@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
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/jsx-runtime.ts
|
|
3
|
+
var NATIVE_VNODE = Symbol("tarve.native-vnode");
|
|
4
|
+
function jsx(type, props, key) {
|
|
5
|
+
return { type, props: props ?? {}, key };
|
|
6
|
+
}
|
|
7
|
+
var jsxs = jsx;
|
|
8
|
+
var jsxDEV = jsx;
|
|
9
|
+
function Fragment(props) {
|
|
10
|
+
return jsx("fragment", props);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
Fragment,
|
|
14
|
+
jsx,
|
|
15
|
+
jsxDEV,
|
|
16
|
+
jsxs
|
|
17
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/jsx-runtime.ts
|
|
3
|
+
var NATIVE_VNODE = Symbol("tarve.native-vnode");
|
|
4
|
+
function jsx(type, props, key) {
|
|
5
|
+
return { type, props: props ?? {}, key };
|
|
6
|
+
}
|
|
7
|
+
function _nativeJsx(type, props, key) {
|
|
8
|
+
const vnode = jsx(type, props, key);
|
|
9
|
+
vnode[NATIVE_VNODE] = true;
|
|
10
|
+
return vnode;
|
|
11
|
+
}
|
|
12
|
+
function _isNativeVNode(vnode) {
|
|
13
|
+
return vnode[NATIVE_VNODE] === true;
|
|
14
|
+
}
|
|
15
|
+
var jsxs = jsx;
|
|
16
|
+
var jsxDEV = jsx;
|
|
17
|
+
function Fragment(props) {
|
|
18
|
+
return jsx("fragment", props);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
Fragment,
|
|
22
|
+
_isNativeVNode,
|
|
23
|
+
_nativeJsx,
|
|
24
|
+
jsx,
|
|
25
|
+
jsxDEV,
|
|
26
|
+
jsxs
|
|
27
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/bridge/runtime.ts
|
|
3
|
+
import { existsSync, readFileSync } from "fs";
|
|
4
|
+
import { basename, extname, join, parse, resolve } from "path";
|
|
5
|
+
|
|
6
|
+
// packages/core/targets.ts
|
|
7
|
+
var BUILD_TARGETS = ["windows-x64", "linux-x64"];
|
|
8
|
+
var TARGET_CONFIGS = {
|
|
9
|
+
"windows-x64": {
|
|
10
|
+
platform: "win32",
|
|
11
|
+
arch: "x64",
|
|
12
|
+
bunTarget: "bun-windows-x64",
|
|
13
|
+
nativeDirectory: "win32-x64",
|
|
14
|
+
nativeName: "tarve_native.dll",
|
|
15
|
+
executableSuffix: ".exe"
|
|
16
|
+
},
|
|
17
|
+
"linux-x64": {
|
|
18
|
+
platform: "linux",
|
|
19
|
+
arch: "x64",
|
|
20
|
+
bunTarget: "bun-linux-x64",
|
|
21
|
+
nativeDirectory: "linux-x64",
|
|
22
|
+
nativeName: "libtarve_native.so",
|
|
23
|
+
executableSuffix: ""
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
function isBuildTarget(value) {
|
|
27
|
+
return BUILD_TARGETS.includes(value);
|
|
28
|
+
}
|
|
29
|
+
function targetConfig(target) {
|
|
30
|
+
return TARGET_CONFIGS[target];
|
|
31
|
+
}
|
|
32
|
+
function hostBuildTarget(platform = process.platform, arch = process.arch) {
|
|
33
|
+
return BUILD_TARGETS.find((target) => {
|
|
34
|
+
const config = TARGET_CONFIGS[target];
|
|
35
|
+
return config.platform === platform && config.arch === arch;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// packages/core/src/bridge/runtime.ts
|
|
40
|
+
function developmentLibrary(directory, target) {
|
|
41
|
+
const manifest = join(directory, "current.json");
|
|
42
|
+
if (!existsSync(manifest))
|
|
43
|
+
return;
|
|
44
|
+
const { library, target: manifestTarget } = JSON.parse(readFileSync(manifest, "utf8"));
|
|
45
|
+
if (typeof library !== "string" || basename(library) !== library)
|
|
46
|
+
throw new Error("Invalid Tarve native build manifest");
|
|
47
|
+
if (manifestTarget !== undefined) {
|
|
48
|
+
if (typeof manifestTarget !== "string" || !isBuildTarget(manifestTarget))
|
|
49
|
+
throw new Error("Invalid Tarve native build manifest");
|
|
50
|
+
if (manifestTarget !== target)
|
|
51
|
+
return;
|
|
52
|
+
} else {
|
|
53
|
+
const expected = targetConfig(target).nativeName;
|
|
54
|
+
const expectedExtension = extname(expected).toLowerCase();
|
|
55
|
+
const expectedStem = parse(expected).name;
|
|
56
|
+
const candidateExtension = extname(library).toLowerCase();
|
|
57
|
+
const candidateStem = parse(library).name;
|
|
58
|
+
if (candidateExtension !== expectedExtension || candidateStem !== expectedStem && !candidateStem.startsWith(`${expectedStem}-`)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return join(directory, library);
|
|
63
|
+
}
|
|
64
|
+
function nativePath() {
|
|
65
|
+
const target = hostBuildTarget();
|
|
66
|
+
if (!target)
|
|
67
|
+
throw new Error(`Unsupported native platform: ${process.platform}-${process.arch}`);
|
|
68
|
+
const config = targetConfig(target);
|
|
69
|
+
const name = config.nativeName;
|
|
70
|
+
if (process.env.TARVE_NATIVE)
|
|
71
|
+
return process.env.TARVE_NATIVE;
|
|
72
|
+
for (const directory of [
|
|
73
|
+
resolve(import.meta.dir, "../../../../native/bin"),
|
|
74
|
+
resolve(import.meta.dir, "../../native/bin")
|
|
75
|
+
]) {
|
|
76
|
+
const path = developmentLibrary(directory, target);
|
|
77
|
+
if (path && existsSync(path))
|
|
78
|
+
return path;
|
|
79
|
+
}
|
|
80
|
+
const installed = [
|
|
81
|
+
join(import.meta.dir, name),
|
|
82
|
+
resolve(import.meta.dir, "../../native", config.nativeDirectory, name),
|
|
83
|
+
resolve(import.meta.dir, "../../../../native", config.nativeDirectory, name)
|
|
84
|
+
];
|
|
85
|
+
const found = installed.find((path) => !!path && existsSync(path));
|
|
86
|
+
if (found)
|
|
87
|
+
return found;
|
|
88
|
+
for (const directory of [resolve("native/bin")]) {
|
|
89
|
+
const path = developmentLibrary(directory, target) ?? join(directory, name);
|
|
90
|
+
if (existsSync(path))
|
|
91
|
+
return path;
|
|
92
|
+
}
|
|
93
|
+
throw new Error(`Tarve native library missing for ${process.platform}-${process.arch}. In the repository, run bun run build:native.`);
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
developmentLibrary,
|
|
97
|
+
nativePath
|
|
98
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BuildTarget } from "./targets";
|
|
2
|
+
export { BUILD_TARGETS, hostBuildTarget, isBuildTarget, nativeDirectoryForBuildTarget, nativeRelativePath, targetConfig, type BuildTarget } from "./targets";
|
|
3
|
+
export interface BuildOptions {
|
|
4
|
+
entrypoint: string;
|
|
5
|
+
outfile?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
target?: BuildTarget;
|
|
9
|
+
/** Override for building the repository against a freshly compiled release library. */
|
|
10
|
+
nativeLibrary?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Compile an ordinary Tarve app. No production entrypoint or app-side bridge setup is needed. */
|
|
13
|
+
export declare function build(options: BuildOptions): Promise<string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type BuildTarget } from "./targets";
|
|
2
|
+
export declare const NATIVE_RUNTIME_MANIFEST_NAME = "runtime.json";
|
|
3
|
+
export declare const NATIVE_COMPATIBILITY_MANIFEST_NAME = "native-runtime.json";
|
|
4
|
+
export interface NativeCompatibilityManifest {
|
|
5
|
+
schemaVersion: 1;
|
|
6
|
+
packageVersion: string;
|
|
7
|
+
protocolVersion: number;
|
|
8
|
+
nativeAbiVersion: number;
|
|
9
|
+
sourceFingerprint: string;
|
|
10
|
+
}
|
|
11
|
+
export interface NativeRuntimeManifest extends NativeCompatibilityManifest {
|
|
12
|
+
target: BuildTarget;
|
|
13
|
+
nativeName: string;
|
|
14
|
+
sha256: string;
|
|
15
|
+
}
|
|
16
|
+
/** Fingerprint every source/config input that can change the native runtime binary. */
|
|
17
|
+
export declare function nativeSourceFingerprint(root: string): Promise<string>;
|
|
18
|
+
export declare function createNativeCompatibilityManifest(root: string, packageVersion: string): Promise<NativeCompatibilityManifest>;
|
|
19
|
+
export declare function readNativeCompatibilityManifest(path: string): Promise<NativeCompatibilityManifest>;
|
|
20
|
+
export declare function writeNativeCompatibilityManifest(path: string, manifest: NativeCompatibilityManifest): Promise<void>;
|
|
21
|
+
export declare function writeNativeRuntimeManifest(library: string, target: BuildTarget, compatibility: NativeCompatibilityManifest): Promise<string>;
|
|
22
|
+
export declare function assertNativeRuntimeCompatible(library: string, target: BuildTarget, expected: NativeCompatibilityManifest): Promise<NativeRuntimeManifest>;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { Style } from "../../protocol/src/index";
|
|
2
|
+
import { type BaseProps, type Child, type VNode } from "./jsx-runtime";
|
|
3
|
+
import { type IconName } from "./components";
|
|
4
|
+
import { type RadioOption } from "./controls";
|
|
5
|
+
import { type SheetSide } from "./extra-controls";
|
|
6
|
+
export interface CarouselItem {
|
|
7
|
+
value: string;
|
|
8
|
+
content: Child;
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface CarouselProps extends BaseProps {
|
|
12
|
+
items: readonly CarouselItem[];
|
|
13
|
+
index: number;
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
showIndicators?: boolean;
|
|
16
|
+
previousLabel?: string;
|
|
17
|
+
nextLabel?: string;
|
|
18
|
+
onIndexChange?: (index: number) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function Carousel({ items, index, loop, showIndicators, previousLabel, nextLabel, onIndexChange, style, id, ...props }: CarouselProps): VNode;
|
|
21
|
+
export interface ChartDatum {
|
|
22
|
+
label: string;
|
|
23
|
+
value: number;
|
|
24
|
+
color?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ChartProps extends BaseProps {
|
|
27
|
+
data: readonly ChartDatum[];
|
|
28
|
+
max?: number;
|
|
29
|
+
height?: number;
|
|
30
|
+
barWidth?: number;
|
|
31
|
+
showValues?: boolean;
|
|
32
|
+
showLabels?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function Chart({ data, max, height, barWidth, showValues, showLabels, style, id, ...props }: ChartProps): VNode;
|
|
35
|
+
export interface DrawerProps extends BaseProps {
|
|
36
|
+
open: boolean;
|
|
37
|
+
side?: SheetSide;
|
|
38
|
+
title?: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
size?: Style["width"];
|
|
41
|
+
showClose?: boolean;
|
|
42
|
+
closeOnOverlay?: boolean;
|
|
43
|
+
closeOnEscape?: boolean;
|
|
44
|
+
onOpenChange?: (open: boolean) => void;
|
|
45
|
+
}
|
|
46
|
+
export declare function Drawer({ side, size, ...props }: DrawerProps): VNode;
|
|
47
|
+
export interface NavigationMenuLink {
|
|
48
|
+
value: string;
|
|
49
|
+
label: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface NavigationMenuItem {
|
|
54
|
+
value: string;
|
|
55
|
+
label: string;
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
links?: readonly NavigationMenuLink[];
|
|
58
|
+
}
|
|
59
|
+
export interface NavigationMenuProps extends BaseProps {
|
|
60
|
+
items: readonly NavigationMenuItem[];
|
|
61
|
+
value?: string;
|
|
62
|
+
openValue?: string;
|
|
63
|
+
onValueChange?: (value: string) => void;
|
|
64
|
+
onOpenValueChange?: (value: string | undefined) => void;
|
|
65
|
+
}
|
|
66
|
+
export declare function NavigationMenu({ items, value, openValue, onValueChange, onOpenValueChange, style, id, ...props }: NavigationMenuProps): VNode;
|
|
67
|
+
export interface ResizableProps extends BaseProps {
|
|
68
|
+
orientation?: "horizontal" | "vertical";
|
|
69
|
+
size: number;
|
|
70
|
+
min?: number;
|
|
71
|
+
max?: number;
|
|
72
|
+
step?: number;
|
|
73
|
+
first: Child;
|
|
74
|
+
second: Child;
|
|
75
|
+
label?: string;
|
|
76
|
+
disabled?: boolean;
|
|
77
|
+
onSizeChange?: (size: number) => void;
|
|
78
|
+
}
|
|
79
|
+
export declare function Resizable({ orientation, size, min, max, step, first, second, label, disabled, onSizeChange, style, id, ...props }: ResizableProps): VNode;
|
|
80
|
+
export interface SidebarItem {
|
|
81
|
+
value: string;
|
|
82
|
+
label: string;
|
|
83
|
+
icon?: IconName;
|
|
84
|
+
disabled?: boolean;
|
|
85
|
+
badge?: Child;
|
|
86
|
+
}
|
|
87
|
+
export interface SidebarProps extends BaseProps {
|
|
88
|
+
items: readonly SidebarItem[];
|
|
89
|
+
value?: string;
|
|
90
|
+
collapsed?: boolean;
|
|
91
|
+
width?: number;
|
|
92
|
+
collapsedWidth?: number;
|
|
93
|
+
header?: Child;
|
|
94
|
+
footer?: Child;
|
|
95
|
+
onValueChange?: (value: string) => void;
|
|
96
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
97
|
+
}
|
|
98
|
+
export declare function Sidebar({ items, value, collapsed, width, collapsedWidth, header, footer, onValueChange, onCollapsedChange, style, id, ...props }: SidebarProps): VNode;
|
|
99
|
+
export type QuestionnaireAnswer = string | string[];
|
|
100
|
+
export interface QuestionnaireQuestion {
|
|
101
|
+
id: string;
|
|
102
|
+
title: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
type: "text" | "single" | "multiple";
|
|
105
|
+
options?: readonly RadioOption[];
|
|
106
|
+
required?: boolean;
|
|
107
|
+
placeholder?: string;
|
|
108
|
+
}
|
|
109
|
+
export interface QuestionnaireProps extends BaseProps {
|
|
110
|
+
questions: readonly QuestionnaireQuestion[];
|
|
111
|
+
values: Readonly<Record<string, QuestionnaireAnswer | undefined>>;
|
|
112
|
+
current: number;
|
|
113
|
+
previousLabel?: string;
|
|
114
|
+
nextLabel?: string;
|
|
115
|
+
submitLabel?: string;
|
|
116
|
+
onCurrentChange?: (index: number) => void;
|
|
117
|
+
onValueChange?: (questionId: string, value: QuestionnaireAnswer) => void;
|
|
118
|
+
onSubmit?: () => void;
|
|
119
|
+
}
|
|
120
|
+
export declare function Questionnaire({ questions, values, current, previousLabel, nextLabel, submitLabel, onCurrentChange, onValueChange, onSubmit, style, id, ...props }: QuestionnaireProps): VNode;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { FileDialogOptions, NativeEvent, NativeCommand, Renderer, Snapshot } from "../../protocol/src/index";
|
|
2
|
+
import { type NativeBridge } from "./bridge";
|
|
3
|
+
import { type HotkeyHandler } from "./hotkeys";
|
|
4
|
+
import type { VNode } from "./jsx-runtime";
|
|
5
|
+
import type { ComponentAdapter } from "./component-adapter";
|
|
6
|
+
export type AppErrorSource = "render" | "event-handler" | "listener" | "hotkey" | "bridge" | "native" | "request" | "file-dialog";
|
|
7
|
+
export interface AppErrorEvent {
|
|
8
|
+
error: Error;
|
|
9
|
+
source: AppErrorSource;
|
|
10
|
+
event?: string;
|
|
11
|
+
targetId?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AppOptions {
|
|
14
|
+
debug?: boolean;
|
|
15
|
+
/** Keep the native window hidden while still creating a real renderer surface. */
|
|
16
|
+
headless?: boolean;
|
|
17
|
+
/** Native renderer selected when the app starts. Explicit cpu/gpu wins over TARVE_RENDERER. */
|
|
18
|
+
renderer?: Renderer;
|
|
19
|
+
/** Optional adapters that translate foreign component types into Tarve VNodes. */
|
|
20
|
+
componentAdapters?: readonly ComponentAdapter[];
|
|
21
|
+
bridge?: NativeBridge;
|
|
22
|
+
onError?: (event: AppErrorEvent) => void;
|
|
23
|
+
/** Development mode: runtime errors render an in-window overlay and render() remounts in the same window. Defaults to TARVE_DEV=1. */
|
|
24
|
+
dev?: boolean;
|
|
25
|
+
/** Show the native frame-time graph. Defaults to TARVE_FRAME_OVERLAY=1. Never schedules frames on its own. */
|
|
26
|
+
frameOverlay?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export type DiagnosticInput = Extract<NativeCommand, {
|
|
29
|
+
type: "input" | "resize";
|
|
30
|
+
}>;
|
|
31
|
+
export interface AppHandle {
|
|
32
|
+
ready: Promise<void>;
|
|
33
|
+
closed: Promise<void>;
|
|
34
|
+
update(): void;
|
|
35
|
+
close(): void;
|
|
36
|
+
focus(id: string): void;
|
|
37
|
+
scrollToItem(id: string, index: number, offset?: number): void;
|
|
38
|
+
registerHotkey(shortcut: string, handler: HotkeyHandler): () => void;
|
|
39
|
+
openFileDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
40
|
+
openFilesDialog(options?: FileDialogOptions): Promise<string[]>;
|
|
41
|
+
openFolderDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
42
|
+
saveFileDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
43
|
+
onEvent(listener: (event: NativeEvent) => void): () => void;
|
|
44
|
+
inspect(): Promise<Snapshot>;
|
|
45
|
+
capture(path: string): Promise<void>;
|
|
46
|
+
/** Advance the native deterministic motion clock. Requires debug mode. */
|
|
47
|
+
advanceMotion(milliseconds: number): Promise<void>;
|
|
48
|
+
debug(command: DiagnosticInput): void;
|
|
49
|
+
/** Replace the view in the same native window, resetting component state. */
|
|
50
|
+
remount(view: () => VNode): void;
|
|
51
|
+
/** Toggle the native frame-time overlay. */
|
|
52
|
+
setFrameOverlay(enabled: boolean): void;
|
|
53
|
+
}
|
|
54
|
+
export declare function createApp(view: () => VNode, options?: AppOptions): AppHandle;
|
|
55
|
+
/**
|
|
56
|
+
* Renders the app until its window closes. In dev mode a second call in the same
|
|
57
|
+
* process (e.g. a `bun --hot` reload) remounts into the already open window.
|
|
58
|
+
*/
|
|
59
|
+
export declare function render(view: () => VNode, options?: AppOptions): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare module "*.png" { const path: string; export default path; }
|
|
2
|
+
declare module "*.jpg" { const path: string; export default path; }
|
|
3
|
+
declare module "*.jpeg" { const path: string; export default path; }
|
|
4
|
+
declare module "*.svg" { const path: string; export default path; }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export declare function openLibrary(path: string): import("bun:ffi").Library<{
|
|
2
|
+
readonly tarve_abi_version: {
|
|
3
|
+
readonly args: readonly [];
|
|
4
|
+
readonly returns: "u32";
|
|
5
|
+
};
|
|
6
|
+
readonly tarve_start: {
|
|
7
|
+
readonly args: readonly ["buffer", "u32"];
|
|
8
|
+
readonly returns: "i32";
|
|
9
|
+
};
|
|
10
|
+
readonly tarve_send: {
|
|
11
|
+
readonly args: readonly ["buffer", "u32"];
|
|
12
|
+
readonly returns: "i32";
|
|
13
|
+
};
|
|
14
|
+
readonly tarve_event_pipe_name: {
|
|
15
|
+
readonly args: readonly ["buffer", "u32"];
|
|
16
|
+
readonly returns: "i32";
|
|
17
|
+
};
|
|
18
|
+
readonly tarve_poll_event: {
|
|
19
|
+
readonly args: readonly ["buffer", "u32"];
|
|
20
|
+
readonly returns: "i32";
|
|
21
|
+
};
|
|
22
|
+
readonly tarve_open_external: {
|
|
23
|
+
readonly args: readonly ["buffer", "u32"];
|
|
24
|
+
readonly returns: "i32";
|
|
25
|
+
};
|
|
26
|
+
readonly tarve_last_error: {
|
|
27
|
+
readonly args: readonly ["buffer", "u32"];
|
|
28
|
+
readonly returns: "i32";
|
|
29
|
+
};
|
|
30
|
+
readonly tarve_join: {
|
|
31
|
+
readonly args: readonly [];
|
|
32
|
+
readonly returns: "i32";
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type SceneDocument, type NativeCommand, type NativeEvent } from "../../../protocol/src/index";
|
|
2
|
+
export interface NativeBridge {
|
|
3
|
+
start(document: SceneDocument, onEvent: (event: NativeEvent) => void): void;
|
|
4
|
+
send(command: NativeCommand): void;
|
|
5
|
+
join(): void;
|
|
6
|
+
}
|
|
7
|
+
export interface BunFfiBridgeOptions {
|
|
8
|
+
libraryPath?: string;
|
|
9
|
+
/** @deprecated Event delivery no longer uses a Bun Worker. */
|
|
10
|
+
workerPath?: string | URL;
|
|
11
|
+
}
|
|
12
|
+
export declare function assertNativeAbiVersion(actual: number): void;
|
|
13
|
+
/** Open an absolute URI with the operating system's registered handler. */
|
|
14
|
+
export declare function openExternal(target: string): void;
|
|
15
|
+
export interface PolledNativeEvent {
|
|
16
|
+
buffer: Uint8Array<ArrayBufferLike>;
|
|
17
|
+
event?: NativeEvent;
|
|
18
|
+
}
|
|
19
|
+
export declare function pollNativeEvent(initialBuffer: Uint8Array<ArrayBufferLike>, poll: (buffer: Uint8Array<ArrayBufferLike>, capacity: number) => number, error: () => Error, decoder?: TextDecoder): PolledNativeEvent;
|
|
20
|
+
export declare function drainNativeEvents(initialBuffer: Uint8Array<ArrayBufferLike>, poll: (buffer: Uint8Array<ArrayBufferLike>, capacity: number) => number, error: () => Error, onEvent: (event: NativeEvent) => void, decoder?: TextDecoder): Uint8Array<ArrayBufferLike>;
|
|
21
|
+
export declare class BunFfiBridge implements NativeBridge {
|
|
22
|
+
private readonly options;
|
|
23
|
+
private library?;
|
|
24
|
+
private eventSocket?;
|
|
25
|
+
private eventBuffer;
|
|
26
|
+
private readonly decoder;
|
|
27
|
+
private closed;
|
|
28
|
+
private eventTransportFailed;
|
|
29
|
+
constructor(options?: BunFfiBridgeOptions);
|
|
30
|
+
private error;
|
|
31
|
+
private drainEventQueue;
|
|
32
|
+
private eventPipeName;
|
|
33
|
+
private closeEventSocket;
|
|
34
|
+
private failEventTransport;
|
|
35
|
+
private connectEventWake;
|
|
36
|
+
private pollEvents;
|
|
37
|
+
private stopAfterEventFailure;
|
|
38
|
+
start(document: SceneDocument, onEvent: (event: NativeEvent) => void): void;
|
|
39
|
+
send(command: NativeCommand): void;
|
|
40
|
+
join(): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type BuildTarget } from "../../targets";
|
|
2
|
+
export declare function developmentLibrary(directory: string, target: BuildTarget): string | undefined;
|
|
3
|
+
/** File resolution for development and npm installs; the app compiler embeds the native library. */
|
|
4
|
+
export declare function nativePath(): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type BaseProps, type Child, type VNode } from "./jsx-runtime";
|
|
2
|
+
export type AttachmentStatus = "ready" | "uploading" | "error";
|
|
3
|
+
export interface AttachmentProps extends BaseProps {
|
|
4
|
+
name: string;
|
|
5
|
+
size?: string;
|
|
6
|
+
status?: AttachmentStatus;
|
|
7
|
+
progress?: number;
|
|
8
|
+
leading?: Child;
|
|
9
|
+
removeLabel?: string;
|
|
10
|
+
onRemove?: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function Attachment({ name, size, status, progress, leading, removeLabel, onRemove, style, id, ...props }: AttachmentProps): VNode;
|
|
13
|
+
export type BubbleSide = "incoming" | "outgoing";
|
|
14
|
+
export type BubbleVariant = "default" | "secondary" | "destructive";
|
|
15
|
+
export interface BubbleProps extends BaseProps {
|
|
16
|
+
side?: BubbleSide;
|
|
17
|
+
variant?: BubbleVariant;
|
|
18
|
+
maxWidth?: number | `${number}%`;
|
|
19
|
+
}
|
|
20
|
+
export declare function Bubble({ side, variant, maxWidth, children, style, ...props }: BubbleProps): VNode;
|
|
21
|
+
export interface MarkerProps extends BaseProps {
|
|
22
|
+
label?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function Marker({ label, children, style, ...props }: MarkerProps): VNode;
|
|
25
|
+
export interface MessageProps extends BaseProps {
|
|
26
|
+
side?: BubbleSide;
|
|
27
|
+
author?: string;
|
|
28
|
+
avatarSrc?: string;
|
|
29
|
+
avatarFallback?: string;
|
|
30
|
+
timestamp?: string;
|
|
31
|
+
actions?: Child;
|
|
32
|
+
bubbleVariant?: BubbleVariant;
|
|
33
|
+
}
|
|
34
|
+
export declare function Message({ side, author, avatarSrc, avatarFallback, timestamp, actions, bubbleVariant, children, style, id, ...props }: MessageProps): VNode;
|
|
35
|
+
export interface MessageScrollerProps extends BaseProps {
|
|
36
|
+
height?: number;
|
|
37
|
+
gap?: number;
|
|
38
|
+
onScroll?: (offset: number, max: number) => void;
|
|
39
|
+
}
|
|
40
|
+
export declare function MessageScroller({ height, gap, onScroll, children, style, ...props }: MessageScrollerProps): VNode;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { VNode } from "./jsx-runtime";
|
|
2
|
+
export interface ComponentAdapterInput {
|
|
3
|
+
type: unknown;
|
|
4
|
+
props: Readonly<Record<string, unknown>>;
|
|
5
|
+
key?: string | number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Converts a foreign component into a Tarve VNode. Returning undefined lets
|
|
9
|
+
* the next adapter (or Tarve's normal component handling) try the node.
|
|
10
|
+
*/
|
|
11
|
+
export type ComponentAdapter = (component: ComponentAdapterInput) => VNode | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Control } from "../../../protocol/src/index";
|
|
2
|
+
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
3
|
+
import { type ButtonVariant } from "../theme";
|
|
4
|
+
export interface ButtonProps extends BaseProps {
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
size?: "sm" | "default" | "lg";
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
control?: Control;
|
|
9
|
+
onClick?: () => void;
|
|
10
|
+
onHover?: (hovered: boolean) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function Button({ variant, size, style, disabled, control, children, ...props }: ButtonProps): VNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
2
|
+
import { type SvgNode } from "./svg";
|
|
3
|
+
export type IconName = "check" | "x" | "plus" | "minus" | "chevron-down" | "chevron-up" | "chevron-right" | "chevron-left" | "search" | "info" | "house" | "settings" | "user" | "bell" | "heart" | "star" | "download" | "trash-2" | "folder" | "mail";
|
|
4
|
+
export interface IconProps extends BaseProps {
|
|
5
|
+
name?: IconName;
|
|
6
|
+
iconNode?: readonly SvgNode[];
|
|
7
|
+
size?: number;
|
|
8
|
+
color?: string;
|
|
9
|
+
strokeWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
declare const icons: Record<IconName, readonly SvgNode[]>;
|
|
12
|
+
export declare function Icon({ name, iconNode, size, color, strokeWidth, style, ...props }: IconProps): VNode;
|
|
13
|
+
export { icons as iconNodes };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { NativeImageSource } from "../../../protocol/src/index";
|
|
2
|
+
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
3
|
+
export interface ImageBytesSource {
|
|
4
|
+
/** Encoded PNG, JPEG, WebP or SVG bytes. */
|
|
5
|
+
bytes: Uint8Array;
|
|
6
|
+
mediaType?: string;
|
|
7
|
+
/** Stable key can reduce GPU cache churn when pixels are updated in place. */
|
|
8
|
+
cacheKey?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ImageRgbaSource {
|
|
11
|
+
/** Raw RGBA8 pixels in row-major order. */
|
|
12
|
+
rgba: Uint8Array;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
premultiplied?: boolean;
|
|
16
|
+
cacheKey?: string;
|
|
17
|
+
}
|
|
18
|
+
export type ImageSource = string | Uint8Array | ImageBytesSource | ImageRgbaSource;
|
|
19
|
+
export interface ImageProps extends BaseProps {
|
|
20
|
+
/** Local path, data URL, encoded bytes, or raw RGBA8 pixels. */
|
|
21
|
+
src: ImageSource;
|
|
22
|
+
width?: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
fit?: "cover" | "contain";
|
|
25
|
+
}
|
|
26
|
+
export type ImageHttpCacheMode = "default" | "reload" | "no-store";
|
|
27
|
+
export interface LoadImageSourceOptions {
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
cache?: ImageHttpCacheMode;
|
|
30
|
+
/** Maximum encoded response size. Defaults to 64 MiB. */
|
|
31
|
+
maxBytes?: number;
|
|
32
|
+
}
|
|
33
|
+
export type SerializedImageSource = {
|
|
34
|
+
path: string;
|
|
35
|
+
} | {
|
|
36
|
+
image: NativeImageSource;
|
|
37
|
+
};
|
|
38
|
+
/** Protocol normalization shared by Image and intrinsic img reconciliation. */
|
|
39
|
+
export declare function serializeImageSource(source: ImageSource): SerializedImageSource;
|
|
40
|
+
/** Fetch an HTTP(S) image with AbortSignal support and a bounded 64 MiB in-process LRU. */
|
|
41
|
+
export declare function loadImageSource(url: string | URL, options?: LoadImageSourceOptions): Promise<ImageBytesSource>;
|
|
42
|
+
export declare function clearImageSourceCache(): void;
|
|
43
|
+
export declare function Image({ width, height, style, ...props }: ImageProps): VNode;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
2
|
+
export type InputType = "text" | "password" | "email" | "number" | "search" | "tel" | "url";
|
|
3
|
+
export interface InputProps extends BaseProps {
|
|
4
|
+
type?: InputType;
|
|
5
|
+
value?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
onChange?: (value: string) => void;
|
|
9
|
+
/** Enter (with or without modifiers) submits the current value. */
|
|
10
|
+
onSubmit?: (value: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function Input({ type, value, style, ...props }: InputProps): VNode;
|
|
13
|
+
export interface TextAreaProps extends BaseProps {
|
|
14
|
+
value?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** When true, Enter submits and Shift+Enter inserts a newline. Ctrl/Cmd+Enter always submits. */
|
|
18
|
+
submitOnEnter?: boolean;
|
|
19
|
+
onChange?: (value: string) => void;
|
|
20
|
+
onSubmit?: (value: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function TextArea({ style, ...props }: TextAreaProps): VNode;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Style } from "../../../protocol/src/index";
|
|
2
|
+
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
3
|
+
export interface ViewProps extends BaseProps {
|
|
4
|
+
gap?: number;
|
|
5
|
+
padding?: Style["padding"];
|
|
6
|
+
flex?: number;
|
|
7
|
+
align?: Style["align"];
|
|
8
|
+
justify?: Style["justify"];
|
|
9
|
+
portal?: boolean;
|
|
10
|
+
dismissOnOutside?: boolean;
|
|
11
|
+
onOutsideClick?: () => void;
|
|
12
|
+
dragRegion?: boolean;
|
|
13
|
+
windowAction?: "minimize" | "toggleMaximize" | "close";
|
|
14
|
+
focusable?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Internal helper shared by the primitive container components. */
|
|
17
|
+
export declare function container(kind: string, props: ViewProps, defaults?: Style): VNode;
|
|
18
|
+
export declare function View(props: ViewProps): VNode;
|
|
19
|
+
export declare function Row(props: ViewProps): VNode;
|
|
20
|
+
export declare function Column(props: ViewProps): VNode;
|
|
21
|
+
export type PortalProps = ViewProps;
|
|
22
|
+
export declare function Portal(props: PortalProps): VNode;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IntrinsicStyle, VNode } from "../jsx-runtime";
|
|
2
|
+
import { type PressableProps } from "./pressable";
|
|
3
|
+
export interface LinkProps extends Omit<PressableProps, "control" | "style"> {
|
|
4
|
+
href: string;
|
|
5
|
+
style?: IntrinsicStyle;
|
|
6
|
+
/** Accessible label override for icon-only or otherwise non-textual links. */
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
/** Native hyperlink primitive. Opens `href` through the platform's registered URI handler. */
|
|
10
|
+
export declare function Link({ href, label, children, style, disabled, onClick, ...props }: LinkProps): VNode;
|