@typecad/ui 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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1443 -0
  3. package/dist/engine-index.d.ts +7 -0
  4. package/dist/engine-index.js +41 -0
  5. package/dist/index.d.ts +165 -0
  6. package/dist/index.js +42 -0
  7. package/dist/preview/build-program.d.ts +7 -0
  8. package/dist/preview/build-program.js +665 -0
  9. package/dist/preview/host-gfx.d.ts +90 -0
  10. package/dist/preview/host-gfx.js +552 -0
  11. package/dist/preview/host-ui-runtime.d.ts +241 -0
  12. package/dist/preview/host-ui-runtime.js +3236 -0
  13. package/dist/preview/types.d.ts +83 -0
  14. package/dist/preview/types.js +1 -0
  15. package/dist/types.d.ts +108 -0
  16. package/dist/types.js +10 -0
  17. package/dist/ui-engine/block-layout.d.ts +8 -0
  18. package/dist/ui-engine/block-layout.js +95 -0
  19. package/dist/ui-engine/color.d.ts +49 -0
  20. package/dist/ui-engine/color.js +273 -0
  21. package/dist/ui-engine/css-parser.d.ts +155 -0
  22. package/dist/ui-engine/css-parser.js +1058 -0
  23. package/dist/ui-engine/default-keyboards.d.ts +3 -0
  24. package/dist/ui-engine/default-keyboards.js +53 -0
  25. package/dist/ui-engine/easing.d.ts +12 -0
  26. package/dist/ui-engine/easing.js +76 -0
  27. package/dist/ui-engine/font-assets.d.ts +50 -0
  28. package/dist/ui-engine/font-assets.js +431 -0
  29. package/dist/ui-engine/html-parser.d.ts +116 -0
  30. package/dist/ui-engine/html-parser.js +284 -0
  31. package/dist/ui-engine/image-assets.d.ts +21 -0
  32. package/dist/ui-engine/image-assets.js +125 -0
  33. package/dist/ui-engine/inline-parser.d.ts +30 -0
  34. package/dist/ui-engine/inline-parser.js +66 -0
  35. package/dist/ui-engine/keyframes.d.ts +3 -0
  36. package/dist/ui-engine/keyframes.js +39 -0
  37. package/dist/ui-engine/layout-engine.d.ts +35 -0
  38. package/dist/ui-engine/layout-engine.js +203 -0
  39. package/dist/ui-engine/model.d.ts +239 -0
  40. package/dist/ui-engine/model.js +987 -0
  41. package/dist/ui-engine/rich-layout.d.ts +51 -0
  42. package/dist/ui-engine/rich-layout.js +220 -0
  43. package/dist/ui-engine/run-types.d.ts +13 -0
  44. package/dist/ui-engine/run-types.js +1 -0
  45. package/dist/ui-engine/runtime-header/antialiasing.d.ts +1 -0
  46. package/dist/ui-engine/runtime-header/antialiasing.js +141 -0
  47. package/dist/ui-engine/runtime-header/blend-bodies.d.ts +1 -0
  48. package/dist/ui-engine/runtime-header/blend-bodies.js +39 -0
  49. package/dist/ui-engine/runtime-header/canvas-helpers.d.ts +1 -0
  50. package/dist/ui-engine/runtime-header/canvas-helpers.js +155 -0
  51. package/dist/ui-engine/runtime-header/canvas-scrollbar.d.ts +1 -0
  52. package/dist/ui-engine/runtime-header/canvas-scrollbar.js +105 -0
  53. package/dist/ui-engine/runtime-header/color-mono-refresh.d.ts +1 -0
  54. package/dist/ui-engine/runtime-header/color-mono-refresh.js +154 -0
  55. package/dist/ui-engine/runtime-header/dirty-scroll-mutators.d.ts +1 -0
  56. package/dist/ui-engine/runtime-header/dirty-scroll-mutators.js +169 -0
  57. package/dist/ui-engine/runtime-header/display-shim.d.ts +1 -0
  58. package/dist/ui-engine/runtime-header/display-shim.js +104 -0
  59. package/dist/ui-engine/runtime-header/forward-decls.d.ts +1 -0
  60. package/dist/ui-engine/runtime-header/forward-decls.js +137 -0
  61. package/dist/ui-engine/runtime-header/guard-close.d.ts +1 -0
  62. package/dist/ui-engine/runtime-header/guard-close.js +8 -0
  63. package/dist/ui-engine/runtime-header/image-drawing.d.ts +1 -0
  64. package/dist/ui-engine/runtime-header/image-drawing.js +300 -0
  65. package/dist/ui-engine/runtime-header/init-press-input.d.ts +1 -0
  66. package/dist/ui-engine/runtime-header/init-press-input.js +126 -0
  67. package/dist/ui-engine/runtime-header/keyboard.d.ts +1 -0
  68. package/dist/ui-engine/runtime-header/keyboard.js +342 -0
  69. package/dist/ui-engine/runtime-header/node-decoration.d.ts +1 -0
  70. package/dist/ui-engine/runtime-header/node-decoration.js +212 -0
  71. package/dist/ui-engine/runtime-header/paint-order-coords.d.ts +1 -0
  72. package/dist/ui-engine/runtime-header/paint-order-coords.js +190 -0
  73. package/dist/ui-engine/runtime-header/paint-rects-repair.d.ts +1 -0
  74. package/dist/ui-engine/runtime-header/paint-rects-repair.js +553 -0
  75. package/dist/ui-engine/runtime-header/scroll-physics.d.ts +1 -0
  76. package/dist/ui-engine/runtime-header/scroll-physics.js +161 -0
  77. package/dist/ui-engine/runtime-header/state-bindings-nav.d.ts +1 -0
  78. package/dist/ui-engine/runtime-header/state-bindings-nav.js +176 -0
  79. package/dist/ui-engine/runtime-header/structs.d.ts +1 -0
  80. package/dist/ui-engine/runtime-header/structs.js +220 -0
  81. package/dist/ui-engine/runtime-header/text-rendering.d.ts +1 -0
  82. package/dist/ui-engine/runtime-header/text-rendering.js +715 -0
  83. package/dist/ui-engine/runtime-header/tick/bindings-phase.d.ts +1 -0
  84. package/dist/ui-engine/runtime-header/tick/bindings-phase.js +103 -0
  85. package/dist/ui-engine/runtime-header/tick/dirty-draw-phase.d.ts +1 -0
  86. package/dist/ui-engine/runtime-header/tick/dirty-draw-phase.js +1051 -0
  87. package/dist/ui-engine/runtime-header/tick/flush-phase.d.ts +1 -0
  88. package/dist/ui-engine/runtime-header/tick/flush-phase.js +17 -0
  89. package/dist/ui-engine/runtime-header/tick/scroll-canvas-phase.d.ts +1 -0
  90. package/dist/ui-engine/runtime-header/tick/scroll-canvas-phase.js +15 -0
  91. package/dist/ui-engine/runtime-header/tick/transitions-phase.d.ts +1 -0
  92. package/dist/ui-engine/runtime-header/tick/transitions-phase.js +213 -0
  93. package/dist/ui-engine/runtime-header/tick-motion-helpers.d.ts +1 -0
  94. package/dist/ui-engine/runtime-header/tick-motion-helpers.js +26 -0
  95. package/dist/ui-engine/runtime-header/tick.d.ts +1 -0
  96. package/dist/ui-engine/runtime-header/tick.js +17 -0
  97. package/dist/ui-engine/runtime-header/touch-keyboard-fwd.d.ts +1 -0
  98. package/dist/ui-engine/runtime-header/touch-keyboard-fwd.js +406 -0
  99. package/dist/ui-engine/runtime-header/types-defines.d.ts +1 -0
  100. package/dist/ui-engine/runtime-header/types-defines.js +79 -0
  101. package/dist/ui-engine/runtime-header.d.ts +1 -0
  102. package/dist/ui-engine/runtime-header.js +69 -0
  103. package/dist/ui-engine/scroll-memory-diagnostics.d.ts +16 -0
  104. package/dist/ui-engine/scroll-memory-diagnostics.js +58 -0
  105. package/dist/ui-engine/select-engine.d.ts +4 -0
  106. package/dist/ui-engine/select-engine.js +19 -0
  107. package/dist/ui-engine/style-resolver.d.ts +77 -0
  108. package/dist/ui-engine/style-resolver.js +341 -0
  109. package/dist/ui-engine/text-layout.d.ts +19 -0
  110. package/dist/ui-engine/text-layout.js +92 -0
  111. package/dist/ui-engine/transpile-ui.d.ts +11 -0
  112. package/dist/ui-engine/transpile-ui.js +33 -0
  113. package/dist/ui-engine/ua-stylesheet.d.ts +3 -0
  114. package/dist/ui-engine/ua-stylesheet.js +56 -0
  115. package/dist/ui-engine/ui-file-splitter.d.ts +14 -0
  116. package/dist/ui-engine/ui-file-splitter.js +47 -0
  117. package/dist/ui-engine/ui-lowering.d.ts +33 -0
  118. package/dist/ui-engine/ui-lowering.js +390 -0
  119. package/dist/ui-engine/ui-registry.d.ts +81 -0
  120. package/dist/ui-engine/ui-registry.js +429 -0
  121. package/dist/ui-engine/yoga-layout.d.ts +12 -0
  122. package/dist/ui-engine/yoga-layout.js +314 -0
  123. package/package.json +86 -0
  124. package/src/engine-index.ts +51 -0
  125. package/src/index.ts +232 -0
  126. package/src/preview/build-program.ts +734 -0
  127. package/src/preview/host-gfx.ts +580 -0
  128. package/src/preview/host-ui-runtime.ts +3245 -0
  129. package/src/preview/types.ts +96 -0
  130. package/src/types.ts +127 -0
  131. package/src/ui-engine/block-layout.ts +104 -0
  132. package/src/ui-engine/color.ts +263 -0
  133. package/src/ui-engine/css-parser.ts +1003 -0
  134. package/src/ui-engine/default-keyboards.ts +58 -0
  135. package/src/ui-engine/easing.ts +53 -0
  136. package/src/ui-engine/font-assets.ts +512 -0
  137. package/src/ui-engine/html-parser.ts +397 -0
  138. package/src/ui-engine/image-assets.ts +170 -0
  139. package/src/ui-engine/inline-parser.ts +78 -0
  140. package/src/ui-engine/keyframes.ts +47 -0
  141. package/src/ui-engine/layout-engine.ts +228 -0
  142. package/src/ui-engine/model.ts +1225 -0
  143. package/src/ui-engine/rich-layout.ts +257 -0
  144. package/src/ui-engine/run-types.ts +14 -0
  145. package/src/ui-engine/runtime-header/antialiasing.ts +141 -0
  146. package/src/ui-engine/runtime-header/blend-bodies.ts +39 -0
  147. package/src/ui-engine/runtime-header/canvas-helpers.ts +155 -0
  148. package/src/ui-engine/runtime-header/canvas-scrollbar.ts +105 -0
  149. package/src/ui-engine/runtime-header/color-mono-refresh.ts +154 -0
  150. package/src/ui-engine/runtime-header/dirty-scroll-mutators.ts +169 -0
  151. package/src/ui-engine/runtime-header/display-shim.ts +104 -0
  152. package/src/ui-engine/runtime-header/forward-decls.ts +137 -0
  153. package/src/ui-engine/runtime-header/guard-close.ts +8 -0
  154. package/src/ui-engine/runtime-header/image-drawing.ts +300 -0
  155. package/src/ui-engine/runtime-header/init-press-input.ts +126 -0
  156. package/src/ui-engine/runtime-header/keyboard.ts +342 -0
  157. package/src/ui-engine/runtime-header/node-decoration.ts +212 -0
  158. package/src/ui-engine/runtime-header/paint-order-coords.ts +190 -0
  159. package/src/ui-engine/runtime-header/paint-rects-repair.ts +553 -0
  160. package/src/ui-engine/runtime-header/scroll-physics.ts +161 -0
  161. package/src/ui-engine/runtime-header/state-bindings-nav.ts +176 -0
  162. package/src/ui-engine/runtime-header/structs.ts +220 -0
  163. package/src/ui-engine/runtime-header/text-rendering.ts +715 -0
  164. package/src/ui-engine/runtime-header/tick/bindings-phase.ts +103 -0
  165. package/src/ui-engine/runtime-header/tick/dirty-draw-phase.ts +1051 -0
  166. package/src/ui-engine/runtime-header/tick/flush-phase.ts +17 -0
  167. package/src/ui-engine/runtime-header/tick/scroll-canvas-phase.ts +15 -0
  168. package/src/ui-engine/runtime-header/tick/transitions-phase.ts +213 -0
  169. package/src/ui-engine/runtime-header/tick-motion-helpers.ts +26 -0
  170. package/src/ui-engine/runtime-header/tick.ts +18 -0
  171. package/src/ui-engine/runtime-header/touch-keyboard-fwd.ts +406 -0
  172. package/src/ui-engine/runtime-header/types-defines.ts +79 -0
  173. package/src/ui-engine/runtime-header.ts +71 -0
  174. package/src/ui-engine/scroll-memory-diagnostics.ts +79 -0
  175. package/src/ui-engine/select-engine.ts +21 -0
  176. package/src/ui-engine/style-resolver.ts +416 -0
  177. package/src/ui-engine/text-layout.ts +114 -0
  178. package/src/ui-engine/transpile-ui.ts +45 -0
  179. package/src/ui-engine/ua-stylesheet.ts +60 -0
  180. package/src/ui-engine/ui-file-splitter.ts +59 -0
  181. package/src/ui-engine/ui-lowering.ts +459 -0
  182. package/src/ui-engine/ui-registry.ts +530 -0
  183. package/src/ui-engine/yoga-layout.ts +309 -0
