@weasel-js/core 1.14.0 → 1.14.2

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 CHANGED
@@ -1,5 +1,82 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.14.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 012cae5: Shader commands and mesh gradients stay exact far from the origin. A shader command's kit vertex stage now
8
+ takes `u_worldOrigin`, a world point near its bounds, and `u_screenToLocal`, composed in doubles, and exposes
9
+ `v_worldLocal`, the world point measured from that origin, beside `v_world`, which it now computes from them
10
+ rather than by inverting `u_view` in float32. A consumer shader drawing detail far out reads `v_worldLocal`
11
+ (a periodic one, `mod(u_worldOrigin, P) + v_worldLocal`); `u_screenToLocal` and `u_worldOrigin` are kit
12
+ uniforms, so a shader must not set them. `PaintBindContext.spaceInverse` takes an optional point to measure
13
+ paint space from, subtracted in doubles; the mesh gradient measures from its bake's corner and its vertex
14
+ stage takes `u_origin`, so its geometry is rebased like the kit's own paths.
15
+ - ae38d2e: `nodeGates` no longer allocates for a node with no parent, and remembers answers only for ancestors. A walk over a flat scene, which is every pick and marquee made after an edit, had been building a `Set` and two map entries per node to answer hidden and locked.
16
+ - 4bba14d: A scene's `add` and `remove` cost less again: a history builds the step it reports only when something observes its steps, and expands caused ops only when an op has them; a remove narrows an empty selection without building node gates; an empty pose-removal drain returns early; and a `kit:add` payload takes its optional fields by assignment. An emitter with no listeners now returns from `emit` without copying its listener set.
17
+ - d05de93: Grid lines and ruler guides now line up a moved shape's drawn box, stroke included, instead of its pose origin, so **stroked shapes land half a stroke width differently against grid lines and guides**: a rect with a 10-wide stroke now puts its stroke's outer edge on the line, where it used to put the rect's own edge, 5 further in. The grid also lands a box's center or far edge when that is nearer a line than its near edge, and a multi-node move snaps the union box rather than each node's origin. On a turned container's lattice the grid still snaps the pose origin. Drawing a new shape and the pen are unchanged; they snap the pointer.
18
+
19
+ On a resize that turns or skews the box, equal spacing now snaps the sides of the box's axis-aligned extent the drag moves, solving along the handle's own axis; it offered nothing before. Alignment and spacing marks on such a resize span the box where it lands.
20
+
21
+ Breaking for a custom `SnapSource`: `SnapCollect.edges` and the `SnapEdge` and `SnapEdges` types are removed. `SnapCollect.sides` lists the sides of the box a resize moves and each one's rate per unit of the move (`SnapSide`), and `SnapCollect.boxAt(delta)` gives the box where a resolved move puts it.
22
+ - Updated dependencies [012cae5]
23
+ - Updated dependencies [56f9771]
24
+ - Updated dependencies [3c3e00b]
25
+ - Updated dependencies [9b0c6ee]
26
+ - Updated dependencies [dedcb92]
27
+ - Updated dependencies [dc5a786]
28
+ - Updated dependencies [4bba14d]
29
+ - Updated dependencies [c5cba19]
30
+ - Updated dependencies [dec74a9]
31
+ - Updated dependencies [64b59af]
32
+ - @weasel-js/renderer@1.14.2
33
+ - @weasel-js/font@1.14.2
34
+ - @weasel-js/text@1.14.2
35
+ - @weasel-js/prefs@1.14.2
36
+ - @weasel-js/history@1.14.2
37
+ - @weasel-js/registry@1.14.2
38
+ - @weasel-js/text-dom@1.14.2
39
+ - @weasel-js/routing@1.14.2
40
+ - @weasel-js/animator@1.14.2
41
+ - @weasel-js/cursor@1.14.2
42
+ - @weasel-js/icons@1.14.2
43
+ - @weasel-js/modes@1.14.2
44
+ - @weasel-js/react@1.14.2
45
+ - @weasel-js/select@1.14.2
46
+ - @weasel-js/stroke@1.14.2
47
+ - @weasel-js/simulation@1.14.2
48
+ - @weasel-js/geom@1.14.2
49
+ - @weasel-js/gestures@1.14.2
50
+ - @weasel-js/headless@1.14.2
51
+ - @weasel-js/paint@1.14.2
52
+ - @weasel-js/quantity@1.14.2
53
+
54
+ ## 1.14.1
55
+
56
+ ### Patch Changes
57
+
58
+ - @weasel-js/animator@1.14.1
59
+ - @weasel-js/cursor@1.14.1
60
+ - @weasel-js/font@1.14.1
61
+ - @weasel-js/geom@1.14.1
62
+ - @weasel-js/gestures@1.14.1
63
+ - @weasel-js/headless@1.14.1
64
+ - @weasel-js/history@1.14.1
65
+ - @weasel-js/icons@1.14.1
66
+ - @weasel-js/modes@1.14.1
67
+ - @weasel-js/paint@1.14.1
68
+ - @weasel-js/prefs@1.14.1
69
+ - @weasel-js/quantity@1.14.1
70
+ - @weasel-js/react@1.14.1
71
+ - @weasel-js/registry@1.14.1
72
+ - @weasel-js/renderer@1.14.1
73
+ - @weasel-js/routing@1.14.1
74
+ - @weasel-js/select@1.14.1
75
+ - @weasel-js/simulation@1.14.1
76
+ - @weasel-js/stroke@1.14.1
77
+ - @weasel-js/text@1.14.1
78
+ - @weasel-js/text-dom@1.14.1
79
+
3
80
  ## 1.14.0
4
81
 
5
82
  ### Minor Changes
