@typecad/framework-zephyr 1.0.0-alpha.16 → 1.0.0-alpha.19

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 (210) hide show
  1. package/LICENSE +202 -21
  2. package/README.md +49 -87
  3. package/dist/as-built.d.ts +2 -2
  4. package/dist/as-built.js +2 -2
  5. package/dist/audit.d.ts +111 -0
  6. package/dist/audit.js +416 -0
  7. package/dist/boardgen.d.ts +1 -9
  8. package/dist/boardgen.js +288 -47
  9. package/dist/chips/resolve.js +20 -0
  10. package/dist/chips/types.d.ts +22 -1
  11. package/dist/debug-codegen.js +1 -1
  12. package/dist/display/bindings.d.ts +55 -0
  13. package/dist/display/bindings.js +316 -0
  14. package/dist/display/gfx.d.ts +2 -3
  15. package/dist/display/gfx.js +166 -154
  16. package/dist/display/index.js +20 -1
  17. package/dist/display/mipi-dbi-host.d.ts +9 -0
  18. package/dist/display/mipi-dbi-host.js +174 -0
  19. package/dist/display/profiles.d.ts +109 -4
  20. package/dist/display/profiles.js +270 -7
  21. package/dist/display/touch-adapter.js +119 -49
  22. package/dist/display/ui-adapter-eink.d.ts +2 -0
  23. package/dist/display/ui-adapter-eink.js +4 -0
  24. package/dist/display/ui-adapter-gray.d.ts +8 -0
  25. package/dist/display/ui-adapter-gray.js +170 -0
  26. package/dist/display/ui-adapter-mono.d.ts +13 -0
  27. package/dist/display/ui-adapter-mono.js +230 -0
  28. package/dist/display/ui-adapter-native.d.ts +10 -0
  29. package/dist/display/ui-adapter-native.js +295 -0
  30. package/dist/display/ui-adapter-shared.d.ts +11 -0
  31. package/dist/display/ui-adapter-shared.js +122 -0
  32. package/dist/display/ui-adapter.js +510 -558
  33. package/dist/doctor.js +4 -4
  34. package/dist/dt-config/custom-board.js +2 -2
  35. package/dist/dt-config/kconfig.d.ts +62 -1
  36. package/dist/dt-config/kconfig.js +141 -38
  37. package/dist/dt-config/overlay.d.ts +15 -2
  38. package/dist/dt-config/overlay.js +433 -18
  39. package/dist/framework.manifest.d.ts +10 -4
  40. package/dist/framework.manifest.js +133 -17
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js +14 -6
  43. package/dist/licenses.d.ts +2 -2
  44. package/dist/licenses.js +13 -92
  45. package/dist/lowering/can.d.ts +25 -0
  46. package/dist/lowering/can.js +97 -0
  47. package/dist/lowering/clock.d.ts +17 -0
  48. package/dist/lowering/clock.js +58 -0
  49. package/dist/lowering/fs.js +1 -1
  50. package/dist/lowering/gpio.js +0 -32
  51. package/dist/lowering/hid.d.ts +27 -0
  52. package/dist/lowering/hid.js +244 -0
  53. package/dist/lowering/http.js +264 -32
  54. package/dist/lowering/i2c.d.ts +8 -0
  55. package/dist/lowering/i2c.js +137 -5
  56. package/dist/lowering/i2s.d.ts +27 -0
  57. package/dist/lowering/i2s.js +98 -0
  58. package/dist/lowering/index.d.ts +9 -1
  59. package/dist/lowering/index.js +25 -1
  60. package/dist/lowering/interrupts.js +6 -0
  61. package/dist/lowering/matrix.d.ts +15 -0
  62. package/dist/lowering/matrix.js +63 -0
  63. package/dist/lowering/mqtt.js +110 -8
  64. package/dist/lowering/power.d.ts +3 -2
  65. package/dist/lowering/power.js +20 -45
  66. package/dist/lowering/pwm.js +25 -0
  67. package/dist/lowering/sensor.d.ts +2 -2
  68. package/dist/lowering/sensor.js +8 -4
  69. package/dist/lowering/strip.d.ts +16 -0
  70. package/dist/lowering/strip.js +70 -0
  71. package/dist/lowering/thread.js +5 -1
  72. package/dist/lowering/trace.d.ts +44 -0
  73. package/dist/lowering/trace.js +239 -0
  74. package/dist/lowering/uart.js +6 -1
  75. package/dist/lowering/usb.d.ts +3 -1
  76. package/dist/lowering/usb.js +16 -13
  77. package/dist/lowering/wdt.js +2 -29
  78. package/dist/sbom.d.ts +181 -0
  79. package/dist/sbom.js +901 -0
  80. package/dist/sdk/board-catalog-sync.d.ts +1 -3
  81. package/dist/sdk/board-catalog-sync.js +4 -10
  82. package/dist/strategy.d.ts +82 -46
  83. package/dist/strategy.js +639 -182
  84. package/dist/tmp-probe.d.ts +2 -0
  85. package/dist/tmp-probe.js +9 -0
  86. package/dist/toolchain/debug-config.d.ts +50 -90
  87. package/dist/toolchain/debug-config.js +239 -510
  88. package/dist/toolchain/env-check.d.ts +1 -3
  89. package/dist/toolchain/env-check.js +2 -7
  90. package/dist/toolchain/index.d.ts +28 -3
  91. package/dist/toolchain/index.js +498 -62
  92. package/dist/toolchain/runners.d.ts +16 -0
  93. package/dist/toolchain/runners.js +75 -0
  94. package/dist/toolchain/scaffold.d.ts +5 -2
  95. package/dist/toolchain/scaffold.js +79 -15
  96. package/dist/toolchain/west-discover.d.ts +6 -0
  97. package/dist/toolchain/west-discover.js +36 -13
  98. package/dist/toolchain/west-spawn.js +8 -2
  99. package/dist/west-inventory.d.ts +25 -0
  100. package/dist/west-inventory.js +97 -0
  101. package/installer/README.md +328 -328
  102. package/installer/install.sh +2 -2
  103. package/installer/templates/project/.typecad/activate-zephyr.ps1 +1 -1
  104. package/installer/templates/project/.typecad/activate-zephyr.sh +1 -1
  105. package/installer/templates/project/.vscode/settings.json +1 -1
  106. package/installer/templates/project/README.md +2 -2
  107. package/package.json +5 -5
  108. package/src/as-built.ts +206 -206
  109. package/src/audit.ts +529 -0
  110. package/src/boardgen.ts +265 -50
  111. package/src/chips/resolve.ts +21 -0
  112. package/src/chips/types.ts +10 -1
  113. package/src/display/bindings.ts +347 -0
  114. package/src/display/gfx.ts +318 -306
  115. package/src/display/index.ts +87 -70
  116. package/src/display/mipi-dbi-host.ts +183 -0
  117. package/src/display/profiles.ts +458 -139
  118. package/src/display/touch-adapter.ts +119 -49
  119. package/src/display/ui-adapter-eink.ts +13 -0
  120. package/src/display/ui-adapter-gray.ts +178 -0
  121. package/src/display/ui-adapter-mono.ts +238 -0
  122. package/src/display/ui-adapter-native.ts +304 -0
  123. package/src/display/ui-adapter-shared.ts +125 -0
  124. package/src/display/ui-adapter.ts +732 -781
  125. package/src/doctor.ts +4 -4
  126. package/src/dt-config/custom-board.ts +2 -2
  127. package/src/dt-config/kconfig.ts +647 -505
  128. package/src/dt-config/overlay.ts +1475 -1058
  129. package/src/framework.manifest.ts +659 -535
  130. package/src/index.ts +16 -6
  131. package/src/licenses.ts +346 -425
  132. package/src/lowering/can.ts +140 -0
  133. package/src/lowering/clock.ts +91 -0
  134. package/src/lowering/fs.ts +135 -135
  135. package/src/lowering/gpio.ts +0 -33
  136. package/src/lowering/hid.ts +261 -0
  137. package/src/lowering/http.ts +264 -32
  138. package/src/lowering/i2c.ts +142 -5
  139. package/src/lowering/i2s.ts +143 -0
  140. package/src/lowering/index.ts +18 -1
  141. package/src/lowering/interrupts.ts +6 -0
  142. package/src/lowering/matrix.ts +70 -0
  143. package/src/lowering/mqtt.ts +109 -8
  144. package/src/lowering/power.ts +41 -0
  145. package/src/lowering/pwm.ts +192 -167
  146. package/src/lowering/sensor.ts +159 -155
  147. package/src/lowering/strip.ts +81 -0
  148. package/src/lowering/thread.ts +5 -1
  149. package/src/lowering/trace.ts +270 -0
  150. package/src/lowering/uart.ts +6 -1
  151. package/src/lowering/usb.ts +16 -13
  152. package/src/lowering/wdt.ts +2 -25
  153. package/src/sbom.ts +1117 -0
  154. package/src/sdk/board-catalog-sync.ts +4 -25
  155. package/src/strategy.ts +2680 -2309
  156. package/src/toolchain/debug-config.ts +262 -522
  157. package/src/toolchain/env-check.ts +279 -285
  158. package/src/toolchain/index.ts +1792 -1359
  159. package/src/toolchain/runners.ts +80 -0
  160. package/src/toolchain/scaffold.ts +355 -296
  161. package/src/toolchain/west-discover.ts +35 -13
  162. package/src/toolchain/west-spawn.ts +174 -168
  163. package/src/west-inventory.ts +102 -0
  164. package/dist/async/timer-polyfill.d.ts +0 -10
  165. package/dist/async/timer-polyfill.js +0 -95
  166. package/dist/chips/board-overrides.d.ts +0 -7
  167. package/dist/chips/board-overrides.js +0 -11
  168. package/dist/chips/esp32.d.ts +0 -2
  169. package/dist/chips/esp32.js +0 -71
  170. package/dist/chips/esp32s3.d.ts +0 -2
  171. package/dist/chips/esp32s3.js +0 -103
  172. package/dist/chips/soc/.d.ts +0 -2
  173. package/dist/chips/soc/.js +0 -129
  174. package/dist/chips/soc/esp32.d.ts +0 -2
  175. package/dist/chips/soc/esp32.js +0 -120
  176. package/dist/chips/soc/esp32c3.d.ts +0 -2
  177. package/dist/chips/soc/esp32c3.js +0 -90
  178. package/dist/chips/soc/esp32c6.d.ts +0 -2
  179. package/dist/chips/soc/esp32c6.js +0 -109
  180. package/dist/chips/soc/esp32s3.d.ts +0 -2
  181. package/dist/chips/soc/esp32s3.js +0 -189
  182. package/dist/chips/soc/index.d.ts +0 -2
  183. package/dist/chips/soc/index.js +0 -23
  184. package/dist/chips/soc/nrf52840.d.ts +0 -2
  185. package/dist/chips/soc/nrf52840.js +0 -130
  186. package/dist/chips/soc/rp2040.d.ts +0 -2
  187. package/dist/chips/soc/rp2040.js +0 -141
  188. package/dist/chips/soc/rp2350a.d.ts +0 -2
  189. package/dist/chips/soc/rp2350a.js +0 -145
  190. package/dist/chips/soc/samd21g18a.d.ts +0 -2
  191. package/dist/chips/soc/samd21g18a.js +0 -143
  192. package/dist/chips/soc/stm32f411xe.d.ts +0 -2
  193. package/dist/chips/soc/stm32f411xe.js +0 -251
  194. package/dist/chips/xiao-ble.d.ts +0 -2
  195. package/dist/chips/xiao-ble.js +0 -100
  196. package/dist/lowering/pulse.d.ts +0 -7
  197. package/dist/lowering/pulse.js +0 -51
  198. package/dist/lowering/tone.d.ts +0 -10
  199. package/dist/lowering/tone.js +0 -63
  200. package/dist/lowering/worker-backing.d.ts +0 -14
  201. package/dist/lowering/worker-backing.js +0 -79
  202. package/dist/lowering/worker.d.ts +0 -6
  203. package/dist/lowering/worker.js +0 -14
  204. package/dist/sdk/board-data.generated.d.ts +0 -2
  205. package/dist/sdk/board-data.generated.js +0 -4
  206. package/dist/sdk/catalog-walker.d.ts +0 -90
  207. package/dist/sdk/catalog-walker.js +0 -682
  208. package/dist/sdk/dts-reader.d.ts +0 -83
  209. package/dist/sdk/dts-reader.js +0 -596
  210. package/src/debug-codegen.ts +0 -207
