@typecad/cuttlefish 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (187) hide show
  1. package/dist/api/config.d.ts +32 -0
  2. package/dist/api/index.d.ts +1 -1
  3. package/dist/api/schema/types.d.ts +15 -0
  4. package/dist/api/shared/async-runtime-static.d.ts +12 -1
  5. package/dist/api/shared/async-runtime-static.js +69 -24
  6. package/dist/api/shared/async-symbol-detector.d.ts +11 -0
  7. package/dist/api/shared/async-symbol-detector.js +140 -0
  8. package/dist/api/shared/async-types.d.ts +24 -0
  9. package/dist/api/shared/coop-scheduler.d.ts +60 -0
  10. package/dist/api/shared/coop-scheduler.js +149 -0
  11. package/dist/api/shared/display-adapter.d.ts +4 -3
  12. package/dist/api/shared/display-adapter.js +15 -118
  13. package/dist/api/shared/display-adapters/sdl.js +38 -31
  14. package/dist/api/shared/display-profile.d.ts +47 -25
  15. package/dist/api/shared/display-profile.js +31 -164
  16. package/dist/api/shared/framework-manifest-registry.d.ts +9 -0
  17. package/dist/api/shared/framework-manifest-registry.js +27 -0
  18. package/dist/api/shared/framework-manifest.d.ts +581 -0
  19. package/dist/api/shared/framework-manifest.js +182 -0
  20. package/dist/api/shared/glcdfont.d.ts +12 -0
  21. package/dist/api/shared/glcdfont.js +124 -0
  22. package/dist/api/shared/graphics-strategy.d.ts +37 -0
  23. package/dist/api/shared/hal-op-ir.d.ts +755 -1
  24. package/dist/api/shared/hal-op-ir.js +129 -1
  25. package/dist/api/shared/index.d.ts +20 -2
  26. package/dist/api/shared/index.js +25 -1
  27. package/dist/api/shared/ir-core.d.ts +4 -0
  28. package/dist/api/shared/ir-declarations.d.ts +6 -0
  29. package/dist/api/shared/native-display-op-resolver.d.ts +10 -0
  30. package/dist/api/shared/native-display-op-resolver.js +64 -0
  31. package/dist/api/shared/platform-strategy.d.ts +113 -2
  32. package/dist/api/shared/polyfill-helper-registry.js +18 -1
  33. package/dist/api/shared/promise-runtime.d.ts +1 -1
  34. package/dist/api/shared/promise-runtime.js +95 -13
  35. package/dist/api/shared/toolchain-types.d.ts +17 -0
  36. package/dist/api/shared/validate-framework-manifest.d.ts +28 -0
  37. package/dist/api/shared/validate-framework-manifest.js +494 -0
  38. package/dist/api/shared/worker-runtime-polyfill.d.ts +22 -0
  39. package/dist/api/shared/worker-runtime-polyfill.js +34 -0
  40. package/dist/api/shared/worker-runtime.d.ts +69 -0
  41. package/dist/api/shared/worker-runtime.js +163 -0
  42. package/dist/cli.js +186 -82
  43. package/dist/config-loader.d.ts +7 -2
  44. package/dist/config-loader.js +23 -3
  45. package/dist/config-schema.d.ts +112 -70
  46. package/dist/config-schema.js +14 -0
  47. package/dist/contract/board-generator.d.ts +17 -0
  48. package/dist/contract/board-generator.js +57 -0
  49. package/dist/contract/contract-parser.d.ts +217 -0
  50. package/dist/contract/contract-parser.js +224 -0
  51. package/dist/contract/index.d.ts +22 -0
  52. package/dist/contract/index.js +68 -0
  53. package/dist/create/board-codegen.js +4 -4
  54. package/dist/create/board-generators.js +4 -5
  55. package/dist/create/board-spec.d.ts +72 -75
  56. package/dist/create/board-spec.js +0 -1
  57. package/dist/create/init-scaffold.d.ts +9 -2
  58. package/dist/create/init-scaffold.js +0 -14
  59. package/dist/create/init-templates.d.ts +2 -0
  60. package/dist/create/init-templates.js +74 -8
  61. package/dist/create/init-wizard.js +31 -7
  62. package/dist/debug/preprocessor.js +178 -39
  63. package/dist/debug/types.d.ts +23 -0
  64. package/dist/diagnostics/mermaid-builder.d.ts +1 -1
  65. package/dist/diagnostics/mermaid-builder.js +34 -24
  66. package/dist/emit/compliance/arxml-writer.d.ts +11 -0
  67. package/dist/emit/compliance/arxml-writer.js +34 -0
  68. package/dist/emit/compliance/compliance-context.d.ts +57 -0
  69. package/dist/emit/compliance/compliance-context.js +113 -0
  70. package/dist/emit/compliance/deviation-ledger.d.ts +27 -0
  71. package/dist/emit/compliance/deviation-ledger.js +47 -0
  72. package/dist/emit/compliance/deviation-writer.d.ts +30 -0
  73. package/dist/emit/compliance/deviation-writer.js +37 -0
  74. package/dist/emit/compliance/index.d.ts +7 -0
  75. package/dist/emit/compliance/index.js +6 -0
  76. package/dist/emit/compliance/rule-engine.d.ts +13 -0
  77. package/dist/emit/compliance/rule-engine.js +101 -0
  78. package/dist/emit/compliance/rules.d.ts +16 -0
  79. package/dist/emit/compliance/rules.js +191 -0
  80. package/dist/emit/compliance/types.d.ts +59 -0
  81. package/dist/emit/compliance/types.js +8 -0
  82. package/dist/emit/cpp-emitter.js +4 -3
  83. package/dist/emit/emitters/class-emitter.js +6 -1
  84. package/dist/emit/emitters/emitter-context.d.ts +28 -1
  85. package/dist/emit/emitters/function-emitter-impl.js +153 -53
  86. package/dist/emit/emitters/line-appender.js +19 -0
  87. package/dist/emit/emitters/line-marker.d.ts +38 -0
  88. package/dist/emit/emitters/line-marker.js +39 -0
  89. package/dist/emit/emitters/output-finalizer.d.ts +6 -0
  90. package/dist/emit/emitters/output-finalizer.js +101 -12
  91. package/dist/emit/emitters/setup.d.ts +17 -0
  92. package/dist/emit/emitters/setup.js +257 -36
  93. package/dist/emit/emitters/top-level-prep.js +8 -0
  94. package/dist/emit/emitters/type-decl-emitter.js +28 -3
  95. package/dist/emit/emitters/ui-emitter.js +33 -9
  96. package/dist/emit/expression-renderer.d.ts +1 -1
  97. package/dist/emit/expression-renderer.js +91 -6
  98. package/dist/emit/route-hal-op.js +18 -5
  99. package/dist/emit/snprintf-helpers.js +15 -4
  100. package/dist/emit/statement-renderer.d.ts +10 -0
  101. package/dist/emit/statement-renderer.js +34 -5
  102. package/dist/emit/utils/async-state-machine.js +221 -125
  103. package/dist/emit/utils/hal-op-cpp-type.d.ts +6 -0
  104. package/dist/emit/utils/hal-op-cpp-type.js +40 -0
  105. package/dist/framework-package.js +2 -0
  106. package/dist/framework-registry.d.ts +17 -0
  107. package/dist/ir/adc-range-validation.js +14 -1
  108. package/dist/ir/build-ir-state.d.ts +1 -0
  109. package/dist/ir/build-ir-state.js +14 -0
  110. package/dist/ir/build-ir.js +9 -5
  111. package/dist/ir/call-graph.js +16 -0
  112. package/dist/ir/expression-to-ir.js +164 -0
  113. package/dist/ir/feature-registry.js +7 -25
  114. package/dist/ir/function-builder.js +22 -0
  115. package/dist/ir/hal/hal-emitter.d.ts +5 -2
  116. package/dist/ir/hal/hal-emitter.js +50 -18
  117. package/dist/ir/hal/hal-parser.d.ts +6 -0
  118. package/dist/ir/hal/hal-parser.js +81 -0
  119. package/dist/ir/hal/hal-plugins.js +723 -1
  120. package/dist/ir/identifier-collector.js +35 -0
  121. package/dist/ir/interrupt-analysis.d.ts +5 -1
  122. package/dist/ir/interrupt-analysis.js +8 -16
  123. package/dist/ir/network-validation.d.ts +4 -0
  124. package/dist/ir/network-validation.js +184 -0
  125. package/dist/ir/ownership-analysis.js +20 -1
  126. package/dist/ir/pin-capability-validation.js +37 -0
  127. package/dist/ir/pin-mode-validation.d.ts +2 -2
  128. package/dist/ir/pin-mode-validation.js +49 -18
  129. package/dist/ir/program-analysis.d.ts +65 -0
  130. package/dist/ir/program-analysis.js +318 -2
  131. package/dist/ir/render-expr.js +11 -0
  132. package/dist/ir/timing-validation.d.ts +6 -1
  133. package/dist/ir/timing-validation.js +60 -13
  134. package/dist/ir/transformers/call-statement.js +105 -0
  135. package/dist/ir/transformers/expressions.js +62 -0
  136. package/dist/ir/transformers/hal-call-resolver.js +21 -0
  137. package/dist/ir/transformers/hal-emit-helpers.js +1 -1
  138. package/dist/ir/transformers/namespace-methods.js +17 -12
  139. package/dist/ir/transformers/ui-reactive.js +2 -2
  140. package/dist/ir/transformers/variables.js +92 -3
  141. package/dist/ir/type-resolution.js +18 -0
  142. package/dist/ir/ui-element-auto-wire.js +7 -5
  143. package/dist/ir/utils/map-statements.d.ts +4 -0
  144. package/dist/ir/utils/map-statements.js +79 -0
  145. package/dist/ir/validation-orchestrator.js +9 -2
  146. package/dist/ir/worker-analysis.d.ts +10 -0
  147. package/dist/ir/worker-analysis.js +261 -0
  148. package/dist/libdef/c-to-decl.d.ts +27 -0
  149. package/dist/libdef/c-to-decl.js +397 -0
  150. package/dist/libdef/component-decls.d.ts +2 -0
  151. package/dist/libdef/component-decls.js +6 -0
  152. package/dist/libdef/component-discovery.d.ts +43 -0
  153. package/dist/libdef/component-discovery.js +83 -0
  154. package/dist/libdef/cpp-to-decl.d.ts +9 -0
  155. package/dist/libdef/cpp-to-decl.js +72 -0
  156. package/dist/libdef/registry.js +5 -2
  157. package/dist/lint-cache.d.ts +59 -0
  158. package/dist/lint-cache.js +257 -0
  159. package/dist/orchestrator/graph-builder.js +14 -9
  160. package/dist/platform/coop-scheduler-runtime.d.ts +19 -0
  161. package/dist/platform/coop-scheduler-runtime.js +41 -0
  162. package/dist/platform/generic-strategy.d.ts +15 -3
  163. package/dist/platform/generic-strategy.js +49 -4
  164. package/dist/safety/safety-bridge.d.ts +11 -0
  165. package/dist/safety/safety-bridge.js +48 -0
  166. package/dist/safety/sidecar-bridge.d.ts +5 -0
  167. package/dist/safety/sidecar-bridge.js +22 -0
  168. package/dist/safety-hook.d.ts +79 -0
  169. package/dist/safety-hook.js +35 -0
  170. package/dist/testing.d.ts +7 -1
  171. package/dist/testing.js +8 -1
  172. package/dist/transpile.d.ts +3 -0
  173. package/dist/transpile.js +175 -41
  174. package/dist/types.d.ts +13 -2
  175. package/dist/ui-hook.d.ts +17 -3
  176. package/dist/utils/cli.js +78 -4
  177. package/dist/utils/fs.d.ts +13 -0
  178. package/dist/utils/fs.js +50 -0
  179. package/package.json +24 -5
  180. package/dist/api/shared/display-adapters/eink-mono.d.ts +0 -2
  181. package/dist/api/shared/display-adapters/eink-mono.js +0 -53
  182. package/dist/api/shared/display-adapters/ssd1309.d.ts +0 -2
  183. package/dist/api/shared/display-adapters/ssd1309.js +0 -136
  184. package/dist/api/shared/display-adapters/st7796.d.ts +0 -2
  185. package/dist/api/shared/display-adapters/st7796.js +0 -132
  186. package/dist/licenses.d.ts +0 -185
  187. package/dist/licenses.js +0 -963
