@oh-just-another/state 0.60.0 → 0.61.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 (62) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +4 -4
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/actions/actionKeyboard.js +2 -2
  5. package/dist/actions/actionKeyboard.js.map +1 -1
  6. package/dist/actions/actionMode.d.ts +0 -2
  7. package/dist/actions/actionMode.d.ts.map +1 -1
  8. package/dist/actions/actionMode.js +37 -37
  9. package/dist/actions/actionMode.js.map +1 -1
  10. package/dist/actions/types.d.ts +1 -1
  11. package/dist/built-in-handlers.d.ts +8 -0
  12. package/dist/built-in-handlers.d.ts.map +1 -1
  13. package/dist/built-in-handlers.js +31 -16
  14. package/dist/built-in-handlers.js.map +1 -1
  15. package/dist/constants.d.ts +93 -0
  16. package/dist/constants.d.ts.map +1 -1
  17. package/dist/constants.js +93 -0
  18. package/dist/constants.js.map +1 -1
  19. package/dist/editor/animation-scene.d.ts.map +1 -1
  20. package/dist/editor/animation-scene.js +37 -1
  21. package/dist/editor/animation-scene.js.map +1 -1
  22. package/dist/editor/event-fanout.d.ts +6 -6
  23. package/dist/editor/event-fanout.d.ts.map +1 -1
  24. package/dist/editor/event-fanout.js +8 -8
  25. package/dist/editor/event-fanout.js.map +1 -1
  26. package/dist/editor/hit-test.d.ts +8 -0
  27. package/dist/editor/hit-test.d.ts.map +1 -1
  28. package/dist/editor/hit-test.js +31 -16
  29. package/dist/editor/hit-test.js.map +1 -1
  30. package/dist/editor/link-handle-drag.d.ts +20 -0
  31. package/dist/editor/link-handle-drag.d.ts.map +1 -1
  32. package/dist/editor/link-handle-drag.js +71 -2
  33. package/dist/editor/link-handle-drag.js.map +1 -1
  34. package/dist/editor/pointer-binding.d.ts.map +1 -1
  35. package/dist/editor/pointer-binding.js +93 -39
  36. package/dist/editor/pointer-binding.js.map +1 -1
  37. package/dist/editor/public/brush.d.ts +69 -8
  38. package/dist/editor/public/brush.d.ts.map +1 -1
  39. package/dist/editor/public/brush.js +189 -20
  40. package/dist/editor/public/brush.js.map +1 -1
  41. package/dist/editor/public/cursor.js +4 -5
  42. package/dist/editor/public/cursor.js.map +1 -1
  43. package/dist/editor/render-orchestrator.d.ts +9 -6
  44. package/dist/editor/render-orchestrator.d.ts.map +1 -1
  45. package/dist/editor/render-orchestrator.js +25 -28
  46. package/dist/editor/render-orchestrator.js.map +1 -1
  47. package/dist/editor-events.d.ts +5 -5
  48. package/dist/editor-events.d.ts.map +1 -1
  49. package/dist/editor.d.ts +64 -19
  50. package/dist/editor.d.ts.map +1 -1
  51. package/dist/editor.js +116 -60
  52. package/dist/editor.js.map +1 -1
  53. package/dist/index.d.ts +1 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/modes.d.ts +24 -5
  56. package/dist/modes.d.ts.map +1 -1
  57. package/dist/modes.js.map +1 -1
  58. package/dist/overlay.d.ts +7 -19
  59. package/dist/overlay.d.ts.map +1 -1
  60. package/dist/overlay.js +11 -42
  61. package/dist/overlay.js.map +1 -1
  62. package/package.json +5 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # @oh-just-another/state
2
2
 
