@weasel-js/labkit 0.8.0 → 1.0.1
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 +11 -3
- package/dist/_dts/{DrawCommand-DACv9lhe.d.ts → DrawCommand-CitWPxMY.d.ts} +80 -7
- package/dist/_dts/{useExperimentState-eSvpwV_P.d.ts → useExperimentState-CJn2hHzd.d.ts} +6 -4
- package/dist/{chunk-SSMHPMDV.js → chunk-53XSBIUK.js} +12 -11
- package/dist/chunk-53XSBIUK.js.map +1 -0
- package/dist/{chunk-OHGEOTCV.js → chunk-EXBV7A6X.js} +3 -3
- package/dist/{chunk-OHGEOTCV.js.map → chunk-EXBV7A6X.js.map} +1 -1
- package/dist/{chunk-6V7ROR7G.js → chunk-ISEK5LXT.js} +1931 -904
- package/dist/chunk-ISEK5LXT.js.map +1 -0
- package/dist/chunk-NRD3TDNQ.js +5946 -0
- package/dist/chunk-NRD3TDNQ.js.map +1 -0
- package/dist/index.d.ts +37 -13
- package/dist/index.js +776 -27
- package/dist/index.js.map +1 -1
- package/dist/passthrough/weasel-canvas.d.ts +29 -6
- package/dist/passthrough/weasel-canvas.js +1 -1
- package/dist/passthrough/weasel-ui.d.ts +169 -79
- package/dist/passthrough/weasel-ui.js +2 -2
- package/dist/state/index.d.ts +2 -2
- package/dist/state/index.js +2 -2
- package/dist/styles.css +228 -287
- package/dist/ui/layers/index.js +3 -3
- package/package.json +4 -6
- package/src/canvas/CanvasStack.less +1 -1
- package/src/controls/ControlPanel.less +12 -12
- package/src/dragdrop/DragGhost.less +2 -2
- package/src/dragdrop/Palette.less +6 -6
- package/src/index.ts +2 -0
- package/src/lab/Lab.test.tsx +20 -15
- package/src/lab/Lab.tsx +33 -32
- package/src/lab/LabContext.ts +3 -3
- package/src/lab/LabShell.less +14 -14
- package/src/lab/LabShell.test.tsx +7 -20
- package/src/lab/LabShell.tsx +22 -13
- package/src/lab/WorkspaceGrid.less +1 -1
- package/src/lab/WorkspaceGrid.stories.tsx +4 -4
- package/src/lab/index.ts +1 -1
- package/src/lab/useSystemMode.ts +30 -0
- package/src/layers/LayerList.less +9 -9
- package/src/passthrough/weasel-ui.ts +4 -0
- package/src/primitives/FpsMeter.less +5 -5
- package/src/primitives/ScaleIndicator.less +7 -7
- package/src/primitives/Sidebar.less +12 -12
- package/src/primitives/StatusBar.less +10 -10
- package/src/primitives/Toolbar.less +16 -16
- package/src/state/store.test.ts +17 -9
- package/src/state/store.ts +13 -10
- package/src/state/types.ts +5 -2
- package/src/theme/Interstellar.stories.less +20 -20
- package/src/theme/Interstellar.stories.tsx +44 -59
- package/src/theme/base.less +26 -26
- package/src/theme/interstellar.test.ts +30 -0
- package/src/theme/interstellar.tokens.json +57 -0
- package/src/theme/interstellar.ts +9 -0
- package/src/ui/layers/LayerStack.less +21 -21
- package/src/ui/properties/CurveField.less +5 -5
- package/src/ui/properties/EffectCard.tsx +2 -2
- package/src/ui/properties/PropertyGroup.less +6 -6
- package/src/ui/properties/PropertyPanel.less +70 -70
- package/src/ui/properties/PropertyPanel.stories.tsx +0 -1
- package/src/ui/properties/SpeechBalloonPanels.stories.tsx +1 -1
- package/src/ui/properties/storyLayouts.tsx +1 -1
- package/src/workspace/Workspace.less +14 -14
- package/src/workspace/Workspace.stories.tsx +2 -2
- package/src/workspace/Workspace.test.tsx +2 -2
- package/dist/chunk-6V7ROR7G.js.map +0 -1
- package/dist/chunk-FBZCQXI2.js +0 -6037
- package/dist/chunk-FBZCQXI2.js.map +0 -1
- package/dist/chunk-SSMHPMDV.js.map +0 -1
- package/dist/theme-interstellar.css +0 -25
- package/dist/theme-light.css +0 -13
- package/src/theme/interstellar.less +0 -34
- package/src/theme/light.less +0 -14
- package/src/theme/tokens.less +0 -85
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Ref } from 'react';
|
|
3
|
-
import { N as Node, V as View, D as DrawCommand, S as Scene, B as Bounds, a as ViewportDims, P as PathDrawCommand } from '../_dts/DrawCommand-
|
|
3
|
+
import { N as Node, V as View, D as DrawCommand, S as Scene, B as Bounds, a as ViewportDims, P as PathDrawCommand } from '../_dts/DrawCommand-CitWPxMY.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `renderSceneToCanvas` — substrate for detached, read-only scene views
|
|
@@ -55,6 +55,10 @@ interface RenderSceneToCanvasArgs<TData, TLayer extends string, TPose> {
|
|
|
55
55
|
* minimap's visible-window indicator. Wrapped in the same view transform
|
|
56
56
|
* as scene commands. */
|
|
57
57
|
extraCommands?: DrawCommand[];
|
|
58
|
+
/** Optional per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot
|
|
59
|
+
* `alphaFor`. Pass the same function the main canvas uses to keep a
|
|
60
|
+
* scoping-dim treatment consistent across both. Defaults to `() => 1`. */
|
|
61
|
+
alphaFor?: (id: string) => number;
|
|
58
62
|
/** Optional device-pixel ratio. Defaults to `window.devicePixelRatio || 1`
|
|
59
63
|
* when available, otherwise 1. Tests typically pin this to 1 or 2. */
|
|
60
64
|
dpr?: number;
|
|
@@ -62,16 +66,27 @@ interface RenderSceneToCanvasArgs<TData, TLayer extends string, TPose> {
|
|
|
62
66
|
/**
|
|
63
67
|
* Build the DrawCommand list that `renderSceneToCanvas` would dispatch.
|
|
64
68
|
*
|
|
65
|
-
* Pure — no GL, no DOM, no side effects.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* so the output is in screen
|
|
69
|
+
* Pure — no GL, no DOM, no side effects. Walks the scene through
|
|
70
|
+
* `buildSceneTree` — the same walk `<SceneCanvas>`'s `buildSceneLayer` uses —
|
|
71
|
+
* appends any `extraCommands`, and wraps the result in a single
|
|
72
|
+
* `{ kind: 'group', transform: viewToMat3(view) }` so the output is in screen
|
|
73
|
+
* space. Sharing the walk is what keeps hidden layers unpainted and container
|
|
74
|
+
* clips applied here; a hand-rolled `renderOrder()` loop silently dropped both.
|
|
75
|
+
*
|
|
76
|
+
* Each node's commands additionally go through `wrapNodeOutput` — pose
|
|
77
|
+
* rotation, then the `alphaFor` multiplier — exactly as `buildSceneLayer`
|
|
78
|
+
* does, so a `drawOne` shared between the two paints the same thing in both.
|
|
79
|
+
* A `drawOne` that rotates its own output will therefore rotate twice here;
|
|
80
|
+
* emit unrotated geometry and let the pose drive it.
|
|
81
|
+
*
|
|
82
|
+
* Output shape follows `buildSceneTree`: one group per **visible** layer, in
|
|
83
|
+
* scene-layer order, each holding one group per node on that layer.
|
|
69
84
|
*
|
|
70
85
|
* Exported for tests and for callers that want to render into something
|
|
71
86
|
* other than a real `<canvas>` (e.g. an offscreen renderer or a
|
|
72
87
|
* snapshot fixture).
|
|
73
88
|
*/
|
|
74
|
-
declare function buildSceneViewCommands<TData, TLayer extends string, TPose>(scene: Scene<TData, TLayer, TPose>, view: View, drawOne: SceneViewDrawOne<TData, TLayer, TPose>, extraCommands?: ReadonlyArray<DrawCommand
|
|
89
|
+
declare function buildSceneViewCommands<TData, TLayer extends string, TPose>(scene: Scene<TData, TLayer, TPose>, view: View, drawOne: SceneViewDrawOne<TData, TLayer, TPose>, extraCommands?: ReadonlyArray<DrawCommand>, alphaFor?: (id: string) => number): DrawCommand[];
|
|
75
90
|
/**
|
|
76
91
|
* Render one frame of `scene` at `view` into `canvas`. See module docstring
|
|
77
92
|
* for the design context.
|
|
@@ -110,6 +125,10 @@ interface SceneViewCanvasProps<TData, TLayer extends string, TPose> {
|
|
|
110
125
|
* indicator; available to other consumers that want to overlay a
|
|
111
126
|
* world-space annotation. */
|
|
112
127
|
extraCommands?: ReadonlyArray<DrawCommand>;
|
|
128
|
+
/** Optional per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot
|
|
129
|
+
* `alphaFor`. Pass the same function the main canvas uses to keep a
|
|
130
|
+
* scoping-dim treatment consistent across both. Defaults to `() => 1`. */
|
|
131
|
+
alphaFor?: (id: string) => number;
|
|
113
132
|
/** Optional CSS class for sizing / positioning the `<canvas>`. The kit
|
|
114
133
|
* does not emit inline styles for layout — use a class. */
|
|
115
134
|
className?: string;
|
|
@@ -236,6 +255,10 @@ interface MinimapCanvasProps<TData, TLayer extends string, TPose> {
|
|
|
236
255
|
/** Pose → AABB. Defaults to identity (`pose as Bounds`), matching
|
|
237
256
|
* `sceneAdapter` / `useSelectTool`. */
|
|
238
257
|
poseBounds?: (pose: TPose) => Bounds;
|
|
258
|
+
/** Optional per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot
|
|
259
|
+
* `alphaFor`. Pass the same function the main canvas uses so a
|
|
260
|
+
* scoping-dim treatment shows up in the minimap too. */
|
|
261
|
+
alphaFor?: (id: string) => number;
|
|
239
262
|
/** Visual tuning of the indicator stroke. */
|
|
240
263
|
indicatorStyle?: IndicatorStyle;
|
|
241
264
|
/** CSS class for sizing / positioning the canvas. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { FALLBACK_FIT_VIEW, MinimapCanvas, SceneViewCanvas, buildSceneViewCommands, computeFitView2 as computeFitView, computeIndicatorCommand, renderSceneToCanvas } from '../chunk-
|
|
1
|
+
export { FALLBACK_FIT_VIEW, MinimapCanvas, SceneViewCanvas, buildSceneViewCommands, computeFitView2 as computeFitView, computeIndicatorCommand, renderSceneToCanvas } from '../chunk-ISEK5LXT.js';
|
|
2
2
|
//# sourceMappingURL=weasel-canvas.js.map
|
|
3
3
|
//# sourceMappingURL=weasel-canvas.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ReactNode, CSSProperties, ButtonHTMLAttributes, ReactElement, MutableRefObject, PointerEvent as PointerEvent$1, KeyboardEvent, RefCallback } from 'react';
|
|
4
|
-
import { V as View, D as DrawCommand, O as Op, b as NodeId, c as Path, S as Scene, H as History, B as Bounds } from '../_dts/DrawCommand-
|
|
3
|
+
import { ReactNode, CSSProperties, ButtonHTMLAttributes, ReactElement, MutableRefObject, PointerEvent as PointerEvent$1, KeyboardEvent, RefCallback, RefObject } from 'react';
|
|
4
|
+
import { V as View, D as DrawCommand, O as Op, b as NodeId, c as Path, S as Scene, H as History, B as Bounds } from '../_dts/DrawCommand-CitWPxMY.js';
|
|
5
5
|
import { TextFieldProps, ValidationResult, CheckboxProps as CheckboxProps$1, SwitchProps as SwitchProps$1, TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1, RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1, NumberFieldProps as NumberFieldProps$1, SelectProps as SelectProps$1, ListBoxItemProps, ComboBoxProps as ComboBoxProps$1, SliderProps as SliderProps$1, ModalOverlayProps, DialogProps as DialogProps$1 } from 'react-aria-components';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1157,6 +1157,31 @@ interface ModifierState {
|
|
|
1157
1157
|
interface AffordanceBinding<TScratch = unknown> {
|
|
1158
1158
|
initialScratch?: TScratch;
|
|
1159
1159
|
}
|
|
1160
|
+
/**
|
|
1161
|
+
* What a **registered layer's** `hitTest` returns. Extends `AffordanceBinding`
|
|
1162
|
+
* so existing implementations keep typechecking; the added fields are how a
|
|
1163
|
+
* consumer's own chrome says the things kit chrome says through
|
|
1164
|
+
* `AffordanceRegion` — which cursor to show, and whether it owns the point
|
|
1165
|
+
* outright.
|
|
1166
|
+
*/
|
|
1167
|
+
interface LayerHit<TScratch = unknown> extends AffordanceBinding<TScratch> {
|
|
1168
|
+
/** CSS cursor while the pointer is over this hit. Reaches the hover-cursor
|
|
1169
|
+
* pump as `AffordanceHit.cursor`, the same path kit chrome uses. */
|
|
1170
|
+
cursor?: string;
|
|
1171
|
+
/** `'exclusive'` bars every binding whose target doesn't consult the
|
|
1172
|
+
* affordance. Omitted means `'shared'` — today's behavior. Same name and
|
|
1173
|
+
* meaning as `AffordanceHit.strength`, which it becomes. */
|
|
1174
|
+
strength?: 'exclusive' | 'shared';
|
|
1175
|
+
/** Which gestures an exclusive claim bars. Omitted bars all of them. */
|
|
1176
|
+
claimedKinds?: readonly ClaimableGesture[];
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Gesture kinds an affordance claim can bar, in the spec vocabulary bindings
|
|
1180
|
+
* are written in. `'pointer'` is one token because `pointerDown` / `click` /
|
|
1181
|
+
* `drag` are a single press protocol — at the event level the first two are
|
|
1182
|
+
* the same `kind: 'pointerdown'`, told apart only by `stage`.
|
|
1183
|
+
*/
|
|
1184
|
+
type ClaimableGesture = 'pointer' | 'doubleClick' | 'contextMenu' | 'longPress' | 'wheel';
|
|
1160
1185
|
|
|
1161
1186
|
/**
|
|
1162
1187
|
* Canvas size in CSS pixels — passed to `draw` for layers that anchor to
|
|
@@ -1235,7 +1260,7 @@ interface RenderLayer<TData> {
|
|
|
1235
1260
|
/** Chrome-caps visibility predicate. When supplied, the layer must
|
|
1236
1261
|
* not return a hit from any chrome element whose id reports
|
|
1237
1262
|
* `false`. Absent → every element is hittable. */
|
|
1238
|
-
isVisible?: (id: string) => boolean) =>
|
|
1263
|
+
isVisible?: (id: string) => boolean) => LayerHit | null;
|
|
1239
1264
|
/**
|
|
1240
1265
|
* Called on every pointermove when no gesture is currently captured.
|
|
1241
1266
|
* Lets layers (e.g. HUD widgets) track hover state without participating
|
|
@@ -1829,17 +1854,28 @@ type ModSpec = Partial<{
|
|
|
1829
1854
|
mod: boolean | 'optional';
|
|
1830
1855
|
shift: boolean | 'optional';
|
|
1831
1856
|
}>;
|
|
1857
|
+
/** The predicate form of {@link TargetSpec}. `hit` is the raw target
|
|
1858
|
+
* (affordance for drag, `e.target` otherwise); `bodyTarget` is the optional
|
|
1859
|
+
* body-class string ('empty' | 'selected-body' | 'unselected-body') when
|
|
1860
|
+
* `classifyTarget` is wired. Predicates that only need one of the two can
|
|
1861
|
+
* ignore the other. */
|
|
1862
|
+
interface TargetPredicate {
|
|
1863
|
+
(hit: unknown, bodyTarget?: string): boolean;
|
|
1864
|
+
/** `false` declares that the predicate reads `bodyTarget` only. An
|
|
1865
|
+
* exclusive affordance claim bars bindings whose target doesn't consult
|
|
1866
|
+
* the hit; a body predicate that declares nothing looks like it does. */
|
|
1867
|
+
readsAffordance?: boolean;
|
|
1868
|
+
}
|
|
1832
1869
|
/** Target selector for click and drag gesture specs. String forms are sugar
|
|
1833
1870
|
* for the kit-owned object-kind registry (TODO.md Tier 1 follow-up); until
|
|
1834
1871
|
* that ships, consumers can pass `{ kindOf: predicate }` to classify hits
|
|
1835
|
-
* themselves.
|
|
1872
|
+
* themselves.
|
|
1873
|
+
*
|
|
1874
|
+
* Adding a form here is a compile error in `parseTargetSpec` until
|
|
1875
|
+
* `TargetSpecForm` grows a matching variant — which is in turn a compile
|
|
1876
|
+
* error at every site that switches on one. */
|
|
1836
1877
|
type TargetSpec = 'empty' | 'selected-body' | 'unselected-body' | `kind:${string}` | `kind:${string}:selected` | `affordance:${string}` | {
|
|
1837
|
-
|
|
1838
|
-
* `e.target` otherwise); `bodyTarget` is the optional body-class
|
|
1839
|
-
* string ('empty' | 'selected-body' | 'unselected-body') when
|
|
1840
|
-
* `classifyTarget` is wired. Predicates that only need one of the
|
|
1841
|
-
* two can ignore the other. */
|
|
1842
|
-
kindOf: (hit: unknown, bodyTarget?: string) => boolean;
|
|
1878
|
+
kindOf: TargetPredicate;
|
|
1843
1879
|
};
|
|
1844
1880
|
/** Phase qualifier on a gesture spec. Restricts when the spec matches based
|
|
1845
1881
|
* on per-tool gesture-lifecycle state.
|
|
@@ -1880,6 +1916,7 @@ interface KeyHeldSpec {
|
|
|
1880
1916
|
interface WheelSpec {
|
|
1881
1917
|
kind: 'wheel';
|
|
1882
1918
|
direction?: 'up' | 'down' | '*';
|
|
1919
|
+
target?: TargetSpec;
|
|
1883
1920
|
mods?: ModSpec;
|
|
1884
1921
|
phase?: PhaseSpec;
|
|
1885
1922
|
}
|
|
@@ -2022,6 +2059,15 @@ interface Point2 {
|
|
|
2022
2059
|
interface AffordanceHit {
|
|
2023
2060
|
/** Discriminator string, e.g. `'handle:bottom-right'`. */
|
|
2024
2061
|
kind: string;
|
|
2062
|
+
/** Id of whatever produced this hit — a kit affordance's `id`, or the
|
|
2063
|
+
* registered layer's id. Read only by the dispatcher's dead-claim warning today. */
|
|
2064
|
+
owner?: string;
|
|
2065
|
+
/** `'exclusive'` means no binding may act on this point unless its target
|
|
2066
|
+
* consults the affordance. `'shared'` (the default) competes on scope and
|
|
2067
|
+
* specificity as bindings always have. */
|
|
2068
|
+
strength?: 'exclusive' | 'shared';
|
|
2069
|
+
/** Which gestures an exclusive claim bars. Omitted bars all of them. */
|
|
2070
|
+
claimedKinds?: readonly ClaimableGesture[];
|
|
2025
2071
|
/** World-space fixed/pivot point. For resize: opposite corner. For rotate: pivot. */
|
|
2026
2072
|
fixedPoint?: {
|
|
2027
2073
|
x: number;
|
|
@@ -2349,6 +2395,20 @@ interface OngoingInvoker {
|
|
|
2349
2395
|
* the `Action` type. */
|
|
2350
2396
|
type Invoker = ImmediateInvoker | OngoingInvoker;
|
|
2351
2397
|
|
|
2398
|
+
/**
|
|
2399
|
+
* GestureBinding — connects a GestureSpec to an Action id (with per-binding
|
|
2400
|
+
* options). Tools own arrays of these on their `bindings` field; ambient
|
|
2401
|
+
* gesture-bindings are registered globally.
|
|
2402
|
+
*
|
|
2403
|
+
* See `docs/superpowers/specs/2026-05-16-registry-unification-design.md`.
|
|
2404
|
+
*/
|
|
2405
|
+
|
|
2406
|
+
interface GestureBinding {
|
|
2407
|
+
spec: GestureSpec;
|
|
2408
|
+
actionId: string;
|
|
2409
|
+
opts?: BindingOpts;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2352
2412
|
/**
|
|
2353
2413
|
* Pose composition for hierarchical scene graphs.
|
|
2354
2414
|
*
|
|
@@ -3311,20 +3371,6 @@ interface DepSchema {
|
|
|
3311
3371
|
*/
|
|
3312
3372
|
type DepName = keyof DepSchema;
|
|
3313
3373
|
|
|
3314
|
-
/**
|
|
3315
|
-
* GestureBinding — connects a GestureSpec to an Action id (with per-binding
|
|
3316
|
-
* options). Tools own arrays of these on their `bindings` field; ambient
|
|
3317
|
-
* gesture-bindings are registered globally.
|
|
3318
|
-
*
|
|
3319
|
-
* See `docs/superpowers/specs/2026-05-16-registry-unification-design.md`.
|
|
3320
|
-
*/
|
|
3321
|
-
|
|
3322
|
-
interface GestureBinding {
|
|
3323
|
-
spec: GestureSpec;
|
|
3324
|
-
actionId: string;
|
|
3325
|
-
opts?: BindingOpts;
|
|
3326
|
-
}
|
|
3327
|
-
|
|
3328
3374
|
type HandleKind = 'corner' | 'rotation' | 'anchor';
|
|
3329
3375
|
type HitShape = {
|
|
3330
3376
|
kind: 'rect';
|
|
@@ -3369,6 +3415,38 @@ interface DebugSink {
|
|
|
3369
3415
|
clearSnap(): void;
|
|
3370
3416
|
}
|
|
3371
3417
|
|
|
3418
|
+
/**
|
|
3419
|
+
* When an entry's bindings are live. A set, not one value: the hand tool is
|
|
3420
|
+
* palette-selectable AND engaged by holding space, and both hold at once.
|
|
3421
|
+
*/
|
|
3422
|
+
interface Eligibility {
|
|
3423
|
+
/** Selectable as the focused entry — exclusive, one at a time. */
|
|
3424
|
+
focus?: boolean;
|
|
3425
|
+
/** Also live while this key is held. */
|
|
3426
|
+
offhand?: HotkeyTrigger;
|
|
3427
|
+
/** Live regardless of what is focused. */
|
|
3428
|
+
always?: boolean;
|
|
3429
|
+
/** Live only for input this entry's own affordances produced. */
|
|
3430
|
+
claimed?: boolean;
|
|
3431
|
+
/** Modality filter, applied wherever it would otherwise be live. */
|
|
3432
|
+
capabilities?: CapabilityTag[];
|
|
3433
|
+
}
|
|
3434
|
+
/**
|
|
3435
|
+
* A registry entry: what it contributes, and when it is eligible. Every role
|
|
3436
|
+
* is optional and independent — an entry that only routes input declares only
|
|
3437
|
+
* `bindings` and `actions`.
|
|
3438
|
+
*/
|
|
3439
|
+
interface Contribution {
|
|
3440
|
+
id: string;
|
|
3441
|
+
eligibility: Eligibility;
|
|
3442
|
+
bindings?: GestureBinding[];
|
|
3443
|
+
actions?: Action[];
|
|
3444
|
+
overlay?: RenderLayer<unknown>;
|
|
3445
|
+
presentation?: ToolPresentation;
|
|
3446
|
+
/** Reflection escape hatch — the authored form, when there was one. */
|
|
3447
|
+
def?: unknown;
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3372
3450
|
/** Modifier-key snapshot at event dispatch time. `space` is included
|
|
3373
3451
|
* because tools commonly use space as a hotkey-slot trigger and may
|
|
3374
3452
|
* also want to read it as a flag mid-gesture. */
|
|
@@ -3418,6 +3496,10 @@ interface ToolCtx<TScratch = unknown> {
|
|
|
3418
3496
|
debug?: DebugSink;
|
|
3419
3497
|
scratch: TScratch;
|
|
3420
3498
|
}
|
|
3499
|
+
/** Hotkey-slot trigger key. The slot is engaged while this key is held —
|
|
3500
|
+
* hence "hotkey": active as long as the key is hot. `null` (or omitted)
|
|
3501
|
+
* means the tool is not eligible for the hotkey slot. */
|
|
3502
|
+
type HotkeyTrigger = 'space' | 'alt' | 'ctrl' | 'meta' | 'shift';
|
|
3421
3503
|
/** World-space AABB shape used by `previewBounds`. Alias of the kit-wide
|
|
3422
3504
|
* `Bounds` type — the optional `rotation` field carries through so a tool
|
|
3423
3505
|
* can report an oriented preview rect (e.g. mid-rotate). */
|
|
@@ -3426,8 +3508,8 @@ type ToolBounds = Bounds;
|
|
|
3426
3508
|
* tool — consumers that render a palette (`<ToolPalette>`) read these
|
|
3427
3509
|
* fields to display the tool; consumers that don't can ignore them.
|
|
3428
3510
|
*
|
|
3429
|
-
* Note: cursor is NOT here.
|
|
3430
|
-
* already plumbed through `<Canvas>` to `style.cursor` on the host. */
|
|
3511
|
+
* Note: cursor is NOT here. `Tool.cursor` (inherited from `Contribution`)
|
|
3512
|
+
* is already plumbed through `<Canvas>` to `style.cursor` on the host. */
|
|
3431
3513
|
interface ToolPresentation<TScratch = unknown> {
|
|
3432
3514
|
/** Human-readable label, distinct from the `id`. Falls back to `id`. */
|
|
3433
3515
|
label?: string;
|
|
@@ -3442,34 +3524,13 @@ interface ToolPresentation<TScratch = unknown> {
|
|
|
3442
3524
|
* derives one from `Tool.keybinding` via its own formatter. */
|
|
3443
3525
|
shortcut?: string;
|
|
3444
3526
|
}
|
|
3445
|
-
/**
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
* strings — apps can define their own. Untagged tools are treated as
|
|
3453
|
-
* ineligible by all modes except those whose `allows` list includes
|
|
3454
|
-
* every implicit-or-declared tag (i.e. `normal` in the default preset).
|
|
3455
|
-
*/
|
|
3456
|
-
capabilities?: CapabilityTag[];
|
|
3457
|
-
/**
|
|
3458
|
-
* Actions this tool owns and needs registered while it is in the tools
|
|
3459
|
-
* registry — e.g. polygon's `polygon.adjustSides`, which its own bindings
|
|
3460
|
-
* reference by id.
|
|
3461
|
-
*
|
|
3462
|
-
* Declared here rather than registered by the hook with `useAction`,
|
|
3463
|
-
* because tool hooks run wherever the consumer calls them — for
|
|
3464
|
-
* `<SceneCanvas>` that is ABOVE `<ActionsProviderIfRoot>`, where
|
|
3465
|
-
* `useActionsRegistry()` returns null and `useAction` silently no-ops. The
|
|
3466
|
-
* result was a binding pointing at an action id nothing had registered, so
|
|
3467
|
-
* the gesture fell through to whatever matched next (polygon's
|
|
3468
|
-
* wheel/arrow-key side adjustment did nothing and `nudge.*` moved the
|
|
3469
|
-
* selection instead). `<ToolActionsMounter>` registers these from inside
|
|
3470
|
-
* the provider.
|
|
3471
|
-
*/
|
|
3472
|
-
actions?: Action[];
|
|
3527
|
+
/**
|
|
3528
|
+
* The focus-declaring case of a `Contribution`: a mode the user switches
|
|
3529
|
+
* into, plus the hooks that only make sense for one (`initScratch`,
|
|
3530
|
+
* activate/deactivate, live preview, `cursor`). Everything else — bindings,
|
|
3531
|
+
* actions, overlay, presentation — is inherited.
|
|
3532
|
+
*/
|
|
3533
|
+
interface Tool<TScratch = unknown> extends Contribution {
|
|
3473
3534
|
/** Optional caller-supplied key. Most built-in tools have their activation
|
|
3474
3535
|
* key declared in `BUILTIN_SELECT_KEYS` in `useKeybindings.ts`; this field
|
|
3475
3536
|
* is for tools that want their activation key to be configurable by the
|
|
@@ -3479,11 +3540,9 @@ interface Tool<TScratch = unknown> {
|
|
|
3479
3540
|
* the invoker knows which tool to switch to). */
|
|
3480
3541
|
keybinding?: ToolKeybinding;
|
|
3481
3542
|
initScratch?: () => TScratch;
|
|
3543
|
+
cursor?: string | ((ctx: ToolCtx<TScratch>) => string);
|
|
3482
3544
|
onActivate?: (ctx: ToolCtx<TScratch>) => void;
|
|
3483
3545
|
onDeactivate?: (ctx: ToolCtx<TScratch>) => void;
|
|
3484
|
-
cursor?: string | ((ctx: ToolCtx<TScratch>) => string);
|
|
3485
|
-
/** Presentation metadata for tool palettes. See `ToolPresentation`. */
|
|
3486
|
-
presentation?: ToolPresentation<TScratch>;
|
|
3487
3546
|
/** Returns the in-flight preview pose for `id` if this tool is mid-gesture
|
|
3488
3547
|
* on it; otherwise `null`. Lets `Canvas.helpersRef.getEffectivePose`
|
|
3489
3548
|
* reflect live gesture state without reaching into hook internals. The
|
|
@@ -3501,26 +3560,6 @@ interface Tool<TScratch = unknown> {
|
|
|
3501
3560
|
* consults this alongside `previewPose` to avoid double-rendering. Returns
|
|
3502
3561
|
* `null` when no gesture is in flight. */
|
|
3503
3562
|
previewIds?: () => Iterable<string> | null;
|
|
3504
|
-
/** Optional overlay layer rendered on top of the scene/chrome whenever
|
|
3505
|
-
* this tool is in any active slot (active, hotkey, or ambient).
|
|
3506
|
-
* The layer's `draw` function reads from this tool's scratch via React
|
|
3507
|
-
* closure (re-evaluated each render). Return early from `draw` to render
|
|
3508
|
-
* nothing — typically gated on a scratch field like
|
|
3509
|
-
* `if (!scratch.overlay) return`. */
|
|
3510
|
-
overlay?: RenderLayer<unknown>;
|
|
3511
|
-
/** Declarative gesture bindings — the tool's entire input surface. The
|
|
3512
|
-
* gesture dispatcher consults these at active scope while this tool is
|
|
3513
|
-
* active, and at hotkey scope while it is held. See
|
|
3514
|
-
* `docs/superpowers/specs/2026-05-16-registry-unification-design.md`. */
|
|
3515
|
-
bindings?: GestureBinding[];
|
|
3516
|
-
/** Reflection escape hatch: when this `Tool` was produced by `defineTool`,
|
|
3517
|
-
* the source `ToolDef` is attached here so introspection consumers
|
|
3518
|
-
* (`buildRouteRegistry`, `findConflicts`, the toolkit-builder UI, the
|
|
3519
|
-
* reflection demo) can read the authored form — `hookName` in particular,
|
|
3520
|
-
* which the runtime `Tool` doesn't carry. Tools constructed without
|
|
3521
|
-
* `defineTool` may leave this undefined. Typed as `unknown` to keep this
|
|
3522
|
-
* file from importing the routing types — consumers cast at the use site. */
|
|
3523
|
-
def?: unknown;
|
|
3524
3563
|
}
|
|
3525
3564
|
/** Internal alias for "a Tool of any scratch type" — used in registries and
|
|
3526
3565
|
* dispatchers that hold tools of heterogeneous scratch shapes. `any` is
|
|
@@ -4400,6 +4439,57 @@ interface ReorderDragHandlers {
|
|
|
4400
4439
|
}
|
|
4401
4440
|
declare function useReorderDragList(opts: UseReorderDragListOptions): ReorderDragHandlers;
|
|
4402
4441
|
|
|
4442
|
+
/** The only thing the hook needs to know about a bar's items: which are
|
|
4443
|
+
* skipped by arrow navigation. */
|
|
4444
|
+
type RovingItem = {
|
|
4445
|
+
disabled?: boolean;
|
|
4446
|
+
};
|
|
4447
|
+
type UseRovingTabIndexOptions = {
|
|
4448
|
+
/** In the same order as the elements carrying `itemClassName`. */
|
|
4449
|
+
items: readonly RovingItem[];
|
|
4450
|
+
/** Class on the focusable element of each item, inside the container the
|
|
4451
|
+
* returned `rootRef` is attached to. Their DOM order must match `items`. */
|
|
4452
|
+
itemClassName: string;
|
|
4453
|
+
/** Index that carries `tabIndex=0`. Defaults to the first enabled item; a
|
|
4454
|
+
* radiogroup-style bar passes its selected index so Tab lands on the
|
|
4455
|
+
* current value. */
|
|
4456
|
+
tabStopIndex?: number;
|
|
4457
|
+
/** Called with the new index as arrow/Home/End focus moves, before focus
|
|
4458
|
+
* moves. This is where a selection-follows-focus bar commits the value. */
|
|
4459
|
+
onNavigate?: (index: number) => void;
|
|
4460
|
+
/** Space/Enter on the item at `index`. When omitted the keypress is left
|
|
4461
|
+
* alone, which on a native `<button>` produces an ordinary click. */
|
|
4462
|
+
onActivate?: (index: number) => void;
|
|
4463
|
+
};
|
|
4464
|
+
type RovingTabIndex<T extends HTMLElement = HTMLDivElement> = {
|
|
4465
|
+
/** Attach to the container element that holds the items. */
|
|
4466
|
+
rootRef: RefObject<T | null>;
|
|
4467
|
+
/** `tabIndex` value for the item at `index`. */
|
|
4468
|
+
tabIndexFor: (index: number) => 0 | -1;
|
|
4469
|
+
/** `onKeyDown` for the item at `index`. */
|
|
4470
|
+
onKeyDown: (index: number) => (e: KeyboardEvent<HTMLElement>) => void;
|
|
4471
|
+
};
|
|
4472
|
+
/**
|
|
4473
|
+
* Roving tabindex for a bar of items: one item is in the tab order, and the
|
|
4474
|
+
* arrow keys move focus among the rest, skipping disabled ones and wrapping
|
|
4475
|
+
* at both ends. Home and End go to the first and last enabled item. Both axes
|
|
4476
|
+
* navigate, so the same bar works laid out either way.
|
|
4477
|
+
*
|
|
4478
|
+
* Backs `ActionsBar`, `OptionsBar`, and `ToggleBar`.
|
|
4479
|
+
*
|
|
4480
|
+
* **When a bar should not use this.** Only when the bar owns its items. A
|
|
4481
|
+
* container of arbitrary compound controls — a number field, a select, a
|
|
4482
|
+
* color field — must leave the arrow keys alone, because those controls edit
|
|
4483
|
+
* their own value with them; taking the arrows over would break the control
|
|
4484
|
+
* to navigate between controls. `ToolOptionsBar` is that case and keeps plain
|
|
4485
|
+
* DOM tab order. A bar whose items are all simple buttons is the case this
|
|
4486
|
+
* hook is for.
|
|
4487
|
+
*
|
|
4488
|
+
* With every item disabled there is no tab stop and the bar drops out of the
|
|
4489
|
+
* tab order entirely.
|
|
4490
|
+
*/
|
|
4491
|
+
declare function useRovingTabIndex<T extends HTMLElement = HTMLDivElement>(options: UseRovingTabIndexOptions): RovingTabIndex<T>;
|
|
4492
|
+
|
|
4403
4493
|
/**
|
|
4404
4494
|
* Display-formatter for numbers. Use this anywhere a number is shown to
|
|
4405
4495
|
* a user. The whole point: negative values get prefixed with the real
|
|
@@ -4413,5 +4503,5 @@ declare function useReorderDragList(opts: UseReorderDragListOptions): ReorderDra
|
|
|
4413
4503
|
declare const MINUS_SIGN = "\u2212";
|
|
4414
4504
|
declare function formatNumber(value: number, options?: Intl.NumberFormatOptions): string;
|
|
4415
4505
|
|
|
4416
|
-
export { ActionBar, ActionsBar, Badge, Button, Checkbox, ComboBox, ComboBoxItem, CurveEditor, DataGrid, Dialog, EDGE_PROFILES, Field, Input, KeyCap, KeySequence, MINUS_SIGN, NumberField, OptionsBar, Plot2D, PointPlotter, Powerline, Radio, RadioGroup, RangeSlider, Select, SelectItem, Sidebar, SidebarPanel, Slider, Switch, Tab, TabList, TabPanel, Tabs, ToggleBar, ToolButton, ToolGroup, ToolPalette, chromaAt, detectPlatform, dlog, fieldClasses, formatNumber, formatShortcut, formatShortcutParts, inferKeycapKind, isDebugEnabled, keyGlyph, keySpecFromKey, keySpecsFromMods, oklchToHex, paintGradientTrack, useReorderDragList };
|
|
4417
|
-
export type { ActionBarProps, ActionsBarItem, ActionsBarProps, ActionsBarSize, ActionsBarVariant, AddPointMode, AnchorRenderProps, AxesSettings, BadgeProps, BadgeShape, BadgeSize, BadgeTone, BadgeVariant, BoundsCtx, BuiltInEdgeName, ButtonProps, ButtonSize, ButtonVariant, CheckboxProps, ChromaCurve, ChromaCurvePoint, ComboBoxItemProps, ComboBoxOption, ComboBoxProps, ControlPoint, CurveDomain, CurveEditorProps, DataGridColumn, DataGridProps, DialogProps, EdgeCap, EdgeProfile, EndpointMode, FieldOrientation, FieldProps, FillSettings, GradientTrackOpts, GridSettings, InputProps, InterpolationMode, KeyCapProps, KeyCapVariant, KeySequenceProps, KeySpec$1 as KeySpec, KeycapKind, LayerListItem, LogicalMod, LogicalModSpec, NumberFieldProps, OptionsBarItem, OptionsBarProps, OptionsBarSize, OptionsBarVariant, Platform, Plot2DCoords, Plot2DHandle, Plot2DProps, PointPlotterProps, PowerlineProps, PowerlineSegment, RadioGroupProps, RadioProps, RangeSliderProps, ReorderDragHandlers, ReorderDragState, SelectItemProps, SelectOption, SelectProps, SidebarPanelProps, SidebarProps, SliderProps, SwitchProps, TabListProps, TabPanelProps, TabProps, TabsProps, Thumb, ThumbRenderCtx, ThumbShape, ToggleBarItem, ToggleBarProps, ToggleBarSize, ToggleBarVariant, ToolButtonProps, ToolGroupProps, ToolPaletteProps, TrackCtx, UseReorderDragListOptions };
|
|
4506
|
+
export { ActionBar, ActionsBar, Badge, Button, Checkbox, ComboBox, ComboBoxItem, CurveEditor, DataGrid, Dialog, EDGE_PROFILES, Field, Input, KeyCap, KeySequence, MINUS_SIGN, NumberField, OptionsBar, Plot2D, PointPlotter, Powerline, Radio, RadioGroup, RangeSlider, Select, SelectItem, Sidebar, SidebarPanel, Slider, Switch, Tab, TabList, TabPanel, Tabs, ToggleBar, ToolButton, ToolGroup, ToolPalette, chromaAt, detectPlatform, dlog, fieldClasses, formatNumber, formatShortcut, formatShortcutParts, inferKeycapKind, isDebugEnabled, keyGlyph, keySpecFromKey, keySpecsFromMods, oklchToHex, paintGradientTrack, useReorderDragList, useRovingTabIndex };
|
|
4507
|
+
export type { ActionBarProps, ActionsBarItem, ActionsBarProps, ActionsBarSize, ActionsBarVariant, AddPointMode, AnchorRenderProps, AxesSettings, BadgeProps, BadgeShape, BadgeSize, BadgeTone, BadgeVariant, BoundsCtx, BuiltInEdgeName, ButtonProps, ButtonSize, ButtonVariant, CheckboxProps, ChromaCurve, ChromaCurvePoint, ComboBoxItemProps, ComboBoxOption, ComboBoxProps, ControlPoint, CurveDomain, CurveEditorProps, DataGridColumn, DataGridProps, DialogProps, EdgeCap, EdgeProfile, EndpointMode, FieldOrientation, FieldProps, FillSettings, GradientTrackOpts, GridSettings, InputProps, InterpolationMode, KeyCapProps, KeyCapVariant, KeySequenceProps, KeySpec$1 as KeySpec, KeycapKind, LayerListItem, LogicalMod, LogicalModSpec, NumberFieldProps, OptionsBarItem, OptionsBarProps, OptionsBarSize, OptionsBarVariant, Platform, Plot2DCoords, Plot2DHandle, Plot2DProps, PointPlotterProps, PowerlineProps, PowerlineSegment, RadioGroupProps, RadioProps, RangeSliderProps, ReorderDragHandlers, ReorderDragState, RovingItem, RovingTabIndex, SelectItemProps, SelectOption, SelectProps, SidebarPanelProps, SidebarProps, SliderProps, SwitchProps, TabListProps, TabPanelProps, TabProps, TabsProps, Thumb, ThumbRenderCtx, ThumbShape, ToggleBarItem, ToggleBarProps, ToggleBarSize, ToggleBarVariant, ToolButtonProps, ToolGroupProps, ToolPaletteProps, TrackCtx, UseReorderDragListOptions, UseRovingTabIndexOptions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { m as ActionBar,
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { m as ActionBar, r3 as ActionsBar, Ft as Badge, a as Button, o3 as Checkbox, p4 as ComboBox, m2 as ComboBoxItem, F as CurveEditor, l as DataGrid, c2 as Dialog, qe as EDGE_PROFILES, n as Field, u2 as Input, s2 as KeyCap, c as KeySequence, a2 as MINUS_SIGN, f3 as NumberField, r2 as OptionsBar, _ as Plot2D, n4 as PointPlotter, r4 as Powerline, u3 as Radio, l2 as RadioGroup, l3 as RangeSlider, p3 as Select, h as SelectItem, n2 as Sidebar, o4 as SidebarPanel, f2 as Slider, a4 as Switch, c3 as Tab, s3 as TabList, l4 as TabPanel, o6 as Tabs, r as ToggleBar, o5 as ToolButton, n3 as ToolGroup, _2 as ToolPalette, ze as chromaAt, u as detectPlatform, p as dlog, r5 as fieldClasses, o2 as formatNumber, d2 as formatShortcut, u4 as formatShortcutParts, o as inferKeycapKind, f as isDebugEnabled, e as keyGlyph, p2 as keySpecFromKey, d as keySpecsFromMods, Re as oklchToHex, p5 as paintGradientTrack, s as useReorderDragList, a3 as useRovingTabIndex } from '../chunk-NRD3TDNQ.js';
|
|
2
|
+
import '../chunk-ISEK5LXT.js';
|
|
3
3
|
//# sourceMappingURL=weasel-ui.js.map
|
|
4
4
|
//# sourceMappingURL=weasel-ui.js.map
|
package/dist/state/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as InstrumentSerializers, W as WorkspaceRecord, U as UndoStack, S as StorageAdapter } from '../_dts/useExperimentState-
|
|
2
|
-
export { C as CreateLabStoreOptions, E as ExperimentStateHandle, L as LabStore, a as LabStoreActions, b as LabStoreContext, c as LabStoreProvider, d as LabStoreState, e as SavedSnapshot, f as WorkspaceIdContext, g as WorkspaceIdProvider, h as createLabStore, i as createMemoryAdapter, l as localStorageAdapter, n as noneAdapter, s as sessionStorageAdapter, u as urlHashAdapter, j as useExperimentState, k as useLabStore, m as useWorkspaceId } from '../_dts/useExperimentState-
|
|
1
|
+
import { I as InstrumentSerializers, W as WorkspaceRecord, U as UndoStack, S as StorageAdapter } from '../_dts/useExperimentState-CJn2hHzd.js';
|
|
2
|
+
export { C as CreateLabStoreOptions, E as ExperimentStateHandle, L as LabStore, a as LabStoreActions, b as LabStoreContext, c as LabStoreProvider, d as LabStoreState, e as SavedSnapshot, f as WorkspaceIdContext, g as WorkspaceIdProvider, h as createLabStore, i as createMemoryAdapter, l as localStorageAdapter, n as noneAdapter, s as sessionStorageAdapter, u as urlHashAdapter, j as useExperimentState, k as useLabStore, m as useWorkspaceId } from '../_dts/useExperimentState-CJn2hHzd.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { ReactNode } from 'react';
|
|
5
5
|
import 'zustand/vanilla';
|
package/dist/state/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createLabStore, LabStoreProvider, WorkspaceIdProvider } from '../chunk-
|
|
2
|
-
export { LabStoreContext, LabStoreProvider, WorkspaceIdContext, WorkspaceIdProvider, createLabStore, createMemoryAdapter, decodeUrlHash, deserializeWorkspaces, emptyUndoStack, encodeUrlHash, labStorageKey, localStorageAdapter, noneAdapter, serializeWorkspaces, sessionStorageAdapter, urlHashAdapter, useExperimentState, useLabStore, useWorkspaceId } from '../chunk-
|
|
1
|
+
import { createLabStore, LabStoreProvider, WorkspaceIdProvider } from '../chunk-53XSBIUK.js';
|
|
2
|
+
export { LabStoreContext, LabStoreProvider, WorkspaceIdContext, WorkspaceIdProvider, createLabStore, createMemoryAdapter, decodeUrlHash, deserializeWorkspaces, emptyUndoStack, encodeUrlHash, labStorageKey, localStorageAdapter, noneAdapter, serializeWorkspaces, sessionStorageAdapter, urlHashAdapter, useExperimentState, useLabStore, useWorkspaceId } from '../chunk-53XSBIUK.js';
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
|