motionary 10.2.0 → 10.3.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 (72) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +32 -0
  3. package/dist/chunks/{keyframes-W-474DMc.js → keyframes-DVAC5sQI.js} +2 -2
  4. package/dist/chunks/{keyframes-W-474DMc.js.map → keyframes-DVAC5sQI.js.map} +1 -1
  5. package/dist/chunks/{keyframes-ZheOkpt0.cjs → keyframes-Dw9zwVQa.cjs} +2 -2
  6. package/dist/chunks/{keyframes-ZheOkpt0.cjs.map → keyframes-Dw9zwVQa.cjs.map} +1 -1
  7. package/dist/chunks/{registry-BIEjKngP.js → registry-46AAzyeC.js} +2 -2
  8. package/dist/chunks/{registry-BIEjKngP.js.map → registry-46AAzyeC.js.map} +1 -1
  9. package/dist/chunks/{registry-eJgpFAzI.cjs → registry-CSVil2qJ.cjs} +2 -2
  10. package/dist/chunks/{registry-eJgpFAzI.cjs.map → registry-CSVil2qJ.cjs.map} +1 -1
  11. package/dist/chunks/{ticker-CM_56oVy.js → ticker-COOYAyQy.js} +2 -2
  12. package/dist/chunks/{ticker-CM_56oVy.js.map → ticker-COOYAyQy.js.map} +1 -1
  13. package/dist/chunks/{ticker-D4o6enH0.cjs → ticker-gHv6pNfx.cjs} +2 -2
  14. package/dist/chunks/{ticker-D4o6enH0.cjs.map → ticker-gHv6pNfx.cjs.map} +1 -1
  15. package/dist/chunks/{tween-CBuWYpI-.cjs → tween-CFN0WcOb.cjs} +13 -3
  16. package/dist/chunks/tween-CFN0WcOb.cjs.map +1 -0
  17. package/dist/chunks/{tween-CqX1JBuj.js → tween-CGyolmzB.js} +13 -3
  18. package/dist/chunks/tween-CGyolmzB.js.map +1 -0
  19. package/dist/components/widgets.cjs +403 -202
  20. package/dist/components/widgets.cjs.map +1 -1
  21. package/dist/components/widgets.d.cts +42 -2
  22. package/dist/components/widgets.d.ts +42 -2
  23. package/dist/components/widgets.js +402 -203
  24. package/dist/components/widgets.js.map +1 -1
  25. package/dist/llms-full.txt +97 -1
  26. package/dist/llms.txt +6 -2
  27. package/dist/manifest.json +234 -1
  28. package/dist/runtime/format-css.cjs +4 -4
  29. package/dist/runtime/format-css.js +4 -4
  30. package/dist/runtime/format-motion.cjs +4 -4
  31. package/dist/runtime/format-motion.js +4 -4
  32. package/dist/runtime/format-sprite.cjs +225 -0
  33. package/dist/runtime/format-sprite.cjs.map +1 -0
  34. package/dist/runtime/format-sprite.d.cts +224 -0
  35. package/dist/runtime/format-sprite.d.ts +224 -0
  36. package/dist/runtime/format-sprite.iife.js +2 -0
  37. package/dist/runtime/format-sprite.iife.js.map +1 -0
  38. package/dist/runtime/format-sprite.js +215 -0
  39. package/dist/runtime/format-sprite.js.map +1 -0
  40. package/dist/runtime/format-svg.cjs +3 -3
  41. package/dist/runtime/format-svg.cjs.map +1 -1
  42. package/dist/runtime/format-svg.iife.js.map +1 -1
  43. package/dist/runtime/format-svg.js +3 -3
  44. package/dist/runtime/format-svg.js.map +1 -1
  45. package/dist/runtime/scroll.cjs +2 -2
  46. package/dist/runtime/scroll.js +2 -2
  47. package/dist/runtime/text.cjs +147 -0
  48. package/dist/runtime/text.cjs.map +1 -0
  49. package/dist/runtime/text.d.cts +65 -0
  50. package/dist/runtime/text.d.ts +65 -0
  51. package/dist/runtime/text.iife.js +2 -0
  52. package/dist/runtime/text.iife.js.map +1 -0
  53. package/dist/runtime/text.js +143 -0
  54. package/dist/runtime/text.js.map +1 -0
  55. package/dist/runtime.cjs +3 -3
  56. package/dist/runtime.d.cts +9 -2
  57. package/dist/runtime.d.ts +9 -2
  58. package/dist/runtime.iife.js +1 -1
  59. package/dist/runtime.iife.js.map +1 -1
  60. package/dist/runtime.js +5 -5
  61. package/dist/widgets.umd.js +1 -1
  62. package/dist/widgets.umd.js.map +1 -1
  63. package/docs/ROADMAP.md +1 -1
  64. package/docs/components/README.md +3 -1
  65. package/docs/components/usa-route-transition.md +38 -0
  66. package/docs/components/usa-text-splitter.md +60 -0
  67. package/docs/components.md +45 -0
  68. package/docs/runtime/format-sprite.md +60 -0
  69. package/docs/runtime/text.md +59 -0
  70. package/package.json +21 -1
  71. package/dist/chunks/tween-CBuWYpI-.cjs.map +0 -1
  72. package/dist/chunks/tween-CqX1JBuj.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [10.3.0] - 2026-10-09
