{"_id":"o0o0o","_rev":"3-514ce11ef29379b3889f6a1579dc2d66","name":"o0o0o","dist-tags":{"latest":"0.2.2"},"versions":{"0.2.0":{"name":"o0o0o","version":"0.2.0","_id":"o0o0o@0.2.0","maintainers":[{"name":"kyooni18","email":"kyooni0118@gmail.com"}],"dist":{"shasum":"3b9114e6eef16eb8b0b16c8e86a932016b31f7cd","tarball":"https://registry.npmjs.org/o0o0o/-/o0o0o-0.2.0.tgz","fileCount":51,"integrity":"sha512-aQ9t7p6MH4APKgk59ymsd4vFPeKnYgT1xiME/PquoFgfVAsadutdeiHk5W1LsoFyL+82KI1wAJ6ATMOOjPPgzw==","signatures":[{"sig":"MEQCIEzfmyJzGLNcGp0dbzUWi0w/InrDoNmprkvW/laiKidEAiBcMjn4kHUe01Q0nk7VePODoZ0YQouIxF5ZtWOek2pxOQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":121143},"type":"module","types":"./index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./index.d.ts","default":"./src/index.js"},"./dom":{"types":"./src/dom/index.d.ts","default":"./src/dom/index.js"},"./wasm":{"types":"./src/wasm/index.d.ts","default":"./src/wasm/index.js"},"./layout":{"types":"./src/layout/index.d.ts","default":"./src/layout/index.js"},"./worker":{"types":"./src/worker/index.d.ts","default":"./src/worker/index.js"},"./interpolate":{"types":"./src/interpolate/index.d.ts","default":"./src/interpolate/index.js"}},"scripts":{"test":"node --test test/*.test.mjs","bench":"node bench/springs.mjs","typecheck":"tsc -p tsconfig.types.json","build:wasm":"bash wasm/build.sh","bench:worker":"node bench/worker-springs.mjs"},"_npmUser":{"name":"kyooni18","email":"kyooni0118@gmail.com"},"_npmVersion":"11.19.0","description":"Renderer-agnostic motion runtime with adaptive JS/WASM spring execution.","directories":{},"_nodeVersion":"26.7.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/o0o0o_0.2.0_1787679636896_0.6553023319610634","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"o0o0o","version":"0.2.1","_id":"o0o0o@0.2.1","maintainers":[{"name":"kyooni18","email":"kyooni0118@gmail.com"}],"dist":{"shasum":"97a93a5010d9dd46af935a839ae59c86cb8bc4dc","tarball":"https://registry.npmjs.org/o0o0o/-/o0o0o-0.2.1.tgz","fileCount":62,"integrity":"sha512-xgjuQDlysb/ZjrbRX6+Go27/D6SEK8kbP0gckreum7JfPhu9VGesorO9dFUERTz5KE0AjXJGgEXhuqBEDV+ylw==","signatures":[{"sig":"MEYCIQDgfrdyrmgqHlLJOz3HWZyuqujQYQ5KmO9VIKGuRtyMMwIhAKkNBI/7l99sR+OufW4b+ablZDHLcg7TXq8zhp4BreII","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":340108},"type":"module","types":"./index.d.ts","engines":{"node":">=20"},"exports":{".":{"types":"./index.d.ts","default":"./src/index.js"},"./dom":{"types":"./src/dom/index.d.ts","default":"./src/dom/index.js"},"./path":{"types":"./src/path/index.d.ts","default":"./src/path/index.js"},"./wasm":{"types":"./src/wasm/index.d.ts","default":"./src/wasm/index.js"},"./webgl":{"types":"./src/webgl/index.d.ts","default":"./src/webgl/index.js"},"./canvas":{"types":"./src/canvas/index.d.ts","default":"./src/canvas/index.js"},"./layout":{"types":"./src/layout/index.d.ts","default":"./src/layout/index.js"},"./scroll":{"types":"./src/scroll/index.d.ts","default":"./src/scroll/index.js"},"./webgpu":{"types":"./src/webgpu/index.d.ts","default":"./src/webgpu/index.js"},"./worker":{"types":"./src/worker/index.d.ts","default":"./src/worker/index.js"},"./gesture":{"types":"./src/gesture/index.d.ts","default":"./src/gesture/index.js"},"./material":{"types":"./src/material/index.d.ts","default":"./src/material/index.js"},"./timeline":{"types":"./src/timeline/index.d.ts","default":"./src/timeline/index.js"},"./transition":{"types":"./src/transition/index.d.ts","default":"./src/transition/index.js"},"./constraints":{"types":"./src/constraints/index.d.ts","default":"./src/constraints/index.js"},"./interpolate":{"types":"./src/interpolate/index.d.ts","default":"./src/interpolate/index.js"}},"scripts":{"test":"node --test test/*.test.mjs","bench":"node bench/springs.mjs","typecheck":"tsc -p tsconfig.types.json","bench:path":"node bench/path.mjs","build:wasm":"bash wasm/build.sh","bench:scroll":"node bench/scroll.mjs","bench:worker":"node bench/worker-springs.mjs","bench:gestures":"node bench/gestures.mjs","bench:timeline":"node bench/timeline.mjs","bench:renderers":"node bench/renderers.mjs","bench:constraints":"node bench/constraints.mjs","bench:transitions":"node bench/transitions.mjs"},"_npmUser":{"name":"kyooni18","email":"kyooni0118@gmail.com"},"_npmVersion":"11.19.0","description":"Renderer-agnostic adaptive motion runtime with JS/WASM/Worker execution, gestures, timelines, transitions, scroll linking, constraints, and GPU/canvas adapters.","directories":{},"sideEffects":false,"_nodeVersion":"26.7.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/o0o0o_0.2.1_1787713873743_0.5626079815080243","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"o0o0o","version":"0.2.2","type":"module","description":"Renderer-agnostic adaptive motion runtime with JS/WASM/Worker execution, gestures, timelines, transitions, scroll linking, constraints, and GPU/canvas adapters.","exports":{".":{"types":"./index.d.ts","default":"./src/index.js"},"./dom":{"types":"./src/dom/index.d.ts","default":"./src/dom/index.js"},"./interpolate":{"types":"./src/interpolate/index.d.ts","default":"./src/interpolate/index.js"},"./layout":{"types":"./src/layout/index.d.ts","default":"./src/layout/index.js"},"./worker":{"types":"./src/worker/index.d.ts","default":"./src/worker/index.js"},"./wasm":{"types":"./src/wasm/index.d.ts","default":"./src/wasm/index.js"},"./path":{"types":"./src/path/index.d.ts","default":"./src/path/index.js"},"./material":{"types":"./src/material/index.d.ts","default":"./src/material/index.js"},"./gesture":{"types":"./src/gesture/index.d.ts","default":"./src/gesture/index.js"},"./timeline":{"types":"./src/timeline/index.d.ts","default":"./src/timeline/index.js"},"./transition":{"types":"./src/transition/index.d.ts","default":"./src/transition/index.js"},"./scroll":{"types":"./src/scroll/index.d.ts","default":"./src/scroll/index.js"},"./constraints":{"types":"./src/constraints/index.d.ts","default":"./src/constraints/index.js"},"./canvas":{"types":"./src/canvas/index.d.ts","default":"./src/canvas/index.js"},"./webgl":{"types":"./src/webgl/index.d.ts","default":"./src/webgl/index.js"},"./webgpu":{"types":"./src/webgpu/index.d.ts","default":"./src/webgpu/index.js"}},"types":"./index.d.ts","scripts":{"build:wasm":"bash wasm/build.sh","test":"node --test test/*.test.mjs","bench":"node bench/springs.mjs","bench:worker":"node bench/worker-springs.mjs","typecheck":"tsc -p tsconfig.types.json","bench:path":"node bench/path.mjs","bench:gestures":"node bench/gestures.mjs","bench:timeline":"node bench/timeline.mjs","bench:transitions":"node bench/transitions.mjs","bench:constraints":"node bench/constraints.mjs","bench:scroll":"node bench/scroll.mjs","bench:renderers":"node bench/renderers.mjs"},"engines":{"node":">=20"},"sideEffects":false,"gitHead":"251be3654f0331456706a28b636b7c18c651e9db","_id":"o0o0o@0.2.2","_nodeVersion":"26.7.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-8F3k1f2M/F2P5LE+/SLYKPx+pExl7xshQFtvK18Yo4qJDZ+LN6ZVXdg/xTm7PcY11kTCFBj6Fa7RPT9hgenK1Q==","shasum":"90404fe90d7a38770b5c34e8846e0905dffc94ae","tarball":"https://registry.npmjs.org/o0o0o/-/o0o0o-0.2.2.tgz","fileCount":62,"unpackedSize":342847,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCH1z9x53EU5A8PkFJ4Lno1OhdpXg8ZAyhprpNaeXl3NQCIQCvGO2FHe2M4J+KvBwRPJ7JM1gi7to+ePJmxoVEEJX46w=="}]},"_npmUser":{"name":"kyooni18","email":"kyooni0118@gmail.com"},"directories":{},"maintainers":[{"name":"kyooni18","email":"kyooni0118@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/o0o0o_0.2.2_1787729503353_0.3843674758431084"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-25T17:40:36.740Z","modified":"2026-08-26T07:31:43.644Z","0.2.0":"2026-08-25T17:40:37.053Z","0.2.1":"2026-08-26T03:11:13.933Z","0.2.2":"2026-08-26T07:31:43.494Z"},"description":"Renderer-agnostic adaptive motion runtime with JS/WASM/Worker execution, gestures, timelines, transitions, scroll linking, constraints, and GPU/canvas adapters.","maintainers":[{"name":"kyooni18","email":"kyooni0118@gmail.com"}],"readme":"# Motion Runtime Prototype\n\nA renderer-agnostic motion runtime focused on interruptibility, low main-thread cost, smooth retargeting, and scalable execution. Vune can consume it through an adapter, but the core has no Vune, DOM, React, or Vue dependency.\n\n## Current state (0.2.2)\n\n### Numeric runtime\n\n- Numeric `MotionValue` with velocity tracking, detailed subscriptions, and allocation-free `subscribeValue()` listeners for hot render bindings.\n- Interruptible springs. Retargeting preserves current position and velocity.\n- Response/damping springs and low-level mass/stiffness/damping springs.\n- Distance-adaptive `smooth`, `snappy`, `bouncy`, `gentle`, and `interactive` profiles.\n- Cubic-bezier timing animations.\n- Analytic exponential decay and bounded inertia for release motion.\n- Exact damped-spring settling for low-count interaction physics, avoiding frame-rate-dependent substeps.\n- One scheduler for all active motion.\n- Dense spring storage with swap-remove.\n- Bounded solver substeps for bad frame-time spikes.\n- Reduced-motion support.\n\n### Adaptive execution backends\n\n- Zero-startup-cost JS spring kernel.\n- Lazy WebAssembly promotion for larger spring batches.\n- WebAssembly SIMD (`f32x4`) with scalar WASM fallback.\n- State remains in WASM linear memory after promotion; there is no per-frame full-buffer copy.\n- WASM memory grows on demand instead of imposing a fixed allocator ceiling.\n- Optional Worker + `SharedArrayBuffer` + shared `WebAssembly.Memory` path.\n- `worker: 'auto'` is now the default. It only prepares a Worker when workload crosses the threshold and gracefully stays on JS/WASM when shared memory is unavailable.\n- The normal auto scheduler can switch itself to asynchronous Worker frames after the shared backend is ready.\n- When a Worker frame is running, retarget/cancel/replace mutations are buffered to the frame boundary so the main thread never races the Worker over an in-flight shared slot.\n- Overlapping `stepAsync()` calls are serialized at the engine level as well as the backend level.\n- Supported environments use `Atomics.waitAsync()` for completion, eliminating the per-frame Worker `done` message. A message fallback remains for environments without it.\n- Worker failure restores authoritative `MotionValue` state before falling back to the local shared-WASM path.\n\n### Frame-budget governor\n\n`FrameBudgetGovernor` tracks an exponential moving average of main-thread motion cost. Under sustained pressure it can lower the promotion thresholds, moving medium workloads to WASM or the Worker earlier without changing public motion semantics.\n\n```js\nconst engine = new MotionEngine({\n  frameBudgetMs: 7,\n  adaptiveBackends: true,\n  wasmThreshold: 256,\n  workerThreshold: 4096,\n});\n\nconsole.log(engine.getBackendPlan());\n```\n\nThe governor does not skip frames or silently lower animation quality. It only changes where the same solver work runs.\n\n### Direct manipulation / gestures\n\nThe gesture package is renderer-agnostic. It turns pointer-like coordinates into `MotionValue` updates, release velocity, inertia, snapping, rubber-band bounds, and spring settling without knowing about DOM elements.\n\n- `VelocityTracker` uses a short recency-weighted regression window instead of a single event delta.\n- Tracking storage is a fixed-size typed-array ring buffer, so steady-state input sampling allocates no sample objects.\n- `DragController` supports x/y/both axes, direction locking, dynamic bounds, momentum, snapping, and rubber-band resistance.\n- Release motion preserves measured velocity and changes from decay to an exact damped spring only when a bound is crossed.\n- The DOM adapter consumes `PointerEvent.getCoalescedEvents()` when available, retaining high-frequency pen/touch samples that browsers may merge into one delivered event.\n\n```js\nimport { motionValue } from 'o0o0o';\nimport { createDragController } from 'o0o0o/gesture';\nimport { bindMotionStyles, bindPointerDrag } from 'o0o0o/dom';\n\nconst x = motionValue(0);\nconst drag = createDragController({\n  x,\n  axis: 'x',\n  bounds: { minX: 0, maxX: 480 },\n  snapX: [0, 160, 320, 480],\n});\n\nbindMotionStyles(card, { x });\nconst unbind = bindPointerDrag(card, drag);\n```\n\nThe numeric core also exposes release motion directly:\n\n```js\nimport { animateInertia } from 'o0o0o';\n\nanimateInertia(x, {\n  velocity: 1450, // units per second\n  min: 0,\n  max: 480,\n  timeConstant: 0.325,\n});\n```\n\n### Keyframes, phases, and timeline graph\n\n`Timeline` is a precompiled time-axis runtime rather than a Promise chain. Numeric keyframe times and values live in typed arrays, cubic-bezier curves are compiled once into shared lookup tables, and steady-state scalar sampling creates no timeline frame objects.\n\n- Multiple tracks on one timeline.\n- Nested timeline clips with offsets, playback speed, and fill policy.\n- `play()`, `pause()`, `seek()`, `scrub()`, `reverse()`, playback-rate changes, finite/infinite repeats, and alternate direction.\n- Exact numeric velocity propagation from keyframe tracks, so interrupting a timeline with a spring or inertia animation keeps motion continuity.\n- Bidirectional ownership arbitration: a timeline interrupts an older spring/timeline on the same `MotionValue`, and starting an engine animation interrupts the owning timeline.\n- Large frame gaps use wall-clock driver time while numerical spring integration keeps its safety clamp. Timelines therefore catch up after a suspended tab instead of playing in slow motion.\n- `PhaseTimeline` compiles named multi-property choreography with transition durations and holds.\n- `stagger()` supports first/last/center/index origins and optional easing.\n\n```js\nimport {\n  MotionEngine,\n  curves,\n  motionValue,\n  timeline,\n} from 'o0o0o';\n\nconst engine = new MotionEngine();\nconst x = motionValue(0);\nconst scale = motionValue(1);\n\nconst intro = timeline()\n  .fromTo(x, 0, 280, {\n    at: 0,\n    duration: 0.42,\n    easing: curves.smooth,\n  })\n  .fromTo(scale, 0.94, 1, {\n    at: 0.08,\n    duration: 0.28,\n    easing: curves.easeOut,\n  });\n\nconst player = intro.player({\n  engine,\n  iterations: 2,\n  direction: 'alternate',\n});\n\nplayer.play();\nplayer.scrub(0.5);  // deterministic seek, useful for interactive scrubbing\nplayer.reverse();\n```\n\nStructured values can use the same timeline through the existing interpolation layer:\n\n```js\nconst colorTimeline = timeline().fromTo(\n  (color) => panel.style.backgroundColor = color,\n  '#ff2d55',\n  '#5ac8fa',\n  { duration: 0.4, type: 'color', color: { space: 'oklab' } },\n);\n```\n\nNamed phases are convenient for reusable UI choreography:\n\n```js\nimport { createPhaseTimeline } from 'o0o0o/timeline';\n\nconst press = createPhaseTimeline({ scale, opacity }, [\n  { name: 'idle', values: { scale: 1, opacity: 1 } },\n  { name: 'pressed', duration: 0.10, hold: 0.04, values: { scale: 0.96, opacity: 0.88 } },\n  { name: 'release', duration: 0.18, values: { scale: 1, opacity: 1 } },\n]);\n\npress.player({ engine }).play();\n```\n\n\n\n\n\nTimeline playback can also be driven by a numeric interaction domain instead of a clock:\n\n```js\nimport { createTimelineScrubber } from 'o0o0o/timeline';\n\n// 0..400 can be drag pixels while the timeline remains normalized internally.\nconst scrubber = createTimelineScrubber(player, {\n  min: 0,\n  max: 400,\n  snapPoints: [0, 400],\n});\n\nscrubber.set(160, 900);\nscrubber.release(); // bounded inertia -> nearest snap point\n```\n\nThe scrubber only depends on a `MotionValue`; a `DragController`, gamepad axis, scroll position, or custom input source can all drive it.\n\n### State transitions and presence\n\nThe transition package adds named UI state motion without making the numeric core aware of components or renderers. Numeric `MotionValue` bindings are animated directly, so every property retains its own velocity during interruption. Structured bindings (colors, transforms, materials, paths, or custom interpolators) share one precompiled scalar progress animation per state change.\n\n```js\nimport { motionValue, spring } from 'o0o0o';\nimport { createStateTransitionGraph } from 'o0o0o/transition';\n\nconst x = motionValue(0);\nconst opacity = motionValue(0);\n\nconst panel = createStateTransitionGraph({ x, opacity }, {\n  hidden: { x: 24, opacity: 0 },\n  visible: { x: 0, opacity: 1 },\n  focused: { x: 0, opacity: 0.92 },\n}, {\n  initial: 'hidden',\n  routes: {\n    'hidden->visible': spring({ response: 0.32, dampingRatio: 0.82 }),\n    '*->hidden': spring({ response: 0.24, dampingRatio: 0.9 }),\n  },\n});\n\npanel.to('visible');\n```\n\n`TransitionController` is the two-state enter/exit convenience layer. Reversing an enter while it is still moving retargets the same numeric `MotionValue`s instead of restarting them from rest.\n\n```js\nimport { createPresence, createTransition } from 'o0o0o/transition';\n\nconst transition = createTransition([\n  { key: 'opacity', target: opacity, from: 0, to: 1 },\n  { key: 'scale', target: scale, from: 0.96, to: 1 },\n]);\n\nconst presence = createPresence(transition);\npresence.enter();\n\n// `rendered` stays true until exit motion actually finishes.\nconst exit = presence.exit();\nawait exit.finished;\nconsole.log(presence.rendered); // false\n```\n\nIf enter is requested during exit, the pending unmount is invalidated and the same values reverse smoothly.\n\n### Structured interpolation\n\n- Numbers.\n- CSS colors: hex, rgb/rgba, hsl/hsla and common basic named colors.\n- `srgb`, linear-light `linear-srgb`, `oklab`, and `oklch` interpolation.\n- OKLab is the default color path for visually even transitions.\n- Transparent endpoint chroma borrowing avoids the usual transparent-black fade halo.\n- 2D CSS transform matrix composition/decomposition.\n- Common 3D transform components.\n- Shortest-path angle interpolation by default.\n- Materials: blur, saturation, brightness, contrast and perceptual tint interpolation driven by a single progress value.\n- SVG path morphing with one-time command normalization to cubic curves.\n- `animateInterpolated()` drives structured output through the same scalar motion runtime.\n\n### SVG path morphing\n\nPath parsing and topology work happen once. Per-frame numeric sampling only lerps a reusable typed buffer.\n\nSupported input commands include `M/L/H/V/C/S/Q/T/A/Z`, absolute or relative. Lines, quadratics and arcs normalize to cubic segments. Paths with different segment counts are equalized by splitting cubic curves. Closed paths can align starting segments and reverse winding to avoid needlessly long morphs.\n\n```js\nimport { createPathMorpher } from 'o0o0o/path';\n\nconst morph = createPathMorpher(\n  'M0 0 L100 0 L100 100 Z',\n  'M20 10 C80 -20 120 60 80 120 Z',\n);\n\n// Allocation-free numeric sampling for Canvas/WebGL/custom renderers.\nconst coordinates = morph.sampleInto(0.5);\n\n// SVG DOM route. Formatting is done only when a path string is needed.\nconst d = morph.sample(0.5);\n```\n\nFor very large closed paths, alignment uses a bounded set of promising start-index candidates instead of exhaustive O(n^2) matching.\n\n### Materials\n\nThe material model is renderer-agnostic. Presets are only convenient starting values.\n\n```js\nimport { materials, mixMaterial } from 'o0o0o/material';\n\nconst material = mixMaterial(materials.ultraThin, materials.glass, 0.5);\n```\n\nThe DOM adapter maps a resolved material to `backdrop-filter` plus a tint color:\n\n```js\nimport { animateMaterial } from 'o0o0o/dom';\nimport { smooth } from 'o0o0o';\n\nanimateMaterial(panel, 'ultraThin', 'glass', smooth());\n```\n\n### Layout / FLIP\n\n- `LayoutTransition` captures first and last bounds in separate read phases.\n- Writes begin only after all last bounds have been measured.\n- Position and size projection.\n- Existing transforms are preserved and restored.\n- Page-scroll compensation.\n- Nested projection correction: an animated child removes the selected ancestor's projection instead of double-transforming.\n- Interrupting an older layout transition captures the current visual rectangle before restoring the previous projection.\n\n\n\nMatched geometry across different element instances uses keyed snapshots:\n\n```js\nimport {\n  captureSharedLayout,\n  createSharedLayoutTransition,\n} from 'o0o0o/layout';\n\nconst before = captureSharedLayout(oldTree, {\n  key: (element) => element.dataset.motionKey,\n});\n\n// mutate / replace the tree here\n\nconst shared = createSharedLayoutTransition(before, newTree, {\n  key: (element) => element.dataset.motionKey,\n  fadeTarget: true,\n});\nshared.play();\n```\n\nThe source element does not have to remain mounted. All matched targets in one shared transition use a single progress animation; each target only evaluates its projection matrix during the write phase. Duplicate source or target keys are rejected instead of being matched ambiguously. If a matched transition is interrupted, the next transition captures the currently rendered target geometry before cancelling the old projection so it can continue without jumping back to the underlying layout box.\n\n### DOM adapter\n\n- x/y/z, scale3d, rotateX/Y/Z bindings.\n- Direct numeric style bindings with units.\n- Structured `animateStyle()` for colors/transforms.\n- `animateMaterial()` and `applyMaterial()`.\n- `animatePath()` / `animateAttribute()` for SVG and other attributes.\n- WAAPI escape hatch for fixed compositor-friendly keyframes.\n- One global dirty-element queue: updating thousands of bound elements does not enqueue one microtask per element.\n- Dirty compositor writes: direct/attribute updates do not reserialize transforms, and `will-change` is limited to the bound transform/opacity properties.\n- Optional RAF-based DOM commit mode.\n- Pointer-drag binding with pointer capture, touch-action management, cancellation handling, and coalesced-event sampling.\n\n```js\nimport { configureDomBatching } from 'o0o0o/dom';\n\nconfigureDomBatching({ scheduler: 'raf' });\n```\n\n## Basic numeric API\n\n```js\nimport { motionValue, animate, smooth, spring } from 'o0o0o';\n\nconst x = motionValue(0);\n\nx.subscribe((value, { velocity }) => {\n  console.log(value, velocity);\n});\n\n// Hot render bindings that only need the value avoid allocating metadata.\nx.subscribeValue((value) => render(value));\n\nanimate(x, 600, smooth());\n\n// Retarget while moving. Existing velocity is kept.\nsetTimeout(() => {\n  animate(x, -120, spring({\n    response: 0.34,\n    dampingRatio: 0.8,\n  }));\n}, 120);\n```\n\nFor deterministic/manual stepping:\n\n```js\nimport { MotionEngine, motionValue, spring } from 'o0o0o';\n\nconst engine = new MotionEngine({ autoStart: false, wasm: false, worker: false });\nconst x = motionValue(0);\n\nengine.animate(x, 100, spring());\nfor (let frame = 0; frame < 120; frame += 1) {\n  engine.step(1000 / 60);\n}\n```\n\n## Color, transform, path, and material interpolation\n\n```js\nimport { animateInterpolated, smooth } from 'o0o0o';\n\nanimateInterpolated(\n  '#ff2d55',\n  '#5ac8fa',\n  smooth(),\n  (color) => {\n    element.style.backgroundColor = color;\n  },\n  { type: 'color', color: { space: 'oklab' } },\n);\n```\n\nTransforms can be strings or component objects. A `350deg -> 10deg` rotation takes the short 20-degree route by default.\n\nPath and material values use the same progress-channel mechanism:\n\n```js\nanimateInterpolated(fromPath, toPath, smooth(), updatePath, {\n  type: 'path',\n  path: { precision: 2 },\n});\n\nanimateInterpolated('clear', 'glass', smooth(), updateMaterial, {\n  type: 'material',\n});\n```\n\n## Layout animation\n\n```js\nimport { smooth } from 'o0o0o';\nimport { animateLayout } from 'o0o0o/layout';\n\nconst { controls } = animateLayout(\n  [sidebar, content],\n  () => root.classList.toggle('expanded'),\n  { spec: smooth() },\n);\n\nawait controls?.finished;\n```\n\nThe numeric core does not know that this is a layout animation.\n\n## Worker + shared WASM\n\nFor normal browser use, `worker: 'auto'` lets the engine decide when to prepare and use the Worker. Explicit manual control is still available:\n\n```js\nconst engine = new MotionEngine({\n  autoStart: false,\n  wasm: 'auto',\n  worker: true,\n  workerThreshold: 4096,\n});\n\nawait engine.prepareWorker();\n\nconst values = Array.from({ length: 10000 }, () => motionValue(0));\nfor (const value of values) engine.animate(value, 200, spring());\n\nawait engine.stepAsync(1000 / 60);\n```\n\nThe Worker and main thread instantiate the same kernel over the same shared `WebAssembly.Memory`. Spring state itself never crosses `postMessage`.\n\nWhen `Atomics.waitAsync()` exists, the completion path is:\n\n```text\nmain                         worker\n |                             |\n | count + dt + sequence       |\n | Atomics.notify -----------> |\n |                             | step_springs(...)\n |                             | store(doneSequence)\n | <---------- Atomics.notify  |\n | resume                      |\n```\n\nWithout `Atomics.waitAsync()`, the backend uses the previous tiny `done` message as a fallback.\n\n### Browser requirements for shared Worker execution\n\nShared WASM memory requires `SharedArrayBuffer`. On the web that normally means a secure, cross-origin-isolated page, for example:\n\n```text\nCross-Origin-Opener-Policy: same-origin\nCross-Origin-Embedder-Policy: require-corp\n```\n\nIf shared memory is unavailable, `worker: 'auto'` keeps the regular JS/WASM execution path.\n\n\n## Scroll-driven motion\n\n`ScrollTracker` is renderer-independent: it maps an arbitrary scalar offset to a normalized `MotionValue`, while preserving offset and normalized velocity. The DOM/window `ScrollObserver` is a thin adapter that coalesces bursts of scroll events into one metric read per animation frame.\n\n```js\nimport { observeScroll, bindScrollTimeline } from 'o0o0o/scroll';\n\nconst scroll = observeScroll(scroller, {\n  axis: 'y',\n  start: 0,\n  end: (metrics) => metrics.max,\n});\n\n// player stays paused; scroll position deterministically seeks it.\nconst link = bindScrollTimeline(player, scroll);\n```\n\nThe range may be dynamic, so resizes/content growth can be reflected on the next sampled frame without rebuilding the tracker. `ScrollTracker` itself can also be fed from a virtual scroller, game camera, native shell, or any other numeric source.\n\n## Constraint graph\n\n`ConstraintGraph` evaluates relationships between numeric values after source motion commits. The graph is compiled once into a topological operation order and typed arrays, rather than chaining one subscription callback per relationship.\n\n```js\nimport { createConstraintGraph } from 'o0o0o/constraints';\n\nconst graph = createConstraintGraph();\nconst leader = graph.node(x, { name: 'leader' });\nconst follower = graph.node(y, { name: 'follower' });\nconst opacityNode = graph.node(opacity);\n\ngraph\n  .affine(follower, leader, { scale: 0.5, offset: 24 })\n  .clamp(opacityNode, follower, { min: 0, max: 1 })\n  .attach(engine);\n```\n\nBuilt-in relations include affine/follow, clamp, weighted sum, mix, and custom mapping. Numeric velocity is propagated analytically through the built-in relations. This means a derived value can be interrupted by spring/inertia motion without first losing its instantaneous velocity.\n\nThe topology is intentionally locked after the first compile/evaluate. Runtime work is then just typed-array reads, a compact operation switch, and writes to bound outputs. Cycles are rejected at compile time.\n\n## Canvas / WebGL / WebGPU adapters\n\nRenderer adapters remain outside the motion solver. They subscribe through the value-only hot path and coalesce changes so a burst of `MotionValue` commits does not create one render submission per value.\n\nCanvas keeps one retained `Float64Array` snapshot and invokes one draw callback per dirty frame:\n\n```js\nimport { createCanvasRenderer } from 'o0o0o/canvas';\n\nconst renderer = createCanvasRenderer(ctx, [x, y, scale], (ctx, values) => {\n  const [x, y, scale] = values;\n  // draw using the retained numeric snapshot\n});\n```\n\nWebGL resolves uniform locations once and batches dirty uniform uploads:\n\n```js\nimport { createWebGLUniformBinder } from 'o0o0o/webgl';\n\nconst uniforms = createWebGLUniformBinder(gl, program, [\n  { name: 'uProgress', value: progress },\n  { name: 'uPosition', values: [x, y] },\n]);\n```\n\nWebGPU packs scalar values into one retained `Float32Array` and emits one `queue.writeBuffer()` per dirty frame:\n\n```js\nimport { createWebGPUBufferBinder } from 'o0o0o/webgpu';\n\nconst gpuValues = createWebGPUBufferBinder(device, uniformBuffer, [\n  { value: x, index: 0 },\n  { value: y, index: 1 },\n  { value: opacity, index: 4 }, // explicit padding/layout is allowed\n], { floatCount: 8 });\n```\n\nThese packages are renderer bridges, not a GPU physics backend. A future WebGPU compute solver can be added independently for particle/mesh workloads large enough to amortize dispatch overhead.\n\n## Package entry points\n\n```text\no0o0o\no0o0o/dom\no0o0o/interpolate\no0o0o/layout\no0o0o/gesture\no0o0o/timeline\no0o0o/transition\no0o0o/scroll\no0o0o/constraints\no0o0o/canvas\no0o0o/webgl\no0o0o/webgpu\no0o0o/material\no0o0o/path\no0o0o/wasm\no0o0o/worker\n```\n\n## Build / test / benchmark\n\n```sh\nnpm run build:wasm\nnpm test\nnpm run typecheck\nnpm run bench -- 10000 600\nnpm run bench:worker -- 10000 300\nnpm run bench:path -- 256 10000\nnpm run bench:gestures -- 500000\nnpm run bench:timeline -- 10000 600\nnpm run bench:transitions -- 10000 1000\nnpm run bench:constraints -- 10000 1000\nnpm run bench:scroll -- 500000\nnpm run bench:renderers -- 1000 500\n```\n\n`build:wasm` emits four binaries:\n\n```text\nkernel-scalar.wasm\nkernel-simd.wasm\nkernel-shared-scalar.wasm\nkernel-shared-simd.wasm\n```\n\nThe numeric benchmarks intentionally exclude browser layout, paint, compositing, input, and framework overhead.\n\n## Deliberately outside the numeric core\n\nRenderer-specific layout measurement, DOM style parsing, material rendering, path rendering, and framework bindings remain adapters or optional packages. Canvas/WebGL/WebGPU now have lightweight value-to-renderer bridges, while GPU compute simulation intentionally remains outside the numeric core.\n\nThe next useful layers are a true WebGPU compute backend for massive particle/mesh fields, richer rotated/skewed shared-layout geometry, declarative constraint presets, and framework bindings such as Vune.\n","readmeFilename":"README.md"}