motionary 10.7.0 → 10.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +42 -3
  3. package/dist/chunks/{anim-image-CFGpUX7t.cjs → anim-image-BzTQa2k3.cjs} +2 -2
  4. package/dist/chunks/{anim-image-CFGpUX7t.cjs.map → anim-image-BzTQa2k3.cjs.map} +1 -1
  5. package/dist/chunks/{anim-image-CXDD19FH.js → anim-image-iD646Q7i.js} +2 -2
  6. package/dist/chunks/{anim-image-CXDD19FH.js.map → anim-image-iD646Q7i.js.map} +1 -1
  7. package/dist/chunks/{keyframes-DwR6GPej.js → keyframes-B4zefz0k.js} +2 -2
  8. package/dist/chunks/{keyframes-DwR6GPej.js.map → keyframes-B4zefz0k.js.map} +1 -1
  9. package/dist/chunks/{keyframes-DdwGY1gr.cjs → keyframes-BlOyB1PP.cjs} +2 -2
  10. package/dist/chunks/{keyframes-DdwGY1gr.cjs.map → keyframes-BlOyB1PP.cjs.map} +1 -1
  11. package/dist/chunks/{registry-DhKZCitb.cjs → registry-BZxDVL3h.cjs} +2 -2
  12. package/dist/chunks/{registry-DhKZCitb.cjs.map → registry-BZxDVL3h.cjs.map} +1 -1
  13. package/dist/chunks/{registry-D87dP_aR.js → registry-Bkt3-3ET.js} +3 -3
  14. package/dist/chunks/{registry-D87dP_aR.js.map → registry-Bkt3-3ET.js.map} +1 -1
  15. package/dist/chunks/runtime-link-CUiZ8lbE.cjs +38 -0
  16. package/dist/chunks/runtime-link-CUiZ8lbE.cjs.map +1 -0
  17. package/dist/chunks/runtime-link-c13gskBZ.js +36 -0
  18. package/dist/chunks/runtime-link-c13gskBZ.js.map +1 -0
  19. package/dist/chunks/{ticker-jD9_A9Rh.cjs → ticker-BfxAECfO.cjs} +2 -2
  20. package/dist/chunks/{ticker-jD9_A9Rh.cjs.map → ticker-BfxAECfO.cjs.map} +1 -1
  21. package/dist/chunks/{ticker-CJYI5Pxc.js → ticker-ZtweD3U4.js} +2 -2
  22. package/dist/chunks/{ticker-CJYI5Pxc.js.map → ticker-ZtweD3U4.js.map} +1 -1
  23. package/dist/chunks/{tween-Dk0QmNe9.cjs → tween--MD-39y0.cjs} +2 -2
  24. package/dist/chunks/{tween-Dk0QmNe9.cjs.map → tween--MD-39y0.cjs.map} +1 -1
  25. package/dist/chunks/{tween-_Lld1MsF.js → tween-DACdkLyO.js} +2 -2
  26. package/dist/chunks/{tween-_Lld1MsF.js.map → tween-DACdkLyO.js.map} +1 -1
  27. package/dist/components/snap-carousel.cjs +216 -0
  28. package/dist/components/snap-carousel.cjs.map +1 -0
  29. package/dist/components/snap-carousel.d.cts +80 -0
  30. package/dist/components/snap-carousel.d.ts +80 -0
  31. package/dist/components/snap-carousel.js +214 -0
  32. package/dist/components/snap-carousel.js.map +1 -0
  33. package/dist/components/widgets.cjs +32 -46
  34. package/dist/components/widgets.cjs.map +1 -1
  35. package/dist/components/widgets.d.cts +77 -4
  36. package/dist/components/widgets.d.ts +77 -4
  37. package/dist/components/widgets.js +22 -36
  38. package/dist/components/widgets.js.map +1 -1
  39. package/dist/llms-full.txt +94 -6
  40. package/dist/llms.txt +6 -3
  41. package/dist/manifest.json +260 -19
  42. package/dist/runtime/drag-snap.cjs +269 -0
  43. package/dist/runtime/drag-snap.cjs.map +1 -0
  44. package/dist/runtime/drag-snap.d.cts +109 -0
  45. package/dist/runtime/drag-snap.d.ts +109 -0
  46. package/dist/runtime/drag-snap.iife.js +2 -0
  47. package/dist/runtime/drag-snap.iife.js.map +1 -0
  48. package/dist/runtime/drag-snap.js +261 -0
  49. package/dist/runtime/drag-snap.js.map +1 -0
  50. package/dist/runtime/format-apng.cjs +4 -4
  51. package/dist/runtime/format-apng.js +4 -4
  52. package/dist/runtime/format-css.cjs +4 -4
  53. package/dist/runtime/format-css.js +4 -4
  54. package/dist/runtime/format-gif.cjs +4 -4
  55. package/dist/runtime/format-gif.js +4 -4
  56. package/dist/runtime/format-gltf.cjs +37 -18
  57. package/dist/runtime/format-gltf.cjs.map +1 -1
  58. package/dist/runtime/format-gltf.d.cts +18 -2
  59. package/dist/runtime/format-gltf.d.ts +18 -2
  60. package/dist/runtime/format-gltf.iife.js +1 -1
  61. package/dist/runtime/format-gltf.iife.js.map +1 -1
  62. package/dist/runtime/format-gltf.js +37 -18
  63. package/dist/runtime/format-gltf.js.map +1 -1
  64. package/dist/runtime/format-motion.cjs +4 -4
  65. package/dist/runtime/format-motion.js +4 -4
  66. package/dist/runtime/format-obj.cjs +1 -1
  67. package/dist/runtime/format-obj.d.cts +2 -0
  68. package/dist/runtime/format-obj.d.ts +2 -0
  69. package/dist/runtime/format-obj.iife.js.map +1 -1
  70. package/dist/runtime/format-obj.js +1 -1
  71. package/dist/runtime/format-scene.cjs +1 -1
  72. package/dist/runtime/format-scene.js +1 -1
  73. package/dist/runtime/format-sprite.cjs +3 -3
  74. package/dist/runtime/format-sprite.js +3 -3
  75. package/dist/runtime/format-svg.cjs +3 -3
  76. package/dist/runtime/format-svg.js +3 -3
  77. package/dist/runtime/format-webp.cjs +4 -4
  78. package/dist/runtime/format-webp.js +4 -4
  79. package/dist/runtime/gl.cjs +17 -4
  80. package/dist/runtime/gl.cjs.map +1 -1
  81. package/dist/runtime/gl.d.cts +2 -0
  82. package/dist/runtime/gl.d.ts +2 -0
  83. package/dist/runtime/gl.iife.js +1 -1
  84. package/dist/runtime/gl.iife.js.map +1 -1
  85. package/dist/runtime/gl.js +17 -4
  86. package/dist/runtime/gl.js.map +1 -1
  87. package/dist/runtime/gltf-anim.cjs +251 -0
  88. package/dist/runtime/gltf-anim.cjs.map +1 -0
  89. package/dist/runtime/gltf-anim.d.cts +216 -0
  90. package/dist/runtime/gltf-anim.d.ts +216 -0
  91. package/dist/runtime/gltf-anim.iife.js +2 -0
  92. package/dist/runtime/gltf-anim.iife.js.map +1 -0
  93. package/dist/runtime/gltf-anim.js +243 -0
  94. package/dist/runtime/gltf-anim.js.map +1 -0
  95. package/dist/runtime/physics.cjs +1 -1
  96. package/dist/runtime/physics.js +1 -1
  97. package/dist/runtime/scroll.cjs +2 -2
  98. package/dist/runtime/scroll.js +2 -2
  99. package/dist/runtime/smooth.cjs +1 -1
  100. package/dist/runtime/smooth.js +1 -1
  101. package/dist/runtime/text.cjs +1 -1
  102. package/dist/runtime/text.js +1 -1
  103. package/dist/runtime/vector.cjs +421 -11
  104. package/dist/runtime/vector.cjs.map +1 -1
  105. package/dist/runtime/vector.d.cts +20 -4
  106. package/dist/runtime/vector.d.ts +20 -4
  107. package/dist/runtime/vector.iife.js +1 -1
  108. package/dist/runtime/vector.iife.js.map +1 -1
  109. package/dist/runtime/vector.js +421 -12
  110. package/dist/runtime/vector.js.map +1 -1
  111. package/dist/runtime.cjs +3 -3
  112. package/dist/runtime.d.cts +1 -1
  113. package/dist/runtime.d.ts +1 -1
  114. package/dist/runtime.iife.js +1 -1
  115. package/dist/runtime.iife.js.map +1 -1
  116. package/dist/runtime.js +5 -5
  117. package/dist/widgets.umd.js +1 -1
  118. package/dist/widgets.umd.js.map +1 -1
  119. package/docs/ROADMAP.md +1 -1
  120. package/docs/components/README.md +3 -2
  121. package/docs/components/usa-gl-scene.md +27 -6
  122. package/docs/components/usa-lottie-player.md +18 -0
  123. package/docs/components/usa-snap-carousel.md +68 -0
  124. package/docs/components.md +51 -3
  125. package/docs/runtime/drag-snap.md +60 -0
  126. package/docs/runtime/format-gltf.md +3 -2
  127. package/docs/runtime/gltf-anim.md +62 -0
  128. package/docs/runtime/vector.md +3 -2
  129. package/package.json +31 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [10.8.0] - 2026-10-09
