@steambrew/ttc 2.8.6 → 3.0.0
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/.prettierrc +9 -9
- package/bun.lock +680 -0
- package/dist/index.js +315 -459
- package/package.json +55 -54
- package/rollup.config.js +22 -22
- package/src/check-health.ts +53 -54
- package/src/index.ts +53 -61
- package/src/logger.ts +49 -46
- package/src/plugin-api.ts +77 -263
- package/src/query-parser.ts +83 -89
- package/src/static-embed.ts +274 -281
- package/src/transpiler.ts +303 -317
- package/src/version-control.ts +53 -31
- package/tsconfig.json +23 -23
- package/pnpm-workspace.yaml +0 -2
package/package.json
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@steambrew/ttc",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"millennium-ttc": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"prepare": "bun run build"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "SteamClientHomebrew",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"description": "A tiny typescript compiler for Millennium plugins.",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@babel/parser": "^7.27.5",
|
|
23
|
+
"@babel/preset-env": "^7.27.2",
|
|
24
|
+
"@babel/preset-react": "^7.27.1",
|
|
25
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
26
|
+
"@babel/traverse": "^7.27.4",
|
|
27
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
28
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
29
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
31
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
32
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
33
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
34
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
35
|
+
"@rollup/pluginutils": "^5.1.4",
|
|
36
|
+
"chalk": "^5.4.1",
|
|
37
|
+
"dotenv": "^16.5.0",
|
|
38
|
+
"fs": "0.0.1-security",
|
|
39
|
+
"glob": "^11.0.2",
|
|
40
|
+
"magic-string": "^0.30.17",
|
|
41
|
+
"rollup": "^4.42.0",
|
|
42
|
+
"rollup-plugin-esbuild": "^6.2.1",
|
|
43
|
+
"rollup-plugin-inject-process-env": "^1.3.1",
|
|
44
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
45
|
+
"rollup-plugin-scss": "^4.0.1",
|
|
46
|
+
"sass": "^1.89.1",
|
|
47
|
+
"terser": "^5.43.1",
|
|
48
|
+
"tslib": "^2.8.1"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/babel__traverse": "^7.20.7",
|
|
52
|
+
"@types/glob": "^8.1.0",
|
|
53
|
+
"@types/node": "^22.15.30"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/rollup.config.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
-
import typescript from '@rollup/plugin-typescript';
|
|
3
|
-
import json from '@rollup/plugin-json';
|
|
4
|
-
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
|
|
7
|
-
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
input: 'src/index.ts',
|
|
11
|
-
context: 'window',
|
|
12
|
-
output: {
|
|
13
|
-
file: 'dist/index.js',
|
|
14
|
-
},
|
|
15
|
-
plugins: [commonjs(), typescript(), json(), nodeResolve()],
|
|
16
|
-
external: [
|
|
17
|
-
...Object.keys(pkg.dependencies || {}),
|
|
18
|
-
...Object.keys(pkg.peerDependencies || {}),
|
|
19
|
-
...Object.keys(pkg.optionalDependencies || {}),
|
|
20
|
-
...Object.keys(pkg.devDependencies || {}),
|
|
21
|
-
],
|
|
22
|
-
};
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
+
import typescript from '@rollup/plugin-typescript';
|
|
3
|
+
import json from '@rollup/plugin-json';
|
|
4
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
|
|
7
|
+
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
input: 'src/index.ts',
|
|
11
|
+
context: 'window',
|
|
12
|
+
output: {
|
|
13
|
+
file: 'dist/index.js',
|
|
14
|
+
},
|
|
15
|
+
plugins: [commonjs(), typescript(), json(), nodeResolve()],
|
|
16
|
+
external: [
|
|
17
|
+
...Object.keys(pkg.dependencies || {}),
|
|
18
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
19
|
+
...Object.keys(pkg.optionalDependencies || {}),
|
|
20
|
+
...Object.keys(pkg.devDependencies || {}),
|
|
21
|
+
],
|
|
22
|
+
};
|
package/src/check-health.ts
CHANGED
|
@@ -1,54 +1,53 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export const ValidatePlugin = (bIsMillennium: boolean, target: string): Promise<any> => {
|
|
6
|
-
return new Promise<any>((resolve, reject) => {
|
|
7
|
-
if (!existsSync(target)) {
|
|
8
|
-
|
|
9
|
-
reject();
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (bIsMillennium) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { existsSync, readFile } from 'fs';
|
|
3
|
+
import { Logger } from './logger';
|
|
4
|
+
|
|
5
|
+
export const ValidatePlugin = (bIsMillennium: boolean, target: string): Promise<any> => {
|
|
6
|
+
return new Promise<any>((resolve, reject) => {
|
|
7
|
+
if (!existsSync(target)) {
|
|
8
|
+
Logger.error(`target path does not exist: ${target}`);
|
|
9
|
+
reject();
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (bIsMillennium) {
|
|
14
|
+
resolve({
|
|
15
|
+
name: 'core',
|
|
16
|
+
common_name: 'Millennium',
|
|
17
|
+
description: 'An integrated plugin that provides core platform functionality.',
|
|
18
|
+
useBackend: false,
|
|
19
|
+
frontend: '.',
|
|
20
|
+
});
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const pluginModule = path.join(target, 'plugin.json');
|
|
25
|
+
|
|
26
|
+
if (!existsSync(pluginModule)) {
|
|
27
|
+
Logger.error(`plugin.json not found: ${pluginModule}`);
|
|
28
|
+
reject();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
readFile(pluginModule, 'utf8', (err, data) => {
|
|
33
|
+
if (err) {
|
|
34
|
+
Logger.error(`could not read plugin.json: ${pluginModule}`);
|
|
35
|
+
reject();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(data);
|
|
41
|
+
if (!('name' in parsed)) {
|
|
42
|
+
Logger.error('plugin.json is missing required "name" field');
|
|
43
|
+
reject();
|
|
44
|
+
} else {
|
|
45
|
+
resolve(parsed);
|
|
46
|
+
}
|
|
47
|
+
} catch (parseError) {
|
|
48
|
+
Logger.error('plugin.json contains invalid JSON:', pluginModule);
|
|
49
|
+
reject();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,61 +1,53 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* this component serves as:
|
|
5
|
-
* - typescript transpiler
|
|
6
|
-
* - rollup configurator
|
|
7
|
-
*/
|
|
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
|
-
import { performance } from 'perf_hooks';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
StartCompilerModule();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
CheckModuleUpdates().then(StartCompilerModule);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
Initialize();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* this component serves as:
|
|
5
|
+
* - typescript transpiler
|
|
6
|
+
* - rollup configurator
|
|
7
|
+
*/
|
|
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
|
+
import { performance } from 'perf_hooks';
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
var PerfStartTime: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const CheckModuleUpdates = async () => {
|
|
19
|
+
return await CheckForUpdates();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const StartCompilerModule = () => {
|
|
23
|
+
const parameters = ValidateParameters(process.argv.slice(2));
|
|
24
|
+
const bIsMillennium = parameters.isMillennium || false;
|
|
25
|
+
const bTersePlugin = parameters.type == BuildType.ProdBuild;
|
|
26
|
+
|
|
27
|
+
ValidatePlugin(bIsMillennium, parameters.targetPlugin)
|
|
28
|
+
.then((json: any) => {
|
|
29
|
+
const props: TranspilerProps = {
|
|
30
|
+
minify: bTersePlugin,
|
|
31
|
+
pluginName: json?.name,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
TranspilerPluginComponent(bIsMillennium, json, props);
|
|
35
|
+
})
|
|
36
|
+
.catch(() => {
|
|
37
|
+
process.exit();
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const Initialize = () => {
|
|
42
|
+
global.PerfStartTime = performance.now();
|
|
43
|
+
|
|
44
|
+
// Check for --no-update flag
|
|
45
|
+
if (process.argv.includes('--no-update')) {
|
|
46
|
+
StartCompilerModule();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
CheckModuleUpdates().then(StartCompilerModule);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Initialize();
|
package/src/logger.ts
CHANGED
|
@@ -1,46 +1,49 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import path, { dirname } from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const version: string = JSON.parse(
|
|
7
|
+
readFileSync(path.resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf8'),
|
|
8
|
+
).version;
|
|
9
|
+
|
|
10
|
+
interface DoneOptions {
|
|
11
|
+
elapsedMs: number;
|
|
12
|
+
buildType: 'dev' | 'prod';
|
|
13
|
+
sysfsCount?: number;
|
|
14
|
+
envCount?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Logger = {
|
|
18
|
+
warn(message: string, loc?: string) {
|
|
19
|
+
if (loc) {
|
|
20
|
+
console.warn(`${chalk.dim(loc + ':')} ${message}`);
|
|
21
|
+
} else {
|
|
22
|
+
console.warn(`${chalk.yellow('warning:')} ${message}`);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
error(message: string, loc?: string) {
|
|
27
|
+
if (loc) {
|
|
28
|
+
console.error(`${chalk.dim(loc + ':')} ${message}`);
|
|
29
|
+
} else {
|
|
30
|
+
console.error(`${chalk.red('error:')} ${message}`);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
update(current: string, latest: string, installCmd: string) {
|
|
35
|
+
console.log(`\n${chalk.yellow('update available')} ${chalk.dim(current)} → ${chalk.green(latest)}`);
|
|
36
|
+
console.log(`${chalk.dim('run:')} ${installCmd}\n`);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
done({ elapsedMs, buildType, sysfsCount, envCount }: DoneOptions) {
|
|
40
|
+
const elapsed = `${(elapsedMs / 1000).toFixed(2)}s`;
|
|
41
|
+
const meta: string[] = [`ttc v${version}`];
|
|
42
|
+
if (buildType === 'dev') meta.push('no type checking');
|
|
43
|
+
if (sysfsCount) meta.push(`${sysfsCount} constSysfsExpr`);
|
|
44
|
+
if (envCount) meta.push(`${envCount} env var${envCount > 1 ? 's' : ''}`);
|
|
45
|
+
console.log(`${chalk.green('Finished')} ${buildType} in ${elapsed} ` + chalk.dim('(' + meta.join(', ') + ')'));
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { Logger };
|