Skip to content

Commit

Permalink
tgui 4.3 (#56080)
Browse files Browse the repository at this point in the history
  • Loading branch information
stylemistake authored Jan 17, 2021
1 parent 113b92a commit a6e60e4
Show file tree
Hide file tree
Showing 151 changed files with 4,436 additions and 7,358 deletions.
2 changes: 1 addition & 1 deletion code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/datum/asset/simple/tgui_common
keep_local_name = TRUE
assets = list(
"tgui-common.chunk.js" = 'tgui/public/tgui-common.chunk.js',
"tgui-common.bundle.js" = 'tgui/public/tgui-common.bundle.js',
)

/datum/asset/simple/tgui
Expand Down
5 changes: 2 additions & 3 deletions code/modules/client/client_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,9 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
set_macros()

// Initialize tgui panel
tgui_panel.initialize()
src << browse(file('html/statbrowser.html'), "window=statbrowser")
addtimer(CALLBACK(src, .proc/check_panel_loaded), 30 SECONDS)

tgui_panel.initialize()

if(alert_mob_dupe_login)
spawn()
Expand Down Expand Up @@ -459,7 +458,7 @@ GLOBAL_LIST_INIT(blacklisted_builds, list(
var/announce_join = mob.client?.prefs?.broadcast_login_logout
if (!stealth_admin)
deadchat_broadcast(" has disconnected.", "<b>[mob][mob.get_realname_string()]</b>", follow_target = mob, turf_target = get_turf(mob), message_type = DEADCHAT_LOGIN_LOGOUT, admin_only=!announce_join)

GLOB.clients -= src
GLOB.directory -= ckey
log_access("Logout: [key_name(src)]")
Expand Down
5 changes: 3 additions & 2 deletions code/modules/tgui/tgui_window.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@
html = replacetextEx(html, "<!-- tgui:html -->\n", inline_html)
// Open the window
client << browse(html, "window=[id];[options]")
// Instruct the client to signal UI when the window is closed.
winset(client, id, "on-close=\"uiclose [id]\"")
// Detect whether the control is a browser
is_browser = winexists(client, id) == "BROWSER"
// Instruct the client to signal UI when the window is closed.
if(!is_browser)
winset(client, id, "on-close=\"uiclose [id]\"")

/**
* public
Expand Down
5 changes: 4 additions & 1 deletion code/modules/tgui_panel/tgui_panel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
* Initializes tgui panel.
*/
/datum/tgui_panel/proc/initialize(force = FALSE)
set waitfor = FALSE
// Minimal sleep to defer initialization to after client constructor
sleep(1)
initialized_at = world.time
// Perform a clean initialization
window.initialize(inline_assets = list(
Expand All @@ -46,7 +49,7 @@
window.send_asset(get_asset_datum(/datum/asset/simple/namespaced/fontawesome))
window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat))
request_telemetry()
addtimer(CALLBACK(src, .proc/on_initialize_timed_out), 2 SECONDS)
addtimer(CALLBACK(src, .proc/on_initialize_timed_out), 5 SECONDS)

/**
* private
Expand Down
2 changes: 1 addition & 1 deletion tgui/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/.yarn/**
/**/node_modules
/**/*.bundle.*
/**/*.chunk.*
/**/*.hot-update.*
/packages/inferno/**
/packages/tgui/public/shim-*.js
1 change: 1 addition & 0 deletions tgui/.eslintrc-harder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ rules:
selfClosing: after-props,
nonEmpty: after-props,
}]
react/display-name: error
4 changes: 2 additions & 2 deletions tgui/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
parser: babel-eslint
parser: '@babel/eslint-parser'
parserOptions:
ecmaVersion: 2019
sourceType: module
Expand Down Expand Up @@ -583,7 +583,7 @@ rules:
## Rule enforces consistent usage of destructuring assignment in component
# react/destructuring-assignment: [error, always, { ignoreClassFields: true }]
## Prevent missing displayName in a React component definition
react/display-name: error
# react/display-name: error
## Forbid certain props on Components
# react/forbid-component-props: error
## Forbid certain props on DOM Nodes
Expand Down
55 changes: 55 additions & 0 deletions tgui/.yarn/releases/yarn-2.4.0.cjs

Large diffs are not rendered by default.

55 changes: 0 additions & 55 deletions tgui/.yarn/releases/yarn.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion tgui/.yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn.cjs
yarnPath: .yarn/releases/yarn-2.4.0.cjs
37 changes: 37 additions & 0 deletions tgui/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/

const createBabelConfig = options => {
const { mode, presets = [], plugins = [] } = options;
return {
presets: [
['@babel/preset-env', {
modules: 'commonjs',
useBuiltIns: 'entry',
corejs: '3.8',
spec: false,
loose: true,
targets: [],
}],
...presets,
],
plugins: [
'@babel/plugin-transform-jscript',
'babel-plugin-inferno',
'babel-plugin-transform-remove-console',
'common/string.babel-plugin.cjs',
...plugins,
],
};
};

module.exports = (api) => {
api.cache(true);
const mode = process.env.NODE_ENV;
return createBabelConfig({ mode });
};

module.exports.createBabelConfig = createBabelConfig;
9 changes: 7 additions & 2 deletions tgui/bin/tgui
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ fi

## Fall back to running Yarn from the repo
if ! hash yarn 2>/dev/null; then
alias yarn="node '${base_dir}/.yarn/releases/yarn.cjs'"
yarn_releases=("${base_dir}"/.yarn/releases/yarn-*.cjs)
yarn_release="${yarn_releases[0]}"
yarn() {
node "${yarn_release}" "${@}"
}
fi


Expand Down Expand Up @@ -77,6 +81,7 @@ task-clean() {
## Yarn artifacts
rm -rf .yarn/cache
rm -rf .yarn/unplugged
rm -rf .yarn/webpack
rm -rf .yarn/build-state.yml
rm -rf .yarn/install-state.gz
rm -f .pnp.js
Expand Down Expand Up @@ -177,7 +182,7 @@ fi
## Make a production webpack build + Run eslint
if [[ -z ${1} ]]; then
task-install
task-eslint
task-eslint --fix
task-webpack --mode=production
exit 0
fi
Expand Down
2 changes: 1 addition & 1 deletion tgui/bin/tgui-dev-server.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
rem Copyright (c) 2020 Aleksej Komarov
rem SPDX-License-Identifier: MIT
call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\tgui.ps1" --dev %*
call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\tgui_.ps1" --dev %*
rem Pause if launched in a separate shell unless initiated from powershell
echo %PSModulePath% | findstr %USERPROFILE% >NUL
if %errorlevel% equ 0 exit 0
Expand Down
2 changes: 1 addition & 1 deletion tgui/bin/tgui.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@echo off
rem Copyright (c) 2020 Aleksej Komarov
rem SPDX-License-Identifier: MIT
call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\tgui.ps1" %*
call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\tgui_.ps1" %*
rem Pause if launched in a separate shell unless initiated from powershell
echo %PSModulePath% | findstr %USERPROFILE% >NUL
if %errorlevel% equ 0 exit 0
Expand Down
95 changes: 56 additions & 39 deletions tgui/bin/tgui.ps1 → tgui/bin/tgui_.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@
## Initial set-up
## --------------------------------------------------------

## Enable strict mode and stop of first cmdlet error
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'

## Validates exit code of external commands
function Throw-On-Native-Failure {
if (-not $?) {
exit 1
}
}

## Normalize current directory
$basedir = Split-Path $MyInvocation.MyCommand.Path
$basedir = Resolve-Path "$($basedir)\.."
Expand All @@ -15,7 +27,9 @@ Set-Location $basedir
## --------------------------------------------------------

function yarn {
node.exe ".yarn\releases\yarn.cjs" @Args
$YarnRelease = Get-ChildItem -Filter ".yarn\releases\yarn-*.cjs" | Select-Object -First 1
node ".yarn\releases\$YarnRelease" @Args
Throw-On-Native-Failure
}

function Remove-Quiet {
Expand Down Expand Up @@ -51,6 +65,7 @@ function task-clean {
## Yarn artifacts
Remove-Quiet -Recurse -Force ".yarn\cache"
Remove-Quiet -Recurse -Force ".yarn\unplugged"
Remove-Quiet -Recurse -Force ".yarn\webpack"
Remove-Quiet -Recurse -Force ".yarn\build-state.yml"
Remove-Quiet -Recurse -Force ".yarn\install-state.gz"
Remove-Quiet -Force ".pnp.js"
Expand All @@ -63,44 +78,46 @@ function task-clean {
## Main
## --------------------------------------------------------

if ($Args[0] -eq "--clean") {
task-clean
exit 0
}

if ($Args[0] -eq "--dev") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-dev-server @Rest
exit 0
}

if ($Args[0] -eq "--lint") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-eslint @Rest
exit 0
}

if ($Args[0] -eq "--lint-harder") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-eslint -c ".eslintrc-harder.yml" @Rest
exit 0
}

if ($Args[0] -eq "--fix") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-eslint --fix @Rest
exit 0
}

## Analyze the bundle
if ($Args[0] -eq "--analyze") {
task-install
task-webpack --mode=production --analyze
exit 0
if ($Args.Length -gt 0) {
if ($Args[0] -eq "--clean") {
task-clean
exit 0
}

if ($Args[0] -eq "--dev") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-dev-server @Rest
exit 0
}

if ($Args[0] -eq "--lint") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-eslint @Rest
exit 0
}

if ($Args[0] -eq "--lint-harder") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-eslint -c ".eslintrc-harder.yml" @Rest
exit 0
}

if ($Args[0] -eq "--fix") {
$Rest = $Args | Select-Object -Skip 1
task-install
task-eslint --fix @Rest
exit 0
}

## Analyze the bundle
if ($Args[0] -eq "--analyze") {
task-install
task-webpack --mode=production --analyze
exit 0
}
}

## Make a production webpack build
Expand Down
Loading

0 comments on commit a6e60e4

Please sign in to comment.