@tarve/core 0.3.0 → 0.5.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 +101 -1
- package/README.md +68 -11
- package/dist/npm/build.js +830 -84
- package/dist/npm/cli.js +1094 -117
- package/dist/npm/embedded-assets.js +35 -4
- package/dist/npm/index.js +2515 -207
- package/dist/npm/native-runtime.json +3 -3
- package/dist/npm/node-build.js +865 -0
- package/dist/npm/protocol.js +1 -1
- package/dist/npm/runtime.js +5 -5
- package/dist/types/core/app-metadata.d.ts +49 -0
- package/dist/types/core/build.d.ts +21 -0
- package/dist/types/core/cli.d.ts +1 -1
- package/dist/types/core/esbuild-file-imports.d.ts +8 -0
- package/dist/types/core/node-build.d.ts +7 -0
- package/dist/types/core/node-dev.d.ts +4 -0
- package/dist/types/core/node-target.d.ts +10 -0
- package/dist/types/core/runtime-select.d.ts +8 -0
- package/dist/types/core/src/app-metadata.d.ts +16 -0
- package/dist/types/core/src/app.d.ts +87 -2
- package/dist/types/core/src/assets.d.ts +4 -0
- package/dist/types/core/src/bridge/binding.d.ts +10 -34
- package/dist/types/core/src/canvas.d.ts +161 -0
- package/dist/types/core/src/components/image.d.ts +7 -3
- package/dist/types/core/src/components/layout.d.ts +4 -3
- package/dist/types/core/src/components/pressable.d.ts +2 -2
- package/dist/types/core/src/embedded-assets.d.ts +12 -2
- package/dist/types/core/src/extra-controls.d.ts +1 -1
- package/dist/types/core/src/html-elements.d.ts +26 -0
- package/dist/types/core/src/index.d.ts +5 -2
- package/dist/types/core/src/inline-text.d.ts +21 -0
- package/dist/types/core/src/jsx-runtime.d.ts +175 -4
- package/dist/types/core/src/media-element.d.ts +71 -0
- package/dist/types/core/src/memo.d.ts +18 -0
- package/dist/types/core/src/png.d.ts +29 -0
- package/dist/types/core/src/popups.d.ts +3 -2
- package/dist/types/core/src/reconciler.d.ts +27 -3
- package/dist/types/core/src/test-renderer.d.ts +2 -0
- package/dist/types/core/src/theme.d.ts +2 -1
- package/dist/types/core/src/virtual-list.d.ts +5 -1
- package/dist/types/core/windows-executable.d.ts +16 -0
- package/dist/types/protocol/src/index.d.ts +206 -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 +11 -2
package/dist/npm/protocol.js
CHANGED
package/dist/npm/runtime.js
CHANGED
|
@@ -70,17 +70,17 @@ function nativePath() {
|
|
|
70
70
|
if (process.env.TARVE_NATIVE)
|
|
71
71
|
return process.env.TARVE_NATIVE;
|
|
72
72
|
for (const directory of [
|
|
73
|
-
resolve(import.meta.
|
|
74
|
-
resolve(import.meta.
|
|
73
|
+
resolve(import.meta.dirname, "../../../../native/bin"),
|
|
74
|
+
resolve(import.meta.dirname, "../../native/bin")
|
|
75
75
|
]) {
|
|
76
76
|
const path = developmentLibrary(directory, target);
|
|
77
77
|
if (path && existsSync(path))
|
|
78
78
|
return path;
|
|
79
79
|
}
|
|
80
80
|
const installed = [
|
|
81
|
-
join(import.meta.
|
|
82
|
-
resolve(import.meta.
|
|
83
|
-
resolve(import.meta.
|
|
81
|
+
join(import.meta.dirname, name),
|
|
82
|
+
resolve(import.meta.dirname, "../../native", config.nativeDirectory, name),
|
|
83
|
+
resolve(import.meta.dirname, "../../../../native", config.nativeDirectory, name)
|
|
84
84
|
];
|
|
85
85
|
const found = installed.find((path) => !!path && existsSync(path));
|
|
86
86
|
if (found)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Tarve app is called and how it looks to the OS: the executable's
|
|
3
|
+
* version resource and icon, the window and taskbar icon, the Windows app
|
|
4
|
+
* identity (media controls, notifications) and the Linux desktop entry.
|
|
5
|
+
*/
|
|
6
|
+
export interface AppMetadata {
|
|
7
|
+
name: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
publisher?: string;
|
|
11
|
+
copyright?: string;
|
|
12
|
+
/** Absolute path to a .png (square, ideally 256 px or more) or .ico. */
|
|
13
|
+
icon?: string;
|
|
14
|
+
/** Windows AppUserModelID / Linux app id, e.g. `Acme.Notes`. */
|
|
15
|
+
appId?: string;
|
|
16
|
+
}
|
|
17
|
+
export type AppMetadataOverrides = Partial<AppMetadata>;
|
|
18
|
+
/** Same rule the Windows shell applies to AppUserModelIDs. */
|
|
19
|
+
export declare function validAppId(id: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Reads the `tarve` field of the package.json nearest the entrypoint
|
|
22
|
+
* (`tarve.apps["<entry path>"]` overrides it for one entrypoint of a
|
|
23
|
+
* multi-app package), then applies `overrides` (CLI flags). Without a
|
|
24
|
+
* `tarve` field the app is named after its entry file, as before.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveAppMetadata(entrypoint: string, overrides?: AppMetadataOverrides): AppMetadata;
|
|
27
|
+
export interface AppIconImages {
|
|
28
|
+
/** Multi-size .ico (16–256 px) for the Windows executable. */
|
|
29
|
+
ico: Uint8Array;
|
|
30
|
+
/** The largest square PNG (at most 256 px), for the window icon and Linux. */
|
|
31
|
+
png: Uint8Array;
|
|
32
|
+
}
|
|
33
|
+
/** Converts an app icon to every form a build needs. An .ico is used as it is. */
|
|
34
|
+
export declare function appIconImages(path: string): AppIconImages;
|
|
35
|
+
export interface BuildMetadata {
|
|
36
|
+
metadata: AppMetadata;
|
|
37
|
+
images?: AppIconImages;
|
|
38
|
+
/** `process.env.TARVE_APP_METADATA` for the bundler's define. */
|
|
39
|
+
define: Record<string, string>;
|
|
40
|
+
}
|
|
41
|
+
/** Metadata, icon images and the runtime define for `tarve build` (Bun and Node alike). */
|
|
42
|
+
export declare function buildMetadata(entrypoint: string, overrides: AppMetadataOverrides): BuildMetadata;
|
|
43
|
+
/** The metadata an app reads at run time (see src/app-metadata.ts), as a JSON string. */
|
|
44
|
+
export declare function runtimeMetadata(metadata: AppMetadata, icon: string | undefined): string;
|
|
45
|
+
/**
|
|
46
|
+
* Linux, when the app has an icon or id: a freedesktop entry and its icon next to the executable. Copy them to
|
|
47
|
+
* ~/.local/share/applications and ~/.local/share/icons/hicolor/256x256/apps to install.
|
|
48
|
+
*/
|
|
49
|
+
export declare function writeLinuxDesktopEntry(outfile: string, metadata: AppMetadata, png: Uint8Array | undefined): string;
|
|
@@ -3,11 +3,32 @@ export { BUILD_TARGETS, hostBuildTarget, isBuildTarget, nativeDirectoryForBuildT
|
|
|
3
3
|
export interface BuildOptions {
|
|
4
4
|
entrypoint: string;
|
|
5
5
|
outfile?: string;
|
|
6
|
+
/** Executable, window and app-identity metadata; each also reads from package.json `tarve`. */
|
|
6
7
|
name?: string;
|
|
7
8
|
version?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
publisher?: string;
|
|
11
|
+
copyright?: string;
|
|
12
|
+
/** .png (square, 256 px or more) or .ico. */
|
|
13
|
+
icon?: string;
|
|
14
|
+
/** Windows AppUserModelID / Linux app id, e.g. `Acme.Notes`. */
|
|
15
|
+
appId?: string;
|
|
8
16
|
target?: BuildTarget;
|
|
9
17
|
/** Override for building the repository against a freshly compiled release library. */
|
|
10
18
|
nativeLibrary?: string;
|
|
19
|
+
runtime?: "bun" | "node";
|
|
20
|
+
/** Node.js binary for the target OS; required for cross-compiling a Node SEA. */
|
|
21
|
+
targetExecutable?: string;
|
|
11
22
|
}
|
|
12
23
|
/** Compile an ordinary Tarve app. No production entrypoint or app-side bridge setup is needed. */
|
|
13
24
|
export declare function build(options: BuildOptions): Promise<string>;
|
|
25
|
+
/** The metadata fields of build options, as overrides of package.json `tarve`. */
|
|
26
|
+
export declare function metadataOverrides(options: BuildOptions): {
|
|
27
|
+
name: string | undefined;
|
|
28
|
+
version: string | undefined;
|
|
29
|
+
description: string | undefined;
|
|
30
|
+
publisher: string | undefined;
|
|
31
|
+
copyright: string | undefined;
|
|
32
|
+
icon: string | undefined;
|
|
33
|
+
appId: string | undefined;
|
|
34
|
+
};
|
package/dist/types/core/cli.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Plugin } from "esbuild";
|
|
2
|
+
/**
|
|
3
|
+
* esbuild rejects Bun's `with { type: "text" }` and `import x from "./a.png" with { type: "file" }`. Route such
|
|
4
|
+
* imports (and plain image imports) through esbuild's file loader, which copies the asset next to the
|
|
5
|
+
* bundle. Like Bun, the import is the asset's absolute path: esbuild's own path is relative to the
|
|
6
|
+
* bundle, which `readFileSync` would resolve against the working directory instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare const fileImportAttributes: Plugin;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type BuildOptions } from "./build";
|
|
2
|
+
export interface NodeBuildOptions extends BuildOptions {
|
|
3
|
+
/** Node.js 26.10+ executable used to build the SEA. Defaults to the installed Node. */
|
|
4
|
+
nodeExecutable?: string;
|
|
5
|
+
}
|
|
6
|
+
/** Bundle a TSX app and its native runtime into a Node.js single executable. */
|
|
7
|
+
export declare function buildNode(options: NodeBuildOptions): Promise<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function devNode(entrypoint: string): Promise<void>;
|
|
2
|
+
/** The Node.js executable for Node apps, also when the CLI itself runs under Bun. */
|
|
3
|
+
export declare function nodeExecutable(): string;
|
|
4
|
+
export declare function runNode(entrypoint: string): Promise<number>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BuildTarget } from "./targets";
|
|
2
|
+
/** Extract one regular file from a tar archive (ustar/pax/GNU long names). */
|
|
3
|
+
export declare function extractTarMember(archive: Buffer, member: string): Buffer;
|
|
4
|
+
/** Throw unless an executable is the Node.js release the SEA blob is built with. */
|
|
5
|
+
export declare function assertNodeVersion(executable: string, version: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Return an official Node.js binary for `target`, downloading it from nodejs.org
|
|
8
|
+
* (or NODEJS_ORG_MIRROR) on first use, verified against the release SHASUMS256.
|
|
9
|
+
*/
|
|
10
|
+
export declare function targetNodeExecutable(target: BuildTarget, version: string): Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type AppRuntime = "bun" | "node";
|
|
2
|
+
/**
|
|
3
|
+
* The runtime a `tarve` command uses: an explicit --runtime, otherwise the one
|
|
4
|
+
* that launched it — Bun itself, or bunx/`bun run` (which may run the CLI with
|
|
5
|
+
* Node because of its shebang but identify themselves in npm_config_user_agent).
|
|
6
|
+
*/
|
|
7
|
+
export declare function selectRuntime(flag: string | undefined, versions?: NodeJS.ProcessVersions, userAgent?: string | undefined): AppRuntime;
|
|
8
|
+
export declare function supportsNodeRuntime(version: string | undefined): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Set by `tarve run`/`tarve dev` (env) or baked into a `tarve build` executable (define). */
|
|
2
|
+
export interface RuntimeAppMetadata {
|
|
3
|
+
name?: string;
|
|
4
|
+
appId?: string;
|
|
5
|
+
/** Path (run/dev) or data URL (built executables) of the app icon. */
|
|
6
|
+
icon?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function runtimeAppMetadata(): RuntimeAppMetadata;
|
|
9
|
+
/** The bytes of an icon given as a path (including embedded `with { type: "file" }` imports) or a data URL. */
|
|
10
|
+
export declare function iconBytes(icon: string): Uint8Array;
|
|
11
|
+
/**
|
|
12
|
+
* An .ico on disk for the Windows shell (app identity shortcut, IconUri): the
|
|
13
|
+
* icon itself when it already is one, else a PNG wrapped as a one-entry .ico in
|
|
14
|
+
* a per-user cache, so it outlives temporary directories.
|
|
15
|
+
*/
|
|
16
|
+
export declare function iconFileForShell(icon: string): string | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { FileDialogOptions, NativeEvent, NativeCommand, Renderer, Snapshot } from "../../protocol/src/index";
|
|
1
|
+
import type { FileDialogOptions, NativeEvent, NativeCommand, NativeSystemMediaSession, Renderer, Snapshot } from "../../protocol/src/index";
|
|
2
|
+
import { type MediaController } from "./media-element";
|
|
2
3
|
import { type NativeBridge } from "./bridge";
|
|
3
4
|
import { type HotkeyHandler } from "./hotkeys";
|
|
4
5
|
import type { VNode } from "./jsx-runtime";
|
|
@@ -24,6 +25,75 @@ export interface AppOptions {
|
|
|
24
25
|
dev?: boolean;
|
|
25
26
|
/** Show the native frame-time graph. Defaults to TARVE_FRAME_OVERLAY=1. Never schedules frames on its own. */
|
|
26
27
|
frameOverlay?: boolean;
|
|
28
|
+
/** Animation frames per second (transitions, `spin`, keyframes); `null` follows the display's refresh rate. Default 60. */
|
|
29
|
+
maxFps?: number | null;
|
|
30
|
+
/**
|
|
31
|
+
* Font files the app ships, like CSS `@font-face`: TTF/OTF/WOFF2 paths (or `import font from "./Inter.ttf" with { type: "file" }`).
|
|
32
|
+
* Each font is then available by its family name in `fontFamily`.
|
|
33
|
+
*/
|
|
34
|
+
fontFaces?: readonly string[];
|
|
35
|
+
/** What the window close button does without an onCloseRequest handler: quit (default) or hide the window, e.g. for tray apps. */
|
|
36
|
+
closeBehavior?: "exit" | "hide";
|
|
37
|
+
/**
|
|
38
|
+
* GPU antialiasing on Windows (D3D11). `0` (default): no multisampling; shape edges
|
|
39
|
+
* get a one-pixel coverage fringe, ~30 MB less memory. `2`, `4` or `8`: MSAA with that
|
|
40
|
+
* many samples, smoother clip edges (rounded `overflow: hidden`, gradients). `TARVE_MSAA` overrides it.
|
|
41
|
+
*/
|
|
42
|
+
msaa?: 0 | 2 | 4 | 8;
|
|
43
|
+
/**
|
|
44
|
+
* Windows: after this many ms without a new frame (default 3000), return the pages only
|
|
45
|
+
* startup touched to the OS, so Task Manager shows what the app really uses. `false` never
|
|
46
|
+
* does. `TARVE_TRIM` (ms, or 0 to disable) overrides it.
|
|
47
|
+
*/
|
|
48
|
+
memoryTrimDelay?: number | false;
|
|
49
|
+
/**
|
|
50
|
+
* Windows app identity (AppUserModelID). Without it, media controls and notifications show
|
|
51
|
+
* the host executable (bun.exe, node.exe) or "Unknown app". `icon` is an .ico/.png path.
|
|
52
|
+
*/
|
|
53
|
+
appIdentity?: {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
icon?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Window and taskbar icon: a .png/.ico/.jpg/.webp path (or `import icon from "./icon.png" with { type: "file" }`)
|
|
60
|
+
* or a data URL. Defaults to the `tarve.icon` of the app's package.json under `tarve run`/`dev`/`build`.
|
|
61
|
+
*/
|
|
62
|
+
icon?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface SystemMediaSession extends NativeSystemMediaSession {
|
|
65
|
+
onAction?: (action: "play" | "pause" | "next" | "previous" | "seek", time?: number) => void;
|
|
66
|
+
}
|
|
67
|
+
export type TrayMenuItem = {
|
|
68
|
+
type: "separator";
|
|
69
|
+
} | {
|
|
70
|
+
type?: "item";
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
checked?: boolean;
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
onSelect?: () => void;
|
|
76
|
+
items?: TrayMenuItem[];
|
|
77
|
+
};
|
|
78
|
+
export interface TrayOptions {
|
|
79
|
+
/** PNG/JPEG/WebP/ICO path or data URL (also `import icon from "./tray.png" with { type: "file" }` in compiled apps). Defaults to the app icon (`createApp({ icon })` or package.json `tarve.icon`), then the system application icon. */
|
|
80
|
+
icon?: string;
|
|
81
|
+
tooltip?: string;
|
|
82
|
+
menu?: TrayMenuItem[];
|
|
83
|
+
onClick?: () => void;
|
|
84
|
+
onDoubleClick?: () => void;
|
|
85
|
+
/** Called with the selected item id, after the item's own onSelect. */
|
|
86
|
+
onMenu?: (id: string) => void;
|
|
87
|
+
}
|
|
88
|
+
export interface TrayHandle {
|
|
89
|
+
/** Merges and re-applies options; the shell icon is modified in place, not recreated. */
|
|
90
|
+
update(options: Partial<TrayOptions>): void;
|
|
91
|
+
remove(): void;
|
|
92
|
+
}
|
|
93
|
+
export interface NotifyOptions {
|
|
94
|
+
title: string;
|
|
95
|
+
body?: string;
|
|
96
|
+
onClick?: () => void;
|
|
27
97
|
}
|
|
28
98
|
export type DiagnosticInput = Extract<NativeCommand, {
|
|
29
99
|
type: "input" | "resize";
|
|
@@ -34,8 +104,21 @@ export interface AppHandle {
|
|
|
34
104
|
update(): void;
|
|
35
105
|
close(): void;
|
|
36
106
|
focus(id: string): void;
|
|
37
|
-
|
|
107
|
+
/** Scrolls a variable VirtualList to an item; `smooth` eases there like CSS `scroll-behavior: smooth`. */
|
|
108
|
+
scrollToItem(id: string, index: number, offset?: number, options?: {
|
|
109
|
+
smooth?: boolean;
|
|
110
|
+
}): void;
|
|
38
111
|
registerHotkey(shortcut: string, handler: HotkeyHandler): () => void;
|
|
112
|
+
show(): void;
|
|
113
|
+
hide(): void;
|
|
114
|
+
minimize(): void;
|
|
115
|
+
/** Shows a system tray icon (Windows). A second call replaces the first tray. */
|
|
116
|
+
tray(options: TrayOptions): TrayHandle;
|
|
117
|
+
systemMedia(session: SystemMediaSession | null): void;
|
|
118
|
+
/** Shows a system notification from the tray icon; requires an active tray. */
|
|
119
|
+
notify(options: NotifyOptions): void;
|
|
120
|
+
/** HTMLMediaElement methods for an `<audio>` element by id. */
|
|
121
|
+
media(id: string): MediaController;
|
|
39
122
|
openFileDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
40
123
|
openFilesDialog(options?: FileDialogOptions): Promise<string[]>;
|
|
41
124
|
openFolderDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
@@ -50,6 +133,8 @@ export interface AppHandle {
|
|
|
50
133
|
remount(view: () => VNode): void;
|
|
51
134
|
/** Toggle the native frame-time overlay. */
|
|
52
135
|
setFrameOverlay(enabled: boolean): void;
|
|
136
|
+
/** Animation frames per second; `null` follows the display's refresh rate. Motion keeps its speed. */
|
|
137
|
+
setMaxFps(fps: number | null): void;
|
|
53
138
|
}
|
|
54
139
|
export declare function createApp(view: () => VNode, options?: AppOptions): AppHandle;
|
|
55
140
|
/**
|
|
@@ -2,3 +2,7 @@ declare module "*.png" { const path: string; export default path; }
|
|
|
2
2
|
declare module "*.jpg" { const path: string; export default path; }
|
|
3
3
|
declare module "*.jpeg" { const path: string; export default path; }
|
|
4
4
|
declare module "*.svg" { const path: string; export default path; }
|
|
5
|
+
declare module "*.webp" { const path: string; export default path; }
|
|
6
|
+
declare module "*.ttf" { const path: string; export default path; }
|
|
7
|
+
declare module "*.otf" { const path: string; export default path; }
|
|
8
|
+
declare module "*.woff2" { const path: string; export default path; }
|
|
@@ -1,34 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
}>;
|
|
1
|
+
type NativeSymbols = Record<"tarve_start" | "tarve_send" | "tarve_event_pipe_name" | "tarve_poll_event" | "tarve_open_external" | "tarve_last_error", (buffer: Uint8Array, length: number) => number> & {
|
|
2
|
+
tarve_abi_version(): number;
|
|
3
|
+
tarve_join(): number;
|
|
4
|
+
};
|
|
5
|
+
type NativeLibrary = {
|
|
6
|
+
symbols: NativeSymbols;
|
|
7
|
+
close(): void;
|
|
8
|
+
};
|
|
9
|
+
export declare function openLibrary(path: string): NativeLibrary;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { VNode } from "./jsx-runtime";
|
|
2
|
+
import { type ImageProps } from "./components/image";
|
|
3
|
+
/**
|
|
4
|
+
* `<canvas onDraw={ctx => …}>`: a CanvasRenderingContext2D recorder. Every render
|
|
5
|
+
* replays `onDraw` into a fresh context; paths, fills, strokes, gradients and
|
|
6
|
+
* transforms become one native SVG scene, and `fillText` becomes positioned
|
|
7
|
+
* native text, so the drawing is vector-sharp at any DPI.
|
|
8
|
+
*/
|
|
9
|
+
type Matrix = [number, number, number, number, number, number];
|
|
10
|
+
interface CanvasState {
|
|
11
|
+
fillStyle: string | CanvasGradient;
|
|
12
|
+
strokeStyle: string | CanvasGradient;
|
|
13
|
+
lineWidth: number;
|
|
14
|
+
lineCap: "butt" | "round" | "square";
|
|
15
|
+
lineJoin: "miter" | "round" | "bevel";
|
|
16
|
+
miterLimit: number;
|
|
17
|
+
globalAlpha: number;
|
|
18
|
+
font: string;
|
|
19
|
+
textAlign: "start" | "end" | "left" | "right" | "center";
|
|
20
|
+
textBaseline: "top" | "hanging" | "middle" | "alphabetic" | "ideographic" | "bottom";
|
|
21
|
+
transform: Matrix;
|
|
22
|
+
lineDash: number[];
|
|
23
|
+
}
|
|
24
|
+
export declare class CanvasGradient {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly kind: "linear" | "radial";
|
|
27
|
+
readonly coords: number[];
|
|
28
|
+
readonly stops: [number, string][];
|
|
29
|
+
constructor(id: string, kind: "linear" | "radial", coords: number[]);
|
|
30
|
+
addColorStop(offset: number, color: string): void;
|
|
31
|
+
}
|
|
32
|
+
export interface CanvasText {
|
|
33
|
+
text: string;
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
matrix: Matrix;
|
|
37
|
+
font: string;
|
|
38
|
+
color: string;
|
|
39
|
+
align: CanvasState["textAlign"];
|
|
40
|
+
baseline: CanvasState["textBaseline"];
|
|
41
|
+
alpha: number;
|
|
42
|
+
stroke: boolean;
|
|
43
|
+
lineWidth: number;
|
|
44
|
+
}
|
|
45
|
+
/** Anything `<img src>` accepts: a path, an imported asset or RGBA pixels. */
|
|
46
|
+
export type CanvasImageSource = ImageProps["src"] | {
|
|
47
|
+
src: ImageProps["src"];
|
|
48
|
+
};
|
|
49
|
+
interface CanvasImage {
|
|
50
|
+
source: ImageProps["src"];
|
|
51
|
+
matrix: Matrix;
|
|
52
|
+
alpha: number;
|
|
53
|
+
dx: number;
|
|
54
|
+
dy: number;
|
|
55
|
+
dw?: number;
|
|
56
|
+
dh?: number;
|
|
57
|
+
crop?: [number, number, number, number];
|
|
58
|
+
}
|
|
59
|
+
/** Paint order: vector layers, text and images interleave; a partial clearRect cuts everything before it. */
|
|
60
|
+
type CanvasOp = {
|
|
61
|
+
svg: string[];
|
|
62
|
+
} | {
|
|
63
|
+
text: CanvasText;
|
|
64
|
+
} | {
|
|
65
|
+
image: CanvasImage;
|
|
66
|
+
} | {
|
|
67
|
+
clear: string;
|
|
68
|
+
};
|
|
69
|
+
export declare class CanvasRenderingContext2D {
|
|
70
|
+
readonly width: number;
|
|
71
|
+
readonly height: number;
|
|
72
|
+
private state;
|
|
73
|
+
private stack;
|
|
74
|
+
private path;
|
|
75
|
+
private start;
|
|
76
|
+
private current;
|
|
77
|
+
/** The open vector layer, in paint order; flushed when text or an image is drawn on top. */
|
|
78
|
+
elements: string[];
|
|
79
|
+
readonly defs: string[];
|
|
80
|
+
readonly texts: CanvasText[];
|
|
81
|
+
readonly ops: CanvasOp[];
|
|
82
|
+
private gradients;
|
|
83
|
+
constructor(width: number, height: number);
|
|
84
|
+
get fillStyle(): string | CanvasGradient;
|
|
85
|
+
set fillStyle(v: string | CanvasGradient);
|
|
86
|
+
get strokeStyle(): string | CanvasGradient;
|
|
87
|
+
set strokeStyle(v: string | CanvasGradient);
|
|
88
|
+
get lineWidth(): number;
|
|
89
|
+
set lineWidth(v: number);
|
|
90
|
+
get lineCap(): "butt" | "round" | "square";
|
|
91
|
+
set lineCap(v: "butt" | "round" | "square");
|
|
92
|
+
get lineJoin(): "bevel" | "miter" | "round";
|
|
93
|
+
set lineJoin(v: "bevel" | "miter" | "round");
|
|
94
|
+
get miterLimit(): number;
|
|
95
|
+
set miterLimit(v: number);
|
|
96
|
+
get globalAlpha(): number;
|
|
97
|
+
set globalAlpha(v: number);
|
|
98
|
+
get font(): string;
|
|
99
|
+
set font(v: string);
|
|
100
|
+
get textAlign(): "center" | "end" | "left" | "right" | "start";
|
|
101
|
+
set textAlign(v: "center" | "end" | "left" | "right" | "start");
|
|
102
|
+
get textBaseline(): "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top";
|
|
103
|
+
set textBaseline(v: "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top");
|
|
104
|
+
setLineDash(segments: number[]): void;
|
|
105
|
+
getLineDash(): number[];
|
|
106
|
+
save(): void;
|
|
107
|
+
restore(): void;
|
|
108
|
+
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
109
|
+
resetTransform(): void;
|
|
110
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
111
|
+
translate(x: number, y: number): void;
|
|
112
|
+
scale(x: number, y: number): void;
|
|
113
|
+
rotate(angle: number): void;
|
|
114
|
+
getTransform(): Matrix;
|
|
115
|
+
private point;
|
|
116
|
+
private scaleFactor;
|
|
117
|
+
beginPath(): void;
|
|
118
|
+
moveTo(x: number, y: number): void;
|
|
119
|
+
lineTo(x: number, y: number): void;
|
|
120
|
+
closePath(): void;
|
|
121
|
+
quadraticCurveTo(cx: number, cy: number, x: number, y: number): void;
|
|
122
|
+
bezierCurveTo(c1x: number, c1y: number, c2x: number, c2y: number, x: number, y: number): void;
|
|
123
|
+
rect(x: number, y: number, w: number, h: number): void;
|
|
124
|
+
roundRect(x: number, y: number, w: number, h: number, radius?: number | number[]): void;
|
|
125
|
+
/** Arc as cubic Béziers in user space, so any transform maps it exactly. */
|
|
126
|
+
ellipse(x: number, y: number, rx: number, ry: number, rotation: number, start: number, end: number, ccw?: boolean): void;
|
|
127
|
+
arc(x: number, y: number, r: number, start: number, end: number, ccw?: boolean): void;
|
|
128
|
+
arcTo(x1: number, y1: number, x2: number, y2: number, r: number): void;
|
|
129
|
+
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
|
|
130
|
+
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
|
|
131
|
+
private paint;
|
|
132
|
+
private emit;
|
|
133
|
+
fill(rule?: "nonzero" | "evenodd"): void;
|
|
134
|
+
stroke(): void;
|
|
135
|
+
private rectPath;
|
|
136
|
+
fillRect(x: number, y: number, w: number, h: number): void;
|
|
137
|
+
strokeRect(x: number, y: number, w: number, h: number): void;
|
|
138
|
+
private flush;
|
|
139
|
+
/** Clears to transparent: the whole canvas drops everything drawn so far; a partial
|
|
140
|
+
* rectangle cuts a hole (in any transform) through all earlier paths, text and images. */
|
|
141
|
+
clearRect(x: number, y: number, w: number, h: number): void;
|
|
142
|
+
private text;
|
|
143
|
+
/** drawImage(image, dx, dy[, dw, dh]) or drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh). */
|
|
144
|
+
drawImage(image: CanvasImageSource, ...args: number[]): void;
|
|
145
|
+
fillText(text: string, x: number, y: number): void;
|
|
146
|
+
strokeText(text: string, x: number, y: number): void;
|
|
147
|
+
/** One vector layer as an SVG document (all paths drawn so far by default). */
|
|
148
|
+
toSvg(elements?: readonly string[]): string;
|
|
149
|
+
/** The paint order, with the open layer closed. */
|
|
150
|
+
layers(): CanvasOp[];
|
|
151
|
+
}
|
|
152
|
+
/** CSS `font` shorthand: [style] [variant] [weight] size[/line-height] family. */
|
|
153
|
+
export declare function parseCanvasFont(font: string): {
|
|
154
|
+
fontStyle?: "italic";
|
|
155
|
+
fontWeight?: number;
|
|
156
|
+
fontSize: number;
|
|
157
|
+
fontFamily: string;
|
|
158
|
+
};
|
|
159
|
+
/** `<canvas width height onDraw>` — HTML's default size is 300×150. */
|
|
160
|
+
export declare function expandCanvas(props: Record<string, any>, key: string): VNode;
|
|
161
|
+
export {};
|
|
@@ -17,11 +17,16 @@ export interface ImageRgbaSource {
|
|
|
17
17
|
}
|
|
18
18
|
export type ImageSource = string | Uint8Array | ImageBytesSource | ImageRgbaSource;
|
|
19
19
|
export interface ImageProps extends BaseProps {
|
|
20
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Local path, `http(s)://` URL, data URL, encoded bytes, or raw RGBA8 pixels.
|
|
22
|
+
* A URL is fetched and decoded natively, off the UI thread, the first time the
|
|
23
|
+
* image is on screen (like `loading="lazy"`); until then it shows its placeholder.
|
|
24
|
+
*/
|
|
21
25
|
src: ImageSource;
|
|
22
26
|
width?: number;
|
|
23
27
|
height?: number;
|
|
24
|
-
|
|
28
|
+
/** CSS `object-fit`. */
|
|
29
|
+
fit?: "cover" | "contain" | "fill";
|
|
25
30
|
}
|
|
26
31
|
export type ImageHttpCacheMode = "default" | "reload" | "no-store";
|
|
27
32
|
export interface LoadImageSourceOptions {
|
|
@@ -35,7 +40,6 @@ export type SerializedImageSource = {
|
|
|
35
40
|
} | {
|
|
36
41
|
image: NativeImageSource;
|
|
37
42
|
};
|
|
38
|
-
/** Protocol normalization shared by Image and intrinsic img reconciliation. */
|
|
39
43
|
export declare function serializeImageSource(source: ImageSource): SerializedImageSource;
|
|
40
44
|
/** Fetch an HTTP(S) image with AbortSignal support and a bounded 64 MiB in-process LRU. */
|
|
41
45
|
export declare function loadImageSource(url: string | URL, options?: LoadImageSourceOptions): Promise<ImageBytesSource>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Style } from "../../../protocol/src/index";
|
|
2
|
-
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
3
|
-
export interface ViewProps extends BaseProps {
|
|
2
|
+
import { type BaseProps, type DropTargetProps, type VNode } from "../jsx-runtime";
|
|
3
|
+
export interface ViewProps extends BaseProps, DropTargetProps {
|
|
4
4
|
gap?: number;
|
|
5
5
|
padding?: Style["padding"];
|
|
6
|
-
flex
|
|
6
|
+
/** CSS `flex`: `1` is `1 1 0`; strings take any CSS value, e.g. `"1 1 176px"`. */
|
|
7
|
+
flex?: number | string;
|
|
7
8
|
align?: Style["align"];
|
|
8
9
|
justify?: Style["justify"];
|
|
9
10
|
portal?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Control } from "../../../protocol/src/index";
|
|
2
|
-
import type { VNode } from "../jsx-runtime";
|
|
2
|
+
import type { DraggableProps, VNode } from "../jsx-runtime";
|
|
3
3
|
import { type ViewProps } from "./layout";
|
|
4
|
-
export interface PressableProps extends ViewProps {
|
|
4
|
+
export interface PressableProps extends ViewProps, DraggableProps {
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
onClick?: () => void;
|
|
7
7
|
onContextMenu?: (position: {
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
/** Native APIs cannot open Bun's virtual files. Resolve them once before sending the scene. */
|
|
2
2
|
export declare function nativeAssetPath(source: string): string;
|
|
3
|
-
/**
|
|
4
|
-
export
|
|
3
|
+
/** SHA-256 and byte size of an embedded asset, computed when the executable is built. */
|
|
4
|
+
export interface AssetDigest {
|
|
5
|
+
sha256: string;
|
|
6
|
+
size: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Give native libraries a physical path for an asset embedded in a Bun executable.
|
|
10
|
+
* With a build-time `digest`, a launch that finds the extracted copy at the
|
|
11
|
+
* expected size reuses it without reading or hashing the embedded bytes; the
|
|
12
|
+
* full hash check runs only when the copy is written.
|
|
13
|
+
*/
|
|
14
|
+
export declare function materializeAsset(source: string, filename: string, digest?: AssetDigest): string;
|
|
@@ -11,7 +11,7 @@ export interface SpinnerProps extends BaseProps {
|
|
|
11
11
|
size?: number;
|
|
12
12
|
label?: string;
|
|
13
13
|
}
|
|
14
|
-
/** A
|
|
14
|
+
/** A loading indicator: an arc that turns once every 800 ms, rotated natively by `style.spin`. */
|
|
15
15
|
export declare function Spinner({ size, label, style, ...props }: SpinnerProps): VNode;
|
|
16
16
|
export interface AvatarProps extends BaseProps {
|
|
17
17
|
src?: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { VNode } from "./jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* HTML elements that are not single native nodes: the remaining `<input>` types,
|
|
4
|
+
* `<form>`, `<fieldset>`, lists, tables and `<details>`. Each expands to Tarve
|
|
5
|
+
* components with the browser's user-agent defaults. Uncontrolled elements keep
|
|
6
|
+
* their state here, keyed by id, the way a browser keeps it in the DOM.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HTML_ELEMENTS: Set<string>;
|
|
9
|
+
export declare const HTML_INPUT_TYPES: Set<string>;
|
|
10
|
+
/** Named values of a form, kept across renders like the DOM keeps field values. */
|
|
11
|
+
export declare function formValues(key: string): Map<string, FormValue>;
|
|
12
|
+
/** An uncontrolled element's value, kept across renders like the DOM keeps it. */
|
|
13
|
+
export declare function storedValue<T>(key: string, initial: T): T;
|
|
14
|
+
export declare function storeValue(key: string, value: unknown): void;
|
|
15
|
+
/** Forgets uncontrolled HTML element state (tests and remounts). */
|
|
16
|
+
export declare function resetHtmlState(): void;
|
|
17
|
+
export type FormValue = string | boolean | string[];
|
|
18
|
+
export interface FormContext {
|
|
19
|
+
values: Map<string, FormValue>;
|
|
20
|
+
required: Set<string>;
|
|
21
|
+
submit(): void;
|
|
22
|
+
}
|
|
23
|
+
/** `<input type="checkbox|radio|range|date|file">`. */
|
|
24
|
+
export declare function expandInput(props: Record<string, any>, key: string, form: FormContext | undefined): VNode;
|
|
25
|
+
/** Lists, tables, fieldsets and details, with Chromium's user-agent spacing. */
|
|
26
|
+
export declare function expandHtml(type: string, props: Record<string, any>, key: string): VNode;
|
|
@@ -3,6 +3,7 @@ export type { WindowProps, WindowCloseRequestEvent, ViewProps, PortalProps, Pres
|
|
|
3
3
|
export { Checkbox, Switch, RadioGroup, Slider, Card, Badge, Separator, Progress, Tabs, Accordion } from "./controls";
|
|
4
4
|
export type { CheckboxProps, SwitchProps, RadioOption, RadioGroupProps, SliderProps, CardProps, BadgeProps, SeparatorProps, ProgressProps, TabItem, TabsProps, AccordionItem, AccordionProps } from "./controls";
|
|
5
5
|
export { VirtualList } from "./virtual-list";
|
|
6
|
+
export { memo, shallowEqual } from "./memo";
|
|
6
7
|
export type { VirtualListProps } from "./virtual-list";
|
|
7
8
|
export { AnimatePresence } from "./motion";
|
|
8
9
|
export type { AnimatePresenceProps } from "./motion";
|
|
@@ -30,7 +31,9 @@ export type { ComponentAdapter, ComponentAdapterInput } from "./component-adapte
|
|
|
30
31
|
export { theme, Theme, lightTheme, darkTheme, createTheme, buttonVariants } from "./theme";
|
|
31
32
|
export type { ThemeColors, ThemeFocusOutline, ThemeDefinition, ThemeOverrides, ButtonVariant } from "./theme";
|
|
32
33
|
export { Style } from "./style";
|
|
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
|
-
export type { VNode, Child, PastePayload } from "./jsx-runtime";
|
|
34
|
+
export type { StateStyle, OutlineStyle, BorderStyle, TextShadow, BoxShadow, Transform, Gradient, GradientStop, GradientSide, GradientLength, GradientCentre, RadialExtent, LinearGradient, RadialGradient, ConicGradient, ConicGradientStop, UserSelect, TextDecoration, Renderer, WindowPosition, WindowPositionPreset, FileDialogFilter, FileDialogOptions, ScrollOrientation, ScrollPosition, MotionProperty, NumericMotionProperty, MotionEasing, MotionTransition, MotionTransitions, MotionValues } from "../../protocol/src/index";
|
|
35
|
+
export type { VNode, Child, PastePayload, DragPosition, DragMoveEvent, DragEndEvent, DropEvent, DraggableProps, DropTargetProps } from "./jsx-runtime";
|
|
35
36
|
export { BunFfiBridge, openExternal } from "./bridge";
|
|
36
37
|
export type { NativeBridge, BunFfiBridgeOptions } from "./bridge";
|
|
38
|
+
export { CanvasRenderingContext2D, CanvasGradient, parseCanvasFont } from "./canvas";
|
|
39
|
+
export type { MediaController, MediaElementProps, MediaEventInfo } from "./media-element";
|