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
@@ -0,0 +1,4 @@
1
+ /** A Tailwind breakpoint a column can be hidden below. */
2
+ export type Breakpoint = "sm" | "md" | "lg";
3
+ /** The breakpoints the screen is currently narrower than. Empty on the server and where `matchMedia` is missing (jsdom), so nothing is hidden there. */
4
+ export declare function useNarrowerThan(active: boolean): Set<Breakpoint>;
@@ -3,6 +3,13 @@ export declare const NBSP = "\u00A0";
3
3
  export declare const MISSING = "\u2013";
4
4
  /** The decimal byte units `format.bytes` writes. */
5
5
  export type ByteUnit = "B" | "kB" | "MB" | "GB" | "TB" | "PB";
6
+ /** The binary byte units `format.bytes` writes with `{ binary: true }`. */
7
+ export type BinaryByteUnit = "B" | "KiB" | "MiB" | "GiB" | "TiB" | "PiB";
8
+ /** What `format.bytes` and `format.byteUnit` take beyond the value: `{ binary: true }` for KiB, MiB, GiB (powers of 1024), or a unit to fix. A binary unit implies binary. */
9
+ export type BytesOptions = {
10
+ binary?: boolean;
11
+ unit?: ByteUnit | BinaryByteUnit;
12
+ };
6
13
  /** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. `null` or `undefined` prints the placeholder. */
