@tarve/core 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/LICENSE +201 -0
  2. package/PERFORMANCE.md +82 -0
  3. package/README.md +549 -0
  4. package/RELEASE.md +72 -0
  5. package/dist/npm/build.js +259 -0
  6. package/dist/npm/cli.js +285 -0
  7. package/dist/npm/embedded-assets.js +52 -0
  8. package/dist/npm/index.js +7077 -0
  9. package/dist/npm/jsx-dev-runtime.js +17 -0
  10. package/dist/npm/jsx-runtime.js +27 -0
  11. package/dist/npm/native-runtime.json +7 -0
  12. package/dist/npm/protocol.js +8 -0
  13. package/dist/npm/runtime.js +98 -0
  14. package/dist/types/core/build.d.ts +13 -0
  15. package/dist/types/core/cli.d.ts +2 -0
  16. package/dist/types/core/native-runtime.d.ts +22 -0
  17. package/dist/types/core/src/advanced-controls.d.ts +120 -0
  18. package/dist/types/core/src/app.d.ts +59 -0
  19. package/dist/types/core/src/assets.d.ts +4 -0
  20. package/dist/types/core/src/bridge/binding.d.ts +34 -0
  21. package/dist/types/core/src/bridge/index.d.ts +41 -0
  22. package/dist/types/core/src/bridge/runtime.d.ts +4 -0
  23. package/dist/types/core/src/chat-controls.d.ts +40 -0
  24. package/dist/types/core/src/component-adapter.d.ts +11 -0
  25. package/dist/types/core/src/components/button.d.ts +12 -0
  26. package/dist/types/core/src/components/icon.d.ts +13 -0
  27. package/dist/types/core/src/components/image.d.ts +43 -0
  28. package/dist/types/core/src/components/input.d.ts +22 -0
  29. package/dist/types/core/src/components/layout.d.ts +22 -0
  30. package/dist/types/core/src/components/link.d.ts +10 -0
  31. package/dist/types/core/src/components/modal.d.ts +15 -0
  32. package/dist/types/core/src/components/pressable.d.ts +19 -0
  33. package/dist/types/core/src/components/rich-content.d.ts +45 -0
  34. package/dist/types/core/src/components/scroll.d.ts +12 -0
  35. package/dist/types/core/src/components/svg.d.ts +61 -0
  36. package/dist/types/core/src/components/text.d.ts +9 -0
  37. package/dist/types/core/src/components/titlebar.d.ts +10 -0
  38. package/dist/types/core/src/components/window.d.ts +20 -0
  39. package/dist/types/core/src/components.d.ts +34 -0
  40. package/dist/types/core/src/controls.d.ts +84 -0
  41. package/dist/types/core/src/desktop-controls.d.ts +62 -0
  42. package/dist/types/core/src/dev-overlay.d.ts +9 -0
  43. package/dist/types/core/src/embedded-assets.d.ts +4 -0
  44. package/dist/types/core/src/extra-controls.d.ts +182 -0
  45. package/dist/types/core/src/form-controls.d.ts +118 -0
  46. package/dist/types/core/src/hotkeys.d.ts +3 -0
  47. package/dist/types/core/src/index.d.ts +36 -0
  48. package/dist/types/core/src/intrinsic-style.d.ts +3 -0
  49. package/dist/types/core/src/jsx-dev-runtime.d.ts +2 -0
  50. package/dist/types/core/src/jsx-runtime.d.ts +279 -0
  51. package/dist/types/core/src/list.d.ts +10 -0
  52. package/dist/types/core/src/motion.d.ts +19 -0
  53. package/dist/types/core/src/popups.d.ts +115 -0
  54. package/dist/types/core/src/reconciler.d.ts +54 -0
  55. package/dist/types/core/src/render-scope.d.ts +3 -0
  56. package/dist/types/core/src/select.d.ts +17 -0
  57. package/dist/types/core/src/style.d.ts +7 -0
  58. package/dist/types/core/src/test-renderer.d.ts +84 -0
  59. package/dist/types/core/src/text-search.d.ts +37 -0
  60. package/dist/types/core/src/theme.d.ts +91 -0
  61. package/dist/types/core/src/virtual-list.d.ts +31 -0
  62. package/dist/types/core/src/visual-testing.d.ts +24 -0
  63. package/dist/types/core/targets.d.ts +16 -0
  64. package/dist/types/protocol/src/index.d.ts +534 -0
  65. package/native/linux-x64/libtarve_native.so +0 -0
  66. package/native/linux-x64/runtime.json +10 -0
  67. package/native/win32-x64/runtime.json +10 -0
  68. package/native/win32-x64/tarve_native.dll +0 -0
  69. package/package.json +131 -0