11
+
12
+ ### Added
13
+ - **`motionary/runtime/drag-snap`** — pointer drag along one axis with velocity tracking (last 100 ms), inertial throws (constant deceleration), snap points (nearest to the projected throw; a fast flick always moves one point), rubber-band edges and a critically damped spring on the shared ticker; the click that ends a drag is swallowed, clicks inside still work. `createDragSnap(el, { snap, onUpdate, onSnap, … })` → `snapTo()`, `setPosition()`, `setSnapPoints()`; pure helpers `projectThrow`, `nearestSnap`, `rubberband`, `springStep`, `velocityTracker`. Reduced motion: no inertia, no spring. CDN `dist/runtime/drag-snap.iife.js`; fixed gzip budget.
14
+ - **`<usa-snap-carousel>`** (**Requires: motionary/runtime/drag-snap**) — drag / swipe carousel with real inertia and snapping, slides that keep their own width (peek), `align` (center · start), `gap`, `index`, `autoplay` (pauses on hover, focus, off screen; never under reduced motion), prev / next buttons, dots, ←/→ / Home / End; `next()`, `prev()`, `goTo()`, `controller`, `usa:change`. Without the runtime module it stays a native CSS scroll-snap strip (plus the clear notice). **Shipped as its own entry point `motionary/components/snap-carousel`** — from 10.8 new components are not added to `motionary/components/widgets` or the all-components `motionary/components/lite` bundle, whose fixed 70 KB gzip budget stays as it is.
15
+ - **`motionary/runtime/gltf-anim`** — glTF 2.0 **animation** (translation / rotation / scale / weights channels; `LINEAR` with quaternion slerp, `STEP`, `CUBICSPLINE` Hermite with in / out tangents), **skinning** (joint hierarchy, inverse bind matrices, 4 influences per vertex) and **morph targets** (POSITION + NORMAL deltas; mesh, node and animated weights) for models loaded by `motionary/runtime/format-gltf`, deformed on the CPU so every runtime/gl material works. `gltfAnimator(model, { clip, loop, speed })` → `seek()`, `update(dt)`, `play()` on the shared ticker; `gltfClips`, `sampleChannel`, `applyClip`, `deformModel`, `deformGeometry` are pure. Fixed gzip budget.
16
+ - `motionary/runtime/format-gltf`: **sparse accessors**; skin and morph data are kept on each geometry (`geometry.deform`) and node (`extras.skin`, `extras.weights`). `motionary/runtime/gl`: `geometry.version` — bump it after changing positions / normals and the renderer re-uploads them.
17
+ - **`<usa-gl-scene animation>`** plays a clip (name or index; empty = the first) with `animation-speed`; reduced motion shows the first pose; `animator` property; `usa:load` lists the clips. Animation needs `motionary/runtime/gltf-anim` (all five prerequisite places list it for the new "3D animation" card).
18
+ - **Lottie text layers** in `motionary/runtime/vector`: fonts by family + style (weight / italic), justification, tracking, line height, fill + stroke (stroke over fill), box text with word wrapping, source-text keyframes and source-text expressions.
19
+ - **Lottie expression subset** with Motionary's own interpreter — **no `eval` / `new Function`** (works under a strict CSP; an expression can only call the listed helpers): `time`, `value`, `wiggle()`, `loopOut()` / `loopIn()` (cycle · pingpong · offset · continue, + `…Duration`), `linear()`, `ease()`, `easeIn()`, `easeOut()`, `clamp()`, `valueAtTime()`, `framesToTime()`, `timeToFrames()`, `degreesToRadians()`, `radiansToDegrees()`, `add` / `sub` / `mul` / `div` / `length`, `Math.*`, arithmetic on numbers and arrays, `var` / `$bm_rt =`, comparisons and `?:`. Anything else keeps the keyframed value and `inspectLottie()` lists "expressions outside the supported subset". `evalExpression(src, value, time, fr)` is exported.
20
+ - New gallery / Store cards: snap carousel, 3D animation (a self-made skinned tentacle with two clips), Lottie text + expressions. Self-made, MIT test fixtures: `sample-skin.gltf`, `sample-morph.gltf` (one sparse target), `motionary-tentacle.glb`, `sample-text.json` (credits in `test/fixtures/formats/CREDITS.md`).
21
+ - Prerequisites for both new runtime modules appear in all five places (gallery card, Store detail with the **Requires:** badge, `docs/runtime/drag-snap.md` + `docs/runtime/gltf-anim.md` with compatibility tables, README, AI manifest); the format-gltf and vector compatibility tables are updated.
22
+
23
+ ### Accessibility
24
+ - `<usa-snap-carousel>` is a labelled `region` (`aria-roledescription="carousel"`), slides are `group`s labelled "n of N", the viewport is focusable with ←/→ / Home / End, prev / next are real buttons (disabled at the ends), dots are labelled buttons with `aria-current`, slide changes made with keys or buttons are announced politely; autoplay pauses on hover / focus and is off under reduced motion, where moves are instant.
25
+ - `<usa-gl-scene animation>`: reduced motion shows the first pose instead of playing.
26
+
27
+ ### Deferred (from the 10.8 plan)
28
+ - Cross-platform 3.0 (mini-program / HarmonyOS ArkTS samples, cross-platform previewer) and "manifest covers all effects" are not in this release; they stay on the roadmap after 11.0.
29
+
10
30
  ## [10.7.0] - 2026-10-09