@@ -0,0 +1,7 @@
1
+ import type { TranspilerUIHook } from "@typecad/cuttlefish/ui-hook";
2
+ export type { TranspilerUIHook };
3
+ /**
4
+ * Build and return the TranspilerUIHook — the object cuttlefish core uses
5
+ * to access all UI capabilities (parsing, layout, lowering, emission).
6
+ */
7
+ export declare function registerTranspilerUI(): TranspilerUIHook;
@@ -0,0 +1,41 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Engine entry point for @typecad/ui.
3
+ //
4
+ // Cuttlefish dynamically imports this module when UI usage is detected:
5
+ // const engine = await import("@typecad/ui/engine");
6
+ // const hook = await engine.registerTranspilerUI();
7
+ //
8
+ // registerTranspilerUI() returns an object implementing the TranspilerUIHook
9
+ // interface defined in @typecad/cuttlefish. This is the single runtime
10
+ // contract between the two packages.
11
+ // ---------------------------------------------------------------------------
12
+ import { resetUIRegistry, loadUIModule, loadUIModuleFromText, getUIModule, hasUIModule, allUIModules, allLoweredUIModules, markEntryHasUI, entryHasUI, clearEntryHasUI, lowerOnMount, generateProjectUITypeDeclarations, } from "./ui-engine/ui-registry.js";
13
+ import { resolveColor, resolveColorInternal } from "./ui-engine/color.js";
14
+ import { emitRuntimeHeader } from "./ui-engine/runtime-header.js";
15
+ import { splitUiFile } from "./ui-engine/ui-file-splitter.js";
16
+ import { analyzeScrollMemory } from "./ui-engine/scroll-memory-diagnostics.js";
17
+ /**
18
+ * Build and return the TranspilerUIHook — the object cuttlefish core uses
19
+ * to access all UI capabilities (parsing, layout, lowering, emission).
20
+ */
21
+ export function registerTranspilerUI() {
22
+ return {
23
+ resetUIRegistry,
24
+ loadUIModule,
25
+ loadUIModuleFromText,
26
+ getUIModule,
27
+ hasUIModule,
28
+ allUIModules,
29
+ allLoweredUIModules,
30
+ markEntryHasUI,
31
+ entryHasUI,
32
+ clearEntryHasUI,
33
+ lowerOnMount,
34
+ resolveColor,
35
+ resolveColorInternal,
36
+ emitRuntimeHeader,
37
+ splitUiFile,
38
+ generateProjectUITypeDeclarations,
39
+ analyzeScrollMemory,
40
+ };
41
+ }
@@ -0,0 +1,165 @@
1
+ export type { ScreenTree, TextElement, ButtonElement, ViewElement, PressBinding, CheckElement, SelectElement, RadioElement, ProgressElement, RangeElement, InputElement, CanvasElement, CanvasCtx } from "./types.js";
2
+ import type { CanvasCtx } from "./types.js";
3
+ /** Allowed signal value types. The transpiler lowers each of these to a C++
4
+ * scalar: `number` → int/double, `string` → const char*, `boolean` → bool.
5
+ * Other types (objects, arrays, null) are rejected at type-check time by
6
+ * Signal<T extends SignalValue> and at build time by the `ui-signal-initializer`
7
+ * diagnostic. */
8
+ export type SignalValue = number | string | boolean;
9
+ /** A reactive signal whose value lives on the device. */
10
+ export interface Signal<T extends SignalValue> {
11
+ (): T;
12
+ set(value: T): void;
13
+ }
14
+ export interface MountOptions {
15
+ /** Display driver id (must be in the framework's supportedDisplayDrivers()). */
16
+ display?: string;
17
+ /** Bus identifier, e.g. "SPI" or "Wire". */
18
+ bus?: string;
19
+ /** Chip-select pin. */
20
+ cs?: number;
21
+ /** Data/command pin. */
22
+ dc?: number;
23
+ /** Reset pin. */
24
+ rst?: number;
25
+ /** Rotation override. Defaults to the project display profile. */
26
+ rotation?: number;
27
+ /** Backlight pin override. Defaults to the project display profile. */
28
+ backlight?: number;
29
+ /** SPI frequency override. Defaults to the project display profile. */
30
+ spiFrequency?: number;
31
+ /** I2C address override for I2C displays. Defaults to the project display profile. */
32
+ address?: number;
33
+ /** Reset pin override for I2C displays. Defaults to the project display profile. */
34
+ reset?: number;
35
+ }
36
+ /**
37
+ * Mount a baked UI tree to the display configured in `cuttlefish.config.ts`.
38
+ * Optional overrides are available for advanced cases, but ordinary apps should
39
+ * keep hardware setup in the project config and call `ui.mount(screen)`.
40
+ *
41
+ * Validates the driver against the active framework at transpile time
42
+ * (fail-fast). The tree is lowered to a static C++ node table; this call lowers
43
+ * to display.init + the first-frame draw.
44
+ *
45
+ * `tree` is typed loosely (a record of element handles) so the concrete
46
+ * ScreenTree interface generated per .ui.html file — which has concrete named
47
+ * fields rather than an index signature — is assignable. The transpiler
48
+ * intercepts the call structurally; the type only needs to permit it.
49
+ */
50
+ export declare function mount(tree: unknown, opts?: MountOptions): void;
51
+ /**
52
+ * Declare a reactive signal. Lowers to a plain device variable + dirty flag.
53
+ *
54
+ * Accepts `number`, `string`, or `boolean` literals. Literal values are widened
55
+ * to their primitive type so `ui.signal(0)` returns `Signal<number>` (and
56
+ * `.set(1)` works), not `Signal<0>`. Other types (objects, arrays, null) are
57
+ * rejected at type-check time and at build time with a `ui-signal-initializer`
58
+ * diagnostic.
59
+ */
60
+ export declare function signal(initial: number): Signal<number>;
61
+ export declare function signal(initial: string): Signal<string>;
62
+ export declare function signal(initial: boolean): Signal<boolean>;
63
+ /**
64
+ * Bind a node property to a computed value, re-evaluated each tick. When the
65
+ * value changes, the node is marked dirty and (for transition-able properties)
66
+ * the transition is armed.
67
+ */
68
+ export declare function bind<K extends string>(node: unknown, property: K, compute: () => unknown): void;
69
+ /**
70
+ * Subscribe to changes on an `<input>` element's text. The callback fires after
71
+ * the on-screen keyboard commits, with the new text. Use it to push keyboard
72
+ * input back into app state.
73
+ *
74
+ * let ssid = '';
75
+ * ui.bindInput(screen.ssid, (text) => { ssid = text; });
76
+ */
77
+ export declare function bindInput(node: unknown, onText: (text: string) => void): void;
78
+ /**
79
+ * Watch a GPIO pin for falling edges (button press). The callback runs as an
80
+ * async task in the existing microtask pump — no ISRs, natural debounce from
81
+ * the ~20ms poll interval. Safe to write to signals inside the callback.
82
+ *
83
+ * ui.watchPin(4, () => { count.set(count() + 1); });
84
+ */
85
+ export declare function watchPin(pin: number, onFalling: () => void): void;
86
+ /**
87
+ * Bind a `<list>` element to dynamic data via two callbacks.
88
+ *
89
+ * ui.bindList(screen.myList,
90
+ * () => itemCount, // total number of items
91
+ * (i) => `Item ${i}` // text for item at index i
92
+ * );
93
+ *
94
+ * The list virtualizes: only visible items are rendered. Scroll by dragging.
95
+ * The count function is called each frame; if the count changes, the list
96
+ * refreshes automatically.
97
+ */
98
+ export declare function bindList(node: unknown, countFn: () => number, itemFn: (index: number) => string, onTap?: (index: number) => void): void;
99
+ /**
100
+ * Await the next tap. Must be used inside an `async` function.
101
+ *
102
+ * async function screensaver() {
103
+ * while (true) {
104
+ * await ui.onTap(); // resume on the next tap, anywhere
105
+ * backlightOn();
106
+ * }
107
+ * }
108
+ *
109
+ * With no argument it resumes on the next tap on the screen (including empty
110
+ * space — useful for "wake on any touch"). Pass an element to resume only when
111
+ * that element is tapped:
112
+ *
113
+ * await ui.onTap(screen.btn);
114
+ *
115
+ * A tap fires BOTH the tapped element's onClick handler AND resumes any
116
+ * `await ui.onTap()` awaiter. Returns a Promise<void>; it is a resume signal,
117
+ * not a value — there is nothing to read from it.
118
+ */
119
+ export declare function onTap(node?: unknown): Promise<void>;
120
+ /**
121
+ * Register a draw callback for a `<canvas>` element. The callback runs every
122
+ * frame and receives a `ctx` whose methods map to the display graphics
123
+ * primitives. Coordinates are canvas-relative ((0,0) = top-left of the element);
124
+ * drawing is clipped to the canvas buffer.
125
+ *
126
+ * ui.drawCanvas(screen.spark, (ctx) => {
127
+ * ctx.fillScreen('black');
128
+ * ctx.line(0, ctx.height / 2, ctx.width, ctx.height / 2, 'limegreen');
129
+ * ctx.fillCircle(needleX, 20, 3, 'red');
130
+ * ctx.text(4, 12, `${temp}°`, 'white');
131
+ * });
132
+ *
133
+ * Color arguments are CSS color strings resolved to RGB565 at transpile time.
134
+ * `ctx.width` / `ctx.height` are the canvas buffer dimensions.
135
+ */
136
+ export declare function drawCanvas(node: unknown, callback: (ctx: CanvasCtx) => void): void;
137
+ /**
138
+ * Native desktop (SDL) window controls. These are no-ops on hardware targets
139
+ * (Arduino/AVR/ESP32 have no window); on the SDL target they map to the
140
+ * underlying SDL window calls. The initial title/icon come from
141
+ * `cuttlefish.config.ts` (`display.title` / `display.icon`); these methods
142
+ * change them at runtime.
143
+ */
144
+ export interface WindowApi {
145
+ /** Set the OS window title. Native SDL only; no-op on hardware. */
146
+ setTitle(title: string): void;
147
+ /**
148
+ * Set the window/taskbar icon from an image file path. Native SDL only.
149
+ * Note: runtime icon changes require SDL_image; prefer the `display.icon`
150
+ * config option for the common case (loaded once at launch).
151
+ */
152
+ setIcon(path: string): void;
153
+ }
154
+ export declare const ui: {
155
+ mount: typeof mount;
156
+ signal: typeof signal;
157
+ bind: typeof bind;
158
+ bindInput: typeof bindInput;
159
+ bindList: typeof bindList;
160
+ watchPin: typeof watchPin;
161
+ onTap: typeof onTap;
162
+ drawCanvas: typeof drawCanvas;
163
+ window: WindowApi;
164
+ };
165
+ export default ui;
package/dist/index.js ADDED
@@ -0,0 +1,42 @@
1
+ // ---------------------------------------------------------------------------
2
+ // @typecad/ui — public authoring API.
3
+ //
4
+ // These functions are compile-time constructs: the transpiler intercepts
5
+ // ui.mount / ui.signal / ui.bind and lowers them to device variables and
6
+ // binding-table entries. They have no runtime implementation in the emitted
7
+ // C++; their bodies exist only so TypeScript authoring type-checks.
8
+ // ---------------------------------------------------------------------------
9
+ // ---------------------------------------------------------------------------
10
+ // Runtime fallback.
11
+ //
12
+ // Every function above is a compile-time construct: the @typecad/cuttlefish
13
+ // transpiler intercepts `ui.mount` / `ui.signal` / `ui.bind` / ... calls and
14
+ // lowers them to device variables and binding-table entries, so these bodies
15
+ // never run on the device. But the package still has to be importable from
16
+ // plain Node (editor language servers, the test runner, tooling) without
17
+ // crashing, and a forgotten build step should fail loudly rather than silently
18
+ // no-op. Each fallback throws an explicit "compile-time construct" error.
19
+ //
20
+ // The signatures intentionally match the `export declare function` contracts
21
+ // above so the public type surface is unchanged.
22
+ // ---------------------------------------------------------------------------
23
+ const COMPILE_TIME_ERROR = () => {
24
+ throw new Error("@typecad/ui: this function is a compile-time construct. It must be " +
25
+ "lowered by the @typecad/cuttlefish transpiler at build time, not " +
26
+ "called at runtime.");
27
+ };
28
+ export const ui = {
29
+ mount: COMPILE_TIME_ERROR,
30
+ signal: COMPILE_TIME_ERROR,
31
+ bind: COMPILE_TIME_ERROR,
32
+ bindInput: COMPILE_TIME_ERROR,
33
+ bindList: COMPILE_TIME_ERROR,
34
+ watchPin: COMPILE_TIME_ERROR,
35
+ onTap: COMPILE_TIME_ERROR,
36
+ drawCanvas: COMPILE_TIME_ERROR,
37
+ window: {
38
+ setTitle: COMPILE_TIME_ERROR,
39
+ setIcon: COMPILE_TIME_ERROR,
40
+ },
41
+ };
42
+ export default ui;
@@ -0,0 +1,7 @@
1
+ import { ResolvedCuttlefishConfig } from "@typecad/cuttlefish/config-loader";
2
+ import type { PreviewSnapshot } from "./types.js";
3
+ export interface BuildPreviewSnapshotOptions {
4
+ config: ResolvedCuttlefishConfig;
5
+ projectRoot: string;
6
+ }
7
+ export declare function buildPreviewSnapshot(options: BuildPreviewSnapshotOptions): Promise<PreviewSnapshot>;