@@ -10,7 +10,6 @@ export declare const BoardSpecSchema: z.ZodObject<{
10
10
  description: z.ZodOptional<z.ZodString>;
11
11
  clockSpeed: z.ZodNumber;
12
12
  fqbn: z.ZodString;
13
- platformioTarget: z.ZodString;
14
13
  arduinoDefine: z.ZodString;
15
14
  moduleFlash: z.ZodNullable<z.ZodNumber>;
16
15
  externalRam: z.ZodNullable<z.ZodNumber>;
@@ -262,11 +261,11 @@ export declare const BoardSpecSchema: z.ZodObject<{
262
261
  channels: z.ZodNumber;
263
262
  pins: z.ZodArray<z.ZodString, "many">;
264
263
  }, "strip", z.ZodTypeAny, {
265
- channels: number;
266
264
  pins: string[];
267
- }, {
268
265
  channels: number;
266
+ }, {
269
267
  pins: string[];
268
+ channels: number;
270
269
  }>>>;
271
270
  timers: z.ZodArray<z.ZodObject<{
272
271
  instance: z.ZodNumber;
@@ -276,12 +275,12 @@ export declare const BoardSpecSchema: z.ZodObject<{
276
275
  }, "strict", z.ZodTypeAny, {
277
276
  type: "general" | "high_speed" | "rtc" | "sys";
278
277
  instance: number;
279
- bits: 16 | 8 | 32 | 64;
278
+ bits: 8 | 16 | 32 | 64;
280
279
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
281
280
  }, {
282
281
  type: "general" | "high_speed" | "rtc" | "sys";
283
282
  instance: number;
284
- bits: 16 | 8 | 32 | 64;
283
+ bits: 8 | 16 | 32 | 64;
285
284
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
286
285
  }>, "many">;
287
286
  wifi: z.ZodObject<{
@@ -366,6 +365,32 @@ export declare const BoardSpecSchema: z.ZodObject<{
366
365
  }>;
367
366
  }, "strict", z.ZodTypeAny, {
368
367
  architecture: string;
368
+ mcuId: string;
369
+ mcuName: string;
370
+ boardId: string;
371
+ boardName: string;
372
+ vendor: string;
373
+ clockSpeed: number;
374
+ fqbn: string;
375
+ arduinoDefine: string;
376
+ moduleFlash: number | null;
377
+ externalRam: number | null;
378
+ gpioRange: [number, number];
379
+ excludedGpio: number[];
380
+ pins: {
381
+ gpio: number;
382
+ capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
383
+ functions?: {
384
+ type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
385
+ instance: number;
386
+ role: string;
387
+ }[] | undefined;
388
+ alt?: string[] | undefined;
389
+ warnings?: string[] | undefined;
390
+ unsafe?: boolean | undefined;
391
+ notes?: string | undefined;
392
+ onboardLed?: boolean | undefined;
393
+ }[];
369
394
  i2c: Record<string, {
370
395
  sda?: string | undefined;
371
396
  scl?: string | undefined;
@@ -414,39 +439,7 @@ export declare const BoardSpecSchema: z.ZodObject<{
414
439
  vid: string;
415
440
  pid: string;
416
441
  };
417
- wifi: {
418
- type: "wifi" | "wifi6";
419
- supportsStation: boolean;
420
- supportsAp: boolean;
421
- };
422
442
  unsafe: string[];
423
- mcuId: string;
424
- mcuName: string;
425
- boardId: string;
426
- boardName: string;
427
- vendor: string;
428
- clockSpeed: number;
429
- fqbn: string;
430
- platformioTarget: string;
431
- arduinoDefine: string;
432
- moduleFlash: number | null;
433
- externalRam: number | null;
434
- gpioRange: [number, number];
435
- excludedGpio: number[];
436
- pins: {
437
- gpio: number;
438
- capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
439
- functions?: {
440
- type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
441
- instance: number;
442
- role: string;
443
- }[] | undefined;
444
- alt?: string[] | undefined;
445
- warnings?: string[] | undefined;
446
- unsafe?: boolean | undefined;
447
- notes?: string | undefined;
448
- onboardLed?: boolean | undefined;
449
- }[];
450
443
  analog: string[];
451
444
  peripheralInstances: {
452
445
  i2c: {
@@ -468,7 +461,7 @@ export declare const BoardSpecSchema: z.ZodObject<{
468
461
  timers: {
469
462
  type: "general" | "high_speed" | "rtc" | "sys";
470
463
  instance: number;
471
- bits: 16 | 8 | 32 | 64;
464
+ bits: 8 | 16 | 32 | 64;
472
465
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
473
466
  }[];
474
467
  features: {
@@ -480,6 +473,11 @@ export declare const BoardSpecSchema: z.ZodObject<{
480
473
  hardwareRng: boolean;
481
474
  fpu: boolean;
482
475
  };
476
+ wifi: {
477
+ type: "wifi" | "wifi6";
478
+ supportsStation: boolean;
479
+ supportsAp: boolean;
480
+ };
483
481
  bluetooth: {
484
482
  type: "classic" | "ble" | "dual";
485
483
  version: string;
@@ -491,13 +489,39 @@ export declare const BoardSpecSchema: z.ZodObject<{
491
489
  externalRam?: number | undefined;
492
490
  rtcMemory?: number | undefined;
493
491
  };
492
+ description?: string | undefined;
494
493
  touch?: {
495
- channels: number;
496
494
  pins: string[];
495
+ channels: number;
497
496
  } | null | undefined;
498
- description?: string | undefined;
499
497
  }, {
500
498
  architecture: string;
499
+ mcuId: string;
500
+ mcuName: string;
501
+ boardId: string;
502
+ boardName: string;
503
+ vendor: string;
504
+ clockSpeed: number;
505
+ fqbn: string;
506
+ arduinoDefine: string;
507
+ moduleFlash: number | null;
508
+ externalRam: number | null;
509
+ gpioRange: [number, number];
510
+ excludedGpio: number[];
511
+ pins: {
512
+ gpio: number;
513
+ capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
514
+ functions?: {
515
+ type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
516
+ instance: number;
517
+ role: string;
518
+ }[] | undefined;
519
+ alt?: string[] | undefined;
520
+ warnings?: string[] | undefined;
521
+ unsafe?: boolean | undefined;
522
+ notes?: string | undefined;
523
+ onboardLed?: boolean | undefined;
524
+ }[];
501
525
  i2c: Record<string, {
502
526
  sda?: string | undefined;
503
527
  scl?: string | undefined;
@@ -546,39 +570,7 @@ export declare const BoardSpecSchema: z.ZodObject<{
546
570
  vid: string;
547
571
  pid: string;
548
572
  };
549
- wifi: {
550
- type: "wifi" | "wifi6";
551
- supportsStation: boolean;
552
- supportsAp: boolean;
553
- };
554
573
  unsafe: string[];
555
- mcuId: string;
556
- mcuName: string;
557
- boardId: string;
558
- boardName: string;
559
- vendor: string;
560
- clockSpeed: number;
561
- fqbn: string;
562
- platformioTarget: string;
563
- arduinoDefine: string;
564
- moduleFlash: number | null;
565
- externalRam: number | null;
566
- gpioRange: [number, number];
567
- excludedGpio: number[];
568
- pins: {
569
- gpio: number;
570
- capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
571
- functions?: {
572
- type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
573
- instance: number;
574
- role: string;
575
- }[] | undefined;
576
- alt?: string[] | undefined;
577
- warnings?: string[] | undefined;
578
- unsafe?: boolean | undefined;
579
- notes?: string | undefined;
580
- onboardLed?: boolean | undefined;
581
- }[];
582
574
  analog: string[];
583
575
  peripheralInstances: {
584
576
  i2c: {
@@ -600,7 +592,7 @@ export declare const BoardSpecSchema: z.ZodObject<{
600
592
  timers: {
601
593
  type: "general" | "high_speed" | "rtc" | "sys";
602
594
  instance: number;
603
- bits: 16 | 8 | 32 | 64;
595
+ bits: 8 | 16 | 32 | 64;
604
596
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
605
597
  }[];
606
598
  features: {
@@ -612,6 +604,11 @@ export declare const BoardSpecSchema: z.ZodObject<{
612
604
  hardwareRng: boolean;
613
605
  fpu: boolean;
614
606
  };
607
+ wifi: {
608
+ type: "wifi" | "wifi6";
609
+ supportsStation: boolean;
610
+ supportsAp: boolean;
611
+ };
615
612
  bluetooth: {
616
613
  type: "classic" | "ble" | "dual";
617
614
  version: string;
@@ -623,11 +620,11 @@ export declare const BoardSpecSchema: z.ZodObject<{
623
620
  externalRam?: number | undefined;
624
621
  rtcMemory?: number | undefined;
625
622
  };
623
+ description?: string | undefined;
626
624
  touch?: {
627
- channels: number;
628
625
  pins: string[];
626
+ channels: number;
629
627
  } | null | undefined;
630
- description?: string | undefined;
631
628
  }>;
632
629
  export type BoardSpec = z.infer<typeof BoardSpecSchema>;
633
630
  export declare function parseBoardSpec(jsoncText: string): BoardSpec;
@@ -111,7 +111,6 @@ export const BoardSpecSchema = z.object({
111
111
  // Build
112
112
  clockSpeed: z.number().int(),
113
113
  fqbn: z.string().min(1),
114
- platformioTarget: z.string().min(1),
115
114
  arduinoDefine: z.string().min(1),
116
115
  // Memory (module-level; silicon memory is derived)
117
116
  moduleFlash: z.number().int().nullable(),
@@ -6,10 +6,17 @@ export interface KnownTarget {
6
6
  isNative: boolean;
7
7
  architecture?: ArchitectureIdentifier;
8
8
  boardPackage?: string;
9
- frameworkPackage: string;
10
- framework: string;
9
+ /** Framework package + id. Optional on embedded targets: the scaffold wizard
10
+ * fills these in by discovering installed @typecad/framework-* packages, so
11
+ * KNOWN_TARGETS board entries do not hardcode a framework. Native targets
12
+ * set them directly. */
13
+ frameworkPackage?: string;
14
+ framework?: string;
11
15
  buildTarget?: string;
12
16
  mcu?: string;
17
+ /** Framework-specific config (becomes frameworkData in cuttlefish.config.ts).
18
+ * Carries framework-specific target/options data for the selected framework. */
19
+ frameworkData?: Record<string, unknown>;
13
20
  }
14
21
  export declare function registerKnownTarget(target: KnownTarget): void;
15
22
  export declare const KNOWN_TARGETS: ReadonlyArray<KnownTarget>;
@@ -17,8 +17,6 @@ const _knownTargets = [
17
17
  isNative: false,
18
18
  architecture: 'avr',
19
19
  boardPackage: '@typecad/board-arduino-uno',
20
- frameworkPackage: '@typecad/framework-arduino',
21
- framework: 'arduino',
22
20
  buildTarget: 'arduino:avr:uno',
23
21
  mcu: 'atmega328p',
24
22
  },
@@ -28,8 +26,6 @@ const _knownTargets = [
28
26
  isNative: false,
29
27
  architecture: 'esp32',
30
28
  boardPackage: '@typecad/board-esp32-devkit',
31
- frameworkPackage: '@typecad/framework-arduino',
32
- framework: 'arduino',
33
29
  buildTarget: 'esp32:esp32:esp32',
34
30
  mcu: 'esp32',
35
31
  },
@@ -39,8 +35,6 @@ const _knownTargets = [
39
35
  isNative: false,
40
36
  architecture: 'esp32s3',
41
37
  boardPackage: '@typecad/board-esp32s3',
42
- frameworkPackage: '@typecad/framework-arduino',
43
- framework: 'arduino',
44
38
  buildTarget: 'esp32:esp32:esp32s3',
45
39
  mcu: 'esp32s3',
46
40
  },
@@ -50,8 +44,6 @@ const _knownTargets = [
50
44
  isNative: false,
51
45
  architecture: 'esp32c3',
52
46
  boardPackage: '@typecad/board-esp32c3',
53
- frameworkPackage: '@typecad/framework-arduino',
54
- framework: 'arduino',
55
47
  buildTarget: 'esp32:esp32:esp32c3',
56
48
  mcu: 'esp32c3',
57
49
  },
@@ -61,8 +53,6 @@ const _knownTargets = [
61
53
  isNative: false,
62
54
  architecture: 'esp32c6',
63
55
  boardPackage: '@typecad/board-esp32c6',
64
- frameworkPackage: '@typecad/framework-arduino',
65
- framework: 'arduino',
66
56
  buildTarget: 'esp32:esp32:esp32c6',
67
57
  mcu: 'esp32c6',
68
58
  },
@@ -72,8 +62,6 @@ const _knownTargets = [
72
62
  isNative: false,
73
63
  architecture: 'rp2040',
74
64
  boardPackage: '@typecad/board-rp2040',
75
- frameworkPackage: '@typecad/framework-arduino',
76
- framework: 'arduino',
77
65
  buildTarget: 'rp2040:rp2040:rpipico',
78
66
  mcu: 'rp2040',
79
67
  },
@@ -83,8 +71,6 @@ const _knownTargets = [
83
71
  isNative: false,
84
72
  architecture: 'rp2350',
85
73
  boardPackage: '@typecad/board-rp2350',
86
- frameworkPackage: '@typecad/framework-arduino',
87
- framework: 'arduino',
88
74
  buildTarget: 'rp2040:rp2040:rpipico2',
89
75
  mcu: 'rp2350',
90
76
  },
@@ -13,6 +13,8 @@ export interface InitProjectOptions {
13
13
  baudRate?: number;
14
14
  includeSketch: boolean;
15
15
  toolchainType?: string;
16
+ /** Extra frameworkData fields (e.g. `{ target: 'esp32s3' }` for framework-esp32). */
17
+ frameworkData?: Record<string, unknown>;
16
18
  }
17
19
  export declare function generateProjectPackageJson(options: InitProjectOptions): string;
18
20
  export declare function generateProjectTsconfig(options: InitProjectOptions): string;
@@ -150,8 +150,12 @@ export default config;
150
150
  `;
151
151
  }
152
152
  const buildTarget = options.buildTarget;
153
- const resolvedToolchain = options.toolchainType ?? 'arduino-cli';
154
- const buildTargetLine = buildTarget ? `\n // Framework data\n frameworkData: {\n buildTarget: '${buildTarget}',\n },` : '';
153
+ const resolvedToolchain = options.toolchainType
154
+ ?? 'arduino-cli';
155
+ let frameworkDataBlock = '';
156
+ if (buildTarget) {
157
+ frameworkDataBlock = `\n // Framework data\n frameworkData: {\n buildTarget: '${buildTarget}',\n },`;
158
+ }
155
159
  const mcuLine = options.mcu
156
160
  ? `\n // MCU package — provides silicon-level pin definitions\n mcu: '${options.mcu.startsWith('@') ? options.mcu : `@typecad/mcu-${options.mcu}`}',\n`
157
161
  : '';
@@ -181,7 +185,7 @@ const config: CuttlefishConfig = {
181
185
  target: '${options.architecture}',${mcuLine}${boardLine}
182
186
 
183
187
  // Framework package — controls code generation strategy
184
- framework: '${options.frameworkPackage}',${buildTargetLine}
188
+ framework: '${options.frameworkPackage}',${frameworkDataBlock}
185
189
 
186
190
  // Output / build options
187
191
  output: {
@@ -211,6 +215,22 @@ declare global {
211
215
  type Owned<T = unknown> = T;
212
216
  type Shared<T = unknown> = T;
213
217
  type Mutable<T = unknown> = T;
218
+ // SafeVariable: SEU-resistant storage. The transpiler lowers SafeVariable<number>
219
+ // to a C++ template with inverted-redundancy storage. Declared as an interface
220
+ // (not a type alias) so the TS type checker recognizes method calls.
221
+ // Arithmetic T only (integral or floating-point); string is rejected by a
222
+ // static_assert in the emitted C++ template.
223
+ interface SafeVariable<T = number> { set(value: T): void; get(): T; valid(): boolean; hasFault(): boolean; }
224
+ // SafeInt: chainable bounds-checked signed-integer arithmetic. The transpiler
225
+ // lowers SafeInt<number> to SafeInt<int32_t> (a C++ template with sticky-fault
226
+ // overflow detection). Signed integer T only — unsigned/bool/float/string are
227
+ // rejected by a static_assert in the emitted C++ template.
228
+ interface SafeInt<T = number> {
229
+ add(delta: T): SafeInt<T>; sub(delta: T): SafeInt<T>;
230
+ mul(factor: T): SafeInt<T>; divide(d: T): SafeInt<T>; mod(d: T): SafeInt<T>;
231
+ negate(): SafeInt<T>; absValue(): SafeInt<T>;
232
+ get(): T; hasFault(): boolean; valid(): boolean; reset(newValue: T): void;
233
+ }
214
234
 
215
235
  type uint8_t = number;
216
236
  type int8_t = number;
@@ -236,6 +256,20 @@ declare global {
236
256
  error(...args: unknown[]): void;
237
257
  }
238
258
  const console: Console;
259
+
260
+ // Convenience helper for volatile variables in TypeCAD programs.
261
+ // The transpiler detects calls to volatile() and emits the C++ volatile qualifier.
262
+ declare function volatile<T>(value: T): T;
263
+
264
+ // JS-style timers (declared here so a project does not need "dom" in tsconfig
265
+ // lib to type setInterval/setTimeout). The transpiler rewrites these to
266
+ // __tc_setInterval/__tc_setTimeout and emits the timer_methods polyfill when
267
+ // used. Note: Timing.setInterval/setTimeout (from @typecad/hal) is the
268
+ // preferred single entry point and is typed via the @typecad/board import.
269
+ declare function setInterval(handler: () => void, timeout?: number): number;
270
+ declare function setTimeout(handler: () => void, timeout?: number): number;
271
+ declare function clearInterval(id: number): void;
272
+ declare function clearTimeout(id: number): void;
239
273
  }
240
274
 
241
275
  export {};
@@ -254,6 +288,22 @@ declare global {
254
288
  type Owned<T = unknown> = T;
255
289
  type Shared<T = unknown> = T;
256
290
  type Mutable<T = unknown> = T;
291
+ // SafeVariable: SEU-resistant storage. The transpiler lowers SafeVariable<number>
292
+ // to a C++ template with inverted-redundancy storage. Declared as an interface
293
+ // (not a type alias) so the TS type checker recognizes method calls.
294
+ // Arithmetic T only (integral or floating-point); string is rejected by a
295
+ // static_assert in the emitted C++ template.
296
+ interface SafeVariable<T = number> { set(value: T): void; get(): T; valid(): boolean; hasFault(): boolean; }
297
+ // SafeInt: chainable bounds-checked signed-integer arithmetic. The transpiler
298
+ // lowers SafeInt<number> to SafeInt<int32_t> (a C++ template with sticky-fault
299
+ // overflow detection). Signed integer T only — unsigned/bool/float/string are
300
+ // rejected by a static_assert in the emitted C++ template.
301
+ interface SafeInt<T = number> {
302
+ add(delta: T): SafeInt<T>; sub(delta: T): SafeInt<T>;
303
+ mul(factor: T): SafeInt<T>; divide(d: T): SafeInt<T>; mod(d: T): SafeInt<T>;
304
+ negate(): SafeInt<T>; absValue(): SafeInt<T>;
305
+ get(): T; hasFault(): boolean; valid(): boolean; reset(newValue: T): void;
306
+ }
257
307
 
258
308
  type uint8_t = number;
259
309
  type int8_t = number;
@@ -279,6 +329,20 @@ declare global {
279
329
  error(...args: unknown[]): void;
280
330
  }
281
331
  const console: Console;
332
+
333
+ // Convenience helper for volatile variables in TypeCAD programs.
334
+ // The transpiler detects calls to volatile() and emits the C++ volatile qualifier.
335
+ declare function volatile<T>(value: T): T;
336
+
337
+ // JS-style timers (declared here so a project does not need "dom" in tsconfig
338
+ // lib to type setInterval/setTimeout). The transpiler rewrites these to
339
+ // __tc_setInterval/__tc_setTimeout and emits the timer_methods polyfill when
340
+ // used. Note: Timing.setInterval/setTimeout (from @typecad/hal) is the
341
+ // preferred single entry point and is typed via the @typecad/board import.
342
+ declare function setInterval(handler: () => void, timeout?: number): number;
343
+ declare function setTimeout(handler: () => void, timeout?: number): number;
344
+ declare function clearInterval(id: number): void;
345
+ declare function clearTimeout(id: number): void;
282
346
  }
283
347
 
284
348
  declare module '@typecad/board' {
@@ -508,11 +572,13 @@ export default [
508
572
  files: ["src/**/*.ts"],
509
573
  languageOptions: {
510
574
  parser: tsparser,
511
- parserOptions: {
512
- // Type-aware parsing so @typescript-eslint/no-explicit-any resolves
513
- // imported bindings to their real types instead of defaulting to any.
514
- project: "./tsconfig.json",
515
- },
575
+ // NOTE: do NOT set parserOptions.project here. None of the rules below
576
+ // (no-restricted-syntax, the cuttlefish/* AST rules, no-explicit-any,
577
+ // no-eval, ...) consume type information, so enabling type-aware linting
578
+ // only forces ESLint to build a full TS type-program per file — ~3.4s of
579
+ // pure overhead on small projects with zero change to what is detected.
580
+ // If a future rule needs types, scope project to that rule only via
581
+ // parserOptions on a dedicated config block, not globally.
516
582
  },
517
583
  plugins: {
518
584
  "@typescript-eslint": tseslint,
@@ -84,15 +84,29 @@ export async function runInitWizard(partialOptions) {
84
84
  targetId = await promptSelect(rl, "Target", targetOptions);
85
85
  }
86
86
  const target = KNOWN_TARGETS.find((t) => t.id === targetId);
87
- // 3. Framework (only for embedded targets)
87
+ // 3. Framework (only for embedded targets). Discover installed
88
+ // @typecad/framework-* packages rather than hardcoding a single option, so
89
+ // the wizard reflects whichever frameworks the user has installed.
88
90
  let framework = target.framework;
89
91
  let frameworkPackage = target.frameworkPackage;
90
92
  if (!target.isNative) {
91
- const frameworkOptions = [
92
- { label: "Arduino (digitalWrite, Wire, SPI)", value: 'arduino', pkg: '@typecad/framework-arduino' },
93
+ // Candidate framework families and their user-facing labels. The wizard
94
+ // shows whichever are installed (resolvable) in the user's project.
95
+ const frameworkCandidates = [
96
+ { value: 'arduino', label: 'Arduino (digitalWrite, Wire, SPI)' },
97
+ { value: 'zephyr', label: 'Zephyr RTOS' },
98
+ { value: 'esp-idf', label: 'ESP-IDF' },
93
99
  ];
94
- if (target.architecture === 'avr') {
95
- frameworkOptions.push({ label: "Bare-metal AVR (PORTB, etc.)", value: 'avr', pkg: '@typecad/framework-avr' });
100
+ const frameworkOptions = [];
101
+ for (const candidate of frameworkCandidates) {
102
+ const pkg = `@typecad/framework-${candidate.value}`;
103
+ try {
104
+ require.resolve(`${pkg}/package.json`, { paths: [process.cwd()] });
105
+ frameworkOptions.push({ label: candidate.label, value: candidate.value, pkg });
106
+ }
107
+ catch {
108
+ // framework not installed; skip
109
+ }
96
110
  }
97
111
  if (partialOptions?.framework) {
98
112
  const match = frameworkOptions.find(f => f.value === partialOptions.framework);
@@ -100,6 +114,13 @@ export async function runInitWizard(partialOptions) {
100
114
  frameworkPackage = match?.pkg ?? `@typecad/framework-${partialOptions.framework}`;
101
115
  console.log(`${chalk.cyan("?")} Framework: ${chalk.white(framework)}`);
102
116
  }
117
+ else if (frameworkOptions.length === 0) {
118
+ // No framework installed and none requested via --framework: abort
119
+ // rather than produce a broken scaffold with an empty framework field
120
+ // (which would generate invalid package.json + cuttlefish.config.ts).
121
+ throw new Error("No @typecad/framework-* packages found in this project. " +
122
+ "Install one before scaffolding, e.g.: npm i @typecad/framework-arduino");
123
+ }
103
124
  else if (frameworkOptions.length === 1) {
104
125
  framework = frameworkOptions[0].value;
105
126
  frameworkPackage = frameworkOptions[0].pkg;
@@ -148,12 +169,15 @@ export async function runInitWizard(partialOptions) {
148
169
  isNative: target.isNative,
149
170
  architecture: target.architecture,
150
171
  boardPackage: target.boardPackage,
151
- frameworkPackage,
152
- framework,
172
+ frameworkPackage: frameworkPackage ?? '',
173
+ framework: framework ?? '',
153
174
  buildTarget: target.buildTarget,
154
175
  mcu: target.mcu,
155
176
  baudRate,
156
177
  includeSketch,
178
+ ...(target.frameworkData
179
+ ? { frameworkData: target.frameworkData }
180
+ : {}),
157
181
  };
158
182
  }
159
183
  catch (err) {