@tarve/core 0.5.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 +46 -0
- package/README.md +54 -2
- package/dist/npm/build.js +714 -138
- package/dist/npm/cli.js +1013 -161
- package/dist/npm/embedded-assets.js +7 -2
- package/dist/npm/index.js +3096 -1084
- 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 +299 -5
- package/dist/npm/protocol.js +1 -1
- 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 +5 -2
- package/dist/types/core/jsx-compile.d.ts +7 -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 +2 -0
- package/dist/types/core/src/app.d.ts +29 -27
- package/dist/types/core/src/bridge/index.d.ts +1 -1
- 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 +1 -1
- package/dist/types/core/src/components/layout.d.ts +1 -1
- package/dist/types/core/src/components/pressable.d.ts +1 -1
- 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 +1 -1
- package/dist/types/core/src/form-controls.d.ts +1 -1
- package/dist/types/core/src/index.d.ts +20 -11
- package/dist/types/core/src/inline-text.d.ts +7 -3
- package/dist/types/core/src/intrinsic-style.d.ts +1 -1
- package/dist/types/core/src/jsx-runtime.d.ts +10 -4
- package/dist/types/core/src/media-element.d.ts +3 -4
- package/dist/types/core/src/memo.d.ts +10 -0
- package/dist/types/core/src/motion.d.ts +1 -1
- package/dist/types/core/src/popups.d.ts +1 -1
- 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 +10 -11
- 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 +1 -1
- package/dist/types/core/src/text-search.d.ts +1 -1
- package/dist/types/core/src/theme.d.ts +8 -1
- package/dist/types/core/src/updates.d.ts +87 -0
- package/dist/types/core/src/virtual-list.d.ts +3 -1
- 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/protocol/src/index.d.ts +159 -8
- 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 +3 -2
- /package/dist/types/core/{app-metadata.d.ts → package-metadata.d.ts} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* node:net createConnection for the native event wake pipe (a Windows named pipe or a
|
|
3
|
+
* Unix socket), over tjs.connect("pipe"). Only the events the bridge listens to exist.
|
|
4
|
+
*/
|
|
5
|
+
type Listener = (...args: any[]) => void;
|
|
6
|
+
|
|
7
|
+
export class Socket {
|
|
8
|
+
destroyed = false;
|
|
9
|
+
private readonly listeners = new Map<string, Listener[]>();
|
|
10
|
+
private connection?: TjsConnection;
|
|
11
|
+
|
|
12
|
+
constructor(path: string) {
|
|
13
|
+
tjs.connect("pipe", path).then(async connection => {
|
|
14
|
+
if (this.destroyed) {
|
|
15
|
+
connection.close();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
this.connection = connection;
|
|
19
|
+
const { readable } = await connection.opened;
|
|
20
|
+
this.emit("connect");
|
|
21
|
+
void this.pump(readable);
|
|
22
|
+
}).catch(error => this.fail(error));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private async pump(readable: ReadableStream<Uint8Array>): Promise<void> {
|
|
26
|
+
const reader = readable.getReader();
|
|
27
|
+
try {
|
|
28
|
+
for (;;) {
|
|
29
|
+
const { done, value } = await reader.read();
|
|
30
|
+
if (this.destroyed) return;
|
|
31
|
+
if (done) break;
|
|
32
|
+
this.emit("data", value);
|
|
33
|
+
}
|
|
34
|
+
this.destroyed = true;
|
|
35
|
+
this.emit("close", false);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
this.fail(error);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private fail(error: unknown): void {
|
|
42
|
+
if (this.destroyed) return;
|
|
43
|
+
this.destroyed = true;
|
|
44
|
+
this.emit("error", error instanceof Error ? error : new Error(String(error)));
|
|
45
|
+
this.emit("close", true);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private emit(event: string, ...args: unknown[]): void {
|
|
49
|
+
for (const listener of this.listeners.get(event) ?? []) listener(...args);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
on(event: string, listener: Listener): this {
|
|
53
|
+
this.listeners.set(event, [...this.listeners.get(event) ?? [], listener]);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
destroy(): this {
|
|
58
|
+
if (this.destroyed) return this;
|
|
59
|
+
this.destroyed = true;
|
|
60
|
+
this.connection?.close();
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function createConnection(path: string): Socket {
|
|
66
|
+
return new Socket(path);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default { Socket, createConnection };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { dlopen } from "tjs:ffi";
|
|
2
|
+
import { readFileSync } from "./fs";
|
|
3
|
+
|
|
4
|
+
declare const TARVE_TXIKI_PLATFORM: "win32" | "linux";
|
|
5
|
+
const windows = TARVE_TXIKI_PLATFORM === "win32";
|
|
6
|
+
|
|
7
|
+
interface TjsSystem {
|
|
8
|
+
cpus: { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number } }[];
|
|
9
|
+
loadAvg: [number, number, number];
|
|
10
|
+
uptime: number;
|
|
11
|
+
networkInterfaces: { name: string; address: string; netmask: string; mac: string; internal: boolean; scopeId?: number }[];
|
|
12
|
+
userInfo: { userName: string; userId: number; groupId: number; shell: string | null; homeDir: string };
|
|
13
|
+
}
|
|
14
|
+
const system = () => (tjs as unknown as { system: TjsSystem }).system;
|
|
15
|
+
|
|
16
|
+
export const EOL = windows ? "\r\n" : "\n";
|
|
17
|
+
export function tmpdir(): string { return tjs.tmpDir; }
|
|
18
|
+
export function homedir(): string { return tjs.homeDir; }
|
|
19
|
+
export function hostname(): string { return (tjs as unknown as { hostName: string }).hostName; }
|
|
20
|
+
export function platform(): string { return TARVE_TXIKI_PLATFORM; }
|
|
21
|
+
export function type(): string { return windows ? "Windows_NT" : "Linux"; }
|
|
22
|
+
export function arch(): string { return "x64"; }
|
|
23
|
+
export function cpus() { return system().cpus; }
|
|
24
|
+
export function availableParallelism(): number { return Math.max(1, system().cpus.length); }
|
|
25
|
+
export function loadavg(): number[] { return [...system().loadAvg]; }
|
|
26
|
+
export function uptime(): number { return system().uptime; }
|
|
27
|
+
export function userInfo() {
|
|
28
|
+
const info = system().userInfo;
|
|
29
|
+
return { username: info.userName, uid: info.userId, gid: info.groupId, shell: info.shell, homedir: info.homeDir };
|
|
30
|
+
}
|
|
31
|
+
export function networkInterfaces() {
|
|
32
|
+
const out: Record<string, object[]> = {};
|
|
33
|
+
for (const { name, ...entry } of system().networkInterfaces) {
|
|
34
|
+
(out[name] ??= []).push({ ...entry, family: entry.address.includes(":") ? "IPv6" : "IPv4", cidr: null });
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let kernel: ReturnType<typeof loadKernel> | undefined;
|
|
40
|
+
function loadKernel() {
|
|
41
|
+
return dlopen("kernel32.dll", { GlobalMemoryStatusEx: { args: ["buffer"], returns: "i32" } }).symbols;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** [total, available] physical memory in bytes. */
|
|
45
|
+
function memory(): [number, number] {
|
|
46
|
+
if (windows) {
|
|
47
|
+
// MEMORYSTATUSEX: dwLength at 0, ullTotalPhys at 8, ullAvailPhys at 16.
|
|
48
|
+
const status = new Uint8Array(64);
|
|
49
|
+
const view = new DataView(status.buffer);
|
|
50
|
+
view.setUint32(0, 64, true);
|
|
51
|
+
(kernel ??= loadKernel()).GlobalMemoryStatusEx(status);
|
|
52
|
+
return [Number(view.getBigUint64(8, true)), Number(view.getBigUint64(16, true))];
|
|
53
|
+
}
|
|
54
|
+
const info = readFileSync("/proc/meminfo", "utf8") as string;
|
|
55
|
+
const kib = (key: string) => Number(new RegExp(`^${key}:\\s+(\\d+)`, "m").exec(info)?.[1] ?? 0) * 1024;
|
|
56
|
+
return [kib("MemTotal"), kib("MemAvailable")];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function totalmem(): number { return memory()[0]; }
|
|
60
|
+
export function freemem(): number { return memory()[1]; }
|
|
61
|
+
|
|
62
|
+
/** Kernel version, e.g. "10.0.26100" on Windows (RtlGetVersion is not shimmed by compatibility modes). */
|
|
63
|
+
export function release(): string {
|
|
64
|
+
if (!windows) return (readFileSync("/proc/sys/kernel/osrelease", "utf8") as string).trim();
|
|
65
|
+
const info = new Uint8Array(276);
|
|
66
|
+
const view = new DataView(info.buffer);
|
|
67
|
+
view.setUint32(0, 276, true);
|
|
68
|
+
dlopen("ntdll.dll", { RtlGetVersion: { args: ["buffer"], returns: "i32" } }).symbols.RtlGetVersion(info);
|
|
69
|
+
return `${view.getUint32(4, true)}.${view.getUint32(8, true)}.${view.getUint32(12, true)}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default { EOL, arch, availableParallelism, cpus, freemem, homedir, hostname, loadavg, networkInterfaces, platform, release, tmpdir, totalmem, type, uptime, userInfo };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function setTimeout<T = void>(milliseconds = 0, value?: T): Promise<T> {
|
|
2
|
+
return new Promise(resolve => globalThis.setTimeout(() => resolve(value as T), milliseconds));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function setImmediate<T = void>(value?: T): Promise<T> {
|
|
6
|
+
return setTimeout(0, value);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default { setImmediate, setTimeout };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function unavailable(name: string): never {
|
|
2
|
+
throw new Error(`zlib.${name} is not available in the Tarve txiki.js runtime`);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export const deflateSync = (_data: Uint8Array): Uint8Array => unavailable("deflateSync");
|
|
6
|
+
export const inflateSync = (_data: Uint8Array): Uint8Array => unavailable("inflateSync");
|
|
7
|
+
export const gzipSync = (_data: Uint8Array): Uint8Array => unavailable("gzipSync");
|
|
8
|
+
export const gunzipSync = (_data: Uint8Array): Uint8Array => unavailable("gunzipSync");
|
|
9
|
+
export default { deflateSync, gunzipSync, gzipSync, inflateSync };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The slice of the txiki.js (tjs) runtime API the Tarve txiki runtime uses.
|
|
2
|
+
// https://txikijs.org/docs/api
|
|
3
|
+
|
|
4
|
+
interface TjsFileHandle {
|
|
5
|
+
read(buffer: Uint8Array, position?: number): Promise<number | null>;
|
|
6
|
+
stat(): Promise<{ size: number }>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** A WinterTC-style socket: streams arrive with `opened`. */
|
|
11
|
+
interface TjsConnection {
|
|
12
|
+
readonly opened: Promise<{ readable: ReadableStream<Uint8Array>; writable: WritableStream<Uint8Array> }>;
|
|
13
|
+
close(): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface TjsGlobal {
|
|
17
|
+
readonly args: string[];
|
|
18
|
+
readonly env: Record<string, string | undefined>;
|
|
19
|
+
readonly exePath: string;
|
|
20
|
+
readonly tmpDir: string;
|
|
21
|
+
readonly homeDir: string;
|
|
22
|
+
readonly version: string;
|
|
23
|
+
readonly engine: { versions: Record<string, string | number> };
|
|
24
|
+
readonly cwd: string;
|
|
25
|
+
chdir(directory: string): void;
|
|
26
|
+
exit(code?: number): never;
|
|
27
|
+
open(path: string, mode: string): Promise<TjsFileHandle>;
|
|
28
|
+
stat(path: string): Promise<{ size: number }>;
|
|
29
|
+
makeDir(path: string, options?: { recursive?: boolean }): Promise<void>;
|
|
30
|
+
writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
31
|
+
rename(from: string, to: string): Promise<void>;
|
|
32
|
+
remove(path: string): Promise<void>;
|
|
33
|
+
connect(transport: "pipe" | "tcp", host: string, port?: number): Promise<TjsConnection>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare var tjs: TjsGlobal;
|
|
37
|
+
|
|
38
|
+
declare module "tjs:ffi" {
|
|
39
|
+
type FfiType = "void" | "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "f32" | "f64" | "ptr" | "buffer" | "string" | "size_t";
|
|
40
|
+
export interface SymbolDefinition { args: readonly FfiType[]; returns: FfiType }
|
|
41
|
+
export function dlopen<T extends Record<string, SymbolDefinition>>(path: string, symbols: T): {
|
|
42
|
+
symbols: { [K in keyof T]: (...args: any[]) => any };
|
|
43
|
+
close(): void;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare module "tjs:hashing" {
|
|
48
|
+
export function createHash(algorithm: string): {
|
|
49
|
+
update(data: Uint8Array): unknown;
|
|
50
|
+
digest(encoding: "hex"): string;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
declare module "tjs:path" {
|
|
55
|
+
import type * as path from "node:path";
|
|
56
|
+
const value: typeof path;
|
|
57
|
+
export default value;
|
|
58
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stands in for a Node API txiki.js lacks. Each call site is a pure call that tree
|
|
3
|
+
* shaking removes when the API is unused; txiki-build rejects a bundle where one is left.
|
|
4
|
+
*/
|
|
5
|
+
export function unavailable(marker: string): any {
|
|
6
|
+
const fail = (): never => {
|
|
7
|
+
throw new Error(`${marker.replace(/^[^:]+:/, "")} is not available in the Tarve txiki.js runtime`);
|
|
8
|
+
};
|
|
9
|
+
return new Proxy(fail, { get: fail, apply: fail, construct: fail });
|
|
10
|
+
}
|
|
@@ -16,8 +16,11 @@ export interface BuildOptions {
|
|
|
16
16
|
target?: BuildTarget;
|
|
17
17
|
/** Override for building the repository against a freshly compiled release library. */
|
|
18
18
|
nativeLibrary?: string;
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
/** "txiki": a txiki.js (QuickJS-ng) executable, no Bun or Node.js at run time. */
|
|
20
|
+
runtime?: "bun" | "node" | "txiki";
|
|
21
|
+
/** Experimental: compile JSX into reusable templates at build time (packages/core/jsx-compile.ts). Bun and txiki.js builds. */
|
|
22
|
+
compileJsx?: boolean;
|
|
23
|
+
/** Runtime binary for the target OS (Node.js or txiki.js); required when cross-compiling a Node SEA or txiki.js app. */
|
|
21
24
|
targetExecutable?: string;
|
|
22
25
|
}
|
|
23
26
|
/** Compile an ordinary Tarve app. No production entrypoint or app-side bridge setup is needed. */
|
|
@@ -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,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 {};
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export interface RuntimeAppMetadata {
|
|
3
3
|
name?: string;
|
|
4
4
|
appId?: string;
|
|
5
|
+
/** App version (package.json or --version); checkForUpdate compares against it. */
|
|
6
|
+
version?: string;
|
|
5
7
|
/** Path (run/dev) or data URL (built executables) of the app icon. */
|
|
6
8
|
icon?: string;
|
|
7
9
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { FileDialogOptions, NativeEvent, NativeCommand, NativeSystemMediaSession, Renderer, Snapshot } from "
|
|
1
|
+
import type { FileDialogOptions, NativeEvent, NativeCommand, NativeStats, NativeSystemMediaSession, PhaseSummary, Renderer, Snapshot } from "./protocol";
|
|
2
2
|
import { type MediaController } from "./media-element";
|
|
3
3
|
import { type NativeBridge } from "./bridge";
|
|
4
4
|
import { type HotkeyHandler } from "./hotkeys";
|
|
5
5
|
import type { VNode } from "./jsx-runtime";
|
|
6
|
+
import { type TrayHandle, type TrayOptions } from "./app/tray";
|
|
6
7
|
import type { ComponentAdapter } from "./component-adapter";
|
|
7
8
|
export type AppErrorSource = "render" | "event-handler" | "listener" | "hotkey" | "bridge" | "native" | "request" | "file-dialog";
|
|
8
9
|
export interface AppErrorEvent {
|
|
@@ -64,32 +65,7 @@ export interface AppOptions {
|
|
|
64
65
|
export interface SystemMediaSession extends NativeSystemMediaSession {
|
|
65
66
|
onAction?: (action: "play" | "pause" | "next" | "previous" | "seek", time?: number) => void;
|
|
66
67
|
}
|
|
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
|
-
}
|
|
68
|
+
export type { TrayMenuItem, TrayOptions, TrayHandle } from "./app/tray";
|
|
93
69
|
export interface NotifyOptions {
|
|
94
70
|
title: string;
|
|
95
71
|
body?: string;
|
|
@@ -98,6 +74,24 @@ export interface NotifyOptions {
|
|
|
98
74
|
export type DiagnosticInput = Extract<NativeCommand, {
|
|
99
75
|
type: "input" | "resize";
|
|
100
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
|
+
}
|
|
101
95
|
export interface AppHandle {
|
|
102
96
|
ready: Promise<void>;
|
|
103
97
|
closed: Promise<void>;
|
|
@@ -125,6 +119,14 @@ export interface AppHandle {
|
|
|
125
119
|
saveFileDialog(options?: FileDialogOptions): Promise<string | undefined>;
|
|
126
120
|
onEvent(listener: (event: NativeEvent) => void): () => void;
|
|
127
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>;
|
|
128
130
|
capture(path: string): Promise<void>;
|
|
129
131
|
/** Advance the native deterministic motion clock. Requires debug mode. */
|
|
130
132
|
advanceMotion(milliseconds: number): Promise<void>;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { GlassMaterial, Style } from "../protocol";
|
|
2
|
+
import type { VNode } from "../jsx-runtime";
|
|
3
|
+
import { type ViewProps } from "./layout";
|
|
4
|
+
export type GlassVariant = "regular" | "clear" | "tinted";
|
|
5
|
+
export interface GlassProps extends ViewProps {
|
|
6
|
+
/**
|
|
7
|
+
* `regular`: frosted, legible over anything (toolbars, tab bars). `clear`: barely
|
|
8
|
+
* tinted, for controls over media. `tinted`: `tint` shows through strongly.
|
|
9
|
+
*/
|
|
10
|
+
variant?: GlassVariant;
|
|
11
|
+
/**
|
|
12
|
+
* Tint colour laid over the variant's veil; the alpha is the strength. `regular` stays
|
|
13
|
+
* frosted under it, `clear` shows it nearly alone. A gradient string passes through as is.
|
|
14
|
+
*/
|
|
15
|
+
tint?: string;
|
|
16
|
+
/** Light or dark appearance of the rim and veil. Default `light`. */
|
|
17
|
+
appearance?: "light" | "dark";
|
|
18
|
+
/** Corner radius. Default 26 (a capsule when the box is 52 px tall). */
|
|
19
|
+
radius?: number;
|
|
20
|
+
/** Overrides of the material: blur, saturate, refraction, highlight. */
|
|
21
|
+
material?: Partial<GlassMaterial>;
|
|
22
|
+
/** Outer shadow under the glass. Default on. */
|
|
23
|
+
shadow?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Glass boxes with the same key fuse like drops of liquid: where two come within
|
|
26
|
+
* `blend` px of each other their shapes bridge smoothly, as one surface. The first
|
|
27
|
+
* box of the key in tree order paints the surface: its tint, material and `blend`
|
|
28
|
+
* are the surface's, the others contribute only their shape (up to 8 per key).
|
|
29
|
+
*/
|
|
30
|
+
merge?: string;
|
|
31
|
+
/** How far apart in px two merged boxes start bridging; read from the first box of the key. Default 32. */
|
|
32
|
+
blend?: number;
|
|
33
|
+
}
|
|
34
|
+
/** `top` composited over `bottom` (source-over); `top` unchanged when either is not a hex colour. */
|
|
35
|
+
export declare function over(top: string, bottom: string): string;
|
|
36
|
+
/** The rim, inner light and drop shadow of iOS 26 glass, for a given radius and appearance. */
|
|
37
|
+
export declare function glassChrome(appearance: "light" | "dark", shadow: boolean): Style;
|
|
38
|
+
/** The complete style of a glass surface: veil, material, radius and chrome. */
|
|
39
|
+
export declare function glassSurface(variant: GlassVariant, appearance: "light" | "dark", options?: {
|
|
40
|
+
tint?: string;
|
|
41
|
+
radius?: number;
|
|
42
|
+
material?: Partial<GlassMaterial>;
|
|
43
|
+
shadow?: boolean;
|
|
44
|
+
merge?: string;
|
|
45
|
+
blend?: number;
|
|
46
|
+
}): Style;
|
|
47
|
+
/**
|
|
48
|
+
* A container made of Liquid Glass: what scrolls behind it shows through blurred,
|
|
49
|
+
* bent at the rounded edge, under a light veil, with a bright rim. Compose like a
|
|
50
|
+
* `View`; controls inside keep their own look.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Glass({ variant, tint, appearance, radius, material, shadow, merge, blend, style, ...props }: GlassProps): VNode;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
2
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";
|
|
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" | "play" | "pause" | "skip-back" | "skip-forward";
|
|
4
4
|
export interface IconProps extends BaseProps {
|
|
5
5
|
name?: IconName;
|
|
6
6
|
iconNode?: readonly SvgNode[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NativeImageSource } from "
|
|
1
|
+
import type { NativeImageSource } from "../protocol";
|
|
2
2
|
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
3
3
|
export interface ImageBytesSource {
|
|
4
4
|
/** Encoded PNG, JPEG, WebP or SVG bytes. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Control } from "
|
|
1
|
+
import type { Control } from "../protocol";
|
|
2
2
|
import type { DraggableProps, VNode } from "../jsx-runtime";
|
|
3
3
|
import { type ViewProps } from "./layout";
|
|
4
4
|
export interface PressableProps extends ViewProps, DraggableProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BaseProps, type VNode } from "../jsx-runtime";
|
|
2
|
-
import type { SyntaxTheme } from "
|
|
2
|
+
import type { SyntaxTheme } from "../protocol";
|
|
3
3
|
interface RichProps extends Omit<BaseProps, "children"> {
|
|
4
4
|
/** Overrides syntax colours without changing parsing or layout. */
|
|
5
5
|
syntaxTheme?: Partial<SyntaxTheme>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { VNode } from "../jsx-runtime";
|
|
2
|
-
import type { ScrollOrientation, ScrollPosition } from "
|
|
2
|
+
import type { ScrollInfo, ScrollOrientation, ScrollPosition } from "../protocol";
|
|
3
3
|
import { type ViewProps } from "./layout";
|
|
4
4
|
export interface ScrollProps extends ViewProps {
|
|
5
5
|
speed?: number;
|
|
6
6
|
orientation?: ScrollOrientation;
|
|
7
|
-
onScroll?: (offset: number, max: number) => void;
|
|
7
|
+
onScroll?: (offset: number, max: number, info: ScrollInfo) => void;
|
|
8
8
|
onScrollPosition?: (position: ScrollPosition) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare function Scroll({ speed, orientation, ...props }: ScrollProps): VNode;
|