@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.
Files changed (122) hide show
  1. package/CHANGELOG.md +126 -1
  2. package/README.md +121 -12
  3. package/dist/npm/build.js +1401 -85
  4. package/dist/npm/cli.js +1940 -117
  5. package/dist/npm/embedded-assets.js +22 -3
  6. package/dist/npm/index.js +5274 -975
  7. package/dist/npm/jsx-dev-runtime.js +1268 -0
  8. package/dist/npm/jsx-runtime.js +1268 -0
  9. package/dist/npm/native-runtime.json +3 -3
  10. package/dist/npm/node-build.js +1159 -0
  11. package/dist/npm/protocol.js +1 -1
  12. package/dist/npm/runtime.js +5 -5
  13. package/dist/npm/txiki/fetch.ts +228 -0
  14. package/dist/npm/txiki/intl-data.ts +7 -0
  15. package/dist/npm/txiki/intl.test.ts +53 -0
  16. package/dist/npm/txiki/intl.ts +249 -0
  17. package/dist/npm/txiki/prelude.ts +132 -0
  18. package/dist/npm/txiki/runtime.ts +6 -0
  19. package/dist/npm/txiki/shims/buffer.ts +112 -0
  20. package/dist/npm/txiki/shims/child-process.ts +151 -0
  21. package/dist/npm/txiki/shims/crypto.ts +30 -0
  22. package/dist/npm/txiki/shims/events.ts +75 -0
  23. package/dist/npm/txiki/shims/fs-promises.ts +77 -0
  24. package/dist/npm/txiki/shims/fs.ts +231 -0
  25. package/dist/npm/txiki/shims/module.ts +8 -0
  26. package/dist/npm/txiki/shims/net.ts +69 -0
  27. package/dist/npm/txiki/shims/os.ts +72 -0
  28. package/dist/npm/txiki/shims/path.ts +4 -0
  29. package/dist/npm/txiki/shims/timers-promises.ts +9 -0
  30. package/dist/npm/txiki/shims/zlib.ts +9 -0
  31. package/dist/npm/txiki/tjs.d.ts +58 -0
  32. package/dist/npm/txiki/unavailable.ts +10 -0
  33. package/dist/types/core/build.d.ts +24 -0
  34. package/dist/types/core/cli.d.ts +1 -1
  35. package/dist/types/core/esbuild-file-imports.d.ts +8 -0
  36. package/dist/types/core/jsx-compile.d.ts +7 -0
  37. package/dist/types/core/node-build.d.ts +7 -0
  38. package/dist/types/core/node-dev.d.ts +4 -0
  39. package/dist/types/core/node-target.d.ts +10 -0
  40. package/dist/types/core/package-metadata.d.ts +49 -0
  41. package/dist/types/core/runtime-select.d.ts +8 -0
  42. package/dist/types/core/src/advanced-controls.d.ts +1 -1
  43. package/dist/types/core/src/app/element-events.d.ts +18 -0
  44. package/dist/types/core/src/app/media.d.ts +15 -0
  45. package/dist/types/core/src/app/requests.d.ts +25 -0
  46. package/dist/types/core/src/app/shadow.d.ts +7 -0
  47. package/dist/types/core/src/app/stats.d.ts +12 -0
  48. package/dist/types/core/src/app/tray.d.ts +40 -0
  49. package/dist/types/core/src/app-metadata.d.ts +18 -0
  50. package/dist/types/core/src/app.d.ts +89 -2
  51. package/dist/types/core/src/assets.d.ts +4 -0
  52. package/dist/types/core/src/bridge/binding.d.ts +10 -34
  53. package/dist/types/core/src/bridge/index.d.ts +1 -1
  54. package/dist/types/core/src/canvas.d.ts +161 -0
  55. package/dist/types/core/src/chat-controls.d.ts +2 -1
  56. package/dist/types/core/src/components/button.d.ts +1 -1
  57. package/dist/types/core/src/components/glass.d.ts +52 -0
  58. package/dist/types/core/src/components/icon.d.ts +1 -1
  59. package/dist/types/core/src/components/image.d.ts +8 -4
  60. package/dist/types/core/src/components/layout.d.ts +5 -4
  61. package/dist/types/core/src/components/pressable.d.ts +3 -3
  62. package/dist/types/core/src/components/rich-content.d.ts +1 -1
  63. package/dist/types/core/src/components/scroll.d.ts +2 -2
  64. package/dist/types/core/src/components/svg.d.ts +1 -1
  65. package/dist/types/core/src/components/titlebar.d.ts +15 -1
  66. package/dist/types/core/src/components/window.d.ts +21 -1
  67. package/dist/types/core/src/components.d.ts +2 -0
  68. package/dist/types/core/src/css-shadow.d.ts +1 -1
  69. package/dist/types/core/src/desktop-controls.d.ts +2 -2
  70. package/dist/types/core/src/embedded-assets.d.ts +3 -2
  71. package/dist/types/core/src/extra-controls.d.ts +2 -2
  72. package/dist/types/core/src/form-controls.d.ts +1 -1
  73. package/dist/types/core/src/html-elements.d.ts +26 -0
  74. package/dist/types/core/src/index.d.ts +23 -11
  75. package/dist/types/core/src/inline-text.d.ts +25 -0
  76. package/dist/types/core/src/intrinsic-style.d.ts +1 -1
  77. package/dist/types/core/src/jsx-runtime.d.ts +182 -5
  78. package/dist/types/core/src/media-element.d.ts +70 -0
  79. package/dist/types/core/src/memo.d.ts +28 -0
  80. package/dist/types/core/src/motion.d.ts +1 -1
  81. package/dist/types/core/src/png.d.ts +29 -0
  82. package/dist/types/core/src/popups.d.ts +4 -3
  83. package/dist/types/core/src/protocol.d.ts +6 -0
  84. package/dist/types/core/src/reconciler/diff.d.ts +11 -0
  85. package/dist/types/core/src/reconciler/intrinsics.d.ts +24 -0
  86. package/dist/types/core/src/reconciler.d.ts +33 -10
  87. package/dist/types/core/src/render-scope.d.ts +8 -0
  88. package/dist/types/core/src/style.d.ts +1 -1
  89. package/dist/types/core/src/tailwind-palette.d.ts +1 -0
  90. package/dist/types/core/src/tailwind.d.ts +8 -0
  91. package/dist/types/core/src/test-renderer.d.ts +3 -1
  92. package/dist/types/core/src/text-search.d.ts +1 -1
  93. package/dist/types/core/src/theme.d.ts +10 -2
  94. package/dist/types/core/src/updates.d.ts +87 -0
  95. package/dist/types/core/src/virtual-list.d.ts +8 -2
  96. package/dist/types/core/txiki/fetch.d.ts +1 -0
  97. package/dist/types/core/txiki/intl-data.d.ts +6 -0
  98. package/dist/types/core/txiki/intl.d.ts +92 -0
  99. package/dist/types/core/txiki/prelude.d.ts +1 -0
  100. package/dist/types/core/txiki/runtime.d.ts +2 -0
  101. package/dist/types/core/txiki/shims/buffer.d.ts +37 -0
  102. package/dist/types/core/txiki/shims/child-process.d.ts +46 -0
  103. package/dist/types/core/txiki/shims/crypto.d.ts +16 -0
  104. package/dist/types/core/txiki/shims/events.d.ts +21 -0
  105. package/dist/types/core/txiki/shims/fs-promises.d.ts +41 -0
  106. package/dist/types/core/txiki/shims/fs.d.ts +44 -0
  107. package/dist/types/core/txiki/shims/module.d.ts +5 -0
  108. package/dist/types/core/txiki/shims/net.d.ts +22 -0
  109. package/dist/types/core/txiki/shims/os.d.ts +52 -0
  110. package/dist/types/core/txiki/shims/path.d.ts +3 -0
  111. package/dist/types/core/txiki/shims/timers-promises.d.ts +7 -0
  112. package/dist/types/core/txiki/shims/zlib.d.ts +11 -0
  113. package/dist/types/core/txiki/unavailable.d.ts +5 -0
  114. package/dist/types/core/txiki-build.d.ts +23 -0
  115. package/dist/types/core/updates-build.d.ts +35 -0
  116. package/dist/types/core/windows-executable.d.ts +16 -0
  117. package/dist/types/protocol/src/index.d.ts +344 -11
  118. package/native/linux-x64/libtarve_native.so +0 -0
  119. package/native/linux-x64/runtime.json +4 -4
  120. package/native/win32-x64/runtime.json +4 -4
  121. package/native/win32-x64/tarve_native.dll +0 -0
  122. package/package.json +13 -3
