More TGUI Maintenance

This commit is contained in:
Casey
2022-06-05 17:58:12 -04:00
committed by CHOMPStation2
parent b0b0ec8bc4
commit 1e7c0c6685
39 changed files with 309 additions and 111 deletions

View File

@@ -1,9 +1,4 @@
//DEFINITIONS FOR ASSET DATUMS START HERE. //DEFINITIONS FOR ASSET DATUMS START HERE.
/datum/asset/simple/tgui_common
// keep_local_name = TRUE
assets = list(
"tgui-common.bundle.js" = file("tgui/public/tgui-common.bundle.js"),
)
/datum/asset/simple/tgui /datum/asset/simple/tgui
// keep_local_name = TRUE // keep_local_name = TRUE

View File

@@ -93,9 +93,8 @@
window.initialize( window.initialize(
fancy = user.client.prefs.tgui_fancy, fancy = user.client.prefs.tgui_fancy,
assets = list( assets = list(
get_asset_datum(/datum/asset/simple/tgui_common), get_asset_datum(/datum/asset/simple/tgui),
get_asset_datum(/datum/asset/simple/tgui) ))
))
else else
window.send_message("ping") window.send_message("ping")
window.send_asset(get_asset_datum(/datum/asset/simple/fontawesome)) window.send_asset(get_asset_datum(/datum/asset/simple/fontawesome))

View File

@@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View File

@@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View File

@@ -1,6 +1,6 @@
{ {
"name": "eslint", "name": "eslint",
"version": "7.21.0-pnpify", "version": "7.32.0-sdk",
"main": "./lib/api.js", "main": "./lib/api.js",
"type": "commonjs" "type": "commonjs"
} }

View File

@@ -1,5 +1,5 @@
# This file is automatically generated by PnPify. # This file is automatically generated by @yarnpkg/sdks.
# Manual changes will be lost! # Manual changes might be lost!
integrations: integrations:
- vscode - vscode

View File

@@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View File

@@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View File

@@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View File