11
31
 
12
32
  ### Added
package/README.md CHANGED
@@ -191,6 +191,8 @@ Motionary ships its own zero-dependency animation runtime — shared ticker, twe
191
191
  | [Official Rive runtime](docs/runtime/rive.md) | `@rive-app/canvas` | `https://unpkg.com/@rive-app/canvas@2.44.1/rive.js` | `provideRiveRuntime(() => import('@rive-app/canvas')); // lazy: fetched when the first <usa-rive> mounts` | official runtime (not bundled) |
192
192
  | [2D rigid-body physics](docs/runtime/physics.md) | `motionary/runtime/physics` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/physics.iife.js` | `use(physics);` | 10.0 KB |
193
193
  | [Scene JSON (motionary-scene@1)](docs/runtime/format-scene.md) | `motionary/runtime/format-scene` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-scene.iife.js` | `use(formatScene);` | 3.0 KB |
194
+ | [Drag, inertia and snap points](docs/runtime/drag-snap.md) | `motionary/runtime/drag-snap` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/drag-snap.iife.js` | `use(dragSnap);` | 4.0 KB |
195
+ | [glTF animation, skinning and morph targets](docs/runtime/gltf-anim.md) | `motionary/runtime/gltf-anim` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gltf-anim.iife.js` | `use(gltfAnim);` | 4.5 KB |
194
196
 
195
197
  Install once: `npm i motionary`. Plain HTML: load `runtime.iife.js` first, then the module files (each registers itself).
196
198
 
@@ -317,19 +319,20 @@ defineSmoothScroll(); // registers <usa-smooth-scroll> — after the prerequisit
317
319
  <usa-smooth-scroll lerp="0.1" offset="64"></usa-smooth-scroll>
318
320
  ```
319
321
 
320
- #### `<usa-gl-scene>` — Requires: motionary/runtime/gl + motionary/runtime/format-gltf + motionary/runtime/format-obj
322
+ #### `<usa-gl-scene>` — Requires: motionary/runtime/gl + motionary/runtime/format-gltf + motionary/runtime/format-obj + motionary/runtime/gltf-anim
321
323
 
322
324
  - **Install:** `npm i motionary`
323
- - **Import order & registration:** Register the core first, then the module: use(gl) also registers the core. CDN: load runtime.iife.js, then runtime/gl.iife.js (it registers itself). Register the core first, then the module: use(formatGltf) also registers the core. CDN: load runtime.iife.js, then runtime/format-gltf.iife.js (it registers itself). Register the core first, then the module: use(formatObj) also registers the core. CDN: load runtime.iife.js, then runtime/format-obj.iife.js (it registers itself).
325
+ - **Import order & registration:** Register the core first, then the module: use(gl) also registers the core. CDN: load runtime.iife.js, then runtime/gl.iife.js (it registers itself). Register the core first, then the module: use(formatGltf) also registers the core. CDN: load runtime.iife.js, then runtime/format-gltf.iife.js (it registers itself). Register the core first, then the module: use(formatObj) also registers the core. CDN: load runtime.iife.js, then runtime/format-obj.iife.js (it registers itself). Register the core first, then the module: use(gltfAnim) also registers the core. CDN: load runtime.iife.js, then runtime/gltf-anim.iife.js (it registers itself).
324
326
 
325
327
  ```js
326
328
  import { use } from 'motionary/runtime';
327
329
  import { gl } from 'motionary/runtime/gl';
328
330
  import { formatGltf } from 'motionary/runtime/format-gltf';
329
331
  import { formatObj } from 'motionary/runtime/format-obj';
332
+ import { gltfAnim } from 'motionary/runtime/gltf-anim';
330
333
  import { defineGlScene } from 'motionary/components/widgets';
331
334
 
332
- use(gl, formatGltf, formatObj);
335
+ use(gl, formatGltf, formatObj, gltfAnim);
333
336
  defineGlScene(); // registers <usa-gl-scene> — after the prerequisites
334
337
  ```
335
338
 
@@ -340,6 +343,7 @@ defineGlScene(); // registers <usa-gl-scene> — after the prerequisites
340
343
  <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gl.iife.js"></script>
341
344
  <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-gltf.iife.js"></script>
342
345
  <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-obj.iife.js"></script>
346
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gltf-anim.iife.js"></script>
343
347
  <!-- then the component bundles -->
344
348
  <script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
345
349
  <script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
@@ -441,6 +445,40 @@ definePhysicsPlayground(); // registers <usa-physics-playground> — after the p
441
445
  <usa-physics-playground preset="pyramid" spawn label="Knock the pyramid over"></usa-physics-playground>
442
446
  ```
443
447
 
