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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/dist/api/config.d.ts +32 -0
  2. package/dist/api/index.d.ts +1 -1
  3. package/dist/api/schema/types.d.ts +15 -0
  4. package/dist/api/shared/async-runtime-static.d.ts +12 -1
  5. package/dist/api/shared/async-runtime-static.js +69 -24
  6. package/dist/api/shared/async-symbol-detector.d.ts +11 -0
  7. package/dist/api/shared/async-symbol-detector.js +140 -0
  8. package/dist/api/shared/async-types.d.ts +24 -0
  9. package/dist/api/shared/coop-scheduler.d.ts +60 -0
  10. package/dist/api/shared/coop-scheduler.js +149 -0
  11. package/dist/api/shared/display-adapter.d.ts +4 -3
  12. package/dist/api/shared/display-adapter.js +15 -118
  13. package/dist/api/shared/display-adapters/sdl.js +38 -31
  14. package/dist/api/shared/display-profile.d.ts +47 -25
  15. package/dist/api/shared/display-profile.js +31 -164
  16. package/dist/api/shared/framework-manifest-registry.d.ts +9 -0
  17. package/dist/api/shared/framework-manifest-registry.js +27 -0
  18. package/dist/api/shared/framework-manifest.d.ts +581 -0
  19. package/dist/api/shared/framework-manifest.js +182 -0
  20. package/dist/api/shared/glcdfont.d.ts +12 -0
  21. package/dist/api/shared/glcdfont.js +124 -0
  22. package/dist/api/shared/graphics-strategy.d.ts +37 -0
  23. package/dist/api/shared/hal-op-ir.d.ts +755 -1
  24. package/dist/api/shared/hal-op-ir.js +129 -1
  25. package/dist/api/shared/index.d.ts +20 -2
  26. package/dist/api/shared/index.js +25 -1
  27. package/dist/api/shared/ir-core.d.ts +4 -0
  28. package/dist/api/shared/ir-declarations.d.ts +6 -0
  29. package/dist/api/shared/native-display-op-resolver.d.ts +10 -0
  30. package/dist/api/shared/native-display-op-resolver.js +64 -0
  31. package/dist/api/shared/platform-strategy.d.ts +113 -2
  32. package/dist/api/shared/polyfill-helper-registry.js +18 -1
  33. package/dist/api/shared/promise-runtime.d.ts +1 -1
  34. package/dist/api/shared/promise-runtime.js +95 -13
  35. package/dist/api/shared/toolchain-types.d.ts +17 -0
  36. package/dist/api/shared/validate-framework-manifest.d.ts +28 -0
  37. package/dist/api/shared/validate-framework-manifest.js +494 -0
  38. package/dist/api/shared/worker-runtime-polyfill.d.ts +22 -0
  39. package/dist/api/shared/worker-runtime-polyfill.js +34 -0
  40. package/dist/api/shared/worker-runtime.d.ts +69 -0
  41. package/dist/api/shared/worker-runtime.js +163 -0
  42. package/dist/cli.js +186 -82
  43. package/dist/config-loader.d.ts +7 -2
  44. package/dist/config-loader.js +23 -3
  45. package/dist/config-schema.d.ts +112 -70
  46. package/dist/config-schema.js +14 -0
  47. package/dist/contract/board-generator.d.ts +17 -0
  48. package/dist/contract/board-generator.js +57 -0
  49. package/dist/contract/contract-parser.d.ts +217 -0
  50. package/dist/contract/contract-parser.js +224 -0
  51. package/dist/contract/index.d.ts +22 -0
  52. package/dist/contract/index.js +68 -0
  53. package/dist/create/board-codegen.js +4 -4
  54. package/dist/create/board-generators.js +4 -5
  55. package/dist/create/board-spec.d.ts +72 -75
  56. package/dist/create/board-spec.js +0 -1
  57. package/dist/create/init-scaffold.d.ts +9 -2
  58. package/dist/create/init-scaffold.js +0 -14
  59. package/dist/create/init-templates.d.ts +2 -0
  60. package/dist/create/init-templates.js +74 -8
  61. package/dist/create/init-wizard.js +31 -7
  62. package/dist/debug/preprocessor.js +178 -39
  63. package/dist/debug/types.d.ts +23 -0
  64. package/dist/diagnostics/mermaid-builder.d.ts +1 -1
  65. package/dist/diagnostics/mermaid-builder.js +34 -24
  66. package/dist/emit/compliance/arxml-writer.d.ts +11 -0
  67. package/dist/emit/compliance/arxml-writer.js +34 -0
  68. package/dist/emit/compliance/compliance-context.d.ts +57 -0
  69. package/dist/emit/compliance/compliance-context.js +113 -0
  70. package/dist/emit/compliance/deviation-ledger.d.ts +27 -0
  71. package/dist/emit/compliance/deviation-ledger.js +47 -0
  72. package/dist/emit/compliance/deviation-writer.d.ts +30 -0
  73. package/dist/emit/compliance/deviation-writer.js +37 -0
  74. package/dist/emit/compliance/index.d.ts +7 -0
  75. package/dist/emit/compliance/index.js +6 -0
  76. package/dist/emit/compliance/rule-engine.d.ts +13 -0
  77. package/dist/emit/compliance/rule-engine.js +101 -0
  78. package/dist/emit/compliance/rules.d.ts +16 -0
  79. package/dist/emit/compliance/rules.js +191 -0
  80. package/dist/emit/compliance/types.d.ts +59 -0
  81. package/dist/emit/compliance/types.js +8 -0
  82. package/dist/emit/cpp-emitter.js +4 -3
  83. package/dist/emit/emitters/class-emitter.js +6 -1
  84. package/dist/emit/emitters/emitter-context.d.ts +28 -1
  85. package/dist/emit/emitters/function-emitter-impl.js +153 -53
  86. package/dist/emit/emitters/line-appender.js +19 -0
  87. package/dist/emit/emitters/line-marker.d.ts +38 -0
  88. package/dist/emit/emitters/line-marker.js +39 -0
  89. package/dist/emit/emitters/output-finalizer.d.ts +6 -0
  90. package/dist/emit/emitters/output-finalizer.js +101 -12
  91. package/dist/emit/emitters/setup.d.ts +17 -0
  92. package/dist/emit/emitters/setup.js +257 -36
  93. package/dist/emit/emitters/top-level-prep.js +8 -0
  94. package/dist/emit/emitters/type-decl-emitter.js +28 -3
  95. package/dist/emit/emitters/ui-emitter.js +33 -9
  96. package/dist/emit/expression-renderer.d.ts +1 -1
  97. package/dist/emit/expression-renderer.js +91 -6
  98. package/dist/emit/route-hal-op.js +18 -5
  99. package/dist/emit/snprintf-helpers.js +15 -4
  100. package/dist/emit/statement-renderer.d.ts +10 -0
  101. package/dist/emit/statement-renderer.js +34 -5
  102. package/dist/emit/utils/async-state-machine.js +221 -125
  103. package/dist/emit/utils/hal-op-cpp-type.d.ts +6 -0
  104. package/dist/emit/utils/hal-op-cpp-type.js +40 -0
  105. package/dist/framework-package.js +2 -0
  106. package/dist/framework-registry.d.ts +17 -0
  107. package/dist/ir/adc-range-validation.js +14 -1
  108. package/dist/ir/build-ir-state.d.ts +1 -0
  109. package/dist/ir/build-ir-state.js +14 -0
  110. package/dist/ir/build-ir.js +9 -5
  111. package/dist/ir/call-graph.js +16 -0
  112. package/dist/ir/expression-to-ir.js +164 -0
  113. package/dist/ir/feature-registry.js +7 -25
  114. package/dist/ir/function-builder.js +22 -0
  115. package/dist/ir/hal/hal-emitter.d.ts +5 -2
  116. package/dist/ir/hal/hal-emitter.js +50 -18
  117. package/dist/ir/hal/hal-parser.d.ts +6 -0
  118. package/dist/ir/hal/hal-parser.js +81 -0
  119. package/dist/ir/hal/hal-plugins.js +723 -1
  120. package/dist/ir/identifier-collector.js +35 -0
  121. package/dist/ir/interrupt-analysis.d.ts +5 -1
  122. package/dist/ir/interrupt-analysis.js +8 -16
  123. package/dist/ir/network-validation.d.ts +4 -0
  124. package/dist/ir/network-validation.js +184 -0
  125. package/dist/ir/ownership-analysis.js +20 -1
  126. package/dist/ir/pin-capability-validation.js +37 -0
  127. package/dist/ir/pin-mode-validation.d.ts +2 -2
  128. package/dist/ir/pin-mode-validation.js +49 -18
  129. package/dist/ir/program-analysis.d.ts +65 -0
  130. package/dist/ir/program-analysis.js +318 -2
  131. package/dist/ir/render-expr.js +11 -0
  132. package/dist/ir/timing-validation.d.ts +6 -1
  133. package/dist/ir/timing-validation.js +60 -13
  134. package/dist/ir/transformers/call-statement.js +105 -0
  135. package/dist/ir/transformers/expressions.js +62 -0
  136. package/dist/ir/transformers/hal-call-resolver.js +21 -0
  137. package/dist/ir/transformers/hal-emit-helpers.js +1 -1
  138. package/dist/ir/transformers/namespace-methods.js +17 -12
  139. package/dist/ir/transformers/ui-reactive.js +2 -2
  140. package/dist/ir/transformers/variables.js +92 -3
  141. package/dist/ir/type-resolution.js +18 -0
  142. package/dist/ir/ui-element-auto-wire.js +7 -5
  143. package/dist/ir/utils/map-statements.d.ts +4 -0
  144. package/dist/ir/utils/map-statements.js +79 -0
  145. package/dist/ir/validation-orchestrator.js +9 -2
  146. package/dist/ir/worker-analysis.d.ts +10 -0
  147. package/dist/ir/worker-analysis.js +261 -0
  148. package/dist/libdef/c-to-decl.d.ts +27 -0
  149. package/dist/libdef/c-to-decl.js +397 -0
  150. package/dist/libdef/component-decls.d.ts +2 -0
  151. package/dist/libdef/component-decls.js +6 -0
  152. package/dist/libdef/component-discovery.d.ts +43 -0
  153. package/dist/libdef/component-discovery.js +83 -0
  154. package/dist/libdef/cpp-to-decl.d.ts +9 -0
  155. package/dist/libdef/cpp-to-decl.js +72 -0
  156. package/dist/libdef/registry.js +5 -2
  157. package/dist/lint-cache.d.ts +59 -0
  158. package/dist/lint-cache.js +257 -0
  159. package/dist/orchestrator/graph-builder.js +14 -9
  160. package/dist/platform/coop-scheduler-runtime.d.ts +19 -0
  161. package/dist/platform/coop-scheduler-runtime.js +41 -0
  162. package/dist/platform/generic-strategy.d.ts +15 -3
  163. package/dist/platform/generic-strategy.js +49 -4
  164. package/dist/safety/safety-bridge.d.ts +11 -0
  165. package/dist/safety/safety-bridge.js +48 -0
  166. package/dist/safety/sidecar-bridge.d.ts +5 -0
  167. package/dist/safety/sidecar-bridge.js +22 -0
  168. package/dist/safety-hook.d.ts +79 -0
  169. package/dist/safety-hook.js +35 -0
  170. package/dist/testing.d.ts +7 -1
  171. package/dist/testing.js +8 -1
  172. package/dist/transpile.d.ts +3 -0
  173. package/dist/transpile.js +175 -41
  174. package/dist/types.d.ts +13 -2
  175. package/dist/ui-hook.d.ts +17 -3
  176. package/dist/utils/cli.js +78 -4
  177. package/dist/utils/fs.d.ts +13 -0
  178. package/dist/utils/fs.js +50 -0
  179. package/package.json +24 -5
  180. package/dist/api/shared/display-adapters/eink-mono.d.ts +0 -2
  181. package/dist/api/shared/display-adapters/eink-mono.js +0 -53
  182. package/dist/api/shared/display-adapters/ssd1309.d.ts +0 -2
  183. package/dist/api/shared/display-adapters/ssd1309.js +0 -136
  184. package/dist/api/shared/display-adapters/st7796.d.ts +0 -2
  185. package/dist/api/shared/display-adapters/st7796.js +0 -132
  186. package/dist/licenses.d.ts +0 -185
  187. package/dist/licenses.js +0 -963
