strata-react 1.3.15 → 1.3.16

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.
Files changed (52) hide show
  1. package/README.md +47 -8
  2. package/UPGRADING.md +13 -0
  3. package/dist/components/data-table.d.ts +6 -0
  4. package/dist/components/field.d.ts +2 -0
  5. package/dist/components/hotkeys.d.ts +1 -1
  6. package/dist/components/link-card.d.ts +4 -2
  7. package/dist/components/pause-button.d.ts +7 -0
  8. package/dist/components/schedule-table.d.ts +24 -0
  9. package/dist/components/system-panel.d.ts +58 -0
  10. package/dist/components/theme.d.ts +46 -1
  11. package/dist/{errors-D99YX4XL.js → errors-D0TsKLwJ.js} +2 -2
  12. package/dist/{errors-D99YX4XL.js.map → errors-D0TsKLwJ.js.map} +1 -1
  13. package/dist/{field-QCCmWTuY.js → field-jfhLD5XX.js} +22 -15
  14. package/dist/{field-QCCmWTuY.js.map → field-jfhLD5XX.js.map} +1 -1
  15. package/dist/{format-B32-PVi2.js → format-BNkXVwFx.js} +67 -6
  16. package/dist/format-BNkXVwFx.js.map +1 -0
  17. package/dist/index.d.ts +6 -3
  18. package/dist/index.js +796 -409
  19. package/dist/index.js.map +1 -1
  20. package/dist/lib/breakpoint.d.ts +4 -0
  21. package/dist/lib/format.d.ts +59 -6
  22. package/dist/map.js +3 -3
  23. package/dist/{microphone-BZXMKTCM.js → microphone-CZy0bNEx.js} +138 -91
  24. package/dist/microphone-CZy0bNEx.js.map +1 -0
  25. package/dist/panorama.js +2 -2
  26. package/dist/query/index.d.ts +5 -1
  27. package/dist/query/poll.d.ts +24 -0
  28. package/dist/reading.css +11 -0
  29. package/dist/{run-hR9neQHM.js → run-BT2WKzMz.js} +83 -17
  30. package/dist/run-BT2WKzMz.js.map +1 -0
  31. package/dist/strata.bare.css +279 -0
  32. package/dist/strata.css +840 -10
  33. package/dist/strata.migrate.css +15 -6
  34. package/dist/testing/index.d.ts +4 -2
  35. package/dist/testing.js +32 -6
  36. package/dist/testing.js.map +1 -1
  37. package/dist/{theme-By3DSUTs.js → theme-CFBAYaiu.js} +147 -6
  38. package/dist/theme-CFBAYaiu.js.map +1 -0
  39. package/dist/{value-controls-B7iNh4WO.js → value-controls-WRXbtUp6.js} +21 -6
  40. package/dist/value-controls-WRXbtUp6.js.map +1 -0
  41. package/dist/visual/capture.d.ts +2 -0
  42. package/dist/visual/fonts.d.ts +18 -0
  43. package/dist/visual/index.d.ts +1 -0
  44. package/dist/visual/types.d.ts +7 -1
  45. package/dist/visual-cli.js +1 -1
  46. package/dist/visual.js +1 -1
  47. package/package.json +12 -3
  48. package/dist/format-B32-PVi2.js.map +0 -1
  49. package/dist/microphone-BZXMKTCM.js.map +0 -1
  50. package/dist/run-hR9neQHM.js.map +0 -1
  51. package/dist/theme-By3DSUTs.js.map +0 -1
  52. package/dist/value-controls-B7iNh4WO.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,19 +1,19 @@
1
- import { a as Textarea, c as useSearchParam, d as cn, f as typeSteps, i as NativeSelect, l as Tooltip, n as Field, o as useFieldControl, r as Input, s as controlHeight, t as ChoiceGroup, u as KeyText } from "./field-QCCmWTuY.js";
2
- import { a as toDate, i as format, n as NBSP, r as createFormat, t as MISSING } from "./format-B32-PVi2.js";
3
- import { a as useAsyncAction, c as KeysLegend, d as useInView, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-B7iNh4WO.js";
4
- import { a as fieldErrorsOf, c as IconButton, d as isDev, i as errorPayload, l as RowAction, n as describeActionError, o as readErrorBody, r as describeHttpError, s as Button, t as HttpError, u as buttonVariants } from "./errors-D99YX4XL.js";
5
- import { a as useMicrophone, c as fetchJson, d as useLoad, f as StrataToastRegion, h as overlaySurface, i as explainMicrophoneError, l as staleOf, m as toastTimeout, n as MicrophoneError, o as StrataQueryProvider, p as toast, r as browserMicrophone, s as createQueryClient, t as MicrophoneContext, u as toLoad } from "./microphone-BZXMKTCM.js";
1
+ import { a as Textarea, c as useSearchParam, d as cn, f as typeSteps, i as NativeSelect, l as Tooltip, n as Field, o as useFieldControl, r as Input, s as controlHeight, t as ChoiceGroup, u as KeyText } from "./field-jfhLD5XX.js";
2
+ import { a as toDate, i as format, n as NBSP, r as createFormat, t as MISSING } from "./format-BNkXVwFx.js";
3
+ import { a as useAsyncAction, c as KeysLegend, d as useInView, i as AsyncButton, l as isTypingTarget, n as NumberField, o as Toolbar, r as Slider, s as ToolbarSeparator, t as ColorField, u as useHotkeys } from "./value-controls-WRXbtUp6.js";
4
+ import { a as fieldErrorsOf, c as IconButton, d as isDev, i as errorPayload, l as RowAction, n as describeActionError, o as readErrorBody, r as describeHttpError, s as Button, t as HttpError, u as buttonVariants } from "./errors-D0TsKLwJ.js";
5
+ import { a as useMicrophone, c as toastTimeout, d as fetchJson, f as staleOf, g as overlaySurface, h as usePoll, i as explainMicrophoneError, l as StrataQueryProvider, m as useLoad, n as MicrophoneError, o as StrataToastRegion, p as toLoad, r as browserMicrophone, s as toast, t as MicrophoneContext, u as createQueryClient } from "./microphone-CZy0bNEx.js";
6
6
  import { n as useSharedCursor, r as geo, t as CursorScope } from "./cursor-DDGBPiTJ.js";
7
- import { a as useColorScheme, i as colorSchemeScript, n as ColorSchemeChoice, o as useSystemColorScheme, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY } from "./theme-By3DSUTs.js";
7
+ 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-CFBAYaiu.js";
8
8
  import * as React from "react";
9
9
  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";
10
- import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FileQuestion, Flag, Folder, FolderOpen, GripVertical, History, 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";
10
+ 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, History, 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";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
12
  import { Link as Link$1, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
13
+ import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
13
14
  import { createSortedRowModel, flexRender, rowSortingFeature, tableFeatures, useTable } from "@tanstack/react-table";
14
15
  import { UNSAFE_PortalProvider, VisuallyHidden, mergeProps, useDrag, useDrop, useFocusRing, useMove, useSlider, useSliderThumb, useUNSAFE_PortalContext } from "react-aria";
15
16
  import { LayoutInfo, Rect, Size, useSliderState } from "react-stately";
16
- import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
17
17
  import pixelmatch from "pixelmatch";
18
18
  // src/lib/chords.ts
19
19
  /** The platform this page runs on, read from the browser (`mac` for macOS and iOS). Server and test default: `other`. */
@@ -533,6 +533,26 @@ function ToggleGroupView({ label, options, value, onChange, size = "default", cl
533
533
  })
534
534
  });
535
535
  }
536
+ // src/components/pause-button.tsx
537
+ /** The pause control of a polled screen: a "Pause updates" toggle and when the readings were last taken ("Updated 12:00"). Takes the `Poll` from `usePoll`. */
538
+ function PauseButton({ poll, hideUpdated = false, className }) {
539
+ const when = poll.updatedAt ? format.clock(poll.updatedAt) : null;
540
+ return /* @__PURE__ */ jsxs("div", {
541
+ className: cn("inline-flex flex-wrap items-center gap-x-3 gap-y-1", className),
542
+ children: [!hideUpdated && /* @__PURE__ */ jsx("span", {
543
+ role: "status",
544
+ "aria-live": "off",
545
+ className: "type-caption text-muted-foreground tabular-nums",
546
+ children: poll.paused ? when ? `Paused. Last updated ${when}` : "Paused" : when ? `Updated ${when}` : "Not read yet"
547
+ }), /* @__PURE__ */ jsx(Toggle, {
548
+ label: "Pause updates",
549
+ icon: Pause,
550
+ size: "sm",
551
+ pressed: poll.paused,
552
+ onChange: () => poll.toggle()
553
+ })]
554
+ });
555
+ }
536
556
  // src/components/switch.tsx
537
557
  /** An on/off setting that applies at once, its label and control one target. */
538
558
  function Switch({ label, detail, on, defaultOn, onChange, disabled, className }) {
@@ -943,52 +963,631 @@ function Meter({ label, value, max = 1, valueText, detail, thresholds, worseWhen
943
963
  style: { left: `${Math.min(1, Math.max(0, t.at)) * 100}%` }
944
964
  }, t.at))]
945
965
  });
