strata-react 2.1.7 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -224,6 +224,7 @@ thousands of lines. Such an app imports the same stylesheet **without the reset*
224
224
  | Workspace | `Workspace`, `WorkspaceBar`, `Split`, `Pane`, `useWorkspaceState`, `WorkspaceState` | One screen of panes for a tool: splits of panes with a growing stage, a header on every pane (name, actions, fold button), separators that resize by pointer and by keyboard (arrows, Shift, Home, End, Enter to restore) within each pane's `min` and `max`, panes that fold to a rail or header bar with a visible way back (and `state.toggle(id)` from a menu), sizes and folds remembered with `useWorkspaceState("name")`, and stacking below 720px. `WorkspaceBar` is the one bar across the top (the tool's name as the `h1`, a polite status, the filled action, an end slot for the scheme and palette choice, wrapping on a phone), where `PageHeader` is an app screen's heading and `Toolbar` a row of controls inside a pane. A pane's body is inset by default so an `Inspector` lines up with the pane's name; `flush` draws a tree, table or stage edge to edge. `onFiles` and `acceptLabel` on `Workspace` take files dropped anywhere on the window (`FileDropOverlay`). Each pane is a labelled region |
225
225
  | Writes kept while offline | `createOutbox`, `useOutbox`, `useOutboxStarted`, `OutboxStatus`, `isRefusal` | Writes that must not be lost when the connection is (answers in a game played on a tablet whose wifi drops): kept in localStorage (`strata:outbox:<name>`), sent one at a time oldest first, a dependent write (`after`) refused with what it follows; a 4xx is refused and listed with the server's reason until dismissed, anything else (no answer, 5xx, 401/403 from a login, 408, 429) waits and is tried again after 2 s doubling to a minute, at once on `online` or when the page is shown. `add` answers how the first try went (`sent`, `waiting`, `refused`) so a screen goes on without the server. Every write must be idempotent on the server (a client-made id). `OutboxStatus noun="answer"` is the sign: nothing while all is sent, "3 answers kept on this device. The server could not be reached. Trying again at 10:42." with Send now, and the refused list |
226
226
  | Items kept for offline | `createReserve`, `useReserve` | The read side of the outbox: items the server made ahead (rounds of play), kept per key in localStorage (`strata:reserve:<name>:<key>`), `size` each. `take(key)` removes and returns the oldest (an item is used once); `refresh(key, fresh)` after a fresh item arrives drops kept items `sameMake(kept, fresh)` calls out of date and tops up in one request when fewer than half remain (one in flight per key; a failure is tried again at the next refresh); `useReserve(reserve, key)` is the count for "6 rounds kept for offline"; `seed` and `clear` for tests and stories. Without storage nothing is kept and `persisted` says so |
227
+ | Drawing | `useDrawing`, `DrawingLayer`, `DrawingToolbar`, `Drawing`, `Stroke`, `Brush`, `DrawingOp`, `BRUSHES`, `feedbackMarker`, `applyOp`, `invertOp`, `replay`, `rescaleDrawing`, `drawingToSvg` | Drawing on a picture as vectors: each stroke is its brush (pen, pencil, marker, highlighter, brush; colour, width, opacity, hardness, round, square or chisel nib, pressure) and its points, with an optional note. Every change is an operation (add, remove, change) carrying what it replaced, so `invertOp` needs no document, `useDrawing`'s `log` is the whole history (`replay(initial, log)` rebuilds the drawing) and Undo and Redo are `useHistory` steps ("Undo move mark"). `DrawingLayer` is the SVG over the picture: draw (pen pressure, or a mouse's slowness), select (press a stroke, drag it, drag a corner to resize; Enter, arrows, `[` `]`, Delete and N from the keyboard), erase (whole strokes touched, one step) or `none` (the picture keeps its pan), and a note box anchored to a stroke (`noteFor`). `DrawingToolbar` is the full kit; an app with one preset draws its own two controls. `Compare markup=` lays a layer over the pictures in every view, zoomed and panned with them. `drawingToSvg` exports a standalone SVG drawn the same way, notes as titles |
227
228
  | History and save state | `useHistory`, `useHistoryState`, `History`, `useAutoSave`, `SaveStatus`, `SaveState`, `useLeaveGuard` | Undo and redo for a document edited over a session: a step is a name and an `undo`/`redo` pair, `begin(label)` groups a drag into one step, a `key` merges a slider's pushes, a `limit` drops the oldest. `history.commands` are Undo and Redo as `Command`s ("Undo move clip", Mod+Z, Mod+Shift+Z or Mod+Y) for `useCommands` and `Menu`. `useAutoSave` debounces and never overlaps saves; `SaveStatus` is the fixed-width sign ("Saved 10:42", "Saving…", "Unsaved changes", "Not saved" with the reason and "Try again"), quiet except for a failure and its recovery. For one removal that commits after a few seconds, use `useUndoable` |
228
229
  | Links and URL choices | `ButtonLink`, `TextLink`, `useSearchParam`, `NativeSelect param=`, `ChoiceGroup param=`, `ToggleGroup param=` | `ButtonLink` is a link (`to` for a route, `href` for a download) drawn as a `Button` with its variants; it sets `data-variant`, so `variant="default"` is the view's one filled button for `expectOneFilledButton()`. `TextLink` is the house in-app link. Both are React Aria links with React Router navigation. A filter or choice a person would link to is `useSearchParam("mode", { default, parse })` (the default is never written, an invalid value reads as the default, other params are kept, history is replaced), or `param=` on the three controls, as `Tabs` does |
