motion-dom 14.6.0 → 14.7.1

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.
Files changed (86) hide show
  1. package/dist/cjs/index.js +574 -580
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/es/animation/AsyncMotionValueAnimation.mjs +3 -6
  4. package/dist/es/animation/AsyncMotionValueAnimation.mjs.map +1 -1
  5. package/dist/es/animation/JSAnimation.mjs +18 -30
  6. package/dist/es/animation/JSAnimation.mjs.map +1 -1
  7. package/dist/es/animation/NativeAnimation.mjs +4 -4
  8. package/dist/es/animation/NativeAnimation.mjs.map +1 -1
  9. package/dist/es/animation/animate/effects.mjs +5 -2
  10. package/dist/es/animation/animate/effects.mjs.map +1 -1
  11. package/dist/es/animation/generators/inertia.mjs +3 -2
  12. package/dist/es/animation/generators/inertia.mjs.map +1 -1
  13. package/dist/es/animation/generators/spring.mjs +40 -44
  14. package/dist/es/animation/generators/spring.mjs.map +1 -1
  15. package/dist/es/animation/interfaces/visual-element-target.mjs +1 -1
  16. package/dist/es/animation/interfaces/visual-element-target.mjs.map +1 -1
  17. package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs +7 -15
  18. package/dist/es/animation/keyframes/DOMKeyframesResolver.mjs.map +1 -1
  19. package/dist/es/animation/keyframes/KeyframesResolver.mjs.map +1 -1
  20. package/dist/es/animation/utils/can-animate.mjs +1 -0
  21. package/dist/es/animation/utils/can-animate.mjs.map +1 -1
  22. package/dist/es/animation/utils/css-variables-conversion.mjs +2 -1
  23. package/dist/es/animation/utils/css-variables-conversion.mjs.map +1 -1
  24. package/dist/es/animation/utils/is-transition-defined.mjs +1 -0
  25. package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
  26. package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +45 -21
  27. package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
  28. package/dist/es/animation/waapi/transforms/groups.mjs.map +1 -1
  29. package/dist/es/animation/waapi/utils/accelerated-values.mjs +4 -1
  30. package/dist/es/animation/waapi/utils/accelerated-values.mjs.map +1 -1
  31. package/dist/es/effects/style/transform.mjs +4 -20
  32. package/dist/es/effects/style/transform.mjs.map +1 -1
  33. package/dist/es/gestures/drag/VisualElementDragControls.mjs +78 -61
  34. package/dist/es/gestures/drag/VisualElementDragControls.mjs.map +1 -1
  35. package/dist/es/gestures/pan/PanSession.mjs +28 -39
  36. package/dist/es/gestures/pan/PanSession.mjs.map +1 -1
  37. package/dist/es/index.mjs +1 -1
  38. package/dist/es/layout/LayoutAnimationBuilder.mjs +2 -2
  39. package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
  40. package/dist/es/projection/animation/mix-values.mjs +3 -11
  41. package/dist/es/projection/animation/mix-values.mjs.map +1 -1
  42. package/dist/es/projection/geometry/delta-apply.mjs +10 -6
  43. package/dist/es/projection/geometry/delta-apply.mjs.map +1 -1
  44. package/dist/es/projection/geometry/delta-calc.mjs +2 -2
  45. package/dist/es/projection/geometry/delta-calc.mjs.map +1 -1
  46. package/dist/es/projection/geometry/delta-remove.mjs +2 -2
  47. package/dist/es/projection/geometry/delta-remove.mjs.map +1 -1
  48. package/dist/es/projection/node/HTMLProjectionNode.mjs +1 -1
  49. package/dist/es/projection/node/HTMLProjectionNode.mjs.map +1 -1
  50. package/dist/es/projection/node/create-projection-node.mjs +147 -138
  51. package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
  52. package/dist/es/projection/styles/transform.mjs +12 -16
  53. package/dist/es/projection/styles/transform.mjs.map +1 -1
  54. package/dist/es/projection/utils/has-transform.mjs +16 -2
  55. package/dist/es/projection/utils/has-transform.mjs.map +1 -1
  56. package/dist/es/render/VisualElement.mjs +20 -37
  57. package/dist/es/render/VisualElement.mjs.map +1 -1
  58. package/dist/es/render/dom/parse-transform.mjs +6 -17
  59. package/dist/es/render/dom/parse-transform.mjs.map +1 -1
  60. package/dist/es/render/html/HTMLVisualElement.mjs +2 -1
  61. package/dist/es/render/html/HTMLVisualElement.mjs.map +1 -1
  62. package/dist/es/render/html/utils/build-transform.mjs +25 -29
  63. package/dist/es/render/html/utils/build-transform.mjs.map +1 -1
  64. package/dist/es/render/utils/animation-state.mjs +57 -13
  65. package/dist/es/render/utils/animation-state.mjs.map +1 -1
  66. package/dist/es/utils/interpolate.mjs +2 -1
  67. package/dist/es/utils/interpolate.mjs.map +1 -1
  68. package/dist/es/utils/mix/color.mjs +2 -1
  69. package/dist/es/utils/mix/color.mjs.map +1 -1
  70. package/dist/es/utils/mix/complex.mjs +4 -4
  71. package/dist/es/utils/mix/complex.mjs.map +1 -1
  72. package/dist/es/utils/resolve-elements.mjs.map +1 -1
  73. package/dist/es/value/index.mjs +13 -34
  74. package/dist/es/value/index.mjs.map +1 -1
  75. package/dist/es/value/types/color/hex.mjs +13 -26
  76. package/dist/es/value/types/color/hex.mjs.map +1 -1
  77. package/dist/es/value/types/complex/index.mjs +1 -1
  78. package/dist/es/value/types/complex/index.mjs.map +1 -1
  79. package/dist/index.d.ts +72 -21
  80. package/dist/motion-dom.dev.js +558 -573
  81. package/dist/motion-dom.js +1 -1
  82. package/dist/size-rollup-motion-value.js +1 -1
  83. package/dist/size-rollup-motion-value.js.map +1 -1
  84. package/dist/size-rollup-style-effect.js +1 -1
  85. package/dist/size-rollup-style-effect.js.map +1 -1
  86. package/package.json +4 -3
