@weasel-js/routing 1.10.1 → 1.11.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/dist/{chunk-VCEIQ64H.js → chunk-KLBH7VFF.js} +740 -87
- package/dist/chunk-KLBH7VFF.js.map +1 -0
- package/dist/{index-DkOqUxow.d.ts → index-Cb7ehEks.d.ts} +1689 -1177
- package/dist/index.d.ts +6 -3
- package/dist/index.js +85 -17
- package/dist/index.js.map +1 -1
- package/dist/{internal-Boc2I3zn.d.ts → internal-Dcyz_cJv.d.ts} +31 -1
- package/dist/internal.d.ts +8 -5
- package/dist/react.d.ts +61 -29
- package/dist/react.js +467 -232
- package/dist/react.js.map +1 -1
- package/package.json +13 -9
- package/dist/chunk-VCEIQ64H.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { U as UseGestureDispatcherOptions } from './internal-
|
|
2
|
-
export { D as DispatcherChannels } from './internal-
|
|
1
|
+
import { U as UseGestureDispatcherOptions } from './internal-Dcyz_cJv.js';
|
|
2
|
+
export { D as DispatcherChannels } from './internal-Dcyz_cJv.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import { ReactNode, ReactElement } from 'react';
|
|
5
|
-
import { D as DepRegistry, a as DepName, b as
|
|
6
|
-
export {
|
|
5
|
+
import { D as DepRegistry, a as DepName, b as DepSource, S as ScopeNode, A as Action, c as ActionDeps, M as MenuHost, d as ActionsRegistry, e as ActionDisabledReason, B as BoundGesture, f as ActionVariant, g as MenuDef, h as DepNode, T as ToolNode, N as NodeId, K as KernelOverlay, C as Contribution, i as Tool, O as OverlayPosition } from './index-Cb7ehEks.js';
|
|
6
|
+
export { j as ActiveToolContextProvider, k as ActiveToolContextProviderIfRoot, l as ActiveToolContextProviderProps, m as ActiveToolContextValue, u as useActiveToolContext, n as useOptionalActiveToolContext } from './index-Cb7ehEks.js';
|
|
7
|
+
import { IconRef } from '@weasel-js/icons';
|
|
7
8
|
import { ModeRegistry } from '@weasel-js/modes';
|
|
8
9
|
import '@weasel-js/gestures';
|
|
9
10
|
import '@weasel-js/cursor';
|
|
10
11
|
import '@weasel-js/geom';
|
|
12
|
+
import '@weasel-js/menu';
|
|
13
|
+
import '@weasel-js/prefs';
|
|
11
14
|
import '@weasel-js/registry';
|
|
12
15
|
import '@weasel-js/select';
|
|
13
16
|
|
|
@@ -36,8 +39,8 @@ declare function useDepRegistry(): DepRegistry;
|
|
|
36
39
|
declare function useOptionalDepRegistry(): DepRegistry | null;
|
|
37
40
|
/** Register a live source for `name` for the lifetime of the calling
|
|
38
41
|
* component. The `source` thunk is called at dispatch time and should
|
|
39
|
-
* return the latest value. */
|
|
40
|
-
declare function useDepSource<K extends DepName>(name: K, source:
|
|
42
|
+
* return the latest value; its `below` reads the source it displaced. */
|
|
43
|
+
declare function useDepSource<K extends DepName>(name: K, source: DepSource<K>): void;
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
* One node of the actions tree: the actions registered at it, over its
|
|
@@ -52,20 +55,31 @@ declare class ActionsNode extends ScopeNode<ActionsNode> {
|
|
|
52
55
|
private readonly tunings;
|
|
53
56
|
private readonly dispatchers;
|
|
54
57
|
private cache;
|
|
58
|
+
private host;
|
|
55
59
|
/** Called on `activate`, so a scope's dep and tool nodes move with it. */
|
|
56
60
|
readonly onActivate: (() => void)[];
|
|
57
61
|
constructor(parent: ActionsNode | null, descends: boolean, contextDeps: () => DepRegistry | null);
|
|
58
62
|
private resolve;
|
|
63
|
+
/** Every tuning for `id` from the root down to here, root first. */
|
|
64
|
+
private tuningsOf;
|
|
59
65
|
/** `a` under every tuning for its id from the root down to here. */
|
|
60
66
|
private tuned;
|
|
61
67
|
private snapshot;
|
|
62
68
|
private deps;
|
|
69
|
+
/** The actions registered at this node itself, live, unmuted and tuned —
|
|
70
|
+
* none from the scopes below it. */
|
|
71
|
+
ownActions(): readonly Action[];
|
|
72
|
+
/** The deps `a` is invoked with from here: the active scope's, which is
|
|
73
|
+
* what `trigger` and `begin` run it with. */
|
|
74
|
+
depsOf(a: Action): ActionDeps;
|
|
75
|
+
/** The menu host of this node's tree, made by its root on first ask. Rows
|
|
76
|
+
* resolve and run against the active scope, as chrome's `trigger` does. */
|
|
77
|
+
menuHost(): MenuHost;
|
|
63
78
|
private dispatcher;
|
|
64
79
|
activate(): void;
|
|
65
80
|
readonly registry: ActionsRegistry;
|
|
66
81
|
}
|
|
67
82
|
/**
|
|
68
|
-
* @experimental
|
|
69
83
|
* Mounts a root `ActionsRegistry` for its lifetime. Children call
|
|
70
84
|
* `useActionsRegistry()` or `useAction()` to participate. Mounts no input
|
|
71
85
|
* listener of its own — the gesture dispatcher owns input.
|
|
@@ -74,12 +88,10 @@ declare function ActionsProvider({ children }: {
|
|
|
74
88
|
children: ReactNode;
|
|
75
89
|
}): ReactElement;
|
|
76
90
|
/**
|
|
77
|
-
* @experimental
|
|
78
91
|
* Returns the `ActionsRegistry` in scope, or `null` when there is none.
|
|
79
92
|
*/
|
|
80
93
|
declare function useActionsRegistry(): ActionsRegistry | null;
|
|
81
94
|
/**
|
|
82
|
-
* @experimental
|
|
83
95
|
* Register an `Action` for the lifetime of the calling component. No-op (with
|
|
84
96
|
* a dev-only warning) when no `ActionsProvider` is in scope. Re-registers on
|
|
85
97
|
* `action` reference change (consumers should memoize stable identities to
|
|
@@ -87,8 +99,37 @@ declare function useActionsRegistry(): ActionsRegistry | null;
|
|
|
87
99
|
*/
|
|
88
100
|
declare function useAction(action: Action): void;
|
|
89
101
|
|
|
102
|
+
/** What a command offers besides its id, label and callback. */
|
|
103
|
+
interface CommandOptions {
|
|
104
|
+
/** True when the command can run, else why not. Read each time it is asked. */
|
|
105
|
+
enabled?: () => true | ActionDisabledReason;
|
|
106
|
+
/** Whether it reads as held down. Read each time it is asked. */
|
|
107
|
+
active?: () => boolean;
|
|
108
|
+
/** The gestures that run it. The `{ spec, opts: { params } }` form gives one variant its own key. */
|
|
109
|
+
keys?: BoundGesture | readonly BoundGesture[];
|
|
110
|
+
/** Shown beside the label. */
|
|
111
|
+
icon?: IconRef;
|
|
112
|
+
/** Words a palette finds it by and a tagged bar or menu gathers it under. */
|
|
113
|
+
tags?: readonly string[];
|
|
114
|
+
/** One entry each in a bar, menu or palette; `run` receives the chosen one's params. */
|
|
115
|
+
variants?: readonly ActionVariant[];
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Register `run` as an action under `id` on the nearest `<ActionsProvider>`
|
|
119
|
+
* for the calling component's lifetime, so a menu, toolbar, palette or key
|
|
120
|
+
* can run it. Callbacks and option functions may be new on every render: the
|
|
121
|
+
* latest are read when used, and the action is replaced only when `id`,
|
|
122
|
+
* `label`, `icon`, `keys`, `tags` or `variants` change by value.
|
|
123
|
+
*/
|
|
124
|
+
declare function useCommand(id: string, label: string, run: (params?: Readonly<Record<string, unknown>>) => void, options?: CommandOptions): void;
|
|
125
|
+
|
|
126
|
+
/** The menu host in scope: the nearest `<ActionsProvider>`'s, else the one a
|
|
127
|
+
* canvas with no provider above it makes. Null outside both. */
|
|
128
|
+
declare function useMenuHost(): MenuHost | null;
|
|
129
|
+
/** Declare menus for the calling component's lifetime. Memoize `defs`. */
|
|
130
|
+
declare function useMenus(defs: readonly MenuDef[], owner?: string | null): void;
|
|
131
|
+
|
|
90
132
|
/**
|
|
91
|
-
* @experimental
|
|
92
133
|
* Input scopes and yokes: the tiers between a root registry and a canvas.
|
|
93
134
|
*/
|
|
94
135
|
|
|
@@ -100,21 +141,20 @@ interface InputScopeProps {
|
|
|
100
141
|
children: ReactNode;
|
|
101
142
|
}
|
|
102
143
|
/**
|
|
103
|
-
* @experimental
|
|
104
144
|
* One canvas's input: actions, deps and a tool of its own, under whichever
|
|
105
145
|
* registries are in scope (or its yoke's). What the canvas registers stays
|
|
106
146
|
* here; what it looks up is answered here first, then by the tiers above.
|
|
107
|
-
* With nothing in scope it is a root
|
|
147
|
+
* With nothing in scope it is a root, and makes the menu host
|
|
148
|
+
* `<ActionsProvider>` would have.
|
|
108
149
|
*
|
|
109
150
|
* Chrome above calls `trigger` / `begin` / `useActiveToolContext` on its own
|
|
110
151
|
* registries, and those reach the active scope: the one last activated — by a
|
|
111
|
-
* pointerdown or
|
|
152
|
+
* pointerdown, wheel or contextmenu — or the newest where none has been. Keys are stricter:
|
|
112
153
|
* one that reaches the page goes to the canvas last pressed or scrolled in,
|
|
113
154
|
* across every root on the page, and to none before the first.
|
|
114
155
|
*/
|
|
115
156
|
declare function InputScope({ yoke, children }: InputScopeProps): ReactElement;
|
|
116
157
|
/**
|
|
117
|
-
* @experimental
|
|
118
158
|
* Make a yoke for canvases to join, under the registries in scope where it is
|
|
119
159
|
* called. It lives as long as the calling component.
|
|
120
160
|
*/
|
|
@@ -125,7 +165,6 @@ interface YokeProps {
|
|
|
125
165
|
children: ReactNode;
|
|
126
166
|
}
|
|
127
167
|
/**
|
|
128
|
-
* @experimental
|
|
129
168
|
* Canvases that share input on purpose: the active tool, the gesture in
|
|
130
169
|
* flight, history, and yoke-wide actions. Made once with `useYoke()`, and
|
|
131
170
|
* passed to each canvas that joins it (`yoke={yoke}`) and to
|
|
@@ -141,7 +180,6 @@ interface Yoke {
|
|
|
141
180
|
readonly tools: ToolNode;
|
|
142
181
|
}
|
|
143
182
|
/**
|
|
144
|
-
* @experimental
|
|
145
183
|
* Put `value` in scope for what is not a canvas — a toolbar, a status bar — so
|
|
146
184
|
* its actions, deps and tool reads reach the yoke and, through it, the member
|
|
147
185
|
* canvas last used.
|
|
@@ -182,7 +220,7 @@ interface OngoingAction {
|
|
|
182
220
|
*/
|
|
183
221
|
declare function useOngoingAction(actionId: string): OngoingAction;
|
|
184
222
|
|
|
185
|
-
/**
|
|
223
|
+
/** World-space pointer position and the view it is over — a
|
|
186
224
|
* view id, or `null` for a surface's own camera. `null` as a whole when the
|
|
187
225
|
* pointer is over no publishing surface. */
|
|
188
226
|
type PointerWorldPos = {
|
|
@@ -190,7 +228,7 @@ type PointerWorldPos = {
|
|
|
190
228
|
worldY: number;
|
|
191
229
|
viewId: string | null;
|
|
192
230
|
} | null;
|
|
193
|
-
/**
|
|
231
|
+
/** A pointer store: the latest position, a way to publish one, and change notification. */
|
|
194
232
|
interface PointerContextValue {
|
|
195
233
|
/** The latest position. */
|
|
196
234
|
get(): PointerWorldPos;
|
|
@@ -203,10 +241,9 @@ interface PointerContextValue {
|
|
|
203
241
|
/** `get()` as a stable thunk, for hooks taking a drop-point option. */
|
|
204
242
|
readonly getDropPoint: () => PointerWorldPos;
|
|
205
243
|
}
|
|
206
|
-
/**
|
|
244
|
+
/** A pointer store with no provider around it. */
|
|
207
245
|
declare function createPointerStore(): PointerContextValue;
|
|
208
246
|
/**
|
|
209
|
-
* @experimental
|
|
210
247
|
* Wrap the part of the React tree that should share one pointer.
|
|
211
248
|
* `<SceneCanvas>` mounts one when none is in scope, so mount it yourself only
|
|
212
249
|
* when two surfaces should share a pointer. Pass `store` to publish into one
|
|
@@ -216,15 +253,14 @@ declare function PointerContextProvider({ children, store }: {
|
|
|
216
253
|
children: ReactNode;
|
|
217
254
|
store?: PointerContextValue;
|
|
218
255
|
}): ReactNode;
|
|
219
|
-
/**
|
|
256
|
+
/** The surrounding pointer store, or `null` when no provider is
|
|
220
257
|
* in scope. */
|
|
221
258
|
declare function usePointerContext(): PointerContextValue | null;
|
|
222
|
-
/**
|
|
259
|
+
/** The pointer, re-rendering the caller whenever it changes.
|
|
223
260
|
* `null` outside a provider. */
|
|
224
261
|
declare function usePointerPosition(): PointerWorldPos;
|
|
225
262
|
|
|
226
263
|
/**
|
|
227
|
-
* @experimental
|
|
228
264
|
* SelectionContext — an ambient context that publishes "what's currently
|
|
229
265
|
* selected" so non-canvas UI (command palette, status bar) can read it without
|
|
230
266
|
* threading a selection prop through the tree.
|
|
@@ -234,7 +270,7 @@ declare function usePointerPosition(): PointerWorldPos;
|
|
|
234
270
|
* last-writer-wins. `<SceneCanvas>` publishes automatically.
|
|
235
271
|
*/
|
|
236
272
|
|
|
237
|
-
/**
|
|
273
|
+
/** The ambient selection store a canvas publishes into and non-canvas UI reads. */
|
|
238
274
|
interface SelectionContextValue {
|
|
239
275
|
/** The most-recently-published selection. Empty array when no canvas
|
|
240
276
|
* has published or when the active canvas's selection is empty. */
|
|
@@ -248,7 +284,6 @@ interface SelectionContextValue {
|
|
|
248
284
|
publishSelection(ids: readonly NodeId[], kinds?: readonly (string | undefined)[]): void;
|
|
249
285
|
}
|
|
250
286
|
/**
|
|
251
|
-
* @experimental
|
|
252
287
|
* Wrap the part of the React tree that should share a selection context.
|
|
253
288
|
* Usually placed at the demo / app root, alongside `<ActionsProvider>`.
|
|
254
289
|
*/
|
|
@@ -256,13 +291,11 @@ declare function SelectionContextProvider({ children }: {
|
|
|
256
291
|
children: ReactNode;
|
|
257
292
|
}): ReactNode;
|
|
258
293
|
/**
|
|
259
|
-
* @experimental
|
|
260
294
|
* The current selection-context value, or `null` when no
|
|
261
295
|
* `<SelectionContextProvider>` is in scope.
|
|
262
296
|
*/
|
|
263
297
|
declare function useSelectionContext(): SelectionContextValue | null;
|
|
264
298
|
/**
|
|
265
|
-
* @experimental
|
|
266
299
|
* Mounts a `<SelectionContextProvider>` only when no parent provider is in
|
|
267
300
|
* scope; otherwise renders children unwrapped.
|
|
268
301
|
*/
|
|
@@ -270,7 +303,6 @@ declare function SelectionContextProviderIfRoot({ children, }: {
|
|
|
270
303
|
children: ReactNode;
|
|
271
304
|
}): ReactNode;
|
|
272
305
|
/**
|
|
273
|
-
* @experimental
|
|
274
306
|
* Publishes `ids` into the surrounding `<SelectionContextProvider>` whenever
|
|
275
307
|
* their content changes, and clears the slot on unmount unless another
|
|
276
308
|
* publisher has written it since. No-op when there's no provider in scope.
|
|
@@ -380,4 +412,4 @@ declare function useContributions<TOverlay = KernelOverlay>(opts: UseContributio
|
|
|
380
412
|
*/
|
|
381
413
|
declare function useOffhandAction(entries: readonly Contribution<unknown>[]): void;
|
|
382
414
|
|
|
383
|
-
export { ActionsProvider, type ContributionsApi, DepRegistry, DepRegistryProvider, InputScope, type InputScopeProps, type OngoingAction, PointerContextProvider, type PointerContextValue, type PointerWorldPos, SelectionContextProvider, SelectionContextProviderIfRoot, type SelectionContextValue, type ToolsApi, type UseContributionsOptions, UseGestureDispatcherOptions, type UseToolsOptions, Yoke, type YokeProps, createPointerStore, useAction, useActionsRegistry, useContributions, useDepRegistry, useDepSource, useGestureDispatcher, useOffhandAction, useOngoingAction, useOptionalDepRegistry, usePointerContext, usePointerPosition, usePublishSelection, useSelectionContext, useTools, useYoke };
|
|
415
|
+
export { ActionsProvider, type CommandOptions, type ContributionsApi, DepRegistry, DepRegistryProvider, InputScope, type InputScopeProps, type OngoingAction, PointerContextProvider, type PointerContextValue, type PointerWorldPos, SelectionContextProvider, SelectionContextProviderIfRoot, type SelectionContextValue, type ToolsApi, type UseContributionsOptions, UseGestureDispatcherOptions, type UseToolsOptions, Yoke, type YokeProps, createPointerStore, useAction, useActionsRegistry, useCommand, useContributions, useDepRegistry, useDepSource, useGestureDispatcher, useMenuHost, useMenus, useOffhandAction, useOngoingAction, useOptionalDepRegistry, usePointerContext, usePointerPosition, usePublishSelection, useSelectionContext, useTools, useYoke };
|