stickyflow 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/dist/{chunk-KFJIFHXG.js → chunk-65IVT4GK.js} +475 -199
  4. package/dist/chunk-65IVT4GK.js.map +1 -0
  5. package/dist/{chunk-6JKNT2YC.js → chunk-BYMIYXP5.js} +17 -7
  6. package/dist/chunk-BYMIYXP5.js.map +1 -0
  7. package/dist/{chunk-N6WVHOUQ.js → chunk-CSXQD3ON.js} +28 -15
  8. package/dist/chunk-CSXQD3ON.js.map +1 -0
  9. package/dist/{chunk-YM3XFBI4.cjs → chunk-CXL254BT.cjs} +17 -6
  10. package/dist/chunk-CXL254BT.cjs.map +1 -0
  11. package/dist/{chunk-S5BVAAEF.cjs → chunk-DDCTNLLD.cjs} +989 -713
  12. package/dist/chunk-DDCTNLLD.cjs.map +1 -0
  13. package/dist/{chunk-34PK7HEU.cjs → chunk-HFOGKSNU.cjs} +18 -18
  14. package/dist/{chunk-34PK7HEU.cjs.map → chunk-HFOGKSNU.cjs.map} +1 -1
  15. package/dist/{chunk-IIOJFR73.cjs → chunk-UXDWH2JC.cjs} +56 -43
  16. package/dist/chunk-UXDWH2JC.cjs.map +1 -0
  17. package/dist/{chunk-6LQJUAD4.js → chunk-XEN5QIIJ.js} +6 -6
  18. package/dist/{chunk-6LQJUAD4.js.map → chunk-XEN5QIIJ.js.map} +1 -1
  19. package/dist/index.cjs +24 -24
  20. package/dist/index.d.cts +4 -4
  21. package/dist/index.d.ts +4 -4
  22. package/dist/index.js +4 -4
  23. package/dist/interaction/index.cjs +780 -382
  24. package/dist/interaction/index.cjs.map +1 -1
  25. package/dist/interaction/index.d.cts +12 -3
  26. package/dist/interaction/index.d.ts +12 -3
  27. package/dist/interaction/index.js +562 -165
  28. package/dist/interaction/index.js.map +1 -1
  29. package/dist/{render-r1GYvjNm.d.cts → render-C5X74hds.d.cts} +75 -4
  30. package/dist/{render-r1GYvjNm.d.ts → render-C5X74hds.d.ts} +75 -4
  31. package/dist/{runtimeTypes-ByiafBwg.d.ts → runtimeTypes-D8hPZ62T.d.ts} +1 -1
  32. package/dist/{runtimeTypes-DwLeD-em.d.cts → runtimeTypes-yTSAvtCn.d.cts} +1 -1
  33. package/dist/stickyflow-diagram.global.js +37 -35
  34. package/dist/stickyflow-diagram.global.js.map +1 -1
  35. package/dist/{types-T7W2yTQF.d.cts → types-BDKDf4zr.d.cts} +1 -1
  36. package/dist/{types-ndGA1kbl.d.ts → types-CdgGdtoD.d.ts} +1 -1
  37. package/dist/viewer/index.cjs +9 -9
  38. package/dist/viewer/index.d.cts +4 -4
  39. package/dist/viewer/index.d.ts +4 -4
  40. package/dist/viewer/index.js +4 -4
  41. package/dist/web-component/index.cjs +6 -6
  42. package/dist/web-component/index.d.cts +2 -2
  43. package/dist/web-component/index.d.ts +2 -2
  44. package/dist/web-component/index.js +4 -4
  45. package/package.json +1 -1
  46. package/dist/chunk-6JKNT2YC.js.map +0 -1
  47. package/dist/chunk-IIOJFR73.cjs.map +0 -1
  48. package/dist/chunk-KFJIFHXG.js.map +0 -1
  49. package/dist/chunk-N6WVHOUQ.js.map +0 -1
  50. package/dist/chunk-S5BVAAEF.cjs.map +0 -1
  51. package/dist/chunk-YM3XFBI4.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { render, formatRollingNumber, DEFAULT_ROLLING_NUMBER_STYLE } from './chunk-KFJIFHXG.js';
2
- import { parseContractVersion, isContractCompatible, Emitter, resolveOwner, CHANGE_COLOR, findOwnerNode, isPrimary, linkSelectionOverlay, pathSelectionOverlay, isometricSelectionOverlay, shapeSelectionOverlay, DERIVED_HEIGHT_ROLES, quickDuplicateBubbles, isCameraGesture, linkChangeOverlay, shapeChangeOverlay, startChangeFade, REDUCED_MOTION_DURATION_MS, FLASH_DURATION_MS } from './chunk-6LQJUAD4.js';
1
+ import { render, formatRollingNumber, DEFAULT_ROLLING_NUMBER_STYLE } from './chunk-65IVT4GK.js';
2
+ import { parseContractVersion, isContractCompatible, Emitter, resolveOwner, CHANGE_COLOR, findOwnerNode, isPrimary, linkSelectionOverlay, pathSelectionOverlay, isometricSelectionOverlay, shapeSelectionOverlay, DERIVED_HEIGHT_ROLES, quickDuplicateBubbles, isCameraGesture, linkChangeOverlay, shapeChangeOverlay, startChangeFade, REDUCED_MOTION_DURATION_MS, FLASH_DURATION_MS } from './chunk-XEN5QIIJ.js';
3
3
 
4
4
  // src/runtime/viewer/display/rootAttributesPatch.ts
5
5
  var CAMERA_OWNED_ATTRIBUTES = /* @__PURE__ */ new Set(["viewbox", "width", "height"]);
