@fluxlay/react 1.3.1 → 1.3.2
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
CHANGED
|
@@ -20,7 +20,7 @@ The SDK ships its own styles (xterm CSS is imported automatically by `useTermina
|
|
|
20
20
|
|
|
21
21
|
Wallpapers run in an isolated `fluxlay://` origin with a minimal Content Security Policy enforced by the desktop app. As a result:
|
|
22
22
|
|
|
23
|
-
- **No external hosts.** `fetch` / `XMLHttpRequest` / `WebSocket` to arbitrary origins is blocked by `connect-src`. The only non-`'self'` endpoint allowed by default is the local Fluxlay API (`http://127.0.0.1:*`), which the SDK uses internally. To reach an external host, declare it under `network:` in `fluxlay.yaml` — its scheme + host[:port] is then injected into `connect-src` / `img-src` / `media-src` / `font-src` (passive resources only; never `script-src`).
|
|
23
|
+
- **No external hosts.** `fetch` / `XMLHttpRequest` / `WebSocket` to arbitrary origins is blocked by `connect-src`. The only non-`'self'` endpoint allowed by default is the local Fluxlay API (`http://127.0.0.1:*`), which the SDK uses internally. To reach an external host, declare it under `network:` in `fluxlay.yaml` — its scheme + host[:port] is then injected into `connect-src` / `img-src` / `media-src` / `font-src` (passive resources only; never `script-src`). For declared hosts that don't return `Access-Control-Allow-Origin` (e.g. Google Calendar ICS feeds), use `proxiedFetch` to route the request through the host process and bypass CORS.
|
|
24
24
|
- **No `eval` / `new Function`.** `script-src` is `'self'` only — no `'unsafe-eval'`, no `'unsafe-inline'`. Bundlers, template engines, and runtime-compiled code paths that rely on `eval` will not run. (Dev mode loosens this for HMR; production does not.)
|
|
25
25
|
- **No `__TAURI__.core.invoke`.** Wallpaper windows are excluded from every Tauri capability, so `invoke` is unavailable. All host interactions must go through SDK hooks, which talk to the local API over HTTP / WebSocket.
|
|
26
26
|
- **Inline styles are allowed** (`style-src 'self' 'unsafe-inline'`) so React `style={...}` and CSS-in-JS keep working.
|
|
@@ -331,6 +331,53 @@ function Wallpaper() {
|
|
|
331
331
|
|
|
332
332
|
Returns `{ terminalRef, instance }`.
|
|
333
333
|
|
|
334
|
+
### `proxiedFetch(input, init?)`
|
|
335
|
+
|
|
336
|
+
`fetch`-compatible wrapper that routes the request through the Fluxlay host process. Use this for declared `network:` origins that don't return `Access-Control-Allow-Origin` (e.g. ICS feeds, public RSS endpoints) — the host issues the upstream request as a regular HTTP client, so browser CORS does not apply. The host validates that the target URL's origin is declared in this wallpaper's `network:` manifest entries; non-declared origins return 403.
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
import { proxiedFetch } from "@fluxlay/react";
|
|
340
|
+
|
|
341
|
+
const res = await proxiedFetch("https://calendar.google.com/calendar/ical/.../basic.ics");
|
|
342
|
+
const text = await res.text();
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Restrictions vs. native `fetch`:
|
|
346
|
+
|
|
347
|
+
- Only `http:` / `https:` URLs are accepted.
|
|
348
|
+
- `Cookie` / `Origin` / `Host` / `Referer` request headers are stripped.
|
|
349
|
+
- Response body is capped at 10 MiB; streaming is not supported (the upstream body is fully buffered).
|
|
350
|
+
- Forwarded response headers are limited to `Content-Type`, `Cache-Control`, `ETag`, `Last-Modified`.
|
|
351
|
+
|
|
352
|
+
### `openUrl(url)`
|
|
353
|
+
|
|
354
|
+
Opens an `http:` / `https:` URL in the user's default browser via `tauri-plugin-opener`. Wallpapers cannot navigate the OS shell directly, so this is the only path to make in-wallpaper links clickable.
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { openUrl } from "@fluxlay/react";
|
|
358
|
+
|
|
359
|
+
<button onClick={() => void openUrl("https://github.com/fluxlay/monorepo")}>Open</button>;
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Throws when the host rejects the URL (non-http(s) scheme) or fails to launch the browser.
|
|
363
|
+
|
|
364
|
+
### `notify(options)`
|
|
365
|
+
|
|
366
|
+
Posts an OS-level notification (Notification Center on macOS, Action Center on Windows) via `tauri-plugin-notification`. The browser `Notification` API is not usable from sandboxed wallpaper origins, so this is the supported way to surface events from a running wallpaper.
|
|
367
|
+
|
|
368
|
+
```ts
|
|
369
|
+
import { notify } from "@fluxlay/react";
|
|
370
|
+
|
|
371
|
+
await notify({ title: "Build finished", body: "All tests passed" });
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
| Option | Type | Description |
|
|
375
|
+
| ------- | -------- | ---------------------------------------- |
|
|
376
|
+
| `title` | `string` | Required. Shown as the notification title. |
|
|
377
|
+
| `body` | `string` | Optional. Shown as the notification body. |
|
|
378
|
+
|
|
379
|
+
The first call from a freshly installed Fluxlay app may trigger an OS-level permission prompt; subsequent calls succeed silently if the user grants notification permission.
|
|
380
|
+
|
|
334
381
|
### `runShell(commandId, options?)`
|
|
335
382
|
|
|
336
383
|
Low-level function to run a shell command imperatively.
|
package/dist/index.d.mts
CHANGED
|
@@ -114,6 +114,43 @@ declare function pixelToNormalized(x: number, y: number): {
|
|
|
114
114
|
* the active wallpaper. Returns `null` when the path is missing.
|
|
115
115
|
*/
|
|
116
116
|
declare function getPropertyFileUrl(path: string | null | undefined): string | null; //#endregion
|
|
117
|
+
//#region src/host-actions.d.ts
|
|
118
|
+
/**
|
|
119
|
+
* Host-side side effects that the wallpaper webview cannot trigger directly.
|
|
120
|
+
*
|
|
121
|
+
* Both functions POST to Fluxlay's local HTTP API on `127.0.0.1:<fluxlay_port>`.
|
|
122
|
+
* The host validates the origin (must be a wallpaper window) and performs the
|
|
123
|
+
* action via Tauri plugins (`tauri-plugin-opener`, `tauri-plugin-notification`).
|
|
124
|
+
*/
|
|
125
|
+
/**
|
|
126
|
+
* Open `url` in the user's default browser.
|
|
127
|
+
*
|
|
128
|
+
* The wallpaper webview is sandboxed and cannot navigate the OS shell. This
|
|
129
|
+
* helper asks the Fluxlay host to open the URL with `tauri-plugin-opener`,
|
|
130
|
+
* which routes to the system default handler (Chrome / Safari / etc.). Only
|
|
131
|
+
* `http:` / `https:` URLs are accepted; anything else is rejected by the host.
|
|
132
|
+
*
|
|
133
|
+
* Typical use: making links inside a wallpaper clickable.
|
|
134
|
+
*
|
|
135
|
+
* @throws An error if the host rejects the URL or fails to open it.
|
|
136
|
+
*/
|
|
137
|
+
declare function openUrl(url: string): Promise<void>;
|
|
138
|
+
interface NotifyOptions {
|
|
139
|
+
title: string;
|
|
140
|
+
body?: string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Show an OS-level notification (Notification Center on macOS, Action Center
|
|
144
|
+
* on Windows) via `tauri-plugin-notification`.
|
|
145
|
+
*
|
|
146
|
+
* Wallpapers cannot use the browser `Notification` API (no permission prompt
|
|
147
|
+
* pathway exists for sandboxed origins). This helper asks the Fluxlay host to
|
|
148
|
+
* post the notification on the wallpaper's behalf. The first call may trigger
|
|
149
|
+
* an OS-level permission prompt for the Fluxlay app.
|
|
150
|
+
*
|
|
151
|
+
* @throws An error if the host fails to deliver the notification.
|
|
152
|
+
*/
|
|
153
|
+
declare function notify(options: NotifyOptions): Promise<void>; //#endregion
|
|
117
154
|
//#region src/ime-inline.d.ts
|
|
118
155
|
/**
|
|
119
156
|
* Predicate: is `el` an element on which we want to auto-handle IME?
|
|
@@ -254,6 +291,35 @@ declare class ImeInlineController {
|
|
|
254
291
|
private resolveCaretColor;
|
|
255
292
|
private resolveSelectionColor;
|
|
256
293
|
} //#endregion
|
|
294
|
+
//#region src/proxied-fetch.d.ts
|
|
295
|
+
/**
|
|
296
|
+
* `fetch` replacement that routes the request through Fluxlay's host-side
|
|
297
|
+
* HTTP proxy.
|
|
298
|
+
*
|
|
299
|
+
* The wallpaper webview is sandboxed by CSP `connect-src` and is also subject
|
|
300
|
+
* to standard browser CORS rules. Many real-world endpoints (Google Calendar
|
|
301
|
+
* ICS, public RSS feeds, etc.) do not return `Access-Control-Allow-Origin`
|
|
302
|
+
* headers, so a direct `fetch` from the wallpaper fails even when the origin
|
|
303
|
+
* is declared in `network[]` of `fluxlay.yaml`.
|
|
304
|
+
*
|
|
305
|
+
* `proxiedFetch` POSTs the desired request to the local Fluxlay API
|
|
306
|
+
* (`/v1/network-proxy`), which the Rust host issues as a regular HTTP request
|
|
307
|
+
* — bypassing the browser's CORS policy. The host validates that the target
|
|
308
|
+
* URL's origin is declared in this wallpaper's `network[]` manifest entries,
|
|
309
|
+
* so the security model is identical to direct fetch (no new attack surface).
|
|
310
|
+
*
|
|
311
|
+
* The returned `Response` contains the upstream status, body, and the subset
|
|
312
|
+
* of upstream headers that the host forwards (`Content-Type`, `Cache-Control`,
|
|
313
|
+
* `ETag`, `Last-Modified`).
|
|
314
|
+
*
|
|
315
|
+
* Restrictions vs. native `fetch`:
|
|
316
|
+
* - Only `http:` / `https:` schemes are supported.
|
|
317
|
+
* - `Cookie` / `Origin` / `Host` / `Referer` request headers are stripped.
|
|
318
|
+
* - Response body is capped at 10 MiB.
|
|
319
|
+
* - Streaming response bodies are not supported (the upstream body is fully
|
|
320
|
+
* buffered before being returned).
|
|
321
|
+
*/
|
|
322
|
+
declare function proxiedFetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>; //#endregion
|
|
257
323
|
//#region src/transport/index.d.ts
|
|
258
324
|
/** The result returned after executing a shell command. */
|
|
259
325
|
interface ShellResult {
|
|
@@ -1002,4 +1068,4 @@ interface SystemMonitorOptions {
|
|
|
1002
1068
|
*/
|
|
1003
1069
|
declare function useSystemMonitor(options?: SystemMonitorOptions): SystemMonitorInfo;
|
|
1004
1070
|
//#endregion
|
|
1005
|
-
export { AudioInfo, AudioOptions, CaretRect, DiskInfo, HttpTransport, ImeCommitHandler, type ImeCommitPayload, type ImeCompositionPayload, ImeInlineController, ImeInlineControllerOptions, ImeInputApi, InvokeMethodMap, type KeyEvent, type KeyModifiers, KeyboardHandlers, ManifestInfo, MediaMetadataInfo, MediaMetadataOptions, type MouseButton, type MouseButtonEvent, MouseEventHandlers, type MouseInputEvent, MousePosition, type MouseWheelEvent, PropertyValue, PropertyValues, SelectionRect, ShellOptions, type ShellResult, SubscribeEventMap, SystemMonitorInfo, SystemMonitorOptions, TerminalInstance, TerminalThemes, Transport, UseShellOptions, UseTerminalOptions, caretIndexFromClientPoint, defaultTransport, getPropertyFileUrl, isImeAutoTarget, measureCaretRect, measureSelectionRects, normalizedToPixel, pixelToNormalized, runShell, useActiveElement, useAudio, useImeInput, useIsFocused, useKeyboard, useMediaMetadata, useMouseEvents, useMousePosition, useProperties, useShell, useSystemMonitor, useTerminal };
|
|
1071
|
+
export { AudioInfo, AudioOptions, CaretRect, DiskInfo, HttpTransport, ImeCommitHandler, type ImeCommitPayload, type ImeCompositionPayload, ImeInlineController, ImeInlineControllerOptions, ImeInputApi, InvokeMethodMap, type KeyEvent, type KeyModifiers, KeyboardHandlers, ManifestInfo, MediaMetadataInfo, MediaMetadataOptions, type MouseButton, type MouseButtonEvent, MouseEventHandlers, type MouseInputEvent, MousePosition, type MouseWheelEvent, NotifyOptions, PropertyValue, PropertyValues, SelectionRect, ShellOptions, type ShellResult, SubscribeEventMap, SystemMonitorInfo, SystemMonitorOptions, TerminalInstance, TerminalThemes, Transport, UseShellOptions, UseTerminalOptions, caretIndexFromClientPoint, defaultTransport, getPropertyFileUrl, isImeAutoTarget, measureCaretRect, measureSelectionRects, normalizedToPixel, notify, openUrl, pixelToNormalized, proxiedFetch, runShell, useActiveElement, useAudio, useImeInput, useIsFocused, useKeyboard, useMediaMetadata, useMouseEvents, useMousePosition, useProperties, useShell, useSystemMonitor, useTerminal };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{
|
|
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)}},[
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,u as g,v as _}from"./use-mouse-events-7jatubKJ.mjs";import{useCallback as v,useEffect as y,useRef as b,useState as x}from"react";import{FitAddon as S}from"@xterm/addon-fit";import{Terminal as C}from"@xterm/xterm";import"@xterm/xterm/css/xterm.css";function w(){let[e,t]=x(()=>typeof document>`u`?null:T());return y(()=>{let e=()=>t(T());return e(),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,e),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,e)}},[]),e}function T(){let e=document.activeElement;return!e||e===document.body||e===document.documentElement?null:e}const E=new m;function D(e){let[t,n]=x({rms:0,peak:0,spectrum:[]}),r=e?.numBands;return y(()=>{let e={};r!==void 0&&(e.num_bands=String(r));let t=E.subscribe(`audio-stream`,e=>n(e),e);return()=>{t()}},[r]),t}function O(){let[e,t]=x(null),[n,r]=x(0),a=b(new Set),o=b(!1);y(()=>{let e=i.subscribe(`ime-composition-stream`,e=>{t(e.text===``?null:e.text),r(e.cursor)}),n=i.subscribe(`ime-commit-stream`,e=>{if(e.type===`commit`)for(let t of a.current)t(e.text)});return()=>{e(),n()}},[]);let s=v(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);i.invoke(`ime-activate`,t?{caret:t}:{}).catch(()=>{})},[]),c=v(()=>{o.current=!1,i.invoke(`ime-deactivate`,{}).catch(()=>{})},[]),l=v(e=>(a.current.add(e),()=>{a.current.delete(e)}),[]);return y(()=>()=>{o.current&&=(i.invoke(`ime-deactivate`,{}).catch(()=>{}),!1)},[]),{composition:e,cursor:n,activate:s,deactivate:c,onCommit:l}}function k(e){let[t,n]=x(!1);return y(()=>{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 A=new m;function j(e){let[t,n]=x({title:null,artist:null,album:null,artwork:null,duration:null,elapsedTime:null,playbackRate:null,isPlaying:!1}),r=e?.intervalMs;return y(()=>{let e={};r!==void 0&&(e.interval_ms=String(r));let t=A.subscribe(`media-metadata-stream`,e=>n(e),e);return()=>{t()}},[r]),t}const M=new m;function N(){let[e,t]=x({});return y(()=>{M.invoke(`properties`,{}).then(e=>t(e));let e=M.subscribe(`properties-stream`,e=>t(e));return()=>{e()}},[]),e}function P(e,t={}){let{showStdout:n=!0,showStderr:r=!1,refreshInterval:i=3e4,terminal:a}=t,[o,c]=x(!1),[l,u]=x(null),[d,f]=x(null),p=b(t);y(()=>{p.current=t},[t]);let m=v(async()=>{if(!o){c(!0),u(null);try{let t=p.current,n=t.columns,r=t.lines;a&&(a.fitAddon.fit(),n=a.terminal.cols,r=a.terminal.rows);let i=await s(e,{...t,columns:n,lines:r});f(i),i.success||u(`Command failed with status ${i.statusCode}: ${i.stderr}`)}catch(e){u(String(e))}finally{c(!1)}}},[e,a]);return y(()=>{if(!a||!d)return;let{terminal:e}=a;if(e.reset(),d.success){let t=``;n&&(t+=d.stdout),r&&(t+=d.stderr);let i=t.trimEnd();if(i){e.write(i);let t=i.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)}},[a,d,n,r]),y(()=>{m()},[e]),y(()=>{if(!i)return;let e=setInterval(m,i);return()=>clearInterval(e)},[m,i]),{execute:m,isRunning:o,error:l,result:d}}const F=new m;function I(e){let[t,n]=x({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 y(()=>{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=F.subscribe(`system-monitor-stream`,e=>n(e),e);return()=>{t()}},[r,i,a,o,s,c,l,u]),t}function L(e={}){let{fontSize:t=12,fontFamily:n=`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`,theme:r=d.dark.default}=e,i=b(null),[a,o]=x(null);return y(()=>{if(!i.current)return;let e=document.createElement(`style`);e.textContent=`
|
|
3
3
|
.xterm-char-measure-element {
|
|
4
4
|
position: absolute !important;
|
|
5
5
|
top: 0 !important;
|
|
@@ -28,4 +28,4 @@ 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 a
|
|
|
28
28
|
.xterm-selection {
|
|
29
29
|
display: none !important; /* Hide xterm's own selection overlay. */
|
|
30
30
|
}
|
|
31
|
-
`,document.head.appendChild(e);let a=new
|
|
31
|
+
`,document.head.appendChild(e);let a=new C({fontSize:t,fontFamily:n,disableStdin:!0,cursorBlink:!1,convertEol:!0,scrollback:0,theme:r}),s=new S;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{m as HttpTransport,g as ImeInlineController,d as TerminalThemes,l as caretIndexFromClientPoint,i as defaultTransport,o as getPropertyFileUrl,_ as isImeAutoTarget,e as measureCaretRect,a as measureSelectionRects,r as normalizedToPixel,f as notify,c as openUrl,n as pixelToNormalized,t as proxiedFetch,s as runShell,w as useActiveElement,D as useAudio,O as useImeInput,k as useIsFocused,p as useKeyboard,j as useMediaMetadata,h as useMouseEvents,u as useMousePosition,N as useProperties,P as useShell,I as useSystemMonitor,L as useTerminal};
|
package/dist/mimo/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,n as t,r as n,t as r}from"../use-mouse-events-7jatubKJ.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
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};
|
|
@@ -1,7 +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
|
|
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=
|
|
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(){return`http://127.0.0.1:${new URLSearchParams(window.location.search).get(`fluxlay_port`)||`1421`}/v1`}async function d(e){let t=await fetch(`${u()}/open-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`openUrl failed: ${t.status} ${e}`)}}async function f(e){let t=await fetch(`${u()}/notify`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`notify failed: ${t.status} ${e}`)}}function p(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 m=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||!b(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||!b(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&&b(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&&b(t)&&this.tracked&&C(t,this.tracked.start,this.tracked.length),t!==e&&this.detachCaretListeners(t),this.target=e,this.tracked=null,e&&b(e)?(this.attachCaretListeners(e),this.scheduleCaretRefresh()):this.clearCaret()}updateComposition(e,t){let n=this.target;if(!n||!b(n))return;if(this.desiredVerticalX=null,e===null){this.tracked&&=(C(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;x(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||!b(t))return;let n=t.selectionStart??t.value.length,r=t.selectionEnd??n,i=r>n;T(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?(x(e,n,r-n,``),e.setSelectionRange(n,n)):n>0&&(x(e,n-1,1,``),e.setSelectionRange(n-1,n-1));return;case`deleteForward:`:i?(x(e,n,r-n,``),e.setSelectionRange(n,n)):n<e.value.length&&(x(e,n,1,``),e.setSelectionRange(n,n));return;case`deleteWordBackward:`:{if(i){x(e,n,r-n,``),e.setSelectionRange(n,n);return}let t=O(e.value,n);t<n&&(x(e,t,n-t,``),e.setSelectionRange(t,t));return}case`deleteWordForward:`:{if(i){x(e,n,r-n,``),e.setSelectionRange(n,n);return}let t=k(e.value,n);t>n&&(x(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}=_(e,n,r);v(e,t,Math.max(0,i-1));return}case`moveRightAndModifySelection:`:{let{anchor:t,focus:i}=_(e,n,r);v(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}=_(e,n,r);v(e,t,0);return}case`moveToEndOfLineAndModifySelection:`:case`moveToRightEndOfLineAndModifySelection:`:case`moveToEndOfParagraphAndModifySelection:`:case`moveToEndOfDocumentAndModifySelection:`:{let{anchor:t}=_(e,n,r);v(e,t,e.value.length);return}case`moveWordLeft:`:case`moveWordBackward:`:{let t=O(e.value,n);e.setSelectionRange(t,t);return}case`moveWordRight:`:case`moveWordForward:`:{let t=k(e.value,r);e.setSelectionRange(t,t);return}case`moveWordLeftAndModifySelection:`:case`moveWordBackwardAndModifySelection:`:{let{anchor:t,focus:i}=_(e,n,r);v(e,t,O(e.value,i));return}case`moveWordRightAndModifySelection:`:case`moveWordForwardAndModifySelection:`:{let{anchor:t,focus:i}=_(e,n,r);v(e,t,k(e.value,i));return}case`selectAll:`:e.setSelectionRange(0,e.value.length);return;case`insertNewline:`:case`insertLineBreak:`:case`insertParagraphSeparator:`:if(e instanceof HTMLTextAreaElement){x(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=E(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}=_(e,n,r),o=E(e,a,t===`moveUpAndModifySelection:`?`up`:`down`,this.desiredVerticalX);this.desiredVerticalX=o.desiredX,v(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,b(t)){if(this.tracked){x(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;x(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||!b(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 h,this.overlay}ensureSelectionOverlay(){return this.selectionOverlay||=new g,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)`}},h=class{el=null;show(e,t){if(!this.el){y();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`)}},g=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 _(e,t,n){return e.selectionDirection===`backward`?{anchor:n,focus:t}:{anchor:t,focus:n}}function v(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 y(){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 b(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement}function x(e,t,n,r){S(e,e.value.slice(0,t)+r+e.value.slice(t+n)),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function S(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 C(e,t,n){x(e,t,n,``),e.setSelectionRange(t,t)}const w=/[\p{L}\p{N}_]/u;function T(e){return e===`moveUp:`||e===`moveDown:`||e===`moveUpAndModifySelection:`||e===`moveDownAndModifySelection:`}function E(e,t,n,r){let a=i(e,t);if(!a)return{pos:D(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 D(e,t,n){let r=t<=0?0:e.lastIndexOf(`
|
|
3
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
4
|
`,t-1)+1;return n+Math.min(i,t-n)}let a=e.indexOf(`
|
|
5
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
|
|
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
|
|
6
|
+
`,o),c=s===-1?e.length:s;return o+Math.min(i,c-o)}function O(e,t){let n=t;for(;n>0&&/\s/.test(e[n-1]??``);)n--;for(;n>0&&w.test(e[n-1]??``);)n--;return n}function k(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??``);)n++;for(;n<e.length&&w.test(e[n]??``);)n++;return n}async function A(e,t){let n=typeof e==`string`?e:e instanceof URL?e.toString():e.url,r=new URLSearchParams(window.location.search),i=r.get(`fluxlay_port`)||`1421`,a=r.get(`window_label`)||`main`,o=`http://127.0.0.1:${i}/v1/network-proxy?window_label=${encodeURIComponent(a)}`,s={};t?.headers&&new Headers(t.headers).forEach((e,t)=>{s[t]=e});let c;return t?.body!==void 0&&t.body!==null&&(c=typeof t.body==`string`?t.body:await new Response(t.body).text()),fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`},signal:t?.signal??null,body:JSON.stringify({method:t?.method??`GET`,url:n,headers:s,body:c})})}var j=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 M=new j;async function N(e,t){return await M.invoke(`run-script`,{scriptId:e,columns:t?.columns,lines:t?.lines})}const P=new j,F={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`&&I();function I(){let e=null,t=!1,n=()=>{if(t||e===null)return;let r=e;e=null,t=!0,P.invoke(`ime-update-caret`,{caret:r}).catch(()=>{}).finally(()=>{t=!1,e&&n()})},r=new m({showCaret:!0,onCaretChange:t=>{t!==null&&(e=t,n())}}),i=!1,a=()=>{i||(i=!0,P.subscribe(`ime-composition-stream`,e=>{let t=e.text===``?null:e.text;r.updateComposition(t,e.cursor)}),P.subscribe(`ime-commit-stream`,e=>{e.type===`commit`?r.commit(e.text):r.applyCommand(e.kind)}))},o=e=>{let t=e.getBoundingClientRect();P.invoke(`ime-activate`,{caret:{x:t.left,y:t.top,height:t.height}}).catch(()=>{})};document.addEventListener(`focusin`,e=>{let t=e.target;p(t)&&(a(),r.setTarget(t),o(t))}),document.addEventListener(`focusout`,e=>{e.target===r.getTarget()&&(r.setTarget(null),P.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 L=new j;function R(n){let r=t(n);r.current=n,e(()=>{let e=L.subscribe(`keyboard-stream`,e=>{e.pressed?r.current.onKeyDown?.(e):r.current.onKeyUp?.(e)});return()=>{e()}},[])}const z=new j;function B(){let[t,r]=n({x:0,y:0});return e(()=>{let e=new URLSearchParams(window.location.search).get(`window_label`)||`main`,t=z.subscribe(`mouse-stream`,e=>{r({x:e.x,y:-e.y})},{window_label:e});return()=>{t()}},[]),t}const V=new j;function H(n){let r=t(n);r.current=n,e(()=>{let e=new URLSearchParams(window.location.search).get(`window_label`)||`main`,t=V.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{i as _,A as a,c,s as d,P as f,o as g,l as h,N as i,d as l,a as m,B as n,F as o,f as p,R as r,j as s,H as t,m as u,p as v};
|