@steambrew/ttc 2.8.7 → 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/package.json CHANGED
@@ -1,54 +1,55 @@
1
- {
2
- "name": "@steambrew/ttc",
3
- "version": "2.8.7",
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": "npm 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-inject-process-env": "^1.3.1",
43
- "rollup-plugin-polyfill-node": "^0.13.0",
44
- "rollup-plugin-scss": "^4.0.1",
45
- "sass": "^1.89.1",
46
- "terser": "^5.43.1",
47
- "tslib": "^2.8.1"
48
- },
49
- "devDependencies": {
50
- "@types/babel__traverse": "^7.20.7",
51
- "@types/glob": "^8.1.0",
52
- "@types/node": "^22.15.30"
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
+ };
@@ -1,54 +1,53 @@
1
- import chalk from 'chalk';
2
- import path from 'path';
3
- import { existsSync, readFile } from 'fs';
4
-
5
- export const ValidatePlugin = (bIsMillennium: boolean, 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
- 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
-
26
- const pluginModule = path.join(target, 'plugin.json');
27
-
28
- if (!existsSync(pluginModule)) {
29
- console.error(chalk.red.bold(`\n[-] --target [${target}] `) + chalk.red('is not a valid plugin (missing plugin.json)'));
30
- reject();
31
- return;
32
- }
33
-
34
- readFile(pluginModule, 'utf8', (err, data) => {
35
- if (err) {
36
- console.error(chalk.red.bold(`\n[-] couldn't read plugin.json from [${pluginModule}]`));
37
- reject();
38
- return;
39
- }
40
-
41
- try {
42
- if (!('name' in JSON.parse(data))) {
43
- console.error(chalk.red.bold(`\n[-] target plugin doesn't contain "name" in plugin.json [${pluginModule}]`));
44
- reject();
45
- } else {
46
- resolve(JSON.parse(data));
47
- }
48
- } catch (parseError) {
49
- console.error(chalk.red.bold(`\n[-] couldn't parse JSON in plugin.json from [${pluginModule}]`));
50
- reject();
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
- import chalk from 'chalk';
14
- // import { Logger } from './Logger'
15
-
16
- declare global {
17
- var PerfStartTime: number;
18
- }
19
-
20
- const CheckModuleUpdates = async () => {
21
- return await CheckForUpdates();
22
- };
23
-
24
- const StartCompilerModule = () => {
25
- const parameters = ValidateParameters(process.argv.slice(2));
26
- const bIsMillennium = parameters.isMillennium || false;
27
- const bTersePlugin = parameters.type == BuildType.ProdBuild;
28
-
29
- console.log(chalk.greenBright.bold('config'), 'Building target:', parameters.targetPlugin, 'with type:', BuildType[parameters.type], 'minify:', bTersePlugin, '...');
30
-
31
- ValidatePlugin(bIsMillennium, parameters.targetPlugin)
32
- .then((json: any) => {
33
- const props: TranspilerProps = {
34
- bTersePlugin: bTersePlugin,
35
- strPluginInternalName: json?.name,
36
- };
37
-
38
- TranspilerPluginComponent(bIsMillennium, json, props);
39
- })
40
-
41
- /**
42
- * plugin is invalid, we close the proccess as it has already been handled
43
- */
44
- .catch(() => {
45
- process.exit();
46
- });
47
- };
48
-
49
- const Initialize = () => {
50
- global.PerfStartTime = performance.now();
51
-
52
- // Check for --no-update flag
53
- if (process.argv.includes('--no-update')) {
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
- const Logger = {
4
- Info: (name: string, ...LogMessage: any) => {
5
- console.log(chalk.magenta.bold(name), ...LogMessage);
6
- },
7
-
8
- Warn: (...LogMessage: any) => {
9
- console.log(chalk.yellow.bold('**'), ...LogMessage);
10
- },
11
-
12
- Error: (...LogMessage: any) => {
13
- console.error(chalk.red.bold('!!'), ...LogMessage);
14
- },
15
-
16
- Tree: (name: string, strTitle: string, LogObject: any) => {
17
- const fixedPadding = 15; // <-- always pad keys to 15 characters
18
-
19
- console.log(chalk.greenBright.bold(name).padEnd(fixedPadding), strTitle);
20
-
21
- const isLocalPath = (strTestPath: string): boolean => {
22
- const filePathRegex = /^(\/|\.\/|\.\.\/|\w:\/)?([\w-.]+\/)*[\w-.]+\.\w+$/;
23
- return filePathRegex.test(strTestPath);
24
- };
25
-
26
- for (const [key, value] of Object.entries(LogObject)) {
27
- let color = chalk.white;
28
-
29
- switch (typeof value) {
30
- case 'string':
31
- color = isLocalPath(value) ? chalk.blueBright : chalk.white;
32
- break;
33
- case 'boolean':
34
- color = chalk.green;
35
- break;
36
- case 'number':
37
- color = chalk.yellow;
38
- break;
39
- }
40
-
41
- console.log(chalk.greenBright.bold(`${key}: `).padEnd(fixedPadding), color(String(value)));
42
- }
43
- },
44
- };
45
-
46
- export { Logger };
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 };