@@ -0,0 +1,182 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Framework manifest schema
3
+ //
4
+ // Single source of truth for "what a framework is." A zod schema defines the
5
+ // contract; the FrameworkManifest type is inferred from it so there is no
6
+ // drift between runtime validation and static types. Each field maps to a real
7
+ // code artifact (PlatformStrategy method, LoadedFramework export, file path).
8
+ //
9
+ // Per-package `framework.manifest.ts` files call defineFrameworkManifest() to
10
+ // declare their coverage. The validator in validate-framework-manifest.ts
11
+ // cross-checks each claim against the loaded strategy/toolchain.
12
+ // ---------------------------------------------------------------------------
13
+ import { z } from 'zod';
14
+ // Core HAL categories that EVERY framework MUST declare coverage for (the
15
+ // universal embedded surface: digital/analog I/O, comms buses, timing, power,
16
+ // watchdog). These keys are required in every manifest's `hal` block.
17
+ //
18
+ // Extended categories — `rmt`, `ble`, `preferences`, `random`, `fs`, `mqtt`,
19
+ // `mdns`, `ota`, etc. — are OPTIONAL: a framework declares them only if it
20
+ // lowers them. The HalCoverageSchema below uses `.catchall()` so declared
21
+ // extended categories survive zod parsing (they used to be silently stripped,
22
+ // which made esp32's ble/rmt/preferences manifest blocks dead data) and get
23
+ // validated by the manifest validator like any core category. A framework that
24
+ // does not lower an extended category simply omits it.
25
+ const HAL_CATEGORIES = [
26
+ 'gpio', 'pwm', 'adc', 'dac', 'interrupts', 'tone', 'timing', 'power',
27
+ 'i2c', 'spi', 'uart', 'pulse', 'shift', 'board', 'wdt', 'wifi', 'http',
28
+ 'mqtt', 'display',
29
+ ];
30
+ const OpStatus = z.enum(['supported', 'stub', 'unsupported', 'probe-inconclusive', 'polyfill']);
31
+ const HalCategorySchema = z.object({
32
+ supported: z.boolean(),
33
+ unsupportedReason: z.string().optional(),
34
+ ops: z.record(z.string(), OpStatus),
35
+ partialCoverage: z.boolean().default(false),
36
+ });
37
+ const DisplayCategorySchema = HalCategorySchema.extend({
38
+ drivers: z.array(z.string()),
39
+ colorFormat: z.enum(['rgb565', 'mono']).nullable(),
40
+ });
41
+ const HalCoverageSchema = z.object(Object.fromEntries(HAL_CATEGORIES.map((c) => [
42
+ c,
43
+ c === 'display' ? DisplayCategorySchema : HalCategorySchema,
44
+ ]))).extend({
45
+ raw: z.object({ supported: z.boolean() }).default({ supported: true }),
46
+ // catchall: extended categories (rmt, ble, preferences, random, fs, mqtt,
47
+ // mdns, ota, ...) declared by a framework that lowers them. Without this,
48
+ // zod's default object parsing silently strips unknown keys, so a manifest's
49
+ // `ble:` / `rmt:` / `preferences:` / `random:` blocks never reached the
50
+ // validator or consumers. The catchall validates them with the same shape as
51
+ // core categories (HalCategorySchema) and preserves them on the parsed
52
+ // object. Frameworks that don't lower an extended category simply omit it.
53
+ // `raw` is excluded — it is the escape hatch, not a HAL category.
54
+ }).catchall(HalCategorySchema);
55
+ const EntrypointSchema = z.object({
56
+ entrypointFunctionName: z.string(),
57
+ requiresLoopFunction: z.boolean(),
58
+ sourceExtension: z.enum(['ino', 'cc', 'cpp', 'h']),
59
+ overrideBaseName: z.string().optional(),
60
+ outputSubdirectory: z.string().optional(),
61
+ generateHeaderFile: z.boolean(),
62
+ customBridgeShim: z.string().optional(),
63
+ });
64
+ const ProfileSchema = z.object({
65
+ targets: z.array(z.string()),
66
+ forcedIncludes: z.array(z.string()),
67
+ symbolAliases: z.record(z.string(), z.string()),
68
+ });
69
+ const PolyfillCoverageSchema = z.object({
70
+ emitted: z.array(z.object({
71
+ id: z.string(),
72
+ domain: z.string(),
73
+ notes: z.string().optional(),
74
+ })),
75
+ suppressed: z.array(z.object({
76
+ id: z.string(),
77
+ reason: z.string(),
78
+ })),
79
+ });
80
+ const ToolchainCoverageSchema = z.object({
81
+ backend: z.string(),
82
+ operations: z.object({
83
+ prepare: z.boolean(),
84
+ compile: z.boolean(),
85
+ upload: z.boolean(),
86
+ monitor: z.boolean(),
87
+ }),
88
+ reexportedFrom: z.string().optional(),
89
+ });
90
+ const LibraryResolutionSchema = z.object({
91
+ isFrameworkLibraryImport: z.boolean(),
92
+ getFrameworkLibraryHeaderName: z.boolean(),
93
+ buildClassNameMap: z.boolean(),
94
+ tryGenerateLibDecl: z.boolean(),
95
+ reexportedFrom: z.string().optional(),
96
+ });
97
+ /**
98
+ * Capability block for an optional subcommand the framework may own (e.g.
99
+ * `cuttlefish doctor`, `cuttlefish licenses`). The manifest only declares
100
+ * availability; the framework's runtime `doctor` / `licenses` exports provide
101
+ * the implementation, and cuttlefish dispatches to them when present.
102
+ */
103
+ const SubcommandCapabilitySchema = z.object({
104
+ available: z.boolean(),
105
+ });
106
+ const StdLibSupportSchema = z.object({
107
+ hasVector: z.boolean(),
108
+ hasString: z.boolean(),
109
+ hasIostream: z.boolean(),
110
+ hasExceptions: z.boolean(),
111
+ hasRTTI: z.boolean(),
112
+ recommendedArrayImpl: z.enum(['std_vector', 'static_array']),
113
+ recommendedStringImpl: z.enum(['std_string', 'static_string']),
114
+ });
115
+ const TypeEmissionSchema = z.object({
116
+ normalizeCppType: z.boolean(),
117
+ mathHeader: z.enum(['none', '<math.h>', '<Arduino.h>']),
118
+ needsStdString: z.boolean(),
119
+ needsStdVector: z.boolean(),
120
+ needsIostream: z.boolean(),
121
+ needsStdFunction: z.boolean(),
122
+ stdlibSupport: StdLibSupportSchema,
123
+ });
124
+ const ConformanceSchema = z.object({
125
+ hardwareTestGroups: z.array(z.string()),
126
+ halResolutionTests: z.array(z.string()),
127
+ });
128
+ export const FrameworkManifestSchema = z.object({
129
+ schemaVersion: z.literal(1),
130
+ frameworkId: z.string(),
131
+ packageName: z.string(),
132
+ canonical: z.boolean().default(false),
133
+ displayName: z.string(),
134
+ description: z.string(),
135
+ basedOn: z.string().optional(),
136
+ implementationMode: z.enum(['from-scratch', 'extends-canonical', 'extends-other']),
137
+ inheritsStrategyId: z.string().optional(),
138
+ entrypoint: EntrypointSchema,
139
+ profile: ProfileSchema,
140
+ hal: HalCoverageSchema,
141
+ polyfills: PolyfillCoverageSchema,
142
+ toolchain: ToolchainCoverageSchema,
143
+ libraryResolution: LibraryResolutionSchema.optional(),
144
+ typeEmission: TypeEmissionSchema,
145
+ ambientTypes: z.array(z.string()),
146
+ conformance: ConformanceSchema,
147
+ // Optional subcommand capabilities owned by the framework. When declared
148
+ // `{ available: true }`, the framework exports matching `doctor` / `licenses`
149
+ // functions that cuttlefish dispatches the corresponding CLI subcommands to.
150
+ doctor: SubcommandCapabilitySchema.optional(),
151
+ licenses: SubcommandCapabilitySchema.optional(),
152
+ });
153
+ /**
154
+ * Authoritative map of HAL op kinds that are lowered via the polyfill system
155
+ * rather than via `resolveHALOperation`. Keyed by op kind; value is the
156
+ * polyfill id that backs it.
157
+ *
158
+ * The manifest validator uses this to verify `polyfill`-declared ops: if a
159
+ * manifest declares `timing.set_interval: 'polyfill'`, the framework's
160
+ * `polyfills.emitted` list must include the polyfill id named here.
161
+ *
162
+ * Keep in sync with the transpiler's lowering routes — when a new op kind
163
+ * starts being routed via a polyfill instead of the HAL resolver, add it
164
+ * here. The set is intentionally small and stable: polyfill-routed ops are
165
+ * the exception, not the rule.
166
+ */
167
+ export const POLYFILL_BACKED_OPS = {
168
+ 'timing.set_interval': 'timer_methods',
169
+ 'timing.set_timeout': 'timer_methods',
170
+ 'timing.clear_interval': 'timer_methods',
171
+ 'timing.clear_timeout': 'timer_methods',
172
+ };
173
+ /**
174
+ * Validates and returns a FrameworkManifest. Frameworks call this from their
175
+ * `framework.manifest.ts` to get both static type-checking (the parameter type
176
+ * is the inferred FrameworkManifest) and runtime validation (zod parse).
177
+ * Bad manifests throw at module-load time.
178
+ */
179
+ export function defineFrameworkManifest(input) {
180
+ return FrameworkManifestSchema.parse(input);
181
+ }
182
+ export { HAL_CATEGORIES };
@@ -0,0 +1,12 @@
1
+ export declare const GLCDFONT_BYTES: readonly number[];
2
+ /**
3
+ * Render the font as a C++ byte-array literal (16 bytes per line). Used by
4
+ * adapters that need the table emitted into the synthesized translation unit.
5
+ *
6
+ * Example output:
7
+ * static const uint8_t glcdfont[] = {
8
+ * 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x5b, 0x4f, 0x5b, 0x3e, ...
9
+ * ...
10
+ * };
11
+ */
12
+ export declare function renderGlcdfontArray(name: string, type?: string): string;
@@ -0,0 +1,124 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Adafruit GFX 5x7 glcdfont — the 'classic' fixed-space bitmap font shipped
3
+ // with Adafruit_GFX since 1.0.
4
+ //
5
+ // Source: Adafruit_GFX library glcdfont.c
6
+ // Copyright (c) 2013 Adafruit Industries. All rights reserved.
7
+ // Licensed under BSD-3-Clause (as part of the Adafruit_GFX library).
8
+ // Upstream: https://github.com/adafruit/Adafruit-GFX-Library/blob/master/glcdfont.c
9
+ //
10
+ // NOTE: an earlier revision of this file described the bytes as "public
11
+ // domain." That claim could not be verified — glcdfont.c carries no
12
+ // per-file license statement and is distributed as part of the BSD-3-Clause
13
+ // Adafruit_GFX library, so the conservative treatment is BSD-3-Clause.
14
+ //
15
+ // Shared between:
16
+ // - packages/cuttlefish/src/api/shared/display-adapters/sdl.ts
17
+ // (emits __sdl_glcdfont[] for the SDL preview host adapter)
18
+ // - packages/ui/src/ui-engine/runtime-header/cuttlefish-gfx.ts
19
+ // (emits glcdfont[] for native display adapters — AVR, ESP32)
20
+ //
21
+ // 256 glyphs × 5 bytes = 1280 bytes. Indexed as glcdfont[ch * 5 + column].
22
+ // ---------------------------------------------------------------------------
23
+ export const GLCDFONT_BYTES = [
24
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x5b, 0x4f, 0x5b, 0x3e, 0x3e, 0x6b, 0x4f, 0x6b, 0x3e, 0x1c,
25
+ 0x3e, 0x7c, 0x3e, 0x1c, 0x18, 0x3c, 0x7e, 0x3c, 0x18, 0x1c, 0x57, 0x7d, 0x57, 0x1c, 0x1c, 0x5e,
26
+ 0x7f, 0x5e, 0x1c, 0x00, 0x18, 0x3c, 0x18, 0x00, 0xff, 0xe7, 0xc3, 0xe7, 0xff, 0x00, 0x18, 0x24,
27
+ 0x18, 0x00, 0xff, 0xe7, 0xdb, 0xe7, 0xff, 0x30, 0x48, 0x3a, 0x06, 0x0e, 0x26, 0x29, 0x79, 0x29,
28
+ 0x26, 0x40, 0x7f, 0x05, 0x05, 0x07, 0x40, 0x7f, 0x05, 0x25, 0x3f, 0x5a, 0x3c, 0xe7, 0x3c, 0x5a,
29
+ 0x7f, 0x3e, 0x1c, 0x1c, 0x08, 0x08, 0x1c, 0x1c, 0x3e, 0x7f, 0x14, 0x22, 0x7f, 0x22, 0x14, 0x5f,
30
+ 0x5f, 0x00, 0x5f, 0x5f, 0x06, 0x09, 0x7f, 0x01, 0x7f, 0x00, 0x66, 0x89, 0x95, 0x6a, 0x60, 0x60,
31
+ 0x60, 0x60, 0x60, 0x94, 0xa2, 0xff, 0xa2, 0x94, 0x08, 0x04, 0x7e, 0x04, 0x08, 0x10, 0x20, 0x7e,
32
+ 0x20, 0x10, 0x08, 0x08, 0x2a, 0x1c, 0x08, 0x08, 0x1c, 0x2a, 0x08, 0x08, 0x1e, 0x10, 0x10, 0x10,
33
+ 0x10, 0x0c, 0x1e, 0x0c, 0x1e, 0x0c, 0x30, 0x38, 0x3e, 0x38, 0x30, 0x06, 0x0e, 0x3e, 0x0e, 0x06,
34
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x14,
35
+ 0x7f, 0x14, 0x7f, 0x14, 0x24, 0x2a, 0x7f, 0x2a, 0x12, 0x23, 0x13, 0x08, 0x64, 0x62, 0x36, 0x49,
36
+ 0x56, 0x20, 0x50, 0x00, 0x08, 0x07, 0x03, 0x00, 0x00, 0x1c, 0x22, 0x41, 0x00, 0x00, 0x41, 0x22,
37
+ 0x1c, 0x00, 0x2a, 0x1c, 0x7f, 0x1c, 0x2a, 0x08, 0x08, 0x3e, 0x08, 0x08, 0x00, 0x80, 0x70, 0x30,
38
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 0x60, 0x60, 0x00, 0x20, 0x10, 0x08, 0x04, 0x02,
39
+ 0x3e, 0x51, 0x49, 0x45, 0x3e, 0x00, 0x42, 0x7f, 0x40, 0x00, 0x72, 0x49, 0x49, 0x49, 0x46, 0x21,
40
+ 0x41, 0x49, 0x4d, 0x33, 0x18, 0x14, 0x12, 0x7f, 0x10, 0x27, 0x45, 0x45, 0x45, 0x39, 0x3c, 0x4a,
41
+ 0x49, 0x49, 0x31, 0x41, 0x21, 0x11, 0x09, 0x07, 0x36, 0x49, 0x49, 0x49, 0x36, 0x46, 0x49, 0x49,
42
+ 0x29, 0x1e, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40, 0x34, 0x00, 0x00, 0x00, 0x08, 0x14, 0x22,
43
+ 0x41, 0x14, 0x14, 0x14, 0x14, 0x14, 0x00, 0x41, 0x22, 0x14, 0x08, 0x02, 0x01, 0x59, 0x09, 0x06,
44
+ 0x3e, 0x41, 0x5d, 0x59, 0x4e, 0x7c, 0x12, 0x11, 0x12, 0x7c, 0x7f, 0x49, 0x49, 0x49, 0x36, 0x3e,
45
+ 0x41, 0x41, 0x41, 0x22, 0x7f, 0x41, 0x41, 0x41, 0x3e, 0x7f, 0x49, 0x49, 0x49, 0x41, 0x7f, 0x09,
46
+ 0x09, 0x09, 0x01, 0x3e, 0x41, 0x41, 0x51, 0x73, 0x7f, 0x08, 0x08, 0x08, 0x7f, 0x00, 0x41, 0x7f,
47
+ 0x41, 0x00, 0x20, 0x40, 0x41, 0x3f, 0x01, 0x7f, 0x08, 0x14, 0x22, 0x41, 0x7f, 0x40, 0x40, 0x40,
48
+ 0x40, 0x7f, 0x02, 0x1c, 0x02, 0x7f, 0x7f, 0x04, 0x08, 0x10, 0x7f, 0x3e, 0x41, 0x41, 0x41, 0x3e,
49
+ 0x7f, 0x09, 0x09, 0x09, 0x06, 0x3e, 0x41, 0x51, 0x21, 0x5e, 0x7f, 0x09, 0x19, 0x29, 0x46, 0x26,
50
+ 0x49, 0x49, 0x49, 0x32, 0x03, 0x01, 0x7f, 0x01, 0x03, 0x3f, 0x40, 0x40, 0x40, 0x3f, 0x1f, 0x20,
51
+ 0x40, 0x20, 0x1f, 0x3f, 0x40, 0x38, 0x40, 0x3f, 0x63, 0x14, 0x08, 0x14, 0x63, 0x03, 0x04, 0x78,
52
+ 0x04, 0x03, 0x61, 0x59, 0x49, 0x4d, 0x43, 0x00, 0x7f, 0x41, 0x41, 0x41, 0x02, 0x04, 0x08, 0x10,
53
+ 0x20, 0x00, 0x41, 0x41, 0x41, 0x7f, 0x04, 0x02, 0x01, 0x02, 0x04, 0x40, 0x40, 0x40, 0x40, 0x40,
54
+ 0x00, 0x03, 0x07, 0x08, 0x00, 0x20, 0x54, 0x54, 0x78, 0x40, 0x7f, 0x28, 0x44, 0x44, 0x38, 0x38,
55
+ 0x44, 0x44, 0x44, 0x28, 0x38, 0x44, 0x44, 0x28, 0x7f, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x08,
56
+ 0x7e, 0x09, 0x02, 0x18, 0xa4, 0xa4, 0x9c, 0x78, 0x7f, 0x08, 0x04, 0x04, 0x78, 0x00, 0x44, 0x7d,
57
+ 0x40, 0x00, 0x20, 0x40, 0x40, 0x3d, 0x00, 0x7f, 0x10, 0x28, 0x44, 0x00, 0x00, 0x41, 0x7f, 0x40,
58
+ 0x00, 0x7c, 0x04, 0x78, 0x04, 0x78, 0x7c, 0x08, 0x04, 0x04, 0x78, 0x38, 0x44, 0x44, 0x44, 0x38,
59
+ 0xfc, 0x18, 0x24, 0x24, 0x18, 0x18, 0x24, 0x24, 0x18, 0xfc, 0x7c, 0x08, 0x04, 0x04, 0x08, 0x48,
60
+ 0x54, 0x54, 0x54, 0x24, 0x04, 0x04, 0x3f, 0x44, 0x24, 0x3c, 0x40, 0x40, 0x20, 0x7c, 0x1c, 0x20,
61
+ 0x40, 0x20, 0x1c, 0x3c, 0x40, 0x30, 0x40, 0x3c, 0x44, 0x28, 0x10, 0x28, 0x44, 0x4c, 0x90, 0x90,
62
+ 0x90, 0x7c, 0x44, 0x64, 0x54, 0x4c, 0x44, 0x00, 0x08, 0x36, 0x41, 0x00, 0x00, 0x00, 0x77, 0x00,
63
+ 0x00, 0x00, 0x41, 0x36, 0x08, 0x00, 0x02, 0x01, 0x02, 0x04, 0x02, 0x3c, 0x26, 0x23, 0x26, 0x3c,
64
+ 0x1e, 0xa1, 0xa1, 0x61, 0x12, 0x3a, 0x40, 0x40, 0x20, 0x7a, 0x38, 0x54, 0x54, 0x55, 0x59, 0x21,
65
+ 0x55, 0x55, 0x79, 0x41, 0x22, 0x54, 0x54, 0x78, 0x42, 0x21, 0x55, 0x54, 0x78, 0x40, 0x20, 0x54,
66
+ 0x55, 0x79, 0x40, 0x0c, 0x1e, 0x52, 0x72, 0x12, 0x39, 0x55, 0x55, 0x55, 0x59, 0x39, 0x54, 0x54,
67
+ 0x54, 0x59, 0x39, 0x55, 0x54, 0x54, 0x58, 0x00, 0x00, 0x45, 0x7c, 0x41, 0x00, 0x02, 0x45, 0x7d,
68
+ 0x42, 0x00, 0x01, 0x45, 0x7c, 0x40, 0x7d, 0x12, 0x11, 0x12, 0x7d, 0xf0, 0x28, 0x25, 0x28, 0xf0,
69
+ 0x7c, 0x54, 0x55, 0x45, 0x00, 0x20, 0x54, 0x54, 0x7c, 0x54, 0x7c, 0x0a, 0x09, 0x7f, 0x49, 0x32,
70
+ 0x49, 0x49, 0x49, 0x32, 0x3a, 0x44, 0x44, 0x44, 0x3a, 0x32, 0x4a, 0x48, 0x48, 0x30, 0x3a, 0x41,
71
+ 0x41, 0x21, 0x7a, 0x3a, 0x42, 0x40, 0x20, 0x78, 0x00, 0x9d, 0xa0, 0xa0, 0x7d, 0x3d, 0x42, 0x42,
72
+ 0x42, 0x3d, 0x3d, 0x40, 0x40, 0x40, 0x3d, 0x3c, 0x24, 0xff, 0x24, 0x24, 0x48, 0x7e, 0x49, 0x43,
73
+ 0x66, 0x2b, 0x2f, 0xfc, 0x2f, 0x2b, 0xff, 0x09, 0x29, 0xf6, 0x20, 0xc0, 0x88, 0x7e, 0x09, 0x03,
74
+ 0x20, 0x54, 0x54, 0x79, 0x41, 0x00, 0x00, 0x44, 0x7d, 0x41, 0x30, 0x48, 0x48, 0x4a, 0x32, 0x38,
75
+ 0x40, 0x40, 0x22, 0x7a, 0x00, 0x7a, 0x0a, 0x0a, 0x72, 0x7d, 0x0d, 0x19, 0x31, 0x7d, 0x26, 0x29,
76
+ 0x29, 0x2f, 0x28, 0x26, 0x29, 0x29, 0x29, 0x26, 0x30, 0x48, 0x4d, 0x40, 0x20, 0x38, 0x08, 0x08,
77
+ 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x38, 0x2f, 0x10, 0xc8, 0xac, 0xba, 0x2f, 0x10, 0x28, 0x34,
78
+ 0xfa, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x08, 0x14, 0x2a, 0x14, 0x22, 0x22, 0x14, 0x2a, 0x14, 0x08,
79
+ 0x55, 0x00, 0x55, 0x00, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0xff, 0x55, 0xff, 0x55, 0xff, 0x00,
80
+ 0x00, 0x00, 0xff, 0x00, 0x10, 0x10, 0x10, 0xff, 0x00, 0x14, 0x14, 0x14, 0xff, 0x00, 0x10, 0x10,
81
+ 0xff, 0x00, 0xff, 0x10, 0x10, 0xf0, 0x10, 0xf0, 0x14, 0x14, 0x14, 0xfc, 0x00, 0x14, 0x14, 0xf7,
82
+ 0x00, 0xff, 0x00, 0x00, 0xff, 0x00, 0xff, 0x14, 0x14, 0xf4, 0x04, 0xfc, 0x14, 0x14, 0x17, 0x10,
83
+ 0x1f, 0x10, 0x10, 0x1f, 0x10, 0x1f, 0x14, 0x14, 0x14, 0x1f, 0x00, 0x10, 0x10, 0x10, 0xf0, 0x00,
84
+ 0x00, 0x00, 0x00, 0x1f, 0x10, 0x10, 0x10, 0x10, 0x1f, 0x10, 0x10, 0x10, 0x10, 0xf0, 0x10, 0x00,
85
+ 0x00, 0x00, 0xff, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0xff, 0x10, 0x00, 0x00,
86
+ 0x00, 0xff, 0x14, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x1f, 0x10, 0x17, 0x00, 0x00, 0xfc,
87
+ 0x04, 0xf4, 0x14, 0x14, 0x17, 0x10, 0x17, 0x14, 0x14, 0xf4, 0x04, 0xf4, 0x00, 0x00, 0xff, 0x00,
88
+ 0xf7, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xf7, 0x00, 0xf7, 0x14, 0x14, 0x14, 0x17, 0x14,
89
+ 0x10, 0x10, 0x1f, 0x10, 0x1f, 0x14, 0x14, 0x14, 0xf4, 0x14, 0x10, 0x10, 0xf0, 0x10, 0xf0, 0x00,
90
+ 0x00, 0x1f, 0x10, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x14, 0x00, 0x00, 0x00, 0xfc, 0x14, 0x00, 0x00,
91
+ 0xf0, 0x10, 0xf0, 0x10, 0x10, 0xff, 0x10, 0xff, 0x14, 0x14, 0x14, 0xff, 0x14, 0x10, 0x10, 0x10,
92
+ 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x10, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xf0, 0xf0, 0xf0,
93
+ 0xf0, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0x0f, 0x0f, 0x0f, 0x0f,
94
+ 0x38, 0x44, 0x44, 0x38, 0x44, 0xfc, 0x4a, 0x4a, 0x4a, 0x34, 0x7e, 0x02, 0x02, 0x06, 0x06, 0x02,
95
+ 0x7e, 0x02, 0x7e, 0x02, 0x63, 0x55, 0x49, 0x41, 0x63, 0x38, 0x44, 0x44, 0x3c, 0x04, 0x40, 0x7e,
96
+ 0x20, 0x1e, 0x20, 0x06, 0x02, 0x7e, 0x02, 0x02, 0x99, 0xa5, 0xe7, 0xa5, 0x99, 0x1c, 0x2a, 0x49,
97
+ 0x2a, 0x1c, 0x4c, 0x72, 0x01, 0x72, 0x4c, 0x30, 0x4a, 0x4d, 0x4d, 0x30, 0x30, 0x48, 0x78, 0x48,
98
+ 0x30, 0xbc, 0x62, 0x5a, 0x46, 0x3d, 0x3e, 0x49, 0x49, 0x49, 0x00, 0x7e, 0x01, 0x01, 0x01, 0x7e,
99
+ 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x44, 0x44, 0x5f, 0x44, 0x44, 0x40, 0x51, 0x4a, 0x44, 0x40, 0x40,
100
+ 0x44, 0x4a, 0x51, 0x40, 0x00, 0x00, 0xff, 0x01, 0x03, 0xe0, 0x80, 0xff, 0x00, 0x00, 0x08, 0x08,
101
+ 0x6b, 0x6b, 0x08, 0x36, 0x12, 0x36, 0x24, 0x36, 0x06, 0x0f, 0x09, 0x0f, 0x06, 0x00, 0x00, 0x18,
102
+ 0x18, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x30, 0x40, 0xff, 0x01, 0x01, 0x00, 0x1f, 0x01, 0x01,
103
+ 0x1e, 0x00, 0x19, 0x1d, 0x17, 0x12, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
104
+ ];
105
+ /**
106
+ * Render the font as a C++ byte-array literal (16 bytes per line). Used by
107
+ * adapters that need the table emitted into the synthesized translation unit.
108
+ *
109
+ * Example output:
110
+ * static const uint8_t glcdfont[] = {
111
+ * 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x5b, 0x4f, 0x5b, 0x3e, ...
112
+ * ...
113
+ * };
114
+ */
115
+ export function renderGlcdfontArray(name, type = "uint8_t") {
116
+ const lines = [];
117
+ for (let i = 0; i < GLCDFONT_BYTES.length; i += 16) {
118
+ const row = GLCDFONT_BYTES.slice(i, i + 16)
119
+ .map((b) => "0x" + b.toString(16).padStart(2, "0"))
120
+ .join(", ");
121
+ lines.push(` ${row},`);
122
+ }
123
+ return `static const ${type} ${name}[] = {\n${lines.join("\n")}\n};`;
124
+ }
@@ -1,4 +1,6 @@
1
1
  import type { DisplayHALOp } from "./display-op-ir.js";
