@vielzeug/necromancer 2.0.2 → 2.1.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/errors.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var e=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},t=class extends e{},n=class extends e{};exports.NecromancerConfigError=t,exports.NecromancerError=e,exports.NecromancerUnsupportedError=n;
1
+ var e=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},t=class extends e{},n=class extends e{};exports.NecromancerConfigError=t,exports.NecromancerError=e,exports.NecromancerUnsupportedError=n;
2
2
  //# sourceMappingURL=errors.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Narrows an unknown error to any Necromancer-originated error. */\n static is(error: unknown): error is NecromancerError {\n return error instanceof NecromancerError;\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n"],"mappings":"AACA,IAAa,EAAb,MAAa,UAAyB,KAAM,CAC1C,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CAGA,OAAO,GAAG,EAA2C,CACnD,OAAO,aAAiB,CAC1B,CACF,EAGa,EAAb,cAA4C,CAAiB,CAAC,EAGjD,EAAb,cAAiD,CAAiB,CAAC"}
1
+ {"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n"],"mappings":"AACA,IAAa,EAAb,cAAsC,KAAM,CAC1C,YAAY,EAAiB,EAAqB,CAChD,MAAM,EAAS,CAAI,EACnB,KAAK,KAAO,WAAW,KACvB,OAAO,eAAe,KAAM,WAAW,SAAS,CAClD,CACF,EAGa,EAAb,cAA4C,CAAiB,CAAC,EAGjD,EAAb,cAAiD,CAAiB,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  /** Base class for errors raised by `@vielzeug/necromancer`. */
2
2
  export declare class NecromancerError extends Error {
3
3
  constructor(message: string, opts?: ErrorOptions);
4
- /** Narrows an unknown error to any Necromancer-originated error. */
5
- static is(error: unknown): error is NecromancerError;
6
4
  }
7
5
  /** Thrown when a Necromancer-owned option is invalid. */
