@typecad/cuttlefish 0.1.0-alpha.1

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 (377) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +79 -0
  3. package/dist/api/board-types.d.ts +1 -0
  4. package/dist/api/board-types.js +4 -0
  5. package/dist/api/capabilities.d.ts +12 -0
  6. package/dist/api/capabilities.js +1 -0
  7. package/dist/api/config.d.ts +120 -0
  8. package/dist/api/config.js +7 -0
  9. package/dist/api/index.d.ts +5 -0
  10. package/dist/api/index.js +2 -0
  11. package/dist/api/schema/builder.d.ts +14 -0
  12. package/dist/api/schema/builder.js +15 -0
  13. package/dist/api/schema/index.d.ts +2 -0
  14. package/dist/api/schema/index.js +1 -0
  15. package/dist/api/schema/types.d.ts +257 -0
  16. package/dist/api/schema/types.js +4 -0
  17. package/dist/api/shared/async-runtime-static.d.ts +8 -0
  18. package/dist/api/shared/async-runtime-static.js +201 -0
  19. package/dist/api/shared/async-types.d.ts +42 -0
  20. package/dist/api/shared/async-types.js +8 -0
  21. package/dist/api/shared/board-resolver.d.ts +12 -0
  22. package/dist/api/shared/board-resolver.js +7 -0
  23. package/dist/api/shared/cpp-type-ir.d.ts +229 -0
  24. package/dist/api/shared/cpp-type-ir.js +672 -0
  25. package/dist/api/shared/display-adapter.d.ts +12 -0
  26. package/dist/api/shared/display-adapter.js +145 -0
  27. package/dist/api/shared/display-adapters/eink-mono.d.ts +2 -0
  28. package/dist/api/shared/display-adapters/eink-mono.js +53 -0
  29. package/dist/api/shared/display-adapters/sdl.d.ts +2 -0
  30. package/dist/api/shared/display-adapters/sdl.js +452 -0
  31. package/dist/api/shared/display-adapters/ssd1309.d.ts +2 -0
  32. package/dist/api/shared/display-adapters/ssd1309.js +136 -0
  33. package/dist/api/shared/display-adapters/st7796.d.ts +2 -0
  34. package/dist/api/shared/display-adapters/st7796.js +132 -0
  35. package/dist/api/shared/display-capabilities.d.ts +45 -0
  36. package/dist/api/shared/display-capabilities.js +54 -0
  37. package/dist/api/shared/display-op-ir.d.ts +62 -0
  38. package/dist/api/shared/display-op-ir.js +19 -0
  39. package/dist/api/shared/display-profile.d.ts +265 -0
  40. package/dist/api/shared/display-profile.js +338 -0
  41. package/dist/api/shared/graphics-strategy.d.ts +29 -0
  42. package/dist/api/shared/graphics-strategy.js +11 -0
  43. package/dist/api/shared/hal-op-ir.d.ts +393 -0
  44. package/dist/api/shared/hal-op-ir.js +18 -0
  45. package/dist/api/shared/index.d.ts +26 -0
  46. package/dist/api/shared/index.js +21 -0
  47. package/dist/api/shared/ir-core.d.ts +363 -0
  48. package/dist/api/shared/ir-core.js +8 -0
  49. package/dist/api/shared/ir-declarations.d.ts +201 -0
  50. package/dist/api/shared/ir-declarations.js +26 -0
  51. package/dist/api/shared/ir.d.ts +85 -0
  52. package/dist/api/shared/ir.js +13 -0
  53. package/dist/api/shared/platform-strategy.d.ts +402 -0
  54. package/dist/api/shared/platform-strategy.js +14 -0
  55. package/dist/api/shared/polyfill-helper-registry.d.ts +11 -0
  56. package/dist/api/shared/polyfill-helper-registry.js +86 -0
  57. package/dist/api/shared/polyfill-types.d.ts +33 -0
  58. package/dist/api/shared/polyfill-types.js +76 -0
  59. package/dist/api/shared/promise-runtime.d.ts +10 -0
  60. package/dist/api/shared/promise-runtime.js +244 -0
  61. package/dist/api/shared/snprintf-types.d.ts +29 -0
  62. package/dist/api/shared/snprintf-types.js +8 -0
  63. package/dist/api/shared/string-method-registry.d.ts +53 -0
  64. package/dist/api/shared/string-method-registry.js +168 -0
  65. package/dist/api/shared/toolchain-types.d.ts +63 -0
  66. package/dist/api/shared/toolchain-types.js +71 -0
  67. package/dist/api/shared/types.d.ts +50 -0
  68. package/dist/api/shared/types.js +6 -0
  69. package/dist/ast/parse.d.ts +2 -0
  70. package/dist/ast/parse.js +4 -0
  71. package/dist/cache.d.ts +26 -0
  72. package/dist/cache.js +95 -0
  73. package/dist/cli-utils.d.ts +37 -0
  74. package/dist/cli-utils.js +250 -0
  75. package/dist/cli.d.ts +2 -0
  76. package/dist/cli.js +635 -0
  77. package/dist/config-loader.d.ts +78 -0
  78. package/dist/config-loader.js +508 -0
  79. package/dist/config-schema.d.ts +233 -0
  80. package/dist/config-schema.js +83 -0
  81. package/dist/create/board-checklist.d.ts +2 -0
  82. package/dist/create/board-checklist.js +52 -0
  83. package/dist/create/board-codegen.d.ts +9 -0
  84. package/dist/create/board-codegen.js +238 -0
  85. package/dist/create/board-generators.d.ts +12 -0
  86. package/dist/create/board-generators.js +652 -0
  87. package/dist/create/board-spec.d.ts +640 -0
  88. package/dist/create/board-spec.js +215 -0
  89. package/dist/create/eslint-rules-template.d.ts +2 -0
  90. package/dist/create/eslint-rules-template.js +672 -0
  91. package/dist/create/index.d.ts +11 -0
  92. package/dist/create/index.js +8 -0
  93. package/dist/create/init-scaffold.d.ts +27 -0
  94. package/dist/create/init-scaffold.js +150 -0
  95. package/dist/create/init-templates.d.ts +24 -0
  96. package/dist/create/init-templates.js +379 -0
  97. package/dist/create/init-wizard.d.ts +8 -0
  98. package/dist/create/init-wizard.js +168 -0
  99. package/dist/debug/breakpoint-loader.d.ts +24 -0
  100. package/dist/debug/breakpoint-loader.js +137 -0
  101. package/dist/debug/index.d.ts +3 -0
  102. package/dist/debug/index.js +7 -0
  103. package/dist/debug/preprocessor.d.ts +9 -0
  104. package/dist/debug/preprocessor.js +214 -0
  105. package/dist/debug/types.d.ts +32 -0
  106. package/dist/debug/types.js +6 -0
  107. package/dist/diagnostics/diagnostics-report.d.ts +51 -0
  108. package/dist/diagnostics/diagnostics-report.js +333 -0
  109. package/dist/diagnostics/json-schema.d.ts +138 -0
  110. package/dist/diagnostics/json-schema.js +27 -0
  111. package/dist/diagnostics/md-writer.d.ts +10 -0
  112. package/dist/diagnostics/md-writer.js +336 -0
  113. package/dist/diagnostics/mermaid-builder.d.ts +65 -0
  114. package/dist/diagnostics/mermaid-builder.js +681 -0
  115. package/dist/emit/cpp-emitter.d.ts +6 -0
  116. package/dist/emit/cpp-emitter.js +48 -0
  117. package/dist/emit/emitters/class-emitter.d.ts +2 -0
  118. package/dist/emit/emitters/class-emitter.js +523 -0
  119. package/dist/emit/emitters/emitter-context.d.ts +174 -0
  120. package/dist/emit/emitters/emitter-context.js +1 -0
  121. package/dist/emit/emitters/entrypoint-synthesizer.d.ts +2 -0
  122. package/dist/emit/emitters/entrypoint-synthesizer.js +175 -0
  123. package/dist/emit/emitters/function-emitter-impl.d.ts +19 -0
  124. package/dist/emit/emitters/function-emitter-impl.js +428 -0
  125. package/dist/emit/emitters/line-appender.d.ts +15 -0
  126. package/dist/emit/emitters/line-appender.js +344 -0
  127. package/dist/emit/emitters/namespace-emitter.d.ts +2 -0
  128. package/dist/emit/emitters/namespace-emitter.js +324 -0
  129. package/dist/emit/emitters/output-finalizer.d.ts +4 -0
  130. package/dist/emit/emitters/output-finalizer.js +267 -0
  131. package/dist/emit/emitters/setup.d.ts +3 -0
  132. package/dist/emit/emitters/setup.js +851 -0
  133. package/dist/emit/emitters/top-level-prep.d.ts +2 -0
  134. package/dist/emit/emitters/top-level-prep.js +706 -0
  135. package/dist/emit/emitters/type-decl-emitter.d.ts +2 -0
  136. package/dist/emit/emitters/type-decl-emitter.js +251 -0
  137. package/dist/emit/emitters/ui-emitter.d.ts +21 -0
  138. package/dist/emit/emitters/ui-emitter.js +564 -0
  139. package/dist/emit/enum-emitter.d.ts +1 -0
  140. package/dist/emit/enum-emitter.js +1 -0
  141. package/dist/emit/expression-renderer.d.ts +283 -0
  142. package/dist/emit/expression-renderer.js +1477 -0
  143. package/dist/emit/native-helpers-emitter.d.ts +11 -0
  144. package/dist/emit/native-helpers-emitter.js +34 -0
  145. package/dist/emit/route-hal-op.d.ts +5 -0
  146. package/dist/emit/route-hal-op.js +13 -0
  147. package/dist/emit/snprintf-helpers.d.ts +17 -0
  148. package/dist/emit/snprintf-helpers.js +462 -0
  149. package/dist/emit/statement-renderer.d.ts +189 -0
  150. package/dist/emit/statement-renderer.js +948 -0
  151. package/dist/emit/utils/async-state-machine.d.ts +42 -0
  152. package/dist/emit/utils/async-state-machine.js +343 -0
  153. package/dist/emit/utils/comment-helpers.d.ts +20 -0
  154. package/dist/emit/utils/comment-helpers.js +31 -0
  155. package/dist/emit/utils/cpp-helpers.d.ts +47 -0
  156. package/dist/emit/utils/cpp-helpers.js +85 -0
  157. package/dist/emit/utils/include-resolver.d.ts +58 -0
  158. package/dist/emit/utils/include-resolver.js +155 -0
  159. package/dist/emit/utils/index.d.ts +8 -0
  160. package/dist/emit/utils/index.js +12 -0
  161. package/dist/emit/utils/type-inference.d.ts +159 -0
  162. package/dist/emit/utils/type-inference.js +559 -0
  163. package/dist/eslint-check.d.ts +10 -0
  164. package/dist/eslint-check.js +102 -0
  165. package/dist/framework-package.d.ts +10 -0
  166. package/dist/framework-package.js +58 -0
  167. package/dist/framework-registry.d.ts +39 -0
  168. package/dist/framework-registry.js +30 -0
  169. package/dist/incremental-cache.d.ts +116 -0
  170. package/dist/incremental-cache.js +335 -0
  171. package/dist/ir/adc-range-validation.d.ts +11 -0
  172. package/dist/ir/adc-range-validation.js +250 -0
  173. package/dist/ir/ast-node-utils.d.ts +8 -0
  174. package/dist/ir/ast-node-utils.js +32 -0
  175. package/dist/ir/board-pin-utils.d.ts +13 -0
  176. package/dist/ir/board-pin-utils.js +65 -0
  177. package/dist/ir/board-resolver.d.ts +36 -0
  178. package/dist/ir/board-resolver.js +437 -0
  179. package/dist/ir/build-ir-state.d.ts +167 -0
  180. package/dist/ir/build-ir-state.js +306 -0
  181. package/dist/ir/build-ir.d.ts +2 -0
  182. package/dist/ir/build-ir.js +808 -0
  183. package/dist/ir/call-graph.d.ts +35 -0
  184. package/dist/ir/call-graph.js +194 -0
  185. package/dist/ir/compile-time-only.d.ts +2 -0
  186. package/dist/ir/compile-time-only.js +16 -0
  187. package/dist/ir/declaration-builders.d.ts +9 -0
  188. package/dist/ir/declaration-builders.js +608 -0
  189. package/dist/ir/entry-points.d.ts +30 -0
  190. package/dist/ir/entry-points.js +191 -0
  191. package/dist/ir/expression-to-ir.d.ts +5 -0
  192. package/dist/ir/expression-to-ir.js +2249 -0
  193. package/dist/ir/extract-property-chain.d.ts +10 -0
  194. package/dist/ir/extract-property-chain.js +30 -0
  195. package/dist/ir/feature-prescan.d.ts +3 -0
  196. package/dist/ir/feature-prescan.js +43 -0
  197. package/dist/ir/feature-registry.d.ts +30 -0
  198. package/dist/ir/feature-registry.js +816 -0
  199. package/dist/ir/filter.d.ts +7 -0
  200. package/dist/ir/filter.js +85 -0
  201. package/dist/ir/function-builder.d.ts +19 -0
  202. package/dist/ir/function-builder.js +670 -0
  203. package/dist/ir/hal/hal-emitter.d.ts +62 -0
  204. package/dist/ir/hal/hal-emitter.js +735 -0
  205. package/dist/ir/hal/hal-parser.d.ts +61 -0
  206. package/dist/ir/hal/hal-parser.js +473 -0
  207. package/dist/ir/hal/hal-plugins.d.ts +34 -0
  208. package/dist/ir/hal/hal-plugins.js +706 -0
  209. package/dist/ir/hal-resolver.d.ts +5 -0
  210. package/dist/ir/hal-resolver.js +5 -0
  211. package/dist/ir/heap-analysis.d.ts +8 -0
  212. package/dist/ir/heap-analysis.js +350 -0
  213. package/dist/ir/heap-array-validation.d.ts +24 -0
  214. package/dist/ir/heap-array-validation.js +29 -0
  215. package/dist/ir/identifier-collector.d.ts +18 -0
  216. package/dist/ir/identifier-collector.js +439 -0
  217. package/dist/ir/interrupt-analysis.d.ts +39 -0
  218. package/dist/ir/interrupt-analysis.js +467 -0
  219. package/dist/ir/memory-budget-validation.d.ts +10 -0
  220. package/dist/ir/memory-budget-validation.js +86 -0
  221. package/dist/ir/namespace-builder.d.ts +7 -0
  222. package/dist/ir/namespace-builder.js +152 -0
  223. package/dist/ir/ownership-analysis.d.ts +9 -0
  224. package/dist/ir/ownership-analysis.js +1207 -0
  225. package/dist/ir/peripheral-ownership.d.ts +3 -0
  226. package/dist/ir/peripheral-ownership.js +152 -0
  227. package/dist/ir/peripheral-symbols.d.ts +7 -0
  228. package/dist/ir/peripheral-symbols.js +57 -0
  229. package/dist/ir/peripheral-usage.d.ts +54 -0
  230. package/dist/ir/peripheral-usage.js +691 -0
  231. package/dist/ir/peripheral-validation.d.ts +8 -0
  232. package/dist/ir/peripheral-validation.js +77 -0
  233. package/dist/ir/pin-alias-conflict.d.ts +4 -0
  234. package/dist/ir/pin-alias-conflict.js +34 -0
  235. package/dist/ir/pin-capability-validation.d.ts +6 -0
  236. package/dist/ir/pin-capability-validation.js +413 -0
  237. package/dist/ir/pin-mode-validation.d.ts +10 -0
  238. package/dist/ir/pin-mode-validation.js +301 -0
  239. package/dist/ir/pin-safety.d.ts +11 -0
  240. package/dist/ir/pin-safety.js +58 -0
  241. package/dist/ir/program-analysis.d.ts +44 -0
  242. package/dist/ir/program-analysis.js +589 -0
  243. package/dist/ir/pulldown-validation.d.ts +7 -0
  244. package/dist/ir/pulldown-validation.js +49 -0
  245. package/dist/ir/pwm-timer-sharing.d.ts +4 -0
  246. package/dist/ir/pwm-timer-sharing.js +93 -0
  247. package/dist/ir/reachability.d.ts +68 -0
  248. package/dist/ir/reachability.js +224 -0
  249. package/dist/ir/register-decorators.d.ts +6 -0
  250. package/dist/ir/register-decorators.js +49 -0
  251. package/dist/ir/render-expr.d.ts +4 -0
  252. package/dist/ir/render-expr.js +127 -0
  253. package/dist/ir/resource-analysis.d.ts +19 -0
  254. package/dist/ir/resource-analysis.js +153 -0
  255. package/dist/ir/statement-to-ir.d.ts +23 -0
  256. package/dist/ir/statement-to-ir.js +349 -0
  257. package/dist/ir/symbol-table.d.ts +68 -0
  258. package/dist/ir/symbol-table.js +179 -0
  259. package/dist/ir/symbol-types.d.ts +56 -0
  260. package/dist/ir/symbol-types.js +107 -0
  261. package/dist/ir/timer0-pwm-timing-conflict.d.ts +4 -0
  262. package/dist/ir/timer0-pwm-timing-conflict.js +71 -0
  263. package/dist/ir/timing-validation.d.ts +7 -0
  264. package/dist/ir/timing-validation.js +95 -0
  265. package/dist/ir/transformers/array-methods.d.ts +8 -0
  266. package/dist/ir/transformers/array-methods.js +493 -0
  267. package/dist/ir/transformers/call-statement.d.ts +5 -0
  268. package/dist/ir/transformers/call-statement.js +758 -0
  269. package/dist/ir/transformers/callback-context-registry.d.ts +20 -0
  270. package/dist/ir/transformers/callback-context-registry.js +55 -0
  271. package/dist/ir/transformers/canvas-lowering.d.ts +42 -0
  272. package/dist/ir/transformers/canvas-lowering.js +249 -0
  273. package/dist/ir/transformers/control-flow.d.ts +8 -0
  274. package/dist/ir/transformers/control-flow.js +508 -0
  275. package/dist/ir/transformers/expressions.d.ts +7 -0
  276. package/dist/ir/transformers/expressions.js +406 -0
  277. package/dist/ir/transformers/hal-call-resolver.d.ts +29 -0
  278. package/dist/ir/transformers/hal-call-resolver.js +274 -0
  279. package/dist/ir/transformers/hal-emit-helpers.d.ts +14 -0
  280. package/dist/ir/transformers/hal-emit-helpers.js +63 -0
  281. package/dist/ir/transformers/namespace-methods.d.ts +20 -0
  282. package/dist/ir/transformers/namespace-methods.js +110 -0
  283. package/dist/ir/transformers/register-assignment.d.ts +5 -0
  284. package/dist/ir/transformers/register-assignment.js +56 -0
  285. package/dist/ir/transformers/ui-call-resolver.d.ts +149 -0
  286. package/dist/ir/transformers/ui-call-resolver.js +1136 -0
  287. package/dist/ir/transformers/ui-callback-lowering.d.ts +62 -0
  288. package/dist/ir/transformers/ui-callback-lowering.js +623 -0
  289. package/dist/ir/transformers/ui-mount.d.ts +20 -0
  290. package/dist/ir/transformers/ui-mount.js +35 -0
  291. package/dist/ir/transformers/ui-reactive.d.ts +68 -0
  292. package/dist/ir/transformers/ui-reactive.js +129 -0
  293. package/dist/ir/transformers/variables.d.ts +14 -0
  294. package/dist/ir/transformers/variables.js +1045 -0
  295. package/dist/ir/try-catch-validation.d.ts +26 -0
  296. package/dist/ir/try-catch-validation.js +128 -0
  297. package/dist/ir/type-resolution.d.ts +31 -0
  298. package/dist/ir/type-resolution.js +977 -0
  299. package/dist/ir/ui-element-auto-wire.d.ts +50 -0
  300. package/dist/ir/ui-element-auto-wire.js +218 -0
  301. package/dist/ir/unit-suspicion-validation.d.ts +12 -0
  302. package/dist/ir/unit-suspicion-validation.js +296 -0
  303. package/dist/ir/utils/walk-ir.d.ts +6 -0
  304. package/dist/ir/utils/walk-ir.js +162 -0
  305. package/dist/ir/validation-orchestrator.d.ts +4 -0
  306. package/dist/ir/validation-orchestrator.js +45 -0
  307. package/dist/libdef/base-class-resolver.d.ts +23 -0
  308. package/dist/libdef/base-class-resolver.js +50 -0
  309. package/dist/libdef/cpp-to-decl.d.ts +34 -0
  310. package/dist/libdef/cpp-to-decl.js +584 -0
  311. package/dist/libdef/header-parser.d.ts +53 -0
  312. package/dist/libdef/header-parser.js +269 -0
  313. package/dist/libdef/registry.d.ts +10 -0
  314. package/dist/libdef/registry.js +142 -0
  315. package/dist/mapping/peripheral-names.d.ts +23 -0
  316. package/dist/mapping/peripheral-names.js +63 -0
  317. package/dist/mapping/source-map.d.ts +46 -0
  318. package/dist/mapping/source-map.js +207 -0
  319. package/dist/orchestrator/dts-generator.d.ts +17 -0
  320. package/dist/orchestrator/dts-generator.js +83 -0
  321. package/dist/orchestrator/graph-builder.d.ts +18 -0
  322. package/dist/orchestrator/graph-builder.js +218 -0
  323. package/dist/orchestrator/semantic-facts-verifier.d.ts +38 -0
  324. package/dist/orchestrator/semantic-facts-verifier.js +121 -0
  325. package/dist/orchestrator/semantic-facts.d.ts +141 -0
  326. package/dist/orchestrator/semantic-facts.js +652 -0
  327. package/dist/orchestrator/type-checker.d.ts +39 -0
  328. package/dist/orchestrator/type-checker.js +760 -0
  329. package/dist/platform/async-runtime.d.ts +8 -0
  330. package/dist/platform/async-runtime.js +26 -0
  331. package/dist/platform/generic-strategy.d.ts +101 -0
  332. package/dist/platform/generic-strategy.js +289 -0
  333. package/dist/platform/index.d.ts +4 -0
  334. package/dist/platform/index.js +9 -0
  335. package/dist/platform/registry.d.ts +21 -0
  336. package/dist/platform/registry.js +42 -0
  337. package/dist/platform/toolchain.d.ts +4 -0
  338. package/dist/platform/toolchain.js +43 -0
  339. package/dist/preview/client.d.ts +1 -0
  340. package/dist/preview/client.js +137 -0
  341. package/dist/preview/server.d.ts +5 -0
  342. package/dist/preview/server.js +199 -0
  343. package/dist/profiler/index.d.ts +28 -0
  344. package/dist/profiler/index.js +28 -0
  345. package/dist/profiler/profiler.d.ts +95 -0
  346. package/dist/profiler/profiler.js +338 -0
  347. package/dist/profiler/types.d.ts +87 -0
  348. package/dist/profiler/types.js +12 -0
  349. package/dist/stores/display-profile-store.d.ts +16 -0
  350. package/dist/stores/display-profile-store.js +48 -0
  351. package/dist/stores/theme-store.d.ts +13 -0
  352. package/dist/stores/theme-store.js +30 -0
  353. package/dist/testing.d.ts +45 -0
  354. package/dist/testing.js +47 -0
  355. package/dist/transpile/resolution.d.ts +29 -0
  356. package/dist/transpile/resolution.js +282 -0
  357. package/dist/transpile.d.ts +3 -0
  358. package/dist/transpile.js +722 -0
  359. package/dist/types.d.ts +217 -0
  360. package/dist/types.js +1 -0
  361. package/dist/ui/ui-bridge.d.ts +4 -0
  362. package/dist/ui/ui-bridge.js +34 -0
  363. package/dist/ui-hook.d.ts +84 -0
  364. package/dist/ui-hook.js +45 -0
  365. package/dist/utils/cli.d.ts +3 -0
  366. package/dist/utils/cli.js +463 -0
  367. package/dist/utils/fs.d.ts +4 -0
  368. package/dist/utils/fs.js +23 -0
  369. package/dist/utils/logger.d.ts +2 -0
  370. package/dist/utils/logger.js +8 -0
  371. package/dist/utils/strings.d.ts +35 -0
  372. package/dist/utils/strings.js +142 -0
  373. package/dist/utils/ui.d.ts +66 -0
  374. package/dist/utils/ui.js +149 -0
  375. package/dist/watch.d.ts +35 -0
  376. package/dist/watch.js +111 -0
  377. package/package.json +127 -0