@@ -0,0 +1,84 @@
1
+ import type { Control, NodeSnapshot, Renderer, Snapshot } from "../../protocol/src/index";
2
+ import { type AppHandle, type AppOptions } from "./app";
3
+ import type { VNode } from "./jsx-runtime";
4
+ export interface WaitForOptions {
5
+ timeout?: number;
6
+ interval?: number;
7
+ }
8
+ export interface TextLocatorOptions {
9
+ exact?: boolean;
10
+ }
11
+ export interface RoleLocatorOptions extends TextLocatorOptions {
12
+ name?: string | RegExp;
13
+ }
14
+ export interface Point {
15
+ x: number;
16
+ y: number;
17
+ }
18
+ export interface WheelOptions {
19
+ delta?: number;
20
+ deltaX?: number;
21
+ deltaY?: number;
22
+ }
23
+ export interface TestRendererOptions extends Omit<AppOptions, "debug"> {
24
+ /** Automation always enables diagnostic input. Hidden mode still uses a real native renderer. */
25
+ headless?: boolean;
26
+ }
27
+ export interface TestProcessOptions {
28
+ command: readonly string[];
29
+ cwd?: string;
30
+ env?: Record<string, string | undefined>;
31
+ /** Force a renderer backend in the child process. */
32
+ renderer?: Exclude<Renderer, "auto">;
33
+ stdout?: "inherit" | "pipe";
34
+ stderr?: "inherit" | "pipe";
35
+ }
36
+ export interface TestProcess {
37
+ pid: number;
38
+ exited: Promise<number>;
39
+ stdout?: ReadableStream<Uint8Array>;
40
+ stderr?: ReadableStream<Uint8Array>;
41
+ kill(signal?: number | NodeJS.Signals): void;
42
+ }
43
+ type SnapshotQuery = (snapshot: Snapshot) => NodeSnapshot[];
44
+ /** Poll an async condition until it returns a truthy value. */
45
+ export declare function waitFor<T>(predicate: () => T | false | null | undefined | Promise<T | false | null | undefined>, options?: WaitForOptions): Promise<T>;
46
+ export declare class Locator {
47
+ private readonly renderer;
48
+ private readonly query;
49
+ readonly description: string;
50
+ constructor(renderer: TestRenderer, query: SnapshotQuery, description: string);
51
+ all(): Promise<NodeSnapshot[]>;
52
+ count(): Promise<number>;
53
+ node(): Promise<NodeSnapshot>;
54
+ waitFor(options?: WaitForOptions): Promise<NodeSnapshot>;
55
+ click(): Promise<void>;
56
+ fill(value: string): Promise<void>;
57
+ press(key: string): Promise<void>;
58
+ wheel(options: number | WheelOptions): Promise<void>;
59
+ dragTo(target: Locator | Point): Promise<void>;
60
+ }
61
+ /** Public automation facade backed by Tarve's real inspect/capture/input protocol. */
62
+ export declare class TestRenderer {
63
+ readonly app: AppHandle;
64
+ constructor(app: AppHandle);
65
+ static create(view: () => VNode, options?: TestRendererOptions): Promise<TestRenderer>;
66
+ inspect(): Promise<Snapshot>;
67
+ capture(path: string): Promise<void>;
68
+ /** Advance the deterministic native motion clock without sleeping. */
69
+ advanceMotion(milliseconds: number): Promise<void>;
70
+ close(): void;
71
+ getById(id: string): Locator;
72
+ getByText(text: string | RegExp, options?: TextLocatorOptions): Locator;
73
+ getByRole(role: Control["role"], options?: RoleLocatorOptions): Locator;
74
+ locator(predicate: (node: NodeSnapshot) => boolean, description?: string): Locator;
75
+ waitFor<T>(predicate: (snapshot: Snapshot) => T | false | null | undefined, options?: WaitForOptions): Promise<T>;
76
+ /** Wait until renderer counters stop changing for consecutive samples. */
77
+ waitForIdle(options?: WaitForOptions & {
78
+ stableSamples?: number;
79
+ }): Promise<Snapshot>;
80
+ }
81
+ export declare function createTestRenderer(view: () => VNode, options?: TestRendererOptions): Promise<TestRenderer>;
82
+ /** Spawn a renderer test in an isolated process, useful for GPU/backend matrix runs. */
83
+ export declare function launchTestProcess(options: TestProcessOptions): TestProcess;
84
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { TextHighlight } from "../../protocol/src/index";
2
+ export interface FindRangesOptions {
3
+ text: string;
4
+ query: string;
5
+ caseSensitive?: boolean;
6
+ wholeWord?: boolean;
7
+ }
8
+ /** UTF-16 ranges, matching the native highlight protocol. */
9
+ export declare function findRanges({ text, query, caseSensitive, wholeWord }: FindRangesOptions): Array<{
10
+ start: number;
11
+ end: number;
12
+ }>;
13
+ export interface TextSearchOptions extends Omit<TextHighlight, "ranges" | "activeIndex"> {
14
+ query: string;
15
+ }
16
+ export interface TextSearchSnapshot {
17
+ props: {
18
+ highlight: TextHighlight | undefined;
19
+ onHighlight: (event: {
20
+ matchCount: number;
21
+ query?: string;
22
+ caseSensitive?: boolean;
23
+ wholeWord?: boolean;
24
+ }) => void;
25
+ };
26
+ total: number;
27
+ active: number;
28
+ }
29
+ export interface TextSearchController {
30
+ getSnapshot(options: TextSearchOptions): TextSearchSnapshot;
31
+ next(): void;
32
+ previous(): void;
33
+ goTo(index: number): void;
34
+ subscribe(listener: () => void): () => void;
35
+ }
36
+ /** Framework-neutral navigation for highlight on a native container or leaf. */
37
+ export declare function createTextSearchController(): TextSearchController;
@@ -0,0 +1,91 @@
1
+ import type { StateStyle, Style, SyntaxTheme } from "../../protocol/src/index";
2
+ export interface ThemeColors {
3
+ background: string;
4
+ card: string;
5
+ foreground: string;
6
+ muted: string;
7
+ mutedForeground: string;
8
+ border: string;
9
+ input: string;
10
+ primary: string;
11
+ primaryForeground: string;
12
+ primaryHover: string;
13
+ primaryActive: string;
14
+ secondary: string;
15
+ secondaryForeground: string;
16
+ secondaryHover: string;
17
+ secondaryActive: string;
18
+ destructive: string;
19
+ destructiveForeground: string;
20
+ destructiveHover: string;
21
+ destructiveActive: string;
22
+ ring: string;
23
+ ringSoft: string;
24
+ success: string;
25
+ successMuted: string;
26
+ /** Diff washes. A wash is a background tint, not an action colour: a
27
+ * saturated `destructive` red behind a line of code is unreadable, so the
28
+ * diff carries its own low-chroma tokens. */
29
+ diffAddBackground: string;
30
+ diffAddEmphasisBackground: string;
31
+ diffAddForeground: string;
32
+ diffAddAccent: string;
33
+ diffRemoveBackground: string;
34
+ diffRemoveEmphasisBackground: string;
35
+ diffRemoveForeground: string;
36
+ diffRemoveAccent: string;
37
+ disabled: string;
38
+ disabledForeground: string;
39
+ placeholder: string;
40
+ selection: string;
41
+ scrollbar: string;
42
+ overlay: string;
43
+ imagePlaceholder: string;
44
+ sliderThumb: string;
45
+ windowCloseHover: string;
46
+ windowCloseActive: string;
47
+ }
48
+ export interface ThemeDefinition {
49
+ colors: ThemeColors;
50
+ syntax: SyntaxTheme;
51
+ focusOutline?: ThemeFocusOutline;
52
+ }
53
+ export interface ThemeOverrides {
54
+ colors?: Partial<ThemeColors>;
55
+ syntax?: Partial<SyntaxTheme>;
56
+ focusOutline?: Partial<ThemeFocusOutline>;
57
+ }
58
+ export type ThemeFocusOutline = Pick<StateStyle, "outlineWidth" | "outlineColor" | "outlineOffset" | "outlineRadius" | "outlineStyle">;
59
+ export declare const lightTheme: ThemeDefinition;
60
+ export declare const darkTheme: ThemeDefinition;
61
+ export declare function createTheme(overrides?: ThemeOverrides, base?: ThemeDefinition): ThemeDefinition;
62
+ /** Theme composition with base-first argument order, useful for conditional light/dark themes. */
63
+ export declare const Theme: {
64
+ readonly create: (base?: ThemeDefinition, overrides?: ThemeOverrides) => ThemeDefinition;
65
+ };
66
+ /** Semantic tokens used by components and application styles. */
67
+ export declare const theme: {
68
+ readonly colors: Record<keyof ThemeColors, string>;
69
+ readonly space: {
70
+ readonly xs: 4;
71
+ readonly sm: 8;
72
+ readonly md: 12;
73
+ readonly lg: 16;
74
+ readonly xl: 24;
75
+ readonly xxl: 32;
76
+ };
77
+ readonly radius: {
78
+ readonly sm: 6;
79
+ readonly md: 8;
80
+ readonly lg: 12;
81
+ };
82
+ readonly font: {
83
+ readonly family: "system-ui";
84
+ readonly size: 14;
85
+ readonly lineHeight: 1.5;
86
+ };
87
+ };
88
+ export declare function resolveThemeColor(value: string, selected: ThemeDefinition): string;
89
+ export declare function resolveThemeStyle(style: Style, selected: ThemeDefinition): Style;
90
+ export type ButtonVariant = "default" | "secondary" | "outline" | "ghost" | "destructive";
91
+ export declare const buttonVariants: Record<ButtonVariant, Style>;
@@ -0,0 +1,31 @@
1
+ import { type BaseProps, type Child, type VNode } from "./jsx-runtime";
2
+ export interface VirtualListProps<T> extends BaseProps {
3
+ items: readonly T[];
4
+ itemHeight: number;
5
+ height: number;
6
+ offset: number;
7
+ overscan?: number;
8
+ keyForItem?: (item: T, index: number) => string | number;
9
+ renderItem: (item: T, index: number) => Child;
10
+ onScroll: (offset: number, max: number) => void;
11
+ }
12
+ export interface VariableVirtualListProps<T> extends Omit<VirtualListProps<T>, "itemHeight" | "keyForItem"> {
13
+ /** Stable list id is required so measured heights survive rerenders. */
14
+ id: string;
15
+ itemHeight?: never;
16
+ estimatedItemHeight: number;
17
+ keyForItem: (item: T, index: number) => string | number;
18
+ alignment?: "top" | "bottom";
19
+ followTail?: boolean;
20
+ }
21
+ export interface WindowedVirtualListProps<T> extends Omit<VariableVirtualListProps<T>, "overscan"> {
22
+ /** Total logical row count; `items` contains only the mounted window. */
23
+ itemCount: number;
24
+ /** Logical index represented by `items[0]`. */
25
+ windowStart: number;
26
+ overscan?: never;
27
+ }
28
+ /** Fixed-height rows; the caller keeps `offset` and updates it from `onScroll`. */
29
+ export declare function VirtualList<T>(props: VirtualListProps<T>): VNode;
30
+ export declare function VirtualList<T>(props: VariableVirtualListProps<T>): VNode;
31
+ export declare function VirtualList<T>(props: WindowedVirtualListProps<T>): VNode;
@@ -0,0 +1,24 @@
1
+ export interface RgbaImage {
2
+ width: number;
3
+ height: number;
4
+ rgba: Uint8Array;
5
+ }
6
+ export interface PixelComparisonOptions {
7
+ /** Per-channel delta ignored as noise. */
8
+ threshold?: number;
9
+ }
10
+ export interface PixelComparison {
11
+ width: number;
12
+ height: number;
13
+ differentPixels: number;
14
+ totalPixels: number;
15
+ differenceRatio: number;
16
+ maxChannelDelta: number;
17
+ }
18
+ /** Decode Tarve's 8-bit RGBA PNG captures without an external image dependency. */
19
+ export declare function readPngRgba(path: string): Promise<RgbaImage>;
20
+ export declare function compareRgbaImages(actual: RgbaImage, expected: RgbaImage, options?: PixelComparisonOptions): PixelComparison;
21
+ export declare function comparePngCaptures(actualPath: string, expectedPath: string, options?: PixelComparisonOptions): Promise<PixelComparison>;
22
+ export declare function assertPngMatches(actualPath: string, expectedPath: string, options?: PixelComparisonOptions & {
23
+ maxDifferenceRatio?: number;
24
+ }): Promise<PixelComparison>;
@@ -0,0 +1,16 @@
1
+ export declare const BUILD_TARGETS: readonly ["windows-x64", "linux-x64"];
2
+ export type BuildTarget = typeof BUILD_TARGETS[number];
3
+ export interface TargetConfig {
4
+ platform: "win32" | "linux";
5
+ arch: "x64";
6
+ bunTarget: "bun-windows-x64" | "bun-linux-x64";
7
+ nativeDirectory: "win32-x64" | "linux-x64";
8
+ nativeName: "tarve_native.dll" | "libtarve_native.so";
9
+ executableSuffix: ".exe" | "";
10
+ }
11
+ export declare const TARGET_CONFIGS: Readonly<Record<BuildTarget, TargetConfig>>;
12
+ export declare function isBuildTarget(value: string): value is BuildTarget;
13
+ export declare function targetConfig(target: BuildTarget): TargetConfig;
14
+ export declare function hostBuildTarget(platform?: NodeJS.Platform, arch?: string): BuildTarget | undefined;
15
+ export declare function nativeDirectoryForBuildTarget(target: BuildTarget): TargetConfig["nativeDirectory"];
16
+ export declare function nativeRelativePath(target: BuildTarget): string;