@weasel-js/routing 1.9.4 → 1.10.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-Y5RURZBH.js → chunk-VCEIQ64H.js} +1017 -851
- package/dist/chunk-VCEIQ64H.js.map +1 -0
- package/dist/{index-gArM2tbt.d.ts → index-DkOqUxow.d.ts} +370 -596
- package/dist/index.d.ts +3 -3
- package/dist/index.js +16 -64
- package/dist/index.js.map +1 -1
- package/dist/{internal-B0SsznMG.d.ts → internal-Boc2I3zn.d.ts} +38 -67
- package/dist/internal.d.ts +4 -4
- package/dist/react.d.ts +123 -34
- package/dist/react.js +688 -751
- package/dist/react.js.map +1 -1
- package/package.json +9 -8
- package/dist/chunk-Y5RURZBH.js.map +0 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
import { U as UseGestureDispatcherOptions } from './internal-
|
|
2
|
-
export { D as DispatcherChannels } from './internal-
|
|
1
|
+
import { U as UseGestureDispatcherOptions } from './internal-Boc2I3zn.js';
|
|
2
|
+
export { D as DispatcherChannels } from './internal-Boc2I3zn.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 DepSchema, S as ScopeNode, A as ActionsRegistry, c as Action, d as DepNode, T as ToolNode, K as KernelOverlay, C as Contribution, e as
|
|
6
|
-
export { f as ActiveToolContextProvider, g as ActiveToolContextProviderIfRoot, h as ActiveToolContextProviderProps, i as ActiveToolContextValue, u as useActiveToolContext, j as useOptionalActiveToolContext } from './index-
|
|
5
|
+
import { D as DepRegistry, a as DepName, b as DepSchema, S as ScopeNode, A as ActionsRegistry, c as Action, d as DepNode, T as ToolNode, N as NodeId, K as KernelOverlay, C as Contribution, e as Tool, O as OverlayPosition } from './index-DkOqUxow.js';
|
|
6
|
+
export { f as ActiveToolContextProvider, g as ActiveToolContextProviderIfRoot, h as ActiveToolContextProviderProps, i as ActiveToolContextValue, u as useActiveToolContext, j as useOptionalActiveToolContext } from './index-DkOqUxow.js';
|
|
7
7
|
import { ModeRegistry } from '@weasel-js/modes';
|
|
8
8
|
import '@weasel-js/gestures';
|
|
9
9
|
import '@weasel-js/cursor';
|
|
10
10
|
import '@weasel-js/geom';
|
|
11
|
-
import '@weasel-js/
|
|
11
|
+
import '@weasel-js/registry';
|
|
12
12
|
import '@weasel-js/select';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Attach the input pipeline to a canvas: DOM pointer, wheel, keyboard and
|
|
15
|
+
* Attach the input pipeline to a canvas: DOM pointer, wheel, keyboard, and
|
|
16
16
|
* multitouch listeners in, normalized input events out, routed through the
|
|
17
17
|
* dispatcher to whichever action a binding names.
|
|
18
18
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* providers.
|
|
19
|
+
* The active tool and the dep registry come from context, so it must be
|
|
20
|
+
* mounted inside `<SceneCanvas>`'s providers.
|
|
22
21
|
*/
|
|
23
22
|
declare function useGestureDispatcher(opts: UseGestureDispatcherOptions): void;
|
|
24
23
|
|
|
@@ -50,12 +49,15 @@ declare class ActionsNode extends ScopeNode<ActionsNode> {
|
|
|
50
49
|
private readonly contextDeps;
|
|
51
50
|
private readonly actions;
|
|
52
51
|
private readonly muted;
|
|
52
|
+
private readonly tunings;
|
|
53
53
|
private readonly dispatchers;
|
|
54
54
|
private cache;
|
|
55
55
|
/** Called on `activate`, so a scope's dep and tool nodes move with it. */
|
|
56
56
|
readonly onActivate: (() => void)[];
|
|
57
57
|
constructor(parent: ActionsNode | null, descends: boolean, contextDeps: () => DepRegistry | null);
|
|
58
58
|
private resolve;
|
|
59
|
+
/** `a` under every tuning for its id from the root down to here. */
|
|
60
|
+
private tuned;
|
|
59
61
|
private snapshot;
|
|
60
62
|
private deps;
|
|
61
63
|
private dispatcher;
|
|
@@ -125,11 +127,10 @@ interface YokeProps {
|
|
|
125
127
|
/**
|
|
126
128
|
* @experimental
|
|
127
129
|
* Canvases that share input on purpose: the active tool, the gesture in
|
|
128
|
-
* flight, history and yoke-wide actions. Made once with `useYoke()
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* toolbar, say. The members can sit anywhere in the tree
|
|
132
|
-
* tree, says who shares.
|
|
130
|
+
* flight, history, and yoke-wide actions. Made once with `useYoke()`, and
|
|
131
|
+
* passed to each canvas that joins it (`yoke={yoke}`) and to
|
|
132
|
+
* `<Yoke value={yoke}>` around anything else that should reach it — a
|
|
133
|
+
* toolbar, say. The members can sit anywhere in the tree.
|
|
133
134
|
*/
|
|
134
135
|
interface Yoke {
|
|
135
136
|
/** @internal */
|
|
@@ -176,10 +177,106 @@ interface OngoingAction {
|
|
|
176
177
|
*
|
|
177
178
|
* An edit left open when the control unmounts, or when `actionId` changes, is
|
|
178
179
|
* committed — it is what the user was looking at when the control went away.
|
|
180
|
+
* On unmount that happens a microtask later.
|
|
179
181
|
* The returned object is stable for the life of the component.
|
|
180
182
|
*/
|
|
181
183
|
declare function useOngoingAction(actionId: string): OngoingAction;
|
|
182
184
|
|
|
185
|
+
/** @experimental World-space pointer position and the view it is over — a
|
|
186
|
+
* view id, or `null` for a surface's own camera. `null` as a whole when the
|
|
187
|
+
* pointer is over no publishing surface. */
|
|
188
|
+
type PointerWorldPos = {
|
|
189
|
+
worldX: number;
|
|
190
|
+
worldY: number;
|
|
191
|
+
viewId: string | null;
|
|
192
|
+
} | null;
|
|
193
|
+
/** @experimental */
|
|
194
|
+
interface PointerContextValue {
|
|
195
|
+
/** The latest position. */
|
|
196
|
+
get(): PointerWorldPos;
|
|
197
|
+
/** Publish a position. Subscribers hear only a changed value. */
|
|
198
|
+
set(next: PointerWorldPos): void;
|
|
199
|
+
/** Called after every change; returns the unsubscribe. */
|
|
200
|
+
subscribe(fn: () => void): () => void;
|
|
201
|
+
/** Bumps on every change. */
|
|
202
|
+
getVersion(): number;
|
|
203
|
+
/** `get()` as a stable thunk, for hooks taking a drop-point option. */
|
|
204
|
+
readonly getDropPoint: () => PointerWorldPos;
|
|
205
|
+
}
|
|
206
|
+
/** @experimental A pointer store with no provider around it. */
|
|
207
|
+
declare function createPointerStore(): PointerContextValue;
|
|
208
|
+
/**
|
|
209
|
+
* @experimental
|
|
210
|
+
* Wrap the part of the React tree that should share one pointer.
|
|
211
|
+
* `<SceneCanvas>` mounts one when none is in scope, so mount it yourself only
|
|
212
|
+
* when two surfaces should share a pointer. Pass `store` to publish into one
|
|
213
|
+
* you hold elsewhere (`createPointerStore()`).
|
|
214
|
+
*/
|
|
215
|
+
declare function PointerContextProvider({ children, store }: {
|
|
216
|
+
children: ReactNode;
|
|
217
|
+
store?: PointerContextValue;
|
|
218
|
+
}): ReactNode;
|
|
219
|
+
/** @experimental The surrounding pointer store, or `null` when no provider is
|
|
220
|
+
* in scope. */
|
|
221
|
+
declare function usePointerContext(): PointerContextValue | null;
|
|
222
|
+
/** @experimental The pointer, re-rendering the caller whenever it changes.
|
|
223
|
+
* `null` outside a provider. */
|
|
224
|
+
declare function usePointerPosition(): PointerWorldPos;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @experimental
|
|
228
|
+
* SelectionContext — an ambient context that publishes "what's currently
|
|
229
|
+
* selected" so non-canvas UI (command palette, status bar) can read it without
|
|
230
|
+
* threading a selection prop through the tree.
|
|
231
|
+
*
|
|
232
|
+
* **Single slot:** the context holds one selection array. Whichever publisher
|
|
233
|
+
* calls `publishSelection` most recently owns it, so a multi-canvas page gets
|
|
234
|
+
* last-writer-wins. `<SceneCanvas>` publishes automatically.
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
/** @experimental */
|
|
238
|
+
interface SelectionContextValue {
|
|
239
|
+
/** The most-recently-published selection. Empty array when no canvas
|
|
240
|
+
* has published or when the active canvas's selection is empty. */
|
|
241
|
+
readonly selection: readonly NodeId[];
|
|
242
|
+
/** Optional per-id kind label, parallel to `selection` (e.g. `'rectangle'`,
|
|
243
|
+
* `'path'`, `'group'`). Sparse entries (`undefined`) are allowed; treat it
|
|
244
|
+
* as best-effort. */
|
|
245
|
+
readonly kinds?: readonly (string | undefined)[];
|
|
246
|
+
/** Publish the calling canvas's selection. Calling with the same content
|
|
247
|
+
* does not re-render the consumer tree. */
|
|
248
|
+
publishSelection(ids: readonly NodeId[], kinds?: readonly (string | undefined)[]): void;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* @experimental
|
|
252
|
+
* Wrap the part of the React tree that should share a selection context.
|
|
253
|
+
* Usually placed at the demo / app root, alongside `<ActionsProvider>`.
|
|
254
|
+
*/
|
|
255
|
+
declare function SelectionContextProvider({ children }: {
|
|
256
|
+
children: ReactNode;
|
|
257
|
+
}): ReactNode;
|
|
258
|
+
/**
|
|
259
|
+
* @experimental
|
|
260
|
+
* The current selection-context value, or `null` when no
|
|
261
|
+
* `<SelectionContextProvider>` is in scope.
|
|
262
|
+
*/
|
|
263
|
+
declare function useSelectionContext(): SelectionContextValue | null;
|
|
264
|
+
/**
|
|
265
|
+
* @experimental
|
|
266
|
+
* Mounts a `<SelectionContextProvider>` only when no parent provider is in
|
|
267
|
+
* scope; otherwise renders children unwrapped.
|
|
268
|
+
*/
|
|
269
|
+
declare function SelectionContextProviderIfRoot({ children, }: {
|
|
270
|
+
children: ReactNode;
|
|
271
|
+
}): ReactNode;
|
|
272
|
+
/**
|
|
273
|
+
* @experimental
|
|
274
|
+
* Publishes `ids` into the surrounding `<SelectionContextProvider>` whenever
|
|
275
|
+
* their content changes, and clears the slot on unmount unless another
|
|
276
|
+
* publisher has written it since. No-op when there's no provider in scope.
|
|
277
|
+
*/
|
|
278
|
+
declare function usePublishSelection(ids: readonly NodeId[], kinds?: readonly (string | undefined)[]): void;
|
|
279
|
+
|
|
183
280
|
/** Options for `useTools`: which tools exist, which one starts active, and
|
|
184
281
|
* which run continuously regardless of the active one. */
|
|
185
282
|
interface UseToolsOptions<TOverlay = KernelOverlay> {
|
|
@@ -189,7 +286,7 @@ interface UseToolsOptions<TOverlay = KernelOverlay> {
|
|
|
189
286
|
/** Tools eligible for the active slot or hotkey slot. The keys are the
|
|
190
287
|
* tool ids; the values are the tool records. A tool with `hotkey` set
|
|
191
288
|
* is wired into the hotkey slot whenever the engagement state matches. */
|
|
192
|
-
registry: Record<string,
|
|
289
|
+
registry: Record<string, Tool<TOverlay>>;
|
|
193
290
|
/** Always-on entries — tools or other contributions, live regardless of
|
|
194
291
|
* the active slot. */
|
|
195
292
|
ambient?: readonly Contribution<TOverlay>[];
|
|
@@ -205,8 +302,7 @@ interface ToolsApi<TOverlay = KernelOverlay> {
|
|
|
205
302
|
/** Set the active-slot tool, or `null` to clear it. The gesture dispatcher
|
|
206
303
|
* watches the active tool and cancels any in-flight handle itself. */
|
|
207
304
|
setActive: (id: string | null) => void;
|
|
208
|
-
/** Currently hotkey-engaged tool id (or `null`)
|
|
209
|
-
* the hotkey stack for backwards compat with the pre-stack API. */
|
|
305
|
+
/** Currently hotkey-engaged tool id (or `null`): the top of the hotkey stack. */
|
|
210
306
|
hotkeyEngaged: string | null;
|
|
211
307
|
/** Engage a hotkey-slot tool by id. */
|
|
212
308
|
engageHotkey: (id: string) => void;
|
|
@@ -215,31 +311,24 @@ interface ToolsApi<TOverlay = KernelOverlay> {
|
|
|
215
311
|
/** All always-on entries, in registration order. */
|
|
216
312
|
ambient: readonly Contribution<TOverlay>[];
|
|
217
313
|
/** Full registry — for userland UI (palette buttons, etc.). */
|
|
218
|
-
registry: Readonly<Record<string,
|
|
314
|
+
registry: Readonly<Record<string, Tool<TOverlay>>>;
|
|
219
315
|
/** Returns true if a tool with the given id is in the registry or ambient list. */
|
|
220
316
|
has(id: string): boolean;
|
|
221
|
-
/**
|
|
222
|
-
*
|
|
223
|
-
* Filters out tools with no `overlay` field. Order: active, then hotkey
|
|
224
|
-
* (if engaged), then ambient (registration order). */
|
|
317
|
+
/** Overlay layers from currently-engaged tools that declare `position`.
|
|
318
|
+
* Order: active, then hotkey (if engaged), then ambient (registration order). */
|
|
225
319
|
getActiveOverlays(position?: OverlayPosition): TOverlay[];
|
|
226
320
|
}
|
|
227
321
|
/**
|
|
228
|
-
* Manages the active tool and hotkey slot
|
|
229
|
-
*
|
|
230
|
-
* A thin shim over {@link useContributions}: the `registry` / `ambient`
|
|
231
|
-
* arguments are restated as declared eligibility (`focus` / `always`), and
|
|
232
|
-
* assembly happens in one place for tools and non-tool contributions alike.
|
|
322
|
+
* Manages the active tool and hotkey slot; a thin shim over
|
|
323
|
+
* {@link useContributions}.
|
|
233
324
|
*
|
|
234
325
|
* Requires `<ActiveToolContextProvider>` (or `<WeaselProvider>` /
|
|
235
326
|
* `<SceneCanvas>`, which mount one internally) in scope: active/hotkey state
|
|
236
|
-
* lives in the context
|
|
237
|
-
* `useTools` calls all read the same source of truth.
|
|
327
|
+
* lives in the context.
|
|
238
328
|
*
|
|
239
|
-
* **First
|
|
240
|
-
* `
|
|
241
|
-
*
|
|
242
|
-
* context currently holds (the first caller wins).
|
|
329
|
+
* **First mount wins**: if the context's slot is unseeded on first mount,
|
|
330
|
+
* `useTools` pushes `opts.active` to the context. Subsequent mounts respect
|
|
331
|
+
* whatever the context currently holds.
|
|
243
332
|
*/
|
|
244
333
|
declare function useTools<TOverlay = KernelOverlay>(opts: UseToolsOptions<TOverlay>): ToolsApi<TOverlay>;
|
|
245
334
|
|
|
@@ -291,4 +380,4 @@ declare function useContributions<TOverlay = KernelOverlay>(opts: UseContributio
|
|
|
291
380
|
*/
|
|
292
381
|
declare function useOffhandAction(entries: readonly Contribution<unknown>[]): void;
|
|
293
382
|
|
|
294
|
-
export { ActionsProvider, type ContributionsApi, DepRegistry, DepRegistryProvider, InputScope, type InputScopeProps, type OngoingAction, type ToolsApi, type UseContributionsOptions, UseGestureDispatcherOptions, type UseToolsOptions, Yoke, type YokeProps, useAction, useActionsRegistry, useContributions, useDepRegistry, useDepSource, useGestureDispatcher, useOffhandAction, useOngoingAction, useOptionalDepRegistry, useTools, useYoke };
|
|
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 };
|