@weasel-js/core 1.14.2 → 1.15.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.
Files changed (137) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/dist/affordances/pathAnchors.js +0 -1
  3. package/dist/affordances/pathAnchors.js.map +1 -1
  4. package/dist/barrel/paths.js +1 -1
  5. package/dist/barrel/renderer.js +2 -2
  6. package/dist/barrel/routing.js +6 -4
  7. package/dist/barrel/text.js +5 -3
  8. package/dist/canvas/Canvas.js +5 -1
  9. package/dist/canvas/Canvas.js.map +1 -1
  10. package/dist/canvas/DrawCanvas.js +5 -1
  11. package/dist/canvas/DrawCanvas.js.map +1 -1
  12. package/dist/canvas/SceneCanvas/SceneCanvasInput.js +4 -0
  13. package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
  14. package/dist/canvas/SceneCanvas/builtinToolSets.js +6 -3
  15. package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -1
  16. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +1 -1
  17. package/dist/canvas/SceneCanvas/presets/paths.js +6 -6
  18. package/dist/canvas/SceneCanvas/presets/paths.js.map +1 -1
  19. package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js +1 -1
  20. package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js.map +1 -1
  21. package/dist/canvas/SceneCanvas/useBuiltinTools.js +2 -0
  22. package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -1
  23. package/dist/canvas/SceneCanvas/useContributionRoles.js +2 -0
  24. package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -1
  25. package/dist/canvas/SceneCanvas/useSceneChrome.js +17 -5
  26. package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
  27. package/dist/canvas/SceneCanvas/useSceneStandardActions.js +3 -0
  28. package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
  29. package/dist/canvas/SceneCanvas.js +5 -4
  30. package/dist/canvas/SceneCanvas.js.map +1 -1
  31. package/dist/canvas/SceneViewCanvas.js +5 -1
  32. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  33. package/dist/canvas/affordanceAt.js +0 -1
  34. package/dist/canvas/affordanceAt.js.map +1 -1
  35. package/dist/canvas/deps/chromeRules.js +37 -0
  36. package/dist/canvas/deps/chromeRules.js.map +1 -0
  37. package/dist/canvas/deps/editAnchors.js +0 -6
  38. package/dist/canvas/deps/editAnchors.js.map +1 -1
  39. package/dist/canvas/deps/hitTestArea.js +3 -1
  40. package/dist/canvas/deps/hitTestArea.js.map +1 -1
  41. package/dist/canvas/deps/modeDefaultTool.js +23 -0
  42. package/dist/canvas/deps/modeDefaultTool.js.map +1 -0
  43. package/dist/canvas/deps/pathEditCommits.js +1 -1
  44. package/dist/canvas/deps/selectionSnapshot.js +23 -0
  45. package/dist/canvas/deps/selectionSnapshot.js.map +1 -0
  46. package/dist/canvas/deps/snap.js +1 -0
  47. package/dist/canvas/deps/snap.js.map +1 -1
  48. package/dist/canvas/pickReach.js +12 -8
  49. package/dist/canvas/pickReach.js.map +1 -1
  50. package/dist/canvas/pickWalk.js +7 -5
  51. package/dist/canvas/pickWalk.js.map +1 -1
  52. package/dist/canvas/scenePickSource.js +2 -2
  53. package/dist/canvas/scenePickSource.js.map +1 -1
  54. package/dist/canvas/useCanvasSurface.js +21 -3
  55. package/dist/canvas/useCanvasSurface.js.map +1 -1
  56. package/dist/canvas/useFrameLoop.js +6 -7
  57. package/dist/canvas/useFrameLoop.js.map +1 -1
  58. package/dist/canvas/useSurfaceSize.js +4 -3
  59. package/dist/canvas/useSurfaceSize.js.map +1 -1
  60. package/dist/core/geometry/regionHit.js +35 -16
  61. package/dist/core/geometry/regionHit.js.map +1 -1
  62. package/dist/core/scene/editMode.js +4 -1
  63. package/dist/core/scene/editMode.js.map +1 -1
  64. package/dist/core/scene/historyFacade.js +7 -50
  65. package/dist/core/scene/historyFacade.js.map +1 -1
  66. package/dist/core/scene/nodeGates.js +2 -2
  67. package/dist/core/scene/nodeGates.js.map +1 -1
  68. package/dist/core/scene/opTable.js +8 -8
  69. package/dist/core/scene/opTable.js.map +1 -1
  70. package/dist/core/scene/outerOps.js +2 -2
  71. package/dist/core/scene/outerOps.js.map +1 -1
  72. package/dist/core/scene/poseWrites.js +16 -15
  73. package/dist/core/scene/poseWrites.js.map +1 -1
  74. package/dist/core/scene/sceneJournals.js +78 -0
  75. package/dist/core/scene/sceneJournals.js.map +1 -0
  76. package/dist/core/scene/sceneRecording.js +3 -2
  77. package/dist/core/scene/sceneRecording.js.map +1 -1
  78. package/dist/core/viewport/useCanvasSize.js +47 -26
  79. package/dist/core/viewport/useCanvasSize.js.map +1 -1
  80. package/dist/{depSchema-DD9H89gX.d.ts → depSchema-ChQPzEkW.d.ts} +40 -13
  81. package/dist/domains/chrome-caps/resolve.js +1 -0
  82. package/dist/domains/chrome-caps/resolve.js.map +1 -1
  83. package/dist/domains/chrome-caps/useChromeCaps.js +4 -2
  84. package/dist/domains/chrome-caps/useChromeCaps.js.map +1 -1
  85. package/dist/domains/paths/pathEditState.js +0 -24
  86. package/dist/domains/paths/pathEditState.js.map +1 -1
  87. package/dist/domains/snap/probes2d.js +5 -0
  88. package/dist/domains/snap/probes2d.js.map +1 -1
  89. package/dist/domains/snap/sceneReads.js +11 -1
  90. package/dist/domains/snap/sceneReads.js.map +1 -1
  91. package/dist/domains/snap/sceneSession2d.js +4 -2
  92. package/dist/domains/snap/sceneSession2d.js.map +1 -1
  93. package/dist/domains/text/index.js +2 -2
  94. package/dist/icons.table.js +1 -1
  95. package/dist/icons.table.js.map +1 -1
  96. package/dist/icons.table.json +5 -0
  97. package/dist/index.d.ts +112 -60
  98. package/dist/index.js +12 -8
  99. package/dist/interactions/actions/booleans/action.js +4 -2
  100. package/dist/interactions/actions/booleans/action.js.map +1 -1
  101. package/dist/interactions/actions/defaults/anchorEditing.js +3 -6
  102. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  103. package/dist/interactions/actions/defaults/bendSegment.js +1 -2
  104. package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
  105. package/dist/interactions/actions/defaults/exitPathEdit.js +17 -1
  106. package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
  107. package/dist/interactions/actions/edit-anchors/action.js +3 -4
  108. package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
  109. package/dist/interactions/actions/insert/action.js +21 -2
  110. package/dist/interactions/actions/insert/action.js.map +1 -1
  111. package/dist/interactions/actions/insert/params.js +43 -0
  112. package/dist/interactions/actions/insert/params.js.map +1 -0
  113. package/dist/interactions/actions/notices.js +17 -0
  114. package/dist/interactions/actions/notices.js.map +1 -0
  115. package/dist/interactions/actions/outlines/createOutlines.js +8 -6
  116. package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
  117. package/dist/interactions/actions/outlines/createOutlinesAction.js +13 -8
  118. package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -1
  119. package/dist/interactions/actions/outlines/outlineStrokeAction.js +3 -2
  120. package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -1
  121. package/dist/interactions/actions/pathCommands/pathNodes.js +1 -1
  122. package/dist/interactions/actions/testUtils.js +0 -7
  123. package/dist/interactions/actions/testUtils.js.map +1 -1
  124. package/dist/interactions/actions/useNotices.js +13 -0
  125. package/dist/interactions/actions/useNotices.js.map +1 -0
  126. package/dist/test-seams.d.ts +5 -12
  127. package/dist/tools/builtin/anchors/anchorsTool.js +31 -0
  128. package/dist/tools/builtin/anchors/anchorsTool.js.map +1 -0
  129. package/dist/tools/builtin/polygon/usePolygonTool.js +1 -1
  130. package/dist/tools/builtin/star/useStarTool.js +1 -1
  131. package/dist/tools/index.js +4 -2
  132. package/dist/tools/toolOptions.js +47 -0
  133. package/dist/tools/toolOptions.js.map +1 -0
  134. package/dist/version.js +1 -1
  135. package/package.json +25 -25
  136. package/dist/interactions/actions/defaults/pathEditTools.js +0 -60
  137. package/dist/interactions/actions/defaults/pathEditTools.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SceneViewCanvas.js","names":[],"sources":["../../src/canvas/SceneViewCanvas.tsx"],"sourcesContent":["/**\n * `<SceneViewCanvas>` — pointer-inert, read-only render of a `Scene` at a\n * given `View` into its own `<canvas>` DOM element.\n *\n * It paints through `useFrameLoop` rather than from React: a render and an\n * override commit both just mark the surface dirty. The mount paint is\n * synchronous, so the first frame the user sees is the scene, and nothing\n * paints while the canvas is off screen or the tab is hidden.\n */\nimport {\n useCallback,\n useEffect,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport type { Ref } from 'react';\nimport { assignRef } from '@weasel-js/react';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport type { CanvasRendererLease } from './canvasRenderer';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport { useSurfaceSize, type SurfaceSizeProps } from './useSurfaceSize';\nimport { sceneViewFrame } from './sceneViewRender';\nimport type { RenderSceneToCanvasArgs, SceneViewDrawOne, SceneViewLayers } from './sceneViewRender';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { normalizeView, type View } from '../core/viewport/view';\nimport type { Scene } from '../core/scene/types';\nimport type { Animator } from '@weasel-js/animator';\n\n/** Props for `<SceneViewCanvas>`. */\nexport interface SceneViewCanvasProps<TData, TLayer extends string, TPose> extends SurfaceSizeProps {\n /** Scene to render. The component subscribes to it and repaints when it\n * changes. */\n scene: Scene<TData, TLayer, TPose>;\n /** Camera. Applied to scene + `extraCommands` via the renderer's group\n * transform. */\n view: View;\n /** Per-node draw callback. See `SceneViewDrawOne`. The consumer is\n * responsible for what gets painted — there is no AABB-fill default. */\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>;\n /** Optional extra commands appended after scene commands, inside the same\n * view transform — a world-space annotation over the scene. */\n extraCommands?: ReadonlyArray<DrawCommand>;\n /** Optional per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot\n * `alphaFor`. Pass the same function the main canvas uses to keep a\n * scoping-dim treatment consistent across both. Defaults to `() => 1`. */\n alphaFor?: (id: string) => number;\n /** Hide scene layers in this view only, keyed `scene:<layerId>` as on\n * `<SceneCanvas>` — pass the main canvas's map to keep the two in step. */\n layerVisibility?: SceneViewLayers['layerVisibility'];\n /** Paint order for this view, keyed as `layerVisibility`. */\n layerOrder?: SceneViewLayers['layerOrder'];\n /** Skip nodes and commands that cannot reach this view — the scene slot's\n * `cull`. Off by default; worth it when the view shows a small part of a\n * large scene. */\n cull?: boolean;\n /** Where `drawOne`'s output for a node can reach — the scene slot's\n * `paintBounds`. Defaults to `defaultPaintBounds` when `drawOne` is\n * `defaultDrawOne`. */\n paintBounds?: RenderSceneToCanvasArgs<TData, TLayer, TPose>['paintBounds'];\n /** Optional animator, as on `<SceneCanvas>`: the view repaints on its ticks\n * and paints its `colorOverrides`. Pass the main canvas's animator so both\n * show the same colors. */\n animator?: Animator;\n /** Optional CSS class for the `<canvas>`. Its size is `width` × `height`\n * unless a rule on this class sizes it. */\n className?: string;\n /** Forwarded ref to the underlying `<canvas>`. Consumers attach their own\n * pointer listeners or call `toBlob` for snapshots through this. */\n canvasRef?: Ref<HTMLCanvasElement>;\n}\n\nfunction SceneViewCanvasInner<TData, TLayer extends string, TPose>(\n props: SceneViewCanvasProps<TData, TLayer, TPose>,\n) {\n const {\n scene, drawOne, extraCommands, alphaFor, layerVisibility, layerOrder,\n animator, className, canvasRef, cull, paintBounds,\n } = props;\n const view = normalizeView(props.view);\n\n // Subscribe to scene version. The snapshot value isn't used directly —\n // we only need React to re-render the component when the scene mutates.\n useSyncExternalStore(scene.subscribe, scene.getVersion, scene.getVersion);\n\n const localRef = useRef<HTMLCanvasElement | null>(null);\n\n const setCanvasRef = useCallback((el: HTMLCanvasElement | null): void => {\n localRef.current = el;\n assignRef(canvasRef, el);\n }, [canvasRef]);\n const { width, height } = useSurfaceSize(props, localRef);\n\n const paint = (lease: CanvasRendererLease): boolean => {\n const canvas = localRef.current;\n if (!canvas || width === 0 || height === 0) return false;\n const commands = sceneViewFrame({\n scene,\n view,\n width,\n height,\n drawOne,\n extraCommands: extraCommands as DrawCommand[] | undefined,\n alphaFor,\n layerVisibility,\n layerOrder,\n colorOverrides: animator?.colorOverrides,\n cull,\n paintBounds,\n });\n return lease.paint(canvas, commands, view, { width, height });\n };\n const { requestRedraw } = useCanvasSurface(paint, { target: localRef, onCommit: 'paint' });\n\n // Override writes never bump the scene version, so the version subscription\n // above cannot see them.\n useEffect(() => scene.overrides.subscribe(requestRedraw), [scene, requestRedraw]);\n useEffect(() => scene.scroll?.subscribe(requestRedraw), [scene, requestRedraw]);\n useEffect(() => animator?.onTick(requestRedraw), [animator, requestRedraw]);\n\n return (\n <SurfaceCanvas\n ref={setCanvasRef}\n width={props.width}\n height={props.height}\n className={className}\n />\n );\n}\n\n/**\n * Pointer-inert read-only scene view. It attaches no event listeners;\n * consumers attach their own through `canvasRef`, a plain prop because\n * `forwardRef` erases the component's generics. `width` and `height` are CSS\n * pixels and size the drawing buffer; a `className` rule that sizes the\n * element stretches that buffer to fit. Given neither, it fills its parent.\n */\nexport const SceneViewCanvas = SceneViewCanvasInner;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuEA,SAAS,qBACP,OACA;CACA,MAAM,EACJ,OAAO,SAAS,eAAe,UAAU,iBAAiB,YAC1D,UAAU,WAAW,WAAW,MAAM,gBACpC;CACJ,MAAM,OAAO,cAAc,MAAM,IAAI;CAIrC,qBAAqB,MAAM,WAAW,MAAM,YAAY,MAAM,UAAU;CAExE,MAAM,WAAW,OAAiC,IAAI;CAEtD,MAAM,eAAe,aAAa,OAAuC;EACvE,SAAS,UAAU;EACnB,UAAU,WAAW,EAAE;CACzB,GAAG,CAAC,SAAS,CAAC;CACd,MAAM,EAAE,OAAO,WAAW,eAAe,OAAO,QAAQ;CAExD,MAAM,SAAS,UAAwC;EACrD,MAAM,SAAS,SAAS;EACxB,IAAI,CAAC,UAAU,UAAU,KAAK,WAAW,GAAG,OAAO;EACnD,MAAM,WAAW,eAAe;GAC9B;GACA;GACA;GACA;GACA;GACe;GACf;GACA;GACA;GACA,gBAAgB,UAAU;GAC1B;GACA;EACF,CAAC;EACD,OAAO,MAAM,MAAM,QAAQ,UAAU,MAAM;GAAE;GAAO;EAAO,CAAC;CAC9D;CACA,MAAM,EAAE,kBAAkB,iBAAiB,OAAO;EAAE,QAAQ;EAAU,UAAU;CAAQ,CAAC;CAIzF,gBAAgB,MAAM,UAAU,UAAU,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC;CAChF,gBAAgB,MAAM,QAAQ,UAAU,aAAa,GAAG,CAAC,OAAO,aAAa,CAAC;CAC9E,gBAAgB,UAAU,OAAO,aAAa,GAAG,CAAC,UAAU,aAAa,CAAC;CAE1E,OACE,oBAAC,eAAD;EACE,KAAK;EACL,OAAO,MAAM;EACb,QAAQ,MAAM;EACH;CACZ,CAAA;AAEL;;;;;;;;AASA,IAAa,kBAAkB"}
1
+ {"version":3,"file":"SceneViewCanvas.js","names":[],"sources":["../../src/canvas/SceneViewCanvas.tsx"],"sourcesContent":["/**\n * `<SceneViewCanvas>` — pointer-inert, read-only render of a `Scene` at a\n * given `View` into its own `<canvas>` DOM element.\n *\n * It paints through `useFrameLoop` rather than from React: a render and an\n * override commit both just mark the surface dirty. The mount paint is\n * synchronous, so the first frame the user sees is the scene, and nothing\n * paints while the canvas is off screen or the tab is hidden.\n */\nimport {\n useCallback,\n useEffect,\n useRef,\n useSyncExternalStore,\n} from 'react';\nimport type { Ref } from 'react';\nimport { assignRef } from '@weasel-js/react';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport type { CanvasRendererLease } from './canvasRenderer';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport { useSurfaceSize, type SurfaceSizeProps } from './useSurfaceSize';\nimport { sceneViewFrame } from './sceneViewRender';\nimport type { RenderSceneToCanvasArgs, SceneViewDrawOne, SceneViewLayers } from './sceneViewRender';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport { normalizeView, type View } from '../core/viewport/view';\nimport type { Scene } from '../core/scene/types';\nimport type { Animator } from '@weasel-js/animator';\n\n/** Props for `<SceneViewCanvas>`. */\nexport interface SceneViewCanvasProps<TData, TLayer extends string, TPose> extends SurfaceSizeProps {\n /** Scene to render. The component subscribes to it and repaints when it\n * changes. */\n scene: Scene<TData, TLayer, TPose>;\n /** Camera. Applied to scene + `extraCommands` via the renderer's group\n * transform. */\n view: View;\n /** Per-node draw callback. See `SceneViewDrawOne`. The consumer is\n * responsible for what gets painted — there is no AABB-fill default. */\n drawOne: SceneViewDrawOne<TData, TLayer, TPose>;\n /** Optional extra commands appended after scene commands, inside the same\n * view transform — a world-space annotation over the scene. */\n extraCommands?: ReadonlyArray<DrawCommand>;\n /** Optional per-id alpha multiplier, mirroring `<SceneCanvas>`'s scene-slot\n * `alphaFor`. Pass the same function the main canvas uses to keep a\n * scoping-dim treatment consistent across both. Defaults to `() => 1`. */\n alphaFor?: (id: string) => number;\n /** Hide scene layers in this view only, keyed `scene:<layerId>` as on\n * `<SceneCanvas>` — pass the main canvas's map to keep the two in step. */\n layerVisibility?: SceneViewLayers['layerVisibility'];\n /** Paint order for this view, keyed as `layerVisibility`. */\n layerOrder?: SceneViewLayers['layerOrder'];\n /** Skip nodes and commands that cannot reach this view — the scene slot's\n * `cull`. Off by default; worth it when the view shows a small part of a\n * large scene. */\n cull?: boolean;\n /** Where `drawOne`'s output for a node can reach — the scene slot's\n * `paintBounds`. Defaults to `defaultPaintBounds` when `drawOne` is\n * `defaultDrawOne`. */\n paintBounds?: RenderSceneToCanvasArgs<TData, TLayer, TPose>['paintBounds'];\n /** Optional animator, as on `<SceneCanvas>`: the view repaints on its ticks\n * and paints its `colorOverrides`. Pass the main canvas's animator so both\n * show the same colors. */\n animator?: Animator;\n /** Optional CSS class for the `<canvas>`. Its size is `width` × `height`\n * unless a rule on this class sizes it. */\n className?: string;\n /** Forwarded ref to the underlying `<canvas>`. Consumers attach their own\n * pointer listeners or call `toBlob` for snapshots through this. */\n canvasRef?: Ref<HTMLCanvasElement>;\n}\n\nfunction SceneViewCanvasInner<TData, TLayer extends string, TPose>(\n props: SceneViewCanvasProps<TData, TLayer, TPose>,\n) {\n const {\n scene, drawOne, extraCommands, alphaFor, layerVisibility, layerOrder,\n animator, className, canvasRef, cull, paintBounds,\n } = props;\n const view = normalizeView(props.view);\n\n // Subscribe to scene version. The snapshot value isn't used directly —\n // we only need React to re-render the component when the scene mutates.\n useSyncExternalStore(scene.subscribe, scene.getVersion, scene.getVersion);\n\n const localRef = useRef<HTMLCanvasElement | null>(null);\n\n const setCanvasRef = useCallback((el: HTMLCanvasElement | null): void => {\n localRef.current = el;\n assignRef(canvasRef, el);\n }, [canvasRef]);\n const { width, height } = useSurfaceSize(props, localRef);\n\n const paint = (lease: CanvasRendererLease): boolean => {\n const canvas = localRef.current;\n if (!canvas || width === 0 || height === 0) return false;\n const commands = sceneViewFrame({\n scene,\n view,\n width,\n height,\n drawOne,\n extraCommands: extraCommands as DrawCommand[] | undefined,\n alphaFor,\n layerVisibility,\n layerOrder,\n colorOverrides: animator?.colorOverrides,\n cull,\n paintBounds,\n });\n return lease.paint(canvas, commands, view, { width, height });\n };\n const { requestRedraw } = useCanvasSurface(paint, { target: localRef, onCommit: 'paint', size: { width, height } });\n\n // Override writes never bump the scene version, so the version subscription\n // above cannot see them.\n useEffect(() => scene.overrides.subscribe(requestRedraw), [scene, requestRedraw]);\n useEffect(() => scene.scroll?.subscribe(requestRedraw), [scene, requestRedraw]);\n useEffect(() => animator?.onTick(requestRedraw), [animator, requestRedraw]);\n\n return (\n <SurfaceCanvas\n ref={setCanvasRef}\n width={props.width}\n height={props.height}\n className={className}\n />\n );\n}\n\n/**\n * Pointer-inert read-only scene view. It attaches no event listeners;\n * consumers attach their own through `canvasRef`, a plain prop because\n * `forwardRef` erases the component's generics. `width` and `height` are CSS\n * pixels and size the drawing buffer; a `className` rule that sizes the\n * element stretches that buffer to fit. Given neither, it fills its parent.\n */\nexport const SceneView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return {
42
42
  editingId: dep.editingId ?? null,
43
- tool: dep.tool ?? null,
44
43
  getPose: (id) => toCamera ? toCamera(id, dep.getEditablePath(id)) : dep.getEditablePath(id),
45
44
  getNode: (id) => dep.getNodeShape(id),
46
45
  ...dep.extensions ? { extensions: dep.extensions } : {},
@@ -1 +1 @@
1
- {"version":3,"file":"affordanceAt.js","names":[],"sources":["../../src/canvas/affordanceAt.ts"],"sourcesContent":["/**\n * The dispatcher-side affordance classifier: answers \"what piece of selection\n * chrome is under this world point?\" by assembling the kit's affordances and\n * running the one shared walk (`hitAffordanceRegions`).\n */\n\nimport type { BodyClassification } from '@weasel-js/gestures';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport type { View } from 'core/viewport/view';\nimport type { AffordanceHit, WorldPoint } from '@weasel-js/routing';\nimport type { Affordance, CommonAffordanceScratch, LayerHit } from 'affordances/types';\nimport { hitAffordanceRegions, type AffordanceRegionHit } from 'affordances/hitAffordanceRegions';\nimport { createCornerResizeAffordance } from 'affordances/cornerResize';\nimport { createRotationAffordance } from 'affordances/rotationHandle';\nimport { createPathAnchorAffordances, type AnchorState } from 'affordances/pathAnchors';\nimport { targetSizesPx } from 'core/device/targets';\n\nexport type { AnchorState };\n\n/** What decides the kit's chrome affordances — their sizes and which ones\n * exist. Shared by the hit-test and the slops overlay, which draws them. */\nexport interface ChromeAffordanceOptions {\n /** Pointer-size multiplier from the live `DeviceProfile`. Every default\n * below is resolved through {@link targetSizesPx} at this scale, so the\n * grab zone tracks the painted chrome on a coarse pointer. Default 1. */\n targetScale?: number;\n /** Corner-handle hit radius in screen px. Overrides the device-scaled default. */\n handleHitRadius?: number;\n /** Anchor / control hit radius in screen px. Overrides the device-scaled default. */\n anchorHitRadius?: number;\n /** Minimum rotate-band thickness outside the selection AABB, in screen px.\n * Overrides the device-scaled default. */\n rotateBandPx?: number;\n /** The rotate badge the selection overlay paints (`rotationBadgeOf`), so\n * it can be grabbed where it is drawn. Omitted or null, only the rotate\n * ring is hit-tested. */\n rotationBadge?: { distancePx: number; sizePx: number } | null;\n /** Resize handles at the edge midpoints as well as the corners. Default true. */\n edgeHandles?: boolean;\n /** Anchor-editing state. When omitted, anchors aren't hit-tested. */\n getAnchorState?: () => AnchorState | null;\n}\n\nexport interface BuildAffordanceAtOptions extends ChromeAffordanceOptions {\n /** Live ChromeState at call time — current selection plus effective bounds,\n * including in-flight move/resize ghost poses. */\n getChromeState: () => ChromeState;\n /** Live view. Needed because region hit radii and the rotate band are\n * declared in screen pixels and resolved against the current scale. */\n getView: () => View;\n /** The affordances to walk, when the caller built them itself to share\n * them (`chromeAffordances`). Otherwise built from these options. */\n affordances?: readonly Affordance[];\n /** Chrome-caps resolver. Keeps the hit-test and the renderer agreeing on\n * which chrome is live (resize handles gated by\n * `'selection.resize-handles'`, rotation by `'selection.rotation-handle'`,\n * anchors by `'path-edit.anchors'`). Omitting defaults to always-visible. */\n getIsVisible?: () => (id: string) => boolean;\n}\n\n/**\n * The kit's selection chrome as affordances, bottom → top: rotate ring (and\n * badge), resize handles, then anchors and their controls — a corner handle\n * beats the rotate band it sits inside, and a control handle beats everything.\n */\nexport function chromeAffordances(opts: ChromeAffordanceOptions = {}): Affordance[] {\n const sizes = targetSizesPx(opts.targetScale);\n const {\n handleHitRadius = sizes.handle,\n anchorHitRadius = sizes.anchor,\n rotateBandPx = sizes.rotationDistance,\n getAnchorState,\n rotationBadge,\n edgeHandles = true,\n } = opts;\n return [\n createRotationAffordance({\n bandPx: rotateBandPx,\n paint: null,\n ...(rotationBadge\n ? { handle: { distancePx: rotationBadge.distancePx, hitRadiusPx: rotationBadge.sizePx } }\n : {}),\n }),\n createCornerResizeAffordance({ handleHitRadius, edges: edgeHandles }),\n ...(getAnchorState\n ? createPathAnchorAffordances(getAnchorState, { hitRadius: anchorHitRadius })\n : []),\n ];\n}\n\n/**\n * Read anchor-editing state off a dep registry, for\n * {@link ChromeAffordanceOptions.getAnchorState}. Returns `null` while no\n * `editAnchors` dep is registered, so anchors are not hit-tested.\n */\nexport function anchorStateFrom(\n getRegistry: () => { get(name: 'editAnchors'): EditAnchorsDep | undefined } | null,\n /** The editable path in the world the hit-test is asked in. A node on a\n * parallax plane stores its path in the plane's world; the surface carries\n * it into the asking camera's. Default: unchanged. */\n toCamera?: (id: string, path: unknown) => unknown,\n): () => AnchorState | null {\n return () => {\n const dep = getRegistry()?.get('editAnchors');\n if (!dep) return null;\n return {\n editingId: dep.editingId ?? null,\n tool: dep.tool ?? null,\n // The hit-test reads world-coord anchor positions, so route through\n // `getEditablePath`: both pose-as-polygon and `data.path` consumers\n // resolve correctly.\n getPose: (id) => (toCamera ? toCamera(id, dep.getEditablePath(id)) : dep.getEditablePath(id)),\n getNode: (id) => dep.getNodeShape(id),\n ...(dep.extensions ? { extensions: dep.extensions } : {}),\n getOutline: (id) => {\n const path = dep.getOutlinePath?.(id) ?? dep.getEditablePath(id);\n return toCamera ? toCamera(id, path) : path;\n },\n };\n };\n}\n\n/**\n * Build the `affordanceAt` thunk for `useSceneGestureDispatcher`. The point is\n * **world-space**; callers convert from client coords first. Priority follows\n * the order of {@link chromeAffordances}, topmost first.\n */\nexport function buildAffordanceAt(\n opts: BuildAffordanceAtOptions,\n): (worldPoint: WorldPoint) => AffordanceHit | null {\n const { getChromeState, getView, getIsVisible } = opts;\n const affordances = opts.affordances ?? chromeAffordances(opts);\n\n return function affordanceAt({ x: wx, y: wy }) {\n const hit = hitAffordanceRegions(\n affordances,\n wx,\n wy,\n getChromeState(),\n getView(),\n getIsVisible?.(),\n );\n return hit ? toAffordanceHit(hit) : null;\n };\n}\n\n/**\n * Region hit → `AffordanceHit`. The scratch fields named by\n * {@link CommonAffordanceScratch} are lifted onto the hit because the actions\n * that consume them read them there; the whole scratch rides along as `payload`.\n */\nfunction toAffordanceHit(hit: AffordanceRegionHit): AffordanceHit {\n const scratch = (hit.binding.initialScratch ?? {}) as CommonAffordanceScratch;\n return {\n kind: hit.region.hitKind ?? `${hit.affordanceId}:${hit.regionId}`,\n owner: hit.affordanceId,\n strength: 'shared',\n ...(scratch.targetId !== undefined ? { targetIds: [scratch.targetId] } : {}),\n ...(scratch.anchor !== undefined ? { anchor: scratch.anchor } : {}),\n ...(scratch.fixedPoint !== undefined ? { fixedPoint: scratch.fixedPoint } : {}),\n ...(hit.cursor !== undefined ? { cursor: hit.cursor } : {}),\n ...(hit.binding.initialScratch !== undefined ? { payload: hit.binding.initialScratch } : {}),\n } as AffordanceHit;\n}\n\n/**\n * Classify a world-space point against the current selection: `'empty'`,\n * `'selected-body'`, or `'unselected-body'`.\n *\n * @param kindOfNode - Resolver from a hit node id to its semantic kind.\n * Omitting it leaves `kind` undefined, which makes every `kind:` TargetSpec\n * form no-match.\n * @param doubleClickNames - The node a double-click on a hit names\n * (`doubleClickTarget`). Where that is another node, it rides along as\n * `doubleClick`, classified the same way.\n */\nexport function buildClassifyTarget(\n getSelection: () => readonly string[],\n pickBest: (world: WorldPoint) => string | null,\n kindOfNode?: (id: string) => string | undefined,\n doubleClickNames?: (hitId: string) => string,\n): (worldPoint: WorldPoint) => BodyClassification {\n return function classifyTarget(world) {\n const hitId = pickBest(world);\n if (!hitId) return { body: 'empty' };\n const sel = getSelection();\n const classify = (id: string) => ({\n body: sel.includes(id) ? 'selected-body' as const : 'unselected-body' as const,\n kind: kindOfNode?.(id),\n id,\n });\n const named = doubleClickNames?.(hitId);\n return named !== undefined && named !== hitId\n ? { ...classify(hitId), doubleClick: classify(named) }\n : classify(hitId);\n };\n}\n\n/** A registered layer's claim on a point, as the affordance the dispatcher\n * routes: its kind names the layer, and it carries what the layer's hit-test\n * resolved. */\nexport function layerAffordance(layerId: string, claim: LayerHit): AffordanceHit {\n return {\n kind: `layer:${layerId}`,\n owner: layerId,\n strength: claim.strength ?? 'shared',\n ...(claim.claimedKinds !== undefined ? { claimedKinds: claim.claimedKinds } : {}),\n ...(claim.cursor !== undefined ? { cursor: claim.cursor } : {}),\n ...(claim.initialScratch !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GAAI,MAAM,iBAAiB,SAAY,EAAE,cAAc,MAAM,aAAa,IAAI,CAAC;EAC/E,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;EAC7D,GAAI,MAAM,mBAAmB,SAAY,EAAE,SAAS,MAAM,eAAe,IAAI,CAAC;CAChF;AACF"}
1
+ {"version":3,"file":"affordanceAt.js","names":[],"sources":["../../src/canvas/affordanceAt.ts"],"sourcesContent":["/**\n * The dispatcher-side affordance classifier: answers \"what piece of selection\n * chrome is under this world point?\" by assembling the kit's affordances and\n * running the one shared walk (`hitAffordanceRegions`).\n */\n\nimport type { BodyClassification } from '@weasel-js/gestures';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport type { View } from 'core/viewport/view';\nimport type { AffordanceHit, WorldPoint } from '@weasel-js/routing';\nimport type { Affordance, CommonAffordanceScratch, LayerHit } from 'affordances/types';\nimport { hitAffordanceRegions, type AffordanceRegionHit } from 'affordances/hitAffordanceRegions';\nimport { createCornerResizeAffordance } from 'affordances/cornerResize';\nimport { createRotationAffordance } from 'affordances/rotationHandle';\nimport { createPathAnchorAffordances, type AnchorState } from 'affordances/pathAnchors';\nimport { targetSizesPx } from 'core/device/targets';\n\nexport type { AnchorState };\n\n/** What decides the kit's chrome affordances — their sizes and which ones\n * exist. Shared by the hit-test and the slops overlay, which draws them. */\nexport interface ChromeAffordanceOptions {\n /** Pointer-size multiplier from the live `DeviceProfile`. Every default\n * below is resolved through {@link targetSizesPx} at this scale, so the\n * grab zone tracks the painted chrome on a coarse pointer. Default 1. */\n targetScale?: number;\n /** Corner-handle hit radius in screen px. Overrides the device-scaled default. */\n handleHitRadius?: number;\n /** Anchor / control hit radius in screen px. Overrides the device-scaled default. */\n anchorHitRadius?: number;\n /** Minimum rotate-band thickness outside the selection AABB, in screen px.\n * Overrides the device-scaled default. */\n rotateBandPx?: number;\n /** The rotate badge the selection overlay paints (`rotationBadgeOf`), so\n * it can be grabbed where it is drawn. Omitted or null, only the rotate\n * ring is hit-tested. */\n rotationBadge?: { distancePx: number; sizePx: number } | null;\n /** Resize handles at the edge midpoints as well as the corners. Default true. */\n edgeHandles?: boolean;\n /** Anchor-editing state. When omitted, anchors aren't hit-tested. */\n getAnchorState?: () => AnchorState | null;\n}\n\nexport interface BuildAffordanceAtOptions extends ChromeAffordanceOptions {\n /** Live ChromeState at call time — current selection plus effective bounds,\n * including in-flight move/resize ghost poses. */\n getChromeState: () => ChromeState;\n /** Live view. Needed because region hit radii and the rotate band are\n * declared in screen pixels and resolved against the current scale. */\n getView: () => View;\n /** The affordances to walk, when the caller built them itself to share\n * them (`chromeAffordances`). Otherwise built from these options. */\n affordances?: readonly Affordance[];\n /** Chrome-caps resolver. Keeps the hit-test and the renderer agreeing on\n * which chrome is live (resize handles gated by\n * `'selection.resize-handles'`, rotation by `'selection.rotation-handle'`,\n * anchors by `'path-edit.anchors'`). Omitting defaults to always-visible. */\n getIsVisible?: () => (id: string) => boolean;\n}\n\n/**\n * The kit's selection chrome as affordances, bottom → top: rotate ring (and\n * badge), resize handles, then anchors and their controls — a corner handle\n * beats the rotate band it sits inside, and a control handle beats everything.\n */\nexport function chromeAffordances(opts: ChromeAffordanceOptions = {}): Affordance[] {\n const sizes = targetSizesPx(opts.targetScale);\n const {\n handleHitRadius = sizes.handle,\n anchorHitRadius = sizes.anchor,\n rotateBandPx = sizes.rotationDistance,\n getAnchorState,\n rotationBadge,\n edgeHandles = true,\n } = opts;\n return [\n createRotationAffordance({\n bandPx: rotateBandPx,\n paint: null,\n ...(rotationBadge\n ? { handle: { distancePx: rotationBadge.distancePx, hitRadiusPx: rotationBadge.sizePx } }\n : {}),\n }),\n createCornerResizeAffordance({ handleHitRadius, edges: edgeHandles }),\n ...(getAnchorState\n ? createPathAnchorAffordances(getAnchorState, { hitRadius: anchorHitRadius })\n : []),\n ];\n}\n\n/**\n * Read anchor-editing state off a dep registry, for\n * {@link ChromeAffordanceOptions.getAnchorState}. Returns `null` while no\n * `editAnchors` dep is registered, so anchors are not hit-tested.\n */\nexport function anchorStateFrom(\n getRegistry: () => { get(name: 'editAnchors'): EditAnchorsDep | undefined } | null,\n /** The editable path in the world the hit-test is asked in. A node on a\n * parallax plane stores its path in the plane's world; the surface carries\n * it into the asking camera's. Default: unchanged. */\n toCamera?: (id: string, path: unknown) => unknown,\n): () => AnchorState | null {\n return () => {\n const dep = getRegistry()?.get('editAnchors');\n if (!dep) return null;\n return {\n editingId: dep.editingId ?? null,\n // The hit-test reads world-coord anchor positions, so route through\n // `getEditablePath`: both pose-as-polygon and `data.path` consumers\n // resolve correctly.\n getPose: (id) => (toCamera ? toCamera(id, dep.getEditablePath(id)) : dep.getEditablePath(id)),\n getNode: (id) => dep.getNodeShape(id),\n ...(dep.extensions ? { extensions: dep.extensions } : {}),\n getOutline: (id) => {\n const path = dep.getOutlinePath?.(id) ?? dep.getEditablePath(id);\n return toCamera ? toCamera(id, path) : path;\n },\n };\n };\n}\n\n/**\n * Build the `affordanceAt` thunk for `useSceneGestureDispatcher`. The point is\n * **world-space**; callers convert from client coords first. Priority follows\n * the order of {@link chromeAffordances}, topmost first.\n */\nexport function buildAffordanceAt(\n opts: BuildAffordanceAtOptions,\n): (worldPoint: WorldPoint) => AffordanceHit | null {\n const { getChromeState, getView, getIsVisible } = opts;\n const affordances = opts.affordances ?? chromeAffordances(opts);\n\n return function affordanceAt({ x: wx, y: wy }) {\n const hit = hitAffordanceRegions(\n affordances,\n wx,\n wy,\n getChromeState(),\n getView(),\n getIsVisible?.(),\n );\n return hit ? toAffordanceHit(hit) : null;\n };\n}\n\n/**\n * Region hit → `AffordanceHit`. The scratch fields named by\n * {@link CommonAffordanceScratch} are lifted onto the hit because the actions\n * that consume them read them there; the whole scratch rides along as `payload`.\n */\nfunction toAffordanceHit(hit: AffordanceRegionHit): AffordanceHit {\n const scratch = (hit.binding.initialScratch ?? {}) as CommonAffordanceScratch;\n return {\n kind: hit.region.hitKind ?? `${hit.affordanceId}:${hit.regionId}`,\n owner: hit.affordanceId,\n strength: 'shared',\n ...(scratch.targetId !== undefined ? { targetIds: [scratch.targetId] } : {}),\n ...(scratch.anchor !== undefined ? { anchor: scratch.anchor } : {}),\n ...(scratch.fixedPoint !== undefined ? { fixedPoint: scratch.fixedPoint } : {}),\n ...(hit.cursor !== undefined ? { cursor: hit.cursor } : {}),\n ...(hit.binding.initialScratch !== undefined ? { payload: hit.binding.initialScratch } : {}),\n } as AffordanceHit;\n}\n\n/**\n * Classify a world-space point against the current selection: `'empty'`,\n * `'selected-body'`, or `'unselected-body'`.\n *\n * @param kindOfNode - Resolver from a hit node id to its semantic kind.\n * Omitting it leaves `kind` undefined, which makes every `kind:` TargetSpec\n * form no-match.\n * @param doubleClickNames - The node a double-click on a hit names\n * (`doubleClickTarget`). Where that is another node, it rides along as\n * `doubleClick`, classified the same way.\n */\nexport function buildClassifyTarget(\n getSelection: () => readonly string[],\n pickBest: (world: WorldPoint) => string | null,\n kindOfNode?: (id: string) => string | undefined,\n doubleClickNames?: (hitId: string) => string,\n): (worldPoint: WorldPoint) => BodyClassification {\n return function classifyTarget(world) {\n const hitId = pickBest(world);\n if (!hitId) return { body: 'empty' };\n const sel = getSelection();\n const classify = (id: string) => ({\n body: sel.includes(id) ? 'selected-body' as const : 'unselected-body' as const,\n kind: kindOfNode?.(id),\n id,\n });\n const named = doubleClickNames?.(hitId);\n return named !== undefined && named !== hitId\n ? { ...classify(hitId), doubleClick: classify(named) }\n : classify(hitId);\n };\n}\n\n/** A registered layer's claim on a point, as the affordance the dispatcher\n * routes: its kind names the layer, and it carries what the layer's hit-test\n * resolved. */\nexport function layerAffordance(layerId: string, claim: LayerHit): AffordanceHit {\n return {\n kind: `layer:${layerId}`,\n owner: layerId,\n strength: claim.strength ?? 'shared',\n ...(claim.claimedKinds !== undefined ? { claimedKinds: claim.claimedKinds } : {}),\n ...(claim.cursor !== undefined ? { cursor: claim.cursor } : {}),\n ...(claim.initialScratch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,EAAE,cAAc,MAAM,aAAa,IAAI,CAAC;EAC/E,GAAI,MAAM,WAAW,SAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;EAC7D,GAAI,MAAM,mBAAmB,SAAY,EAAE,SAAS,MAAM,eAAe,IAAI,CAAC;CAChF;AACF"}
@@ -0,0 +1,37 @@
1
+ import { useCallback, useMemo, useState } from "react";
2
+ import { useLatest } from "@weasel-js/react";
3
+
4
+ //#region src/canvas/deps/chromeRules.ts
5
+ /**
6
+ * The `chromeRules` dep: the canvas's chrome-visibility rules, read and set
7
+ * at run time, for an action that shows or hides a piece of chrome.
8
+ */
9
+ /**
10
+ * The rules set through the dep over `rules`, and the dep that reads and sets
11
+ * them. Its identity is stable.
12
+ */
13
+ function useChromeRulesDep(rules) {
14
+ const [overrides, setOverrides] = useState({});
15
+ const merged = useMemo(() => ({
16
+ ...rules,
17
+ ...overrides
18
+ }), [rules, overrides]);
19
+ const mergedRef = useLatest(merged);
20
+ const set = useCallback((id, rule) => {
21
+ setOverrides((prev) => prev[id] === rule ? prev : {
22
+ ...prev,
23
+ [id]: rule
24
+ });
25
+ }, []);
26
+ return {
27
+ rules: merged,
28
+ dep: useMemo(() => ({
29
+ get: (id) => mergedRef.current[id],
30
+ set
31
+ }), [mergedRef, set])
32
+ };
33
+ }
34
+
35
+ //#endregion
36
+ export { useChromeRulesDep };
37
+ //# sourceMappingURL=chromeRules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chromeRules.js","names":[],"sources":["../../../src/canvas/deps/chromeRules.ts"],"sourcesContent":["/**\n * The `chromeRules` dep: the canvas's chrome-visibility rules, read and set\n * at run time, for an action that shows or hides a piece of chrome.\n */\nimport { useCallback, useMemo, useState } from 'react';\nimport { useLatest } from '@weasel-js/react';\nimport type { VisibilityRules } from 'domains/chrome-caps';\n\n/** One chrome id's rule, as `VisibilityRules` holds it. */\nexport type VisibilityRule = NonNullable<VisibilityRules[string]>;\n\n/** Read and set the rule in force for a chrome id. */\nexport interface ChromeRulesDep {\n /** The rule in force for `id`, or undefined where none is set, which shows it. */\n get(id: string): VisibilityRule | undefined;\n /** Put `rule` in force for `id`, over the presets' rule and `chromeVisibility`'s. */\n set(id: string, rule: VisibilityRule): void;\n}\n\ndeclare module '@weasel-js/routing' {\n interface DepSchema {\n /** The canvas's chrome-visibility rules. Sourced by `<SceneCanvas>`, whose\n * `set` lays a rule over its presets' and its `chromeVisibility` prop's\n * until it unmounts; an app keeping these as preferences sources its own. */\n chromeRules?: ChromeRulesDep;\n }\n}\n\n/**\n * The rules set through the dep over `rules`, and the dep that reads and sets\n * them. Its identity is stable.\n */\nexport function useChromeRulesDep(rules: VisibilityRules): { rules: VisibilityRules; dep: ChromeRulesDep } {\n const [overrides, setOverrides] = useState<VisibilityRules>({});\n const merged = useMemo(() => ({ ...rules, ...overrides }), [rules, overrides]);\n const mergedRef = useLatest(merged);\n const set = useCallback((id: string, rule: VisibilityRule) => {\n setOverrides((prev) => (prev[id] === rule ? prev : { ...prev, [id]: rule }));\n }, []);\n const dep = useMemo<ChromeRulesDep>(() => ({ get: (id) => mergedRef.current[id], set }), [mergedRef, set]);\n return { rules: merged, dep };\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,SAAgB,kBAAkB,OAAyE;CACzG,MAAM,CAAC,WAAW,gBAAgB,SAA0B,CAAC,CAAC;CAC9D,MAAM,SAAS,eAAe;EAAE,GAAG;EAAO,GAAG;CAAU,IAAI,CAAC,OAAO,SAAS,CAAC;CAC7E,MAAM,YAAY,UAAU,MAAM;CAClC,MAAM,MAAM,aAAa,IAAY,SAAyB;EAC5D,cAAc,SAAU,KAAK,QAAQ,OAAO,OAAO;GAAE,GAAG;IAAO,KAAK;EAAK,CAAE;CAC7E,GAAG,CAAC,CAAC;CAEL,OAAO;EAAE,OAAO;EAAQ,KADZ,eAA+B;GAAE,MAAM,OAAO,UAAU,QAAQ;GAAK;EAAI,IAAI,CAAC,WAAW,GAAG,CAChF;CAAI;AAC9B"}
@@ -47,7 +47,6 @@ function useEditAnchorsDepSource(scene, selection, adapter, externalState, tune)
47
47
  const effectiveId = state.getEditingId();
48
48
  const selectedAnchors = effectiveId ? state.getSelectedAnchors() : EMPTY_ANCHOR_SELECTION;
49
49
  const marquee = effectiveId ? state.getMarquee() : null;
50
- const tool = effectiveId ? state.getTool() : null;
51
50
  return {
52
51
  editingId: effectiveId,
53
52
  setEditingId(id) {
@@ -84,11 +83,6 @@ function useEditAnchorsDepSource(scene, selection, adapter, externalState, tune)
84
83
  state.setHandleLocks(next);
85
84
  registry.changed?.();
86
85
  },
87
- tool,
88
- setTool(id) {
89
- if (!effectiveId) return;
90
- state.setTool(id);
91
- },
92
86
  ...pathAccess(sc, ad, state.getExtensions())
93
87
  };
94
88
  });
@@ -1 +1 @@
1
- {"version":3,"file":"editAnchors.js","names":[],"sources":["../../../src/canvas/deps/editAnchors.ts"],"sourcesContent":["/**\n * `useEditAnchorsDepSource` — wires the `editAnchors` dep.\n *\n * A node's editable polygon lives in one of two places: the pose itself\n * (`pose.kind === 'polygon'`), or `data.path` with a rect pose, stored pose-local.\n * `getEditablePath` returns it in **world coords** either way, and `applyEdit` commits in the\n * correct storage shape as one undoable batch, preserving the render invariant\n * `pathInWorld(stored, pose) === world`. What the node keeps per anchor — a `data.skin`, vertex\n * colors — is renumbered in that batch when the caller says where the points came from, and each path-edit extension finishes\n * the edit first (`PathEditExtension.finishEdit`). Live previews ride the standard\n * `OngoingHandle.previewIds/Pose/Data` triple — this dep doesn't own preview state.\n */\nimport { useState } from 'react';\nimport { useDepRegistry, useDepSource } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport { locksOf, type EditAnchorsParams } from 'interactions/actions/edit-anchors/params';\nimport type { Scene, NodeId } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { PointOrigin, PolygonPath } from '@weasel-js/geom';\nimport { anchorDataPatch } from 'domains/paths/anchorData';\nimport { classifyPathStorage, pathEditPathOf, resolveEditablePathOf } from 'domains/paths/editablePath';\nimport { representationOf } from 'domains/paths/pathRepresentation';\nimport type { PathEditExtension } from 'domains/paths/pathEditExtension';\nimport {\n finishCtx, finishEdit, otherOps, pathEditFollower, reshapeOps, type EditableNode,\n} from './pathEditCommits';\nimport { useTransformFollower } from './transformFollowers';\nimport { createPathEditState, isSelectedNode, type PathEditState } from 'domains/paths/pathEditState';\nimport { resolveParams, type ActionTunings } from '@weasel-js/routing';\nimport type { Op } from 'core/ops/types';\n\ninterface OpsApplier {\n applyOps(ops: Op[], label?: string): void;\n}\n\n/** The part of a `PathEditState` the dep reads and writes. */\nexport type EditAnchorsStateRef = Omit<PathEditState, 'subscribe' | 'getEditingIds' | 'setExtensions'>;\n/** The same, with the change notice chrome reading the dep waits on. */\nexport type EditAnchorsStateSource = EditAnchorsStateRef & Partial<Pick<PathEditState, 'subscribe'>>;\n\nexport { resolveEditablePathOf };\n\nfunction tunedHandleLock(tune: ActionTunings | undefined): EditAnchorsParams['handleLock'] {\n const params = resolveParams(tune?.editAnchors?.params as Parameters<typeof resolveParams>[0]);\n return (params as EditAnchorsParams | undefined)?.handleLock;\n}\n\nconst EMPTY_ANCHOR_SELECTION: ReadonlySet<number> = new Set<number>();\n\n/**\n * Publish the `editAnchors` dep for `scene`: its path access and commits\n * through `adapter`, and the edit state of `externalState` (or one of its\n * own), with the extensions that state holds finishing every edit.\n */\nexport function useEditAnchorsDepSource(\n scene: Scene<unknown, string, unknown>,\n selection: SelectionApi,\n adapter: OpsApplier,\n externalState?: EditAnchorsStateRef,\n /** `<SceneCanvas tune>`: the handle locks start from its `editAnchors`\n * `handleLock` param until a toggle sets them. */\n tune?: ActionTunings,\n): void {\n const registry = useDepRegistry();\n const tuneRef = useLatest(tune);\n const sceneRef = useLatest(scene);\n const selectionRef = useLatest(selection);\n const adapterRef = useLatest(adapter);\n\n // A caller that shares the state with nothing else gets one of its own.\n const [ownState] = useState(() => createPathEditState({\n isSelectedNode: (id) => isSelectedNode(sceneRef.current, selectionRef.current, id),\n }));\n const stateRef = useLatest(externalState ?? ownState);\n\n useDepSource('editAnchors', (): EditAnchorsDep => {\n const sc = sceneRef.current;\n const ad = adapterRef.current;\n const state = stateRef.current;\n const effectiveId = state.getEditingId();\n // Anchor selection and the marquee belong to one specific edited node, so never\n // hand them out alongside an empty id.\n const selectedAnchors = effectiveId ? state.getSelectedAnchors() : EMPTY_ANCHOR_SELECTION;\n const marquee = effectiveId ? state.getMarquee() : null;\n const tool = effectiveId ? state.getTool() : null;\n return {\n editingId: effectiveId,\n setEditingId(id: string | null) {\n const next = id ?? '';\n if (effectiveId !== next) {\n registry.get('dispatchTrace')?.recordModeSwitch(\n 'editAnchors.editingId',\n effectiveId || null,\n next || null,\n next ? 'enter' : 'exit',\n );\n // Anchor indices only mean something relative to one path.\n state.setSelectedAnchors(EMPTY_ANCHOR_SELECTION);\n state.setSelectedMark(null);\n state.setMarquee(null);\n }\n stateRef.current.setEditingId(id);\n },\n selectedAnchors,\n setSelectedAnchors(next: Iterable<number>) {\n if (!effectiveId) return;\n const set = new Set(next);\n if (set.size > 0) state.setSelectedMark(null);\n state.setSelectedAnchors(set);\n },\n selectedMark: effectiveId ? state.getSelectedMark() : null,\n setSelectedMark(mark) {\n if (!effectiveId) return;\n if (mark !== null) state.setSelectedAnchors(EMPTY_ANCHOR_SELECTION);\n state.setSelectedMark(mark);\n },\n extensions: state.getExtensions(),\n marquee,\n setMarquee(rect) {\n if (!effectiveId) return;\n state.setMarquee(rect);\n },\n handleLocks: state.getHandleLocks() ?? locksOf(tunedHandleLock(tuneRef.current)),\n setHandleLocks(next) {\n state.setHandleLocks(next);\n registry.changed?.();\n },\n tool,\n setTool(id) {\n if (!effectiveId) return;\n state.setTool(id);\n },\n ...pathAccess(sc, ad, state.getExtensions()),\n };\n });\n useTransformFollower(() => pathEditFollower(sceneRef.current, stateRef.current.getExtensions()));\n}\n\n/** The members of the dep that read the scene and commit to it. */\nfunction pathAccess(\n sc: Scene<unknown, string, unknown>,\n ad: OpsApplier,\n extensions: readonly PathEditExtension[],\n): Pick<\n EditAnchorsDep,\n | 'getEditablePath' | 'getOutlinePath' | 'getStorageKind' | 'getNodeShape' | 'applyEdit' | 'editOps' | 'finishEdit'\n | 'store'\n> {\n const editOps = (id: string, worldPath: unknown, label: string, origins?: readonly (PointOrigin | null)[]): Op[] => {\n const node = sc.get(id as NodeId) as EditableNode | undefined;\n if (!node) return [];\n const done = finishEdit(extensions, node, worldPath as PolygonPath, origins, finishCtx(sc, id, extensions));\n if (!done) return [];\n // A form's origins number the anchors of its edit path, not data.path's.\n const before = origins && !representationOf(extensions, node.data) ? resolveEditablePathOf(node) : null;\n const patch = { ...(before && origins ? anchorDataPatch(node.data, before, done.path, origins) : {}), ...done.data };\n return [\n ...reshapeOps(id, node, done.path, label, Object.keys(patch).length > 0 ? patch : null, extensions),\n ...otherOps(sc, done.others, label, extensions),\n ];\n };\n return {\n getEditablePath(id: string): PolygonPath | null {\n const node = sc.get(id as NodeId);\n return pathEditPathOf(node as { pose: unknown; data: unknown }, extensions);\n },\n getOutlinePath(id: string): PolygonPath | null {\n return resolveEditablePathOf(sc.get(id as NodeId) as { pose: unknown; data: unknown });\n },\n getStorageKind(id: string): 'pose' | 'data' | null {\n const node = sc.get(id as NodeId);\n const storage = classifyPathStorage(node as { pose: unknown; data: unknown });\n return storage?.kind ?? null;\n },\n getNodeShape(id: string): { pose: unknown; data: unknown } | null {\n const node = sc.get(id as NodeId);\n if (!node) return null;\n return { pose: node.pose, data: node.data };\n },\n applyEdit(id: string, worldPath: unknown, label: string, origins?: readonly (PointOrigin | null)[]) {\n const ops = editOps(id, worldPath, label, origins);\n if (ops.length > 0) ad.applyOps(ops, label);\n },\n editOps,\n finishEdit(id: string, worldPath: unknown, origins?: readonly (PointOrigin | null)[]) {\n const node = sc.get(id as NodeId) as EditableNode | undefined;\n if (!node) return { path: worldPath, others: [] };\n const done = finishEdit(extensions, node, worldPath as PolygonPath, origins, finishCtx(sc, id, extensions));\n if (!done) return null;\n const others = [...done.others.values()].flatMap((o) => (o.path && !o.remove ? [{ id: o.id, path: o.path }] : []));\n return { path: done.path, others };\n },\n store(id, worldPath, label, data) {\n const node = sc.get(id as NodeId) as EditableNode | undefined;\n const ops = node ? reshapeOps(id, node, worldPath, label, data ?? null, extensions) : [];\n if (ops.length > 0) ad.applyOps(ops, label);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,gBAAgB,MAAkE;CAEzF,OADe,cAAc,MAAM,aAAa,MACxC,CAAA,EAA0C;AACpD;AAEA,IAAM,yCAA8C,IAAI,IAAY;;;;;;AAOpE,SAAgB,wBACd,OACA,WACA,SACA,eAGA,MACM;CACN,MAAM,WAAW,eAAe;CAChC,MAAM,UAAU,UAAU,IAAI;CAC9B,MAAM,WAAW,UAAU,KAAK;CAChC,MAAM,eAAe,UAAU,SAAS;CACxC,MAAM,aAAa,UAAU,OAAO;CAGpC,MAAM,CAAC,YAAY,eAAe,oBAAoB,EACpD,iBAAiB,OAAO,eAAe,SAAS,SAAS,aAAa,SAAS,EAAE,EACnF,CAAC,CAAC;CACF,MAAM,WAAW,UAAU,iBAAiB,QAAQ;CAEpD,aAAa,qBAAqC;EAChD,MAAM,KAAK,SAAS;EACpB,MAAM,KAAK,WAAW;EACtB,MAAM,QAAQ,SAAS;EACvB,MAAM,cAAc,MAAM,aAAa;EAGvC,MAAM,kBAAkB,cAAc,MAAM,mBAAmB,IAAI;EACnE,MAAM,UAAU,cAAc,MAAM,WAAW,IAAI;EACnD,MAAM,OAAO,cAAc,MAAM,QAAQ,IAAI;EAC7C,OAAO;GACL,WAAW;GACX,aAAa,IAAmB;IAC9B,MAAM,OAAO,MAAM;IACnB,IAAI,gBAAgB,MAAM;KACxB,SAAS,IAAI,eAAe,CAAC,EAAE,iBAC7B,yBACA,eAAe,MACf,QAAQ,MACR,OAAO,UAAU,MACnB;KAEA,MAAM,mB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CAAC,EAAE,SAAS,CAAC;IAAE,IAAI,EAAE;IAAI,MAAM,EAAE;GAAK,CAAC,IAAI,CAAC,CAAE;GACjH,OAAO;IAAE,MAAM,KAAK;IAAM;GAAO;EACnC;EACA,MAAM,IAAI,WAAW,OAAO,MAAM;GAChC,MAAM,OAAO,GAAG,IAAI,EAAY;GAChC,MAAM,MAAM,OAAO,WAAW,IAAI,MAAM,WAAW,OAAO,QAAQ,MAAM,UAAU,IAAI,CAAC;GACvF,IAAI,IAAI,SAAS,GAAG,GAAG,SAAS,KAAK,KAAK;EAC5C;CACF;AACF"}
1
+ {"version":3,"file":"editAnchors.js","names":[],"sources":["../../../src/canvas/deps/editAnchors.ts"],"sourcesContent":["/**\n * `useEditAnchorsDepSource` — wires the `editAnchors` dep.\n *\n * A node's editable polygon lives in one of two places: the pose itself\n * (`pose.kind === 'polygon'`), or `data.path` with a rect pose, stored pose-local.\n * `getEditablePath` returns it in **world coords** either way, and `applyEdit` commits in the\n * correct storage shape as one undoable batch, preserving the render invariant\n * `pathInWorld(stored, pose) === world`. What the node keeps per anchor — a `data.skin`, vertex\n * colors — is renumbered in that batch when the caller says where the points came from, and each path-edit extension finishes\n * the edit first (`PathEditExtension.finishEdit`). Live previews ride the standard\n * `OngoingHandle.previewIds/Pose/Data` triple — this dep doesn't own preview state.\n */\nimport { useState } from 'react';\nimport { useDepRegistry, useDepSource } from '@weasel-js/routing/react';\nimport { useLatest } from '@weasel-js/react';\nimport type { EditAnchorsDep } from 'interactions/actions/depSchema';\nimport { locksOf, type EditAnchorsParams } from 'interactions/actions/edit-anchors/params';\nimport type { Scene, NodeId } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { PointOrigin, PolygonPath } from '@weasel-js/geom';\nimport { anchorDataPatch } from 'domains/paths/anchorData';\nimport { classifyPathStorage, pathEditPathOf, resolveEditablePathOf } from 'domains/paths/editablePath';\nimport { representationOf } from 'domains/paths/pathRepresentation';\nimport type { PathEditExtension } from 'domains/paths/pathEditExtension';\nimport {\n finishCtx, finishEdit, otherOps, pathEditFollower, reshapeOps, type EditableNode,\n} from './pathEditCommits';\nimport { useTransformFollower } from './transformFollowers';\nimport { createPathEditState, isSelectedNode, type PathEditState } from 'domains/paths/pathEditState';\nimport { resolveParams, type ActionTunings } from '@weasel-js/routing';\nimport type { Op } from 'core/ops/types';\n\ninterface OpsApplier {\n applyOps(ops: Op[], label?: string): void;\n}\n\n/** The part of a `PathEditState` the dep reads and writes. */\nexport type EditAnchorsStateRef = Omit<PathEditState, 'subscribe' | 'getEditingIds' | 'setExtensions'>;\n/** The same, with the change notice chrome reading the dep waits on. */\nexport type EditAnchorsStateSource = EditAnchorsStateRef & Partial<Pick<PathEditState, 'subscribe'>>;\n\nexport { resolveEditablePathOf };\n\nfunction tunedHandleLock(tune: ActionTunings | undefined): EditAnchorsParams['handleLock'] {\n const params = resolveParams(tune?.editAnchors?.params as Parameters<typeof resolveParams>[0]);\n return (params as EditAnchorsParams | undefined)?.handleLock;\n}\n\nconst EMPTY_ANCHOR_SELECTION: ReadonlySet<number> = new Set<number>();\n\n/**\n * Publish the `editAnchors` dep for `scene`: its path access and commits\n * through `adapter`, and the edit state of `externalState` (or one of its\n * own), with the extensions that state holds finishing every edit.\n */\nexport function useEditAnchorsDepSource(\n scene: Scene<unknown, string, unknown>,\n selection: SelectionApi,\n adapter: OpsApplier,\n externalState?: EditAnchorsStateRef,\n /** `<SceneCanvas tune>`: the handle locks start from its `editAnchors`\n * `handleLock` param until a toggle sets them. */\n tune?: ActionTunings,\n): void {\n const registry = useDepRegistry();\n const tuneRef = useLatest(tune);\n const sceneRef = useLatest(scene);\n const selectionRef = useLatest(selection);\n const adapterRef = useLatest(adapter);\n\n // A caller that shares the state with nothing else gets one of its own.\n const [ownState] = useState(() => createPathEditState({\n isSelectedNode: (id) => isSelectedNode(sceneRef.current, selectionRef.current, id),\n }));\n const stateRef = useLatest(externalState ?? ownState);\n\n useDepSource('editAnchors', (): EditAnchorsDep => {\n const sc = sceneRef.current;\n const ad = adapterRef.current;\n const state = stateRef.current;\n const effectiveId = state.getEditingId();\n // Anchor selection and the marquee belong to one specific edited node, so never\n // hand them out alongside an empty id.\n const selectedAnchors = effectiveId ? state.getSelectedAnchors() : EMPTY_ANCHOR_SELECTION;\n const marquee = effectiveId ? state.getMarquee() : null;\n return {\n editingId: effectiveId,\n setEditingId(id: string | null) {\n const next = id ?? '';\n if (effectiveId !== next) {\n registry.get('dispatchTrace')?.recordModeSwitch(\n 'editAnchors.editingId',\n effectiveId || null,\n next || null,\n next ? 'enter' : 'exit',\n );\n // Anchor indices only mean something relative to one path.\n state.setSelectedAnchors(EMPTY_ANCHOR_SELECTION);\n state.setSelectedMark(null);\n state.setMarquee(null);\n }\n stateRef.current.setEditingId(id);\n },\n selectedAnchors,\n setSelectedAnchors(next: Iterable<number>) {\n if (!effectiveId) return;\n const set = new Set(next);\n if (set.size > 0) state.setSelectedMark(null);\n state.setSelectedAnchors(set);\n },\n selectedMark: effectiveId ? state.getSelectedMark() : null,\n setSelectedMark(mark) {\n if (!effectiveId) return;\n if (mark !== null) state.setSelectedAnchors(EMPTY_ANCHOR_SELECTION);\n state.setSelectedMark(mark);\n },\n extensions: state.getExtensions(),\n marquee,\n setMarquee(rect) {\n if (!effectiveId) return;\n state.setMarquee(rect);\n },\n handleLocks: state.getHandleLocks() ?? locksOf(tunedHandleLock(tuneRef.current)),\n setHandleLocks(next) {\n state.setHandleLocks(next);\n registry.changed?.();\n },\n ...pathAccess(sc, ad, state.getExtensions()),\n };\n });\n useTransformFollower(() => pathEditFollower(sceneRef.current, stateRef.current.getExtensions()));\n}\n\n/** The members of the dep that read the scene and commit to it. */\nfunction pathAccess(\n sc: Scene<unknown, string, unknown>,\n ad: OpsApplier,\n extensions: readonly PathEditExtension[],\n): Pick<\n EditAnchorsDep,\n | 'getEditablePath' | 'getOutlinePath' | 'getStorageKind' | 'getNodeShape' | 'applyEdit' | 'editOps' | 'finishEdit'\n | 'store'\n> {\n const editOps = (id: string, worldPath: unknown, label: string, origins?: readonly (PointOrigin | null)[]): Op[] => {\n const node = sc.get(id as NodeId) as EditableNode | undefined;\n if (!node) return [];\n const done = finishEdit(extensions, node, worldPath as PolygonPath, origins, finishCtx(sc, id, extensions));\n if (!done) return [];\n // A form's origins number the anchors of its edit path, not data.path's.\n const before = origins && !representationOf(extensions, node.data) ? resolveEditablePathOf(node) : null;\n const patch = { ...(before && origins ? anchorDataPatch(node.data, before, done.path, origins) : {}), ...done.data };\n return [\n ...reshapeOps(id, node, done.path, label, Object.keys(patch).length > 0 ? patch : null, extensions),\n ...otherOps(sc, done.others, label, extensions),\n ];\n };\n return {\n getEditablePath(id: string): PolygonPath | null {\n const node = sc.get(id as NodeId);\n return pathEditPathOf(node as { pose: unknown; data: unknown }, extensions);\n },\n getOutlinePath(id: string): PolygonPath | null {\n return resolveEditablePathOf(sc.get(id as NodeId) as { pose: unknown; data: unknown });\n },\n getStorageKind(id: string): 'pose' | 'data' | null {\n const node = sc.get(id as NodeId);\n const storage = classifyPathStorage(node as { pose: unknown; data: unknown });\n return storage?.kind ?? null;\n },\n getNodeShape(id: string): { pose: unknown; data: unknown } | null {\n const node = sc.get(id as NodeId);\n if (!node) return null;\n return { pose: node.pose, data: node.data };\n },\n applyEdit(id: string, worldPath: unknown, label: string, origins?: readonly (PointOrigin | null)[]) {\n const ops = editOps(id, worldPath, label, origins);\n if (ops.length > 0) ad.applyOps(ops, label);\n },\n editOps,\n finishEdit(id: string, worldPath: unknown, origins?: readonly (PointOrigin | null)[]) {\n const node = sc.get(id as NodeId) as EditableNode | undefined;\n if (!node) return { path: worldPath, others: [] };\n const done = finishEdit(extensions, node, worldPath as PolygonPath, origins, finishCtx(sc, id, extensions));\n if (!done) return null;\n const others = [...done.others.values()].flatMap((o) => (o.path && !o.remove ? [{ id: o.id, path: o.path }] : []));\n return { path: done.path, others };\n },\n store(id, worldPath, label, data) {\n const node = sc.get(id as NodeId) as EditableNode | undefined;\n const ops = node ? reshapeOps(id, node, worldPath, label, data ?? null, extensions) : [];\n if (ops.length > 0) ad.applyOps(ops, label);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAS,gBAAgB,MAAkE;CAEzF,OADe,cAAc,MAAM,aAAa,MACxC,CAAA,EAA0C;AACpD;AAEA,IAAM,yCAA8C,IAAI,IAAY;;;;;;AAOpE,SAAgB,wBACd,OACA,WACA,SACA,eAGA,MACM;CACN,MAAM,WAAW,eAAe;CAChC,MAAM,UAAU,UAAU,IAAI;CAC9B,MAAM,WAAW,UAAU,KAAK;CAChC,MAAM,eAAe,UAAU,SAAS;CACxC,MAAM,aAAa,UAAU,OAAO;CAGpC,MAAM,CAAC,YAAY,eAAe,oBAAoB,EACpD,iBAAiB,OAAO,eAAe,SAAS,SAAS,aAAa,SAAS,EAAE,EACnF,CAAC,CAAC;CACF,MAAM,WAAW,UAAU,iBAAiB,QAAQ;CAEpD,aAAa,qBAAqC;EAChD,MAAM,KAAK,SAAS;EACpB,MAAM,KAAK,WAAW;EACtB,MAAM,QAAQ,SAAS;EACvB,MAAM,cAAc,MAAM,aAAa;EAGvC,MAAM,kBAAkB,cAAc,MAAM,mBAAmB,IAAI;EACnE,MAAM,UAAU,cAAc,MAAM,WAAW,IAAI;EACnD,OAAO;GACL,WAAW;GACX,aAAa,IAAmB;IAC9B,MAAM,OAAO,MAAM;IACnB,IAAI,gBAAgB,MAAM;KACxB,SAAS,IAAI,eAAe,CAAC,EAAE,iBAC7B,yBACA,eAAe,MACf,QAAQ,MACR,OAAO,UAAU,MACnB;KAEA,MAAM,mBAAmB,sBAAsB;KAC/C,MAAM,gBAAgB,IAAI;KAC1B,MAAM,WAAW,IAAI;IACvB;IACA,SAAS,QAAQ,aAAa,EAAE;GAClC;GACA;GACA,mBAAmB,MAAwB;IACzC,IAAI,CAAC,aAAa;IAClB,MAAM,MAAM,IAAI,IAAI,IAAI;IACxB,IAAI,IAAI,OAAO,GAAG,MAAM,g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AI,SAAS,GAAG,GAAG,SAAS,KAAK,KAAK;EAC5C;CACF;AACF"}
@@ -2,7 +2,7 @@ import { rectToPlane, toPlane } from "../../core/viewport/parallax.js";
2
2
  import { poseDescriptorForNode, visualBoundsViaDescriptor } from "../../core/geometry/poseDescriptor.js";
3
3
  import { AUTO_POSE_DESCRIPTOR } from "../../core/geometry/autoPoseDescriptor.js";
4
4
  import { findShapeInk, findShapeSilhouette } from "../NodeShape.js";
5
- import { polygonRegion, poseOutline, rectRegion, regionBoundsOf, regionOf, regionTakes } from "../../core/geometry/regionHit.js";
5
+ import { polygonRegion, poseOutline, rectRegion, regionBoundsOf, regionOf, regionTakes, regionTakesByBounds } from "../../core/geometry/regionHit.js";
6
6
  import { scenePickSource } from "../scenePickSource.js";
7
7
  import { pickWalk } from "../pickWalk.js";
8
8
  import { applyToPoint, boundsOfPath, pathIntersectsRect } from "@weasel-js/geom";
@@ -60,6 +60,8 @@ function regionPickQuery(r, mode, descriptor, query) {
60
60
  hits: (node, pose, derived, inherited) => {
61
61
  const g = poseDescriptorForNode(descriptor, node);
62
62
  const b = derived ? boundsOfPath(derived) : regionBoundsOf(node, pose, g);
63
+ const decided = regionTakesByBounds(r, mode, b);
64
+ if (decided !== void 0) return decided;
63
65
  let ink;
64
66
  const filled = () => ink ??= findShapeInk(node, pose, { inherited })?.filled !== false;
65
67
  return regionTakes(r, mode, asInked(filled, pose), b, () => asInked(filled, findShapeSilhouette(node, pose, { derivedPath: derived }) ?? derived ?? poseOutline(pose, b)), filled);
@@ -1 +1 @@
1
- {"version":3,"file":"hitTestArea.js","names":[],"sources":["../../../src/canvas/deps/hitTestArea.ts"],"sourcesContent":["/**\n * Silhouette-aware area hit-test for marquee and lasso selection.\n *\n * The per-node decision is `regionTakes` (`core/geometry/regionHit`). This\n * module supplies the scene walk and the node's drawn outline: the painter's\n * world-frame silhouette (`findShapeSilhouette`), or with no painter the pose\n * rect, rotated if the pose is.\n */\nimport type { Scene, NodeId } from 'core/scene/types';\nimport { applyToPoint, boundsOfPath, pathIntersectsRect, type Affine } from '@weasel-js/geom';\nimport type { LassoHitMode } from 'core/adapters/types';\nimport {\n poseDescriptorForNode,\n visualBoundsViaDescriptor,\n type PoseDescriptor,\n} from 'interactions/actions/resize/geometry';\nimport { AUTO_POSE_DESCRIPTOR } from 'core/geometry/autoPoseDescriptor';\nimport {\n pickWalk,\n scenePickSource,\n type PickQuery,\n type ScenePickSourceOptions,\n} from 'canvas/pickWalk';\nimport { rectToPlane, toPlane, type PlaneMap } from 'core/viewport/parallax';\n\nimport type { HitTestView } from 'interactions/actions/depSchema';\nimport { findShapeInk, findShapeSilhouette } from 'canvas/NodeShape';\nimport {\n polygonRegion,\n poseOutline,\n rectRegion,\n regionBoundsOf,\n regionOf,\n regionTakes,\n type SelectRegion,\n} from 'core/geometry/regionHit';\n\nexport interface AABBBounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** What a region query takes back beyond leaves. */\nexport interface RegionQueryOptions {\n /** Default `false`: a region that takes a group and its members\n * selects the same ink twice. A bare-adapter consumer, which has nothing\n * to fold members back into their group, asks for them. */\n includeGroups?: boolean;\n}\n\n\n/** The pick options a region dep hands the shared walk: the asking view's\n * layer gate and camera, and the surface's alpha. */\nexport function regionPickOptions(\n view: HitTestView | undefined,\n alphaOf: ((id: string) => number) | undefined,\n): ScenePickSourceOptions<unknown> {\n const camera = view?.get?.();\n return {\n ...(alphaOf ? { alphaOf } : {}),\n ...(view?.layerIsPainted ? { layerIsPainted: (layer: string) => view.layerIsPainted!(layer) } : {}),\n ...(camera ? { camera } : {}),\n };\n}\n\n/** Marquee entry point: every node the rect `bounds` meets. */\nexport function hitTestArea(\n scene: Scene<unknown, string, unknown>,\n bounds: AABBBounds,\n opts?: ScenePickSourceOptions<unknown>,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n query: RegionQueryOptions = {},\n): NodeId[] {\n return walkArea(scene, rectRegion(bounds), 'intersect', opts, descriptor, query);\n}\n\n/**\n * Every node an arbitrary closed area polygon meets. `area` is interleaved\n * `[x0,y0,x1,y1,…]`; `areaBounds` is its AABB, derived when omitted.\n */\nexport function hitTestAreaPolygon(\n scene: Scene<unknown, string, unknown>,\n area: ArrayLike<number>,\n areaBounds?: AABBBounds,\n /** True when `area` IS its own bounding rect, so `areaBounds` containment\n * implies containment in the area proper. Never pass this for a lasso\n * polygon — a node inside the hull's box can miss the hull. */\n areaIsRect = false,\n /** The asking view's alpha and layer accessors. A bare scene answers for\n * itself; a view that dims or reorders layers has to supply its own. */\n opts?: ScenePickSourceOptions<unknown>,\n /** How to read this scene's poses. Default `AUTO_POSE_DESCRIPTOR`. */\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n query: RegionQueryOptions = {},\n): NodeId[] {\n const region = regionOf(area, areaBounds, areaIsRect);\n return region ? walkArea(scene, region, 'intersect', opts, descriptor, query) : [];\n}\n\n/**\n * Lasso entry point: which nodes a closed lasso polygon picks under `mode`\n * (see `regionTakes`).\n */\nexport function hitTestLassoPolygon(\n scene: Scene<unknown, string, unknown>,\n polygon: ReadonlyArray<{ x: number; y: number }>,\n mode: LassoHitMode,\n opts?: ScenePickSourceOptions<unknown>,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n query: RegionQueryOptions = {},\n): NodeId[] {\n const region = polygonRegion(polygon);\n return region ? walkArea(scene, region, mode, opts, descriptor, query) : [];\n}\n\n/** `shape` as a region reads it: a polygon path's open subpaths enclose\n * nothing when the node's painter lays down no fill. */\nfunction asInked<T>(filled: () => boolean, shape: T): T {\n if ((shape as { kind?: unknown } | null)?.kind !== 'polygon') return shape;\n return filled() ? shape : { ...shape, openFill: 'none' };\n}\n\n/** The walk every region query shares: skip groups unless asked, gate on\n * the clip, and let `regionTakes` decide each node. */\nfunction walkArea(\n scene: Scene<unknown, string, unknown>,\n region: SelectRegion,\n mode: LassoHitMode,\n opts: ScenePickSourceOptions<unknown> | undefined,\n descriptor: PoseDescriptor<unknown>,\n query: RegionQueryOptions,\n): NodeId[] {\n const src = scenePickSource(scene, { ...opts, index: { descriptor } });\n return pickWalk<unknown>(src, regionPickQuery(region, mode, descriptor, query)) as NodeId[];\n}\n\n/** The query a marquee or a lasso over `r` asks of each node. */\nexport function regionPickQuery(\n r: SelectRegion,\n mode: LassoHitMode,\n descriptor: PoseDescriptor<unknown>,\n query: RegionQueryOptions,\n): PickQuery<unknown> {\n return {\n includeGroups: query.includeGroups === true,\n broad: { box: r.bounds },\n clipAdmits: (clip, node, pose, derived) => {\n const g = poseDescriptorForNode(descriptor, node);\n return pathIntersectsRect(clip, derived ? boundsOfPath(derived) : visualBoundsViaDescriptor(pose, g))\n && pathIntersectsRect(clip, r.bounds);\n },\n hits: (node, pose, derived, inherited) => {\n // The descriptor sees the node here, so a pose shape whose extent\n // depends on `node.data` bounds itself rather than its pose's default.\n const g = poseDescriptorForNode(descriptor, node);\n // A derived node's pose is a placeholder: its path is the extent and the fallback outline.\n const b = derived ? boundsOfPath(derived) : regionBoundsOf(node as object, pose, g);\n let ink: boolean | undefined;\n const filled = (): boolean => ink ??= findShapeInk(node as never, pose, { inherited })?.filled !== false;\n return regionTakes(r, mode, asInked(filled, pose), b, () =>\n asInked(filled, findShapeSilhouette(node as never, pose, { derivedPath: derived }) ?? derived ?? poseOutline(pose, b)), filled);\n },\n inPlane: (m) => regionPickQuery(regionInPlane(r, m), mode, descriptor, query),\n // A copy is tested by every walk, so the query carried into one asks no index.\n inCopy: (m) => ({ ...regionPickQuery(regionInCopy(r, m), mode, descriptor, query), broad: undefined }),\n };\n}\n\n/** `r` carried into a plane's world. The map is axis-aligned, so a rect stays\n * one; a flipped axis reverses the winding, which no region test reads. */\nfunction regionInPlane(r: SelectRegion, m: PlaneMap): SelectRegion {\n const coords: number[] = [];\n for (const v of r.verts) {\n const p = toPlane(m, v);\n coords.push(p.x, p.y);\n }\n return regionOf(coords, rectToPlane(m, r.bounds), r.isRect)!;\n}\n\n/** `r` carried by an affine into a copy's source frame. A rect stays one only\n * while the map keeps the axes; a turn makes it a polygon. */\nfunction regionInCopy(r: SelectRegion, m: Affine): SelectRegion {\n const coords: number[] = [];\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const v of r.verts) {\n const [x, y] = applyToPoint(m, v.x, v.y);\n coords.push(x, y);\n x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y);\n }\n const keepsAxes = (m[1] === 0 && m[2] === 0) || (m[0] === 0 && m[3] === 0);\n return regionOf(coords, { x: x0, y: y0, width: x1 - x0, height: y1 - y0 }, r.isRect && keepsAxes)!;\n}\n"],"mappings":";;;;;;;;;;;;AAuDA,SAAgB,kBACd,MACA,SACiC;CACjC,MAAM,SAAS,MAAM,MAAM;CAC3B,OAAO;EACL,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC7B,GAAI,MAAM,iBAAiB,EAAE,iBAAiB,UAAkB,KAAK,eAAgB,KAAK,EAAE,IAAI,CAAC;EACjG,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAC7B;AACF;;AAGA,SAAgB,YACd,OACA,QACA,MACA,aAAsC,sBACtC,QAA4B,CAAC,GACnB;CACV,OAAO,SAAS,OAAO,WAAW,MAAM,GAAG,aAAa,MAAM,YAAY,KAAK;AACjF;;;;;AA6BA,SAAgB,oBACd,OACA,SACA,MACA,MACA,aAAsC,sBACtC,QAA4B,CAAC,GACnB;CACV,MAAM,SAAS,cAAc,OAAO;CACpC,OAAO,SAAS,SAAS,OAAO,QAAQ,MAAM,MAAM,YAAY,KAAK,IAAI,CAAC;AAC5E;;;AAIA,SAAS,QAAW,QAAuB,OAAa;CACtD,IAAK,OAAqC,SAAS,WAAW,OAAO;CACrE,OAAO,OAAO,IAAI,QAAQ;EAAE,GAAG;EAAO,UAAU;CAAO;AACzD;;;AAIA,SAAS,SACP,OACA,QACA,MACA,MACA,YACA,OACU;CACV,MAAM,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AS,QAAQ,YAAY,GAAG,EAAE,MAAM,GAAG,EAAE,MAAM;AAC5D;;;AAIA,SAAS,aAAa,GAAiB,GAAyB;CAC9D,MAAM,SAAmB,CAAC;CAC1B,IAAI,KAAK,UAAU,KAAK,UAAU,KAAK,WAAW,KAAK;CACvD,KAAK,MAAM,KAAK,EAAE,OAAO;EACvB,MAAM,CAAC,GAAG,KAAK,aAAa,GAAG,EAAE,GAAG,EAAE,CAAC;EACvC,OAAO,KAAK,GAAG,CAAC;EAChB,KAAK,KAAK,IAAI,IAAI,CAAC;EAAG,KAAK,KAAK,IAAI,IAAI,CAAC;EAAG,KAAK,KAAK,IAAI,IAAI,CAAC;EAAG,KAAK,KAAK,IAAI,IAAI,CAAC;CACvF;CACA,MAAM,YAAa,EAAE,OAAO,KAAK,EAAE,OAAO,KAAO,EAAE,OAAO,KAAK,EAAE,OAAO;CACxE,OAAO,SAAS,QAAQ;EAAE,GAAG;EAAI,GAAG;EAAI,OAAO,KAAK;EAAI,QAAQ,KAAK;CAAG,GAAG,EAAE,UAAU,SAAS;AAClG"}
1
+ {"version":3,"file":"hitTestArea.js","names":[],"sources":["../../../src/canvas/deps/hitTestArea.ts"],"sourcesContent":["/**\n * Silhouette-aware area hit-test for marquee and lasso selection.\n *\n * The per-node decision is `regionTakes` (`core/geometry/regionHit`). This\n * module supplies the scene walk and the node's drawn outline: the painter's\n * world-frame silhouette (`findShapeSilhouette`), or with no painter the pose\n * rect, rotated if the pose is.\n */\nimport type { Scene, NodeId } from 'core/scene/types';\nimport { applyToPoint, boundsOfPath, pathIntersectsRect, type Affine } from '@weasel-js/geom';\nimport type { LassoHitMode } from 'core/adapters/types';\nimport {\n poseDescriptorForNode,\n visualBoundsViaDescriptor,\n type PoseDescriptor,\n} from 'interactions/actions/resize/geometry';\nimport { AUTO_POSE_DESCRIPTOR } from 'core/geometry/autoPoseDescriptor';\nimport {\n pickWalk,\n scenePickSource,\n type PickQuery,\n type ScenePickSourceOptions,\n} from 'canvas/pickWalk';\nimport { rectToPlane, toPlane, type PlaneMap } from 'core/viewport/parallax';\n\nimport type { HitTestView } from 'interactions/actions/depSchema';\nimport { findShapeInk, findShapeSilhouette } from 'canvas/NodeShape';\nimport {\n polygonRegion,\n poseOutline,\n rectRegion,\n regionBoundsOf,\n regionOf,\n regionTakes,\n regionTakesByBounds,\n type SelectRegion,\n} from 'core/geometry/regionHit';\n\nexport interface AABBBounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** What a region query takes back beyond leaves. */\nexport interface RegionQueryOptions {\n /** Default `false`: a region that takes a group and its members\n * selects the same ink twice. A bare-adapter consumer, which has nothing\n * to fold members back into their group, asks for them. */\n includeGroups?: boolean;\n}\n\n\n/** The pick options a region dep hands the shared walk: the asking view's\n * layer gate and camera, and the surface's alpha. */\nexport function regionPickOptions(\n view: HitTestView | undefined,\n alphaOf: ((id: string) => number) | undefined,\n): ScenePickSourceOptions<unknown> {\n const camera = view?.get?.();\n return {\n ...(alphaOf ? { alphaOf } : {}),\n ...(view?.layerIsPainted ? { layerIsPainted: (layer: string) => view.layerIsPainted!(layer) } : {}),\n ...(camera ? { camera } : {}),\n };\n}\n\n/** Marquee entry point: every node the rect `bounds` meets. */\nexport function hitTestArea(\n scene: Scene<unknown, string, unknown>,\n bounds: AABBBounds,\n opts?: ScenePickSourceOptions<unknown>,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n query: RegionQueryOptions = {},\n): NodeId[] {\n return walkArea(scene, rectRegion(bounds), 'intersect', opts, descriptor, query);\n}\n\n/**\n * Every node an arbitrary closed area polygon meets. `area` is interleaved\n * `[x0,y0,x1,y1,…]`; `areaBounds` is its AABB, derived when omitted.\n */\nexport function hitTestAreaPolygon(\n scene: Scene<unknown, string, unknown>,\n area: ArrayLike<number>,\n areaBounds?: AABBBounds,\n /** True when `area` IS its own bounding rect, so `areaBounds` containment\n * implies containment in the area proper. Never pass this for a lasso\n * polygon — a node inside the hull's box can miss the hull. */\n areaIsRect = false,\n /** The asking view's alpha and layer accessors. A bare scene answers for\n * itself; a view that dims or reorders layers has to supply its own. */\n opts?: ScenePickSourceOptions<unknown>,\n /** How to read this scene's poses. Default `AUTO_POSE_DESCRIPTOR`. */\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n query: RegionQueryOptions = {},\n): NodeId[] {\n const region = regionOf(area, areaBounds, areaIsRect);\n return region ? walkArea(scene, region, 'intersect', opts, descriptor, query) : [];\n}\n\n/**\n * Lasso entry point: which nodes a closed lasso polygon picks under `mode`\n * (see `regionTakes`).\n */\nexport function hitTestLassoPolygon(\n scene: Scene<unknown, string, unknown>,\n polygon: ReadonlyArray<{ x: number; y: number }>,\n mode: LassoHitMode,\n opts?: ScenePickSourceOptions<unknown>,\n descriptor: PoseDescriptor<unknown> = AUTO_POSE_DESCRIPTOR,\n query: RegionQueryOptions = {},\n): NodeId[] {\n const region = polygonRegion(polygon);\n return region ? walkArea(scene, region, mode, opts, descriptor, query) : [];\n}\n\n/** `shape` as a region reads it: a polygon path's open subpaths enclose\n * nothing when the node's painter lays down no fill. */\nfunction asInked<T>(filled: () => boolean, shape: T): T {\n if ((shape as { kind?: unknown } | null)?.kind !== 'polygon') return shape;\n return filled() ? shape : { ...shape, openFill: 'none' };\n}\n\n/** The walk every region query shares: skip groups unless asked, gate on\n * the clip, and let `regionTakes` decide each node. */\nfunction walkArea(\n scene: Scene<unknown, string, unknown>,\n region: SelectRegion,\n mode: LassoHitMode,\n opts: ScenePickSourceOptions<unknown> | undefined,\n descriptor: PoseDescriptor<unknown>,\n query: RegionQueryOptions,\n): NodeId[] {\n const src = scenePickSource(scene, { ...opts, index: { descriptor } });\n return pickWalk<unknown>(src, regionPickQuery(region, mode, descriptor, query)) as NodeId[];\n}\n\n/** The query a marquee or a lasso over `r` asks of each node. */\nexport function regionPickQuery(\n r: SelectRegion,\n mode: LassoHitMode,\n descriptor: PoseDescriptor<unknown>,\n query: RegionQueryOptions,\n): PickQuery<unknown> {\n return {\n includeGroups: query.includeGroups === true,\n broad: { box: r.bounds },\n clipAdmits: (clip, node, pose, derived) => {\n const g = poseDescriptorForNode(descriptor, node);\n return pathIntersectsRect(clip, derived ? boundsOfPath(derived) : visualBoundsViaDescriptor(pose, g))\n && pathIntersectsRect(clip, r.bounds);\n },\n hits: (node, pose, derived, inherited) => {\n // The descriptor sees the node here, so a pose shape whose extent\n // depends on `node.data` bounds itself rather than its pose's default.\n const g = poseDescriptorForNode(descriptor, node);\n // A derived node's pose is a placeholder: its path is the extent and the fallback outline.\n const b = derived ? boundsOfPath(derived) : regionBoundsOf(node as object, pose, g);\n const decided = regionTakesByBounds(r, mode, b);\n if (decided !== undefined) return decided;\n let ink: boolean | undefined;\n const filled = (): boolean => ink ??= findShapeInk(node as never, pose, { inherited })?.filled !== false;\n return regionTakes(r, mode, asInked(filled, pose), b, () =>\n asInked(filled, findShapeSilhouette(node as never, pose, { derivedPath: derived }) ?? derived ?? poseOutline(pose, b)), filled);\n },\n inPlane: (m) => regionPickQuery(regionInPlane(r, m), mode, descriptor, query),\n // A copy is tested by every walk, so the query carried into one asks no index.\n inCopy: (m) => ({ ...regionPickQuery(regionInCopy(r, m), mode, descriptor, query), broad: undefined }),\n };\n}\n\n/** `r` carried into a plane's world. The map is axis-aligned, so a rect stays\n * one; a flipped axis reverses the winding, which no region test reads. */\nfunction regionInPlane(r: SelectRegion, m: PlaneMap): SelectRegion {\n const coords: number[] = [];\n for (const v of r.verts) {\n const p = toPlane(m, v);\n coords.push(p.x, p.y);\n }\n return regionOf(coords, rectToPlane(m, r.bounds), r.isRect)!;\n}\n\n/** `r` carried by an affine into a copy's source frame. A rect stays one only\n * while the map keeps the axes; a turn makes it a polygon. */\nfunction regionInCopy(r: SelectRegion, m: Affine): SelectRegion {\n const coords: number[] = [];\n let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n for (const v of r.verts) {\n const [x, y] = applyToPoint(m, v.x, v.y);\n coords.push(x, y);\n x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y);\n }\n const keepsAxes = (m[1] === 0 && m[2] === 0) || (m[0] === 0 && m[3] === 0);\n return regionOf(coords, { x: x0, y: y0, width: x1 - x0, height: y1 - y0 }, r.isRect && keepsAxes)!;\n}\n"],"mappings":";;;;;;;;;;;;AAwDA,SAAgB,kBACd,MACA,SACiC;CACjC,MAAM,SAAS,MAAM,MAAM;CAC3B,OAAO;EACL,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;EAC7B,GAAI,MAAM,iBAAiB,EAAE,iBAAiB,UAAkB,KAAK,eAAgB,KAAK,EAAE,IAAI,CAAC;EACjG,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;CAC7B;AACF;;AAGA,SAAgB,YACd,OACA,QACA,MACA,aAAsC,sBACtC,QAA4B,CAAC,GACnB;CACV,OAAO,SAAS,OAAO,WAAW,MAAM,GAAG,aAAa,MAAM,YAAY,KAAK;AACjF;;;;;AA6BA,SAAgB,oBACd,OACA,SACA,MACA,MACA,aAAsC,sBACtC,QAA4B,CAAC,GACnB;CACV,MAAM,SAAS,cAAc,OAAO;CACpC,OAAO,SAAS,SAAS,OAAO,QAAQ,MAAM,MAAM,YAAY,KAAK,IAAI,CAAC;AAC5E;;;AAIA,SAAS,QAAW,QAAuB,OAAa;CACtD,IAAK,OAAqC,SAAS,WAAW,OAAO;CACrE,OAAO,OAAO,IAAI,QAAQ;EAAE,GAAG;EAAO,UAAU;CAAO;AACzD;;;AAIA,SAAS,SACP,OACA,QACA,MACA,MACA,YACA,OACU;CACV,MAAM,MAAM,gBAAgB,OAAO;EAAE,GAAG;EAAM,OAAO,EAAE,WAAW;CAAE,CAAC;CACrE,OAAO,SAAkB,KAAK,gBAAgB,QAAQ,MAAM,YAAY,KAAK,CAAC;AAChF;;AAGA,SAAgB,gBACd,GACA,MACA,YACA,OACoB;CACpB,OAAO;EACL,eAAe,MAAM,kBAAkB;EACvC,OA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K,UAAU,KAAK,WAAW,KAAK;CACvD,KAAK,MAAM,KAAK,EAAE,OAAO;EACvB,MAAM,CAAC,GAAG,KAAK,aAAa,GAAG,EAAE,GAAG,EAAE,CAAC;EACvC,OAAO,KAAK,GAAG,CAAC;EAChB,KAAK,KAAK,IAAI,IAAI,CAAC;EAAG,KAAK,KAAK,IAAI,IAAI,CAAC;EAAG,KAAK,KAAK,IAAI,IAAI,CAAC;EAAG,KAAK,KAAK,IAAI,IAAI,CAAC;CACvF;CACA,MAAM,YAAa,EAAE,OAAO,KAAK,EAAE,OAAO,KAAO,EAAE,OAAO,KAAK,EAAE,OAAO;CACxE,OAAO,SAAS,QAAQ;EAAE,GAAG;EAAI,GAAG;EAAI,OAAO,KAAK;EAAI,QAAQ,KAAK;CAAG,GAAG,EAAE,UAAU,SAAS;AAClG"}
@@ -0,0 +1,23 @@
1
+ import { useLatest } from "@weasel-js/react";
2
+ import { useDepSource } from "@weasel-js/routing/react";
3
+ import { defaultToolOf } from "@weasel-js/modes";
4
+
5
+ //#region src/canvas/deps/modeDefaultTool.ts
6
+ /**
7
+ * Wires the `modeDefaultTool` dep: the tool the canvas's active mode starts
8
+ * on, when the canvas mounts it. Absent with no mode registry.
9
+ */
10
+ function useModeDefaultToolDepSource(modes, tools) {
11
+ const ref = useLatest({
12
+ modes,
13
+ tools
14
+ });
15
+ useDepSource("modeDefaultTool", () => {
16
+ const { modes: m } = ref.current;
17
+ return m ? () => defaultToolOf(m.current(), ref.current.tools.has) : void 0;
18
+ });
19
+ }
20
+
21
+ //#endregion
22
+ export { useModeDefaultToolDepSource };
23
+ //# sourceMappingURL=modeDefaultTool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modeDefaultTool.js","names":[],"sources":["../../../src/canvas/deps/modeDefaultTool.ts"],"sourcesContent":["/**\n * Wires the `modeDefaultTool` dep: the tool the canvas's active mode starts\n * on, when the canvas mounts it. Absent with no mode registry.\n */\nimport { defaultToolOf, type ModeRegistry } from '@weasel-js/modes';\nimport { useLatest } from '@weasel-js/react';\nimport { useDepSource } from '@weasel-js/routing/react';\nimport type { ToolsApi } from 'tools/overlayBinding';\n\nexport function useModeDefaultToolDepSource(modes: ModeRegistry | undefined, tools: Pick<ToolsApi, 'has'>): void {\n const ref = useLatest({ modes, tools });\n useDepSource('modeDefaultTool', () => {\n const { modes: m } = ref.current;\n return m ? () => defaultToolOf(m.current(), ref.current.tools.has) : undefined;\n });\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,4BAA4B,OAAiC,OAAoC;CAC/G,MAAM,MAAM,UAAU;EAAE;EAAO;CAAM,CAAC;CACtC,aAAa,yBAAyB;EACpC,MAAM,EAAE,OAAO,MAAM,IAAI;EACzB,OAAO,UAAU,cAAc,EAAE,QAAQ,GAAG,IAAI,QAAQ,MAAM,GAAG,IAAI;CACvE,CAAC;AACH"}
@@ -1,9 +1,9 @@
1
1
  import { sceneDependentsOf } from "../../core/scene/dependents.js";
2
2
  import { createTransformOp } from "../../core/ops/transform.js";
3
3
  import { createSetDataOp } from "../../core/ops/setData.js";
4
+ import { withoutShapeGenerator } from "../../domains/paths/shapeGenerator.js";
4
5
  import { createDeleteOp } from "../../core/ops/delete.js";
5
6
  import { pathEditPathOf, storeEditablePath } from "../../domains/paths/editablePath.js";
6
- import { withoutShapeGenerator } from "../../domains/paths/shapeGenerator.js";
7
7
  import { withoutGeometryBoundData } from "../../domains/paths/pathEditExtension.js";
8
8
  import { writtenBy } from "../../core/ops/writtenBy.js";
9
9
 
@@ -0,0 +1,23 @@
1
+ import { useDepRegistry, useDepSource } from "@weasel-js/routing/react";
2
+
3
+ //#region src/canvas/deps/selectionSnapshot.ts
4
+ var sameIds = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
5
+ function useSelectionSnapshotDepSource() {
6
+ const registry = useDepRegistry();
7
+ useDepSource("selectionSnapshot", () => ({ take() {
8
+ const ids = registry.get("selection")?.get() ?? null;
9
+ const edit = registry.get("editAnchors");
10
+ const editing = edit?.editingId ?? "";
11
+ const anchors = edit ? [...edit.selectedAnchors] : [];
12
+ return () => {
13
+ const selection = registry.get("selection");
14
+ if (ids && selection && !sameIds(selection.get(), ids)) selection.set([...ids]);
15
+ const now = registry.get("editAnchors");
16
+ if (editing && now?.editingId === editing) now.setSelectedAnchors(anchors);
17
+ };
18
+ } }));
19
+ }
20
+
21
+ //#endregion
22
+ export { useSelectionSnapshotDepSource };
23
+ //# sourceMappingURL=selectionSnapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectionSnapshot.js","names":[],"sources":["../../../src/canvas/deps/selectionSnapshot.ts"],"sourcesContent":["/**\n * The `selectionSnapshot` dep: the node selection and, in path edit, the anchor\n * selection, captured together, so the last operation puts both back before it\n * reruns an action that changed them.\n */\nimport type { SelectionSnapshotDep } from '@weasel-js/routing';\nimport { useDepRegistry, useDepSource } from '@weasel-js/routing/react';\nimport type {} from '../../interactions/actions/depSchema';\n\nconst sameIds = (a: readonly string[], b: readonly string[]): boolean =>\n a.length === b.length && a.every((id, i) => id === b[i]);\n\nexport function useSelectionSnapshotDepSource(): void {\n const registry = useDepRegistry();\n useDepSource('selectionSnapshot', (): SelectionSnapshotDep => ({\n take() {\n const ids = registry.get('selection')?.get() ?? null;\n const edit = registry.get('editAnchors');\n const editing = edit?.editingId ?? '';\n const anchors = edit ? [...edit.selectedAnchors] : [];\n return () => {\n const selection = registry.get('selection');\n if (ids && selection && !sameIds(selection.get(), ids)) selection.set([...ids] as never);\n const now = registry.get('editAnchors');\n if (editing && now?.editingId === editing) now.setSelectedAnchors(anchors);\n };\n },\n }));\n}\n"],"mappings":";;;AASA,IAAM,WAAW,GAAsB,MACrC,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,IAAI,MAAM,OAAO,EAAE,EAAE;AAEzD,SAAgB,gCAAsC;CACpD,MAAM,WAAW,eAAe;CAChC,aAAa,4BAAkD,EAC7D,OAAO;EACL,MAAM,MAAM,SAAS,IAAI,WAAW,CAAC,EAAE,IAAI,KAAK;EAChD,MAAM,OAAO,SAAS,IAAI,aAAa;EACvC,MAAM,UAAU,MAAM,aAAa;EACnC,MAAM,UAAU,OAAO,CAAC,GAAG,KAAK,eAAe,IAAI,CAAC;EACpD,aAAa;GACX,MAAM,YAAY,SAAS,IAAI,WAAW;GAC1C,IAAI,OAAO,aAAa,CAAC,QAAQ,UAAU,IAAI,GAAG,GAAG,GAAG,UAAU,IAAI,CAAC,GAAG,GAAG,CAAU;GACvF,MAAM,MAAM,SAAS,IAAI,aAAa;GACtC,IAAI,WAAW,KAAK,cAAc,SAAS,IAAI,mBAAmB,OAAO;EAC3E;CACF,EACF,EAAE;AACJ"}
@@ -53,6 +53,7 @@ function useSnapDepSource(viewRef, session, store) {
53
53
  reachPx,
54
54
  ...s.poseDescriptor ? { poseDescriptor: s.poseDescriptor } : {},
55
55
  ...s.originProjection ? { originProjection: s.originProjection } : {},
56
+ ...s.anchors ? { anchors: s.anchors } : {},
56
57
  ...debug ? { debug } : {},
57
58
  store
58
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"snap.js","names":[],"sources":["../../../src/canvas/deps/snap.ts"],"sourcesContent":["/**\n * `useSnapDepSource` — wires the `snap` dep whose `begin` every snapping\n * gesture runs: a session over the snap sources `session` names, writing its\n * marks to the outcome store this hook returns.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useKitSettings, useLatest } from '@weasel-js/react';\nimport type { DebugSink, WorldPoint } from '@weasel-js/routing';\nimport type { SnapDep } from 'interactions/actions/snapDep';\nimport { ownGeometryAt } from 'domains/paths/pathSnap/pathSnapSource';\nimport type { View } from 'core/viewport/view';\nimport type { Scene } from 'core/scene/types';\nimport type { DrawnBoxes } from 'interactions/actions/drawnBoxes';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { OriginProjection } from 'interactions/gestures/shared/originProjection';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSourceRegistry } from 'domains/snap/registry';\nimport { assertSnapSourceIds, snapSourcesFor } from 'domains/snap/gather';\nimport { sceneSession2d } from 'domains/snap/sceneSession2d';\nimport { DEFAULT_SNAP_PX } from 'domains/snap/session2d';\nimport type { SnapReadoutDep } from 'domains/snap/readoutDep';\nimport { rotationSnapSource } from 'domains/snap/rotationSource';\nimport { pathSnapSource } from 'domains/paths/pathSnap/pathSnapSource';\nimport type { SnapSource } from 'domains/snap/types';\n\n/** What `begin` reads: the scene its probes come from and the sources it asks. */\nexport interface SnapSessionSources {\n scene: Scene<unknown, string, unknown>;\n /** The boxes the subject is drawn with, read when a session begins. */\n boxes: () => DrawnBoxes;\n /** `<SceneCanvas snap.sources>`, then the presets' `snapSources`. */\n sources: readonly SnapSource[];\n /** Sources `useSnapSource` adds, after `sources`. */\n registry?: SnapSourceRegistry;\n /** Ids of the canvas's default sources to leave out. */\n omit?: readonly string[];\n /** Overrides the kit setting `targets.snapPx`. */\n reachPx?: number;\n /** How a node's rotation is read, for angle targets. */\n poseDescriptor?: PoseDescriptor<unknown>;\n /** How a pose's origin is read, for the `origin` probe. */\n originProjection?: OriginProjection<unknown>;\n /** The canvas's debug sink, read when a session begins: each frame's\n * candidates are recorded into it. */\n debug?: () => DebugSink | null | undefined;\n}\n\n/** The sources every canvas asks after its own, unless `omit` names one:\n * quarter turns and other nodes' angles for a rotate, and other nodes'\n * anchors for a point gesture, under `pathSnapSource`'s own id, so a\n * consumer's `pathSnapSource()` takes its place. */\nconst DEFAULT_SNAP_SOURCES: readonly SnapSource[] = [\n rotationSnapSource(),\n { ...pathSnapSource({ only: ['anchor'] }), gestures: ['point'] },\n];\n\n/** `listed`, which must not repeat an id, then each default whose id is\n * neither listed nor in `omit`. */\nfunction withDefaults(listed: readonly SnapSource[], omit: readonly string[] = []): SnapSource[] {\n assertSnapSourceIds(listed);\n const taken = new Set([...listed.map((s) => s.id), ...omit]);\n return [...listed, ...DEFAULT_SNAP_SOURCES.filter((s) => !taken.has(s.id))];\n}\n\nexport function useSnapDepSource(\n viewRef: React.RefObject<View | null>,\n session: SnapSessionSources,\n /** The canvas's outcome store, which its readout layer draws. */\n store: SnapOutcomeStore,\n): SnapOutcomeStore {\n const sessionRef = useLatest(session);\n const kitSettings = useKitSettings();\n useDepSource('snapReadout', (): SnapReadoutDep => ({ store }));\n\n useDepSource('snap', (): SnapDep => ({\n begin: (req) => {\n const s = sessionRef.current;\n const view = viewRef.current;\n const omit = new Set(req.omit);\n const sources = [\n ...withDefaults([...s.sources, ...(s.registry?.list() ?? [])], s.omit).filter((src) => !omit.has(src.id)),\n ...(req.sources ?? []),\n ];\n assertSnapSourceIds(sources);\n const wantsGeometry = snapSourcesFor(sources, req.gesture).some((src) => src.roles.includes('geometry'));\n const debug = s.debug?.() ?? undefined;\n const reachPx = s.reachPx ?? kitSettings.get('targets.snapPx') ?? DEFAULT_SNAP_PX;\n return sceneSession2d({\n req,\n scene: s.scene,\n boxes: s.boxes(),\n sources,\n ...(wantsGeometry ? { geometryAt: (press: WorldPoint, ids: readonly string[]) => ownGeometryAt(s.scene, press, ids, view?.scale ?? { x: 1, y: 1 }, reachPx) } : {}),\n view: () => viewRef.current,\n reachPx,\n ...(s.poseDescriptor ? { poseDescriptor: s.poseDescriptor } : {}),\n ...(s.originProjection ? { originProjection: s.originProjection } : {}),\n ...(debug ? { debug } : {}),\n store,\n });\n },\n }));\n return store;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmDA,IAAM,uBAA8C,CAClD,mBAAmB,GACnB;CAAE,GAAG,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;CAAG,UAAU,CAAC,OAAO;AAAE,CACjE;;;AAIA,SAAS,aAAa,QAA+B,OAA0B,CAAC,GAAiB;CAC/F,oBAAoB,MAAM;CAC1B,MAAM,wBAAQ,IAAI,IAAI,CAAC,GAAG,OAAO,KAAK,MAAM,EAAE,EAAE,GAAG,GAAG,IAAI,CAAC;CAC3D,OAAO,CAAC,GAAG,QAAQ,GAAG,qBAAqB,QAAQ,MAAM,C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js","names":[],"sources":["../../../src/canvas/deps/snap.ts"],"sourcesContent":["/**\n * `useSnapDepSource` — wires the `snap` dep whose `begin` every snapping\n * gesture runs: a session over the snap sources `session` names, writing its\n * marks to the outcome store this hook returns.\n */\nimport { useDepSource } from '@weasel-js/routing/react';\nimport { useKitSettings, useLatest } from '@weasel-js/react';\nimport type { DebugSink, WorldPoint } from '@weasel-js/routing';\nimport type { SnapDep } from 'interactions/actions/snapDep';\nimport { ownGeometryAt } from 'domains/paths/pathSnap/pathSnapSource';\nimport type { View } from 'core/viewport/view';\nimport type { Scene } from 'core/scene/types';\nimport type { DrawnBoxes } from 'interactions/actions/drawnBoxes';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { OriginProjection } from 'interactions/gestures/shared/originProjection';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSourceRegistry } from 'domains/snap/registry';\nimport { assertSnapSourceIds, snapSourcesFor } from 'domains/snap/gather';\nimport { sceneSession2d } from 'domains/snap/sceneSession2d';\nimport { DEFAULT_SNAP_PX } from 'domains/snap/session2d';\nimport type { SnapReadoutDep } from 'domains/snap/readoutDep';\nimport { rotationSnapSource } from 'domains/snap/rotationSource';\nimport { pathSnapSource } from 'domains/paths/pathSnap/pathSnapSource';\nimport type { SnapAnchors, SnapSource } from 'domains/snap/types';\n\n/** What `begin` reads: the scene its probes come from and the sources it asks. */\nexport interface SnapSessionSources {\n scene: Scene<unknown, string, unknown>;\n /** The boxes the subject is drawn with, read when a session begins. */\n boxes: () => DrawnBoxes;\n /** `<SceneCanvas snap.sources>`, then the presets' `snapSources`. */\n sources: readonly SnapSource[];\n /** Sources `useSnapSource` adds, after `sources`. */\n registry?: SnapSourceRegistry;\n /** Ids of the canvas's default sources to leave out. */\n omit?: readonly string[];\n /** Overrides the kit setting `targets.snapPx`. */\n reachPx?: number;\n /** How a node's rotation is read, for angle targets. */\n poseDescriptor?: PoseDescriptor<unknown>;\n /** How a pose's origin is read, for the `origin` probe. */\n originProjection?: OriginProjection<unknown>;\n /** Each node's snap anchors, for the `anchor` probes of a move. */\n anchors?: SnapAnchors;\n /** The canvas's debug sink, read when a session begins: each frame's\n * candidates are recorded into it. */\n debug?: () => DebugSink | null | undefined;\n}\n\n/** The sources every canvas asks after its own, unless `omit` names one:\n * quarter turns and other nodes' angles for a rotate, and other nodes'\n * anchors for a point gesture, under `pathSnapSource`'s own id, so a\n * consumer's `pathSnapSource()` takes its place. */\nconst DEFAULT_SNAP_SOURCES: readonly SnapSource[] = [\n rotationSnapSource(),\n { ...pathSnapSource({ only: ['anchor'] }), gestures: ['point'] },\n];\n\n/** `listed`, which must not repeat an id, then each default whose id is\n * neither listed nor in `omit`. */\nfunction withDefaults(listed: readonly SnapSource[], omit: readonly string[] = []): SnapSource[] {\n assertSnapSourceIds(listed);\n const taken = new Set([...listed.map((s) => s.id), ...omit]);\n return [...listed, ...DEFAULT_SNAP_SOURCES.filter((s) => !taken.has(s.id))];\n}\n\nexport function useSnapDepSource(\n viewRef: React.RefObject<View | null>,\n session: SnapSessionSources,\n /** The canvas's outcome store, which its readout layer draws. */\n store: SnapOutcomeStore,\n): SnapOutcomeStore {\n const sessionRef = useLatest(session);\n const kitSettings = useKitSettings();\n useDepSource('snapReadout', (): SnapReadoutDep => ({ store }));\n\n useDepSource('snap', (): SnapDep => ({\n begin: (req) => {\n const s = sessionRef.current;\n const view = viewRef.current;\n const omit = new Set(req.omit);\n const sources = [\n ...withDefaults([...s.sources, ...(s.registry?.list() ?? [])], s.omit).filter((src) => !omit.has(src.id)),\n ...(req.sources ?? []),\n ];\n assertSnapSourceIds(sources);\n const wantsGeometry = snapSourcesFor(sources, req.gesture).some((src) => src.roles.includes('geometry'));\n const debug = s.debug?.() ?? undefined;\n const reachPx = s.reachPx ?? kitSettings.get('targets.snapPx') ?? DEFAULT_SNAP_PX;\n return sceneSession2d({\n req,\n scene: s.scene,\n boxes: s.boxes(),\n sources,\n ...(wantsGeometry ? { geometryAt: (press: WorldPoint, ids: readonly string[]) => ownGeometryAt(s.scene, press, ids, view?.scale ?? { x: 1, y: 1 }, reachPx) } : {}),\n view: () => viewRef.current,\n reachPx,\n ...(s.poseDescriptor ? { poseDescriptor: s.poseDescriptor } : {}),\n ...(s.originProjection ? { originProjection: s.originProjection } : {}),\n ...(s.anchors ? { anchors: s.anchors } : {}),\n ...(debug ? { debug } : {}),\n store,\n });\n },\n }));\n return store;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqDA,IAAM,uBAA8C,CAClD,mBAAmB,GACnB;CAAE,GAAG,eAAe,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;CAAG,UAAU,CAAC,OAAO;AAAE,CACjE;;;AAIA,SAAS,aAAa,QAA+B,OAA0B,CAAC,GAAiB;CAC/F,oBAAoB,MAAM;CAC1B,MAAM,wBAAQ,IAAI,IAAI,CAAC,GAAG,OAAO,KAAK,MAAM,EAAE,EAAE,GAAG,GAAG,IAAI,CAAC;CAC3D,OAAO,CAAC,GAAG,QAAQ,GAAG,qBAAqB,QAAQ,MAAM,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC,CAAC;AAC5E;AAEA,SAAgB,iBACd,SACA,SAEA,OACkB;CAClB,MAAM,aAAa,UAAU,OAAO;CACpC,MAAM,cAAc,eAAe;CACnC,aAAa,sBAAsC,EAAE,MAAM,EAAE;CAE7D,aAAa,eAAwB,EACnC,QAAQ,QAAQ;EACd,MAAM,IAAI,WAAW;EACrB,MAAM,OAAO,QAAQ;EACrB,MAAM,OAAO,IAAI,IAAI,IAAI,IAAI;EAC7B,MAAM,UAAU,CACd,GAAG,aAAa,CAAC,GAAG,EAAE,SAAS,GAAI,EAAE,UAAU,KAAK,KAAK,CAAC,CAAE,GAAG,EAAE,IAAI,CAAC,CAAC,QAAQ,QAAQ,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC,GACxG,GAAI,IAAI,WAAW,CAAC,CACtB;EACA,oBAAoB,OAAO;EAC3B,MAAM,gBAAgB,eAAe,SAAS,IAAI,OAAO,CAAC,CAAC,MAAM,QAAQ,IAAI,MAAM,SAAS,UAAU,CAAC;EACvG,MAAM,QAAQ,EAAE,QAAQ,KAAK;EAC7B,MAAM,UAAU,EAAE,WAAW,YAAY,IAAI,gBAAgB,KAAK;EAClE,OAAO,eAAe;GACpB;GACA,OAAO,EAAE;GACT,OAAO,EAAE,MAAM;GACf;GACA,GAAI,gBAAgB,EAAE,aAAa,OAAmB,QAA2B,cAAc,EAAE,OAAO,OAAO,KAAK,MAAM,SAAS;IAAE,GAAG;IAAG,GAAG;GAAE,GAAG,OAAO,EAAE,IAAI,CAAC;GACjK,YAAY,QAAQ;GACpB;GACA,GAAI,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,IAAI,CAAC;GAC/D,GAAI,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,IAAI,CAAC;GACrE,GAAI,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,IAAI,CAAC;GAC1C,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;GACzB;EACF,CAAC;CACH,EACF,EAAE;CACF,OAAO;AACT"}
@@ -1,26 +1,25 @@
1
1
  //#region src/canvas/pickReach.ts
2
2
  /**
3
3
  * Whether `q` lands on `node` anywhere it is painted: as authored, or in any
4
- * copy an ancestor draws of it. `parents` is innermost first.
4
+ * copy an ancestor draws of it. `parentsOf` answers innermost first.
5
5
  *
6
6
  * A copy is the clipped content transformed, so the query is carried into the
7
7
  * copy's source frame before the copying container's own clip is asked, and
8
8
  * every clip below it is asked in that frame too.
9
9
  *
10
- * `parents` is called only when the answer needs it — always when
10
+ * `parentsOf` is called only when the answer needs it — always when
11
11
  * `copying` says some container in the walk draws copies, otherwise only
12
12
  * after the node hits as authored.
13
13
  */
14
14
  function reaches(node, pose, derived, inherited, q, parentsOf, copying, look) {
15
- const admits = (query, ancestor) => {
16
- const clip = look.clipOf(ancestor);
17
- return clip === null || query.clipAdmits(look.carry(clip, ancestor.layer, node.layer), node, pose, derived);
18
- };
19
- const parents = copying && q.inCopy !== void 0 ? parentsOf() : null;
15
+ const parents = copying && q.inCopy !== void 0 ? parentsOf(node) : null;
20
16
  if (parents === null || !parents.some((a) => look.copiesOf(a).length > 0)) {
21
17
  if (!q.hits(node, pose, derived, inherited)) return false;
22
- return (parents ?? parentsOf()).every((a) => admits(q, a));
18
+ const all = parents ?? parentsOf(node);
19
+ for (let i = 0; i < all.length; i++) if (!admitsIn(look, q, all[i], node, pose, derived)) return false;
20
+ return true;
23
21
  }
22
+ const admits = (query, ancestor) => admitsIn(look, query, ancestor, node, pose, derived);
24
23
  const outermostFirst = [...parents].reverse();
25
24
  const from = (i, query) => {
26
25
  if (i === outermostFirst.length) return query.hits(node, pose, derived, inherited);
@@ -34,6 +33,11 @@ function reaches(node, pose, derived, inherited, q, parentsOf, copying, look) {
34
33
  };
35
34
  return from(0, q);
36
35
  }
36
+ /** Whether `ancestor`'s clip, carried into `node`'s plane, leaves `query` anything of it. */
37
+ function admitsIn(look, query, ancestor, node, pose, derived) {
38
+ const clip = look.clipOf(ancestor);
39
+ return clip === null || query.clipAdmits(look.carry(clip, ancestor.layer, node.layer), node, pose, derived);
40
+ }
37
41
 
38
42
  //#endregion
39
43
  export { reaches };
@@ -1 +1 @@
1
- {"version":3,"file":"pickReach.js","names":[],"sources":["../../src/canvas/pickReach.ts"],"sourcesContent":["import type { Affine, Path } from '@weasel-js/geom';\nimport type { PickCandidate, PickQuery } from './pickWalk';\nimport type { InheritedPaint } from 'core/scene/inheritedPaint';\n\n/** What {@link reaches} needs from the walk, each memoized per walk there. */\nexport interface ReachLookups<TPose> {\n /** An ancestor's own clip, or null. */\n clipOf(ancestor: PickCandidate<TPose>): Path | null;\n /** The maps from world into the source frame of each copy `ancestor` draws:\n * the inverses of its `copiesFromPose`. Empty when it draws none. */\n copiesOf(ancestor: PickCandidate<TPose>): readonly Affine[];\n /** A clip carried from its container's plane into the node's. */\n carry(clip: Path, fromLayer: string | undefined, toLayer: string | undefined): Path;\n}\n\n/**\n * Whether `q` lands on `node` anywhere it is painted: as authored, or in any\n * copy an ancestor draws of it. `parents` is innermost first.\n *\n * A copy is the clipped content transformed, so the query is carried into the\n * copy's source frame before the copying container's own clip is asked, and\n * every clip below it is asked in that frame too.\n *\n * `parents` is called only when the answer needs it — always when\n * `copying` says some container in the walk draws copies, otherwise only\n * after the node hits as authored.\n */\nexport function reaches<TPose>(\n node: PickCandidate<TPose>,\n pose: TPose,\n derived: Path | null | undefined,\n inherited: InheritedPaint | undefined,\n q: PickQuery<TPose>,\n parentsOf: () => readonly PickCandidate<TPose>[],\n copying: boolean,\n look: ReachLookups<TPose>,\n): boolean {\n const admits = (query: PickQuery<TPose>, ancestor: PickCandidate<TPose>): boolean => {\n const clip = look.clipOf(ancestor);\n return clip === null\n || query.clipAdmits(look.carry(clip, ancestor.layer, node.layer), node, pose, derived);\n };\n\n const parents = copying && q.inCopy !== undefined ? parentsOf() : null;\n if (parents === null || !parents.some((a) => look.copiesOf(a).length > 0)) {\n if (!q.hits(node, pose, derived, inherited)) return false;\n return (parents ?? parentsOf()).every((a) => admits(q, a));\n }\n\n const outermostFirst = [...parents].reverse();\n const from = (i: number, query: PickQuery<TPose>): boolean => {\n if (i === outermostFirst.length) return query.hits(node, pose, derived, inherited);\n const ancestor = outermostFirst[i];\n if (admits(query, ancestor) && from(i + 1, query)) return true;\n for (const m of look.copiesOf(ancestor)) {\n const inCopy = query.inCopy?.(m);\n if (inCopy !== undefined && admits(inCopy, ancestor) && from(i + 1, inCopy)) return true;\n }\n return false;\n };\n return from(0, q);\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,QACd,MACA,MACA,SACA,WACA,GACA,WACA,SACA,MACS;CACT,MAAM,UAAU,OAAyB,aAA4C;EACnF,MAAM,OAAO,KAAK,OAAO,QAAQ;EACjC,OAAO,SAAS,QACX,MAAM,WAAW,KAAK,MAAM,MAAM,SAAS,OAAO,KAAK,KAAK,GAAG,MAAM,MAAM,OAAO;CACzF;CAEA,MAAM,UAAU,WAAW,EAAE,WAAW,SAAY,UAAU,IAAI;CAClE,IAAI,YAAY,QAAQ,CAAC,QAAQ,MAAM,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG;EACzE,IAAI,CAAC,EAAE,KAAK,MAAM,MAAM,SAAS,SAAS,GAAG,OAAO;EACpD,QAAQ,WAAW,UAAU,EAAA,CAAG,OAAO,MAAM,OAAO,GAAG,CAAC,CAAC;CAC3D;CAEA,MAAM,iBAAiB,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ;CAC5C,MAAM,QAAQ,GAAW,UAAqC;EAC5D,IAAI,MAAM,eAAe,QAAQ,OAAO,MAAM,KAAK,MAAM,MAAM,SAAS,SAAS;EACjF,MAAM,WAAW,eAAe;EAChC,IAAI,OAAO,OAAO,QAAQ,KAAK,KAAK,IAAI,GAAG,KAAK,GAAG,OAAO;EAC1D,KAAK,MAAM,KAAK,KAAK,SAAS,QAAQ,GAAG;GACvC,MAAM,SAAS,MAAM,SAAS,CAAC;GAC/B,IAAI,WAAW,UAAa,OAAO,QAAQ,QAAQ,KAAK,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO;EACtF;EACA,OAAO;CACT;CACA,OAAO,KAAK,GAAG,CAAC;AAClB"}
1
+ {"version":3,"file":"pickReach.js","names":[],"sources":["../../src/canvas/pickReach.ts"],"sourcesContent":["import type { Affine, Path } from '@weasel-js/geom';\nimport type { PickCandidate, PickQuery } from './pickWalk';\nimport type { InheritedPaint } from 'core/scene/inheritedPaint';\n\n/** What {@link reaches} needs from the walk, each memoized per walk there. */\nexport interface ReachLookups<TPose> {\n /** An ancestor's own clip, or null. */\n clipOf(ancestor: PickCandidate<TPose>): Path | null;\n /** The maps from world into the source frame of each copy `ancestor` draws:\n * the inverses of its `copiesFromPose`. Empty when it draws none. */\n copiesOf(ancestor: PickCandidate<TPose>): readonly Affine[];\n /** A clip carried from its container's plane into the node's. */\n carry(clip: Path, fromLayer: string | undefined, toLayer: string | undefined): Path;\n}\n\n/**\n * Whether `q` lands on `node` anywhere it is painted: as authored, or in any\n * copy an ancestor draws of it. `parentsOf` answers innermost first.\n *\n * A copy is the clipped content transformed, so the query is carried into the\n * copy's source frame before the copying container's own clip is asked, and\n * every clip below it is asked in that frame too.\n *\n * `parentsOf` is called only when the answer needs it — always when\n * `copying` says some container in the walk draws copies, otherwise only\n * after the node hits as authored.\n */\nexport function reaches<TPose>(\n node: PickCandidate<TPose>,\n pose: TPose,\n derived: Path | null | undefined,\n inherited: InheritedPaint | undefined,\n q: PickQuery<TPose>,\n parentsOf: (node: PickCandidate<TPose>) => readonly PickCandidate<TPose>[],\n copying: boolean,\n look: ReachLookups<TPose>,\n): boolean {\n const parents = copying && q.inCopy !== undefined ? parentsOf(node) : null;\n if (parents === null || !parents.some((a) => look.copiesOf(a).length > 0)) {\n if (!q.hits(node, pose, derived, inherited)) return false;\n const all = parents ?? parentsOf(node);\n for (let i = 0; i < all.length; i++) if (!admitsIn(look, q, all[i]!, node, pose, derived)) return false;\n return true;\n }\n\n const admits = (query: PickQuery<TPose>, ancestor: PickCandidate<TPose>): boolean =>\n admitsIn(look, query, ancestor, node, pose, derived);\n const outermostFirst = [...parents].reverse();\n const from = (i: number, query: PickQuery<TPose>): boolean => {\n if (i === outermostFirst.length) return query.hits(node, pose, derived, inherited);\n const ancestor = outermostFirst[i];\n if (admits(query, ancestor) && from(i + 1, query)) return true;\n for (const m of look.copiesOf(ancestor)) {\n const inCopy = query.inCopy?.(m);\n if (inCopy !== undefined && admits(inCopy, ancestor) && from(i + 1, inCopy)) return true;\n }\n return false;\n };\n return from(0, q);\n}\n\n/** Whether `ancestor`'s clip, carried into `node`'s plane, leaves `query` anything of it. */\nfunction admitsIn<TPose>(\n look: ReachLookups<TPose>,\n query: PickQuery<TPose>,\n ancestor: PickCandidate<TPose>,\n node: PickCandidate<TPose>,\n pose: TPose,\n derived: Path | null | undefined,\n): boolean {\n const clip = look.clipOf(ancestor);\n return clip === null\n || query.clipAdmits(look.carry(clip, ancestor.layer, node.layer), node, pose, derived);\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,QACd,MACA,MACA,SACA,WACA,GACA,WACA,SACA,MACS;CACT,MAAM,UAAU,WAAW,EAAE,WAAW,SAAY,UAAU,IAAI,IAAI;CACtE,IAAI,YAAY,QAAQ,CAAC,QAAQ,MAAM,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG;EACzE,IAAI,CAAC,EAAE,KAAK,MAAM,MAAM,SAAS,SAAS,GAAG,OAAO;EACpD,MAAM,MAAM,WAAW,UAAU,IAAI;EACrC,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,QAAQ,KAAK,IAAI,CAAC,SAAS,MAAM,GAAG,IAAI,IAAK,MAAM,MAAM,OAAO,GAAG,OAAO;EAClG,OAAO;CACT;CAEA,MAAM,UAAU,OAAyB,aACvC,SAAS,MAAM,OAAO,UAAU,MAAM,MAAM,OAAO;CACrD,MAAM,iBAAiB,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ;CAC5C,MAAM,QAAQ,GAAW,UAAqC;EAC5D,IAAI,MAAM,eAAe,QAAQ,OAAO,MAAM,KAAK,MAAM,MAAM,SAAS,SAAS;EACjF,MAAM,WAAW,eAAe;EAChC,IAAI,OAAO,OAAO,QAAQ,KAAK,KAAK,IAAI,GAAG,KAAK,GAAG,OAAO;EAC1D,KAAK,MAAM,KAAK,KAAK,SAAS,QAAQ,GAAG;GACvC,MAAM,SAAS,MAAM,SAAS,CAAC;GAC/B,IAAI,WAAW,UAAa,OAAO,QAAQ,QAAQ,KAAK,KAAK,IAAI,GAAG,MAAM,GAAG,OAAO;EACtF;EACA,OAAO;CACT;CACA,OAAO,KAAK,GAAG,CAAC;AAClB;;AAGA,SAAS,SACP,MACA,OACA,UACA,MACA,MACA,SACS;CACT,MAAM,OAAO,KAAK,OAAO,QAAQ;CACjC,OAAO,SAAS,QACX,MAAM,WAAW,KAAK,MAAM,MAAM,SAAS,OAAO,KAAK,KAAK,GAAG,MAAM,MAAM,OAAO;AACzF"}
@@ -62,6 +62,12 @@ function pickWalk(src, q) {
62
62
  }
63
63
  return found;
64
64
  };
65
+ const lookups = {
66
+ clipOf,
67
+ copiesOf,
68
+ carry
69
+ };
70
+ const parentsOf = (node) => src.parentsOf(node);
65
71
  const order = src.order();
66
72
  const copying = order.some((n) => typeof n.copiesFromPose === "function");
67
73
  const visit = (q.broad !== void 0 ? src.candidates?.((layer) => {
@@ -80,11 +86,7 @@ function pickWalk(src, q) {
80
86
  const pose = src.poseOf(node);
81
87
  const derived = src.derivedPathOf?.(node);
82
88
  const inherited = inheritsPaint(node) ? inheritedPaintOf(node, src.parentsOf(node)) : void 0;
83
- if (!reaches(node, pose, derived, inherited, query, () => src.parentsOf(node), copying, {
84
- clipOf,
85
- copiesOf,
86
- carry
87
- })) continue;
89
+ if (!reaches(node, pose, derived, inherited, query, parentsOf, copying, lookups)) continue;
88
90
  out.push(node.id);
89
91
  }
90
92
  return out;
@@ -1 +1 @@
1
- {"version":3,"file":"pickWalk.js","names":[],"sources":["../../src/canvas/pickWalk.ts"],"sourcesContent":["/**\n * The one hit-test walk. Everything that decides whether a node *can* be hit lives here; a\n * query supplies only the shape test and the clip predicate for its own region.\n *\n * The gates, in the order the walk applies them:\n * 1. groups, when the query does not want them\n * 2. the node is painted at all — not hidden in the scene (`nodeGates`),\n * and on a layer the asking view's `layerVisibility` / `layerOrder` paints\n * 3. painted alpha is above zero\n * 4. the node is not locked, unless the query asks for locked nodes\n * 5. the query's own shape test\n * 6. every ancestor clip admits the query region\n *\n * 2, 3 and 6 are all \"the renderer did not put this on screen\". A pick path\n * that skips one answers for a node the user cannot see. 4 is the other axis:\n * a locked node is on screen and still out of reach.\n */\n\nimport { invert, type Affine, type Path } from '@weasel-js/geom';\nimport type { CopiesFromPoseFn } from 'core/scene/types';\nimport { ownClipOf, type ClipBearing } from './ownClip';\nimport { inheritedPaintOf, inheritsPaint, type InheritedPaint } from 'core/scene/inheritedPaint';\nimport { rectToPlane, type PlaneMap } from 'core/viewport/parallax';\nimport { clipCarrier } from './planeClips';\nimport { reaches } from './pickReach';\n\n/** The subset of a node the walk itself reads. Deliberately structural: a\n * bare adapter's node satisfies it as readily as a `SceneNode`. */\nexport interface PickCandidate<TPose> extends ClipBearing<TPose> {\n id: string;\n kind?: string;\n layer?: string;\n pose: TPose;\n /** `false` makes the node transparent to the walk — see `SceneNode.pickable`. */\n pickable?: boolean;\n /** Read for an `'inherit'` fill or stroke, which takes its containers'. */\n data?: unknown;\n copiesFromPose?: CopiesFromPoseFn<TPose>;\n}\n\n/**\n * Everything the walk reads that a **view** owns.\n *\n * A layer must not hold state a view owns, so none of these are closed over\n * at construction — each is asked per walk, of the view being dispatched to.\n */\nexport interface PickSource<TPose> {\n /** Candidates in paint order, back-to-front. Containers included; the\n * query decides whether they can be hit. */\n order(): readonly PickCandidate<TPose>[];\n /** The pose the renderer draws — override-aware. Not `node.pose`, which is\n * how the render and pick paths came to disagree about where a node is. */\n poseOf(node: PickCandidate<TPose>): TPose;\n /** Ancestors, innermost first. Only walked for candidates that already\n * passed their own shape test. */\n parentsOf(node: PickCandidate<TPose>): readonly PickCandidate<TPose>[];\n /** Painted alpha for the asking view: the view's `alphaFor` times any\n * per-node override alpha. Omit when the source has no alpha concept. */\n alphaOf?(id: string): number;\n /** Whether this layer reaches the screen in the asking view. Omit for a\n * source with no layers. */\n layerIsPainted?(layer: string): boolean;\n /** Whether the node is locked — painted, but not something a pointer can\n * take. Omit for a source with no lock concept. */\n isLocked?(node: PickCandidate<TPose>): boolean;\n /** Whether the source hides the node, so nothing of it is on screen. Omit\n * for a source that hides nothing. */\n isHidden?(node: PickCandidate<TPose>): boolean;\n /** The path a node computes from its dependencies, or null for none. */\n derivedPathOf?(node: PickCandidate<TPose>): Path | null;\n /** How the asking view's world maps into a parallax layer's, or null for a\n * layer that moves with the camera. Omit for a source with no planes. */\n planeOf?(layer: string): PlaneMap | null;\n /**\n * The candidates a query with these broad boxes can hit, back-to-front: a\n * subset of `order()` that drops only nodes no query inside the box could\n * hit. `broadFor(layer)` is the box for that layer's query: `null` for a\n * layer it cannot reach, `undefined` for one with no box, which makes this\n * answer `null` and the walk visit `order()`. Omit for a source with no index.\n */\n candidates?(\n broadFor: (layer: string | undefined) => PickBroad | null | undefined,\n ): readonly PickCandidate<TPose>[] | null;\n}\n\n/** The box a query cannot hit outside of, for a source's index to look up. */\nexport interface PickBroad {\n /** World box, already grown by the query's own slop. */\n box: { x: number; y: number; width: number; height: number };\n /** Screen px per world unit at the asking view (least axis); grows the box\n * by the largest `outsetPx` the index holds. Omit for a query whose test\n * reads no `outsetPx`. */\n pxPerWorld?: number;\n}\n\n/** `broad` carried into a plane's world, as `inPlane` carries the query. */\nexport function broadInPlane(broad: PickBroad, m: PlaneMap): PickBroad {\n const box = rectToPlane(m, broad.box);\n if (broad.pxPerWorld === undefined) return { box };\n // A plane's pixel is the same on screen, so its world unit holds fewer of them.\n const k = Math.max(Math.abs(m.scale.x), Math.abs(m.scale.y));\n return { box, pxPerWorld: broad.pxPerWorld / k };\n}\n\n/** One hit-test question: what region, and what counts as covering it. */\nexport interface PickQuery<TPose> {\n /** Default `true`. The area walks exclude groups so a marquee does not\n * return a group and its members both. */\n includeGroups?: boolean;\n /** Default `false`. Every selecting or editing query passes over locked\n * nodes; one that only samples what is painted can take them back. */\n includeLocked?: boolean;\n /** Where the query can hit at all, for a source with an index. `inPlane`\n * carries it with the query; without it the walk visits every node. */\n broad?: PickBroad;\n /** Does this node, drawn at this pose, cover the query region? `derived`\n * is the node's resolved path when it has one — a derived node's pose is a\n * placeholder, so a region test that reads only the pose answers for the\n * wrong box. `inherited` is what its `'inherit'` fields take from its\n * containers, for the ink it is tested against; absent when it inherits\n * nothing. */\n hits(node: PickCandidate<TPose>, pose: TPose, derived?: Path | null, inherited?: InheritedPaint): boolean;\n /**\n * Does an ancestor's clip leave anything of `node` for this query to hit?\n *\n * A point query asks point-in-clip and ignores the node. An area query has\n * to ask about the node as well: the clip and the area can overlap where\n * the node is not, and the node and the clip can overlap where the area is\n * not, and only the two terms together reject both.\n */\n clipAdmits(\n clip: Path,\n node: PickCandidate<TPose>,\n pose: TPose,\n derived?: Path | null,\n ): boolean;\n /** The same question asked in a parallax plane's world: the region carried\n * through `map`, and any screen-pixel slop re-derived at the plane's scale.\n * A query without it cannot reach nodes on a plane — it would test them\n * where their poses sit rather than where they are painted. */\n inPlane?(map: PlaneMap): PickQuery<TPose>;\n /** The same question carried by `m`, an affine from world into the source\n * frame of a copy a container draws. A query without it cannot reach\n * copies — see `GroupNode.copiesFromPose`. */\n inCopy?(m: Affine): PickQuery<TPose>;\n}\n\n/**\n * Collect every candidate the query hits, back-to-front — the last element is\n * the topmost, which is the order `pickTopMostHit` expects.\n */\nexport function pickWalk<TPose>(\n src: PickSource<TPose>,\n q: PickQuery<TPose>,\n): string[] {\n const includeGroups = q.includeGroups ?? true;\n const isLocked = q.includeLocked === true ? undefined : src.isLocked;\n const out: string[] = [];\n\n // Resolving a container's clip is the expensive half, so the *path* is memoized per\n // container for the walk. The predicate re-runs per candidate: caching its answer per\n // container would answer the wrong question for an area query.\n const clipPath = new Map<string, Path | null>();\n // A clip is in its container's plane; the query is in the candidate's.\n const carry = clipCarrier(src.planeOf ?? null);\n\n const clipOf = (ancestor: PickCandidate<TPose>): Path | null => {\n const cached = clipPath.get(ancestor.id);\n if (cached !== undefined) return cached;\n const resolved = ownClipOf(\n ancestor, src.poseOf(ancestor), () => src.derivedPathOf?.(ancestor),\n );\n clipPath.set(ancestor.id, resolved);\n return resolved;\n };\n\n const copyMaps = new Map<string, readonly Affine[]>();\n const copiesOf = (ancestor: PickCandidate<TPose>): readonly Affine[] => {\n let found = copyMaps.get(ancestor.id);\n if (found === undefined) {\n const fn = ancestor.copiesFromPose;\n const copies = fn ? fn(src.poseOf(ancestor), ancestor as never) ?? [] : [];\n found = copies.map(invert).filter((m): m is Affine => m !== null);\n copyMaps.set(ancestor.id, found);\n }\n return found;\n };\n\n // One reprojected query per plane per walk; `null` marks a plane this\n // query cannot reach.\n const planeQueries = new Map<string, PickQuery<TPose> | null>();\n const queryFor = (layer: string | undefined): PickQuery<TPose> | null => {\n if (layer === undefined || src.planeOf === undefined) return q;\n let found = planeQueries.get(layer);\n if (found === undefined) {\n const map = src.planeOf(layer);\n found = map === null ? q : (q.inPlane?.(map) ?? null);\n planeQueries.set(layer, found);\n }\n return found;\n };\n\n const order = src.order();\n const copying = order.some((n) => typeof n.copiesFromPose === 'function');\n const visit = (q.broad !== undefined ? src.candidates?.((layer) => {\n const query = queryFor(layer);\n return query === null ? null : query.broad;\n }) : null) ?? order;\n for (const node of visit) {\n if (!includeGroups && node.kind === 'group') continue;\n // Transparent to picking: the click belongs to whatever is behind it,\n // which for a label inside a box is the box.\n if (node.pickable === false) continue;\n if (src.isHidden?.(node) === true) continue;\n if (node.layer !== undefined && src.layerIsPainted?.(node.layer) === false) continue;\n if (src.alphaOf !== undefined && src.alphaOf(node.id) <= 0) continue;\n if (isLocked !== undefined && isLocked(node)) continue;\n\n const query = queryFor(node.layer);\n if (query === null) continue;\n const pose = src.poseOf(node);\n const derived = src.derivedPathOf?.(node);\n const inherited = inheritsPaint(node) ? inheritedPaintOf(node, src.parentsOf(node)) : undefined;\n if (!reaches(node, pose, derived, inherited, query, () => src.parentsOf(node), copying, { clipOf, copiesOf, carry })) continue;\n out.push(node.id);\n }\n\n return out;\n}\n\n/**\n * The two answers a pick needs from the view it is asked for rather than from\n * the data behind it: how that view paints a node, and whether it paints a\n * layer at all. A scene and a bare adapter take the same pair.\n */\nexport interface ViewPickGates {\n /** Painted alpha: the view's `alphaFor` times any per-node override alpha.\n * A node painted at alpha 0 cannot be hit. */\n alphaOf?: (id: string) => number;\n /** Whether a node's `layer` reaches the screen in the asking view. */\n layerIsPainted?: (layer: string) => boolean;\n}\n\n/** The gates a bare adapter takes from its view, plus how that view's camera\n * maps into each parallax layer — see `scenePlaneOf`. */\nexport interface AdapterPickGates extends ViewPickGates {\n planeOf?: (layer: string) => PlaneMap | null;\n}\n\nexport { scenePickSource, scenePlaneOf, type ScenePickSourceOptions } from './scenePickSource';\nexport { adapterPickSource } from './adapterPickSource';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuJA,SAAgB,SACd,KACA,GACU;CACV,MAAM,gBAAgB,EAAE,iBAAiB;CACzC,MAAM,WAAW,EAAE,kBAAkB,OAAO,SAAY,IAAI;CAC5D,MAAM,MAAgB,CAAC;CAKvB,MAAM,2BAAW,IAAI,IAAyB;CAE9C,MAAM,QAAQ,YAAY,IAAI,WAAW,IAAI;CAE7C,MAAM,UAAU,aAAgD;EAC9D,MAAM,SAAS,SAAS,IAAI,SAAS,EAAE;EACvC,IAAI,WAAW,QAAW,OAAO;EACjC,MAAM,WAAW,UACf,UAAU,IAAI,OAAO,QAAQ,SAAS,IAAI,gBAAgB,QAAQ,CACpE;EACA,SAAS,IAAI,SAAS,IAAI,QAAQ;EAClC,OAAO;CACT;CAEA,MAAM,2BAAW,IAAI,IAA+B;CACpD,MAAM,YAAY,aAAsD;EACtE,IAAI,QAAQ,SAAS,IAAI,SAAS,EAAE;EACpC,IAAI,UAAU,QAAW;GACvB,MAAM,KAAK,SAAS;GAEpB,SADe,KAAK,GAAG,IAAI,OAAO,QAAQ,GAAG,QAAiB,KAAK,CAAC,IAAI,CAAC,EACjE,CAAO,IAAI,MAAM,CAAC,CAAC,QAAQ,MAAmB,MAAM,IAAI;GAChE,SAAS,IAAI,SAAS,IAAI,KAAK;EACjC;EACA,OAAO;CACT;CAIA,MAAM,+BAAe,IAAI,IAAqC;CAC9D,MAAM,YAAY,UAAuD;EACvE,IAAI,UAAU,UAAa,IAAI,YAAY,QAAW,OAAO;EAC7D,IAAI,QAAQ,aAAa,IAAI,KAAK;EAClC,IAAI,UAAU,QAAW;GACvB,MAAM,MAAM,IAAI,QAAQ,KAAK;GAC7B,QAAQ,QAAQ,OAAO,IAAK,EAAE,UAAU,GAAG,KAAK;GAChD,aAAa,IAAI,OAAO,KAAK;EAC/B;EACA,OAAO;CACT;CAEA,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,UAAU,MAAM,MAAM,MAAM,OAAO,EAAE,mBAAmB,UAAU;CACxE,MAAM,SAAS,EAAE,UAAU,SAAY,IAAI,cAAc,UAAU;EACjE,MAAM,QAAQ,SAAS,KAAK;EAC5B,OAAO,UAAU,OAAO,OAAO,MAAM;CACvC,CAAC,IAAI,SAAS;CACd,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,iBAAiB,KAAK,SAAS,SAAS;EAG7C,IAAI,KAAK,aAAa,OAAO;EAC7B,IAAI,IAAI,WAAW,IAAI,MAAM,MAAM;EACnC,IAAI,KAAK,UAAU,UAAa,IAAI,iBAAiB,KAAK,KAAK,MAAM,OAAO;EAC5E,IAAI,IAAI,YAAY,UAAa,IAAI,QAAQ,KAAK,EAAE,KAAK,GAAG;EAC5D,IAAI,aAAa,UAAa,SAAS,IAAI,GAAG;EAE9C,MAAM,QAAQ,SAAS,KAAK,KAAK;EACjC,IAAI,UAAU,MAAM;EACpB,MAAM,OAAO,IAAI,OAAO,IAAI;EAC5B,MAAM,UAAU,IAAI,gBAAgB,IAAI;EACxC,MAAM,YAAY,cAAc,IAAI,IAAI,iBAAiB,MAAM,IAAI,UAAU,IAAI,CAAC,IAAI;EACtF,IAAI,CAAC,QAAQ,MAAM,MAAM,SAAS,WAAW,aAAa,IAAI,UAAU,IAAI,GAAG,SAAS;GAAE;GAAQ;GAAU;EAAM,CAAC,GAAG;EACtH,IAAI,KAAK,KAAK,EAAE;CAClB;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"pickWalk.js","names":[],"sources":["../../src/canvas/pickWalk.ts"],"sourcesContent":["/**\n * The one hit-test walk. Everything that decides whether a node *can* be hit lives here; a\n * query supplies only the shape test and the clip predicate for its own region.\n *\n * The gates, in the order the walk applies them:\n * 1. groups, when the query does not want them\n * 2. the node is painted at all — not hidden in the scene (`nodeGates`),\n * and on a layer the asking view's `layerVisibility` / `layerOrder` paints\n * 3. painted alpha is above zero\n * 4. the node is not locked, unless the query asks for locked nodes\n * 5. the query's own shape test\n * 6. every ancestor clip admits the query region\n *\n * 2, 3 and 6 are all \"the renderer did not put this on screen\". A pick path\n * that skips one answers for a node the user cannot see. 4 is the other axis:\n * a locked node is on screen and still out of reach.\n */\n\nimport { invert, type Affine, type Path } from '@weasel-js/geom';\nimport type { CopiesFromPoseFn } from 'core/scene/types';\nimport { ownClipOf, type ClipBearing } from './ownClip';\nimport { inheritedPaintOf, inheritsPaint, type InheritedPaint } from 'core/scene/inheritedPaint';\nimport { rectToPlane, type PlaneMap } from 'core/viewport/parallax';\nimport { clipCarrier } from './planeClips';\nimport { reaches } from './pickReach';\n\n/** The subset of a node the walk itself reads. Deliberately structural: a\n * bare adapter's node satisfies it as readily as a `SceneNode`. */\nexport interface PickCandidate<TPose> extends ClipBearing<TPose> {\n id: string;\n kind?: string;\n layer?: string;\n pose: TPose;\n /** `false` makes the node transparent to the walk — see `SceneNode.pickable`. */\n pickable?: boolean;\n /** Read for an `'inherit'` fill or stroke, which takes its containers'. */\n data?: unknown;\n copiesFromPose?: CopiesFromPoseFn<TPose>;\n}\n\n/**\n * Everything the walk reads that a **view** owns.\n *\n * A layer must not hold state a view owns, so none of these are closed over\n * at construction — each is asked per walk, of the view being dispatched to.\n */\nexport interface PickSource<TPose> {\n /** Candidates in paint order, back-to-front. Containers included; the\n * query decides whether they can be hit. */\n order(): readonly PickCandidate<TPose>[];\n /** The pose the renderer draws — override-aware. Not `node.pose`, which is\n * how the render and pick paths came to disagree about where a node is. */\n poseOf(node: PickCandidate<TPose>): TPose;\n /** Ancestors, innermost first. Only walked for candidates that already\n * passed their own shape test. */\n parentsOf(node: PickCandidate<TPose>): readonly PickCandidate<TPose>[];\n /** Painted alpha for the asking view: the view's `alphaFor` times any\n * per-node override alpha. Omit when the source has no alpha concept. */\n alphaOf?(id: string): number;\n /** Whether this layer reaches the screen in the asking view. Omit for a\n * source with no layers. */\n layerIsPainted?(layer: string): boolean;\n /** Whether the node is locked — painted, but not something a pointer can\n * take. Omit for a source with no lock concept. */\n isLocked?(node: PickCandidate<TPose>): boolean;\n /** Whether the source hides the node, so nothing of it is on screen. Omit\n * for a source that hides nothing. */\n isHidden?(node: PickCandidate<TPose>): boolean;\n /** The path a node computes from its dependencies, or null for none. */\n derivedPathOf?(node: PickCandidate<TPose>): Path | null;\n /** How the asking view's world maps into a parallax layer's, or null for a\n * layer that moves with the camera. Omit for a source with no planes. */\n planeOf?(layer: string): PlaneMap | null;\n /**\n * The candidates a query with these broad boxes can hit, back-to-front: a\n * subset of `order()` that drops only nodes no query inside the box could\n * hit. `broadFor(layer)` is the box for that layer's query: `null` for a\n * layer it cannot reach, `undefined` for one with no box, which makes this\n * answer `null` and the walk visit `order()`. Omit for a source with no index.\n */\n candidates?(\n broadFor: (layer: string | undefined) => PickBroad | null | undefined,\n ): readonly PickCandidate<TPose>[] | null;\n}\n\n/** The box a query cannot hit outside of, for a source's index to look up. */\nexport interface PickBroad {\n /** World box, already grown by the query's own slop. */\n box: { x: number; y: number; width: number; height: number };\n /** Screen px per world unit at the asking view (least axis); grows the box\n * by the largest `outsetPx` the index holds. Omit for a query whose test\n * reads no `outsetPx`. */\n pxPerWorld?: number;\n}\n\n/** `broad` carried into a plane's world, as `inPlane` carries the query. */\nexport function broadInPlane(broad: PickBroad, m: PlaneMap): PickBroad {\n const box = rectToPlane(m, broad.box);\n if (broad.pxPerWorld === undefined) return { box };\n // A plane's pixel is the same on screen, so its world unit holds fewer of them.\n const k = Math.max(Math.abs(m.scale.x), Math.abs(m.scale.y));\n return { box, pxPerWorld: broad.pxPerWorld / k };\n}\n\n/** One hit-test question: what region, and what counts as covering it. */\nexport interface PickQuery<TPose> {\n /** Default `true`. The area walks exclude groups so a marquee does not\n * return a group and its members both. */\n includeGroups?: boolean;\n /** Default `false`. Every selecting or editing query passes over locked\n * nodes; one that only samples what is painted can take them back. */\n includeLocked?: boolean;\n /** Where the query can hit at all, for a source with an index. `inPlane`\n * carries it with the query; without it the walk visits every node. */\n broad?: PickBroad;\n /** Does this node, drawn at this pose, cover the query region? `derived`\n * is the node's resolved path when it has one — a derived node's pose is a\n * placeholder, so a region test that reads only the pose answers for the\n * wrong box. `inherited` is what its `'inherit'` fields take from its\n * containers, for the ink it is tested against; absent when it inherits\n * nothing. */\n hits(node: PickCandidate<TPose>, pose: TPose, derived?: Path | null, inherited?: InheritedPaint): boolean;\n /**\n * Does an ancestor's clip leave anything of `node` for this query to hit?\n *\n * A point query asks point-in-clip and ignores the node. An area query has\n * to ask about the node as well: the clip and the area can overlap where\n * the node is not, and the node and the clip can overlap where the area is\n * not, and only the two terms together reject both.\n */\n clipAdmits(\n clip: Path,\n node: PickCandidate<TPose>,\n pose: TPose,\n derived?: Path | null,\n ): boolean;\n /** The same question asked in a parallax plane's world: the region carried\n * through `map`, and any screen-pixel slop re-derived at the plane's scale.\n * A query without it cannot reach nodes on a plane — it would test them\n * where their poses sit rather than where they are painted. */\n inPlane?(map: PlaneMap): PickQuery<TPose>;\n /** The same question carried by `m`, an affine from world into the source\n * frame of a copy a container draws. A query without it cannot reach\n * copies — see `GroupNode.copiesFromPose`. */\n inCopy?(m: Affine): PickQuery<TPose>;\n}\n\n/**\n * Collect every candidate the query hits, back-to-front — the last element is\n * the topmost, which is the order `pickTopMostHit` expects.\n */\nexport function pickWalk<TPose>(\n src: PickSource<TPose>,\n q: PickQuery<TPose>,\n): string[] {\n const includeGroups = q.includeGroups ?? true;\n const isLocked = q.includeLocked === true ? undefined : src.isLocked;\n const out: string[] = [];\n\n // Resolving a container's clip is the expensive half, so the *path* is memoized per\n // container for the walk. The predicate re-runs per candidate: caching its answer per\n // container would answer the wrong question for an area query.\n const clipPath = new Map<string, Path | null>();\n // A clip is in its container's plane; the query is in the candidate's.\n const carry = clipCarrier(src.planeOf ?? null);\n\n const clipOf = (ancestor: PickCandidate<TPose>): Path | null => {\n const cached = clipPath.get(ancestor.id);\n if (cached !== undefined) return cached;\n const resolved = ownClipOf(\n ancestor, src.poseOf(ancestor), () => src.derivedPathOf?.(ancestor),\n );\n clipPath.set(ancestor.id, resolved);\n return resolved;\n };\n\n const copyMaps = new Map<string, readonly Affine[]>();\n const copiesOf = (ancestor: PickCandidate<TPose>): readonly Affine[] => {\n let found = copyMaps.get(ancestor.id);\n if (found === undefined) {\n const fn = ancestor.copiesFromPose;\n const copies = fn ? fn(src.poseOf(ancestor), ancestor as never) ?? [] : [];\n found = copies.map(invert).filter((m): m is Affine => m !== null);\n copyMaps.set(ancestor.id, found);\n }\n return found;\n };\n\n // One reprojected query per plane per walk; `null` marks a plane this\n // query cannot reach.\n const planeQueries = new Map<string, PickQuery<TPose> | null>();\n const queryFor = (layer: string | undefined): PickQuery<TPose> | null => {\n if (layer === undefined || src.planeOf === undefined) return q;\n let found = planeQueries.get(layer);\n if (found === undefined) {\n const map = src.planeOf(layer);\n found = map === null ? q : (q.inPlane?.(map) ?? null);\n planeQueries.set(layer, found);\n }\n return found;\n };\n\n const lookups = { clipOf, copiesOf, carry };\n const parentsOf = (node: PickCandidate<TPose>) => src.parentsOf(node);\n const order = src.order();\n const copying = order.some((n) => typeof n.copiesFromPose === 'function');\n const visit = (q.broad !== undefined ? src.candidates?.((layer) => {\n const query = queryFor(layer);\n return query === null ? null : query.broad;\n }) : null) ?? order;\n for (const node of visit) {\n if (!includeGroups && node.kind === 'group') continue;\n // Transparent to picking: the click belongs to whatever is behind it,\n // which for a label inside a box is the box.\n if (node.pickable === false) continue;\n if (src.isHidden?.(node) === true) continue;\n if (node.layer !== undefined && src.layerIsPainted?.(node.layer) === false) continue;\n if (src.alphaOf !== undefined && src.alphaOf(node.id) <= 0) continue;\n if (isLocked !== undefined && isLocked(node)) continue;\n\n const query = queryFor(node.layer);\n if (query === null) continue;\n const pose = src.poseOf(node);\n const derived = src.derivedPathOf?.(node);\n const inherited = inheritsPaint(node) ? inheritedPaintOf(node, src.parentsOf(node)) : undefined;\n if (!reaches(node, pose, derived, inherited, query, parentsOf, copying, lookups)) continue;\n out.push(node.id);\n }\n\n return out;\n}\n\n/**\n * The two answers a pick needs from the view it is asked for rather than from\n * the data behind it: how that view paints a node, and whether it paints a\n * layer at all. A scene and a bare adapter take the same pair.\n */\nexport interface ViewPickGates {\n /** Painted alpha: the view's `alphaFor` times any per-node override alpha.\n * A node painted at alpha 0 cannot be hit. */\n alphaOf?: (id: string) => number;\n /** Whether a node's `layer` reaches the screen in the asking view. */\n layerIsPainted?: (layer: string) => boolean;\n}\n\n/** The gates a bare adapter takes from its view, plus how that view's camera\n * maps into each parallax layer — see `scenePlaneOf`. */\nexport interface AdapterPickGates extends ViewPickGates {\n planeOf?: (layer: string) => PlaneMap | null;\n}\n\nexport { scenePickSource, scenePlaneOf, type ScenePickSourceOptions } from './scenePickSource';\nexport { adapterPickSource } from './adapterPickSource';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuJA,SAAgB,SACd,KACA,GACU;CACV,MAAM,gBAAgB,EAAE,iBAAiB;CACzC,MAAM,WAAW,EAAE,kBAAkB,OAAO,SAAY,IAAI;CAC5D,MAAM,MAAgB,CAAC;CAKvB,MAAM,2BAAW,IAAI,IAAyB;CAE9C,MAAM,QAAQ,YAAY,IAAI,WAAW,IAAI;CAE7C,MAAM,UAAU,aAAgD;EAC9D,MAAM,SAAS,SAAS,IAAI,SAAS,EAAE;EACvC,IAAI,WAAW,QAAW,OAAO;EACjC,MAAM,WAAW,UACf,UAAU,IAAI,OAAO,QAAQ,SAAS,IAAI,gBAAgB,QAAQ,CACpE;EACA,SAAS,IAAI,SAAS,IAAI,QAAQ;EAClC,OAAO;CACT;CAEA,MAAM,2BAAW,IAAI,IAA+B;CACpD,MAAM,YAAY,aAAsD;EACtE,IAAI,QAAQ,SAAS,IAAI,SAAS,EAAE;EACpC,IAAI,UAAU,Q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