@steambrew/ttc 1.2.1 → 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 -259
- 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 +219 -77
- 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,80 +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[`process.env.${key}`] = JSON.stringify(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
|
-
|
|
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 }));
|
|
228
296
|
}
|
|
229
297
|
};
|
|
230
|
-
|
|
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({});
|
|
231
337
|
}
|
|
232
|
-
|
|
338
|
+
|
|
339
|
+
const envConfig = dotenv.config().parsed || {};
|
|
340
|
+
if (envConfig) {
|
|
341
|
+
Logger.Info('Injecting environment variables...');
|
|
342
|
+
}
|
|
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) {
|
|
233
362
|
const generateBundle = (_, bundle) => {
|
|
234
363
|
for (const fileName in bundle) {
|
|
235
|
-
if (bundle[fileName].type != 'chunk')
|
|
364
|
+
if (bundle[fileName].type != 'chunk') {
|
|
236
365
|
continue;
|
|
237
|
-
|
|
238
|
-
|
|
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'};`,
|
|
239
370
|
`const pluginName = "${props.strPluginInternalName}";`,
|
|
240
|
-
InitializePlugins.toString(),
|
|
241
|
-
|
|
242
|
-
|
|
371
|
+
InitializePlugins.toString(),
|
|
372
|
+
InitializePlugins.name + '()',
|
|
373
|
+
WrappedCallServerMethod,
|
|
374
|
+
WrappedCallable,
|
|
375
|
+
generate(bundle[fileName].code),
|
|
376
|
+
ExecutePluginModule.toString(),
|
|
377
|
+
ExecutePluginModule.name + '()',
|
|
243
378
|
]);
|
|
244
379
|
}
|
|
245
380
|
};
|
|
@@ -251,11 +386,13 @@ function GetPluginComponents(props) {
|
|
|
251
386
|
tsConfigPath = './tsconfig.json';
|
|
252
387
|
}
|
|
253
388
|
const pluginList = [
|
|
254
|
-
InsertMillennium(props),
|
|
389
|
+
InsertMillennium(ComponentType.Plugin, props),
|
|
255
390
|
typescript({
|
|
256
|
-
tsconfig: tsConfigPath
|
|
391
|
+
tsconfig: tsConfigPath,
|
|
257
392
|
}),
|
|
258
|
-
resolve(),
|
|
393
|
+
resolve(),
|
|
394
|
+
commonjs(),
|
|
395
|
+
json(),
|
|
259
396
|
injectProcessEnv(envVars),
|
|
260
397
|
replace({
|
|
261
398
|
delimiters: ['', ''],
|
|
@@ -264,7 +401,8 @@ function GetPluginComponents(props) {
|
|
|
264
401
|
'Millennium.callServerMethod': `__call_server_method__`,
|
|
265
402
|
'client.callable': `__wrapped_callable__`,
|
|
266
403
|
'client.pluginSelf': 'window.PLUGIN_LIST[pluginName]',
|
|
267
|
-
'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, '
|
|
404
|
+
'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, ',
|
|
405
|
+
'client.BindPluginSettings()': 'client.BindPluginSettings(pluginName)',
|
|
268
406
|
}),
|
|
269
407
|
];
|
|
270
408
|
if (props.bTersePlugin) {
|
|
@@ -274,22 +412,25 @@ function GetPluginComponents(props) {
|
|
|
274
412
|
}
|
|
275
413
|
function GetWebkitPluginComponents(props) {
|
|
276
414
|
const pluginList = [
|
|
277
|
-
|
|
415
|
+
InsertMillennium(ComponentType.Webkit, props),
|
|
278
416
|
typescript({
|
|
279
|
-
tsconfig: './webkit/tsconfig.json'
|
|
417
|
+
tsconfig: './webkit/tsconfig.json',
|
|
280
418
|
}),
|
|
281
|
-
resolve(),
|
|
419
|
+
resolve(),
|
|
420
|
+
commonjs(),
|
|
421
|
+
json(),
|
|
282
422
|
injectProcessEnv(envVars),
|
|
283
423
|
replace({
|
|
284
424
|
delimiters: ['', ''],
|
|
285
425
|
preventAssignment: true,
|
|
286
426
|
'Millennium.callServerMethod': `__call_server_method__`,
|
|
287
427
|
'webkit.callable': `__wrapped_callable__`,
|
|
428
|
+
'client.BindPluginSettings()': 'client.BindPluginSettings(pluginName)',
|
|
288
429
|
}),
|
|
289
430
|
babel({
|
|
290
431
|
presets: ['@babel/preset-env', '@babel/preset-react'],
|
|
291
432
|
babelHelpers: 'bundled',
|
|
292
|
-
})
|
|
433
|
+
}),
|
|
293
434
|
];
|
|
294
435
|
props.bTersePlugin && pluginList.push(terser());
|
|
295
436
|
return pluginList;
|
|
@@ -297,10 +438,10 @@ function GetWebkitPluginComponents(props) {
|
|
|
297
438
|
const GetFrontEndDirectory = () => {
|
|
298
439
|
const pluginJsonPath = './plugin.json';
|
|
299
440
|
try {
|
|
300
|
-
return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ??
|
|
441
|
+
return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? 'frontend';
|
|
301
442
|
}
|
|
302
443
|
catch (error) {
|
|
303
|
-
return
|
|
444
|
+
return 'frontend';
|
|
304
445
|
}
|
|
305
446
|
};
|
|
306
447
|
const TranspilerPluginComponent = async (props) => {
|
|
@@ -313,25 +454,26 @@ const TranspilerPluginComponent = async (props) => {
|
|
|
313
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.');
|
|
314
455
|
process.exit(1);
|
|
315
456
|
}
|
|
316
|
-
return id === '@steambrew/client' || id === 'react' || id === 'react-dom';
|
|
457
|
+
return id === '@steambrew/client' || id === 'react' || id === 'react-dom' || id === 'react-dom/client';
|
|
317
458
|
},
|
|
318
459
|
output: {
|
|
319
|
-
name:
|
|
320
|
-
file:
|
|
460
|
+
name: 'millennium_main',
|
|
461
|
+
file: '.millennium/Dist/index.js',
|
|
321
462
|
globals: {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
463
|
+
react: 'window.SP_REACT',
|
|
464
|
+
'react-dom': 'window.SP_REACTDOM',
|
|
465
|
+
'react-dom/client': 'window.SP_REACTDOM',
|
|
466
|
+
'@steambrew/client': 'window.MILLENNIUM_API',
|
|
325
467
|
},
|
|
326
468
|
exports: 'named',
|
|
327
|
-
format: 'iife'
|
|
328
|
-
}
|
|
469
|
+
format: 'iife',
|
|
470
|
+
},
|
|
329
471
|
};
|
|
330
|
-
Logger.Info(
|
|
472
|
+
Logger.Info('Starting build; this may take a few moments...');
|
|
331
473
|
try {
|
|
332
474
|
await (await rollup(frontendRollupConfig)).write(frontendRollupConfig.output);
|
|
333
475
|
if (fs.existsSync(`./webkit/index.tsx`)) {
|
|
334
|
-
Logger.Info(
|
|
476
|
+
Logger.Info('Compiling webkit module...');
|
|
335
477
|
const webkitRollupConfig = {
|
|
336
478
|
input: `./webkit/index.tsx`,
|
|
337
479
|
plugins: GetWebkitPluginComponents(props),
|
|
@@ -344,14 +486,14 @@ const TranspilerPluginComponent = async (props) => {
|
|
|
344
486
|
return id === '@steambrew/webkit';
|
|
345
487
|
},
|
|
346
488
|
output: {
|
|
347
|
-
name:
|
|
348
|
-
file:
|
|
489
|
+
name: 'millennium_main',
|
|
490
|
+
file: '.millennium/Dist/webkit.js',
|
|
349
491
|
exports: 'named',
|
|
350
492
|
format: 'iife',
|
|
351
493
|
globals: {
|
|
352
|
-
|
|
494
|
+
'@steambrew/webkit': 'window.MILLENNIUM_API',
|
|
353
495
|
},
|
|
354
|
-
}
|
|
496
|
+
},
|
|
355
497
|
};
|
|
356
498
|
await (await rollup(webkitRollupConfig)).write(webkitRollupConfig.output);
|
|
357
499
|
}
|
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
|
+
}
|