3
+ ## 0.61.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0548ab3: Unify the active tool into a single `editor.activeTool` value object (breaking).
8
+ - `state`: `editor.activeTool: ActiveTool` (`{ type, locked, lastActiveTool }`)
9
+ replaces `editor.mode` and `editor.toolLocked`; `setActiveTool(type)` replaces
10
+ `setMode`. `EditorOptions.initialMode` → `initialTool`. The typed `mode` event
11
+ is now `tool` and fires with the `ActiveTool` object on a type switch or a
12
+ lock flip. The action category `"mode"` is now `"tool"`. The vestigial
13
+ `"eyedropper"` mode is removed from `Mode` — colour sampling is armed from
14
+ the colour picker (`beginEyedropperPick`) and never was a toolbar tool.
15
+ - `react-ui`: `useMode()` → `useActiveTool(): ActiveTool`;
16
+ `DiagramRoot`/`DiagramCanvas` prop `initialMode` → `initialTool`.
17
+ - `editor`: `EditorAPI.getMode/setMode` → `getActiveTool/setActiveTool`;
18
+ `initialMode` prop → `initialTool`; re-exports `ActiveTool`.
19
+ - `diagram` (+ vue/svelte/angular wrappers): element methods and controller
20
+ `getMode/setMode` → `getActiveTool/setActiveTool`.
21
+
22
+ Tool ids are unchanged (`"select"`, `"draw-rect"`, …). There are no visible
23
+ behaviour changes — this is an API refactor establishing one source of truth
24
+ for "which tool is active".
25
+
26
+ - 762dd8a: Brush capture pipeline upgrade: input streamlining (low-pass with commit-time catch-up), speed-simulated pressure for mouse/touch (slow = thick, fast = thin) with rate-limited pen pressure, sample decimation with a soft point cap, and end tapering. `BrushElement` gains an optional regeneration payload (`pressures`, `simulatePressure`, `baseWidth`) carried through serialization; `Editor.beginBrushStroke` accepts a `pointerType` argument to pick the pressure source. The live preview runs the same pipeline as the commit.
27
+ - 4722388: Editable width for committed brush strokes. `style.strokeWidth` never
28
+ affected brushes (their widths are baked per point), so the property panel's
29
+ Thin/Medium/Thick control silently did nothing for them. A brush-only
30
+ selection now gets a popover range slider driving the new
31
+ `Editor.setBrushWidth(ids, width)`, which scales every baked point width by
32
+ `newWidth / baseWidth` — the stroke keeps its exact pressure profile at the
33
+ new thickness — and records the new `baseWidth`. Legacy strokes without a
34
+ recorded base fall back to their widest point. One undo step.
35
+ - 05707ed: Drag the caption pill along its link. With the link selected, dragging the
36
+ pill slides the label along the drawn path (the cursor is projected back onto
37
+ the polyline — new `projectPointToPathT` in scene); within a few pixels of
38
+ the arc-length middle it snaps back to the default placement
39
+ (`label.position` removed, so elbow links regain longest-segment
40
+ auto-placement). One undo step, Escape reverts, double-click still opens the
41
+ inline text editor, and handle dots keep pointer priority over the pill.
42
+ Tunable snap radius: `LINK_LABEL_DRAG_SNAP_PX`.
43
+ - 84450bc: Link captions: measured rounded pill, multiline, correct placement and hit-testing.
44
+ - `scene`: new shared label geometry (`linkLabelAnchor`, `estimateLinkLabelBox`,
45
+ `linkLabelBounds`, `pointAlongPath`) — one source of truth for the renderer,
46
+ hit-testing and culling. `findLinkAt` now also hits inside the caption pill.
47
+ Elbow links place an unpositioned label on the longest segment's midpoint;
48
+ explicit `label.position` is clamped away from the arrowheads. Tunables in
49
+ `constants.ts` (`LINK_LABEL_MAX_WIDTH`, paddings, clearance).
50
+ - `renderer-core`: the caption is a rounded pill sized by real `measureText`
51
+ word-wrap (multiline, `\n` breaks) instead of a square estimated box; it
52
+ rides the drawn geometry (flattened curve for bezier, not the chord), and
53
+ `computeLinkWorldBounds` unions the pill so dirty-rect / viewport culling
54
+ never clip it. `LABEL_POSITION` / `LABEL_FONT_SIZE` constants moved to
55
+ `scene` as `LINK_LABEL_DEFAULT_POSITION` / `LINK_LABEL_DEFAULT_FONT_SIZE`.
56
+ - `state`: `linkLabelWorld` uses the shared anchor, so the inline editor opens
57
+ exactly over the pill (including bezier and elbow links).
58
+ - `react-ui`: the inline caption editor is a multiline textarea — Enter
59
+ commits, Shift+Enter inserts a newline, Escape cancels.
60
+
61
+ ### Patch Changes
62
+
63
+ - 50a2bd4: Fix: with a creation tool active (draw-edge, draw-rect, …) a press on a
64
+ selected shape's edge no longer grabs the shape's resize/rotate handle — it
65
+ starts the new link / element as expected. Selection chrome (resize, rotate,
66
+ group and selected-link endpoint handles) is now pressable only under the
67
+ select tool, and the overlay stops drawing the handles while a creation tool
68
+ is active (outlines stay; the hand tool keeps the chrome visible).
69
+ - 20af638: Fix: the caption pill no longer fights the bend/segment handles. The
70
+ "add waypoint" and elbow segment handles slide out from under the label pill
71
+ along their own span (`getLinkWaypointMidpoints` is label-aware; new shared
72
+ `getElbowSegmentHandles` keeps the drawn dot and the grab point identical), so
73
+ a click on the pill selects the link and a double-click opens the inline
74
+ caption editor. Visible handle dots keep pointer priority — an existing
75
+ waypoint dot sitting inside the pill is still grabbable (dots draw above the
76
+ pill).
77
+ - 3c50ef1: Tile cache honours per-element hide (B12, hide half). `renderViaTiles` accepts
78
+ `hideElements`: tiles bake with the set applied, and an element entering or
79
+ leaving the set invalidates only the tiles it touches — so the stroke-eraser
80
+ preview and per-element visibility no longer drop very large scenes off the
81
+ tile-cache path into a full re-render every frame. Group-isolation dim still
82
+ takes the full path (dimming almost everything would re-rasterise most tiles
83
+ anyway).
84
+ - f960332: Fix: mp4 shapes survive a page reload. The video file-drop handler never
85
+ persisted the bytes into `Scene.files`, so a restored scene had only a dead
86
+ `blob:` URL and nothing to rehydrate from (the "dead-blob-url" renderer
87
+ warning) on every backend. The handler now stores the file (`fileId` on the
88
+ shape), and scene rehydration grew a video branch: it rebuilds the hidden,
89
+ muted, looping `<video>` element from the persisted bytes (shared
90
+ `createHiddenLoopingVideo` factory with the drop handler) and resumes
91
+ playback best-effort. Videos dropped BEFORE this fix have no stored bytes and
92
+ still won't restore — re-add them once.
93
+ - Updated dependencies [762dd8a]
94
+ - Updated dependencies [05707ed]
95
+ - Updated dependencies [20af638]
96
+ - Updated dependencies [84450bc]
97
+ - @oh-just-another/scene@0.61.0
98
+ - @oh-just-another/renderer-core@0.60.0
99
+ - @oh-just-another/history@0.57.4
100
+
3
101
  ## 0.60.0