946
- const figure = /* @__PURE__ */ jsx("span", {
966
+ const figure = /* @__PURE__ */ jsx("span", {
967
+ "aria-hidden": true,
968
+ className: "shrink-0 type-body-sm tabular-nums text-foreground",
969
+ children: text
970
+ });
971
+ const note = hasNote && /* @__PURE__ */ jsxs("div", {
972
+ className: "flex flex-wrap items-center gap-x-3 gap-y-1",
973
+ children: [crossed && /* @__PURE__ */ jsx("span", {
974
+ id: statusId,
975
+ className: "contents",
976
+ children: /* @__PURE__ */ jsx(Status, {
977
+ tone: crossed.tone,
978
+ children: crossed.label
979
+ })
980
+ }), detail && /* @__PURE__ */ jsx("span", {
981
+ id: detailId,
982
+ className: "type-body-sm text-muted-foreground tabular-nums",
983
+ children: detail
984
+ })]
985
+ });
986
+ if (hideLabel) return /* @__PURE__ */ jsxs("div", {
987
+ className: cn("grid min-w-0 gap-1.5", className),
988
+ children: [/* @__PURE__ */ jsxs("div", {
989
+ className: "flex items-center gap-3",
990
+ children: [bar, figure]
991
+ }), note]
992
+ });
993
+ return /* @__PURE__ */ jsxs("div", {
994
+ className: cn("grid min-w-0 gap-1.5", className),
995
+ children: [
996
+ /* @__PURE__ */ jsxs("div", {
997
+ className: "flex items-baseline justify-between gap-3",
998
+ children: [/* @__PURE__ */ jsx("span", {
999
+ id: labelId,
1000
+ className: "min-w-0 truncate type-label text-foreground",
1001
+ children: label
1002
+ }), figure]
1003
+ }),
1004
+ /* @__PURE__ */ jsx("div", {
1005
+ className: "flex",
1006
+ children: bar
1007
+ }),
1008
+ note
1009
+ ]
1010
+ });
1011
+ }
1012
+ // src/lib/base.ts
1013
+ /**
1014
+ * Where the app is mounted: the path of the page's `<base href>` without its trailing slash, `""` at the root or where there is no base (SSR, a plain page).
1015
+ * Give it to React Router as `createBrowserRouter(routes, { basename: appBase() || "/" })`.
1016
+ */
1017
+ function appBase(doc = typeof document === "undefined" ? void 0 : document) {
1018
+ if (!doc?.querySelector("base[href]")) return "";
1019
+ return new URL(".", doc.baseURI).pathname.replace(/\/$/, "");
1020
+ }
1021
+ /**
1022
+ * Puts the app's base in front of a root-relative path (`/api/learners` becomes `/proxy/api/learners` behind a proxy).
1023
+ * Anything else (a relative path, a full URL, a protocol-relative `//host`) is returned as it is. Use it for every `fetch`, `<img src>` and download link the app builds; in-app links are router paths and need none.
1024
+ */
1025
+ function withBase(path, base = appBase()) {
1026
+ return path.startsWith("/") && !path.startsWith("//") ? base + path : path;
1027
+ }
1028
+ // src/query/api.ts
1029
+ var isRaw = (body) => typeof Blob !== "undefined" && body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof FormData !== "undefined" && body instanceof FormData || body instanceof URLSearchParams || typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
1030
+ /**
1031
+ * A small client over `fetchJson` for the app's own server: root-relative paths get the app's base (so it works behind a reverse proxy),
1032
+ * and `post`, `put` and `patch` send their body as JSON (a `Blob`, bytes, `FormData` or a stream is sent as it is, with the Blob's own type). `api.post<Learner>("/api/learners", { nickname })`.
1033
+ */
1034
+ function createApi({ base, ...options } = {}) {
1035
+ const url = (path) => withBase(path, base ?? appBase());
1036
+ const send = (method, path, body, init) => fetchJson(url(path), {
1037
+ ...init,
1038
+ method,
1039
+ ...body === void 0 ? {} : isRaw(body) ? { body } : { json: body }
1040
+ }, options);
1041
+ return {
1042
+ url,
1043
+ get: (path, init) => send("GET", path, void 0, init),
1044
+ post: (path, body, init) => send("POST", path, body, init),
1045
+ put: (path, body, init) => send("PUT", path, body, init),
1046
+ patch: (path, body, init) => send("PATCH", path, body, init),
1047
+ delete: (path, init) => send("DELETE", path, void 0, init)
1048
+ };
1049
+ }
1050
+ // src/query/typed-api.ts
1051
+ function fill(path, values, query) {
1052
+ const filled = path.replace(/\{([^}]+)\}/g, (_, name) => {
1053
+ const value = values?.[name];
1054
+ if (value === void 0 || value === null) throw new Error(`strata-react: the path ${path} needs "${name}" in \`path\``);
1055
+ return encodeURIComponent(String(value));
1056
+ });
1057
+ const search = new URLSearchParams();
1058
+ for (const [key, value] of Object.entries(query ?? {})) for (const item of Array.isArray(value) ? value : [value]) if (item !== void 0 && item !== null) search.append(key, String(item));
1059
+ const text = search.toString();
1060
+ return text ? `${filled}${filled.includes("?") ? "&" : "?"}${text}` : filled;
1061
+ }
1062
+ /**
1063
+ * `createApi` typed by the server's schema: `const api = createTypedApi<paths>()`, then `api.post("/api/learners", { json: { nickname } })` and
1064
+ * `api.get("/api/learners/{id}", { path: { id } })`; the path, `path` and `query` values, `json` and the answer are checked, and `{id}` is filled and escaped.
1065
+ */
1066
+ function createTypedApi(options = {}) {
1067
+ const api = createApi(options);
1068
+ const call = (method) => (path, request) => {
1069
+ const { path: values, query, json, body, ...init } = request ?? {};
1070
+ const target = fill(path, values, query);
1071
+ const rest = init;
1072
+ return method === "get" ? api.get(target, rest) : method === "delete" ? api.delete(target, rest) : api[method](target, body ?? json, rest);
1073
+ };
1074
+ return {
1075
+ url: api.url,
1076
+ get: call("get"),
1077
+ post: call("post"),
1078
+ put: call("put"),
1079
+ patch: call("patch"),
1080
+ delete: call("delete")
1081
+ };
1082
+ }
1083
+ // src/query/infinite.ts
1084
+ /** `useInfiniteQuery` for cursor-paged data, returned as an `InfiniteLoad<T>` for `InfiniteList` (or `DataView`). */
1085
+ function useInfiniteLoad({ queryKey, queryFn, items, itemKey, hasMore = () => false, nextCursor, cursorAfter = itemKey, isRemoved, describeError = describeHttpError, enabled, staleTime }) {
1086
+ const queryHash = hashKey(queryKey);
1087
+ const [stored, setStored] = React.useState(() => ({
1088
+ query: queryHash,
1089
+ keys: /* @__PURE__ */ new Set()
1090
+ }));
1091
+ const dismissed = stored.query === queryHash ? stored.keys : none;
1092
+ const hidden = React.useCallback((key) => dismissed.has(key) || (isRemoved?.(key) ?? false), [dismissed, isRemoved]);
1093
+ const latest = React.useRef({
1094
+ hidden,
1095
+ items,
1096
+ itemKey,
1097
+ hasMore,
1098
+ cursorAfter,
1099
+ nextCursor
1100
+ });
1101
+ latest.current = {
1102
+ hidden,
1103
+ items,
1104
+ itemKey,
1105
+ hasMore,
1106
+ cursorAfter,
1107
+ nextCursor
1108
+ };
1109
+ const query = useInfiniteQuery({
1110
+ queryKey,
1111
+ queryFn: ({ pageParam, signal }) => queryFn({
1112
+ cursor: pageParam.cursor,
1113
+ signal
1114
+ }),
1115
+ initialPageParam: { cursor: void 0 },
1116
+ getNextPageParam: (lastPage, pages) => {
1117
+ const l = latest.current;
1118
+ if (l.nextCursor) {
1119
+ const next = l.nextCursor(lastPage);
1120
+ return next === null ? null : { cursor: next };
1121
+ }
1122
+ if (!l.hasMore(lastPage)) return null;
1123
+ const after = nextAfter(pages, l.items, l.itemKey, l.hidden);
1124
+ return { cursor: after === void 0 ? void 0 : l.cursorAfter(after) };
1125
+ },
1126
+ enabled,
1127
+ staleTime
1128
+ });
1129
+ const pages = query.data?.pages;
1130
+ const list = React.useMemo(() => pages ? merge(pages, latest.current.items, latest.current.itemKey, hidden).held : void 0, [pages, hidden]);
1131
+ const { hasNextPage, isFetchingNextPage, fetchNextPage, refetch } = query;
1132
+ const loadMore = React.useCallback(() => {
1133
+ if (hasNextPage && !isFetchingNextPage) fetchNextPage();
1134
+ }, [
1135
+ hasNextPage,
1136
+ isFetchingNextPage,
1137
+ fetchNextPage
1138
+ ]);
1139
+ const change = React.useCallback((edit) => setStored((s) => {
1140
+ const keys = new Set(s.query === queryHash ? s.keys : none);
1141
+ edit(keys);
1142
+ return {
1143
+ query: queryHash,
1144
+ keys
1145
+ };
1146
+ }), [queryHash]);
1147
+ const dismiss = React.useCallback((key) => change((keys) => keys.add(key)), [change]);
1148
+ const restore = React.useCallback((key) => change((keys) => keys.delete(key)), [change]);
1149
+ const extra = {
1150
+ more: {
1151
+ hasMore: Boolean(hasNextPage),
1152
+ loadingMore: isFetchingNextPage,
1153
+ error: query.isFetchNextPageError ? describeError(query.error) : void 0,
1154
+ loadMore
1155
+ },
1156
+ itemKey,
1157
+ dismiss,
1158
+ restore
1159
+ };
1160
+ if (list) {
1161
+ const stale = query.isRefetchError ? staleOf(query, describeError) : void 0;
1162
+ return {
1163
+ status: "ready",
1164
+ data: list,
1165
+ ...stale && { stale },
1166
+ ...extra
1167
+ };
1168
+ }
1169
+ if (query.status === "error") return {
1170
+ status: "error",
1171
+ message: describeError(query.error),
1172
+ retry: () => void refetch(),
1173
+ ...extra
1174
+ };
1175
+ return {
1176
+ status: "loading",
1177
+ ...extra
1178
+ };
1179
+ }
1180
+ var none = /* @__PURE__ */ new Set();
1181
+ /** Every page's items, in order, once each by key: the ones held (not dismissed) and the last one seen. */
1182
+ function merge(pages, items, itemKey, hidden) {
1183
+ const seen = /* @__PURE__ */ new Set();
1184
+ const held = [];
1185
+ let last;
1186
+ let lastPageAddedAny = false;
1187
+ pages.forEach((page, p) => {
1188
+ for (const item of items(page)) {
1189
+ const key = itemKey(item);
1190
+ if (seen.has(key)) continue;
1191
+ seen.add(key);
1192
+ last = item;
1193
+ if (p === pages.length - 1) lastPageAddedAny = true;
1194
+ if (!hidden(key)) held.push(item);
1195
+ }
1196
+ });
1197
+ return {
1198
+ held,
1199
+ last,
1200
+ lastPageAddedAny
1201
+ };
1202
+ }
1203
+ /** The item the next page goes after: the last held, or the last seen when nothing is held or the last page brought nothing new. */
1204
+ function nextAfter(pages, items, itemKey, hidden) {
1205
+ const { held, last, lastPageAddedAny } = merge(pages, items, itemKey, hidden);
1206
+ if (held.length === 0 || pages.length > 1 && !lastPageAddedAny) return last;
1207
+ return held[held.length - 1];
1208
+ }
1209
+ /** `useInfiniteLoad`'s `items` and `nextCursor` for the shared `Page<T>` shape: `useInfiniteLoad({ queryKey, queryFn, itemKey, ...apiPage<Item>() })`. */
1210
+ function apiPage() {
1211
+ return {
1212
+ items: (page) => page.items,
1213
+ nextCursor: (page) => page.next
1214
+ };
1215
+ }
1216
+ // src/query/job.ts
1217
+ /** A long-running job's status: polled every `every` ms while `isRunning`, with the `invalidates` queries read again once when it ends. */
1218
+ function useJob({ isRunning, every = 2e3, invalidates = [], describeError, ...options }) {
1219
+ const client = useQueryClient();
1220
+ const query = useQuery({
1221
+ ...options,
1222
+ refetchInterval: (q) => q.state.data !== void 0 && isRunning(q.state.data) ? every : false
1223
+ });
1224
+ const running = query.data !== void 0 && isRunning(query.data);
1225
+ const queryHash = hashKey(options.queryKey);
1226
+ const seen = query.data === void 0 ? void 0 : running;
1227
+ const was = React.useRef(void 0);
1228
+ React.useEffect(() => {
1229
+ if (seen === void 0) return;
1230
+ const before = was.current;
1231
+ if (before && before.query === queryHash && before.running && !seen) for (const queryKey of before.invalidates) client.invalidateQueries({ queryKey });
1232
+ was.current = {
1233
+ query: queryHash,
1234
+ running: seen,
1235
+ invalidates
1236
+ };
1237
+ });
1238
+ const { refetch } = query;
1239
+ const poll = React.useCallback(() => void refetch(), [refetch]);
1240
+ return {
1241
+ ...toLoad(query, describeError),
1242
+ running,
1243
+ poll
1244
+ };
1245
+ }
1246
+ /** Whether a task of the shared contract (`strata_python.contracts.Task`) is still going: its `state` is not one of the finished ones. Pass the generated `FINISHED`; for `useJob({ isRunning: (t) => isTaskRunning(t, FINISHED) })`. */
1247
+ function isTaskRunning(task, finished) {
1248
+ return !(Array.isArray(finished) ? finished.includes(task.state) : finished.has(task.state));
1249
+ }
1250
+ // src/query/workflow.ts
1251
+ /** Whether the queue job advancing a workflow run is still going. `finished` is the generated `FINISHED` (or `["done", "failed", "cancelled"]`). */
1252
+ function isWorkflowRunning(run, finished) {
1253
+ return run.job != null && isTaskRunning(run.job, finished);
1254
+ }
1255
+ /** A subject's `WorkflowRun`: polled while its job runs, its `invalidates` read again once when it ends. */
1256
+ function useWorkflowRun({ finished, ...options }) {
1257
+ return useJob({
1258
+ ...options,
1259
+ isRunning: (run) => isWorkflowRunning(run, finished)
1260
+ });
1261
+ }
1262
+ // src/components/data-view.tsx
1263
+ /** The default failed-read panel: the reason on the danger tint, with Try again. Its parent carries `role="alert"`. */
1264
+ function LoadError({ message, retry, className }) {
1265
+ return /* @__PURE__ */ jsxs("div", {
1266
+ className: cn("flex flex-wrap items-start gap-3 rounded-surface bg-danger-subtle p-4 text-danger", className),
1267
+ children: [
1268
+ /* @__PURE__ */ jsx(CircleAlert, {
1269
+ "aria-hidden": true,
1270
+ className: "mt-0.5 size-5 shrink-0"
1271
+ }),
1272
+ /* @__PURE__ */ jsx("p", {
1273
+ className: "min-w-0 flex-1 type-body",
1274
+ children: message
1275
+ }),
1276
+ /* @__PURE__ */ jsxs(Button, {
1277
+ size: "sm",
1278
+ onClick: retry,
1279
+ children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), "Try again"]
1280
+ })
1281
+ ]
1282
+ });
1283
+ }
1284
+ var defaultError = (failure) => /* @__PURE__ */ jsx(LoadError, { ...failure });
1285
+ /** Every view of remote data: renders `skeleton` while loading, an alert with Try again on error, `empty` when `isEmpty`, else `children(data)`, under a `StaleNotice` when a refresh failed. The skeleton and empty state are required. */
1286
+ function DataView$1({ state, isEmpty, skeleton, empty, children, staleNotice = (stale) => /* @__PURE__ */ jsx(StaleNotice, { stale }), error = defaultError, className }) {
1287
+ return /* @__PURE__ */ jsxs("div", {
1288
+ className: cn("min-w-0", className),
1289
+ "aria-busy": state.status === "loading" || void 0,
1290
+ children: [
1291
+ state.status === "loading" && skeleton,
1292
+ state.status === "error" && /* @__PURE__ */ jsx("div", {
1293
+ role: "alert",
1294
+ children: error({
1295
+ message: state.message,
1296
+ retry: state.retry
1297
+ })
1298
+ }),
1299
+ state.status === "ready" && /* @__PURE__ */ jsxs(Fragment, { children: [state.stale && staleNotice(state.stale), isEmpty(state.data) ? empty : children(state.data)] })
1300
+ ]
1301
+ });
1302
+ }
1303
+ /** When `readAt` was, for a person: the clock time today, else the weekday and time. */
1304
+ function readTime(readAt, now = /* @__PURE__ */ new Date()) {
1305
+ return readAt.toDateString() === now.toDateString() ? format.clock.format(readAt) : format.shortDay.format(readAt);
1306
+ }
1307
+ /** The notice over data whose refresh failed: what happened, how old the data shown is, and Try again. A polite status, not an alert: nothing was lost. */
1308
+ function StaleNotice({ stale, shown, className }) {
1309
+ return /* @__PURE__ */ jsxs("div", {
1310
+ role: "status",
1311
+ className: cn("mb-4 flex flex-wrap items-start gap-3 rounded-surface bg-warning-subtle p-3 text-warning", className),
1312
+ children: [
1313
+ /* @__PURE__ */ jsx(History, {
1314
+ "aria-hidden": true,
1315
+ className: "mt-0.5 size-4 shrink-0"
1316
+ }),
1317
+ /* @__PURE__ */ jsxs("p", {
1318
+ className: "min-w-0 flex-1 type-body-sm",
1319
+ children: [
1320
+ stale.message,
1321
+ " ",
1322
+ shown ? shown(readTime(stale.readAt)) : `Showing data from ${readTime(stale.readAt)}.`
1323
+ ]
1324
+ }),
1325
+ /* @__PURE__ */ jsxs(Button, {
1326
+ size: "sm",
1327
+ onClick: stale.retry,
1328
+ disabled: stale.retrying,
1329
+ children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), stale.retrying ? "Trying again…" : "Try again"]
1330
+ })
1331
+ ]
1332
+ });
1333
+ }
1334
+ /** An empty state that teaches the next action: a title, a sentence and an action. No illustration slot, on purpose. */
1335
+ function EmptyState({ title, children, action }) {
1336
+ return /* @__PURE__ */ jsxs("div", {
1337
+ className: "grid justify-items-start gap-2 border-y border-border py-6",
1338
+ children: [
1339
+ /* @__PURE__ */ jsx("p", {
1340
+ className: "type-heading",
1341
+ children: title
1342
+ }),
1343
+ children && /* @__PURE__ */ jsx("p", {
1344
+ className: "max-w-prose type-body text-muted-foreground",
1345
+ children
1346
+ }),
1347
+ action && /* @__PURE__ */ jsx("div", {
1348
+ className: "mt-2",
1349
+ children: action
1350
+ })
1351
+ ]
1352
+ });
1353
+ }
1354
+ /** A placeholder block for a loading layout. Size it with layout classes so it mirrors the final content. */
1355
+ function Skeleton({ className }) {
1356
+ return /* @__PURE__ */ jsx("div", {
1357
+ "aria-hidden": true,
1358
+ className: cn("rounded-control bg-muted motion-safe:animate-pulse", className)
1359
+ });
1360
+ }
1361
+ // src/components/system-panel.tsx
1362
+ /** The shared limits for a folder's disk, as shares of its size: filling up at 80%, nearly full at 95%. */
1363
+ var diskThresholds = [{
1364
+ at: .8,
1365
+ tone: "warning",
1366
+ label: "Filling up"
1367
+ }, {
1368
+ at: .95,
1369
+ tone: "danger",
1370
+ label: "Nearly full"
1371
+ }];
1372
+ /** Reads `GET /api/system` (or another path) as a `Load` for `SystemPanel`, polled when given a `Poll`. Behind a reverse proxy the path is put under the app's base. */
1373
+ function useSystemInfo({ path = "/api/system", poll } = {}) {
1374
+ return useLoad({
1375
+ queryKey: [
1376
+ "strata",
1377
+ "system",
1378
+ path
1379
+ ],
1380
+ queryFn: () => fetchJson(withBase(path)),
1381
+ poll
1382
+ });
1383
+ }
1384
+ function Fact({ term, children }) {
1385
+ return /* @__PURE__ */ jsxs("div", {
1386
+ className: "flex gap-6",
1387
+ children: [/* @__PURE__ */ jsx("dt", {
1388
+ className: "w-28 shrink-0 text-muted-foreground",
1389
+ children: term
1390
+ }), /* @__PURE__ */ jsx("dd", {
1391
+ className: "min-w-0",
1392
+ children
1393
+ })]
1394
+ });
1395
+ }
1396
+ /** "301.6 GB of 512 GB": both in the larger figure's unit, so they read as one comparison. */
1397
+ function ofSize(used, size) {
1398
+ const unit = format.byteUnit(size);
1399
+ return `${format.bytes(used, unit)} of ${format.bytes(size, unit)}`;
1400
+ }
1401
+ function PanelHeading({ id, level, children }) {
1402
+ return React.createElement(`h${level}`, {
1403
+ id,
1404
+ className: "type-heading"
1405
+ }, children);
1406
+ }
1407
+ function SystemSkeleton() {
1408
+ return /* @__PURE__ */ jsxs("div", {
1409
+ className: "grid gap-8",
947
1410
  "aria-hidden": true,
948
- className: "shrink-0 type-body-sm tabular-nums text-foreground",
949
- children: text
1411
+ children: [
1412
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-28 w-full max-w-xl" }),
1413
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-full max-w-xl" }),
1414
+ /* @__PURE__ */ jsx(Skeleton, { className: "h-16 w-full max-w-xl" })
1415
+ ]
950
1416
  });
951
- const note = hasNote && /* @__PURE__ */ jsxs("div", {
952
- className: "flex flex-wrap items-center gap-x-3 gap-y-1",
953
- children: [crossed && /* @__PURE__ */ jsx("span", {
954
- id: statusId,
955
- className: "contents",
956
- children: /* @__PURE__ */ jsx(Status, {
957
- tone: crossed.tone,
958
- children: crossed.label
959
- })
960
- }), detail && /* @__PURE__ */ jsx("span", {
961
- id: detailId,
962
- className: "type-body-sm text-muted-foreground tabular-nums",
963
- children: detail
964
- })]
1417
+ }
1418
+ function FolderRow({ folder, thresholds }) {
1419
+ const { name, path, exists, free_bytes: free, total_bytes: total } = folder;
1420
+ const where = /* @__PURE__ */ jsx("span", {
1421
+ className: "font-mono type-body-sm text-muted-foreground break-all",
1422
+ children: path
965
1423
  });
966
- if (hideLabel) return /* @__PURE__ */ jsxs("div", {
967
- className: cn("grid min-w-0 gap-1.5", className),
1424
+ if (!exists) return /* @__PURE__ */ jsxs("div", {
1425
+ className: "grid gap-1.5",
968
1426
  children: [/* @__PURE__ */ jsxs("div", {
969
- className: "flex items-center gap-3",
970
- children: [bar, figure]
971
- }), note]
1427
+ className: "flex items-center justify-between gap-3",
1428
+ children: [/* @__PURE__ */ jsx("span", {
1429
+ className: "type-label",
1430
+ children: name
1431
+ }), /* @__PURE__ */ jsx(Status, {
1432
+ tone: "warning",
1433
+ icon: FolderX,
1434
+ children: "Missing"
1435
+ })]
1436
+ }), where]
1437
+ });
1438
+ if (free == null || total == null || total <= 0) return /* @__PURE__ */ jsxs("div", {
1439
+ className: "grid gap-1.5",
1440
+ children: [/* @__PURE__ */ jsxs("div", {
1441
+ className: "flex items-center justify-between gap-3",
1442
+ children: [/* @__PURE__ */ jsx("span", {
1443
+ className: "type-label",
1444
+ children: name
1445
+ }), /* @__PURE__ */ jsx(Status, {
1446
+ tone: "neutral",
1447
+ children: "Not measured"
1448
+ })]
1449
+ }), where]
972
1450
  });
973
1451
  return /* @__PURE__ */ jsxs("div", {
974
- className: cn("grid min-w-0 gap-1.5", className),
1452
+ className: "grid gap-1.5",
1453
+ children: [/* @__PURE__ */ jsx(Meter, {
1454
+ label: `${name} folder disk space used`,
1455
+ value: total - free,
1456
+ max: total,
1457
+ thresholds,
1458
+ detail: ofSize(total - free, total)
1459
+ }), where]
1460
+ });
1461
+ }
1462
+ function ServiceRow({ service }) {
1463
+ return /* @__PURE__ */ jsxs("li", {
1464
+ className: "flex flex-wrap items-baseline gap-x-3 gap-y-0.5",
975
1465
  children: [
976
- /* @__PURE__ */ jsxs("div", {
977
- className: "flex items-baseline justify-between gap-3",
978
- children: [/* @__PURE__ */ jsx("span", {
979
- id: labelId,
980
- className: "min-w-0 truncate type-label text-foreground",
981
- children: label
982
- }), figure]
1466
+ /* @__PURE__ */ jsx("span", {
1467
+ className: "type-label",
1468
+ children: service.name
983
1469
  }),
984
- /* @__PURE__ */ jsx("div", {
985
- className: "flex",
986
- children: bar
1470
+ service.ok ? /* @__PURE__ */ jsx(Status, {
1471
+ tone: "success",
1472
+ icon: CircleCheck,
1473
+ children: "Up"
1474
+ }) : /* @__PURE__ */ jsx(Status, {
1475
+ tone: "danger",
1476
+ icon: CircleAlert,
1477
+ children: "Down"
987
1478
  }),
988
- note
1479
+ service.version && /* @__PURE__ */ jsxs("span", {
1480
+ className: "type-body-sm text-muted-foreground tabular-nums",
1481
+ children: ["version ", service.version]
1482
+ }),
1483
+ !service.ok && service.detail && /* @__PURE__ */ jsx("span", {
1484
+ className: "type-body-sm text-danger",
1485
+ children: service.detail
1486
+ })
989
1487
  ]
990
1488
  });
991
1489
  }
1490
+ /** About this server, from `GET /api/system`: version and commit, when it started, each folder's disk as a meter with its state in words, and each service as Up or Down. Loaded through `DataView`, with a skeleton and the stale notice. */
1491
+ function SystemPanel({ load, thresholds = diskThresholds, facts = [], now, headingLevel = 2, className }) {
1492
+ const headings = {
1493
+ folders: React.useId(),
1494
+ services: React.useId(),
1495
+ server: React.useId()
1496
+ };
1497
+ return /* @__PURE__ */ jsx(DataView$1, {
1498
+ state: load,
1499
+ isEmpty: () => false,
1500
+ skeleton: /* @__PURE__ */ jsx(SystemSkeleton, {}),
1501
+ staleNotice: (stale) => /* @__PURE__ */ jsx(StaleNotice, {
1502
+ stale,
1503
+ shown: (when) => `These readings are from ${when}.`
1504
+ }),
1505
+ empty: /* @__PURE__ */ jsx(EmptyState, {
1506
+ title: "No readings",
1507
+ children: "The server sent nothing to report."
1508
+ }),
1509
+ className,
1510
+ children: (s) => /* @__PURE__ */ jsxs("div", {
1511
+ className: "grid max-w-xl gap-8",
1512
+ children: [
1513
+ /* @__PURE__ */ jsxs("section", {
1514
+ "aria-labelledby": headings.server,
1515
+ className: "grid gap-3",
1516
+ children: [/* @__PURE__ */ jsx(PanelHeading, {
1517
+ id: headings.server,
1518
+ level: headingLevel,
1519
+ children: "Server"
1520
+ }), /* @__PURE__ */ jsxs("dl", {
1521
+ className: "grid gap-2 type-body-sm",
1522
+ children: [
1523
+ /* @__PURE__ */ jsx(Fact, {
1524
+ term: "Version",
1525
+ children: /* @__PURE__ */ jsx("span", {
1526
+ className: "tabular-nums",
1527
+ children: s.version
1528
+ })
1529
+ }),
1530
+ /* @__PURE__ */ jsx(Fact, {
1531
+ term: "Source",
1532
+ children: s.commit ? /* @__PURE__ */ jsx("span", {
1533
+ className: "font-mono",
1534
+ title: s.commit,
1535
+ children: s.commit.slice(0, 12)
1536
+ }) : "Installed package"
1537
+ }),
1538
+ /* @__PURE__ */ jsxs(Fact, {
1539
+ term: "Started",
1540
+ children: [format.dateTime(s.started_at), /* @__PURE__ */ jsxs("span", {
1541
+ className: "ml-2 text-muted-foreground tabular-nums",
1542
+ children: ["up ", format.duration(((now ?? /* @__PURE__ */ new Date()).getTime() - new Date(s.started_at).getTime()) / 1e3, { style: "parts" })]
1543
+ })]
1544
+ }),
1545
+ /* @__PURE__ */ jsx(Fact, {
1546
+ term: "Python",
1547
+ children: /* @__PURE__ */ jsx("span", {
1548
+ className: "tabular-nums",
1549
+ children: s.python
1550
+ })
1551
+ }),
1552
+ /* @__PURE__ */ jsx(Fact, {
1553
+ term: "Platform",
1554
+ children: s.platform
1555
+ }),
1556
+ facts.map((f) => /* @__PURE__ */ jsx(Fact, {
1557
+ term: f.term,
1558
+ children: f.value
1559
+ }, f.term))
1560
+ ]
1561
+ })]
1562
+ }),
1563
+ s.folders.length > 0 && /* @__PURE__ */ jsxs("section", {
1564
+ "aria-labelledby": headings.folders,
1565
+ className: "grid gap-3",
1566
+ children: [/* @__PURE__ */ jsx(PanelHeading, {
1567
+ id: headings.folders,
1568
+ level: headingLevel,
1569
+ children: "Folders"
1570
+ }), s.folders.map((f) => /* @__PURE__ */ jsx(FolderRow, {
1571
+ folder: f,
1572
+ thresholds
1573
+ }, f.name))]
1574
+ }),
1575
+ s.services.length > 0 && /* @__PURE__ */ jsxs("section", {
1576
+ "aria-labelledby": headings.services,
1577
+ className: "grid gap-3",
1578
+ children: [/* @__PURE__ */ jsx(PanelHeading, {
1579
+ id: headings.services,
1580
+ level: headingLevel,
1581
+ children: "Services"
1582
+ }), /* @__PURE__ */ jsx("ul", {
1583
+ className: "grid gap-2",
1584
+ children: s.services.map((svc) => /* @__PURE__ */ jsx(ServiceRow, { service: svc }, svc.name))
1585
+ })]
1586
+ })
1587
+ ]
1588
+ })
1589
+ });
1590
+ }
992
1591
  // src/components/composition.tsx
993
1592
  var MAX_TOKENS = 5;
994
1593
  /** A part's colour: its own, or the chart token for its position. Throws past the fifth token. */
@@ -1103,8 +1702,17 @@ function CompositionBar({ label, parts, formatValue, formatShare = format.share,
1103
1702
  });
1104
1703
  }
1105
1704
  // src/components/link-card.tsx
1705
+ /** True when `href` is on another origin than the page (a relative one never is). Unreadable is treated as leaving. */
1706
+ function leavesSite(href) {
1707
+ if (typeof window === "undefined") return false;
1708
+ try {
1709
+ return new URL(href, window.location.href).origin !== window.location.origin;
1710
+ } catch {
1711
+ return true;
1712
+ }
1713
+ }
1106
1714
  /** A destination as a card that is one link: its title is the link's name, the description and status marks are its description, and the whole card is the target. */
1107
- function LinkCard({ title, description, marks, as: Heading = "h3", className, ...destination }) {
1715
+ function LinkCard({ title, description, marks, as: Heading = "h3", className, external, ...destination }) {
1108
1716
  const descriptionId = React.useId();
1109
1717
  const marksId = React.useId();
1110
1718
  const describedBy = [description && descriptionId, marks && marksId].filter(Boolean).join(" ") || void 0;
@@ -1119,7 +1727,7 @@ function LinkCard({ title, description, marks, as: Heading = "h3", className, ..
1119
1727
  "aria-describedby": describedBy,
1120
1728
  className: linkClass,
1121
1729
  children: title
1122
- }), /* @__PURE__ */ jsx(ArrowUpRight, {
1730
+ }), (external ?? leavesSite(destination.href)) && /* @__PURE__ */ jsx(ArrowUpRight, {
1123
1731
  "aria-hidden": true,
1124
1732
  className: "mt-0.5 size-4 shrink-0 text-muted-foreground"
1125
1733
  })] }) : /* @__PURE__ */ jsx(Link$1, {
@@ -1153,105 +1761,6 @@ function LinkCardList({ label, children, className }) {
1153
1761
  }, React.isValidElement(child) && child.key != null ? child.key : i))
1154
1762
  });
1155
1763
  }
