@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.
- package/LICENSE +21 -0
- package/README.md +1443 -0
- package/dist/engine-index.d.ts +7 -0
- package/dist/engine-index.js +41 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.js +42 -0
- package/dist/preview/build-program.d.ts +7 -0
- package/dist/preview/build-program.js +665 -0
- package/dist/preview/host-gfx.d.ts +90 -0
- package/dist/preview/host-gfx.js +552 -0
- package/dist/preview/host-ui-runtime.d.ts +241 -0
- package/dist/preview/host-ui-runtime.js +3236 -0
- package/dist/preview/types.d.ts +83 -0
- package/dist/preview/types.js +1 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.js +10 -0
- package/dist/ui-engine/block-layout.d.ts +8 -0
- package/dist/ui-engine/block-layout.js +95 -0
- package/dist/ui-engine/color.d.ts +49 -0
- package/dist/ui-engine/color.js +273 -0
- package/dist/ui-engine/css-parser.d.ts +155 -0
- package/dist/ui-engine/css-parser.js +1058 -0
- package/dist/ui-engine/default-keyboards.d.ts +3 -0
- package/dist/ui-engine/default-keyboards.js +53 -0
- package/dist/ui-engine/easing.d.ts +12 -0
- package/dist/ui-engine/easing.js +76 -0
- package/dist/ui-engine/font-assets.d.ts +50 -0
- package/dist/ui-engine/font-assets.js +431 -0
- package/dist/ui-engine/html-parser.d.ts +116 -0
- package/dist/ui-engine/html-parser.js +284 -0
- package/dist/ui-engine/image-assets.d.ts +21 -0
- package/dist/ui-engine/image-assets.js +125 -0
- package/dist/ui-engine/inline-parser.d.ts +30 -0
- package/dist/ui-engine/inline-parser.js +66 -0
- package/dist/ui-engine/keyframes.d.ts +3 -0
- package/dist/ui-engine/keyframes.js +39 -0
- package/dist/ui-engine/layout-engine.d.ts +35 -0
- package/dist/ui-engine/layout-engine.js +203 -0
- package/dist/ui-engine/model.d.ts +239 -0
- package/dist/ui-engine/model.js +987 -0
- package/dist/ui-engine/rich-layout.d.ts +51 -0
- package/dist/ui-engine/rich-layout.js +220 -0
- package/dist/ui-engine/run-types.d.ts +13 -0
- package/dist/ui-engine/run-types.js +1 -0
- package/dist/ui-engine/runtime-header/antialiasing.d.ts +1 -0
- package/dist/ui-engine/runtime-header/antialiasing.js +141 -0
- package/dist/ui-engine/runtime-header/blend-bodies.d.ts +1 -0
- package/dist/ui-engine/runtime-header/blend-bodies.js +39 -0
- package/dist/ui-engine/runtime-header/canvas-helpers.d.ts +1 -0
- package/dist/ui-engine/runtime-header/canvas-helpers.js +155 -0
- package/dist/ui-engine/runtime-header/canvas-scrollbar.d.ts +1 -0
- package/dist/ui-engine/runtime-header/canvas-scrollbar.js +105 -0
- package/dist/ui-engine/runtime-header/color-mono-refresh.d.ts +1 -0
- package/dist/ui-engine/runtime-header/color-mono-refresh.js +154 -0
- package/dist/ui-engine/runtime-header/dirty-scroll-mutators.d.ts +1 -0
- package/dist/ui-engine/runtime-header/dirty-scroll-mutators.js +169 -0
- package/dist/ui-engine/runtime-header/display-shim.d.ts +1 -0
- package/dist/ui-engine/runtime-header/display-shim.js +104 -0
- package/dist/ui-engine/runtime-header/forward-decls.d.ts +1 -0
- package/dist/ui-engine/runtime-header/forward-decls.js +137 -0
- package/dist/ui-engine/runtime-header/guard-close.d.ts +1 -0
- package/dist/ui-engine/runtime-header/guard-close.js +8 -0
- package/dist/ui-engine/runtime-header/image-drawing.d.ts +1 -0
- package/dist/ui-engine/runtime-header/image-drawing.js +300 -0
- package/dist/ui-engine/runtime-header/init-press-input.d.ts +1 -0
- package/dist/ui-engine/runtime-header/init-press-input.js +126 -0
- package/dist/ui-engine/runtime-header/keyboard.d.ts +1 -0
- package/dist/ui-engine/runtime-header/keyboard.js +342 -0
- package/dist/ui-engine/runtime-header/node-decoration.d.ts +1 -0
- package/dist/ui-engine/runtime-header/node-decoration.js +212 -0
- package/dist/ui-engine/runtime-header/paint-order-coords.d.ts +1 -0
- package/dist/ui-engine/runtime-header/paint-order-coords.js +190 -0
- package/dist/ui-engine/runtime-header/paint-rects-repair.d.ts +1 -0
- package/dist/ui-engine/runtime-header/paint-rects-repair.js +553 -0
- package/dist/ui-engine/runtime-header/scroll-physics.d.ts +1 -0
- package/dist/ui-engine/runtime-header/scroll-physics.js +161 -0
- package/dist/ui-engine/runtime-header/state-bindings-nav.d.ts +1 -0
- package/dist/ui-engine/runtime-header/state-bindings-nav.js +176 -0
- package/dist/ui-engine/runtime-header/structs.d.ts +1 -0
- package/dist/ui-engine/runtime-header/structs.js +220 -0
- package/dist/ui-engine/runtime-header/text-rendering.d.ts +1 -0
- package/dist/ui-engine/runtime-header/text-rendering.js +715 -0
- package/dist/ui-engine/runtime-header/tick/bindings-phase.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick/bindings-phase.js +103 -0
- package/dist/ui-engine/runtime-header/tick/dirty-draw-phase.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick/dirty-draw-phase.js +1051 -0
- package/dist/ui-engine/runtime-header/tick/flush-phase.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick/flush-phase.js +17 -0
- package/dist/ui-engine/runtime-header/tick/scroll-canvas-phase.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick/scroll-canvas-phase.js +15 -0
- package/dist/ui-engine/runtime-header/tick/transitions-phase.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick/transitions-phase.js +213 -0
- package/dist/ui-engine/runtime-header/tick-motion-helpers.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick-motion-helpers.js +26 -0
- package/dist/ui-engine/runtime-header/tick.d.ts +1 -0
- package/dist/ui-engine/runtime-header/tick.js +17 -0
- package/dist/ui-engine/runtime-header/touch-keyboard-fwd.d.ts +1 -0
- package/dist/ui-engine/runtime-header/touch-keyboard-fwd.js +406 -0
- package/dist/ui-engine/runtime-header/types-defines.d.ts +1 -0
- package/dist/ui-engine/runtime-header/types-defines.js +79 -0
- package/dist/ui-engine/runtime-header.d.ts +1 -0
- package/dist/ui-engine/runtime-header.js +69 -0
- package/dist/ui-engine/scroll-memory-diagnostics.d.ts +16 -0
- package/dist/ui-engine/scroll-memory-diagnostics.js +58 -0
- package/dist/ui-engine/select-engine.d.ts +4 -0
- package/dist/ui-engine/select-engine.js +19 -0
- package/dist/ui-engine/style-resolver.d.ts +77 -0
- package/dist/ui-engine/style-resolver.js +341 -0
- package/dist/ui-engine/text-layout.d.ts +19 -0
- package/dist/ui-engine/text-layout.js +92 -0
- package/dist/ui-engine/transpile-ui.d.ts +11 -0
- package/dist/ui-engine/transpile-ui.js +33 -0
- package/dist/ui-engine/ua-stylesheet.d.ts +3 -0
- package/dist/ui-engine/ua-stylesheet.js +56 -0
- package/dist/ui-engine/ui-file-splitter.d.ts +14 -0
- package/dist/ui-engine/ui-file-splitter.js +47 -0
- package/dist/ui-engine/ui-lowering.d.ts +33 -0
- package/dist/ui-engine/ui-lowering.js +390 -0
- package/dist/ui-engine/ui-registry.d.ts +81 -0
- package/dist/ui-engine/ui-registry.js +429 -0
- package/dist/ui-engine/yoga-layout.d.ts +12 -0
- package/dist/ui-engine/yoga-layout.js +314 -0
- package/package.json +86 -0
- package/src/engine-index.ts +51 -0
- package/src/index.ts +232 -0
- package/src/preview/build-program.ts +734 -0
- package/src/preview/host-gfx.ts +580 -0
- package/src/preview/host-ui-runtime.ts +3245 -0
- package/src/preview/types.ts +96 -0
- package/src/types.ts +127 -0
- package/src/ui-engine/block-layout.ts +104 -0
- package/src/ui-engine/color.ts +263 -0
- package/src/ui-engine/css-parser.ts +1003 -0
- package/src/ui-engine/default-keyboards.ts +58 -0
- package/src/ui-engine/easing.ts +53 -0
- package/src/ui-engine/font-assets.ts +512 -0
- package/src/ui-engine/html-parser.ts +397 -0
- package/src/ui-engine/image-assets.ts +170 -0
- package/src/ui-engine/inline-parser.ts +78 -0
- package/src/ui-engine/keyframes.ts +47 -0
- package/src/ui-engine/layout-engine.ts +228 -0
- package/src/ui-engine/model.ts +1225 -0
- package/src/ui-engine/rich-layout.ts +257 -0
- package/src/ui-engine/run-types.ts +14 -0
- package/src/ui-engine/runtime-header/antialiasing.ts +141 -0
- package/src/ui-engine/runtime-header/blend-bodies.ts +39 -0
- package/src/ui-engine/runtime-header/canvas-helpers.ts +155 -0
- package/src/ui-engine/runtime-header/canvas-scrollbar.ts +105 -0
- package/src/ui-engine/runtime-header/color-mono-refresh.ts +154 -0
- package/src/ui-engine/runtime-header/dirty-scroll-mutators.ts +169 -0
- package/src/ui-engine/runtime-header/display-shim.ts +104 -0
- package/src/ui-engine/runtime-header/forward-decls.ts +137 -0
- package/src/ui-engine/runtime-header/guard-close.ts +8 -0
- package/src/ui-engine/runtime-header/image-drawing.ts +300 -0
- package/src/ui-engine/runtime-header/init-press-input.ts +126 -0
- package/src/ui-engine/runtime-header/keyboard.ts +342 -0
- package/src/ui-engine/runtime-header/node-decoration.ts +212 -0
- package/src/ui-engine/runtime-header/paint-order-coords.ts +190 -0
- package/src/ui-engine/runtime-header/paint-rects-repair.ts +553 -0
- package/src/ui-engine/runtime-header/scroll-physics.ts +161 -0
- package/src/ui-engine/runtime-header/state-bindings-nav.ts +176 -0
- package/src/ui-engine/runtime-header/structs.ts +220 -0
- package/src/ui-engine/runtime-header/text-rendering.ts +715 -0
- package/src/ui-engine/runtime-header/tick/bindings-phase.ts +103 -0
- package/src/ui-engine/runtime-header/tick/dirty-draw-phase.ts +1051 -0
- package/src/ui-engine/runtime-header/tick/flush-phase.ts +17 -0
- package/src/ui-engine/runtime-header/tick/scroll-canvas-phase.ts +15 -0
- package/src/ui-engine/runtime-header/tick/transitions-phase.ts +213 -0
- package/src/ui-engine/runtime-header/tick-motion-helpers.ts +26 -0
- package/src/ui-engine/runtime-header/tick.ts +18 -0
- package/src/ui-engine/runtime-header/touch-keyboard-fwd.ts +406 -0
- package/src/ui-engine/runtime-header/types-defines.ts +79 -0
- package/src/ui-engine/runtime-header.ts +71 -0
- package/src/ui-engine/scroll-memory-diagnostics.ts +79 -0
- package/src/ui-engine/select-engine.ts +21 -0
- package/src/ui-engine/style-resolver.ts +416 -0
- package/src/ui-engine/text-layout.ts +114 -0
- package/src/ui-engine/transpile-ui.ts +45 -0
- package/src/ui-engine/ua-stylesheet.ts +60 -0
- package/src/ui-engine/ui-file-splitter.ts +59 -0
- package/src/ui-engine/ui-lowering.ts +459 -0
- package/src/ui-engine/ui-registry.ts +530 -0
- 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
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -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>;
|