@vitavision/workbench 0.0.0-bootstrap.0 → 0.1.0
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/LICENSE-APACHE +202 -0
- package/LICENSE-MIT +21 -0
- package/README.md +89 -0
- package/dist/index.d.ts +671 -0
- package/dist/index.js +1469 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -3
- package/src/components/AppShell.tsx +141 -0
- package/src/components/FileDrop.tsx +223 -0
- package/src/components/PlaybackBar.tsx +303 -0
- package/src/components/SplitPane.tsx +306 -0
- package/src/components/Toaster.tsx +149 -0
- package/src/components/TreeView.tsx +244 -0
- package/src/components/dropFiles.ts +131 -0
- package/src/components/playhead.ts +158 -0
- package/src/components/splitSize.ts +160 -0
- package/src/components/toastStore.ts +128 -0
- package/src/components/treeModel.ts +188 -0
- package/src/components/usePlayback.ts +105 -0
- package/src/index.ts +67 -0
- package/src/styles.css +7 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
import { MeasureTone } from "@vitavision/ui";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/components/splitSize.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A pane size: CSS pixels as a number, or a share of the split's length as a percentage
|
|
6
|
+
* string (`"30%"`).
|
|
7
|
+
*/
|
|
8
|
+
type PaneSize = number | `${number}%`;
|
|
9
|
+
/** The limits a `SplitPane`'s sized pane is held to, resolved to pixels. */
|
|
10
|
+
interface SplitLimits {
|
|
11
|
+
/** The smallest open size, in pixels. */
|
|
12
|
+
min: number;
|
|
13
|
+
/** The largest size, in pixels. */
|
|
14
|
+
max: number;
|
|
15
|
+
/** Whether the pane may close to 0 below `min`. */
|
|
16
|
+
collapsible: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A size in pixels.
|
|
20
|
+
*
|
|
21
|
+
* @param size - Pixels, or a percentage of `length`.
|
|
22
|
+
* @param length - The split's length along its axis, in pixels.
|
|
23
|
+
* @returns The size in pixels (never negative).
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveSize(size: PaneSize, length: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* The limits in pixels for a split of `length`. `max` never exceeds `length`, and `min`
|
|
28
|
+
* never exceeds `max`.
|
|
29
|
+
*
|
|
30
|
+
* @param length - The split's length along its axis, in pixels.
|
|
31
|
+
* @param minSize - The smallest open size. Defaults to 0.
|
|
32
|
+
* @param maxSize - The largest size. Defaults to the whole length.
|
|
33
|
+
* @param collapsible - Whether the pane may close below `minSize`.
|
|
34
|
+
* @returns The resolved limits.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveLimits(length: number, minSize?: PaneSize, maxSize?: PaneSize, collapsible?: boolean): SplitLimits;
|
|
37
|
+
/**
|
|
38
|
+
* Hold a proposed size to the limits. A collapsible pane dragged below half its minimum
|
|
39
|
+
* snaps shut (0); between half the minimum and the minimum it stays at the minimum.
|
|
40
|
+
*
|
|
41
|
+
* @param size - The proposed size, in pixels.
|
|
42
|
+
* @param limits - The resolved limits.
|
|
43
|
+
* @returns The size to apply, in pixels, rounded to whole pixels.
|
|
44
|
+
*/
|
|
45
|
+
export declare function clampSize(size: number, limits: SplitLimits): number;
|
|
46
|
+
/** Which way a `SplitPane` lays out its two panes. */
|
|
47
|
+
type SplitOrientation = "horizontal" | "vertical";
|
|
48
|
+
/** Which of the two panes carries the explicit size; the other takes the rest. */
|
|
49
|
+
type SizedPane = "start" | "end";
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/components/AppShell.d.ts
|
|
52
|
+
/** How one side panel of an `AppShell` is sized. */
|
|
53
|
+
interface SidePanelSize {
|
|
54
|
+
/** The initial width: pixels or a percentage. */
|
|
55
|
+
defaultSize?: PaneSize | undefined;
|
|
56
|
+
/** The narrowest the panel may be dragged. */
|
|
57
|
+
minSize?: PaneSize | undefined;
|
|
58
|
+
/** The widest the panel may be dragged. */
|
|
59
|
+
maxSize?: PaneSize | undefined;
|
|
60
|
+
/** Lets the panel close (drag it under half its minimum, or Enter on its divider). */
|
|
61
|
+
collapsible?: boolean | undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Props of `AppShell`. */
|
|
64
|
+
interface AppShellProps {
|
|
65
|
+
/** The top bar: the app's name, the file actions, the theme toggle. */
|
|
66
|
+
header?: ReactNode;
|
|
67
|
+
/** The panel left of the main surface — a navigator such as a `TreeView`. */
|
|
68
|
+
left?: ReactNode;
|
|
69
|
+
/** The main surface — the viewport. Always present. */
|
|
70
|
+
main: ReactNode;
|
|
71
|
+
/** The panel right of the main surface — an inspector. */
|
|
72
|
+
right?: ReactNode;
|
|
73
|
+
/** The strip along the bottom, across the whole width — a `PlaybackBar`, a status line. */
|
|
74
|
+
bottom?: ReactNode;
|
|
75
|
+
/** Names the left panel's landmark (`<aside>`). Defaults to "Navigator". */
|
|
76
|
+
leftLabel?: string | undefined;
|
|
77
|
+
/** Names the right panel's landmark (`<aside>`). Defaults to "Inspector". */
|
|
78
|
+
rightLabel?: string | undefined;
|
|
79
|
+
/** The left panel's sizing. Defaults to 280 px, 180 px to 50%. */
|
|
80
|
+
leftSize?: SidePanelSize | undefined;
|
|
81
|
+
/** The right panel's sizing. Defaults to 320 px, 220 px to 50%. */
|
|
82
|
+
rightSize?: SidePanelSize | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Remember the side panels' widths in `localStorage`, under `<storageKey>:left` and
|
|
85
|
+
* `<storageKey>:right`.
|
|
86
|
+
*/
|
|
87
|
+
storageKey?: string | undefined;
|
|
88
|
+
/** Merged with the shell's own classes through `cn` — override `h-dvh` to embed it. */
|
|
89
|
+
className?: string | undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The full-viewport frame of a studio app: `header` across the top, `left` | `main` |
|
|
93
|
+
* `right` in the middle with resizable side panels, `bottom` across the foot. Every slot but
|
|
94
|
+
* `main` is optional, and an absent slot takes no space.
|
|
95
|
+
*
|
|
96
|
+
* Landmarks: the header is a `<header>`, the main surface a `<main>`, the side panels
|
|
97
|
+
* `<aside>`s named by `leftLabel` and `rightLabel`. Each side panel is divided from the main
|
|
98
|
+
* surface by a `SplitPane` divider (drag, or focus it and use the arrow keys). Only the
|
|
99
|
+
* insides of the panels scroll; the shell itself is fixed to the viewport (`h-dvh`).
|
|
100
|
+
*/
|
|
101
|
+
export declare function AppShell({ header, left, main, right, bottom, leftLabel, rightLabel, leftSize, rightSize, storageKey, className }: AppShellProps): import("react").JSX.Element;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/components/SplitPane.d.ts
|
|
104
|
+
/** Props of `SplitPane`. */
|
|
105
|
+
interface SplitPaneProps {
|
|
106
|
+
/**
|
|
107
|
+
* The two panes, in reading order (left then right, or top then bottom). Exactly two;
|
|
108
|
+
* nest another `SplitPane` in either for more.
|
|
109
|
+
*/
|
|
110
|
+
children: readonly [ReactNode, ReactNode];
|
|
111
|
+
/**
|
|
112
|
+
* `horizontal` (the default) lays the panes side by side with a vertical divider;
|
|
113
|
+
* `vertical` stacks them with a horizontal one.
|
|
114
|
+
*/
|
|
115
|
+
orientation?: SplitOrientation | undefined;
|
|
116
|
+
/** Which pane carries the size; the other takes the rest. Defaults to `start`. */
|
|
117
|
+
sizedPane?: SizedPane | undefined;
|
|
118
|
+
/** The sized pane's size in pixels, controlled. Pair with `onSizeChange`. */
|
|
119
|
+
size?: number | undefined;
|
|
120
|
+
/** The initial size when uncontrolled: pixels or a percentage. Defaults to `"50%"`. */
|
|
121
|
+
defaultSize?: PaneSize | undefined;
|
|
122
|
+
/** Called with the new size in pixels on every drag move and key press (0 when collapsed). */
|
|
123
|
+
onSizeChange?: ((size: number) => void) | undefined;
|
|
124
|
+
/** The sized pane's smallest open size: pixels or a percentage. Defaults to 0. */
|
|
125
|
+
minSize?: PaneSize | undefined;
|
|
126
|
+
/** The sized pane's largest size: pixels or a percentage. Defaults to `"100%"`. */
|
|
127
|
+
maxSize?: PaneSize | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Lets the sized pane close: dragging it below half its minimum snaps it shut, and Enter
|
|
130
|
+
* on the divider collapses it or restores the last open size.
|
|
131
|
+
*/
|
|
132
|
+
collapsible?: boolean | undefined;
|
|
133
|
+
/** How far one arrow-key press moves the divider, in pixels (four times with Shift). Defaults to 16. */
|
|
134
|
+
step?: number | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Remember the size under this `localStorage` key, and start from it. Uncontrolled only:
|
|
137
|
+
* a controlled split's size is the caller's to keep.
|
|
138
|
+
*/
|
|
139
|
+
storageKey?: string | undefined;
|
|
140
|
+
/** Names the divider for assistive technology. Defaults to "Resize panes". */
|
|
141
|
+
"aria-label"?: string | undefined;
|
|
142
|
+
/** Merged with the split's own classes through `cn`. */
|
|
143
|
+
className?: string | undefined;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Two panes with a draggable, keyboard-operable divider between them.
|
|
147
|
+
*
|
|
148
|
+
* The divider is a `role="separator"` focusable control carrying `aria-valuenow` (the sized
|
|
149
|
+
* pane's size in pixels), `aria-valuemin`/`aria-valuemax` and `aria-controls` (the sized
|
|
150
|
+
* pane). Arrow keys along the axis move it by `step` (Shift: four steps), Home/End give the
|
|
151
|
+
* sized pane its minimum/maximum, Enter collapses or restores a `collapsible` pane. Dragging
|
|
152
|
+
* uses pointer capture, so the drag survives the pointer leaving the divider.
|
|
153
|
+
*
|
|
154
|
+
* Fills its container (`h-full w-full`), so it nests. State is exposed as `data-orientation`
|
|
155
|
+
* on the root, `data-dragging` on the root and the divider while a drag is in progress, and
|
|
156
|
+
* `data-collapsed` on the root and the sized pane while it is closed.
|
|
157
|
+
*/
|
|
158
|
+
export declare function SplitPane({ children, orientation, sizedPane, size: controlledSize, defaultSize, onSizeChange, minSize, maxSize, collapsible, step, storageKey, "aria-label": ariaLabel, className }: SplitPaneProps): import("react").JSX.Element;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/components/treeModel.d.ts
|
|
161
|
+
/** One node of a `TreeView`. */
|
|
162
|
+
interface TreeNode {
|
|
163
|
+
/** Identifies the node to `selectedId`, `onSelect` and `expanded`. Unique in the tree. */
|
|
164
|
+
id: string;
|
|
165
|
+
/** The node's name: shown, read out, and matched by type-ahead. */
|
|
166
|
+
label: string;
|
|
167
|
+
/** A leading icon (decorative) — typically a lucide icon at `size-3.5`. */
|
|
168
|
+
icon?: ReactNode;
|
|
169
|
+
/** Child nodes. A node with a (possibly empty) array is a parent; without, a leaf. */
|
|
170
|
+
children?: readonly TreeNode[] | undefined;
|
|
171
|
+
/** A quiet trailing annotation — a type, a count, a frame name. Shown in mono. */
|
|
172
|
+
meta?: ReactNode;
|
|
173
|
+
/** Shown and focusable, but not selectable. */
|
|
174
|
+
disabled?: boolean | undefined;
|
|
175
|
+
}
|
|
176
|
+
/** A node as it is laid out: one visible row of the tree. */
|
|
177
|
+
interface TreeRow {
|
|
178
|
+
/** The node. */
|
|
179
|
+
node: TreeNode;
|
|
180
|
+
/** Depth, from 1 at the root (`aria-level`). */
|
|
181
|
+
level: number;
|
|
182
|
+
/** The parent's id, or `null` at the root. */
|
|
183
|
+
parentId: string | null;
|
|
184
|
+
/** 1-based position among its siblings (`aria-posinset`). */
|
|
185
|
+
posInSet: number;
|
|
186
|
+
/** How many siblings, itself included (`aria-setsize`). */
|
|
187
|
+
setSize: number;
|
|
188
|
+
/** Whether the node has a children array. */
|
|
189
|
+
isParent: boolean;
|
|
190
|
+
/** Whether the node is a parent and expanded. */
|
|
191
|
+
isExpanded: boolean;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The rows a reader can see: every root, and the children of every expanded parent, in
|
|
195
|
+
* document order.
|
|
196
|
+
*
|
|
197
|
+
* @param nodes - The roots.
|
|
198
|
+
* @param expanded - The ids of the expanded parents.
|
|
199
|
+
* @returns The visible rows, in order.
|
|
200
|
+
*/
|
|
201
|
+
export declare function visibleRows(nodes: readonly TreeNode[], expanded: ReadonlySet<string>): TreeRow[];
|
|
202
|
+
/**
|
|
203
|
+
* Every parent's id — the expanded set for "everything open".
|
|
204
|
+
*
|
|
205
|
+
* @param nodes - The roots.
|
|
206
|
+
* @returns The ids of every node with a children array, at any depth.
|
|
207
|
+
*/
|
|
208
|
+
export declare function parentIds(nodes: readonly TreeNode[]): string[];
|
|
209
|
+
/**
|
|
210
|
+
* The ancestors of a node, root first — what must be expanded for it to be visible.
|
|
211
|
+
*
|
|
212
|
+
* @param nodes - The roots.
|
|
213
|
+
* @param id - The node.
|
|
214
|
+
* @returns The ancestor ids, root first; empty for a root or an id not in the tree.
|
|
215
|
+
*/
|
|
216
|
+
export declare function ancestorIds(nodes: readonly TreeNode[], id: string): string[];
|
|
217
|
+
/** What a key press on a tree asks for. */
|
|
218
|
+
type TreeKeyAction = {
|
|
219
|
+
type: "focus";
|
|
220
|
+
id: string;
|
|
221
|
+
} | {
|
|
222
|
+
type: "expand";
|
|
223
|
+
id: string;
|
|
224
|
+
} | {
|
|
225
|
+
type: "collapse";
|
|
226
|
+
id: string;
|
|
227
|
+
} | {
|
|
228
|
+
type: "select";
|
|
229
|
+
id: string;
|
|
230
|
+
} | {
|
|
231
|
+
type: "expand-siblings";
|
|
232
|
+
ids: string[];
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* The tree's keyboard (the WAI-ARIA tree pattern), as a pure function.
|
|
236
|
+
*
|
|
237
|
+
* ↓/↑ move to the next/previous visible row; → expands a closed parent, or moves into an
|
|
238
|
+
* open one's first child; ← collapses an open parent, or moves to the parent; Home/End go to
|
|
239
|
+
* the first/last visible row; Enter and Space select; `*` expands every sibling of the
|
|
240
|
+
* focused row; a printable character moves to the next row whose label starts with it
|
|
241
|
+
* (type-ahead, wrapping).
|
|
242
|
+
*
|
|
243
|
+
* @param rows - The visible rows, from `visibleRows`.
|
|
244
|
+
* @param focusedId - The row with focus.
|
|
245
|
+
* @param key - `KeyboardEvent.key`.
|
|
246
|
+
* @returns The action, or `null` when the key does nothing here.
|
|
247
|
+
*/
|
|
248
|
+
export declare function treeKeyAction(rows: readonly TreeRow[], focusedId: string, key: string): TreeKeyAction | null;
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/components/TreeView.d.ts
|
|
251
|
+
/** Props of `TreeView`. */
|
|
252
|
+
interface TreeViewProps {
|
|
253
|
+
/** The roots of the tree. */
|
|
254
|
+
nodes: readonly TreeNode[];
|
|
255
|
+
/** The selected node's id, controlled; `null` or absent for none. */
|
|
256
|
+
selectedId?: string | null | undefined;
|
|
257
|
+
/** Called with the node's id (and the node) on click, Enter or Space. Not called for a disabled node. */
|
|
258
|
+
onSelect?: ((id: string, node: TreeNode) => void) | undefined;
|
|
259
|
+
/** The expanded parents' ids, controlled. Pair with `onExpandedChange`. */
|
|
260
|
+
expanded?: readonly string[] | undefined;
|
|
261
|
+
/** The initially expanded parents' ids, when uncontrolled. */
|
|
262
|
+
defaultExpanded?: readonly string[] | undefined;
|
|
263
|
+
/** Start with every parent expanded, when uncontrolled (overrides `defaultExpanded`). */
|
|
264
|
+
defaultExpandAll?: boolean | undefined;
|
|
265
|
+
/** Called with the new set of expanded ids whenever a parent opens or closes. */
|
|
266
|
+
onExpandedChange?: ((expanded: string[]) => void) | undefined;
|
|
267
|
+
/** Names the tree for assistive technology. */
|
|
268
|
+
"aria-label": string;
|
|
269
|
+
/** Merged with the tree's own classes through `cn`. */
|
|
270
|
+
className?: string | undefined;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A data-driven tree (the WAI-ARIA tree pattern) with single selection.
|
|
274
|
+
*
|
|
275
|
+
* Keyboard: the tree is one Tab stop (roving `tabindex`). ↓/↑ move between visible rows, →
|
|
276
|
+
* expands a parent or enters it, ← collapses a parent or goes up to its parent, Home/End jump
|
|
277
|
+
* to the ends, Enter/Space select, `*` expands the focused row's siblings, and a letter jumps
|
|
278
|
+
* to the next row starting with it. Clicking a row selects it; clicking its chevron toggles it.
|
|
279
|
+
*
|
|
280
|
+
* Selection is controlled (`selectedId`/`onSelect`). When `selectedId` changes to a node
|
|
281
|
+
* inside a collapsed parent, its ancestors are expanded (through `onExpandedChange` when
|
|
282
|
+
* `expanded` is controlled) and the row is scrolled into view — so a pick in a viewport can
|
|
283
|
+
* drive the tree.
|
|
284
|
+
*
|
|
285
|
+
* Each row is a `treeitem` with `aria-level`, `aria-posinset`, `aria-setsize`,
|
|
286
|
+
* `aria-selected` and, for parents, `aria-expanded`; also `data-selected` and, for parents,
|
|
287
|
+
* `data-state` (`open`/`closed`). Row height follows the density in force.
|
|
288
|
+
*/
|
|
289
|
+
export declare function TreeView({ nodes, selectedId, onSelect, expanded: controlledExpanded, defaultExpanded, defaultExpandAll, onExpandedChange, "aria-label": ariaLabel, className }: TreeViewProps): import("react").JSX.Element;
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/components/playhead.d.ts
|
|
292
|
+
/**
|
|
293
|
+
* A sampled timeline's current position: an external store shared by React and render loops.
|
|
294
|
+
*
|
|
295
|
+
* Every function member may be called detached (`const { get } = playhead`), which is how
|
|
296
|
+
* `useSyncExternalStore` and a render loop hold them.
|
|
297
|
+
*/
|
|
298
|
+
interface Playhead {
|
|
299
|
+
/** The current sample index, an integer in `0 … count − 1` (0 when `count` is 0). Cheap: call it every frame. */
|
|
300
|
+
readonly get: () => number;
|
|
301
|
+
/**
|
|
302
|
+
* Move to sample `k`. Rounded to an integer and clamped to `0 … count − 1`; listeners are
|
|
303
|
+
* notified only if the index changed.
|
|
304
|
+
*/
|
|
305
|
+
readonly set: (k: number) => void;
|
|
306
|
+
/**
|
|
307
|
+
* Be told when the index or the timeline changes.
|
|
308
|
+
*
|
|
309
|
+
* @returns The unsubscribe function.
|
|
310
|
+
*/
|
|
311
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
312
|
+
/** How many samples the timeline has. */
|
|
313
|
+
readonly count: number;
|
|
314
|
+
/** The time between samples, in seconds. Sample `k` is at `t = k · dt`. */
|
|
315
|
+
readonly dt: number;
|
|
316
|
+
/**
|
|
317
|
+
* Swap in a new timeline — a newly loaded or re-baked scenario — keeping the one store
|
|
318
|
+
* every subscriber already holds. The index is clamped into the new range (not reset:
|
|
319
|
+
* call `set(0)` for that). Listeners are notified if anything changed.
|
|
320
|
+
*/
|
|
321
|
+
readonly setTimeline: (count: number, dt: number) => void;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* A playhead over `count` samples spaced `dt` seconds apart, starting at sample 0.
|
|
325
|
+
*
|
|
326
|
+
* Create one per app (not per render — keep it in a `useState` initialiser or module
|
|
327
|
+
* scope), hand it to `PlaybackBar` and to the render loop, and replace its timeline with
|
|
328
|
+
* `setTimeline` when a new scenario loads.
|
|
329
|
+
*
|
|
330
|
+
* @param count - The number of samples (a non-negative integer).
|
|
331
|
+
* @param dt - Seconds between samples (positive).
|
|
332
|
+
* @returns The store.
|
|
333
|
+
*/
|
|
334
|
+
export declare function createPlayhead(count: number, dt: number): Playhead;
|
|
335
|
+
/**
|
|
336
|
+
* A sample index made legal: rounded, and clamped to `0 … count − 1`.
|
|
337
|
+
*
|
|
338
|
+
* @param k - Any number (`NaN` reads as 0).
|
|
339
|
+
* @param count - The number of samples.
|
|
340
|
+
* @returns The index; 0 when `count` is 0.
|
|
341
|
+
*/
|
|
342
|
+
export declare function clampIndex(k: number, count: number): number;
|
|
343
|
+
/** The outcome of one clock step: the new fractional position, and whether playback ran off the end. */
|
|
344
|
+
interface AdvanceResult {
|
|
345
|
+
/** The new position in samples (fractional); the index to show is its floor. */
|
|
346
|
+
position: number;
|
|
347
|
+
/** True when a non-looping timeline reached its last sample on this step. */
|
|
348
|
+
ended: boolean;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* One step of real-time playback, in samples.
|
|
352
|
+
*
|
|
353
|
+
* Each sample is shown for `dt`: a looping timeline has period `count · dt` and wraps from
|
|
354
|
+
* the last sample to the first; a non-looping one stops on the last sample and reports
|
|
355
|
+
* `ended`. The position is fractional so that playback slower than one sample per frame
|
|
356
|
+
* still advances.
|
|
357
|
+
*
|
|
358
|
+
* @param position - The current position in samples (fractional).
|
|
359
|
+
* @param delta - How many samples to advance (elapsed seconds × speed ÷ dt); not negative.
|
|
360
|
+
* @param count - The number of samples.
|
|
361
|
+
* @param loop - Whether to wrap at the end.
|
|
362
|
+
* @returns The new position and whether playback ended.
|
|
363
|
+
*/
|
|
364
|
+
export declare function advance(position: number, delta: number, count: number, loop: boolean): AdvanceResult;
|
|
365
|
+
/**
|
|
366
|
+
* The default time readout: seconds with millisecond resolution, `"1.234 s"`.
|
|
367
|
+
*
|
|
368
|
+
* @param seconds - The time.
|
|
369
|
+
* @returns The formatted time.
|
|
370
|
+
*/
|
|
371
|
+
export declare function formatSeconds(seconds: number): string;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/components/PlaybackBar.d.ts
|
|
374
|
+
/** A point of interest on the timeline — a capture, an event — drawn as a tick on the scrubber. */
|
|
375
|
+
interface PlaybackMarker {
|
|
376
|
+
/** The sample the marker sits on. */
|
|
377
|
+
index: number;
|
|
378
|
+
/** What happens there; names the tick for assistive technology and its tooltip. */
|
|
379
|
+
label?: string | undefined;
|
|
380
|
+
/** The tick's colour. Defaults to `signal`. */
|
|
381
|
+
tone?: MeasureTone | undefined;
|
|
382
|
+
}
|
|
383
|
+
/** The speeds offered by default. */
|
|
384
|
+
export declare const DEFAULT_SPEEDS: readonly number[];
|
|
385
|
+
/** Props of `PlaybackBar`. */
|
|
386
|
+
interface PlaybackBarProps {
|
|
387
|
+
/** Where playback is. The bar subscribes to it; seeking writes to it. */
|
|
388
|
+
playhead: Playhead;
|
|
389
|
+
/** Whether playback is running, controlled. */
|
|
390
|
+
playing: boolean;
|
|
391
|
+
/** Called with the requested playing state (the play/pause button, Space). */
|
|
392
|
+
onPlayingChange: (playing: boolean) => void;
|
|
393
|
+
/** The playback rate, controlled. Defaults to 1. */
|
|
394
|
+
speed?: number | undefined;
|
|
395
|
+
/** Called with the chosen rate. Without it the speed selector is not shown. */
|
|
396
|
+
onSpeedChange?: ((speed: number) => void) | undefined;
|
|
397
|
+
/** The rates the selector offers. Defaults to 0.25×, 0.5×, 1×, 2×, 4×. */
|
|
398
|
+
speeds?: readonly number[] | undefined;
|
|
399
|
+
/** Whether playback wraps at the end, controlled. */
|
|
400
|
+
loop?: boolean | undefined;
|
|
401
|
+
/** Called with the new loop state. Without it the loop toggle is not shown. */
|
|
402
|
+
onLoopChange?: ((loop: boolean) => void) | undefined;
|
|
403
|
+
/** Ticks on the scrubber, each a click target that seeks to it. */
|
|
404
|
+
markers?: readonly PlaybackMarker[] | undefined;
|
|
405
|
+
/** Called after a marker tick is clicked (the playhead has already moved to it). */
|
|
406
|
+
onMarkerSelect?: ((marker: PlaybackMarker) => void) | undefined;
|
|
407
|
+
/** Formats `t = k · dt` in seconds for the readout. Defaults to `"1.234 s"`. */
|
|
408
|
+
formatTime?: ((seconds: number) => string) | undefined;
|
|
409
|
+
/** Names the bar (a `toolbar`). Defaults to "Playback". */
|
|
410
|
+
"aria-label"?: string | undefined;
|
|
411
|
+
/** Merged with the bar's own classes through `cn`. */
|
|
412
|
+
className?: string | undefined;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* The transport for a sampled timeline: jump to start, previous marker, step back,
|
|
416
|
+
* play/pause, step forward, next marker, jump to end; a scrubber over the samples with the
|
|
417
|
+
* markers as ticks; the time `t = k · dt`; the speed; loop.
|
|
418
|
+
*
|
|
419
|
+
* `playing`, `speed` and `loop` are controlled props. The position is the `playhead` store,
|
|
420
|
+
* which the bar subscribes to itself — so during playback only the bar re-renders. Drive the
|
|
421
|
+
* store with `usePlaybackClock`, and read `playhead.get()` in a render loop.
|
|
422
|
+
*
|
|
423
|
+
* A `role="toolbar"`. Keyboard, while focus is inside it: the scrubber is a slider (←/→ one
|
|
424
|
+
* sample, PageUp/PageDown ten, Home/End); on the buttons, ←/→ step one sample; Space
|
|
425
|
+
* toggles playback anywhere in the bar except on a button, where it presses the button. The
|
|
426
|
+
* root carries `data-playing` while playing and `data-empty` when the timeline has no samples.
|
|
427
|
+
*/
|
|
428
|
+
export declare function PlaybackBar({ playhead, playing, onPlayingChange, speed, onSpeedChange, speeds, loop, onLoopChange, markers, onMarkerSelect, formatTime, "aria-label": ariaLabel, className }: PlaybackBarProps): import("react").JSX.Element;
|
|
429
|
+
//#endregion
|
|
430
|
+
//#region src/components/usePlayback.d.ts
|
|
431
|
+
/**
|
|
432
|
+
* The playhead's current sample index, re-rendering the calling component when it changes.
|
|
433
|
+
*
|
|
434
|
+
* Use it only where the index is *displayed* (the playback bar, a readout). A render loop
|
|
435
|
+
* reads `playhead.get()` in its own frame callback instead, and re-renders nothing.
|
|
436
|
+
*
|
|
437
|
+
* @param playhead - The store.
|
|
438
|
+
* @returns The current sample index.
|
|
439
|
+
*/
|
|
440
|
+
export declare function usePlayhead(playhead: Playhead): number;
|
|
441
|
+
/**
|
|
442
|
+
* The playhead's timeline — `count` and `dt` — re-rendering when `setTimeline` changes it.
|
|
443
|
+
*
|
|
444
|
+
* @param playhead - The store.
|
|
445
|
+
* @returns The number of samples and the seconds between them.
|
|
446
|
+
*/
|
|
447
|
+
export declare function usePlayheadTimeline(playhead: Playhead): {
|
|
448
|
+
count: number;
|
|
449
|
+
dt: number;
|
|
450
|
+
};
|
|
451
|
+
/** Options of `usePlaybackClock`. */
|
|
452
|
+
interface PlaybackClockOptions {
|
|
453
|
+
/** The store to advance. */
|
|
454
|
+
playhead: Playhead;
|
|
455
|
+
/** Whether the clock runs. */
|
|
456
|
+
playing: boolean;
|
|
457
|
+
/** Playback rate: 1 is real time. Defaults to 1. */
|
|
458
|
+
speed?: number | undefined;
|
|
459
|
+
/** Wrap from the last sample to the first instead of stopping. Defaults to false. */
|
|
460
|
+
loop?: boolean | undefined;
|
|
461
|
+
/** Called once when a non-looping timeline reaches its last sample; set `playing` false here. */
|
|
462
|
+
onEnd?: (() => void) | undefined;
|
|
463
|
+
/**
|
|
464
|
+
* The longest wall-clock gap one frame may advance by, in milliseconds. A tab in the
|
|
465
|
+
* background gets no animation frames, and without this cap the first frame back would
|
|
466
|
+
* jump by the whole time away. Defaults to 100.
|
|
467
|
+
*/
|
|
468
|
+
maxFrameMs?: number | undefined;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Advance a playhead in real time × `speed` while `playing`, from `requestAnimationFrame`.
|
|
472
|
+
*
|
|
473
|
+
* Position is accumulated fractionally, so slow playback of a finely sampled timeline still
|
|
474
|
+
* moves; the store only ever holds the integer index. A seek from elsewhere (the scrubber, a
|
|
475
|
+
* marker) is picked up on the next frame. Starting a non-looping timeline that sits on its
|
|
476
|
+
* last sample rewinds it to 0 first. `speed`, `loop` and `onEnd` may change while playing
|
|
477
|
+
* without restarting the clock.
|
|
478
|
+
*
|
|
479
|
+
* Renders nothing and re-renders nothing: call it once, in the component that owns the
|
|
480
|
+
* `playing` state.
|
|
481
|
+
*
|
|
482
|
+
* @param options - The playhead and the transport state.
|
|
483
|
+
*/
|
|
484
|
+
export declare function usePlaybackClock({ playhead, playing, speed, loop, onEnd, maxFrameMs }: PlaybackClockOptions): void;
|
|
485
|
+
//#endregion
|
|
486
|
+
//#region src/components/FileDrop.d.ts
|
|
487
|
+
/** Props of `FileDrop`. */
|
|
488
|
+
interface FileDropProps {
|
|
489
|
+
/** Called with the accepted files of a drop or a pick (never with an empty list). */
|
|
490
|
+
onFiles: (files: File[]) => void;
|
|
491
|
+
/** Called with the files a drop or a pick brought that `accept` turned away. */
|
|
492
|
+
onReject?: ((files: File[]) => void) | undefined;
|
|
493
|
+
/**
|
|
494
|
+
* Which files to take, as `<input accept>`: extensions (`.json`), MIME types and MIME
|
|
495
|
+
* wildcards (`image/*`), comma-separated. Applied to drops as well as the picker. Default: all.
|
|
496
|
+
*/
|
|
497
|
+
accept?: string | undefined;
|
|
498
|
+
/** Take several files at once. Defaults to true; when false only the first accepted file is passed. */
|
|
499
|
+
multiple?: boolean | undefined;
|
|
500
|
+
/**
|
|
501
|
+
* The picker chooses a folder (`webkitdirectory`) instead of files. Dropped folders are
|
|
502
|
+
* walked either way; files found in a folder carry `webkitRelativePath`.
|
|
503
|
+
*/
|
|
504
|
+
directory?: boolean | undefined;
|
|
505
|
+
/**
|
|
506
|
+
* Take drops anywhere in the window, showing a full-window overlay while files are dragged
|
|
507
|
+
* over it; the component itself then renders only the picker button (for a header). Without
|
|
508
|
+
* it, the component is an inline drop zone.
|
|
509
|
+
*/
|
|
510
|
+
overlay?: boolean | undefined;
|
|
511
|
+
/** Refuses drops and blocks the picker. */
|
|
512
|
+
disabled?: boolean | undefined;
|
|
513
|
+
/** The picker button's label. Defaults to "Open files…" (or "Open folder…" with `directory`). */
|
|
514
|
+
buttonLabel?: string | undefined;
|
|
515
|
+
/** The overlay's message. Defaults to "Drop to open". */
|
|
516
|
+
overlayMessage?: ReactNode;
|
|
517
|
+
/** The inline zone's message, before the button. Defaults to "Drop files here, or". */
|
|
518
|
+
children?: ReactNode;
|
|
519
|
+
/** Merged with the zone's (or, with `overlay`, the button's) own classes through `cn`. */
|
|
520
|
+
className?: string | undefined;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* A drop target plus an "Open files…" button over a hidden `<input type="file">`.
|
|
524
|
+
*
|
|
525
|
+
* Inline (the default) it is a dashed zone with a message and the button, carrying
|
|
526
|
+
* `data-dragging` while files are dragged over it. With `overlay` it renders only the button
|
|
527
|
+
* and takes drops anywhere in the window, showing a full-window overlay (`aria-hidden`: the
|
|
528
|
+
* button is the accessible route) while a drag carrying files is over the window. Only drags
|
|
529
|
+
* that carry files are reacted to; text and links pass through.
|
|
530
|
+
*
|
|
531
|
+
* Files are filtered by `accept` on both routes (the browser applies it to neither drops nor,
|
|
532
|
+
* reliably, the picker); the rest go to `onReject`. A dropped folder is walked recursively.
|
|
533
|
+
*/
|
|
534
|
+
export declare function FileDrop({ onFiles, onReject, accept, multiple, directory, overlay, disabled, buttonLabel, overlayMessage, children, className }: FileDropProps): import("react").JSX.Element;
|
|
535
|
+
//#endregion
|
|
536
|
+
//#region src/components/dropFiles.d.ts
|
|
537
|
+
/**
|
|
538
|
+
* Whether a file matches an `accept` string, as `<input type="file" accept>` reads it:
|
|
539
|
+
* comma-separated extensions (`.json`), MIME types (`application/json`) and MIME wildcards
|
|
540
|
+
* (`image/*`). Matching is case-insensitive.
|
|
541
|
+
*
|
|
542
|
+
* @param file - The file's name and MIME type.
|
|
543
|
+
* @param accept - The accept string; empty or absent accepts everything.
|
|
544
|
+
* @returns Whether the file is accepted.
|
|
545
|
+
*/
|
|
546
|
+
export declare function acceptsFile(file: {
|
|
547
|
+
name: string;
|
|
548
|
+
type: string;
|
|
549
|
+
}, accept: string | undefined): boolean;
|
|
550
|
+
/** The part of the File and Directory Entries API a drop walk needs (`webkitGetAsEntry`). */
|
|
551
|
+
interface DropEntry {
|
|
552
|
+
/** A file (`FileSystemFileEntry`). */
|
|
553
|
+
isFile: boolean;
|
|
554
|
+
/** A folder (`FileSystemDirectoryEntry`). */
|
|
555
|
+
isDirectory: boolean;
|
|
556
|
+
/** The entry's own name. */
|
|
557
|
+
name: string;
|
|
558
|
+
/** The entry's path from the drop root, with a leading `/`. */
|
|
559
|
+
fullPath: string;
|
|
560
|
+
/** A file entry's contents, as a `File`. */
|
|
561
|
+
file?: (success: (file: File) => void, failure?: (error: unknown) => void) => void;
|
|
562
|
+
/** A folder entry's reader; `readEntries` yields the children in batches, then an empty one. */
|
|
563
|
+
createReader?: () => {
|
|
564
|
+
readEntries: (success: (entries: DropEntry[]) => void, failure?: (error: unknown) => void) => void;
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* Every file in a drop, with dropped folders walked recursively.
|
|
569
|
+
*
|
|
570
|
+
* Files found inside a folder carry `webkitRelativePath` (`scene/meshes/base.glb`), as the
|
|
571
|
+
* files of `<input webkitdirectory>` do, so both routes give the same shape. Where the entries
|
|
572
|
+
* API is missing, the drop's plain file list is returned.
|
|
573
|
+
*
|
|
574
|
+
* @param dataTransfer - The drop's data.
|
|
575
|
+
* @returns The files, in the order the browser listed them.
|
|
576
|
+
*/
|
|
577
|
+
export declare function collectDroppedFiles(dataTransfer: Pick<DataTransfer, "files" | "items">): Promise<File[]>;
|
|
578
|
+
//#endregion
|
|
579
|
+
//#region src/components/toastStore.d.ts
|
|
580
|
+
/** A toast's kind: a fact (`info`), a completed action (`success`), a caveat (`warn`), a failure (`error`). */
|
|
581
|
+
type ToastTone = "info" | "success" | "warn" | "error";
|
|
582
|
+
/** What `toast()` takes. */
|
|
583
|
+
interface ToastOptions {
|
|
584
|
+
/** One line: what happened. */
|
|
585
|
+
title: string;
|
|
586
|
+
/** More detail, and what to do about it. */
|
|
587
|
+
description?: string | undefined;
|
|
588
|
+
/** Defaults to `info`. */
|
|
589
|
+
tone?: ToastTone | undefined;
|
|
590
|
+
/**
|
|
591
|
+
* How long it stays, in milliseconds, while not hovered or focused. Defaults to 5000
|
|
592
|
+
* (8000 for `error`); `Infinity` keeps it until dismissed.
|
|
593
|
+
*/
|
|
594
|
+
duration?: number | undefined;
|
|
595
|
+
/** Replace the toast with this id instead of adding one — for progress that updates in place. */
|
|
596
|
+
id?: string | undefined;
|
|
597
|
+
}
|
|
598
|
+
/** A toast in the store. */
|
|
599
|
+
interface ToastRecord {
|
|
600
|
+
/** Identifies the toast to `dismiss` and to `id` replacement. */
|
|
601
|
+
id: string;
|
|
602
|
+
/** One line: what happened. */
|
|
603
|
+
title: string;
|
|
604
|
+
/** More detail, if any. */
|
|
605
|
+
description: string | undefined;
|
|
606
|
+
/** Its kind. */
|
|
607
|
+
tone: ToastTone;
|
|
608
|
+
/** Milliseconds before it dismisses itself (`Infinity`: never). */
|
|
609
|
+
duration: number;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* A toast store: what `toast()` writes to and `<Toaster />` reads. Every member may be called
|
|
613
|
+
* detached.
|
|
614
|
+
*/
|
|
615
|
+
interface ToastStore {
|
|
616
|
+
/** Add a toast (or replace the one with `options.id`), returning its id. */
|
|
617
|
+
readonly toast: (options: ToastOptions) => string;
|
|
618
|
+
/** Remove one toast, or every toast when `id` is omitted. */
|
|
619
|
+
readonly dismiss: (id?: string) => void;
|
|
620
|
+
/** The toasts, oldest first. The same array until the store changes. */
|
|
621
|
+
readonly getSnapshot: () => readonly ToastRecord[];
|
|
622
|
+
/** Be told when the toasts change; returns the unsubscribe function. */
|
|
623
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* A new, empty toast store. The package keeps one (behind `toast()` and the default
|
|
627
|
+
* `<Toaster />`); create another only to isolate a region or a test.
|
|
628
|
+
*
|
|
629
|
+
* @returns The store.
|
|
630
|
+
*/
|
|
631
|
+
export declare function createToastStore(): ToastStore;
|
|
632
|
+
/** The store behind `toast()` and a `<Toaster />` given no `store`. */
|
|
633
|
+
export declare const defaultToastStore: ToastStore;
|
|
634
|
+
/**
|
|
635
|
+
* Raise a notification, from anywhere — shown by the mounted `<Toaster />`.
|
|
636
|
+
*
|
|
637
|
+
* `toast({ title: "Scenario loaded", tone: "success" })`. Pass `id` to update a toast in
|
|
638
|
+
* place (a progress message that becomes a result). `toast.dismiss(id)` removes one early,
|
|
639
|
+
* `toast.dismiss()` all of them.
|
|
640
|
+
*
|
|
641
|
+
* @param options - The message, its tone and its duration.
|
|
642
|
+
* @returns The toast's id.
|
|
643
|
+
*/
|
|
644
|
+
export declare const toast: ((options: ToastOptions) => string) & {
|
|
645
|
+
/** Remove one toast, or every toast when `id` is omitted. */
|
|
646
|
+
dismiss: (id?: string) => void;
|
|
647
|
+
};
|
|
648
|
+
//#endregion
|
|
649
|
+
//#region src/components/Toaster.d.ts
|
|
650
|
+
/** Props of `Toaster`. */
|
|
651
|
+
interface ToasterProps {
|
|
652
|
+
/** The store to show. Defaults to the one behind `toast()`. */
|
|
653
|
+
store?: ToastStore | undefined;
|
|
654
|
+
/** How many toasts are shown at once; older ones wait. Defaults to 5. */
|
|
655
|
+
limit?: number | undefined;
|
|
656
|
+
/** Merged with the stack's own classes through `cn` (it is fixed to the bottom-right corner). */
|
|
657
|
+
className?: string | undefined;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* The stack of notifications raised with `toast()`. Mount it once, near the root.
|
|
661
|
+
*
|
|
662
|
+
* Fixed to the bottom-right corner, newest at the bottom. Each toast dismisses itself after
|
|
663
|
+
* its `duration`; the countdown pauses while the pointer is over the stack or focus is inside
|
|
664
|
+
* it. A `section` landmark ("Notifications") holding a polite live region, so new toasts are
|
|
665
|
+
* announced; an `error` toast is a `role="alert"`, announced at once. Each toast carries
|
|
666
|
+
* `data-tone` and a "Dismiss" button.
|
|
667
|
+
*/
|
|
668
|
+
export declare function Toaster({ store, limit, className }: ToasterProps): import("react").JSX.Element;
|
|
669
|
+
//#endregion
|
|
670
|
+
export type { AdvanceResult, AppShellProps, DropEntry, FileDropProps, PaneSize, PlaybackBarProps, PlaybackClockOptions, PlaybackMarker, Playhead, SidePanelSize, SizedPane, SplitLimits, SplitOrientation, SplitPaneProps, ToastOptions, ToastRecord, ToastStore, ToastTone, ToasterProps, TreeKeyAction, TreeNode, TreeRow, TreeViewProps };
|
|
671
|
+
//# sourceMappingURL=index.d.ts.map
|