@steambrew/ttc 2.4.2 → 2.4.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/Compiler.ts CHANGED
@@ -3,9 +3,14 @@ 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
16
  import { Logger } from './Logger';
@@ -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') {
package/VersionMon.ts CHANGED
@@ -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
  };