@steambrew/ttc 1.1.1 → 1.2.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.
Files changed (3) hide show
  1. package/Compiler.ts +232 -200
  2. package/dist/index.js +69 -53
  3. package/package.json +2 -2
package/Compiler.ts CHANGED
@@ -1,259 +1,291 @@
1
1
  import { OutputOptions, RollupOptions, rollup } from "rollup";
2
- import json from '@rollup/plugin-json';
3
- import commonjs from '@rollup/plugin-commonjs';
4
- import replace from '@rollup/plugin-replace';
5
- import typescript from '@rollup/plugin-typescript';
6
- import resolve from '@rollup/plugin-node-resolve';
7
- import terser from '@rollup/plugin-terser';
8
- import babel from '@rollup/plugin-babel';
9
-
10
- import chalk from 'chalk'
2
+ import json from "@rollup/plugin-json";
3
+ import commonjs from "@rollup/plugin-commonjs";
4
+ import replace from "@rollup/plugin-replace";
5
+ import typescript from "@rollup/plugin-typescript";
6
+ import resolve from "@rollup/plugin-node-resolve";
7
+ import terser from "@rollup/plugin-terser";
8
+ import babel from "@rollup/plugin-babel";
9
+
10
+ import chalk from "chalk";
11
11
  import { Logger } from "./Logger";
12
- import fs from 'fs';
12
+ import fs from "fs";
13
13
 
14
- import injectProcessEnv from 'rollup-plugin-inject-process-env';
15
- import dotenv from 'dotenv';
14
+ import injectProcessEnv from "rollup-plugin-inject-process-env";
15
+ import dotenv from "dotenv";
16
16
 
17
17
  const envConfig = dotenv.config().parsed || {};
18
18
 
19
19
  if (envConfig) {
20
- Logger.Info("Injecting environment variables...")
20
+ Logger.Info("Injecting environment variables...");
21
21
  }
22
22
 
23
23
  const envVars = Object.keys(envConfig).reduce((acc: any, key) => {
24
- acc[`process.env.${key}`] = JSON.stringify(envConfig[key]);
24
+ acc[key] = envConfig[key];
25
25
  return acc;
26
26
  }, {});
27
27
 
28
28
  declare global {
29
- interface Window {
30
- PLUGIN_LIST: any
31
- }
29
+ interface Window {
30
+ PLUGIN_LIST: any;
31
+ }
32
32
  }
33
33
 
34
- declare const pluginName: string, millennium_main: any, MILLENNIUM_BACKEND_IPC: any
34
+ declare const pluginName: string,
35
+ millennium_main: any,
36
+ MILLENNIUM_BACKEND_IPC: any;
35
37
 
36
38
  export interface TranspilerProps {
37
- bTersePlugin?: boolean,
38
- strPluginInternalName: string
39
+ bTersePlugin?: boolean;
40
+ strPluginInternalName: string;
39
41
  }
40
42
 
41
- const WrappedCallServerMethod = "const __call_server_method__ = (methodName, kwargs) => Millennium.callServerMethod(pluginName, methodName, kwargs)"
42
- const WrappedCallable = "const __wrapped_callable__ = (route) => MILLENNIUM_API.callable(__call_server_method__, route)"
43
+ const WrappedCallServerMethod =
44
+ "const __call_server_method__ = (methodName, kwargs) => Millennium.callServerMethod(pluginName, methodName, kwargs)";
45
+ const WrappedCallable =
46
+ "const __wrapped_callable__ = (route) => MILLENNIUM_API.callable(__call_server_method__, route)";
43
47
 
44
48
  /**
45
- * @description Append the active plugin to the global plugin
49
+ * @description Append the active plugin to the global plugin
46
50
  * list and notify that the frontend Loaded.
47
51
  */
48
52
  function ExecutePluginModule() {
49
- // Assign the plugin on plugin list.
50
- Object.assign(window.PLUGIN_LIST[pluginName], millennium_main)
51
- // Run the rolled up plugins default exported function
52
- millennium_main["default"]();
53
- MILLENNIUM_BACKEND_IPC.postMessage(1, { pluginName: pluginName })
53
+ // Assign the plugin on plugin list.
54
+ Object.assign(window.PLUGIN_LIST[pluginName], millennium_main);
55
+ // Run the rolled up plugins default exported function
56
+ millennium_main["default"]();
57
+ MILLENNIUM_BACKEND_IPC.postMessage(1, { pluginName: pluginName });
54
58
  }
