@weasel-js/core 1.14.2 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/dist/affordances/pathAnchors.js +0 -1
  3. package/dist/affordances/pathAnchors.js.map +1 -1
  4. package/dist/barrel/paths.js +1 -1
  5. package/dist/barrel/renderer.js +2 -2
  6. package/dist/barrel/routing.js +6 -4
  7. package/dist/barrel/text.js +5 -3
  8. package/dist/canvas/Canvas.js +5 -1
  9. package/dist/canvas/Canvas.js.map +1 -1
  10. package/dist/canvas/DrawCanvas.js +5 -1
  11. package/dist/canvas/DrawCanvas.js.map +1 -1
  12. package/dist/canvas/SceneCanvas/SceneCanvasInput.js +4 -0
  13. package/dist/canvas/SceneCanvas/SceneCanvasInput.js.map +1 -1
  14. package/dist/canvas/SceneCanvas/builtinToolSets.js +6 -3
  15. package/dist/canvas/SceneCanvas/builtinToolSets.js.map +1 -1
  16. package/dist/canvas/SceneCanvas/defaultNodeProperties.js +1 -1
  17. package/dist/canvas/SceneCanvas/presets/paths.js +6 -6
  18. package/dist/canvas/SceneCanvas/presets/paths.js.map +1 -1
  19. package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js +1 -1
  20. package/dist/canvas/SceneCanvas/shapeGeneratorProperties.js.map +1 -1
  21. package/dist/canvas/SceneCanvas/useBuiltinTools.js +2 -0
  22. package/dist/canvas/SceneCanvas/useBuiltinTools.js.map +1 -1
  23. package/dist/canvas/SceneCanvas/useContributionRoles.js +2 -0
  24. package/dist/canvas/SceneCanvas/useContributionRoles.js.map +1 -1
  25. package/dist/canvas/SceneCanvas/useSceneChrome.js +17 -5
  26. package/dist/canvas/SceneCanvas/useSceneChrome.js.map +1 -1
  27. package/dist/canvas/SceneCanvas/useSceneStandardActions.js +3 -0
  28. package/dist/canvas/SceneCanvas/useSceneStandardActions.js.map +1 -1
  29. package/dist/canvas/SceneCanvas.js +5 -4
  30. package/dist/canvas/SceneCanvas.js.map +1 -1
  31. package/dist/canvas/SceneViewCanvas.js +5 -1
  32. package/dist/canvas/SceneViewCanvas.js.map +1 -1
  33. package/dist/canvas/affordanceAt.js +0 -1
  34. package/dist/canvas/affordanceAt.js.map +1 -1
  35. package/dist/canvas/deps/chromeRules.js +37 -0
  36. package/dist/canvas/deps/chromeRules.js.map +1 -0
  37. package/dist/canvas/deps/editAnchors.js +0 -6
  38. package/dist/canvas/deps/editAnchors.js.map +1 -1
  39. package/dist/canvas/deps/hitTestArea.js +3 -1
  40. package/dist/canvas/deps/hitTestArea.js.map +1 -1
  41. package/dist/canvas/deps/modeDefaultTool.js +23 -0
  42. package/dist/canvas/deps/modeDefaultTool.js.map +1 -0
  43. package/dist/canvas/deps/pathEditCommits.js +1 -1
  44. package/dist/canvas/deps/selectionSnapshot.js +23 -0
  45. package/dist/canvas/deps/selectionSnapshot.js.map +1 -0
  46. package/dist/canvas/deps/snap.js +1 -0
  47. package/dist/canvas/deps/snap.js.map +1 -1
  48. package/dist/canvas/pickReach.js +12 -8
  49. package/dist/canvas/pickReach.js.map +1 -1
  50. package/dist/canvas/pickWalk.js +7 -5
  51. package/dist/canvas/pickWalk.js.map +1 -1
  52. package/dist/canvas/scenePickSource.js +2 -2
  53. package/dist/canvas/scenePickSource.js.map +1 -1
  54. package/dist/canvas/useCanvasSurface.js +21 -3
  55. package/dist/canvas/useCanvasSurface.js.map +1 -1
  56. package/dist/canvas/useFrameLoop.js +6 -7
  57. package/dist/canvas/useFrameLoop.js.map +1 -1
  58. package/dist/canvas/useSurfaceSize.js +4 -3
  59. package/dist/canvas/useSurfaceSize.js.map +1 -1
  60. package/dist/core/geometry/regionHit.js +35 -16
  61. package/dist/core/geometry/regionHit.js.map +1 -1
  62. package/dist/core/scene/editMode.js +4 -1
  63. package/dist/core/scene/editMode.js.map +1 -1
  64. package/dist/core/scene/historyFacade.js +7 -50
  65. package/dist/core/scene/historyFacade.js.map +1 -1
  66. package/dist/core/scene/nodeGates.js +2 -2
  67. package/dist/core/scene/nodeGates.js.map +1 -1
  68. package/dist/core/scene/opTable.js +8 -8
  69. package/dist/core/scene/opTable.js.map +1 -1
  70. package/dist/core/scene/outerOps.js +2 -2
  71. package/dist/core/scene/outerOps.js.map +1 -1
  72. package/dist/core/scene/poseWrites.js +16 -15
  73. package/dist/core/scene/poseWrites.js.map +1 -1
  74. package/dist/core/scene/sceneJournals.js +78 -0
  75. package/dist/core/scene/sceneJournals.js.map +1 -0
  76. package/dist/core/scene/sceneRecording.js +3 -2
  77. package/dist/core/scene/sceneRecording.js.map +1 -1
  78. package/dist/core/viewport/useCanvasSize.js +47 -26
  79. package/dist/core/viewport/useCanvasSize.js.map +1 -1
  80. package/dist/{depSchema-DD9H89gX.d.ts → depSchema-ChQPzEkW.d.ts} +40 -13
  81. package/dist/domains/chrome-caps/resolve.js +1 -0
  82. package/dist/domains/chrome-caps/resolve.js.map +1 -1
  83. package/dist/domains/chrome-caps/useChromeCaps.js +4 -2
  84. package/dist/domains/chrome-caps/useChromeCaps.js.map +1 -1
  85. package/dist/domains/paths/pathEditState.js +0 -24
  86. package/dist/domains/paths/pathEditState.js.map +1 -1
  87. package/dist/domains/snap/probes2d.js +5 -0
  88. package/dist/domains/snap/probes2d.js.map +1 -1
  89. package/dist/domains/snap/sceneReads.js +11 -1
  90. package/dist/domains/snap/sceneReads.js.map +1 -1
  91. package/dist/domains/snap/sceneSession2d.js +4 -2
  92. package/dist/domains/snap/sceneSession2d.js.map +1 -1
  93. package/dist/domains/text/index.js +2 -2
  94. package/dist/icons.table.js +1 -1
  95. package/dist/icons.table.js.map +1 -1
  96. package/dist/icons.table.json +5 -0
  97. package/dist/index.d.ts +112 -60
  98. package/dist/index.js +12 -8
  99. package/dist/interactions/actions/booleans/action.js +4 -2
  100. package/dist/interactions/actions/booleans/action.js.map +1 -1
  101. package/dist/interactions/actions/defaults/anchorEditing.js +3 -6
  102. package/dist/interactions/actions/defaults/anchorEditing.js.map +1 -1
  103. package/dist/interactions/actions/defaults/bendSegment.js +1 -2
  104. package/dist/interactions/actions/defaults/bendSegment.js.map +1 -1
  105. package/dist/interactions/actions/defaults/exitPathEdit.js +17 -1
  106. package/dist/interactions/actions/defaults/exitPathEdit.js.map +1 -1
  107. package/dist/interactions/actions/edit-anchors/action.js +3 -4
  108. package/dist/interactions/actions/edit-anchors/action.js.map +1 -1
  109. package/dist/interactions/actions/insert/action.js +21 -2
  110. package/dist/interactions/actions/insert/action.js.map +1 -1
  111. package/dist/interactions/actions/insert/params.js +43 -0
  112. package/dist/interactions/actions/insert/params.js.map +1 -0
  113. package/dist/interactions/actions/notices.js +17 -0
  114. package/dist/interactions/actions/notices.js.map +1 -0
  115. package/dist/interactions/actions/outlines/createOutlines.js +8 -6
  116. package/dist/interactions/actions/outlines/createOutlines.js.map +1 -1
  117. package/dist/interactions/actions/outlines/createOutlinesAction.js +13 -8
  118. package/dist/interactions/actions/outlines/createOutlinesAction.js.map +1 -1
  119. package/dist/interactions/actions/outlines/outlineStrokeAction.js +3 -2
  120. package/dist/interactions/actions/outlines/outlineStrokeAction.js.map +1 -1
  121. package/dist/interactions/actions/pathCommands/pathNodes.js +1 -1
  122. package/dist/interactions/actions/testUtils.js +0 -7
  123. package/dist/interactions/actions/testUtils.js.map +1 -1
  124. package/dist/interactions/actions/useNotices.js +13 -0
  125. package/dist/interactions/actions/useNotices.js.map +1 -0
  126. package/dist/test-seams.d.ts +5 -12
  127. package/dist/tools/builtin/anchors/anchorsTool.js +31 -0
  128. package/dist/tools/builtin/anchors/anchorsTool.js.map +1 -0
  129. package/dist/tools/builtin/polygon/usePolygonTool.js +1 -1
  130. package/dist/tools/builtin/star/useStarTool.js +1 -1
  131. package/dist/tools/index.js +4 -2
  132. package/dist/tools/toolOptions.js +47 -0
  133. package/dist/tools/toolOptions.js.map +1 -0
  134. package/dist/version.js +1 -1
  135. package/package.json +25 -25
  136. package/dist/interactions/actions/defaults/pathEditTools.js +0 -60
  137. package/dist/interactions/actions/defaults/pathEditTools.js.map +0 -1
@@ -1,6 +1,5 @@
1
1
  import { pathOperationTags } from "../pathGestureTags.js";
2
2
  import { editingLayer, inPlane } from "../planeInput.js";
3
- import { pathEditToolActive } from "./pathEditTools.js";
4
3
  import { representationOf } from "../../../domains/paths/pathRepresentation.js";
5
4
  import { pathEditPreview } from "../edit-anchors/preview.js";
6
5
  import { segmentUnder } from "./segmentUnder.js";
@@ -72,7 +71,7 @@ var bendSegmentAction = inPlane({
72
71
  }
73
72
  },