8
6
  export declare class NecromancerConfigError extends NecromancerError {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;IAMhD,oEAAoE;IACpE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB;CAGrD;AAED,yDAAyD;AACzD,qBAAa,sBAAuB,SAAQ,gBAAgB;CAAG;AAE/D,yEAAyE;AACzE,qBAAa,2BAA4B,SAAQ,gBAAgB;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY;CAKjD;AAED,yDAAyD;AACzD,qBAAa,sBAAuB,SAAQ,gBAAgB;CAAG;AAE/D,yEAAyE;AACzE,qBAAa,2BAA4B,SAAQ,gBAAgB;CAAG"}
package/dist/errors.js CHANGED
@@ -1,11 +1,8 @@
1
1
  //#region src/errors.ts
2
- var e = class e extends Error {
2
+ var e = class extends Error {
3
3
  constructor(e, t) {
4
4
  super(e, t), this.name = new.target.name, Object.setPrototypeOf(this, new.target.prototype);
5
5
  }
6
- static is(t) {
7
- return t instanceof e;
8
- }
9
6
  }, t = class extends e {}, n = class extends e {};
10
7
  //#endregion
11
8
  export { t as NecromancerConfigError, e as NecromancerError, n as NecromancerUnsupportedError };
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Narrows an unknown error to any Necromancer-originated error. */\n static is(error: unknown): error is NecromancerError {\n return error instanceof NecromancerError;\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n"],"mappings":";AACA,IAAa,IAAb,MAAa,UAAyB,MAAM;CAC1C,YAAY,GAAiB,GAAqB;EAGhD,AAFA,MAAM,GAAS,CAAI,GACnB,KAAK,OAAO,WAAW,MACvB,OAAO,eAAe,MAAM,WAAW,SAAS;CAClD;CAGA,OAAO,GAAG,GAA2C;EACnD,OAAO,aAAiB;CAC1B;AACF,GAGa,IAAb,cAA4C,EAAiB,CAAC,GAGjD,IAAb,cAAiD,EAAiB,CAAC"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n"],"mappings":";AACA,IAAa,IAAb,cAAsC,MAAM;CAC1C,YAAY,GAAiB,GAAqB;EAGhD,AAFA,MAAM,GAAS,CAAI,GACnB,KAAK,OAAO,WAAW,MACvB,OAAO,eAAe,MAAM,WAAW,SAAS;CAClD;AACF,GAGa,IAAb,cAA4C,EAAiB,CAAC,GAGjD,IAAb,cAAiD,EAAiB,CAAC"}
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=new WeakMap;function t(t){for(let n of e.get(t)??[])n.dispose()}function n(t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n),n.result.then(()=>{r?.delete(n),r?.size===0&&e.delete(t)})}function r(e,t){let n=()=>t(e.reason);return e.addEventListener(`abort`,n,{once:!0}),()=>e.removeEventListener(`abort`,n)}function i(e,t,n){return e.finished.then(()=>(t(),{status:n?`reduced`:`finished`}),e=>(t(),{reason:e,status:`cancelled`}))}function a(e,t,n=!1){let a=!1,o,s=!1,c,l=i(e,()=>{c?.(),c=void 0},n).then(e=>a&&s&&e.status===`cancelled`?{reason:o,status:`cancelled`}:e),u=t=>{a||(a=!0,o=t,s=t!==void 0,c?.(),c=void 0,e.cancel())};return t&&(c=r(t,u)),{animation:e,dispose:u,get disposed(){return a},result:l,[Symbol.dispose](){this.dispose()}}}function o(e,t){let n=!1,i,a=Promise.all(e.map(e=>e.result)).then(e=>(i?.(),i=void 0,e)),o=t=>{if(!n){n=!0,i?.(),i=void 0;for(let n of e)n.dispose(t)}};return t&&(i=r(t,o)),{dispose:o,get disposed(){return n},handles:e,results:a,[Symbol.dispose](){this.dispose()}}}var s=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},c=class extends s{},l=class extends s{},u=180;function d(e){return e===`full`?!1:e===`reduced`||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function f(e={},t=!1){let{duration:n,interrupt:r,motion:i=`system`,signal:a,...o}=e,s=n===void 0?{...o,duration:u}:{...o,duration:n};return t?{...s,delay:0,duration:0,endDelay:0,iterations:1}:s}function p(e,t){if(t===0)return e;let n=e.delay??0;if(typeof n!=`number`)throw new c(`A non-zero stagger requires a numeric delay; received ${typeof n}.`);return{...e,delay:n+t}}function m(e,r,i={}){if(i.signal?.aborted)throw i.signal.reason;if(typeof e.animate!=`function`)throw new l(`The Web Animations API is not available in this environment.`);i.interrupt===`cancel`&&t(e);let o=d(i.motion??`system`),s=a(e.animate(r,f(i,o)),i.signal,o);return n(e,s),s}function h(e){return[...new Set(e)]}function g(e){if(!Number.isFinite(e)||e<0)throw new c(`stagger must be a finite, non-negative number.`)}function _(e,t,n={}){let{signal:r,stagger:i=0,...a}=n;if(g(i),r?.aborted)throw r.reason;let s=h(e),c=s.map((e,n)=>typeof t==`function`?t(e,n,s.length):t),l=[];try{for(let[e,t]of s.entries()){let n=c[e];l.push(m(t,n,p(a,e*i)))}}catch(e){for(let t of l)t.dispose(e);throw e}return o(l,r)}function v(e,t){let n=10**t;return Math.round(e*n)/n}function y(e){if(`offsetWidth`in e&&`offsetHeight`in e)return{height:e.offsetHeight,width:e.offsetWidth};let t=e.getBoundingClientRect();return{height:t.height,width:t.width}}function b(e){let t=e.getBoundingClientRect(),n=y(e);return{height:n.height,width:n.width,x:t.x,y:t.y}}function x(e,t){return t===0?1:e/t}function S(e,t,n){let r=t(e);if(typeof r!=`string`||r.length===0)throw new c(`getKey must return a non-empty string for every ${n} element.`);return r}function C(e,t,n){let r=new Map;for(let i of e){let e=S(i.element,t,n);if(r.has(e))throw new c(`getKey returned duplicate keys for the ${n} elements.`);r.set(e,i)}return r}function w(e,t){if(!e.isConnected)return;let n=b(e),r=t.x-n.x,i=t.y-n.y,a=x(t.width,n.width),o=x(t.height,n.height);return r===0&&i===0&&a===1&&o===1?void 0:{element:e,scaleX:a,scaleY:o,x:r,y:i}}function T(e,t){let n=new Map(e.map(e=>[e.element,e]));return t.flatMap(e=>{let t=n.get(e);return t?[w(e,t.rect)].filter(e=>!!e):[]})}function E(e,t,n){let r=new Set;return t.flatMap(t=>{let i=S(t,n,`committed`),a=e.get(i);if(r.has(i))throw new c(`getKey returned duplicate keys for the committed elements.`);return r.add(i),a?[w(t,a.rect)].filter(e=>!!e):[]})}function D(e,t={}){let n=h(e).map(e=>({element:e,rect:b(e)})),r=t.getKey,i=r?C(n,r,`captured`):void 0,a=!1;return{animate(e={}){if(a)throw new c(`This layout transition has already been animated.`);let{elements:t,...o}=e,s=h(t??n.map(({element:e})=>e)),l=r&&i?E(i,s,r):T(n,s);return a=!0,_(l.map(({element:e})=>e),(e,t)=>{let n=l[t],r=`${v(n.x,2)}px ${v(n.y,2)}px`;return[{composite:`add`,scale:`${v(n.scaleX,4)} ${v(n.scaleY,4)}`,translate:r},{composite:`add`,scale:`1 1`,translate:`0px 0px`}]},o)}}}exports.NecromancerConfigError=c,exports.NecromancerError=s,exports.NecromancerUnsupportedError=l,exports.animate=m,exports.animateEach=_,exports.captureLayout=D;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=new WeakMap;function t(t){for(let n of e.get(t)??[])n.dispose()}function n(t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n),n.result.then(()=>{r?.delete(n),r?.size===0&&e.delete(t)})}function r(e,t){let n=()=>t(e.reason);return e.addEventListener(`abort`,n,{once:!0}),()=>e.removeEventListener(`abort`,n)}function i(e,t,n){return e.finished.then(()=>(t(),{status:n?`reduced`:`finished`}),e=>(t(),{reason:e,status:`cancelled`}))}function a(e,t,n=!1){let a=!1,o,s=!1,c,l=i(e,()=>{c?.(),c=void 0},n).then(e=>a&&s&&e.status===`cancelled`?{reason:o,status:`cancelled`}:e),u=t=>{a||(a=!0,o=t,s=t!==void 0,c?.(),c=void 0,e.cancel())};return t&&(c=r(t,u)),{animation:e,dispose:u,get disposed(){return a},result:l,[Symbol.dispose](){this.dispose()}}}function o(e,t){let n=!1,i,a=Promise.all(e.map(e=>e.result)).then(e=>(i?.(),i=void 0,e)),o=t=>{if(!n){n=!0,i?.(),i=void 0;for(let n of e)n.dispose(t)}};return t&&(i=r(t,o)),{dispose:o,get disposed(){return n},handles:e,results:a,[Symbol.dispose](){this.dispose()}}}var s=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},c=class extends s{},l=class extends s{},u=180;function d(e){return e===`full`?!1:e===`reduced`||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function f(e={},t=!1){let{duration:n,interrupt:r,motion:i=`system`,signal:a,...o}=e,s=n===void 0?{...o,duration:u}:{...o,duration:n};return t?{...s,delay:0,duration:0,endDelay:0,iterations:1}:s}function p(e,t){if(t===0)return e;let n=e.delay??0;if(typeof n!=`number`)throw new c(`A non-zero stagger requires a numeric delay; received ${typeof n}.`);return{...e,delay:n+t}}function m(e,r,i={}){if(i.signal?.aborted)throw i.signal.reason;if(typeof e.animate!=`function`)throw new l(`The Web Animations API is not available in this environment.`);i.interrupt===`cancel`&&t(e);let o=d(i.motion??`system`),s=a(e.animate(r,f(i,o)),i.signal,o);return n(e,s),s}function h(e){return[...new Set(e)]}function g(e){if(!Number.isFinite(e)||e<0)throw new c(`stagger must be a finite, non-negative number.`)}function _(e,t,n={}){let{signal:r,stagger:i=0,...a}=n;if(g(i),r?.aborted)throw r.reason;let s=h(e),c=s.map((e,n)=>typeof t==`function`?t(e,n,s.length):t),l=[];try{for(let[e,t]of s.entries()){let n=c[e];l.push(m(t,n,p(a,e*i)))}}catch(e){for(let t of l)t.dispose(e);throw e}return o(l,r)}function v(e,t){let n=10**t;return Math.round(e*n)/n}function y(e){if(`offsetWidth`in e&&`offsetHeight`in e)return{height:e.offsetHeight,width:e.offsetWidth};let t=e.getBoundingClientRect();return{height:t.height,width:t.width}}function b(e){let t=e.getBoundingClientRect(),n=y(e);return{height:n.height,width:n.width,x:t.x,y:t.y}}function x(e,t){return t===0?1:e/t}function S(e,t,n){let r=t(e);if(typeof r!=`string`||r.length===0)throw new c(`getKey must return a non-empty string for every ${n} element.`);return r}function C(e,t,n){let r=new Map;for(let i of e){let e=S(i.element,t,n);if(r.has(e))throw new c(`getKey returned duplicate keys for the ${n} elements.`);r.set(e,i)}return r}function w(e,t){if(!e.isConnected)return;let n=b(e),r=t.x-n.x,i=t.y-n.y,a=x(t.width,n.width),o=x(t.height,n.height);return r===0&&i===0&&a===1&&o===1?void 0:{element:e,scaleX:a,scaleY:o,x:r,y:i}}function T(e,t){let n=new Map(e.map(e=>[e.element,e]));return t.flatMap(e=>{let t=n.get(e);return t?[w(e,t.rect)].filter(e=>!!e):[]})}function E(e,t,n){let r=new Set;return t.flatMap(t=>{let i=S(t,n,`committed`),a=e.get(i);if(r.has(i))throw new c(`getKey returned duplicate keys for the committed elements.`);return r.add(i),a?[w(t,a.rect)].filter(e=>!!e):[]})}function D(e,t={}){let n=h(e).map(e=>({element:e,rect:b(e)})),r=t.getKey,i=r?C(n,r,`captured`):void 0,a=!1;return{animate(e={}){if(a)throw new c(`This layout transition has already been animated.`);let{elements:t,...o}=e,s=h(t??n.map(({element:e})=>e)),l=r&&i?E(i,s,r):T(n,s);return a=!0,_(l.map(({element:e})=>e),(e,t)=>{let n=l[t],r=`${v(n.x,2)}px ${v(n.y,2)}px`;return[{composite:`add`,scale:`${v(n.scaleX,4)} ${v(n.scaleY,4)}`,translate:r},{composite:`add`,scale:`1 1`,translate:`0px 0px`}]},o)}}}exports.NecromancerConfigError=c,exports.NecromancerError=s,exports.NecromancerUnsupportedError=l,exports.animate=m,exports.animateEach=_,exports.captureLayout=D;
2
2
  //# sourceMappingURL=necromancer.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"necromancer.cjs","names":[],"sources":["../src/_active.ts","../src/_handle.ts","../src/errors.ts","../src/_motion.ts","../src/animate.ts","../src/_elements.ts","../src/animate-each.ts","../src/layout.ts"],"sourcesContent":["import type { AnimationHandle } from './types';\n\n// Scoped to one DOM element by design: `interrupt: 'cancel'` answers \"replace whatever\n// Necromancer is doing to *this* element\", not \"coordinate across element categories\".\n// A caller that needs to cancel an animation on a different element (or coordinate several\n// elements as one unit) already has that element's own handle, or should use `animateEach()`\n// and a shared `signal` instead. Keeping the WeakMap element-scoped means it only ever needs\n// to answer one question and never grows into a general-purpose animation registry.\nconst handlesByElement = new WeakMap<Element, Set<AnimationHandle>>();\n\n/** Cancels active Necromancer-owned animations without touching native animations owned by callers. */\nexport function interruptAnimations(element: Element): void {\n for (const handle of handlesByElement.get(element) ?? []) handle.dispose();\n}\n\n/** Tracks a handle until its terminal result releases the element association. */\nexport function trackAnimation(element: Element, handle: AnimationHandle): void {\n let handles = handlesByElement.get(element);\n\n if (!handles) {\n handles = new Set();\n handlesByElement.set(element, handles);\n }\n\n handles.add(handle);\n\n void handle.result.then(() => {\n handles?.delete(handle);\n\n if (handles?.size === 0) handlesByElement.delete(element);\n });\n}\n","import type { AnimationGroup, AnimationHandle, AnimationResult } from './types';\n\n/**\n * Attaches an abort listener to a signal and returns a function that removes it.\n * When the signal aborts, calls the dispose function with the signal's reason.\n */\nfunction attachAbortSignalListener(signal: AbortSignal, dispose: (reason?: unknown) => void): () => void {\n const abort = () => dispose(signal.reason);\n\n signal.addEventListener('abort', abort, { once: true });\n\n return () => signal.removeEventListener('abort', abort);\n}\n\nfunction createResultPromise(animation: Animation, onSettled: () => void, reduced: boolean): Promise<AnimationResult> {\n return animation.finished.then(\n () => {\n onSettled();\n\n return { status: reduced ? 'reduced' : 'finished' };\n },\n (reason: unknown) => {\n onSettled();\n\n return { reason, status: 'cancelled' };\n },\n );\n}\n\n/** Wraps a native Animation with Necromancer's lifecycle contract. */\nexport function createAnimationHandle(animation: Animation, signal?: AbortSignal, reduced = false): AnimationHandle {\n let disposed = false;\n let disposeReason: unknown;\n let hasDisposeReason = false;\n let removeAbortListener: (() => void) | undefined;\n\n const result: Promise<AnimationResult> = createResultPromise(\n animation,\n () => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n },\n reduced,\n ).then((outcome): AnimationResult => {\n if (disposed && hasDisposeReason && outcome.status === 'cancelled') {\n return { reason: disposeReason, status: 'cancelled' };\n }\n\n return outcome;\n });\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n disposeReason = reason;\n hasDisposeReason = reason !== undefined;\n removeAbortListener?.();\n removeAbortListener = undefined;\n animation.cancel();\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n animation,\n dispose,\n get disposed() {\n return disposed;\n },\n result,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\n/** Combines child animation handles under one disposal owner. */\nexport function createAnimationGroup(handles: readonly AnimationHandle[], signal?: AbortSignal): AnimationGroup {\n let disposed = false;\n let removeAbortListener: (() => void) | undefined;\n\n const results: Promise<readonly AnimationResult[]> = Promise.all(handles.map((handle) => handle.result)).then(\n (childResults): readonly AnimationResult[] => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n\n return childResults;\n },\n );\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n removeAbortListener?.();\n removeAbortListener = undefined;\n for (const handle of handles) handle.dispose(reason);\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n handles,\n results,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n","/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Narrows an unknown error to any Necromancer-originated error. */\n static is(error: unknown): error is NecromancerError {\n return error instanceof NecromancerError;\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n","import { NecromancerConfigError } from './errors';\nimport type { AnimateOptions, MotionMode } from './types';\n\nconst DEFAULT_DURATION = 180;\n\n/** Reports whether the requested motion preference reduces visible movement. */\nexport function shouldReduceMotion(mode: MotionMode): boolean {\n if (mode === 'full') return false;\n\n if (mode === 'reduced') return true;\n\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Converts ownership options to native timing, collapsing reduced motion to an instant transition. */\nexport function resolveAnimationOptions(options: AnimateOptions = {}, reduced = false): KeyframeAnimationOptions {\n const { duration, interrupt: _interrupt, motion: _motion = 'system', signal: _signal, ...nativeOptions } = options;\n const timing =\n duration === undefined ? { ...nativeOptions, duration: DEFAULT_DURATION } : { ...nativeOptions, duration };\n\n return reduced ? { ...timing, delay: 0, duration: 0, endDelay: 0, iterations: 1 } : timing;\n}\n\n/** Adds an element's stagger offset without changing native nonnumeric delays when no offset is needed. */\nexport function withStaggeredDelay(options: AnimateOptions, offset: number): AnimateOptions {\n if (offset === 0) return options;\n\n const delay = options.delay ?? 0;\n\n if (typeof delay !== 'number') {\n throw new NecromancerConfigError(`A non-zero stagger requires a numeric delay; received ${typeof delay}.`);\n }\n\n return { ...options, delay: delay + offset };\n}\n","import { interruptAnimations, trackAnimation } from './_active';\nimport { createAnimationHandle } from './_handle';\nimport { resolveAnimationOptions, shouldReduceMotion } from './_motion';\nimport { NecromancerUnsupportedError } from './errors';\nimport type { AnimateOptions, AnimationHandle, Keyframes } from './types';\n\n/**\n * Starts a lifecycle-owned native Web Animation for one element.\n *\n * The returned handle cancels its native animation when disposed. By default, the\n * operating system's reduced-motion preference suppresses movement.\n */\nexport function animate(element: Element, keyframes: Keyframes, options: AnimateOptions = {}): AnimationHandle {\n if (options.signal?.aborted) throw options.signal.reason;\n\n if (typeof element.animate !== 'function') {\n throw new NecromancerUnsupportedError('The Web Animations API is not available in this environment.');\n }\n\n if (options.interrupt === 'cancel') interruptAnimations(element);\n\n const reduced = shouldReduceMotion(options.motion ?? 'system');\n const nativeAnimation = element.animate(\n keyframes as Keyframe[] | PropertyIndexedKeyframes,\n resolveAnimationOptions(options, reduced),\n );\n const handle = createAnimationHandle(nativeAnimation, options.signal, reduced);\n\n trackAnimation(element, handle);\n\n return handle;\n}\n","/** Deduplicates elements while preserving first-seen order. Shared by `animateEach()` and `captureLayout()`. */\nexport function uniqueElements(elements: Iterable<Element>): Element[] {\n return [...new Set(elements)];\n}\n","import { uniqueElements } from './_elements';\nimport { createAnimationGroup } from './_handle';\nimport { withStaggeredDelay } from './_motion';\nimport { animate } from './animate';\nimport { NecromancerConfigError } from './errors';\nimport type { AnimateEachOptions, AnimationGroup, AnimationHandle, KeyframeFactory, Keyframes } from './types';\n\nfunction validateStagger(stagger: number): void {\n if (!Number.isFinite(stagger) || stagger < 0) {\n throw new NecromancerConfigError('stagger must be a finite, non-negative number.');\n }\n}\n\n/**\n * Starts lifecycle-owned animations for unique elements in iteration order.\n *\n * Each subsequent element starts after `stagger` milliseconds. A keyframe factory\n * receives the stable unique-element index and total before any animation starts.\n */\nexport function animateEach(\n elements: Iterable<Element>,\n keyframes: Keyframes | KeyframeFactory,\n options: AnimateEachOptions = {},\n): AnimationGroup {\n const { signal, stagger = 0, ...animationOptions } = options;\n\n validateStagger(stagger);\n\n if (signal?.aborted) throw signal.reason;\n\n const unique = uniqueElements(elements);\n const frames = unique.map((element, index) =>\n typeof keyframes === 'function' ? keyframes(element, index, unique.length) : keyframes,\n );\n const handles: AnimationHandle[] = [];\n\n try {\n for (const [index, element] of unique.entries()) {\n // `frames` was built above from `unique`, one entry per element, so this index is always in range.\n const currentFrames = frames[index]!;\n\n handles.push(animate(element, currentFrames, withStaggeredDelay(animationOptions, index * stagger)));\n }\n } catch (error) {\n for (const handle of handles) handle.dispose(error);\n\n throw error;\n }\n\n return createAnimationGroup(handles, signal);\n}\n","import { uniqueElements } from './_elements';\nimport { animateEach } from './animate-each';\nimport { NecromancerConfigError } from './errors';\nimport type { LayoutAnimationOptions, LayoutCaptureOptions, LayoutTransition } from './types';\n\ntype LayoutRect = Readonly<Pick<DOMRectReadOnly, 'height' | 'width' | 'x' | 'y'>>;\ntype LayoutEntry = Readonly<{ element: Element; rect: LayoutRect }>;\ntype LayoutChange = Readonly<{ element: Element; scaleX: number; scaleY: number; x: number; y: number }>;\n\n// Rounds before templating into a keyframe string purely for DevTools readability — a `getBoundingClientRect()`\n// subtraction routinely produces values like `12.340000000000002`, which is noise once rendered as CSS.\n// Pixels only need whole-number precision; scale factors (close to 1) need finer precision to stay visually exact.\nfunction round(value: number, precision: number): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n// `getBoundingClientRect()`'s width/height is the rotated, axis-aligned bounding box — using it\n// for size would distort the scale ratio under any rotation. `offsetWidth`/`offsetHeight` report\n// the box's own untransformed layout size instead. Elements without an offset box (e.g. SVG)\n// fall back to the bounding rect, accepting that same distortion as the only option available.\nfunction measureSize(element: Element): Readonly<{ height: number; width: number }> {\n if ('offsetWidth' in element && 'offsetHeight' in element) {\n return { height: (element as HTMLElement).offsetHeight, width: (element as HTMLElement).offsetWidth };\n }\n\n const rect = element.getBoundingClientRect();\n\n return { height: rect.height, width: rect.width };\n}\n\nfunction measureLayout(element: Element): LayoutRect {\n const rect = element.getBoundingClientRect();\n const size = measureSize(element);\n\n return { height: size.height, width: size.width, x: rect.x, y: rect.y };\n}\n\n// `next` is 0 exactly when the element has collapsed (e.g. `display: none` mid-transition);\n// there's no meaningful ratio to compute then, so treat it as unscaled rather than producing Infinity/NaN.\nfunction computeScale(captured: number, next: number): number {\n return next === 0 ? 1 : captured / next;\n}\n\nfunction readKey(element: Element, getKey: (element: Element) => string, phase: string): string {\n const key = getKey(element);\n\n if (typeof key !== 'string' || key.length === 0) {\n throw new NecromancerConfigError(`getKey must return a non-empty string for every ${phase} element.`);\n }\n\n return key;\n}\n\nfunction createKeyMap(entries: readonly LayoutEntry[], getKey: (element: Element) => string, phase: string) {\n const keys = new Map<string, LayoutEntry>();\n\n for (const entry of entries) {\n const key = readKey(entry.element, getKey, phase);\n\n if (keys.has(key)) {\n throw new NecromancerConfigError(`getKey returned duplicate keys for the ${phase} elements.`);\n }\n\n keys.set(key, entry);\n }\n\n return keys;\n}\n\nfunction changedElement(element: Element, rect: LayoutRect): LayoutChange | undefined {\n if (!element.isConnected) return undefined;\n\n const next = measureLayout(element);\n const x = rect.x - next.x;\n const y = rect.y - next.y;\n const scaleX = computeScale(rect.width, next.width);\n const scaleY = computeScale(rect.height, next.height);\n\n return x === 0 && y === 0 && scaleX === 1 && scaleY === 1 ? undefined : { element, scaleX, scaleY, x, y };\n}\n\nfunction matchByIdentity(entries: readonly LayoutEntry[], elements: readonly Element[]): LayoutChange[] {\n const captured = new Map(entries.map((entry) => [entry.element, entry]));\n\n return elements.flatMap((element) => {\n const entry = captured.get(element);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\nfunction matchByKey(\n captured: ReadonlyMap<string, LayoutEntry>,\n elements: readonly Element[],\n getKey: (element: Element) => string,\n): LayoutChange[] {\n const committed = new Set<string>();\n\n return elements.flatMap((element) => {\n const key = readKey(element, getKey, 'committed');\n const entry = captured.get(key);\n\n if (committed.has(key)) {\n throw new NecromancerConfigError('getKey returned duplicate keys for the committed elements.');\n }\n\n committed.add(key);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\n/**\n * Captures the current position and size of unique elements for a later FLIP animation.\n *\n * Each element's `x`/`y` position and `width`/`height` are captured. Rotation and other\n * transforms are not captured or compensated. Capture before mutating the DOM, then call\n * the returned transition's `animate()` method after the browser has applied the resulting\n * layout — position changes animate via translate, and size changes via scale, both\n * additively composed on top of any authored transform.\n */\nexport function captureLayout(elements: Iterable<Element>, options: LayoutCaptureOptions = {}): LayoutTransition {\n const entries: LayoutEntry[] = uniqueElements(elements).map((element) => ({\n element,\n rect: measureLayout(element),\n }));\n const getKey = options.getKey;\n const captured = getKey ? createKeyMap(entries, getKey, 'captured') : undefined;\n\n let consumed = false;\n\n return {\n animate(options: LayoutAnimationOptions = {}) {\n if (consumed) throw new NecromancerConfigError('This layout transition has already been animated.');\n\n const { elements: committedElements, ...animationOptions } = options;\n const elements = uniqueElements(committedElements ?? entries.map(({ element }) => element));\n const changed = getKey && captured ? matchByKey(captured, elements, getKey) : matchByIdentity(entries, elements);\n\n consumed = true;\n\n return animateEach(\n changed.map(({ element }) => element),\n (_, index) => {\n // `changed` was mapped directly into the elements array above, so this index is always in range.\n const change = changed[index]!;\n const translate = `${round(change.x, 2)}px ${round(change.y, 2)}px`;\n const scale = `${round(change.scaleX, 4)} ${round(change.scaleY, 4)}`;\n\n return [\n { composite: 'add', scale, translate },\n { composite: 'add', scale: '1 1', translate: '0px 0px' },\n ];\n },\n animationOptions,\n );\n },\n };\n}\n"],"mappings":"mEAQA,IAAM,EAAmB,IAAI,QAG7B,SAAgB,EAAoB,EAAwB,CAC1D,IAAK,IAAM,KAAU,EAAiB,IAAI,CAAO,GAAK,CAAC,EAAG,EAAO,QAAQ,CAC3E,CAGA,SAAgB,EAAe,EAAkB,EAA+B,CAC9E,IAAI,EAAU,EAAiB,IAAI,CAAO,EAErC,IACH,EAAU,IAAI,IACd,EAAiB,IAAI,EAAS,CAAO,GAGvC,EAAQ,IAAI,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KAAK,CAAE,aAAc,CAAO,CAAC,EACpF,EAAU,GAAU,EAAW,EAAW,EAAU,EAAU,CAAM,EAAI,EAAgB,EAAS,CAAQ,EAI/G,MAFA,GAAW,GAEJ,EACL,EAAQ,KAAK,CAAE,aAAc,CAAO,GACnC,EAAG,IAAU,CAEZ,IAAM,EAAS,EAAQ,GACjB,EAAY,GAAG,EAAM,EAAO,EAAG,CAAC,EAAE,KAAK,EAAM,EAAO,EAAG,CAAC,EAAE,IAGhE,MAAO,CACL,CAAE,UAAW,MAAO,MAAA,GAHL,EAAM,EAAO,OAAQ,CAAC,EAAE,GAAG,EAAM,EAAO,OAAQ,CAAC,IAGrC,WAAU,EACrC,CAAE,UAAW,MAAO,MAAO,MAAO,UAAW,SAAU,CACzD,CACF,EACA,CACF,CACF,CACF,CACF"}
1
+ {"version":3,"file":"necromancer.cjs","names":[],"sources":["../src/_active.ts","../src/_handle.ts","../src/errors.ts","../src/_motion.ts","../src/animate.ts","../src/_elements.ts","../src/animate-each.ts","../src/layout.ts"],"sourcesContent":["import type { AnimationHandle } from './types';\n\n// Scoped to one DOM element by design: `interrupt: 'cancel'` answers \"replace whatever\n// Necromancer is doing to *this* element\", not \"coordinate across element categories\".\n// A caller that needs to cancel an animation on a different element (or coordinate several\n// elements as one unit) already has that element's own handle, or should use `animateEach()`\n// and a shared `signal` instead. Keeping the WeakMap element-scoped means it only ever needs\n// to answer one question and never grows into a general-purpose animation registry.\nconst handlesByElement = new WeakMap<Element, Set<AnimationHandle>>();\n\n/** Cancels active Necromancer-owned animations without touching native animations owned by callers. */\nexport function interruptAnimations(element: Element): void {\n for (const handle of handlesByElement.get(element) ?? []) handle.dispose();\n}\n\n/** Tracks a handle until its terminal result releases the element association. */\nexport function trackAnimation(element: Element, handle: AnimationHandle): void {\n let handles = handlesByElement.get(element);\n\n if (!handles) {\n handles = new Set();\n handlesByElement.set(element, handles);\n }\n\n handles.add(handle);\n\n void handle.result.then(() => {\n handles?.delete(handle);\n\n if (handles?.size === 0) handlesByElement.delete(element);\n });\n}\n","import type { AnimationGroup, AnimationHandle, AnimationResult } from './types';\n\n/**\n * Attaches an abort listener to a signal and returns a function that removes it.\n * When the signal aborts, calls the dispose function with the signal's reason.\n */\nfunction attachAbortSignalListener(signal: AbortSignal, dispose: (reason?: unknown) => void): () => void {\n const abort = () => dispose(signal.reason);\n\n signal.addEventListener('abort', abort, { once: true });\n\n return () => signal.removeEventListener('abort', abort);\n}\n\nfunction createResultPromise(animation: Animation, onSettled: () => void, reduced: boolean): Promise<AnimationResult> {\n return animation.finished.then(\n () => {\n onSettled();\n\n return { status: reduced ? 'reduced' : 'finished' };\n },\n (reason: unknown) => {\n onSettled();\n\n return { reason, status: 'cancelled' };\n },\n );\n}\n\n/** Wraps a native Animation with Necromancer's lifecycle contract. */\nexport function createAnimationHandle(animation: Animation, signal?: AbortSignal, reduced = false): AnimationHandle {\n let disposed = false;\n let disposeReason: unknown;\n let hasDisposeReason = false;\n let removeAbortListener: (() => void) | undefined;\n\n const result: Promise<AnimationResult> = createResultPromise(\n animation,\n () => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n },\n reduced,\n ).then((outcome): AnimationResult => {\n if (disposed && hasDisposeReason && outcome.status === 'cancelled') {\n return { reason: disposeReason, status: 'cancelled' };\n }\n\n return outcome;\n });\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n disposeReason = reason;\n hasDisposeReason = reason !== undefined;\n removeAbortListener?.();\n removeAbortListener = undefined;\n animation.cancel();\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n animation,\n dispose,\n get disposed() {\n return disposed;\n },\n result,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\n/** Combines child animation handles under one disposal owner. */\nexport function createAnimationGroup(handles: readonly AnimationHandle[], signal?: AbortSignal): AnimationGroup {\n let disposed = false;\n let removeAbortListener: (() => void) | undefined;\n\n const results: Promise<readonly AnimationResult[]> = Promise.all(handles.map((handle) => handle.result)).then(\n (childResults): readonly AnimationResult[] => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n\n return childResults;\n },\n );\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n removeAbortListener?.();\n removeAbortListener = undefined;\n for (const handle of handles) handle.dispose(reason);\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n handles,\n results,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n","/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n","import { NecromancerConfigError } from './errors';\nimport type { AnimateOptions, MotionMode } from './types';\n\nconst DEFAULT_DURATION = 180;\n\n/** Reports whether the requested motion preference reduces visible movement. */\nexport function shouldReduceMotion(mode: MotionMode): boolean {\n if (mode === 'full') return false;\n\n if (mode === 'reduced') return true;\n\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Converts ownership options to native timing, collapsing reduced motion to an instant transition. */\nexport function resolveAnimationOptions(options: AnimateOptions = {}, reduced = false): KeyframeAnimationOptions {\n const { duration, interrupt: _interrupt, motion: _motion = 'system', signal: _signal, ...nativeOptions } = options;\n const timing =\n duration === undefined ? { ...nativeOptions, duration: DEFAULT_DURATION } : { ...nativeOptions, duration };\n\n return reduced ? { ...timing, delay: 0, duration: 0, endDelay: 0, iterations: 1 } : timing;\n}\n\n/** Adds an element's stagger offset without changing native nonnumeric delays when no offset is needed. */\nexport function withStaggeredDelay(options: AnimateOptions, offset: number): AnimateOptions {\n if (offset === 0) return options;\n\n const delay = options.delay ?? 0;\n\n if (typeof delay !== 'number') {\n throw new NecromancerConfigError(`A non-zero stagger requires a numeric delay; received ${typeof delay}.`);\n }\n\n return { ...options, delay: delay + offset };\n}\n","import { interruptAnimations, trackAnimation } from './_active';\nimport { createAnimationHandle } from './_handle';\nimport { resolveAnimationOptions, shouldReduceMotion } from './_motion';\nimport { NecromancerUnsupportedError } from './errors';\nimport type { AnimateOptions, AnimationHandle, Keyframes } from './types';\n\n/**\n * Starts a lifecycle-owned native Web Animation for one element.\n *\n * The returned handle cancels its native animation when disposed. By default, the\n * operating system's reduced-motion preference suppresses movement.\n */\nexport function animate(element: Element, keyframes: Keyframes, options: AnimateOptions = {}): AnimationHandle {\n if (options.signal?.aborted) throw options.signal.reason;\n\n if (typeof element.animate !== 'function') {\n throw new NecromancerUnsupportedError('The Web Animations API is not available in this environment.');\n }\n\n if (options.interrupt === 'cancel') interruptAnimations(element);\n\n const reduced = shouldReduceMotion(options.motion ?? 'system');\n const nativeAnimation = element.animate(\n keyframes as Keyframe[] | PropertyIndexedKeyframes,\n resolveAnimationOptions(options, reduced),\n );\n const handle = createAnimationHandle(nativeAnimation, options.signal, reduced);\n\n trackAnimation(element, handle);\n\n return handle;\n}\n","/** Deduplicates elements while preserving first-seen order. Shared by `animateEach()` and `captureLayout()`. */\nexport function uniqueElements(elements: Iterable<Element>): Element[] {\n return [...new Set(elements)];\n}\n","import { uniqueElements } from './_elements';\nimport { createAnimationGroup } from './_handle';\nimport { withStaggeredDelay } from './_motion';\nimport { animate } from './animate';\nimport { NecromancerConfigError } from './errors';\nimport type { AnimateEachOptions, AnimationGroup, AnimationHandle, KeyframeFactory, Keyframes } from './types';\n\nfunction validateStagger(stagger: number): void {\n if (!Number.isFinite(stagger) || stagger < 0) {\n throw new NecromancerConfigError('stagger must be a finite, non-negative number.');\n }\n}\n\n/**\n * Starts lifecycle-owned animations for unique elements in iteration order.\n *\n * Each subsequent element starts after `stagger` milliseconds. A keyframe factory\n * receives the stable unique-element index and total before any animation starts.\n */\nexport function animateEach(\n elements: Iterable<Element>,\n keyframes: Keyframes | KeyframeFactory,\n options: AnimateEachOptions = {},\n): AnimationGroup {\n const { signal, stagger = 0, ...animationOptions } = options;\n\n validateStagger(stagger);\n\n if (signal?.aborted) throw signal.reason;\n\n const unique = uniqueElements(elements);\n const frames = unique.map((element, index) =>\n typeof keyframes === 'function' ? keyframes(element, index, unique.length) : keyframes,\n );\n const handles: AnimationHandle[] = [];\n\n try {\n for (const [index, element] of unique.entries()) {\n // `frames` was built above from `unique`, one entry per element, so this index is always in range.\n const currentFrames = frames[index]!;\n\n handles.push(animate(element, currentFrames, withStaggeredDelay(animationOptions, index * stagger)));\n }\n } catch (error) {\n for (const handle of handles) handle.dispose(error);\n\n throw error;\n }\n\n return createAnimationGroup(handles, signal);\n}\n","import { uniqueElements } from './_elements';\nimport { animateEach } from './animate-each';\nimport { NecromancerConfigError } from './errors';\nimport type { LayoutAnimationOptions, LayoutCaptureOptions, LayoutTransition } from './types';\n\ntype LayoutRect = Readonly<Pick<DOMRectReadOnly, 'height' | 'width' | 'x' | 'y'>>;\ntype LayoutEntry = Readonly<{ element: Element; rect: LayoutRect }>;\ntype LayoutChange = Readonly<{ element: Element; scaleX: number; scaleY: number; x: number; y: number }>;\n\n// Rounds before templating into a keyframe string purely for DevTools readability — a `getBoundingClientRect()`\n// subtraction routinely produces values like `12.340000000000002`, which is noise once rendered as CSS.\n// Pixels only need whole-number precision; scale factors (close to 1) need finer precision to stay visually exact.\nfunction round(value: number, precision: number): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n// `getBoundingClientRect()`'s width/height is the rotated, axis-aligned bounding box — using it\n// for size would distort the scale ratio under any rotation. `offsetWidth`/`offsetHeight` report\n// the box's own untransformed layout size instead. Elements without an offset box (e.g. SVG)\n// fall back to the bounding rect, accepting that same distortion as the only option available.\nfunction measureSize(element: Element): Readonly<{ height: number; width: number }> {\n if ('offsetWidth' in element && 'offsetHeight' in element) {\n return { height: (element as HTMLElement).offsetHeight, width: (element as HTMLElement).offsetWidth };\n }\n\n const rect = element.getBoundingClientRect();\n\n return { height: rect.height, width: rect.width };\n}\n\nfunction measureLayout(element: Element): LayoutRect {\n const rect = element.getBoundingClientRect();\n const size = measureSize(element);\n\n return { height: size.height, width: size.width, x: rect.x, y: rect.y };\n}\n\n// `next` is 0 exactly when the element has collapsed (e.g. `display: none` mid-transition);\n// there's no meaningful ratio to compute then, so treat it as unscaled rather than producing Infinity/NaN.\nfunction computeScale(captured: number, next: number): number {\n return next === 0 ? 1 : captured / next;\n}\n\nfunction readKey(element: Element, getKey: (element: Element) => string, phase: string): string {\n const key = getKey(element);\n\n if (typeof key !== 'string' || key.length === 0) {\n throw new NecromancerConfigError(`getKey must return a non-empty string for every ${phase} element.`);\n }\n\n return key;\n}\n\nfunction createKeyMap(entries: readonly LayoutEntry[], getKey: (element: Element) => string, phase: string) {\n const keys = new Map<string, LayoutEntry>();\n\n for (const entry of entries) {\n const key = readKey(entry.element, getKey, phase);\n\n if (keys.has(key)) {\n throw new NecromancerConfigError(`getKey returned duplicate keys for the ${phase} elements.`);\n }\n\n keys.set(key, entry);\n }\n\n return keys;\n}\n\nfunction changedElement(element: Element, rect: LayoutRect): LayoutChange | undefined {\n if (!element.isConnected) return undefined;\n\n const next = measureLayout(element);\n const x = rect.x - next.x;\n const y = rect.y - next.y;\n const scaleX = computeScale(rect.width, next.width);\n const scaleY = computeScale(rect.height, next.height);\n\n return x === 0 && y === 0 && scaleX === 1 && scaleY === 1 ? undefined : { element, scaleX, scaleY, x, y };\n}\n\nfunction matchByIdentity(entries: readonly LayoutEntry[], elements: readonly Element[]): LayoutChange[] {\n const captured = new Map(entries.map((entry) => [entry.element, entry]));\n\n return elements.flatMap((element) => {\n const entry = captured.get(element);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\nfunction matchByKey(\n captured: ReadonlyMap<string, LayoutEntry>,\n elements: readonly Element[],\n getKey: (element: Element) => string,\n): LayoutChange[] {\n const committed = new Set<string>();\n\n return elements.flatMap((element) => {\n const key = readKey(element, getKey, 'committed');\n const entry = captured.get(key);\n\n if (committed.has(key)) {\n throw new NecromancerConfigError('getKey returned duplicate keys for the committed elements.');\n }\n\n committed.add(key);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\n/**\n * Captures the current position and size of unique elements for a later FLIP animation.\n *\n * Each element's `x`/`y` position and `width`/`height` are captured. Rotation and other\n * transforms are not captured or compensated. Capture before mutating the DOM, then call\n * the returned transition's `animate()` method after the browser has applied the resulting\n * layout — position changes animate via translate, and size changes via scale, both\n * additively composed on top of any authored transform.\n */\nexport function captureLayout(elements: Iterable<Element>, options: LayoutCaptureOptions = {}): LayoutTransition {\n const entries: LayoutEntry[] = uniqueElements(elements).map((element) => ({\n element,\n rect: measureLayout(element),\n }));\n const getKey = options.getKey;\n const captured = getKey ? createKeyMap(entries, getKey, 'captured') : undefined;\n\n let consumed = false;\n\n return {\n animate(options: LayoutAnimationOptions = {}) {\n if (consumed) throw new NecromancerConfigError('This layout transition has already been animated.');\n\n const { elements: committedElements, ...animationOptions } = options;\n const elements = uniqueElements(committedElements ?? entries.map(({ element }) => element));\n const changed = getKey && captured ? matchByKey(captured, elements, getKey) : matchByIdentity(entries, elements);\n\n consumed = true;\n\n return animateEach(\n changed.map(({ element }) => element),\n (_, index) => {\n // `changed` was mapped directly into the elements array above, so this index is always in range.\n const change = changed[index]!;\n const translate = `${round(change.x, 2)}px ${round(change.y, 2)}px`;\n const scale = `${round(change.scaleX, 4)} ${round(change.scaleY, 4)}`;\n\n return [\n { composite: 'add', scale, translate },\n { composite: 'add', scale: '1 1', translate: '0px 0px' },\n ];\n },\n animationOptions,\n );\n },\n };\n}\n"],"mappings":"mEAQA,IAAM,EAAmB,IAAI,QAG7B,SAAgB,EAAoB,EAAwB,CAC1D,IAAK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AO,CACL,QAAQ,EAAkC,CAAC,EAAG,CAC5C,GAAI,EAAU,MAAM,IAAI,EAAuB,mDAAmD,EAElG,GAAM,CAAE,SAAU,EAAmB,GAAG,GAAqB,EACvD,EAAW,EAAe,GAAqB,EAAQ,KAAK,CAAE,aAAc,CAAO,CAAC,EACpF,EAAU,GAAU,EAAW,EAAW,EAAU,EAAU,CAAM,EAAI,EAAgB,EAAS,CAAQ,EAI/G,MAFA,GAAW,GAEJ,EACL,EAAQ,KAAK,CAAE,aAAc,CAAO,GACnC,EAAG,IAAU,CAEZ,IAAM,EAAS,EAAQ,GACjB,EAAY,GAAG,EAAM,EAAO,EAAG,CAAC,EAAE,KAAK,EAAM,EAAO,EAAG,CAAC,EAAE,IAGhE,MAAO,CACL,CAAE,UAAW,MAAO,MAAA,GAHL,EAAM,EAAO,OAAQ,CAAC,EAAE,GAAG,EAAM,EAAO,OAAQ,CAAC,IAGrC,WAAU,EACrC,CAAE,UAAW,MAAO,MAAO,MAAO,UAAW,SAAU,CACzD,CACF,EACA,CACF,CACF,CACF,CACF"}
@@ -1,2 +1,2 @@
1
- var Necromancer=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=new WeakMap;function n(e){for(let n of t.get(e)??[])n.dispose()}function r(e,n){let r=t.get(e);r||(r=new Set,t.set(e,r)),r.add(n),n.result.then(()=>{r?.delete(n),r?.size===0&&t.delete(e)})}function i(e,t){let n=()=>t(e.reason);return e.addEventListener(`abort`,n,{once:!0}),()=>e.removeEventListener(`abort`,n)}function a(e,t,n){return e.finished.then(()=>(t(),{status:n?`reduced`:`finished`}),e=>(t(),{reason:e,status:`cancelled`}))}function o(e,t,n=!1){let r=!1,o,s=!1,c,l=a(e,()=>{c?.(),c=void 0},n).then(e=>r&&s&&e.status===`cancelled`?{reason:o,status:`cancelled`}:e),u=t=>{r||(r=!0,o=t,s=t!==void 0,c?.(),c=void 0,e.cancel())};return t&&(c=i(t,u)),{animation:e,dispose:u,get disposed(){return r},result:l,[Symbol.dispose](){this.dispose()}}}function s(e,t){let n=!1,r,a=Promise.all(e.map(e=>e.result)).then(e=>(r?.(),r=void 0,e)),o=t=>{if(!n){n=!0,r?.(),r=void 0;for(let n of e)n.dispose(t)}};return t&&(r=i(t,o)),{dispose:o,get disposed(){return n},handles:e,results:a,[Symbol.dispose](){this.dispose()}}}var c=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},l=class extends c{},u=class extends c{},d=180;function f(e){return e===`full`?!1:e===`reduced`||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function p(e={},t=!1){let{duration:n,interrupt:r,motion:i=`system`,signal:a,...o}=e,s=n===void 0?{...o,duration:d}:{...o,duration:n};return t?{...s,delay:0,duration:0,endDelay:0,iterations:1}:s}function m(e,t){if(t===0)return e;let n=e.delay??0;if(typeof n!=`number`)throw new l(`A non-zero stagger requires a numeric delay; received ${typeof n}.`);return{...e,delay:n+t}}function h(e,t,i={}){if(i.signal?.aborted)throw i.signal.reason;if(typeof e.animate!=`function`)throw new u(`The Web Animations API is not available in this environment.`);i.interrupt===`cancel`&&n(e);let a=f(i.motion??`system`),s=o(e.animate(t,p(i,a)),i.signal,a);return r(e,s),s}function g(e){return[...new Set(e)]}function _(e){if(!Number.isFinite(e)||e<0)throw new l(`stagger must be a finite, non-negative number.`)}function v(e,t,n={}){let{signal:r,stagger:i=0,...a}=n;if(_(i),r?.aborted)throw r.reason;let o=g(e),c=o.map((e,n)=>typeof t==`function`?t(e,n,o.length):t),l=[];try{for(let[e,t]of o.entries()){let n=c[e];l.push(h(t,n,m(a,e*i)))}}catch(e){for(let t of l)t.dispose(e);throw e}return s(l,r)}function y(e,t){let n=10**t;return Math.round(e*n)/n}function b(e){if(`offsetWidth`in e&&`offsetHeight`in e)return{height:e.offsetHeight,width:e.offsetWidth};let t=e.getBoundingClientRect();return{height:t.height,width:t.width}}function x(e){let t=e.getBoundingClientRect(),n=b(e);return{height:n.height,width:n.width,x:t.x,y:t.y}}function S(e,t){return t===0?1:e/t}function C(e,t,n){let r=t(e);if(typeof r!=`string`||r.length===0)throw new l(`getKey must return a non-empty string for every ${n} element.`);return r}function w(e,t,n){let r=new Map;for(let i of e){let e=C(i.element,t,n);if(r.has(e))throw new l(`getKey returned duplicate keys for the ${n} elements.`);r.set(e,i)}return r}function T(e,t){if(!e.isConnected)return;let n=x(e),r=t.x-n.x,i=t.y-n.y,a=S(t.width,n.width),o=S(t.height,n.height);return r===0&&i===0&&a===1&&o===1?void 0:{element:e,scaleX:a,scaleY:o,x:r,y:i}}function E(e,t){let n=new Map(e.map(e=>[e.element,e]));return t.flatMap(e=>{let t=n.get(e);return t?[T(e,t.rect)].filter(e=>!!e):[]})}function D(e,t,n){let r=new Set;return t.flatMap(t=>{let i=C(t,n,`committed`),a=e.get(i);if(r.has(i))throw new l(`getKey returned duplicate keys for the committed elements.`);return r.add(i),a?[T(t,a.rect)].filter(e=>!!e):[]})}function O(e,t={}){let n=g(e).map(e=>({element:e,rect:x(e)})),r=t.getKey,i=r?w(n,r,`captured`):void 0,a=!1;return{animate(e={}){if(a)throw new l(`This layout transition has already been animated.`);let{elements:t,...o}=e,s=g(t??n.map(({element:e})=>e)),c=r&&i?D(i,s,r):E(n,s);return a=!0,v(c.map(({element:e})=>e),(e,t)=>{let n=c[t],r=`${y(n.x,2)}px ${y(n.y,2)}px`;return[{composite:`add`,scale:`${y(n.scaleX,4)} ${y(n.scaleY,4)}`,translate:r},{composite:`add`,scale:`1 1`,translate:`0px 0px`}]},o)}}}return e.NecromancerConfigError=l,e.NecromancerError=c,e.NecromancerUnsupportedError=u,e.animate=h,e.animateEach=v,e.captureLayout=O,e})({});
1
+ var Necromancer=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=new WeakMap;function n(e){for(let n of t.get(e)??[])n.dispose()}function r(e,n){let r=t.get(e);r||(r=new Set,t.set(e,r)),r.add(n),n.result.then(()=>{r?.delete(n),r?.size===0&&t.delete(e)})}function i(e,t){let n=()=>t(e.reason);return e.addEventListener(`abort`,n,{once:!0}),()=>e.removeEventListener(`abort`,n)}function a(e,t,n){return e.finished.then(()=>(t(),{status:n?`reduced`:`finished`}),e=>(t(),{reason:e,status:`cancelled`}))}function o(e,t,n=!1){let r=!1,o,s=!1,c,l=a(e,()=>{c?.(),c=void 0},n).then(e=>r&&s&&e.status===`cancelled`?{reason:o,status:`cancelled`}:e),u=t=>{r||(r=!0,o=t,s=t!==void 0,c?.(),c=void 0,e.cancel())};return t&&(c=i(t,u)),{animation:e,dispose:u,get disposed(){return r},result:l,[Symbol.dispose](){this.dispose()}}}function s(e,t){let n=!1,r,a=Promise.all(e.map(e=>e.result)).then(e=>(r?.(),r=void 0,e)),o=t=>{if(!n){n=!0,r?.(),r=void 0;for(let n of e)n.dispose(t)}};return t&&(r=i(t,o)),{dispose:o,get disposed(){return n},handles:e,results:a,[Symbol.dispose](){this.dispose()}}}var c=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},l=class extends c{},u=class extends c{},d=180;function f(e){return e===`full`?!1:e===`reduced`||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function p(e={},t=!1){let{duration:n,interrupt:r,motion:i=`system`,signal:a,...o}=e,s=n===void 0?{...o,duration:d}:{...o,duration:n};return t?{...s,delay:0,duration:0,endDelay:0,iterations:1}:s}function m(e,t){if(t===0)return e;let n=e.delay??0;if(typeof n!=`number`)throw new l(`A non-zero stagger requires a numeric delay; received ${typeof n}.`);return{...e,delay:n+t}}function h(e,t,i={}){if(i.signal?.aborted)throw i.signal.reason;if(typeof e.animate!=`function`)throw new u(`The Web Animations API is not available in this environment.`);i.interrupt===`cancel`&&n(e);let a=f(i.motion??`system`),s=o(e.animate(t,p(i,a)),i.signal,a);return r(e,s),s}function g(e){return[...new Set(e)]}function _(e){if(!Number.isFinite(e)||e<0)throw new l(`stagger must be a finite, non-negative number.`)}function v(e,t,n={}){let{signal:r,stagger:i=0,...a}=n;if(_(i),r?.aborted)throw r.reason;let o=g(e),c=o.map((e,n)=>typeof t==`function`?t(e,n,o.length):t),l=[];try{for(let[e,t]of o.entries()){let n=c[e];l.push(h(t,n,m(a,e*i)))}}catch(e){for(let t of l)t.dispose(e);throw e}return s(l,r)}function y(e,t){let n=10**t;return Math.round(e*n)/n}function b(e){if(`offsetWidth`in e&&`offsetHeight`in e)return{height:e.offsetHeight,width:e.offsetWidth};let t=e.getBoundingClientRect();return{height:t.height,width:t.width}}function x(e){let t=e.getBoundingClientRect(),n=b(e);return{height:n.height,width:n.width,x:t.x,y:t.y}}function S(e,t){return t===0?1:e/t}function C(e,t,n){let r=t(e);if(typeof r!=`string`||r.length===0)throw new l(`getKey must return a non-empty string for every ${n} element.`);return r}function w(e,t,n){let r=new Map;for(let i of e){let e=C(i.element,t,n);if(r.has(e))throw new l(`getKey returned duplicate keys for the ${n} elements.`);r.set(e,i)}return r}function T(e,t){if(!e.isConnected)return;let n=x(e),r=t.x-n.x,i=t.y-n.y,a=S(t.width,n.width),o=S(t.height,n.height);return r===0&&i===0&&a===1&&o===1?void 0:{element:e,scaleX:a,scaleY:o,x:r,y:i}}function E(e,t){let n=new Map(e.map(e=>[e.element,e]));return t.flatMap(e=>{let t=n.get(e);return t?[T(e,t.rect)].filter(e=>!!e):[]})}function D(e,t,n){let r=new Set;return t.flatMap(t=>{let i=C(t,n,`committed`),a=e.get(i);if(r.has(i))throw new l(`getKey returned duplicate keys for the committed elements.`);return r.add(i),a?[T(t,a.rect)].filter(e=>!!e):[]})}function O(e,t={}){let n=g(e).map(e=>({element:e,rect:x(e)})),r=t.getKey,i=r?w(n,r,`captured`):void 0,a=!1;return{animate(e={}){if(a)throw new l(`This layout transition has already been animated.`);let{elements:t,...o}=e,s=g(t??n.map(({element:e})=>e)),c=r&&i?D(i,s,r):E(n,s);return a=!0,v(c.map(({element:e})=>e),(e,t)=>{let n=c[t],r=`${y(n.x,2)}px ${y(n.y,2)}px`;return[{composite:`add`,scale:`${y(n.scaleX,4)} ${y(n.scaleY,4)}`,translate:r},{composite:`add`,scale:`1 1`,translate:`0px 0px`}]},o)}}}return e.NecromancerConfigError=l,e.NecromancerError=c,e.NecromancerUnsupportedError=u,e.animate=h,e.animateEach=v,e.captureLayout=O,e})({});
2
2
  //# sourceMappingURL=necromancer.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"necromancer.iife.js","names":[],"sources":["../src/_active.ts","../src/_handle.ts","../src/errors.ts","../src/_motion.ts","../src/animate.ts","../src/_elements.ts","../src/animate-each.ts","../src/layout.ts"],"sourcesContent":["import type { AnimationHandle } from './types';\n\n// Scoped to one DOM element by design: `interrupt: 'cancel'` answers \"replace whatever\n// Necromancer is doing to *this* element\", not \"coordinate across element categories\".\n// A caller that needs to cancel an animation on a different element (or coordinate several\n// elements as one unit) already has that element's own handle, or should use `animateEach()`\n// and a shared `signal` instead. Keeping the WeakMap element-scoped means it only ever needs\n// to answer one question and never grows into a general-purpose animation registry.\nconst handlesByElement = new WeakMap<Element, Set<AnimationHandle>>();\n\n/** Cancels active Necromancer-owned animations without touching native animations owned by callers. */\nexport function interruptAnimations(element: Element): void {\n for (const handle of handlesByElement.get(element) ?? []) handle.dispose();\n}\n\n/** Tracks a handle until its terminal result releases the element association. */\nexport function trackAnimation(element: Element, handle: AnimationHandle): void {\n let handles = handlesByElement.get(element);\n\n if (!handles) {\n handles = new Set();\n handlesByElement.set(element, handles);\n }\n\n handles.add(handle);\n\n void handle.result.then(() => {\n handles?.delete(handle);\n\n if (handles?.size === 0) handlesByElement.delete(element);\n });\n}\n","import type { AnimationGroup, AnimationHandle, AnimationResult } from './types';\n\n/**\n * Attaches an abort listener to a signal and returns a function that removes it.\n * When the signal aborts, calls the dispose function with the signal's reason.\n */\nfunction attachAbortSignalListener(signal: AbortSignal, dispose: (reason?: unknown) => void): () => void {\n const abort = () => dispose(signal.reason);\n\n signal.addEventListener('abort', abort, { once: true });\n\n return () => signal.removeEventListener('abort', abort);\n}\n\nfunction createResultPromise(animation: Animation, onSettled: () => void, reduced: boolean): Promise<AnimationResult> {\n return animation.finished.then(\n () => {\n onSettled();\n\n return { status: reduced ? 'reduced' : 'finished' };\n },\n (reason: unknown) => {\n onSettled();\n\n return { reason, status: 'cancelled' };\n },\n );\n}\n\n/** Wraps a native Animation with Necromancer's lifecycle contract. */\nexport function createAnimationHandle(animation: Animation, signal?: AbortSignal, reduced = false): AnimationHandle {\n let disposed = false;\n let disposeReason: unknown;\n let hasDisposeReason = false;\n let removeAbortListener: (() => void) | undefined;\n\n const result: Promise<AnimationResult> = createResultPromise(\n animation,\n () => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n },\n reduced,\n ).then((outcome): AnimationResult => {\n if (disposed && hasDisposeReason && outcome.status === 'cancelled') {\n return { reason: disposeReason, status: 'cancelled' };\n }\n\n return outcome;\n });\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n disposeReason = reason;\n hasDisposeReason = reason !== undefined;\n removeAbortListener?.();\n removeAbortListener = undefined;\n animation.cancel();\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n animation,\n dispose,\n get disposed() {\n return disposed;\n },\n result,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\n/** Combines child animation handles under one disposal owner. */\nexport function createAnimationGroup(handles: readonly AnimationHandle[], signal?: AbortSignal): AnimationGroup {\n let disposed = false;\n let removeAbortListener: (() => void) | undefined;\n\n const results: Promise<readonly AnimationResult[]> = Promise.all(handles.map((handle) => handle.result)).then(\n (childResults): readonly AnimationResult[] => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n\n return childResults;\n },\n );\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n removeAbortListener?.();\n removeAbortListener = undefined;\n for (const handle of handles) handle.dispose(reason);\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n handles,\n results,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n","/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Narrows an unknown error to any Necromancer-originated error. */\n static is(error: unknown): error is NecromancerError {\n return error instanceof NecromancerError;\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n","import { NecromancerConfigError } from './errors';\nimport type { AnimateOptions, MotionMode } from './types';\n\nconst DEFAULT_DURATION = 180;\n\n/** Reports whether the requested motion preference reduces visible movement. */\nexport function shouldReduceMotion(mode: MotionMode): boolean {\n if (mode === 'full') return false;\n\n if (mode === 'reduced') return true;\n\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Converts ownership options to native timing, collapsing reduced motion to an instant transition. */\nexport function resolveAnimationOptions(options: AnimateOptions = {}, reduced = false): KeyframeAnimationOptions {\n const { duration, interrupt: _interrupt, motion: _motion = 'system', signal: _signal, ...nativeOptions } = options;\n const timing =\n duration === undefined ? { ...nativeOptions, duration: DEFAULT_DURATION } : { ...nativeOptions, duration };\n\n return reduced ? { ...timing, delay: 0, duration: 0, endDelay: 0, iterations: 1 } : timing;\n}\n\n/** Adds an element's stagger offset without changing native nonnumeric delays when no offset is needed. */\nexport function withStaggeredDelay(options: AnimateOptions, offset: number): AnimateOptions {\n if (offset === 0) return options;\n\n const delay = options.delay ?? 0;\n\n if (typeof delay !== 'number') {\n throw new NecromancerConfigError(`A non-zero stagger requires a numeric delay; received ${typeof delay}.`);\n }\n\n return { ...options, delay: delay + offset };\n}\n","import { interruptAnimations, trackAnimation } from './_active';\nimport { createAnimationHandle } from './_handle';\nimport { resolveAnimationOptions, shouldReduceMotion } from './_motion';\nimport { NecromancerUnsupportedError } from './errors';\nimport type { AnimateOptions, AnimationHandle, Keyframes } from './types';\n\n/**\n * Starts a lifecycle-owned native Web Animation for one element.\n *\n * The returned handle cancels its native animation when disposed. By default, the\n * operating system's reduced-motion preference suppresses movement.\n */\nexport function animate(element: Element, keyframes: Keyframes, options: AnimateOptions = {}): AnimationHandle {\n if (options.signal?.aborted) throw options.signal.reason;\n\n if (typeof element.animate !== 'function') {\n throw new NecromancerUnsupportedError('The Web Animations API is not available in this environment.');\n }\n\n if (options.interrupt === 'cancel') interruptAnimations(element);\n\n const reduced = shouldReduceMotion(options.motion ?? 'system');\n const nativeAnimation = element.animate(\n keyframes as Keyframe[] | PropertyIndexedKeyframes,\n resolveAnimationOptions(options, reduced),\n );\n const handle = createAnimationHandle(nativeAnimation, options.signal, reduced);\n\n trackAnimation(element, handle);\n\n return handle;\n}\n","/** Deduplicates elements while preserving first-seen order. Shared by `animateEach()` and `captureLayout()`. */\nexport function uniqueElements(elements: Iterable<Element>): Element[] {\n return [...new Set(elements)];\n}\n","import { uniqueElements } from './_elements';\nimport { createAnimationGroup } from './_handle';\nimport { withStaggeredDelay } from './_motion';\nimport { animate } from './animate';\nimport { NecromancerConfigError } from './errors';\nimport type { AnimateEachOptions, AnimationGroup, AnimationHandle, KeyframeFactory, Keyframes } from './types';\n\nfunction validateStagger(stagger: number): void {\n if (!Number.isFinite(stagger) || stagger < 0) {\n throw new NecromancerConfigError('stagger must be a finite, non-negative number.');\n }\n}\n\n/**\n * Starts lifecycle-owned animations for unique elements in iteration order.\n *\n * Each subsequent element starts after `stagger` milliseconds. A keyframe factory\n * receives the stable unique-element index and total before any animation starts.\n */\nexport function animateEach(\n elements: Iterable<Element>,\n keyframes: Keyframes | KeyframeFactory,\n options: AnimateEachOptions = {},\n): AnimationGroup {\n const { signal, stagger = 0, ...animationOptions } = options;\n\n validateStagger(stagger);\n\n if (signal?.aborted) throw signal.reason;\n\n const unique = uniqueElements(elements);\n const frames = unique.map((element, index) =>\n typeof keyframes === 'function' ? keyframes(element, index, unique.length) : keyframes,\n );\n const handles: AnimationHandle[] = [];\n\n try {\n for (const [index, element] of unique.entries()) {\n // `frames` was built above from `unique`, one entry per element, so this index is always in range.\n const currentFrames = frames[index]!;\n\n handles.push(animate(element, currentFrames, withStaggeredDelay(animationOptions, index * stagger)));\n }\n } catch (error) {\n for (const handle of handles) handle.dispose(error);\n\n throw error;\n }\n\n return createAnimationGroup(handles, signal);\n}\n","import { uniqueElements } from './_elements';\nimport { animateEach } from './animate-each';\nimport { NecromancerConfigError } from './errors';\nimport type { LayoutAnimationOptions, LayoutCaptureOptions, LayoutTransition } from './types';\n\ntype LayoutRect = Readonly<Pick<DOMRectReadOnly, 'height' | 'width' | 'x' | 'y'>>;\ntype LayoutEntry = Readonly<{ element: Element; rect: LayoutRect }>;\ntype LayoutChange = Readonly<{ element: Element; scaleX: number; scaleY: number; x: number; y: number }>;\n\n// Rounds before templating into a keyframe string purely for DevTools readability — a `getBoundingClientRect()`\n// subtraction routinely produces values like `12.340000000000002`, which is noise once rendered as CSS.\n// Pixels only need whole-number precision; scale factors (close to 1) need finer precision to stay visually exact.\nfunction round(value: number, precision: number): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n// `getBoundingClientRect()`'s width/height is the rotated, axis-aligned bounding box — using it\n// for size would distort the scale ratio under any rotation. `offsetWidth`/`offsetHeight` report\n// the box's own untransformed layout size instead. Elements without an offset box (e.g. SVG)\n// fall back to the bounding rect, accepting that same distortion as the only option available.\nfunction measureSize(element: Element): Readonly<{ height: number; width: number }> {\n if ('offsetWidth' in element && 'offsetHeight' in element) {\n return { height: (element as HTMLElement).offsetHeight, width: (element as HTMLElement).offsetWidth };\n }\n\n const rect = element.getBoundingClientRect();\n\n return { height: rect.height, width: rect.width };\n}\n\nfunction measureLayout(element: Element): LayoutRect {\n const rect = element.getBoundingClientRect();\n const size = measureSize(element);\n\n return { height: size.height, width: size.width, x: rect.x, y: rect.y };\n}\n\n// `next` is 0 exactly when the element has collapsed (e.g. `display: none` mid-transition);\n// there's no meaningful ratio to compute then, so treat it as unscaled rather than producing Infinity/NaN.\nfunction computeScale(captured: number, next: number): number {\n return next === 0 ? 1 : captured / next;\n}\n\nfunction readKey(element: Element, getKey: (element: Element) => string, phase: string): string {\n const key = getKey(element);\n\n if (typeof key !== 'string' || key.length === 0) {\n throw new NecromancerConfigError(`getKey must return a non-empty string for every ${phase} element.`);\n }\n\n return key;\n}\n\nfunction createKeyMap(entries: readonly LayoutEntry[], getKey: (element: Element) => string, phase: string) {\n const keys = new Map<string, LayoutEntry>();\n\n for (const entry of entries) {\n const key = readKey(entry.element, getKey, phase);\n\n if (keys.has(key)) {\n throw new NecromancerConfigError(`getKey returned duplicate keys for the ${phase} elements.`);\n }\n\n keys.set(key, entry);\n }\n\n return keys;\n}\n\nfunction changedElement(element: Element, rect: LayoutRect): LayoutChange | undefined {\n if (!element.isConnected) return undefined;\n\n const next = measureLayout(element);\n const x = rect.x - next.x;\n const y = rect.y - next.y;\n const scaleX = computeScale(rect.width, next.width);\n const scaleY = computeScale(rect.height, next.height);\n\n return x === 0 && y === 0 && scaleX === 1 && scaleY === 1 ? undefined : { element, scaleX, scaleY, x, y };\n}\n\nfunction matchByIdentity(entries: readonly LayoutEntry[], elements: readonly Element[]): LayoutChange[] {\n const captured = new Map(entries.map((entry) => [entry.element, entry]));\n\n return elements.flatMap((element) => {\n const entry = captured.get(element);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\nfunction matchByKey(\n captured: ReadonlyMap<string, LayoutEntry>,\n elements: readonly Element[],\n getKey: (element: Element) => string,\n): LayoutChange[] {\n const committed = new Set<string>();\n\n return elements.flatMap((element) => {\n const key = readKey(element, getKey, 'committed');\n const entry = captured.get(key);\n\n if (committed.has(key)) {\n throw new NecromancerConfigError('getKey returned duplicate keys for the committed elements.');\n }\n\n committed.add(key);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\n/**\n * Captures the current position and size of unique elements for a later FLIP animation.\n *\n * Each element's `x`/`y` position and `width`/`height` are captured. Rotation and other\n * transforms are not captured or compensated. Capture before mutating the DOM, then call\n * the returned transition's `animate()` method after the browser has applied the resulting\n * layout — position changes animate via translate, and size changes via scale, both\n * additively composed on top of any authored transform.\n */\nexport function captureLayout(elements: Iterable<Element>, options: LayoutCaptureOptions = {}): LayoutTransition {\n const entries: LayoutEntry[] = uniqueElements(elements).map((element) => ({\n element,\n rect: measureLayout(element),\n }));\n const getKey = options.getKey;\n const captured = getKey ? createKeyMap(entries, getKey, 'captured') : undefined;\n\n let consumed = false;\n\n return {\n animate(options: LayoutAnimationOptions = {}) {\n if (consumed) throw new NecromancerConfigError('This layout transition has already been animated.');\n\n const { elements: committedElements, ...animationOptions } = options;\n const elements = uniqueElements(committedElements ?? entries.map(({ element }) => element));\n const changed = getKey && captured ? matchByKey(captured, elements, getKey) : matchByIdentity(entries, elements);\n\n consumed = true;\n\n return animateEach(\n changed.map(({ element }) => element),\n (_, index) => {\n // `changed` was mapped directly into the elements array above, so this index is always in range.\n const change = changed[index]!;\n const translate = `${round(change.x, 2)}px ${round(change.y, 2)}px`;\n const scale = `${round(change.scaleX, 4)} ${round(change.scaleY, 4)}`;\n\n return [\n { composite: 'add', scale, translate },\n { composite: 'add', scale: '1 1', translate: '0px 0px' },\n ];\n },\n animationOptions,\n );\n },\n };\n}\n"],"mappings":"0FAQA,IAAM,EAAmB,IAAI,QAG7B,SAAgB,EAAoB,EAAwB,CAC1D,IAAK,IAAM,KAAU,EAAiB,IAAI,CAAO,GAAK,CAAC,EAAG,EAAO,QAAQ,CAC3E,CAGA,SAAgB,EAAe,EAAkB,EAA+B,CAC9E,IAAI,EAAU,EAAiB,IAAI,CAAO,EAErC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AM,CAAE,SAAU,EAAmB,GAAG,GAAqB,EACvD,EAAW,EAAe,GAAqB,EAAQ,KAAK,CAAE,aAAc,CAAO,CAAC,EACpF,EAAU,GAAU,EAAW,EAAW,EAAU,EAAU,CAAM,EAAI,EAAgB,EAAS,CAAQ,EAI/G,MAFA,GAAW,GAEJ,EACL,EAAQ,KAAK,CAAE,aAAc,CAAO,GACnC,EAAG,IAAU,CAEZ,IAAM,EAAS,EAAQ,GACjB,EAAY,GAAG,EAAM,EAAO,EAAG,CAAC,EAAE,KAAK,EAAM,EAAO,EAAG,CAAC,EAAE,IAGhE,MAAO,CACL,CAAE,UAAW,MAAO,MAAA,GAHL,EAAM,EAAO,OAAQ,CAAC,EAAE,GAAG,EAAM,EAAO,OAAQ,CAAC,IAGrC,WAAU,EACrC,CAAE,UAAW,MAAO,MAAO,MAAO,UAAW,SAAU,CACzD,CACF,EACA,CACF,CACF,CACF,CACF"}