2
+ import type { DisplayProfile, ResolvedDisplay, TouchProfile, TouchAdapterCodegen } from "./display-profile.js";
3
+ import type { DisplayAdapterCode } from "./display-adapter.js";
2
4
  export interface GraphicsCapacity {
3
5
  /** Max nodes the retained tree may hold on this target. */
4
6
  maxNodes: number;
@@ -15,6 +17,41 @@ export interface PlatformGraphicsStrategy {
15
17
  code?: string;
16
18
  expression?: string;
17
19
  } | undefined;
20
+ /**
21
+ * True if this strategy emits its own display adapters (e.g. framework-arduino
22
+ * owns the Adafruit_GFX drivers, framework-native owns SDL). When false or
23
+ * undefined, generateDisplayAdapter() falls back to cuttlefish's generic
24
+ * built-in adapter registry.
25
+ */
26
+ providesDisplayAdapter?(): boolean;
27
+ /**
28
+ * Returns the adapter code for one display, or undefined to defer to cuttlefish's
29
+ * built-in adapter registry. Only called when providesDisplayAdapter()
30
+ * returns true.
31
+ */
32
+ resolveDisplayAdapter?(display: ResolvedDisplay): DisplayAdapterCode | undefined;
33
+ /**
34
+ * True if this strategy emits its own touch adapters (ESP32 native). When
35
+ * false or undefined, generateTouchAdapter() falls back to the built-in
36
+ * library switch (the Arduino path, unchanged).
37
+ */
38
+ providesTouchAdapter?(): boolean;
39
+ /**
40
+ * Returns the touch adapter codegen for the given touch profile, or
41
+ * undefined to defer to the built-in library switch. Only called when
42
+ * providesTouchAdapter() returns true. Returning undefined for an
43
+ * unsupported library (e.g. XPT2046 on native IDF) lets the dispatch
44
+ * surface a clear compile-time error instead of emitting incompatible code.
45
+ */
46
+ resolveTouchAdapter?(touch: TouchProfile): TouchAdapterCodegen | undefined;
47
+ /**
48
+ * Optional hook returning this framework's named display-profile registry
49
+ * (profile name → DisplayProfile). When present, transpile.ts consults it to
50
+ * resolve `display.profile` config values instead of dynamically importing a
51
+ * framework module — so profile names resolve correctly per-framework.
52
+ * Returns undefined to fall back to the legacy dynamic-import path.
53
+ */
54
+ getProfileRegistry?(): Map<string, DisplayProfile>;
18
55
  /** Display driver ids this framework provides (e.g. new Set(["ili9341"])). */
19
56
  supportedDisplayDrivers(): ReadonlySet<string>;
20
57
  /** Target color format — drives transpile-time color resolution.