@@ -232,6 +232,14 @@ var ViewportController = class {
232
232
  setNatural(natural) {
233
233
  this.#natural = natural;
234
234
  }
235
+ #userPoint(clientX, clientY) {
236
+ const matrix = this.#svg.getScreenCTM();
237
+ if (!matrix) {
238
+ return null;
239
+ }
240
+ const point = new DOMPoint(clientX, clientY).matrixTransform(matrix.inverse());
241
+ return { x: point.x, y: point.y };
242
+ }
235
243
  zoomBy(factor, clientX, clientY) {
236
244
  const rect = this.#svg.getBoundingClientRect();
237
245
  if (rect.width <= 0 || rect.height <= 0) {
@@ -239,16 +247,19 @@ var ViewportController = class {
239
247
  }
240
248
  const centerX = clientX ?? rect.left + rect.width / 2;
241
249
  const centerY = clientY ?? rect.top + rect.height / 2;
242
- const worldX = this.#view.x + (centerX - rect.left) / rect.width * this.#view.w;
243
- const worldY = this.#view.y + (centerY - rect.top) / rect.height * this.#view.h;
244
- this.#view = { w: this.#view.w / factor, h: this.#view.h / factor, x: 0, y: 0 };
245
- this.#view.x = worldX - (centerX - rect.left) / rect.width * this.#view.w;
246
- this.#view.y = worldY - (centerY - rect.top) / rect.height * this.#view.h;
250
+ const anchor = this.#userPoint(centerX, centerY);
251
+ this.#view = { ...this.#view, w: this.#view.w / factor, h: this.#view.h / factor };
252
+ this.apply();
253
+ const moved = anchor ? this.#userPoint(centerX, centerY) : null;
254
+ if (anchor && moved) {
255
+ this.#view.x += anchor.x - moved.x;
256
+ this.#view.y += anchor.y - moved.y;
257
+ }
247
258
  this.apply();
248
259
  }
249
260
  panBy(dxPixels, dyPixels) {
250
- const rect = this.#svg.getBoundingClientRect();
251
- const pixelsPerUnit = rect.width > 0 ? rect.width / this.#view.w : 1;
261
+ const scale = this.#svg.getScreenCTM()?.a;
262
+ const pixelsPerUnit = scale && scale > 0 ? scale : 1;
252
263
  this.#view.x -= dxPixels / pixelsPerUnit;
253
264
  this.#view.y -= dyPixels / pixelsPerUnit;
254
265
  this.apply();
@@ -381,8 +392,8 @@ function readWidgetStyle(surface) {
381
392
  return DEFAULT_ROLLING_NUMBER_STYLE;
382
393
  }
383
394
  }
384
- function cellsOf(box, plain) {
385
- const size = Math.max(1, Math.min(box.width, box.height) * 0.28);
395
+ function cellsOf(box, plain, fontSize = 0) {
396
+ const size = fontSize > 0 ? fontSize : Math.max(1, Math.min(box.width, box.height) * 0.28);
386
397
  return {
387
398
  size,
388
399
  plain,
@@ -468,7 +479,7 @@ function flattenRollingNumbers(svg) {
468
479
  const value = surface.getAttribute("data-sf-widget-value") ?? "";
469
480
  const style = readWidgetStyle(surface);
470
481
  const label = surface.querySelector("div > span:not([data-sf-rolling-digit])")?.textContent ?? "";
471
- const cells = cellsOf(box, style.variant === "plain");
482
+ const cells = cellsOf(box, style.variant === "plain", style.fontSize);
472
483
  const labelBlock = label ? cells.size * 0.3 : 0;
473
484
  const rowWidth = value.length * cells.cellWidth + Math.max(0, value.length - 1) * cells.gap;
474
485
  const left = box.x + (box.width - rowWidth) / 2;
@@ -2024,6 +2035,7 @@ uniform vec3 uColor;
2024
2035
  uniform vec3 uAccent;
2025
2036
  uniform vec3 uGlow;
2026
2037
  uniform vec3 uCore;
2038
+ uniform vec3 uPeak;
2027
2039
  varying vec2 vUv;
2028
2040
 
2029
2041
  float wireAt(float at, float lineAt, float depth, float radius, float knob, float spread) {
@@ -2096,7 +2108,8 @@ void main() {
2096
2108
  vec2 q = abs(vec2(across - (tickEnd - tickLength * 0.5), tickAlong)) - vec2(tickLength * 0.5, halfTick) + corner;
2097
2109
  float edge = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - corner;
2098
2110
  float tick = (1.0 - smoothstep(-0.75, 0.75, edge)) * inRange * mix(0.4, 1.0, tickBump);
2099
- vec3 tickColor = mix(uColor, vec3(1.0), tickBump);
2111
+ vec3 peakColor = dot(uPeak, uPeak) > 0.0 ? uPeak : vec3(1.0);
2112
+ vec3 tickColor = mix(uColor, peakColor, tickBump);
2100
2113
 
2101
2114
  float alpha = clamp(tick + line * 0.95 + glow + core, 0.0, 1.0);
2102
2115
  vec3 rgb = tickColor * tick + lineColor * line * 0.95 + glowColor * glow + coreColor * core;
@@ -3661,5 +3674,5 @@ function createViewer(options) {
3661
3674
  }
3662
3675
 
3663
3676
  export { SHADER_DEFAULTS, connectInteraction, createViewer, registerShaderProgram, shaderProgram };
3664
- //# sourceMappingURL=chunk-N6WVHOUQ.js.map
3665
- //# sourceMappingURL=chunk-N6WVHOUQ.js.map
3677
+ //# sourceMappingURL=chunk-CSXQD3ON.js.map
3678
+ //# sourceMappingURL=chunk-CSXQD3ON.js.map