@visulima/tui 4.0.0 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/LICENSE.md +130 -1
- package/dist/components/box.d.ts +735 -3
- package/dist/components/box.js +1 -1
- package/dist/components/canvas.js +1 -1
- package/dist/components/cursor.d.ts +2 -3
- package/dist/components/cursor.js +1 -1
- package/dist/components/error-overview.js +1 -1
- package/dist/components/spacer.js +1 -1
- package/dist/components/static-render.d.ts +2 -3
- package/dist/components/static-render.js +1 -1
- package/dist/components/static.d.ts +1 -3
- package/dist/components/static.js +1 -1
- package/dist/components/text.d.ts +1 -3
- package/dist/components/text.js +1 -1
- package/dist/components/transform.js +1 -1
- package/dist/core/index.js +1 -1
- package/dist/ink/canvas/index.d.ts +14 -1
- package/dist/ink/canvas/index.js +1 -1
- package/dist/ink/hooks/use-animation.js +1 -1
- package/dist/ink/hooks/use-app.d.ts +1 -2
- package/dist/ink/hooks/use-app.js +1 -1
- package/dist/ink/hooks/use-box-metrics.d.ts +2 -3
- package/dist/ink/hooks/use-box-metrics.js +1 -1
- package/dist/ink/hooks/use-clipboard.js +1 -1
- package/dist/ink/hooks/use-color-blindness.js +1 -1
- package/dist/ink/hooks/use-console-capture.js +1 -1
- package/dist/ink/hooks/use-cursor.d.ts +0 -1
- package/dist/ink/hooks/use-cursor.js +1 -1
- package/dist/ink/hooks/use-focus-manager.d.ts +0 -1
- package/dist/ink/hooks/use-focus-manager.js +1 -1
- package/dist/ink/hooks/use-focus.js +1 -1
- package/dist/ink/hooks/use-form.js +1 -1
- package/dist/ink/hooks/use-hotkey.js +1 -1
- package/dist/ink/hooks/use-input.js +2 -2
- package/dist/ink/hooks/use-interval.js +1 -1
- package/dist/ink/hooks/use-key-bindings.js +1 -1
- package/dist/ink/hooks/use-key-chord.js +1 -1
- package/dist/ink/hooks/use-paste.js +1 -1
- package/dist/ink/hooks/use-persistent-state.js +2 -2
- package/dist/ink/hooks/use-scroll-acceleration.js +1 -1
- package/dist/ink/hooks/use-scroll-input.js +1 -1
- package/dist/ink/hooks/use-stderr.d.ts +0 -1
- package/dist/ink/hooks/use-stderr.js +1 -1
- package/dist/ink/hooks/use-stdin.d.ts +0 -1
- package/dist/ink/hooks/use-stdin.js +1 -1
- package/dist/ink/hooks/use-stdout.d.ts +0 -1
- package/dist/ink/hooks/use-stdout.js +1 -1
- package/dist/ink/hooks/use-stopwatch.js +1 -1
- package/dist/ink/hooks/use-terminal-palette.js +1 -1
- package/dist/ink/hooks/use-text-buffer.js +4 -4
- package/dist/ink/hooks/use-text-selection.d.ts +3 -4
- package/dist/ink/hooks/use-text-selection.js +1 -1
- package/dist/ink/hooks/use-timeout.js +1 -1
- package/dist/ink/hooks/use-timer.js +1 -1
- package/dist/ink/hooks/use-window-size.js +1 -1
- package/dist/ink/index.d.ts +23 -15
- package/dist/ink/index.js +1 -1
- package/dist/ink/mouse/use-element-position.d.ts +2 -3
- package/dist/ink/mouse/use-element-position.js +1 -1
- package/dist/ink/mouse/use-mouse-action.d.ts +1 -2
- package/dist/ink/mouse/use-mouse-action.js +1 -1
- package/dist/ink/mouse/use-mouse-position.d.ts +1 -2
- package/dist/ink/mouse/use-mouse-position.js +1 -1
- package/dist/ink/mouse/use-mouse.d.ts +1 -2
- package/dist/ink/mouse/use-mouse.js +1 -1
- package/dist/ink/mouse/use-on-mouse-click.d.ts +3 -4
- package/dist/ink/mouse/use-on-mouse-click.js +1 -1
- package/dist/ink/mouse/use-on-mouse-hover.d.ts +2 -3
- package/dist/ink/mouse/use-on-mouse-hover.js +1 -1
- package/dist/ink/mouse/use-on-mouse-state.d.ts +2 -3
- package/dist/ink/mouse/use-on-mouse-state.js +1 -1
- package/dist/ink/public/cursor.d.ts +22 -1
- package/dist/ink/public/cursor.js +1 -1
- package/dist/ink/public/dom.d.ts +2 -3
- package/dist/ink/public/highlighter.d.ts +49 -3
- package/dist/ink/public/highlighter.js +1 -1
- package/dist/ink/public/input.d.ts +19 -1
- package/dist/ink/public/styles.d.ts +1 -3
- package/dist/ink/public/utils.d.ts +8 -1
- package/dist/ink/public/utils.js +1 -1
- package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-CaI93Rjj.js +1 -0
- package/dist/packem_shared/Cell-CbDQUAjW.js +1 -0
- package/dist/packem_shared/DevTools-DKYxA_wO.js +1 -0
- package/dist/packem_shared/FocusContext-mWFBWdli.js +1 -0
- package/dist/packem_shared/Fullscreen-DKKMVbkg.js +1 -0
- package/dist/packem_shared/{IMECompositionBuffer-VhC9HRCv.js → IMECompositionBuffer-uYiAz3jI.js} +1 -1
- package/dist/packem_shared/{InputParser-CUAGWKQQ.js → InputParser-O4nyWUuQ.js} +2 -2
- package/dist/packem_shared/{KEY-C--kOw41.js → KEY-DGV_trPu.js} +1 -1
- package/dist/packem_shared/LayoutNode-D4i45GQM.js +1 -0
- package/dist/packem_shared/MouseProvider-BSTuFqG9.js +1 -0
- package/dist/packem_shared/NAMED_COLORS-DvfPALxN.js +1 -0
- package/dist/packem_shared/Range-CMqYzhij.js +1 -0
- package/dist/packem_shared/Renderer-Dg5_-6TF.js +1 -0
- package/dist/packem_shared/ResizeObserver-ClWoCtGV.js +1 -0
- package/dist/packem_shared/Static-sqw4n2Fv.js +1 -0
- package/dist/packem_shared/{TuiApp-CCVaiKbf.js → TuiApp-D1How6sn.js} +1 -1
- package/dist/packem_shared/TuiContext-Bbq9JRCu.js +3 -0
- package/dist/packem_shared/animation-context-Icwf5tBE.js +1 -0
- package/dist/packem_shared/ansi-parser-CysVDsNz.js +1 -0
- package/dist/packem_shared/ansi-tokenizer-D5k5LzXg.js +1 -0
- package/dist/packem_shared/{app-context-DTm1_XBA.js → app-context-CfgsW0CV.js} +1 -1
- package/dist/packem_shared/{app-context.d-DMLw5Nxy.d.ts → app-context.d-DAF6oxKX.d.ts} +0 -1
- package/dist/packem_shared/{boxes-DyY_LXCi.js → boxes-CidWUOVk.js} +1 -1
- package/dist/packem_shared/buildCursorOnlySequence-D24o0D7-.js +1 -0
- package/dist/packem_shared/calculateScroll-jdxVlcmq.js +1 -0
- package/dist/packem_shared/calculateScrollbarLayout-DCVwJ0Cl.js +1 -0
- package/dist/packem_shared/clearOsc52-olbKg5Nw.js +1 -0
- package/dist/packem_shared/clearStringWidthCache-EWeHQcEb.js +1 -0
- package/dist/packem_shared/colorize-Dsbi0Wr0.js +1 -0
- package/dist/packem_shared/createBrailleGrid-B5uefhi4.js +1 -0
- package/dist/packem_shared/createCanvasBuffer-C7w6bGe4.js +1 -0
- package/dist/packem_shared/createInlineLoop-BPlBAXqd.js +2 -0
- package/dist/packem_shared/createScreen-BBvF-ZyU.js +3 -0
- package/dist/packem_shared/cursor-context-wLwblh2o.js +1 -0
- package/dist/packem_shared/{disposeHighlighter-D9OkrhwX.js → disposeHighlighter-BS4lDPP8.js} +1 -1
- package/dist/packem_shared/dom-xpeZzKuf.js +1 -0
- package/dist/packem_shared/{dom.d-CLGlidfI.d.ts → dom.d-BV2bnRcH.d.ts} +2 -3
- package/dist/packem_shared/{focus-context-CsT69klR.js → focus-context-8h3hmNxy.js} +1 -1
- package/dist/packem_shared/formatDuration-DcLMLZro.js +1 -0
- package/dist/packem_shared/getPathToRoot-DBqZKIzf.js +1 -0
- package/dist/packem_shared/index-7Qq5uu0d.js +75 -0
- package/dist/packem_shared/isIntersecting-C8tJIsvH.js +1 -0
- package/dist/packem_shared/isTerminalPaletteQuerySupported-DwJPJ8_h.js +1 -0
- package/dist/packem_shared/kittyFlags-jpd_IAFL.js +1 -0
- package/dist/packem_shared/load-native-root-binding-B1WunHs4.js +1 -0
- package/dist/packem_shared/measure-element-pHwUPovG.js +1 -0
- package/dist/packem_shared/measure-text-DtlK6gar.js +3 -0
- package/dist/packem_shared/mouse-context-BEnaR3tG.js +1 -0
- package/dist/packem_shared/{mouse-context.d-W-nszUps.d.ts → mouse-context.d-5TGeZyIF.d.ts} +1 -2
- package/dist/packem_shared/parseSgrMouse-CHYo9gs6.js +1 -0
- package/dist/packem_shared/processLayout-DYdx6C3A.js +2 -0
- package/dist/packem_shared/reconciler-BPm7fZa6.js +1 -0
- package/dist/packem_shared/reconciler-DXp9qy6k.js +1 -0
- package/dist/packem_shared/render-B_NqU7AH.js +1 -0
- package/dist/packem_shared/render-DrIzCc0i.js +24 -0
- package/dist/packem_shared/{render.d-DjQhFsiN.d.ts → render.d-dEKhpngX.d.ts} +2 -3
- package/dist/packem_shared/renderToString-BLr8QvYq.js +2 -0
- package/dist/packem_shared/renderToString-D66vRHLQ.js +4 -0
- package/dist/packem_shared/renderToken-DFWLdYz_.js +1 -0
- package/dist/packem_shared/renderTreeToBuffer-MEHvKJc-.js +2 -0
- package/dist/packem_shared/renderer-D97BmOBO.js +17 -0
- package/dist/packem_shared/{selection.d-BSAWa4ey.d.ts → selection.d-DCMpXtpU.d.ts} +1 -1
- package/dist/packem_shared/squashTextNodesWithMap-CUJZZeW3.js +1 -0
- package/dist/packem_shared/stderr-context-Xeacf3Ir.js +1 -0
- package/dist/packem_shared/stdin-context-Ceh-YuU1.js +1 -0
- package/dist/packem_shared/stdout-context-BhxOwdNK.js +1 -0
- package/dist/packem_shared/{styles.d-CKGQFfm4.d.ts → styles.d-BCZOPl_g.d.ts} +37 -3
- package/dist/packem_shared/text-width-BXmBaLDv.js +2 -0
- package/dist/packem_shared/utils-BlDbvbdr.js +1 -0
- package/dist/packem_shared/waitFor-BjdYqkin.js +4 -0
- package/dist/packem_shared/wrapOrTruncateStyledLine-Gm21gYDr.js +3 -0
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/testing/index.d.ts +4 -6
- package/dist/testing/index.js +1 -1
- package/index.js +26 -26
- package/package.json +12 -12
- package/dist/packem_shared/COLOR_BLINDNESS_COMPENSATION-Ilnoyeqc.js +0 -1
- package/dist/packem_shared/Cell-BrXn3jxY.js +0 -1
- package/dist/packem_shared/DevTools-CZ-O0Ckm.js +0 -1
- package/dist/packem_shared/FocusContext-BWFqf9kb.js +0 -1
- package/dist/packem_shared/Fullscreen-BRhuBLBh.js +0 -1
- package/dist/packem_shared/LayoutNode-LPYsuzBg.js +0 -1
- package/dist/packem_shared/MouseProvider-DOcWCRVq.js +0 -1
- package/dist/packem_shared/NAMED_COLORS-82DpREQV.js +0 -1
- package/dist/packem_shared/Range-BsVYNWtg.js +0 -1
- package/dist/packem_shared/Renderer-BeS49FNq.js +0 -1
- package/dist/packem_shared/ResizeObserver-BI9bDy-j.js +0 -1
- package/dist/packem_shared/Static-DSzsElz4.js +0 -1
- package/dist/packem_shared/TuiContext-BNmP0lMY.js +0 -3
- package/dist/packem_shared/animation-context-DW3p-vpk.js +0 -1
- package/dist/packem_shared/ansi-parser-DlgLtOYO.js +0 -1
- package/dist/packem_shared/ansi-tokenizer-BU67A126.js +0 -1
- package/dist/packem_shared/buildCursorOnlySequence-CerkmjWt.js +0 -1
- package/dist/packem_shared/calculateScroll-D4Y_JR4H.js +0 -1
- package/dist/packem_shared/calculateScrollbarLayout-Lf6i24c9.js +0 -1
- package/dist/packem_shared/clearOsc52-BUpnQOav.js +0 -1
- package/dist/packem_shared/clearStringWidthCache-DKFjfJuB.js +0 -1
- package/dist/packem_shared/colorize-DU4YZkp3.js +0 -1
- package/dist/packem_shared/createBrailleGrid-BTOQrujS.js +0 -1
- package/dist/packem_shared/createCanvasBuffer-CL6sAM-A.js +0 -1
- package/dist/packem_shared/createInlineLoop-BMDYJkRp.js +0 -2
- package/dist/packem_shared/createScreen-DoYpyL0V.js +0 -3
- package/dist/packem_shared/cursor-context-CFviBqPX.js +0 -1
- package/dist/packem_shared/dom-rphpG0kf.js +0 -1
- package/dist/packem_shared/formatDuration-Bdx4ZgRh.js +0 -1
- package/dist/packem_shared/getPathToRoot-PDJeqiEH.js +0 -1
- package/dist/packem_shared/index-Dl9I2_QH.js +0 -75
- package/dist/packem_shared/isIntersecting-Bo2npvMR.js +0 -1
- package/dist/packem_shared/isTerminalPaletteQuerySupported-BYzmqq9-.js +0 -1
- package/dist/packem_shared/kittyFlags-g8ALyoCU.js +0 -1
- package/dist/packem_shared/load-native-root-binding-CxJnHcac.js +0 -1
- package/dist/packem_shared/measure-element-D4M9iSYp.js +0 -1
- package/dist/packem_shared/measure-text-B7juNq4Y.js +0 -3
- package/dist/packem_shared/mouse-context-DaARgUu1.js +0 -1
- package/dist/packem_shared/parseSgrMouse-bUrqPrh-.js +0 -1
- package/dist/packem_shared/processLayout-I83k6vXE.js +0 -2
- package/dist/packem_shared/reconciler-D4fi5NfR.js +0 -1
- package/dist/packem_shared/reconciler-DkwOtC5B.js +0 -1
- package/dist/packem_shared/render-CPVY5vpQ.js +0 -1
- package/dist/packem_shared/render-CvhjGwOg.js +0 -24
- package/dist/packem_shared/renderToString-B1LgWcJe.js +0 -4
- package/dist/packem_shared/renderToString-Df6HST7u.js +0 -2
- package/dist/packem_shared/renderToken-DjiQ6dfv.js +0 -1
- package/dist/packem_shared/renderTreeToBuffer-BpSD0sBJ.js +0 -2
- package/dist/packem_shared/renderer-Cs0KEr1o.js +0 -17
- package/dist/packem_shared/squashTextNodesWithMap-BmUSBPfc.js +0 -1
- package/dist/packem_shared/stderr-context-CR2LLec6.js +0 -1
- package/dist/packem_shared/stdin-context-BjMA9Sbi.js +0 -1
- package/dist/packem_shared/stdout-context-DAAlQct2.js +0 -1
- package/dist/packem_shared/text-width-e49vlbQH.js +0 -2
- package/dist/packem_shared/utils-CVgM8kTn.js +0 -1
- package/dist/packem_shared/waitFor-CTAki32d.js +0 -4
- package/dist/packem_shared/wrapOrTruncateStyledLine-46W8bTtv.js +0 -3
package/dist/components/box.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as r,jsxs as p}from"react/jsx-runtime";import{forwardRef as u,useContext as h}from"react";import{a as B}from"../packem_shared/accessibility-context-DDyHTwmA.js";import{b as E}from"../packem_shared/background-context-rjOaWFki.js";const S={flexDirection:"row",flexGrow:0,flexShrink:1,flexWrap:"nowrap"},X=u(({"aria-hidden":x,"aria-label":t,"aria-role":n,"aria-state":l,backgroundColor:o,children:d,opaque:v,scrollbar:b,sticky:a,stickyChildren:s,...e},m)=>{const{isScreenReaderEnabled:i}=h(B),f=t?r("ink-text",{children:t}):void 0,w=n||l?{role:n,state:l}:void 0;if(i&&x)return null;const c=p("ink-box",{internal_accessibility:w,opaque:v,ref:m,scrollbar:b,sticky:a,style:{...S,...e,backgroundColor:o,overflowX:e.overflowX??e.overflow??"visible",overflowY:e.overflowY??e.overflow??"visible"},children:[i&&f?f:d,a&&s&&!i?r("ink-box",{internalStickyAlternate:!0,style:{position:"absolute",...e},children:s}):null]});return o?r(E.Provider,{value:o,children:c}):c});X.displayName="Box";export{X as Box,X as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as f}from"react/jsx-runtime";import{useRef as s,useMemo as d,Fragment as p}from"react";import{createCanvasBuffer as x,serializeRow as R}from"../packem_shared/createCanvasBuffer-C7w6bGe4.js";import{Box as h}from"./box.js";import{Text as v}from"./text.js";function j({draw:a,height:e,version:u,width:o}){const t=s(void 0),i=s(void 0);(t.current?.width!==o||t.current.height!==e)&&(t.current=x(o,e),i.current={hasRendered:!1,lines:Array.from({length:e}).fill("")});const n=t.current,c=i.current,l=d(()=>{a(n.context);for(let r=0;r<n.height;r+=1)c.hasRendered&&n.dirty[r]===0||(c.lines[r]=R(n,r),n.dirty[r]=0);return c.hasRendered=!0,[...c.lines]},[u,o,e]);return f(h,{flexDirection:"column",flexShrink:0,height:e,width:o,children:l.map((r,m)=>f(p,{children:f(v,{wrap:"truncate-end",children:r})},m))})}export{j as Canvas,j as default};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React, { RefObject } from 'react';
|
|
2
2
|
import { CursorShape } from "../ink/public/cursor.js";
|
|
3
|
-
import { D as DOMElement } from "../packem_shared/dom.d-
|
|
3
|
+
import { D as DOMElement } from "../packem_shared/dom.d-BV2bnRcH.js";
|
|
4
4
|
import 'yoga-layout';
|
|
5
|
+
import "../packem_shared/styles.d-BCZOPl_g.js";
|
|
5
6
|
import '@visulima/colorize';
|
|
6
|
-
import "../packem_shared/styles.d-CKGQFfm4.js";
|
|
7
|
-
import 'type-fest';
|
|
8
7
|
type Props = {
|
|
9
8
|
/**
|
|
10
9
|
* Optional reference to anchor cursor coordinates to a different element.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as c}from"react/jsx-runtime";import{useMemo as u}from"react";function m({anchorRef:t,shape:e,x:r=0,y:n=0}){const o=t??void 0,i=o===void 0&&r===0&&n===0,s=u(()=>({anchorRef:o,inline:i,shape:e,x:r,y:n}),[o,i,e,r,n]);return c("ink-cursor",{internal_cursor:s})}export{m as Cursor,m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire as
|
|
1
|
+
import{createRequire as b}from"node:module";import{jsxs as c,jsx as d}from"react/jsx-runtime";import{parseStacktrace as C}from"@visulima/error/stacktrace";import{Box as u}from"./box.js";import{Text as s}from"./text.js";let _;const $=o=>(_??=b(import.meta.url))(o),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=o=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[r,l]=a.versions.node.split(".").map(Number);if(r>22||r===22&&l>=3||r===20&&l>=16)return a.getBuiltinModule(o)}return $(o)},{existsSync:v,readFileSync:x}=w("node:fs"),{cwd:y}=a,T=(o,r=2)=>o.replace(/^\t+/gm,l=>" ".repeat(l.length*r)),j=(o,r)=>{const l=[],m=o-r,n=o+r;for(let t=m;t<=n;t++)l.push(t);return l},N=(o,r,l={})=>{var m;if(typeof o!="string")throw new TypeError("Source code is missing.");if(!r||r<1)throw new TypeError("Line number must start from `1`.");const n=T(o).split(/\r?\n/);if(!(r>n.length))return j(r,(m=l.around)!==null&&m!==void 0?m:3).filter(t=>n[t-1]!==void 0).map(t=>({line:t,value:n[t-1]}))},g=o=>{if(!o)return o;const r=y();return o.replace(`file://${r}/`,"").replace(`${r}/`,"")};function q({error:o}){const r=C(o),l=new Map,m=r.map(e=>{const i=!e.methodName&&!e.file?`raw:${e.raw}`:`${g(e.file)??""}:${e.line}:${e.column}:${e.methodName??""}`,h=l.get(i)??0;return l.set(i,h+1),{key:`${i}#${h}`,trace:e}}),n=r[0],t=g(n?.file);let f,p=0;if(t&&n?.line&&v(t)){const e=x(t,"utf8");if(f=N(e,n.line),f)for(const{line:i}of f)p=Math.max(p,String(i).length)}return c(u,{flexDirection:"column",padding:1,children:[c(u,{children:[c(s,{backgroundColor:"red",color:"white",children:[" ","ERROR"," "]}),c(s,{children:[" ",o.message]})]}),n&&t?d(u,{marginTop:1,children:c(s,{dimColor:!0,children:[t,":",n.line,":",n.column]})}):null,n&&f?d(u,{flexDirection:"column",marginTop:1,children:f.map(({line:e,value:i})=>c(u,{children:[d(u,{width:p+1,children:c(s,{"aria-label":e===n.line?`Line ${e}, error`:`Line ${e}`,backgroundColor:e===n.line?"red":void 0,color:e===n.line?"white":void 0,dimColor:e!==n.line,children:[String(e).padStart(p," "),":"]})}),d(s,{backgroundColor:e===n.line?"red":void 0,color:e===n.line?"white":void 0,children:` ${i}`})]},`excerpt-${e}`))}):null,r.length>0?d(u,{flexDirection:"column",marginTop:1,children:m.map(({key:e,trace:i})=>{const h=g(i.file)??"";return!i.methodName&&!i.file?c(u,{children:[d(s,{dimColor:!0,children:"- "}),d(s,{bold:!0,dimColor:!0,children:i.raw})]},e):c(u,{children:[d(s,{dimColor:!0,children:"- "}),d(s,{bold:!0,dimColor:!0,children:i.methodName??"<anonymous>"}),c(s,{"aria-label":`at ${h} line ${i.line} column ${i.column}`,color:"gray",dimColor:!0,children:[" ","(",h,":",i.line,":",i.column,")"]})]},e)})}):null]})}export{q as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{Box as o}from"./box.js";function
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{Box as o}from"./box.js";function f(){return r(o,{flexGrow:1})}export{f as Spacer,f as default};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode, DependencyList } from 'react';
|
|
2
|
-
import { D as DOMElement } from "../packem_shared/dom.d-
|
|
3
|
-
import { S as Styles } from "../packem_shared/styles.d-
|
|
2
|
+
import { D as DOMElement } from "../packem_shared/dom.d-BV2bnRcH.js";
|
|
3
|
+
import { S as Styles } from "../packem_shared/styles.d-BCZOPl_g.js";
|
|
4
4
|
import 'yoga-layout';
|
|
5
5
|
import "../ink/public/cursor.js";
|
|
6
6
|
import '@visulima/colorize';
|
|
7
|
-
import 'type-fest';
|
|
8
7
|
/**
|
|
9
8
|
* @property children Render function invoked once to produce the cached content.
|
|
10
9
|
* @property deps Dependencies that control when the static content is re-rendered. When any dependency changes (shallow, Object.is comparison), the cache is invalidated and children() is invoked again. If omitted, the cache is invalidated whenever the children function reference changes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as m}from"react/jsx-runtime";import{useRef as u,useLayoutEffect as v,useEffect as g,useMemo as E}from"react";const h=(e,r)=>{if(e===r)return!0;if(!e||!r||e.length!==r.length)return!1;for(const[f,c]of e.entries())if(!Object.is(c,r[f]))return!1;return!0},S=({children:e,deps:r,onRender:f,style:c,width:s})=>{const n=u(null),o=u(!1),a=u(r),l=u(e),d=u(f);d.current=f;let i=!1;r!==void 0?h(a.current,r)||(i=!0,a.current=r):e!==l.current&&(i=!0,l.current=e),i&&(o.current=!1,n.current&&(n.current.cachedRender=void 0)),v(()=>{const t=n.current;t&&(t.internal_onRendered=()=>{o.current=!0,d.current?.(t)})}),g(()=>()=>{const t=n.current;t&&(t.cachedRender=void 0,t.internal_onRendered=void 0)},[]);const R=E(()=>({...c,width:s}),[c,s]);return m("ink-static-render",{ref:n,style:R,children:o.current?null:e()})};export{S as StaticRender,S as default};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ReactNode, ReactElement } from 'react';
|
|
2
|
-
import { S as Styles } from "../packem_shared/styles.d-
|
|
2
|
+
import { S as Styles } from "../packem_shared/styles.d-BCZOPl_g.js";
|
|
3
3
|
import '@visulima/colorize';
|
|
4
|
-
import 'type-fest';
|
|
5
|
-
import 'yoga-layout';
|
|
6
4
|
type Props<T> = {
|
|
7
5
|
/**
|
|
8
6
|
* Function that is called to render every item in the `items` array. The first argument is the item itself, and the second argument is the index of that item in the `items` array. Note that a `key` must be assigned to the root component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as d}from"react/jsx-runtime";import{useState as f,useMemo as o,useLayoutEffect as x}from"react";function y(s){const{children:i,items:t,style:n}=s,[e,r]=f(0),c=o(()=>t.slice(e),[t,e]);x(()=>{r(t.length)},[t.length]);const l=c.map((m,a)=>i(m,e+a)),u=o(()=>({flexDirection:"column",position:"absolute",...n}),[n]);return d("ink-box",{internal_static:!0,style:u,children:l})}export{y as Static,y as default};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AnsiColors } from '@visulima/colorize';
|
|
2
2
|
import { ReactNode, ReactElement } from 'react';
|
|
3
|
-
import { LiteralUnion } from
|
|
4
|
-
import { S as Styles } from "../packem_shared/styles.d-CKGQFfm4.js";
|
|
5
|
-
import 'yoga-layout';
|
|
3
|
+
import { L as LiteralUnion, S as Styles } from "../packem_shared/styles.d-BCZOPl_g.js";
|
|
6
4
|
type Props = {
|
|
7
5
|
/**
|
|
8
6
|
* Hide the element from screen readers.
|
package/dist/components/text.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as z}from"react/jsx-runtime";import f from"@visulima/colorize";import{useContext as g,useCallback as B}from"react";import{c as C}from"../packem_shared/colorize-Dsbi0Wr0.js";import{a as D}from"../packem_shared/accessibility-context-DDyHTwmA.js";import{b as S}from"../packem_shared/background-context-rjOaWFki.js";function R({"aria-hidden":w=!1,"aria-label":o,backgroundColor:a,bold:s=!1,children:i,color:e,dimColor:n=!1,inverse:u=!1,italic:m=!1,strikethrough:x=!1,underline:l=!1,wrap:v="wrap"}){const{isScreenReaderEnabled:r}=g(D),p=g(S),k=r&&o?o:i,y=B(t=>{n&&(t=f.dim(t)),e&&(t=C(t,e,"foreground"));const b=a??p;return b&&(t=C(t,b,"background")),s&&(t=f.bold(t)),m&&(t=f.italic(t)),l&&(t=f.underline(t)),x&&(t=f.strikethrough(t)),u&&(t=f.inverse(t)),t},[n,e,a,p,s,m,l,x,u]);return k==null||r&&w?null:z("ink-text",{internal_transform:y,style:{flexDirection:"row",flexGrow:0,flexShrink:1,textWrap:v},children:r&&o?o:i})}export{R as Text,R as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useContext as f}from"react";import{a as i}from"../packem_shared/accessibility-context-DDyHTwmA.js";const s={flexDirection:"row",flexGrow:0,flexShrink:1};function x({accessibilityLabel:t,children:r,transform:n}){const{isScreenReaderEnabled:o}=f(i);return r==null?null:e("ink-text",{internal_transform:n,style:s,children:o&&t?t:r})}export{x as Transform,x as default};
|
package/dist/core/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{TuiApp as o}from"../packem_shared/TuiApp-
|
|
1
|
+
import{TuiApp as o}from"../packem_shared/TuiApp-D1How6sn.js";import{Cell as t,StyleMasks as m}from"../packem_shared/Cell-CbDQUAjW.js";import{createInlineLoop as l}from"../packem_shared/createInlineLoop-BPlBAXqd.js";import{InputParser as f}from"../packem_shared/InputParser-O4nyWUuQ.js";import{Renderer as x,TerminalGuard as s,terminalSize as u}from"../packem_shared/Renderer-Dg5_-6TF.js";export{t as Cell,f as InputParser,x as Renderer,m as StyleMasks,s as TerminalGuard,o as TuiApp,l as createInlineLoop,u as terminalSize};
|
|
@@ -21,4 +21,17 @@ type BrailleGrid = {
|
|
|
21
21
|
* allocated per chart render and thrown away.
|
|
22
22
|
*/
|
|
23
23
|
declare const createBrailleGrid: (cellWidth: number, cellHeight: number) => BrailleGrid;
|
|
24
|
-
export {
|
|
24
|
+
export {
|
|
25
|
+
/**
|
|
26
|
+
* Public canvas surface (`@visulima/tui/canvas`).
|
|
27
|
+
*
|
|
28
|
+
* Registry components are copied into consumer repos and therefore cannot
|
|
29
|
+
* reach into `src/ink/**` the way the in-tree components used to. Everything
|
|
30
|
+
* a copied component needs to paint a canvas is re-exported here, and this
|
|
31
|
+
* barrel is part of the package's public API contract: treat the signatures
|
|
32
|
+
* below as stable and version them accordingly.
|
|
33
|
+
*
|
|
34
|
+
* The `Canvas` React component itself lives at `@visulima/tui/components/canvas`
|
|
35
|
+
* — this entry is the imperative layer beneath it.
|
|
36
|
+
*/
|
|
37
|
+
type BrailleGrid, type CanvasContext, type CellStyle, createBrailleGrid };
|
package/dist/ink/canvas/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createBrailleGrid as a}from"../../packem_shared/createBrailleGrid-
|
|
1
|
+
import{createBrailleGrid as a}from"../../packem_shared/createBrailleGrid-B5uefhi4.js";import{createCanvasBuffer as f,serializeRow as i}from"../../packem_shared/createCanvasBuffer-C7w6bGe4.js";export{a as createBrailleGrid,f as createCanvasBuffer,i as serializeRow};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as K,useState as h,useRef as m,useCallback as z,useLayoutEffect as x}from"react";import{a as O}from"../../packem_shared/animation-context-Icwf5tBE.js";const A=100,k=2147483647,f={delta:0,frame:0,time:0};function N(o){const{interval:I=A,isActive:e=!0}=o??{},t=D(I),{renderThrottleMs:i,subscribe:l}=K(O),[n,S]=h(0),[T,d]=h(f),a=m(0),u=m(0),v=m({isActive:e,resetKey:n,safeInterval:t}),c=v.current,y=e&&(t!==c.safeInterval||!c.isActive||n!==c.resetKey),b=z(()=>{S(r=>r+1)},[]);return x(()=>{if(!e)return;d(f);let r=0;const{startTime:p,unsubscribe:M}=l(s=>{if(i>0&&s<a.current)return;const R=s-r,C=s-u.current;u.current=s,a.current=s+i,d({delta:C,frame:Math.floor(R/t),time:R})},t);return r=p,u.current=p,a.current=r+i,M},[t,e,l,i,n]),x(()=>{v.current={isActive:e,resetKey:n,safeInterval:t}},[e,t,n]),y?{...f,reset:b}:{...T,reset:b}}function D(o){return Number.isFinite(o)?Math.min(k,Math.max(1,o)):A}export{N as default,N as useAnimation};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { P as Props } from "../../packem_shared/app-context.d-
|
|
2
|
-
import 'react';
|
|
1
|
+
import { P as Props } from "../../packem_shared/app-context.d-DAF6oxKX.js";
|
|
3
2
|
/**
|
|
4
3
|
* A React hook that returns app lifecycle methods like `exit()` and `waitUntilRenderFlush()`.
|
|
5
4
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as t}from"react";import{A as o}from"../../packem_shared/app-context-CfgsW0CV.js";const r=()=>t(o);export{r as default,r as useApp};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
|
-
import { D as DOMElement } from "../../packem_shared/dom.d-
|
|
2
|
+
import { D as DOMElement } from "../../packem_shared/dom.d-BV2bnRcH.js";
|
|
3
3
|
import 'yoga-layout';
|
|
4
4
|
import "../public/cursor.js";
|
|
5
|
+
import "../../packem_shared/styles.d-BCZOPl_g.js";
|
|
5
6
|
import '@visulima/colorize';
|
|
6
|
-
import "../../packem_shared/styles.d-CKGQFfm4.js";
|
|
7
|
-
import 'type-fest';
|
|
8
7
|
/**
|
|
9
8
|
* Metrics of a box element.
|
|
10
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as s,useCallback as f,useEffect as u,useMemo as l}from"react";import{a as m}from"../../packem_shared/dom-xpeZzKuf.js";const d={height:0,left:0,top:0,width:0},c=t=>{if(t)return t.parentNode?c(t.parentNode):t.nodeName==="ink-root"?t:void 0},y=t=>{const[r,h]=s(d),[a,i]=s(!1),n=f(()=>{const e=t.current?.yogaNode?.getComputedLayout()??d;h(o=>o.width!==e.width||o.height!==e.height||o.left!==e.left||o.top!==e.top?e:o),i(!!t.current)},[t]);return u(n),u(()=>{const e=c(t.current);if(e)return m(e,n)}),l(()=>({...r,hasMeasured:a}),[r,a])};export{y as default,y as useBoxMetrics};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as e,useCallback as
|
|
1
|
+
import{useMemo as e,useCallback as p}from"react";import{isOsc52Supported as i,writeOsc52 as n}from"../../packem_shared/clearOsc52-olbKg5Nw.js";import m from"./use-stdout.js";const l=(u={})=>{const{target:r="c"}=u,{stdout:o}=m(),t=e(()=>i(),[]),s=p(c=>{!t||!o||n(o,c,r)},[t,o,r]);return e(()=>({copy:s,isSupported:t}),[s,t])};export{l as default,l as useClipboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as a,useCallback as
|
|
1
|
+
import{useMemo as a,useCallback as u}from"react";import{IDENTITY_MATRIX as i,COLOR_BLINDNESS_COMPENSATION as c,COLOR_BLINDNESS_SIMULATION as f,transformHexColor as l}from"../../packem_shared/COLOR_BLINDNESS_COMPENSATION-CaI93Rjj.js";const C=(m={})=>{const{compensate:e=!1,mode:r="none"}=m,o=a(()=>r==="none"?i:e&&r!=="achromatopsia"?c[r]:f[r],[r,e]),n=r!=="none",t=u(s=>n?l(s,o):s,[n,o]);return a(()=>({isActive:n,matrix:o,transformColor:t}),[n,o,t])};export{C as default,C as useColorBlindness};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as L,useRef as b,useMemo as p,useEffect as h,useCallback as v}from"react";const i=["log","info","warn","error","debug"],x=(y={})=>{const{filter:r=i,isActive:c=!0,maxEntries:o=200}=y,[l,f]=L([]),g=b(0),S=Array.isArray(r)?r.toSorted().join(","):"",u=p(()=>r,[S]);h(()=>{if(!c)return;const n={},d=new Set(u);for(const e of i)d.has(e)&&(n[e]=console[e],console[e]=(...m)=>{n[e]?.apply(console,m);const E=m.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");f(t=>{const A={id:++g.current,level:e,message:E,timestamp:Date.now()},s=[...t,A];return s.length>o?s.slice(-o):s})});return()=>{for(const e of i)n[e]&&(console[e]=n[e])}},[c,o,u]);const a=v(()=>{f([])},[]);return p(()=>({clear:a,entries:l}),[a,l])};export{x as default,x as useConsoleCapture};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as e,useRef as
|
|
1
|
+
import{useContext as e,useRef as n,useCallback as u,useInsertionEffect as i}from"react";import{C as c}from"../../packem_shared/cursor-context-wLwblh2o.js";const a=()=>{const o=e(c),t=n(void 0),r=u(s=>{t.current=s},[]);return i(()=>(o.setCursorPosition(t.current),()=>{o.setCursorPosition(void 0)})),{setCursorPosition:r}};export{a as default,a as useCursor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as s}from"react";import{
|
|
1
|
+
import{useContext as s}from"react";import{F as e}from"../../packem_shared/focus-context-8h3hmNxy.js";const t=()=>{const o=s(e);return{activeId:o.activeId,disableFocus:o.disableFocus,enableFocus:o.enableFocus,focus:o.focus,focusNext:o.focusNext,focusPrevious:o.focusPrevious}};export{t as default,t as useFocusManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as
|
|
1
|
+
import{useContext as l,useMemo as p,useEffect as o}from"react";import{F as M}from"../../packem_shared/focus-context-8h3hmNxy.js";import x from"./use-stdin.js";const C=({autoFocus:r=!1,id:s,isActive:t=!0}={})=>{const{isRawModeSupported:n,setRawMode:a}=x(),{activate:u,activeId:d,add:f,deactivate:i,focus:c,remove:m}=l(M),e=p(()=>s??Math.random().toString().slice(2,7),[s]);return o(()=>(f(e,{autoFocus:r}),()=>{m(e)}),[e,r]),o(()=>{t?u(e):i(e)},[t,e]),o(()=>{if(!(!n||!t))return a(!0),()=>{a(!1)}},[t]),{focus:c,isFocused:!!e&&d===e}};export{C as default,C as useFocus};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useMemo as
|
|
1
|
+
import{useMemo as E,useState as l,useRef as F,useCallback as u}from"react";const I=i=>{const s={};for(const c of Object.keys(i))s[c]=i[c].initialValue;return s},p=i=>{const{fields:s,onSubmit:c}=i,f=E(()=>I(s),[s]),[d,m]=l(f),[h,b]=l({}),[k,y]=l({}),[x,v]=l(!1),n=F(d);n.current=d;const a=u((t,r,e=n.current)=>s[t]?.validate?.(r,e),[s]),S=u((t,r)=>{const e={...n.current,[t]:r};n.current=e,m(e);const o=a(t,r,e);b(V=>{if(o===void 0){const g={...V};return delete g[t],g}return{...V,[t]:o}})},[a]),j=u((t,r=!0)=>{y(e=>({...e,[t]:r}))},[]),O=u(()=>{m(f),b({}),y({})},[f]),T=u(async()=>{const t={},r={};for(const e of Object.keys(s)){r[e]=!0;const o=a(e,n.current[e]);o!==void 0&&(t[e]=o)}if(b(t),y(r),Object.keys(t).length>0)return!1;try{return v(!0),await c?.(n.current),!0}finally{v(!1)}},[s,a,c]);return{errors:h,isSubmitting:x,reset:O,setTouched:j,setValue:S,submit:T,touched:k,values:d}};export{p as default,p as useForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{useCallback as o}from"react";import c from"./use-input.js";const f=new Set(["backspace","delete","downArrow","end","escape","home","leftArrow","pageDown","pageUp","return","rightArrow","tab","upArrow"]),i=t=>{const r=t.split("+").map(a=>a.trim()).filter(a=>a.length>0),e={};for(const a of r){const n=a.toLowerCase();switch(n){case"alt":case"cmd":case"meta":{e.meta=!0;break}case"control":case"ctrl":{e.ctrl=!0;break}case"shift":{e.shift=!0;break}default:if(f.has(n))e.name=n;else switch(n){case"down":{e.name="downArrow";break}case"enter":{e.name="return";break}case"esc":{e.name="escape";break}case"left":{e.name="leftArrow";break}case"right":{e.name="rightArrow";break}case"up":{e.name="upArrow";break}default:e.input=a}}}return e},l=(t,r,e)=>t.ctrl!==void 0&&t.ctrl!==e.ctrl||t.shift!==void 0&&t.shift!==e.shift||t.meta!==void 0&&t.meta!==e.meta?!1:t.name!==void 0?!!e[t.name]:t.input!==void 0?r===t.input:!1,w=(t,r,e)=>{const a=typeof t=="string"?i(t):t;c(o((n,s)=>{l(a,n,s)&&r()},[t,r]),{isActive:e?.isActive??!0})};export{w as default,w as useHotkey};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`:{t.name="enter";break}case" ":{t.name="tab";break}case" ":case"\x1B ":{t.name="space",t.meta=e.length===2;break}case"\b":case"\x1B\b":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{t.name="escape",t.meta=e.length===2;break}case"\x1B":case"":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")t.name=String.fromCharCode(e.charCodeAt(0)+97-1),t.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")t.name="number";else if(e.length===1&&e>="a"&&e<="z")t.name=e;else if(e.length===1&&e>="A"&&e<="Z")t.name=e.toLowerCase(),t.shift=!0;else if(
|
|
1
|
+
import{createRequire as C}from"node:module";import{useRef as L,useEffectEvent as _,useEffect as y,useLayoutEffect as P}from"react";import{IMECompositionBuffer as R,isIMEInput as E}from"../../packem_shared/IMECompositionBuffer-uYiAz3jI.js";import{kittyModifiers as p}from"../../packem_shared/kittyFlags-jpd_IAFL.js";import{r as b}from"../../packem_shared/reconciler-BPm7fZa6.js";import{useStdinContext as q}from"./use-stdin.js";let K;const S=e=>(K??=C(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[n,a]=m.versions.node.split(".").map(Number);if(n>22||n===22&&a>=3||n===20&&a>=16)return m.getBuiltinModule(e)}return S(e)},{Buffer:I}=$("node:buffer"),N=/^\u001B([a-z0-9])$/i,T=/^\u001B+([ON[]|\[\[)(?:(\d+)(?:;(\d+))?([~^$])|(?:1;)?(\d+)?([a-zA-Z]))/,v={"[1~":"home","[2$":"insert","[2^":"insert","[2~":"insert","[3$":"delete","[3^":"delete","[3~":"delete","[4~":"end","[5$":"pageup","[5^":"pageup","[5~":"pageup","[6$":"pagedown","[6^":"pagedown","[6~":"pagedown","[7$":"home","[7^":"home","[7~":"home","[8$":"end","[8^":"end","[8~":"end","[11~":"f1","[12~":"f2","[13~":"f3","[14~":"f4","[15~":"f5","[17~":"f6","[18~":"f7","[19~":"f8","[20~":"f9","[21~":"f10","[23~":"f11","[24~":"f12","[[5~":"pageup","[[6~":"pagedown","[[A":"f1","[[B":"f2","[[C":"f3","[[D":"f4","[[E":"f5","[A":"up","[a":"up","[B":"down","[b":"down","[C":"right","[c":"right","[D":"left","[d":"left","[E":"clear","[e":"clear","[F":"end","[H":"home","[P":"f1","[Q":"f2","[R":"f3","[S":"f4","[Z":"tab",OA:"up",Oa:"up",OB:"down",Ob:"down",OC:"right",Oc:"right",OD:"left",Od:"left",OE:"clear",Oe:"clear",OF:"end",OH:"home",OP:"f1",OQ:"f2",OR:"f3",OS:"f4"},j=[...Object.values(v),"backspace"],M=e=>["[2$","[3$","[5$","[6$","[7$","[8$","[a","[b","[c","[d","[e","[Z"].includes(e),D=e=>["[2^","[3^","[5^","[6^","[7^","[8^","Oa","Ob","Oc","Od","Oe"].includes(e),B=/^\u001B\[(\d+)(?:;(\d+)(?::(\d+))?(?:;([\d:]+))?)?u$/,Z=/^\u001B\[(\d+);(\d+):(\d+)([A-Z~])$/i,F={A:"up",B:"down",C:"right",D:"left",E:"clear",F:"end",H:"home",P:"f1",Q:"f2",R:"f3",S:"f4"},H={2:"insert",3:"delete",5:"pageup",6:"pagedown",7:"home",8:"end",11:"f1",12:"f2",13:"f3",14:"f4",15:"f5",17:"f6",18:"f7",19:"f8",20:"f9",21:"f10",23:"f11",24:"f12"},w={8:"backspace",9:"tab",27:"escape",127:"backspace",57358:"capslock",57359:"scrolllock",57360:"numlock",57361:"printscreen",57362:"pause",57363:"menu",57376:"f13",57377:"f14",57378:"f15",57379:"f16",57380:"f17",57381:"f18",57382:"f19",57383:"f20",57384:"f21",57385:"f22",57386:"f23",57387:"f24",57388:"f25",57389:"f26",57390:"f27",57391:"f28",57392:"f29",57393:"f30",57394:"f31",57395:"f32",57396:"f33",57397:"f34",57398:"f35",57399:"kp0",57400:"kp1",57401:"kp2",57402:"kp3",57403:"kp4",57404:"kp5",57405:"kp6",57406:"kp7",57407:"kp8",57408:"kp9",57409:"kpdecimal",57410:"kpdivide",57411:"kpmultiply",57412:"kpsubtract",57413:"kpadd",57414:"kpenter",57415:"kpequal",57416:"kpseparator",57417:"kpleft",57418:"kpright",57419:"kpup",57420:"kpdown",57421:"kppageup",57422:"kppagedown",57423:"kphome",57424:"kpend",57425:"kpinsert",57426:"kpdelete",57427:"kpbegin",57428:"mediaplay",57429:"mediapause",57430:"mediaplaypause",57431:"mediareverse",57432:"mediastop",57433:"mediafastforward",57434:"mediarewind",57435:"mediatracknext",57436:"mediatrackprevious",57437:"mediarecord",57438:"lowervolume",57439:"raisevolume",57440:"mutevolume",57441:"leftshift",57442:"leftcontrol",57443:"leftalt",57444:"leftsuper",57445:"lefthyper",57446:"leftmeta",57447:"rightshift",57448:"rightcontrol",57449:"rightalt",57450:"rightsuper",57451:"righthyper",57452:"rightmeta",57453:"isoLevel3Shift",57454:"isoLevel5Shift"},x=e=>e>=0&&e<=1114111&&!(e>=55296&&e<=57343),g=e=>x(e)?String.fromCodePoint(e):"?";function A(e){return e===3?"release":e===2?"repeat":"press"}function O(e){return{capsLock:!!(e&p.capsLock),ctrl:!!(e&p.ctrl),hyper:!!(e&p.hyper),meta:!!(e&p.meta),numLock:!!(e&p.numLock),option:!!(e&p.alt),shift:!!(e&p.shift),super:!!(e&p.super)}}const U=e=>{const n=B.exec(e);if(!n)return null;const a=Number.parseInt(n[1],10),l=n[2]?Math.max(0,Number.parseInt(n[2],10)-1):0,t=n[3]?Number.parseInt(n[3],10):1,c=n[4];if(!x(a))return null;let s;c&&(s=c.split(":").map(d=>g(Number.parseInt(d,10))).join(""));let f,o;return a===32?(f="space",o=!0):a===13?(f="return",o=!0):w[a]?(f=w[a],o=!1):a>=1&&a<=26?(f=String.fromCodePoint(a+96),o=!1):(f=g(a).toLowerCase(),o=!0),o&&!s&&(s=g(a)),{name:f,...O(l),eventType:A(t),isKittyProtocol:!0,isPrintable:o,raw:e,sequence:e,text:s}},z=e=>{const n=Z.exec(e);if(!n)return null;const a=Number.parseInt(n[1],10),l=Math.max(0,Number.parseInt(n[2],10)-1),t=Number.parseInt(n[3],10),c=n[4],s=c==="~"?H[a]:F[c];return s?{name:s,...O(l),eventType:A(t),isKittyProtocol:!0,isPrintable:!1,raw:e,sequence:e}:null},Q=(e="")=>{let n;I.isBuffer(e)?e[0]>127&&e[1]===void 0?(e[0]-=128,e=`\x1B${String(e)}`):e=String(e):e!==void 0&&typeof e!="string"?e=String(e):e||(e="");const a=U(e);if(a)return a;const l=z(e);if(l)return l;if(B.test(e))return{ctrl:!1,isKittyProtocol:!0,isPrintable:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};const t={ctrl:!1,meta:!1,name:"",option:!1,raw:e,sequence:e,shift:!1};switch(t.sequence=t.sequence||e||t.name,e){case"\r":case"\x1B\r":{t.raw=void 0,t.name="return",t.option=e.length===2;break}case`
|
|
2
|
+
`:{t.name="enter";break}case" ":{t.name="tab";break}case" ":case"\x1B ":{t.name="space",t.meta=e.length===2;break}case"\b":case"\x1B\b":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}case"\x1B":case"\x1B\x1B":{t.name="escape",t.meta=e.length===2;break}case"\x1B":case"":{t.name="backspace",t.meta=e.charAt(0)==="\x1B";break}default:if(e.length===1&&e<="")t.name=String.fromCharCode(e.charCodeAt(0)+97-1),t.ctrl=!0;else if(e.length===1&&e>="0"&&e<="9")t.name="number";else if(e.length===1&&e>="a"&&e<="z")t.name=e;else if(e.length===1&&e>="A"&&e<="Z")t.name=e.toLowerCase(),t.shift=!0;else if(n=N.exec(e))t.meta=!0,t.shift=/^[A-Z]$/.test(n[1]);else if(n=T.exec(e)){const c=[...e];c[0]==="\x1B"&&c[1]==="\x1B"&&(t.option=!0);const s=[n[1],n[2],n[4],n[6]].filter(Boolean).join(""),f=(n[3]||n[5]||1)-1;t.ctrl=!!(f&4),t.meta=!!(f&10),t.shift=!!(f&1),t.code=s,t.name=v[s]??"",t.shift=M(s)||t.shift,t.ctrl=D(s)||t.ctrl}}return t},ee=(e,n={})=>{const{internal_eventEmitter:a,internal_exitOnCtrlC:l,setRawMode:t,stdin:c}=q(),s=n.imeEnabled??!0,f=n.imeTimeout??50,o=L(void 0),d=_(e);y(()=>{if(s)return o.current=new R({onFlush:h=>{const u={backspace:!1,capsLock:!1,ctrl:!1,delete:!1,downArrow:!1,end:!1,escape:!1,home:!1,hyper:!1,leftArrow:!1,meta:!1,numLock:!1,pageDown:!1,pageUp:!1,return:!1,rightArrow:!1,shift:!1,super:!1,tab:!1,upArrow:!1};b.discreteUpdates(()=>{d(h,u)})},timeout:f}),()=>{o.current?.destroy(),o.current=void 0}},[s,f]),y(()=>{if(n.isActive!==!1)return t(!0),()=>{t(!1)}},[n.isActive,t]),P(()=>{if(n.isActive===!1)return;const h=u=>{if(s&&E(u)){o.current?.add(u);return}o.current?.flush();const r=Q(u),k={backspace:r.name==="backspace",capsLock:r.capsLock??!1,ctrl:r.ctrl,delete:r.name==="delete",downArrow:r.name==="down",end:r.name==="end",escape:r.name==="escape",eventType:r.eventType,home:r.name==="home",hyper:r.hyper??!1,leftArrow:r.name==="left",meta:r.meta||r.option,numLock:r.numLock??!1,pageDown:r.name==="pagedown",pageUp:r.name==="pageup",return:r.name==="return",rightArrow:r.name==="right",shift:r.shift,super:r.super??!1,tab:r.name==="tab",upArrow:r.name==="up"};let i;r.isKittyProtocol?r.isPrintable?i=r.text??r.name:r.ctrl&&r.name.length===1?i=r.name:i="":r.ctrl?i=r.name:i=r.sequence,!r.isKittyProtocol&&j.includes(r.name)&&(i=""),i.startsWith("\x1B")&&(i=i.slice(1)),i.length===1&&typeof i[0]=="string"&&/[A-Z]/.test(i[0])&&(k.shift=!0),!(i==="c"&&k.ctrl&&l)&&(!r.name&&i===""||b.discreteUpdates(()=>{d(i,k)}))};return a.on("input",h),()=>{a.removeListener("input",h)}},[n.isActive,c,l,s])};export{ee as default,ee as useInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as
|
|
1
|
+
import{useRef as o,useLayoutEffect as i,useEffect as f,useCallback as a}from"react";const l=(t,r,s)=>{const{isActive:c=!0}=s??{},u=o(t),e=o(void 0);return i(()=>{u.current=t},[t]),f(()=>{if(!c||r<=0||!Number.isFinite(r))return;const n=setInterval(()=>{u.current()},r);return e.current=n,()=>{clearInterval(n),e.current=void 0}},[r,c]),{clear:a(()=>{e.current!==void 0&&(clearInterval(e.current),e.current=void 0)},[])}};export{l as default,l as useInterval};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as
|
|
1
|
+
import{useRef as d,useCallback as m,useMemo as b}from"react";import g from"./use-input.js";const f=new Set(["backspace","delete","downArrow","end","escape","home","leftArrow","pageDown","pageUp","return","rightArrow","tab","upArrow"]),p=new Set(["ctrl","hyper","meta","shift","super"]);function w(e,i,t){const r=e.indexOf("+");if(r!==-1){const o=e.slice(0,r),n=e.slice(r+1);return!p.has(o)||!t[o]?!1:f.has(n)?t[n]===!0:i===n}return f.has(e)?t[e]===!0:i===e}function k(e,i){const{isActive:t=!0}=i??{},r=d(e);return r.current=e,g(m((n,u)=>{for(const{binding:s,handler:a}of r.current){if(s.enabled===!1)continue;const c=typeof s.key=="string"?[s.key]:s.key;for(const l of c)if(w(l,n,u)){a();return}}},[]),{isActive:t}),{bindings:b(()=>e.filter(n=>n.binding.enabled!==!1).map(n=>n.binding),[e])}}export{k as default,k as useKeyBindings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as a,useCallback as
|
|
1
|
+
import{useRef as a,useCallback as m}from"react";import g from"./use-input.js";const w=(t,r)=>{if(r.escape)return"escape";if(r.return)return"return";if(r.tab)return"tab";if(r.backspace)return"backspace";if(r.delete)return"delete";if(r.home)return"home";if(r.end)return"end";if(r.pageUp)return"pageup";if(r.pageDown)return"pagedown";if(r.upArrow)return"up";if(r.downArrow)return"down";if(r.leftArrow)return"left";if(r.rightArrow)return"right";if(t===" ")return"space";if(!(!t||t.length===0))return t},v=(t,r)=>{const u=w(t,r);if(u===void 0)return;const n=[];return r.ctrl&&n.push("ctrl"),r.meta&&n.push("meta"),r.shift&&n.push("shift"),n.push(u),n.join("+")},o=t=>t.trim().toLowerCase(),R=(t,r,u)=>{const{isActive:n=!0,resetAfter:i=1e3}=u??{},e=a(0),f=a(0),p=a(r);p.current=r,g(m((l,h)=>{const c=Date.now();i>0&&e.current>0&&c-f.current>i&&(e.current=0);const s=v(l,h);if(s===void 0||t.length===0)return;const d=t[e.current];if(d===void 0){e.current=0;return}if(o(s)===o(d)){e.current+=1,f.current=c,e.current>=t.length&&(e.current=0,p.current());return}e.current=0,o(s)===o(t[0]??"")&&(e.current=1,f.current=c)},[t,i]),{isActive:n})};export{R as default,R as useKeyChord};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffectEvent as
|
|
1
|
+
import{useEffectEvent as o,useEffect as n}from"react";import{r as u}from"../../packem_shared/reconciler-BPm7fZa6.js";import{useStdinContext as l}from"./use-stdin.js";const p=(i,e={})=>{const{internal_eventEmitter:t,setBracketedPasteMode:r,setRawMode:s}=l(),c=o(i);n(()=>{if(e.isActive!==!1)return s(!0),r(!0),()=>{s(!1),r(!1)}},[e.isActive,s,r]),n(()=>{if(e.isActive===!1)return;const a=f=>{u.discreteUpdates(()=>{c(f)})};return t.on("paste",a),()=>{t.removeListener("paste",a)}},[e.isActive,t])};export{p as default,p as usePaste};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`)},c=()=>{if(s!==void 0)return s;try{const t=
|
|
1
|
+
import{createRequire as S}from"node:module";import{useRef as m,useState as N,useEffect as R,useCallback as O}from"react";let h;const _=e=>(h??=S(import.meta.url))(e),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:f,l=e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[r,s]=a.versions.node.split(".").map(Number);if(r>22||r===22&&s>=3||r===20&&s>=16)return a.getBuiltinModule(e)}return _(e)},{mkdirSync:y,writeFileSync:v,renameSync:w,readFileSync:j}=l("node:fs"),{homedir:E}=l("node:os"),p=l("node:path"),f=a,q=()=>{const e=new Map;return{read:r=>e.get(r),write:(r,s)=>{e.set(r,s)}}},P=/[/\\]/,T=e=>{if(e===""||e==="."||e===".."||P.test(e)||e.includes("\0"))throw new Error(`[visulima/tui] usePersistentState: invalid namespace ${JSON.stringify(e)} — must not be empty or contain path separators.`)},b=e=>{T(e);const r=p.join(E(),".cache","visulima-tui",`${e}.json`);let s;const o=(t,n)=>{const i=n instanceof Error?n.message:String(n);f.stderr.write(`[visulima/tui] persistent-state ${t} failed: ${i}
|
|
2
|
+
`)},c=()=>{if(s!==void 0)return s;try{const t=j(r,"utf8"),n=JSON.parse(t);s=n&&typeof n=="object"?n:{}}catch(t){const n=t?.code;n!=="ENOENT"&&n!=="EACCES"&&o("read",t),s={}}return s};return{read:t=>c()[t],write:(t,n)=>{const i=p.dirname(r),u=`${r}.tmp.${f.pid}`,d=c();d[t]=n;try{y(i,{recursive:!0}),v(u,JSON.stringify(d,null,2),{encoding:"utf8",flag:"w"}),w(u,r)}catch(g){o("write",g)}}}},$=(e,r,s)=>{const o=e.read(r);if(o===void 0)return s;try{return JSON.parse(o)}catch{return s}},M=(e,r,s)=>{const o=m(void 0);o.current??=s?.storage??b(s?.namespace??"tui");const c=o.current,[t,n]=N(()=>$(c,e,r)),i=m(void 0);i.current??={key:e,value:t},R(()=>{if(!(i.current?.key===e&&Object.is(i.current.value,t)))try{c.write(e,JSON.stringify(t)),i.current={key:e,value:t}}catch{}},[e,t,c]);const u=O(d=>{n(d)},[]);return[t,u]};export{b as createFileStorage,q as createMemoryStorage,M as default,M as usePersistentState};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as h,useRef as e,useEffect as y,useCallback as C,useMemo as _}from"react";const g=100,p=16,w=.5,E=(k={})=>{const{acceleration:R=1.5,decayRate:M=.92,isActive:r=!0,maxVelocity:S=20,onScroll:d}=k,[I,l]=h(0),[n,m]=h(!1),t=e(0),v=e(0),i=e(!1),f=e(void 0),c=e(d);c.current=d,y(()=>{if(!r||!n)return;const s=()=>{if(i.current){i.current=!1;return}const o=t.current;if(Math.abs(o)<w){t.current=0,l(0),m(!1);return}t.current*=M;const u=Math.round(t.current);u!==0&&c.current?.(u),l(t.current)};return f.current=setInterval(s,p),()=>{f.current&&clearInterval(f.current)}},[r,n,M]);const T=C(s=>{if(!r){c.current?.(s==="down"?1:-1);return}const o=Date.now(),u=o-v.current,a=s==="down"?1:-1;v.current=o,u<g&&Math.sign(t.current)===a?t.current=Math.min(Math.abs(t.current*R),S)*a:t.current=a,l(t.current),m(!0),i.current=!0,c.current?.(a)},[r,R,S]);return _(()=>({handleScroll:T,isCoasting:n,velocity:I}),[T,n,I])};export{E as default,E as useScrollAcceleration};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"./use-focus.js";import a from"./use-input.js";const
|
|
1
|
+
import c from"./use-focus.js";import a from"./use-input.js";const m=l=>{const{getViewportHeight:f,isActive:i=!0,scrollBy:o,scrollToBottom:e,scrollToTop:u,vimBindings:s=!1}=l,{isFocused:n}=c({isActive:i});return a((t,r)=>{if(r.upArrow){o(-1);return}if(r.downArrow){o(1);return}if(r.pageUp){o(-f());return}if(r.pageDown){o(f());return}if(r.home){u();return}if(r.end){e();return}if(r.ctrl&&t==="u"){o(-Math.floor(f()/2));return}if(r.ctrl&&t==="d"){o(Math.floor(f()/2));return}if(s){if(t==="k"){o(-1);return}if(t==="j"){o(1);return}if(t==="G"&&r.shift){e();return}if(t==="g"&&!r.shift){u();return}if(t==="u"&&!r.ctrl){o(-Math.floor(f()/2));return}t==="d"&&!r.ctrl&&o(Math.floor(f()/2))}},{isActive:i}),{isFocused:n}};export{m as default,m as useScrollInput};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t}from"react";import{
|
|
1
|
+
import{useContext as t}from"react";import{S as r}from"../../packem_shared/stderr-context-Xeacf3Ir.js";const s=()=>t(r);export{s as default,s as useStderr};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import 'react';
|
|
3
2
|
type PublicProps = {
|
|
4
3
|
/**
|
|
5
4
|
* A boolean flag determining if the current `stdin` supports `setRawMode`. A component using `setRawMode` might want to use `isRawModeSupported` to nicely fall back in environments where raw mode is not supported.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t}from"react";import{
|
|
1
|
+
import{useContext as t}from"react";import{S as o}from"../../packem_shared/stdin-context-Ceh-YuU1.js";const s=()=>t(o),i=()=>t(o);export{s as default,s as useStdin,i as useStdinContext};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useContext as t}from"react";import{
|
|
1
|
+
import{useContext as t}from"react";import{S as o}from"../../packem_shared/stdout-context-BhxOwdNK.js";const s=()=>t(o);export{s as default,s as useStdout};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as u,useCallback as t,useRef as
|
|
1
|
+
import{useState as u,useCallback as t,useRef as v}from"react";import b from"./use-animation.js";function w(i){const{autoStart:l=!1,interval:p=1e3}=i??{},[o,e]=u(l),[f,r]=u([]),{reset:a,time:n}=b({interval:p,isActive:o}),m=t(()=>{e(!0)},[]),g=t(()=>{e(!1)},[]),R=t(()=>{e(s=>!s)},[]),d=t(()=>{e(!1),r([]),a()},[a]),c=v(n);c.current=n;const A=t(()=>{const{current:s}=c;return r(S=>[...S,s]),s},[]);return{elapsed:n,isRunning:o,lap:A,laps:f,reset:d,start:m,stop:g,toggle:R}}export{w as default,w as useStopwatch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as a,useMemo as f,useEffect as c}from"react";import{isTerminalPaletteQuerySupported as m,queryTerminalPalette as d}from"../../packem_shared/isTerminalPaletteQuerySupported-DwJPJ8_h.js";import{useStdinContext as p}from"./use-stdin.js";import y from"./use-stdout.js";const x=()=>{const{stdin:t}=p(),{stdout:e}=y(),[n,i]=a(null),[l,o]=a(!0),s=f(()=>m(),[]);return c(()=>{if(!s||!t||!e){o(!1);return}let r=!1;return(async()=>{try{const u=await d(t,e,200);r||i(u)}catch{}finally{r||o(!1)}})(),()=>{r=!0}},[s,t,e]),{isLoading:l,isSupported:s,palette:n}};export{x as default,x as useTerminalPalette};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{useState as
|
|
2
|
-
`);return
|
|
3
|
-
`),
|
|
4
|
-
`)},[]),
|
|
1
|
+
import{useState as H,useRef as b,useCallback as u,useMemo as y}from"react";const J=300,Q=100,Y=/\S+\s*$/,E=s=>{const i=s.split(`
|
|
2
|
+
`);return i.length===0?[""]:i},Z=s=>s.join(`
|
|
3
|
+
`),f=s=>({anchor:s.anchor,cursor:{...s.cursor},lines:[...s.lines]}),T=(s,i,o)=>o?{...s,anchor:s.anchor??s.cursor,cursor:i}:{...s,anchor:null,cursor:i},z=(s,i)=>i.line<s.line||i.line===s.line&&i.col<s.col?{end:s,start:i}:{end:i,start:s},L=s=>{if(!s.anchor)return null;const{end:i,start:o}=z(s.cursor,s.anchor),a=[...s.lines],d=a[o.line].slice(0,o.col),g=a[i.line].slice(i.col);return a.splice(o.line,i.line-o.line+1,d+g),{anchor:null,cursor:o,lines:a}},C=(s,i)=>{const o=L(s)??s,a=[...o.lines],{col:d,line:g}=o.cursor,m=a[g].slice(0,d),S=a[g].slice(d),l=E(i);if(l.length===1)return a[g]=m+l[0]+S,{anchor:null,cursor:{col:d+l[0].length,line:g},lines:a};const w=m+l[0],k=l.at(-1)+S,v=l.slice(1,-1);return a.splice(g,1,w,...v,k),{anchor:null,cursor:{col:l.at(-1).length,line:g+l.length-1},lines:a}},en=(s="")=>{const[i,o]=H(()=>{const n=E(s);return{anchor:null,cursor:{col:n.at(-1).length,line:n.length-1},lines:n}}),a=b([]),d=b([]),g=b(0),m=b(i.cursor.col);m.current=i.cursor.col;const S=b(i);S.current=i;const l=u(n=>{const e=Date.now();e-g.current<J&&a.current.length>0||(a.current.push(n),a.current.length>Q&&a.current.shift()),d.current=[],g.current=e},[]),w=u(()=>S.current.anchor!==null,[]),k=u(()=>{const n=S.current;if(!n.anchor)return"";const{end:e,start:r}=z(n.cursor,n.anchor);if(r.line===e.line)return n.lines[r.line].slice(r.col,e.col);const t=[];t.push(n.lines[r.line].slice(r.col));for(let c=r.line+1;c<e.line;c++)t.push(n.lines[c]);return t.push(n.lines[e.line].slice(0,e.col)),t.join(`
|
|
4
|
+
`)},[]),v=u(n=>{o(e=>(l(f(e)),C(e,n)))},[l]),M=u(()=>{o(n=>{l(f(n));const e=L(n)??n,r=[...e.lines],{col:t,line:c}=e.cursor,h=r[c].slice(0,t),p=r[c].slice(t);return r.splice(c,1,h,p),{anchor:null,cursor:{col:0,line:c+1},lines:r}})},[l]),_=u(()=>{o(n=>{if(n.anchor)return l(f(n)),L(n)??n;const{col:e,line:r}=n.cursor;if(e===0&&r===0)return n;l(f(n));const t=[...n.lines];if(e===0){const c=t[r-1],h=c.length;return t[r-1]=c+t[r],t.splice(r,1),{anchor:null,cursor:{col:h,line:r-1},lines:t}}return t[r]=t[r].slice(0,e-1)+t[r].slice(e),{anchor:null,cursor:{col:e-1,line:r},lines:t}})},[l]),A=u(()=>{o(n=>{if(n.anchor)return l(f(n)),L(n)??n;const{col:e,line:r}=n.cursor,t=n.lines[r];if(e===t.length&&r===n.lines.length-1)return n;l(f(n));const c=[...n.lines];return e===t.length?(c[r]=t+c[r+1],c.splice(r+1,1),{anchor:null,cursor:n.cursor,lines:c}):(c[r]=t.slice(0,e)+t.slice(e+1),{anchor:null,cursor:n.cursor,lines:c})})},[l]),O=u(()=>{o(n=>{l(f(n));const e=[...n.lines],{line:r}=n.cursor;if(e.length===1)return{anchor:null,cursor:{col:0,line:0},lines:[""]};e.splice(r,1);const t=Math.min(r,e.length-1);return{anchor:null,cursor:{col:Math.min(n.cursor.col,e[t].length),line:t},lines:e}})},[l]),R=u(()=>{o(n=>{l(f(n));const e=[...n.lines],{col:r,line:t}=n.cursor;return e[t]=e[t].slice(0,r),{...n,anchor:null,lines:e}})},[l]),x=u(()=>{o(n=>{l(f(n));const e=[...n.lines],{col:r,line:t}=n.cursor;return e[t]=e[t].slice(r),{anchor:null,cursor:{col:0,line:t},lines:e}})},[l]),D=u(()=>{o(n=>{if(l(f(n)),n.anchor)return L(n)??n;const{col:e,line:r}=n.cursor,c=n.lines[r].slice(0,e).replace(Y,""),h=[...n.lines];return h[r]=c+n.lines[r].slice(e),{anchor:null,cursor:{col:c.length,line:r},lines:h}})},[l]),j=u((n,e=!1)=>{o(r=>{const{col:t,line:c}=r.cursor;let h=c,p=t;switch(n){case"down":{c<r.lines.length-1&&(h=c+1,p=Math.min(m.current,r.lines[h].length));break}case"left":{t>0?p=t-1:c>0&&(h=c-1,p=r.lines[h].length);break}case"right":{const G=r.lines[c].length;t<G?p=t+1:c<r.lines.length-1&&(h=c+1,p=0);break}case"up":{c>0&&(h=c-1,p=Math.min(m.current,r.lines[h].length));break}}return T(r,{col:p,line:h},e)})},[]),N=u((n=!1)=>{o(e=>T(e,{col:0,line:e.cursor.line},n))},[]),U=u((n=!1)=>{o(e=>T(e,{col:e.lines[e.cursor.line].length,line:e.cursor.line},n))},[]),B=u((n=!1)=>{o(e=>T(e,{col:0,line:0},n))},[]),F=u((n=!1)=>{o(e=>{const r=e.lines.length-1;return T(e,{col:e.lines[r].length,line:r},n)})},[]),I=u(()=>{o(n=>{const e=n.lines.length-1;return{...n,anchor:{col:0,line:0},cursor:{col:n.lines[e].length,line:e}}})},[]),K=u(()=>{o(n=>n.anchor?{...n,anchor:null}:n)},[]),W=u(()=>{o(n=>n.anchor?(l(f(n)),L(n)??n):n)},[l]),P=u(n=>{o(e=>{if(!e.anchor)return l(f(e)),C(e,n);l(f(e));const r=L(e)??e;return C(r,n)})},[l]),V=u(n=>{const e=E(n);o({anchor:null,cursor:{col:e.at(-1).length,line:e.length-1},lines:e}),a.current=[],d.current=[]},[]),X=u(()=>{const n=a.current.pop();n&&(d.current.push(f(S.current)),o(n))},[]),$=u(()=>{const n=d.current.pop();n&&(a.current.push(f(S.current)),o(n))},[]),q=y(()=>Z(i.lines),[i.lines]);return y(()=>({anchor:i.anchor,clearSelection:K,cursor:i.cursor,deleteBack:_,deleteForward:A,deleteLine:O,deleteSelection:W,deleteToLineEnd:R,deleteToLineStart:x,deleteWord:D,getSelectedText:k,hasSelection:w,insert:v,lines:i.lines,moveCursor:j,moveToEnd:F,moveToLineEnd:U,moveToLineStart:N,moveToStart:B,newline:M,redo:$,replaceSelection:P,selectAll:I,setValue:V,undo:X,value:q}),[i.anchor,i.cursor,i.lines,q,K,_,A,O,W,R,x,D,k,w,v,j,F,U,N,B,M,$,P,I,V,X])};export{en as default,en as useTextBuffer};
|