@@ -1,4 +1,4 @@
1
- import type { Control, MotionProperty, MotionValues, StateStyle, Style, SvgNode, TextHighlight } from "../../protocol/src/index";
1
+ import type { Control, MotionProperty, MotionValues, StateStyle, Style, SvgNode, TextHighlight } from "./protocol";
2
2
  import type { ImageSource } from "./components/image";
3
3
  export type Child = VNode | string | number | boolean | null | undefined | Child[];
4
4
  /** Clipboard content delivered to the focused element when the clipboard holds no text. */
@@ -11,11 +11,47 @@ export type PastePayload = {
11
11
  height: number;
12
12
  rgba: Uint8Array;
13
13
  };
14
+ export interface DragPosition {
15
+ x: number;
16
+ y: number;
17
+ }
18
+ /** Pointer position while dragging and the drop target currently under it. */
19
+ export interface DragMoveEvent extends DragPosition {
20
+ over: string | null;
21
+ }
22
+ /** Fired once per drag: `target` is the accepting drop target, or null. */
23
+ export interface DragEndEvent extends DragPosition {
24
+ target: string | null;
25
+ cancelled: boolean;
26
+ }
27
+ /** Delivered to the drop target; `source` is the dragged node id. */
28
+ export interface DropEvent extends DragPosition {
29
+ source: string;
30
+ }
31
+ /** Makes a node a drop target. Any of the drop handlers implies `dropTarget`. */
32
+ export interface DropTargetProps {
33
+ dropTarget?: boolean;
34
+ onDragEnter?: (source: string) => void;
35
+ onDragLeave?: (source: string) => void;
36
+ onDrop?: (event: DropEvent) => void;
37
+ }
38
+ /** Pointer drag on an interactive node. A press only becomes a drag after the
39
+ * pointer travels 4px, so the node keeps its click; Escape or window blur cancels. */
40
+ export interface DraggableProps {
41
+ draggable?: boolean;
42
+ onDragStart?: (position: DragPosition) => void;
43
+ onDragMove?: (event: DragMoveEvent) => void;
44
+ onDragEnd?: (event: DragEndEvent) => void;
45
+ }
14
46
  export interface BaseProps {
15
47
  id?: string;
16
48
  key?: string | number;
17
49
  children?: Child;
18
50
  style?: Style;
51
+ /** Tailwind utility classes, compiled to `style` at the call site; an explicit `style` wins. */
52
+ className?: string;
53
+ /** Same as `className`, HTML spelling. Both may be given; `className` comes last. */
54
+ class?: string;
19
55
  rovingGroup?: boolean;
20
56
  highlight?: TextHighlight;
21
57
  onHighlight?: (event: {
@@ -28,18 +64,43 @@ export interface BaseProps {
28
64
  }) => void;
29
65
  /** Receives non-text clipboard content (files or a bitmap) pasted while focused. */
30
66
  onPaste?: (payload: PastePayload) => void;
67
+ /** Content-box size after layout, on mount and whenever it changes (a ResizeObserver). */
68
+ onSize?: (size: {
69
+ width: number;
70
+ height: number;
71
+ }) => void;
72
+ /** Pointer position inside this node (like DOM `offsetX`/`offsetY`) while it is over it or its children. */
73
+ onPointerMove?: (point: {
74
+ x: number;
75
+ y: number;
76
+ }) => void;
77
+ /** The pointer left this node and its children (DOM `pointerleave`). */
78
+ onPointerLeave?: () => void;
31
79
  }
32
80
  export type IntrinsicStateStyle = StateStyle & {
33
81
  backgroundColor?: string;
34
82
  color?: string;
35
83
  };
36
- export type IntrinsicStyle = Omit<Style, "hover" | "focus" | "focusVisible" | "active" | "disabled"> & {
84
+ export type IntrinsicStyle = Omit<Style, "hover" | "focus" | "focusVisible" | "active" | "disabled" | "overflow" | "dark"> & {
85
+ /** Overrides under a dark window theme (Tailwind's `dark:`). */
86
+ dark?: Omit<IntrinsicStyle, "dark">;
87
+ /** CSS `overflow`; on a `<div>`, `auto` or `scroll` makes it a scroll container. */
88
+ overflow?: Style["overflow"] | "auto" | "scroll";
89
+ overflowX?: Style["overflow"] | "auto" | "scroll";
90
+ overflowY?: Style["overflow"] | "auto" | "scroll";
37
91
  /** CSS-like alias for Tarve's native `direction`. */
38
92
  flexDirection?: Style["direction"];
39
93
  /** CSS-like alias for Tarve's native `background`. */
40
94
  backgroundColor?: string;
41
95
  /** CSS-like alias for Tarve's native `foreground`. */
42
96
  color?: string;
97
+ /** CSS-like alias for Tarve's native `radius`. */
98
+ borderRadius?: Style["radius"];
99
+ /** CSS `align-items` and `justify-content` (Tarve's `align` and `justify`). */
100
+ alignItems?: "flex-start" | "start" | "center" | "flex-end" | "end" | "stretch";
101
+ justifyContent?: "flex-start" | "start" | "center" | "flex-end" | "end" | "space-between" | "space-around" | "space-evenly";
102
+ /** CSS `object-fit` on an `<img>` (its `fit` prop). */
103
+ objectFit?: "fill" | "contain" | "cover" | "none" | "scale-down";
43
104
  hover?: IntrinsicStateStyle;
44
105
  focus?: IntrinsicStateStyle;
45
106
  focusVisible?: IntrinsicStateStyle;
@@ -47,11 +108,11 @@ export type IntrinsicStyle = Omit<Style, "hover" | "focus" | "focusVisible" | "a
47
108
  disabled?: IntrinsicStateStyle;
48
109
  };
49
110
  export type DivStyle = IntrinsicStyle;
50
- export interface DivProps extends Omit<BaseProps, "style"> {
111
+ export interface DivProps extends Omit<BaseProps, "style">, DropTargetProps {
51
112
  style?: IntrinsicStyle;
52
113
  gap?: number;
53
114
  padding?: Style["padding"];
54
- flex?: number;
115
+ flex?: number | string;
55
116
  align?: Style["align"];
56
117
  justify?: Style["justify"];
57
118
  portal?: boolean;
@@ -77,6 +138,8 @@ export interface SpanProps extends Omit<BaseProps, "style"> {
77
138
  size?: number;
78
139
  weight?: number;
79
140
  color?: string;
141
+ /** Inside a paragraph the span becomes a click target. */
142
+ onClick?: () => void;
80
143
  }
81
144
  export type ParagraphProps = SpanProps;
82
145
  export type HeadingProps = SpanProps;
@@ -94,10 +157,30 @@ export interface ImgProps extends Omit<BaseProps, "style" | "children"> {
94
157
  height?: number;
95
158
  fit?: "cover" | "contain";
96
159
  }
97
- export type IntrinsicInputType = "text" | "password" | "email" | "number" | "search" | "tel" | "url";
160
+ export type IntrinsicInputType = "text" | "password" | "email" | "number" | "search" | "tel" | "url" | "checkbox" | "radio" | "range" | "date" | "file" | "color" | "time";
98
161
  export interface IntrinsicInputProps extends Omit<BaseProps, "style" | "children"> {
99
162
  style?: IntrinsicStyle;
100
163
  type?: IntrinsicInputType;
164
+ /** Form field name: `<form onSubmit>` receives values keyed by it. */
165
+ name?: string;
166
+ required?: boolean;
167
+ /** Initial value of an uncontrolled field. */
168
+ defaultValue?: string;
169
+ /** checkbox and radio. */
170
+ checked?: boolean;
171
+ defaultChecked?: boolean;
172
+ /** Visible label of a checkbox, radio or range. */
173
+ label?: string;
174
+ ariaLabel?: string;
175
+ /** range and date. */
176
+ min?: number | string;
177
+ max?: number | string;
178
+ step?: number;
179
+ /** file: `.png,.jpg` filters and multiple selection; onFiles receives every path. */
180
+ accept?: string;
181
+ multiple?: boolean;
182
+ onFiles?: (paths: string[]) => void;
183
+ onCheckedChange?: (checked: boolean) => void;
101
184
  value?: string;
102
185
  placeholder?: string;
103
186
  disabled?: boolean;
@@ -106,6 +189,11 @@ export interface IntrinsicInputProps extends Omit<BaseProps, "style" | "children
106
189
  }
107
190
  export interface IntrinsicTextareaProps extends Omit<BaseProps, "style" | "children"> {
108
191
  style?: IntrinsicStyle;
192
+ /** Form field name: `<form onSubmit>` receives the text keyed by it. */
193
+ name?: string;
194
+ required?: boolean;
195
+ /** Initial text of an uncontrolled textarea. */
196
+ defaultValue?: string;
109
197
  value?: string;
110
198
  placeholder?: string;
111
199
  disabled?: boolean;
@@ -119,6 +207,8 @@ export interface IntrinsicButtonProps extends Omit<BaseProps, "style"> {
119
207
  size?: "sm" | "default" | "lg";
120
208
  disabled?: boolean;
121
209
  control?: Control;
210
+ /** Inside a `<form>` a button submits unless `type="button"`. */
211
+ type?: "submit" | "button" | "reset";
122
212
  onClick?: () => void;
123
213
  onHover?: (hovered: boolean) => void;
124
214
  }
@@ -206,6 +296,11 @@ export interface IntrinsicOptionProps {
206
296
  }
207
297
  export interface IntrinsicSelectProps extends Omit<BaseProps, "style"> {
208
298
  style?: IntrinsicStyle;
299
+ /** Form field name: `<form onSubmit>` receives the chosen value keyed by it. */
300
+ name?: string;
301
+ required?: boolean;
302
+ /** Initial choice of an uncontrolled select; without it, the first enabled option. */
303
+ defaultValue?: string;
209
304
  value?: string;
210
305
  placeholder?: string;
211
306
  disabled?: boolean;
@@ -238,6 +333,42 @@ export declare const jsxDEV: typeof jsx;
238
333
  export declare function Fragment(props: {
239
334
  children?: Child;
240
335
  }): VNode;
336
+ export interface IntrinsicBlockProps extends Omit<BaseProps, "style"> {
337
+ style?: IntrinsicStyle;
338
+ }
339
+ export interface IntrinsicFormProps extends IntrinsicBlockProps {
340
+ /** Enter in a field or a submit button: named values, after `required` fields are filled. */
341
+ onSubmit?: (values: Record<string, string | boolean | string[]>) => void;
342
+ /** A required field was empty; receives its name. */
343
+ onInvalid?: (name: string) => void;
344
+ ariaLabel?: string;
345
+ }
346
+ export interface IntrinsicListProps extends IntrinsicBlockProps {
347
+ start?: number;
348
+ }
349
+ export interface IntrinsicDetailsProps extends IntrinsicBlockProps {
350
+ open?: boolean;
351
+ onToggle?: (open: boolean) => void;
352
+ }
353
+ export interface IntrinsicCellProps extends IntrinsicBlockProps {
354
+ colSpan?: number;
355
+ rowSpan?: number;
356
+ }
357
+ export interface IntrinsicCanvasProps extends IntrinsicBlockProps {
358
+ /** CSS pixels; HTML's default canvas is 300×150. */
359
+ width?: number;
360
+ height?: number;
361
+ /** Draws with the Canvas 2D API; replayed on every render. */
362
+ onDraw?: (context: import("./canvas").CanvasRenderingContext2D) => void;
363
+ ariaLabel?: string;
364
+ }
365
+ export interface IntrinsicMeterProps extends IntrinsicBlockProps {
366
+ value: number;
367
+ min?: number;
368
+ max?: number;
369
+ ariaLabel?: string;
370
+ title?: string;
371
+ }
241
372
  export declare namespace JSX {
242
373
  type Element = VNode;
243
374
  interface ElementChildrenAttribute {
@@ -248,7 +379,53 @@ export declare namespace JSX {
248
379
  }
249
380
  interface IntrinsicElements {
250
381
  div: DivProps;
382
+ form: IntrinsicFormProps;
383
+ pre: SpanProps;
384
+ blockquote: IntrinsicBlockProps;
385
+ meter: IntrinsicMeterProps;
386
+ canvas: IntrinsicCanvasProps;
387
+ audio: import("./media-element").MediaElementProps;
388
+ abbr: SpanProps & {
389
+ title?: string;
390
+ };
391
+ fieldset: IntrinsicBlockProps;
392
+ legend: IntrinsicBlockProps;
393
+ ul: IntrinsicListProps;
394
+ ol: IntrinsicListProps;
395
+ li: IntrinsicBlockProps;
396
+ dl: IntrinsicBlockProps;
397
+ dt: IntrinsicBlockProps;
398
+ dd: IntrinsicBlockProps;
399
+ table: IntrinsicBlockProps;
400
+ caption: IntrinsicBlockProps;
401
+ thead: IntrinsicBlockProps;
402
+ tbody: IntrinsicBlockProps;
403
+ tfoot: IntrinsicBlockProps;
404
+ tr: IntrinsicBlockProps;
405
+ th: IntrinsicCellProps;
406
+ td: IntrinsicCellProps;
407
+ details: IntrinsicDetailsProps;
408
+ summary: IntrinsicBlockProps;
251
409
  span: SpanProps;
410
+ strong: SpanProps;
411
+ b: SpanProps;
412
+ em: SpanProps;
413
+ i: SpanProps;
414
+ u: SpanProps;
415
+ s: SpanProps;
416
+ del: SpanProps;
417
+ ins: SpanProps;
418
+ code: SpanProps;
419
+ kbd: SpanProps;
420
+ samp: SpanProps;
421
+ var: SpanProps;
422
+ cite: SpanProps;
423
+ dfn: SpanProps;
424
+ mark: SpanProps;
425
+ small: SpanProps;
426
+ sub: SpanProps;
427
+ sup: SpanProps;
428
+ br: Omit<SpanProps, "children">;
252
429
  p: ParagraphProps;
253
430
  h1: HeadingProps;
254
431
  h2: HeadingProps;
@@ -0,0 +1,70 @@
1
+ import type { VNode } from "./jsx-runtime";
2
+ /**
3
+ * `<audio>`: an HTMLMediaElement played by the native runtime. Attributes are
4
+ * reconciled after each render (src, loop, muted, volume, autoPlay); playback
5
+ * state comes back as media events. With `controls` it renders the default
6
+ * control bar; without, it renders nothing, as in a browser.
7
+ */
8
+ export interface MediaElementProps {
9
+ id?: string;
10
+ src?: string;
11
+ controls?: boolean;
12
+ autoPlay?: boolean;
13
+ loop?: boolean;
14
+ muted?: boolean;
15
+ /** 0–1, HTMLMediaElement.volume. */
16
+ volume?: number;
17
+ style?: Record<string, unknown>;
18
+ ariaLabel?: string;
19
+ onLoadedMetadata?: (event: MediaEventInfo) => void;
20
+ onPlay?: (event: MediaEventInfo) => void;
21
+ onPause?: (event: MediaEventInfo) => void;
22
+ onTimeUpdate?: (event: MediaEventInfo) => void;
23
+ onSeeked?: (event: MediaEventInfo) => void;
24
+ onEnded?: (event: MediaEventInfo) => void;
25
+ onError?: (message: string) => void;
26
+ }
27
+ export interface MediaEventInfo {
28
+ currentTime: number;
29
+ duration: number | null;
30
+ paused: boolean;
31
+ }
32
+ /** What a render asks of one media element. */
33
+ export interface MediaRequest {
34
+ src?: string;
35
+ loop: boolean;
36
+ muted: boolean;
37
+ volume: number;
38
+ autoPlay: boolean;
39
+ handlers: MediaElementProps;
40
+ }
41
+ interface MediaState {
42
+ paused: boolean;
43
+ time: number;
44
+ duration: number | null;
45
+ ended: boolean;
46
+ error?: string;
47
+ }
48
+ /** Playback state of an element; during render the current scope, otherwise the app's `scope`. */
49
+ export declare function mediaState(id: string, scope?: object): MediaState;
50
+ export interface MediaController {
51
+ play(): void;
52
+ pause(): void;
53
+ /** HTMLMediaElement.currentTime = seconds. */
54
+ seek(seconds: number): void;
55
+ setVolume(volume: number): void;
56
+ setMuted(muted: boolean): void;
57
+ }
58
+ export declare function mediaRequest(props: MediaElementProps): MediaRequest;
59
+ /** The default controls of a browser's audio element: play, time, seek bar, mute. */
60
+ export declare function expandAudio(props: MediaElementProps, id: string): VNode;
61
+ /** Applies a native media event to the element's state; returns the handler to call. */
62
+ export declare function applyMediaEvent(event: {
63
+ id: string;
64
+ event: string;
65
+ time?: number;
66
+ duration?: number | null;
67
+ paused?: boolean;
68
+ message?: string;
69
+ }, request: MediaRequest | undefined, scope: object): (() => void) | undefined;
70
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { VNode } from "./jsx-runtime";
2
+ /** Marks a component made by {@link memo}; the reconciler reads it. */
3
+ export declare const MEMO: unique symbol;
4
+ export interface MemoInfo<P> {
5
+ render: (props: P) => VNode;
6
+ equal: (previous: P, next: P) => boolean;
7
+ /** A compiled JSX template (jsx-compile.ts): it renders one element, which keeps its list position. */
8
+ template?: boolean;
9
+ }
10
+ /** Object.is on every own prop, like React.memo's default comparison. */
11
+ export declare function shallowEqual(previous: object, next: object): boolean;
12
+ /**
13
+ * A component whose compiled subtree is reused while its props stay equal
14
+ * (shallowly, or by `equal`), its position in the tree is the same, and the
15
+ * theme, inherited font and form around it have not changed. A reused subtree
16
+ * costs no rendering, no compiling and no diffing: an update touches only the
17
+ * components whose props changed. Everything the component shows must come
18
+ * from its props; reading module state inside it shows stale values.
19
+ */
20
+ export declare function memo<P extends object>(render: (props: P) => VNode, equal?: (previous: P, next: P) => boolean): (props: P) => VNode;
21
+ /**
22
+ * A JSX subtree compiled at build time (packages/core/jsx-compile.ts): `render` builds
23
+ * the subtree from its dynamic parts (`props`), which are only values the parent
24
+ * computed, so the compiled subtree is reused while they are equal. Event handler
25
+ * props (`events`) never force a recompile: the subtree calls whichever handler the
26
+ * latest render passed.
27
+ */
28
+ export declare function template<P extends Record<string, unknown>>(render: (props: P) => VNode, events?: readonly string[]): (props: P) => VNode;
@@ -1,4 +1,4 @@
1
- import type { MotionTransitions, MotionValues } from "../../protocol/src/index";
1
+ import type { MotionTransitions, MotionValues } from "./protocol";
2
2
  import { type VNode } from "./jsx-runtime";
3
3
  export interface AnimatePresenceProps {
4
4
  /** Stable identity for this presence boundary. */
@@ -0,0 +1,29 @@
1
+ export interface DecodedPng {
2
+ width: number;
3
+ height: number;
4
+ /** Straight (not premultiplied) RGBA8. */
5
+ rgba: Uint8Array;
6
+ }
7
+ export declare function isPng(bytes: Uint8Array): boolean;
8
+ /** Width and height from a PNG's IHDR, without decoding it. */
9
+ export declare function pngSize(bytes: Uint8Array): {
10
+ width: number;
11
+ height: number;
12
+ } | undefined;
13
+ /**
14
+ * Decodes a non-interlaced PNG of any colour type at bit depth 8 or 16 (and
15
+ * 1/2/4-bit palette or grey), the forms image editors and icon exporters write.
16
+ */
17
+ export declare function decodePng(bytes: Uint8Array): DecodedPng;
18
+ /** Encodes straight RGBA8 pixels as an 8-bit RGBA PNG. */
19
+ export declare function encodePng(rgba: Uint8Array, width: number, height: number): Uint8Array;
20
+ /** Area-averaged downscale (premultiplied, so transparent edges keep their colour) to a size x size square. */
21
+ export declare function resizeSquare(image: DecodedPng, size: number): Uint8Array;
22
+ /** An .ico whose entries are PNG images (Windows Vista and later), each square and at most 256 px. */
23
+ export declare function encodeIco(entries: readonly {
24
+ size: number;
25
+ png: Uint8Array;
26
+ }[]): Uint8Array;
27
+ export declare function isIco(bytes: Uint8Array): boolean;
28
+ /** The largest PNG-compressed entry of an .ico, if it has one. */
29
+ export declare function largestIcoPng(bytes: Uint8Array): Uint8Array | undefined;
@@ -1,10 +1,11 @@
1
- import type { Style } from "../../protocol/src/index";
1
+ import type { Style } from "./protocol";
2
2
  import { type BaseProps, type Child, type VNode } from "./jsx-runtime";
3
3
  import { type IconName } from "./components";
4
4
  export type PopupSide = "top" | "right" | "bottom" | "left";
5
5
  export interface TooltipProps extends BaseProps {
6
6
  id: string;
7
- open: boolean;
7
+ /** Controlled visibility. Omit it and the tooltip shows while its trigger is hovered, one at a time. */
8
+ open?: boolean;
8
9
  trigger: Child;
9
10
  content: Child;
10
11
  side?: PopupSide;
@@ -12,7 +13,7 @@ export interface TooltipProps extends BaseProps {
12
13
  onOpenChange?: (open: boolean) => void;
13
14
  contentStyle?: Style;
14
15
  }
15
- export declare function Tooltip({ id, open, trigger, content, side, label, onOpenChange, contentStyle, style, }: TooltipProps): VNode;
16
+ export declare function Tooltip({ id, open: controlledOpen, trigger, content, side, label, onOpenChange, contentStyle, style, }: TooltipProps): VNode;
16
17
  export interface PopoverProps extends BaseProps {
17
18
  id: string;
18
19
  open: boolean;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The wire protocol shared with the native runtime. Imported by path, not as
3
+ * `@tarve/protocol`: the published `dist/types` keep this relative import so
4
+ * consumers resolve the bundled `protocol/src/index.d.ts` without a second package.
5
+ */
6
+ export * from "../../protocol/src/index";
@@ -0,0 +1,11 @@
1
+ import type { NativeNode, TreeMutation } from "../protocol";
2
+ import type { CompiledTree } from "../reconciler";
3
+ /** Structural equality of plain data (styles, controls, memo props). */
4
+ export declare function sameValue(a: unknown, b: unknown): boolean;
5
+ /** null requests a structural replacement; an empty list means no native work is needed. */
6
+ export declare function diffTrees(previous: CompiledTree, next: CompiledTree): NativeNode[] | null;
7
+ /**
8
+ * Computes one atomic retained-tree mutation batch. A null result is reserved for
9
+ * identity-incompatible replacements (root ID or an existing keyed node kind changed).
10
+ */
11
+ export declare function diffTreeMutations(previous: CompiledTree, next: CompiledTree, unchanged?: (old: NativeNode, node: NativeNode) => boolean): TreeMutation[] | null;
@@ -0,0 +1,24 @@
1
+ import { type Child, type VNode } from "../jsx-runtime";
2
+ import { type MediaRequest } from "../media-element";
3
+ import { type FormContext } from "../html-elements";
4
+ /** Layout props a `<div>` accepts directly, as shorthands for its style. */
5
+ export declare const DIV_SHORTHANDS: readonly ["gap", "padding", "flex", "align", "justify"];
6
+ export declare function textContent(value: Child): string;
7
+ /** What the reconciler lends an intrinsic element while it compiles. */
8
+ export interface IntrinsicContext {
9
+ /** The enclosing `<form>`, if any. */
10
+ form: FormContext | undefined;
11
+ /** Names the native node a `<label htmlFor>` targets for `id`. */
12
+ labelable(id: string, nativeId: string): void;
13
+ /** Ties a `<label>` to its `htmlFor` target. */
14
+ label(targetId: string, labelId: string): void;
15
+ /** Declares an `<audio>` element's native media. */
16
+ media(id: string, request: MediaRequest): void;
17
+ }
18
+ export interface IntrinsicExpansion {
19
+ element: VNode;
20
+ /** A `<form>`: the element's descendants compile inside this form. */
21
+ form?: FormContext;
22
+ }
23
+ /** The component element an intrinsic `child` compiles as; undefined when `child` is a native kind. */
24
+ export declare function expandIntrinsic(child: VNode, path: string, context: IntrinsicContext): IntrinsicExpansion | undefined;
@@ -1,7 +1,9 @@
1
- import { type MotionProperty, type NativeNode, type Renderer, type SceneDocument, type ScrollPosition, type TreeMutation, type VirtualListMeasurement } from "../../protocol/src/index";
2
- import { type PastePayload, type VNode } from "./jsx-runtime";
1
+ import { type MotionProperty, type NativeNode, type Renderer, type SceneDocument, type ScrollInfo, type ScrollPosition, type VirtualListMeasurement } from "./protocol";
2
+ import { type DragEndEvent, type DragMoveEvent, type DragPosition, type DropEvent, type PastePayload, type VNode } from "./jsx-runtime";
3
3
  import type { WindowCloseRequestEvent } from "./components";
4
4
  import type { ComponentAdapter } from "./component-adapter";
5
+ import type { MediaRequest } from "./media-element";
6
+ export { diffTrees, diffTreeMutations } from "./reconciler/diff";
5
7
  export interface Handlers {
6
8
  onClick?: () => void;
7
9
  onMarkdownLink?: (href: string) => void;
@@ -26,10 +28,10 @@ export interface Handlers {
26
28
  onSubmit?: (value: string) => void;
27
29
  onPaste?: (payload: PastePayload) => void;
28
30
  onValueChange?: (value: number) => void;
29
- onScroll?: (offset: number, max: number) => void;
31
+ onScroll?: (offset: number, max: number, info: ScrollInfo) => void;
30
32
  onScrollPosition?: (position: ScrollPosition) => void;
31
33
  onVirtualListLayout?: (items: VirtualListMeasurement[]) => void;
32
- onVirtualListScrollToItem?: (index: number, offset: number) => void;
34
+ onVirtualListScrollToItem?: (index: number, offset: number, smooth?: boolean) => void;
33
35
  onVirtualListFocus?: (key: string | null) => void;
34
36
  onEscape?: () => void;
35
37
  onKeyDown?: (key: string) => void;
@@ -38,17 +40,38 @@ export interface Handlers {
38
40
  onTransitionEnd?: (event: {
39
41
  property: MotionProperty;
40
42
  }) => void;
43
+ onDragStart?: (position: DragPosition) => void;
44
+ onDragMove?: (event: DragMoveEvent) => void;
45
+ onDragEnd?: (event: DragEndEvent) => void;
46
+ onDragEnter?: (source: string) => void;
47
+ onDragLeave?: (source: string) => void;
48
+ onDrop?: (event: DropEvent) => void;
49
+ onSize?: (size: {
50
+ width: number;
51
+ height: number;
52
+ }) => void;
53
+ onPointerMove?: (point: {
54
+ x: number;
55
+ y: number;
56
+ }) => void;
57
+ onPointerLeave?: () => void;
41
58
  }
42
59
  export interface CompiledTree {
43
60
  document: SceneDocument;
44
61
  handlers: Map<string, Handlers>;
45
62
  nodes: Map<string, NativeNode>;
63
+ media?: Map<string, MediaRequest>;
64
+ /** Some style carried a window-width breakpoint: the app re-renders when the width changes. */
65
+ usesViewport?: boolean;
46
66
  }
47
- export declare function compileTree(element: VNode, debug?: boolean, renderer?: Renderer, componentAdapters?: readonly ComponentAdapter[], renderScope?: object, visible?: boolean): CompiledTree;
48
- /** null requests a structural replacement; an empty list means no native work is needed. */
49
- export declare function diffTrees(previous: CompiledTree, next: CompiledTree): NativeNode[] | null;
50
67
  /**
51
- * Computes one atomic retained-tree mutation batch. A null result is reserved for
52
- * identity-incompatible replacements (root ID or an existing keyed node kind changed).
68
+ * Forgets every memoized subtree containing `id`, so the next render compiles it
69
+ * again. Called when a handler of that node runs: handlers update the state a
70
+ * component reads (VirtualList's measured height, a row's own module state),
71
+ * which its props alone do not show.
53
72
  */
54
- export declare function diffTreeMutations(previous: CompiledTree, next: CompiledTree): TreeMutation[] | null;
73
+ export declare function invalidateMemos(renderScope: object, id: string): void;
74
+ export declare function compileTree(element: VNode, debug?: boolean, renderer?: Renderer, componentAdapters?: readonly ComponentAdapter[], renderScope?: object, visible?: boolean, viewport?: {
75
+ width: number;
76
+ height: number;
77
+ }): CompiledTree;
@@ -1,3 +1,11 @@
1
1
  export declare function currentRenderScope(): object;
2
2
  export declare function currentRenderEpoch(): number;
3
3
  export declare function withRenderScope<T>(scope: object | undefined, render: () => T): T;
4
+ /**
5
+ * Module state kept per render scope (one app, one remount, one test renderer),
6
+ * like a DOM document keeps its elements' state. Read during render; event
7
+ * handlers close over the value they received at render time.
8
+ */
9
+ export declare function scopedState<T>(key: symbol, create: () => T, scope?: object): T;
10
+ /** Forgets every scoped state of a scope (tests). */
11
+ export declare function resetScopedState(scope?: object): void;
@@ -1,4 +1,4 @@
1
- import type { Style as ProtocolStyle } from "../../protocol/src/index";
1
+ import type { Style as ProtocolStyle } from "./protocol";
2
2
  export type Style = ProtocolStyle;
3
3
  /** Typed style helpers. `create` is allocation-free; `merge` deep-merges visual state objects. */
4
4
  export declare const Style: {
@@ -0,0 +1 @@
1
+ export declare const PALETTE: Record<string, string>;
@@ -0,0 +1,8 @@
1
+ import type { Style } from "./protocol";
2
+ /**
3
+ * Tailwind utility classes as a Tarve style. Falsy arguments are skipped, so it
4
+ * composes like `clsx`: `tw("p-4", active && "bg-primary")`. Later classes win.
5
+ */
6
+ export declare function tw(...classes: readonly (string | false | null | undefined)[]): Style;
7
+ /** `className` compiled under an explicit `style`: inline wins, as it does in CSS. */
8
+ export declare function styleWithClassName(className: string, style: Record<string, unknown> | undefined): Record<string, unknown>;
@@ -1,4 +1,4 @@
1
- import type { Control, NodeSnapshot, Renderer, Snapshot } from "../../protocol/src/index";
1
+ import type { Control, NodeSnapshot, Renderer, Snapshot } from "./protocol";
2
2
  import { type AppHandle, type AppOptions } from "./app";
3
3
  import type { VNode } from "./jsx-runtime";
4
4
  export interface WaitForOptions {
@@ -53,6 +53,8 @@ export declare class Locator {
53
53
  node(): Promise<NodeSnapshot>;
54
54
  waitFor(options?: WaitForOptions): Promise<NodeSnapshot>;
55
55
  click(): Promise<void>;
56
+ /** Moves the pointer over the node: its centre, or `offset` from its top-left corner. */
57
+ hover(offset?: Point): Promise<void>;
56
58
  fill(value: string): Promise<void>;
57
59
  press(key: string): Promise<void>;
58
60
  wheel(options: number | WheelOptions): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { TextHighlight } from "../../protocol/src/index";
1
+ import type { TextHighlight } from "./protocol";
2
2
  export interface FindRangesOptions {
3
3
  text: string;
4
4
  query: string;
@@ -1,4 +1,4 @@
1
- import type { StateStyle, Style, SyntaxTheme } from "../../protocol/src/index";
1
+ import type { StateStyle, Style, SyntaxTheme } from "./protocol";
2
2
  export interface ThemeColors {
3
3
  background: string;
4
4
  card: string;
@@ -19,6 +19,8 @@ export interface ThemeColors {
19
19
  destructiveForeground: string;
20
20
  destructiveHover: string;
21
21
  destructiveActive: string;
22
+ /** Destructive colour for text and icons on the background: errors, alerts. */
23
+ destructiveText: string;
22
24
  ring: string;
23
25
  ringSoft: string;
24
26
  success: string;
@@ -86,8 +88,14 @@ export declare const theme: {
86
88
  };
87
89
  };
88
90
  export declare function resolveThemeColor(value: string, selected: ThemeDefinition): string;
89
- /** Theme token or CSS colour (hex, rgb(), hsl(), names) for colour keys; other strings unchanged. */
90
91
  export declare function resolveStyleString(key: string, value: string, selected: ThemeDefinition): string;
92
+ /**
93
+ * Theme-resolved copy of a style. Equal styles (most nodes of a list share a handful)
94
+ * resolve once per theme: the result is cached by the style's JSON, which QuickJS
95
+ * serializes in C far faster than the resolution runs in JS. Nested objects (state
96
+ * styles, shadows, gradients) are the cache's own copies, shared and frozen; the top
97
+ * level is a fresh copy callers may extend.
98
+ */
91
99
  export declare function resolveThemeStyle(style: Style, selected: ThemeDefinition): Style;
92
100
  export type ButtonVariant = "default" | "secondary" | "outline" | "ghost" | "destructive";
93
101
  export declare const buttonVariants: Record<ButtonVariant, Style>;