229
230
  | Speech | `speak`, `useSpeech`, `SayAgain`, `SayPicture`, `ClipsProvider`, `useClips`, `useSayOnShow`, `canSay`, `textOf`, `installFakeSpeech` (`strata-react/testing`) | The browser's `speechSynthesis` with the voice picked by language once voices have loaded, what is being said cancelled by the next prompt, a slightly slow default rate, and nothing where there is no speech or the person muted it. Recorded prompts (`speak(parts)`, `SayAgain parts=`): each part's clip plays in order, and the browser's voice says the words when a part has no clip or one fails (one voice per prompt). `SayAgain`'s name is the sentence it says; `SayPicture` is the same on a big picture (the picture alone where nothing can be heard). `installFakeSpeech()` records what was said and which clips played in a test (`clips()`, `finish()`, `failClip()`) . `ClipsProvider load=` reads the app's clip list once (a record of line text to URL, read again only when `clipsQueryKey` is invalidated); `useClips()` gives `ready`, `parts(text)`, `say(text)` and `words(text)` (`split` cuts a prompt into lines, `describe` words a line that has no clip), `useSayOnShow(text)` says a prompt once the list has arrived or failed, and `SayAgain` inside the provider needs no `parts` or `lang`; outside it, the browser's voice alone |
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as AsyncActionOptions, B as RowAction, C as useColorScheme, D as DensityName, E as Density, F as useAsyncAction, H as buttonVariants, I as Button, L as ButtonProps, M as AsyncLabels, N as FieldErrors, O as DensityProps, P as Phase, R as IconButton, S as palettes, T as useSystemColorScheme, U as ControlSize, V as RowActionProps, W as IconComponent, _ as PaletteOption, a as browserMicrophone, b as colorSchemeScript, c as COLOR_SCHEME_STORAGE_KEY, d as ColorSchemeLabels, f as ColorSchemePreference, g as PaletteChoice, h as PALETTE_STORAGE_KEY, i as MicrophoneStream, j as AsyncButton, k as AsyncAction, l as ColorScheme, m as DEFAULT_PALETTE, n as MicrophoneContext, o as explainMicrophoneError, p as ColorSchemeState, r as MicrophoneError, s as useMicrophone, t as Microphone, u as ColorSchemeChoice, v as PaletteState, w as usePalette, x as paletteScript, y as ThemeProvider, z as IconButtonProps } from "./microphone-xGKxcK6p.js";
1
+ import { A as AsyncActionOptions, B as RowAction, C as useColorScheme, D as DensityName, E as Density, F as useAsyncAction, H as buttonVariants, I as Button, L as ButtonProps, M as AsyncLabels, N as FieldErrors, O as DensityProps, P as Phase, R as IconButton, S as palettes, T as useSystemColorScheme, U as ControlSize, V as RowActionProps, W as IconComponent, _ as PaletteOption, a as browserMicrophone, b as colorSchemeScript, c as COLOR_SCHEME_STORAGE_KEY, d as ColorSchemeLabels, f as ColorSchemePreference, g as PaletteChoice, h as PALETTE_STORAGE_KEY, i as MicrophoneStream, j as AsyncButton, k as AsyncAction, l as ColorScheme, m as DEFAULT_PALETTE, n as MicrophoneContext, o as explainMicrophoneError, p as ColorSchemeState, r as MicrophoneError, s as useMicrophone, t as Microphone, u as ColorSchemeChoice, v as PaletteState, w as usePalette, x as paletteScript, y as ThemeProvider, z as IconButtonProps } from "./microphone-DWh4OaMH.js";
2
2
  import { n as geo, t as LatLng } from "./geo-DfKa9JtK.js";
3
3
  import { $ as ChartMark, A as SpanOutcome, B as StageGuides, C as MediaSpanData, Ct as PlayerWarning, D as SpanActionsNotice, E as SpanActions, F as RateChoice, G as VolumeControlProps, H as Transport, I as SeekBar, J as KeysLegend, K as transportShortcuts, L as SeekBarProps, M as useMediaSpans, N as MediaStage, O as SpanBehaviour, P as Precision, Q as useHotkeys, R as SeekBarSpan, S as MediaProgress, St as skipAction, T as PlayerNotice, Tt as usePlayerWarnings, U as TransportProps, V as TimeReadout, W as VolumeControl, X as isTypingTarget, Y as Shortcut, Z as keyName, _ as MediaStat, _t as MediaMark, a as MediaPlayerProps, at as LineChartProps, b as mediaStatRows, bt as SkipSteps, c as MediaSource, ct as YScale, d as SPEECH_RATES, dt as CursorMapping, et as ChartSpan, f as SourceAttacher, ft as CursorOwner, g as useMediaElement, gt as useSharedCursor, h as useAttachedSource, ht as SharedCursor, i as MediaPlayer, it as LineChartGroupProps, j as SpanWords, k as SpanKind, l as MediaWindow, lt as logScale, m as StreamContext, mt as CursorScopeProps, n as MediaElementState, nt as LineChart, o as MediaProblem, ot as Point, p as StreamAttachment, pt as CursorScope, q as HotkeysOptions, r as MediaHeading, rt as LineChartGroup, s as MediaSession, st as SpanTone, t as MediaElementOptions, tt as GroupedChart, u as ResumeWords, ut as valueAt, v as MediaStats, vt as SkipAction, w as MediaSpansState, wt as PlayerWarningEvent, x as useMediaStats, xt as marksFor, y as StreamStats, yt as SkipLevel, z as SpanStrip } from "./media-player-C6j069Aa.js";
4
4
  import { ClassValue } from "clsx";
@@ -4220,6 +4220,8 @@ type ViewportFrameProps = ViewportState & {
4220
4220
  shown: number;
4221
4221
  axis?: "x" | "y";
4222
4222
  };
4223
+ /** Drawn over the picture and `cover`, zoomed and panned with them: a `DrawingLayer` on the picture. The layer passes no pointer events of its own (`pointer-events-none`); what it draws decides whether it takes them, and a press it takes is stopped there so it does not pan. */
4224
+ markup?: React.ReactNode;
4223
4225
  /** Drawn over the frame, not zoomed with it: a divider to drag, a corner label. Its pointer, key and double-click events do not reach the frame, so using it never pans the picture. */
4224
4226
  overlay?: React.ReactNode;
4225
4227
  /** The tallest the frame may be, as a CSS length (`"60svh"`). The width follows, narrower than the space it has and centred, so the picture keeps its shape. Default: no limit, the frame is as tall as its width and aspect make it. */
@@ -4250,6 +4252,8 @@ export declare const ViewportFrame: React.ForwardRefExoticComponent<ViewportStat
4250
4252
  shown: number;
4251
4253
  axis?: "x" | "y";
4252
4254
  };
