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, andisMotionValuefor value lifecycle and velocity trackinganimateSingleValuefor value-level animation start and stopstyleEffectandsvgEffectfor HTML and SVG DOM writesisVariantLabelandresolveVariantFromPropsfor variant label and function resolutionvariantPriorityOrderas the upstream reference point for lane orderingtransformValue,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:
isObjectreplaces the local object guard for target normalizationmemois 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, andsetActiveas 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:
motionValueanimateSingleValuestyleEffectsvgEffectisVariantLabelresolveVariantFromPropsisObject
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:
createAnimationStateupdateMotionValuesFromPropsanimateTargetanimateVariantresolveVariantDOMVisualElement,HTMLVisualElement, andSVGVisualElement
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-domowns 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:
- Keep the pure initial-style resolver separate from mounted runtime startup.
- Reuse
motion-domvariant helpers anywhere the current code still duplicates label or function resolution. - Add the first VisualElement-facing seam only after MotionState, MotionContext, and exit activation are stable.
- Revisit
variantPriorityOrderwhen gestures and presence become real, and either align with upstream ordering or document the deliberate Solid-specific difference.