@vizejs/fresco 0.716.0 → 0.718.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{accessibility-OEhyYUxd.d.mts → accessibility-DwzT925M.d.mts} +46 -5
- package/dist/accessibility-DwzT925M.d.mts.map +1 -0
- package/dist/{app-CIX6NAW-.mjs → app-C_wFlWSV.mjs} +443 -123
- package/dist/app-C_wFlWSV.mjs.map +1 -0
- package/dist/app-_QmZ-PoH.d.mts +270 -0
- package/dist/app-_QmZ-PoH.d.mts.map +1 -0
- package/dist/ascii-font/index.d.mts +60 -0
- package/dist/ascii-font/index.d.mts.map +1 -0
- package/dist/ascii-font/index.mjs +68 -0
- package/dist/ascii-font/index.mjs.map +1 -0
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components-DzkL-yHj.mjs +6165 -0
- package/dist/components-DzkL-yHj.mjs.map +1 -0
- package/dist/composables/index.d.mts +3 -3
- package/dist/composables/index.mjs +4 -4
- package/dist/{composables-DbJGVNSG.mjs → composables-BJeirPSH.mjs} +116 -55
- package/dist/composables-BJeirPSH.mjs.map +1 -0
- package/dist/{index-CWRginDz.d.mts → index-B3zQ6E-5.d.mts} +1099 -337
- package/dist/index-B3zQ6E-5.d.mts.map +1 -0
- package/dist/{index-Dikou9bu.d.mts → index-Ddp2Txtm.d.mts} +52 -4
- package/dist/index-Ddp2Txtm.d.mts.map +1 -0
- package/dist/index.d.mts +98 -7
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +262 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{protocol-D8xt3DG7.d.mts → protocol-DavoeNLn.d.mts} +14 -4
- package/dist/{protocol-D8xt3DG7.d.mts.map → protocol-DavoeNLn.d.mts.map} +1 -1
- package/dist/qr-code/index.d.mts +101 -0
- package/dist/qr-code/index.d.mts.map +1 -0
- package/dist/qr-code/index.mjs +88 -0
- package/dist/qr-code/index.mjs.map +1 -0
- package/dist/testing/index.d.mts +3 -3
- package/dist/testing/index.mjs +1 -1
- package/dist/{useApp-CVB2jNCO.d.mts → useApp-vIRJ5Th3.d.mts} +34 -8
- package/dist/useApp-vIRJ5Th3.d.mts.map +1 -0
- package/dist/{useVirtualViewport-pPZWmwUC.mjs → useBoxMetrics-lF5Myjc7.mjs} +66 -6
- package/dist/useBoxMetrics-lF5Myjc7.mjs.map +1 -0
- package/package.json +14 -6
- package/dist/accessibility-OEhyYUxd.d.mts.map +0 -1
- package/dist/app-CIX6NAW-.mjs.map +0 -1
- package/dist/app-CKsTWQuP.d.mts +0 -154
- package/dist/app-CKsTWQuP.d.mts.map +0 -1
- package/dist/components-D9SeB0Be.mjs +0 -3331
- package/dist/components-D9SeB0Be.mjs.map +0 -1
- package/dist/composables-DbJGVNSG.mjs.map +0 -1
- package/dist/index-CWRginDz.d.mts.map +0 -1
- package/dist/index-Dikou9bu.d.mts.map +0 -1
- package/dist/useApp-CVB2jNCO.d.mts.map +0 -1
- package/dist/useVirtualViewport-pPZWmwUC.mjs.map +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/kittyKeyboard.ts"],"sourcesContent":["/**\n * Kitty keyboard protocol constants compatible with Ink.\n */\n\n/** Bit values defined by the Kitty keyboard progressive-enhancement protocol. */\nexport const kittyFlags = {\n disambiguateEscapeCodes: 1,\n reportEventTypes: 2,\n reportAlternateKeys: 4,\n reportAllKeysAsEscapeCodes: 8,\n reportAssociatedText: 16,\n} as const;\n\n/** Supported Kitty keyboard protocol flag name. */\nexport type KittyFlagName = keyof typeof kittyFlags;\n\n/** Kitty keyboard protocol negotiation options. */\nexport interface KittyKeyboardOptions {\n /** Whether protocol negotiation is automatic, forced, or disabled. @default \"auto\" */\n mode?: \"auto\" | \"enabled\" | \"disabled\";\n /** Progressive-enhancement flags requested from the terminal. @default [] */\n flags?: KittyFlagName[];\n}\n\n/** Combine named Kitty keyboard flags into the protocol bit mask. */\nexport function resolveKittyFlags(flags: KittyFlagName[]): number {\n return flags.reduce((bits, flag) => bits | kittyFlags[flag], 0);\n}\n\n/** Modifier bit values reported by the Kitty keyboard protocol. */\nexport const kittyModifiers = {\n shift: 1,\n alt: 2,\n ctrl: 4,\n super: 8,\n hyper: 16,\n meta: 32,\n capsLock: 64,\n numLock: 128,\n} as const;\n"],"mappings":";;;;;;;;;AAKA,MAAa,aAAa;CACxB,yBAAyB;CACzB,kBAAkB;CAClB,qBAAqB;CACrB,4BAA4B;CAC5B,sBAAsB;AACxB;;AAcA,SAAgB,kBAAkB,OAAgC;CAChE,OAAO,MAAM,QAAQ,MAAM,SAAS,OAAO,WAAW,OAAO,CAAC;AAChE;;AAGA,MAAa,iBAAiB;CAC5B,OAAO;CACP,KAAK;CACL,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,UAAU;CACV,SAAS;AACX"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/kittyKeyboard.ts","../src/plugins.ts","../src/devtools.ts","../src/theme.ts"],"sourcesContent":["/**\n * Kitty keyboard protocol constants compatible with Ink.\n */\n\n/** Bit values defined by the Kitty keyboard progressive-enhancement protocol. */\nexport const kittyFlags = {\n disambiguateEscapeCodes: 1,\n reportEventTypes: 2,\n reportAlternateKeys: 4,\n reportAllKeysAsEscapeCodes: 8,\n reportAssociatedText: 16,\n} as const;\n\n/** Supported Kitty keyboard protocol flag name. */\nexport type KittyFlagName = keyof typeof kittyFlags;\n\n/** Kitty keyboard protocol negotiation options. */\nexport interface KittyKeyboardOptions {\n /** Whether protocol negotiation is automatic, forced, or disabled. @default \"auto\" */\n mode?: \"auto\" | \"enabled\" | \"disabled\";\n /** Progressive-enhancement flags requested from the terminal. @default [] */\n flags?: KittyFlagName[];\n}\n\n/** Combine named Kitty keyboard flags into the protocol bit mask. */\nexport function resolveKittyFlags(flags: KittyFlagName[]): number {\n return flags.reduce((bits, flag) => bits | kittyFlags[flag], 0);\n}\n\n/** Modifier bit values reported by the Kitty keyboard protocol. */\nexport const kittyModifiers = {\n shift: 1,\n alt: 2,\n ctrl: 4,\n super: 8,\n hyper: 16,\n meta: 32,\n capsLock: 64,\n numLock: 128,\n} as const;\n","import { inject, type App as VueApp, type Component, type InjectionKey, type Plugin } from \"vue\";\n\n/** Typed provider owned by a Fresco extension. */\nexport interface FrescoProvider<Value> {\n /** Stable Vue injection key for advanced adapter integration. */\n readonly key: InjectionKey<Value>;\n /** Install a value while a plugin is configuring the application. */\n provide(app: VueApp, value: Value): void;\n /** Read the nearest value from component setup. */\n use(): Value;\n}\n\n/** Declarative component and provider setup for one Fresco plugin. */\nexport interface FrescoPluginDefinition {\n /** Optional global components keyed by their public template names. */\n readonly components?: Readonly<Record<string, Component>>;\n /** Additional provider or application setup performed during installation. */\n readonly setup?: (app: VueApp) => void;\n}\n\n/**\n * Define a typed extension provider with an optional fallback value.\n *\n * Fallback presence follows argument presence: explicitly passing `undefined`\n * is a valid fallback for value types that include it.\n */\nexport function defineFrescoProvider<Value>(\n description: string,\n fallback?: Value,\n): FrescoProvider<Value> {\n const key: InjectionKey<Value> = Symbol(description);\n const hasFallback = arguments.length >= 2;\n const missing = Symbol(\"missing-fresco-provider\");\n\n return {\n key,\n provide(app, value) {\n app.provide(key, value);\n },\n use() {\n const value = inject(key as InjectionKey<Value | typeof missing>, missing);\n if (value !== missing) return value;\n if (hasFallback) return fallback as Value;\n throw new Error(`Fresco provider ${JSON.stringify(description)} is not installed`);\n },\n };\n}\n\n/** Define a Vue plugin that registers Fresco components and typed providers. */\nexport function defineFrescoPlugin(definition: Readonly<FrescoPluginDefinition>): Plugin<[]> {\n return {\n install(app) {\n for (const [name, component] of Object.entries(definition.components ?? {})) {\n app.component(name, component);\n }\n definition.setup?.(app);\n },\n };\n}\n","import type { LayoutResultNapi } from \"@vizejs/fresco-native\";\nimport type { FrescoInputEvent } from \"./protocol.js\";\nimport type {\n FrescoDeclaredSize,\n FrescoHostNode,\n FrescoNodeLifecycleHooks,\n FrescoNodeUpdateKind,\n FrescoRenderNodeKind,\n} from \"./renderer.js\";\n\n/** One immutable native layout rectangle joined to its host node. */\nexport interface FrescoLayoutInspection {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/** Flat, immutable host-node record suitable for tree inspectors. */\nexport interface FrescoNodeInspection {\n readonly id: number;\n readonly type: FrescoRenderNodeKind;\n readonly parentId: number | null;\n readonly childIds: readonly number[];\n readonly depth: number;\n readonly props: Readonly<Record<string, unknown>>;\n readonly text?: string;\n readonly layout: FrescoLayoutInspection | null;\n}\n\n/** One inspected Fresco host tree and the native layouts joined to it. */\nexport interface FrescoTreeInspection {\n readonly rootId: number;\n readonly nodes: readonly FrescoNodeInspection[];\n readonly nodeCount: number;\n readonly layoutCount: number;\n /** Layout ids that did not belong to the inspected host tree. */\n readonly unmatchedLayoutIds: readonly number[];\n}\n\n/** Metrics recorded after one application frame. */\nexport interface FrescoDevtoolsRenderMetrics {\n readonly renderTime: number;\n readonly nodeCount: number;\n readonly layoutCount: number;\n}\n\ninterface FrescoDevtoolsEventBase {\n /** Monotonic event order local to this devtools instance. */\n readonly sequence: number;\n readonly nodeId?: number;\n}\n\n/** Bounded, discriminated event records emitted by Fresco devtools. */\nexport type FrescoDevtoolsEvent =\n | (FrescoDevtoolsEventBase & {\n readonly type: \"create\";\n readonly nodeId: number;\n readonly nodeType: FrescoRenderNodeKind;\n })\n | (FrescoDevtoolsEventBase & {\n readonly type: \"update\";\n readonly nodeId: number;\n readonly updateKind: FrescoNodeUpdateKind;\n })\n | (FrescoDevtoolsEventBase & {\n readonly type: \"resize\";\n readonly nodeId: number;\n readonly previous: FrescoDeclaredSize;\n readonly current: FrescoDeclaredSize;\n })\n | (FrescoDevtoolsEventBase & {\n readonly type: \"remove\";\n readonly nodeId: number;\n readonly nodeType: FrescoRenderNodeKind;\n })\n | (FrescoDevtoolsEventBase & {\n readonly type: \"input\";\n readonly input: FrescoInputEvent;\n })\n | (FrescoDevtoolsEventBase & {\n readonly type: \"render\";\n readonly metrics: FrescoDevtoolsRenderMetrics;\n });\n\ntype WithoutSequence<Event> = Event extends unknown ? Omit<Event, \"sequence\"> : never;\ntype FrescoDevtoolsEventInput = WithoutSequence<FrescoDevtoolsEvent>;\n\n/** Point-in-time state returned by {@link FrescoDevtools.snapshot}. */\nexport interface FrescoDevtoolsSnapshot {\n readonly tree: FrescoTreeInspection | null;\n readonly events: readonly FrescoDevtoolsEvent[];\n readonly latestRender: FrescoDevtoolsRenderMetrics | null;\n}\n\n/** Configuration for {@link createFrescoDevtools}. */\nexport interface FrescoDevtoolsOptions {\n /** Maximum retained trace events. Older records are discarded first. @default 200 */\n eventLimit?: number;\n}\n\n/** Inspector and bounded trace collector accepted by `createApp`. */\nexport interface FrescoDevtools {\n /** Lifecycle hooks wired into the public Fresco renderer. */\n readonly lifecycle: FrescoNodeLifecycleHooks;\n /** Record one normalized terminal input event. */\n recordInput(input: FrescoInputEvent): void;\n /** Join a rendered host tree with its native layouts and render metrics. */\n recordRender(\n root: FrescoHostNode,\n layouts: readonly LayoutResultNapi[],\n metrics: FrescoDevtoolsRenderMetrics,\n ): FrescoTreeInspection;\n /** Read an immutable copy of the current inspector state and bounded trace. */\n snapshot(): FrescoDevtoolsSnapshot;\n /** Remove trace records without discarding the latest tree or metrics. */\n clearEvents(): void;\n}\n\n/** Options for the terminal-friendly debug overlay formatter. */\nexport interface FrescoDebugOverlayOptions {\n /** Maximum tree rows included after the summary. @default 20 */\n maxNodes?: number;\n /** Maximum recent trace rows included after the tree. @default 8 */\n maxEvents?: number;\n}\n\nfunction copyLayout(layout: LayoutResultNapi): FrescoLayoutInspection {\n return {\n x: layout.x,\n y: layout.y,\n width: layout.width,\n height: layout.height,\n };\n}\n\n/**\n * Join a live host tree with the layout results produced by the same native frame.\n *\n * The returned records are flat and immutable, so devtools can index them without\n * retaining parent back-references or the mutable Vue renderer tree.\n */\nexport function inspectFrescoTree(\n root: FrescoHostNode,\n layouts: readonly LayoutResultNapi[] = [],\n): FrescoTreeInspection {\n const layoutsById = new Map(layouts.map((layout) => [layout.id, layout]));\n const matchedLayoutIds = new Set<number>();\n const nodes: FrescoNodeInspection[] = [];\n\n const visit = (node: FrescoHostNode, depth: number) => {\n const layout = layoutsById.get(node.id);\n if (layout) matchedLayoutIds.add(node.id);\n nodes.push({\n id: node.id,\n type: node.type,\n parentId: node.parent?.id ?? null,\n childIds: node.children.map((child) => child.id),\n depth,\n props: { ...node.props },\n ...(node.text === undefined ? {} : { text: node.text }),\n layout: layout ? copyLayout(layout) : null,\n });\n for (const child of node.children) visit(child, depth + 1);\n };\n\n visit(root, 0);\n return {\n rootId: root.id,\n nodes,\n nodeCount: nodes.length,\n layoutCount: matchedLayoutIds.size,\n unmatchedLayoutIds: layouts\n .map((layout) => layout.id)\n .filter((id) => !matchedLayoutIds.has(id)),\n };\n}\n\nfunction retainedLimit(limit: number | undefined): number {\n if (limit === undefined) return 200;\n if (!Number.isFinite(limit)) return 200;\n return Math.max(0, Math.floor(limit));\n}\n\n/** Create one opt-in tree inspector and bounded event trace collector. */\nexport function createFrescoDevtools(options: FrescoDevtoolsOptions = {}): FrescoDevtools {\n const eventLimit = retainedLimit(options.eventLimit);\n const events: FrescoDevtoolsEvent[] = [];\n let sequence = 0;\n let tree: FrescoTreeInspection | null = null;\n let latestRender: FrescoDevtoolsRenderMetrics | null = null;\n\n const append = (event: FrescoDevtoolsEventInput) => {\n if (eventLimit === 0) return;\n events.push({ ...event, sequence: sequence++ } as FrescoDevtoolsEvent);\n const overflow = events.length - eventLimit;\n if (overflow > 0) events.splice(0, overflow);\n };\n\n const lifecycle: FrescoNodeLifecycleHooks = {\n onCreate(node) {\n append({ type: \"create\", nodeId: node.id, nodeType: node.type });\n },\n onUpdate(node, updateKind) {\n append({ type: \"update\", nodeId: node.id, updateKind });\n },\n onResize(node, previous, current) {\n append({ type: \"resize\", nodeId: node.id, previous, current });\n },\n onRemove(node) {\n append({ type: \"remove\", nodeId: node.id, nodeType: node.type });\n },\n };\n\n return {\n lifecycle,\n recordInput(input) {\n append({ type: \"input\", input: { ...input } as FrescoInputEvent });\n },\n recordRender(root, layouts, metrics) {\n tree = inspectFrescoTree(root, layouts);\n latestRender = { ...metrics };\n append({ type: \"render\", metrics: latestRender });\n return tree;\n },\n snapshot() {\n return {\n tree,\n events: events.map((event) => ({ ...event })),\n latestRender,\n };\n },\n clearEvents() {\n events.length = 0;\n },\n };\n}\n\nfunction formatNode(node: FrescoNodeInspection): string {\n const indent = \" \".repeat(node.depth);\n const layout = node.layout\n ? ` ${node.layout.width}x${node.layout.height}@${node.layout.x},${node.layout.y}`\n : \" layout:pending\";\n const text = node.text === undefined ? \"\" : ` ${JSON.stringify(node.text)}`;\n return `${indent}#${node.id} ${node.type}${layout}${text}`;\n}\n\nfunction formatEvent(event: FrescoDevtoolsEvent): string {\n switch (event.type) {\n case \"create\":\n return `${event.sequence} create #${event.nodeId} ${event.nodeType}`;\n case \"update\":\n return `${event.sequence} update #${event.nodeId} ${event.updateKind}`;\n case \"resize\":\n return `${event.sequence} resize #${event.nodeId}`;\n case \"remove\":\n return `${event.sequence} remove #${event.nodeId} ${event.nodeType}`;\n case \"input\":\n return `${event.sequence} input ${event.input.type}`;\n case \"render\":\n return `${event.sequence} render ${event.metrics.renderTime.toFixed(2)}ms`;\n }\n}\n\n/** Render an inspector snapshot as a compact terminal debug overlay. */\nexport function formatFrescoDebugOverlay(\n snapshot: FrescoDevtoolsSnapshot,\n options: FrescoDebugOverlayOptions = {},\n): string {\n const maxNodes = Math.max(0, Math.floor(options.maxNodes ?? 20));\n const maxEvents = Math.max(0, Math.floor(options.maxEvents ?? 8));\n const render = snapshot.latestRender;\n const summary = render\n ? `Fresco ${render.nodeCount} nodes · ${render.layoutCount} layouts · ${render.renderTime.toFixed(2)}ms`\n : \"Fresco devtools · waiting for first render\";\n const treeRows = snapshot.tree?.nodes.slice(0, maxNodes).map(formatNode) ?? [];\n const eventRows = snapshot.events.slice(-maxEvents).map(formatEvent);\n return [summary, ...treeRows, ...(eventRows.length > 0 ? [\"events\", ...eventRows] : [])].join(\n \"\\n\",\n );\n}\n","import {\n computed,\n inject,\n provide,\n toValue,\n type InjectionKey,\n type MaybeRefOrGetter,\n type Ref,\n} from \"vue\";\n\nimport type { FrescoBorderStyle } from \"./protocol.js\";\n\n/** Semantic terminal colors consumed by Fresco components and applications. */\nexport interface FrescoThemeColors {\n foreground: string;\n background: string;\n muted: string;\n primary: string;\n accent: string;\n positive: string;\n caution: string;\n negative: string;\n info: string;\n focus: string;\n}\n\n/** Cell-based spacing scale shared by layout components. */\nexport interface FrescoThemeSpacing {\n none: number;\n xs: number;\n sm: number;\n md: number;\n lg: number;\n xl: number;\n}\n\n/** Border defaults for progressively stronger terminal surfaces. */\nexport interface FrescoThemeBorders {\n subtle: FrescoBorderStyle;\n regular: FrescoBorderStyle;\n strong: FrescoBorderStyle;\n}\n\n/** Animation timing contract, including the effective reduced-motion policy. */\nexport interface FrescoThemeMotion {\n reduced: boolean;\n fastMs: number;\n regularMs: number;\n slowMs: number;\n}\n\n/** Complete, resolved Fresco theme available to descendants. */\nexport interface FrescoTheme {\n colors: FrescoThemeColors;\n spacing: FrescoThemeSpacing;\n borders: FrescoThemeBorders;\n motion: FrescoThemeMotion;\n}\n\n/** Scoped partial theme layered over the nearest provider. */\nexport interface FrescoThemeOverride {\n colors?: Partial<FrescoThemeColors>;\n spacing?: Partial<FrescoThemeSpacing>;\n borders?: Partial<FrescoThemeBorders>;\n motion?: Partial<FrescoThemeMotion>;\n}\n\n/** Static defaults shared without runtime stylesheet or token generation. */\nexport const defaultFrescoTheme: Readonly<FrescoTheme> = Object.freeze({\n colors: Object.freeze({\n foreground: \"white\",\n background: \"black\",\n muted: \"gray\",\n primary: \"cyan\",\n accent: \"magenta\",\n positive: \"green\",\n caution: \"yellow\",\n negative: \"red\",\n info: \"blue\",\n focus: \"cyan\",\n }),\n spacing: Object.freeze({ none: 0, xs: 1, sm: 1, md: 2, lg: 3, xl: 4 }),\n borders: Object.freeze({ subtle: \"single\", regular: \"rounded\", strong: \"double\" }),\n motion: Object.freeze({ reduced: false, fastMs: 80, regularMs: 160, slowMs: 240 }),\n});\n\n/** Injection identity for framework adapters that bridge Fresco theme scopes. */\nexport const FRESCO_THEME_KEY: InjectionKey<Readonly<Ref<FrescoTheme>>> = Symbol(\"fresco-theme\");\n\n/** Resolve one scoped override without mutating its parent theme. */\nexport function resolveFrescoTheme(\n parent: Readonly<FrescoTheme>,\n override: Readonly<FrescoThemeOverride> = {},\n): FrescoTheme {\n return {\n colors: { ...parent.colors, ...override.colors },\n spacing: { ...parent.spacing, ...override.spacing },\n borders: { ...parent.borders, ...override.borders },\n motion: { ...parent.motion, ...override.motion },\n };\n}\n\n/** Provide a reactive theme scoped to the current component subtree. */\nexport function provideFrescoTheme(\n override: MaybeRefOrGetter<FrescoThemeOverride> = {},\n): Readonly<Ref<FrescoTheme>> {\n const parent = inject(FRESCO_THEME_KEY, undefined);\n const theme = computed(() =>\n resolveFrescoTheme(parent?.value ?? defaultFrescoTheme, toValue(override)),\n );\n provide(FRESCO_THEME_KEY, theme);\n return theme;\n}\n\n/** Read the nearest resolved theme, falling back to the static defaults. */\nexport function useFrescoTheme(): Readonly<Ref<FrescoTheme>> {\n const theme = inject(FRESCO_THEME_KEY, undefined);\n return theme ?? computed(() => defaultFrescoTheme as FrescoTheme);\n}\n"],"mappings":";;;;;;;;;;AAKA,MAAa,aAAa;CACxB,yBAAyB;CACzB,kBAAkB;CAClB,qBAAqB;CACrB,4BAA4B;CAC5B,sBAAsB;AACxB;;AAcA,SAAgB,kBAAkB,OAAgC;CAChE,OAAO,MAAM,QAAQ,MAAM,SAAS,OAAO,WAAW,OAAO,CAAC;AAChE;;AAGA,MAAa,iBAAiB;CAC5B,OAAO;CACP,KAAK;CACL,MAAM;CACN,OAAO;CACP,OAAO;CACP,MAAM;CACN,UAAU;CACV,SAAS;AACX;;;;;;;;;ACbA,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O;GAAQ,GAAG,SAAS;EAAO;EAC/C,SAAS;GAAE,GAAG,OAAO;GAAS,GAAG,SAAS;EAAQ;EAClD,SAAS;GAAE,GAAG,OAAO;GAAS,GAAG,SAAS;EAAQ;EAClD,QAAQ;GAAE,GAAG,OAAO;GAAQ,GAAG,SAAS;EAAO;CACjD;AACF;;AAGA,SAAgB,mBACd,WAAkD,CAAC,GACvB;CAC5B,MAAM,SAAS,OAAO,kBAAkB,KAAA,CAAS;CACjD,MAAM,QAAQ,eACZ,mBAAmB,QAAQ,SAAS,oBAAoB,QAAQ,QAAQ,CAAC,CAC3E;CACA,QAAQ,kBAAkB,KAAK;CAC/B,OAAO;AACT;;AAGA,SAAgB,iBAA6C;CAE3D,OADc,OAAO,kBAAkB,KAAA,CAC5B,KAAK,eAAe,kBAAiC;AAClE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/protocol.d.ts
|
|
2
2
|
/** Public JavaScript protocol shared by Fresco components and the renderer. */
|
|
3
3
|
/** Discriminant shared by JavaScript and native render nodes. */
|
|
4
|
-
type FrescoRenderNodeKind = "root" | "box" | "text" | "input";
|
|
4
|
+
type FrescoRenderNodeKind = "root" | "box" | "text" | "input" | "raw";
|
|
5
5
|
/** Numeric or CSS-like dimension accepted by component style props. */
|
|
6
6
|
type FrescoDimension = number | string;
|
|
7
7
|
/** Display modes supported by the native layout engine. */
|
|
@@ -142,14 +142,24 @@ interface FrescoInputRenderNode extends FrescoRenderNodeBase {
|
|
|
142
142
|
placeholder?: string;
|
|
143
143
|
focused?: boolean;
|
|
144
144
|
cursor?: number;
|
|
145
|
+
/** Inclusive grapheme index at the start of the active selection. */
|
|
146
|
+
selectionStart?: number;
|
|
147
|
+
/** Exclusive grapheme index at the end of the active selection. */
|
|
148
|
+
selectionEnd?: number;
|
|
145
149
|
mask?: boolean;
|
|
146
150
|
maskChar?: string;
|
|
147
151
|
}
|
|
152
|
+
/** Precomposed terminal lines emitted without text wrapping. */
|
|
153
|
+
interface FrescoRawRenderNode extends FrescoRenderNodeBase {
|
|
154
|
+
nodeType: "raw";
|
|
155
|
+
/** Exact terminal rows painted in order inside the computed layout. */
|
|
156
|
+
lines?: string[];
|
|
157
|
+
}
|
|
148
158
|
type UnionKeys<Union> = Union extends Union ? keyof Union : never;
|
|
149
159
|
type StrictUnionHelper<Member, Union> = Member extends Member ? Member & Partial<Record<Exclude<UnionKeys<Union>, keyof Member>, never>> : never;
|
|
150
160
|
type StrictUnion<Union> = StrictUnionHelper<Union, Union>;
|
|
151
161
|
/** Strict discriminated union accepted by the native render bridge. */
|
|
152
|
-
type FrescoRenderNode = StrictUnion<FrescoRootRenderNode | FrescoBoxRenderNode | FrescoTextRenderNode | FrescoInputRenderNode>;
|
|
162
|
+
type FrescoRenderNode = StrictUnion<FrescoRootRenderNode | FrescoBoxRenderNode | FrescoTextRenderNode | FrescoInputRenderNode | FrescoRawRenderNode>;
|
|
153
163
|
/** Lifecycle phase attached to a normalized keyboard event. */
|
|
154
164
|
type KeyEventType = "press" | "repeat" | "release";
|
|
155
165
|
/** Modifier state shared by keyboard and mouse events. */
|
|
@@ -208,5 +218,5 @@ type FrescoInputEvent = StrictUnion<KeyEvent | PasteEvent | ResizeEvent | MouseE
|
|
|
208
218
|
/** Compatibility alias for the pre-protocol event union name. */
|
|
209
219
|
type InputEvent = FrescoInputEvent;
|
|
210
220
|
//#endregion
|
|
211
|
-
export {
|
|
212
|
-
//# sourceMappingURL=protocol-
|
|
221
|
+
export { InputEvent as A, FrescoRenderNodeKind as C, FrescoStyle as D, FrescoSnakeStyleAliases as E, ResizeEvent as F, KeyEventType as M, MouseEvent as N, FrescoTextRenderNode as O, PasteEvent as P, FrescoRenderNode as S, FrescoRootRenderNode as T, FrescoModifiers as _, FrescoAlignSelf as a, FrescoPosition as b, FrescoBoxRenderNode as c, FrescoDisplay as d, FrescoFlexDirection as f, FrescoJustifyContent as g, FrescoInputRenderNode as h, FrescoAlignItems as i, KeyEvent as j, FrescoTextWrapMode as k, FrescoCanonicalStyle as l, FrescoInputEvent as m, FocusEvent as n, FrescoAppearance as o, FrescoFlexWrap as p, FrescoAlignContent as r, FrescoBorderStyle as s, CompositionEvent as t, FrescoDimension as u, FrescoMouseEventKind as v, FrescoRenderStyle as w, FrescoRawRenderNode as x, FrescoOverflow as y };
|
|
222
|
+
//# sourceMappingURL=protocol-DavoeNLn.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol-
|
|
1
|
+
{"version":3,"file":"protocol-DavoeNLn.d.mts","names":[],"sources":["../src/protocol.ts"],"mappings":";;AAGA;AAAA,KAAY,oBAAA;;KAEA,eAAA;AAFoB;AAAA,KAIpB,aAAA;;KAEA,cAAA;;KAEA,cAAA;AAJZ;AAAA,KAMY,mBAAA;;KAEA,cAAA;AARa;AAAA,KAUb,oBAAA;;KAUA,gBAAA;;KASA,eAAA,YAA2B,gBAAgB;AAzBvD;AAAA,KA2BY,kBAAA;;UAYK,oBAAA,mBAAuC,eAAA,GAAkB,eAAA;EACxE,OAAA,GAAU,aAAA;EACV,QAAA,GAAW,cAAA;EACX,GAAA,GAAM,SAAA;EACN,KAAA,GAAQ,SAAA;EACR,MAAA,GAAS,SAAA;EACT,IAAA,GAAO,SAAA;EACP,QAAA,GAAW,cAAA;EACX,SAAA,GAAY,cAAA;EACZ,SAAA,GAAY,cAAA;EACZ,aAAA,GAAgB,mBAAA;EAChB,QAAA,GAAW,cAAA;EACX,cAAA,GAAiB,oBAAA;EACjB,UAAA,GAAa,gBAAA;EACb,SAAA,GAAY,eAAA;EACZ,YAAA,GAAe,kBAAA;EACf,QAAA;EACA,UAAA;EACA,SAAA,GAAY,SAAA;EACZ,KAAA,GAAQ,SAAA;EACR,MAAA,GAAS,SAAA;EACT,QAAA,GAAW,SAAA;EACX,SAAA,GAAY,SAAA;EACZ,QAAA,GAAW,SAAA;EACX,SAAA,GAAY,SAAA;EACZ,WAAA;EACA,OAAA;EACA,UAAA;EACA,YAAA;EACA,a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 -0,0 +1,101 @@
|
|
|
1
|
+
import { PropType } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/qr-code/index.d.ts
|
|
4
|
+
type QrCodeErrorCorrection = "low" | "medium" | "quartile" | "high";
|
|
5
|
+
type QrCodeMatrix = readonly (readonly boolean[])[];
|
|
6
|
+
interface QrCodeProviderOptions {
|
|
7
|
+
errorCorrection: QrCodeErrorCorrection;
|
|
8
|
+
}
|
|
9
|
+
type QrCodeProvider = (value: string, options: Readonly<QrCodeProviderOptions>) => QrCodeMatrix;
|
|
10
|
+
interface QrCodeProps {
|
|
11
|
+
value: string;
|
|
12
|
+
provider: QrCodeProvider;
|
|
13
|
+
errorCorrection?: QrCodeErrorCorrection;
|
|
14
|
+
quietZone?: number;
|
|
15
|
+
cellWidth?: number;
|
|
16
|
+
dark?: string;
|
|
17
|
+
light?: string;
|
|
18
|
+
fg?: string;
|
|
19
|
+
bg?: string;
|
|
20
|
+
invert?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** Preserve a provider's exact public type without wrapping its implementation. */
|
|
23
|
+
declare function defineQrCodeProvider(provider: QrCodeProvider): QrCodeProvider;
|
|
24
|
+
/** Render a provider matrix without bundling a QR encoder in Fresco. */
|
|
25
|
+
declare const QrCode: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
26
|
+
value: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
required: true;
|
|
29
|
+
};
|
|
30
|
+
provider: {
|
|
31
|
+
type: PropType<QrCodeProvider>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
errorCorrection: {
|
|
35
|
+
type: PropType<QrCodeErrorCorrection>;
|
|
36
|
+
default: string;
|
|
37
|
+
};
|
|
38
|
+
quietZone: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: number;
|
|
41
|
+
};
|
|
42
|
+
cellWidth: {
|
|
43
|
+
type: NumberConstructor;
|
|
44
|
+
default: number;
|
|
45
|
+
};
|
|
46
|
+
dark: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: string;
|
|
49
|
+
};
|
|
50
|
+
light: {
|
|
51
|
+
type: StringConstructor;
|
|
52
|
+
default: string;
|
|
53
|
+
};
|
|
54
|
+
fg: StringConstructor;
|
|
55
|
+
bg: StringConstructor;
|
|
56
|
+
invert: BooleanConstructor;
|
|
57
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
60
|
+
value: {
|
|
61
|
+
type: StringConstructor;
|
|
62
|
+
required: true;
|
|
63
|
+
};
|
|
64
|
+
provider: {
|
|
65
|
+
type: PropType<QrCodeProvider>;
|
|
66
|
+
required: true;
|
|
67
|
+
};
|
|
68
|
+
errorCorrection: {
|
|
69
|
+
type: PropType<QrCodeErrorCorrection>;
|
|
70
|
+
default: string;
|
|
71
|
+
};
|
|
72
|
+
quietZone: {
|
|
73
|
+
type: NumberConstructor;
|
|
74
|
+
default: number;
|
|
75
|
+
};
|
|
76
|
+
cellWidth: {
|
|
77
|
+
type: NumberConstructor;
|
|
78
|
+
default: number;
|
|
79
|
+
};
|
|
80
|
+
dark: {
|
|
81
|
+
type: StringConstructor;
|
|
82
|
+
default: string;
|
|
83
|
+
};
|
|
84
|
+
light: {
|
|
85
|
+
type: StringConstructor;
|
|
86
|
+
default: string;
|
|
87
|
+
};
|
|
88
|
+
fg: StringConstructor;
|
|
89
|
+
bg: StringConstructor;
|
|
90
|
+
invert: BooleanConstructor;
|
|
91
|
+
}>> & Readonly<{}>, {
|
|
92
|
+
invert: boolean;
|
|
93
|
+
errorCorrection: QrCodeErrorCorrection;
|
|
94
|
+
quietZone: number;
|
|
95
|
+
cellWidth: number;
|
|
96
|
+
dark: string;
|
|
97
|
+
light: string;
|
|
98
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
99
|
+
//#endregion
|
|
100
|
+
export { QrCode, QrCodeErrorCorrection, QrCodeMatrix, QrCodeProps, QrCodeProvider, QrCodeProviderOptions, defineQrCodeProvider };
|
|
101
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/qr-code/index.ts"],"mappings":";;;KAIY,qBAAA;AAAA,KACA,YAAA;AAAA,UAEK,qBAAA;EACf,eAAA,EAAiB,qBAAqB;AAAA;AAAA,KAG5B,cAAA,IACV,KAAA,UACA,OAAA,EAAS,QAAA,CAAS,qBAAA,MACf,YAAA;AAAA,UAEY,WAAA;EACf,KAAA;EACA,QAAA,EAAU,cAAA;EACV,eAAA,GAAkB,qBAAqB;EACvC,SAAA;EACA,SAAA;EACA,IAAA;EACA,KAAA;EACA,EAAA;EACA,EAAA;EACA,MAAA;AAAA;;iBAIc,oBAAA,CAAqB,QAAA,EAAU,cAAA,GAAiB,cAAc;;cAgCjE,MAAA,gBAAM,eAAA,eAAA,gBAAA;;;;;;UAIe,QAAA,CAAS,cAAA;;;;UAErB,QAAA,CAAS,qBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAFG,QAAA,CAAS,cAAA;;;;UAErB,QAAA,CAAS,qBAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { computed, defineComponent, h } from "vue";
|
|
2
|
+
//#region src/qr-code/index.ts
|
|
3
|
+
/** Optional, provider-driven QR code entry point. */
|
|
4
|
+
/** Preserve a provider's exact public type without wrapping its implementation. */
|
|
5
|
+
function defineQrCodeProvider(provider) {
|
|
6
|
+
return provider;
|
|
7
|
+
}
|
|
8
|
+
function normalizedInteger(value, fallback) {
|
|
9
|
+
if (!Number.isFinite(value)) return fallback;
|
|
10
|
+
return Math.max(0, Math.trunc(value));
|
|
11
|
+
}
|
|
12
|
+
function validateMatrix(matrix) {
|
|
13
|
+
if (matrix.length === 0) throw new Error("FRESCO_QR_MATRIX_EMPTY: provider returned an empty matrix");
|
|
14
|
+
const size = matrix.length;
|
|
15
|
+
return matrix.map((row, rowIndex) => {
|
|
16
|
+
if (row.length !== size) throw new Error(`FRESCO_QR_MATRIX_SQUARE: row ${rowIndex} has ${row.length} cells; expected ${size}`);
|
|
17
|
+
return row.map((cell, columnIndex) => {
|
|
18
|
+
if (typeof cell !== "boolean") throw new Error(`FRESCO_QR_MATRIX_CELL: row ${rowIndex}, column ${columnIndex} is not boolean`);
|
|
19
|
+
return cell;
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Render a provider matrix without bundling a QR encoder in Fresco. */
|
|
24
|
+
const QrCode = defineComponent({
|
|
25
|
+
name: "QrCode",
|
|
26
|
+
props: {
|
|
27
|
+
value: {
|
|
28
|
+
type: String,
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
provider: {
|
|
32
|
+
type: Function,
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
errorCorrection: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: "medium"
|
|
38
|
+
},
|
|
39
|
+
quietZone: {
|
|
40
|
+
type: Number,
|
|
41
|
+
default: 2
|
|
42
|
+
},
|
|
43
|
+
cellWidth: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: 2
|
|
46
|
+
},
|
|
47
|
+
dark: {
|
|
48
|
+
type: String,
|
|
49
|
+
default: "█"
|
|
50
|
+
},
|
|
51
|
+
light: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: " "
|
|
54
|
+
},
|
|
55
|
+
fg: String,
|
|
56
|
+
bg: String,
|
|
57
|
+
invert: Boolean
|
|
58
|
+
},
|
|
59
|
+
setup(props) {
|
|
60
|
+
const matrix = computed(() => validateMatrix(props.provider(props.value, { errorCorrection: props.errorCorrection })));
|
|
61
|
+
const rows = computed(() => {
|
|
62
|
+
const quietZone = normalizedInteger(props.quietZone, 2);
|
|
63
|
+
const cellWidth = Math.max(1, normalizedInteger(props.cellWidth, 2));
|
|
64
|
+
const dark = (props.invert ? props.light : props.dark).repeat(cellWidth);
|
|
65
|
+
const light = (props.invert ? props.dark : props.light).repeat(cellWidth);
|
|
66
|
+
const quietRow = light.repeat(matrix.value.length + quietZone * 2);
|
|
67
|
+
const horizontalPadding = light.repeat(quietZone);
|
|
68
|
+
return [
|
|
69
|
+
...Array(quietZone).fill(quietRow),
|
|
70
|
+
...matrix.value.map((row) => `${horizontalPadding}${row.map((cell) => cell ? dark : light).join("")}${horizontalPadding}`),
|
|
71
|
+
...Array(quietZone).fill(quietRow)
|
|
72
|
+
];
|
|
73
|
+
});
|
|
74
|
+
return () => h("box", {
|
|
75
|
+
style: { flexDirection: "column" },
|
|
76
|
+
"aria-label": `QR code for ${props.value}`
|
|
77
|
+
}, rows.value.map((row, index) => h("text", {
|
|
78
|
+
key: index,
|
|
79
|
+
text: row,
|
|
80
|
+
fg: props.fg,
|
|
81
|
+
bg: props.bg
|
|
82
|
+
})));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
//#endregion
|
|
86
|
+
export { QrCode, defineQrCodeProvider };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/qr-code/index.ts"],"sourcesContent":["/** Optional, provider-driven QR code entry point. */\n\nimport { computed, defineComponent, h, type PropType } from \"vue\";\n\nexport type QrCodeErrorCorrection = \"low\" | \"medium\" | \"quartile\" | \"high\";\nexport type QrCodeMatrix = readonly (readonly boolean[])[];\n\nexport interface QrCodeProviderOptions {\n errorCorrection: QrCodeErrorCorrection;\n}\n\nexport type QrCodeProvider = (\n value: string,\n options: Readonly<QrCodeProviderOptions>,\n) => QrCodeMatrix;\n\nexport interface QrCodeProps {\n value: string;\n provider: QrCodeProvider;\n errorCorrection?: QrCodeErrorCorrection;\n quietZone?: number;\n cellWidth?: number;\n dark?: string;\n light?: string;\n fg?: string;\n bg?: string;\n invert?: boolean;\n}\n\n/** Preserve a provider's exact public type without wrapping its implementation. */\nexport function defineQrCodeProvider(provider: QrCodeProvider): QrCodeProvider {\n return provider;\n}\n\nfunction normalizedInteger(value: number, fallback: number): number {\n if (!Number.isFinite(value)) return fallback;\n return Math.max(0, Math.trunc(value));\n}\n\nfunction validateMatrix(matrix: QrCodeMatrix): boolean[][] {\n if (matrix.length === 0) {\n throw new Error(\"FRESCO_QR_MATRIX_EMPTY: provider returned an empty matrix\");\n }\n const size = matrix.length;\n return matrix.map((row, rowIndex) => {\n if (row.length !== size) {\n throw new Error(\n `FRESCO_QR_MATRIX_SQUARE: row ${rowIndex} has ${row.length} cells; expected ${size}`,\n );\n }\n return row.map((cell, columnIndex) => {\n if (typeof cell !== \"boolean\") {\n throw new Error(\n `FRESCO_QR_MATRIX_CELL: row ${rowIndex}, column ${columnIndex} is not boolean`,\n );\n }\n return cell;\n });\n });\n}\n\n/** Render a provider matrix without bundling a QR encoder in Fresco. */\nexport const QrCode = defineComponent({\n name: \"QrCode\",\n props: {\n value: { type: String, required: true },\n provider: { type: Function as PropType<QrCodeProvider>, required: true },\n errorCorrection: {\n type: String as PropType<QrCodeErrorCorrection>,\n default: \"medium\",\n },\n quietZone: { type: Number, default: 2 },\n cellWidth: { type: Number, default: 2 },\n dark: { type: String, default: \"█\" },\n light: { type: String, default: \" \" },\n fg: String,\n bg: String,\n invert: Boolean,\n },\n setup(props) {\n const matrix = computed(() =>\n validateMatrix(\n props.provider(props.value, {\n errorCorrection: props.errorCorrection,\n }),\n ),\n );\n const rows = computed(() => {\n const quietZone = normalizedInteger(props.quietZone, 2);\n const cellWidth = Math.max(1, normalizedInteger(props.cellWidth, 2));\n const dark = (props.invert ? props.light : props.dark).repeat(cellWidth);\n const light = (props.invert ? props.dark : props.light).repeat(cellWidth);\n const quietRow = light.repeat(matrix.value.length + quietZone * 2);\n const horizontalPadding = light.repeat(quietZone);\n return [\n ...Array<string>(quietZone).fill(quietRow),\n ...matrix.value.map(\n (row) =>\n `${horizontalPadding}${row.map((cell) => (cell ? dark : light)).join(\"\")}${horizontalPadding}`,\n ),\n ...Array<string>(quietZone).fill(quietRow),\n ];\n });\n\n return () =>\n h(\n \"box\",\n {\n style: { flexDirection: \"column\" },\n \"aria-label\": `QR code for ${props.value}`,\n },\n rows.value.map((row, index) =>\n h(\"text\", { key: index, text: row, fg: props.fg, bg: props.bg }),\n ),\n );\n },\n});\n"],"mappings":";;;;AA8BA,SAAgB,qBAAqB,UAA0C;CAC7E,OAAO;AACT;AAEA,SAAS,kBAAkB,OAAe,UAA0B;CAClE,IAAI,CAAC,OAAO,SAAS,KAAK,GAAG,OAAO;CACpC,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,KAAK,CAAC;AACtC;AAEA,SAAS,eAAe,QAAmC;CACzD,IAAI,OAAO,WAAW,GACpB,MAAM,IAAI,MAAM,2DAA2D;CAE7E,MAAM,OAAO,OAAO;CACpB,OAAO,OAAO,KAAK,KAAK,aAAa;EACnC,IAAI,IAAI,WAAW,MACjB,MAAM,IAAI,MACR,gCAAgC,SAAS,OAAO,IAAI,OAAO,mBAAmB,MAChF;EAEF,OAAO,IAAI,KAAK,MAAM,gBAAgB;GACpC,IAAI,OAAO,SAAS,WAClB,MAAM,IAAI,MACR,8BAA8B,SAAS,WAAW,YAAY,gBAChE;GAEF,OAAO;EACT,CAAC;CACH,CAAC;AACH;;AAGA,MAAa,SAAS,gBAAgB;CACpC,MAAM;CACN,OAAO;EACL,OAAO;GAAE,MAAM;GAAQ,UAAU;EAAK;EACtC,UAAU;GAAE,MAAM;GAAsC,UAAU;EAAK;EACvE,iBAAiB;GACf,MAAM;GACN,SAAS;EACX;EACA,WAAW;GAAE,MAAM;GAAQ,SAAS;EAAE;EACtC,WAAW;GAAE,MAAM;GAAQ,SAAS;EAAE;EACtC,MAAM;GAAE,MAAM;GAAQ,SAAS;EAAI;EACnC,OAAO;GAAE,MAAM;GAAQ,SAAS;EAAI;EACpC,IAAI;EACJ,IAAI;EACJ,QAAQ;CACV;CACA,MAAM,OAAO;EACX,MAAM,SAAS,eACb,eACE,MAAM,SAAS,MAAM,OAAO,EAC1B,iBAAiB,MAAM,gBACzB,CAAC,CACH,CACF;EACA,MAAM,OAAO,eAAe;GAC1B,MAAM,YAAY,kBAAkB,MAAM,WAAW,CAAC;GACtD,MAAM,YAAY,KAAK,IAAI,GAAG,kBAAkB,MAAM,WAAW,CAAC,CAAC;GACnE,MAAM,QAAQ,MAAM,SAAS,MAAM,QAAQ,MAAM,MAAM,OAAO,SAAS;GACvE,MAAM,SAAS,MAAM,SAAS,MAAM,OAAO,MAAM,OAAO,OAAO,SAAS;GACxE,MAAM,WAAW,MAAM,OAAO,OAAO,MAAM,SAAS,YAAY,CAAC;GACjE,MAAM,oBAAoB,MAAM,OAAO,SAAS;GAChD,OAAO;IACL,GAAG,MAAc,SAAS,EAAE,KAAK,QAAQ;IACzC,GAAG,OAAO,MAAM,KACb,QACC,GAAG,oBAAoB,IAAI,KAAK,SAAU,OAAO,OAAO,KAAM,EAAE,KAAK,EAAE,IAAI,mBAC/E;IACA,GAAG,MAAc,SAAS,EAAE,KAAK,QAAQ;GAC3C;EACF,CAAC;EAED,aACE,EACE,OACA;GACE,OAAO,EAAE,eAAe,SAAS;GACjC,cAAc,eAAe,MAAM;EACrC,GACA,KAAK,MAAM,KAAK,KAAK,UACnB,EAAE,QAAQ;GAAE,KAAK;GAAO,MAAM;GAAK,IAAI,MAAM;GAAI,IAAI,MAAM;EAAG,CAAC,CACjE,CACF;CACJ;AACF,CAAC"}
|
package/dist/testing/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as FrescoElement,
|
|
3
|
-
import { r as FocusManager, t as UseAppReturn } from "../useApp-
|
|
1
|
+
import { N as MouseEvent, S as FrescoRenderNode, j as KeyEvent } from "../protocol-DavoeNLn.mjs";
|
|
2
|
+
import { i as FrescoElement, l as FrescoNode, m as createRenderer$1, n as AriaState, t as AriaRole, u as FrescoNodeLifecycleHooks } from "../accessibility-DwzT925M.mjs";
|
|
3
|
+
import { r as FocusManager, t as UseAppReturn } from "../useApp-vIRJ5Th3.mjs";
|
|
4
4
|
import { App, Component, Ref, VNodeChild } from "vue";
|
|
5
5
|
|
|
6
6
|
//#region src/testing/mount.d.ts
|
package/dist/testing/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as createFocusManager, E as FOCUS_KEY, M as createAppContext, P as SCREEN_READER_KEY, _ as CURSOR_KEY, a as lastMouseEvent, b as STREAMS_KEY, d as isStaticNode, f as createRenderer$1, i as lastKeyEvent, j as APP_KEY, n as lastCompositionEvent, o as lastPasteEvent, p as treeToRenderNodes, r as lastFocusEvent, s as lastResizeEvent, u as isStaticItemNode, v as createCursorContext, x as createStreamsContext } from "../app-C_wFlWSV.mjs";
|
|
2
2
|
import { h, nextTick, ref } from "vue";
|
|
3
3
|
//#region src/testing/mount.ts
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ref } from "vue";
|
|
1
|
+
import { InjectionKey, Ref } from "vue";
|
|
2
2
|
|
|
3
3
|
//#region src/composables/useFocus.d.ts
|
|
4
4
|
interface UseFocusOptions {
|
|
@@ -10,6 +10,21 @@ interface UseFocusOptions {
|
|
|
10
10
|
id?: string;
|
|
11
11
|
/** Parent focus ID used to derive descendant-focus state */
|
|
12
12
|
parentId?: string | null | Ref<string | null | undefined>;
|
|
13
|
+
/** Descendant that receives focus when this target is focused */
|
|
14
|
+
delegateFocusTo?: string | null | Ref<string | null | undefined>;
|
|
15
|
+
/** Keep programmatic and sequential focus inside this target subtree */
|
|
16
|
+
trapFocus?: boolean | Ref<boolean>;
|
|
17
|
+
}
|
|
18
|
+
/** Registration state retained for one focusable target. */
|
|
19
|
+
interface FocusRegistrationOptions {
|
|
20
|
+
/** Whether the target participates in focus traversal. @default true */
|
|
21
|
+
isActive?: boolean;
|
|
22
|
+
/** Focus the target when no target currently owns focus. @default false */
|
|
23
|
+
autoFocus?: boolean;
|
|
24
|
+
/** Registered parent used for descendant and trap boundaries. @default null */
|
|
25
|
+
parentId?: string | null | undefined;
|
|
26
|
+
/** Registered descendant that receives delegated focus. @default null */
|
|
27
|
+
delegateFocusTo?: string | null | undefined;
|
|
13
28
|
}
|
|
14
29
|
interface FocusManager {
|
|
15
30
|
/** Currently focused element ID */
|
|
@@ -18,6 +33,8 @@ interface FocusManager {
|
|
|
18
33
|
activeId: Readonly<Ref<string | undefined>>;
|
|
19
34
|
/** All active focusable element IDs */
|
|
20
35
|
focusableIds: Readonly<Ref<string[]>>;
|
|
36
|
+
/** Innermost active focus-trap root, when present */
|
|
37
|
+
activeTrapId: Readonly<Ref<string | undefined>>;
|
|
21
38
|
/** Whether focus management is enabled */
|
|
22
39
|
isEnabled: Ref<boolean>;
|
|
23
40
|
/** Enable focus management */
|
|
@@ -31,20 +48,24 @@ interface FocusManager {
|
|
|
31
48
|
/** Focus previous element */
|
|
32
49
|
focusPrevious: () => void;
|
|
33
50
|
/** Register a focusable element */
|
|
34
|
-
register: (id: string, options?:
|
|
35
|
-
isActive?: boolean;
|
|
36
|
-
autoFocus?: boolean;
|
|
37
|
-
parentId?: string | null | undefined;
|
|
38
|
-
}) => void;
|
|
51
|
+
register: (id: string, options?: FocusRegistrationOptions) => void;
|
|
39
52
|
/** Unregister a focusable element */
|
|
40
53
|
unregister: (id: string) => void;
|
|
41
54
|
/** Activate or deactivate a focusable element while keeping its order */
|
|
42
55
|
setActive: (id: string, isActive: boolean) => void;
|
|
43
56
|
/** Reparent a focusable element while keeping its registration order */
|
|
44
57
|
setParent: (id: string, parentId: string | null | undefined) => void;
|
|
58
|
+
/** Change the descendant that receives delegated focus */
|
|
59
|
+
setDelegate: (id: string, delegateFocusTo: string | null | undefined) => void;
|
|
60
|
+
/** Activate a nested focus boundary rooted at a registered target */
|
|
61
|
+
trapFocus: (id: string) => void;
|
|
62
|
+
/** Release a focus boundary and every nested boundary that depends on it */
|
|
63
|
+
releaseFocusTrap: (id: string) => void;
|
|
45
64
|
/** Whether a registered descendant of the target currently owns focus */
|
|
46
65
|
hasFocusedDescendant: (id: string) => boolean;
|
|
47
66
|
}
|
|
67
|
+
/** Make an owning focus target the default parent for nested useFocus calls. */
|
|
68
|
+
declare function provideFocusScope(parentId: string | null | Ref<string | null | undefined>): void;
|
|
48
69
|
/**
|
|
49
70
|
* Use focus management
|
|
50
71
|
*/
|
|
@@ -52,6 +73,7 @@ declare function useFocus(options?: UseFocusOptions): {
|
|
|
52
73
|
id: string;
|
|
53
74
|
isFocused: import("vue").ComputedRef<boolean>;
|
|
54
75
|
hasFocusedDescendant: import("vue").ComputedRef<boolean>;
|
|
76
|
+
isFocusTrapActive: import("vue").ComputedRef<boolean>;
|
|
55
77
|
focus: (targetId?: string) => void;
|
|
56
78
|
blur: () => void;
|
|
57
79
|
};
|
|
@@ -65,8 +87,12 @@ declare function useFocusManager(): {
|
|
|
65
87
|
focusPrevious: () => void;
|
|
66
88
|
focus: (id: string) => void;
|
|
67
89
|
hasFocusedDescendant: (id: string) => boolean;
|
|
90
|
+
trapFocus: (id: string) => void;
|
|
91
|
+
releaseFocusTrap: (id: string) => void;
|
|
92
|
+
setDelegate: (id: string, delegateFocusTo: string | null | undefined) => void;
|
|
68
93
|
activeId: Readonly<Ref<string | undefined, string | undefined>>;
|
|
69
94
|
focusableIds: Readonly<Ref<string[], string[]>>;
|
|
95
|
+
activeTrapId: Readonly<Ref<string | undefined, string | undefined>>;
|
|
70
96
|
};
|
|
71
97
|
//#endregion
|
|
72
98
|
//#region src/composables/useApp.d.ts
|
|
@@ -91,5 +117,5 @@ interface UseAppReturn {
|
|
|
91
117
|
*/
|
|
92
118
|
declare function useApp(): UseAppReturn;
|
|
93
119
|
//#endregion
|
|
94
|
-
export {
|
|
95
|
-
//# sourceMappingURL=useApp-
|
|
120
|
+
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useApp-vIRJ5Th3.d.mts","names":[],"sources":["../src/composables/useFocus.ts","../src/composables/useApp.ts"],"mappings":";;;UAoBiB,eAAA;EAEM;EAArB,QAAA,aAAqB,GAAA;EAQa;EANlC,SAAA;EAQyB;EANzB,EAAA;EAJA;EAMA,QAAA,mBAA2B,GAAA;EAJ3B;EAMA,eAAA,mBAAkC,GAAA;EAFlC;EAIA,SAAA,aAAsB,GAAA;AAAA;;UAIP,wBAAA;EAJO;EAMtB,QAAA;EANyB;EAQzB,SAAA;EAJuC;EAMvC,QAAA;EANuC;EAQvC,eAAA;AAAA;AAAA,UAGe,YAAA;EAHf;EAKA,SAAA,EAAW,GAAA;EALI;EAOf,QAAA,EAAU,QAAA,CAAS,GAAA;EAJQ;EAM3B,YAAA,EAAc,QAAA,CAAS,GAAA;EAJZ;EAMX,YAAA,EAAc,QAAA,CAAS,GAAA;EAJb;EAMV,SAAA,EAAW,GAAA;EAJG;EAMd,WAAA;EAJc;EAMd,YAAA;EAQiC;EANjC,KAAA,GAAQ,EAAA;EAMiD;EAJzD,SAAA;EAhBW;EAkBX,aAAA;EAhBU;EAkBV,QAAA,GAAW,EAAA,UAAY,OAAA,GAAU,wBAAA;EAhBjC;EAkBA,UAAA,GAAa,EAAA;EAlBU;EAoBvB,SAAA,GAAY,EAAA,UAAY,QAAA;EAlBV;EAoBd,SAAA,GAAY,EAAA,UAAY,QAAA;EAlBxB;EAoBA,WAAA,GAAc,EAAA,UAAY,eAAA;EAlB1B;EAoBA,SAAA,GAAY,EAAA;EAhBZ;EAkBA,gBAAA,GAAmB,EAAA;EAhBnB;EAkBA,oBAAA,GAAuB,EAAA;AAAA;;iBAiPT,iBAAA,CAAkB,QAAwD,kBAA9B,GAAG;;;;iBAO/C,QAAA,CAAS,OAAA,GAAS,eAAoB;;;;;;;;AAxPnB;AAiPnC;;AAjPmC,iBAmWnB,eAAA;;;;;;;;;4BAzWU,eAAA;;;;;;;UCrET,YAAA;EDcM;ECZrB,KAAA,EAAO,GAAA;EDoB2B;EClBlC,MAAA,EAAQ,GAAA;EDoBiB;EClBzB,SAAA,EAAW,GAAA;EDQX;ECNA,IAAA,GAAO,aAAA;EDQP;ECNA,MAAA;EDUA;ECRA,KAAA;EDUA;ECRA,oBAAA,QAA4B,OAAA;AAAA;;;;iBAwEd,MAAA,IAAU,YAAY"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { computed, inject, isRef, onUnmounted, ref, watch } from "vue";
|
|
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-C_wFlWSV.mjs";
|
|
2
|
+
import { computed, inject, isRef, onMounted, onUnmounted, reactive, ref, watch } from "vue";
|
|
3
3
|
//#region src/composables/useIsScreenReaderEnabled.ts
|
|
4
4
|
/**
|
|
5
5
|
* useIsScreenReaderEnabled - screen reader mode flag.
|
|
@@ -138,7 +138,7 @@ function handleStructuredOptions(event, options, lastKey) {
|
|
|
138
138
|
const inkKey = toInkKey(event);
|
|
139
139
|
if (event.char) {
|
|
140
140
|
lastKey.value = event.char;
|
|
141
|
-
options.onChar?.(event.char);
|
|
141
|
+
if (!event.ctrl && !event.alt && !event.meta) options.onChar?.(event.char);
|
|
142
142
|
options.onKey?.(event.char, modifiers);
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
@@ -172,7 +172,7 @@ function useInput(handlerOrOptions = {}, handlerOptions = {}) {
|
|
|
172
172
|
const inkKey = toInkKey(event);
|
|
173
173
|
const input = inputValue(event, inkKey);
|
|
174
174
|
const pressedKey = keyName(event);
|
|
175
|
-
if (input === "c" && inkKey.ctrl && streams.internal_exitOnCtrlC) return;
|
|
175
|
+
if (input === "c" && inkKey.ctrl && streams.internal_exitOnCtrlC && !options.captureCtrlC) return;
|
|
176
176
|
lastKey.value = pressedKey || null;
|
|
177
177
|
options.handler?.(input, inkKey);
|
|
178
178
|
handleStructuredOptions(event, options, lastKey);
|
|
@@ -323,6 +323,66 @@ function createVirtualViewport(options) {
|
|
|
323
323
|
/** Composition API alias for {@link createVirtualViewport}. */
|
|
324
324
|
const useVirtualViewport = createVirtualViewport;
|
|
325
325
|
//#endregion
|
|
326
|
-
|
|
326
|
+
//#region src/composables/useBoxMetrics.ts
|
|
327
|
+
/**
|
|
328
|
+
* useBoxMetrics - best-effort layout metrics for a rendered Fresco node.
|
|
329
|
+
*/
|
|
330
|
+
async function loadNative() {
|
|
331
|
+
return import("@vizejs/fresco-native");
|
|
332
|
+
}
|
|
333
|
+
function targetId(target) {
|
|
334
|
+
return target?.id ?? target?.$el?.id;
|
|
335
|
+
}
|
|
336
|
+
function useBoxMetrics(ref) {
|
|
337
|
+
const metrics = reactive({
|
|
338
|
+
width: 0,
|
|
339
|
+
height: 0,
|
|
340
|
+
left: 0,
|
|
341
|
+
top: 0,
|
|
342
|
+
hasMeasured: false
|
|
343
|
+
});
|
|
344
|
+
let timer = null;
|
|
345
|
+
const applyLayout = (layout) => {
|
|
346
|
+
metrics.width = layout.width;
|
|
347
|
+
metrics.height = layout.height;
|
|
348
|
+
metrics.left = layout.x;
|
|
349
|
+
metrics.top = layout.y;
|
|
350
|
+
metrics.hasMeasured = true;
|
|
351
|
+
};
|
|
352
|
+
const refresh = () => {
|
|
353
|
+
const id = targetId(ref.value);
|
|
354
|
+
if (id === void 0) {
|
|
355
|
+
metrics.width = 0;
|
|
356
|
+
metrics.height = 0;
|
|
357
|
+
metrics.left = 0;
|
|
358
|
+
metrics.top = 0;
|
|
359
|
+
metrics.hasMeasured = false;
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
const cachedLayout = getLastRenderLayout(ref.value);
|
|
363
|
+
if (cachedLayout) {
|
|
364
|
+
applyLayout(cachedLayout);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
loadNative().then((native) => {
|
|
368
|
+
const layouts = "getLastRenderLayouts" in native ? native.getLastRenderLayouts() : [];
|
|
369
|
+
updateLastRenderLayouts(layouts);
|
|
370
|
+
const layout = layouts.find((item) => item.id === id);
|
|
371
|
+
if (!layout) return;
|
|
372
|
+
applyLayout(layout);
|
|
373
|
+
}).catch(() => {});
|
|
374
|
+
};
|
|
375
|
+
metrics.refresh = refresh;
|
|
376
|
+
onMounted(() => {
|
|
377
|
+
refresh();
|
|
378
|
+
timer = setInterval(refresh, 100);
|
|
379
|
+
});
|
|
380
|
+
onUnmounted(() => {
|
|
381
|
+
if (timer) clearInterval(timer);
|
|
382
|
+
});
|
|
383
|
+
return metrics;
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
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 };
|
|
327
387
|
|
|
328
|
-
//# sourceMappingURL=
|
|
388
|
+
//# sourceMappingURL=useBoxMetrics-lF5Myjc7.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBoxMetrics-lF5Myjc7.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\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\nexport interface UsePasteOptions {\n /** Whether the paste handler is active */\n isActive?: boolean | Ref<boolean>;\n}\n\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\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\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\nexport interface KeyHandler {\n (key: string, modifiers: { ctrl: boolean; alt: boolean; shift: boolean; meta: boolean }): void;\n}\n\nexport interface UseInputOptions {\n /** Whether to capture input (boolean or Ref<boolean>) */\n active?: boolean | Ref<boolean>;\n /** Whether to capture input (alias for active, boolean or Ref<boolean>) */\n isActive?: boolean | Ref<boolean>;\n /** Ink-compatible input callback */\n handler?: (input: string, key: Key) => void;\n /** Called on key press */\n onKey?: KeyHandler;\n /** Called on character input */\n onChar?: (char: string) => void;\n /** Called on Enter */\n onSubmit?: () => void;\n /** Called on Escape */\n onEscape?: () => void;\n /** Called on arrow keys */\n onArrow?: (direction: \"up\" | \"down\" | \"left\" | \"right\") => void;\n /** Called when an IME composition starts */\n onCompositionStart?: () => void;\n /** Called when IME preedit text changes */\n onCompositionUpdate?: (text: string, cursor: number) => void;\n /** Called when IME commits text */\n onCompositionEnd?: (text: string) => void;\n /** Deliver Ctrl+C to this handler instead of reserving it for app exit. */\n captureCtrlC?: boolean;\n}\n\nexport interface UseInputReturn {\n isActive: Ref<boolean>;\n lastKey: Ref<string | null>;\n enable: () => void;\n disable: () => void;\n}\n\nexport type InputHandler = (input: string, key: Key) => void;\n\nexport interface UseInputHandlerOptions {\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\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\nexport interface UseMouseOptions {\n /** Whether the handler receives events. */\n isActive?: boolean | Readonly<Ref<boolean>>;\n}\n\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\nexport type VirtualScrollAlignment = \"nearest\" | \"start\" | \"center\" | \"end\";\n\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\nexport interface VirtualViewportOptions {\n itemCount: number;\n viewportSize: number;\n overscan?: number;\n initialOffset?: number;\n}\n\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\nexport interface BoxMetrics {\n width: number;\n height: number;\n left: number;\n top: number;\n}\n\nexport interface UseBoxMetricsResult extends BoxMetrics {\n hasMeasured: boolean;\n /** Refresh from the latest completed native layout snapshot. */\n refresh(): void;\n}\n\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\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":";;;;;;AAOA,SAAgB,2B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