@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,172 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 48b6c4c: <!-- bump-approved: minor: maintainer — 1.15.0 release requested 2026-10-31 -->
8
+
9
+ An action can declare its params as a form, `Action.params` (a `@weasel-js/prefs` group of labels, ranges, steps,
10
+ and defaults). An immediate run of such an action that commits one history entry becomes the actions tree's last
11
+ operation, read with `useLastOperation()` / `useLastOperationStore()` (or `lastOperationOf(registry)`). Its
12
+ `adjust(patch)` undoes that entry, puts back the selection the run started from, reruns the action with the patch
13
+ over the values it used, and keeps the new entry in place of the old one, so the history still holds one entry. Any
14
+ other history step, an undo or redo, or `dismiss()` clears it. The values last used become the action's params for
15
+ the rest of the session, under any tuning. Core publishes a `selectionSnapshot` dep that captures the node selection
16
+ and the anchor selection together, which the rerun restores.
17
+
18
+ `@weasel-js/ui` adds `<LastOperationPanel>`, which draws the last operation as a form titled with the command's label,
19
+ adjusting it on each change and dismissing it from its close button; it renders nothing while there is none.
20
+
21
+ `bridgePaths` and `bridgeAnchors` declare their Tension (`BRIDGE_PARAMS`), `resamplePath` its count, spacing, corners,
22
+ and tolerance (`RESAMPLE_PARAMS`), and `addExtremeAnchors` a new Turns param (`ADD_EXTREMES_PARAMS`). `resamplePath`
23
+ is now an immediate command committing one entry, where it was an ongoing action previewed through `begin`: code
24
+ driving it with `useOngoingAction` must trigger it instead. `addExtremeAnchors` takes `params.axes` — `'xy'` (the
25
+ default), `'x'`, or `'y'` — and geom's `segmentExtremaTs` and `addExtremaAnchors` take the same choice as a last
26
+ argument (`ExtremaAxes`).
27
+
28
+ ### Patch Changes
29
+
30
+ - 8461e7b: `NodeGates.hidden` and `NodeGates.locked` take the node itself as well as its id, and answer the same for
31
+ either; a walk that already holds the node saves looking it up. The pick walk now hands them its
32
+ candidates, decides a marquee from a node's bounds before building anything to test its outline, and no
33
+ longer allocates per candidate. Scene edits and history pushes allocate less per op. No result changes.
34
+ - 70a64a3: Tools can declare options: `ToolDef.options` names the action they are params of, a prefs group of number leaves
35
+ (their bounds and defaults), and which one is the tool's size and which its strength. `<SceneCanvas>` tunes the
36
+ action from the values the host keeps in the new `toolOptionValues` dep (`ToolOptionValues`, published with
37
+ `useToolOptionValues`; `createToolOptionValues` keeps them in memory). `defineTool` adds step actions for the size
38
+ and strength, bound to `[` `]` and `Shift+[` `Shift+]` while the tool is the active one, so they win over the same keys'
39
+ anchor-selection commands only then.
40
+
41
+ The Smudge brush (`SMUDGE_BRUSH_OPTIONS`: size, strength) and the Simplify brush (`SIMPLIFY_BRUSH_OPTIONS`: size,
42
+ tolerance) declare theirs. Size steps by ×1.25; the Smudge brush's strength by 0.1, the Simplify brush's tolerance by
43
+ ×1.25.
44
+ - f77e789: A canvas left to fill its parent now shows its new size, painted, in the frame its parent resized in, rather than
45
+ one frame late at the old size. `<Canvas>`, `<SceneCanvas>`, `<DrawCanvas>`, and `<SceneViewCanvas>` also paint a
46
+ commit that changes their size in place instead of on the next frame. `useElementSize` and `useCanvasSize` take
47
+ `{ beforePaint: true }` to render their caller with a new size inside the `ResizeObserver` callback; it suits only a
48
+ caller whose render lays out nothing outside the observed element, since the browser reports anything else that
49
+ resizes there as a loop error. Without it the size arrives in a task after the callback, as before. A canvas's
50
+ `onResize` now fires from a passive effect.
51
+ - 0e60598: Drawing a polygon or a star leaves the last-operation panel up with its sides, or its points and inner radius
52
+ (`insertParams`, `POLYGON_INSERT_PARAMS`, `STAR_INSERT_PARAMS`); a change redraws the shape in place from the same
53
+ drag, as one undo entry. A drag that insert behaviors answered gets no panel. The star's "Inner" property row is now
54
+ "Inner radius". The scene's history answers `activeJournal()`, and its journals `observe`, so the last operation
55
+ follows edits into an open journal, such as path edit's.
56
+ - a1cb281: Images drawn at half their size or smaller are now smoothed through mipmaps by default: `imageMinification` defaults
57
+ to `'auto'` on `WeaselRenderer` and `<Canvas>`, which builds an image's mipmaps the first time a frame draws the whole of
58
+ it that small. This changes the pixels of every image drawn small; pass `imageMinification: 'linear'` for the old
59
+ single-tap look. A draw with `source` and a `sprites` run never sample mipmaps, under any mode, so a sprite-sheet cell
60
+ drawn small no longer takes color from the cells beside it under `'mipmap'` or `'auto'`.
61
+ - c41c917: Path edit's tools are ordinary tools, and a mode can name the tool it starts on.
62
+
63
+ **Breaking:** the `pathEditTool.*` toggle actions (`pathEditToolAction`, `exitPathEditToolAction`,
64
+ `pathEditToolActive`, `simplifyBrushToolAction`, `lengthenToolAction`, `SIMPLIFY_BRUSH_TOOL`, `LENGTHEN_TOOL`) are
65
+ removed, as are the `editAnchors` dep's `tool` and `setTool`, `PathEditHost`'s `tool` and `setTool`, and
66
+ `AnchorState.tool`. The `simplifyBrush` and `lengthenPath` actions no longer bind a drag themselves: mount
67
+ `useSimplifyBrushTool` and `useLengthenTool` (or `usePathEditTools`, named by `PATH_EDIT_TOOLS`; `usePathToolsTools`
68
+ includes them), each carrying `edits-anchors`. Their bindings sit at the active tier, so they outrank anchor
69
+ editing's ambient drags; a Lengthen drag on an anchor that is no open end falls through to moving it.
70
+
71
+ `ModeDefinition.defaultTool` names the tool a mode starts on: entering the mode activates it, leaving restores the
72
+ tool active at entry, and Escape with another tool on returns to it before a second Escape leaves: a mode shortcut's
73
+ `exit` and `cancel` and core's `exitPathEdit` each call `returnToModeDefault` first, reading the new `modeDefaultTool`
74
+ dep `<SceneCanvas>` sources. `PATH_EDIT` names core's new `anchors` tool (key A, glyph `core:anchors`), which the
75
+ `pathEdit` preset mounts and `ANCHOR_TOOLS` names; it binds nothing and holds path edit's active slot. The pointer
76
+ cursor over an anchor or handle is now `editAnchors`' own `cursor`, so a path-edit tool's cursor shows there.
77
+
78
+ A `chromeRules` dep, which `<SceneCanvas>` sources, reads and sets chrome-visibility rules at run time. The toggles
79
+ `pathEdit.show.direction`, `.comb`, `.balance`, and `.corners` (group `pathOverlays`) use it to flip each overlay
80
+ between `always` and `never`, and come with the preset that draws it.
81
+
82
+ `ToolPalette` takes `ineligible: 'dim' | 'hide'`, default `dim`; `hide` leaves out every tool the current mode does
83
+ not allow. The Girth tool's palette group is now `path`, beside Trim, Extend, and the Smudge brush.
84
+
85
+ In the dev server and under vitest, `weaselIcons` in app mode stops looking for tables at the nearest workspace root
86
+ above the app, and reads that workspace's packages' source tables. It used to walk on into an enclosing checkout's
87
+ `node_modules` (a git worktree sits inside its main checkout), so a worktree served that checkout's glyphs: a glyph
88
+ added on the branch drew as "?", and one redrawn there drew as before.
89
+ - d25ad30: A runs array can now be refilled in place. `clearRuns(runs)` in `@weasel-js/text` forgets what the layout and
90
+ paint caches hold for it while leaving it filed, `resolveRunsInto(out, runs, style)` resolves into an array the
91
+ caller owns, rewriting each run object whose optional fields match, and `textCommandFromRunsInto(cmd, …)` in
92
+ `@weasel-js/renderer` refills a text command and its runs. Core re-exports all three.
93
+
94
+ A HUD text widget now keeps one command and one runs array for its life and refills them when its text, color
95
+ or family changes, so a readout rewritten every frame no longer allocates a command, its runs, or a cache
96
+ entry per label. What its `draw` returned shows the widget's current text rather than a snapshot of the
97
+ text it had then.
98
+ - 1de1aab: The Smudge brush now smudges text: a text node it may push (selected, or any unlocked, shown one while nothing is
99
+ selected) is converted to outlines, as Create Outlines does, the moment the brush touches it, and its paths are
100
+ smudged from then on. Conversion and smudge are one undo entry labeled "Smudge brush", and Escape mid-stroke puts the
101
+ text back. Text whose face has no outlines is left alone, and the user is told once per stroke. In a host with no
102
+ `createOutlinesAdapter` dep, text is skipped. A selected group is now smudged as its path leaves.
103
+
104
+ `applyCreateOutlines(adapter, ids?)` converts the given text nodes rather than only the selection.
105
+
106
+ A journal can now open inside another (`Journal.beginJournal`), and `scene.history.beginJournal` opens inside the
107
+ journal edits are going to when there is one, so a gesture journaled during a mode lands in the mode's journal as one
108
+ entry. A journal opened on `scene.history` now takes the scene's `applyBatch` edits without an active-journal accessor.
109
+
110
+ New `notices` dep (`NoticesDep`, published with `useNotices`): where an action tells the user something went wrong.
111
+ Create Outlines, Outline Stroke, Pathfinder, and the Smudge brush report text they cannot outline through it, and fall
112
+ back to the console without it.
113
+ - fce0494: A node can now declare points of its own that a move snaps, through `<SceneCanvas snap={{ anchors }}>`
114
+ or `createSnapSession2d({ anchors })`: a function from a node id to points in that node's box frame,
115
+ such as a cabinet's hanger holes. Each becomes a probe of the new role `'anchor'`, offered only to a
116
+ source whose `roles` list it, so a grid can land the holes on a pegboard's while alignment and spacing
117
+ keep measuring the box.
118
+ - 746fab0: The warp tools (Distort, Envelope, Puppet Warp) now work on a selected group: one set of controls is laid around all
119
+ of its paths, and they warp together. Selected text converts to outlines when a warp begins on it (a drag on the fresh
120
+ controls, or a pin placed), conversion and warp landing as one undo step; canceling the drag puts the text back, and
121
+ text whose face has no outlines is left alone with a notice. While a warp tool is active, the selection's resize and
122
+ rotation handles no longer draw over its controls or take its presses.
123
+
124
+ New `ToolDef.hides`: chrome ids hidden, in paint and hit-test alike, while that tool is the active one (carried to
125
+ rules as `RuleCtx.hiddenChrome`).
126
+ - Updated dependencies [2bdba7b]
127
+ - Updated dependencies [8461e7b]
128
+ - Updated dependencies [70a64a3]
129
+ - Updated dependencies [3f13a49]
130
+ - Updated dependencies [719d457]
131
+ - Updated dependencies [d40f593]
132
+ - Updated dependencies [81a1b94]
133
+ - Updated dependencies [b7d362d]
134
+ - Updated dependencies [a95d3a4]
135
+ - Updated dependencies [e05ddd3]
136
+ - Updated dependencies [30bf607]
137
+ - Updated dependencies [35f0277]
138
+ - Updated dependencies [48b6c4c]
139
+ - Updated dependencies [a1cb281]
140
+ - Updated dependencies [2e2f76c]
141
+ - Updated dependencies [c41c917]
142
+ - Updated dependencies [fbc7ebf]
143
+ - Updated dependencies [d25ad30]
144
+ - Updated dependencies [1de1aab]
145
+ - Updated dependencies [fce0494]
146
+ - Updated dependencies [51ca29e]
147
+ - Updated dependencies [746fab0]
148
+ - @weasel-js/renderer@1.15.0
149
+ - @weasel-js/history@1.15.0
150
+ - @weasel-js/routing@1.15.0
151
+ - @weasel-js/font@1.15.0
152
+ - @weasel-js/text@1.15.0
153
+ - @weasel-js/geom@1.15.0
154
+ - @weasel-js/modes@1.15.0
155
+ - @weasel-js/stroke@1.15.0
156
+ - @weasel-js/text-dom@1.15.0
157
+ - @weasel-js/animator@1.15.0
158
+ - @weasel-js/headless@1.15.0
159
+ - @weasel-js/gestures@1.15.0
160
+ - @weasel-js/cursor@1.15.0
161
+ - @weasel-js/icons@1.15.0
162
+ - @weasel-js/paint@1.15.0
163
+ - @weasel-js/prefs@1.15.0
164
+ - @weasel-js/quantity@1.15.0
165
+ - @weasel-js/react@1.15.0
166
+ - @weasel-js/registry@1.15.0
167
+ - @weasel-js/select@1.15.0
168
+ - @weasel-js/simulation@1.15.0
169
+
3
170
  ## 1.14.2
4
171
 
5
172
  ### Patch Changes
@@ -46,7 +46,6 @@ function createPathAnchorAffordances(getAnchorState, opts = {}) {
46
46
  hitRadiusPx: hitRadius
47
47
  },
48
48
  hitKind,
