geonodes-web-render 0.3.0 → 0.3.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/dist/embed.js CHANGED
@@ -8495,92 +8495,111 @@ var Kf = {
8495
8495
  simulationZone: Gf
8496
8496
  }, qf = { padding: .08 };
8497
8497
  function Jf(e) {
8498
- let { nodes: t, edges: n, breadcrumbs: r, onNavigate: i, onSelectionIds: o } = e, { fitView: s } = ll(), [l, u, d] = fd(t), [f, p, m] = pd(n);
8499
- return c(() => {
8500
- u(t), o?.([]), s(qf);
8498
+ let { nodes: t, edges: n, breadcrumbs: r, onNavigate: i, onSelectionIds: o, zoomOnScroll: s = !0 } = e, { fitView: l } = ll(), u = d(null), f = d(!1), [p, m, h] = fd(t), [v, y, b] = pd(n);
8499
+ c(() => {
8500
+ m(t), o?.([]), f.current = !1, l(qf);
8501
8501
  }, [
8502
8502
  t,
8503
- u,
8503
+ m,
8504
8504
  o,
8505
- s
8505
+ l
8506
8506
  ]), c(() => {
8507
- p(n);
8508
- }, [n, p]), /* @__PURE__ */ _(dd, {
8509
- nodes: l,
8510
- edges: f,
8511
- onNodesChange: d,
8512
- onEdgesChange: m,
8513
- onSelectionChange: a(({ nodes: e }) => {
8514
- o?.(e.map((e) => e.id));
8515
- }, [o]),
8516
- nodeTypes: Kf,
8517
- fitView: !0,
8518
- fitViewOptions: qf,
8519
- minZoom: .2,
8520
- nodesDraggable: !1,
8521
- nodesConnectable: !1,
8522
- elementsSelectable: !0,
8523
- nodesFocusable: !1,
8524
- edgesFocusable: !1,
8525
- selectNodesOnDrag: !1,
8526
- selectionOnDrag: !0,
8527
- selectionMode: va.Partial,
8528
- connectOnClick: !1,
8529
- panOnDrag: [1, 2],
8530
- panOnScroll: !1,
8531
- zoomOnScroll: !0,
8532
- zoomOnDoubleClick: !1,
8533
- children: [
8534
- /* @__PURE__ */ g(bd, {
8535
- gap: 20,
8536
- size: 1
8537
- }),
8538
- /* @__PURE__ */ g(kd, { showInteractive: !1 }),
8539
- r.length > 1 ? /* @__PURE__ */ g(Sc, {
8540
- position: "top-left",
8541
- children: /* @__PURE__ */ g("nav", {
8542
- className: "gn-breadcrumbs",
8543
- "aria-label": "Node group path",
8544
- children: r.map((e, t) => {
8545
- let n = t === r.length - 1;
8546
- return /* @__PURE__ */ _("span", {
8547
- className: "gn-breadcrumbs__item",
8548
- children: [t > 0 ? /* @__PURE__ */ g("span", {
8549
- className: "gn-breadcrumbs__sep",
8550
- "aria-hidden": "true",
8551
- children: "›"
8552
- }) : null, n ? /* @__PURE__ */ g("span", {
8553
- className: "gn-breadcrumbs__current",
8554
- "aria-current": "page",
8555
- children: e.label
8556
- }) : /* @__PURE__ */ g("button", {
8557
- type: "button",
8558
- className: "gn-breadcrumbs__link",
8559
- onClick: () => i(t),
8560
- children: e.label
8561
- })]
8562
- }, `${e.id}-${t}`);
8507
+ y(n);
8508
+ }, [n, y]), c(() => {
8509
+ let e = u.current;
8510
+ if (!e) return;
8511
+ let t = new ResizeObserver(() => {
8512
+ f.current || l(qf);
8513
+ });
8514
+ return t.observe(e), () => t.disconnect();
8515
+ }, [l]);
8516
+ let x = a((e) => {
8517
+ e && (f.current = !0);
8518
+ }, []);
8519
+ return /* @__PURE__ */ g("div", {
8520
+ ref: u,
8521
+ style: {
8522
+ width: "100%",
8523
+ height: "100%"
8524
+ },
8525
+ children: /* @__PURE__ */ _(dd, {
8526
+ nodes: p,
8527
+ edges: v,
8528
+ onNodesChange: h,
8529
+ onEdgesChange: b,
8530
+ onSelectionChange: a(({ nodes: e }) => {
8531
+ o?.(e.map((e) => e.id));
8532
+ }, [o]),
8533
+ onMoveStart: x,
8534
+ nodeTypes: Kf,
8535
+ fitView: !0,
8536
+ fitViewOptions: qf,
8537
+ minZoom: .2,
8538
+ nodesDraggable: !1,
8539
+ nodesConnectable: !1,
8540
+ elementsSelectable: !0,
8541
+ nodesFocusable: !1,
8542
+ edgesFocusable: !1,
8543
+ selectNodesOnDrag: !1,
8544
+ selectionOnDrag: !0,
8545
+ selectionMode: va.Partial,
8546
+ connectOnClick: !1,
8547
+ panOnDrag: [1, 2],
8548
+ panOnScroll: !1,
8549
+ zoomOnScroll: s,
8550
+ zoomOnDoubleClick: !1,
8551
+ children: [
8552
+ /* @__PURE__ */ g(bd, {
8553
+ gap: 20,
8554
+ size: 1
8555
+ }),
8556
+ /* @__PURE__ */ g(kd, { showInteractive: !1 }),
8557
+ r.length > 1 ? /* @__PURE__ */ g(Sc, {
8558
+ position: "top-left",
8559
+ children: /* @__PURE__ */ g("nav", {
8560
+ className: "gn-breadcrumbs",
8561
+ "aria-label": "Node group path",
8562
+ children: r.map((e, t) => {
8563
+ let n = t === r.length - 1;
8564
+ return /* @__PURE__ */ _("span", {
8565
+ className: "gn-breadcrumbs__item",
8566
+ children: [t > 0 ? /* @__PURE__ */ g("span", {
8567
+ className: "gn-breadcrumbs__sep",
8568
+ "aria-hidden": "true",
8569
+ children: "›"
8570
+ }) : null, n ? /* @__PURE__ */ g("span", {
8571
+ className: "gn-breadcrumbs__current",
8572
+ "aria-current": "page",
8573
+ children: e.label
8574
+ }) : /* @__PURE__ */ g("button", {
8575
+ type: "button",
8576
+ className: "gn-breadcrumbs__link",
8577
+ onClick: () => i(t),
8578
+ children: e.label
8579
+ })]
8580
+ }, `${e.id}-${t}`);
8581
+ })
8582
+ })
8583
+ }) : null,
8584
+ /* @__PURE__ */ g(Sc, {
8585
+ position: "bottom-right",
8586
+ children: /* @__PURE__ */ g("a", {
8587
+ href: "https://extensions.blender.org/add-ons/tree-clipper/",
8588
+ target: "_blank",
8589
+ rel: "noopener noreferrer",
8590
+ className: "tree-clipper-badge",
8591
+ children: "Exported from Blender using Tree Clipper ↗"
8563
8592
  })
8564
8593
  })
8565
- }) : null,
8566
- /* @__PURE__ */ g(Sc, {
8567
- position: "bottom-right",
8568
- children: /* @__PURE__ */ g("a", {
8569
- href: "https://extensions.blender.org/add-ons/tree-clipper/",
8570
- target: "_blank",
8571
- rel: "noopener noreferrer",
8572
- className: "tree-clipper-badge",
8573
- children: "Exported from Blender using Tree Clipper ↗"
8574
- })
8575
- })
8576
- ]
8594
+ ]
8595
+ })
8577
8596
  });
8578
8597
  }
8579
8598
  function Yf(e) {
8580
- let { jsonText: t, showHeader: n = !0, onSelectionChange: r } = e, [i, o] = f({
8599
+ let { jsonText: t, showHeader: n = !0, onSelectionChange: r, zoomOnScroll: i = !0 } = e, [o, s] = f({
8581
8600
  json: t,
8582
8601
  ids: []
8583
- }), s = u(() => {
8602
+ }), l = u(() => {
8584
8603
  if (!t.trim()) return null;
8585
8604
  try {
8586
8605
  let { rootId: e, trees: n } = ff(JSON.parse(t)), r = {};
@@ -8603,36 +8622,36 @@ function Yf(e) {
8603
8622
  error: e instanceof Error ? e.message : String(e)
8604
8623
  };
8605
8624
  }
8606
- }, [t]), l = u(() => {
8607
- if (!s?.views) return [];
8608
- let e = i.json === t ? i.ids : [], n = [s.rootId];
8609
- for (let t of e) s.views[t] && n.push(t);
8625
+ }, [t]), d = u(() => {
8626
+ if (!l?.views) return [];
8627
+ let e = o.json === t ? o.ids : [], n = [l.rootId];
8628
+ for (let t of e) l.views[t] && n.push(t);
8610
8629
  return n;
8611
8630
  }, [
8612
- s,
8613
- i,
8631
+ l,
8632
+ o,
8614
8633
  t
8615
- ]), d = s?.views ? s.views[l[l.length - 1]] : null, p = a((e) => {
8616
- o((n) => ({
8634
+ ]), p = l?.views ? l.views[d[d.length - 1]] : null, m = a((e) => {
8635
+ s((n) => ({
8617
8636
  json: t,
8618
8637
  ids: n.json === t ? [...n.ids, e] : [e]
8619
8638
  }));
8620
- }, [t]), m = u(() => ({ openGroup: p }), [p]);
8639
+ }, [t]), h = u(() => ({ openGroup: m }), [m]);
8621
8640
  c(() => {
8622
- if (l.length <= 1) return;
8641
+ if (d.length <= 1) return;
8623
8642
  function e(e) {
8624
8643
  if (e.key !== "Tab" && e.key !== "Escape" || e.ctrlKey || e.metaKey || e.altKey) return;
8625
8644
  let n = e.target;
8626
- n && (n.isContentEditable || n.tagName === "INPUT" || n.tagName === "TEXTAREA" || n.closest(".cm-editor")) || (e.preventDefault(), o({
8645
+ n && (n.isContentEditable || n.tagName === "INPUT" || n.tagName === "TEXTAREA" || n.closest(".cm-editor")) || (e.preventDefault(), s({
8627
8646
  json: t,
8628
- ids: l.slice(1, -1)
8647
+ ids: d.slice(1, -1)
8629
8648
  }));
8630
8649
  }
8631
8650
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
8632
- }, [l, t]);
8633
- let h = s?.views ? l.map((e) => ({
8651
+ }, [d, t]);
8652
+ let v = l?.views ? d.map((e) => ({
8634
8653
  id: e,
8635
- label: s.views[e].graph.label
8654
+ label: l.views[e].graph.label
8636
8655
  })) : [];
8637
8656
  return /* @__PURE__ */ _("div", {
8638
8657
  className: "panel flow-panel",
@@ -8644,25 +8663,26 @@ function Yf(e) {
8644
8663
  }), /* @__PURE__ */ g("div", {
8645
8664
  className: "panel-status",
8646
8665
  "aria-live": "polite",
8647
- children: d ? `${d.graph.nodes.length} nodes, ${d.graph.edges.length} links` : null
8666
+ children: p ? `${p.graph.nodes.length} nodes, ${p.graph.edges.length} links` : null
8648
8667
  })]
8649
8668
  }) : null, /* @__PURE__ */ g("div", {
8650
8669
  className: "panel-body flow-panel__body",
8651
- children: s?.error ? /* @__PURE__ */ _("div", {
8670
+ children: l?.error ? /* @__PURE__ */ _("div", {
8652
8671
  className: "flow-error",
8653
8672
  role: "alert",
8654
- children: [/* @__PURE__ */ g("strong", { children: "Parse error" }), /* @__PURE__ */ g("span", { children: s.error })]
8655
- }) : d ? /* @__PURE__ */ g(Cf.Provider, {
8656
- value: m,
8673
+ children: [/* @__PURE__ */ g("strong", { children: "Parse error" }), /* @__PURE__ */ g("span", { children: l.error })]
8674
+ }) : p ? /* @__PURE__ */ g(Cf.Provider, {
8675
+ value: h,
8657
8676
  children: /* @__PURE__ */ g(sd, { children: /* @__PURE__ */ g(Jf, {
8658
- nodes: d.flow.nodes,
8659
- edges: d.flow.edges,
8660
- breadcrumbs: h,
8661
- onNavigate: (e) => o({
8677
+ nodes: p.flow.nodes,
8678
+ edges: p.flow.edges,
8679
+ breadcrumbs: v,
8680
+ onNavigate: (e) => s({
8662
8681
  json: t,
8663
- ids: l.slice(1, e + 1)
8682
+ ids: d.slice(1, e + 1)
8664
8683
  }),
8665
- onSelectionIds: r
8684
+ onSelectionIds: r,
8685
+ zoomOnScroll: i
8666
8686
  }) })
8667
8687
  }) : /* @__PURE__ */ g("div", {
8668
8688
  className: "flow-empty",
@@ -8697,7 +8717,8 @@ function Xf(e) {
8697
8717
  children: [/* @__PURE__ */ g("strong", { children: "Decode error" }), /* @__PURE__ */ g("span", { children: i })]
8698
8718
  }) : /* @__PURE__ */ g(Yf, {
8699
8719
  jsonText: n,
8700
- showHeader: !1
8720
+ showHeader: !1,
8721
+ zoomOnScroll: !1
8701
8722
  })
8702
8723
  })
8703
8724
  });
@@ -4,4 +4,7 @@ export declare function GeometryNodesFlow(props: {
4
4
  showHeader?: boolean;
5
5
  /** Reports the currently selected node ids (raw Tree Clipper node ids as strings). */
6
6
  onSelectionChange?: (nodeIds: string[]) => void;
7
+ /** Zoom the canvas on mouse-wheel. Default true; set false (e.g. in an embed)
8
+ * so the wheel scrolls the host page instead of the node tree. */
9
+ zoomOnScroll?: boolean;
7
10
  }): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "geonodes-web-render",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Browser-based viewer for Blender Geometry Nodes exported via Tree Clipper. Renders node trees as a read-only, Blender-styled graph.",
5
5
  "type": "module",
6
6
  "exports": {