@typecad/cuttlefish 1.0.0-alpha.12 → 1.0.0-alpha.14

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.
Files changed (101) hide show
  1. package/assets/editor-extensions/typecad-debug/README.md +142 -0
  2. package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
  3. package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
  4. package/assets/editor-extensions/typecad-debug/package.json +76 -0
  5. package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
  6. package/assets/editor-extensions/typecad-ui/README.md +52 -0
  7. package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
  8. package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
  9. package/assets/editor-extensions/typecad-ui/icon.png +0 -0
  10. package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
  11. package/assets/editor-extensions/typecad-ui/package.json +54 -0
  12. package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
  13. package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
  14. package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
  15. package/dist/add-preset.d.ts +4 -0
  16. package/dist/add-preset.js +74 -0
  17. package/dist/api/config.d.ts +8 -5
  18. package/dist/api/shared/display-adapters/sdl.js +1 -1
  19. package/dist/api/shared/display-profile.d.ts +11 -0
  20. package/dist/api/shared/display-profile.js +3 -0
  21. package/dist/api/shared/framework-manifest.d.ts +61 -504
  22. package/dist/api/shared/hal-op-ir.d.ts +19 -0
  23. package/dist/api/shared/toolchain-types.d.ts +0 -1
  24. package/dist/cli.js +31 -9
  25. package/dist/config-loader.d.ts +0 -2
  26. package/dist/config-loader.js +13 -6
  27. package/dist/config-schema.d.ts +17 -230
  28. package/dist/config-schema.js +1 -3
  29. package/dist/contract/contract-parser.d.ts +9 -127
  30. package/dist/create/board-checklist.js +1 -1
  31. package/dist/create/board-codegen.js +4 -4
  32. package/dist/create/board-spec.d.ts +74 -530
  33. package/dist/create/debug-artifacts.d.ts +20 -0
  34. package/dist/create/debug-artifacts.js +69 -0
  35. package/dist/create/editor-integration.d.ts +30 -0
  36. package/dist/create/editor-integration.js +218 -0
  37. package/dist/create/eslint-rules-template.d.ts +2 -2
  38. package/dist/create/framework-catalog.d.ts +8 -0
  39. package/dist/create/framework-catalog.js +28 -5
  40. package/dist/create/index.d.ts +9 -6
  41. package/dist/create/index.js +6 -4
  42. package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +5 -4
  43. package/dist/create/{init-scaffold.js → scaffold.js} +38 -2
  44. package/dist/create/templates.d.ts +29 -0
  45. package/dist/create/{init-templates.js → templates.js} +15 -2
  46. package/dist/create/wizard.d.ts +8 -0
  47. package/dist/create/{init-wizard.js → wizard.js} +11 -4
  48. package/dist/emit/compliance/rules.js +18 -4
  49. package/dist/emit/emitters/function-emitter-impl.js +7 -1
  50. package/dist/emit/emitters/line-appender.js +6 -0
  51. package/dist/emit/emitters/setup.js +22 -0
  52. package/dist/emit/emitters/ui-emitter.js +40 -15
  53. package/dist/emit/route-hal-op.js +55 -1
  54. package/dist/emit/statement-renderer.js +5 -2
  55. package/dist/ir/build-ir.js +46 -4
  56. package/dist/ir/expression-to-ir.js +17 -0
  57. package/dist/ir/hal/hal-emitter.js +23 -5
  58. package/dist/ir/hal/hal-plugins.js +11 -0
  59. package/dist/ir/pin-mode-validation.js +32 -9
  60. package/dist/ir/pin-state-tracking.d.ts +58 -0
  61. package/dist/ir/pin-state-tracking.js +182 -0
  62. package/dist/ir/program-analysis.d.ts +6 -0
  63. package/dist/ir/program-analysis.js +38 -0
  64. package/dist/ir/statement-to-ir.js +14 -0
  65. package/dist/ir/transformers/control-flow.js +29 -0
  66. package/dist/ir/transformers/ui-call-resolver.js +105 -1
  67. package/dist/ir/ui-element-auto-wire.js +7 -4
  68. package/dist/library/catalog.d.ts +35 -0
  69. package/dist/library/catalog.js +67 -0
  70. package/dist/library/cli.d.ts +2 -0
  71. package/dist/library/cli.js +168 -0
  72. package/dist/library/init.d.ts +25 -0
  73. package/dist/library/init.js +397 -0
  74. package/dist/library/install.d.ts +9 -0
  75. package/dist/library/install.js +80 -0
  76. package/dist/library/registry-search.d.ts +34 -0
  77. package/dist/library/registry-search.js +50 -0
  78. package/dist/library/validate.d.ts +17 -0
  79. package/dist/library/validate.js +175 -0
  80. package/dist/library-packages.d.ts +95 -0
  81. package/dist/library-packages.js +275 -0
  82. package/dist/orchestrator/graph-builder.d.ts +4 -1
  83. package/dist/orchestrator/graph-builder.js +23 -1
  84. package/dist/preview/api-shared-shim.d.ts +1 -0
  85. package/dist/preview/api-shared-shim.js +7 -0
  86. package/dist/preview/client.js +235 -2
  87. package/dist/preview/server.js +154 -62
  88. package/dist/testing.d.ts +2 -2
  89. package/dist/testing.js +1 -1
  90. package/dist/theme-tokens.d.ts +22 -0
  91. package/dist/theme-tokens.js +172 -0
  92. package/dist/transpile.js +90 -5
  93. package/dist/types.d.ts +24 -0
  94. package/dist/ui-hook.d.ts +7 -0
  95. package/dist/utils/cli.d.ts +2 -2
  96. package/dist/utils/cli.js +77 -3
  97. package/dist/utils/ui.d.ts +5 -0
  98. package/dist/utils/ui.js +7 -0
  99. package/package.json +18 -9
  100. package/dist/create/init-templates.d.ts +0 -28
  101. package/dist/create/init-wizard.d.ts +0 -8
