@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/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
- // Assign the plugin on plugin list.
185
- Object.assign(window.PLUGIN_LIST[pluginName], millennium_main);
186
- // Run the rolled up plugins default exported function
187
- millennium_main["default"]();
188
- MILLENNIUM_BACKEND_IPC.postMessage(1, { pluginName: pluginName });
189
- }
190
- /**
191
- * @description Append the active plugin to the global plugin
192
- * list and notify that the frontend Loaded.
193
- */
194
- function ExecuteWebkitModule() {
195
- // Assign the plugin on plugin list.
196
- Object.assign(window.PLUGIN_LIST[pluginName], millennium_main);
197
- // Run the rolled up plugins default exported function
198
- millennium_main["default"]();
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 Simple bootstrap function that initializes PLUGIN_LIST
202
- * for current plugin given that is doesnt exist.
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
- !window.PLUGIN_LIST && (window.PLUGIN_LIST = {});
210
- // initialize a container for the plugin
211
- if (!window.PLUGIN_LIST[pluginName]) {
212
- window.PLUGIN_LIST[pluginName] = {};
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
- const ContructFunctions = (parts) => {
216
- return parts.join("\n");
217
- };
218
- function InsertMillennium(props) {
219
- const generateBundle = (_, bundle) => {
220
- for (const fileName in bundle) {
221
- if (bundle[fileName].type != "chunk")
222
- continue;
223
- Logger.Info("Injecting Millennium shims into module... " + chalk.green.bold("okay"));
224
- bundle[fileName].code = ContructFunctions([
225
- `const pluginName = "${props.strPluginInternalName}";`,
226
- InitializePlugins.toString(),
227
- InitializePlugins.name + "()",
228
- WrappedCallServerMethod,
229
- WrappedCallable,
230
- bundle[fileName].code,
231
- ExecutePluginModule.toString(),
232
- ExecutePluginModule.name + "()",
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
- return { name: String(), generateBundle };
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
- function InsertWebkitMillennium(props) {
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 != "chunk")
364
+ if (bundle[fileName].type != 'chunk') {
242
365
  continue;
243
- Logger.Info("Injecting Millennium shims into webkit module... " +
244
- chalk.green.bold("okay"));
245
- bundle[fileName].code = ContructFunctions([
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
- ExecuteWebkitModule.toString(),
253
- ExecuteWebkitModule.name + "()",
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 = "./tsconfig.json";
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
- "process.env.NODE_ENV": JSON.stringify("production"),
277
- "Millennium.callServerMethod": `__call_server_method__`,
278
- "client.callable": `__wrapped_callable__`,
279
- "client.pluginSelf": "window.PLUGIN_LIST[pluginName]",
280
- "client.Millennium.exposeObj(": "client.Millennium.exposeObj(exports, ",
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
- InsertWebkitMillennium(props),
415
+ InsertMillennium(ComponentType.Webkit, props),
291
416
  typescript({
292
- tsconfig: "./webkit/tsconfig.json",
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
- "Millennium.callServerMethod": `__call_server_method__`,
302
- "webkit.callable": `__wrapped_callable__`,
426
+ 'Millennium.callServerMethod': `__call_server_method__`,
427
+ 'webkit.callable': `__wrapped_callable__`,
428
+ 'client.BindPluginSettings()': 'client.BindPluginSettings(pluginName)',
303
429
  }),
304
430
  babel({
305
- presets: ["@babel/preset-env", "@babel/preset-react"],
306
- babelHelpers: "bundled",
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 = "./plugin.json";
439
+ const pluginJsonPath = './plugin.json';
314
440
  try {
315
- return (JSON.parse(fs.readFileSync(pluginJsonPath, "utf8"))?.frontend ??
316
- "frontend");
441
+ return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? 'frontend';
317
442
  }
318
443
  catch (error) {
319
- return "frontend";
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: "window",
451
+ context: 'window',
327
452
  external: (id) => {
328
- if (id === "@steambrew/webkit") {
329
- 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.");
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 === "@steambrew/client" || id === "react" || id === "react-dom";
457
+ return id === '@steambrew/client' || id === 'react' || id === 'react-dom' || id === 'react-dom/client';
333
458
  },
334
459
  output: {
335
- name: "millennium_main",
336
- file: ".millennium/Dist/index.js",
460
+ name: 'millennium_main',
461
+ file: '.millennium/Dist/index.js',
337
462
  globals: {
338
- react: "window.SP_REACT",
339
- "react-dom": "window.SP_REACTDOM",
340
- "@steambrew/client": "window.MILLENNIUM_API",
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: "named",
343
- format: "iife",
468
+ exports: 'named',
469
+ format: 'iife',
344
470
  },
345
471
  };
346
- Logger.Info("Starting build; this may take a few moments...");
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("Compiling webkit module...");
476
+ Logger.Info('Compiling webkit module...');
351
477
  const webkitRollupConfig = {
352
478
  input: `./webkit/index.tsx`,
353
479
  plugins: GetWebkitPluginComponents(props),
354
- context: "window",
480
+ context: 'window',
355
481
  external: (id) => {
356
- if (id === "@steambrew/client") {
357
- 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.");
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 === "@steambrew/webkit";
486
+ return id === '@steambrew/webkit';
361
487
  },
362
488
  output: {
363
- name: "millennium_main",
364
- file: ".millennium/Dist/webkit.js",
365
- exports: "named",
366
- format: "iife",
489
+ name: 'millennium_main',
490
+ file: '.millennium/Dist/webkit.js',
491
+ exports: 'named',
492
+ format: 'iife',
367
493
  globals: {
368
- "@steambrew/webkit": "window.MILLENNIUM_API",
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("Build succeeded!", Number((performance.now() - global.PerfStartTime).toFixed(3)), "ms elapsed.");
500
+ Logger.Info('Build succeeded!', Number((performance.now() - global.PerfStartTime).toFixed(3)), 'ms elapsed.');
375
501
  }
376
502
  catch (exception) {
377
- Logger.Error("Build failed!", exception);
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
- "name": "@steambrew/ttc",
3
- "version": "1.2.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
- },
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
- "keywords": [],
17
- "author": "",
18
- "license": "ISC",
19
- "description": "A tiny typescript compiler for Millennium plugins.",
20
- "dependencies": {
21
- "@babel/preset-env": "^7.26.0",
22
- "@babel/preset-react": "^7.25.9",
23
- "@rollup/plugin-babel": "^6.0.4",
24
- "@rollup/plugin-commonjs": "^28.0.1",
25
- "@rollup/plugin-json": "^6.1.0",
26
- "@rollup/plugin-node-resolve": "^15.3.0",
27
- "@rollup/plugin-replace": "^6.0.1",
28
- "@rollup/plugin-terser": "^0.4.4",
29
- "@rollup/plugin-typescript": "^12.1.1",
30
- "chalk": "^5.3.0",
31
- "dotenv": "^16.4.7",
32
- "fs": "^0.0.1-security",
33
- "rollup": "^4.28.0",
34
- "rollup-plugin-inject-process-env": "^1.3.1",
35
- "tslib": "^2.8.1"
36
- },
37
- "devDependencies": {
38
- "@types/node": "^22.10.1"
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
+ }