1156
- // src/components/data-view.tsx
1157
- /** The default failed-read panel: the reason on the danger tint, with Try again. Its parent carries `role="alert"`. */
1158
- function LoadError({ message, retry, className }) {
1159
- return /* @__PURE__ */ jsxs("div", {
1160
- className: cn("flex flex-wrap items-start gap-3 rounded-surface bg-danger-subtle p-4 text-danger", className),
1161
- children: [
1162
- /* @__PURE__ */ jsx(CircleAlert, {
1163
- "aria-hidden": true,
1164
- className: "mt-0.5 size-5 shrink-0"
1165
- }),
1166
- /* @__PURE__ */ jsx("p", {
1167
- className: "min-w-0 flex-1 type-body",
1168
- children: message
1169
- }),
1170
- /* @__PURE__ */ jsxs(Button, {
1171
- size: "sm",
1172
- onClick: retry,
1173
- children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), "Try again"]
1174
- })
1175
- ]
1176
- });
1177
- }
1178
- var defaultError = (failure) => /* @__PURE__ */ jsx(LoadError, { ...failure });
1179
- /** Every view of remote data: renders `skeleton` while loading, an alert with Try again on error, `empty` when `isEmpty`, else `children(data)`, under a `StaleNotice` when a refresh failed. The skeleton and empty state are required. */
1180
- function DataView$1({ state, isEmpty, skeleton, empty, children, staleNotice = (stale) => /* @__PURE__ */ jsx(StaleNotice, { stale }), error = defaultError, className }) {
1181
- return /* @__PURE__ */ jsxs("div", {
1182
- className: cn("min-w-0", className),
1183
- "aria-busy": state.status === "loading" || void 0,
1184
- children: [
1185
- state.status === "loading" && skeleton,
1186
- state.status === "error" && /* @__PURE__ */ jsx("div", {
1187
- role: "alert",
1188
- children: error({
1189
- message: state.message,
1190
- retry: state.retry
1191
- })
1192
- }),
1193
- state.status === "ready" && /* @__PURE__ */ jsxs(Fragment, { children: [state.stale && staleNotice(state.stale), isEmpty(state.data) ? empty : children(state.data)] })
1194
- ]
1195
- });
1196
- }
1197
- /** When `readAt` was, for a person: the clock time today, else the weekday and time. */
1198
- function readTime(readAt, now = /* @__PURE__ */ new Date()) {
1199
- return readAt.toDateString() === now.toDateString() ? format.clock.format(readAt) : format.shortDay.format(readAt);
1200
- }
1201
- /** The notice over data whose refresh failed: what happened, how old the data shown is, and Try again. A polite status, not an alert: nothing was lost. */
1202
- function StaleNotice({ stale, shown, className }) {
1203
- return /* @__PURE__ */ jsxs("div", {
1204
- role: "status",
1205
- className: cn("mb-4 flex flex-wrap items-start gap-3 rounded-surface bg-warning-subtle p-3 text-warning", className),
1206
- children: [
1207
- /* @__PURE__ */ jsx(History, {
1208
- "aria-hidden": true,
1209
- className: "mt-0.5 size-4 shrink-0"
1210
- }),
1211
- /* @__PURE__ */ jsxs("p", {
1212
- className: "min-w-0 flex-1 type-body-sm",
1213
- children: [
1214
- stale.message,
1215
- " ",
1216
- shown ? shown(readTime(stale.readAt)) : `Showing data from ${readTime(stale.readAt)}.`
1217
- ]
1218
- }),
1219
- /* @__PURE__ */ jsxs(Button, {
1220
- size: "sm",
1221
- onClick: stale.retry,
1222
- disabled: stale.retrying,
1223
- children: [/* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true }), stale.retrying ? "Trying again…" : "Try again"]
1224
- })
1225
- ]
1226
- });
1227
- }
1228
- /** An empty state that teaches the next action: a title, a sentence and an action. No illustration slot, on purpose. */
1229
- function EmptyState({ title, children, action }) {
1230
- return /* @__PURE__ */ jsxs("div", {
1231
- className: "grid justify-items-start gap-2 border-y border-border py-6",
1232
- children: [
1233
- /* @__PURE__ */ jsx("p", {
1234
- className: "type-heading",
1235
- children: title
1236
- }),
1237
- children && /* @__PURE__ */ jsx("p", {
1238
- className: "max-w-prose type-body text-muted-foreground",
1239
- children
1240
- }),
1241
- action && /* @__PURE__ */ jsx("div", {
1242
- className: "mt-2",
1243
- children: action
1244
- })
1245
- ]
1246
- });
1247
- }
1248
- /** A placeholder block for a loading layout. Size it with layout classes so it mirrors the final content. */
1249
- function Skeleton({ className }) {
1250
- return /* @__PURE__ */ jsx("div", {
1251
- "aria-hidden": true,
1252
- className: cn("rounded-control bg-muted motion-safe:animate-pulse", className)
1253
- });
1254
- }
1255
1764
  // src/components/secret-field.tsx
1256
1765
  var input = "w-full min-w-0 rounded-control border border-input bg-background pl-3 pr-1 type-body text-foreground transition-state placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 aria-invalid:border-danger";
1257
1766
  /** A credential the server keeps and never shows again: "Not set", "Set" (no characters, not even its length), a masked entry with a named Show toggle, Replace, a confirmed Remove that says what stops working, and a Test with its result beside it. A set, untouched field reports nothing. */
@@ -1810,7 +2319,7 @@ var DEFAULT_WORDS = {
1810
2319
  waiting: "Needs review",
1811
2320
  blocked: "Waiting"
1812
2321
  };
1813
- var LOOKS$1 = {
2322
+ var LOOKS$2 = {
1814
2323
  done: {
1815
2324
  tone: "success",
1816
2325
  icon: Check
@@ -1837,7 +2346,7 @@ var LOOKS$1 = {
1837
2346
  }
1838
2347
  };
1839
2348
  function wordOf(stage, words) {
1840
- const state = stage.state in LOOKS$1 ? stage.state : "blocked";
2349
+ const state = stage.state in LOOKS$2 ? stage.state : "blocked";
1841
2350
  if (state === "done" && stage.gate) return words.approved;
1842
2351
  return words[state];
1843
2352
  }
@@ -1872,11 +2381,11 @@ function WorkflowSteps({ label, stages, onApprove, onRetry, words, now, classNam
1872
2381
  "aria-label": label,
1873
2382
  className: cn("grid min-w-0 gap-0 divide-y divide-border", className),
1874
2383
  children: stages.map((stage) => {
1875
- const state = stage.state in LOOKS$1 ? stage.state : "blocked";
2384
+ const state = stage.state in LOOKS$2 ? stage.state : "blocked";
1876
2385
  const look = stage.state === "done" && stage.gate ? {
1877
2386
  tone: "success",
1878
2387
  icon: Check
1879
- } : LOOKS$1[state];
2388
+ } : LOOKS$2[state];
1880
2389
  const detail = detailOf(stage, now);
1881
2390
  const error = state === "failed" ? stage.last?.error : null;
1882
2391
  return /* @__PURE__ */ jsxs("li", {
@@ -1929,6 +2438,35 @@ function WorkflowSteps({ label, stages, onApprove, onRetry, words, now, classNam
1929
2438
  })
1930
2439
  });
1931
2440
  }
2441
+ // src/lib/breakpoint.ts
2442
+ var DEFAULTS = {
2443
+ sm: "40rem",
2444
+ md: "48rem",
2445
+ lg: "64rem"
2446
+ };
2447
+ function width(name) {
2448
+ if (typeof document === "undefined") return DEFAULTS[name];
2449
+ return getComputedStyle(document.documentElement).getPropertyValue(`--breakpoint-${name}`).trim() || DEFAULTS[name];
2450
+ }
2451
+ /** The breakpoints the screen is currently narrower than. Empty on the server and where `matchMedia` is missing (jsdom), so nothing is hidden there. */
2452
+ function useNarrowerThan(active) {
2453
+ const [below, setBelow] = React.useState(() => /* @__PURE__ */ new Set());
2454
+ React.useEffect(() => {
2455
+ if (!active || typeof matchMedia !== "function") return;
2456
+ const queries = [
2457
+ "sm",
2458
+ "md",
2459
+ "lg"
2460
+ ].map((name) => [name, matchMedia(`(width < ${width(name)})`)]);
2461
+ const read = () => setBelow(new Set(queries.filter(([, q]) => q.matches).map(([name]) => name)));
2462
+ read();
2463
+ for (const [, q] of queries) q.addEventListener("change", read);
2464
+ return () => {
2465
+ for (const [, q] of queries) q.removeEventListener("change", read);
2466
+ };
2467
+ }, [active]);
2468
+ return below;
2469
+ }
1932
2470
  // src/lib/choice.ts
1933
2471
  function resolve(explicit, implies) {
1934
2472
  const all = new Set(explicit);
@@ -2379,8 +2917,21 @@ var features = tableFeatures({
2379
2917
  rowSortingFeature,
2380
2918
  sortedRowModel: createSortedRowModel()
2381
2919
  });
2382
- function Table$1({ caption, columns, rows, rowKey, sortState: [sort, setSort], virtualizeFrom = 100, maxHeight = 480, selection, expansion, className }) {
2383
- const defs = React.useMemo(() => columns.map((c) => {
2920
+ var HIDE_BELOW = {
2921
+ sm: "max-sm:hidden",
2922
+ md: "max-md:hidden",
2923
+ lg: "max-lg:hidden"
2924
+ };
2925
+ function Table$1({ caption, columns: allColumns, rows, rowKey, sortState: [sort, setSort], virtualizeFrom = 100, maxHeight = 480, selection, expansion, className }) {
2926
+ const willVirtualize = rows.length >= virtualizeFrom;
2927
+ const narrower = useNarrowerThan(willVirtualize && allColumns.some((c) => c.hideBelow));
2928
+ const columns = React.useMemo(() => willVirtualize ? allColumns.filter((c, i) => i === 0 || !c.hideBelow || !narrower.has(c.hideBelow)) : allColumns, [
2929
+ allColumns,
2930
+ willVirtualize,
2931
+ narrower
2932
+ ]);
2933
+ const hiddenBelow = (c, i) => i > 0 && c.hideBelow ? HIDE_BELOW[c.hideBelow] : void 0;
2934
+ const defs = React.useMemo(() => allColumns.map((c) => {
2384
2935
  const { value, sort } = c;
2385
2936
  if (!value) return {
2386
2937
  id: c.key,
@@ -2403,9 +2954,9 @@ function Table$1({ caption, columns, rows, rowKey, sortState: [sort, setSort], v
2403
2954
  sortUndefined: "last",
2404
2955
  sortFn: sort ? (a, b) => sort(a.original, b.original) : (a, b) => compareValues(a.getValue(c.key), b.getValue(c.key))
2405
2956
  };
2406
- }), [columns]);
2957
+ }), [allColumns]);
2407
2958
  const sortable = (c) => c.value ? c.sort !== false : Boolean(c.sort);
2408
- const sorting = sort && columns.some((c) => c.key === sort.key && sortable(c)) ? [{
2959
+ const sorting = sort && allColumns.some((c) => c.key === sort.key && sortable(c)) ? [{
2409
2960
  id: sort.key,
2410
2961
  desc: sort.dir === "descending"
2411
2962
  }] : [];
@@ -2503,7 +3054,7 @@ function Table$1({ caption, columns, rows, rowKey, sortState: [sort, setSort], v
2503
3054
  isRowHeader: i === 0,
2504
3055
  allowsSorting: sortable(c),
2505
3056
  width: c.numeric ? "0.6fr" : "1fr",
2506
- className: cn("py-2 text-left align-bottom type-caption font-normal text-muted-foreground outline-offset-[-2px]", i < columns.length - 1 && "pr-4", c.numeric && "text-right"),
3057
+ className: cn("py-2 text-left align-bottom type-caption font-normal text-muted-foreground outline-offset-[-2px]", i < columns.length - 1 && "pr-4", c.numeric && "text-right", hiddenBelow(c, i)),
2507
3058
  children: ({ allowsSorting, sortDirection }) => {
2508
3059
  const Icon = sortDirection === "ascending" ? ArrowUp : sortDirection === "descending" ? ArrowDown : ArrowUpDown;
2509
3060
  const label = c.hideHeader ? /* @__PURE__ */ jsx("span", {
@@ -2554,7 +3105,7 @@ function Table$1({ caption, columns, rows, rowKey, sortState: [sort, setSort], v
2554
3105
  columns.map((c, i) => {
2555
3106
  const cell = cells.get(c.key);
2556
3107
  return /* @__PURE__ */ jsx(Cell, {
2557
- className: cn("py-2.5 align-middle", i < columns.length - 1 && "pr-4", c.numeric && "text-right tabular-nums", c.truncate && "max-w-48 truncate", c.className),
3108
+ className: cn("py-2.5 align-middle", i < columns.length - 1 && "pr-4", c.numeric && "text-right tabular-nums", c.truncate && "max-w-48 truncate", hiddenBelow(c, i), c.className),
2558
3109
  children: flexRender(cell.column.columnDef.cell, cell.getContext())
2559
3110
  }, c.key);
2560
3111
  })
@@ -2614,7 +3165,7 @@ function TableSkeleton({ rows = 4, columns = 5 }) {
2614
3165
  });
2615
3166
  }
2616
3167
  // src/components/jobs-table.tsx
2617
- var LOOKS = {
3168
+ var LOOKS$1 = {
2618
3169
  queued: {
2619
3170
  tone: "neutral",
2620
3171
  icon: Clock,
@@ -2670,7 +3221,7 @@ function JobsTable({ caption, jobs, describe = (j) => j.kind, onCancel, onRetry,
2670
3221
  key: "state",
2671
3222
  header: "State",
2672
3223
  cell: (j) => {
2673
- const look = LOOKS[j.state] ?? LOOKS.queued;
3224
+ const look = LOOKS$1[j.state] ?? LOOKS$1.queued;
2674
3225
  return /* @__PURE__ */ jsx(Status, {
2675
3226
  tone: look.tone,
2676
3227
  icon: look.icon,
@@ -2724,9 +3275,95 @@ function JobsTable({ caption, jobs, describe = (j) => j.kind, onCancel, onRetry,
2724
3275
  }) : null
2725
3276
  }
2726
3277
  ],
2727
- rows: jobs,
2728
- rowKey: (j) => String(j.id),
2729
- className: cn(className)
3278
+ rows: jobs,
3279
+ rowKey: (j) => String(j.id),
3280
+ className: cn(className)
3281
+ });
3282
+ }
3283
+ // src/components/schedule-table.tsx
3284
+ var LOOKS = {
3285
+ ok: {
3286
+ tone: "success",
3287
+ icon: Check,
3288
+ word: "OK"
3289
+ },
3290
+ success: {
3291
+ tone: "success",
3292
+ icon: Check,
3293
+ word: "OK"
3294
+ },
3295
+ failed: {
3296
+ tone: "danger",
3297
+ icon: CircleAlert,
3298
+ word: "Failed"
3299
+ },
3300
+ failure: {
3301
+ tone: "danger",
3302
+ icon: CircleAlert,
3303
+ word: "Failed"
3304
+ }
3305
+ };
3306
+ function lookOf(row) {
3307
+ if (row.running) return {
3308
+ tone: "info",
3309
+ icon: LoaderCircle,
3310
+ word: "Running"
3311
+ };
3312
+ if (row.result == null) return {
3313
+ tone: "neutral",
3314
+ icon: CircleDashed,
3315
+ word: "Never run"
3316
+ };
3317
+ return LOOKS[row.result.toLowerCase()] ?? {
3318
+ tone: "neutral",
3319
+ icon: Ban,
3320
+ word: row.result
3321
+ };
3322
+ }
3323
+ /** A table of a machine's scheduled jobs: each one's last result as a word, when it last ran and when it runs next. The last and next columns drop on a phone. */
3324
+ function ScheduleTable({ caption, rows, now, className }) {
3325
+ return /* @__PURE__ */ jsx(DataTable, {
3326
+ caption,
3327
+ columns: [
3328
+ {
3329
+ key: "label",
3330
+ header: "Job",
3331
+ cell: (r) => r.label,
3332
+ value: (r) => r.label,
3333
+ truncate: true
3334
+ },
3335
+ {
3336
+ key: "result",
3337
+ header: "Last result",
3338
+ cell: (r) => {
3339
+ const look = lookOf(r);
3340
+ return /* @__PURE__ */ jsx(Status, {
3341
+ tone: look.tone,
3342
+ icon: look.icon,
3343
+ children: look.word
3344
+ });
3345
+ },
3346
+ value: (r) => lookOf(r).word
3347
+ },
3348
+ {
3349
+ key: "last",
3350
+ header: "Last run",
3351
+ cell: (r) => format.ago(r.last, now),
3352
+ value: (r) => r.last == null ? null : new Date(r.last),
3353
+ missing: "Never",
3354
+ hideBelow: "sm"
3355
+ },
3356
+ {
3357
+ key: "next",
3358
+ header: "Next run",
3359
+ cell: (r) => format.ago(r.next, now),
3360
+ value: (r) => r.next == null ? null : new Date(r.next),
3361
+ hideBelow: "sm"
3362
+ }
3363
+ ],
3364
+ rows,
3365
+ rowKey: (r) => r.label,
3366
+ className
2730
3367
  });
2731
3368
  }
2732
3369
  // src/components/thumbnail.tsx
@@ -11520,256 +12157,6 @@ function ActiveList({ label, active, empty, children, className }) {
11520
12157
  })
11521
12158
  });
11522
12159
  }
11523
- // src/lib/base.ts
11524
- /**
11525
- * Where the app is mounted: the path of the page's `<base href>` without its trailing slash, `""` at the root or where there is no base (SSR, a plain page).
11526
- * Give it to React Router as `createBrowserRouter(routes, { basename: appBase() || "/" })`.
11527
- */
11528
- function appBase(doc = typeof document === "undefined" ? void 0 : document) {
11529
- if (!doc?.querySelector("base[href]")) return "";
11530
- return new URL(".", doc.baseURI).pathname.replace(/\/$/, "");
11531
- }
11532
- /**
11533
- * Puts the app's base in front of a root-relative path (`/api/learners` becomes `/proxy/api/learners` behind a proxy).
11534
- * Anything else (a relative path, a full URL, a protocol-relative `//host`) is returned as it is. Use it for every `fetch`, `<img src>` and download link the app builds; in-app links are router paths and need none.
11535
- */
11536
- function withBase(path, base = appBase()) {
11537
- return path.startsWith("/") && !path.startsWith("//") ? base + path : path;
11538
- }
11539
- // src/query/api.ts
11540
- var isRaw = (body) => typeof Blob !== "undefined" && body instanceof Blob || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof FormData !== "undefined" && body instanceof FormData || body instanceof URLSearchParams || typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
11541
- /**
11542
- * A small client over `fetchJson` for the app's own server: root-relative paths get the app's base (so it works behind a reverse proxy),
11543
- * and `post`, `put` and `patch` send their body as JSON (a `Blob`, bytes, `FormData` or a stream is sent as it is, with the Blob's own type). `api.post<Learner>("/api/learners", { nickname })`.
11544
- */
11545
- function createApi({ base, ...options } = {}) {
11546
- const url = (path) => withBase(path, base ?? appBase());
11547
- const send = (method, path, body, init) => fetchJson(url(path), {
11548
- ...init,
11549
- method,
11550
- ...body === void 0 ? {} : isRaw(body) ? { body } : { json: body }
11551
- }, options);
11552
- return {
11553
- url,
11554
- get: (path, init) => send("GET", path, void 0, init),
11555
- post: (path, body, init) => send("POST", path, body, init),
11556
- put: (path, body, init) => send("PUT", path, body, init),
11557
- patch: (path, body, init) => send("PATCH", path, body, init),
11558
- delete: (path, init) => send("DELETE", path, void 0, init)
11559
- };
11560
- }
11561
- // src/query/typed-api.ts
11562
- function fill(path, values, query) {
11563
- const filled = path.replace(/\{([^}]+)\}/g, (_, name) => {
11564
- const value = values?.[name];
11565
- if (value === void 0 || value === null) throw new Error(`strata-react: the path ${path} needs "${name}" in \`path\``);
11566
- return encodeURIComponent(String(value));
11567
- });
11568
- const search = new URLSearchParams();
11569
- for (const [key, value] of Object.entries(query ?? {})) for (const item of Array.isArray(value) ? value : [value]) if (item !== void 0 && item !== null) search.append(key, String(item));
11570
- const text = search.toString();
11571
- return text ? `${filled}${filled.includes("?") ? "&" : "?"}${text}` : filled;
11572
- }
11573
- /**
11574
- * `createApi` typed by the server's schema: `const api = createTypedApi<paths>()`, then `api.post("/api/learners", { json: { nickname } })` and
11575
- * `api.get("/api/learners/{id}", { path: { id } })`; the path, `path` and `query` values, `json` and the answer are checked, and `{id}` is filled and escaped.
11576
- */
11577
- function createTypedApi(options = {}) {
11578
- const api = createApi(options);
11579
- const call = (method) => (path, request) => {
11580
- const { path: values, query, json, body, ...init } = request ?? {};
11581
- const target = fill(path, values, query);
11582
- const rest = init;
11583
- return method === "get" ? api.get(target, rest) : method === "delete" ? api.delete(target, rest) : api[method](target, body ?? json, rest);
11584
- };
11585
- return {
11586
- url: api.url,
11587
- get: call("get"),
11588
- post: call("post"),
11589
- put: call("put"),
11590
- patch: call("patch"),
11591
- delete: call("delete")
11592
- };
11593
- }
11594
- // src/query/infinite.ts
11595
- /** `useInfiniteQuery` for cursor-paged data, returned as an `InfiniteLoad<T>` for `InfiniteList` (or `DataView`). */
11596
- function useInfiniteLoad({ queryKey, queryFn, items, itemKey, hasMore = () => false, nextCursor, cursorAfter = itemKey, isRemoved, describeError = describeHttpError, enabled, staleTime }) {
11597
- const queryHash = hashKey(queryKey);
11598
- const [stored, setStored] = React.useState(() => ({
11599
- query: queryHash,
11600
- keys: /* @__PURE__ */ new Set()
11601
- }));
11602
- const dismissed = stored.query === queryHash ? stored.keys : none;
11603
- const hidden = React.useCallback((key) => dismissed.has(key) || (isRemoved?.(key) ?? false), [dismissed, isRemoved]);
11604
- const latest = React.useRef({
11605
- hidden,
11606
- items,
11607
- itemKey,
11608
- hasMore,
11609
- cursorAfter,
11610
- nextCursor
11611
- });
11612
- latest.current = {
11613
- hidden,
11614
- items,
11615
- itemKey,
11616
- hasMore,
11617
- cursorAfter,
11618
- nextCursor
11619
- };
11620
- const query = useInfiniteQuery({
11621
- queryKey,
11622
- queryFn: ({ pageParam, signal }) => queryFn({
11623
- cursor: pageParam.cursor,
11624
- signal
11625
- }),
11626
- initialPageParam: { cursor: void 0 },
11627
- getNextPageParam: (lastPage, pages) => {
11628
- const l = latest.current;
11629
- if (l.nextCursor) {
11630
- const next = l.nextCursor(lastPage);
11631
- return next === null ? null : { cursor: next };
11632
- }
11633
- if (!l.hasMore(lastPage)) return null;
11634
- const after = nextAfter(pages, l.items, l.itemKey, l.hidden);
11635
- return { cursor: after === void 0 ? void 0 : l.cursorAfter(after) };
11636
- },
11637
- enabled,
11638
- staleTime
11639
- });
11640
- const pages = query.data?.pages;
11641
- const list = React.useMemo(() => pages ? merge(pages, latest.current.items, latest.current.itemKey, hidden).held : void 0, [pages, hidden]);
11642
- const { hasNextPage, isFetchingNextPage, fetchNextPage, refetch } = query;
11643
- const loadMore = React.useCallback(() => {
11644
- if (hasNextPage && !isFetchingNextPage) fetchNextPage();
11645
- }, [
11646
- hasNextPage,
11647
- isFetchingNextPage,
11648
- fetchNextPage
11649
- ]);
11650
- const change = React.useCallback((edit) => setStored((s) => {
11651
- const keys = new Set(s.query === queryHash ? s.keys : none);
11652
- edit(keys);
11653
- return {
11654
- query: queryHash,
11655
- keys
11656
- };
11657
- }), [queryHash]);
11658
- const dismiss = React.useCallback((key) => change((keys) => keys.add(key)), [change]);
11659
- const restore = React.useCallback((key) => change((keys) => keys.delete(key)), [change]);
11660
- const extra = {
11661
- more: {
11662
- hasMore: Boolean(hasNextPage),
11663
- loadingMore: isFetchingNextPage,
11664
- error: query.isFetchNextPageError ? describeError(query.error) : void 0,
11665
- loadMore
11666
- },
11667
- itemKey,
11668
- dismiss,
11669
- restore
11670
- };
11671
- if (list) {
11672
- const stale = query.isRefetchError ? staleOf(query, describeError) : void 0;
11673
- return {
11674
- status: "ready",
11675
- data: list,
11676
- ...stale && { stale },
11677
- ...extra
11678
- };
11679
- }
11680
- if (query.status === "error") return {
11681
- status: "error",
11682
- message: describeError(query.error),
11683
- retry: () => void refetch(),
11684
- ...extra
11685
- };
11686
- return {
11687
- status: "loading",
11688
- ...extra
11689
- };
11690
- }
11691
- var none = /* @__PURE__ */ new Set();
11692
- /** Every page's items, in order, once each by key: the ones held (not dismissed) and the last one seen. */
11693
- function merge(pages, items, itemKey, hidden) {
11694
- const seen = /* @__PURE__ */ new Set();
11695
- const held = [];
11696
- let last;
11697
- let lastPageAddedAny = false;
11698
- pages.forEach((page, p) => {
11699
- for (const item of items(page)) {
11700
- const key = itemKey(item);
11701
- if (seen.has(key)) continue;
11702
- seen.add(key);
11703
- last = item;
11704
- if (p === pages.length - 1) lastPageAddedAny = true;
11705
- if (!hidden(key)) held.push(item);
11706
- }
11707
- });
11708
- return {
11709
- held,
11710
- last,
11711
- lastPageAddedAny
11712
- };
11713
- }
11714
- /** The item the next page goes after: the last held, or the last seen when nothing is held or the last page brought nothing new. */
11715
- function nextAfter(pages, items, itemKey, hidden) {
11716
- const { held, last, lastPageAddedAny } = merge(pages, items, itemKey, hidden);
11717
- if (held.length === 0 || pages.length > 1 && !lastPageAddedAny) return last;
11718
- return held[held.length - 1];
11719
- }
11720
- /** `useInfiniteLoad`'s `items` and `nextCursor` for the shared `Page<T>` shape: `useInfiniteLoad({ queryKey, queryFn, itemKey, ...apiPage<Item>() })`. */
11721
- function apiPage() {
11722
- return {
11723
- items: (page) => page.items,
11724
- nextCursor: (page) => page.next
11725
- };
11726
- }
11727
- // src/query/job.ts
11728
- /** A long-running job's status: polled every `every` ms while `isRunning`, with the `invalidates` queries read again once when it ends. */
11729
- function useJob({ isRunning, every = 2e3, invalidates = [], describeError, ...options }) {
11730
- const client = useQueryClient();
11731
- const query = useQuery({
11732
- ...options,
11733
- refetchInterval: (q) => q.state.data !== void 0 && isRunning(q.state.data) ? every : false
11734
- });
11735
- const running = query.data !== void 0 && isRunning(query.data);
11736
- const queryHash = hashKey(options.queryKey);
11737
- const seen = query.data === void 0 ? void 0 : running;
11738
- const was = React.useRef(void 0);
11739
- React.useEffect(() => {
11740
- if (seen === void 0) return;
11741
- const before = was.current;
11742
- if (before && before.query === queryHash && before.running && !seen) for (const queryKey of before.invalidates) client.invalidateQueries({ queryKey });
11743
- was.current = {
11744
- query: queryHash,
11745
- running: seen,
11746
- invalidates
11747
- };
11748
- });
11749
- const { refetch } = query;
11750
- const poll = React.useCallback(() => void refetch(), [refetch]);
11751
- return {
11752
- ...toLoad(query, describeError),
11753
- running,
11754
- poll
11755
- };
11756
- }
11757
- /** Whether a task of the shared contract (`strata_python.contracts.Task`) is still going: its `state` is not one of the finished ones. Pass the generated `FINISHED`; for `useJob({ isRunning: (t) => isTaskRunning(t, FINISHED) })`. */
11758
- function isTaskRunning(task, finished) {
11759
- return !(Array.isArray(finished) ? finished.includes(task.state) : finished.has(task.state));
11760
- }
11761
- // src/query/workflow.ts
11762
- /** Whether the queue job advancing a workflow run is still going. `finished` is the generated `FINISHED` (or `["done", "failed", "cancelled"]`). */
11763
- function isWorkflowRunning(run, finished) {
11764
- return run.job != null && isTaskRunning(run.job, finished);
11765
- }
11766
- /** A subject's `WorkflowRun`: polled while its job runs, its `invalidates` read again once when it ends. */
11767
- function useWorkflowRun({ finished, ...options }) {
11768
- return useJob({
11769
- ...options,
11770
- isRunning: (run) => isWorkflowRunning(run, finished)
11771
- });
11772
- }
11773
12160
  // src/query/outbox.ts
11774
12161
  /** Whether a failure is the server's answer for good (refused) rather than for now (waiting). */
11775
12162
  function isRefusal(error) {
@@ -18499,6 +18886,6 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
18499
18886
  ]
18500
18887
  });
18501
18888
  }
18502
- export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, 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_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, PageHeader, PairJudge, PairVote, Pane, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, 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, 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, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, 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, usePlayerWarnings, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSharedCursor, useSpeech, useSystemColorScheme, useTimelineZoom, useUndoable, useViewOptions, useViewport, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
18889
+ export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, 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, 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 };
18503
18890
 
18504
18891
  //# sourceMappingURL=index.js.map