@vielzeug/necromancer 26.10.15 → 26.10.16

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/testing.js CHANGED
@@ -1,2 +1,49 @@
1
- var FakeAnimation=class{#e;#t;cancelCallCount=0;finishCallCount=0;finished;constructor(){this.finished=new Promise((e,t)=>{this.#t=e,this.#e=t})}cancel=()=>{this.cancelCallCount+=1,this.#e(new DOMException(`The animation was canceled.`,`AbortError`))};finish=()=>{this.finishCallCount+=1,this.#t()}};function installFakeAnimations(){let e=[],t=Object.getOwnPropertyDescriptor(Element.prototype,`animate`),n=!1;Object.defineProperty(Element.prototype,"animate",{configurable:!0,value:(t,n)=>{let r=new FakeAnimation;return e.push({animation:r,keyframes:t,options:n}),r},writable:!0});let restore=()=>{n||(n=!0,t?Object.defineProperty(Element.prototype,"animate",t):Reflect.deleteProperty(Element.prototype,`animate`))};return{calls:e,restore,[Symbol.dispose]:restore}}function createRect(e,t,n=20,r=20){return new DOMRect(e,t,n,r)}export{FakeAnimation,createRect,installFakeAnimations};
1
+ //#region src/testing/index.ts
2
+ var FakeAnimation = class {
3
+ #e;
4
+ #t;
5
+ cancelCallCount = 0;
6
+ finishCallCount = 0;
7
+ finished;
8
+ constructor() {
9
+ this.finished = new Promise((e, t) => {
10
+ this.#t = e, this.#e = t;
11
+ });
12
+ }
13
+ cancel = () => {
14
+ this.cancelCallCount += 1, this.#e(new DOMException("The animation was canceled.", "AbortError"));
15
+ };
16
+ finish = () => {
17
+ this.finishCallCount += 1, this.#t();
18
+ };
19
+ };
20
+ function installFakeAnimations() {
21
+ let e = [], t = Object.getOwnPropertyDescriptor(Element.prototype, "animate"), n = !1;
22
+ Object.defineProperty(Element.prototype, "animate", {
23
+ configurable: !0,
24
+ value: (t, n) => {
25
+ let r = new FakeAnimation();
26
+ return e.push({
27
+ animation: r,
28
+ keyframes: t,
29
+ options: n
30
+ }), r;
31
+ },
32
+ writable: !0
33
+ });
34
+ let restore = () => {
35
+ n || (n = !0, t ? Object.defineProperty(Element.prototype, "animate", t) : Reflect.deleteProperty(Element.prototype, "animate"));
36
+ };
37
+ return {
38
+ calls: e,
39
+ restore,
40
+ [Symbol.dispose]: restore
41
+ };
42
+ }
43
+ function createRect(e, t, n = 20, r = 20) {
44
+ return new DOMRect(e, t, n, r);
45
+ }
46
+ //#endregion
47
+ export { FakeAnimation, createRect, installFakeAnimations };
48
+
2
49
  //# sourceMappingURL=testing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/index.ts"],"sourcesContent":["/**\n * Testing utilities for code that calls Necromancer's animation functions.\n *\n * jsdom (and most non-browser DOM environments) do not implement `Element.animate()`,\n * so any test that exercises `animate()`, `animateEach()`, or `captureLayout()` needs a\n * substitute. This module has no test-runner import: it works the same under Vitest,\n * Jest, or any other runner; use your runner's own spy/mock APIs on top if needed.\n */\n\nexport type AnimationCall = {\n readonly animation: FakeAnimation;\n readonly keyframes: Keyframe[] | PropertyIndexedKeyframes;\n readonly options?: KeyframeAnimationOptions;\n};\n\n/** A minimal `Animation` stand-in. Call `finish()`/`cancel()` to settle it like the real API would. */\nexport class FakeAnimation {\n #reject!: (reason?: unknown) => void;\n #resolve!: () => void;\n\n /** Number of times `cancel()` has been called. */\n cancelCallCount = 0;\n /** Number of times `finish()` has been called. */\n finishCallCount = 0;\n /** Mirrors the native `Animation.finished` promise. */\n finished: Promise<void>;\n\n constructor() {\n this.finished = new Promise<void>((resolve, reject) => {\n this.#resolve = resolve;\n this.#reject = reject;\n });\n }\n\n /** Rejects `finished` with an `AbortError`, like a real cancelled `Animation`. */\n cancel = (): void => {\n this.cancelCallCount += 1;\n this.#reject(new DOMException('The animation was canceled.', 'AbortError'));\n };\n\n /** Resolves `finished`, like a real completed `Animation`. */\n finish = (): void => {\n this.finishCallCount += 1;\n this.#resolve();\n };\n}\n\n/**\n * Replaces `Element.prototype.animate` with a deterministic lifecycle fake for a test.\n * Dispose the installation or call `restore()` to restore the original implementation.\n *\n * @example\n * using animations = installFakeAnimations();\n * const handle = animate(element, [{ opacity: 0 }, { opacity: 1 }]);\n * animations.calls[0]?.animation.finish();\n * await handle.result; // { status: 'finished' }\n */\nexport function installFakeAnimations(): {\n readonly calls: readonly AnimationCall[];\n restore(): void;\n [Symbol.dispose](): void;\n} {\n const calls: AnimationCall[] = [];\n const descriptor = Object.getOwnPropertyDescriptor(Element.prototype, 'animate');\n let restored = false;\n\n Object.defineProperty(Element.prototype, 'animate', {\n configurable: true,\n value: (keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: KeyframeAnimationOptions) => {\n const animation = new FakeAnimation();\n\n calls.push({ animation, keyframes, options });\n\n // Necromancer only consumes the documented Animation surface represented by FakeAnimation.\n return animation as unknown as Animation;\n },\n writable: true,\n });\n\n const restore = (): void => {\n if (restored) return;\n\n restored = true;\n if (descriptor) Object.defineProperty(Element.prototype, 'animate', descriptor);\n else Reflect.deleteProperty(Element.prototype, 'animate');\n };\n\n return {\n calls,\n restore,\n [Symbol.dispose]: restore,\n };\n}\n\n/** Builds a `DOMRect` for mocking `Element.getBoundingClientRect()` in `captureLayout()` tests. */\nexport function createRect(x: number, y: number, width = 20, height = 20): DOMRect {\n return new DOMRect(x, y, width, height);\n}\n"],"mappings":"AAgBA,IAAa,cAAb,KAA2B,CACzB,GACA,GAGA,gBAAkB,EAElB,gBAAkB,EAElB,SAEA,aAAc,CACZ,KAAK,SAAW,IAAI,SAAe,EAAS,IAAW,CACrD,KAAK,GAAW,EAChB,KAAK,GAAU,CACjB,CAAC,CACH,CAGA,WAAqB,CACnB,KAAK,iBAAmB,EACxB,KAAK,GAAQ,IAAI,aAAa,8BAA+B,YAAY,CAAC,CAC5E,EAGA,WAAqB,CACnB,KAAK,iBAAmB,EACxB,KAAK,GAAS,CAChB,CACF,EAYA,SAAgB,uBAId,CACA,IAAM,EAAyB,CAAC,EAC1B,EAAa,OAAO,yBAAyB,QAAQ,UAAW,SAAS,EAC3E,EAAW,GAEf,OAAO,eAAe,QAAQ,UAAW,UAAW,CAClD,aAAc,GACd,OAAQ,EAAkD,IAAuC,CAC/F,IAAM,EAAY,IAAI,cAKtB,OAHA,EAAM,KAAK,CAAE,YAAW,YAAW,SAAQ,CAAC,EAGrC,CACT,EACA,SAAU,EACZ,CAAC,EAED,IAAM,YAAsB,CACtB,IAEJ,EAAW,GACP,EAAY,OAAO,eAAe,QAAQ,UAAW,UAAW,CAAU,EACzE,QAAQ,eAAe,QAAQ,UAAW,SAAS,EAC1D,EAEA,MAAO,CACL,QACA,SACC,OAAO,SAAU,OACpB,CACF,CAGA,SAAgB,WAAW,EAAW,EAAW,EAAQ,GAAI,EAAS,GAAa,CACjF,OAAO,IAAI,QAAQ,EAAG,EAAG,EAAO,CAAM,CACxC"}
1
+ {"version":3,"file":"testing.js","names":["#resolve","resolve","#reject","reject","calls","descriptor","restored","animation","x","y","width","height"],"sources":["../src/testing/index.ts"],"sourcesContent":["/**\n * Testing utilities for code that calls Necromancer's animation functions.\n *\n * jsdom (and most non-browser DOM environments) do not implement `Element.animate()`,\n * so any test that exercises `animate()`, `animateEach()`, or `captureLayout()` needs a\n * substitute. This module has no test-runner import: it works the same under Vitest,\n * Jest, or any other runner; use your runner's own spy/mock APIs on top if needed.\n */\n\nexport type AnimationCall = {\n readonly animation: FakeAnimation;\n readonly keyframes: Keyframe[] | PropertyIndexedKeyframes;\n readonly options?: KeyframeAnimationOptions;\n};\n\n/** A minimal `Animation` stand-in. Call `finish()`/`cancel()` to settle it like the real API would. */\nexport class FakeAnimation {\n #reject!: (reason?: unknown) => void;\n #resolve!: () => void;\n\n /** Number of times `cancel()` has been called. */\n cancelCallCount = 0;\n /** Number of times `finish()` has been called. */\n finishCallCount = 0;\n /** Mirrors the native `Animation.finished` promise. */\n finished: Promise<void>;\n\n constructor() {\n this.finished = new Promise<void>((resolve, reject) => {\n this.#resolve = resolve;\n this.#reject = reject;\n });\n }\n\n /** Rejects `finished` with an `AbortError`, like a real cancelled `Animation`. */\n cancel = (): void => {\n this.cancelCallCount += 1;\n this.#reject(new DOMException('The animation was canceled.', 'AbortError'));\n };\n\n /** Resolves `finished`, like a real completed `Animation`. */\n finish = (): void => {\n this.finishCallCount += 1;\n this.#resolve();\n };\n}\n\n/**\n * Replaces `Element.prototype.animate` with a deterministic lifecycle fake for a test.\n * Dispose the installation or call `restore()` to restore the original implementation.\n *\n * @example\n * using animations = installFakeAnimations();\n * const handle = animate(element, [{ opacity: 0 }, { opacity: 1 }]);\n * animations.calls[0]?.animation.finish();\n * await handle.result; // { status: 'finished' }\n */\nexport function installFakeAnimations(): {\n readonly calls: readonly AnimationCall[];\n restore(): void;\n [Symbol.dispose](): void;\n} {\n const calls: AnimationCall[] = [];\n const descriptor = Object.getOwnPropertyDescriptor(Element.prototype, 'animate');\n let restored = false;\n\n Object.defineProperty(Element.prototype, 'animate', {\n configurable: true,\n value: (keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: KeyframeAnimationOptions) => {\n const animation = new FakeAnimation();\n\n calls.push({ animation, keyframes, options });\n\n // Necromancer only consumes the documented Animation surface represented by FakeAnimation.\n return animation as unknown as Animation;\n },\n writable: true,\n });\n\n const restore = (): void => {\n if (restored) return;\n\n restored = true;\n if (descriptor) Object.defineProperty(Element.prototype, 'animate', descriptor);\n else Reflect.deleteProperty(Element.prototype, 'animate');\n };\n\n return {\n calls,\n restore,\n [Symbol.dispose]: restore,\n };\n}\n\n/** Builds a `DOMRect` for mocking `Element.getBoundingClientRect()` in `captureLayout()` tests. */\nexport function createRect(x: number, y: number, width = 20, height = 20): DOMRect {\n return new DOMRect(x, y, width, height);\n}\n"],"mappings":";AAgBA,IAAa,gBAAb,MAA2B;CACzB;CACA;CAGA,kBAAkB;CAElB,kBAAkB;CAElB;CAEA,cAAc;EACZ,KAAK,WAAW,IAAI,SAAe,GAAS,MAAW;GAErD,AADA,KAAKA,KAAWC,GAChB,KAAKC,KAAUC;EACjB,CAAC;CACH;CAGA,eAAqB;EAEnB,AADA,KAAK,mBAAmB,GACxB,KAAKD,GAAQ,IAAI,aAAa,+BAA+B,YAAY,CAAC;CAC5E;CAGA,eAAqB;EAEnB,AADA,KAAK,mBAAmB,GACxB,KAAKF,GAAS;CAChB;AACF;AAYA,SAAgB,wBAId;CACA,IAAMI,IAAyB,CAAC,GAC1BC,IAAa,OAAO,yBAAyB,QAAQ,WAAW,SAAS,GAC3EC,IAAW;CAEf,OAAO,eAAe,QAAQ,WAAW,WAAW;EAClD,cAAc;EACd,QAAQ,GAAkD,MAAuC;GAC/F,IAAMC,IAAY,IAAI,cAAc;GAKpC,OAHAH,EAAM,KAAK;IAAE;IAAW;IAAW;GAAQ,CAAC,GAGrCG;EACT;EACA,UAAU;CACZ,CAAC;CAED,IAAM,gBAAsB;EAC1B,AAAID,MAEJ,IAAW,IACPD,IAAY,OAAO,eAAe,QAAQ,WAAW,WAAWA,CAAU,IACzE,QAAQ,eAAe,QAAQ,WAAW,SAAS;CAC1D;CAEA,OAAO;EACL;EACA;GACC,OAAO,UAAU;CACpB;AACF;AAGA,SAAgB,WAAW,GAAW,GAAW,IAAQ,IAAI,IAAS,IAAa;CACjF,OAAO,IAAI,QAAQG,GAAGC,GAAGC,GAAOC,CAAM;AACxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vielzeug/necromancer",
3
- "version": "26.10.15",
3
+ "version": "26.10.16",
4
4
  "description": "Lifecycle-owned Web Animations API primitives with native access, per-handle groups, and additive FLIP",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,11 +53,11 @@
53
53
  "test:types": "tsc -p tsconfig.type-tests.json"
54
54
  },
55
55
  "devDependencies": {
56
- "@playwright/test": "^1.63.0",
57
- "@types/node": "^26.6.2",
58
- "jsdom": "^30.1.1",
56
+ "@playwright/test": "^1.64.1",
57
+ "@types/node": "^26.6.5",
58
+ "jsdom": "^30.1.3",
59
59
  "typescript": "^6.0.3",
60
- "vite": "^8.3.0",
61
- "vitest": "^5.0.1"
60
+ "vite": "^8.3.4",
61
+ "vitest": "^5.0.5"
62
62
  }
63
63
  }