motion-dom 14.7.1 → 14.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +370 -147
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/animation/JSAnimation.mjs +7 -1
- package/dist/es/animation/JSAnimation.mjs.map +1 -1
- package/dist/es/animation/generators/keyframes.mjs +12 -3
- package/dist/es/animation/generators/keyframes.mjs.map +1 -1
- package/dist/es/animation/utils/is-transition-defined.mjs +1 -0
- package/dist/es/animation/utils/is-transition-defined.mjs.map +1 -1
- package/dist/es/animation/waapi/supports/waapi.mjs +3 -1
- package/dist/es/animation/waapi/supports/waapi.mjs.map +1 -1
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs +31 -35
- package/dist/es/animation/waapi/transforms/TransformAnimation.mjs.map +1 -1
- package/dist/es/animation/waapi/utils/needs-mixer.mjs +11 -0
- package/dist/es/animation/waapi/utils/needs-mixer.mjs.map +1 -0
- package/dist/es/effects/svg/index.mjs +14 -0
- package/dist/es/effects/svg/index.mjs.map +1 -1
- package/dist/es/gestures/drag/index.mjs +4 -3
- package/dist/es/gestures/drag/index.mjs.map +1 -1
- package/dist/es/gestures/drag/projection.mjs +85 -0
- package/dist/es/gestures/drag/projection.mjs.map +1 -0
- package/dist/es/index.mjs +1 -1
- package/dist/es/layout/LayoutAnimationBuilder.mjs +34 -51
- package/dist/es/layout/LayoutAnimationBuilder.mjs.map +1 -1
- package/dist/es/layout/visual-element.mjs +48 -0
- package/dist/es/layout/visual-element.mjs.map +1 -0
- package/dist/es/projection/geometry/round.mjs +25 -0
- package/dist/es/projection/geometry/round.mjs.map +1 -0
- package/dist/es/projection/node/DocumentProjectionNode.mjs +2 -8
- package/dist/es/projection/node/DocumentProjectionNode.mjs.map +1 -1
- package/dist/es/projection/node/create-projection-node.mjs +68 -48
- package/dist/es/projection/node/create-projection-node.mjs.map +1 -1
- package/dist/es/projection/utils/measure.mjs +5 -1
- package/dist/es/projection/utils/measure.mjs.map +1 -1
- package/dist/es/stats/buffer.mjs +1 -0
- package/dist/es/stats/buffer.mjs.map +1 -1
- package/dist/es/stats/index.mjs +31 -0
- package/dist/es/stats/index.mjs.map +1 -1
- package/dist/es/utils/interpolate.mjs +3 -2
- package/dist/es/utils/interpolate.mjs.map +1 -1
- package/dist/es/utils/is-ref-object.mjs +8 -0
- package/dist/es/utils/is-ref-object.mjs.map +1 -0
- package/dist/es/utils/transform.mjs.map +1 -1
- package/dist/es/value/index.mjs +10 -1
- package/dist/es/value/index.mjs.map +1 -1
- package/dist/index.d.ts +298 -232
- package/dist/motion-dom.dev.js +370 -147
- package/dist/motion-dom.js +1 -1
- package/dist/size-rollup-motion-value.js +1 -1
- package/dist/size-rollup-motion-value.js.map +1 -1
- package/dist/size-rollup-style-effect.js +1 -1
- package/dist/size-rollup-style-effect.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={};class t{constructor(){this.subscriptions=[]}add(e){var t,s;return t=this.subscriptions,s=e,-1===t.indexOf(s)&&t.push(s),()=>this.remove(e)}remove(e){!function(e,t){const s=e.indexOf(t);s>-1&&e.splice(s,1)}(this.subscriptions,e)}notify(e,t,s){const i=this.subscriptions.length;if(i)if(1===i)this.subscriptions[0](e,t,s);else for(let n=0;n<i;n++){const i=this.subscriptions[n];i&&i(e,t,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const s=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function i(t,i,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,a=!0;const o=()=>r=!0,c=s.reduce((e,t)=>(e[t]=function(e){let t,s=new Set,i=new Set,n=!1,r=!1;const a=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function c(s){a.has(s)&&(i.add(s),e()),(t=s)(o)}const h={schedule:(e,r=!1,o=!1)=>{const c=o&&n,h=c?s:i;return r&&a.add(e),c&&e!==t&&h.delete(e),h.add(e),e},cancel:e=>{i.delete(e),a.delete(e)},process:e=>{if(o=e,n)return void(r=!0);n=!0;const a=s;s=i,i=a,s.forEach(c),s.clear(),t=void 0,n=!1,r&&(r=!1,h.process(e))}};return h}(o),e),{}),{setup:h,read:d,resolveKeyframes:u,preUpdate:p,update:l,preRender:v,render:m,postRender:f}=c,g=()=>{const s=e.useManualTiming,o=s?n.timestamp:performance.now();r=!1,s||(n.delta=a?1e3/60:Math.max(Math.min(o-n.timestamp,40),1)),n.timestamp=o,n.isProcessing=!0,h.process(n),d.process(n),u.process(n),p.process(n),l.process(n),v.process(n),m.process(n),f.process(n),n.isProcessing=!1,r&&i&&(a=!1,t(g))};return{schedule:s.reduce((e,s)=>{const i=c[s];return e[s]=(e,s=!1,o=!1)=>(r||(r=!0,a=!0,n.isProcessing||t(g)),i.schedule(e,s,o)),e},{}),cancel:e=>{for(let t=0;t<s.length;t++)c[s[t]].cancel(e)},state:n,steps:c}}const n={delta:0,timestamp:0,isProcessing:!1},{schedule:r}=i("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:e=>e,!0,n);let a;function o(){a=void 0}const c={now:()=>(void 0===a&&c.set(n.isProcessing||e.useManualTiming?n.timestamp:performance.now()),a),set:e=>{a=e,queueMicrotask(o)}},h={current:void 0};class d{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{const t=c.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.dirty(),this.dependents))for(const e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){var t;this.current=e,this.updatedAt=c.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,s){var i;return"change"===e?this.onChangeSubscribe(s):((i=this.events)[e]||(i[e]=new t)).add(s)}onChangeSubscribe(e){const{events:s}=this;return s.change||this.changeSubscriber?(s.change||(s.change=new t,s.change.add(this.changeSubscriber),this.changeSubscriber=void 0),s.change.add(e)):this.changeSubscriber=e,()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:s.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){r.read(()=>{this.changeSubscriber||this.events.change?.getSize()||this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,s){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,
|
|
1
|
+
const e={};class t{constructor(){this.subscriptions=[]}add(e){var t,s;return t=this.subscriptions,s=e,-1===t.indexOf(s)&&t.push(s),()=>this.remove(e)}remove(e){!function(e,t){const s=e.indexOf(t);s>-1&&e.splice(s,1)}(this.subscriptions,e)}notify(e,t,s){const i=this.subscriptions.length;if(i)if(1===i)this.subscriptions[0](e,t,s);else for(let n=0;n<i;n++){const i=this.subscriptions[n];i&&i(e,t,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const s=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function i(t,i,n={delta:0,timestamp:0,isProcessing:!1}){let r=!1,a=!0;const o=()=>r=!0,c=s.reduce((e,t)=>(e[t]=function(e){let t,s=new Set,i=new Set,n=!1,r=!1;const a=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function c(s){a.has(s)&&(i.add(s),e()),(t=s)(o)}const h={schedule:(e,r=!1,o=!1)=>{const c=o&&n,h=c?s:i;return r&&a.add(e),c&&e!==t&&h.delete(e),h.add(e),e},cancel:e=>{i.delete(e),a.delete(e)},process:e=>{if(o=e,n)return void(r=!0);n=!0;const a=s;s=i,i=a,s.forEach(c),s.clear(),t=void 0,n=!1,r&&(r=!1,h.process(e))}};return h}(o),e),{}),{setup:h,read:d,resolveKeyframes:u,preUpdate:p,update:l,preRender:v,render:m,postRender:f}=c,g=()=>{const s=e.useManualTiming,o=s?n.timestamp:performance.now();r=!1,s||(n.delta=a?1e3/60:Math.max(Math.min(o-n.timestamp,40),1)),n.timestamp=o,n.isProcessing=!0,h.process(n),d.process(n),u.process(n),p.process(n),l.process(n),v.process(n),m.process(n),f.process(n),n.isProcessing=!1,r&&i&&(a=!1,t(g))};return{schedule:s.reduce((e,s)=>{const i=c[s];return e[s]=(e,s=!1,o=!1)=>(r||(r=!0,a=!0,n.isProcessing||t(g)),i.schedule(e,s,o)),e},{}),cancel:e=>{for(let t=0;t<s.length;t++)c[s[t]].cancel(e)},state:n,steps:c}}const n={delta:0,timestamp:0,isProcessing:!1},{schedule:r}=i("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:e=>e,!0,n);let a;function o(){a=void 0}const c={now:()=>(void 0===a&&c.set(n.isProcessing||e.useManualTiming?n.timestamp:performance.now()),a),set:e=>{a=e,queueMicrotask(o)}},h={current:void 0};class d{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{const t=c.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.dirty(),this.dependents))for(const e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){var t;this.current=e,this.updatedAt=c.now(),null===this.canTrackVelocity&&void 0!==e&&(this.canTrackVelocity=(t=this.current,!isNaN(parseFloat(t))))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on("change",e)}on(e,s){var i;return"change"===e?this.onChangeSubscribe(s):((i=this.events)[e]||(i[e]=new t)).add(s)}onChangeSubscribe(e){const{events:s}=this;return s.change||this.changeSubscriber?(s.change||(s.change=new t,s.change.add(this.changeSubscriber),this.changeSubscriber=void 0),s.change.add(e)):this.changeSubscriber=e,()=>{this.changeSubscriber===e?this.changeSubscriber=void 0:s.change?.remove(e),this.stopIfUnobserved()}}stopIfUnobserved(){r.read(()=>{this.changeSubscriber||this.events.change?.getSize()||this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,s){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-s}jump(e,t=!0){t&&(this.updatedAt=c.now(),this.stop()),this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,this.stopPassiveEffect?.()}dirty(){const{current:e,changeSubscriber:t}=this;t?t(e):this.events.change?.notify(e)}addDependent(e){(this.dependents||(this.dependents=new Set)).add(e)}removeDependent(e){this.dependents?.delete(e)}get(){h.current?.push(this);const e=this.animation?.liveValue?.();return void 0===e?this.current:e}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){const e=c.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||e-this.updatedAt>30)return 0;const t=Math.min(this.updatedAt-this.prevUpdatedAt,30);return s=parseFloat(this.current)-parseFloat(this.prevFrameValue),(i=t)?s*(1e3/i):0;var s,i}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0;let s,i=!1;s=e(()=>{i=!0,this.events.animationComplete?.notify(),this.animation===s&&(this.animation=void 0),t()}),i||(this.animation=s),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}}function u(e,t){return new d(e,t)}export{d as MotionValue,h as collectMotionValues,u as motionValue};
|
|
2
2
|
//# sourceMappingURL=size-rollup-motion-value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size-rollup-motion-value.js","sources":["../../motion-utils/dist/es/global-config.mjs","../../motion-utils/dist/es/subscription-manager.mjs","../../motion-utils/dist/es/array.mjs","../../motion-utils/dist/es/velocity-per-second.mjs","../lib/frameloop/order.js","../lib/frameloop/batcher.js","../lib/frameloop/render-step.js","../lib/frameloop/frame-data.js","../lib/frameloop/frame.js","../../motion-utils/dist/es/noop.mjs","../lib/frameloop/sync-time.js","../lib/value/index.js"],"sourcesContent":["const MotionGlobalConfig = {};\n\nexport { MotionGlobalConfig };\n//# sourceMappingURL=global-config.mjs.map\n","import { addUniqueItem, removeItem } from './array.mjs';\n\nclass SubscriptionManager {\n constructor() {\n this.subscriptions = [];\n }\n add(handler) {\n addUniqueItem(this.subscriptions, handler);\n return () => this.remove(handler);\n }\n remove(handler) {\n removeItem(this.subscriptions, handler);\n }\n notify(a, b, c) {\n const numSubscriptions = this.subscriptions.length;\n if (!numSubscriptions)\n return;\n if (numSubscriptions === 1) {\n /**\n * If there's only a single handler we can just call it without invoking a loop.\n */\n this.subscriptions[0](a, b, c);\n }\n else {\n for (let i = 0; i < numSubscriptions; i++) {\n /**\n * Check whether the handler exists before firing as it's possible\n * the subscriptions were modified during this loop running.\n */\n const handler = this.subscriptions[i];\n handler && handler(a, b, c);\n }\n }\n }\n getSize() {\n return this.subscriptions.length;\n }\n clear() {\n this.subscriptions.length = 0;\n }\n}\n\nexport { SubscriptionManager };\n//# sourceMappingURL=subscription-manager.mjs.map\n","function addUniqueItem(arr, item) {\n if (arr.indexOf(item) === -1)\n arr.push(item);\n}\nfunction removeItem(arr, item) {\n const index = arr.indexOf(item);\n if (index > -1)\n arr.splice(index, 1);\n}\n// Adapted from array-move\nfunction moveItem([...arr], fromIndex, toIndex) {\n const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;\n if (startIndex >= 0 && startIndex < arr.length) {\n const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;\n const [item] = arr.splice(fromIndex, 1);\n arr.splice(endIndex, 0, item);\n }\n return arr;\n}\n\nexport { addUniqueItem, moveItem, removeItem };\n//# sourceMappingURL=array.mjs.map\n","/*\n Convert velocity into velocity per second\n*/\n/*#__NO_SIDE_EFFECTS__*/\nconst velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;\n\nexport { velocityPerSecond };\n//# sourceMappingURL=velocity-per-second.mjs.map\n","export const stepsOrder = [\n \"setup\", // Compute\n \"read\", // Read\n \"resolveKeyframes\", // Write/Read/Write/Read\n \"preUpdate\", // Compute\n \"update\", // Compute\n \"preRender\", // Compute\n \"render\", // Write\n \"postRender\", // Compute\n];\n//# sourceMappingURL=order.js.map","import { MotionGlobalConfig } from \"motion-utils\";\nimport { stepsOrder } from \"./order\";\nimport { createRenderStep } from \"./render-step\";\nconst maxElapsed = 40;\nexport function createRenderBatcher(scheduleNextBatch, allowKeepAlive, state = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n}) {\n let runNextFrame = false;\n let useDefaultElapsed = true;\n const flagRunNextFrame = () => (runNextFrame = true);\n const steps = stepsOrder.reduce((acc, key) => {\n acc[key] = createRenderStep(flagRunNextFrame);\n return acc;\n }, {});\n const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;\n const processBatch = () => {\n const useManualTiming = MotionGlobalConfig.useManualTiming;\n const timestamp = useManualTiming\n ? state.timestamp\n : performance.now();\n runNextFrame = false;\n if (!useManualTiming) {\n state.delta = useDefaultElapsed\n ? 1000 / 60\n : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);\n }\n state.timestamp = timestamp;\n state.isProcessing = true;\n // Unrolled render loop for better per-frame performance\n setup.process(state);\n read.process(state);\n resolveKeyframes.process(state);\n preUpdate.process(state);\n update.process(state);\n preRender.process(state);\n render.process(state);\n postRender.process(state);\n state.isProcessing = false;\n if (runNextFrame && allowKeepAlive) {\n useDefaultElapsed = false;\n scheduleNextBatch(processBatch);\n }\n };\n const wake = () => {\n runNextFrame = true;\n useDefaultElapsed = true;\n if (!state.isProcessing) {\n scheduleNextBatch(processBatch);\n }\n };\n const schedule = stepsOrder.reduce((acc, key) => {\n const step = steps[key];\n acc[key] = (process, keepAlive = false, immediate = false) => {\n if (!runNextFrame)\n wake();\n return step.schedule(process, keepAlive, immediate);\n };\n return acc;\n }, {});\n const cancel = (process) => {\n for (let i = 0; i < stepsOrder.length; i++) {\n steps[stepsOrder[i]].cancel(process);\n }\n };\n return { schedule, cancel, state, steps };\n}\n//# sourceMappingURL=batcher.js.map","export function createRenderStep(runNextFrame) {\n /**\n * We create and reuse two queues, one to queue jobs for the current frame\n * and one for the next. We reuse to avoid triggering GC after x frames.\n */\n let thisFrame = new Set();\n let nextFrame = new Set();\n /**\n * Track whether we're currently processing jobs in this step. This way\n * we can decide whether to schedule new jobs for this frame or next.\n */\n let isProcessing = false;\n let flushNextFrame = false;\n /**\n * The callback currently running. If it schedules itself with `immediate`\n * it's left in place, so as before it doesn't run again this step.\n */\n let running;\n /**\n * A set of processes which were marked keepAlive when scheduled.\n * A keepAlive process is always also held by a frame queue until\n * it's cancelled, so a Set has the same lifetime semantics as a\n * WeakSet here while being considerably faster to query every frame.\n */\n const toKeepAlive = new Set();\n let latestFrameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n };\n function triggerCallback(callback) {\n if (toKeepAlive.has(callback)) {\n nextFrame.add(callback);\n runNextFrame();\n }\n ;\n (running = callback)(latestFrameData);\n }\n const step = {\n /**\n * Schedule a process to run on the next frame.\n */\n schedule: (callback, keepAlive = false, immediate = false) => {\n const addToCurrentFrame = immediate && isProcessing;\n const queue = addToCurrentFrame ? thisFrame : nextFrame;\n if (keepAlive)\n toKeepAlive.add(callback);\n /**\n * A callback scheduled with `immediate` during processing may\n * already have run this step (for instance, a value it reads was\n * changed by a later callback). Re-adding moves it to the end of\n * the queue, so it runs again. The running callback is excluded,\n * so one that re-schedules itself can't loop forever.\n */\n addToCurrentFrame && callback !== running && queue.delete(callback);\n queue.add(callback);\n return callback;\n },\n /**\n * Cancel the provided callback from running on the next frame.\n */\n cancel: (callback) => {\n nextFrame.delete(callback);\n toKeepAlive.delete(callback);\n },\n /**\n * Execute all schedule callbacks.\n */\n process: (frameData) => {\n latestFrameData = frameData;\n /**\n * If we're already processing we've probably been triggered by a flushSync\n * inside an existing process. Instead of executing, mark flushNextFrame\n * as true and ensure we flush the following frame at the end of this one.\n */\n if (isProcessing) {\n flushNextFrame = true;\n return;\n }\n isProcessing = true;\n // Swap this frame and the next to avoid GC\n const prevFrame = thisFrame;\n thisFrame = nextFrame;\n nextFrame = prevFrame;\n // Execute this frame\n thisFrame.forEach(triggerCallback);\n // Clear the frame so no callbacks remain. This is to avoid\n // memory leaks should this render step not run for a while.\n thisFrame.clear();\n running = undefined;\n isProcessing = false;\n if (flushNextFrame) {\n flushNextFrame = false;\n step.process(frameData);\n }\n },\n };\n return step;\n}\n//# sourceMappingURL=render-step.js.map","/**\n * The frameloop's state, kept apart from the frameloop itself so that\n * reading it doesn't bundle the scheduler.\n */\nexport const frameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n};\n//# sourceMappingURL=frame-data.js.map","import { noop } from \"motion-utils\";\nimport { createRenderBatcher } from \"./batcher\";\nimport { frameData } from \"./frame-data\";\nexport const { schedule: frame, cancel: cancelFrame, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : noop, true, frameData);\n//# sourceMappingURL=frame.js.map","/*#__NO_SIDE_EFFECTS__*/\nconst noop = (any) => any;\n\nexport { noop };\n//# sourceMappingURL=noop.mjs.map\n","import { MotionGlobalConfig } from \"motion-utils\";\nimport { frameData } from \"./frame-data\";\nlet now;\nfunction clearTime() {\n now = undefined;\n}\n/**\n * An eventloop-synchronous alternative to performance.now().\n *\n * Ensures that time measurements remain consistent within a synchronous context.\n * Usually calling performance.now() twice within the same synchronous context\n * will return different values which isn't useful for animations when we're usually\n * trying to sync animations to the same frame.\n */\nexport const time = {\n now: () => {\n if (now === undefined) {\n time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming\n ? frameData.timestamp\n : performance.now());\n }\n return now;\n },\n set: (newTime) => {\n now = newTime;\n queueMicrotask(clearTime);\n },\n};\n//# sourceMappingURL=sync-time.js.map","import { SubscriptionManager, velocityPerSecond, warnOnce, } from \"motion-utils\";\nimport { frame } from \"../frameloop\";\nimport { time } from \"../frameloop/sync-time\";\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;\nconst isFloat = (value) => {\n return !isNaN(parseFloat(value));\n};\nexport const collectMotionValues = {\n current: undefined,\n};\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue {\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, options = {}) {\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 this.canTrackVelocity = null;\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n this.events = {};\n this.updateAndNotify = (v) => {\n const currentTime = time.now();\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 this.prev = this.current;\n this.setCurrent(v);\n // Update update subscribers\n if (this.current !== this.prev) {\n this.dirty();\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty();\n }\n }\n }\n };\n this.hasAnimated = false;\n this.setCurrent(init);\n this.owner = options.owner;\n }\n setCurrent(current) {\n this.current = current;\n this.updatedAt = time.now();\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current);\n }\n }\n setPrevFrameValue(prevFrameValue = this.current) {\n this.prevFrameValue = prevFrameValue;\n this.prevUpdatedAt = this.updatedAt;\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) {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`);\n }\n return this.on(\"change\", subscription);\n }\n on(eventName, callback) {\n var _a;\n if (eventName === \"change\")\n return this.onChangeSubscribe(callback);\n return ((_a = this.events)[eventName] || (_a[eventName] = new SubscriptionManager())).add(callback);\n }\n onChangeSubscribe(callback) {\n const { events } = this;\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback;\n }\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 return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined;\n }\n else {\n events.change?.remove(callback);\n }\n this.stopIfUnobserved();\n };\n }\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop();\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 * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect, stopPassiveEffect) {\n this.passiveEffect = passiveEffect;\n this.stopPassiveEffect = stopPassiveEffect;\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) {\n this.passiveEffect\n ? this.passiveEffect(v, this.updateAndNotify)\n : this.updateAndNotify(v);\n }\n setWithVelocity(prev, current, delta) {\n this.set(current);\n this.prev = undefined;\n this.prevFrameValue = prev;\n this.prevUpdatedAt = this.updatedAt - delta;\n }\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(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 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 }\n else {\n this.events.change?.notify(current);\n }\n }\n addDependent(dependent) {\n ;\n (this.dependents || (this.dependents = new Set())).add(dependent);\n }\n removeDependent(dependent) {\n this.dependents?.delete(dependent);\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 * 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 return sampled === undefined ? this.current : sampled;\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 * @public\n */\n getPrevious() {\n return this.prev;\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 if (!this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {\n return 0;\n }\n const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(parseFloat(this.current) -\n parseFloat(this.prevFrameValue), delta);\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) {\n this.stop();\n return new Promise((resolve) => {\n this.hasAnimated = true;\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;\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)\n this.animation = undefined;\n resolve();\n });\n if (!isComplete)\n this.animation = animation;\n this.events.animationStart?.notify();\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 * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation;\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}\nexport function motionValue(init, options) {\n return new MotionValue(init, options);\n}\n//# sourceMappingURL=index.js.map"],"names":["MotionGlobalConfig","SubscriptionManager","constructor","this","subscriptions","add","handler","arr","item","indexOf","push","remove","index","splice","removeItem","notify","a","b","c","numSubscriptions","length","i","getSize","clear","stepsOrder","createRenderBatcher","scheduleNextBatch","allowKeepAlive","state","delta","timestamp","isProcessing","runNextFrame","useDefaultElapsed","flagRunNextFrame","steps","reduce","acc","key","running","thisFrame","Set","nextFrame","flushNextFrame","toKeepAlive","latestFrameData","triggerCallback","callback","has","step","schedule","keepAlive","immediate","addToCurrentFrame","queue","delete","cancel","process","frameData","prevFrame","forEach","undefined","createRenderStep","setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender","processBatch","useManualTiming","performance","now","Math","max","min","frame","requestAnimationFrame","any","clearTime","time","set","newTime","queueMicrotask","collectMotionValues","current","MotionValue","init","options","canTrackVelocity","events","updateAndNotify","v","currentTime","updatedAt","setPrevFrameValue","prev","setCurrent","dirty","dependents","dependent","hasAnimated","owner","value","isNaN","parseFloat","prevFrameValue","prevUpdatedAt","onChange","subscription","on","eventName","_a","onChangeSubscribe","change","changeSubscriber","stopIfUnobserved","stop","clearListeners","eventManagers","attach","passiveEffect","stopPassiveEffect","setWithVelocity","jump","endAnimation","addDependent","removeDependent","get","sampled","animation","liveValue","getCurrent","getPrevious","getVelocity","velocity","frameDuration","start","startAnimation","Promise","resolve","isComplete","animationComplete","animationStart","animationCancel","isAnimating","destroy","motionValue"],"mappings":"AAAA,MAAMA,EAAqB,CAAA,ECE3B,MAAMC,EACF,WAAAC,GACIC,KAAKC,cAAgB,EACzB,CACA,GAAAC,CAAIC,GCNR,IAAuBC,EAAKC,EDQpB,OCReD,EDODJ,KAAKC,cCPCI,EDOcF,GCNZ,IAAtBC,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oF,SACrCoB,WAAWxG,KAAKyG,iBRnRS8B,EQmRQ7G,GRnR0B4G,GAAY,IAAOC,GAAiB,EAAjF,IAACD,EAAUC,CQoRjC,CAWA,KAAAC,CAAMC,GAEF,OADAzI,KAAKoH,OACE,IAAIsB,QAASC,IAChB3I,KAAKoG,aAAc,EAMnB,IACI6B,EADAW,GAAa,EAGjBX,EAAYQ,EAAe,KACvBG,GAAa,EACb5I,KAAKyF,OAAOoD,mBAAmBjI,SAC3BZ,KAAKiI,YAAcA,IACnBjI,KAAKiI,eAAYvE,GACrBiF,MAECC,IACD5I,KAAKiI,UAAYA,GACrBjI,KAAKyF,OAAOqD,gBAAgBlI,UAEpC,CAMA,IAAAwG,GACQpH,KAAKiI,YACLjI,KAAKiI,UAAUb,OACfpH,KAAKyF,OAAOsD,iBAAiBnI,UAGjCZ,KAAKiI,eAAYvE,CACrB,CAMA,WAAAsF,GACI,QAAShJ,KAAKiI,SAClB,CAUA,OAAAgB,GACIjJ,KAAKkG,YAAY9E,QACjBpB,KAAKyF,OAAOwD,SAASrI,SACrBZ,KAAKqH,iBACLrH,KAAKoH,OACLpH,KAAKyH,qBACT,EAEG,SAASyB,EAAY5D,EAAMC,GAC9B,OAAO,IAAIF,EAAYC,EAAMC,EACjC"}
|
|
1
|
+
{"version":3,"file":"size-rollup-motion-value.js","sources":["../../motion-utils/dist/es/global-config.mjs","../../motion-utils/dist/es/subscription-manager.mjs","../../motion-utils/dist/es/array.mjs","../../motion-utils/dist/es/velocity-per-second.mjs","../lib/frameloop/order.js","../lib/frameloop/batcher.js","../lib/frameloop/render-step.js","../lib/frameloop/frame-data.js","../lib/frameloop/frame.js","../../motion-utils/dist/es/noop.mjs","../lib/frameloop/sync-time.js","../lib/value/index.js"],"sourcesContent":["const MotionGlobalConfig = {};\n\nexport { MotionGlobalConfig };\n//# sourceMappingURL=global-config.mjs.map\n","import { addUniqueItem, removeItem } from './array.mjs';\n\nclass SubscriptionManager {\n constructor() {\n this.subscriptions = [];\n }\n add(handler) {\n addUniqueItem(this.subscriptions, handler);\n return () => this.remove(handler);\n }\n remove(handler) {\n removeItem(this.subscriptions, handler);\n }\n notify(a, b, c) {\n const numSubscriptions = this.subscriptions.length;\n if (!numSubscriptions)\n return;\n if (numSubscriptions === 1) {\n /**\n * If there's only a single handler we can just call it without invoking a loop.\n */\n this.subscriptions[0](a, b, c);\n }\n else {\n for (let i = 0; i < numSubscriptions; i++) {\n /**\n * Check whether the handler exists before firing as it's possible\n * the subscriptions were modified during this loop running.\n */\n const handler = this.subscriptions[i];\n handler && handler(a, b, c);\n }\n }\n }\n getSize() {\n return this.subscriptions.length;\n }\n clear() {\n this.subscriptions.length = 0;\n }\n}\n\nexport { SubscriptionManager };\n//# sourceMappingURL=subscription-manager.mjs.map\n","function addUniqueItem(arr, item) {\n if (arr.indexOf(item) === -1)\n arr.push(item);\n}\nfunction removeItem(arr, item) {\n const index = arr.indexOf(item);\n if (index > -1)\n arr.splice(index, 1);\n}\n// Adapted from array-move\nfunction moveItem([...arr], fromIndex, toIndex) {\n const startIndex = fromIndex < 0 ? arr.length + fromIndex : fromIndex;\n if (startIndex >= 0 && startIndex < arr.length) {\n const endIndex = toIndex < 0 ? arr.length + toIndex : toIndex;\n const [item] = arr.splice(fromIndex, 1);\n arr.splice(endIndex, 0, item);\n }\n return arr;\n}\n\nexport { addUniqueItem, moveItem, removeItem };\n//# sourceMappingURL=array.mjs.map\n","/*\n Convert velocity into velocity per second\n*/\n/*#__NO_SIDE_EFFECTS__*/\nconst velocityPerSecond = (velocity, frameDuration) => frameDuration ? velocity * (1000 / frameDuration) : 0;\n\nexport { velocityPerSecond };\n//# sourceMappingURL=velocity-per-second.mjs.map\n","export const stepsOrder = [\n \"setup\", // Compute\n \"read\", // Read\n \"resolveKeyframes\", // Write/Read/Write/Read\n \"preUpdate\", // Compute\n \"update\", // Compute\n \"preRender\", // Compute\n \"render\", // Write\n \"postRender\", // Compute\n];\n//# sourceMappingURL=order.js.map","import { MotionGlobalConfig } from \"motion-utils\";\nimport { stepsOrder } from \"./order\";\nimport { createRenderStep } from \"./render-step\";\nconst maxElapsed = 40;\nexport function createRenderBatcher(scheduleNextBatch, allowKeepAlive, state = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n}) {\n let runNextFrame = false;\n let useDefaultElapsed = true;\n const flagRunNextFrame = () => (runNextFrame = true);\n const steps = stepsOrder.reduce((acc, key) => {\n acc[key] = createRenderStep(flagRunNextFrame);\n return acc;\n }, {});\n const { setup, read, resolveKeyframes, preUpdate, update, preRender, render, postRender, } = steps;\n const processBatch = () => {\n const useManualTiming = MotionGlobalConfig.useManualTiming;\n const timestamp = useManualTiming\n ? state.timestamp\n : performance.now();\n runNextFrame = false;\n if (!useManualTiming) {\n state.delta = useDefaultElapsed\n ? 1000 / 60\n : Math.max(Math.min(timestamp - state.timestamp, maxElapsed), 1);\n }\n state.timestamp = timestamp;\n state.isProcessing = true;\n // Unrolled render loop for better per-frame performance\n setup.process(state);\n read.process(state);\n resolveKeyframes.process(state);\n preUpdate.process(state);\n update.process(state);\n preRender.process(state);\n render.process(state);\n postRender.process(state);\n state.isProcessing = false;\n if (runNextFrame && allowKeepAlive) {\n useDefaultElapsed = false;\n scheduleNextBatch(processBatch);\n }\n };\n const wake = () => {\n runNextFrame = true;\n useDefaultElapsed = true;\n if (!state.isProcessing) {\n scheduleNextBatch(processBatch);\n }\n };\n const schedule = stepsOrder.reduce((acc, key) => {\n const step = steps[key];\n acc[key] = (process, keepAlive = false, immediate = false) => {\n if (!runNextFrame)\n wake();\n return step.schedule(process, keepAlive, immediate);\n };\n return acc;\n }, {});\n const cancel = (process) => {\n for (let i = 0; i < stepsOrder.length; i++) {\n steps[stepsOrder[i]].cancel(process);\n }\n };\n return { schedule, cancel, state, steps };\n}\n//# sourceMappingURL=batcher.js.map","export function createRenderStep(runNextFrame) {\n /**\n * We create and reuse two queues, one to queue jobs for the current frame\n * and one for the next. We reuse to avoid triggering GC after x frames.\n */\n let thisFrame = new Set();\n let nextFrame = new Set();\n /**\n * Track whether we're currently processing jobs in this step. This way\n * we can decide whether to schedule new jobs for this frame or next.\n */\n let isProcessing = false;\n let flushNextFrame = false;\n /**\n * The callback currently running. If it schedules itself with `immediate`\n * it's left in place, so as before it doesn't run again this step.\n */\n let running;\n /**\n * A set of processes which were marked keepAlive when scheduled.\n * A keepAlive process is always also held by a frame queue until\n * it's cancelled, so a Set has the same lifetime semantics as a\n * WeakSet here while being considerably faster to query every frame.\n */\n const toKeepAlive = new Set();\n let latestFrameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n };\n function triggerCallback(callback) {\n if (toKeepAlive.has(callback)) {\n nextFrame.add(callback);\n runNextFrame();\n }\n ;\n (running = callback)(latestFrameData);\n }\n const step = {\n /**\n * Schedule a process to run on the next frame.\n */\n schedule: (callback, keepAlive = false, immediate = false) => {\n const addToCurrentFrame = immediate && isProcessing;\n const queue = addToCurrentFrame ? thisFrame : nextFrame;\n if (keepAlive)\n toKeepAlive.add(callback);\n /**\n * A callback scheduled with `immediate` during processing may\n * already have run this step (for instance, a value it reads was\n * changed by a later callback). Re-adding moves it to the end of\n * the queue, so it runs again. The running callback is excluded,\n * so one that re-schedules itself can't loop forever.\n */\n addToCurrentFrame && callback !== running && queue.delete(callback);\n queue.add(callback);\n return callback;\n },\n /**\n * Cancel the provided callback from running on the next frame.\n */\n cancel: (callback) => {\n nextFrame.delete(callback);\n toKeepAlive.delete(callback);\n },\n /**\n * Execute all schedule callbacks.\n */\n process: (frameData) => {\n latestFrameData = frameData;\n /**\n * If we're already processing we've probably been triggered by a flushSync\n * inside an existing process. Instead of executing, mark flushNextFrame\n * as true and ensure we flush the following frame at the end of this one.\n */\n if (isProcessing) {\n flushNextFrame = true;\n return;\n }\n isProcessing = true;\n // Swap this frame and the next to avoid GC\n const prevFrame = thisFrame;\n thisFrame = nextFrame;\n nextFrame = prevFrame;\n // Execute this frame\n thisFrame.forEach(triggerCallback);\n // Clear the frame so no callbacks remain. This is to avoid\n // memory leaks should this render step not run for a while.\n thisFrame.clear();\n running = undefined;\n isProcessing = false;\n if (flushNextFrame) {\n flushNextFrame = false;\n step.process(frameData);\n }\n },\n };\n return step;\n}\n//# sourceMappingURL=render-step.js.map","/**\n * The frameloop's state, kept apart from the frameloop itself so that\n * reading it doesn't bundle the scheduler.\n */\nexport const frameData = {\n delta: 0.0,\n timestamp: 0.0,\n isProcessing: false,\n};\n//# sourceMappingURL=frame-data.js.map","import { noop } from \"motion-utils\";\nimport { createRenderBatcher } from \"./batcher\";\nimport { frameData } from \"./frame-data\";\nexport const { schedule: frame, cancel: cancelFrame, steps: frameSteps, } = /* @__PURE__ */ createRenderBatcher(typeof requestAnimationFrame !== \"undefined\" ? requestAnimationFrame : noop, true, frameData);\n//# sourceMappingURL=frame.js.map","/*#__NO_SIDE_EFFECTS__*/\nconst noop = (any) => any;\n\nexport { noop };\n//# sourceMappingURL=noop.mjs.map\n","import { MotionGlobalConfig } from \"motion-utils\";\nimport { frameData } from \"./frame-data\";\nlet now;\nfunction clearTime() {\n now = undefined;\n}\n/**\n * An eventloop-synchronous alternative to performance.now().\n *\n * Ensures that time measurements remain consistent within a synchronous context.\n * Usually calling performance.now() twice within the same synchronous context\n * will return different values which isn't useful for animations when we're usually\n * trying to sync animations to the same frame.\n */\nexport const time = {\n now: () => {\n if (now === undefined) {\n time.set(frameData.isProcessing || MotionGlobalConfig.useManualTiming\n ? frameData.timestamp\n : performance.now());\n }\n return now;\n },\n set: (newTime) => {\n now = newTime;\n queueMicrotask(clearTime);\n },\n};\n//# sourceMappingURL=sync-time.js.map","import { SubscriptionManager, velocityPerSecond, warnOnce, } from \"motion-utils\";\nimport { frame } from \"../frameloop\";\nimport { time } from \"../frameloop/sync-time\";\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;\nconst isFloat = (value) => {\n return !isNaN(parseFloat(value));\n};\nexport const collectMotionValues = {\n current: undefined,\n};\n/**\n * `MotionValue` is used to track the state and velocity of motion values.\n *\n * @public\n */\nexport class MotionValue {\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, options = {}) {\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 this.canTrackVelocity = null;\n /**\n * An object containing a SubscriptionManager for each active event.\n */\n this.events = {};\n this.updateAndNotify = (v) => {\n const currentTime = time.now();\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 this.prev = this.current;\n this.setCurrent(v);\n // Update update subscribers\n if (this.current !== this.prev) {\n this.dirty();\n if (this.dependents) {\n for (const dependent of this.dependents) {\n dependent.dirty();\n }\n }\n }\n };\n this.hasAnimated = false;\n this.setCurrent(init);\n this.owner = options.owner;\n }\n setCurrent(current) {\n this.current = current;\n this.updatedAt = time.now();\n if (this.canTrackVelocity === null && current !== undefined) {\n this.canTrackVelocity = isFloat(this.current);\n }\n }\n setPrevFrameValue(prevFrameValue = this.current) {\n this.prevFrameValue = prevFrameValue;\n this.prevUpdatedAt = this.updatedAt;\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) {\n if (process.env.NODE_ENV !== \"production\") {\n warnOnce(false, `value.onChange(callback) is deprecated. Switch to value.on(\"change\", callback).`);\n }\n return this.on(\"change\", subscription);\n }\n on(eventName, callback) {\n var _a;\n if (eventName === \"change\")\n return this.onChangeSubscribe(callback);\n return ((_a = this.events)[eventName] || (_a[eventName] = new SubscriptionManager())).add(callback);\n }\n onChangeSubscribe(callback) {\n const { events } = this;\n if (!events.change && !this.changeSubscriber) {\n this.changeSubscriber = callback;\n }\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 return () => {\n if (this.changeSubscriber === callback) {\n this.changeSubscriber = undefined;\n }\n else {\n events.change?.remove(callback);\n }\n this.stopIfUnobserved();\n };\n }\n /**\n * If we have no more change listeners by the start\n * of the next frame, stop active animations.\n */\n stopIfUnobserved() {\n frame.read(() => {\n if (!this.changeSubscriber && !this.events.change?.getSize()) {\n this.stop();\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 * Attaches a passive effect to the `MotionValue`.\n */\n attach(passiveEffect, stopPassiveEffect) {\n this.passiveEffect = passiveEffect;\n this.stopPassiveEffect = stopPassiveEffect;\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) {\n this.passiveEffect\n ? this.passiveEffect(v, this.updateAndNotify)\n : this.updateAndNotify(v);\n }\n setWithVelocity(prev, current, delta) {\n this.set(current);\n this.prev = undefined;\n this.prevFrameValue = prev;\n this.prevUpdatedAt = this.updatedAt - delta;\n }\n /**\n * Set the state of the `MotionValue`, stopping any active animations,\n * effects, and resets velocity to `0`.\n */\n jump(v, endAnimation = true) {\n if (endAnimation) {\n /**\n * Stop first, as stopping a running animation can set the\n * value it's showing, which would replace v. Marking the value\n * as updated now skips a JS animation's catch-up tick on stop,\n * which could otherwise complete it.\n */\n this.updatedAt = time.now();\n this.stop();\n }\n this.updateAndNotify(v);\n this.prev = v;\n this.prevUpdatedAt = this.prevFrameValue = undefined;\n this.stopPassiveEffect?.();\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 }\n else {\n this.events.change?.notify(current);\n }\n }\n addDependent(dependent) {\n ;\n (this.dependents || (this.dependents = new Set())).add(dependent);\n }\n removeDependent(dependent) {\n this.dependents?.delete(dependent);\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 * 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 return sampled === undefined ? this.current : sampled;\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 * @public\n */\n getPrevious() {\n return this.prev;\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 if (!this.canTrackVelocity ||\n this.prevFrameValue === undefined ||\n currentTime - this.updatedAt > MAX_VELOCITY_DELTA) {\n return 0;\n }\n const delta = Math.min(this.updatedAt - this.prevUpdatedAt, MAX_VELOCITY_DELTA);\n // Casts because of parseFloat's poor typing\n return velocityPerSecond(parseFloat(this.current) -\n parseFloat(this.prevFrameValue), delta);\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) {\n this.stop();\n return new Promise((resolve) => {\n this.hasAnimated = true;\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;\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)\n this.animation = undefined;\n resolve();\n });\n if (!isComplete)\n this.animation = animation;\n this.events.animationStart?.notify();\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 * Returns `true` if this value is currently animating.\n *\n * @public\n */\n isAnimating() {\n return !!this.animation;\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}\nexport function motionValue(init, options) {\n return new MotionValue(init, options);\n}\n//# sourceMappingURL=index.js.map"],"names":["MotionGlobalConfig","SubscriptionManager","constructor","this","subscriptions","add","handler","arr","item","indexOf","push","remove","index","splice","removeItem","notify","a","b","c","numSubscriptions","length","i","getSize","clear","stepsOrder","createRenderBatcher","scheduleNextBatch","allowKeepAlive","state","delta","timestamp","isProcessing","runNextFrame","useDefaultElapsed","flagRunNextFrame","steps","reduce","acc","key","running","thisFrame","Set","nextFrame","flushNextFrame","toKeepAlive","latestFrameData","triggerCallback","callback","has","step","schedule","keepAlive","immediate","addToCurrentFrame","queue","delete","cancel","process","frameData","prevFrame","forEach","undefined","createRenderStep","setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender","processBatch","useManualTiming","performance","now","Math","max","min","frame","requestAnimationFrame","any","clearTime","time","set","newTime","queueMicrotask","collectMotionValues","current","MotionValue","init","options","canTrackVelocity","events","updateAndNotify","v","currentTime","updatedAt","setPrevFrameValue","prev","setCurrent","dirty","dependents","dependent","hasAnimated","owner","value","isNaN","parseFloat","prevFrameValue","prevUpdatedAt","onChange","subscription","on","eventName","_a","onChangeSubscribe","change","changeSubscriber","stopIfUnobserved","stop","clearListeners","eventManagers","attach","passiveEffect","stopPassiveEffect","setWithVelocity","jump","endAnimation","addDependent","removeDependent","get","sampled","animation","liveValue","getCurrent","getPrevious","getVelocity","velocity","frameDuration","start","startAnimation","Promise","resolve","isComplete","animationComplete","animationStart","animationCancel","isAnimating","destroy","motionValue"],"mappings":"AAAA,MAAMA,EAAqB,CAAA,ECE3B,MAAMC,EACF,WAAAC,GACIC,KAAKC,cAAgB,EACzB,CACA,GAAAC,CAAIC,GCNR,IAAuBC,EAAKC,EDQpB,OCReD,EDODJ,KAAKC,cCPCI,EDOcF,GCNZ,IAAtBC,EAAIE,QAAQD,IACZD,EAAIG,KAAKF,GDMF,IAAML,KAAKQ,OAAOL,EAC7B,CACA,MAAAK,CAAOL,ICNX,SAAoBC,EAAKC,GACrB,MAAMI,EAAQL,EAAIE,QAAQD,GACtBI,GAAQ,GACRL,EAAIM,OAAOD,EAAO,EAC1B,CDGQE,CAAWX,KAAKC,cAAeE,EACnC,CACA,MAAAS,CAAOC,EAAGC,EAAGC,GACT,MAAMC,EAAmBhB,KAAKC,cAAcgB,OAC5C,GAAKD,EAEL,GAAyB,IAArBA,EAIAhB,KAAKC,cAAc,GAAGY,EAAGC,EAAGC,QAG5B,IAA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5I,KAAKiI,UAAYA,GACrBjI,KAAKyF,OAAOqD,gBAAgBlI,UAEpC,CAMA,IAAAwG,GACQpH,KAAKiI,YACLjI,KAAKiI,UAAUb,OACfpH,KAAKyF,OAAOsD,iBAAiBnI,UAGjCZ,KAAKiI,eAAYvE,CACrB,CAMA,WAAAsF,GACI,QAAShJ,KAAKiI,SAClB,CAUA,OAAAgB,GACIjJ,KAAKkG,YAAY9E,QACjBpB,KAAKyF,OAAOwD,SAASrI,SACrBZ,KAAKqH,iBACLrH,KAAKoH,OACLpH,KAAKyH,qBACT,EAEG,SAASyB,EAAY5D,EAAMC,GAC9B,OAAO,IAAIF,EAAYC,EAAMC,EACjC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t=new WeakMap,e=t=>t.startsWith("--"),s=t=>180*t/Math.PI,n=t=>{const e=s(Math.atan2(t[1],t[0]));return i(e)},r={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:n,rotateZ:n,skewX:t=>s(Math.atan(t[1])),skewY:t=>s(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},i=t=>((t%=360)<0&&(t+=360),t),a=t=>Math.hypot(t[0],t[1]),o=t=>Math.hypot(t[4],t[5]),c={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:a,scaleY:o,scaleZ:t=>Math.hypot(t[8],t[9],t[10]),scale:t=>(a(t)+o(t))/2,rotateX:t=>i(s(Math.atan2(t[6],t[5]))),rotateY:t=>i(s(Math.atan2(-t[2],t[0]))),rotateZ:n,rotate:n,skewX:t=>s(Math.atan(t[4])),skewY:t=>s(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function h(t){return t.includes("scale")?1:0}const d=(t,e)=>{const{transform:s="none"}=getComputedStyle(t);return function(t,e){if(!t||"none"===t)return h(e);const s=t.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!s)return h(e);const n=(s[1]?c:r)[e],i=s[2].split(",").map(t=>parseFloat(t));return"function"==typeof n?n(i):i[n]}(s,e)},u=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],l=(()=>new Set([...u,"pathRotation"]))();const p={},f=t=>"object"==typeof t&&null!==t;class g{constructor(){this.subscriptions=[]}add(t){var e,s;return e=this.subscriptions,s=t,-1===e.indexOf(s)&&e.push(s),()=>this.remove(t)}remove(t){!function(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}(this.subscriptions,t)}notify(t,e,s){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](t,e,s);else for(let r=0;r<n;r++){const n=this.subscriptions[r];n&&n(t,e,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function m(t){return f(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const v=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function b(t,e,s={delta:0,timestamp:0,isProcessing:!1}){let n=!1,r=!0;const i=()=>n=!0,a=v.reduce((t,e)=>(t[e]=function(t){let e,s=new Set,n=new Set,r=!1,i=!1;const a=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function c(s){a.has(s)&&(n.add(s),t()),(e=s)(o)}const h={schedule:(t,i=!1,o=!1)=>{const c=o&&r,h=c?s:n;return i&&a.add(t),c&&t!==e&&h.delete(t),h.add(t),t},cancel:t=>{n.delete(t),a.delete(t)},process:t=>{if(o=t,r)return void(i=!0);r=!0;const a=s;s=n,n=a,s.forEach(c),s.clear(),e=void 0,r=!1,i&&(i=!1,h.process(t))}};return h}(i),t),{}),{setup:o,read:c,resolveKeyframes:h,preUpdate:d,update:u,preRender:l,render:f,postRender:g}=a,m=()=>{const i=p.useManualTiming,a=i?s.timestamp:performance.now();n=!1,i||(s.delta=r?1e3/60:Math.max(Math.min(a-s.timestamp,40),1)),s.timestamp=a,s.isProcessing=!0,o.process(s),c.process(s),h.process(s),d.process(s),u.process(s),l.process(s),f.process(s),g.process(s),s.isProcessing=!1,n&&e&&(r=!1,t(m))};return{schedule:v.reduce((e,i)=>{const o=a[i];return e[i]=(e,i=!1,a=!1)=>(n||(n=!0,r=!0,s.isProcessing||t(m)),o.schedule(e,i,a)),e},{}),cancel:t=>{for(let e=0;e<v.length;e++)a[v[e]].cancel(t)},state:s,steps:a}}const y={delta:0,timestamp:0,isProcessing:!1},{schedule:w}=b("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:t=>t,!0,y);let k;function S(){k=void 0}const P={now:()=>(void 0===k&&P.set(y.isProcessing||p.useManualTiming?y.timestamp:performance.now()),k),set:t=>{k=t,queueMicrotask(S)}};class M{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=t=>{const e=P.now();if(this.updatedAt!==e&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.dirty(),this.dependents))for(const t of this.dependents)t.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=P.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){var s;return"change"===t?this.onChangeSubscribe(e):((s=this.events)[t]||(s[t]=new g)).add(e)}onChangeSubscribe(t){const{events:e}=this;return e.change||this.changeSubscriber?(e.change||(e.change=new g,e.change.add(this.changeSubscriber),this.changeSubscriber=void 0),e.change.add(t)):this.changeSubscriber=t,()=>{this.changeSubscriber===t?this.changeSubscriber=void 0:e.change?.remove(t),this.stopIfUnobserved()}}stopIfUnobserved(){w.read(()=>{this.changeSubscriber||this.events.change?.getSize()||this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,e,s){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,e=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,e&&this.stop(),this.stopPassiveEffect?.()}dirty(){const{current:t,changeSubscriber:e}=this;e?e(t):this.events.change?.notify(t)}addDependent(t){(this.dependents||(this.dependents=new Set)).add(t)}removeDependent(t){this.dependents?.delete(t)}get(){const t=this.animation?.liveValue?.();return void 0===t?this.current:t}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=P.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return s=parseFloat(this.current)-parseFloat(this.prevFrameValue),(n=e)?s*(1e3/n):0;var s,n}start(t){return this.stop(),new Promise(e=>{this.hasAnimated=!0;let s,n=!1;s=t(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===s&&(this.animation=void 0),e()}),n||(this.animation=s),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}}const A={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},R={...A,transform:t=>((t,e,s)=>s>e?e:s<t?t:s)(0,1,t)},V={...A,default:1},X={...A,transform:Math.round},Y=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),x=Y("deg"),E=Y("%"),B=Y("px"),F=(()=>({...E,parse:t=>E.parse(t)/100,transform:t=>E.transform(100*t)}))(),Z={rotate:x,pathRotation:x,rotateX:x,rotateY:x,rotateZ:x,scale:V,scaleX:V,scaleY:V,scaleZ:V,skew:x,skewX:x,skewY:x,distance:B,translateX:B,translateY:B,translateZ:B,x:B,y:B,z:B,perspective:B,transformPerspective:B,opacity:R,originX:F,originY:F,originZ:B},C={borderWidth:B,borderTopWidth:B,borderRightWidth:B,borderBottomWidth:B,borderLeftWidth:B,borderRadius:B,borderTopLeftRadius:B,borderTopRightRadius:B,borderBottomRightRadius:B,borderBottomLeftRadius:B,width:B,maxWidth:B,height:B,maxHeight:B,top:B,right:B,bottom:B,left:B,inset:B,insetBlock:B,insetBlockStart:B,insetBlockEnd:B,insetInline:B,insetInlineStart:B,insetInlineEnd:B,padding:B,paddingTop:B,paddingRight:B,paddingBottom:B,paddingLeft:B,paddingBlock:B,paddingBlockStart:B,paddingBlockEnd:B,paddingInline:B,paddingInlineStart:B,paddingInlineEnd:B,margin:B,marginTop:B,marginRight:B,marginBottom:B,marginLeft:B,marginBlock:B,marginBlockStart:B,marginBlockEnd:B,marginInline:B,marginInlineStart:B,marginInlineEnd:B,fontSize:B,backgroundPositionX:B,backgroundPositionY:B,...Z,zIndex:X,fillOpacity:R,strokeOpacity:R,numOctaves:X},I=(t,e)=>e&&"number"==typeof t?e.transform(t):t,O={};function T(t){const{test:e,read:s,get:n,flush:r,state:i}=t;return Object.assign((e,s)=>{const n=function(t){if(null==t)return[];if(t instanceof EventTarget)return[t];if("string"==typeof t){const e=(O.current?.root||document).querySelectorAll(t);return e?Array.from(e):[]}return Array.from(t).filter(t=>null!=t)}(e),r=[];for(const e of n){const n=t(e,s);r.push(n)}return()=>{for(const t of r)t()}},{test:e,read:s,get:n,flush:r,state:i})}class W{constructor(t=w.render){this.step=t,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{const{pending:t,numPending:e}=this;this.numPending=0;for(let s=0;s<e;s++)t[s]()}}set(t,e,s,n){if(this.values.get(t)?.onRemove(),n)for(const t of this.values.values())t.value===n&&(s=t.render);const r=()=>s&&this.schedule(s);void 0!==e.get()&&r();const i=e.on("change",r),a=()=>{i(),s&&!n&&this.cancel(s),this.values.get(t)?.onRemove===a&&this.values.delete(t)};return this.values.set(t,{value:e,render:n?void 0:s,onRemove:a}),a}get(t){return this.values.get(t)?.value}release(){const t=new Map;return this.values.forEach((e,s)=>{t.set(s,e.value),e.onRemove()}),this.transformKeys=this.transformValues=void 0,t}schedule(t){const{pending:e,numPending:s}=this;for(let n=0;n<s;n++)if(e[n]===t)return;s||this.step(this.flush),e[this.numPending++]=t}cancel(t){const{pending:e}=this;for(let s=0;s<this.numPending;s++)if(e[s]===t)return void(e[s]=e[--this.numPending])}}function z(t,{step:e,...s}={}){const n=new WeakMap;return Object.assign((s,r)=>{const i=n.get(s)??new W(e);n.set(s,i);const a=[];for(const e in r){const n=r[e],o=t(s,i,e,n);a.push(o)}return()=>{for(const t of a)t()}},s,{get:(t,e)=>n.get(t)?.get(e),flush:t=>n.get(t)?.flush(),state:t=>n.get(t)})}const U={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},L={},K=(t,e,s=I(e,Z[t]))=>(L[t]||(L[t]=(U[t]||t)+"("))+s+")",N=(t,e)=>("number"==typeof e?e:parseFloat(e))===(t.startsWith("scale")?1:0);const $=new Set(["originX","originY","originZ"]),j=(t,e)=>I(t.get(e)?.get(),C[e]),q=(s,n,r,i)=>{let a,o;if(l.has(r)){if("pathRotation"!==r){const t=n.transformKeys??(n.transformKeys=[]);(n.transformValues??(n.transformValues={}))[r]=i,t.includes(r)||(t.push(r),t.sort((t,e)=>u.indexOf(t)-u.indexOf(e)))}n.get("transform")||(m(s)||n.get("transformBox")||q(s,n,"transformBox",new M("fill-box")),n.set("transform",new M("none"),()=>{t.get(s)?.check(),s.style.transform=function(t){let e="";const{transformKeys:s=[],transformValues:n={}}=t;for(let t=0;t<s.length;t++){const r=s[t],i=n[r].getCurrent();void 0!==i&&(N(r,i)||(e+=(e&&" ")+K(r,i)))}const r=t.get("pathRotation")?.get();return r&&(e+=(e&&" ")+K("rotate",r)),e||"none"}(n)})),o=n.get("transform")}else $.has(r)?(n.get("transformOrigin")||n.set("transformOrigin",new M(""),()=>{const t=j(n,"originX")??"50%",e=j(n,"originY")??"50%",r=j(n,"originZ")??0;s.style.transformOrigin=`${t} ${e} ${r}`}),o=n.get("transformOrigin")):a=e(r)?()=>{s.style.setProperty(r,i.getCurrent())}:()=>{s.style[r]=I(i.getCurrent(),C[r])};return n.set(r,i,a,o)},D=(t,s)=>{if(l.has(s))return d(t,s);const n=getComputedStyle(t),r=e(s)?n.getPropertyValue(s):n[s];return"string"==typeof r&&r.trim()||0},G=z(q,{test:t=>{return m(t)||f(e=t)&&"ownerSVGElement"in e;var e},read:D}),H=T(G);export{q as addStyleValue,$ as originProps,D as readStyleValue,H as styleEffect,G as styleSubjectEffect};
|
|
1
|
+
const t=new WeakMap,e=t=>t.startsWith("--"),s=t=>180*t/Math.PI,n=t=>{const e=s(Math.atan2(t[1],t[0]));return i(e)},r={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scaleZ:()=>1,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:n,rotateZ:n,skewX:t=>s(Math.atan(t[1])),skewY:t=>s(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},i=t=>((t%=360)<0&&(t+=360),t),a=t=>Math.hypot(t[0],t[1]),o=t=>Math.hypot(t[4],t[5]),c={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:a,scaleY:o,scaleZ:t=>Math.hypot(t[8],t[9],t[10]),scale:t=>(a(t)+o(t))/2,rotateX:t=>i(s(Math.atan2(t[6],t[5]))),rotateY:t=>i(s(Math.atan2(-t[2],t[0]))),rotateZ:n,rotate:n,skewX:t=>s(Math.atan(t[4])),skewY:t=>s(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function h(t){return t.includes("scale")?1:0}const d=(t,e)=>{const{transform:s="none"}=getComputedStyle(t);return function(t,e){if(!t||"none"===t)return h(e);const s=t.match(/^matrix(3d)?\(([-\d.e\s,]+)\)$/u);if(!s)return h(e);const n=(s[1]?c:r)[e],i=s[2].split(",").map(t=>parseFloat(t));return"function"==typeof n?n(i):i[n]}(s,e)},u=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","scaleZ","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],l=(()=>new Set([...u,"pathRotation"]))();const p={},f=t=>"object"==typeof t&&null!==t;class g{constructor(){this.subscriptions=[]}add(t){var e,s;return e=this.subscriptions,s=t,-1===e.indexOf(s)&&e.push(s),()=>this.remove(t)}remove(t){!function(t,e){const s=t.indexOf(e);s>-1&&t.splice(s,1)}(this.subscriptions,t)}notify(t,e,s){const n=this.subscriptions.length;if(n)if(1===n)this.subscriptions[0](t,e,s);else for(let r=0;r<n;r++){const n=this.subscriptions[r];n&&n(t,e,s)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function m(t){return f(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const v=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function b(t,e,s={delta:0,timestamp:0,isProcessing:!1}){let n=!1,r=!0;const i=()=>n=!0,a=v.reduce((t,e)=>(t[e]=function(t){let e,s=new Set,n=new Set,r=!1,i=!1;const a=new Set;let o={delta:0,timestamp:0,isProcessing:!1};function c(s){a.has(s)&&(n.add(s),t()),(e=s)(o)}const h={schedule:(t,i=!1,o=!1)=>{const c=o&&r,h=c?s:n;return i&&a.add(t),c&&t!==e&&h.delete(t),h.add(t),t},cancel:t=>{n.delete(t),a.delete(t)},process:t=>{if(o=t,r)return void(i=!0);r=!0;const a=s;s=n,n=a,s.forEach(c),s.clear(),e=void 0,r=!1,i&&(i=!1,h.process(t))}};return h}(i),t),{}),{setup:o,read:c,resolveKeyframes:h,preUpdate:d,update:u,preRender:l,render:f,postRender:g}=a,m=()=>{const i=p.useManualTiming,a=i?s.timestamp:performance.now();n=!1,i||(s.delta=r?1e3/60:Math.max(Math.min(a-s.timestamp,40),1)),s.timestamp=a,s.isProcessing=!0,o.process(s),c.process(s),h.process(s),d.process(s),u.process(s),l.process(s),f.process(s),g.process(s),s.isProcessing=!1,n&&e&&(r=!1,t(m))};return{schedule:v.reduce((e,i)=>{const o=a[i];return e[i]=(e,i=!1,a=!1)=>(n||(n=!0,r=!0,s.isProcessing||t(m)),o.schedule(e,i,a)),e},{}),cancel:t=>{for(let e=0;e<v.length;e++)a[v[e]].cancel(t)},state:s,steps:a}}const y={delta:0,timestamp:0,isProcessing:!1},{schedule:w}=b("undefined"!=typeof requestAnimationFrame?requestAnimationFrame:t=>t,!0,y);let k;function S(){k=void 0}const P={now:()=>(void 0===k&&P.set(y.isProcessing||p.useManualTiming?y.timestamp:performance.now()),k),set:t=>{k=t,queueMicrotask(S)}};class M{constructor(t,e={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=t=>{const e=P.now();if(this.updatedAt!==e&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(t),this.current!==this.prev&&(this.dirty(),this.dependents))for(const t of this.dependents)t.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=e.owner}setCurrent(t){var e;this.current=t,this.updatedAt=P.now(),null===this.canTrackVelocity&&void 0!==t&&(this.canTrackVelocity=(e=this.current,!isNaN(parseFloat(e))))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,e){var s;return"change"===t?this.onChangeSubscribe(e):((s=this.events)[t]||(s[t]=new g)).add(e)}onChangeSubscribe(t){const{events:e}=this;return e.change||this.changeSubscriber?(e.change||(e.change=new g,e.change.add(this.changeSubscriber),this.changeSubscriber=void 0),e.change.add(t)):this.changeSubscriber=t,()=>{this.changeSubscriber===t?this.changeSubscriber=void 0:e.change?.remove(t),this.stopIfUnobserved()}}stopIfUnobserved(){w.read(()=>{this.changeSubscriber||this.events.change?.getSize()||this.stop()})}clearListeners(){this.changeSubscriber=void 0;for(const t in this.events)this.events[t].clear()}attach(t,e){this.passiveEffect=t,this.stopPassiveEffect=e}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,e,s){this.set(e),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-s}jump(t,e=!0){e&&(this.updatedAt=P.now(),this.stop()),this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,this.stopPassiveEffect?.()}dirty(){const{current:t,changeSubscriber:e}=this;e?e(t):this.events.change?.notify(t)}addDependent(t){(this.dependents||(this.dependents=new Set)).add(t)}removeDependent(t){this.dependents?.delete(t)}get(){const t=this.animation?.liveValue?.();return void 0===t?this.current:t}getCurrent(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=P.now();if(!this.canTrackVelocity||void 0===this.prevFrameValue||t-this.updatedAt>30)return 0;const e=Math.min(this.updatedAt-this.prevUpdatedAt,30);return s=parseFloat(this.current)-parseFloat(this.prevFrameValue),(n=e)?s*(1e3/n):0;var s,n}start(t){return this.stop(),new Promise(e=>{this.hasAnimated=!0;let s,n=!1;s=t(()=>{n=!0,this.events.animationComplete?.notify(),this.animation===s&&(this.animation=void 0),e()}),n||(this.animation=s),this.events.animationStart?.notify()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel?.notify()),this.animation=void 0}isAnimating(){return!!this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect?.()}}const A={test:t=>"number"==typeof t,parse:parseFloat,transform:t=>t},R={...A,transform:t=>((t,e,s)=>s>e?e:s<t?t:s)(0,1,t)},V={...A,default:1},X={...A,transform:Math.round},Y=t=>({test:e=>"string"==typeof e&&e.endsWith(t)&&1===e.split(" ").length,parse:parseFloat,transform:e=>`${e}${t}`}),x=Y("deg"),E=Y("%"),B=Y("px"),F=(()=>({...E,parse:t=>E.parse(t)/100,transform:t=>E.transform(100*t)}))(),Z={rotate:x,pathRotation:x,rotateX:x,rotateY:x,rotateZ:x,scale:V,scaleX:V,scaleY:V,scaleZ:V,skew:x,skewX:x,skewY:x,distance:B,translateX:B,translateY:B,translateZ:B,x:B,y:B,z:B,perspective:B,transformPerspective:B,opacity:R,originX:F,originY:F,originZ:B},C={borderWidth:B,borderTopWidth:B,borderRightWidth:B,borderBottomWidth:B,borderLeftWidth:B,borderRadius:B,borderTopLeftRadius:B,borderTopRightRadius:B,borderBottomRightRadius:B,borderBottomLeftRadius:B,width:B,maxWidth:B,height:B,maxHeight:B,top:B,right:B,bottom:B,left:B,inset:B,insetBlock:B,insetBlockStart:B,insetBlockEnd:B,insetInline:B,insetInlineStart:B,insetInlineEnd:B,padding:B,paddingTop:B,paddingRight:B,paddingBottom:B,paddingLeft:B,paddingBlock:B,paddingBlockStart:B,paddingBlockEnd:B,paddingInline:B,paddingInlineStart:B,paddingInlineEnd:B,margin:B,marginTop:B,marginRight:B,marginBottom:B,marginLeft:B,marginBlock:B,marginBlockStart:B,marginBlockEnd:B,marginInline:B,marginInlineStart:B,marginInlineEnd:B,fontSize:B,backgroundPositionX:B,backgroundPositionY:B,...Z,zIndex:X,fillOpacity:R,strokeOpacity:R,numOctaves:X},I=(t,e)=>e&&"number"==typeof t?e.transform(t):t,O={};function T(t){const{test:e,read:s,get:n,flush:r,state:i}=t;return Object.assign((e,s)=>{const n=function(t){if(null==t)return[];if(t instanceof EventTarget)return[t];if("string"==typeof t){const e=(O.current?.root||document).querySelectorAll(t);return e?Array.from(e):[]}return Array.from(t).filter(t=>null!=t)}(e),r=[];for(const e of n){const n=t(e,s);r.push(n)}return()=>{for(const t of r)t()}},{test:e,read:s,get:n,flush:r,state:i})}class W{constructor(t=w.render){this.step=t,this.values=new Map,this.pending=[],this.numPending=0,this.flush=()=>{const{pending:t,numPending:e}=this;this.numPending=0;for(let s=0;s<e;s++)t[s]()}}set(t,e,s,n){if(this.values.get(t)?.onRemove(),n)for(const t of this.values.values())t.value===n&&(s=t.render);const r=()=>s&&this.schedule(s);void 0!==e.get()&&r();const i=e.on("change",r),a=()=>{i(),s&&!n&&this.cancel(s),this.values.get(t)?.onRemove===a&&this.values.delete(t)};return this.values.set(t,{value:e,render:n?void 0:s,onRemove:a}),a}get(t){return this.values.get(t)?.value}release(){const t=new Map;return this.values.forEach((e,s)=>{t.set(s,e.value),e.onRemove()}),this.transformKeys=this.transformValues=void 0,t}schedule(t){const{pending:e,numPending:s}=this;for(let n=0;n<s;n++)if(e[n]===t)return;s||this.step(this.flush),e[this.numPending++]=t}cancel(t){const{pending:e}=this;for(let s=0;s<this.numPending;s++)if(e[s]===t)return void(e[s]=e[--this.numPending])}}function z(t,{step:e,...s}={}){const n=new WeakMap;return Object.assign((s,r)=>{const i=n.get(s)??new W(e);n.set(s,i);const a=[];for(const e in r){const n=r[e],o=t(s,i,e,n);a.push(o)}return()=>{for(const t of a)t()}},s,{get:(t,e)=>n.get(t)?.get(e),flush:t=>n.get(t)?.flush(),state:t=>n.get(t)})}const U={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},L={},K=(t,e,s=I(e,Z[t]))=>(L[t]||(L[t]=(U[t]||t)+"("))+s+")",N=(t,e)=>("number"==typeof e?e:parseFloat(e))===(t.startsWith("scale")?1:0);const $=new Set(["originX","originY","originZ"]),j=(t,e)=>I(t.get(e)?.get(),C[e]),q=(s,n,r,i)=>{let a,o;if(l.has(r)){if("pathRotation"!==r){const t=n.transformKeys??(n.transformKeys=[]);(n.transformValues??(n.transformValues={}))[r]=i,t.includes(r)||(t.push(r),t.sort((t,e)=>u.indexOf(t)-u.indexOf(e)))}n.get("transform")||(m(s)||n.get("transformBox")||q(s,n,"transformBox",new M("fill-box")),n.set("transform",new M("none"),()=>{t.get(s)?.check(),s.style.transform=function(t){let e="";const{transformKeys:s=[],transformValues:n={}}=t;for(let t=0;t<s.length;t++){const r=s[t],i=n[r].getCurrent();void 0!==i&&(N(r,i)||(e+=(e&&" ")+K(r,i)))}const r=t.get("pathRotation")?.get();return r&&(e+=(e&&" ")+K("rotate",r)),e||"none"}(n)})),o=n.get("transform")}else $.has(r)?(n.get("transformOrigin")||n.set("transformOrigin",new M(""),()=>{const t=j(n,"originX")??"50%",e=j(n,"originY")??"50%",r=j(n,"originZ")??0;s.style.transformOrigin=`${t} ${e} ${r}`}),o=n.get("transformOrigin")):a=e(r)?()=>{s.style.setProperty(r,i.getCurrent())}:()=>{s.style[r]=I(i.getCurrent(),C[r])};return n.set(r,i,a,o)},D=(t,s)=>{if(l.has(s))return d(t,s);const n=getComputedStyle(t),r=e(s)?n.getPropertyValue(s):n[s];return"string"==typeof r&&r.trim()||0},G=z(q,{test:t=>{return m(t)||f(e=t)&&"ownerSVGElement"in e;var e},read:D}),H=T(G);export{q as addStyleValue,$ as originProps,D as readStyleValue,H as styleEffect,G as styleSubjectEffect};
|
|
2
2
|
//# sourceMappingURL=size-rollup-style-effect.js.map
|