@steambrew/ttc 2.7.3 → 2.7.5

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
@@ -84,7 +84,7 @@ var BuildType;
84
84
  BuildType[BuildType["ProdBuild"] = 1] = "ProdBuild";
85
85
  })(BuildType || (BuildType = {}));
86
86
  const ValidateParameters = (args) => {
87
- let typeProp = BuildType.DevBuild, targetProp = process.cwd();
87
+ let typeProp = BuildType.DevBuild, targetProp = process.cwd(), isMillennium = false;
88
88
  if (args.includes('--help')) {
89
89
  PrintParamHelp();
90
90
  process.exit();
@@ -118,10 +118,14 @@ const ValidateParameters = (args) => {
118
118
  }
119
119
  targetProp = args[i + 1];
120
120
  }
121
+ if (args[i] == '--millennium-internal') {
122
+ isMillennium = true;
123
+ }
121
124
  }
122
125
  return {
123
126
  type: typeProp,
124
127
  targetPlugin: targetProp,
128
+ isMillennium: isMillennium,
125
129
  };
126
130
  };
127
131
 
@@ -150,13 +154,24 @@ const CheckForUpdates = async () => {
150
154
  });
151
155
  };
152
156
 
153
- const ValidatePlugin = (target) => {
157
+ const ValidatePlugin = (bIsMillennium, target) => {
154
158
  return new Promise((resolve, reject) => {
155
159
  if (!existsSync(target)) {
156
160
  console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid system path'));
157
161
  reject();
158
162
  return;
159
163
  }
164
+ if (bIsMillennium) {
165
+ console.log(chalk.green.bold('\n[+] Using Millennium internal build configuration'));
166
+ resolve({
167
+ name: 'core',
168
+ common_name: 'Millennium',
169
+ description: 'An integrated plugin that provides core platform functionality.',
170
+ useBackend: false,
171
+ frontend: '.',
172
+ });
173
+ return;
174
+ }
160
175
  const pluginModule = path.join(target, 'plugin.json');
161
176
  if (!existsSync(pluginModule)) {
162
177
  console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid plugin (missing plugin.json)'));
@@ -294,35 +309,9 @@ function InitializePlugins() {
294
309
  MillenniumStore.ignoreProxyFlag = false;
295
310
  });
296
311
  }
297
- async function WebkitInitializeIPC() {
298
- let intervalId = null;
299
- const maxWaitTime = 10000; // 10 seconds
300
- intervalId = setInterval(() => {
301
- if (typeof SteamClient === 'undefined') {
302
- return;
303
- }
304
- if (intervalId) {
305
- clearInterval(intervalId);
306
- intervalId = null;
307
- }
308
- SteamClient.BrowserView?.RegisterForMessageFromParent((messageId, data) => {
309
- if (messageId !== IPCMessageId) {
310
- return;
311
- }
312
- const payload = JSON.parse(data);
313
- MillenniumStore.ignoreProxyFlag = true;
314
- MillenniumStore.settingsStore[payload.name] = payload.value;
315
- MillenniumStore.ignoreProxyFlag = false;
316
- });
317
- }, 100);
318
- setTimeout(() => {
319
- if (intervalId) {
320
- clearInterval(intervalId);
321
- console.warn('%c Millennium %c Failed to find SteamClient after 10000ms', 'background:rgb(37, 105, 184); color: white;', 'background: transparent;');
322
- }
323
- }, maxWaitTime);
312
+ if (isClientModule) {
313
+ ClientInitializeIPC();
324
314
  }
325
- isClientModule ? ClientInitializeIPC() : WebkitInitializeIPC();
326
315
  const StartSettingPropagation = (name, value) => {
327
316
  if (MillenniumStore.ignoreProxyFlag) {
328
317
  return;
@@ -683,9 +672,9 @@ async function MergePluginList(plugins) {
683
672
  // Merge input plugins with the filtered custom plugins
684
673
  return [...plugins, ...filteredCustomPlugins];
685
674
  }
686
- async function GetPluginComponents(props) {
675
+ async function GetPluginComponents(pluginJson, props) {
687
676
  let tsConfigPath = '';
688
- const frontendDir = GetFrontEndDirectory();
677
+ const frontendDir = GetFrontEndDirectory(pluginJson);
689
678
  if (frontendDir === '.' || frontendDir === './') {
690
679
  tsConfigPath = './tsconfig.json';
691
680
  }
@@ -697,21 +686,23 @@ async function GetPluginComponents(props) {
697
686
  }
698
687
  Logger.Info('millenniumAPI', 'Loading tsconfig from ' + chalk.cyan.bold(tsConfigPath) + '... ' + chalk.green.bold('okay'));
699
688
  let pluginList = [
689
+ typescript({
690
+ tsconfig: tsConfigPath,
691
+ compilerOptions: {
692
+ outDir: undefined,
693
+ },
694
+ }),
700
695
  url({
701
696
  include: ['**/*.gif', '**/*.webm', '**/*.svg'], // Add all non-JS assets you use
702
697
  limit: 0, // Set to 0 to always copy the file instead of inlining as base64
703
698
  fileName: '[hash][extname]', // Optional: custom output naming
704
699
  }),
705
700
  InsertMillennium(ComponentType.Plugin, props),
706
- commonjs(),
707
- nodePolyfills(),
708
701
  nodeResolve({
709
702
  browser: true,
710
703
  }),
711
- typescript({
712
- include: ['**/*.ts', '**/*.tsx', 'src/**/*.ts', 'src/**/*.tsx'],
713
- tsconfig: tsConfigPath,
714
- }),
704
+ commonjs(),
705
+ nodePolyfills(),
715
706
  scss({
716
707
  output: false,
717
708
  outputStyle: 'compressed',
@@ -719,7 +710,6 @@ async function GetPluginComponents(props) {
719
710
  watch: 'src/styles',
720
711
  sass: sass,
721
712
  }),
722
- resolve(),
723
713
  json(),
724
714
  constSysfsExpr(),
725
715
  replace({
@@ -776,19 +766,30 @@ async function GetWebkitPluginComponents(props) {
776
766
  props.bTersePlugin && pluginList.push(terser());
777
767
  return pluginList;
778
768
  }
779
- const GetFrontEndDirectory = () => {
780
- const pluginJsonPath = './plugin.json';
769
+ const GetFrontEndDirectory = (pluginJson) => {
781
770
  try {
782
- return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? 'frontend';
771
+ return pluginJson?.frontend ?? 'frontend';
783
772
  }
784
773
  catch (error) {
785
774
  return 'frontend';
786
775
  }
787
776
  };
788
- const TranspilerPluginComponent = async (props) => {
777
+ const TranspilerPluginComponent = async (bIsMillennium, pluginJson, props) => {
778
+ const frontendDir = GetFrontEndDirectory(pluginJson);
779
+ console.log(chalk.greenBright.bold('config'), 'Frontend directory set to:', chalk.cyan.bold(frontendDir));
780
+ const frontendPlugins = await GetPluginComponents(pluginJson, props);
781
+ // Fix entry file path construction
782
+ let entryFile = '';
783
+ if (frontendDir === '.' || frontendDir === './' || frontendDir === '') {
784
+ entryFile = './index.tsx';
785
+ }
786
+ else {
787
+ entryFile = `./${frontendDir}/index.tsx`;
788
+ }
789
+ console.log(chalk.greenBright.bold('config'), 'Entry file set to:', chalk.cyan.bold(entryFile));
789
790
  const frontendRollupConfig = {
790
- input: `./${GetFrontEndDirectory()}/index.tsx`,
791
- plugins: await GetPluginComponents(props),
791
+ input: entryFile,
792
+ plugins: frontendPlugins,
792
793
  context: 'window',
793
794
  external: (id) => {
794
795
  if (id === '@steambrew/webkit') {
@@ -799,7 +800,7 @@ const TranspilerPluginComponent = async (props) => {
799
800
  },
800
801
  output: {
801
802
  name: 'millennium_main',
802
- file: '.millennium/Dist/index.js',
803
+ file: bIsMillennium ? '../../build/frontend.bin' : '.millennium/Dist/index.js',
803
804
  globals: {
804
805
  react: 'window.SP_REACT',
805
806
  'react-dom': 'window.SP_REACTDOM',
@@ -854,15 +855,16 @@ const CheckModuleUpdates = async () => {
854
855
  };
855
856
  const StartCompilerModule = () => {
856
857
  const parameters = ValidateParameters(process.argv.slice(2));
858
+ const bIsMillennium = parameters.isMillennium || false;
857
859
  const bTersePlugin = parameters.type == BuildType.ProdBuild;
858
860
  console.log(chalk.greenBright.bold('config'), 'Building target:', parameters.targetPlugin, 'with type:', BuildType[parameters.type], 'minify:', bTersePlugin, '...');
859
- ValidatePlugin(parameters.targetPlugin)
861
+ ValidatePlugin(bIsMillennium, parameters.targetPlugin)
860
862
  .then((json) => {
861
863
  const props = {
862
864
  bTersePlugin: bTersePlugin,
863
865
  strPluginInternalName: json?.name,
864
866
  };
865
- TranspilerPluginComponent(props);
867
+ TranspilerPluginComponent(bIsMillennium, json, props);
866
868
  })
867
869
  /**
868
870
  * plugin is invalid, we close the proccess as it has already been handled
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steambrew/ttc",
3
- "version": "2.7.3",
3
+ "version": "2.7.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -0,0 +1,2 @@
1
+ onlyBuiltDependencies:
2
+ - '@parcel/watcher'
@@ -2,7 +2,7 @@ import chalk from 'chalk';
2
2
  import path from 'path';
3
3
  import { existsSync, readFile } from 'fs';
4
4
 
5
- export const ValidatePlugin = (target: string): Promise<any> => {
5
+ export const ValidatePlugin = (bIsMillennium: boolean, target: string): Promise<any> => {
6
6
  return new Promise<any>((resolve, reject) => {
7
7
  if (!existsSync(target)) {
8
8
  console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid system path'));
@@ -10,6 +10,19 @@ export const ValidatePlugin = (target: string): Promise<any> => {
10
10
  return;
11
11
  }
12
12
 
13
+ if (bIsMillennium) {
14
+ console.log(chalk.green.bold('\n[+] Using Millennium internal build configuration'));
15
+
16
+ resolve({
17
+ name: 'core',
18
+ common_name: 'Millennium',
19
+ description: 'An integrated plugin that provides core platform functionality.',
20
+ useBackend: false,
21
+ frontend: '.',
22
+ });
23
+ return;
24
+ }
25
+
13
26
  const pluginModule = path.join(target, 'plugin.json');
14
27
 
15
28
  if (!existsSync(pluginModule)) {
package/src/index.ts CHANGED
@@ -23,18 +23,19 @@ const CheckModuleUpdates = async () => {
23
23
 
24
24
  const StartCompilerModule = () => {
25
25
  const parameters = ValidateParameters(process.argv.slice(2));
26
+ const bIsMillennium = parameters.isMillennium || false;
26
27
  const bTersePlugin = parameters.type == BuildType.ProdBuild;
27
28
 
28
29
  console.log(chalk.greenBright.bold('config'), 'Building target:', parameters.targetPlugin, 'with type:', BuildType[parameters.type], 'minify:', bTersePlugin, '...');
29
30
 
30
- ValidatePlugin(parameters.targetPlugin)
31
+ ValidatePlugin(bIsMillennium, parameters.targetPlugin)
31
32
  .then((json: any) => {
32
33
  const props: TranspilerProps = {
33
34
  bTersePlugin: bTersePlugin,
34
35
  strPluginInternalName: json?.name,
35
36
  };
36
37
 
37
- TranspilerPluginComponent(props);
38
+ TranspilerPluginComponent(bIsMillennium, json, props);
38
39
  })
39
40
 
40
41
  /**
package/src/plugin-api.ts CHANGED
@@ -188,42 +188,10 @@ function InitializePlugins() {
188
188
  });
189
189
  }
190
190
 
191
- async function WebkitInitializeIPC() {
192
- let intervalId: NodeJS.Timeout | null = null;
193
- const maxWaitTime = 10000; // 10 seconds
194
-
195
- intervalId = setInterval(() => {
196
- if (typeof SteamClient === 'undefined') {
197
- return;
198
- }
199
-
200
- if (intervalId) {
201
- clearInterval(intervalId);
202
- intervalId = null;
203
- }
204
-
205
- SteamClient.BrowserView?.RegisterForMessageFromParent((messageId: string, data: string) => {
206
- if (messageId !== IPCMessageId) {
207
- return;
208
- }
209
-
210
- const payload = JSON.parse(data);
211
- MillenniumStore.ignoreProxyFlag = true;
212
- MillenniumStore.settingsStore[payload.name] = payload.value;
213
- MillenniumStore.ignoreProxyFlag = false;
214
- });
215
- }, 100);
216
-
217
- setTimeout(() => {
218
- if (intervalId) {
219
- clearInterval(intervalId);
220
- console.warn('%c Millennium %c Failed to find SteamClient after 10000ms', 'background:rgb(37, 105, 184); color: white;', 'background: transparent;');
221
- }
222
- }, maxWaitTime);
191
+ if (isClientModule) {
192
+ ClientInitializeIPC();
223
193
  }
224
194
 
225
- isClientModule ? ClientInitializeIPC() : WebkitInitializeIPC();
226
-
227
195
  const StartSettingPropagation = (name: string, value: any) => {
228
196
  if (MillenniumStore.ignoreProxyFlag) {
229
197
  return;
@@ -29,11 +29,13 @@ export enum BuildType {
29
29
  export interface ParameterProps {
30
30
  type: BuildType;
31
31
  targetPlugin: string; // path
32
+ isMillennium?: boolean;
32
33
  }
33
34
 
34
35
  export const ValidateParameters = (args: Array<string>): ParameterProps => {
35
36
  let typeProp: BuildType = BuildType.DevBuild,
36
- targetProp: string = process.cwd();
37
+ targetProp: string = process.cwd(),
38
+ isMillennium: boolean = false;
37
39
 
38
40
  if (args.includes('--help')) {
39
41
  PrintParamHelp();
@@ -73,10 +75,15 @@ export const ValidateParameters = (args: Array<string>): ParameterProps => {
73
75
 
74
76
  targetProp = args[i + 1];
75
77
  }
78
+
79
+ if (args[i] == '--millennium-internal') {
80
+ isMillennium = true;
81
+ }
76
82
  }
77
83
 
78
84
  return {
79
85
  type: typeProp,
80
86
  targetPlugin: targetProp,
87
+ isMillennium: isMillennium,
81
88
  };
82
89
  };
package/src/transpiler.ts CHANGED
@@ -119,9 +119,9 @@ async function MergePluginList(plugins: any[]) {
119
119
  return [...plugins, ...filteredCustomPlugins];
120
120
  }
121
121
 
122
- async function GetPluginComponents(props: TranspilerProps): Promise<InputPluginOption[]> {
122
+ async function GetPluginComponents(pluginJson: any, props: TranspilerProps): Promise<InputPluginOption[]> {
123
123
  let tsConfigPath = '';
124
- const frontendDir = GetFrontEndDirectory();
124
+ const frontendDir = GetFrontEndDirectory(pluginJson);
125
125
 
126
126
  if (frontendDir === '.' || frontendDir === './') {
127
127
  tsConfigPath = './tsconfig.json';
@@ -136,21 +136,23 @@ async function GetPluginComponents(props: TranspilerProps): Promise<InputPluginO
136
136
  Logger.Info('millenniumAPI', 'Loading tsconfig from ' + chalk.cyan.bold(tsConfigPath) + '... ' + chalk.green.bold('okay'));
137
137
 
138
138
  let pluginList = [
139
+ typescript({
140
+ tsconfig: tsConfigPath,
141
+ compilerOptions: {
142
+ outDir: undefined,
143
+ },
144
+ }),
139
145
  url({
140
146
  include: ['**/*.gif', '**/*.webm', '**/*.svg'], // Add all non-JS assets you use
141
147
  limit: 0, // Set to 0 to always copy the file instead of inlining as base64
142
148
  fileName: '[hash][extname]', // Optional: custom output naming
143
149
  }),
144
150
  InsertMillennium(ComponentType.Plugin, props),
145
- commonjs(),
146
- nodePolyfills(),
147
151
  nodeResolve({
148
152
  browser: true,
149
153
  }),
150
- typescript({
151
- include: ['**/*.ts', '**/*.tsx', 'src/**/*.ts', 'src/**/*.tsx'],
152
- tsconfig: tsConfigPath,
153
- }),
154
+ commonjs(),
155
+ nodePolyfills(),
154
156
  scss({
155
157
  output: false,
156
158
  outputStyle: 'compressed',
@@ -158,7 +160,6 @@ async function GetPluginComponents(props: TranspilerProps): Promise<InputPluginO
158
160
  watch: 'src/styles',
159
161
  sass: sass,
160
162
  }),
161
- resolve(),
162
163
  json(),
163
164
  constSysfsExpr(),
164
165
  replace({
@@ -223,19 +224,33 @@ async function GetWebkitPluginComponents(props: TranspilerProps) {
223
224
  return pluginList;
224
225
  }
225
226
 
226
- const GetFrontEndDirectory = () => {
227
- const pluginJsonPath = './plugin.json';
227
+ const GetFrontEndDirectory = (pluginJson: any) => {
228
228
  try {
229
- return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? 'frontend';
229
+ return pluginJson?.frontend ?? 'frontend';
230
230
  } catch (error) {
231
231
  return 'frontend';
232
232
  }
233
233
  };
234
234
 
235
- export const TranspilerPluginComponent = async (props: TranspilerProps) => {
235
+ export const TranspilerPluginComponent = async (bIsMillennium: boolean, pluginJson: any, props: TranspilerProps) => {
236
+ const frontendDir = GetFrontEndDirectory(pluginJson);
237
+ console.log(chalk.greenBright.bold('config'), 'Frontend directory set to:', chalk.cyan.bold(frontendDir));
238
+
239
+ const frontendPlugins = await GetPluginComponents(pluginJson, props);
240
+
241
+ // Fix entry file path construction
242
+ let entryFile = '';
243
+ if (frontendDir === '.' || frontendDir === './' || frontendDir === '') {
244
+ entryFile = './index.tsx';
245
+ } else {
246
+ entryFile = `./${frontendDir}/index.tsx`;
247
+ }
248
+
249
+ console.log(chalk.greenBright.bold('config'), 'Entry file set to:', chalk.cyan.bold(entryFile));
250
+
236
251
  const frontendRollupConfig: RollupOptions = {
237
- input: `./${GetFrontEndDirectory()}/index.tsx`,
238
- plugins: await GetPluginComponents(props),
252
+ input: entryFile,
253
+ plugins: frontendPlugins,
239
254
  context: 'window',
240
255
  external: (id) => {
241
256
  if (id === '@steambrew/webkit') {
@@ -249,7 +264,7 @@ export const TranspilerPluginComponent = async (props: TranspilerProps) => {
249
264
  },
250
265
  output: {
251
266
  name: 'millennium_main',
252
- file: '.millennium/Dist/index.js',
267
+ file: bIsMillennium ? '../../build/frontend.bin' : '.millennium/Dist/index.js',
253
268
  globals: {
254
269
  react: 'window.SP_REACT',
255
270
  'react-dom': 'window.SP_REACTDOM',