@weasel-js/labkit 1.0.2 → 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.
Files changed (100) hide show
  1. package/dist/_dts/{DrawCommand-CitWPxMY.d.ts → DrawCommand-uKHt4Vul.d.ts} +56 -0
  2. package/dist/_dts/{index-C6Yze7sQ.d.ts → index-CFlDPeZh.d.ts} +30 -1
  3. package/dist/_dts/{types-Si4Fw-1F.d.ts → types-x92Kfeme.d.ts} +14 -0
  4. package/dist/_dts/{useExperimentState-CJn2hHzd.d.ts → useExperimentState-vrttakTt.d.ts} +43 -0
  5. package/dist/canvas/index.d.ts +13 -2
  6. package/dist/canvas/index.js +2 -2
  7. package/dist/{chunk-3P56ZCCJ.js → chunk-3WPOGKUP.js} +93 -62
  8. package/dist/chunk-3WPOGKUP.js.map +1 -0
  9. package/dist/{chunk-54IQ2DX7.js → chunk-574LJAV4.js} +3 -3
  10. package/dist/chunk-574LJAV4.js.map +1 -0
  11. package/dist/{chunk-VLAHRJOC.js → chunk-5R2ATYPJ.js} +2 -2
  12. package/dist/{chunk-VLAHRJOC.js.map → chunk-5R2ATYPJ.js.map} +1 -1
  13. package/dist/{chunk-2ZRE7WGQ.js → chunk-73PXCRCR.js} +3 -3
  14. package/dist/chunk-73PXCRCR.js.map +1 -0
  15. package/dist/{chunk-PWC7AQZM.js → chunk-CPUJ3QXL.js} +2 -2
  16. package/dist/chunk-CPUJ3QXL.js.map +1 -0
  17. package/dist/{chunk-R4TACNW7.js → chunk-N5KTQKQA.js} +11 -11
  18. package/dist/chunk-N5KTQKQA.js.map +1 -0
  19. package/dist/{chunk-HXZHVU4G.js → chunk-PMAU3SEE.js} +3 -3
  20. package/dist/chunk-PMAU3SEE.js.map +1 -0
  21. package/dist/{chunk-7BKDG73Z.js → chunk-RL2LOLNI.js} +2 -2
  22. package/dist/chunk-RL2LOLNI.js.map +1 -0
  23. package/dist/{chunk-2QNYYL3V.js → chunk-SFL7NFKN.js} +2 -2
  24. package/dist/chunk-SFL7NFKN.js.map +1 -0
  25. package/dist/{chunk-53XSBIUK.js → chunk-T7OKNJTY.js} +2 -2
  26. package/dist/chunk-T7OKNJTY.js.map +1 -0
  27. package/dist/controls/index.d.ts +4 -2
  28. package/dist/controls/index.js +1 -1
  29. package/dist/dragdrop/index.d.ts +2 -2
  30. package/dist/index.d.ts +122 -6
  31. package/dist/index.js +18 -18
  32. package/dist/index.js.map +1 -1
  33. package/dist/layers/index.d.ts +6 -3
  34. package/dist/layers/index.js +1 -1
  35. package/dist/passthrough/weasel-canvas.d.ts +5 -1
  36. package/dist/passthrough/weasel-canvas.js +1 -1
  37. package/dist/passthrough/weasel-ui.d.ts +444 -7
  38. package/dist/passthrough/weasel-ui.js +2 -2
  39. package/dist/primitives/index.d.ts +13 -0
  40. package/dist/primitives/index.js +2 -2
  41. package/dist/state/index.d.ts +15 -2
  42. package/dist/state/index.js +2 -2
  43. package/dist/state/index.js.map +1 -1
  44. package/dist/styles.css +1 -1
  45. package/dist/ui/layers/index.d.ts +5 -0
  46. package/dist/ui/layers/index.js +3 -3
  47. package/dist/undo/index.d.ts +17 -2
  48. package/dist/undo/index.js +1 -1
  49. package/package.json +1 -1
  50. package/src/canvas/CanvasStack.tsx +4 -0
  51. package/src/canvas/CanvasStackContext.ts +3 -0
  52. package/src/canvas/canvasCoords.ts +2 -0
  53. package/src/canvas/useLayerScheduler.ts +2 -0
  54. package/src/controls/ControlPanel.tsx +2 -0
  55. package/src/controls/types.ts +14 -0
  56. package/src/instrument/capabilityDetector.ts +3 -0
  57. package/src/instrument/defineInstrument.ts +2 -0
  58. package/src/instrument/types.ts +29 -0
  59. package/src/instrument/validateConfigSchema.ts +5 -0
  60. package/src/lab/Lab.tsx +3 -0
  61. package/src/lab/LabContext.ts +5 -0
  62. package/src/lab/LabShell.tsx +4 -0
  63. package/src/lab/WorkspaceGrid.tsx +2 -0
  64. package/src/lab/gridDims.ts +2 -0
  65. package/src/layers/LayerList.tsx +3 -0
  66. package/src/primitives/FpsMeter.tsx +1 -0
  67. package/src/primitives/ScaleIndicator.tsx +4 -0
  68. package/src/primitives/Sidebar.tsx +3 -0
  69. package/src/primitives/StatusBar.tsx +3 -0
  70. package/src/primitives/Toolbar.tsx +6 -0
  71. package/src/state/SingletonExperiment.tsx +1 -0
  72. package/src/state/adapters.ts +8 -0
  73. package/src/state/context.tsx +9 -0
  74. package/src/state/helpers.ts +12 -0
  75. package/src/state/store.ts +6 -0
  76. package/src/state/types.ts +17 -0
  77. package/src/state/useExperimentState.ts +3 -0
  78. package/src/ui/layers/LayerStack.tsx +5 -0
  79. package/src/ui/properties/CurveField.tsx +4 -1
  80. package/src/ui/properties/EffectCard.tsx +12 -0
  81. package/src/ui/properties/PropertyGroup.tsx +1 -0
  82. package/src/ui/properties/PropertyPanel.tsx +28 -0
  83. package/src/undo/eventBus.ts +4 -0
  84. package/src/undo/undoStack.ts +11 -0
  85. package/src/workspace/DefaultSidebar.tsx +3 -0
  86. package/src/workspace/DefaultStatusBar.tsx +3 -0
  87. package/src/workspace/DefaultToolbar.tsx +3 -0
  88. package/src/workspace/Workspace.tsx +3 -0
  89. package/src/workspace/WorkspaceChrome.tsx +4 -0
  90. package/src/workspace/slotTypes.ts +9 -0
  91. package/src/workspace/workspaceOps.ts +8 -0
  92. package/dist/chunk-2QNYYL3V.js.map +0 -1
  93. package/dist/chunk-2ZRE7WGQ.js.map +0 -1
  94. package/dist/chunk-3P56ZCCJ.js.map +0 -1
  95. package/dist/chunk-53XSBIUK.js.map +0 -1
  96. package/dist/chunk-54IQ2DX7.js.map +0 -1
  97. package/dist/chunk-7BKDG73Z.js.map +0 -1
  98. package/dist/chunk-HXZHVU4G.js.map +0 -1
  99. package/dist/chunk-PWC7AQZM.js.map +0 -1
  100. package/dist/chunk-R4TACNW7.js.map +0 -1
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import earcut from 'earcut';
4
4
  import polygonClipping from 'polygon-clipping';