4255
+ /** Drawn over the picture and `cover`, zoomed and panned with them: a `DrawingLayer` on the picture. The layer passes no pointer events of its own (`pointer-events-none`); what it draws decides whether it takes them, and a press it takes is stopped there so it does not pan. */
4256
+ markup?: React.ReactNode;
4253
4257
  /** Drawn over the frame, not zoomed with it: a divider to drag, a corner label. Its pointer, key and double-click events do not reach the frame, so using it never pans the picture. */
4254
4258
  overlay?: React.ReactNode;
4255
4259
  /** The tallest the frame may be, as a CSS length (`"60svh"`). The width follows, narrower than the space it has and centred, so the picture keeps its shape. Default: no limit, the frame is as tall as its width and aspect make it. */
@@ -4439,12 +4443,22 @@ type CompareProps = {
4439
4443
  keys?: boolean;
4440
4444
  /** Shortcuts of the surrounding screen (the answer keys of a `PairVote`), bound with Compare's own and drawn in the same legend, so there is one list and the two cannot clash unseen. Listed first. */
4441
4445
  extraShortcuts?: Shortcut[];
4446
+ /**
4447
+ * A layer drawn over the pictures, zoomed and panned with them, in every view: a `DrawingLayer`
4448
+ * for marks on the pair. Called once the picture's natural size is known, with that size and
4449
+ * whether this is the first frame (side by side and above and below draw two frames, so two
4450
+ * layers show one drawing; give a note box to the `primary` one only).
4451
+ */
4452
+ markup?: (frame: {
4453
+ size: readonly [number, number];
4454
+ primary: boolean;
4455
+ }) => React.ReactNode;
4442
4456
  /** Drawn under the picture, above the legend, and kept in full screen: where a vote bar goes so the answer is never out of reach of the pictures. */
4443
4457
  footer?: React.ReactNode;
4444
4458
  className?: string;
4445
4459
  };
4446
4460
  /** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
4447
- export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, regions, onPick, pick, pickWords, keys, extraShortcuts, footer, maxHeight, reserve, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
4461
+ export declare function Compare({ label, a, b, blind, missing, mode, onModeChange, modes, regions, onPick, pick, pickWords, keys, extraShortcuts, markup, footer, maxHeight, reserve, cannotCompare, readPixels, defaultDifference, className }: CompareProps): React.JSX.Element;
4448
4462
  /** Props for `FullscreenFrame`. */
