@tarve/core 0.1.2 → 0.3.0
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/CHANGELOG.md +64 -0
- package/README.md +26 -3
- package/dist/npm/build.js +1 -1
- package/dist/npm/cli.js +1 -1
- package/dist/npm/index.js +425 -25
- package/dist/npm/native-runtime.json +3 -3
- package/dist/npm/protocol.js +1 -1
- package/dist/types/core/src/app.d.ts +1 -1
- package/dist/types/core/src/css-shadow.d.ts +20 -0
- package/dist/types/core/src/index.d.ts +1 -1
- package/dist/types/core/src/theme.d.ts +2 -0
- package/dist/types/protocol/src/index.d.ts +87 -6
- package/native/linux-x64/libtarve_native.so +0 -0
- package/native/linux-x64/runtime.json +4 -4
- package/native/win32-x64/runtime.json +4 -4
- package/native/win32-x64/tarve_native.dll +0 -0
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@tarve/core` and `@tarve/react-icons` are documented here. Versions follow [Semantic Versioning](https://semver.org/); before 1.0, minor versions may contain breaking changes.
|
|
4
|
+
|
|
5
|
+
## 0.3.0 — 2026-09-30
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Gradient backgrounds: `linear-gradient(…)`, `radial-gradient(…)` and their `repeating-` forms as CSS strings or `{ type, angle | to, shape, size, at, repeating, stops }` objects, in state styles too, on D3D11, Vello GPU and the CPU renderer. Stops take `%` or `px` with CSS fix-up of omitted positions; radial gradients take every size keyword, explicit radii and `at` centres in keywords, `%` or `px` (with edge offsets like `right 10px bottom 20%`). Gradients with matching shape and stop count transition stop by stop.
|
|
9
|
+
- `textShadow` blur (`{ blur }` or CSS `"1px 2px 4px #0006"`): glyphs are rasterized, blurred on the CPU and cached as one image per node, so the gaussian matches on every renderer. Blur transitions with the rest of the shadow.
|
|
10
|
+
- Gradient `borderColor` (fills the border ring; solid borders) and gradient `foreground` on `Text` (glyph coverage filled with the gradient, cached per node). Both transition like background gradients.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- JSON protocol version 47.
|
|
14
|
+
- Pointer moves no longer walk the whole tree: transitions advance only on animating nodes, hit testing skips the stacking sort for containers whose children share a z-index, and portal and `transform` lookups are cached per tree update. On a 10,000-node tree a pointer move drops from ~2.6 ms to ~0.5 ms.
|
|
15
|
+
- Windows GPU startup: the D3D11 device (driver load, ~140 ms) is created on a background thread as soon as the app starts, overlapping window creation and the first layout. Apps on the CPU renderer skip it.
|
|
16
|
+
- The D3D11 shaders ship as precompiled DXBC (`native/src/shaders`), so startup no longer loads `d3dcompiler_47.dll` or compiles HLSL (~20 ms). A test fails if `ui.hlsl` changes without regenerating the bytecode.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
- `bun --hot`: editing a file now reloads into the open window. A second `render()` in the same process remounts instead of failing with "Only one native app can be started per process", and under `--hot` `render()` resolves once the window is ready (Bun defers reloads while a top-level `await` is pending) and the process exits when the window closes.
|
|
20
|
+
- Windows: when the session is out of USER/atom memory (`SetPropW` fails with `0x80070008`), the window starts without UI Automation exposure and logs a warning instead of panicking the window thread in the AccessKit subclassing adapter.
|
|
21
|
+
- `InputOTP` focus: clicking now shows the active slot (slots had only a keyboard focus-visible ring), a click maps to the nearest slot instead of the hidden input's text position, and clicking a filled slot selects its character so typing replaces it instead of inserting before the code.
|
|
22
|
+
- Idle memory: the native runtime returns free `mimalloc` pages to the OS once rendering settles (at most every 500 ms). Since 0.2.0 an idle app stayed at its startup peak; a 2,000-row list now idles at ~225 MB instead of ~255 MB.
|
|
23
|
+
|
|
24
|
+
## 0.2.0 — 2026-09-29
|
|
25
|
+
|
|
26
|
+
### Breaking
|
|
27
|
+
- `hover` styles now also apply to ancestors of the hovered node and to non-interactive nodes, like CSS `:hover`. Containers with a `hover` style that never activated before will now react.
|
|
28
|
+
- Unsupported colour strings in colour properties throw when the view is compiled instead of painting black.
|
|
29
|
+
- State styles with a matching `transition` now animate instead of switching instantly, and emit `motionComplete`.
|
|
30
|
+
- JSON protocol version 46: `@tarve/core` 0.2.0 requires its bundled native runtime (as always, runtimes are not mixed across versions).
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
- `transform`: translate/scale about the box centre (object or CSS `translate*()`/`scale*()` syntax), applied to the whole subtree on every renderer, followed by hit testing and hover, and animatable with `transition` (e.g. a hover lift).
|
|
34
|
+
- CSS colours in every colour property: `rgb()`/`rgba()`, `hsl()`/`hsla()`, short hex and common names. Unsupported colour strings now throw instead of silently rendering black.
|
|
35
|
+
- CSS syntax for shadows: `boxShadow: "0 8px 24px -4px rgba(0,0,0,.2), inset 0 1px 0 #fff"` and `textShadow: "1px 2px #0006"`, including `rgb()`/`hsl()` colours and theme tokens. Shadow objects also accept those colour formats.
|
|
36
|
+
- `hover` styles apply to every node under the pointer and its ancestors (CSS `:hover`), not only interactive nodes.
|
|
37
|
+
- Native transitions for `background`, `foreground`, `borderColor`, `boxShadow` and `textShadow`, and state-driven transitions: hover/active/focus/disabled changes animate `opacity`, `radius`, colours and shadows from the value on screen. No frames are scheduled once a transition ends.
|
|
38
|
+
- `boxShadow`: `{ x, y, blur, spread, color, inset }` or a list of up to 8, in base and state styles. Analytic gaussian blur on D3D11, Vello GPU and the CPU renderer; outer shadows are clipped out of their own box; `inset` paints inside the padding box.
|
|
39
|
+
- `borderStyle` (`dashed`, `dotted`, `double`, `groove`, `ridge`, `inset`, `outset`, `none`) on any node with a uniform border width.
|
|
40
|
+
- `textShadow: { x, y, color }` on text, button labels, `Input` and `TextArea`, including state styles such as `hover` (solid offset; no blur). Protocol version is now 46.
|
|
41
|
+
- Linux accessibility: the AccessKit bridge now runs on Linux through AT-SPI, so screen readers such as Orca can read and drive Tarve apps.
|
|
42
|
+
- Word-wise editing in `Input`/`TextArea`: `Ctrl+←/→` (Option on macOS) moves by word, with `Shift` to select; `Ctrl+Backspace`/`Ctrl+Delete` delete a word.
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- Faster native runtime: `mimalloc` allocator and `FxHash` maps cut native tree update time by ~40% on a 6,000-node tree.
|
|
46
|
+
- Syntax highlight cache uses an O(1) LRU.
|
|
47
|
+
- Text highlight search no longer depends on the `regex` crate.
|
|
48
|
+
|
|
49
|
+
## 0.1.2 — 2026-09-28
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
- `@tarve/react-icons` is published alongside `@tarve/core`.
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
- The published `package.json` contains only consumer-facing fields.
|
|
56
|
+
|
|
57
|
+
## 0.1.1 — 2026-09-28
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
- Package renamed from `tarve` to `@tarve/core`. The CLI command is still `tarve`.
|
|
61
|
+
|
|
62
|
+
## 0.1.0 — 2026-09-28
|
|
63
|
+
|
|
64
|
+
Initial release: native Windows x64 and Linux x64 runtime with JSX components, Taffy layout, Parley text, Vello and D3D11 rendering, rich markdown/code/diff, native text editing with undo/redo, motion transitions, Windows accessibility, file dialogs, global hotkeys and standalone executable builds.
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Tarve turns a TSX tree into a retained native interface. It does not use a brows
|
|
|
21
21
|
- shadcn-inspired components and semantic light/dark theme tokens.
|
|
22
22
|
- Native Markdown, syntax-highlighted Code, and Diff leaves designed for large documents.
|
|
23
23
|
- Fixed-height, measured variable-height, and externally windowed `VirtualList` modes.
|
|
24
|
-
-
|
|
24
|
+
- Accessibility through AccessKit: UI Automation on Windows and AT-SPI on Linux.
|
|
25
25
|
- Global hotkeys, native file dialogs, custom title bars, window positioning, and standalone Windows/Linux builds.
|
|
26
26
|
- Event-driven Bun/native bridge with no continuous idle polling: an idle window presents zero frames.
|
|
27
27
|
- Development mode with in-window runtime error overlay, same-window remount under `bun --hot`, and a native frame-time graph.
|
|
@@ -176,6 +176,29 @@ function App() {
|
|
|
176
176
|
}
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
+
Every colour property (`background`, `foreground`, `borderColor`, `outlineColor`, rich-content and diff colours, state styles and the window background) accepts hex (`#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`), `rgb()`/`rgba()`, `hsl()`/`hsla()`, common names such as `transparent` or `white`, and theme tokens. Unsupported colour strings throw when the view is compiled instead of rendering black.
|
|
180
|
+
|
|
181
|
+
`transform` translates and scales a node and its subtree about the box centre: `{ x, y, scale, scaleX, scaleY }` or CSS syntax such as `"translateY(-2px) scale(1.02)"`. It is paint-only (layout does not move) but hit testing and hover follow the transformed box, and it transitions like other paint properties. Rotation is not supported yet.
|
|
182
|
+
|
|
183
|
+
Borders accept `borderStyle` with the same values as `outlineStyle` (`dashed`, `dotted`, `double`, `groove`, `ridge`, `inset`, `outset`, `none`); non-solid styles apply when all four border widths are equal. Text, button labels, `Input` and `TextArea` accept `textShadow: { x, y, blur, color }`, an offset copy of the glyphs (`blur` is the CSS blur radius; 0 is a solid copy, larger values blur it identically on every renderer); it also works inside state styles such as `hover`.
|
|
184
|
+
|
|
185
|
+
`boxShadow` takes `{ x, y, blur, spread, color, inset }` or a list of up to 8 (the first paints on top). `blur` is the CSS blur radius; `spread` grows or shrinks the shadow and its corner radius; `inset` paints inside the padding box. Outer shadows are never drawn under their own box, so translucent backgrounds stay clean. Shadows do not affect layout, work in state styles such as `hover`, and render the same on D3D11, Vello GPU and the CPU renderer.
|
|
186
|
+
|
|
187
|
+
`background` also takes a gradient, as a CSS string or an object: `"linear-gradient(135deg, #2563eb, #9333ea 80%)"`, `"linear-gradient(to top right, red, blue)"`, `"radial-gradient(circle at 25% 75%, #fff, #000)"`, `"repeating-linear-gradient(45deg, #000 0 6px, #fff 6px 12px)"`, or `{ type: "linear", angle: 135, stops: ["#2563eb", { color: "#9333ea", offset: 0.8 }] }`. Angles accept `deg`, `rad`, `turn` and `grad`. Stop positions take `%` or `px` (object offsets: a number is a 0..1 fraction, strings take `px`/`%`); two positions make a hard stop, omitted ones are spread and positions never go back, as in CSS. Radial gradients take `circle`/`ellipse`, a size keyword (`closest-side`, `closest-corner`, `farthest-side`, `farthest-corner`, the default) or explicit radii (`circle 40px`, `ellipse 50% 20px`; object `size: 40` or `["50%", "20px"]`), and an `at` centre in keywords, percentages or `px`, including edge offsets such as `at right 10px bottom 20%`. `repeating-linear-gradient` and `repeating-radial-gradient` tile the stop pattern; patterns finer than a pixel paint their average colour. Stop colours accept the same colour syntax and theme tokens. With `transition`, gradients with the same kind, stop count, units, size and repeat mode animate stop by stop; anything else, including colour ↔ gradient, switches instantly, as in CSS. `borderColor` and `foreground` take the same gradients: a gradient border fills the ring between the border and padding boxes (solid `borderStyle`; other styles use the first stop), and gradient text on `Text` fills the glyphs with the gradient laid over the text box, like CSS `background-clip: text` (it is rasterized once and cached, so it renders identically everywhere; `Button` labels and icons use the first stop). Other length units (`em`, `rem`, `vw`, `vh`, …) and `calc()` are not supported yet; they are planned for the whole style system rather than for gradients alone.
|
|
188
|
+
|
|
189
|
+
`hover` styles apply to any node under the pointer and to its ancestors, as CSS `:hover` does; the innermost interactive node still receives events. With `transition`, `opacity`, `radius`, `background`, `foreground`, `borderColor`, `boxShadow` and `textShadow` animate natively both on JS updates and on hover/active/focus/disabled changes, starting from the value on screen:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
<Column style={{
|
|
193
|
+
background: "#ffffff",
|
|
194
|
+
boxShadow: { y: 2, blur: 6, color: "#0f172a22" },
|
|
195
|
+
hover: { background: "#eff6ff", boxShadow: { y: 14, blur: 28, color: "#2563eb44" } },
|
|
196
|
+
transition: { all: { duration: 220, easing: "easeOut" } },
|
|
197
|
+
}} />
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
Both shadows also accept CSS syntax: `boxShadow: "inset 0 1px 2px rgba(0,0,0,.2), 0 8px 24px -4px #0003"` and `textShadow: "1px 2px #0006"` (or `"none"`). Lengths are `px` or unitless `0`; colours may be hex, `rgb()`/`rgba()`, `hsl()`/`hsla()`, a few names or theme tokens. Invalid strings throw when the view is compiled. Shadow lists of different lengths interpolate against transparent layers. `motionFrom` and AnimatePresence `enter`/`exit` accept numeric properties only.
|
|
201
|
+
|
|
179
202
|
Create derived themes with `createTheme` or `Theme.create`. Theme tokens cover surfaces, foregrounds, borders, focus outlines, selection, caret, scrollbars, modal overlays, rich-content colors, and control states.
|
|
180
203
|
|
|
181
204
|
## Native motion
|
|
@@ -347,7 +370,7 @@ Native text search and copy operate on the mounted logical window. A retained ed
|
|
|
347
370
|
|
|
348
371
|
Editors keep a native per-field undo/redo history (`Ctrl+Z`, `Ctrl+Y` / `Ctrl+Shift+Z`) that coalesces continuous typing or deletion into word-sized steps and resets when a controlled value changes externally. `onSubmit(value)` fires on Enter for `Input`; `TextArea` submits on `Ctrl/Cmd+Enter`, or on Enter with `submitOnEnter` (Shift+Enter then inserts a newline). The caret blinks after activity and settles solid after 10 s idle, so a focused editor schedules no idle frames. When the clipboard holds no text, `Ctrl+V` delivers files or a bitmap to the focused element's `onPaste` as `{ kind: "files", files }` or `{ kind: "image", width, height, rgba }`.
|
|
349
372
|
|
|
350
|
-
On Windows, Tarve projects the native tree through AccessKit/UI Automation with roles, names, values, states, actions, focus, text ranges, selection, scroll ranges, live regions, and field relationships. Linux
|
|
373
|
+
On Windows, Tarve projects the native tree through AccessKit/UI Automation with roles, names, values, states, actions, focus, text ranges, selection, scroll ranges, live regions, and field relationships. On Linux, the same AccessKit tree is exposed over AT-SPI (D-Bus) for screen readers such as Orca; it activates only when an assistive technology connects.
|
|
351
374
|
|
|
352
375
|
## Desktop APIs
|
|
353
376
|
|
|
@@ -525,7 +548,7 @@ Building Tarve from source, the test and smoke-test gates, and the release proce
|
|
|
525
548
|
|
|
526
549
|
## Current scope
|
|
527
550
|
|
|
528
|
-
Tarve is pre-1.0 and currently targets **Windows x64 and Linux x64**. The current application bootstrap model uses one native app/window lifetime per process; multi-window support is not yet part of the public runtime model.
|
|
551
|
+
Tarve is pre-1.0 and currently targets **Windows x64 and Linux x64**. The current application bootstrap model uses one native app/window lifetime per process; multi-window support is not yet part of the public runtime model.
|
|
529
552
|
|
|
530
553
|
## License
|
|
531
554
|
|
package/dist/npm/build.js
CHANGED
|
@@ -54,7 +54,7 @@ import { basename, dirname, join } from "path";
|
|
|
54
54
|
|
|
55
55
|
// packages/protocol/src/index.ts
|
|
56
56
|
var NATIVE_ABI_VERSION = 5;
|
|
57
|
-
var PROTOCOL_VERSION =
|
|
57
|
+
var PROTOCOL_VERSION = 47;
|
|
58
58
|
|
|
59
59
|
// packages/core/native-runtime.ts
|
|
60
60
|
var NATIVE_RUNTIME_MANIFEST_NAME = "runtime.json";
|
package/dist/npm/cli.js
CHANGED
|
@@ -52,7 +52,7 @@ import { basename, dirname, join } from "path";
|
|
|
52
52
|
|
|
53
53
|
// packages/protocol/src/index.ts
|
|
54
54
|
var NATIVE_ABI_VERSION = 5;
|
|
55
|
-
var PROTOCOL_VERSION =
|
|
55
|
+
var PROTOCOL_VERSION = 47;
|
|
56
56
|
|
|
57
57
|
// packages/core/native-runtime.ts
|
|
58
58
|
var NATIVE_RUNTIME_MANIFEST_NAME = "runtime.json";
|
package/dist/npm/index.js
CHANGED
|
@@ -34,6 +34,372 @@ function Column(props) {
|
|
|
34
34
|
function Portal(props) {
|
|
35
35
|
return container("view", { ...props, portal: true });
|
|
36
36
|
}
|
|
37
|
+
// packages/core/src/css-shadow.ts
|
|
38
|
+
var NAMED = {
|
|
39
|
+
transparent: "#00000000",
|
|
40
|
+
black: "#000000",
|
|
41
|
+
white: "#ffffff",
|
|
42
|
+
red: "#ff0000",
|
|
43
|
+
green: "#008000",
|
|
44
|
+
blue: "#0000ff",
|
|
45
|
+
gray: "#808080",
|
|
46
|
+
grey: "#808080",
|
|
47
|
+
yellow: "#ffff00",
|
|
48
|
+
orange: "#ffa500",
|
|
49
|
+
purple: "#800080",
|
|
50
|
+
pink: "#ffc0cb",
|
|
51
|
+
cyan: "#00ffff",
|
|
52
|
+
magenta: "#ff00ff"
|
|
53
|
+
};
|
|
54
|
+
function hex2(value) {
|
|
55
|
+
return Math.round(Math.min(255, Math.max(0, value))).toString(16).padStart(2, "0");
|
|
56
|
+
}
|
|
57
|
+
function channel(token, scale) {
|
|
58
|
+
const value = token.endsWith("%") ? Number(token.slice(0, -1)) / 100 * scale : Number(token);
|
|
59
|
+
if (!Number.isFinite(value))
|
|
60
|
+
throw new TypeError(`Invalid colour channel: ${token}`);
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
function alpha(token) {
|
|
64
|
+
if (token === undefined)
|
|
65
|
+
return 1;
|
|
66
|
+
return Math.min(1, Math.max(0, channel(token, 1)));
|
|
67
|
+
}
|
|
68
|
+
function hslToRgb(h, s, l) {
|
|
69
|
+
const k = (n) => (n + h / 30) % 12;
|
|
70
|
+
const a = s * Math.min(l, 1 - l);
|
|
71
|
+
const f = (n) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
72
|
+
return [f(0) * 255, f(8) * 255, f(4) * 255];
|
|
73
|
+
}
|
|
74
|
+
function cssColor(value) {
|
|
75
|
+
const input = value.trim().toLowerCase();
|
|
76
|
+
if (input.startsWith("var("))
|
|
77
|
+
return value.trim();
|
|
78
|
+
if (Object.hasOwn(NAMED, input))
|
|
79
|
+
return NAMED[input];
|
|
80
|
+
if (/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(input)) {
|
|
81
|
+
const digits = input.slice(1);
|
|
82
|
+
return digits.length <= 4 ? `#${[...digits].map((d) => d + d).join("")}` : input;
|
|
83
|
+
}
|
|
84
|
+
const fn = input.match(/^(rgba?|hsla?)\((.*)\)$/);
|
|
85
|
+
if (!fn)
|
|
86
|
+
throw new TypeError(`Unsupported colour: ${value}`);
|
|
87
|
+
const [body, slash] = fn[2].split("/").map((part) => part.trim());
|
|
88
|
+
const parts = body.split(/[\s,]+/).filter(Boolean);
|
|
89
|
+
const a = alpha(slash ?? parts[3]);
|
|
90
|
+
if (parts.length < 3)
|
|
91
|
+
throw new TypeError(`Unsupported colour: ${value}`);
|
|
92
|
+
const [r, g, b] = fn[1].startsWith("rgb") ? [channel(parts[0], 255), channel(parts[1], 255), channel(parts[2], 255)] : hslToRgb(Number.parseFloat(parts[0]), channel(parts[1], 1), channel(parts[2], 1));
|
|
93
|
+
return `#${hex2(r)}${hex2(g)}${hex2(b)}${hex2(a * 255)}`;
|
|
94
|
+
}
|
|
95
|
+
function splitTopLevel(value, separator) {
|
|
96
|
+
const parts = [];
|
|
97
|
+
let depth = 0;
|
|
98
|
+
let current = "";
|
|
99
|
+
for (const character of value) {
|
|
100
|
+
if (character === "(")
|
|
101
|
+
depth++;
|
|
102
|
+
if (character === ")")
|
|
103
|
+
depth--;
|
|
104
|
+
if (depth === 0 && separator.test(character)) {
|
|
105
|
+
if (current.trim())
|
|
106
|
+
parts.push(current.trim());
|
|
107
|
+
current = "";
|
|
108
|
+
} else {
|
|
109
|
+
current += character;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (current.trim())
|
|
113
|
+
parts.push(current.trim());
|
|
114
|
+
return parts;
|
|
115
|
+
}
|
|
116
|
+
function length(token) {
|
|
117
|
+
const match = token.match(/^(-?(?:\d+\.?\d*|\.\d+))(px)?$/);
|
|
118
|
+
if (!match)
|
|
119
|
+
return;
|
|
120
|
+
const number = Number(match[1]);
|
|
121
|
+
if (match[2] === undefined && number !== 0)
|
|
122
|
+
return;
|
|
123
|
+
return number;
|
|
124
|
+
}
|
|
125
|
+
function parseLayer(layer, allowInset) {
|
|
126
|
+
let inset = false;
|
|
127
|
+
let color;
|
|
128
|
+
const lengths = [];
|
|
129
|
+
for (const token of splitTopLevel(layer, /\s/)) {
|
|
130
|
+
if (token.toLowerCase() === "inset" && allowInset && !inset) {
|
|
131
|
+
inset = true;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const value = length(token);
|
|
135
|
+
if (value !== undefined) {
|
|
136
|
+
lengths.push(value);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (color !== undefined)
|
|
140
|
+
throw new TypeError(`Unexpected token in shadow: ${token}`);
|
|
141
|
+
color = cssColor(token);
|
|
142
|
+
}
|
|
143
|
+
if (lengths.length < 2)
|
|
144
|
+
throw new TypeError(`A shadow needs x and y offsets: ${layer}`);
|
|
145
|
+
return { lengths, color: color ?? "#000000", inset };
|
|
146
|
+
}
|
|
147
|
+
function parseBoxShadow(value) {
|
|
148
|
+
if (value.trim().toLowerCase() === "none")
|
|
149
|
+
return [];
|
|
150
|
+
return splitTopLevel(value, /,/).map((layer) => {
|
|
151
|
+
const { lengths, color, inset } = parseLayer(layer, true);
|
|
152
|
+
if (lengths.length > 4)
|
|
153
|
+
throw new TypeError(`Too many lengths in box-shadow: ${layer}`);
|
|
154
|
+
const [x, y, blur = 0, spread = 0] = lengths;
|
|
155
|
+
if (blur < 0)
|
|
156
|
+
throw new RangeError(`box-shadow blur must not be negative: ${layer}`);
|
|
157
|
+
return { x, y, blur, spread, color, ...inset ? { inset: true } : {} };
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function parseTextShadow(value) {
|
|
161
|
+
if (value.trim().toLowerCase() === "none")
|
|
162
|
+
return;
|
|
163
|
+
const layers = splitTopLevel(value, /,/);
|
|
164
|
+
if (layers.length !== 1)
|
|
165
|
+
throw new TypeError("textShadow supports a single shadow");
|
|
166
|
+
const { lengths, color } = parseLayer(layers[0], false);
|
|
167
|
+
if (lengths.length > 3)
|
|
168
|
+
throw new TypeError(`Too many lengths in text-shadow: ${value}`);
|
|
169
|
+
if ((lengths[2] ?? 0) < 0)
|
|
170
|
+
throw new TypeError("textShadow blur must be >= 0");
|
|
171
|
+
return { x: lengths[0], y: lengths[1], ...lengths[2] ? { blur: lengths[2] } : {}, color };
|
|
172
|
+
}
|
|
173
|
+
function parseTransform(value) {
|
|
174
|
+
let [x, y, scaleX, scaleY] = [0, 0, 1, 1];
|
|
175
|
+
const input = value.trim();
|
|
176
|
+
if (input.toLowerCase() === "none")
|
|
177
|
+
return {};
|
|
178
|
+
const pattern = /([a-zA-Z]+)\(([^)]*)\)/g;
|
|
179
|
+
let consumed = "";
|
|
180
|
+
for (const match of input.matchAll(pattern)) {
|
|
181
|
+
consumed += match[0];
|
|
182
|
+
const name = match[1];
|
|
183
|
+
const args = match[2].split(/[\s,]+/).filter(Boolean);
|
|
184
|
+
const px = (token) => {
|
|
185
|
+
const number = token === undefined ? 0 : length(token);
|
|
186
|
+
if (number === undefined)
|
|
187
|
+
throw new TypeError(`Unsupported transform length: ${token}`);
|
|
188
|
+
return number;
|
|
189
|
+
};
|
|
190
|
+
const factor = (token) => {
|
|
191
|
+
const number = Number(token);
|
|
192
|
+
if (token === undefined || !Number.isFinite(number) || number === 0)
|
|
193
|
+
throw new TypeError(`Invalid scale: ${token}`);
|
|
194
|
+
return number;
|
|
195
|
+
};
|
|
196
|
+
switch (name) {
|
|
197
|
+
case "translate":
|
|
198
|
+
x += scaleX * px(args[0]);
|
|
199
|
+
y += scaleY * px(args[1]);
|
|
200
|
+
break;
|
|
201
|
+
case "translateX":
|
|
202
|
+
x += scaleX * px(args[0]);
|
|
203
|
+
break;
|
|
204
|
+
case "translateY":
|
|
205
|
+
y += scaleY * px(args[0]);
|
|
206
|
+
break;
|
|
207
|
+
case "scale": {
|
|
208
|
+
const sx = factor(args[0]);
|
|
209
|
+
scaleX *= sx;
|
|
210
|
+
scaleY *= args[1] === undefined ? sx : factor(args[1]);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
case "scaleX":
|
|
214
|
+
scaleX *= factor(args[0]);
|
|
215
|
+
break;
|
|
216
|
+
case "scaleY":
|
|
217
|
+
scaleY *= factor(args[0]);
|
|
218
|
+
break;
|
|
219
|
+
default:
|
|
220
|
+
throw new TypeError(`Unsupported transform function: ${name}() (translate and scale only)`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (consumed.replace(/\s/g, "") !== input.replace(/\s/g, ""))
|
|
224
|
+
throw new TypeError(`Invalid transform: ${value}`);
|
|
225
|
+
return {
|
|
226
|
+
...x !== 0 ? { x } : {},
|
|
227
|
+
...y !== 0 ? { y } : {},
|
|
228
|
+
...scaleX === scaleY ? scaleX !== 1 ? { scale: scaleX } : {} : { scaleX, scaleY }
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
var GRADIENT = /^\s*(repeating-)?(linear|radial)-gradient\(/i;
|
|
232
|
+
function angle(token) {
|
|
233
|
+
const match = token.match(/^(-?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/);
|
|
234
|
+
if (!match)
|
|
235
|
+
return;
|
|
236
|
+
const value = Number(match[1]);
|
|
237
|
+
return { deg: value, rad: value * 180 / Math.PI, turn: value * 360, grad: value * 0.9 }[match[2]];
|
|
238
|
+
}
|
|
239
|
+
var LENGTH_PERCENT = /^-?(?:\d+\.?\d*|\.\d+)(px|%)$/;
|
|
240
|
+
function position(token) {
|
|
241
|
+
if (token === "0")
|
|
242
|
+
return 0;
|
|
243
|
+
const match = token.match(LENGTH_PERCENT);
|
|
244
|
+
if (!match)
|
|
245
|
+
throw new TypeError(`Gradient positions must be px or %: ${token}`);
|
|
246
|
+
return match[1] === "%" ? Number(token.slice(0, -1)) / 100 : token;
|
|
247
|
+
}
|
|
248
|
+
function parseStop(token) {
|
|
249
|
+
const [color, ...positions] = splitTopLevel(token, /\s/);
|
|
250
|
+
if (!color || positions.length > 2)
|
|
251
|
+
throw new TypeError(`Invalid colour stop: ${token}`);
|
|
252
|
+
return positions.length === 0 ? [{ color }] : positions.map((value) => ({ color, offset: position(value) }));
|
|
253
|
+
}
|
|
254
|
+
function centre(tokens) {
|
|
255
|
+
const invalid = () => new TypeError(`Invalid radial-gradient position: at ${tokens.join(" ")}`);
|
|
256
|
+
const HORIZONTAL = /^(left|right)$/;
|
|
257
|
+
const VERTICAL = /^(top|bottom)$/;
|
|
258
|
+
const KEYWORD = /^(left|right|top|bottom|center)$/;
|
|
259
|
+
const edge = (keyword) => keyword === "left" || keyword === "top" ? 0 : keyword === "center" ? 0.5 : 1;
|
|
260
|
+
const result = {};
|
|
261
|
+
if (tokens.length === 0 || tokens.length > 4)
|
|
262
|
+
throw invalid();
|
|
263
|
+
if (tokens.length <= 2) {
|
|
264
|
+
const loose = [];
|
|
265
|
+
for (const token of tokens) {
|
|
266
|
+
if (HORIZONTAL.test(token)) {
|
|
267
|
+
if (result.x !== undefined)
|
|
268
|
+
throw invalid();
|
|
269
|
+
result.x = edge(token);
|
|
270
|
+
} else if (VERTICAL.test(token)) {
|
|
271
|
+
if (result.y !== undefined)
|
|
272
|
+
throw invalid();
|
|
273
|
+
result.y = edge(token);
|
|
274
|
+
} else if (token === "center")
|
|
275
|
+
loose.push(0.5);
|
|
276
|
+
else
|
|
277
|
+
loose.push(position(token));
|
|
278
|
+
}
|
|
279
|
+
if (tokens.length === 2 && loose.length === 2)
|
|
280
|
+
return { x: loose[0], y: loose[1] };
|
|
281
|
+
if (tokens.length === 2 && loose.length === 1 && !KEYWORD.test(tokens[1]) && result.y !== undefined)
|
|
282
|
+
throw invalid();
|
|
283
|
+
result.x ??= loose.shift() ?? 0.5;
|
|
284
|
+
result.y ??= loose.shift() ?? 0.5;
|
|
285
|
+
return result;
|
|
286
|
+
}
|
|
287
|
+
let index = 0;
|
|
288
|
+
while (index < tokens.length) {
|
|
289
|
+
const keyword = tokens[index];
|
|
290
|
+
if (!KEYWORD.test(keyword))
|
|
291
|
+
throw invalid();
|
|
292
|
+
const next = tokens[index + 1];
|
|
293
|
+
const offset = next !== undefined && !KEYWORD.test(next) ? position(next) : undefined;
|
|
294
|
+
index += offset === undefined ? 1 : 2;
|
|
295
|
+
if (keyword === "center") {
|
|
296
|
+
if (offset !== undefined)
|
|
297
|
+
throw invalid();
|
|
298
|
+
if (result.x === undefined)
|
|
299
|
+
result.x = 0.5;
|
|
300
|
+
else if (result.y === undefined)
|
|
301
|
+
result.y = 0.5;
|
|
302
|
+
else
|
|
303
|
+
throw invalid();
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
const axis = HORIZONTAL.test(keyword) ? "x" : "y";
|
|
307
|
+
if (result[axis] !== undefined)
|
|
308
|
+
throw invalid();
|
|
309
|
+
const fromEnd = keyword === "right" || keyword === "bottom";
|
|
310
|
+
if (offset === undefined)
|
|
311
|
+
result[axis] = edge(keyword);
|
|
312
|
+
else if (typeof offset === "number")
|
|
313
|
+
result[axis] = fromEnd ? 1 - offset : offset;
|
|
314
|
+
else {
|
|
315
|
+
result[axis] = offset;
|
|
316
|
+
if (fromEnd) {
|
|
317
|
+
if (axis === "x")
|
|
318
|
+
result.xEdge = "right";
|
|
319
|
+
else
|
|
320
|
+
result.yEdge = "bottom";
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
result.x ??= 0.5;
|
|
325
|
+
result.y ??= 0.5;
|
|
326
|
+
return result;
|
|
327
|
+
}
|
|
328
|
+
var EXTENT = /^(closest|farthest)-(side|corner)$/;
|
|
329
|
+
function parseGradient(value) {
|
|
330
|
+
const match = value.trim().match(/^(repeating-)?(linear|radial)-gradient\(([\s\S]*)\)$/i);
|
|
331
|
+
if (!match)
|
|
332
|
+
throw new TypeError(`Unsupported gradient: ${value}`);
|
|
333
|
+
const repeating = match[1] ? { repeating: true } : {};
|
|
334
|
+
const args = splitTopLevel(match[3], /,/);
|
|
335
|
+
const first = (args[0] ?? "").toLowerCase().split(/\s+/);
|
|
336
|
+
if (match[2].toLowerCase() === "linear") {
|
|
337
|
+
const degrees = first.length === 1 ? angle(first[0]) : undefined;
|
|
338
|
+
if (degrees !== undefined)
|
|
339
|
+
return { type: "linear", angle: degrees, ...repeating, stops: args.slice(1).flatMap(parseStop) };
|
|
340
|
+
if (first[0] === "to") {
|
|
341
|
+
const sides = first.slice(1).sort((a, b) => Number(a === "left" || a === "right") - Number(b === "left" || b === "right"));
|
|
342
|
+
const valid = sides.length >= 1 && sides.length <= 2 && sides.every((side) => /^(top|bottom|left|right)$/.test(side)) && new Set(sides.map((side) => side === "top" || side === "bottom")).size === sides.length;
|
|
343
|
+
if (!valid)
|
|
344
|
+
throw new TypeError(`Invalid gradient direction: ${args[0]}`);
|
|
345
|
+
return { type: "linear", to: sides.join(" "), ...repeating, stops: args.slice(1).flatMap(parseStop) };
|
|
346
|
+
}
|
|
347
|
+
return { type: "linear", ...repeating, stops: args.flatMap(parseStop) };
|
|
348
|
+
}
|
|
349
|
+
const header = first.some((word) => /^(circle|ellipse|at)$/.test(word) || EXTENT.test(word) || LENGTH_PERCENT.test(word));
|
|
350
|
+
if (!header)
|
|
351
|
+
return { type: "radial", ...repeating, stops: args.flatMap(parseStop) };
|
|
352
|
+
const at = first.indexOf("at");
|
|
353
|
+
let shape;
|
|
354
|
+
let extent;
|
|
355
|
+
const lengths = [];
|
|
356
|
+
for (const word of at < 0 ? first : first.slice(0, at)) {
|
|
357
|
+
if (word === "circle" || word === "ellipse")
|
|
358
|
+
shape = word;
|
|
359
|
+
else if (EXTENT.test(word))
|
|
360
|
+
extent = word;
|
|
361
|
+
else if (LENGTH_PERCENT.test(word))
|
|
362
|
+
lengths.push(word);
|
|
363
|
+
else
|
|
364
|
+
throw new TypeError(`Unsupported radial-gradient size: ${word}`);
|
|
365
|
+
}
|
|
366
|
+
if (extent && lengths.length)
|
|
367
|
+
throw new TypeError(`A radial gradient takes an extent keyword or lengths, not both: ${args[0]}`);
|
|
368
|
+
if (lengths.length > 2)
|
|
369
|
+
throw new TypeError(`Too many radial-gradient sizes: ${args[0]}`);
|
|
370
|
+
shape ??= lengths.length === 1 ? "circle" : lengths.length === 2 ? "ellipse" : undefined;
|
|
371
|
+
if (shape === "circle" && (lengths.length > 1 || lengths.some((length) => String(length).endsWith("%")))) {
|
|
372
|
+
throw new TypeError(`A circle takes one px radius: ${args[0]}`);
|
|
373
|
+
}
|
|
374
|
+
if (shape === "ellipse" && lengths.length === 1)
|
|
375
|
+
throw new TypeError(`An ellipse takes two radii: ${args[0]}`);
|
|
376
|
+
const size = extent ?? (lengths.length === 1 ? lengths[0] : lengths.length === 2 ? [lengths[0], lengths[1]] : undefined);
|
|
377
|
+
return {
|
|
378
|
+
type: "radial",
|
|
379
|
+
...shape ? { shape } : {},
|
|
380
|
+
...size ? { size } : {},
|
|
381
|
+
...at >= 0 ? { at: centre(first.slice(at + 1)) } : {},
|
|
382
|
+
...repeating,
|
|
383
|
+
stops: args.slice(1).flatMap(parseStop)
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function normalizeGradient(gradient, colour) {
|
|
387
|
+
if (gradient.stops.length === 0)
|
|
388
|
+
throw new TypeError("A gradient needs at least one colour stop");
|
|
389
|
+
const stops = gradient.stops.map((stop) => {
|
|
390
|
+
const { color, offset } = typeof stop === "string" ? { color: stop, offset: undefined } : stop;
|
|
391
|
+
let resolved = offset;
|
|
392
|
+
if (typeof offset === "string") {
|
|
393
|
+
const parsed = position(offset.trim());
|
|
394
|
+
resolved = parsed;
|
|
395
|
+
} else if (offset !== undefined && !Number.isFinite(offset)) {
|
|
396
|
+
throw new TypeError(`Invalid gradient offset: ${offset}`);
|
|
397
|
+
}
|
|
398
|
+
return resolved === undefined ? { color: colour(color) } : { color: colour(color), offset: resolved };
|
|
399
|
+
});
|
|
400
|
+
return { ...gradient, stops: stops.length === 1 ? [stops[0], { color: stops[0].color }] : stops };
|
|
401
|
+
}
|
|
402
|
+
|
|
37
403
|
// packages/core/src/theme.ts
|
|
38
404
|
var defaultFocusOutline = {
|
|
39
405
|
outlineWidth: 2,
|
|
@@ -212,13 +578,46 @@ function resolveThemeColor(value, selected) {
|
|
|
212
578
|
const key = keyByRef.get(value);
|
|
213
579
|
return key ? selected.colors[key] : value;
|
|
214
580
|
}
|
|
581
|
+
var PAINT_KEYS = ["background", "foreground", "borderColor"];
|
|
582
|
+
function resolveShadowColors(style, selected) {
|
|
583
|
+
if (typeof style.transform === "string")
|
|
584
|
+
style.transform = parseTransform(style.transform);
|
|
585
|
+
const colour = (value) => resolveThemeColor(cssColor(value), selected);
|
|
586
|
+
if (typeof style.textShadow === "string") {
|
|
587
|
+
const parsed = parseTextShadow(style.textShadow);
|
|
588
|
+
if (parsed)
|
|
589
|
+
style.textShadow = parsed;
|
|
590
|
+
else
|
|
591
|
+
delete style.textShadow;
|
|
592
|
+
}
|
|
593
|
+
if (style.textShadow && typeof style.textShadow === "object") {
|
|
594
|
+
style.textShadow = { ...style.textShadow, color: colour(style.textShadow.color) };
|
|
595
|
+
}
|
|
596
|
+
for (const key of PAINT_KEYS) {
|
|
597
|
+
const value = style[key];
|
|
598
|
+
const gradient = typeof value === "string" && GRADIENT.test(value) ? parseGradient(value) : value;
|
|
599
|
+
if (gradient && typeof gradient === "object")
|
|
600
|
+
style[key] = normalizeGradient(gradient, colour);
|
|
601
|
+
}
|
|
602
|
+
const box = typeof style.boxShadow === "string" ? parseBoxShadow(style.boxShadow) : style.boxShadow;
|
|
603
|
+
if (box !== undefined) {
|
|
604
|
+
style.boxShadow = Array.isArray(box) ? box.map((shadow) => ({ ...shadow, color: colour(shadow.color) })) : { ...box, color: colour(box.color) };
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
var COLOR_KEY = /^(background|foreground|color)$|(Color|Background|Foreground|Accent|Rule)$/;
|
|
608
|
+
function resolveStyleString(key, value, selected) {
|
|
609
|
+
if (PAINT_KEYS.includes(key) && GRADIENT.test(value))
|
|
610
|
+
return value;
|
|
611
|
+
return resolveThemeColor(COLOR_KEY.test(key) ? cssColor(value) : value, selected);
|
|
612
|
+
}
|
|
215
613
|
function resolveThemeStyle(style, selected) {
|
|
216
614
|
const resolved = { ...style };
|
|
217
615
|
for (const key of Object.keys(resolved)) {
|
|
218
616
|
const value = resolved[key];
|
|
219
617
|
if (typeof value === "string")
|
|
220
|
-
resolved[key] =
|
|
618
|
+
resolved[key] = resolveStyleString(key, value, selected);
|
|
221
619
|
}
|
|
620
|
+
resolveShadowColors(resolved, selected);
|
|
222
621
|
for (const state of ["hover", "focus", "focusVisible", "active", "disabled"]) {
|
|
223
622
|
const value = style[state];
|
|
224
623
|
if (!value)
|
|
@@ -227,9 +626,10 @@ function resolveThemeStyle(style, selected) {
|
|
|
227
626
|
for (const key of Object.keys(next)) {
|
|
228
627
|
const stateValue = next[key];
|
|
229
628
|
if (typeof stateValue === "string") {
|
|
230
|
-
next[key] =
|
|
629
|
+
next[key] = resolveStyleString(key, stateValue, selected);
|
|
231
630
|
}
|
|
232
631
|
}
|
|
632
|
+
resolveShadowColors(next, selected);
|
|
233
633
|
resolved[state] = next;
|
|
234
634
|
}
|
|
235
635
|
return resolved;
|
|
@@ -282,7 +682,7 @@ function Pressable(props) {
|
|
|
282
682
|
}
|
|
283
683
|
// packages/protocol/src/index.ts
|
|
284
684
|
var NATIVE_ABI_VERSION = 5;
|
|
285
|
-
var PROTOCOL_VERSION =
|
|
685
|
+
var PROTOCOL_VERSION = 47;
|
|
286
686
|
|
|
287
687
|
// packages/core/src/bridge/binding.ts
|
|
288
688
|
import { dlopen } from "bun:ffi";
|
|
@@ -865,6 +1265,10 @@ function accessibleText2(child, parts = []) {
|
|
|
865
1265
|
}
|
|
866
1266
|
return parts.join(" ").replace(/\s+/g, " ").trim();
|
|
867
1267
|
}
|
|
1268
|
+
function firstStopColor(gradient) {
|
|
1269
|
+
const stop = gradient.stops[0];
|
|
1270
|
+
return typeof stop === "string" ? stop : stop?.color ?? theme.colors.foreground;
|
|
1271
|
+
}
|
|
868
1272
|
function composedContent(child, foreground) {
|
|
869
1273
|
if (Array.isArray(child))
|
|
870
1274
|
return child.map((item) => composedContent(item, foreground));
|
|
@@ -922,15 +1326,6 @@ function composedContent(child, foreground) {
|
|
|
922
1326
|
}
|
|
923
1327
|
};
|
|
924
1328
|
}
|
|
925
|
-
if (child.type === "icon") {
|
|
926
|
-
return {
|
|
927
|
-
...child,
|
|
928
|
-
props: {
|
|
929
|
-
...props,
|
|
930
|
-
style: { foreground, ...props.style }
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
}
|
|
934
1329
|
const children = props.children === undefined ? undefined : composedContent(props.children, foreground);
|
|
935
1330
|
if (children === undefined)
|
|
936
1331
|
return child;
|
|
@@ -968,7 +1363,8 @@ function Button({ variant = "default", size = "default", style, disabled, contro
|
|
|
968
1363
|
}
|
|
969
1364
|
const label = accessibleText2(children);
|
|
970
1365
|
const semanticControl = control ? { ...control, ...control.label || !label ? {} : { label } } : { role: "button", ...label ? { label } : {} };
|
|
971
|
-
const
|
|
1366
|
+
const paint = disabled ? buttonStyle.disabled?.foreground ?? buttonStyle.foreground ?? theme.colors.foreground : buttonStyle.foreground ?? theme.colors.foreground;
|
|
1367
|
+
const foreground = typeof paint !== "string" ? firstStopColor(paint) : GRADIENT.test(paint) ? firstStopColor(parseGradient(paint)) : paint;
|
|
972
1368
|
return _nativeJsx("pressable", {
|
|
973
1369
|
...props,
|
|
974
1370
|
children: composedContent(children, foreground),
|
|
@@ -5702,7 +6098,7 @@ function compileTree(element, debug = false, renderer = "auto", componentAdapter
|
|
|
5702
6098
|
height: p.height ?? 820,
|
|
5703
6099
|
minWidth: p.minWidth ?? 780,
|
|
5704
6100
|
minHeight: p.minHeight ?? 580,
|
|
5705
|
-
background:
|
|
6101
|
+
background: resolveStyleString("background", p.style?.background ?? theme.colors.background, selectedTheme),
|
|
5706
6102
|
decorations: true,
|
|
5707
6103
|
resizable: p.resizable ?? true,
|
|
5708
6104
|
position: p.position ?? "center",
|
|
@@ -5738,6 +6134,8 @@ function compileTree(element, debug = false, renderer = "auto", componentAdapter
|
|
|
5738
6134
|
...focusOutlineOverrides(p.style?.focus),
|
|
5739
6135
|
...p.style?.focusVisible
|
|
5740
6136
|
};
|
|
6137
|
+
if (control?.role === "otpSlot")
|
|
6138
|
+
rawStyle.focus = { ...rawStyle.focusVisible, ...p.style?.focus };
|
|
5741
6139
|
}
|
|
5742
6140
|
const style = resolveThemeStyle(rawStyle, selectedTheme);
|
|
5743
6141
|
for (const key of ["padding", "margin"]) {
|
|
@@ -6572,22 +6970,23 @@ function createApp(view, options = {}) {
|
|
|
6572
6970
|
return app;
|
|
6573
6971
|
}
|
|
6574
6972
|
async function render(view, options) {
|
|
6575
|
-
const
|
|
6973
|
+
const hot = process.execArgv.includes("--hot");
|
|
6576
6974
|
const registry = globalThis;
|
|
6577
|
-
const existing =
|
|
6975
|
+
const existing = registry[DEV_APP_KEY];
|
|
6578
6976
|
if (existing) {
|
|
6579
6977
|
existing.remount(view);
|
|
6580
|
-
|
|
6978
|
+
if (!hot)
|
|
6979
|
+
await existing.closed;
|
|
6581
6980
|
return;
|
|
6582
6981
|
}
|
|
6583
6982
|
const app = createApp(view, options);
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
|
|
6587
|
-
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
}
|
|
6983
|
+
registry[DEV_APP_KEY] = app;
|
|
6984
|
+
app.closed.then(() => {
|
|
6985
|
+
if (registry[DEV_APP_KEY] === app)
|
|
6986
|
+
delete registry[DEV_APP_KEY];
|
|
6987
|
+
if (hot)
|
|
6988
|
+
process.exit(0);
|
|
6989
|
+
});
|
|
6591
6990
|
try {
|
|
6592
6991
|
await app.ready;
|
|
6593
6992
|
} catch (error) {
|
|
@@ -6595,7 +6994,8 @@ async function render(view, options) {
|
|
|
6595
6994
|
delete registry[DEV_APP_KEY];
|
|
6596
6995
|
throw error;
|
|
6597
6996
|
}
|
|
6598
|
-
|
|
6997
|
+
if (!hot)
|
|
6998
|
+
await app.closed;
|
|
6599
6999
|
}
|
|
6600
7000
|
function pastePayload(event) {
|
|
6601
7001
|
if (event.files?.length)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"packageVersion": "0.
|
|
4
|
-
"protocolVersion":
|
|
3
|
+
"packageVersion": "0.3.0",
|
|
4
|
+
"protocolVersion": 47,
|
|
5
5
|
"nativeAbiVersion": 5,
|
|
6
|
-
"sourceFingerprint": "
|
|
6
|
+
"sourceFingerprint": "3afbaa02c07fe554ac6ca8a2ac82546b8a25ca8eeadee359369edf87f027e9e0"
|
|
7
7
|
}
|
package/dist/npm/protocol.js
CHANGED
|
@@ -53,7 +53,7 @@ export interface AppHandle {
|
|
|
53
53
|
}
|
|
54
54
|
export declare function createApp(view: () => VNode, options?: AppOptions): AppHandle;
|
|
55
55
|
/**
|
|
56
|
-
* Renders the app until its window closes.
|
|
56
|
+
* Renders the app until its window closes. A second call in the same
|
|
57
57
|
* process (e.g. a `bun --hot` reload) remounts into the already open window.
|
|
58
58
|
*/
|
|
59
59
|
export declare function render(view: () => VNode, options?: AppOptions): Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { BoxShadow, Gradient, TextShadow, Transform } from "../../protocol/src/index";
|
|
2
|
+
/**
|
|
3
|
+
* CSS colour → "#rrggbbaa". Hex, rgb()/rgba(), hsl()/hsla() and a few names are
|
|
4
|
+
* converted; theme tokens (`var(--…)`) pass through for theme resolution.
|
|
5
|
+
*/
|
|
6
|
+
export declare function cssColor(value: string): string;
|
|
7
|
+
/** CSS `box-shadow` syntax: "inset 0 1px 2px rgba(0,0,0,.2), 0 8px 24px #0003" or "none". */
|
|
8
|
+
export declare function parseBoxShadow(value: string): BoxShadow[];
|
|
9
|
+
/** CSS `text-shadow` syntax for one solid shadow: "1px 2px #0006". Blur must be 0. */
|
|
10
|
+
export declare function parseTextShadow(value: string): TextShadow | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* CSS `transform` syntax limited to translate/scale: "translateY(-2px) scale(1.02)".
|
|
13
|
+
* Functions compose left to right as in CSS; "none" is the identity.
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseTransform(value: string): Transform;
|
|
16
|
+
export declare const GRADIENT: RegExp;
|
|
17
|
+
/** CSS `linear-gradient(…)` / `radial-gradient(…)` and their `repeating-` forms → gradient object. */
|
|
18
|
+
export declare function parseGradient(value: string): Gradient;
|
|
19
|
+
/** Resolves stop colours and converts `N%` offsets to fractions; px and omitted offsets resolve natively. */
|
|
20
|
+
export declare function normalizeGradient(gradient: Gradient, colour: (value: string) => string): Gradient;
|
|
@@ -30,7 +30,7 @@ export type { ComponentAdapter, ComponentAdapterInput } from "./component-adapte
|
|
|
30
30
|
export { theme, Theme, lightTheme, darkTheme, createTheme, buttonVariants } from "./theme";
|
|
31
31
|
export type { ThemeColors, ThemeFocusOutline, ThemeDefinition, ThemeOverrides, ButtonVariant } from "./theme";
|
|
32
32
|
export { Style } from "./style";
|
|
33
|
-
export type { StateStyle, OutlineStyle, UserSelect, TextDecoration, Renderer, WindowPosition, WindowPositionPreset, FileDialogFilter, FileDialogOptions, ScrollOrientation, ScrollPosition, MotionProperty, MotionEasing, MotionTransition, MotionTransitions, MotionValues } from "../../protocol/src/index";
|
|
33
|
+
export type { StateStyle, OutlineStyle, BorderStyle, TextShadow, BoxShadow, Transform, Gradient, GradientStop, GradientSide, GradientLength, GradientCentre, RadialExtent, LinearGradient, RadialGradient, UserSelect, TextDecoration, Renderer, WindowPosition, WindowPositionPreset, FileDialogFilter, FileDialogOptions, ScrollOrientation, ScrollPosition, MotionProperty, NumericMotionProperty, MotionEasing, MotionTransition, MotionTransitions, MotionValues } from "../../protocol/src/index";
|
|
34
34
|
export type { VNode, Child, PastePayload } from "./jsx-runtime";
|
|
35
35
|
export { BunFfiBridge, openExternal } from "./bridge";
|
|
36
36
|
export type { NativeBridge, BunFfiBridgeOptions } from "./bridge";
|
|
@@ -86,6 +86,8 @@ export declare const theme: {
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
export declare function resolveThemeColor(value: string, selected: ThemeDefinition): string;
|
|
89
|
+
/** Theme token or CSS colour (hex, rgb(), hsl(), names) for colour keys; other strings unchanged. */
|
|
90
|
+
export declare function resolveStyleString(key: string, value: string, selected: ThemeDefinition): string;
|
|
89
91
|
export declare function resolveThemeStyle(style: Style, selected: ThemeDefinition): Style;
|
|
90
92
|
export type ButtonVariant = "default" | "secondary" | "outline" | "ghost" | "destructive";
|
|
91
93
|
export declare const buttonVariants: Record<ButtonVariant, Style>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/** Renderer-independent, versioned messages crossing the C ABI as UTF-8 JSON. */
|
|
2
2
|
export declare const NATIVE_ABI_VERSION = 5;
|
|
3
|
-
export declare const PROTOCOL_VERSION =
|
|
3
|
+
export declare const PROTOCOL_VERSION = 47;
|
|
4
4
|
export type Renderer = "auto" | "gpu" | "cpu";
|
|
5
5
|
export type Length = number | `${number}%` | "auto";
|
|
6
|
-
|
|
6
|
+
/** Numeric properties: usable in `motionFrom` and AnimatePresence enter/exit values. */
|
|
7
|
+
export type NumericMotionProperty = "width" | "height" | "top" | "right" | "bottom" | "left" | "opacity" | "radius";
|
|
8
|
+
/** Colour and shadow properties also transition on hover/active/focus/disabled changes. */
|
|
9
|
+
export type MotionProperty = NumericMotionProperty | "background" | "foreground" | "borderColor" | "boxShadow" | "textShadow" | "transform";
|
|
7
10
|
export type MotionEasing = "linear" | "ease" | "easeIn" | "easeOut" | "easeInOut";
|
|
8
11
|
export interface MotionTransition {
|
|
9
12
|
/** Duration in milliseconds. Defaults to 200 when omitted. */
|
|
@@ -13,7 +16,7 @@ export interface MotionTransition {
|
|
|
13
16
|
easing?: MotionEasing;
|
|
14
17
|
}
|
|
15
18
|
export type MotionTransitions = Partial<Record<MotionProperty | "all", MotionTransition>>;
|
|
16
|
-
export type MotionValues = Partial<Record<
|
|
19
|
+
export type MotionValues = Partial<Record<NumericMotionProperty, number>>;
|
|
17
20
|
export type NodeKind = "window" | "titlebar" | "view" | "row" | "column" | "text" | "markdown" | "code" | "diff" | "button" | "image" | "svg" | "scroll" | "input" | "textarea" | "pressable" | "slider" | "splitter";
|
|
18
21
|
export type SvgElementName = "path" | "circle" | "ellipse" | "g" | "line" | "polygon" | "polyline" | "rect";
|
|
19
22
|
export type SvgAttributeValue = string | number;
|
|
@@ -26,6 +29,75 @@ export type Insets = number | {
|
|
|
26
29
|
left?: number;
|
|
27
30
|
};
|
|
28
31
|
export type OutlineStyle = "dotted" | "dashed" | "solid" | "double" | "groove" | "ridge" | "inset" | "outset" | "none" | "hidden";
|
|
32
|
+
/** Same values as OutlineStyle. Non-solid styles apply when all four border widths are equal. */
|
|
33
|
+
export type BorderStyle = OutlineStyle;
|
|
34
|
+
/** Offset copy of the text; `blur` is the CSS blur radius (sigma = blur / 2, max 200), 0 for a solid copy. */
|
|
35
|
+
export interface TextShadow {
|
|
36
|
+
x?: number;
|
|
37
|
+
y?: number;
|
|
38
|
+
blur?: number;
|
|
39
|
+
color: string;
|
|
40
|
+
}
|
|
41
|
+
/** CSS-like box shadow. `blur` is the CSS blur radius (sigma = blur / 2); `inset` paints inside the padding box. */
|
|
42
|
+
/** Paint-time translate/scale about the box centre. Hit testing follows it; layout does not. */
|
|
43
|
+
export interface Transform {
|
|
44
|
+
x?: number;
|
|
45
|
+
y?: number;
|
|
46
|
+
scale?: number;
|
|
47
|
+
scaleX?: number;
|
|
48
|
+
scaleY?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface BoxShadow {
|
|
51
|
+
x?: number;
|
|
52
|
+
y?: number;
|
|
53
|
+
blur?: number;
|
|
54
|
+
spread?: number;
|
|
55
|
+
color: string;
|
|
56
|
+
inset?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** Gradient length: a number is px; strings take `px` or `%`. */
|
|
59
|
+
export type GradientLength = number | `${number}px` | `${number}%`;
|
|
60
|
+
/**
|
|
61
|
+
* A colour stop. A number `offset` is a fraction 0..1 of the gradient line (or radial ray);
|
|
62
|
+
* strings take `px` or `%`. Omitted offsets are spread evenly and positions never go back, as in CSS.
|
|
63
|
+
*/
|
|
64
|
+
export interface GradientStop {
|
|
65
|
+
color: string;
|
|
66
|
+
offset?: number | `${number}px` | `${number}%`;
|
|
67
|
+
}
|
|
68
|
+
export type GradientSide = "top" | "bottom" | "left" | "right" | "top left" | "top right" | "bottom left" | "bottom right";
|
|
69
|
+
/** CSS `linear-gradient`: `angle` in CSS degrees (0 = to top, 90 = to right, default 180), or `to` a side/corner. */
|
|
70
|
+
export interface LinearGradient {
|
|
71
|
+
type: "linear";
|
|
72
|
+
angle?: number;
|
|
73
|
+
to?: GradientSide;
|
|
74
|
+
repeating?: boolean;
|
|
75
|
+
stops: readonly (GradientStop | string)[];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Radial centre. A number is a fraction of the box; strings take `px` or `%`.
|
|
79
|
+
* `xEdge: "right"` / `yEdge: "bottom"` measure from the far edge (CSS `right 10px bottom 20%`).
|
|
80
|
+
*/
|
|
81
|
+
export interface GradientCentre {
|
|
82
|
+
x?: number | `${number}px` | `${number}%`;
|
|
83
|
+
y?: number | `${number}px` | `${number}%`;
|
|
84
|
+
xEdge?: "left" | "right";
|
|
85
|
+
yEdge?: "top" | "bottom";
|
|
86
|
+
}
|
|
87
|
+
export type RadialExtent = "closest-side" | "closest-corner" | "farthest-side" | "farthest-corner";
|
|
88
|
+
/**
|
|
89
|
+
* CSS `radial-gradient`. `at` is the centre as fractions of the box (default 0.5, 0.5).
|
|
90
|
+
* `size` is an extent keyword (default `farthest-corner`), one length (circle radius) or two (ellipse radii).
|
|
91
|
+
*/
|
|
92
|
+
export interface RadialGradient {
|
|
93
|
+
type: "radial";
|
|
94
|
+
shape?: "ellipse" | "circle";
|
|
95
|
+
at?: GradientCentre;
|
|
96
|
+
size?: RadialExtent | GradientLength | readonly [GradientLength, GradientLength];
|
|
97
|
+
repeating?: boolean;
|
|
98
|
+
stops: readonly (GradientStop | string)[];
|
|
99
|
+
}
|
|
100
|
+
export type Gradient = LinearGradient | RadialGradient;
|
|
29
101
|
export type UserSelect = "auto" | "text" | "none" | "all";
|
|
30
102
|
export type TextDecoration = "none" | "underline" | "overline" | "line-through";
|
|
31
103
|
export interface SyntaxTheme {
|
|
@@ -69,9 +141,11 @@ export interface TextHighlight {
|
|
|
69
141
|
activeColor?: string;
|
|
70
142
|
}
|
|
71
143
|
export interface StateStyle {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
144
|
+
/** Colour, gradient object, or CSS `linear-gradient(…)` / `radial-gradient(…)` string. */
|
|
145
|
+
background?: string | Gradient;
|
|
146
|
+
foreground?: string | Gradient;
|
|
147
|
+
borderColor?: string | Gradient;
|
|
148
|
+
borderStyle?: BorderStyle;
|
|
75
149
|
radius?: number;
|
|
76
150
|
opacity?: number;
|
|
77
151
|
outlineWidth?: number;
|
|
@@ -86,6 +160,13 @@ export interface StateStyle {
|
|
|
86
160
|
placeholderBackground?: string;
|
|
87
161
|
thumbColor?: string;
|
|
88
162
|
textDecoration?: TextDecoration;
|
|
163
|
+
/** Text, button, Input and TextArea text. Offset copy, optionally blurred. */
|
|
164
|
+
/** Object form, or CSS text-shadow syntax such as "1px 2px 4px #0006". */
|
|
165
|
+
textShadow?: TextShadow | string;
|
|
166
|
+
/** One shadow or up to 8; the first paints on top. Does not affect layout. */
|
|
167
|
+
boxShadow?: BoxShadow | readonly BoxShadow[] | string;
|
|
168
|
+
/** Object form, or CSS syntax such as "translateY(-2px) scale(1.02)" (translate/scale only). */
|
|
169
|
+
transform?: Transform | string;
|
|
89
170
|
}
|
|
90
171
|
export interface Style extends StateStyle {
|
|
91
172
|
width?: Length;
|
|
Binary file
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"packageVersion": "0.
|
|
4
|
-
"protocolVersion":
|
|
3
|
+
"packageVersion": "0.3.0",
|
|
4
|
+
"protocolVersion": 47,
|
|
5
5
|
"nativeAbiVersion": 5,
|
|
6
|
-
"sourceFingerprint": "
|
|
6
|
+
"sourceFingerprint": "3afbaa02c07fe554ac6ca8a2ac82546b8a25ca8eeadee359369edf87f027e9e0",
|
|
7
7
|
"target": "linux-x64",
|
|
8
8
|
"nativeName": "libtarve_native.so",
|
|
9
|
-
"sha256": "
|
|
9
|
+
"sha256": "a8d0836ce5cafcdd545a0a1a96830fd5f9185fb741cf22302dee2ddfdfd37ed8"
|
|
10
10
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"packageVersion": "0.
|
|
4
|
-
"protocolVersion":
|
|
3
|
+
"packageVersion": "0.3.0",
|
|
4
|
+
"protocolVersion": 47,
|
|
5
5
|
"nativeAbiVersion": 5,
|
|
6
|
-
"sourceFingerprint": "
|
|
6
|
+
"sourceFingerprint": "3afbaa02c07fe554ac6ca8a2ac82546b8a25ca8eeadee359369edf87f027e9e0",
|
|
7
7
|
"target": "windows-x64",
|
|
8
8
|
"nativeName": "tarve_native.dll",
|
|
9
|
-
"sha256": "
|
|
9
|
+
"sha256": "d6ec51f5ae61c5240788c657988eaedbd5ec3ea7cd968febea394ce0e5e5d177"
|
|
10
10
|
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarve/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Native Bun/TSX GUI with Taffy layout, Parley text and Vello rendering",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"tarve": "./dist/npm/cli.js"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
|
+
"CHANGELOG.md",
|
|
35
36
|
"dist/npm",
|
|
36
37
|
"dist/types",
|
|
37
38
|
"native/win32-x64",
|