1
+ {"version":3,"file":"necromancer.iife.js","names":[],"sources":["../src/_active.ts","../src/_handle.ts","../src/errors.ts","../src/_motion.ts","../src/animate.ts","../src/_elements.ts","../src/animate-each.ts","../src/layout.ts"],"sourcesContent":["import type { AnimationHandle } from './types';\n\n// Scoped to one DOM element by design: `interrupt: 'cancel'` answers \"replace whatever\n// Necromancer is doing to *this* element\", not \"coordinate across element categories\".\n// A caller that needs to cancel an animation on a different element (or coordinate several\n// elements as one unit) already has that element's own handle, or should use `animateEach()`\n// and a shared `signal` instead. Keeping the WeakMap element-scoped means it only ever needs\n// to answer one question and never grows into a general-purpose animation registry.\nconst handlesByElement = new WeakMap<Element, Set<AnimationHandle>>();\n\n/** Cancels active Necromancer-owned animations without touching native animations owned by callers. */\nexport function interruptAnimations(element: Element): void {\n for (const handle of handlesByElement.get(element) ?? []) handle.dispose();\n}\n\n/** Tracks a handle until its terminal result releases the element association. */\nexport function trackAnimation(element: Element, handle: AnimationHandle): void {\n let handles = handlesByElement.get(element);\n\n if (!handles) {\n handles = new Set();\n handlesByElement.set(element, handles);\n }\n\n handles.add(handle);\n\n void handle.result.then(() => {\n handles?.delete(handle);\n\n if (handles?.size === 0) handlesByElement.delete(element);\n });\n}\n","import type { AnimationGroup, AnimationHandle, AnimationResult } from './types';\n\n/**\n * Attaches an abort listener to a signal and returns a function that removes it.\n * When the signal aborts, calls the dispose function with the signal's reason.\n */\nfunction attachAbortSignalListener(signal: AbortSignal, dispose: (reason?: unknown) => void): () => void {\n const abort = () => dispose(signal.reason);\n\n signal.addEventListener('abort', abort, { once: true });\n\n return () => signal.removeEventListener('abort', abort);\n}\n\nfunction createResultPromise(animation: Animation, onSettled: () => void, reduced: boolean): Promise<AnimationResult> {\n return animation.finished.then(\n () => {\n onSettled();\n\n return { status: reduced ? 'reduced' : 'finished' };\n },\n (reason: unknown) => {\n onSettled();\n\n return { reason, status: 'cancelled' };\n },\n );\n}\n\n/** Wraps a native Animation with Necromancer's lifecycle contract. */\nexport function createAnimationHandle(animation: Animation, signal?: AbortSignal, reduced = false): AnimationHandle {\n let disposed = false;\n let disposeReason: unknown;\n let hasDisposeReason = false;\n let removeAbortListener: (() => void) | undefined;\n\n const result: Promise<AnimationResult> = createResultPromise(\n animation,\n () => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n },\n reduced,\n ).then((outcome): AnimationResult => {\n if (disposed && hasDisposeReason && outcome.status === 'cancelled') {\n return { reason: disposeReason, status: 'cancelled' };\n }\n\n return outcome;\n });\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n disposeReason = reason;\n hasDisposeReason = reason !== undefined;\n removeAbortListener?.();\n removeAbortListener = undefined;\n animation.cancel();\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n animation,\n dispose,\n get disposed() {\n return disposed;\n },\n result,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\n/** Combines child animation handles under one disposal owner. */\nexport function createAnimationGroup(handles: readonly AnimationHandle[], signal?: AbortSignal): AnimationGroup {\n let disposed = false;\n let removeAbortListener: (() => void) | undefined;\n\n const results: Promise<readonly AnimationResult[]> = Promise.all(handles.map((handle) => handle.result)).then(\n (childResults): readonly AnimationResult[] => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n\n return childResults;\n },\n );\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n removeAbortListener?.();\n removeAbortListener = undefined;\n for (const handle of handles) handle.dispose(reason);\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n handles,\n results,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n","/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n","import { NecromancerConfigError } from './errors';\nimport type { AnimateOptions, MotionMode } from './types';\n\nconst DEFAULT_DURATION = 180;\n\n/** Reports whether the requested motion preference reduces visible movement. */\nexport function shouldReduceMotion(mode: MotionMode): boolean {\n if (mode === 'full') return false;\n\n if (mode === 'reduced') return true;\n\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Converts ownership options to native timing, collapsing reduced motion to an instant transition. */\nexport function resolveAnimationOptions(options: AnimateOptions = {}, reduced = false): KeyframeAnimationOptions {\n const { duration, interrupt: _interrupt, motion: _motion = 'system', signal: _signal, ...nativeOptions } = options;\n const timing =\n duration === undefined ? { ...nativeOptions, duration: DEFAULT_DURATION } : { ...nativeOptions, duration };\n\n return reduced ? { ...timing, delay: 0, duration: 0, endDelay: 0, iterations: 1 } : timing;\n}\n\n/** Adds an element's stagger offset without changing native nonnumeric delays when no offset is needed. */\nexport function withStaggeredDelay(options: AnimateOptions, offset: number): AnimateOptions {\n if (offset === 0) return options;\n\n const delay = options.delay ?? 0;\n\n if (typeof delay !== 'number') {\n throw new NecromancerConfigError(`A non-zero stagger requires a numeric delay; received ${typeof delay}.`);\n }\n\n return { ...options, delay: delay + offset };\n}\n","import { interruptAnimations, trackAnimation } from './_active';\nimport { createAnimationHandle } from './_handle';\nimport { resolveAnimationOptions, shouldReduceMotion } from './_motion';\nimport { NecromancerUnsupportedError } from './errors';\nimport type { AnimateOptions, AnimationHandle, Keyframes } from './types';\n\n/**\n * Starts a lifecycle-owned native Web Animation for one element.\n *\n * The returned handle cancels its native animation when disposed. By default, the\n * operating system's reduced-motion preference suppresses movement.\n */\nexport function animate(element: Element, keyframes: Keyframes, options: AnimateOptions = {}): AnimationHandle {\n if (options.signal?.aborted) throw options.signal.reason;\n\n if (typeof element.animate !== 'function') {\n throw new NecromancerUnsupportedError('The Web Animations API is not available in this environment.');\n }\n\n if (options.interrupt === 'cancel') interruptAnimations(element);\n\n const reduced = shouldReduceMotion(options.motion ?? 'system');\n const nativeAnimation = element.animate(\n keyframes as Keyframe[] | PropertyIndexedKeyframes,\n resolveAnimationOptions(options, reduced),\n );\n const handle = createAnimationHandle(nativeAnimation, options.signal, reduced);\n\n trackAnimation(element, handle);\n\n return handle;\n}\n","/** Deduplicates elements while preserving first-seen order. Shared by `animateEach()` and `captureLayout()`. */\nexport function uniqueElements(elements: Iterable<Element>): Element[] {\n return [...new Set(elements)];\n}\n","import { uniqueElements } from './_elements';\nimport { createAnimationGroup } from './_handle';\nimport { withStaggeredDelay } from './_motion';\nimport { animate } from './animate';\nimport { NecromancerConfigError } from './errors';\nimport type { AnimateEachOptions, AnimationGroup, AnimationHandle, KeyframeFactory, Keyframes } from './types';\n\nfunction validateStagger(stagger: number): void {\n if (!Number.isFinite(stagger) || stagger < 0) {\n throw new NecromancerConfigError('stagger must be a finite, non-negative number.');\n }\n}\n\n/**\n * Starts lifecycle-owned animations for unique elements in iteration order.\n *\n * Each subsequent element starts after `stagger` milliseconds. A keyframe factory\n * receives the stable unique-element index and total before any animation starts.\n */\nexport function animateEach(\n elements: Iterable<Element>,\n keyframes: Keyframes | KeyframeFactory,\n options: AnimateEachOptions = {},\n): AnimationGroup {\n const { signal, stagger = 0, ...animationOptions } = options;\n\n validateStagger(stagger);\n\n if (signal?.aborted) throw signal.reason;\n\n const unique = uniqueElements(elements);\n const frames = unique.map((element, index) =>\n typeof keyframes === 'function' ? keyframes(element, index, unique.length) : keyframes,\n );\n const handles: AnimationHandle[] = [];\n\n try {\n for (const [index, element] of unique.entries()) {\n // `frames` was built above from `unique`, one entry per element, so this index is always in range.\n const currentFrames = frames[index]!;\n\n handles.push(animate(element, currentFrames, withStaggeredDelay(animationOptions, index * stagger)));\n }\n } catch (error) {\n for (const handle of handles) handle.dispose(error);\n\n throw error;\n }\n\n return createAnimationGroup(handles, signal);\n}\n","import { uniqueElements } from './_elements';\nimport { animateEach } from './animate-each';\nimport { NecromancerConfigError } from './errors';\nimport type { LayoutAnimationOptions, LayoutCaptureOptions, LayoutTransition } from './types';\n\ntype LayoutRect = Readonly<Pick<DOMRectReadOnly, 'height' | 'width' | 'x' | 'y'>>;\ntype LayoutEntry = Readonly<{ element: Element; rect: LayoutRect }>;\ntype LayoutChange = Readonly<{ element: Element; scaleX: number; scaleY: number; x: number; y: number }>;\n\n// Rounds before templating into a keyframe string purely for DevTools readability — a `getBoundingClientRect()`\n// subtraction routinely produces values like `12.340000000000002`, which is noise once rendered as CSS.\n// Pixels only need whole-number precision; scale factors (close to 1) need finer precision to stay visually exact.\nfunction round(value: number, precision: number): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n// `getBoundingClientRect()`'s width/height is the rotated, axis-aligned bounding box — using it\n// for size would distort the scale ratio under any rotation. `offsetWidth`/`offsetHeight` report\n// the box's own untransformed layout size instead. Elements without an offset box (e.g. SVG)\n// fall back to the bounding rect, accepting that same distortion as the only option available.\nfunction measureSize(element: Element): Readonly<{ height: number; width: number }> {\n if ('offsetWidth' in element && 'offsetHeight' in element) {\n return { height: (element as HTMLElement).offsetHeight, width: (element as HTMLElement).offsetWidth };\n }\n\n const rect = element.getBoundingClientRect();\n\n return { height: rect.height, width: rect.width };\n}\n\nfunction measureLayout(element: Element): LayoutRect {\n const rect = element.getBoundingClientRect();\n const size = measureSize(element);\n\n return { height: size.height, width: size.width, x: rect.x, y: rect.y };\n}\n\n// `next` is 0 exactly when the element has collapsed (e.g. `display: none` mid-transition);\n// there's no meaningful ratio to compute then, so treat it as unscaled rather than producing Infinity/NaN.\nfunction computeScale(captured: number, next: number): number {\n return next === 0 ? 1 : captured / next;\n}\n\nfunction readKey(element: Element, getKey: (element: Element) => string, phase: string): string {\n const key = getKey(element);\n\n if (typeof key !== 'string' || key.length === 0) {\n throw new NecromancerConfigError(`getKey must return a non-empty string for every ${phase} element.`);\n }\n\n return key;\n}\n\nfunction createKeyMap(entries: readonly LayoutEntry[], getKey: (element: Element) => string, phase: string) {\n const keys = new Map<string, LayoutEntry>();\n\n for (const entry of entries) {\n const key = readKey(entry.element, getKey, phase);\n\n if (keys.has(key)) {\n throw new NecromancerConfigError(`getKey returned duplicate keys for the ${phase} elements.`);\n }\n\n keys.set(key, entry);\n }\n\n return keys;\n}\n\nfunction changedElement(element: Element, rect: LayoutRect): LayoutChange | undefined {\n if (!element.isConnected) return undefined;\n\n const next = measureLayout(element);\n const x = rect.x - next.x;\n const y = rect.y - next.y;\n const scaleX = computeScale(rect.width, next.width);\n const scaleY = computeScale(rect.height, next.height);\n\n return x === 0 && y === 0 && scaleX === 1 && scaleY === 1 ? undefined : { element, scaleX, scaleY, x, y };\n}\n\nfunction matchByIdentity(entries: readonly LayoutEntry[], elements: readonly Element[]): LayoutChange[] {\n const captured = new Map(entries.map((entry) => [entry.element, entry]));\n\n return elements.flatMap((element) => {\n const entry = captured.get(element);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\nfunction matchByKey(\n captured: ReadonlyMap<string, LayoutEntry>,\n elements: readonly Element[],\n getKey: (element: Element) => string,\n): LayoutChange[] {\n const committed = new Set<string>();\n\n return elements.flatMap((element) => {\n const key = readKey(element, getKey, 'committed');\n const entry = captured.get(key);\n\n if (committed.has(key)) {\n throw new NecromancerConfigError('getKey returned duplicate keys for the committed elements.');\n }\n\n committed.add(key);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\n/**\n * Captures the current position and size of unique elements for a later FLIP animation.\n *\n * Each element's `x`/`y` position and `width`/`height` are captured. Rotation and other\n * transforms are not captured or compensated. Capture before mutating the DOM, then call\n * the returned transition's `animate()` method after the browser has applied the resulting\n * layout — position changes animate via translate, and size changes via scale, both\n * additively composed on top of any authored transform.\n */\nexport function captureLayout(elements: Iterable<Element>, options: LayoutCaptureOptions = {}): LayoutTransition {\n const entries: LayoutEntry[] = uniqueElements(elements).map((element) => ({\n element,\n rect: measureLayout(element),\n }));\n const getKey = options.getKey;\n const captured = getKey ? createKeyMap(entries, getKey, 'captured') : undefined;\n\n let consumed = false;\n\n return {\n animate(options: LayoutAnimationOptions = {}) {\n if (consumed) throw new NecromancerConfigError('This layout transition has already been animated.');\n\n const { elements: committedElements, ...animationOptions } = options;\n const elements = uniqueElements(committedElements ?? entries.map(({ element }) => element));\n const changed = getKey && captured ? matchByKey(captured, elements, getKey) : matchByIdentity(entries, elements);\n\n consumed = true;\n\n return animateEach(\n changed.map(({ element }) => element),\n (_, index) => {\n // `changed` was mapped directly into the elements array above, so this index is always in range.\n const change = changed[index]!;\n const translate = `${round(change.x, 2)}px ${round(change.y, 2)}px`;\n const scale = `${round(change.scaleX, 4)} ${round(change.scaleY, 4)}`;\n\n return [\n { composite: 'add', scale, translate },\n { composite: 'add', scale: '1 1', translate: '0px 0px' },\n ];\n },\n animationOptions,\n );\n },\n };\n}\n"],"mappings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EAAW,EAAS,EAAa,EAAS,EAAQ,UAAU,EAAI,IAAA,GAElE,EAAW,GAEf,MAAO,CACL,QAAQ,EAAkC,CAAC,EAAG,CAC5C,GAAI,EAAU,MAAM,IAAI,EAAuB,mDAAmD,EAElG,GAAM,CAAE,SAAU,EAAmB,GAAG,GAAqB,EACvD,EAAW,EAAe,GAAqB,EAAQ,KAAK,CAAE,aAAc,CAAO,CAAC,EACpF,EAAU,GAAU,EAAW,EAAW,EAAU,EAAU,CAAM,EAAI,EAAgB,EAAS,CAAQ,EAI/G,MAFA,GAAW,GAEJ,EACL,EAAQ,KAAK,CAAE,aAAc,CAAO,GACnC,EAAG,IAAU,CAEZ,IAAM,EAAS,EAAQ,GACjB,EAAY,GAAG,EAAM,EAAO,EAAG,CAAC,EAAE,KAAK,EAAM,EAAO,EAAG,CAAC,EAAE,IAGhE,MAAO,CACL,CAAE,UAAW,MAAO,MAAA,GAHL,EAAM,EAAO,OAAQ,CAAC,EAAE,GAAG,EAAM,EAAO,OAAQ,CAAC,IAGrC,WAAU,EACrC,CAAE,UAAW,MAAO,MAAO,MAAO,UAAW,SAAU,CACzD,CACF,EACA,CACF,CACF,CACF,CACF"}
@@ -1,2 +1,2 @@
1
- var e=new WeakMap;function t(t){for(let n of e.get(t)??[])n.dispose()}function n(t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n),n.result.then(()=>{r?.delete(n),r?.size===0&&e.delete(t)})}function r(e,t){let n=()=>t(e.reason);return e.addEventListener(`abort`,n,{once:!0}),()=>e.removeEventListener(`abort`,n)}function i(e,t,n){return e.finished.then(()=>(t(),{status:n?`reduced`:`finished`}),e=>(t(),{reason:e,status:`cancelled`}))}function a(e,t,n=!1){let a=!1,o,s=!1,c,l=i(e,()=>{c?.(),c=void 0},n).then(e=>a&&s&&e.status===`cancelled`?{reason:o,status:`cancelled`}:e),u=t=>{a||(a=!0,o=t,s=t!==void 0,c?.(),c=void 0,e.cancel())};return t&&(c=r(t,u)),{animation:e,dispose:u,get disposed(){return a},result:l,[Symbol.dispose](){this.dispose()}}}function o(e,t){let n=!1,i,a=Promise.all(e.map(e=>e.result)).then(e=>(i?.(),i=void 0,e)),o=t=>{if(!n){n=!0,i?.(),i=void 0;for(let n of e)n.dispose(t)}};return t&&(i=r(t,o)),{dispose:o,get disposed(){return n},handles:e,results:a,[Symbol.dispose](){this.dispose()}}}var s=class e extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}static is(t){return t instanceof e}},c=class extends s{},l=class extends s{},u=180;function d(e){return e===`full`?!1:e===`reduced`||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function f(e={},t=!1){let{duration:n,interrupt:r,motion:i=`system`,signal:a,...o}=e,s=n===void 0?{...o,duration:u}:{...o,duration:n};return t?{...s,delay:0,duration:0,endDelay:0,iterations:1}:s}function p(e,t){if(t===0)return e;let n=e.delay??0;if(typeof n!=`number`)throw new c(`A non-zero stagger requires a numeric delay; received ${typeof n}.`);return{...e,delay:n+t}}function m(e,r,i={}){if(i.signal?.aborted)throw i.signal.reason;if(typeof e.animate!=`function`)throw new l(`The Web Animations API is not available in this environment.`);i.interrupt===`cancel`&&t(e);let o=d(i.motion??`system`),s=a(e.animate(r,f(i,o)),i.signal,o);return n(e,s),s}function h(e){return[...new Set(e)]}function g(e){if(!Number.isFinite(e)||e<0)throw new c(`stagger must be a finite, non-negative number.`)}function _(e,t,n={}){let{signal:r,stagger:i=0,...a}=n;if(g(i),r?.aborted)throw r.reason;let s=h(e),c=s.map((e,n)=>typeof t==`function`?t(e,n,s.length):t),l=[];try{for(let[e,t]of s.entries()){let n=c[e];l.push(m(t,n,p(a,e*i)))}}catch(e){for(let t of l)t.dispose(e);throw e}return o(l,r)}function v(e,t){let n=10**t;return Math.round(e*n)/n}function y(e){if(`offsetWidth`in e&&`offsetHeight`in e)return{height:e.offsetHeight,width:e.offsetWidth};let t=e.getBoundingClientRect();return{height:t.height,width:t.width}}function b(e){let t=e.getBoundingClientRect(),n=y(e);return{height:n.height,width:n.width,x:t.x,y:t.y}}function x(e,t){return t===0?1:e/t}function S(e,t,n){let r=t(e);if(typeof r!=`string`||r.length===0)throw new c(`getKey must return a non-empty string for every ${n} element.`);return r}function C(e,t,n){let r=new Map;for(let i of e){let e=S(i.element,t,n);if(r.has(e))throw new c(`getKey returned duplicate keys for the ${n} elements.`);r.set(e,i)}return r}function w(e,t){if(!e.isConnected)return;let n=b(e),r=t.x-n.x,i=t.y-n.y,a=x(t.width,n.width),o=x(t.height,n.height);return r===0&&i===0&&a===1&&o===1?void 0:{element:e,scaleX:a,scaleY:o,x:r,y:i}}function T(e,t){let n=new Map(e.map(e=>[e.element,e]));return t.flatMap(e=>{let t=n.get(e);return t?[w(e,t.rect)].filter(e=>!!e):[]})}function E(e,t,n){let r=new Set;return t.flatMap(t=>{let i=S(t,n,`committed`),a=e.get(i);if(r.has(i))throw new c(`getKey returned duplicate keys for the committed elements.`);return r.add(i),a?[w(t,a.rect)].filter(e=>!!e):[]})}function D(e,t={}){let n=h(e).map(e=>({element:e,rect:b(e)})),r=t.getKey,i=r?C(n,r,`captured`):void 0,a=!1;return{animate(e={}){if(a)throw new c(`This layout transition has already been animated.`);let{elements:t,...o}=e,s=h(t??n.map(({element:e})=>e)),l=r&&i?E(i,s,r):T(n,s);return a=!0,_(l.map(({element:e})=>e),(e,t)=>{let n=l[t],r=`${v(n.x,2)}px ${v(n.y,2)}px`;return[{composite:`add`,scale:`${v(n.scaleX,4)} ${v(n.scaleY,4)}`,translate:r},{composite:`add`,scale:`1 1`,translate:`0px 0px`}]},o)}}}export{c as NecromancerConfigError,s as NecromancerError,l as NecromancerUnsupportedError,m as animate,_ as animateEach,D as captureLayout};
1
+ var e=new WeakMap;function t(t){for(let n of e.get(t)??[])n.dispose()}function n(t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n),n.result.then(()=>{r?.delete(n),r?.size===0&&e.delete(t)})}function r(e,t){let n=()=>t(e.reason);return e.addEventListener(`abort`,n,{once:!0}),()=>e.removeEventListener(`abort`,n)}function i(e,t,n){return e.finished.then(()=>(t(),{status:n?`reduced`:`finished`}),e=>(t(),{reason:e,status:`cancelled`}))}function a(e,t,n=!1){let a=!1,o,s=!1,c,l=i(e,()=>{c?.(),c=void 0},n).then(e=>a&&s&&e.status===`cancelled`?{reason:o,status:`cancelled`}:e),u=t=>{a||(a=!0,o=t,s=t!==void 0,c?.(),c=void 0,e.cancel())};return t&&(c=r(t,u)),{animation:e,dispose:u,get disposed(){return a},result:l,[Symbol.dispose](){this.dispose()}}}function o(e,t){let n=!1,i,a=Promise.all(e.map(e=>e.result)).then(e=>(i?.(),i=void 0,e)),o=t=>{if(!n){n=!0,i?.(),i=void 0;for(let n of e)n.dispose(t)}};return t&&(i=r(t,o)),{dispose:o,get disposed(){return n},handles:e,results:a,[Symbol.dispose](){this.dispose()}}}var s=class extends Error{constructor(e,t){super(e,t),this.name=new.target.name,Object.setPrototypeOf(this,new.target.prototype)}},c=class extends s{},l=class extends s{},u=180;function d(e){return e===`full`?!1:e===`reduced`||typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches}function f(e={},t=!1){let{duration:n,interrupt:r,motion:i=`system`,signal:a,...o}=e,s=n===void 0?{...o,duration:u}:{...o,duration:n};return t?{...s,delay:0,duration:0,endDelay:0,iterations:1}:s}function p(e,t){if(t===0)return e;let n=e.delay??0;if(typeof n!=`number`)throw new c(`A non-zero stagger requires a numeric delay; received ${typeof n}.`);return{...e,delay:n+t}}function m(e,r,i={}){if(i.signal?.aborted)throw i.signal.reason;if(typeof e.animate!=`function`)throw new l(`The Web Animations API is not available in this environment.`);i.interrupt===`cancel`&&t(e);let o=d(i.motion??`system`),s=a(e.animate(r,f(i,o)),i.signal,o);return n(e,s),s}function h(e){return[...new Set(e)]}function g(e){if(!Number.isFinite(e)||e<0)throw new c(`stagger must be a finite, non-negative number.`)}function _(e,t,n={}){let{signal:r,stagger:i=0,...a}=n;if(g(i),r?.aborted)throw r.reason;let s=h(e),c=s.map((e,n)=>typeof t==`function`?t(e,n,s.length):t),l=[];try{for(let[e,t]of s.entries()){let n=c[e];l.push(m(t,n,p(a,e*i)))}}catch(e){for(let t of l)t.dispose(e);throw e}return o(l,r)}function v(e,t){let n=10**t;return Math.round(e*n)/n}function y(e){if(`offsetWidth`in e&&`offsetHeight`in e)return{height:e.offsetHeight,width:e.offsetWidth};let t=e.getBoundingClientRect();return{height:t.height,width:t.width}}function b(e){let t=e.getBoundingClientRect(),n=y(e);return{height:n.height,width:n.width,x:t.x,y:t.y}}function x(e,t){return t===0?1:e/t}function S(e,t,n){let r=t(e);if(typeof r!=`string`||r.length===0)throw new c(`getKey must return a non-empty string for every ${n} element.`);return r}function C(e,t,n){let r=new Map;for(let i of e){let e=S(i.element,t,n);if(r.has(e))throw new c(`getKey returned duplicate keys for the ${n} elements.`);r.set(e,i)}return r}function w(e,t){if(!e.isConnected)return;let n=b(e),r=t.x-n.x,i=t.y-n.y,a=x(t.width,n.width),o=x(t.height,n.height);return r===0&&i===0&&a===1&&o===1?void 0:{element:e,scaleX:a,scaleY:o,x:r,y:i}}function T(e,t){let n=new Map(e.map(e=>[e.element,e]));return t.flatMap(e=>{let t=n.get(e);return t?[w(e,t.rect)].filter(e=>!!e):[]})}function E(e,t,n){let r=new Set;return t.flatMap(t=>{let i=S(t,n,`committed`),a=e.get(i);if(r.has(i))throw new c(`getKey returned duplicate keys for the committed elements.`);return r.add(i),a?[w(t,a.rect)].filter(e=>!!e):[]})}function D(e,t={}){let n=h(e).map(e=>({element:e,rect:b(e)})),r=t.getKey,i=r?C(n,r,`captured`):void 0,a=!1;return{animate(e={}){if(a)throw new c(`This layout transition has already been animated.`);let{elements:t,...o}=e,s=h(t??n.map(({element:e})=>e)),l=r&&i?E(i,s,r):T(n,s);return a=!0,_(l.map(({element:e})=>e),(e,t)=>{let n=l[t],r=`${v(n.x,2)}px ${v(n.y,2)}px`;return[{composite:`add`,scale:`${v(n.scaleX,4)} ${v(n.scaleY,4)}`,translate:r},{composite:`add`,scale:`1 1`,translate:`0px 0px`}]},o)}}}export{c as NecromancerConfigError,s as NecromancerError,l as NecromancerUnsupportedError,m as animate,_ as animateEach,D as captureLayout};
2
2
  //# sourceMappingURL=necromancer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"necromancer.js","names":[],"sources":["../src/_active.ts","../src/_handle.ts","../src/errors.ts","../src/_motion.ts","../src/animate.ts","../src/_elements.ts","../src/animate-each.ts","../src/layout.ts"],"sourcesContent":["import type { AnimationHandle } from './types';\n\n// Scoped to one DOM element by design: `interrupt: 'cancel'` answers \"replace whatever\n// Necromancer is doing to *this* element\", not \"coordinate across element categories\".\n// A caller that needs to cancel an animation on a different element (or coordinate several\n// elements as one unit) already has that element's own handle, or should use `animateEach()`\n// and a shared `signal` instead. Keeping the WeakMap element-scoped means it only ever needs\n// to answer one question and never grows into a general-purpose animation registry.\nconst handlesByElement = new WeakMap<Element, Set<AnimationHandle>>();\n\n/** Cancels active Necromancer-owned animations without touching native animations owned by callers. */\nexport function interruptAnimations(element: Element): void {\n for (const handle of handlesByElement.get(element) ?? []) handle.dispose();\n}\n\n/** Tracks a handle until its terminal result releases the element association. */\nexport function trackAnimation(element: Element, handle: AnimationHandle): void {\n let handles = handlesByElement.get(element);\n\n if (!handles) {\n handles = new Set();\n handlesByElement.set(element, handles);\n }\n\n handles.add(handle);\n\n void handle.result.then(() => {\n handles?.delete(handle);\n\n if (handles?.size === 0) handlesByElement.delete(element);\n });\n}\n","import type { AnimationGroup, AnimationHandle, AnimationResult } from './types';\n\n/**\n * Attaches an abort listener to a signal and returns a function that removes it.\n * When the signal aborts, calls the dispose function with the signal's reason.\n */\nfunction attachAbortSignalListener(signal: AbortSignal, dispose: (reason?: unknown) => void): () => void {\n const abort = () => dispose(signal.reason);\n\n signal.addEventListener('abort', abort, { once: true });\n\n return () => signal.removeEventListener('abort', abort);\n}\n\nfunction createResultPromise(animation: Animation, onSettled: () => void, reduced: boolean): Promise<AnimationResult> {\n return animation.finished.then(\n () => {\n onSettled();\n\n return { status: reduced ? 'reduced' : 'finished' };\n },\n (reason: unknown) => {\n onSettled();\n\n return { reason, status: 'cancelled' };\n },\n );\n}\n\n/** Wraps a native Animation with Necromancer's lifecycle contract. */\nexport function createAnimationHandle(animation: Animation, signal?: AbortSignal, reduced = false): AnimationHandle {\n let disposed = false;\n let disposeReason: unknown;\n let hasDisposeReason = false;\n let removeAbortListener: (() => void) | undefined;\n\n const result: Promise<AnimationResult> = createResultPromise(\n animation,\n () => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n },\n reduced,\n ).then((outcome): AnimationResult => {\n if (disposed && hasDisposeReason && outcome.status === 'cancelled') {\n return { reason: disposeReason, status: 'cancelled' };\n }\n\n return outcome;\n });\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n disposeReason = reason;\n hasDisposeReason = reason !== undefined;\n removeAbortListener?.();\n removeAbortListener = undefined;\n animation.cancel();\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n animation,\n dispose,\n get disposed() {\n return disposed;\n },\n result,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\n/** Combines child animation handles under one disposal owner. */\nexport function createAnimationGroup(handles: readonly AnimationHandle[], signal?: AbortSignal): AnimationGroup {\n let disposed = false;\n let removeAbortListener: (() => void) | undefined;\n\n const results: Promise<readonly AnimationResult[]> = Promise.all(handles.map((handle) => handle.result)).then(\n (childResults): readonly AnimationResult[] => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n\n return childResults;\n },\n );\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n removeAbortListener?.();\n removeAbortListener = undefined;\n for (const handle of handles) handle.dispose(reason);\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n handles,\n results,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n","/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n /** Narrows an unknown error to any Necromancer-originated error. */\n static is(error: unknown): error is NecromancerError {\n return error instanceof NecromancerError;\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n","import { NecromancerConfigError } from './errors';\nimport type { AnimateOptions, MotionMode } from './types';\n\nconst DEFAULT_DURATION = 180;\n\n/** Reports whether the requested motion preference reduces visible movement. */\nexport function shouldReduceMotion(mode: MotionMode): boolean {\n if (mode === 'full') return false;\n\n if (mode === 'reduced') return true;\n\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Converts ownership options to native timing, collapsing reduced motion to an instant transition. */\nexport function resolveAnimationOptions(options: AnimateOptions = {}, reduced = false): KeyframeAnimationOptions {\n const { duration, interrupt: _interrupt, motion: _motion = 'system', signal: _signal, ...nativeOptions } = options;\n const timing =\n duration === undefined ? { ...nativeOptions, duration: DEFAULT_DURATION } : { ...nativeOptions, duration };\n\n return reduced ? { ...timing, delay: 0, duration: 0, endDelay: 0, iterations: 1 } : timing;\n}\n\n/** Adds an element's stagger offset without changing native nonnumeric delays when no offset is needed. */\nexport function withStaggeredDelay(options: AnimateOptions, offset: number): AnimateOptions {\n if (offset === 0) return options;\n\n const delay = options.delay ?? 0;\n\n if (typeof delay !== 'number') {\n throw new NecromancerConfigError(`A non-zero stagger requires a numeric delay; received ${typeof delay}.`);\n }\n\n return { ...options, delay: delay + offset };\n}\n","import { interruptAnimations, trackAnimation } from './_active';\nimport { createAnimationHandle } from './_handle';\nimport { resolveAnimationOptions, shouldReduceMotion } from './_motion';\nimport { NecromancerUnsupportedError } from './errors';\nimport type { AnimateOptions, AnimationHandle, Keyframes } from './types';\n\n/**\n * Starts a lifecycle-owned native Web Animation for one element.\n *\n * The returned handle cancels its native animation when disposed. By default, the\n * operating system's reduced-motion preference suppresses movement.\n */\nexport function animate(element: Element, keyframes: Keyframes, options: AnimateOptions = {}): AnimationHandle {\n if (options.signal?.aborted) throw options.signal.reason;\n\n if (typeof element.animate !== 'function') {\n throw new NecromancerUnsupportedError('The Web Animations API is not available in this environment.');\n }\n\n if (options.interrupt === 'cancel') interruptAnimations(element);\n\n const reduced = shouldReduceMotion(options.motion ?? 'system');\n const nativeAnimation = element.animate(\n keyframes as Keyframe[] | PropertyIndexedKeyframes,\n resolveAnimationOptions(options, reduced),\n );\n const handle = createAnimationHandle(nativeAnimation, options.signal, reduced);\n\n trackAnimation(element, handle);\n\n return handle;\n}\n","/** Deduplicates elements while preserving first-seen order. Shared by `animateEach()` and `captureLayout()`. */\nexport function uniqueElements(elements: Iterable<Element>): Element[] {\n return [...new Set(elements)];\n}\n","import { uniqueElements } from './_elements';\nimport { createAnimationGroup } from './_handle';\nimport { withStaggeredDelay } from './_motion';\nimport { animate } from './animate';\nimport { NecromancerConfigError } from './errors';\nimport type { AnimateEachOptions, AnimationGroup, AnimationHandle, KeyframeFactory, Keyframes } from './types';\n\nfunction validateStagger(stagger: number): void {\n if (!Number.isFinite(stagger) || stagger < 0) {\n throw new NecromancerConfigError('stagger must be a finite, non-negative number.');\n }\n}\n\n/**\n * Starts lifecycle-owned animations for unique elements in iteration order.\n *\n * Each subsequent element starts after `stagger` milliseconds. A keyframe factory\n * receives the stable unique-element index and total before any animation starts.\n */\nexport function animateEach(\n elements: Iterable<Element>,\n keyframes: Keyframes | KeyframeFactory,\n options: AnimateEachOptions = {},\n): AnimationGroup {\n const { signal, stagger = 0, ...animationOptions } = options;\n\n validateStagger(stagger);\n\n if (signal?.aborted) throw signal.reason;\n\n const unique = uniqueElements(elements);\n const frames = unique.map((element, index) =>\n typeof keyframes === 'function' ? keyframes(element, index, unique.length) : keyframes,\n );\n const handles: AnimationHandle[] = [];\n\n try {\n for (const [index, element] of unique.entries()) {\n // `frames` was built above from `unique`, one entry per element, so this index is always in range.\n const currentFrames = frames[index]!;\n\n handles.push(animate(element, currentFrames, withStaggeredDelay(animationOptions, index * stagger)));\n }\n } catch (error) {\n for (const handle of handles) handle.dispose(error);\n\n throw error;\n }\n\n return createAnimationGroup(handles, signal);\n}\n","import { uniqueElements } from './_elements';\nimport { animateEach } from './animate-each';\nimport { NecromancerConfigError } from './errors';\nimport type { LayoutAnimationOptions, LayoutCaptureOptions, LayoutTransition } from './types';\n\ntype LayoutRect = Readonly<Pick<DOMRectReadOnly, 'height' | 'width' | 'x' | 'y'>>;\ntype LayoutEntry = Readonly<{ element: Element; rect: LayoutRect }>;\ntype LayoutChange = Readonly<{ element: Element; scaleX: number; scaleY: number; x: number; y: number }>;\n\n// Rounds before templating into a keyframe string purely for DevTools readability — a `getBoundingClientRect()`\n// subtraction routinely produces values like `12.340000000000002`, which is noise once rendered as CSS.\n// Pixels only need whole-number precision; scale factors (close to 1) need finer precision to stay visually exact.\nfunction round(value: number, precision: number): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n// `getBoundingClientRect()`'s width/height is the rotated, axis-aligned bounding box — using it\n// for size would distort the scale ratio under any rotation. `offsetWidth`/`offsetHeight` report\n// the box's own untransformed layout size instead. Elements without an offset box (e.g. SVG)\n// fall back to the bounding rect, accepting that same distortion as the only option available.\nfunction measureSize(element: Element): Readonly<{ height: number; width: number }> {\n if ('offsetWidth' in element && 'offsetHeight' in element) {\n return { height: (element as HTMLElement).offsetHeight, width: (element as HTMLElement).offsetWidth };\n }\n\n const rect = element.getBoundingClientRect();\n\n return { height: rect.height, width: rect.width };\n}\n\nfunction measureLayout(element: Element): LayoutRect {\n const rect = element.getBoundingClientRect();\n const size = measureSize(element);\n\n return { height: size.height, width: size.width, x: rect.x, y: rect.y };\n}\n\n// `next` is 0 exactly when the element has collapsed (e.g. `display: none` mid-transition);\n// there's no meaningful ratio to compute then, so treat it as unscaled rather than producing Infinity/NaN.\nfunction computeScale(captured: number, next: number): number {\n return next === 0 ? 1 : captured / next;\n}\n\nfunction readKey(element: Element, getKey: (element: Element) => string, phase: string): string {\n const key = getKey(element);\n\n if (typeof key !== 'string' || key.length === 0) {\n throw new NecromancerConfigError(`getKey must return a non-empty string for every ${phase} element.`);\n }\n\n return key;\n}\n\nfunction createKeyMap(entries: readonly LayoutEntry[], getKey: (element: Element) => string, phase: string) {\n const keys = new Map<string, LayoutEntry>();\n\n for (const entry of entries) {\n const key = readKey(entry.element, getKey, phase);\n\n if (keys.has(key)) {\n throw new NecromancerConfigError(`getKey returned duplicate keys for the ${phase} elements.`);\n }\n\n keys.set(key, entry);\n }\n\n return keys;\n}\n\nfunction changedElement(element: Element, rect: LayoutRect): LayoutChange | undefined {\n if (!element.isConnected) return undefined;\n\n const next = measureLayout(element);\n const x = rect.x - next.x;\n const y = rect.y - next.y;\n const scaleX = computeScale(rect.width, next.width);\n const scaleY = computeScale(rect.height, next.height);\n\n return x === 0 && y === 0 && scaleX === 1 && scaleY === 1 ? undefined : { element, scaleX, scaleY, x, y };\n}\n\nfunction matchByIdentity(entries: readonly LayoutEntry[], elements: readonly Element[]): LayoutChange[] {\n const captured = new Map(entries.map((entry) => [entry.element, entry]));\n\n return elements.flatMap((element) => {\n const entry = captured.get(element);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\nfunction matchByKey(\n captured: ReadonlyMap<string, LayoutEntry>,\n elements: readonly Element[],\n getKey: (element: Element) => string,\n): LayoutChange[] {\n const committed = new Set<string>();\n\n return elements.flatMap((element) => {\n const key = readKey(element, getKey, 'committed');\n const entry = captured.get(key);\n\n if (committed.has(key)) {\n throw new NecromancerConfigError('getKey returned duplicate keys for the committed elements.');\n }\n\n committed.add(key);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\n/**\n * Captures the current position and size of unique elements for a later FLIP animation.\n *\n * Each element's `x`/`y` position and `width`/`height` are captured. Rotation and other\n * transforms are not captured or compensated. Capture before mutating the DOM, then call\n * the returned transition's `animate()` method after the browser has applied the resulting\n * layout — position changes animate via translate, and size changes via scale, both\n * additively composed on top of any authored transform.\n */\nexport function captureLayout(elements: Iterable<Element>, options: LayoutCaptureOptions = {}): LayoutTransition {\n const entries: LayoutEntry[] = uniqueElements(elements).map((element) => ({\n element,\n rect: measureLayout(element),\n }));\n const getKey = options.getKey;\n const captured = getKey ? createKeyMap(entries, getKey, 'captured') : undefined;\n\n let consumed = false;\n\n return {\n animate(options: LayoutAnimationOptions = {}) {\n if (consumed) throw new NecromancerConfigError('This layout transition has already been animated.');\n\n const { elements: committedElements, ...animationOptions } = options;\n const elements = uniqueElements(committedElements ?? entries.map(({ element }) => element));\n const changed = getKey && captured ? matchByKey(captured, elements, getKey) : matchByIdentity(entries, elements);\n\n consumed = true;\n\n return animateEach(\n changed.map(({ element }) => element),\n (_, index) => {\n // `changed` was mapped directly into the elements array above, so this index is always in range.\n const change = changed[index]!;\n const translate = `${round(change.x, 2)}px ${round(change.y, 2)}px`;\n const scale = `${round(change.scaleX, 4)} ${round(change.scaleY, 4)}`;\n\n return [\n { composite: 'add', scale, translate },\n { composite: 'add', scale: '1 1', translate: '0px 0px' },\n ];\n },\n animationOptions,\n );\n },\n };\n}\n"],"mappings":"AAQA,IAAM,EAAmB,IAAI,QAG7B,SAAgB,EAAoB,EAAwB,CAC1D,IAAK,IAAM,KAAU,EAAiB,IAAI,CAAO,GAAK,CAAC,EAAG,EAAO,QAAQ,CAC3E,CAGA,SAAgB,EAAe,EAAkB,EAA+B,CAC9E,IAAI,EAAU,EAAiB,IAAI,CAAO,EAErC,IACH,EAAU,IAAI,IACd,EAAiB,IAAI,EAAS,CAAO,GAGvC,EAAQ,IAAI,CAAM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,CAAE,aAAc,CAAO,CAAC,EACpF,EAAU,GAAU,EAAW,EAAW,EAAU,EAAU,CAAM,EAAI,EAAgB,EAAS,CAAQ,EAI/G,MAFA,GAAW,GAEJ,EACL,EAAQ,KAAK,CAAE,aAAc,CAAO,GACnC,EAAG,IAAU,CAEZ,IAAM,EAAS,EAAQ,GACjB,EAAY,GAAG,EAAM,EAAO,EAAG,CAAC,EAAE,KAAK,EAAM,EAAO,EAAG,CAAC,EAAE,IAGhE,MAAO,CACL,CAAE,UAAW,MAAO,MAAA,GAHL,EAAM,EAAO,OAAQ,CAAC,EAAE,GAAG,EAAM,EAAO,OAAQ,CAAC,IAGrC,WAAU,EACrC,CAAE,UAAW,MAAO,MAAO,MAAO,UAAW,SAAU,CACzD,CACF,EACA,CACF,CACF,CACF,CACF"}
