@steambrew/ttc 3.2.3 → 3.2.4
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/dist/index.js +47 -41
- package/package.json +2 -3
- package/rollup.config.js +6 -1
- package/src/check-health.ts +30 -0
- package/src/index.ts +31 -1
- package/src/logger.ts +34 -2
- package/src/plugin-api.ts +30 -0
- package/src/plugin-json.d.ts +30 -0
- package/src/query-parser.ts +30 -0
- package/src/static-embed.ts +78 -44
- package/src/transpiler.ts +31 -1
- package/src/version-control.ts +30 -0
- package/.claude/settings.local.json +0 -10
package/dist/index.js
CHANGED
|
@@ -52,14 +52,14 @@ const Logger = {
|
|
|
52
52
|
},
|
|
53
53
|
done({ elapsedMs, buildType, sysfsCount, envCount }) {
|
|
54
54
|
const elapsed = `${(elapsedMs / 1000).toFixed(2)}s`;
|
|
55
|
-
const meta = [`ttc v${version}`];
|
|
55
|
+
const meta = [`ttc v${version} (${"fd773865"})`];
|
|
56
56
|
if (buildType === 'dev')
|
|
57
57
|
meta.push('no type checking');
|
|
58
58
|
if (sysfsCount)
|
|
59
59
|
meta.push(`${sysfsCount} bundled file${sysfsCount > 1 ? 's' : ''}`);
|
|
60
60
|
if (envCount)
|
|
61
61
|
meta.push(`${envCount} env var${envCount > 1 ? 's' : ''}`);
|
|
62
|
-
console.log(`${chalk.green('Finished')} ${buildType} in ${elapsed} ` + chalk.dim(
|
|
62
|
+
console.log(`${chalk.green('Finished')} ${buildType} in ${elapsed} ` + chalk.dim(meta.join(', ')));
|
|
63
63
|
},
|
|
64
64
|
failed({ elapsedMs, buildType }) {
|
|
65
65
|
const elapsed = `${(elapsedMs / 1000).toFixed(2)}s`;
|
|
@@ -268,6 +268,7 @@ function constSysfsExpr(options = {}) {
|
|
|
268
268
|
const filter = createFilter(options.include, options.exclude);
|
|
269
269
|
const pluginName = 'millennium-const-sysfs-expr';
|
|
270
270
|
let count = 0;
|
|
271
|
+
const globCache = new Map();
|
|
271
272
|
const plugin = {
|
|
272
273
|
name: pluginName,
|
|
273
274
|
transform(code, id) {
|
|
@@ -311,8 +312,6 @@ function constSysfsExpr(options = {}) {
|
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
314
|
},
|
|
314
|
-
});
|
|
315
|
-
traverse(ast, {
|
|
316
315
|
CallExpression: (nodePath) => {
|
|
317
316
|
const node = nodePath.node;
|
|
318
317
|
if (node.callee.type === 'Identifier' && node.callee.name === 'constSysfsExpr') {
|
|
@@ -432,53 +431,60 @@ function constSysfsExpr(options = {}) {
|
|
|
432
431
|
? path.dirname(pathOrPattern)
|
|
433
432
|
: path.resolve(path.dirname(id), path.dirname(pathOrPattern));
|
|
434
433
|
let embeddedContent;
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
|
|
438
|
-
fs.statSync(path.resolve(searchBasePath, pathOrPattern)).isFile()) {
|
|
439
|
-
const singleFilePath = path.resolve(searchBasePath, pathOrPattern);
|
|
440
|
-
try {
|
|
441
|
-
const rawContent = fs.readFileSync(singleFilePath, callOptions.encoding);
|
|
442
|
-
const contentString = rawContent.toString();
|
|
443
|
-
const fileInfo = {
|
|
444
|
-
content: contentString,
|
|
445
|
-
filePath: singleFilePath,
|
|
446
|
-
fileName: path.relative(searchBasePath, singleFilePath),
|
|
447
|
-
};
|
|
448
|
-
embeddedContent = JSON.stringify(fileInfo);
|
|
449
|
-
this.addWatchFile(singleFilePath);
|
|
450
|
-
}
|
|
451
|
-
catch (fileError) {
|
|
452
|
-
let message = String(fileError instanceof Error ? fileError.message : (fileError ?? 'Unknown file read error'));
|
|
453
|
-
this.error(`Error reading file ${singleFilePath}: ${message}`, node.loc?.start.index);
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
434
|
+
const cacheKey = `${searchBasePath}\0${pathOrPattern}\0${callOptions.encoding}`;
|
|
435
|
+
if (globCache.has(cacheKey)) {
|
|
436
|
+
embeddedContent = globCache.get(cacheKey);
|
|
456
437
|
}
|
|
457
438
|
else {
|
|
458
|
-
const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const fileInfoArray = [];
|
|
464
|
-
for (const fullPath of matchingFiles) {
|
|
439
|
+
const isPotentialPattern = /[?*+!@()[\]{}]/.test(pathOrPattern);
|
|
440
|
+
if (!isPotentialPattern &&
|
|
441
|
+
fs.existsSync(path.resolve(searchBasePath, pathOrPattern)) &&
|
|
442
|
+
fs.statSync(path.resolve(searchBasePath, pathOrPattern)).isFile()) {
|
|
443
|
+
const singleFilePath = path.resolve(searchBasePath, pathOrPattern);
|
|
465
444
|
try {
|
|
466
|
-
const rawContent = fs.readFileSync(
|
|
445
|
+
const rawContent = fs.readFileSync(singleFilePath, callOptions.encoding);
|
|
467
446
|
const contentString = rawContent.toString();
|
|
468
|
-
|
|
447
|
+
const fileInfo = {
|
|
469
448
|
content: contentString,
|
|
470
|
-
filePath:
|
|
471
|
-
fileName: path.relative(searchBasePath,
|
|
472
|
-
}
|
|
473
|
-
|
|
449
|
+
filePath: singleFilePath,
|
|
450
|
+
fileName: path.relative(searchBasePath, singleFilePath),
|
|
451
|
+
};
|
|
452
|
+
embeddedContent = JSON.stringify(fileInfo);
|
|
453
|
+
this.addWatchFile(singleFilePath);
|
|
474
454
|
}
|
|
475
455
|
catch (fileError) {
|
|
476
456
|
let message = String(fileError instanceof Error ? fileError.message : (fileError ?? 'Unknown file read error'));
|
|
477
|
-
this.
|
|
457
|
+
this.error(`Error reading file ${singleFilePath}: ${message}`, node.loc?.start.index);
|
|
458
|
+
return;
|
|
478
459
|
}
|
|
479
460
|
}
|
|
480
|
-
|
|
481
|
-
|
|
461
|
+
else {
|
|
462
|
+
const matchingFiles = glob.sync(pathOrPattern, {
|
|
463
|
+
cwd: searchBasePath,
|
|
464
|
+
nodir: true,
|
|
465
|
+
absolute: true,
|
|
466
|
+
});
|
|
467
|
+
const fileInfoArray = [];
|
|
468
|
+
for (const fullPath of matchingFiles) {
|
|
469
|
+
try {
|
|
470
|
+
const rawContent = fs.readFileSync(fullPath, callOptions.encoding);
|
|
471
|
+
const contentString = rawContent.toString();
|
|
472
|
+
fileInfoArray.push({
|
|
473
|
+
content: contentString,
|
|
474
|
+
filePath: fullPath,
|
|
475
|
+
fileName: path.relative(searchBasePath, fullPath),
|
|
476
|
+
});
|
|
477
|
+
this.addWatchFile(fullPath);
|
|
478
|
+
}
|
|
479
|
+
catch (fileError) {
|
|
480
|
+
let message = String(fileError instanceof Error ? fileError.message : (fileError ?? 'Unknown file read error'));
|
|
481
|
+
this.warn(`Error reading file ${fullPath}: ${message}`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
embeddedContent = JSON.stringify(fileInfoArray);
|
|
485
|
+
}
|
|
486
|
+
globCache.set(cacheKey, embeddedContent);
|
|
487
|
+
} // end cache miss
|
|
482
488
|
// Replace the call expression with the generated content string
|
|
483
489
|
magicString.overwrite(node.start, node.end, embeddedContent);
|
|
484
490
|
hasReplaced = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steambrew/ttc",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "rollup -c",
|
|
12
|
-
"dev": "rollup -c -w"
|
|
13
|
-
"prepare": "bun run build"
|
|
12
|
+
"dev": "rollup -c -w"
|
|
14
13
|
},
|
|
15
14
|
"publishConfig": {
|
|
16
15
|
"access": "public"
|
package/rollup.config.js
CHANGED
|
@@ -2,17 +2,22 @@ import commonjs from '@rollup/plugin-commonjs';
|
|
|
2
2
|
import typescript from '@rollup/plugin-typescript';
|
|
3
3
|
import json from '@rollup/plugin-json';
|
|
4
4
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
5
|
+
import replace from '@rollup/plugin-replace';
|
|
5
6
|
import { readFileSync } from 'fs';
|
|
7
|
+
import { execSync } from 'child_process';
|
|
6
8
|
|
|
7
9
|
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
8
10
|
|
|
11
|
+
let gitCommit = 'unknown';
|
|
12
|
+
try { gitCommit = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).trim(); } catch {}
|
|
13
|
+
|
|
9
14
|
export default {
|
|
10
15
|
input: 'src/index.ts',
|
|
11
16
|
context: 'window',
|
|
12
17
|
output: {
|
|
13
18
|
file: 'dist/index.js',
|
|
14
19
|
},
|
|
15
|
-
plugins: [commonjs(), typescript(), json(), nodeResolve()],
|
|
20
|
+
plugins: [replace({ __GIT_COMMIT__: JSON.stringify(gitCommit), preventAssignment: true }), commonjs(), typescript(), json(), nodeResolve()],
|
|
16
21
|
external: [
|
|
17
22
|
...Object.keys(pkg.dependencies || {}),
|
|
18
23
|
...Object.keys(pkg.peerDependencies || {}),
|
package/src/check-health.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
import path from 'path';
|
|
2
32
|
import { existsSync, readFile } from 'fs';
|
|
3
33
|
import { Logger } from './logger';
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,34 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin / env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ==================================================
|
|
5
|
+
* _____ _ _ _ _
|
|
6
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
7
|
+
* | | | | | | | -_| | | | | | |
|
|
8
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
9
|
+
*
|
|
10
|
+
* ==================================================
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2026 Project Millennium
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
* in the Software without restriction, including without limitation the rights
|
|
17
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
* furnished to do so, subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
* copies or substantial portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
* SOFTWARE.
|
|
31
|
+
*/
|
|
2
32
|
|
|
3
33
|
/**
|
|
4
34
|
* this component serves as:
|
package/src/logger.ts
CHANGED
|
@@ -1,8 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
import chalk from 'chalk';
|
|
2
32
|
import { readFileSync } from 'fs';
|
|
3
33
|
import path, { dirname } from 'path';
|
|
4
34
|
import { fileURLToPath } from 'url';
|
|
5
35
|
|
|
36
|
+
declare const __GIT_COMMIT__: string;
|
|
37
|
+
|
|
6
38
|
const version: string = JSON.parse(readFileSync(path.resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'), 'utf8')).version;
|
|
7
39
|
|
|
8
40
|
interface DoneOptions {
|
|
@@ -36,11 +68,11 @@ const Logger = {
|
|
|
36
68
|
|
|
37
69
|
done({ elapsedMs, buildType, sysfsCount, envCount }: DoneOptions) {
|
|
38
70
|
const elapsed = `${(elapsedMs / 1000).toFixed(2)}s`;
|
|
39
|
-
const meta: string[] = [`ttc v${version}`];
|
|
71
|
+
const meta: string[] = [`ttc v${version} (${__GIT_COMMIT__})`];
|
|
40
72
|
if (buildType === 'dev') meta.push('no type checking');
|
|
41
73
|
if (sysfsCount) meta.push(`${sysfsCount} bundled file${sysfsCount > 1 ? 's' : ''}`);
|
|
42
74
|
if (envCount) meta.push(`${envCount} env var${envCount > 1 ? 's' : ''}`);
|
|
43
|
-
console.log(`${chalk.green('Finished')} ${buildType} in ${elapsed} ` + chalk.dim(
|
|
75
|
+
console.log(`${chalk.green('Finished')} ${buildType} in ${elapsed} ` + chalk.dim(meta.join(', ')));
|
|
44
76
|
},
|
|
45
77
|
|
|
46
78
|
failed({ elapsedMs, buildType }: Pick<DoneOptions, 'elapsedMs' | 'buildType'>) {
|
package/src/plugin-api.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
declare global {
|
|
2
32
|
interface Window {
|
|
3
33
|
/**
|
package/src/plugin-json.d.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
/**
|
|
2
32
|
* generated from https://raw.githubusercontent.com/SteamClientHomebrew/Millennium/main/src/sys/plugin-schema.json
|
|
3
33
|
*/
|
package/src/query-parser.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
import { Logger } from './logger';
|
|
2
32
|
|
|
3
33
|
export const PrintParamHelp = () => {
|
package/src/static-embed.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
import * as parser from '@babel/parser';
|
|
2
32
|
import { createFilter } from '@rollup/pluginutils';
|
|
3
33
|
import fs from 'fs';
|
|
@@ -47,6 +77,7 @@ export default function constSysfsExpr(options: EmbedPluginOptions = {}): SysfsP
|
|
|
47
77
|
const filter = createFilter(options.include, options.exclude);
|
|
48
78
|
const pluginName = 'millennium-const-sysfs-expr';
|
|
49
79
|
let count = 0;
|
|
80
|
+
const globCache = new Map<string, string>();
|
|
50
81
|
|
|
51
82
|
const plugin: Plugin = {
|
|
52
83
|
name: pluginName,
|
|
@@ -97,9 +128,6 @@ export default function constSysfsExpr(options: EmbedPluginOptions = {}): SysfsP
|
|
|
97
128
|
}
|
|
98
129
|
}
|
|
99
130
|
},
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
traverse(ast, {
|
|
103
131
|
CallExpression: (nodePath) => {
|
|
104
132
|
const node = nodePath.node;
|
|
105
133
|
if (node.callee.type === 'Identifier' && node.callee.name === 'constSysfsExpr') {
|
|
@@ -220,55 +248,61 @@ export default function constSysfsExpr(options: EmbedPluginOptions = {}): SysfsP
|
|
|
220
248
|
|
|
221
249
|
let embeddedContent: string;
|
|
222
250
|
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
!isPotentialPattern &&
|
|
227
|
-
fs.existsSync(path.resolve(searchBasePath, pathOrPattern)) &&
|
|
228
|
-
fs.statSync(path.resolve(searchBasePath, pathOrPattern)).isFile()
|
|
229
|
-
) {
|
|
230
|
-
const singleFilePath = path.resolve(searchBasePath, pathOrPattern);
|
|
231
|
-
|
|
232
|
-
try {
|
|
233
|
-
const rawContent: string | Buffer = fs.readFileSync(singleFilePath, callOptions.encoding);
|
|
234
|
-
const contentString = rawContent.toString();
|
|
235
|
-
const fileInfo: FileInfo = {
|
|
236
|
-
content: contentString,
|
|
237
|
-
filePath: singleFilePath,
|
|
238
|
-
fileName: path.relative(searchBasePath, singleFilePath),
|
|
239
|
-
};
|
|
240
|
-
embeddedContent = JSON.stringify(fileInfo);
|
|
241
|
-
this.addWatchFile(singleFilePath);
|
|
242
|
-
} catch (fileError: unknown) {
|
|
243
|
-
let message = String(fileError instanceof Error ? fileError.message : (fileError ?? 'Unknown file read error'));
|
|
244
|
-
this.error(`Error reading file ${singleFilePath}: ${message}`, node.loc?.start.index);
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
251
|
+
const cacheKey = `${searchBasePath}\0${pathOrPattern}\0${callOptions.encoding}`;
|
|
252
|
+
if (globCache.has(cacheKey)) {
|
|
253
|
+
embeddedContent = globCache.get(cacheKey)!;
|
|
247
254
|
} else {
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
const isPotentialPattern = /[?*+!@()[\]{}]/.test(pathOrPattern);
|
|
256
|
+
|
|
257
|
+
if (
|
|
258
|
+
!isPotentialPattern &&
|
|
259
|
+
fs.existsSync(path.resolve(searchBasePath, pathOrPattern)) &&
|
|
260
|
+
fs.statSync(path.resolve(searchBasePath, pathOrPattern)).isFile()
|
|
261
|
+
) {
|
|
262
|
+
const singleFilePath = path.resolve(searchBasePath, pathOrPattern);
|
|
263
|
+
|
|
256
264
|
try {
|
|
257
|
-
const rawContent: string | Buffer = fs.readFileSync(
|
|
265
|
+
const rawContent: string | Buffer = fs.readFileSync(singleFilePath, callOptions.encoding);
|
|
258
266
|
const contentString = rawContent.toString();
|
|
259
|
-
|
|
267
|
+
const fileInfo: FileInfo = {
|
|
260
268
|
content: contentString,
|
|
261
|
-
filePath:
|
|
262
|
-
fileName: path.relative(searchBasePath,
|
|
263
|
-
}
|
|
264
|
-
|
|
269
|
+
filePath: singleFilePath,
|
|
270
|
+
fileName: path.relative(searchBasePath, singleFilePath),
|
|
271
|
+
};
|
|
272
|
+
embeddedContent = JSON.stringify(fileInfo);
|
|
273
|
+
this.addWatchFile(singleFilePath);
|
|
265
274
|
} catch (fileError: unknown) {
|
|
266
275
|
let message = String(fileError instanceof Error ? fileError.message : (fileError ?? 'Unknown file read error'));
|
|
267
|
-
this.
|
|
276
|
+
this.error(`Error reading file ${singleFilePath}: ${message}`, node.loc?.start.index);
|
|
277
|
+
return;
|
|
268
278
|
}
|
|
279
|
+
} else {
|
|
280
|
+
const matchingFiles = glob.sync(pathOrPattern, {
|
|
281
|
+
cwd: searchBasePath,
|
|
282
|
+
nodir: true,
|
|
283
|
+
absolute: true,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
const fileInfoArray: FileInfo[] = [];
|
|
287
|
+
for (const fullPath of matchingFiles) {
|
|
288
|
+
try {
|
|
289
|
+
const rawContent: string | Buffer = fs.readFileSync(fullPath, callOptions.encoding);
|
|
290
|
+
const contentString = rawContent.toString();
|
|
291
|
+
fileInfoArray.push({
|
|
292
|
+
content: contentString,
|
|
293
|
+
filePath: fullPath,
|
|
294
|
+
fileName: path.relative(searchBasePath, fullPath),
|
|
295
|
+
});
|
|
296
|
+
this.addWatchFile(fullPath);
|
|
297
|
+
} catch (fileError: unknown) {
|
|
298
|
+
let message = String(fileError instanceof Error ? fileError.message : (fileError ?? 'Unknown file read error'));
|
|
299
|
+
this.warn(`Error reading file ${fullPath}: ${message}`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
embeddedContent = JSON.stringify(fileInfoArray);
|
|
269
303
|
}
|
|
270
|
-
|
|
271
|
-
}
|
|
304
|
+
globCache.set(cacheKey, embeddedContent);
|
|
305
|
+
} // end cache miss
|
|
272
306
|
|
|
273
307
|
// Replace the call expression with the generated content string
|
|
274
308
|
magicString.overwrite(node.start, node.end, embeddedContent);
|
package/src/transpiler.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
import babel from '@rollup/plugin-babel';
|
|
2
32
|
import commonjs from '@rollup/plugin-commonjs';
|
|
3
33
|
import json from '@rollup/plugin-json';
|
|
@@ -152,7 +182,7 @@ function tsconfigPathsPlugin(tsconfigPath: string): InputPluginOption {
|
|
|
152
182
|
|
|
153
183
|
function resolveWithExtensions(base: string): string | null {
|
|
154
184
|
for (const ext of ['', '.ts', '.tsx', '.js', '.jsx', '/index.ts', '/index.tsx']) {
|
|
155
|
-
|
|
185
|
+
if (fs.existsSync(base + ext) && fs.statSync(base + ext).isFile()) return base + ext;
|
|
156
186
|
}
|
|
157
187
|
return null;
|
|
158
188
|
}
|
package/src/version-control.ts
CHANGED
|
@@ -1,3 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ==================================================
|
|
3
|
+
* _____ _ _ _ _
|
|
4
|
+
* | |_| | |___ ___ ___|_|_ _ _____
|
|
5
|
+
* | | | | | | | -_| | | | | | |
|
|
6
|
+
* |_|_|_|_|_|_|___|_|_|_|_|_|___|_|_|_|
|
|
7
|
+
*
|
|
8
|
+
* ==================================================
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 Project Millennium
|
|
11
|
+
*
|
|
12
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
* in the Software without restriction, including without limitation the rights
|
|
15
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
* furnished to do so, subject to the following conditions:
|
|
18
|
+
*
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
* copies or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
* SOFTWARE.
|
|
29
|
+
*/
|
|
30
|
+
|
|
1
31
|
import path from 'path';
|
|
2
32
|
import { fileURLToPath } from 'url';
|
|
3
33
|
import { readFile, access } from 'fs/promises';
|