@typecad/cuttlefish 1.0.0-alpha.6 → 1.0.0-alpha.7
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/api/shared/display-adapter.d.ts +2 -1
- package/dist/api/shared/display-adapter.js +8 -1
- package/dist/api/shared/display-adapters/sdl.js +9 -2
- package/dist/api/shared/display-profile.d.ts +20 -3
- package/dist/api/shared/display-profile.js +21 -6
- package/dist/api/shared/framework-manifest-registry.d.ts +9 -0
- package/dist/api/shared/framework-manifest-registry.js +25 -0
- package/dist/api/shared/framework-manifest.d.ts +462 -0
- package/dist/api/shared/framework-manifest.js +149 -0
- package/dist/api/shared/glcdfont.d.ts +12 -0
- package/dist/api/shared/glcdfont.js +124 -0
- package/dist/api/shared/graphics-strategy.d.ts +28 -0
- package/dist/api/shared/hal-op-ir.d.ts +418 -1
- package/dist/api/shared/hal-op-ir.js +95 -1
- package/dist/api/shared/index.d.ts +11 -1
- package/dist/api/shared/index.js +14 -0
- package/dist/api/shared/native-display-op-resolver.d.ts +10 -0
- package/dist/api/shared/native-display-op-resolver.js +64 -0
- package/dist/api/shared/platform-strategy.d.ts +9 -0
- package/dist/api/shared/promise-runtime.js +78 -0
- package/dist/api/shared/validate-framework-manifest.d.ts +28 -0
- package/dist/api/shared/validate-framework-manifest.js +417 -0
- package/dist/cli.js +109 -4
- package/dist/config-loader.js +20 -1
- package/dist/config-schema.d.ts +36 -36
- package/dist/create/board-spec.d.ts +4 -4
- package/dist/create/init-scaffold.d.ts +3 -0
- package/dist/create/init-scaffold.js +48 -0
- package/dist/create/init-templates.d.ts +2 -0
- package/dist/create/init-templates.js +28 -8
- package/dist/create/init-wizard.js +20 -1
- package/dist/emit/cpp-emitter.js +4 -3
- package/dist/emit/emitters/emitter-context.d.ts +5 -0
- package/dist/emit/emitters/function-emitter-impl.js +69 -59
- package/dist/emit/emitters/output-finalizer.d.ts +6 -0
- package/dist/emit/emitters/output-finalizer.js +21 -11
- package/dist/emit/emitters/setup.js +40 -0
- package/dist/emit/emitters/top-level-prep.js +2 -0
- package/dist/emit/emitters/ui-emitter.js +23 -8
- package/dist/emit/expression-renderer.js +10 -1
- package/dist/emit/snprintf-helpers.js +8 -0
- package/dist/emit/statement-renderer.js +13 -0
- package/dist/emit/utils/async-state-machine.js +185 -116
- package/dist/emit/utils/hal-op-cpp-type.d.ts +6 -0
- package/dist/emit/utils/hal-op-cpp-type.js +40 -0
- package/dist/ir/build-ir.js +5 -1
- package/dist/ir/expression-to-ir.js +14 -0
- package/dist/ir/feature-registry.js +7 -25
- package/dist/ir/hal/hal-emitter.d.ts +5 -2
- package/dist/ir/hal/hal-emitter.js +40 -12
- package/dist/ir/hal/hal-parser.d.ts +6 -0
- package/dist/ir/hal/hal-parser.js +74 -0
- package/dist/ir/hal/hal-plugins.js +561 -0
- package/dist/ir/identifier-collector.js +18 -0
- package/dist/ir/network-validation.d.ts +4 -0
- package/dist/ir/network-validation.js +184 -0
- package/dist/ir/ownership-analysis.js +14 -1
- package/dist/ir/program-analysis.d.ts +23 -0
- package/dist/ir/program-analysis.js +81 -2
- package/dist/ir/timing-validation.d.ts +6 -1
- package/dist/ir/timing-validation.js +50 -12
- package/dist/ir/transformers/expressions.js +58 -0
- package/dist/ir/transformers/hal-emit-helpers.js +1 -1
- package/dist/ir/transformers/variables.js +41 -3
- package/dist/ir/validation-orchestrator.js +3 -1
- package/dist/libdef/c-to-decl.d.ts +27 -0
- package/dist/libdef/c-to-decl.js +397 -0
- package/dist/libdef/component-decls.d.ts +2 -0
- package/dist/libdef/component-decls.js +6 -0
- package/dist/libdef/component-discovery.d.ts +43 -0
- package/dist/libdef/component-discovery.js +83 -0
- package/dist/libdef/cpp-to-decl.d.ts +9 -0
- package/dist/libdef/cpp-to-decl.js +72 -0
- package/dist/libdef/idf-discovery.d.ts +7 -0
- package/dist/libdef/idf-discovery.js +59 -0
- package/dist/libdef/registry.js +5 -2
- package/dist/lint-cache.d.ts +59 -0
- package/dist/lint-cache.js +257 -0
- package/dist/orchestrator/graph-builder.js +6 -2
- package/dist/stores/display-profile-store.d.ts +1 -0
- package/dist/stores/display-profile-store.js +1 -0
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +3 -1
- package/dist/transpile.d.ts +3 -0
- package/dist/transpile.js +72 -27
- package/dist/ui-hook.d.ts +17 -1
- package/dist/utils/cli.js +27 -1
- package/dist/utils/fs.d.ts +13 -0
- package/dist/utils/fs.js +50 -0
- package/package.json +8 -4
package/dist/ui-hook.d.ts
CHANGED
|
@@ -58,7 +58,23 @@ export interface TranspilerUIHook {
|
|
|
58
58
|
lowerOnMount(htmlPath: string, opts: LowerOptions): LoweredUI;
|
|
59
59
|
resolveColor(input: string, format: "rgb565" | "rgb666" | "rgb888" | "mono"): number;
|
|
60
60
|
resolveColorInternal(input: string, format: "rgb565" | "rgb666" | "rgb888" | "mono"): number;
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Emits ONLY the CuttlefishGFX class definition (the shared GFX base for
|
|
63
|
+
* native display paths). Called separately from emitRuntimeHeader so the
|
|
64
|
+
* class can be emitted BEFORE display adapter declarations that
|
|
65
|
+
* instantiate CuttlefishGFX by value. Returns "" when active is false
|
|
66
|
+
* (Arduino path).
|
|
67
|
+
*/
|
|
68
|
+
emitCuttlefishGfx(active: boolean): string;
|
|
69
|
+
/**
|
|
70
|
+
* Options controlling runtime-header emission.
|
|
71
|
+
* - nativeDisplayActive: when true, emit the shared CuttlefishGFX class
|
|
72
|
+
* (used by native display adapters on AVR/ESP32). Arduino paths pass
|
|
73
|
+
* false (default) and use Adafruit_GFX directly.
|
|
74
|
+
*/
|
|
75
|
+
emitRuntimeHeader(opts?: {
|
|
76
|
+
nativeDisplayActive?: boolean;
|
|
77
|
+
}): string;
|
|
62
78
|
splitUiFile(src: string): UiFileParts;
|
|
63
79
|
generateProjectUITypeDeclarations(projectRoot: string): {
|
|
64
80
|
written: string[];
|
package/dist/utils/cli.js
CHANGED
|
@@ -431,12 +431,16 @@ export function parseCommandLine(argv) {
|
|
|
431
431
|
// gen-decls - generate .d.ts from C++ files
|
|
432
432
|
if (command === "gen-decls") {
|
|
433
433
|
const allFlag = argv.includes("--all");
|
|
434
|
+
const componentsFlag = argv.includes("--components");
|
|
435
|
+
if (allFlag && componentsFlag) {
|
|
436
|
+
throw new Error("gen-decls: --components and --all are mutually exclusive. Use one or the other.");
|
|
437
|
+
}
|
|
434
438
|
// The positional path may sit at argv[3] or argv[4] depending on whether
|
|
435
439
|
// --all precedes or follows it. Scan argv starting after the subcommand
|
|
436
440
|
// name (argv[2]) for the first token that is not a flag and not a known
|
|
437
441
|
// flag's value. This mirrors the default-pipeline approach of "first
|
|
438
442
|
// non-flag token wins".
|
|
439
|
-
const booleanFlags = new Set(["--all"]);
|
|
443
|
+
const booleanFlags = new Set(["--all", "--components"]);
|
|
440
444
|
const valueFlags = new Set([
|
|
441
445
|
"--emit", "--target", "--outDir", "--out-dir", "--emit-maps", "--build-target",
|
|
442
446
|
]);
|
|
@@ -457,6 +461,28 @@ export function parseCommandLine(argv) {
|
|
|
457
461
|
inputPath = tok;
|
|
458
462
|
break;
|
|
459
463
|
}
|
|
464
|
+
// --components mode: scan managed_components/ + components/ declared in
|
|
465
|
+
// cuttlefish.config.ts. Falls back to cwd when no path is given.
|
|
466
|
+
if (componentsFlag) {
|
|
467
|
+
const componentsDir = inputPath || process.cwd();
|
|
468
|
+
return {
|
|
469
|
+
command: "gen-decls",
|
|
470
|
+
inputFile: undefined,
|
|
471
|
+
emitMode,
|
|
472
|
+
target,
|
|
473
|
+
outDir: outDir ? path.resolve(process.cwd(), outDir) : undefined,
|
|
474
|
+
emitMaps,
|
|
475
|
+
noTranspile: false,
|
|
476
|
+
compile: false,
|
|
477
|
+
upload: false,
|
|
478
|
+
monitor: false,
|
|
479
|
+
watch: false,
|
|
480
|
+
baud: 9600,
|
|
481
|
+
platformContext,
|
|
482
|
+
scanDir: undefined,
|
|
483
|
+
componentsDir: path.resolve(process.cwd(), componentsDir),
|
|
484
|
+
};
|
|
485
|
+
}
|
|
460
486
|
if (!inputPath && !allFlag) {
|
|
461
487
|
throw new Error("Missing input C++ file path. Use: gen-decls <file.cpp> or gen-decls --all <directory>");
|
|
462
488
|
}
|
package/dist/utils/fs.d.ts
CHANGED
|
@@ -2,3 +2,16 @@ export declare function ensureDir(dirPath: string): void;
|
|
|
2
2
|
export declare function readText(filePath: string): string;
|
|
3
3
|
export declare function writeText(filePath: string, content: string): void;
|
|
4
4
|
export declare function listFiles(dirPath: string, extension: string): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Recursive variant of {@link listFiles}. Walks `dirPath` depth-first and
|
|
7
|
+
* returns every file (in every subdirectory) whose name ends with `extension`.
|
|
8
|
+
*
|
|
9
|
+
* Used by {@link loadLibraryDefinitions} so libdefs under nested cache dirs
|
|
10
|
+
* like `.cuttlefish/component-decls/<component>/` are discovered. Purely
|
|
11
|
+
* additive vs. the non-recursive `listFiles` — single-level layouts keep
|
|
12
|
+
* working, nested layouts now also work.
|
|
13
|
+
*
|
|
14
|
+
* Returns absolute paths. Unreadable directories are silently skipped
|
|
15
|
+
* (matches `listFiles`'s not-exist behavior for non-existent roots).
|
|
16
|
+
*/
|
|
17
|
+
export declare function listFilesRecursive(dirPath: string, extension: string): string[];
|
package/dist/utils/fs.js
CHANGED
|
@@ -10,6 +10,15 @@ export function readText(filePath) {
|
|
|
10
10
|
}
|
|
11
11
|
export function writeText(filePath, content) {
|
|
12
12
|
ensureDir(path.dirname(filePath));
|
|
13
|
+
// Skip writing when content is identical — preserves mtime so downstream
|
|
14
|
+
// build tools (idf.py/ninja, arduino-cli, make) can skip recompilation.
|
|
15
|
+
try {
|
|
16
|
+
if (fs.readFileSync(filePath, "utf8") === content)
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// File doesn't exist yet — fall through to write.
|
|
21
|
+
}
|
|
13
22
|
fs.writeFileSync(filePath, content, "utf8");
|
|
14
23
|
}
|
|
15
24
|
export function listFiles(dirPath, extension) {
|
|
@@ -21,3 +30,44 @@ export function listFiles(dirPath, extension) {
|
|
|
21
30
|
.filter((name) => name.toLowerCase().endsWith(extension.toLowerCase()))
|
|
22
31
|
.map((name) => path.join(dirPath, name));
|
|
23
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Recursive variant of {@link listFiles}. Walks `dirPath` depth-first and
|
|
35
|
+
* returns every file (in every subdirectory) whose name ends with `extension`.
|
|
36
|
+
*
|
|
37
|
+
* Used by {@link loadLibraryDefinitions} so libdefs under nested cache dirs
|
|
38
|
+
* like `.cuttlefish/component-decls/<component>/` are discovered. Purely
|
|
39
|
+
* additive vs. the non-recursive `listFiles` — single-level layouts keep
|
|
40
|
+
* working, nested layouts now also work.
|
|
41
|
+
*
|
|
42
|
+
* Returns absolute paths. Unreadable directories are silently skipped
|
|
43
|
+
* (matches `listFiles`'s not-exist behavior for non-existent roots).
|
|
44
|
+
*/
|
|
45
|
+
export function listFilesRecursive(dirPath, extension) {
|
|
46
|
+
if (!fs.existsSync(dirPath)) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const ext = extension.toLowerCase();
|
|
50
|
+
const out = [];
|
|
51
|
+
const stack = [dirPath];
|
|
52
|
+
while (stack.length > 0) {
|
|
53
|
+
const cur = stack.pop();
|
|
54
|
+
let entries;
|
|
55
|
+
try {
|
|
56
|
+
entries = fs.readdirSync(cur, { withFileTypes: true });
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Permission error / race / etc. Skip this subtree.
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
const full = path.join(cur, entry.name);
|
|
64
|
+
if (entry.isDirectory()) {
|
|
65
|
+
stack.push(full);
|
|
66
|
+
}
|
|
67
|
+
else if (entry.isFile() && entry.name.toLowerCase().endsWith(ext)) {
|
|
68
|
+
out.push(full);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typecad/cuttlefish",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "TypeScript to C++ transpiler — native, Arduino, and bare-metal targets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/transpile.js",
|
|
@@ -49,6 +49,10 @@
|
|
|
49
49
|
"types": "./dist/emit/route-hal-op.d.ts",
|
|
50
50
|
"default": "./dist/emit/route-hal-op.js"
|
|
51
51
|
},
|
|
52
|
+
"./lib/component-decls": {
|
|
53
|
+
"types": "./dist/libdef/component-decls.d.ts",
|
|
54
|
+
"default": "./dist/libdef/component-decls.js"
|
|
55
|
+
},
|
|
52
56
|
"./ir/transformers/ui-lowering": {
|
|
53
57
|
"types": "./dist/ir/transformers/ui-lowering.d.ts",
|
|
54
58
|
"default": "./dist/ir/transformers/ui-lowering.js"
|
|
@@ -81,10 +85,10 @@
|
|
|
81
85
|
"chalk": "^4.1.2",
|
|
82
86
|
"typescript": "^5.7.3",
|
|
83
87
|
"zod": "^3.24.0",
|
|
84
|
-
"@typecad/arduino-cli": "1.0.0-alpha.
|
|
88
|
+
"@typecad/arduino-cli": "1.0.0-alpha.7"
|
|
85
89
|
},
|
|
86
90
|
"peerDependencies": {
|
|
87
|
-
"@typecad/ui": "1.0.0-alpha.
|
|
91
|
+
"@typecad/ui": "1.0.0-alpha.7"
|
|
88
92
|
},
|
|
89
93
|
"peerDependenciesMeta": {
|
|
90
94
|
"@typecad/ui": {
|
|
@@ -92,7 +96,7 @@
|
|
|
92
96
|
}
|
|
93
97
|
},
|
|
94
98
|
"optionalDependencies": {
|
|
95
|
-
"@typecad/framework-native": "1.0.0-alpha.
|
|
99
|
+
"@typecad/framework-native": "1.0.0-alpha.7"
|
|
96
100
|
},
|
|
97
101
|
"devDependencies": {
|
|
98
102
|
"@types/node": "^22.10.7"
|