1
+ {"version":3,"file":"necromancer.js","names":[],"sources":["../src/_active.ts","../src/_handle.ts","../src/errors.ts","../src/_motion.ts","../src/animate.ts","../src/_elements.ts","../src/animate-each.ts","../src/layout.ts"],"sourcesContent":["import type { AnimationHandle } from './types';\n\n// Scoped to one DOM element by design: `interrupt: 'cancel'` answers \"replace whatever\n// Necromancer is doing to *this* element\", not \"coordinate across element categories\".\n// A caller that needs to cancel an animation on a different element (or coordinate several\n// elements as one unit) already has that element's own handle, or should use `animateEach()`\n// and a shared `signal` instead. Keeping the WeakMap element-scoped means it only ever needs\n// to answer one question and never grows into a general-purpose animation registry.\nconst handlesByElement = new WeakMap<Element, Set<AnimationHandle>>();\n\n/** Cancels active Necromancer-owned animations without touching native animations owned by callers. */\nexport function interruptAnimations(element: Element): void {\n for (const handle of handlesByElement.get(element) ?? []) handle.dispose();\n}\n\n/** Tracks a handle until its terminal result releases the element association. */\nexport function trackAnimation(element: Element, handle: AnimationHandle): void {\n let handles = handlesByElement.get(element);\n\n if (!handles) {\n handles = new Set();\n handlesByElement.set(element, handles);\n }\n\n handles.add(handle);\n\n void handle.result.then(() => {\n handles?.delete(handle);\n\n if (handles?.size === 0) handlesByElement.delete(element);\n });\n}\n","import type { AnimationGroup, AnimationHandle, AnimationResult } from './types';\n\n/**\n * Attaches an abort listener to a signal and returns a function that removes it.\n * When the signal aborts, calls the dispose function with the signal's reason.\n */\nfunction attachAbortSignalListener(signal: AbortSignal, dispose: (reason?: unknown) => void): () => void {\n const abort = () => dispose(signal.reason);\n\n signal.addEventListener('abort', abort, { once: true });\n\n return () => signal.removeEventListener('abort', abort);\n}\n\nfunction createResultPromise(animation: Animation, onSettled: () => void, reduced: boolean): Promise<AnimationResult> {\n return animation.finished.then(\n () => {\n onSettled();\n\n return { status: reduced ? 'reduced' : 'finished' };\n },\n (reason: unknown) => {\n onSettled();\n\n return { reason, status: 'cancelled' };\n },\n );\n}\n\n/** Wraps a native Animation with Necromancer's lifecycle contract. */\nexport function createAnimationHandle(animation: Animation, signal?: AbortSignal, reduced = false): AnimationHandle {\n let disposed = false;\n let disposeReason: unknown;\n let hasDisposeReason = false;\n let removeAbortListener: (() => void) | undefined;\n\n const result: Promise<AnimationResult> = createResultPromise(\n animation,\n () => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n },\n reduced,\n ).then((outcome): AnimationResult => {\n if (disposed && hasDisposeReason && outcome.status === 'cancelled') {\n return { reason: disposeReason, status: 'cancelled' };\n }\n\n return outcome;\n });\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n disposeReason = reason;\n hasDisposeReason = reason !== undefined;\n removeAbortListener?.();\n removeAbortListener = undefined;\n animation.cancel();\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n animation,\n dispose,\n get disposed() {\n return disposed;\n },\n result,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n\n/** Combines child animation handles under one disposal owner. */\nexport function createAnimationGroup(handles: readonly AnimationHandle[], signal?: AbortSignal): AnimationGroup {\n let disposed = false;\n let removeAbortListener: (() => void) | undefined;\n\n const results: Promise<readonly AnimationResult[]> = Promise.all(handles.map((handle) => handle.result)).then(\n (childResults): readonly AnimationResult[] => {\n removeAbortListener?.();\n removeAbortListener = undefined;\n\n return childResults;\n },\n );\n\n const dispose = (reason?: unknown): void => {\n if (disposed) return;\n\n disposed = true;\n removeAbortListener?.();\n removeAbortListener = undefined;\n for (const handle of handles) handle.dispose(reason);\n };\n\n if (signal) {\n removeAbortListener = attachAbortSignalListener(signal, dispose);\n }\n\n return {\n dispose,\n get disposed() {\n return disposed;\n },\n handles,\n results,\n [Symbol.dispose]() {\n this.dispose();\n },\n };\n}\n","/** Base class for errors raised by `@vielzeug/necromancer`. */\nexport class NecromancerError extends Error {\n constructor(message: string, opts?: ErrorOptions) {\n super(message, opts);\n this.name = new.target.name;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/** Thrown when a Necromancer-owned option is invalid. */\nexport class NecromancerConfigError extends NecromancerError {}\n\n/** Thrown when the runtime does not implement the Web Animations API. */\nexport class NecromancerUnsupportedError extends NecromancerError {}\n","import { NecromancerConfigError } from './errors';\nimport type { AnimateOptions, MotionMode } from './types';\n\nconst DEFAULT_DURATION = 180;\n\n/** Reports whether the requested motion preference reduces visible movement. */\nexport function shouldReduceMotion(mode: MotionMode): boolean {\n if (mode === 'full') return false;\n\n if (mode === 'reduced') return true;\n\n return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\n/** Converts ownership options to native timing, collapsing reduced motion to an instant transition. */\nexport function resolveAnimationOptions(options: AnimateOptions = {}, reduced = false): KeyframeAnimationOptions {\n const { duration, interrupt: _interrupt, motion: _motion = 'system', signal: _signal, ...nativeOptions } = options;\n const timing =\n duration === undefined ? { ...nativeOptions, duration: DEFAULT_DURATION } : { ...nativeOptions, duration };\n\n return reduced ? { ...timing, delay: 0, duration: 0, endDelay: 0, iterations: 1 } : timing;\n}\n\n/** Adds an element's stagger offset without changing native nonnumeric delays when no offset is needed. */\nexport function withStaggeredDelay(options: AnimateOptions, offset: number): AnimateOptions {\n if (offset === 0) return options;\n\n const delay = options.delay ?? 0;\n\n if (typeof delay !== 'number') {\n throw new NecromancerConfigError(`A non-zero stagger requires a numeric delay; received ${typeof delay}.`);\n }\n\n return { ...options, delay: delay + offset };\n}\n","import { interruptAnimations, trackAnimation } from './_active';\nimport { createAnimationHandle } from './_handle';\nimport { resolveAnimationOptions, shouldReduceMotion } from './_motion';\nimport { NecromancerUnsupportedError } from './errors';\nimport type { AnimateOptions, AnimationHandle, Keyframes } from './types';\n\n/**\n * Starts a lifecycle-owned native Web Animation for one element.\n *\n * The returned handle cancels its native animation when disposed. By default, the\n * operating system's reduced-motion preference suppresses movement.\n */\nexport function animate(element: Element, keyframes: Keyframes, options: AnimateOptions = {}): AnimationHandle {\n if (options.signal?.aborted) throw options.signal.reason;\n\n if (typeof element.animate !== 'function') {\n throw new NecromancerUnsupportedError('The Web Animations API is not available in this environment.');\n }\n\n if (options.interrupt === 'cancel') interruptAnimations(element);\n\n const reduced = shouldReduceMotion(options.motion ?? 'system');\n const nativeAnimation = element.animate(\n keyframes as Keyframe[] | PropertyIndexedKeyframes,\n resolveAnimationOptions(options, reduced),\n );\n const handle = createAnimationHandle(nativeAnimation, options.signal, reduced);\n\n trackAnimation(element, handle);\n\n return handle;\n}\n","/** Deduplicates elements while preserving first-seen order. Shared by `animateEach()` and `captureLayout()`. */\nexport function uniqueElements(elements: Iterable<Element>): Element[] {\n return [...new Set(elements)];\n}\n","import { uniqueElements } from './_elements';\nimport { createAnimationGroup } from './_handle';\nimport { withStaggeredDelay } from './_motion';\nimport { animate } from './animate';\nimport { NecromancerConfigError } from './errors';\nimport type { AnimateEachOptions, AnimationGroup, AnimationHandle, KeyframeFactory, Keyframes } from './types';\n\nfunction validateStagger(stagger: number): void {\n if (!Number.isFinite(stagger) || stagger < 0) {\n throw new NecromancerConfigError('stagger must be a finite, non-negative number.');\n }\n}\n\n/**\n * Starts lifecycle-owned animations for unique elements in iteration order.\n *\n * Each subsequent element starts after `stagger` milliseconds. A keyframe factory\n * receives the stable unique-element index and total before any animation starts.\n */\nexport function animateEach(\n elements: Iterable<Element>,\n keyframes: Keyframes | KeyframeFactory,\n options: AnimateEachOptions = {},\n): AnimationGroup {\n const { signal, stagger = 0, ...animationOptions } = options;\n\n validateStagger(stagger);\n\n if (signal?.aborted) throw signal.reason;\n\n const unique = uniqueElements(elements);\n const frames = unique.map((element, index) =>\n typeof keyframes === 'function' ? keyframes(element, index, unique.length) : keyframes,\n );\n const handles: AnimationHandle[] = [];\n\n try {\n for (const [index, element] of unique.entries()) {\n // `frames` was built above from `unique`, one entry per element, so this index is always in range.\n const currentFrames = frames[index]!;\n\n handles.push(animate(element, currentFrames, withStaggeredDelay(animationOptions, index * stagger)));\n }\n } catch (error) {\n for (const handle of handles) handle.dispose(error);\n\n throw error;\n }\n\n return createAnimationGroup(handles, signal);\n}\n","import { uniqueElements } from './_elements';\nimport { animateEach } from './animate-each';\nimport { NecromancerConfigError } from './errors';\nimport type { LayoutAnimationOptions, LayoutCaptureOptions, LayoutTransition } from './types';\n\ntype LayoutRect = Readonly<Pick<DOMRectReadOnly, 'height' | 'width' | 'x' | 'y'>>;\ntype LayoutEntry = Readonly<{ element: Element; rect: LayoutRect }>;\ntype LayoutChange = Readonly<{ element: Element; scaleX: number; scaleY: number; x: number; y: number }>;\n\n// Rounds before templating into a keyframe string purely for DevTools readability — a `getBoundingClientRect()`\n// subtraction routinely produces values like `12.340000000000002`, which is noise once rendered as CSS.\n// Pixels only need whole-number precision; scale factors (close to 1) need finer precision to stay visually exact.\nfunction round(value: number, precision: number): number {\n const factor = 10 ** precision;\n\n return Math.round(value * factor) / factor;\n}\n\n// `getBoundingClientRect()`'s width/height is the rotated, axis-aligned bounding box — using it\n// for size would distort the scale ratio under any rotation. `offsetWidth`/`offsetHeight` report\n// the box's own untransformed layout size instead. Elements without an offset box (e.g. SVG)\n// fall back to the bounding rect, accepting that same distortion as the only option available.\nfunction measureSize(element: Element): Readonly<{ height: number; width: number }> {\n if ('offsetWidth' in element && 'offsetHeight' in element) {\n return { height: (element as HTMLElement).offsetHeight, width: (element as HTMLElement).offsetWidth };\n }\n\n const rect = element.getBoundingClientRect();\n\n return { height: rect.height, width: rect.width };\n}\n\nfunction measureLayout(element: Element): LayoutRect {\n const rect = element.getBoundingClientRect();\n const size = measureSize(element);\n\n return { height: size.height, width: size.width, x: rect.x, y: rect.y };\n}\n\n// `next` is 0 exactly when the element has collapsed (e.g. `display: none` mid-transition);\n// there's no meaningful ratio to compute then, so treat it as unscaled rather than producing Infinity/NaN.\nfunction computeScale(captured: number, next: number): number {\n return next === 0 ? 1 : captured / next;\n}\n\nfunction readKey(element: Element, getKey: (element: Element) => string, phase: string): string {\n const key = getKey(element);\n\n if (typeof key !== 'string' || key.length === 0) {\n throw new NecromancerConfigError(`getKey must return a non-empty string for every ${phase} element.`);\n }\n\n return key;\n}\n\nfunction createKeyMap(entries: readonly LayoutEntry[], getKey: (element: Element) => string, phase: string) {\n const keys = new Map<string, LayoutEntry>();\n\n for (const entry of entries) {\n const key = readKey(entry.element, getKey, phase);\n\n if (keys.has(key)) {\n throw new NecromancerConfigError(`getKey returned duplicate keys for the ${phase} elements.`);\n }\n\n keys.set(key, entry);\n }\n\n return keys;\n}\n\nfunction changedElement(element: Element, rect: LayoutRect): LayoutChange | undefined {\n if (!element.isConnected) return undefined;\n\n const next = measureLayout(element);\n const x = rect.x - next.x;\n const y = rect.y - next.y;\n const scaleX = computeScale(rect.width, next.width);\n const scaleY = computeScale(rect.height, next.height);\n\n return x === 0 && y === 0 && scaleX === 1 && scaleY === 1 ? undefined : { element, scaleX, scaleY, x, y };\n}\n\nfunction matchByIdentity(entries: readonly LayoutEntry[], elements: readonly Element[]): LayoutChange[] {\n const captured = new Map(entries.map((entry) => [entry.element, entry]));\n\n return elements.flatMap((element) => {\n const entry = captured.get(element);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\nfunction matchByKey(\n captured: ReadonlyMap<string, LayoutEntry>,\n elements: readonly Element[],\n getKey: (element: Element) => string,\n): LayoutChange[] {\n const committed = new Set<string>();\n\n return elements.flatMap((element) => {\n const key = readKey(element, getKey, 'committed');\n const entry = captured.get(key);\n\n if (committed.has(key)) {\n throw new NecromancerConfigError('getKey returned duplicate keys for the committed elements.');\n }\n\n committed.add(key);\n\n return entry\n ? [changedElement(element, entry.rect)].filter((change): change is LayoutChange => Boolean(change))\n : [];\n });\n}\n\n/**\n * Captures the current position and size of unique elements for a later FLIP animation.\n *\n * Each element's `x`/`y` position and `width`/`height` are captured. Rotation and other\n * transforms are not captured or compensated. Capture before mutating the DOM, then call\n * the returned transition's `animate()` method after the browser has applied the resulting\n * layout — position changes animate via translate, and size changes via scale, both\n * additively composed on top of any authored transform.\n */\nexport function captureLayout(elements: Iterable<Element>, options: LayoutCaptureOptions = {}): LayoutTransition {\n const entries: LayoutEntry[] = uniqueElements(elements).map((element) => ({\n element,\n rect: measureLayout(element),\n }));\n const getKey = options.getKey;\n const captured = getKey ? createKeyMap(entries, getKey, 'captured') : undefined;\n\n let consumed = false;\n\n return {\n animate(options: LayoutAnimationOptions = {}) {\n if (consumed) throw new NecromancerConfigError('This layout transition has already been animated.');\n\n const { elements: committedElements, ...animationOptions } = options;\n const elements = uniqueElements(committedElements ?? entries.map(({ element }) => element));\n const changed = getKey && captured ? matchByKey(captured, elements, getKey) : matchByIdentity(entries, elements);\n\n consumed = true;\n\n return animateEach(\n changed.map(({ element }) => element),\n (_, index) => {\n // `changed` was mapped directly into the elements array above, so this index is always in range.\n const change = changed[index]!;\n const translate = `${round(change.x, 2)}px ${round(change.y, 2)}px`;\n const scale = `${round(change.scaleX, 4)} ${round(change.scaleY, 4)}`;\n\n return [\n { composite: 'add', scale, translate },\n { composite: 'add', scale: '1 1', translate: '0px 0px' },\n ];\n },\n animationOptions,\n );\n },\n };\n}\n"],"mappings":"AAQA,IAAM,EAAmB,IAAI,QAG7B,SAAgB,EAAoB,EAAwB,CAC1D,IAAK,IAAM,K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QAAQ,EAAkC,CAAC,EAAG,CAC5C,GAAI,EAAU,MAAM,IAAI,EAAuB,mDAAmD,EAElG,GAAM,CAAE,SAAU,EAAmB,GAAG,GAAqB,EACvD,EAAW,EAAe,GAAqB,EAAQ,KAAK,CAAE,aAAc,CAAO,CAAC,EACpF,EAAU,GAAU,EAAW,EAAW,EAAU,EAAU,CAAM,EAAI,EAAgB,EAAS,CAAQ,EAI/G,MAFA,GAAW,GAEJ,EACL,EAAQ,KAAK,CAAE,aAAc,CAAO,GACnC,EAAG,IAAU,CAEZ,IAAM,EAAS,EAAQ,GACjB,EAAY,GAAG,EAAM,EAAO,EAAG,CAAC,EAAE,KAAK,EAAM,EAAO,EAAG,CAAC,EAAE,IAGhE,MAAO,CACL,CAAE,UAAW,MAAO,MAAA,GAHL,EAAM,EAAO,OAAQ,CAAC,EAAE,GAAG,EAAM,EAAO,OAAQ,CAAC,IAGrC,WAAU,EACrC,CAAE,UAAW,MAAO,MAAO,MAAO,UAAW,SAAU,CACzD,CACF,EACA,CACF,CACF,CACF,CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vielzeug/necromancer",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "Dependency-free, lifecycle-owned animation primitives built on the Web Animations API",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,6 +36,7 @@
36
36
  ]
37
37
  }
38
38
  },
39
+ "sideEffects": false,
39
40
  "publishConfig": {
40
41
  "access": "public",
41
42
  "registry": "https://registry.npmjs.org/"