49
- ...getAnchorState()?.tool ? {} : { cursor },
50
49
  bind: () => ({ initialScratch: {
51
50
  ...scratch,
52
51
  targetId
@@ -1 +1 @@
1
- {"version":3,"file":"pathAnchors.js","names":[],"sources":["../../src/affordances/pathAnchors.ts"],"sourcesContent":["/** Path anchor, control-handle, and segment affordances, and the parts path-edit extensions add. */\n\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport type { Affordance, AffordanceBinding, AffordanceRegion, CommonAffordanceScratch } from './types';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport { pathToAnchors, type AnchorSet, type PolygonPath } from '@weasel-js/geom';\nimport { enumerateAnchors } from 'interactions/actions/edit-anchors/geometry';\nimport type { PathEditExtension } from 'domains/paths/pathEditExtension';\n\n/**\n * Live anchor-editing state. The thunk that returns it is called on every\n * pointer event, so it must be cheap (O(1) field reads).\n */\nexport interface AnchorState {\n /** Id of the path currently in anchor-edit mode, or `null`. Control handles\n * are only hittable on the path that is being edited. */\n editingId: string | null;\n /** Current editable path for a node id. Non-polygon values are ignored. */\n getPose(id: string): unknown;\n /** The committed pose and data of a node, which extensions' parts read. */\n getNode?(id: string): { pose: unknown; data: unknown } | null;\n /** The path-edit extensions whose parts are pressed, in order. */\n extensions?: readonly PathEditExtension[];\n /** The active path-edit tool, if any. While one is set, anchors and controls\n * carry no cursor of their own, so the tool's action shows its own. */\n tool?: string | null;\n /** The path whose outline counts as a segment press, when it is not\n * `getPose`'s: a path drawn from a form, edited through the form's edit\n * path. */\n getOutline?(id: string): unknown;\n}\n\n/** Options for the path-anchor affordances. */\nexport interface PathAnchorAffordanceOptions {\n /** Hit radius (screen-px) for anchor and control points. Default 8. */\n hitRadius?: number;\n /** Cursor while hovering an anchor or control, with no path-edit tool\n * active. Defaults to `'pointer'`. */\n cursor?: CursorSpec;\n}\n\n/** What an anchor hit hands to the action that follows. */\nexport interface AnchorScratch extends CommonAffordanceScratch {\n /** Node id of the path the anchor belongs to. */\n targetId: string;\n /** Sequential anchor index in path walk order. */\n anchorIndex: number;\n /** Which of the anchor's three grabbable points this is. */\n part: 'anchor' | 'controlIn' | 'controlOut';\n}\n\n/** Chrome-caps id gating the anchor, control, and segment affordances. */\nexport const PATH_ANCHOR_CHROME_ID = 'path-edit.anchors';\n\n/**\n * Segment, extension-part, anchor, and control affordances for the selected\n * paths, bottom → top.\n *\n * Three affordances rather than one, so that a control handle beats an anchor\n * regardless of which is nearer, the way controls draw on top, and both beat\n * the segment they sit on. Within each, nearest wins. A press on the edited\n * path's outline is a `segment` hit, which the segment bend binds to and a\n * selection move turns down. Anchors, controls, and segments share one id:\n * chrome-caps gates anchor editing as a single piece of chrome. A part a\n * path-edit extension adds (`PathEditExtension.parts`) may name a chrome id of\n * its own as well, so it can be shown apart from the anchors.\n *\n * Order matters — spread this into an affordance list in the returned order.\n */\nexport function createPathAnchorAffordances(\n getAnchorState: () => AnchorState | null,\n opts: PathAnchorAffordanceOptions = {},\n): Affordance[] {\n const { hitRadius = 8, cursor = 'pointer' } = opts;\n\n /** Selected polygon paths, and the one being edited, paired with their node id. */\n const editablePaths = (state: ChromeState): Array<{ id: string; path: PolygonPath }> => {\n const anchorState = getAnchorState();\n if (!anchorState) return [];\n const out: Array<{ id: string; path: PolygonPath }> = [];\n for (const id of withEdited(state.selection, anchorState.editingId)) {\n const pose = anchorState.getPose(id);\n if (!pose || (pose as { kind?: string }).kind !== 'polygon') continue;\n out.push({ id, path: pose as PolygonPath });\n }\n return out;\n };\n\n const point = (\n id: string,\n targetId: string,\n x: number,\n y: number,\n scratch: AnchorScratch,\n hitKind: string,\n ): AffordanceRegion => ({\n id,\n // Anchor coordinates are already world space, pose rotation baked in.\n // Anchoring to `null` keeps the framework from applying it twice.\n targetId: null,\n shape: { kind: 'point', x, y, hitRadiusPx: hitRadius },\n hitKind,\n ...(getAnchorState()?.tool ? {} : { cursor }),\n bind: (): AffordanceBinding => ({ initialScratch: { ...scratch, targetId } }),\n });\n\n const anchors: Affordance = {\n id: PATH_ANCHOR_CHROME_ID,\n regions(state) {\n const editingId = getAnchorState()?.editingId ?? null;\n const out: AffordanceRegion[] = [];\n for (const { id, path } of editablePaths(state)) {\n // `editAnchorsAction` edits whatever path the dep says is in edit\n // mode, ignoring which one was hit — so once a path IS being edited,\n // only its own anchors may claim the press.\n if (editingId !== null && id !== editingId) continue;\n for (const a of enumerateAnchors(path)) {\n out.push(point(\n `${id}:anchor:${a.anchorIndex}`,\n id, a.x, a.y,\n { targetId: id, anchorIndex: a.anchorIndex, part: 'anchor' },\n `anchor:${a.anchorIndex}`,\n ));\n }\n }\n return out;\n },\n };\n\n const controls: Affordance = {\n id: PATH_ANCHOR_CHROME_ID,\n regions(state) {\n const anchorState = getAnchorState();\n const editingId = anchorState?.editingId ?? null;\n if (editingId === null) return [];\n const out: AffordanceRegion[] = [];\n for (const { id, path } of editablePaths(state)) {\n // Controls are grabbable only on the path actually in edit mode.\n if (id !== editingId) continue;\n for (const a of enumerateAnchors(path)) {\n if (a.controlIn) {\n out.push(point(\n `${id}:controlIn:${a.anchorIndex}`,\n id, a.controlIn.x, a.controlIn.y,\n { targetId: id, anchorIndex: a.anchorIndex, part: 'controlIn' },\n `controlIn:${a.anchorIndex}`,\n ));\n }\n if (a.controlOut) {\n out.push(point(\n `${id}:controlOut:${a.anchorIndex}`,\n id, a.controlOut.x, a.controlOut.y,\n { targetId: id, anchorIndex: a.anchorIndex, part: 'controlOut' },\n `controlOut:${a.anchorIndex}`,\n ));\n }\n }\n }\n return out;\n },\n };\n\n const segments: Affordance = {\n id: PATH_ANCHOR_CHROME_ID,\n regions(state) {\n const editingId = getAnchorState()?.editingId ?? null;\n if (editingId === null) return [];\n const edited = editablePaths(state).find(({ id }) => id === editingId);\n if (!edited) return [];\n const outline = getAnchorState()?.getOutline?.(editingId) as PolygonPath | null | undefined;\n return [{\n id: `${editingId}:segment`,\n targetId: null,\n shape: { kind: 'outline', path: outline?.kind === 'polygon' ? outline : edited.path, hitRadiusPx: hitRadius },\n hitKind: 'segment',\n bind: (): AffordanceBinding => ({ initialScratch: { targetId: editingId } }),\n }];\n },\n };\n\n return [segments, extensionParts(getAnchorState, hitRadius, cursor), anchors, controls];\n}\n\n/** The parts path-edit extensions add to the path in edit mode, each pressed\n * as its own `hitKind`. */\nfunction extensionParts(\n getAnchorState: () => AnchorState | null,\n hitRadius: number,\n cursor: CursorSpec,\n): Affordance {\n return {\n id: PATH_ANCHOR_CHROME_ID,\n regions() {\n const anchorState = getAnchorState();\n const editingId = anchorState?.editingId ?? null;\n const extensions = anchorState?.extensions?.filter((e) => e.parts) ?? [];\n if (editingId === null || extensions.length === 0) return [];\n const pose = anchorState!.getPose(editingId);\n const node = anchorState!.getNode?.(editingId);\n if (!node || !pose || (pose as { kind?: string }).kind !== 'polygon') return [];\n const target = {\n id: editingId, node, path: pose as PolygonPath, anchors: pathToAnchors(pose as PolygonPath) as AnchorSet,\n };\n return extensions.flatMap((ext) => ext.parts!(target).map((part): AffordanceRegion => ({\n id: `${editingId}:${part.hitKind}`,\n targetId: null,\n shape: {\n kind: 'point', x: part.x, y: part.y, hitRadiusPx: part.hitRadiusPx ?? hitRadius,\n ...(part.standoff ? { standoff: part.standoff } : {}),\n },\n hitKind: part.hitKind,\n ...(part.chromeId ? { chromeId: part.chromeId } : {}),\n cursor,\n bind: (): AffordanceBinding => ({ initialScratch: { targetId: editingId } }),\n })));\n },\n };\n}\n\n/** `selection`, and the path being edited after it when the selection does not hold it: a path edited through the\n * effect that hides it is edited while the effect is what is selected. */\nfunction withEdited(selection: readonly string[], editingId: string | null): readonly string[] {\n return editingId === null || selection.includes(editingId) ? selection : [...selection, editingId];\n}\n"],"mappings":";;;;;AAoDA,IAAa,wBAAwB;;;;;;;;;;;;;;;;AAiBrC,SAAgB,4BACd,gBACA,OAAoC,CAAC,GACvB;CACd,MAAM,EAAE,YAAY,GAAG,SAAS,cAAc;;CAG9C,MAAM,iBAAiB,UAAiE;EACtF,MAAM,cAAc,eAAe;EACnC,IAAI,CAAC,aAAa,OAAO,CAAC;EAC1B,MAAM,MAAgD,CAAC;EACvD,KAAK,MAAM,MAAM,WAAW,MAAM,WAAW,YAAY,SAAS,GAAG;GACnE,MAAM,OAAO,YAAY,QAAQ,EAAE;GACnC,IAAI,CAAC,QAAS,KAA2B,SAAS,WAAW;GAC7D,IAAI,KAAK;IAAE;IAAI,MAAM;GAAoB,CAAC;EAC5C;EACA,OAAO;CACT;CAEA,MAAM,SACJ,IACA,UACA,GACA,GACA,SACA,aACsB;EACtB;EAGA,UAAU;EACV,OAAO;GAAE,MAAM;GAAS;GAAG;GAAG,aAAa;EAAU;EACrD;EACA,GAAI,eAAe,CAAC,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO;EAC3C,aAAgC,EAAE,gBAAgB;GAAE,GAAG;GAAS;EAAS,EAAE;CAC7E;CAEA,MAAM,UAAsB;EAC1B,IAAI;EACJ,QAAQ,OAAO;GACb,MAAM,YAAY,eAAe,CAAC,EAAE,aAAa;GACjD,MAAM,MAA0B,CAAC;GACjC,KAAK,M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EACL;CACF;AACF;;;AAIA,SAAS,WAAW,WAA8B,WAA6C;CAC7F,OAAO,cAAc,QAAQ,UAAU,SAAS,SAAS,IAAI,YAAY,CAAC,GAAG,WAAW,SAAS;AACnG"}
1
+ {"version":3,"file":"pathAnchors.js","names":[],"sources":["../../src/affordances/pathAnchors.ts"],"sourcesContent":["/** Path anchor, control-handle, and segment affordances, and the parts path-edit extensions add. */\n\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport type { Affordance, AffordanceBinding, AffordanceRegion, CommonAffordanceScratch } from './types';\nimport type { ChromeState } from 'core/selection/chromeState';\nimport { pathToAnchors, type AnchorSet, type PolygonPath } from '@weasel-js/geom';\nimport { enumerateAnchors } from 'interactions/actions/edit-anchors/geometry';\nimport type { PathEditExtension } from 'domains/paths/pathEditExtension';\n\n/**\n * Live anchor-editing state. The thunk that returns it is called on every\n * pointer event, so it must be cheap (O(1) field reads).\n */\nexport interface AnchorState {\n /** Id of the path currently in anchor-edit mode, or `null`. Control handles\n * are only hittable on the path that is being edited. */\n editingId: string | null;\n /** Current editable path for a node id. Non-polygon values are ignored. */\n getPose(id: string): unknown;\n /** The committed pose and data of a node, which extensions' parts read. */\n getNode?(id: string): { pose: unknown; data: unknown } | null;\n /** The path-edit extensions whose parts are pressed, in order. */\n extensions?: readonly PathEditExtension[];\n /** The path whose outline counts as a segment press, when it is not\n * `getPose`'s: a path drawn from a form, edited through the form's edit\n * path. */\n getOutline?(id: string): unknown;\n}\n\n/** Options for the path-anchor affordances. */\nexport interface PathAnchorAffordanceOptions {\n /** Hit radius (screen-px) for anchor and control points. Default 8. */\n hitRadius?: number;\n /** Cursor while hovering a part a path-edit extension adds. Defaults to\n * `'pointer'`. Anchors and controls carry none: the action a drag on one\n * would start shows its own, `editAnchors`' pointer or a path-edit tool's. */\n cursor?: CursorSpec;\n}\n\n/** What an anchor hit hands to the action that follows. */\nexport interface AnchorScratch extends CommonAffordanceScratch {\n /** Node id of the path the anchor belongs to. */\n targetId: string;\n /** Sequential anchor index in path walk order. */\n anchorIndex: number;\n /** Which of the anchor's three grabbable points this is. */\n part: 'anchor' | 'controlIn' | 'controlOut';\n}\n\n/** Chrome-caps id gating the anchor, control, and segment affordances. */\nexport const PATH_ANCHOR_CHROME_ID = 'path-edit.anchors';\n\n/**\n * Segment, extension-part, anchor, and control affordances for the selected\n * paths, bottom → top.\n *\n * Three affordances rather than one, so that a control handle beats an anchor\n * regardless of which is nearer, the way controls draw on top, and both beat\n * the segment they sit on. Within each, nearest wins. A press on the edited\n * path's outline is a `segment` hit, which the segment bend binds to and a\n * selection move turns down. Anchors, controls, and segments share one id:\n * chrome-caps gates anchor editing as a single piece of chrome. A part a\n * path-edit extension adds (`PathEditExtension.parts`) may name a chrome id of\n * its own as well, so it can be shown apart from the anchors.\n *\n * Order matters — spread this into an affordance list in the returned order.\n */\nexport function createPathAnchorAffordances(\n getAnchorState: () => AnchorState | null,\n opts: PathAnchorAffordanceOptions = {},\n): Affordance[] {\n const { hitRadius = 8, cursor = 'pointer' } = opts;\n\n /** Selected polygon paths, and the one being edited, paired with their node id. */\n const editablePaths = (state: ChromeState): Array<{ id: string; path: PolygonPath }> => {\n const anchorState = getAnchorState();\n if (!anchorState) return [];\n const out: Array<{ id: string; path: PolygonPath }> = [];\n for (const id of withEdited(state.selection, anchorState.editingId)) {\n const pose = anchorState.getPose(id);\n if (!pose || (pose as { kind?: string }).kind !== 'polygon') continue;\n out.push({ id, path: pose as PolygonPath });\n }\n return out;\n };\n\n const point = (\n id: string,\n targetId: string,\n x: number,\n y: number,\n scratch: AnchorScratch,\n hitKind: string,\n ): AffordanceRegion => ({\n id,\n // Anchor coordinates are already world space, pose rotation baked in.\n // Anchoring to `null` keeps the framework from applying it twice.\n targetId: null,\n shape: { kind: 'point', x, y, hitRadiusPx: hitRadius },\n hitKind,\n bind: (): AffordanceBinding => ({ initialScratch: { ...scratch, targetId } }),\n });\n\n const anchors: Affordance = {\n id: PATH_ANCHOR_CHROME_ID,\n regions(state) {\n const editingId = getAnchorState()?.editingId ?? null;\n const out: AffordanceRegion[] = [];\n for (const { id, path } of editablePaths(state)) {\n // `editAnchorsAction` edits whatever path the dep says is in edit\n // mode, ignoring which one was hit — so once a path IS being edited,\n // only its own anchors may claim the press.\n if (editingId !== null && id !== editingId) continue;\n for (const a of enumerateAnchors(path)) {\n out.push(point(\n `${id}:anchor:${a.anchorIndex}`,\n id, a.x, a.y,\n { targetId: id, anchorIndex: a.anchorIndex, part: 'anchor' },\n `anchor:${a.anchorIndex}`,\n ));\n }\n }\n return out;\n },\n };\n\n const controls: Affordance = {\n id: PATH_ANCHOR_CHROME_ID,\n regions(state) {\n const anchorState = getAnchorState();\n const editingId = anchorState?.editingId ?? null;\n if (editingId === null) return [];\n const out: AffordanceRegion[] = [];\n for (const { id, path } of editablePaths(state)) {\n // Controls are grabbable only on the path actually in edit mode.\n if (id !== editingId) continue;\n for (const a of enumerateAnchors(path)) {\n if (a.controlIn) {\n out.push(point(\n `${id}:controlIn:${a.anchorIndex}`,\n id, a.controlIn.x, a.controlIn.y,\n { targetId: id, anchorIndex: a.anchorIndex, part: 'controlIn' },\n `controlIn:${a.anchorIndex}`,\n ));\n }\n if (a.controlOut) {\n out.push(point(\n `${id}:controlOut:${a.anchorIndex}`,\n id, a.controlOut.x, a.controlOut.y,\n { targetId: id, anchorIndex: a.anchorIndex, part: 'controlOut' },\n `controlOut:${a.anchorIndex}`,\n ));\n }\n }\n }\n return out;\n },\n };\n\n const segments: Affordance = {\n id: PATH_ANCHOR_CHROME_ID,\n regions(state) {\n const editingId = getAnchorState()?.editingId ?? null;\n if (editingId === null) return [];\n const edited = editablePaths(state).find(({ id }) => id === editingId);\n if (!edited) return [];\n const outline = getAnchorState()?.getOutline?.(editingId) as PolygonPath | null | undefined;\n return [{\n id: `${editingId}:segment`,\n targetId: null,\n shape: { kind: 'outline', path: outline?.kind === 'polygon' ? outline : edited.path, hitRadiusPx: hitRadius },\n hitKind: 'segment',\n bind: (): AffordanceBinding => ({ initialScratch: { targetId: editingId } }),\n }];\n },\n };\n\n return [segments, extensionParts(getAnchorState, hitRadius, cursor), anchors, controls];\n}\n\n/** The parts path-edit extensions add to the path in edit mode, each pressed\n * as its own `hitKind`. */\nfunction extensionParts(\n getAnchorState: () => AnchorState | null,\n hitRadius: number,\n cursor: CursorSpec,\n): Affordance {\n return {\n id: PATH_ANCHOR_CHROME_ID,\n regions() {\n const anchorState = getAnchorState();\n const editingId = anchorState?.editingId ?? null;\n const extensions = anchorState?.extensions?.filter((e) => e.parts) ?? [];\n if (editingId === null || extensions.length === 0) return [];\n const pose = anchorState!.getPose(editingId);\n const node = anchorState!.getNode?.(editingId);\n if (!node || !pose || (pose as { kind?: string }).kind !== 'polygon') return [];\n const target = {\n id: editingId, node, path: pose as PolygonPath, anchors: pathToAnchors(pose as PolygonPath) as AnchorSet,\n };\n return extensions.flatMap((ext) => ext.parts!(target).map((part): AffordanceRegion => ({\n id: `${editingId}:${part.hitKind}`,\n targetId: null,\n shape: {\n kind: 'point', x: part.x, y: part.y, hitRadiusPx: part.hitRadiusPx ?? hitRadius,\n ...(part.standoff ? { standoff: part.standoff } : {}),\n },\n hitKind: part.hitKind,\n ...(part.chromeId ? { chromeId: part.chromeId } : {}),\n cursor,\n bind: (): AffordanceBinding => ({ initialScratch: { targetId: editingId } }),\n })));\n },\n };\n}\n\n/** `selection`, and the path being edited after it when the selection does not hold it: a path edited through the\n * effect that hides it is edited while the effect is what is selected. */\nfunction withEdited(selection: readonly string[], editingId: string | null): readonly string[] {\n return editingId === null || selection.includes(editingId) ? selection : [...selection, editingId];\n}\n"],"mappings":";;;;;AAkDA,IAAa,wBAAwB;;;;;;;;;;;;;;;;AAiBrC,SAAgB,4BACd,gBACA,OAAoC,CAAC,GACvB;CACd,MAAM,EAAE,YAAY,GAAG,SAAS,cAAc;;CAG9C,MAAM,iBAAiB,UAAiE;EACtF,MAAM,cAAc,eAAe;EACnC,IAAI,CAAC,aAAa,OAAO,CAAC;EAC1B,MAAM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,CAAC,QAAS,KAA2B,SAAS,WAAW,OAAO,CAAC;GAC9E,MAAM,SAAS;IACb,IAAI;IAAW;IAAM,MAAM;IAAqB,SAAS,cAAc,IAAmB;GAC5F;GACA,OAAO,WAAW,SAAS,QAAQ,IAAI,MAAO,MAAM,CAAC,CAAC,KAAK,UAA4B;IACrF,IAAI,GAAG,UAAU,GAAG,KAAK;IACzB,UAAU;IACV,OAAO;KACL,MAAM;KAAS,GAAG,KAAK;KAAG,GAAG,KAAK;KAAG,aAAa,KAAK,eAAe;KACtE,GAAI,KAAK,WAAW,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;IACrD;IACA,SAAS,KAAK;IACd,GAAI,KAAK,WAAW,EAAE,UAAU,KAAK,SAAS,IAAI,CAAC;IACnD;IACA,aAAgC,EAAE,gBAAgB,EAAE,UAAU,UAAU,EAAE;GAC5E,EAAE,CAAC;EACL;CACF;AACF;;;AAIA,SAAS,WAAW,WAA8B,WAA6C;CAC7F,OAAO,cAAc,QAAQ,UAAU,SAAS,SAAS,IAAI,YAAY,CAAC,GAAG,WAAW,SAAS;AACnG"}
@@ -3,6 +3,7 @@ import { derivedPartsOf, pathFromParts, resolvePartPaint } from "../core/scene/d
3
3
  import { sourcesOf } from "../core/scene/dependents.js";
4
4
  import { pathPoseDescriptor } from "../core/geometry/pathPoseDescriptor.js";
5
5
  import { commitOps } from "../interactions/actions/defaultCommitAdapter.js";
6
+ import { SHAPE_COUNT_RANGE, STAR_RATIO_RANGE, clampShapeGenerator, isShapeGenerator, regenerateShape, settleShapeGenerator, shapeGeneratorOf, shapeGeneratorPath, withoutShapeGenerator } from "../domains/paths/shapeGenerator.js";
6
7
  import { HANDLE_LOCK_ROLES, locksInForce } from "../interactions/actions/edit-anchors/handleDrag.js";
7
8
  import { classifyPathStorage, hasEditablePath, pathEditPathOf, resolveEditablePathOf, storeEditablePath } from "../domains/paths/editablePath.js";
8
9
  import { finishPathEditFrame, pathEditPreview } from "../interactions/actions/edit-anchors/preview.js";
@@ -18,7 +19,6 @@ import { segmentUnder } from "../interactions/actions/defaults/segmentUnder.js";
18
19
  import { applyBooleanOp, previewBooleanOp } from "../interactions/actions/booleans/booleans.js";
19
20
  import { PATHFINDER_STROKES } from "../interactions/actions/booleans/action.js";
20
21
  import { makeBooleanGroup } from "../interactions/actions/booleans/booleanGroupAction.js";
21
- import { SHAPE_COUNT_RANGE, STAR_RATIO_RANGE, clampShapeGenerator, isShapeGenerator, regenerateShape, settleShapeGenerator, shapeGeneratorOf, shapeGeneratorPath, withoutShapeGenerator } from "../domains/paths/shapeGenerator.js";
22
22
  import { GEOMETRY_BOUND_DATA, withoutGeometryBoundData } from "../domains/paths/pathEditExtension.js";
23
23
  import { deleteNode, insertAt, pathCopy, pathNodesOf, reshapeOps, reshapeTo, selectedPathNodes, slotOf, withPath } from "../interactions/actions/pathCommands/pathNodes.js";
24
24
  import { livePathEdit } from "../interactions/actions/pathCommands/livePathEdit.js";
@@ -5,7 +5,7 @@ import { alignPreset, arrangePreset, distributePreset, flipPreset, reorderPreset
5
5
  import { clipboardPreset, contextMenuPreset, deletePreset, duplicatePreset, editPreset, escapePreset, groupPreset, nudgePreset, selectAllPreset, stylePreset } from "../canvas/SceneCanvas/presets/edit.js";
6
6
  import { ingestPreset } from "../canvas/SceneCanvas/presets/ingest.js";
7
7
  import { anchorKeysPreset, outlinesPreset, pathCommandsPreset, pathEditPreset, pathfinderPreset, pathsPreset } from "../canvas/SceneCanvas/presets/paths.js";
8
- import { BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DRAW_TOOLS, PAGE_TOOLS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS } from "../canvas/SceneCanvas/builtinToolSets.js";
8
+ import { ANCHOR_TOOLS, BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, DRAW_TOOLS, PAGE_TOOLS, SELECT_TOOLS, SHAPE_TOOLS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS } from "../canvas/SceneCanvas/builtinToolSets.js";
9
9
  import { drawToolsPreset, pageToolsPreset, selectToolsPreset, shapeToolsPreset, typeToolsPreset, viewToolsPreset } from "../canvas/SceneCanvas/presets/tools.js";
10
10
  import { selectPreset } from "../canvas/SceneCanvas/presets/select.js";
11
11
  import { movePreset, outlinePreset, resizePreset, rotatePreset } from "../canvas/SceneCanvas/presets/transform.js";
@@ -27,4 +27,4 @@ import { canQueryLocalFonts, cssFamilyName, cssFontFamily, cssFontFamilyLoading,
27
27
  import { bindingSpec, held, key, keySpecRoute, unbound } from "@weasel-js/gestures";
28
28
  import { CURSOR_ANGLE_STEPS, CURSOR_MAX_CSS_PX, bakeCursor, createCursorSink as createCursorSink$1, createPaintedCursorState as createPaintedCursorState$1, cursorFor as cursorFor$1, resolveCursor, resolveCursorTier as resolveCursorTier$1 } from "@weasel-js/cursor";
29
29
 
30
- export { BASELINE_ACTIONS, BASELINE_ACTION_IDS, BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, CURSOR_ANGLE_STEPS, CURSOR_MAX_CSS_PX, DRAW_TOOLS, FEATURE_ACTION_IDS, FEATURE_PRESETS, KEYMAP_HOLD, KIT_SHAPE_KINDS, KIT_VERSIONS, PAGE_TOOLS, PAINTED_CURSOR_LAYER_ID, SCENE_CANVAS_FEATURES, SELECT_TOOLS, SHAPE_KINDS, SHAPE_TOOLS, SPRITE_STRIDE, TOOL_DRIVEN_ACTION_IDS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS, alignPreset, anchorKeysPreset, arrangePreset, assembleEntries, bakeCursor, bindingSpec, blur, canQueryLocalFonts, captureGesture, captureKey, checkRequirements, clipboardPreset, contextMenuPreset, createCursorSink$1 as createCursorSink, createKeymapStack, createPaintedCursorLayer, createPaintedCursorState$1 as createPaintedCursorState, createReflectable$1 as createReflectable, cssFamilyName, cssFontFamily, cssFontFamilyLoading, cullDrawCommands$1 as cullDrawCommands, cursorFor$1 as cursorFor, deletePreset, describeKeymap, describePresets, distributePreset, drawPreset, drawToolsPreset, duplicatePreset, editPreset, enableLocalFontOutlines, escapePreset, flipPreset, fontOutlineRegistry, fontRegistry, frameRect, groupPreset, hasFontOutlines, held, holdPreview$1 as holdPreview, holdPreviewId$1 as holdPreviewId, ingestPreset, isAtom, isCanvasFont, key, keySpecRoute, keymapContribution$1 as keymapContribution, keymapLeaderBindingId, keymapLeaderId, keymapShortcuts, listFontOutlines, liveScope, loadFontOutlines, mat3$1 as mat3, mergeContributions$1 as mergeContributions, modeShortcutSpec, modeShortcuts, movePreset, nudgePreset, outlinePreset, outlineStatus, outlinesPreset, pageToolsPreset, paletteInsertPaint, pathCommandsPreset, pathEditPreset, pathfinderPreset, pathsPreset, pickPreset, refreshCanvasFont, registerCanvasFont, registerEffect, registerFont, registerFontOutlines, reorderPreset, resizePreset, resolveCursor, resolveCursorTier$1 as resolveCursorTier, rotateAroundAABBCenter, rotatePreset, satisfiesRange, scopeBindings, selectAllPreset, selectPreset, selectToolsPreset, shapeToolsPreset, stylePreset, subscribeGlyphReady$1 as subscribeGlyphReady, textBoxOf, transformPreset, typeToolsPreset, unbound, unregisterCanvasFont, unregisterFontOutlines, useTransformFollower, viewPreset, viewToMat3$1 as viewToMat3, viewToolsPreset, vignette, warmFonts$1 as warmFonts };
30
+ export { ANCHOR_TOOLS, BASELINE_ACTIONS, BASELINE_ACTION_IDS, BUILTIN_TOOLS, BUILTIN_TOOL_GROUPS, BUILTIN_TOOL_IDS, CURSOR_ANGLE_STEPS, CURSOR_MAX_CSS_PX, DRAW_TOOLS, FEATURE_ACTION_IDS, FEATURE_PRESETS, KEYMAP_HOLD, KIT_SHAPE_KINDS, KIT_VERSIONS, PAGE_TOOLS, PAINTED_CURSOR_LAYER_ID, SCENE_CANVAS_FEATURES, SELECT_TOOLS, SHAPE_KINDS, SHAPE_TOOLS, SPRITE_STRIDE, TOOL_DRIVEN_ACTION_IDS, TOOL_GROUP_ORDER, TYPE_TOOLS, VIEW_TOOLS, alignPreset, anchorKeysPreset, arrangePreset, assembleEntries, bakeCursor, bindingSpec, blur, canQueryLocalFonts, captureGesture, captureKey, checkRequirements, clipboardPreset, contextMenuPreset, createCursorSink$1 as createCursorSink, createKeymapStack, createPaintedCursorLayer, createPaintedCursorState$1 as createPaintedCursorState, createReflectable$1 as createReflectable, cssFamilyName, cssFontFamily, cssFontFamilyLoading, cullDrawCommands$1 as cullDrawCommands, cursorFor$1 as cursorFor, deletePreset, describeKeymap, describePresets, distributePreset, drawPreset, drawToolsPreset, duplicatePreset, editPreset, enableLocalFontOutlines, escapePreset, flipPreset, fontOutlineRegistry, fontRegistry, frameRect, groupPreset, hasFontOutlines, held, holdPreview$1 as holdPreview, holdPreviewId$1 as holdPreviewId, ingestPreset, isAtom, isCanvasFont, key, keySpecRoute, keymapContribution$1 as keymapContribution, keymapLeaderBindingId, keymapLeaderId, keymapShortcuts, listFontOutlines, liveScope, loadFontOutlines, mat3$1 as mat3, mergeContributions$1 as mergeContributions, modeShortcutSpec, modeShortcuts, movePreset, nudgePreset, outlinePreset, outlineStatus, outlinesPreset, pageToolsPreset, paletteInsertPaint, pathCommandsPreset, pathEditPreset, pathfinderPreset, pathsPreset, pickPreset, refreshCanvasFont, registerCanvasFont, registerEffect, registerFont, registerFontOutlines, reorderPreset, resizePreset, resolveCursor, resolveCursorTier$1 as resolveCursorTier, rotateAroundAABBCenter, rotatePreset, satisfiesRange, scopeBindings, selectAllPreset, selectPreset, selectToolsPreset, shapeToolsPreset, stylePreset, subscribeGlyphReady$1 as subscribeGlyphReady, textBoxOf, transformPreset, typeToolsPreset, unbound, unregisterCanvasFont, unregisterFontOutlines, useTransformFollower, viewPreset, viewToMat3$1 as viewToMat3, viewToolsPreset, vignette, warmFonts$1 as warmFonts };
@@ -9,11 +9,11 @@ import { flipAction } from "../interactions/actions/flip/action.js";
9
9
  import { createResizeAction, resizeAction } from "../interactions/actions/resize/action.js";
10
10
  import { rotateAction } from "../interactions/actions/rotate/action.js";
11
11
  import { areaSelectAction } from "../interactions/actions/defaults/areaSelect.js";
12
+ import { POLYGON_INSERT_PARAMS, STAR_INSERT_PARAMS, insertParams } from "../interactions/actions/insert/params.js";
12
13
  import { insertAction } from "../interactions/actions/insert/action.js";
13
14
  import { placeAction } from "../interactions/actions/insert/placeAction.js";
14
15
  import { INSERT_REPOSITION_BINDING, insertRepositionAction } from "../interactions/actions/insert/repositionAction.js";
15
16
  import { clearSelectionAction } from "../interactions/actions/defaults/clearSelection.js";
16
- import { exitPathEditToolAction, pathEditToolAction, pathEditToolActive } from "../interactions/actions/defaults/pathEditTools.js";
17
17
  import { cloneAction } from "../interactions/actions/clone/action.js";
18
18
  import { viewportDragPanAction } from "../interactions/actions/defaults/viewportDragPan.js";
19
19
  import { makeViewportZoomAction, viewportZoomAction } from "../interactions/actions/defaults/viewportZoom.js";
@@ -36,12 +36,14 @@ import { computeSliceOps } from "../interactions/actions/defaults/sliceOps.js";
36
36
  import { useSliceDep, useSliceDepSource } from "../canvas/deps/slice.js";
37
37
  import { useBooleansAdapterSource } from "../canvas/deps/booleans.js";
38
38
  import { defineTool, useTools as useTools$1 } from "../tools/overlayBinding.js";
39
+ import { useToolOptionTunings, useToolOptionValues } from "../tools/toolOptions.js";
39
40
  import { useKeybindings } from "../tools/useKeybindings.js";
40
41
  import { pickTopMostHit } from "../tools/builtin/pickTopMostHit.js";
41
42
  import { GROUP_ENTRY_ID, createGroupEntryContribution, useGroupEntryContribution } from "../tools/builtin/select/groupEntry.js";
42
43
  import { useSelectTool } from "../tools/builtin/select/useSelectTool.js";
43
44
  import { useHandTool } from "../tools/builtin/hand/useHandTool.js";
44
45
  import { DRAG_PAN_ID, dragPanContribution } from "../tools/builtin/hand/dragPanContribution.js";
46
+ import { ANCHORS_TOOL_ID, anchorsTool } from "../tools/builtin/anchors/anchorsTool.js";
45
47
  import { useTextTool } from "../tools/builtin/text/useTextTool.js";
46
48
  import { STICKY_DEFAULTS, stickyData, stickyNodeFactory } from "../tools/builtin/sticky/stickyNode.js";
47
49
  import { useStickyTool } from "../tools/builtin/sticky/useStickyTool.js";
@@ -58,10 +60,10 @@ import { useStarTool } from "../tools/builtin/star/useStarTool.js";
58
60
  import { usePencilTool } from "../tools/builtin/pencil/usePencilTool.js";
59
61
  import { useSliceTool } from "../tools/builtin/slice/useSliceTool.js";
60
62
  import { useMeasureTool } from "../tools/builtin/measure/useMeasureTool.js";
61
- import { isToolSet, toolIdsOf as toolIdsOf$1, toolSet as toolSet$1, toolSetHas, withoutTools } from "../tools/index.js";
63
+ import { createToolOptionValues, isToolSet, steppedOption, toolIdsOf as toolIdsOf$1, toolOptionParams, toolOptionSteps, toolSet as toolSet$1, toolSetHas, withoutTools } from "../tools/index.js";
62
64
  import { useLatest as useLatest$1 } from "@weasel-js/react";
63
65
  import { ActionDisabledReason as ActionDisabledReason$1, actionBindings as actionBindings$1, actionCursor, actionItemTitle, actionItems, actionSettingsParams, actionShortcuts, actionsTagged, bindingId, buildDepsFromRequires as buildDepsFromRequires$1, createDepRegistry, createDispatcher as createDispatcher$1, deleteScratch, evaluateActive as evaluateActive$1, evaluateEnabled as evaluateEnabled$1, getScratch as getScratch$1, heldKeySpec as heldKeySpec$1, keySpecShortcut, keysHeld, matchActionItem, modifierStateOf, overlaysOf as overlaysOf$1, readActionSettings, resolveBindingOverrides, resolveParams as resolveParams$1, resolveSchemaMenu, roleReader as roleReader$1, scratchKey as scratchKey$1, setScratch as setScratch$1, specificity, taggedActionItems, tuneAction } from "@weasel-js/routing";
64
66
  import { bodyPredicate, hitPredicate as hitPredicate$1 } from "@weasel-js/gestures";
65
- import { ActionsProvider as ActionsProvider$1, ActiveToolContextProvider as ActiveToolContextProvider$1, ActiveToolContextProviderIfRoot as ActiveToolContextProviderIfRoot$1, DepRegistryProvider as DepRegistryProvider$1, InputScope as InputScope$1, Yoke, useAction, useActionsRegistry as useActionsRegistry$1, useActiveToolContext, useCommand, useDepRegistry as useDepRegistry$1, useDepSource as useDepSource$1, useGestureDispatcher as useGestureDispatcher$1, useMenuHost as useMenuHost$1, useMenus, useOngoingAction, useOpenKeymap, useOptionalActiveToolContext as useOptionalActiveToolContext$1, useOptionalDepRegistry as useOptionalDepRegistry$1, useYoke } from "@weasel-js/routing/react";
67
+ import { ActionsProvider as ActionsProvider$1, ActiveToolContextProvider as ActiveToolContextProvider$1, ActiveToolContextProviderIfRoot as ActiveToolContextProviderIfRoot$1, DepRegistryProvider as DepRegistryProvider$1, InputScope as InputScope$1, Yoke, lastOperationOf, useAction, useActionsRegistry as useActionsRegistry$1, useActiveToolContext, useCommand, useDepRegistry as useDepRegistry$1, useDepSource as useDepSource$1, useGestureDispatcher as useGestureDispatcher$1, useLastOperation, useLastOperationStore, useMenuHost as useMenuHost$1, useMenus, useOngoingAction, useOpenKeymap, useOptionalActiveToolContext as useOptionalActiveToolContext$1, useOptionalDepRegistry as useOptionalDepRegistry$1, useYoke } from "@weasel-js/routing/react";
66
68
 
67
- export { AREA_SELECT_ID, ActionDisabledReason$1 as ActionDisabledReason, ActionsProvider$1 as ActionsProvider, ActiveToolContextProvider$1 as ActiveToolContextProvider, ActiveToolContextProviderIfRoot$1 as ActiveToolContextProviderIfRoot, CORNER_ANCHORS, DRAG_PAN_ID, DepRegistryProvider$1 as DepRegistryProvider, EDGE_HANDLE_MIN_RADII, GROUP_ENTRY_ID, INSERT_REPOSITION_BINDING, InputScope$1 as InputScope, KIT_STANDARD_ACTION_IDS, PATH_GESTURE_TAGS, RESIZE_HANDLE_ANCHORS, SELECTION_MOVE_ID, SELECTION_RESIZE_ID, SELECTION_ROTATE_ID, SELECTION_TRANSFORM_ID, STICKY_DEFAULTS, Yoke, actionBindings$1 as actionBindings, actionCursor, actionItemTitle, actionItems, actionSettingsParams, actionShortcuts, actionsTagged, areaSelectAction, areaSelectContribution, bindingId, bodyPredicate, buildDepsFromRequires$1 as buildDepsFromRequires, clearSelectionAction, clipboardCopyAction, clipboardCutAction, clipboardPasteAction, clipboardPasteEventAction, cloneAction, commitDeleteToScene, computeSliceOps, containerScrollAction, contextMenuAction, cornerPoint, createDeleteAction, createDepRegistry, createDispatcher$1 as createDispatcher, createGroupEntryContribution, createPointerFollower, createResizeAction, defaultCommitAdapter, defineTool, deleteAction, deleteAnchorsAction, deleteScratch, dragPanContribution, editAnchorsAction, editingLayer, enterTextEditAction, evaluateActive$1 as evaluateActive, evaluateEnabled$1 as evaluateEnabled, exitPathEditToolAction, flipAction, getScratch$1 as getScratch, handlePoint, heldKeySpec$1 as heldKeySpec, hiddenSourceDeleteOps, hitPredicate$1 as hitPredicate, inPlane, insertAction, insertLayer, insertRepositionAction, isCornerHandle, isToolSet, keySpecShortcut, keysHeld, lassoSelectAction, makePinchZoomAction, makeViewportWheelPanAction, makeViewportZoomAction, matchActionItem, modifierStateOf, moveAction, nudgeAnchorsDownAction, nudgeAnchorsLeftAction, nudgeAnchorsRightAction, nudgeAnchorsUpAction, onEmptyCanvas, openContextMenu, overlaysOf$1 as overlaysOf, pathEditToolAction, pathEditToolActive, pathOperationTags, pickTopMostHit, pinchZoomAction, placeAction, readActionSettings, refusalOf, resizeAction, resizeHandlesFor, resolveBindingOverrides, resolveParams$1 as resolveParams, resolveSchemaMenu, roleReader$1 as roleReader, rotateAction, scratchKey$1 as scratchKey, scrollRange, scrollableAt, selectAnchorAction, selectFromLasso, selectionLayer, selectionMoveBindings, selectionMoveContribution, selectionResizeBindings, selectionResizeContribution, selectionRotateBindings, selectionRotateContribution, selectionTransformBindings, selectionTransformContribution, setScratch$1 as setScratch, sliceAction, specificity, stickyData, stickyNodeFactory, taggedActionItems, toolIdsOf$1 as toolIdsOf, toolSet$1 as toolSet, toolSetHas, tuneAction, useAction, useActionsRegistry$1 as useActionsRegistry, useActiveToolContext, useBooleansAdapterSource, useCommand, useDepRegistry$1 as useDepRegistry, useDepSource$1 as useDepSource, useEllipseTool, useEyedropperTool, useGestureDispatcher$1 as useGestureDispatcher, useGroupEntryContribution, useHandTool, useImageTool, useKeybindings, useLassoTool, useLatest$1 as useLatest, useLineTool, useMeasureTool, useMenuHost$1 as useMenuHost, useMenus, useOngoingAction, useOpenKeymap, useOptionalActiveToolContext$1 as useOptionalActiveToolContext, useOptionalDepRegistry$1 as useOptionalDepRegistry, usePenTool, usePencilTool, usePolygonTool, usePoseDescriptorDepSource, useRectTool, useResizePolicy, useSelectTool, useSliceDep, useSliceDepSource, useSliceTool, useStandardActions, useStarTool, useStickyTool, useTextTool, useTools$1 as useTools, useYoke, viewportDragPanAction, viewportWheelPanAction, viewportZoomAction, withoutTools };
69
+ export { ANCHORS_TOOL_ID, AREA_SELECT_ID, ActionDisabledReason$1 as ActionDisabledReason, ActionsProvider$1 as ActionsProvider, ActiveToolContextProvider$1 as ActiveToolContextProvider, ActiveToolContextProviderIfRoot$1 as ActiveToolContextProviderIfRoot, CORNER_ANCHORS, DRAG_PAN_ID, DepRegistryProvider$1 as DepRegistryProvider, EDGE_HANDLE_MIN_RADII, GROUP_ENTRY_ID, INSERT_REPOSITION_BINDING, InputScope$1 as InputScope, KIT_STANDARD_ACTION_IDS, PATH_GESTURE_TAGS, POLYGON_INSERT_PARAMS, RESIZE_HANDLE_ANCHORS, SELECTION_MOVE_ID, SELECTION_RESIZE_ID, SELECTION_ROTATE_ID, SELECTION_TRANSFORM_ID, STAR_INSERT_PARAMS, STICKY_DEFAULTS, Yoke, actionBindings$1 as actionBindings, actionCursor, actionItemTitle, actionItems, actionSettingsParams, actionShortcuts, actionsTagged, anchorsTool, areaSelectAction, areaSelectContribution, bindingId, bodyPredicate, buildDepsFromRequires$1 as buildDepsFromRequires, clearSelectionAction, clipboardCopyAction, clipboardCutAction, clipboardPasteAction, clipboardPasteEventAction, cloneAction, commitDeleteToScene, computeSliceOps, containerScrollAction, contextMenuAction, cornerPoint, createDeleteAction, createDepRegistry, createDispatcher$1 as createDispatcher, createGroupEntryContribution, createPointerFollower, createResizeAction, createToolOptionValues, defaultCommitAdapter, defineTool, deleteAction, deleteAnchorsAction, deleteScratch, dragPanContribution, editAnchorsAction, editingLayer, enterTextEditAction, evaluateActive$1 as evaluateActive, evaluateEnabled$1 as evaluateEnabled, flipAction, getScratch$1 as getScratch, handlePoint, heldKeySpec$1 as heldKeySpec, hiddenSourceDeleteOps, hitPredicate$1 as hitPredicate, inPlane, insertAction, insertLayer, insertParams, insertRepositionAction, isCornerHandle, isToolSet, keySpecShortcut, keysHeld, lassoSelectAction, lastOperationOf, makePinchZoomAction, makeViewportWheelPanAction, makeViewportZoomAction, matchActionItem, modifierStateOf, moveAction, nudgeAnchorsDownAction, nudgeAnchorsLeftAction, nudgeAnchorsRightAction, nudgeAnchorsUpAction, onEmptyCanvas, openContextMenu, overlaysOf$1 as overlaysOf, pathOperationTags, pickTopMostHit, pinchZoomAction, placeAction, readActionSettings, refusalOf, resizeAction, resizeHandlesFor, resolveBindingOverrides, resolveParams$1 as resolveParams, resolveSchemaMenu, roleReader$1 as roleReader, rotateAction, scratchKey$1 as scratchKey, scrollRange, scrollableAt, selectAnchorAction, selectFromLasso, selectionLayer, selectionMoveBindings, selectionMoveContribution, selectionResizeBindings, selectionResizeContribution, selectionRotateBindings, selectionRotateContribution, selectionTransformBindings, selectionTransformContribution, setScratch$1 as setScratch, sliceAction, specificity, steppedOption, stickyData, stickyNodeFactory, taggedActionItems, toolIdsOf$1 as toolIdsOf, toolOptionParams, toolOptionSteps, toolSet$1 as toolSet, toolSetHas, tuneAction, useAction, useActionsRegistry$1 as useActionsRegistry, useActiveToolContext, useBooleansAdapterSource, useCommand, useDepRegistry$1 as useDepRegistry, useDepSource$1 as useDepSource, useEllipseTool, useEyedropperTool, useGestureDispatcher$1 as useGestureDispatcher, useGroupEntryContribution, useHandTool, useImageTool, useKeybindings, useLassoTool, useLastOperation, useLastOperationStore, useLatest$1 as useLatest, useLineTool, useMeasureTool, useMenuHost$1 as useMenuHost, useMenus, useOngoingAction, useOpenKeymap, useOptionalActiveToolContext$1 as useOptionalActiveToolContext, useOptionalDepRegistry$1 as useOptionalDepRegistry, usePenTool, usePencilTool, usePolygonTool, usePoseDescriptorDepSource, useRectTool, useResizePolicy, useSelectTool, useSliceDep, useSliceDepSource, useSliceTool, useStandardActions, useStarTool, useStickyTool, useTextTool, useToolOptionTunings, useToolOptionValues, useTools$1 as useTools, useYoke, viewportDragPanAction, viewportWheelPanAction, viewportZoomAction, withoutTools };
@@ -1,10 +1,12 @@
1
1
  import { strokeRegion } from "../interactions/actions/outlines/strokeRegion.js";
2
+ import { warnTextOutlines, warnUser } from "../interactions/actions/notices.js";
2
3
  import { applyCreateOutlines } from "../interactions/actions/outlines/createOutlines.js";
3
4
  import { applyOutlineStroke } from "../interactions/actions/outlines/outlineStroke.js";
4
5
  import { useSceneTextEdit } from "../domains/text/useSceneTextEdit.js";
5
6
  import { createTextLayer } from "../domains/text/textLayer.js";
6
- import { TEXT_EDIT_FONT_HOLD, TextOutlinesError as TextOutlinesError$1, charOffsetToDomPosition, domPositionToCharOffset, domToRuns, loadTextOutlines as loadTextOutlines$1, runsToDom, textCommand, textCommandFromPose, textCommandFromRuns, textToPath as textToPath$1, textToPathsByPaint as textToPathsByPaint$1, useTextEdit } from "../domains/text/index.js";
7
+ import { TEXT_EDIT_FONT_HOLD, TextOutlinesError as TextOutlinesError$1, charOffsetToDomPosition, domPositionToCharOffset, domToRuns, loadTextOutlines as loadTextOutlines$1, runsToDom, textCommand, textCommandFromPose, textCommandFromRuns, textCommandFromRunsInto, textToPath as textToPath$1, textToPathsByPaint as textToPathsByPaint$1, useTextEdit } from "../domains/text/index.js";
7
8
  import { useCreateOutlinesAdapter } from "../interactions/actions/outlines/useCreateOutlinesAdapter.js";
8
- import { DEFAULT_DECORATION_METRICS, DEFAULT_TEXT_FILL as DEFAULT_TEXT_FILL$1, DEFAULT_TEXT_STYLE, MARKDOWN_RUN_GRAMMAR, QUAD_STRIDE, SCRIPT_METRICS, SMALL_CAPS_SCALE, applyStyleToRange, cachedLayoutRuns, cachedPaintRuns, caretIndexAt as caretIndexAt$1, createMarkdownRenderer, decorationMetrics, defaultLabelTextRenderer, dropRuns, effectiveRangeStyle, fitTextPose, fontString, halfLeadingFor, isBoldWeight, isSmallCapsLetter, isTextData as isTextData$1, layoutMarkdown, layoutRuns, layoutTextPose, markdownToRuns, measureText, measureTextBounds as measureTextBounds$1, measuredWidth, nodeHasFlag, numericWeight, paintRuns, paragraphDirection, patchRangeStyle, pointInTextPose as pointInTextPose$1, rangeWeight, registerBidi, registerShaper, renderLabel, resolveAlign, resolveRunFace, resolveRuns, resolveTextStyle, runsToMarkdown, runsToPlainText as runsToPlainText$1, scriptMetrics, scriptMetricsFor, setFlagOverRange, smallCapsScale, smallCapsScaleFor, smallCapsText, styleAtRange, textLineBoxes as textLineBoxes$1, textPoseLayoutInput, toRuns, transformRunTexts, unboldPatch, verticalAlignOffset } from "@weasel-js/text";
9
+ import { useNotices } from "../interactions/actions/useNotices.js";
10
+ import { DEFAULT_DECORATION_METRICS, DEFAULT_TEXT_FILL as DEFAULT_TEXT_FILL$1, DEFAULT_TEXT_STYLE, MARKDOWN_RUN_GRAMMAR, QUAD_STRIDE, SCRIPT_METRICS, SMALL_CAPS_SCALE, applyStyleToRange, cachedLayoutRuns, cachedPaintRuns, caretIndexAt as caretIndexAt$1, clearRuns, createMarkdownRenderer, decorationMetrics, defaultLabelTextRenderer, dropRuns, effectiveRangeStyle, fitTextPose, fontString, halfLeadingFor, isBoldWeight, isSmallCapsLetter, isTextData as isTextData$1, layoutMarkdown, layoutRuns, layoutTextPose, markdownToRuns, measureText, measureTextBounds as measureTextBounds$1, measuredWidth, nodeHasFlag, numericWeight, paintRuns, paragraphDirection, patchRangeStyle, pointInTextPose as pointInTextPose$1, rangeWeight, registerBidi, registerShaper, renderLabel, resolveAlign, resolveRunFace, resolveRuns, resolveRunsInto, resolveTextStyle, runsToMarkdown, runsToPlainText as runsToPlainText$1, scriptMetrics, scriptMetricsFor, setFlagOverRange, smallCapsScale, smallCapsScaleFor, smallCapsText, styleAtRange, textLineBoxes as textLineBoxes$1, textPoseLayoutInput, toRuns, transformRunTexts, unboldPatch, verticalAlignOffset } from "@weasel-js/text";
9
11
 
10
- export { DEFAULT_DECORATION_METRICS, DEFAULT_TEXT_FILL$1 as DEFAULT_TEXT_FILL, DEFAULT_TEXT_STYLE, MARKDOWN_RUN_GRAMMAR, QUAD_STRIDE, SCRIPT_METRICS, SMALL_CAPS_SCALE, TEXT_EDIT_FONT_HOLD, TextOutlinesError$1 as TextOutlinesError, applyCreateOutlines, applyOutlineStroke, applyStyleToRange, cachedLayoutRuns, cachedPaintRuns, caretIndexAt$1 as caretIndexAt, charOffsetToDomPosition, createMarkdownRenderer, createTextLayer, decorationMetrics, defaultLabelTextRenderer, domPositionToCharOffset, domToRuns, dropRuns, effectiveRangeStyle, fitTextPose, fontString, halfLeadingFor, isBoldWeight, isSmallCapsLetter, isTextData$1 as isTextData, layoutMarkdown, layoutRuns, layoutTextPose, loadTextOutlines$1 as loadTextOutlines, markdownToRuns, measureText, measureTextBounds$1 as measureTextBounds, measuredWidth, nodeHasFlag, numericWeight, paintRuns, paragraphDirection, patchRangeStyle, pointInTextPose$1 as pointInTextPose, rangeWeight, registerBidi, registerShaper, renderLabel, resolveAlign, resolveRunFace, resolveRuns, resolveTextStyle, runsToDom, runsToMarkdown, runsToPlainText$1 as runsToPlainText, scriptMetrics, scriptMetricsFor, setFlagOverRange, smallCapsScale, smallCapsScaleFor, smallCapsText, strokeRegion, styleAtRange, textCommand, textCommandFromPose, textCommandFromRuns, textLineBoxes$1 as textLineBoxes, textPoseLayoutInput, textToPath$1 as textToPath, textToPathsByPaint$1 as textToPathsByPaint, toRuns, transformRunTexts, unboldPatch, useCreateOutlinesAdapter, useSceneTextEdit, useTextEdit, verticalAlignOffset };
12
+ export { DEFAULT_DECORATION_METRICS, DEFAULT_TEXT_FILL$1 as DEFAULT_TEXT_FILL, DEFAULT_TEXT_STYLE, MARKDOWN_RUN_GRAMMAR, QUAD_STRIDE, SCRIPT_METRICS, SMALL_CAPS_SCALE, TEXT_EDIT_FONT_HOLD, TextOutlinesError$1 as TextOutlinesError, applyCreateOutlines, applyOutlineStroke, applyStyleToRange, cachedLayoutRuns, cachedPaintRuns, caretIndexAt$1 as caretIndexAt, charOffsetToDomPosition, clearRuns, createMarkdownRenderer, createTextLayer, decorationMetrics, defaultLabelTextRenderer, domPositionToCharOffset, domToRuns, dropRuns, effectiveRangeStyle, fitTextPose, fontString, halfLeadingFor, isBoldWeight, isSmallCapsLetter, isTextData$1 as isTextData, layoutMarkdown, layoutRuns, layoutTextPose, loadTextOutlines$1 as loadTextOutlines, markdownToRuns, measureText, measureTextBounds$1 as measureTextBounds, measuredWidth, nodeHasFlag, numericWeight, paintRuns, paragraphDirection, patchRangeStyle, pointInTextPose$1 as pointInTextPose, rangeWeight, registerBidi, registerShaper, renderLabel, resolveAlign, resolveRunFace, resolveRuns, resolveRunsInto, resolveTextStyle, runsToDom, runsToMarkdown, runsToPlainText$1 as runsToPlainText, scriptMetrics, scriptMetricsFor, setFlagOverRange, smallCapsScale, smallCapsScaleFor, smallCapsText, strokeRegion, styleAtRange, textCommand, textCommandFromPose, textCommandFromRuns, textCommandFromRunsInto, textLineBoxes$1 as textLineBoxes, textPoseLayoutInput, textToPath$1 as textToPath, textToPathsByPaint$1 as textToPathsByPaint, toRuns, transformRunTexts, unboldPatch, useCreateOutlinesAdapter, useNotices, useSceneTextEdit, useTextEdit, verticalAlignOffset, warnTextOutlines, warnUser };
@@ -62,7 +62,11 @@ function CanvasInner(props, ref) {
62
62
  dpr: props.dpr,
63
63
  redrawOn: props.redrawOn,
64
64
  shaders: props.shaders,
65
- onCommit: "redraw"
65
+ onCommit: "redraw",
66
+ size: {
67
+ width,
68
+ height
69
+ }
66
70
  });
67
71
  const { getPaintedVersion, markPainted } = usePaintedVersion(props.contentVersion);
68
72
  const { extrasRef, extrasVersion, registerLayer, hitTestExtrasIn } = useExtraLayers(gateRef);
@@ -1 +1 @@
1
- {"version":3,"file":"Canvas.js","names":[],"sources":["../../src/canvas/Canvas.tsx"],"sourcesContent":["/**\n * Low-level WebGL surface + viewport primitive. Composes layers into a single GL render pass,\n * applies a view transform, and delivers hover to the layers that ask for it. It routes no\n * gesture: `<SceneCanvas>` mounts the gesture dispatcher on this same element. Canvas owns NO\n * scene-shaped state — selection, picking, kind registry, scene-aware overlays all live in\n * `<SceneCanvas>`, which wraps it.\n *\n * The `layers` prop is a map keyed by slot name, every slot already a layer. Standard slots\n * render at a canonical position; custom entries (any other key, value carrying `.layer`) insert\n * at `after`/`before` an existing slot, defaulting to the top.\n *\n * @internal\n * @deprecated Bare `<Canvas>` is not a supported consumer surface.\n * Use `<SceneCanvas>` instead.\n */\n\nimport { forwardRef, useCallback, useEffect, useInsertionEffect, useLayoutEffect, useRef } from 'react';\nimport type React from 'react';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport { registerMountedCanvas } from './mountedCanvases';\nimport { useViewHelpers } from './useViewHelpers';\nimport { useViewLayerGate } from './useViewLayerGate';\nimport { useSurfaceInput } from './useSurfaceInput';\nimport { useOptionalViewRegistry } from './viewRegistry';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport type { CanvasHelpers } from './useViewHelpers';\nimport type { CanvasProps } from './canvasProps';\nimport { useLatest } from '@weasel-js/react';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport { useSurfaceSize } from './useSurfaceSize';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { AUTO_POSE_DESCRIPTOR } from 'core/geometry/autoPoseDescriptor';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { useDebugSink } from '../debug/useDebugSink';\nimport { useToolCursor } from './useToolCursor';\nimport { useCanvasElements } from './useCanvasElements';\nimport { alwaysVisible, useExtraLayers } from './useExtraLayers';\nimport { usePaintedCursor } from './usePaintedCursor';\nimport { useCanvasHandle } from './useCanvasHandle';\nimport { useComposedLayers, useSlotLayers } from './useLayerStack';\nimport { useViewRegistrySurface } from './useViewRegistrySurface';\nimport { useCanvasPaint, usePaintedVersion } from './useCanvasPaint';\nimport { layerHover } from './layerHover';\nimport { useClientToWorld } from './useClientToWorld';\n\nexport type { CanvasProps, CanvasRetainOptions } from './canvasProps';\n\nconst NO_SELECTION: SelectionApi['current'] = [];\n\nfunction CanvasInner<TPose>(\n props: CanvasProps<TPose>,\n ref: React.ForwardedRef<CanvasExtensionApi>,\n) {\n const {\n paintInto, inputElement, tools, viewState, style, getIsVisible, layerVisibility, layerOrder,\n helpersRef, debugSinkRef,\n poseDescriptor: geometry = AUTO_POSE_DESCRIPTOR as unknown as PoseDescriptor<TPose>,\n } = props;\n\n const { sink: debugSink, overlay: debugOverlay, frameStats, getDebug } = useDebugSink(props.debug);\n const elements = useCanvasElements(paintInto, inputElement);\n const { canvasRef, ownCanvasRef, detached } = elements;\n const { width, height } = useSurfaceSize(props, ownCanvasRef);\n\n // Read by `hitTestExtras`, which is built once and must see live values.\n const helpersForLayersRef = useRef<CanvasHelpers<TPose> | null>(null);\n const dimsRef = useLatest({ width, height });\n // Which layers reach the screen, and which chrome within them: asked by the\n // paint and by every hit-test.\n const gateRef = useLatest({ getIsVisible, layerVisibility, layerOrder });\n\n // The frame loop paints; a committed render only marks the surface dirty, so\n // no prop can reach the paint without repainting it. The thunk defers to\n // `useCanvasPaint` below, which needs inputs this render has not computed yet.\n const paintRef = useRef<() => boolean>(() => false);\n const { lease, requestRedraw, subscribeFrame, subscribeBeforePaint, subscribeResume } = useCanvasSurface(\n useCallback(() => paintRef.current(), []),\n { syncPaint: props.syncPaint ?? false, target: canvasRef, dpr: props.dpr, redrawOn: props.redrawOn, shaders: props.shaders, onCommit: 'redraw' },\n );\n const { getPaintedVersion, markPainted } = usePaintedVersion(props.contentVersion);\n const { extrasRef, extrasVersion, registerLayer, hitTestExtrasIn } = useExtraLayers(gateRef);\n\n const {\n viewRef, setView, getView, subscribeView,\n adoptControlled, announceControlled, clearSubscribers,\n } = viewState;\n\n const toWorld = useClientToWorld(canvasRef, props.clientToWorld, viewRef);\n\n useLayoutEffect(() => {\n const element = canvasRef.current;\n if (!element) return;\n return registerMountedCanvas({ element, getView });\n }, [canvasRef, detached, inputElement, getView]);\n\n const { paintedCursor, paintedCursorLayer, cursorSink } = usePaintedCursor(canvasRef, requestRedraw);\n\n const frame = { viewRef, dimsRef, helpersRef: helpersForLayersRef };\n useCanvasHandle(ref, { ...elements, inputElement, paintCanvas: paintInto?.canvas }, frame, {\n hitTestExtrasIn, clientToWorld: toWorld, requestRedraw, subscribeFrame, subscribeBeforePaint,\n subscribeResume, registerLayer, getView, setView, subscribeView,\n getPaintedVersion, paintedCursor, cursorSink, getDebug,\n });\n\n const viewRegistry = useOptionalViewRegistry();\n\n // One view's overlay-aware state. A hook, so N views are N components each\n // calling it once — not a loop in this body.\n const layers = useSlotLayers(props.layers, tools, props.backgroundFill, props.decorationLayer);\n const { helpers: viewHelpers } = useViewHelpers<TPose>({\n adapter: props.adapter, geometry, boundsOf: props.boundsOf, boundsOfPose: props.boundsOfPose,\n nodes: props.nodes, gestureSource: props.gestureSource, previewPoseExtra: props.previewPoseExtra,\n getScale: () => viewRef.current.scale,\n selection: () => props.selection?.current ?? NO_SELECTION,\n getIsVisible: () => gateRef.current.getIsVisible?.() ?? alwaysVisible,\n layerIsPainted: useViewLayerGate(layerVisibility, layerOrder, () => layers),\n });\n const helpersForLayers: CanvasHelpers<TPose> = { ...viewHelpers, getDebug: () => debugSink, viewId: null };\n\n useViewRegistrySurface(viewRegistry, layers, frame, { requestRedraw, hitTestExtrasIn, clientToWorld: toWorld, setView: viewState.setViewFromInput });\n const layersWithDebug = useComposedLayers(layers, {\n viewRegistry, debugOverlay, extrasRef, extrasVersion, cursorLayer: paintedCursorLayer,\n }, requestRedraw);\n\n // Everything the paint, hit-testing and the view registry read that a React\n // render owns. `useLatest` and the insertion effect below publish committed\n // renders only, ahead of every layout effect in the commit, any of which may\n // ask for a sync paint.\n const paintInputsRef = useLatest({\n layers: layersWithDebug, width, height, debugSink, frameStats,\n dpr: props.dpr, layerGroups: props.layerGroups, shaders: props.shaders,\n flattenTolerance: props.flattenTolerance, retain: props.retain, imageMinification: props.imageMinification,\n });\n useInsertionEffect(() => {\n adoptControlled();\n helpersForLayersRef.current = helpersForLayers;\n if (helpersRef) helpersRef.current = helpersForLayers;\n if (debugSinkRef) debugSinkRef.current = debugSink;\n });\n useLayoutEffect(() => {\n announceControlled();\n });\n\n useCanvasPaint(paintRef, lease, elements, { ...frame, inputsRef: paintInputsRef, gateRef }, markPainted, requestRedraw);\n useEffect(() => clearSubscribers, [clearSubscribers]);\n\n useToolCursor(cursorSink, tools, detached ? inputElement : null, style?.cursor);\n\n useSurfaceInput(canvasRef, {\n focusOnPress: props.autoFocusOnPointerDown ?? true,\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n ...layerHover(layersWithDebug, {\n viewRef, toWorld, layerVisibility, layerOrder, dims: { width, height },\n }),\n });\n\n if (detached) return null;\n\n return (\n <SurfaceCanvas\n ref={elements.setOwnCanvas}\n width={props.width}\n height={props.height}\n tabIndex={props.tabIndex ?? 0} aria-label={props['aria-label']}\n className={props.className} style={style}\n />\n );\n}\n\n/** Forward-ref'd `<canvas>` wrapper. Generic over the pose type, inferred from the\n * `adapter` prop. */\nexport const Canvas = forwardRef(CanvasInner) as <TPose = unknown>(\n props: CanvasProps<TPose> & { ref?: React.ForwardedRef<CanvasExtensionApi> },\n) => ReturnType<typeof CanvasInner>;\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,IAAM,eAAwC,CAAC;AAE/C,SAAS,YACP,OACA,KACA;CACA,MAAM,EACJ,WAAW,cAAc,OAAO,WAAW,OAAO,cAAc,iBAAiB,YACjF,YAAY,cACZ,gBAAgB,WAAW,yBACzB;CAEJ,MAAM,EAAE,MAAM,WAAW,SAAS,cAAc,YAAY,aAAa,aAAa,MAAM,KAAK;CACjG,MAAM,WAAW,kBAAkB,WA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MAAM;EACd,GAAG,WAAW,iBAAiB;GAC7B;GAAS;GAAS;GAAiB;GAAY,MAAM;IAAE;IAAO;GAAO;EACvE,CAAC;CACH,CAAC;CAED,IAAI,UAAU,OAAO;CAErB,OACE,oBAAC,eAAD;EACE,KAAK,SAAS;EACd,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,UAAU,MAAM,YAAY;EAAG,cAAY,MAAM;EACjD,WAAW,MAAM;EAAkB;CACpC,CAAA;AAEL;;;AAIA,IAAa,SAAS,WAAW,WAAW"}
1
+ {"version":3,"file":"Canvas.js","names":[],"sources":["../../src/canvas/Canvas.tsx"],"sourcesContent":["/**\n * Low-level WebGL surface + viewport primitive. Composes layers into a single GL render pass,\n * applies a view transform, and delivers hover to the layers that ask for it. It routes no\n * gesture: `<SceneCanvas>` mounts the gesture dispatcher on this same element. Canvas owns NO\n * scene-shaped state — selection, picking, kind registry, scene-aware overlays all live in\n * `<SceneCanvas>`, which wraps it.\n *\n * The `layers` prop is a map keyed by slot name, every slot already a layer. Standard slots\n * render at a canonical position; custom entries (any other key, value carrying `.layer`) insert\n * at `after`/`before` an existing slot, defaulting to the top.\n *\n * @internal\n * @deprecated Bare `<Canvas>` is not a supported consumer surface.\n * Use `<SceneCanvas>` instead.\n */\n\nimport { forwardRef, useCallback, useEffect, useInsertionEffect, useLayoutEffect, useRef } from 'react';\nimport type React from 'react';\nimport type { CanvasExtensionApi } from './canvasExtension';\nimport { registerMountedCanvas } from './mountedCanvases';\nimport { useViewHelpers } from './useViewHelpers';\nimport { useViewLayerGate } from './useViewLayerGate';\nimport { useSurfaceInput } from './useSurfaceInput';\nimport { useOptionalViewRegistry } from './viewRegistry';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport type { CanvasHelpers } from './useViewHelpers';\nimport type { CanvasProps } from './canvasProps';\nimport { useLatest } from '@weasel-js/react';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport { useSurfaceSize } from './useSurfaceSize';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport { AUTO_POSE_DESCRIPTOR } from 'core/geometry/autoPoseDescriptor';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport { useDebugSink } from '../debug/useDebugSink';\nimport { useToolCursor } from './useToolCursor';\nimport { useCanvasElements } from './useCanvasElements';\nimport { alwaysVisible, useExtraLayers } from './useExtraLayers';\nimport { usePaintedCursor } from './usePaintedCursor';\nimport { useCanvasHandle } from './useCanvasHandle';\nimport { useComposedLayers, useSlotLayers } from './useLayerStack';\nimport { useViewRegistrySurface } from './useViewRegistrySurface';\nimport { useCanvasPaint, usePaintedVersion } from './useCanvasPaint';\nimport { layerHover } from './layerHover';\nimport { useClientToWorld } from './useClientToWorld';\n\nexport type { CanvasProps, CanvasRetainOptions } from './canvasProps';\n\nconst NO_SELECTION: SelectionApi['current'] = [];\n\nfunction CanvasInner<TPose>(\n props: CanvasProps<TPose>,\n ref: React.ForwardedRef<CanvasExtensionApi>,\n) {\n const {\n paintInto, inputElement, tools, viewState, style, getIsVisible, layerVisibility, layerOrder,\n helpersRef, debugSinkRef,\n poseDescriptor: geometry = AUTO_POSE_DESCRIPTOR as unknown as PoseDescriptor<TPose>,\n } = props;\n\n const { sink: debugSink, overlay: debugOverlay, frameStats, getDebug } = useDebugSink(props.debug);\n const elements = useCanvasElements(paintInto, inputElement);\n const { canvasRef, ownCanvasRef, detached } = elements;\n const { width, height } = useSurfaceSize(props, ownCanvasRef);\n\n // Read by `hitTestExtras`, which is built once and must see live values.\n const helpersForLayersRef = useRef<CanvasHelpers<TPose> | null>(null);\n const dimsRef = useLatest({ width, height });\n // Which layers reach the screen, and which chrome within them: asked by the\n // paint and by every hit-test.\n const gateRef = useLatest({ getIsVisible, layerVisibility, layerOrder });\n\n // The frame loop paints; a committed render only marks the surface dirty, so\n // no prop can reach the paint without repainting it. The thunk defers to\n // `useCanvasPaint` below, which needs inputs this render has not computed yet.\n const paintRef = useRef<() => boolean>(() => false);\n const { lease, requestRedraw, subscribeFrame, subscribeBeforePaint, subscribeResume } = useCanvasSurface(\n useCallback(() => paintRef.current(), []),\n { syncPaint: props.syncPaint ?? false, target: canvasRef, dpr: props.dpr, redrawOn: props.redrawOn, shaders: props.shaders, onCommit: 'redraw', size: { width, height } },\n );\n const { getPaintedVersion, markPainted } = usePaintedVersion(props.contentVersion);\n const { extrasRef, extrasVersion, registerLayer, hitTestExtrasIn } = useExtraLayers(gateRef);\n\n const {\n viewRef, setView, getView, subscribeView,\n adoptControlled, announceControlled, clearSubscribers,\n } = viewState;\n\n const toWorld = useClientToWorld(canvasRef, props.clientToWorld, viewRef);\n\n useLayoutEffect(() => {\n const element = canvasRef.current;\n if (!element) return;\n return registerMountedCanvas({ element, getView });\n }, [canvasRef, detached, inputElement, getView]);\n\n const { paintedCursor, paintedCursorLayer, cursorSink } = usePaintedCursor(canvasRef, requestRedraw);\n\n const frame = { viewRef, dimsRef, helpersRef: helpersForLayersRef };\n useCanvasHandle(ref, { ...elements, inputElement, paintCanvas: paintInto?.canvas }, frame, {\n hitTestExtrasIn, clientToWorld: toWorld, requestRedraw, subscribeFrame, subscribeBeforePaint,\n subscribeResume, registerLayer, getView, setView, subscribeView,\n getPaintedVersion, paintedCursor, cursorSink, getDebug,\n });\n\n const viewRegistry = useOptionalViewRegistry();\n\n // One view's overlay-aware state. A hook, so N views are N components each\n // calling it once — not a loop in this body.\n const layers = useSlotLayers(props.layers, tools, props.backgroundFill, props.decorationLayer);\n const { helpers: viewHelpers } = useViewHelpers<TPose>({\n adapter: props.adapter, geometry, boundsOf: props.boundsOf, boundsOfPose: props.boundsOfPose,\n nodes: props.nodes, gestureSource: props.gestureSource, previewPoseExtra: props.previewPoseExtra,\n getScale: () => viewRef.current.scale,\n selection: () => props.selection?.current ?? NO_SELECTION,\n getIsVisible: () => gateRef.current.getIsVisible?.() ?? alwaysVisible,\n layerIsPainted: useViewLayerGate(layerVisibility, layerOrder, () => layers),\n });\n const helpersForLayers: CanvasHelpers<TPose> = { ...viewHelpers, getDebug: () => debugSink, viewId: null };\n\n useViewRegistrySurface(viewRegistry, layers, frame, { requestRedraw, hitTestExtrasIn, clientToWorld: toWorld, setView: viewState.setViewFromInput });\n const layersWithDebug = useComposedLayers(layers, {\n viewRegistry, debugOverlay, extrasRef, extrasVersion, cursorLayer: paintedCursorLayer,\n }, requestRedraw);\n\n // Everything the paint, hit-testing and the view registry read that a React\n // render owns. `useLatest` and the insertion effect below publish committed\n // renders only, ahead of every layout effect in the commit, any of which may\n // ask for a sync paint.\n const paintInputsRef = useLatest({\n layers: layersWithDebug, width, height, debugSink, frameStats,\n dpr: props.dpr, layerGroups: props.layerGroups, shaders: props.shaders,\n flattenTolerance: props.flattenTolerance, retain: props.retain, imageMinification: props.imageMinification,\n });\n useInsertionEffect(() => {\n adoptControlled();\n helpersForLayersRef.current = helpersForLayers;\n if (helpersRef) helpersRef.current = helpersForLayers;\n if (debugSinkRef) debugSinkRef.current = debugSink;\n });\n useLayoutEffect(() => {\n announceControlled();\n });\n\n useCanvasPaint(paintRef, lease, elements, { ...frame, inputsRef: paintInputsRef, gateRef }, markPainted, requestRedraw);\n useEffect(() => clearSubscribers, [clearSubscribers]);\n\n useToolCursor(cursorSink, tools, detached ? inputElement : null, style?.cursor);\n\n useSurfaceInput(canvasRef, {\n focusOnPress: props.autoFocusOnPointerDown ?? true,\n onFocus: props.onFocus,\n onBlur: props.onBlur,\n ...layerHover(layersWithDebug, {\n viewRef, toWorld, layerVisibility, layerOrder, dims: { width, height },\n }),\n });\n\n if (detached) return null;\n\n return (\n <SurfaceCanvas\n ref={elements.setOwnCanvas}\n width={props.width}\n height={props.height}\n tabIndex={props.tabIndex ?? 0} aria-label={props['aria-label']}\n className={props.className} style={style}\n />\n );\n}\n\n/** Forward-ref'd `<canvas>` wrapper. Generic over the pose type, inferred from the\n * `adapter` prop. */\nexport const Canvas = forwardRef(CanvasInner) as <TPose = unknown>(\n props: CanvasProps<TPose> & { ref?: React.ForwardedRef<CanvasExtensionApi> },\n) => ReturnType<typ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Y,WAAW,UAAU;EACrC,IAAI,cAAc,aAAa,UAAU;CAC3C,CAAC;CACD,sBAAsB;EACpB,mBAAmB;CACrB,CAAC;CAED,eAAe,UAAU,OAAO,UAAU;EAAE,GAAG;EAAO,WAAW;EAAgB;CAAQ,GAAG,aAAa,aAAa;CACtH,gBAAgB,kBAAkB,CAAC,gBAAgB,CAAC;CAEpD,cAAc,YAAY,OAAO,WAAW,eAAe,MAAM,OAAO,MAAM;CAE9E,gBAAgB,WAAW;EACzB,cAAc,MAAM,0BAA0B;EAC9C,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,GAAG,WAAW,iBAAiB;GAC7B;GAAS;GAAS;GAAiB;GAAY,MAAM;IAAE;IAAO;GAAO;EACvE,CAAC;CACH,CAAC;CAED,IAAI,UAAU,OAAO;CAErB,OACE,oBAAC,eAAD;EACE,KAAK,SAAS;EACd,OAAO,MAAM;EACb,QAAQ,MAAM;EACd,UAAU,MAAM,YAAY;EAAG,cAAY,MAAM;EACjD,WAAW,MAAM;EAAkB;CACpC,CAAA;AAEL;;;AAIA,IAAa,SAAS,WAAW,WAAW"}
@@ -68,7 +68,11 @@ function DrawCanvas(props) {
68
68
  target: canvasElRef,
69
69
  dpr,
70
70
  redrawOn,
71
- onCommit: "paint"
71
+ onCommit: "paint",
72
+ size: {
73
+ width,
74
+ height
75
+ }
72
76
  });
73
77
  return /* @__PURE__ */ jsx(SurfaceCanvas, {
74
78
  ref: setRefs,
@@ -1 +1 @@
1
- {"version":3,"file":"DrawCanvas.js","names":[],"sources":["../../src/canvas/DrawCanvas.tsx"],"sourcesContent":["/**\n * `<DrawCanvas>` — a sized, DPR-correct WebGL2 surface that paints a list of\n * draw commands, with no scene, tools or dispatcher behind it.\n *\n * It paints through the same surface hook as `<SceneViewCanvas>`\n * (`useCanvasSurface`), whose frame loop stops while the canvas is off screen\n * or the tab is hidden. Like `<SceneViewCanvas>` it attaches no event\n * listeners. Its size is `width` × `height` unless a `className` rule sizes\n * the element; the drawing buffer stays `width` × `height` either way. Given\n * neither, it fills its parent.\n */\nimport { useCallback, useRef } from 'react';\nimport type { Ref } from 'react';\nimport { assignRef } from '@weasel-js/react';\nimport type { Paint } from '@weasel-js/paint';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport { useSurfaceSize, type SurfaceSizeProps } from './useSurfaceSize';\nimport type { CanvasRendererLease } from './canvasRenderer';\nimport { viewToMat3 } from '@weasel-js/geom';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport type { RedrawSource } from '../core/layers/render';\nimport { backgroundFillCommands } from '../core/layers/backgroundFill';\nimport { normalizeView, type View } from '../core/viewport/view';\n\n/** What a `<DrawCanvas>` paints: a command list, or a function returning one\n * that is called on every paint with the surface's CSS-pixel size. */\nexport type DrawCanvasDraw =\n | readonly DrawCommand[]\n | ((size: { width: number; height: number }) => readonly DrawCommand[]);\n\n/** Props for `<DrawCanvas>`. */\nexport interface DrawCanvasProps extends SurfaceSizeProps {\n /** The commands to paint, in the coordinate space `view` maps to the\n * screen — CSS pixels when `view` is omitted. A new array repaints on the\n * next frame. A function is read at paint time, so state it reads outside\n * React repaints when one of `redrawOn`'s sources notifies. */\n draw: DrawCanvasDraw;\n /** Camera over `draw`'s commands. Defaults to the identity view. */\n view?: View;\n /** Fills the whole surface beneath `draw`, in screen space. The canvas is\n * transparent without it. */\n background?: Paint;\n /** External state a `draw` function reads. Each source is subscribed while\n * mounted and repaints the canvas when it notifies. */\n redrawOn?: readonly RedrawSource[];\n /** Device-pixel ratio. Defaults to `window.devicePixelRatio`, read per\n * paint. */\n dpr?: number;\n /** CSS class for the `<canvas>` element. */\n className?: string;\n /** Receives the underlying `<canvas>`, for pointer listeners or `toBlob`. */\n canvasRef?: Ref<HTMLCanvasElement>;\n}\n\nconst IDENTITY_VIEW: View = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n\n/**\n * Paint draw commands onto a canvas of its own. For a surface that only draws —\n * a package demo, a swatch, a preview — where a `<SceneCanvas>` would bring a\n * scene, tools and an input dispatcher that nothing uses.\n */\nexport function DrawCanvas(props: DrawCanvasProps) {\n const { draw, background, redrawOn, dpr, className, canvasRef } = props;\n const view = props.view ? normalizeView(props.view) : IDENTITY_VIEW;\n\n const canvasElRef = useRef<HTMLCanvasElement | null>(null);\n const setRefs = useCallback((el: HTMLCanvasElement | null) => {\n canvasElRef.current = el;\n assignRef(canvasRef, el);\n }, [canvasRef]);\n const { width, height } = useSurfaceSize(props, canvasElRef);\n\n const paint = (lease: CanvasRendererLease): boolean => {\n const el = canvasElRef.current;\n if (!el || width === 0 || height === 0) return false;\n const content = typeof draw === 'function' ? draw({ width, height }) : draw;\n const commands: DrawCommand[] = background ? backgroundFillCommands(background, { width, height }) : [];\n commands.push({ kind: 'group', transform: viewToMat3(view), children: [...content] });\n return lease.paint(el, commands, view, { width, height, dpr });\n };\n useCanvasSurface(paint, { target: canvasElRef, dpr, redrawOn, onCommit: 'paint' });\n\n return <SurfaceCanvas ref={setRefs} width={props.width} height={props.height} className={className} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAM,gBAAsB;CAAE,GAAG;CAAG,GAAG;CAAG,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE;;;;;;AAOhE,SAAgB,WAAW,OAAwB;CACjD,MAAM,EAAE,MAAM,YAAY,UAAU,KAAK,WAAW,cAAc;CAClE,MAAM,OAAO,MAAM,OAAO,cAAc,MAAM,IAAI,IAAI;CAEtD,MAAM,cAAc,OAAiC,IAAI;CACzD,MAAM,UAAU,aAAa,OAAiC;EAC5D,YAAY,UAAU;EACtB,UAAU,WAAW,EAAE;CACzB,GAAG,CAAC,SAAS,CAAC;CACd,MAAM,EAAE,OAAO,WAAW,eAAe,OAAO,WAAW;CAE3D,MAAM,SAAS,UAAwC;EACrD,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,MAAM,UAAU,KAAK,WAAW,GAAG,OAAO;EAC/C,MAAM,UAAU,OAAO,SAAS,aAAa,KAAK;GAAE;GAAO;EAAO,CAAC,IAAI;EACvE,MAAM,WAA0B,aAAa,uBAAuB,YAAY;GAAE;GAAO;EAAO,CAAC,IAAI,CAAC;EACtG,SAAS,KAAK;GAAE,MAAM;GAAS,WAAW,WAAW,IAAI;GAAG,UAAU,CAAC,GAAG,OAAO;EAAE,CAAC;EACpF,OAAO,MAAM,MAAM,IAAI,UAAU,MAAM;GAAE;GAAO;GAAQ;EAAI,CAAC;CAC/D;CACA,iBAAiB,OAAO;EAAE,QAAQ;EAAa;EAAK;EAAU,UAAU;CAAQ,CAAC;CAEjF,OAAO,oBAAC,eAAD;EAAe,KAAK;EAAS,OAAO,MAAM;EAAO,QAAQ,MAAM;EAAmB;CAAY,CAAA;AACvG"}
1
+ {"version":3,"file":"DrawCanvas.js","names":[],"sources":["../../src/canvas/DrawCanvas.tsx"],"sourcesContent":["/**\n * `<DrawCanvas>` — a sized, DPR-correct WebGL2 surface that paints a list of\n * draw commands, with no scene, tools or dispatcher behind it.\n *\n * It paints through the same surface hook as `<SceneViewCanvas>`\n * (`useCanvasSurface`), whose frame loop stops while the canvas is off screen\n * or the tab is hidden. Like `<SceneViewCanvas>` it attaches no event\n * listeners. Its size is `width` × `height` unless a `className` rule sizes\n * the element; the drawing buffer stays `width` × `height` either way. Given\n * neither, it fills its parent.\n */\nimport { useCallback, useRef } from 'react';\nimport type { Ref } from 'react';\nimport { assignRef } from '@weasel-js/react';\nimport type { Paint } from '@weasel-js/paint';\nimport { useCanvasSurface } from './useCanvasSurface';\nimport { SurfaceCanvas } from './SurfaceCanvas';\nimport { useSurfaceSize, type SurfaceSizeProps } from './useSurfaceSize';\nimport type { CanvasRendererLease } from './canvasRenderer';\nimport { viewToMat3 } from '@weasel-js/geom';\nimport type { DrawCommand } from '@weasel-js/renderer';\nimport type { RedrawSource } from '../core/layers/render';\nimport { backgroundFillCommands } from '../core/layers/backgroundFill';\nimport { normalizeView, type View } from '../core/viewport/view';\n\n/** What a `<DrawCanvas>` paints: a command list, or a function returning one\n * that is called on every paint with the surface's CSS-pixel size. */\nexport type DrawCanvasDraw =\n | readonly DrawCommand[]\n | ((size: { width: number; height: number }) => readonly DrawCommand[]);\n\n/** Props for `<DrawCanvas>`. */\nexport interface DrawCanvasProps extends SurfaceSizeProps {\n /** The commands to paint, in the coordinate space `view` maps to the\n * screen — CSS pixels when `view` is omitted. A new array repaints on the\n * next frame. A function is read at paint time, so state it reads outside\n * React repaints when one of `redrawOn`'s sources notifies. */\n draw: DrawCanvasDraw;\n /** Camera over `draw`'s commands. Defaults to the identity view. */\n view?: View;\n /** Fills the whole surface beneath `draw`, in screen space. The canvas is\n * transparent without it. */\n background?: Paint;\n /** External state a `draw` function reads. Each source is subscribed while\n * mounted and repaints the canvas when it notifies. */\n redrawOn?: readonly RedrawSource[];\n /** Device-pixel ratio. Defaults to `window.devicePixelRatio`, read per\n * paint. */\n dpr?: number;\n /** CSS class for the `<canvas>` element. */\n className?: string;\n /** Receives the underlying `<canvas>`, for pointer listeners or `toBlob`. */\n canvasRef?: Ref<HTMLCanvasElement>;\n}\n\nconst IDENTITY_VIEW: View = { x: 0, y: 0, scale: { x: 1, y: 1 } };\n\n/**\n * Paint draw commands onto a canvas of its own. For a surface that only draws —\n * a package demo, a swatch, a preview — where a `<SceneCanvas>` would bring a\n * scene, tools and an input dispatcher that nothing uses.\n */\nexport function DrawCanvas(props: DrawCanvasProps) {\n const { draw, background, redrawOn, dpr, className, canvasRef } = props;\n const view = props.view ? normalizeView(props.view) : IDENTITY_VIEW;\n\n const canvasElRef = useRef<HTMLCanvasElement | null>(null);\n const setRefs = useCallback((el: HTMLCanvasElement | null) => {\n canvasElRef.current = el;\n assignRef(canvasRef, el);\n }, [canvasRef]);\n const { width, height } = useSurfaceSize(props, canvasElRef);\n\n const paint = (lease: CanvasRendererLease): boolean => {\n const el = canvasElRef.current;\n if (!el || width === 0 || height === 0) return false;\n const content = typeof draw === 'function' ? draw({ width, height }) : draw;\n const commands: DrawCommand[] = background ? backgroundFillCommands(background, { width, height }) : [];\n commands.push({ kind: 'group', transform: viewToMat3(view), children: [...content] });\n return lease.paint(el, commands, view, { width, height, dpr });\n };\n useCanvasSurface(paint, { target: canvasElRef, dpr, redrawOn, onCommit: 'paint', size: { width, height } });\n\n return <SurfaceCanvas ref={setRefs} width={props.width} height={props.height} className={className} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAM,gBAAsB;CAAE,GAAG;CAAG,GAAG;CAAG,OAAO;EAAE,GAAG;EAAG,GAAG;CAAE;AAAE;;;;;;AAOhE,SAAgB,WAAW,OAAwB;CACjD,MAAM,EAAE,MAAM,YAAY,UAAU,KAAK,WAAW,cAAc;CAClE,MAAM,OAAO,MAAM,OAAO,cAAc,MAAM,IAAI,IAAI;CAEtD,MAAM,cAAc,OAAiC,IAAI;CACzD,MAAM,UAAU,aAAa,OAAiC;EAC5D,YAAY,UAAU;EACtB,UAAU,WAAW,EAAE;CACzB,GAAG,CAAC,SAAS,CAAC;CACd,MAAM,EAAE,OAAO,WAAW,eAAe,OAAO,WAAW;CAE3D,MAAM,SAAS,UAAwC;EACrD,MAAM,KAAK,YAAY;EACvB,IAAI,CAAC,MAAM,UAAU,KAAK,WAAW,GAAG,OAAO;EAC/C,MAAM,UAAU,OAAO,SAAS,aAAa,KAAK;GAAE;GAAO;EAAO,CAAC,IAAI;EACvE,MAAM,WAA0B,aAAa,uBAAuB,YAAY;GAAE;GAAO;EAAO,CAAC,IAAI,CAAC;EACtG,SAAS,KAAK;GAAE,MAAM;GAAS,WAAW,WAAW,IAAI;GAAG,UAAU,CAAC,GAAG,OAAO;EAAE,CAAC;EACpF,OAAO,MAAM,MAAM,IAAI,UAAU,MAAM;GAAE;GAAO;GAAQ;EAAI,CAAC;CAC/D;CACA,iBAAiB,OAAO;EAAE,QAAQ;EAAa;EAAK;EAAU,UAAU;EAAS,MAAM;GAAE;GAAO;EAAO;CAAE,CAAC;CAE1G,OAAO,oBAAC,eAAD;EAAe,KAAK;EAAS,OAAO,MAAM;EAAO,QAAQ,MAAM;EAAmB;CAAY,CAAA;AACvG"}
@@ -3,6 +3,7 @@ import { dlog } from "../../debug/flag.js";
3
3
  import { usePointerPublisher } from "./PointerProviderIfRoot.js";
4
4
  import { SnapSourceRegistryContext } from "../../domains/snap/registry.js";
5
5
  import { useTestHook } from "../../test-hook/useTestHook.js";
6
+ import { useModeDefaultToolDepSource } from "../deps/modeDefaultTool.js";
6
7
  import { useHitObserver } from "../useHitObserver.js";
7
8
  import { GeometryProjectionRegistrar, ResizePolicyRegistrar } from "./poseRegistrars.js";
8
9
  import { useSceneGestureDispatcher } from "./useSceneGestureDispatcher.js";
@@ -12,6 +13,7 @@ import { useToolKeybindings } from "./useToolKeybindings.js";
12
13
  import { useContext, useEffect } from "react";
13
14
  import { useLatest } from "@weasel-js/react";
14
15
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
16
+ import { useDepSource } from "@weasel-js/routing/react";
15
17
 
16
18
  //#region src/canvas/SceneCanvas/SceneCanvasInput.tsx
17
19
  /**
@@ -32,6 +34,8 @@ function SceneCanvasInput(p) {
32
34
  return () => dlog("scene-canvas", "unmount");
33
35
  }, []);
34
36
  usePointerPublisher(canvas.elementRef, canvas.apiRef);
37
+ useDepSource("chromeRules", () => chrome.chromeRules);
38
+ useModeDefaultToolDepSource(props.modes, p.tools.tools);
35
39
  useSceneStandardActions({
36
40
  props,
37
41
  viewOn: p.viewOn,
@@ -1 +1 @@
1
- {"version":3,"file":"SceneCanvasInput.js","names":["_Fragment"],"sources":["../../../src/canvas/SceneCanvas/SceneCanvasInput.tsx"],"sourcesContent":["import type { ResizeHandleLayout } from 'interactions/actions/resize/cornerHandles';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport type { Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { RuleCtx } from 'domains/chrome-caps';\nimport type { Affordance } from 'affordances/types';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport { useContext, useEffect, type MutableRefObject, type RefObject } from 'react';\nimport { SnapSourceRegistryContext } from 'domains/snap/registry';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSource } from 'domains/snap/types';\nimport { dlog } from '../../debug/flag';\nimport { useDeviceProfile } from '../../core/device/useDeviceProfile';\nimport { useTestHook } from '../../test-hook/useTestHook';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport { useHitObserver } from '../useHitObserver';\nimport type { CanvasViewState } from '../useCanvasView';\nimport { GeometryProjectionRegistrar, ResizePolicyRegistrar } from './poseRegistrars';\nimport { usePointerPublisher } from './PointerProviderIfRoot';\nimport type { BridgeAdapter, SceneCanvasProps } from './props';\nimport type { NodeAtPoint } from './useNodeAtPoint';\nimport type { useSceneCanvasTools } from './useSceneCanvasTools';\nimport { useSceneGestureDispatcher } from './useSceneGestureDispatcher';\nimport { useCanvasDevtoolsRoot, type CanvasDevtools } from './useCanvasDevtoolsRoot';\nimport type { useScenePicking } from './useScenePicking';\nimport {\n useSceneStandardActions, type SceneStandardActionsInputs, type StandardActionsProps,\n} from './useSceneStandardActions';\nimport { useToolKeybindings } from './useToolKeybindings';\n\ntype Props = SceneCanvasProps<unknown, string, unknown>;\ntype Picking = ReturnType<typeof useScenePicking<unknown, string, unknown>>;\n\n/** The `<SceneCanvas>` props its input wiring reads. */\nexport type SceneCanvasInputOptions = StandardActionsProps & Pick<\n Props,\n | 'selectTool' | 'geometryProjection' | 'enableGestureDispatcher' | 'enableKeybindings'\n | 'claimKeys' | 'longPress' | 'modes' | 'versionCheck' | 'onClick' | 'onDoubleClick' | 'routing'\n>;\n\n/** What `<SceneCanvas>` hands {@link SceneCanvasInput}. */\nexport interface SceneCanvasInputProps {\n props: SceneCanvasInputOptions;\n scene: Scene<unknown, string, unknown>;\n selection: SelectionApi;\n descriptor: PoseDescriptor<unknown>;\n picking: Pick<\n Picking, 'pickEvery' | 'pickBest' | 'boundsOf' | 'planeOfNode' | 'kindOfNode' | 'doubleClickNames' | 'viewLayerGate' | 'alphaOf' | 'enteredGroup' | 'reachable'\n > & { adapter: BridgeAdapter };\n /** The node a hit resolves to, for the `onClick` / `onDoubleClick` observers. */\n nodeAtPointRef: MutableRefObject<NodeAtPoint | undefined>;\n tools: ReturnType<typeof useSceneCanvasTools>;\n viewOn: boolean;\n camera: { viewState: CanvasViewState; viewAnimation: SceneStandardActionsInputs['viewAnimation'] };\n dispatcher: Dispatcher;\n pathEdit: {\n state: SceneStandardActionsInputs['editAnchorsExternalState'];\n };\n chrome: { getIsVisible: () => (id: string) => boolean; getRuleCtx: () => RuleCtx | undefined };\n /** The selection overlay's rotate badge, and where the dispatcher reports the affordances\n * it hit-tests, for the slops overlay. */\n overlay: {\n rotationBadge: { distancePx: number; sizePx: number } | null | undefined;\n /** The resize-handle layout the overlay paints, so the hit-test grabs exactly those. */\n resizeHandles: ResizeHandleLayout;\n chromeAffordancesRef: MutableRefObject<readonly Affordance[]>;\n };\n canvas: {\n elementRef: MutableRefObject<HTMLElement | null>;\n apiRef: RefObject<CanvasExtensionApi | null>;\n ready: boolean;\n };\n ingestionClipboard: SceneStandardActionsInputs['ingestionClipboard'];\n ingestionHandlers: SceneStandardActionsInputs['ingestionHandlers'];\n /** The enabled presets' snap sources. */\n snapSources: readonly SnapSource[];\n /** The outcome store the canvas's readout layer draws. */\n snapStore: SnapOutcomeStore;\n devtools: CanvasDevtools;\n}\n\n/**\n * The canvas's input wiring: the pointer publisher, the standard actions and their deps, the\n * gesture dispatcher, and the tool keybindings, in that order, then the test hook.\n *\n * A component of its own, mounted ahead of `<SceneCanvas>`'s children, rather than hooks in the\n * canvas's body: dep sources and actions stack newest-live in effect order, and a parent's\n * effects run after its children's, so a child overriding a kit dep would lose to it.\n */\nexport function SceneCanvasInput(p: SceneCanvasInputProps) {\n const { props, scene, selection, picking, chrome, overlay, canvas } = p;\n const { viewState } = p.camera;\n const { selectTool, enableKeybindings = true } = props;\n const snapRegistry = useContext(SnapSourceRegistryContext);\n useEffect(() => {\n dlog('scene-canvas', 'mount');\n return () => dlog('scene-canvas', 'unmount');\n }, []);\n usePointerPublisher(canvas.elementRef, canvas.apiRef);\n useSceneStandardActions({\n props, viewOn: p.viewOn,\n selection, enteredGroup: picking.enteredGroup, scene, adapter: picking.adapter, standardActions: p.tools.standardActions,\n currentViewRef: viewState.viewRef, onViewChange: viewState.setViewFromInput,\n poseDescriptor: p.descriptor, dispatcher: p.dispatcher,\n pickEvery: picking.pickEvery, layerIsPainted: picking.viewLayerGate, alphaOf: picking.alphaOf, reachable: picking.reachable,\n viewAnimation: p.camera.viewAnimation, editAnchorsExternalState: p.pathEdit.state,\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef, ingestionClipboard: p.ingestionClipboard,\n ingestionHandlers: p.ingestionHandlers,\n snap: { sources: [...(props.snap?.sources ?? []), ...p.snapSources], registry: snapRegistry, store: p.snapStore },\n });\n\n // Rides the gesture dispatcher as an OBSERVER rather than an Action binding because the\n // prop is a notification, not a behavior: as a binding it would lose first-match-wins to\n // `enterPathEdit` on every body hit and silently stop firing.\n const onDoubleClick = useHitObserver(props.onDoubleClick, p.nodeAtPointRef);\n const onClick = useHitObserver(props.onClick, p.nodeAtPointRef);\n const selectionRef = useLatest(selection);\n const { targetScale } = useDeviceProfile();\n const { root, traces } = useCanvasDevtoolsRoot({\n scene, selection, viewState, tools: p.tools.tools, contributions: p.tools.contributions, routing: props.routing,\n element: canvas.elementRef, api: canvas.apiRef, devtools: p.devtools,\n });\n useSceneGestureDispatcher({\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef,\n tools: p.tools.tools, contributions: p.tools.contributions,\n enabled: props.enableGestureDispatcher ?? true, keyboard: enableKeybindings,\n claimKeys: props.claimKeys ?? false,\n selectionRef,\n boundsOf: picking.boundsOf, planeOfNode: picking.planeOfNode,\n pickEvery: picking.pickEvery, pickBest: picking.pickBest, kindOfNode: picking.kindOfNode,\n doubleClickNames: picking.doubleClickNames,\n viewRef: viewState.viewRef, dispatcher: p.dispatcher, traces,\n getIsVisibleForCanvas: chrome.getIsVisible, getRuleCtx: chrome.getRuleCtx,\n targetScale, handleHitRadius: overlay.resizeHandles.hitRadiusPx,\n edgeHandles: overlay.resizeHandles.edges,\n rotationBadge: overlay.rotationBadge, chromeAffordancesRef: overlay.chromeAffordancesRef,\n onDoubleClick, onClick, longPress: props.longPress,\n });\n useToolKeybindings({\n internalTools: p.tools.internal,\n toolsTakeover: p.tools.takeover ?? undefined,\n surface: p.tools.surface,\n enableKeybindings,\n modes: props.modes,\n canvasApi: canvas.ready ? canvas.apiRef.current : null,\n versionCheck: props.versionCheck,\n });\n useTestHook({\n getScene: () => scene as never,\n getSelectionIds: () => (selection.current as readonly string[] | undefined) ?? [],\n getView: () => viewState.viewRef.current,\n getActiveToolId: () => p.tools.tools.active ?? null,\n probes: root.probes,\n });\n\n // Mounted only when passed: an empty default registered with the deps above would land\n // after, and over, a dep one of these registered (child effects run first). Absent\n // `geometryProjection` leaves the dep undefined.\n return (\n <>\n {selectTool?.resize\n ? <ResizePolicyRegistrar options={selectTool.resize as UseResizeOptions<unknown>} />\n : null}\n {props.geometryProjection ? <GeometryProjectionRegistrar projection={props.geometryProjection} /> : null}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2FA,SAAgB,iBAAiB,GAA0B;CACzD,MAAM,EAAE,OAAO,OAAO,WAAW,SAAS,QAAQ,SAAS,WAAW;CACtE,MAAM,EAAE,cAAc,EAAE;CACxB,MAAM,EAAE,YAAY,oBAAoB,SAAS;CACjD,MAAM,eAAe,WAAW,yBAAyB;CACzD,gBAAgB;EACd,KAAK,gBAAgB,OAAO;EAC5B,aAAa,KAAK,gBAAgB,SAAS;CAC7C,GAAG,CAAC,CAAC;CACL,oBAAoB,OAAO,YAAY,OAAO,MAAM;CACpD,wBA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OAAO;EAAc,YAAY,OAAO;EAC/D;EAAa,iBAAiB,QAAQ,cAAc;EACpD,aAAa,QAAQ,cAAc;EACnC,eAAe,QAAQ;EAAe,sBAAsB,QAAQ;EACpE;EAAe;EAAS,WAAW,MAAM;CAC3C,CAAC;CACD,mBAAmB;EACjB,eAAe,EAAE,MAAM;EACvB,eAAe,EAAE,MAAM,YAAY;EACnC,SAAS,EAAE,MAAM;EACjB;EACA,OAAO,MAAM;EACb,WAAW,OAAO,QAAQ,OAAO,OAAO,UAAU;EAClD,cAAc,MAAM;CACtB,CAAC;CACD,YAAY;EACV,gBAAgB;EAChB,uBAAwB,UAAU,WAA6C,CAAC;EAChF,eAAe,UAAU,QAAQ;EACjC,uBAAuB,EAAE,MAAM,MAAM,UAAU;EAC/C,QAAQ,KAAK;CACf,CAAC;CAKD,OACE,qBAAAA,UAAA,EAAA,UAAA,CACG,YAAY,SACT,oBAAC,uBAAD,EAAuB,SAAS,WAAW,OAAsC,CAAA,IACjF,MACH,MAAM,qBAAqB,oBAAC,6BAAD,EAA6B,YAAY,MAAM,mBAAqB,CAAA,IAAI,IACpG,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"SceneCanvasInput.js","names":["_Fragment"],"sources":["../../../src/canvas/SceneCanvas/SceneCanvasInput.tsx"],"sourcesContent":["import type { ResizeHandleLayout } from 'interactions/actions/resize/cornerHandles';\nimport { useLatest } from '@weasel-js/react';\nimport type { Dispatcher } from '@weasel-js/routing';\nimport { useDepSource } from '@weasel-js/routing/react';\nimport type { Scene } from 'core/scene/types';\nimport type { SelectionApi } from 'core/selection/useSelection';\nimport type { RuleCtx } from 'domains/chrome-caps';\nimport type { Affordance } from 'affordances/types';\nimport type { PoseDescriptor } from 'interactions/actions/resize/geometry';\nimport type { UseResizeOptions } from 'interactions/actions/resize/options';\nimport { useContext, useEffect, type MutableRefObject, type RefObject } from 'react';\nimport { SnapSourceRegistryContext } from 'domains/snap/registry';\nimport type { SnapOutcomeStore } from 'domains/snap/outcomeStore';\nimport type { SnapSource } from 'domains/snap/types';\nimport { dlog } from '../../debug/flag';\nimport { useDeviceProfile } from '../../core/device/useDeviceProfile';\nimport { useTestHook } from '../../test-hook/useTestHook';\nimport type { CanvasExtensionApi } from '../canvasExtension';\nimport type { ChromeRulesDep } from '../deps/chromeRules';\nimport { useModeDefaultToolDepSource } from '../deps/modeDefaultTool';\nimport { useHitObserver } from '../useHitObserver';\nimport type { CanvasViewState } from '../useCanvasView';\nimport { GeometryProjectionRegistrar, ResizePolicyRegistrar } from './poseRegistrars';\nimport { usePointerPublisher } from './PointerProviderIfRoot';\nimport type { BridgeAdapter, SceneCanvasProps } from './props';\nimport type { NodeAtPoint } from './useNodeAtPoint';\nimport type { useSceneCanvasTools } from './useSceneCanvasTools';\nimport { useSceneGestureDispatcher } from './useSceneGestureDispatcher';\nimport { useCanvasDevtoolsRoot, type CanvasDevtools } from './useCanvasDevtoolsRoot';\nimport type { useScenePicking } from './useScenePicking';\nimport {\n useSceneStandardActions, type SceneStandardActionsInputs, type StandardActionsProps,\n} from './useSceneStandardActions';\nimport { useToolKeybindings } from './useToolKeybindings';\n\ntype Props = SceneCanvasProps<unknown, string, unknown>;\ntype Picking = ReturnType<typeof useScenePicking<unknown, string, unknown>>;\n\n/** The `<SceneCanvas>` props its input wiring reads. */\nexport type SceneCanvasInputOptions = StandardActionsProps & Pick<\n Props,\n | 'selectTool' | 'geometryProjection' | 'enableGestureDispatcher' | 'enableKeybindings'\n | 'claimKeys' | 'longPress' | 'modes' | 'versionCheck' | 'onClick' | 'onDoubleClick' | 'routing'\n>;\n\n/** What `<SceneCanvas>` hands {@link SceneCanvasInput}. */\nexport interface SceneCanvasInputProps {\n props: SceneCanvasInputOptions;\n scene: Scene<unknown, string, unknown>;\n selection: SelectionApi;\n descriptor: PoseDescriptor<unknown>;\n picking: Pick<\n Picking, 'pickEvery' | 'pickBest' | 'boundsOf' | 'planeOfNode' | 'kindOfNode' | 'doubleClickNames' | 'viewLayerGate' | 'alphaOf' | 'enteredGroup' | 'reachable'\n > & { adapter: BridgeAdapter };\n /** The node a hit resolves to, for the `onClick` / `onDoubleClick` observers. */\n nodeAtPointRef: MutableRefObject<NodeAtPoint | undefined>;\n tools: ReturnType<typeof useSceneCanvasTools>;\n viewOn: boolean;\n camera: { viewState: CanvasViewState; viewAnimation: SceneStandardActionsInputs['viewAnimation'] };\n dispatcher: Dispatcher;\n pathEdit: {\n state: SceneStandardActionsInputs['editAnchorsExternalState'];\n };\n chrome: {\n getIsVisible: () => (id: string) => boolean;\n getRuleCtx: () => RuleCtx | undefined;\n chromeRules: ChromeRulesDep;\n };\n /** The selection overlay's rotate badge, and where the dispatcher reports the affordances\n * it hit-tests, for the slops overlay. */\n overlay: {\n rotationBadge: { distancePx: number; sizePx: number } | null | undefined;\n /** The resize-handle layout the overlay paints, so the hit-test grabs exactly those. */\n resizeHandles: ResizeHandleLayout;\n chromeAffordancesRef: MutableRefObject<readonly Affordance[]>;\n };\n canvas: {\n elementRef: MutableRefObject<HTMLElement | null>;\n apiRef: RefObject<CanvasExtensionApi | null>;\n ready: boolean;\n };\n ingestionClipboard: SceneStandardActionsInputs['ingestionClipboard'];\n ingestionHandlers: SceneStandardActionsInputs['ingestionHandlers'];\n /** The enabled presets' snap sources. */\n snapSources: readonly SnapSource[];\n /** The outcome store the canvas's readout layer draws. */\n snapStore: SnapOutcomeStore;\n devtools: CanvasDevtools;\n}\n\n/**\n * The canvas's input wiring: the pointer publisher, the standard actions and their deps, the\n * gesture dispatcher, and the tool keybindings, in that order, then the test hook.\n *\n * A component of its own, mounted ahead of `<SceneCanvas>`'s children, rather than hooks in the\n * canvas's body: dep sources and actions stack newest-live in effect order, and a parent's\n * effects run after its children's, so a child overriding a kit dep would lose to it.\n */\nexport function SceneCanvasInput(p: SceneCanvasInputProps) {\n const { props, scene, selection, picking, chrome, overlay, canvas } = p;\n const { viewState } = p.camera;\n const { selectTool, enableKeybindings = true } = props;\n const snapRegistry = useContext(SnapSourceRegistryContext);\n useEffect(() => {\n dlog('scene-canvas', 'mount');\n return () => dlog('scene-canvas', 'unmount');\n }, []);\n usePointerPublisher(canvas.elementRef, canvas.apiRef);\n useDepSource('chromeRules', () => chrome.chromeRules);\n useModeDefaultToolDepSource(props.modes, p.tools.tools);\n useSceneStandardActions({\n props, viewOn: p.viewOn,\n selection, enteredGroup: picking.enteredGroup, scene, adapter: picking.adapter, standardActions: p.tools.standardActions,\n currentViewRef: viewState.viewRef, onViewChange: viewState.setViewFromInput,\n poseDescriptor: p.descriptor, dispatcher: p.dispatcher,\n pickEvery: picking.pickEvery, layerIsPainted: picking.viewLayerGate, alphaOf: picking.alphaOf, reachable: picking.reachable,\n viewAnimation: p.camera.viewAnimation, editAnchorsExternalState: p.pathEdit.state,\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef, ingestionClipboard: p.ingestionClipboard,\n ingestionHandlers: p.ingestionHandlers,\n snap: { sources: [...(props.snap?.sources ?? []), ...p.snapSources], registry: snapRegistry, store: p.snapStore },\n });\n\n // Rides the gesture dispatcher as an OBSERVER rather than an Action binding because the\n // prop is a notification, not a behavior: as a binding it would lose first-match-wins to\n // `enterPathEdit` on every body hit and silently stop firing.\n const onDoubleClick = useHitObserver(props.onDoubleClick, p.nodeAtPointRef);\n const onClick = useHitObserver(props.onClick, p.nodeAtPointRef);\n const selectionRef = useLatest(selection);\n const { targetScale } = useDeviceProfile();\n const { root, traces } = useCanvasDevtoolsRoot({\n scene, selection, viewState, tools: p.tools.tools, contributions: p.tools.contributions, routing: props.routing,\n element: canvas.elementRef, api: canvas.apiRef, devtools: p.devtools,\n });\n useSceneGestureDispatcher({\n canvasRef: canvas.elementRef, canvasApiRef: canvas.apiRef,\n tools: p.tools.tools, contributions: p.tools.contributions,\n enabled: props.enableGestureDispatcher ?? true, keyboard: enableKeybindings,\n claimKeys: props.claimKeys ?? false,\n selectionRef,\n boundsOf: picking.boundsOf, planeOfNode: picking.planeOfNode,\n pickEvery: picking.pickEvery, pickBest: picking.pickBest, kindOfNode: picking.kindOfNode,\n doubleClickNames: picking.doubleClickNames,\n viewRef: viewState.viewRef, dispatcher: p.dispatcher, traces,\n getIsVisibleForCanvas: chrome.getIsVisible, getRuleCtx: chrome.getRuleCtx,\n targetScale, handleHitRadius: overlay.resizeHandles.hitRadiusPx,\n edgeHandles: overlay.resizeHandles.edges,\n rotationBadge: overlay.rotationBadge, chromeAffordancesRef: overlay.chromeAffordancesRef,\n onDoubleClick, onClick, longPress: props.longPress,\n });\n useToolKeybindings({\n internalTools: p.tools.internal,\n toolsTakeover: p.tools.takeover ?? undefined,\n surface: p.tools.surface,\n enableKeybindings,\n modes: props.modes,\n canvasApi: canvas.ready ? canvas.apiRef.current : null,\n versionCheck: props.versionCheck,\n });\n useTestHook({\n getScene: () => scene as never,\n getSelectionIds: () => (selection.current as readonly string[] | undefined) ?? [],\n getView: () => viewState.viewRef.current,\n getActiveToolId: () => p.tools.tools.active ?? null,\n probes: root.probes,\n });\n\n // Mounted only when passed: an empty default registered with the deps above would land\n // after, and over, a dep one of these registered (child effects run first). Absent\n // `geometryProjection` leaves the dep undefined.\n return (\n <>\n {selectTool?.resize\n ? <ResizePolicyRegistrar options={selectTool.resize as UseResizeOptions<unknown>} />\n : null}\n {props.geometryProjection ? <GeometryProjectionRegistrar projection={props.geometryProjection} /> : null}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkGA,SAAgB,iBAAiB,GAA0B;CACzD,MAAM,EAAE,OAAO,OAAO,WAAW,SAAS,QAAQ,SAAS,WAAW;CACtE,MAAM,EAAE,cAAc,EAAE;CACxB,MAAM,EAAE,YAAY,oBAAoB,SAAS;CACjD,MAAM,eAAe,WAAW,yBAAyB;CACzD,gBAAgB;EACd,KAAK,gBAAgB,OAAO;EAC5B,aAAa,KAAK,gBAAgB,SAAS;CAC7C,GAAG,CAAC,CAAC;CACL,oBAAoB,OAAO,YAAY,OAAO,MAAM;CACpD,aAAa,qBAAqB,OAAO,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