4449
4463
  type FullscreenFrameProps = {
4450
4464
  /** Names the full-screen view for screen readers: "Compare renderings". Required. */
@@ -4882,6 +4896,242 @@ export declare function useHistoryState<S>(initial: S | (() => S), options?: His
4882
4896
  reset: (next: S) => void;
4883
4897
  history: History;
4884
4898
  };
4899
+ /** The shape of a tool's tip. A chisel is wide across `nibAngle` and thin along it, as a highlighter is. */
4900
+ type Nib = "round" | "square" | "chisel";
4901
+ /** The kind of tool, which decides the defaults and how a stroke is drawn. */
4902
+ type BrushKind = "pen" | "pencil" | "marker" | "highlighter" | "brush";
4903
+ /** How a stroke looks. All of it is data saved with the stroke. */
4904
+ type Brush = {
4905
+ kind: BrushKind;
4906
+ /** `#rrggbb`. The user's colour, not a theme role. */
4907
+ colour: string;
4908
+ /** Width in the drawing's units (its widest, for a stroke whose width varies). */
4909
+ width: number;
4910
+ /** 0 to 1, for the whole stroke. */
4911
+ opacity: number;
4912
+ /** 0 to 1: 1 a crisp edge, 0 a soft one (the edge blurs over about half the width). */
4913
+ hardness: number;
4914
+ nib: Nib;
4915
+ /** A chisel's angle in degrees from the x axis. Default 45. */
4916
+ nibAngle?: number;
4917
+ /** Whether the width follows the pen's pressure (or, for a mouse, how slowly it moved). */
4918
+ pressure: boolean;
4919
+ /** `multiply` darkens what it lies over, as a highlighter does. Default `normal`. */
4920
+ blend?: "normal" | "multiply";
4921
+ };
4922
+ /** A point a stroke passes through: x, y in the drawing's units, and pressure 0 to 1 where it was measured. */
4923
+ type StrokePoint = readonly [x: number, y: number, pressure?: number];
4924
+ /** One drawn element. */
4925
+ type Stroke = {
4926
+ /** Unique in its drawing. */
4927
+ id: string;
4928
+ brush: Brush;
4929
+ points: readonly StrokePoint[];
4930
+ /** What the person wrote about it. Absent (never empty) when there is none. */
4931
+ note?: string;
4932
+ };
4933
+ /** A drawing: the size of its coordinate space and its strokes, bottom first. */
4934
+ type Drawing = {
4935
+ /** The coordinate space's width and height (the picture it is drawn on, in its pixels). */
4936
+ width: number;
4937
+ height: number;
4938
+ strokes: readonly Stroke[];
4939
+ };
4940
+ /** The fields of a stroke a `change` can replace. A note is cleared by `""`, never `undefined`, so an op survives a JSON round trip (an `undefined` field would vanish from it and the change would no longer clear the note). */
4941
+ type StrokeChange = Partial<Pick<Stroke, "points" | "brush" | "note">>;
4942
+ /** One change to a drawing, carrying what it needs to be undone. */
4943
+ type DrawingOp = {
4944
+ op: "add";
4945
+ stroke: Stroke;
4946
+ index: number;
4947
+ } | {
4948
+ op: "remove";
4949
+ stroke: Stroke;
4950
+ index: number;
4951
+ } | {
4952
+ op: "change";
4953
+ id: string;
4954
+ before: StrokeChange;
4955
+ after: StrokeChange;
4956
+ };
4957
+ /** An axis-aligned box: left, top, right, bottom. */
4958
+ type Box = readonly [x0: number, y0: number, x1: number, y1: number];
4959
+ /** A drawing with nothing on it. */
4960
+ export declare function emptyDrawing(width: number, height: number): Drawing;
4961
+ /** The tools' starting brushes. The widths are for a drawing about 1000 units wide; scale them for another. */
4962
+ export declare const BRUSHES: Readonly<Record<BrushKind, Brush>>;
4963
+ /**
4964
+ * The feedback marker: thick, half see-through, a strong bright colour, so it shows on a white page,
4965
+ * a yellowed scan and black type alike and is never mistaken for the page's own ink. `scale` is the
4966
+ * drawing's width over 1000.
4967
+ */
4968
+ export declare function feedbackMarker(scale?: number): Brush;
4969
+ /** The drawing after one operation. Pure: the drawing given is not changed. An op that does not apply (an unknown id) gives the drawing back as it was. */
4970
+ export declare function applyOp(d: Drawing, op: DrawingOp): Drawing;
4971
+ /** The operation that undoes `op`. Needs no document: every op carries what it replaced. */
4972
+ export declare function invertOp(op: DrawingOp): DrawingOp;
4973
+ /** Applies each operation in turn: the log from `useDrawing` rebuilds the drawing it made. */
4974
+ export declare function replay(d: Drawing, ops: readonly DrawingOp[]): Drawing;
4975
+ /** The fields of `s` that `change` would replace, as they are now: the `before` of a change op. */
4976
+ export declare function currentOf(s: Stroke, change: StrokeChange): StrokeChange;
4977
+ /** A drawing scaled into another coordinate space (the same picture served at another size). Widths scale with the mean of the two factors. */
4978
+ export declare function rescaleDrawing(d: Drawing, width: number, height: number): Drawing;
4979
+ /** The box a stroke's points span, not counting its width. */
4980
+ export declare function pointsBox(points: readonly StrokePoint[]): Box;
4981
+ /** The box a stroke covers, ink and all: its points' box grown by half its width. */
4982
+ export declare function strokeBox(s: Stroke): Box;
4983
+ /** The stroke's points moved by `dx`, `dy`. */
4984
+ export declare function movePoints(points: readonly StrokePoint[], dx: number, dy: number): StrokePoint[];
4985
+ /** The stroke's points mapped from the box `from` onto the box `to` (a resize by a corner). A box with no width or height keeps that axis. */
4986
+ export declare function fitPoints(points: readonly StrokePoint[], from: Box, to: Box): StrokePoint[];
4987
+ /** Whether the point lies on the stroke's ink, or within `slop` units of it. */
4988
+ export declare function hitsStroke(s: Stroke, x: number, y: number, slop?: number): boolean;
4989
+ /** The points of the path `smoothPath` draws, its curves cut into eight straight pieces each: what hit tests measure against. */
4990
+ export declare function curvePoints(points: readonly StrokePoint[]): StrokePoint[];
4991
+ /** The topmost stroke under the point, or undefined. */
4992
+ export declare function strokeAt(d: Drawing, x: number, y: number, slop?: number): Stroke | undefined;
4993
+ /**
4994
+ * Fewer points along the same line (Ramer-Douglas-Peucker, within `tolerance` units), so a stroke
4995
+ * saved is a few dozen points, not one per pointer event. A point where the pressure changes by more
4996
+ * than a tenth is kept, so a pressed line keeps its swell.
4997
+ */
4998
+ export declare function simplifyPoints(points: readonly StrokePoint[], tolerance: number): StrokePoint[];
4999
+ /** The width of the stroke at each of its points: the brush's width, times its pressure where it follows it, times a chisel's angle against the stroke's direction. */
5000
+ export declare function widthsOf(s: Stroke): number[];
5001
+ /** A smooth path through the points. One point is a zero-length line, which a round or square cap draws as a dot. */
5002
+ export declare function smoothPath(points: readonly (readonly [number, number])[]): string;
5003
+ /** How one stroke is drawn, as plain data for SVG: a stroked line or a filled outline, plus its group's look. */
5004
+ type StrokeShape = {
5005
+ kind: "line" | "fill";
5006
+ /** The path's `d`. */
5007
+ d: string;
5008
+ colour: string;
5009
+ /** For a line: its stroke width, cap and join. */
5010
+ width: number;
5011
+ cap: "round" | "square";
5012
+ opacity: number;
5013
+ blend: "normal" | "multiply";
5014
+ /** Blur of the edge in the drawing's units, 0 for a crisp one. */
5015
+ soften: number;
5016
+ /** A pencil's grain: the noise's frequency per unit, 0 for none. */
5017
+ grain: number;
5018
+ };
5019
+ /** How a stroke is drawn: the one rendering used on screen and in export. */
5020
+ export declare function strokeShape(s: Stroke): StrokeShape;
5021
+ /**
5022
+ * The SVG filter for a soft edge or a pencil's grain, or "" when the stroke needs none. `id` must be
5023
+ * unique in the document. The region is in the drawing's units around the stroke's ink (`box`), not
5024
+ * the default share of its bounding box, which is zero high for a level line and would hide it.
5025
+ */
5026
+ export declare function filterMarkup(shape: StrokeShape, id: string, box: Box): string;
5027
+ /** The drawing as a standalone SVG document, drawn as `DrawingLayer` draws it; each stroke's note is its `<title>`. */
5028
+ export declare function drawingToSvg(d: Drawing, { idPrefix }?: {
5029
+ idPrefix?: string;
5030
+ }): string;
5031
+ /** A stroke id unique in this page's life: time and a counter, so two tabs drawing on one document rarely clash. */
5032
+ export declare function newStrokeId(): string;
5033
+ /** Which tool is in hand: `draw` with the brush given, `select` to choose, move and resize strokes, `erase` to remove whole strokes by touching them, `none` to leave the pointer to what is under the layer. */
5034
+ type DrawTool = "none" | "draw" | "select" | "erase";
5035
+ /** Options for `useDrawing`. */
5036
+ type DrawingOptions = {
5037
+ /** The drawing to start from (a saved one, or `emptyDrawing(w, h)`). Read once, as `useState` does. */
5038
+ initial: Drawing | (() => Drawing);
5039
+ /** A history to share with the rest of an editor, so one Undo walks back both. Default: a history of its own. */
5040
+ history?: History;
5041
+ /** With a history of its own: the most steps kept. Default 100. */
5042
+ limit?: number;
5043
+ };
5044
+ /** What `useDrawing` returns. */
5045
+ type DrawingState = {
5046
+ drawing: Drawing;
5047
+ /** Every operation applied since the hook started, in order, undos and redos too (as the inverse ops they apply): `replay(initial, log)` is `drawing`. */
5048
+ log: readonly DrawingOp[];
5049
+ history: History;
5050
+ /** The chosen stroke's id, or null. */
5051
+ selected: string | null;
5052
+ select: (id: string | null) => void;
5053
+ /** Adds a stroke on top. One undo step, named `label` ("draw mark"). */
5054
+ add: (stroke: Stroke, label?: string) => void;
5055
+ /** Removes strokes by id, as one step. */
5056
+ remove: (ids: string | readonly string[], label?: string) => void;
5057
+ /** Replaces fields of a stroke (its points after a move, its note, its brush), as one step. Pass `key` to merge a run of changes (a slider) into one. Nothing happens when nothing would change. */
5058
+ change: (id: string, change: StrokeChange, label: string, key?: string) => void;
5059
+ /** Applies operations made elsewhere (another tab, a server's merge) as one step. */
5060
+ apply: (ops: readonly DrawingOp[], label: string) => void;
5061
+ /** Removes every stroke, as one step. */
5062
+ clear: (label?: string) => void;
5063
+ /** Sets the coordinate space of a drawing with no strokes yet (the picture's size, once it is known). Not a step: there is nothing to undo. */
5064
+ fit: (width: number, height: number) => void;
5065
+ };
5066
+ /** A vector drawing with every change an operation, its log, a selection and undo. Pass the returned state to `DrawingLayer` and `DrawingToolbar`. */
5067
+ export declare function useDrawing({ initial, history: shared, limit }: DrawingOptions): DrawingState;
5068
+ /** The words of the note box. */
5069
+ type StrokeNoteWords = {
5070
+ /** The text box's label: "What is wrong here?". */
5071
+ label: string;
5072
+ /** Under the box: "Optional". */
5073
+ hint?: string;
5074
+ /** Default "Done". */
5075
+ done?: string;
5076
+ /** Default "Delete mark". */
5077
+ remove?: string;
5078
+ };
5079
+ /** Props for `DrawingLayer`. */
5080
+ type DrawingLayerProps = {
5081
+ state: DrawingState;
5082
+ tool: DrawTool;
5083
+ /** The brush a `draw` stroke is made with. */
5084
+ brush: Brush;
5085
+ /** Names the drawing for screen readers: "Marks on page 12". Required. */
5086
+ label: string;
5087
+ /** The picture's size, so a drawing with no strokes yet takes its coordinate space (`fit`). */
5088
+ size?: readonly [number, number];
5089
+ /** Called with each stroke just drawn (after it is added): open its note, say. */
5090
+ onDrawn?: (stroke: Stroke) => void;
5091
+ /** The stroke whose note box is open, or null. Give it to one layer only when several show one drawing. */
5092
+ noteFor?: string | null;
5093
+ /** The note box was closed (Done, Escape, a press outside, or its stroke deleted). The note is already saved. */
5094
+ onNoteClose?: () => void;
5095
+ /** With the select tool, N on a stroke asks for its note. */
5096
+ onNoteRequest?: (id: string) => void;
5097
+ /** The note box's words. */
5098
+ noteWords?: StrokeNoteWords;
5099
+ /** Short names for strokes in the select tool's labels: "Mark". Default "Mark". */
5100
+ noun?: string;
5101
+ className?: string;
5102
+ };
5103
+ /** The SVG layer a drawing is made on, laid over a picture of the same shape (inside a `ViewportFrame` it zooms and pans with it). */
5104
+ export declare function DrawingLayer({ state, tool, brush, label, size, onDrawn, noteFor, onNoteClose, onNoteRequest, noteWords, noun, className }: DrawingLayerProps): React.JSX.Element;
5105
+ /** A tool the toolbar offers: a brush kind to draw with, or `select`, `erase`, or `none` ("Look", the pointer left to the picture). */
5106
+ type ToolChoice = BrushKind | "select" | "erase" | "none";
5107
+ /** A brush control the toolbar shows. */
5108
+ type BrushControl = "colour" | "width" | "opacity" | "hardness" | "nib";
5109
+ /** Props for `DrawingToolbar`. */
5110
+ type DrawingToolbarProps = {
5111
+ state: DrawingState;
5112
+ tool: DrawTool;
5113
+ brush: Brush;
5114
+ /** The tool and brush chosen; a brush kind starts from its `BRUSHES` defaults (scaled) with the colour kept. */
5115
+ onChange: (next: {
5116
+ tool: DrawTool;
5117
+ brush: Brush;
5118
+ }) => void;
5119
+ /** Which tools to offer, in order. Default all: Look, Select, the five brushes, Eraser. */
5120
+ tools?: readonly ToolChoice[];
5121
+ /** Which brush controls to show. Default all. */
5122
+ controls?: readonly BrushControl[];
5123
+ /** Colours offered as swatches, `#rrggbb`. */
5124
+ palette?: readonly string[];
5125
+ /** The widest a stroke may be, in drawing units. Default 60 × `scale`. */
5126
+ maxWidth?: number;
5127
+ /** The drawing's width over 1000: the default brushes' widths are scaled by it. Default 1. */
5128
+ scale?: number;
5129
+ /** Called with the stroke to annotate when Note is pressed with one chosen. Without it there is no Note button. */
5130
+ onNote?: (id: string) => void;
5131
+ className?: string;
5132
+ };
5133
+ /** The whole drawing kit: tools, colour, width, opacity, hardness and nib, with Undo, Redo and Delete for the chosen stroke. */
5134
+ export declare function DrawingToolbar({ state, tool, brush, onChange, tools, controls, palette, maxWidth, scale, onNote, className }: DrawingToolbarProps): React.JSX.Element;
4885
5135
  /** The state of a document's saving. */
4886
5136
  type SaveState = {
4887
5137
  status: "saved"; /** When it last saved here; null for a document just opened. */
@@ -5526,5 +5776,5 @@ export declare function rangeBetween(ids: readonly string[], a: string | null, b
5526
5776
  export declare function countMarks(marks: Readonly<Record<string, string | undefined>>, ids?: readonly string[]): Record<string, number>;
5527
5777
  /** The id `by` places from `from` in `ids`, held to the ends; the first (or last) when `from` is not set. */
5528
5778
  export declare function stepId(ids: readonly string[], from: string | null, by: number): string | null;
5529
- export { type ActiveItem, type AlertDialogProps, type AlertProps, type Api, type ApiOptions, type ApiPage, type AspectRatio, type AsyncAction, type AsyncActionOptions, AsyncButton, type AsyncLabels, type AudioMedia, type AutoRecorder, type AutoRecorderState, type AutoSave, type AutoSaveOptions, type AutoTake, type BinaryByteUnit, type BookPage, type BookUrl, type BookViewerProps, type BoxListProps, type BoxOverlayProps, type BoxSource, type BoxTone, type BoxedPictureProps, type BoxesState, Button, type ButtonLinkProps, type ButtonProps, type ByteHighlight, type ByteRange, type ByteUnit, type ByteViewProps, type BytesOptions, COLOR_SCHEME_STORAGE_KEY, type Candidate, type CellValue, type ChartMark, type ChartSpan, type CheckboxGesture, type CheckboxProps, type Choice, type ChoiceCounts, type ChoiceGridProps, type ChoiceGroupProps, type ChoiceMarks, type ChoiceSize, type ChoiceState, type Choices, type ClientWork, type Clips, type ClipsContext, type ClipsProviderProps, type ColorFieldProps, type ColorScheme, ColorSchemeChoice, type ColorSchemeLabels, type ColorSchemePreference, type ColorSchemeState, type Column, type Command, type CommandMenuProps, type CommandsOptions, type CompareAudioProps, type CompareGridProps, type CompareMode, type CompareProps, type CompareTextProps, type CompareVideoGridProps, type CompareVideoProps, type ComposerProps, type CompositionBarProps, type CompositionPart, type ConsoleLevel, type ConsoleLine, type ConsoleProps, type ContextMenuProps, type ControlSize, type ConversationImage, type ConversationProps, type ConversationTurn, type CountOptions, type CursorMapping, type CursorOwner, CursorScope, type CursorScopeProps, type CutChange, type CutLimit, type CutRoom, DEFAULT_PALETTE, type DataTableProps, type DateFormatter, type DateInput, type DecodedAudio, type Delivery, Density, type DensityName, type DensityProps, type DescribeError, type DialogProps, type Difference, type DifferenceState, type DisclosureOpenProps, type DisclosureProps, type DragData, type DragSourceProps, type DropTarget, type Easing, type EditClip, type EditListOptions, type EditListPlayerProps, type EditListSlot, type EditListState, type EditTimes, type EditableRegion, type EntityMatch, type EntityMatcher, type ErrorBody, type Expanded, type ExpandedOptions, type FailedRemoval, type FetchJsonInit, type FetchJsonOptions, type FieldErrors, type FieldProps, type FileIntake, type FileIntakeOptions, type FileOutcome, type FilmFrame, type FilmStripProps, type Folder, type FolderListing, type FolderPickerProps, type Format, type FormatOptions, type FullscreenFrameProps, type GlimpseLook, type GlimpseProps, type GlimpseWhy, type Grid, type GroupMember, type GroupedChart, type Handle, type History, type HistoryOptions, type HistoryStateOptions, type HistoryStep, type HotkeysOptions, IconButton, type IconButtonProps, type IconComponent, type ImageMedia, type Implies, type InViewOptions, type InfiniteListProps, type InfiniteLoad, type InfiniteLoadOptions, type InitialSelection, type InkColours, type InkMatch, type InkMatchState, type InputLevelProps, type InspectorProps, type InspectorSectionProps, type Job, type JobAction, type JobActionOptions, type JobFailure, type JobOptions, type JobProgress, type JobRow, type JobStatusProps, type JobWords, type JobsTableProps, type KeyCheck, KeysLegend, type LatLng, type LightboxItem, type LightboxProps, type LightboxUrl, LineChart, LineChartGroup, type LineChartGroupProps, type LineChartProps, type LinkCardProps, type ListeningLevelProps, type Load, type LoadFailure, type LoadMoreProps, type Loudness, type MarkKind, type MarkPattern, type MarkTone, type MarkableTextProps, type MediaContentsItem, type MediaContentsProps, type MediaElementOptions, type MediaElementState, type MediaHeading, type MediaMark, MediaPlayer, type MediaPlayerProps, type MediaProblem, type MediaProgress, type MediaSession, type MediaSource, type MediaSpanData, type MediaSpansState, MediaStage, type MediaStat, type MediaStats, type MediaWindow, type MenuEntry, type MenuProps, type MeterProps, type MeterThreshold, type MetricProps, type Microphone, MicrophoneContext, MicrophoneError, type MicrophoneStream, type More, type NativeSelectProps, type NavItem, type NumberFieldProps, type NumberFormatter, type Outbox, type OutboxItem, type OutboxOptions, type OutboxRefusal, type OutboxRequest, type OutboxSnapshot, type OutboxStatusProps, PALETTE_STORAGE_KEY, type PageNames, type Pair, type PairAnswer, type PairJudgeProps, type PairVoteProps, type PairVoteSlot, type PairVoteWords, PaletteChoice, type PaletteOption, type PaletteState, type PaneProps, type PeakPair, type PendingRemoval, type Phase, type PictureBox, type PictureRegion, type PixelImageProps, type Pixels, type PlaceBoardProps, type PlaceState, type Platform, type PlayWindowButtonProps, PlayerNotice, type PlayerWarning, type PlayerWarningEvent, type Point, type Poll, type PopoverProps, type Precision, type Property, type PropertyListProps, type PropertyRowProps, type RangeProps, RateChoice, type ReadPixels, type Rebinding, type Recorder, type RecorderState, type Recording, type Rect, type RectLimits, type Region, type RegionEditorProps, type RegionTone, type Reserve, type ReserveOptions, type ResumeWords, type Block as RichBlock, type Inline as RichInline, type RichTextProps, RowAction, type RowActionProps, type RowExpansion, type RowSelection, SPEECH_RATES, type SaveState, type SayAgainProps, type SayOnShowOptions, type SayPictureProps, type Saying, type ScheduleRow, type ScheduleTableProps, type SearchParam, type SearchParamOptions, type SecretFieldProps, type SecretTestResult, SeekBar, type SeekBarProps, type SeekBarSpan, type Segment, type Segmenter, type SegmenterOptions, type SelectableGridProps, type SequenceItem, type SequenceTimelineProps, type SetOptions, type ShareBox, type SharedCursor, type Shortcut, type ShortcutOverrides, type SkipAction, type SkipLevel, type SkipSteps, type SliderProps, type Sort, type SortableListProps, type SourceAttacher, SpanActions, type SpanActionsNotice, type SpanBehaviour, type SpanKind, type SpanOutcome, SpanStrip, type SpanTone, type SpanWords, type SpeakOptions, type Speech, type SpeechLevel, type SpeechPart, StageGuides, type StageState, type StageWords, type Stale, type StrataToastRegionProps, type StreamAttachment, type StreamContext, type StreamStats, type SwitchProps, type SystemFact, type SystemFolder, type SystemInfoLike, type SystemPanelProps, type SystemService, type TabItem, type TakeLevelProps, type TextDifference, type TextLinkProps, type TextMedia, type TextSegment, ThemeProvider, type ThumbnailProps, type TileAspect, type TileGridProps, type TileSize, TimeReadout, type TimelineChange, type TimelineClock, type TimelineClockOptions, type TimelineDrop, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelinePlayerProps, type TimelineProps, type ToastContentProps, type ToggleGroupProps, type ToggleOption, type ToggleProps, type Tone, type ToolbarProps, type TooltipProps, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptSeek, type TranscriptViewProps, type TranscriptWord, Transport, type TransportProps, type TreeNodeState, type TreeProps, type TypedApi, type Undoable, type UndoableOptions, type UseAutoRecorderOptions, type UseRecorderOptions, type UseSpeechOptions, type VideoLoop, type VideoMedia, type VideoMode, type ViewGroup, type ViewGroupRows, type ViewOptionsConfig, type ViewOptionsProps, type ViewOptionsState, type ViewPointerOptions, type ViewSort, type Viewport, type ViewportFrameProps, type ViewportState, VolumeControl, type VolumeControlProps, type WaveformMark, type WaveformMarkKind, type WaveformPeaks, type WaveformProps, type WaveformSpan, type WaveformTone, type WorkContext, type WorkPhase, type WorkflowRunLike, type WorkflowRunOptions, type WorkflowStage, type WorkflowStepsProps, type WorkflowSummaryData, type WorkflowSummaryProps, type WorkflowSummaryState, type WorkflowSummaryWords, type WorkspaceBarProps, type WorkspaceState, type YScale, browserMicrophone, buttonVariants, colorSchemeScript, explainMicrophoneError, format$1 as format, geo, isTypingTarget, keyName, logScale, marksFor, mediaStatRows, paletteScript, palettes, readPixels$1 as readPixels, skipAction, transportShortcuts, useAsyncAction, useAttachedSource, useColorScheme, useHotkeys, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, usePalette, usePlayerWarnings, useSharedCursor, useSystemColorScheme, valueAt };
5779
+ export { type ActiveItem, type AlertDialogProps, type AlertProps, type Api, type ApiOptions, type ApiPage, type AspectRatio, type AsyncAction, type AsyncActionOptions, AsyncButton, type AsyncLabels, type AudioMedia, type AutoRecorder, type AutoRecorderState, type AutoSave, type AutoSaveOptions, type AutoTake, type BinaryByteUnit, type BookPage, type BookUrl, type BookViewerProps, type BoxListProps, type BoxOverlayProps, type BoxSource, type BoxTone, type BoxedPictureProps, type BoxesState, type Brush, type BrushControl, type BrushKind, Button, type ButtonLinkProps, type ButtonProps, type ByteHighlight, type ByteRange, type ByteUnit, type ByteViewProps, type BytesOptions, COLOR_SCHEME_STORAGE_KEY, type Candidate, type CellValue, type ChartMark, type ChartSpan, type CheckboxGesture, type CheckboxProps, type Choice, type ChoiceCounts, type ChoiceGridProps, type ChoiceGroupProps, type ChoiceMarks, type ChoiceSize, type ChoiceState, type Choices, type ClientWork, type Clips, type ClipsContext, type ClipsProviderProps, type ColorFieldProps, type ColorScheme, ColorSchemeChoice, type ColorSchemeLabels, type ColorSchemePreference, type ColorSchemeState, type Column, type Command, type CommandMenuProps, type CommandsOptions, type CompareAudioProps, type CompareGridProps, type CompareMode, type CompareProps, type CompareTextProps, type CompareVideoGridProps, type CompareVideoProps, type ComposerProps, type CompositionBarProps, type CompositionPart, type ConsoleLevel, type ConsoleLine, type ConsoleProps, type ContextMenuProps, type ControlSize, type ConversationImage, type ConversationProps, type ConversationTurn, type CountOptions, type CursorMapping, type CursorOwner, CursorScope, type CursorScopeProps, type CutChange, type CutLimit, type CutRoom, DEFAULT_PALETTE, type DataTableProps, type DateFormatter, type DateInput, type DecodedAudio, type Delivery, Density, type DensityName, type DensityProps, type DescribeError, type DialogProps, type Difference, type DifferenceState, type DisclosureOpenProps, type DisclosureProps, type DragData, type DragSourceProps, type DrawTool, type Drawing, type Box as DrawingBox, type DrawingLayerProps, type DrawingOp, type DrawingOptions, type DrawingState, type DrawingToolbarProps, type DropTarget, type Easing, type EditClip, type EditListOptions, type EditListPlayerProps, type EditListSlot, type EditListState, type EditTimes, type EditableRegion, type EntityMatch, type EntityMatcher, type ErrorBody, type Expanded, type ExpandedOptions, type FailedRemoval, type FetchJsonInit, type FetchJsonOptions, type FieldErrors, type FieldProps, type FileIntake, type FileIntakeOptions, type FileOutcome, type FilmFrame, type FilmStripProps, type Folder, type FolderListing, type FolderPickerProps, type Format, type FormatOptions, type FullscreenFrameProps, type GlimpseLook, type GlimpseProps, type GlimpseWhy, type Grid, type GroupMember, type GroupedChart, type Handle, type History, type HistoryOptions, type HistoryStateOptions, type HistoryStep, type HotkeysOptions, IconButton, type IconButtonProps, type IconComponent, type ImageMedia, type Implies, type InViewOptions, type InfiniteListProps, type InfiniteLoad, type InfiniteLoadOptions, type InitialSelection, type InkColours, type InkMatch, type InkMatchState, type InputLevelProps, type InspectorProps, type InspectorSectionProps, type Job, type JobAction, type JobActionOptions, type JobFailure, type JobOptions, type JobProgress, type JobRow, type JobStatusProps, type JobWords, type JobsTableProps, type KeyCheck, KeysLegend, type LatLng, type LightboxItem, type LightboxProps, type LightboxUrl, LineChart, LineChartGroup, type LineChartGroupProps, type LineChartProps, type LinkCardProps, type ListeningLevelProps, type Load, type LoadFailure, type LoadMoreProps, type Loudness, type MarkKind, type MarkPattern, type MarkTone, type MarkableTextProps, type MediaContentsItem, type MediaContentsProps, type MediaElementOptions, type MediaElementState, type MediaHeading, type MediaMark, MediaPlayer, type MediaPlayerProps, type MediaProblem, type MediaProgress, type MediaSession, type MediaSource, type MediaSpanData, type MediaSpansState, MediaStage, type MediaStat, type MediaStats, type MediaWindow, type MenuEntry, type MenuProps, type MeterProps, type MeterThreshold, type MetricProps, type Microphone, MicrophoneContext, MicrophoneError, type MicrophoneStream, type More, type NativeSelectProps, type NavItem, type Nib, type NumberFieldProps, type NumberFormatter, type Outbox, type OutboxItem, type OutboxOptions, type OutboxRefusal, type OutboxRequest, type OutboxSnapshot, type OutboxStatusProps, PALETTE_STORAGE_KEY, type PageNames, type Pair, type PairAnswer, type PairJudgeProps, type PairVoteProps, type PairVoteSlot, type PairVoteWords, PaletteChoice, type PaletteOption, type PaletteState, type PaneProps, type PeakPair, type PendingRemoval, type Phase, type PictureBox, type PictureRegion, type PixelImageProps, type Pixels, type PlaceBoardProps, type PlaceState, type Platform, type PlayWindowButtonProps, PlayerNotice, type PlayerWarning, type PlayerWarningEvent, type Point, type Poll, type PopoverProps, type Precision, type Property, type PropertyListProps, type PropertyRowProps, type RangeProps, RateChoice, type ReadPixels, type Rebinding, type Recorder, type RecorderState, type Recording, type Rect, type RectLimits, type Region, type RegionEditorProps, type RegionTone, type Reserve, type ReserveOptions, type ResumeWords, type Block as RichBlock, type Inline as RichInline, type RichTextProps, RowAction, type RowActionProps, type RowExpansion, type RowSelection, SPEECH_RATES, type SaveState, type SayAgainProps, type SayOnShowOptions, type SayPictureProps, type Saying, type ScheduleRow, type ScheduleTableProps, type SearchParam, type SearchParamOptions, type SecretFieldProps, type SecretTestResult, SeekBar, type SeekBarProps, type SeekBarSpan, type Segment, type Segmenter, type SegmenterOptions, type SelectableGridProps, type SequenceItem, type SequenceTimelineProps, type SetOptions, type ShareBox, type SharedCursor, type Shortcut, type ShortcutOverrides, type SkipAction, type SkipLevel, type SkipSteps, type SliderProps, type Sort, type SortableListProps, type SourceAttacher, SpanActions, type SpanActionsNotice, type SpanBehaviour, type SpanKind, type SpanOutcome, SpanStrip, type SpanTone, type SpanWords, type SpeakOptions, type Speech, type SpeechLevel, type SpeechPart, StageGuides, type StageState, type StageWords, type Stale, type StrataToastRegionProps, type StreamAttachment, type StreamContext, type StreamStats, type Stroke, type StrokeChange, type StrokeNoteWords, type StrokePoint, type StrokeShape, type SwitchProps, type SystemFact, type SystemFolder, type SystemInfoLike, type SystemPanelProps, type SystemService, type TabItem, type TakeLevelProps, type TextDifference, type TextLinkProps, type TextMedia, type TextSegment, ThemeProvider, type ThumbnailProps, type TileAspect, type TileGridProps, type TileSize, TimeReadout, type TimelineChange, type TimelineClock, type TimelineClockOptions, type TimelineDrop, type TimelineItem, type TimelineLane, type TimelineMarker, type TimelinePlayerProps, type TimelineProps, type ToastContentProps, type ToggleGroupProps, type ToggleOption, type ToggleProps, type Tone, type ToolChoice, type ToolbarProps, type TooltipProps, type TranscriptGroup, type TranscriptPhrase, type TranscriptPhraseState, type TranscriptSeek, type TranscriptViewProps, type TranscriptWord, Transport, type TransportProps, type TreeNodeState, type TreeProps, type TypedApi, type Undoable, type UndoableOptions, type UseAutoRecorderOptions, type UseRecorderOptions, type UseSpeechOptions, type VideoLoop, type VideoMedia, type VideoMode, type ViewGroup, type ViewGroupRows, type ViewOptionsConfig, type ViewOptionsProps, type ViewOptionsState, type ViewPointerOptions, type ViewSort, type Viewport, type ViewportFrameProps, type ViewportState, VolumeControl, type VolumeControlProps, type WaveformMark, type WaveformMarkKind, type WaveformPeaks, type WaveformProps, type WaveformSpan, type WaveformTone, type WorkContext, type WorkPhase, type WorkflowRunLike, type WorkflowRunOptions, type WorkflowStage, type WorkflowStepsProps, type WorkflowSummaryData, type WorkflowSummaryProps, type WorkflowSummaryState, type WorkflowSummaryWords, type WorkspaceBarProps, type WorkspaceState, type YScale, browserMicrophone, buttonVariants, colorSchemeScript, explainMicrophoneError, format$1 as format, geo, isTypingTarget, keyName, logScale, marksFor, mediaStatRows, paletteScript, palettes, readPixels$1 as readPixels, skipAction, transportShortcuts, useAsyncAction, useAttachedSource, useColorScheme, useHotkeys, useMediaElement, useMediaSpans, useMediaStats, useMicrophone, usePalette, usePlayerWarnings, useSharedCursor, useSystemColorScheme, valueAt };
5530
5780
  //# sourceMappingURL=index.d.ts.map