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

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 (315) hide show
  1. package/README.md +82 -79
  2. package/assets/editor-extensions/typecad-debug/README.md +25 -26
  3. package/dist/api/config.d.ts +22 -26
  4. package/dist/api/schema/types.d.ts +20 -3
  5. package/dist/api/shared/async-runtime-static.d.ts +1 -1
  6. package/dist/api/shared/async-runtime-static.js +5 -5
  7. package/dist/api/shared/async-types.d.ts +3 -2
  8. package/dist/api/shared/board-catalog.d.ts +2 -0
  9. package/dist/api/shared/board-catalog.js +6 -0
  10. package/dist/api/shared/board-resolver.d.ts +4 -7
  11. package/dist/api/shared/board-resolver.js +2 -1
  12. package/dist/api/shared/coop-scheduler.d.ts +1 -1
  13. package/dist/api/shared/coop-scheduler.js +1 -1
  14. package/dist/api/shared/cpp-type-ir.d.ts +1 -1
  15. package/dist/api/shared/cpp-type-ir.js +1 -1
  16. package/dist/api/shared/display-profile.d.ts +1 -1
  17. package/dist/api/shared/display-profile.js +3 -5
  18. package/dist/api/shared/framework-manifest-registry.d.ts +1 -1
  19. package/dist/api/shared/framework-manifest-registry.js +0 -1
  20. package/dist/api/shared/framework-manifest.d.ts +7 -6
  21. package/dist/api/shared/framework-manifest.js +6 -11
  22. package/dist/api/shared/hal-op-ir.d.ts +294 -685
  23. package/dist/api/shared/hal-op-ir.js +31 -65
  24. package/dist/api/shared/index.d.ts +0 -4
  25. package/dist/api/shared/index.js +1 -7
  26. package/dist/api/shared/ir-core.d.ts +6 -0
  27. package/dist/api/shared/ir-declarations.d.ts +4 -0
  28. package/dist/api/shared/ir.d.ts +1 -3
  29. package/dist/api/shared/platform-strategy.d.ts +14 -37
  30. package/dist/api/shared/polyfill-helper-registry.js +0 -5
  31. package/dist/api/shared/polyfill-types.js +0 -27
  32. package/dist/api/shared/promise-runtime.js +3 -3
  33. package/dist/api/shared/spdx-licenses.d.ts +12 -10
  34. package/dist/api/shared/spdx-licenses.js +1 -1
  35. package/dist/api/shared/toolchain-types.d.ts +1 -1
  36. package/dist/api/shared/toolchain-types.js +3 -3
  37. package/dist/api/shared/types.d.ts +0 -3
  38. package/dist/api/shared/validate-framework-manifest.js +13 -33
  39. package/dist/board-catalog/dts-reader.d.ts +220 -0
  40. package/dist/board-catalog/dts-reader.js +1052 -0
  41. package/dist/board-catalog/index.d.ts +11 -0
  42. package/dist/board-catalog/index.js +12 -0
  43. package/dist/board-catalog/pinconfig.d.ts +48 -0
  44. package/dist/board-catalog/pinconfig.js +263 -0
  45. package/dist/board-catalog/sdk.d.ts +82 -0
  46. package/dist/board-catalog/sdk.js +180 -0
  47. package/dist/board-catalog/store.d.ts +196 -0
  48. package/dist/board-catalog/store.js +363 -0
  49. package/dist/board-catalog/types.d.ts +233 -0
  50. package/dist/board-catalog/types.js +7 -0
  51. package/dist/board-catalog/walker.d.ts +112 -0
  52. package/dist/board-catalog/walker.js +1101 -0
  53. package/dist/cli-utils.d.ts +2 -2
  54. package/dist/cli-utils.js +5 -5
  55. package/dist/cli.js +214 -242
  56. package/dist/config-loader.d.ts +14 -19
  57. package/dist/config-loader.js +240 -78
  58. package/dist/config-schema.d.ts +3 -5
  59. package/dist/config-schema.js +8 -8
  60. package/dist/contract/board-generator.d.ts +4 -4
  61. package/dist/contract/board-generator.js +16 -5
  62. package/dist/contract/contract-parser.d.ts +27 -0
  63. package/dist/contract/contract-parser.js +76 -0
  64. package/dist/contract/index.d.ts +1 -1
  65. package/dist/contract/index.js +70 -21
  66. package/dist/create/active-board-catalog.d.ts +9 -0
  67. package/dist/create/active-board-catalog.js +94 -0
  68. package/dist/create/board-catalog.generated.d.ts +96 -0
  69. package/dist/create/board-catalog.generated.js +128737 -0
  70. package/dist/create/board-search.d.ts +23 -0
  71. package/dist/create/board-search.js +88 -0
  72. package/dist/create/editor-integration.d.ts +4 -2
  73. package/dist/create/editor-integration.js +41 -2
  74. package/dist/create/framework-catalog.d.ts +41 -9
  75. package/dist/create/framework-catalog.js +48 -57
  76. package/dist/create/index.d.ts +5 -11
  77. package/dist/create/index.js +3 -8
  78. package/dist/create/mcu-target.d.ts +39 -0
  79. package/dist/create/mcu-target.js +80 -0
  80. package/dist/create/pack-targets.d.ts +19 -0
  81. package/dist/create/pack-targets.js +56 -0
  82. package/dist/create/scaffold.d.ts +4 -7
  83. package/dist/create/scaffold.js +19 -109
  84. package/dist/create/templates.d.ts +27 -5
  85. package/dist/create/templates.js +120 -116
  86. package/dist/create/wizard.d.ts +12 -1
  87. package/dist/create/wizard.js +163 -38
  88. package/dist/debug/preprocessor.d.ts +5 -0
  89. package/dist/debug/preprocessor.js +31 -7
  90. package/dist/diagnostics/diagnostics-report.d.ts +1 -1
  91. package/dist/diagnostics/diagnostics-report.js +3 -11
  92. package/dist/diagnostics/json-schema.d.ts +1 -1
  93. package/dist/diagnostics/md-writer.js +2 -2
  94. package/dist/diagnostics/mermaid-builder.d.ts +1 -1
  95. package/dist/diagnostics/mermaid-builder.js +1 -1
  96. package/dist/emit/cpp-emitter.js +4 -1
  97. package/dist/emit/emitters/class-emitter.js +32 -4
  98. package/dist/emit/emitters/emitter-context.d.ts +11 -0
  99. package/dist/emit/emitters/entrypoint-synthesizer.js +1 -1
  100. package/dist/emit/emitters/function-emitter-impl.js +33 -17
  101. package/dist/emit/emitters/output-finalizer.d.ts +7 -0
  102. package/dist/emit/emitters/output-finalizer.js +31 -23
  103. package/dist/emit/emitters/setup.js +125 -63
  104. package/dist/emit/emitters/top-level-prep.js +1 -1
  105. package/dist/emit/emitters/type-decl-emitter.js +13 -8
  106. package/dist/emit/emitters/ui-emitter.js +1 -1
  107. package/dist/emit/expression-renderer.d.ts +3 -3
  108. package/dist/emit/expression-renderer.js +17 -7
  109. package/dist/emit/route-hal-op.js +17 -48
  110. package/dist/emit/snprintf-helpers.d.ts +1 -3
  111. package/dist/emit/snprintf-helpers.js +1 -39
  112. package/dist/emit/statement-renderer.d.ts +0 -4
  113. package/dist/emit/statement-renderer.js +54 -45
  114. package/dist/emit/utils/async-state-machine.d.ts +16 -9
  115. package/dist/emit/utils/async-state-machine.js +56 -54
  116. package/dist/emit/utils/comment-helpers.d.ts +0 -8
  117. package/dist/emit/utils/comment-helpers.js +1 -1
  118. package/dist/emit/utils/cpp-helpers.d.ts +2 -2
  119. package/dist/emit/utils/cpp-helpers.js +2 -2
  120. package/dist/emit/utils/hal-op-cpp-type.js +4 -6
  121. package/dist/emit/utils/index.d.ts +3 -3
  122. package/dist/emit/utils/index.js +3 -3
  123. package/dist/emit/utils/type-inference.d.ts +1 -29
  124. package/dist/emit/utils/type-inference.js +0 -75
  125. package/dist/framework-package.d.ts +3 -0
  126. package/dist/framework-package.js +23 -6
  127. package/dist/framework-registry.d.ts +5 -5
  128. package/dist/frameworks/native/graphics/terminal-preview.d.ts +5 -0
  129. package/dist/frameworks/native/graphics/terminal-preview.js +33 -0
  130. package/dist/frameworks/native/index.d.ts +3 -0
  131. package/dist/frameworks/native/index.js +15 -0
  132. package/dist/frameworks/native/native-compile.d.ts +17 -0
  133. package/dist/frameworks/native/native-compile.js +170 -0
  134. package/dist/frameworks/native/native-config.d.ts +41 -0
  135. package/dist/frameworks/native/native-config.js +7 -0
  136. package/dist/frameworks/native/strategy.d.ts +97 -0
  137. package/dist/frameworks/native/strategy.js +664 -0
  138. package/dist/ir/board-resolver.d.ts +18 -23
  139. package/dist/ir/board-resolver.js +43 -401
  140. package/dist/ir/build-ir-state.d.ts +3 -0
  141. package/dist/ir/build-ir-state.js +42 -0
  142. package/dist/ir/build-ir.d.ts +1 -1
  143. package/dist/ir/build-ir.js +40 -42
  144. package/dist/ir/declaration-builders.js +1 -0
  145. package/dist/ir/expression-to-ir.js +17 -10
  146. package/dist/ir/hal/hal-emitter.d.ts +0 -2
  147. package/dist/ir/hal/hal-emitter.js +92 -41
  148. package/dist/ir/hal/hal-parser.d.ts +5 -5
  149. package/dist/ir/hal/hal-parser.js +128 -36
  150. package/dist/ir/hal/hal-plugins.d.ts +0 -1
  151. package/dist/ir/hal/hal-plugins.js +425 -716
  152. package/dist/ir/heap-analysis.js +2 -41
  153. package/dist/ir/identifier-collector.js +32 -20
  154. package/dist/ir/network-validation.js +7 -11
  155. package/dist/ir/ownership-analysis.js +75 -13
  156. package/dist/ir/peripheral-usage.d.ts +8 -2
  157. package/dist/ir/peripheral-usage.js +78 -149
  158. package/dist/ir/peripheral-validation.js +23 -3
  159. package/dist/ir/pin-capability-validation.d.ts +12 -0
  160. package/dist/ir/pin-capability-validation.js +61 -97
  161. package/dist/ir/pin-mode-validation.js +5 -5
  162. package/dist/ir/program-analysis.d.ts +8 -15
  163. package/dist/ir/program-analysis.js +140 -323
  164. package/dist/ir/pulldown-validation.js +11 -4
  165. package/dist/ir/resource-analysis.js +15 -3
  166. package/dist/ir/statement-to-ir.js +0 -6
  167. package/dist/ir/timing-validation.js +1 -1
  168. package/dist/ir/transformers/array-methods.js +11 -5
  169. package/dist/ir/transformers/call-statement.js +20 -87
  170. package/dist/ir/transformers/callback-context-registry.d.ts +1 -1
  171. package/dist/ir/transformers/callback-context-registry.js +8 -16
  172. package/dist/ir/transformers/control-flow.js +0 -13
  173. package/dist/ir/transformers/expressions.js +10 -9
  174. package/dist/ir/transformers/hal-call-resolver.d.ts +2 -2
  175. package/dist/ir/transformers/hal-call-resolver.js +24 -10
  176. package/dist/ir/transformers/hal-emit-helpers.d.ts +2 -2
  177. package/dist/ir/transformers/hal-emit-helpers.js +2 -2
  178. package/dist/ir/transformers/namespace-methods.js +1 -1
  179. package/dist/ir/transformers/ui-callback-lowering.d.ts +0 -2
  180. package/dist/ir/transformers/ui-callback-lowering.js +0 -24
  181. package/dist/ir/transformers/variables.js +338 -42
  182. package/dist/ir/try-catch-validation.js +4 -3
  183. package/dist/ir/type-resolution.js +15 -4
  184. package/dist/ir/validation-orchestrator.js +0 -9
  185. package/dist/libdef/cpp-to-decl.d.ts +0 -9
  186. package/dist/libdef/cpp-to-decl.js +0 -72
  187. package/dist/libdef/registry.d.ts +0 -1
  188. package/dist/libdef/registry.js +1 -24
  189. package/dist/library/init.d.ts +1 -1
  190. package/dist/library/init.js +137 -137
  191. package/dist/library-packages.d.ts +1 -1
  192. package/dist/library-packages.js +1 -1
  193. package/dist/mapping/peripheral-names.js +9 -4
  194. package/dist/mapping/source-map.d.ts +3 -4
  195. package/dist/mapping/source-map.js +12 -18
  196. package/dist/orchestrator/graph-builder.d.ts +3 -3
  197. package/dist/orchestrator/graph-builder.js +13 -12
  198. package/dist/orchestrator/type-checker.d.ts +3 -3
  199. package/dist/orchestrator/type-checker.js +3 -3
  200. package/dist/platform/async-runtime.js +1 -1
  201. package/dist/platform/coop-scheduler-runtime.js +2 -2
  202. package/dist/platform/generic-debug-codegen.d.ts +36 -0
  203. package/dist/platform/generic-debug-codegen.js +185 -0
  204. package/dist/platform/generic-strategy.d.ts +3 -4
  205. package/dist/platform/generic-strategy.js +5 -80
  206. package/dist/platform/index.js +1 -1
  207. package/dist/platform/registry.d.ts +2 -2
  208. package/dist/platform/registry.js +2 -2
  209. package/dist/safety/asil-decorators.d.ts +32 -0
  210. package/dist/safety/asil-decorators.js +32 -0
  211. package/dist/safety/authoring.d.ts +85 -0
  212. package/dist/safety/authoring.js +61 -0
  213. package/dist/safety/engine.d.ts +3 -0
  214. package/dist/safety/engine.js +83 -0
  215. package/dist/safety/hal/ops.d.ts +48 -0
  216. package/dist/safety/hal/ops.js +46 -0
  217. package/dist/safety/iso26262/analyze.d.ts +13 -0
  218. package/dist/safety/iso26262/analyze.js +29 -0
  219. package/dist/safety/iso26262/asil.d.ts +10 -0
  220. package/dist/safety/iso26262/asil.js +22 -0
  221. package/dist/safety/iso26262/collect.d.ts +14 -0
  222. package/dist/safety/iso26262/collect.js +137 -0
  223. package/dist/safety/iso26262/goto-checker.d.ts +10 -0
  224. package/dist/safety/iso26262/goto-checker.js +72 -0
  225. package/dist/safety/iso26262/heap-checker.d.ts +7 -0
  226. package/dist/safety/iso26262/heap-checker.js +57 -0
  227. package/dist/safety/iso26262/init-checker.d.ts +13 -0
  228. package/dist/safety/iso26262/init-checker.js +127 -0
  229. package/dist/safety/iso26262/loop-checker.d.ts +7 -0
  230. package/dist/safety/iso26262/loop-checker.js +86 -0
  231. package/dist/safety/iso26262/recursion-checker.d.ts +9 -0
  232. package/dist/safety/iso26262/recursion-checker.js +134 -0
  233. package/dist/safety/iso26262/sidecar-writer.d.ts +25 -0
  234. package/dist/safety/iso26262/sidecar-writer.js +13 -0
  235. package/dist/safety/passes/pinMode-intercept.d.ts +3 -0
  236. package/dist/safety/passes/pinMode-intercept.js +60 -0
  237. package/dist/safety/runtime/mode-table.d.ts +5 -0
  238. package/dist/safety/runtime/mode-table.js +55 -0
  239. package/dist/safety/runtime/polyfills.d.ts +6 -0
  240. package/dist/safety/runtime/polyfills.js +12 -0
  241. package/dist/safety/runtime/result-struct.d.ts +11 -0
  242. package/dist/safety/runtime/result-struct.js +98 -0
  243. package/dist/safety/runtime/safe-int.d.ts +33 -0
  244. package/dist/safety/runtime/safe-int.js +170 -0
  245. package/dist/safety/runtime/safe-traits.d.ts +4 -0
  246. package/dist/safety/runtime/safe-traits.js +95 -0
  247. package/dist/safety/runtime/safe-variable.d.ts +39 -0
  248. package/dist/safety/runtime/safe-variable.js +226 -0
  249. package/dist/safety/runtime/vote.d.ts +8 -0
  250. package/dist/safety/runtime/vote.js +92 -0
  251. package/dist/safety/runtime/write-verify.d.ts +8 -0
  252. package/dist/safety/runtime/write-verify.js +71 -0
  253. package/dist/safety/safe-int-types.d.ts +45 -0
  254. package/dist/safety/safe-int-types.js +25 -0
  255. package/dist/safety/safe-variable-types.d.ts +29 -0
  256. package/dist/safety/safe-variable-types.js +19 -0
  257. package/dist/safety/safety-bridge.d.ts +5 -6
  258. package/dist/safety/safety-bridge.js +15 -28
  259. package/dist/safety/sidecar-bridge.d.ts +1 -3
  260. package/dist/safety/sidecar-bridge.js +3 -20
  261. package/dist/safety/specifiers.d.ts +6 -0
  262. package/dist/safety/specifiers.js +14 -0
  263. package/dist/safety-hook.d.ts +8 -7
  264. package/dist/safety-hook.js +12 -13
  265. package/dist/testing.d.ts +4 -5
  266. package/dist/testing.js +5 -5
  267. package/dist/transpile/resolution.d.ts +1 -1
  268. package/dist/transpile/resolution.js +18 -9
  269. package/dist/transpile/test-pins.d.ts +18 -0
  270. package/dist/transpile/test-pins.js +142 -0
  271. package/dist/transpile.d.ts +1 -2
  272. package/dist/transpile.js +36 -30
  273. package/dist/types.d.ts +26 -26
  274. package/dist/ui-hook.d.ts +1 -1
  275. package/dist/utils/cli.d.ts +2 -2
  276. package/dist/utils/cli.js +92 -154
  277. package/dist/utils/fs.d.ts +3 -4
  278. package/dist/utils/fs.js +4 -5
  279. package/dist/utils/strings.d.ts +0 -1
  280. package/dist/utils/strings.js +0 -8
  281. package/dist/utils/ui.d.ts +5 -2
  282. package/dist/utils/ui.js +13 -3
  283. package/package.json +158 -157
  284. package/dist/add-preset.d.ts +0 -4
  285. package/dist/add-preset.js +0 -74
  286. package/dist/api/shared/async-symbol-detector.d.ts +0 -11
  287. package/dist/api/shared/async-symbol-detector.js +0 -140
  288. package/dist/api/shared/native-display-op-resolver.d.ts +0 -10
  289. package/dist/api/shared/native-display-op-resolver.js +0 -64
  290. package/dist/create/board-checklist.d.ts +0 -2
  291. package/dist/create/board-checklist.js +0 -52
  292. package/dist/create/board-codegen.d.ts +0 -9
  293. package/dist/create/board-codegen.js +0 -238
  294. package/dist/create/board-generators.d.ts +0 -12
  295. package/dist/create/board-generators.js +0 -651
  296. package/dist/create/board-spec.d.ts +0 -181
  297. package/dist/create/board-spec.js +0 -214
  298. package/dist/install/framework-catalog.d.ts +0 -53
  299. package/dist/install/framework-catalog.js +0 -107
  300. package/dist/install/handle-install.d.ts +0 -35
  301. package/dist/install/handle-install.js +0 -177
  302. package/dist/install/index.d.ts +0 -4
  303. package/dist/install/index.js +0 -3
  304. package/dist/ir/pin-state-tracking.d.ts +0 -58
  305. package/dist/ir/pin-state-tracking.js +0 -182
  306. package/dist/ir/pwm-timer-sharing.d.ts +0 -4
  307. package/dist/ir/pwm-timer-sharing.js +0 -94
  308. package/dist/ir/timer0-pwm-timing-conflict.d.ts +0 -4
  309. package/dist/ir/timer0-pwm-timing-conflict.js +0 -72
  310. package/dist/libdef/component-decls.d.ts +0 -2
  311. package/dist/libdef/component-decls.js +0 -6
  312. package/dist/libdef/component-discovery.d.ts +0 -43
  313. package/dist/libdef/component-discovery.js +0 -83
  314. package/dist/theme-tokens.d.ts +0 -22
  315. package/dist/theme-tokens.js +0 -172