@@ -52,7 +52,7 @@ class MotionValue {
52
52
  this.setCurrent(v);
53
53
  // Update update subscribers
54
54
  if (this.current !== this.prev) {
55
- this.notifyChange();
55
+ this.dirty();
56
56
  if (this.dependents) {
57
57
  for (const dependent of this.dependents) {
58
58
  dependent.dirty();
@@ -190,12 +190,9 @@ class MotionValue {
190
190
  * @public
191
191
  */
192
192
  set(v) {
193
- if (!this.passiveEffect) {
194
- this.updateAndNotify(v);
195
- }
196
- else {
197
- this.passiveEffect(v, this.updateAndNotify);
198
- }
193
+ this.passiveEffect
194
+ ? this.passiveEffect(v, this.updateAndNotify)
195
+ : this.updateAndNotify(v);
199
196
  }
200
197
  setWithVelocity(prev, current, delta) {
201
198
  this.set(current);
@@ -212,13 +209,9 @@ class MotionValue {
212
209
  this.prev = v;
213
210
  this.prevUpdatedAt = this.prevFrameValue = undefined;
214
211
  endAnimation && this.stop();
215
- if (this.stopPassiveEffect)
216
- this.stopPassiveEffect();
212
+ this.stopPassiveEffect?.();
217
213
  }
218
214
  dirty() {
219
- this.notifyChange();
220
- }
221
- notifyChange() {
222
215
  const { current, changeSubscriber } = this;
223
216
  /**
224
217
  * One or the other exists. Subscribing during the direct
@@ -233,15 +226,10 @@ class MotionValue {
233
226
  }
234
227
  }
235
228
  addDependent(dependent) {
236
- if (!this.dependents) {
237
- this.dependents = new Set();
238
- }
239
- this.dependents.add(dependent);
229
+ (this.dependents || (this.dependents = new Set())).add(dependent);
240
230
  }
241
231
  removeDependent(dependent) {
242
- if (this.dependents) {
243
- this.dependents.delete(dependent);
244
- }
232
+ this.dependents?.delete(dependent);
245
233
  }
246
234
  /**
247
235
  * Returns the latest state of `MotionValue`
@@ -251,9 +239,7 @@ class MotionValue {
251
239
  * @public
252
240
  */
253
241
  get() {
254
- if (collectMotionValues.current) {
255
- collectMotionValues.current.push(this);
256
- }
242
+ collectMotionValues.current?.push(this);
257
243
  /**
258
244
  * A value animating on the compositor isn't updated every frame,
259
245
  * so read it from its animation.
@@ -319,7 +305,7 @@ class MotionValue {
319
305
  isComplete = true;
320
306
  this.events.animationComplete?.notify();
321
307
  if (this.animation === animation)
322
- this.clearAnimation();
308
+ this.animation = undefined;
323
309
  resolve();
324
310
  });
325
311
  if (!isComplete)
@@ -335,11 +321,10 @@ class MotionValue {
335
321
  stop() {
336
322
  if (this.animation) {
337
323
  this.animation.stop();
338
- if (this.events.animationCancel) {
339
- this.events.animationCancel.notify();
340
- }
324
+ this.events.animationCancel?.notify();
341
325
  }
342
- this.clearAnimation();
326
+ // Assign rather than delete to keep the object's shape stable
327
+ this.animation = undefined;
343
328
  }
344
329
  /**
345
330
  * Returns `true` if this value is currently animating.
@@ -349,10 +334,6 @@ class MotionValue {
349
334
  isAnimating() {
350
335
  return !!this.animation;
351
336
  }
352
- clearAnimation() {
353
- // Assign rather than delete to keep the object's shape stable
354
- this.animation = undefined;
355
- }
356
337
  /**
357
338
  * Destroy and clean up subscribers to this `MotionValue`.
358
339
  *
@@ -367,9 +348,7 @@ class MotionValue {
367
348
  this.events.destroy?.notify();
368
349
  this.clearListeners();
369
350
  this.stop();
370
- if (this.stopPassiveEffect) {
371
- this.stopPassiveEffect();
372
- }
351
+ this.stopPassiveEffect?.();
373
352
  }
374
353
  }
375
354
  function motionValue(init, options) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/value/index.ts"],"sourcesContent":["import {\n EasingFunction,\n SubscriptionManager,\n velocityPerSecond,\n warnOnce,\n} from \"motion-utils\"\nimport {\n AnimationPlaybackControlsWithThen,\n AnyResolvedKeyframe,\n MotionValueAnimation,\n TransformProperties,\n} from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { time } from \"../frameloop/sync-time\"\n\n/**\n * @public\n */\nexport type Subscriber<T> = (v: T) => void\n\n/**\n * @public\n */\nexport type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void\n\nexport type StartAnimation = (\n complete: () => void\n) => AnimationPlaybackControlsWithThen | undefined\n\nexport interface MotionValueEventCallbacks<V> {\n animationStart: () => void\n animationComplete: () => void\n animationCancel: () => void\n change: (latestValue: V) => void\n destroy: () => void\n}\n\n/**\n * Maximum time between the value of two frames, beyond which we\n * assume the velocity has since been 0.\n */\nconst MAX_VELOCITY_DELTA = 30\n\nconst isFloat = (value: any): value is string => {\n return !isNaN(parseFloat(value))\n}\n\ninterface ResolvedValues {\n [key: string]: AnyResolvedKeyframe\n}\n\nexport interface Owner {\n current: HTMLElement | unknown\n getProps: () => {\n onUpdate?: (latest: ResolvedValues) => void\n transformTemplate?: (\n transform: TransformProperties,\n generatedTransform: string\n ) => string\n }\n}\n\nexport interface AccelerateConfig {\n factory: (animation: AnimationPlaybackControlsWithThen) => VoidFunction\n times: number[]\n keyframes: any[]\n ease?: EasingFunction | EasingFunction[]\n duration: number\n isTransformed?: boolean\n}\n\nexport interface MotionValueOptions {\n owner?: Owner\n}\n\nexport const collectMotionValues: { current: MotionValue[] | undefined } = {\n current: undefined,\n}\n\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue<V = any> {\n /**\n * If a MotionValue has an owner, it was created internally within Motion\n * and therefore has no external listeners. It is therefore safe to animate via WAAPI.\n */\n owner?: Owner\n\n /**\n * The current state of the `MotionValue`.\n */\n private current: V | undefined\n\n /**\n * The previous state of the `MotionValue`.\n */\n private prev: V | undefined\n\n /**\n * The previous state of the `MotionValue` at the end of the previous frame.\n */\n private prevFrameValue: V | undefined\n\n /**\n * The last time the `MotionValue` was updated.\n */\n updatedAt: number\n\n /**\n * The time `prevFrameValue` was updated.\n */\n prevUpdatedAt: number | undefined\n\n /**\n * Add a passive effect to this `MotionValue`.\n *\n * A passive effect intercepts calls to `set`. For instance, `useSpring` adds\n * a passive effect that attaches a `spring` to the latest\n * set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.\n *\n * @internal\n */\n private passiveEffect?: PassiveEffect<V>\n private stopPassiveEffect?: VoidFunction\n\n /**\n * Whether the passive effect is active.\n */\n isEffectActive?: boolean\n\n /**\n * A reference to the currently-controlling animation.\n */\n animation?: MotionValueAnimation\n\n /**\n * The sole `change` subscriber. Most values have exactly one (an\n * effect or a follower), so it's stored and notified directly. A\n * SubscriptionManager is only created for a second subscriber.\n */\n private changeSubscriber?: Subscriber<V>\n\n /**\n * Tracks whether this value can output a velocity. Currently this is only true\n * if the value is numerical, but we might be able to widen the scope here and support\n * other value types.\n *\n * @internal\n */\n private canTrackVelocity: boolean | null = null\n\n /**\n * A list of MotionValues whose values are computed from this one.\n * This is a rough start to a proper signal-like dirtying system.\n */\n private dependents: Set<MotionValue> | undefined\n\n /**\n * Tracks whether this value should be removed\n */\n liveStyle?: boolean\n\n /**\n * Scroll timeline acceleration metadata. When set, VisualElement\n * can create a native WAAPI animation attached to a scroll timeline\n * instead of driving updates through JS.\n */\n accelerate?: AccelerateConfig\n\n /**\n * @param init - The initiating value\n * @param config - Optional configuration options\n *\n * - `transformer`: A function to transform incoming values with.\n */\n constructor(init: V, options: MotionValueOptions = {}) {\n this.setCurrent(init)\n this.owner = options.owner\n }\n\n setCurrent(current: V) {\n this.current = current\n this.updatedAt = time.now()\n\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current)\n }\n }\n\n setPrevFrameValue(prevFrameValue: V | undefined = this.current) {\n this.prevFrameValue = prevFrameValue\n this.prevUpdatedAt = this.updatedAt\n }\n\n /**\n * Adds a function that will be notified when the `MotionValue` is updated.\n *\n * It returns a function that, when called, will cancel the subscription.\n *\n * When calling `onChange` inside a React component, it should be wrapped with the\n * `useEffect` hook. As it returns an unsubscribe function, this should be returned\n * from the `useEffect` function to ensure you don't add duplicate subscribers..\n *\n * ```jsx\n * export const MyComponent = () => {\n * const x = useMotionValue(0)\n * const y = useMotionValue(0)\n * const opacity = useMotionValue(1)\n *\n * useEffect(() => {\n * function updateOpacity() {\n * const maxXY = Math.max(x.get(), y.get())\n * const newOpacity = transform(maxXY, [0, 100], [1, 0])\n * opacity.set(newOpacity)\n * }\n *\n * const unsubscribeX = x.on(\"change\", updateOpacity)\n * const unsubscribeY = y.on(\"change\", updateOpacity)\n *\n * return () => {\n * unsubscribeX()\n * unsubscribeY()\n * }\n * }, [])\n *\n * return <motion.div style={{ x }} />\n * }\n * ```\n *\n * @param subscriber - A function that receives the latest value.\n * @returns A function that, when called, will cancel this subscription.\n *\n * @deprecated\n */\n onChange(subscription: Subscriber<V>): () => void {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(\n false,\n `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`\n )\n }\n return this.on(\"change\", subscription)\n }\n\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n private events: {\n [key: string]: SubscriptionManager<any>\n } = {}\n\n on<EventName extends keyof MotionValueEventCallbacks<V>>(\n eventName: EventName,\n callback: MotionValueEventCallbacks<V>[EventName]\n ): VoidFunction {\n if (eventName === \"change\") return this.onChangeSubscribe(callback)\n\n return (this.events[eventName] ||= new SubscriptionManager()).add(\n callback\n )\n }\n\n private onChangeSubscribe(callback: Subscriber<V>): VoidFunction {\n const { events } = this\n\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback\n } else {\n if (!events.change) {\n events.change = new SubscriptionManager()\n events.change.add(this.changeSubscriber!)\n this.changeSubscriber = undefined\n }\n events.change.add(callback)\n }\n\n return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined\n } else {\n events.change?.remove(callback)\n }\n this.stopIfUnobserved()\n }\n }\n\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n private stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop()\n }\n })\n }\n\n clearListeners() {\n this.changeSubscriber = undefined\n for (const eventManagers in this.events) {\n this.events[eventManagers].clear()\n }\n }\n\n /**\n * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect: PassiveEffect<V>, stopPassiveEffect: VoidFunction) {\n this.passiveEffect = passiveEffect\n this.stopPassiveEffect = stopPassiveEffect\n }\n\n /**\n * Sets the state of the `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useMotionValue(0)\n * x.set(10)\n * ```\n *\n * @param latest - Latest value to set.\n * @param render - Whether to notify render subscribers. Defaults to `true`\n *\n * @public\n */\n set(v: V) {\n if (!this.passiveEffect) {\n this.updateAndNotify(v)\n } else {\n this.passiveEffect(v, this.updateAndNotify)\n }\n }\n\n setWithVelocity(prev: V, current: V, delta: number) {\n this.set(current)\n this.prev = undefined\n this.prevFrameValue = prev\n this.prevUpdatedAt = this.updatedAt - delta\n }\n\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v: V, endAnimation = true) {\n this.updateAndNotify(v)\n this.prev = v\n this.prevUpdatedAt = this.prevFrameValue = undefined\n endAnimation && this.stop()\n if (this.stopPassiveEffect) this.stopPassiveEffect()\n }\n\n dirty() {\n this.notifyChange()\n }\n\n private notifyChange() {\n const { current, changeSubscriber } = this\n /**\n * One or the other exists. Subscribing during the direct\n * subscriber's call moves it into a new manager, which must not\n * then be notified for the same change.\n */\n if (changeSubscriber) {\n changeSubscriber(current!)\n } else {\n this.events.change?.notify(current)\n }\n }\n\n addDependent(dependent: MotionValue) {\n if (!this.dependents) {\n this.dependents = new Set()\n }\n this.dependents.add(dependent)\n }\n\n removeDependent(dependent: MotionValue) {\n if (this.dependents) {\n this.dependents.delete(dependent)\n }\n }\n\n updateAndNotify = (v: V) => {\n const currentTime = time.now()\n\n /**\n * If we're updating the value during another frame or eventloop\n * than the previous frame, then the we set the previous frame value\n * to current.\n */\n if (this.updatedAt !== currentTime) {\n this.setPrevFrameValue()\n }\n\n this.prev = this.current\n\n this.setCurrent(v)\n\n // Update update subscribers\n if (this.current !== this.prev) {\n this.notifyChange()\n\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty()\n }\n }\n }\n }\n\n /**\n * Returns the latest state of `MotionValue`\n *\n * @returns - The latest state of `MotionValue`\n *\n * @public\n */\n get() {\n if (collectMotionValues.current) {\n collectMotionValues.current.push(this)\n }\n\n /**\n * A value animating on the compositor isn't updated every frame,\n * so read it from its animation.\n */\n const sampled = this.animation?.liveValue?.()\n\n return sampled === undefined ? this.current! : (sampled as V)\n }\n\n /**\n * The value as last set. Unlike get(), this doesn't read an animation\n * running on the compositor, which renders the value itself.\n */\n getCurrent() {\n return this.current!\n }\n\n /**\n * @public\n */\n getPrevious() {\n return this.prev\n }\n\n /**\n * Returns the latest velocity of `MotionValue`\n *\n * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.\n *\n * @public\n */\n getVelocity() {\n const currentTime = time.now()\n\n if (\n !this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA\n ) {\n return 0\n }\n\n const delta = Math.min(\n this.updatedAt - this.prevUpdatedAt!,\n MAX_VELOCITY_DELTA\n )\n\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(\n parseFloat(this.current as any) -\n parseFloat(this.prevFrameValue as any),\n delta\n )\n }\n\n hasAnimated = false\n\n /**\n * Registers a new animation to control this `MotionValue`. Only one\n * animation can drive a `MotionValue` at one time.\n *\n * ```jsx\n * value.start()\n * ```\n *\n * @param animation - A function that starts the provided animation\n */\n start(startAnimation: StartAnimation) {\n this.stop()\n\n return new Promise<void>((resolve) => {\n this.hasAnimated = true\n\n /**\n * Complete synchronously via the callback rather than chaining a\n * second promise per animation. Guard against animations that\n * complete before startAnimation has returned.\n */\n let isComplete = false\n let animation: MotionValueAnimation | undefined\n // eslint-disable-next-line prefer-const -- read by the callback before assignment when completing synchronously\n animation = startAnimation(() => {\n isComplete = true\n this.events.animationComplete?.notify()\n if (this.animation === animation) this.clearAnimation()\n resolve()\n })\n\n if (!isComplete) this.animation = animation\n\n this.events.animationStart?.notify()\n })\n }\n\n /**\n * Stop the currently active animation.\n *\n * @public\n */\n stop() {\n if (this.animation) {\n this.animation.stop()\n if (this.events.animationCancel) {\n this.events.animationCancel.notify()\n }\n }\n this.clearAnimation()\n }\n\n /**\n * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation\n }\n\n private clearAnimation() {\n // Assign rather than delete to keep the object's shape stable\n this.animation = undefined\n }\n\n /**\n * Destroy and clean up subscribers to this `MotionValue`.\n *\n * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically\n * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually\n * created a `MotionValue` via the `motionValue` function.\n *\n * @public\n */\n destroy() {\n this.dependents?.clear()\n this.events.destroy?.notify()\n this.clearListeners()\n this.stop()\n\n if (this.stopPassiveEffect) {\n this.stopPassiveEffect()\n }\n }\n}\n\nexport function motionValue<V>(init: V, options?: MotionValueOptions) {\n return new MotionValue<V>(init, options)\n}\n"],"names":[],"mappings":";;;;AAqCA;;;AAGG;AACH,MAAM,kBAAkB,GAAG,EAAE;AAE7B,MAAM,OAAO,GAAG,CAAC,KAAU,KAAqB;IAC5C,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AA8BM,MAAM,mBAAmB,GAA2C;AACvE,IAAA,OAAO,EAAE,SAAS;;AAGtB;;;;AAIG;MACU,WAAW,CAAA;AAwFpB;;;;;AAKG;IACH,WAAA,CAAY,IAAO,EAAE,OAAA,GAA8B,EAAE,EAAA;AAjCrD;;;;;;AAMG;QACK,IAAA,CAAA,gBAAgB,GAAmB,IAAI;AA+F/C;;AAEG;QACK,IAAA,CAAA,MAAM,GAEV,EAAE;AAyIN,QAAA,IAAA,CAAA,eAAe,GAAG,CAAC,CAAI,KAAI;AACvB,YAAA,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE;AAE9B;;;;AAIG;AACH,YAAA,IAAI,IAAI,CAAC,SAAS,KAAK,WAAW,EAAE;gBAChC,IAAI,CAAC,iBAAiB,EAAE;YAC5B;AAEA,YAAA,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO;AAExB,YAAA,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;;YAGlB,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,EAAE;gBAC5B,IAAI,CAAC,YAAY,EAAE;AAEnB,gBAAA,IAAI,IAAI,CAAC,UAAU,EAAE;AACjB,oBAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE;wBACrC,SAAS,CAAC,KAAK,EAAE;oBACrB;gBACJ;YACJ;AACJ,QAAA,CAAC;QAqED,IAAA,CAAA,WAAW,GAAG,KAAK;A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AI,CAAC,UAAU,EAAE,KAAK,EAAE;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE;QAC7B,IAAI,CAAC,cAAc,EAAE;QACrB,IAAI,CAAC,IAAI,EAAE;AAEX,QAAA,IAAI,IAAI,CAAC,iBAAiB,EAAE;YACxB,IAAI,CAAC,iBAAiB,EAAE;QAC5B;IACJ;AACH;AAEK,SAAU,WAAW,CAAI,IAAO,EAAE,OAA4B,EAAA;AAChE,IAAA,OAAO,IAAI,WAAW,CAAI,IAAI,EAAE,OAAO,CAAC;AAC5C;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/value/index.ts"],"sourcesContent":["import {\n EasingFunction,\n SubscriptionManager,\n velocityPerSecond,\n warnOnce,\n} from \"motion-utils\"\nimport {\n AnimationPlaybackControlsWithThen,\n AnyResolvedKeyframe,\n MotionValueAnimation,\n TransformProperties,\n} from \"../animation/types\"\nimport { frame } from \"../frameloop\"\nimport { time } from \"../frameloop/sync-time\"\n\n/**\n * @public\n */\nexport type Subscriber<T> = (v: T) => void\n\n/**\n * @public\n */\nexport type PassiveEffect<T> = (v: T, safeSetter: (v: T) => void) => void\n\nexport type StartAnimation = (\n complete: () => void\n) => AnimationPlaybackControlsWithThen | undefined\n\nexport interface MotionValueEventCallbacks<V> {\n animationStart: () => void\n animationComplete: () => void\n animationCancel: () => void\n change: (latestValue: V) => void\n destroy: () => void\n}\n\n/**\n * Maximum time between the value of two frames, beyond which we\n * assume the velocity has since been 0.\n */\nconst MAX_VELOCITY_DELTA = 30\n\nconst isFloat = (value: any): value is string => {\n return !isNaN(parseFloat(value))\n}\n\ninterface ResolvedValues {\n [key: string]: AnyResolvedKeyframe\n}\n\nexport interface Owner {\n current: HTMLElement | unknown\n getProps: () => {\n onUpdate?: (latest: ResolvedValues) => void\n transformTemplate?: (\n transform: TransformProperties,\n generatedTransform: string\n ) => string\n }\n}\n\nexport interface AccelerateConfig {\n factory: (animation: AnimationPlaybackControlsWithThen) => VoidFunction\n times: number[]\n keyframes: any[]\n ease?: EasingFunction | EasingFunction[]\n duration: number\n isTransformed?: boolean\n}\n\nexport interface MotionValueOptions {\n owner?: Owner\n}\n\nexport const collectMotionValues: { current: MotionValue[] | undefined } = {\n current: undefined,\n}\n\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue<V = any> {\n /**\n * If a MotionValue has an owner, it was created internally within Motion\n * and therefore has no external listeners. It is therefore safe to animate via WAAPI.\n */\n owner?: Owner\n\n /**\n * The current state of the `MotionValue`.\n */\n private current: V | undefined\n\n /**\n * The previous state of the `MotionValue`.\n */\n private prev: V | undefined\n\n /**\n * The previous state of the `MotionValue` at the end of the previous frame.\n */\n private prevFrameValue: V | undefined\n\n /**\n * The last time the `MotionValue` was updated.\n */\n updatedAt: number\n\n /**\n * The time `prevFrameValue` was updated.\n */\n prevUpdatedAt: number | undefined\n\n /**\n * Add a passive effect to this `MotionValue`.\n *\n * A passive effect intercepts calls to `set`. For instance, `useSpring` adds\n * a passive effect that attaches a `spring` to the latest\n * set value. Hypothetically there could be a `useSmooth` that attaches an input smoothing effect.\n *\n * @internal\n */\n private passiveEffect?: PassiveEffect<V>\n private stopPassiveEffect?: VoidFunction\n\n /**\n * Whether the passive effect is active.\n */\n isEffectActive?: boolean\n\n /**\n * A reference to the currently-controlling animation.\n */\n animation?: MotionValueAnimation\n\n /**\n * The sole `change` subscriber. Most values have exactly one (an\n * effect or a follower), so it's stored and notified directly. A\n * SubscriptionManager is only created for a second subscriber.\n */\n private changeSubscriber?: Subscriber<V>\n\n /**\n * Tracks whether this value can output a velocity. Currently this is only true\n * if the value is numerical, but we might be able to widen the scope here and support\n * other value types.\n *\n * @internal\n */\n private canTrackVelocity: boolean | null = null\n\n /**\n * A list of MotionValues whose values are computed from this one.\n * This is a rough start to a proper signal-like dirtying system.\n */\n private dependents: Set<MotionValue> | undefined\n\n /**\n * Tracks whether this value should be removed\n */\n liveStyle?: boolean\n\n /**\n * Scroll timeline acceleration metadata. When set, VisualElement\n * can create a native WAAPI animation attached to a scroll timeline\n * instead of driving updates through JS.\n */\n accelerate?: AccelerateConfig\n\n /**\n * @param init - The initiating value\n * @param config - Optional configuration options\n *\n * - `transformer`: A function to transform incoming values with.\n */\n constructor(init: V, options: MotionValueOptions = {}) {\n this.setCurrent(init)\n this.owner = options.owner\n }\n\n setCurrent(current: V) {\n this.current = current\n this.updatedAt = time.now()\n\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current)\n }\n }\n\n setPrevFrameValue(prevFrameValue: V | undefined = this.current) {\n this.prevFrameValue = prevFrameValue\n this.prevUpdatedAt = this.updatedAt\n }\n\n /**\n * Adds a function that will be notified when the `MotionValue` is updated.\n *\n * It returns a function that, when called, will cancel the subscription.\n *\n * When calling `onChange` inside a React component, it should be wrapped with the\n * `useEffect` hook. As it returns an unsubscribe function, this should be returned\n * from the `useEffect` function to ensure you don't add duplicate subscribers..\n *\n * ```jsx\n * export const MyComponent = () => {\n * const x = useMotionValue(0)\n * const y = useMotionValue(0)\n * const opacity = useMotionValue(1)\n *\n * useEffect(() => {\n * function updateOpacity() {\n * const maxXY = Math.max(x.get(), y.get())\n * const newOpacity = transform(maxXY, [0, 100], [1, 0])\n * opacity.set(newOpacity)\n * }\n *\n * const unsubscribeX = x.on(\"change\", updateOpacity)\n * const unsubscribeY = y.on(\"change\", updateOpacity)\n *\n * return () => {\n * unsubscribeX()\n * unsubscribeY()\n * }\n * }, [])\n *\n * return <motion.div style={{ x }} />\n * }\n * ```\n *\n * @param subscriber - A function that receives the latest value.\n * @returns A function that, when called, will cancel this subscription.\n *\n * @deprecated\n */\n onChange(subscription: Subscriber<V>): () => void {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(\n false,\n `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`\n )\n }\n return this.on(\"change\", subscription)\n }\n\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n private events: {\n [key: string]: SubscriptionManager<any>\n } = {}\n\n on<EventName extends keyof MotionValueEventCallbacks<V>>(\n eventName: EventName,\n callback: MotionValueEventCallbacks<V>[EventName]\n ): VoidFunction {\n if (eventName === \"change\") return this.onChangeSubscribe(callback)\n\n return (this.events[eventName] ||= new SubscriptionManager()).add(\n callback\n )\n }\n\n private onChangeSubscribe(callback: Subscriber<V>): VoidFunction {\n const { events } = this\n\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback\n } else {\n if (!events.change) {\n events.change = new SubscriptionManager()\n events.change.add(this.changeSubscriber!)\n this.changeSubscriber = undefined\n }\n events.change.add(callback)\n }\n\n return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined\n } else {\n events.change?.remove(callback)\n }\n this.stopIfUnobserved()\n }\n }\n\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n private stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop()\n }\n })\n }\n\n clearListeners() {\n this.changeSubscriber = undefined\n for (const eventManagers in this.events) {\n this.events[eventManagers].clear()\n }\n }\n\n /**\n * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect: PassiveEffect<V>, stopPassiveEffect: VoidFunction) {\n this.passiveEffect = passiveEffect\n this.stopPassiveEffect = stopPassiveEffect\n }\n\n /**\n * Sets the state of the `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useMotionValue(0)\n * x.set(10)\n * ```\n *\n * @param latest - Latest value to set.\n * @param render - Whether to notify render subscribers. Defaults to `true`\n *\n * @public\n */\n set(v: V) {\n this.passiveEffect\n ? this.passiveEffect(v, this.updateAndNotify)\n : this.updateAndNotify(v)\n }\n\n setWithVelocity(prev: V, current: V, delta: number) {\n this.set(current)\n this.prev = undefined\n this.prevFrameValue = prev\n this.prevUpdatedAt = this.updatedAt - delta\n }\n\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v: V, endAnimation = true) {\n this.updateAndNotify(v)\n this.prev = v\n this.prevUpdatedAt = this.prevFrameValue = undefined\n endAnimation && this.stop()\n this.stopPassiveEffect?.()\n }\n\n dirty() {\n const { current, changeSubscriber } = this\n /**\n * One or the other exists. Subscribing during the direct\n * subscriber's call moves it into a new manager, which must not\n * then be notified for the same change.\n */\n if (changeSubscriber) {\n changeSubscriber(current!)\n } else {\n this.events.change?.notify(current)\n }\n }\n\n addDependent(dependent: MotionValue) {\n ;(this.dependents ||= new Set()).add(dependent)\n }\n\n removeDependent(dependent: MotionValue) {\n this.dependents?.delete(dependent)\n }\n\n updateAndNotify = (v: V) => {\n const currentTime = time.now()\n\n /**\n * If we're updating the value during another frame or eventloop\n * than the previous frame, then the we set the previous frame value\n * to current.\n */\n if (this.updatedAt !== currentTime) {\n this.setPrevFrameValue()\n }\n\n this.prev = this.current\n\n this.setCurrent(v)\n\n // Update update subscribers\n if (this.current !== this.prev) {\n this.dirty()\n\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty()\n }\n }\n }\n }\n\n /**\n * Returns the latest state of `MotionValue`\n *\n * @returns - The latest state of `MotionValue`\n *\n * @public\n */\n get() {\n collectMotionValues.current?.push(this)\n\n /**\n * A value animating on the compositor isn't updated every frame,\n * so read it from its animation.\n */\n const sampled = this.animation?.liveValue?.()\n\n return sampled === undefined ? this.current! : (sampled as V)\n }\n\n /**\n * The value as last set. Unlike get(), this doesn't read an animation\n * running on the compositor, which renders the value itself.\n */\n getCurrent() {\n return this.current!\n }\n\n /**\n * @public\n */\n getPrevious() {\n return this.prev\n }\n\n /**\n * Returns the latest velocity of `MotionValue`\n *\n * @returns - The latest velocity of `MotionValue`. Returns `0` if the state is non-numerical.\n *\n * @public\n */\n getVelocity() {\n const currentTime = time.now()\n\n if (\n !this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA\n ) {\n return 0\n }\n\n const delta = Math.min(\n this.updatedAt - this.prevUpdatedAt!,\n MAX_VELOCITY_DELTA\n )\n\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(\n parseFloat(this.current as any) -\n parseFloat(this.prevFrameValue as any),\n delta\n )\n }\n\n hasAnimated = false\n\n /**\n * Registers a new animation to control this `MotionValue`. Only one\n * animation can drive a `MotionValue` at one time.\n *\n * ```jsx\n * value.start()\n * ```\n *\n * @param animation - A function that starts the provided animation\n */\n start(startAnimation: StartAnimation) {\n this.stop()\n\n return new Promise<void>((resolve) => {\n this.hasAnimated = true\n\n /**\n * Complete synchronously via the callback rather than chaining a\n * second promise per animation. Guard against animations that\n * complete before startAnimation has returned.\n */\n let isComplete = false\n let animation: MotionValueAnimation | undefined\n // eslint-disable-next-line prefer-const -- read by the callback before assignment when completing synchronously\n animation = startAnimation(() => {\n isComplete = true\n this.events.animationComplete?.notify()\n if (this.animation === animation) this.animation = undefined\n resolve()\n })\n\n if (!isComplete) this.animation = animation\n\n this.events.animationStart?.notify()\n })\n }\n\n /**\n * Stop the currently active animation.\n *\n * @public\n */\n stop() {\n if (this.animation) {\n this.animation.stop()\n this.events.animationCancel?.notify()\n }\n // Assign rather than delete to keep the object's shape stable\n this.animation = undefined\n }\n\n /**\n * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation\n }\n\n /**\n * Destroy and clean up subscribers to this `MotionValue`.\n *\n * The `MotionValue` hooks like `useMotionValue` and `useTransform` automatically\n * handle the lifecycle of the returned `MotionValue`, so this method is only necessary if you've manually\n * created a `MotionValue` via the `motionValue` function.\n *\n * @public\n */\n destroy() {\n this.dependents?.clear()\n this.events.destroy?.notify()\n this.clearListeners()\n this.stop()\n this.stopPassiveEffect?.()\n }\n}\n\nexport function motionValue<V>(init: V, options?: MotionValueOptions) {\n return new MotionValue<V>(init, options)\n}\n"],"names":[],"mappings":";;;;AAqCA;;;AAGG;AACH,MAAM,kBAAkB,GAAG,EAAE;AAE7B,MAAM,OAAO,GAAG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IAAI,CAAC,SAAS,GAAG,SAAS;AAC5D,gBAAA,OAAO,EAAE;AACb,YAAA,CAAC,CAAC;AAEF,YAAA,IAAI,CAAC,UAAU;AAAE,gBAAA,IAAI,CAAC,SAAS,GAAG,SAAS;AAE3C,YAAA,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,EAAE;AACxC,QAAA,CAAC,CAAC;IACN;AAEA;;;;AAIG;IACH,IAAI,GAAA;AACA,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE;AAChB,YAAA,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;AACrB,YAAA,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE;QACzC;;AAEA,QAAA,IAAI,CAAC,SAAS,GAAG,SAAS;IAC9B;AAEA;;;;AAIG;IACH,WAAW,GAAA;AACP,QAAA,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS;IAC3B;AAEA;;;;;;;;AAQG;IACH,OAAO,GAAA;AACH,QAAA,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE;QAC7B,IAAI,CAAC,cAAc,EAAE;QACrB,IAAI,CAAC,IAAI,EAAE;AACX,QAAA,IAAI,CAAC,iBAAiB,IAAI;IAC9B;AACH;AAEK,SAAU,WAAW,CAAI,IAAO,EAAE,OAA4B,EAAA;AAChE,IAAA,OAAO,IAAI,WAAW,CAAI,IAAI,EAAE,OAAO,CAAC;AAC5C;;;;"}
@@ -1,34 +1,21 @@
1
1
  import { rgba } from './rgba.mjs';
2
2
  import { isColorString } from './utils.mjs';
3
3
 
4
+ /**
5
+ * #FF0000 has two characters per channel, #F00 one, which is doubled.
6
+ */
7
+ const channel = (v, i, size) => {
8
+ const c = v.substring(1 + i * size, 1 + (i + 1) * size);
9
+ return size > 1 ? c : c + c;
10
+ };
4
11
  function parseHex(v) {
5
- let r = "";
6
- let g = "";
7
- let b = "";
8
- let a = "";
9
- // If we have 6 characters, ie #FF0000
10
- if (v.length > 5) {
11
- r = v.substring(1, 3);
12
- g = v.substring(3, 5);
13
- b = v.substring(5, 7);
14
- a = v.substring(7, 9);
15
- // Or we have 3 characters, ie #F00
16
- }
17
- else {
18
- r = v.substring(1, 2);
19
- g = v.substring(2, 3);
20
- b = v.substring(3, 4);
21
- a = v.substring(4, 5);
22
- r += r;
23
- g += g;
24
- b += b;
25
- a += a;
26
- }
12
+ const size = v.length > 5 ? 2 : 1;
13
+ const alpha = channel(v, 3, size);
27
14
  return {
28
- red: parseInt(r, 16),
29
- green: parseInt(g, 16),
30
- blue: parseInt(b, 16),
31
- alpha: a ? parseInt(a, 16) / 255 : 1,
15
+ red: parseInt(channel(v, 0, size), 16),
16
+ green: parseInt(channel(v, 1, size), 16),
17
+ blue: parseInt(channel(v, 2, size), 16),
18
+ alpha: alpha ? parseInt(alpha, 16) / 255 : 1,
32
19
  };
33
20
  }
34
21
  const hex = {
@@ -1 +1 @@
1
- {"version":3,"file":"hex.mjs","sources":["../../../../../src/value/types/color/hex.ts"],"sourcesContent":["import { RGBA } from \"../types\"\nimport { rgba } from \"./rgba\"\nimport { isColorString } from \"./utils\"\n\nfunction parseHex(v: string): RGBA {\n let r = \"\"\n let g = \"\"\n let b = \"\"\n let a = \"\"\n\n // If we have 6 characters, ie #FF0000\n if (v.length > 5) {\n r = v.substring(1, 3)\n g = v.substring(3, 5)\n b = v.substring(5, 7)\n a = v.substring(7, 9)\n\n // Or we have 3 characters, ie #F00\n } else {\n r = v.substring(1, 2)\n g = v.substring(2, 3)\n b = v.substring(3, 4)\n a = v.substring(4, 5)\n r += r\n g += g\n b += b\n a += a\n }\n\n return {\n red: parseInt(r, 16),\n green: parseInt(g, 16),\n blue: parseInt(b, 16),\n alpha: a ? parseInt(a, 16) / 255 : 1,\n }\n}\n\nexport const hex = {\n test: /*@__PURE__*/ isColorString(\"#\"),\n parse: parseHex,\n transform: rgba.transform,\n}\n"],"names":[],"mappings":";;;A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AA,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,IAAI,CAAC,SAAS;;;;;"}
1
+ {"version":3,"file":"hex.mjs","sources":["../../../../../src/value/types/color/hex.ts"],"sourcesContent":["import { RGBA } from \"../types\"\nimport { rgba } from \"./rgba\"\nimport { isColorString } from \"./utils\"\n\n/**\n * #FF0000 has two characters per channel, #F00 one, which is doubled.\n */\nconst channel = (v: string, i: number, size: number) => {\n const c = v.substring(1 + i * size, 1 + (i + 1) * size)\n return size > 1 ? c : c + c\n}\n\nfunction parseHex(v: string): RGBA {\n const size = v.length > 5 ? 2 : 1\n const alpha = channel(v, 3, size)\n\n return {\n red: parseInt(channel(v, 0, size), 16),\n green: parseInt(channel(v, 1, size), 16),\n blue: parseInt(channel(v, 2, size), 16),\n alpha: alpha ? parseInt(alpha, 16) / 255 : 1,\n }\n}\n\nexport const hex = {\n test: /*@__PURE__*/ isColorString(\"#\"),\n parse: parseHex,\n transform: rgba.transform,\n}\n"],"names":[],"mappings":";;;AAIA;;AAEG;AACH,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,IAAY,KAAI;IACnD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;AACvD,IAAA,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;AAC/B,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS,EAAA;AACvB,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IACjC,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC;IAEjC,OAAO;AACH,QAAA,GAAG,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;AACtC,QAAA,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;AACxC,QAAA,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,QAAA,KAAK,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC;KAC/C;AACL;AAEO,MAAM,GAAG,GAAG;AACf,IAAA,IAAI,gBAAgB,aAAa,CAAC,GAAG,CAAC;AACtC,IAAA,KAAK,EAAE,QAAQ;IACf,SAAS,EAAE,IAAI,CAAC,SAAS;;;;;"}
@@ -124,5 +124,5 @@ const complex = {
124
124
  getAnimatableNone,
125
125
  };
126
126
 
127
- export { analyseComplexValue, complex, hasComplexValues };
127
+ export { analyseComplexValue, buildTransformer, complex, hasComplexValues };
128
128
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../../../src/value/types/complex/index.ts"],"sourcesContent":["import { AnyResolvedKeyframe } from \"../../../animation/types\"\nimport { CSSVariableToken } from \"../../../animation/utils/is-css-variable\"\nimport { color } from \"../color\"\nimport { Color } from \"../types\"\nimport { colorRegex } from \"../utils/color-regex\"\nimport { floatRegex } from \"../utils/float-regex\"\nimport { sanitize } from \"../utils/sanitize\"\n\n/**\n * Non-global copies of the token regexes so test() can use .test()\n * (no match array, stops at the first token) without lastIndex state.\n */\nconst hasFloat = /*@__PURE__*/ new RegExp(floatRegex.source)\nconst hasColor = /*@__PURE__*/ new RegExp(colorRegex.source, \"i\")\n\nfunction test(v: any) {\n return (\n isNaN(v) &&\n typeof v === \"string\" &&\n (hasFloat.test(v) || hasColor.test(v))\n )\n}\n\nconst NUMBER_TOKEN = \"number\"\nconst COLOR_TOKEN = \"color\"\nconst VAR_TOKEN = \"var\"\nconst VAR_FUNCTION_TOKEN = \"var(\"\nconst SPLIT_TOKEN = \"${}\"\n\nexport type ComplexValues = Array<\n CSSVariableToken | AnyResolvedKeyframe | Color\n>\n\nexport interface ValueIndexes {\n color: number[]\n number: number[]\n var: number[]\n}\n\nexport interface ComplexValueInfo {\n values: ComplexValues\n split: string[]\n indexes: ValueIndexes\n types: Array<keyof ValueIndexes>\n}\n\n// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex`.\n// The lookahead skips digits in function names, like the 3 in matrix3d(.\nconst complexRegex =\n /var\\s*\\(\\s*--(?:[\\w-]+\\s*|[\\w-]+\\s*,(?:\\s*[^)(\\s]|\\s*\\((?:[^)(]|\\([^)(]*\\))*\\))+\\s*)\\)|#[\\da-f]{3,8}|(?:rgb|hsl)a?\\((?:-?[\\d.]+%?[,\\s]+){2}-?[\\d.]+%?\\s*(?:[,/]\\s*)?(?:\\b\\d+(?:\\.\\d+)?|\\.\\d+)?%?\\)|-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?![a-z]*\\()/giu\n\n/**\n * Whether analyseComplexValue(value) would find any values, without\n * tokenising the string. CSS variables are resolved before this is\n * used, so it's enough to look for a number or a color.\n */\nexport function hasComplexValues(value: AnyResolvedKeyframe) {\n const asString = value.toString()\n return hasFloat.test(asString) || hasColor.test(asString)\n}\n\nexport function analyseComplexValue(\n value: AnyResolvedKeyframe\n): ComplexValueInfo {\n const originalValue = value.toString()\n\n const values: ComplexValues = []\n const indexes: ValueIndexes = {\n color: [],\n number: [],\n var: [],\n }\n const types: Array<keyof ValueIndexes> = []\n\n let i = 0\n const tokenised = originalValue.replace(complexRegex, (parsedValue) => {\n if (color.test(parsedValue)) {\n indexes.color.push(i)\n types.push(COLOR_TOKEN)\n values.push(color.parse(parsedValue))\n } else if (parsedValue.startsWith(VAR_FUNCTION_TOKEN)) {\n indexes.var.push(i)\n types.push(VAR_TOKEN)\n values.push(parsedValue)\n } else {\n indexes.number.push(i)\n types.push(NUMBER_TOKEN)\n values.push(parseFloat(parsedValue))\n }\n ++i\n return SPLIT_TOKEN\n })\n const split = tokenised.split(SPLIT_TOKEN)\n\n return { values, split, indexes, types }\n}\n\nfunction parseComplexValue(v: AnyResolvedKeyframe) {\n return analyseComplexValue(v).values\n}\n\nfunction buildTransformer({ split, types }: ComplexValueInfo) {\n const numSections = split.length\n return (v: Array<CSSVariableToken | Color | number | string>) => {\n let output = \"\"\n for (let i = 0; i < numSections; i++) {\n output += split[i]\n if (v[i] !== undefined) {\n const type = types[i]\n if (type === NUMBER_TOKEN) {\n output += sanitize(v[i] as number)\n } else if (type === COLOR_TOKEN) {\n output += color.transform(v[i] as Color)\n } else {\n output += v[i]\n }\n }\n }\n\n return output\n }\n}\n\nfunction createTransformer(source: AnyResolvedKeyframe) {\n return buildTransformer(analyseComplexValue(source))\n}\n\nconst convertNumbersToZero = (v: number | string) =>\n typeof v === \"number\" ? 0 : color.test(v) ? color.getAnimatableNone(v) : v\n\n/**\n * Convert a parsed value to its zero equivalent, but preserve numbers\n * that act as divisors in CSS calc() expressions.\n *\n * analyseComplexValue extracts numbers from CSS strings and puts the\n * surrounding text into a `split` template array. For example:\n * \"calc(var(--gap) / 5)\" → values: [var(--gap), 5]\n * split: [\"calc(\", \" / \", \")\"]\n *\n * When building a zero-equivalent for animation, naively zeroing all\n * numbers turns the divisor into 0 → \"calc(var(--gap) / 0)\" → NaN.\n * We detect this by checking whether the text preceding a number\n * (split[i]) ends with \"/\" — the CSS calc division operator.\n */\nconst convertToZero = (\n value: ComplexValues[number],\n splitBefore: string\n): ComplexValues[number] => {\n if (typeof value === \"number\") {\n return splitBefore?.trim().endsWith(\"/\") ? value : 0\n }\n return convertNumbersToZero(value as string)\n}\n\nfunction getAnimatableNone(v: AnyResolvedKeyframe) {\n const info = analyseComplexValue(v)\n const transformer = buildTransformer(info)\n return transformer(\n info.values.map((value, i) => convertToZero(value, info.split[i]))\n )\n}\n\nexport const complex = {\n test,\n parse: parseComplexValue,\n createTransformer,\n getAnimatableNone,\n}\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AAC;AAC1C,IAAA,OAAO,WAAW,CACd,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CACrE;AACL;AAEO,MAAM,OAAO,GAAG;IACnB,IAAI;AACJ,IAAA,KAAK,EAAE,iBAAiB;IACxB,iBAAiB;IACjB,iBAAiB;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../../../src/value/types/complex/index.ts"],"sourcesContent":["import { AnyResolvedKeyframe } from \"../../../animation/types\"\nimport { CSSVariableToken } from \"../../../animation/utils/is-css-variable\"\nimport { color } from \"../color\"\nimport { Color } from \"../types\"\nimport { colorRegex } from \"../utils/color-regex\"\nimport { floatRegex } from \"../utils/float-regex\"\nimport { sanitize } from \"../utils/sanitize\"\n\n/**\n * Non-global copies of the token regexes so test() can use .test()\n * (no match array, stops at the first token) without lastIndex state.\n */\nconst hasFloat = /*@__PURE__*/ new RegExp(floatRegex.source)\nconst hasColor = /*@__PURE__*/ new RegExp(colorRegex.source, \"i\")\n\nfunction test(v: any) {\n return (\n isNaN(v) &&\n typeof v === \"string\" &&\n (hasFloat.test(v) || hasColor.test(v))\n )\n}\n\nconst NUMBER_TOKEN = \"number\"\nconst COLOR_TOKEN = \"color\"\nconst VAR_TOKEN = \"var\"\nconst VAR_FUNCTION_TOKEN = \"var(\"\nconst SPLIT_TOKEN = \"${}\"\n\nexport type ComplexValues = Array<\n CSSVariableToken | AnyResolvedKeyframe | Color\n>\n\nexport interface ValueIndexes {\n color: number[]\n number: number[]\n var: number[]\n}\n\nexport interface ComplexValueInfo {\n values: ComplexValues\n split: string[]\n indexes: ValueIndexes\n types: Array<keyof ValueIndexes>\n}\n\n// this regex consists of the `singleCssVariableRegex|rgbHSLValueRegex|digitRegex`.\n// The lookahead skips digits in function names, like the 3 in matrix3d(.\nconst complexRegex =\n /var\\s*\\(\\s*--(?:[\\w-]+\\s*|[\\w-]+\\s*,(?:\\s*[^)(\\s]|\\s*\\((?:[^)(]|\\([^)(]*\\))*\\))+\\s*)\\)|#[\\da-f]{3,8}|(?:rgb|hsl)a?\\((?:-?[\\d.]+%?[,\\s]+){2}-?[\\d.]+%?\\s*(?:[,/]\\s*)?(?:\\b\\d+(?:\\.\\d+)?|\\.\\d+)?%?\\)|-?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?![a-z]*\\()/giu\n\n/**\n * Whether analyseComplexValue(value) would find any values, without\n * tokenising the string. CSS variables are resolved before this is\n * used, so it's enough to look for a number or a color.\n */\nexport function hasComplexValues(value: AnyResolvedKeyframe) {\n const asString = value.toString()\n return hasFloat.test(asString) || hasColor.test(asString)\n}\n\nexport function analyseComplexValue(\n value: AnyResolvedKeyframe\n): ComplexValueInfo {\n const originalValue = value.toString()\n\n const values: ComplexValues = []\n const indexes: ValueIndexes = {\n color: [],\n number: [],\n var: [],\n }\n const types: Array<keyof ValueIndexes> = []\n\n let i = 0\n const tokenised = originalValue.replace(complexRegex, (parsedValue) => {\n if (color.test(parsedValue)) {\n indexes.color.push(i)\n types.push(COLOR_TOKEN)\n values.push(color.parse(parsedValue))\n } else if (parsedValue.startsWith(VAR_FUNCTION_TOKEN)) {\n indexes.var.push(i)\n types.push(VAR_TOKEN)\n values.push(parsedValue)\n } else {\n indexes.number.push(i)\n types.push(NUMBER_TOKEN)\n values.push(parseFloat(parsedValue))\n }\n ++i\n return SPLIT_TOKEN\n })\n const split = tokenised.split(SPLIT_TOKEN)\n\n return { values, split, indexes, types }\n}\n\nfunction parseComplexValue(v: AnyResolvedKeyframe) {\n return analyseComplexValue(v).values\n}\n\nexport function buildTransformer({ split, types }: ComplexValueInfo) {\n const numSections = split.length\n return (v: Array<CSSVariableToken | Color | number | string>) => {\n let output = \"\"\n for (let i = 0; i < numSections; i++) {\n output += split[i]\n if (v[i] !== undefined) {\n const type = types[i]\n if (type === NUMBER_TOKEN) {\n output += sanitize(v[i] as number)\n } else if (type === COLOR_TOKEN) {\n output += color.transform(v[i] as Color)\n } else {\n output += v[i]\n }\n }\n }\n\n return output\n }\n}\n\nfunction createTransformer(source: AnyResolvedKeyframe) {\n return buildTransformer(analyseComplexValue(source))\n}\n\nconst convertNumbersToZero = (v: number | string) =>\n typeof v === \"number\" ? 0 : color.test(v) ? color.getAnimatableNone(v) : v\n\n/**\n * Convert a parsed value to its zero equivalent, but preserve numbers\n * that act as divisors in CSS calc() expressions.\n *\n * analyseComplexValue extracts numbers from CSS strings and puts the\n * surrounding text into a `split` template array. For example:\n * \"calc(var(--gap) / 5)\" → values: [var(--gap), 5]\n * split: [\"calc(\", \" / \", \")\"]\n *\n * When building a zero-equivalent for animation, naively zeroing all\n * numbers turns the divisor into 0 → \"calc(var(--gap) / 0)\" → NaN.\n * We detect this by checking whether the text preceding a number\n * (split[i]) ends with \"/\" — the CSS calc division operator.\n */\nconst convertToZero = (\n value: ComplexValues[number],\n splitBefore: string\n): ComplexValues[number] => {\n if (typeof value === \"number\") {\n return splitBefore?.trim().endsWith(\"/\") ? value : 0\n }\n return convertNumbersToZero(value as string)\n}\n\nfunction getAnimatableNone(v: AnyResolvedKeyframe) {\n const info = analyseComplexValue(v)\n const transformer = buildTransformer(info)\n return transformer(\n info.values.map((value, i) => convertToZero(value, info.split[i]))\n )\n}\n\nexport const complex = {\n test,\n parse: parseComplexValue,\n createTransformer,\n getAnimatableNone,\n}\n"],"names":[],"mappings":";;;;;AAQA;;;AAGG;AACH,MAAM,QAAQ,iBAAiB,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;AAC5D,MAAM,QAAQ,iBAAiB,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,CAAC;AAEjE,SAAS,IAAI,CAAC,CAAM,EAAA;AAChB,IAAA,QACI,KAAK,CAAC,CAAC,CAAC;QACR,OAAO,CAAC,KAAK,QAAQ;AACrB,SAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,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