11
+
12
+ ### Added
13
+ - **View Transitions 2.0** — `<usa-route-transition>`: a route container that swaps its content on same-origin link clicks (fetched pages, using the element that matches `selector` / its id) or inline `<template data-route>` routes; animated with the View Transitions API when available (`engine="auto"`) or the Web Animations fallback (`engine="waapi"`, effects `fade` / `slide` / `zoom`); `data-shared="name"` elements morph between routes (`view-transition-name`); `cross-document` opts the site into native cross-document (MPA) view transitions (`@view-transition { navigation: auto }`); history push / replace / off with `popstate`; `navigate(url)`, `current`; `usa:navigate` (cancelable), `usa:navigated`.
14
+ - **`motionary/runtime/text`** — `splitText(el, { type: 'chars,words,lines' })`: grapheme-aware characters (`Intl.Segmenter`: emoji, combining marks, CJK), words, lines grouped by rendered position; nested inline markup kept; accessible (`aria-label` with the full text, pieces `aria-hidden`); `--i` index custom property; `revert()` / `resplit()`; pure `segment()` for SSR / workers. CDN `dist/runtime/text.iife.js`; fixed gzip budget.
15
+ - **`motionary/runtime/format-sprite`** — sprite sheets and image sequences: `parseSpriteSheet()` (TexturePacker JSON hash + array with trimmed / rotated frames; Aseprite JSON hash + array with per-frame `duration` and `frameTags` forward / reverse / pingpong / pingpong_reverse), `gridSheet()`, `frameOrder()`, `drawFrame()`, `spritePlayer()` (canvas or element background), `imageSequence('frame_{0001}.webp', …)`, `preloadImages()`, `sequencePlayer()` (cover-fit, scrub with `progress`). All players are runtime timelines (seek, reverse, scroll-scrub). Test fixtures in the real export formats; `test/fixtures/formats/CREDITS.md` lists sample licences.
16
+ - **Runtime tween**: numbers inside any CSS string are interpolated when both ends share the same text (`filter: blur(8px) saturate(0%)`, `box-shadow`, `clip-path`, `matrix(…)`), and values that cannot be interpolated (keywords such as `display`) switch at 50 % like CSS — previously they threw.
17
+ - **New components (10.3)** in `motionary/components/widgets`: `<usa-route-transition>` and `<usa-text-splitter>` — splits into chars / words / lines and staggers them in (`rise`, `fade`, `blur`, `flip`, `wave`) on view, load or hover, optional `loop` (**Requires: motionary/runtime/text**). The 4.x `<usa-split-text>` keeps its name and API; the runtime-powered element is a new tag.
18
+ - Showcase: new gallery cards with copyable code, live demos and live Store thumbnails.
19
+
20
+ ### Accessibility
21
+ - `<usa-text-splitter>` keeps the full sentence as the element's accessible name and hides the animated pieces from screen readers; under reduced motion the text is shown at once. `<usa-route-transition>` swaps instantly under reduced motion and keeps native link semantics (modifier-clicks, `target`, downloads and cross-origin links are left alone).
22
+
23
+ ### Fixed
24
+ - `<usa-route-transition>` (Web Animations fallback) no longer hangs when the exit animation's `finished` promise never settles (background tabs, DOMs without animation timing): the swap waits at most the exit duration.
25
+ - `format-svg`: value interpolation narrows the runtime's new string values correctly (TypeScript build error after the 10.3 tween change; behaviour unchanged).
26
+
10
27
  ## [10.2.0] - 2026-10-09
11
28
 
12
29
  ### Added
@@ -21,6 +38,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
38
  ### Accessibility
22
39
  - `<usa-scroll-scene>` is user-driven (it only moves when the reader scrolls); under reduced motion the scrub is linear and the preview loop does not run. `<usa-motion-inspector>` controls are a labelled `toolbar`, rows have labelled scrub sliders, and its slow-motion switch helps people check motion for vestibular safety.
23
40
 
41
+ ### Fixed
42
+ - Runtime timeline: a timeline holding an infinitely repeating child no longer seeks to `NaN` (`0 × Infinity`) — infinite-duration timelines seek on the raw time.
43
+ - `format-svg`: SMIL `<set>` without `dur` is applied and holds its value (duration 0, freeze) instead of being dropped with a `NaN` duration.
44
+ - Tests: the 10.1 manifest test no longer pins the exact runtime module list, so releases that add modules keep it green.
45
+
24
46
  ## [10.1.0] - 2026-10-09
25
47
 
26
48
  ### Added
package/README.md CHANGED
@@ -178,6 +178,8 @@ Motionary ships its own zero-dependency animation runtime — shared ticker, twe
178
178
  | [Motion / Framer keyframe JSON loader](docs/runtime/format-motion.md) | `motionary/runtime/format-motion` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-motion.iife.js` | `use(formatMotion);` | 2.5 KB |
179
179
  | [Scroll scenes](docs/runtime/scroll.md) | `motionary/runtime/scroll` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/scroll.iife.js` | `use(scroll);` | 4.5 KB |
