motionary 10.0.0 → 10.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +45 -0
  3. package/bin/create-motionary-plugin.mjs +124 -0
  4. package/dist/chunks/keyframes-CyH_abhI.js +183 -0
  5. package/dist/chunks/keyframes-CyH_abhI.js.map +1 -0
  6. package/dist/chunks/keyframes-cUdsXSXQ.cjs +187 -0
  7. package/dist/chunks/keyframes-cUdsXSXQ.cjs.map +1 -0
  8. package/dist/chunks/registry-C0xLNq3-.cjs +81 -0
  9. package/dist/chunks/registry-C0xLNq3-.cjs.map +1 -0
  10. package/dist/chunks/registry-jF8VIA_9.js +69 -0
  11. package/dist/chunks/registry-jF8VIA_9.js.map +1 -0
  12. package/dist/chunks/tween-DDObu9iA.js +542 -0
  13. package/dist/chunks/tween-DDObu9iA.js.map +1 -0
  14. package/dist/chunks/tween-JEthWrjo.cjs +554 -0
  15. package/dist/chunks/tween-JEthWrjo.cjs.map +1 -0
  16. package/dist/components/marketplace.cjs +104 -0
  17. package/dist/components/marketplace.cjs.map +1 -1
  18. package/dist/components/marketplace.d.cts +33 -2
  19. package/dist/components/marketplace.d.ts +33 -2
  20. package/dist/components/marketplace.js +101 -1
  21. package/dist/components/marketplace.js.map +1 -1
  22. package/dist/components/widgets.cjs +420 -199
  23. package/dist/components/widgets.cjs.map +1 -1
  24. package/dist/components/widgets.d.cts +42 -2
  25. package/dist/components/widgets.d.ts +42 -2
  26. package/dist/components/widgets.js +420 -201
  27. package/dist/components/widgets.js.map +1 -1
  28. package/dist/llms-full.txt +3018 -0
  29. package/dist/llms.txt +207 -0
  30. package/dist/manifest.json +7562 -0
  31. package/dist/manifest.schema.json +85 -0
  32. package/dist/runtime/format-css.cjs +184 -0
  33. package/dist/runtime/format-css.cjs.map +1 -0
  34. package/dist/runtime/format-css.d.cts +174 -0
  35. package/dist/runtime/format-css.d.ts +174 -0
  36. package/dist/runtime/format-css.iife.js +2 -0
  37. package/dist/runtime/format-css.iife.js.map +1 -0
  38. package/dist/runtime/format-css.js +176 -0
  39. package/dist/runtime/format-css.js.map +1 -0
  40. package/dist/runtime/format-motion.cjs +138 -0
  41. package/dist/runtime/format-motion.cjs.map +1 -0
  42. package/dist/runtime/format-motion.d.cts +208 -0
  43. package/dist/runtime/format-motion.d.ts +208 -0
  44. package/dist/runtime/format-motion.iife.js +2 -0
  45. package/dist/runtime/format-motion.iife.js.map +1 -0
  46. package/dist/runtime/format-motion.js +132 -0
  47. package/dist/runtime/format-motion.js.map +1 -0
  48. package/dist/runtime.cjs +78 -0
  49. package/dist/runtime.cjs.map +1 -0
  50. package/dist/runtime.d.cts +236 -0
  51. package/dist/runtime.d.ts +236 -0
  52. package/dist/runtime.iife.js +2 -0
  53. package/dist/runtime.iife.js.map +1 -0
  54. package/dist/runtime.js +54 -0
  55. package/dist/runtime.js.map +1 -0
  56. package/dist/widgets.umd.js +1 -1
  57. package/dist/widgets.umd.js.map +1 -1
  58. package/docs/ROADMAP.md +69 -38
  59. package/docs/components.md +55 -0
  60. package/docs/runtime/core.md +55 -0
  61. package/docs/runtime/format-css.md +59 -0
  62. package/docs/runtime/format-motion.md +56 -0
  63. package/package.json +48 -6