448
+ #### `<usa-snap-carousel>` — Requires: motionary/runtime/drag-snap
449
+
450
+ - **Install:** `npm i motionary`
451
+ - **Import order & registration:** Register the core first, then the module: use(dragSnap) also registers the core. CDN: load runtime.iife.js, then runtime/drag-snap.iife.js (it registers itself).
452
+
453
+ ```js
454
+ import { use } from 'motionary/runtime';
455
+ import { dragSnap } from 'motionary/runtime/drag-snap';
456
+ import { defineSnapCarousel } from 'motionary/components/snap-carousel';
457
+
458
+ use(dragSnap);
459
+ defineSnapCarousel(); // registers <usa-snap-carousel> — after the prerequisites
460
+ ```
461
+
462
+ - **CDN:**
463
+
464
+ ```html
465
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
466
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/drag-snap.iife.js"></script>
467
+ <!-- then the component bundles -->
468
+ <script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
469
+ <script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
470
+ ```
471
+
472
+ - **Minimal example:**
473
+
474
+ ```html
475
+ <usa-snap-carousel align="center" gap="16" label="Featured">
476
+ <article>…</article>
477
+ <article>…</article>
478
+ <article>…</article>
479
+ </usa-snap-carousel>
480
+ ```
481
+
444
482
  <!-- runtime:end -->
445
483
 
446
484
  ## Accessibility & reduced motion
@@ -474,6 +512,7 @@ Evergreen browsers since 2023: Chrome / Edge ≥ 111, Safari ≥ 16.4, Firefox
474
512
 
475
513
  ## Documentation
476
514
 
515
+ - **Individual entry points (10.8+):** new components ship as their own entry (`motionary/components/snap-carousel`) and are not added to `motionary/components/widgets` or the all-components `motionary/components/lite` bundle (its 70 KB gzip budget is fixed).
477
516
  - **MCP server:** `npx -y -p motionary motionary-mcp` — read-only component catalog for MCP clients (search, API, prerequisite-aware snippets; 2.0 adds `suggest_motion` and `validate_snippet`): [docs/mcp.md](docs/mcp.md).
478
517
  - **AI assistants:** [AGENTS.md](AGENTS.md) · [prompt guide](docs/ai-prompt-guide.md) · one page per component in [docs/components/](docs/components/README.md) · `components.json` / `llms.txt` / `llms-full.txt` on the site root.
479
518
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var tween = require('./tween-Dk0QmNe9.cjs');
3
+ var tween = require('./tween--MD-39y0.cjs');
4
4
 
5
5
  /**
6
6
  * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,
@@ -171,4 +171,4 @@ exports.composeFrames = composeFrames;
171
171
  exports.crc32 = crc32;
172
172
  exports.fixDelay = fixDelay;
173
173
  exports.u8 = u8;
174
- //# sourceMappingURL=anim-image-CFGpUX7t.cjs.map
174
+ //# sourceMappingURL=anim-image-BzTQa2k3.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"anim-image-CFGpUX7t.cjs","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":["Playable"],"mappings":";;;;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EAAU,MAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE;AAEpE;AACM,SAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAA6C,EAAA;IAC5H,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACxD,MAAM,GAAG,GAAgB,EAAE;AAC3B,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACrB,QAAA,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI;AAC/D,QAAA,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK;AAC7C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,YAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAClB,YAAA,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,MAAM;gBAAE;AAC5B,YAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,gBAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CA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AE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAA;IACpE,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;AAC1B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,GAAG,CAAC;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACxE,YAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAClB;IACF;IACA,IAAI,CAAC,GAAG,UAAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;;;;;;;"}
1
+ {"version":3,"file":"anim-image-BzTQa2k3.cjs","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":["Playable"],"mappings":";;;;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EAAU,MAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE;AAEpE;AACM,SAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAA6C,EAAA;IAC5H,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACxD,MAAM,GAAG,GAAgB,EAAE;AAC3B,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACrB,QAAA,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI;AAC/D,QAAA,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK;AAC7C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,YAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAClB,YAAA,IAAI,EAAE,GAAG,CAA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AC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC;AAEnK;AACA,IAAI,GAAG,GAAuB,IAAI;AAC5B,SAAU,KAAK,CAAC,KAAiB,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAA;IACpE,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;AAC1B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,GAAG,CAAC;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACxE,YAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAClB;IACF;IACA,IAAI,CAAC,GAAG,UAAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { P as Playable } from './tween-_Lld1MsF.js';
1
+ import { P as Playable } from './tween-DACdkLyO.js';
2
2
 
3
3
  /**
4
4
  * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,
@@ -163,4 +163,4 @@ function crc32(bytes, start = 0, end = bytes.length) {
163
163
  }
164
164
 
165
165
  export { animatedImagePlayer as a, browserDecode as b, composeFrames as c, bytesOf as d, crc32 as e, fixDelay as f, u8 as u };
166
- //# sourceMappingURL=anim-image-CXDD19FH.js.map
166
+ //# sourceMappingURL=anim-image-iD646Q7i.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"anim-image-CXDD19FH.js","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EAAU,MAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE;AAEpE;AACM,SAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAA6C,EAAA;IAC5H,MAAM,MAAM,GA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AAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;"}
1
+ {"version":3,"file":"anim-image-iD646Q7i.js","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EA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AAU,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACxE,YAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAClB;IACF;IACA,IAAI,CAAC,GAAG,UAAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;"}
@@ -1,4 +1,4 @@
1
- import { T as Timeline, a as Tween, p as parseValue } from './tween-_Lld1MsF.js';
1
+ import { T as Timeline, a as Tween, p as parseValue } from './tween-DACdkLyO.js';
2
2
  import { p as parseEase } from './ease-XN8_0sXu.js';
3
3
 
4
4
  /**
@@ -181,4 +181,4 @@ function framesToTimeline(target, frames, o = {}) {
181
181
  }
182
182
 
183
183
  export { camelProp as c, distributeOffsets as d, framesToTimeline as f };
184
- //# sourceMappingURL=keyframes-DwR6GPej.js.map
184
+ //# sourceMappingURL=keyframes-B4zefz0k.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyframes-DwR6GPej.js","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":[],"mappings":";;;AAAA;;;;AAIG;MAkBU,SAAS,GAAG,CAAC,CAAS,MAAc,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAE1I;AACM,SAAU,iBAAiB,CAAuC,MAAW,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAA+B;IACvE,IAAI,CAAC,GAAG,CAAC,MAAM;AAAE,QAAA,OAAO,GAAG;AAC3B,IAAA,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI;AAAE,QAAA,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;IACnE,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI;QAAE,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;IACtE,IAAI,CAAC,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AAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;AAAQ,gBAAA,MAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;IACjP;AACA,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;"}
1
+ {"version":3,"file":"keyframes-B4zefz0k.js","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return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2
2
 
3
- var tween = require('./tween-Dk0QmNe9.cjs');
3
+ var tween = require('./tween--MD-39y0.cjs');
4
4
  var ease = require('./ease-HwYZnZat.cjs');
5
5
 
6
6
  /**
@@ -185,4 +185,4 @@ function framesToTimeline(target, frames, o = {}) {
185
185
  exports.camelProp = camelProp;
186
186
  exports.distributeOffsets = distributeOffsets;
187
187
  exports.framesToTimeline = framesToTimeline;
188
- //# sourceMappingURL=keyframes-DdwGY1gr.cjs.map
188
+ //# sourceMappingURL=keyframes-BlOyB1PP.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyframes-DdwGY1gr.cjs","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":["parseValue","Timeline","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B1PP.cjs","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":["parseValue","Timeline","Tween","parseEase"],"mappings":";;;;;AAAA;;;;AAIG;MAkBU,SAAS,GAAG,CAAC,CAAS,MAAc,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAE1I;AACM,SAAU,iBAAiB,CAAuC,MAAW,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG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,CAAC,IAAIC,WAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAGC,cAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACnI,QAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ;YAAE,EAAE,CAAC,IAAI,CAAC,MAAK,EAAG,IAAK,MAAc,CAAC,KAAK;AAAG,gBAAA,MAAsB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;AAAQ,gBAAA,MAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;IACjP;AACA,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;;;"}
@@ -9,7 +9,7 @@
9
9
  * inside Web Workers.
10
10
  */