package/dist/types.d.ts CHANGED
@@ -100,6 +100,8 @@ export interface TranspileOptions {
100
100
  autosar?: ComplianceMode;
101
101
  /** When true (and autosar is warn/strict), also emit the .autosar-deviations.arxml sidecar. */
102
102
  autosarArxml?: boolean;
103
+ /** Upgrade UI CSS-compatibility warnings (css-* diagnostics) to errors. */
104
+ strictCss?: boolean;
103
105
  }
104
106
  export interface LibraryDefinitionCondition {
105
107
  target?: TargetProfile;
@@ -179,6 +181,8 @@ export interface CommandLineOptions {
179
181
  autosar?: ComplianceMode;
180
182
  /** When true (and autosar is warn/strict), also emit the .autosar-deviations.arxml sidecar. */
181
183
  autosarArxml?: boolean;
184
+ /** Upgrade UI CSS-compatibility warnings (css-* diagnostics) to errors. */
185
+ strictCss?: boolean;
182
186
  /** Config file for preview command */
183
187
  configPath?: string;
184
188
  /** Project root (dir of cuttlefish.config.ts); passed to transpileFile for the ESLint gate. */
@@ -188,6 +192,7 @@ export interface GenerateLibdefOptions {
188
192
  inputFile: string;
189
193
  outDir: string;
190
194
  }
195
+ /** `cuttlefish add <preset>` — scaffold a copy-and-own asset into the project. */
191
196
  export interface GeneratedOutputs {
192
197
  headerPath?: string;
193
198
  sourcePath: string;
@@ -233,4 +238,23 @@ export interface BoardAddCommandOptions {
233
238
  specPath: string;
234
239
  force?: boolean;
235
240
  }
241
+ /** Parsed `cuttlefish library <subcommand>` options. */
242
+ export interface LibraryCommandOptions {
243
+ command: "library";
244
+ subcommand: "search" | "install" | "init" | "validate";
245
+ /** Non-flag tokens after the subcommand: search text, install names, init name, validate path. */
246
+ positionals: string[];
247
+ /** search: taxonomy category id. */
248
+ category?: string;
249
+ /** init: framework id from the framework catalog. */
250
+ framework?: string;
251
+ /** init: comma-separated board-target prefixes. */
252
+ targets?: string;
253
+ /** init: scaffold directory (default ./<library-id>). */
254
+ dir?: string;
255
+ /** init: skip prompts, take defaults. */
256
+ yes?: boolean;
257
+ /** Machine-readable output for search/validate. */
258
+ json?: boolean;
259
+ }
236
260
  export {};
package/dist/ui-hook.d.ts CHANGED
@@ -75,6 +75,13 @@ export interface TranspilerUIHook {
75
75
  nativeDisplayActive?: boolean;
76
76
  }): string;
77
77
  splitUiFile(src: string): UiFileParts;
78
+ /** Pre-decode src="…" image references (png/jpg/ico/…) into the RGB565
79
+ * asset cache. Must be awaited BEFORE loadUIModule/loadUIModuleFromText —
80
+ * the synchronous asset reader and natural-size layout read the cache. */
81
+ warmUpImageDecoding(sourceText: string, baseDir: string, opts?: {
82
+ maxW?: number;
83
+ maxH?: number;
84
+ }): Promise<void>;
78
85
  generateProjectUITypeDeclarations(projectRoot: string): {
79
86
  written: string[];
80
87
  errors: Array<{
@@ -1,3 +1,3 @@
1
- import { CommandLineOptions, CreateCommandOptions, BoardAddCommandOptions } from "../types.js";
1
+ import { CommandLineOptions, CreateCommandOptions, BoardAddCommandOptions, LibraryCommandOptions } from "../types.js";
2
2
  export declare function printHelp(): void;
3
- export declare function parseCommandLine(argv: string[]): CommandLineOptions | CreateCommandOptions | BoardAddCommandOptions | "help";
3
+ export declare function parseCommandLine(argv: string[]): CommandLineOptions | CreateCommandOptions | BoardAddCommandOptions | LibraryCommandOptions | "help";
package/dist/utils/cli.js CHANGED
@@ -20,6 +20,15 @@ export function printHelp() {
20
20
  console.log(` cuttlefish doctor Check the active framework's environment (e.g. toolchain + board core)`);
21
21
  console.log(` cuttlefish licenses [--all] [--strict] Scan this project's Arduino libraries for SPDX licenses (--all: every installed library)`);
22
22
  console.log();
23
+ console.log(chalk.cyan(`LIBRARY PACKAGES`) + chalk.gray(` (npm keywords are the catalog)`));
24
+ console.log();
25
+ console.log(` cuttlefish library search [text] [--category <id>] [--json]`);
26
+ console.log(` Browse cuttlefish library packages on npm, optionally by category`);
27
+ console.log(` cuttlefish library install <pkg...> Install library packages into this project`);
28
+ console.log(` cuttlefish library init [name] [--framework <id>] [--category <id>] [--targets <list>]`);
29
+ console.log(` Scaffold a new library package (interactive; --yes takes defaults)`);
30
+ console.log(` cuttlefish library validate [path] [--json] Validate a library package (manifest, shims, keywords, AUTOSAR strict)`);
31
+ console.log();
23
32
  console.log(chalk.gray(`Transpilation is always performed first. Use --compile, --upload, and`));
24
33
  console.log(chalk.gray(`--monitor to chain operations after transpilation.`));
25
34
  console.log();
@@ -49,6 +58,10 @@ export function printHelp() {
49
58
  console.log(` --autosar-arxml Also write <name>.autosar-deviations.arxml (Artop/DaVinci).`);
50
59
  console.log(` No-op unless --autosar is warn or strict.`);
51
60
  console.log();
61
+ console.log(` --strict-css Treat UI CSS-compatibility warnings as errors (css-*`);
62
+ console.log(` diagnostics: ignored alpha, quantized font sizes,`);
63
+ console.log(` unsupported display/position values, viewport-hogging sizes).`);
64
+ console.log();
52
65
  console.log(chalk.cyan(`BUILD COMMANDS`) + chalk.gray(` (chain in order: --compile → --upload → --monitor)`));
53
66
  console.log();
54
67
  console.log(` --compile Compile the generated output using the framework toolchain.`);
@@ -277,6 +290,10 @@ function parsePipelineCommand(argv, command, inputFile) {
277
290
  // --autosar-arxml: also write the .autosar-deviations.arxml sidecar
278
291
  // (Artop/DaVinci tooling). No-op unless --autosar is warn or strict.
279
292
  const autosarArxml = readBooleanFlag(argv, ["--autosar-arxml"]);
293
+ // --strict-css: upgrade UI CSS-compatibility warnings (css-* diagnostics,
294
+ // e.g. ignored alpha, quantized font sizes, unsupported display values) to
295
+ // errors so builds fail instead of silently approximating.
296
+ const strictCss = readBooleanFlag(argv, ["--strict-css"]);
280
297
  const emitMode = emitFlag === "cpp" || emitFlag === "split" ? emitFlag : "split";
281
298
  const emitMaps = emitMapsFlag === undefined ? true : emitMapsFlag !== "false";
282
299
  // Accept any target string — the framework package registers its own strategy id.
@@ -329,6 +346,7 @@ function parsePipelineCommand(argv, command, inputFile) {
329
346
  frameworkPackage: frameworkFlag,
330
347
  autosar,
331
348
  autosarArxml,
349
+ strictCss,
332
350
  };
333
351
  }
334
352
  export function parseCommandLine(argv) {
@@ -362,9 +380,6 @@ export function parseCommandLine(argv) {
362
380
  if (firstArg === "create-board") {
363
381
  throw new Error(`The 'create-board' command has been removed. Board scaffolding is now in @typecad/create.`);
364
382
  }
365
- if (firstArg === "init") {
366
- throw new Error(`Use 'cuttlefish create' instead of 'cuttlefish init'.`);
367
- }
368
383
  // build subcommand — entry point comes from cuttlefish.config.ts
369
384
  if (firstArg === "build") {
370
385
  return parsePipelineCommand(argv, "build");
@@ -432,6 +447,65 @@ export function parseCommandLine(argv) {
432
447
  platformContext: {},
433
448
  };
434
449
  }
450
+ // library subcommand — the cuttlefish library package manager
451
+ // (search/install/init/validate; npm keywords are the catalog).
452
+ if (firstArg === "library") {
453
+ const sub = argv[3];
454
+ const known = new Set(["search", "install", "init", "validate"]);
455
+ if (!sub || !known.has(sub)) {
456
+ throw new Error("Usage: cuttlefish library <search|install|init|validate> [args]. " +
457
+ "Try 'cuttlefish library search' to browse, or 'cuttlefish library init <name>'.");
458
+ }
459
+ const subcommand = sub;
460
+ // Value flags accept both forms (--category led and --category=led); the
461
+ // generic readFlag helper only handles the space-separated form, which
462
+ // would silently drop an equals-form filter.
463
+ const valueFlags = new Set(["--category", "--framework", "--targets", "--dir"]);
464
+ const flagValues = new Map();
465
+ const positionals = [];
466
+ let jsonFlag = false;
467
+ let yesFlag = false;
468
+ for (let i = 4; i < argv.length; i++) {
469
+ const tok = argv[i];
470
+ if (tok.startsWith("--") && tok.includes("=")) {
471
+ const eq = tok.indexOf("=");
472
+ flagValues.set(tok.slice(0, eq), tok.slice(eq + 1));
473
+ continue;
474
+ }
475
+ if (valueFlags.has(tok)) {
476
+ if (i + 1 < argv.length) {
477
+ flagValues.set(tok, argv[++i]);
478
+ }
479
+ continue;
480
+ }
481
+ if (tok === "--json") {
482
+ jsonFlag = true;
483
+ continue;
484
+ }
485
+ if (tok === "--yes" || tok === "-y") {
486
+ yesFlag = true;
487
+ continue;
488
+ }
489
+ if (tok.startsWith("-"))
490
+ continue;
491
+ positionals.push(tok);
492
+ }
493
+ const category = flagValues.get("--category");
494
+ if (category !== undefined && subcommand !== "search" && subcommand !== "init") {
495
+ throw new Error("--category applies to 'library search' and 'library init' only.");
496
+ }
497
+ return {
498
+ command: "library",
499
+ subcommand,
500
+ positionals,
501
+ category,
502
+ framework: flagValues.get("--framework"),
503
+ targets: flagValues.get("--targets"),
504
+ dir: flagValues.get("--dir"),
505
+ yes: yesFlag,
506
+ json: jsonFlag,
507
+ };
508
+ }
435
509
  // Named subcommands
436
510
  if (firstArg === "gen-libdefs" || firstArg === "gen-decls" || firstArg === "map-error") {
437
511
  const command = firstArg;
@@ -27,6 +27,11 @@ export declare function printTranspiling(): void;
27
27
  * Print compiling step
28
28
  */
29
29
  export declare function printCompiling(target: string): void;
30
+ /**
31
+ * Print the debug-session strategy notice (debug builds only): which
32
+ * framework's code-generation strategy is preparing the debug build.
33
+ */
34
+ export declare function printDebugStrategy(framework: string): void;
30
35
  /**
31
36
  * Print uploading step
32
37
  */
package/dist/utils/ui.js CHANGED
@@ -69,6 +69,13 @@ export function printTranspiling() {
69
69
  export function printCompiling(target) {
70
70
  console.log(chalk.cyan(`${ICON_COMPILE} Compiling for `) + chalk.white(target));
71
71
  }
72
+ /**
73
+ * Print the debug-session strategy notice (debug builds only): which
74
+ * framework's code-generation strategy is preparing the debug build.
75
+ */
76
+ export function printDebugStrategy(framework) {
77
+ console.log(chalk.cyan(`${ICON_COMPILE} Preparing to debug using `) + chalk.white(framework));
78
+ }
72
79
  /**
73
80
  * Print uploading step
74
81
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typecad/cuttlefish",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.14",
4
4
  "description": "TypeScript to C++ transpiler — native, Arduino, and bare-metal targets",
5
5
  "type": "module",
6
6
  "main": "./dist/transpile.js",
@@ -37,6 +37,14 @@
37
37
  "types": "./dist/ir/build-ir-state.d.ts",
38
38
  "default": "./dist/ir/build-ir-state.js"
39
39
  },
40
+ "./library-packages": {
41
+ "types": "./dist/library-packages.d.ts",
42
+ "default": "./dist/library-packages.js"
43
+ },
44
+ "./compliance": {
45
+ "types": "./dist/emit/compliance/index.d.ts",
46
+ "default": "./dist/emit/compliance/index.js"
47
+ },
40
48
  "./config-loader": {
41
49
  "types": "./dist/config-loader.d.ts",
42
50
  "default": "./dist/config-loader.js"
@@ -83,7 +91,8 @@
83
91
  }
84
92
  },
85
93
  "files": [
86
- "dist"
94
+ "dist",
95
+ "assets"
87
96
  ],
88
97
  "publishConfig": {
89
98
  "access": "public"
@@ -94,13 +103,13 @@
94
103
  "start": "node dist/cli.js"
95
104
  },
96
105
  "dependencies": {
97
- "chalk": "^4.1.2",
106
+ "chalk": "^6.0.0",
98
107
  "typescript": "^5.7.3",
99
- "zod": "^3.24.0"
108
+ "zod": "^4.4.3"
100
109
  },
101
110
  "peerDependencies": {
102
- "@typecad/ui": "1.0.0-alpha.12",
103
- "@typecad/safety": "1.0.0-alpha.12"
111
+ "@typecad/ui": "1.0.0-alpha.14",
112
+ "@typecad/safety": "1.0.0-alpha.14"
104
113
  },
105
114
  "peerDependenciesMeta": {
106
115
  "@typecad/ui": {
@@ -111,8 +120,8 @@
111
120
  }
112
121
  },
113
122
  "optionalDependencies": {
114
- "@typecad/expect": "1.0.0-alpha.12",
115
- "@typecad/framework-native": "1.0.0-alpha.12"
123
+ "@typecad/expect": "1.0.0-alpha.14",
124
+ "@typecad/framework-native": "1.0.0-alpha.14"
116
125
  },
117
126
  "devDependencies": {
118
127
  "@types/node": "^22.10.7"
@@ -141,7 +150,7 @@
141
150
  "typescript"
142
151
  ],
143
152
  "engines": {
144
- "node": ">=18"
153
+ "node": ">=22.11.0"
145
154
  },
146
155
  "author": "typecad0",
147
156
  "sideEffects": false
@@ -1,28 +0,0 @@
1
- import type { ArchitectureIdentifier } from '../api/index.js';
2
- export interface InitProjectOptions {
3
- projectName: string;
4
- targetId: string;
5
- targetDisplayName: string;
6
- isNative: boolean;
7
- architecture?: ArchitectureIdentifier;
8
- boardPackage?: string;
9
- frameworkPackage: string;
10
- framework: string;
11
- buildTarget?: string;
12
- mcu?: string;
13
- baudRate?: number;
14
- includeSketch: boolean;
15
- toolchainType?: string;
16
- /** Extra frameworkData fields (e.g. `{ target: 'esp32s3' }` for framework-esp32). */
17
- frameworkData?: Record<string, unknown>;
18
- }
19
- export declare function generateProjectPackageJson(options: InitProjectOptions): string;
20
- export declare function generateProjectTsconfig(options: InitProjectOptions): string;
21
- export declare function generateProjectConfig(options: InitProjectOptions): string;
22
- export declare function generateProjectEnvDts(options: InitProjectOptions): string;
23
- export declare function generateStarterSketch(options: InitProjectOptions): string;
24
- export declare function generateStarterTest(_options: InitProjectOptions): string;
25
- export declare function generateStarterSim(options: InitProjectOptions): string;
26
- export declare function generateBoardForwardingFile(boardPackage: string): string;
27
- export declare function generateGitignore(_options: InitProjectOptions): string;
28
- export declare function generateEslintConfig(_options: InitProjectOptions): string;
@@ -1,8 +0,0 @@
1
- import type { InitProjectOptions } from "./init-templates.js";
2
- export declare function runInitWizard(partialOptions?: {
3
- projectName?: string;
4
- board?: string;
5
- framework?: string;
6
- baud?: number;
7
- noSketch?: boolean;
8
- }): Promise<InitProjectOptions | null>;