@@ -0,0 +1,85 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://harrisoncn.github.io/Motionary/components.schema.json",
4
+ "title": "Motionary component manifest",
5
+ "description": "Machine-readable list of every Motionary component (tags, attributes, events, slots, import paths, CDN URLs, minimal examples, prerequisites) and every motionary/runtime module. Generated at build time from the source and the gallery catalog.",
6
+ "type": "object",
7
+ "required": ["format", "schemaVersion", "package", "version", "cdn", "runtimeModules", "components"],
8
+ "properties": {
9
+ "format": { "const": "motionary/components" },
10
+ "schemaVersion": { "type": "integer", "minimum": 1 },
11
+ "package": { "type": "string" },
12
+ "version": { "type": "string" },
13
+ "homepage": { "type": "string" },
14
+ "llms": { "type": "string" },
15
+ "cdn": {
16
+ "type": "object",
17
+ "properties": { "components": { "type": "string" }, "widgets": { "type": "string" }, "runtime": { "type": "string" } },
18
+ "required": ["components", "widgets", "runtime"]
19
+ },
20
+ "runtimeModules": { "type": "array", "items": { "$ref": "#/$defs/prerequisite" } },
21
+ "components": { "type": "array", "items": { "$ref": "#/$defs/component" } }
22
+ },
23
+ "$defs": {
24
+ "prerequisite": {
25
+ "type": "object",
26
+ "required": ["id", "kind", "label", "install", "importPath", "import", "register", "cdn", "order", "docs"],
27
+ "properties": {
28
+ "id": { "type": "string" },
29
+ "kind": { "enum": ["runtime", "peer"] },
30
+ "label": { "type": "string" },
31
+ "title": { "type": "string" },
32
+ "summary": { "type": "string" },
33
+ "install": { "type": "string", "description": "Exact install command." },
34
+ "importPath": { "type": "string" },
35
+ "import": { "type": "string" },
36
+ "register": { "type": "string", "description": "Registration code, run before the component mounts." },
37
+ "cdn": { "type": "string", "description": "Copyable <script> tags (version-pinned)." },
38
+ "cdnEsm": { "type": "string" },
39
+ "order": { "type": "string", "description": "Import order and registration steps in words." },
40
+ "docs": { "type": "string" },
41
+ "budget": { "type": "integer", "description": "gzip size budget in bytes (CI-enforced)." },
42
+ "exports": { "type": "array", "items": { "type": "string" } },
43
+ "compat": { "type": "array", "items": { "type": "array", "items": { "type": "string" } } },
44
+ "example": { "type": "string" }
45
+ }
46
+ },
47
+ "component": {
48
+ "type": "object",
49
+ "required": ["id", "tag", "title", "description", "category", "import", "cdn", "attributes", "events", "slots", "example", "requires"],
50
+ "properties": {
51
+ "id": { "type": "string" },
52
+ "tag": { "type": "string", "pattern": "^[a-z][a-z0-9]*-[a-z0-9-]+$" },
53
+ "title": { "type": "string" },
54
+ "description": { "type": "string" },
55
+ "category": { "type": "string" },
56
+ "since": { "type": "string" },
57
+ "keywords": { "type": "array", "items": { "type": "string" } },
58
+ "import": {
59
+ "type": "object",
60
+ "required": ["path", "define"],
61
+ "properties": { "path": { "type": "string" }, "define": { "type": "string" }, "register": { "type": "string" } }
62
+ },
63
+ "cdn": { "type": "string" },
64
+ "attributes": { "type": "array", "items": { "type": "string" } },
65
+ "events": { "type": "array", "items": { "type": "string" } },
66
+ "slots": { "type": "array", "items": { "type": "string" } },
67
+ "methods": { "type": "array", "items": { "type": "string" } },
68
+ "example": { "type": "string" },
69
+ "requires": { "type": "array", "items": { "type": "string" }, "description": "Prerequisite ids (runtimeModules[].id or peer ids)." },
70
+ "prerequisites": {
71
+ "type": ["object", "null"],
72
+ "properties": {
73
+ "badge": { "type": "string" },
74
+ "install": { "type": "string" },
75
+ "importAndRegister": { "type": "string" },
76
+ "order": { "type": "string" },
77
+ "cdn": { "type": "string" },
78
+ "example": { "type": "string" }
79
+ }
80
+ },
81
+ "source": { "type": "string" }
82
+ }
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,184 @@
1
+ 'use strict';
2
+
3
+ var registry = require('../chunks/registry-C0xLNq3-.cjs');
4
+ var keyframes = require('../chunks/keyframes-cUdsXSXQ.cjs');
5
+ require('../chunks/tween-JEthWrjo.cjs');
6
+
7
+ /**
8
+ * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web
9
+ * Animations API keyframes into the runtime timeline.
10
+ *
11
+ * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet
12
+ * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),
13
+ * per-frame `animation-timing-function`, `!important` ignored as in CSS.
14
+ * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.
15
+ * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)
16
+ * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with
17
+ * offsets distributed like the WAAPI.
18
+ * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.
19
+ *
20
+ * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,
21
+ * `@property` typed interpolation, 3D / matrix transforms (switch discretely).
22
+ */
23
+ /** Strip comments. */
24
+ const clean = (css) => css.replace(/\/\*[\s\S]*?\*\//g, '');
25
+ function block(css, open) {
26
+ let depth = 0;
27
+ for (let i = open; i < css.length; i++) {
28
+ if (css[i] === '{')
29
+ depth++;
30
+ else if (css[i] === '}' && --depth === 0)
31
+ return [css.slice(open + 1, i), i + 1];
32
+ }
33
+ throw new Error('[motionary] format-css: unbalanced braces in @keyframes');
34
+ }
35
+ function decls(body) {
36
+ const props = {};
37
+ let easing;
38
+ // split on ';' outside parentheses
39
+ let depth = 0, cur = '';
40
+ const parts = [];
41
+ for (const ch of body) {
42
+ if (ch === '(')
43
+ depth++;
44
+ if (ch === ')')
45
+ depth--;
46
+ if (ch === ';' && !depth) {
47
+ parts.push(cur);
48
+ cur = '';
49
+ }
50
+ else
51
+ cur += ch;
52
+ }
53
+ parts.push(cur);
54
+ for (const p of parts) {
55
+ const i = p.indexOf(':');
56
+ if (i < 0)
57
+ continue;
58
+ const k = p.slice(0, i).trim();
59
+ const v = p.slice(i + 1).replace(/!important/i, '').trim();
60
+ if (!k || !v)
61
+ continue;
62
+ if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function')
63
+ easing = v;
64
+ else
65
+ props[keyframes.camelProp(k)] = v;
66
+ }
67
+ return { props, easing };
68
+ }
69
+ const offsetOf = (sel) => {
70
+ const s = sel.trim().toLowerCase();
71
+ if (s === 'from')
72
+ return 0;
73
+ if (s === 'to')
74
+ return 1;
75
+ const n = parseFloat(s);
76
+ if (!s.endsWith('%') || !Number.isFinite(n))
77
+ throw new Error(`[motionary] format-css: bad keyframe selector "${sel}"`);
78
+ return n / 100;
79
+ };
80
+ /** Parse the body of one `@keyframes` block. */
81
+ function parseKeyframesBody(body) {
82
+ const frames = [];
83
+ let i = 0;
84
+ while (i < body.length) {
85
+ const open = body.indexOf('{', i);
86
+ if (open < 0)
87
+ break;
88
+ const sel = body.slice(i, open);
89
+ const [inner, end] = block(body, open);
90
+ const d = decls(inner);
91
+ for (const part of sel.split(','))
92
+ if (part.trim())
93
+ frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });
94
+ i = end;
95
+ }
96
+ // merge duplicate offsets (later declarations win, as in CSS)
97
+ const by = new Map();
98
+ for (const f of frames.sort((a, b) => a.offset - b.offset)) {
99
+ const prev = by.get(f.offset);
100
+ by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);
101
+ }
102
+ return Array.from(by.values());
103
+ }
104
+ /** Every `@keyframes` block in a stylesheet's text. */
105
+ function parseKeyframes(cssText) {
106
+ const css = clean(cssText);
107
+ const out = [];
108
+ const re = /@(?:-webkit-|-moz-)?keyframes\s+(["']?)([\w-]+)\1\s*\{/g;
109
+ let m;
110
+ while ((m = re.exec(css))) {
111
+ const [body, end] = block(css, m.index + m[0].length - 1);
112
+ out.push({ name: m[2], frames: parseKeyframesBody(body) });
113
+ re.lastIndex = end;
114
+ }
115
+ return out;
116
+ }
117
+ /** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */
118
+ function fromCssRule(rule) {
119
+ const css = rule.cssText;
120
+ const open = css.indexOf('{');
121
+ return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };
122
+ }
123
+ /** WAAPI keyframes (array or property-indexed form) → frames. */
124
+ function fromWaapi(kf) {
125
+ let list;
126
+ if (Array.isArray(kf))
127
+ list = kf;
128
+ else {
129
+ const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));
130
+ list = Array.from({ length: n }, (_, i) => {
131
+ const f = {};
132
+ for (const [k, v] of Object.entries(kf)) {
133
+ if (k === 'composite')
134
+ continue;
135
+ const arr = Array.isArray(v) ? v : [v];
136
+ if (k === 'offset') {
137
+ if (arr[i] !== undefined)
138
+ f.offset = arr[i];
139
+ continue;
140
+ }
141
+ if (k === 'easing') {
142
+ const e = arr[Math.min(i, arr.length - 1)];
143
+ if (e !== undefined)
144
+ f.easing = e;
145
+ continue;
146
+ }
147
+ if (arr.length === 1 && n > 1) {
148
+ if (i === n - 1)
149
+ f[k] = arr[0];
150
+ continue;
151
+ }
152
+ if (arr[i] !== undefined)
153
+ f[k] = arr[i];
154
+ }
155
+ return f;
156
+ });
157
+ }
158
+ return keyframes.distributeOffsets(list).map((f) => {
159
+ const props = {};
160
+ for (const [k, v] of Object.entries(f))
161
+ if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number'))
162
+ props[keyframes.camelProp(k === 'cssFloat' ? 'float' : k)] = v;
163
+ return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };
164
+ });
165
+ }
166
+ /** Frames in WAAPI array form (for `element.animate()`). */
167
+ function toWaapi(frames) {
168
+ return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) }));
169
+ }
170
+ /** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */
171
+ function playKeyframes(target, frames, o = {}) {
172
+ return keyframes.framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });
173
+ }
174
+ /** The module object for `use(formatCss)`. */
175
+ const formatCss = { id: 'format-css', version: registry.RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };
176
+
177
+ exports.formatCss = formatCss;
178
+ exports.fromCssRule = fromCssRule;
179
+ exports.fromWaapi = fromWaapi;
180
+ exports.parseKeyframes = parseKeyframes;
181
+ exports.parseKeyframesBody = parseKeyframesBody;
182
+ exports.playKeyframes = playKeyframes;
183
+ exports.toWaapi = toWaapi;
184
+ //# sourceMappingURL=format-css.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-css.cjs","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":["camelProp","distributeOffsets","framesToTimeline","RUNTIME_VERSION"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;AACA,MAAM,KAAK,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAEnE,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY,EAAA;IACtC,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;aACtB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC;AAAE,YAAA,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAClF;AACA,IAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAC5E;AAEA,SAAS,KAAK,CAAC,IAAY,EAAA;IACzB,MAAM,KAAK,GAA2B,EAAE;AACxC,IAAA,IAAI,MAA0B;;AAE9B,IAAA,IAAI,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,EAAE;IACvB,MAAM,KAAK,GAAa,EAAE;AAC1B,IAAA,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE;QACrB,IAAI,EAAE,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;QACvB,IAAI,EAAE,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;AACvB,QAAA,I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C,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAe;AACvH;AAEA;AACM,SAAU,aAAa,CAAC,MAAc,EAAE,MAA8B,EAAE,IAA0B,EAAE,EAAA;AACxG,IAAA,OAAOE,0BAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;AACtH;AAUA;AACO,MAAM,SAAS,GAAgC,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAEC,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE;;;;;;;;;;"}
@@ -0,0 +1,174 @@
1
+ /** Easing functions (t ∈ [0, 1] → progress). Original implementations of the standard Penner-style curves. */
2
+ type Ease = (t: number) => number;
3
+
4
+ type Target = object | Element;
5
+ type Props = Record<string, number | string>;
6
+ interface PlayOptions {
7
+ /** Delay before the first iteration, ms. */
8
+ delay?: number;
9
+ /** Extra iterations (-1 = forever). */
10
+ repeat?: number;
11
+ /** Alternate direction on every other iteration. */
12
+ yoyo?: boolean;
13
+ /** Start paused (`play()` to start). */
14
+ paused?: boolean;
15
+ onUpdate?: (progress: number) => void;
16
+ onComplete?: () => void;
17
+ }
18
+ interface TweenOptions extends PlayOptions {
19
+ to?: Props;
20
+ from?: Props;
21
+ /** ms (default 600). */
22
+ duration?: number;
23
+ ease?: string | Ease;
24
+ /** Delay added per target index (ms) when several targets are given. */
25
+ stagger?: number;
26
+ }
27
+ /** Common playback: delay, repeat, yoyo, direction, ticker attachment, promise. */
28
+ declare abstract class Playable {
29
+ delay: number;
30
+ repeat: number;
31
+ yoyo: boolean;
32
+ /** Playback rate multiplier. */
33
+ timeScale: number;
34
+ onUpdate?: (progress: number) => void;
35
+ onComplete?: () => void;
36
+ protected _t: number;
37
+ private _dir;
38
+ private _off;
39
+ private _done;
40
+ private _resolve;
41
+ /** Resolves on completion (forward end, or start when reversed). */
42
+ finished: Promise<void>;
43
+ /** Set when owned by a timeline (then the ticker never drives it). */
44
+ parent: Timeline | null;
45
+ constructor(o: PlayOptions);
46
+ /** One iteration, ms. */
47
+ abstract get duration(): number;
48
+ /** Render at `ms` into one iteration. */
49
+ protected abstract renderLocal(ms: number, iterationEnded: boolean): void;
50
+ get totalDuration(): number;
51
+ get time(): number;
52
+ get progress(): number;
53
+ set progress(p: number);
54
+ get isActive(): boolean;
55
+ get reversed(): boolean;
56
+ /** Jump to `ms` (total time, including the delay) and render. */
57
+ seek(ms: number): this;
58
+ play(): this;
59
+ pause(): this;
60
+ /** Play backwards from the current time. */
61
+ reverse(): this;
62
+ restart(): this;
63
+ /** Stop and detach for good. */
64
+ kill(): void;
65
+ /** Promise-like: `await tween(...)`. */
66
+ then<R>(ok?: (v: void) => R, err?: (e: unknown) => R): Promise<R>;
67
+ private attach;
68
+ private advance;
69
+ protected complete(): void;
70
+ }
71
+ /** Position: ms number, '<' (start of previous), '>' (end of previous, default), '+=200' / '-=200' (relative to the end), 'label', 'label+=100', '<+=100'. */
72
+ type Position = number | string;
73
+ interface TimelineOptions extends PlayOptions {
74
+ /** Defaults merged into every `.to()`. */
75
+ defaults?: Omit<TweenOptions, 'to' | 'from'>;
76
+ }
77
+ /** A sequence of tweens, nested timelines and callbacks. */
78
+ declare class Timeline extends Playable {
79
+ private children;
80
+ private labels;
81
+ private prevStart;
82
+ private prevEnd;
83
+ private defaults;
84
+ private lastLocal;
85
+ constructor(o?: TimelineOptions);
86
+ get duration(): number;
87
+ private resolve;
88
+ /** Add a tween, timeline or callback at a position. */
89
+ add(item: Playable | (() => void), position?: Position): this;
90
+ /** `tween(target, vars)` placed at `position` (stagger across several targets). */
91
+ to(target: Target | Target[] | ArrayLike<Target>, vars: TweenOptions, position?: Position): this;
92
+ call(fn: () => void, position?: Position): this;
93
+ label(name: string, position?: Position): this;
94
+ /** Time of a label, ms. */
95
+ labelTime(name: string): number | undefined;
96
+ remove(item: Playable): void;
97
+ /** Children in start order (callbacks excluded). */
98
+ getChildren(): Playable[];
99
+ protected renderLocal(ms: number): void;
100
+ }
101
+
102
+ /** A runtime module: `{ id, version, api }`, registered with `use()`. */
103
+ interface RuntimeModule<A = unknown> {
104
+ /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
105
+ id: string;
106
+ version: string;
107
+ /** Other modules this one needs (registered first by `use()` callers). */
108
+ requires?: string[];
109
+ /** The module's public API (what `requireModule(id)` returns). */
110
+ api: A;
111
+ /** Optional one-time setup, called on first registration. */
112
+ setup?(registry: RuntimeRegistry): void;
113
+ }
114
+ interface RuntimeRegistry {
115
+ version: string;
116
+ modules: Map<string, RuntimeModule>;
117
+ /** Shared per-page state slots (the ticker lives here). */
118
+ slots: Record<string, unknown>;
119
+ }
120
+
121
+ /**
122
+ * Normalised keyframes shared by the format loaders: a list of frames with
123
+ * offsets in [0, 1], camelCase props and an optional per-segment easing,
124
+ * played as a runtime `Timeline` (one tween per segment).
125
+ */
126
+
127
+ interface Frame {
128
+ offset: number;
129
+ props: Record<string, string | number>;
130
+ /** Easing from this frame to the next. */
131
+ easing?: string;
132
+ }
133
+ interface KeyframesPlayOptions extends PlayOptions {
134
+ /** ms (default 1000). */
135
+ duration?: number;
136
+ /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */
137
+ ease?: string | Ease;
138
+ }
139
+
140
+ interface KeyframesDef {
141
+ name: string;
142
+ frames: Frame[];
143
+ }
144
+ /** Parse the body of one `@keyframes` block. */
145
+ declare function parseKeyframesBody(body: string): Frame[];
146
+ /** Every `@keyframes` block in a stylesheet's text. */
147
+ declare function parseKeyframes(cssText: string): KeyframesDef[];
148
+ /** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */
149
+ declare function fromCssRule(rule: {
150
+ name: string;
151
+ cssText: string;
152
+ }): KeyframesDef;
153
+ type WaapiFrame = Record<string, unknown> & {
154
+ offset?: number | null;
155
+ easing?: string;
156
+ };
157
+ /** WAAPI keyframes (array or property-indexed form) → frames. */
158
+ declare function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[];
159
+ /** Frames in WAAPI array form (for `element.animate()`). */
160
+ declare function toWaapi(frames: Frame[]): Keyframe[];
161
+ /** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */
162
+ declare function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o?: KeyframesPlayOptions): Timeline;
163
+ interface FormatCssApi {
164
+ parseKeyframes: typeof parseKeyframes;
165
+ fromCssRule: typeof fromCssRule;
166
+ fromWaapi: typeof fromWaapi;
167
+ toWaapi: typeof toWaapi;
168
+ playKeyframes: typeof playKeyframes;
169
+ }
170
+ /** The module object for `use(formatCss)`. */
171
+ declare const formatCss: RuntimeModule<FormatCssApi>;
172
+
173
+ export { formatCss, fromCssRule, fromWaapi, parseKeyframes, parseKeyframesBody, playKeyframes, toWaapi };
174
+ export type { FormatCssApi, Frame, KeyframesDef, KeyframesPlayOptions };
@@ -0,0 +1,174 @@
1
+ /** Easing functions (t ∈ [0, 1] → progress). Original implementations of the standard Penner-style curves. */
2
+ type Ease = (t: number) => number;
3
+
4
+ type Target = object | Element;
5
+ type Props = Record<string, number | string>;
6
+ interface PlayOptions {
7
+ /** Delay before the first iteration, ms. */
8
+ delay?: number;
9
+ /** Extra iterations (-1 = forever). */
10
+ repeat?: number;
11
+ /** Alternate direction on every other iteration. */
12
+ yoyo?: boolean;
13
+ /** Start paused (`play()` to start). */
14
+ paused?: boolean;
15
+ onUpdate?: (progress: number) => void;
16
+ onComplete?: () => void;
17
+ }
18
+ interface TweenOptions extends PlayOptions {
19
+ to?: Props;
20
+ from?: Props;
21
+ /** ms (default 600). */
22
+ duration?: number;
23
+ ease?: string | Ease;
24
+ /** Delay added per target index (ms) when several targets are given. */
25
+ stagger?: number;
26
+ }
27
+ /** Common playback: delay, repeat, yoyo, direction, ticker attachment, promise. */
28
+ declare abstract class Playable {
29
+ delay: number;
30
+ repeat: number;
31
+ yoyo: boolean;
32
+ /** Playback rate multiplier. */
33
+ timeScale: number;
34
+ onUpdate?: (progress: number) => void;
35
+ onComplete?: () => void;
36
+ protected _t: number;
37
+ private _dir;
38
+ private _off;
39
+ private _done;
40
+ private _resolve;
41
+ /** Resolves on completion (forward end, or start when reversed). */
42
+ finished: Promise<void>;
43
+ /** Set when owned by a timeline (then the ticker never drives it). */
44
+ parent: Timeline | null;
45
+ constructor(o: PlayOptions);
46
+ /** One iteration, ms. */
47
+ abstract get duration(): number;
48
+ /** Render at `ms` into one iteration. */
49
+ protected abstract renderLocal(ms: number, iterationEnded: boolean): void;
50
+ get totalDuration(): number;
51
+ get time(): number;
52
+ get progress(): number;
53
+ set progress(p: number);
54
+ get isActive(): boolean;
55
+ get reversed(): boolean;
56
+ /** Jump to `ms` (total time, including the delay) and render. */
57
+ seek(ms: number): this;
58
+ play(): this;
59
+ pause(): this;
60
+ /** Play backwards from the current time. */
61
+ reverse(): this;
62
+ restart(): this;
63
+ /** Stop and detach for good. */
64
+ kill(): void;
65
+ /** Promise-like: `await tween(...)`. */
66
+ then<R>(ok?: (v: void) => R, err?: (e: unknown) => R): Promise<R>;
67
+ private attach;
68
+ private advance;
69
+ protected complete(): void;
70
+ }
71
+ /** Position: ms number, '<' (start of previous), '>' (end of previous, default), '+=200' / '-=200' (relative to the end), 'label', 'label+=100', '<+=100'. */
72
+ type Position = number | string;
73
+ interface TimelineOptions extends PlayOptions {
74
+ /** Defaults merged into every `.to()`. */
75
+ defaults?: Omit<TweenOptions, 'to' | 'from'>;
76
+ }
77
+ /** A sequence of tweens, nested timelines and callbacks. */
78
+ declare class Timeline extends Playable {
79
+ private children;
80
+ private labels;
81
+ private prevStart;
82
+ private prevEnd;
83
+ private defaults;
84
+ private lastLocal;
85
+ constructor(o?: TimelineOptions);
86
+ get duration(): number;
87
+ private resolve;
88
+ /** Add a tween, timeline or callback at a position. */
89
+ add(item: Playable | (() => void), position?: Position): this;
90
+ /** `tween(target, vars)` placed at `position` (stagger across several targets). */
91
+ to(target: Target | Target[] | ArrayLike<Target>, vars: TweenOptions, position?: Position): this;
92
+ call(fn: () => void, position?: Position): this;
93
+ label(name: string, position?: Position): this;
94
+ /** Time of a label, ms. */
95
+ labelTime(name: string): number | undefined;
96
+ remove(item: Playable): void;
97
+ /** Children in start order (callbacks excluded). */
98
+ getChildren(): Playable[];
99
+ protected renderLocal(ms: number): void;
100
+ }
101
+
102
+ /** A runtime module: `{ id, version, api }`, registered with `use()`. */
103
+ interface RuntimeModule<A = unknown> {
104
+ /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
105
+ id: string;
106
+ version: string;
107
+ /** Other modules this one needs (registered first by `use()` callers). */
108
+ requires?: string[];
109
+ /** The module's public API (what `requireModule(id)` returns). */
110
+ api: A;
111
+ /** Optional one-time setup, called on first registration. */
112
+ setup?(registry: RuntimeRegistry): void;
113
+ }
114
+ interface RuntimeRegistry {
115
+ version: string;
116
+ modules: Map<string, RuntimeModule>;
117
+ /** Shared per-page state slots (the ticker lives here). */
118
+ slots: Record<string, unknown>;
119
+ }
120
+
121
+ /**
122
+ * Normalised keyframes shared by the format loaders: a list of frames with
123
+ * offsets in [0, 1], camelCase props and an optional per-segment easing,
124
+ * played as a runtime `Timeline` (one tween per segment).
125
+ */
126
+
127
+ interface Frame {
128
+ offset: number;
129
+ props: Record<string, string | number>;
130
+ /** Easing from this frame to the next. */
131
+ easing?: string;
132
+ }
133
+ interface KeyframesPlayOptions extends PlayOptions {
134
+ /** ms (default 1000). */
135
+ duration?: number;
136
+ /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */
137
+ ease?: string | Ease;
138
+ }
139
+
140
+ interface KeyframesDef {
141
+ name: string;
142
+ frames: Frame[];
143
+ }
144
+ /** Parse the body of one `@keyframes` block. */
145
+ declare function parseKeyframesBody(body: string): Frame[];
146
+ /** Every `@keyframes` block in a stylesheet's text. */
147
+ declare function parseKeyframes(cssText: string): KeyframesDef[];
148
+ /** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */
149
+ declare function fromCssRule(rule: {
150
+ name: string;
151
+ cssText: string;
152
+ }): KeyframesDef;
153
+ type WaapiFrame = Record<string, unknown> & {
154
+ offset?: number | null;
155
+ easing?: string;
156
+ };
157
+ /** WAAPI keyframes (array or property-indexed form) → frames. */
158
+ declare function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[];
159
+ /** Frames in WAAPI array form (for `element.animate()`). */
160
+ declare function toWaapi(frames: Frame[]): Keyframe[];
161
+ /** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */
162
+ declare function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o?: KeyframesPlayOptions): Timeline;
163
+ interface FormatCssApi {
164
+ parseKeyframes: typeof parseKeyframes;
165
+ fromCssRule: typeof fromCssRule;
166
+ fromWaapi: typeof fromWaapi;
167
+ toWaapi: typeof toWaapi;
168
+ playKeyframes: typeof playKeyframes;
169
+ }
170
+ /** The module object for `use(formatCss)`. */
171
+ declare const formatCss: RuntimeModule<FormatCssApi>;
172
+
173
+ export { formatCss, fromCssRule, fromWaapi, parseKeyframes, parseKeyframesBody, playKeyframes, toWaapi };
174
+ export type { FormatCssApi, Frame, KeyframesDef, KeyframesPlayOptions };
@@ -0,0 +1,2 @@
1
+ !function(e,t,s,o){"use strict";const r=e=>e.startsWith("--")?e:e.trim().replace(/-([a-z])/g,(e,t)=>t.toUpperCase());function n(e){if(!e||"none"===e)return{x:0,y:0,rotate:0,scale:1};const t={},s=/([a-zA-Z][a-zA-Z0-9]*)\(([^)]*)\)/g;let o,r=e;for(;o=s.exec(e);){r=r.replace(o[0],"");const e=o[2].split(/[\s,]+/).filter(Boolean);switch(o[1]){case"translate":t.x=e[0],t.y=e[1]??0;break;case"translateX":t.x=e[0];break;case"translateY":t.y=e[0];break;case"translate3d":if(0!==parseFloat(e[2]||"0"))return null;t.x=e[0],t.y=e[1]??0;break;case"scale3d":if(1!==parseFloat(e[2]??"1"))return null;void 0!==e[1]&&e[1]!==e[0]?(t.scaleX=+e[0],t.scaleY=+e[1]):t.scale=+e[0];break;case"rotate":case"rotateZ":t.rotate=e[0];break;case"scale":void 0!==e[1]&&e[1]!==e[0]?(t.scaleX=+e[0],t.scaleY=+e[1]):t.scale=+e[0];break;case"scaleX":t.scaleX=+e[0];break;case"scaleY":t.scaleY=+e[0];break;case"skewX":t.skewX=e[0];break;case"skewY":t.skewY=e[0];break;default:return null}}return r.trim()?null:t}function a(e){const t={};for(const[s,o]of Object.entries(e)){if("transform"===s&&"string"==typeof o){const e=n(o);if(e){Object.assign(t,e);continue}}t[s]=o}return t}const f=e=>{try{return s.parseValue(e),!0}catch{return!1}};function i(e,t){let s=0;for(let o=t;o<e.length;o++)if("{"===e[o])s++;else if("}"===e[o]&&0===--s)return[e.slice(t+1,o),o+1];throw new Error("[motionary] format-css: unbalanced braces in @keyframes")}function c(e){const t={};let s,o=0,n="";const a=[];for(const t of e)"("===t&&o++,")"===t&&o--,";"!==t||o?n+=t:(a.push(n),n="");a.push(n);for(const e of a){const o=e.indexOf(":");if(o<0)continue;const n=e.slice(0,o).trim(),a=e.slice(o+1).replace(/!important/i,"").trim();n&&a&&("animation-timing-function"===n||"-webkit-animation-timing-function"===n?s=a:t[r(n)]=a)}return{props:t,easing:s}}const l=e=>{const t=e.trim().toLowerCase();if("from"===t)return 0;if("to"===t)return 1;const s=parseFloat(t);if(!t.endsWith("%")||!Number.isFinite(s))throw new Error(`[motionary] format-css: bad keyframe selector "${e}"`);return s/100};function p(e){const t=[];let s=0;for(;s<e.length;){const o=e.indexOf("{",s);if(o<0)break;const r=e.slice(s,o),[n,a]=i(e,o),f=c(n);for(const e of r.split(","))e.trim()&&t.push({offset:l(e),props:{...f.props},...f.easing?{easing:f.easing}:{}});s=a}const o=new Map;for(const e of t.sort((e,t)=>e.offset-t.offset)){const t=o.get(e.offset);o.set(e.offset,t?{offset:e.offset,props:{...t.props,...e.props},easing:e.easing??t.easing}:e)}return Array.from(o.values())}function u(e){const t=(e=>e.replace(/\/\*[\s\S]*?\*\//g,""))(e),s=[],o=/@(?:-webkit-|-moz-)?keyframes\s+(["']?)([\w-]+)\1\s*\{/g;let r;for(;r=o.exec(t);){const[e,n]=i(t,r.index+r[0].length-1);s.push({name:r[2],frames:p(e)}),o.lastIndex=n}return s}function m(e){const t=e.cssText,s=t.indexOf("{");return{name:e.name,frames:p(i(t,s)[0])}}function y(e){let t;if(Array.isArray(e))t=e;else{const s=Math.max(...Object.entries(e).filter(([e])=>"easing"!==e&&"offset"!==e&&"composite"!==e).map(([,e])=>Array.isArray(e)?e.length:1));t=Array.from({length:s},(t,o)=>{const r={};for(const[t,n]of Object.entries(e)){if("composite"===t)continue;const e=Array.isArray(n)?n:[n];if("offset"!==t){if("easing"===t){const t=e[Math.min(o,e.length-1)];void 0!==t&&(r.easing=t);continue}1===e.length&&s>1?o===s-1&&(r[t]=e[0]):void 0!==e[o]&&(r[t]=e[o])}else void 0!==e[o]&&(r.offset=e[o])}return r})}return function(e){const t=e.map(e=>({...e}));if(!t.length)return t;null==t[0].offset&&(t[0].offset=1===t.length?1:0),null==t[t.length-1].offset&&(t[t.length-1].offset=1);let s=0;for(;s<t.length;){if(null!=t[s].offset){s++;continue}const e=s-1;let o=s;for(;null==t[o].offset;)o++;const r=t[e].offset,n=t[o].offset;for(let a=s;a<o;a++)t[a].offset=r+(n-r)*(a-e)/(o-e);s=o}return t}(t).map(e=>{const t={};for(const[s,o]of Object.entries(e))"offset"===s||"easing"===s||"composite"===s||"string"!=typeof o&&"number"!=typeof o||(t[r("cssFloat"===s?"float":s)]=o);return{offset:e.offset,props:t,...e.easing?{easing:e.easing}:{}}})}function g(e){return e.map(e=>({...e.props,offset:e.offset,...e.easing?{easing:e.easing}:{}}))}function d(e,t,r={}){return function(e,t,r={}){const n=r.duration??1e3,i=[...t].sort((e,t)=>e.offset-t.offset).map(e=>({...e,props:a(e.props)})),c=new s.Timeline({repeat:r.repeat,yoyo:r.yoyo,delay:r.delay,onUpdate:r.onUpdate,onComplete:r.onComplete}),l=Array.from(new Set(i.flatMap(e=>Object.keys(e.props)))),p=i.map(e=>({...e,props:{...e.props}}));for(const e of l){let t,s;for(const s of p)e in s.props?t=s.props[e]:void 0!==t&&(s.props[e]=t);for(let t=p.length-1;t>=0;t--)e in p[t].props?s=p[t].props[e]:void 0!==s&&(p[t].props[e]=s)}const u=r.ease??"linear";1===p.length&&p.unshift({...p[0],offset:0});for(let t=0;t<p.length-1;t++){const r=p[t],a=p[t+1],i=Math.max(0,(a.offset-r.offset)*n),m={},y={},g=[];for(const e of l)f(r.props[e])&&f(a.props[e])?(m[e]=r.props[e],y[e]=a.props[e]):g.push([e,a.props[e]]);c.add(new s.Tween(e,{from:m,to:y,duration:i,ease:r.easing?o.parseEase(r.easing):u,paused:!0}),r.offset*n);for(const[t,s]of g)c.call(()=>{e.style?e.style.setProperty(t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),String(s)):e[t]=s},r.offset*n+i/2)}return!1===r.paused&&c.play(),c}(e,Array.isArray(t)?t:t.frames,{...r,paused:r.paused??!1})}const h={id:"format-css",version:t.RUNTIME_VERSION,requires:["core"],api:{parseKeyframes:u,fromCssRule:m,fromWaapi:y,toWaapi:g,playKeyframes:d}};t.register(h),e.formatCss=h,e.fromCssRule=m,e.fromWaapi=y,e.parseKeyframes=u,e.parseKeyframesBody=p,e.playKeyframes=d,e.toWaapi=g}(this.MotionaryRuntime=this.MotionaryRuntime||{},MotionaryRuntime,MotionaryRuntime,MotionaryRuntime);
2
+ //# sourceMappingURL=format-css.iife.js.map