4
102
 
5
103
  ### Minor Changes
package/README.md CHANGED
@@ -23,11 +23,11 @@ const editor = new Editor({
23
23
  mainTarget: layered.get("main"),
24
24
  overlayTarget: layered.get("overlay"),
25
25
  initialScene: emptyScene(),
26
- initialMode: "select",
26
+ initialTool: "select",
27
27
  });
28
28
 
29
29
  editor.subscribe(() => render());
30
- editor.setMode("draw-rect");
30
+ editor.setActiveTool("draw-rect");
31
31
  ```
32
32
 
33
33
  ## Concepts
@@ -36,7 +36,7 @@ editor.setMode("draw-rect");
36
36
 
37
37
  The centerpiece controller (`Editor`, `EditorOptions`, `LoadSceneOptions`). It owns the scene, selection, and viewport, and exposes a high-level API spanning:
38
38
 
39
- - **Tools / modes** — `mode`, `setMode`, `toolLocked` / `setToolLocked` (sticky tool).
39
+ - **Tools** — `activeTool` (`{ type, locked, lastActiveTool }`, the single source of truth), `setActiveTool`, `setToolLocked` (sticky tool).
40
40
  - **Selection** — `selection`, `selectAll`, `deleteSelected`, `moveSelectionBy`, `focusCycle`, plus link selection (`selectedLinks`, `selectedLink`).
41
41
  - **History** — `undo`, `redo`, `canUndo`, `canRedo`, `history` (backed by `@oh-just-another/history`).
42
42
  - **Hit-testing** — `hitTest(worldPoint)` returns a `PressTarget`; `hitAnnotation`.
@@ -48,7 +48,7 @@ The centerpiece controller (`Editor`, `EditorOptions`, `LoadSceneOptions`). It o
48
48
  - **Text editing** — inline caret/selection model: `beginTextEdit`, `commitTextEdit`, `cancelTextEdit`, `setEditingText`, `setTextCaretFromPoint`, `extendTextSelectionToPoint`, `caretIndexAtWorldPoint`, `editingTextOverlay`, plus `createTextAt`.
49
49
  - **Image / file insert** — `insertImage`, `addElement`, `beginPlacement`, and a `FileDropRegistry` (see below).
50
50
  - **GIF / animation playback** — `togglePlayback`, `hoverAnimatedElement`, `isPlaybackPaused`.
51
- - **Brush strokes** — `beginBrushStroke`, `extendBrushStroke`, `commitBrushStroke`, `cancelBrushStroke`, `pendingBrushStroke`.
51
+ - **Brush strokes** — `beginBrushStroke` (a `pointerType` argument picks the pressure source: real pen pressure, or speed-simulated for mouse/touch), `extendBrushStroke`, `commitBrushStroke`, `cancelBrushStroke`, `pendingBrushStroke`. Capture streamlines input, decimates samples, and tapers stroke ends on commit; the live preview matches the committed result.
52
52
  - **Annotations / comments** — `addAnnotation`, `removeAnnotation`, `toggleAnnotationResolved`, `addComment`, `removeComment`, `setSelectedAnnotation`, `setCommentAuthor`.
53
53
  - **Scene lifecycle** — `scene`, `loadScene`.
54
54