package/dist/sbom.d.ts ADDED
@@ -0,0 +1,181 @@
1
+ import { type ReadFile, type ReadDir } from '@typecad/cuttlefish/api/shared';
2
+ export type SbomFormat = 'cyclonedx' | 'spdx';
3
+ /** Options accepted by `runSbomPresenter` (the parsed `typecad-hal sbom`
4
+ * command options are structurally compatible). */
5
+ export interface SbomPresenterOptions {
6
+ format?: SbomFormat;
7
+ /** Scope to every west manifest module (default: only linked modules). */
8
+ all?: boolean;
9
+ /** Exit non-zero on integrity warnings (floating revisions, missing SHAs). */
10
+ strict?: boolean;
11
+ /** Verify the recorded CycloneDX SBOM against the current build. */
12
+ check?: boolean;
13
+ /** Print the JSON to stdout instead of writing a file. */
14
+ stdout?: boolean;
15
+ /** Output path (default: <buildDir>/sbom.cdx.json, or ./sbom.cdx.json). */
16
+ output?: string;
17
+ /** Compare two SBOM files instead of generating. */
18
+ diff?: [string, string];
19
+ }
20
+ /** One `west list` project with its immutable identity. */
21
+ export interface WestModuleRef {
22
+ name: string;
23
+ abspath: string;
24
+ /** Manifest revision (SHA, tag, or branch — see floating-revision warning). */
25
+ revision?: string;
26
+ /** Checked-out commit SHA (what the build actually compiled). */
27
+ sha?: string;
28
+ url?: string;
29
+ }
30
+ export type SbomWarningKind = 'floating-revision' | 'missing-sha' | 'no-build' | 'unknown-license' | 'west-list-limited';
31
+ export interface SbomWarning {
32
+ kind: SbomWarningKind;
33
+ component: string;
34
+ detail?: string;
35
+ }
36
+ export interface SbomModule {
37
+ name: string;
38
+ isKernel: boolean;
39
+ /** Identity: the checked-out SHA (kernel: friendly version, e.g. 4.3.0). */
40
+ version: string;
41
+ sha?: string;
42
+ revision?: string;
43
+ url?: string;
44
+ /** Resolved SPDX license id (absent when undeterminable). */
45
+ spdx?: string;
46
+ kernelVersion?: string;
47
+ }
48
+ export interface SbomInventoryMeta {
49
+ projectName?: string;
50
+ projectVersion?: string;
51
+ boardTarget?: string;
52
+ }
53
+ export type SbomInventory = {
54
+ ok: true;
55
+ scope: 'linked' | 'all';
56
+ projectName: string;
57
+ projectVersion: string;
58
+ boardTarget?: string;
59
+ buildDir?: string;
60
+ artifact?: {
61
+ path: string;
62
+ fileName: string;
63
+ sha256: string;
64
+ sizeBytes: number;
65
+ };
66
+ modules: SbomModule[];
67
+ tools: {
68
+ cuttlefish?: string;
69
+ frameworkZephyr?: string;
70
+ /** @typecad/hal as installed in THIS project — the API surface the
71
+ * firmware source compiled against (part of the generator ladder,
72
+ * never a linked runtime component). */
73
+ hal?: string;
74
+ sdk?: string;
75
+ };
76
+ warnings: SbomWarning[];
77
+ needsBuild: boolean;
78
+ } | {
79
+ ok: false;
80
+ reason: 'no-workspace';
81
+ message: string;
82
+ };
83
+ /**
84
+ * Injected seams so the inventory + presenters are unit-testable without
85
+ * spawning west or touching disk. The production runner (defaultSbomRunner)
86
+ * wires these to discoverWest + westSpawn + fs + crypto.
87
+ */
88
+ export interface SbomRunner {
89
+ /** Directory the project lives in (project name fallback, build search). */
90
+ cwd?: string;
91
+ /** Discovered $ZEPHYR_BASE (absolute), or undefined. */
92
+ zephyrBase?: string;
93
+ /** west manifest projects with identity fields, or null when west failed. */
94
+ listModules: () => WestModuleRef[] | null;
95
+ /** The last build's compile_commands.json path, or undefined. */
96
+ compileCommandsPath?: () => string | undefined;
97
+ readFile: ReadFile;
98
+ readdir: ReadDir;
99
+ statMtimeMs?: (p: string) => number | null;
100
+ sha256?: (p: string) => string | null;
101
+ fileSize?: (p: string) => number | null;
102
+ /** $ZEPHYR_BASE/VERSION text (kernel friendly version), or undefined. */
103
+ zephyrVersionText?: () => string | undefined;
104
+ /** Project package.json text, or undefined. */
105
+ projectPackageJson?: () => string | undefined;
106
+ /** Toolchain versions for the formulation block. */
107
+ toolVersions?: () => {
108
+ cuttlefish?: string;
109
+ frameworkZephyr?: string;
110
+ sdk?: string;
111
+ };
112
+ }
113
+ /** Parse a Zephyr VERSION file ("VERSION_MAJOR = 4\n...") into "4.3.0". */
114
+ export declare function parseZephyrVersion(text: string | undefined): string | undefined;
115
+ /**
116
+ * Collect the as-built inventory: kernel + west modules (linked-only by
117
+ * default), each one's immutable identity + resolved SPDX license, the hashed
118
+ * firmware artifact, the project identity, and the toolchain versions.
119
+ * Never throws.
120
+ */
121
+ export declare function collectSbomInventory(runner: SbomRunner, allModules?: boolean, meta?: SbomInventoryMeta): SbomInventory;
122
+ /**
123
+ * Deterministic serial number: the same build (same component identities +
124
+ * artifact hash) always produces the same urn:uuid, so `sbom --check` can
125
+ * regenerate and compare without false drift from random UUIDs.
126
+ */
127
+ export declare function sbomSerialNumber(inv: Extract<SbomInventory, {
128
+ ok: true;
129
+ }>): string;
130
+ export interface SbomBuildOpts {
131
+ toolVersion: string;
132
+ /** RFC3339 UTC timestamp (reused verbatim by --check comparisons). */
133
+ timestamp: string;
134
+ }
135
+ export declare function buildCycloneDXBom(inv: Extract<SbomInventory, {
136
+ ok: true;
137
+ }>, opts: SbomBuildOpts): Record<string, unknown>;
138
+ export declare function buildSpdxDocument(inv: Extract<SbomInventory, {
139
+ ok: true;
140
+ }>, opts: SbomBuildOpts): Record<string, unknown>;
141
+ /** Stable stringify: object keys sorted, so regenerated docs compare equal. */
142
+ export declare function canonicalJson(value: unknown): string;
143
+ export interface SbomDiffEntry {
144
+ /** Stable component identity (`type:name` — NOT the bom-ref, which embeds
145
+ * the version and would turn every update into remove+add). */
146
+ component: string;
147
+ field: 'version' | 'license' | 'hash';
148
+ from: string;
149
+ to: string;
150
+ }
151
+ export interface SbomDiffResult {
152
+ added: string[];
153
+ removed: string[];
154
+ changed: SbomDiffEntry[];
155
+ }
156
+ /** Compare two CycloneDX documents' component sets (added/removed/changed),
157
+ * keyed by type:name so a version bump reads as a change, not churn. */
158
+ export declare function diffCycloneDxDocs(a: Record<string, unknown>, b: Record<string, unknown>): SbomDiffResult;
159
+ /**
160
+ * Parse `west list --format` TSV output into module refs. Empty columns and
161
+ * west's "N/A" placeholder (e.g. the sha/url of the manifest-imported zephyr
162
+ * project) become undefined; lines without a name+abspath pair are skipped.
163
+ * Exported for unit tests.
164
+ */
165
+ export declare function parseWestListOutput(out: string): WestModuleRef[];
166
+ /**
167
+ * Write `<buildDir>/sbom.cdx.json` after a successful west build. Best-effort:
168
+ * any failure returns undefined silently — a missing SBOM never blocks the
169
+ * build. `runner` is a test seam; production leaves it unset.
170
+ */
171
+ export declare function stampBuildSbom(args: {
172
+ buildDir: string;
173
+ board?: string;
174
+ projectRoot?: string;
175
+ }, runner?: SbomRunner | null): string | undefined;
176
+ /** @internal Test-only override of the default runner. Pass null to simulate west-not-found. */
177
+ export declare function __setSbomRunnerForTest(runner: SbomRunner | null | undefined): void;
178
+ /** `typecad-hal sbom` presenter: generate (default), --check, or --diff.
179
+ * `--stdout` (generate mode) prints ONLY the JSON document — the banner,
180
+ * summary, and warnings are suppressed so it is a clean CI pipe. */
181
+ export declare function runSbomPresenter(options: SbomPresenterOptions): void;