@@ -1,181 +0,0 @@
1
- import { z } from 'zod';
2
- export declare function stripJsonc(text: string): string;
3
- export declare const BoardSpecSchema: z.ZodObject<{
4
- architecture: z.ZodString;
5
- mcuId: z.ZodString;
6
- mcuName: z.ZodString;
7
- boardId: z.ZodString;
8
- boardName: z.ZodString;
9
- vendor: z.ZodString;
10
- description: z.ZodOptional<z.ZodString>;
11
- clockSpeed: z.ZodNumber;
12
- fqbn: z.ZodString;
13
- arduinoDefine: z.ZodString;
14
- moduleFlash: z.ZodNullable<z.ZodNumber>;
15
- externalRam: z.ZodNullable<z.ZodNumber>;
16
- gpioRange: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
17
- excludedGpio: z.ZodArray<z.ZodNumber>;
18
- pins: z.ZodArray<z.ZodObject<{
19
- gpio: z.ZodNumber;
20
- capabilities: z.ZodEnum<{
21
- FULL_GPIO: "FULL_GPIO";
22
- FULL_GPIO_ANALOG: "FULL_GPIO_ANALOG";
23
- FULL_GPIO_TOUCH: "FULL_GPIO_TOUCH";
24
- FULL_GPIO_ANALOG_TOUCH: "FULL_GPIO_ANALOG_TOUCH";
25
- FULL_GPIO_DAC: "FULL_GPIO_DAC";
26
- INPUT_ONLY: "INPUT_ONLY";
27
- }>;
28
- functions: z.ZodOptional<z.ZodArray<z.ZodObject<{
29
- type: z.ZodEnum<{
30
- i2c: "i2c";
31
- spi: "spi";
32
- uart: "uart";
33
- adc: "adc";
34
- dac: "dac";
35
- pwm: "pwm";
36
- touch: "touch";
37
- usb: "usb";
38
- }>;
39
- instance: z.ZodNumber;
40
- role: z.ZodString;
41
- }, z.core.$strict>>>;
42
- alt: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
- warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
44
- unsafe: z.ZodOptional<z.ZodBoolean>;
45
- notes: z.ZodOptional<z.ZodString>;
46
- onboardLed: z.ZodOptional<z.ZodBoolean>;
47
- }, z.core.$strict>>;
48
- unsafe: z.ZodArray<z.ZodString>;
49
- analog: z.ZodArray<z.ZodString>;
50
- i2c: z.ZodRecord<z.ZodString, z.ZodObject<{
51
- sda: z.ZodOptional<z.ZodString>;
52
- scl: z.ZodOptional<z.ZodString>;
53
- mosi: z.ZodOptional<z.ZodString>;
54
- miso: z.ZodOptional<z.ZodString>;
55
- sck: z.ZodOptional<z.ZodString>;
56
- cs: z.ZodOptional<z.ZodString>;
57
- tx: z.ZodOptional<z.ZodString>;
58
- rx: z.ZodOptional<z.ZodString>;
59
- }, z.core.$strict>>;
60
- spi: z.ZodRecord<z.ZodString, z.ZodObject<{
61
- sda: z.ZodOptional<z.ZodString>;
62
- scl: z.ZodOptional<z.ZodString>;
63
- mosi: z.ZodOptional<z.ZodString>;
64
- miso: z.ZodOptional<z.ZodString>;
65
- sck: z.ZodOptional<z.ZodString>;
66
- cs: z.ZodOptional<z.ZodString>;
67
- tx: z.ZodOptional<z.ZodString>;
68
- rx: z.ZodOptional<z.ZodString>;
69
- }, z.core.$strict>>;
70
- uart: z.ZodRecord<z.ZodString, z.ZodObject<{
71
- sda: z.ZodOptional<z.ZodString>;
72
- scl: z.ZodOptional<z.ZodString>;
73
- mosi: z.ZodOptional<z.ZodString>;
74
- miso: z.ZodOptional<z.ZodString>;
75
- sck: z.ZodOptional<z.ZodString>;
76
- cs: z.ZodOptional<z.ZodString>;
77
- tx: z.ZodOptional<z.ZodString>;
78
- rx: z.ZodOptional<z.ZodString>;
79
- }, z.core.$strict>>;
80
- peripheralInstances: z.ZodObject<{
81
- i2c: z.ZodArray<z.ZodObject<{
82
- instance: z.ZodNumber;
83
- defaultPins: z.ZodRecord<z.ZodString, z.ZodString>;
84
- alternatePins: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
85
- }, z.core.$strict>>;
86
- spi: z.ZodArray<z.ZodObject<{
87
- instance: z.ZodNumber;
88
- defaultPins: z.ZodRecord<z.ZodString, z.ZodString>;
89
- alternatePins: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
90
- }, z.core.$strict>>;
91
- uart: z.ZodArray<z.ZodObject<{
92
- instance: z.ZodNumber;
93
- defaultPins: z.ZodRecord<z.ZodString, z.ZodString>;
94
- alternatePins: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
95
- }, z.core.$strict>>;
96
- }, z.core.$strict>;
97
- adc: z.ZodArray<z.ZodObject<{
98
- instance: z.ZodNumber;
99
- channels: z.ZodNumber;
100
- resolution: z.ZodNumber;
101
- referenceVoltage: z.ZodNumber;
102
- maxValue: z.ZodNumber;
103
- referenceVoltages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
104
- }, z.core.$strict>>;
105
- pwm: z.ZodObject<{
106
- channels: z.ZodNumber;
107
- resolution: z.ZodNumber;
108
- maxFrequency: z.ZodNumber;
109
- }, z.core.$strict>;
110
- touch: z.ZodOptional<z.ZodNullable<z.ZodObject<{
111
- channels: z.ZodNumber;
112
- pins: z.ZodArray<z.ZodString>;
113
- }, z.core.$strip>>>;
114
- timers: z.ZodArray<z.ZodObject<{
115
- instance: z.ZodNumber;
116
- type: z.ZodEnum<{
117
- general: "general";
118
- high_speed: "high_speed";
119
- rtc: "rtc";
120
- sys: "sys";
121
- }>;
122
- bits: z.ZodUnion<readonly [z.ZodLiteral<8>, z.ZodLiteral<16>, z.ZodLiteral<32>, z.ZodLiteral<64>]>;
123
- features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
124
- pwm: "pwm";
125
- capture: "capture";
126
- compare: "compare";
127
- interrupt: "interrupt";
128
- dma: "dma";
129
- }>>>;
130
- }, z.core.$strict>>;
131
- wifi: z.ZodObject<{
132
- type: z.ZodEnum<{
133
- wifi: "wifi";
134
- wifi6: "wifi6";
135
- }>;
136
- supportsStation: z.ZodBoolean;
137
- supportsAp: z.ZodBoolean;
138
- }, z.core.$strict>;
139
- bluetooth: z.ZodObject<{
140
- type: z.ZodEnum<{
141
- classic: "classic";
142
- ble: "ble";
143
- dual: "dual";
144
- }>;
145
- version: z.ZodString;
146
- }, z.core.$strict>;
147
- usb: z.ZodObject<{
148
- type: z.ZodEnum<{
149
- device: "device";
150
- host: "host";
151
- otg: "otg";
152
- }>;
153
- vid: z.ZodString;
154
- pid: z.ZodString;
155
- }, z.core.$strict>;
156
- features: z.ZodObject<{
157
- multicore: z.ZodBoolean;
158
- coreCount: z.ZodNumber;
159
- deepSleep: z.ZodBoolean;
160
- watchdog: z.ZodBoolean;
161
- externalInterrupts: z.ZodBoolean;
162
- hardwareRng: z.ZodBoolean;
163
- fpu: z.ZodBoolean;
164
- }, z.core.$strict>;
165
- memory: z.ZodObject<{
166
- flash: z.ZodNumber;
167
- sram: z.ZodNumber;
168
- eeprom: z.ZodNumber;
169
- externalRam: z.ZodOptional<z.ZodNumber>;
170
- rtcMemory: z.ZodOptional<z.ZodNumber>;
171
- }, z.core.$strict>;
172
- }, z.core.$strict>;
173
- export type BoardSpec = z.infer<typeof BoardSpecSchema>;
174
- export declare function parseBoardSpec(jsoncText: string): BoardSpec;
175
- export declare function safeParseBoardSpec(jsoncText: string): {
176
- success: true;
177
- spec: BoardSpec;
178
- } | {
179
- success: false;
180
- errors: string[];
181
- };
@@ -1,214 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // board-spec.ts — Zod schema + types for the .jsonc chip spec consumed by
3
- // `cuttlefish board add`. The spec is a human-authored description of the
4
- // silicon + board; the codegen transforms it into package source files.
5
- // ---------------------------------------------------------------------------
6
- import { z } from 'zod';
7
- // ---------------------------------------------------------------------------
8
- // Comment stripper — .jsonc → JSON. Strips // line comments and /* */ blocks
9
- // while respecting string literals (a // inside a string is not a comment).
10
- // ---------------------------------------------------------------------------
11
- export function stripJsonc(text) {
12
- let result = '';
13
- let i = 0;
14
- while (i < text.length) {
15
- const ch = text[i];
16
- const next = text[i + 1];
17
- // String literal — copy verbatim until closing quote
18
- if (ch === '"') {
19
- result += ch;
20
- i++;
21
- while (i < text.length) {
22
- result += text[i];
23
- if (text[i] === '\\' && i + 1 < text.length) {
24
- result += text[i + 1];
25
- i += 2;
26
- continue;
27
- }
28
- if (text[i] === '"') {
29
- i++;
30
- break;
31
- }
32
- i++;
33
- }
34
- continue;
35
- }
36
- // Line comment // ... \n
37
- if (ch === '/' && next === '/') {
38
- while (i < text.length && text[i] !== '\n')
39
- i++;
40
- continue;
41
- }
42
- // Block comment /* ... */
43
- if (ch === '/' && next === '*') {
44
- i += 2;
45
- while (i < text.length && !(text[i] === '*' && text[i + 1] === '/'))
46
- i++;
47
- i += 2;
48
- continue;
49
- }
50
- result += ch;
51
- i++;
52
- }
53
- return result;
54
- }
55
- // ---------------------------------------------------------------------------
56
- // Sub-schemas
57
- // ---------------------------------------------------------------------------
58
- const PinFunctionSchema = z.object({
59
- type: z.enum(['i2c', 'spi', 'uart', 'adc', 'dac', 'pwm', 'touch', 'usb']),
60
- instance: z.number().int(),
61
- role: z.string(),
62
- }).strict();
63
- const PinSpecSchema = z.object({
64
- gpio: z.number().int(),
65
- capabilities: z.enum([
66
- 'FULL_GPIO', 'FULL_GPIO_ANALOG', 'FULL_GPIO_TOUCH',
67
- 'FULL_GPIO_ANALOG_TOUCH', 'FULL_GPIO_DAC', 'INPUT_ONLY',
68
- ]),
69
- functions: z.array(PinFunctionSchema).optional(),
70
- alt: z.array(z.string()).optional(),
71
- warnings: z.array(z.string()).optional(),
72
- unsafe: z.boolean().optional(),
73
- notes: z.string().optional(),
74
- onboardLed: z.boolean().optional(),
75
- }).strict();
76
- const PeripheralInstanceSchema = z.object({
77
- instance: z.number().int(),
78
- defaultPins: z.record(z.string(), z.string()),
79
- alternatePins: z.record(z.string(), z.array(z.string())).optional(),
80
- }).strict();
81
- const AdcSchema = z.object({
82
- instance: z.number().int(),
83
- channels: z.number().int(),
84
- resolution: z.number().int(),
85
- referenceVoltage: z.number(),
86
- maxValue: z.number().int(),
87
- referenceVoltages: z.record(z.string(), z.number()).optional(),
88
- }).strict();
89
- const BusPinMapSchema = z.record(z.string(), z.object({
90
- sda: z.string().optional(),
91
- scl: z.string().optional(),
92
- mosi: z.string().optional(),
93
- miso: z.string().optional(),
94
- sck: z.string().optional(),
95
- cs: z.string().optional(),
96
- tx: z.string().optional(),
97
- rx: z.string().optional(),
98
- }).strict());
99
- // ---------------------------------------------------------------------------
100
- // Top-level spec schema
101
- // ---------------------------------------------------------------------------
102
- export const BoardSpecSchema = z.object({
103
- // Identity
104
- architecture: z.string().min(1),
105
- mcuId: z.string().min(1),
106
- mcuName: z.string().min(1),
107
- boardId: z.string().min(1),
108
- boardName: z.string().min(1),
109
- vendor: z.string().min(1),
110
- description: z.string().optional(),
111
- // Build
112
- clockSpeed: z.number().int(),
113
- fqbn: z.string().min(1),
114
- arduinoDefine: z.string().min(1),
115
- // Memory (module-level; silicon memory is derived)
116
- moduleFlash: z.number().int().nullable(),
117
- externalRam: z.number().int().nullable(),
118
- // GPIO range
119
- gpioRange: z.tuple([z.number().int(), z.number().int()]),
120
- excludedGpio: z.array(z.number().int()),
121
- // Pin data
122
- pins: z.array(PinSpecSchema),
123
- unsafe: z.array(z.string()),
124
- analog: z.array(z.string()),
125
- // Bus maps
126
- i2c: BusPinMapSchema,
127
- spi: BusPinMapSchema,
128
- uart: BusPinMapSchema,
129
- // Peripherals
130
- peripheralInstances: z.object({
131
- i2c: z.array(PeripheralInstanceSchema),
132
- spi: z.array(PeripheralInstanceSchema),
133
- uart: z.array(PeripheralInstanceSchema),
134
- }).strict(),
135
- adc: z.array(AdcSchema),
136
- pwm: z.object({
137
- channels: z.number().int(),
138
- resolution: z.number().int(),
139
- maxFrequency: z.number().int(),
140
- }).strict(),
141
- touch: z.object({
142
- channels: z.number().int(),
143
- pins: z.array(z.string()),
144
- }).nullable().optional(),
145
- timers: z.array(z.object({
146
- instance: z.number().int(),
147
- type: z.enum(['general', 'high_speed', 'rtc', 'sys']),
148
- bits: z.union([z.literal(8), z.literal(16), z.literal(32), z.literal(64)]),
149
- features: z.array(z.enum(['pwm', 'capture', 'compare', 'interrupt', 'dma'])).optional(),
150
- }).strict()),
151
- // Connectivity
152
- wifi: z.object({
153
- type: z.enum(['wifi', 'wifi6']),
154
- supportsStation: z.boolean(),
155
- supportsAp: z.boolean(),
156
- }).strict(),
157
- bluetooth: z.object({
158
- type: z.enum(['classic', 'ble', 'dual']),
159
- version: z.string(),
160
- }).strict(),
161
- usb: z.object({
162
- type: z.enum(['device', 'host', 'otg']),
163
- vid: z.string(),
164
- pid: z.string(),
165
- }).strict(),
166
- // Features
167
- features: z.object({
168
- multicore: z.boolean(),
169
- coreCount: z.number().int(),
170
- deepSleep: z.boolean(),
171
- watchdog: z.boolean(),
172
- externalInterrupts: z.boolean(),
173
- hardwareRng: z.boolean(),
174
- fpu: z.boolean(),
175
- }).strict(),
176
- // Silicon memory
177
- memory: z.object({
178
- flash: z.number().int(),
179
- sram: z.number().int(),
180
- eeprom: z.number().int(),
181
- externalRam: z.number().int().optional(),
182
- rtcMemory: z.number().int().optional(),
183
- }).strict(),
184
- }).strict();
185
- // ---------------------------------------------------------------------------
186
- // Parse + validate a .jsonc string
187
- // ---------------------------------------------------------------------------
188
- export function parseBoardSpec(jsoncText) {
189
- const jsonText = stripJsonc(jsoncText);
190
- let parsed;
191
- try {
192
- parsed = JSON.parse(jsonText);
193
- }
194
- catch (e) {
195
- throw new Error(`Invalid JSON in spec file: ${e.message}`);
196
- }
197
- return BoardSpecSchema.parse(parsed);
198
- }
199
- export function safeParseBoardSpec(jsoncText) {
200
- try {
201
- const spec = parseBoardSpec(jsoncText);
202
- return { success: true, spec };
203
- }
204
- catch (e) {
205
- if (e instanceof z.ZodError) {
206
- const errors = e.issues.map(issue => {
207
- const path = issue.path.join('.');
208
- return path ? `${path}: ${issue.message}` : issue.message;
209
- });
210
- return { success: false, errors };
211
- }
212
- return { success: false, errors: [e.message] };
213
- }
214
- }
@@ -1,53 +0,0 @@
1
- /** A framework family that ships as an installable @typecad/framework-* package. */
2
- export interface FrameworkCatalogEntry {
3
- /** Short id, e.g. "arduino". Matches the suffix of @typecad/framework-<id>. */
4
- id: string;
5
- /** Full npm package name, e.g. "@typecad/framework-arduino". */
6
- packageName: string;
7
- /** Human-readable label shown in the install prompt. */
8
- label: string;
9
- /**
10
- * Whether a real package exists on the registry. Used to filter the prompt:
11
- * "esp-idf" is a known family with no published package yet, so it must not
12
- * be offered for install (it would fail at the package-manager step).
13
- */
14
- installable: boolean;
15
- }
16
- /**
17
- * The installable frameworks. Kept aligned with the packages/ directory:
18
- * framework-arduino, framework-native, framework-zephyr all ship real packages.
19
- * esp-idf is intentionally absent (no published package in this repo).
20
- */
21
- export declare const FRAMEWORK_CATALOG: readonly FrameworkCatalogEntry[];
22
- /** Structural shape we need from a board/target. Keeps this module decoupled
23
- * from the create/ module's KnownTarget (and trivially testable with literals). */
24
- export interface BoardLike {
25
- isNative?: boolean;
26
- architecture?: string;
27
- }
28
- /** Look up a catalog entry by framework id (e.g. "arduino"). */
29
- export declare function frameworkCatalogEntry(id: string): FrameworkCatalogEntry | undefined;
30
- /**
31
- * The framework ids compatible with a board. Native boards map to ["native"];
32
- * embedded boards map via ARCHITECTURE_FRAMEWORKS (falling back to arduino for
33
- * unknown architectures). Order is preserved as the catalog order so the most
34
- * common framework is offered first in the prompt.
35
- */
36
- export declare function frameworksForTarget(target: BoardLike): FrameworkCatalogEntry[];
37
- export type PackageManager = "npm" | "pnpm" | "yarn";
38
- /**
39
- * Detect the package manager for a directory. Priority:
40
- * 1. package.json#packageManager field (the strongest signal, Corepack-style)
41
- * 2. lockfile presence (pnpm-lock.yaml / yarn.lock → otherwise npm)
42
- * 3. default "npm"
43
- * Never throws — unreadable/missing files fall through to the next signal.
44
- */
45
- export declare function detectPackageManager(cwd: string): PackageManager;
46
- /**
47
- * Build the package-manager invocation that installs `packageName` into the
48
- * current project (project-local, never global — per the install command spec).
49
- */
50
- export declare function buildInstallCommand(pm: PackageManager, packageName: string): {
51
- bin: string;
52
- args: string[];
53
- };
@@ -1,107 +0,0 @@
1
- // Framework catalog + board→framework compatibility for `cuttlefish install`.
2
- //
3
- // A "framework" is a `@typecad/framework-<id>` npm package. This module is the
4
- // single source of truth for which frameworks exist as installable packages and
5
- // which are compatible with a given board architecture. It is deliberately
6
- // free of side effects (no fs/process beyond lockfile/package.json reads in
7
- // detectPackageManager) so it unit-tests cleanly.
8
- import path from "node:path";
9
- import fs from "node:fs";
10
- /**
11
- * The installable frameworks. Kept aligned with the packages/ directory:
12
- * framework-arduino, framework-native, framework-zephyr all ship real packages.
13
- * esp-idf is intentionally absent (no published package in this repo).
14
- */
15
- export const FRAMEWORK_CATALOG = [
16
- { id: "arduino", packageName: "@typecad/framework-arduino", label: "Arduino (digitalWrite, Wire, SPI)", installable: true },
17
- { id: "zephyr", packageName: "@typecad/framework-zephyr", label: "Zephyr RTOS", installable: true },
18
- { id: "native", packageName: "@typecad/framework-native", label: "Native (Windows/Linux executable)", installable: true },
19
- ];
20
- /**
21
- * Architecture → compatible framework ids. Derived from each framework
22
- * package's framework.manifest.ts `profile.targets`:
23
- * - arduino: avr, esp32 family, rp2040/rp2350, samd, stm32
24
- * - zephyr: nrf52 (xiao_ble), esp32, esp32s3
25
- * - native: desktop only
26
- * Unknown embedded architectures fall back to [arduino] (the broadest core).
27
- */
28
- const ARCHITECTURE_FRAMEWORKS = {
29
- avr: ["arduino"],
30
- esp32: ["arduino", "zephyr"],
31
- esp32s2: ["arduino"],
32
- esp32s3: ["arduino", "zephyr"],
33
- esp32c3: ["arduino"],
34
- esp32c6: ["arduino"],
35
- rp2040: ["arduino"],
36
- rp2350: ["arduino"],
37
- samd: ["arduino"],
38
- stm32: ["arduino"],
39
- nrf52: ["zephyr"],
40
- };
41
- const FALLBACK_FRAMEWORKS = ["arduino"];
42
- /** Look up a catalog entry by framework id (e.g. "arduino"). */
43
- export function frameworkCatalogEntry(id) {
44
- return FRAMEWORK_CATALOG.find((f) => f.id === id);
45
- }
46
- /**
47
- * The framework ids compatible with a board. Native boards map to ["native"];
48
- * embedded boards map via ARCHITECTURE_FRAMEWORKS (falling back to arduino for
49
- * unknown architectures). Order is preserved as the catalog order so the most
50
- * common framework is offered first in the prompt.
51
- */
52
- export function frameworksForTarget(target) {
53
- let ids;
54
- if (target.isNative) {
55
- ids = ["native"];
56
- }
57
- else {
58
- ids = ARCHITECTURE_FRAMEWORKS[target.architecture ?? ""] ?? FALLBACK_FRAMEWORKS;
59
- }
60
- // Re-map ids → catalog entries in catalog order (stable ordering), dropping
61
- // any id that has no catalog entry (defensive — keeps the prompt clean).
62
- return FRAMEWORK_CATALOG.filter((entry) => ids.includes(entry.id));
63
- }
64
- /**
65
- * Detect the package manager for a directory. Priority:
66
- * 1. package.json#packageManager field (the strongest signal, Corepack-style)
67
- * 2. lockfile presence (pnpm-lock.yaml / yarn.lock → otherwise npm)
68
- * 3. default "npm"
69
- * Never throws — unreadable/missing files fall through to the next signal.
70
- */
71
- export function detectPackageManager(cwd) {
72
- try {
73
- const pkgPath = path.join(cwd, "package.json");
74
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
75
- const pm = typeof pkg.packageManager === "string" ? pkg.packageManager : "";
76
- if (pm.startsWith("pnpm"))
77
- return "pnpm";
78
- if (pm.startsWith("yarn"))
79
- return "yarn";
80
- if (pm.startsWith("npm"))
81
- return "npm";
82
- }
83
- catch {
84
- // no package.json or unparseable JSON — fall through to lockfile detection
85
- }
86
- if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml")))
87
- return "pnpm";
88
- if (fs.existsSync(path.join(cwd, "yarn.lock")))
89
- return "yarn";
90
- // package-lock.json implies npm; absence also defaults to npm.
91
- return "npm";
92
- }
93
- /**
94
- * Build the package-manager invocation that installs `packageName` into the
95
- * current project (project-local, never global — per the install command spec).
96
- */
97
- export function buildInstallCommand(pm, packageName) {
98
- switch (pm) {
99
- case "pnpm":
100
- return { bin: "pnpm", args: ["add", packageName] };
101
- case "yarn":
102
- return { bin: "yarn", args: ["add", packageName] };
103
- case "npm":
104
- default:
105
- return { bin: "npm", args: ["install", packageName] };
106
- }
107
- }
@@ -1,35 +0,0 @@
1
- import type { InstallCommandOptions } from "../types.js";
2
- import { type FrameworkCatalogEntry, type PackageManager } from "./framework-catalog.js";
3
- interface InstallCommand {
4
- bin: string;
5
- args: string[];
6
- cwd: string;
7
- }
8
- interface InstallRunResult {
9
- /** Exit status; null when the process could not be launched (ENOENT, etc.). */
10
- status: number | null;
11
- /** Populated only when the binary could not be launched. */
12
- launchError?: string;
13
- }
14
- type InstallRunner = (cmd: InstallCommand) => InstallRunResult;
15
- /**
16
- * FOR TESTS ONLY. Replaces the real spawn-based installer with `runner`.
17
- * Pass `undefined` to restore the real executor.
18
- */
19
- export declare function __setInstallRunnerForTest(runner: InstallRunner | undefined): void;
20
- export interface InstallResult {
21
- pm: PackageManager;
22
- bin: string;
23
- args: string[];
24
- }
25
- /**
26
- * Resolve the package manager and run the install for `entry`'s package. In
27
- * dry-run mode the command is printed but not executed. Throws on launch
28
- * failure or non-zero exit so the CLI surfaces a clear error.
29
- */
30
- export declare function installFrameworkPackage(entry: FrameworkCatalogEntry, opts: {
31
- cwd: string;
32
- dryRun?: boolean;
33
- }): InstallResult;
34
- export declare function handleInstall(options: InstallCommandOptions): Promise<void>;
35
- export {};