55
59
 
56
60
  /**
57
- * @description Append the active plugin to the global plugin
61
+ * @description Append the active plugin to the global plugin
58
62
  * list and notify that the frontend Loaded.
59
63
  */
60
64
  function ExecuteWebkitModule() {
61
- // Assign the plugin on plugin list.
62
- Object.assign(window.PLUGIN_LIST[pluginName], millennium_main)
63
- // Run the rolled up plugins default exported function
64
- millennium_main["default"]();
65
+ // Assign the plugin on plugin list.
66
+ Object.assign(window.PLUGIN_LIST[pluginName], millennium_main);
67
+ // Run the rolled up plugins default exported function
68
+ millennium_main["default"]();
65
69
  }
66
70
 
67
71
  /**
68
- * @description Simple bootstrap function that initializes PLUGIN_LIST
69
- * for current plugin given that is doesnt exist.
72
+ * @description Simple bootstrap function that initializes PLUGIN_LIST
73
+ * for current plugin given that is doesnt exist.
70
74
  */
71
75
  function InitializePlugins() {
72
- /**
73
- * This function is called n times depending on n plugin count,
74
- * Create the plugin list if it wasn't already created
75
- */
76
- !window.PLUGIN_LIST && (window.PLUGIN_LIST = {})
77
-
78
- // initialize a container for the plugin
79
- if (!window.PLUGIN_LIST[pluginName]) {
80
- window.PLUGIN_LIST[pluginName] = {};
81
- }
76
+ /**
77
+ * This function is called n times depending on n plugin count,
78
+ * Create the plugin list if it wasn't already created
79
+ */
80
+ !window.PLUGIN_LIST && (window.PLUGIN_LIST = {});
81
+
82
+ // initialize a container for the plugin
83
+ if (!window.PLUGIN_LIST[pluginName]) {
84
+ window.PLUGIN_LIST[pluginName] = {};
85
+ }
82
86
  }
83
87
 
