Skip to content

refactor: consolidate runtime adapters, split dist chunks, and deduplicate core/scene clones - #95

Merged
alowpoly merged 5 commits into
mainfrom
consolidate-runtime-adapters
Dec 3, 2026
Merged

alowpoly merged 5 commits into
mainfrom
consolidate-runtime-adapters

Conversation

@alowpoly

@alowpoly alowpoly commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Consolidates duplicated runtime adapter logic, core algorithms, and build output across @layoutit/polycss, @layoutit/polycss-core, @layoutit/polycss-react, @layoutit/polycss-vue, bench/, and website/ (-2,225 net lines across 115 files vs main, and packages/polycss/dist JS reduced from 700.0 KB to 201.4 KB via chunk splitting).

Key changes

  • Single runtime adapter layer (@layoutit/polycss/runtime):
    • Collapsed TransformControls (with per-handle TransformGizmoCache memoization and live getState drag callbacks) and Select onto shared runtime engines (gizmoEngine.ts, selectionEngine.ts).
    • Extracted shared camera snapshot/store sync (cameraSnapshotAttrs.ts), DOM mesh registry & pointer event synthesis (meshHitTest.ts), standalone mesh mounting (standaloneMesh.ts), and <Poly> leaf descriptors (polyLeafDescriptor.ts).
    • Enabled tsup chunk splitting (splitting: true) in packages/polycss/tsup.config.ts while retaining all 368 @layoutit/polycss-core re-exports in dist/index.js and keeping customElements.define isolated to dist/elements.js.
  • Scene decomposition & clone removal:
    • Split packages/polycss/src/api/createPolyScene.ts (1,387 -> 320 lines) into api/scene/renderEntry.ts and api/scene/meshEntry.ts.
    • Extracted shared SAH BVH (packages/core/src/cull/bvh.ts), shared Orbit/Map pointer controls (pointerControlsCore.ts, PolyPointerControlsElement.ts), shared core vector/merge/color/iframe/Three-camera helpers, shared custom-element camera wrapper (cameraWrapper.ts), and shared bench math (bench/math.mjs).
    • Pruned verified dead code across packages/polycss, packages/fonts, and website/.
  • Bug fixes & parity improvements:
    • Fixed Vue <PolySelect> single-click toggle-off (shallowRef instead of reactive Proxy identity mismatch; updated packages/vue/src/select/Select.test.ts), added non-Element click guard (target?.closest?.), aligned React api.has to live controller state, and made duplicate add() in multi-select a no-op.
    • Fixed -webkit-* camelCase slicing in cssPropToCamel (prop.slice(7)).
  • Mechanical guards:
    • Added zero-network morph registry-dependency compatibility verification to check-packs.mjs.
    • Added all-exports chunk-splitting guard to bench/renderer-ir-conformance.test.mjs.
    • Added real DOM MutationObserver zero-churn orbit tests to React and Vue TransformControls test suites.

Verification

  • pnpm map && pnpm verify (all guards, unit tests, builds, typecheck, IR conformance, packs, bench, and examples)
  • pnpm test:coverage (all 8 workspace packages)
  • pnpm --filter @layoutit/polycss-website build && test:domformat-tools && verify:domformat (23 pages, 304 Gallery models)
  • pnpm bench:gate:lifecycle (13/13)
  • pnpm bench:gate:ci -- --base-ref main (55/55 across Chromium and Firefox)
  • pnpm bench:gate:perf -- --base-ref main (9/9)

@alowpoly
alowpoly merged commit c26218f into main Dec 3, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant