@weasel-js/core 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +330 -0
- package/dist/{DrawCommand-DCmiNkBj.d.ts → DrawCommand-BbPrSTra.d.ts} +24 -0
- package/dist/{chunk-Z3KNFTTS.js → chunk-3JYFAQIB.js} +3 -3
- package/dist/chunk-3JYFAQIB.js.map +1 -0
- package/dist/{chunk-UB6A6L77.js → chunk-3KGMJMOS.js} +3 -3
- package/dist/{chunk-UB6A6L77.js.map → chunk-3KGMJMOS.js.map} +1 -1
- package/dist/{chunk-IO5Z75X4.js → chunk-HGF5X6MZ.js} +2 -2
- package/dist/chunk-HGF5X6MZ.js.map +1 -0
- package/dist/{chunk-775XXAHR.js → chunk-JOSUVS6C.js} +2 -2
- package/dist/{chunk-775XXAHR.js.map → chunk-JOSUVS6C.js.map} +1 -1
- package/dist/{chunk-FVNWK7U3.js → chunk-SMCZRSYB.js} +1677 -1371
- package/dist/chunk-SMCZRSYB.js.map +1 -0
- package/dist/{chunk-DCIU3SRK.js → chunk-TR3HZN34.js} +79 -151
- package/dist/chunk-TR3HZN34.js.map +1 -0
- package/dist/{chunk-6SHZHXXR.js → chunk-U45SODC2.js} +2 -2
- package/dist/{chunk-6SHZHXXR.js.map → chunk-U45SODC2.js.map} +1 -1
- package/dist/clipboard.d.ts +5 -2
- package/dist/clipboard.js +1 -2
- package/dist/clone.d.ts +2 -2
- package/dist/clone.js +0 -1
- package/dist/{geometry-DVeZ2i-c.d.ts → geometry-5X6TrAkX.d.ts} +1 -1
- package/dist/{grid-XcFQVS0f.d.ts → grid-sfilv5HP.d.ts} +7 -2
- package/dist/index.d.ts +695 -49
- package/dist/index.js +7 -8
- package/dist/insert.d.ts +6 -3
- package/dist/insert.js +1 -2
- package/dist/insert.js.map +1 -1
- package/dist/move.d.ts +26 -5
- package/dist/move.js +2 -3
- package/dist/move.js.map +1 -1
- package/dist/{options-wAvCnOZd.d.ts → options-CbsIgQci.d.ts} +3 -1
- package/dist/patterns-builtin.d.ts +8 -0
- package/dist/patterns-builtin.js +1 -2
- package/dist/{pointSnapToGrid-BuDZWBrL.d.ts → pointSnapToGrid-C3wowsQy.d.ts} +9 -3
- package/dist/{index-DPI8DV0A.d.ts → registry-CxnkXbG8.d.ts} +225 -350
- package/dist/renderer.d.ts +36 -4
- package/dist/renderer.js +7 -8
- package/dist/resize.d.ts +12 -5
- package/dist/resize.js +2 -3
- package/dist/routing.d.ts +106 -7
- package/dist/routing.js +1 -2
- package/dist/{types-BJ8_cyT7.d.ts → types-BHK2dkMu.d.ts} +43 -1
- package/dist/{types-BhJJ2OCM.d.ts → types-ByZxoD6P.d.ts} +1 -1
- package/dist/{types-B_-khFM0.d.ts → types-DpQ0cWYC.d.ts} +32 -0
- package/dist/{types-Kh_osAq9.d.ts → types-vqxpCFVp.d.ts} +31 -0
- package/dist/{viewToMat3-BvaWCN99.d.ts → viewToMat3-CQW_YqDw.d.ts} +1 -1
- package/package.json +6 -6
- package/dist/chunk-DCIU3SRK.js.map +0 -1
- package/dist/chunk-FVNWK7U3.js.map +0 -1
- package/dist/chunk-IO5Z75X4.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -9
- package/dist/chunk-PZ5AY32C.js.map +0 -1
- package/dist/chunk-Z3KNFTTS.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,335 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5d25a40: `@weasel-js/font`'s six reset seams — `_resetFontRegistryForTests`,
|
|
8
|
+
`_resetFallbackForTests`, `_getPagesForTests`, `_resetDynamicFontsForTests`,
|
|
9
|
+
`__setGlyphRasterizerForTests` and `_resetFontOutlinesForTests` — are no longer
|
|
10
|
+
exported from the package barrel. They now live at a new
|
|
11
|
+
`@weasel-js/font/test-seams` entry point.
|
|
12
|
+
|
|
13
|
+
Nothing loses the ability to reach them. They exist because font registration,
|
|
14
|
+
the fallback policy, the dynamic atlas and the outline registry are global
|
|
15
|
+
module state that changes what renders, so a test in another package that sets
|
|
16
|
+
one has to be able to put it back — which is why they were on the barrel in the
|
|
17
|
+
first place. A named test-seam entry serves that need without an application
|
|
18
|
+
finding a `_resetFontOutlinesForTests` by autocompleting the barrel. Both
|
|
19
|
+
entries share one chunk, so the registries remain single instances.
|
|
20
|
+
|
|
21
|
+
This is a breaking change for anything importing those six names from
|
|
22
|
+
`@weasel-js/font`; the import specifier is the only edit.
|
|
23
|
+
|
|
24
|
+
`evaluateEnabled` in `@weasel-js/core` is now marked `@experimental` at its
|
|
25
|
+
definition. An `@internal` block intended for it had come detached and sat above
|
|
26
|
+
three unrelated constants, so the function read as undocumented public API while
|
|
27
|
+
a stale marker said otherwise. It is genuinely public — `@weasel-js/ui`'s
|
|
28
|
+
`ActionBar` calls it — and `@experimental` matches the rest of the `enabled`
|
|
29
|
+
predicate surface.
|
|
30
|
+
|
|
31
|
+
- f7077f6: An image quad no longer mints and frees a vertex array and two buffers on every
|
|
32
|
+
draw. The renderer keeps a ring of quad geometry per image program instead, and
|
|
33
|
+
a draw writes its four corners into the next slot. On an M2 Max via ANGLE this
|
|
34
|
+
takes an image command from ~7.0 us to ~3.9 us, measured by
|
|
35
|
+
`tests/perf/image-quad.spec.ts`; nothing about the API or the pixels changes.
|
|
36
|
+
|
|
37
|
+
A ring rather than one buffer, because one is the worst of the three shapes. The
|
|
38
|
+
driver tracks a write hazard per buffer object, so rewriting a single quad
|
|
39
|
+
buffer before each draw waits on the draw still reading it — 40–80 us per quad
|
|
40
|
+
against 5.4 for the per-draw allocation this replaced and 0.3 for the ring.
|
|
41
|
+
Sixty-four slots put that many draws between one write of a buffer and the next.
|
|
42
|
+
|
|
43
|
+
The remaining gap to a pattern-filled rect of the same size (~2.3 us) is texture
|
|
44
|
+
state, not geometry: an image binds a different texture and sets its filter per
|
|
45
|
+
draw.
|
|
46
|
+
|
|
47
|
+
- 514c34a: Document every public export at its definition site
|
|
48
|
+
|
|
49
|
+
A JSDoc string now sits on each symbol reachable through a package's published
|
|
50
|
+
entry points, in every package except `@weasel-js/ui`. Documentation only — no
|
|
51
|
+
export was added, removed, renamed or reordered, and no behavior changed.
|
|
52
|
+
|
|
53
|
+
`npm run audit:jsdoc` enumerates the public exports and reports which lack a
|
|
54
|
+
docstring, so the claim can be re-derived rather than trusted.
|
|
55
|
+
|
|
56
|
+
- Updated dependencies [5d25a40]
|
|
57
|
+
- Updated dependencies [514c34a]
|
|
58
|
+
- @weasel-js/font@1.0.3
|
|
59
|
+
- @weasel-js/geom@1.0.3
|
|
60
|
+
- @weasel-js/gestures@1.0.3
|
|
61
|
+
- @weasel-js/history@1.0.3
|
|
62
|
+
- @weasel-js/modes@1.0.3
|
|
63
|
+
|
|
64
|
+
## 1.0.2
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- 28710f2: The renderer's solid batch is drained at the sites that decide routing or
|
|
69
|
+
change stencil state, instead of at each emitter that happened to remember.
|
|
70
|
+
Geometry that cannot join a run now goes through `tryStageSolid`, which returns
|
|
71
|
+
`false` only after flushing — so the only way an emitter earns permission to
|
|
72
|
+
draw for itself is to have called the function that drained the batch. `pushClip`
|
|
73
|
+
and `popClip` flush as their first statement, since rasterizing into the stencil
|
|
74
|
+
is what creates the obligation.
|
|
75
|
+
|
|
76
|
+
Nothing about the drawn result changes; this removes a way for a future draw
|
|
77
|
+
path to paint under geometry staged before it.
|
|
78
|
+
|
|
79
|
+
- 2e3fea2: The `routing` namespace is gone from the main barrel, and the reflection
|
|
80
|
+
surface exports only what a consumer can use.
|
|
81
|
+
|
|
82
|
+
`export * as routing` made tool authoring reachable two ways — `core.routing.defineTool`
|
|
83
|
+
and the `@weasel-js/core/routing` subpath — and no consumer ever used the first.
|
|
84
|
+
It survived as the unfinished half of the 2026-05-12 declarative-routing work,
|
|
85
|
+
whose Phase 6 was to move `defineTool` out of `routing/` entirely. **Removing
|
|
86
|
+
it is a breaking change for anyone importing the namespace form**; the subpath
|
|
87
|
+
is unchanged and is what every known consumer already uses.
|
|
88
|
+
|
|
89
|
+
`tools/routing/reflection` now exports `buildRouteRegistry`, `findConflicts`,
|
|
90
|
+
`RegistryEntry` and `Conflict` — the four an external inspector needs.
|
|
91
|
+
`PREDICATE_TARGET`, `findScopedConflicts`, `formatConflict`,
|
|
92
|
+
`reportRouteConflicts` and `ToolScopes` are still there and still used; they
|
|
93
|
+
are just no longer public, since their only caller is inside the kit.
|
|
94
|
+
|
|
95
|
+
- 75ba7b1: Three fixes found by re-checking backlog entries against the code.
|
|
96
|
+
|
|
97
|
+
SVG gradients survive a round trip. The parser now reads `gradientUnits`
|
|
98
|
+
(`objectBoundingBox` → `units: 'bounds'`, `userSpaceOnUse` → `'world'`) and the
|
|
99
|
+
serializer writes back whichever the paint declares, instead of hardcoding
|
|
100
|
+
`userSpaceOnUse` on the way out — which had been reading a box-relative
|
|
101
|
+
gradient's `0..1` geometry as page coordinates, i.e. a gradient the size of a
|
|
102
|
+
pixel.
|
|
103
|
+
|
|
104
|
+
`unpackSvgFiles` keeps gradient fills instead of flattening them to a solid.
|
|
105
|
+
The reason recorded for the flattening — that the `kit:path` painter has no
|
|
106
|
+
gradient slot — had not been true for some time; `NodeFill` is
|
|
107
|
+
`string | FillStyle`, now exported. A `userSpaceOnUse` gradient is normalized
|
|
108
|
+
against the leaf's own box on the way in, so it survives the fit-clamp and
|
|
109
|
+
drop-point placement that move the geometry out from under it. Gradient
|
|
110
|
+
_strokes_ still flatten: `data.stroke` genuinely is a color string.
|
|
111
|
+
|
|
112
|
+
`extractUniformNames` skips precision and interpolation qualifiers. `uniform
|
|
113
|
+
highp float u_t;` — the common spelling in hand-written GLSL — matched nothing
|
|
114
|
+
at all, so the uniform got no location and every write to it was dropped in
|
|
115
|
+
silence. Comma-separated declarator lists (`uniform float a, b;`) read too.
|
|
116
|
+
|
|
117
|
+
Also adds `tests/visual/text-decoration.spec.ts`, a baseline-free assertion
|
|
118
|
+
that underline and strikethrough sit `0.40 em` apart and span only their own
|
|
119
|
+
runs. It measures the gap between two gap-free horizontal ink runs, which is
|
|
120
|
+
something `text.spec.ts`'s 5% diff tolerance cannot see move.
|
|
121
|
+
|
|
122
|
+
- e4a6ec4: Tool authoring moved out of `routing/` and onto the main barrel. `defineTool`,
|
|
123
|
+
`defineViewportTool`, `ToolDef`, `ViewportToolDef` and `ToolKeybinding` now come
|
|
124
|
+
from `@weasel-js/core`:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { defineTool, type ToolDef } from "@weasel-js/core";
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**This is a breaking change for anyone importing them from
|
|
131
|
+
`@weasel-js/core/routing`.** That subpath keeps the route grammar (`parseRoute`,
|
|
132
|
+
`formatRoute`, `describeRoute`, the gesture descriptors) and the reflection
|
|
133
|
+
consumers (`buildRouteRegistry`, `findConflicts`) — it is now only the surface
|
|
134
|
+
that _reads_ routes back, matching its name.
|
|
135
|
+
|
|
136
|
+
Finishes Phase 6 of the 2026-05-12 declarative-routing work. Source layout
|
|
137
|
+
follows: the factory and its `ToolDef` types sit at the top of `src/tools/`
|
|
138
|
+
alongside `useTools` and `useKeybindings`, with `routing/types.ts` renamed
|
|
139
|
+
`routeTypes.ts` to clear the existing `tools/types.ts`. Behavior and runtime
|
|
140
|
+
contract are unchanged.
|
|
141
|
+
|
|
142
|
+
- d2a9049: Six backlog entries, all in the input and hit-test layers.
|
|
143
|
+
|
|
144
|
+
Tool overlays can say where they sit. `Contribution.overlay` takes a
|
|
145
|
+
`RenderLayer` or an array of them, and a new `overlayPosition` (`'top'` — the
|
|
146
|
+
default — / `'before-selection'` / `'after-selection'`) anchors them against
|
|
147
|
+
the selection chrome instead of always landing on top; with no selection layer
|
|
148
|
+
in the stack the anchored positions fall back to the tail.
|
|
149
|
+
`getActiveOverlays(position?)` partitions, and `placeToolOverlays` in
|
|
150
|
+
`canvas/layerOrder.ts` does the splice, so the ordering is testable without a
|
|
151
|
+
GL context.
|
|
152
|
+
|
|
153
|
+
`drop` and `paste` are route-grammar gesture names. They shipped without them,
|
|
154
|
+
so the inspector reported `undefined` for every ingestion binding. Both are
|
|
155
|
+
targetless and carry the spec's MIME-glob filter as their arg — `drop(image/*)`.
|
|
156
|
+
|
|
157
|
+
An unhandled paste stays the page's. `onPaste` now dispatches first and calls
|
|
158
|
+
`preventDefault` only on `'handled'`, the shape `onWheel` already used.
|
|
159
|
+
Clipboard items materialize synchronously, so unlike `onDrop` the result is
|
|
160
|
+
known while the default can still be suppressed.
|
|
161
|
+
|
|
162
|
+
Marquee and lasso see the shape a node actually draws. `hitTestArea` asked the
|
|
163
|
+
_pose_ for a silhouette, which meant the kit's own inserted shapes — geometry
|
|
164
|
+
on `node.data.path` behind a plain `{x,y,w,h}` pose — took the AABB path and
|
|
165
|
+
kept every false positive the silhouette test exists to drop. It now asks
|
|
166
|
+
`findShapeSilhouette` for the drawn world-frame boundary. Paying for that is a
|
|
167
|
+
containment short-circuit: a node the rect marquee swallows whole is a hit no
|
|
168
|
+
silhouette can overturn, so neither the kernel nor the painter runs. Net
|
|
169
|
+
against the committed bench baseline, polygon-pose scenes gain (1.25x at 1000
|
|
170
|
+
nodes / 100% area) and plain-rect scenes lose ~8% on the two rows that scan
|
|
171
|
+
everything. The short-circuit is marquee-only, behind `hitTestAreaPolygon`'s
|
|
172
|
+
`areaIsRect` flag, because a node inside a lasso hull's bounding box can still
|
|
173
|
+
miss the hull.
|
|
174
|
+
|
|
175
|
+
Layout siblings reflowing mid-drag render opaque. `OngoingHandle.previewOpaqueIds()`
|
|
176
|
+
names the subset of `previewIds()` that skips the ghost alpha; `moveAction`
|
|
177
|
+
fills it from the destination and source reflow ids. A ghost means "in flight
|
|
178
|
+
under the pointer", which a sibling settling into its destination slot is not.
|
|
179
|
+
|
|
180
|
+
`LayoutStrategy.acceptsDrop(container, dragged)` rejects a drag before any
|
|
181
|
+
drop-target work, so a type-aware container falls through to whatever sits
|
|
182
|
+
under it rather than swallowing everything in its bounds.
|
|
183
|
+
|
|
184
|
+
`flipAction` reads `params.pivot`. `'each'` (the default, unchanged) mirrors
|
|
185
|
+
every pose about its own AABB; `'union'` mirrors about the selection envelope
|
|
186
|
+
so items swap sides, and the `geometryProjection` data op follows the same
|
|
187
|
+
pivot.
|
|
188
|
+
|
|
189
|
+
- 5f05431: `viewport.pinchZoom` now pans as well as zooms. It anchored `zoomAt` on the
|
|
190
|
+
current gesture centroid and never translated by the centroid delta, so two
|
|
191
|
+
fingers travelling together — spread unchanged, zoom factor 1 — moved the view
|
|
192
|
+
not at all.
|
|
193
|
+
|
|
194
|
+
Each frame now anchors the zoom on the previous centroid and then translates by
|
|
195
|
+
how far the centroid travelled. Together those pin the world point under the
|
|
196
|
+
gesture midpoint as the midpoint moves, which is what makes a pinch feel
|
|
197
|
+
attached to the fingers.
|
|
198
|
+
|
|
199
|
+
The action's id and label are unchanged (`viewport.pinchZoom` / `Pinch Zoom`).
|
|
200
|
+
Consumers who bound it get panning with no wiring change.
|
|
201
|
+
|
|
202
|
+
- 5fea43d: Five unrelated small fixes.
|
|
203
|
+
|
|
204
|
+
A tapered stroke with `align: 'inner'` or `'outer'` on a polygon path painted
|
|
205
|
+
at half its requested widths. That alignment renders by tessellating at twice
|
|
206
|
+
the width and stencilling half away, and the doubling reached `stroke.width`
|
|
207
|
+
but not `vertexWidths`. The doubled array is memoized per source array, since
|
|
208
|
+
the ribbon cache compares it by reference.
|
|
209
|
+
|
|
210
|
+
An image insert previews the decoded bitmap inside the drag bounds instead of
|
|
211
|
+
committing on release with no preview at all. It falls back to the bare
|
|
212
|
+
outline until the image decodes, and `useImageTool({ preview: 'outline' })`
|
|
213
|
+
opts out of the bitmap entirely.
|
|
214
|
+
|
|
215
|
+
A HUD widget that claims the pointer reports a `'pointer'` cursor without
|
|
216
|
+
implementing anything — hovering one while a drawing tool was active used to
|
|
217
|
+
keep showing that tool's cursor. The rule is keyed on the `claims` every
|
|
218
|
+
widget already declares, so it covers consumer-authored widgets too;
|
|
219
|
+
decoration claims nothing and the hit walk descends past it. A widget's own
|
|
220
|
+
`cursorAt` still wins, and `button` takes a `cursor` option that feeds it.
|
|
221
|
+
|
|
222
|
+
`composeAffordanceLayer`'s `hitTest` returns a `LayerHit`, carrying the hit
|
|
223
|
+
region's declared cursor and claim instead of dropping them. `AffordanceRegion`
|
|
224
|
+
gains optional `strength` / `claimedKinds` to declare that claim.
|
|
225
|
+
|
|
226
|
+
`ToolPalette` uses the shared `useRovingTabIndex` rather than its own container
|
|
227
|
+
handler, so arrow keys skip tools that are ineligible in the current mode and
|
|
228
|
+
the tab stop no longer sits on one. `ToolButton` takes an `onKeyDown`.
|
|
229
|
+
|
|
230
|
+
- 443d74e: Stroke ribbons are tessellated once per stroke configuration instead of once
|
|
231
|
+
per frame. The renderer rebuilt every stroked path's ribbon geometry on every
|
|
232
|
+
frame and discarded it; it now caches the result on `Path` identity, keyed by
|
|
233
|
+
the parameters that change the ribbon — width, cap, join, miter limit,
|
|
234
|
+
alignment, dash, and flatten tolerance. Paint and vertex colors are not in the
|
|
235
|
+
key, since both are applied over the same triangles at draw time.
|
|
236
|
+
|
|
237
|
+
A ribbon that survives a frame also stops paying for a fresh VAO and two
|
|
238
|
+
buffers on every subsequent frame. One whose path or stroke parameters change
|
|
239
|
+
each frame keeps the transient upload it had before, freed at end of frame —
|
|
240
|
+
so an animated or freshly drawn path never accumulates GL resources waiting on
|
|
241
|
+
garbage collection.
|
|
242
|
+
|
|
243
|
+
Nothing about the drawn result changes. The cache is keyed on object identity,
|
|
244
|
+
matching the fill cache: a `Path` rebuilt with equal coordinates is a distinct
|
|
245
|
+
entry and re-tessellates.
|
|
246
|
+
|
|
247
|
+
- 7decec1: Four more backlog fixes.
|
|
248
|
+
|
|
249
|
+
`@weasel-js/svg` reads and writes `<image>`. A new `SvgImageNode` holds the
|
|
250
|
+
`href` verbatim — an external URL or a `data:` URI, with `xlink:href` accepted
|
|
251
|
+
on the way in — plus a box that inherited transforms collapse onto and an
|
|
252
|
+
element-local rotation. `unpackSvgFiles` maps it onto the `kit:image` painter's
|
|
253
|
+
`data.image.src`, so a dropped SVG carrying raster content now keeps it instead
|
|
254
|
+
of dropping the element on parse. `preserveAspectRatio` is not modeled: the box
|
|
255
|
+
is taken literally and written back as `none`, and a non-`none` source warns.
|
|
256
|
+
|
|
257
|
+
`pickTopMostHit` resolves sibling z-order. An adapter can supply `getZIndex(id)`
|
|
258
|
+
or `compareZ(a, b)`; both compose with the existing parent/child collapse rather
|
|
259
|
+
than replacing it, so a child still beats its own ancestor whatever z the two
|
|
260
|
+
report. Without either, the hit list's own order decides, as before.
|
|
261
|
+
|
|
262
|
+
`useSceneTextEdit` supplies `setStyle`. Clearing a style flag that the _node_
|
|
263
|
+
sets is the one edit the additive run algebra can't express, and `useTextEdit`
|
|
264
|
+
declines it without a writer — so every scene-wired consumer silently refused
|
|
265
|
+
that toggle. Override the projection with `setStyle(data, style)` for a
|
|
266
|
+
non-default data shape.
|
|
267
|
+
|
|
268
|
+
The slops debug overlay draws handle halos at the real hit radius. Affordance
|
|
269
|
+
regions moved to screen-pixel radii, but this layer still scaled its circles by
|
|
270
|
+
the view, so at 4x zoom it drew a 32px halo over an 8px target — the one thing
|
|
271
|
+
a hit-test overlay must not do. Anchor slops now read the anchor radius rather
|
|
272
|
+
than the handle radius.
|
|
273
|
+
|
|
274
|
+
- 24daa08: Five unrelated backlog fixes.
|
|
275
|
+
|
|
276
|
+
The specificity tuple's `phase` dimension is graded rather than binary: an
|
|
277
|
+
atom scores 2 when both its channel and its lifecycle state are concrete, 1
|
|
278
|
+
when one axis is wildcarded, and 0 for `*:*`, which matches everything an
|
|
279
|
+
undeclared phase would have matched. An atom list takes the minimum, since
|
|
280
|
+
`matchPhase` is a union. No existing binding reorders — the four ambient
|
|
281
|
+
actions hold at 1, and the polygon and star tools' `phase: 'engaged'` wheel
|
|
282
|
+
bindings rise to 2, widening a gap they already won.
|
|
283
|
+
|
|
284
|
+
The loupe's pixel mode no longer drops the end of a fast drag: a readback
|
|
285
|
+
requested while `createImageBitmap` is in flight is remembered and re-run when
|
|
286
|
+
that one settles, instead of being discarded.
|
|
287
|
+
|
|
288
|
+
SVG unpack applies the fit-clamp to text on both axes. `fontSize` now scales
|
|
289
|
+
with the file, and a text node's box width is estimated from its longest line
|
|
290
|
+
instead of inheriting the parser's unbounded-width wrap sentinel — which,
|
|
291
|
+
folded into the union AABB, had been clamping any external SVG containing
|
|
292
|
+
text down to a speck. That sentinel is now the exported `UNBOUNDED_TEXT_WIDTH`
|
|
293
|
+
rather than a bare `99999`, so a consumer reading `SvgTextNode.width` can tell
|
|
294
|
+
a measurement from a placeholder.
|
|
295
|
+
|
|
296
|
+
The debug overlay takes per-feature line widths and dashes through
|
|
297
|
+
`DebugConfig.strokes`, alongside the colors `DebugConfig.theme` already
|
|
298
|
+
carried. Defaults are unchanged.
|
|
299
|
+
|
|
300
|
+
A `.dfont` face declines the outline tier by name. Datafork TrueType holds its
|
|
301
|
+
sfnt tables inside a Macintosh resource map, which is still not unpacked, but
|
|
302
|
+
it is now recognized before parsing and reported as itself rather than dying
|
|
303
|
+
on an unrecognized-signature message that never says which format it saw.
|
|
304
|
+
|
|
305
|
+
- f79e4b2: Viewport layers can now answer where a screen point lands inside them.
|
|
306
|
+
`createViewportLayer` returns a `ViewportLayer`, adding:
|
|
307
|
+
|
|
308
|
+
```ts
|
|
309
|
+
layer.reproject(outer, dims, screen); // → inner-world point, or null if outside
|
|
310
|
+
viewportsAt(layers, outer, dims, screen); // → topmost viewport containing it
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
`bounds` is already a pure function of `(outer, dims)`, so re-projection
|
|
314
|
+
recomputes the exact rect the frame painted rather than a remembered one — no
|
|
315
|
+
stored state and nothing to go stale. Right and bottom edges are exclusive, so
|
|
316
|
+
adjacent viewports never both claim a pixel.
|
|
317
|
+
|
|
318
|
+
This deliberately does **not** touch the dispatcher, which the previous
|
|
319
|
+
docstring promised it would. Tools still target the outer view; a consumer that
|
|
320
|
+
wants a click inside a viewport to mean something calls `reproject` from its own
|
|
321
|
+
handler. Making tools work _inside_ a viewport raises questions this primitive
|
|
322
|
+
does not answer — which view a pinch zooms, what a drag leaving the rect does —
|
|
323
|
+
and is tracked as its own item.
|
|
324
|
+
|
|
325
|
+
- Updated dependencies [d2a9049]
|
|
326
|
+
- Updated dependencies [24daa08]
|
|
327
|
+
- @weasel-js/gestures@1.0.2
|
|
328
|
+
- @weasel-js/font@1.0.2
|
|
329
|
+
- @weasel-js/geom@1.0.2
|
|
330
|
+
- @weasel-js/history@1.0.2
|
|
331
|
+
- @weasel-js/modes@1.0.2
|
|
332
|
+
|
|
3
333
|
## 1.0.1
|
|
4
334
|
|
|
5
335
|
### Patch Changes
|
|
@@ -33,6 +33,10 @@ declare function apply(m: Mat3, x: number, y: number): [number, number];
|
|
|
33
33
|
* matches clip-down).
|
|
34
34
|
*/
|
|
35
35
|
declare function screenToClip(width: number, height: number): Mat3;
|
|
36
|
+
/** The renderer's 3x3 matrix operations, as one namespace. These work on the
|
|
37
|
+
* 9-element `Float32Array` form the GL uniform upload wants — distinct from
|
|
38
|
+
* `@weasel-js/geom`'s 6-element affine `Mat3`, though the logical element
|
|
39
|
+
* order is the same. */
|
|
36
40
|
declare const mat3: {
|
|
37
41
|
identity: typeof identity;
|
|
38
42
|
multiply: typeof multiply;
|
|
@@ -140,6 +144,9 @@ declare function fontString(s: ResolvedTextStyle): string;
|
|
|
140
144
|
* (300/500/900) are out of scope for slice 1.
|
|
141
145
|
*/
|
|
142
146
|
|
|
147
|
+
/** A span of text with its own styling, as authored. Fields left absent
|
|
148
|
+
* inherit from the node's text style — this is the difference between a run
|
|
149
|
+
* and a fully resolved one. */
|
|
143
150
|
interface StyledRun {
|
|
144
151
|
text: string;
|
|
145
152
|
bold?: boolean;
|
|
@@ -155,8 +162,13 @@ interface StyledRun {
|
|
|
155
162
|
underline?: boolean;
|
|
156
163
|
strikethrough?: boolean;
|
|
157
164
|
}
|
|
165
|
+
/** Normalize the two accepted spellings of text content — a plain string or
|
|
166
|
+
* an array of runs — to runs. Throws on a run with no string `text`. */
|
|
158
167
|
declare function toRuns(input: string | StyledRun[]): StyledRun[];
|
|
168
|
+
/** Concatenate runs, dropping all styling. */
|
|
159
169
|
declare function runsToPlainText(runs: readonly StyledRun[]): string;
|
|
170
|
+
/** Render runs as Markdown, preserving bold and italic. The flavor written to
|
|
171
|
+
* the clipboard alongside the plain-text one. */
|
|
160
172
|
declare function runsToMarkdown(runs: readonly StyledRun[]): string;
|
|
161
173
|
/**
|
|
162
174
|
* Parse a small markdown subset (`**bold**`, `*italic*`, `***both***`) into
|
|
@@ -184,6 +196,8 @@ declare function markdownToRuns(input: string): StyledRun[];
|
|
|
184
196
|
* `runs/rangeStyle.ts` for why the model collapses the tri-state.
|
|
185
197
|
*/
|
|
186
198
|
|
|
199
|
+
/** A run with every style resolved against the node's text style — no
|
|
200
|
+
* optional inheritance left. This is what layout and painting consume. */
|
|
187
201
|
interface ResolvedRun {
|
|
188
202
|
text: string;
|
|
189
203
|
fontFamily: string;
|
|
@@ -201,6 +215,8 @@ interface ResolvedRun {
|
|
|
201
215
|
/** Draw a rule through this run's x-height. Additive over the node style. */
|
|
202
216
|
strikethrough: boolean;
|
|
203
217
|
}
|
|
218
|
+
/** Resolve each run's styling against the node's text style, filling in
|
|
219
|
+
* everything the run left inherited. */
|
|
204
220
|
declare function resolveRuns(runs: readonly StyledRun[], style: ResolvedTextStyle): ResolvedRun[];
|
|
205
221
|
|
|
206
222
|
/**
|
|
@@ -210,6 +226,9 @@ declare function resolveRuns(runs: readonly StyledRun[], style: ResolvedTextStyl
|
|
|
210
226
|
* `height`) is the legacy behavior: offset 0.
|
|
211
227
|
*/
|
|
212
228
|
type TextVerticalAlign = 'top' | 'center' | 'bottom';
|
|
229
|
+
/** How far to shift laid-out text down inside a box of `boxHeight` to satisfy
|
|
230
|
+
* a vertical alignment. Zero when the box height is unknown or alignment is
|
|
231
|
+
* top. */
|
|
213
232
|
declare function verticalAlignOffset(align: TextVerticalAlign | undefined, boxHeight: number | undefined, textHeight: number): number;
|
|
214
233
|
|
|
215
234
|
/**
|
|
@@ -286,6 +305,8 @@ interface SolidPaint {
|
|
|
286
305
|
}
|
|
287
306
|
/** DrawCommand variants implemented through step 6. */
|
|
288
307
|
type DrawCommand = PathDrawCommand | GroupDrawCommand | TextDrawCommand | ImageDrawCommand | ShaderDrawCommand;
|
|
308
|
+
/** Draw a path, filled and/or stroked. The workhorse command: every shape the
|
|
309
|
+
* kit draws that is not text, an image, or a custom shader is one of these. */
|
|
289
310
|
interface PathDrawCommand {
|
|
290
311
|
kind: 'path';
|
|
291
312
|
path: Path;
|
|
@@ -308,6 +329,9 @@ interface PathDrawCommand {
|
|
|
308
329
|
*/
|
|
309
330
|
vertexColors?: number[];
|
|
310
331
|
}
|
|
332
|
+
/** Draw a list of commands under a shared transform, opacity, color matrix
|
|
333
|
+
* and clip. Groups nest, and their effects accumulate down the stack — this
|
|
334
|
+
* is how a container node's transform reaches its descendants. */
|
|
311
335
|
interface GroupDrawCommand {
|
|
312
336
|
kind: 'group';
|
|
313
337
|
transform?: Mat3;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-
|
|
1
|
+
import { DEFAULT_GUIDE_TOLERANCE_PX, pxExtent } from './chunk-U45SODC2.js';
|
|
2
2
|
|
|
3
3
|
// src/interactions/actions/resize/behaviors/clampMinSize.ts
|
|
4
4
|
function clampMinSize(args) {
|
|
@@ -244,5 +244,5 @@ function fixedCornerOf(bounds, anchor) {
|
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
export { CORNER_ANCHORS, DEFAULT_RESIZE_BEHAVIORS, clampMinSize, cornerPoint, cornerResizeHandles, fixedCornerOf, hitCornerHandle, lockAspectWithModifier, pointSnapToGrid, snapToGrid, snapToGuides };
|
|
247
|
-
//# sourceMappingURL=chunk-
|
|
248
|
-
//# sourceMappingURL=chunk-
|
|
247
|
+
//# sourceMappingURL=chunk-3JYFAQIB.js.map
|
|
248
|
+
//# sourceMappingURL=chunk-3JYFAQIB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interactions/actions/resize/behaviors/clampMinSize.ts","../src/interactions/actions/resize/behaviors/lockAspect.ts","../src/interactions/actions/resize/behaviors/snapToGrid.ts","../src/interactions/actions/resize/behaviors/snapToGuides.ts","../src/interactions/actions/resize/behaviors/pointSnapToGrid.ts","../src/interactions/actions/resize/behaviors/index.ts","../src/interactions/actions/resize/cornerHandles.ts"],"names":[],"mappings":";;;AAKO,SAAS,aAAuC,IAAA,EAG3B;AAC1B,EAAA,MAAM,EAAE,QAAA,EAAU,SAAA,EAAU,GAAI,IAAA;AAChC,EAAA,OAAO;AAAA,IACL,MAAA,CAAO,IAAA,EAAM,EAAE,IAAA,EAAM,QAAO,EAAG;AAC7B,MAAA,IAAI,EAAE,CAAA,EAAG,CAAA,EAAG,KAAA,EAAO,QAAO,GAAI,IAAA;AAC9B,MAAA,IAAI,OAAA,GAAU,KAAA;AACd,MAAA,IAAI,MAAA,CAAO,CAAA,KAAM,MAAA,IAAU,KAAA,GAAQ,QAAA,EAAU;AAC3C,QAAA,IAAI,MAAA,CAAO,MAAM,KAAA,EAAO;AAEtB,UAAA,KAAA,GAAQ,QAAA;AAAA,QACV,CAAA,MAAO;AAGL,UAAA,MAAM,QAAQ,CAAA,GAAI,KAAA;AAClB,UAAA,CAAA,GAAI,KAAA,GAAQ,QAAA;AACZ,UAAA,KAAA,GAAQ,QAAA;AAAA,QACV;AACA,QAAA,OAAA,GAAU,IAAA;AAAA,MACZ;AACA,MAAA,IAAI,MAAA,CAAO,CAAA,KAAM,MAAA,IAAU,MAAA,GAAS,SAAA,EAAW;AAC7C,QAAA,IAAI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,CAAC,CAAA;AAC/B,IAAA,OAAO,EAAE,IAAI,CAAA,CAAE,CAAA,EAAG,IAAI,CAAA,CAAE,CAAA,EAAG,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO;AAAA,EAC9C,CAAC,CAAA;AACH;AAIO,SAAS,eAAA,CACd,MAAA,EACA,EAAA,EACA,EAAA,EACA,MAAA,EACS;AACT,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,EAAA,GAAK,MAAA,CAAO,EAAE,CAAA,IAAK,MAAA,IAC9B,IAAA,CAAK,GAAA,CAAI,EAAA,GAAK,MAAA,CAAO,EAAE,CAAA,IAAK,MAAA;AACnC;AAWO,SAAS,aAAA,CACd,QACA,MAAA,EAC0B;AAC1B,EAAA,OAAO;AAAA,IACL,CAAA,EAAG,OAAO,CAAA,KAAM,KAAA,GAAQ,OAAO,CAAA,GAAI,MAAA,CAAO,QAAQ,MAAA,CAAO,CAAA;AAAA,IACzD,CAAA,EAAG,OAAO,CAAA,KAAM,KAAA,GAAQ,OAAO,CAAA,GAAI,MAAA,CAAO,SAAS,MAAA,CAAO;AAAA,GAC5D;AACF","file":"chunk-3JYFAQIB.js","sourcesContent":["import type { BoundsConstraint, ResizePose } from '../../../gestures/types';\n\n/** Resize constraint that stops a node shrinking past a minimum. The anchored\n * edge stays put, so clamping pushes the dragged edge back rather than moving\n * the node. */\nexport function clampMinSize<TPose extends ResizePose>(args: {\n minWidth: number;\n minHeight: number;\n}): BoundsConstraint<TPose> {\n const { minWidth, minHeight } = args;\n return {\n onMove(_ctx, { pose, anchor }) {\n let { x, y, width, height } = pose;\n let changed = false;\n if (anchor.x !== 'free' && width < minWidth) {\n if (anchor.x === 'min') {\n // West edge is anchor; east edge was dragged. Hold x; widen to min.\n width = minWidth;\n } else {\n // East edge is anchor at originalRight = x + width. Hold the right;\n // shift x left so width = minWidth.\n const right = x + width;\n x = right - minWidth;\n width = minWidth;\n }\n changed = true;\n }\n if (anchor.y !== 'free' && height < minHeight) {\n if (anchor.y === 'min') {\n height = minHeight;\n } else {\n const bottom = y + height;\n y = bottom - minHeight;\n height = minHeight;\n }\n changed = true;\n }\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n ResizePose,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\n/** Aspect-ratio lock: drag a corner/edge with `key` (default `'shift'`) held\n * to keep the resized bounds at the start-pose's `width / height` ratio.\n *\n * Strategy:\n * - Compute the proposed deltas in width and height (signed, relative to\n * origin). Whichever axis has the larger absolute delta \"wins\"; the other\n * is recomputed from `(originW / originH) * winnerDelta`.\n * - The opposite corner/edge stays anchored — for the corner case we infer\n * the anchor from the proposed bounds; for an edge handle we resize the\n * orthogonal axis symmetrically around the dragged edge's anchor (the\n * handle's own line stays put, the orthogonal axis grows/shrinks centered\n * on the un-dragged edge — see notes below).\n * - No-op when the modifier is not held, when the origin has zero width or\n * height (no defined ratio), or when the proposed pose hasn't moved.\n *\n * Edge-handle handling: with `anchor.x !== 'free' && anchor.y === 'free'`\n * (an `e` or `w` handle), only the width was driven by the pointer. We pick\n * the new height as `width / ratio` and pin it to the un-dragged y axis by\n * anchoring at the origin's top edge (`y` stays at `origin.y`). Symmetric\n * for `n` / `s`.\n */\nexport function lockAspectWithModifier<TPose extends ResizePose>(opts: {\n key?: ModKey;\n} = {}): BoundsConstraint<TPose> {\n const { key = 'shift' } = opts;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (!ctx.modifiers[key]) return;\n const origin = ctx.origin.get(ctx.draggedIds[0]) as ResizePose | undefined;\n if (!origin) return;\n if (origin.width === 0 || origin.height === 0) return;\n const ratio = origin.width / origin.height; // w / h\n\n // Signed deltas relative to origin. Negative deltas mean the user has\n // dragged through the anchor and flipped the rect; we preserve sign on\n // the recomputed axis so the flipped quadrant stays consistent.\n const dw = pose.width - origin.width;\n const dh = pose.height - origin.height;\n\n let nw: number;\n let nh: number;\n\n if (anchor.x === 'free' && anchor.y === 'free') {\n // No driven axis — nothing to lock against.\n return;\n } else if (anchor.x === 'free') {\n // Edge handle: n or s. height is driven; width follows.\n nh = pose.height;\n nw = nh * ratio;\n // sign-preserve width if the original height delta caused a flip.\n // (height-driven only; width direction follows ratio absolutely.)\n if (nw < 0) nw = -nw;\n } else if (anchor.y === 'free') {\n // Edge handle: e or w. width is driven; height follows.\n nw = pose.width;\n nh = nw / ratio;\n if (nh < 0) nh = -nh;\n } else {\n // Corner handle. Pick the dominant axis by absolute delta.\n if (Math.abs(dw) >= Math.abs(dh)) {\n nw = pose.width;\n // Match height sign to width sign so the rect stays in the same\n // quadrant the pointer chose.\n nh = (Math.abs(nw) / ratio) * Math.sign(pose.height || 1);\n } else {\n nh = pose.height;\n nw = (Math.abs(nh) * ratio) * Math.sign(pose.width || 1);\n }\n }\n\n // Recompute x/y from the anchor (the un-dragged edge stays pinned).\n let nx = pose.x;\n let ny = pose.y;\n if (anchor.x === 'min') {\n // West edge anchored at origin.x.\n nx = origin.x;\n } else if (anchor.x === 'max') {\n // East edge anchored at origin.x + origin.width.\n nx = origin.x + origin.width - nw;\n } else {\n // Edge handle (n/s): width grew/shrunk via ratio. Center horizontally\n // about the origin's center so the rect stays visually centered on\n // the dragged edge's midline.\n nx = origin.x + origin.width / 2 - nw / 2;\n }\n if (anchor.y === 'min') {\n ny = origin.y;\n } else if (anchor.y === 'max') {\n ny = origin.y + origin.height - nh;\n } else {\n ny = origin.y + origin.height / 2 - nh / 2;\n }\n\n return {\n pose: { ...pose, x: nx, y: ny, width: nw, height: nh },\n };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n ResizePose,\n} from '../../../gestures/types';\n\ntype ModKey = keyof ModifierState;\n\n/** Resize constraint that snaps the moving edges to a grid, leaving the\n * anchored ones where they are. By default a node already smaller than one\n * grid cell on an axis is left unsnapped on that axis, so it stays resizable\n * at sub-grid sizes. */\nexport function snapToGrid<TPose extends ResizePose>(args: {\n spacing: number;\n bypassKey?: ModKey;\n suspendBelowDim?: boolean;\n}): BoundsConstraint<TPose> {\n const { spacing, bypassKey, suspendBelowDim = true } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const origin = ctx.origin.get(ctx.draggedIds[0])!;\n const subX = suspendBelowDim && origin.width < spacing;\n const subY = suspendBelowDim && origin.height < spacing;\n\n let { x, y, width, height } = pose;\n let changed = false;\n\n if (anchor.x !== 'free' && !subX) {\n if (anchor.x === 'min') {\n // East edge moves; west (x) stays.\n const east = round(x + width);\n width = east - x;\n } else {\n // West edge moves; east (x+width) stays.\n const right = origin.x + origin.width;\n const newX = round(x);\n width = right - newX;\n x = newX;\n }\n changed = true;\n }\n if (anchor.y !== 'free' && !subY) {\n if (anchor.y === 'min') {\n const south = round(y + height);\n height = south - y;\n } else {\n const bottom = origin.y + origin.height;\n const newY = round(y);\n height = bottom - newY;\n y = newY;\n }\n changed = true;\n }\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n BoundsConstraint,\n ResizePose,\n} from '../../../gestures/types';\nimport type { Guide } from 'features/guides/types';\nimport type { View } from 'core/viewport/view';\nimport { pxExtent } from 'core/viewport/pxExtent';\nimport { DEFAULT_GUIDE_TOLERANCE_PX } from '../../../gestures/shared/strategies/guides';\n\ntype ModKey = keyof ModifierState;\n\n/** Options for the resize-flavored `snapToGuides`. */\nexport interface SnapToGuidesResizeArgs {\n /** Stable getter into the live guide list (typically from `useGuides`). */\n getGuides: () => readonly Guide[];\n /** Snap tolerance (screen px when `getView` is set, world units otherwise). */\n tolerance?: number;\n /** Read the active view; required for screen-pixel tolerance. */\n getView?: () => View;\n /** Modifier key that bypasses snapping while held. */\n bypassKey?: ModKey;\n}\n\n/**\n * Resize behavior that snaps the active edge of the dragged rect to the\n * nearest guide on the corresponding axis when within `tolerance`. The\n * \"free\" axis is left untouched. The fixed (anchor) edge stays pinned;\n * only the moving edge snaps.\n *\n * On the X axis, vertical guides (`axis: 'x'`) constrain the moving vertical\n * edge — east when `anchor.x === 'min'` (west pinned), west when `'max'`.\n * Likewise on Y for horizontal guides.\n */\nexport function snapToGuides<TPose extends ResizePose>(\n args: SnapToGuidesResizeArgs,\n): BoundsConstraint<TPose> {\n const tolerance = args.tolerance ?? DEFAULT_GUIDE_TOLERANCE_PX;\n const getView = args.getView;\n const bypassKey = args.bypassKey;\n\n return {\n onMove(ctx, { pose, anchor }) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n const guides = args.getGuides();\n if (guides.length === 0) return;\n\n // Per axis: a vertical guide is matched by a horizontal distance, so it\n // answers to `scale.x` alone.\n const tol = getView ? pxExtent(tolerance, getView().scale) : { x: tolerance, y: tolerance };\n\n let { x, y, width, height } = pose;\n let changed = false;\n\n // X-axis: snap the moving vertical edge to the nearest 'x' guide.\n if (anchor.x !== 'free') {\n const movingX = anchor.x === 'min' ? x + width : x;\n let bestD = 0;\n let bestAbs = Infinity;\n for (const g of guides) {\n if (g.axis !== 'x') continue;\n const d = g.offset - movingX;\n const ad = Math.abs(d);\n if (ad <= tol.x && ad < bestAbs) {\n bestAbs = ad;\n bestD = d;\n }\n }\n if (bestAbs !== Infinity && bestD !== 0) {\n if (anchor.x === 'min') {\n // East edge moves; west (x) stays.\n width = width + bestD;\n } else {\n // West edge moves; east (x+width) stays.\n x = x + bestD;\n width = width - bestD;\n }\n changed = true;\n }\n }\n\n // Y-axis: snap the moving horizontal edge to the nearest 'y' guide.\n if (anchor.y !== 'free') {\n const movingY = anchor.y === 'min' ? y + height : y;\n let bestD = 0;\n let bestAbs = Infinity;\n for (const g of guides) {\n if (g.axis !== 'y') continue;\n const d = g.offset - movingY;\n const ad = Math.abs(d);\n if (ad <= tol.y && ad < bestAbs) {\n bestAbs = ad;\n bestD = d;\n }\n }\n if (bestAbs !== Infinity && bestD !== 0) {\n if (anchor.y === 'min') {\n height = height + bestD;\n } else {\n y = y + bestD;\n height = height - bestD;\n }\n changed = true;\n }\n }\n\n if (!changed) return;\n return { pose: { ...pose, x, y, width, height } };\n },\n };\n}\n","import type {\n ModifierState,\n PointSnapBehavior,\n PointSnapContext,\n PointSnapFrame,\n PointSnapResult,\n ResizePose,\n} from '../../../gestures/types';\n\n/** Resize behavior that snaps one reference point of the resize — the dragged\n * corner, the fixed corner, or the center, per `frame` — to a grid, moving\n * the whole pose by the same delta. Unlike the bounds-level `snapToGrid`,\n * this preserves the node's dimensions. */\nexport function pointSnapToGrid<TPose extends ResizePose>(args: {\n spacing: number;\n frame?: PointSnapFrame;\n bypassKey?: keyof ModifierState;\n}): PointSnapBehavior<TPose> {\n const { spacing, frame = 'dragged-corner', bypassKey } = args;\n const round = (v: number) => Math.round(v / spacing) * spacing;\n\n return {\n id: `pointSnapToGrid:${frame}`,\n onMove(ctx: PointSnapContext<TPose>): PointSnapResult | null {\n if (bypassKey && ctx.modifiers[bypassKey]) return null;\n const src =\n frame === 'dragged-corner' ? ctx.draggedCorner :\n frame === 'fixed-corner' ? ctx.fixedCorner :\n frame === 'center' ? ctx.center :\n ctx.origin;\n if (!src) return null;\n return { frame, worldX: round(src.worldX), worldY: round(src.worldY) };\n },\n };\n}\n","export { clampMinSize } from './clampMinSize';\nexport { lockAspectWithModifier } from './lockAspect';\nexport { snapToGrid } from './snapToGrid';\n\nimport type { BoundsConstraint, ResizePose } from '../../../gestures/types';\nimport { lockAspectWithModifier } from './lockAspect';\n\n/** The kit's standard resize behaviors, applied when a consumer doesn't\n * supply its own list: shift-drag locks the start pose's aspect ratio.\n * Pass an explicit `behaviors: []` to opt out. Stateless, so one shared\n * frozen instance is safe across every gesture. */\nexport const DEFAULT_RESIZE_BEHAVIORS: readonly BoundsConstraint<ResizePose>[] =\n Object.freeze([lockAspectWithModifier()]);\nexport { snapToGuides } from './snapToGuides';\nexport { pointSnapToGrid } from './pointSnapToGrid';\n","import type { ResizeAnchor } from '../../gestures/types';\nimport type { Bounds } from 'core/viewport/fitViewToBounds';\n\n/** Corner resize-handle: world-space center plus the anchor that pins the opposite corner during resize. */\nexport interface CornerHandle {\n cx: number;\n cy: number;\n anchor: ResizeAnchor;\n}\n\n/** Which AABB edge a corner sits on, per axis. `'min'` = the x/y origin\n * edge; `'max'` = the origin + extent edge. */\nexport type CornerEdge = 'min' | 'max';\n\n/** One entry of the canonical 4-corner resize layout. The single source of\n * truth for \"which corner maps to which anchor / handle-kind\". */\nexport interface CornerAnchor {\n /** Which x-edge the corner sits on (`'min'` = left, `'max'` = right). */\n xEdge: CornerEdge;\n /** Which y-edge the corner sits on (`'min'` = top, `'max'` = bottom). */\n yEdge: CornerEdge;\n /** Anchor that pins the diagonally-opposite (fixed) corner. Always the\n * axis-wise opposite of `{xEdge, yEdge}`. */\n anchor: ResizeAnchor;\n /** Affordance/handle discriminator string for this corner. */\n kind: string;\n /** Short positional tag (`'<xEdge>-<yEdge>'`), e.g. `'min-max'`. */\n tag: string;\n}\n\n/**\n * The single ordered corner→anchor table. Order is **load-bearing**: every\n * consumer iterates it in this sequence (TL, TR, BL, BR) so positional\n * meaning (the i-th handle / `kind` / `tag`) stays consistent across the\n * resize-handle affordance, the affordance-hit classifier, and\n * `cornerResizeHandles`. Each corner's `anchor` names the diagonally\n * opposite corner, so dragging the corner scales the box from that fixed\n * point.\n */\nexport const CORNER_ANCHORS: readonly CornerAnchor[] = [\n { xEdge: 'min', yEdge: 'min', anchor: { x: 'max', y: 'max' }, kind: 'handle:top-left', tag: 'min-min' },\n { xEdge: 'max', yEdge: 'min', anchor: { x: 'min', y: 'max' }, kind: 'handle:top-right', tag: 'max-min' },\n { xEdge: 'min', yEdge: 'max', anchor: { x: 'max', y: 'min' }, kind: 'handle:bottom-left', tag: 'min-max' },\n { xEdge: 'max', yEdge: 'max', anchor: { x: 'min', y: 'min' }, kind: 'handle:bottom-right', tag: 'max-max' },\n];\n\n/** Resolve a corner's world-space position for the given bounds. `xEdge`\n * `'max'` → `x + width`; `yEdge` `'max'` → `y + height`. */\nexport function cornerPoint(\n bounds: Bounds,\n entry: Pick<CornerAnchor, 'xEdge' | 'yEdge'>,\n): { x: number; y: number } {\n return {\n x: entry.xEdge === 'max' ? bounds.x + bounds.width : bounds.x,\n y: entry.yEdge === 'max' ? bounds.y + bounds.height : bounds.y,\n };\n}\n\n/** Standard 4-corner resize-handle layout: each corner pins the opposite\n * corner via an anchor of `{x: 'min'|'max', y: 'min'|'max'}` so dragging it\n * scales the box from the fixed opposite corner. Decodes {@link CORNER_ANCHORS}\n * against `bounds`. */\nexport function cornerResizeHandles(bounds: Bounds): CornerHandle[] {\n return CORNER_ANCHORS.map((c) => {\n const p = cornerPoint(bounds, c);\n return { cx: p.x, cy: p.y, anchor: c.anchor };\n });\n}\n\n/** Square hit-test for a handle: returns true if `(px, py)` is within\n * `radius` of the handle center on both axes. */\nexport function hitCornerHandle(\n handle: CornerHandle,\n px: number,\n py: number,\n radius: number,\n): boolean {\n return Math.abs(px - handle.cx) <= radius\n && Math.abs(py - handle.cy) <= radius;\n}\n\n/** The corner that does NOT move under a resize gesture with the given\n * anchor. Used by the rotated-resize math to pin a world-space invariant.\n *\n * Convention: `anchor.x === 'min'` means the min-x (left) edge is the\n * fixed anchor, so the fixed corner sits at `x = bounds.x` (min-x).\n * `anchor.x === 'max'` means the max-x (right) edge is fixed, so the\n * fixed corner sits at `x = bounds.x + bounds.width`. `'free'` on an\n * axis means that axis doesn't move; the fixed coord is the bounds\n * origin on that axis. */\nexport function fixedCornerOf(\n bounds: Bounds,\n anchor: ResizeAnchor,\n): { x: number; y: number } {\n return {\n x: anchor.x === 'max' ? bounds.x + bounds.width : bounds.x,\n y: anchor.y === 'max' ? bounds.y + bounds.height : bounds.y,\n };\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RECT_ORIGIN_PROJECTION } from './chunk-
|
|
1
|
+
import { RECT_ORIGIN_PROJECTION } from './chunk-U45SODC2.js';
|
|
2
2
|
import { registerOpFactory } from './chunk-GVCNT7UH.js';
|
|
3
3
|
|
|
4
4
|
// src/core/ops/transform.ts
|
|
@@ -99,5 +99,5 @@ function snap(strategy, opts = {}) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
export { createReparentOp, createTransformOp, deleteScratch, getScratch, scratchKey, setScratch, snap };
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
103
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-3KGMJMOS.js.map
|
|
103
|
+
//# sourceMappingURL=chunk-3KGMJMOS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/ops/transform.ts","../src/core/ops/reparent.ts","../src/interactions/scratchKey.ts","../src/interactions/gestures/shared/snap.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,kBAAyB,IAAA,EAAgC;AACvE,EAAA,MAAM,EAAE,IAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,GAAc,CAAA,UAAA,EAAa,EAAE,CAAA,CAAA,EAAG,GAAI,IAAA;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,MAAM,EAAE,EAAA,EAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,EAAY;AAAA,IACzC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAM,OAAA,EAAS;AAOb,MAAC,OAAA,CAAoC,OAAA,CAAQ,EAAA,EAAI,EAAE,CAAA;AACnD,MAAA,IAAI,gBAAA,CAAiB,IAAA,EAAM,EAAE,CAAA,EAAG,OAAO,KAAA;AACvC,MAAA,OAAO,MAAA;AAAA,IACT,CAAA;AAAA,IACA,MAAA,GAAS;AACP,MAAA,OAAO,iBAAA,CAAyB,EAAE,EAAA,EAAI,IAAA,EAAM,IAAI,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,CAAA;AAAA,IAChF;AAAA,GACF;AACF;AAEA,iBAAA,CAA0C,WAAA,EAAa,CAA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e,MAAA,EAAW;AAC9B,MAAA,MAAM,WAAW,IAAA,CAAK,SAAA,CAAU,YAAY,SAAA,CAAU,EAAA,EAAI,UAAU,EAAE,CAAA;AACtE,MAAA,MAAM,OAAA,GAAU,QAAA,CAAS,IAAA,CAAK,QAAA,EAAU,GAAG,CAAA;AAC3C,MAAA,IAAI,YAAY,IAAA,EAAM;AACtB,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,SAAA,CAAU,UAAU,CAAA;AACpC,MAAA,MAAM,EAAA,GAAK,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA;AACjC,MAAA,OAAO;AAAA,QACL,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,EAAA,CAAG,CAAA,EAAG,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,GAAG,CAAA;AAAE,OACnE;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-UB6A6L77.js","sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface TransformAdapter<TPose> {\n setPose(id: string, pose: TPose): void;\n}\n\n/** @internal */\ninterface TransformArgs<TPose> {\n id: string;\n from: TPose;\n to: TPose;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Op: set an object's pose, inverting back to `from`. `coalesceKey` defaults to\n * `transform:${id}` so successive pose writes to the same node (drag-move,\n * resize, repeated nudges) merge into one undo entry within the history's\n * coalesce window. Pass an explicit key (or a unique one) to opt out. */\nexport function createTransformOp<TPose>(args: TransformArgs<TPose>): Op {\n const { id, from, to, label, coalesceKey = `transform:${id}` } = args;\n return {\n name: 'transform',\n args: { id, from, to, label, coalesceKey },\n label,\n coalesceKey,\n apply(adapter) {\n // Always call setPose so consumers that inspect op behavior (tests,\n // overlays) see a consistent \"this op writes (id, to)\" signal. When\n // from and to are structurally identical, additionally report a\n // no-op to history so the entry can be skipped from the undo stack.\n // setPose(id, to) is idempotent in this branch — adapters write the\n // same pose they already had.\n (adapter as TransformAdapter<TPose>).setPose(id, to);\n if (poseShallowEqual(from, to)) return false;\n return undefined;\n },\n invert() {\n return createTransformOp<TPose>({ id, from: to, to: from, label, coalesceKey });\n },\n };\n}\n\nregisterOpFactory<TransformArgs<unknown>>('transform', (args) => createTransformOp(args));\n\nfunction poseShallowEqual<TPose>(a: TPose, b: TPose): boolean {\n if (a === b) return true;\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') return false;\n const ka = Object.keys(a as object);\n const kb = Object.keys(b as object);\n if (ka.length !== kb.length) return false;\n for (const k of ka) {\n if ((a as Record<string, unknown>)[k] !== (b as Record<string, unknown>)[k]) return false;\n }\n return true;\n}\n","import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface ReparentAdapter {\n setParent(id: string, parentId: string | null): void;\n}\n\n/** @internal */\ninterface ReparentArgs {\n id: string;\n fromParentId: string | null;\n toParentId: string | null;\n label?: string;\n coalesceKey?: string;\n}\n\n/**\n * Op: change `id`'s parent, inverting back to the prior parent.\n *\n * `coalesceKey` defaults to `reparent:${id}` so successive reparents of the\n * same id batch-merge cleanly.\n */\nexport function createReparentOp(args: ReparentArgs): Op {\n const { id, fromParentId, toParentId, label = 'Reparent', coalesceKey = `reparent:${id}` } = args;\n return {\n name: 'reparent',\n args: { id, fromParentId, toParentId, label, coalesceKey },\n label,\n coalesceKey,\n apply(adapter) {\n (adapter as ReparentAdapter).setParent(id, toParentId);\n },\n invert() {\n return createReparentOp({\n id,\n fromParentId: toParentId,\n toParentId: fromParentId,\n label,\n coalesceKey,\n });\n },\n };\n}\n\nregisterOpFactory<ReparentArgs>('reparent', (args) => createReparentOp(args));\n","/**\n * Typed keys for the gesture/behavior scratch store.\n *\n * Gestures expose `ctx.scratch: Record<string, unknown>` as a per-gesture\n * mutable bag that behaviors use to stash state across `onDown` / `onMove`\n * / `onEnd` calls. The store is `unknown`-valued because behaviors are\n * tool-agnostic — a single behavior may run under different tools with\n * different scratch shapes. Without a typing convention every read site\n * has to `(ctx.scratch as <some shape>)[KEY]`, and a writer changing the\n * shape can silently break readers with no compile-time signal.\n *\n * `ScratchKey<T>` is a phantom-typed string that carries its payload type\n * via a branded interface. `getScratch` and `setScratch` use the brand to\n * narrow / constrain at the typing layer; at runtime the key is just its\n * underlying string and the store remains a plain `Record`.\n *\n * @example\n * ```ts\n * // Module-level (or behavior-level) constant, shared by writer + reader:\n * const LASSO_VERTICES = scratchKey<readonly { x: number; y: number }[]>('lasso.vertices');\n *\n * // Writer (a tool's onMove):\n * setScratch(ctx.scratch, LASSO_VERTICES, vertices);\n *\n * // Reader (a behavior's onEnd):\n * const vertices = getScratch(ctx.scratch, LASSO_VERTICES) ?? [];\n * // ^? readonly { x: number; y: number }[] | undefined\n * ```\n */\n\n/** Phantom-typed key for a scratch slot. The `__scratchKeyPayload` phantom\n * field carries the value type without occupying any runtime memory. */\nexport interface ScratchKey<T> {\n readonly name: string;\n /** Phantom — never read at runtime. Only present so TypeScript can\n * recover `T` at use sites. */\n readonly __scratchKeyPayload?: (_: T) => T;\n}\n\n/** Compatible scratch store shape. The kit's gesture context's `scratch`\n * field already satisfies this; consumers don't need to construct one. */\nexport type ScratchStore = Record<string, unknown>;\n\n/**\n * Make a typed scratch key. Use module-level constants so the same key\n * is shared by writer and reader.\n *\n * Namespace the name by behavior or feature to avoid collisions\n * (`'behavior.field'` is a good convention). Two keys with the same\n * `name` refer to the same slot at runtime — the type parameter is a\n * compile-time contract, not a uniqueness guarantee.\n */\nexport function scratchKey<T>(name: string): ScratchKey<T> {\n return { name };\n}\n\n/** Read a typed slot from the scratch store. Returns `undefined` if\n * nothing has been written under the key. */\nexport function getScratch<T>(\n store: ScratchStore,\n key: ScratchKey<T>,\n): T | undefined {\n return store[key.name] as T | undefined;\n}\n\n/** Write a value to a typed slot. Overwrites whatever was there. */\nexport function setScratch<T>(\n store: ScratchStore,\n key: ScratchKey<T>,\n value: T,\n): void {\n store[key.name] = value;\n}\n\n/** Remove a slot from the scratch store. Returns `true` if it was set,\n * `false` if it wasn't. */\nexport function deleteScratch<T>(\n store: ScratchStore,\n key: ScratchKey<T>,\n): boolean {\n if (Object.prototype.hasOwnProperty.call(store, key.name)) {\n delete store[key.name];\n return true;\n }\n return false;\n}\n","import type { MoveBehavior, ModifierState, SnapStrategy } from '../types';\nimport {\n RECT_ORIGIN_PROJECTION,\n type OriginProjection,\n} from './strategies/grid';\n\ntype ModKey = keyof ModifierState;\n\n/**\n * Generic snap behavior factory: wraps a `SnapStrategy` and returns a\n * `MoveBehavior` whose `onMove` returns a uniform `GroupTransform`.\n *\n * Implementation:\n * 1. Compute the primary's proposed pose by applying the gesture's\n * `transform` (translate) to `origin.get(primaryId)`.\n * 2. Call `strategy.snap(proposed)`. If null, no-op.\n * 3. Derive the snapped delta via the `OriginProjection`:\n * dx = origin(snapped).x - origin(originPose).x\n * ...so the gesture applies the same delta to every dragged id.\n *\n * The pose-shape-aware delta extraction lives here — gestures stay pose-shape\n * agnostic. Default projection is `{x, y}`-bearing (rect / path / polygon).\n * Pass `origin` for exotic poses.\n */\nexport function snap<TPose>(\n strategy: SnapStrategy<TPose>,\n opts: { bypassKey?: ModKey; origin?: OriginProjection<TPose> } = {},\n): MoveBehavior<TPose> {\n const { bypassKey } = opts;\n const proj: OriginProjection<TPose> = opts.origin\n ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n return {\n onMove(ctx, transform) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n // The new contract: behaviors see a GroupTransform, not a pose. But\n // strategies still operate on poses. Reconstruct the proposed pose\n // by applying the (translate) transform to the primary's origin.\n if (transform.kind !== 'translate') return;\n const primaryId = ctx.draggedIds[0];\n if (primaryId === undefined) return;\n const originPose = ctx.origin.get(primaryId);\n if (originPose === undefined) return;\n const proposed = proj.translate(originPose, transform.dx, transform.dy);\n const snapped = strategy.snap(proposed, ctx);\n if (snapped === null) return;\n const o0 = proj.getOrigin(originPose);\n const o1 = proj.getOrigin(snapped);\n return {\n transform: { kind: 'translate', dx: o1.x - o0.x, dy: o1.y - o0.y },\n };\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/ops/transform.ts","../src/core/ops/reparent.ts","../src/interactions/scratchKey.ts","../src/interactions/gestures/shared/snap.ts"],"names":[],"mappings":";;;;AAoBO,SAAS,kBAAyB,IAAA,EAAgC;AACvE,EAAA,MAAM,EAAE,IAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,GAAc,CAAA,UAAA,EAAa,EAAE,CAAA,CAAA,EAAG,GAAI,IAAA;AACjE,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,WAAA;AAAA,IACN,MAAM,EAAE,EAAA,EAAI,IAAA,EAAM,EAAA,EAAI,OAAO,WAAA,EAAY;AAAA,IACzC,KAAA;AAAA,IACA,WAAA;AAAA,IACA,MAAM,OAAA,EAAS;AAOb,MAAC,OAAA,CAAoC,OAAA,CAAQ,EAAA,EAAI,EAAE,CAAA;AACnD,MAAA,IAAI,gBAAA,CAAiB,IAAA,EAAM,EAAE,CAAA,EAAG,OAAO,KAAA;AACvC,MAAA,OAAO,MAAA;AAAA,IACT,CAAA;AAAA,IACA,MAAA,GAAS;AACP,MAAA,OAAO,iBAAA,CAAyB,EAAE,EAAA,EAAI,IAAA,EAAM,IAAI,EAAA,EAAI,IAAA,EAAM,KAAA,EAAO,WAAA,EAAa,CAAA;AAAA,IAChF;AAAA,GACF;AACF;AAEA,iBAAA,CAA0C,WAAA,EAAa,CAAC,IAAA,KAAS,iBAAA,CAAkB,IAAI,CAAC,CAAA;AAExF,SAAS,gBAAA,CAAwB,GAAU,CAAA,EAAmB;AAC5D,EAAA,IAAI,CAAA,KAAM,GAAG,OAAO,IAAA;AACpB,EAAA,IAAI,CAAA,KAAM,IAAA,IAAQ,CAAA,KAAM,IAAA,IAAQ,OAAO,MAAM,QAAA,IAAY,OAAO,CAAA,KAAM,QAAA,EAAU,OAAO,KAAA;AACvF,EAAA,MAAM,EAAA,GAAK,MAAA,CA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A,GAAK,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA;AACjC,MAAA,OAAO;AAAA,QACL,SAAA,EAAW,EAAE,IAAA,EAAM,WAAA,EAAa,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,EAAA,CAAG,CAAA,EAAG,EAAA,EAAI,EAAA,CAAG,CAAA,GAAI,GAAG,CAAA;AAAE,OACnE;AAAA,IACF;AAAA,GACF;AACF","file":"chunk-3KGMJMOS.js","sourcesContent":["import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface TransformAdapter<TPose> {\n setPose(id: string, pose: TPose): void;\n}\n\n/** @internal */\ninterface TransformArgs<TPose> {\n id: string;\n from: TPose;\n to: TPose;\n label?: string;\n coalesceKey?: string;\n}\n\n/** Op: set an object's pose, inverting back to `from`. `coalesceKey` defaults to\n * `transform:${id}` so successive pose writes to the same node (drag-move,\n * resize, repeated nudges) merge into one undo entry within the history's\n * coalesce window. Pass an explicit key (or a unique one) to opt out. */\nexport function createTransformOp<TPose>(args: TransformArgs<TPose>): Op {\n const { id, from, to, label, coalesceKey = `transform:${id}` } = args;\n return {\n name: 'transform',\n args: { id, from, to, label, coalesceKey },\n label,\n coalesceKey,\n apply(adapter) {\n // Always call setPose so consumers that inspect op behavior (tests,\n // overlays) see a consistent \"this op writes (id, to)\" signal. When\n // from and to are structurally identical, additionally report a\n // no-op to history so the entry can be skipped from the undo stack.\n // setPose(id, to) is idempotent in this branch — adapters write the\n // same pose they already had.\n (adapter as TransformAdapter<TPose>).setPose(id, to);\n if (poseShallowEqual(from, to)) return false;\n return undefined;\n },\n invert() {\n return createTransformOp<TPose>({ id, from: to, to: from, label, coalesceKey });\n },\n };\n}\n\nregisterOpFactory<TransformArgs<unknown>>('transform', (args) => createTransformOp(args));\n\nfunction poseShallowEqual<TPose>(a: TPose, b: TPose): boolean {\n if (a === b) return true;\n if (a === null || b === null || typeof a !== 'object' || typeof b !== 'object') return false;\n const ka = Object.keys(a as object);\n const kb = Object.keys(b as object);\n if (ka.length !== kb.length) return false;\n for (const k of ka) {\n if ((a as Record<string, unknown>)[k] !== (b as Record<string, unknown>)[k]) return false;\n }\n return true;\n}\n","import type { Op } from './types';\nimport { registerOpFactory } from './registry';\n\ninterface ReparentAdapter {\n setParent(id: string, parentId: string | null): void;\n}\n\n/** @internal */\ninterface ReparentArgs {\n id: string;\n fromParentId: string | null;\n toParentId: string | null;\n label?: string;\n coalesceKey?: string;\n}\n\n/**\n * Op: change `id`'s parent, inverting back to the prior parent.\n *\n * `coalesceKey` defaults to `reparent:${id}` so successive reparents of the\n * same id batch-merge cleanly.\n */\nexport function createReparentOp(args: ReparentArgs): Op {\n const { id, fromParentId, toParentId, label = 'Reparent', coalesceKey = `reparent:${id}` } = args;\n return {\n name: 'reparent',\n args: { id, fromParentId, toParentId, label, coalesceKey },\n label,\n coalesceKey,\n apply(adapter) {\n (adapter as ReparentAdapter).setParent(id, toParentId);\n },\n invert() {\n return createReparentOp({\n id,\n fromParentId: toParentId,\n toParentId: fromParentId,\n label,\n coalesceKey,\n });\n },\n };\n}\n\nregisterOpFactory<ReparentArgs>('reparent', (args) => createReparentOp(args));\n","/**\n * Typed keys for the gesture/behavior scratch store.\n *\n * Gestures expose `ctx.scratch: Record<string, unknown>` as a per-gesture\n * mutable bag that behaviors use to stash state across `onDown` / `onMove`\n * / `onEnd` calls. The store is `unknown`-valued because behaviors are\n * tool-agnostic — a single behavior may run under different tools with\n * different scratch shapes. Without a typing convention every read site\n * has to `(ctx.scratch as <some shape>)[KEY]`, and a writer changing the\n * shape can silently break readers with no compile-time signal.\n *\n * `ScratchKey<T>` is a phantom-typed string that carries its payload type\n * via a branded interface. `getScratch` and `setScratch` use the brand to\n * narrow / constrain at the typing layer; at runtime the key is just its\n * underlying string and the store remains a plain `Record`.\n *\n * @example\n * ```ts\n * // Module-level (or behavior-level) constant, shared by writer + reader:\n * const LASSO_VERTICES = scratchKey<readonly { x: number; y: number }[]>('lasso.vertices');\n *\n * // Writer (a tool's onMove):\n * setScratch(ctx.scratch, LASSO_VERTICES, vertices);\n *\n * // Reader (a behavior's onEnd):\n * const vertices = getScratch(ctx.scratch, LASSO_VERTICES) ?? [];\n * // ^? readonly { x: number; y: number }[] | undefined\n * ```\n */\n\n/** Phantom-typed key for a scratch slot. The `__scratchKeyPayload` phantom\n * field carries the value type without occupying any runtime memory. */\nexport interface ScratchKey<T> {\n readonly name: string;\n /** Phantom — never read at runtime. Only present so TypeScript can\n * recover `T` at use sites. */\n readonly __scratchKeyPayload?: (_: T) => T;\n}\n\n/** Compatible scratch store shape. The kit's gesture context's `scratch`\n * field already satisfies this; consumers don't need to construct one. */\nexport type ScratchStore = Record<string, unknown>;\n\n/**\n * Make a typed scratch key. Use module-level constants so the same key\n * is shared by writer and reader.\n *\n * Namespace the name by behavior or feature to avoid collisions\n * (`'behavior.field'` is a good convention). Two keys with the same\n * `name` refer to the same slot at runtime — the type parameter is a\n * compile-time contract, not a uniqueness guarantee.\n */\nexport function scratchKey<T>(name: string): ScratchKey<T> {\n return { name };\n}\n\n/** Read a typed slot from the scratch store. Returns `undefined` if\n * nothing has been written under the key. */\nexport function getScratch<T>(\n store: ScratchStore,\n key: ScratchKey<T>,\n): T | undefined {\n return store[key.name] as T | undefined;\n}\n\n/** Write a value to a typed slot. Overwrites whatever was there. */\nexport function setScratch<T>(\n store: ScratchStore,\n key: ScratchKey<T>,\n value: T,\n): void {\n store[key.name] = value;\n}\n\n/** Remove a slot from the scratch store. Returns `true` if it was set,\n * `false` if it wasn't. */\nexport function deleteScratch<T>(\n store: ScratchStore,\n key: ScratchKey<T>,\n): boolean {\n if (Object.prototype.hasOwnProperty.call(store, key.name)) {\n delete store[key.name];\n return true;\n }\n return false;\n}\n","import type { MoveBehavior, ModifierState, SnapStrategy } from '../types';\nimport {\n RECT_ORIGIN_PROJECTION,\n type OriginProjection,\n} from './strategies/grid';\n\ntype ModKey = keyof ModifierState;\n\n/**\n * Generic snap behavior factory: wraps a `SnapStrategy` and returns a\n * `MoveBehavior` whose `onMove` returns a uniform `GroupTransform`.\n *\n * Implementation:\n * 1. Compute the primary's proposed pose by applying the gesture's\n * `transform` (translate) to `origin.get(primaryId)`.\n * 2. Call `strategy.snap(proposed)`. If null, no-op.\n * 3. Derive the snapped delta via the `OriginProjection`:\n * dx = origin(snapped).x - origin(originPose).x\n * ...so the gesture applies the same delta to every dragged id.\n *\n * The pose-shape-aware delta extraction lives here — gestures stay pose-shape\n * agnostic. Default projection is `{x, y}`-bearing (rect / path / polygon).\n * Pass `origin` for exotic poses.\n */\nexport function snap<TPose>(\n strategy: SnapStrategy<TPose>,\n opts: { bypassKey?: ModKey; origin?: OriginProjection<TPose> } = {},\n): MoveBehavior<TPose> {\n const { bypassKey } = opts;\n const proj: OriginProjection<TPose> = opts.origin\n ?? (RECT_ORIGIN_PROJECTION as unknown as OriginProjection<TPose>);\n return {\n onMove(ctx, transform) {\n if (bypassKey && ctx.modifiers[bypassKey]) return;\n // The new contract: behaviors see a GroupTransform, not a pose. But\n // strategies still operate on poses. Reconstruct the proposed pose\n // by applying the (translate) transform to the primary's origin.\n if (transform.kind !== 'translate') return;\n const primaryId = ctx.draggedIds[0];\n if (primaryId === undefined) return;\n const originPose = ctx.origin.get(primaryId);\n if (originPose === undefined) return;\n const proposed = proj.translate(originPose, transform.dx, transform.dy);\n const snapped = strategy.snap(proposed, ctx);\n if (snapped === null) return;\n const o0 = proj.getOrigin(originPose);\n const o1 = proj.getOrigin(snapped);\n return {\n transform: { kind: 'translate', dx: o1.x - o0.x, dy: o1.y - o0.y },\n };\n },\n };\n}\n"]}
|
|
@@ -163,5 +163,5 @@ function chunks(params) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
export { chunks, createTilePattern, crosshatch, dots, drawTileShapes, getTexture, hatch, registerTexture, tileGeometry, tileSize };
|
|
166
|
-
//# sourceMappingURL=chunk-
|
|
167
|
-
//# sourceMappingURL=chunk-
|
|
166
|
+
//# sourceMappingURL=chunk-HGF5X6MZ.js.map
|
|
167
|
+
//# sourceMappingURL=chunk-HGF5X6MZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/renderer/textures/registerTexture.ts","../src/features/patterns/tileGeometry.ts","../src/features/patterns/index.ts","../src/features/patterns/patterns-builtin.ts"],"names":[],"mappings":";AAmBA,IAAI,OAAA,GAAU,CAAA;AACd,IAAI,QAAA,uBAAe,GAAA,EAA0B;AAQtC,SAAS,WAAW,EAAA,EAAiC;AAC1D,EAAA,OAAO,QAAA,CAAS,GAAA,CAAI,EAAE,CAAA,IAAK,IAAA;AAC7B;AAWO,SAAS,gBACd,KAAA,EACe;AACf,EAAA,MAAM,EAAA,GAAK,CAAA,IAAA,EAAO,EAAE,OAAO,CAAA,CAAA;AAC3B,EAAA,QAAA,CAAS,GAAA,CAAI,EAAA,EAAI,EAAE,MAAA,EAAQ,OAAO,CAAA;AAClC,EAAA,OAAO,EAAE,EAAA,EAAG;AACd;;;ACtBO,SAAS,SAAS,IAAA,EAA+B;AACtD,EAAA,IAAI,IAAA,CAAK,IAAA,KAAS,MAAA,EAAW,OAAO,IAAA,CAAK,IAAA;AACzC,EAAA,QAAQ,KAAK,IAAA;AAAM,IACjB,KAAK,OAAA;AAAS,MAAA,OAAO,CAAA;AAAA,IACrB,KAAK,YAAA;AAAc,MAAA,OAAO,CAAA;AAAA,IAC1B,KAAK,MAAA;AAAQ,MAAA,OAAO,CAAA;AAAA,IACpB,KAAK,QAAA;AAAU,MAAA,OAAO,EAAA;AAAA,IACtB;AAAS,MAAA,OAAO,CAAA;AAAA;AAEpB;AAIA,SAAS,WAAW,IAAA,EAA4B;AAC9C,EAAA,IAAI,IAAI,IAAA,GAAO,CAAA;AACf,EAAA,OAAO,MAAM;AACX,IAAA,CAAA,GAAK,IAAI,UAAA,GAAc,CAAA;AACvB,IAAA,IAAI,IAAI,IAAA,CAAK,IAAA,CAAK,IAAK,CAAA,KAAM,EAAA,EAAK,IAAI,CAAC,CAAA;AACvC,I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ACH;AAUO,SAAS,MAAM,MAAA,EAA2C;AAC/D,EAAA,OAAO,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,GAAG,QAAQ,CAAA;AAC3C;AAUO,SAAS,WAAW,MAAA,EAAgD;AACzE,EAAA,OAAO,MAAM,EAAE,IAAA,EAAM,YAAA,EAAc,GAAG,QAAQ,CAAA;AAChD;AAUO,SAAS,KAAK,MAAA,EAA0C;AAC7D,EAAA,OAAO,MAAM,EAAE,IAAA,EAAM,MAAA,EAAQ,GAAG,QAAQ,CAAA;AAC1C;AAoBO,SAAS,OAAO,MAAA,EAA4C;AACjE,EAAA,OAAO,MAAM,EAAE,IAAA,EAAM,QAAA,EAAU,GAAG,QAAQ,CAAA;AAC5C","file":"chunk-HGF5X6MZ.js","sourcesContent":["/**\n * registerTexture — accepts an image source, assigns an opaque id, stores in\n * a module-level registry. Actual GL upload happens lazily at draw time in\n * drawShader() via GLTextureCache.upload (which is idempotent).\n *\n * Lifecycle: textures live for the renderer's lifetime. No unregister in v1.\n *\n * Convention §9: this registry stores image data only — no per-renderer state.\n * Each WeaselRenderer's GLTextureCache does its own dedup via has(id).\n */\n\nexport interface TextureHandle {\n readonly id: string;\n}\n\nexport interface TextureEntry {\n source: HTMLImageElement | ImageBitmap;\n}\n\nlet counter = 0;\nlet registry = new Map<string, TextureEntry>();\n\n/** @internal Test helper — do not call from product code. */\nexport function _resetTextureRegistryForTests(): void {\n registry = new Map();\n counter = 0;\n}\n\nexport function getTexture(id: string): TextureEntry | null {\n return registry.get(id) ?? null;\n}\n\n/**\n * Register an image for use as a shader texture uniform.\n *\n * Returns a TextureHandle whose `id` can be passed as a ShaderUniform value.\n * The handle is valid for the lifetime of the renderer it will be used with.\n *\n * @param image The image to register. HTMLImageElement must be fully loaded.\n * @returns Opaque TextureHandle.\n */\nexport function registerTexture(\n image: HTMLImageElement | ImageBitmap,\n): TextureHandle {\n const id = `tex_${++counter}`;\n registry.set(id, { source: image });\n return { id };\n}\n","/**\n * The shapes a built-in tile is made of, as data.\n *\n * One description, two renderers: `patterns-builtin` strokes/fills these to\n * an `OffscreenCanvas` to build the GL texture, and `@weasel-js/svg` maps\n * them to `<pattern>` children. Duplicating the tile drawing in the\n * serializer would let the raster and vector forms drift apart silently.\n */\n\nimport type { TilePatternSpec } from '../../core/paint-types';\n\n/** One primitive within a pattern tile, in tile-local coordinates. */\nexport type TileShape =\n | { kind: 'line'; x1: number; y1: number; x2: number; y2: number; width: number; color: string }\n | { kind: 'circle'; cx: number; cy: number; r: number; color: string }\n | { kind: 'ellipse'; cx: number; cy: number; rx: number; ry: number; rotation: number; color: string }\n | { kind: 'rect'; x: number; y: number; width: number; height: number; color: string };\n\n/** A built-in tile's shapes plus the edge length they're drawn within. */\nexport interface TileGeometry {\n size: number;\n shapes: TileShape[];\n}\n\n/** Defaults per tile kind, matching each factory's signature. */\nexport function tileSize(spec: TilePatternSpec): number {\n if (spec.size !== undefined) return spec.size;\n switch (spec.tile) {\n case 'hatch': return 5;\n case 'crosshatch': return 6;\n case 'dots': return 6;\n case 'chunks': return 48;\n default: return 8;\n }\n}\n\n/** Seeded PRNG (mulberry32) — `chunks` places its scatter with this, so the\n * same `seed` yields the same tile in both the raster and vector paths. */\nfunction mulberry32(seed: number): () => number {\n let s = seed | 0;\n return () => {\n s = (s + 0x6D2B79F5) | 0;\n let t = Math.imul(s ^ (s >>> 15), 1 | s);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n/** Resolve a pattern spec to the shapes that make up one tile. Consumers that\n * want to draw a pattern swatch themselves — a picker, an SVG export — read\n * this rather than rasterizing a texture. */\nexport function tileGeometry(spec: TilePatternSpec): TileGeometry {\n const s = tileSize(spec);\n const { color } = spec;\n\n switch (spec.tile) {\n case 'hatch': {\n const width = spec.lineWidth ?? 1;\n return { size: s, shapes: forwardDiagonals(s, width, color) };\n }\n case 'crosshatch': {\n const width = spec.lineWidth ?? 0.8;\n return {\n size: s,\n shapes: [...forwardDiagonals(s, width, color), ...backwardDiagonals(s, width, color)],\n };\n }\n case 'dots': {\n const r = spec.radius ?? 1;\n return { size: s, shapes: [{ kind: 'circle', cx: s / 2, cy: s / 2, r, color }] };\n }\n case 'chunks': {\n const density = spec.density ?? 0.35;\n const chunkSize = spec.chunkSize ?? 3;\n const rand = mulberry32(spec.seed ?? 42);\n const count = Math.round((s * s * density) / (chunkSize * chunkSize));\n const shapes: TileShape[] = [];\n if (spec.bg !== undefined) {\n shapes.push({ kind: 'rect', x: 0, y: 0, width: s, height: s, color: spec.bg });\n }\n for (let i = 0; i < count; i++) {\n const cx = rand() * s;\n const cy = rand() * s;\n const w = chunkSize * (0.5 + rand());\n const h = chunkSize * (0.5 + rand());\n const rotation = rand() * Math.PI;\n shapes.push({ kind: 'ellipse', cx, cy, rx: w / 2, ry: h / 2, rotation, color });\n }\n return { size: s, shapes };\n }\n default:\n return { size: s, shapes: [] };\n }\n}\n\n/** The forward (`/`) diagonal, plus the two corner stubs that make it tile\n * seamlessly across the edges. */\nfunction forwardDiagonals(s: number, width: number, color: string): TileShape[] {\n return [\n { kind: 'line', x1: -1, y1: s + 1, x2: s + 1, y2: -1, width, color },\n { kind: 'line', x1: -1, y1: 1, x2: 1, y2: -1, width, color },\n { kind: 'line', x1: s - 1, y1: s + 1, x2: s + 1, y2: s - 1, width, color },\n ];\n}\n\n/** The backward (`\\`) diagonal and its two stubs. */\nfunction backwardDiagonals(s: number, width: number, color: string): TileShape[] {\n return [\n { kind: 'line', x1: -1, y1: -1, x2: s + 1, y2: s + 1, width, color },\n { kind: 'line', x1: s - 1, y1: -1, x2: s + 1, y2: 1, width, color },\n { kind: 'line', x1: -1, y1: s - 1, x2: 1, y2: s + 1, width, color },\n ];\n}\n\n/** Draw a tile's shapes to a 2D context — the raster half of the pair. */\nexport function drawTileShapes(oc: CanvasRenderingContext2D, geometry: TileGeometry): void {\n for (const shape of geometry.shapes) {\n if (shape.kind === 'line') {\n oc.strokeStyle = shape.color;\n oc.lineWidth = shape.width;\n oc.beginPath();\n oc.moveTo(shape.x1, shape.y1);\n oc.lineTo(shape.x2, shape.y2);\n oc.stroke();\n continue;\n }\n oc.fillStyle = shape.color;\n if (shape.kind === 'rect') {\n oc.fillRect(shape.x, shape.y, shape.width, shape.height);\n continue;\n }\n oc.beginPath();\n if (shape.kind === 'circle') {\n oc.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2);\n } else {\n oc.ellipse(shape.cx, shape.cy, shape.rx, shape.ry, shape.rotation, 0, Math.PI * 2);\n }\n oc.fill();\n }\n}\n","/**\n * Tile-pattern primitive — a small helper for building repeating texture\n * tiles from a draw callback. The result plugs into a `FillStyle` of\n * `{ fill: 'pattern', pattern }` (see `../../core/paint-types.ts`).\n *\n * GL-backed: the tile is rendered to an `OffscreenCanvas` (with a 2D fallback\n * to a regular `<canvas>` for environments without `OffscreenCanvas`),\n * converted to an `ImageBitmap`, and registered with `registerTexture()`.\n * The returned `TextureHandle` is what `FillStyle.pattern` accepts.\n *\n * For ready-to-use named patterns (hatch, crosshatch, dots, chunks),\n * see the `@weasel-js/core/patterns-builtin` subpath.\n */\n\nimport { registerTexture } from '../../renderer/textures/registerTexture';\nimport type { TextureHandle } from '../../renderer/textures/registerTexture';\n\n/** Options for `createTilePattern`. */\nexport interface TilePatternOpts {\n /** Edge length (in pixels) of the square offscreen tile. */\n size: number;\n /** FillStyle one tile at integer-pixel coordinates `(0, 0) .. (size, size)`. */\n draw: (oc: CanvasRenderingContext2D, size: number) => void;\n}\n\n/**\n * Render a single tile to an offscreen canvas and register it as a GL\n * texture, returning a `TextureHandle` you can wrap in a `FillStyle` of\n * `{ fill: 'pattern', pattern }`. Returns `null` only when an\n * `OffscreenCanvas`/2D context can't be acquired (very rare; same fallback\n * semantics as the prior `CanvasPattern`-based implementation).\n */\nexport function createTilePattern(opts: TilePatternOpts): TextureHandle | null {\n // Prefer OffscreenCanvas; fall back to <canvas> for environments without it\n // (tests in jsdom may need that fallback — try OffscreenCanvas first).\n let off: OffscreenCanvas | HTMLCanvasElement;\n try {\n off = new OffscreenCanvas(opts.size, opts.size);\n } catch {\n if (typeof document === 'undefined') return null;\n const c = document.createElement('canvas');\n c.width = opts.size;\n c.height = opts.size;\n off = c;\n }\n const oc = off.getContext('2d') as CanvasRenderingContext2D | null;\n if (!oc) return null;\n opts.draw(oc, opts.size);\n\n // Convert to ImageBitmap so registerTexture can store it.\n // OffscreenCanvas.transferToImageBitmap() is the fast path; the\n // synchronous path requires OffscreenCanvas. If we got here without it,\n // the env doesn't support OffscreenCanvas — fail gracefully.\n let bitmap: ImageBitmap;\n if (typeof (off as OffscreenCanvas).transferToImageBitmap === 'function') {\n bitmap = (off as OffscreenCanvas).transferToImageBitmap();\n } else {\n return null;\n }\n return registerTexture(bitmap);\n}\n","/**\n * Built-in pattern factories — generic line/dot/scatter textures. Each\n * returns a `TextureHandle` you can wrap in a `FillStyle` of\n * `{ fill: 'pattern', pattern }` and pass to anything that accepts a `FillStyle`\n * (`FillStyle`-aware layers, path fills, etc.).\n * Imported from a subpath so consumers that ship their own catalog can\n * avoid the bundle cost.\n *\n * All factories require an explicit `color` (and `bg` for `chunks`). No\n * defaults are baked in — the caller's design system is the source of truth\n * for palette decisions.\n *\n * Each is a thin wrapper over `tileGeometry`, which describes the tile as\n * shapes so `@weasel-js/svg` can emit the same tile as a `<pattern>`.\n * Prefer naming a tile in a `TilePatternSpec` over calling these directly —\n * a spec serializes, a `TextureHandle` does not.\n */\n\nexport { tileGeometry, tileSize, drawTileShapes } from './tileGeometry';\nexport type { TileShape, TileGeometry } from './tileGeometry';\n\nimport { createTilePattern } from '.';\nimport { tileGeometry, drawTileShapes, tileSize } from './tileGeometry';\nimport type { TilePatternSpec } from '../../core/paint-types';\nimport type { TextureHandle } from '../../renderer/textures/registerTexture';\n\nfunction build(spec: TilePatternSpec): TextureHandle | null {\n const geometry = tileGeometry(spec);\n return createTilePattern({\n size: tileSize(spec),\n draw: (oc) => drawTileShapes(oc, geometry),\n });\n}\n\n/** Diagonal hatch (forward slash). */\nexport interface HatchParams {\n color: string;\n size?: number;\n lineWidth?: number;\n}\n\n/** Build a diagonal-hatch pattern texture. */\nexport function hatch(params: HatchParams): TextureHandle | null {\n return build({ tile: 'hatch', ...params });\n}\n\n/** Diagonal hatch in both directions. */\nexport interface CrosshatchParams {\n color: string;\n size?: number;\n lineWidth?: number;\n}\n\n/** Build a crosshatch pattern texture. */\nexport function crosshatch(params: CrosshatchParams): TextureHandle | null {\n return build({ tile: 'crosshatch', ...params });\n}\n\n/** Regular grid of filled dots. */\nexport interface DotsParams {\n color: string;\n size?: number;\n radius?: number;\n}\n\n/** Build a dot-grid pattern texture. */\nexport function dots(params: DotsParams): TextureHandle | null {\n return build({ tile: 'dots', ...params });\n}\n\n/**\n * Random scatter of small ellipses on top of a solid background. Driven by a\n * seeded PRNG so the same `seed` produces a deterministic tile.\n *\n * Note: the `bg` field is optional — omit it for a transparent background\n * (the scatter shapes draw directly onto whatever sits beneath the overlay).\n */\nexport interface ChunksParams {\n color: string;\n bg?: string;\n size?: number;\n /** Coverage: `chunks * chunkSize²` per `size²` tile. Range ~[0, 1]. */\n density?: number;\n chunkSize?: number;\n seed?: number;\n}\n\n/** Build a seeded random-scatter pattern texture. */\nexport function chunks(params: ChunksParams): TextureHandle | null {\n return build({ tile: 'chunks', ...params });\n}\n"]}
|