@weasel-js/core 1.1.0 → 1.2.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/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, ColorOverrideRegistry, CropIcon, CursorCoordsHud, DEFAULT_ALPHA_DECAY, DEFAULT_ALPHA_MIN, DEFAULT_DEBUG_STROKES, DEFAULT_DEBUG_THEME, DEFAULT_DEVICE_PROFILE, DEFAULT_FILL_COLOR, DEFAULT_HANDLE_SIZE, DEFAULT_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_STYLE, DEFAULT_VELOCITY_DECAY, DepRegistryProviderIfRoot, DeviceProfileProvider, DivideIcon, EASINGS, EllipseIcon, ExcludeIcon, EyedropperIcon, FALLBACK_FIT_VIEW, GHOST_STROKE, HANDLE_BASE_PX, HandIcon, IDENTITY_JOINT, IDENTITY_POSE_COMPOSITION, IntersectIcon, KIT_SHAPE_KINDS, LassoIcon, LineIcon, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, ROTATION_HANDLE_BASE_PX, RectIcon, SPRING_PRESETS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TextIcon, UnionIcon, UnknownIcon, VERSION, WeaselProvider, aabbCenter, actionIs, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, bezierCubic, bezierQuadratic, blendPoses, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, canBringForward, canHover, canQueryLocalFonts2 as canQueryLocalFonts, canSendBackward, capabilityAll, capabilityIn, capabilityIs, capabilityNot, caretIndexAt, cellAt, charOffsetToDomPosition, clampView, clearSelectionAction, clientToCanvas, clipboardCopyAction, clipboardCutAction, cloneAction, coarsePointer, composeAffordanceLayer, composePath, composeRectPose, composeSelectionPose, composeWorldPose, computeFitView, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createTextLayer, createViewportLayer, cycleVertexColors, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, defineTool, defineViewportTool, deriveAlignmentGuides, deriveParallaxView, describeRule, domPositionToCharOffset, domToRuns, drawLayers, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorsAction, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getNodeShapes, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, isCanvasFont2 as isCanvasFont, isEditableTarget, isPatternSpec, lassoSelectAction, layoutMarkdown, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, liveScope, makeViewportZoomAction, markdownToRuns, mat3, matchAlignment, matchesKeyBinding, meanScale, measureText, measureTextBounds, measuredWidth, mergeAlphaFromPrev, mergeContributions, modeIn, modeIs, modeNot, modifierHeld, momentum, moveAction, multiActive, nearest, nearestWithin, nestedHitTester, never, nodeHasFlag, none, normalizeHex, not, nurbs, oklabToOklch, oklabToSrgbU8, oklchToOklab, openFilePicker, or, outlineStatus2 as outlineStatus, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerNodeShape, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveColor, resolveDeviceProfile, resolveFillPattern, resolvePatternSpec, resolveRuns, resolveSkeleton, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sampleTrack, sceneFromJSON, sceneNodeClientRect, sceneToAdapter, scopeBindings, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, shapeCoversPoint, sliceAction, snapPoint, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, tweenPose, tweenVertexColors, unionBounds, unionBoundsPath, unregisterCanvasFont2 as unregisterCanvasFont, unregisterFontOutlines2 as unregisterFontOutlines, useActiveToolContext, useAlign, useAnimator, useArrayAdapter, useAutoCenter, useBooleans, useBooleansAdapter, useCanvasFocus, useCanvasSize, useDecayLoop, useDeviceProfile, useDistribute, useDragGesture, useDragHandle, useDragRadial, useDragRect, useDropZone, useEllipseTool, useEyedropperTool, useGestureDispatcher, useGridCellHover, useGuides, useHandTool, useHandleDrag, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useOptionalActiveToolContext, usePenTool, usePencilTool, usePinchGesture, usePinchZoomTool, usePointerStylus, usePolygonTool, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewTween, useZoom, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportZoomAction, viewportsAt, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-3B4QEB2G.js';
2
- export { ActionDisabledReason, ActionsProvider, DepRegistryProvider, evaluateEnabled, useAction, useActionsRegistry, useDepRegistry, useDepSource, useOptionalDepRegistry } from './chunk-J3YC3GVF.js';
1
+ export { ALWAYS, ANCHOR_HIT_BASE_PX, ActionsProviderIfRoot, ActiveToolContextProvider, ActiveToolContextProviderIfRoot, BUNDLE_TOOLS, COARSE_TARGET_SCALE, CURVE_REPS, CanvasView, ColorOverrideRegistry, CropIcon, CursorCoordsHud, DEFAULT_ALPHA_DECAY, DEFAULT_ALPHA_MIN, DEFAULT_DEBUG_STROKES, DEFAULT_DEBUG_THEME, DEFAULT_DEVICE_PROFILE, DEFAULT_FILL_COLOR, DEFAULT_HANDLE_SIZE, DEFAULT_PALETTE, DEFAULT_ROTATION_HANDLE_DISTANCE, DEFAULT_STROKE_COLOR, DEFAULT_TEXT_STYLE, DEFAULT_VELOCITY_DECAY, DepRegistryProviderIfRoot, DeviceProfileProvider, DivideIcon, EASINGS, EllipseIcon, ExcludeIcon, EyedropperIcon, FALLBACK_FIT_VIEW, GHOST_STROKE, HANDLE_BASE_PX, HandIcon, IDENTITY_JOINT, IDENTITY_POSE_COMPOSITION, IntersectIcon, KIT_SHAPE_KINDS, LassoIcon, LineIcon, MIXED, MOVE_ANCHORS, MinimapCanvas, NEVER, PATH_ANCHOR_CHROME_ID, PenIcon, PencilIcon, PickHud, PointerProviderIfRoot, PolygonIcon, RECT_ALIGN_PROJECTION, ROTATION_HANDLE_BASE_PX, RectIcon, SPRING_PRESETS, SceneCanvas, SceneViewCanvas, SelectIcon, SelectionContextProvider, SelectionContextProviderIfRoot, StarIcon, SubtractIcon, TextIcon, UnionIcon, UnknownIcon, VERSION, WeaselProvider, aabbCenter, actionIs, actionShortcuts, alignDeltaFor, alignInsertBehavior, alignMoveBehavior, alignResizeBehavior, alignedStrokeRect, always, and, animateLifecycle, animateOnSetPose, annulusSemiAxes, applyBooleanOp, applyStyleToRange, areaSelectAction, arrayAdapter, asNodeId, bezierCubic, bezierQuadratic, blendPoses, buildChromeCtx, buildRuleCtx, buildSceneViewCommands, canBringForward, canHover, canQueryLocalFonts2 as canQueryLocalFonts, canSendBackward, capabilityAll, capabilityIn, capabilityIs, capabilityNot, caretIndexAt, cellAt, charOffsetToDomPosition, clampView, clearSelectionAction, clientToCanvas, clipboardCopyAction, clipboardCutAction, cloneAction, coarsePointer, composeAffordanceLayer, composePath, composeRectPose, composeSelectionPose, composeWorldPose, computeFitView, computeFitViewport, computeIndicatorCommand, computeWheelAction, cond, constrainTo45, containedThenNearest, countPathAnchors, createCellHighlightLayer, createChildrenLayer, createCornerResizeAffordance, createDebugOverlayLayer, createDebugSink, createDispatcher, createGridLayer, createGuidesLayer, createHistory, createMarkdownRenderer, createMoveToIndexOp, createNodeProperties, createNodeRouting, createParallaxLayer, createPathAnchorAffordances, createPathEditingOverlayLayer, createPathLayer, createPenPreviewLayer, createReorderOp, createRotationAffordance, createScene, createSelectionHandlesLayer, createSelectionOutlineLayer, createSelectionOverlayLayer, createSetDataOp, createSetLayerOp, createSetPathOp, createSetTextOp, createTextLayer, createViewResolver, createViewportLayer, cycleVertexColors, decomposePath, decomposeRectPose, defaultCommitAdapter, defaultDrawOne, defaultLabelTextRenderer, defaultNodeProperties, defaultNodeRouting, defaultVisibilityRules, defineTool, defineViewportTool, deriveAlignmentGuides, deriveParallaxView, describeRule, domPositionToCharOffset, domToRuns, drawLayers, drawOneLayer, easeIn, easeInBack, easeInBounce, easeInCirc, easeInCubic, easeInElastic, easeInExpo, easeInOut, easeInOutBack, easeInOutBounce, easeInOutCirc, easeInOutCubic, easeInOutElastic, easeInOutExpo, easeInOutQuad, easeInOutQuart, easeInOutQuint, easeInOutSine, easeInQuad, easeInQuart, easeInQuint, easeInSine, easeOut, easeOutBack, easeOutBounce, easeOutCirc, easeOutCubic, easeOutElastic, easeOutExpo, easeOutQuad, easeOutQuart, easeOutQuint, easeOutSine, editAnchorsAction, enableLocalFontOutlines2 as enableLocalFontOutlines, enterTextEditAction, enumerateAnchors, evaluate, fillInPoseFrame, fillToBoundsFrame, findNodeShape, findShapeInk, findShapeSilhouette, fitTextPose, fitToBounds, fitViewToBounds, fitZoom, focused, fontString, forEachCoalesced, frameRect, freeform, gateLayer, gesturing, getAlpha01, getImageBitmap, getNodeShapes, getStylusData, gradientForBounds, gradientGeometry, hasFontOutlines2 as hasFontOutlines, hexToRgba, hitAffordanceRegions, hitAnchor, hitRotationHandle, hovering, hoveringSelected, imageStatus, inferredNodeProperties, inferredNodeRouting, insertAction, isCanvasFont2 as isCanvasFont, isEditableTarget, isLayerVisible, isPatternSpec, keySpecShortcut, lassoSelectAction, layoutMarkdown, lerpColorArray, lerpOklab, lerpOklch, linear, listFontOutlines2 as listFontOutlines, liveScope, makeViewportZoomAction, markdownToRuns, mat3, matchAlignment, matchesKeyBinding, meanScale, measureText, measureTextBounds, measuredWidth, mergeAlphaFromPrev, mergeContributions, modeIn, modeIs, modeNot, modifierHeld, momentum, moveAction, multiActive, nearest, nearestWithin, nestedHitTester, never, nodeHasFlag, none, normalizeHex, not, nurbs, oklabToOklch, oklabToSrgbU8, oklchToOklab, openFilePicker, or, outlineStatus2 as outlineStatus, parseColor, parseColorToRgba255, parseDebugFlags, pathContainsPoint, pathContainsPolygon, pathContainsRect, pathDistanceToPoint, pathDivide, pathExclude, pathFromD, pathInPoseFrame, pathInWorld, pathIntersect, pathIntersectsPolygon, pathIntersectsRect, pathOriginProjection, pathSubtract, pathToAnchors, pathUnion, pickTopMostHit, pinchZoomAction, planPixelRender, pointInRotatedRect, pointInTextPose, poseRotationOf, pressureToWidth, rainbowVertexColors, rebaseLocalPose, rectCorners, registerCanvasFont2 as registerCanvasFont, registerContentHandler, registerFont2 as registerFont, registerFontOutlines2 as registerFontOutlines, registerNodeShape, renderLabel, renderSceneToCanvas, renderSceneToPixels, resizeAction, resolveColor, resolveDeviceProfile, resolveFillPattern, resolveParams, resolvePatternSpec, resolveRuns, resolveSkeleton, resolveStrokeWidth, resolveTextStyle, resolveVisibility, rgbaToHex, rotateAction, rotateAroundAABBCenter, rotatePathAround, rotatePoint, rotatedRectCorners, rotationDegreesUnit, rotationHandle, roundToCell, runsToDom, runsToMarkdown, runsToPlainText, sampleGradientStops, sampleTrack, sceneFromJSON, sceneNodeClientRect, sceneSelectionStore, sceneToAdapter, scopeBindings, screenToWorld, selectFromLasso, selectionAtLeast, selectionEmpty, selectionIs, setFlagOverRange, shapeCoversPoint, sliceAction, snapPoint, solidVertexColors, specificity, spiro, splitPathByLine, splitSubpaths, springPose, springVertexColors, srgbU8ToOklab, staggerVertexColors, startThresholdDrag, styleAtRange, subscribeGlyphReady2 as subscribeGlyphReady, subscribeImageReady, textCommand, textLineBoxes, tileGrid, toHex8, toRuns, translatePoseViaDescriptor, translateRectPose, tweenPose, tweenVertexColors, unionBounds, unionBoundsPath, unregisterCanvasFont2 as unregisterCanvasFont, unregisterFontOutlines2 as unregisterFontOutlines, useActiveToolContext, useAlign, useAnimator, useArrayAdapter, useAutoCenter, useBooleans, useBooleansAdapter, useCanvasFocus, useCanvasSize, useDecayLoop, useDeviceProfile, useDistribute, useDragGesture, useDragHandle, useDragRadial, useDragRect, useDropZone, useEllipseTool, useEyedropperTool, useGestureDispatcher, useGridCellHover, useGuides, useHandTool, useHandleDrag, useHoverTracking, useImageTool, useKeybindings, useLassoTool, useLineTool, useOptionalActiveToolContext, usePenTool, usePencilTool, usePinchGesture, usePinchZoomTool, usePointerStylus, usePolygonTool, usePublishSelection, useRectTool, useResizePolicy, useRotateTool, useScene, useSceneAdapter, useSceneTextEdit, useSelectTool, useSelection, useSelectionContext, useSimulation, useSliceDep, useStandardActions, useStarTool, useTextEdit, useTextTool, useTools, useVelocityTracker, useViewAnimation, useViewTween, useZoom, verticalAlignOffset, viewToMat3, viewToTransform, viewportDragPanAction, viewportZoomAction, viewportsAt, when, withAlpha01, withCoord, withGradientKind, worldEditToStorage, worldPoseLookup, worldToScreen, zoomAt, zoomAtLeast } from './chunk-7KYLIC3E.js';
2
+ export { ActionDisabledReason, ActionsProvider, DepRegistryProvider, actionBindings, evaluateEnabled, useAction, useActionsRegistry, useDepRegistry, useDepSource, useOptionalDepRegistry } from './chunk-CKADTCHK.js';
3
3
  export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap } from './chunk-CSMF654J.js';