180
180
  | [SVG loader: SMIL playback + path morphing](docs/runtime/format-svg.md) | `motionary/runtime/format-svg` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-svg.iife.js` | `use(formatSvg);` | 5.0 KB |
181
+ | [Text splitting](docs/runtime/text.md) | `motionary/runtime/text` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/text.iife.js` | `use(text);` | 2.5 KB |
182
+ | [Sprite sheets & image sequences](docs/runtime/format-sprite.md) | `motionary/runtime/format-sprite` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-sprite.iife.js` | `use(formatSprite);` | 3.0 KB |
181
183
 
182
184
  Install once: `npm i motionary`. Plain HTML: load `runtime.iife.js` first, then the module files (each registers itself).
183
185
 
@@ -244,6 +246,36 @@ defineScrollScene(); // registers <usa-scroll-scene> — after the prerequisites
244
246
  </usa-scroll-scene>
245
247
  ```
246
248
 
249
+ #### `<usa-text-splitter>` — Requires: motionary/runtime/text
250
+
251
+ - **Install:** `npm i motionary`
252
+ - **Import order & registration:** Register the core first, then the module: use(text) also registers the core. CDN: load runtime.iife.js, then runtime/text.iife.js (it registers itself).
253
+
254
+ ```js
255
+ import { use } from 'motionary/runtime';
256
+ import { text } from 'motionary/runtime/text';
257
+ import { defineTextSplitter } from 'motionary/components/widgets';
258
+
259
+ use(text);
260
+ defineTextSplitter(); // registers <usa-text-splitter> — after the prerequisites
261
+ ```
262
+
263
+ - **CDN:**
264
+
265
+ ```html
266
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
267
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/text.iife.js"></script>
268
+ <!-- then the component bundles -->
269
+ <script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
270
+ <script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
271
+ ```
272
+
273
+ - **Minimal example:**
274
+
275
+ ```html
276
+ <usa-text-splitter split="chars" effect="rise" stagger="30">Motion, made simple.</usa-text-splitter>
277
+ ```
278
+
247
279
  <!-- runtime:end -->
248
280
 
249
281
  ## Accessibility & reduced motion
@@ -1,4 +1,4 @@
1
- import { T as Timeline, a as Tween, p as parseEase, d as parseValue } from './tween-CqX1JBuj.js';
1
+ import { T as Timeline, a as Tween, p as parseEase, d as parseValue } from './tween-CGyolmzB.js';
2
2
 