@@ -0,0 +1,338 @@
1
+ /**
2
+ * Performance profiler for the transpilation pipeline.
3
+ *
4
+ * Usage:
5
+ * const profiler = initProfiler({ enabled: true });
6
+ * profiler.startSession();
7
+ * profiler.timeSync('phase:name', () => { ... });
8
+ * await profiler.timeAsync('phase:async', async () => { ... });
9
+ * const report = profiler.endSession();
10
+ */
11
+ import { performance } from "node:perf_hooks";
12
+ import { DEFAULT_PROFILER_OPTIONS, } from "./types.js";
13
+ export class Profiler {
14
+ constructor(options = {}) {
15
+ this.timings = new Map();
16
+ this.activeTimers = new Map();
17
+ this.memorySnapshots = [];
18
+ this.sessionStart = 0;
19
+ this.parentStack = [];
20
+ this.timerCounter = 0;
21
+ this.enabled = options.enabled ?? DEFAULT_PROFILER_OPTIONS.enabled;
22
+ this.trackMemory = options.trackMemory ?? DEFAULT_PROFILER_OPTIONS.trackMemory;
23
+ this.threshold = options.threshold ?? DEFAULT_PROFILER_OPTIONS.threshold;
24
+ }
25
+ /**
26
+ * Check if profiling is enabled
27
+ */
28
+ isEnabled() {
29
+ return this.enabled;
30
+ }
31
+ /**
32
+ * Start a timing measurement
33
+ */
34
+ startTimer(name, metadata) {
35
+ if (!this.enabled)
36
+ return;
37
+ const uniqueName = `${name}#${this.timerCounter++}`;
38
+ const startTime = performance.now();
39
+ this.activeTimers.set(uniqueName, startTime);
40
+ // Track parent-child relationships
41
+ if (this.parentStack.length > 0) {
42
+ const parentName = this.parentStack[this.parentStack.length - 1];
43
+ const parentEntry = this.timings.get(parentName);
44
+ if (parentEntry) {
45
+ parentEntry.children.push(uniqueName);
46
+ }
47
+ }
48
+ // Store initial entry
49
+ const entry = {
50
+ name: uniqueName,
51
+ startTime,
52
+ endTime: 0,
53
+ duration: 0,
54
+ parent: this.parentStack[this.parentStack.length - 1],
55
+ children: [],
56
+ metadata,
57
+ };
58
+ this.timings.set(uniqueName, entry);
59
+ if (this.trackMemory) {
60
+ this.captureMemorySnapshot(`${name}:start`);
61
+ }
62
+ }
63
+ /**
64
+ * End a timing measurement
65
+ */
66
+ endTimer(name) {
67
+ if (!this.enabled)
68
+ return 0;
69
+ // Find the most recent timer with this base name
70
+ let uniqueName;
71
+ for (const [key] of [...this.timings.entries()].reverse()) {
72
+ if (key.startsWith(`${name}#`)) {
73
+ uniqueName = key;
74
+ break;
75
+ }
76
+ }
77
+ if (!uniqueName)
78
+ return 0;
79
+ const entry = this.timings.get(uniqueName);
80
+ if (!entry)
81
+ return 0;
82
+ const endTime = performance.now();
83
+ const duration = endTime - entry.startTime;
84
+ entry.endTime = endTime;
85
+ entry.duration = duration;
86
+ // Remove from active timers
87
+ this.activeTimers.delete(uniqueName);
88
+ // If duration is below threshold, remove the entry
89
+ if (duration < this.threshold) {
90
+ this.timings.delete(uniqueName);
91
+ }
92
+ return duration;
93
+ }
94
+ /**
95
+ * Time a synchronous function
96
+ */
97
+ timeSync(name, fn, metadata) {
98
+ if (!this.enabled)
99
+ return fn();
100
+ const uniqueName = `${name}#${this.timerCounter}`;
101
+ this.startTimer(name, metadata);
102
+ this.parentStack.push(uniqueName);
103
+ try {
104
+ const result = fn();
105
+ return result;
106
+ }
107
+ finally {
108
+ this.parentStack.pop();
109
+ this.endTimer(name);
110
+ }
111
+ }
112
+ /**
113
+ * Time an asynchronous function
114
+ */
115
+ async timeAsync(name, fn, metadata) {
116
+ if (!this.enabled)
117
+ return fn();
118
+ const uniqueName = `${name}#${this.timerCounter}`;
119
+ this.startTimer(name, metadata);
120
+ this.parentStack.push(uniqueName);
121
+ try {
122
+ const result = await fn();
123
+ return result;
124
+ }
125
+ finally {
126
+ this.parentStack.pop();
127
+ this.endTimer(name);
128
+ }
129
+ }
130
+ /**
131
+ * Capture a memory snapshot
132
+ */
133
+ captureMemorySnapshot(name) {
134
+ if (!this.enabled || !this.trackMemory)
135
+ return;
136
+ const mem = process.memoryUsage();
137
+ this.memorySnapshots.push({
138
+ name,
139
+ timestamp: performance.now(),
140
+ heapUsed: mem.heapUsed,
141
+ heapTotal: mem.heapTotal,
142
+ external: mem.external,
143
+ });
144
+ }
145
+ /**
146
+ * Start a profiling session
147
+ */
148
+ startSession() {
149
+ if (!this.enabled)
150
+ return;
151
+ this.sessionStart = performance.now();
152
+ this.timings.clear();
153
+ this.memorySnapshots = [];
154
+ this.parentStack = [];
155
+ this.timerCounter = 0;
156
+ this.captureMemorySnapshot("session:start");
157
+ }
158
+ /**
159
+ * End a profiling session and return the session data
160
+ */
161
+ endSession() {
162
+ const endTime = performance.now();
163
+ this.captureMemorySnapshot("session:end");
164
+ const phaseStats = this.computePhaseStatistics(endTime - this.sessionStart);
165
+ return {
166
+ startTime: this.sessionStart,
167
+ endTime,
168
+ totalDuration: endTime - this.sessionStart,
169
+ timings: new Map(this.timings),
170
+ memorySnapshots: [...this.memorySnapshots],
171
+ phaseStats,
172
+ };
173
+ }
174
+ /**
175
+ * Compute aggregated statistics by phase
176
+ */
177
+ computePhaseStatistics(totalDuration) {
178
+ const phaseMap = new Map();
179
+ for (const [, entry] of this.timings) {
180
+ // Extract base phase name (remove counter suffix and file-specific parts)
181
+ const basePhase = this.extractBasePhase(entry.name);
182
+ const existing = phaseMap.get(basePhase);
183
+ if (existing) {
184
+ existing.total += entry.duration;
185
+ existing.count++;
186
+ existing.min = Math.min(existing.min, entry.duration);
187
+ existing.max = Math.max(existing.max, entry.duration);
188
+ }
189
+ else {
190
+ phaseMap.set(basePhase, {
191
+ total: entry.duration,
192
+ count: 1,
193
+ min: entry.duration,
194
+ max: entry.duration,
195
+ });
196
+ }
197
+ }
198
+ const stats = [];
199
+ for (const [phase, data] of phaseMap) {
200
+ stats.push({
201
+ phase,
202
+ totalDuration: data.total,
203
+ callCount: data.count,
204
+ avgDuration: data.total / data.count,
205
+ minDuration: data.min,
206
+ maxDuration: data.max,
207
+ percentageOfTotal: totalDuration > 0 ? (data.total / totalDuration) * 100 : 0,
208
+ });
209
+ }
210
+ // Sort by total duration descending
211
+ stats.sort((a, b) => b.totalDuration - a.totalDuration);
212
+ return stats;
213
+ }
214
+ /**
215
+ * Extract the base phase name from a timer name
216
+ */
217
+ extractBasePhase(name) {
218
+ // Remove counter suffix (e.g., "phase#123" -> "phase")
219
+ let base = name.replace(/#\d+$/, "");
220
+ return base;
221
+ }
222
+ /**
223
+ * Generate a profiler report from a session
224
+ */
225
+ generateReport(session) {
226
+ const bottlenecks = this.identifyBottlenecks(session);
227
+ const recommendations = this.generateRecommendations(session, bottlenecks);
228
+ return {
229
+ session,
230
+ summary: this.generateSummary(session),
231
+ bottlenecks,
232
+ recommendations,
233
+ };
234
+ }
235
+ /**
236
+ * Identify phases that are bottlenecks (>10% of total time)
237
+ */
238
+ identifyBottlenecks(session) {
239
+ const bottlenecks = [];
240
+ const threshold = session.totalDuration * 0.1; // 10% threshold
241
+ for (const stat of session.phaseStats) {
242
+ if (stat.totalDuration > threshold) {
243
+ bottlenecks.push(`${stat.phase}: ${stat.totalDuration.toFixed(2)}ms (${stat.percentageOfTotal.toFixed(1)}%)`);
244
+ }
245
+ }
246
+ return bottlenecks;
247
+ }
248
+ /**
249
+ * Generate optimization recommendations based on profiling data
250
+ */
251
+ generateRecommendations(session, bottlenecks) {
252
+ const recommendations = new Set();
253
+ for (const stat of session.phaseStats) {
254
+ // Type-checking recommendations
255
+ if (stat.phase.includes("typecheck") && stat.percentageOfTotal > 30) {
256
+ recommendations.add("Consider using --skipTypeCheck during development for faster iteration");
257
+ }
258
+ // IR building recommendations
259
+ if (stat.phase.includes("ir:build") && stat.percentageOfTotal > 25) {
260
+ recommendations.add("IR building is slow - check if incremental cache is working properly");
261
+ }
262
+ // Emission recommendations
263
+ if (stat.phase.includes("emit") && stat.percentageOfTotal > 40) {
264
+ recommendations.add("Emission phase is slow - consider optimizing emitter or reducing output complexity");
265
+ }
266
+ // Graph collection recommendations
267
+ if (stat.phase.includes("graph:collect") && stat.percentageOfTotal > 15) {
268
+ recommendations.add("Graph collection is slow - consider caching import resolution results");
269
+ }
270
+ }
271
+ // Memory recommendations
272
+ if (session.memorySnapshots.length > 1) {
273
+ const startMem = session.memorySnapshots[0];
274
+ const endMem = session.memorySnapshots[session.memorySnapshots.length - 1];
275
+ const memDelta = endMem.heapUsed - startMem.heapUsed;
276
+ if (memDelta > 100 * 1024 * 1024) {
277
+ // > 100MB
278
+ recommendations.add(`High memory usage (${(memDelta / 1024 / 1024).toFixed(0)}MB delta) - consider streaming large files`);
279
+ }
280
+ }
281
+ return Array.from(recommendations);
282
+ }
283
+ /**
284
+ * Generate a human-readable summary
285
+ */
286
+ generateSummary(session) {
287
+ const lines = [
288
+ `Total transpilation time: ${session.totalDuration.toFixed(2)}ms`,
289
+ `Phases measured: ${session.phaseStats.length}`,
290
+ ];
291
+ if (session.memorySnapshots.length > 1) {
292
+ const start = session.memorySnapshots[0];
293
+ const end = session.memorySnapshots[session.memorySnapshots.length - 1];
294
+ const delta = end.heapUsed - start.heapUsed;
295
+ const sign = delta >= 0 ? "+" : "";
296
+ lines.push(`Memory delta: ${sign}${(delta / 1024 / 1024).toFixed(2)}MB`);
297
+ }
298
+ return lines.join("\n");
299
+ }
300
+ /**
301
+ * Get all timing durations as a flat record (for diagnostics integration).
302
+ */
303
+ getTimings() {
304
+ const result = {};
305
+ for (const [name, entry] of this.timings) {
306
+ result[name] = entry.duration;
307
+ }
308
+ return result;
309
+ }
310
+ /**
311
+ * Clear all profiling data
312
+ */
313
+ clear() {
314
+ this.timings.clear();
315
+ this.activeTimers.clear();
316
+ this.memorySnapshots = [];
317
+ this.parentStack = [];
318
+ this.timerCounter = 0;
319
+ }
320
+ }
321
+ // Global profiler instance
322
+ let globalProfiler = null;
323
+ /**
324
+ * Get the global profiler instance (creates one if not exists)
325
+ */
326
+ export function getProfiler() {
327
+ if (!globalProfiler) {
328
+ globalProfiler = new Profiler();
329
+ }
330
+ return globalProfiler;
331
+ }
332
+ /**
333
+ * Initialize the global profiler with options
334
+ */
335
+ export function initProfiler(options = {}) {
336
+ globalProfiler = new Profiler(options);
337
+ return globalProfiler;
338
+ }
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Types for the transpilation performance profiler.
3
+ */
4
+ export interface TimingEntry {
5
+ /** Unique name for this timing entry */
6
+ name: string;
7
+ /** Start time from performance.now() */
8
+ startTime: number;
9
+ /** End time from performance.now() */
10
+ endTime: number;
11
+ /** Duration in milliseconds */
12
+ duration: number;
13
+ /** Parent timer name (for hierarchical timing) */
14
+ parent?: string;
15
+ /** Child timer names */
16
+ children: string[];
17
+ /** Optional metadata */
18
+ metadata?: Record<string, unknown>;
19
+ }
20
+ export interface MemorySnapshot {
21
+ /** Name/label for this snapshot */
22
+ name: string;
23
+ /** Timestamp from performance.now() */
24
+ timestamp: number;
25
+ /** Heap used in bytes */
26
+ heapUsed: number;
27
+ /** Heap total in bytes */
28
+ heapTotal: number;
29
+ /** External memory in bytes */
30
+ external: number;
31
+ }
32
+ export interface PhaseStatistics {
33
+ /** Phase name (base name without file-specific suffixes) */
34
+ phase: string;
35
+ /** Total duration in milliseconds */
36
+ totalDuration: number;
37
+ /** Number of times this phase was called */
38
+ callCount: number;
39
+ /** Average duration per call in milliseconds */
40
+ avgDuration: number;
41
+ /** Minimum duration in milliseconds */
42
+ minDuration: number;
43
+ /** Maximum duration in milliseconds */
44
+ maxDuration: number;
45
+ /** Percentage of total transpilation time */
46
+ percentageOfTotal: number;
47
+ }
48
+ export interface ProfilerSession {
49
+ /** Session start time from performance.now() */
50
+ startTime: number;
51
+ /** Session end time from performance.now() */
52
+ endTime: number;
53
+ /** Total session duration in milliseconds */
54
+ totalDuration: number;
55
+ /** All timing entries by name */
56
+ timings: Map<string, TimingEntry>;
57
+ /** Memory snapshots taken during profiling */
58
+ memorySnapshots: MemorySnapshot[];
59
+ /** Aggregated statistics by phase */
60
+ phaseStats: PhaseStatistics[];
61
+ }
62
+ export interface ProfilerOptions {
63
+ /** Enable profiling (default: false) */
64
+ enabled: boolean;
65
+ /** Track memory usage (default: false) */
66
+ trackMemory: boolean;
67
+ /** Output format for reports */
68
+ outputFormat: "console" | "json" | "markdown";
69
+ /** Output file path (default: console output) */
70
+ outputPath?: string;
71
+ /** Minimum duration (ms) to include in report (default: 0) */
72
+ threshold: number;
73
+ }
74
+ export interface ProfilerReport {
75
+ /** The profiling session data */
76
+ session: ProfilerSession;
77
+ /** Human-readable summary */
78
+ summary: string;
79
+ /** Identified bottlenecks (>10% of total time) */
80
+ bottlenecks: string[];
81
+ /** Optimization recommendations */
82
+ recommendations: string[];
83
+ }
84
+ /**
85
+ * Default profiler options
86
+ */
87
+ export declare const DEFAULT_PROFILER_OPTIONS: ProfilerOptions;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Types for the transpilation performance profiler.
3
+ */
4
+ /**
5
+ * Default profiler options
6
+ */
7
+ export const DEFAULT_PROFILER_OPTIONS = {
8
+ enabled: false,
9
+ trackMemory: false,
10
+ outputFormat: "console",
11
+ threshold: 0,
12
+ };
@@ -0,0 +1,16 @@
1
+ import type { DisplayProfile, ResolvedDisplay } from "../api/shared/index.js";
2
+ export type { ResolvedDisplay };
3
+ /** Set the display profile for this transpile run. Called from transpileFile. */
4
+ export declare function setDisplayProfile(profile: DisplayProfile, wiring: {
5
+ cs?: number;
6
+ dc?: number;
7
+ rst?: number;
8
+ bus?: string;
9
+ address?: number;
10
+ reset?: number;
11
+ buildTarget?: string;
12
+ }): void;
13
+ /** Get the current display profile, or a default if none set. */
14
+ export declare function getDisplayProfile(): ResolvedDisplay;
15
+ /** Reset for the next transpile run. */
16
+ export declare function resetDisplayProfile(): void;
@@ -0,0 +1,48 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Display profile store — module-scoped profile for the current transpile run.
3
+ //
4
+ // Set early in transpileFile when the config's `display` field is loaded.
5
+ // All hardcoded display-value sites read from here via getDisplayProfile().
6
+ //
7
+ // This avoids deep changes to the config loader and TranspileOptions type —
8
+ // the full config plumbing can come later. The important thing is that
9
+ // display dimensions, pins, rotation, and touch config are data-driven.
10
+ // ---------------------------------------------------------------------------
11
+ let currentProfile = null;
12
+ /** Set the display profile for this transpile run. Called from transpileFile. */
13
+ export function setDisplayProfile(profile, wiring) {
14
+ currentProfile = {
15
+ ...profile,
16
+ _mountCs: wiring.cs ?? 5,
17
+ _mountDc: wiring.dc ?? 21,
18
+ _mountRst: wiring.rst ?? 22,
19
+ _mountBus: wiring.bus ?? "SPI",
20
+ _mountAddress: wiring.address ?? 0x3C,
21
+ _mountReset: wiring.reset ?? -1,
22
+ _buildTarget: wiring.buildTarget,
23
+ };
24
+ }
25
+ /** Get the current display profile, or a default if none set. */
26
+ export function getDisplayProfile() {
27
+ if (currentProfile)
28
+ return currentProfile;
29
+ return {
30
+ driver: "ili9341",
31
+ width: 320,
32
+ height: 240,
33
+ colorFormat: "rgb565",
34
+ rotation: 1,
35
+ backlight: 17,
36
+ spiPins: { mosi: 23, sck: 18, miso: 19 },
37
+ _mountCs: 5,
38
+ _mountDc: 21,
39
+ _mountRst: 22,
40
+ _mountBus: "SPI",
41
+ _mountAddress: 0x3C,
42
+ _mountReset: -1,
43
+ };
44
+ }
45
+ /** Reset for the next transpile run. */
46
+ export function resetDisplayProfile() {
47
+ currentProfile = null;
48
+ }
@@ -0,0 +1,13 @@
1
+ /** Set the CSS theme file path. When non-null, loadUIModule uses this
2
+ * instead of the default sibling .ui.css. Pass null to restore default. */
3
+ export declare function setThemeCss(path: string | null): void;
4
+ /** Get the CSS theme override path, or null for default sibling-file behavior. */
5
+ export declare function getThemeCss(): string | null;
6
+ /** Set the active theme class for class-scoped CSS variables (e.g. "dark").
7
+ * When set, var() substitution prefers variables defined under this class
8
+ * over :root defaults. */
9
+ export declare function setThemeClass(cls: string | null): void;
10
+ /** Get the active theme class, or null (use :root only). */
11
+ export declare function getThemeClass(): string | null;
12
+ /** Reset to default (sibling-file convention). */
13
+ export declare function resetThemeCss(): void;
@@ -0,0 +1,30 @@
1
+ // Module-scoped CSS theme path override.
2
+ // Set via setThemeCss() from the config loader; read by loadUIModule().
3
+ // When set, this path replaces the default sibling-file convention
4
+ // (hello.ui.html → hello.ui.css).
5
+ let themeCssOverride = null;
6
+ let themeClassOverride = null;
7
+ /** Set the CSS theme file path. When non-null, loadUIModule uses this
8
+ * instead of the default sibling .ui.css. Pass null to restore default. */
9
+ export function setThemeCss(path) {
10
+ themeCssOverride = path;
11
+ }
12
+ /** Get the CSS theme override path, or null for default sibling-file behavior. */
13
+ export function getThemeCss() {
14
+ return themeCssOverride;
15
+ }
16
+ /** Set the active theme class for class-scoped CSS variables (e.g. "dark").
17
+ * When set, var() substitution prefers variables defined under this class
18
+ * over :root defaults. */
19
+ export function setThemeClass(cls) {
20
+ themeClassOverride = cls;
21
+ }
22
+ /** Get the active theme class, or null (use :root only). */
23
+ export function getThemeClass() {
24
+ return themeClassOverride;
25
+ }
26
+ /** Reset to default (sibling-file convention). */
27
+ export function resetThemeCss() {
28
+ themeCssOverride = null;
29
+ themeClassOverride = null;
30
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Testing utilities for @typecad/cuttlefish.
3
+ *
4
+ * This module exposes internal transpiler functions that are needed by
5
+ * the test suite but are intentionally kept out of the main public API
6
+ * (`@typecad/cuttlefish`). Import via `@typecad/cuttlefish/testing`.
7
+ */
8
+ export { buildProgramIR } from "./ir/build-ir.js";
9
+ export { emitCpp, registerAllEnumNames } from "./emit/cpp-emitter.js";
10
+ export { analyzePeripheralUsage, createEmptyPeripheralUsage } from "./ir/peripheral-usage.js";
11
+ export { inferSnprintfArg, createEmissionScopeState, escapeCppStringLiteral } from "./emit/snprintf-helpers.js";
12
+ export { setLoadedFramework } from "./framework-registry.js";
13
+ export { registerPlatformStrategy, resolveStrategy, clearAllProfileCaches } from "./platform/registry.js";
14
+ export type { EmitMode, GeneratedOutputs, TargetProfile, PlatformContext } from "./types.js";
15
+ export { findConfigFile, parseConfigFile, loadCuttlefishConfig, generateVirtualTypeDeclaration, } from "./config-loader.js";
16
+ export { transpileFile } from "./transpile.js";
17
+ export { scaffoldProject, normalizeProjectName, KNOWN_BOARDS, generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateGitignore, generateEslintConfig, runInitWizard, } from "./create/index.js";
18
+ export type { InitProjectOptions } from "./create/index.js";
19
+ export { scaffoldBoardPackages, parseBoardSpec, safeParseBoardSpec, stripJsonc, } from "./create/index.js";
20
+ export type { BoardSpec, ScaffoldBoardResult } from "./create/index.js";
21
+ export { BoardGenerators } from "./create/index.js";
22
+ export { buildCallGraph, getReachableSymbols } from "./ir/call-graph.js";
23
+ export { detectEntryPoints, detectExportedEntryPoints } from "./ir/entry-points.js";
24
+ export { analyzeReachability, getReachabilityStats } from "./ir/reachability.js";
25
+ export { filterProgramIR } from "./ir/filter.js";
26
+ export { validateTryCatch } from "./ir/try-catch-validation.js";
27
+ export { prescanUnsupportedFeatures } from "./ir/feature-prescan.js";
28
+ export { LINT_RULES, ESLINT_OPT_OUT_KINDS, kindRegistryEntries, } from "./ir/feature-registry.js";
29
+ export type { LintRule, FeatureEntry, FeatureStatus, DiagnosticMatch } from "./ir/feature-registry.js";
30
+ export { runEslintCheck } from "./eslint-check.js";
31
+ export type { ESLintError } from "./eslint-check.js";
32
+ export { runSemanticGates } from "./orchestrator/type-checker.js";
33
+ export { canonicalize, buildSemanticFacts, } from "./orchestrator/semantic-facts.js";
34
+ export type { CanonicalType, SemanticFacts, FactStore, ValueCategory, Lifetime, Nullable, SemanticOrigin, AnalysisResult, BindingResolver, } from "./orchestrator/semantic-facts.js";
35
+ export { verifyFacts } from "./orchestrator/semantic-facts-verifier.js";
36
+ export type { VerifierOptions, VerifierResult, UnknownTypeSeverity } from "./orchestrator/semantic-facts-verifier.js";
37
+ export { discoverWatchDirs, isRelevantChange } from "./watch.js";
38
+ export { parseCommandLine } from "./utils/cli.js";
39
+ export { parseHeader, stripPreprocessorBlocks } from "./libdef/header-parser.js";
40
+ export { BaseClassResolver, buildClassIndex } from "./libdef/base-class-resolver.js";
41
+ export type { ResolveResult } from "./libdef/base-class-resolver.js";
42
+ export { generateDecl, generateDeclsForDirectory } from "./libdef/cpp-to-decl.js";
43
+ export { renderExprAsText } from "./ir/render-expr.js";
44
+ export { contextStorage, CompilationContext } from "./ir/build-ir-state.js";
45
+ export type { ExpressionIR } from "./api/index.js";
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Testing utilities for @typecad/cuttlefish.
3
+ *
4
+ * This module exposes internal transpiler functions that are needed by
5
+ * the test suite but are intentionally kept out of the main public API
6
+ * (`@typecad/cuttlefish`). Import via `@typecad/cuttlefish/testing`.
7
+ */
8
+ export { buildProgramIR } from "./ir/build-ir.js";
9
+ export { emitCpp, registerAllEnumNames } from "./emit/cpp-emitter.js";
10
+ export { analyzePeripheralUsage, createEmptyPeripheralUsage } from "./ir/peripheral-usage.js";
11
+ export { inferSnprintfArg, createEmissionScopeState, escapeCppStringLiteral } from "./emit/snprintf-helpers.js";
12
+ export { setLoadedFramework } from "./framework-registry.js";
13
+ export { registerPlatformStrategy, resolveStrategy, clearAllProfileCaches } from "./platform/registry.js";
14
+ // ── Config loader ───────────────────────────────────────────────────────────
15
+ export { findConfigFile, parseConfigFile, loadCuttlefishConfig, generateVirtualTypeDeclaration, } from "./config-loader.js";
16
+ // ── Transpiler internal API ─────────────────────────────────────────────────
17
+ export { transpileFile } from "./transpile.js";
18
+ // ── Project scaffolding ──────────────────────────────────────────────────────
19
+ export { scaffoldProject, normalizeProjectName, KNOWN_BOARDS, generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateGitignore, generateEslintConfig, runInitWizard, } from "./create/index.js";
20
+ // ── Board codegen (`cuttlefish board add`) ───────────────────────────────────
21
+ export { scaffoldBoardPackages, parseBoardSpec, safeParseBoardSpec, stripJsonc, } from "./create/index.js";
22
+ export { BoardGenerators } from "./create/index.js";
23
+ // ── Tree-shaking & reachability ──────────────────────────────────────────────
24
+ export { buildCallGraph, getReachableSymbols } from "./ir/call-graph.js";
25
+ export { detectEntryPoints, detectExportedEntryPoints } from "./ir/entry-points.js";
26
+ export { analyzeReachability, getReachabilityStats } from "./ir/reachability.js";
27
+ export { filterProgramIR } from "./ir/filter.js";
28
+ // ── Validation ──────────────────────────────────────────────────────────────
29
+ export { validateTryCatch } from "./ir/try-catch-validation.js";
30
+ export { prescanUnsupportedFeatures } from "./ir/feature-prescan.js";
31
+ // Feature registry + ESLint selector source-of-truth (parity-tested).
32
+ export { LINT_RULES, ESLINT_OPT_OUT_KINDS, kindRegistryEntries, } from "./ir/feature-registry.js";
33
+ // ── ESLint gate ──────────────────────────────────────────────────────────────
34
+ export { runEslintCheck } from "./eslint-check.js";
35
+ // ── Semantic gates (TypeChecker-based) ──────────────────────────────────────
36
+ export { runSemanticGates } from "./orchestrator/type-checker.js";
37
+ export { canonicalize, buildSemanticFacts, } from "./orchestrator/semantic-facts.js";
38
+ export { verifyFacts } from "./orchestrator/semantic-facts-verifier.js";
39
+ // ── Watch & CLI utilities ───────────────────────────────────────────────────
40
+ export { discoverWatchDirs, isRelevantChange } from "./watch.js";
41
+ export { parseCommandLine } from "./utils/cli.js";
42
+ export { parseHeader, stripPreprocessorBlocks } from "./libdef/header-parser.js";
43
+ export { BaseClassResolver, buildClassIndex } from "./libdef/base-class-resolver.js";
44
+ export { generateDecl, generateDeclsForDirectory } from "./libdef/cpp-to-decl.js";
45
+ // ── IR rendering internals (for fail-closed regression tests) ───────────────
46
+ export { renderExprAsText } from "./ir/render-expr.js";
47
+ export { contextStorage, CompilationContext } from "./ir/build-ir-state.js";
@@ -0,0 +1,29 @@
1
+ export interface ResolvedNpmPackage {
2
+ packagePath: string;
3
+ sourcePath: string;
4
+ subpath: string;
5
+ packageName: string;
6
+ moduleKey: string;
7
+ }
8
+ export interface NativeCppModule {
9
+ declPath: string;
10
+ cppPath: string;
11
+ headerPath?: string;
12
+ moduleKey: string;
13
+ }
14
+ export interface TranspileGraphResult {
15
+ files: string[];
16
+ npmPackages: Map<string, ResolvedNpmPackage>;
17
+ nativeModules: Map<string, NativeCppModule>;
18
+ /** `.ui.html` modules discovered during graph build, keyed by resolved path. */
19
+ uiModules: Set<string>;
20
+ }
21
+ export declare function resolveImport(fromFile: string, moduleSpecifier: string, boardPackage?: string): {
22
+ sourcePath: string;
23
+ npmPackage?: ResolvedNpmPackage;
24
+ uiModule?: boolean;
25
+ } | undefined;
26
+ export declare function isInNodeModules(filePath: string): boolean;
27
+ export declare function getNpmPackageInfoForFile(filePath: string, moduleSpecifier: string): ResolvedNpmPackage | undefined;
28
+ export declare function detectNativeCppModule(fromFile: string, moduleSpecifier: string): NativeCppModule | undefined;
29
+ export declare function isCuttlefishSDKPath(filePath: string): boolean;