@@ -4,15 +4,22 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const moduleWrapper = tsserver => { const moduleWrapper = tsserver => {
if (!process.versions.pnp) {
return tsserver;
}
const {isAbsolute} = require(`path`); const {isAbsolute} = require(`path`);
const pnpApi = require(`pnpapi`); const pnpApi = require(`pnpapi`);
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => { const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
return `${locator.name}@${locator.reference}`; return `${locator.name}@${locator.reference}`;
})); }));
@@ -23,9 +30,9 @@ const moduleWrapper = tsserver => {
function toEditorPath(str) { function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths // We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || str.match(/\$\$virtual\//))) { if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || isVirtual(str))) {
// We also take the opportunity to turn virtual paths into physical ones; // We also take the opportunity to turn virtual paths into physical ones;
// this makes is much easier to work with workspaces that list peer // this makes it much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual // dependencies, since otherwise Ctrl+Click would bring us to the virtual
// file instances instead of the real ones. // file instances instead of the real ones.
// //
@@ -34,26 +41,49 @@ const moduleWrapper = tsserver => {
// with peer dep (otherwise jumping into react-dom would show resolution // with peer dep (otherwise jumping into react-dom would show resolution
// errors on react). // errors on react).
// //
const resolved = pnpApi.resolveVirtual(str); const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
if (resolved) { if (resolved) {
const locator = pnpApi.findPackageLocator(resolved); const locator = pnpApi.findPackageLocator(resolved);
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) { if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
str = resolved; str = resolved;
} }
} }
str = str.replace(/\\/g, `/`) str = normalize(str);
str = str.replace(/^\/?/, `/`);
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
if (str.match(/\.zip\//)) { if (str.match(/\.zip\//)) {
str = `${isVSCode ? `^` : ``}zip:${str}`; switch (hostInfo) {
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
case `vscode`: {
str = `^zip:${str}`;
} break;
// To make "go to definition" work,
// We have to resolve the actual file system path from virtual path
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
case `coc-nvim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = resolve(`zipfile:${str}`);
} break;
// Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
// We have to resolve the actual file system path from virtual path,
// everything else is up to neovim
case `neovim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = `zipfile:${str}`;
} break;
default: {
str = `zip:${str}`;
} break;
}
} }
} }
@@ -66,15 +96,29 @@ const moduleWrapper = tsserver => {
: str.replace(/^\^?zip:/, ``); : str.replace(/^\^?zip:/, ``);
} }
// Force enable 'allowLocalPluginLoads'
// TypeScript tries to resolve plugins using a path relative to itself
// which doesn't work when using the global cache
// https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
// VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
// TypeScript already does local loads and if this code is running the user trusts the workspace
// https://github.com/microsoft/vscode/issues/45856
const ConfiguredProject = tsserver.server.ConfiguredProject;
const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
ConfiguredProject.prototype.enablePluginsWithOptions = function() {
this.projectService.allowLocalPluginLoads = true;
return originalEnablePluginsWithOptions.apply(this, arguments);
};
// And here is the point where we hijack the VSCode <-> TS communications // And here is the point where we hijack the VSCode <-> TS communications
// by adding ourselves in the middle. We locate everything that looks // by adding ourselves in the middle. We locate everything that looks
// like an absolute path of ours and normalize it. // like an absolute path of ours and normalize it.
const Session = tsserver.server.Session; const Session = tsserver.server.Session;
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype; const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
let isVSCode = false; let hostInfo = `unknown`;
return Object.assign(Session.prototype, { Object.assign(Session.prototype, {
onMessage(/** @type {string} */ message) { onMessage(/** @type {string} */ message) {
const parsedMessage = JSON.parse(message) const parsedMessage = JSON.parse(message)
@@ -82,9 +126,9 @@ const moduleWrapper = tsserver => {
parsedMessage != null && parsedMessage != null &&
typeof parsedMessage === `object` && typeof parsedMessage === `object` &&
parsedMessage.arguments && parsedMessage.arguments &&
parsedMessage.arguments.hostInfo === `vscode` typeof parsedMessage.arguments.hostInfo === `string`
) { ) {
isVSCode = true; hostInfo = parsedMessage.arguments.hostInfo;
} }
return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => { return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
@@ -98,6 +142,8 @@ const moduleWrapper = tsserver => {
}))); })));
} }
}); });
return tsserver;
}; };
if (existsSync(absPnpApiPath)) { if (existsSync(absPnpApiPath)) {

View File

@@ -0,0 +1,157 @@
#!/usr/bin/env node
const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
const moduleWrapper = tsserver => {
if (!process.versions.pnp) {
return tsserver;
}
const {isAbsolute} = require(`path`);
const pnpApi = require(`pnpapi`);
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
return `${locator.name}@${locator.reference}`;
}));
// VSCode sends the zip paths to TS using the "zip://" prefix, that TS
// doesn't understand. This layer makes sure to remove the protocol
// before forwarding it to TS, and to add it back on all returned paths.
function toEditorPath(str) {
// We add the `zip:` prefix to both `.zip/` paths and virtual paths
if (isAbsolute(str) && !str.match(/^\^zip:/) && (str.match(/\.zip\//) || isVirtual(str))) {
// We also take the opportunity to turn virtual paths into physical ones;
// this makes it much easier to work with workspaces that list peer
// dependencies, since otherwise Ctrl+Click would bring us to the virtual
// file instances instead of the real ones.
//
// We only do this to modules owned by the the dependency tree roots.
// This avoids breaking the resolution when jumping inside a vendor
// with peer dep (otherwise jumping into react-dom would show resolution
// errors on react).
//
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
if (resolved) {
const locator = pnpApi.findPackageLocator(resolved);
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
str = resolved;
}
}
str = normalize(str);
if (str.match(/\.zip\//)) {
switch (hostInfo) {
// Absolute VSCode `Uri.fsPath`s need to start with a slash.
// VSCode only adds it automatically for supported schemes,
// so we have to do it manually for the `zip` scheme.
// The path needs to start with a caret otherwise VSCode doesn't handle the protocol
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
case `vscode`: {
str = `^zip:${str}`;
} break;
// To make "go to definition" work,
// We have to resolve the actual file system path from virtual path
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
case `coc-nvim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = resolve(`zipfile:${str}`);
} break;
// Support neovim native LSP and [typescript-language-server](https://github.com/theia-ide/typescript-language-server)
// We have to resolve the actual file system path from virtual path,
// everything else is up to neovim
case `neovim`: {
str = normalize(resolved).replace(/\.zip\//, `.zip::`);
str = `zipfile:${str}`;
} break;
default: {
str = `zip:${str}`;
} break;
}
}
}
return str;
}
function fromEditorPath(str) {
return process.platform === `win32`
? str.replace(/^\^?zip:\//, ``)
: str.replace(/^\^?zip:/, ``);
}
// Force enable 'allowLocalPluginLoads'
// TypeScript tries to resolve plugins using a path relative to itself
// which doesn't work when using the global cache
// https://github.com/microsoft/TypeScript/blob/1b57a0395e0bff191581c9606aab92832001de62/src/server/project.ts#L2238
// VSCode doesn't want to enable 'allowLocalPluginLoads' due to security concerns but
// TypeScript already does local loads and if this code is running the user trusts the workspace
// https://github.com/microsoft/vscode/issues/45856
const ConfiguredProject = tsserver.server.ConfiguredProject;
const {enablePluginsWithOptions: originalEnablePluginsWithOptions} = ConfiguredProject.prototype;
ConfiguredProject.prototype.enablePluginsWithOptions = function() {
this.projectService.allowLocalPluginLoads = true;
return originalEnablePluginsWithOptions.apply(this, arguments);
};
// And here is the point where we hijack the VSCode <-> TS communications
// by adding ourselves in the middle. We locate everything that looks
// like an absolute path of ours and normalize it.
const Session = tsserver.server.Session;
const {onMessage: originalOnMessage, send: originalSend} = Session.prototype;
let hostInfo = `unknown`;
Object.assign(Session.prototype, {
onMessage(/** @type {string} */ message) {
const parsedMessage = JSON.parse(message)
if (
parsedMessage != null &&
typeof parsedMessage === `object` &&
parsedMessage.arguments &&
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
}
return originalOnMessage.call(this, JSON.stringify(parsedMessage, (key, value) => {
return typeof value === `string` ? fromEditorPath(value) : value;
}));
},
send(/** @type {any} */ msg) {
return originalSend.call(this, JSON.parse(JSON.stringify(msg, (key, value) => {
return typeof value === `string` ? toEditorPath(value) : value;
})));
}
});
return tsserver;
};
if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/tsserverlibrary.js
require(absPnpApiPath).setup();
}
}
// Defer to the real typescript/lib/tsserverlibrary.js your application uses
module.exports = moduleWrapper(absRequire(`typescript/lib/tsserverlibrary.js`));

View File

@@ -4,7 +4,7 @@ const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`); const {createRequire, createRequireFromPath} = require(`module`);
const {resolve} = require(`path`); const {resolve} = require(`path`);
const relPnpApiPath = "../../../../.pnp.js"; const relPnpApiPath = "../../../../.pnp.cjs";
const absPnpApiPath = resolve(__dirname, relPnpApiPath); const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);

View File

@@ -1,6 +1,6 @@
{ {
"name": "typescript", "name": "typescript",
"version": "4.2.3-pnpify", "version": "4.3.5-sdk",
"main": "./lib/typescript.js", "main": "./lib/typescript.js",
"type": "commonjs" "type": "commonjs"
} }

View File

@@ -14,7 +14,7 @@ const createBabelConfig = options => {
[require.resolve('@babel/preset-env'), { [require.resolve('@babel/preset-env'), {
modules: 'commonjs', modules: 'commonjs',
useBuiltIns: 'entry', useBuiltIns: 'entry',
corejs: '3.10', corejs: '3',
spec: false, spec: false,
loose: true, loose: true,
targets: [], targets: [],

View File

@@ -59,7 +59,7 @@ task-webpack() {
## Runs a development server ## Runs a development server
task-dev-server() { task-dev-server() {
cd "${base_dir}" cd "${base_dir}"
yarn node packages/tgui-dev-server/index.esm.js "${@}" yarn node --experimental-modules packages/tgui-dev-server/index.js "${@}"
} }
## Run a linter through all packages ## Run a linter through all packages

View File

@@ -47,7 +47,7 @@ function task-webpack {
## Runs a development server ## Runs a development server
function task-dev-server { function task-dev-server {
yarn node "packages/tgui-dev-server/index.esm.js" @Args yarn node --experimental-modules "packages/tgui-dev-server/index.js" @Args
} }
## Run a linter through all packages ## Run a linter through all packages

View File

@@ -2,6 +2,7 @@
"private": true, "private": true,
"name": "tgui-workspace", "name": "tgui-workspace",
"version": "4.4.0", "version": "4.4.0",
"packageManager": "yarn@3.2.1",
"workspaces": [ "workspaces": [
"packages/*" "packages/*"
], ],

View File

@@ -4,11 +4,12 @@
* @license MIT * @license MIT
*/ */
import axios from 'axios';
import { exec } from 'child_process'; import { exec } from 'child_process';
import { createLogger } from 'common/logging.js';
import { promisify } from 'util'; import { promisify } from 'util';
import { createLogger } from './logging.js';
import { require } from './require.js';
const axios = require('axios');
const logger = createLogger('dreamseeker'); const logger = createLogger('dreamseeker');
const instanceByPid = new Map(); const instanceByPid = new Map();

View File

@@ -1,5 +0,0 @@
const esmRequire = require('esm')(module, {
cache: false,
});
esmRequire('./index.js');

View File

@@ -37,7 +37,7 @@ if (process.env.NODE_ENV !== 'production') {
window.onunload = () => socket && socket.close(); window.onunload = () => socket && socket.close();
} }
export const subscribe = fn => subscribers.push(fn); const subscribe = fn => subscribers.push(fn);
/** /**
* A json serializer which handles circular references and other junk. * A json serializer which handles circular references and other junk.
@@ -91,7 +91,7 @@ const serializeObject = obj => {
return json; return json;
}; };
export const sendMessage = msg => { const sendMessage = msg => {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
const json = serializeObject(msg); const json = serializeObject(msg);
// Send message using WebSocket // Send message using WebSocket
@@ -119,7 +119,7 @@ export const sendMessage = msg => {
} }
}; };
export const sendLogEntry = (level, ns, ...args) => { const sendLogEntry = (level, ns, ...args) => {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
try { try {
sendMessage({ sendMessage({
@@ -135,7 +135,7 @@ export const sendLogEntry = (level, ns, ...args) => {
} }
}; };
export const setupHotReloading = () => { const setupHotReloading = () => {
if (process.env.NODE_ENV !== 'production' if (process.env.NODE_ENV !== 'production'
&& process.env.WEBPACK_HMR_ENABLED && process.env.WEBPACK_HMR_ENABLED
&& window.WebSocket) { && window.WebSocket) {
@@ -168,3 +168,10 @@ export const setupHotReloading = () => {
} }
} }
}; };
module.exports = {
subscribe,
sendMessage,
sendLogEntry,
setupHotReloading,
};

View File

@@ -4,13 +4,15 @@
* @license MIT * @license MIT
*/ */
import { createLogger } from 'common/logging.js';
import fs from 'fs'; import fs from 'fs';
import { basename } from 'path'; import { basename } from 'path';
import SourceMap from 'source-map'; import { createLogger } from '../logging.js';
import { parse as parseStackTrace } from 'stacktrace-parser'; import { require } from '../require.js';
import { resolveGlob } from '../util.js'; import { resolveGlob } from '../util.js';
const SourceMap = require('source-map');
const { parse: parseStackTrace } = require('stacktrace-parser');
const logger = createLogger('retrace'); const logger = createLogger('retrace');
const { SourceMapConsumer } = SourceMap; const { SourceMapConsumer } = SourceMap;

View File

@@ -4,11 +4,13 @@
* @license MIT * @license MIT
*/ */
import { createLogger, directLog } from 'common/logging.js';
import http from 'http'; import http from 'http';
import { inspect } from 'util'; import { inspect } from 'util';
import WebSocket from 'ws'; import { createLogger, directLog } from '../logging.js';
import { retrace, loadSourceMaps } from './retrace.js'; import { require } from '../require.js';
import { loadSourceMaps, retrace } from './retrace.js';
const WebSocket = require('ws');
const logger = createLogger('link'); const logger = createLogger('link');

View File

@@ -2,10 +2,9 @@
"private": true, "private": true,
"name": "tgui-dev-server", "name": "tgui-dev-server",
"version": "4.3.0", "version": "4.3.0",
"type": "module",
"dependencies": { "dependencies": {
"axios": "^0.27.2", "axios": "^0.27.2",
"common": "workspace:*",
"esm": "^3.2.25",
"glob": "^8.0.3", "glob": "^8.0.3",
"source-map": "^0.7.3", "source-map": "^0.7.3",
"stacktrace-parser": "^0.1.10", "stacktrace-parser": "^0.1.10",

View File

@@ -4,13 +4,13 @@
* @license MIT * @license MIT
*/ */
import { createLogger } from 'common/logging.js';
import fs from 'fs'; import fs from 'fs';
import os from 'os'; import os from 'os';
import { basename } from 'path'; import { basename } from 'path';
import { DreamSeeker } from './dreamseeker.js';
import { createLogger } from './logging.js';
import { resolveGlob, resolvePath } from './util.js'; import { resolveGlob, resolvePath } from './util.js';
import { regQuery } from './winreg.js'; import { regQuery } from './winreg.js';
import { DreamSeeker } from './dreamseeker.js';
const logger = createLogger('reloader'); const logger = createLogger('reloader');

View File

@@ -0,0 +1,9 @@
/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { createRequire } from 'module';
export const require = createRequire(import.meta.url);

View File

@@ -4,26 +4,26 @@
* @license MIT * @license MIT
*/ */
import glob from 'glob';
import { resolve as resolvePath } from 'path';
import fs from 'fs'; import fs from 'fs';
import { promisify } from 'util'; import path from 'path';
import { require } from './require.js';
export { resolvePath }; const globPkg = require('glob');
export const resolvePath = path.resolve;
/** /**
* Combines path.resolve with glob patterns. * Combines path.resolve with glob patterns.
*/ */
export const resolveGlob = async (...sections) => { export const resolveGlob = (...sections) => {
const unsafePaths = await promisify(glob)( const unsafePaths = globPkg.sync(path.resolve(...sections), {
resolvePath(...sections), { strict: false,
strict: false, silent: true,
silent: true, });
});
const safePaths = []; const safePaths = [];
for (let path of unsafePaths) { for (let path of unsafePaths) {
try { try {
await promisify(fs.stat)(path); fs.statSync(path);
safePaths.push(path); safePaths.push(path);
} }
catch {} catch {}

View File

@@ -4,11 +4,11 @@
* @license MIT * @license MIT
*/ */
import { createLogger } from 'common/logging.js';
import fs from 'fs'; import fs from 'fs';
import { createRequire } from 'module'; import { createRequire } from 'module';
import { dirname } from 'path'; import { dirname } from 'path';
import { loadSourceMaps, setupLink } from './link/server.js'; import { loadSourceMaps, setupLink } from './link/server.js';
import { createLogger } from './logging.js';
import { reloadByondCache } from './reloader.js'; import { reloadByondCache } from './reloader.js';
import { resolveGlob } from './util.js'; import { resolveGlob } from './util.js';

View File

@@ -7,8 +7,8 @@
*/ */
import { exec } from 'child_process'; import { exec } from 'child_process';
import { createLogger } from 'common/logging.js';
import { promisify } from 'util'; import { promisify } from 'util';
import { createLogger } from './logging.js';
const logger = createLogger('winreg'); const logger = createLogger('winreg');

View File

@@ -10,7 +10,7 @@ import './styles/themes/light.scss';
import { perf } from 'common/perf'; import { perf } from 'common/perf';
import { combineReducers } from 'common/redux'; import { combineReducers } from 'common/redux';
import { setupHotReloading } from 'tgui-dev-server/link/client'; import { setupHotReloading } from 'tgui-dev-server/link/client.cjs';
import { setupGlobalEvents } from 'tgui/events'; import { setupGlobalEvents } from 'tgui/events';
import { captureExternalLinks } from 'tgui/links'; import { captureExternalLinks } from 'tgui/links';
import { createRenderer } from 'tgui/renderer'; import { createRenderer } from 'tgui/renderer';

View File

@@ -39,7 +39,7 @@ export const debugMiddleware = store => {
}; };
export const relayMiddleware = store => { export const relayMiddleware = store => {
const devServer = require('tgui-dev-server/link/client'); const devServer = require('tgui-dev-server/link/client.cjs');
const externalBrowser = location.search === '?external'; const externalBrowser = location.search === '?external';
if (externalBrowser) { if (externalBrowser) {
devServer.subscribe(msg => { devServer.subscribe(msg => {

View File

@@ -20,7 +20,7 @@ import './styles/themes/wizard.scss';
import './styles/themes/abstract.scss'; import './styles/themes/abstract.scss';
import { perf } from 'common/perf'; import { perf } from 'common/perf';
import { setupHotReloading } from 'tgui-dev-server/link/client'; import { setupHotReloading } from 'tgui-dev-server/link/client.cjs';
import { setupHotKeys } from './hotkeys'; import { setupHotKeys } from './hotkeys';
import { captureExternalLinks } from './links'; import { captureExternalLinks } from './links';
import { createRenderer } from './renderer'; import { createRenderer } from './renderer';

View File

@@ -4,7 +4,7 @@
* @license MIT * @license MIT
*/ */
import { sendLogEntry } from 'tgui-dev-server/link/client'; import { sendLogEntry } from 'tgui-dev-server/link/client.cjs';
const LEVEL_DEBUG = 0; const LEVEL_DEBUG = 0;
const LEVEL_LOG = 1; const LEVEL_LOG = 1;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,28 +1,23 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es3",
"noEmit": true,
"strict": false,
"allowJs": true, "allowJs": true,
"checkJs": false,
"jsx": "preserve",
"lib": [
"dom",
"dom.iterable",
"esnext",
"ScriptHost"
],
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"checkJs": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"module": "esnext", "isolatedModules": false,
"moduleResolution": "node", "jsx": "preserve",
"lib": ["DOM", "DOM.Iterable", "ESNext", "ScriptHost"],
"module": "ESNext",
"moduleResolution": "Node",
"noEmit": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": false "skipLibCheck": true,
"strict": false,
"target": "ES3"
}, },
"include": [ "include": [
"./global.d.ts", "./*.d.ts",
"./packages" "./packages"
] ]
} }

View File

@@ -98,10 +98,6 @@ module.exports = (env = {}, argv) => {
}, },
optimization: { optimization: {
emitOnErrors: false, emitOnErrors: false,
splitChunks: {
chunks: 'initial',
name: 'tgui-common',
},
}, },
performance: { performance: {
hints: false, hints: false,

View File

@@ -4264,13 +4264,6 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"esm@npm:^3.2.25":
version: 3.2.25
resolution: "esm@npm:3.2.25"
checksum: 978aabe2de83541c105605a6d60a26ed8e627ef6bb0a7605fe15a95bbdea6b8348bd045255cb22219c054dd09a81a94823df00843d9e97f42419c92015ce3a64
languageName: node
linkType: hard
"espree@npm:^9.3.2": "espree@npm:^9.3.2":
version: 9.3.2 version: 9.3.2
resolution: "espree@npm:9.3.2" resolution: "espree@npm:9.3.2"
@@ -8668,8 +8661,6 @@ resolve@^2.0.0-next.3:
resolution: "tgui-dev-server@workspace:packages/tgui-dev-server" resolution: "tgui-dev-server@workspace:packages/tgui-dev-server"
dependencies: dependencies:
axios: ^0.27.2 axios: ^0.27.2
common: "workspace:*"
esm: ^3.2.25
glob: ^8.0.3 glob: ^8.0.3
source-map: ^0.7.3 source-map: ^0.7.3
stacktrace-parser: ^0.1.10 stacktrace-parser: ^0.1.10