# motion-dom and motion-utils source map This note records what the local `motion-dom` and `motion-utils` packages already solve for us, what still needs a Solid-specific layer, and where the current Solid MotionState should stop duplicating upstream behavior. The practical benefit is simple: when we add more runtime features, we can reuse the right Motion primitives instead of slowly rebuilding a second animation engine beside them. ## Problem The current Solid runtime needs three different kinds of behavior: - framework-neutral animation primitives such as `MotionValue`, per-value animation control, and DOM style writers - framework-owned behavior such as Solid accessor resolution, lifecycle timing, and retained host ownership - feature orchestration such as variants, initial visual state, gestures, presence, and layout Without a source map, it is easy to rebuild all three inside the Solid adapter even when `motion-dom` already provides most of the first category and part of the third. ## What motion-dom already gives us These exports are available from the package root and are safe to use from a non-React, non-Vue adapter: - `motionValue`, `MotionValue`, and `isMotionValue` for value lifecycle and velocity tracking - `animateSingleValue` for value-level animation start and stop - `styleEffect` and `svgEffect` for HTML and SVG DOM writes - `isVariantLabel` and `resolveVariantFromProps` for variant label and function resolution - `variantPriorityOrder` as the upstream reference point for lane ordering - `transformValue`, `mapValue`, `springValue`, `frame`, and related value utilities for later feature work These are framework-neutral because they operate on plain values, DOM elements, or MotionValue instances. They do not require React hooks or Vue component instances. ## What motion-utils already gives us `motion-utils` is a pure utility layer. The current Solid runtime only needs a small part of it today, but it is still useful to keep the overlap explicit: - `isObject` replaces the local object guard for target normalization - `memo` is available if we later need one-time derived tables or lookup structures - other helpers are generic math and easing utilities rather than framework code ## Where the current Solid runtime was overlapping Before the current refactor, the Solid state file was doing all of this in one place: - normalizing raw Motion options - resolving variant labels - deciding the active lane - managing DOM renderer lifetime - maintaining the scalar MotionValue renderer - preparing for SSR and hydration even though that work must stay pure That shape made it hard to tell which behavior belonged to Motion itself and which behavior had to stay Solid-specific. ## What stays Solid-specific These behaviors still need a Solid-owned layer even after reusing more Motion primitives: - resolving accessor props such as `animate={() => ...}` inside Solid tracking rules - separating render-time initial style resolution from mount-time Motion startup - keeping one stable MotionState across host element swaps - exposing `mount`, `unmount`, `updateOptions`, and `setActive` as the Solid runtime contract - coordinating future presence, retained rendering, and layout invalidation with Solid ownership rules This is the real adapter boundary. `motion-dom` can animate and render values, but it does not know when a Solid ref becomes available or when a retained subtree should stay logically alive after control-flow removal. ## What we should reuse now The current Solid runtime should keep reusing these immediately: - `motionValue` - `animateSingleValue` - `styleEffect` - `svgEffect` - `isVariantLabel` - `resolveVariantFromProps` - `isObject` These give us a good narrow foundation without forcing us to adopt the full VisualElement stack before the Solid state and context layers are ready. ## What we should not reuse directly yet Some `motion-dom` helpers are valuable reference points but still assume a VisualElement-based runtime: - `createAnimationState` - `updateMotionValuesFromProps` - `animateTarget` - `animateVariant` - `resolveVariant` - `DOMVisualElement`, `HTMLVisualElement`, and `SVGVisualElement` These are not wrong for Solid. They are simply one layer higher than the current runtime. Using them directly now would force us to fake a VisualElement protocol before the Solid MotionState, context, and presence boundaries are actually in place. ## Current decision The current implementation uses this split: - Solid owns MotionState lifecycle, option snapshots, lane activation, and initial-style resolution. - `motion-dom` owns MotionValue behavior, single-value animation control, and DOM writes. - The scalar renderer stays as an internal bridge until the real VisualElement layer exists. That is a narrower and more honest boundary than either extreme: - not rebuilding Motion primitives from scratch - not pretending the current Solid runtime already has a full VisualElement architecture ## Immediate follow-up When the next runtime steps land, use this order: 1. Keep the pure initial-style resolver separate from mounted runtime startup. 2. Reuse `motion-dom` variant helpers anywhere the current code still duplicates label or function resolution. 3. Add the first VisualElement-facing seam only after MotionState, MotionContext, and exit activation are stable. 4. Revisit `variantPriorityOrder` when gestures and presence become real, and either align with upstream ordering or document the deliberate Solid-specific difference.