package/README.md CHANGED
@@ -199,7 +199,7 @@ return [{
199
199
  }];
200
200
  ```
201
201
 
202
- An empty vertex source selects the kit's vertex shader, which provides the `v_uv`, `v_screen` and `v_world` varyings and sets `u_bounds`, `u_view` and `u_proj` itself. Uniforms take a number, a 2–4 element tuple, a `Float32Array`, or a `TextureHandle` from `registerTexture`. Output **premultiplied** alpha — `vec4(rgb * a, a)` — or translucent pixels come out too bright. `bounds` is in CSS pixels.
202
+ An empty vertex source selects the kit's vertex shader, which provides the `v_uv`, `v_screen`, `v_world` and `v_worldLocal` varyings and sets `u_bounds`, `u_view`, `u_proj` and `u_worldOrigin` itself. Far from the origin `v_world` is as coarse as any float32 that size; `v_worldLocal` is the same point measured from `u_worldOrigin`, a world point near the bounds, and stays exact, so a periodic pattern reads `mod(u_worldOrigin, P) + v_worldLocal`. Uniforms take a number, a 2–4 element tuple, a `Float32Array`, or a `TextureHandle` from `registerTexture`. Output **premultiplied** alpha — `vec4(rgb * a, a)` — or translucent pixels come out too bright. `bounds` is in CSS pixels.
203
203
 
204
204
  ## Subpath imports
205
205
 
@@ -1160,9 +1160,9 @@ var MeshBakeCache = class {
1160
1160
  * patches cover, not the whole shape it is filling, and a clamped read would
1161
1161
  * otherwise smear its border colors across the rest.
1162
1162
  *
1163
- * `u_meshOrigin` / `u_meshSize` are the bake's box in paint space, and the
1164
- * bake maps that box onto texel *centers*, which is the half-texel the uv
1165
- * rescale accounts for. Output is PREMULTIPLIED alpha.
1163
+ * `u_meshSize` is the bake's box in paint space, measured from its corner,
1164
+ * which `u_worldInv` puts at zero; the bake maps that box onto texel
1165
+ * *centers*, which is the half-texel the uv rescale accounts for. Output is PREMULTIPLIED alpha.
1166
1166
  */
1167
1167
  /** The id this program is registered under. */
1168
1168
  const MESH_PROGRAM_ID = "kit:mesh-gradient";
@@ -1170,10 +1170,11 @@ const MESH_VERT_SRC = `#version 300 es
1170
1170
  in vec2 a_position;
1171
1171
  uniform mat3 u_proj;
1172
1172
  uniform mat3 u_model;
1173
+ uniform vec2 u_origin;
1173
1174
  uniform mat3 u_worldInv;
1174
1175
  out vec2 v_world;
1175
1176
  void main() {
1176
- vec3 screen = u_model * vec3(a_position, 1.0);
1177
+ vec3 screen = u_model * vec3(a_position - u_origin, 1.0);
1177
1178
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
1178
1179
  gl_Position = vec4(clip.xy, 0.0, 1.0);
1179
1180
  vec3 world = u_worldInv * vec3(screen.xy, 1.0);
@@ -1184,13 +1185,12 @@ const MESH_FRAG_SRC = `#version 300 es
1184
1185
  precision highp float;
1185
1186
  in vec2 v_world;
1186
1187
  uniform sampler2D u_sampler;
1187
- uniform vec2 u_meshOrigin;
1188
1188
  uniform vec2 u_meshSize;
1189
1189
  uniform float u_opacity;
1190
1190
  uniform float u_alpha;
1191
1191
  out vec4 outColor;
1192
1192
  void main() {
1193
- vec2 t =(v_world - u_meshOrigin) / max(u_meshSize, vec2(0.0001));
1193
+ vec2 t = v_world / max(u_meshSize, vec2(0.0001));
1194
1194
  if (t.x < 0.0 || t.x > 1.0 || t.y < 0.0 || t.y > 1.0) {
1195
1195
  outColor = vec4(0.0);
1196
1196
  return;
@@ -1432,12 +1432,13 @@ function bakeFor(ctx, mesh) {
1432
1432
  function bindMesh(ctx, fill) {
1433
1433
  const mesh = asMesh$1(fill);
1434
1434
  if (!mesh.patches.some(isValidPatch)) return null;
1435
- const inverse = ctx.spaceInverse(mesh.units);
1436
- if (!inverse) return null;
1437
1435
  const program = ctx.program(MESH_PROGRAM_ID);
1438
1436
  if (!program) return null;
1439
1437
  const entry = bakeFor(ctx, mesh);
1440
1438
  if (!entry) return null;
1439
+ const { box } = entry;
1440
+ const inverse = ctx.spaceInverse(mesh.units, box);
1441
+ if (!inverse) return null;
1441
1442
  const gl = ctx.gl;
1442
1443
  gl.useProgram(program.handle);
1443
1444
  ctx.setProjAndModel(program);
@@ -1445,8 +1446,6 @@ function bindMesh(ctx, fill) {
1445
1446
  gl.activeTexture(gl.TEXTURE0);
1446
1447
  gl.bindTexture(gl.TEXTURE_2D, entry.texture);
1447
1448
  gl.uniform1i(program.uniform("u_sampler"), 0);
1448
- const { box } = entry;
1449
- gl.uniform2f(program.uniform("u_meshOrigin"), box.x, box.y);
1450
1449
  gl.uniform2f(program.uniform("u_meshSize"), box.width, box.height);
1451
1450
  gl.uniform1f(program.uniform("u_opacity"), mesh.opacity ?? 1);
1452
1451
  gl.uniform1f(program.uniform("u_alpha"), ctx.alpha);