@tarve/core 0.1.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 +201 -0
- package/PERFORMANCE.md +82 -0
- package/README.md +549 -0
- package/RELEASE.md +72 -0
- package/dist/npm/build.js +259 -0
- package/dist/npm/cli.js +285 -0
- package/dist/npm/embedded-assets.js +52 -0
- package/dist/npm/index.js +7077 -0
- package/dist/npm/jsx-dev-runtime.js +17 -0
- package/dist/npm/jsx-runtime.js +27 -0
- package/dist/npm/native-runtime.json +7 -0
- package/dist/npm/protocol.js +8 -0
- package/dist/npm/runtime.js +98 -0
- package/dist/types/core/build.d.ts +13 -0
- package/dist/types/core/cli.d.ts +2 -0
- package/dist/types/core/native-runtime.d.ts +22 -0
- package/dist/types/core/src/advanced-controls.d.ts +120 -0
- package/dist/types/core/src/app.d.ts +59 -0
- package/dist/types/core/src/assets.d.ts +4 -0
- package/dist/types/core/src/bridge/binding.d.ts +34 -0
- package/dist/types/core/src/bridge/index.d.ts +41 -0
- package/dist/types/core/src/bridge/runtime.d.ts +4 -0
- package/dist/types/core/src/chat-controls.d.ts +40 -0
- package/dist/types/core/src/component-adapter.d.ts +11 -0
- package/dist/types/core/src/components/button.d.ts +12 -0
- package/dist/types/core/src/components/icon.d.ts +13 -0
- package/dist/types/core/src/components/image.d.ts +43 -0
- package/dist/types/core/src/components/input.d.ts +22 -0
- package/dist/types/core/src/components/layout.d.ts +22 -0
- package/dist/types/core/src/components/link.d.ts +10 -0
- package/dist/types/core/src/components/modal.d.ts +15 -0
- package/dist/types/core/src/components/pressable.d.ts +19 -0
- package/dist/types/core/src/components/rich-content.d.ts +45 -0
- package/dist/types/core/src/components/scroll.d.ts +12 -0
- package/dist/types/core/src/components/svg.d.ts +61 -0
- package/dist/types/core/src/components/text.d.ts +9 -0
- package/dist/types/core/src/components/titlebar.d.ts +10 -0
- package/dist/types/core/src/components/window.d.ts +20 -0
- package/dist/types/core/src/components.d.ts +34 -0
- package/dist/types/core/src/controls.d.ts +84 -0
- package/dist/types/core/src/desktop-controls.d.ts +62 -0
- package/dist/types/core/src/dev-overlay.d.ts +9 -0
- package/dist/types/core/src/embedded-assets.d.ts +4 -0
- package/dist/types/core/src/extra-controls.d.ts +182 -0
- package/dist/types/core/src/form-controls.d.ts +118 -0
- package/dist/types/core/src/hotkeys.d.ts +3 -0
- package/dist/types/core/src/index.d.ts +36 -0
- package/dist/types/core/src/intrinsic-style.d.ts +3 -0
- package/dist/types/core/src/jsx-dev-runtime.d.ts +2 -0
- package/dist/types/core/src/jsx-runtime.d.ts +279 -0
- package/dist/types/core/src/list.d.ts +10 -0
- package/dist/types/core/src/motion.d.ts +19 -0
- package/dist/types/core/src/popups.d.ts +115 -0
- package/dist/types/core/src/reconciler.d.ts +54 -0
- package/dist/types/core/src/render-scope.d.ts +3 -0
- package/dist/types/core/src/select.d.ts +17 -0
- package/dist/types/core/src/style.d.ts +7 -0
- package/dist/types/core/src/test-renderer.d.ts +84 -0
- package/dist/types/core/src/text-search.d.ts +37 -0
- package/dist/types/core/src/theme.d.ts +91 -0
- package/dist/types/core/src/virtual-list.d.ts +31 -0
- package/dist/types/core/src/visual-testing.d.ts +24 -0
- package/dist/types/core/targets.d.ts +16 -0
- package/dist/types/protocol/src/index.d.ts +534 -0
- package/native/linux-x64/libtarve_native.so +0 -0
- package/native/linux-x64/runtime.json +10 -0
- package/native/win32-x64/runtime.json +10 -0
- package/native/win32-x64/tarve_native.dll +0 -0
- package/package.json +131 -0
package/README.md
ADDED
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
# Tarve
|
|
2
|
+
|
|
3
|
+
Native desktop UI for **Bun + TypeScript/TSX**.
|
|
4
|
+
|
|
5
|
+
Tarve turns a TSX tree into a retained native interface. It does not use a browser, DOM, or React runtime. Layout is handled by **Taffy**, text shaping and editing by **Parley**, and rendering is selectable between GPU and low-memory CPU paths.
|
|
6
|
+
|
|
7
|
+
> **Current supported targets:** Windows x64 and Linux x64
|
|
8
|
+
>
|
|
9
|
+
> **Runtime:** Bun 1.4+
|
|
10
|
+
>
|
|
11
|
+
> **Package:** `tarve`
|
|
12
|
+
>
|
|
13
|
+
> **License:** Apache-2.0
|
|
14
|
+
|
|
15
|
+
## Highlights
|
|
16
|
+
|
|
17
|
+
- Native TSX UI with a dedicated `tarve` JSX runtime.
|
|
18
|
+
- Retained Taffy Flexbox/Grid layout with incremental property and structural updates.
|
|
19
|
+
- Parley text shaping, selection, clipboard, caret handling, IME composition, and Unicode-aware editing.
|
|
20
|
+
- Native Windows D3D11/DXGI renderer with Vello/WGPU fallback; Linux uses Vello/WGPU. Both platforms provide a `vello_cpu + softbuffer` CPU renderer.
|
|
21
|
+
- shadcn-inspired components and semantic light/dark theme tokens.
|
|
22
|
+
- Native Markdown, syntax-highlighted Code, and Diff leaves designed for large documents.
|
|
23
|
+
- Fixed-height, measured variable-height, and externally windowed `VirtualList` modes.
|
|
24
|
+
- Windows UI Automation accessibility through AccessKit.
|
|
25
|
+
- Global hotkeys, native file dialogs, custom title bars, window positioning, and standalone Windows/Linux builds.
|
|
26
|
+
- Event-driven Bun/native bridge with no continuous idle polling.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
For a published package:
|
|
31
|
+
|
|
32
|
+
```powershell
|
|
33
|
+
bun add tarve
|
|
34
|
+
bun add -d typescript @types/bun
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
To consume the package directly from this repository before registry publication:
|
|
38
|
+
|
|
39
|
+
```powershell
|
|
40
|
+
bun run pack
|
|
41
|
+
bun add ./dist/tarve-0.1.0.tgz
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use this TypeScript configuration:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"compilerOptions": {
|
|
49
|
+
"target": "ESNext",
|
|
50
|
+
"module": "ESNext",
|
|
51
|
+
"moduleResolution": "Bundler",
|
|
52
|
+
"strict": true,
|
|
53
|
+
"noEmit": true,
|
|
54
|
+
"jsx": "react-jsx",
|
|
55
|
+
"jsxImportSource": "@tarve/core",
|
|
56
|
+
"types": ["bun", "@tarve/core/assets"]
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick start
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Button, Column, Text, Window, createApp } from "@tarve/core";
|
|
65
|
+
|
|
66
|
+
let count = 0;
|
|
67
|
+
|
|
68
|
+
function App() {
|
|
69
|
+
return (
|
|
70
|
+
<Window title="Counter" width={520} height={360}>
|
|
71
|
+
<Column flex={1} align="center" justify="center" gap={16}>
|
|
72
|
+
<Text size={42} weight={700}>{count}</Text>
|
|
73
|
+
<Button onClick={() => count++}>Increase</Button>
|
|
74
|
+
</Column>
|
|
75
|
+
</Window>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const app = createApp(App);
|
|
80
|
+
await app.ready;
|
|
81
|
+
await app.closed;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Run the source directly with Bun:
|
|
85
|
+
|
|
86
|
+
```powershell
|
|
87
|
+
bun app.tsx
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Build a standalone executable
|
|
91
|
+
|
|
92
|
+
The package CLI compiles a Tarve application into a standalone executable and embeds the native runtime. Windows produces a `.exe`; Linux produces an ELF executable with no required extension. The target defaults to the current host. Published Tarve packages contain both Windows x64 and Linux x64 native runtimes, so `--target` can switch between those targets without rebuilding Tarve's Rust runtime.
|
|
93
|
+
|
|
94
|
+
```powershell
|
|
95
|
+
bun run tarve build app.tsx --outfile dist/App.exe
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bun run tarve build app.tsx --outfile dist/App
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Cross-compile explicitly from either Windows x64 or Linux x64:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
bun run tarve build app.tsx --target windows-x64 --outfile dist/App.exe
|
|
106
|
+
bun run tarve build app.tsx --target linux-x64 --outfile dist/App
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Tarve's release/package pipeline builds each native runtime on its native OS and assembles both into the same npm package. Repository maintainers can stage one runtime with `bun run package:native`; `bun run package` intentionally refuses to create an incomplete single-platform package.
|
|
110
|
+
|
|
111
|
+
Each staged native runtime carries compatibility metadata containing its target, native ABI, JSON protocol version, source fingerprint, and binary hash. Cross-compilation validates that metadata before embedding the runtime, so a stale Linux `.so` cannot be combined with newer JavaScript (or vice versa). After native/protocol changes, rebuild the affected runtime on that OS with `bun run package:native` before cross-compiling from the other OS.
|
|
112
|
+
|
|
113
|
+
To build the Linux runtime on Ubuntu or WSL, install the native toolchain once:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
apt-get update
|
|
117
|
+
apt-get install -y build-essential pkg-config libx11-dev libxkbcommon-dev libxkbcommon-x11-0 libwayland-dev libegl1-mesa-dev libfontconfig1-dev curl ca-certificates
|
|
118
|
+
curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain stable
|
|
119
|
+
source "$HOME/.cargo/env"
|
|
120
|
+
cargo --version
|
|
121
|
+
bun run package:native
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Rustup installs Cargo per user. If you switch between a normal WSL user and `root`, install/activate Rust for the user that actually runs `bun run package:native`, or run the build from the same user where Rustup was installed.
|
|
125
|
+
|
|
126
|
+
The build API is also exported:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import { build } from "@tarve/core/build";
|
|
130
|
+
|
|
131
|
+
await build({
|
|
132
|
+
entrypoint: "app.tsx",
|
|
133
|
+
target: "linux-x64",
|
|
134
|
+
outfile: "dist/App",
|
|
135
|
+
name: "My App"
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Renderers
|
|
140
|
+
|
|
141
|
+
`createApp` accepts `renderer: "auto" | "gpu" | "cpu"`.
|
|
142
|
+
|
|
143
|
+
| Mode | Windows | Linux |
|
|
144
|
+
| --- | --- | --- |
|
|
145
|
+
| `auto` | Uses the native D3D11/DXGI GPU renderer by default. | Uses the Vello/WGPU GPU renderer by default. |
|
|
146
|
+
| `gpu` | Uses D3D11/DXGI with Vello/WGPU fallback for initialization or recovery failures. If Vello cannot run on the available adapter, falls back to CPU. | Uses Vello/WGPU with the platform graphics backend selected by WGPU. If the adapter lacks Vello's required shader features, falls back to CPU. |
|
|
147
|
+
| `cpu` | Uses `vello_cpu + softbuffer`. | Uses `vello_cpu + softbuffer`. |
|
|
148
|
+
|
|
149
|
+
```tsx
|
|
150
|
+
const app = createApp(App, {
|
|
151
|
+
renderer: "cpu"
|
|
152
|
+
});
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
An explicit renderer in `createApp` takes precedence over `TARVE_RENDERER`. `WGPU_BACKEND` can select a WGPU backend for development and diagnostics. On Windows, setting it also selects the Vello/WGPU path instead of the normal D3D11 renderer. An explicit `WGPU_BACKEND` keeps GPU failures strict instead of silently falling back to CPU, which makes backend-specific diagnostics reliable.
|
|
156
|
+
|
|
157
|
+
## Components
|
|
158
|
+
|
|
159
|
+
Tarve exports native primitives and higher-level controls from the main `tarve` entry point.
|
|
160
|
+
|
|
161
|
+
| Area | Components |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| Window and layout | `Window`, `TitleBar`, `View`, `Row`, `Column`, `Scroll`, `ScrollArea`, `Portal`, `Resizable`, `AspectRatio`, `Direction` |
|
|
164
|
+
| Text and media | `Text`, `Typography`, `Image`, `Svg`, `Icon` |
|
|
165
|
+
| Inputs | `Input`, `TextArea`, `Checkbox`, `Switch`, `RadioGroup`, `Select`, `NativeSelect`, `Slider`, `InputOTP` |
|
|
166
|
+
| Buttons and feedback | `Button`, `ButtonGroup`, `Toggle`, `ToggleGroup`, `Badge`, `Progress`, `Spinner`, `Skeleton`, `Alert` |
|
|
167
|
+
| Overlays | `Modal`/`Dialog`, `AlertDialog`, `Popover`, `Tooltip`, `DropdownMenu`, `ContextMenu`, `Sheet`, `Drawer`, `HoverCard`, `CommandPalette` |
|
|
168
|
+
| Navigation | `Tabs`, `Accordion`, `Breadcrumb`, `Pagination`, `NavigationMenu`, `Menubar`, `Sidebar`, `Collapsible` |
|
|
169
|
+
| Data | `List`, `VirtualList`, `Table`, `DataTable`, `DataGrid`, `TreeView` |
|
|
170
|
+
| Rich content | `Markdown`, `Code`, `Diff` |
|
|
171
|
+
| App/chat UI | `Card`, `Field`, `Item`, `Empty`, `Questionnaire`, `Attachment`, `Message`, `Bubble`, `MessageScroller` |
|
|
172
|
+
|
|
173
|
+
The public API also includes lower-level composition primitives such as `Pressable`, declarative SVG elements, reusable `Style` helpers, component adapters, and desktop APIs exposed through `AppHandle`.
|
|
174
|
+
|
|
175
|
+
## Styling and themes
|
|
176
|
+
|
|
177
|
+
Tarve uses semantic theme tokens. `lightTheme` is the default; `darkTheme` can be selected per window and themes can be changed at runtime without recreating the native window.
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
import { Button, Window, darkTheme, theme } from "@tarve/core";
|
|
181
|
+
|
|
182
|
+
function App() {
|
|
183
|
+
return (
|
|
184
|
+
<Window theme={darkTheme}>
|
|
185
|
+
<Button
|
|
186
|
+
style={{
|
|
187
|
+
background: theme.colors.primary,
|
|
188
|
+
hover: { background: theme.colors.primaryHover },
|
|
189
|
+
focus: { outlineWidth: 2 },
|
|
190
|
+
disabled: { foreground: theme.colors.mutedForeground }
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
Continue
|
|
194
|
+
</Button>
|
|
195
|
+
</Window>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
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.
|
|
201
|
+
|
|
202
|
+
## Native motion
|
|
203
|
+
|
|
204
|
+
Tarve transitions retained native values without a Bun timer or per-frame TSX render. Bun sends the new target once; Rust owns interpolation, layout/paint invalidation, frame scheduling, retargeting, and completion.
|
|
205
|
+
|
|
206
|
+
The first motion surface supports numeric `width`, `height`, `top`, `right`, `bottom`, `left`, `opacity`, and `radius`. Transitions can use `linear`, `ease`, `easeIn`, `easeOut`, or `easeInOut`, with optional duration and delay in milliseconds.
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
<View
|
|
210
|
+
id="details-panel"
|
|
211
|
+
motionFrom={{ opacity: 0, width: 240 }}
|
|
212
|
+
onTransitionEnd={({ property }) => {
|
|
213
|
+
console.log(`${property} finished`);
|
|
214
|
+
}}
|
|
215
|
+
style={{
|
|
216
|
+
width: expanded ? 420 : 280,
|
|
217
|
+
opacity: expanded ? 1 : 0.72,
|
|
218
|
+
radius: 16,
|
|
219
|
+
transition: {
|
|
220
|
+
width: { duration: 220, easing: "easeOut" },
|
|
221
|
+
opacity: { duration: 160, easing: "linear" },
|
|
222
|
+
radius: { duration: 220, easing: "easeOut" },
|
|
223
|
+
},
|
|
224
|
+
}}
|
|
225
|
+
/>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Changing a target while it is already moving retargets from the current interpolated value, so the node does not jump back to its previous declarative target. `motionFrom` is mount-only: it provides the initial numeric value when a native node is first created.
|
|
229
|
+
|
|
230
|
+
Use `AnimatePresence` when a node must stay mounted long enough to finish an exit transition. Keep the presence boundary rendered and toggle `present`; removing the boundary itself cannot retain its child for exit.
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
<AnimatePresence
|
|
234
|
+
id="details-presence"
|
|
235
|
+
present={detailsOpen}
|
|
236
|
+
enter={{ opacity: 0 }}
|
|
237
|
+
exit={{ opacity: 0 }}
|
|
238
|
+
transition={{ opacity: { duration: 180, easing: "easeOut" } }}
|
|
239
|
+
>
|
|
240
|
+
<Card id="details-card" style={{ opacity: 1 }}>
|
|
241
|
+
<Text>Project details</Text>
|
|
242
|
+
</Card>
|
|
243
|
+
</AnimatePresence>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Base numeric style targets participate in native motion. Interactive `hover`, `focus`, `focusVisible`, `active`, and `disabled` overrides are still applied immediately rather than creating state-transition tracks.
|
|
247
|
+
|
|
248
|
+
## Rich content
|
|
249
|
+
|
|
250
|
+
`Markdown`, `Code`, and `Diff` are native leaf nodes, so large documents do not expand into thousands of TSX children.
|
|
251
|
+
|
|
252
|
+
```tsx
|
|
253
|
+
<Column
|
|
254
|
+
highlight={{ query: search, activeIndex: currentMatch }}
|
|
255
|
+
onHighlight={({ matchCount }) => {
|
|
256
|
+
totalMatches = matchCount;
|
|
257
|
+
}}
|
|
258
|
+
>
|
|
259
|
+
<Markdown source={document} />
|
|
260
|
+
<Code
|
|
261
|
+
code={snippet}
|
|
262
|
+
language="tsx"
|
|
263
|
+
showLineNumbers
|
|
264
|
+
/>
|
|
265
|
+
<Diff
|
|
266
|
+
source={patch}
|
|
267
|
+
wordDiff
|
|
268
|
+
maxLines={expanded ? undefined : 80}
|
|
269
|
+
onShowMore={() => {
|
|
270
|
+
expanded = true;
|
|
271
|
+
}}
|
|
272
|
+
/>
|
|
273
|
+
</Column>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
`Markdown` supports GFM structure including tables, task lists, links, quotes, lists, inline code, and fenced code. Embedded HTML is displayed as literal text.
|
|
277
|
+
|
|
278
|
+
`Code` supports syntax highlighting through Syntect, optional `language`/`path` detection, selectable text, line numbers, and horizontal scrolling.
|
|
279
|
+
|
|
280
|
+
`Diff` accepts either a unified/Git patch in `source` or an `oldText`/`newText` pair. It supports word-level changes, per-file sections, collapsible paths, line limits, line-click events, and selection/copy without diff chrome.
|
|
281
|
+
|
|
282
|
+
`createTextSearchController` and `findRanges` provide search/navigation helpers for `Text`, `Markdown`, `Code`, and `Diff`.
|
|
283
|
+
|
|
284
|
+
## Images
|
|
285
|
+
|
|
286
|
+
`Image` accepts local paths, data URLs, encoded PNG/JPEG/WebP/SVG bytes, and raw RGBA8 pixels. Raw RGBA is sent directly to the native image cache, so live pixel updates do not require a PNG encode/decode round trip.
|
|
287
|
+
|
|
288
|
+
```tsx
|
|
289
|
+
<Image
|
|
290
|
+
src={{
|
|
291
|
+
rgba: previewPixels,
|
|
292
|
+
width: 640,
|
|
293
|
+
height: 360,
|
|
294
|
+
cacheKey: "live-preview",
|
|
295
|
+
}}
|
|
296
|
+
width={640}
|
|
297
|
+
height={360}
|
|
298
|
+
fit="contain"
|
|
299
|
+
/>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
HTTP(S) loading is explicit and asynchronous. `loadImageSource` supports `AbortSignal`, payload limits, and a bounded in-process LRU cache:
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
const controller = new AbortController();
|
|
306
|
+
const avatar = await loadImageSource("https://example.com/avatar.webp", {
|
|
307
|
+
signal: controller.signal,
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
render(() => <Image src={avatar} width={96} height={96} fit="cover" />);
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
The native decoded-image cache is bounded and renderer-side image caches retain only images used by the current scene/frame.
|
|
314
|
+
|
|
315
|
+
## Lists and virtualization
|
|
316
|
+
|
|
317
|
+
`List` keeps all items mounted and is appropriate for normal collections.
|
|
318
|
+
|
|
319
|
+
`VirtualList` has three modes:
|
|
320
|
+
|
|
321
|
+
- **Fixed height:** use `itemHeight` for the smallest and simplest runtime path.
|
|
322
|
+
- **Measured variable height:** use `estimatedItemHeight`, a stable `id`, and `keyForItem`. Tarve measures rows natively and preserves a keyed scroll anchor as row heights change or items are prepended/reordered.
|
|
323
|
+
- **Externally windowed:** add `itemCount` and `windowStart` when the application owns a larger logical data set and passes only a mounted window.
|
|
324
|
+
|
|
325
|
+
Fixed-height example:
|
|
326
|
+
|
|
327
|
+
```tsx
|
|
328
|
+
<VirtualList
|
|
329
|
+
items={rows}
|
|
330
|
+
itemHeight={36}
|
|
331
|
+
height={360}
|
|
332
|
+
offset={offset}
|
|
333
|
+
onScroll={(nextOffset) => {
|
|
334
|
+
offset = nextOffset;
|
|
335
|
+
}}
|
|
336
|
+
renderItem={(row) => <Text>{row.label}</Text>}
|
|
337
|
+
/>
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Variable-height example:
|
|
341
|
+
|
|
342
|
+
```tsx
|
|
343
|
+
<VirtualList
|
|
344
|
+
id="messages"
|
|
345
|
+
items={messages}
|
|
346
|
+
estimatedItemHeight={52}
|
|
347
|
+
height={420}
|
|
348
|
+
offset={offset}
|
|
349
|
+
keyForItem={(message) => message.id}
|
|
350
|
+
alignment="bottom"
|
|
351
|
+
followTail
|
|
352
|
+
onScroll={(nextOffset) => {
|
|
353
|
+
offset = nextOffset;
|
|
354
|
+
}}
|
|
355
|
+
renderItem={(message) => (
|
|
356
|
+
<Text>{message.body}</Text>
|
|
357
|
+
)}
|
|
358
|
+
/>
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Variable lists retain measured heights by key and can keep a focused editor row alive while normal windowing moves it outside the visible range.
|
|
362
|
+
|
|
363
|
+
Native text search and copy operate on the mounted logical window. A retained editor row that is parked only to preserve focus is excluded from search, copy, accessibility, and tab order. For an externally windowed data set, search the full logical data set in the application/provider, call `scrollToItem` for the chosen result, and apply the native highlight after that row mounts.
|
|
364
|
+
|
|
365
|
+
## Native input and accessibility
|
|
366
|
+
|
|
367
|
+
`Input` and `TextArea` use native text editing over Parley, including caret placement, selection, clipboard operations, grapheme-aware deletion, IME composition, wrapping, and scrolling. Password input remains masked in rendering and accessibility output.
|
|
368
|
+
|
|
369
|
+
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 }`.
|
|
370
|
+
|
|
371
|
+
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 input and rendering are supported, but the AccessKit accessibility bridge is currently Windows-only.
|
|
372
|
+
|
|
373
|
+
## Desktop APIs
|
|
374
|
+
|
|
375
|
+
`createApp` returns an `AppHandle` with lifecycle and desktop integration methods.
|
|
376
|
+
|
|
377
|
+
```tsx
|
|
378
|
+
const app = createApp(App);
|
|
379
|
+
|
|
380
|
+
const unregisterSave = app.registerHotkey("Ctrl+S", () => {
|
|
381
|
+
saveProject();
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
const file = await app.openFileDialog({
|
|
385
|
+
title: "Open project",
|
|
386
|
+
filters: [{ name: "JSON", extensions: ["json"] }]
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
const files = await app.openFilesDialog();
|
|
390
|
+
const folder = await app.openFolderDialog();
|
|
391
|
+
const target = await app.saveFileDialog({
|
|
392
|
+
fileName: "report.json"
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
unregisterSave();
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Other `AppHandle` APIs include `update`, `close`, `focus`, `scrollToItem`, event listeners, debug inspection, and deterministic screen capture.
|
|
399
|
+
|
|
400
|
+
`Window.onCloseRequest` can cancel a user-initiated close with `event.preventDefault()`. `Window.position` accepts centered/edge/corner presets or explicit logical desktop coordinates.
|
|
401
|
+
|
|
402
|
+
## Automation and visual regression
|
|
403
|
+
|
|
404
|
+
`TestRenderer` exposes the supported automation surface over the same native renderer used by applications. It provides ID/text/role locators, pointer and keyboard actions, `waitFor`, `waitForIdle`, capture, and an optional hidden-window mode for CI runs that still require a real renderer surface.
|
|
405
|
+
|
|
406
|
+
```tsx
|
|
407
|
+
const test = await createTestRenderer(App, {
|
|
408
|
+
renderer: "cpu",
|
|
409
|
+
headless: true,
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
await test.getByRole("button", { name: "Save" }).click();
|
|
413
|
+
await test.getById("project-name").fill("Tarve demo");
|
|
414
|
+
await test.waitFor((snapshot) =>
|
|
415
|
+
snapshot.nodes.some((node) => node.text === "Saved") || false
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
// After an interaction or app update starts a transition:
|
|
419
|
+
await test.advanceMotion(50);
|
|
420
|
+
const midpoint = await test.inspect();
|
|
421
|
+
|
|
422
|
+
await test.capture("dist/saved.png");
|
|
423
|
+
test.close();
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
`advanceMotion(milliseconds)` first flushes any queued declarative update, then advances the native motion clock without sleeping. Once used, that app instance stays on deterministic motion time, which makes intermediate geometry and captures reproducible. `waitForIdle()` also waits for `activeMotions === 0`.
|
|
427
|
+
|
|
428
|
+
Use `launchTestProcess` to isolate CPU/GPU test runs in child processes. `readPngRgba`, `comparePngCaptures`, and `assertPngMatches` are reusable pixel-regression helpers; Tarve's own visual smoke tests use the same public PNG decoder.
|
|
429
|
+
|
|
430
|
+
## Custom title bar
|
|
431
|
+
|
|
432
|
+
Render `TitleBar` inside `Window` to opt into Tarve-managed window chrome:
|
|
433
|
+
|
|
434
|
+
```tsx
|
|
435
|
+
<Window title="My app" width={1000} height={700}>
|
|
436
|
+
<TitleBar title="My app" />
|
|
437
|
+
<View flex={1}>
|
|
438
|
+
{/* application */}
|
|
439
|
+
</View>
|
|
440
|
+
</Window>
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Tarve keeps native dragging, resize hit testing, and minimize/maximize/close behavior on supported platforms. Windows additionally applies Windows 11 corner and maximized/fullscreen border handling.
|
|
444
|
+
|
|
445
|
+
## Icons
|
|
446
|
+
|
|
447
|
+
Tarve includes native `Icon` and SVG primitives. The optional `@tarve/react-icons` package adapts static SVG icon components from libraries such as Lucide, Phosphor, Heroicons, and Tabler without adding React as a core Tarve dependency.
|
|
448
|
+
|
|
449
|
+
```ts
|
|
450
|
+
import {
|
|
451
|
+
lucideReactAdapter,
|
|
452
|
+
phosphorReactAdapter,
|
|
453
|
+
reactSvgAdapter
|
|
454
|
+
} from "@tarve/react-icons";
|
|
455
|
+
|
|
456
|
+
const app = createApp(App, {
|
|
457
|
+
componentAdapters: [
|
|
458
|
+
reactSvgAdapter,
|
|
459
|
+
lucideReactAdapter,
|
|
460
|
+
phosphorReactAdapter
|
|
461
|
+
]
|
|
462
|
+
});
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
## Error handling
|
|
466
|
+
|
|
467
|
+
`createApp` accepts a structured application-level error handler:
|
|
468
|
+
|
|
469
|
+
```tsx
|
|
470
|
+
const app = createApp(App, {
|
|
471
|
+
onError(event) {
|
|
472
|
+
console.error(
|
|
473
|
+
event.source,
|
|
474
|
+
event.event,
|
|
475
|
+
event.targetId,
|
|
476
|
+
event.error
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
Recoverable callback, listener, hotkey, bridge, request, dialog, and update failures are reported through `onError`. A failed native update keeps the last confirmed tree.
|
|
483
|
+
|
|
484
|
+
## Examples
|
|
485
|
+
|
|
486
|
+
The `examples/` directory is an independent Bun consumer project using only public Tarve APIs.
|
|
487
|
+
|
|
488
|
+
```powershell
|
|
489
|
+
bun run setup:examples
|
|
490
|
+
cd examples
|
|
491
|
+
bun run check
|
|
492
|
+
bun run counter
|
|
493
|
+
bun run components
|
|
494
|
+
bun run forms
|
|
495
|
+
bun run intrinsics
|
|
496
|
+
bun run large-list
|
|
497
|
+
bun run rich-content
|
|
498
|
+
bun run diff
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
`setup:examples` builds host-local package staging itself; it does not require the universal publishable tarball.
|
|
502
|
+
|
|
503
|
+
All example UI copy and example documentation is written in English.
|
|
504
|
+
|
|
505
|
+
## Developing Tarve
|
|
506
|
+
|
|
507
|
+
Building the native library requires Bun 1.4+ and Rust stable.
|
|
508
|
+
|
|
509
|
+
On Windows x64, install Visual Studio Build Tools with C++ tooling and the Windows SDK and use the `x86_64-pc-windows-msvc` Rust target.
|
|
510
|
+
|
|
511
|
+
On Debian/Ubuntu Linux x64, install the native build dependencies first:
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
sudo apt install build-essential pkg-config libx11-dev libxkbcommon-dev \
|
|
515
|
+
libxkbcommon-x11-0 libwayland-dev libegl1-mesa-dev libfontconfig1-dev
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
Linux file dialogs use the XDG desktop portal through `rfd`. Opening external links uses `xdg-open` when available and falls back to `gio open`.
|
|
519
|
+
|
|
520
|
+
On WSLg, Tarve prefers winit's X11 backend when `DISPLAY` is available; native Linux keeps winit's normal Wayland/X11 auto-selection. This avoids WSLg-specific Wayland `Broken pipe` event-loop failures without changing backend selection on ordinary Linux desktops.
|
|
521
|
+
|
|
522
|
+
```powershell
|
|
523
|
+
bun install
|
|
524
|
+
bun run build:native
|
|
525
|
+
bun run check
|
|
526
|
+
bun run test
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
`bun run package:local` stages JS, declarations, and the native runtime for the current host for local development. `bun run package` is the publishable universal package gate and requires both Windows x64 and Linux x64 runtimes. The release pipeline documented in `RELEASE.md` assembles both runtimes into the same npm artifact. Tarve does not sign binaries; sign the executables you build with `tarve build` using your own certificate.
|
|
530
|
+
|
|
531
|
+
Run the full package, executable, accessibility, and visual release gate with:
|
|
532
|
+
|
|
533
|
+
```powershell
|
|
534
|
+
bun run verify
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
Additional project documentation:
|
|
538
|
+
|
|
539
|
+
- [Production readiness](PRODUCTION.md)
|
|
540
|
+
- [Performance measurements](PERFORMANCE.md)
|
|
541
|
+
- [Release process](RELEASE.md)
|
|
542
|
+
|
|
543
|
+
## Current scope
|
|
544
|
+
|
|
545
|
+
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. Accessibility integration remains Windows-only for now.
|
|
546
|
+
|
|
547
|
+
## License
|
|
548
|
+
|
|
549
|
+
Tarve is licensed under the [Apache License 2.0](LICENSE).
|
package/RELEASE.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Tarve release policy
|
|
2
|
+
|
|
3
|
+
Tarve currently ships for **Windows x64 and Linux x64**. The release process is intentionally fail-closed: a release tag must match the product version, and the complete verification gate must pass. The npm package stages both native runtimes so `tarve build --target windows-x64|linux-x64` can cross-compile application executables.
|
|
4
|
+
|
|
5
|
+
The npm artifact is universal across those two targets: Linux CI builds `libtarve_native.so`, Windows CI builds `tarve_native.dll`, and packaging only proceeds after both are staged. Each runtime includes compatibility metadata with its target, protocol/ABI versions, source fingerprint, and binary hash. Packaging rejects missing, stale, mismatched, or modified runtimes before publishing.
|
|
6
|
+
|
|
7
|
+
## License and distribution
|
|
8
|
+
|
|
9
|
+
- Tarve is licensed under the **Apache License 2.0**. The canonical license text is in `LICENSE`, and package manifests use the SPDX identifier `Apache-2.0`.
|
|
10
|
+
- `@tarve/core-internal` and `@tarve/protocol` are private workspace packages for repository organization, but inherit the same Apache-2.0 license.
|
|
11
|
+
- The native Rust crate declares `license = "Apache-2.0"` and remains `publish = false`; it is distributed as part of Tarve rather than as an independent crates.io package.
|
|
12
|
+
- The automated release-policy gate rejects license drift between the root package, workspace packages, native crate, and the canonical `LICENSE` file.
|
|
13
|
+
- The release workflow publishes GitHub release artifacts and then publishes the same verified npm tarball to the npm registry (see *npm publishing* below).
|
|
14
|
+
|
|
15
|
+
## Version policy
|
|
16
|
+
|
|
17
|
+
There are three independent version domains:
|
|
18
|
+
|
|
19
|
+
1. **Product SemVer** — one version shared by the root npm package, `@tarve/core-internal`, `@tarve/protocol`, their workspace entries in `bun.lock`, `native/Cargo.toml` and the `tarve_native` entry in `Cargo.lock`.
|
|
20
|
+
2. **JSON protocol version** — a monotonically increasing integer used by serialized TS/Rust messages. It is currently **v45** and is independent from package SemVer.
|
|
21
|
+
3. **Native C ABI version** — a monotonically increasing integer for exported FFI function compatibility. It is currently **v5** and is independent from both product SemVer and the JSON protocol.
|
|
22
|
+
|
|
23
|
+
Use the version tool rather than editing manifests independently:
|
|
24
|
+
|
|
25
|
+
```powershell
|
|
26
|
+
bun run version:check
|
|
27
|
+
bun run version:set -- 0.2.0
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`bun run release:policy` rejects product-version drift, license-policy drift, protocol mismatches and ABI mismatches.
|
|
31
|
+
|
|
32
|
+
## Code signing
|
|
33
|
+
|
|
34
|
+
Tarve is a framework, not an end-user application, so the Tarve release does **not** Authenticode-sign its native runtimes. Signing is the responsibility of each application author: sign the executable produced by `tarve build` with your own certificate (for example `signtool sign /fd SHA256 /tr <timestamp-url> /td SHA256 dist/App.exe`). The published npm tarball is instead protected by npm provenance and by the SHA-256 hashes in `dist/release-manifest.json`.
|
|
35
|
+
|
|
36
|
+
## Release procedure
|
|
37
|
+
|
|
38
|
+
1. Update the product version with `bun run version:set -- <semver>`.
|
|
39
|
+
2. Commit the version change and run `bun run release:check`.
|
|
40
|
+
3. Create an annotated or lightweight tag exactly matching `v<semver>`, for example `v0.2.0`.
|
|
41
|
+
4. Push the commit and tag.
|
|
42
|
+
5. `.github/workflows/release.yml` verifies that the tag points to a commit reachable from the default branch, reruns the full release gate, packs the universal npm tarball, verifies that it contains exactly the staged Windows and Linux runtimes, emits SHA-256 hashes in `dist/release-manifest.json`, uploads the artifacts and creates the GitHub release.
|
|
43
|
+
|
|
44
|
+
Prerelease SemVer tags such as `v0.2.0-beta.1` are published as GitHub prereleases.
|
|
45
|
+
|
|
46
|
+
## npm publishing
|
|
47
|
+
|
|
48
|
+
The `npm-publish` job in `.github/workflows/release.yml` runs only after the Windows release job succeeds. It publishes `@tarve/core` from the exact `dist/tarve-core-<version>.tgz` produced and verified by `release:build` (it never repacks), with npm provenance attestation:
|
|
49
|
+
|
|
50
|
+
- stable versions go to the `latest` dist-tag; prerelease versions (`0.2.0-beta.1`) go to `next`;
|
|
51
|
+
- the job is fail-closed: it refuses to run without the `NPM_TOKEN` secret, verifies the tarball name matches the tag, and skips nothing silently;
|
|
52
|
+
- publishing requires the `npm` GitHub environment, so a required reviewer can gate the registry step.
|
|
53
|
+
|
|
54
|
+
One-time setup:
|
|
55
|
+
|
|
56
|
+
1. The package is published under the `tarve` npm organization (the unscoped name `tarve` is rejected by npm as too similar to `tar`). Owners need 2FA enabled.
|
|
57
|
+
2. Create a granular **automation** access token with read-and-write access to the `@tarve` scope (organization `tarve`) and store it as the `NPM_TOKEN` secret of the `npm` GitHub environment.
|
|
58
|
+
3. Optionally add required reviewers to the `npm` environment.
|
|
59
|
+
|
|
60
|
+
To inspect what would be published locally, stage both native runtimes, then:
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
bun run package
|
|
64
|
+
bun run pack
|
|
65
|
+
npm publish --dry-run (Get-ChildItem dist/tarve-core-*.tgz).FullName
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For a local release rehearsal (both runtimes staged):
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
bun run release:build -- --tag v0.1.0
|
|
72
|
+
```
|