@glissade/scene 0.10.0-pre.0 → 0.10.0-pre.1

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/index.js CHANGED
@@ -371,8 +371,8 @@ function createScene(init) {
371
371
  });
372
372
  const nodes = /* @__PURE__ */ new Map();
373
373
  const playhead = createPlayhead();
374
- let measurer = null;
375
- indexNodes(root, nodes, () => measurer ?? fallbackMeasurer());
374
+ const measurer = signal(null);
375
+ indexNodes(root, nodes, () => measurer() ?? fallbackMeasurer());
376
376
  return {
377
377
  root,
378
378
  nodes,
@@ -384,10 +384,10 @@ function createScene(init) {
384
384
  return nodes.get(target.slice(0, slash))?.resolveTarget(target.slice(slash + 1));
385
385
  },
386
386
  setTextMeasurer: (m) => {
387
- measurer = m;
387
+ measurer.set(m);
388
388
  },
389
389
  get textMeasurer() {
390
- return measurer ?? fallbackMeasurer();
390
+ return measurer.peek() ?? fallbackMeasurer();
391
391
  }
392
392
  };
393
393
  }
package/dist/layout.js CHANGED
@@ -95,6 +95,7 @@ var Layout = class extends Group {
95
95
  justify: this.justify,
96
96
  align: this.align
97
97
  };
98
+ this.trackStructure();
98
99
  const flowable = [];
99
100
  const absolute = [];
100
101
  this.children.forEach((child, index) => {
@@ -476,11 +476,17 @@ declare function sketchStrokes(segs: readonly PathSeg[], style: SketchStyle, see
476
476
  /** Rounded-rect path segments — Rect's outline, shared with Highlight. */
477
477
  declare function roundedRectSegs(x: number, y: number, w: number, h: number, r: number): PathSeg[];
478
478
  declare class Group extends Node {
479
+ #private;
479
480
  readonly children: Node[];
480
481
  constructor(props?: NodeProps & {
481
482
  children?: Node[];
482
483
  });
484
+ /** Record the structural version as a dependency — call inside a computed
485
+ * that walks `children` so add()/remove() invalidate it. */
486
+ protected trackStructure(): void;
483
487
  add(child: Node): this;
488
+ /** Remove a child (the reactive counterpart to add()); no-op if absent. */
489
+ remove(child: Node): this;
484
490
  protected draw(out: DisplayListBuilder, ctx: EvalContext): void;
485
491
  }
486
492
  interface ShapeProps extends NodeProps {
@@ -910,14 +910,34 @@ function roundedRectSegs(x, y, w, h, r) {
910
910
  }
911
911
  var Group = class extends Node {
912
912
  children;
913
+ /** Version bumped on structural child mutation, so a dependency-tracked memo
914
+ * (e.g. Layout's computed) re-runs when the child SET changes — not only when
915
+ * a participating prop signal does. */
916
+ #structure = signal(0);
913
917
  constructor(props = {}) {
914
918
  super(props);
915
919
  this.children = props.children ?? [];
916
920
  for (const child of this.children) child.parent = this;
917
921
  }
922
+ /** Record the structural version as a dependency — call inside a computed
923
+ * that walks `children` so add()/remove() invalidate it. */
924
+ trackStructure() {
925
+ this.#structure();
926
+ }
918
927
  add(child) {
919
928
  child.parent = this;
920
929
  this.children.push(child);
930
+ this.#structure.set(this.#structure.peek() + 1);
931
+ return this;
932
+ }
933
+ /** Remove a child (the reactive counterpart to add()); no-op if absent. */
934
+ remove(child) {
935
+ const i = this.children.indexOf(child);
936
+ if (i >= 0) {
937
+ this.children.splice(i, 1);
938
+ if (child.parent === this) child.parent = null;
939
+ this.#structure.set(this.#structure.peek() + 1);
940
+ }
921
941
  return this;
922
942
  }
923
943
  draw(out, ctx) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glissade/scene",
3
- "version": "0.10.0-pre.0",
3
+ "version": "0.10.0-pre.1",
4
4
  "description": "glissade scene graph: nodes, transforms, DisplayList emission. Renderer-agnostic; zero DOM/Node dependencies.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  ],
21
21
  "dependencies": {
22
22
  "yoga-layout": "^3.2.1",
23
- "@glissade/core": "0.10.0-pre.0"
23
+ "@glissade/core": "0.10.0-pre.1"
24
24
  },
25
25
  "repository": {
26
26
  "type": "git",