3
3
  /**
4
4
  * Normalised keyframes shared by the format loaders: a list of frames with
@@ -180,4 +180,4 @@ function framesToTimeline(target, frames, o = {}) {
180
180
  }
181
181
 
182
182
  export { camelProp as c, distributeOffsets as d, framesToTimeline as f };
183
- //# sourceMappingURL=keyframes-W-474DMc.js.map
183
+ //# sourceMappingURL=keyframes-DVAC5sQI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyframes-W-474DMc.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,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K,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;;;;"}
1
+ {"version":3,"file":"keyframes-DVAC5sQI.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,GAAG,CAAC;AACT,IAAA,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE;QACrB,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,EAAE;AAAE,YAAA,CAAC,EAAE;YAAE;QAAU;AAC5C,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,CAAC;AACT,QAAA,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI;AAAE,YA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E,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var tween = require('./tween-CBuWYpI-.cjs');
3
+ var tween = require('./tween-CFN0WcOb.cjs');
4
4
 
5
5
  /**
6
6
  * Normalised keyframes shared by the format loaders: a list of frames with
@@ -184,4 +184,4 @@ function framesToTimeline(target, frames, o = {}) {
184
184
  exports.camelProp = camelProp;
185
185
  exports.distributeOffsets = distributeOffsets;
186
186
  exports.framesToTimeline = framesToTimeline;
187
- //# sourceMappingURL=keyframes-ZheOkpt0.cjs.map
187
+ //# sourceMappingURL=keyframes-Dw9zwVQa.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"keyframes-ZheOkpt0.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,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,GAAG,CAAC;AACT,IAAA,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE;QACrB,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,EAAE;AAAE,YAAA,CAAC,EAAE;YAAE;QAAU;AAC5C,QAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,CAAC;AACT,QAAA,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI;AAAE,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AAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;;;;;"}
1
+ {"version":3,"file":"keyframes-Dw9zwVQa.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,C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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC;QACA,EAAE,CAAC,GAAG,CAAC,IAAIC,WAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAGC,eAAS,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;;;;;;"}
@@ -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.2.0';
10
+ const RUNTIME_VERSION = '10.3.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');
@@ -66,4 +66,4 @@ function requireModule(id, who) {
66
66
  const registeredModules = () => Array.from(registry().modules.keys());
67
67
 
68
68
  export { RUNTIME_VERSION as R, RUNTIME_CDN as a, RuntimeModuleError as b, moduleCdn as c, modulePath as d, registeredModules as e, registry as f, requireModule as g, hasModule as h, missingMessage as m, register as r };
69
- //# sourceMappingURL=registry-BIEjKngP.js.map
69
+ //# sourceMappingURL=registry-46AAzyeC.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-BIEjKngP.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.2.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,SAAS,CAAC,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AC,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-46AAzyeC.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.3.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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,CAAC,kGAAkG,CAAC;QAC3J,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAAE;AACzB,QAAA,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,QAAQ,IAAI,EAAE;YAAE,IAAI,CAAC,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;;;;"}
@@ -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.2.0';
12
+ const RUNTIME_VERSION = '10.3.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-eJgpFAzI.cjs.map
81
+ //# sourceMappingURL=registry-CSVil2qJ.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry-eJgpFAzI.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.2.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,SAAS,CAAC,MAAM,CAAC,CAAA,wBAAA,EAA2B,SAAS,CAAC,EAAE,CA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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-CSVil2qJ.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.3.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,GAA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AAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YAAE;AACzB,QAAA,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,QAAQ,IAAI,EAAE;YAAE,IAAI,CAAC,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;;;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { f as registry } from './registry-BIEjKngP.js';
1
+ import { f as registry } from './registry-46AAzyeC.js';
2
2
 
3
3
  /**
4
4
  * The shared ticker: one requestAnimationFrame loop per page (or worker) for
@@ -67,4 +67,4 @@ function getTicker() {
67
67
  }
68
68
 
69
69
  export { getTicker as g };
70
- //# sourceMappingURL=ticker-CM_56oVy.js.map
70
+ //# sourceMappingURL=ticker-COOYAyQy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ticker-CM_56oVy.js","sources":["../../src/runtime/ticker.ts"],"sourcesContent":["/**\n * The shared ticker: one requestAnimationFrame loop per page (or worker) for\n * every runtime animation, with lag smoothing and a frame budget readout.\n * Falls back to a 16 ms timer where rAF is missing (Node, some workers).\n * Nothing runs until the first listener is added (SSR-safe).\n */\nimport { registry } from './registry';\n\nexport type TickFn = (time: number, delta: number) => void;\n\nexport interface Ticker {\n /** Add a listener; returns a remover. */\n add(fn: TickFn): () => void;\n remove(fn: TickFn): void;\n /** ms since the ticker started (frozen while sleeping). */\n readonly time: number;\n /** Smoothed frames per second. */\n readonly fps: number;\n /** Listener count (0 = asleep). */\n readonly size: number;\n /** Cap a single frame's delta (default 100 ms) so a background tab does not jump animations. */\n lagSmoothing(maxDelta: number): void;\n /** Global time scale (1 = normal, 0.5 = half speed, 0 = frozen). */\n timeScale: number;\n /** Advance by `ms` synchronously (tests, offline rendering, worker loops). */\n step(ms: number): void;\n}\n\nfunction createTicker(): Ticker {\n const fns = new Set<TickFn>();\n let time = 0, last = -1, fps = 60, maxDelta = 100, handle: unknown = null;\n const g = globalThis as any;\n const now = (): number => (g.performance?.now ? g.performance.now() : Date.now());\n const raf = (cb: (t: number) => void): unknown => (typeof g.requestAnimationFrame === 'function' ? g.requestAnimationFrame(cb) : setTimeout(() => cb(now()), 16));\n const caf = (h: unknown): void => (typeof g.cancelAnimationFrame === 'function' ? g.cancelAnimationFrame(h) : clearTimeout(h as any));\n const run = (dt: number, cap = true): void => {\n const d = (cap ? Math.min(dt, maxDelta) : dt) * t.timeScale;\n time += d;\n for (const fn of Array.from(fns)) fn(time, d);\n };\n const frame = (ts: number): void => {\n handle = null;\n if (!fns.size) return;\n const n = typeof ts === 'number' && ts > 0 ? ts : now();\n const dt = last < 0 ? 0 : n - last;\n last = n;\n if (dt > 0) fps = fps * 0.9 + (1000 / dt) * 0.1;\n run(dt);\n if (fns.size) handle = raf(frame);\n };\n const wake = (): void => {\n if (handle === null && fns.size) {\n last = -1;\n handle = raf(frame);\n }\n };\n const t: Ticker = {\n add(fn) {\n fns.add(fn);\n wake();\n return () => t.remove(fn);\n },\n remove(fn) {\n fns.delete(fn);\n if (!fns.size && handle !== null) {\n caf(handle);\n handle = null;\n }\n },\n get time() { return time; },\n get fps() { return Math.round(fps); },\n get size() { return fns.size; },\n lagSmoothing(ms) { maxDelta = ms > 0 ? ms : Infinity; },\n timeScale: 1,\n step(ms) { run(ms, false); },\n };\n return t;\n}\n\n/** The page-wide ticker (shared across every copy of the runtime). */\nexport function getTicker(): Ticker {\n const s = registry().slots;\n return (s.ticker ||= createTicker()) as Ticker;\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAuBH,SAAS,YAAY,GAAA;AACnB,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;IAC7B,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,QAAQ,GAAG,GAAG,EAAE,MAAM,GAAY,IAAI;IACzE,MAAM,CAAC,GAAG,UAAiB;AAC3B,IAAA,MAAM,GAAG,GAAG,OAAe,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACjF,IAAA,MAAM,GAAG,GAAG,CAAC,EAAuB,MAAe,OAAO,CAAC,CAAC,qBAAqB,KAAK,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACjK,IAAA,MAAM,GAAG,GAAG,CAAC,CAAU,MAAY,OAAO,CAAC,CAAC,oBAAoB,KAAK,UAAU,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAQ,CAAC,CAAC;IACrI,MAAM,GAAG,GAAG,CAAC,EAAU,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,MAAM,CAAC,EAAE,CAAC;QAC3B,CAAC;AACD,QAAA,MAAM,CAAC,EAAE,EAAA;AACP,YAAA,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACd,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,KAAK,IAAI,EAAE;gBAChC,GAAG,CAAC,MAAM,CAAC;gBACX,MAAM,GAAG,IAAI;YACf;QACF,CAAC;AACD,QAAA,IAAI,IAAI,GAAA,EAAK,OAAO,IAAI,CAAC,CAAC,CAAC;QAC3B,IAAI,GAAG,GAAA,EAAK,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/B,QAAA,YAAY,CAAC,EAAE,EAAA,EAAI,QAAQ,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;AACvD,QAAA,SAAS,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,EAAA,EAAI,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7B;AACD,IAAA,OAAO,CAAC;AACV;AAEA;SACgB,SAAS,GAAA;AACvB,IAAA,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,KAAK;AAC1B,IAAA,QAAQ,CAAC,CAAC,MAAM,KAAR,CAAC,CAAC,MAAM,GAAK,YAAY,EAAE,CAAA;AACrC;;;;"}
1
+ {"version":3,"file":"ticker-COOYAyQy.js","sources":["../../src/runtime/ticker.ts"],"sourcesContent":["/**\n * The shared ticker: one requestAnimationFrame loop per page (or worker) for\n * every runtime animation, with lag smoothing and a frame budget readout.\n * Falls back to a 16 ms timer where rAF is missing (Node, some workers).\n * Nothing runs until the first listener is added (SSR-safe).\n */\nimport { registry } from './registry';\n\nexport type TickFn = (time: number, delta: number) => void;\n\nexport interface Ticker {\n /** Add a listener; returns a remover. */\n add(fn: TickFn): () => void;\n remove(fn: TickFn): void;\n /** ms since the ticker started (frozen while sleeping). */\n readonly time: number;\n /** Smoothed frames per second. */\n readonly fps: number;\n /** Listener count (0 = asleep). */\n readonly size: number;\n /** Cap a single frame's delta (default 100 ms) so a background tab does not jump animations. */\n lagSmoothing(maxDelta: number): void;\n /** Global time scale (1 = normal, 0.5 = half speed, 0 = frozen). */\n timeScale: number;\n /** Advance by `ms` synchronously (tests, offline rendering, worker loops). */\n step(ms: number): void;\n}\n\nfunction createTicker(): Ticker {\n const fns = new Set<TickFn>();\n let time = 0, last = -1, fps = 60, maxDelta = 100, handle: unknown = null;\n const g = globalThis as any;\n const now = (): number => (g.performance?.now ? g.performance.now() : Date.now());\n const raf = (cb: (t: number) => void): unknown => (typeof g.requestAnimationFrame === 'function' ? g.requestAnimationFrame(cb) : setTimeout(() => cb(now()), 16));\n const caf = (h: unknown): void => (typeof g.cancelAnimationFrame === 'function' ? g.cancelAnimationFrame(h) : clearTimeout(h as any));\n const run = (dt: number, cap = true): void => {\n const d = (cap ? Math.min(dt, maxDelta) : dt) * t.timeScale;\n time += d;\n for (const fn of Array.from(fns)) fn(time, d);\n };\n const frame = (ts: number): void => {\n handle = null;\n if (!fns.size) return;\n const n = typeof ts === 'number' && ts > 0 ? ts : now();\n const dt = last < 0 ? 0 : n - last;\n last = n;\n if (dt > 0) fps = fps * 0.9 + (1000 / dt) * 0.1;\n run(dt);\n if (fns.size) handle = raf(frame);\n };\n const wake = (): void => {\n if (handle === null && fns.size) {\n last = -1;\n handle = raf(frame);\n }\n };\n const t: Ticker = {\n add(fn) {\n fns.add(fn);\n wake();\n return () => t.remove(fn);\n },\n remove(fn) {\n fns.delete(fn);\n if (!fns.size && handle !== null) {\n caf(handle);\n handle = null;\n }\n },\n get time() { return time; },\n get fps() { return Math.round(fps); },\n get size() { return fns.size; },\n lagSmoothing(ms) { maxDelta = ms > 0 ? ms : Infinity; },\n timeScale: 1,\n step(ms) { run(ms, false); },\n };\n return t;\n}\n\n/** The page-wide ticker (shared across every copy of the runtime). */\nexport function getTicker(): Ticker {\n const s = registry().slots;\n return (s.ticker ||= createTicker()) as Ticker;\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAuBH,SAAS,YAAY,GAAA;AACnB,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;IAC7B,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,QAAQ,GAAG,GAAG,EAAE,MAAM,GAAY,IAAI;IACzE,MAAM,CAAC,GAAG,UAAiB;AAC3B,IAAA,MAAM,GAAG,GAAG,OAAe,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACjF,IAAA,MAAM,GAAG,GAAG,CAAC,EAAuB,MAAe,OAAO,CAAC,CAAC,qBAAqB,KAAK,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACjK,IAAA,MAAM,GAAG,GAAG,CAAC,CAAU,MAAY,OAAO,CAAC,CAAC,oBAAoB,KAAK,UAAU,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAQ,CAAC,CAAC;IACrI,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,GAAG,GAAG,IAAI,KAAU;QAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,SAAS;QAC3D,IAAI,IAAI,CAAC;QACT,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AAAE,YAAA,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/C,IA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C,CAAC,CAAC;QAC3B,IAAI,GAAG,GAAA,EAAK,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/B,QAAA,YAAY,CAAC,EAAE,EAAA,EAAI,QAAQ,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;AACvD,QAAA,SAAS,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,EAAA,EAAI,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7B;AACD,IAAA,OAAO,CAAC;AACV;AAEA;SACgB,SAAS,GAAA;AACvB,IAAA,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,KAAK;AAC1B,IAAA,QAAQ,CAAC,CAAC,MAAM,KAAR,CAAC,CAAC,MAAM,GAAK,YAAY,EAAE,CAAA;AACrC;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var registry = require('./registry-eJgpFAzI.cjs');
3
+ var registry = require('./registry-CSVil2qJ.cjs');
4
4
 
5
5
  /**
6
6
  * The shared ticker: one requestAnimationFrame loop per page (or worker) for
@@ -69,4 +69,4 @@ function getTicker() {
69
69
  }
70
70
 
71
71
  exports.getTicker = getTicker;
72
- //# sourceMappingURL=ticker-D4o6enH0.cjs.map
72
+ //# sourceMappingURL=ticker-gHv6pNfx.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ticker-D4o6enH0.cjs","sources":["../../src/runtime/ticker.ts"],"sourcesContent":["/**\n * The shared ticker: one requestAnimationFrame loop per page (or worker) for\n * every runtime animation, with lag smoothing and a frame budget readout.\n * Falls back to a 16 ms timer where rAF is missing (Node, some workers).\n * Nothing runs until the first listener is added (SSR-safe).\n */\nimport { registry } from './registry';\n\nexport type TickFn = (time: number, delta: number) => void;\n\nexport interface Ticker {\n /** Add a listener; returns a remover. */\n add(fn: TickFn): () => void;\n remove(fn: TickFn): void;\n /** ms since the ticker started (frozen while sleeping). */\n readonly time: number;\n /** Smoothed frames per second. */\n readonly fps: number;\n /** Listener count (0 = asleep). */\n readonly size: number;\n /** Cap a single frame's delta (default 100 ms) so a background tab does not jump animations. */\n lagSmoothing(maxDelta: number): void;\n /** Global time scale (1 = normal, 0.5 = half speed, 0 = frozen). */\n timeScale: number;\n /** Advance by `ms` synchronously (tests, offline rendering, worker loops). */\n step(ms: number): void;\n}\n\nfunction createTicker(): Ticker {\n const fns = new Set<TickFn>();\n let time = 0, last = -1, fps = 60, maxDelta = 100, handle: unknown = null;\n const g = globalThis as any;\n const now = (): number => (g.performance?.now ? g.performance.now() : Date.now());\n const raf = (cb: (t: number) => void): unknown => (typeof g.requestAnimationFrame === 'function' ? g.requestAnimationFrame(cb) : setTimeout(() => cb(now()), 16));\n const caf = (h: unknown): void => (typeof g.cancelAnimationFrame === 'function' ? g.cancelAnimationFrame(h) : clearTimeout(h as any));\n const run = (dt: number, cap = true): void => {\n const d = (cap ? Math.min(dt, maxDelta) : dt) * t.timeScale;\n time += d;\n for (const fn of Array.from(fns)) fn(time, d);\n };\n const frame = (ts: number): void => {\n handle = null;\n if (!fns.size) return;\n const n = typeof ts === 'number' && ts > 0 ? ts : now();\n const dt = last < 0 ? 0 : n - last;\n last = n;\n if (dt > 0) fps = fps * 0.9 + (1000 / dt) * 0.1;\n run(dt);\n if (fns.size) handle = raf(frame);\n };\n const wake = (): void => {\n if (handle === null && fns.size) {\n last = -1;\n handle = raf(frame);\n }\n };\n const t: Ticker = {\n add(fn) {\n fns.add(fn);\n wake();\n return () => t.remove(fn);\n },\n remove(fn) {\n fns.delete(fn);\n if (!fns.size && handle !== null) {\n caf(handle);\n handle = null;\n }\n },\n get time() { return time; },\n get fps() { return Math.round(fps); },\n get size() { return fns.size; },\n lagSmoothing(ms) { maxDelta = ms > 0 ? ms : Infinity; },\n timeScale: 1,\n step(ms) { run(ms, false); },\n };\n return t;\n}\n\n/** The page-wide ticker (shared across every copy of the runtime). */\nexport function getTicker(): Ticker {\n const s = registry().slots;\n return (s.ticker ||= createTicker()) as Ticker;\n}\n"],"names":["registry"],"mappings":";;;;AAAA;;;;;AAKG;AAuBH,SAAS,YAAY,GAAA;AACnB,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;IAC7B,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,QAAQ,GAAG,GAAG,EAAE,MAAM,GAAY,IAAI;IACzE,MAAM,CAAC,GAAG,UAAiB;AAC3B,IAAA,MAAM,GAAG,GAAG,OAAe,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACjF,IAAA,MAAM,GAAG,GAAG,CAAC,EAAuB,MAAe,OAAO,CAAC,CAAC,qBAAqB,KAAK,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACjK,IAAA,MAAM,GAAG,GAAG,CAAC,CAAU,MAAY,OAAO,CAAC,CAAC,oBAAoB,KAAK,UAAU,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAQ,CAAC,CAAC;IACrI,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,GAAG,GAAG,IAAI,KAAU;QAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,SAAS;QAC3D,IAAI,IAAI,CAAC;QACT,KAAK,MAAM,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;AAAE,YAAA,EAAE,CAAC,IAAI,EA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AA,EAAK,OAAO,IAAI,CAAC,CAAC,CAAC;QAC3B,IAAI,GAAG,GAAA,EAAK,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/B,QAAA,YAAY,CAAC,EAAE,EAAA,EAAI,QAAQ,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;AACvD,QAAA,SAAS,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,EAAA,EAAI,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7B;AACD,IAAA,OAAO,CAAC;AACV;AAEA;SACgB,SAAS,GAAA;AACvB,IAAA,MAAM,CAAC,GAAGA,iBAAQ,EAAE,CAAC,KAAK;AAC1B,IAAA,QAAQ,CAAC,CAAC,MAAM,KAAR,CAAC,CAAC,MAAM,GAAK,YAAY,EAAE,CAAA;AACrC;;;;"}
1
+ {"version":3,"file":"ticker-gHv6pNfx.cjs","sources":["../../src/runtime/ticker.ts"],"sourcesContent":["/**\n * The shared ticker: one requestAnimationFrame loop per page (or worker) for\n * every runtime animation, with lag smoothing and a frame budget readout.\n * Falls back to a 16 ms timer where rAF is missing (Node, some workers).\n * Nothing runs until the first listener is added (SSR-safe).\n */\nimport { registry } from './registry';\n\nexport type TickFn = (time: number, delta: number) => void;\n\nexport interface Ticker {\n /** Add a listener; returns a remover. */\n add(fn: TickFn): () => void;\n remove(fn: TickFn): void;\n /** ms since the ticker started (frozen while sleeping). */\n readonly time: number;\n /** Smoothed frames per second. */\n readonly fps: number;\n /** Listener count (0 = asleep). */\n readonly size: number;\n /** Cap a single frame's delta (default 100 ms) so a background tab does not jump animations. */\n lagSmoothing(maxDelta: number): void;\n /** Global time scale (1 = normal, 0.5 = half speed, 0 = frozen). */\n timeScale: number;\n /** Advance by `ms` synchronously (tests, offline rendering, worker loops). */\n step(ms: number): void;\n}\n\nfunction createTicker(): Ticker {\n const fns = new Set<TickFn>();\n let time = 0, last = -1, fps = 60, maxDelta = 100, handle: unknown = null;\n const g = globalThis as any;\n const now = (): number => (g.performance?.now ? g.performance.now() : Date.now());\n const raf = (cb: (t: number) => void): unknown => (typeof g.requestAnimationFrame === 'function' ? g.requestAnimationFrame(cb) : setTimeout(() => cb(now()), 16));\n const caf = (h: unknown): void => (typeof g.cancelAnimationFrame === 'function' ? g.cancelAnimationFrame(h) : clearTimeout(h as any));\n const run = (dt: number, cap = true): void => {\n const d = (cap ? Math.min(dt, maxDelta) : dt) * t.timeScale;\n time += d;\n for (const fn of Array.from(fns)) fn(time, d);\n };\n const frame = (ts: number): void => {\n handle = null;\n if (!fns.size) return;\n const n = typeof ts === 'number' && ts > 0 ? ts : now();\n const dt = last < 0 ? 0 : n - last;\n last = n;\n if (dt > 0) fps = fps * 0.9 + (1000 / dt) * 0.1;\n run(dt);\n if (fns.size) handle = raf(frame);\n };\n const wake = (): void => {\n if (handle === null && fns.size) {\n last = -1;\n handle = raf(frame);\n }\n };\n const t: Ticker = {\n add(fn) {\n fns.add(fn);\n wake();\n return () => t.remove(fn);\n },\n remove(fn) {\n fns.delete(fn);\n if (!fns.size && handle !== null) {\n caf(handle);\n handle = null;\n }\n },\n get time() { return time; },\n get fps() { return Math.round(fps); },\n get size() { return fns.size; },\n lagSmoothing(ms) { maxDelta = ms > 0 ? ms : Infinity; },\n timeScale: 1,\n step(ms) { run(ms, false); },\n };\n return t;\n}\n\n/** The page-wide ticker (shared across every copy of the runtime). */\nexport function getTicker(): Ticker {\n const s = registry().slots;\n return (s.ticker ||= createTicker()) as Ticker;\n}\n"],"names":["registry"],"mappings":";;;;AAAA;;;;;AAKG;AAuBH,SAAS,YAAY,GAAA;AACnB,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;IAC7B,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,GAA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,CAAC,CAAC,CAAC;AACvD,QAAA,SAAS,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,EAAA,EAAI,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KAC7B;AACD,IAAA,OAAO,CAAC;AACV;AAEA;SACgB,SAAS,GAAA;AACvB,IAAA,MAAM,CAAC,GAAGA,iBAAQ,EAAE,CAAC,KAAK;AAC1B,IAAA,QAAQ,CAAC,CAAC,MAAM,KAAR,CAAC,CAAC,MAAM,GAAK,YAAY,EAAE,CAAA;AACrC;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var ticker = require('./ticker-D4o6enH0.cjs');
3
+ var ticker = require('./ticker-gHv6pNfx.cjs');
4
4
 
5
5
  const out = (f) => (t) => 1 - f(1 - t);
6
6
  const inOut = (f) => (t) => (t < 0.5 ? f(t * 2) / 2 : 1 - f((1 - t) * 2) / 2);
@@ -101,6 +101,7 @@ const TRANSFORM = ['x', 'y', 'rotate', 'scale', 'scaleX', 'scaleY', 'skewX', 'sk
101
101
  const DEFAULT_UNIT = { x: 'px', y: 'px', rotate: 'deg', skewX: 'deg', skewY: 'deg', scale: '', scaleX: '', scaleY: '' };
102
102
  const tstate = new WeakMap();
103
103
  const isEl = (t) => typeof Element !== 'undefined' && t instanceof Element;
104
+ const NUM_RE = /-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?/gi;
104
105
  /** Parse '12px', '-3.5', '50%', '#0af', 'rgb(1 2 3 / .5)', 'rgba(…)'. */
105
106
  function parseValue(v) {
106
107
  if (typeof v === 'number')
@@ -124,9 +125,16 @@ function parseValue(v) {
124
125
  m = /^(-?[\d.]+(?:e-?\d+)?)([a-z%]*)$/i.exec(s);
125
126
  if (m)
126
127
  return { kind: 'num', v: parseFloat(m[1]), u: m[2] };
127
- throw new Error(`[motionary] cannot tween value "${s}"`);
128
+ return { kind: 'str', s, parts: s.split(NUM_RE), nums: (s.match(NUM_RE) || []).map(Number) };
128
129
  }
129
130
  const lerpVal = (a, b, p) => {
131
+ if (a.kind === 'str' || b.kind === 'str') {
132
+ if (a.kind === 'str' && b.kind === 'str' && a.parts.join('\u0000') === b.parts.join('\u0000') && a.nums.length === b.nums.length) {
133
+ return a.parts.map((t, i) => t + (i < a.nums.length ? +(a.nums[i] + (b.nums[i] - a.nums[i]) * p).toFixed(4) : '')).join('');
134
+ }
135
+ const src = p < 0.5 ? a : b;
136
+ return src.kind === 'str' ? src.s : src.kind === 'num' ? (src.u ? src.v + src.u : src.v) : `rgba(${src.c.join(', ')})`;
137
+ }
130
138
  if (a.kind === 'col' || b.kind === 'col') {
131
139
  const ca = a.kind === 'col' ? a.c : [0, 0, 0, 0], cb = b.kind === 'col' ? b.c : [0, 0, 0, 0];
132
140
  const c = ca.map((x, i) => x + (cb[i] - x) * p);
@@ -176,6 +184,8 @@ function writeProp(t, k, v) {
176
184
  }
177
185
  if (TRANSFORM.includes(k)) {
178
186
  const p = parseValue(v);
187
+ if (p.kind !== 'num')
188
+ throw new Error(`[motionary] ${k} needs a number (got "${v}")`);
179
189
  const s = tstate.get(t) || {};
180
190
  s[k] = { v: p.v, u: p.u };
181
191
  tstate.set(t, s);
@@ -484,4 +494,4 @@ exports.parseValue = parseValue;
484
494
  exports.steps = steps;
485
495
  exports.timeline = timeline;
486
496
  exports.tween = tween;
487
- //# sourceMappingURL=tween-CBuWYpI-.cjs.map
497
+ //# sourceMappingURL=tween-CFN0WcOb.cjs.map