4
4
  export { CORNER_ANCHORS, cornerPoint, cornerResizeHandles, hitCornerHandle, pointSnapToGrid } from './chunk-J7LUY47N.js';
5
5
  export { DEFAULT_FLATTEN_TOLERANCE, DEFAULT_GUIDE_TOLERANCE_PX, IMPERIAL_INCHES, METRIC_MM, PATH_C, PATH_CMD_LENGTHS, PATH_L, PATH_M, PATH_Q, PATH_Z, PIXELS, PathBuilder, RECT_ORIGIN_PROJECTION, RECT_POSE_DESCRIPTOR, ROTATED_POSE_DESCRIPTOR, boundsOfPath, ellipsePath, flattenCubic, flattenCubicWithArcLen, flattenQuadratic, flattenQuadraticWithArcLen, formatUnit, gridSnapStrategy, guideSnapStrategy, linePath, pathPoseDescriptor, pointInPath, pointToGridCell, polygonFromPoints, pxExtent, rectPath, regularPolygonPath, resolveUnit, scaleDelta, scalePathToBounds, starPath, transformPath, translatePath, translatePolygonInPlace, withinPxBox, withinPxRadius } from './chunk-4Z6J4IVH.js';
6
- export { PointerContextProvider, WEASEL_CLIPBOARD_MIME, WEASEL_CLIPBOARD_MIME_WEB, applyOpsTo, buildWeaselClipboardText, dispatchApplyBatch, dlog, dwarn, embedWeaselMetadataInSvg, extractWeaselClipboardFromSvg, isDebugEnabled, parseWeaselClipboardText, sniffWeaselClipboardText, useClipboardOps, usePointerContext } from './chunk-JOSUVS6C.js';
6
+ export { PointerContextProvider, WEASEL_CLIPBOARD_MIME, WEASEL_CLIPBOARD_MIME_WEB, applyOpsTo, buildWeaselClipboardText, dispatchApplyBatch, dlog, dwarn, embedWeaselMetadataInSvg, extractWeaselClipboardFromSvg, isDebugEnabled, parseWeaselClipboardText, sniffWeaselClipboardText, useClipboardOps, usePointerContext } from './chunk-ADWOB5K2.js';
7
7
  export { cloneByAltDrag } from './chunk-UGFFCMQP.js';
