@weasel-js/core 1.6.0 → 1.6.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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b209a8e: A feature installs from one entry. `SurfaceContribution` extends `Contribution` with `views` and `attach(api, deps)`, and `Contribution` gains `deps`; `<SceneCanvas ambient>` installs every role an entry declares and removes them with it. `mergeContributions` throws on a duplicate dep name or view id as well as a duplicate entry id.
8
+
9
+ Bindings can be scoped to views with `opts.views`; a binding that names the view an input landed in outranks bindings that do not. `InvocationCtx.viewId` and `RuleCtx.viewId` carry that view, layer `data.viewId` names the view a draw is for, and the `rootView` dep answers the surface camera from inside a view.
10
+
11
+ `createMinimapContribution` puts a minimap inside a canvas, with a linked crosshair, and `createLinkedCursorContribution` draws the crosshair alone. `<MinimapCanvas>` now runs on a dispatcher, publishes its pointer, and takes an `id`.
12
+
13
+ Breaking: `PointerContextValue` is a store — `get`, `set`, `subscribe`, `getVersion` — in place of `pointerRef`, and `PointerWorldPos` carries `viewId`. `usePointerPosition()` follows it. `useHud`'s ref is optional; `useHudContribution(hud, options)` attaches the HUD as well as routing its input.
14
+ - 7683659: A labkit camera now routes through weasel's gesture dispatcher. `<CanvasStack>` and `<Stage>` pan on a drag, zoom on the wheel and report a tap through `CameraInput`, which drives core's `viewport.dragPan` and `viewport.zoom` over the camera as a weasel `View` (`toCameraView` / `fromCameraView`). The loupe joins the same dispatcher, taking the wheel while its lens is up. A trial publishes its pointer, and `RenderContext.trial.pointer` is that store; `<LinkedCursor>` draws the crosshair on the stage while the pointer is over another view.
15
+
16
+ Breaking: `usePanZoom` is removed. `PointerContextProvider` takes an optional `store`, and core exports `crosshairRects`.
17
+ - Updated dependencies [b209a8e]
18
+ - @weasel-js/routing@1.6.1
19
+ - @weasel-js/cursor@1.6.1
20
+ - @weasel-js/font@1.6.1
21
+ - @weasel-js/geom@1.6.1
22
+ - @weasel-js/gestures@1.6.1
23
+ - @weasel-js/history@1.6.1
24
+ - @weasel-js/paint@1.6.1
25
+ - @weasel-js/text@1.6.1
26
+
3
27
  ## 1.6.0
4
28
 
5
29
  ### Patch Changes