7
14
  export type NumberFormatter = ((value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string) & {
8
15
  format: (value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string;
@@ -90,9 +97,30 @@ export declare function createFormat(locale: string, options?: FormatOptions): {
90
97
  /**
91
98
  * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and
92
99
  * networks are sold): one decimal below 10 ("5.2 GB"), whole above ("431 GB"). Pass `unit`
93
- * to fix the unit, so figures compared side by side ("431 of 466 GB") share one.
100
+ * to fix the unit, so figures compared side by side ("431 of 466 GB") share one. Memory is
101
+ * read in binary units: `{ binary: true }` writes KiB, MiB, GiB ("7.6 GiB"), and a binary
102
+ * unit ("GiB") picks that too. The second argument is a unit or `{ binary, unit }`.
103
+ */
104
+ bytes: (value: number, unitOrOptions?: ByteUnit | BinaryByteUnit | BytesOptions) => string;
105
+ /**
106
+ * A length of time in words, the unit chosen by size: "45 s", "16 min", "3.5 h", "2 days". Unknown
107
+ * (null, negative, not finite) prints the placeholder. `style: "parts"` is an uptime, the two
108
+ * largest units written out: "1d 1h 0m", "2h 5m", "5m 3s". Not `runningTime`, which is a media clock.
109
+ */
110
+ duration: (seconds: number | null | undefined, { style }?: {
111
+ style?: "approx" | "parts";
112
+ }) => string;
113
+ /**
114
+ * A reading and its unit: `format.measure(12.34, "GB")` is "12.3 GB" (one decimal at most, a
115
+ * non-breaking space). `"%"` takes the figure as percent points and goes through `percent`, so
116
+ * the locale decides the spacing: `format.measure(41, "%")` is "41%". Unknown prints the placeholder.
117
+ */
118
+ measure: (value: number | null | undefined, unit: string) => string;
119
+ /**
120
+ * A tick for the axis of a chart of the past, from seconds before now: "now", "−30 s", "−2 min",
121
+ * "−6 h", "−3 d" (a true minus sign). Pass it as `LineChart`'s `formatX` after turning x into seconds ago.
94
122
  */
95
- bytes: (value: number, unit?: ByteUnit) => string;
123
+ agoTick: (secondsAgo: number | null | undefined) => string;
96
124
  /**
97
125
  * A distance in metres as a person says it: metres under a kilometre ("850 m"), then
98
126
  * kilometres, one decimal below 100 ("12.4 km"), whole above; `"imperial"` is feet under a
@@ -100,7 +128,9 @@ export declare function createFormat(locale: string, options?: FormatOptions): {
100
128
  */
101
129
  distance: (metres: number, system?: "metric" | "imperial") => string;
102
130
  /** The unit `bytes` would choose for a value, to share it across a set of figures. */
103
- byteUnit: (value: number) => ByteUnit;
131
+ byteUnit: (value: number, { binary }?: {
132
+ binary?: boolean;
133
+ }) => "B" | "kB" | "MB" | "GB" | "TB" | "PB" | "KiB" | "MiB" | "GiB" | "TiB" | "PiB";
104
134
  /**
105
135
  * "1 piece", "6 pieces": the count and its noun, so copy never reads "1 pieces". They are
106
136
  * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same
@@ -170,9 +200,30 @@ export declare const format: {
170
200
  /**
171
201
  * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and
172
202
  * networks are sold): one decimal below 10 ("5.2 GB"), whole above ("431 GB"). Pass `unit`
173
- * to fix the unit, so figures compared side by side ("431 of 466 GB") share one.
203
+ * to fix the unit, so figures compared side by side ("431 of 466 GB") share one. Memory is
204
+ * read in binary units: `{ binary: true }` writes KiB, MiB, GiB ("7.6 GiB"), and a binary
205
+ * unit ("GiB") picks that too. The second argument is a unit or `{ binary, unit }`.
206
+ */
207
+ bytes: (value: number, unitOrOptions?: ByteUnit | BinaryByteUnit | BytesOptions) => string;
208
+ /**
209
+ * A length of time in words, the unit chosen by size: "45 s", "16 min", "3.5 h", "2 days". Unknown
210
+ * (null, negative, not finite) prints the placeholder. `style: "parts"` is an uptime, the two
211
+ * largest units written out: "1d 1h 0m", "2h 5m", "5m 3s". Not `runningTime`, which is a media clock.
212
+ */
213
+ duration: (seconds: number | null | undefined, { style }?: {
214
+ style?: "approx" | "parts";
215
+ }) => string;
216
+ /**
217
+ * A reading and its unit: `format.measure(12.34, "GB")` is "12.3 GB" (one decimal at most, a
218
+ * non-breaking space). `"%"` takes the figure as percent points and goes through `percent`, so
219
+ * the locale decides the spacing: `format.measure(41, "%")` is "41%". Unknown prints the placeholder.
220
+ */
221
+ measure: (value: number | null | undefined, unit: string) => string;
222
+ /**
223
+ * A tick for the axis of a chart of the past, from seconds before now: "now", "−30 s", "−2 min",
224
+ * "−6 h", "−3 d" (a true minus sign). Pass it as `LineChart`'s `formatX` after turning x into seconds ago.
174
225
  */
175
- bytes: (value: number, unit?: ByteUnit) => string;
226
+ agoTick: (secondsAgo: number | null | undefined) => string;
176
227
  /**
177
228
  * A distance in metres as a person says it: metres under a kilometre ("850 m"), then
178
229
  * kilometres, one decimal below 100 ("12.4 km"), whole above; `"imperial"` is feet under a
@@ -180,7 +231,9 @@ export declare const format: {
180
231
  */
181
232
  distance: (metres: number, system?: "metric" | "imperial") => string;
182
233
  /** The unit `bytes` would choose for a value, to share it across a set of figures. */
183
- byteUnit: (value: number) => ByteUnit;
234
+ byteUnit: (value: number, { binary }?: {
235
+ binary?: boolean;
236
+ }) => "B" | "kB" | "MB" | "GB" | "TB" | "PB" | "KiB" | "MiB" | "GiB" | "TiB" | "PiB";
184
237
  /**
185
238
  * "1 piece", "6 pieces": the count and its noun, so copy never reads "1 pieces". They are
186
239
  * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same
package/dist/map.js CHANGED
@@ -1,6 +1,6 @@
1
- import { a as useColorScheme } from "./theme-By3DSUTs.js";
2
- import { d as cn, l as Tooltip$1 } from "./field-QCCmWTuY.js";
3
- import { i as format } from "./format-B32-PVi2.js";
1
+ import { u as useColorScheme } from "./theme-CFBAYaiu.js";
2
+ import { d as cn, l as Tooltip$1 } from "./field-jfhLD5XX.js";
3
+ import { i as format } from "./format-BNkXVwFx.js";
4
4
  import { n as useSharedCursor, r as geo } from "./cursor-DDGBPiTJ.js";
5
5
  import * as React from "react";
6
6
  import { Button } from "react-aria-components";
@@ -1,5 +1,5 @@
1
- import { d as cn } from "./field-QCCmWTuY.js";
2
- import { d as isDev, o as readErrorBody, r as describeHttpError, s as Button$1, t as HttpError } from "./errors-D99YX4XL.js";
1
+ import { d as cn } from "./field-jfhLD5XX.js";
2
+ import { d as isDev, o as readErrorBody, r as describeHttpError, s as Button$1, t as HttpError } from "./errors-D0TsKLwJ.js";
3
3
  import * as React from "react";
4
4
  import { Button, Text, UNSTABLE_Toast, UNSTABLE_ToastContent, UNSTABLE_ToastQueue, UNSTABLE_ToastRegion } from "react-aria-components";
5
5
  import { CircleCheck, Info, TriangleAlert, X } from "lucide-react";
@@ -7,6 +7,140 @@ import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query";
8
8
  // src/lib/overlay.ts
9
9
  var overlaySurface = "rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay";
10
+ // src/query/poll.ts
11
+ /** The pause state and last-read time of a polled screen: pass it to `useLoad({ poll })` and to `PauseButton`. */
12
+ function usePoll({ every, paused: initiallyPaused = false }) {
13
+ const [paused, setPaused] = React.useState(initiallyPaused);
14
+ const [at, setAt] = React.useState(0);
15
+ const toggle = React.useCallback(() => setPaused((p) => !p), []);
16
+ const note = React.useCallback((dataUpdatedAt) => setAt((previous) => Math.max(previous, dataUpdatedAt)), []);
17
+ return React.useMemo(() => {
18
+ const poll = {
19
+ every,
20
+ paused,
21
+ toggle,
22
+ updatedAt: at ? new Date(at) : null,
23
+ note,
24
+ with: (override) => ({
25
+ ...poll,
26
+ every: override.every,
27
+ with: (again) => poll.with(again)
28
+ })
29
+ };
30
+ return poll;
31
+ }, [
32
+ every,
33
+ paused,
34
+ toggle,
35
+ at,
36
+ note
37
+ ]);
38
+ }
39
+ /** Wires a query to its `Poll`: the time of each read, and one read when the poll is resumed. */
40
+ function usePollBinding(poll, query) {
41
+ const note = poll?.note;
42
+ React.useEffect(() => {
43
+ if (note && query.dataUpdatedAt) note(query.dataUpdatedAt);
44
+ }, [note, query.dataUpdatedAt]);
45
+ const paused = poll?.paused;
46
+ const wasPaused = React.useRef(paused);
47
+ React.useEffect(() => {
48
+ if (wasPaused.current && paused === false) query.refetch();
49
+ wasPaused.current = paused;
50
+ }, [paused]);
51
+ }
52
+ // src/query/index.tsx
53
+ /** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */
54
+ function createQueryClient(overrides) {
55
+ return new QueryClient({
56
+ ...overrides,
57
+ defaultOptions: {
58
+ ...overrides?.defaultOptions,
59
+ queries: {
60
+ retry: 1,
61
+ staleTime: 3e4,
62
+ refetchOnWindowFocus: false,
63
+ ...overrides?.defaultOptions?.queries
64
+ }
65
+ }
66
+ });
67
+ }
68
+ /** Provides a query client (Strata's defaults unless one is passed) to the app. */
69
+ function StrataQueryProvider({ client, children }) {
70
+ const [fallback] = React.useState(() => client ?? createQueryClient());
71
+ return /* @__PURE__ */ jsx(QueryClientProvider, {
72
+ client: client ?? fallback,
73
+ children
74
+ });
75
+ }
76
+ /**
77
+ * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.
78
+ * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.
79
+ */
80
+ function toLoad(query, describe = describeHttpError) {
81
+ if (query.status === "success") return {
82
+ status: "ready",
83
+ data: query.data
84
+ };
85
+ if (query.status === "error" && query.data !== void 0) return {
86
+ status: "ready",
87
+ data: query.data,
88
+ stale: staleOf(query, describe)
89
+ };
90
+ if (query.status === "error") return {
91
+ status: "error",
92
+ message: describe(query.error),
93
+ retry: () => void query.refetch()
94
+ };
95
+ return { status: "loading" };
96
+ }
97
+ /** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */
98
+ function staleOf(query, describe = describeHttpError) {
99
+ return {
100
+ message: describe(query.error),
101
+ readAt: new Date(query.dataUpdatedAt),
102
+ retry: () => void query.refetch(),
103
+ retrying: query.isFetching
104
+ };
105
+ }
106
+ /** `useQuery`, returned as a `Load<T>` for `DataView`. With `poll` (from `usePoll`) it reads again every `poll.every` ms until the person pauses it. */
107
+ function useLoad(options) {
108
+ const { describeError, poll, ...rest } = options;
109
+ const query = useQuery(poll ? {
110
+ ...rest,
111
+ refetchInterval: poll.paused ? false : poll.every
112
+ } : rest);
113
+ usePollBinding(poll, query);
114
+ return toLoad(query, describeError);
115
+ }
116
+ /**
117
+ * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
118
+ * `init.json` sends a JSON body without building the headers. A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
119
+ */
120
+ async function fetchJson(input, init, { readError = readErrorBody } = {}) {
121
+ const { json, ...rest } = init ?? {};
122
+ const headers = new Headers(rest.headers);
123
+ if (!headers.has("Accept")) headers.set("Accept", "application/json");
124
+ if (json !== void 0) {
125
+ if (!headers.has("Content-Type")) headers.set("Content-Type", "application/json");
126
+ rest.body = JSON.stringify(json);
127
+ rest.method ??= "POST";
128
+ }
129
+ const res = await fetch(input, {
130
+ ...rest,
131
+ headers
132
+ });
133
+ if (!res.ok) {
134
+ const raw = await res.text().catch(() => "");
135
+ let body = raw || void 0;
136
+ try {
137
+ if (raw) body = JSON.parse(raw);
138
+ } catch {}
139
+ throw new HttpError(res.status, res.statusText, String(input), body, readError(body));
140
+ }
141
+ const text = res.status === 204 ? "" : await res.text();
142
+ return text ? JSON.parse(text) : void 0;
143
+ }
10
144
  // src/components/toast.tsx
11
145
  var queue = new UNSTABLE_ToastQueue({ maxVisibleToasts: 3 });
12
146
  /** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */
@@ -129,93 +263,6 @@ function StrataToastRegion({ label = "Notifications", className }) {
129
263
  })
130
264
  });
131
265
  }
