@steambrew/ttc 1.2.2 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +9 -0
- package/Compiler.ts +226 -291
- package/Linter.ts +43 -43
- package/Logger.ts +48 -48
- package/Parameters.ts +71 -71
- package/PluginSetup.ts +259 -0
- package/VersionMon.ts +27 -27
- package/dist/index.js +230 -104
- package/index.ts +64 -64
- package/package.json +38 -40
- package/rollup.config.js +31 -31
- package/tsconfig.json +23 -23
package/dist/index.js
CHANGED
|
@@ -166,91 +166,215 @@ const ValidatePlugin = (target) => {
|
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
-
const envConfig = dotenv.config().parsed || {};
|
|
170
|
-
if (envConfig) {
|
|
171
|
-
Logger.Info("Injecting environment variables...");
|
|
172
|
-
}
|
|
173
|
-
const envVars = Object.keys(envConfig).reduce((acc, key) => {
|
|
174
|
-
acc[key] = envConfig[key];
|
|
175
|
-
return acc;
|
|
176
|
-
}, {});
|
|
177
|
-
const WrappedCallServerMethod = "const __call_server_method__ = (methodName, kwargs) => Millennium.callServerMethod(pluginName, methodName, kwargs)";
|
|
178
|
-
const WrappedCallable = "const __wrapped_callable__ = (route) => MILLENNIUM_API.callable(__call_server_method__, route)";
|
|
179
169
|
/**
|
|
180
170
|
* @description Append the active plugin to the global plugin
|
|
181
171
|
* list and notify that the frontend Loaded.
|
|
182
172
|
*/
|
|
183
173
|
function ExecutePluginModule() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
174
|
+
let MillenniumStore = window.MILLENNIUM_PLUGIN_SETTINGS_STORE[pluginName];
|
|
175
|
+
function OnPluginConfigChange(key, __, value) {
|
|
176
|
+
if (key in MillenniumStore.settingsStore) {
|
|
177
|
+
MillenniumStore.ignoreProxyFlag = true;
|
|
178
|
+
MillenniumStore.settingsStore[key] = value;
|
|
179
|
+
MillenniumStore.ignoreProxyFlag = false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Expose the OnPluginConfigChange so it can be called externally */
|
|
183
|
+
MillenniumStore.OnPluginConfigChange = OnPluginConfigChange;
|
|
184
|
+
MILLENNIUM_BACKEND_IPC.postMessage(0, { pluginName: pluginName, methodName: '__builtins__.__millennium_plugin_settings_parser__' }).then((response) => {
|
|
185
|
+
/**
|
|
186
|
+
* __millennium_plugin_settings_parser__ will return false if the plugin has no settings.
|
|
187
|
+
* If the plugin has settings, it will return a base64 encoded string.
|
|
188
|
+
* The string is then decoded and parsed into an object.
|
|
189
|
+
*/
|
|
190
|
+
if (typeof response.returnValue === 'string') {
|
|
191
|
+
MillenniumStore.ignoreProxyFlag = true;
|
|
192
|
+
/** Initialize the settings store from the settings returned from the backend. */
|
|
193
|
+
MillenniumStore.settingsStore = MillenniumStore.DefinePluginSetting(Object.fromEntries(JSON.parse(atob(response.returnValue)).map((item) => [item.functionName, item])));
|
|
194
|
+
MillenniumStore.ignoreProxyFlag = false;
|
|
195
|
+
}
|
|
196
|
+
/** @ts-ignore: call the plugin main after the settings have been parsed. This prevent plugin settings from being undefined at top level. */
|
|
197
|
+
let PluginModule = PluginEntryPointMain();
|
|
198
|
+
/** Assign the plugin on plugin list. */
|
|
199
|
+
Object.assign(window.PLUGIN_LIST[pluginName], {
|
|
200
|
+
...PluginModule,
|
|
201
|
+
__millennium_internal_plugin_name_do_not_use_or_change__: pluginName,
|
|
202
|
+
});
|
|
203
|
+
/** Run the rolled up plugins default exported function */
|
|
204
|
+
PluginModule.default();
|
|
205
|
+
/** If the current module is a client module, post message id=1 which calls the front_end_loaded method on the backend. */
|
|
206
|
+
if (MILLENNIUM_IS_CLIENT_MODULE) {
|
|
207
|
+
MILLENNIUM_BACKEND_IPC.postMessage(1, { pluginName: pluginName });
|
|
208
|
+
}
|
|
209
|
+
});
|
|
199
210
|
}
|
|
200
211
|
/**
|
|
201
|
-
* @description
|
|
202
|
-
*
|
|
212
|
+
* @description Initialize the plugins settings store and the plugin list.
|
|
213
|
+
* This function is called once per plugin and is used to store the plugin settings and the plugin list.
|
|
203
214
|
*/
|
|
204
215
|
function InitializePlugins() {
|
|
216
|
+
var _a, _b;
|
|
205
217
|
/**
|
|
206
218
|
* This function is called n times depending on n plugin count,
|
|
207
219
|
* Create the plugin list if it wasn't already created
|
|
208
220
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
(_a = (window.PLUGIN_LIST || (window.PLUGIN_LIST = {})))[pluginName] || (_a[pluginName] = {});
|
|
222
|
+
(_b = (window.MILLENNIUM_PLUGIN_SETTINGS_STORE || (window.MILLENNIUM_PLUGIN_SETTINGS_STORE = {})))[pluginName] || (_b[pluginName] = {});
|
|
223
|
+
/**
|
|
224
|
+
* Accepted IPC message types from Millennium backend.
|
|
225
|
+
*/
|
|
226
|
+
let IPCType;
|
|
227
|
+
(function (IPCType) {
|
|
228
|
+
IPCType[IPCType["CallServerMethod"] = 0] = "CallServerMethod";
|
|
229
|
+
})(IPCType || (IPCType = {}));
|
|
230
|
+
let MillenniumStore = window.MILLENNIUM_PLUGIN_SETTINGS_STORE[pluginName];
|
|
231
|
+
let IPCMessageId = `Millennium.Internal.IPC.[${pluginName}]`;
|
|
232
|
+
let isClientModule = MILLENNIUM_IS_CLIENT_MODULE;
|
|
233
|
+
const ComponentTypeMap = {
|
|
234
|
+
DropDown: ['string', 'number', 'boolean'],
|
|
235
|
+
NumberTextInput: ['number'],
|
|
236
|
+
StringTextInput: ['string'],
|
|
237
|
+
FloatTextInput: ['number'],
|
|
238
|
+
CheckBox: ['boolean'],
|
|
239
|
+
NumberSlider: ['number'],
|
|
240
|
+
FloatSlider: ['number'],
|
|
241
|
+
};
|
|
242
|
+
MillenniumStore.ignoreProxyFlag = false;
|
|
243
|
+
function DelegateToBackend(pluginName, name, value) {
|
|
244
|
+
console.log(`Delegating ${name} to backend`, value);
|
|
245
|
+
// print stack trace
|
|
246
|
+
const stack = new Error().stack?.split('\n').slice(2).join('\n');
|
|
247
|
+
console.log(stack);
|
|
248
|
+
return MILLENNIUM_BACKEND_IPC.postMessage(IPCType.CallServerMethod, {
|
|
249
|
+
pluginName,
|
|
250
|
+
methodName: '__builtins__.__update_settings_value__',
|
|
251
|
+
argumentList: { name, value },
|
|
252
|
+
});
|
|
213
253
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
254
|
+
async function ClientInitializeIPC() {
|
|
255
|
+
/** Wait for the MainWindowBrowser to not be undefined */
|
|
256
|
+
while (typeof MainWindowBrowserManager === 'undefined') {
|
|
257
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
258
|
+
}
|
|
259
|
+
MainWindowBrowserManager.m_browser.on('message', (messageId, data) => {
|
|
260
|
+
if (messageId !== IPCMessageId) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const { name, value } = JSON.parse(data);
|
|
264
|
+
MillenniumStore.ignoreProxyFlag = true;
|
|
265
|
+
MillenniumStore.settingsStore[name] = value;
|
|
266
|
+
DelegateToBackend(pluginName, name, value);
|
|
267
|
+
MillenniumStore.ignoreProxyFlag = false;
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
function WebkitInitializeIPC() {
|
|
271
|
+
SteamClient.BrowserView.RegisterForMessageFromParent((messageId, data) => {
|
|
272
|
+
if (messageId !== IPCMessageId) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
const payload = JSON.parse(data);
|
|
276
|
+
MillenniumStore.ignoreProxyFlag = true;
|
|
277
|
+
MillenniumStore.settingsStore[payload.name] = payload.value;
|
|
278
|
+
MillenniumStore.ignoreProxyFlag = false;
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
isClientModule ? ClientInitializeIPC() : WebkitInitializeIPC();
|
|
282
|
+
const StartSettingPropagation = (name, value) => {
|
|
283
|
+
if (MillenniumStore.ignoreProxyFlag) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (isClientModule) {
|
|
287
|
+
DelegateToBackend(pluginName, name, value);
|
|
288
|
+
/** If the browser doesn't exist yet, no use sending anything to it. */
|
|
289
|
+
if (typeof MainWindowBrowserManager !== 'undefined') {
|
|
290
|
+
MainWindowBrowserManager?.m_browser?.PostMessage(IPCMessageId, JSON.stringify({ name, value }));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
/** Send the message to the SharedJSContext */
|
|
295
|
+
SteamClient.BrowserView.PostMessageToParent(IPCMessageId, JSON.stringify({ name, value }));
|
|
234
296
|
}
|
|
235
297
|
};
|
|
236
|
-
|
|
298
|
+
function clamp(value, min, max) {
|
|
299
|
+
return Math.max(min, Math.min(max, value));
|
|
300
|
+
}
|
|
301
|
+
const DefinePluginSetting = (obj) => {
|
|
302
|
+
return new Proxy(obj, {
|
|
303
|
+
set(target, property, value) {
|
|
304
|
+
if (!(property in target)) {
|
|
305
|
+
throw new TypeError(`Property ${String(property)} does not exist on plugin settings`);
|
|
306
|
+
}
|
|
307
|
+
const settingType = ComponentTypeMap[target[property].type];
|
|
308
|
+
const range = target[property]?.range;
|
|
309
|
+
/** Clamp the value between the given range */
|
|
310
|
+
if (settingType.includes('number') && typeof value === 'number') {
|
|
311
|
+
if (range) {
|
|
312
|
+
value = clamp(value, range[0], range[1]);
|
|
313
|
+
}
|
|
314
|
+
value || (value = 0); // Fallback to 0 if the value is undefined or null
|
|
315
|
+
}
|
|
316
|
+
/** Check if the value is of the proper type */
|
|
317
|
+
if (!settingType.includes(typeof value)) {
|
|
318
|
+
throw new TypeError(`Expected ${settingType.join(' or ')}, got ${typeof value}`);
|
|
319
|
+
}
|
|
320
|
+
target[property].value = value;
|
|
321
|
+
StartSettingPropagation(String(property), value);
|
|
322
|
+
return true;
|
|
323
|
+
},
|
|
324
|
+
get(target, property) {
|
|
325
|
+
if (property === '__raw_get_internals__') {
|
|
326
|
+
return target;
|
|
327
|
+
}
|
|
328
|
+
if (property in target) {
|
|
329
|
+
return target[property].value;
|
|
330
|
+
}
|
|
331
|
+
return undefined;
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
MillenniumStore.DefinePluginSetting = DefinePluginSetting;
|
|
336
|
+
MillenniumStore.settingsStore = DefinePluginSetting({});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const envConfig = dotenv.config().parsed || {};
|
|
340
|
+
if (envConfig) {
|
|
341
|
+
Logger.Info('Injecting environment variables...');
|
|
237
342
|
}
|
|
238
|
-
|
|
343
|
+
const envVars = Object.keys(envConfig).reduce((acc, key) => {
|
|
344
|
+
acc[key] = envConfig[key];
|
|
345
|
+
return acc;
|
|
346
|
+
}, {});
|
|
347
|
+
var ComponentType;
|
|
348
|
+
(function (ComponentType) {
|
|
349
|
+
ComponentType[ComponentType["Plugin"] = 0] = "Plugin";
|
|
350
|
+
ComponentType[ComponentType["Webkit"] = 1] = "Webkit";
|
|
351
|
+
})(ComponentType || (ComponentType = {}));
|
|
352
|
+
const WrappedCallServerMethod = 'const __call_server_method__ = (methodName, kwargs) => Millennium.callServerMethod(pluginName, methodName, kwargs)';
|
|
353
|
+
const WrappedCallable = 'const __wrapped_callable__ = (route) => MILLENNIUM_API.callable(__call_server_method__, route)';
|
|
354
|
+
const ConstructFunctions = (parts) => {
|
|
355
|
+
return parts.join('\n');
|
|
356
|
+
};
|
|
357
|
+
function generate(code) {
|
|
358
|
+
/** Wrap it in a proxy */
|
|
359
|
+
return `let PluginEntryPointMain = function() { ${code} return millennium_main; };`;
|
|
360
|
+
}
|
|
361
|
+
function InsertMillennium(type, props) {
|
|
239
362
|
const generateBundle = (_, bundle) => {
|
|
240
363
|
for (const fileName in bundle) {
|
|
241
|
-
if (bundle[fileName].type !=
|
|
364
|
+
if (bundle[fileName].type != 'chunk') {
|
|
242
365
|
continue;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
bundle[fileName].code =
|
|
366
|
+
}
|
|
367
|
+
Logger.Info('Injecting Millennium shims into ' + ComponentType[type] + ' module... ' + chalk.green.bold('okay'));
|
|
368
|
+
bundle[fileName].code = ConstructFunctions([
|
|
369
|
+
`const MILLENNIUM_IS_CLIENT_MODULE = ${type === ComponentType.Plugin ? 'true' : 'false'};`,
|
|
246
370
|
`const pluginName = "${props.strPluginInternalName}";`,
|
|
247
371
|
InitializePlugins.toString(),
|
|
248
|
-
InitializePlugins.name +
|
|
372
|
+
InitializePlugins.name + '()',
|
|
249
373
|
WrappedCallServerMethod,
|
|
250
374
|
WrappedCallable,
|
|
251
|
-
bundle[fileName].code,
|
|
252
|
-
|
|
253
|
-
|
|
375
|
+
generate(bundle[fileName].code),
|
|
376
|
+
ExecutePluginModule.toString(),
|
|
377
|
+
ExecutePluginModule.name + '()',
|
|
254
378
|
]);
|
|
255
379
|
}
|
|
256
380
|
};
|
|
@@ -259,10 +383,10 @@ function InsertWebkitMillennium(props) {
|
|
|
259
383
|
function GetPluginComponents(props) {
|
|
260
384
|
let tsConfigPath = `./${GetFrontEndDirectory()}/tsconfig.json`;
|
|
261
385
|
if (!fs.existsSync(tsConfigPath)) {
|
|
262
|
-
tsConfigPath =
|
|
386
|
+
tsConfigPath = './tsconfig.json';
|
|
263
387
|
}
|
|
264
388
|
const pluginList = [
|
|
265
|
-
InsertMillennium(props),
|
|
389
|
+
InsertMillennium(ComponentType.Plugin, props),
|
|
266
390
|
typescript({
|
|
267
391
|
tsconfig: tsConfigPath,
|
|
268
392
|
}),
|
|
@@ -271,13 +395,14 @@ function GetPluginComponents(props) {
|
|
|
271
395
|
json(),
|
|
272
396
|
injectProcessEnv(envVars),
|
|
273
397
|
replace({
|
|
274
|
-
delimiters: [
|
|
398
|
+
delimiters: ['', ''],
|
|
275
399
|
preventAssignment: true,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
400
|
+
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
401
|
+
'Millennium.callServerMethod': `__call_server_method__`,
|
|
402
|
+
'client.callable': `__wrapped_callable__`,
|
|
403
|
+
'client.pluginSelf': 'window.PLUGIN_LIST[pluginName]',
|
|
404
|
+
'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, ',
|
|
405
|
+
'client.BindPluginSettings()': 'client.BindPluginSettings(pluginName)',
|
|
281
406
|
}),
|
|
282
407
|
];
|
|
283
408
|
if (props.bTersePlugin) {
|
|
@@ -287,94 +412,95 @@ function GetPluginComponents(props) {
|
|
|
287
412
|
}
|
|
288
413
|
function GetWebkitPluginComponents(props) {
|
|
289
414
|
const pluginList = [
|
|
290
|
-
|
|
415
|
+
InsertMillennium(ComponentType.Webkit, props),
|
|
291
416
|
typescript({
|
|
292
|
-
tsconfig:
|
|
417
|
+
tsconfig: './webkit/tsconfig.json',
|
|
293
418
|
}),
|
|
294
419
|
resolve(),
|
|
295
420
|
commonjs(),
|
|
296
421
|
json(),
|
|
297
422
|
injectProcessEnv(envVars),
|
|
298
423
|
replace({
|
|
299
|
-
delimiters: [
|
|
424
|
+
delimiters: ['', ''],
|
|
300
425
|
preventAssignment: true,
|
|
301
|
-
|
|
302
|
-
|
|
426
|
+
'Millennium.callServerMethod': `__call_server_method__`,
|
|
427
|
+
'webkit.callable': `__wrapped_callable__`,
|
|
428
|
+
'client.BindPluginSettings()': 'client.BindPluginSettings(pluginName)',
|
|
303
429
|
}),
|
|
304
430
|
babel({
|
|
305
|
-
presets: [
|
|
306
|
-
babelHelpers:
|
|
431
|
+
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
432
|
+
babelHelpers: 'bundled',
|
|
307
433
|
}),
|
|
308
434
|
];
|
|
309
435
|
props.bTersePlugin && pluginList.push(terser());
|
|
310
436
|
return pluginList;
|
|
311
437
|
}
|
|
312
438
|
const GetFrontEndDirectory = () => {
|
|
313
|
-
const pluginJsonPath =
|
|
439
|
+
const pluginJsonPath = './plugin.json';
|
|
314
440
|
try {
|
|
315
|
-
return
|
|
316
|
-
"frontend");
|
|
441
|
+
return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? 'frontend';
|
|
317
442
|
}
|
|
318
443
|
catch (error) {
|
|
319
|
-
return
|
|
444
|
+
return 'frontend';
|
|
320
445
|
}
|
|
321
446
|
};
|
|
322
447
|
const TranspilerPluginComponent = async (props) => {
|
|
323
448
|
const frontendRollupConfig = {
|
|
324
449
|
input: `./${GetFrontEndDirectory()}/index.tsx`,
|
|
325
450
|
plugins: GetPluginComponents(props),
|
|
326
|
-
context:
|
|
451
|
+
context: 'window',
|
|
327
452
|
external: (id) => {
|
|
328
|
-
if (id ===
|
|
329
|
-
Logger.Error(
|
|
453
|
+
if (id === '@steambrew/webkit') {
|
|
454
|
+
Logger.Error('The @steambrew/webkit module should not be included in the frontend module, use @steambrew/client instead. Please remove it from the frontend module and try again.');
|
|
330
455
|
process.exit(1);
|
|
331
456
|
}
|
|
332
|
-
return id ===
|
|
457
|
+
return id === '@steambrew/client' || id === 'react' || id === 'react-dom' || id === 'react-dom/client';
|
|
333
458
|
},
|
|
334
459
|
output: {
|
|
335
|
-
name:
|
|
336
|
-
file:
|
|
460
|
+
name: 'millennium_main',
|
|
461
|
+
file: '.millennium/Dist/index.js',
|
|
337
462
|
globals: {
|
|
338
|
-
react:
|
|
339
|
-
|
|
340
|
-
|
|
463
|
+
react: 'window.SP_REACT',
|
|
464
|
+
'react-dom': 'window.SP_REACTDOM',
|
|
465
|
+
'react-dom/client': 'window.SP_REACTDOM',
|
|
466
|
+
'@steambrew/client': 'window.MILLENNIUM_API',
|
|
341
467
|
},
|
|
342
|
-
exports:
|
|
343
|
-
format:
|
|
468
|
+
exports: 'named',
|
|
469
|
+
format: 'iife',
|
|
344
470
|
},
|
|
345
471
|
};
|
|
346
|
-
Logger.Info(
|
|
472
|
+
Logger.Info('Starting build; this may take a few moments...');
|
|
347
473
|
try {
|
|
348
474
|
await (await rollup(frontendRollupConfig)).write(frontendRollupConfig.output);
|
|
349
475
|
if (fs.existsSync(`./webkit/index.tsx`)) {
|
|
350
|
-
Logger.Info(
|
|
476
|
+
Logger.Info('Compiling webkit module...');
|
|
351
477
|
const webkitRollupConfig = {
|
|
352
478
|
input: `./webkit/index.tsx`,
|
|
353
479
|
plugins: GetWebkitPluginComponents(props),
|
|
354
|
-
context:
|
|
480
|
+
context: 'window',
|
|
355
481
|
external: (id) => {
|
|
356
|
-
if (id ===
|
|
357
|
-
Logger.Error(
|
|
482
|
+
if (id === '@steambrew/client') {
|
|
483
|
+
Logger.Error('The @steambrew/client module should not be included in the webkit module, use @steambrew/webkit instead. Please remove it from the webkit module and try again.');
|
|
358
484
|
process.exit(1);
|
|
359
485
|
}
|
|
360
|
-
return id ===
|
|
486
|
+
return id === '@steambrew/webkit';
|
|
361
487
|
},
|
|
362
488
|
output: {
|
|
363
|
-
name:
|
|
364
|
-
file:
|
|
365
|
-
exports:
|
|
366
|
-
format:
|
|
489
|
+
name: 'millennium_main',
|
|
490
|
+
file: '.millennium/Dist/webkit.js',
|
|
491
|
+
exports: 'named',
|
|
492
|
+
format: 'iife',
|
|
367
493
|
globals: {
|
|
368
|
-
|
|
494
|
+
'@steambrew/webkit': 'window.MILLENNIUM_API',
|
|
369
495
|
},
|
|
370
496
|
},
|
|
371
497
|
};
|
|
372
498
|
await (await rollup(webkitRollupConfig)).write(webkitRollupConfig.output);
|
|
373
499
|
}
|
|
374
|
-
Logger.Info(
|
|
500
|
+
Logger.Info('Build succeeded!', Number((performance.now() - global.PerfStartTime).toFixed(3)), 'ms elapsed.');
|
|
375
501
|
}
|
|
376
502
|
catch (exception) {
|
|
377
|
-
Logger.Error(
|
|
503
|
+
Logger.Error('Build failed!', exception);
|
|
378
504
|
process.exit(1);
|
|
379
505
|
}
|
|
380
506
|
};
|
package/index.ts
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* this component serves as:
|
|
5
|
-
* - typescript transpiler
|
|
6
|
-
* - rollup configurator
|
|
7
|
-
*/
|
|
8
|
-
import { BuildType, ValidateParameters } from "./Parameters"
|
|
9
|
-
import { CheckForUpdates } from "./VersionMon"
|
|
10
|
-
import { ValidatePlugin } from './Linter'
|
|
11
|
-
import { TranspilerPluginComponent, TranspilerProps } from './Compiler'
|
|
12
|
-
import { performance } from 'perf_hooks';
|
|
13
|
-
import { Logger } from "./Logger";
|
|
14
|
-
// import { Logger } from './Logger'
|
|
15
|
-
|
|
16
|
-
declare global {
|
|
17
|
-
var PerfStartTime: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const CheckModuleUpdates = async () => {
|
|
21
|
-
return await CheckForUpdates()
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const StartCompilerModule = () => {
|
|
25
|
-
|
|
26
|
-
const parameters = ValidateParameters( process.argv.slice(2) );
|
|
27
|
-
const bTersePlugin = parameters.type == BuildType.ProdBuild
|
|
28
|
-
|
|
29
|
-
Logger.Tree("Transpiler config: ", {
|
|
30
|
-
target: parameters.targetPlugin,
|
|
31
|
-
build: BuildType[parameters.type],
|
|
32
|
-
minify: bTersePlugin
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
ValidatePlugin(parameters.targetPlugin).then((json: any) => {
|
|
36
|
-
|
|
37
|
-
const props: TranspilerProps = {
|
|
38
|
-
bTersePlugin: bTersePlugin,
|
|
39
|
-
strPluginInternalName: json?.name
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
TranspilerPluginComponent(props)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* plugin is invalid, we close the proccess as it has already been handled
|
|
47
|
-
*/
|
|
48
|
-
.catch(() => {
|
|
49
|
-
process.exit()
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const Initialize = () => {
|
|
54
|
-
global.PerfStartTime = performance.now();
|
|
55
|
-
|
|
56
|
-
// Check for --no-update flag
|
|
57
|
-
if (process.argv.includes("--no-update")) {
|
|
58
|
-
StartCompilerModule()
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
CheckModuleUpdates().then(StartCompilerModule)
|
|
63
|
-
}
|
|
64
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* this component serves as:
|
|
5
|
+
* - typescript transpiler
|
|
6
|
+
* - rollup configurator
|
|
7
|
+
*/
|
|
8
|
+
import { BuildType, ValidateParameters } from "./Parameters"
|
|
9
|
+
import { CheckForUpdates } from "./VersionMon"
|
|
10
|
+
import { ValidatePlugin } from './Linter'
|
|
11
|
+
import { TranspilerPluginComponent, TranspilerProps } from './Compiler'
|
|
12
|
+
import { performance } from 'perf_hooks';
|
|
13
|
+
import { Logger } from "./Logger";
|
|
14
|
+
// import { Logger } from './Logger'
|
|
15
|
+
|
|
16
|
+
declare global {
|
|
17
|
+
var PerfStartTime: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const CheckModuleUpdates = async () => {
|
|
21
|
+
return await CheckForUpdates()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const StartCompilerModule = () => {
|
|
25
|
+
|
|
26
|
+
const parameters = ValidateParameters( process.argv.slice(2) );
|
|
27
|
+
const bTersePlugin = parameters.type == BuildType.ProdBuild
|
|
28
|
+
|
|
29
|
+
Logger.Tree("Transpiler config: ", {
|
|
30
|
+
target: parameters.targetPlugin,
|
|
31
|
+
build: BuildType[parameters.type],
|
|
32
|
+
minify: bTersePlugin
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
ValidatePlugin(parameters.targetPlugin).then((json: any) => {
|
|
36
|
+
|
|
37
|
+
const props: TranspilerProps = {
|
|
38
|
+
bTersePlugin: bTersePlugin,
|
|
39
|
+
strPluginInternalName: json?.name
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
TranspilerPluginComponent(props)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* plugin is invalid, we close the proccess as it has already been handled
|
|
47
|
+
*/
|
|
48
|
+
.catch(() => {
|
|
49
|
+
process.exit()
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const Initialize = () => {
|
|
54
|
+
global.PerfStartTime = performance.now();
|
|
55
|
+
|
|
56
|
+
// Check for --no-update flag
|
|
57
|
+
if (process.argv.includes("--no-update")) {
|
|
58
|
+
StartCompilerModule()
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
CheckModuleUpdates().then(StartCompilerModule)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
65
|
Initialize();
|
package/package.json
CHANGED
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@steambrew/ttc",
|
|
3
|
+
"version": "1.4.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"millennium-ttc": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"prepare": "npm run build"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"description": "A tiny typescript compiler for Millennium plugins.",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@babel/preset-env": "^7.26.0",
|
|
23
|
+
"@babel/preset-react": "^7.25.9",
|
|
24
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
25
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
26
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
27
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
28
|
+
"@rollup/plugin-replace": "^6.0.1",
|
|
29
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
30
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
31
|
+
"chalk": "^5.3.0",
|
|
32
|
+
"dotenv": "^16.4.7",
|
|
33
|
+
"fs": "^0.0.1-security",
|
|
34
|
+
"rollup": "^4.28.0",
|
|
35
|
+
"rollup-plugin-inject-process-env": "^1.3.1",
|
|
36
|
+
"tslib": "^2.8.1"
|
|
37
|
+
}
|
|
38
|
+
}
|