@@ -3,6 +3,7 @@ import { NodeId, Bounds, View, SelectionApi, ActionDeps, IngestItem, DragSample,
3
3
  import { P as Path } from './path-JEV2c5If.js';
4
4
  import { ResolvedRun, TextStyle, TextVerticalAlign } from '@weasel-js/text';
5
5
  import { Mat3 } from '@weasel-js/geom';
6
+ import { ReactNode } from 'react';
6
7
  import * as _weasel_js_history from '@weasel-js/history';
7
8
  import { Op, History, SerializedHistory } from '@weasel-js/history';
8
9
  import { a as SceneAdapter, L as LayoutStrategy, b as LayoutDropTargetMode, I as InsertAdapter } from './types-CxC8P6W0.js';
@@ -1773,65 +1774,6 @@ interface CullRect {
1773
1774
  */
1774
1775
  declare function cullDrawCommands(cmds: DrawCommand[], transform: GlMat3, rect: CullRect): DrawCommand[];
1775
1776
 
1776
- /** Options for stroke tessellation. */
1777
- interface StrokeOptions {
1778
- flattenTolerance?: number;
1779
- /**
1780
- * Shorten each open subpath by this much at its start / end, in the same
1781
- * world units as the path. Stroke markers use this so a filled head is not
1782
- * speared by its own line; the caller resolves the distance, because this
1783
- * layer knows nothing about the marker registry.
1784
- */
1785
- startInset?: number;
1786
- endInset?: number;
1787
- }
1788
- /** Resolve a stroke width to world units. A number is already world units;
1789
- * `{ px }` is screen pixels divided by the accumulated scale, so it holds its
1790
- * on-screen thickness as the view zooms. */
1791
- declare function resolveStrokeWidth(width: ScreenLength, scale: number): number;
1792
- /**
1793
- * Build a triangle-mesh ribbon from a stroked Path.
1794
- *
1795
- * Supports:
1796
- * - cap: 'butt' | 'round' | 'square'
1797
- * - join: 'miter' | 'round' | 'bevel'
1798
- * - center alignment directly; RectPath inner/outer alignment via a
1799
- * pre-shifted rect; PolygonPath inner/outer alignment via stencil at the
1800
- * renderer level
1801
- * - dash splitting
1802
- */
1803
- declare function tessellateStroke(path: Path, stroke: Stroke, opts?: StrokeOptions): Mesh;
1804
-
1805
- /**
1806
- * Effects that ship with the kit.
1807
- *
1808
- * Each is a function returning `Effect[]`, not a single `Effect`, because a
1809
- * separable kernel is genuinely two passes and hiding that behind one entry
1810
- * would make the cost invisible at the callsite:
1811
- *
1812
- * effects={[...blur({ radius: 4 }), ...vignette({ amount: 0.6 })]}
1813
- */
1814
-
1815
- /**
1816
- * Gaussian blur, as a horizontal pass followed by a vertical one.
1817
- *
1818
- * `radius` is in device pixels and is the distance of the outermost tap, not a
1819
- * standard deviation — 0 is a copy, and the falloff is the same nine-tap
1820
- * kernel at every radius, so a large one is a wide blur rather than a better
1821
- * one. Two passes at O(9) beat one at O(81) and look the same.
1822
- */
1823
- declare function blur({ radius }: {
1824
- radius: number;
1825
- }): Effect[];
1826
- /**
1827
- * Darken toward the corners. `amount` is how dark the corner gets (0..1) and
1828
- * `feather` how much of the radius the falloff occupies.
1829
- */
1830
- declare function vignette({ amount, feather }: {
1831
- amount: number;
1832
- feather?: number;
1833
- }): Effect[];
1834
-
1835
1777
  /** Per-axis limits on a view's position. Any side may be left open. */
1836
1778
  interface PanBounds {
1837
1779
  minX?: number;
@@ -2573,6 +2515,66 @@ declare function useViewAnimation(view: ViewChannel, animator?: Animator): ViewA
2573
2515
  * animator of its own, so the camera runs on exactly the one passed. */
2574
2516
  declare function useViewAnimationOn(view: ViewChannel, animator: Animator): ViewAnimationApi;
2575
2517
 
2518
+ /**
2519
+ * @experimental
2520
+ * PointerContext — the world-space position of the canvas pointer, and the
2521
+ * view it is over, refreshed on every `pointermove` and cleared on
2522
+ * `pointerleave`.
2523
+ *
2524
+ * It is an external store rather than React state: cursor moves fire dozens of
2525
+ * times per second, and a consumer that only reads on demand (paste at the
2526
+ * pointer) must not re-render for each one. Readers that do need to follow it
2527
+ * — a linked cursor — subscribe, or use `usePointerPosition()`.
2528
+ *
2529
+ * `<SceneCanvas>` publishes automatically, and defers to a provider already in
2530
+ * scope, so several surfaces under one provider share one pointer: a detached
2531
+ * minimap and its main canvas each see where the other's pointer is.
2532
+ */
2533
+
2534
+ /** @experimental World-space pointer position and the view it is over — a
2535
+ * view id, or `null` for a surface's own camera. `null` as a whole when the
2536
+ * pointer is over no publishing surface. */
2537
+ type PointerWorldPos = {
2538
+ worldX: number;
2539
+ worldY: number;
2540
+ viewId: string | null;
2541
+ } | null;
2542
+ /** @experimental */
2543
+ interface PointerContextValue {
2544
+ /** The latest position. */
2545
+ get(): PointerWorldPos;
2546
+ /** Publish a position. Subscribers hear only a changed value. */
2547
+ set(next: PointerWorldPos): void;
2548
+ /** Called after every change; returns the unsubscribe. */
2549
+ subscribe(fn: () => void): () => void;
2550
+ /** Bumps on every change. */
2551
+ getVersion(): number;
2552
+ /** `get()` as a stable thunk, for hooks taking a drop-point option. */
2553
+ readonly getDropPoint: () => PointerWorldPos;
2554
+ }
2555
+ /** @experimental A pointer store with no provider around it. */
2556
+ declare function createPointerStore(): PointerContextValue;
2557
+ /**
2558
+ * @experimental
2559
+ * Wrap the part of the React tree that should share one pointer. Usually at
2560
+ * the app root, alongside `<ActionsProvider>` and `<SelectionContextProvider>`.
2561
+ *
2562
+ * Most consumers don't need to mount this directly — `<SceneCanvas>` mounts
2563
+ * one when none is in scope. Mount it yourself when two surfaces should share
2564
+ * a pointer. Pass `store` to publish into one you hold elsewhere
2565
+ * (`createPointerStore()`).
2566
+ */
2567
+ declare function PointerContextProvider({ children, store }: {
2568
+ children: ReactNode;
2569
+ store?: PointerContextValue;
2570
+ }): ReactNode;
2571
+ /** @experimental The surrounding pointer store, or `null` when no provider is
2572
+ * in scope. */
2573
+ declare function usePointerContext(): PointerContextValue | null;
2574
+ /** @experimental The pointer, re-rendering the caller whenever it changes.
2575
+ * `null` outside a provider. */
2576
+ declare function usePointerPosition(): PointerWorldPos;
2577
+
2576
2578
  /**
2577
2579
  * Pose composition for hierarchical scene graphs.
2578
2580
  *
@@ -3497,7 +3499,77 @@ declare module '@weasel-js/routing' {
3497
3499
  * consults this seam (rotation lives on the pose, baked at render).
3498
3500
  */
3499
3501
  geometryProjection?: GeometryProjection;
3502
+ /**
3503
+ * The surface's own camera. Inside a `<CanvasView>`, `view` answers that
3504
+ * view's camera and this one does not change: an action bound in a view
3505
+ * that must move the main camera — a minimap's pan — reads this.
3506
+ */
3507
+ rootView: ViewApi;
3508
+ /**
3509
+ * The pointer store in scope: where the pointer is, in which view. Shared
3510
+ * by every surface under one `<PointerContextProvider>`.
3511
+ */
3512
+ pointer?: PointerContextValue;
3500
3513
  }
3501
3514
  }
3502
3515
 
3503
- export { type DerivedDep as $, type SliceDep as A, type VertexColorChannel as B, type CullRect as C, type DrawCommand as D, type Effect as E, type InsertExtras as F, type GlMat3 as G, type SerializedScene as H, IDENTITY_COLOR_MATRIX as I, type GeometryProjection as J, type ContentHandlerEntry as K, type SvgIngestOptions as L, type Mesh as M, type Node as N, type PanBounds as O, type PathDrawCommand as P, type Animator as Q, type RenderTarget as R, SPRITE_STRIDE as S, type TextDrawCommand as T, ColorOverrideRegistry as U, type ViewAnimationOptions as V, WeaselRenderer as W, type UseSceneOptions as X, type SceneRegistry as Y, type RegisteredOp as Z, type PoseOverrides as _, type GroupDrawCommand as a, type StaggerSpringPoseOptions as a$, type ViewportDims as a0, ShaderProgram as a1, type BooleansAdapter as a2, type UseAnimatorOptions as a3, type SpringPresetName as a4, type EasingSpec as a5, type AnimationHandle as a6, type SampledTrack as a7, type AddLayerSpec as a8, type AddNodeSpec as a9, type Keyframe as aA, type LassoSelectDep as aB, type LayerRecord as aC, type LayoutDep as aD, type LeafNode as aE, type LoopFactory as aF, type LoopOptions as aG, type NestedTimeline as aH, type NodeAtPointDep as aI, type PhysicsHandle as aJ, type PhysicsOptions as aK, type PoseAdapter as aL, type PoseClosure as aM, type PoseOverride as aN, RECT_POSE_COMPOSITION as aO, RIGID_POSE_COMPOSITION as aP, type ResizePolicy as aQ, SPRING_PRESETS as aR, type SerializedNode as aS, type SnapDep as aT, type SpringOptions as aU, type SpringPreset as aV, type StaggerBuilder as aW, type StaggerDelay as aX, type StaggerFactory as aY, type StaggerOptions as aZ, type StaggerPerItem as a_, type AnimateToBoundsOptions as aa, type AreaSelectDep as ab, type BezierEasing as ac, type BooleanOp as ad, type BooleanOpResult as ae, type ClipboardDep as af, type ClipboardIngestCtx as ag, type ColorOverride as ah, type ColorOverrideFn as ai, type ContainerNode as aj, type DecayLoopConfig as ak, type DecayOptions as al, EASINGS as am, type EasingFn as an, type EasingName as ao, type EditAnchorsDep as ap, type EventBooking as aq, type EventBookingHandle as ar, type EventTrack as as, type FitViewToBoundsOptions as at, IDENTITY_POSE_COMPOSITION as au, type IngestCtx as av, type IngestionDep as aw, type InsertDep as ax, type Interpolate as ay, type InterpolatorFactory as az, type ImageDrawCommand as b, resolveEasing as b$, type StaggerTweenOptions as b0, type SvgUnpacker as b1, type SystemLayerRecord as b2, type SystemLayerSpec as b3, type TextEditDep as b4, type TimelineClock as b5, type TimelineEvent as b6, type TimelineHandle as b7, type TimelineOptions as b8, type TimelineTrack as b9, easeInOutCirc as bA, easeInOutCubic as bB, easeInOutElastic as bC, easeInOutExpo as bD, easeInOutQuad as bE, easeInOutQuart as bF, easeInOutQuint as bG, easeInOutSine as bH, easeInQuad as bI, easeInQuart as bJ, easeInQuint as bK, easeInSine as bL, easeOut as bM, easeOutBack as bN, easeOutBounce as bO, easeOutCirc as bP, easeOutCubic as bQ, easeOutElastic as bR, easeOutExpo as bS, easeOutQuad as bT, easeOutQuart as bU, easeOutQuint as bV, easeOutSine as bW, fitViewToBounds as bX, linear as bY, rebaseLocalPose as bZ, registerContentHandler as b_, type Track as ba, type TweenLoopOptions as bb, type TweenOptions as bc, type UserLayerRecord as bd, VIEW_ANIMATION_KEY as be, type ViewAnimationApi as bf, type ViewApi as bg, type ViewChannel as bh, applyBooleanOp as bi, asNodeId as bj, composeRectPose as bk, composeRigidPose as bl, composeWorldPose as bm, cubicBezierEasing as bn, decomposeRectPose as bo, decomposeRigidPose as bp, easeIn as bq, easeInBack as br, easeInBounce as bs, easeInCirc as bt, easeInCubic as bu, easeInElastic as bv, easeInExpo as bw, easeInOut as bx, easeInOutBack as by, easeInOutBounce as bz, type ImageMinification as c, resolveStrokeWidth as c0, translateRectPose as c1, useDecayLoop as c2, useViewAnimation as c3, useViewAnimationOn as c4, worldPoseLookup as c5, ShaderCompileError as d, type ShaderDrawCommand as e, type ShaderProgramHandle as f, type ShaderUniform as g, type SolidPaint as h, type SpriteSheet as i, type SpritesDrawCommand as j, type StrokeOptions as k, type WeaselRendererOptions as l, blur as m, buildGradientRamp as n, cullDrawCommands as o, frameRect as p, mat3 as q, registerEffect as r, registerProgram as s, tessellateStroke as t, vignette as u, viewToMat3 as v, type Scene as w, type RectPose as x, type InertiaConfig as y, type PoseComposition as z };
3516
+ /** Options for stroke tessellation. */
3517
+ interface StrokeOptions {
3518
+ flattenTolerance?: number;
3519
+ /**
3520
+ * Shorten each open subpath by this much at its start / end, in the same
3521
+ * world units as the path. Stroke markers use this so a filled head is not
3522
+ * speared by its own line; the caller resolves the distance, because this
3523
+ * layer knows nothing about the marker registry.
3524
+ */
3525
+ startInset?: number;
3526
+ endInset?: number;
3527
+ }
3528
+ /** Resolve a stroke width to world units. A number is already world units;
3529
+ * `{ px }` is screen pixels divided by the accumulated scale, so it holds its
3530
+ * on-screen thickness as the view zooms. */
3531
+ declare function resolveStrokeWidth(width: ScreenLength, scale: number): number;
3532
+ /**
3533
+ * Build a triangle-mesh ribbon from a stroked Path.
3534
+ *
3535
+ * Supports:
3536
+ * - cap: 'butt' | 'round' | 'square'
3537
+ * - join: 'miter' | 'round' | 'bevel'
3538
+ * - center alignment directly; RectPath inner/outer alignment via a
3539
+ * pre-shifted rect; PolygonPath inner/outer alignment via stencil at the
3540
+ * renderer level
3541
+ * - dash splitting
3542
+ */
3543
+ declare function tessellateStroke(path: Path, stroke: Stroke, opts?: StrokeOptions): Mesh;
3544
+
3545
+ /**
3546
+ * Effects that ship with the kit.
3547
+ *
3548
+ * Each is a function returning `Effect[]`, not a single `Effect`, because a
3549
+ * separable kernel is genuinely two passes and hiding that behind one entry
3550
+ * would make the cost invisible at the callsite:
3551
+ *
3552
+ * effects={[...blur({ radius: 4 }), ...vignette({ amount: 0.6 })]}
3553
+ */
3554
+
3555
+ /**
3556
+ * Gaussian blur, as a horizontal pass followed by a vertical one.
3557
+ *
3558
+ * `radius` is in device pixels and is the distance of the outermost tap, not a
3559
+ * standard deviation — 0 is a copy, and the falloff is the same nine-tap
3560
+ * kernel at every radius, so a large one is a wide blur rather than a better
3561
+ * one. Two passes at O(9) beat one at O(81) and look the same.
3562
+ */
3563
+ declare function blur({ radius }: {
3564
+ radius: number;
3565
+ }): Effect[];
3566
+ /**
3567
+ * Darken toward the corners. `amount` is how dark the corner gets (0..1) and
3568
+ * `feather` how much of the radius the falloff occupies.
3569
+ */
3570
+ declare function vignette({ amount, feather }: {
3571
+ amount: number;
3572
+ feather?: number;
3573
+ }): Effect[];
3574
+
3575
+ export { type DerivedDep as $, type SliceDep as A, type VertexColorChannel as B, type CullRect as C, type DrawCommand as D, type Effect as E, type InsertExtras as F, type GlMat3 as G, type SerializedScene as H, IDENTITY_COLOR_MATRIX as I, type GeometryProjection as J, type ContentHandlerEntry as K, type SvgIngestOptions as L, type Mesh as M, type Node as N, type PanBounds as O, type PathDrawCommand as P, type Animator as Q, type RenderTarget as R, SPRITE_STRIDE as S, type TextDrawCommand as T, ColorOverrideRegistry as U, type ViewAnimationOptions as V, WeaselRenderer as W, type UseSceneOptions as X, type SceneRegistry as Y, type RegisteredOp as Z, type PoseOverrides as _, type GroupDrawCommand as a, type StaggerDelay as a$, type ViewportDims as a0, type ViewApi as a1, ShaderProgram as a2, type BooleansAdapter as a3, type UseAnimatorOptions as a4, type SpringPresetName as a5, type EasingSpec as a6, type AnimationHandle as a7, type SampledTrack as a8, type AddLayerSpec as a9, type InterpolatorFactory as aA, type Keyframe as aB, type LassoSelectDep as aC, type LayerRecord as aD, type LayoutDep as aE, type LeafNode as aF, type LoopFactory as aG, type LoopOptions as aH, type NestedTimeline as aI, type NodeAtPointDep as aJ, type PhysicsHandle as aK, type PhysicsOptions as aL, PointerContextProvider as aM, type PointerContextValue as aN, type PointerWorldPos as aO, type PoseAdapter as aP, type PoseClosure as aQ, type PoseOverride as aR, RECT_POSE_COMPOSITION as aS, RIGID_POSE_COMPOSITION as aT, type ResizePolicy as aU, SPRING_PRESETS as aV, type SerializedNode as aW, type SnapDep as aX, type SpringOptions as aY, type SpringPreset as aZ, type StaggerBuilder as a_, type AddNodeSpec as aa, type AnimateToBoundsOptions as ab, type AreaSelectDep as ac, type BezierEasing as ad, type BooleanOp as ae, type BooleanOpResult as af, type ClipboardDep as ag, type ClipboardIngestCtx as ah, type ColorOverride as ai, type ColorOverrideFn as aj, type ContainerNode as ak, type DecayLoopConfig as al, type DecayOptions as am, EASINGS as an, type EasingFn as ao, type EasingName as ap, type EditAnchorsDep as aq, type EventBooking as ar, type EventBookingHandle as as, type EventTrack as at, type FitViewToBoundsOptions as au, IDENTITY_POSE_COMPOSITION as av, type IngestCtx as aw, type IngestionDep as ax, type InsertDep as ay, type Interpolate as az, type ImageDrawCommand as b, fitViewToBounds as b$, type StaggerFactory as b0, type StaggerOptions as b1, type StaggerPerItem as b2, type StaggerSpringPoseOptions as b3, type StaggerTweenOptions as b4, type SvgUnpacker as b5, type SystemLayerRecord as b6, type SystemLayerSpec as b7, type TextEditDep as b8, type TimelineClock as b9, easeInExpo as bA, easeInOut as bB, easeInOutBack as bC, easeInOutBounce as bD, easeInOutCirc as bE, easeInOutCubic as bF, easeInOutElastic as bG, easeInOutExpo as bH, easeInOutQuad as bI, easeInOutQuart as bJ, easeInOutQuint as bK, easeInOutSine as bL, easeInQuad as bM, easeInQuart as bN, easeInQuint as bO, easeInSine as bP, easeOut as bQ, easeOutBack as bR, easeOutBounce as bS, easeOutCirc as bT, easeOutCubic as bU, easeOutElastic as bV, easeOutExpo as bW, easeOutQuad as bX, easeOutQuart as bY, easeOutQuint as bZ, easeOutSine as b_, type TimelineEvent as ba, type TimelineHandle as bb, type TimelineOptions as bc, type TimelineTrack as bd, type Track as be, type TweenLoopOptions as bf, type TweenOptions as bg, type UserLayerRecord as bh, VIEW_ANIMATION_KEY as bi, type ViewAnimationApi as bj, type ViewChannel as bk, applyBooleanOp as bl, asNodeId as bm, composeRectPose as bn, composeRigidPose as bo, composeWorldPose as bp, createPointerStore as bq, cubicBezierEasing as br, decomposeRectPose as bs, decomposeRigidPose as bt, easeIn as bu, easeInBack as bv, easeInBounce as bw, easeInCirc as bx, easeInCubic as by, easeInElastic as bz, type ImageMinification as c, linear as c0, rebaseLocalPose as c1, registerContentHandler as c2, resolveEasing as c3, resolveStrokeWidth as c4, translateRectPose as c5, useDecayLoop as c6, usePointerContext as c7, usePointerPosition as c8, useViewAnimation as c9, useViewAnimationOn as ca, worldPoseLookup as cb, ShaderCompileError as d, type ShaderDrawCommand as e, type ShaderProgramHandle as f, type ShaderUniform as g, type SolidPaint as h, type SpriteSheet as i, type SpritesDrawCommand as j, type StrokeOptions as k, type WeaselRendererOptions as l, blur as m, buildGradientRamp as n, cullDrawCommands as o, frameRect as p, mat3 as q, registerEffect as r, registerProgram as s, tessellateStroke as t, vignette as u, viewToMat3 as v, type Scene as w, type RectPose as x, type InertiaConfig as y, type PoseComposition as z };