@vizejs/fresco 0.817.0 → 0.819.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 (44) hide show
  1. package/dist/{app-CDSThgku.mjs → app-ByxmaQXv.mjs} +8 -119
  2. package/dist/app-ByxmaQXv.mjs.map +1 -0
  3. package/dist/ascii-font/index.d.mts +15 -0
  4. package/dist/ascii-font/index.d.mts.map +1 -1
  5. package/dist/ascii-font/index.mjs +0 -3
  6. package/dist/ascii-font/index.mjs.map +1 -1
  7. package/dist/components/index.d.mts +1 -1
  8. package/dist/components/index.mjs +1 -1
  9. package/dist/{components-CkggYTVQ.mjs → components-0LBWpsQe.mjs} +5 -116
  10. package/dist/components-0LBWpsQe.mjs.map +1 -0
  11. package/dist/composables/index.d.mts +3 -3
  12. package/dist/composables/index.mjs +3 -3
  13. package/dist/{composables-amARnyjm.mjs → composables-D1oKPS0m.mjs} +3 -15
  14. package/dist/composables-D1oKPS0m.mjs.map +1 -0
  15. package/dist/{index-BOV-0YqV.d.mts → index-C7_vgg04.d.mts} +64 -22
  16. package/dist/index-C7_vgg04.d.mts.map +1 -0
  17. package/dist/{index-BF-rzRoS.d.mts → index-ORAWju9U.d.mts} +964 -363
  18. package/dist/index-ORAWju9U.d.mts.map +1 -0
  19. package/dist/index.d.mts +4 -4
  20. package/dist/index.mjs +4 -30
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/qr-code/index.d.mts +29 -0
  23. package/dist/qr-code/index.d.mts.map +1 -1
  24. package/dist/qr-code/index.mjs +0 -3
  25. package/dist/qr-code/index.mjs.map +1 -1
  26. package/dist/testing/index.d.mts +23 -6
  27. package/dist/testing/index.d.mts.map +1 -1
  28. package/dist/testing/index.mjs +1 -42
  29. package/dist/testing/index.mjs.map +1 -1
  30. package/dist/{useApp-vIRJ5Th3.d.mts → useApp-CZwf8lOA.d.mts} +10 -7
  31. package/dist/useApp-CZwf8lOA.d.mts.map +1 -0
  32. package/dist/{useBoxMetrics-9FFVE-tA.mjs → useBoxMetrics-DyBYcQEp.mjs} +2 -22
  33. package/dist/useBoxMetrics-DyBYcQEp.mjs.map +1 -0
  34. package/dist/{useVirtualViewport-TxTapifg.d.mts → useVirtualViewport-CCWjx3oS.d.mts} +7 -1
  35. package/dist/useVirtualViewport-CCWjx3oS.d.mts.map +1 -0
  36. package/package.json +2 -2
  37. package/dist/app-CDSThgku.mjs.map +0 -1
  38. package/dist/components-CkggYTVQ.mjs.map +0 -1
  39. package/dist/composables-amARnyjm.mjs.map +0 -1
  40. package/dist/index-BF-rzRoS.d.mts.map +0 -1
  41. package/dist/index-BOV-0YqV.d.mts.map +0 -1
  42. package/dist/useApp-vIRJ5Th3.d.mts.map +0 -1
  43. package/dist/useBoxMetrics-9FFVE-tA.mjs.map +0 -1
  44. package/dist/useVirtualViewport-TxTapifg.d.mts.map +0 -1
@@ -1,24 +1,6 @@
1
- import { D as createFocusManager, E as FOCUS_KEY, I as treeToScreenReaderString, M as createAppContext, P as SCREEN_READER_KEY, _ as CURSOR_KEY, a as lastMouseEvent, b as STREAMS_KEY, d as treeToRenderNodes, f as isStaticItemNode, i as lastKeyEvent, j as APP_KEY, n as lastCompositionEvent, o as lastPasteEvent, p as isStaticNode, r as lastFocusEvent, s as lastResizeEvent, u as createRenderer$1, v as createCursorContext, x as createStreamsContext } from "../app-CDSThgku.mjs";
1
+ import { D as createFocusManager, E as FOCUS_KEY, F as SCREEN_READER_KEY, L as treeToScreenReaderString, M as APP_KEY, N as createAppContext, _ as CURSOR_KEY, a as lastMouseEvent, b as STREAMS_KEY, d as treeToRenderNodes, f as isStaticItemNode, i as lastKeyEvent, n as lastCompositionEvent, o as lastPasteEvent, p as isStaticNode, r as lastFocusEvent, s as lastResizeEvent, u as createRenderer$1, v as createCursorContext, x as createStreamsContext } from "../app-ByxmaQXv.mjs";
2
2
  import { h, nextTick, ref } from "vue";
3
3
  //#region src/testing/mount.ts