132
- // src/query/index.tsx
133
- /** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */
134
- function createQueryClient(overrides) {
135
- return new QueryClient({
136
- ...overrides,
137
- defaultOptions: {
138
- ...overrides?.defaultOptions,
139
- queries: {
140
- retry: 1,
141
- staleTime: 3e4,
142
- refetchOnWindowFocus: false,
143
- ...overrides?.defaultOptions?.queries
144
- }
145
- }
146
- });
147
- }
148
- /** Provides a query client (Strata's defaults unless one is passed) to the app. */
149
- function StrataQueryProvider({ client, children }) {
150
- const [fallback] = React.useState(() => client ?? createQueryClient());
151
- return /* @__PURE__ */ jsx(QueryClientProvider, {
152
- client: client ?? fallback,
153
- children
154
- });
155
- }
156
- /**
157
- * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.
158
- * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.
159
- */
160
- function toLoad(query, describe = describeHttpError) {
161
- if (query.status === "success") return {
162
- status: "ready",
163
- data: query.data
164
- };
165
- if (query.status === "error" && query.data !== void 0) return {
166
- status: "ready",
167
- data: query.data,
168
- stale: staleOf(query, describe)
169
- };
170
- if (query.status === "error") return {
171
- status: "error",
172
- message: describe(query.error),
173
- retry: () => void query.refetch()
174
- };
175
- return { status: "loading" };
176
- }
177
- /** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */
178
- function staleOf(query, describe = describeHttpError) {
179
- return {
180
- message: describe(query.error),
181
- readAt: new Date(query.dataUpdatedAt),
182
- retry: () => void query.refetch(),
183
- retrying: query.isFetching
184
- };
185
- }
186
- /** `useQuery`, returned as a `Load<T>` for `DataView`. */
187
- function useLoad(options) {
188
- const { describeError, ...rest } = options;
189
- return toLoad(useQuery(rest), describeError);
190
- }
191
- /**
192
- * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.
193
- * `init.json` sends a JSON body without building the headers. A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
194
- */
195
- async function fetchJson(input, init, { readError = readErrorBody } = {}) {
196
- const { json, ...rest } = init ?? {};
197
- const headers = new Headers(rest.headers);
198
- if (!headers.has("Accept")) headers.set("Accept", "application/json");
199
- if (json !== void 0) {
200
- if (!headers.has("Content-Type")) headers.set("Content-Type", "application/json");
201
- rest.body = JSON.stringify(json);
202
- rest.method ??= "POST";
203
- }
204
- const res = await fetch(input, {
205
- ...rest,
206
- headers
207
- });
208
- if (!res.ok) {
209
- const raw = await res.text().catch(() => "");
210
- let body = raw || void 0;
211
- try {
212
- if (raw) body = JSON.parse(raw);
213
- } catch {}
214
- throw new HttpError(res.status, res.statusText, String(input), body, readError(body));
215
- }
216
- const text = res.status === 204 ? "" : await res.text();
217
- return text ? JSON.parse(text) : void 0;
218
- }
219
266
  // src/lib/microphone.ts
220
267
  /** A microphone that would not open, with a sentence a person can act on. */
221
268
  var MicrophoneError = class extends Error {};