84
- const ContructFunctions = (parts: any) => { return parts.join('\n'); }
85
-
86
- function InsertMillennium(props: TranspilerProps)
87
- {
88
- const generateBundle = (_: unknown, bundle: any) => {
89
- for (const fileName in bundle) {
90
- if (bundle[fileName].type != 'chunk') continue
91
-
92
- Logger.Info("Injecting Millennium shims into module... " + chalk.green.bold("okay"))
93
-
94
- bundle[fileName].code = ContructFunctions([
95
- `const pluginName = "${props.strPluginInternalName}";`,
96
- InitializePlugins.toString(), InitializePlugins.name + "()",
97
- WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
98
- ExecutePluginModule.toString(), ExecutePluginModule.name + "()"
99
- ])
100
- }
88
+ const ContructFunctions = (parts: any) => {
89
+ return parts.join("\n");
90
+ };
91
+
92
+ function InsertMillennium(props: TranspilerProps) {
93
+ const generateBundle = (_: unknown, bundle: any) => {
94
+ for (const fileName in bundle) {
95
+ if (bundle[fileName].type != "chunk") continue;
96
+
97
+ Logger.Info(
98
+ "Injecting Millennium shims into module... " + chalk.green.bold("okay")
99
+ );
100
+
101
+ bundle[fileName].code = ContructFunctions([
102
+ `const pluginName = "${props.strPluginInternalName}";`,
103
+ InitializePlugins.toString(),
104
+ InitializePlugins.name + "()",
105
+ WrappedCallServerMethod,
106
+ WrappedCallable,
107
+ bundle[fileName].code,
108
+ ExecutePluginModule.toString(),
109
+ ExecutePluginModule.name + "()",
110
+ ]);
101
111
  }
112
+ };
102
113
 
103
- return { name: String(), generateBundle };
114
+ return { name: String(), generateBundle };
104
115
  }
105
116
 
106
- function InsertWebkitMillennium(props: TranspilerProps)
107
- {
108
- const generateBundle = (_: unknown, bundle: any) => {
109
- for (const fileName in bundle) {
110
- if (bundle[fileName].type != 'chunk') continue
111
-
112
- Logger.Info("Injecting Millennium shims into webkit module... " + chalk.green.bold("okay"))
113
-
114
- bundle[fileName].code = ContructFunctions([
115
- `const pluginName = "${props.strPluginInternalName}";`,
116
- InitializePlugins.toString(), InitializePlugins.name + "()",
117
- WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
118
- ExecuteWebkitModule.toString(), ExecuteWebkitModule.name + "()"
119
- ])
120
- }
117
+ function InsertWebkitMillennium(props: TranspilerProps) {
118
+ const generateBundle = (_: unknown, bundle: any) => {
119
+ for (const fileName in bundle) {
120
+ if (bundle[fileName].type != "chunk") continue;
121
+
122
+ Logger.Info(
123
+ "Injecting Millennium shims into webkit module... " +
124
+ chalk.green.bold("okay")
125
+ );
126
+
127
+ bundle[fileName].code = ContructFunctions([
128
+ `const pluginName = "${props.strPluginInternalName}";`,
129
+ InitializePlugins.toString(),
130
+ InitializePlugins.name + "()",
131
+ WrappedCallServerMethod,
132
+ WrappedCallable,
133
+ bundle[fileName].code,
134
+ ExecuteWebkitModule.toString(),
135
+ ExecuteWebkitModule.name + "()",
136
+ ]);
121
137
  }
138
+ };
122
139
 
123
- return { name: String(), generateBundle };
140
+ return { name: String(), generateBundle };
124
141
  }
125
142
 
126
143
  function GetPluginComponents(props: TranspilerProps) {
127
-
128
- let tsConfigPath = `./${GetFrontEndDirectory()}/tsconfig.json`
129
-
130
- if (!fs.existsSync(tsConfigPath)) {
131
- tsConfigPath = './tsconfig.json'
132
- }
133
-
134
- const pluginList = [
135
- InsertMillennium(props),
136
- typescript({
137
- tsconfig: tsConfigPath
138
- }),
139
- resolve(), commonjs(), json(),
140
- injectProcessEnv(envVars),
141
- replace({
142
- delimiters: ['', ''],
143
- preventAssignment: true,
144
- 'process.env.NODE_ENV' : JSON.stringify('production'),
145
- 'Millennium.callServerMethod' : `__call_server_method__`,
146
- 'client.callable' : `__wrapped_callable__`,
147
- 'client.pluginSelf' : 'window.PLUGIN_LIST[pluginName]',
148
- 'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, '
149
- }),
150
- ]
151
-
152
- if (props.bTersePlugin) {
153
- pluginList.push(terser())
154
- }
155
- return pluginList
144
+ let tsConfigPath = `./${GetFrontEndDirectory()}/tsconfig.json`;
145
+
146
+ if (!fs.existsSync(tsConfigPath)) {
147
+ tsConfigPath = "./tsconfig.json";
148
+ }
149
+
150
+ const pluginList = [
151
+ InsertMillennium(props),
152
+ typescript({
153
+ tsconfig: tsConfigPath,
154
+ }),
155
+ resolve(),
156
+ commonjs(),
157
+ json(),
158
+ injectProcessEnv(envVars),
159
+ replace({
160
+ delimiters: ["", ""],
161
+ preventAssignment: true,
162
+ "process.env.NODE_ENV": JSON.stringify("production"),
163
+ "Millennium.callServerMethod": `__call_server_method__`,
164
+ "client.callable": `__wrapped_callable__`,
165
+ "client.pluginSelf": "window.PLUGIN_LIST[pluginName]",
166
+ "client.Millennium.exposeObj(": "client.Millennium.exposeObj(exports, ",
167
+ }),
168
+ ];
169
+
170
+ if (props.bTersePlugin) {
171
+ pluginList.push(terser());
172
+ }
173
+ return pluginList;
156
174
  }
157
175
 
158
176
  function GetWebkitPluginComponents(props: TranspilerProps) {
159
- const pluginList = [
160
- InsertWebkitMillennium(props),
161
- typescript({
162
- tsconfig: './webkit/tsconfig.json'
163
- }),
164
- resolve(), commonjs(), json(),
165
- injectProcessEnv(envVars),
166
- replace({
167
- delimiters: ['', ''],
168
- preventAssignment: true,
169
- 'Millennium.callServerMethod': `__call_server_method__`,
170
- 'webkit.callable': `__wrapped_callable__`,
171
- }),
172
- babel({
173
- presets: ['@babel/preset-env', '@babel/preset-react'],
174
- babelHelpers: 'bundled',
175
- })
176
- ]
177
-
178
- props.bTersePlugin && pluginList.push(terser())
179
- return pluginList
177
+ const pluginList = [
178
+ InsertWebkitMillennium(props),
179
+ typescript({
180
+ tsconfig: "./webkit/tsconfig.json",
181
+ }),
182
+ resolve(),
183
+ commonjs(),
184
+ json(),
185
+ injectProcessEnv(envVars),
186
+ replace({
187
+ delimiters: ["", ""],
188
+ preventAssignment: true,
189
+ "Millennium.callServerMethod": `__call_server_method__`,
190
+ "webkit.callable": `__wrapped_callable__`,
191
+ }),
192
+ babel({
193
+ presets: ["@babel/preset-env", "@babel/preset-react"],
194
+ babelHelpers: "bundled",
195
+ }),
196
+ ];
197
+
198
+ props.bTersePlugin && pluginList.push(terser());
199
+ return pluginList;
180
200
  }
181
201
 
182
202
  const GetFrontEndDirectory = () => {
183
- const pluginJsonPath = './plugin.json';
184
- try {
185
- return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? "frontend";
186
- }
187
- catch (error) {
188
- return "frontend";
189
- }
190
- }
203
+ const pluginJsonPath = "./plugin.json";
204
+ try {
205
+ return (
206
+ JSON.parse(fs.readFileSync(pluginJsonPath, "utf8"))?.frontend ??
207
+ "frontend"
208
+ );
209
+ } catch (error) {
210
+ return "frontend";
211
+ }
212
+ };
191
213
 
192
214
  export const TranspilerPluginComponent = async (props: TranspilerProps) => {
193
-
194
- const frontendRollupConfig: RollupOptions = {
195
- input: `./${GetFrontEndDirectory()}/index.tsx`,
196
- plugins: GetPluginComponents(props),
197
- context: 'window',
198
- external: (id) => {
199
- if (id === '@steambrew/webkit') {
200
- 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.')
201
- process.exit(1)
202
- }
203
-
204
- return id === '@steambrew/client' || id === 'react' || id === 'react-dom'
215
+ const frontendRollupConfig: RollupOptions = {
216
+ input: `./${GetFrontEndDirectory()}/index.tsx`,
217
+ plugins: GetPluginComponents(props),
218
+ context: "window",
219
+ external: (id) => {
220
+ if (id === "@steambrew/webkit") {
221
+ Logger.Error(
222
+ "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."
223
+ );
224
+ process.exit(1);
225
+ }
226
+
227
+ return id === "@steambrew/client" || id === "react" || id === "react-dom";
228
+ },
229
+ output: {
230
+ name: "millennium_main",
231
+ file: ".millennium/Dist/index.js",
232
+ globals: {
233
+ react: "window.SP_REACT",
234
+ "react-dom": "window.SP_REACTDOM",
235
+ "@steambrew/client": "window.MILLENNIUM_API",
236
+ },
237
+ exports: "named",
238
+ format: "iife",
239
+ },
240
+ };
241
+
242
+ Logger.Info("Starting build; this may take a few moments...");
243
+
244
+ try {
245
+ await (
246
+ await rollup(frontendRollupConfig)
247
+ ).write(frontendRollupConfig.output as OutputOptions);
248
+
249
+ if (fs.existsSync(`./webkit/index.tsx`)) {
250
+ Logger.Info("Compiling webkit module...");
251
+
252
+ const webkitRollupConfig: RollupOptions = {
253
+ input: `./webkit/index.tsx`,
254
+ plugins: GetWebkitPluginComponents(props),
255
+ context: "window",
256
+ external: (id) => {
257
+ if (id === "@steambrew/client") {
258
+ Logger.Error(
259
+ "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."
260
+ );
261
+ process.exit(1);
262
+ }
263
+
264
+ return id === "@steambrew/webkit";
205
265
  },
206
266
  output: {
207
- name: "millennium_main",
208
- file: ".millennium/Dist/index.js",
209
- globals: {
210
- "react" : "window.SP_REACT",
211
- "react-dom" : "window.SP_REACTDOM",
212
- "@steambrew/client": "window.MILLENNIUM_API"
213
- },
214
- exports: 'named',
215
- format: 'iife'
216
- }
217
- }
267
+ name: "millennium_main",
268
+ file: ".millennium/Dist/webkit.js",
269
+ exports: "named",
270
+ format: "iife",
271
+ globals: {
272
+ "@steambrew/webkit": "window.MILLENNIUM_API",
273
+ },
274
+ },
275
+ };
218
276
 
219
- Logger.Info("Starting build; this may take a few moments...")
220
-
221
- try {
222
- await (await rollup(frontendRollupConfig)).write(frontendRollupConfig.output as OutputOptions);
223
-
224
- if (fs.existsSync(`./webkit/index.tsx`)) {
225
- Logger.Info("Compiling webkit module...")
226
-
227
- const webkitRollupConfig: RollupOptions = {
228
- input: `./webkit/index.tsx`,
229
- plugins: GetWebkitPluginComponents(props),
230
- context: 'window',
231
- external: (id) => {
232
- if (id === '@steambrew/client') {
233
- 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.')
234
- process.exit(1)
235
- }
236
-
237
- return id === '@steambrew/webkit'
238
- },
239
- output: {
240
- name: "millennium_main",
241
- file: ".millennium/Dist/webkit.js",
242
- exports: 'named',
243
- format: 'iife',
244
- globals: {
245
- "@steambrew/webkit": "window.MILLENNIUM_API"
246
- },
247
- }
248
- }
249
-
250
- await (await rollup(webkitRollupConfig)).write(webkitRollupConfig.output as OutputOptions);
251
- }
252
-
253
- Logger.Info('Build succeeded!', Number((performance.now() - global.PerfStartTime).toFixed(3)), 'ms elapsed.')
277
+ await (
278
+ await rollup(webkitRollupConfig)
279
+ ).write(webkitRollupConfig.output as OutputOptions);
254
280
  }
255
- catch (exception) {
256
- Logger.Error('Build failed!', exception)
257
- process.exit(1)
258
- }
259
- }
281
+
282
+ Logger.Info(
283
+ "Build succeeded!",
284
+ Number((performance.now() - global.PerfStartTime).toFixed(3)),
285
+ "ms elapsed."
286
+ );
287
+ } catch (exception) {
288
+ Logger.Error("Build failed!", exception);
289
+ process.exit(1);
290
+ }
291
+ };
package/dist/index.js CHANGED
@@ -171,7 +171,7 @@ if (envConfig) {
171
171
  Logger.Info("Injecting environment variables...");
172
172
  }
173
173
  const envVars = Object.keys(envConfig).reduce((acc, key) => {
174
- acc[`process.env.${key}`] = JSON.stringify(envConfig[key]);
174
+ acc[key] = envConfig[key];
175
175
  return acc;
176
176
  }, {});
177
177
  const WrappedCallServerMethod = "const __call_server_method__ = (methodName, kwargs) => Millennium.callServerMethod(pluginName, methodName, kwargs)";
@@ -181,9 +181,9 @@ const WrappedCallable = "const __wrapped_callable__ = (route) => MILLENNIUM_API.
181
181
  * list and notify that the frontend Loaded.
182
182
  */
183
183
  function ExecutePluginModule() {
184
- // Assign the plugin on plugin list.
184
+ // Assign the plugin on plugin list.
185
185
  Object.assign(window.PLUGIN_LIST[pluginName], millennium_main);
186
- // Run the rolled up plugins default exported function
186
+ // Run the rolled up plugins default exported function
187
187
  millennium_main["default"]();
188
188
  MILLENNIUM_BACKEND_IPC.postMessage(1, { pluginName: pluginName });
189
189
  }
@@ -192,9 +192,9 @@ function ExecutePluginModule() {
192
192
  * list and notify that the frontend Loaded.
193
193
  */
194
194
  function ExecuteWebkitModule() {
195
- // Assign the plugin on plugin list.
195
+ // Assign the plugin on plugin list.
196
196
  Object.assign(window.PLUGIN_LIST[pluginName], millennium_main);
197
- // Run the rolled up plugins default exported function
197
+ // Run the rolled up plugins default exported function
198
198
  millennium_main["default"]();
199
199
  }
200
200
  /**
@@ -212,18 +212,24 @@ function InitializePlugins() {
212
212
  window.PLUGIN_LIST[pluginName] = {};
213
213
  }
214
214
  }
215
- const ContructFunctions = (parts) => { return parts.join('\n'); };
215
+ const ContructFunctions = (parts) => {
216
+ return parts.join("\n");
217
+ };
216
218
  function InsertMillennium(props) {
217
219
  const generateBundle = (_, bundle) => {
218
220
  for (const fileName in bundle) {
219
- if (bundle[fileName].type != 'chunk')
221
+ if (bundle[fileName].type != "chunk")
220
222
  continue;
221
223
  Logger.Info("Injecting Millennium shims into module... " + chalk.green.bold("okay"));
222
224
  bundle[fileName].code = ContructFunctions([
223
225
  `const pluginName = "${props.strPluginInternalName}";`,
224
- InitializePlugins.toString(), InitializePlugins.name + "()",
225
- WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
226
- ExecutePluginModule.toString(), ExecutePluginModule.name + "()"
226
+ InitializePlugins.toString(),
227
+ InitializePlugins.name + "()",
228
+ WrappedCallServerMethod,
229
+ WrappedCallable,
230
+ bundle[fileName].code,
231
+ ExecutePluginModule.toString(),
232
+ ExecutePluginModule.name + "()",
227
233
  ]);
228
234
  }
229
235
  };
@@ -232,14 +238,19 @@ function InsertMillennium(props) {
232
238
  function InsertWebkitMillennium(props) {
233
239
  const generateBundle = (_, bundle) => {
234
240
  for (const fileName in bundle) {
235
- if (bundle[fileName].type != 'chunk')
241
+ if (bundle[fileName].type != "chunk")
236
242
  continue;
237
- Logger.Info("Injecting Millennium shims into webkit module... " + chalk.green.bold("okay"));
243
+ Logger.Info("Injecting Millennium shims into webkit module... " +
244
+ chalk.green.bold("okay"));
238
245
  bundle[fileName].code = ContructFunctions([
239
246
  `const pluginName = "${props.strPluginInternalName}";`,
240
- InitializePlugins.toString(), InitializePlugins.name + "()",
241
- WrappedCallServerMethod, WrappedCallable, bundle[fileName].code,
242
- ExecuteWebkitModule.toString(), ExecuteWebkitModule.name + "()"
247
+ InitializePlugins.toString(),
248
+ InitializePlugins.name + "()",
249
+ WrappedCallServerMethod,
250
+ WrappedCallable,
251
+ bundle[fileName].code,
252
+ ExecuteWebkitModule.toString(),
253
+ ExecuteWebkitModule.name + "()",
243
254
  ]);
244
255
  }
245
256
  };
@@ -248,23 +259,25 @@ function InsertWebkitMillennium(props) {
248
259
  function GetPluginComponents(props) {
249
260
  let tsConfigPath = `./${GetFrontEndDirectory()}/tsconfig.json`;
250
261
  if (!fs.existsSync(tsConfigPath)) {
251
- tsConfigPath = './tsconfig.json';
262
+ tsConfigPath = "./tsconfig.json";
252
263
  }
253
264
  const pluginList = [
254
265
  InsertMillennium(props),
255
266
  typescript({
256
- tsconfig: tsConfigPath
267
+ tsconfig: tsConfigPath,
257
268
  }),
258
- resolve(), commonjs(), json(),
269
+ resolve(),
270
+ commonjs(),
271
+ json(),
259
272
  injectProcessEnv(envVars),
260
273
  replace({
261
- delimiters: ['', ''],
274
+ delimiters: ["", ""],
262
275
  preventAssignment: true,
263
- 'process.env.NODE_ENV': JSON.stringify('production'),
264
- 'Millennium.callServerMethod': `__call_server_method__`,
265
- 'client.callable': `__wrapped_callable__`,
266
- 'client.pluginSelf': 'window.PLUGIN_LIST[pluginName]',
267
- 'client.Millennium.exposeObj(': 'client.Millennium.exposeObj(exports, '
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, ",
268
281
  }),
269
282
  ];
270
283
  if (props.bTersePlugin) {
@@ -276,28 +289,31 @@ function GetWebkitPluginComponents(props) {
276
289
  const pluginList = [
277
290
  InsertWebkitMillennium(props),
278
291
  typescript({
279
- tsconfig: './webkit/tsconfig.json'
292
+ tsconfig: "./webkit/tsconfig.json",
280
293
  }),
281
- resolve(), commonjs(), json(),
294
+ resolve(),
295
+ commonjs(),
296
+ json(),
282
297
  injectProcessEnv(envVars),
283
298
  replace({
284
- delimiters: ['', ''],
299
+ delimiters: ["", ""],
285
300
  preventAssignment: true,
286
- 'Millennium.callServerMethod': `__call_server_method__`,
287
- 'webkit.callable': `__wrapped_callable__`,
301
+ "Millennium.callServerMethod": `__call_server_method__`,
302
+ "webkit.callable": `__wrapped_callable__`,
288
303
  }),
289
304
  babel({
290
- presets: ['@babel/preset-env', '@babel/preset-react'],
291
- babelHelpers: 'bundled',
292
- })
305
+ presets: ["@babel/preset-env", "@babel/preset-react"],
306
+ babelHelpers: "bundled",
307
+ }),
293
308
  ];
294
309
  props.bTersePlugin && pluginList.push(terser());
295
310
  return pluginList;
296
311
  }
297
312
  const GetFrontEndDirectory = () => {
298
- const pluginJsonPath = './plugin.json';
313
+ const pluginJsonPath = "./plugin.json";
299
314
  try {
300
- return JSON.parse(fs.readFileSync(pluginJsonPath, 'utf8'))?.frontend ?? "frontend";
315
+ return (JSON.parse(fs.readFileSync(pluginJsonPath, "utf8"))?.frontend ??
316
+ "frontend");
301
317
  }
302
318
  catch (error) {
303
319
  return "frontend";
@@ -307,25 +323,25 @@ const TranspilerPluginComponent = async (props) => {
307
323
  const frontendRollupConfig = {
308
324
  input: `./${GetFrontEndDirectory()}/index.tsx`,
309
325
  plugins: GetPluginComponents(props),
310
- context: 'window',
326
+ context: "window",
311
327
  external: (id) => {
312
- if (id === '@steambrew/webkit') {
313
- 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.');
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.");
314
330
  process.exit(1);
315
331
  }
316
- return id === '@steambrew/client' || id === 'react' || id === 'react-dom';
332
+ return id === "@steambrew/client" || id === "react" || id === "react-dom";
317
333
  },
318
334
  output: {
319
335
  name: "millennium_main",
320
336
  file: ".millennium/Dist/index.js",
321
337
  globals: {
322
- "react": "window.SP_REACT",
338
+ react: "window.SP_REACT",
323
339
  "react-dom": "window.SP_REACTDOM",
324
- "@steambrew/client": "window.MILLENNIUM_API"
340
+ "@steambrew/client": "window.MILLENNIUM_API",
325
341
  },
326
- exports: 'named',
327
- format: 'iife'
328
- }
342
+ exports: "named",
343
+ format: "iife",
344
+ },
329
345
  };
330
346
  Logger.Info("Starting build; this may take a few moments...");
331
347
  try {
@@ -335,30 +351,30 @@ const TranspilerPluginComponent = async (props) => {
335
351
  const webkitRollupConfig = {
336
352
  input: `./webkit/index.tsx`,
337
353
  plugins: GetWebkitPluginComponents(props),
338
- context: 'window',
354
+ context: "window",
339
355
  external: (id) => {
340
- if (id === '@steambrew/client') {
341
- 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.');
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.");
342
358
  process.exit(1);
343
359
  }
344
- return id === '@steambrew/webkit';
360
+ return id === "@steambrew/webkit";
345
361
  },
346
362
  output: {
347
363
  name: "millennium_main",
348
364
  file: ".millennium/Dist/webkit.js",
349
- exports: 'named',
350
- format: 'iife',
365
+ exports: "named",
366
+ format: "iife",
351
367
  globals: {
352
- "@steambrew/webkit": "window.MILLENNIUM_API"
368
+ "@steambrew/webkit": "window.MILLENNIUM_API",
353
369
  },
354
- }
370
+ },
355
371
  };
356
372
  await (await rollup(webkitRollupConfig)).write(webkitRollupConfig.output);
357
373
  }
358
- Logger.Info('Build succeeded!', Number((performance.now() - global.PerfStartTime).toFixed(3)), 'ms elapsed.');
374
+ Logger.Info("Build succeeded!", Number((performance.now() - global.PerfStartTime).toFixed(3)), "ms elapsed.");
359
375
  }
360
376
  catch (exception) {
361
- Logger.Error('Build failed!', exception);
377
+ Logger.Error("Build failed!", exception);
362
378
  process.exit(1);
363
379
  }
364
380
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steambrew/ttc",
3
- "version": "1.1.1",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -37,4 +37,4 @@
37
37
  "devDependencies": {
38
38
  "@types/node": "^22.10.1"
39
39
  }
40
- }
40
+ }