4
- /**
5
- * Test-only mount harness for the Fresco JS layer.
6
- *
7
- * Fresco's renderer is pure JS up to the byte boundary that crosses into the
8
- * native module: `renderer.ts` imports only types from `@vizejs/fresco-native`,
9
- * and `app.ts` loads the native binding lazily and only in interactive mode.
10
- * This harness mounts components through the real custom renderer with the
11
- * same provide set `createApp`/`renderToString` install, so tests assert the
12
- * mounted `FrescoNode` output tree without a native build and without mocks.
13
- *
14
- * Not exported from the package entry points; `vp pack` does not ship it.
15
- */
16
- /**
17
- * Mount a component (or a plain render function) through the Fresco renderer.
18
- *
19
- * The returned {@link MountedFresco.root} is live: re-read it after reactive
20
- * updates plus `await nextTick()` to observe the patched output tree.
21
- */
22
4
  function mountFresco(root, options = {}) {
23
5
  const renderer = createRenderer$1({
24
6
  onMutation: options.onMutation,
@@ -68,13 +50,6 @@ function mountFresco(root, options = {}) {
68
50
  unmount: () => app.unmount()
69
51
  };
70
52
  }
71
- /**
72
- * Dispatch a key event through the same `lastKeyEvent` ref the interactive
73
- * event loop writes, then wait for watchers to flush.
74
- *
75
- * Pass `char` for printable input or `key` for named keys ("left", "enter",
76
- * "backspace", ...). Modifiers default to false.
77
- */
78
53
  function dispatchKey(event) {
79
54
  lastKeyEvent.value = {
80
55
  type: "key",
@@ -90,7 +65,6 @@ function dispatchKey(event) {
90
65
  };
91
66
  return nextTick();
92
67
  }
93
- /** Dispatch a sequence of printable characters via {@link dispatchKey}. */
94
68
  async function typeChars(text) {
95
69
  for (const char of text) await dispatchKey({ char });
96
70
  }
@@ -99,10 +73,6 @@ function definedProps(props) {
99
73
  if (entries.length === 0) return void 0;
100
74
  return Object.fromEntries(entries);
101
75
  }
102
- /**
103
- * Convert a mounted node (or the harness root) into a plain snapshot object
104
- * suitable for `assert.deepEqual` against an inline expected structure.
105
- */
106
76
  function toTreeSnapshot(node) {
107
77
  const snapshot = { type: node.type };
108
78
  if (node.text !== void 0) snapshot.text = node.text;
@@ -111,7 +81,6 @@ function toTreeSnapshot(node) {
111
81
  if (node.children.length > 0) snapshot.children = node.children.map((child) => toTreeSnapshot(child));
112
82
  return snapshot;
113
83
  }
114
- /** Depth-first list of nodes matching a predicate, starting at `node`. */
115
84
  function findNodes(node, predicate) {
116
85
  const matches = [];
117
86
  const visit = (current) => {
@@ -121,13 +90,11 @@ function findNodes(node, predicate) {
121
90
  visit(node);
122
91
  return matches;
123
92
  }
124
- /** First mounted child under the harness root, asserting it exists. */
125
93
  function firstChild(mounted) {
126
94
  const child = mounted.root.children[0];
127
95
  if (!child) throw new Error("expected the mounted tree to have a root child");
128
96
  return child;
129
97
  }
130
- /** Convenience wrapper that renders `component` with `h` and mounts it. */
131
98
  function mountComponent(component, props = {}, slot, options = {}) {
132
99
  return mountFresco(() => h(component, props, slot), options);
133
100
  }
@@ -226,13 +193,6 @@ function getByTestId(root, testId) {
226
193
  }
227
194
  //#endregion
228
195
  //#region src/testing/index.ts
229
- /**
230
- * Test utilities for Fresco component and app behavior.
231
- *
232
- * The harness mounts through the real Vue custom renderer and records frames
233
- * without loading the native terminal binding, so it is safe in plain Node,
234
- * Vitest, and `node:test` suites.
235
- */
236
196
  function nodeText(node) {
237
197
  if (node.text !== void 0) return node.text;
238
198
  const propText = node.props.text ?? node.props.content;
@@ -342,7 +302,6 @@ async function dispatchResize(mounted, width, height) {
342
302
  mounted.appContext.height.value = height;
343
303
  await nextTick();
344
304
  }
345
- /** Mount a Fresco app for tests with frame snapshots and input injection. */
346
305
  function renderTui(root, options = {}) {
347
306
  const mounted = mountFresco(root, options);
348
307
  const frames = [];
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["createRenderer"],"sources":["../../src/testing/mount.ts","../../src/testing/queries.ts","../../src/testing/index.ts"],"sourcesContent":["/**\n * Test-only mount harness for the Fresco JS layer.\n *\n * Fresco's renderer is pure JS up to the byte boundary that crosses into the\n * native module: `renderer.ts` imports only types from `@vizejs/fresco-native`,\n * and `app.ts` loads the native binding lazily and only in interactive mode.\n * This harness mounts components through the real custom renderer with the\n * same provide set `createApp`/`renderToString` install, so tests assert the\n * mounted `FrescoNode` output tree without a native build and without mocks.\n *\n * Not exported from the package entry points; `vp pack` does not ship it.\n */\n\nimport {\n h,\n ref,\n nextTick,\n type App as VueApp,\n type Component,\n type Ref,\n type VNodeChild,\n} from \"vue\";\nimport { SCREEN_READER_KEY } from \"../accessibility.js\";\nimport { lastKeyEvent, type KeyEvent } from \"../app.js\";\nimport { APP_KEY, createAppContext, type UseAppReturn } from \"../composables/useApp.js\";\nimport { createCursorContext, CURSOR_KEY } from \"../composables/useCursor.js\";\nimport { createFocusManager, FOCUS_KEY, type FocusManager } from \"../composables/useFocus.js\";\nimport { createStreamsContext, STREAMS_KEY } from \"../composables/useStreams.js\";\nimport {\n createRenderer,\n type FrescoElement,\n type FrescoNode,\n type FrescoNodeLifecycleHooks,\n} from \"../renderer.js\";\n\n/** Options for {@link mountFresco}. */\nexport interface MountFrescoOptions {\n /** Terminal width provided through the app context. Defaults to 80. */\n width?: number;\n /** Terminal height provided through the app context. Defaults to 24. */\n height?: number;\n /** Initial screen reader mode. Defaults to false. */\n screenReader?: boolean;\n /** Observe host-tree mutations that require a native frame. */\n onMutation?: () => void;\n /** Observe host-node lifecycle transitions. */\n lifecycle?: FrescoNodeLifecycleHooks;\n}\n\n/** A mounted Fresco component tree under test. */\nexport interface MountedFresco {\n /** Root element the Vue app mounted into; children form the output tree. */\n root: FrescoElement;\n /** The Vue app instance (for `provide`-level introspection if needed). */\n app: VueApp<FrescoElement>;\n /** App context provided to composables such as `useApp` and `useWindowSize`. */\n appContext: UseAppReturn;\n /** Focus manager provided to the tree, as the real app would. */\n focusManager: FocusManager;\n /** Screen reader flag provided to the tree; writable to flip modes. */\n screenReaderEnabled: Ref<boolean>;\n /** Renderer controls for stable lookup and recursive disposal. */\n renderer: ReturnType<typeof createRenderer>;\n /** Unmount the tree and dispose all component watchers. */\n unmount(): void;\n}\n\n/**\n * Mount a component (or a plain render function) through the Fresco renderer.\n *\n * The returned {@link MountedFresco.root} is live: re-read it after reactive\n * updates plus `await nextTick()` to observe the patched output tree.\n */\nexport function mountFresco(\n root: Component | (() => VNodeChild),\n options: MountFrescoOptions = {},\n): MountedFresco {\n const renderer = createRenderer({\n onMutation: options.onMutation,\n lifecycle: options.lifecycle,\n });\n const { createApp } = renderer;\n const component: Component = typeof root === \"function\" ? { setup: () => root } : root;\n const app = createApp(component);\n\n const focusManager = createFocusManager();\n const screenReaderEnabled = ref(options.screenReader ?? false);\n const noopWrite = () => {};\n const width = options.width ?? 80;\n const height = options.height ?? 24;\n // A detached stdout stand-in keeps createAppContext from attaching resize\n // listeners to the real process.stdout on every mounted test tree.\n const stdout = {\n isTTY: false,\n columns: width,\n rows: height,\n write: () => true,\n } as unknown as NodeJS.WriteStream;\n\n const appContext = createAppContext({ width, height, stdout });\n app.provide(APP_KEY, appContext);\n app.provide(FOCUS_KEY, focusManager);\n app.provide(SCREEN_READER_KEY, screenReaderEnabled);\n app.provide(CURSOR_KEY, createCursorContext(noopWrite));\n app.provide(\n STREAMS_KEY,\n createStreamsContext({\n interactive: false,\n writeToStdout: noopWrite,\n writeToStderr: noopWrite,\n }),\n );\n\n const rootElement: FrescoElement = {\n id: -1,\n type: \"root\",\n props: {},\n children: [],\n parent: null,\n };\n app.mount(rootElement);\n\n return {\n root: rootElement,\n app,\n appContext,\n focusManager,\n screenReaderEnabled,\n renderer,\n unmount: () => app.unmount(),\n };\n}\n\n/**\n * Dispatch a key event through the same `lastKeyEvent` ref the interactive\n * event loop writes, then wait for watchers to flush.\n *\n * Pass `char` for printable input or `key` for named keys (\"left\", \"enter\",\n * \"backspace\", ...). Modifiers default to false.\n */\nexport function dispatchKey(event: Partial<Omit<KeyEvent, \"type\">>): Promise<void> {\n lastKeyEvent.value = {\n type: \"key\",\n ctrl: false,\n alt: false,\n shift: false,\n meta: false,\n super: false,\n hyper: false,\n capsLock: false,\n numLock: false,\n ...event,\n };\n return nextTick();\n}\n\n/** Dispatch a sequence of printable characters via {@link dispatchKey}. */\nexport async function typeChars(text: string): Promise<void> {\n for (const char of text) {\n await dispatchKey({ char });\n }\n}\n\n/**\n * Serializable snapshot of a mounted output tree.\n *\n * Node ids come from a module-global counter and depend on mount order, and\n * `parent` back-references make trees cyclic, so both are omitted. Props are\n * kept only when defined, so snapshots stay inline-sized and deterministic.\n */\nexport interface FrescoNodeSnapshot {\n type: FrescoNode[\"type\"];\n text?: string;\n props?: Record<string, unknown>;\n children?: FrescoNodeSnapshot[];\n}\n\nfunction definedProps(props: Record<string, unknown>): Record<string, unknown> | undefined {\n const entries = Object.entries(props).filter(([, value]) => value !== undefined);\n if (entries.length === 0) return undefined;\n return Object.fromEntries(entries);\n}\n\n/**\n * Convert a mounted node (or the harness root) into a plain snapshot object\n * suitable for `assert.deepEqual` against an inline expected structure.\n */\nexport function toTreeSnapshot(node: FrescoNode): FrescoNodeSnapshot {\n const snapshot: FrescoNodeSnapshot = { type: node.type };\n if (node.text !== undefined) snapshot.text = node.text;\n const props = definedProps(node.props);\n if (props) snapshot.props = props;\n if (node.children.length > 0) {\n snapshot.children = node.children.map((child) => toTreeSnapshot(child));\n }\n return snapshot;\n}\n\n/** Depth-first list of nodes matching a predicate, starting at `node`. */\nexport function findNodes(\n node: FrescoNode,\n predicate: (candidate: FrescoNode) => boolean,\n): FrescoNode[] {\n const matches: FrescoNode[] = [];\n const visit = (current: FrescoNode) => {\n if (predicate(current)) matches.push(current);\n for (const child of current.children) visit(child);\n };\n visit(node);\n return matches;\n}\n\n/** First mounted child under the harness root, asserting it exists. */\nexport function firstChild(mounted: MountedFresco): FrescoNode {\n const child = mounted.root.children[0];\n if (!child) throw new Error(\"expected the mounted tree to have a root child\");\n return child;\n}\n\n/** Convenience wrapper that renders `component` with `h` and mounts it. */\nexport function mountComponent(\n component: Component,\n props: Record<string, unknown> = {},\n slot?: () => VNodeChild,\n options: MountFrescoOptions = {},\n): MountedFresco {\n return mountFresco(() => h(component, props, slot), options);\n}\n","import type { AriaRole, AriaState } from \"../accessibility.js\";\nimport type { FrescoNode } from \"../renderer.js\";\nimport { findNodes } from \"./mount.js\";\n\nexport type FrescoTextMatcher = string | RegExp;\n\nexport interface FrescoRoleQueryOptions {\n readonly name?: FrescoTextMatcher;\n readonly description?: FrescoTextMatcher;\n readonly state?: AriaState;\n}\n\nfunction stringValue(value: unknown): string | undefined {\n if (typeof value === \"string\" || typeof value === \"number\") return String(value);\n return undefined;\n}\n\nfunction ownText(node: FrescoNode): string | undefined {\n if (node.text !== undefined) return node.text;\n const propText = node.props.text ?? node.props.content;\n if (typeof propText === \"string\" || typeof propText === \"number\") return String(propText);\n\n if (node.type === \"input\") {\n const value = node.props.value;\n const placeholder = node.props.placeholder;\n if (typeof value === \"string\" || typeof value === \"number\") return String(value);\n if (typeof placeholder === \"string\" || typeof placeholder === \"number\")\n return String(placeholder);\n }\n\n return undefined;\n}\n\nfunction accessibleName(node: FrescoNode): string {\n const ariaLabel = stringValue(node.props[\"aria-label\"]);\n if (ariaLabel !== undefined) return ariaLabel;\n\n const text = ownText(node);\n if (text !== undefined) return text;\n\n return node.children\n .map((child) => accessibleName(child))\n .filter(Boolean)\n .join(\" \");\n}\n\nfunction accessibleDescription(node: FrescoNode): string | undefined {\n return stringValue(\n node.props[\"aria-description\"] ?? node.props.ariaDescription ?? node.props.description,\n );\n}\n\nfunction matchesText(text: string, matcher: FrescoTextMatcher): boolean {\n if (typeof matcher === \"string\") return text === matcher;\n matcher.lastIndex = 0;\n return matcher.test(text);\n}\n\nfunction roleOf(node: FrescoNode): AriaRole | undefined {\n return stringValue(node.props[\"aria-role\"]) as AriaRole | undefined;\n}\n\nfunction testIdOf(node: FrescoNode): string | undefined {\n return stringValue(node.props[\"test-id\"] ?? node.props[\"data-testid\"]);\n}\n\nfunction stateOf(node: FrescoNode): AriaState {\n const state = node.props[\"aria-state\"];\n return state && typeof state === \"object\" ? (state as AriaState) : {};\n}\n\nfunction matchesState(node: FrescoNode, expected: AriaState | undefined): boolean {\n if (expected === undefined) return true;\n const actual = stateOf(node);\n return Object.entries(expected).every(([key, value]) => actual[key as keyof AriaState] === value);\n}\n\nfunction describeRole(role: AriaRole, options: FrescoRoleQueryOptions): string {\n const parts = [`role ${JSON.stringify(role)}`];\n if (options.name !== undefined) parts.push(`name ${String(options.name)}`);\n if (options.description !== undefined) parts.push(`description ${String(options.description)}`);\n if (options.state !== undefined) parts.push(`state ${JSON.stringify(options.state)}`);\n return parts.join(\", \");\n}\n\nfunction uniqueNode(nodes: readonly FrescoNode[], description: string): FrescoNode {\n if (nodes.length === 0) throw new Error(`Unable to find Fresco node with ${description}`);\n if (nodes.length > 1) throw new Error(`Found ${nodes.length} Fresco nodes with ${description}`);\n return nodes[0]!;\n}\n\nexport function queryAllByRole(\n root: FrescoNode,\n role: AriaRole,\n options: FrescoRoleQueryOptions = {},\n): FrescoNode[] {\n return findNodes(root, (node) => {\n if (roleOf(node) !== role) return false;\n if (options.name !== undefined && !matchesText(accessibleName(node), options.name))\n return false;\n if (\n options.description !== undefined &&\n !matchesText(accessibleDescription(node) ?? \"\", options.description)\n )\n return false;\n return matchesState(node, options.state);\n });\n}\n\nexport function getByRole(\n root: FrescoNode,\n role: AriaRole,\n options: FrescoRoleQueryOptions = {},\n): FrescoNode {\n return uniqueNode(queryAllByRole(root, role, options), describeRole(role, options));\n}\n\nexport function queryAllByText(root: FrescoNode, text: FrescoTextMatcher): FrescoNode[] {\n return findNodes(root, (node) => {\n const value = ownText(node);\n return value !== undefined && matchesText(value, text);\n });\n}\n\nexport function getByText(root: FrescoNode, text: FrescoTextMatcher): FrescoNode {\n return uniqueNode(queryAllByText(root, text), `text ${String(text)}`);\n}\n\nexport function queryAllByDescription(\n root: FrescoNode,\n description: FrescoTextMatcher,\n): FrescoNode[] {\n return findNodes(root, (node) => {\n const value = accessibleDescription(node);\n return value !== undefined && matchesText(value, description);\n });\n}\n\nexport function getByDescription(root: FrescoNode, description: FrescoTextMatcher): FrescoNode {\n return uniqueNode(queryAllByDescription(root, description), `description ${String(description)}`);\n}\n\nexport function queryAllByTestId(root: FrescoNode, testId: string): FrescoNode[] {\n return findNodes(root, (node) => testIdOf(node) === testId);\n}\n\nexport function getByTestId(root: FrescoNode, testId: string): FrescoNode {\n return uniqueNode(queryAllByTestId(root, testId), `test id ${JSON.stringify(testId)}`);\n}\n","/**\n * Test utilities for Fresco component and app behavior.\n *\n * The harness mounts through the real Vue custom renderer and records frames\n * without loading the native terminal binding, so it is safe in plain Node,\n * Vitest, and `node:test` suites.\n */\n\nimport { nextTick, type Component, type VNodeChild } from \"vue\";\nimport {\n lastCompositionEvent,\n lastFocusEvent,\n lastMouseEvent,\n lastPasteEvent,\n lastResizeEvent,\n type CompositionEvent,\n type FocusEvent,\n type KeyEvent,\n type MouseEvent,\n type PasteEvent,\n type ResizeEvent,\n} from \"../app.js\";\nimport { treeToScreenReaderString } from \"../accessibility.js\";\nimport type { FrescoNode } from \"../renderer.js\";\nimport {\n dispatchKey,\n mountFresco,\n toTreeSnapshot,\n type FrescoNodeSnapshot,\n type MountedFresco,\n type MountFrescoOptions,\n} from \"./mount.js\";\nimport { treeToRenderNodes } from \"../renderer.js\";\nimport { isStaticItemNode, isStaticNode } from \"../staticNodes.js\";\nimport type { FrescoRenderNode } from \"../protocol.js\";\n\nexport {\n dispatchKey,\n findNodes,\n firstChild,\n mountComponent,\n mountFresco,\n toTreeSnapshot,\n typeChars,\n type FrescoNodeSnapshot,\n type MountedFresco,\n type MountFrescoOptions,\n} from \"./mount.js\";\nexport {\n getByDescription,\n getByRole,\n getByTestId,\n getByText,\n queryAllByDescription,\n queryAllByRole,\n queryAllByTestId,\n queryAllByText,\n type FrescoRoleQueryOptions,\n type FrescoTextMatcher,\n} from \"./queries.js\";\nexport type { FrescoRenderNode } from \"../protocol.js\";\n\nexport type RenderTuiOptions = MountFrescoOptions;\nexport type RenderTuiRoot = Component | (() => VNodeChild);\nexport type KeyInput = Partial<Omit<KeyEvent, \"type\">>;\nexport type MouseInput = Omit<MouseEvent, \"type\">;\n\n/** A single recorded harness frame. */\nexport interface FrescoFrameSnapshot {\n /** Plain terminal output projected from the current mounted tree. */\n output: string;\n /** Deterministic semantic text exposed to assistive technology. */\n screenReaderOutput: string;\n /** Serializable renderer tree for structural assertions. */\n tree: FrescoNodeSnapshot;\n /** Stable native protocol payload for assertions before crossing into Rust. */\n protocolNodes: readonly FrescoRenderNode[];\n}\n\n/** Input driver that injects events through Fresco's public event refs. */\nexport interface FrescoInputDriver {\n /** Dispatch a key event and record the resulting frame. */\n key(event: KeyInput): Promise<FrescoFrameSnapshot>;\n /** Dispatch each printable character and record one frame after the text. */\n text(text: string): Promise<FrescoFrameSnapshot>;\n /** Dispatch a bracketed paste payload and record the resulting frame. */\n paste(text: string): Promise<FrescoFrameSnapshot>;\n /** Update the provided app size, dispatch a resize event, and record a frame. */\n resize(width: number, height: number): Promise<FrescoFrameSnapshot>;\n /** Dispatch a mouse event and record the resulting frame. */\n mouse(event: MouseInput): Promise<FrescoFrameSnapshot>;\n /** Dispatch terminal focus state and record the resulting frame. */\n focus(focused: boolean): Promise<FrescoFrameSnapshot>;\n /** Dispatch a composition start event and record the resulting frame. */\n compositionStart(text?: string, cursor?: number): Promise<FrescoFrameSnapshot>;\n /** Dispatch a composition update event and record the resulting frame. */\n compositionUpdate(text: string, cursor: number): Promise<FrescoFrameSnapshot>;\n /** Dispatch a composition end event and record the resulting frame. */\n compositionEnd(text: string, cursor?: number): Promise<FrescoFrameSnapshot>;\n}\n\n/** Mounted TUI harness with frame history and input helpers. */\nexport interface RenderTuiResult extends MountedFresco {\n /** Recorded plain frames, including the initial mount frame. */\n readonly frames: readonly string[];\n /** Recorded frame snapshots, including the initial mount frame. */\n readonly frameSnapshots: readonly FrescoFrameSnapshot[];\n /** Event injection helpers. */\n readonly input: FrescoInputDriver;\n /** Record and return a fresh snapshot of the current mounted tree. */\n captureFrame(): FrescoFrameSnapshot;\n /** Return the latest recorded plain frame. */\n lastFrame(): string;\n /** Return the latest recorded frame snapshot. */\n frameSnapshot(): FrescoFrameSnapshot;\n}\n\nfunction nodeText(node: FrescoNode): string {\n if (node.text !== undefined) return node.text;\n const propText = node.props.text ?? node.props.content;\n if (typeof propText === \"string\" || typeof propText === \"number\") return String(propText);\n if (node.type !== \"input\") return \"\";\n\n const value = node.props.value;\n const placeholder = node.props.placeholder;\n if (typeof value === \"string\" || typeof value === \"number\") return String(value);\n if (typeof placeholder === \"string\" || typeof placeholder === \"number\")\n return String(placeholder);\n return \"\";\n}\n\nfunction joinOutput(parts: readonly string[], separator = \"\\n\"): string {\n return parts.filter(Boolean).join(separator);\n}\n\nfunction normalizeOutput(output: string): string {\n return output.endsWith(\"\\n\") ? output.slice(0, -1) : output;\n}\n\nfunction appendOutput(previous: string, next: string): string {\n const normalized = normalizeOutput(next);\n if (!normalized) return previous;\n return previous ? `${previous}\\n${normalized}` : normalized;\n}\n\nfunction treeToFrameOutput(node: FrescoNode, options: { skipStatic?: boolean } = {}): string {\n if (options.skipStatic && isStaticNode(node)) return \"\";\n\n const ownText = nodeText(node);\n const childOutput = node.children.map((child) => treeToFrameOutput(child, options));\n\n if (node.type === \"text\" || node.type === \"input\") {\n return `${ownText}${childOutput.join(\"\")}`;\n }\n\n const style = (node.props.style ?? {}) as Record<string, unknown>;\n const flexDirection = style.flexDirection ?? style.flex_direction;\n const separator = flexDirection === \"column\" ? \"\\n\" : \"\";\n return joinOutput(childOutput, separator);\n}\n\nfunction captureStaticOutput(node: FrescoNode, renderedStaticItems: Map<number, number>): string {\n const output: string[] = [];\n\n const visit = (current: FrescoNode) => {\n if (isStaticNode(current)) {\n const renderedItems = renderedStaticItems.get(current.id) ?? 0;\n const staticItems = current.children.filter(isStaticItemNode);\n const nextItems = staticItems.slice(renderedItems);\n const nextOutput = joinOutput(\n nextItems.map((child) => treeToFrameOutput(child)),\n \"\\n\",\n );\n if (nextOutput) output.push(nextOutput);\n renderedStaticItems.set(current.id, staticItems.length);\n return;\n }\n\n for (const child of current.children) visit(child);\n };\n\n visit(node);\n return joinOutput(output, \"\\n\");\n}\n\nfunction renderFrame(root: FrescoNode, staticOutput: string): string {\n return joinOutput([staticOutput, treeToFrameOutput(root, { skipStatic: true })], \"\\n\");\n}\n\nfunction latestSnapshot(snapshots: readonly FrescoFrameSnapshot[]): FrescoFrameSnapshot {\n const snapshot = snapshots[snapshots.length - 1];\n if (!snapshot) throw new Error(\"expected renderTui to record an initial frame\");\n return snapshot;\n}\n\nfunction protocolSnapshot(root: FrescoNode): FrescoRenderNode[] {\n const nodes = treeToRenderNodes(root);\n const ids = new Map(nodes.map((node, index) => [node.id, index - 1]));\n return nodes.map((node) => {\n const id = ids.get(node.id) ?? node.id;\n const children = node.children?.map((child) => ids.get(child) ?? child);\n return (\n children === undefined ? { ...node, id } : { ...node, id, children }\n ) as FrescoRenderNode;\n });\n}\n\nasync function dispatchPaste(text: string): Promise<void> {\n const event: PasteEvent = { type: \"paste\", text };\n lastPasteEvent.value = event;\n await nextTick();\n}\n\nasync function dispatchMouse(event: MouseInput): Promise<void> {\n lastMouseEvent.value = { type: \"mouse\", ...event };\n await nextTick();\n}\n\nasync function dispatchFocus(focused: boolean): Promise<void> {\n const event: FocusEvent = { type: \"focus\", focused };\n lastFocusEvent.value = event;\n await nextTick();\n}\n\nasync function dispatchComposition(\n type: CompositionEvent[\"type\"],\n text: string,\n cursor: number,\n): Promise<void> {\n lastCompositionEvent.value = { type, text, cursor };\n await nextTick();\n}\n\nasync function dispatchResize(\n mounted: MountedFresco,\n width: number,\n height: number,\n): Promise<void> {\n const event: ResizeEvent = { type: \"resize\", width, height };\n lastResizeEvent.value = event;\n mounted.appContext.width.value = width;\n mounted.appContext.height.value = height;\n await nextTick();\n}\n\n/** Mount a Fresco app for tests with frame snapshots and input injection. */\nexport function renderTui(root: RenderTuiRoot, options: RenderTuiOptions = {}): RenderTuiResult {\n const mounted = mountFresco(root, options);\n const frames: string[] = [];\n const frameSnapshots: FrescoFrameSnapshot[] = [];\n const renderedStaticItems = new Map<number, number>();\n let staticOutput = \"\";\n\n const captureFrame = () => {\n staticOutput = appendOutput(\n staticOutput,\n captureStaticOutput(mounted.root, renderedStaticItems),\n );\n const snapshot: FrescoFrameSnapshot = {\n output: renderFrame(mounted.root, staticOutput),\n screenReaderOutput: treeToScreenReaderString(mounted.root),\n tree: toTreeSnapshot(mounted.root),\n protocolNodes: protocolSnapshot(mounted.root),\n };\n frames.push(snapshot.output);\n frameSnapshots.push(snapshot);\n return snapshot;\n };\n\n const recordAfter = async (dispatch: Promise<void>) => {\n await dispatch;\n return captureFrame();\n };\n\n const input: FrescoInputDriver = {\n key: (event) => recordAfter(dispatchKey(event)),\n async text(text) {\n for (const char of text) {\n await dispatchKey({ char });\n }\n return captureFrame();\n },\n paste: (text) => recordAfter(dispatchPaste(text)),\n resize: (width, height) => recordAfter(dispatchResize(mounted, width, height)),\n mouse: (event) => recordAfter(dispatchMouse(event)),\n focus: (focused) => recordAfter(dispatchFocus(focused)),\n compositionStart: (text = \"\", cursor = 0) =>\n recordAfter(dispatchComposition(\"compositionstart\", text, cursor)),\n compositionUpdate: (text, cursor) =>\n recordAfter(dispatchComposition(\"compositionupdate\", text, cursor)),\n compositionEnd: (text, cursor = text.length) =>\n recordAfter(dispatchComposition(\"compositionend\", text, cursor)),\n };\n\n captureFrame();\n\n return {\n ...mounted,\n frames,\n frameSnapshots,\n input,\n captureFrame,\n lastFrame: () => latestSnapshot(frameSnapshots).output,\n frameSnapshot: () => latestSnapshot(frameSnapshots),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyEA,SAAgB,YACd,MACA,UAA8B,CAAC,GAChB;CACf,MAAM,WAAWA,iBAAe;EAC9B,YAAY,QAAQ;EACpB,WAAW,QAAQ;CACrB,CAAC;CACD,MAAM,EAAE,cAAc;CAEtB,MAAM,MAAM,UADiB,OAAO,SAAS,aAAa,EAAE,aAAa,KAAK,IAAI,IACnD;CAE/B,MAAM,eAAe,mBAAmB;CACxC,MAAM,sBAAsB,IAAI,QAAQ,gBAAgB,KAAK;CAC7D,MAAM,kBAAkB,CAAC;CACzB,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,eAAe,KAAK,QAAQ;EAC5B,OAAO;CACT;CAEA,MAAM,cAAc,OAAO,aAA4B;EACrD,MAAM;EACN,OAAO,aAAa;CACtB;CAEA,MAAM,QAA2B;EAC/B,MAAM,UAAU,YAAY,YAAY,KAAK,CAAC;EAC9C,MAAM,KAAK,MAAM;GACf,KAAK,MAAM,QAAQ,MACjB,MAAM,YAAY,EAAE,KAAK,CAAC;GAE5B,OAAO,aAAa;EACtB;EACA,QAAQ,SAAS,YAAY,cAAc,IAAI,CAAC;EAChD,SAAS,OAAO,WAAW,YAAY,eAAe,SAAS,OAAO,MAAM,CAAC;EAC7E,QAAQ,UAAU,YAAY,cAAc,KAAK,CAAC;EAClD,QAAQ,YAAY,YAAY,cAAc,OAAO,CAAC;EACtD,mBAAmB,OAAO,IAAI,SAAS,MACrC,YAAY,oBAAoB,oBAAoB,MAAM,MAAM,CAAC;EACnE,oBAAoB,MAAM,WACxB,YAAY,oBAAoB,qBAAqB,MAAM,MAAM,CAAC;EACpE,iBAAiB,MAAM,SAAS,KAAK,WACnC,YAAY,oBAAoB,kBAAkB,MAAM,MAAM,CAAC;CACnE;CAEA,aAAa;CAEb,OAAO;EACL,GAAG;EACH;EACA;EACA;EACA;EACA,iBAAiB,eAAe,cAAc,EAAE;EAChD,qBAAqB,eAAe,cAAc;CACpD;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["createRenderer"],"sources":["../../src/testing/mount.ts","../../src/testing/queries.ts","../../src/testing/index.ts"],"sourcesContent":["/**\n * Mount harness for testing the Fresco JS layer.\n *\n * Fresco's renderer is pure JS up to the byte boundary that crosses into the\n * native module: `renderer.ts` imports only types from `@vizejs/fresco-native`,\n * and `app.ts` loads the native binding lazily and only in interactive mode.\n * This harness mounts components through the real custom renderer with the\n * same provide set `createApp`/`renderToString` install, so tests assert the\n * mounted `FrescoNode` output tree without a native build and without mocks.\n *\n * Published through `@vizejs/fresco/testing` for application and component tests.\n */\n\nimport {\n h,\n ref,\n nextTick,\n type App as VueApp,\n type Component,\n type Ref,\n type VNodeChild,\n} from \"vue\";\nimport { SCREEN_READER_KEY } from \"../accessibility.js\";\nimport { lastKeyEvent, type KeyEvent } from \"../app.js\";\nimport { APP_KEY, createAppContext, type UseAppReturn } from \"../composables/useApp.js\";\nimport { createCursorContext, CURSOR_KEY } from \"../composables/useCursor.js\";\nimport { createFocusManager, FOCUS_KEY, type FocusManager } from \"../composables/useFocus.js\";\nimport { createStreamsContext, STREAMS_KEY } from \"../composables/useStreams.js\";\nimport {\n createRenderer,\n type FrescoElement,\n type FrescoNode,\n type FrescoNodeLifecycleHooks,\n} from \"../renderer.js\";\n\n/** Options for {@link mountFresco}. */\nexport interface MountFrescoOptions {\n /** Terminal width provided through the app context. @default 80 */\n width?: number;\n /** Terminal height provided through the app context. @default 24 */\n height?: number;\n /** Initial screen-reader mode. @default false */\n screenReader?: boolean;\n /** Observe host-tree mutations that require a frame. @default undefined */\n onMutation?: () => void;\n /** Observe host-node lifecycle transitions. @default undefined */\n lifecycle?: FrescoNodeLifecycleHooks;\n}\n\n/** A mounted Fresco component tree under test. */\nexport interface MountedFresco {\n /** Root element the Vue app mounted into; children form the output tree. */\n root: FrescoElement;\n /** The Vue app instance (for `provide`-level introspection if needed). */\n app: VueApp<FrescoElement>;\n /** App context provided to composables such as `useApp` and `useWindowSize`. */\n appContext: UseAppReturn;\n /** Focus manager provided to the tree, as the real app would. */\n focusManager: FocusManager;\n /** Screen reader flag provided to the tree; writable to flip modes. */\n screenReaderEnabled: Ref<boolean>;\n /** Renderer controls for stable lookup and recursive disposal. */\n renderer: ReturnType<typeof createRenderer>;\n /** Unmount the tree and dispose all component watchers. */\n unmount(): void;\n}\n\n/**\n * Mount a component (or a plain render function) through the Fresco renderer.\n *\n * The returned {@link MountedFresco.root} is live: re-read it after reactive\n * updates plus `await nextTick()` to observe the patched output tree.\n */\nexport function mountFresco(\n root: Component | (() => VNodeChild),\n options: MountFrescoOptions = {},\n): MountedFresco {\n const renderer = createRenderer({\n onMutation: options.onMutation,\n lifecycle: options.lifecycle,\n });\n const { createApp } = renderer;\n const component: Component = typeof root === \"function\" ? { setup: () => root } : root;\n const app = createApp(component);\n\n const focusManager = createFocusManager();\n const screenReaderEnabled = ref(options.screenReader ?? false);\n const noopWrite = () => {};\n const width = options.width ?? 80;\n const height = options.height ?? 24;\n // A detached stdout stand-in keeps createAppContext from attaching resize\n // listeners to the real process.stdout on every mounted test tree.\n const stdout = {\n isTTY: false,\n columns: width,\n rows: height,\n write: () => true,\n } as unknown as NodeJS.WriteStream;\n\n const appContext = createAppContext({ width, height, stdout });\n app.provide(APP_KEY, appContext);\n app.provide(FOCUS_KEY, focusManager);\n app.provide(SCREEN_READER_KEY, screenReaderEnabled);\n app.provide(CURSOR_KEY, createCursorContext(noopWrite));\n app.provide(\n STREAMS_KEY,\n createStreamsContext({\n interactive: false,\n writeToStdout: noopWrite,\n writeToStderr: noopWrite,\n }),\n );\n\n const rootElement: FrescoElement = {\n id: -1,\n type: \"root\",\n props: {},\n children: [],\n parent: null,\n };\n app.mount(rootElement);\n\n return {\n root: rootElement,\n app,\n appContext,\n focusManager,\n screenReaderEnabled,\n renderer,\n unmount: () => app.unmount(),\n };\n}\n\n/**\n * Dispatch a key event through the same `lastKeyEvent` ref the interactive\n * event loop writes, then wait for watchers to flush.\n *\n * Pass `char` for printable input or `key` for named keys (\"left\", \"enter\",\n * \"backspace\", ...). Modifiers default to false.\n */\nexport function dispatchKey(event: Partial<Omit<KeyEvent, \"type\">>): Promise<void> {\n lastKeyEvent.value = {\n type: \"key\",\n ctrl: false,\n alt: false,\n shift: false,\n meta: false,\n super: false,\n hyper: false,\n capsLock: false,\n numLock: false,\n ...event,\n };\n return nextTick();\n}\n\n/** Dispatch a sequence of printable characters via {@link dispatchKey}. */\nexport async function typeChars(text: string): Promise<void> {\n for (const char of text) {\n await dispatchKey({ char });\n }\n}\n\n/**\n * Serializable snapshot of a mounted output tree.\n *\n * Node ids come from a module-global counter and depend on mount order, and\n * `parent` back-references make trees cyclic, so both are omitted. Props are\n * kept only when defined, so snapshots stay inline-sized and deterministic.\n */\nexport interface FrescoNodeSnapshot {\n type: FrescoNode[\"type\"];\n text?: string;\n props?: Record<string, unknown>;\n children?: FrescoNodeSnapshot[];\n}\n\nfunction definedProps(props: Record<string, unknown>): Record<string, unknown> | undefined {\n const entries = Object.entries(props).filter(([, value]) => value !== undefined);\n if (entries.length === 0) return undefined;\n return Object.fromEntries(entries);\n}\n\n/**\n * Convert a mounted node (or the harness root) into a plain snapshot object\n * suitable for `assert.deepEqual` against an inline expected structure.\n */\nexport function toTreeSnapshot(node: FrescoNode): FrescoNodeSnapshot {\n const snapshot: FrescoNodeSnapshot = { type: node.type };\n if (node.text !== undefined) snapshot.text = node.text;\n const props = definedProps(node.props);\n if (props) snapshot.props = props;\n if (node.children.length > 0) {\n snapshot.children = node.children.map((child) => toTreeSnapshot(child));\n }\n return snapshot;\n}\n\n/** Depth-first list of nodes matching a predicate, starting at `node`. */\nexport function findNodes(\n node: FrescoNode,\n predicate: (candidate: FrescoNode) => boolean,\n): FrescoNode[] {\n const matches: FrescoNode[] = [];\n const visit = (current: FrescoNode) => {\n if (predicate(current)) matches.push(current);\n for (const child of current.children) visit(child);\n };\n visit(node);\n return matches;\n}\n\n/** First mounted child under the harness root, asserting it exists. */\nexport function firstChild(mounted: MountedFresco): FrescoNode {\n const child = mounted.root.children[0];\n if (!child) throw new Error(\"expected the mounted tree to have a root child\");\n return child;\n}\n\n/** Convenience wrapper that renders `component` with `h` and mounts it. */\nexport function mountComponent(\n component: Component,\n props: Record<string, unknown> = {},\n slot?: () => VNodeChild,\n options: MountFrescoOptions = {},\n): MountedFresco {\n return mountFresco(() => h(component, props, slot), options);\n}\n","import type { AriaRole, AriaState } from \"../accessibility.js\";\nimport type { FrescoNode } from \"../renderer.js\";\nimport { findNodes } from \"./mount.js\";\n\n/** Exact text or a regular expression used by terminal semantic queries. */\nexport type FrescoTextMatcher = string | RegExp;\n\n/** Optional accessible-name, description, and state filters for role queries. */\nexport interface FrescoRoleQueryOptions {\n /** Accessible-name filter; omission accepts every name. @default undefined */\n readonly name?: FrescoTextMatcher;\n /** Accessible-description filter; omission accepts every description. @default undefined */\n readonly description?: FrescoTextMatcher;\n /** Requested state subset compared with strict equality; omission accepts every state. @default undefined */\n readonly state?: AriaState;\n}\n\nfunction stringValue(value: unknown): string | undefined {\n if (typeof value === \"string\" || typeof value === \"number\") return String(value);\n return undefined;\n}\n\nfunction ownText(node: FrescoNode): string | undefined {\n if (node.text !== undefined) return node.text;\n const propText = node.props.text ?? node.props.content;\n if (typeof propText === \"string\" || typeof propText === \"number\") return String(propText);\n\n if (node.type === \"input\") {\n const value = node.props.value;\n const placeholder = node.props.placeholder;\n if (typeof value === \"string\" || typeof value === \"number\") return String(value);\n if (typeof placeholder === \"string\" || typeof placeholder === \"number\")\n return String(placeholder);\n }\n\n return undefined;\n}\n\nfunction accessibleName(node: FrescoNode): string {\n const ariaLabel = stringValue(node.props[\"aria-label\"]);\n if (ariaLabel !== undefined) return ariaLabel;\n\n const text = ownText(node);\n if (text !== undefined) return text;\n\n return node.children\n .map((child) => accessibleName(child))\n .filter(Boolean)\n .join(\" \");\n}\n\nfunction accessibleDescription(node: FrescoNode): string | undefined {\n return stringValue(\n node.props[\"aria-description\"] ?? node.props.ariaDescription ?? node.props.description,\n );\n}\n\nfunction matchesText(text: string, matcher: FrescoTextMatcher): boolean {\n if (typeof matcher === \"string\") return text === matcher;\n matcher.lastIndex = 0;\n return matcher.test(text);\n}\n\nfunction roleOf(node: FrescoNode): AriaRole | undefined {\n return stringValue(node.props[\"aria-role\"]) as AriaRole | undefined;\n}\n\nfunction testIdOf(node: FrescoNode): string | undefined {\n return stringValue(node.props[\"test-id\"] ?? node.props[\"data-testid\"]);\n}\n\nfunction stateOf(node: FrescoNode): AriaState {\n const state = node.props[\"aria-state\"];\n return state && typeof state === \"object\" ? (state as AriaState) : {};\n}\n\nfunction matchesState(node: FrescoNode, expected: AriaState | undefined): boolean {\n if (expected === undefined) return true;\n const actual = stateOf(node);\n return Object.entries(expected).every(([key, value]) => actual[key as keyof AriaState] === value);\n}\n\nfunction describeRole(role: AriaRole, options: FrescoRoleQueryOptions): string {\n const parts = [`role ${JSON.stringify(role)}`];\n if (options.name !== undefined) parts.push(`name ${String(options.name)}`);\n if (options.description !== undefined) parts.push(`description ${String(options.description)}`);\n if (options.state !== undefined) parts.push(`state ${JSON.stringify(options.state)}`);\n return parts.join(\", \");\n}\n\nfunction uniqueNode(nodes: readonly FrescoNode[], description: string): FrescoNode {\n if (nodes.length === 0) throw new Error(`Unable to find Fresco node with ${description}`);\n if (nodes.length > 1) throw new Error(`Found ${nodes.length} Fresco nodes with ${description}`);\n return nodes[0]!;\n}\n\n/** Return every node with the requested semantic role and optional accessibility filters. */\nexport function queryAllByRole(\n root: FrescoNode,\n role: AriaRole,\n options: FrescoRoleQueryOptions = {},\n): FrescoNode[] {\n return findNodes(root, (node) => {\n if (roleOf(node) !== role) return false;\n if (options.name !== undefined && !matchesText(accessibleName(node), options.name))\n return false;\n if (\n options.description !== undefined &&\n !matchesText(accessibleDescription(node) ?? \"\", options.description)\n )\n return false;\n return matchesState(node, options.state);\n });\n}\n\n/** Return the only role match; throw when no node or multiple nodes match. */\nexport function getByRole(\n root: FrescoNode,\n role: AriaRole,\n options: FrescoRoleQueryOptions = {},\n): FrescoNode {\n return uniqueNode(queryAllByRole(root, role, options), describeRole(role, options));\n}\n\n/** Return every node whose own text matches exactly or satisfies the regular expression. */\nexport function queryAllByText(root: FrescoNode, text: FrescoTextMatcher): FrescoNode[] {\n return findNodes(root, (node) => {\n const value = ownText(node);\n return value !== undefined && matchesText(value, text);\n });\n}\n\n/** Return the only text match; throw when no node or multiple nodes match. */\nexport function getByText(root: FrescoNode, text: FrescoTextMatcher): FrescoNode {\n return uniqueNode(queryAllByText(root, text), `text ${String(text)}`);\n}\n\n/** Return every node whose accessible description matches the text or regular expression. */\nexport function queryAllByDescription(\n root: FrescoNode,\n description: FrescoTextMatcher,\n): FrescoNode[] {\n return findNodes(root, (node) => {\n const value = accessibleDescription(node);\n return value !== undefined && matchesText(value, description);\n });\n}\n\n/** Return the only description match; throw when no node or multiple nodes match. */\nexport function getByDescription(root: FrescoNode, description: FrescoTextMatcher): FrescoNode {\n return uniqueNode(queryAllByDescription(root, description), `description ${String(description)}`);\n}\n\n/** Return every node with the exact test-id or data-testid value. */\nexport function queryAllByTestId(root: FrescoNode, testId: string): FrescoNode[] {\n return findNodes(root, (node) => testIdOf(node) === testId);\n}\n\n/** Return the only test-id match; throw when no node or multiple nodes match. */\nexport function getByTestId(root: FrescoNode, testId: string): FrescoNode {\n return uniqueNode(queryAllByTestId(root, testId), `test id ${JSON.stringify(testId)}`);\n}\n","/**\n * Test utilities for Fresco component and app behavior.\n *\n * The harness mounts through the real Vue custom renderer and records frames\n * without loading the native terminal binding, so it is safe in plain Node,\n * Vitest, and `node:test` suites.\n */\n\nimport { nextTick, type Component, type VNodeChild } from \"vue\";\nimport {\n lastCompositionEvent,\n lastFocusEvent,\n lastMouseEvent,\n lastPasteEvent,\n lastResizeEvent,\n type CompositionEvent,\n type FocusEvent,\n type KeyEvent,\n type MouseEvent,\n type PasteEvent,\n type ResizeEvent,\n} from \"../app.js\";\nimport { treeToScreenReaderString } from \"../accessibility.js\";\nimport type { FrescoNode } from \"../renderer.js\";\nimport {\n dispatchKey,\n mountFresco,\n toTreeSnapshot,\n type FrescoNodeSnapshot,\n type MountedFresco,\n type MountFrescoOptions,\n} from \"./mount.js\";\nimport { treeToRenderNodes } from \"../renderer.js\";\nimport { isStaticItemNode, isStaticNode } from \"../staticNodes.js\";\nimport type { FrescoRenderNode } from \"../protocol.js\";\n\nexport {\n dispatchKey,\n findNodes,\n firstChild,\n mountComponent,\n mountFresco,\n toTreeSnapshot,\n typeChars,\n type FrescoNodeSnapshot,\n type MountedFresco,\n type MountFrescoOptions,\n} from \"./mount.js\";\nexport {\n getByDescription,\n getByRole,\n getByTestId,\n getByText,\n queryAllByDescription,\n queryAllByRole,\n queryAllByTestId,\n queryAllByText,\n type FrescoRoleQueryOptions,\n type FrescoTextMatcher,\n} from \"./queries.js\";\nexport type { FrescoRenderNode } from \"../protocol.js\";\n\n/** Initial terminal dimensions, accessibility mode, and renderer observers for the harness. */\nexport type RenderTuiOptions = MountFrescoOptions;\n/** Vue component or render function mounted by the terminal test harness. */\nexport type RenderTuiRoot = Component | (() => VNodeChild);\n/** Key event fields; the driver supplies the event discriminator and false modifier defaults. */\nexport type KeyInput = Partial<Omit<KeyEvent, \"type\">>;\n/** Mouse event fields; the driver supplies the event discriminator. */\nexport type MouseInput = Omit<MouseEvent, \"type\">;\n\n/** A single recorded harness frame. */\nexport interface FrescoFrameSnapshot {\n /** Plain terminal output projected from the current mounted tree. */\n output: string;\n /** Deterministic semantic text exposed to assistive technology. */\n screenReaderOutput: string;\n /** Serializable renderer tree for structural assertions. */\n tree: FrescoNodeSnapshot;\n /** Stable native protocol payload for assertions before crossing into Rust. */\n protocolNodes: readonly FrescoRenderNode[];\n}\n\n/** Input driver that injects events through Fresco's public event refs. */\nexport interface FrescoInputDriver {\n /** Dispatch a key event and record the resulting frame. */\n key(event: KeyInput): Promise<FrescoFrameSnapshot>;\n /** Dispatch each printable character and record one frame after the text. */\n text(text: string): Promise<FrescoFrameSnapshot>;\n /** Dispatch a bracketed paste payload and record the resulting frame. */\n paste(text: string): Promise<FrescoFrameSnapshot>;\n /** Update the provided app size, dispatch a resize event, and record a frame. */\n resize(width: number, height: number): Promise<FrescoFrameSnapshot>;\n /** Dispatch a mouse event and record the resulting frame. */\n mouse(event: MouseInput): Promise<FrescoFrameSnapshot>;\n /** Dispatch terminal focus state and record the resulting frame. */\n focus(focused: boolean): Promise<FrescoFrameSnapshot>;\n /** Dispatch a composition start event and record the resulting frame. */\n compositionStart(text?: string, cursor?: number): Promise<FrescoFrameSnapshot>;\n /** Dispatch a composition update event and record the resulting frame. */\n compositionUpdate(text: string, cursor: number): Promise<FrescoFrameSnapshot>;\n /** Dispatch a composition end event and record the resulting frame. */\n compositionEnd(text: string, cursor?: number): Promise<FrescoFrameSnapshot>;\n}\n\n/** Mounted TUI harness with frame history and input helpers. */\nexport interface RenderTuiResult extends MountedFresco {\n /** Recorded plain frames, including the initial mount frame. */\n readonly frames: readonly string[];\n /** Recorded frame snapshots, including the initial mount frame. */\n readonly frameSnapshots: readonly FrescoFrameSnapshot[];\n /** Event injection helpers. */\n readonly input: FrescoInputDriver;\n /** Record and return a fresh snapshot of the current mounted tree. */\n captureFrame(): FrescoFrameSnapshot;\n /** Return the latest recorded plain frame. */\n lastFrame(): string;\n /** Return the latest recorded frame snapshot. */\n frameSnapshot(): FrescoFrameSnapshot;\n}\n\nfunction nodeText(node: FrescoNode): string {\n if (node.text !== undefined) return node.text;\n const propText = node.props.text ?? node.props.content;\n if (typeof propText === \"string\" || typeof propText === \"number\") return String(propText);\n if (node.type !== \"input\") return \"\";\n\n const value = node.props.value;\n const placeholder = node.props.placeholder;\n if (typeof value === \"string\" || typeof value === \"number\") return String(value);\n if (typeof placeholder === \"string\" || typeof placeholder === \"number\")\n return String(placeholder);\n return \"\";\n}\n\nfunction joinOutput(parts: readonly string[], separator = \"\\n\"): string {\n return parts.filter(Boolean).join(separator);\n}\n\nfunction normalizeOutput(output: string): string {\n return output.endsWith(\"\\n\") ? output.slice(0, -1) : output;\n}\n\nfunction appendOutput(previous: string, next: string): string {\n const normalized = normalizeOutput(next);\n if (!normalized) return previous;\n return previous ? `${previous}\\n${normalized}` : normalized;\n}\n\nfunction treeToFrameOutput(node: FrescoNode, options: { skipStatic?: boolean } = {}): string {\n if (options.skipStatic && isStaticNode(node)) return \"\";\n\n const ownText = nodeText(node);\n const childOutput = node.children.map((child) => treeToFrameOutput(child, options));\n\n if (node.type === \"text\" || node.type === \"input\") {\n return `${ownText}${childOutput.join(\"\")}`;\n }\n\n const style = (node.props.style ?? {}) as Record<string, unknown>;\n const flexDirection = style.flexDirection ?? style.flex_direction;\n const separator = flexDirection === \"column\" ? \"\\n\" : \"\";\n return joinOutput(childOutput, separator);\n}\n\nfunction captureStaticOutput(node: FrescoNode, renderedStaticItems: Map<number, number>): string {\n const output: string[] = [];\n\n const visit = (current: FrescoNode) => {\n if (isStaticNode(current)) {\n const renderedItems = renderedStaticItems.get(current.id) ?? 0;\n const staticItems = current.children.filter(isStaticItemNode);\n const nextItems = staticItems.slice(renderedItems);\n const nextOutput = joinOutput(\n nextItems.map((child) => treeToFrameOutput(child)),\n \"\\n\",\n );\n if (nextOutput) output.push(nextOutput);\n renderedStaticItems.set(current.id, staticItems.length);\n return;\n }\n\n for (const child of current.children) visit(child);\n };\n\n visit(node);\n return joinOutput(output, \"\\n\");\n}\n\nfunction renderFrame(root: FrescoNode, staticOutput: string): string {\n return joinOutput([staticOutput, treeToFrameOutput(root, { skipStatic: true })], \"\\n\");\n}\n\nfunction latestSnapshot(snapshots: readonly FrescoFrameSnapshot[]): FrescoFrameSnapshot {\n const snapshot = snapshots[snapshots.length - 1];\n if (!snapshot) throw new Error(\"expected renderTui to record an initial frame\");\n return snapshot;\n}\n\nfunction protocolSnapshot(root: FrescoNode): FrescoRenderNode[] {\n const nodes = treeToRenderNodes(root);\n const ids = new Map(nodes.map((node, index) => [node.id, index - 1]));\n return nodes.map((node) => {\n const id = ids.get(node.id) ?? node.id;\n const children = node.children?.map((child) => ids.get(child) ?? child);\n return (\n children === undefined ? { ...node, id } : { ...node, id, children }\n ) as FrescoRenderNode;\n });\n}\n\nasync function dispatchPaste(text: string): Promise<void> {\n const event: PasteEvent = { type: \"paste\", text };\n lastPasteEvent.value = event;\n await nextTick();\n}\n\nasync function dispatchMouse(event: MouseInput): Promise<void> {\n lastMouseEvent.value = { type: \"mouse\", ...event };\n await nextTick();\n}\n\nasync function dispatchFocus(focused: boolean): Promise<void> {\n const event: FocusEvent = { type: \"focus\", focused };\n lastFocusEvent.value = event;\n await nextTick();\n}\n\nasync function dispatchComposition(\n type: CompositionEvent[\"type\"],\n text: string,\n cursor: number,\n): Promise<void> {\n lastCompositionEvent.value = { type, text, cursor };\n await nextTick();\n}\n\nasync function dispatchResize(\n mounted: MountedFresco,\n width: number,\n height: number,\n): Promise<void> {\n const event: ResizeEvent = { type: \"resize\", width, height };\n lastResizeEvent.value = event;\n mounted.appContext.width.value = width;\n mounted.appContext.height.value = height;\n await nextTick();\n}\n\n/** Mount a Fresco app for tests with frame snapshots and input injection. */\nexport function renderTui(root: RenderTuiRoot, options: RenderTuiOptions = {}): RenderTuiResult {\n const mounted = mountFresco(root, options);\n const frames: string[] = [];\n const frameSnapshots: FrescoFrameSnapshot[] = [];\n const renderedStaticItems = new Map<number, number>();\n let staticOutput = \"\";\n\n const captureFrame = () => {\n staticOutput = appendOutput(\n staticOutput,\n captureStaticOutput(mounted.root, renderedStaticItems),\n );\n const snapshot: FrescoFrameSnapshot = {\n output: renderFrame(mounted.root, staticOutput),\n screenReaderOutput: treeToScreenReaderString(mounted.root),\n tree: toTreeSnapshot(mounted.root),\n protocolNodes: protocolSnapshot(mounted.root),\n };\n frames.push(snapshot.output);\n frameSnapshots.push(snapshot);\n return snapshot;\n };\n\n const recordAfter = async (dispatch: Promise<void>) => {\n await dispatch;\n return captureFrame();\n };\n\n const input: FrescoInputDriver = {\n key: (event) => recordAfter(dispatchKey(event)),\n async text(text) {\n for (const char of text) {\n await dispatchKey({ char });\n }\n return captureFrame();\n },\n paste: (text) => recordAfter(dispatchPaste(text)),\n resize: (width, height) => recordAfter(dispatchResize(mounted, width, height)),\n mouse: (event) => recordAfter(dispatchMouse(event)),\n focus: (focused) => recordAfter(dispatchFocus(focused)),\n compositionStart: (text = \"\", cursor = 0) =>\n recordAfter(dispatchComposition(\"compositionstart\", text, cursor)),\n compositionUpdate: (text, cursor) =>\n recordAfter(dispatchComposition(\"compositionupdate\", text, cursor)),\n compositionEnd: (text, cursor = text.length) =>\n recordAfter(dispatchComposition(\"compositionend\", text, cursor)),\n };\n\n captureFrame();\n\n return {\n ...mounted,\n frames,\n frameSnapshots,\n input,\n captureFrame,\n lastFrame: () => latestSnapshot(frameSnapshots).output,\n frameSnapshot: () => latestSnapshot(frameSnapshots),\n };\n}\n"],"mappings":";;;AAyEA,SAAgB,YACd,MACA,UAA8B,CAAC,GAChB;CACf,MAAM,WAAWA,iBAAe;EAC9B,YAAY,QAAQ;EACpB,WAAW,QAAQ;CACrB,CAAC;CACD,MAAM,EAAE,cAAc;CAEtB,MAAM,MAAM,UADiB,OAAO,SAAS,aAAa,EAAE,aAAa,KAAK,IAAI,IACnD;CAE/B,MAAM,eAAe,mBAAmB;CACxC,MAAM,sBAAsB,IAAI,QAAQ,gBAAgB,KAAK;CAC7D,MAAM,kBAAkB,CAAC;CACzB,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,SAAS,QAAQ,UAAU;CAUjC,MAAM,aAAa,iBAAiB;EAAE;EAAO;EAAQ,QAAA;GANnD,OAAO;GACP,SAAS;GACT,MAAM;GACN,aAAa;EAG2C;CAAE,CAAC;CAC7D,IAAI,QAAQ,SAAS,UAAU;CAC/B,IAAI,QAAQ,WAAW,YAAY;CACnC,IAAI,QAAQ,mBAAmB,mBAAmB;CAClD,IAAI,QAAQ,YAAY,oBAAoB,SAAS,CAAC;CACtD,IAAI,QACF,aACA,qBAAqB;EACnB,aAAa;EACb,eAAe;EACf,eAAe;CACjB,CAAC,CACH;CAEA,MAAM,cAA6B;EACjC,IAAI;EACJ,MAAM;EACN,OAAO,CAAC;EACR,UAAU,CAAC;EACX,QAAQ;CACV;CACA,IAAI,MAAM,WAAW;CAErB,OAAO;EACL,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,eAAe,IAAI,QAAQ;CAC7B;AACF;AASA,SAAgB,YAAY,OAAuD;CACjF,aAAa,QAAQ;EACnB,MAAM;EACN,MAAM;EACN,KAAK;EACL,OAAO;EACP,MAAM;EACN,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;EACT,GAAG;CACL;CACA,OAAO,SAAS;AAClB;AAGA,eAAsB,U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 -1,18 +1,19 @@
1
1
  import { InjectionKey, Ref } from "vue";
2
2
 
3
3
  //#region src/composables/useFocus.d.ts
4
+ /** Component focus registration, ancestry, delegation, and subtree trapping. */
4
5
  interface UseFocusOptions {
5
- /** Enable or disable this focus target while keeping its logical identity */
6
+ /** Whether this focus target participates in traversal. @default true */
6
7
  isActive?: boolean | Ref<boolean>;
7
- /** Auto-focus this component when nothing else is focused */
8
+ /** Focus this target when no target already owns focus. @default false */
8
9
  autoFocus?: boolean;
9
- /** Focus ID for this element */
10
+ /** Stable logical identity for this focus target. @default A generated "focus-" identifier */
10
11
  id?: string;
11
- /** Parent focus ID used to derive descendant-focus state */
12
+ /** Parent used for descendant state; explicitly supplied undefined or null clears inherited ancestry. @default The injected focus scope, or null */
12
13
  parentId?: string | null | Ref<string | null | undefined>;
13
- /** Descendant that receives focus when this target is focused */
14
+ /** Registered descendant that receives delegated focus. @default null */
14
15
  delegateFocusTo?: string | null | Ref<string | null | undefined>;
15
- /** Keep programmatic and sequential focus inside this target subtree */
16
+ /** Keep programmatic and sequential focus inside this target subtree. @default false */
16
17
  trapFocus?: boolean | Ref<boolean>;
17
18
  }
18
19
  /** Registration state retained for one focusable target. */
@@ -26,6 +27,7 @@ interface FocusRegistrationOptions {
26
27
  /** Registered descendant that receives delegated focus. @default null */
27
28
  delegateFocusTo?: string | null | undefined;
28
29
  }
30
+ /** Ordered focus registry with activation, delegated descendants, and nested trap boundaries. */
29
31
  interface FocusManager {
30
32
  /** Currently focused element ID */
31
33
  focusedId: Ref<string | null>;
@@ -96,6 +98,7 @@ declare function useFocusManager(): {
96
98
  };
97
99
  //#endregion
98
100
  //#region src/composables/useApp.d.ts
101
+ /** Reactive terminal dimensions and lifecycle controls supplied by the application. */
99
102
  interface UseAppReturn {
100
103
  /** Terminal width */
101
104
  width: Ref<number>;
@@ -118,4 +121,4 @@ interface UseAppReturn {
118
121
  declare function useApp(): UseAppReturn;
119
122
  //#endregion
120
123
  export { provideFocusScope as a, UseFocusOptions as i, useApp as n, useFocus as o, FocusManager as r, useFocusManager as s, UseAppReturn as t };
121
- //# sourceMappingURL=useApp-vIRJ5Th3.d.mts.map
124
+ //# sourceMappingURL=useApp-CZwf8lOA.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useApp-CZwf8lOA.d.mts","names":[],"sources":["../src/composables/useFocus.ts","../src/composables/useApp.ts"],"mappings":";;;;UAuBiB,eAAA;EAUmB;EARlC,QAAA,aAAqB,GAAA;EAUI;EARzB,SAAA;EAFA;EAIA,EAAA;EAFA;EAIA,QAAA,mBAA2B,GAAA;EAA3B;EAEA,eAAA,mBAAkC,GAAA;EAAlC;EAEA,SAAA,aAAsB,GAAA;AAAA;;UAIP,wBAAA;EAJU;EAMzB,QAAA;EAFuC;EAIvC,SAAA;EAJuC;EAMvC,QAAA;EAFA;EAIA,eAAA;AAAA;;UAIe,YAAA;EAAA;EAEf,SAAA,EAAW,GAAA;;EAEX,QAAA,EAAU,QAAA,CAAS,GAAA;EAAA;EAEnB,YAAA,EAAc,QAAA,CAAS,GAAA;EAAA;EAEvB,YAAA,EAAc,QAAA,CAAS,GAAA;EAAA;EAEvB,SAAA,EAAW,GAAA;EAAA;EAEX,WAAA;EAUyD;EARzD,YAAA;EAZA;EAcA,KAAA,GAAQ,EAAA;EAZR;EAcA,SAAA;EAdmB;EAgBnB,aAAA;EAdc;EAgBd,QAAA,GAAW,EAAA,UAAY,OAAA,GAAU,wBAAA;EAdjC;EAgBA,UAAA,GAAa,EAAA;EAhBU;EAkBvB,SAAA,GAAY,EAAA,UAAY,QAAA;EAhBb;EAkBX,SAAA,GAAY,EAAA,UAAY,QAAA;EAdxB;EAgBA,WAAA,GAAc,EAAA,UAAY,eAAA;EAdlB;EAgBR,SAAA,GAAY,EAAA;EAZZ;EAcA,gBAAA,GAAmB,EAAA;EAZR;EAcX,oBAAA,GAAuB,EAAA;AAAA;;iBAiPT,iBAAA,CAAkB,QAAwD,kBAA9B,GAAG;;;;iBAO/C,QAAA,CAAS,OAAA,GAAS,eAAoB;;;;;;;;;;AAPoC;iBAkH1E,eAAA;;;;;;;;;4BAzWU,eAAA;;;;;;;;UCvET,YAAA;EDuBmB;ECrBlC,KAAA,EAAO,GAAA;EDuBkB;ECrBzB,MAAA,EAAQ,GAAA;EDWR;ECTA,SAAA,EAAW,GAAA;EDWX;ECTA,IAAA,GAAO,aAAA;EDaP;ECXA,MAAA;EDaA;ECXA,KAAA;EDaA;ECXA,oBAAA,QAA4B,OAAA;AAAA;;;;iBAyEd,MAAA,IAAU,YAAY"}
@@ -1,17 +1,11 @@
1
- import { F as isScreenReaderEnabledByDefault, P as SCREEN_READER_KEY, T as useStreamsContext, a as lastMouseEvent, g as updateLastRenderLayouts, i as lastKeyEvent, m as getLastRenderLayout, n as lastCompositionEvent, o as lastPasteEvent } from "./app-CDSThgku.mjs";
1
+ import { F as SCREEN_READER_KEY, I as isScreenReaderEnabledByDefault, T as useStreamsContext, a as lastMouseEvent, g as updateLastRenderLayouts, i as lastKeyEvent, m as getLastRenderLayout, n as lastCompositionEvent, o as lastPasteEvent } from "./app-ByxmaQXv.mjs";
2
2
  import { computed, inject, isRef, onMounted, onUnmounted, reactive, ref, watch } from "vue";
3
3
  //#region src/composables/useIsScreenReaderEnabled.ts
4
- /**
5
- * useIsScreenReaderEnabled - screen reader mode flag.
6
- */
7
4
  function useIsScreenReaderEnabled() {
8
5
  return inject(SCREEN_READER_KEY, null)?.value ?? isScreenReaderEnabledByDefault();
9
6
  }
10
7
  //#endregion
11
8
  //#region src/composables/usePaste.ts
12
- /**
13
- * usePaste - bracketed paste handling.
14
- */
15
9
  let activePasteHandlerCount = 0;
16
10
  function hasActivePasteHandlers() {
17
11
  return activePasteHandlerCount > 0;
@@ -63,9 +57,6 @@ function usePaste(handler, options = {}) {
63
57
  }
64
58
  //#endregion
65
59
  //#region src/composables/useInput.ts
66
- /**
67
- * useInput - Input handling composable
68
- */
69
60
  function toRef(value) {
70
61
  return isRef(value) ? value : ref(value);
71
62
  }
@@ -204,9 +195,6 @@ function useInput(handlerOrOptions = {}, handlerOptions = {}) {
204
195
  disable
205
196
  };
206
197
  }
207
- /**
208
- * Shorthand for handling specific key combinations
209
- */
210
198
  function useKeyPress(key, handler, options = {}) {
211
199
  const { ctrl = false, alt = false, shift = false, meta = false } = options;
212
200
  useInput({ onKey: (pressedKey, modifiers) => {
@@ -215,8 +203,6 @@ function useKeyPress(key, handler, options = {}) {
215
203
  }
216
204
  //#endregion
217
205
  //#region src/composables/useMouse.ts
218
- /** Mouse and wheel input handling for focused Fresco surfaces. */
219
- /** Subscribe to normalized mouse actions, including wheel direction. */
220
206
  function useMouse(handler, options = {}) {
221
207
  const externalIsActive = isRef(options.isActive) ? options.isActive : void 0;
222
208
  const locallyEnabled = ref(externalIsActive ? true : options.isActive ?? true);
@@ -236,12 +222,10 @@ function useMouse(handler, options = {}) {
236
222
  }
237
223
  //#endregion
238
224
  //#region src/composables/useVirtualViewport.ts
239
- /** Bounded viewport state for large terminal collections. */
240
225
  function count(value, name) {
241
226
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name} must be a non-negative safe integer`);
242
227
  return value;
243
228
  }
244
- /** Create viewport state whose retained range scales with visible rows, not item count. */
245
229
  function createVirtualViewport(options) {
246
230
  const itemCount = ref(count(options.itemCount, "itemCount"));
247
231
  const viewportSize = ref(count(options.viewportSize, "viewportSize"));
@@ -320,13 +304,9 @@ function createVirtualViewport(options) {
320
304
  scrollIntoView
321
305
  };
322
306
  }
323
- /** Composition API alias for {@link createVirtualViewport}. */
324
307
  const useVirtualViewport = createVirtualViewport;
325
308
  //#endregion
326
309
  //#region src/composables/useBoxMetrics.ts
327
- /**
328
- * useBoxMetrics - best-effort layout metrics for a rendered Fresco node.
329
- */
330
310
  async function loadNative() {
331
311
  return import("@vizejs/fresco-native");
332
312
  }
@@ -385,4 +365,4 @@ function useBoxMetrics(ref) {
385
365
  //#endregion
386
366
  export { useInput as a, useIsScreenReaderEnabled as c, useMouse as i, createVirtualViewport as n, useKeyPress as o, useVirtualViewport as r, usePaste as s, useBoxMetrics as t };
387
367
 
388
- //# sourceMappingURL=useBoxMetrics-9FFVE-tA.mjs.map
368
+ //# sourceMappingURL=useBoxMetrics-DyBYcQEp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBoxMetrics-DyBYcQEp.mjs","names":["toRef"],"sources":["../src/composables/useIsScreenReaderEnabled.ts","../src/composables/usePaste.ts","../src/composables/useInput.ts","../src/composables/useMouse.ts","../src/composables/useVirtualViewport.ts","../src/composables/useBoxMetrics.ts"],"sourcesContent":["/**\n * useIsScreenReaderEnabled - screen reader mode flag.\n */\n\nimport { inject } from \"vue\";\nimport { SCREEN_READER_KEY, isScreenReaderEnabledByDefault } from \"../accessibility.js\";\n\n/** Read the current screen-reader mode as a boolean snapshot. */\nexport function useIsScreenReaderEnabled(): boolean {\n const enabled = inject(SCREEN_READER_KEY, null);\n return enabled?.value ?? isScreenReaderEnabledByDefault();\n}\n","/**\n * usePaste - bracketed paste handling.\n */\n\nimport { isRef, onUnmounted, ref, watch, type Ref } from \"vue\";\nimport { lastPasteEvent } from \"../app.js\";\nimport { useStreamsContext } from \"./useStreams.js\";\n\nlet activePasteHandlerCount = 0;\n\n/** Activation for whole bracketed-paste delivery and terminal-mode ownership. */\nexport interface UsePasteOptions {\n /** Whether this handler owns whole paste delivery. @default true */\n isActive?: boolean | Ref<boolean>;\n}\n\n/** Whether dedicated active handlers currently own whole paste delivery. */\nexport function hasActivePasteHandlers(): boolean {\n return activePasteHandlerCount > 0;\n}\n\nfunction toRef(value: boolean | Ref<boolean>): Ref<boolean> {\n return isRef(value) ? value : ref(value);\n}\n\n/** Deliver whole paste payloads while balancing raw-mode and bracketed-paste requests; release ownership on unmount. */\nexport function usePaste(handler: (text: string) => void, options: UsePasteOptions = {}) {\n const isActive = toRef(options.isActive ?? true);\n const streams = useStreamsContext();\n let rawModeEnabled = false;\n let bracketedPasteEnabled = false;\n let pasteHandlerRegistered = false;\n\n const syncRawMode = (isEnabled: boolean) => {\n if (rawModeEnabled === isEnabled) return;\n streams.setRawMode(isEnabled);\n rawModeEnabled = isEnabled;\n };\n\n const syncBracketedPasteMode = (isEnabled: boolean) => {\n if (bracketedPasteEnabled === isEnabled) return;\n streams.setBracketedPasteMode(isEnabled);\n bracketedPasteEnabled = isEnabled;\n };\n\n const syncPasteRegistration = (isEnabled: boolean) => {\n if (pasteHandlerRegistered === isEnabled) return;\n activePasteHandlerCount += isEnabled ? 1 : -1;\n pasteHandlerRegistered = isEnabled;\n };\n\n const syncActiveState = (isEnabled: boolean) => {\n syncRawMode(isEnabled);\n syncBracketedPasteMode(isEnabled);\n syncPasteRegistration(isEnabled);\n };\n\n watch(lastPasteEvent, (event) => {\n if (!event || !isActive.value) return;\n handler(event.text);\n });\n\n watch(isActive, syncActiveState, { immediate: true });\n onUnmounted(() => syncActiveState(false));\n\n return {\n isActive,\n enable: () => {\n isActive.value = true;\n },\n disable: () => {\n isActive.value = false;\n },\n };\n}\n","/**\n * useInput - Input handling composable\n */\n\nimport { isRef, onUnmounted, ref, watch, type Ref } from \"vue\";\nimport { lastCompositionEvent, lastKeyEvent, lastPasteEvent, type KeyEvent } from \"../app.js\";\nimport { hasActivePasteHandlers } from \"./usePaste.js\";\nimport { useStreamsContext } from \"./useStreams.js\";\n\n/** Normalized compatibility flags for a delivered terminal key event. */\nexport interface Key {\n upArrow: boolean;\n downArrow: boolean;\n leftArrow: boolean;\n rightArrow: boolean;\n pageDown: boolean;\n pageUp: boolean;\n home: boolean;\n end: boolean;\n return: boolean;\n escape: boolean;\n ctrl: boolean;\n shift: boolean;\n tab: boolean;\n backspace: boolean;\n delete: boolean;\n meta: boolean;\n super: boolean;\n hyper: boolean;\n capsLock: boolean;\n numLock: boolean;\n eventType?: \"press\" | \"repeat\" | \"release\";\n}\n\n/** Receive a normalized key name and exact modifier state. */\nexport interface KeyHandler {\n (key: string, modifiers: { ctrl: boolean; alt: boolean; shift: boolean; meta: boolean }): void;\n}\n\n/** Activation and callbacks for key, character, paste, and composition input. */\nexport interface UseInputOptions {\n /** Activation flag used when isActive is omitted. @default true */\n active?: boolean | Ref<boolean>;\n /** Activation flag that takes precedence over active. @default active ?? true */\n isActive?: boolean | Ref<boolean>;\n /** Receive printable input and normalized compatibility key flags. @default undefined */\n handler?: (input: string, key: Key) => void;\n /** Receive normalized key names with exact modifier state. @default undefined */\n onKey?: KeyHandler;\n /** Receive printable text without command modifiers. @default undefined */\n onChar?: (char: string) => void;\n /** Receive the normalized Enter key. @default undefined */\n onSubmit?: () => void;\n /** Receive the normalized Escape key. @default undefined */\n onEscape?: () => void;\n /** Receive normalized arrow directions. @default undefined */\n onArrow?: (direction: \"up\" | \"down\" | \"left\" | \"right\") => void;\n /** Receive the start of IME preedit. @default undefined */\n onCompositionStart?: () => void;\n /** Receive an IME preedit update. @default undefined */\n onCompositionUpdate?: (text: string, cursor: number) => void;\n /** Receive committed IME composition text. @default undefined */\n onCompositionEnd?: (text: string) => void;\n /** Whether this handler owns Ctrl+C delivery. @default false */\n captureCtrlC?: boolean;\n}\n\n/** Mutable activation and the latest delivered key or printable text. */\nexport interface UseInputReturn {\n isActive: Ref<boolean>;\n lastKey: Ref<string | null>;\n enable: () => void;\n disable: () => void;\n}\n\n/** Receive printable input with normalized compatibility key flags. */\nexport type InputHandler = (input: string, key: Key) => void;\n\n/** Activation for the callback overload of useInput. */\nexport interface UseInputHandlerOptions {\n /** Whether the callback overload receives terminal input. @default true */\n isActive?: boolean | Ref<boolean>;\n}\n\nfunction toRef(value: boolean | Ref<boolean>): Ref<boolean> {\n return isRef(value) ? value : ref(value);\n}\n\nfunction keyName(event: KeyEvent): string {\n return event.char ?? event.key ?? \"\";\n}\n\nfunction toInkKey(event: KeyEvent): Key {\n const key = event.key;\n\n return {\n upArrow: key === \"up\",\n downArrow: key === \"down\",\n leftArrow: key === \"left\",\n rightArrow: key === \"right\",\n pageDown: key === \"pagedown\" || key === \"pageDown\",\n pageUp: key === \"pageup\" || key === \"pageUp\",\n home: key === \"home\",\n end: key === \"end\",\n return: key === \"enter\" || key === \"return\",\n escape: key === \"escape\" || key === \"esc\",\n ctrl: event.ctrl,\n shift: event.shift,\n tab: key === \"tab\" || key === \"backtab\",\n backspace: key === \"backspace\",\n delete: key === \"delete\",\n meta: event.meta,\n super: event.super,\n hyper: event.hyper,\n capsLock: event.capsLock,\n numLock: event.numLock,\n eventType: event.eventType,\n };\n}\n\nfunction emptyKey(): Key {\n return {\n upArrow: false,\n downArrow: false,\n leftArrow: false,\n rightArrow: false,\n pageDown: false,\n pageUp: false,\n home: false,\n end: false,\n return: false,\n escape: false,\n ctrl: false,\n shift: false,\n tab: false,\n backspace: false,\n delete: false,\n meta: false,\n super: false,\n hyper: false,\n capsLock: false,\n numLock: false,\n };\n}\n\nfunction inputValue(event: KeyEvent, key: Key): string {\n if (event.char) return event.char;\n if (key.return) return \"\\r\";\n return \"\";\n}\n\nfunction handleStructuredOptions(\n event: KeyEvent,\n options: UseInputOptions,\n lastKey: Ref<string | null>,\n) {\n const modifiers = {\n ctrl: event.ctrl,\n alt: event.alt,\n shift: event.shift,\n meta: event.meta,\n };\n const pressedKey = keyName(event);\n const inkKey = toInkKey(event);\n\n if (event.char) {\n lastKey.value = event.char;\n // Modified character chords represent commands, not text insertion. AltGr\n // terminals report their committed text without these command modifiers.\n if (!event.ctrl && !event.alt && !event.meta) options.onChar?.(event.char);\n options.onKey?.(event.char, modifiers);\n return;\n }\n\n if (pressedKey) {\n lastKey.value = pressedKey;\n options.onKey?.(pressedKey, modifiers);\n }\n\n if (inkKey.return) options.onSubmit?.();\n if (inkKey.escape) options.onEscape?.();\n if (inkKey.upArrow) options.onArrow?.(\"up\");\n if (inkKey.downArrow) options.onArrow?.(\"down\");\n if (inkKey.leftArrow) options.onArrow?.(\"left\");\n if (inkKey.rightArrow) options.onArrow?.(\"right\");\n}\n\n/** Observe normalized terminal input while active and release input watchers and mode requests when the component unmounts. */\nexport function useInput(handler: InputHandler, options?: UseInputHandlerOptions): UseInputReturn;\nexport function useInput(options?: UseInputOptions): UseInputReturn;\nexport function useInput(\n handlerOrOptions: InputHandler | UseInputOptions = {},\n handlerOptions: UseInputHandlerOptions = {},\n): UseInputReturn {\n const options =\n typeof handlerOrOptions === \"function\"\n ? { handler: handlerOrOptions, isActive: handlerOptions.isActive }\n : handlerOrOptions;\n\n const activeSource = options.isActive ?? options.active ?? true;\n const isActive = toRef(activeSource);\n const lastKey = ref<string | null>(null);\n const streams = useStreamsContext();\n let rawModeEnabled = false;\n\n const syncRawMode = (isEnabled: boolean) => {\n if (rawModeEnabled === isEnabled) return;\n streams.setRawMode(isEnabled);\n rawModeEnabled = isEnabled;\n };\n\n watch(lastKeyEvent, (event) => {\n if (!event || !isActive.value) return;\n\n const inkKey = toInkKey(event);\n const input = inputValue(event, inkKey);\n const pressedKey = keyName(event);\n\n if (input === \"c\" && inkKey.ctrl && streams.internal_exitOnCtrlC && !options.captureCtrlC)\n return;\n\n lastKey.value = pressedKey || null;\n options.handler?.(input, inkKey);\n handleStructuredOptions(event, options, lastKey);\n });\n\n watch(lastPasteEvent, (event) => {\n if (!event || !isActive.value || hasActivePasteHandlers()) return;\n\n lastKey.value = event.text;\n options.handler?.(event.text, emptyKey());\n options.onChar?.(event.text);\n });\n\n watch(lastCompositionEvent, (event) => {\n if (!event || !isActive.value) return;\n\n if (event.type === \"compositionstart\") {\n options.onCompositionStart?.();\n } else if (event.type === \"compositionupdate\") {\n options.onCompositionUpdate?.(event.text, event.cursor);\n } else {\n options.onCompositionEnd?.(event.text);\n }\n });\n\n watch(isActive, syncRawMode, { immediate: true });\n onUnmounted(() => syncRawMode(false));\n\n const enable = () => {\n isActive.value = true;\n };\n\n const disable = () => {\n isActive.value = false;\n };\n\n return {\n isActive,\n lastKey,\n enable,\n disable,\n };\n}\n\n/**\n * Shorthand for handling specific key combinations\n */\nexport function useKeyPress(\n key: string,\n handler: () => void,\n options: { ctrl?: boolean; alt?: boolean; shift?: boolean; meta?: boolean } = {},\n) {\n const { ctrl = false, alt = false, shift = false, meta = false } = options;\n\n useInput({\n onKey: (pressedKey, modifiers) => {\n const matches =\n pressedKey.toLowerCase() === key.toLowerCase() &&\n modifiers.ctrl === ctrl &&\n modifiers.alt === alt &&\n modifiers.shift === shift &&\n modifiers.meta === meta;\n\n if (matches) {\n handler();\n }\n },\n });\n}\n","/** Mouse and wheel input handling for focused Fresco surfaces. */\n\nimport { computed, isRef, ref, watch, type Ref } from \"vue\";\nimport { lastMouseEvent } from \"../app.js\";\nimport type { MouseEvent } from \"../protocol.js\";\n\n/** External activation gate for normalized terminal mouse and wheel events. */\nexport interface UseMouseOptions {\n /** External activation gate; local enable cannot override a false external ref. @default true */\n isActive?: boolean | Readonly<Ref<boolean>>;\n}\n\n/** Readonly effective activation, local enable and disable commands, and explicit watcher disposal. */\nexport interface UseMouseReturn {\n isActive: Readonly<Ref<boolean>>;\n /** Start delivering normalized mouse events. */\n enable: () => void;\n /** Stop delivering normalized mouse events. */\n disable: () => void;\n /** Unsubscribe the handler from the shared mouse event stream. */\n stop: () => void;\n}\n\n/** Subscribe to normalized mouse actions, including wheel direction. */\nexport function useMouse(\n handler: (event: MouseEvent) => void,\n options: UseMouseOptions = {},\n): UseMouseReturn {\n const externalIsActive = isRef(options.isActive) ? options.isActive : undefined;\n const locallyEnabled = ref(externalIsActive ? true : (options.isActive ?? true));\n const isActive = computed(() => locallyEnabled.value && (externalIsActive?.value ?? true));\n\n const stop = watch(\n lastMouseEvent,\n (event) => {\n if (event && isActive.value) handler(event);\n },\n { flush: \"sync\" },\n );\n\n return {\n isActive,\n enable: () => {\n locallyEnabled.value = true;\n },\n disable: () => {\n locallyEnabled.value = false;\n },\n stop,\n };\n}\n","/** Bounded viewport state for large terminal collections. */\n\nimport { computed, ref, type ComputedRef, type Ref } from \"vue\";\n\n/** Alignment used when revealing a collection item. */\nexport type VirtualScrollAlignment = \"nearest\" | \"start\" | \"center\" | \"end\";\n\n/** Visible and overscanned half-open item-index ranges. */\nexport interface VirtualViewportRange {\n /** First item occupying the viewport. */\n visibleStart: number;\n /** Exclusive end of items occupying the viewport. */\n visibleEnd: number;\n /** First retained item, including leading overscan. */\n overscanStart: number;\n /** Exclusive end of retained items, including trailing overscan. */\n overscanEnd: number;\n}\n\n/** Collection size, visible capacity, overscan, and initial scroll offset. */\nexport interface VirtualViewportOptions {\n itemCount: number;\n viewportSize: number;\n /** Extra retained items before and after the visible range. @default 2 */\n overscan?: number;\n /** Initial item offset, clamped to the current scrollable range. @default 0 */\n initialOffset?: number;\n}\n\n/** Bounded reactive collection offsets and range controls; counts must be nonnegative safe integers. */\nexport interface VirtualViewport {\n readonly itemCount: Readonly<Ref<number>>;\n readonly viewportSize: Readonly<Ref<number>>;\n readonly overscan: Readonly<Ref<number>>;\n readonly offset: Readonly<Ref<number>>;\n readonly maxOffset: ComputedRef<number>;\n readonly atStart: ComputedRef<boolean>;\n readonly atEnd: ComputedRef<boolean>;\n readonly range: ComputedRef<VirtualViewportRange>;\n /** Replace the collection size and clamp the current offset. */\n setItemCount(value: number): boolean;\n /** Replace the visible row count and clamp the current offset. */\n setViewportSize(value: number): boolean;\n /** Replace the number of retained rows on each side of the viewport. */\n setOverscan(value: number): boolean;\n /** Move to an absolute, bounded offset. */\n scrollTo(offset: number): boolean;\n /** Move by a signed row delta. */\n scrollBy(delta: number): boolean;\n /** Reveal one item using the requested viewport alignment. */\n scrollIntoView(index: number, alignment?: VirtualScrollAlignment): boolean;\n}\n\nfunction count(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new RangeError(`${name} must be a non-negative safe integer`);\n }\n return value;\n}\n\n/** Create viewport state whose retained range scales with visible rows, not item count. */\nexport function createVirtualViewport(options: VirtualViewportOptions): VirtualViewport {\n const itemCount = ref(count(options.itemCount, \"itemCount\"));\n const viewportSize = ref(count(options.viewportSize, \"viewportSize\"));\n const overscan = ref(count(options.overscan ?? 2, \"overscan\"));\n const offset = ref(0);\n const maxOffset = computed(() => Math.max(0, itemCount.value - viewportSize.value));\n const atStart = computed(() => offset.value === 0);\n const atEnd = computed(() => offset.value === maxOffset.value);\n const range = computed<VirtualViewportRange>(() => {\n const visibleStart = Math.min(offset.value, itemCount.value);\n const visibleEnd = Math.min(itemCount.value, visibleStart + viewportSize.value);\n return {\n visibleStart,\n visibleEnd,\n overscanStart: Math.max(0, visibleStart - overscan.value),\n overscanEnd: Math.min(itemCount.value, visibleEnd + overscan.value),\n };\n });\n\n const scrollTo = (value: number) => {\n const next = Math.min(maxOffset.value, count(value, \"offset\"));\n if (next === offset.value) return false;\n offset.value = next;\n return true;\n };\n const clamp = () => scrollTo(Math.min(offset.value, maxOffset.value));\n\n const setItemCount = (value: number) => {\n const next = count(value, \"itemCount\");\n if (next === itemCount.value) return false;\n itemCount.value = next;\n clamp();\n return true;\n };\n const setViewportSize = (value: number) => {\n const next = count(value, \"viewportSize\");\n if (next === viewportSize.value) return false;\n viewportSize.value = next;\n clamp();\n return true;\n };\n const setOverscan = (value: number) => {\n const next = count(value, \"overscan\");\n if (next === overscan.value) return false;\n overscan.value = next;\n return true;\n };\n const scrollBy = (delta: number) => {\n if (!Number.isSafeInteger(delta)) throw new RangeError(\"delta must be a safe integer\");\n return scrollTo(Math.max(0, offset.value + delta));\n };\n const scrollIntoView = (index: number, alignment: VirtualScrollAlignment = \"nearest\") => {\n count(index, \"index\");\n if (index >= itemCount.value || viewportSize.value === 0) return false;\n let next = offset.value;\n if (alignment === \"start\") next = index;\n else if (alignment === \"center\") next = Math.max(0, index - Math.floor(viewportSize.value / 2));\n else if (alignment === \"end\") next = Math.max(0, index + 1 - viewportSize.value);\n else if (index < offset.value) next = index;\n else if (index >= offset.value + viewportSize.value) {\n next = index + 1 - viewportSize.value;\n }\n return scrollTo(next);\n };\n\n scrollTo(options.initialOffset ?? 0);\n\n return {\n itemCount,\n viewportSize,\n overscan,\n offset,\n maxOffset,\n atStart,\n atEnd,\n range,\n setItemCount,\n setViewportSize,\n setOverscan,\n scrollTo,\n scrollBy,\n scrollIntoView,\n };\n}\n\n/** Composition API alias for {@link createVirtualViewport}. */\nexport const useVirtualViewport = createVirtualViewport;\n","/**\n * useBoxMetrics - best-effort layout metrics for a rendered Fresco node.\n */\n\nimport { onMounted, onUnmounted, reactive, type Ref } from \"vue\";\nimport { getLastRenderLayout, updateLastRenderLayouts, type DOMElement } from \"../layoutMetrics.js\";\n\n/** Last measured layout rectangle in terminal cells. */\nexport interface BoxMetrics {\n width: number;\n height: number;\n left: number;\n top: number;\n}\n\n/** Measured rectangle, measurement-state flag, and an explicit refresh request. */\nexport interface UseBoxMetricsResult extends BoxMetrics {\n hasMeasured: boolean;\n /** Refresh from the latest completed native layout snapshot. */\n refresh(): void;\n}\n\n/** Host node or component element accepted by terminal layout measurement. */\nexport type MetricTarget = DOMElement;\n\nasync function loadNative() {\n return import(\"@vizejs/fresco-native\");\n}\n\nfunction targetId(target: MetricTarget | null | undefined): number | undefined {\n return target?.id ?? target?.$el?.id;\n}\n\n/** Read completed layout measurements, falling back to native measurement; poll after mount and stop on unmount. */\nexport function useBoxMetrics(ref: Ref<MetricTarget | null>): UseBoxMetricsResult {\n const metrics = reactive({\n width: 0,\n height: 0,\n left: 0,\n top: 0,\n hasMeasured: false,\n }) as UseBoxMetricsResult;\n\n let timer: ReturnType<typeof setInterval> | null = null;\n\n const applyLayout = (layout: { width: number; height: number; x: number; y: number }) => {\n metrics.width = layout.width;\n metrics.height = layout.height;\n metrics.left = layout.x;\n metrics.top = layout.y;\n metrics.hasMeasured = true;\n };\n\n const refresh = () => {\n const id = targetId(ref.value);\n if (id === undefined) {\n metrics.width = 0;\n metrics.height = 0;\n metrics.left = 0;\n metrics.top = 0;\n metrics.hasMeasured = false;\n return;\n }\n\n const cachedLayout = getLastRenderLayout(ref.value);\n if (cachedLayout) {\n applyLayout(cachedLayout);\n return;\n }\n\n void loadNative()\n .then((native) => {\n const layouts = \"getLastRenderLayouts\" in native ? native.getLastRenderLayouts() : [];\n updateLastRenderLayouts(layouts);\n const layout = layouts.find((item: { id: number }) => item.id === id);\n if (!layout) return;\n\n applyLayout(layout);\n })\n .catch(() => {});\n };\n\n metrics.refresh = refresh;\n\n onMounted(() => {\n refresh();\n timer = setInterval(refresh, 100);\n });\n\n onUnmounted(() => {\n if (timer) clearInterval(timer);\n });\n\n return metrics;\n}\n"],"mappings":";;;AAQA,SAAgB,2BAAoC;CAElD,OADgB,OAAO,mBAAmB,IAC7B,GAAG,SAAS,+BAA+B;AAC1D;;;ACHA,IAAI,0BAA0B;AAS9B,SAAgB,yBAAkC;CAChD,OAAO,0BAA0B;AACnC;AAEA,SAASA,QAAM,OAA6C;CAC1D,OAAO,MAAM,KAAK,IAAI,QAAQ,IAAI,KAAK;AACzC;AAGA,SAAgB,SAAS,SAAiC,UAA2B,CAAC,GAAG;CACvF,MAAM,WAAWA,QAAM,QAAQ,YAAY,IAAI;CAC/C,MAAM,UAAU,kBAAkB;CAClC,IAAI,iBAAiB;CACrB,IAAI,wBAAwB;CAC5B,IAAI,yBAAyB;CAE7B,MAAM,eAAe,cAAuB;EAC1C,IAAI,mBAAmB,WAAW;EAClC,QAAQ,WAAW,SAAS;EAC5B,iBAAiB;CACnB;CAEA,MAAM,0BAA0B,cAAuB;EACrD,IAAI,0BAA0B,WAAW;EACzC,QAAQ,sBAAsB,SAAS;EACvC,wBAAwB;CAC1B;CAEA,MAAM,yBAAyB,cAAuB;EACpD,IAAI,2BAA2B,WAAW;EAC1C,2BAA2B,YAAY,IAAI;EAC3C,yBAAyB;CAC3B;CAEA,MAAM,mBAAmB,cAAuB;EAC9C,YAAY,SAAS;EACrB,uBAAuB,SAAS;EAChC,sBAAsB,SAAS;CACjC;CAEA,MAAM,iBAAiB,UAAU;EAC/B,IAAI,CAAC,SAAS,CAAC,SAAS,OAAO;EAC/B,QAAQ,MAAM,IAAI;CACpB,CAAC;CAED,MAAM,UAAU,iBAAiB,EAAE,WAAW,KAAK,CAAC;CACpD,kBAAkB,gBAAgB,KAA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edRef, Ref } from "vue";
2
2
 
3
3
  //#region src/composables/useVirtualViewport.d.ts
4
+ /** Alignment used when revealing a collection item. */
4
5
  type VirtualScrollAlignment = "nearest" | "start" | "center" | "end";
6
+ /** Visible and overscanned half-open item-index ranges. */
5
7
  interface VirtualViewportRange {
6
8
  /** First item occupying the viewport. */
7
9
  visibleStart: number;
@@ -12,12 +14,16 @@ interface VirtualViewportRange {
12
14
  /** Exclusive end of retained items, including trailing overscan. */
13
15
  overscanEnd: number;
14
16
  }
17
+ /** Collection size, visible capacity, overscan, and initial scroll offset. */
15
18
  interface VirtualViewportOptions {
16
19
  itemCount: number;
17
20
  viewportSize: number;
21
+ /** Extra retained items before and after the visible range. @default 2 */
18
22
  overscan?: number;
23
+ /** Initial item offset, clamped to the current scrollable range. @default 0 */
19
24
  initialOffset?: number;
20
25
  }
26
+ /** Bounded reactive collection offsets and range controls; counts must be nonnegative safe integers. */
21
27
  interface VirtualViewport {
22
28
  readonly itemCount: Readonly<Ref<number>>;
23
29
  readonly viewportSize: Readonly<Ref<number>>;
@@ -46,4 +52,4 @@ declare function createVirtualViewport(options: VirtualViewportOptions): Virtual
46
52
  declare const useVirtualViewport: typeof createVirtualViewport;
47
53
  //#endregion
48
54
  export { createVirtualViewport as a, VirtualViewportRange as i, VirtualViewport as n, useVirtualViewport as o, VirtualViewportOptions as r, VirtualScrollAlignment as t };
49
- //# sourceMappingURL=useVirtualViewport-TxTapifg.d.mts.map
55
+ //# sourceMappingURL=useVirtualViewport-CCWjx3oS.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVirtualViewport-CCWjx3oS.d.mts","names":[],"sources":["../src/composables/useVirtualViewport.ts"],"mappings":";;;;KAKY,sBAAA;;UAGK,oBAAA;EAHiB;EAKhC,YAAA;EAFe;EAIf,UAAA;;EAEA,aAAA;EAJA;EAMA,WAAA;AAAA;;UAIe,sBAAA;EACf,SAAA;EACA,YAAA;EAFqC;EAIrC,QAAA;EAJqC;EAMrC,aAAA;AAAA;;UAIe,eAAA;EAAA,SACN,SAAA,EAAW,QAAA,CAAS,GAAA;EAAA,SACpB,YAAA,EAAc,QAAA,CAAS,GAAA;EAAA,SACvB,QAAA,EAAU,QAAA,CAAS,GAAA;EAAA,SACnB,MAAA,EAAQ,QAAA,CAAS,GAAA;EAAA,SACjB,SAAA,EAAW,WAAA;EAAA,SACX,OAAA,EAAS,WAAA;EAAA,SACT,KAAA,EAAO,WAAA;EAAA,SACP,KAAA,EAAO,WAAA,CAAY,oBAAA;EANL;EAQvB,YAAA,CAAa,KAAA;EAPM;EASnB,eAAA,CAAgB,KAAA;EARC;EAUjB,WAAA,CAAY,KAAA;EARM;EAUlB,QAAA,CAAS,MAAA;EARmB;EAU5B,QAAA,CAAS,KAAA;EAEiC;EAA1C,cAAA,CAAe,KAAA,UAAe,SAAA,GAAY,sBAAA;AAAA;;iBAW5B,qBAAA,CAAsB,OAAA,EAAS,sBAAA,GAAyB,eAAe;;cAsF1E,kBAAA,SAAkB,qBAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/fresco",
3
- "version": "0.817.0",
3
+ "version": "0.819.0",
4
4
  "description": "Vue TUI framework - Build terminal UIs with Vue.js",
5
5
  "keywords": [
6
6
  "cli",
@@ -58,7 +58,7 @@
58
58
  "access": "public"
59
59
  },
60
60
  "dependencies": {
61
- "@vizejs/fresco-native": "0.817.0"
61
+ "@vizejs/fresco-native": "0.819.0"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/node": "25.9.2",