@steambrew/ttc 2.7.3 → 2.7.4
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 +48 -20
- package/package.json +1 -1
- package/pnpm-workspace.yaml +2 -0
- package/src/check-health.ts +14 -1
- package/src/index.ts +3 -2
- package/src/query-parser.ts +8 -1
- package/src/transpiler.ts +31 -16
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)'));
|
|
@@ -683,9 +698,9 @@ async function MergePluginList(plugins) {
|
|
|
683
698
|
// Merge input plugins with the filtered custom plugins
|
|
684
699
|
return [...plugins, ...filteredCustomPlugins];
|
|
685
700
|
}
|
|
686
|
-
async function GetPluginComponents(props) {
|
|
701
|
+
async function GetPluginComponents(pluginJson, props) {
|
|
687
702
|
let tsConfigPath = '';
|
|
688
|
-
const frontendDir = GetFrontEndDirectory();
|
|
703
|
+
const frontendDir = GetFrontEndDirectory(pluginJson);
|
|
689
704
|
if (frontendDir === '.' || frontendDir === './') {
|
|
690
705
|
tsConfigPath = './tsconfig.json';
|
|
691
706
|
}
|
|
@@ -697,21 +712,23 @@ async function GetPluginComponents(props) {
|
|
|
697
712
|
}
|
|
698
713
|
Logger.Info('millenniumAPI', 'Loading tsconfig from ' + chalk.cyan.bold(tsConfigPath) + '... ' + chalk.green.bold('okay'));
|
|
699
714
|
let pluginList = [
|
|
715
|
+
typescript({
|
|
716
|
+
tsconfig: tsConfigPath,
|
|
717
|
+
compilerOptions: {
|
|
718
|
+
outDir: undefined,
|
|
719
|
+
},
|
|
720
|
+
}),
|
|
700
721
|
url({
|
|
701
722
|
include: ['**/*.gif', '**/*.webm', '**/*.svg'], // Add all non-JS assets you use
|
|
702
723
|
limit: 0, // Set to 0 to always copy the file instead of inlining as base64
|
|
703
724
|
fileName: '[hash][extname]', // Optional: custom output naming
|
|
704
725
|
}),
|
|
705
726
|
InsertMillennium(ComponentType.Plugin, props),
|
|
706
|
-
commonjs(),
|
|
707
|
-
nodePolyfills(),
|
|
708
727
|
nodeResolve({
|
|
709
728
|
browser: true,
|
|
710
729
|
}),
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
tsconfig: tsConfigPath,
|
|
714
|
-
}),
|
|
730
|
+
commonjs(),
|
|
731
|
+
nodePolyfills(),
|
|
715
732
|
scss({
|
|
716
733
|
output: false,
|
|
717
734
|
outputStyle: 'compressed',
|
|
@@ -719,7 +736,6 @@ async function GetPluginComponents(props) {
|
|
|
719
736
|
watch: 'src/styles',
|
|
720
737
|
sass: sass,
|
|
721
738
|
}),
|
|
722
|
-
resolve(),
|
|
723
739
|
json(),
|
|
724
740
|
constSysfsExpr(),
|
|
725
741
|
replace({
|
|
@@ -776,19 +792,30 @@ async function GetWebkitPluginComponents(props) {
|
|
|
776
792
|
props.bTersePlugin && pluginList.push(terser());
|
|
777
793
|
return pluginList;
|
|
778
794
|
}
|
|
779
|
-
const GetFrontEndDirectory = () => {
|
|
780
|
-
const pluginJsonPath = './plugin.json';
|
|
795
|
+
const GetFrontEndDirectory = (pluginJson) => {
|
|
781
796
|
try {
|
|
782
|
-
return
|
|
797
|
+
return pluginJson?.frontend ?? 'frontend';
|
|
783
798
|
}
|
|
784
799
|
catch (error) {
|
|
785
800
|
return 'frontend';
|
|
786
801
|
}
|
|
787
802
|
};
|
|
788
|
-
const TranspilerPluginComponent = async (props) => {
|
|
803
|
+
const TranspilerPluginComponent = async (bIsMillennium, pluginJson, props) => {
|
|
804
|
+
const frontendDir = GetFrontEndDirectory(pluginJson);
|
|
805
|
+
console.log(chalk.greenBright.bold('config'), 'Frontend directory set to:', chalk.cyan.bold(frontendDir));
|
|
806
|
+
const frontendPlugins = await GetPluginComponents(pluginJson, props);
|
|
807
|
+
// Fix entry file path construction
|
|
808
|
+
let entryFile = '';
|
|
809
|
+
if (frontendDir === '.' || frontendDir === './' || frontendDir === '') {
|
|
810
|
+
entryFile = './index.tsx';
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
entryFile = `./${frontendDir}/index.tsx`;
|
|
814
|
+
}
|
|
815
|
+
console.log(chalk.greenBright.bold('config'), 'Entry file set to:', chalk.cyan.bold(entryFile));
|
|
789
816
|
const frontendRollupConfig = {
|
|
790
|
-
input:
|
|
791
|
-
plugins:
|
|
817
|
+
input: entryFile,
|
|
818
|
+
plugins: frontendPlugins,
|
|
792
819
|
context: 'window',
|
|
793
820
|
external: (id) => {
|
|
794
821
|
if (id === '@steambrew/webkit') {
|
|
@@ -799,7 +826,7 @@ const TranspilerPluginComponent = async (props) => {
|
|
|
799
826
|
},
|
|
800
827
|
output: {
|
|
801
828
|
name: 'millennium_main',
|
|
802
|
-
file: '.millennium/Dist/index.js',
|
|
829
|
+
file: bIsMillennium ? '../../build/frontend.bin' : '.millennium/Dist/index.js',
|
|
803
830
|
globals: {
|
|
804
831
|
react: 'window.SP_REACT',
|
|
805
832
|
'react-dom': 'window.SP_REACTDOM',
|
|
@@ -854,15 +881,16 @@ const CheckModuleUpdates = async () => {
|
|
|
854
881
|
};
|
|
855
882
|
const StartCompilerModule = () => {
|
|
856
883
|
const parameters = ValidateParameters(process.argv.slice(2));
|
|
884
|
+
const bIsMillennium = parameters.isMillennium || false;
|
|
857
885
|
const bTersePlugin = parameters.type == BuildType.ProdBuild;
|
|
858
886
|
console.log(chalk.greenBright.bold('config'), 'Building target:', parameters.targetPlugin, 'with type:', BuildType[parameters.type], 'minify:', bTersePlugin, '...');
|
|
859
|
-
ValidatePlugin(parameters.targetPlugin)
|
|
887
|
+
ValidatePlugin(bIsMillennium, parameters.targetPlugin)
|
|
860
888
|
.then((json) => {
|
|
861
889
|
const props = {
|
|
862
890
|
bTersePlugin: bTersePlugin,
|
|
863
891
|
strPluginInternalName: json?.name,
|
|
864
892
|
};
|
|
865
|
-
TranspilerPluginComponent(props);
|
|
893
|
+
TranspilerPluginComponent(bIsMillennium, json, props);
|
|
866
894
|
})
|
|
867
895
|
/**
|
|
868
896
|
* plugin is invalid, we close the proccess as it has already been handled
|
package/package.json
CHANGED
package/src/check-health.ts
CHANGED
|
@@ -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/query-parser.ts
CHANGED
|
@@ -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
|
-
|
|
151
|
-
|
|
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
|
|
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:
|
|
238
|
-
plugins:
|
|
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',
|