@typecad/cuttlefish 1.0.0-alpha.13 → 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 (343) hide show
  1. package/README.md +82 -79
  2. package/assets/editor-extensions/typecad-debug/README.md +141 -0
  3. package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
  4. package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
  5. package/assets/editor-extensions/typecad-debug/package.json +76 -0
  6. package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
  7. package/assets/editor-extensions/typecad-ui/README.md +52 -0
  8. package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
  9. package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
  10. package/assets/editor-extensions/typecad-ui/icon.png +0 -0
  11. package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
  12. package/assets/editor-extensions/typecad-ui/package.json +54 -0
  13. package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
  14. package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
  15. package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
  16. package/dist/api/config.d.ts +30 -27
  17. package/dist/api/schema/types.d.ts +20 -3
  18. package/dist/api/shared/async-runtime-static.d.ts +1 -1
  19. package/dist/api/shared/async-runtime-static.js +5 -5
  20. package/dist/api/shared/async-types.d.ts +3 -2
  21. package/dist/api/shared/board-catalog.d.ts +2 -0
  22. package/dist/api/shared/board-catalog.js +6 -0
  23. package/dist/api/shared/board-resolver.d.ts +4 -7
  24. package/dist/api/shared/board-resolver.js +2 -1
  25. package/dist/api/shared/coop-scheduler.d.ts +1 -1
  26. package/dist/api/shared/coop-scheduler.js +1 -1
  27. package/dist/api/shared/cpp-type-ir.d.ts +1 -1
  28. package/dist/api/shared/cpp-type-ir.js +1 -1
  29. package/dist/api/shared/display-profile.d.ts +1 -1
  30. package/dist/api/shared/display-profile.js +3 -5
  31. package/dist/api/shared/framework-manifest-registry.d.ts +1 -1
  32. package/dist/api/shared/framework-manifest-registry.js +0 -1
  33. package/dist/api/shared/framework-manifest.d.ts +65 -507
  34. package/dist/api/shared/framework-manifest.js +6 -11
  35. package/dist/api/shared/hal-op-ir.d.ts +294 -685
  36. package/dist/api/shared/hal-op-ir.js +31 -65
  37. package/dist/api/shared/index.d.ts +0 -4
  38. package/dist/api/shared/index.js +1 -7
  39. package/dist/api/shared/ir-core.d.ts +6 -0
  40. package/dist/api/shared/ir-declarations.d.ts +4 -0
  41. package/dist/api/shared/ir.d.ts +1 -3
  42. package/dist/api/shared/platform-strategy.d.ts +14 -37
  43. package/dist/api/shared/polyfill-helper-registry.js +0 -5
  44. package/dist/api/shared/polyfill-types.js +0 -27
  45. package/dist/api/shared/promise-runtime.js +3 -3
  46. package/dist/api/shared/spdx-licenses.d.ts +12 -10
  47. package/dist/api/shared/spdx-licenses.js +1 -1
  48. package/dist/api/shared/toolchain-types.d.ts +1 -1
  49. package/dist/api/shared/toolchain-types.js +3 -3
  50. package/dist/api/shared/types.d.ts +0 -3
  51. package/dist/api/shared/validate-framework-manifest.js +13 -33
  52. package/dist/board-catalog/dts-reader.d.ts +220 -0
  53. package/dist/board-catalog/dts-reader.js +1052 -0
  54. package/dist/board-catalog/index.d.ts +11 -0
  55. package/dist/board-catalog/index.js +12 -0
  56. package/dist/board-catalog/pinconfig.d.ts +48 -0
  57. package/dist/board-catalog/pinconfig.js +263 -0
  58. package/dist/board-catalog/sdk.d.ts +82 -0
  59. package/dist/board-catalog/sdk.js +180 -0
  60. package/dist/board-catalog/store.d.ts +196 -0
  61. package/dist/board-catalog/store.js +363 -0
  62. package/dist/board-catalog/types.d.ts +233 -0
  63. package/dist/board-catalog/types.js +7 -0
  64. package/dist/board-catalog/walker.d.ts +112 -0
  65. package/dist/board-catalog/walker.js +1101 -0
  66. package/dist/cli-utils.d.ts +2 -2
  67. package/dist/cli-utils.js +5 -5
  68. package/dist/cli.js +227 -244
  69. package/dist/config-loader.d.ts +14 -19
  70. package/dist/config-loader.js +242 -78
  71. package/dist/config-schema.d.ts +19 -227
  72. package/dist/config-schema.js +9 -8
  73. package/dist/contract/board-generator.d.ts +4 -4
  74. package/dist/contract/board-generator.js +16 -5
  75. package/dist/contract/contract-parser.d.ts +36 -127
  76. package/dist/contract/contract-parser.js +76 -0
  77. package/dist/contract/index.d.ts +1 -1
  78. package/dist/contract/index.js +70 -21
  79. package/dist/create/active-board-catalog.d.ts +9 -0
  80. package/dist/create/active-board-catalog.js +94 -0
  81. package/dist/create/board-catalog.generated.d.ts +96 -0
  82. package/dist/create/board-catalog.generated.js +128737 -0
  83. package/dist/create/board-search.d.ts +23 -0
  84. package/dist/create/board-search.js +88 -0
  85. package/dist/create/editor-integration.d.ts +32 -0
  86. package/dist/create/editor-integration.js +257 -0
  87. package/dist/create/eslint-rules-template.d.ts +2 -2
  88. package/dist/create/framework-catalog.d.ts +48 -8
  89. package/dist/create/framework-catalog.js +58 -44
  90. package/dist/create/index.d.ts +8 -13
  91. package/dist/create/index.js +5 -9
  92. package/dist/create/mcu-target.d.ts +39 -0
  93. package/dist/create/mcu-target.js +80 -0
  94. package/dist/create/pack-targets.d.ts +19 -0
  95. package/dist/create/pack-targets.js +56 -0
  96. package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +8 -11
  97. package/dist/create/{init-scaffold.js → scaffold.js} +28 -87
  98. package/dist/create/templates.d.ts +51 -0
  99. package/dist/create/{init-templates.js → templates.js} +135 -116
  100. package/dist/create/wizard.d.ts +19 -0
  101. package/dist/create/wizard.js +314 -0
  102. package/dist/debug/preprocessor.d.ts +5 -0
  103. package/dist/debug/preprocessor.js +31 -7
  104. package/dist/diagnostics/diagnostics-report.d.ts +1 -1
  105. package/dist/diagnostics/diagnostics-report.js +3 -11
  106. package/dist/diagnostics/json-schema.d.ts +1 -1
  107. package/dist/diagnostics/md-writer.js +2 -2
  108. package/dist/diagnostics/mermaid-builder.d.ts +1 -1
  109. package/dist/diagnostics/mermaid-builder.js +1 -1
  110. package/dist/emit/cpp-emitter.js +4 -1
  111. package/dist/emit/emitters/class-emitter.js +32 -4
  112. package/dist/emit/emitters/emitter-context.d.ts +11 -0
  113. package/dist/emit/emitters/entrypoint-synthesizer.js +1 -1
  114. package/dist/emit/emitters/function-emitter-impl.js +33 -17
  115. package/dist/emit/emitters/output-finalizer.d.ts +7 -0
  116. package/dist/emit/emitters/output-finalizer.js +31 -23
  117. package/dist/emit/emitters/setup.js +147 -63
  118. package/dist/emit/emitters/top-level-prep.js +1 -1
  119. package/dist/emit/emitters/type-decl-emitter.js +13 -8
  120. package/dist/emit/emitters/ui-emitter.js +1 -1
  121. package/dist/emit/expression-renderer.d.ts +3 -3
  122. package/dist/emit/expression-renderer.js +17 -7
  123. package/dist/emit/route-hal-op.js +17 -48
  124. package/dist/emit/snprintf-helpers.d.ts +1 -3
  125. package/dist/emit/snprintf-helpers.js +1 -39
  126. package/dist/emit/statement-renderer.d.ts +0 -4
  127. package/dist/emit/statement-renderer.js +54 -45
  128. package/dist/emit/utils/async-state-machine.d.ts +16 -9
  129. package/dist/emit/utils/async-state-machine.js +56 -54
  130. package/dist/emit/utils/comment-helpers.d.ts +0 -8
  131. package/dist/emit/utils/comment-helpers.js +1 -1
  132. package/dist/emit/utils/cpp-helpers.d.ts +2 -2
  133. package/dist/emit/utils/cpp-helpers.js +2 -2
  134. package/dist/emit/utils/hal-op-cpp-type.js +4 -6
  135. package/dist/emit/utils/index.d.ts +3 -3
  136. package/dist/emit/utils/index.js +3 -3
  137. package/dist/emit/utils/type-inference.d.ts +1 -29
  138. package/dist/emit/utils/type-inference.js +0 -75
  139. package/dist/framework-package.d.ts +3 -0
  140. package/dist/framework-package.js +23 -6
  141. package/dist/framework-registry.d.ts +5 -5
  142. package/dist/frameworks/native/graphics/terminal-preview.d.ts +5 -0
  143. package/dist/frameworks/native/graphics/terminal-preview.js +33 -0
  144. package/dist/frameworks/native/index.d.ts +3 -0
  145. package/dist/frameworks/native/index.js +15 -0
  146. package/dist/frameworks/native/native-compile.d.ts +17 -0
  147. package/dist/frameworks/native/native-compile.js +170 -0
  148. package/dist/frameworks/native/native-config.d.ts +41 -0
  149. package/dist/frameworks/native/native-config.js +7 -0
  150. package/dist/frameworks/native/strategy.d.ts +97 -0
  151. package/dist/frameworks/native/strategy.js +664 -0
  152. package/dist/ir/board-resolver.d.ts +18 -23
  153. package/dist/ir/board-resolver.js +43 -401
  154. package/dist/ir/build-ir-state.d.ts +3 -0
  155. package/dist/ir/build-ir-state.js +42 -0
  156. package/dist/ir/build-ir.d.ts +1 -1
  157. package/dist/ir/build-ir.js +64 -45
  158. package/dist/ir/declaration-builders.js +1 -0
  159. package/dist/ir/expression-to-ir.js +17 -10
  160. package/dist/ir/hal/hal-emitter.d.ts +0 -2
  161. package/dist/ir/hal/hal-emitter.js +92 -41
  162. package/dist/ir/hal/hal-parser.d.ts +5 -5
  163. package/dist/ir/hal/hal-parser.js +128 -36
  164. package/dist/ir/hal/hal-plugins.d.ts +0 -1
  165. package/dist/ir/hal/hal-plugins.js +425 -716
  166. package/dist/ir/heap-analysis.js +2 -41
  167. package/dist/ir/identifier-collector.js +32 -20
  168. package/dist/ir/network-validation.js +7 -11
  169. package/dist/ir/ownership-analysis.js +75 -13
  170. package/dist/ir/peripheral-usage.d.ts +8 -2
  171. package/dist/ir/peripheral-usage.js +78 -149
  172. package/dist/ir/peripheral-validation.js +23 -3
  173. package/dist/ir/pin-capability-validation.d.ts +12 -0
  174. package/dist/ir/pin-capability-validation.js +61 -97
  175. package/dist/ir/pin-mode-validation.js +5 -5
  176. package/dist/ir/program-analysis.d.ts +8 -15
  177. package/dist/ir/program-analysis.js +140 -323
  178. package/dist/ir/pulldown-validation.js +11 -4
  179. package/dist/ir/resource-analysis.js +15 -3
  180. package/dist/ir/statement-to-ir.js +0 -6
  181. package/dist/ir/timing-validation.js +1 -1
  182. package/dist/ir/transformers/array-methods.js +11 -5
  183. package/dist/ir/transformers/call-statement.js +20 -87
  184. package/dist/ir/transformers/callback-context-registry.d.ts +1 -1
  185. package/dist/ir/transformers/callback-context-registry.js +8 -16
  186. package/dist/ir/transformers/control-flow.js +0 -13
  187. package/dist/ir/transformers/expressions.js +10 -9
  188. package/dist/ir/transformers/hal-call-resolver.d.ts +2 -2
  189. package/dist/ir/transformers/hal-call-resolver.js +24 -10
  190. package/dist/ir/transformers/hal-emit-helpers.d.ts +2 -2
  191. package/dist/ir/transformers/hal-emit-helpers.js +2 -2
  192. package/dist/ir/transformers/namespace-methods.js +1 -1
  193. package/dist/ir/transformers/ui-callback-lowering.d.ts +0 -2
  194. package/dist/ir/transformers/ui-callback-lowering.js +0 -24
  195. package/dist/ir/transformers/variables.js +338 -42
  196. package/dist/ir/try-catch-validation.js +4 -3
  197. package/dist/ir/type-resolution.js +15 -4
  198. package/dist/ir/validation-orchestrator.js +0 -9
  199. package/dist/libdef/cpp-to-decl.d.ts +0 -9
  200. package/dist/libdef/cpp-to-decl.js +0 -72
  201. package/dist/libdef/registry.d.ts +0 -1
  202. package/dist/libdef/registry.js +1 -24
  203. package/dist/library/catalog.d.ts +35 -0
  204. package/dist/library/catalog.js +67 -0
  205. package/dist/library/cli.d.ts +2 -0
  206. package/dist/library/cli.js +168 -0
  207. package/dist/library/init.d.ts +25 -0
  208. package/dist/library/init.js +397 -0
  209. package/dist/library/install.d.ts +9 -0
  210. package/dist/library/install.js +80 -0
  211. package/dist/library/registry-search.d.ts +34 -0
  212. package/dist/library/registry-search.js +50 -0
  213. package/dist/library/validate.d.ts +17 -0
  214. package/dist/library/validate.js +175 -0
  215. package/dist/library-packages.d.ts +95 -0
  216. package/dist/library-packages.js +275 -0
  217. package/dist/mapping/peripheral-names.js +9 -4
  218. package/dist/mapping/source-map.d.ts +3 -4
  219. package/dist/mapping/source-map.js +12 -18
  220. package/dist/orchestrator/graph-builder.d.ts +3 -3
  221. package/dist/orchestrator/graph-builder.js +29 -12
  222. package/dist/orchestrator/type-checker.d.ts +3 -3
  223. package/dist/orchestrator/type-checker.js +3 -3
  224. package/dist/platform/async-runtime.js +1 -1
  225. package/dist/platform/coop-scheduler-runtime.js +2 -2
  226. package/dist/platform/generic-debug-codegen.d.ts +36 -0
  227. package/dist/platform/generic-debug-codegen.js +185 -0
  228. package/dist/platform/generic-strategy.d.ts +3 -4
  229. package/dist/platform/generic-strategy.js +5 -80
  230. package/dist/platform/index.js +1 -1
  231. package/dist/platform/registry.d.ts +2 -2
  232. package/dist/platform/registry.js +2 -2
  233. package/dist/preview/client.js +17 -3
  234. package/dist/safety/asil-decorators.d.ts +32 -0
  235. package/dist/safety/asil-decorators.js +32 -0
  236. package/dist/safety/authoring.d.ts +85 -0
  237. package/dist/safety/authoring.js +61 -0
  238. package/dist/safety/engine.d.ts +3 -0
  239. package/dist/safety/engine.js +83 -0
  240. package/dist/safety/hal/ops.d.ts +48 -0
  241. package/dist/safety/hal/ops.js +46 -0
  242. package/dist/safety/iso26262/analyze.d.ts +13 -0
  243. package/dist/safety/iso26262/analyze.js +29 -0
  244. package/dist/safety/iso26262/asil.d.ts +10 -0
  245. package/dist/safety/iso26262/asil.js +22 -0
  246. package/dist/safety/iso26262/collect.d.ts +14 -0
  247. package/dist/safety/iso26262/collect.js +137 -0
  248. package/dist/safety/iso26262/goto-checker.d.ts +10 -0
  249. package/dist/safety/iso26262/goto-checker.js +72 -0
  250. package/dist/safety/iso26262/heap-checker.d.ts +7 -0
  251. package/dist/safety/iso26262/heap-checker.js +57 -0
  252. package/dist/safety/iso26262/init-checker.d.ts +13 -0
  253. package/dist/safety/iso26262/init-checker.js +127 -0
  254. package/dist/safety/iso26262/loop-checker.d.ts +7 -0
  255. package/dist/safety/iso26262/loop-checker.js +86 -0
  256. package/dist/safety/iso26262/recursion-checker.d.ts +9 -0
  257. package/dist/safety/iso26262/recursion-checker.js +134 -0
  258. package/dist/safety/iso26262/sidecar-writer.d.ts +25 -0
  259. package/dist/safety/iso26262/sidecar-writer.js +13 -0
  260. package/dist/safety/passes/pinMode-intercept.d.ts +3 -0
  261. package/dist/safety/passes/pinMode-intercept.js +60 -0
  262. package/dist/safety/runtime/mode-table.d.ts +5 -0
  263. package/dist/safety/runtime/mode-table.js +55 -0
  264. package/dist/safety/runtime/polyfills.d.ts +6 -0
  265. package/dist/safety/runtime/polyfills.js +12 -0
  266. package/dist/safety/runtime/result-struct.d.ts +11 -0
  267. package/dist/safety/runtime/result-struct.js +98 -0
  268. package/dist/safety/runtime/safe-int.d.ts +33 -0
  269. package/dist/safety/runtime/safe-int.js +170 -0
  270. package/dist/safety/runtime/safe-traits.d.ts +4 -0
  271. package/dist/safety/runtime/safe-traits.js +95 -0
  272. package/dist/safety/runtime/safe-variable.d.ts +39 -0
  273. package/dist/safety/runtime/safe-variable.js +226 -0
  274. package/dist/safety/runtime/vote.d.ts +8 -0
  275. package/dist/safety/runtime/vote.js +92 -0
  276. package/dist/safety/runtime/write-verify.d.ts +8 -0
  277. package/dist/safety/runtime/write-verify.js +71 -0
  278. package/dist/safety/safe-int-types.d.ts +45 -0
  279. package/dist/safety/safe-int-types.js +25 -0
  280. package/dist/safety/safe-variable-types.d.ts +29 -0
  281. package/dist/safety/safe-variable-types.js +19 -0
  282. package/dist/safety/safety-bridge.d.ts +5 -6
  283. package/dist/safety/safety-bridge.js +15 -28
  284. package/dist/safety/sidecar-bridge.d.ts +1 -3
  285. package/dist/safety/sidecar-bridge.js +3 -20
  286. package/dist/safety/specifiers.d.ts +6 -0
  287. package/dist/safety/specifiers.js +14 -0
  288. package/dist/safety-hook.d.ts +8 -7
  289. package/dist/safety-hook.js +12 -13
  290. package/dist/testing.d.ts +5 -6
  291. package/dist/testing.js +5 -5
  292. package/dist/transpile/resolution.d.ts +1 -1
  293. package/dist/transpile/resolution.js +18 -9
  294. package/dist/transpile/test-pins.d.ts +18 -0
  295. package/dist/transpile/test-pins.js +142 -0
  296. package/dist/transpile.d.ts +1 -2
  297. package/dist/transpile.js +90 -29
  298. package/dist/types.d.ts +45 -26
  299. package/dist/ui-hook.d.ts +1 -1
  300. package/dist/utils/cli.d.ts +2 -2
  301. package/dist/utils/cli.js +160 -157
  302. package/dist/utils/fs.d.ts +3 -4
  303. package/dist/utils/fs.js +4 -5
  304. package/dist/utils/strings.d.ts +0 -1
  305. package/dist/utils/strings.js +0 -8
  306. package/dist/utils/ui.d.ts +5 -2
  307. package/dist/utils/ui.js +13 -3
  308. package/package.json +158 -149
  309. package/dist/add-preset.d.ts +0 -4
  310. package/dist/add-preset.js +0 -74
  311. package/dist/api/shared/async-symbol-detector.d.ts +0 -11
  312. package/dist/api/shared/async-symbol-detector.js +0 -140
  313. package/dist/api/shared/native-display-op-resolver.d.ts +0 -10
  314. package/dist/api/shared/native-display-op-resolver.js +0 -64
  315. package/dist/create/board-checklist.d.ts +0 -2
  316. package/dist/create/board-checklist.js +0 -52
  317. package/dist/create/board-codegen.d.ts +0 -9
  318. package/dist/create/board-codegen.js +0 -238
  319. package/dist/create/board-generators.d.ts +0 -12
  320. package/dist/create/board-generators.js +0 -651
  321. package/dist/create/board-spec.d.ts +0 -637
  322. package/dist/create/board-spec.js +0 -214
  323. package/dist/create/init-templates.d.ts +0 -28
  324. package/dist/create/init-wizard.d.ts +0 -8
  325. package/dist/create/init-wizard.js +0 -182
  326. package/dist/install/framework-catalog.d.ts +0 -53
  327. package/dist/install/framework-catalog.js +0 -107
  328. package/dist/install/handle-install.d.ts +0 -35
  329. package/dist/install/handle-install.js +0 -177
  330. package/dist/install/index.d.ts +0 -4
  331. package/dist/install/index.js +0 -3
  332. package/dist/ir/pin-state-tracking.d.ts +0 -58
  333. package/dist/ir/pin-state-tracking.js +0 -182
  334. package/dist/ir/pwm-timer-sharing.d.ts +0 -4
  335. package/dist/ir/pwm-timer-sharing.js +0 -94
  336. package/dist/ir/timer0-pwm-timing-conflict.d.ts +0 -4
  337. package/dist/ir/timer0-pwm-timing-conflict.js +0 -72
  338. package/dist/libdef/component-decls.d.ts +0 -2
  339. package/dist/libdef/component-decls.js +0 -6
  340. package/dist/libdef/component-discovery.d.ts +0 -43
  341. package/dist/libdef/component-discovery.js +0 -83
  342. package/dist/theme-tokens.d.ts +0 -22
  343. package/dist/theme-tokens.js +0 -172
