@zaly/tui 0.0.6 → 0.0.8
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/assets/schemas/theme.schema.json +272 -270
- package/assets/themes/kanagawa-dragon.json +3 -0
- package/assets/themes/kanagawa-wave.json +3 -0
- package/dist/{actions-CnVzKVID.d.mts → actions-DFboj3g5.d.mts} +4 -4
- package/dist/{actions-CnVzKVID.d.mts.map → actions-DFboj3g5.d.mts.map} +1 -1
- package/dist/ansi.d.mts +10 -11
- package/dist/ansi.d.mts.map +1 -1
- package/dist/ansi.mjs +1 -2
- package/dist/{autocomplete-Dfw-yQDa.d.mts → autocomplete-CxzetPOo.d.mts} +4 -4
- package/dist/{autocomplete-Dfw-yQDa.d.mts.map → autocomplete-CxzetPOo.d.mts.map} +1 -1
- package/dist/{box-DepqUtuo.mjs → box-DLEcEvDH.mjs} +18 -11
- package/dist/box-DLEcEvDH.mjs.map +1 -0
- package/dist/{builder-DTz5mppV.mjs → builder-IkMf7I8z.mjs} +5 -4
- package/dist/builder-IkMf7I8z.mjs.map +1 -0
- package/dist/{callbacks-DcMBGQEO.mjs → callbacks-D132G8dy.mjs} +7 -6
- package/dist/callbacks-D132G8dy.mjs.map +1 -0
- package/dist/{client-BBdtbLp4.mjs → client-C2GXKfJ1.mjs} +63 -9
- package/dist/client-C2GXKfJ1.mjs.map +1 -0
- package/dist/client-bzdHIDL2.mjs +1 -0
- package/dist/{clipboard-l_TWxxTf.mjs → clipboard-CNPBTX7j.mjs} +9 -7
- package/dist/{clipboard-l_TWxxTf.mjs.map → clipboard-CNPBTX7j.mjs.map} +1 -1
- package/dist/clipboard.d.mts +6 -7
- package/dist/clipboard.d.mts.map +1 -1
- package/dist/clipboard.mjs +1 -2
- package/dist/{ctx-DjJ1zSbs.mjs → ctx-CXjkWABc.mjs} +3 -3
- package/dist/{ctx-DjJ1zSbs.mjs.map → ctx-CXjkWABc.mjs.map} +1 -1
- package/dist/ctx-Dh6slUVy.mjs +1 -0
- package/dist/{divider-cclEAdPx.mjs → divider-l0-JPEIm.mjs} +2 -2
- package/dist/{divider-cclEAdPx.mjs.map → divider-l0-JPEIm.mjs.map} +1 -1
- package/dist/{files-Aw3iWpXD.d.mts → files-BUsa-RVl.d.mts} +3 -3
- package/dist/{files-Aw3iWpXD.d.mts.map → files-BUsa-RVl.d.mts.map} +1 -1
- package/dist/{github-DS00VoOj.d.mts → github-D89A3F9U.d.mts} +3 -3
- package/dist/{github-DS00VoOj.d.mts.map → github-D89A3F9U.d.mts.map} +1 -1
- package/dist/{image-BTxDPPiT.d.mts → image-34bU73bW.d.mts} +2 -2
- package/dist/{image-BTxDPPiT.d.mts.map → image-34bU73bW.d.mts.map} +1 -1
- package/dist/image.d.mts +14 -15
- package/dist/image.d.mts.map +1 -1
- package/dist/image.mjs +1 -2
- package/dist/index.d.mts +13 -13
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{input-CRBuTrsL.mjs → input-D7fQEUdt.mjs} +3 -3
- package/dist/input-D7fQEUdt.mjs.map +1 -0
- package/dist/{input-B5Vy-iaa.d.mts → input-Dylds_sI.d.mts} +3 -3
- package/dist/input-Dylds_sI.d.mts.map +1 -0
- package/dist/{inspect-D6FW_QUo.d.mts → inspect-DPLRum7L.d.mts} +2 -2
- package/dist/{inspect-D6FW_QUo.d.mts.map → inspect-DPLRum7L.d.mts.map} +1 -1
- package/dist/{inspect-DE5goDzB.mjs → inspect-xR9KKdk9.mjs} +3 -3
- package/dist/{inspect-DE5goDzB.mjs.map → inspect-xR9KKdk9.mjs.map} +1 -1
- package/dist/kitty-JbCJC0iQ.mjs.map +1 -1
- package/dist/{log-Djvrxqk0.mjs → log-CnewrxAc.mjs} +4 -4
- package/dist/{log-Djvrxqk0.mjs.map → log-CnewrxAc.mjs.map} +1 -1
- package/dist/{logger-DDrt03So.mjs → logger-CWEGIWaG.mjs} +3 -3
- package/dist/logger-CWEGIWaG.mjs.map +1 -0
- package/dist/{markdown-CTlPe5ks.mjs → markdown-C6UVXJoj.mjs} +7 -7
- package/dist/markdown-C6UVXJoj.mjs.map +1 -0
- package/dist/markdown.d.mts +5 -5
- package/dist/markdown.d.mts.map +1 -1
- package/dist/markdown.mjs +1 -2
- package/dist/md.bun.d.mts +1 -2
- package/dist/md.bun.d.mts.map +1 -1
- package/dist/md.node.d.mts +1 -2
- package/dist/md.node.d.mts.map +1 -1
- package/dist/node-BZ7f6HzU.mjs.map +1 -1
- package/dist/{overlay-9xNgsuuy.mjs → overlay-9WXYiGgW.mjs} +2 -2
- package/dist/{overlay-9xNgsuuy.mjs.map → overlay-9WXYiGgW.mjs.map} +1 -1
- package/dist/{picker-cH-rc7-X.mjs → picker-BqHINl_a.mjs} +4 -4
- package/dist/picker-BqHINl_a.mjs.map +1 -0
- package/dist/{picker-D8OLb6kZ.d.mts → picker-JL8lZfRH.d.mts} +5 -5
- package/dist/{picker-D8OLb6kZ.d.mts.map → picker-JL8lZfRH.d.mts.map} +1 -1
- package/dist/queries-B_lOwEiE.mjs.map +1 -1
- package/dist/{queries-DH3bj74K.d.mts → queries-Cvalgu6P.d.mts} +3 -3
- package/dist/queries-Cvalgu6P.d.mts.map +1 -0
- package/dist/reactive-f7NpAi69.mjs.map +1 -1
- package/dist/{registry-w_w7gZr_.mjs → registry-JjYaWUZz.mjs} +2 -2
- package/dist/registry-JjYaWUZz.mjs.map +1 -0
- package/dist/{render-F8pVXN7h.mjs → render-DtRw_LwV.mjs} +2 -2
- package/dist/{render-F8pVXN7h.mjs.map → render-DtRw_LwV.mjs.map} +1 -1
- package/dist/{renderer-uMeDzF9B.mjs → renderer-BOqnFB5U.mjs} +7 -7
- package/dist/renderer-BOqnFB5U.mjs.map +1 -0
- package/dist/renderer-BSMOuiLM.mjs +1 -0
- package/dist/{renderer-qSMVeNSV.mjs → renderer-DesbRwjQ.mjs} +2 -2
- package/dist/renderer-DesbRwjQ.mjs.map +1 -0
- package/dist/select-m7NE6Rwa.mjs.map +1 -1
- package/dist/{select-CbmAZdpt.d.mts → select-zGd5pbiB.d.mts} +3 -3
- package/dist/{select-CbmAZdpt.d.mts.map → select-zGd5pbiB.d.mts.map} +1 -1
- package/dist/services/logger.d.mts +1 -1
- package/dist/services/logger.mjs +1 -2
- package/dist/services/notifier.d.mts +3 -4
- package/dist/services/notifier.d.mts.map +1 -1
- package/dist/services/notifier.mjs +2 -2
- package/dist/services/notifier.mjs.map +1 -1
- package/dist/services/picker.d.mts +8 -9
- package/dist/services/picker.d.mts.map +1 -1
- package/dist/services/picker.mjs +10 -8
- package/dist/services/picker.mjs.map +1 -1
- package/dist/services/prompt.d.mts +8 -9
- package/dist/services/prompt.d.mts.map +1 -1
- package/dist/services/prompt.mjs +9 -7
- package/dist/services/prompt.mjs.map +1 -1
- package/dist/shiki/server.d.mts +1 -1
- package/dist/shiki/server.mjs +6 -2
- package/dist/shiki/server.mjs.map +1 -1
- package/dist/{shiki-BK-v9CtF.mjs → shiki--ASSYv4_.mjs} +3 -3
- package/dist/{shiki-BK-v9CtF.mjs.map → shiki--ASSYv4_.mjs.map} +1 -1
- package/dist/{shiki-B5NwIiot.mjs → shiki-D7l5--zz.mjs} +19 -5
- package/dist/shiki-D7l5--zz.mjs.map +1 -0
- package/dist/show-DR2x1YFc.mjs.map +1 -1
- package/dist/style.d.mts +7 -7
- package/dist/style.d.mts.map +1 -1
- package/dist/style.mjs +2 -2
- package/dist/{text-DILrol9j.mjs → text-BLz1tRoC.mjs} +4 -3
- package/dist/{text-DILrol9j.mjs.map → text-BLz1tRoC.mjs.map} +1 -1
- package/dist/{text-9lwQeqYr.d.mts → text-BefiXAFW.d.mts} +3 -3
- package/dist/{text-9lwQeqYr.d.mts.map → text-BefiXAFW.d.mts.map} +1 -1
- package/dist/{text-q26V6_Sc.mjs → text-CRZD9KTN.mjs} +3 -2
- package/dist/{text-q26V6_Sc.mjs.map → text-CRZD9KTN.mjs.map} +1 -1
- package/dist/text.d.mts +1 -1
- package/dist/text.mjs +1 -2
- package/dist/{theme.config-BptYUq4K.mjs → theme.config-DHgHWQ9t.mjs} +273 -242
- package/dist/theme.config-DHgHWQ9t.mjs.map +1 -0
- package/dist/themes.d.mts +8 -9
- package/dist/themes.d.mts.map +1 -1
- package/dist/themes.mjs +1 -2
- package/dist/tree-Bo1afYhe.mjs.map +1 -1
- package/dist/{tree-C28QOVIK.d.mts → tree-CArtDRec.d.mts} +3 -3
- package/dist/{tree-C28QOVIK.d.mts.map → tree-CArtDRec.d.mts.map} +1 -1
- package/dist/{types-B9Eh7k2v.d.mts → types-C0EOLZDc.d.mts} +7 -2
- package/dist/types-C0EOLZDc.d.mts.map +1 -0
- package/dist/{widget-M7jD8Rgg.d.mts → widget-DtJU2-BJ.d.mts} +2 -2
- package/dist/{widget-M7jD8Rgg.d.mts.map → widget-DtJU2-BJ.d.mts.map} +1 -1
- package/dist/widgets/autocomplete.d.mts +1 -1
- package/dist/widgets/autocomplete.mjs +2 -2
- package/dist/widgets/autocomplete.mjs.map +1 -1
- package/dist/widgets/box.d.mts +1 -1
- package/dist/widgets/box.mjs +1 -2
- package/dist/widgets/code.d.mts +4 -5
- package/dist/widgets/code.d.mts.map +1 -1
- package/dist/widgets/code.mjs +5 -5
- package/dist/widgets/completions/actions.d.mts +1 -1
- package/dist/widgets/completions/actions.mjs +1 -2
- package/dist/widgets/completions/files.d.mts +1 -1
- package/dist/widgets/completions/files.mjs +1 -2
- package/dist/widgets/completions/github.d.mts +1 -1
- package/dist/widgets/completions/github.mjs +1 -2
- package/dist/widgets/completions/index.d.mts +3 -3
- package/dist/widgets/diff.d.mts +5 -6
- package/dist/widgets/diff.d.mts.map +1 -1
- package/dist/widgets/diff.mjs +3 -3
- package/dist/widgets/diff.mjs.map +1 -1
- package/dist/widgets/divider.d.mts +4 -5
- package/dist/widgets/divider.d.mts.map +1 -1
- package/dist/widgets/divider.mjs +1 -2
- package/dist/widgets/image.d.mts +1 -1
- package/dist/widgets/image.mjs +1 -1
- package/dist/widgets/image.mjs.map +1 -1
- package/dist/widgets/input.d.mts +1 -1
- package/dist/widgets/input.mjs +1 -2
- package/dist/widgets/log.d.mts +1 -1
- package/dist/widgets/log.mjs +1 -2
- package/dist/widgets/markdown.d.mts +8 -9
- package/dist/widgets/markdown.d.mts.map +1 -1
- package/dist/widgets/markdown.mjs +1 -2
- package/dist/widgets/overlay.d.mts +1 -1
- package/dist/widgets/overlay.mjs +1 -2
- package/dist/widgets/picker.d.mts +1 -1
- package/dist/widgets/picker.mjs +1 -2
- package/dist/widgets/progress.d.mts +5 -6
- package/dist/widgets/progress.d.mts.map +1 -1
- package/dist/widgets/select.d.mts +1 -1
- package/dist/widgets/select.mjs +1 -2
- package/dist/widgets/show.d.mts +7 -7
- package/dist/widgets/show.d.mts.map +1 -1
- package/dist/widgets/show.mjs +1 -2
- package/dist/widgets/spinner.d.mts +7 -8
- package/dist/widgets/spinner.d.mts.map +1 -1
- package/dist/widgets/spinner.mjs.map +1 -1
- package/dist/widgets/text.d.mts +1 -1
- package/dist/widgets/text.mjs +1 -2
- package/dist/widgets/tree.d.mts +1 -1
- package/dist/widgets/tree.mjs +1 -2
- package/dist/widgets/widget.d.mts +1 -1
- package/dist/widgets/widget.mjs +1 -2
- package/dist/worker-C01jK2Ip.mjs +1 -0
- package/dist/worker-T6SdPzUH.mjs.map +1 -1
- package/package.json +11 -12
- package/dist/box-DepqUtuo.mjs.map +0 -1
- package/dist/builder-DTz5mppV.mjs.map +0 -1
- package/dist/callbacks-DcMBGQEO.mjs.map +0 -1
- package/dist/client-BBdtbLp4.mjs.map +0 -1
- package/dist/client-cIckDgAj.mjs +0 -2
- package/dist/ctx-Bt4VlRPg.mjs +0 -2
- package/dist/input-B5Vy-iaa.d.mts.map +0 -1
- package/dist/input-CRBuTrsL.mjs.map +0 -1
- package/dist/logger-DDrt03So.mjs.map +0 -1
- package/dist/markdown-CTlPe5ks.mjs.map +0 -1
- package/dist/picker-cH-rc7-X.mjs.map +0 -1
- package/dist/queries-DH3bj74K.d.mts.map +0 -1
- package/dist/registry-w_w7gZr_.mjs.map +0 -1
- package/dist/renderer-Dgj_qEOA.mjs +0 -2
- package/dist/renderer-qSMVeNSV.mjs.map +0 -1
- package/dist/renderer-uMeDzF9B.mjs.map +0 -1
- package/dist/shiki-B5NwIiot.mjs.map +0 -1
- package/dist/theme.config-BptYUq4K.mjs.map +0 -1
- package/dist/types-B9Eh7k2v.d.mts.map +0 -1
- package/dist/worker-BvRm4OsW.mjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-BZ7f6HzU.mjs","names":["#children","#state","#mountAc","#ctx","#id","#parent","#actionTargets","#cache","#invalidations","#rendering","#render","#registerActionMeta"],"sources":["../src/core/node.ts"],"sourcesContent":["import type { MaybePromise } from \"@zaly/shared\"\nimport type { TryResult } from \"@zaly/shared/logger\"\nimport type { ActionCtx, ActionDef, NodeActionMap } from \"../input/actions.ts\"\nimport type { RoutedKey, RoutedPaste } from \"../input/router.ts\"\nimport type { SurfaceType } from \"../renderer/renderer.ts\"\nimport type { MountCtx, RenderCtx } from \"./ctx.ts\"\nimport type { Ref, SignalStore } from \"./reactive.ts\"\nimport type { Layout, State } from \"./state.ts\"\n\nimport { Emitter } from \"@zaly/shared\"\nimport { createStore, inRenderContextOf, unwrap, withActiveNode } from \"./reactive.ts\"\n\n/** Minimum event map every node carries. Custom event maps intersect\n * this with their own events via `&`. */\nexport type BaseEvents = {\n invalidate: {}\n mount: {}\n unmount: {}\n focus: {}\n blur: {}\n show: {}\n hide: {}\n key: { key: RoutedKey }\n paste: { paste: RoutedPaste }\n childadded: { child: Node }\n childremoved: { child: Node }\n}\n\n/**\n * Public Node handle. Calling `render(ctx)` returns the node's rows from the\n * per-node cache, recomputing only if state read inside `_render` has changed\n * since the last call.\n *\n * Concrete subclasses implement the protected `_render(ctx)` hook; the public\n * `render` is the caching wrapper around it.\n *\n * State is a `createStore` proxy: reads inside `_render` track per-field;\n * mutating a read field invalidates this node. Three write forms:\n *\n * - `n.state.field = value` (direct assignment)\n * - `n.state.set({ field: value, ... })` (patch — partial merge)\n * - `n.state.set(current => ({ ... }))` (updater — receives untracked current)\n *\n * Writes through nested objects/arrays (`n.state.padding[0] = 1`) do NOT —\n * reassign the whole field instead.\n */\nexport abstract class Node<T extends object = object, E extends {} = {}> extends Emitter<\n BaseEvents,\n E\n> {\n #cache?: { rows: string[]; version: number; width: number }\n #parent?: Node\n #rendering: Promise<string[]> | undefined\n /** Bumped on every `invalidate()`. Captured at the start of a render\n * and re-checked after `_render` resolves: if the count moved, an\n * external mutation landed during the render and the rows we just\n * produced reflect pre-mutation state. We skip writing the cache in\n * that case so the surface's already-scheduled re-paint sees a\n * cache miss and re-renders against the latest state. */\n #invalidations = 0\n readonly #children: Node[] = []\n #state: SignalStore<T>\n #ctx?: MountCtx\n #id?: string\n #actionTargets = new Set<Node>()\n #mountAc?: AbortController\n actions?: NodeActionMap\n type?: string\n protected layout?(ctx: RenderCtx): MaybePromise<Layout | undefined>\n\n constructor(state: State<T>, ...children: Node[]) {\n super()\n this.onEmitError = (err) => {\n const logger = this.logger\n if (logger) logger.error(err)\n // oxlint-disable-next-line no-console\n else console.error(\"Uncaught node event error (node is unmounted, no ctx):\", err)\n }\n // `createStore` gives us per-field reactivity for free: reads\n // inside `_render` subscribe via the rendering Node's tracking\n // ctx, so mutating a read field invalidates exactly this node.\n // Fields nobody reads never allocate a signal — mutation is just\n // a state update with no cascade. Finer-grained than the old\n // \"any write invalidates everything\" Proxy.\n this.#state = createStore(state)\n children.forEach((c) => this.add(c))\n }\n\n withEvents<Events extends {}>(): this & Emitter<Events> {\n return this as unknown as this & Emitter<Events>\n }\n\n withActions<A extends NodeActionMap>(actions: A): this & { actions: A } {\n this.actions = { ...this.actions, ...actions }\n return this as this & { actions: A }\n }\n\n action(id: keyof NonNullable<this[\"actions\"]> & string, opts?: Partial<ActionCtx>): boolean {\n const entry = this.actions?.[id]\n const fn = typeof entry === \"function\" ? entry : entry?.fn\n if (!fn) return false\n fn({ source: \"programmatic\", target: this, ...opts, id, node: this })\n return true\n }\n\n get mountSignal(): AbortSignal {\n this.#mountAc ??= new AbortController()\n return this.#mountAc.signal\n }\n\n get state(): SignalStore<T> & State<T> {\n return this.#state\n }\n\n get children(): readonly Node[] {\n return this.#children\n }\n\n protected get logger() {\n return this.#ctx?.logger.child({\n id: this.#id,\n name: \"node\",\n node: this.type ?? \"unknown\",\n })\n }\n\n protected try<R>(fn: () => R): TryResult<R> {\n const logger = this.logger\n if (!logger) return fn() as TryResult<R>\n return logger.try(fn) as TryResult<R>\n }\n\n /** Fragment protocol — opt-in. When defined, layout containers\n * (Box's row/column allocator) treat this node as a transparent\n * fragment and substitute the returned children for `this` during\n * flex allocation and rendering. The fragment Node still exists in\n * the tree (it's mounted; it bubbles invalidates from its\n * descendants), but layout sees through it.\n *\n * Used by `show`, `errorBoundary`, `suspense`: their children carry\n * their own flex props through to the parent box, can share its\n * `gap`, and a row containing a `show` with multiple flex children\n * allocates per-leaf-slot rather than collapsing into one. */\n protected layoutChildren?(): readonly Node[]\n\n // Make parent readonly\n get parent(): Node | undefined {\n return this.#parent\n }\n\n /** Mount context when this node is attached to a surface — surface\n * identifier plus scoped handles to router / overlay / tree lookups.\n * `undefined` before mount and after unmount. Exposed so widget\n * authors can reach renderer services without closing over a ref. */\n get ctx(): MountCtx | undefined {\n return this.#ctx\n }\n\n get surface(): SurfaceType | undefined {\n return this.#ctx?.surface\n }\n\n get mounted(): boolean {\n return this.#ctx !== undefined\n }\n\n /**\n * Read or set the node's `id`. Called without args, returns the\n * current id. Called with a string, sets it and returns `this` for\n * chaining — useful when building trees inline:\n *\n * ```ts\n * input({...}).id(\"chat-input\").focus().on(\"submit\", ...)\n * ```\n *\n * The id is used by `ctx.getNode(id)` / `Renderer.getNode(id)` for\n * tree lookups, and by the input router as a per-instance scope for\n * keymap bindings (alongside the class-level `type`).\n */\n id(): string | undefined\n id(value: string): this\n id(value?: string): string | undefined | this {\n if (value === undefined) return this.#id\n this.#id = value\n return this\n }\n\n async getLayout(ctx: RenderCtx): Promise<Layout | undefined> {\n if (!this.layout) return\n return this.layout(ctx)\n }\n\n get layoutNodes(): readonly Node[] {\n if (this.layoutChildren === undefined) return [this]\n const ret: Node[] = []\n for (const c of this.with(() => this.layoutChildren?.()) ?? []) ret.push(...c.layoutNodes)\n return ret\n }\n\n addActionTarget(node: Node): this {\n this.#actionTargets.add(node)\n return this\n }\n\n removeActionTarget(node: Node): this {\n this.#actionTargets.delete(node)\n return this\n }\n\n get actionTargets(): Iterable<Node> {\n return this.#actionTargets\n }\n\n invalidate(): this {\n this.#cache = undefined\n // Suppress only when this invalidate originates from *inside this\n // node's own render call stack* — e.g. Markdown mutating its child\n // Text inside its own `_render`. The active render observes the\n // mutation as part of its own logic and produces rows that already\n // reflect it, so we skip the cascade *and* the generation bump:\n // the cache writeback at the end of the render is valid.\n //\n // External mutations (network callbacks, event handlers) and\n // mutations cascading up from a *deeper* render's own call stack\n // (e.g. Text._render mutating something that bubbles to Markdown\n // mid-Markdown-render) run outside *this* node's ALS scope, so\n // `inRenderContextOf(this)` returns `false` and they emit + bump\n // normally — the in-flight render's rows are stale, the cache\n // writeback gets skipped, and the surface schedules a fresh paint.\n if (inRenderContextOf(this)) return this\n this.#invalidations++\n // Always emit and always cascade — surfaces (stream, UI) dedupe\n // via their own `scheduled` flag, and the parent's cache always\n // includes whatever rows we returned last render, so a child\n // mutation always implies a stale parent cache. (We previously\n // skipped the cascade when `hadCache` was false, which was buggy:\n // a node that intentionally doesn't cache — e.g. one whose\n // `_render` mutates a child mid-render and skips the writeback —\n // would silently fail to dirty its parent on the next mutation,\n // pinning the surface to the first render's output.)\n void this.emit(\"invalidate\")\n this.parent?.invalidate()\n return this\n }\n\n with<R>(fn: () => R): R {\n return withActiveNode(this, () => fn())\n }\n\n async render(ctx: RenderCtx): Promise<string[]> {\n // `visible: false` on the state suppresses the render entirely —\n // no `_render` call, no cached rows, zero layout footprint. Opt-in\n // via `state.visible`; absence or `true` is the default shown path.\n // Resolve inside the tracking ctx so a signal accessor read\n // subscribes this node. Async work registered via `createAsync` is\n // fire-and-forget here; surfaces that need a \"wait until settled\"\n // commit (Stream) install a `SuspenseContext` boundary at their\n // append boundary and await it before painting.\n this.#rendering ??= this.with(() => this.#render(ctx))\n\n try {\n return await this.#rendering\n } finally {\n this.#rendering = undefined\n }\n }\n\n async #render(ctx: RenderCtx): Promise<string[]> {\n // Cache the hidden result too, so a later `invalidate()` sees\n // `hadCache === true` and cascades up — otherwise a toggleable\n // panel (autocomplete, modal) whose first paint happened while\n // hidden would swallow the flip-to-visible invalidate.\n if (!(unwrap(this.state.visible) ?? true)) {\n this.#cache = { rows: [], version: ctx.version, width: ctx.width }\n return this.#cache.rows\n }\n // Cache key includes `ctx.width` because rendered output is\n // width-dependent. `version` alone catches state/theme mutations\n // (top-level bumps version on theme change), but a parent passing\n // a different `width` to the same node — common in flex\n // measure-then-allocate passes — needs a fresh render.\n if (this.#cache?.version === ctx.version && this.#cache.width === ctx.width) {\n return this.#cache.rows\n }\n // Capture the invalidation count *before* awaiting `_render`. If\n // it bumps mid-render, the rows we get back are based on stale\n // state — the external mutation that bumped it has already emitted\n // and re-scheduled the surface, so skip caching. The re-paint will\n // run a fresh `_render` against the latest state.\n const stamp = this.#invalidations\n try {\n const rows = await this._render(ctx)\n if (this.#invalidations === stamp) {\n this.#cache = { rows, version: ctx.version, width: ctx.width }\n }\n return rows\n } catch (error) {\n this.logger?.error(error)\n // Don't cache the error result — a later invalidate should\n // re-render and give the user a chance to recover.\n this.#cache = undefined\n return [\n ctx.style.error(\n `[Node render error: ${error instanceof Error ? error.message : String(error)}]`\n ),\n ]\n }\n }\n\n protected abstract _render(ctx: RenderCtx): Promise<string[]> | string[]\n\n add(child: Node): this {\n this.splice(this.#children.length, 0, child)\n return this\n }\n\n remove(child: Node): this {\n const i = this.#children.indexOf(child)\n if (i === -1) return this\n this.splice(i, 1)\n return this\n }\n\n splice(start: number, deleteCount: number, ...items: Node[]): this {\n // Reject self-insertion — a node in its own children list would\n // create a cycle and stack-overflow on traversal.\n const filtered: Node[] = []\n for (const c of items) {\n if (c === this) continue\n filtered.push(c)\n }\n\n // If any item is already a child of this container, pull it out\n // first so we don't end up with duplicates. Adjust `start` when a\n // removal falls before it so the caller-relative index is preserved.\n let adjustedStart = Math.max(0, Math.min(start, this.#children.length))\n for (const c of filtered) {\n if (c.parent !== this) continue\n const i = this.#children.indexOf(c)\n if (i === -1) continue\n this.#children.splice(i, 1)\n if (i < adjustedStart) adjustedStart--\n }\n\n const removed = this.#children.splice(adjustedStart, deleteCount, ...filtered)\n for (const c of removed) {\n void this.emit(\"childremoved\", { child: c })\n if (c.mounted) c.unmount()\n if (c.parent === this) c.#parent = undefined\n }\n for (const c of filtered) {\n // Detach from old parent before rewriting `#parent`, so the old\n // parent's `remove()` path observes a consistent `c.parent === old`\n // and cleans up its own bookkeeping.\n if (c.parent && c.parent !== this) {\n c.unmount()\n c.parent.remove(c)\n }\n c.#parent = this\n void this.emit(\"childadded\", { child: c })\n if (this.#ctx !== undefined) c.mount(this.#ctx)\n }\n this.invalidate()\n return this\n }\n\n clear(): this {\n this.splice(0, this.#children.length)\n return this\n }\n\n mount(ctx: MountCtx): this {\n if (this.#ctx?.surface === ctx.surface) return this\n if (this.#ctx) {\n throw new Error(\n `Node is already mounted on \"${this.#ctx.surface}\" (requested \"${ctx.surface}\"). Unmount first if you meant to move it.`\n )\n }\n // Make sure state.visible is tracked and will trigger invalidate\n withActiveNode(this, () => unwrap(this.state.visible))\n this.#ctx = ctx\n this.#registerActionMeta(ctx)\n void this.emit(\"mount\")\n for (const c of this.#children) c.mount(ctx)\n return this\n }\n\n /** Contribute any `ActionInfo`-shaped entries in `this.actions` to\n * the catalog. The instance `fn` stays on the node (dispatch finds\n * it via the focus-chain walk); only metadata lands in the registry.\n * Uses `extend: false` so defaults don't clobber user overrides\n * that were registered before the widget mounted. */\n #registerActionMeta(ctx: MountCtx): void {\n if (!this.actions) return\n const metas: Record<string, ActionDef> = {}\n let any = false\n for (const [id, entry] of Object.entries(this.actions)) {\n if (typeof entry === \"function\") continue\n const { fn: _fn, ...info } = entry\n metas[id] = info\n any = true\n }\n if (any) ctx.actions.register(metas, { default: true })\n }\n\n unmount(): this {\n if (!this.#ctx) return this\n this.#mountAc?.abort()\n this.#mountAc = undefined\n for (const c of this.#children) c.unmount()\n void this.emit(\"unmount\")\n this.#ctx.input.blur(this)\n this.#ctx = undefined\n return this\n }\n\n /** Become the focused node. Routes through the MountCtx, which emits\n * `blur` on the previous focus and `focus` on this node.\n *\n * When called before the node is mounted (the common case for\n * `input({ focus: true }).on(...)` style setup), the focus is\n * deferred until the next `mount` event. That keeps the API\n * synchronous and side-effect-free at build time — callers don't\n * have to think about ordering. */\n focus(): this {\n if (!this.#ctx) {\n this.once(\"mount\", () => this.focus())\n return this\n }\n this.#ctx.input.focus(this)\n return this\n }\n\n /** Release focus. No-op when not mounted. */\n blur(): this {\n this.#ctx?.input.blur(this)\n return this\n }\n\n get visible() {\n return unwrap(this.state.visible) ?? true\n }\n\n show(): this {\n if (this.visible) return this\n this.state.visible = true\n void this.emit(\"show\")\n return this\n }\n\n hide(): this {\n if (!this.visible) return this\n this.state.visible = false\n void this.emit(\"hide\")\n return this\n }\n\n toggle(): this {\n this.state.visible = !this.visible\n return this\n }\n\n ref<N extends Node>(ref?: Ref<this extends N ? N : never>): this {\n if (ref) ref.value = this as unknown as Exclude<typeof ref.value, undefined>\n return this\n }\n\n isVisible(): boolean {\n return this.visible && (this.parent ? this.parent.isVisible() : true)\n }\n}\n\n/** Runtime type guard for Node.\n *\n * @internal*/\nexport function isNode(x: unknown): x is Node {\n return x instanceof Node\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,IAAsB,OAAtB,cAAiF,QAG/E;CACA;CACA;CACA;;;;;;;CAOA,iBAAiB;CACjB,YAA6B,CAAC;CAC9B;CACA;CACA;CACA,iCAAiB,IAAI,IAAU;CAC/B;CAC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,KAAKD,UAAU,MAAM;EACrB,KAAKA,WAAW,KAAA;EAChB,KAAK,MAAM,KAAK,KAAKF,WAAW,EAAE,QAAQ;EAC1C,KAAU,KAAK,SAAS;EACxB,KAAKG,KAAK,MAAM,KAAK,IAAI;EACzB,KAAKA,OAAO,KAAA;EACZ,OAAO;CACT;;;;;;;;;CAUA,QAAc;EACZ,IAAI,CAAC,KAAKA,MAAM;GACd,KAAK,KAAK,eAAe,KAAK,MAAM,CAAC;GACrC,OAAO;EACT;EACA,KAAKA,KAAK,MAAM,MAAM,IAAI;EAC1B,OAAO;CACT;;CAGA,OAAa;EACX,KAAKA,MAAM,MAAM,KAAK,IAAI;EAC1B,OAAO;CACT;CAEA,IAAI,UAAU;EACZ,OAAO,OAAO,KAAK,MAAM,OAAO,KAAK;CACvC;CAEA,OAAa;EACX,IAAI,KAAK,SAAS,OAAO;EACzB,KAAK,MAAM,UAAU;EACrB,KAAU,KAAK,MAAM;EACrB,OAAO;CACT;CAEA,OAAa;EACX,IAAI,CAAC,KAAK,SAAS,OAAO;EAC1B,KAAK,MAAM,UAAU;EACrB,KAAU,KAAK,MAAM;EACrB,OAAO;CACT;CAEA,SAAe;EACb,KAAK,MAAM,UAAU,CAAC,KAAK;EAC3B,OAAO;CACT;CAEA,IAAoB,KAA6C;EAC/D,IAAI,KAAK,IAAI,QAAQ;EACrB,OAAO;CACT;CAEA,YAAqB;EACnB,OAAO,KAAK,YAAY,KAAK,SAAS,KAAK,OAAO,UAAU,IAAI;CAClE;AACF"}
|
|
1
|
+
{"version":3,"file":"node-BZ7f6HzU.mjs","names":[],"sources":["../src/core/node.ts"],"sourcesContent":["import type { MaybePromise } from \"@zaly/shared\"\nimport type { TryResult } from \"@zaly/shared/logger\"\nimport type { ActionCtx, ActionDef, NodeActionMap } from \"../input/actions.ts\"\nimport type { RoutedKey, RoutedPaste } from \"../input/router.ts\"\nimport type { SurfaceType } from \"../renderer/renderer.ts\"\nimport type { MountCtx, RenderCtx } from \"./ctx.ts\"\nimport type { Ref, SignalStore } from \"./reactive.ts\"\nimport type { Layout, State } from \"./state.ts\"\n\nimport { Emitter } from \"@zaly/shared\"\nimport { createStore, inRenderContextOf, unwrap, withActiveNode } from \"./reactive.ts\"\n\n/** Minimum event map every node carries. Custom event maps intersect\n * this with their own events via `&`. */\nexport type BaseEvents = {\n invalidate: {}\n mount: {}\n unmount: {}\n focus: {}\n blur: {}\n show: {}\n hide: {}\n key: { key: RoutedKey }\n paste: { paste: RoutedPaste }\n childadded: { child: Node }\n childremoved: { child: Node }\n}\n\n/**\n * Public Node handle. Calling `render(ctx)` returns the node's rows from the\n * per-node cache, recomputing only if state read inside `_render` has changed\n * since the last call.\n *\n * Concrete subclasses implement the protected `_render(ctx)` hook; the public\n * `render` is the caching wrapper around it.\n *\n * State is a `createStore` proxy: reads inside `_render` track per-field;\n * mutating a read field invalidates this node. Three write forms:\n *\n * - `n.state.field = value` (direct assignment)\n * - `n.state.set({ field: value, ... })` (patch — partial merge)\n * - `n.state.set(current => ({ ... }))` (updater — receives untracked current)\n *\n * Writes through nested objects/arrays (`n.state.padding[0] = 1`) do NOT —\n * reassign the whole field instead.\n */\nexport abstract class Node<T extends object = object, E extends {} = {}> extends Emitter<\n BaseEvents,\n E\n> {\n #cache?: { rows: string[]; version: number; width: number }\n #parent?: Node\n #rendering: Promise<string[]> | undefined\n /** Bumped on every `invalidate()`. Captured at the start of a render\n * and re-checked after `_render` resolves: if the count moved, an\n * external mutation landed during the render and the rows we just\n * produced reflect pre-mutation state. We skip writing the cache in\n * that case so the surface's already-scheduled re-paint sees a\n * cache miss and re-renders against the latest state. */\n #invalidations = 0\n readonly #children: Node[] = []\n #state: SignalStore<T>\n #ctx?: MountCtx\n #id?: string\n #actionTargets = new Set<Node>()\n #mountAc?: AbortController\n actions?: NodeActionMap\n type?: string\n protected layout?(ctx: RenderCtx): MaybePromise<Layout | undefined>\n\n constructor(state: State<T>, ...children: Node[]) {\n super()\n this.onEmitError = (err) => {\n const logger = this.logger\n if (logger) logger.error(err)\n // oxlint-disable-next-line no-console\n else console.error(\"Uncaught node event error (node is unmounted, no ctx):\", err)\n }\n // `createStore` gives us per-field reactivity for free: reads\n // inside `_render` subscribe via the rendering Node's tracking\n // ctx, so mutating a read field invalidates exactly this node.\n // Fields nobody reads never allocate a signal — mutation is just\n // a state update with no cascade. Finer-grained than the old\n // \"any write invalidates everything\" Proxy.\n this.#state = createStore(state)\n children.forEach((c) => this.add(c))\n }\n\n withEvents<Events extends {}>(): this & Emitter<Events> {\n return this as unknown as this & Emitter<Events>\n }\n\n withActions<A extends NodeActionMap>(actions: A): this & { actions: A } {\n this.actions = { ...this.actions, ...actions }\n return this as this & { actions: A }\n }\n\n action(id: keyof NonNullable<this[\"actions\"]> & string, opts?: Partial<ActionCtx>): boolean {\n const entry = this.actions?.[id]\n const fn = typeof entry === \"function\" ? entry : entry?.fn\n if (!fn) return false\n fn({ source: \"programmatic\", target: this, ...opts, id, node: this })\n return true\n }\n\n get mountSignal(): AbortSignal {\n this.#mountAc ??= new AbortController()\n return this.#mountAc.signal\n }\n\n get state(): SignalStore<T> & State<T> {\n return this.#state\n }\n\n get children(): readonly Node[] {\n return this.#children\n }\n\n protected get logger() {\n return this.#ctx?.logger.child({\n id: this.#id,\n name: \"node\",\n node: this.type ?? \"unknown\",\n })\n }\n\n protected try<R>(fn: () => R): TryResult<R> {\n const logger = this.logger\n if (!logger) return fn() as TryResult<R>\n return logger.try(fn) as TryResult<R>\n }\n\n /** Fragment protocol — opt-in. When defined, layout containers\n * (Box's row/column allocator) treat this node as a transparent\n * fragment and substitute the returned children for `this` during\n * flex allocation and rendering. The fragment Node still exists in\n * the tree (it's mounted; it bubbles invalidates from its\n * descendants), but layout sees through it.\n *\n * Used by `show`, `errorBoundary`, `suspense`: their children carry\n * their own flex props through to the parent box, can share its\n * `gap`, and a row containing a `show` with multiple flex children\n * allocates per-leaf-slot rather than collapsing into one. */\n protected layoutChildren?(): readonly Node[]\n\n // Make parent readonly\n get parent(): Node | undefined {\n return this.#parent\n }\n\n /** Mount context when this node is attached to a surface — surface\n * identifier plus scoped handles to router / overlay / tree lookups.\n * `undefined` before mount and after unmount. Exposed so widget\n * authors can reach renderer services without closing over a ref. */\n get ctx(): MountCtx | undefined {\n return this.#ctx\n }\n\n get surface(): SurfaceType | undefined {\n return this.#ctx?.surface\n }\n\n get mounted(): boolean {\n return this.#ctx !== undefined\n }\n\n /**\n * Read or set the node's `id`. Called without args, returns the\n * current id. Called with a string, sets it and returns `this` for\n * chaining — useful when building trees inline:\n *\n * ```ts\n * input({...}).id(\"chat-input\").focus().on(\"submit\", ...)\n * ```\n *\n * The id is used by `ctx.getNode(id)` / `Renderer.getNode(id)` for\n * tree lookups, and by the input router as a per-instance scope for\n * keymap bindings (alongside the class-level `type`).\n */\n id(): string | undefined\n id(value: string): this\n id(value?: string): string | undefined | this {\n if (value === undefined) return this.#id\n this.#id = value\n return this\n }\n\n async getLayout(ctx: RenderCtx): Promise<Layout | undefined> {\n if (!this.layout) return\n return this.layout(ctx)\n }\n\n get layoutNodes(): readonly Node[] {\n if (this.layoutChildren === undefined) return [this]\n const ret: Node[] = []\n for (const c of this.with(() => this.layoutChildren?.()) ?? []) ret.push(...c.layoutNodes)\n return ret\n }\n\n addActionTarget(node: Node): this {\n this.#actionTargets.add(node)\n return this\n }\n\n removeActionTarget(node: Node): this {\n this.#actionTargets.delete(node)\n return this\n }\n\n get actionTargets(): Iterable<Node> {\n return this.#actionTargets\n }\n\n invalidate(): this {\n this.#cache = undefined\n // Suppress only when this invalidate originates from *inside this\n // node's own render call stack* — e.g. Markdown mutating its child\n // Text inside its own `_render`. The active render observes the\n // mutation as part of its own logic and produces rows that already\n // reflect it, so we skip the cascade *and* the generation bump:\n // the cache writeback at the end of the render is valid.\n //\n // External mutations (network callbacks, event handlers) and\n // mutations cascading up from a *deeper* render's own call stack\n // (e.g. Text._render mutating something that bubbles to Markdown\n // mid-Markdown-render) run outside *this* node's ALS scope, so\n // `inRenderContextOf(this)` returns `false` and they emit + bump\n // normally — the in-flight render's rows are stale, the cache\n // writeback gets skipped, and the surface schedules a fresh paint.\n if (inRenderContextOf(this)) return this\n this.#invalidations++\n // Always emit and always cascade — surfaces (stream, UI) dedupe\n // via their own `scheduled` flag, and the parent's cache always\n // includes whatever rows we returned last render, so a child\n // mutation always implies a stale parent cache. (We previously\n // skipped the cascade when `hadCache` was false, which was buggy:\n // a node that intentionally doesn't cache — e.g. one whose\n // `_render` mutates a child mid-render and skips the writeback —\n // would silently fail to dirty its parent on the next mutation,\n // pinning the surface to the first render's output.)\n void this.emit(\"invalidate\")\n this.parent?.invalidate()\n return this\n }\n\n with<R>(fn: () => R): R {\n return withActiveNode(this, () => fn())\n }\n\n async render(ctx: RenderCtx): Promise<string[]> {\n // `visible: false` on the state suppresses the render entirely —\n // no `_render` call, no cached rows, zero layout footprint. Opt-in\n // via `state.visible`; absence or `true` is the default shown path.\n // Resolve inside the tracking ctx so a signal accessor read\n // subscribes this node. Async work registered via `createAsync` is\n // fire-and-forget here; surfaces that need a \"wait until settled\"\n // commit (Stream) install a `SuspenseContext` boundary at their\n // append boundary and await it before painting.\n this.#rendering ??= this.with(() => this.#render(ctx))\n\n try {\n return await this.#rendering\n } finally {\n this.#rendering = undefined\n }\n }\n\n async #render(ctx: RenderCtx): Promise<string[]> {\n // Cache the hidden result too, so a later `invalidate()` sees\n // `hadCache === true` and cascades up — otherwise a toggleable\n // panel (autocomplete, modal) whose first paint happened while\n // hidden would swallow the flip-to-visible invalidate.\n if (!(unwrap(this.state.visible) ?? true)) {\n this.#cache = { rows: [], version: ctx.version, width: ctx.width }\n return this.#cache.rows\n }\n // Cache key includes `ctx.width` because rendered output is\n // width-dependent. `version` alone catches state/theme mutations\n // (top-level bumps version on theme change), but a parent passing\n // a different `width` to the same node — common in flex\n // measure-then-allocate passes — needs a fresh render.\n if (this.#cache?.version === ctx.version && this.#cache.width === ctx.width) {\n return this.#cache.rows\n }\n // Capture the invalidation count *before* awaiting `_render`. If\n // it bumps mid-render, the rows we get back are based on stale\n // state — the external mutation that bumped it has already emitted\n // and re-scheduled the surface, so skip caching. The re-paint will\n // run a fresh `_render` against the latest state.\n const stamp = this.#invalidations\n try {\n const rows = await this._render(ctx)\n if (this.#invalidations === stamp) {\n this.#cache = { rows, version: ctx.version, width: ctx.width }\n }\n return rows\n } catch (error) {\n this.logger?.error(error)\n // Don't cache the error result — a later invalidate should\n // re-render and give the user a chance to recover.\n this.#cache = undefined\n return [\n ctx.style.error(\n `[Node render error: ${error instanceof Error ? error.message : String(error)}]`\n ),\n ]\n }\n }\n\n protected abstract _render(ctx: RenderCtx): Promise<string[]> | string[]\n\n add(child: Node): this {\n this.splice(this.#children.length, 0, child)\n return this\n }\n\n remove(child: Node): this {\n const i = this.#children.indexOf(child)\n if (i === -1) return this\n this.splice(i, 1)\n return this\n }\n\n splice(start: number, deleteCount: number, ...items: Node[]): this {\n // Reject self-insertion — a node in its own children list would\n // create a cycle and stack-overflow on traversal.\n const filtered: Node[] = []\n for (const c of items) {\n if (c === this) continue\n filtered.push(c)\n }\n\n // If any item is already a child of this container, pull it out\n // first so we don't end up with duplicates. Adjust `start` when a\n // removal falls before it so the caller-relative index is preserved.\n let adjustedStart = Math.max(0, Math.min(start, this.#children.length))\n for (const c of filtered) {\n if (c.parent !== this) continue\n const i = this.#children.indexOf(c)\n if (i === -1) continue\n this.#children.splice(i, 1)\n if (i < adjustedStart) adjustedStart--\n }\n\n const removed = this.#children.splice(adjustedStart, deleteCount, ...filtered)\n for (const c of removed) {\n void this.emit(\"childremoved\", { child: c })\n if (c.mounted) c.unmount()\n if (c.parent === this) c.#parent = undefined\n }\n for (const c of filtered) {\n // Detach from old parent before rewriting `#parent`, so the old\n // parent's `remove()` path observes a consistent `c.parent === old`\n // and cleans up its own bookkeeping.\n if (c.parent && c.parent !== this) {\n c.unmount()\n c.parent.remove(c)\n }\n c.#parent = this\n void this.emit(\"childadded\", { child: c })\n if (this.#ctx !== undefined) c.mount(this.#ctx)\n }\n this.invalidate()\n return this\n }\n\n clear(): this {\n this.splice(0, this.#children.length)\n return this\n }\n\n mount(ctx: MountCtx): this {\n if (this.#ctx?.surface === ctx.surface) return this\n if (this.#ctx) {\n throw new Error(\n `Node is already mounted on \"${this.#ctx.surface}\" (requested \"${ctx.surface}\"). Unmount first if you meant to move it.`\n )\n }\n // Make sure state.visible is tracked and will trigger invalidate\n withActiveNode(this, () => unwrap(this.state.visible))\n this.#ctx = ctx\n this.#registerActionMeta(ctx)\n void this.emit(\"mount\")\n for (const c of this.#children) c.mount(ctx)\n return this\n }\n\n /** Contribute any `ActionInfo`-shaped entries in `this.actions` to\n * the catalog. The instance `fn` stays on the node (dispatch finds\n * it via the focus-chain walk); only metadata lands in the registry.\n * Uses `extend: false` so defaults don't clobber user overrides\n * that were registered before the widget mounted. */\n #registerActionMeta(ctx: MountCtx): void {\n if (!this.actions) return\n const metas: Record<string, ActionDef> = {}\n let any = false\n for (const [id, entry] of Object.entries(this.actions)) {\n if (typeof entry === \"function\") continue\n const { fn: _fn, ...info } = entry\n metas[id] = info\n any = true\n }\n if (any) ctx.actions.register(metas, { default: true })\n }\n\n unmount(): this {\n if (!this.#ctx) return this\n this.#mountAc?.abort()\n this.#mountAc = undefined\n for (const c of this.#children) c.unmount()\n void this.emit(\"unmount\")\n this.#ctx.input.blur(this)\n this.#ctx = undefined\n return this\n }\n\n /** Become the focused node. Routes through the MountCtx, which emits\n * `blur` on the previous focus and `focus` on this node.\n *\n * When called before the node is mounted (the common case for\n * `input({ focus: true }).on(...)` style setup), the focus is\n * deferred until the next `mount` event. That keeps the API\n * synchronous and side-effect-free at build time — callers don't\n * have to think about ordering. */\n focus(): this {\n if (!this.#ctx) {\n this.once(\"mount\", () => this.focus())\n return this\n }\n this.#ctx.input.focus(this)\n return this\n }\n\n /** Release focus. No-op when not mounted. */\n blur(): this {\n this.#ctx?.input.blur(this)\n return this\n }\n\n get visible() {\n return unwrap(this.state.visible) ?? true\n }\n\n show(): this {\n if (this.visible) return this\n this.state.visible = true\n void this.emit(\"show\")\n return this\n }\n\n hide(): this {\n if (!this.visible) return this\n this.state.visible = false\n void this.emit(\"hide\")\n return this\n }\n\n toggle(): this {\n this.state.visible = !this.visible\n return this\n }\n\n ref<N extends Node>(ref?: Ref<this extends N ? N : never>): this {\n if (ref) ref.value = this as unknown as Exclude<typeof ref.value, undefined>\n return this\n }\n\n isVisible(): boolean {\n return this.visible && (this.parent ? this.parent.isVisible() : true)\n }\n}\n\n/** Runtime type guard for Node.\n *\n * @internal*/\nexport function isNode(x: unknown): x is Node {\n return x instanceof Node\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,IAAsB,OAAtB,cAAiF,QAG/E;CACA;CACA;CACA;;;;;;;CAOA,iBAAiB;CACjB,YAA6B,CAAC;CAC9B;CACA;CACA;CACA,iCAAiB,IAAI,IAAU;CAC/B;CACA;CACA;CAGA,YAAY,OAAiB,GAAG,UAAkB;EAChD,MAAM;EACN,KAAK,eAAe,QAAQ;GAC1B,MAAM,SAAS,KAAK;GACpB,IAAI,QAAQ,OAAO,MAAM,GAAG;QAEvB,QAAQ,MAAM,0DAA0D,GAAG;EAClF;EAOA,KAAK,SAAS,YAAY,KAAK;EAC/B,SAAS,SAAS,MAAM,KAAK,IAAI,CAAC,CAAC;CACrC;CAEA,aAAwD;EACtD,OAAO;CACT;CAEA,YAAqC,SAAmC;EACtE,KAAK,UAAU;GAAE,GAAG,KAAK;GAAS,GAAG;EAAQ;EAC7C,OAAO;CACT;CAEA,OAAO,IAAiD,MAAoC;EAC1F,MAAM,QAAQ,KAAK,UAAU;EAC7B,MAAM,KAAK,OAAO,UAAU,aAAa,QAAQ,OAAO;EACxD,IAAI,CAAC,IAAI,OAAO;EAChB,GAAG;GAAE,QAAQ;GAAgB,QAAQ;GAAM,GAAG;GAAM;GAAI,MAAM;EAAK,CAAC;EACpE,OAAO;CACT;CAEA,IAAI,cAA2B;EAC7B,KAAK,aAAa,IAAI,gBAAgB;E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,CAAC,KAAK;EAC3B,OAAO;CACT;CAEA,IAAoB,KAA6C;EAC/D,IAAI,KAAK,IAAI,QAAQ;EACrB,OAAO;CACT;CAEA,YAAqB;EACnB,OAAO,KAAK,YAAY,KAAK,SAAS,KAAK,OAAO,UAAU,IAAI;CAClE;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as box } from "./box-
|
|
1
|
+
import { n as box } from "./box-DLEcEvDH.mjs";
|
|
2
2
|
//#region src/widgets/overlay.ts
|
|
3
3
|
function overlay(state, ...children) {
|
|
4
4
|
const node = box({
|
|
@@ -15,4 +15,4 @@ function overlay(state, ...children) {
|
|
|
15
15
|
//#endregion
|
|
16
16
|
export { overlay as t };
|
|
17
17
|
|
|
18
|
-
//# sourceMappingURL=overlay-
|
|
18
|
+
//# sourceMappingURL=overlay-9WXYiGgW.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay-
|
|
1
|
+
{"version":3,"file":"overlay-9WXYiGgW.mjs","names":[],"sources":["../src/widgets/overlay.ts"],"sourcesContent":["import type { Emitter } from \"@zaly/shared\"\nimport type { Node } from \"../core/node.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { Box, BoxStyle } from \"./box.ts\"\n\nimport { box } from \"./box.ts\"\n\nexport interface OverlayState {\n /** Absolute column (1-based) of the overlay's left edge. */\n x: number\n /** Absolute row (1-based) of the overlay's top edge. */\n y: number\n /** Higher zIndex paints on top. Default: 0. */\n zIndex?: number\n verticalAnchor?: \"top\" | \"center\" | \"bottom\"\n horizontalAnchor?: \"left\" | \"center\" | \"right\"\n relative?: \"screen\" | \"ui\" | \"stream\"\n /** If true, the overlay will be automatically removed from the renderer when closed.\n * When false, the overlay will remain in the renderer but will be hidden.\n * Default: true. */\n removeOnClose?: boolean\n}\n\ntype OverlayEvents = {\n close: {}\n}\n\nexport type Overlay<T extends Node[] = Node[]> = Box<OverlayState> & {\n children: T\n} & Emitter<OverlayEvents>\n\nexport function overlay<T extends Node[] = Node[]>(\n state: State<OverlayState & BoxStyle>,\n ...children: T\n): Overlay<T> {\n const node = box({ visible: false, ...state }, ...children) as Overlay<T>\n node.withActions({\n \"overlay.close\": {\n desc: \"Close overlay\",\n fn: () => ((node.state.removeOnClose ?? true) ? node.ctx?.overlay.remove(node) : node.hide()),\n keys: [\"esc\", \"ctrl-c\"],\n },\n })\n return node\n}\n"],"mappings":";;AA+BA,SAAgB,QACd,OACA,GAAG,UACS;CACZ,MAAM,OAAO,IAAI;EAAE,SAAS;EAAO,GAAG;CAAM,GAAG,GAAG,QAAQ;CAC1D,KAAK,YAAY,EACf,iBAAiB;EACf,MAAM;EACN,UAAY,KAAK,MAAM,iBAAiB,OAAQ,KAAK,KAAK,QAAQ,OAAO,IAAI,IAAI,KAAK,KAAK;EAC3F,MAAM,CAAC,OAAO,QAAQ;CACxB,EACF,CAAC;CACD,OAAO;AACT"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { S as unwrap, f as effect, h as memo, s as createProgressive, x as untrack } from "./reactive-f7NpAi69.mjs";
|
|
2
2
|
import { t as widget } from "./widget-BkMwhY2p.mjs";
|
|
3
|
-
import { t as Input } from "./input-
|
|
3
|
+
import { t as Input } from "./input-D7fQEUdt.mjs";
|
|
4
4
|
import { n as select } from "./select-m7NE6Rwa.mjs";
|
|
5
5
|
import { t as tree } from "./tree-Bo1afYhe.mjs";
|
|
6
6
|
import { sliceAnsi, stripAnsi } from "@zaly/shared/ansi";
|
|
@@ -11,10 +11,10 @@ const SCORE_GAP_START = -3;
|
|
|
11
11
|
const SCORE_GAP_EXTENSION = -1;
|
|
12
12
|
const BONUS_BOUNDARY = SCORE_MATCH / 2;
|
|
13
13
|
const BONUS_NONWORD = SCORE_MATCH / 2;
|
|
14
|
-
const BONUS_CAMEL_123 =
|
|
14
|
+
const BONUS_CAMEL_123 = 7;
|
|
15
15
|
const BONUS_CONSECUTIVE = 4;
|
|
16
16
|
const BONUS_FIRST_CHAR_MULTIPLIER = 2;
|
|
17
|
-
const BONUS_NO_PATH_SEP =
|
|
17
|
+
const BONUS_NO_PATH_SEP = 6;
|
|
18
18
|
const CHAR_WHITE = 0;
|
|
19
19
|
const CHAR_NONWORD = 1;
|
|
20
20
|
const CHAR_DELIMITER = 2;
|
|
@@ -618,4 +618,4 @@ const picker = widget((props) => {
|
|
|
618
618
|
//#endregion
|
|
619
619
|
export { picker as t };
|
|
620
620
|
|
|
621
|
-
//# sourceMappingURL=picker-
|
|
621
|
+
//# sourceMappingURL=picker-BqHINl_a.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"picker-BqHINl_a.mjs","names":[],"sources":["../src/search/score.ts","../src/search/matcher.ts","../src/search/sort.ts","../src/search/search.ts","../src/widgets/picker.ts"],"sourcesContent":["export type ScoreOptions = {\n filenameBonus?: boolean\n historyBonus?: boolean\n}\n\nconst SCORE_MATCH = 16\nconst SCORE_GAP_START = -3\nconst SCORE_GAP_EXTENSION = -1\n\nconst BONUS_BOUNDARY = SCORE_MATCH / 2\nconst BONUS_NONWORD = SCORE_MATCH / 2\nconst BONUS_CAMEL_123 = BONUS_BOUNDARY - 1\nconst BONUS_CONSECUTIVE = -(SCORE_GAP_START + SCORE_GAP_EXTENSION)\nconst BONUS_FIRST_CHAR_MULTIPLIER = 2\nconst BONUS_NO_PATH_SEP = BONUS_BOUNDARY - 2\n\nconst CHAR_WHITE = 0\nconst CHAR_NONWORD = 1\nconst CHAR_DELIMITER = 2\nconst CHAR_LOWER = 3\nconst CHAR_UPPER = 4\nconst CHAR_LETTER = 5\nconst CHAR_NUMBER = 6\n\nconst PATH_SEPS = new Set([\"/\", \"\\\\\"])\n\nconst CHAR_CLASS = Array.from({ length: 256 }, (_, b) => {\n const ch = String.fromCharCode(b)\n if (/\\s/.test(ch)) return CHAR_WHITE\n if (String.raw`/\\,:;|`.includes(ch)) return CHAR_DELIMITER\n if (b >= 48 && b <= 57) return CHAR_NUMBER\n if (b >= 65 && b <= 90) return CHAR_UPPER\n if (b >= 97 && b <= 122) return CHAR_LOWER\n return CHAR_NONWORD\n})\n\nfunction charClass(str: string, pos: number): number {\n const code = str.charCodeAt(pos)\n return code <= 255 ? (CHAR_CLASS[code] ?? CHAR_NONWORD) : CHAR_LETTER\n}\n\nexport class Score {\n readonly #opts: ScoreOptions\n readonly #bonusMatrix: number[][] = []\n readonly #bonusBoundaryWhite: number\n readonly #bonusBoundaryDelimiter: number\n\n #consecutive = 0\n #firstBonus = 0\n #prev: number | undefined\n #prevClass = CHAR_WHITE\n #score = 0\n #str = \"\"\n\n isFile = false\n\n constructor(opts: ScoreOptions = {}) {\n this.#opts = opts\n this.#bonusBoundaryWhite = opts.historyBonus ? BONUS_BOUNDARY : BONUS_BOUNDARY + 2\n this.#bonusBoundaryDelimiter = opts.historyBonus ? BONUS_BOUNDARY : BONUS_BOUNDARY + 1\n for (let prev = 0; prev <= 6; prev++) {\n this.#bonusMatrix[prev] = []\n for (let curr = 0; curr <= 6; curr++) {\n this.#bonusMatrix[prev][curr] = this.#computeBonus(prev, curr)\n }\n }\n }\n\n get score(): number {\n return this.#score\n }\n\n isLeftBoundary(str: string, pos: number): boolean {\n return pos === 0 || charClass(str, pos - 1) < CHAR_LOWER\n }\n\n isRightBoundary(str: string, pos: number): boolean {\n return pos === str.length - 1 || charClass(str, pos + 1) < CHAR_LOWER\n }\n\n init(str: string, first: number): void {\n this.#str = str\n this.#score = 0\n this.#consecutive = 0\n this.#prevClass = first > 0 ? charClass(str, first - 1) : CHAR_WHITE\n this.#prev = undefined\n this.#firstBonus = 0\n\n if (this.isFile && this.#opts.filenameBonus && !hasPathSepAfter(str, first)) {\n this.#score += BONUS_NO_PATH_SEP\n }\n this.update(first)\n }\n\n update(pos: number): void {\n const cls = charClass(this.#str, pos)\n const gap = this.#prev === undefined ? 0 : pos - this.#prev - 1\n let bonus = 0\n\n if (gap > 0) {\n this.#prevClass = charClass(this.#str, pos - 1)\n bonus = this.#bonusMatrix[this.#prevClass]?.[cls] ?? 0\n this.#score += SCORE_GAP_START + (gap - 1) * SCORE_GAP_EXTENSION\n this.#consecutive = 0\n this.#firstBonus = 0\n } else {\n bonus = this.#bonusMatrix[this.#prevClass]?.[cls] ?? 0\n if (this.#consecutive === 0) {\n this.#firstBonus = bonus\n } else {\n if (bonus >= BONUS_BOUNDARY && bonus > this.#firstBonus) this.#firstBonus = bonus\n bonus = Math.max(bonus, this.#firstBonus, BONUS_CONSECUTIVE)\n }\n this.#consecutive++\n }\n\n if (this.#prev === undefined) bonus *= BONUS_FIRST_CHAR_MULTIPLIER\n this.#score += SCORE_MATCH + bonus\n this.#prevClass = cls\n this.#prev = pos\n }\n\n get(str: string, from: number, to: number): number {\n this.init(str, from)\n for (let i = from + 1; i <= to; i++) this.update(i)\n return this.#score\n }\n\n #computeBonus(prev: number, curr: number): number {\n if (curr > CHAR_NONWORD) {\n if (prev === CHAR_WHITE) return this.#bonusBoundaryWhite\n if (prev === CHAR_DELIMITER) return this.#bonusBoundaryDelimiter\n if (prev === CHAR_NONWORD) return BONUS_BOUNDARY\n }\n if (\n (prev === CHAR_LOWER && curr === CHAR_UPPER) ||\n (prev !== CHAR_NUMBER && curr === CHAR_NUMBER)\n ) {\n return BONUS_CAMEL_123\n }\n if (curr === CHAR_NONWORD || curr === CHAR_DELIMITER) return BONUS_NONWORD\n if (curr === CHAR_WHITE) return BONUS_BOUNDARY + 2\n return 0\n }\n}\n\nfunction hasPathSepAfter(str: string, first: number): boolean {\n for (let i = first + 1; i < str.length; i++) if (PATH_SEPS.has(str[i])) return true\n return false\n}\n","import type { ScoreOptions } from \"./score.ts\"\n\nimport { Score } from \"./score.ts\"\n\nexport type SearchItem = {\n idx?: number\n score?: number\n file?: string\n text: string\n}\n\nexport type ScoredItem<T extends SearchItem = SearchItem> = T & {\n score: number\n topk?: boolean\n}\n\nexport type MatcherOptions = ScoreOptions & {\n fuzzy?: boolean\n ignorecase?: boolean\n regex?: boolean\n smartcase?: boolean\n}\n\ntype Mod = {\n chars: string[]\n entropy: number\n exactPrefix?: boolean\n exactSuffix?: boolean\n field?: string\n fuzzy?: boolean\n ignorecase?: boolean\n inverse?: boolean\n pattern: string\n re?: RegExp\n regex?: boolean\n word?: boolean\n}\n\ntype Match = {\n from: number\n score: number\n search: string\n str: string\n to: number\n}\n\nexport class Matcher<T extends SearchItem = SearchItem> {\n readonly opts: Required<Pick<MatcherOptions, \"fuzzy\" | \"ignorecase\" | \"smartcase\">> &\n MatcherOptions\n readonly score: Score\n mods: Mod[][] = []\n one: Mod | undefined\n pattern = \"\"\n tick = 0\n\n constructor(opts: MatcherOptions = {}) {\n this.opts = {\n fuzzy: true,\n ignorecase: true,\n smartcase: true,\n ...opts,\n }\n this.score = new Score(opts)\n }\n\n empty(): boolean {\n return this.mods.length === 0\n }\n\n init(pattern: string): boolean {\n pattern = pattern.trim()\n if (pattern === this.pattern) return false\n\n this.pattern = pattern\n this.tick++\n this.mods = []\n this.one = undefined\n if (pattern === \"\") return true\n\n if (this.opts.regex) {\n this.mods = [[this.#prepare(pattern)]]\n } else {\n let isOr = false\n for (const part of pattern.split(/ +/)) {\n if (part === \"|\") {\n isOr = true\n continue\n }\n const mod = this.#prepare(part)\n if (mod.pattern === \"\") continue\n if (isOr && this.mods.length > 0) this.mods.at(-1)?.push(mod)\n else this.mods.push([mod])\n isOr = false\n }\n }\n\n this.mods = this.mods.map((ors) => ors.toSorted((a, b) => a.entropy - b.entropy))\n this.mods = this.mods.toSorted((a, b) => (b[0]?.entropy ?? 0) - (a[0]?.entropy ?? 0))\n if (this.mods.length === 1 && this.mods[0]?.length === 1) this.one = this.mods[0][0]\n return true\n }\n\n match(input: T | string): number {\n if (this.empty()) return 1000\n const item = typeof input === \"string\" ? { text: input } : input\n if (this.one) return this.#match(item, this.one)?.score ?? 0\n\n let score = 0\n for (const any of this.mods) {\n let match: Match | undefined\n for (const mod of any) {\n match = this.#match(item, mod)\n if (match) break\n }\n if (!match) return 0\n score += match.score\n }\n return score\n }\n\n update(item: T): ScoredItem<T> {\n const score = this.match(item)\n const it = item as ScoredItem<T>\n it.score = score\n return it\n }\n\n positions(input: T | string): number[] {\n if (this.empty()) return []\n const item = typeof input === \"string\" ? { text: input } : input\n const ret: number[] = []\n const all = this.mods.flat()\n for (const mod of all) {\n const match = this.#match(item, mod)\n if (!match) continue\n if (mod.fuzzy) ret.push(...this.#fuzzyPositions(match.search, mod.chars, match.from))\n else for (let i = match.from; i <= match.to; i++) ret.push(i)\n }\n return [...new Set(ret)].toSorted((a, b) => a - b)\n }\n\n fields(): string[] {\n const ret = new Set<string>()\n for (const mod of this.mods.flat()) ret.add(mod.field ?? \"text\")\n return [...ret]\n }\n\n #prepare(pattern: string): Mod {\n const mod: Mod = { chars: [], entropy: 0, pattern }\n\n if (this.opts.regex) {\n mod.regex = true\n const isLower = mod.pattern.toLowerCase() === mod.pattern\n mod.ignorecase = this.opts.smartcase ? isLower : this.opts.ignorecase\n try {\n mod.re = new RegExp(mod.pattern, mod.ignorecase ? \"i\" : undefined)\n } catch {\n mod.re = undefined\n }\n } else {\n const file = parseFilePattern(pattern)\n if (file) {\n mod.field = \"file\"\n mod.pattern = `${file}$`\n }\n\n const field = mod.pattern.match(/^([\\w_][\\w_]+):(.*)$/)\n if (field) {\n mod.field = field[1]\n mod.pattern = field[2]\n }\n\n mod.ignorecase = this.opts.ignorecase\n const isLower = mod.pattern.toLowerCase() === mod.pattern\n if (this.opts.smartcase) mod.ignorecase = isLower\n mod.fuzzy = this.opts.fuzzy\n if (!mod.fuzzy) mod.entropy += 10\n\n if (mod.pattern.startsWith(\"!\")) {\n mod.fuzzy = false\n mod.inverse = true\n mod.pattern = mod.pattern.slice(1)\n mod.entropy -= 1\n }\n if (mod.pattern.startsWith(\"'\")) {\n mod.fuzzy = false\n mod.pattern = mod.pattern.slice(1)\n mod.entropy += 10\n if (mod.pattern.endsWith(\"'\")) {\n mod.word = true\n mod.pattern = mod.pattern.slice(0, -1)\n mod.entropy += 10\n }\n } else if (mod.pattern.startsWith(\"^\")) {\n mod.fuzzy = false\n mod.exactPrefix = true\n mod.pattern = mod.pattern.slice(1)\n mod.entropy += 20\n }\n if (mod.pattern.endsWith(\"$\")) {\n mod.fuzzy = false\n mod.exactSuffix = true\n mod.pattern = mod.pattern.slice(0, -1)\n mod.entropy += 20\n }\n\n const rareChars = (mod.pattern.match(/[^\\w\\s]/g) ?? []).length\n mod.entropy += Math.min(mod.pattern.length, 20) + rareChars * 2\n if (!mod.ignorecase && !isLower) mod.entropy *= 2\n if (mod.ignorecase) mod.pattern = mod.pattern.toLowerCase()\n }\n\n // oxlint-disable-next-line typescript/no-misused-spread\n mod.chars = [...mod.pattern]\n return mod\n }\n\n #match(item: SearchItem, mod: Mod): Match | undefined {\n this.score.isFile = itemField(item, \"file\") !== undefined\n let str = item.text\n\n if (mod.field) {\n const value = itemField(item, mod.field)\n if (value === undefined)\n return mod.inverse ? { from: 0, score: 1000, search: str, str, to: 0 } : undefined\n str = value\n }\n\n const original = str\n if (mod.ignorecase) str = str.toLowerCase()\n\n if (mod.regex) return this.#regex(original, mod)\n if (mod.fuzzy) return this.#fuzzy(str, original, mod.chars)\n\n let from = -1\n let to = -1\n if (mod.exactPrefix) {\n if (str.startsWith(mod.pattern)) {\n from = 0\n to = mod.pattern.length - 1\n }\n } else if (mod.exactSuffix) {\n if (str.endsWith(mod.pattern)) {\n from = str.length - mod.pattern.length\n to = str.length - 1\n }\n } else {\n from = str.indexOf(mod.pattern)\n to = from + mod.pattern.length - 1\n while (mod.word && from >= 0) {\n if (this.score.isLeftBoundary(str, from) && this.score.isRightBoundary(str, to)) break\n from = str.indexOf(mod.pattern, to + 1)\n to = from + mod.pattern.length - 1\n }\n }\n\n if (mod.inverse)\n return from === -1 ? { from: 0, score: 1000, search: str, str: original, to: 0 } : undefined\n if (from >= 0)\n return { from, score: this.score.get(original, from, to), search: str, str: original, to }\n return undefined\n }\n\n #regex(str: string, mod: Mod): Match | undefined {\n const match = mod.re?.exec(str)\n if (!match?.[0]) return undefined\n const from = match.index\n const to = from + match[0].length - 1\n return { from, score: this.score.get(str, from, to), search: str, str, to }\n }\n\n #fuzzyFind(\n str: string,\n original: string,\n pattern: string[],\n init = 0\n ): Pick<Match, \"from\" | \"to\" | \"score\"> | undefined {\n const from = str.indexOf(pattern[0] ?? \"\", init)\n if (from === -1) return undefined\n this.score.init(original, from)\n let last = from\n for (let i = 1; i < pattern.length; i++) {\n last = str.indexOf(pattern[i], last + 1)\n // Bail before reading the score: a partial accumulation never\n // escapes this method, so `#fuzzy` only ever sees a score that\n // corresponds to a fully-matched window.\n if (last === -1) return undefined\n this.score.update(last)\n }\n return { from, score: this.score.score, to: last }\n }\n\n #fuzzy(str: string, original: string, pattern: string[]): Match | undefined {\n // Anchor on every occurrence of the first char and keep the\n // highest-scoring window. The score rides in the return value rather\n // than being read off the shared `this.score`, so there's no\n // \"is the accumulator aligned with `best` right now?\" invariant.\n let best = this.#fuzzyFind(str, original, pattern)\n if (!best) return undefined\n for (\n let next = this.#fuzzyFind(str, original, pattern, best.from + 1);\n next;\n next = this.#fuzzyFind(str, original, pattern, next.from + 1)\n ) {\n if (next.score > best.score) best = next\n }\n return { from: best.from, score: best.score, search: str, str: original, to: best.to }\n }\n\n #fuzzyPositions(str: string, pattern: string[], from: number): number[] {\n const ret = [from]\n let last = from\n for (let i = 1; i < pattern.length; i++) {\n last = str.indexOf(pattern[i], last + 1)\n if (last === -1) break\n ret.push(last)\n }\n return ret\n }\n}\n\nfunction itemField(item: SearchItem, field: string): string | undefined {\n const value = item[field as keyof SearchItem] as unknown\n if (value === undefined || value === null) return undefined\n if (typeof value === \"string\") return value\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\")\n return String(value)\n if (Array.isArray(value)) return value.join(\" \")\n return\n}\n\nfunction parseFilePattern(pattern: string): string | undefined {\n return (\n pattern.match(/^(.*[/\\\\].*):\\d*:?:?\\d*$/)?.[1] ??\n pattern.match(/^(.+\\.[a-z_]+):\\d*:?:?\\d*$/)?.[1]\n )\n}\n","import type { ScoredItem, SearchItem } from \"./matcher.ts\"\n\ntype SortKey<T extends SearchItem> = Extract<keyof (ScoredItem<T> & SearchItem), string>\n\nexport type SortField<T extends SearchItem = SearchItem> =\n | SortKey<T>\n | `#${SortKey<T>}`\n | `${SortKey<T>}:desc`\n\nexport type ParsedField<T extends SearchItem = SearchItem> = {\n desc?: boolean\n len?: boolean\n name: SortKey<T>\n}\n\nexport type Sorter<T extends SearchItem = SearchItem> = (\n a: ScoredItem<T>,\n b: ScoredItem<T>\n) => number\n\nfunction parse<T extends SearchItem>(field: SortField<T>): ParsedField<T> {\n const len = field.startsWith(\"#\")\n const desc = field.endsWith(\":desc\")\n const name = field.replace(/^#/, \"\").replace(/:desc$/, \"\") as SortKey<T>\n return { desc, len, name }\n}\n\nexport function sorter<T extends SearchItem>(\n fields: readonly SortField<T>[] = [\"score:desc\", \"#text\", \"idx\"]\n): Sorter<T> {\n const parsed: ParsedField<T>[] = fields.map(parse)\n return (a, b) => {\n for (const field of parsed) {\n let av: unknown = a[field.name]\n let bv: unknown = b[field.name]\n if (av === undefined || bv === undefined) continue\n if (field.len) {\n av = typeof av === \"string\" || Array.isArray(av) ? av.length : 0\n bv = typeof bv === \"string\" || Array.isArray(bv) ? bv.length : 0\n }\n if (av === bv) continue\n if (typeof av === \"boolean\" && typeof bv === \"boolean\") {\n av = av ? 0 : 1\n bv = bv ? 0 : 1\n }\n return compare(av, bv) * (field.desc ? -1 : 1)\n }\n return 0\n }\n}\n\nfunction compare(a: unknown, b: unknown): number {\n if (typeof a === \"number\" && typeof b === \"number\") return a - b\n if (typeof a === \"string\" && typeof b === \"string\") return a.localeCompare(b)\n return String(a).localeCompare(String(b))\n}\n","// oxlint-disable no-await-in-loop\nimport type { MaybePromise } from \"@zaly/shared\"\nimport type { MatcherOptions, ScoredItem, SearchItem } from \"./matcher.ts\"\nimport type { Sorter, SortField } from \"./sort.ts\"\n\nimport { TopK } from \"@zaly/shared/minheap\"\nimport { Matcher } from \"./matcher.ts\"\nimport { sorter } from \"./sort.ts\"\n\nexport type SearchOptions<T extends SearchItem = SearchItem> = MatcherOptions & {\n sort?: boolean | readonly SortField<T>[]\n filter?: boolean\n sortEmpty?: boolean\n frecency?: () => (file: string) => number\n limit?: number\n throttle?: number\n}\n\nexport type SearchFn<T extends SearchItem = SearchItem> = (\n query: string,\n match: Match<T>\n) => MaybePromise<ScoredItem<T>[]>\n\nexport type SearchItems<T extends SearchItem = SearchItem> = readonly T[] | SearchFn<T>\n\n/** Match function handed to `complete`. Returns `0` for no match,\n * positive integer otherwise — so both `match(s) > 0` and the\n * idiomatic `.filter(match(s))` work (0 is falsy). The magnitude is a\n * score the source can use to rank its own candidates when it cares\n * about order. */\nexport type Match<T extends SearchItem = SearchItem> = (s: string | T) => number\n\nconst BONUS_FRECENCY = 8\nconst SEARCH_LIMIT = 1000\nconst aborted = Symbol(\"search.aborted\")\n\nexport class Searcher<T extends SearchItem = SearchItem> {\n #opts: SearchOptions<T>\n #sorter?: Sorter<T>\n #matcher: Matcher<T>\n #ac?: AbortController\n\n constructor(opts: SearchOptions<T>) {\n this.#opts = opts\n const sortOpts = opts.sort === true ? undefined : opts.sort\n this.#sorter = sortOpts === false ? undefined : sorter(sortOpts)\n this.#matcher = new Matcher(opts)\n }\n\n /** Create a match function bound to the current pattern. If the\n * matcher has been updated since the search started, match will\n * return `0` to indicate no match, to prevent stale results */\n createMatch(opts: { signal: AbortSignal }): Match<T> {\n const m = this.#matcher\n return (s: string | T) => (opts.signal.aborted ? 0 : m.match(s))\n }\n\n async search(\n items: SearchItems<T>,\n query = \"\",\n opts: { progress?: (results: ScoredItem<T>[]) => MaybePromise } = {}\n ): Promise<ScoredItem<T>[]> {\n try {\n return await this.#search(items, query, opts)\n } catch (error) {\n if (error === aborted) return []\n throw error\n }\n }\n\n get limit(): number {\n return this.#opts.limit ?? (this.#sorter ? SEARCH_LIMIT : Infinity)\n }\n\n async #search(\n items: SearchItems<T>,\n query = \"\",\n opts: { progress?: (results: ScoredItem<T>[]) => MaybePromise } = {}\n ): Promise<ScoredItem<T>[]> {\n this.#ac?.abort(aborted)\n // oxlint-disable-next-line no-multi-assign\n const ac = (this.#ac = new AbortController())\n\n const m = this.#matcher\n m.init(query)\n const f = this.#opts.frecency?.()\n const s = this.#sorter\n const limit = this.limit\n const ret: ScoredItem<T>[] = []\n let match = (item: T) => this.#matcher.update(item)\n const topk =\n s && (this.#opts.sortEmpty || !m.empty())\n ? new TopK<ScoredItem<T>>(limit, (a, b) => -s(a, b))\n : undefined\n\n if (typeof items === \"function\") {\n match = (item: T) => item as ScoredItem<T>\n items = await items(query, this.createMatch({ signal: ac.signal }))\n ac.signal.throwIfAborted()\n }\n\n if (items.length === 0) return []\n\n const results = () => topk?.sorted() ?? ret\n\n // Process items in three phases, so that the results in the UI stabilize faster:\n // - previous topk results (topk)\n // - scored items (score)\n // - unscored items (rest)\n const todo: [T[], T[], T[]] = [[], [], []]\n let idx = 0\n if (!topk) todo[0] = items as T[]\n else {\n for (const item of items) {\n item.idx = idx++\n const it = item as ScoredItem<T>\n if (it.topk) todo[0].push(item)\n else if (it.score) todo[1].push(item)\n else todo[2].push(item)\n }\n }\n\n const doFilter = !m.empty() && (this.#opts.filter ?? true)\n\n let lastYield = performance.now()\n let dirty = false\n let count = 0\n\n loop: for (const todos of todo) {\n for (const item of todos) {\n ac.signal.throwIfAborted()\n if (count++ % 256 === 0) {\n const now = performance.now()\n if (now - lastYield >= (this.#opts.throttle ?? 16)) {\n lastYield = now\n await new Promise((r) => setImmediate(r))\n if (opts.progress && dirty) {\n dirty = false\n await opts.progress(results())\n }\n }\n }\n const si = match(item)\n if (si.file && si.score && f) {\n const frecency = f(si.file)\n si.score += (1 - 1 / (1 + frecency)) * BONUS_FRECENCY\n }\n if (doFilter && si.score === 0) continue\n if (topk) {\n si.topk = false\n const ta = topk.add(si)\n if (ta.added) {\n si.topk = true\n dirty = true\n if (ta.evicted) ta.evicted.topk = false\n }\n } else {\n ret.push(si)\n dirty = true\n if (ret.length >= limit) break loop\n }\n }\n }\n\n return results()\n }\n\n positions(s: string | T): number[] {\n return this.#matcher.positions(s)\n }\n}\n","import type { Reactive, Ref } from \"../core/reactive.ts\"\nimport type { State } from \"../core/state.ts\"\nimport type { NodeActionMap } from \"../input/actions.ts\"\nimport type { ScoredItem, SearchItem } from \"../search/matcher.ts\"\nimport type { SearchItems, SearchOptions } from \"../search/search.ts\"\nimport type { Option, Select, SelectState } from \"./select.ts\"\nimport type { TreeItem, TreeProps } from \"./tree.ts\"\n\nimport { sliceAnsi, stripAnsi } from \"@zaly/shared/ansi\"\nimport { createProgressive, effect, memo, untrack, unwrap } from \"../core/reactive.ts\"\nimport { Searcher } from \"../search/search.ts\"\nimport { Input } from \"./input.ts\"\nimport { select } from \"./select.ts\"\nimport { tree } from \"./tree.ts\"\nimport { widget } from \"./widget.ts\"\n\nexport type PickerItem = Option & SearchItem\nexport type PickerActions = keyof ReturnType<typeof picker>[\"actions\"]\n\ntype PickerBaseProps<T extends PickerItem = PickerItem> = SearchOptions<T> & {\n /** The `Input` to watch. Pass the node directly, or a `Ref<Input>`\n * populated by `node.ref(ref)` elsewhere in the tree — the latter\n * enables fully inline composition where the input doesn't need a\n * local binding. The ref is dereferenced on mount, so wiring is\n * type-safe and ordering-flexible (autocomplete can be constructed\n * before the Input is). */\n input?: Input | Ref<Input>\n pattern?: Reactive<string>\n reverse?: boolean\n actions?: NodeActionMap<Select<T>>\n}\n\nexport type PickerSelectProps<T extends PickerItem = PickerItem> = PickerBaseProps<T> &\n Omit<SelectState<T>, \"items\"> & {\n items: Reactive<SearchItems<T>>\n tree?: never\n }\n\nexport type PickerTreeProps<T extends TreeItem = TreeItem> = PickerBaseProps<T> &\n TreeProps<T> & {\n items?: never\n }\n\nfunction isTree<T extends Option = Option>(\n props: PickerTreeProps<T> | PickerSelectProps<T>\n): props is PickerTreeProps<T> {\n return \"tree\" in props\n}\n\nexport const picker = widget(\n <T extends PickerItem = PickerItem>(props: State<PickerSelectProps<T> | PickerTreeProps<T>>) => {\n const pattern = memo(() => {\n if (props.pattern !== undefined) return unwrap(props.pattern)\n const inp = props.input instanceof Input ? props.input : props.input?.()\n return inp?.state.value ?? \"\"\n })\n\n let node: Select<T>\n let items: Reactive<SearchItems<T>>\n if (isTree(props)) {\n props = { filter: false, fuzzy: false, sort: false, ...props }\n const t = tree(props)\n node = t\n items = t.items\n } else {\n node = select({ ...props, items: [] })\n items = props.items\n }\n const searcher = new Searcher<T>(props)\n\n node.extendRenderer((prev) => (item, ctx) => {\n let row = prev(item, ctx)\n if (!item.score) return row\n const stripped = stripAnsi(row)\n const positions = searcher.positions(stripped).toSorted((a, b) => b - a)\n while (positions.length > 0) {\n const from = positions.pop()!\n let to = from\n while (positions.length && positions.at(-1) === to + 1) to = positions.pop()!\n row =\n sliceAnsi(row, 0, from) +\n ctx.style.accent(stripped.slice(from, to + 1)) +\n sliceAnsi(row, to + 1)\n }\n return row\n })\n\n const results = createProgressive<ScoredItem<T>[]>(\n async ({ set }) =>\n await searcher.search(unwrap(items), pattern(), { progress: (r) => set(r) }),\n {\n initialValue: [],\n }\n )\n node.state.items = results\n if (props.input) node.bind(props.input)\n\n const matches = () =>\n unwrap(node.state.items)\n .map((item, i) => [item, i] as const)\n .filter(([item]) => item.score)\n .map(([, i]) => i)\n\n effect(() => {\n const m = matches()\n node.state.more = m.length >= searcher.limit\n if (m.length === 0 || pattern() === \"\") return\n untrack(() => {\n // When filtering, go to the first (best) match.\n // When not filtering, go to the first match that is at or after the current active index, or the first match if none are after.\n if (props.filter === false) {\n const active = node.active\n node.active = m.find((i) => i >= active) ?? m[0]\n } else node.active = 0\n })\n })\n\n return node.withActions({\n ...props.actions,\n \"picker.next\": () => {\n const active = node.active\n const m = matches()\n if (m.length === 0) return node.action(\"select.next\")\n node.active = node.state.reverse\n ? (m.toReversed().find((i) => i < active) ?? m.at(-1)!)\n : (m.find((i) => i > active) ?? m[0])\n },\n \"picker.prev\": () => {\n const active = node.active\n const m = matches()\n if (m.length === 0) return node.action(\"select.prev\")\n node.active = node.state.reverse\n ? (m.find((i) => i > active) ?? m[0])\n : (m.toReversed().find((i) => i < active) ?? m.at(-1)!)\n },\n })\n }\n)\n"],"mappings":";;;;;;;;AAKA,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,sBAAsB;AAE5B,MAAM,iBAAiB,cAAc;AACrC,MAAM,gBAAgB,cAAc;AACpC,MAAM,kBAAkB;AACxB,MAAM,oBAAoB;AAC1B,MAAM,8BAA8B;AACpC,MAAM,oBAAoB;AAE1B,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AACvB,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,cAAc;AACpB,MAAM,cAAc;AAEpB,MAAM,4BAAY,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC;AAErC,MAAM,aAAa,MAAM,KAAK,EAAE,QAAQ,IAAI,IAAI,GAAG,MAAM;CACvD,MAAM,KAAK,OAAO,aAAa,CAAC;CAChC,IAAI,KAAK,KAAK,EAAE,GAAG,OAAO;CAC1B,IAAI,OAAO,GAAG,SAAS,SAAS,EAAE,GAAG,OAAO;CAC5C,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO;CAC/B,IAAI,KAAK,MAAM,KAAK,IAAI,OAAO;CAC/B,IAAI,KAAK,MAAM,KAAK,KAAK,OAAO;CAChC,OAAO;AACT,CAAC;AAED,SAAS,UAAU,KAAa,KAAqB;CACnD,MAAM,OAAO,IAAI,WAAW,GAAG;CAC/B,OAAO,QAAQ,MAAO,WAAW,SAAS,eAAgB;AAC5D;AAEA,IAAa,QAAb,MAAmB;CACjB;CACA,eAAoC,CAAC;CACrC;CACA;CAEA,eAAe;CACf,cAAc;CACd;CACA,aAAa;CACb,SAAS;CACT,OAAO;CAEP,SAAS;CAET,YAAY,OAAqB,CAAC,GAAG;EACnC,KAAK,QAAQ;EACb,KAAK,sBAAsB,KAAK,eA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O,KAAK,MAAM,KAAK,CAAC,CACrB,KAAK,MAAM,MAAM,CAAC,MAAM,CAAC,CAAU,CAAC,CACpC,QAAQ,CAAC,UAAU,KAAK,KAAK,CAAC,CAC9B,KAAK,GAAG,OAAO,CAAC;CAErB,aAAa;EACX,MAAM,IAAI,QAAQ;EAClB,KAAK,MAAM,OAAO,EAAE,UAAU,SAAS;EACvC,IAAI,EAAE,WAAW,KAAK,QAAQ,MAAM,IAAI;EACxC,cAAc;GAGZ,IAAI,MAAM,WAAW,OAAO;IAC1B,MAAM,SAAS,KAAK;IACpB,KAAK,SAAS,EAAE,MAAM,MAAM,KAAK,MAAM,KAAK,EAAE;GAChD,OAAO,KAAK,SAAS;EACvB,CAAC;CACH,CAAC;CAED,OAAO,KAAK,YAAY;EACtB,GAAG,MAAM;EACT,qBAAqB;GACnB,MAAM,SAAS,KAAK;GACpB,MAAM,IAAI,QAAQ;GAClB,IAAI,EAAE,WAAW,GAAG,OAAO,KAAK,OAAO,aAAa;GACpD,KAAK,SAAS,KAAK,MAAM,UACpB,EAAE,WAAW,CAAC,CAAC,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,GAAG,EAAE,IACjD,EAAE,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE;EACtC;EACA,qBAAqB;GACnB,MAAM,SAAS,KAAK;GACpB,MAAM,IAAI,QAAQ;GAClB,IAAI,EAAE,WAAW,GAAG,OAAO,KAAK,OAAO,aAAa;GACpD,KAAK,SAAS,KAAK,MAAM,UACpB,EAAE,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,KAC/B,EAAE,WAAW,CAAC,CAAC,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE,GAAG,EAAE;EACxD;CACF,CAAC;AACH,CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Ut as NodeActionMap, X as State, nt as Reactive, rt as Ref } from "./queries-
|
|
2
|
-
import { t as Input } from "./input-
|
|
1
|
+
import { Ut as NodeActionMap, X as State, nt as Reactive, rt as Ref } from "./queries-Cvalgu6P.mjs";
|
|
2
|
+
import { t as Input } from "./input-Dylds_sI.mjs";
|
|
3
3
|
import { n as SearchOptions, r as SearchItem, t as SearchItems } from "./search-FvGnswRl.mjs";
|
|
4
|
-
import { i as Select, o as SelectState, t as Option } from "./select-
|
|
5
|
-
import { r as TreeProps, t as TreeItem } from "./tree-
|
|
4
|
+
import { i as Select, o as SelectState, t as Option } from "./select-zGd5pbiB.mjs";
|
|
5
|
+
import { r as TreeProps, t as TreeItem } from "./tree-CArtDRec.mjs";
|
|
6
6
|
//#region src/widgets/picker.d.ts
|
|
7
7
|
type PickerItem = Option & SearchItem;
|
|
8
8
|
type PickerActions = keyof ReturnType<typeof picker>["actions"];
|
|
@@ -33,4 +33,4 @@ declare const picker: <T extends PickerItem = PickerItem>(props: State<PickerSel
|
|
|
33
33
|
};
|
|
34
34
|
//#endregion
|
|
35
35
|
export { picker as a, PickerTreeProps as i, PickerItem as n, PickerSelectProps as r, PickerActions as t };
|
|
36
|
-
//# sourceMappingURL=picker-
|
|
36
|
+
//# sourceMappingURL=picker-JL8lZfRH.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picker-
|
|
1
|
+
{"version":3,"file":"picker-JL8lZfRH.d.mts","names":[],"sources":["../src/widgets/picker.ts"],"mappings":";;;;;;KAgBY,aAAa,SAAS;KACtB,sBAAsB,kBAAkB;KAE/C,gBAAgB,UAAU,aAAa,cAAc,cAAc;;;;;;;EAOtE,QAAQ,QAAQ,IAAI;EACpB,UAAU;EACV;EACA,UAAU,cAAc,OAAO;;KAGrB,kBAAkB,UAAU,aAAa,cAAc,gBAAgB,KACjF,KAAK,YAAY;EACf,OAAO,SAAS,YAAY;EAC5B;;KAGQ,gBAAgB,UAAU,WAAW,YAAY,gBAAgB,KAC3E,UAAU;EACR;;cASS,SACV,UAAU,aAAU,YAAA,OAAsB,MAAM,kBAAkB,KAAK,gBAAgB,QAAG,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries-B_lOwEiE.mjs","names":["#router","#terminal"],"sources":["../src/input/keys.ts","../src/input/queries.ts"],"sourcesContent":["/**\n * Keyboard event shape + pattern-based matcher.\n *\n * `KeyEvent.name` is a canonical name:\n * - Single characters for printable keys: `\"a\"`, `\"A\"`, `\" \"`, `\"!\"`. The\n * `name` reflects the raw character the decoder produced — so `Shift+A`\n * arrives as `{ name: \"A\", shift: true }` (terminals already fold\n * shift into the uppercase byte for letters).\n * - Named constants for non-printing keys: `\"enter\"`, `\"tab\"`, `\"esc\"`,\n * `\"backspace\"`, `\"delete\"`, `\"space\"`, arrows `\"up\"/\"down\"/\"left\"/\n * \"right\"`, navigation `\"home\"/\"end\"/\"pageup\"/\"pagedown\"/\"insert\"`,\n * function keys `\"f1\"` .. `\"f12\"`.\n *\n * Patterns for `keyMatches` are dash-separated modifier prefixes plus the\n * name: `\"a\"`, `\"ctrl-c\"`, `\"shift-tab\"`, `\"ctrl-shift-x\"`. Unknown\n * prefixes are treated as literal characters in the name, so\n * `\"something-foo\"` is interpreted as the name `\"something-foo\"` rather\n * than a missing-modifier error.\n *\n * Modifier prefixes (order-independent):\n * - `ctrl-`\n * - `alt-`\n * - `shift-`\n * - `meta-` (a.k.a. super / cmd)\n */\n\nexport interface KeyEvent {\n /** Canonical key name — raw character or one of the named constants above. */\n name: string\n /**\n * The literal text the keystroke would insert, when that makes sense.\n * For printable chars this is the char itself; for Enter, Tab, etc. it's\n * undefined. Widgets use this to decide whether to insert content vs.\n * treat the key as a command.\n */\n text?: string\n ctrl: boolean\n alt: boolean\n shift: boolean\n meta: boolean\n}\n\n/** Canonical modifier names used in `KeyPattern`. */\nexport type KeyModifier = \"ctrl\" | \"alt\" | \"shift\" | \"meta\"\n\n/**\n * Named keys the decoder emits for non-printable keystrokes. Bindings\n * reference these directly (`\"enter\"`, `\"f5\"`, `\"pageup\"`, …).\n */\nexport type SpecialKeyName = (typeof specialKeys)[number]\n\ndeclare const KeyPatternBrand: unique symbol\n\n/** A validated, canonical key binding string. */\nexport type KeyPattern = string & { readonly [KeyPatternBrand]: true }\n\nconst MOD_NAMES = new Set<string>([\"ctrl\", \"alt\", \"shift\", \"meta\"])\nconst specialKeys = [\n \"enter\",\n \"tab\",\n \"backspace\",\n \"delete\",\n \"space\",\n \"esc\",\n \"up\",\n \"down\",\n \"left\",\n \"right\",\n \"home\",\n \"end\",\n \"pageup\",\n \"pagedown\",\n \"insert\",\n \"f1\",\n \"f2\",\n \"f3\",\n \"f4\",\n \"f5\",\n \"f6\",\n \"f7\",\n \"f8\",\n \"f9\",\n \"f10\",\n \"f11\",\n \"f12\",\n] as const\nconst SPECIAL_KEY_NAMES = new Set<string>(specialKeys)\n\ninterface ParsedPattern {\n name: string\n ctrl: boolean\n alt: boolean\n shift: boolean\n meta: boolean\n}\n\nexport class KeyPatternError extends Error {\n constructor(pattern: string, reason: string) {\n super(`invalid key pattern ${JSON.stringify(pattern)}: ${reason}`)\n this.name = \"KeyPatternError\"\n }\n}\n\nfunction parsePattern(pattern: string): ParsedPattern {\n const mods = { alt: false, ctrl: false, meta: false, shift: false }\n let name = pattern\n while (name.length > 0) {\n const dash = name.indexOf(\"-\")\n if (dash <= 0) break\n const mod = name.slice(0, dash)\n if (!MOD_NAMES.has(mod)) throw new KeyPatternError(pattern, `unknown modifier: ${mod}`)\n if (mods[mod as KeyModifier]) throw new KeyPatternError(pattern, `duplicate modifier: ${mod}`)\n mods[mod as KeyModifier] = true\n name = name.slice(dash + 1)\n }\n\n const ret = normalizeKey({ ...mods, name })\n name = ret.name\n if (name === \"\") throw new KeyPatternError(pattern, \"missing key name\")\n if (name.includes(\"-\") && name !== \"-\") throw new KeyPatternError(pattern, \"too many keys\")\n if (!isPrintableKeyName(name)) throw new KeyPatternError(pattern, `unknown key name: ${name}`)\n if (mods.shift && !canUseShiftModifier(name)) {\n throw new KeyPatternError(\n pattern,\n `shift-${name} will not trigger; bind the shifted character instead`\n )\n }\n return ret\n}\n\nfunction normalizeKey(p: ParsedPattern): ParsedPattern {\n if (/^[A-Z]$/.test(p.name)) return { ...p, name: p.name.toLowerCase(), shift: true }\n if (p.name === \" \") return { ...p, name: \"space\" }\n return p\n}\n\nfunction isPrintableKeyName(s: string): boolean {\n // oxlint-disable-next-line typescript/no-misused-spread\n return SPECIAL_KEY_NAMES.has(s) || ([...s].length === 1 && !/[\\p{C}]/u.test(s))\n}\n\nfunction canUseShiftModifier(name: string): boolean {\n return /^[a-zA-Z]$/.test(name) || SPECIAL_KEY_NAMES.has(name)\n}\n\nexport function isKeyPattern(s: string): s is KeyPattern {\n try {\n canonical(s)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Canonical string form of a pattern or event — modifiers in a fixed\n * alphabetical order, then the key name, joined by `-`. Used by the\n * router to build a pattern index whose keys match regardless of how\n * the user spelled the modifier order (`\"ctrl-shift-a\"` and\n * `\"shift-ctrl-a\"` both canonicalize to `\"ctrl-shift-a\"`).\n */\nexport function canonical(patternOrEvent: string | KeyEvent): KeyPattern {\n const p =\n typeof patternOrEvent === \"string\" ? parsePattern(patternOrEvent) : normalizeKey(patternOrEvent)\n const parts: string[] = []\n if (p.alt) parts.push(\"alt\")\n if (p.ctrl) parts.push(\"ctrl\")\n if (p.meta) parts.push(\"meta\")\n if (p.shift) parts.push(\"shift\")\n parts.push(p.name)\n return parts.join(\"-\") as KeyPattern\n}\n\n/**\n * Test whether an event matches a pattern (or any of a list of patterns).\n * Unspecified modifiers in the pattern must be *absent* on the event —\n * matching is strict, not inclusive, so `\"a\"` only matches a bare `a`\n * (no ctrl/alt/etc.).\n */\nexport function keyMatches(ev: KeyEvent, pattern: string | readonly string[]): boolean {\n if (Array.isArray(pattern)) {\n for (const p of pattern) if (keyMatches(ev, p)) return true\n return false\n }\n const p = parsePattern(pattern as string)\n const e = normalizeKey(ev)\n return (\n e.name === p.name &&\n e.ctrl === p.ctrl &&\n e.alt === p.alt &&\n e.shift === p.shift &&\n e.meta === p.meta\n )\n}\n","import type { TerminalResponseEvent } from \"./decoder.ts\"\nimport type { InputRouter } from \"./router.ts\"\n\nexport type TerminalQuery<T = TerminalResponseEvent> = TerminalQueryOpts & {\n request: string\n match: (event: TerminalResponseEvent) => T | undefined\n}\n\nexport type TerminalQueryOpts = {\n timeout?: number\n wrap?: (seq: string) => string\n}\n\ntype TerminalQueryWriter = {\n write: (seq: string) => void\n}\n\nexport class TerminalQueries {\n readonly #router: InputRouter\n readonly #terminal: TerminalQueryWriter\n\n constructor(router: InputRouter, terminal: TerminalQueryWriter) {\n this.#router = router\n this.#terminal = terminal\n }\n\n query<T>(query: TerminalQuery<T>): Promise<T | undefined> {\n const timeout = query.timeout ?? 200\n const ac = new AbortController()\n return new Promise((resolve) => {\n const finish = (value?: T) => {\n if (ac.signal.aborted) return\n ac.abort()\n clearTimeout(timer)\n resolve(value)\n }\n const timer = setTimeout(() => finish(), timeout)\n timer.unref()\n this.#router.on(\n \"term-response\",\n ({ event }) => {\n const value = query.match(event)\n if (value !== undefined) finish(value)\n },\n { signal: ac.signal }\n )\n this.#terminal.write(query.wrap?.(query.request) ?? query.request)\n })\n }\n\n primaryDeviceAttributes(opts: TerminalQueryOpts = {}) {\n return this.query<TerminalResponseEvent & { attrs: number[] }>({\n match: (ev) =>\n ev.kind === \"csi\" && ev.final === \"c\" && ev.params.startsWith(\"?\")\n ? { ...ev, attrs: parseAttrs(ev.params) }\n : undefined,\n request: \"\\x1b[c\",\n ...opts,\n })\n }\n\n secondaryDeviceAttributes(opts: TerminalQueryOpts = {}) {\n return this.query<TerminalResponseEvent & { attrs: number[] }>({\n match: (ev) =>\n ev.kind === \"csi\" && ev.final === \"c\" && ev.params.startsWith(\">\")\n ? { ...ev, attrs: parseAttrs(ev.params) }\n : undefined,\n request: \"\\x1b[>c\",\n ...opts,\n })\n }\n\n xtVersion(opts: TerminalQueryOpts = {}) {\n return this.query<TerminalResponseEvent & { name: string; version?: string }>({\n match: (ev) => {\n if (ev.kind !== \"dcs\" || !ev.payload.startsWith(\">|\")) return\n const payload = ev.payload.slice(2)\n const m = payload.match(/^([^\\s]+)\\(([^\\s]+)\\)$/) ?? payload.match(/^([^\\s]+)\\s+([^\\s]+)$/)\n return { ...ev, name: m?.[1] ?? payload, version: m?.[2] }\n },\n request: \"\\x1b[>q\",\n ...opts,\n })\n }\n}\n\nexport function parseAttrs(params: string): number[] {\n return params\n .slice(1)\n .split(\";\")\n .map((n) => Number.parseInt(n, 10))\n .filter(Number.isFinite)\n}\n"],"mappings":";AAwDA,MAAM,4BAAY,IAAI,IAAY;CAAC;CAAQ;CAAO;CAAS;AAAM,CAAC;AA8BlE,MAAM,oCAAoB,IAAI,IAAY;CA5BxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAEkD,CAAC;AAUrD,IAAa,kBAAb,cAAqC,MAAM;CACzC,YAAY,SAAiB,QAAgB;EAC3C,MAAM,uBAAuB,KAAK,UAAU,OAAO,EAAE,IAAI,QAAQ;EACjE,KAAK,OAAO;CACd;AACF;AAEA,SAAS,aAAa,SAAgC;CACpD,MAAM,OAAO;EAAE,KAAK;EAAO,MAAM;EAAO,MAAM;EAAO,OAAO;CAAM;CAClE,IAAI,OAAO;CACX,OAAO,KAAK,SAAS,GAAG;EACtB,MAAM,OAAO,KAAK,QAAQ,GAAG;EAC7B,IAAI,QAAQ,GAAG;EACf,MAAM,MAAM,KAAK,MAAM,GAAG,IAAI;EAC9B,IAAI,CAAC,UAAU,IAAI,GAAG,GAAG,MAAM,IAAI,gBAAgB,SAAS,qBAAqB,KAAK;EACtF,IAAI,KAAK,MAAqB,MAAM,IAAI,gBAAgB,SAAS,uBAAuB,KAAK;EAC7F,KAAK,OAAsB;EAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;CAC5B;CAEA,MAAM,MAAM,aAAa;EAAE,GAAG;EAAM;CAAK,CA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,IACtC,KAAA;GACN,SAAS;GACT,GAAG;EACL,CAAC;CACH;CAEA,0BAA0B,OAA0B,CAAC,GAAG;EACtD,OAAO,KAAK,MAAmD;GAC7D,QAAQ,OACN,GAAG,SAAS,SAAS,GAAG,UAAU,OAAO,GAAG,OAAO,WAAW,GAAG,IAC7D;IAAE,GAAG;IAAI,OAAO,WAAW,GAAG,MAAM;GAAE,IACtC,KAAA;GACN,SAAS;GACT,GAAG;EACL,CAAC;CACH;CAEA,UAAU,OAA0B,CAAC,GAAG;EACtC,OAAO,KAAK,MAAkE;GAC5E,QAAQ,OAAO;IACb,IAAI,GAAG,SAAS,SAAS,CAAC,GAAG,QAAQ,WAAW,IAAI,GAAG;IACvD,MAAM,UAAU,GAAG,QAAQ,MAAM,CAAC;IAClC,MAAM,IAAI,QAAQ,MAAM,wBAAwB,KAAK,QAAQ,MAAM,uBAAuB;IAC1F,OAAO;KAAE,GAAG;KAAI,MAAM,IAAI,MAAM;KAAS,SAAS,IAAI;IAAG;GAC3D;GACA,SAAS;GACT,GAAG;EACL,CAAC;CACH;AACF;AAEA,SAAgB,WAAW,QAA0B;CACnD,OAAO,OACJ,MAAM,CAAC,CAAC,CACR,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,OAAO,SAAS,GAAG,EAAE,CAAC,CAAC,CAClC,OAAO,OAAO,QAAQ;AAC3B"}
|
|
1
|
+
{"version":3,"file":"queries-B_lOwEiE.mjs","names":[],"sources":["../src/input/keys.ts","../src/input/queries.ts"],"sourcesContent":["/**\n * Keyboard event shape + pattern-based matcher.\n *\n * `KeyEvent.name` is a canonical name:\n * - Single characters for printable keys: `\"a\"`, `\"A\"`, `\" \"`, `\"!\"`. The\n * `name` reflects the raw character the decoder produced — so `Shift+A`\n * arrives as `{ name: \"A\", shift: true }` (terminals already fold\n * shift into the uppercase byte for letters).\n * - Named constants for non-printing keys: `\"enter\"`, `\"tab\"`, `\"esc\"`,\n * `\"backspace\"`, `\"delete\"`, `\"space\"`, arrows `\"up\"/\"down\"/\"left\"/\n * \"right\"`, navigation `\"home\"/\"end\"/\"pageup\"/\"pagedown\"/\"insert\"`,\n * function keys `\"f1\"` .. `\"f12\"`.\n *\n * Patterns for `keyMatches` are dash-separated modifier prefixes plus the\n * name: `\"a\"`, `\"ctrl-c\"`, `\"shift-tab\"`, `\"ctrl-shift-x\"`. Unknown\n * prefixes are treated as literal characters in the name, so\n * `\"something-foo\"` is interpreted as the name `\"something-foo\"` rather\n * than a missing-modifier error.\n *\n * Modifier prefixes (order-independent):\n * - `ctrl-`\n * - `alt-`\n * - `shift-`\n * - `meta-` (a.k.a. super / cmd)\n */\n\nexport interface KeyEvent {\n /** Canonical key name — raw character or one of the named constants above. */\n name: string\n /**\n * The literal text the keystroke would insert, when that makes sense.\n * For printable chars this is the char itself; for Enter, Tab, etc. it's\n * undefined. Widgets use this to decide whether to insert content vs.\n * treat the key as a command.\n */\n text?: string\n ctrl: boolean\n alt: boolean\n shift: boolean\n meta: boolean\n}\n\n/** Canonical modifier names used in `KeyPattern`. */\nexport type KeyModifier = \"ctrl\" | \"alt\" | \"shift\" | \"meta\"\n\n/**\n * Named keys the decoder emits for non-printable keystrokes. Bindings\n * reference these directly (`\"enter\"`, `\"f5\"`, `\"pageup\"`, …).\n */\nexport type SpecialKeyName = (typeof specialKeys)[number]\n\ndeclare const KeyPatternBrand: unique symbol\n\n/** A validated, canonical key binding string. */\nexport type KeyPattern = string & { readonly [KeyPatternBrand]: true }\n\nconst MOD_NAMES = new Set<string>([\"ctrl\", \"alt\", \"shift\", \"meta\"])\nconst specialKeys = [\n \"enter\",\n \"tab\",\n \"backspace\",\n \"delete\",\n \"space\",\n \"esc\",\n \"up\",\n \"down\",\n \"left\",\n \"right\",\n \"home\",\n \"end\",\n \"pageup\",\n \"pagedown\",\n \"insert\",\n \"f1\",\n \"f2\",\n \"f3\",\n \"f4\",\n \"f5\",\n \"f6\",\n \"f7\",\n \"f8\",\n \"f9\",\n \"f10\",\n \"f11\",\n \"f12\",\n] as const\nconst SPECIAL_KEY_NAMES = new Set<string>(specialKeys)\n\ninterface ParsedPattern {\n name: string\n ctrl: boolean\n alt: boolean\n shift: boolean\n meta: boolean\n}\n\nexport class KeyPatternError extends Error {\n constructor(pattern: string, reason: string) {\n super(`invalid key pattern ${JSON.stringify(pattern)}: ${reason}`)\n this.name = \"KeyPatternError\"\n }\n}\n\nfunction parsePattern(pattern: string): ParsedPattern {\n const mods = { alt: false, ctrl: false, meta: false, shift: false }\n let name = pattern\n while (name.length > 0) {\n const dash = name.indexOf(\"-\")\n if (dash <= 0) break\n const mod = name.slice(0, dash)\n if (!MOD_NAMES.has(mod)) throw new KeyPatternError(pattern, `unknown modifier: ${mod}`)\n if (mods[mod as KeyModifier]) throw new KeyPatternError(pattern, `duplicate modifier: ${mod}`)\n mods[mod as KeyModifier] = true\n name = name.slice(dash + 1)\n }\n\n const ret = normalizeKey({ ...mods, name })\n name = ret.name\n if (name === \"\") throw new KeyPatternError(pattern, \"missing key name\")\n if (name.includes(\"-\") && name !== \"-\") throw new KeyPatternError(pattern, \"too many keys\")\n if (!isPrintableKeyName(name)) throw new KeyPatternError(pattern, `unknown key name: ${name}`)\n if (mods.shift && !canUseShiftModifier(name)) {\n throw new KeyPatternError(\n pattern,\n `shift-${name} will not trigger; bind the shifted character instead`\n )\n }\n return ret\n}\n\nfunction normalizeKey(p: ParsedPattern): ParsedPattern {\n if (/^[A-Z]$/.test(p.name)) return { ...p, name: p.name.toLowerCase(), shift: true }\n if (p.name === \" \") return { ...p, name: \"space\" }\n return p\n}\n\nfunction isPrintableKeyName(s: string): boolean {\n // oxlint-disable-next-line typescript/no-misused-spread\n return SPECIAL_KEY_NAMES.has(s) || ([...s].length === 1 && !/[\\p{C}]/u.test(s))\n}\n\nfunction canUseShiftModifier(name: string): boolean {\n return /^[a-zA-Z]$/.test(name) || SPECIAL_KEY_NAMES.has(name)\n}\n\nexport function isKeyPattern(s: string): s is KeyPattern {\n try {\n canonical(s)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Canonical string form of a pattern or event — modifiers in a fixed\n * alphabetical order, then the key name, joined by `-`. Used by the\n * router to build a pattern index whose keys match regardless of how\n * the user spelled the modifier order (`\"ctrl-shift-a\"` and\n * `\"shift-ctrl-a\"` both canonicalize to `\"ctrl-shift-a\"`).\n */\nexport function canonical(patternOrEvent: string | KeyEvent): KeyPattern {\n const p =\n typeof patternOrEvent === \"string\" ? parsePattern(patternOrEvent) : normalizeKey(patternOrEvent)\n const parts: string[] = []\n if (p.alt) parts.push(\"alt\")\n if (p.ctrl) parts.push(\"ctrl\")\n if (p.meta) parts.push(\"meta\")\n if (p.shift) parts.push(\"shift\")\n parts.push(p.name)\n return parts.join(\"-\") as KeyPattern\n}\n\n/**\n * Test whether an event matches a pattern (or any of a list of patterns).\n * Unspecified modifiers in the pattern must be *absent* on the event —\n * matching is strict, not inclusive, so `\"a\"` only matches a bare `a`\n * (no ctrl/alt/etc.).\n */\nexport function keyMatches(ev: KeyEvent, pattern: string | readonly string[]): boolean {\n if (Array.isArray(pattern)) {\n for (const p of pattern) if (keyMatches(ev, p)) return true\n return false\n }\n const p = parsePattern(pattern as string)\n const e = normalizeKey(ev)\n return (\n e.name === p.name &&\n e.ctrl === p.ctrl &&\n e.alt === p.alt &&\n e.shift === p.shift &&\n e.meta === p.meta\n )\n}\n","import type { TerminalResponseEvent } from \"./decoder.ts\"\nimport type { InputRouter } from \"./router.ts\"\n\nexport type TerminalQuery<T = TerminalResponseEvent> = TerminalQueryOpts & {\n request: string\n match: (event: TerminalResponseEvent) => T | undefined\n}\n\nexport type TerminalQueryOpts = {\n timeout?: number\n wrap?: (seq: string) => string\n}\n\ntype TerminalQueryWriter = {\n write: (seq: string) => void\n}\n\nexport class TerminalQueries {\n readonly #router: InputRouter\n readonly #terminal: TerminalQueryWriter\n\n constructor(router: InputRouter, terminal: TerminalQueryWriter) {\n this.#router = router\n this.#terminal = terminal\n }\n\n query<T>(query: TerminalQuery<T>): Promise<T | undefined> {\n const timeout = query.timeout ?? 200\n const ac = new AbortController()\n return new Promise((resolve) => {\n const finish = (value?: T) => {\n if (ac.signal.aborted) return\n ac.abort()\n clearTimeout(timer)\n resolve(value)\n }\n const timer = setTimeout(() => finish(), timeout)\n timer.unref()\n this.#router.on(\n \"term-response\",\n ({ event }) => {\n const value = query.match(event)\n if (value !== undefined) finish(value)\n },\n { signal: ac.signal }\n )\n this.#terminal.write(query.wrap?.(query.request) ?? query.request)\n })\n }\n\n primaryDeviceAttributes(opts: TerminalQueryOpts = {}) {\n return this.query<TerminalResponseEvent & { attrs: number[] }>({\n match: (ev) =>\n ev.kind === \"csi\" && ev.final === \"c\" && ev.params.startsWith(\"?\")\n ? { ...ev, attrs: parseAttrs(ev.params) }\n : undefined,\n request: \"\\x1b[c\",\n ...opts,\n })\n }\n\n secondaryDeviceAttributes(opts: TerminalQueryOpts = {}) {\n return this.query<TerminalResponseEvent & { attrs: number[] }>({\n match: (ev) =>\n ev.kind === \"csi\" && ev.final === \"c\" && ev.params.startsWith(\">\")\n ? { ...ev, attrs: parseAttrs(ev.params) }\n : undefined,\n request: \"\\x1b[>c\",\n ...opts,\n })\n }\n\n xtVersion(opts: TerminalQueryOpts = {}) {\n return this.query<TerminalResponseEvent & { name: string; version?: string }>({\n match: (ev) => {\n if (ev.kind !== \"dcs\" || !ev.payload.startsWith(\">|\")) return\n const payload = ev.payload.slice(2)\n const m = payload.match(/^([^\\s]+)\\(([^\\s]+)\\)$/) ?? payload.match(/^([^\\s]+)\\s+([^\\s]+)$/)\n return { ...ev, name: m?.[1] ?? payload, version: m?.[2] }\n },\n request: \"\\x1b[>q\",\n ...opts,\n })\n }\n}\n\nexport function parseAttrs(params: string): number[] {\n return params\n .slice(1)\n .split(\";\")\n .map((n) => Number.parseInt(n, 10))\n .filter(Number.isFinite)\n}\n"],"mappings":";AAwDA,MAAM,4BAAY,IAAI,IAAY;CAAC;CAAQ;CAAO;CAAS;AAAM,CAAC;AA8BlE,MAAM,oCAAoB,IA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WAAW,IAAI,GAAG;IACvD,MAAM,UAAU,GAAG,QAAQ,MAAM,CAAC;IAClC,MAAM,IAAI,QAAQ,MAAM,wBAAwB,KAAK,QAAQ,MAAM,uBAAuB;IAC1F,OAAO;KAAE,GAAG;KAAI,MAAM,IAAI,MAAM;KAAS,SAAS,IAAI;IAAG;GAC3D;GACA,SAAS;GACT,GAAG;EACL,CAAC;CACH;AACF;AAEA,SAAgB,WAAW,QAA0B;CACnD,OAAO,OACJ,MAAM,CAAC,CAAC,CACR,MAAM,GAAG,CAAC,CACV,KAAK,MAAM,OAAO,SAAS,GAAG,EAAE,CAAC,CAAC,CAClC,OAAO,OAAO,QAAQ;AAC3B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as Color, f as Style, t as Theme } from "./types-
|
|
2
|
-
import { a as StyleBuilder, t as InspectOpts } from "./inspect-
|
|
1
|
+
import { c as Color, f as Style, t as Theme } from "./types-C0EOLZDc.mjs";
|
|
2
|
+
import { a as StyleBuilder, t as InspectOpts } from "./inspect-DPLRum7L.mjs";
|
|
3
3
|
import { Emitter, MaybePromise } from "@zaly/shared";
|
|
4
4
|
import { LogEntry, LogLevel, LogReporter, Logger, TryResult } from "@zaly/shared/logger";
|
|
5
5
|
import { ArgsOpts, ArgsResult } from "@zaly/shared/args";
|
|
@@ -1960,4 +1960,4 @@ declare class TerminalQueries {
|
|
|
1960
1960
|
declare function parseAttrs(params: string): number[];
|
|
1961
1961
|
//#endregion
|
|
1962
1962
|
export { Context as $, LogState as A, useContext as At, Padding as B, Actions as Bt, OverlaySurface as C, peek as Ct, LoggerStream as D, untrack as Dt, LogStyleOverride as E, toAccessor as Et, Overlay as F, ActionCtx as Ft, text as G, KeyModifier as Gt, Text as H, NodeAction as Ht, OverlayState as I, ActionDef as It, Layout as J, SpecialKeyName as Jt, textContent as K, KeyPattern as Kt, overlay as L, ActionFilter as Lt, log as M, withOwner as Mt, MountCtx as N, Size as Nt, TuiReporter as O, unwrap as Ot, RenderCtx as P, Action as Pt, Accessor as Q, Box as R, ActionFn as Rt, Stream as S, onCleanup as St, LogEntryFactory as T, signal as Tt, TextContent as U, NodeActionMap as Ut, box as V, KeyBinding as Vt, TextStyle as W, KeyEvent as Wt, State as X, isKeyPattern as Xt, LayoutState as Y, canonical as Yt, StyleState as Z, keyMatches as Zt, RenderStats as _, createSuspenseBoundary as _t, InputRouter as a, Signal as at, SurfaceType as b, isAccessor as bt, KeyPatterns as c, SuspenseContext as ct, RoutedPaste as d, createIterable as dt, Owner as et, BaseEvents as f, createNode as ft, RenderEvents as g, createStore as gt, NodeVisitor as h, createRoot as ht, parseAttrs as i, Setter as it, LogStyle as j, withActiveNode as jt, TuiReporterOpts as k, useActiveOwner as kt, KeymapEntry as l, createAsync as lt, isNode as m, createRef as mt, TerminalQuery as n, Reactive as nt, InputRouterEvents as o, SignalStore as ot, Node as p, createProgressive as pt, FlexState as q, KeyPatternError as qt, TerminalQueryOpts as r, Ref as rt, KeyHandler as s, SuspenseBoundary as st, TerminalQueries as t, Progressive as tt, RoutedKey as u, createContext as ut, Renderer as v, effect as vt, Terminal as w, provideContext as wt, UI as x, memo as xt, RendererOptions as y, inRenderContextOf as yt, BoxStyle as z, ActionMap as zt };
|
|
1963
|
-
//# sourceMappingURL=queries-
|
|
1963
|
+
//# sourceMappingURL=queries-Cvalgu6P.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries-Cvalgu6P.d.mts","names":["_$___core_state_ts0.Layout","_$__box_ts0.Box","_$__terminal_ts0.Terminal"],"sources":["../src/input/keys.ts","../src/input/decoder.ts","../src/input/actions.ts","../src/layout/size.ts","../src/core/reactive.ts","../src/core/state.ts","../src/layout/border.ts","../src/widgets/text.ts","../src/widgets/box.ts","../src/widgets/overlay.ts","../src/core/ctx.ts","../src/widgets/log.ts","../src/services/logger.ts","../src/renderer/terminal.ts","../src/renderer/frame.ts","../src/renderer/surface.ts","../src/renderer/overlay.ts","../src/renderer/selection.ts","../src/renderer/stream.ts","../src/renderer/ui.ts","../src/renderer/renderer.ts","../src/core/node.ts","../src/input/router.ts","../src/input/queries.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA0BiB;;EAEf;;;;;;;EAOA;EACA;EACA;EACA;EACA;;;KAIU;;;;;KAMA,yBAAyB;cAEvB;;KAGF;YAAkC;;cAGxC;cAuCO,wBAAwB;EACnC,YAAY,iBAAiB;;iBAgDf,aAAa,YAAY,KAAK;;;;;;;;iBAgB9B,UAAU,yBAAyB,WAAW;;;;;;;iBAkB9C,WAAW,IAAI,UAAU;;;;;;;;;;;;KCvK7B;KAEA;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;EAEI;EAAgB;;EAChB;EAA8B,QAAQ;EAAa;;KAG7C;EACN;EAAuB;EAAa;EAAkB;EAAgB;;EACtE;EAAuB;EAA6B;EAAkB;;KAEhE;EACN;EAAa,OAAO;;EACpB;EAAe;;EACf;EAAe;IACjB,wBACA;;;;;;;;KCrBQ,UAAU,UAAU,WAAW,UAAU;;WAE1C;WACA,OAAO;;;;WAIP,SAAS;;WAET;;WAEA,MAAM;EACf,OAAO,WAAW;KACf,UAAU;;;;WAKA,MAAM;;KAIT,SAAS,UAAU,WAAW,UAAU,aAClD,KAAK,UAAU,GAAG,OACf;KAEO,aAAa,KAAK;EAC5B;EACA,IAAI;EACJ;;;;;;;;;;;;;;;UAgBe,UAAU,UAAU,WAAW,UAAU;EACxD;EACA;EACA;EACA;EACA,OAAO;EACP;EACA,KAAK,SAAS,GAAG;;;EAGjB;;KAGU,OAAO,UAAU,WAAW,UAAU,YAAY,UAAU,GAAG;EAAO;;KAEtE,YAAY,eAAe;KAE3B;EACV;EACA,cAAc;EACd;EACA;EACA,UAAU,MAAM;;;;;;;;;;;KA0BN,WAAW,UAAU,OAAO,QACpC,SAAS,UAAU,MAClB,UAAU,UAAU;EAAO,IAAI,SAAS,UAAU;;;KAG3C,cAAc,UAAU,OAAO,QAAQ,eAAe,W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