5
5
 
6
- // ../core/dist/chunk-W2WB4352.js
6
+ // ../core/dist/chunk-TR3HZN34.js
7
7
 
8
8
  // ../gestures/dist/index.js
9
9
  var GESTURE_DESCRIPTORS = [
@@ -288,7 +288,7 @@ function matchSpec(e, spec, isMac, phaseCtx) {
288
288
  }
289
289
  var EMPTY_ENGAGED = /* @__PURE__ */ new Set();
290
290
 
291
- // ../core/dist/chunk-W2WB4352.js
291
+ // ../core/dist/chunk-TR3HZN34.js
292
292
  var DepRegistryContext = createContext(null);
293
293
  function DepRegistryProvider({ children }) {
294
294
  const sourcesRef = useRef(/* @__PURE__ */ new Map());
@@ -699,7 +699,7 @@ function reportRouteConflicts(scopes, warn = (m) => console.warn(m)) {
699
699
  return conflicts;
700
700
  }
701
701
 
702
- // ../geom/dist/chunk-K5JJ6WRB.js
702
+ // ../geom/dist/chunk-UULRZUHO.js
703
703
  function cubicEvalAt(x0, y0, x1, y1, x2, y2, x3, y3, t) {
704
704
  const u = 1 - t;
705
705
  const a = u * u * u, b = 3 * u * u * t, c = 3 * u * t * t, d = t * t * t;
@@ -815,7 +815,7 @@ function transformCoords(coords, m) {
815
815
  return out;
816
816
  }
817
817
 
818
- // ../core/dist/chunk-6SHZHXXR.js
818
+ // ../core/dist/chunk-U45SODC2.js
819
819
  function resolveUnit(v, unitSystem) {
820
820
  if (typeof v === "number") return v;
821
821
  if (!unitSystem) {
@@ -1563,7 +1563,7 @@ function createDeleteOp(args) {
1563
1563
  }
1564
1564
  registerOpFactory("delete", (args) => createDeleteOp(args));
1565
1565
 
1566
- // ../core/dist/chunk-UB6A6L77.js
1566
+ // ../core/dist/chunk-3KGMJMOS.js
1567
1567
  function createTransformOp(args) {
1568
1568
  const { id, from, to, label, coalesceKey = `transform:${id}` } = args;
1569
1569
  return {
@@ -1644,7 +1644,7 @@ function snap(strategy, opts = {}) {
1644
1644
  };
1645
1645
  }
1646
1646
 
1647
- // ../core/dist/chunk-Z3KNFTTS.js
1647
+ // ../core/dist/chunk-3JYFAQIB.js
1648
1648
  function lockAspectWithModifier(opts = {}) {
1649
1649
  const { key = "shift" } = opts;
1650
1650
  return {
@@ -1840,7 +1840,7 @@ function materializePaste(adapter, snapshot, opts) {
1840
1840
  return { ops, newIds, created };
1841
1841
  }
1842
1842
 
1843
- // ../core/dist/chunk-IO5Z75X4.js
1843
+ // ../core/dist/chunk-HGF5X6MZ.js
1844
1844
  var counter = 0;
1845
1845
  var registry = /* @__PURE__ */ new Map();
1846
1846
  function getTexture(id) {
@@ -1998,7 +1998,7 @@ function chunks(params) {
1998
1998
  return build({ tile: "chunks", ...params });
1999
1999
  }
2000
2000
 
2001
- // ../font/dist/index.js
2001
+ // ../font/dist/chunk-3RSTZDXH.js
2002
2002
  var subscribers = /* @__PURE__ */ new Set();
2003
2003
  var generation = 0;
2004
2004
  function glyphGeneration() {
@@ -2642,6 +2642,8 @@ function warnOnce(key, message) {
2642
2642
  warned.add(key);
2643
2643
  console.warn(message);
2644
2644
  }
2645
+
2646
+ // ../font/dist/index.js
2645
2647
  var TEXT_VERT_SRC = (
2646
2648
  /* glsl */
2647
2649
  `#version 300 es
@@ -2738,7 +2740,7 @@ var TEXT_SDF_UNIFORMS = [
2738
2740
  ];
2739
2741
  var TEXT_SDF_ATTRIBUTES = ["a_position", "a_uv", "a_baselineY"];
2740
2742
 
2741
- // ../modes/dist/chunk-KILROWYB.js
2743
+ // ../modes/dist/chunk-YAJYQMBG.js
2742
2744
  var NORMAL = {
2743
2745
  allows: [
2744
2746
  "creates-selection",
@@ -3131,7 +3133,7 @@ function serialToEntry(se, custom, logger) {
3131
3133
  };
3132
3134
  }
3133
3135
 
3134
- // ../core/dist/chunk-PI56ORHE.js
3136
+ // ../core/dist/chunk-SMCZRSYB.js
3135
3137
  function worldToScreen(worldX, worldY, view) {
3136
3138
  return [view.panX + worldX * view.zoom.x, view.panY + worldY * view.zoom.y];
3137
3139
  }
@@ -6988,70 +6990,98 @@ function drawTextGroup(ctx, group, prog, dx, dy) {
6988
6990
  gl.deleteBuffer(vbo);
6989
6991
  gl.deleteBuffer(ibo);
6990
6992
  }
6993
+ var IMAGE_QUAD_RING_SIZE = 64;
6994
+ var IMAGE_QUAD_RINGS = /* @__PURE__ */ new WeakMap();
6995
+ var IMAGE_QUAD_INDICES = new Uint32Array([0, 1, 2, 1, 3, 2]);
6996
+ var IMAGE_QUAD_STRIDE = 16;
6997
+ function imageQuadRing(gl, prog) {
6998
+ const existing = IMAGE_QUAD_RINGS.get(prog);
6999
+ if (existing) return existing;
7000
+ const aPosLoc = prog.attribute("a_position");
7001
+ const aUvLoc = prog.attribute("a_uv");
7002
+ const ibo = gl.createBuffer();
7003
+ if (!ibo) throw new Error("drawImage: createBuffer (IBO) returned null");
7004
+ const vaos = [];
7005
+ const vbos = [];
7006
+ for (let slot = 0; slot < IMAGE_QUAD_RING_SIZE; slot++) {
7007
+ const vao = gl.createVertexArray();
7008
+ const vbo = gl.createBuffer();
7009
+ if (!vao) throw new Error("drawImage: createVertexArray returned null");
7010
+ if (!vbo) throw new Error("drawImage: createBuffer returned null");
7011
+ gl.bindVertexArray(vao);
7012
+ gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
7013
+ gl.bufferData(gl.ARRAY_BUFFER, 4 * IMAGE_QUAD_STRIDE, gl.DYNAMIC_DRAW);
7014
+ if (aPosLoc !== void 0) {
7015
+ gl.enableVertexAttribArray(aPosLoc);
7016
+ gl.vertexAttribPointer(aPosLoc, 2, gl.FLOAT, false, IMAGE_QUAD_STRIDE, 0);
7017
+ }
7018
+ if (aUvLoc !== void 0) {
7019
+ gl.enableVertexAttribArray(aUvLoc);
7020
+ gl.vertexAttribPointer(aUvLoc, 2, gl.FLOAT, false, IMAGE_QUAD_STRIDE, 8);
7021
+ }
7022
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);
7023
+ if (slot === 0) gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, IMAGE_QUAD_INDICES, gl.STATIC_DRAW);
7024
+ gl.bindVertexArray(null);
7025
+ vaos.push(vao);
7026
+ vbos.push(vbo);
7027
+ }
7028
+ const ring = { vaos, vbos, ibo, next: 0 };
7029
+ IMAGE_QUAD_RINGS.set(prog, ring);
7030
+ return ring;
7031
+ }
7032
+ function disposeImageQuads(gl, prog) {
7033
+ const ring = IMAGE_QUAD_RINGS.get(prog);
7034
+ if (!ring) return;
7035
+ for (const vao of ring.vaos) gl.deleteVertexArray(vao);
7036
+ for (const vbo of ring.vbos) gl.deleteBuffer(vbo);
7037
+ gl.deleteBuffer(ring.ibo);
7038
+ IMAGE_QUAD_RINGS.delete(prog);
7039
+ }
7040
+ var IMAGE_QUAD_VERTICES = new Float32Array(16);
6991
7041
  function drawImage(ctx, cmd) {
6992
7042
  ctx.imageCache.upload(cmd.image, cmd.image);
6993
7043
  const gl = ctx.gl;
6994
- gl.useProgram(ctx.imageFill.handle);
7044
+ const prog = ctx.imageFill;
7045
+ gl.useProgram(prog.handle);
6995
7046
  const x0 = cmd.x, y0 = cmd.y;
6996
7047
  const x1 = cmd.x + cmd.w, y1 = cmd.y + cmd.h;
6997
- const vertices = new Float32Array([
6998
- x0,
6999
- y0,
7000
- 0,
7001
- 0,
7002
- x1,
7003
- y0,
7004
- 1,
7005
- 0,
7006
- x0,
7007
- y1,
7008
- 0,
7009
- 1,
7010
- x1,
7011
- y1,
7012
- 1,
7013
- 1
7014
- ]);
7015
- const indices = new Uint32Array([0, 1, 2, 1, 3, 2]);
7016
- const vao = gl.createVertexArray();
7017
- if (!vao) throw new Error("drawImage: createVertexArray returned null");
7018
- gl.bindVertexArray(vao);
7019
- const vbo = gl.createBuffer();
7020
- if (!vbo) throw new Error("drawImage: createBuffer returned null");
7021
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
7022
- gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.DYNAMIC_DRAW);
7023
- const stride = 16;
7024
- const aPosLoc = ctx.imageFill.attribute("a_position");
7025
- const aUvLoc = ctx.imageFill.attribute("a_uv");
7026
- if (aPosLoc !== void 0) {
7027
- gl.enableVertexAttribArray(aPosLoc);
7028
- gl.vertexAttribPointer(aPosLoc, 2, gl.FLOAT, false, stride, 0);
7029
- }
7030
- if (aUvLoc !== void 0) {
7031
- gl.enableVertexAttribArray(aUvLoc);
7032
- gl.vertexAttribPointer(aUvLoc, 2, gl.FLOAT, false, stride, 8);
7033
- }
7034
- const ibo = gl.createBuffer();
7035
- if (!ibo) throw new Error("drawImage: createBuffer (IBO) returned null");
7036
- gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, ibo);
7037
- gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.DYNAMIC_DRAW);
7038
- setProjAndModel(ctx, ctx.imageFill);
7039
- setColorMatrixUniforms(ctx, ctx.imageFill);
7048
+ const v = IMAGE_QUAD_VERTICES;
7049
+ v[0] = x0;
7050
+ v[1] = y0;
7051
+ v[2] = 0;
7052
+ v[3] = 0;
7053
+ v[4] = x1;
7054
+ v[5] = y0;
7055
+ v[6] = 1;
7056
+ v[7] = 0;
7057
+ v[8] = x0;
7058
+ v[9] = y1;
7059
+ v[10] = 0;
7060
+ v[11] = 1;
7061
+ v[12] = x1;
7062
+ v[13] = y1;
7063
+ v[14] = 1;
7064
+ v[15] = 1;
7065
+ const ring = imageQuadRing(gl, prog);
7066
+ const slot = ring.next;
7067
+ ring.next = (slot + 1) % IMAGE_QUAD_RING_SIZE;
7068
+ gl.bindVertexArray(ring.vaos[slot]);
7069
+ gl.bindBuffer(gl.ARRAY_BUFFER, ring.vbos[slot]);
7070
+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, v);
7071
+ setProjAndModel(ctx, prog);
7072
+ setColorMatrixUniforms(ctx, prog);
7040
7073
  ctx.imageCache.bind(cmd.image, 0);
7041
7074
  gl.texParameteri(
7042
7075
  gl.TEXTURE_2D,
7043
7076
  gl.TEXTURE_MAG_FILTER,
7044
7077
  cmd.sampling === "nearest" ? gl.NEAREST : gl.LINEAR
7045
7078
  );
7046
- gl.uniform1i(ctx.imageFill.uniform("u_sampler"), 0);
7047
- gl.uniform1f(ctx.imageFill.uniform("u_opacity"), cmd.opacity ?? 1);
7048
- gl.uniform1f(ctx.imageFill.uniform("u_alpha"), ctx.state.alpha);
7079
+ gl.uniform1i(prog.uniform("u_sampler"), 0);
7080
+ gl.uniform1f(prog.uniform("u_opacity"), cmd.opacity ?? 1);
7081
+ gl.uniform1f(prog.uniform("u_alpha"), ctx.state.alpha);
7049
7082
  applyClipTest(ctx);
7050
7083
  gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_INT, 0);
7051
7084
  gl.bindVertexArray(null);
7052
- gl.deleteVertexArray(vao);
7053
- gl.deleteBuffer(vbo);
7054
- gl.deleteBuffer(ibo);
7055
7085
  }
7056
7086
  var CUSTOM_VERT_SRC = (
7057
7087
  /* glsl */
@@ -7371,6 +7401,7 @@ var WeaselRenderer = class {
7371
7401
  this.gradRampCache.free();
7372
7402
  if (this.quadVbo) gl.deleteBuffer(this.quadVbo);
7373
7403
  if (this.quadIbo) gl.deleteBuffer(this.quadIbo);
7404
+ disposeImageQuads(gl, this.imageFill);
7374
7405
  this.solidBatch.dispose();
7375
7406
  }
7376
7407
  /**
@@ -24475,5 +24506,5 @@ function oklchToOklab(L, C, h) {
24475
24506
  }
24476
24507
 
24477
24508
  export { FALLBACK_FIT_VIEW, MinimapCanvas, SceneViewCanvas, UnknownIcon, buildSceneViewCommands, computeFitView2, computeIndicatorCommand, eligibleContribution, evaluateEnabled, oklabToSrgbU8, oklchToOklab, renderSceneToCanvas, rgbaToHex, useActionsRegistry, useOptionalDepRegistry };
24478
- //# sourceMappingURL=chunk-3P56ZCCJ.js.map
24479
- //# sourceMappingURL=chunk-3P56ZCCJ.js.map
24509
+ //# sourceMappingURL=chunk-3WPOGKUP.js.map
24510
+ //# sourceMappingURL=chunk-3WPOGKUP.js.map