package/package.json CHANGED
@@ -1,149 +1,158 @@
1
- {
2
- "name": "@typecad/cuttlefish",
3
- "version": "1.0.0-alpha.13",
4
- "description": "TypeScript to C++ transpiler native, Arduino, and bare-metal targets",
5
- "type": "module",
6
- "main": "./dist/transpile.js",
7
- "types": "./dist/transpile.d.ts",
8
- "bin": {
9
- "cuttlefish": "dist/cli.js"
10
- },
11
- "exports": {
12
- ".": {
13
- "types": "./dist/transpile.d.ts",
14
- "default": "./dist/transpile.js"
15
- },
16
- "./testing": {
17
- "types": "./dist/testing.d.ts",
18
- "default": "./dist/testing.js"
19
- },
20
- "./api": {
21
- "types": "./dist/api/index.d.ts",
22
- "default": "./dist/api/index.js"
23
- },
24
- "./api/shared": {
25
- "types": "./dist/api/shared/index.d.ts",
26
- "default": "./dist/api/shared/index.js"
27
- },
28
- "./ui-hook": {
29
- "types": "./dist/ui-hook.d.ts",
30
- "default": "./dist/ui-hook.js"
31
- },
32
- "./safety-hook-types": {
33
- "types": "./dist/safety-hook.d.ts",
34
- "default": "./dist/safety-hook.js"
35
- },
36
- "./build-ir-state": {
37
- "types": "./dist/ir/build-ir-state.d.ts",
38
- "default": "./dist/ir/build-ir-state.js"
39
- },
40
- "./config-loader": {
41
- "types": "./dist/config-loader.d.ts",
42
- "default": "./dist/config-loader.js"
43
- },
44
- "./utils/ui": {
45
- "types": "./dist/utils/ui.d.ts",
46
- "default": "./dist/utils/ui.js"
47
- },
48
- "./stores/display-profile-store": {
49
- "types": "./dist/stores/display-profile-store.d.ts",
50
- "default": "./dist/stores/display-profile-store.js"
51
- },
52
- "./stores/theme-store": {
53
- "types": "./dist/stores/theme-store.d.ts",
54
- "default": "./dist/stores/theme-store.js"
55
- },
56
- "./api/schema": {
57
- "types": "./dist/api/schema/index.d.ts",
58
- "default": "./dist/api/schema/index.js"
59
- },
60
- "./emit/route-hal-op": {
61
- "types": "./dist/emit/route-hal-op.d.ts",
62
- "default": "./dist/emit/route-hal-op.js"
63
- },
64
- "./lib/component-decls": {
65
- "types": "./dist/libdef/component-decls.d.ts",
66
- "default": "./dist/libdef/component-decls.js"
67
- },
68
- "./ir/transformers/ui-lowering": {
69
- "types": "./dist/ir/transformers/ui-lowering.d.ts",
70
- "default": "./dist/ir/transformers/ui-lowering.js"
71
- },
72
- "./ir/ui-element-auto-wire": {
73
- "types": "./dist/ir/ui-element-auto-wire.d.ts",
74
- "default": "./dist/ir/ui-element-auto-wire.js"
75
- },
76
- "./ir/transformers/ui-mount": {
77
- "types": "./dist/ir/transformers/ui-mount.d.ts",
78
- "default": "./dist/ir/transformers/ui-mount.js"
79
- },
80
- "./ir/transformers/ui-reactive": {
81
- "types": "./dist/ir/transformers/ui-reactive.d.ts",
82
- "default": "./dist/ir/transformers/ui-reactive.js"
83
- }
84
- },
85
- "files": [
86
- "dist",
87
- "assets"
88
- ],
89
- "publishConfig": {
90
- "access": "public"
91
- },
92
- "scripts": {
93
- "build": "tsc",
94
- "prepublishOnly": "npm run build",
95
- "start": "node dist/cli.js"
96
- },
97
- "dependencies": {
98
- "chalk": "^4.1.2",
99
- "typescript": "^5.7.3",
100
- "zod": "^3.24.0"
101
- },
102
- "peerDependencies": {
103
- "@typecad/ui": "1.0.0-alpha.13",
104
- "@typecad/safety": "1.0.0-alpha.13"
105
- },
106
- "peerDependenciesMeta": {
107
- "@typecad/ui": {
108
- "optional": true
109
- },
110
- "@typecad/safety": {
111
- "optional": true
112
- }
113
- },
114
- "optionalDependencies": {
115
- "@typecad/expect": "1.0.0-alpha.13",
116
- "@typecad/framework-native": "1.0.0-alpha.13"
117
- },
118
- "devDependencies": {
119
- "@types/node": "^22.10.7"
120
- },
121
- "license": "MIT",
122
- "repository": {
123
- "type": "git",
124
- "url": "git+https://github.com/justind000/typecode.git",
125
- "directory": "packages/cuttlefish"
126
- },
127
- "homepage": "https://github.com/justind000/typecode/tree/main/packages/cuttlefish",
128
- "bugs": {
129
- "url": "https://github.com/justind000/typecode/issues"
130
- },
131
- "keywords": [
132
- "arduino",
133
- "cli",
134
- "codegen",
135
- "cpp",
136
- "cuttlefish",
137
- "embedded",
138
- "firmware",
139
- "microcontroller",
140
- "transpiler",
141
- "typecad",
142
- "typescript"
143
- ],
144
- "engines": {
145
- "node": ">=18"
146
- },
147
- "author": "typecad0",
148
- "sideEffects": false
149
- }
1
+ {
2
+ "name": "@typecad/cuttlefish",
3
+ "version": "1.0.0-alpha.15",
4
+ "description": "TypeScript to C++ transpiler \u2014 native, Arduino, and bare-metal targets",
5
+ "type": "module",
6
+ "main": "./dist/transpile.js",
7
+ "types": "./dist/transpile.d.ts",
8
+ "bin": {
9
+ "cuttlefish": "dist/cli.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/transpile.d.ts",
14
+ "default": "./dist/transpile.js"
15
+ },
16
+ "./testing": {
17
+ "types": "./dist/testing.d.ts",
18
+ "default": "./dist/testing.js"
19
+ },
20
+ "./api": {
21
+ "types": "./dist/api/index.d.ts",
22
+ "default": "./dist/api/index.js"
23
+ },
24
+ "./api/shared": {
25
+ "types": "./dist/api/shared/index.d.ts",
26
+ "default": "./dist/api/shared/index.js"
27
+ },
28
+ "./board-catalog": {
29
+ "types": "./dist/board-catalog/index.d.ts",
30
+ "default": "./dist/board-catalog/index.js"
31
+ },
32
+ "./ui-hook": {
33
+ "types": "./dist/ui-hook.d.ts",
34
+ "default": "./dist/ui-hook.js"
35
+ },
36
+ "./safety-hook-types": {
37
+ "types": "./dist/safety-hook.d.ts",
38
+ "default": "./dist/safety-hook.js"
39
+ },
40
+ "./safety": {
41
+ "types": "./dist/safety/authoring.d.ts",
42
+ "default": "./dist/safety/authoring.js"
43
+ },
44
+ "./build-ir-state": {
45
+ "types": "./dist/ir/build-ir-state.d.ts",
46
+ "default": "./dist/ir/build-ir-state.js"
47
+ },
48
+ "./library-packages": {
49
+ "types": "./dist/library-packages.d.ts",
50
+ "default": "./dist/library-packages.js"
51
+ },
52
+ "./compliance": {
53
+ "types": "./dist/emit/compliance/index.d.ts",
54
+ "default": "./dist/emit/compliance/index.js"
55
+ },
56
+ "./config-loader": {
57
+ "types": "./dist/config-loader.d.ts",
58
+ "default": "./dist/config-loader.js"
59
+ },
60
+ "./utils/ui": {
61
+ "types": "./dist/utils/ui.d.ts",
62
+ "default": "./dist/utils/ui.js"
63
+ },
64
+ "./stores/display-profile-store": {
65
+ "types": "./dist/stores/display-profile-store.d.ts",
66
+ "default": "./dist/stores/display-profile-store.js"
67
+ },
68
+ "./stores/theme-store": {
69
+ "types": "./dist/stores/theme-store.d.ts",
70
+ "default": "./dist/stores/theme-store.js"
71
+ },
72
+ "./api/schema": {
73
+ "types": "./dist/api/schema/index.d.ts",
74
+ "default": "./dist/api/schema/index.js"
75
+ },
76
+ "./emit/route-hal-op": {
77
+ "types": "./dist/emit/route-hal-op.d.ts",
78
+ "default": "./dist/emit/route-hal-op.js"
79
+ },
80
+ "./ir/transformers/ui-lowering": {
81
+ "types": "./dist/ir/transformers/ui-lowering.d.ts",
82
+ "default": "./dist/ir/transformers/ui-lowering.js"
83
+ },
84
+ "./ir/ui-element-auto-wire": {
85
+ "types": "./dist/ir/ui-element-auto-wire.d.ts",
86
+ "default": "./dist/ir/ui-element-auto-wire.js"
87
+ },
88
+ "./ir/transformers/ui-mount": {
89
+ "types": "./dist/ir/transformers/ui-mount.d.ts",
90
+ "default": "./dist/ir/transformers/ui-mount.js"
91
+ },
92
+ "./ir/transformers/ui-reactive": {
93
+ "types": "./dist/ir/transformers/ui-reactive.d.ts",
94
+ "default": "./dist/ir/transformers/ui-reactive.js"
95
+ }
96
+ },
97
+ "files": [
98
+ "dist",
99
+ "assets"
100
+ ],
101
+ "publishConfig": {
102
+ "access": "public"
103
+ },
104
+ "scripts": {
105
+ "build": "tsc",
106
+ "prepublishOnly": "npm run build",
107
+ "start": "node dist/cli.js"
108
+ },
109
+ "dependencies": {
110
+ "@typecad/hal": "1.0.0-alpha.15",
111
+ "chalk": "^6.0.0",
112
+ "inquirer-select-pro": "^1.0.0-alpha.9",
113
+ "typescript": "^5.7.3",
114
+ "zod": "^4.4.3"
115
+ },
116
+ "peerDependencies": {
117
+ "@typecad/ui": "1.0.0-alpha.15"
118
+ },
119
+ "peerDependenciesMeta": {
120
+ "@typecad/ui": {
121
+ "optional": true
122
+ }
123
+ },
124
+ "optionalDependencies": {
125
+ "@typecad/expect": "1.0.0-alpha.15"
126
+ },
127
+ "devDependencies": {
128
+ "@types/node": "^22.10.7"
129
+ },
130
+ "license": "MIT",
131
+ "repository": {
132
+ "type": "git",
133
+ "url": "git+https://github.com/justind000/typecode.git",
134
+ "directory": "packages/cuttlefish"
135
+ },
136
+ "homepage": "https://github.com/justind000/typecode/tree/main/packages/cuttlefish",
137
+ "bugs": {
138
+ "url": "https://github.com/justind000/typecode/issues"
139
+ },
140
+ "keywords": [
141
+ "arduino",
142
+ "cli",
143
+ "codegen",
144
+ "cpp",
145
+ "cuttlefish",
146
+ "embedded",
147
+ "firmware",
148
+ "microcontroller",
149
+ "transpiler",
150
+ "typecad",
151
+ "typescript"
152
+ ],
153
+ "engines": {
154
+ "node": ">=22.11.0"
155
+ },
156
+ "author": "typecad0",
157
+ "sideEffects": false
158
+ }
@@ -1,4 +0,0 @@
1
- import type { AddCommandOptions } from "./types.js";
2
- export declare function listAddPresets(): string;
3
- /** Run `cuttlefish add <preset>`: copy the preset into the project. */
4
- export declare function runAddPreset(options: AddCommandOptions): void;
@@ -1,74 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // `cuttlefish add <preset>` — scaffold copy-and-own assets into a project.
3
- //
4
- // Presets are files shipped with the package under assets/. The command COPIES
5
- // them into the user's project (never injected at build time): the user owns
6
- // the file from day one and the build only reads what they reference. This is
7
- // the same philosophy as shadcn/ui — components as source you keep, not a
8
- // runtime dependency.
9
- // ---------------------------------------------------------------------------
10
- import fs from "node:fs";
11
- import path from "node:path";
12
- import { fileURLToPath } from "node:url";
13
- import { loadShadcnTheme, applyShadcnTheme } from "./theme-tokens.js";
14
- import chalk from "chalk";
15
- const ASSETS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../assets");
16
- const PRESETS = {
17
- shadcn: {
18
- source: "shadcn/shadcn.css",
19
- dest: "src/styles/shadcn.css",
20
- description: "shadcn-style CSS variable tokens + component class recipes (buttons, cards, badges, alerts, ...)",
21
- nextSteps: [
22
- `Link it from a stylesheet (sibling .ui.css file or a <style> block):`,
23
- ``,
24
- ` @import "./styles/shadcn.css";`,
25
- ``,
26
- `Then use the classes on native elements:`,
27
- ` <button class="btn btn-primary">Save</button>`,
28
- ` <view class="card"> ... <text class="card-title">Title</text> ... </view>`,
29
- ``,
30
- `Dark theme: the file defines a .dark token set — activate it with`,
31
- `themeClass: 'dark' in cuttlefish.config.ts's display block.`,
32
- `The file is yours: tune tokens and prune recipes freely.`,
33
- ``,
34
- `Themes: start from an included one with --theme <name>`,
35
- `(see \`cuttlefish theme\` for the list); swap later with the same command.`,
36
- ],
37
- },
38
- };
39
- export function listAddPresets() {
40
- return Object.entries(PRESETS).map(([id, p]) => ` ${id.padEnd(10)} ${p.description}`).join("\n");
41
- }
42
- /** Run `cuttlefish add <preset>`: copy the preset into the project. */
43
- export function runAddPreset(options) {
44
- const preset = PRESETS[options.preset];
45
- if (!preset) {
46
- throw new Error(`Unknown preset "${options.preset}". Available presets:\n${listAddPresets()}`);
47
- }
48
- const src = path.join(ASSETS_DIR, preset.source);
49
- if (!fs.existsSync(src)) {
50
- throw new Error(`Preset asset missing from the cuttlefish package: ${src}`);
51
- }
52
- const dest = path.resolve(options.projectRoot, preset.dest);
53
- if (fs.existsSync(dest) && !options.force) {
54
- throw new Error(`${dest} already exists — re-run with --force to overwrite (your edits will be lost).`);
55
- }
56
- fs.mkdirSync(path.dirname(dest), { recursive: true });
57
- fs.copyFileSync(src, dest);
58
- // --theme <name>: merge an included shadcn theme's tokens into the copied
59
- // stylesheet (shadcn preset only; no-op for future presets without themes).
60
- if (options.theme) {
61
- if (options.preset !== "shadcn") {
62
- throw new Error(`--theme applies to the shadcn preset only (got "${options.preset}").`);
63
- }
64
- const theme = loadShadcnTheme(options.theme, options.projectRoot);
65
- fs.writeFileSync(dest, applyShadcnTheme(fs.readFileSync(dest, "utf-8"), theme), "utf-8");
66
- console.log(chalk.green(`✓`) + ` Theme ${chalk.cyan(theme.name)} tokens merged into the copied file.`);
67
- }
68
- console.log(chalk.green(`✓`) + ` Added preset ${chalk.cyan(options.preset)} → ${path.relative(options.projectRoot, dest)}`);
69
- console.log();
70
- console.log(chalk.bold(`Next steps:`));
71
- for (const line of preset.nextSteps) {
72
- console.log(line ? ` ${line}` : ``);
73
- }
74
- }
@@ -1,11 +0,0 @@
1
- import type { ProgramIR } from "../index.js";
2
- /**
3
- * Walk a program's IR and return true if ANY statement or expression references
4
- * a cooperative-runtime symbol. Short-circuits on the first hit.
5
- *
6
- * Inspects the same node shapes the duplicated framework-strategy walkers did:
7
- * `raw` expressions, `hal-expr`/`hal-op` nodes whose operation carries raw
8
- * `code`, and any `raw`-kind subtree. Covers both the statement and expression
9
- * IR trees.
10
- */
11
- export declare function programUsesAsyncRuntimeSymbols(program: ProgramIR): boolean;
@@ -1,140 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Shared async-runtime symbol detector
3
- //
4
- // Returns true when a program actually references a symbol provided by the
5
- // cooperative Promise/microtask runtime (MicrotaskQueue, Promise<T>,
6
- // enqueueMicrotask, cuttlefish_pump_microtasks, the __cuttlefish_async_*
7
- // HAL helpers, __cuttlefish_wait_pin_edge). This is the precise gate for
8
- // emitting the `async_runtime` polyfill.
9
- //
10
- // It is intentionally NARROWER than "does the program have an async function?"
11
- // An `async function` whose body only does `await delay(ms)` lowers to a
12
- // pure millis()-polling state machine (see emit/utils/async-state-machine.ts)
13
- // that touches NONE of these symbols — so it needs the AsyncTaskClass (gated
14
- // separately on fn.isAsync) but NOT the Promise runtime. Conflating the two
15
- // pulls ~250 lines of dead Promise/microtask code into every such sketch.
16
- //
17
- // Both framework strategies (Arduino, Zephyr) previously carried a private
18
- // copy of this walk; this shared version de-duplicates them and is also used
19
- // centrally by emit/emitters/setup.ts to filter the polyfill id.
20
- // ---------------------------------------------------------------------------
21
- /** Tokens that only exist in the cooperative Promise/microtask runtime. */
22
- const ASYNC_RUNTIME_TOKENS = [
23
- "__cuttlefish_async_", // Async.sleep / Async.yield / Async.sleepUntil / Async.currentTask
24
- "__cuttlefish_wait_pin_edge", // HAL edge-wait helper (polling-based Promise impl)
25
- "enqueueMicrotask", // MicrotaskQueue::enqueue alias
26
- "cuttlefish_pump_microtasks", // loop() injection target
27
- "typecad_async::", // direct namespace qualification
28
- "Promise<", // Promise<T> / Promise<void> instantiation
29
- ];
30
- /** True if `text` references any async-runtime symbol. */
31
- function referencesAsyncSymbol(text) {
32
- for (const tok of ASYNC_RUNTIME_TOKENS) {
33
- if (text.includes(tok))
34
- return true;
35
- }
36
- return false;
37
- }
38
- /**
39
- * Walk a program's IR and return true if ANY statement or expression references
40
- * a cooperative-runtime symbol. Short-circuits on the first hit.
41
- *
42
- * Inspects the same node shapes the duplicated framework-strategy walkers did:
43
- * `raw` expressions, `hal-expr`/`hal-op` nodes whose operation carries raw
44
- * `code`, and any `raw`-kind subtree. Covers both the statement and expression
45
- * IR trees.
46
- */
47
- export function programUsesAsyncRuntimeSymbols(program) {
48
- const FOUND = {};
49
- const seen = new Set();
50
- const walkExpr = (expr) => {
51
- if (!expr || typeof expr !== "object")
52
- return;
53
- if (seen.has(expr))
54
- return;
55
- seen.add(expr);
56
- const e = expr;
57
- if (e.kind === "raw" && typeof e.value === "string" && referencesAsyncSymbol(e.value)) {
58
- throw FOUND;
59
- }
60
- // HAL method calls that lower via rawCpp() become `hal-expr` nodes whose
61
- // `operation` is { operation: "raw", code: "..." }. The Async singleton's
62
- // methods (sleep/yield/sleepUntil/currentTask) land here.
63
- if (e.kind === "hal-expr" && e.operation && typeof e.operation === "object") {
64
- const op = e.operation;
65
- if (op.operation === "raw" && typeof op.code === "string" && referencesAsyncSymbol(op.code)) {
66
- throw FOUND;
67
- }
68
- }
69
- for (const v of Object.values(e)) {
70
- if (Array.isArray(v)) {
71
- for (const item of v) {
72
- if (item && typeof item === "object") {
73
- if ("kind" in item && typeof item.kind === "string") {
74
- walkExpr(item);
75
- }
76
- else {
77
- walkStmt(item);
78
- }
79
- }
80
- }
81
- }
82
- else if (v && typeof v === "object" && "kind" in v && typeof v.kind === "string") {
83
- walkExpr(v);
84
- }
85
- }
86
- };
87
- const walkStmt = (stmt) => {
88
- if (!stmt || typeof stmt !== "object")
89
- return;
90
- if (seen.has(stmt))
91
- return;
92
- seen.add(stmt);
93
- const s = stmt;
94
- // HAL method calls that lower via rawCpp() become `hal-op` statements whose
95
- // `operation` is { operation: "raw", code: "..." }. The Async singleton's
96
- // methods land here at statement level.
97
- if (s.kind === "hal-op" && s.operation && typeof s.operation === "object") {
98
- const op = s.operation;
99
- if (op.operation === "raw" && typeof op.code === "string" && referencesAsyncSymbol(op.code)) {
100
- throw FOUND;
101
- }
102
- }
103
- for (const v of Object.values(s)) {
104
- if (Array.isArray(v)) {
105
- for (const item of v) {
106
- if (item && typeof item === "object") {
107
- if ("body" in item || "statements" in item || "thenBranch" in item || "cases" in item) {
108
- walkStmt(item);
109
- }
110
- else if ("kind" in item && typeof item.kind === "string") {
111
- walkExpr(item);
112
- }
113
- }
114
- }
115
- }
116
- else if (v && typeof v === "object" && "kind" in v && typeof v.kind === "string") {
117
- walkExpr(v);
118
- }
119
- else if (v && typeof v === "object") {
120
- walkStmt(v);
121
- }
122
- }
123
- };
124
- try {
125
- for (const fn of program.functions) {
126
- for (const stmt of fn.statements)
127
- walkStmt(stmt);
128
- }
129
- // Top-level statements (outside any function) — e.g. a bare Async.sleep()
130
- // called from setup-level code.
131
- for (const stmt of program.topLevelStatements)
132
- walkStmt(stmt);
133
- }
134
- catch (e) {
135
- if (e === FOUND)
136
- return true;
137
- throw e;
138
- }
139
- return false;
140
- }
@@ -1,10 +0,0 @@
1
- import type { DisplayHALOp } from "./display-op-ir.js";
2
- /**
3
- * Resolve a display HAL op to a call into the native adapter surface
4
- * (display_init / display_targetFillRect / etc.). Returns undefined for ops
5
- * this resolver does not handle.
6
- */
7
- export declare function resolveNativeDisplayOp(op: DisplayHALOp): {
8
- code?: string;
9
- expression?: string;
10
- } | undefined;
@@ -1,64 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- // Shared display-op resolver for native (non-Arduino) display strategies.
3
- //
4
- // Both NativeAVRStrategy and Esp32Strategy override resolveDisplayOp to return
5
- // undefined for display.* ops (the design intent: display ops are resolved
6
- // through the adapter path, not per-op HAL lowering). But the HAL lowering
7
- // layer still calls resolveDisplayOp for every display.* op emitted by user
8
- // code (display.init via ui.mount, display.fill_rect/draw_rect/draw_text via
9
- // direct HAL calls, display.flush per frame).
10
- //
11
- // Those ops need to lower to CALLS INTO the adapter surface — the same
12
- // display_init() / display_targetFillRect() / etc. functions the Adafruit
13
- // path calls. The native adapters emit those functions with identical
14
- // signatures, so the lowering is identical across native strategies.
15
- //
16
- // This module provides that lowering. Each native strategy's resolveDisplayOp
17
- // delegates here instead of returning undefined.
18
- // ---------------------------------------------------------------------------
19
- /** Render a color value as a C++ hex literal (e.g. 0x07e0) for readable RGB565. */
20
- function hexColor(c) {
21
- return `0x${c.toString(16)}`;
22
- }
23
- /**
24
- * Resolve a display HAL op to a call into the native adapter surface
25
- * (display_init / display_targetFillRect / etc.). Returns undefined for ops
26
- * this resolver does not handle.
27
- */
28
- export function resolveNativeDisplayOp(op) {
29
- switch (op.operation) {
30
- case "display.init":
31
- // The adapter's display_init() does bus setup, panel init sequence,
32
- // rotation, and the initial fillScreen. No backlight GPIO parameter
33
- // on native paths — the Adafruit-style backlight pin is handled in
34
- // the mount config if needed.
35
- return { code: `display_init();` };
36
- case "display.fill_rect":
37
- // Delegate to the polymorphic target draw so the same call works
38
- // whether the active target is the panel or an offscreen canvas.
39
- return {
40
- code: `display_targetFillRect(display_defaultTarget(), ${op.x}, ${op.y}, ${op.w}, ${op.h}, ${hexColor(op.color)});`,
41
- };
42
- case "display.draw_rect":
43
- return {
44
- code: `display_targetDrawRect(display_defaultTarget(), ${op.x}, ${op.y}, ${op.w}, ${op.h}, ${hexColor(op.color)});`,
45
- };
46
- case "display.draw_text":
47
- return {
48
- code: [
49
- `display_targetSetCursor(display_defaultTarget(), ${op.x}, ${op.y});`,
50
- `display_targetSetTextColor(display_defaultTarget(), ${hexColor(op.color)});`,
51
- `display_targetSetTextSize(display_defaultTarget(), 2);`,
52
- `display_targetPrint(display_defaultTarget(), ${JSON.stringify(op.text)});`,
53
- ].join("\n"),
54
- };
55
- case "display.flush":
56
- // Direct-mode panels (ILI9341, ST7796S) draw immediately — no flush.
57
- // Buffered panels (SSD1309) flush via display_partial_refresh, which
58
- // the runtime calls through display_partial_refresh directly (not via
59
- // HAL op) at frame end.
60
- return { code: `/* flush: ${op.rects.length} rect(s) — native display */` };
61
- default:
62
- return undefined;
63
- }
64
- }
@@ -1,2 +0,0 @@
1
- import type { BoardSpec } from './board-spec.js';
2
- export declare function generateFrameworkChecklist(spec: BoardSpec): string;