@@ -287,6 +334,6 @@ var browserMicrophone = { async open(onSamples) {
287
334
  var MicrophoneContext = React.createContext(browserMicrophone);
288
335
  /** The microphone from the nearest `MicrophoneContext`. */
289
336
  var useMicrophone = () => React.useContext(MicrophoneContext);
290
- export { useMicrophone as a, fetchJson as c, useLoad as d, StrataToastRegion as f, overlaySurface as h, explainMicrophoneError as i, staleOf as l, toastTimeout as m, MicrophoneError as n, StrataQueryProvider as o, toast as p, browserMicrophone as r, createQueryClient as s, MicrophoneContext as t, toLoad as u };
337
+ export { useMicrophone as a, toastTimeout as c, fetchJson as d, staleOf as f, overlaySurface as g, usePoll as h, explainMicrophoneError as i, StrataQueryProvider as l, useLoad as m, MicrophoneError as n, StrataToastRegion as o, toLoad as p, browserMicrophone as r, toast as s, MicrophoneContext as t, createQueryClient as u };
291
338
 
292
- //# sourceMappingURL=microphone-BZXMKTCM.js.map
339
+ //# sourceMappingURL=microphone-CZy0bNEx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"microphone-CZy0bNEx.js","names":["ToastQueue","ToastRegion","AriaToast","ToastContent","Button","AriaButton"],"sources":["../src/lib/overlay.ts","../src/query/poll.ts","../src/query/index.tsx","../src/components/toast.tsx","../src/lib/microphone.ts"],"sourcesContent":["// The look every floating surface shares (Dialog, Popover, and later Menu and Toast): the popover\n// role pair, an overlay radius, one hairline and the one shadow that exists for what floats\n// (components.md §3.11). One string, so a menu and a popover cannot drift apart.\nexport const overlaySurface =\n \"rounded-overlay border border-border bg-popover text-popover-foreground shadow-overlay enter-overlay\";\n","import * as React from \"react\";\nimport type { UseQueryResult } from \"@tanstack/react-query\";\n\n// Pausing a polled read (strata-react issue #344, from the status page in jburnhams/homepage). A\n// screen that re-reads every few seconds needs the same three parts every time: whether it is\n// paused, a button that says so, and when the readings were taken. A person reading a table while\n// it re-sorts under them needs the pause (ux-research `patterns.md` on live data: the person, not\n// the poll, decides when the view moves); a page whose readings may be minutes old needs the time.\n// Written by hand it was a `useState`, a button with `aria-pressed`, `refetchInterval: paused ?\n// false : ms` and an \"updated 12:00\" line, in every live screen.\n//\n// - `usePoll({ every })` holds the state and is passed to `useLoad({ poll })`, which polls at its\n// interval while it is not paused, notes when each read arrived, and reads once at once when the\n// poll is resumed (what was on screen is as old as the pause).\n// - `PauseButton` (components/pause-button.tsx) takes the same object, with its words fixed.\n// - One `Poll` may serve several reads: the page pauses together. The time is the latest read's. A read\n// with its own pace takes `poll.with({ every })`: same pause and time, other interval (#349).\n// - `useJob` keeps its own interval: a job is polled only while it runs, which is not the person's\n// to pause.\n\n/** The state of a polled read: its interval, whether the person paused it and when it last read. Made by `usePoll`. */\nexport type Poll = {\n /** Milliseconds between reads while not paused. */\n every: number;\n paused: boolean;\n /** Pause or resume. Resuming reads at once. */\n toggle: () => void;\n /** When the last read arrived, or `null` before the first. */\n updatedAt: Date | null;\n /** Used by `useLoad`: records the time of the read that just arrived (TanStack's `dataUpdatedAt`; 0 is none). */\n note: (dataUpdatedAt: number) => void;\n /** The same poll at another pace: a read that must be slower (or faster) than the page's keeps the shared pause, resume and \"updated\" time (`useLoad({ poll: poll.with({ every: 60_000 }) })`). */\n with: (override: { every: number }) => Poll;\n};\n\n/** The pause state and last-read time of a polled screen: pass it to `useLoad({ poll })` and to `PauseButton`. */\nexport function usePoll({ every, paused: initiallyPaused = false }: { every: number; paused?: boolean }): Poll {\n const [paused, setPaused] = React.useState(initiallyPaused);\n const [at, setAt] = React.useState(0);\n const toggle = React.useCallback(() => setPaused((p) => !p), []);\n const note = React.useCallback((dataUpdatedAt: number) => setAt((previous) => Math.max(previous, dataUpdatedAt)), []);\n return React.useMemo(() => {\n const poll: Poll = { every, paused, toggle, updatedAt: at ? new Date(at) : null, note, with: (override) => ({ ...poll, every: override.every, with: (again) => poll.with(again) }) };\n return poll;\n }, [every, paused, toggle, at, note]);\n}\n\n/** Wires a query to its `Poll`: the time of each read, and one read when the poll is resumed. */\nexport function usePollBinding(poll: Poll | undefined, query: Pick<UseQueryResult, \"dataUpdatedAt\" | \"refetch\">) {\n const note = poll?.note;\n React.useEffect(() => {\n if (note && query.dataUpdatedAt) note(query.dataUpdatedAt);\n }, [note, query.dataUpdatedAt]);\n const paused = poll?.paused;\n const wasPaused = React.useRef(paused);\n React.useEffect(() => {\n if (wasPaused.current && paused === false) void query.refetch();\n wasPaused.current = paused;\n // `refetch` is stable per query; only the pause changing should read.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paused]);\n}\n","import * as React from \"react\";\nimport {\n QueryClient,\n QueryClientProvider,\n useQuery,\n type QueryKey,\n type UseQueryOptions,\n type UseQueryResult,\n} from \"@tanstack/react-query\";\nimport type { Load, Stale } from \"../components/data-view\";\nimport { usePollBinding, type Poll } from \"./poll\";\nimport { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody } from \"../lib/errors\";\n\nexport { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody };\n\n// Data loading, the Strata way: TanStack Query fetches and caches, and every view of the result\n// goes through DataView, which takes a Load<T>. `toLoad` is the one bridge between them, so a\n// screen never re-derives loading/error/ready from a query's flags and never forgets one.\n//\n// Opinions in createQueryClient: one retry (a second failure is real and the person should see\n// it with a \"Try again\"), 30 s stale time (dashboards are read many times a minute but change\n// over minutes), and no refetch on window focus (a table that reorders itself while someone reads\n// it is worse than one that is 30 s old). Override per query when the data says otherwise.\n\n/** A QueryClient with Strata's defaults: one retry, 30 s stale time, no refetch on window focus. */\nexport function createQueryClient(overrides?: ConstructorParameters<typeof QueryClient>[0]) {\n return new QueryClient({\n ...overrides,\n defaultOptions: {\n ...overrides?.defaultOptions,\n queries: { retry: 1, staleTime: 30_000, refetchOnWindowFocus: false, ...overrides?.defaultOptions?.queries },\n },\n });\n}\n\n/** Provides a query client (Strata's defaults unless one is passed) to the app. */\nexport function StrataQueryProvider({ client, children }: { client?: QueryClient; children: React.ReactNode }) {\n const [fallback] = React.useState(() => client ?? createQueryClient());\n return <QueryClientProvider client={client ?? fallback}>{children}</QueryClientProvider>;\n}\n\n/**\n * Turns a TanStack query result into the `Load<T>` that `DataView` takes; errors are described for a person by `describe`.\n * A refetch that fails after data arrived stays `ready`, with `stale` saying why and when the data was read.\n */\nexport function toLoad<T>(query: UseQueryResult<T>, describe: DescribeError = describeHttpError): Load<T> {\n if (query.status === \"success\") return { status: \"ready\", data: query.data };\n // TanStack keeps the last good data when a refetch fails and sets status \"error\" (isRefetchError).\n // That is old data, not no data: keep it on screen and say how old it is.\n if (query.status === \"error\" && query.data !== undefined) return { status: \"ready\", data: query.data, stale: staleOf(query, describe) };\n if (query.status === \"error\") return { status: \"error\", message: describe(query.error), retry: () => void query.refetch() };\n return { status: \"loading\" };\n}\n\n/** The `Stale` of a query whose refetch failed after a good read. Shared by `toLoad` and `useInfiniteLoad`. */\nexport function staleOf(\n query: { error: unknown; dataUpdatedAt: number; isFetching: boolean; refetch: () => unknown },\n describe: DescribeError = describeHttpError,\n): Stale {\n return { message: describe(query.error), readAt: new Date(query.dataUpdatedAt), retry: () => void query.refetch(), retrying: query.isFetching };\n}\n\n/** `useQuery`, returned as a `Load<T>` for `DataView`. With `poll` (from `usePoll`) it reads again every `poll.every` ms until the person pauses it. */\nexport function useLoad<T, K extends QueryKey = QueryKey>(\n options: UseQueryOptions<T, Error, T, K> & {\n describeError?: DescribeError;\n /** Read again on this poll's interval unless it is paused; see `usePoll` and `PauseButton`. Replaces `refetchInterval`. */\n poll?: Poll;\n },\n): Load<T> {\n const { describeError, poll, ...rest } = options;\n const query = useQuery(poll ? { ...rest, refetchInterval: poll.paused ? false : poll.every } : rest);\n usePollBinding(poll, query);\n return toLoad(query, describeError);\n}\n\n/** What `fetchJson` takes as `fetch`'s init, plus `json`. */\nexport type FetchJsonInit = RequestInit & {\n /**\n * A value sent as the JSON body: `Content-Type: application/json` is set unless the caller gave one, and the method is `POST` unless given.\n * Replaces `body`; an app never builds the `RequestInit` for a write by hand.\n */\n json?: unknown;\n};\n\n/** Options for `fetchJson` beyond `fetch`'s own. */\nexport type FetchJsonOptions = {\n /** Finds the server's reason and per-field messages in an error body. Default `readErrorBody` (FastAPI's `detail`, `message`, `error`). */\n readError?: (body: unknown) => ErrorBody;\n};\n\n/**\n * fetch() that throws an HttpError on a non-2xx response and parses JSON: the queryFn default, and the usual commit for a write.\n * `init.json` sends a JSON body without building the headers. A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).\n */\nexport async function fetchJson<T>(input: string | URL, init?: FetchJsonInit, { readError = readErrorBody }: FetchJsonOptions = {}): Promise<T> {\n const { json, ...rest } = init ?? {};\n // Headers, tuple arrays and plain objects are all valid HeadersInit; normalise before adding the\n // default so a caller's Authorization (or their own Accept) is never dropped.\n const headers = new Headers(rest.headers);\n if (!headers.has(\"Accept\")) headers.set(\"Accept\", \"application/json\");\n if (json !== undefined) {\n if (!headers.has(\"Content-Type\")) headers.set(\"Content-Type\", \"application/json\");\n rest.body = JSON.stringify(json);\n rest.method ??= \"POST\";\n }\n const res = await fetch(input, { ...rest, headers });\n if (!res.ok) {\n // The body is read as text and parsed only when it parses: a proxy's HTML 502 page or an empty\n // body must still throw the HttpError, never a JSON SyntaxError in its place.\n const raw = await res.text().catch(() => \"\");\n let body: unknown = raw || undefined;\n try {\n if (raw) body = JSON.parse(raw);\n } catch {\n // Not JSON: keep the text.\n }\n throw new HttpError(res.status, res.statusText, String(input), body, readError(body));\n }\n // Writes (DELETE, a PUT that returns nothing) answer 204 or an empty body; that is success, not a\n // JSON parse error.\n const text = res.status === 204 ? \"\" : await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n}\n\nexport { usePoll, type Poll } from \"./poll\";\nexport { createApi, type Api, type ApiOptions } from \"./api\";\nexport { createTypedApi, type TypedApi } from \"./typed-api\";\nexport { useInfiniteLoad, apiPage, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type More } from \"./infinite\";\nexport { useJob, isTaskRunning, type Job, type JobOptions } from \"./job\";\nexport { useWorkflowRun, isWorkflowRunning, type WorkflowRunLike, type WorkflowRunOptions } from \"./workflow\";\n","import * as React from \"react\";\nimport { UNSTABLE_Toast as AriaToast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, Button as AriaButton, Text } from \"react-aria-components\";\nimport { CircleCheck, Info, TriangleAlert, X } from \"lucide-react\";\nimport { Button } from \"./button\";\nimport { cn } from \"../lib/utils\";\nimport { overlaySurface } from \"../lib/overlay\";\nimport { isDev } from \"../lib/dev\";\n\n// A toast confirms background work that finished (\"Export finished\", \"3 pieces synced\"). It is a\n// polite live region; it never carries an error a person must act on, which goes inline as an\n// `Alert` with its recovery (components.md §3.13, patterns.md §7), so there is no danger tone:\n// the type refuses it. `warning` is for a fact worth a glance (\"Kiln 2 is 40 min behind\").\n//\n// Rules the component owns so an app does not have to:\n// - One region, once, at the app root (`ToastRegion`), on the `layer-bar` layer: bottom end of the\n// window on a wide screen, the top on a phone, so it does not sit on the undo bar or cover the\n// focused control. It is a labelled landmark the keyboard reaches with F6 (React Aria).\n// - It stays long enough to read: 5 s plus 40 ms a character, up to 15 s, at least 8 s with an\n// action. The timer pauses while the pointer or focus is on it. There is always a dismiss control.\n// - At most one action, a button (\"Open file\"); content is words, not a form.\n// - Announcements are React Aria's: the toast's text is read when it appears and not again.\n// - The queue is module-level, so `toast.show()` works from a mutation's `onSuccess` outside any\n// component; `toast.clear()` empties it for a test. React Aria marks its toast API unstable; it\n// is used only here, behind this small surface, so a change upstream stays in this file.\n// - One region at a time, enforced (issue #230): the first mounted owns the queue and a second one draws nothing and\n// says so in development, naming the fix. Two regions on one queue show every toast twice, which looks like a bug in\n// the toast and (in a test) fails `findByText` with \"Found multiple elements\"; the usual cause is a route tree that\n// draws the region in its root layout while a test helper draws one too (`renderRoutes(..., { toasts: false })`),\n// or an app with a region in a layout and another in a page. Ownership is held by a mounted-order list, not by the\n// queue, so unmounting the owner hands it to the next region.\n// Toasts are rare and brief, so they get the overlay entrance and nothing else (character.md §3).\n\n/** What a toast says. */\nexport type ToastContentProps = {\n /** What finished, past tense, in the product's words: \"Export finished\". */\n title: string;\n /** One more sentence: what and where (\"run.mp4, 2:31 at 1080p, in your Downloads folder.\"). */\n description?: string;\n /** `info` by default. There is no danger tone: an error the person must act on is an `Alert`. */\n tone?: \"info\" | \"success\" | \"warning\";\n /** One action beside the words. */\n action?: { label: string; onPress: () => void };\n /** Milliseconds before it goes. Defaults to enough to read the words. */\n timeout?: number;\n};\n\nconst queue = new ToastQueue<ToastContentProps>({ maxVisibleToasts: 3 });\n\n/** Milliseconds a toast stays: 5 s plus 40 ms a character, to at most 15 s, and at least 8 s with an action. */\nexport function toastTimeout(content: Pick<ToastContentProps, \"title\" | \"description\" | \"action\" | \"timeout\">): number {\n if (content.timeout !== undefined) return content.timeout;\n const chars = content.title.length + (content.description?.length ?? 0) + (content.action?.label.length ?? 0);\n return Math.max(content.action ? 8000 : 0, Math.min(15000, 5000 + 40 * chars));\n}\n\n/** The toast queue: `toast.show({ title })` from anywhere; `toast.close(key)`; `toast.clear()`. */\nexport const toast = {\n /** Shows a toast and returns its key. */\n show(content: ToastContentProps): string {\n // Nothing appears without a region, and nothing says so: in development the first such call does (issue #249).\n if (mounted.length === 0 && !warnedNoRegion && isDev()) {\n warnedNoRegion = true;\n console.warn(\"strata-react: toast.show() was called but no StrataToastRegion is mounted, so nothing will appear. Render <StrataToastRegion /> once at the app root.\");\n }\n return queue.add(content, { timeout: toastTimeout(content) });\n },\n close(key: string) {\n queue.close(key);\n },\n clear() {\n queue.clear();\n },\n};\n\nconst marks = { info: { icon: Info, color: \"text-info\" }, success: { icon: CircleCheck, color: \"text-success\" }, warning: { icon: TriangleAlert, color: \"text-warning\" } } as const;\n\n/** Props for `ToastRegion`. */\nexport type StrataToastRegionProps = {\n /** Names the landmark. Default \"Notifications\". */\n label?: string;\n className?: string;\n};\n\n// The regions mounted now, oldest first: the first draws, the rest stay empty.\nconst mounted: string[] = [];\nlet warnedNoRegion = false;\n/** For tests: forget that the missing-region warning was given. */\nexport function resetToastWarnings() {\n warnedNoRegion = false;\n}\nconst watchers = new Set<() => void>();\nconst changed = () => watchers.forEach((w) => w());\nconst watch = (w: () => void) => {\n watchers.add(w);\n return () => void watchers.delete(w);\n};\n\n/** True while this region is the one that draws. The server and the first client render say yes, so hydration matches. */\nfunction useOwnsQueue(): boolean {\n const id = React.useId();\n React.useLayoutEffect(() => {\n mounted.push(id);\n changed();\n return () => {\n mounted.splice(mounted.indexOf(id), 1);\n changed();\n };\n }, [id]);\n const owns = React.useSyncExternalStore(watch, () => mounted[0] === id, () => true);\n const [warned, setWarned] = React.useState(false);\n React.useEffect(() => {\n if (owns || warned || mounted.indexOf(id) < 1) return;\n setWarned(true);\n if (isDev()) {\n console.warn(\"strata-react: a StrataToastRegion is already mounted, so this one draws nothing. Render it once at the app root; in a test of a route tree that draws its own, pass `toasts: false` to renderRoutes.\");\n }\n }, [owns, warned, id]);\n return owns;\n}\n\n/** The one place toasts appear. Render it once at the app root; a second one mounted at the same time draws nothing and warns in development. A labelled landmark (F6), polite, above panes and the undo bar. */\nexport function StrataToastRegion({ label = \"Notifications\", className }: StrataToastRegionProps) {\n const owns = useOwnsQueue();\n if (!owns) return null;\n return (\n <ToastRegion\n queue={queue}\n aria-label={label}\n className={cn(\"layer-bar fixed inset-x-4 top-4 grid justify-items-end gap-2 outline-none sm:inset-x-auto sm:top-auto sm:right-4 sm:bottom-4\", className)}\n >\n {({ toast: t }) => (\n <AriaToast\n toast={t}\n className={cn(\"flex w-full max-w-sm items-start gap-3 p-3 outline-none focus-visible:outline-2 focus-visible:outline-ring\", overlaySurface)}\n >\n {(() => {\n const { icon: Icon, color } = marks[t.content.tone ?? \"info\"];\n return <Icon aria-hidden className={cn(\"mt-0.5 size-4 shrink-0\", color)} />;\n })()}\n <ToastContent className=\"grid min-w-0 flex-1 gap-0.5\">\n <Text slot=\"title\" className=\"type-label\">\n {t.content.title}\n </Text>\n {t.content.description && <Text slot=\"description\" className=\"type-body-sm text-muted-foreground\">{t.content.description}</Text>}\n </ToastContent>\n {t.content.action && (\n <Button size=\"sm\" onPress={() => { t.content.action?.onPress(); queue.close(t.key); }}>\n {t.content.action.label}\n </Button>\n )}\n <AriaButton slot=\"close\" aria-label=\"Dismiss\" className=\"grid size-6 shrink-0 cursor-pointer place-items-center rounded-control text-muted-foreground transition-state hover:bg-muted hover:text-foreground\">\n <X aria-hidden className=\"size-4\" />\n </AriaButton>\n </AriaToast>\n )}\n </ToastRegion>\n );\n}\n","import * as React from \"react\";\n\n// The microphone as raw samples, for an app that records speech (strata-voice's studio). What an app would\n// otherwise write each time:\n// - MediaRecorder only writes compressed audio, so the samples come through an AudioWorklet (loaded from a\n// Blob URL, so the app ships no worklet file) that posts 2048 frames at a time (~43 ms at 48 kHz): about\n// 23 messages a second instead of one per 128-frame render quantum.\n// - Echo cancellation, noise suppression and automatic gain are off: each reshapes a voice, and a take is\n// meant to be the voice as it was. The worklet feeds a silent gain into the output, because a worklet\n// nothing pulls does not run.\n// - getUserMedia exists only on a secure page (https:// or http://localhost), and its refusals are\n// DOMExceptions by name; `explainMicrophoneError` turns both into a sentence a person can act on.\n// - The device is behind `MicrophoneContext`, so a screen takes it from `useMicrophone()` and a test or\n// story gives it `fakeMicrophone()` (strata-react/testing) instead: hardware is the one true external.\n// Not a React Aria part: there is none for capture, and nothing here is a control.\n// `browserMicrophone` is covered by the stories in Chromium only: jsdom has no audio graph.\n\n/** A microphone that is open and sending samples. */\nexport type MicrophoneStream = {\n sampleRate: number;\n /** What the browser calls the device (\"USB Audio Device\"), or null when it says nothing. */\n device: string | null;\n /** Stops the device (the browser's recording light goes out). */\n close: () => void;\n};\n\n/** Something that can be opened to send mono samples (-1 to 1) a chunk at a time. */\nexport type Microphone = {\n open: (onSamples: (chunk: Float32Array) => void) => Promise<MicrophoneStream>;\n};\n\n/** A microphone that would not open, with a sentence a person can act on. */\nexport class MicrophoneError extends Error {}\n\n/** The sentence for what getUserMedia threw. */\nexport function explainMicrophoneError(e: unknown): MicrophoneError {\n const name = e instanceof DOMException ? e.name : \"\";\n if (name === \"NotAllowedError\")\n return new MicrophoneError(\"The browser was not allowed to use the microphone. Allow it from the address bar, then try again.\");\n if (name === \"NotFoundError\") return new MicrophoneError(\"No microphone was found. Plug one in, then try again.\");\n if (name === \"NotReadableError\") return new MicrophoneError(\"The microphone is in use by another program. Close it, then try again.\");\n // DOMException is checked apart from Error: it is an Error in browsers but not in every runtime (jsdom).\n const said = e instanceof DOMException || e instanceof Error ? e.message : String(e);\n return new MicrophoneError(`The microphone could not be opened (${said}).`);\n}\n\nconst WORKLET = `\nclass StrataTap extends AudioWorkletProcessor {\n constructor() { super(); this.buf = new Float32Array(2048); this.n = 0 }\n process(inputs) {\n const ch = inputs[0] && inputs[0][0]\n if (ch) for (let i = 0; i < ch.length; i++) {\n this.buf[this.n++] = ch[i]\n if (this.n === this.buf.length) { this.port.postMessage(this.buf.slice()); this.n = 0 }\n }\n return true\n }\n}\nregisterProcessor('strata-tap', StrataTap)\n`;\n\n/** The browser's own microphone, with its processing off. */\nexport const browserMicrophone: Microphone = {\n async open(onSamples) {\n if (typeof navigator === \"undefined\" || !navigator.mediaDevices?.getUserMedia)\n throw new MicrophoneError(\"The microphone needs a secure page: open the app at http://localhost or over https.\");\n let media: MediaStream;\n try {\n media = await navigator.mediaDevices.getUserMedia({\n audio: { channelCount: 1, echoCancellation: false, noiseSuppression: false, autoGainControl: false },\n });\n } catch (e) {\n throw explainMicrophoneError(e);\n }\n let context: AudioContext | undefined;\n const close = () => {\n for (const t of media.getTracks()) t.stop();\n void context?.close();\n };\n // Once the device is open, any failure building the graph closes it again: the caller gets no stream to\n // close, and the browser's recording light would otherwise stay on.\n try {\n context = new AudioContext();\n const url = URL.createObjectURL(new Blob([WORKLET], { type: \"text/javascript\" }));\n try {\n await context.audioWorklet.addModule(url);\n } finally {\n URL.revokeObjectURL(url);\n }\n const tap = new AudioWorkletNode(context, \"strata-tap\");\n tap.port.onmessage = (event: MessageEvent<Float32Array>) => onSamples(event.data);\n const mute = context.createGain();\n mute.gain.value = 0;\n context.createMediaStreamSource(media).connect(tap).connect(mute).connect(context.destination);\n return { sampleRate: context.sampleRate, device: media.getAudioTracks()[0]?.label || null, close };\n } catch (e) {\n close();\n throw explainMicrophoneError(e);\n }\n },\n};\n\n/** The microphone screens record from: the browser's, unless a provider gives another (a fake in tests and stories). */\nexport const MicrophoneContext = React.createContext<Microphone>(browserMicrophone);\n\n/** The microphone from the nearest `MicrophoneContext`. */\nexport const useMicrophone = (): Microphone => React.useContext(MicrophoneContext);\n"],"mappings":";;;;;;;;AAGA,IAAa,iBACX;;;ACgCF,SAAgB,QAAQ,EAAE,OAAO,QAAQ,kBAAkB,SAAoD;CAC7G,MAAM,CAAC,QAAQ,aAAa,MAAM,SAAS,eAAe;CAC1D,MAAM,CAAC,IAAI,SAAS,MAAM,SAAS,CAAC;CACpC,MAAM,SAAS,MAAM,kBAAkB,WAAW,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;CAC/D,MAAM,OAAO,MAAM,aAAa,kBAA0B,OAAO,aAAa,KAAK,IAAI,UAAU,aAAa,CAAC,GAAG,CAAC,CAAC;CACpH,OAAO,MAAM,cAAc;EACzB,MAAM,OAAa;GAAE;GAAO;GAAQ;GAAQ,WAAW,KAAK,IAAI,KAAK,EAAE,I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,QAAQ,aAAa,UAAU,GAAG;EAC1C,UAAU;GACR,IAAI,gBAAgB,GAAG;EACzB;EACA,MAAM,MAAM,IAAI,iBAAiB,SAAS,YAAY;EACtD,IAAI,KAAK,aAAa,UAAsC,UAAU,MAAM,IAAI;EAChF,MAAM,OAAO,QAAQ,WAAW;EAChC,KAAK,KAAK,QAAQ;EAClB,QAAQ,wBAAwB,KAAK,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,QAAQ,QAAQ,WAAW;EAC7F,OAAO;GAAE,YAAY,QAAQ;GAAY,QAAQ,MAAM,eAAe,CAAC,CAAC,EAAE,EAAE,SAAS;GAAM;EAAM;CACnG,SAAS,GAAG;EACV,MAAM;EACN,MAAM,uBAAuB,CAAC;CAChC;AACF,EACF;;AAGA,IAAa,oBAAoB,MAAM,cAA0B,iBAAiB;;AAGlF,IAAa,sBAAkC,MAAM,WAAW,iBAAiB"}
package/dist/panorama.js CHANGED
@@ -1,5 +1,5 @@
1
- import { d as useInView, r as Slider } from "./value-controls-B7iNh4WO.js";
2
- import { d as cn } from "./field-QCCmWTuY.js";
1
+ import { d as useInView, r as Slider } from "./value-controls-WRXbtUp6.js";
2
+ import { d as cn } from "./field-jfhLD5XX.js";
3
3
  import * as React from "react";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { VisuallyHidden } from "react-aria";
@@ -1,5 +1,6 @@
1
1
  import { QueryClient, QueryKey, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
2
2
  import { Load, Stale } from '../components/data-view';
3
+ import { Poll } from './poll';
3
4
  import { HttpError, describeHttpError, errorPayload, readErrorBody, DescribeError, ErrorBody } from '../lib/errors';
4
5
  import * as React from "react";
5
6
  export { HttpError, describeHttpError, errorPayload, readErrorBody, type DescribeError, type ErrorBody };
@@ -22,9 +23,11 @@ export declare function staleOf(query: {
22
23
  isFetching: boolean;
23
24
  refetch: () => unknown;
24
25
  }, describe?: DescribeError): Stale;
25
- /** `useQuery`, returned as a `Load<T>` for `DataView`. */
26
+ /** `useQuery`, returned as a `Load<T>` for `DataView`. With `poll` (from `usePoll`) it reads again every `poll.every` ms until the person pauses it. */
26
27
  export declare function useLoad<T, K extends QueryKey = QueryKey>(options: UseQueryOptions<T, Error, T, K> & {
27
28
  describeError?: DescribeError;
29
+ /** Read again on this poll's interval unless it is paused; see `usePoll` and `PauseButton`. Replaces `refetchInterval`. */
30
+ poll?: Poll;
28
31
  }): Load<T>;
29
32
  /** What `fetchJson` takes as `fetch`'s init, plus `json`. */
30
33
  export type FetchJsonInit = RequestInit & {
@@ -44,6 +47,7 @@ export type FetchJsonOptions = {
44
47
  * `init.json` sends a JSON body without building the headers. A 204 or empty body resolves to undefined. An error response's body is read onto the HttpError (`body`, `reason`, `fieldErrors`).
45
48
  */
46
49
  export declare function fetchJson<T>(input: string | URL, init?: FetchJsonInit, { readError }?: FetchJsonOptions): Promise<T>;
50
+ export { usePoll, type Poll } from './poll';
47
51
  export { createApi, type Api, type ApiOptions } from './api';
48
52
  export { createTypedApi, type TypedApi } from './typed-api';
49
53
  export { useInfiniteLoad, apiPage, type ApiPage, type InfiniteLoad, type InfiniteLoadOptions, type More } from './infinite';
@@ -0,0 +1,24 @@
1
+ import { UseQueryResult } from '@tanstack/react-query';
2
+ /** The state of a polled read: its interval, whether the person paused it and when it last read. Made by `usePoll`. */
3
+ export type Poll = {
4
+ /** Milliseconds between reads while not paused. */
5
+ every: number;
6
+ paused: boolean;
7
+ /** Pause or resume. Resuming reads at once. */
8
+ toggle: () => void;
9
+ /** When the last read arrived, or `null` before the first. */
10
+ updatedAt: Date | null;
11
+ /** Used by `useLoad`: records the time of the read that just arrived (TanStack's `dataUpdatedAt`; 0 is none). */
12
+ note: (dataUpdatedAt: number) => void;
13
+ /** The same poll at another pace: a read that must be slower (or faster) than the page's keeps the shared pause, resume and "updated" time (`useLoad({ poll: poll.with({ every: 60_000 }) })`). */
14
+ with: (override: {
15
+ every: number;
16
+ }) => Poll;
17
+ };
18
+ /** The pause state and last-read time of a polled screen: pass it to `useLoad({ poll })` and to `PauseButton`. */
19
+ export declare function usePoll({ every, paused: initiallyPaused }: {
20
+ every: number;
21
+ paused?: boolean;
22
+ }): Poll;
23
+ /** Wires a query to its `Poll`: the time of each read, and one read when the poll is resumed. */
24
+ export declare function usePollBinding(poll: Poll | undefined, query: Pick<UseQueryResult, "dataUpdatedAt" | "refetch">): void;
@@ -0,0 +1,11 @@
1
+ /* The reading serif, opt-in (`@import "strata-react/reading.css"` after strata.css): Source Serif 4 with its
2
+ optical-size axis, for surfaces people read rather than operate (an article, notes, a long description),
3
+ as `font-reading`. Chosen by Jonathan on 2026-11-25 from a specimen of six: sturdy proportions, a generous
4
+ x-height and clear numerals and units ("200 °C", "1,222"), and it sits well beside Instrument Sans.
5
+ Not in strata.css on purpose: Operate screens keep the sans, and an app that never reads long text should
6
+ not bundle the files (ux-slop-taxonomy §3b: a serif page title on a dashboard is an editorial costume). */
7
+ @import "@fontsource-variable/source-serif-4/opsz.css";
8
+
9
+ @theme {
10
+ --font-reading: "Source Serif 4 Variable", ui-serif, Georgia, serif;
11
+ }