@vibecook/ice 0.10.0 → 0.14.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.
- package/README.md +79 -50
- package/dist/chunk-BA7XJC27.js +2429 -0
- package/dist/chunk-BA7XJC27.js.map +1 -0
- package/dist/chunk-BKV4ZEU3.js +1 -0
- package/dist/chunk-BKV4ZEU3.js.map +1 -0
- package/dist/{chunk-5FQS7V2C.js → chunk-DYK6KNLG.js} +13303 -7485
- package/dist/chunk-DYK6KNLG.js.map +1 -0
- package/dist/chunk-ENIFIUEP.js +155 -0
- package/dist/chunk-ENIFIUEP.js.map +1 -0
- package/dist/chunk-IBWWLA6D.js +634 -0
- package/dist/chunk-IBWWLA6D.js.map +1 -0
- package/dist/{chunk-OR5FNVUE.js → chunk-JS6PG6YD.js} +398 -167
- package/dist/chunk-JS6PG6YD.js.map +1 -0
- package/dist/chunk-QXOCF56A.js +148 -0
- package/dist/chunk-QXOCF56A.js.map +1 -0
- package/dist/chunk-ZPUPBULB.js +7399 -0
- package/dist/chunk-ZPUPBULB.js.map +1 -0
- package/dist/desk-engine.js +36 -0
- package/dist/desk-engine.js.map +1 -0
- package/dist/desk-kit.js +244 -0
- package/dist/desk-kit.js.map +1 -0
- package/dist/desk-objects.js +12728 -0
- package/dist/desk-objects.js.map +1 -0
- package/dist/desk.js +469 -0
- package/dist/desk.js.map +1 -0
- package/dist/devtools.js +233 -189
- package/dist/devtools.js.map +1 -1
- package/dist/dom.js +7 -19
- package/dist/index.js +232 -20
- package/dist/kernel.js +53 -25
- package/dist/react.js +1045 -38
- package/dist/react.js.map +1 -1
- package/dist/types/packages/core/src/behavior/define-behavior.d.ts +11 -0
- package/dist/types/packages/core/src/behavior/runtime.d.ts +4 -0
- package/dist/types/packages/core/src/canvas/define-canvas-type.d.ts +86 -0
- package/dist/types/packages/core/src/canvas/define-container.d.ts +17 -0
- package/dist/types/packages/core/src/canvas/diagnostics.d.ts +27 -0
- package/dist/types/packages/core/src/canvas/engine-catalog.d.ts +70 -0
- package/dist/types/packages/core/src/canvas/extensions.d.ts +125 -0
- package/dist/types/packages/core/src/canvas/frame-behavior-host.d.ts +16 -0
- package/dist/types/packages/core/src/canvas/frame-preview.d.ts +79 -0
- package/dist/types/packages/core/src/canvas/frame-projection.d.ts +38 -0
- package/dist/types/packages/core/src/canvas/frame-view.d.ts +36 -0
- package/dist/types/packages/core/src/canvas/migrate.d.ts +14 -0
- package/dist/types/packages/core/src/canvas/placement.d.ts +30 -0
- package/dist/types/packages/core/src/canvas/presentation-transition.d.ts +100 -0
- package/dist/types/packages/core/src/canvas/runtime-extension-host.d.ts +16 -0
- package/dist/types/packages/core/src/canvas/session.d.ts +47 -0
- package/dist/types/packages/core/src/catalog/camera-derived.d.ts +16 -27
- package/dist/types/packages/core/src/catalog/desk.d.ts +326 -0
- package/dist/types/packages/core/src/catalog/gesture.d.ts +51 -0
- package/dist/types/packages/core/src/catalog/graph.d.ts +2 -2
- package/dist/types/packages/core/src/catalog/index.d.ts +2 -0
- package/dist/types/packages/core/src/catalog/pointer.d.ts +42 -0
- package/dist/types/packages/core/src/catalog/selection-presence.d.ts +7 -0
- package/dist/types/packages/core/src/catalog/settings-resources.d.ts +28 -2
- package/dist/types/packages/core/src/catalog/surface.d.ts +1 -0
- package/dist/types/packages/core/src/doc/doc-commit-sink.d.ts +18 -2
- package/dist/types/packages/core/src/doc/doc-kit.d.ts +21 -2
- package/dist/types/packages/core/src/doc/envelope.d.ts +5 -2
- package/dist/types/packages/core/src/doc/schema-migrate.d.ts +1 -1
- package/dist/types/packages/core/src/doc/version-gate.d.ts +21 -3
- package/dist/types/packages/core/src/engine/commit-sink.d.ts +10 -1
- package/dist/types/packages/core/src/engine/engine.d.ts +6 -0
- package/dist/types/packages/core/src/engine/frame-control.d.ts +74 -0
- package/dist/types/packages/core/src/engine/guests.d.ts +4 -1
- package/dist/types/packages/core/src/engine/world-doors.d.ts +12 -0
- package/dist/types/packages/core/src/facade/create-canvas-engine.d.ts +146 -13
- package/dist/types/packages/core/src/index.d.ts +34 -13
- package/dist/types/packages/core/src/input/queue.d.ts +3 -1
- package/dist/types/packages/core/src/interaction/install.d.ts +30 -0
- package/dist/types/packages/core/src/interaction/wakes.d.ts +24 -0
- package/dist/types/packages/core/src/nav/nav-geometry.d.ts +100 -0
- package/dist/types/packages/core/src/nav/nested-canvas.d.ts +47 -4
- package/dist/types/packages/core/src/ops/cascade.d.ts +2 -1
- package/dist/types/packages/core/src/ops/claims.d.ts +6 -0
- package/dist/types/packages/core/src/ops/insert.d.ts +4 -0
- package/dist/types/packages/core/src/ops/point-pick.d.ts +4 -1
- package/dist/types/packages/core/src/ops/sibling-order.d.ts +14 -4
- package/dist/types/packages/core/src/ops/tray.d.ts +48 -0
- package/dist/types/packages/core/src/presence/presence-kit.d.ts +5 -0
- package/dist/types/packages/core/src/schema/meta.d.ts +10 -0
- package/dist/types/packages/core/src/schema/prefab.d.ts +8 -0
- package/dist/types/packages/core/src/settings/defaults.d.ts +25 -6
- package/dist/types/packages/core/src/surface/gpu-device.d.ts +55 -0
- package/dist/types/packages/core/src/systems/camera-sim.d.ts +29 -0
- package/dist/types/packages/core/src/systems/chrome.d.ts +15 -23
- package/dist/types/packages/core/src/systems/drag-mods.d.ts +34 -0
- package/dist/types/packages/core/src/systems/held.d.ts +71 -0
- package/dist/types/packages/core/src/systems/insert-ghost.d.ts +2 -0
- package/dist/types/packages/core/src/systems/l0-input.d.ts +14 -0
- package/dist/types/packages/core/src/systems/l1-pick.d.ts +37 -1
- package/dist/types/packages/core/src/systems/l2-arbitrate.d.ts +18 -4
- package/dist/types/packages/core/src/systems/l3-behave.d.ts +4 -1
- package/dist/types/packages/core/src/systems/l3-claim.d.ts +7 -0
- package/dist/types/packages/core/src/systems/l3-connect.d.ts +1 -1
- package/dist/types/packages/core/src/systems/l3-drop.d.ts +30 -1
- package/dist/types/packages/core/src/systems/l3-marquee.d.ts +2 -1
- package/dist/types/packages/core/src/systems/l3-ports.d.ts +1 -1
- package/dist/types/packages/core/src/systems/l4-cursor.d.ts +5 -0
- package/dist/types/packages/core/src/systems/nav-flight.d.ts +85 -3
- package/dist/types/packages/core/src/systems/nav-tap.d.ts +44 -0
- package/dist/types/packages/core/src/systems/press-wheel.d.ts +11 -0
- package/dist/types/packages/core/src/systems/tray.d.ts +108 -0
- package/dist/types/packages/core/src/systems/zoom-through.d.ts +30 -0
- package/dist/types/packages/core/src/tools/define-tool.d.ts +10 -0
- package/dist/types/packages/core/src/widget/define-widget.d.ts +166 -63
- package/dist/types/packages/core/src/widget/equip.d.ts +14 -2
- package/dist/types/packages/core/src/widget/held-tools.d.ts +83 -0
- package/dist/types/packages/core/src/widget/menu-actions.d.ts +44 -0
- package/dist/types/packages/core/src/widget/mount-store.d.ts +21 -46
- package/dist/types/packages/core/src/widget/spawn.d.ts +1 -1
- package/dist/types/packages/desk/src/assets/blue-noise.gen.d.ts +10 -0
- package/dist/types/packages/desk/src/card/card.d.ts +103 -0
- package/dist/types/packages/desk/src/compose/ambient.d.ts +59 -0
- package/dist/types/packages/desk/src/compose/builder.d.ts +285 -0
- package/dist/types/packages/desk/src/compose/children.d.ts +3 -0
- package/dist/types/packages/desk/src/compose/index.d.ts +14 -0
- package/dist/types/packages/desk/src/compose/marks.d.ts +126 -0
- package/dist/types/packages/desk/src/compose/pick.d.ts +5 -0
- package/dist/types/packages/desk/src/compose/reflector.d.ts +111 -0
- package/dist/types/packages/desk/src/compose/tap.d.ts +5 -0
- package/dist/types/packages/desk/src/docs.d.ts +23 -0
- package/dist/types/packages/desk/src/engine/budget.d.ts +38 -0
- package/dist/types/packages/desk/src/engine/device.d.ts +54 -0
- package/dist/types/packages/desk/src/engine/index.d.ts +5 -0
- package/dist/types/packages/desk/src/engine/pipeline.d.ts +36 -0
- package/dist/types/packages/desk/src/engine/rasters.d.ts +66 -0
- package/dist/types/packages/desk/src/engine/records.d.ts +56 -0
- package/dist/types/packages/desk/src/engine/shader.d.ts +22 -0
- package/dist/types/packages/desk/src/engine/struct.d.ts +39 -0
- package/dist/types/packages/desk/src/engine/target.d.ts +26 -0
- package/dist/types/packages/desk/src/gpu-ablation.d.ts +61 -0
- package/dist/types/packages/desk/src/gpu-memory.d.ts +54 -0
- package/dist/types/packages/desk/src/gpu-profiler.d.ts +141 -0
- package/dist/types/packages/desk/src/gpu-wrap.d.ts +8 -0
- package/dist/types/packages/desk/src/ground.d.ts +388 -0
- package/dist/types/packages/desk/src/hold/focus.d.ts +53 -0
- package/dist/types/packages/desk/src/hold/pose.d.ts +132 -0
- package/dist/types/packages/desk/src/hold/shaders.d.ts +9 -0
- package/dist/types/packages/desk/src/host/editor.d.ts +18 -0
- package/dist/types/packages/desk/src/host/index.d.ts +9 -0
- package/dist/types/packages/desk/src/host/ink.d.ts +18 -0
- package/dist/types/packages/desk/src/host/layer.d.ts +430 -0
- package/dist/types/packages/desk/src/host/picture.d.ts +2 -0
- package/dist/types/packages/desk/src/host/surface.d.ts +5 -0
- package/dist/types/packages/desk/src/index.d.ts +13 -0
- package/dist/types/packages/desk/src/kind.d.ts +187 -0
- package/dist/types/packages/desk/src/kinds/world.d.ts +429 -0
- package/dist/types/packages/desk/src/kit/arrays.d.ts +88 -0
- package/dist/types/packages/desk/src/kit/blobs.d.ts +40 -0
- package/dist/types/packages/desk/src/kit/book.d.ts +2 -0
- package/dist/types/packages/desk/src/kit/editor.d.ts +103 -0
- package/dist/types/packages/desk/src/kit/eye.d.ts +37 -0
- package/dist/types/packages/desk/src/kit/hold.d.ts +1 -0
- package/dist/types/packages/desk/src/kit/index.d.ts +26 -0
- package/dist/types/packages/desk/src/kit/inside.d.ts +116 -0
- package/dist/types/packages/desk/src/kit/layer.d.ts +159 -0
- package/dist/types/packages/desk/src/kit/light.d.ts +3 -0
- package/dist/types/packages/desk/src/kit/mesh.d.ts +29 -0
- package/dist/types/packages/desk/src/kit/mips.d.ts +2 -0
- package/dist/types/packages/desk/src/kit/nav.d.ts +2 -0
- package/dist/types/packages/desk/src/kit/paper-tex.d.ts +5 -0
- package/dist/types/packages/desk/src/kit/physics.d.ts +44 -0
- package/dist/types/packages/desk/src/kit/place.d.ts +44 -0
- package/dist/types/packages/desk/src/kit/print.d.ts +30 -0
- package/dist/types/packages/desk/src/kit/raster.d.ts +34 -0
- package/dist/types/packages/desk/src/kit/sdf.d.ts +1 -0
- package/dist/types/packages/desk/src/kit/seeds.d.ts +11 -0
- package/dist/types/packages/desk/src/kit/services.d.ts +34 -0
- package/dist/types/packages/desk/src/kit/springs.d.ts +12 -0
- package/dist/types/packages/desk/src/kit/strokes.d.ts +93 -0
- package/dist/types/packages/desk/src/kit/text.d.ts +142 -0
- package/dist/types/packages/desk/src/kit/uniform.d.ts +8 -0
- package/dist/types/packages/desk/src/kit/view.d.ts +39 -0
- package/dist/types/packages/desk/src/kit/wgsl.d.ts +15 -0
- package/dist/types/packages/desk/src/lattice/line.d.ts +15 -0
- package/dist/types/packages/desk/src/lattice/lod.d.ts +52 -0
- package/dist/types/packages/desk/src/lattice/ruler.d.ts +88 -0
- package/dist/types/packages/desk/src/marks/assemble.d.ts +65 -0
- package/dist/types/packages/desk/src/marks/ease.d.ts +4 -0
- package/dist/types/packages/desk/src/marks/laser.d.ts +41 -0
- package/dist/types/packages/desk/src/marks/layout.d.ts +167 -0
- package/dist/types/packages/desk/src/marks/pass.d.ts +59 -0
- package/dist/types/packages/desk/src/marks/shaders.d.ts +12 -0
- package/dist/types/packages/desk/src/mat/grid.d.ts +50 -0
- package/dist/types/packages/desk/src/mat/lamp.d.ts +14 -0
- package/dist/types/packages/desk/src/mat/layout.d.ts +144 -0
- package/dist/types/packages/desk/src/mat/mat-pass.d.ts +83 -0
- package/dist/types/packages/desk/src/mat/night.d.ts +95 -0
- package/dist/types/packages/desk/src/mat/projector.d.ts +39 -0
- package/dist/types/packages/desk/src/mat/shaders.d.ts +17 -0
- package/dist/types/packages/desk/src/mat/tilt.d.ts +14 -0
- package/dist/types/packages/desk/src/nav/flight.d.ts +186 -0
- package/dist/types/packages/desk/src/nav/portal.d.ts +95 -0
- package/dist/types/packages/desk/src/object.d.ts +46 -0
- package/dist/types/packages/desk/src/pass-instrument.d.ts +89 -0
- package/dist/types/packages/desk/src/shaders.d.ts +12 -0
- package/dist/types/packages/desk/src/shaders.gen.d.ts +16 -0
- package/dist/types/packages/desk/src/submit-instrument.d.ts +36 -0
- package/dist/types/packages/desk/src/theme.d.ts +475 -0
- package/dist/types/packages/desk/src/tray/carry.d.ts +99 -0
- package/dist/types/packages/desk/src/tray/drawer.d.ts +113 -0
- package/dist/types/packages/desk/src/tray/flux.d.ts +46 -0
- package/dist/types/packages/desk/src/tray/index.d.ts +4 -0
- package/dist/types/packages/desk/src/tray/lattice.d.ts +71 -0
- package/dist/types/packages/desk/src/tray/layout.d.ts +7 -0
- package/dist/types/packages/desk/src/tray/look.d.ts +29 -0
- package/dist/types/packages/desk/src/tray/pass.d.ts +96 -0
- package/dist/types/packages/desk/src/tray/shaders.d.ts +10 -0
- package/dist/types/packages/desk/src/tray/specimens.d.ts +199 -0
- package/dist/types/packages/devtools/src/attach.d.ts +22 -8
- package/dist/types/packages/devtools/src/dock.d.ts +18 -14
- package/dist/types/packages/devtools/src/gpu-panel.d.ts +105 -0
- package/dist/types/packages/devtools/src/index.d.ts +5 -4
- package/dist/types/packages/dom/src/desk-host.d.ts +91 -0
- package/dist/types/packages/dom/src/host.d.ts +13 -14
- package/dist/types/packages/dom/src/index.d.ts +12 -10
- package/dist/types/packages/dom/src/loop.d.ts +18 -1
- package/dist/types/packages/dom/src/pointer-adapter.d.ts +5 -29
- package/dist/types/packages/dom/src/widget-focus.d.ts +17 -13
- package/dist/types/packages/ice/src/desk-engine.d.ts +2 -0
- package/dist/types/packages/ice/src/desk-kit.d.ts +6 -0
- package/dist/types/packages/ice/src/desk-objects.d.ts +5 -0
- package/dist/types/packages/ice/src/desk.d.ts +5 -0
- package/dist/types/packages/kernel/src/atlas-pack.d.ts +157 -0
- package/dist/types/packages/kernel/src/bezier.d.ts +0 -15
- package/dist/types/packages/kernel/src/coords.d.ts +0 -39
- package/dist/types/packages/kernel/src/index.d.ts +2 -2
- package/dist/types/packages/kernel/src/nav-flight.d.ts +6 -0
- package/dist/types/packages/kernel/src/tray.d.ts +155 -0
- package/dist/types/packages/objects/src/board/board-pass.d.ts +180 -0
- package/dist/types/packages/objects/src/board/board-pen.d.ts +36 -0
- package/dist/types/packages/objects/src/board/board.d.ts +104 -0
- package/dist/types/packages/objects/src/board/data.d.ts +31 -0
- package/dist/types/packages/objects/src/board/history.d.ts +33 -0
- package/dist/types/packages/objects/src/board/kind.d.ts +208 -0
- package/dist/types/packages/objects/src/board/layout.d.ts +102 -0
- package/dist/types/packages/objects/src/board/object.d.ts +7 -0
- package/dist/types/packages/objects/src/board/pen.d.ts +71 -0
- package/dist/types/packages/objects/src/board/shaders.d.ts +36 -0
- package/dist/types/packages/objects/src/board/stroke.d.ts +99 -0
- package/dist/types/packages/objects/src/board/theme.d.ts +150 -0
- package/dist/types/packages/objects/src/calendar/data.d.ts +97 -0
- package/dist/types/packages/objects/src/calendar/events.d.ts +58 -0
- package/dist/types/packages/objects/src/calendar/hand.d.ts +53 -0
- package/dist/types/packages/objects/src/calendar/host/input.d.ts +67 -0
- package/dist/types/packages/objects/src/calendar/host/print.d.ts +9 -0
- package/dist/types/packages/objects/src/calendar/kind.d.ts +297 -0
- package/dist/types/packages/objects/src/calendar/law.d.ts +151 -0
- package/dist/types/packages/objects/src/calendar/layout.d.ts +47 -0
- package/dist/types/packages/objects/src/calendar/month.d.ts +75 -0
- package/dist/types/packages/objects/src/calendar/object.d.ts +45 -0
- package/dist/types/packages/objects/src/calendar/pad.d.ts +42 -0
- package/dist/types/packages/objects/src/calendar/pass.d.ts +229 -0
- package/dist/types/packages/objects/src/calendar/print.d.ts +87 -0
- package/dist/types/packages/objects/src/calendar/printing.d.ts +80 -0
- package/dist/types/packages/objects/src/calendar/roll.d.ts +45 -0
- package/dist/types/packages/objects/src/calendar/shaders.d.ts +12 -0
- package/dist/types/packages/objects/src/calendar/sheet.d.ts +43 -0
- package/dist/types/packages/objects/src/calendar/tiles.d.ts +67 -0
- package/dist/types/packages/objects/src/calendar/turn.d.ts +73 -0
- package/dist/types/packages/objects/src/calendar/writing.d.ts +42 -0
- package/dist/types/packages/objects/src/index.d.ts +22 -0
- package/dist/types/packages/objects/src/kinds.d.ts +24 -0
- package/dist/types/packages/objects/src/minimat/inside.d.ts +17 -0
- package/dist/types/packages/objects/src/minimat/kind.d.ts +51 -0
- package/dist/types/packages/objects/src/minimat/layout.d.ts +83 -0
- package/dist/types/packages/objects/src/minimat/minimat.d.ts +179 -0
- package/dist/types/packages/objects/src/minimat/object.d.ts +8 -0
- package/dist/types/packages/objects/src/minimat/pass.d.ts +61 -0
- package/dist/types/packages/objects/src/minimat/shaders.d.ts +10 -0
- package/dist/types/packages/objects/src/minimat/theme.d.ts +98 -0
- package/dist/types/packages/objects/src/notebook/ink.d.ts +70 -0
- package/dist/types/packages/objects/src/notebook/kind.d.ts +236 -0
- package/dist/types/packages/objects/src/notebook/law.d.ts +129 -0
- package/dist/types/packages/objects/src/notebook/layout.d.ts +46 -0
- package/dist/types/packages/objects/src/notebook/leaf.d.ts +44 -0
- package/dist/types/packages/objects/src/notebook/mesh.d.ts +20 -0
- package/dist/types/packages/objects/src/notebook/motion.d.ts +107 -0
- package/dist/types/packages/objects/src/notebook/object.d.ts +8 -0
- package/dist/types/packages/objects/src/notebook/pages.d.ts +56 -0
- package/dist/types/packages/objects/src/notebook/pass.d.ts +197 -0
- package/dist/types/packages/objects/src/notebook/pick.d.ts +30 -0
- package/dist/types/packages/objects/src/notebook/raster.d.ts +28 -0
- package/dist/types/packages/objects/src/notebook/shaders.d.ts +11 -0
- package/dist/types/packages/objects/src/notebook/shape.d.ts +155 -0
- package/dist/types/packages/objects/src/notebook/theme.d.ts +76 -0
- package/dist/types/packages/objects/src/palette.d.ts +577 -0
- package/dist/types/packages/objects/src/paper/host/body.d.ts +30 -0
- package/dist/types/packages/objects/src/paper/kind.d.ts +81 -0
- package/dist/types/packages/objects/src/paper/layout.d.ts +73 -0
- package/dist/types/packages/objects/src/paper/object.d.ts +31 -0
- package/dist/types/packages/objects/src/paper/pages.d.ts +43 -0
- package/dist/types/packages/objects/src/paper/paper-pass.d.ts +86 -0
- package/dist/types/packages/objects/src/paper/paper.d.ts +117 -0
- package/dist/types/packages/objects/src/paper/shaders.d.ts +18 -0
- package/dist/types/packages/objects/src/paper/theme.d.ts +58 -0
- package/dist/types/packages/objects/src/paper/typing.d.ts +51 -0
- package/dist/types/packages/objects/src/paper/writing.d.ts +161 -0
- package/dist/types/packages/objects/src/photo/carry.d.ts +33 -0
- package/dist/types/packages/objects/src/photo/kind.d.ts +136 -0
- package/dist/types/packages/objects/src/photo/layout.d.ts +39 -0
- package/dist/types/packages/objects/src/photo/object.d.ts +5 -0
- package/dist/types/packages/objects/src/photo/photo-pass.d.ts +104 -0
- package/dist/types/packages/objects/src/photo/photo.d.ts +262 -0
- package/dist/types/packages/objects/src/photo/pictures.d.ts +152 -0
- package/dist/types/packages/objects/src/photo/sample.d.ts +9 -0
- package/dist/types/packages/objects/src/photo/shaders.d.ts +18 -0
- package/dist/types/packages/objects/src/preset.d.ts +44 -0
- package/dist/types/packages/objects/src/shaders.d.ts +3 -0
- package/dist/types/packages/objects/src/shaders.gen.d.ts +21 -0
- package/dist/types/packages/react/src/canvas-hooks.d.ts +12 -0
- package/dist/types/packages/react/src/desk.d.ts +56 -0
- package/dist/types/packages/react/src/engine-context.d.ts +2 -2
- package/dist/types/packages/react/src/frame-preview-boundary.d.ts +19 -0
- package/dist/types/packages/react/src/hooks.d.ts +9 -14
- package/dist/types/packages/react/src/index.d.ts +16 -9
- package/dist/types/packages/react/src/keymap.d.ts +21 -2
- package/dist/types/packages/react/src/selection-menu.d.ts +171 -0
- package/dist/types/packages/react/src/tray-bar.d.ts +124 -0
- package/package.json +64 -31
- package/dist/chunk-5FQS7V2C.js.map +0 -1
- package/dist/chunk-JWRHAM7L.js +0 -1163
- package/dist/chunk-JWRHAM7L.js.map +0 -1
- package/dist/chunk-MFTMPJUF.js +0 -681
- package/dist/chunk-MFTMPJUF.js.map +0 -1
- package/dist/chunk-OR5FNVUE.js.map +0 -1
- package/dist/ground.js +0 -1213
- package/dist/ground.js.map +0 -1
- package/dist/r3f.js +0 -1644
- package/dist/r3f.js.map +0 -1
- package/dist/types/packages/core/src/input/measure-queue.d.ts +0 -30
- package/dist/types/packages/core/src/settings/ground-config.d.ts +0 -103
- package/dist/types/packages/core/src/systems/measure-ingest.d.ts +0 -26
- package/dist/types/packages/devtools/src/gl-panel.d.ts +0 -69
- package/dist/types/packages/dom/src/measure-adapter.d.ts +0 -31
- package/dist/types/packages/dom/src/measure-wiring.d.ts +0 -49
- package/dist/types/packages/dom/src/planes.d.ts +0 -33
- package/dist/types/packages/dom/src/reflectors/chrome.d.ts +0 -33
- package/dist/types/packages/dom/src/reflectors/dom-widgets.d.ts +0 -59
- package/dist/types/packages/dom/src/reflectors/graybox.d.ts +0 -31
- package/dist/types/packages/dom/src/reflectors/plane-transform.d.ts +0 -38
- package/dist/types/packages/ground/src/index.d.ts +0 -69
- package/dist/types/packages/ground/src/layer.d.ts +0 -40
- package/dist/types/packages/ground/src/pass.d.ts +0 -41
- package/dist/types/packages/ground/src/passes/grid-classic.d.ts +0 -30
- package/dist/types/packages/ground/src/passes/grid-magnet.d.ts +0 -31
- package/dist/types/packages/ground/src/passes/grid.d.ts +0 -28
- package/dist/types/packages/ground/src/passes/guides-collect.d.ts +0 -14
- package/dist/types/packages/ground/src/passes/guides.d.ts +0 -3
- package/dist/types/packages/ground/src/passes/magnet-collect.d.ts +0 -63
- package/dist/types/packages/ground/src/passes/soup-collect.d.ts +0 -35
- package/dist/types/packages/ground/src/passes/soup-mesh.d.ts +0 -8
- package/dist/types/packages/ground/src/passes/wires-collect.d.ts +0 -35
- package/dist/types/packages/ground/src/passes/wires.d.ts +0 -10
- package/dist/types/packages/ground/src/poles.d.ts +0 -47
- package/dist/types/packages/ground/src/renderer.d.ts +0 -15
- package/dist/types/packages/ice/src/ground.d.ts +0 -1
- package/dist/types/packages/ice/src/r3f.d.ts +0 -1
- package/dist/types/packages/kernel/src/eviction.d.ts +0 -23
- package/dist/types/packages/kernel/src/zoom-bands.d.ts +0 -19
- package/dist/types/packages/r3f/src/bridge.d.ts +0 -129
- package/dist/types/packages/r3f/src/composite-material.d.ts +0 -26
- package/dist/types/packages/r3f/src/compositor-pass.d.ts +0 -105
- package/dist/types/packages/r3f/src/dev-write-trap.d.ts +0 -30
- package/dist/types/packages/r3f/src/gl-root.d.ts +0 -96
- package/dist/types/packages/r3f/src/gl-router.d.ts +0 -70
- package/dist/types/packages/r3f/src/index.d.ts +0 -17
- package/dist/types/packages/r3f/src/island-state.d.ts +0 -112
- package/dist/types/packages/r3f/src/island.d.ts +0 -13
- package/dist/types/packages/r3f/src/pool.d.ts +0 -56
- package/dist/types/packages/r3f/src/preview-capture.d.ts +0 -19
- package/dist/types/packages/r3f/src/resource-registry.d.ts +0 -30
- package/dist/types/packages/r3f/src/self-sustain.d.ts +0 -39
- package/dist/types/packages/r3f/src/use-island-frame.d.ts +0 -39
- package/dist/types/packages/react/src/infinite-canvas.d.ts +0 -140
- package/dist/types/packages/react/src/preview-snapshots.d.ts +0 -17
- package/dist/types/packages/react/src/widget-preview.d.ts +0 -14
- package/dist/types/packages/react/src/widget-root.d.ts +0 -33
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../kernel/src/shapes.ts","../../kernel/src/coords.ts","../../kernel/src/snap.ts","../../kernel/src/spatial-index.ts","../../kernel/src/anchors.ts","../../kernel/src/bezier.ts","../../kernel/src/easing.ts","../../kernel/src/nav-flight.ts","../../kernel/src/layout.ts","../../kernel/src/tray.ts","../../kernel/src/atlas-pack.ts","../../kernel/src/index.ts"],"sourcesContent":["/** Plain geometric structs shared across the kernel. Ported from v1 `ecs/math.ts`. */\n\nexport interface Vec2 {\n x: number;\n y: number;\n}\n\nexport interface Rect {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface AABB {\n minX: number;\n minY: number;\n maxX: number;\n maxY: number;\n}\n\nexport function rectToAABB(r: Rect): AABB {\n return { minX: r.x, minY: r.y, maxX: r.x + r.width, maxY: r.y + r.height };\n}\n\nexport function aabbToRect(a: AABB): Rect {\n return { x: a.minX, y: a.minY, width: a.maxX - a.minX, height: a.maxY - a.minY };\n}\n\nexport function intersectsAABB(a: AABB, b: AABB): boolean {\n return a.maxX >= b.minX && a.minX <= b.maxX && a.maxY >= b.minY && a.minY <= b.maxY;\n}\n\nexport function pointInAABB(px: number, py: number, a: AABB): boolean {\n return px >= a.minX && px <= a.maxX && py >= a.minY && py <= a.maxY;\n}\n\nexport function clamp(value: number, min: number, max: number): number {\n return Math.max(min, Math.min(max, value));\n}\n","/**\n * THE coordinate seam (Law 13): every conversion between screen, world, and\n * island (widget-local GL) space lives here — including the ONE Y-flip.\n * v1 duplicated this math in three places; nothing outside this module may\n * re-derive it.\n *\n * Conventions:\n * - screen: CSS px, canvas-container-relative, Y-down. DPR never enters world\n * math (it exists only in GL uniforms / FBO sizing — see zoom-bands).\n * - world: world units, Y-down. `Camera.{x,y}` is the WORLD point at the\n * viewport's top-left; `zoom` is screen px per world unit.\n * - island: widget-local GL space — CENTER origin, Y-UP, world-unit scale.\n * (v1 VirtualWidget convention; the only Y-flip in the codebase.)\n */\nimport type { Rect, Vec2 } from \"./shapes\";\n\nexport interface CameraState {\n x: number;\n y: number;\n zoom: number;\n}\n\nexport function screenToWorld(screenX: number, screenY: number, camera: CameraState): Vec2 {\n return {\n x: screenX / camera.zoom + camera.x,\n y: screenY / camera.zoom + camera.y,\n };\n}\n\nexport function worldToScreen(worldX: number, worldY: number, camera: CameraState): Vec2 {\n return {\n x: (worldX - camera.x) * camera.zoom,\n y: (worldY - camera.y) * camera.zoom,\n };\n}\n\n/**\n * Zoom about a fixed screen point (v1 `zoomAtPoint`): the world point under\n * `(screenX, screenY)` stays under it after the zoom change.\n * Returns the new camera (does not mutate). Clamping is the caller's policy.\n */\nexport function zoomAtPoint(\n camera: CameraState,\n screenX: number,\n screenY: number,\n newZoom: number,\n): CameraState {\n const anchor = screenToWorld(screenX, screenY, camera);\n return {\n x: anchor.x - screenX / newZoom,\n y: anchor.y - screenY / newZoom,\n zoom: newZoom,\n };\n}\n\n/**\n * The DEFAULT framing camera (2026-07-18, James: \"do zoom to fit, but with a\n * upper and bottom cap … should feel natural\"): zoom-to-fit `content` (a\n * world-space bbox) with `pad` px of breathing room on every side, zoom\n * clamped into [minZoom, maxZoom] — the natural band: never so far in that\n * one small card fills the screen, never so far out that the board turns\n * into an ant farm. The content CENTER stays centered whether or not a cap\n * engages. Callers own the band policy (engine default: FIT_DEFAULTS ∩ the\n * session's hard CameraLimits) and must pass a real viewport.\n */\nexport function fitCamera(\n content: Rect,\n vpW: number,\n vpH: number,\n opts: { pad: number; minZoom: number; maxZoom: number },\n): CameraState {\n const fit = Math.min(vpW / (content.width + opts.pad * 2), vpH / (content.height + opts.pad * 2));\n const zoom = Math.min(opts.maxZoom, Math.max(opts.minZoom, fit));\n return {\n x: content.x + content.width / 2 - vpW / (2 * zoom),\n y: content.y + content.height / 2 - vpH / (2 * zoom),\n zoom,\n };\n}\n\n// (`planeCssTransform` — the per-plane CSS transform of the retired DOM/GL planes — left at design-015 D7: the DOM\n// lives in screen space, and no element carries a camera transform, §2.2.)\n","/**\n * Snap guide computation (Figma-style), ported verbatim from v1\n * `ecs/spatial/snap.ts` (audited CLEAN-PORT):\n * Phase 1 — edge/center alignment (7 X + 7 Y candidate pairs per reference,\n * per-axis nearest-wins, ties within 0.01 accumulate guides)\n * Phase 2 — equal spacing (between-two-neighbors midpoint; extend-a-pattern),\n * same-perpendicular-band filter\n * Merge — alignment takes priority per axis; equal spacing fills the other;\n * indicators recomputed post-snap at threshold × 0.5.\n * Pure function over plain bounds. Candidate GATHERING (spatial index, tags,\n * Active scoping) is the caller's job — design-003 §5.2/§6.\n */\n\nexport interface SnapGuide {\n axis: \"x\" | \"y\";\n /** World-space coordinate of the alignment line */\n position: number;\n type: \"edge\" | \"center\";\n}\n\nexport interface EqualSpacingIndicator {\n axis: \"x\" | \"y\";\n /** The equal gap value (world units) */\n gap: number;\n /** Pairs of (from, to) marking each equal gap segment */\n segments: { from: number; to: number }[];\n /** Position on the perpendicular axis (for rendering) */\n perpPosition: number;\n}\n\nexport interface SnapResult {\n /** Snap-corrected delta (world units). Apply to entity position. */\n snapDx: number;\n snapDy: number;\n guides: SnapGuide[];\n spacings: EqualSpacingIndicator[];\n}\n\nexport interface EntityBounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport function computeSnapGuides(\n dragged: EntityBounds,\n references: EntityBounds[],\n threshold: number,\n): SnapResult {\n const guides: SnapGuide[] = [];\n const spacings: EqualSpacingIndicator[] = [];\n let snapDx = 0;\n let snapDy = 0;\n\n const dLeft = dragged.x;\n const dRight = dragged.x + dragged.width;\n const dCenterX = dragged.x + dragged.width / 2;\n const dTop = dragged.y;\n const dBottom = dragged.y + dragged.height;\n const dCenterY = dragged.y + dragged.height / 2;\n\n let bestSnapX = Number.POSITIVE_INFINITY;\n let bestSnapY = Number.POSITIVE_INFINITY;\n let bestDx = 0;\n let bestDy = 0;\n const xGuides: SnapGuide[] = [];\n const yGuides: SnapGuide[] = [];\n\n // --- Phase 1: edge/center alignment ---\n for (const ref of references) {\n const rLeft = ref.x;\n const rRight = ref.x + ref.width;\n const rCenterX = ref.x + ref.width / 2;\n const rTop = ref.y;\n const rBottom = ref.y + ref.height;\n const rCenterY = ref.y + ref.height / 2;\n\n const xPairs: [number, number, \"edge\" | \"center\"][] = [\n [dLeft, rLeft, \"edge\"],\n [dLeft, rRight, \"edge\"],\n [dRight, rLeft, \"edge\"],\n [dRight, rRight, \"edge\"],\n [dCenterX, rCenterX, \"center\"],\n [dLeft, rCenterX, \"edge\"],\n [dRight, rCenterX, \"edge\"],\n ];\n for (const [dVal, rVal, type] of xPairs) {\n const dist = Math.abs(dVal - rVal);\n if (dist <= threshold) {\n const dx = rVal - dVal;\n if (dist < bestSnapX) {\n bestSnapX = dist;\n bestDx = dx;\n xGuides.length = 0;\n }\n if (dist <= bestSnapX + 0.01) {\n xGuides.push({ axis: \"x\", position: rVal, type });\n }\n }\n }\n\n const yPairs: [number, number, \"edge\" | \"center\"][] = [\n [dTop, rTop, \"edge\"],\n [dTop, rBottom, \"edge\"],\n [dBottom, rTop, \"edge\"],\n [dBottom, rBottom, \"edge\"],\n [dCenterY, rCenterY, \"center\"],\n [dTop, rCenterY, \"edge\"],\n [dBottom, rCenterY, \"edge\"],\n ];\n for (const [dVal, rVal, type] of yPairs) {\n const dist = Math.abs(dVal - rVal);\n if (dist <= threshold) {\n const dy = rVal - dVal;\n if (dist < bestSnapY) {\n bestSnapY = dist;\n bestDy = dy;\n yGuides.length = 0;\n }\n if (dist <= bestSnapY + 0.01) {\n yGuides.push({ axis: \"y\", position: rVal, type });\n }\n }\n }\n }\n\n // --- Phase 2: equal spacing ---\n const eqResult = computeEqualSpacing(dragged, references, threshold);\n\n // Merge: alignment snap takes priority; equal spacing fills the other axis.\n if (bestSnapX <= threshold) {\n snapDx = bestDx;\n } else if (eqResult.snapDx !== undefined) {\n snapDx = eqResult.snapDx;\n }\n if (bestSnapY <= threshold) {\n snapDy = bestDy;\n } else if (eqResult.snapDy !== undefined) {\n snapDy = eqResult.snapDy;\n }\n\n if (bestSnapX <= threshold) {\n const seen = new Set<number>();\n for (const g of xGuides) {\n if (!seen.has(g.position)) {\n seen.add(g.position);\n guides.push(g);\n }\n }\n }\n if (bestSnapY <= threshold) {\n const seen = new Set<number>();\n for (const g of yGuides) {\n if (!seen.has(g.position)) {\n seen.add(g.position);\n guides.push(g);\n }\n }\n }\n\n // Indicators recomputed against the SNAPPED bounds at half threshold.\n const snappedBounds: EntityBounds = {\n x: dragged.x + snapDx,\n y: dragged.y + snapDy,\n width: dragged.width,\n height: dragged.height,\n };\n const eqFinal = computeEqualSpacing(snappedBounds, references, threshold * 0.5);\n spacings.push(...eqFinal.indicators);\n\n return { snapDx, snapDy, guides, spacings };\n}\n\ninterface EqualSpacingResult {\n snapDx: number | undefined;\n snapDy: number | undefined;\n indicators: EqualSpacingIndicator[];\n}\n\nfunction computeEqualSpacing(\n dragged: EntityBounds,\n references: EntityBounds[],\n threshold: number,\n): EqualSpacingResult {\n const indicators: EqualSpacingIndicator[] = [];\n let snapDx: number | undefined;\n let snapDy: number | undefined;\n\n const xResult = checkAxisSpacing(dragged, references, threshold, \"x\");\n if (xResult) {\n snapDx = xResult.snap;\n indicators.push(...xResult.indicators);\n }\n const yResult = checkAxisSpacing(dragged, references, threshold, \"y\");\n if (yResult) {\n snapDy = yResult.snap;\n indicators.push(...yResult.indicators);\n }\n return { snapDx, snapDy, indicators };\n}\n\nfunction checkAxisSpacing(\n dragged: EntityBounds,\n references: EntityBounds[],\n threshold: number,\n axis: \"x\" | \"y\",\n): { snap: number; indicators: EqualSpacingIndicator[] } | null {\n const isX = axis === \"x\";\n const pos = (b: EntityBounds) => (isX ? b.x : b.y);\n const size = (b: EntityBounds) => (isX ? b.width : b.height);\n const perpPos = (b: EntityBounds) => (isX ? b.y : b.x);\n const perpSize = (b: EntityBounds) => (isX ? b.height : b.width);\n const end = (b: EntityBounds) => pos(b) + size(b);\n\n // Same-perpendicular-band filter.\n const neighbors = references.filter(\n (ref) =>\n perpPos(ref) < perpPos(dragged) + perpSize(dragged) &&\n perpPos(ref) + perpSize(ref) > perpPos(dragged),\n );\n if (neighbors.length < 1) return null;\n\n const sorted = [...neighbors].sort((a, b) => pos(a) - pos(b));\n\n // Existing gaps between consecutive references.\n const refGaps: { from: EntityBounds; to: EntityBounds; gap: number }[] = [];\n for (let i = 0; i < sorted.length - 1; i++) {\n const a = sorted[i];\n const b = sorted[i + 1];\n if (a === undefined || b === undefined) continue;\n const gap = pos(b) - end(a);\n if (gap > 0.1) refGaps.push({ from: a, to: b, gap });\n }\n\n let bestSnap: number | null = null;\n let bestIndicators: EqualSpacingIndicator[] = [];\n let bestDiff = Number.POSITIVE_INFINITY;\n\n // Case 1: between two neighbors — equalize left/right gaps.\n let leftN: EntityBounds | null = null;\n let rightN: EntityBounds | null = null;\n for (const ref of sorted) {\n if (end(ref) <= pos(dragged) + threshold) {\n if (!leftN || end(ref) > end(leftN)) leftN = ref;\n }\n if (pos(ref) >= end(dragged) - threshold) {\n if (!rightN || pos(ref) < pos(rightN)) rightN = ref;\n }\n }\n if (leftN && rightN) {\n const lGap = pos(dragged) - end(leftN);\n const rGap = pos(rightN) - end(dragged);\n const diff = Math.abs(lGap - rGap);\n if (diff <= threshold && diff < bestDiff) {\n const idealPos = (end(leftN) + pos(rightN) - size(dragged)) / 2;\n const snap = idealPos - pos(dragged);\n const equalGap = (pos(rightN) - end(leftN) - size(dragged)) / 2;\n if (equalGap > 0.1) {\n const perpY = computePerpCenter(dragged, [leftN, rightN], isX);\n bestSnap = snap;\n bestDiff = diff;\n bestIndicators = [\n {\n axis,\n gap: equalGap,\n segments: [\n { from: end(leftN), to: idealPos },\n { from: idealPos + size(dragged), to: pos(rightN) },\n ],\n perpPosition: perpY,\n },\n ];\n }\n }\n }\n\n // Case 2: extend an existing gap pattern (append right / prepend left).\n for (const refGap of refGaps) {\n const patternGap = refGap.gap;\n\n if (rightN === null || pos(refGap.to) >= end(dragged) - threshold * 2) {\n const chainEnd = refGap.to;\n const dragGap = pos(dragged) - end(chainEnd);\n const diff = Math.abs(dragGap - patternGap);\n if (diff <= threshold && diff < bestDiff) {\n const idealPos = end(chainEnd) + patternGap;\n const snap = idealPos - pos(dragged);\n const perpY = computePerpCenter(dragged, [refGap.from, refGap.to], isX);\n bestSnap = snap;\n bestDiff = diff;\n bestIndicators = [\n {\n axis,\n gap: patternGap,\n segments: [\n { from: end(refGap.from), to: pos(refGap.to) },\n { from: end(chainEnd), to: idealPos },\n ],\n perpPosition: perpY,\n },\n ];\n }\n }\n\n if (leftN === null || end(refGap.from) <= pos(dragged) + threshold * 2) {\n const chainStart = refGap.from;\n const dragGap = pos(chainStart) - end(dragged);\n const diff = Math.abs(dragGap - patternGap);\n if (diff <= threshold && diff < bestDiff) {\n const idealPos = pos(chainStart) - patternGap - size(dragged);\n const snap = idealPos - pos(dragged);\n const perpY = computePerpCenter(dragged, [refGap.from, refGap.to], isX);\n bestSnap = snap;\n bestDiff = diff;\n bestIndicators = [\n {\n axis,\n gap: patternGap,\n segments: [\n { from: idealPos + size(dragged), to: pos(chainStart) },\n { from: end(refGap.from), to: pos(refGap.to) },\n ],\n perpPosition: perpY,\n },\n ];\n }\n }\n }\n\n if (bestSnap !== null) return { snap: bestSnap, indicators: bestIndicators };\n return null;\n}\n\nfunction computePerpCenter(dragged: EntityBounds, refs: EntityBounds[], isX: boolean): number {\n const perpPos = (b: EntityBounds) => (isX ? b.y : b.x);\n const perpSize = (b: EntityBounds) => (isX ? b.height : b.width);\n const allBounds = [dragged, ...refs];\n const maxStart = Math.max(...allBounds.map(perpPos));\n const minEnd = Math.min(...allBounds.map((b) => perpPos(b) + perpSize(b)));\n if (minEnd < maxStart) {\n return perpPos(dragged) + perpSize(dragged) / 2;\n }\n return maxStart + (minEnd - maxStart) / 2;\n}\n","/**\n * Spatial index backed by an R-tree (rbush) — ported from v1 (audited CLEAN-PORT).\n * World-space AABBs for culling, hit-testing, and snap-candidate gathering\n * (Law 15: the ONLY hit path). The id↔entry map gives O(log n) removal by\n * passing rbush the exact stored reference (v1 \"Fix #8\").\n *\n * `rbush` is the kernel's single, named dependency exception: a zero-dep pure\n * data structure (see .dependency-cruiser.cjs).\n */\nimport RBushImport from \"rbush\";\nimport type { AABB } from \"./shapes\";\n\n// CJS/ESM interop — rbush exports differently depending on context (kept from v1).\ntype RBushModule = typeof RBushImport & { default?: typeof RBushImport };\nconst rbushModule = RBushImport as RBushModule;\nconst RBush = (\n typeof rbushModule.default === \"function\" ? rbushModule.default : RBushImport\n) as typeof RBushImport;\n\nexport interface SpatialEntry<Id> extends AABB {\n id: Id;\n}\n\nexport class SpatialIndex<Id> {\n private tree = new RBush<SpatialEntry<Id>>();\n private entries = new Map<Id, SpatialEntry<Id>>();\n\n upsert(id: Id, bounds: AABB): void {\n const existing = this.entries.get(id);\n if (existing) this.tree.remove(existing);\n const entry: SpatialEntry<Id> = { ...bounds, id };\n this.entries.set(id, entry);\n this.tree.insert(entry);\n }\n\n remove(id: Id): void {\n const existing = this.entries.get(id);\n if (existing) {\n this.tree.remove(existing);\n this.entries.delete(id);\n }\n }\n\n /** All entries intersecting the given AABB. */\n search(bounds: AABB): SpatialEntry<Id>[] {\n return this.tree.search(bounds);\n }\n\n /** Entries within `tolerance` of a point (z-priority is the caller's job). */\n searchPoint(x: number, y: number, tolerance = 0): SpatialEntry<Id>[] {\n return this.tree.search({\n minX: x - tolerance,\n minY: y - tolerance,\n maxX: x + tolerance,\n maxY: y + tolerance,\n });\n }\n\n clear(): void {\n this.tree.clear();\n this.entries.clear();\n }\n\n get size(): number {\n return this.entries.size;\n }\n}\n","/**\n * Port-anchor math (design-001 §5.3): wire geometry NEVER reads port entities —\n * anchors are pure functions over the widget rect + the port declaration, so\n * culled endpoints work by construction.\n */\nimport type { Rect, Vec2 } from \"./shapes\";\n\nexport type PortSide = \"n\" | \"e\" | \"s\" | \"w\";\n\nexport interface PortSlot {\n side: PortSide;\n /** 0-based position among the ports sharing this side. */\n index: number;\n /** Total ports on this side. */\n count: number;\n}\n\n/** World-space anchor point: ports distribute evenly along their side. */\nexport function portAnchor(widget: Rect, slot: PortSlot): Vec2 {\n const f = (slot.index + 1) / (slot.count + 1);\n switch (slot.side) {\n case \"n\":\n return { x: widget.x + widget.width * f, y: widget.y };\n case \"s\":\n return { x: widget.x + widget.width * f, y: widget.y + widget.height };\n case \"w\":\n return { x: widget.x, y: widget.y + widget.height * f };\n case \"e\":\n return { x: widget.x + widget.width, y: widget.y + widget.height * f };\n }\n}\n\n/** Outward unit direction of a side (wire tangent stubs, Y-down world). */\nexport function sideDirection(side: PortSide): Vec2 {\n switch (side) {\n case \"n\":\n return { x: 0, y: -1 };\n case \"s\":\n return { x: 0, y: 1 };\n case \"w\":\n return { x: -1, y: 0 };\n case \"e\":\n return { x: 1, y: 0 };\n }\n}\n","/**\n * Cubic-bezier wire geometry: construction from port anchors, conservative\n * AABB (for the spatial index), and sampled distance (for picking — wires rank\n * below widgets, design-003 §3).\n */\nimport { sideDirection, type PortSide } from \"./anchors\";\nimport type { AABB, Vec2 } from \"./shapes\";\n\nexport interface Cubic {\n x0: number;\n y0: number;\n x1: number;\n y1: number;\n x2: number;\n y2: number;\n x3: number;\n y3: number;\n}\n\n/**\n * Wire curve between two anchors: tangent stubs leave each port along its\n * side's outward direction, scaled with distance (min stub keeps short wires\n * readable).\n */\nexport function wireCubic(\n from: Vec2,\n fromSide: PortSide,\n to: Vec2,\n toSide: PortSide,\n stubScale = 0.4,\n minStub = 24,\n): Cubic {\n const dist = Math.hypot(to.x - from.x, to.y - from.y);\n const stub = Math.max(minStub, dist * stubScale);\n const df = sideDirection(fromSide);\n const dt = sideDirection(toSide);\n return {\n x0: from.x,\n y0: from.y,\n x1: from.x + df.x * stub,\n y1: from.y + df.y * stub,\n x2: to.x + dt.x * stub,\n y2: to.y + dt.y * stub,\n x3: to.x,\n y3: to.y,\n };\n}\n\n/** Point on the curve at t ∈ [0, 1] (Bernstein form). */\nexport function cubicPoint(c: Cubic, t: number): Vec2 {\n const u = 1 - t;\n const b0 = u * u * u;\n const b1 = 3 * u * u * t;\n const b2 = 3 * u * t * t;\n const b3 = t * t * t;\n return {\n x: b0 * c.x0 + b1 * c.x1 + b2 * c.x2 + b3 * c.x3,\n y: b0 * c.y0 + b1 * c.y1 + b2 * c.y2 + b3 * c.y3,\n };\n}\n\n/**\n * Conservative bounds: the control-point hull contains the curve (convex-hull\n * property). Cheap and index-friendly; exact extrema are unnecessary for\n * culling/picking prefilters.\n */\nexport function cubicAABB(c: Cubic): AABB {\n return {\n minX: Math.min(c.x0, c.x1, c.x2, c.x3),\n minY: Math.min(c.y0, c.y1, c.y2, c.y3),\n maxX: Math.max(c.x0, c.x1, c.x2, c.x3),\n maxY: Math.max(c.y0, c.y1, c.y2, c.y3),\n };\n}\n\n// (`tessellateCubic` and its `Tessellation` — the retired @ice/ground wires pass's adaptive flattening — left at\n// design-015 D7: nothing had read them since D5b.)\n\n/** Distance from a point to a line segment. */\nexport function distanceToSegment(\n px: number,\n py: number,\n ax: number,\n ay: number,\n bx: number,\n by: number,\n): number {\n const dx = bx - ax;\n const dy = by - ay;\n const lenSq = dx * dx + dy * dy;\n let t = 0;\n if (lenSq > 0) {\n t = ((px - ax) * dx + (py - ay) * dy) / lenSq;\n t = Math.max(0, Math.min(1, t));\n }\n const cx = ax + t * dx;\n const cy = ay + t * dy;\n return Math.hypot(px - cx, py - cy);\n}\n\n/**\n * Min distance from a point to the curve via polyline sampling. 32 samples is\n * ample for hit thresholds of a few px; error shrinks with curve flatness.\n */\nexport function distanceToCubic(px: number, py: number, c: Cubic, samples = 32): number {\n let best = Number.POSITIVE_INFINITY;\n let prev = cubicPoint(c, 0);\n for (let i = 1; i <= samples; i++) {\n const cur = cubicPoint(c, i / samples);\n const d = distanceToSegment(px, py, prev.x, prev.y, cur.x, cur.y);\n if (d < best) best = d;\n prev = cur;\n }\n return best;\n}\n","/**\n * CSS-style cubic-bezier timing functions (pure math — kernel).\n *\n * `cubicBezierEase(x1, y1, x2, y2)` builds f(t): the exact curve CSS\n * `transition-timing-function: cubic-bezier(…)` runs, so GL surfaces can\n * match DOM transitions beat-for-beat (the composite-quad lift mirrors the\n * DOM card lift's spring, cubic-bezier(0.2, 0.9, 0.3, 1.2)). y outside [0,1]\n * (overshoot springs) is legal and expected; x1/x2 are clamped to [0,1] per\n * spec so x(u) stays monotone and invertible.\n */\n\n/** Bernstein sample with P0=0, P3=1 (one axis of the timing curve). */\nfunction sample(u: number, p1: number, p2: number): number {\n const v = 1 - u;\n return 3 * v * v * u * p1 + 3 * v * u * u * p2 + u * u * u;\n}\n\nexport function cubicBezierEase(x1: number, y1: number, x2: number, y2: number): (t: number) => number {\n const cx1 = Math.min(1, Math.max(0, x1));\n const cx2 = Math.min(1, Math.max(0, x2));\n const sampleDx = (u: number): number => {\n const v = 1 - u;\n return 3 * v * v * cx1 + 6 * v * u * (cx2 - cx1) + 3 * u * u * (1 - cx2);\n };\n\n return (t: number): number => {\n if (t <= 0) return 0;\n if (t >= 1) return 1;\n // Solve x(u) = t: Newton first (fast for well-behaved curves)…\n let u = t;\n for (let i = 0; i < 8; i++) {\n const err = sample(u, cx1, cx2) - t;\n if (Math.abs(err) < 1e-6) return sample(u, y1, y2);\n const d = sampleDx(u);\n if (d < 1e-6) break; // flat spot — Newton would explode\n u = Math.min(1, Math.max(0, u - err / d));\n }\n // …bisection fallback (x is monotone under the clamp).\n let lo = 0;\n let hi = 1;\n u = t;\n while (hi - lo > 1e-6) {\n if (sample(u, cx1, cx2) < t) lo = u;\n else hi = u;\n u = (lo + hi) / 2;\n }\n return sample(u, y1, y2);\n };\n}\n","/**\n * Nav-flight math (design-006 §2/§4 — the portal zoom, T1 camera-flight half).\n *\n * Pure math, no ECS/DOM. Conventions are coords.ts's (Law 13): camera {x,y} =\n * world point at the viewport top-left, zoom = screen px per world unit,\n * `screen = (world − cam)·zoom`.\n *\n * The portal embedding: a container's content coordinates are FRAME-LOCAL\n * (design-001 §5.1) — the transition DEFINES the embedding by mapping the\n * arrival camera's visible rect onto the container's body rect (`portalAffine`,\n * aspect-fit, centers aligned). With that affine fixed, both transition layers\n * ride ONE camera: the destination frame renders under `c(t)` directly; the\n * departed frame renders under `c(t) ∘ A` where A maps departed-frame coords\n * into destination-frame coords. Continuity at the cut is exact by\n * construction (`solveFlightStart`), and no drift is possible mid-flight —\n * there is no second clock.\n *\n * Numerics locked by the mock (2026-07-15, three rounds of field testing):\n * - the progress spring uses the CLOSED-FORM critically-damped solution —\n * semi-implicit Euler diverges once ω·dt nears 1 (a fast exit response on\n * one dropped frame sent the mock's camera to zoom 1501);\n * - the path interpolates zoom in LOG space (constant perceived zoom\n * velocity — van Wijk & Nuij) with the view center linear in 1/zoom, which\n * is exactly an anchored zoom whenever a fixed screen point exists;\n * - flights beyond `maxOctaves` must be depth-capped (`capFlightStart`):\n * sweeping a DOM plane's raster scale ~30× in one flight outruns\n * Chromium's async tile re-raster (stale/missing tiles, persisting at\n * rest) — the capped flight is presented as a crossfade-through-zoom.\n */\nimport type { CameraState } from \"./coords\";\nimport type { Rect } from \"./shapes\";\n\n/** Uniform scale + translate: `A(q) = o + q·s`. */\nexport interface PortalAffine {\n readonly s: number;\n readonly ox: number;\n readonly oy: number;\n}\n\n/** The world rect a camera shows through a viewport. */\nexport function visibleRect(cam: CameraState, vpW: number, vpH: number): Rect {\n return { x: cam.x, y: cam.y, width: vpW / cam.zoom, height: vpH / cam.zoom };\n}\n\n/**\n * The portal embedding: map `arrival` (the world rect the arrival camera will\n * show, in the CHILD frame's coords) onto `portal` (the container's body rect,\n * in the PARENT frame's coords). Aspect-FIT with centers aligned (design-006\n * §8.3 — the card chrome absorbs the letterbox).\n */\nexport function portalAffine(arrival: Rect, portal: Rect): PortalAffine {\n const s = Math.min(portal.width / arrival.width, portal.height / arrival.height);\n return {\n s,\n ox: portal.x + portal.width / 2 - (arrival.x + arrival.width / 2) * s,\n oy: portal.y + portal.height / 2 - (arrival.y + arrival.height / 2) * s,\n };\n}\n\nexport function invertAffine(a: PortalAffine): PortalAffine {\n return { s: 1 / a.s, ox: -a.ox / a.s, oy: -a.oy / a.s };\n}\n\n/** `(outer ∘ inner)(q) = outer(inner(q))` — for multi-level exit portals. */\nexport function composeAffine(outer: PortalAffine, inner: PortalAffine): PortalAffine {\n return { s: outer.s * inner.s, ox: outer.ox + inner.ox * outer.s, oy: outer.oy + inner.oy * outer.s };\n}\n\n/**\n * Continuity solve: the camera `c0` (in the DESTINATION frame) under which\n * departed-frame content mapped through `A` (departed → destination coords)\n * renders EXACTLY as it did under `camPre` (in the departed frame) the instant\n * before the cut. Derivation: a departed point q renders at\n * `(A(q) − c0)·z0 = q·(A.s·z0) + (A.o − c0)·z0`; matching `(q − camPre)·zPre`\n * coefficient-wise gives z0 and the origin below. Zoom limits deliberately do\n * NOT apply here — flight paths transit far outside the user-gesture band\n * (design-006 §3.1); only the ARRIVAL camera is clamped by the caller.\n */\nexport function solveFlightStart(A: PortalAffine, camPre: CameraState): CameraState {\n return {\n x: A.ox + camPre.x * A.s,\n y: A.oy + camPre.y * A.s,\n zoom: camPre.zoom / A.s,\n };\n}\n\n/**\n * Destination camera expressed in departed-frame coordinates. Rendering a\n * procedural outgoing program with this camera is pixel-equivalent to first\n * mapping its points through A and then rendering under `destination`.\n */\nexport function outgoingCamera(A: PortalAffine, destination: CameraState): CameraState {\n return {\n x: (destination.x - A.ox) / A.s,\n y: (destination.y - A.oy) / A.s,\n zoom: A.s * destination.zoom,\n };\n}\n\n/** Zoom distance in octaves — the flight-length measure (design-006 §4/§5). */\nexport function flightOctaves(from: CameraState, to: CameraState): number {\n return Math.abs(Math.log2(to.zoom / from.zoom));\n}\n\n/**\n * Depth-cap a flight start (design-006 §5): beyond `maxOctaves`, clamp the\n * start zoom to `capFactor ×` the arrival zoom (dive direction preserved),\n * keeping the exact start's view CENTER — the portal anchor — so the motion\n * still comes from/goes to the right place. `capped: true` means the caller\n * must present the flight as a crossfade (frozen departing cover + incoming\n * fade-in): geometric continuity is unpresentable at that raster-scale swing.\n */\nexport function capFlightStart(\n exact: CameraState,\n arrival: CameraState,\n vpW: number,\n vpH: number,\n maxOctaves: number,\n capFactor: number,\n): { c0: CameraState; capped: boolean } {\n if (flightOctaves(exact, arrival) <= maxOctaves) return { c0: exact, capped: false };\n const zCap = exact.zoom > arrival.zoom ? arrival.zoom * capFactor : arrival.zoom / capFactor;\n return {\n c0: {\n x: exact.x + (vpW / 2) * (1 / exact.zoom - 1 / zCap),\n y: exact.y + (vpH / 2) * (1 / exact.zoom - 1 / zCap),\n zoom: zCap,\n },\n capped: true,\n };\n}\n\n/**\n * The flight path `c(p)`, p ∈ [0,1]: zoom log-lerped (constant perceived zoom\n * velocity); view CENTER linear in 1/zoom — exactly an anchored zoom whenever\n * a fixed screen point exists between the endpoints, a graceful blend\n * otherwise. Endpoints are exact: c(0) = c0, c(1) = c1.\n */\nexport function flightCamera(\n c0: CameraState,\n c1: CameraState,\n p: number,\n vpW: number,\n vpH: number,\n): CameraState {\n const zoom = Math.exp(Math.log(c0.zoom) + (Math.log(c1.zoom) - Math.log(c0.zoom)) * p);\n const inv0 = 1 / c0.zoom;\n const inv1 = 1 / c1.zoom;\n const inv = 1 / zoom;\n // Equal zooms (numerically) take the linear blend: the anchored form divides by\n // inv1 − inv0. The test is RELATIVE (design-015 D2a-core, the desk's 1e-8…1e8\n // zoom): the exp/log round trip leaves ~|ln z|·2⁻⁵² of relative error in 1/zoom,\n // and the old ABSOLUTE 1e-12 only swallowed that near zoom 1 — at zoom 1e-8, two\n // zooms 3 ulps apart put w at ±4 and the view centre 4× past its endpoints.\n const w = Math.abs(inv1 - inv0) <= 1e-9 * Math.max(inv0, inv1) ? p : (inv - inv0) / (inv1 - inv0);\n const cx = c0.x + vpW * inv0 * 0.5 + (c1.x + vpW * inv1 * 0.5 - (c0.x + vpW * inv0 * 0.5)) * w;\n const cy = c0.y + vpH * inv0 * 0.5 + (c1.y + vpH * inv1 * 0.5 - (c0.y + vpH * inv0 * 0.5)) * w;\n return { x: cx - vpW * inv * 0.5, y: cy - vpH * inv * 0.5, zoom };\n}\n\n/**\n * One step of the critically-damped progress spring toward 1, in CLOSED FORM:\n * with u = 1 − p, the exact solution is `u(t) = (u₀ + Bt)·e^(−ωt)`,\n * `B = −v₀ + ω·u₀`. Unconditionally stable at ANY dt — the discretized form\n * (semi-implicit Euler) diverges once ω·dt approaches 1, which one dropped\n * frame at a fast response reaches easily (mock-measured, 2026-07-15).\n * From rest (v=0) the approach is monotonic: p never overshoots 1.\n */\nexport function springStep(\n p: number,\n v: number,\n omega: number,\n dtSec: number,\n): { p: number; v: number } {\n const u = 1 - p;\n const B = -v + omega * u;\n const decay = Math.exp(-omega * dtSec);\n const u2 = (u + B * dtSec) * decay;\n const du2 = (B - omega * (u + B * dtSec)) * decay;\n return { p: 1 - u2, v: -du2 };\n}\n","/**\n * Pure auto-layout math (2026-07-17, James: cards dropped into a folder \"just\n * pile up on each other\" — and, later, an explicit desktop-style Clean Up).\n *\n * Two primitives, two products, one law each:\n * - `insertSlot` — place ONE newcomer near a drop hint without moving\n * anything: newcomers get a free slot, incumbents never move. Consumed by\n * the drop-consume path (l3-behave). Candidates are edge-aligned to the\n * incumbents (flush right/below/left/above with a gutter), so successive\n * drops grow aligned rows and columns instead of a global imposed grid.\n * - `packLayout` — bottom-left candidate packing for the explicit\n * \"Clean Up\" command (v2 2026-07-17, James: shelves were \"not really\n * efficient\" and selection packs \"overlay on top of unselected widgets\"):\n * items flow in reading order (current y, then x, then index) and each\n * takes the lowest-then-leftmost free spot, so small cards fill the air\n * beside tall ones instead of opening a new shelf. `obstacles` rects are\n * honored as immovable — a scoped pack flows AROUND bystanders. Still\n * \"my mess, straightened\": deterministic, anchored at the cluster's own\n * top-left, idempotent on packed input (pinned by test).\n * - `layerGraph` — the Unreal-Blueprint-style arrange for WIRED widgets:\n * Sugiyama-lite layered layout (longest-path ranks along edge direction,\n * barycenter ordering, columns left→right, vertically centered). Callers\n * lay out each connected component with this and pack the resulting\n * blocks with `packLayout`.\n *\n * Plain structs in, plain structs out (Law 13): no ECS, no DOM, no camera.\n * All coordinates live in ONE frame — callers convert (container-local for\n * folder drops, world for canvas clean-up) before and after.\n */\n\nexport interface LayoutRect {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\nexport interface LayoutSize {\n readonly w: number;\n readonly h: number;\n}\n\nexport interface LayoutPoint {\n readonly x: number;\n readonly y: number;\n}\n\n/** True when the rects are closer than `gutter` on BOTH axes (≥gutter on either axis = fine). */\nfunction crowds(a: LayoutRect, b: LayoutRect, gutter: number): boolean {\n return (\n a.x < b.x + b.w + gutter &&\n b.x < a.x + a.w + gutter &&\n a.y < b.y + b.h + gutter &&\n b.y < a.y + a.h + gutter\n );\n}\n\nfunction isFree(x: number, y: number, size: LayoutSize, incumbents: readonly LayoutRect[], gutter: number): boolean {\n const r = { x, y, w: size.w, h: size.h };\n for (const i of incumbents) {\n if (crowds(r, i, gutter)) return false;\n }\n return true;\n}\n\n/**\n * Nearest free slot to `hint` for a `size` newcomer among `incumbents`.\n *\n * The hint wins verbatim when it is already free (a deliberate drop into\n * empty space is user intent — don't second-guess it). Otherwise candidates\n * flush against each incumbent's edges (top- and far-aligned variants) are\n * ranked by squared distance to the hint; ties resolve to the first-seen\n * candidate (stable in incumbent order — deterministic across runs). The\n * fallback — a spot gutter-right of EVERYTHING — cannot crowd anyone, so a\n * slot always exists.\n */\nexport function insertSlot(\n incumbents: readonly LayoutRect[],\n size: LayoutSize,\n hint: LayoutPoint,\n gutter: number,\n): { x: number; y: number } {\n if (incumbents.length === 0 || isFree(hint.x, hint.y, size, incumbents, gutter)) {\n return { x: hint.x, y: hint.y };\n }\n let best: { x: number; y: number } | undefined;\n let bestD = Number.POSITIVE_INFINITY;\n for (const i of incumbents) {\n const candidates = [\n { x: i.x + i.w + gutter, y: i.y }, // right, top-aligned\n { x: i.x, y: i.y + i.h + gutter }, // below, left-aligned\n { x: i.x - size.w - gutter, y: i.y }, // left, top-aligned\n { x: i.x, y: i.y - size.h - gutter }, // above, left-aligned\n { x: i.x + i.w + gutter, y: i.y + i.h - size.h }, // right, bottom-aligned\n { x: i.x + i.w - size.w, y: i.y + i.h + gutter }, // below, right-aligned\n ];\n for (const c of candidates) {\n if (!isFree(c.x, c.y, size, incumbents, gutter)) continue;\n const d = (c.x - hint.x) ** 2 + (c.y - hint.y) ** 2;\n if (d < bestD) {\n bestD = d;\n best = c;\n }\n }\n }\n if (best !== undefined) return best;\n let maxRight = Number.NEGATIVE_INFINITY;\n for (const i of incumbents) maxRight = Math.max(maxRight, i.x + i.w);\n return { x: maxRight + gutter, y: hint.y };\n}\n\nexport interface PackOpts {\n readonly gutter: number;\n /** Pack origin; defaults to the items' current bbox top-left (the cluster stays put). */\n readonly origin?: LayoutPoint;\n /**\n * Band wrap width; defaults to a near-square derivation (√(total area × 1.6),\n * never narrower than the widest item). Soft: an item that fits nowhere\n * inside the band still places (lowest spot, band ignored) rather than\n * failing.\n */\n readonly maxWidth?: number;\n /**\n * Immovable rects the pack must flow AROUND (e.g. unselected widgets when\n * arranging a selection). Never returned, never moved, never crowded.\n */\n readonly obstacles?: readonly LayoutRect[];\n}\n\n/**\n * Bottom-left candidate packing: items in reading order of their CURRENT\n * positions (strict y, then x, then input index) each take the\n * lowest-then-leftmost free spot from the candidate set (the origin, plus\n * gutter-flush right-of and below-of every placed/obstacle rect, plus the\n * band-left row start under each). Dense with mixed sizes — small cards fill\n * the air beside tall ones — and obstacle-aware. Returns placements parallel\n * to the input array.\n */\nexport function packLayout(items: readonly LayoutRect[], opts: PackOpts): Array<{ x: number; y: number }> {\n if (items.length === 0) return [];\n const gutter = opts.gutter;\n\n let ox: number;\n let oy: number;\n if (opts.origin !== undefined) {\n ox = opts.origin.x;\n oy = opts.origin.y;\n } else {\n ox = Number.POSITIVE_INFINITY;\n oy = Number.POSITIVE_INFINITY;\n for (const it of items) {\n ox = Math.min(ox, it.x);\n oy = Math.min(oy, it.y);\n }\n }\n\n let maxWidth = opts.maxWidth;\n if (maxWidth === undefined) {\n let area = 0;\n let widest = 0;\n for (const it of items) {\n area += (it.w + gutter) * (it.h + gutter);\n widest = Math.max(widest, it.w);\n }\n maxWidth = Math.max(widest, Math.sqrt(area * 1.6));\n }\n\n const order = items\n .map((_, i) => i)\n .sort((a, b) => {\n const ia = items[a] as LayoutRect;\n const ib = items[b] as LayoutRect;\n return ia.y - ib.y || ia.x - ib.x || a - b;\n });\n\n // Feasibility set: obstacles first (they also seed candidates), then\n // every placed item as it lands.\n const placed: LayoutRect[] = [...(opts.obstacles ?? [])];\n const out = new Array<{ x: number; y: number }>(items.length);\n for (const idx of order) {\n const it = items[idx] as LayoutRect;\n const cands: LayoutPoint[] = [{ x: ox, y: oy }];\n for (const r of placed) {\n cands.push({ x: r.x + r.w + gutter, y: r.y }); // right, top-aligned\n cands.push({ x: r.x, y: r.y + r.h + gutter }); // below, left-aligned\n cands.push({ x: ox, y: r.y + r.h + gutter }); // band-left row start\n }\n let best: LayoutPoint | undefined;\n // Pass 1 honors the band; pass 2 drops it (an oversize item or a wall of\n // obstacles must still place — the below-everything candidate is always\n // free, so pass 2 cannot come up empty).\n for (const inBand of [true, false]) {\n for (const c of cands) {\n if (c.x < ox || c.y < oy) continue;\n if (inBand && c.x + it.w > ox + maxWidth) continue;\n if (!isFree(c.x, c.y, it, placed, gutter)) continue;\n if (best === undefined || c.y < best.y || (c.y === best.y && c.x < best.x)) best = c;\n }\n if (best !== undefined) break;\n }\n if (best === undefined) {\n // Defensive only (see pass-2 note above).\n let maxBottom = oy;\n for (const r of placed) maxBottom = Math.max(maxBottom, r.y + r.h);\n best = { x: ox, y: maxBottom + gutter };\n }\n out[idx] = { x: best.x, y: best.y };\n placed.push({ x: best.x, y: best.y, w: it.w, h: it.h });\n }\n return out;\n}\n\nexport interface LayerGraphOpts {\n /** Horizontal gap between columns (leave room for wires to breathe). */\n readonly gapX: number;\n /** Vertical gap between nodes inside a column. */\n readonly gapY: number;\n /**\n * Wrap the column run into stacked BANDS when the unwrapped width would\n * exceed this (carriage-return style: each band flows left→right, bands\n * stack top→down with a 2×gapY separator). Omit for a single band — a\n * graph is inherently wide and only wraps when the caller says the canvas\n * band demands it.\n */\n readonly maxWidth?: number;\n}\n\n/**\n * Layered graph layout (Sugiyama-lite) — the Unreal-Blueprint-style arrange\n * for wired widgets. Rank = longest path from the sources along edge\n * direction (a DFS drops back edges, so cycles are safe); columns flow\n * left→right; nodes stack top→down within a column. Ordering = alternating\n * barycenter sweeps with the BEST ordering kept (counted wire crossings),\n * then the classic transpose refinement (adjacent swaps that strictly\n * reduce crossings) — not provably minimal, but the standard practical\n * pair. Columns center vertically on their band's tallest. Placements are\n * relative to (0,0) — callers anchor the block. Deterministic: all\n * orderings tie-break on node index.\n */\nexport function layerGraph(\n nodes: readonly LayoutSize[],\n edges: readonly (readonly [number, number])[],\n opts: LayerGraphOpts,\n): Array<{ x: number; y: number }> {\n const n = nodes.length;\n if (n === 0) return [];\n\n // Drop self-edges; find back edges via iterative DFS (in index order).\n const outAdj: number[][] = Array.from({ length: n }, () => []);\n for (const [u, v] of edges) {\n if (u !== v && u >= 0 && u < n && v >= 0 && v < n) outAdj[u]?.push(v);\n }\n const kept: Array<[number, number]> = [];\n const state = new Array<0 | 1 | 2>(n).fill(0); // 0 unseen, 1 on stack, 2 done\n for (let root = 0; root < n; root++) {\n if (state[root] !== 0) continue;\n const stack: Array<{ u: number; i: number }> = [{ u: root, i: 0 }];\n state[root] = 1;\n while (stack.length > 0) {\n const top = stack[stack.length - 1] as { u: number; i: number };\n const adj = outAdj[top.u] as number[];\n if (top.i < adj.length) {\n const v = adj[top.i] as number;\n top.i += 1;\n if (state[v] === 1) continue; // back edge — dropped\n kept.push([top.u, v]);\n if (state[v] === 0) {\n state[v] = 1;\n stack.push({ u: v, i: 0 });\n }\n } else {\n state[top.u] = 2;\n stack.pop();\n }\n }\n }\n\n // Longest-path ranks over the kept DAG (topological relaxation).\n const keptOut: number[][] = Array.from({ length: n }, () => []);\n const indeg = new Array<number>(n).fill(0);\n for (const [u, v] of kept) {\n keptOut[u]?.push(v);\n indeg[v] = (indeg[v] as number) + 1;\n }\n const rank = new Array<number>(n).fill(0);\n const queue: number[] = [];\n for (let i = 0; i < n; i++) if (indeg[i] === 0) queue.push(i);\n for (let qi = 0; qi < queue.length; qi++) {\n const u = queue[qi] as number;\n for (const v of keptOut[u] as number[]) {\n rank[v] = Math.max(rank[v] as number, (rank[u] as number) + 1);\n indeg[v] = (indeg[v] as number) - 1;\n if (indeg[v] === 0) queue.push(v);\n }\n }\n\n const maxRank = Math.max(...rank);\n const layers: number[][] = Array.from({ length: maxRank + 1 }, () => []);\n for (let i = 0; i < n; i++) layers[rank[i] as number]?.push(i);\n\n // Barycenter ordering: neighbors (both directions) pull a node toward\n // their average slot in the adjacent fixed layer.\n const neighbors: number[][] = Array.from({ length: n }, () => []);\n for (const [u, v] of kept) {\n neighbors[u]?.push(v);\n neighbors[v]?.push(u);\n }\n const slot = new Array<number>(n).fill(0);\n const reSlot = (): void => {\n for (const layer of layers) {\n layer.forEach((node, s) => {\n slot[node] = s;\n });\n }\n };\n reSlot();\n\n /** Wire crossings across every adjacent layer pair, under the current slots. */\n const crossings = (): number => {\n let total = 0;\n for (let li = 0; li < maxRank; li++) {\n const pairs: Array<[number, number]> = [];\n for (const [u, v] of kept) {\n if (rank[u] === li && rank[v] === li + 1) pairs.push([slot[u] as number, slot[v] as number]);\n }\n for (let i = 0; i < pairs.length; i++) {\n for (let j = i + 1; j < pairs.length; j++) {\n const a = pairs[i] as [number, number];\n const b = pairs[j] as [number, number];\n if ((a[0] - b[0]) * (a[1] - b[1]) < 0) total += 1;\n }\n }\n }\n return total;\n };\n\n // Alternating barycenter sweeps; a sweep can WORSEN crossings, so the best\n // ordering seen is kept, not the last.\n const snapshot = (): number[][] => layers.map((l) => [...l]);\n const restore = (saved: number[][]): void => {\n saved.forEach((l, li) => {\n layers[li] = [...l];\n });\n reSlot();\n };\n let best = snapshot();\n let bestX = crossings();\n for (let sweep = 0; sweep < 4 && bestX > 0; sweep++) {\n const forward = sweep % 2 === 0;\n for (let li = forward ? 1 : maxRank - 1; forward ? li <= maxRank : li >= 0; li += forward ? 1 : -1) {\n const layer = layers[li] as number[];\n const bary = (node: number): number => {\n const ns = (neighbors[node] as number[]).filter((m) => Math.abs((rank[m] as number) - li) === 1);\n if (ns.length === 0) return slot[node] as number;\n return ns.reduce((sum, m) => sum + (slot[m] as number), 0) / ns.length;\n };\n layer.sort((a, b) => bary(a) - bary(b) || a - b);\n reSlot();\n }\n const x = crossings();\n if (x < bestX) {\n bestX = x;\n best = snapshot();\n }\n }\n restore(best);\n\n // Transpose refinement (the classic Sugiyama tail): adjacent swaps that\n // STRICTLY reduce crossings, until a quiet round. Catches the barycenter's\n // tie stalls.\n let improved = bestX > 0;\n for (let round = 0; round < 4 && improved; round++) {\n improved = false;\n for (const layer of layers) {\n for (let s = 0; s + 1 < layer.length; s++) {\n const a = layer[s] as number;\n const b = layer[s + 1] as number;\n layer[s] = b;\n layer[s + 1] = a;\n reSlot();\n const x = crossings();\n if (x < bestX) {\n bestX = x;\n improved = true;\n } else {\n layer[s] = a;\n layer[s + 1] = b;\n reSlot();\n }\n }\n }\n }\n\n // Coordinates. Column widths first; then the column run is partitioned\n // into bands (single band unless maxWidth demands wrapping); each band\n // flows left→right from x=0, stacks below the previous with a 2×gapY\n // separator, and centers its columns on the band's tallest.\n const colW = (layers as number[][]).map((layer) => {\n let widest = 0;\n for (const node of layer) widest = Math.max(widest, (nodes[node] as LayoutSize).w);\n return widest;\n });\n const colH = (layers as number[][]).map((layer) =>\n layer.reduce((sum, node, i) => sum + (nodes[node] as LayoutSize).h + (i > 0 ? opts.gapY : 0), 0),\n );\n\n const bands: number[][] = [];\n if (opts.maxWidth === undefined) {\n bands.push((layers as number[][]).map((_, li) => li));\n } else {\n let cur: number[] = [];\n let width = 0;\n for (let li = 0; li <= maxRank; li++) {\n const grown = (cur.length > 0 ? width + opts.gapX : 0) + (colW[li] as number);\n if (cur.length > 0 && grown > opts.maxWidth) {\n bands.push(cur);\n cur = [li];\n width = colW[li] as number;\n } else {\n cur.push(li);\n width = grown;\n }\n }\n if (cur.length > 0) bands.push(cur);\n }\n\n const out = new Array<{ x: number; y: number }>(n);\n let bandTop = 0;\n for (const band of bands) {\n let tallest = 0;\n for (const li of band) tallest = Math.max(tallest, colH[li] as number);\n let x = 0;\n for (const li of band) {\n let y = bandTop + (tallest - (colH[li] as number)) / 2;\n for (const node of layers[li] as number[]) {\n out[node] = { x, y };\n y += (nodes[node] as LayoutSize).h + opts.gapY;\n }\n x += (colW[li] as number) + opts.gapX;\n }\n bandTop += tallest + opts.gapY * 2;\n }\n return out;\n}\n","/**\n * THE PEGBOARD TRAY'S LATTICE LAW (design-017 §8; K5a) — where the kinds hang on the board: pure, one frame (the BOARD's —\n * x from the drawer's left edge, y down from the board's top at scroll 0), plain structs in and out.\n *\n * The lattice (§6.1) in pitches: holes at x = c + ¼ + ½·(r odd), rows at y = r + ¾; a hole is punched only where its centre\n * lies ≥ ¾ from both sides (the solid border, D-K3.1). The desk's shader and its CPU mirror (desk/tray/lattice.ts) read the\n * same three numbers from here.\n *\n * A kind's HANG (its `defineObject({ tray: { hang } })`): its size on the board (CSS px), its accessory — a hook, a shelf, a\n * clip or a rail, SKÅDIS-style — and its PEGS, the holes the accessory plugs into, in pitches from the specimen's HANG POINT:\n * the centre of its top edge (a hook, a clip, a rail hang it from above) or of its bottom edge (a shelf holds it up). Every\n * peg lands on a hole centre, so the pegs' offsets must be what the stagger allows: between two pegs a whole number of rows,\n * and across them a whole number of pitches on the same parity or a half on the other (`hangError`).\n *\n * The LAW (`layTray`): the items in (category, order, type) order, packed left to right across the board's columns, a line\n * at a time; each placed at the first holes at or after the line's top and the cursor — its row's PARITY is where the stagger\n * puts a hole under its first peg; a pitch between neighbours, a clear row between lines. `bottom` is the last line's foot;\n * the scroll's range is that plus a pitch, less the face the drawer shows (`trayScrollMax`).\n */\n\n/** The lattice's phase and border, pitches (design-017 §6.1). */\nexport const PEG_LATTICE = {\n /** A hole's centre: x = c + colPhase + ½·(r odd) from the board's left edge… */\n colPhase: 0.25,\n /** …at y = r + rowPhase below its top at scroll 0. */\n rowPhase: 0.75,\n /** A hole is punched only where its centre lies this far from both sides (the solid border). */\n border: 0.75,\n} as const;\n\n/** What holds a specimen to the board (design-016 §7.7 — SKÅDIS's accessories). */\nexport type TrayAccessory = \"hook\" | \"shelf\" | \"clip\" | \"rail\";\nexport const TRAY_ACCESSORIES: readonly TrayAccessory[] = [\"hook\", \"shelf\", \"clip\", \"rail\"];\n\n/** How a kind hangs on the tray: its size (CSS px), its pegs (pitches from its hang point), its accessory. */\nexport interface TrayHang {\n readonly w: number;\n readonly h: number;\n /** The holes the accessory plugs into, `[dx, dy]` pitches from the hang point — the top edge's centre, or the bottom edge's on a shelf. */\n readonly pegs: readonly (readonly [number, number])[];\n readonly accessory: TrayAccessory;\n}\n\n/**\n * The accessories' own geometry, pitches — the law's footprints and the desk's drawing read the same numbers. A HOOK drops\n * from its hole to its tip; a SHELF's plank lies under the specimen (its overhang past each side) on a bracket from each\n * hole; a CLIP's body grips the specimen's top edge from its hole; a RAIL's bar runs through its holes past the outer two.\n */\nexport const TRAY_ACCESSORY = {\n /** Round a peg: the plug in its hole and the reach of what sits on it (a hole is 0.26 × 0.66). */\n plug: { hx: 0.17, hy: 0.4 },\n hook: { hx: 0.12, drop: 0.62 },\n shelf: { thick: 0.24, overhang: 0.3, bracket: 0.1 },\n clip: { hx: 0.3, below: 0.55 },\n rail: { hy: 0.13, overhang: 0.4 },\n} as const;\n\n/** One item the law lays: a kind's type, its hang, and its place in the order. */\nexport interface TrayItem {\n readonly type: string;\n readonly hang: TrayHang;\n /** Sorted first (strings; absent = \"\"). */\n readonly category?: string;\n /** Then this (absent = 0), then the type. */\n readonly order?: number;\n}\n\n/** A box, pitches or px by context: left, top, right, bottom. */\nexport interface TrayBox {\n readonly x0: number;\n readonly y0: number;\n readonly x1: number;\n readonly y1: number;\n}\n\n/** A peg as laid: its hole (row, column) and the hole's centre, board px. */\nexport interface TrayPeg {\n readonly row: number;\n readonly col: number;\n readonly x: number;\n readonly y: number;\n}\n\n/** An item as laid, board px: the specimen's rect (top-left, size), its pegs on their holes, its footprint (the specimen and its accessory), its line. */\nexport interface TrayPlaced {\n readonly type: string;\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n readonly pegs: readonly TrayPeg[];\n readonly box: TrayBox;\n readonly line: number;\n}\n\nexport interface TrayLayout {\n readonly placed: readonly TrayPlaced[];\n /** The last line's foot, board px (0: nothing laid). */\n readonly bottom: number;\n}\n\n/**\n * The law's spacing, pitches: the side margin, the gap between neighbours, the first line's top, the clear row between lines. The first\n * line lies below the drawer's HEADER and its fade (design-018 R4, D-R4.2 — the desk's `DRAWER`: the arris 1.5 px, the clear header 48,\n * the ramp 32): at rest nothing laid is faded, every footprint at 99 % of the ramp or past it (2 pitches = 80 px ≥ 1.5 + 48 + 0.944·32;\n * the desk's test holds the two numbers together — the kernel imports no drawer).\n */\nexport interface TraySpacing {\n readonly margin: number;\n readonly gap: number;\n readonly top: number;\n readonly clear: number;\n}\nexport const TRAY_SPACING: TraySpacing = { margin: 0.5, gap: 1, top: 2, clear: 1 };\n\nconst EPS = 1e-9;\nconst whole = (v: number): boolean => Math.abs(v - Math.round(v)) < 1e-9;\n\n/** Why a hang cannot be laid (a message), or null: its size, its pegs on the lattice, its accessory. */\nexport function hangError(h: TrayHang): string | null {\n if (typeof h !== \"object\" || h === null) return \"a hang is { w, h, pegs, accessory }\";\n if (!(Number.isFinite(h.w) && h.w > 0 && Number.isFinite(h.h) && h.h > 0)) return `its size ${h.w} × ${h.h} is not a positive CSS px size`;\n if (!TRAY_ACCESSORIES.includes(h.accessory)) return `its accessory \"${String(h.accessory)}\" is not one of ${TRAY_ACCESSORIES.join(\", \")}`;\n if (!Array.isArray(h.pegs) || h.pegs.length === 0) return \"it names no peg — an accessory plugs into at least one hole\";\n const [x0, y0] = h.pegs[0] as readonly [number, number];\n for (const p of h.pegs) {\n if (!Array.isArray(p) || p.length !== 2 || !Number.isFinite(p[0]) || !Number.isFinite(p[1])) return `a peg ${JSON.stringify(p)} is not [dx, dy] in pitches`;\n const dy = (p[1] as number) - (y0 as number);\n const dx = (p[0] as number) - (x0 as number);\n if (!whole(dy)) return `the peg [${p.join(\", \")}] is ${dy} rows from the first — pegs lie a whole number of rows apart`;\n if (!whole(dx - dy / 2)) return `the peg [${p.join(\", \")}] is ${dx} pitches across from the first over ${dy} rows — the stagger puts holes a whole pitch apart on one parity, a half on the other`;\n }\n return null;\n}\n\n/** The (category, order, type) order. */\nexport function trayOrder(a: TrayItem, b: TrayItem): number {\n const ca = a.category ?? \"\";\n const cb = b.category ?? \"\";\n if (ca !== cb) return ca < cb ? -1 : 1;\n const oa = a.order ?? 0;\n const ob = b.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.type < b.type ? -1 : a.type > b.type ? 1 : 0;\n}\n\n/** A hang's footprint, pitches from its hang point: the specimen, its pegs' plugs and its accessory. */\nexport function hangFootprint(h: TrayHang, pitch: number): TrayBox {\n const A = TRAY_ACCESSORY;\n const hw = h.w / pitch / 2;\n const hh = h.h / pitch;\n const shelf = h.accessory === \"shelf\";\n let x0 = -hw;\n let x1 = hw;\n let y0 = shelf ? -hh : 0;\n let y1 = shelf ? 0 : hh;\n const add = (a: number, b: number, c: number, d: number): void => { x0 = Math.min(x0, a); y0 = Math.min(y0, b); x1 = Math.max(x1, c); y1 = Math.max(y1, d); };\n const xs = h.pegs.map((p) => p[0]);\n for (const [dx, dy] of h.pegs) {\n add(dx - A.plug.hx, dy - A.plug.hy, dx + A.plug.hx, dy + A.plug.hy);\n if (h.accessory === \"hook\") add(dx - A.hook.hx, dy, dx + A.hook.hx, dy + A.hook.drop);\n if (h.accessory === \"clip\") add(dx - A.clip.hx, dy, dx + A.clip.hx, Math.max(dy, 0) + A.clip.below);\n if (shelf) add(dx - A.shelf.bracket, Math.min(0, dy), dx + A.shelf.bracket, Math.max(0, dy));\n }\n if (shelf) add(-hw - A.shelf.overhang, 0, hw + A.shelf.overhang, A.shelf.thick);\n if (h.accessory === \"rail\") {\n const ys = h.pegs.map((p) => p[1]);\n add(Math.min(...xs) - A.rail.overhang, Math.min(...ys) - A.rail.hy, Math.max(...xs) + A.rail.overhang, Math.max(...ys) + A.rail.hy);\n }\n return { x0, y0, x1, y1 };\n}\n\n/** The hole (row, col) whose centre is at board pitches (x, y) — the pegs' lattice, exact for a peg the law laid. */\nfunction holeAt(x: number, y: number): { readonly row: number; readonly col: number } {\n const row = Math.round(y - PEG_LATTICE.rowPhase);\n const col = Math.round(x - PEG_LATTICE.colPhase - ((row & 1) !== 0 ? 0.5 : 0));\n return { row, col };\n}\n\n/** Where a hang's specimen's top edge lies below its hang point, pitches (0, or a shelf's specimen's height above it). */\nconst bodyTop = (h: TrayHang, pitch: number): number => (h.accessory === \"shelf\" ? -h.h / pitch : 0);\n\n/**\n * One item placed at the first holes whose footprint lies on or below `top`, whose specimen's top edge lies on or below `body`,\n * right of `left` (pitches): its hang point, pegs and footprint.\n */\nfunction fit(item: TrayItem, top: number, body: number, left: number, pitch: number): { readonly hx: number; readonly hy: number; readonly box: TrayBox; readonly pegs: readonly (readonly [number, number])[] } {\n const L = PEG_LATTICE;\n const h = item.hang;\n const fp = hangFootprint(h, pitch);\n const [dx0, dy0] = h.pegs[0] as readonly [number, number];\n // the first peg's row: the first whose hang point puts the footprint at or below the line's top and the specimen at or below its body line\n const r0 = Math.ceil(Math.max(top - fp.y0, body - bodyTop(h, pitch)) + dy0 - L.rowPhase - EPS);\n const hy = r0 + L.rowPhase - dy0;\n // its column: the first hole on that row's parity (the stagger) with the footprint right of the cursor and every peg punched\n const odd = (r0 & 1) !== 0 ? 0.5 : 0;\n const minDx = Math.min(...h.pegs.map((p) => p[0]));\n const want = Math.max(left - fp.x0 + dx0, L.border - minDx + dx0);\n const c0 = Math.ceil(want - L.colPhase - odd - EPS);\n const hx = c0 + L.colPhase + odd - dx0;\n return { hx, hy, box: { x0: hx + fp.x0, y0: hy + fp.y0, x1: hx + fp.x1, y1: hy + fp.y1 }, pegs: h.pegs.map(([dx, dy]) => [hx + dx, hy + dy] as const) };\n}\n\n/**\n * Lay the items on a board `width` px wide at `pitch` px (design-017 §8): in (category, order, type) order, left to right, a\n * line at a time — an item that would cross the right margin (or put a peg in the right border) starts the next line, a clear\n * row below the last one's foot. A line's specimens hang with their top edges together (as near as their holes allow): each\n * below the line's top by the most any item's accessory reaches above its specimen. Every peg on a punched hole's centre.\n */\nexport function layTray(items: readonly TrayItem[], width: number, pitch: number, spacing: TraySpacing = TRAY_SPACING): TrayLayout {\n const S = spacing;\n const cols = width / pitch;\n const sorted = [...items].sort(trayOrder);\n // the tallest reach above a specimen (a hook's hole over a note): every line's specimens start that far below its top\n const lead = Math.max(0, ...sorted.map((i) => bodyTop(i.hang, pitch) - hangFootprint(i.hang, pitch).y0));\n const placed: TrayPlaced[] = [];\n let top = S.top;\n let left = S.margin;\n let foot = top;\n let line = 0;\n let inLine = 0;\n const fits = (f: ReturnType<typeof fit>): boolean => f.box.x1 <= cols - S.margin + EPS && f.pegs.every(([x]) => x <= cols - PEG_LATTICE.border + EPS);\n for (const item of sorted) {\n let f = fit(item, top, top + lead, left, pitch);\n if (inLine > 0 && !fits(f)) {\n top = foot + S.clear;\n left = S.margin;\n line += 1;\n inLine = 0;\n f = fit(item, top, top + lead, left, pitch);\n }\n const h = item.hang;\n const x = f.hx * pitch - h.w / 2;\n const y = h.accessory === \"shelf\" ? f.hy * pitch - h.h : f.hy * pitch;\n placed.push({\n type: item.type, x, y, w: h.w, h: h.h, line,\n pegs: f.pegs.map(([px, py]) => { const { row, col } = holeAt(px, py); return { row, col, x: px * pitch, y: py * pitch }; }),\n box: { x0: f.box.x0 * pitch, y0: f.box.y0 * pitch, x1: f.box.x1 * pitch, y1: f.box.y1 * pitch },\n });\n left = f.box.x1 + S.gap;\n foot = inLine === 0 ? f.box.y1 : Math.max(foot, f.box.y1);\n inLine += 1;\n }\n return { placed, bottom: placed.length === 0 ? 0 : foot * pitch };\n}\n\n/** The board's scroll range (design-017 §8): the last line's foot plus a pitch, less the face the drawer shows — never below 0. */\nexport function trayScrollMax(bottom: number, face: number, pitch: number): number {\n return bottom <= 0 ? 0 : Math.max(0, bottom + pitch - face);\n}\n\n/**\n * A specimen's FIT (design-017 §8–§9; K5a's law, K5b's grab point): its object at its natural size seen at the scale its hang asks —\n * the smaller of the two ratios, so the whole object shows — centred in the hang's rect. `zoom` is that scale; `x`/`y`/`w`/`h` the\n * object as drawn, in the rect's units: what a press on the specimen grabs (the insert's anchor is the press across THIS rect).\n */\nexport function specimenFit(\n rect: { readonly x: number; readonly y: number; readonly w: number; readonly h: number },\n natural: { readonly w: number; readonly h: number },\n): { readonly zoom: number; readonly x: number; readonly y: number; readonly w: number; readonly h: number } {\n const zoom = Math.min(rect.w / natural.w, rect.h / natural.h);\n const w = natural.w * zoom;\n const h = natural.h * zoom;\n return { zoom, x: rect.x + (rect.w - w) / 2, y: rect.y + (rect.h - h) / 2, w, h };\n}\n","/**\n * Shelf packing for the atlas-slot allocator (design-012 §4, Q3 RATIFIED\n * 2026-08-31) — pure rect math over a plain page struct. No ids, no sources,\n * no GPU: the caller owns identity, residency and effects; this module owns only\n * where a rect may sit, what it costs, and when a page should grow. That caller\n * was `ground/atlas-allocator.ts` until B8 deleted the old leg; it is\n * `@ice/core`'s `createLayerAllocator` now, over fixed 2048² layers.\n *\n * **Gutters.** Every placed rect is separated from its neighbours AND from the\n * page edge by at least `gutter` px, so a linear tap at a slot's border never\n * reaches a neighbour's texels. 2 px is the default (design-012 §4 says\n * \"1–2 px\"): 1 px covers a bilinear tap's half-texel reach at dpr 1, 2 px\n * covers non-integer scaling and mip level 1.\n *\n * **Shelves, not skyline.** Slots are top-aligned on horizontal shelves whose\n * height is fixed by the first slot to open them. The band below a short slot\n * on a tall shelf is unusable by construction — that loss is real and shows up\n * in `pageWaste().packingWastePct` rather than hiding. A skyline packer would\n * recover some of it at the cost of an O(n) contour per placement and a much\n * harder free/coalesce story; shelves keep free + coalesce O(holes on one\n * shelf), which is what makes the retention half of the ratified design cheap.\n *\n * **Growth never moves a slot.** Shelves are anchored at y=0 and grow right and\n * down, so widening a page only lengthens every shelf's tail and heightening it\n * only adds room below. Every existing rect stays valid at the same origin —\n * the property that lets a page grow with content (Q3) without a repack.\n */\nimport type { Rect } from \"./shapes\";\n\n/** Default slot separation, in device px. See the gutter note above. */\nexport const DEFAULT_ATLAS_GUTTER = 2;\n\nexport interface SlotSize {\n width: number;\n height: number;\n}\n\nexport interface PageSize {\n width: number;\n height: number;\n}\n\n/**\n * One horizontal band. `height` is fixed when the shelf opens; `cursorX` is the\n * next free content-origin x (it starts at `gutter` and retracts when the\n * right-most slot is freed).\n */\nexport interface Shelf {\n y: number;\n height: number;\n cursorX: number;\n}\n\n/**\n * A packed page. Mutated in place by the functions below (a packer is state by\n * nature — the kernel law it obeys is \"no ECS/DOM/GPU\", not \"no mutation\";\n * `spatial-index` sets the same precedent).\n */\nexport interface ShelfPage {\n width: number;\n height: number;\n readonly gutter: number;\n shelves: Shelf[];\n /**\n * Reusable interior holes. Each spans its shelf's FULL height (freeing a\n * short slot on a tall shelf releases the whole band — the sub-shelf\n * remainder was never addressable), so `hole.y` identifies its shelf and\n * coalescing is a one-dimensional merge.\n */\n holes: Rect[];\n /** Σ of the areas handed out by `packRect` and not yet freed. */\n usedArea: number;\n}\n\nexport interface PageWaste {\n /** `width × height` — addressable space, NOT memory (textures are lazily backed). */\n pageArea: number;\n /** `width × occupiedHeight` — the band shelves actually reach into. */\n occupiedArea: number;\n /** Live slot pixels. */\n usedArea: number;\n /** Interior fragmentation: reusable holes left by freed slots. */\n holeArea: number;\n /** `1 − usedArea/occupiedArea` — the number comparable to the spike's 19.5 %. */\n packingWastePct: number;\n /** `1 − usedArea/pageArea` — how much of the allocation is unspent. */\n allocationWastePct: number;\n /** `holeArea/occupiedArea` — the repack trigger. */\n fragmentationPct: number;\n}\n\nexport function createShelfPage(width: number, height: number, gutter = DEFAULT_ATLAS_GUTTER): ShelfPage {\n return { width, height, gutter, shelves: [], holes: [], usedArea: 0 };\n}\n\nexport function cloneShelfPage(page: ShelfPage): ShelfPage {\n return {\n width: page.width,\n height: page.height,\n gutter: page.gutter,\n shelves: page.shelves.map((s) => ({ ...s })),\n holes: page.holes.map((h) => ({ ...h })),\n usedArea: page.usedArea,\n };\n}\n\n/** Bottom edge (exclusive, gutter included) of the last shelf; 0 on an untouched page. */\nexport function pageOccupiedHeight(page: ShelfPage): number {\n const last = page.shelves[page.shelves.length - 1];\n return last === undefined ? 0 : last.y + last.height + page.gutter;\n}\n\nexport function pageWaste(page: ShelfPage): PageWaste {\n const pageArea = page.width * page.height;\n const occupiedArea = page.width * pageOccupiedHeight(page);\n let holeArea = 0;\n for (const h of page.holes) holeArea += h.width * h.height;\n return {\n pageArea,\n occupiedArea,\n usedArea: page.usedArea,\n holeArea,\n packingWastePct: occupiedArea === 0 ? 0 : 1 - page.usedArea / occupiedArea,\n allocationWastePct: pageArea === 0 ? 0 : 1 - page.usedArea / pageArea,\n fragmentationPct: occupiedArea === 0 ? 0 : holeArea / occupiedArea,\n };\n}\n\n/**\n * Where a rect of this size would go in a page of size `width × height`,\n * without touching the page. `null` = nowhere.\n *\n * Candidates are scored `[heightSlack, widthSlack, tail?]`, lowest first: a\n * best-height fit first (shelf height is the irrecoverable dimension), then the\n * tightest width, then holes ahead of shelf tails at equal fit — filling\n * interior fragmentation beats extending into fresh space.\n */\nfunction findPlacement(page: ShelfPage, width: number, height: number, size: SlotSize): Rect | null {\n const g = page.gutter;\n if (size.width <= 0 || size.height <= 0) return null;\n\n // [heightSlack, widthSlack, isTail, x, y] — lowest wins, compared in order.\n let best: [number, number, number, number, number] | null = null;\n const better = (c: [number, number, number, number, number]): boolean => {\n if (best === null) return true;\n for (let i = 0; i < c.length; i++) {\n const a = c[i] as number;\n const b = best[i] as number;\n if (a !== b) return a < b;\n }\n return false;\n };\n\n // A hole never extends past the page edge it was cut from, so it stays legal\n // under any growth — no width check against the (possibly grown) page.\n for (const hole of page.holes) {\n if (hole.width < size.width || hole.height < size.height) continue;\n // Take a hole only on an exact width fit or one leaving a usable remainder.\n // A remainder of 1..gutter px could not hold anything anyway, and dropping\n // it would detach the slack from the free list — the freed rect would then\n // no longer be gutter-adjacent to its right-hand neighbour and the two\n // could never coalesce again. The randomized suite found the leak.\n if (hole.width !== size.width && hole.width - size.width <= g) continue;\n const c: [number, number, number, number, number] = [\n hole.height - size.height,\n hole.width - size.width,\n 0,\n hole.x,\n hole.y,\n ];\n if (better(c)) best = c;\n }\n\n for (const shelf of page.shelves) {\n if (shelf.height < size.height) continue;\n const tail = width - g - shelf.cursorX;\n if (tail < size.width) continue;\n const c: [number, number, number, number, number] = [\n shelf.height - size.height,\n tail - size.width,\n 1,\n shelf.cursorX,\n shelf.y,\n ];\n if (better(c)) best = c;\n }\n\n if (best !== null) return { x: best[3], y: best[4], width: size.width, height: size.height };\n\n const bottom = pageOccupiedHeight(page);\n const y = bottom === 0 ? g : bottom;\n if (y + size.height + g <= height && g + size.width + g <= width) {\n return { x: g, y, width: size.width, height: size.height };\n }\n return null;\n}\n\n/** True when `size` fits a page whose shelves are `page`'s but whose extent is `width × height`. */\nexport function canPackAt(page: ShelfPage, width: number, height: number, size: SlotSize): boolean {\n return findPlacement(page, width, height, size) !== null;\n}\n\n/**\n * Place a rect, mutating the page. `null` when it does not fit — the caller\n * decides whether to grow (`nextGrowthStep`) or open another page.\n */\nexport function packRect(page: ShelfPage, size: SlotSize): Rect | null {\n const rect = findPlacement(page, page.width, page.height, size);\n if (rect === null) return null;\n const g = page.gutter;\n\n const holeIndex = page.holes.findIndex((h) => h.x === rect.x && h.y === rect.y);\n if (holeIndex >= 0) {\n const hole = page.holes[holeIndex] as Rect;\n const remainder = hole.width - rect.width - g;\n if (remainder > 0) {\n page.holes[holeIndex] = { x: hole.x + rect.width + g, y: hole.y, width: remainder, height: hole.height };\n } else {\n page.holes.splice(holeIndex, 1);\n }\n } else {\n const shelf = page.shelves.find((s) => s.y === rect.y);\n if (shelf === undefined) {\n page.shelves.push({ y: rect.y, height: rect.height, cursorX: rect.x + rect.width + g });\n } else {\n shelf.cursorX = rect.x + rect.width + g;\n }\n }\n\n page.usedArea += rect.width * rect.height;\n return rect;\n}\n\n/**\n * Return a rect to the page. `false` when it belongs to no shelf here (a\n * foreign or already-freed rect — the caller's bookkeeping is wrong).\n *\n * The rect's shelf band becomes reusable in full: a right-most rect retracts\n * the shelf cursor (absorbing any holes the retraction reaches), anything else\n * becomes a hole and coalesces with its neighbours.\n */\nexport function freeRect(page: ShelfPage, rect: Rect): boolean {\n const shelf = page.shelves.find((s) => s.y === rect.y);\n if (shelf === undefined) return false;\n const g = page.gutter;\n // ALREADY FREE. The doc above has always promised `false` for a rect this\n // page no longer holds, and the shelf lookup alone cannot tell: a second\n // free of the same rect finds the same shelf, subtracts its area a second\n // time — `usedArea` goes negative, and every waste ratio derived from it\n // goes with it — and pushes a duplicate hole that coalescing then hands out\n // as space twice. Two cheap checks decide it, and both are properties of a\n // LIVE rect: it lies inside the shelf's occupied band, and it is not inside\n // a hole.\n if (rect.x + rect.width + g > shelf.cursorX) return false;\n if (\n page.holes.some(\n (h) => h.y === shelf.y && rect.x >= h.x && rect.x + rect.width <= h.x + h.width,\n )\n ) {\n return false;\n }\n page.usedArea -= rect.width * rect.height;\n\n if (rect.x + rect.width + g === shelf.cursorX) {\n shelf.cursorX = rect.x;\n } else {\n page.holes.push({ x: rect.x, y: shelf.y, width: rect.width, height: shelf.height });\n }\n // Both branches, always in this order: merging can produce a hole that now\n // reaches the cursor (free the tail slot FIRST and every hole to its left\n // stays stranded otherwise — the randomized suite caught exactly that),\n // and absorbing can empty a shelf.\n coalesceHoles(page);\n absorbHolesAtCursor(page, shelf);\n coalesceShelves(page);\n return true;\n}\n\n/** Retract a shelf cursor over every hole that now touches it. */\nfunction absorbHolesAtCursor(page: ShelfPage, shelf: Shelf): void {\n const g = page.gutter;\n for (;;) {\n const i = page.holes.findIndex((h) => h.y === shelf.y && h.x + h.width + g === shelf.cursorX);\n if (i < 0) return;\n shelf.cursorX = (page.holes[i] as Rect).x;\n page.holes.splice(i, 1);\n }\n}\n\n/**\n * Merge holes that are gutter-adjacent on the same shelf. The gutter between\n * them joins the merged hole: it is addressable again once the slots either\n * side of it are gone.\n */\nexport function coalesceHoles(page: ShelfPage): void {\n const g = page.gutter;\n page.holes.sort((a, b) => a.y - b.y || a.x - b.x);\n const merged: Rect[] = [];\n for (const hole of page.holes) {\n const prev = merged[merged.length - 1];\n if (prev !== undefined && prev.y === hole.y && prev.x + prev.width + g === hole.x) {\n prev.width = hole.x + hole.width - prev.x;\n } else {\n merged.push({ ...hole });\n }\n }\n page.holes = merged;\n}\n\n/**\n * Reclaim vertical space: drop trailing empty shelves, and merge adjacent\n * empty ones into a single taller shelf. Without the merge, a page that fully\n * cycles its content keeps its original height ladder forever and can no\n * longer accept a slot taller than any single old shelf.\n */\nexport function coalesceShelves(page: ShelfPage): void {\n const g = page.gutter;\n const isEmpty = (s: Shelf) => s.cursorX === g;\n\n const merged: Shelf[] = [];\n for (const shelf of page.shelves) {\n const prev = merged[merged.length - 1];\n if (prev !== undefined && isEmpty(prev) && isEmpty(shelf)) {\n prev.height = shelf.y + shelf.height - prev.y;\n } else {\n merged.push(shelf);\n }\n }\n while (merged.length > 0 && isEmpty(merged[merged.length - 1] as Shelf)) merged.pop();\n page.shelves = merged;\n}\n\n/**\n * The smallest page that could ever hold `size`: the next power of two on both\n * sides, clamped into `[minSize, maxSize]`. `null` when the device limit cannot\n * hold the slot at all — the honest answer is a refusal, not a clipped slot.\n */\nexport function initialPageSize(\n size: SlotSize,\n minSize: number,\n maxSize: number,\n gutter = DEFAULT_ATLAS_GUTTER,\n): PageSize | null {\n const need = Math.max(size.width, size.height) + 2 * gutter;\n if (need > maxSize) return null;\n let side = Math.max(minSize, 1);\n while (side < need) side *= 2;\n side = Math.min(side, maxSize);\n return { width: side, height: side };\n}\n\n/**\n * The next growth step for a page: double the SHORTER side (ties go to width),\n * capped at the device limit. `null` when both sides are already at the limit.\n *\n * Doubling overshoots — the 100-card uniform board lands on 4096×4096 where\n * 4096×3044 would do, 34 % more addressable space than it spends. That is\n * deliberate: `hic-bench` FINDINGS §6 measured `createTexture` at 0.0 MB and\n * all cost at first write, so the unwritten tail is addressable, not resident,\n * while every growth step IS a real texture realloc. The alternative that lost\n * was growing height in exact shelf increments (tight pages, ~9 reallocs for\n * that board instead of 3). `pageWaste` reports both numbers so the assumption\n * stays visible: `packingWastePct` for packing quality, `allocationWastePct`\n * for the overshoot.\n */\nexport function nextGrowthStep(current: PageSize, maxSize: number): PageSize | null {\n const { width, height } = current;\n if (width >= maxSize && height >= maxSize) return null;\n if (width <= height && width < maxSize) return { width: Math.min(width * 2, maxSize), height };\n if (height < maxSize) return { width, height: Math.min(height * 2, maxSize) };\n return { width: Math.min(width * 2, maxSize), height };\n}\n\n/**\n * The page extent that would admit `size`, growing from the page's current one.\n * `null` when the device limit is reached without room. Pure — the caller\n * applies ONE growth to the answer rather than reallocating per step.\n */\nexport function planPageGrowth(page: ShelfPage, size: SlotSize, maxSize: number): PageSize | null {\n let extent: PageSize = { width: page.width, height: page.height };\n while (!canPackAt(page, extent.width, extent.height, size)) {\n const step = nextGrowthStep(extent, maxSize);\n if (step === null) return null;\n extent = step;\n }\n return extent;\n}\n\n/** Widen/heighten a page in place. Existing rects keep their origins (see the module note). */\nexport function growShelfPage(page: ShelfPage, size: PageSize): void {\n if (size.width < page.width || size.height < page.height) {\n throw new Error(\"atlas: pages grow only — shrinking would move live slots\");\n }\n page.width = size.width;\n page.height = size.height;\n}\n\n/**\n * Repack a set of sizes into a fresh page of the given extent, tallest first —\n * the classic shelf-packing order, and the only reason a repack is worth its\n * re-uploads. Returns rects positionally matched to `sizes`, or `null` if the\n * set does not fit (the caller keeps the page it has).\n */\nexport function packPage(\n width: number,\n height: number,\n gutter: number,\n sizes: readonly SlotSize[],\n): { page: ShelfPage; rects: Rect[] } | null {\n const order = sizes.map((_, i) => i);\n order.sort((a, b) => {\n const sa = sizes[a] as SlotSize;\n const sb = sizes[b] as SlotSize;\n return sb.height - sa.height || sb.width - sa.width || a - b;\n });\n\n const page = createShelfPage(width, height, gutter);\n const rects: (Rect | undefined)[] = new Array(sizes.length);\n for (const i of order) {\n const rect = packRect(page, sizes[i] as SlotSize);\n if (rect === null) return null;\n rects[i] = rect;\n }\n return { page, rects: rects as Rect[] };\n}\n","/**\n * @ice/kernel — pure math. Plain structs in, plain structs out.\n * Import wall: nothing but `rbush` (named exception — zero-dep R-tree).\n */\nexport const KERNEL_VERSION = \"0.0.0\";\n\nexport * from \"./shapes\";\nexport * from \"./coords\";\nexport * from \"./snap\";\nexport * from \"./spatial-index\";\nexport * from \"./anchors\";\nexport * from \"./bezier\";\nexport * from \"./easing\";\nexport * from \"./nav-flight\";\nexport * from \"./layout\";\n// The pegboard tray's lattice law (design-017 §8, K5a): where the kinds hang on the board.\nexport * from \"./tray\";\n// PARKED (design-015 §1, D5b): the shelf packer's one reader was core's residency layer\n// allocator, deleted with the surface infra. Kept, unread, for an image or text atlas.\nexport * from \"./atlas-pack\";\n\n// Gone at design-015 D5b with the HiC/island sizing they served: `surface-geometry` (the copy\n// size / slot size / uv numerator call), `zoom-bands` (island FBO bands), `eviction` (the island\n// FBO pool), `lift` (the DOM/GL lift lockstep) and coords' island helpers (`worldToIsland`,\n// `islandToWorld`, `compositeCameraFrustum`, `worldRectToComposite`).\n"],"mappings":";AAqBO,SAAS,WAAW,GAAe;AACxC,SAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,OAAO,MAAM,EAAE,IAAI,EAAE,OAAO;AAC3E;AAEO,SAAS,WAAW,GAAe;AACxC,SAAO,EAAE,GAAG,EAAE,MAAM,GAAG,EAAE,MAAM,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,EAAE,OAAO,EAAE,KAAK;AACjF;AAEO,SAAS,eAAe,GAAS,GAAkB;AACxD,SAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE;AACjF;AAEO,SAAS,YAAY,IAAY,IAAY,GAAkB;AACpE,SAAO,MAAM,EAAE,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE;AACjE;AAEO,SAAS,MAAM,OAAe,KAA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AK,QAAQ,KAAK;AAClB,OAAK,SAAS,KAAK;AACrB;AAQO,SAAS,SACd,OACA,QACA,QACA,OAC2C;AAC3C,QAAM,QAAQ,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC;AACnC,QAAM,KAAK,CAAC,GAAG,MAAM;AACnB,UAAM,KAAK,MAAM,CAAC;AAClB,UAAM,KAAK,MAAM,CAAC;AAClB,WAAO,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,IAAI;AAAA,EAC7D,CAAC;AAED,QAAM,OAAO,gBAAgB,OAAO,QAAQ,MAAM;AAClD,QAAM,QAA8B,IAAI,MAAM,MAAM,MAAM;AAC1D,aAAW,KAAK,OAAO;AACrB,UAAM,OAAO,SAAS,MAAM,MAAM,CAAC,CAAa;AAChD,QAAI,SAAS,KAAM,QAAO;AAC1B,UAAM,CAAC,IAAI;AAAA,EACb;AACA,SAAO,EAAE,MAAM,MAAuB;AACxC;;;ACpaO,IAAM,iBAAiB;","names":["fit"]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// ../desk/src/engine/pipeline.ts
|
|
2
|
+
var stageBits = (v) => v === "vertex" ? GPUShaderStage.VERTEX : v === "fragment" ? GPUShaderStage.FRAGMENT : GPUShaderStage.COMPUTE;
|
|
3
|
+
var labelled = (label) => label === void 0 ? {} : { label };
|
|
4
|
+
function bindLayout(device, entries, label) {
|
|
5
|
+
return device.createBindGroupLayout({
|
|
6
|
+
...labelled(label),
|
|
7
|
+
entries: entries.map((e) => {
|
|
8
|
+
const visibility = e.stages.reduce((m, s) => m | stageBits(s), 0);
|
|
9
|
+
if ("buffer" in e) return { binding: e.binding, visibility, buffer: { type: e.buffer } };
|
|
10
|
+
if ("texture" in e) return { binding: e.binding, visibility, texture: { sampleType: e.texture, ...e.dimension ? { viewDimension: e.dimension } : {} } };
|
|
11
|
+
return { binding: e.binding, visibility, sampler: { type: e.sampler } };
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function bindGroup(device, layout, resources, label) {
|
|
16
|
+
return device.createBindGroup({
|
|
17
|
+
...labelled(label),
|
|
18
|
+
layout,
|
|
19
|
+
// Duck-typed, not `instanceof GPUBuffer`: under Dawn-in-Node the class
|
|
20
|
+
// globals are optional, and a buffer is the one resource that can be mapped.
|
|
21
|
+
entries: resources.map((r, binding) => ({
|
|
22
|
+
binding,
|
|
23
|
+
resource: typeof r.getMappedRange === "function" ? { buffer: r } : r
|
|
24
|
+
}))
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
var BLEND_OVER = {
|
|
28
|
+
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
29
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
30
|
+
};
|
|
31
|
+
function renderPipeline(device, o) {
|
|
32
|
+
const constants = o.constants ?? {};
|
|
33
|
+
return device.createRenderPipelineAsync({
|
|
34
|
+
...labelled(o.label),
|
|
35
|
+
layout: o.layout,
|
|
36
|
+
vertex: { module: o.module, entryPoint: o.vertex ?? "vs", constants },
|
|
37
|
+
fragment: {
|
|
38
|
+
module: o.module,
|
|
39
|
+
entryPoint: o.fragment ?? "fs",
|
|
40
|
+
constants,
|
|
41
|
+
targets: [o.blend ? { format: o.format, blend: o.blend } : { format: o.format }]
|
|
42
|
+
},
|
|
43
|
+
primitive: { topology: o.topology ?? "triangle-list" }
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function uniformBuffer(device, size, label) {
|
|
47
|
+
return device.createBuffer({ ...labelled(label), size, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });
|
|
48
|
+
}
|
|
49
|
+
function storageBuffer(device, size, label) {
|
|
50
|
+
return device.createBuffer({ ...labelled(label), size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ../desk/src/engine/struct.ts
|
|
54
|
+
var TYPES = {
|
|
55
|
+
f32: { align: 4, size: 4, n: 1, scalar: "f" },
|
|
56
|
+
i32: { align: 4, size: 4, n: 1, scalar: "i" },
|
|
57
|
+
u32: { align: 4, size: 4, n: 1, scalar: "u" },
|
|
58
|
+
vec2f: { align: 8, size: 8, n: 2, scalar: "f" },
|
|
59
|
+
vec3f: { align: 16, size: 12, n: 3, scalar: "f" },
|
|
60
|
+
vec4f: { align: 16, size: 16, n: 4, scalar: "f" },
|
|
61
|
+
// 4 columns of vec4f, column-major — what a projector matrix is uploaded as.
|
|
62
|
+
mat4x4f: { align: 16, size: 64, n: 16, scalar: "f" }
|
|
63
|
+
};
|
|
64
|
+
function typeInfo(type) {
|
|
65
|
+
if (type in TYPES) return TYPES[type];
|
|
66
|
+
const m = /^array<vec4f, (\d+)>$/.exec(type);
|
|
67
|
+
const n = m ? Number(m[1]) : 0;
|
|
68
|
+
return n > 0 ? { align: 16, size: 16 * n, n: 4 * n, scalar: "f" } : void 0;
|
|
69
|
+
}
|
|
70
|
+
function defineStruct(name, fields) {
|
|
71
|
+
let offset = 0;
|
|
72
|
+
let maxAlign = 4;
|
|
73
|
+
const slots = {};
|
|
74
|
+
const seen = /* @__PURE__ */ new Set();
|
|
75
|
+
for (const [field, type] of fields) {
|
|
76
|
+
if (seen.has(field)) throw new Error(`struct ${name}: duplicate field "${field}"`);
|
|
77
|
+
seen.add(field);
|
|
78
|
+
const t = typeInfo(type);
|
|
79
|
+
if (!t) throw new Error(`struct ${name}: unknown type ${String(type)} for "${field}"`);
|
|
80
|
+
offset = Math.ceil(offset / t.align) * t.align;
|
|
81
|
+
slots[field] = { byte: offset, type, n: t.n };
|
|
82
|
+
offset += t.size;
|
|
83
|
+
maxAlign = Math.max(maxAlign, t.align);
|
|
84
|
+
}
|
|
85
|
+
const size = Math.ceil(offset / 16) * 16;
|
|
86
|
+
const width = Math.max(...fields.map(([f]) => f.length), 1);
|
|
87
|
+
const wgsl = `struct ${name} {
|
|
88
|
+
${fields.map(([f, t]) => ` ${f.padEnd(width)} : ${t},`).join("\n")}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
const def = {
|
|
92
|
+
name,
|
|
93
|
+
fields,
|
|
94
|
+
size,
|
|
95
|
+
slots,
|
|
96
|
+
wgsl,
|
|
97
|
+
alloc(count = 1) {
|
|
98
|
+
const bytes = new ArrayBuffer(size * count);
|
|
99
|
+
const f = new Float32Array(bytes);
|
|
100
|
+
const i = new Int32Array(bytes);
|
|
101
|
+
const u = new Uint32Array(bytes);
|
|
102
|
+
return {
|
|
103
|
+
def,
|
|
104
|
+
count,
|
|
105
|
+
bytes,
|
|
106
|
+
set(values, index = 0) {
|
|
107
|
+
if (index < 0 || index >= count) throw new Error(`struct ${name}: element ${index} outside 0..${count - 1}`);
|
|
108
|
+
const base = index * size / 4;
|
|
109
|
+
for (const key in values) {
|
|
110
|
+
const slot = slots[key];
|
|
111
|
+
if (!slot) throw new Error(`struct ${name}: no field "${key}"`);
|
|
112
|
+
const v = values[key];
|
|
113
|
+
const at = base + slot.byte / 4;
|
|
114
|
+
if (slot.n === 1) {
|
|
115
|
+
const num = typeof v === "boolean" ? v ? 1 : 0 : v;
|
|
116
|
+
if (typeof num !== "number") throw new Error(`struct ${name}: "${key}" wants a number`);
|
|
117
|
+
const s = typeInfo(slot.type).scalar;
|
|
118
|
+
if (s === "f") f[at] = num;
|
|
119
|
+
else if (s === "i") i[at] = num | 0;
|
|
120
|
+
else u[at] = num >>> 0;
|
|
121
|
+
} else {
|
|
122
|
+
const arr = v;
|
|
123
|
+
if (!arr || typeof arr.length !== "number" || arr.length !== slot.n) {
|
|
124
|
+
throw new Error(`struct ${name}: "${key}" wants ${slot.n} components`);
|
|
125
|
+
}
|
|
126
|
+
for (let k = 0; k < slot.n; k++) f[at + k] = arr[k];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
view(elements = count) {
|
|
131
|
+
return new Uint8Array(bytes, 0, Math.min(elements, count) * size);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
return def;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
bindLayout,
|
|
141
|
+
bindGroup,
|
|
142
|
+
BLEND_OVER,
|
|
143
|
+
renderPipeline,
|
|
144
|
+
uniformBuffer,
|
|
145
|
+
storageBuffer,
|
|
146
|
+
defineStruct
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=chunk-QXOCF56A.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../desk/src/engine/pipeline.ts","../../desk/src/engine/struct.ts"],"sourcesContent":["// Pipelines and bind groups without the ceremony. Layouts are EXPLICIT, never\n// 'auto': two passes that read the same buffers share one layout object, so a\n// bind group built for one binds to the other.\n\nexport type Visibility = \"vertex\" | \"fragment\" | \"compute\";\n// Looked up at call time, never at module load: a Node host installs the GPU\n// globals AFTER importing the engine.\nconst stageBits = (v: Visibility): number =>\n v === \"vertex\" ? GPUShaderStage.VERTEX : v === \"fragment\" ? GPUShaderStage.FRAGMENT : GPUShaderStage.COMPUTE;\n\n/** `exactOptionalPropertyTypes`: an absent label must be absent, not `undefined`. */\nconst labelled = (label: string | undefined) => (label === undefined ? {} : { label });\n\nexport type BindEntry =\n | { readonly binding: number; readonly stages: readonly Visibility[]; readonly buffer: GPUBufferBindingType }\n | { readonly binding: number; readonly stages: readonly Visibility[]; readonly texture: GPUTextureSampleType; readonly dimension?: GPUTextureViewDimension }\n | { readonly binding: number; readonly stages: readonly Visibility[]; readonly sampler: GPUSamplerBindingType };\n\n/** A binding's layout without its number — what a card material declares (K7b), the card deals the numbers. */\nexport type BindKind = BindEntry extends infer E ? (E extends BindEntry ? Omit<E, \"binding\"> : never) : never;\n\nexport function bindLayout(device: GPUDevice, entries: readonly BindEntry[], label?: string): GPUBindGroupLayout {\n return device.createBindGroupLayout({\n ...labelled(label),\n entries: entries.map((e) => {\n const visibility = e.stages.reduce((m, s) => m | stageBits(s), 0);\n if (\"buffer\" in e) return { binding: e.binding, visibility, buffer: { type: e.buffer } };\n if (\"texture\" in e) return { binding: e.binding, visibility, texture: { sampleType: e.texture, ...(e.dimension ? { viewDimension: e.dimension } : {}) } };\n return { binding: e.binding, visibility, sampler: { type: e.sampler } };\n }),\n });\n}\n\nexport function bindGroup(\n device: GPUDevice,\n layout: GPUBindGroupLayout,\n resources: ReadonlyArray<GPUBuffer | GPUTextureView | GPUSampler>,\n label?: string,\n): GPUBindGroup {\n return device.createBindGroup({\n ...labelled(label),\n layout,\n // Duck-typed, not `instanceof GPUBuffer`: under Dawn-in-Node the class\n // globals are optional, and a buffer is the one resource that can be mapped.\n entries: resources.map((r, binding) => ({\n binding,\n resource: typeof (r as GPUBuffer).getMappedRange === \"function\" ? { buffer: r as GPUBuffer } : (r as GPUTextureView | GPUSampler),\n })),\n });\n}\n\n/** Straight-alpha \"source over\": colour by src-alpha, alpha accumulates. */\nexport const BLEND_OVER: GPUBlendState = {\n color: { srcFactor: \"src-alpha\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n alpha: { srcFactor: \"one\", dstFactor: \"one-minus-src-alpha\", operation: \"add\" },\n};\n\nexport interface RenderPipelineOptions {\n readonly label?: string;\n readonly layout: GPUPipelineLayout;\n readonly module: GPUShaderModule;\n readonly vertex?: string;\n readonly fragment?: string;\n readonly format: GPUTextureFormat;\n readonly blend?: GPUBlendState;\n /** WGSL `override` values, fixed at creation — how one file becomes N specialised pipelines. */\n readonly constants?: Record<string, number>;\n readonly topology?: GPUPrimitiveTopology;\n}\n\nexport function renderPipeline(device: GPUDevice, o: RenderPipelineOptions): Promise<GPURenderPipeline> {\n const constants = o.constants ?? {};\n return device.createRenderPipelineAsync({\n ...labelled(o.label),\n layout: o.layout,\n vertex: { module: o.module, entryPoint: o.vertex ?? \"vs\", constants },\n fragment: {\n module: o.module, entryPoint: o.fragment ?? \"fs\", constants,\n targets: [o.blend ? { format: o.format, blend: o.blend } : { format: o.format }],\n },\n primitive: { topology: o.topology ?? \"triangle-list\" },\n });\n}\n\nexport function uniformBuffer(device: GPUDevice, size: number, label?: string): GPUBuffer {\n return device.createBuffer({ ...labelled(label), size, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST });\n}\n\nexport function storageBuffer(device: GPUDevice, size: number, label?: string): GPUBuffer {\n return device.createBuffer({ ...labelled(label), size, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST });\n}\n","// ONE declaration of a GPU struct, in TypeScript. It yields the WGSL `struct`\n// text the shader is compiled against, the byte layout the CPU packs to, and a\n// packer that writes by field name. Because the shader's struct is generated\n// from this same list in this same order, a layout mismatch is not possible —\n// and a typo in a field name fails WGSL compilation, loudly, at startup, rather\n// than silently reading garbage. (Lineage: research/sdf-card/src/gpu/uniforms.js.)\n//\n// Layout follows the WGSL host-shareable rules for the types we use:\n// f32 / i32 / u32 align 4 size 4\n// vec2f align 8 size 8\n// vec3f align 16 size 12 (a following scalar packs into its tail)\n// vec4f align 16 size 16\n// mat4x4f align 16 size 64 (four vec4f columns)\n// A struct's size is rounded up to 16 so it is a legal uniform member AND a\n// legal storage-array element with the same stride in both address spaces.\n\n/** The scalar and vector types, and a fixed array of vec4f (`array<vec4f, N>`: stride 16, legal in a uniform block) — the portal chain's. */\nexport type FieldType = \"f32\" | \"i32\" | \"u32\" | \"vec2f\" | \"vec3f\" | \"vec4f\" | \"mat4x4f\" | `array<vec4f, ${number}>`;\n\ninterface TypeInfo { readonly align: number; readonly size: number; readonly n: number; readonly scalar: \"f\" | \"i\" | \"u\" }\nconst TYPES: Record<Exclude<FieldType, `array<vec4f, ${number}>`>, TypeInfo> = {\n f32: { align: 4, size: 4, n: 1, scalar: \"f\" },\n i32: { align: 4, size: 4, n: 1, scalar: \"i\" },\n u32: { align: 4, size: 4, n: 1, scalar: \"u\" },\n vec2f: { align: 8, size: 8, n: 2, scalar: \"f\" },\n vec3f: { align: 16, size: 12, n: 3, scalar: \"f\" },\n vec4f: { align: 16, size: 16, n: 4, scalar: \"f\" },\n // 4 columns of vec4f, column-major — what a projector matrix is uploaded as.\n mat4x4f: { align: 16, size: 64, n: 16, scalar: \"f\" },\n};\n\n/** A field type's layout: the table's, or a vec4f array's — N × 16 bytes, 4N floats, written as one flat list. */\nexport function typeInfo(type: FieldType): TypeInfo | undefined {\n if (type in TYPES) return TYPES[type as keyof typeof TYPES];\n const m = /^array<vec4f, (\\d+)>$/.exec(type);\n const n = m ? Number(m[1]) : 0;\n return n > 0 ? { align: 16, size: 16 * n, n: 4 * n, scalar: \"f\" } : undefined;\n}\n\nexport interface FieldSlot {\n readonly byte: number;\n readonly type: FieldType;\n readonly n: number;\n}\n\nexport type FieldValue = number | boolean | ArrayLike<number>;\nexport type StructValues<F extends string> = Partial<Record<F, FieldValue>>;\n\nexport interface StructDef<F extends string> {\n readonly name: string;\n readonly fields: ReadonlyArray<readonly [F, FieldType]>;\n /** Padded size in bytes; also the array stride. */\n readonly size: number;\n readonly slots: Readonly<Record<F, FieldSlot>>;\n /** `struct <name> { ... }` — prepend to any shader that binds this. */\n readonly wgsl: string;\n /** Backing storage for `count` elements. */\n alloc(count?: number): StructBuffer<F>;\n}\n\nexport interface StructBuffer<F extends string> {\n readonly def: StructDef<F>;\n readonly count: number;\n readonly bytes: ArrayBuffer;\n /** Write fields by name into element `index`. Unknown names and wrong arity throw. */\n set(values: StructValues<F>, index?: number): void;\n /** The byte view to upload; `elements` trims to a prefix of the array. */\n view(elements?: number): Uint8Array<ArrayBuffer>;\n}\n\nexport function defineStruct<F extends string>(\n name: string,\n fields: ReadonlyArray<readonly [F, FieldType]>,\n): StructDef<F> {\n let offset = 0;\n let maxAlign = 4;\n const slots = {} as Record<F, FieldSlot>;\n const seen = new Set<string>();\n for (const [field, type] of fields) {\n if (seen.has(field)) throw new Error(`struct ${name}: duplicate field \"${field}\"`);\n seen.add(field);\n const t = typeInfo(type);\n if (!t) throw new Error(`struct ${name}: unknown type ${String(type)} for \"${field}\"`);\n offset = Math.ceil(offset / t.align) * t.align;\n slots[field] = { byte: offset, type, n: t.n };\n offset += t.size;\n maxAlign = Math.max(maxAlign, t.align);\n }\n const size = Math.ceil(offset / 16) * 16;\n const width = Math.max(...fields.map(([f]) => f.length), 1);\n const wgsl =\n `struct ${name} {\\n${fields.map(([f, t]) => ` ${f.padEnd(width)} : ${t},`).join(\"\\n\")}\\n}\\n`;\n\n const def: StructDef<F> = {\n name, fields, size, slots, wgsl,\n alloc(count = 1) {\n const bytes = new ArrayBuffer(size * count);\n const f = new Float32Array(bytes);\n const i = new Int32Array(bytes);\n const u = new Uint32Array(bytes);\n return {\n def, count, bytes,\n set(values, index = 0) {\n if (index < 0 || index >= count) throw new Error(`struct ${name}: element ${index} outside 0..${count - 1}`);\n const base = (index * size) / 4;\n for (const key in values) {\n const slot = slots[key as F];\n if (!slot) throw new Error(`struct ${name}: no field \"${key}\"`);\n const v = values[key as F] as FieldValue;\n const at = base + slot.byte / 4;\n if (slot.n === 1) {\n const num = typeof v === \"boolean\" ? (v ? 1 : 0) : (v as number);\n if (typeof num !== \"number\") throw new Error(`struct ${name}: \"${key}\" wants a number`);\n const s = (typeInfo(slot.type) as TypeInfo).scalar;\n if (s === \"f\") f[at] = num; else if (s === \"i\") i[at] = num | 0; else u[at] = num >>> 0;\n } else {\n const arr = v as ArrayLike<number>;\n if (!arr || typeof arr.length !== \"number\" || arr.length !== slot.n) {\n throw new Error(`struct ${name}: \"${key}\" wants ${slot.n} components`);\n }\n for (let k = 0; k < slot.n; k++) f[at + k] = arr[k] as number;\n }\n }\n },\n view(elements = count) {\n return new Uint8Array(bytes, 0, Math.min(elements, count) * size);\n },\n };\n },\n };\n return def;\n}\n"],"mappings":";AAOA,IAAM,YAAY,CAAC,MACjB,MAAM,WAAW,eAAe,SAAS,MAAM,aAAa,eAAe,WAAW,eAAe;AAGvG,IAAM,WAAW,CAAC,UAA+B,UAAU,SAAY,CAAC,IAAI,EAAE,MAAM;AAU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