@steambrew/ttc 2.4.2 → 2.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steambrew/ttc",
3
- "version": "2.4.2",
3
+ "version": "2.5.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -31,6 +31,7 @@
31
31
  "@rollup/plugin-replace": "^6.0.1",
32
32
  "@rollup/plugin-terser": "^0.4.4",
33
33
  "@rollup/plugin-typescript": "^12.1.1",
34
+ "@rollup/plugin-url": "^8.0.2",
34
35
  "@rollup/pluginutils": "^5.1.4",
35
36
  "chalk": "^5.3.0",
36
37
  "dotenv": "^16.4.7",
@@ -39,6 +40,9 @@
39
40
  "magic-string": "^0.30.17",
40
41
  "rollup": "^4.40.0",
41
42
  "rollup-plugin-inject-process-env": "^1.3.1",
43
+ "rollup-plugin-polyfill-node": "^0.13.0",
44
+ "rollup-plugin-scss": "^4.0.1",
45
+ "sass": "^1.87.0",
42
46
  "tslib": "^2.8.1"
43
47
  },
44
48
  "devDependencies": {
package/rollup.config.js CHANGED
@@ -4,7 +4,7 @@ import json from '@rollup/plugin-json';
4
4
  import nodeResolve from '@rollup/plugin-node-resolve';
5
5
 
6
6
  export default {
7
- input: 'index.ts',
7
+ input: 'src/index.ts',
8
8
  context: 'window',
9
9
  output: {
10
10
  file: 'dist/index.js',
@@ -30,5 +30,7 @@ export default {
30
30
  'perf_hooks',
31
31
  '@rollup/pluginutils',
32
32
  'magic-string',
33
+ 'rollup-plugin-scss',
34
+ 'sass',
33
35
  ],
34
36
  };
@@ -0,0 +1,41 @@
1
+ import chalk from 'chalk';
2
+ import path from 'path';
3
+ import { existsSync, readFile } from 'fs';
4
+
5
+ export const ValidatePlugin = (target: string): Promise<any> => {
6
+ return new Promise<any>((resolve, reject) => {
7
+ if (!existsSync(target)) {
8
+ console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid system path'));
9
+ reject();
10
+ return;
11
+ }
12
+
13
+ const pluginModule = path.join(target, 'plugin.json');
14
+
15
+ if (!existsSync(pluginModule)) {
16
+ console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid plugin (missing plugin.json)'));
17
+ reject();
18
+ return;
19
+ }
20
+
21
+ readFile(pluginModule, 'utf8', (err, data) => {
22
+ if (err) {
23
+ console.error(chalk.red.bold(`\n[-] couldn't read plugin.json from [${pluginModule}]`));
24
+ reject();
25
+ return;
26
+ }
27
+
28
+ try {
29
+ if (!('name' in JSON.parse(data))) {
30
+ console.error(chalk.red.bold(`\n[-] target plugin doesn't contain "name" in plugin.json [${pluginModule}]`));
31
+ reject();
32
+ } else {
33
+ resolve(JSON.parse(data));
34
+ }
35
+ } catch (parseError) {
36
+ console.error(chalk.red.bold(`\n[-] couldn't parse JSON in plugin.json from [${pluginModule}]`));
37
+ reject();
38
+ }
39
+ });
40
+ });
41
+ };
@@ -5,10 +5,10 @@
5
5
  * - typescript transpiler
6
6
  * - rollup configurator
7
7
  */
8
- import { BuildType, ValidateParameters } from './Parameters';
9
- import { CheckForUpdates } from './VersionMon';
10
- import { ValidatePlugin } from './Linter';
11
- import { TranspilerPluginComponent, TranspilerProps } from './Compiler';
8
+ import { BuildType, ValidateParameters } from './query-parser';
9
+ import { CheckForUpdates } from './version-control';
10
+ import { ValidatePlugin } from './check-health';
11
+ import { TranspilerPluginComponent, TranspilerProps } from './transpiler';
12
12
  import { performance } from 'perf_hooks';
13
13
  import chalk from 'chalk';
14
14
  // import { Logger } from './Logger'
@@ -0,0 +1,82 @@
1
+ import chalk from 'chalk';
2
+ import { Logger } from './logger';
3
+
4
+ /***
5
+ * @brief print the parameter list to the stdout
6
+ */
7
+ export const PrintParamHelp = () => {
8
+ console.log(
9
+ 'millennium-ttc parameter list:' +
10
+ '\n\t' +
11
+ chalk.magenta('--help') +
12
+ ': display parameter list' +
13
+ '\n\t' +
14
+ chalk.bold.red('--build') +
15
+ ': ' +
16
+ chalk.bold.red('(required)') +
17
+ ': build type [dev, prod] (prod minifies code)' +
18
+ '\n\t' +
19
+ chalk.magenta('--target') +
20
+ ': path to plugin, default to cwd',
21
+ );
22
+ };
23
+
24
+ export enum BuildType {
25
+ DevBuild,
26
+ ProdBuild,
27
+ }
28
+
29
+ export interface ParameterProps {
30
+ type: BuildType;
31
+ targetPlugin: string; // path
32
+ }
33
+
34
+ export const ValidateParameters = (args: Array<string>): ParameterProps => {
35
+ let typeProp: BuildType = BuildType.DevBuild,
36
+ targetProp: string = process.cwd();
37
+
38
+ if (args.includes('--help')) {
39
+ PrintParamHelp();
40
+ process.exit();
41
+ }
42
+
43
+ // startup args are invalid
44
+ if (!args.includes('--build')) {
45
+ Logger.Error('Received invalid arguments...');
46
+ PrintParamHelp();
47
+ process.exit();
48
+ }
49
+
50
+ for (let i = 0; i < args.length; i++) {
51
+ if (args[i] === '--build') {
52
+ const BuildMode: string = args[i + 1];
53
+
54
+ switch (BuildMode) {
55
+ case 'dev':
56
+ typeProp = BuildType.DevBuild;
57
+ break;
58
+ case 'prod':
59
+ typeProp = BuildType.ProdBuild;
60
+ break;
61
+ default: {
62
+ Logger.Error('--build parameter must be preceded by build type [dev, prod]');
63
+ process.exit();
64
+ }
65
+ }
66
+ }
67
+
68
+ if (args[i] == '--target') {
69
+ if (args[i + 1] === undefined) {
70
+ Logger.Error('--target parameter must be preceded by system path');
71
+ process.exit();
72
+ }
73
+
74
+ targetProp = args[i + 1];
75
+ }
76
+ }
77
+
78
+ return {
79
+ type: typeProp,
80
+ targetPlugin: targetProp,
81
+ };
82
+ };
@@ -3,18 +3,23 @@ import json from '@rollup/plugin-json';
3
3
  import commonjs from '@rollup/plugin-commonjs';
4
4
  import replace from '@rollup/plugin-replace';
5
5
  import typescript from '@rollup/plugin-typescript';
6
- import resolve from '@rollup/plugin-node-resolve';
6
+ import resolve, { nodeResolve } from '@rollup/plugin-node-resolve';
7
7
  import terser from '@rollup/plugin-terser';
8
8
  import babel from '@rollup/plugin-babel';
9
+ import nodePolyfills from 'rollup-plugin-polyfill-node';
10
+ import url from '@rollup/plugin-url';
11
+
12
+ import scss from 'rollup-plugin-scss';
13
+ import * as sass from 'sass';
9
14
 
10
15
  import chalk from 'chalk';
11
- import { Logger } from './Logger';
16
+ import { Logger } from './logger';
12
17
  import fs from 'fs';
13
18
 
14
19
  import injectProcessEnv from 'rollup-plugin-inject-process-env';
15
20
  import dotenv from 'dotenv';
16
- import { ExecutePluginModule, InitializePlugins } from './PluginSetup';
17
- import constSysfsExpr from './StaticEmbed';
21
+ import { ExecutePluginModule, InitializePlugins } from './plugin-api';
22
+ import constSysfsExpr from './static-embed';
18
23
 
19
24
  const envConfig = dotenv.config().parsed || {};
20
25
 
@@ -84,20 +89,69 @@ function InsertMillennium(type: ComponentType, props: TranspilerProps) {
84
89
  return { name: String(), generateBundle };
85
90
  }
86
91
 
87
- function GetPluginComponents(props: TranspilerProps) {
88
- let tsConfigPath = `./${GetFrontEndDirectory()}/tsconfig.json`;
92
+ async function GetCustomUserPlugins() {
93
+ const ttcConfigPath = new URL(`file://${process.cwd().replace(/\\/g, '/')}/ttc.config.mjs`).href;
94
+
95
+ if (fs.existsSync('./ttc.config.mjs')) {
96
+ const { MillenniumCompilerPlugins } = await import(ttcConfigPath);
97
+
98
+ Logger.Info('millenniumAPI', 'Loading custom plugins from ttc.config.mjs... ' + chalk.green.bold('okay'));
99
+ return MillenniumCompilerPlugins;
100
+ }
101
+
102
+ return [];
103
+ }
104
+
105
+ async function MergePluginList(plugins: any[]) {
106
+ const customPlugins = await GetCustomUserPlugins();
107
+
108
+ // Filter out custom plugins that have the same name as input plugins
109
+ const filteredCustomPlugins = customPlugins.filter((customPlugin: any) => !plugins.some((plugin: any) => plugin.name === customPlugin.name));
110
+
111
+ // Merge input plugins with the filtered custom plugins
112
+ return [...plugins, ...filteredCustomPlugins];
113
+ }
114
+
115
+ async function GetPluginComponents(props: TranspilerProps) {
116
+ let tsConfigPath = '';
117
+ const frontendDir = GetFrontEndDirectory();
118
+
119
+ if (frontendDir === '.' || frontendDir === './') {
120
+ tsConfigPath = './tsconfig.json';
121
+ } else {
122
+ tsConfigPath = `./${frontendDir}/tsconfig.json`;
123
+ }
89
124
 
90
125
  if (!fs.existsSync(tsConfigPath)) {
91
126
  tsConfigPath = './tsconfig.json';
92
127
  }
93
128
 
94
- const pluginList = [
129
+ Logger.Info('millenniumAPI', 'Loading tsconfig from ' + chalk.cyan.bold(tsConfigPath) + '... ' + chalk.green.bold('okay'));
130
+
131
+ let pluginList = [
132
+ url({
133
+ include: ['**/*.gif', '**/*.webm', '**/*.svg'], // Add all non-JS assets you use
134
+ limit: 0, // Set to 0 to always copy the file instead of inlining as base64
135
+ fileName: '[hash][extname]', // Optional: custom output naming
136
+ }),
95
137
  InsertMillennium(ComponentType.Plugin, props),
138
+ commonjs(),
139
+ nodePolyfills(),
140
+ nodeResolve({
141
+ browser: true,
142
+ }),
96
143
  typescript({
144
+ include: ['**/*.ts', '**/*.tsx', 'src/**/*.ts', 'src/**/*.tsx'],
97
145
  tsconfig: tsConfigPath,
98
146
  }),
147
+ scss({
148
+ output: false,
149
+ outputStyle: 'compressed',
150
+ sourceMap: false,
151
+ watch: 'src/styles',
152
+ sass: sass,
153
+ }),
99
154
  resolve(),
100
- commonjs(),
101
155
  json(),
102
156
  constSysfsExpr(),
103
157
  injectProcessEnv(envVars),
@@ -119,12 +173,18 @@ function GetPluginComponents(props: TranspilerProps) {
119
173
  return pluginList;
120
174
  }
121
175
 
122
- function GetWebkitPluginComponents(props: TranspilerProps) {
123
- const pluginList = [
176
+ async function GetWebkitPluginComponents(props: TranspilerProps) {
177
+ let pluginList = [
124
178
  InsertMillennium(ComponentType.Webkit, props),
125
179
  typescript({
126
180
  tsconfig: './webkit/tsconfig.json',
127
181
  }),
182
+ url({
183
+ include: ['**/*.mp4', '**/*.webm', '**/*.ogg'],
184
+ limit: 0, // do NOT inline
185
+ fileName: '[name][extname]',
186
+ destDir: 'dist/assets', // or adjust as needed
187
+ }),
128
188
  resolve(),
129
189
  commonjs(),
130
190
  json(),
@@ -143,6 +203,8 @@ function GetWebkitPluginComponents(props: TranspilerProps) {
143
203
  }),
144
204
  ];
145
205
 
206
+ pluginList = await MergePluginList(pluginList);
207
+
146
208
  props.bTersePlugin && pluginList.push(terser());
147
209
  return pluginList;
148
210
  }
@@ -159,7 +221,7 @@ const GetFrontEndDirectory = () => {
159
221
  export const TranspilerPluginComponent = async (props: TranspilerProps) => {
160
222
  const frontendRollupConfig: RollupOptions = {
161
223
  input: `./${GetFrontEndDirectory()}/index.tsx`,
162
- plugins: GetPluginComponents(props),
224
+ plugins: await GetPluginComponents(props),
163
225
  context: 'window',
164
226
  external: (id) => {
165
227
  if (id === '@steambrew/webkit') {
@@ -191,7 +253,7 @@ export const TranspilerPluginComponent = async (props: TranspilerProps) => {
191
253
  if (fs.existsSync(`./webkit/index.tsx`)) {
192
254
  const webkitRollupConfig: RollupOptions = {
193
255
  input: `./webkit/index.tsx`,
194
- plugins: GetWebkitPluginComponents(props),
256
+ plugins: await GetWebkitPluginComponents(props),
195
257
  context: 'window',
196
258
  external: (id) => {
197
259
  if (id === '@steambrew/client') {
@@ -2,7 +2,7 @@ import path from 'path';
2
2
  import { fileURLToPath } from 'url';
3
3
  import { readFile } from 'fs/promises';
4
4
  import { dirname } from 'path';
5
- import { Logger } from './Logger';
5
+ import { Logger } from './logger';
6
6
 
7
7
  export const CheckForUpdates = async (): Promise<boolean> => {
8
8
  return new Promise<boolean>(async (resolve) => {
@@ -22,6 +22,10 @@ export const CheckForUpdates = async (): Promise<boolean> => {
22
22
  Logger.Info('versionMon', `@steambrew/ttc@${packageJson.version} is up-to-date!`);
23
23
  resolve(false);
24
24
  }
25
+ })
26
+ .catch((exception) => {
27
+ Logger.Error('Failed to check for updates: ' + exception);
28
+ resolve(false);
25
29
  });
26
30
  });
27
31
  };
package/tsconfig.json CHANGED
@@ -1,24 +1,23 @@
1
1
  {
2
- "compilerOptions": {
3
- "outDir": "dist",
4
- "module": "ESNext",
5
- "target": "ES2020",
6
- "jsx": "react",
7
- "jsxFactory": "window.SP_REACT.createElement",
8
- "declaration": false,
9
- "moduleResolution": "node",
10
- "noUnusedLocals": true,
11
- "noUnusedParameters": true,
12
- "esModuleInterop": true,
13
- "noImplicitReturns": true,
14
- "noImplicitThis": true,
15
- "noImplicitAny": true,
16
- "strict": true,
17
- "ignoreDeprecations": "5.0",
18
- "allowSyntheticDefaultImports": true,
19
- "skipLibCheck": true
20
- },
21
- "include": ["./"],
22
- "exclude": ["node_modules"]
2
+ "compilerOptions": {
3
+ "outDir": "dist",
4
+ "module": "ESNext",
5
+ "target": "ES2020",
6
+ "jsx": "react",
7
+ "jsxFactory": "window.SP_REACT.createElement",
8
+ "declaration": false,
9
+ "moduleResolution": "node",
10
+ "noUnusedLocals": true,
11
+ "noUnusedParameters": true,
12
+ "esModuleInterop": true,
13
+ "noImplicitReturns": true,
14
+ "noImplicitThis": true,
15
+ "noImplicitAny": true,
16
+ "strict": true,
17
+ "ignoreDeprecations": "5.0",
18
+ "allowSyntheticDefaultImports": true,
19
+ "skipLibCheck": true
20
+ },
21
+ "include": ["./src/**/*"],
22
+ "exclude": ["node_modules"]
23
23
  }
24
-
package/Linter.ts DELETED
@@ -1,44 +0,0 @@
1
- import chalk from 'chalk'
2
- import path from 'path'
3
- import { existsSync, readFile } from 'fs'
4
-
5
- export const ValidatePlugin = (target: string): Promise<any> => {
6
-
7
- return new Promise<any>((resolve, reject) => {
8
- if (!existsSync(target)) {
9
- console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red("is not a valid system path"))
10
- reject()
11
- return
12
- }
13
-
14
- const pluginModule = path.join(target, "plugin.json")
15
-
16
- if (!existsSync(pluginModule)) {
17
- console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red("is not a valid plugin (missing plugin.json)"))
18
- reject()
19
- return
20
- }
21
-
22
- readFile(pluginModule, 'utf8', (err, data) => {
23
- if (err) {
24
- console.error(chalk.red.bold(`\n[-] couldn't read plugin.json from [${pluginModule}]`))
25
- reject()
26
- return
27
- }
28
-
29
- try {
30
- if (!("name" in JSON.parse(data))) {
31
- console.error(chalk.red.bold(`\n[-] target plugin doesn't contain "name" in plugin.json [${pluginModule}]`))
32
- reject()
33
- }
34
- else {
35
- resolve(JSON.parse(data))
36
- }
37
- }
38
- catch (parseError) {
39
- console.error(chalk.red.bold(`\n[-] couldn't parse JSON in plugin.json from [${pluginModule}]`))
40
- reject()
41
- }
42
- });
43
- })
44
- }
package/Parameters.ts DELETED
@@ -1,72 +0,0 @@
1
- import chalk from 'chalk'
2
- import { Logger } from "./Logger"
3
-
4
- /***
5
- * @brief print the parameter list to the stdout
6
- */
7
- export const PrintParamHelp = () => {
8
-
9
- console.log(
10
- "millennium-ttc parameter list:" +
11
- "\n\t" + chalk.magenta("--help") + ": display parameter list" +
12
- "\n\t" + chalk.bold.red("--build") + ": " + chalk.bold.red("(required)") + ": build type [dev, prod] (prod minifies code)" +
13
- "\n\t" + chalk.magenta("--target") + ": path to plugin, default to cwd"
14
- );
15
- }
16
-
17
- export enum BuildType {
18
- DevBuild, ProdBuild
19
- }
20
-
21
- export interface ParameterProps {
22
- type: BuildType,
23
- targetPlugin: string // path
24
- }
25
-
26
- export const ValidateParameters = (args: Array<string>): ParameterProps => {
27
-
28
- let typeProp: BuildType = BuildType.DevBuild, targetProp: string = process.cwd()
29
-
30
- if (args.includes("--help")) {
31
- PrintParamHelp()
32
- process.exit();
33
- }
34
-
35
- // startup args are invalid
36
- if (!args.includes("--build")) {
37
- Logger.Error("Received invalid arguments...");
38
- PrintParamHelp();
39
- process.exit();
40
- }
41
-
42
- for (let i = 0; i < args.length; i++)
43
- {
44
- if (args[i] === "--build")
45
- {
46
- const BuildMode: string = args[i + 1]
47
-
48
- switch (BuildMode) {
49
- case "dev": typeProp = BuildType.DevBuild; break
50
- case "prod": typeProp = BuildType.ProdBuild; break
51
- default: {
52
- Logger.Error('--build parameter must be preceded by build type [dev, prod]');
53
- process.exit();
54
- }
55
- }
56
- }
57
-
58
- if (args[i] == "--target") {
59
- if (args[i + 1] === undefined) {
60
- Logger.Error('--target parameter must be preceded by system path');
61
- process.exit();
62
- }
63
-
64
- targetProp = args[i + 1]
65
- }
66
- }
67
-
68
- return {
69
- type: typeProp,
70
- targetPlugin: targetProp
71
- }
72
- }
File without changes
File without changes
File without changes