74
73
  enabled: (deps, at) => {
75
- if (!deps?.editAnchors?.editingId || pathEditToolActive(deps)) return ActionDisabledReason.NotApplicable;
74
+ if (!deps?.editAnchors?.editingId) return ActionDisabledReason.NotApplicable;
76
75
  const represented = representedPress(deps);
77
76
  const hit = (p) => (represented ? represented(deps, p) : segmentUnder(deps, p.x, p.y)) !== null;
78
77
  if (at && !hit(at)) return ActionDisabledReason.NotApplicable;
@@ -1 +1 @@
1
- {"version":3,"file":"bendSegment.js","names":[],"sources":["../../../../src/interactions/actions/defaults/bendSegment.ts"],"sourcesContent":["/**\n * `bendSegmentAction` — drag a segment of the path being edited to reshape\n * it: the point pressed follows the pointer, and the segment's two handles\n * move to carry it (`bendSegment`). A straight segment becomes a curve.\n *\n * Bound to the `segment` affordance path edit lays along the outline, which\n * ties the marquee's `empty` and move's `selected-body` on specificity and\n * registers ahead of the marquee; move turns segment presses down itself.\n * An anchor's own affordance sits above the segment's, so a press on an\n * anchor is the anchor drag's. On a path drawn from a form whose\n * representation takes segment presses (`PathRepresentation.segmentPress`),\n * the press is the representation's instead.\n */\n\nimport type { Action, ActionDeps, InvocationCtx, OngoingHandle } from '@weasel-js/routing';\nimport { ActionDisabledReason, isSegment } from '@weasel-js/routing';\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport { bendSegment, editAnchorSetTracked, type PointOrigin, type PolygonPath } from '@weasel-js/geom';\nimport { inPlane, editingLayer } from '../planeInput';\nimport { pathEditPreview } from '../edit-anchors/preview';\nimport { segmentUnder } from './segmentUnder';\nimport { representationOf, type PathRepresentation } from 'domains/paths/pathRepresentation';\nimport { pathEditToolActive } from './pathEditTools';\nimport { pathOperationTags } from '../pathGestureTags';\nimport { icon } from '../../../icons.gen';\n\nconst BEND_CURSOR: CursorSpec = 'grab';\n\n/** The segment press of the representation the path in edit is drawn\n * through, when it takes them. */\nfunction representedPress(deps: ActionDeps | undefined): NonNullable<PathRepresentation['segmentPress']> | null {\n const dep = deps?.editAnchors;\n if (!dep?.editingId) return null;\n const representation = representationOf(dep.extensions, dep.getNodeShape(dep.editingId)?.data)?.representation;\n return representation?.segmentPress ? (on, at) => representation.segmentPress!(on, at) : null;\n}\n\nexport const bendSegmentAction: Action & { requires: string[] } = inPlane({\n id: 'bendSegment',\n label: 'Bend segment',\n icon: icon('bendSegment'),\n tags: pathOperationTags('drag'),\n defaultBinding: [{ spec: { kind: 'drag', target: { kindOf: isSegment } }, opts: { id: 'bendSegment.drag' } }],\n cursor: BEND_CURSOR,\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors', 'view', 'kitSettings'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx): OngoingHandle {\n const represented = representedPress(ctx.deps);\n if (represented) return represented(ctx.deps, ctx.world)?.() ?? {};\n const under = segmentUnder(ctx.deps, ctx.world.x, ctx.world.y);\n if (!under) return {};\n const { dep, path: originPath, hit } = under;\n const id = dep.editingId;\n const press = { x: ctx.world.x, y: ctx.world.y };\n let current: { path: PolygonPath; origins?: readonly (PointOrigin | null)[] } | null = null;\n const preview = pathEditPreview(dep, id, () => current);\n if (!preview) return {};\n\n return {\n kind: 'bend-segment',\n onMove(moveCtx: InvocationCtx): void {\n const dx = moveCtx.world.x - press.x;\n const dy = moveCtx.world.y - press.y;\n current = editAnchorSetTracked(originPath, (set) => bendSegment(set, hit, dx, dy)) ?? current;\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n const done = current;\n current = null;\n if (reason === 'cancel' || !done) return;\n dep.applyEdit(id, done.path, 'Bend segment', done.origins);\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n enabled: (deps, at) => {\n if (!deps?.editAnchors?.editingId || pathEditToolActive(deps)) return ActionDisabledReason.NotApplicable;\n const represented = representedPress(deps);\n const hit = (p: { x: number; y: number }) =>\n (represented ? represented(deps, p) : segmentUnder(deps, p.x, p.y)) !== null;\n if (at && !hit(at)) return ActionDisabledReason.NotApplicable;\n return true;\n },\n}, editingLayer);\n"],"mappings":";;;;;;;;;;AA0BA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;AAIhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsF;AAC9G,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAClB,CAAA,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AAC5B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CA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AAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAE,CAAA,CAAA,CAAG,CAAA,CAAE,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AAC1E,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA,CAAA,CAAI,CAAA,CAAE,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAChD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AACT,CAAA;AACF,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA"}
1
+ {"version":3,"file":"bendSegment.js","names":[],"sources":["../../../../src/interactions/actions/defaults/bendSegment.ts"],"sourcesContent":["/**\n * `bendSegmentAction` — drag a segment of the path being edited to reshape\n * it: the point pressed follows the pointer, and the segment's two handles\n * move to carry it (`bendSegment`). A straight segment becomes a curve.\n *\n * Bound to the `segment` affordance path edit lays along the outline, which\n * ties the marquee's `empty` and move's `selected-body` on specificity and\n * registers ahead of the marquee; move turns segment presses down itself.\n * An anchor's own affordance sits above the segment's, so a press on an\n * anchor is the anchor drag's. On a path drawn from a form whose\n * representation takes segment presses (`PathRepresentation.segmentPress`),\n * the press is the representation's instead.\n */\n\nimport type { Action, ActionDeps, InvocationCtx, OngoingHandle } from '@weasel-js/routing';\nimport { ActionDisabledReason, isSegment } from '@weasel-js/routing';\nimport type { CursorSpec } from '@weasel-js/cursor';\nimport { bendSegment, editAnchorSetTracked, type PointOrigin, type PolygonPath } from '@weasel-js/geom';\nimport { inPlane, editingLayer } from '../planeInput';\nimport { pathEditPreview } from '../edit-anchors/preview';\nimport { segmentUnder } from './segmentUnder';\nimport { representationOf, type PathRepresentation } from 'domains/paths/pathRepresentation';\nimport { pathOperationTags } from '../pathGestureTags';\nimport { icon } from '../../../icons.gen';\n\nconst BEND_CURSOR: CursorSpec = 'grab';\n\n/** The segment press of the representation the path in edit is drawn\n * through, when it takes them. */\nfunction representedPress(deps: ActionDeps | undefined): NonNullable<PathRepresentation['segmentPress']> | null {\n const dep = deps?.editAnchors;\n if (!dep?.editingId) return null;\n const representation = representationOf(dep.extensions, dep.getNodeShape(dep.editingId)?.data)?.representation;\n return representation?.segmentPress ? (on, at) => representation.segmentPress!(on, at) : null;\n}\n\nexport const bendSegmentAction: Action & { requires: string[] } = inPlane({\n id: 'bendSegment',\n label: 'Bend segment',\n icon: icon('bendSegment'),\n tags: pathOperationTags('drag'),\n defaultBinding: [{ spec: { kind: 'drag', target: { kindOf: isSegment } }, opts: { id: 'bendSegment.drag' } }],\n cursor: BEND_CURSOR,\n eligible: { capability: 'edits-anchors' },\n requires: ['editAnchors', 'view', 'kitSettings'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx): OngoingHandle {\n const represented = representedPress(ctx.deps);\n if (represented) return represented(ctx.deps, ctx.world)?.() ?? {};\n const under = segmentUnder(ctx.deps, ctx.world.x, ctx.world.y);\n if (!under) return {};\n const { dep, path: originPath, hit } = under;\n const id = dep.editingId;\n const press = { x: ctx.world.x, y: ctx.world.y };\n let current: { path: PolygonPath; origins?: readonly (PointOrigin | null)[] } | null = null;\n const preview = pathEditPreview(dep, id, () => current);\n if (!preview) return {};\n\n return {\n kind: 'bend-segment',\n onMove(moveCtx: InvocationCtx): void {\n const dx = moveCtx.world.x - press.x;\n const dy = moveCtx.world.y - press.y;\n current = editAnchorSetTracked(originPath, (set) => bendSegment(set, hit, dx, dy)) ?? current;\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n const done = current;\n current = null;\n if (reason === 'cancel' || !done) return;\n dep.applyEdit(id, done.path, 'Bend segment', done.origins);\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n enabled: (deps, at) => {\n if (!deps?.editAnchors?.editingId) return ActionDisabledReason.NotApplicable;\n const represented = representedPress(deps);\n const hit = (p: { x: number; y: number }) =>\n (represented ? represented(deps, p) : segmentUnder(deps, p.x, p.y)) !== null;\n if (at && !hit(at)) return ActionDisabledReason.NotApplicable;\n return true;\n },\n}, editingLayer);\n"],"mappings":";;;;;;;;;AAyBA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA0B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;;;AAIhC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAS,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAiB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAsF;AAC9G,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAClB,CAAA,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAK,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,CAAA,CAAA,CAAA,CAAc,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAA,CAAE,CAAA,CAAA,CAAG,CAAA,CAAE,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AAC1E,CAAA,CAAA,CAAA,CAAA,CAAA,CAAI,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAC,CAAA,CAAA,CAAA,CAAI,CAAA,CAAE,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAqB,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAChD,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAA,CAAA,CAAA,CAAA;AACT,CAAA;AACF,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAY,CAAA"}
@@ -1,4 +1,15 @@
1
+ import { returnToModeDefault } from "@weasel-js/routing";
2
+
1
3
  //#region src/interactions/actions/defaults/exitPathEdit.ts
4
+ /**
5
+ * `exitPathEditAction` — immediate Action that exits path-anchor edit
6
+ * mode. Bound to Escape by default; companion to `enterPathEditAction`.
7
+ * Clears `editAnchors.editingId`, which the gesture-side hit-test and
8
+ * `pathEditingOverlayLayer` both gate on. Pressed with a tool on other than
9
+ * the mode's default (path edit's `anchors`), it returns to that tool instead.
10
+ *
11
+ * Always enabled — calling it when no path is being edited is a no-op.
12
+ */
2
13
  var exitPathEditAction = {
3
14
  id: "exitPathEdit",
4
15
  label: "Exit path edit",
@@ -10,10 +21,15 @@ var exitPathEditAction = {
10
21
  opts: { id: "exitPathEdit.key" }
11
22
  }],
12
23
  eligible: { mode: "path-edit" },
13
- requires: ["editAnchors"],
24
+ requires: [
25
+ "editAnchors",
26
+ "activeTool",
27
+ "modeDefaultTool"
28
+ ],
14
29
  invoker: {
15
30
  timing: "immediate",
16
31
  run(deps) {
32
+ if (returnToModeDefault(deps)) return;
17
33
  deps.editAnchors?.setEditingId(null);
18
34
  }
19
35
  },
@@ -1 +1 @@
1
- {"version":3,"file":"exitPathEdit.js","names":[],"sources":["../../../../src/interactions/actions/defaults/exitPathEdit.ts"],"sourcesContent":["/**\n * `exitPathEditAction` — immediate Action that exits path-anchor edit\n * mode. Bound to Escape by default; companion to `enterPathEditAction`.\n * Clears `editAnchors.editingId`, which the gesture-side hit-test and\n * `pathEditingOverlayLayer` both gate on.\n *\n * Always enabled — calling it when no path is being edited is a no-op.\n */\n\nimport type { Action } from '@weasel-js/routing';\nimport type { ImmediateInvoker } from '@weasel-js/routing';\n\nexport const exitPathEditAction: Action & { requires: string[] } = {\n id: 'exitPathEdit',\n label: 'Exit path edit',\n defaultBinding: [{ spec: { kind: 'key', key: 'Escape' }, opts: { id: 'exitPathEdit.key' } }],\n eligible: { mode: 'path-edit' },\n requires: ['editAnchors'],\n invoker: {\n timing: 'immediate',\n run(deps) {\n const editAnchors = deps.editAnchors;\n editAnchors?.setEditingId(null);\n },\n } as ImmediateInvoker,\n enabled: () => true,\n};\n"],"mappings":";AAYA,IAAa,qBAAsD;CACjE,IAAI;CACJ,OAAO;CACP,gBAAgB,CAAC;EAAE,MAAM;GAAE,MAAM;GAAO,KAAK;EAAS;EAAG,MAAM,EAAE,IAAI,mBAAmB;CAAE,CAAC;CAC3F,UAAU,EAAE,MAAM,YAAY;CAC9B,UAAU,CAAC,aAAa;CACxB,SAAS;EACP,QAAQ;EACR,IAAI,MAAM;GAER,AADoB,KAAK,aACZ,aAAa,IAAI;EAChC;CACF;CACA,eAAe;AACjB"}
1
+ {"version":3,"file":"exitPathEdit.js","names":[],"sources":["../../../../src/interactions/actions/defaults/exitPathEdit.ts"],"sourcesContent":["/**\n * `exitPathEditAction` — immediate Action that exits path-anchor edit\n * mode. Bound to Escape by default; companion to `enterPathEditAction`.\n * Clears `editAnchors.editingId`, which the gesture-side hit-test and\n * `pathEditingOverlayLayer` both gate on. Pressed with a tool on other than\n * the mode's default (path edit's `anchors`), it returns to that tool instead.\n *\n * Always enabled — calling it when no path is being edited is a no-op.\n */\n\nimport { returnToModeDefault, type Action } from '@weasel-js/routing';\nimport type { ImmediateInvoker } from '@weasel-js/routing';\n\nexport const exitPathEditAction: Action & { requires: string[] } = {\n id: 'exitPathEdit',\n label: 'Exit path edit',\n defaultBinding: [{ spec: { kind: 'key', key: 'Escape' }, opts: { id: 'exitPathEdit.key' } }],\n eligible: { mode: 'path-edit' },\n requires: ['editAnchors', 'activeTool', 'modeDefaultTool'],\n invoker: {\n timing: 'immediate',\n run(deps) {\n if (returnToModeDefault(deps)) return;\n const editAnchors = deps.editAnchors;\n editAnchors?.setEditingId(null);\n },\n } as ImmediateInvoker,\n enabled: () => true,\n};\n"],"mappings":";;;;;;;;;;;;AAaA,IAAa,qBAAsD;CACjE,IAAI;CACJ,OAAO;CACP,gBAAgB,CAAC;EAAE,MAAM;GAAE,MAAM;GAAO,KAAK;EAAS;EAAG,MAAM,EAAE,IAAI,mBAAmB;CAAE,CAAC;CAC3F,UAAU,EAAE,MAAM,YAAY;CAC9B,UAAU;EAAC;EAAe;EAAc;CAAiB;CACzD,SAAS;EACP,QAAQ;EACR,IAAI,MAAM;GACR,IAAI,oBAAoB,IAAI,GAAG;GAE/B,AADoB,KAAK,aACZ,aAAa,IAAI;EAChC;CACF;CACA,eAAe;AACjB"}
@@ -2,14 +2,13 @@ import { pathOperationTags } from "../pathGestureTags.js";
2
2
  import { editingLayer, inPlane } from "../planeInput.js";
3
3
  import { SNAP_ROLES, snapMods } from "../../../domains/snap/roles.js";
4
4
  import { inputSession } from "../../../domains/snap/session2d.js";
5
- import { pathEditToolActive } from "../defaults/pathEditTools.js";
6
5
  import { HANDLE_LOCK_ROLES, lockHandle, locksInForce } from "./handleDrag.js";
7
6
  import { locksOf } from "./params.js";
8
7
  import { finishPathEditFrame, pathEditPreview } from "./preview.js";
9
8
  import { claimWheel, dragWeights, endExtensionDrags, extensionOverlays, placeHandle, startExtensionDrags, translateWeighted } from "./extensionDrags.js";
10
9
  import { editedPathSymmetries } from "./symmetry.js";
11
10
  import { anchorAt, editAnchorSetTracked, moveHandleSymmetric, moveHandleTo, pathAwayFromAnchors, pathToAnchors, translateAnchorsSymmetric } from "@weasel-js/geom";
12
- import { ActionDisabledReason, isAnchorOrControl, resolveParams, roleReader } from "@weasel-js/routing";
11
+ import { isAnchorOrControl, resolveParams, roleReader } from "@weasel-js/routing";
13
12
 
14
13
  //#region src/interactions/actions/edit-anchors/action.ts
15
14
  /**
@@ -167,6 +166,7 @@ var editAnchorsAction = inPlane({
167
166
  },
168
167
  opts: { id: "editAnchors.drag" }
169
168
  }],
169
+ cursor: "pointer",
170
170
  eligible: { capability: "edits-anchors" },
171
171
  modifierRoles: EDIT_ANCHORS_ROLES,
172
172
  requires: [
@@ -268,8 +268,7 @@ var editAnchorsAction = inPlane({
268
268
  previewData: preview.previewData
269
269
  };
270
270
  }
271
- },
272
- enabled: (deps) => pathEditToolActive(deps) ? ActionDisabledReason.NotApplicable : true
271
+ }
273
272
  }, editingLayer);
274
273
 
275
274
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/edit-anchors/action.ts"],"sourcesContent":["/**\n * `editAnchorsAction` — ongoing Action descriptor for editing polygon anchors.\n *\n * - **Press** selects. Bare press replaces the anchor selection; Shift\n * toggles the pressed anchor in or out of it. Pressing an anchor that\n * is already part of a multi-anchor selection leaves the selection\n * alone, so you can grab a set and move it.\n * - **Drag** then moves whatever the press left selected — one anchor,\n * or every selected anchor together. The pressed anchor snaps through\n * the `snap` dep's `point` session, to what the drag leaves still of the\n * path and to the canvas's targets; Shift holds it to the axes and\n * diagonals through its press, and Ctrl suspends the snap.\n * - **Dragging a control handle** moves just that handle, mirroring the\n * opposite one while the anchor is smooth. Alt breaks the mirror; Shift\n * holds the handle to the angle it had at the press, changing only its\n * length; Mod (Cmd or Ctrl) holds its length, changing only its angle;\n * both freeze it. The `editAnchors` dep's `handleLocks`, or else the\n * `handleLock` param ({@link EditAnchorsParams}), holds a lock with no\n * modifier. The lock in force draws its guide as a `polyline` overlay\n * of role `lock`: the line, or the circle round the anchor.\n * - **Path-edit extensions shape the drag** through their `drag`: anchors\n * that follow an anchor drag by a share of it, where a dragged handle\n * goes after the locks, the wheel mid-drag, and overlays of their own.\n * - **Every frame is finished** by the dep's `finishEdit`, so what a\n * path-edit extension keeps true holds while the drag runs.\n * - **Under a `pathSymmetry` dep**, on a path that is its own image under\n * some of its transforms, every image of what is dragged follows it.\n *\n * Selection lives on the `editAnchors` dep (flat anchor indices) rather\n * than in this handle's scratch, because the keyboard actions\n * (`nudgeAnchors`, `deleteAnchors`) and the overlay all need to read it\n * between gestures.\n *\n * Operational when the consumer wires the `editAnchors` dep, and\n * `buildAffordanceAt` with a `getAnchorState` thunk so the dispatcher\n * classifies anchor/control-handle hits as `anchor:N`, `controlIn:N`, or\n * `controlOut:N` affordances on pointerdown. On any other affordance `start`\n * returns `{}` so other bindings can handle the drag.\n */\n\nimport type { Action } from '@weasel-js/routing';\nimport type { BindingOpts, InvocationCtx, OngoingHandle, OngoingOverlay, WorldPoint } from '@weasel-js/routing';\nimport type { EditAnchorsDep, SnapDep } from '../depSchema';\nimport type { SnapBegin, SnapMods, SnapSession } from '../snapDep';\nimport { inputSession } from 'domains/snap/session2d';\nimport { SNAP_ROLES, snapMods } from 'domains/snap/roles';\nimport { ActionDisabledReason, isAnchorOrControl, resolveParams, roleReader, type ModifierRoles } from '@weasel-js/routing';\nimport {\n anchorAt,\n editAnchorSetTracked,\n moveHandleSymmetric,\n moveHandleTo,\n pathAwayFromAnchors,\n translateAnchorsSymmetric,\n type AnchorSet,\n type AnchorSymmetry,\n type PenAnchor,\n type PointOrigin,\n} from '@weasel-js/geom';\nimport { pathToAnchors, type PolygonPath } from '@weasel-js/geom';\nimport { inPlane, editingLayer } from '../planeInput';\nimport { HANDLE_LOCK_ROLES, lockHandle, locksInForce, type HandlePress } from './handleDrag';\nimport { locksOf, type EditAnchorsParams } from './params';\nimport { finishPathEditFrame, pathEditPreview } from './preview';\nimport {\n claimWheel, dragWeights, endExtensionDrags, extensionOverlays, placeHandle, startExtensionDrags, translateWeighted,\n} from './extensionDrags';\nimport type { PathEditDrag } from 'domains/paths/pathEditExtension';\nimport { pathEditToolActive } from '../defaults/pathEditTools';\nimport { editedPathSymmetries } from './symmetry';\nimport { pathOperationTags } from '../pathGestureTags';\n\n/**\n * Parse an anchor affordance kind — `'anchor:N'` | `'controlIn:N'` |\n * `'controlOut:N'`, where N is the flat anchor index — or `null` when the\n * affordance is not an anchor kind.\n */\nfunction parseAnchorAffordance(\n kind: string,\n): { anchorIndex: number; part: 'anchor' | 'controlIn' | 'controlOut' } | null {\n const m = kind.match(/^(anchor|controlIn|controlOut):(\\d+)$/);\n if (!m) return null;\n return {\n anchorIndex: parseInt(m[2], 10),\n part: m[1] as 'anchor' | 'controlIn' | 'controlOut',\n };\n}\n\n/**\n * Resolve what a press on `anchorIndex` should leave selected.\n *\n * Shift toggles. A bare press on an anchor that's already part of the\n * selection keeps the selection intact (so the drag moves the whole set);\n * a bare press anywhere else collapses to just that anchor.\n */\nexport function selectionAfterAnchorPress(\n current: ReadonlySet<number>,\n anchorIndex: number,\n additive: boolean,\n): Set<number> {\n if (additive) {\n const next = new Set(current);\n if (next.has(anchorIndex)) next.delete(anchorIndex);\n else next.add(anchorIndex);\n return next;\n }\n if (current.has(anchorIndex) && current.size > 1) return new Set(current);\n return new Set([anchorIndex]);\n}\n\ninterface EditAnchorsScratch {\n dep: EditAnchorsDep;\n id: string;\n anchorIndex: number;\n /** `'anchor'` drags on-curve points (and their handles) by a delta.\n * `'controlIn'` / `'controlOut'` drag one control point to an absolute\n * world coord. */\n part: 'anchor' | 'controlIn' | 'controlOut';\n /** Anchors this drag moves — the pressed one, or the whole anchor\n * selection when the press landed inside it. Flat indices. */\n dragging: readonly number[];\n /** World position of the pressed anchor at drag start; the drag delta is\n * measured from here rather than accumulated per move, so the geometry\n * is always derived from `originPose` in one step. */\n anchorOrigin: { x: number; y: number };\n /** The anchor and the dragged control handle at the press, for a handle drag. */\n handlePress: HandlePress | null;\n /** The guide the lock in force drew at the last move. */\n guide: OngoingOverlay | null;\n /** The path-edit extensions' shares of this drag. */\n drags: readonly PathEditDrag[];\n /** The last move, to redo when an extension claims the wheel. */\n lastMove: InvocationCtx | null;\n originPose: PolygonPath;\n currentPose: PolygonPath;\n /** The transforms `originPose` is its own image under, read at the press. */\n symmetries: readonly AnchorSymmetry[];\n /** Where each point of `currentPose` came from in `originPose`. */\n origins?: readonly (PointOrigin | null)[];\n /** Other nodes' world paths the finished edit moves with it. */\n others: readonly { id: string; path: PolygonPath }[];\n}\n\n/**\n * An anchor drag's snap: a `point` session, begun on the first move, for\n * where the pressed anchor goes. The edited path offers no targets but what\n * the drag leaves still of it, and Shift holds the anchor to the axes and\n * diagonals through its press.\n */\nfunction anchorDragSnap(\n snap: SnapDep | undefined,\n press: { id: string; origin: WorldPoint; originPose: PolygonPath; dragging: readonly number[] },\n): { at(world: WorldPoint, mods: SnapMods): WorldPoint; end(): void } {\n let session: SnapSession | null = null;\n return {\n at(world, mods) {\n if (!session) {\n const { path, anchors } = pathAwayFromAnchors(press.originPose, press.dragging);\n const req: SnapBegin = {\n gesture: 'point', press: press.origin, ids: [press.id],\n also: { paths: [path], anchors }, constrain: 'axis',\n };\n session = snap?.begin(req) ?? inputSession(req);\n }\n return session.at(world, mods).point;\n },\n end() {\n session?.end();\n session = null;\n },\n };\n}\n\nconst paramsOf = (opts: BindingOpts | undefined): EditAnchorsParams =>\n (resolveParams(opts?.params) ?? {}) as EditAnchorsParams;\n\n/** Take `next` as the frame to show, finished by the dep. A frame it cannot\n * finish is dropped, so the path stays at the last one it could. */\nfunction track(scratch: EditAnchorsScratch, next: ReturnType<typeof editAnchorSetTracked>): void {\n if (!next) return;\n const { dep, id } = scratch;\n const done = finishPathEditFrame(dep, id, next.path, next.origins);\n if (!done) return;\n scratch.currentPose = done.path as PolygonPath;\n scratch.others = done.others as EditAnchorsScratch['others'];\n scratch.origins = next.origins;\n}\n\n/** The anchor and the handle a press on `part` grabbed; null for an anchor press. */\nfunction handlePressOf(\n origin: PenAnchor,\n part: EditAnchorsScratch['part'],\n): HandlePress | null {\n const handle = part === 'controlIn' ? origin.inHandle : part === 'controlOut' ? origin.outHandle : undefined;\n return handle ? { anchor: { x: origin.x, y: origin.y }, handle: { ...handle } } : null;\n}\n\n/** Move the dragged anchors to follow `to`, and the anchors the extensions\n * weight by their shares. A weighted drag moves no symmetric images. */\nfunction moveAnchors(scratch: EditAnchorsScratch, to: WorldPoint): void {\n if (scratch.dragging.length === 0) return;\n const dx = to.x - scratch.anchorOrigin.x;\n const dy = to.y - scratch.anchorOrigin.y;\n const weights = dragWeights(scratch.drags, scratch.dragging);\n track(scratch, editAnchorSetTracked(scratch.originPose, (set) => {\n if (weights) translateWeighted(set, weights, dx, dy);\n else translateAnchorsSymmetric(set, scratch.dragging, dx, dy, scratch.symmetries);\n }));\n}\n\n/** The modifiers `editAnchors` reads while it runs: Shift on the press adds\n * to the anchor selection, Alt breaks a smooth anchor's mirror, the handle\n * locks, and Shift holds an anchor drag to the axes and diagonals. An anchor\n * drag also reads `snap.suspend` at its default key, Ctrl, which is not\n * declared here because on a handle Ctrl holds the length. */\nexport const EDIT_ANCHORS_ROLES = {\n 'selection.add': { label: 'Add to the anchor selection', keys: ['shift'] },\n 'mirror.break': { label: \"Break the handles' mirror\", keys: ['alt'] },\n ...HANDLE_LOCK_ROLES,\n 'snap.constrain': SNAP_ROLES['snap.constrain'],\n} as const satisfies ModifierRoles;\n\nconst roleHeld = roleReader(EDIT_ANCHORS_ROLES);\n\n/** Move the dragged handle toward the pointer, under the locks in force, then\n * wherever the extensions place it. */\nfunction moveHandle(scratch: EditAnchorsScratch, ctx: InvocationCtx, params: EditAnchorsParams): void {\n const side = scratch.part === 'controlIn' ? 'in' : 'out';\n // Modifiers and held locks are read live, so either can change mid-drag.\n const held = (ctx.deps.editAnchors ?? scratch.dep).handleLocks ?? locksOf(params.handleLock);\n const locks = locksInForce(held, ctx);\n const locked = scratch.handlePress ? lockHandle(scratch.handlePress, ctx.world, locks) : { to: ctx.world, guide: null };\n scratch.guide = locked.guide;\n const to = placeHandle(scratch.drags, locked.to, { locks });\n const alt = roleHeld(ctx, 'mirror.break');\n const move = scratch.symmetries.length > 0\n ? (set: AnchorSet) => moveHandleSymmetric(set, scratch.anchorIndex, side, to.x, to.y, alt, scratch.symmetries)\n : (set: AnchorSet) => moveHandleTo(set, scratch.anchorIndex, side, to.x, to.y, alt);\n track(scratch, editAnchorSetTracked(scratch.originPose, move));\n}\n\n/**\n * What a press drags, the selection updated first, before any move: a handle\n * press drags its anchor's handle; an anchor press selects as\n * {@link selectionAfterAnchorPress} says and drags what it left selected —\n * nothing when Shift took the pressed anchor out of it.\n */\nfunction draggedByPress(\n dep: EditAnchorsDep,\n press: { anchorIndex: number; part: EditAnchorsScratch['part'] },\n shift: boolean,\n): readonly number[] {\n if (press.part !== 'anchor') return [press.anchorIndex];\n const next = selectionAfterAnchorPress(dep.selectedAnchors, press.anchorIndex, shift);\n dep.setSelectedAnchors(next);\n return next.has(press.anchorIndex) ? [...next] : [];\n}\n\n/** Static descriptor for the `editAnchors` Action. */\nexport const editAnchorsAction: Action & { requires: string[] } = inPlane({\n id: 'editAnchors',\n label: 'Edit Anchors',\n tags: pathOperationTags('drag'),\n defaultBinding: [{\n spec: {\n kind: 'drag',\n // Only matches drags whose pointerdown hit an anchor or control handle.\n // Ties moveAction's `selected-body` on specificity and registers after\n // it, so move declines these presses in `start`.\n target: { kindOf: isAnchorOrControl },\n },\n opts: { id: 'editAnchors.drag' },\n }],\n eligible: { capability: 'edits-anchors' },\n modifierRoles: EDIT_ANCHORS_ROLES,\n requires: ['selection', 'editAnchors', 'pathSymmetry', 'snap'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts): OngoingHandle {\n const dep = ctx.deps.editAnchors;\n if (!dep) return {};\n\n const affordance = ctx.drag?.affordance;\n if (!affordance) {\n // No affordance hit → this drag doesn't target an anchor handle.\n // Let other bindings handle it (the handle returns {}, dispatcher moves on).\n return {};\n }\n\n const anchorInfo = parseAnchorAffordance(affordance.kind);\n if (!anchorInfo) {\n // Affordance is a non-anchor kind (e.g. resize handle, rotate handle).\n return {};\n }\n\n const { editingId } = dep;\n // World-coord polygon. For pose-as-polygon nodes this equals\n // node.pose; for data.path nodes it's pathInWorld-projected (translate +\n // rotation) so the anchor world coords match what the user clicked.\n const worldPath = dep.getEditablePath(editingId) as PolygonPath | undefined;\n if (!worldPath || worldPath.kind !== 'polygon') return {};\n\n // Decode once to validate the affordance index against the actual\n // geometry and to read the press origin. A stale affordance (the\n // path changed between pointerdown and now) fails here rather than\n // silently editing whichever anchor now holds that index.\n const decoded = pathToAnchors(worldPath) as AnchorSet;\n const origin = anchorAt(decoded, anchorInfo.anchorIndex);\n if (!origin) return {};\n if (anchorInfo.part === 'controlIn' && !origin.inHandle) return {};\n if (anchorInfo.part === 'controlOut' && !origin.outHandle) return {};\n\n let active = false;\n const preview = pathEditPreview(\n dep, editingId, () => (active ? { path: scratch.currentPose } : null), () => (active ? scratch.others : []),\n );\n if (!preview) return {};\n\n const dragging = draggedByPress(dep, anchorInfo, roleHeld(ctx, 'selection.add'));\n\n const scratch: EditAnchorsScratch = {\n dep,\n id: editingId,\n anchorIndex: anchorInfo.anchorIndex,\n part: anchorInfo.part,\n dragging,\n anchorOrigin: { x: origin.x, y: origin.y },\n handlePress: handlePressOf(origin, anchorInfo.part),\n guide: null,\n drags: startExtensionDrags(dep.extensions, {\n id: editingId,\n node: dep.getNodeShape(editingId),\n path: worldPath,\n anchors: decoded,\n part: anchorInfo.part,\n anchorIndex: anchorInfo.anchorIndex,\n dragging: anchorInfo.part === 'anchor' ? dragging : [],\n scale: ctx.deps.view?.get().scale,\n ...(ctx.deps.snap ? { snap: ctx.deps.snap } : {}),\n }),\n lastMove: null,\n originPose: worldPath,\n currentPose: worldPath,\n symmetries: editedPathSymmetries(ctx.deps.pathSymmetry, editingId, decoded),\n others: [],\n };\n const snapAnchor = anchorDragSnap(ctx.deps.snap, {\n id: editingId, origin: scratch.anchorOrigin, originPose: worldPath, dragging,\n });\n\n const move = (moveCtx: InvocationCtx): void => {\n scratch.lastMove = moveCtx;\n if (scratch.part !== 'anchor') return moveHandle(scratch, moveCtx, paramsOf(opts));\n moveAnchors(scratch, snapAnchor.at(moveCtx.world, snapMods(moveCtx)));\n };\n\n return {\n kind: 'edit-anchors',\n onMove(moveCtx: InvocationCtx): void {\n move(moveCtx);\n active = true;\n },\n onWheel(wheelCtx: InvocationCtx): boolean {\n if (!wheelCtx.wheel || !claimWheel(scratch.drags, wheelCtx.wheel)) return false;\n if (scratch.lastMove) move(scratch.lastMove);\n return true;\n },\n overlay(): readonly OngoingOverlay[] | null {\n if (!active) return null;\n const extra = scratch.drags.length > 0\n ? extensionOverlays(scratch.drags, pathToAnchors(scratch.currentPose) as AnchorSet)\n : [];\n const all = scratch.guide ? [scratch.guide, ...extra] : extra;\n return all.length > 0 ? all : null;\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n active = false;\n try {\n if (reason === 'cancel' || scratch.originPose === scratch.currentPose) return;\n scratch.dep.applyEdit(scratch.id, scratch.currentPose, 'Edit anchors', scratch.origins);\n } finally {\n snapAnchor.end();\n endExtensionDrags(scratch.drags);\n }\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n // A path-edit tool has the drag.\n enabled: (deps) => (pathEditToolActive(deps) ? ActionDisabledReason.NotApplicable : true),\n}, editingLayer);\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA6EA,SAAS,sBACP,MAC6E;CAC7E,MAAM,IAAI,KAAK,MAAM,uCAAuC;CAC5D,IAAI,CAAC,GAAG,OAAO;CACf,OAAO;EACL,aAAa,SAAS,EAAE,IAAI,EAAE;EAC9B,MAAM,EAAE;CACV;AACF;;;;;;;;AASA,SAAgB,0BACd,SACA,aACA,UACa;CACb,IAAI,UAAU;EACZ,MAAM,OAAO,IAAI,IAAI,OAAO;EAC5B,IAAI,KAAK,IAAI,WAAW,GAAG,KAAK,OAAO,WAAW;OAC7C,KAAK,IAAI,WAAW;EACzB,OAAO;CACT;CACA,IAAI,QAAQ,IAAI,WAAW,KAAK,QAAQ,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO;CACxE,uBAAO,IAAI,IAAI,CAAC,WAAW,CAAC;AAC9B;;;;;;;AAyCA,SAAS,eACP,MACA,OACoE;CACpE,IAAI,UAA8B;CAClC,OAAO;EACL,GAAG,OAAO,MAAM;GACd,IAAI,CAAC,SAAS;IACZ,MAAM,EAAE,MAAM,YAAY,oBAAoB,MAAM,YAAY,MAAM,QAAQ;IAC9E,MAAM,MAAiB;KACrB,SAAS;KAAS,OAAO,MAAM;KAAQ,KAAK,CAAC,MAAM,EAAE;KACrD,MAAM;MAAE,OAAO,CAAC,IAAI;MAAG;KAAQ;KAAG,WAAW;IAC/C;IACA,UAAU,MAAM,MAAM,GAAG,KAAK,aAAa,GAAG;GAChD;GACA,OAAO,QAAQ,GAAG,OAAO,IAAI,CAAC,CAAC;EACjC;EACA,MAAM;GACJ,SAAS,IAAI;GACb,UAAU;EACZ;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QAAQ;GACvB;EACF;CACF;CAEA,UAAU,SAAU,mBAAmB,IAAI,IAAI,qBAAqB,gBAAgB;AACtF,GAAG,YAAY"}
1
+ {"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/edit-anchors/action.ts"],"sourcesContent":["/**\n * `editAnchorsAction` — ongoing Action descriptor for editing polygon anchors.\n *\n * - **Press** selects. Bare press replaces the anchor selection; Shift\n * toggles the pressed anchor in or out of it. Pressing an anchor that\n * is already part of a multi-anchor selection leaves the selection\n * alone, so you can grab a set and move it.\n * - **Drag** then moves whatever the press left selected — one anchor,\n * or every selected anchor together. The pressed anchor snaps through\n * the `snap` dep's `point` session, to what the drag leaves still of the\n * path and to the canvas's targets; Shift holds it to the axes and\n * diagonals through its press, and Ctrl suspends the snap.\n * - **Dragging a control handle** moves just that handle, mirroring the\n * opposite one while the anchor is smooth. Alt breaks the mirror; Shift\n * holds the handle to the angle it had at the press, changing only its\n * length; Mod (Cmd or Ctrl) holds its length, changing only its angle;\n * both freeze it. The `editAnchors` dep's `handleLocks`, or else the\n * `handleLock` param ({@link EditAnchorsParams}), holds a lock with no\n * modifier. The lock in force draws its guide as a `polyline` overlay\n * of role `lock`: the line, or the circle round the anchor.\n * - **Path-edit extensions shape the drag** through their `drag`: anchors\n * that follow an anchor drag by a share of it, where a dragged handle\n * goes after the locks, the wheel mid-drag, and overlays of their own.\n * - **Every frame is finished** by the dep's `finishEdit`, so what a\n * path-edit extension keeps true holds while the drag runs.\n * - **Under a `pathSymmetry` dep**, on a path that is its own image under\n * some of its transforms, every image of what is dragged follows it.\n *\n * Selection lives on the `editAnchors` dep (flat anchor indices) rather\n * than in this handle's scratch, because the keyboard actions\n * (`nudgeAnchors`, `deleteAnchors`) and the overlay all need to read it\n * between gestures.\n *\n * Operational when the consumer wires the `editAnchors` dep, and\n * `buildAffordanceAt` with a `getAnchorState` thunk so the dispatcher\n * classifies anchor/control-handle hits as `anchor:N`, `controlIn:N`, or\n * `controlOut:N` affordances on pointerdown. On any other affordance `start`\n * returns `{}` so other bindings can handle the drag.\n */\n\nimport type { Action } from '@weasel-js/routing';\nimport type { BindingOpts, InvocationCtx, OngoingHandle, OngoingOverlay, WorldPoint } from '@weasel-js/routing';\nimport type { EditAnchorsDep, SnapDep } from '../depSchema';\nimport type { SnapBegin, SnapMods, SnapSession } from '../snapDep';\nimport { inputSession } from 'domains/snap/session2d';\nimport { SNAP_ROLES, snapMods } from 'domains/snap/roles';\nimport { isAnchorOrControl, resolveParams, roleReader, type ModifierRoles } from '@weasel-js/routing';\nimport {\n anchorAt,\n editAnchorSetTracked,\n moveHandleSymmetric,\n moveHandleTo,\n pathAwayFromAnchors,\n translateAnchorsSymmetric,\n type AnchorSet,\n type AnchorSymmetry,\n type PenAnchor,\n type PointOrigin,\n} from '@weasel-js/geom';\nimport { pathToAnchors, type PolygonPath } from '@weasel-js/geom';\nimport { inPlane, editingLayer } from '../planeInput';\nimport { HANDLE_LOCK_ROLES, lockHandle, locksInForce, type HandlePress } from './handleDrag';\nimport { locksOf, type EditAnchorsParams } from './params';\nimport { finishPathEditFrame, pathEditPreview } from './preview';\nimport {\n claimWheel, dragWeights, endExtensionDrags, extensionOverlays, placeHandle, startExtensionDrags, translateWeighted,\n} from './extensionDrags';\nimport type { PathEditDrag } from 'domains/paths/pathEditExtension';\nimport { editedPathSymmetries } from './symmetry';\nimport { pathOperationTags } from '../pathGestureTags';\n\n/**\n * Parse an anchor affordance kind — `'anchor:N'` | `'controlIn:N'` |\n * `'controlOut:N'`, where N is the flat anchor index — or `null` when the\n * affordance is not an anchor kind.\n */\nfunction parseAnchorAffordance(\n kind: string,\n): { anchorIndex: number; part: 'anchor' | 'controlIn' | 'controlOut' } | null {\n const m = kind.match(/^(anchor|controlIn|controlOut):(\\d+)$/);\n if (!m) return null;\n return {\n anchorIndex: parseInt(m[2], 10),\n part: m[1] as 'anchor' | 'controlIn' | 'controlOut',\n };\n}\n\n/**\n * Resolve what a press on `anchorIndex` should leave selected.\n *\n * Shift toggles. A bare press on an anchor that's already part of the\n * selection keeps the selection intact (so the drag moves the whole set);\n * a bare press anywhere else collapses to just that anchor.\n */\nexport function selectionAfterAnchorPress(\n current: ReadonlySet<number>,\n anchorIndex: number,\n additive: boolean,\n): Set<number> {\n if (additive) {\n const next = new Set(current);\n if (next.has(anchorIndex)) next.delete(anchorIndex);\n else next.add(anchorIndex);\n return next;\n }\n if (current.has(anchorIndex) && current.size > 1) return new Set(current);\n return new Set([anchorIndex]);\n}\n\ninterface EditAnchorsScratch {\n dep: EditAnchorsDep;\n id: string;\n anchorIndex: number;\n /** `'anchor'` drags on-curve points (and their handles) by a delta.\n * `'controlIn'` / `'controlOut'` drag one control point to an absolute\n * world coord. */\n part: 'anchor' | 'controlIn' | 'controlOut';\n /** Anchors this drag moves — the pressed one, or the whole anchor\n * selection when the press landed inside it. Flat indices. */\n dragging: readonly number[];\n /** World position of the pressed anchor at drag start; the drag delta is\n * measured from here rather than accumulated per move, so the geometry\n * is always derived from `originPose` in one step. */\n anchorOrigin: { x: number; y: number };\n /** The anchor and the dragged control handle at the press, for a handle drag. */\n handlePress: HandlePress | null;\n /** The guide the lock in force drew at the last move. */\n guide: OngoingOverlay | null;\n /** The path-edit extensions' shares of this drag. */\n drags: readonly PathEditDrag[];\n /** The last move, to redo when an extension claims the wheel. */\n lastMove: InvocationCtx | null;\n originPose: PolygonPath;\n currentPose: PolygonPath;\n /** The transforms `originPose` is its own image under, read at the press. */\n symmetries: readonly AnchorSymmetry[];\n /** Where each point of `currentPose` came from in `originPose`. */\n origins?: readonly (PointOrigin | null)[];\n /** Other nodes' world paths the finished edit moves with it. */\n others: readonly { id: string; path: PolygonPath }[];\n}\n\n/**\n * An anchor drag's snap: a `point` session, begun on the first move, for\n * where the pressed anchor goes. The edited path offers no targets but what\n * the drag leaves still of it, and Shift holds the anchor to the axes and\n * diagonals through its press.\n */\nfunction anchorDragSnap(\n snap: SnapDep | undefined,\n press: { id: string; origin: WorldPoint; originPose: PolygonPath; dragging: readonly number[] },\n): { at(world: WorldPoint, mods: SnapMods): WorldPoint; end(): void } {\n let session: SnapSession | null = null;\n return {\n at(world, mods) {\n if (!session) {\n const { path, anchors } = pathAwayFromAnchors(press.originPose, press.dragging);\n const req: SnapBegin = {\n gesture: 'point', press: press.origin, ids: [press.id],\n also: { paths: [path], anchors }, constrain: 'axis',\n };\n session = snap?.begin(req) ?? inputSession(req);\n }\n return session.at(world, mods).point;\n },\n end() {\n session?.end();\n session = null;\n },\n };\n}\n\nconst paramsOf = (opts: BindingOpts | undefined): EditAnchorsParams =>\n (resolveParams(opts?.params) ?? {}) as EditAnchorsParams;\n\n/** Take `next` as the frame to show, finished by the dep. A frame it cannot\n * finish is dropped, so the path stays at the last one it could. */\nfunction track(scratch: EditAnchorsScratch, next: ReturnType<typeof editAnchorSetTracked>): void {\n if (!next) return;\n const { dep, id } = scratch;\n const done = finishPathEditFrame(dep, id, next.path, next.origins);\n if (!done) return;\n scratch.currentPose = done.path as PolygonPath;\n scratch.others = done.others as EditAnchorsScratch['others'];\n scratch.origins = next.origins;\n}\n\n/** The anchor and the handle a press on `part` grabbed; null for an anchor press. */\nfunction handlePressOf(\n origin: PenAnchor,\n part: EditAnchorsScratch['part'],\n): HandlePress | null {\n const handle = part === 'controlIn' ? origin.inHandle : part === 'controlOut' ? origin.outHandle : undefined;\n return handle ? { anchor: { x: origin.x, y: origin.y }, handle: { ...handle } } : null;\n}\n\n/** Move the dragged anchors to follow `to`, and the anchors the extensions\n * weight by their shares. A weighted drag moves no symmetric images. */\nfunction moveAnchors(scratch: EditAnchorsScratch, to: WorldPoint): void {\n if (scratch.dragging.length === 0) return;\n const dx = to.x - scratch.anchorOrigin.x;\n const dy = to.y - scratch.anchorOrigin.y;\n const weights = dragWeights(scratch.drags, scratch.dragging);\n track(scratch, editAnchorSetTracked(scratch.originPose, (set) => {\n if (weights) translateWeighted(set, weights, dx, dy);\n else translateAnchorsSymmetric(set, scratch.dragging, dx, dy, scratch.symmetries);\n }));\n}\n\n/** The modifiers `editAnchors` reads while it runs: Shift on the press adds\n * to the anchor selection, Alt breaks a smooth anchor's mirror, the handle\n * locks, and Shift holds an anchor drag to the axes and diagonals. An anchor\n * drag also reads `snap.suspend` at its default key, Ctrl, which is not\n * declared here because on a handle Ctrl holds the length. */\nexport const EDIT_ANCHORS_ROLES = {\n 'selection.add': { label: 'Add to the anchor selection', keys: ['shift'] },\n 'mirror.break': { label: \"Break the handles' mirror\", keys: ['alt'] },\n ...HANDLE_LOCK_ROLES,\n 'snap.constrain': SNAP_ROLES['snap.constrain'],\n} as const satisfies ModifierRoles;\n\nconst roleHeld = roleReader(EDIT_ANCHORS_ROLES);\n\n/** Move the dragged handle toward the pointer, under the locks in force, then\n * wherever the extensions place it. */\nfunction moveHandle(scratch: EditAnchorsScratch, ctx: InvocationCtx, params: EditAnchorsParams): void {\n const side = scratch.part === 'controlIn' ? 'in' : 'out';\n // Modifiers and held locks are read live, so either can change mid-drag.\n const held = (ctx.deps.editAnchors ?? scratch.dep).handleLocks ?? locksOf(params.handleLock);\n const locks = locksInForce(held, ctx);\n const locked = scratch.handlePress ? lockHandle(scratch.handlePress, ctx.world, locks) : { to: ctx.world, guide: null };\n scratch.guide = locked.guide;\n const to = placeHandle(scratch.drags, locked.to, { locks });\n const alt = roleHeld(ctx, 'mirror.break');\n const move = scratch.symmetries.length > 0\n ? (set: AnchorSet) => moveHandleSymmetric(set, scratch.anchorIndex, side, to.x, to.y, alt, scratch.symmetries)\n : (set: AnchorSet) => moveHandleTo(set, scratch.anchorIndex, side, to.x, to.y, alt);\n track(scratch, editAnchorSetTracked(scratch.originPose, move));\n}\n\n/**\n * What a press drags, the selection updated first, before any move: a handle\n * press drags its anchor's handle; an anchor press selects as\n * {@link selectionAfterAnchorPress} says and drags what it left selected —\n * nothing when Shift took the pressed anchor out of it.\n */\nfunction draggedByPress(\n dep: EditAnchorsDep,\n press: { anchorIndex: number; part: EditAnchorsScratch['part'] },\n shift: boolean,\n): readonly number[] {\n if (press.part !== 'anchor') return [press.anchorIndex];\n const next = selectionAfterAnchorPress(dep.selectedAnchors, press.anchorIndex, shift);\n dep.setSelectedAnchors(next);\n return next.has(press.anchorIndex) ? [...next] : [];\n}\n\n/** Static descriptor for the `editAnchors` Action. */\nexport const editAnchorsAction: Action & { requires: string[] } = inPlane({\n id: 'editAnchors',\n label: 'Edit Anchors',\n tags: pathOperationTags('drag'),\n defaultBinding: [{\n spec: {\n kind: 'drag',\n // Only matches drags whose pointerdown hit an anchor or control handle.\n // Ties moveAction's `selected-body` on specificity and registers after\n // it, so move declines these presses in `start`.\n target: { kindOf: isAnchorOrControl },\n },\n opts: { id: 'editAnchors.drag' },\n }],\n cursor: 'pointer',\n eligible: { capability: 'edits-anchors' },\n modifierRoles: EDIT_ANCHORS_ROLES,\n requires: ['selection', 'editAnchors', 'pathSymmetry', 'snap'],\n invoker: {\n timing: 'ongoing',\n start(ctx: InvocationCtx, opts): OngoingHandle {\n const dep = ctx.deps.editAnchors;\n if (!dep) return {};\n\n const affordance = ctx.drag?.affordance;\n if (!affordance) {\n // No affordance hit → this drag doesn't target an anchor handle.\n // Let other bindings handle it (the handle returns {}, dispatcher moves on).\n return {};\n }\n\n const anchorInfo = parseAnchorAffordance(affordance.kind);\n if (!anchorInfo) {\n // Affordance is a non-anchor kind (e.g. resize handle, rotate handle).\n return {};\n }\n\n const { editingId } = dep;\n // World-coord polygon. For pose-as-polygon nodes this equals\n // node.pose; for data.path nodes it's pathInWorld-projected (translate +\n // rotation) so the anchor world coords match what the user clicked.\n const worldPath = dep.getEditablePath(editingId) as PolygonPath | undefined;\n if (!worldPath || worldPath.kind !== 'polygon') return {};\n\n // Decode once to validate the affordance index against the actual\n // geometry and to read the press origin. A stale affordance (the\n // path changed between pointerdown and now) fails here rather than\n // silently editing whichever anchor now holds that index.\n const decoded = pathToAnchors(worldPath) as AnchorSet;\n const origin = anchorAt(decoded, anchorInfo.anchorIndex);\n if (!origin) return {};\n if (anchorInfo.part === 'controlIn' && !origin.inHandle) return {};\n if (anchorInfo.part === 'controlOut' && !origin.outHandle) return {};\n\n let active = false;\n const preview = pathEditPreview(\n dep, editingId, () => (active ? { path: scratch.currentPose } : null), () => (active ? scratch.others : []),\n );\n if (!preview) return {};\n\n const dragging = draggedByPress(dep, anchorInfo, roleHeld(ctx, 'selection.add'));\n\n const scratch: EditAnchorsScratch = {\n dep,\n id: editingId,\n anchorIndex: anchorInfo.anchorIndex,\n part: anchorInfo.part,\n dragging,\n anchorOrigin: { x: origin.x, y: origin.y },\n handlePress: handlePressOf(origin, anchorInfo.part),\n guide: null,\n drags: startExtensionDrags(dep.extensions, {\n id: editingId,\n node: dep.getNodeShape(editingId),\n path: worldPath,\n anchors: decoded,\n part: anchorInfo.part,\n anchorIndex: anchorInfo.anchorIndex,\n dragging: anchorInfo.part === 'anchor' ? dragging : [],\n scale: ctx.deps.view?.get().scale,\n ...(ctx.deps.snap ? { snap: ctx.deps.snap } : {}),\n }),\n lastMove: null,\n originPose: worldPath,\n currentPose: worldPath,\n symmetries: editedPathSymmetries(ctx.deps.pathSymmetry, editingId, decoded),\n others: [],\n };\n const snapAnchor = anchorDragSnap(ctx.deps.snap, {\n id: editingId, origin: scratch.anchorOrigin, originPose: worldPath, dragging,\n });\n\n const move = (moveCtx: InvocationCtx): void => {\n scratch.lastMove = moveCtx;\n if (scratch.part !== 'anchor') return moveHandle(scratch, moveCtx, paramsOf(opts));\n moveAnchors(scratch, snapAnchor.at(moveCtx.world, snapMods(moveCtx)));\n };\n\n return {\n kind: 'edit-anchors',\n onMove(moveCtx: InvocationCtx): void {\n move(moveCtx);\n active = true;\n },\n onWheel(wheelCtx: InvocationCtx): boolean {\n if (!wheelCtx.wheel || !claimWheel(scratch.drags, wheelCtx.wheel)) return false;\n if (scratch.lastMove) move(scratch.lastMove);\n return true;\n },\n overlay(): readonly OngoingOverlay[] | null {\n if (!active) return null;\n const extra = scratch.drags.length > 0\n ? extensionOverlays(scratch.drags, pathToAnchors(scratch.currentPose) as AnchorSet)\n : [];\n const all = scratch.guide ? [scratch.guide, ...extra] : extra;\n return all.length > 0 ? all : null;\n },\n onEnd(_endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n active = false;\n try {\n if (reason === 'cancel' || scratch.originPose === scratch.currentPose) return;\n scratch.dep.applyEdit(scratch.id, scratch.currentPose, 'Edit anchors', scratch.origins);\n } finally {\n snapAnchor.end();\n endExtensionDrags(scratch.drags);\n }\n },\n previewIds: preview.previewIds,\n previewPose: preview.previewPose,\n previewData: preview.previewData,\n };\n },\n },\n}, editingLayer);\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4EA,SAAS,sBACP,MAC6E;CAC7E,MAAM,IAAI,KAAK,MAAM,uCAAuC;CAC5D,IAAI,CAAC,GAAG,OAAO;CACf,OAAO;EACL,aAAa,SAAS,EAAE,IAAI,EAAE;EAC9B,MAAM,EAAE;CACV;AACF;;;;;;;;AASA,SAAgB,0BACd,SACA,aACA,UACa;CACb,IAAI,UAAU;EACZ,MAAM,OAAO,IAAI,IAAI,OAAO;EAC5B,IAAI,KAAK,IAAI,WAAW,GAAG,KAAK,OAAO,WAAW;OAC7C,KAAK,IAAI,WAAW;EACzB,OAAO;CACT;CACA,IAAI,QAAQ,IAAI,WAAW,KAAK,QAAQ,OAAO,GAAG,OAAO,IAAI,IAAI,OAAO;CACxE,uBAAO,IAAI,IAAI,CAAC,WAAW,CAAC;AAC9B;;;;;;;AAyCA,SAAS,eACP,MACA,OACoE;CACpE,IAAI,UAA8B;CAClC,OAAO;EACL,GAAG,OAAO,MAAM;GACd,IAAI,CAAC,SAAS;IACZ,MAAM,EAAE,MAAM,YAAY,oBAAoB,MAAM,YAAY,MAAM,QAAQ;IAC9E,MAAM,MAAiB;KACrB,SAAS;KAAS,OAAO,MAAM;KAAQ,KAAK,CAAC,MAAM,EAAE;KACrD,MAAM;MAAE,OAAO,CAAC,IAAI;MAAG;KAAQ;KAAG,WAAW;IAC/C;IACA,UAAU,MAAM,MAAM,GAA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,gBAAgB,QAAQ,OAAO;KACxF,UAAU;MACR,WAAW,IAAI;MACf,kBAAkB,QAAQ,KAAK;KACjC;IACF;IACA,YAAY,QAAQ;IACpB,aAAa,QAAQ;IACrB,aAAa,QAAQ;GACvB;EACF;CACF;AACF,GAAG,YAAY"}
@@ -8,6 +8,7 @@ import { insertKind, insertShape } from "./shape.js";
8
8
  import { cancelInsert, commitInsert } from "./commit.js";
9
9
  import { beginInsert } from "./session.js";
10
10
  import { carryStart, nextFrame } from "./frame.js";
11
+ import { insertParams } from "./params.js";
11
12
  import { resolveParams } from "@weasel-js/routing";
12
13
 
13
14
  //#region src/interactions/actions/insert/action.ts
@@ -28,6 +29,10 @@ var INSERT_DRAG_THRESHOLD_PX = 8;
28
29
  * The new node has no scene id until commit, so the live preview is the
29
30
  * `overlay()` surface with `kind: 'insertPreview'`. A consumer-defined kind
30
31
  * the kit cannot draw skips the preview and still commits on release.
32
+ *
33
+ * A polygon's or a star's insert is the last operation once it commits, so a
34
+ * panel can change its sides, or its points and inner radius, by replaying the
35
+ * drag (`insertParams`); a drag that behaviors answered does not replay.
31
36
  */
32
37
  var insertAction = inPlane({
33
38
  id: "insert",
@@ -48,6 +53,7 @@ var insertAction = inPlane({
48
53
  "view",
49
54
  "kitSettings"
50
55
  ],
56
+ params: insertParams,
51
57
  invoker: {
52
58
  timing: "ongoing",
53
59
  dragThresholdPx: INSERT_DRAG_THRESHOLD_PX,
@@ -61,6 +67,7 @@ var insertAction = inPlane({
61
67
  userRotation: 0,
62
68
  repositioning: false
63
69
  };
70
+ let trail = null;
64
71
  const live = ctx.deps.insertLive;
65
72
  if (live) live.gesture = gesture;
66
73
  const scene = ctx.deps.scene;
@@ -94,12 +101,24 @@ var insertAction = inPlane({
94
101
  let committed = false;
95
102
  try {
96
103
  if (reason === "cancel") cancelInsert(session);
97
- else committed = commitInsert(session, frame, endCtx.drag?.points ?? frame.points, gesture.userRotation);
104
+ else {
105
+ trail = endCtx.drag?.points ?? frame.points;
106
+ committed = commitInsert(session, frame, trail, gesture.userRotation);
107
+ }
98
108
  } finally {
99
109
  session.snap.close();
100
110
  runBehaviorSettled(session.behaviors, session.gestureCtx, committed);
101
111
  }
102
- }
112
+ },
113
+ ...session.behaviors.length === 0 ? { replay(params) {
114
+ commitInsert({
115
+ ...session,
116
+ opts: {
117
+ ...session.opts,
118
+ params
119
+ }
120
+ }, frame, trail, gesture.userRotation);
121
+ } } : {}
103
122
  };
104
123
  }
105
124
  },
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/insert/action.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { InvocationCtx, OngoingHandle, BindingOpts, OngoingOverlay } from '@weasel-js/routing';\nimport { resolveParams } from '@weasel-js/routing';\nimport { shapeKindInfo } from 'core/shapeKinds';\nimport type { KitInsertShape } from 'core/shapeKinds';\nimport { SNAP_ROLES } from 'domains/snap/roles';\nimport { runBehaviorSettled } from '../gestureLifecycle';\nimport { inPlane, insertLayer } from '../planeInput';\nimport { copiesWithin } from 'canvas/copiesAbove';\nimport { scenePaintedPoseOf } from 'canvas/derivedPath';\nimport { cancelInsert, commitInsert } from './commit';\nimport { carryStart, nextFrame } from './frame';\nimport type { InsertLiveGesture } from './live';\nimport { beginInsert } from './session';\nimport { insertKind, insertShape } from './shape';\n\n/** How far, in CSS pixels, a drag travels before it draws a shape: past the wobble of a click, so a\n * press that drifts a few pixels draws nothing rather than a shape a few pixels wide. */\nexport const INSERT_DRAG_THRESHOLD_PX = 8;\n\n/**\n * Drag-to-insert. The node `kind` is read from `opts.params.kind`.\n *\n * The drag's start and current point snap through the `snap` dep's `point`\n * sessions (never freehand pencil samples). While `snap.constrain` (Shift) is\n * held, a line's end stays on the 15° line through the snapped start nearest\n * the pointer, and lands where that line meets a target. Behaviors from the\n * binding's `opts.behaviors` (`InsertBehavior[]`) run over the two points\n * after that; on release the first answer wins (`null` aborts, `Op[]` commits\n * in place of the insert).\n *\n * The new node has no scene id until commit, so the live preview is the\n * `overlay()` surface with `kind: 'insertPreview'`. A consumer-defined kind\n * the kit cannot draw skips the preview and still commits on release.\n */\nexport const insertAction: Action & { requires: string[] } = inPlane({\n id: 'insert',\n label: 'Insert',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n modifierRoles: SNAP_ROLES,\n requires: ['insert', 'insertLive', 'insertInto', 'canDropInto', 'selection', 'snap', 'textEdit', 'scene', 'applyOps', 'view', 'kitSettings'],\n invoker: {\n timing: 'ongoing',\n dragThresholdPx: INSERT_DRAG_THRESHOLD_PX,\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n const begun = beginInsert(ctx, opts);\n if (!begun) return {};\n const { session, readers } = begun;\n let frame = begun.frame;\n const gesture: InsertLiveGesture = { open: true, userRotation: 0, repositioning: false };\n const live = ctx.deps.insertLive;\n if (live) live.gesture = gesture;\n // Where the shape will land decides the copies it will be drawn in.\n const scene = ctx.deps.scene;\n const copies = scene ? copiesWithin(scene, session.parent, scenePaintedPoseOf(scene)) : [];\n\n return {\n kind: 'insert',\n onMove(moveCtx: InvocationCtx): void {\n if (gesture.repositioning) carryStart(session, frame.pointer, moveCtx.world, moveCtx);\n frame = nextFrame(session, readers, frame, moveCtx);\n },\n overlay(): OngoingOverlay | null {\n if (!gesture.open) return null;\n // Resolve params on every overlay() so thunked params (polygon\n // sides ticking via ArrowUp mid-drag) reflect in the live preview.\n const resolved = resolveParams(session.opts?.params);\n if (!shapeKindInfo(insertKind(resolved))?.insertPreview) return null;\n const { bounds, extras, start } = insertShape(resolved, frame, frame.points, gesture.userRotation);\n return {\n kind: 'insertPreview',\n shape: extras.kind as KitInsertShape,\n bounds,\n extras,\n // Anchor dot at the click point: radial shapes have no vertex\n // there, and in center mode it marks the growth axis.\n anchorPoint: { x: start.x, y: start.y },\n ...(copies.length > 0 ? { copies } : {}),\n };\n },\n onEnd(endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n gesture.open = false;\n if (live?.gesture === gesture) live.gesture = null;\n let committed = false;\n try {\n if (reason === 'cancel') cancelInsert(session);\n else committed = commitInsert(session, frame, endCtx.drag?.points ?? frame.points, gesture.userRotation);\n } finally {\n session.snap.close();\n runBehaviorSettled(session.behaviors, session.gestureCtx, committed);\n }\n },\n };\n },\n },\n /** Insert needs no selection; anything but `true` blocks dispatcher-routed inserts. */\n enabled: () => true as const,\n}, insertLayer);\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAa,2BAA2B;;;;;;;;;;;;;;;;AAiBxC,IAAa,eAAgD,QAAQ;CACnE,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,EAAE,YAAY,iBAAiB;CACzC,eAAe;CACf,UAAU;EAAC;EAAU;EAAc;EAAc;EAAe;EAAa;EAAQ;EAAY;EAAS;EAAY;EAAQ;CAAa;CAC3I,SAAS;EACP,QAAQ;EACR,iBAAiB;EACjB,MAAM,KAAoB,MAAmC;GAC3D,MAAM,QAAQ,YAAY,KAAK,IAAI;GACnC,IAAI,CAAC,OAAO,OAAO,CAAC;GACpB,MAAM,EAAE,SAAS,YAAY;GAC7B,IAAI,QAAQ,MAAM;GAClB,MAAM,UAA6B;IAAE,MAAM;IAAM,cAAc;IAAG,eAAe;GAAM;GACvF,MAAM,OAAO,IAAI,KAAK;GACtB,IAAI,MAAM,KAAK,UAAU;GAEzB,MAAM,QAAQ,IAAI,KAAK;GACvB,MAAM,SAAS,QAAQ,aAAa,OAAO,QAAQ,QAAQ,mBAAmB,KAAK,CAAC,IAAI,CAAC;GAEzF,OAAO;IACL,MAAM;IACN,OAAO,SAA8B;KACnC,IAAI,QAAQ,eAAe,WAAW,SAAS,MAAM,SAAS,QAAQ,OAAO,OAAO;KACpF,QAAQ,UAAU,SAAS,SAAS,OAAO,OAAO;IACpD;IACA,UAAiC;KAC/B,IAAI,CAAC,QAAQ,MAAM,OAAO;KAG1B,MAAM,WAAW,cAAc,QAAQ,MAAM,MAAM;KACnD,IAAI,CAAC,cAAc,WAAW,QAAQ,CAAC,CAAC,EAAE,eAAe,OAAO;KAChE,MAAM,EAAE,QAAQ,QAAQ,UAAU,YAAY,UAAU,OAAO,MAAM,QAAQ,QAAQ,YAAY;KACjG,OAAO;MACL,MAAM;MACN,OAAO,OAAO;MACd;MACA;MAGA,aAAa;OAAE,GAAG,MAAM;OAAG,GAAG,MAAM;MAAE;MACtC,GAAI,OAAO,SAAS,IAAI,EAAE,OAAO,IAAI,CAAC;KACxC;IACF;IACA,MAAM,QAAuB,QAAmC;KAC9D,QAAQ,OAAO;KACf,IAAI,MAAM,YAAY,SAAS,KAAK,UAAU;KAC9C,IAAI,YAAY;KAChB,IAAI;MACF,IAAI,WAAW,UAAU,aAAa,OAAO;WACxC,YAAY,aAAa,SAAS,OAAO,OAAO,MAAM,UAAU,MAAM,QAAQ,QAAQ,YAAY;KACzG,UAAU;MACR,QAAQ,KAAK,MAAM;MACnB,mBAAmB,QAAQ,WAAW,QAAQ,YAAY,SAAS;KACrE;IACF;GACF;EACF;CACF;;CAEA,eAAe;AACjB,GAAG,WAAW"}
1
+ {"version":3,"file":"action.js","names":[],"sources":["../../../../src/interactions/actions/insert/action.ts"],"sourcesContent":["import type { Action } from '@weasel-js/routing';\nimport type { DragSample, InvocationCtx, OngoingHandle, BindingOpts, OngoingOverlay } from '@weasel-js/routing';\nimport { resolveParams } from '@weasel-js/routing';\nimport { shapeKindInfo } from 'core/shapeKinds';\nimport type { KitInsertShape } from 'core/shapeKinds';\nimport { SNAP_ROLES } from 'domains/snap/roles';\nimport { runBehaviorSettled } from '../gestureLifecycle';\nimport { inPlane, insertLayer } from '../planeInput';\nimport { copiesWithin } from 'canvas/copiesAbove';\nimport { scenePaintedPoseOf } from 'canvas/derivedPath';\nimport { cancelInsert, commitInsert } from './commit';\nimport { carryStart, nextFrame } from './frame';\nimport type { InsertLiveGesture } from './live';\nimport { insertParams } from './params';\nimport { beginInsert } from './session';\nimport { insertKind, insertShape } from './shape';\n\n/** How far, in CSS pixels, a drag travels before it draws a shape: past the wobble of a click, so a\n * press that drifts a few pixels draws nothing rather than a shape a few pixels wide. */\nexport const INSERT_DRAG_THRESHOLD_PX = 8;\n\n/**\n * Drag-to-insert. The node `kind` is read from `opts.params.kind`.\n *\n * The drag's start and current point snap through the `snap` dep's `point`\n * sessions (never freehand pencil samples). While `snap.constrain` (Shift) is\n * held, a line's end stays on the 15° line through the snapped start nearest\n * the pointer, and lands where that line meets a target. Behaviors from the\n * binding's `opts.behaviors` (`InsertBehavior[]`) run over the two points\n * after that; on release the first answer wins (`null` aborts, `Op[]` commits\n * in place of the insert).\n *\n * The new node has no scene id until commit, so the live preview is the\n * `overlay()` surface with `kind: 'insertPreview'`. A consumer-defined kind\n * the kit cannot draw skips the preview and still commits on release.\n *\n * A polygon's or a star's insert is the last operation once it commits, so a\n * panel can change its sides, or its points and inner radius, by replaying the\n * drag (`insertParams`); a drag that behaviors answered does not replay.\n */\nexport const insertAction: Action & { requires: string[] } = inPlane({\n id: 'insert',\n label: 'Insert',\n group: 'insert',\n eligible: { capability: 'creates-shapes' },\n modifierRoles: SNAP_ROLES,\n requires: ['insert', 'insertLive', 'insertInto', 'canDropInto', 'selection', 'snap', 'textEdit', 'scene', 'applyOps', 'view', 'kitSettings'],\n params: insertParams,\n invoker: {\n timing: 'ongoing',\n dragThresholdPx: INSERT_DRAG_THRESHOLD_PX,\n start(ctx: InvocationCtx, opts?: BindingOpts): OngoingHandle {\n const begun = beginInsert(ctx, opts);\n if (!begun) return {};\n const { session, readers } = begun;\n let frame = begun.frame;\n const gesture: InsertLiveGesture = { open: true, userRotation: 0, repositioning: false };\n let trail: readonly DragSample[] | null = null;\n const live = ctx.deps.insertLive;\n if (live) live.gesture = gesture;\n // Where the shape will land decides the copies it will be drawn in.\n const scene = ctx.deps.scene;\n const copies = scene ? copiesWithin(scene, session.parent, scenePaintedPoseOf(scene)) : [];\n\n return {\n kind: 'insert',\n onMove(moveCtx: InvocationCtx): void {\n if (gesture.repositioning) carryStart(session, frame.pointer, moveCtx.world, moveCtx);\n frame = nextFrame(session, readers, frame, moveCtx);\n },\n overlay(): OngoingOverlay | null {\n if (!gesture.open) return null;\n // Resolve params on every overlay() so thunked params (polygon\n // sides ticking via ArrowUp mid-drag) reflect in the live preview.\n const resolved = resolveParams(session.opts?.params);\n if (!shapeKindInfo(insertKind(resolved))?.insertPreview) return null;\n const { bounds, extras, start } = insertShape(resolved, frame, frame.points, gesture.userRotation);\n return {\n kind: 'insertPreview',\n shape: extras.kind as KitInsertShape,\n bounds,\n extras,\n // Anchor dot at the click point: radial shapes have no vertex\n // there, and in center mode it marks the growth axis.\n anchorPoint: { x: start.x, y: start.y },\n ...(copies.length > 0 ? { copies } : {}),\n };\n },\n onEnd(endCtx: InvocationCtx, reason: 'commit' | 'cancel'): void {\n gesture.open = false;\n if (live?.gesture === gesture) live.gesture = null;\n let committed = false;\n try {\n if (reason === 'cancel') cancelInsert(session);\n else {\n trail = endCtx.drag?.points ?? frame.points;\n committed = commitInsert(session, frame, trail, gesture.userRotation);\n }\n } finally {\n session.snap.close();\n runBehaviorSettled(session.behaviors, session.gestureCtx, committed);\n }\n },\n // A behavior's answer is its own to make once, so only a plain insert replays.\n ...(session.behaviors.length === 0 ? {\n replay(params: Record<string, unknown>): void {\n commitInsert({ ...session, opts: { ...session.opts, params } }, frame, trail, gesture.userRotation);\n },\n } : {}),\n };\n },\n },\n /** Insert needs no selection; anything but `true` blocks dispatcher-routed inserts. */\n enabled: () => true as const,\n}, insertLayer);\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAa,2BAA2B;;;;;;;;;;;;;;;;;;;;AAqBxC,IAAa,eAAgD,QAAQ;CACnE,IAAI;CACJ,OAAO;CACP,OAAO;CACP,UAAU,EAAE,YAAY,iBAAiB;CACzC,eAAe;CACf,UAAU;EAAC;EAAU;EAAc;EAAc;EAAe;EAAa;EAAQ;EAAY;EAAS;EAAY;EAAQ;CAAa;CAC3I,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,iBA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,YAAY;MACtE;KACF,UAAU;MACR,QAAQ,KAAK,MAAM;MACnB,mBAAmB,QAAQ,WAAW,QAAQ,YAAY,SAAS;KACrE;IACF;IAEA,GAAI,QAAQ,UAAU,WAAW,IAAI,EACnC,OAAO,QAAuC;KAC5C,aAAa;MAAE,GAAG;MAAS,MAAM;OAAE,GAAG,QAAQ;OAAM;MAAO;KAAE,GAAG,OAAO,OAAO,QAAQ,YAAY;IACpG,EACF,IAAI,CAAC;GACP;EACF;CACF;;CAEA,eAAe;AACjB,GAAG,WAAW"}
@@ -0,0 +1,43 @@
1
+ import { insertKind } from "./shape.js";
2
+ import { SHAPE_COUNT_RANGE, STAR_RATIO_RANGE } from "../../../domains/paths/shapeGenerator.js";
3
+ import { pref } from "@weasel-js/prefs";
4
+
5
+ //#region src/interactions/actions/insert/params.ts
6
+ /** A polygon insert's params as a form, for the last-operation panel. */
7
+ var POLYGON_INSERT_PARAMS = pref.group("Polygon", { sides: pref.number("Sides", 6, {
8
+ min: SHAPE_COUNT_RANGE.min,
9
+ max: SHAPE_COUNT_RANGE.max,
10
+ step: 1,
11
+ control: "slider"
12
+ }) });
13
+ /** A star insert's params as a form, for the last-operation panel. */
14
+ var STAR_INSERT_PARAMS = pref.group("Star", {
15
+ points: pref.number("Points", 5, {
16
+ min: SHAPE_COUNT_RANGE.min,
17
+ max: SHAPE_COUNT_RANGE.max,
18
+ step: 1,
19
+ control: "slider"
20
+ }),
21
+ innerRadiusRatio: pref.number("Inner radius", .5, {
22
+ description: "Inner radius as a fraction of the outer one.",
23
+ min: STAR_RATIO_RANGE.min,
24
+ max: STAR_RATIO_RANGE.max,
25
+ step: .01,
26
+ control: "slider",
27
+ unit: {
28
+ scale: .01,
29
+ suffix: "%",
30
+ precision: 0
31
+ }
32
+ })
33
+ });
34
+ /** The form an insert of the kind `params` names shows: a polygon's sides, a star's points and inner radius, and
35
+ * none for any other kind. */
36
+ function insertParams(params) {
37
+ const kind = insertKind(params);
38
+ return kind === "polygon" ? POLYGON_INSERT_PARAMS : kind === "star" ? STAR_INSERT_PARAMS : null;
39
+ }
40
+
41
+ //#endregion
42
+ export { POLYGON_INSERT_PARAMS, STAR_INSERT_PARAMS, insertParams };
43
+ //# sourceMappingURL=params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.js","names":[],"sources":["../../../../src/interactions/actions/insert/params.ts"],"sourcesContent":["import { pref, type PrefGroup } from '@weasel-js/prefs';\nimport { SHAPE_COUNT_RANGE, STAR_RATIO_RANGE } from 'domains/paths/shapeGenerator';\nimport { insertKind } from './shape';\n\n/** A polygon insert's params as a form, for the last-operation panel. */\nexport const POLYGON_INSERT_PARAMS = pref.group('Polygon', {\n sides: pref.number('Sides', 6, { min: SHAPE_COUNT_RANGE.min, max: SHAPE_COUNT_RANGE.max, step: 1, control: 'slider' }),\n});\n\n/** A star insert's params as a form, for the last-operation panel. */\nexport const STAR_INSERT_PARAMS = pref.group('Star', {\n points: pref.number('Points', 5, { min: SHAPE_COUNT_RANGE.min, max: SHAPE_COUNT_RANGE.max, step: 1, control: 'slider' }),\n innerRadiusRatio: pref.number('Inner radius', 0.5, {\n description: 'Inner radius as a fraction of the outer one.',\n min: STAR_RATIO_RANGE.min, max: STAR_RATIO_RANGE.max, step: 0.01, control: 'slider',\n unit: { scale: 0.01, suffix: '%', precision: 0 },\n }),\n});\n\n/** The form an insert of the kind `params` names shows: a polygon's sides, a star's points and inner radius, and\n * none for any other kind. */\nexport function insertParams(params: Readonly<Record<string, unknown>>): PrefGroup | null {\n const kind = insertKind(params);\n return kind === 'polygon' ? POLYGON_INSERT_PARAMS : kind === 'star' ? STAR_INSERT_PARAMS : null;\n}\n"],"mappings":";;;;;;AAKA,IAAa,wBAAwB,KAAK,MAAM,WAAW,EACzD,OAAO,KAAK,OAAO,SAAS,GAAG;CAAE,KAAK,kBAAkB;CAAK,KAAK,kBAAkB;CAAK,MAAM;CAAG,SAAS;AAAS,CAAC,EACvH,CAAC;;AAGD,IAAa,qBAAqB,KAAK,MAAM,QAAQ;CACnD,QAAQ,KAAK,OAAO,UAAU,GAAG;EAAE,KAAK,kBAAkB;EAAK,KAAK,kBAAkB;EAAK,MAAM;EAAG,SAAS;CAAS,CAAC;CACvH,kBAAkB,KAAK,OAAO,gBAAgB,IAAK;EACjD,aAAa;EACb,KAAK,iBAAiB;EAAK,KAAK,iBAAiB;EAAK,MAAM;EAAM,SAAS;EAC3E,MAAM;GAAE,OAAO;GAAM,QAAQ;GAAK,WAAW;EAAE;CACjD,CAAC;AACH,CAAC;;;AAID,SAAgB,aAAa,QAA6D;CACxF,MAAM,OAAO,WAAW,MAAM;CAC9B,OAAO,SAAS,YAAY,wBAAwB,SAAS,SAAS,qBAAqB;AAC7F"}
@@ -0,0 +1,17 @@
1
+ //#region src/interactions/actions/notices.ts
2
+ /** Warn the user through `notices`, or under `tag` on the console without one. */
3
+ function warnUser(notices, tag, title, opts = {}) {
4
+ if (notices) notices.warn(title, opts);
5
+ else console.warn(`[${tag}] ${title}${opts.description ? ` — ${opts.description}` : ""}`);
6
+ }
7
+ /** Warn that text in `error`'s face could not be turned into outlines. */
8
+ function warnTextOutlines(notices, tag, error) {
9
+ warnUser(notices, tag, `Text in "${error.family}" can't be converted to outlines`, {
10
+ id: "text-outlines",
11
+ description: error.message
12
+ });
13
+ }
14
+
15
+ //#endregion
16
+ export { warnTextOutlines, warnUser };
17
+ //# sourceMappingURL=notices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notices.js","names":[],"sources":["../../../src/interactions/actions/notices.ts"],"sourcesContent":["/**\n * How an action tells the user something went wrong: the `notices` dep a host\n * publishes, shown however it shows such things (draw raises a toast). Without\n * one the message goes to the console.\n */\nimport type { TextOutlinesError } from '@weasel-js/text';\n\n/** What a notice says beyond its title. */\nexport interface NoticeOptions {\n /** One notice per id: a later one with the same id replaces it. */\n id?: string;\n description?: string;\n}\n\n/** The host's notice surface, read by actions whose result the user must hear about. */\nexport interface NoticesDep {\n warn(title: string, opts?: NoticeOptions): void;\n}\n\n/** Warn the user through `notices`, or under `tag` on the console without one. */\nexport function warnUser(notices: NoticesDep | undefined, tag: string, title: string, opts: NoticeOptions = {}): void {\n if (notices) notices.warn(title, opts);\n else console.warn(`[${tag}] ${title}${opts.description ? ` — ${opts.description}` : ''}`);\n}\n\n/** Warn that text in `error`'s face could not be turned into outlines. */\nexport function warnTextOutlines(notices: NoticesDep | undefined, tag: string, error: TextOutlinesError): void {\n warnUser(notices, tag, `Text in \"${error.family}\" can't be converted to outlines`, {\n id: 'text-outlines', description: error.message,\n });\n}\n"],"mappings":";;AAoBA,SAAgB,SAAS,SAAiC,KAAa,OAAe,OAAsB,CAAC,GAAS;CACpH,IAAI,SAAS,QAAQ,KAAK,OAAO,IAAI;MAChC,QAAQ,KAAK,IAAI,IAAI,IAAI,QAAQ,KAAK,cAAc,MAAM,KAAK,gBAAgB,IAAI;AAC1F;;AAGA,SAAgB,iBAAiB,SAAiC,KAAa,OAAgC;CAC7G,SAAS,SAAS,KAAK,YAAY,MAAM,OAAO,mCAAmC;EACjF,IAAI;EAAiB,aAAa,MAAM;CAC1C,CAAC;AACH"}
@@ -3,16 +3,18 @@ import { TextOutlinesError, textToPathsByPaint } from "@weasel-js/text";
3
3
 
4
4
  //#region src/interactions/actions/outlines/createOutlines.ts
5
5
  /**
6
- * Convert every text node in the selection to outlines, as one batch labeled
7
- * "Create Outlines". Other selected nodes are left alone and stay selected.
8
- * All or nothing: if any text node's face cannot supply outlines the scene is
9
- * untouched and the error comes back in the result.
6
+ * Convert every text node among `ids` — the selection, when not given — to
7
+ * outlines, as one batch labeled "Create Outlines". Other nodes are left
8
+ * alone, and the selection keeps them; a selected text node's replacement
9
+ * takes its place there. All or nothing: if any text node's face cannot
10
+ * supply outlines the scene is untouched and the error comes back in the
11
+ * result.
10
12
  */
11
- function applyCreateOutlines(adapter) {
13
+ function applyCreateOutlines(adapter, ids) {
12
14
  const sel = [...adapter.getSelection()];
13
15
  const converted = [];
14
16
  try {
15
- for (const id of sel) {
17
+ for (const id of ids ?? sel) {
16
18
  const text = adapter.getTextSource(id);
17
19
  if (!text) continue;
18
20
  const paths = textToPathsByPaint(text.data, text.pose);
@@ -1 +1 @@
1
- {"version":3,"file":"createOutlines.js","names":[],"sources":["../../../../src/interactions/actions/outlines/createOutlines.ts"],"sourcesContent":["/**\n * Create Outlines: replace each selected text node with path nodes carrying\n * its glyph outlines, giving up editability for geometry — the destructive\n * conversion every vector editor has. One path per paint the text wears; one\n * undoable batch; the replacement takes the text node's slot, so stacking\n * order is unchanged.\n */\nimport type { Affine, Path, Rect } from '@weasel-js/geom';\nimport type { PathPaint } from 'canvas/nodeShapes/nodePaint';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId } from 'core/scene/types';\nimport { textToPathsByPaint, TextOutlinesError, type TextNodeSource } from '@weasel-js/text';\nimport { replaceWithPaths, type PaintedPath } from './replaceWithPaths';\n\n/** What a path minted by an outline action must carry — see\n * {@link CreateOutlinesAdapter.createPathNode}. */\nexport interface OutlinePathSpec extends PathPaint {\n /** The parent the path goes under: the source's own, or the container\n * minted to hold a source's several paths. */\n parent: string | null;\n}\n\n/** What `applyCreateOutlines` and `applyOutlineStroke` read and write through. */\nexport interface CreateOutlinesAdapter {\n getSelection(): readonly NodeId[] | readonly string[];\n /** The text node behind `id`, or `undefined` for anything else. */\n getTextSource(id: NodeId): TextNodeSource | undefined;\n /**\n * Optional: the world-space path of the path node behind `id`, and the\n * paint it wears. Outline Stroke reads both, and passes over a node that\n * lacks either.\n */\n getWorldPath?(id: NodeId): Path | undefined;\n getPaint?(id: NodeId): PathPaint | undefined;\n /**\n * Optional: the frame the node behind `id` draws its stroke in, as the\n * matrix taking that frame to world (`poseFrameOf`); null or absent for a\n * node drawn straight. Outline Stroke skews and stretches a world-width\n * stroke with it. Without it every stroke is outlined in world.\n */\n getStrokeFrame?(id: NodeId): Affine | null | undefined;\n /**\n * Mint one path node of node `sourceId`'s outlines. `path` is in world\n * space. The node must wear `spec`'s fill and stroke — a text whose runs\n * differ in paint gets one path per paint, and a filled node whose stroke\n * is outlined gets one for the fill and one for the stroke — and sit under\n * `spec.parent`. The kit places it; only the consumer knows its data shape,\n * so anything else of the source's `data` worth keeping is the adapter's to\n * copy: onto this path when it stands alone in the source's slot, onto the\n * container when `createContainerNode` minted one.\n */\n createPathNode(path: Path, sourceId: NodeId, spec: OutlinePathSpec): { id: string };\n /**\n * Mint the container that holds one source's several paths, under `parent`.\n * `bounds` is the world envelope of the paths. The kit puts the container in\n * the source's slot and the paths inside it, back to front. Without this,\n * the paths are laid flat in that slot instead.\n */\n createContainerNode?(sourceId: NodeId, spec: { parent: string | null; bounds: Rect }): { id: string };\n /** Full node for `id`, so undo restores the text node whole. */\n getNode(id: string): { id: string } | undefined | null;\n /** The tree: each path is inserted at its source node's index among its\n * parent's children. */\n getParent(id: string): string | null;\n getChildren(parentId: string | null): string[];\n applyOps?(ops: Op[], label?: string): void;\n setSelection?(ids: NodeId[]): void;\n insertNode?(node: { id: string }, index?: number): void;\n removeNode?(id: string): void;\n}\n\n/** Outcome of {@link applyCreateOutlines}. */\nexport type CreateOutlinesResult =\n /** `resultIds` are what replaced the text nodes at their level — a path,\n * a container, or a run of flat paths each — which is also what is now\n * selected in the text nodes' place. */\n | { kind: 'applied'; resultIds: string[] }\n /** Nothing selected is text with ink. */\n | { kind: 'noop'; reason: 'no-text' }\n /** Some selected text has no outline geometry; nothing was changed. */\n | { kind: 'failed'; reason: 'text-outlines'; error: TextOutlinesError };\n\n/**\n * Convert every text node in the selection to outlines, as one batch labeled\n * \"Create Outlines\". Other selected nodes are left alone and stay selected.\n * All or nothing: if any text node's face cannot supply outlines the scene is\n * untouched and the error comes back in the result.\n */\nexport function applyCreateOutlines(adapter: CreateOutlinesAdapter): CreateOutlinesResult {\n const sel = [...adapter.getSelection()] as NodeId[];\n const converted: { id: NodeId; paths: PaintedPath[] }[] = [];\n try {\n for (const id of sel) {\n const text = adapter.getTextSource(id);\n if (!text) continue;\n const paths = textToPathsByPaint(text.data, text.pose);\n if (paths.length > 0) converted.push({ id, paths });\n }\n } catch (err) {\n if (err instanceof TextOutlinesError) return { kind: 'failed', reason: 'text-outlines', error: err };\n throw err;\n }\n if (converted.length === 0) return { kind: 'noop', reason: 'no-text' };\n\n const replaced = replaceWithPaths(adapter, sel, converted, 'Create Outlines');\n return { kind: 'applied', resultIds: converted.flatMap((c) => replaced.get(c.id)!) };\n}\n"],"mappings":";;;;;;;;;;AAwFA,SAAgB,oBAAoB,SAAsD;CACxF,MAAM,MAAM,CAAC,GAAG,QAAQ,aAAa,CAAC;CACtC,MAAM,YAAoD,CAAC;CAC3D,IAAI;EACF,KAAK,MAAM,MAAM,KAAK;GACpB,MAAM,OAAO,QAAQ,cAAc,EAAE;GACrC,IAAI,CAAC,MAAM;GACX,MAAM,QAAQ,mBAAmB,KAAK,MAAM,KAAK,IAAI;GACrD,IAAI,MAAM,SAAS,GAAG,UAAU,KAAK;IAAE;IAAI;GAAM,CAAC;EACpD;CACF,SAAS,KAAK;EACZ,IAAI,eAAe,mBAAmB,OAAO;GAAE,MAAM;GAAU,QAAQ;GAAiB,OAAO;EAAI;EACnG,MAAM;CACR;CACA,IAAI,UAAU,WAAW,GAAG,OAAO;EAAE,MAAM;EAAQ,QAAQ;CAAU;CAErE,MAAM,WAAW,iBAAiB,SAAS,KAAK,WAAW,iBAAiB;CAC5E,OAAO;EAAE,MAAM;EAAW,WAAW,UAAU,SAAS,MAAM,SAAS,IAAI,EAAE,EAAE,CAAE;CAAE;AACrF"}
1
+ {"version":3,"file":"createOutlines.js","names":[],"sources":["../../../../src/interactions/actions/outlines/createOutlines.ts"],"sourcesContent":["/**\n * Create Outlines: replace each selected text node with path nodes carrying\n * its glyph outlines, giving up editability for geometry — the destructive\n * conversion every vector editor has. One path per paint the text wears; one\n * undoable batch; the replacement takes the text node's slot, so stacking\n * order is unchanged.\n */\nimport type { Affine, Path, Rect } from '@weasel-js/geom';\nimport type { PathPaint } from 'canvas/nodeShapes/nodePaint';\nimport type { Op } from 'core/ops/types';\nimport type { NodeId } from 'core/scene/types';\nimport { textToPathsByPaint, TextOutlinesError, type TextNodeSource } from '@weasel-js/text';\nimport { replaceWithPaths, type PaintedPath } from './replaceWithPaths';\n\n/** What a path minted by an outline action must carry — see\n * {@link CreateOutlinesAdapter.createPathNode}. */\nexport interface OutlinePathSpec extends PathPaint {\n /** The parent the path goes under: the source's own, or the container\n * minted to hold a source's several paths. */\n parent: string | null;\n}\n\n/** What `applyCreateOutlines` and `applyOutlineStroke` read and write through. */\nexport interface CreateOutlinesAdapter {\n getSelection(): readonly NodeId[] | readonly string[];\n /** The text node behind `id`, or `undefined` for anything else. */\n getTextSource(id: NodeId): TextNodeSource | undefined;\n /**\n * Optional: the world-space path of the path node behind `id`, and the\n * paint it wears. Outline Stroke reads both, and passes over a node that\n * lacks either.\n */\n getWorldPath?(id: NodeId): Path | undefined;\n getPaint?(id: NodeId): PathPaint | undefined;\n /**\n * Optional: the frame the node behind `id` draws its stroke in, as the\n * matrix taking that frame to world (`poseFrameOf`); null or absent for a\n * node drawn straight. Outline Stroke skews and stretches a world-width\n * stroke with it. Without it every stroke is outlined in world.\n */\n getStrokeFrame?(id: NodeId): Affine | null | undefined;\n /**\n * Mint one path node of node `sourceId`'s outlines. `path` is in world\n * space. The node must wear `spec`'s fill and stroke — a text whose runs\n * differ in paint gets one path per paint, and a filled node whose stroke\n * is outlined gets one for the fill and one for the stroke — and sit under\n * `spec.parent`. The kit places it; only the consumer knows its data shape,\n * so anything else of the source's `data` worth keeping is the adapter's to\n * copy: onto this path when it stands alone in the source's slot, onto the\n * container when `createContainerNode` minted one.\n */\n createPathNode(path: Path, sourceId: NodeId, spec: OutlinePathSpec): { id: string };\n /**\n * Mint the container that holds one source's several paths, under `parent`.\n * `bounds` is the world envelope of the paths. The kit puts the container in\n * the source's slot and the paths inside it, back to front. Without this,\n * the paths are laid flat in that slot instead.\n */\n createContainerNode?(sourceId: NodeId, spec: { parent: string | null; bounds: Rect }): { id: string };\n /** Full node for `id`, so undo restores the text node whole. */\n getNode(id: string): { id: string } | undefined | null;\n /** The tree: each path is inserted at its source node's index among its\n * parent's children. */\n getParent(id: string): string | null;\n getChildren(parentId: string | null): string[];\n applyOps?(ops: Op[], label?: string): void;\n setSelection?(ids: NodeId[]): void;\n insertNode?(node: { id: string }, index?: number): void;\n removeNode?(id: string): void;\n}\n\n/** Outcome of {@link applyCreateOutlines}. */\nexport type CreateOutlinesResult =\n /** `resultIds` are what replaced the text nodes at their level — a path,\n * a container, or a run of flat paths each — which is also what is now\n * selected in the text nodes' place. */\n | { kind: 'applied'; resultIds: string[] }\n /** Nothing selected is text with ink. */\n | { kind: 'noop'; reason: 'no-text' }\n /** Some selected text has no outline geometry; nothing was changed. */\n | { kind: 'failed'; reason: 'text-outlines'; error: TextOutlinesError };\n\n/**\n * Convert every text node among `ids` — the selection, when not given — to\n * outlines, as one batch labeled \"Create Outlines\". Other nodes are left\n * alone, and the selection keeps them; a selected text node's replacement\n * takes its place there. All or nothing: if any text node's face cannot\n * supply outlines the scene is untouched and the error comes back in the\n * result.\n */\nexport function applyCreateOutlines(adapter: CreateOutlinesAdapter, ids?: readonly NodeId[]): CreateOutlinesResult {\n const sel = [...adapter.getSelection()] as NodeId[];\n const converted: { id: NodeId; paths: PaintedPath[] }[] = [];\n try {\n for (const id of ids ?? sel) {\n const text = adapter.getTextSource(id);\n if (!text) continue;\n const paths = textToPathsByPaint(text.data, text.pose);\n if (paths.length > 0) converted.push({ id, paths });\n }\n } catch (err) {\n if (err instanceof TextOutlinesError) return { kind: 'failed', reason: 'text-outlines', error: err };\n throw err;\n }\n if (converted.length === 0) return { kind: 'noop', reason: 'no-text' };\n\n const replaced = replaceWithPaths(adapter, sel, converted, 'Create Outlines');\n return { kind: 'applied', resultIds: converted.flatMap((c) => replaced.get(c.id)!) };\n}\n"],"mappings":";;;;;;;;;;;;AA0FA,SAAgB,oBAAoB,SAAgC,KAA+C;CACjH,MAAM,MAAM,CAAC,GAAG,QAAQ,aAAa,CAAC;CACtC,MAAM,YAAoD,CAAC;CAC3D,IAAI;EACF,KAAK,MAAM,MAAM,OAAO,KAAK;GAC3B,MAAM,OAAO,QAAQ,cAAc,EAAE;GACrC,IAAI,CAAC,MAAM;GACX,MAAM,QAAQ,mBAAmB,KAAK,MAAM,KAAK,IAAI;GACrD,IAAI,MAAM,SAAS,GAAG,UAAU,KAAK;IAAE;IAAI;GAAM,CAAC;EACpD;CACF,SAAS,KAAK;EACZ,IAAI,eAAe,mBAAmB,OAAO;GAAE,MAAM;GAAU,QAAQ;GAAiB,OAAO;EAAI;EACnG,MAAM;CACR;CACA,IAAI,UAAU,WAAW,GAAG,OAAO;EAAE,MAAM;EAAQ,QAAQ;CAAU;CAErE,MAAM,WAAW,iBAAiB,SAAS,KAAK,WAAW,iBAAiB;CAC5E,OAAO;EAAE,MAAM;EAAW,WAAW,UAAU,SAAS,MAAM,SAAS,IAAI,EAAE,EAAE,CAAE;CAAE;AACrF"}
@@ -1,3 +1,4 @@
1
+ import { warnTextOutlines } from "../notices.js";
1
2
  import { applyCreateOutlines } from "./createOutlines.js";
2
3
  import { ActionDisabledReason } from "@weasel-js/routing";
3
4
  import { loadTextOutlines } from "@weasel-js/text";
@@ -7,10 +8,10 @@ import { loadTextOutlines } from "@weasel-js/text";
7
8
  * Run `apply`, an outline conversion of `adapter`'s selection, waiting first
8
9
  * for any face whose outlines are registered but not yet loaded — a face is
9
10
  * parsed on first use, so the first conversion in a session would otherwise
10
- * fail. Warns under `tag` with the reason when the selection still cannot be
11
- * converted.
11
+ * fail. Warns the user through `notices` (under `tag` on the console without
12
+ * it) when the selection still cannot be converted.
12
13
  */
13
- async function withTextOutlines(adapter, apply, tag) {
14
+ async function withTextOutlines(adapter, apply, tag, notices) {
14
15
  const failure = (r) => r.kind === "failed" ? r.error : null;
15
16
  let result = apply();
16
17
  if (failure(result)?.reason === "outlines-loading") {
@@ -19,12 +20,12 @@ async function withTextOutlines(adapter, apply, tag) {
19
20
  result = apply();
20
21
  }
21
22
  const error = failure(result);
22
- if (error) console.warn(`[${tag}] ${error.message}`);
23
+ if (error) warnTextOutlines(notices, tag, error);
23
24
  return result;
24
25
  }
25
26
  /** {@link applyCreateOutlines} through {@link withTextOutlines}. */
26
- function runCreateOutlines(adapter) {
27
- return withTextOutlines(adapter, () => applyCreateOutlines(adapter), "createOutlines");
27
+ function runCreateOutlines(adapter, notices) {
28
+ return withTextOutlines(adapter, () => applyCreateOutlines(adapter), "createOutlines", notices);
28
29
  }
29
30
  /**
30
31
  * Static descriptor for Create Outlines: replace the selected
@@ -45,12 +46,16 @@ var createOutlinesAction = {
45
46
  opts: { id: "createOutlines.key" }
46
47
  }],
47
48
  eligible: { capability: "creates-shapes" },
48
- requires: ["selection", "createOutlinesAdapter"],
49
+ requires: [
50
+ "selection",
51
+ "createOutlinesAdapter",
52
+ "notices"
53
+ ],
49
54
  invoker: {
50
55
  timing: "immediate",
51
56
  run: (deps) => {
52
57
  const adapter = deps.createOutlinesAdapter;
53
- if (adapter) runCreateOutlines(adapter);
58
+ if (adapter) runCreateOutlines(adapter, deps.notices);
54
59
  }
55
60
  },
56
61
  enabled: (deps) => {