You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scope: move renderer setup, materials, geometry and render targets into a createScene(...) factory that returns its parts and a dispose. Move the label pool and tooltip into createLabelLayer(...). Disposal still goes through the existing reverse-order stack.
Acceptance: the same as #111, plus teardown order is unchanged in the recording.
Checked against origin/refactor/111-prepare-pack at d8d73b9. The PR body starts with "⏸ Held until 2.0 ships (see #107)", followed by "Stacked on #121".
Files. All under packages/graph/src/, none exported:
scene.ts: createRenderer, createScene, resize
scene-meshes.ts: the edge, pad, node, fade and post builders
label-layer.ts: createLabelLayer
scene.test.ts, label-layer.test.ts
GraphCanvas.tsx
.changeset/graph-scene-labels.md: patch, "Internal restructure; no API or behaviour change."
Why two factories.createRenderer builds the renderer, scene and camera where they're built today. packBuffers runs after it, then createScene. With seed={null}, three's uuid draws share Math.random with visualRandom. The harness can't see that order, because three draws from its own stream, so the split keeps #111's rule in place by construction.
Disposal. Each resource registers through a track callback as it is built, rather than through one returned dispose. That keeps the 6 stack entries in order: renderer, targets, materials, geometries, labels, tooltip. The array order inside each entry stays the same, and each entry keeps its own try/catch, so a throw in one can't skip the others or leak the canvas.
Other constraints
Labels are appended before the tooltip.
resize keeps its current call order.
viewWidth, viewHeight, viewport and pixelSize stay in GraphCanvas.
The ResizeObserver stays in GraphCanvas.
syncNodes gets GraphCanvas's mutable arrays by reference, and its call during construction stays.
Unit-tested rather than recorded. Recording these would push the recordings past the 200 KB cap:
the renderer options (antialias, alpha: false, powerPreference)
autoClear = false
frustumCulled = false and an infinite bounding sphere on every mesh
the number and order of track entries
the DOM order inside the label layer
Acceptance
vitest run passes without -u, and git diff --exit-code packages/graph/src/__recordings__ is clean. That includes the dispose order in lifecycle.unmount and boot.resize.
browser/graph.spec.ts passes, with its baselines unchanged.
A prettier-formatted diff of dist/index.js shows relocation only.
Every new function is ≤ 60 code lines with cognitive complexity ≤ 12, and the graph lint warning count doesn't rise. If a declarative material builder goes over 60 lines, the PR says why.
Activity
JadRizk commentedon Oct 10, 2026
Scope notes
Checked against
origin/refactor/111-prepare-packat d8d73b9. The PR body starts with "⏸ Held until 2.0 ships (see #107)", followed by "Stacked on #121".Files. All under
packages/graph/src/, none exported:scene.ts:createRenderer,createScene,resizescene-meshes.ts: the edge, pad, node, fade and post builderslabel-layer.ts:createLabelLayerscene.test.ts,label-layer.test.tsGraphCanvas.tsx.changeset/graph-scene-labels.md: patch, "Internal restructure; no API or behaviour change."Why two factories.
createRendererbuilds the renderer, scene and camera where they're built today.packBuffersruns after it, thencreateScene. Withseed={null}, three's uuid draws shareMath.randomwithvisualRandom. The harness can't see that order, because three draws from its own stream, so the split keeps #111's rule in place by construction.Disposal. Each resource registers through a
trackcallback as it is built, rather than through one returneddispose. That keeps the 6 stack entries in order: renderer, targets, materials, geometries, labels, tooltip. The array order inside each entry stays the same, and each entry keeps its own try/catch, so a throw in one can't skip the others or leak the canvas.Other constraints
resizekeeps its current call order.viewWidth,viewHeight,viewportandpixelSizestay in GraphCanvas.ResizeObserverstays in GraphCanvas.syncNodesgets GraphCanvas's mutable arrays by reference, and its call during construction stays.Unit-tested rather than recorded. Recording these would push the recordings past the 200 KB cap:
antialias,alpha: false,powerPreference)autoClear = falsefrustumCulled = falseand an infinite bounding sphere on every meshtrackentriesAcceptance
vitest runpasses without-u, andgit diff --exit-code packages/graph/src/__recordings__is clean. That includes the dispose order inlifecycle.unmountandboot.resize.browser/graph.spec.tspasses, with its baselines unchanged.dist/index.d.tsanddist/index.d.ctsare byte-identical to the Extract prepareGraph and packBuffers #111 branch, and thenpm pack --dry-runfile list is unchanged.dist/index.jsshows relocation only.refactor/111-prepare-pack. 🏷️ types(graph): drop the non-null assertions the compiler doesn't need #118 also has hunks in this region, so whichever merges later rebases.🔀 merge main (with #121 squash-merged) into #112