11
11
  /** Runtime version (kept in sync with the package version by the release script). */
12
- const RUNTIME_VERSION = '10.7.0';
12
+ const RUNTIME_VERSION = '10.8.0';
13
13
  /** Where the CDN builds live (major-pinned). */
14
14
  const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';
15
15
  const KEY = Symbol.for('motionary.runtime');
@@ -78,4 +78,4 @@ exports.register = register;
78
78
  exports.registeredModules = registeredModules;
79
79
  exports.registry = registry;
80
80
  exports.requireModule = requireModule;
81
- //# sourceMappingURL=registry-DhKZCitb.cjs.map
81
+ //# sourceMappingURL=registry-BZxDVL3h.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-DhKZCitb.cjs","sources":["../../src/runtime/registry.ts"],"sourcesContent":["/**\n * Module registry shared by every copy of `motionary/runtime` on the page\n * (ESM, CJS and the CDN IIFE builds all read the same `globalThis` slot),\n * so a component never needs to import the runtime itself — it asks for a\n * module with `requireModule()` and gets a clear error when it is missing.\n * Nothing here touches `window` / `document`: safe to import during SSR and\n * inside Web Workers.\n */\n\n/** Runtime version (kept in sync with the package version by the release script). */\nexport const RUNTIME_VERSION = '10.7.0';\n\n/** Where the CDN builds live (major-pinned). */\nexport const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';\n\n/** A runtime module: `{ id, version, api }`, registered with `use()`. */\nexport interface RuntimeModule<A = unknown> {\n /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */\n id: string;\n version: string;\n /** Other modules this one needs (registered first by `use()` callers). */\n requires?: string[];\n /** The module's public API (what `requireModule(id)` returns). */\n api: A;\n /** Optional one-time setup, called on first registration. */\n setup?(registry: RuntimeRegistry): void;\n}\n\nexport interface RuntimeRegistry {\n version: string;\n modules: Map<string, RuntimeModule>;\n /** Shared per-page state slots (the ticker lives here). */\n slots: Record<string, unknown>;\n}\n\nconst KEY = Symbol.for('motionary.runtime');\n\n/** The page-wide registry (created on first use). */\nexport function registry(): RuntimeRegistry {\n const g = globalThis as unknown as Record<symbol, RuntimeRegistry | undefined>;\n return (g[KEY] ||= { version: RUNTIME_VERSION, modules: new Map(), slots: {} });\n}\n\n/** The import path of a module id. */\nexport const modulePath = (id: string): string => (id === 'core' ? 'motionary/runtime' : `motionary/runtime/${id}`);\n\n/** The CDN IIFE file of a module id. */\nexport const moduleCdn = (id: string): string => RUNTIME_CDN + (id === 'core' ? 'runtime.iife.js' : `runtime/${id}.iife.js`);\n\n/** The text of the \"module missing\" error (shared with the components). */\nexport function missingMessage(id: string, who = 'This feature'): string {\n const path = modulePath(id);\n const reg = id === 'core' ? `import { use } from 'motionary/runtime'; use();` : `import { use } from 'motionary/runtime'; import { ${camel(id)} } from '${path}'; use(${camel(id)});`;\n const cdn = id === 'core' ? `<script src=\"${moduleCdn('core')}\"></script>` : `<script src=\"${moduleCdn('core')}\"></script><script src=\"${moduleCdn(id)}\"></script>`;\n return `[motionary] ${who} requires ${path}. Install once: npm i motionary — then register it before the component mounts: ${reg} Or from a CDN (core first): ${cdn} Docs: https://github.com/HarrisonCN/Motionary/blob/main/docs/runtime/${id}.md`;\n}\n\n/** 'format-css' → 'formatCss' (the module object's export name). */\nexport const camel = (id: string): string => id.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n\n/** Thrown by `requireModule()` when a module is not registered. */\nexport class RuntimeModuleError extends Error {\n readonly module: string;\n constructor(id: string, who?: string) {\n super(missingMessage(id, who));\n this.name = 'RuntimeModuleError';\n this.module = id;\n }\n}\n\n/** Register modules (each once; re-registering the same id keeps the first). Returns the registry. */\nexport function register(...mods: RuntimeModule[]): RuntimeRegistry {\n const r = registry();\n for (const m of mods) {\n if (!m || typeof m.id !== 'string') throw new TypeError('[motionary] use(): not a runtime module — pass the object exported by motionary/runtime/<module>');\n if (r.modules.has(m.id)) continue;\n for (const dep of m.requires || []) if (!r.modules.has(dep)) throw new RuntimeModuleError(dep, `motionary/runtime/${m.id}`);\n r.modules.set(m.id, m as RuntimeModule);\n m.setup?.(r);\n }\n return r;\n}\n\n/** Is a module registered? */\nexport const hasModule = (id: string): boolean => registry().modules.has(id);\n\n/** The API of a registered module, or a `RuntimeModuleError` with install / import / CDN instructions. */\nexport function requireModule<A = unknown>(id: string, who?: string): A {\n const m = registry().modules.get(id);\n if (!m) throw new RuntimeModuleError(id, who);\n return m.api as A;\n}\n\n/** Ids of the registered modules. */\nexport const registeredModules = (): string[] => Array.from(registry().modules.keys());\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACO,MAAM,eAAe,GAAG;AAE/B;AACO,MAAM,WA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C,OAAO,CAAC,GAAG,CAAC,EAAE;AAE3E;AACM,SAAU,aAAa,CAAc,EAAU,EAAE,GAAY,EAAA;IACjE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACpC,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAQ;AACnB;AAEA;AACO,MAAM,iBAAiB,GAAG,MAAgB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;;;;;;;;;;;;"}
1
+ {"version":3,"file":"registry-BZxDVL3h.cjs","sources":["../../src/runtime/registry.ts"],"sourcesContent":["/**\n * Module registry shared by every copy of `motionary/runtime` on the page\n * (ESM, CJS and the CDN IIFE builds all read the same `globalThis` slot),\n * so a component never needs to import the runtime itself — it asks for a\n * module with `requireModule()` and gets a clear error when it is missing.\n * Nothing here touches `window` / `document`: safe to import during SSR and\n * inside Web Workers.\n */\n\n/** Runtime version (kept in sync with the package version by the release script). */\nexport const RUNTIME_VERSION = '10.8.0';\n\n/** Where the CDN builds live (major-pinned). */\nexport const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';\n\n/** A runtime module: `{ id, version, api }`, registered with `use()`. */\nexport interface RuntimeModule<A = unknown> {\n /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */\n id: string;\n version: string;\n /** Other modules this one needs (registered first by `use()` callers). */\n requires?: string[];\n /** The module's public API (what `requireModule(id)` returns). */\n api: A;\n /** Optional one-time setup, called on first registration. */\n setup?(registry: RuntimeRegistry): void;\n}\n\nexport interface RuntimeRegistry {\n version: string;\n modules: Map<string, RuntimeModule>;\n /** Shared per-page state slots (the ticker lives here). */\n slots: Record<string, unknown>;\n}\n\nconst KEY = Symbol.for('motionary.runtime');\n\n/** The page-wide registry (created on first use). */\nexport function registry(): RuntimeRegistry {\n const g = globalThis as unknown as Record<symbol, RuntimeRegistry | undefined>;\n return (g[KEY] ||= { version: RUNTIME_VERSION, modules: new Map(), slots: {} });\n}\n\n/** The import path of a module id. */\nexport const modulePath = (id: string): string => (id === 'core' ? 'motionary/runtime' : `motionary/runtime/${id}`);\n\n/** The CDN IIFE file of a module id. */\nexport const moduleCdn = (id: string): string => RUNTIME_CDN + (id === 'core' ? 'runtime.iife.js' : `runtime/${id}.iife.js`);\n\n/** The text of the \"module missing\" error (shared with the components). */\nexport function missingMessage(id: string, who = 'This feature'): string {\n const path = modulePath(id);\n const reg = id === 'core' ? `import { use } from 'motionary/runtime'; use();` : `import { use } from 'motionary/runtime'; import { ${camel(id)} } from '${path}'; use(${camel(id)});`;\n const cdn = id === 'core' ? `<script src=\"${moduleCdn('core')}\"></script>` : `<script src=\"${moduleCdn('core')}\"></script><script src=\"${moduleCdn(id)}\"></script>`;\n return `[motionary] ${who} requires ${path}. Install once: npm i motionary — then register it before the component mounts: ${reg} Or from a CDN (core first): ${cdn} Docs: https://github.com/HarrisonCN/Motionary/blob/main/docs/runtime/${id}.md`;\n}\n\n/** 'format-css' → 'formatCss' (the module object's export name). */\nexport const camel = (id: string): string => id.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n\n/** Thrown by `requireModule()` when a module is not registered. */\nexport class RuntimeModuleError extends Error {\n readonly module: string;\n constructor(id: string, who?: string) {\n super(missingMessage(id, who));\n this.name = 'RuntimeModuleError';\n this.module = id;\n }\n}\n\n/** Register modules (each once; re-registering the same id keeps the first). Returns the registry. */\nexport function register(...mods: RuntimeModule[]): RuntimeRegistry {\n const r = registry();\n for (const m of mods) {\n if (!m || typeof m.id !== 'string') throw new TypeError('[motionary] use(): not a runtime module — pass the object exported by motionary/runtime/<module>');\n if (r.modules.has(m.id)) continue;\n for (const dep of m.requires || []) if (!r.modules.has(dep)) throw new RuntimeModuleError(dep, `motionary/runtime/${m.id}`);\n r.modules.set(m.id, m as RuntimeModule);\n m.setup?.(r);\n }\n return r;\n}\n\n/** Is a module registered? */\nexport const hasModule = (id: string): boolean => registry().modules.has(id);\n\n/** The API of a registered module, or a `RuntimeModuleError` with install / import / CDN instructions. */\nexport function requireModule<A = unknown>(id: string, who?: string): A {\n const m = registry().modules.get(id);\n if (!m) throw new RuntimeModuleError(id, who);\n return m.api as A;\n}\n\n/** Ids of the registered modules. */\nexport const registeredModules = (): string[] => Array.from(registry().modules.keys());\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACO,MAAM,eAAe,GAAG;AAE/B;AACO,MAAM,WAAW,GAAG;AAsB3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAE3C;SACgB,QAAQ,GAAA;IACtB,MAAM,CAAC,GAAG,UAAoE;IAC9E,QAAQ,CAAC,CAAC,GAAG,CAAA,KAAL,CAAC,CAAC,GAAG,CAAA,GAAM,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAChF;AAEA;AACO,MAAM,UAAU,GAAG,CAAC,EAAU,MAAc,EAAE,KAAK,MAAM,GAAG,mBAAmB,GAAG,CAAA,kBAAA,EAAqB,EAAE,CAAA,CAAE;AAElH;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAa,WAAW,IAAI,EAAE,KAAK,MAAM,GAAG,iBAAiB,GAAG,CAAA,QAAA,EAAW,EAAE,CAAA,QAAA,CAAU;AAE3H;SACgB,cAAc,CAAC,EAAU,EAAE,GAAG,GAAG,cAAc,EAAA;AAC7D,IAAA,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,EAAE,KAAK,MAAM,GAAG,CAAA,+CAAA,CAAiD,GAAG,qDAAqD,KAAK,CAAC,EAAE,CAAC,CAAA,SAAA,EAAY,IAAI,CAAA,OAAA,EAAU,KAAK,CAAC,E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AC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,MAAM,IAAI,kBAAkB,CAAC,GAAG,EAAE,CAAA,kBAAA,EAAqB,CAAC,CAAC,EAAE,CAAA,CAAE,CAAC;QAC3H,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAkB,CAAC;AACvC,QAAA,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IACd;AACA,IAAA,OAAO,CAAC;AACV;AAEA;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAc,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAE3E;AACM,SAAU,aAAa,CAAc,EAAU,EAAE,GAAY,EAAA;IACjE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACpC,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAQ;AACnB;AAEA;AACO,MAAM,iBAAiB,GAAG,MAAgB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;;;;;;;;;;;;"}
@@ -7,7 +7,7 @@
7
7
  * inside Web Workers.
8
8
  */
9
9
  /** Runtime version (kept in sync with the package version by the release script). */
10
- const RUNTIME_VERSION = '10.7.0';
10
+ const RUNTIME_VERSION = '10.8.0';
11
11
  /** Where the CDN builds live (major-pinned). */
12
12
  const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';
13
13
  const KEY = Symbol.for('motionary.runtime');
@@ -65,5 +65,5 @@ function requireModule(id, who) {
65
65
  /** Ids of the registered modules. */
66
66
  const registeredModules = () => Array.from(registry().modules.keys());
67
67
 
68
- export { RUNTIME_VERSION as R, requireModule as a, register as b, RUNTIME_CDN as c, RuntimeModuleError as d, moduleCdn as e, modulePath as f, registeredModules as g, hasModule as h, missingMessage as m, registry as r };
69
- //# sourceMappingURL=registry-D87dP_aR.js.map
68
+ export { RUNTIME_VERSION as R, registry as a, register as b, RUNTIME_CDN as c, RuntimeModuleError as d, moduleCdn as e, modulePath as f, registeredModules as g, hasModule as h, missingMessage as m, requireModule as r };
69
+ //# sourceMappingURL=registry-Bkt3-3ET.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-D87dP_aR.js","sources":["../../src/runtime/registry.ts"],"sourcesContent":["/**\n * Module registry shared by every copy of `motionary/runtime` on the page\n * (ESM, CJS and the CDN IIFE builds all read the same `globalThis` slot),\n * so a component never needs to import the runtime itself — it asks for a\n * module with `requireModule()` and gets a clear error when it is missing.\n * Nothing here touches `window` / `document`: safe to import during SSR and\n * inside Web Workers.\n */\n\n/** Runtime version (kept in sync with the package version by the release script). */\nexport const RUNTIME_VERSION = '10.7.0';\n\n/** Where the CDN builds live (major-pinned). */\nexport const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';\n\n/** A runtime module: `{ id, version, api }`, registered with `use()`. */\nexport interface RuntimeModule<A = unknown> {\n /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */\n id: string;\n version: string;\n /** Other modules this one needs (registered first by `use()` callers). */\n requires?: string[];\n /** The module's public API (what `requireModule(id)` returns). */\n api: A;\n /** Optional one-time setup, called on first registration. */\n setup?(registry: RuntimeRegistry): void;\n}\n\nexport interface RuntimeRegistry {\n version: string;\n modules: Map<string, RuntimeModule>;\n /** Shared per-page state slots (the ticker lives here). */\n slots: Record<string, unknown>;\n}\n\nconst KEY = Symbol.for('motionary.runtime');\n\n/** The page-wide registry (created on first use). */\nexport function registry(): RuntimeRegistry {\n const g = globalThis as unknown as Record<symbol, RuntimeRegistry | undefined>;\n return (g[KEY] ||= { version: RUNTIME_VERSION, modules: new Map(), slots: {} });\n}\n\n/** The import path of a module id. */\nexport const modulePath = (id: string): string => (id === 'core' ? 'motionary/runtime' : `motionary/runtime/${id}`);\n\n/** The CDN IIFE file of a module id. */\nexport const moduleCdn = (id: string): string => RUNTIME_CDN + (id === 'core' ? 'runtime.iife.js' : `runtime/${id}.iife.js`);\n\n/** The text of the \"module missing\" error (shared with the components). */\nexport function missingMessage(id: string, who = 'This feature'): string {\n const path = modulePath(id);\n const reg = id === 'core' ? `import { use } from 'motionary/runtime'; use();` : `import { use } from 'motionary/runtime'; import { ${camel(id)} } from '${path}'; use(${camel(id)});`;\n const cdn = id === 'core' ? `<script src=\"${moduleCdn('core')}\"></script>` : `<script src=\"${moduleCdn('core')}\"></script><script src=\"${moduleCdn(id)}\"></script>`;\n return `[motionary] ${who} requires ${path}. Install once: npm i motionary — then register it before the component mounts: ${reg} Or from a CDN (core first): ${cdn} Docs: https://github.com/HarrisonCN/Motionary/blob/main/docs/runtime/${id}.md`;\n}\n\n/** 'format-css' → 'formatCss' (the module object's export name). */\nexport const camel = (id: string): string => id.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n\n/** Thrown by `requireModule()` when a module is not registered. */\nexport class RuntimeModuleError extends Error {\n readonly module: string;\n constructor(id: string, who?: string) {\n super(missingMessage(id, who));\n this.name = 'RuntimeModuleError';\n this.module = id;\n }\n}\n\n/** Register modules (each once; re-registering the same id keeps the first). Returns the registry. */\nexport function register(...mods: RuntimeModule[]): RuntimeRegistry {\n const r = registry();\n for (const m of mods) {\n if (!m || typeof m.id !== 'string') throw new TypeError('[motionary] use(): not a runtime module — pass the object exported by motionary/runtime/<module>');\n if (r.modules.has(m.id)) continue;\n for (const dep of m.requires || []) if (!r.modules.has(dep)) throw new RuntimeModuleError(dep, `motionary/runtime/${m.id}`);\n r.modules.set(m.id, m as RuntimeModule);\n m.setup?.(r);\n }\n return r;\n}\n\n/** Is a module registered? */\nexport const hasModule = (id: string): boolean => registry().modules.has(id);\n\n/** The API of a registered module, or a `RuntimeModuleError` with install / import / CDN instructions. */\nexport function requireModule<A = unknown>(id: string, who?: string): A {\n const m = registry().modules.get(id);\n if (!m) throw new RuntimeModuleError(id, who);\n return m.api as A;\n}\n\n/** Ids of the registered modules. */\nexport const registeredModules = (): string[] => Array.from(registry().modules.keys());\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACO,MAAM,eAAe,GAAG;AAE/B;AACO,MAAM,WAAW,GAAG;AAsB3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAE3C;SACgB,QAAQ,GAAA;IACtB,MAAM,CAAC,GAAG,UAAoE;IAC9E,QAAQ,CAAC,CAAC,GAAG,CAAA,KAAL,CAAC,CAAC,GAAG,CAAA,GAAM,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAChF;AAEA;AACO,MAAM,UAAU,GAAG,CAAC,EAAU,MAAc,EAAE,KAAK,MAAM,GAAG,mBAAmB,GAAG,CAAA,kBAAA,EAAqB,EAAE,CAAA,CAAE;AAElH;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAa,WAAW,IAAI,EAAE,KAAK,MAAM,GAAG,iBAAiB,GAAG,CAAA,QAAA,EAAW,EAAE,CAAA,QAAA,CAAU;AAE3H;SACgB,cAAc,CAAC,EAAU,EAAE,GAAG,GAAG,cAAc,EAAA;AAC7D,IAAA,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,EAAE,KAAK,MAAM,GAAG,CAAA,+CAAA,CAAiD,GAAG,qDAAqD,KAAK,CAAC,EAAE,CAAC,CAAA,SAAA,EAAY,IAAI,CAAA,OAAA,EAAU,KAAK,CAAC,EAAE,CAAC,CAAA,EAAA,CAAI;AACrL,IAAA,MAAM,GAAG,GAAG,EAAE,KAAK,MAAM,GAAG,CAAA,aAAA,EAAgB,SAAS,CAAC,MAAM,CAAC,CAAA,WAAA,CAAa,GAAG,CAAA,aAAA,EAAgB,SA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,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAkB,CAAC;AACvC,QAAA,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IACd;AACA,IAAA,OAAO,CAAC;AACV;AAEA;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAc,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAE3E;AACM,SAAU,aAAa,CAAc,EAAU,EAAE,GAAY,EAAA;IACjE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACpC,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAQ;AACnB;AAEA;AACO,MAAM,iBAAiB,GAAG,MAAgB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;;"}
1
+ {"version":3,"file":"registry-Bkt3-3ET.js","sources":["../../src/runtime/registry.ts"],"sourcesContent":["/**\n * Module registry shared by every copy of `motionary/runtime` on the page\n * (ESM, CJS and the CDN IIFE builds all read the same `globalThis` slot),\n * so a component never needs to import the runtime itself — it asks for a\n * module with `requireModule()` and gets a clear error when it is missing.\n * Nothing here touches `window` / `document`: safe to import during SSR and\n * inside Web Workers.\n */\n\n/** Runtime version (kept in sync with the package version by the release script). */\nexport const RUNTIME_VERSION = '10.8.0';\n\n/** Where the CDN builds live (major-pinned). */\nexport const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';\n\n/** A runtime module: `{ id, version, api }`, registered with `use()`. */\nexport interface RuntimeModule<A = unknown> {\n /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */\n id: string;\n version: string;\n /** Other modules this one needs (registered first by `use()` callers). */\n requires?: string[];\n /** The module's public API (what `requireModule(id)` returns). */\n api: A;\n /** Optional one-time setup, called on first registration. */\n setup?(registry: RuntimeRegistry): void;\n}\n\nexport interface RuntimeRegistry {\n version: string;\n modules: Map<string, RuntimeModule>;\n /** Shared per-page state slots (the ticker lives here). */\n slots: Record<string, unknown>;\n}\n\nconst KEY = Symbol.for('motionary.runtime');\n\n/** The page-wide registry (created on first use). */\nexport function registry(): RuntimeRegistry {\n const g = globalThis as unknown as Record<symbol, RuntimeRegistry | undefined>;\n return (g[KEY] ||= { version: RUNTIME_VERSION, modules: new Map(), slots: {} });\n}\n\n/** The import path of a module id. */\nexport const modulePath = (id: string): string => (id === 'core' ? 'motionary/runtime' : `motionary/runtime/${id}`);\n\n/** The CDN IIFE file of a module id. */\nexport const moduleCdn = (id: string): string => RUNTIME_CDN + (id === 'core' ? 'runtime.iife.js' : `runtime/${id}.iife.js`);\n\n/** The text of the \"module missing\" error (shared with the components). */\nexport function missingMessage(id: string, who = 'This feature'): string {\n const path = modulePath(id);\n const reg = id === 'core' ? `import { use } from 'motionary/runtime'; use();` : `import { use } from 'motionary/runtime'; import { ${camel(id)} } from '${path}'; use(${camel(id)});`;\n const cdn = id === 'core' ? `<script src=\"${moduleCdn('core')}\"></script>` : `<script src=\"${moduleCdn('core')}\"></script><script src=\"${moduleCdn(id)}\"></script>`;\n return `[motionary] ${who} requires ${path}. Install once: npm i motionary — then register it before the component mounts: ${reg} Or from a CDN (core first): ${cdn} Docs: https://github.com/HarrisonCN/Motionary/blob/main/docs/runtime/${id}.md`;\n}\n\n/** 'format-css' → 'formatCss' (the module object's export name). */\nexport const camel = (id: string): string => id.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n\n/** Thrown by `requireModule()` when a module is not registered. */\nexport class RuntimeModuleError extends Error {\n readonly module: string;\n constructor(id: string, who?: string) {\n super(missingMessage(id, who));\n this.name = 'RuntimeModuleError';\n this.module = id;\n }\n}\n\n/** Register modules (each once; re-registering the same id keeps the first). Returns the registry. */\nexport function register(...mods: RuntimeModule[]): RuntimeRegistry {\n const r = registry();\n for (const m of mods) {\n if (!m || typeof m.id !== 'string') throw new TypeError('[motionary] use(): not a runtime module — pass the object exported by motionary/runtime/<module>');\n if (r.modules.has(m.id)) continue;\n for (const dep of m.requires || []) if (!r.modules.has(dep)) throw new RuntimeModuleError(dep, `motionary/runtime/${m.id}`);\n r.modules.set(m.id, m as RuntimeModule);\n m.setup?.(r);\n }\n return r;\n}\n\n/** Is a module registered? */\nexport const hasModule = (id: string): boolean => registry().modules.has(id);\n\n/** The API of a registered module, or a `RuntimeModuleError` with install / import / CDN instructions. */\nexport function requireModule<A = unknown>(id: string, who?: string): A {\n const m = registry().modules.get(id);\n if (!m) throw new RuntimeModuleError(id, who);\n return m.api as A;\n}\n\n/** Ids of the registered modules. */\nexport const registeredModules = (): string[] => Array.from(registry().modules.keys());\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACO,MAAM,eAAe,GAAG;AAE/B;AACO,MAAM,WAAW,GAAG;AAsB3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAE3C;SACgB,QAAQ,GAAA;IACtB,MAAM,CAAC,GAAG,UAAoE;IAC9E,QAAQ,CAAC,CAAC,GAAG,CAAA,KAAL,CAAC,CAAC,GAAG,CAAA,GAAM,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAChF;AAEA;AACO,MAAM,UAAU,GAAG,CAAC,EAAU,MAAc,EAAE,KAAK,MAAM,GAAG,mBAAmB,GAAG,CAAA,kBAAA,EAAqB,EAAE,CAAA,CAAE;AAElH;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAa,WAAW,IAAI,EAAE,KAAK,MAAM,GAAG,iBAAiB,GAAG,CAAA,QAAA,EAAW,EAAE,CAAA,QAAA,CAAU;AAE3H;SACgB,cAAc,CAAC,EAAU,EAAE,GAAG,GAAG,cAAc,EAAA;AAC7D,IAAA,MAAM,IAAI,G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