8
8
  export { createSetSelectionOp } from './chunk-BHVYVFGV.js';
9
9
  export { createDeleteOp, createInsertOp, rebuildOp, registerOpFactory } from './chunk-GVCNT7UH.js';
@@ -184,17 +184,22 @@ type StrokeAlign = 'center' | 'inner' | 'outer';
184
184
  /** Stroke style: a FillStyle plus structural line parameters. */
185
185
  interface Stroke {
186
186
  paint: FillStyle;
187
- width?: number;
187
+ /** World units, or `{ px }` for screen pixels — resolved against the
188
+ * accumulated transform scale at draw time, so it holds its on-screen
189
+ * thickness as the view zooms. */
190
+ width?: number | {
191
+ px: number;
192
+ };
188
193
  /** Per `CanvasRenderingContext2D.setLineDash` — empty/omitted = solid. */
189
194
  dash?: number[];
190
195
  cap?: 'butt' | 'round' | 'square';
191
196
  join?: 'miter' | 'round' | 'bevel';
192
197
  /**
193
198
  * Miter join fallback threshold. When the miter length exceeds
194
- * `miterLimit * width / 2`, the join falls back to a bevel. Default 10
195
- * (matching Canvas2D). SVG's default is 4; consumers that want SVG
196
- * fidelity should set this explicitly when constructing strokes from
197
- * SVG sources where the attribute was omitted.
199
+ * `miterLimit * width / 2`, the join falls back to a bevel. Default 4,
200
+ * matching SVG which is also what the kit's own serializer implies when
201
+ * it omits the attribute for an unset field. Canvas2D's 10 lets an acute
202
+ * corner throw a spike four times the half-width.
198
203
  */
199
204
  miterLimit?: number;
200
205
  /** Where the stroke sits relative to the geometric edge. Default `'center'`. */
@@ -1,4 +1,4 @@
1
- import { T as TilePatternSpec, a as TextureHandle } from './paint-types-CnLIzqq1.js';
1
+ import { T as TilePatternSpec, a as TextureHandle } from './paint-types-1fUdZUaH.js';
2
2
 
3
3
  /**
4
4
  * The shapes a built-in tile is made of, as data.
@@ -1,4 +1,4 @@
1
- import { N as NodeId, R as RectPose, S as Scene } from './types-vqxpCFVp.js';
1
+ import { N as NodeId, R as RectPose, S as Scene } from './types-C2R2bjxf.js';
2
2
  import { M as ModifierState, A as ActionBehavior, c as ResizeAnchor, R as ResizePose, B as BoundsConstraint, P as PointSnapBehavior } from './types-BhrifbZ1.js';
3
3
  import { V as View } from './view-DSQgxBJB.js';
4
4
  import { CapabilityTag } from '@weasel-js/modes';
@@ -6,8 +6,8 @@ import * as React from 'react';
6
6
  import { MutableRefObject, ReactNode, ReactElement } from 'react';
7
7
  import { GestureSpec, IngestItem, InputEvent } from '@weasel-js/gestures';
8
8
  import { B as Bounds, P as PoseProjection } from './geometry-C56YbnfD.js';
9
- import { F as FillStyle, S as Stroke } from './paint-types-CnLIzqq1.js';
10
- import { D as DrawCommand } from './DrawCommand-BbPrSTra.js';
9
+ import { F as FillStyle, S as Stroke } from './paint-types-1fUdZUaH.js';
10
+ import { D as DrawCommand } from './DrawCommand-uNkv5TjO.js';
11
11
  import * as react_jsx_runtime from 'react/jsx-runtime';
12
12
  import { P as Path } from './path-B6MMiodD.js';
13
13
  import { Op, History } from '@weasel-js/history';
@@ -15,11 +15,6 @@ import { L as LayoutStrategy, I as InsertAdapter } from './types-DbysOO-2.js';
15
15
  import { D as DebugSink } from './types-BHK2dkMu.js';
16
16
  import { Mat3 } from '@weasel-js/geom';
17
17
 
18
- /**
19
- * Read-only state that affordances consult on every render and hit-test
20
- * call. Built once per Canvas render via `buildChromeState`; affordances
21
- * must not cache it across calls.
22
- */
23
18
  interface ChromeState {
24
19
  /** Currently selected ids. Live; reflects useSelection's React state. */
25
20
  readonly selection: readonly NodeId[];
@@ -282,13 +277,21 @@ interface Dims {
282
277
  width: number;
283
278
  height: number;
284
279
  }
280
+ /** One layer's memoized output, keyed by layer id. Owned by the canvas that
281
+ * calls `drawLayers`, not by `drawLayers` itself — the function is pure. */
282
+ type LayerCommandCache = Map<string, {
283
+ deps: readonly unknown[];
284
+ cmds: DrawCommand[];
285
+ }>;
285
286
  /**
286
287
  * A single named render sub-layer within a canvas renderer.
287
288
  *
288
289
  * @template TData - The data object passed to each draw call.
289
290
  */
290
291
  interface RenderLayer<TData> {
291
- /** Unique identifier used in visibility maps and ordering arrays. */
292
+ /** Unique identifier used in visibility maps and ordering arrays. When a
293
+ * cache is in use, an id must identify the same logical layer across
294
+ * frames — reusing it for a different layer can serve cross-layer commands. */
292
295
  id: string;
293
296
  /** Human-readable name for UI toggles. */
294
297
  label: string;
@@ -306,6 +309,21 @@ interface RenderLayer<TData> {
306
309
  * subset manually with `viewToMat3(view)`.
307
310
  */
308
311
  draw: (data: TData, view: View, dims: Dims) => DrawCommand[];
312
+ /**
313
+ * Optional cache key. When present and a `LayerCommandCache` is supplied to
314
+ * `drawLayers`, the layer's previous `DrawCommand[]` is reused as long as
315
+ * every entry is `Object.is`-equal to the previous call's. A layer with no
316
+ * `deps` rebuilds on every frame.
317
+ *
318
+ * **The returned commands must be treated as immutable.** A cached tree is
319
+ * handed to the renderer again on later frames, so mutating a tree you
320
+ * previously returned corrupts the cache silently rather than erroring.
321
+ *
322
+ * **Screen-space layers are not protected against a stale `view`/`dims`
323
+ * the way world-space layers are** (see `space` below) — include them in
324
+ * `deps` if `draw` reads them.
325
+ */
326
+ deps?: (data: TData, view: View, dims: Dims) => readonly unknown[];
309
327
  /**
310
328
  * Whether the layer is shown when no explicit visibility entry exists.
311
329
  * Defaults to `true` when absent.
@@ -379,7 +397,26 @@ interface RenderLayer<TData> {
379
397
  * `viewToMat3(view)` before they reach the renderer. Screen-space layers
380
398
  * (`space: 'screen'`) pass through unchanged.
381
399
  */
382
- declare function drawLayers<TData>(layers: RenderLayer<TData>[], data: TData, visibility: Record<string, boolean>, order: string[] | undefined, view: View | undefined, dims: Dims): DrawCommand[];
400
+ declare function drawLayers<TData>(layers: RenderLayer<TData>[], data: TData, visibility: Record<string, boolean>, order: string[] | undefined, view: View | undefined, dims: Dims, cache?: LayerCommandCache): DrawCommand[];
401
+ /**
402
+ * Resolve one layer's visibility: `alwaysOn` wins, then an explicit entry in
403
+ * `visibility`, then `defaultVisible`, defaulting to shown.
404
+ *
405
+ * Hit-testing asks this too. A layer that is hidden but still claims pointer
406
+ * events is a pointer landing on nothing the user can see.
407
+ */
408
+ declare function isLayerVisible<TData>(layer: RenderLayer<TData>, visibility: Record<string, boolean>): boolean;
409
+ /**
410
+ * Draw one layer and put its commands in the space its `space` declares:
411
+ * world-space output wrapped in a `viewToMat3(view)` group, screen-space
412
+ * output passed through.
413
+ *
414
+ * Anything rendering layers through a view — the canvas itself, a viewport
415
+ * node's inner pass — goes through here. A second copy of this rule that
416
+ * forgets the wrap draws world content at raw world coords, which looks
417
+ * plausible at the identity view and wrong everywhere else.
418
+ */
419
+ declare function drawOneLayer<TData>(layer: RenderLayer<TData>, data: TData, view: View, dims: Dims, cache?: LayerCommandCache): DrawCommand[];
383
420
 
384
421
  /**
385
422
  * Facts about the device the canvas is running on.
@@ -804,6 +841,9 @@ interface BindingOpts {
804
841
  * via `resolveParams(opts?.params)`. */
805
842
  params?: Record<string, unknown> | (() => Record<string, unknown>);
806
843
  }
844
+ /** Resolve `BindingOpts.params` to a concrete record (calling the thunk if
845
+ * needed). Returns `undefined` for absent params. */
846
+ declare function resolveParams(params: BindingOpts['params']): Record<string, unknown> | undefined;
807
847
  /** Convention-shaped action dependencies bag. Actions declare which
808
848
  * contexts they consume; the dispatcher composes them per call.
809
849
  * Consumer-side contexts (e.g. ColorContext) plug in by extending. */
@@ -1232,6 +1272,13 @@ interface SelectionApi {
1232
1272
  setSelection: (ids: NodeId[]) => void;
1233
1273
  };
1234
1274
  }
1275
+ /** Somewhere selection can live outside this hook. `Scene` satisfies it;
1276
+ * so does any store with the same three methods. */
1277
+ interface SelectionStore {
1278
+ getSelection(): readonly NodeId[];
1279
+ setSelection(ids: readonly NodeId[]): void;
1280
+ subscribe(listener: () => void): () => void;
1281
+ }
1235
1282
  /** Options for {@link useSelection}. */
1236
1283
  interface UseSelectionOptions {
1237
1284
  /** Default `'single'`. */
@@ -1240,6 +1287,11 @@ interface UseSelectionOptions {
1240
1287
  extend?: SelectionExtendKey;
1241
1288
  /** Default `[]`. */
1242
1289
  initial?: readonly NodeId[];
1290
+ /** Keep the selection on this store rather than in the hook, so every
1291
+ * consumer of the same scene shares one selection and undo / redo can
1292
+ * restore it. `initial` then only seeds a store that has none yet.
1293
+ * Omit it and the hook owns a selection nobody else sees. */
1294
+ scene?: SelectionStore;
1243
1295
  /** When `true`, every mutator (`set`/`add`/`remove`/`toggle`/`clear`/
1244
1296
  * `applyClick`) is a no-op — selection stays at whatever `initial`
1245
1297
  * pinned it to. Useful for demos that exist to showcase a single
@@ -2812,6 +2864,12 @@ type BoundGesture = GestureSpec | {
2812
2864
  spec: GestureSpec;
2813
2865
  opts: BindingOpts;
2814
2866
  };
2867
+ /**
2868
+ * @experimental
2869
+ * Flatten an action's `defaultBinding` into `GestureBinding`s. A bare
2870
+ * `GestureSpec` has `kind` at top level; the object form has `spec`.
2871
+ */
2872
+ declare function actionBindings(action: Action): GestureBinding[];
2815
2873
  /**
2816
2874
  * @experimental
2817
2875
  * Single registered action. v1: one binding per action.
@@ -3043,4 +3101,4 @@ declare function useActionsRegistry(): ActionsRegistry | null;
3043
3101
  */
3044
3102
  declare function useAction(action: Action): void;
3045
3103
 
3046
- export { type BooleanOp as $, type Action as A, type BooleansAdapter as B, type Condition as C, type Dims as D, type Eligibility as E, ALWAYS as F, type GeometryProjection as G, type HotkeyTrigger as H, type InsertExtras as I, type ActionDeps as J, ActionDisabledReason as K, type LayerHit as L, type ActionEnabledResult as M, type ActionEntry as N, type OverlayPosition as O, ActionsProvider as P, ActiveToolContextProvider as Q, type RenderLayer as R, type SliceDep as S, type Tool as T, type UseSelectionOptions as U, type VisibilityRules as V, ActiveToolContextProviderIfRoot as W, type ActiveToolContextProviderProps as X, type ActiveToolContextValue as Y, type AreaSelectDep as Z, type BindingOpts as _, type DeviceProfile as a, evaluateEnabled as a$, type BooleanOpResult as a0, type BoundGesture as a1, type BuildRuleCtxArgs as a2, type ClaimableGesture as a3, type ClipboardDep as a4, type ClipboardIngestCtx as a5, type CustomPaintContext as a6, type DepName as a7, type DepRegistry as a8, DepRegistryProvider as a9, type ResolveAllOptions as aA, type ResolveOnlyResult as aB, type ResolvedCandidate as aC, type SelectionExtendKey as aD, type SelectionMode as aE, type Selector as aF, type SnapDep as aG, type SvgUnpacker as aH, type TextEditDep as aI, type ToolCtx as aJ, type ToolModifiers as aK, type ToolPresentation as aL, type ToolSlot as aM, type UiOngoingControl as aN, type ViewApi as aO, applyBooleanOp as aP, buildRuleCtx as aQ, clipboardCopyAction as aR, clipboardCutAction as aS, composeRectPose as aT, composeWorldPose as aU, createDispatcher as aV, decomposeRectPose as aW, describeRule as aX, drawLayers as aY, enterTextEditAction as aZ, evaluate as a_, type DispatcherContext as aa, type DragSample as ab, type EditAnchorsDep as ac, type GestureBinding as ad, IDENTITY_POSE_COMPOSITION as ae, type ImmediateInvoker as af, type IngestCtx as ag, type IngestionDep as ah, type InsertDep as ai, type InvocationCtx as aj, type Invoker as ak, type LassoSelectDep as al, type LayoutDep as am, type MatchResult as an, NEVER as ao, type NodeAtPointDep as ap, type OngoingHandle as aq, type OngoingInvoker as ar, type OngoingOverlay as as, type Point2 as at, PointerContextProvider as au, type PointerContextValue as av, type PointerWorldPos as aw, type PoseAdapter as ax, type PoseComposition as ay, type ResizePolicy as az, type DetectedDeviceFacts as b, rebaseLocalPose as b0, registerContentHandler as b1, sliceAction as b2, specificity as b3, translateRectPose as b4, useAction as b5, useActionsRegistry as b6, useActiveToolContext as b7, useDepRegistry as b8, useDepSource as b9, useOptionalActiveToolContext as ba, useOptionalDepRegistry as bb, usePointerContext as bc, useSelection as bd, worldPoseLookup as be, type Rule as c, type RuleCtx as d, type ChromeCtx as e, type ChromeId as f, type DepSchema as g, type ActionsRegistry as h, type AffordanceHit as i, type Dispatcher as j, type ToolDef as k, type ViewportToolDef as l, type AnyTool as m, type ToolKeybinding as n, type ChromeState as o, type SelectionApi as p, type ContentHandlerEntry as q, type SvgIngestOptions as r, type ActionsProp as s, type Affordance as t, type AffordanceRegion as u, type AffordanceBinding as v, type CommonAffordanceScratch as w, type BindingScope as x, type Contribution as y, type ScopedBinding as z };
3104
+ export { type BooleanOp as $, type Action as A, type BooleansAdapter as B, type Condition as C, type Dims as D, type Eligibility as E, ALWAYS as F, type GeometryProjection as G, type HotkeyTrigger as H, type InsertExtras as I, type ActionDeps as J, ActionDisabledReason as K, type LayerHit as L, type ActionEnabledResult as M, type ActionEntry as N, type OverlayPosition as O, ActionsProvider as P, ActiveToolContextProvider as Q, type RenderLayer as R, type SliceDep as S, type Tool as T, type UseSelectionOptions as U, type VisibilityRules as V, ActiveToolContextProviderIfRoot as W, type ActiveToolContextProviderProps as X, type ActiveToolContextValue as Y, type AreaSelectDep as Z, type BindingOpts as _, type DeviceProfile as a, drawOneLayer as a$, type BooleanOpResult as a0, type BoundGesture as a1, type BuildRuleCtxArgs as a2, type ClaimableGesture as a3, type ClipboardDep as a4, type ClipboardIngestCtx as a5, type CustomPaintContext as a6, type DepName as a7, type DepRegistry as a8, DepRegistryProvider as a9, type ResizePolicy as aA, type ResolveAllOptions as aB, type ResolveOnlyResult as aC, type ResolvedCandidate as aD, type SelectionExtendKey as aE, type SelectionMode as aF, type Selector as aG, type SnapDep as aH, type SvgUnpacker as aI, type TextEditDep as aJ, type ToolCtx as aK, type ToolModifiers as aL, type ToolPresentation as aM, type ToolSlot as aN, type UiOngoingControl as aO, type ViewApi as aP, actionBindings as aQ, applyBooleanOp as aR, buildRuleCtx as aS, clipboardCopyAction as aT, clipboardCutAction as aU, composeRectPose as aV, composeWorldPose as aW, createDispatcher as aX, decomposeRectPose as aY, describeRule as aZ, drawLayers as a_, type DispatcherContext as aa, type DragSample as ab, type EditAnchorsDep as ac, type GestureBinding as ad, IDENTITY_POSE_COMPOSITION as ae, type ImmediateInvoker as af, type IngestCtx as ag, type IngestionDep as ah, type InsertDep as ai, type InvocationCtx as aj, type Invoker as ak, type LassoSelectDep as al, type LayerCommandCache as am, type LayoutDep as an, type MatchResult as ao, NEVER as ap, type NodeAtPointDep as aq, type OngoingHandle as ar, type OngoingInvoker as as, type OngoingOverlay as at, type Point2 as au, PointerContextProvider as av, type PointerContextValue as aw, type PointerWorldPos as ax, type PoseAdapter as ay, type PoseComposition as az, type DetectedDeviceFacts as b, enterTextEditAction as b0, evaluate as b1, evaluateEnabled as b2, isLayerVisible as b3, rebaseLocalPose as b4, registerContentHandler as b5, resolveParams as b6, sliceAction as b7, specificity as b8, translateRectPose as b9, useAction as ba, useActionsRegistry as bb, useActiveToolContext as bc, useDepRegistry as bd, useDepSource as be, useOptionalActiveToolContext as bf, useOptionalDepRegistry as bg, usePointerContext as bh, useSelection as bi, worldPoseLookup as bj, type Rule as c, type RuleCtx as d, type ChromeCtx as e, type ChromeId as f, type DepSchema as g, type ActionsRegistry as h, type AffordanceHit as i, type Dispatcher as j, type ToolDef as k, type ViewportToolDef as l, type AnyTool as m, type ToolKeybinding as n, type ChromeState as o, type SelectionApi as p, type ContentHandlerEntry as q, type SvgIngestOptions as r, type ActionsProp as s, type Affordance as t, type AffordanceRegion as u, type AffordanceBinding as v, type CommonAffordanceScratch as w, type BindingScope as x, type Contribution as y, type ScopedBinding as z };
@@ -1,9 +1,9 @@
1
- import { I as ImageMinification, G as GLImageCache } from './viewToMat3-CQW_YqDw.js';
2
- export { V as ViewLike, v as viewToMat3 } from './viewToMat3-CQW_YqDw.js';
3
- import { G as GradStop, S as Stroke } from './paint-types-CnLIzqq1.js';
4
- export { a as TextureHandle, r as registerTexture } from './paint-types-CnLIzqq1.js';
5
- import { M as Mat3, S as ShaderProgramHandle, D as DrawCommand } from './DrawCommand-BbPrSTra.js';
6
- export { G as GroupDrawCommand, I as ImageDrawCommand, P as PathDrawCommand, a as ShaderDrawCommand, b as ShaderUniform, c as SolidPaint, T as TextDrawCommand, m as mat3, r as registerProgram } from './DrawCommand-BbPrSTra.js';
1
+ import { M as Mesh, I as ImageMinification, G as GLImageCache } from './stroke-DaxnQ-u7.js';
2
+ export { S as SpriteSheet, a as StrokeOptions, V as ViewLike, f as frameRect, t as tessellateStroke, v as viewToMat3 } from './stroke-DaxnQ-u7.js';
3
+ import { G as GradStop } from './paint-types-1fUdZUaH.js';
4
+ export { a as TextureHandle, r as registerTexture } from './paint-types-1fUdZUaH.js';
5
+ import { M as Mat3, S as ShaderProgramHandle, D as DrawCommand } from './DrawCommand-uNkv5TjO.js';
6
+ export { G as GroupDrawCommand, I as ImageDrawCommand, P as PathDrawCommand, a as ShaderDrawCommand, b as ShaderUniform, c as SolidPaint, T as TextDrawCommand, m as mat3, r as registerProgram } from './DrawCommand-uNkv5TjO.js';
7
7
  import { P as Path } from './path-B6MMiodD.js';
8
8
  export { canQueryLocalFonts, enableLocalFontOutlines, hasFontOutlines, isCanvasFont, listFontOutlines, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, subscribeGlyphReady, unregisterCanvasFont, unregisterFontOutlines } from '@weasel-js/font';
9
9
 
@@ -36,35 +36,6 @@ declare class ShaderProgram {
36
36
  attribute(name: string): number | undefined;
37
37
  }
38
38
 
39
- /**
40
- * A tessellated representation of a Path, ready to upload to GL.
41
- *
42
- * - `vertices` is interleaved x,y in path-local coordinates (`Float32Array`
43
- * of length `2 * vertexCount`).
44
- * - `indices` are triangle indices into `vertices` (`Uint32Array`, length
45
- * `3 * triangleCount`).
46
- * - `requiresStencil` is set for paths whose fillRule is `'evenodd'` and
47
- * whose triangulation is a *naive* per-contour fan rather than a clean
48
- * inside/outside triangulation. The renderer must use a stencil
49
- * two-pass when this flag is true. Single-contour paths and `'nonzero'`
50
- * multi-contour paths leave it false.
51
- * - `anchorA` / `anchorB` / `anchorT` parameterize each mesh vertex by
52
- * the two consecutive path anchors it lies between and the arc-length
53
- * fraction along that segment (0 = at A, 1 = at B). Vertices that fall
54
- * exactly on an anchor set A === B and t = 0. Used at draw time when
55
- * the DrawCommand supplies per-anchor colors so the renderer can lerp
56
- * per mesh vertex. Optional — emitted by the path tessellators; absent
57
- * on meshes built by other paths (e.g. text glyphs).
58
- */
59
- interface Mesh {
60
- readonly vertices: Float32Array;
61
- readonly indices: Uint32Array;
62
- readonly requiresStencil?: boolean;
63
- readonly anchorA?: Uint32Array;
64
- readonly anchorB?: Uint32Array;
65
- readonly anchorT?: Float32Array;
66
- }
67
-
68
39
  interface GLMeshHandle {
69
40
  readonly vao: WebGLVertexArrayObject;
70
41
  readonly indexCount: number;
@@ -475,23 +446,6 @@ interface TessellateOptions {
475
446
  * line segments, then the resulting polygon triangulated. */
476
447
  declare function tessellate(path: Path, opts?: TessellateOptions): Mesh;
477
448
 
478
- /** Options for stroke tessellation. */
479
- interface StrokeOptions {
480
- flattenTolerance?: number;
481
- }
482
- /**
483
- * Build a triangle-mesh ribbon from a stroked Path.
484
- *
485
- * Supports:
486
- * - cap: 'butt' | 'round' | 'square'
487
- * - join: 'miter' | 'round' | 'bevel'
488
- * - center alignment directly; RectPath inner/outer alignment via a
489
- * pre-shifted rect; PolygonPath inner/outer alignment via stencil at the
490
- * renderer level
491
- * - dash splitting
492
- */
493
- declare function tessellateStroke(path: Path, stroke: Stroke, opts?: StrokeOptions): Mesh;
494
-
495
449
  /**
496
450
  * On-screen glyph size (CSS px) at or above which a face with registered
497
451
  * outlines is drawn as geometry instead of sampled from a distance field.
@@ -507,4 +461,4 @@ declare function tessellateStroke(path: Path, stroke: Stroke, opts?: StrokeOptio
507
461
  */
508
462
  declare const OUTLINE_MIN_SCREEN_PX = 48;
509
463
 
510
- export { DrawCommand, IDENTITY_COLOR_MATRIX, ImageMinification, Mat3, type Mesh, OUTLINE_MIN_SCREEN_PX, ShaderCompileError, ShaderProgramHandle, type StrokeOptions, type TessellateOptions, WeaselRenderer, type WeaselRendererOptions, buildGradientRamp, tessellate, tessellateStroke };
464
+ export { DrawCommand, IDENTITY_COLOR_MATRIX, ImageMinification, Mat3, Mesh, OUTLINE_MIN_SCREEN_PX, ShaderCompileError, ShaderProgramHandle, type TessellateOptions, WeaselRenderer, type WeaselRendererOptions, buildGradientRamp, tessellate };
package/dist/renderer.js CHANGED
@@ -1,9 +1,9 @@
1
- export { IDENTITY_COLOR_MATRIX, OUTLINE_MIN_SCREEN_PX, ShaderCompileError, WeaselRenderer, buildGradientRamp, canQueryLocalFonts, enableLocalFontOutlines, hasFontOutlines, isCanvasFont, listFontOutlines, mat3, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, registerProgram, subscribeGlyphReady, tessellate, tessellateStroke, unregisterCanvasFont, unregisterFontOutlines, viewToMat3 } from './chunk-3B4QEB2G.js';
2
- import './chunk-J3YC3GVF.js';
1
+ export { IDENTITY_COLOR_MATRIX, OUTLINE_MIN_SCREEN_PX, ShaderCompileError, WeaselRenderer, buildGradientRamp, canQueryLocalFonts, enableLocalFontOutlines, frameRect, hasFontOutlines, isCanvasFont, listFontOutlines, mat3, outlineStatus, registerCanvasFont, registerFont, registerFontOutlines, registerProgram, subscribeGlyphReady, tessellate, tessellateStroke, unregisterCanvasFont, unregisterFontOutlines, viewToMat3 } from './chunk-7KYLIC3E.js';
2
+ import './chunk-CKADTCHK.js';
3
3
  import './chunk-CSMF654J.js';
4
4
  import './chunk-J7LUY47N.js';
5
5
  import './chunk-4Z6J4IVH.js';
6
- import './chunk-JOSUVS6C.js';
6
+ import './chunk-ADWOB5K2.js';
7
7
  import './chunk-UGFFCMQP.js';
8
8
  import './chunk-BHVYVFGV.js';
9
9
  import './chunk-GVCNT7UH.js';
package/dist/routing.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ParsedModifiers, GestureName, GestureSpec } from '@weasel-js/gestures';
2
2
  export { ChannelRef, DescribeRouteOptions, GESTURE_DESCRIPTORS, GestureArgSpec, GestureDescriptor, GestureName, ModRequirement, ModifierKey, ParsedModifiers, ParsedRoute, PhaseAtom, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, RouteDescriptionPart, RouteFieldName, RouteTermLabel, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute } from '@weasel-js/gestures';
3
- import { T as Tool } from './registry-DGBrjGbB.js';
4
- import './types-vqxpCFVp.js';
3
+ import { T as Tool } from './registry-l3JX0Z6b.js';
4
+ import './types-C2R2bjxf.js';
5
5
  import '@weasel-js/history';
6
6
  import './path-B6MMiodD.js';
7
7
  import './types-BhrifbZ1.js';
@@ -10,8 +10,8 @@ import './view-DSQgxBJB.js';
10
10
  import '@weasel-js/modes';
11
11
  import 'react';
12
12
  import './geometry-C56YbnfD.js';
13
- import './paint-types-CnLIzqq1.js';
14
- import './DrawCommand-BbPrSTra.js';
13
+ import './paint-types-1fUdZUaH.js';
14
+ import './DrawCommand-uNkv5TjO.js';
15
15
  import 'react/jsx-runtime';
16
16
  import './types-BHK2dkMu.js';
17
17
  import '@weasel-js/geom';
package/dist/routing.js CHANGED
@@ -1,3 +1,3 @@
1
- export { GESTURE_DESCRIPTORS, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute } from './chunk-J3YC3GVF.js';
1
+ export { GESTURE_DESCRIPTORS, RESERVED_ID_NAMES, RESERVED_ID_PREFIXES, ROUTE_FIELD_DEFINITIONS, ROUTE_TERMS, buildRouteRegistry, canonicalModifiers, collapseShiftPairs, describeRoute, describeRouteParts, findConflicts, formatPhaseAtom, formatRoute, getGestureDescriptor, isKnownGestureName, parseRoute } from './chunk-CKADTCHK.js';
2
2
  //# sourceMappingURL=routing.js.map
3
3
  //# sourceMappingURL=routing.js.map
@@ -0,0 +1,153 @@
1
+ import { M as Mat3 } from './DrawCommand-uNkv5TjO.js';
2
+ import { P as Path } from './path-B6MMiodD.js';
3
+ import { S as Stroke } from './paint-types-1fUdZUaH.js';
4
+
5
+ /**
6
+ * A tessellated representation of a Path, ready to upload to GL.
7
+ *
8
+ * - `vertices` is interleaved x,y in path-local coordinates (`Float32Array`
9
+ * of length `2 * vertexCount`).
10
+ * - `indices` are triangle indices into `vertices` (`Uint32Array`, length
11
+ * `3 * triangleCount`).
12
+ * - `requiresStencil` is set for paths whose fillRule is `'evenodd'` and
13
+ * whose triangulation is a *naive* per-contour fan rather than a clean
14
+ * inside/outside triangulation. The renderer must use a stencil
15
+ * two-pass when this flag is true. Single-contour paths and `'nonzero'`
16
+ * multi-contour paths leave it false.
17
+ * - `anchorA` / `anchorB` / `anchorT` parameterize each mesh vertex by
18
+ * the two consecutive path anchors it lies between and the arc-length
19
+ * fraction along that segment (0 = at A, 1 = at B). Vertices that fall
20
+ * exactly on an anchor set A === B and t = 0. Used at draw time when
21
+ * the DrawCommand supplies per-anchor colors so the renderer can lerp
22
+ * per mesh vertex. Optional — emitted by the path tessellators; absent
23
+ * on meshes built by other paths (e.g. text glyphs).
24
+ */
25
+ interface Mesh {
26
+ readonly vertices: Float32Array;
27
+ readonly indices: Uint32Array;
28
+ readonly requiresStencil?: boolean;
29
+ readonly anchorA?: Uint32Array;
30
+ readonly anchorB?: Uint32Array;
31
+ readonly anchorT?: Float32Array;
32
+ }
33
+
34
+ /**
35
+ * GL texture upload cache for ImageBitmap objects.
36
+ *
37
+ * Key: ImageBitmap (or pattern source object) identity (WeakMap) — lets GC
38
+ * reclaim unreferenced bitmaps. The GL textures are NOT freed when the source
39
+ * is gc'd; deferred to v2.
40
+ *
41
+ * Wrapping is set once at upload time per the `repetition` parameter:
42
+ * - undefined / 'no-repeat' → CLAMP_TO_EDGE
43
+ * - 'repeat' → REPEAT (both axes)
44
+ * - 'repeat-x' → REPEAT on S, CLAMP on T
45
+ * - 'repeat-y' → CLAMP on S, REPEAT on T
46
+ *
47
+ * Convention §2: texels stored straight; shader premultiplies.
48
+ */
49
+ type PatternRepetition = 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
50
+ /** MIN_FILTER strategy for uploaded textures. */
51
+ type ImageMinification = 'linear' | 'mipmap';
52
+ type TexSource = ImageBitmap | ImageData | HTMLCanvasElement | HTMLImageElement;
53
+ declare class GLImageCache {
54
+ private readonly gl;
55
+ private readonly minification;
56
+ private readonly map;
57
+ /** `minification` selects the MIN_FILTER strategy for uploaded textures.
58
+ * `'linear'` (default) is the screen path's existing behavior. `'mipmap'`
59
+ * generates mipmaps and filters LINEAR_MIPMAP_LINEAR — required for
60
+ * quality minification when a large source bitmap is drawn small (the
61
+ * headless print/export path); bilinear-only minification undersamples
62
+ * and produces moiré. */
63
+ constructor(gl: WebGL2RenderingContext, minification?: ImageMinification);
64
+ upload(key: object, source: TexSource, repetition?: PatternRepetition): WebGLTexture;
65
+ bind(key: object, unit: number): void;
66
+ }
67
+
68
+ /**
69
+ * Uniform-grid sprite sheet layout — frame index to the source rect an
70
+ * `ImageDrawCommand` samples. Pure arithmetic over the grid description; it
71
+ * never touches the bitmap.
72
+ */
73
+ /** A sprite sheet's grid. `margin` and `spacing` follow the Tiled / Aseprite
74
+ * tileset convention, so a sheet exported from either describes itself here. */
75
+ interface SpriteSheet {
76
+ frameWidth: number;
77
+ frameHeight: number;
78
+ columns: number;
79
+ /** Empty pixels around the whole grid. Default 0. */
80
+ margin?: number;
81
+ /** Empty pixels between adjacent cells — the gutter that keeps linear
82
+ * sampling off the neighboring frame. Default 0. */
83
+ spacing?: number;
84
+ }
85
+ /**
86
+ * Row-major source rect for frame `index`, counting from 0 at the top-left.
87
+ *
88
+ * `index` is not range-checked and does not wrap: past the last cell this
89
+ * returns a rect below the sheet, which draws as an edge smear. Wrapping is
90
+ * the animation's business (`frameRect(sheet, tick % count)`) — a sheet does
91
+ * not know how many of its cells are filled.
92
+ */
93
+ declare function frameRect(sheet: SpriteSheet, index: number): {
94
+ x: number;
95
+ y: number;
96
+ w: number;
97
+ h: number;
98
+ };
99
+
100
+ /**
101
+ * View → Mat3 helper for layer `draw` implementations on world-space layers.
102
+ *
103
+ * The kit's main package ships a `View` type at
104
+ * `src/core/viewport/view.ts`; we re-declare a structurally compatible
105
+ * shape here to avoid a runtime cross-package import. Exported as
106
+ * `ViewLike` from the package barrel.
107
+ */
108
+
109
+ /** A weasel View — `{x, y, scale: {x, y}}`. Local type to avoid a cross-package import. */
110
+ interface View {
111
+ x: number;
112
+ y: number;
113
+ scale: {
114
+ x: number;
115
+ y: number;
116
+ };
117
+ }
118
+ /**
119
+ * Build the world→screen transform matrix for a `View`.
120
+ * Use as the `transform` field of a `kind: 'group'` DrawCommand to wrap
121
+ * world-space content emitted from a layer `draw` implementation.
122
+ *
123
+ * Mapping: `screen = (world − {view.x, view.y}) × {view.scale.x, view.scale.y}`.
124
+ *
125
+ * Column-major layout (matches `mat3.identity()`):
126
+ * `[scale.x, 0, 0, 0, scale.y, 0, -view.x*scale.x, -view.y*scale.y, 1]`.
127
+ */
128
+ declare function viewToMat3(view: View): Mat3;
129
+
130
+ /** Options for stroke tessellation. */
131
+ interface StrokeOptions {
132
+ flattenTolerance?: number;
133
+ }
134
+ /** Resolve a stroke width to world units. A number is already world units;
135
+ * `{ px }` is screen pixels divided by the accumulated scale, so it holds its
136
+ * on-screen thickness as the view zooms. */
137
+ declare function resolveStrokeWidth(width: number | {
138
+ px: number;
139
+ }, scale: number): number;
140
+ /**
141
+ * Build a triangle-mesh ribbon from a stroked Path.
142
+ *
143
+ * Supports:
144
+ * - cap: 'butt' | 'round' | 'square'
145
+ * - join: 'miter' | 'round' | 'bevel'
146
+ * - center alignment directly; RectPath inner/outer alignment via a
147
+ * pre-shifted rect; PolygonPath inner/outer alignment via stencil at the
148
+ * renderer level
149
+ * - dash splitting
150
+ */
151
+ declare function tessellateStroke(path: Path, stroke: Stroke, opts?: StrokeOptions): Mesh;
152
+
153
+ export { GLImageCache as G, type ImageMinification as I, type Mesh as M, type SpriteSheet as S, type View as V, type StrokeOptions as a, frameRect as f, resolveStrokeWidth as r, tessellateStroke as t, viewToMat3 as v };
@@ -323,6 +323,14 @@ interface Scene<TData, TLayer extends string, TPose = RectPose> {
323
323
  * `SceneCanvasAdapter`). Pass `this` from `sceneToAdapter` or a compatible
324
324
  * adapter. */
325
325
  applyBatch(ops: Op[], label: string, adapter: unknown): void;
326
+ /** The transient set of active ids — "operate on these N as a unit".
327
+ * Shared by every view over this scene unless a view supplies its own
328
+ * (see `CanvasView.selection`). Not document content: it never appears
329
+ * in `toJSON`. It does ride on history entries, so undo and redo put
330
+ * back the selection an edit was made under; changing it is never an
331
+ * undo step of its own. */
332
+ getSelection(): readonly NodeId[];
333
+ setSelection(ids: readonly NodeId[]): void;
326
334
  undo(): boolean;
327
335
  redo(): boolean;
328
336
  canUndo(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weasel-js/core",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Domain-agnostic 2D scene graph primitives for React: viewport math, drag/resize/insert/clone interactions, layered canvas rendering.",
5
5
  "license": "MIT",
6
6
  "author": "orochi235",
@@ -74,11 +74,11 @@
74
74
  "react": ">=18"
75
75
  },
76
76
  "dependencies": {
77
- "@weasel-js/font": "1.1.0",
78
- "@weasel-js/geom": "1.1.0",
79
- "@weasel-js/gestures": "1.1.0",
80
- "@weasel-js/history": "1.1.0",
81
- "@weasel-js/modes": "1.1.0",
77
+ "@weasel-js/font": "1.2.0",
78
+ "@weasel-js/geom": "1.2.0",
79
+ "@weasel-js/gestures": "1.2.0",
80
+ "@weasel-js/history": "1.2.0",
81
+ "@weasel-js/modes": "1.2.0",
82
82
  "earcut": "2.2.4",
83
83
  "polygon-clipping": "^0.15.7"
84
84
  },