@fluxlay/react 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -42
- package/dist/index.d.mts +674 -74
- package/dist/index.mjs +3 -4
- package/dist/mimo/index.d.mts +302 -0
- package/dist/mimo/index.mjs +2 -0
- package/dist/use-mouse-events-DSFSfRBX.mjs +7 -0
- package/package.json +7 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`);
|
|
3
|
-
`).length;e.resize(e.cols,Math.max(1,t))}else e.resize(e.cols,1)}else{let t=`Command failed with status ${m.statusCode}: ${m.stderr}`;e.write(`\x1b[31m${t.trimEnd()}\x1b[0m`),e.resize(e.cols,1)}},[l,m,o,s]),t(()=>{v()},[i]),t(()=>{if(!c)return;let e=setInterval(v,c);return()=>clearInterval(e)},[v,c]),{execute:v,isRunning:u,error:f,result:m}}const y=new o;function b(e){let[n,i]=r({cpuUsage:0,cpuPerCore:[],cpuFrequencyMhz:[],memoryTotal:0,memoryUsed:0,memoryUsage:0,swapTotal:0,swapUsed:0,swapUsage:0,batteryLevel:null,batteryCharging:null,networkRxBytesPerSec:0,networkTxBytesPerSec:0,diskReadBytesPerSec:0,diskWriteBytesPerSec:0,processCount:0,uptimeSecs:0,loadAverage:[0,0,0],disks:[],hostname:``,osName:``,cpuBrand:``,physicalCoreCount:0,logicalCoreCount:0,cpuArch:``,kernelVersion:``}),a=e?.cpuIntervalMs,o=e?.memoryIntervalMs,s=e?.networkIntervalMs,c=e?.diskIoIntervalMs,l=e?.diskSpaceIntervalMs,u=e?.batteryIntervalMs,d=e?.processIntervalMs,f=e?.loadAverageIntervalMs;return t(()=>{let e={};a!==void 0&&(e.cpu_interval_ms=String(a)),o!==void 0&&(e.memory_interval_ms=String(o)),s!==void 0&&(e.network_interval_ms=String(s)),c!==void 0&&(e.disk_io_interval_ms=String(c)),l!==void 0&&(e.disk_space_interval_ms=String(l)),u!==void 0&&(e.battery_interval_ms=String(u)),d!==void 0&&(e.process_interval_ms=String(d)),f!==void 0&&(e.load_average_interval_ms=String(f));let t=y.subscribe(`system-monitor-stream`,e=>i(e),e);return()=>{t()}},[a,o,s,c,l,u,d,f]),n}const x={dark:{default:{background:`#00000000`,foreground:`#ffffff`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#e2e8f0`,cursor:`#00000000`,black:`#1e293b`,red:`#f43f5e`,green:`#10b981`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#8b5cf6`,cyan:`#06b6d4`,white:`#f1f5f9`,brightBlack:`#475569`,brightRed:`#fb7185`,brightGreen:`#34d399`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#a78bfa`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`}},light:{default:{background:`#00000000`,foreground:`#18181b`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#334155`,cursor:`#00000000`,black:`#0f172a`,red:`#dc2626`,green:`#16a34a`,yellow:`#d97706`,blue:`#2563eb`,magenta:`#7c3aed`,cyan:`#0891b2`,white:`#f8fafc`,brightBlack:`#64748b`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#f59e0b`,brightBlue:`#3b82f6`,brightMagenta:`#8b5cf6`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},nord:{background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#4C566A`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},dracula:{background:`#282a36`,foreground:`#f8f8f2`,cursor:`#f8f8f2`,black:`#21222c`,red:`#ff5555`,green:`#50fa7b`,yellow:`#f1fa8c`,blue:`#bd93f9`,magenta:`#ff79c6`,cyan:`#8be9fd`,white:`#f8f8f2`,brightBlack:`#6272a4`,brightRed:`#ff6e6e`,brightGreen:`#69ff94`,brightYellow:`#ffffa5`,brightBlue:`#d6acff`,brightMagenta:`#ff92df`,brightCyan:`#a4ffff`,brightWhite:`#ffffff`},gruvbox:{dark:{background:`#282828`,foreground:`#ebdbb2`,cursor:`#ebdbb2`,black:`#282828`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#a89984`,brightBlack:`#928374`,brightRed:`#fb4934`,brightGreen:`#b8bb26`,brightYellow:`#fabd2f`,brightBlue:`#83a598`,brightMagenta:`#d3869b`,brightCyan:`#8ec07c`,brightWhite:`#ebdbb2`},light:{background:`#fbf1c7`,foreground:`#3c3836`,cursor:`#3c3836`,black:`#fbf1c7`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#7c6f64`,brightBlack:`#928374`,brightRed:`#9d0006`,brightGreen:`#79740e`,brightYellow:`#b57614`,brightBlue:`#076678`,brightMagenta:`#8f3f71`,brightCyan:`#427b58`,brightWhite:`#3c3836`}},solarized:{dark:{background:`#002b36`,foreground:`#839496`,cursor:`#93a1a1`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`},light:{background:`#fdf6e3`,foreground:`#657b83`,cursor:`#586e75`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`}},oneDark:{background:`#282c34`,foreground:`#abb2bf`,cursor:`#528bff`,black:`#282c34`,red:`#e06c75`,green:`#98c379`,yellow:`#e5c07b`,blue:`#61afef`,magenta:`#c678dd`,cyan:`#56b6c2`,white:`#abb2bf`,brightBlack:`#5c6370`,brightRed:`#e06c75`,brightGreen:`#98c379`,brightYellow:`#e5c07b`,brightBlue:`#61afef`,brightMagenta:`#c678dd`,brightCyan:`#56b6c2`,brightWhite:`#ffffff`},catppuccin:{latte:{background:`#eff1f5`,foreground:`#4c4f69`,cursor:`#dc8a78`,black:`#5c5f77`,red:`#d20f39`,green:`#40a02b`,yellow:`#df8e1d`,blue:`#1e66f5`,magenta:`#ea76cb`,cyan:`#179299`,white:`#acb0be`,brightBlack:`#6c6f85`,brightRed:`#d20f39`,brightGreen:`#40a02b`,brightYellow:`#df8e1d`,brightBlue:`#1e66f5`,brightMagenta:`#ea76cb`,brightCyan:`#179299`,brightWhite:`#bcc0cc`},frappe:{background:`#303446`,foreground:`#c6d0f5`,cursor:`#f2d5cf`,black:`#51576d`,red:`#e78284`,green:`#a6d189`,yellow:`#e5c890`,blue:`#8caaee`,magenta:`#f4b8e4`,cyan:`#81c8be`,white:`#b5bfe2`,brightBlack:`#626880`,brightRed:`#e78284`,brightGreen:`#a6d189`,brightYellow:`#e5c890`,brightBlue:`#8caaee`,brightMagenta:`#f4b8e4`,brightCyan:`#81c8be`,brightWhite:`#a5adce`},macchiato:{background:`#24273a`,foreground:`#cad3f5`,cursor:`#f4dbd6`,black:`#494d64`,red:`#ed8796`,green:`#a6da95`,yellow:`#eed49f`,blue:`#8aadf4`,magenta:`#f5bde6`,cyan:`#8bd5ca`,white:`#b8c0e0`,brightBlack:`#5b6078`,brightRed:`#ed8796`,brightGreen:`#a6da95`,brightYellow:`#eed49f`,brightBlue:`#8aadf4`,brightMagenta:`#f5bde6`,brightCyan:`#8bd5ca`,brightWhite:`#a5adcb`},mocha:{background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`}},monokaiPro:{background:`#2D2A2E`,foreground:`#FCFCFA`,cursor:`#FCFCFA`,black:`#403E41`,red:`#FF6188`,green:`#A9DC76`,yellow:`#FFD866`,blue:`#FC9867`,magenta:`#AB9DF2`,cyan:`#78DCE8`,white:`#FCFCFA`,brightBlack:`#727072`,brightRed:`#FF6188`,brightGreen:`#A9DC76`,brightYellow:`#FFD866`,brightBlue:`#FC9867`,brightMagenta:`#AB9DF2`,brightCyan:`#78DCE8`,brightWhite:`#FCFCFA`},tokyoNight:{background:`#1a1b26`,foreground:`#a9b1d6`,cursor:`#c0caf5`,black:`#32344a`,red:`#f7768e`,green:`#9ece6a`,yellow:`#e0af68`,blue:`#7aa2f7`,magenta:`#ad8ee6`,cyan:`#449dab`,white:`#787c99`,brightBlack:`#444b6a`,brightRed:`#ff7a93`,brightGreen:`#b9f27c`,brightYellow:`#ff9e64`,brightBlue:`#7da6ff`,brightMagenta:`#bb9af7`,brightCyan:`#0db9d7`,brightWhite:`#acb0d0`},nightOwl:{background:`#011627`,foreground:`#d6deeb`,cursor:`#80a4c2`,black:`#011627`,red:`#ef5350`,green:`#22da6e`,yellow:`#addb67`,blue:`#82aaff`,magenta:`#c792ea`,cyan:`#21c7a8`,white:`#ffffff`,brightBlack:`#575656`,brightRed:`#ef5350`,brightGreen:`#22da6e`,brightYellow:`#ffeb95`,brightBlue:`#82aaff`,brightMagenta:`#c792ea`,brightCyan:`#7fdbca`,brightWhite:`#ffffff`},everforest:{dark:{background:`#2b3339`,foreground:`#d3c6aa`,cursor:`#d3c6aa`,black:`#4b565c`,red:`#e67e80`,green:`#a7c080`,yellow:`#dbbc7f`,blue:`#7fbbb3`,magenta:`#d699b6`,cyan:`#83c092`,white:`#d3c6aa`,brightBlack:`#4b565c`,brightRed:`#e67e80`,brightGreen:`#a7c080`,brightYellow:`#dbbc7f`,brightBlue:`#7fbbb3`,brightMagenta:`#d699b6`,brightCyan:`#83c092`,brightWhite:`#d3c6aa`},light:{background:`#fdf6e3`,foreground:`#5c6a72`,cursor:`#5c6a72`,black:`#fdf6e3`,red:`#f85552`,green:`#8da101`,yellow:`#dfa000`,blue:`#3a94c5`,magenta:`#df69ba`,cyan:`#35a77c`,white:`#dfddc8`,brightBlack:`#5c6a72`,brightRed:`#f85552`,brightGreen:`#8da101`,brightYellow:`#dfa000`,brightBlue:`#3a94c5`,brightMagenta:`#df69ba`,brightCyan:`#35a77c`,brightWhite:`#5c6a72`}}};function S(e={}){let{fontSize:o=12,fontFamily:s=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,theme:c=x.dark.default}=e,l=n(null),[u,d]=r(null);return t(()=>{if(!l.current)return;let e=document.createElement(`style`);e.textContent=`
|
|
1
|
+
import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./use-mouse-events-DSFSfRBX.mjs";import{useCallback as h,useEffect as g,useRef as _,useState as v}from"react";import{FitAddon as y}from"@xterm/addon-fit";import{Terminal as b}from"@xterm/xterm";import"@xterm/xterm/css/xterm.css";function x(){let[e,t]=v(()=>typeof document>`u`?null:S());return g(()=>{let e=()=>t(S());return e(),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e)}},[]),e}function S(){let e=document.activeElement;return!e||e===document.body||e===document.documentElement?null:e}const C=new i;function w(e){let[t,n]=v({rms:0,peak:0,spectrum:[]}),r=e?.numBands;return g(()=>{let e={};r!==void 0&&(e.num_bands=String(r));let t=C.subscribe(`audio-stream`,e=>n(e),e);return()=>{t()}},[r]),t}function T(){let[e,t]=v(null),[n,r]=v(0),i=_(new Set),o=_(!1);g(()=>{let e=a.subscribe(`ime-composition-stream`,e=>{t(e.text===``?null:e.text),r(e.cursor)}),n=a.subscribe(`ime-commit-stream`,e=>{if(e.type===`commit`)for(let t of i.current)t(e.text)});return()=>{e(),n()}},[]);let s=h(e=>{o.current=!0;let t;if(e instanceof HTMLElement){let n=e.getBoundingClientRect();t={x:n.left,y:n.top,height:n.height}}else e&&typeof e==`object`&&(t=e);a.invoke(`ime-activate`,t?{caret:t}:{}).catch(()=>{})},[]),c=h(()=>{o.current=!1,a.invoke(`ime-deactivate`,{}).catch(()=>{})},[]),l=h(e=>(i.current.add(e),()=>{i.current.delete(e)}),[]);return g(()=>()=>{o.current&&=(a.invoke(`ime-deactivate`,{}).catch(()=>{}),!1)},[]),{composition:e,cursor:n,activate:s,deactivate:c,onCommit:l}}function E(e){let[t,n]=v(!1);return g(()=>{let t=e.current;if(!t)return;n(document.activeElement===t);let r=()=>n(!0),i=()=>n(!1);return t.addEventListener(`focus`,r),t.addEventListener(`blur`,i),()=>{t.removeEventListener(`focus`,r),t.removeEventListener(`blur`,i)}},[e]),t}const D=new i;function O(e){let[t,n]=v({title:null,artist:null,album:null,artwork:null,duration:null,elapsedTime:null,playbackRate:null,isPlaying:!1}),r=e?.intervalMs;return g(()=>{let e={};r!==void 0&&(e.interval_ms=String(r));let t=D.subscribe(`media-metadata-stream`,e=>n(e),e);return()=>{t()}},[r]),t}const k=new i;function A(){let[e,t]=v({});return g(()=>{k.invoke(`properties`,{}).then(e=>t(e));let e=k.subscribe(`properties-stream`,e=>t(e));return()=>{e()}},[]),e}function j(t,n={}){let{showStdout:r=!0,showStderr:i=!1,refreshInterval:a=3e4,terminal:o}=n,[s,c]=v(!1),[l,u]=v(null),[d,f]=v(null),p=_(n);g(()=>{p.current=n},[n]);let m=h(async()=>{if(!s){c(!0),u(null);try{let n=p.current,r=n.columns,i=n.lines;o&&(o.fitAddon.fit(),r=o.terminal.cols,i=o.terminal.rows);let a=await e(t,{...n,columns:r,lines:i});f(a),a.success||u(`Command failed with status ${a.statusCode}: ${a.stderr}`)}catch(e){u(String(e))}finally{c(!1)}}},[t,o]);return g(()=>{if(!o||!d)return;let{terminal:e}=o;if(e.reset(),d.success){let t=``;r&&(t+=d.stdout),i&&(t+=d.stderr);let n=t.trimEnd();if(n){e.write(n);let t=n.split(`
|
|
2
|
+
`).length;e.resize(e.cols,Math.max(1,t))}else e.resize(e.cols,1)}else{let t=`Command failed with status ${d.statusCode}: ${d.stderr}`;e.write(`\x1b[31m${t.trimEnd()}\x1b[0m`),e.resize(e.cols,1)}},[o,d,r,i]),g(()=>{m()},[t]),g(()=>{if(!a)return;let e=setInterval(m,a);return()=>clearInterval(e)},[m,a]),{execute:m,isRunning:s,error:l,result:d}}const M=new i;function N(e){let[t,n]=v({cpuUsage:0,cpuPerCore:[],cpuFrequencyMhz:[],memoryTotal:0,memoryUsed:0,memoryUsage:0,swapTotal:0,swapUsed:0,swapUsage:0,batteryLevel:null,batteryCharging:null,networkRxBytesPerSec:0,networkTxBytesPerSec:0,diskReadBytesPerSec:0,diskWriteBytesPerSec:0,processCount:0,uptimeSecs:0,loadAverage:[0,0,0],disks:[],hostname:``,osName:``,cpuBrand:``,physicalCoreCount:0,logicalCoreCount:0,cpuArch:``,kernelVersion:``}),r=e?.cpuIntervalMs,i=e?.memoryIntervalMs,a=e?.networkIntervalMs,o=e?.diskIoIntervalMs,s=e?.diskSpaceIntervalMs,c=e?.batteryIntervalMs,l=e?.processIntervalMs,u=e?.loadAverageIntervalMs;return g(()=>{let e={};r!==void 0&&(e.cpu_interval_ms=String(r)),i!==void 0&&(e.memory_interval_ms=String(i)),a!==void 0&&(e.network_interval_ms=String(a)),o!==void 0&&(e.disk_io_interval_ms=String(o)),s!==void 0&&(e.disk_space_interval_ms=String(s)),c!==void 0&&(e.battery_interval_ms=String(c)),l!==void 0&&(e.process_interval_ms=String(l)),u!==void 0&&(e.load_average_interval_ms=String(u));let t=M.subscribe(`system-monitor-stream`,e=>n(e),e);return()=>{t()}},[r,i,a,o,s,c,l,u]),t}function P(e={}){let{fontSize:t=12,fontFamily:n=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,theme:r=l.dark.default}=e,i=_(null),[a,o]=v(null);return g(()=>{if(!i.current)return;let e=document.createElement(`style`);e.textContent=`
|
|
4
3
|
.xterm-char-measure-element {
|
|
5
4
|
position: absolute !important;
|
|
6
5
|
top: 0 !important;
|
|
@@ -29,4 +28,4 @@ import{useCallback as e,useEffect as t,useRef as n,useState as r}from"react";imp
|
|
|
29
28
|
.xterm-selection {
|
|
30
29
|
display: none !important; /* Hide xterm's own selection overlay. */
|
|
31
30
|
}
|
|
32
|
-
`,document.head.appendChild(e);let
|
|
31
|
+
`,document.head.appendChild(e);let a=new b({fontSize:t,fontFamily:n,disableStdin:!0,cursorBlink:!1,convertEol:!0,scrollback:0,theme:r}),s=new y;return a.loadAddon(s),a.open(i.current),a.write(`\x1B[?25l`),o({terminal:a,fitAddon:s}),()=>{document.head.contains(e)&&document.head.removeChild(e),a.dispose(),o(null)}},[t,n]),{terminalRef:i,instance:a}}export{i as HttpTransport,t as ImeInlineController,l as TerminalThemes,m as caretIndexFromClientPoint,a as defaultTransport,n as getPropertyFileUrl,u as isImeAutoTarget,s as measureCaretRect,r as measureSelectionRects,o as normalizedToPixel,f as pixelToNormalized,e as runShell,x as useActiveElement,w as useAudio,T as useImeInput,E as useIsFocused,d as useKeyboard,O as useMediaMetadata,p as useMouseEvents,c as useMousePosition,A as useProperties,j as useShell,N as useSystemMonitor,P as useTerminal};
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import * as _$react from "react";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region ../../mimo/core/dist/index.d.mts
|
|
6
|
+
//#region src/pointer/cursor.d.ts
|
|
7
|
+
/** Visual configuration for the optional virtual cursor element. */
|
|
8
|
+
interface CursorOptions {
|
|
9
|
+
/** Diameter of the cursor in CSS pixels. Default 16. */
|
|
10
|
+
size?: number;
|
|
11
|
+
/** CSS color value. Default semi-transparent black. */
|
|
12
|
+
color?: string;
|
|
13
|
+
/** Class name applied to the cursor element. Default `"mimo-cursor"`. */
|
|
14
|
+
className?: string;
|
|
15
|
+
} //#endregion
|
|
16
|
+
//#region src/source.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Pointer button identifier. Numeric mappings to native button index / buttons
|
|
19
|
+
* bitmask are encapsulated inside the synthesizer, so consumers never have to
|
|
20
|
+
* deal with raw button numbers.
|
|
21
|
+
*/
|
|
22
|
+
type PointerButton = "left" | "right" | "middle" | "aux1" | "aux2";
|
|
23
|
+
/** Pointer device type. Mirrors `PointerEvent.pointerType`. */
|
|
24
|
+
type PointerType = "mouse" | "touch" | "pen";
|
|
25
|
+
/** Cleanup function returned from a source subscription. */
|
|
26
|
+
type Unsubscribe = () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Fields shared by every pointer event kind. Coordinates are CSS pixels in the
|
|
29
|
+
* target document's viewport. Optional screen coordinates default to the
|
|
30
|
+
* client coordinates when omitted.
|
|
31
|
+
*/
|
|
32
|
+
interface PointerSourceCommon {
|
|
33
|
+
/** Viewport-relative X coordinate, in CSS pixels. */
|
|
34
|
+
x: number;
|
|
35
|
+
/** Viewport-relative Y coordinate, in CSS pixels. */
|
|
36
|
+
y: number;
|
|
37
|
+
/** Optional OS screen X coordinate. Defaults to `x`. */
|
|
38
|
+
screenX?: number;
|
|
39
|
+
/** Optional OS screen Y coordinate. Defaults to `y`. */
|
|
40
|
+
screenY?: number;
|
|
41
|
+
/** Pointer device type. Default `"mouse"`. */
|
|
42
|
+
pointerType?: PointerType;
|
|
43
|
+
/** Normalized pressure in `[0, 1]`. Default 0 with no buttons, 0.5 otherwise. */
|
|
44
|
+
pressure?: number;
|
|
45
|
+
/** Pen tilt around the X axis in degrees, `[-90, 90]`. Default 0. */
|
|
46
|
+
tiltX?: number;
|
|
47
|
+
/** Pen tilt around the Y axis in degrees, `[-90, 90]`. Default 0. */
|
|
48
|
+
tiltY?: number;
|
|
49
|
+
}
|
|
50
|
+
/** Pointer move emitted by an input source. */
|
|
51
|
+
interface PointerSourceMoveEvent extends PointerSourceCommon {
|
|
52
|
+
kind: "move";
|
|
53
|
+
}
|
|
54
|
+
/** Pointer button press / release emitted by an input source. */
|
|
55
|
+
interface PointerSourceButtonEvent extends PointerSourceCommon {
|
|
56
|
+
kind: "button";
|
|
57
|
+
button: PointerButton;
|
|
58
|
+
/** True for press, false for release. */
|
|
59
|
+
pressed: boolean;
|
|
60
|
+
}
|
|
61
|
+
/** Wheel / trackpad scroll emitted by an input source. */
|
|
62
|
+
interface PointerSourceWheelEvent extends PointerSourceCommon {
|
|
63
|
+
kind: "wheel";
|
|
64
|
+
deltaX: number;
|
|
65
|
+
deltaY: number;
|
|
66
|
+
/** 0 = pixel (default), 1 = line, 2 = page. */
|
|
67
|
+
deltaMode?: 0 | 1 | 2;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Pointer cancel - signals that the OS has aborted the current pointer
|
|
71
|
+
* stream (focus loss, gesture takeover, etc.). Cleared down/click bookkeeping
|
|
72
|
+
* and fires `pointercancel` on the active target.
|
|
73
|
+
*/
|
|
74
|
+
interface PointerSourceCancelEvent extends PointerSourceCommon {
|
|
75
|
+
kind: "cancel";
|
|
76
|
+
/** Optional button that was active when the cancel occurred. */
|
|
77
|
+
button?: PointerButton;
|
|
78
|
+
}
|
|
79
|
+
/** Aggregate pointer event type accepted by {@link MimoForwarder}. */
|
|
80
|
+
type PointerSourceEvent = PointerSourceMoveEvent | PointerSourceButtonEvent | PointerSourceWheelEvent | PointerSourceCancelEvent;
|
|
81
|
+
/**
|
|
82
|
+
* Pointer source: a function that takes a handler and returns an unsubscribe
|
|
83
|
+
* callback. Mimo never owns the source; consumers wire it up to whatever
|
|
84
|
+
* transport produces input events (WebSocket, custom hardware, automation
|
|
85
|
+
* scripts, etc.).
|
|
86
|
+
*/
|
|
87
|
+
type PointerSource = (handler: (event: PointerSourceEvent) => void) => Unsubscribe;
|
|
88
|
+
/** Modifier key state at the time of a keyboard event. */
|
|
89
|
+
interface KeyboardModifiers {
|
|
90
|
+
shift?: boolean;
|
|
91
|
+
ctrl?: boolean;
|
|
92
|
+
alt?: boolean;
|
|
93
|
+
meta?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Keyboard press / release emitted by an input source.
|
|
97
|
+
*
|
|
98
|
+
* `code` follows the Web `KeyboardEvent.code` convention identifying a physical
|
|
99
|
+
* key independent of layout (e.g. `"KeyA"`, `"Space"`, `"ArrowLeft"`,
|
|
100
|
+
* `"ShiftLeft"`). `key` is optional; when omitted the synthesizer leaves it
|
|
101
|
+
* blank, which is enough for most listener-style consumers (`onKeyDown`,
|
|
102
|
+
* shortcut handlers, etc.).
|
|
103
|
+
*
|
|
104
|
+
* The forwarder remembers the latest `modifiers` snapshot from this source and
|
|
105
|
+
* uses it to populate `shiftKey` / `ctrlKey` / `altKey` / `metaKey` on every
|
|
106
|
+
* subsequent pointer event, so Shift+click and similar shortcuts behave as
|
|
107
|
+
* expected.
|
|
108
|
+
*/
|
|
109
|
+
interface KeyboardSourceEvent {
|
|
110
|
+
code: string;
|
|
111
|
+
key?: string;
|
|
112
|
+
pressed: boolean;
|
|
113
|
+
/** True if the OS reports this as an auto-repeat. */
|
|
114
|
+
repeat?: boolean;
|
|
115
|
+
modifiers?: KeyboardModifiers;
|
|
116
|
+
}
|
|
117
|
+
/** Keyboard source: same shape as {@link PointerSource}. */
|
|
118
|
+
type KeyboardSource = (handler: (event: KeyboardSourceEvent) => void) => Unsubscribe; //#endregion
|
|
119
|
+
//#region src/forwarder.d.ts
|
|
120
|
+
/**
|
|
121
|
+
* Strategy for choosing which element receives a synthesized keyboard event.
|
|
122
|
+
*
|
|
123
|
+
* - `active-element` (default): dispatch to `document.activeElement`,
|
|
124
|
+
* matching how real keyboard input behaves once a focusable element is
|
|
125
|
+
* focused. Works well with the default `autoFocus` pointer behavior.
|
|
126
|
+
* - `pointer-target`: dispatch to whatever element is currently under the
|
|
127
|
+
* synthetic pointer. Useful for "hover-to-type" demos and games.
|
|
128
|
+
* - `document`: always dispatch on `document`. Best for global shortcut
|
|
129
|
+
* handlers that listen at the document level.
|
|
130
|
+
*/
|
|
131
|
+
type KeyboardTargetStrategy = "active-element" | "pointer-target" | "document";
|
|
132
|
+
interface MimoForwarderOptions {
|
|
133
|
+
/** Source of pointer events. May be omitted if only keyboard is forwarded. */
|
|
134
|
+
pointerSource?: PointerSource;
|
|
135
|
+
/** Source of keyboard events. May be omitted if only pointer is forwarded. */
|
|
136
|
+
keyboardSource?: KeyboardSource;
|
|
137
|
+
/**
|
|
138
|
+
* Document the events are dispatched into. Defaults to `globalThis.document`,
|
|
139
|
+
* which is appropriate for the only realistic case (the page that hosts the
|
|
140
|
+
* forwarder). Mostly here to make tests trivially injectable.
|
|
141
|
+
*/
|
|
142
|
+
document?: Document;
|
|
143
|
+
/** Maximum gap between two clicks that still count as a double click. Default 500ms. */
|
|
144
|
+
doubleClickThresholdMs?: number;
|
|
145
|
+
/**
|
|
146
|
+
* Maximum drift in CSS pixels between pointerdown and pointerup that still
|
|
147
|
+
* fires a click. Beyond this threshold the up is treated as the end of a
|
|
148
|
+
* drag and no click event is synthesized. Default 5px.
|
|
149
|
+
*/
|
|
150
|
+
clickMoveThresholdPx?: number;
|
|
151
|
+
/**
|
|
152
|
+
* Auto-focus the nearest focusable ancestor of the click target on
|
|
153
|
+
* pointerdown, mirroring real browser behavior. Default `true`.
|
|
154
|
+
*/
|
|
155
|
+
autoFocus?: boolean;
|
|
156
|
+
/** Render a virtual cursor element. Set to an object to customize, or `false` to disable. Default `false`. */
|
|
157
|
+
cursor?: boolean | CursorOptions;
|
|
158
|
+
/** See {@link KeyboardTargetStrategy}. Default `"active-element"`. */
|
|
159
|
+
keyboardTarget?: KeyboardTargetStrategy;
|
|
160
|
+
/**
|
|
161
|
+
* After dispatching a synthesized `keydown`, apply the corresponding text
|
|
162
|
+
* mutation when the keyboard target is an editable element (`<input>`,
|
|
163
|
+
* `<textarea>`, or `[contenteditable]`). Browsers do not perform this for
|
|
164
|
+
* untrusted events, so without this option focused inputs would not receive
|
|
165
|
+
* any text from synthesized keystrokes. Default `true`. Set to `false` for
|
|
166
|
+
* games or shortcut handlers that want to consume raw keydown only.
|
|
167
|
+
*/
|
|
168
|
+
editableTextInput?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Enable pointer capture handling: install a process-wide patch on
|
|
171
|
+
* `Element.prototype.{set,release,has}PointerCapture` that routes captures
|
|
172
|
+
* for the mimo pointer to this forwarder. Default `true`. Required for
|
|
173
|
+
* dnd-kit, react-dnd Pointer backend, and Framer Motion drag.
|
|
174
|
+
*/
|
|
175
|
+
pointerCapture?: boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Forwards external pointer / keyboard events into the DOM as synthetic events.
|
|
179
|
+
*
|
|
180
|
+
* The forwarder is framework-agnostic: it owns no React / Vue references. Adapter
|
|
181
|
+
* packages (`@mimo/react`, `@mimo/vue`) are expected to be tiny shells that
|
|
182
|
+
* construct an instance, call `start()` on mount, and `stop()` on unmount.
|
|
183
|
+
*/
|
|
184
|
+
declare class MimoForwarder {
|
|
185
|
+
private readonly options;
|
|
186
|
+
private readonly doc;
|
|
187
|
+
private readonly hitTest;
|
|
188
|
+
private readonly capture;
|
|
189
|
+
private cursor;
|
|
190
|
+
/** `MouseEvent.buttons` bitmask, kept in sync across press/release events. */
|
|
191
|
+
private buttons;
|
|
192
|
+
private lastX;
|
|
193
|
+
private lastY;
|
|
194
|
+
/** Latest keyboard modifier snapshot, propagated to mouse events for Shift+click etc. */
|
|
195
|
+
private modifiers;
|
|
196
|
+
private readonly downRecords;
|
|
197
|
+
private readonly clickRecords;
|
|
198
|
+
private pointerUnsub;
|
|
199
|
+
private keyboardUnsub;
|
|
200
|
+
private running;
|
|
201
|
+
constructor(options?: MimoForwarderOptions);
|
|
202
|
+
start(): void;
|
|
203
|
+
stop(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Replace the pointer source at runtime. Pass `null` to disconnect. Safe to
|
|
206
|
+
* call before `start()` (the source will be picked up on start) or while
|
|
207
|
+
* running (re-subscription happens immediately).
|
|
208
|
+
*/
|
|
209
|
+
setPointerSource(source: PointerSource | null): void;
|
|
210
|
+
/**
|
|
211
|
+
* Push a single pointer event into the forwarder without going through a
|
|
212
|
+
* subscription source. Equivalent to what an active `pointerSource` would
|
|
213
|
+
* deliver, but lets callers (e.g. host integrations that read from React
|
|
214
|
+
* hooks instead of imperative event streams) drive the forwarder directly.
|
|
215
|
+
*
|
|
216
|
+
* No-op while the forwarder is not running.
|
|
217
|
+
*/
|
|
218
|
+
injectPointer(event: PointerSourceEvent): void;
|
|
219
|
+
/** See {@link injectPointer}. */
|
|
220
|
+
injectKeyboard(event: KeyboardSourceEvent): void;
|
|
221
|
+
/** See {@link setPointerSource}. */
|
|
222
|
+
setKeyboardSource(source: KeyboardSource | null): void;
|
|
223
|
+
private handlePointer;
|
|
224
|
+
private handleCancel;
|
|
225
|
+
private flushCaptureTransitions;
|
|
226
|
+
private makeContext;
|
|
227
|
+
private shouldFireClick;
|
|
228
|
+
private bumpClickCount;
|
|
229
|
+
private handleKeyboard;
|
|
230
|
+
private resolveKeyboardTarget;
|
|
231
|
+
} //#endregion
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region ../../mimo/react/dist/index.d.mts
|
|
234
|
+
//#region src/context.d.ts
|
|
235
|
+
declare const MimoForwarderContext: _$react.Context<MimoForwarder | null>; //#endregion
|
|
236
|
+
//#region src/MimoProvider.d.ts
|
|
237
|
+
interface MimoProviderProps extends MimoForwarderOptions {
|
|
238
|
+
children?: ReactNode;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Drives a {@link MimoForwarder} lifecycle from the React tree.
|
|
242
|
+
*
|
|
243
|
+
* The forwarder is constructed once on first render with the initial options.
|
|
244
|
+
* After that, only `pointerSource` and `keyboardSource` are tracked: when
|
|
245
|
+
* either reference changes, the corresponding setter on the forwarder is
|
|
246
|
+
* called so a new transport can be hot-swapped without restart. All other
|
|
247
|
+
* options (cursor, autoFocus, thresholds, ...) are read at construction
|
|
248
|
+
* time and ignored on subsequent renders — remount the provider if you need
|
|
249
|
+
* to change them.
|
|
250
|
+
*
|
|
251
|
+
* `start()` runs in a mount effect and `stop()` in its cleanup, so React
|
|
252
|
+
* StrictMode's mount/unmount/mount cycle is balanced.
|
|
253
|
+
*/
|
|
254
|
+
declare function MimoProvider({
|
|
255
|
+
children,
|
|
256
|
+
...options
|
|
257
|
+
}: MimoProviderProps): _$react_jsx_runtime0.JSX.Element; //#endregion
|
|
258
|
+
//#region src/useMimoForwarder.d.ts
|
|
259
|
+
/**
|
|
260
|
+
* Read the {@link MimoForwarder} instance owned by the nearest
|
|
261
|
+
* {@link MimoProvider}. Throws if used outside one — most consumers want this
|
|
262
|
+
* fail-fast behavior. If you need optional access, read
|
|
263
|
+
* `MimoForwarderContext` directly.
|
|
264
|
+
*/
|
|
265
|
+
declare function useMimoForwarder(): MimoForwarder; //#endregion
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region src/mimo/MimoProvider.d.ts
|
|
268
|
+
interface MimoProviderProps$1 extends Omit<MimoProviderProps, "pointerSource" | "keyboardSource"> {
|
|
269
|
+
/**
|
|
270
|
+
* When `false`, OS pointer events are not injected into the forwarder.
|
|
271
|
+
* Useful for temporarily detaching the cursor (e.g. demo toggles).
|
|
272
|
+
* Defaults to `true`.
|
|
273
|
+
*/
|
|
274
|
+
pointer?: boolean;
|
|
275
|
+
/**
|
|
276
|
+
* When `false`, OS keyboard events are not injected. Defaults to `true`.
|
|
277
|
+
*/
|
|
278
|
+
keyboard?: boolean;
|
|
279
|
+
children?: ReactNode;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Opinionated Mimo provider for fluxlay wallpapers.
|
|
283
|
+
*
|
|
284
|
+
* Subscribes to fluxlay's OS input hooks (`useMousePosition`,
|
|
285
|
+
* `useMouseEvents`, `useKeyboard`) and forwards every event into the embedded
|
|
286
|
+
* {@link MimoForwarder} as a synthetic DOM event. Drop this at the root of a
|
|
287
|
+
* wallpaper and any standard React UI inside it will start receiving real
|
|
288
|
+
* `pointermove` / `pointerdown` / `keydown` etc.
|
|
289
|
+
*
|
|
290
|
+
* `pointerSource` and `keyboardSource` are intentionally not exposed: this
|
|
291
|
+
* provider owns the input source. If you need a custom source (tests, replay,
|
|
292
|
+
* a non-fluxlay environment), import the lower-level `MimoForwarderProvider`
|
|
293
|
+
* from this same module instead.
|
|
294
|
+
*/
|
|
295
|
+
declare function MimoProvider$1({
|
|
296
|
+
pointer,
|
|
297
|
+
keyboard,
|
|
298
|
+
children,
|
|
299
|
+
...rest
|
|
300
|
+
}: MimoProviderProps$1): _$react_jsx_runtime0.JSX.Element;
|
|
301
|
+
//#endregion
|
|
302
|
+
export { type CursorOptions, type KeyboardModifiers, type KeyboardSource, type KeyboardSourceEvent, type KeyboardTargetStrategy, MimoForwarder, MimoForwarderContext, type MimoForwarderOptions, MimoProvider as MimoForwarderProvider, type MimoProviderProps as MimoForwarderProviderProps, MimoProvider$1 as MimoProvider, type MimoProviderProps$1 as MimoProviderProps, type PointerButton, type PointerSource, type PointerSourceButtonEvent, type PointerSourceCancelEvent, type PointerSourceEvent, type PointerSourceMoveEvent, type PointerSourceWheelEvent, type PointerType, type Unsubscribe, useMimoForwarder };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{l as e,n as t,r as n,t as r}from"../use-mouse-events-DSFSfRBX.mjs";import{createContext as i,use as a,useEffect as o,useState as s}from"react";import{jsx as c,jsxs as ee}from"react/jsx-runtime";function l(e){return{view:window,bubbles:!0,cancelable:!0,composed:!0,code:e.code,key:e.key??``,repeat:e.repeat??!1,shiftKey:e.modifiers?.shift??!1,ctrlKey:e.modifiers?.ctrl??!1,altKey:e.modifiers?.alt??!1,metaKey:e.modifiers?.meta??!1}}function u(e,t){let n=t.pressed?`keydown`:`keyup`;e.dispatchEvent(new KeyboardEvent(n,l(t)))}function d(e,t){if(!t.pressed||!e||!(e instanceof Element)||t.modifiers?.ctrl||t.modifiers?.meta||!te(e))return;if(t.code===`Backspace`){g(e,`deleteContentBackward`);return}if(t.code===`Delete`){g(e,`deleteContentForward`);return}if(t.code===`Enter`||t.code===`NumpadEnter`){(e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable)&&h(e,`
|
|
2
|
+
`);return}if(t.code===`Tab`){(e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable)&&h(e,` `);return}let n=ne(t);n!==null&&h(e,n)}function te(e){if(e instanceof HTMLInputElement){if(e.disabled||e.readOnly)return!1;let t=e.type.toLowerCase();return t===``||f.has(t)}return e instanceof HTMLTextAreaElement?!e.disabled&&!e.readOnly:e instanceof HTMLElement&&e.isContentEditable}const f=new Set([`text`,`search`,`url`,`tel`,`email`,`password`,`number`]);function ne(e){return e.key&&e.key.length===1?e.key:re(e.code,e.modifiers?.shift??!1)}function re(e,t){let n=e.match(/^Key([A-Z])$/);if(n)return t?n[1]:n[1].toLowerCase();let r=e.match(/^Digit(\d)$/);if(r)return t?p[parseInt(r[1],10)]:r[1];let i=e.match(/^Numpad(\d)$/);return i?i[1]:m[e]?.[+!!t]??null}const p=[`)`,`!`,`@`,`#`,`$`,`%`,`^`,`&`,`*`,`(`],m={Space:[` `,` `],Minus:[`-`,`_`],Equal:[`=`,`+`],BracketLeft:[`[`,`{`],BracketRight:[`]`,`}`],Backslash:[`\\`,`|`],Semicolon:[`;`,`:`],Quote:[`'`,`"`],Comma:[`,`,`<`],Period:[`.`,`>`],Slash:[`/`,`?`],Backquote:["`",`~`],NumpadMultiply:[`*`,`*`],NumpadAdd:[`+`,`+`],NumpadSubtract:[`-`,`-`],NumpadDivide:[`/`,`/`],NumpadDecimal:[`.`,`.`]};function h(e,t){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){let n=e.selectionStart??e.value.length,r=e.selectionEnd??e.value.length;_(e,e.value.slice(0,n)+t+e.value.slice(r));let i=n+t.length;try{e.setSelectionRange(i,i)}catch{}v(e,`insertText`,t)}else if(e instanceof HTMLElement&&e.isContentEditable){let n=e.ownerDocument,r=n.getSelection();if(!r)return;if(r.rangeCount===0){let t=n.createRange();t.selectNodeContents(e),t.collapse(!1),r.removeAllRanges(),r.addRange(t)}let i=r.getRangeAt(0);i.deleteContents();let a=n.createTextNode(t);i.insertNode(a),i.setStartAfter(a),i.setEndAfter(a),r.removeAllRanges(),r.addRange(i),v(e,`insertText`,t)}}function g(e,t){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){let n=e.selectionStart??e.value.length,r=e.selectionEnd??e.value.length;if(n===r)if(t===`deleteContentBackward`){if(n===0)return;--n}else{if(r>=e.value.length)return;r+=1}_(e,e.value.slice(0,n)+e.value.slice(r));try{e.setSelectionRange(n,n)}catch{}v(e,t,null)}else if(e instanceof HTMLElement&&e.isContentEditable){let n=e.ownerDocument.getSelection();if(!n||n.rangeCount===0)return;let r=n.getRangeAt(0);if(r.collapsed)try{t===`deleteContentBackward`?r.setStart(r.startContainer,Math.max(0,r.startOffset-1)):r.setEnd(r.endContainer,r.endOffset+1)}catch{return}r.deleteContents(),v(e,t,null)}}function _(e,t){let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`);r?.set?r.set.call(e,t):e.value=t}function v(e,t,n){e.dispatchEvent(new InputEvent(`beforeinput`,{bubbles:!0,cancelable:!0,composed:!0,inputType:t,data:n})),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,composed:!0,inputType:t,data:n}))}const y={left:0,middle:1,right:2,aux1:3,aux2:4},b={left:1,right:2,middle:4,aux1:8,aux2:16};function x(e){return y[e]}function S(e){return b[e]}function C(e,t,n,r,i=!0){return{view:window,bubbles:i,cancelable:!0,composed:!0,clientX:e,clientY:t,screenX:r.screenX,screenY:r.screenY,movementX:r.movementX,movementY:r.movementY,button:n,buttons:r.buttons,pointerId:1,pointerType:r.pointerType,isPrimary:!0,pressure:r.pressure,tiltX:r.tiltX,tiltY:r.tiltY,shiftKey:r.modifiers.shiftKey,ctrlKey:r.modifiers.ctrlKey,altKey:r.modifiers.altKey,metaKey:r.modifiers.metaKey}}function w(e,t,n,r,i=!0){return{view:window,bubbles:i,cancelable:!0,composed:!0,clientX:e,clientY:t,screenX:r.screenX,screenY:r.screenY,movementX:r.movementX,movementY:r.movementY,button:n,buttons:r.buttons,shiftKey:r.modifiers.shiftKey,ctrlKey:r.modifiers.ctrlKey,altKey:r.modifiers.altKey,metaKey:r.modifiers.metaKey}}function T(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointermove`,C(t,n,-1,r))),e.dispatchEvent(new MouseEvent(`mousemove`,w(t,n,0,r)))}function ie(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointerout`,C(t,n,-1,r))),e.dispatchEvent(new MouseEvent(`mouseout`,w(t,n,0,r)))}function E(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointerover`,C(t,n,-1,r))),e.dispatchEvent(new MouseEvent(`mouseover`,w(t,n,0,r)))}function D(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointerleave`,C(t,n,-1,r,!1))),e.dispatchEvent(new MouseEvent(`mouseleave`,w(t,n,0,r,!1)))}function O(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointerenter`,C(t,n,-1,r,!1))),e.dispatchEvent(new MouseEvent(`mouseenter`,w(t,n,0,r,!1)))}function k(e,t,n,r,i){let a=x(r);e.dispatchEvent(new PointerEvent(`pointerdown`,C(t,n,a,i))),e.dispatchEvent(new MouseEvent(`mousedown`,w(t,n,a,i)))}function A(e,t,n,r,i){let a=x(r);e.dispatchEvent(new PointerEvent(`pointerup`,C(t,n,a,i))),e.dispatchEvent(new MouseEvent(`mouseup`,w(t,n,a,i)))}function j(e,t,n,r,i,a){let o={...w(t,n,x(r),i),detail:a};r===`left`?(e.dispatchEvent(new MouseEvent(`click`,o)),a===2&&e.dispatchEvent(new MouseEvent(`dblclick`,o))):r===`right`?e.dispatchEvent(new MouseEvent(`contextmenu`,o)):e.dispatchEvent(new MouseEvent(`auxclick`,o))}function M(e,t,n,r,i,a,o){e.dispatchEvent(new WheelEvent(`wheel`,{...w(t,n,0,o),deltaX:r,deltaY:i,deltaMode:a}))}function N(e,t,n,r){e.dispatchEvent(new PointerEvent(`pointercancel`,C(t,n,-1,r)))}function P(e,t,n,r){e.dispatchEvent(new PointerEvent(`gotpointercapture`,C(t,n,-1,r)))}function F(e,t,n,r){e.dispatchEvent(new PointerEvent(`lostpointercapture`,C(t,n,-1,r)))}const I=[];let L=!1,R,z,B;function ae(){L||(L=!0,R=Element.prototype.setPointerCapture,z=Element.prototype.releasePointerCapture,B=Element.prototype.hasPointerCapture,Element.prototype.setPointerCapture=function(e){let t=I[I.length-1];if(t&&e===1){t.markCaptured(this);return}return R.call(this,e)},Element.prototype.releasePointerCapture=function(e){let t=I[I.length-1];if(t&&e===1&&t.getCaptured()===this){t.markReleased();return}return z.call(this,e)},Element.prototype.hasPointerCapture=function(e){let t=I[I.length-1];return t&&e===1?t.getCaptured()===this:B.call(this,e)})}var V=class{captured=null;justCaptured=null;justReleased=null;install(){ae(),I.push(this)}uninstall(){let e=I.lastIndexOf(this);e>=0&&I.splice(e,1),this.reset()}reset(){this.captured=null,this.justCaptured=null,this.justReleased=null}getCaptured(){return this.captured}markCaptured(e){this.captured!==e&&(this.captured&&(this.justReleased=this.captured),this.captured=e,this.justCaptured=e)}markReleased(){this.captured&&=(this.justReleased=this.captured,null)}consumeTransitions(){let e=this.justCaptured,t=this.justReleased;return this.justCaptured=null,this.justReleased=null,{gained:e,lost:t}}},H=class{el=null;doc;resolved;constructor(e,t={}){this.doc=e,this.resolved={size:t.size??16,color:t.color??`rgba(0, 0, 0, 0.7)`,className:t.className??`mimo-cursor`}}attach(){if(this.el)return;let e=this.doc.createElement(`div`);e.className=this.resolved.className,Object.assign(e.style,{position:`fixed`,top:`0`,left:`0`,width:`${this.resolved.size}px`,height:`${this.resolved.size}px`,borderRadius:`50%`,background:this.resolved.color,pointerEvents:`none`,zIndex:`2147483647`,transform:`translate(-50%, -50%)`,willChange:`transform`}),this.doc.body.appendChild(e),this.el=e}move(e,t){this.el&&(this.el.style.transform=`translate(${e}px, ${t}px) translate(-50%, -50%)`)}detach(){this.el?.remove(),this.el=null}};function U(e,t,n){let r=e.elementFromPoint(t,n);for(let e=0;e<64;e++){if(!r?.shadowRoot)return r;let e=r.shadowRoot.elementFromPoint(t,n);if(!e||e===r)return r;r=e}return r}function W(e){let t=[],n=e;for(;n;)t.push(n),n=n.parentElement;return t}function G(e,t){let n=new Set(t);for(let t of e)if(n.has(t))return t;return null}function K(e,t,n,r,i){if(e===t)return;let a=W(e),o=W(t),s=G(a,o);if(e){ie(e,n,r,i);for(let e of a){if(e===s)break;D(e,n,r,i)}}if(t){E(t,n,r,i);for(let e of o){if(e===s)break;O(e,n,r,i)}}}var q=class{current=null;resolve(e,t,n){return U(e,t,n)}update(e,t,n,r,i=null){if(i)return T(i,t,n,r),i;let a=this.resolve(e,t,n);return a!==this.current&&(K(this.current,a,t,n,r),this.current=a),a&&T(a,t,n,r),a}reset(){this.current=null}};const J=[`a[href]`,`button:not([disabled])`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`,`[contenteditable="true"]`].join(`,`);function oe(e){let t=e;for(;t;){if(t instanceof HTMLElement&&t.matches(J))return t;t=t.parentElement}return null}const Y={shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1};var X=class{options;doc;hitTest=new q;capture=new V;cursor=null;buttons=0;lastX=0;lastY=0;modifiers=Y;downRecords=new Map;clickRecords=new Map;pointerUnsub=null;keyboardUnsub=null;running=!1;constructor(e={}){this.options=e,this.doc=e.document??globalThis.document}start(){this.running||(this.running=!0,this.options.pointerCapture!==!1&&this.capture.install(),this.options.cursor&&(this.cursor=new H(this.doc,typeof this.options.cursor==`object`?this.options.cursor:{}),this.cursor.attach()),this.options.pointerSource&&(this.pointerUnsub=this.options.pointerSource(e=>{this.handlePointer(e)})),this.options.keyboardSource&&(this.keyboardUnsub=this.options.keyboardSource(e=>{this.handleKeyboard(e)})))}stop(){this.running&&(this.running=!1,this.pointerUnsub?.(),this.pointerUnsub=null,this.keyboardUnsub?.(),this.keyboardUnsub=null,this.cursor?.detach(),this.cursor=null,this.capture.uninstall(),this.hitTest.reset(),this.buttons=0,this.modifiers=Y,this.downRecords.clear(),this.clickRecords.clear())}setPointerSource(e){this.pointerUnsub?.(),this.pointerUnsub=null,this.options.pointerSource=e??void 0,this.running&&e&&(this.pointerUnsub=e(e=>{this.handlePointer(e)}))}injectPointer(e){this.running&&this.handlePointer(e)}injectKeyboard(e){this.running&&this.handleKeyboard(e)}setKeyboardSource(e){this.keyboardUnsub?.(),this.keyboardUnsub=null,this.options.keyboardSource=e??void 0,this.running&&e&&(this.keyboardUnsub=e(e=>{this.handleKeyboard(e)}))}handlePointer(e){let t=e.x-this.lastX,n=e.y-this.lastY;if(this.lastX=e.x,this.lastY=e.y,this.cursor?.move(e.x,e.y),e.kind===`cancel`){this.handleCancel(e.x,e.y,this.makeContext(e,t,n));return}let r=this.makeContext(e,t,n);if(e.kind===`move`){let t=this.hitTest.update(this.doc,e.x,e.y,r,this.capture.getCaptured());this.flushCaptureTransitions(t,e.x,e.y,r);return}let i=this.hitTest.update(this.doc,e.x,e.y,r,this.capture.getCaptured());if(i)if(e.kind===`button`){let t=S(e.button);if(e.pressed){if(this.buttons|=t,r.buttons=this.buttons,r.pressure=r.pressure||.5,k(i,e.x,e.y,e.button,r),this.downRecords.set(e.button,{target:i,x:e.x,y:e.y}),this.options.autoFocus!==!1){let e=oe(i);if(e)e.focus();else{let e=this.doc.activeElement;e instanceof HTMLElement&&e!==this.doc.body&&e.blur()}}this.flushCaptureTransitions(i,e.x,e.y,r)}else{this.buttons&=~t,r.buttons=this.buttons,r.pressure=this.buttons===0?0:r.pressure,A(i,e.x,e.y,e.button,r),this.flushCaptureTransitions(i,e.x,e.y,r);let n=this.downRecords.get(e.button);if(this.downRecords.delete(e.button),n&&this.shouldFireClick(n,i,e.x,e.y)){let t=se(n.target,i),a=this.bumpClickCount(e.button,t,e.x,e.y);j(t,e.x,e.y,e.button,r,a)}this.buttons===0&&this.capture.getCaptured()&&(this.capture.markReleased(),this.flushCaptureTransitions(i,e.x,e.y,r))}}else M(i,e.x,e.y,e.deltaX,e.deltaY,e.deltaMode??0,r)}handleCancel(e,t,n){let r=this.capture.getCaptured(),i=r??this.hitTest.resolve(this.doc,e,t);i&&N(i,e,t,n),r&&(this.capture.markReleased(),this.flushCaptureTransitions(r,e,t,n)),this.buttons=0,this.downRecords.clear()}flushCaptureTransitions(e,t,n,r){let{gained:i,lost:a}=this.capture.consumeTransitions();a&&F(a,t,n,r),i&&P(i,t,n,r)}makeContext(e,t,n){return{buttons:this.buttons,modifiers:this.modifiers,pointerType:e.pointerType??`mouse`,pressure:e.pressure??(this.buttons>0?.5:0),tiltX:e.tiltX??0,tiltY:e.tiltY??0,movementX:t,movementY:n,screenX:e.screenX??e.x,screenY:e.screenY??e.y}}shouldFireClick(e,t,n,r){let i=this.options.clickMoveThresholdPx??5;return Math.abs(n-e.x)>i||Math.abs(r-e.y)>i?!1:e.target.contains(t)||t.contains(e.target)}bumpClickCount(e,t,n,r){let i=performance.now(),a=this.options.doubleClickThresholdMs??500,o=this.clickRecords.get(e),s=1;return o&&o.target===t&&i-o.time<=a&&Math.abs(o.x-n)<=5&&Math.abs(o.y-r)<=5&&(s=o.count+1),this.clickRecords.set(e,{target:t,x:n,y:r,time:i,count:s}),s}handleKeyboard(e){e.modifiers?this.modifiers={shiftKey:e.modifiers.shift??!1,ctrlKey:e.modifiers.ctrl??!1,altKey:e.modifiers.alt??!1,metaKey:e.modifiers.meta??!1}:this.modifiers=le(e.code,e.pressed,this.modifiers);let t=this.resolveKeyboardTarget();t&&(u(t,e),this.options.editableTextInput!==!1&&d(t,e))}resolveKeyboardTarget(){let e=this.options.keyboardTarget??`active-element`;return e===`document`?this.doc:e===`pointer-target`?U(this.doc,this.lastX,this.lastY)??this.doc:this.doc.activeElement??this.doc.body??this.doc}};function se(e,t){return e===t||e.contains(t)?e:t.contains(e)?t:e}const ce={ShiftLeft:`shiftKey`,ShiftRight:`shiftKey`,ControlLeft:`ctrlKey`,ControlRight:`ctrlKey`,AltLeft:`altKey`,AltRight:`altKey`,MetaLeft:`metaKey`,MetaRight:`metaKey`,OSLeft:`metaKey`,OSRight:`metaKey`};function le(e,t,n){let r=ce[e];return!r||n[r]===t?n:{...n,[r]:t}}const Z=i(null);function Q({children:e,...t}){let[n]=s(()=>new X(t)),{pointerSource:r,keyboardSource:i}=t;return o(()=>{n.setPointerSource(r??null)},[n,r]),o(()=>{n.setKeyboardSource(i??null)},[n,i]),o(()=>(n.start(),()=>n.stop()),[n]),c(Z,{value:n,children:e})}function $(){let e=a(Z);if(!e)throw Error(`useMimoForwarder must be used inside <MimoProvider>`);return e}function ue({pointer:i,keyboard:a}){let s=$(),c=t();return o(()=>{if(!i)return;let{x:t,y:n}=e(c.x,c.y);s.injectPointer({kind:`move`,x:t,y:n})},[s,i,c.x,c.y]),r({onButton:t=>{if(!i)return;let{x:n,y:r}=e(t.x,t.y),a=t.button===`other`?`aux1`:t.button;s.injectPointer({kind:`button`,x:n,y:r,button:a,pressed:t.pressed})},onWheel:t=>{if(!i)return;let{x:n,y:r}=e(t.x,t.y);s.injectPointer({kind:`wheel`,x:n,y:r,deltaX:t.deltaX,deltaY:t.deltaY})}}),n({onKeyDown:e=>{a&&s.injectKeyboard({code:e.code,pressed:!0,repeat:e.repeat,modifiers:{shift:e.modifiers.shift,ctrl:e.modifiers.control,alt:e.modifiers.alt,meta:e.modifiers.meta}})},onKeyUp:e=>{a&&s.injectKeyboard({code:e.code,pressed:!1,modifiers:{shift:e.modifiers.shift,ctrl:e.modifiers.control,alt:e.modifiers.alt,meta:e.modifiers.meta}})}}),null}function de({pointer:e=!0,keyboard:t=!0,children:n,...r}){return ee(Q,{...r,children:[c(ue,{pointer:e,keyboard:t}),n]})}export{X as MimoForwarder,Z as MimoForwarderContext,Q as MimoForwarderProvider,de as MimoProvider,$ as useMimoForwarder};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{useEffect as e,useRef as t,useState as n}from"react";const r=`boxSizing.width.height.overflowX.overflowY.borderTopWidth.borderRightWidth.borderBottomWidth.borderLeftWidth.borderStyle.paddingTop.paddingRight.paddingBottom.paddingLeft.fontStyle.fontVariant.fontWeight.fontStretch.fontSize.fontSizeAdjust.lineHeight.fontFamily.textAlign.textTransform.textIndent.letterSpacing.wordSpacing.tabSize.MozTabSize.direction`.split(`.`);function i(e,t){if(typeof document>`u`)return null;let n=e instanceof HTMLInputElement,i=e.value,a=Math.max(0,Math.min(i.length,t??e.selectionStart??0)),o=window.getComputedStyle(e),s=document.createElement(`div`),c=s.style;c.position=`absolute`,c.top=`0`,c.left=`-9999px`,c.visibility=`hidden`,c.pointerEvents=`none`,c.whiteSpace=n?`pre`:`pre-wrap`,c.wordWrap=`break-word`,c.overflowWrap=`break-word`,c.overflow=`hidden`;for(let e of r)c[e]=o[e]??``;n&&(c.height=`auto`,c.whiteSpace=`pre`,c.overflowX=`hidden`);let l=i.substring(0,a);s.textContent=n?l.replace(/ /g,`\xA0`):l;let u=document.createElement(`span`);if(u.textContent=``,u.style.display=`inline-block`,u.style.width=`0`,s.appendChild(u),!n){let e=i.substring(a);s.appendChild(document.createTextNode(e.length>0?e:`.`))}document.body.appendChild(s);let d=e.getBoundingClientRect(),f=u.getBoundingClientRect(),p=s.getBoundingClientRect();return document.body.removeChild(s),{x:d.left+(f.left-p.left)-e.scrollLeft,y:d.top+(f.top-p.top)-e.scrollTop,height:f.height||parseFloat(o.lineHeight)||parseFloat(o.fontSize)*1.2}}function a(e,t,n){let r=e.value.length;if(r===0)return 0;let a=e instanceof HTMLInputElement,o=0,s=r;if(!a){let t=0,a=r,c=-1;for(;t<=a;){let r=t+a>>1,o=i(e,r);if(!o)break;o.y<=n+.5?(c=r,t=r+1):a=r-1}c<0&&(c=0);let l=i(e,c);if(!l)return c;let u=l.y;for(t=0,a=c;t<a;){let n=t+a>>1,r=i(e,n);!r||r.y<u-.5?t=n+1:a=n}for(o=t,t=c,a=r;t<a;){let n=t+a+1>>1,r=i(e,n);!r||r.y>u+.5?a=n-1:t=n}s=t}if(s<=o)return o;let c=o,l=s;for(;c<l;){let n=c+l>>1,r=i(e,n);!r||r.x<t?c=n+1:l=n}let u=c,d=Math.max(o,c-1),f=i(e,u),p=i(e,d);return p&&f?Math.abs(p.x-t)<=Math.abs(f.x-t)?d:u:p?d:u}function o(e,t,n){if(t===n)return[];let r=Math.min(t,n),a=Math.max(t,n),o=i(e,r),s=i(e,a);if(!o||!s)return[];if(Math.abs(s.y-o.y)<.5)return[{x:o.x,y:o.y,width:Math.max(0,s.x-o.x),height:o.height}];let c=e.getBoundingClientRect(),l=o.height,u=s.y-o.y-l,d=[{x:o.x,y:o.y,width:Math.max(0,c.right-o.x),height:l}];return u>0&&d.push({x:c.left,y:o.y+l,width:c.width,height:u}),d.push({x:c.left,y:s.y,width:Math.max(0,s.x-c.left),height:s.height}),d}function s(e,t){return{x:(e+1)/2*window.innerWidth,y:(1-t)/2*window.innerHeight}}function c(e,t){return{x:e/window.innerWidth*2-1,y:1-t/window.innerHeight*2}}function l(e){if(!e)return null;let t=new URLSearchParams(window.location.search),n=t.get(`fluxlay_port`)||`1421`,r=t.get(`window_label`)||`main`;return`http://127.0.0.1:${n}/v1/file?window_label=${encodeURIComponent(r)}&path=${encodeURIComponent(e)}`}function u(e){if(!(e instanceof HTMLElement))return!1;if(e instanceof HTMLInputElement){let t=e.type;return t===``||t===`text`||t===`search`||t===`email`||t===`tel`||t===`url`||t===`password`}return!!(e instanceof HTMLTextAreaElement||e.isContentEditable)}var d=class{target=null;tracked=null;showCaret;onCaretChange;overlay=null;selectionOverlay=null;desiredVerticalX=null;caretListenersAttached=!1;rafHandle=null;onSelectionChange=()=>this.scheduleCaretRefresh();onTargetScroll=()=>this.scheduleCaretRefresh();onWindowResize=()=>this.scheduleCaretRefresh();dragState=null;onTargetPointerDown=e=>{if(!e.isPrimary)return;let t=this.target;if(!t||!_(t))return;t.focus();let n=a(t,e.clientX,e.clientY);t.setSelectionRange(n,n,`none`),this.dragState={anchor:n,pointerId:e.pointerId,capturing:!1};try{t.setPointerCapture(e.pointerId),this.dragState.capturing=!0}catch{}this.scheduleCaretRefresh()};onTargetPointerMove=e=>{let t=this.target;if(!t||!_(t))return;let n=this.dragState;if(!n||n.pointerId!==e.pointerId)return;let r=a(t,e.clientX,e.clientY),i=Math.min(n.anchor,r),o=Math.max(n.anchor,r),s=r<n.anchor?`backward`:r>n.anchor?`forward`:`none`;t.setSelectionRange(i,o,s),this.scheduleCaretRefresh()};onTargetPointerUp=e=>{if(!this.dragState||this.dragState.pointerId!==e.pointerId)return;let t=this.target;if(this.dragState.capturing&&t&&_(t))try{t.releasePointerCapture(e.pointerId)}catch{}this.dragState=null,this.scheduleCaretRefresh()};onTargetPointerCancel=e=>{this.dragState&&this.dragState.pointerId===e.pointerId&&(this.dragState=null)};constructor(e={}){this.showCaret=e.showCaret??!1,this.onCaretChange=e.onCaretChange}getTarget(){return this.target}setTarget(e){let t=this.target;t&&_(t)&&this.tracked&&b(t,this.tracked.start,this.tracked.length),t!==e&&this.detachCaretListeners(t),this.target=e,this.tracked=null,e&&_(e)?(this.attachCaretListeners(e),this.scheduleCaretRefresh()):this.clearCaret()}updateComposition(e,t){let n=this.target;if(!n||!_(n))return;if(this.desiredVerticalX=null,e===null){this.tracked&&=(b(n,this.tracked.start,this.tracked.length),null),this.scheduleCaretRefresh();return}if(this.tracked===null){let e=n.selectionStart??n.value.length;this.tracked={start:e,length:0}}let r=this.tracked;v(n,r.start,r.length,e);let i=r.start+t;n.setSelectionRange(i,i),this.tracked={start:r.start,length:e.length},this.scheduleCaretRefresh()}applyCommand(e){let t=this.target;if(!t||!_(t))return;let n=t.selectionStart??t.value.length,r=t.selectionEnd??n,i=r>n;S(e)||(this.desiredVerticalX=null);try{this.applyCommandInner(t,e,n,r,i)}finally{this.scheduleCaretRefresh()}}applyCommandInner(e,t,n,r,i){switch(t){case`deleteBackward:`:i?(v(e,n,r-n,``),e.setSelectionRange(n,n)):n>0&&(v(e,n-1,1,``),e.setSelectionRange(n-1,n-1));return;case`deleteForward:`:i?(v(e,n,r-n,``),e.setSelectionRange(n,n)):n<e.value.length&&(v(e,n,1,``),e.setSelectionRange(n,n));return;case`deleteWordBackward:`:{if(i){v(e,n,r-n,``),e.setSelectionRange(n,n);return}let t=T(e.value,n);t<n&&(v(e,t,n-t,``),e.setSelectionRange(t,t));return}case`deleteWordForward:`:{if(i){v(e,n,r-n,``),e.setSelectionRange(n,n);return}let t=E(e.value,n);t>n&&(v(e,n,t-n,``),e.setSelectionRange(n,n));return}case`moveLeft:`:{let t=i?n:Math.max(0,n-1);e.setSelectionRange(t,t);return}case`moveRight:`:{let t=i?r:Math.min(e.value.length,n+1);e.setSelectionRange(t,t);return}case`moveLeftAndModifySelection:`:{let{anchor:t,focus:i}=m(e,n,r);h(e,t,Math.max(0,i-1));return}case`moveRightAndModifySelection:`:{let{anchor:t,focus:i}=m(e,n,r);h(e,t,Math.min(e.value.length,i+1));return}case`moveToBeginningOfLine:`:case`moveToLeftEndOfLine:`:case`moveToBeginningOfParagraph:`:case`moveToBeginningOfDocument:`:e.setSelectionRange(0,0);return;case`moveToEndOfLine:`:case`moveToRightEndOfLine:`:case`moveToEndOfParagraph:`:case`moveToEndOfDocument:`:{let t=e.value.length;e.setSelectionRange(t,t);return}case`moveToBeginningOfLineAndModifySelection:`:case`moveToLeftEndOfLineAndModifySelection:`:case`moveToBeginningOfParagraphAndModifySelection:`:case`moveToBeginningOfDocumentAndModifySelection:`:{let{anchor:t}=m(e,n,r);h(e,t,0);return}case`moveToEndOfLineAndModifySelection:`:case`moveToRightEndOfLineAndModifySelection:`:case`moveToEndOfParagraphAndModifySelection:`:case`moveToEndOfDocumentAndModifySelection:`:{let{anchor:t}=m(e,n,r);h(e,t,e.value.length);return}case`moveWordLeft:`:case`moveWordBackward:`:{let t=T(e.value,n);e.setSelectionRange(t,t);return}case`moveWordRight:`:case`moveWordForward:`:{let t=E(e.value,r);e.setSelectionRange(t,t);return}case`moveWordLeftAndModifySelection:`:case`moveWordBackwardAndModifySelection:`:{let{anchor:t,focus:i}=m(e,n,r);h(e,t,T(e.value,i));return}case`moveWordRightAndModifySelection:`:case`moveWordForwardAndModifySelection:`:{let{anchor:t,focus:i}=m(e,n,r);h(e,t,E(e.value,i));return}case`selectAll:`:e.setSelectionRange(0,e.value.length);return;case`insertNewline:`:case`insertLineBreak:`:case`insertParagraphSeparator:`:if(e instanceof HTMLTextAreaElement){v(e,n,r-n,`
|
|
2
|
+
`);let t=n+1;e.setSelectionRange(t,t)}else e.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Enter`,bubbles:!0}));return;case`insertTab:`:e.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Tab`,bubbles:!0}));return;case`moveUp:`:case`moveDown:`:if(e instanceof HTMLTextAreaElement){let r=C(e,n,t===`moveUp:`?`up`:`down`,this.desiredVerticalX);this.desiredVerticalX=r.desiredX,e.setSelectionRange(r.pos,r.pos)}else e.dispatchEvent(new KeyboardEvent(`keydown`,{key:t===`moveUp:`?`ArrowUp`:`ArrowDown`,bubbles:!0}));return;case`moveUpAndModifySelection:`:case`moveDownAndModifySelection:`:if(e instanceof HTMLTextAreaElement){let{anchor:i,focus:a}=m(e,n,r),o=C(e,a,t===`moveUpAndModifySelection:`?`up`:`down`,this.desiredVerticalX);this.desiredVerticalX=o.desiredX,h(e,i,o.pos)}else e.dispatchEvent(new KeyboardEvent(`keydown`,{key:t===`moveUpAndModifySelection:`?`ArrowUp`:`ArrowDown`,shiftKey:!0,bubbles:!0}));return;default:return}}commit(e){let t=this.target;if(t){if(this.desiredVerticalX=null,_(t)){if(this.tracked){v(t,this.tracked.start,this.tracked.length,e);let n=this.tracked.start+e.length;t.setSelectionRange(n,n),this.tracked=null}else{let n=t.selectionStart??t.value.length;v(t,n,0,e);let r=n+e.length;t.setSelectionRange(r,r)}return}t.isContentEditable&&document.execCommand(`insertText`,!1,e),this.scheduleCaretRefresh()}}attachCaretListeners(e){this.caretListenersAttached||(this.caretListenersAttached=!0,document.addEventListener(`selectionchange`,this.onSelectionChange),e.addEventListener(`scroll`,this.onTargetScroll,{passive:!0}),e.addEventListener(`pointerdown`,this.onTargetPointerDown),e.addEventListener(`pointermove`,this.onTargetPointerMove),e.addEventListener(`pointerup`,this.onTargetPointerUp),e.addEventListener(`pointercancel`,this.onTargetPointerCancel),window.addEventListener(`resize`,this.onWindowResize))}detachCaretListeners(e){this.caretListenersAttached&&(this.caretListenersAttached=!1,document.removeEventListener(`selectionchange`,this.onSelectionChange),e&&(e.removeEventListener(`scroll`,this.onTargetScroll),e.removeEventListener(`pointerdown`,this.onTargetPointerDown),e.removeEventListener(`pointermove`,this.onTargetPointerMove),e.removeEventListener(`pointerup`,this.onTargetPointerUp),e.removeEventListener(`pointercancel`,this.onTargetPointerCancel)),window.removeEventListener(`resize`,this.onWindowResize),this.dragState=null)}scheduleCaretRefresh(){if(this.rafHandle===null){if(typeof requestAnimationFrame>`u`){this.refreshCaret();return}this.rafHandle=requestAnimationFrame(()=>{this.rafHandle=null,this.refreshCaret()})}}refreshCaret(){let e=this.target;if(!e||!_(e)){this.clearCaret();return}let t=e.selectionStart??0,n=e.selectionEnd??t,r=n>t;if(this.showCaret)if(r){let r=o(e,t,n);this.ensureSelectionOverlay().show(r,this.resolveSelectionColor(e)),this.overlay?.hide()}else{this.selectionOverlay?.hide();let t=i(e);t&&this.ensureOverlay().show(t,this.resolveCaretColor(e))}let a=i(e,e.selectionDirection===`backward`?t:n);this.onCaretChange?.(a)}clearCaret(){this.rafHandle!==null&&(cancelAnimationFrame(this.rafHandle),this.rafHandle=null),this.overlay?.hide(),this.selectionOverlay?.hide(),this.onCaretChange?.(null)}ensureOverlay(){return this.overlay||=new f,this.overlay}ensureSelectionOverlay(){return this.selectionOverlay||=new p,this.selectionOverlay}resolveCaretColor(e){let t=window.getComputedStyle(e);return t.caretColor&&t.caretColor!==`auto`?t.caretColor:t.color}resolveSelectionColor(e){return`rgba(0, 122, 255, 0.35)`}},f=class{el=null;show(e,t){if(!this.el){g();let e=document.createElement(`div`);e.setAttribute(`data-fluxlay-ime-caret`,``);let t=e.style;t.position=`fixed`,t.width=`1px`,t.pointerEvents=`none`,t.zIndex=`2147483647`,t.willChange=`left, top, height`,t.animation=`fluxlay-ime-caret-blink 1.06s ease-in-out infinite`,document.body.appendChild(e),this.el=e}let n=this.el.style;n.left=`${e.x}px`,n.top=`${e.y}px`,n.height=`${e.height}px`,n.background=t,n.display=`block`}hide(){this.el&&(this.el.style.display=`none`)}},p=class{container=null;rectEls=[];show(e,t){if(!this.container){let e=document.createElement(`div`);e.setAttribute(`data-fluxlay-ime-selection`,``);let t=e.style;t.position=`fixed`,t.left=`0`,t.top=`0`,t.pointerEvents=`none`,t.zIndex=`2147483646`,document.body.appendChild(e),this.container=e}for(;this.rectEls.length<e.length;){let e=document.createElement(`div`),t=e.style;t.position=`fixed`,t.pointerEvents=`none`,t.willChange=`left, top, width, height`,this.container.appendChild(e),this.rectEls.push(e)}for(let n=0;n<this.rectEls.length;n++){let r=this.rectEls[n];if(n<e.length){let i=e[n],a=r.style;a.left=`${i.x}px`,a.top=`${i.y}px`,a.width=`${i.width}px`,a.height=`${i.height}px`,a.background=t,a.display=`block`}else r.style.display=`none`}}hide(){for(let e of this.rectEls)e.style.display=`none`}};function m(e,t,n){return e.selectionDirection===`backward`?{anchor:n,focus:t}:{anchor:t,focus:n}}function h(e,t,n){let r=Math.min(t,n),i=Math.max(t,n),a=n<t?`backward`:n>t?`forward`:`none`;e.setSelectionRange(r,i,a)}function g(){if(typeof document>`u`||document.getElementById(`fluxlay-ime-caret-style`))return;let e=document.createElement(`style`);e.id=`fluxlay-ime-caret-style`,e.textContent=`@keyframes fluxlay-ime-caret-blink{0%,40%{opacity:1}50%,90%{opacity:0}100%{opacity:1}}`,document.head.appendChild(e)}function _(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement}function v(e,t,n,r){y(e,e.value.slice(0,t)+r+e.value.slice(t+n)),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function y(e,t){let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,r=Object.getOwnPropertyDescriptor(n,`value`);r&&typeof r.set==`function`?r.set.call(e,t):e.value=t}function b(e,t,n){v(e,t,n,``),e.setSelectionRange(t,t)}const x=/[\p{L}\p{N}_]/u;function S(e){return e===`moveUp:`||e===`moveDown:`||e===`moveUpAndModifySelection:`||e===`moveDownAndModifySelection:`}function C(e,t,n,r){let a=i(e,t);if(!a)return{pos:w(e.value,t,n),desiredX:r??0};let o=r??a.x,s=a.height,c=s*.4,l=a.y+(n===`up`?-s:s),u=e.value.length;if(n===`up`){let t=i(e,0);if(t&&l<t.y-c)return{pos:0,desiredX:o}}else{let t=i(e,u);if(t&&l>t.y+c)return{pos:u,desiredX:o}}let d=0,f=u;for(;d<f;){let t=d+f>>1,n=i(e,t);!n||n.y<l-c?d=t+1:f=t}let p=d;for(d=p,f=u;d<f;){let t=d+f+1>>1,n=i(e,t);!n||n.y>l+c?f=t-1:d=t}let m=d;for(d=p,f=m;d<f;){let t=d+f>>1,n=i(e,t);!n||n.x<o?d=t+1:f=t}let h=d,g=Math.max(p,d-1),_=i(e,h),v=i(e,g),y=h;return v&&_?y=Math.abs(v.x-o)<=Math.abs(_.x-o)?g:h:v&&!_&&(y=g),{pos:y,desiredX:o}}function w(e,t,n){let r=t<=0?0:e.lastIndexOf(`
|
|
3
|
+
`,t-1)+1,i=t-r;if(n===`up`){if(r===0)return 0;let t=r-1,n=t===0?0:e.lastIndexOf(`
|
|
4
|
+
`,t-1)+1;return n+Math.min(i,t-n)}let a=e.indexOf(`
|
|
5
|
+
`,t);if(a===-1)return e.length;let o=a+1,s=e.indexOf(`
|
|
6
|
+
`,o),c=s===-1?e.length:s;return o+Math.min(i,c-o)}function T(e,t){let n=t;for(;n>0&&/\s/.test(e[n-1]??``);)n--;for(;n>0&&x.test(e[n-1]??``);)n--;return n}function E(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??``);)n++;for(;n<e.length&&x.test(e[n]??``);)n++;return n}var D=class{get baseUrl(){return`http://127.0.0.1:${new URLSearchParams(window.location.search).get(`fluxlay_port`)||`1421`}/v1`}pendingInvokes=new Map;subscriptions=new Map;async invoke(e,t){let n=new URLSearchParams(window.location.search).get(`window_label`)||`main`,r=`${e}:${n}:${JSON.stringify(t)}`;if(this.pendingInvokes.has(r))return this.pendingInvokes.get(r);let i=(async()=>{try{let r=await fetch(`${this.baseUrl}/${e}?window_label=${n}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok)throw Error(`Failed to invoke ${e}: ${r.statusText}`);return await r.json()}finally{this.pendingInvokes.delete(r)}})();return this.pendingInvokes.set(r,i),i}subscribe(e,t,n){let r=new URLSearchParams(window.location.search).get(`window_label`)||`main`,i=new URLSearchParams({window_label:r,...n}),a=`${this.baseUrl}/${e}?${i.toString()}`,o=a,s=this.subscriptions.get(o);if(!s){let t=new AbortController,n=new Set;s={controller:t,listeners:n},this.subscriptions.set(o,s);let r=t=>{for(let r of[...n])try{r(t)}catch(t){console.error(`Error in subscription handler for ${e}:`,t)}};(async()=>{try{let n=await fetch(a,{signal:t.signal});if(!n.ok||!n.body)throw Error(`Failed to subscribe to ${e}: ${n.statusText}`);let i=n.body.getReader(),o=new TextDecoder,s=``;for(;;){let{done:e,value:t}=await i.read();if(e)break;s+=o.decode(t,{stream:!0});let n=s.split(`
|
|
7
|
+
`);s=n.pop()||``;for(let e of n){let t=e.trim();if(t)try{r(JSON.parse(t))}catch(e){console.error(`Failed to parse NDJSON line:`,e)}}}}catch(t){t.name!==`AbortError`&&console.error(`Error in subscription to ${e}:`,t)}finally{this.subscriptions.get(o)===s&&this.subscriptions.delete(o)}})()}return s.listeners.add(t),()=>{let e=this.subscriptions.get(o);e&&(e.listeners.delete(t),e.listeners.size===0&&(e.controller.abort(),this.subscriptions.delete(o)))}}};const O=new D;async function k(e,t){return await O.invoke(`run-script`,{scriptId:e,columns:t?.columns,lines:t?.lines})}const A=new D,j={dark:{default:{background:`#00000000`,foreground:`#ffffff`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#e2e8f0`,cursor:`#00000000`,black:`#1e293b`,red:`#f43f5e`,green:`#10b981`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#8b5cf6`,cyan:`#06b6d4`,white:`#f1f5f9`,brightBlack:`#475569`,brightRed:`#fb7185`,brightGreen:`#34d399`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#a78bfa`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`}},light:{default:{background:`#00000000`,foreground:`#18181b`,cursor:`#00000000`,black:`#000000`,red:`#ef4444`,green:`#22c55e`,yellow:`#f59e0b`,blue:`#3b82f6`,magenta:`#a855f7`,cyan:`#06b6d4`,white:`#ffffff`,brightBlack:`#71717a`,brightRed:`#f87171`,brightGreen:`#4ade80`,brightYellow:`#fbbf24`,brightBlue:`#60a5fa`,brightMagenta:`#c084fc`,brightCyan:`#22d3ee`,brightWhite:`#ffffff`},modern:{background:`#00000000`,foreground:`#334155`,cursor:`#00000000`,black:`#0f172a`,red:`#dc2626`,green:`#16a34a`,yellow:`#d97706`,blue:`#2563eb`,magenta:`#7c3aed`,cyan:`#0891b2`,white:`#f8fafc`,brightBlack:`#64748b`,brightRed:`#ef4444`,brightGreen:`#22c55e`,brightYellow:`#f59e0b`,brightBlue:`#3b82f6`,brightMagenta:`#8b5cf6`,brightCyan:`#06b6d4`,brightWhite:`#ffffff`}},nord:{background:`#2E3440`,foreground:`#D8DEE9`,cursor:`#D8DEE9`,black:`#3B4252`,red:`#BF616A`,green:`#A3BE8C`,yellow:`#EBCB8B`,blue:`#81A1C1`,magenta:`#B48EAD`,cyan:`#88C0D0`,white:`#E5E9F0`,brightBlack:`#4C566A`,brightRed:`#BF616A`,brightGreen:`#A3BE8C`,brightYellow:`#EBCB8B`,brightBlue:`#81A1C1`,brightMagenta:`#B48EAD`,brightCyan:`#8FBCBB`,brightWhite:`#ECEFF4`},dracula:{background:`#282a36`,foreground:`#f8f8f2`,cursor:`#f8f8f2`,black:`#21222c`,red:`#ff5555`,green:`#50fa7b`,yellow:`#f1fa8c`,blue:`#bd93f9`,magenta:`#ff79c6`,cyan:`#8be9fd`,white:`#f8f8f2`,brightBlack:`#6272a4`,brightRed:`#ff6e6e`,brightGreen:`#69ff94`,brightYellow:`#ffffa5`,brightBlue:`#d6acff`,brightMagenta:`#ff92df`,brightCyan:`#a4ffff`,brightWhite:`#ffffff`},gruvbox:{dark:{background:`#282828`,foreground:`#ebdbb2`,cursor:`#ebdbb2`,black:`#282828`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#a89984`,brightBlack:`#928374`,brightRed:`#fb4934`,brightGreen:`#b8bb26`,brightYellow:`#fabd2f`,brightBlue:`#83a598`,brightMagenta:`#d3869b`,brightCyan:`#8ec07c`,brightWhite:`#ebdbb2`},light:{background:`#fbf1c7`,foreground:`#3c3836`,cursor:`#3c3836`,black:`#fbf1c7`,red:`#cc241d`,green:`#98971a`,yellow:`#d79921`,blue:`#458588`,magenta:`#b16286`,cyan:`#689d6a`,white:`#7c6f64`,brightBlack:`#928374`,brightRed:`#9d0006`,brightGreen:`#79740e`,brightYellow:`#b57614`,brightBlue:`#076678`,brightMagenta:`#8f3f71`,brightCyan:`#427b58`,brightWhite:`#3c3836`}},solarized:{dark:{background:`#002b36`,foreground:`#839496`,cursor:`#93a1a1`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`},light:{background:`#fdf6e3`,foreground:`#657b83`,cursor:`#586e75`,black:`#073642`,red:`#dc322f`,green:`#859900`,yellow:`#b58900`,blue:`#268bd2`,magenta:`#d33682`,cyan:`#2aa198`,white:`#eee8d5`,brightBlack:`#002b36`,brightRed:`#cb4b16`,brightGreen:`#586e75`,brightYellow:`#657b83`,brightBlue:`#839496`,brightMagenta:`#6c71c4`,brightCyan:`#93a1a1`,brightWhite:`#fdf6e3`}},oneDark:{background:`#282c34`,foreground:`#abb2bf`,cursor:`#528bff`,black:`#282c34`,red:`#e06c75`,green:`#98c379`,yellow:`#e5c07b`,blue:`#61afef`,magenta:`#c678dd`,cyan:`#56b6c2`,white:`#abb2bf`,brightBlack:`#5c6370`,brightRed:`#e06c75`,brightGreen:`#98c379`,brightYellow:`#e5c07b`,brightBlue:`#61afef`,brightMagenta:`#c678dd`,brightCyan:`#56b6c2`,brightWhite:`#ffffff`},catppuccin:{latte:{background:`#eff1f5`,foreground:`#4c4f69`,cursor:`#dc8a78`,black:`#5c5f77`,red:`#d20f39`,green:`#40a02b`,yellow:`#df8e1d`,blue:`#1e66f5`,magenta:`#ea76cb`,cyan:`#179299`,white:`#acb0be`,brightBlack:`#6c6f85`,brightRed:`#d20f39`,brightGreen:`#40a02b`,brightYellow:`#df8e1d`,brightBlue:`#1e66f5`,brightMagenta:`#ea76cb`,brightCyan:`#179299`,brightWhite:`#bcc0cc`},frappe:{background:`#303446`,foreground:`#c6d0f5`,cursor:`#f2d5cf`,black:`#51576d`,red:`#e78284`,green:`#a6d189`,yellow:`#e5c890`,blue:`#8caaee`,magenta:`#f4b8e4`,cyan:`#81c8be`,white:`#b5bfe2`,brightBlack:`#626880`,brightRed:`#e78284`,brightGreen:`#a6d189`,brightYellow:`#e5c890`,brightBlue:`#8caaee`,brightMagenta:`#f4b8e4`,brightCyan:`#81c8be`,brightWhite:`#a5adce`},macchiato:{background:`#24273a`,foreground:`#cad3f5`,cursor:`#f4dbd6`,black:`#494d64`,red:`#ed8796`,green:`#a6da95`,yellow:`#eed49f`,blue:`#8aadf4`,magenta:`#f5bde6`,cyan:`#8bd5ca`,white:`#b8c0e0`,brightBlack:`#5b6078`,brightRed:`#ed8796`,brightGreen:`#a6da95`,brightYellow:`#eed49f`,brightBlue:`#8aadf4`,brightMagenta:`#f5bde6`,brightCyan:`#8bd5ca`,brightWhite:`#a5adcb`},mocha:{background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`}},monokaiPro:{background:`#2D2A2E`,foreground:`#FCFCFA`,cursor:`#FCFCFA`,black:`#403E41`,red:`#FF6188`,green:`#A9DC76`,yellow:`#FFD866`,blue:`#FC9867`,magenta:`#AB9DF2`,cyan:`#78DCE8`,white:`#FCFCFA`,brightBlack:`#727072`,brightRed:`#FF6188`,brightGreen:`#A9DC76`,brightYellow:`#FFD866`,brightBlue:`#FC9867`,brightMagenta:`#AB9DF2`,brightCyan:`#78DCE8`,brightWhite:`#FCFCFA`},tokyoNight:{background:`#1a1b26`,foreground:`#a9b1d6`,cursor:`#c0caf5`,black:`#32344a`,red:`#f7768e`,green:`#9ece6a`,yellow:`#e0af68`,blue:`#7aa2f7`,magenta:`#ad8ee6`,cyan:`#449dab`,white:`#787c99`,brightBlack:`#444b6a`,brightRed:`#ff7a93`,brightGreen:`#b9f27c`,brightYellow:`#ff9e64`,brightBlue:`#7da6ff`,brightMagenta:`#bb9af7`,brightCyan:`#0db9d7`,brightWhite:`#acb0d0`},nightOwl:{background:`#011627`,foreground:`#d6deeb`,cursor:`#80a4c2`,black:`#011627`,red:`#ef5350`,green:`#22da6e`,yellow:`#addb67`,blue:`#82aaff`,magenta:`#c792ea`,cyan:`#21c7a8`,white:`#ffffff`,brightBlack:`#575656`,brightRed:`#ef5350`,brightGreen:`#22da6e`,brightYellow:`#ffeb95`,brightBlue:`#82aaff`,brightMagenta:`#c792ea`,brightCyan:`#7fdbca`,brightWhite:`#ffffff`},everforest:{dark:{background:`#2b3339`,foreground:`#d3c6aa`,cursor:`#d3c6aa`,black:`#4b565c`,red:`#e67e80`,green:`#a7c080`,yellow:`#dbbc7f`,blue:`#7fbbb3`,magenta:`#d699b6`,cyan:`#83c092`,white:`#d3c6aa`,brightBlack:`#4b565c`,brightRed:`#e67e80`,brightGreen:`#a7c080`,brightYellow:`#dbbc7f`,brightBlue:`#7fbbb3`,brightMagenta:`#d699b6`,brightCyan:`#83c092`,brightWhite:`#d3c6aa`},light:{background:`#fdf6e3`,foreground:`#5c6a72`,cursor:`#5c6a72`,black:`#fdf6e3`,red:`#f85552`,green:`#8da101`,yellow:`#dfa000`,blue:`#3a94c5`,magenta:`#df69ba`,cyan:`#35a77c`,white:`#dfddc8`,brightBlack:`#5c6a72`,brightRed:`#f85552`,brightGreen:`#8da101`,brightYellow:`#dfa000`,brightBlue:`#3a94c5`,brightMagenta:`#df69ba`,brightCyan:`#35a77c`,brightWhite:`#5c6a72`}}};typeof document<`u`&&M();function M(){let e=null,t=!1,n=()=>{if(t||e===null)return;let r=e;e=null,t=!0,A.invoke(`ime-update-caret`,{caret:r}).catch(()=>{}).finally(()=>{t=!1,e&&n()})},r=new d({showCaret:!0,onCaretChange:t=>{t!==null&&(e=t,n())}}),i=!1,a=()=>{i||(i=!0,A.subscribe(`ime-composition-stream`,e=>{let t=e.text===``?null:e.text;r.updateComposition(t,e.cursor)}),A.subscribe(`ime-commit-stream`,e=>{e.type===`commit`?r.commit(e.text):r.applyCommand(e.kind)}))},o=e=>{let t=e.getBoundingClientRect();A.invoke(`ime-activate`,{caret:{x:t.left,y:t.top,height:t.height}}).catch(()=>{})};document.addEventListener(`focusin`,e=>{let t=e.target;u(t)&&(a(),r.setTarget(t),o(t))}),document.addEventListener(`focusout`,e=>{e.target===r.getTarget()&&(r.setTarget(null),A.invoke(`ime-deactivate`,{}).catch(()=>{}))}),document.addEventListener(`pointerdown`,e=>{let t=e.target;if(!(t instanceof HTMLElement))return;let n=r.getTarget();n&&(t===n||n.contains(t))&&(a(),o(n))})}const N=new D;function P(n){let r=t(n);r.current=n,e(()=>{let e=N.subscribe(`keyboard-stream`,e=>{e.pressed?r.current.onKeyDown?.(e):r.current.onKeyUp?.(e)});return()=>{e()}},[])}const F=new D;function I(){let[t,r]=n({x:0,y:0});return e(()=>{let e=new URLSearchParams(window.location.search).get(`window_label`)||`main`,t=F.subscribe(`mouse-stream`,e=>{r({x:e.x,y:-e.y})},{window_label:e});return()=>{t()}},[]),t}const L=new D;function R(n){let r=t(n);r.current=n,e(()=>{let e=new URLSearchParams(window.location.search).get(`window_label`)||`main`,t=L.subscribe(`mouse-event-stream`,e=>{e.type===`button`?r.current.onButton?.({...e,y:-e.y}):e.type===`wheel`&&r.current.onWheel?.({...e,y:-e.y})},{window_label:e});return()=>{t()}},[])}export{k as a,d as c,l as d,o as f,D as h,A as i,s as l,i as m,I as n,j as o,u as p,P as r,c as s,R as t,a as u};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluxlay/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "SDK for building Fluxlay wallpapers with React",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"desktop",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
".": {
|
|
22
22
|
"types": "./dist/index.d.mts",
|
|
23
23
|
"default": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./mimo": {
|
|
26
|
+
"types": "./dist/mimo/index.d.mts",
|
|
27
|
+
"default": "./dist/mimo/index.mjs"
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
"scripts": {
|
|
@@ -28,6 +32,8 @@
|
|
|
28
32
|
"check": "oxlint --type-aware --type-check --fix && oxfmt --write ."
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
35
|
+
"@fluxlay/sdk-core": "1.2.0",
|
|
36
|
+
"@mimo/react": "0.1.0",
|
|
31
37
|
"@xterm/addon-fit": "^0.11.0",
|
|
32
38
|
"@xterm/xterm": "^6.0.0"
|
|
33
39
|
},
|