@tarve/core 0.4.0 → 0.6.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 +126 -1
- package/README.md +121 -12
- package/dist/npm/build.js +1401 -85
- package/dist/npm/cli.js +1940 -117
- package/dist/npm/embedded-assets.js +22 -3
- package/dist/npm/index.js +5274 -975
- package/dist/npm/jsx-dev-runtime.js +1268 -0
- package/dist/npm/jsx-runtime.js +1268 -0
- package/dist/npm/native-runtime.json +3 -3
- package/dist/npm/node-build.js +1159 -0
- package/dist/npm/protocol.js +1 -1
- package/dist/npm/runtime.js +5 -5
- package/dist/npm/txiki/fetch.ts +228 -0
- package/dist/npm/txiki/intl-data.ts +7 -0
- package/dist/npm/txiki/intl.test.ts +53 -0
- package/dist/npm/txiki/intl.ts +249 -0
- package/dist/npm/txiki/prelude.ts +132 -0
- package/dist/npm/txiki/runtime.ts +6 -0
- package/dist/npm/txiki/shims/buffer.ts +112 -0
- package/dist/npm/txiki/shims/child-process.ts +151 -0
- package/dist/npm/txiki/shims/crypto.ts +30 -0
- package/dist/npm/txiki/shims/events.ts +75 -0
- package/dist/npm/txiki/shims/fs-promises.ts +77 -0
- package/dist/npm/txiki/shims/fs.ts +231 -0
- package/dist/npm/txiki/shims/module.ts +8 -0
- package/dist/npm/txiki/shims/net.ts +69 -0
- package/dist/npm/txiki/shims/os.ts +72 -0
- package/dist/npm/txiki/shims/path.ts +4 -0
- package/dist/npm/txiki/shims/timers-promises.ts +9 -0
- package/dist/npm/txiki/shims/zlib.ts +9 -0
- package/dist/npm/txiki/tjs.d.ts +58 -0
- package/dist/npm/txiki/unavailable.ts +10 -0
- package/dist/types/core/build.d.ts +24 -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/jsx-compile.d.ts +7 -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/package-metadata.d.ts +49 -0
- package/dist/types/core/runtime-select.d.ts +8 -0
- package/dist/types/core/src/advanced-controls.d.ts +1 -1
- package/dist/types/core/src/app/element-events.d.ts +18 -0
- package/dist/types/core/src/app/media.d.ts +15 -0
- package/dist/types/core/src/app/requests.d.ts +25 -0
- package/dist/types/core/src/app/shadow.d.ts +7 -0
- package/dist/types/core/src/app/stats.d.ts +12 -0
- package/dist/types/core/src/app/tray.d.ts +40 -0
- package/dist/types/core/src/app-metadata.d.ts +18 -0
- package/dist/types/core/src/app.d.ts +89 -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/bridge/index.d.ts +1 -1
- package/dist/types/core/src/canvas.d.ts +161 -0
- package/dist/types/core/src/chat-controls.d.ts +2 -1
- package/dist/types/core/src/components/button.d.ts +1 -1
- package/dist/types/core/src/components/glass.d.ts +52 -0
- package/dist/types/core/src/components/icon.d.ts +1 -1
- package/dist/types/core/src/components/image.d.ts +8 -4
- package/dist/types/core/src/components/layout.d.ts +5 -4
- package/dist/types/core/src/components/pressable.d.ts +3 -3
- package/dist/types/core/src/components/rich-content.d.ts +1 -1
- package/dist/types/core/src/components/scroll.d.ts +2 -2
- package/dist/types/core/src/components/svg.d.ts +1 -1
- package/dist/types/core/src/components/titlebar.d.ts +15 -1
- package/dist/types/core/src/components/window.d.ts +21 -1
- package/dist/types/core/src/components.d.ts +2 -0
- package/dist/types/core/src/css-shadow.d.ts +1 -1
- package/dist/types/core/src/desktop-controls.d.ts +2 -2
- package/dist/types/core/src/embedded-assets.d.ts +3 -2
- package/dist/types/core/src/extra-controls.d.ts +2 -2
- package/dist/types/core/src/form-controls.d.ts +1 -1
- package/dist/types/core/src/html-elements.d.ts +26 -0
- package/dist/types/core/src/index.d.ts +23 -11
- package/dist/types/core/src/inline-text.d.ts +25 -0
- package/dist/types/core/src/intrinsic-style.d.ts +1 -1
- package/dist/types/core/src/jsx-runtime.d.ts +182 -5
- package/dist/types/core/src/media-element.d.ts +70 -0
- package/dist/types/core/src/memo.d.ts +28 -0
- package/dist/types/core/src/motion.d.ts +1 -1
- package/dist/types/core/src/png.d.ts +29 -0
- package/dist/types/core/src/popups.d.ts +4 -3
- package/dist/types/core/src/protocol.d.ts +6 -0
- package/dist/types/core/src/reconciler/diff.d.ts +11 -0
- package/dist/types/core/src/reconciler/intrinsics.d.ts +24 -0
- package/dist/types/core/src/reconciler.d.ts +33 -10
- package/dist/types/core/src/render-scope.d.ts +8 -0
- package/dist/types/core/src/style.d.ts +1 -1
- package/dist/types/core/src/tailwind-palette.d.ts +1 -0
- package/dist/types/core/src/tailwind.d.ts +8 -0
- package/dist/types/core/src/test-renderer.d.ts +3 -1
- package/dist/types/core/src/text-search.d.ts +1 -1
- package/dist/types/core/src/theme.d.ts +10 -2
- package/dist/types/core/src/updates.d.ts +87 -0
- package/dist/types/core/src/virtual-list.d.ts +8 -2
- package/dist/types/core/txiki/fetch.d.ts +1 -0
- package/dist/types/core/txiki/intl-data.d.ts +6 -0
- package/dist/types/core/txiki/intl.d.ts +92 -0
- package/dist/types/core/txiki/prelude.d.ts +1 -0
- package/dist/types/core/txiki/runtime.d.ts +2 -0
- package/dist/types/core/txiki/shims/buffer.d.ts +37 -0
- package/dist/types/core/txiki/shims/child-process.d.ts +46 -0
- package/dist/types/core/txiki/shims/crypto.d.ts +16 -0
- package/dist/types/core/txiki/shims/events.d.ts +21 -0
- package/dist/types/core/txiki/shims/fs-promises.d.ts +41 -0
- package/dist/types/core/txiki/shims/fs.d.ts +44 -0
- package/dist/types/core/txiki/shims/module.d.ts +5 -0
- package/dist/types/core/txiki/shims/net.d.ts +22 -0
- package/dist/types/core/txiki/shims/os.d.ts +52 -0
- package/dist/types/core/txiki/shims/path.d.ts +3 -0
- package/dist/types/core/txiki/shims/timers-promises.d.ts +7 -0
- package/dist/types/core/txiki/shims/zlib.d.ts +11 -0
- package/dist/types/core/txiki/unavailable.d.ts +5 -0
- package/dist/types/core/txiki-build.d.ts +23 -0
- package/dist/types/core/updates-build.d.ts +35 -0
- package/dist/types/core/windows-executable.d.ts +16 -0
- package/dist/types/protocol/src/index.d.ts +344 -11
- 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 +13 -3
|
@@ -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
|
+
/** Stops the TypeScript process a build started; the next compileJsx starts a new one. */
|
|
2
|
+
export declare function closeJsxCompiler(): Promise<void>;
|
|
3
|
+
export interface JsxCompileResult {
|
|
4
|
+
code: string;
|
|
5
|
+
templates: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function compileJsx(source: string): Promise<JsxCompileResult>;
|
|
@@ -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,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;
|
|
@@ -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,18 @@
|
|
|
1
|
+
import type { NativeEvent } from "../protocol";
|
|
2
|
+
import type { Handlers } from "../reconciler";
|
|
3
|
+
/** Runs one user handler, reporting a throw; true when it returned normally. */
|
|
4
|
+
export type InvokeHandler = (event: string, targetId: string | undefined, handler: (...args: never[]) => void, ...args: never[]) => boolean;
|
|
5
|
+
export type ElementEvent = NativeEvent & {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
export interface DispatchResult {
|
|
9
|
+
/** A handler existed for the event. */
|
|
10
|
+
handled: boolean;
|
|
11
|
+
/** Every handler that ran returned normally. */
|
|
12
|
+
succeeded: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Routes a native event addressed to an element id to the handlers its node
|
|
16
|
+
* declared. `handlersOf` resolves other nodes (drop targets).
|
|
17
|
+
*/
|
|
18
|
+
export declare function createElementDispatcher(invoke: InvokeHandler, handlersOf: (id: string) => Handlers | undefined): (event: ElementEvent, handlers: Handlers | undefined) => DispatchResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { NativeCommand } from "../protocol";
|
|
2
|
+
import type { MediaController } from "../media-element";
|
|
3
|
+
import type { CompiledTree } from "../reconciler";
|
|
4
|
+
type MediaCommand = Extract<NativeCommand, {
|
|
5
|
+
type: "media";
|
|
6
|
+
}>;
|
|
7
|
+
/**
|
|
8
|
+
* Keeps native media in step with the elements of each committed render: loads
|
|
9
|
+
* new sources, updates changed flags, unloads elements that went away.
|
|
10
|
+
* `send` receives the command and the error-event name for reporting.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createMediaSync(send: (command: MediaCommand, event: string, targetId: string) => void): (committed: CompiledTree) => void;
|
|
13
|
+
/** HTMLMediaElement methods for the element `id`, each a native media command. */
|
|
14
|
+
export declare function mediaController(id: string, send: (command: MediaCommand) => void): MediaController;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FileDialogOptions, NativeCommand, NativeEvent } from "../protocol";
|
|
2
|
+
export type RequestSource = "request" | "file-dialog";
|
|
3
|
+
export type FileDialogMode = "openFile" | "openFiles" | "openFolder" | "saveFile";
|
|
4
|
+
export interface NativeRequests {
|
|
5
|
+
/** Sends a command and resolves with the native event that answers its `requestId`. `null` timeout waits forever. */
|
|
6
|
+
request(command: NativeCommand & {
|
|
7
|
+
requestId: string;
|
|
8
|
+
}, timeoutMs?: number | null, source?: RequestSource): Promise<NativeEvent>;
|
|
9
|
+
fileDialog(mode: FileDialogMode, options?: FileDialogOptions): Promise<string[]>;
|
|
10
|
+
/** Settles the pending request a native response answers, if any. */
|
|
11
|
+
settle(event: NativeEvent): void;
|
|
12
|
+
/** Rejects every pending request (the window closed or failed to start). */
|
|
13
|
+
rejectAll(error: Error): void;
|
|
14
|
+
}
|
|
15
|
+
export interface NativeRequestsOptions {
|
|
16
|
+
send(command: NativeCommand): void;
|
|
17
|
+
reportError(error: unknown, context: {
|
|
18
|
+
source: RequestSource;
|
|
19
|
+
event: string;
|
|
20
|
+
}): Error;
|
|
21
|
+
/** The error a new request fails with once the app has ended; undefined while it runs. */
|
|
22
|
+
closedError(): Error | undefined;
|
|
23
|
+
}
|
|
24
|
+
export declare function validateFileDialogOptions(options: FileDialogOptions): void;
|
|
25
|
+
export declare function createNativeRequests({ send, reportError, closedError }: NativeRequestsOptions): NativeRequests;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { NativeCommand, NativeNode } from "../protocol";
|
|
2
|
+
import { type CompiledTree } from "../reconciler";
|
|
3
|
+
/** A native edit (typing, a slider drag) changed a node: the shadow now holds that value. */
|
|
4
|
+
export declare function editShadowNode(shadow: CompiledTree, id: string, changes: Pick<NativeNode, "value"> | Pick<NativeNode, "control">): void;
|
|
5
|
+
export declare function nativeShadow(tree: CompiledTree, previous?: CompiledTree): CompiledTree;
|
|
6
|
+
/** The smallest native command that turns `previous` into `next`; undefined when nothing changed. */
|
|
7
|
+
export declare function reconciliationCommand(previous: CompiledTree, next: CompiledTree): NativeCommand | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PhaseSummary } from "../protocol";
|
|
2
|
+
/** A ring of recent durations (ms) with nearest-rank percentiles. */
|
|
3
|
+
export declare class PhaseSamples {
|
|
4
|
+
private readonly values;
|
|
5
|
+
private size;
|
|
6
|
+
private next;
|
|
7
|
+
push(ms: number): void;
|
|
8
|
+
/** Runs `work` and records how long it took. */
|
|
9
|
+
time<T>(work: () => T): T;
|
|
10
|
+
summary(): PhaseSummary;
|
|
11
|
+
reset(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { NativeCommand } from "../protocol";
|
|
2
|
+
export type TrayMenuItem = {
|
|
3
|
+
type: "separator";
|
|
4
|
+
} | {
|
|
5
|
+
type?: "item";
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
onSelect?: () => void;
|
|
11
|
+
items?: TrayMenuItem[];
|
|
12
|
+
};
|
|
13
|
+
export interface TrayOptions {
|
|
14
|
+
/** 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. */
|
|
15
|
+
icon?: string;
|
|
16
|
+
tooltip?: string;
|
|
17
|
+
menu?: TrayMenuItem[];
|
|
18
|
+
onClick?: () => void;
|
|
19
|
+
onDoubleClick?: () => void;
|
|
20
|
+
/** Called with the selected item id, after the item's own onSelect. */
|
|
21
|
+
onMenu?: (id: string) => void;
|
|
22
|
+
}
|
|
23
|
+
export interface TrayHandle {
|
|
24
|
+
/** Merges and re-applies options; the shell icon is modified in place, not recreated. */
|
|
25
|
+
update(options: Partial<TrayOptions>): void;
|
|
26
|
+
remove(): void;
|
|
27
|
+
}
|
|
28
|
+
export interface TrayController {
|
|
29
|
+
/** Shows a system tray icon (Windows). A second call replaces the first tray. */
|
|
30
|
+
tray(initial: TrayOptions): TrayHandle;
|
|
31
|
+
/** Options of the tray currently shown. */
|
|
32
|
+
options(): TrayOptions | undefined;
|
|
33
|
+
/** `onSelect` of the menu item with this id. */
|
|
34
|
+
menuHandler(id: string): (() => void) | undefined;
|
|
35
|
+
}
|
|
36
|
+
type TrayCommand = Extract<NativeCommand, {
|
|
37
|
+
type: "tray";
|
|
38
|
+
}>;
|
|
39
|
+
export declare function createTrayController(appIcon: () => string | undefined, send: (command: TrayCommand) => void): TrayController;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
/** App version (package.json or --version); checkForUpdate compares against it. */
|
|
6
|
+
version?: string;
|
|
7
|
+
/** Path (run/dev) or data URL (built executables) of the app icon. */
|
|
8
|
+
icon?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function runtimeAppMetadata(): RuntimeAppMetadata;
|
|
11
|
+
/** The bytes of an icon given as a path (including embedded `with { type: "file" }` imports) or a data URL. */
|
|
12
|
+
export declare function iconBytes(icon: string): Uint8Array;
|
|
13
|
+
/**
|
|
14
|
+
* An .ico on disk for the Windows shell (app identity shortcut, IconUri): the
|
|
15
|
+
* icon itself when it already is one, else a PNG wrapped as a one-entry .ico in
|
|
16
|
+
* a per-user cache, so it outlives temporary directories.
|
|
17
|
+
*/
|
|
18
|
+
export declare function iconFileForShell(icon: string): string | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { FileDialogOptions, NativeEvent, NativeCommand, Renderer, Snapshot } from "
|
|
1
|
+
import type { FileDialogOptions, NativeEvent, NativeCommand, NativeStats, NativeSystemMediaSession, PhaseSummary, Renderer, Snapshot } from "./protocol";
|
|
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";
|
|
6
|
+
import { type TrayHandle, type TrayOptions } from "./app/tray";
|
|
5
7
|
import type { ComponentAdapter } from "./component-adapter";
|
|
6
8
|
export type AppErrorSource = "render" | "event-handler" | "listener" | "hotkey" | "bridge" | "native" | "request" | "file-dialog";
|
|
7
9
|
export interface AppErrorEvent {
|
|
@@ -24,24 +26,107 @@ export interface AppOptions {
|
|
|
24
26
|
dev?: boolean;
|
|
25
27
|
/** Show the native frame-time graph. Defaults to TARVE_FRAME_OVERLAY=1. Never schedules frames on its own. */
|
|
26
28
|
frameOverlay?: boolean;
|
|
29
|
+
/** Animation frames per second (transitions, `spin`, keyframes); `null` follows the display's refresh rate. Default 60. */
|
|
30
|
+
maxFps?: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* Font files the app ships, like CSS `@font-face`: TTF/OTF/WOFF2 paths (or `import font from "./Inter.ttf" with { type: "file" }`).
|
|
33
|
+
* Each font is then available by its family name in `fontFamily`.
|
|
34
|
+
*/
|
|
35
|
+
fontFaces?: readonly string[];
|
|
36
|
+
/** What the window close button does without an onCloseRequest handler: quit (default) or hide the window, e.g. for tray apps. */
|
|
37
|
+
closeBehavior?: "exit" | "hide";
|
|
38
|
+
/**
|
|
39
|
+
* GPU antialiasing on Windows (D3D11). `0` (default): no multisampling; shape edges
|
|
40
|
+
* get a one-pixel coverage fringe, ~30 MB less memory. `2`, `4` or `8`: MSAA with that
|
|
41
|
+
* many samples, smoother clip edges (rounded `overflow: hidden`, gradients). `TARVE_MSAA` overrides it.
|
|
42
|
+
*/
|
|
43
|
+
msaa?: 0 | 2 | 4 | 8;
|
|
44
|
+
/**
|
|
45
|
+
* Windows: after this many ms without a new frame (default 3000), return the pages only
|
|
46
|
+
* startup touched to the OS, so Task Manager shows what the app really uses. `false` never
|
|
47
|
+
* does. `TARVE_TRIM` (ms, or 0 to disable) overrides it.
|
|
48
|
+
*/
|
|
49
|
+
memoryTrimDelay?: number | false;
|
|
50
|
+
/**
|
|
51
|
+
* Windows app identity (AppUserModelID). Without it, media controls and notifications show
|
|
52
|
+
* the host executable (bun.exe, node.exe) or "Unknown app". `icon` is an .ico/.png path.
|
|
53
|
+
*/
|
|
54
|
+
appIdentity?: {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
icon?: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Window and taskbar icon: a .png/.ico/.jpg/.webp path (or `import icon from "./icon.png" with { type: "file" }`)
|
|
61
|
+
* or a data URL. Defaults to the `tarve.icon` of the app's package.json under `tarve run`/`dev`/`build`.
|
|
62
|
+
*/
|
|
63
|
+
icon?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface SystemMediaSession extends NativeSystemMediaSession {
|
|
66
|
+
onAction?: (action: "play" | "pause" | "next" | "previous" | "seek", time?: number) => void;
|
|
67
|
+
}
|
|
68
|
+
export type { TrayMenuItem, TrayOptions, TrayHandle } from "./app/tray";
|
|
69
|
+
export interface NotifyOptions {
|
|
70
|
+
title: string;
|
|
71
|
+
body?: string;
|
|
72
|
+
onClick?: () => void;
|
|
27
73
|
}
|
|
28
74
|
export type DiagnosticInput = Extract<NativeCommand, {
|
|
29
75
|
type: "input" | "resize";
|
|
30
76
|
}>;
|
|
77
|
+
/** JS update phases, each a summary in milliseconds. */
|
|
78
|
+
export interface AppJsStats {
|
|
79
|
+
/** The view function and compileTree. */
|
|
80
|
+
render: PhaseSummary;
|
|
81
|
+
/** Building the patch against what the native tree holds. */
|
|
82
|
+
diff: PhaseSummary;
|
|
83
|
+
/** Updating the JS mirror of the native tree. */
|
|
84
|
+
shadow: PhaseSummary;
|
|
85
|
+
/** Serializing the patch and handing it to the native thread. */
|
|
86
|
+
send: PhaseSummary;
|
|
87
|
+
/** One whole update, from the queued render to the patch sent. */
|
|
88
|
+
update: PhaseSummary;
|
|
89
|
+
heapUsedMb: number;
|
|
90
|
+
}
|
|
91
|
+
export interface AppStats {
|
|
92
|
+
js: AppJsStats;
|
|
93
|
+
native: NativeStats;
|
|
94
|
+
}
|
|
31
95
|
export interface AppHandle {
|
|
32
96
|
ready: Promise<void>;
|
|
33
97
|
closed: Promise<void>;
|
|
34
98
|
update(): void;
|
|
35
99
|
close(): void;
|
|
36
100
|
focus(id: string): void;
|
|
37
|
-
|
|
101
|
+
/** Scrolls a variable VirtualList to an item; `smooth` eases there like CSS `scroll-behavior: smooth`. */
|
|
102
|
+
scrollToItem(id: string, index: number, offset?: number, options?: {
|
|
103
|
+
smooth?: boolean;
|
|
104
|
+
}): void;
|
|
38
105
|
registerHotkey(shortcut: string, handler: HotkeyHandler): () => void;
|
|
106
|
+
show(): void;
|
|
107
|
+
hide(): void;
|
|
108
|
+
minimize(): void;
|
|
109
|
+
/** Shows a system tray icon (Windows). A second call replaces the first tray. */
|
|
110
|
+
tray(options: TrayOptions): TrayHandle;
|
|
111
|
+
systemMedia(session: SystemMediaSession | null): void;
|
|
112
|
+
/** Shows a system notification from the tray icon; requires an active tray. */
|
|
113
|
+
notify(options: NotifyOptions): void;
|
|
114
|
+
/** HTMLMediaElement methods for an `<audio>` element by id. */
|
|
115
|
+
media(id: string): MediaController;
|
|
39
116
|
openFileDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
40
117
|
openFilesDialog(options?: FileDialogOptions): Promise<string[]>;
|
|
41
118
|
openFolderDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
42
119
|
saveFileDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
43
120
|
onEvent(listener: (event: NativeEvent) => void): () => void;
|
|
44
121
|
inspect(): Promise<Snapshot>;
|
|
122
|
+
/**
|
|
123
|
+
* Where time and memory go: percentiles (ms) of the JS update phases and of the
|
|
124
|
+
* native frame phases over their recent samples, plus process memory after each
|
|
125
|
+
* startup stage. `reset` clears the samples after reading them.
|
|
126
|
+
*/
|
|
127
|
+
stats(options?: {
|
|
128
|
+
reset?: boolean;
|
|
129
|
+
}): Promise<AppStats>;
|
|
45
130
|
capture(path: string): Promise<void>;
|
|
46
131
|
/** Advance the native deterministic motion clock. Requires debug mode. */
|
|
47
132
|
advanceMotion(milliseconds: number): Promise<void>;
|
|
@@ -50,6 +135,8 @@ export interface AppHandle {
|
|
|
50
135
|
remount(view: () => VNode): void;
|
|
51
136
|
/** Toggle the native frame-time overlay. */
|
|
52
137
|
setFrameOverlay(enabled: boolean): void;
|
|
138
|
+
/** Animation frames per second; `null` follows the display's refresh rate. Motion keeps its speed. */
|
|
139
|
+
setMaxFps(fps: number | null): void;
|
|
53
140
|
}
|
|
54
141
|
export declare function createApp(view: () => VNode, options?: AppOptions): AppHandle;
|
|
55
142
|
/**
|
|
@@ -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 {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SceneDocument, type NativeCommand, type NativeEvent } from "
|
|
1
|
+
import { type SceneDocument, type NativeCommand, type NativeEvent } from "../protocol";
|
|
2
2
|
export interface NativeBridge {
|
|
3
3
|
start(document: SceneDocument, onEvent: (event: NativeEvent) => void): void;
|
|
4
4
|
send(command: NativeCommand): void;
|
|
@@ -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 {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ScrollInfo } from "./protocol";
|
|
1
2
|
import { type BaseProps, type Child, type VNode } from "./jsx-runtime";
|
|
2
3
|
export type AttachmentStatus = "ready" | "uploading" | "error";
|
|
3
4
|
export interface AttachmentProps extends BaseProps {
|
|
@@ -35,6 +36,6 @@ export declare function Message({ side, author, avatarSrc, avatarFallback, times
|
|
|
35
36
|
export interface MessageScrollerProps extends BaseProps {
|
|
36
37
|
height?: number;
|
|
37
38
|
gap?: number;
|
|
38
|
-
onScroll?: (offset: number, max: number) => void;
|
|
39
|
+
onScroll?: (offset: number, max: number, info: ScrollInfo) => void;
|
|
39
40
|
}
|
|
40
41
|
export declare function MessageScroller({ height, gap, onScroll, children, style, ...props }: MessageScrollerProps): VNode;
|