strata-react 1.3.18 → 1.3.20
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 +33 -8
- package/UPGRADING.md +7 -1
- package/dist/{errors-jep2voNI.js → button-KGJI6jQr.js} +3 -95
- package/dist/button-KGJI6jQr.js.map +1 -0
- package/dist/components/byte-view.d.ts +32 -0
- package/dist/components/console.d.ts +34 -0
- package/dist/components/disclosure.d.ts +2 -0
- package/dist/components/file-intake.d.ts +9 -0
- package/dist/components/hotkeys.d.ts +4 -0
- package/dist/components/media-contents.d.ts +28 -0
- package/dist/components/media-player.d.ts +6 -1
- package/dist/components/pixel-image.d.ts +29 -0
- package/dist/components/shortcut-editor.d.ts +44 -0
- package/dist/components/tree.d.ts +4 -2
- package/dist/components/workflow-steps.d.ts +35 -0
- package/dist/components/workspace.d.ts +22 -2
- package/dist/errors-BUvY1Z4d.js +95 -0
- package/dist/errors-BUvY1Z4d.js.map +1 -0
- package/dist/{field-t4Hoer0d.js → field-BjeE_FeB.js} +6 -101
- package/dist/field-BjeE_FeB.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +1091 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/object-url.d.ts +2 -0
- package/dist/map.js +3 -2
- package/dist/map.js.map +1 -1
- package/dist/{microphone-B5ITwm4G.js → microphone-Bo3WaXgD.js} +5 -3
- package/dist/{microphone-B5ITwm4G.js.map → microphone-Bo3WaXgD.js.map} +1 -1
- package/dist/panorama.js +3 -3
- package/dist/scene/camera.d.ts +71 -0
- package/dist/scene/index.d.ts +2 -0
- package/dist/scene/scene-viewport.d.ts +46 -0
- package/dist/scene.js +526 -0
- package/dist/scene.js.map +1 -0
- package/dist/strata.bare.css +1 -0
- package/dist/strata.css +1 -0
- package/dist/strata.migrate.css +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/layout.d.ts +1 -1
- package/dist/testing/setup.d.ts +14 -0
- package/dist/testing.js +21 -5
- package/dist/testing.js.map +1 -1
- package/dist/{theme-DXacprlw.js → theme-CxYZkUNk.js} +3 -2
- package/dist/{theme-DXacprlw.js.map → theme-CxYZkUNk.js.map} +1 -1
- package/dist/tooltip-DhqrDtyu.js +103 -0
- package/dist/tooltip-DhqrDtyu.js.map +1 -0
- package/dist/{value-controls-DB5l5Qe2.js → value-controls-Dq2-QpvA.js} +8 -4
- package/dist/value-controls-Dq2-QpvA.js.map +1 -0
- package/package.json +6 -1
- package/dist/errors-jep2voNI.js.map +0 -1
- package/dist/field-t4Hoer0d.js.map +0 -1
- package/dist/value-controls-DB5l5Qe2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
1
|
+
import { i as typeSteps, n as KeyText, r as cn, t as Tooltip } from "./tooltip-DhqrDtyu.js";
|
|
2
|
+
import { a as Textarea, c as useSearchParam, d as createFormat, f as format, i as NativeSelect, l as MISSING, n as Field, o as useFieldControl, p as toDate, r as Input, s as controlHeight, t as ChoiceGroup, u as NBSP } from "./field-BjeE_FeB.js";
|
|
3
|
+
import { a as isDev, i as buttonVariants, n as IconButton, o as useInView, r as RowAction, t as Button } from "./button-KGJI6jQr.js";
|
|
4
|
+
import { A as StrataQueryProvider, C as toast, D as LoadError, E as EmptyState, F as useLoad, I as usePoll, L as overlaySurface, M as fetchJson, N as staleOf, O as Skeleton, P as toLoad, S as StrataToastRegion, T as DataView$1, _ as clampViewport, a as useMicrophone, b as viewportTransform, d as zoomToBox, f as FIT, g as boxViewport, h as actualPixelsScale, i as explainMicrophoneError, j as createQueryClient, k as StaleNotice, l as readingOrder, m as MIN_SCALE, n as MicrophoneError, o as Thumbnail, p as MAX_SCALE, r as browserMicrophone, s as ThumbnailSkeleton, t as MicrophoneContext, u as regionStyle, v as frameBoxToShares, w as toastTimeout, x as zoomAt, y as regionShares } from "./microphone-Bo3WaXgD.js";
|
|
5
|
+
import { a as useAsyncAction, c as KeysLegend, d as useHotkeys, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as keyName } from "./value-controls-Dq2-QpvA.js";
|
|
5
6
|
import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
|
|
6
|
-
import { a as
|
|
7
|
+
import { a as fieldErrorsOf, i as errorPayload, n as describeActionError, o as readErrorBody, r as describeHttpError, t as HttpError } from "./errors-BUvY1Z4d.js";
|
|
8
|
+
import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-CxYZkUNk.js";
|
|
7
9
|
import * as React from "react";
|
|
8
10
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, Input as Input$1, Keyboard, Link, ListBox, ListBoxItem, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, Popover as Popover$1, RouterProvider, Row, SearchField, Select, SelectValue, Separator, Slider as Slider$1, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Tree as Tree$1, TreeItem, TreeItemContent, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
9
11
|
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
@@ -2338,6 +2340,105 @@ function WorkflowSteps({ label, stages, onApprove, onRetry, words, now, classNam
|
|
|
2338
2340
|
})
|
|
2339
2341
|
});
|
|
2340
2342
|
}
|
|
2343
|
+
/** Reduces a run's stages to one state and the stage it is about. `running`: its job is queued or running. */
|
|
2344
|
+
function summariseWorkflow(stages, { running = false } = {}) {
|
|
2345
|
+
const total = stages.length;
|
|
2346
|
+
const done = stages.filter((s) => s.state === "done").length;
|
|
2347
|
+
const at = (state, find) => {
|
|
2348
|
+
const i = stages.findIndex(find);
|
|
2349
|
+
return i < 0 ? null : {
|
|
2350
|
+
state,
|
|
2351
|
+
stage: stages[i],
|
|
2352
|
+
step: i + 1,
|
|
2353
|
+
done,
|
|
2354
|
+
total
|
|
2355
|
+
};
|
|
2356
|
+
};
|
|
2357
|
+
if (running) return at("running", (s) => s.state !== "done") ?? {
|
|
2358
|
+
state: "running",
|
|
2359
|
+
done,
|
|
2360
|
+
total
|
|
2361
|
+
};
|
|
2362
|
+
return at("failed", (s) => s.state === "failed") ?? at("waiting", (s) => s.state === "waiting") ?? at("stale", (s) => s.state === "stale") ?? (done === total ? {
|
|
2363
|
+
state: "done",
|
|
2364
|
+
done,
|
|
2365
|
+
total
|
|
2366
|
+
} : done === 0 ? {
|
|
2367
|
+
state: "ready",
|
|
2368
|
+
done,
|
|
2369
|
+
total
|
|
2370
|
+
} : {
|
|
2371
|
+
state: "partial",
|
|
2372
|
+
done,
|
|
2373
|
+
total
|
|
2374
|
+
});
|
|
2375
|
+
}
|
|
2376
|
+
var SUMMARY_LOOKS = {
|
|
2377
|
+
running: {
|
|
2378
|
+
tone: "info",
|
|
2379
|
+
icon: Clock,
|
|
2380
|
+
word: (w) => w.running
|
|
2381
|
+
},
|
|
2382
|
+
failed: {
|
|
2383
|
+
tone: "danger",
|
|
2384
|
+
icon: CircleAlert,
|
|
2385
|
+
word: (w) => w.failed
|
|
2386
|
+
},
|
|
2387
|
+
waiting: {
|
|
2388
|
+
tone: "info",
|
|
2389
|
+
icon: Eye,
|
|
2390
|
+
word: (w) => w.waiting
|
|
2391
|
+
},
|
|
2392
|
+
stale: {
|
|
2393
|
+
tone: "warning",
|
|
2394
|
+
icon: RotateCcw,
|
|
2395
|
+
word: (w) => w.stale
|
|
2396
|
+
},
|
|
2397
|
+
done: {
|
|
2398
|
+
tone: "success",
|
|
2399
|
+
icon: Check,
|
|
2400
|
+
word: (w) => w.done
|
|
2401
|
+
},
|
|
2402
|
+
partial: {
|
|
2403
|
+
tone: "neutral",
|
|
2404
|
+
icon: CircleDashed,
|
|
2405
|
+
word: (w) => w.partial
|
|
2406
|
+
},
|
|
2407
|
+
ready: {
|
|
2408
|
+
tone: "neutral",
|
|
2409
|
+
icon: CircleDashed,
|
|
2410
|
+
word: (w) => w.ready
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2413
|
+
/** The sentence beside the word: which stage, and how far through. */
|
|
2414
|
+
function describeWorkflowSummary(s) {
|
|
2415
|
+
if (s.state === "running") return s.stage ? `${s.stage.title}, step ${s.step} of ${s.total}` : null;
|
|
2416
|
+
if (s.state === "partial") return `${s.done} of ${format.count(s.total, "step")} done`;
|
|
2417
|
+
return s.stage && s.state !== "done" && s.state !== "ready" ? s.stage.title : null;
|
|
2418
|
+
}
|
|
2419
|
+
/** A subject's run through a strata-python pipeline in a few words, for a list of subjects: running (on which step), failed (which), waiting for review (which gate), out of date, part done, or done. */
|
|
2420
|
+
function WorkflowSummary({ stages, running, words, className }) {
|
|
2421
|
+
const summary = summariseWorkflow(stages, { running });
|
|
2422
|
+
const look = SUMMARY_LOOKS[summary.state];
|
|
2423
|
+
const detail = describeWorkflowSummary(summary);
|
|
2424
|
+
const all = {
|
|
2425
|
+
...DEFAULT_WORDS,
|
|
2426
|
+
running: "Running",
|
|
2427
|
+
partial: "Part done",
|
|
2428
|
+
...words
|
|
2429
|
+
};
|
|
2430
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
2431
|
+
className: cn("inline-flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", className),
|
|
2432
|
+
children: [/* @__PURE__ */ jsx(Status, {
|
|
2433
|
+
tone: look.tone,
|
|
2434
|
+
icon: look.icon,
|
|
2435
|
+
children: look.word(all)
|
|
2436
|
+
}), detail && /* @__PURE__ */ jsx("span", {
|
|
2437
|
+
className: "type-body-sm text-muted-foreground",
|
|
2438
|
+
children: detail
|
|
2439
|
+
})]
|
|
2440
|
+
});
|
|
2441
|
+
}
|
|
2341
2442
|
// src/lib/breakpoint.ts
|
|
2342
2443
|
var DEFAULTS = {
|
|
2343
2444
|
sm: "40rem",
|
|
@@ -2713,6 +2814,12 @@ function api(expanded, set, single) {
|
|
|
2713
2814
|
else next.delete(key);
|
|
2714
2815
|
set(next);
|
|
2715
2816
|
},
|
|
2817
|
+
toggle: (key) => {
|
|
2818
|
+
const next = single ? /* @__PURE__ */ new Set() : new Set(expanded);
|
|
2819
|
+
if (expanded.has(key)) next.delete(key);
|
|
2820
|
+
else next.add(key);
|
|
2821
|
+
set(next);
|
|
2822
|
+
},
|
|
2716
2823
|
collapseAll: () => set(/* @__PURE__ */ new Set())
|
|
2717
2824
|
};
|
|
2718
2825
|
}
|
|
@@ -3350,6 +3457,59 @@ function FilmStrip({ label, frames, span, time, onSeek, aspect = "4/3", frameWid
|
|
|
3350
3457
|
})
|
|
3351
3458
|
});
|
|
3352
3459
|
}
|
|
3460
|
+
// src/components/media-contents.tsx
|
|
3461
|
+
/** The index of the item whose span holds `time`, or -1. */
|
|
3462
|
+
function currentItem(items, time) {
|
|
3463
|
+
if (time === void 0) return -1;
|
|
3464
|
+
return items.findIndex((it) => time >= it.start && time < it.end);
|
|
3465
|
+
}
|
|
3466
|
+
/** One media file's chapters as a list of contents beside its player: the one playing marked, and pressing one plays from its start. */
|
|
3467
|
+
function MediaContents({ label, items, time, onSeek, onSelect, className }) {
|
|
3468
|
+
const current = currentItem(items, time);
|
|
3469
|
+
return /* @__PURE__ */ jsx("ol", {
|
|
3470
|
+
"aria-label": label,
|
|
3471
|
+
className: cn("grid min-w-0 gap-0", className),
|
|
3472
|
+
children: items.map((item, i) => /* @__PURE__ */ jsx(ContentsRow, {
|
|
3473
|
+
item,
|
|
3474
|
+
current: i === current,
|
|
3475
|
+
onSeek,
|
|
3476
|
+
onSelect
|
|
3477
|
+
}, item.id))
|
|
3478
|
+
});
|
|
3479
|
+
}
|
|
3480
|
+
var ContentsRow = React.memo(function ContentsRow({ item, current, onSeek, onSelect }) {
|
|
3481
|
+
const from = format.runningTime(item.start);
|
|
3482
|
+
return /* @__PURE__ */ jsx("li", {
|
|
3483
|
+
"aria-current": current ? "time" : void 0,
|
|
3484
|
+
"data-current": current ? "" : void 0,
|
|
3485
|
+
children: /* @__PURE__ */ jsxs(Button$1, {
|
|
3486
|
+
"aria-label": `Play ${item.title}, from ${from}`,
|
|
3487
|
+
onPress: () => {
|
|
3488
|
+
onSeek(item.start);
|
|
3489
|
+
onSelect?.(item.id);
|
|
3490
|
+
},
|
|
3491
|
+
className: cn("grid w-full cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-3 gap-y-0.5 border-l-2 border-transparent px-3 py-2 text-left transition-state hover:bg-muted", current && "border-primary bg-accent hover:bg-accent"),
|
|
3492
|
+
children: [
|
|
3493
|
+
/* @__PURE__ */ jsx("span", {
|
|
3494
|
+
className: "type-label text-foreground",
|
|
3495
|
+
children: item.title
|
|
3496
|
+
}),
|
|
3497
|
+
/* @__PURE__ */ jsx("span", {
|
|
3498
|
+
className: "type-body-sm tabular-nums text-muted-foreground whitespace-nowrap",
|
|
3499
|
+
children: from
|
|
3500
|
+
}),
|
|
3501
|
+
item.detail ? /* @__PURE__ */ jsx("span", {
|
|
3502
|
+
className: "type-caption text-muted-foreground",
|
|
3503
|
+
children: item.detail
|
|
3504
|
+
}) : /* @__PURE__ */ jsx("span", {}),
|
|
3505
|
+
/* @__PURE__ */ jsxs("span", {
|
|
3506
|
+
className: "type-caption tabular-nums text-muted-foreground whitespace-nowrap",
|
|
3507
|
+
children: [format.runningTime(item.end - item.start), " long"]
|
|
3508
|
+
})
|
|
3509
|
+
]
|
|
3510
|
+
})
|
|
3511
|
+
});
|
|
3512
|
+
});
|
|
3353
3513
|
// src/components/fullscreen-frame.tsx
|
|
3354
3514
|
/** Whether this browser can show an element full screen. False in jsdom and on iPhone, where the modal fallback is used. */
|
|
3355
3515
|
function canFullscreen() {
|
|
@@ -4776,7 +4936,7 @@ function useCoarsePointer() {
|
|
|
4776
4936
|
* a touch device), with the failure to load shown and retried. For an editor or a replay, use the
|
|
4777
4937
|
* parts and `useMediaElement` directly.
|
|
4778
4938
|
*/
|
|
4779
|
-
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, className }) {
|
|
4939
|
+
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, className }) {
|
|
4780
4940
|
const list = React.useMemo(() => sources ?? (src ? [{
|
|
4781
4941
|
src,
|
|
4782
4942
|
title: label
|
|
@@ -5284,7 +5444,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5284
5444
|
}] : offsets ? list.map((s, i) => ({
|
|
5285
5445
|
time: offsets[i],
|
|
5286
5446
|
label: s.title
|
|
5287
|
-
})).slice(1) : [],
|
|
5447
|
+
})).slice(1) : !bound && marks || [],
|
|
5288
5448
|
step: JUMP,
|
|
5289
5449
|
bigStep: 60,
|
|
5290
5450
|
label: `Seek in ${label}`
|
|
@@ -7860,6 +8020,82 @@ function FileDropZone({ onFiles, acceptLabel, title, disabled, refuseTypes, chil
|
|
|
7860
8020
|
] })
|
|
7861
8021
|
});
|
|
7862
8022
|
}
|
|
8023
|
+
var carriesFiles = (e, refuse) => {
|
|
8024
|
+
const types = Array.from(e.dataTransfer?.types ?? []);
|
|
8025
|
+
return types.includes("Files") && !refusesDrag({ has: (type) => types.includes(type) }, ["application/x-strata-drag", ...refuse]);
|
|
8026
|
+
};
|
|
8027
|
+
/** While files are dragged anywhere over the window, a dim overlay names what is taken ("Drop to add PAK files"); a drop calls `onFiles`. The app's own drags never trigger it. Keep a `FileButton` beside it for the keyboard and phones. */
|
|
8028
|
+
function FileDropOverlay({ onFiles, acceptLabel, disabled, refuseTypes }) {
|
|
8029
|
+
const [over, setOver] = React.useState(false);
|
|
8030
|
+
const live = React.useRef({
|
|
8031
|
+
onFiles,
|
|
8032
|
+
refuseTypes: refuseTypes ?? []
|
|
8033
|
+
});
|
|
8034
|
+
live.current = {
|
|
8035
|
+
onFiles,
|
|
8036
|
+
refuseTypes: refuseTypes ?? []
|
|
8037
|
+
};
|
|
8038
|
+
React.useEffect(() => {
|
|
8039
|
+
if (disabled) return;
|
|
8040
|
+
let depth = 0;
|
|
8041
|
+
const reset = () => {
|
|
8042
|
+
depth = 0;
|
|
8043
|
+
setOver(false);
|
|
8044
|
+
};
|
|
8045
|
+
const enter = (e) => {
|
|
8046
|
+
if (!carriesFiles(e, live.current.refuseTypes)) return;
|
|
8047
|
+
depth += 1;
|
|
8048
|
+
setOver(true);
|
|
8049
|
+
};
|
|
8050
|
+
const hover = (e) => {
|
|
8051
|
+
if (!carriesFiles(e, live.current.refuseTypes)) return;
|
|
8052
|
+
e.preventDefault();
|
|
8053
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = "copy";
|
|
8054
|
+
};
|
|
8055
|
+
const leave = (e) => {
|
|
8056
|
+
if (!carriesFiles(e, live.current.refuseTypes)) return;
|
|
8057
|
+
depth = Math.max(0, depth - 1);
|
|
8058
|
+
if (depth === 0) setOver(false);
|
|
8059
|
+
};
|
|
8060
|
+
const drop = (e) => {
|
|
8061
|
+
const wanted = carriesFiles(e, live.current.refuseTypes);
|
|
8062
|
+
reset();
|
|
8063
|
+
if (!wanted || e.defaultPrevented) return;
|
|
8064
|
+
e.preventDefault();
|
|
8065
|
+
const files = Array.from(e.dataTransfer?.items ?? []).filter((i) => i.kind === "file").map((i) => i.getAsFile()).filter((f) => f !== null);
|
|
8066
|
+
const list = files.length ? files : Array.from(e.dataTransfer?.files ?? []);
|
|
8067
|
+
if (list.length) live.current.onFiles(list);
|
|
8068
|
+
};
|
|
8069
|
+
document.addEventListener("dragenter", enter);
|
|
8070
|
+
document.addEventListener("dragover", hover);
|
|
8071
|
+
document.addEventListener("dragleave", leave);
|
|
8072
|
+
document.addEventListener("drop", drop);
|
|
8073
|
+
document.addEventListener("dragend", reset);
|
|
8074
|
+
return () => {
|
|
8075
|
+
document.removeEventListener("dragenter", enter);
|
|
8076
|
+
document.removeEventListener("dragover", hover);
|
|
8077
|
+
document.removeEventListener("dragleave", leave);
|
|
8078
|
+
document.removeEventListener("drop", drop);
|
|
8079
|
+
document.removeEventListener("dragend", reset);
|
|
8080
|
+
};
|
|
8081
|
+
}, [disabled]);
|
|
8082
|
+
if (!over || disabled) return null;
|
|
8083
|
+
return /* @__PURE__ */ jsx("div", {
|
|
8084
|
+
"aria-hidden": true,
|
|
8085
|
+
"data-file-drop-overlay": true,
|
|
8086
|
+
className: "pointer-events-none fixed inset-0 layer-overlay grid place-items-center scrim p-6",
|
|
8087
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
8088
|
+
className: "flex items-center gap-3 rounded-overlay border-2 border-dashed border-primary bg-background px-6 py-5 shadow-overlay",
|
|
8089
|
+
children: [/* @__PURE__ */ jsx(Upload, {
|
|
8090
|
+
"aria-hidden": true,
|
|
8091
|
+
className: "size-5 text-primary"
|
|
8092
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
8093
|
+
className: "type-heading",
|
|
8094
|
+
children: ["Drop to add ", acceptLabel]
|
|
8095
|
+
})]
|
|
8096
|
+
})
|
|
8097
|
+
});
|
|
8098
|
+
}
|
|
7863
8099
|
var rowStatus = {
|
|
7864
8100
|
processing: {
|
|
7865
8101
|
tone: "info",
|
|
@@ -7976,6 +8212,812 @@ function MissingFile({ name, accept, onRelink, thumbnail, className }) {
|
|
|
7976
8212
|
})]
|
|
7977
8213
|
});
|
|
7978
8214
|
}
|
|
8215
|
+
// src/lib/object-url.ts
|
|
8216
|
+
/** Bytes (or a Blob) as an object URL: made once per value, revoked when the value changes or the component unmounts. `null` until made, and for `null` data. `type` is the MIME type for bytes ("audio/wav"); a Blob keeps its own unless `type` is given. */
|
|
8217
|
+
function useObjectUrl(data, type) {
|
|
8218
|
+
const [url, setUrl] = React.useState(null);
|
|
8219
|
+
React.useEffect(() => {
|
|
8220
|
+
if (data === null || data === void 0) {
|
|
8221
|
+
setUrl(null);
|
|
8222
|
+
return;
|
|
8223
|
+
}
|
|
8224
|
+
const blob = data instanceof Blob && (type === void 0 || data.type === type) ? data : new Blob([data], type ? { type } : void 0);
|
|
8225
|
+
const made = URL.createObjectURL(blob);
|
|
8226
|
+
setUrl(made);
|
|
8227
|
+
return () => {
|
|
8228
|
+
URL.revokeObjectURL(made);
|
|
8229
|
+
setUrl((now) => now === made ? null : now);
|
|
8230
|
+
};
|
|
8231
|
+
}, [data, type]);
|
|
8232
|
+
return url;
|
|
8233
|
+
}
|
|
8234
|
+
// src/components/pixel-image.tsx
|
|
8235
|
+
var sizeOf = (p) => p.image ? {
|
|
8236
|
+
width: p.image.width,
|
|
8237
|
+
height: p.image.height,
|
|
8238
|
+
data: p.image.data
|
|
8239
|
+
} : {
|
|
8240
|
+
width: p.width,
|
|
8241
|
+
height: p.height,
|
|
8242
|
+
data: p.rgba
|
|
8243
|
+
};
|
|
8244
|
+
/** The zoom a picture is drawn at: a whole number, at least 1. */
|
|
8245
|
+
function pixelZoom(width, height, zoom = "fit", maxSize = 512) {
|
|
8246
|
+
if (typeof zoom === "number") return Math.max(1, Math.round(zoom));
|
|
8247
|
+
return Math.max(1, Math.floor(maxSize / Math.max(1, width, height)));
|
|
8248
|
+
}
|
|
8249
|
+
/** A decoded RGBA picture on a canvas at a whole-number zoom with square pixels, a checkerboard behind clear pixels, named with its size. */
|
|
8250
|
+
function PixelImage({ label, zoom = "fit", maxSize = 512, className, ...source }) {
|
|
8251
|
+
const { width, height, data } = sizeOf(source);
|
|
8252
|
+
const canvas = React.useRef(null);
|
|
8253
|
+
const complete = data.length === width * height * 4 && width > 0 && height > 0;
|
|
8254
|
+
const scale = pixelZoom(width, height, zoom, maxSize);
|
|
8255
|
+
React.useEffect(() => {
|
|
8256
|
+
const el = canvas.current;
|
|
8257
|
+
if (!el || !complete) return;
|
|
8258
|
+
let ctx = null;
|
|
8259
|
+
try {
|
|
8260
|
+
ctx = el.getContext("2d");
|
|
8261
|
+
} catch {
|
|
8262
|
+
ctx = null;
|
|
8263
|
+
}
|
|
8264
|
+
if (!ctx) return;
|
|
8265
|
+
const picture = ctx.createImageData(width, height);
|
|
8266
|
+
picture.data.set(data);
|
|
8267
|
+
ctx.putImageData(picture, 0, 0);
|
|
8268
|
+
}, [
|
|
8269
|
+
data,
|
|
8270
|
+
width,
|
|
8271
|
+
height,
|
|
8272
|
+
complete
|
|
8273
|
+
]);
|
|
8274
|
+
if (!complete) return /* @__PURE__ */ jsx("span", {
|
|
8275
|
+
role: "img",
|
|
8276
|
+
"aria-label": `${label}, no picture data`,
|
|
8277
|
+
className: cn("inline-grid min-h-16 min-w-40 place-items-center rounded-control border border-dashed border-border bg-surface-sunken px-3 type-body-sm text-muted-foreground", className),
|
|
8278
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
8279
|
+
"aria-hidden": true,
|
|
8280
|
+
children: "No picture data"
|
|
8281
|
+
})
|
|
8282
|
+
});
|
|
8283
|
+
const name = `${label}, ${format.integer(width)} by ${format.integer(height)} pixels${scale > 1 ? `, shown at ${scale}×` : ""}`;
|
|
8284
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8285
|
+
className: cn("inline-block w-fit max-w-full overflow-auto rounded-control align-top", className),
|
|
8286
|
+
style: {
|
|
8287
|
+
backgroundColor: "var(--surface-sunken)",
|
|
8288
|
+
backgroundImage: "conic-gradient(var(--muted) 25%, transparent 0 50%, var(--muted) 0 75%, transparent 0)",
|
|
8289
|
+
backgroundSize: "16px 16px"
|
|
8290
|
+
},
|
|
8291
|
+
children: /* @__PURE__ */ jsx("canvas", {
|
|
8292
|
+
ref: canvas,
|
|
8293
|
+
role: "img",
|
|
8294
|
+
"aria-label": name,
|
|
8295
|
+
width,
|
|
8296
|
+
height,
|
|
8297
|
+
className: "image-pixelated block",
|
|
8298
|
+
style: {
|
|
8299
|
+
width: width * scale,
|
|
8300
|
+
height: height * scale
|
|
8301
|
+
}
|
|
8302
|
+
})
|
|
8303
|
+
});
|
|
8304
|
+
}
|
|
8305
|
+
/** The same pixels as a PNG `Blob`, for a download (`useObjectUrl` makes the link). Rejects where there is no canvas. */
|
|
8306
|
+
function rgbaToBlob(width, height, rgba) {
|
|
8307
|
+
return new Promise((resolve, reject) => {
|
|
8308
|
+
const el = document.createElement("canvas");
|
|
8309
|
+
el.width = width;
|
|
8310
|
+
el.height = height;
|
|
8311
|
+
const ctx = el.getContext("2d");
|
|
8312
|
+
if (!ctx) return reject(/* @__PURE__ */ new Error("This browser cannot draw the picture, so it cannot be saved."));
|
|
8313
|
+
const picture = ctx.createImageData(width, height);
|
|
8314
|
+
picture.data.set(rgba);
|
|
8315
|
+
ctx.putImageData(picture, 0, 0);
|
|
8316
|
+
el.toBlob((blob) => blob ? resolve(blob) : reject(/* @__PURE__ */ new Error("The picture could not be saved.")), "image/png");
|
|
8317
|
+
});
|
|
8318
|
+
}
|
|
8319
|
+
// src/components/byte-view.tsx
|
|
8320
|
+
var PER_ROW = 16;
|
|
8321
|
+
var ROW_PX = 20;
|
|
8322
|
+
var OVERSCAN = 4;
|
|
8323
|
+
var MAX_PX = 8e6;
|
|
8324
|
+
var tints = {
|
|
8325
|
+
neutral: "bg-muted",
|
|
8326
|
+
info: "bg-info-subtle",
|
|
8327
|
+
success: "bg-success-subtle",
|
|
8328
|
+
warning: "bg-warning-subtle",
|
|
8329
|
+
danger: "bg-danger-subtle"
|
|
8330
|
+
};
|
|
8331
|
+
var cellStyle = (k) => ({
|
|
8332
|
+
width: "2ch",
|
|
8333
|
+
marginLeft: k === 8 ? "1ch" : void 0
|
|
8334
|
+
});
|
|
8335
|
+
var hex = (n, width = 2) => n.toString(16).padStart(width, "0");
|
|
8336
|
+
var tintOf = (h) => h ? tints[h.tone ?? "neutral"] : void 0;
|
|
8337
|
+
var printable = (b) => b >= 32 && b < 127 ? String.fromCharCode(b) : "·";
|
|
8338
|
+
/** A virtualised hex dump: offsets, sixteen bytes a row and the printable characters, byte and range keyboard, and the selected range reported as `{ start, end }`. */
|
|
8339
|
+
function ByteView({ bytes, label, offset = 0, highlight, defaultSelection, onSelectionChange, height = 320, className }) {
|
|
8340
|
+
const total = bytes.length;
|
|
8341
|
+
const rows = Math.ceil(total / PER_ROW);
|
|
8342
|
+
const visibleRows = Math.max(1, Math.floor(height / ROW_PX));
|
|
8343
|
+
const fullHeight = rows * ROW_PX;
|
|
8344
|
+
const spacer = Math.max(Math.min(fullHeight, MAX_PX), height);
|
|
8345
|
+
const scrollRange = Math.max(0, spacer - height);
|
|
8346
|
+
const rowRange = Math.max(0, rows - height / ROW_PX);
|
|
8347
|
+
const rowAt = (top) => scrollRange > 0 ? top / scrollRange * rowRange : 0;
|
|
8348
|
+
const topOfRow = (row) => rowRange > 0 ? row / rowRange * scrollRange : 0;
|
|
8349
|
+
const scroller = React.useRef(null);
|
|
8350
|
+
const [scrollTop, setScrollTop] = React.useState(0);
|
|
8351
|
+
const firstFloat = rowAt(scrollTop);
|
|
8352
|
+
const first = Math.min(Math.max(0, rows - 1), Math.floor(firstFloat));
|
|
8353
|
+
const fraction = firstFloat - first;
|
|
8354
|
+
const [rawAnchor, setAnchor] = React.useState(defaultSelection ? defaultSelection.start : null);
|
|
8355
|
+
const [rawCursor, setCursor] = React.useState(defaultSelection ? Math.max(defaultSelection.start, defaultSelection.end - 1) : null);
|
|
8356
|
+
const clampTo = (n) => n === null || total === 0 ? null : Math.min(n, total - 1);
|
|
8357
|
+
const anchor = clampTo(rawAnchor);
|
|
8358
|
+
const cursor = clampTo(rawCursor);
|
|
8359
|
+
const range = anchor === null || cursor === null ? null : {
|
|
8360
|
+
start: Math.min(anchor, cursor),
|
|
8361
|
+
end: Math.max(anchor, cursor) + 1
|
|
8362
|
+
};
|
|
8363
|
+
const notify = React.useRef(onSelectionChange);
|
|
8364
|
+
notify.current = onSelectionChange;
|
|
8365
|
+
const select = (nextAnchor, nextCursor) => {
|
|
8366
|
+
setAnchor(nextAnchor);
|
|
8367
|
+
setCursor(nextCursor);
|
|
8368
|
+
notify.current?.({
|
|
8369
|
+
start: Math.min(nextAnchor, nextCursor),
|
|
8370
|
+
end: Math.max(nextAnchor, nextCursor) + 1
|
|
8371
|
+
});
|
|
8372
|
+
};
|
|
8373
|
+
const reveal = (index) => {
|
|
8374
|
+
const el = scroller.current;
|
|
8375
|
+
if (!el) return;
|
|
8376
|
+
const row = Math.floor(index / PER_ROW);
|
|
8377
|
+
const now = rowAt(el.scrollTop);
|
|
8378
|
+
if (row < Math.ceil(now)) el.scrollTop = topOfRow(row);
|
|
8379
|
+
else if (row >= Math.floor(now) + visibleRows) el.scrollTop = topOfRow(row - visibleRows + 1);
|
|
8380
|
+
setScrollTop(el.scrollTop);
|
|
8381
|
+
};
|
|
8382
|
+
const move = (to, extend) => {
|
|
8383
|
+
if (total === 0) return;
|
|
8384
|
+
const index = Math.min(Math.max(0, to), total - 1);
|
|
8385
|
+
select(extend && anchor !== null ? anchor : index, index);
|
|
8386
|
+
reveal(index);
|
|
8387
|
+
};
|
|
8388
|
+
const onKeyDown = (e) => {
|
|
8389
|
+
if (total === 0) return;
|
|
8390
|
+
const at = cursor ?? 0;
|
|
8391
|
+
const extend = e.shiftKey;
|
|
8392
|
+
const rowStart = Math.floor(at / PER_ROW) * PER_ROW;
|
|
8393
|
+
switch (e.key) {
|
|
8394
|
+
case "ArrowLeft":
|
|
8395
|
+
move(cursor === null ? 0 : at - 1, extend);
|
|
8396
|
+
break;
|
|
8397
|
+
case "ArrowRight":
|
|
8398
|
+
move(cursor === null ? 0 : at + 1, extend);
|
|
8399
|
+
break;
|
|
8400
|
+
case "ArrowUp":
|
|
8401
|
+
move(cursor === null ? 0 : at - PER_ROW, extend);
|
|
8402
|
+
break;
|
|
8403
|
+
case "ArrowDown":
|
|
8404
|
+
move(cursor === null ? 0 : at + PER_ROW, extend);
|
|
8405
|
+
break;
|
|
8406
|
+
case "PageUp":
|
|
8407
|
+
move(at - visibleRows * PER_ROW, extend);
|
|
8408
|
+
break;
|
|
8409
|
+
case "PageDown":
|
|
8410
|
+
move(at + visibleRows * PER_ROW, extend);
|
|
8411
|
+
break;
|
|
8412
|
+
case "Home":
|
|
8413
|
+
move(e.ctrlKey || e.metaKey ? 0 : rowStart, extend);
|
|
8414
|
+
break;
|
|
8415
|
+
case "End":
|
|
8416
|
+
move(e.ctrlKey || e.metaKey ? total - 1 : rowStart + PER_ROW - 1, extend);
|
|
8417
|
+
break;
|
|
8418
|
+
case "Escape":
|
|
8419
|
+
if (cursor === null || anchor === cursor) return;
|
|
8420
|
+
select(cursor, cursor);
|
|
8421
|
+
break;
|
|
8422
|
+
default: return;
|
|
8423
|
+
}
|
|
8424
|
+
e.preventDefault();
|
|
8425
|
+
};
|
|
8426
|
+
const byteAt = (target) => {
|
|
8427
|
+
const cell = target?.closest?.("[data-i]");
|
|
8428
|
+
return cell ? Number(cell.dataset.i) : null;
|
|
8429
|
+
};
|
|
8430
|
+
const onPointerDown = (e) => {
|
|
8431
|
+
if (e.button !== 0) return;
|
|
8432
|
+
const i = byteAt(e.target);
|
|
8433
|
+
e.currentTarget.focus({ preventScroll: true });
|
|
8434
|
+
if (i === null) return;
|
|
8435
|
+
select(e.shiftKey && anchor !== null ? anchor : i, i);
|
|
8436
|
+
};
|
|
8437
|
+
const onPointerMove = (e) => {
|
|
8438
|
+
if (!(e.buttons & 1) || anchor === null) return;
|
|
8439
|
+
const i = byteAt(e.target);
|
|
8440
|
+
if (i !== null && i !== cursor) select(anchor, i);
|
|
8441
|
+
};
|
|
8442
|
+
const hexWidth = Math.max(6, hex(offset + Math.max(0, total - 1), 1).length);
|
|
8443
|
+
const marked = (i) => highlight?.find((h) => i >= h.start && i < h.end);
|
|
8444
|
+
const said = (() => {
|
|
8445
|
+
if (cursor === null || range === null) return "";
|
|
8446
|
+
const b = bytes[cursor];
|
|
8447
|
+
const inside = marked(cursor)?.label;
|
|
8448
|
+
const count = range.end - range.start;
|
|
8449
|
+
return `${`Byte 0x${hex(offset + cursor, 1)} of ${format.integer(total)}: ${hex(b)}, ${b}`}${count > 1 ? `; ${format.integer(count)} bytes selected, 0x${hex(offset + range.start, 1)} to 0x${hex(offset + range.end - 1, 1)}` : ""}${inside ? `; in ${inside}` : ""}`;
|
|
8450
|
+
})();
|
|
8451
|
+
const lastRow = Math.min(rows - 1, first + visibleRows + OVERSCAN);
|
|
8452
|
+
const drawn = [];
|
|
8453
|
+
for (let r = Math.max(0, first - OVERSCAN); r <= lastRow; r++) drawn.push(r);
|
|
8454
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
8455
|
+
className: cn("grid min-w-0 gap-1", className),
|
|
8456
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
8457
|
+
role: "group",
|
|
8458
|
+
"aria-label": `${label}, ${format.integer(total)} ${total === 1 ? "byte" : "bytes"}`,
|
|
8459
|
+
tabIndex: 0,
|
|
8460
|
+
onKeyDown,
|
|
8461
|
+
onFocus: (e) => {
|
|
8462
|
+
if (e.target === e.currentTarget && cursor === null && total > 0) select(0, 0);
|
|
8463
|
+
},
|
|
8464
|
+
onPointerDown,
|
|
8465
|
+
onPointerMove,
|
|
8466
|
+
className: "min-w-0 overflow-x-auto rounded-control border border-border bg-surface-sunken font-mono type-body-sm tabular-nums outline-offset-2 select-none",
|
|
8467
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
8468
|
+
"aria-hidden": true,
|
|
8469
|
+
className: "w-max min-w-full",
|
|
8470
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
8471
|
+
className: "flex h-5 items-center gap-3 border-b border-border px-3 text-muted-foreground",
|
|
8472
|
+
children: [
|
|
8473
|
+
/* @__PURE__ */ jsx("span", {
|
|
8474
|
+
style: { width: `${hexWidth}ch` },
|
|
8475
|
+
children: "Offset"
|
|
8476
|
+
}),
|
|
8477
|
+
/* @__PURE__ */ jsx("span", {
|
|
8478
|
+
className: "flex",
|
|
8479
|
+
style: { columnGap: "1ch" },
|
|
8480
|
+
children: Array.from({ length: PER_ROW }, (_, i) => /* @__PURE__ */ jsx("span", {
|
|
8481
|
+
className: "text-center",
|
|
8482
|
+
style: cellStyle(i),
|
|
8483
|
+
children: hex(i)
|
|
8484
|
+
}, i))
|
|
8485
|
+
}),
|
|
8486
|
+
/* @__PURE__ */ jsx("span", { children: "Text" })
|
|
8487
|
+
]
|
|
8488
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
8489
|
+
ref: scroller,
|
|
8490
|
+
onScroll: (e) => setScrollTop(e.currentTarget.scrollTop),
|
|
8491
|
+
className: "overflow-y-auto",
|
|
8492
|
+
style: { height },
|
|
8493
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
8494
|
+
style: { height: spacer },
|
|
8495
|
+
className: "relative",
|
|
8496
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
8497
|
+
className: "sticky top-0 overflow-hidden",
|
|
8498
|
+
style: { height },
|
|
8499
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
8500
|
+
style: { transform: `translateY(${-fraction * ROW_PX}px)` },
|
|
8501
|
+
children: drawn.map((r) => {
|
|
8502
|
+
const base = r * PER_ROW;
|
|
8503
|
+
const count = Math.min(PER_ROW, total - base);
|
|
8504
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
8505
|
+
"data-row": r,
|
|
8506
|
+
className: "flex items-center gap-3 px-3",
|
|
8507
|
+
style: {
|
|
8508
|
+
height: ROW_PX,
|
|
8509
|
+
position: "absolute",
|
|
8510
|
+
top: (r - first) * ROW_PX,
|
|
8511
|
+
left: 0,
|
|
8512
|
+
right: 0
|
|
8513
|
+
},
|
|
8514
|
+
children: [
|
|
8515
|
+
/* @__PURE__ */ jsx("span", {
|
|
8516
|
+
className: "text-muted-foreground",
|
|
8517
|
+
style: { width: `${hexWidth}ch` },
|
|
8518
|
+
children: hex(offset + base, hexWidth)
|
|
8519
|
+
}),
|
|
8520
|
+
/* @__PURE__ */ jsx("span", {
|
|
8521
|
+
className: "flex",
|
|
8522
|
+
style: { columnGap: "1ch" },
|
|
8523
|
+
children: Array.from({ length: PER_ROW }, (_, k) => {
|
|
8524
|
+
const i = base + k;
|
|
8525
|
+
if (k >= count) return /* @__PURE__ */ jsx("span", { style: cellStyle(k) }, k);
|
|
8526
|
+
const inRange = range !== null && i >= range.start && i < range.end;
|
|
8527
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8528
|
+
"data-i": i,
|
|
8529
|
+
"data-selected": inRange || void 0,
|
|
8530
|
+
"data-cursor": i === cursor || void 0,
|
|
8531
|
+
style: cellStyle(k),
|
|
8532
|
+
className: cn("rounded-control text-center", inRange ? "bg-primary text-primary-foreground" : tintOf(marked(i)), i === cursor && "outline-2 outline-ring"),
|
|
8533
|
+
children: hex(bytes[i])
|
|
8534
|
+
}, k);
|
|
8535
|
+
})
|
|
8536
|
+
}),
|
|
8537
|
+
/* @__PURE__ */ jsx("span", {
|
|
8538
|
+
className: "flex",
|
|
8539
|
+
children: Array.from({ length: count }, (_, k) => {
|
|
8540
|
+
const i = base + k;
|
|
8541
|
+
const inRange = range !== null && i >= range.start && i < range.end;
|
|
8542
|
+
return /* @__PURE__ */ jsx("span", {
|
|
8543
|
+
"data-i": i,
|
|
8544
|
+
style: { width: "1ch" },
|
|
8545
|
+
className: cn("text-center", inRange ? "bg-primary text-primary-foreground" : tintOf(marked(i))),
|
|
8546
|
+
children: printable(bytes[i])
|
|
8547
|
+
}, k);
|
|
8548
|
+
})
|
|
8549
|
+
})
|
|
8550
|
+
]
|
|
8551
|
+
}, r);
|
|
8552
|
+
})
|
|
8553
|
+
})
|
|
8554
|
+
})
|
|
8555
|
+
})
|
|
8556
|
+
})]
|
|
8557
|
+
})
|
|
8558
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
8559
|
+
role: "status",
|
|
8560
|
+
className: "type-caption text-muted-foreground tabular-nums",
|
|
8561
|
+
children: total === 0 ? "No bytes." : said
|
|
8562
|
+
})]
|
|
8563
|
+
});
|
|
8564
|
+
}
|
|
8565
|
+
// src/components/console.tsx
|
|
8566
|
+
var LEVEL_WORD = {
|
|
8567
|
+
warning: {
|
|
8568
|
+
word: "Warning",
|
|
8569
|
+
tone: "warning"
|
|
8570
|
+
},
|
|
8571
|
+
error: {
|
|
8572
|
+
word: "Error",
|
|
8573
|
+
tone: "danger"
|
|
8574
|
+
}
|
|
8575
|
+
};
|
|
8576
|
+
var lineKey = (line) => String(line.id);
|
|
8577
|
+
function readHistory(key) {
|
|
8578
|
+
if (!key) return [];
|
|
8579
|
+
try {
|
|
8580
|
+
const parsed = JSON.parse(window.localStorage.getItem(key) ?? "[]");
|
|
8581
|
+
return Array.isArray(parsed) ? parsed.filter((c) => typeof c === "string").slice(-100) : [];
|
|
8582
|
+
} catch {
|
|
8583
|
+
return [];
|
|
8584
|
+
}
|
|
8585
|
+
}
|
|
8586
|
+
/** The longest start every string shares. */
|
|
8587
|
+
function commonStart(items) {
|
|
8588
|
+
if (items.length === 0) return "";
|
|
8589
|
+
let prefix = items[0];
|
|
8590
|
+
for (const item of items) while (!item.startsWith(prefix)) prefix = prefix.slice(0, -1);
|
|
8591
|
+
return prefix;
|
|
8592
|
+
}
|
|
8593
|
+
/** A command console: a polite, virtualised log pinned to its end, above a command line with history (Up, Down) and Tab completion from the app's list. */
|
|
8594
|
+
function Console({ label, lines, onCommand, complete, historyKey, height = 320, lineHeight, commandLabel = "Command", inputRef, className }) {
|
|
8595
|
+
const [text, setText] = React.useState("");
|
|
8596
|
+
const history = React.useRef(readHistory(historyKey));
|
|
8597
|
+
const [cursor, setCursor] = React.useState(null);
|
|
8598
|
+
const draft = React.useRef("");
|
|
8599
|
+
const [matches, setMatches] = React.useState([]);
|
|
8600
|
+
const box = React.useRef(null);
|
|
8601
|
+
const [pinned, setPinned] = React.useState(true);
|
|
8602
|
+
const scroller = () => box.current?.querySelector("[data-strata-scroll]") ?? null;
|
|
8603
|
+
const toEnd = React.useCallback(() => {
|
|
8604
|
+
const el = scroller();
|
|
8605
|
+
if (el) el.scrollTop = el.scrollHeight;
|
|
8606
|
+
}, []);
|
|
8607
|
+
React.useEffect(() => {
|
|
8608
|
+
const el = scroller();
|
|
8609
|
+
if (!el) return;
|
|
8610
|
+
const onScroll = () => setPinned(el.scrollHeight - el.scrollTop - el.clientHeight < 8);
|
|
8611
|
+
el.addEventListener("scroll", onScroll);
|
|
8612
|
+
return () => el.removeEventListener("scroll", onScroll);
|
|
8613
|
+
});
|
|
8614
|
+
React.useLayoutEffect(() => {
|
|
8615
|
+
if (pinned) toEnd();
|
|
8616
|
+
const frame = requestAnimationFrame(() => pinned && toEnd());
|
|
8617
|
+
return () => cancelAnimationFrame(frame);
|
|
8618
|
+
}, [
|
|
8619
|
+
lines,
|
|
8620
|
+
pinned,
|
|
8621
|
+
toEnd
|
|
8622
|
+
]);
|
|
8623
|
+
const run = () => {
|
|
8624
|
+
const command = text.trim();
|
|
8625
|
+
if (!command) return;
|
|
8626
|
+
if (history.current[history.current.length - 1] !== command) history.current = [...history.current, command].slice(-100);
|
|
8627
|
+
if (historyKey) try {
|
|
8628
|
+
window.localStorage.setItem(historyKey, JSON.stringify(history.current));
|
|
8629
|
+
} catch {}
|
|
8630
|
+
setText("");
|
|
8631
|
+
setCursor(null);
|
|
8632
|
+
setMatches([]);
|
|
8633
|
+
setPinned(true);
|
|
8634
|
+
onCommand(command);
|
|
8635
|
+
};
|
|
8636
|
+
const walk = (direction) => {
|
|
8637
|
+
const past = history.current;
|
|
8638
|
+
if (past.length === 0) return;
|
|
8639
|
+
if (cursor === null) {
|
|
8640
|
+
if (direction === 1) return;
|
|
8641
|
+
draft.current = text;
|
|
8642
|
+
setCursor(past.length - 1);
|
|
8643
|
+
setText(past[past.length - 1]);
|
|
8644
|
+
return;
|
|
8645
|
+
}
|
|
8646
|
+
const next = cursor + direction;
|
|
8647
|
+
if (next < 0) return;
|
|
8648
|
+
if (next >= past.length) {
|
|
8649
|
+
setCursor(null);
|
|
8650
|
+
setText(draft.current);
|
|
8651
|
+
} else {
|
|
8652
|
+
setCursor(next);
|
|
8653
|
+
setText(past[next]);
|
|
8654
|
+
}
|
|
8655
|
+
};
|
|
8656
|
+
const onKeyDown = (e) => {
|
|
8657
|
+
if (e.nativeEvent.isComposing) return;
|
|
8658
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
8659
|
+
e.preventDefault();
|
|
8660
|
+
walk(e.key === "ArrowUp" ? -1 : 1);
|
|
8661
|
+
} else if (e.key === "Tab" && complete && !e.shiftKey && text.length > 0) {
|
|
8662
|
+
const found = complete(text);
|
|
8663
|
+
if (found.length === 0) return;
|
|
8664
|
+
e.preventDefault();
|
|
8665
|
+
const start = commonStart(found);
|
|
8666
|
+
if (start.length > text.length) setText(start);
|
|
8667
|
+
setMatches(found.length > 1 ? found : []);
|
|
8668
|
+
} else if (e.key === "Escape") setMatches([]);
|
|
8669
|
+
};
|
|
8670
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
8671
|
+
"aria-label": label,
|
|
8672
|
+
className: cn("grid min-w-0 gap-2", className),
|
|
8673
|
+
children: [
|
|
8674
|
+
/* @__PURE__ */ jsxs("div", {
|
|
8675
|
+
ref: box,
|
|
8676
|
+
role: "log",
|
|
8677
|
+
"aria-live": "polite",
|
|
8678
|
+
"aria-relevant": "additions",
|
|
8679
|
+
"aria-label": `${label}: log`,
|
|
8680
|
+
className: "relative min-w-0 rounded-control border border-border bg-surface-sunken",
|
|
8681
|
+
children: [
|
|
8682
|
+
/* @__PURE__ */ jsx(VirtualList, {
|
|
8683
|
+
label: `${label} lines`,
|
|
8684
|
+
items: lines,
|
|
8685
|
+
itemKey: lineKey,
|
|
8686
|
+
height,
|
|
8687
|
+
bounded: true,
|
|
8688
|
+
estimateSize: 24,
|
|
8689
|
+
rowHeight: lineHeight,
|
|
8690
|
+
children: (line) => {
|
|
8691
|
+
const word = LEVEL_WORD[line.level ?? "info"];
|
|
8692
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
8693
|
+
className: cn("flex min-w-0 items-start gap-2 px-3 py-0.5 font-mono type-body-sm", line.level === "echo" && "text-muted-foreground"),
|
|
8694
|
+
children: [
|
|
8695
|
+
word ? /* @__PURE__ */ jsx(Status, {
|
|
8696
|
+
tone: word.tone,
|
|
8697
|
+
children: word.word
|
|
8698
|
+
}) : line.level === "echo" ? /* @__PURE__ */ jsx("span", {
|
|
8699
|
+
"aria-hidden": true,
|
|
8700
|
+
children: "›"
|
|
8701
|
+
}) : null,
|
|
8702
|
+
line.level === "echo" && /* @__PURE__ */ jsx("span", {
|
|
8703
|
+
className: "sr-only",
|
|
8704
|
+
children: "Command: "
|
|
8705
|
+
}),
|
|
8706
|
+
/* @__PURE__ */ jsx("span", {
|
|
8707
|
+
title: lineHeight ? line.text : void 0,
|
|
8708
|
+
className: cn("min-w-0 flex-1", lineHeight ? "truncate" : "break-words whitespace-pre-wrap"),
|
|
8709
|
+
children: line.text
|
|
8710
|
+
})
|
|
8711
|
+
]
|
|
8712
|
+
});
|
|
8713
|
+
}
|
|
8714
|
+
}),
|
|
8715
|
+
lines.length === 0 && /* @__PURE__ */ jsx("p", {
|
|
8716
|
+
className: "px-3 py-2 type-body-sm text-muted-foreground",
|
|
8717
|
+
children: "Nothing has been written yet."
|
|
8718
|
+
}),
|
|
8719
|
+
!pinned && /* @__PURE__ */ jsxs(Button, {
|
|
8720
|
+
size: "sm",
|
|
8721
|
+
variant: "outline",
|
|
8722
|
+
onPress: () => {
|
|
8723
|
+
setPinned(true);
|
|
8724
|
+
toEnd();
|
|
8725
|
+
},
|
|
8726
|
+
className: "absolute bottom-2 left-1/2 -translate-x-1/2 shadow-overlay",
|
|
8727
|
+
children: [/* @__PURE__ */ jsx(ArrowDown, {}), " Latest"]
|
|
8728
|
+
})
|
|
8729
|
+
]
|
|
8730
|
+
}),
|
|
8731
|
+
/* @__PURE__ */ jsx("form", {
|
|
8732
|
+
onSubmit: (e) => {
|
|
8733
|
+
e.preventDefault();
|
|
8734
|
+
run();
|
|
8735
|
+
},
|
|
8736
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
8737
|
+
label: commandLabel,
|
|
8738
|
+
action: /* @__PURE__ */ jsx(Button, {
|
|
8739
|
+
type: "submit",
|
|
8740
|
+
children: "Run"
|
|
8741
|
+
}),
|
|
8742
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
8743
|
+
ref: inputRef,
|
|
8744
|
+
value: text,
|
|
8745
|
+
onChange: (e) => {
|
|
8746
|
+
setText(e.target.value);
|
|
8747
|
+
setCursor(null);
|
|
8748
|
+
setMatches([]);
|
|
8749
|
+
},
|
|
8750
|
+
onKeyDown,
|
|
8751
|
+
autoComplete: "off",
|
|
8752
|
+
autoCapitalize: "off",
|
|
8753
|
+
autoCorrect: "off",
|
|
8754
|
+
spellCheck: false,
|
|
8755
|
+
className: "font-mono"
|
|
8756
|
+
})
|
|
8757
|
+
})
|
|
8758
|
+
}),
|
|
8759
|
+
/* @__PURE__ */ jsx("p", {
|
|
8760
|
+
role: "status",
|
|
8761
|
+
className: cn("type-caption text-muted-foreground", matches.length === 0 && "sr-only"),
|
|
8762
|
+
children: matches.length > 0 ? `${matches.length} matches: ${matches.join(", ")}` : ""
|
|
8763
|
+
})
|
|
8764
|
+
]
|
|
8765
|
+
});
|
|
8766
|
+
}
|
|
8767
|
+
// src/components/shortcut-editor.tsx
|
|
8768
|
+
var idOf = (s) => s.id ?? s.label;
|
|
8769
|
+
var MODIFIER_KEYS = /* @__PURE__ */ new Set([
|
|
8770
|
+
"Shift",
|
|
8771
|
+
"Control",
|
|
8772
|
+
"Alt",
|
|
8773
|
+
"Meta",
|
|
8774
|
+
"AltGraph",
|
|
8775
|
+
"CapsLock",
|
|
8776
|
+
"Fn",
|
|
8777
|
+
"OS"
|
|
8778
|
+
]);
|
|
8779
|
+
/** Holds a person's rebound keys over a default `Shortcut[]`, remembered under `storageKey` and handed to `onChange`. The result's `shortcuts` is what `useHotkeys` and `KeysLegend` take. */
|
|
8780
|
+
function useRebindableShortcuts(defaults, { storageKey, initial, onChange } = {}) {
|
|
8781
|
+
const [overrides, setOverrides] = React.useState(() => {
|
|
8782
|
+
if (initial) return initial;
|
|
8783
|
+
if (!storageKey) return {};
|
|
8784
|
+
try {
|
|
8785
|
+
const parsed = JSON.parse(window.localStorage.getItem(storageKey) ?? "{}");
|
|
8786
|
+
if (!parsed || typeof parsed !== "object") return {};
|
|
8787
|
+
const out = {};
|
|
8788
|
+
for (const [id, keys] of Object.entries(parsed)) if (Array.isArray(keys) && keys.every((k) => typeof k === "string") && keys.length > 0) out[id] = keys;
|
|
8789
|
+
return out;
|
|
8790
|
+
} catch {
|
|
8791
|
+
return {};
|
|
8792
|
+
}
|
|
8793
|
+
});
|
|
8794
|
+
const latest = React.useRef({
|
|
8795
|
+
onChange,
|
|
8796
|
+
storageKey
|
|
8797
|
+
});
|
|
8798
|
+
latest.current = {
|
|
8799
|
+
onChange,
|
|
8800
|
+
storageKey
|
|
8801
|
+
};
|
|
8802
|
+
const current = React.useRef(overrides);
|
|
8803
|
+
const commit = React.useCallback((next) => {
|
|
8804
|
+
current.current = next;
|
|
8805
|
+
setOverrides(next);
|
|
8806
|
+
const { onChange: notify, storageKey: key } = latest.current;
|
|
8807
|
+
if (key) try {
|
|
8808
|
+
window.localStorage.setItem(key, JSON.stringify(next));
|
|
8809
|
+
} catch {}
|
|
8810
|
+
notify?.(next);
|
|
8811
|
+
}, []);
|
|
8812
|
+
return React.useMemo(() => ({
|
|
8813
|
+
shortcuts: defaults.map((s) => overrides[idOf(s)] ? {
|
|
8814
|
+
...s,
|
|
8815
|
+
keys: overrides[idOf(s)]
|
|
8816
|
+
} : { ...s }),
|
|
8817
|
+
defaults,
|
|
8818
|
+
overrides,
|
|
8819
|
+
isChanged: (id) => id in overrides,
|
|
8820
|
+
setKeys: (id, keys) => {
|
|
8821
|
+
const next = { ...current.current };
|
|
8822
|
+
if (keys === null) delete next[id];
|
|
8823
|
+
else next[id] = keys;
|
|
8824
|
+
commit(next);
|
|
8825
|
+
},
|
|
8826
|
+
resetAll: () => commit({})
|
|
8827
|
+
}), [
|
|
8828
|
+
defaults,
|
|
8829
|
+
overrides,
|
|
8830
|
+
commit
|
|
8831
|
+
]);
|
|
8832
|
+
}
|
|
8833
|
+
/** Judges a key pressed while recording for the shortcut `id`, against the current list. */
|
|
8834
|
+
function checkKey(e, id, shortcuts) {
|
|
8835
|
+
if (e.ctrlKey || e.metaKey || e.altKey) {
|
|
8836
|
+
const chord = [
|
|
8837
|
+
e.ctrlKey && "Ctrl",
|
|
8838
|
+
e.metaKey && "Meta",
|
|
8839
|
+
e.altKey && "Alt",
|
|
8840
|
+
e.shiftKey && "Shift",
|
|
8841
|
+
e.key.length === 1 ? e.key.toUpperCase() : e.key
|
|
8842
|
+
].filter(Boolean).join("+");
|
|
8843
|
+
return {
|
|
8844
|
+
ok: false,
|
|
8845
|
+
reason: isReservedChord(chord) ? `${formatChord(chord)} belongs to the browser.` : `${formatChord(chord)} is a chord, and shortcuts here are single keys: Ctrl, Cmd and Alt belong to the browser and the system.`
|
|
8846
|
+
};
|
|
8847
|
+
}
|
|
8848
|
+
if (e.key === "Tab") return {
|
|
8849
|
+
ok: false,
|
|
8850
|
+
reason: "Tab moves between controls, so it cannot be a shortcut."
|
|
8851
|
+
};
|
|
8852
|
+
const other = shortcuts.find((s) => idOf(s) !== id && !s.disabled && s.keys.includes(e.key));
|
|
8853
|
+
return other ? {
|
|
8854
|
+
ok: "conflict",
|
|
8855
|
+
key: e.key,
|
|
8856
|
+
other
|
|
8857
|
+
} : {
|
|
8858
|
+
ok: true,
|
|
8859
|
+
key: e.key
|
|
8860
|
+
};
|
|
8861
|
+
}
|
|
8862
|
+
/** Each shortcut with its keys and a "Change" that records the next key pressed; refuses keys that cannot be bound, names a conflict and offers a swap, and resets one or all. Edits the list a `useRebindableShortcuts` holds. */
|
|
8863
|
+
function ShortcutEditor({ rebinding, label = "Keyboard shortcuts", className }) {
|
|
8864
|
+
const { shortcuts, defaults, setKeys, isChanged, resetAll, overrides } = rebinding;
|
|
8865
|
+
const [recording, setRecording] = React.useState(null);
|
|
8866
|
+
const [conflict, setConflict] = React.useState(null);
|
|
8867
|
+
const [said, setSaid] = React.useState("");
|
|
8868
|
+
const keysOf = (id) => shortcuts.find((s) => idOf(s) === id).keys;
|
|
8869
|
+
const apply = (id, key, swapWith) => {
|
|
8870
|
+
const own = keysOf(id);
|
|
8871
|
+
const old = own[0];
|
|
8872
|
+
setKeys(id, [key, ...own.slice(1).filter((k) => k !== key)]);
|
|
8873
|
+
if (swapWith) {
|
|
8874
|
+
const theirs = keysOf(idOf(swapWith)).map((k) => k === key ? old : k);
|
|
8875
|
+
setKeys(idOf(swapWith), [...new Set(theirs)]);
|
|
8876
|
+
}
|
|
8877
|
+
};
|
|
8878
|
+
const onKeyDown = (e, shortcut) => {
|
|
8879
|
+
const id = idOf(shortcut);
|
|
8880
|
+
if (e.nativeEvent.isComposing) return;
|
|
8881
|
+
if (e.key === "Tab") {
|
|
8882
|
+
setRecording(null);
|
|
8883
|
+
setSaid("Tab moves between controls, so it cannot be a shortcut. Kept " + keyName(shortcut.keys[0] ?? "") + " for " + shortcut.label + ".");
|
|
8884
|
+
return;
|
|
8885
|
+
}
|
|
8886
|
+
e.stopPropagation();
|
|
8887
|
+
if (e.key === "Escape") {
|
|
8888
|
+
e.preventDefault();
|
|
8889
|
+
setRecording(null);
|
|
8890
|
+
setSaid(`Kept ${keyName(shortcut.keys[0] ?? "")} for ${shortcut.label}.`);
|
|
8891
|
+
return;
|
|
8892
|
+
}
|
|
8893
|
+
if (MODIFIER_KEYS.has(e.key)) return;
|
|
8894
|
+
e.preventDefault();
|
|
8895
|
+
const found = checkKey(e.nativeEvent, id, shortcuts);
|
|
8896
|
+
if (found.ok === false) {
|
|
8897
|
+
setSaid(found.reason);
|
|
8898
|
+
return;
|
|
8899
|
+
}
|
|
8900
|
+
setRecording(null);
|
|
8901
|
+
if (found.ok === "conflict") {
|
|
8902
|
+
setConflict({
|
|
8903
|
+
id,
|
|
8904
|
+
key: found.key,
|
|
8905
|
+
other: found.other
|
|
8906
|
+
});
|
|
8907
|
+
setSaid(`${keyName(found.key)} is already ${found.other.label}. Swap?`);
|
|
8908
|
+
return;
|
|
8909
|
+
}
|
|
8910
|
+
apply(id, found.key);
|
|
8911
|
+
setSaid(`${shortcut.label} is now ${keyName(found.key)}.`);
|
|
8912
|
+
};
|
|
8913
|
+
const anyChanged = Object.keys(overrides).length > 0;
|
|
8914
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
8915
|
+
"aria-label": label,
|
|
8916
|
+
className: cn("grid min-w-0 gap-3", className),
|
|
8917
|
+
children: [/* @__PURE__ */ jsx("ul", {
|
|
8918
|
+
className: "grid min-w-0 divide-y divide-border rounded-surface border border-border",
|
|
8919
|
+
children: shortcuts.map((shortcut) => {
|
|
8920
|
+
const id = idOf(shortcut);
|
|
8921
|
+
const mine = conflict?.id === id ? conflict : null;
|
|
8922
|
+
const isRecording = recording === id;
|
|
8923
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
8924
|
+
className: cn("flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2", shortcut.disabled && "opacity-50"),
|
|
8925
|
+
children: [
|
|
8926
|
+
/* @__PURE__ */ jsx("span", {
|
|
8927
|
+
className: "min-w-0 flex-1 type-body-sm",
|
|
8928
|
+
children: shortcut.label
|
|
8929
|
+
}),
|
|
8930
|
+
/* @__PURE__ */ jsx("span", {
|
|
8931
|
+
className: "flex items-center gap-1",
|
|
8932
|
+
children: shortcut.keys.map((k, i) => /* @__PURE__ */ jsxs(React.Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("span", {
|
|
8933
|
+
className: "sr-only",
|
|
8934
|
+
children: " or "
|
|
8935
|
+
}), /* @__PURE__ */ jsx("kbd", {
|
|
8936
|
+
className: "min-w-5 rounded-control border border-border bg-surface-sunken px-1 text-center font-mono type-caption text-foreground",
|
|
8937
|
+
children: /* @__PURE__ */ jsx(KeyText, { children: keyName(k) })
|
|
8938
|
+
})] }, k))
|
|
8939
|
+
}),
|
|
8940
|
+
isRecording ? /* @__PURE__ */ jsx(Button, {
|
|
8941
|
+
size: "sm",
|
|
8942
|
+
variant: "default",
|
|
8943
|
+
autoFocus: true,
|
|
8944
|
+
"aria-label": `Press a key for ${shortcut.label}. Escape cancels.`,
|
|
8945
|
+
onKeyDown: (e) => onKeyDown(e, shortcut),
|
|
8946
|
+
onBlur: () => setRecording((now) => now === id ? null : now),
|
|
8947
|
+
children: "Press a key…"
|
|
8948
|
+
}) : /* @__PURE__ */ jsx(Button, {
|
|
8949
|
+
size: "sm",
|
|
8950
|
+
"aria-label": `Change ${shortcut.label}`,
|
|
8951
|
+
disabled: shortcut.disabled,
|
|
8952
|
+
onPress: () => {
|
|
8953
|
+
setConflict(null);
|
|
8954
|
+
setRecording(id);
|
|
8955
|
+
setSaid(`Press the new key for ${shortcut.label}. Escape cancels.`);
|
|
8956
|
+
},
|
|
8957
|
+
children: "Change"
|
|
8958
|
+
}),
|
|
8959
|
+
isChanged(id) && !isRecording && /* @__PURE__ */ jsxs(Button, {
|
|
8960
|
+
size: "sm",
|
|
8961
|
+
variant: "ghost",
|
|
8962
|
+
"aria-label": `Reset ${shortcut.label}`,
|
|
8963
|
+
onPress: () => {
|
|
8964
|
+
setKeys(id, null);
|
|
8965
|
+
setConflict(null);
|
|
8966
|
+
const original = defaults.find((s) => idOf(s) === id);
|
|
8967
|
+
setSaid(`${shortcut.label} is back to ${keyName(original?.keys[0] ?? "")}.`);
|
|
8968
|
+
},
|
|
8969
|
+
children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), " Reset"]
|
|
8970
|
+
}),
|
|
8971
|
+
mine && /* @__PURE__ */ jsxs("p", {
|
|
8972
|
+
className: "flex basis-full flex-wrap items-center gap-2 type-body-sm text-warning",
|
|
8973
|
+
children: [
|
|
8974
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
8975
|
+
"Already “",
|
|
8976
|
+
mine.other.label,
|
|
8977
|
+
"”: swap?"
|
|
8978
|
+
] }),
|
|
8979
|
+
/* @__PURE__ */ jsx(Button, {
|
|
8980
|
+
size: "sm",
|
|
8981
|
+
onPress: () => {
|
|
8982
|
+
const given = keysOf(id)[0] ?? "";
|
|
8983
|
+
apply(id, mine.key, mine.other);
|
|
8984
|
+
setConflict(null);
|
|
8985
|
+
setSaid(`${shortcut.label} is now ${keyName(mine.key)}, and ${mine.other.label} has ${keyName(given)}.`);
|
|
8986
|
+
},
|
|
8987
|
+
children: "Swap"
|
|
8988
|
+
}),
|
|
8989
|
+
/* @__PURE__ */ jsx(Button, {
|
|
8990
|
+
size: "sm",
|
|
8991
|
+
variant: "ghost",
|
|
8992
|
+
onPress: () => {
|
|
8993
|
+
setConflict(null);
|
|
8994
|
+
setSaid("Nothing changed.");
|
|
8995
|
+
},
|
|
8996
|
+
children: "Keep as it was"
|
|
8997
|
+
})
|
|
8998
|
+
]
|
|
8999
|
+
})
|
|
9000
|
+
]
|
|
9001
|
+
}, id);
|
|
9002
|
+
})
|
|
9003
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
9004
|
+
className: "flex items-center gap-3",
|
|
9005
|
+
children: [anyChanged && /* @__PURE__ */ jsx(Button, {
|
|
9006
|
+
size: "sm",
|
|
9007
|
+
onPress: () => {
|
|
9008
|
+
resetAll();
|
|
9009
|
+
setConflict(null);
|
|
9010
|
+
setSaid("Every shortcut is back to its default.");
|
|
9011
|
+
},
|
|
9012
|
+
children: "Reset all"
|
|
9013
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
9014
|
+
role: "status",
|
|
9015
|
+
className: "min-w-0 flex-1 type-body-sm text-muted-foreground",
|
|
9016
|
+
children: said
|
|
9017
|
+
})]
|
|
9018
|
+
})]
|
|
9019
|
+
});
|
|
9020
|
+
}
|
|
7979
9021
|
// src/lib/file-intake.ts
|
|
7980
9022
|
/** Whether a file matches one entry of an `accept` list: extension, exact type or `family/*`, ignoring case. */
|
|
7981
9023
|
function matchesAccept(file, accept) {
|
|
@@ -15402,7 +16444,7 @@ var SlotContext = React.createContext({
|
|
|
15402
16444
|
stacked: false
|
|
15403
16445
|
});
|
|
15404
16446
|
/** The workspace: a labelled region that holds the splits and panes, and stacks them when narrow. */
|
|
15405
|
-
function Workspace({ label, state, narrowBelow = 720, className, children }) {
|
|
16447
|
+
function Workspace({ label, state, narrowBelow = 720, onFiles, acceptLabel, className, children }) {
|
|
15406
16448
|
const ref = React.useRef(null);
|
|
15407
16449
|
const { setNarrow } = state;
|
|
15408
16450
|
React.useLayoutEffect(() => {
|
|
@@ -15419,21 +16461,49 @@ function Workspace({ label, state, narrowBelow = 720, className, children }) {
|
|
|
15419
16461
|
}, [narrowBelow, setNarrow]);
|
|
15420
16462
|
return /* @__PURE__ */ jsx(StateContext.Provider, {
|
|
15421
16463
|
value: state,
|
|
15422
|
-
children: /* @__PURE__ */
|
|
16464
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
15423
16465
|
ref,
|
|
15424
16466
|
role: "group",
|
|
15425
16467
|
"aria-label": label,
|
|
15426
16468
|
className: cn("flex h-full min-h-0 min-w-0 flex-col overflow-hidden bg-background", className),
|
|
15427
|
-
children
|
|
16469
|
+
children: [children, onFiles && /* @__PURE__ */ jsx(FileDropOverlay, {
|
|
16470
|
+
onFiles,
|
|
16471
|
+
acceptLabel: acceptLabel ?? "files"
|
|
16472
|
+
})]
|
|
15428
16473
|
})
|
|
15429
16474
|
});
|
|
15430
16475
|
}
|
|
16476
|
+
/** The bar across the top of a `Workspace`: the tool's name as the heading, a polite status line, the few actions, then an end slot for the scheme and palette choice. Wraps on a phone. */
|
|
16477
|
+
function WorkspaceBar({ title, status, actions, end, className }) {
|
|
16478
|
+
return /* @__PURE__ */ jsxs("header", {
|
|
16479
|
+
className: cn("flex min-h-(--control-h) shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border px-3 py-1", className),
|
|
16480
|
+
children: [
|
|
16481
|
+
/* @__PURE__ */ jsx("h1", {
|
|
16482
|
+
className: "type-label min-w-0 shrink-0",
|
|
16483
|
+
children: title
|
|
16484
|
+
}),
|
|
16485
|
+
/* @__PURE__ */ jsx("p", {
|
|
16486
|
+
role: "status",
|
|
16487
|
+
className: "type-body-sm min-w-0 flex-1 truncate text-muted-foreground tabular-nums",
|
|
16488
|
+
children: status
|
|
16489
|
+
}),
|
|
16490
|
+
actions && /* @__PURE__ */ jsx("div", {
|
|
16491
|
+
className: "flex shrink-0 items-center gap-2",
|
|
16492
|
+
children: actions
|
|
16493
|
+
}),
|
|
16494
|
+
end && /* @__PURE__ */ jsx("div", {
|
|
16495
|
+
className: "flex shrink-0 items-center gap-2",
|
|
16496
|
+
children: end
|
|
16497
|
+
})
|
|
16498
|
+
]
|
|
16499
|
+
});
|
|
16500
|
+
}
|
|
15431
16501
|
var iconsFor = (direction, edge, stacked) => {
|
|
15432
16502
|
if (stacked || direction === "column") return edge === "start" ? [PanelTopClose, PanelTopOpen] : [PanelBottomClose, PanelBottomOpen];
|
|
15433
16503
|
return edge === "end" ? [PanelRightClose, PanelRightOpen] : [PanelLeftClose, PanelLeftOpen];
|
|
15434
16504
|
};
|
|
15435
16505
|
/** A region of a workspace with a consistent header (name, actions, fold button) and a body that scrolls. */
|
|
15436
|
-
function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollapsed, actions, className, children }) {
|
|
16506
|
+
function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollapsed, actions, flush, className, children }) {
|
|
15437
16507
|
const state = useState_();
|
|
15438
16508
|
const { direction, edge, stacked } = React.useContext(SlotContext);
|
|
15439
16509
|
const headingId = React.useId();
|
|
@@ -15490,7 +16560,7 @@ function Pane({ id, name, grow, size = 280, min, max, collapsible, defaultCollap
|
|
|
15490
16560
|
}), /* @__PURE__ */ jsx("div", {
|
|
15491
16561
|
id: `pane-body-${id}`,
|
|
15492
16562
|
hidden: folded,
|
|
15493
|
-
className: "min-h-0 min-w-0 flex-1 overflow-auto",
|
|
16563
|
+
className: cn("min-h-0 min-w-0 flex-1 overflow-auto", !flush && "p-3"),
|
|
15494
16564
|
children
|
|
15495
16565
|
})]
|
|
15496
16566
|
});
|
|
@@ -18194,7 +19264,7 @@ function Children({ node }) {
|
|
|
18194
19264
|
return /* @__PURE__ */ jsx(Nodes, { nodes: load.data });
|
|
18195
19265
|
}
|
|
18196
19266
|
/** A hierarchy whose children load as each node opens (a `useChildren` hook per open node): a skeleton row, a Try again row and an "empty" row per node, type-ahead and arrow keys, single selection, open state optionally in the URL, always virtualised. */
|
|
18197
|
-
function Tree({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, current, onCurrentChange, count, badge, sortChildren, reveal, resolveBranch, coverNoun = ["item", "items"], expanded, beforeOpen, loadingRow, emptyRow, height = "24rem", className }) {
|
|
19267
|
+
function Tree({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderNode, selected, onSelect, choices, current, onCurrentChange, count, badge, sortChildren, reveal, resolveBranch, coverNoun = ["item", "items"], branchPress = "select", expanded, beforeOpen, loadingRow, emptyRow, height = "24rem", className }) {
|
|
18198
19268
|
const nodes = React.useRef(/* @__PURE__ */ new Map()).current;
|
|
18199
19269
|
const [covered, setCovered] = React.useState("");
|
|
18200
19270
|
const scroller = React.useRef(null);
|
|
@@ -18324,7 +19394,13 @@ function Tree({ label, roots, useChildren, nodeKey, nodeLabel, isBranch, renderN
|
|
|
18324
19394
|
if (first === void 0 || isNote(String(first))) return;
|
|
18325
19395
|
const key = String(first);
|
|
18326
19396
|
const node = nodes.get(key);
|
|
18327
|
-
if (node
|
|
19397
|
+
if (node === void 0) return;
|
|
19398
|
+
if (branchPress === "toggle" && (isBranch ? isBranch(node) : true)) {
|
|
19399
|
+
if (!expanded.isOpen(key) && beforeOpen?.(node) === false) return;
|
|
19400
|
+
expanded.toggle(key);
|
|
19401
|
+
return;
|
|
19402
|
+
}
|
|
19403
|
+
onSelect?.(key, node);
|
|
18328
19404
|
};
|
|
18329
19405
|
const displayKeys = choices ? [.../* @__PURE__ */ new Set([...choices.selected, ...nodes.keys()])].filter((k) => stateOf(k) === "on" || choices.selected.has(k) && !nodes.has(k)) : [];
|
|
18330
19406
|
const shown = () => {
|
|
@@ -18650,6 +19726,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
18650
19726
|
]
|
|
18651
19727
|
});
|
|
18652
19728
|
}
|
|
18653
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, Workspace, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, describeActionError, describeHttpError, describeRegion, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
19729
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, logScale, loudnessOf, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
18654
19730
|
|
|
18655
19731
|
//# sourceMappingURL=index.js.map
|