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,208 @@
1
+ /** A runtime module: `{ id, version, api }`, registered with `use()`. */
2
+ interface RuntimeModule<A = unknown> {
3
+ /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
4
+ id: string;
5
+ version: string;
6
+ /** Other modules this one needs (registered first by `use()` callers). */
7
+ requires?: string[];
8
+ /** The module's public API (what `requireModule(id)` returns). */
9
+ api: A;
10
+ /** Optional one-time setup, called on first registration. */
11
+ setup?(registry: RuntimeRegistry): void;
12
+ }
13
+ interface RuntimeRegistry {
14
+ version: string;
15
+ modules: Map<string, RuntimeModule>;
16
+ /** Shared per-page state slots (the ticker lives here). */
17
+ slots: Record<string, unknown>;
18
+ }
19
+
20
+ /** Easing functions (t ∈ [0, 1] → progress). Original implementations of the standard Penner-style curves. */
21
+ type Ease = (t: number) => number;
22
+
23
+ type Target = object | Element;
24
+ type Props = Record<string, number | string>;
25
+ interface PlayOptions {
26
+ /** Delay before the first iteration, ms. */
27
+ delay?: number;
28
+ /** Extra iterations (-1 = forever). */
29
+ repeat?: number;
30
+ /** Alternate direction on every other iteration. */
31
+ yoyo?: boolean;
32
+ /** Start paused (`play()` to start). */
33
+ paused?: boolean;
34
+ onUpdate?: (progress: number) => void;
35
+ onComplete?: () => void;
36
+ }
37
+ interface TweenOptions extends PlayOptions {
38
+ to?: Props;
39
+ from?: Props;
40
+ /** ms (default 600). */
41
+ duration?: number;
42
+ ease?: string | Ease;
43
+ /** Delay added per target index (ms) when several targets are given. */
44
+ stagger?: number;
45
+ }
46
+ /** Common playback: delay, repeat, yoyo, direction, ticker attachment, promise. */
47
+ declare abstract class Playable {
48
+ delay: number;
49
+ repeat: number;
50
+ yoyo: boolean;
51
+ /** Playback rate multiplier. */
52
+ timeScale: number;
53
+ onUpdate?: (progress: number) => void;
54
+ onComplete?: () => void;
55
+ protected _t: number;
56
+ private _dir;
57
+ private _off;
58
+ private _done;
59
+ private _resolve;
60
+ /** Resolves on completion (forward end, or start when reversed). */
61
+ finished: Promise<void>;
62
+ /** Set when owned by a timeline (then the ticker never drives it). */
63
+ parent: Timeline | null;
64
+ constructor(o: PlayOptions);
65
+ /** One iteration, ms. */
66
+ abstract get duration(): number;
67
+ /** Render at `ms` into one iteration. */
68
+ protected abstract renderLocal(ms: number, iterationEnded: boolean): void;
69
+ get totalDuration(): number;
70
+ get time(): number;
71
+ get progress(): number;
72
+ set progress(p: number);
73
+ get isActive(): boolean;
74
+ get reversed(): boolean;
75
+ /** Jump to `ms` (total time, including the delay) and render. */
76
+ seek(ms: number): this;
77
+ play(): this;
78
+ pause(): this;
79
+ /** Play backwards from the current time. */
80
+ reverse(): this;
81
+ restart(): this;
82
+ /** Stop and detach for good. */
83
+ kill(): void;
84
+ /** Promise-like: `await tween(...)`. */
85
+ then<R>(ok?: (v: void) => R, err?: (e: unknown) => R): Promise<R>;
86
+ private attach;
87
+ private advance;
88
+ protected complete(): void;
89
+ }
90
+ /** Position: ms number, '<' (start of previous), '>' (end of previous, default), '+=200' / '-=200' (relative to the end), 'label', 'label+=100', '<+=100'. */
91
+ type Position = number | string;
92
+ interface TimelineOptions extends PlayOptions {
93
+ /** Defaults merged into every `.to()`. */
94
+ defaults?: Omit<TweenOptions, 'to' | 'from'>;
95
+ }
96
+ /** A sequence of tweens, nested timelines and callbacks. */
97
+ declare class Timeline extends Playable {
98
+ private children;
99
+ private labels;
100
+ private prevStart;
101
+ private prevEnd;
102
+ private defaults;
103
+ private lastLocal;
104
+ constructor(o?: TimelineOptions);
105
+ get duration(): number;
106
+ private resolve;
107
+ /** Add a tween, timeline or callback at a position. */
108
+ add(item: Playable | (() => void), position?: Position): this;
109
+ /** `tween(target, vars)` placed at `position` (stagger across several targets). */
110
+ to(target: Target | Target[] | ArrayLike<Target>, vars: TweenOptions, position?: Position): this;
111
+ call(fn: () => void, position?: Position): this;
112
+ label(name: string, position?: Position): this;
113
+ /** Time of a label, ms. */
114
+ labelTime(name: string): number | undefined;
115
+ remove(item: Playable): void;
116
+ /** Children in start order (callbacks excluded). */
117
+ getChildren(): Playable[];
118
+ protected renderLocal(ms: number): void;
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
+
134
+ /**
135
+ * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
136
+ * keyframe JSON with the runtime:
137
+ *
138
+ * ```json
139
+ * { "initial": { "opacity": 0, "y": 40 },
140
+ * "animate": { "opacity": 1, "y": [40, -8, 0], "rotate": 0 },
141
+ * "transition": { "duration": 0.6, "ease": "easeOut", "times": [0, 0.7, 1], "delay": 0.1,
142
+ * "repeat": 1, "repeatType": "reverse", "opacity": { "duration": 0.3 } } }
143
+ * ```
144
+ *
145
+ * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as
146
+ * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,
147
+ * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /
148
+ * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),
149
+ * per-property transitions, and `type: "spring"` (`stiffness`, `damping`, `mass`,
150
+ * or `bounce` + `duration`) simulated into an easing curve.
151
+ * Not supported: `layout`, gestures (`whileHover` …), variants propagation,
152
+ * `staggerChildren` (use the runtime timeline `stagger`).
153
+ */
154
+
155
+ type V = number | string;
156
+ interface MotionTransition {
157
+ duration?: number;
158
+ delay?: number;
159
+ ease?: string | number[] | (string | number[])[];
160
+ times?: number[];
161
+ repeat?: number;
162
+ repeatType?: 'loop' | 'reverse' | 'mirror';
163
+ type?: 'tween' | 'spring' | 'keyframes' | 'inertia';
164
+ stiffness?: number;
165
+ damping?: number;
166
+ mass?: number;
167
+ bounce?: number;
168
+ [prop: string]: unknown;
169
+ }
170
+ interface MotionDef {
171
+ initial?: Record<string, V> | false;
172
+ animate: Record<string, V | V[]>;
173
+ transition?: MotionTransition;
174
+ }
175
+ /** A Motion ease → runtime ease. */
176
+ declare function motionEase(e: string | number[] | undefined): Ease;
177
+ /** Simulate a damped spring (unit step) → [ease, duration ms]. */
178
+ declare function springEase(o: {
179
+ stiffness?: number;
180
+ damping?: number;
181
+ mass?: number;
182
+ bounce?: number;
183
+ duration?: number;
184
+ }): [Ease, number];
185
+ /** Motion def → one keyframe track per transition group (`[frames, transition]`). */
186
+ declare function fromMotion(def: MotionDef): {
187
+ frames: Frame[];
188
+ transition: MotionTransition;
189
+ props: string[];
190
+ }[];
191
+ /**
192
+ * Apply `initial` immediately and play `animate` with the transition.
193
+ * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.
194
+ */
195
+ declare function playMotion(target: Target, def: MotionDef, o?: {
196
+ paused?: boolean;
197
+ }): Timeline;
198
+ interface FormatMotionApi {
199
+ fromMotion: typeof fromMotion;
200
+ playMotion: typeof playMotion;
201
+ springEase: typeof springEase;
202
+ motionEase: typeof motionEase;
203
+ }
204
+ /** The module object for `use(formatMotion)`. */
205
+ declare const formatMotion: RuntimeModule<FormatMotionApi>;
206
+
207
+ export { formatMotion, fromMotion, motionEase, playMotion, springEase };
208
+ export type { FormatMotionApi, MotionDef, MotionTransition };
@@ -0,0 +1,2 @@
1
+ !function(e,t,r,a){"use strict";function o(e){if(!e||"none"===e)return{x:0,y:0,rotate:0,scale:1};const t={},r=/([a-zA-Z][a-zA-Z0-9]*)\(([^)]*)\)/g;let a,o=e;for(;a=r.exec(e);){o=o.replace(a[0],"");const e=a[2].split(/[\s,]+/).filter(Boolean);switch(a[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 o.trim()?null:t}function n(e){const t={};for(const[r,a]of Object.entries(e)){if("transform"===r&&"string"==typeof a){const e=o(a);if(e){Object.assign(t,e);continue}}t[r]=a}return t}const s=e=>{try{return r.parseValue(e),!0}catch{return!1}};function i(e,t,o={}){const i=o.duration??1e3,c=[...t].sort((e,t)=>e.offset-t.offset).map(e=>({...e,props:n(e.props)})),p=new r.Timeline({repeat:o.repeat,yoyo:o.yoyo,delay:o.delay,onUpdate:o.onUpdate,onComplete:o.onComplete}),f=Array.from(new Set(c.flatMap(e=>Object.keys(e.props)))),l=c.map(e=>({...e,props:{...e.props}}));for(const e of f){let t,r;for(const r of l)e in r.props?t=r.props[e]:void 0!==t&&(r.props[e]=t);for(let t=l.length-1;t>=0;t--)e in l[t].props?r=l[t].props[e]:void 0!==r&&(l[t].props[e]=r)}const u=o.ease??"linear";1===l.length&&l.unshift({...l[0],offset:0});for(let t=0;t<l.length-1;t++){const o=l[t],n=l[t+1],c=Math.max(0,(n.offset-o.offset)*i),y={},m={},b=[];for(const e of f)s(o.props[e])&&s(n.props[e])?(y[e]=o.props[e],m[e]=n.props[e]):b.push([e,n.props[e]]);p.add(new r.Tween(e,{from:y,to:m,duration:c,ease:o.easing?a.parseEase(o.easing):u,paused:!0}),o.offset*i);for(const[t,r]of b)p.call(()=>{e.style?e.style.setProperty(t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase()),String(r)):e[t]=r},o.offset*i+c/2)}return!1===o.paused&&p.play(),p}const c={linear:"linear",easeIn:"cubic-in",easeOut:"cubic-out",easeInOut:"cubic-in-out",circIn:"circ-in",circOut:"circ-out",circInOut:"circ-in-out",backIn:"back-in",backOut:"back-out",backInOut:"back-in-out",anticipate:"back-in-out"};function p(e){if(Array.isArray(e))return a.cubicBezier(e[0],e[1],e[2],e[3]);if(!e)return a.EASES["cubic-out"];const t=c[e]||e;if(!a.EASES[t])throw new Error(`[motionary] format-motion: unknown ease "${e}"`);return a.EASES[t]}function f(e){let t=e.stiffness??100,r=e.damping??10;const a=e.mass??1;if(void 0!==e.bounce&&void 0!==e.duration){const o=1-Math.min(.95,Math.max(0,e.bounce)),n=2*Math.PI/Math.max(.05,e.duration);t=a*n*n,r=2*o*Math.sqrt(t*a)}const o=1/120,n=[0];let s=0,i=0,c=0,p=0;for(;c<10;){if(i+=(-t*(s-1)-r*i)/a*o,s+=i*o,c+=o,n.push(s),Math.abs(s-1)<.001&&Math.abs(i)<.01){if(++p>12)break}else p=0}const f=n.length-1;n[f]=1;return[e=>{if(e<=0)return 0;if(e>=1)return 1;const t=e*f,r=Math.floor(t);return n[r]+(n[r+1]-n[r])*(t-r)},Math.round(1e3*c)]}function l(e){const t=e.transition||{},r=new Map;for(const a of Object.keys(e.animate)){const e=t[a]&&"object"==typeof t[a]?a:"";r.set(e,[...r.get(e)||[],a])}return Array.from(r.entries()).map(([r,a])=>{const o=r?{...t,...t[r]}:t,n=Math.max(...a.map(t=>Array.isArray(e.animate[t])?e.animate[t].length:1)),s=Math.max(2,n),i=(o.times&&o.times.length===s?o.times:Array.from({length:s},(e,t)=>t/(s-1))).map(e=>({offset:e,props:{}}));for(const t of a){const r=e.animate[t],a=Array.isArray(r)?r:[e.initial&&t in e.initial?e.initial[t]:void 0,r];(a.length===s?a:[...Array(s-a.length).fill(a[0]),...a]).forEach((e,r)=>{null!=e&&(i[r].props[t]=e)})}return Array.isArray(o.ease)&&o.ease.length&&(Array.isArray(o.ease[0])||"string"==typeof o.ease[0])&&o.ease.forEach((e,t)=>{i[t]&&(i[t].easing=Array.isArray(e)?`cubic-bezier(${e.join(",")})`:c[e]||e)}),{frames:i,transition:o,props:a}})}function u(e,t,a={}){const o=new r.Timeline({});if(t.initial)for(const[r,a]of Object.entries(t.initial))i(e,[{offset:0,props:{[r]:a}}],{duration:0}).seek(0);for(const{frames:r,transition:a}of l(t)){let t,n=1e3*(a.duration??.3);"spring"===a.type?[t,n]=f({...a,duration:a.duration}):Array.isArray(a.ease)&&"number"!=typeof a.ease[0]||(t=p(a.ease));const s=a.repeat===1/0?-1:a.repeat||0,c=i(e,r,{duration:n,ease:t,repeat:s,yoyo:0!==s&&"loop"!==a.repeatType&&!!a.repeatType});o.add(c,1e3*(a.delay||0))}return a.paused||o.play(),o}const y={id:"format-motion",version:t.RUNTIME_VERSION,requires:["core"],api:{fromMotion:l,playMotion:u,springEase:f,motionEase:p}};t.register(y),e.formatMotion=y,e.fromMotion=l,e.motionEase=p,e.playMotion=u,e.springEase=f}(this.MotionaryRuntime=this.MotionaryRuntime||{},MotionaryRuntime,MotionaryRuntime,MotionaryRuntime);
2
+ //# sourceMappingURL=format-motion.iife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-motion.iife.js","sources":["../../src/runtime/keyframes.ts","../../src/runtime/format-motion.ts","../../src/runtime/iife/format-motion.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","/**\n * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style\n * keyframe JSON with the runtime:\n *\n * ```json\n * { \"initial\": { \"opacity\": 0, \"y\": 40 },\n * \"animate\": { \"opacity\": 1, \"y\": [40, -8, 0], \"rotate\": 0 },\n * \"transition\": { \"duration\": 0.6, \"ease\": \"easeOut\", \"times\": [0, 0.7, 1], \"delay\": 0.1,\n * \"repeat\": 1, \"repeatType\": \"reverse\", \"opacity\": { \"duration\": 0.3 } } }\n * ```\n *\n * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as\n * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,\n * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /\n * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),\n * per-property transitions, and `type: \"spring\"` (`stiffness`, `damping`, `mass`,\n * or `bounce` + `duration`) simulated into an easing curve.\n * Not supported: `layout`, gestures (`whileHover` …), variants propagation,\n * `staggerChildren` (use the runtime timeline `stagger`).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Timeline, type Target } from './tween';\nimport { cubicBezier, type Ease, EASES } from './ease';\nimport { framesToTimeline, type Frame } from './keyframes';\n\ntype V = number | string;\nexport interface MotionTransition {\n duration?: number;\n delay?: number;\n ease?: string | number[] | (string | number[])[];\n times?: number[];\n repeat?: number;\n repeatType?: 'loop' | 'reverse' | 'mirror';\n type?: 'tween' | 'spring' | 'keyframes' | 'inertia';\n stiffness?: number;\n damping?: number;\n mass?: number;\n bounce?: number;\n [prop: string]: unknown;\n}\nexport interface MotionDef {\n initial?: Record<string, V> | false;\n animate: Record<string, V | V[]>;\n transition?: MotionTransition;\n}\n\nconst NAMES: Record<string, string> = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };\n\n/** A Motion ease → runtime ease. */\nexport function motionEase(e: string | number[] | undefined): Ease {\n if (Array.isArray(e)) return cubicBezier(e[0], e[1], e[2], e[3]);\n if (!e) return EASES['cubic-out'];\n const n = NAMES[e] || e;\n if (!EASES[n]) throw new Error(`[motionary] format-motion: unknown ease \"${e}\"`);\n return EASES[n];\n}\n\n/** Simulate a damped spring (unit step) → [ease, duration ms]. */\nexport function springEase(o: { stiffness?: number; damping?: number; mass?: number; bounce?: number; duration?: number }): [Ease, number] {\n let k = o.stiffness ?? 100, c = o.damping ?? 10;\n const m = o.mass ?? 1;\n if (o.bounce !== undefined && o.duration !== undefined) {\n // map bounce + duration to stiffness / damping (critical damping at bounce 0)\n const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));\n const w = (2 * Math.PI) / Math.max(0.05, o.duration);\n k = m * w * w;\n c = 2 * zeta * Math.sqrt(k * m);\n }\n const dt = 1 / 120;\n const samples: number[] = [0];\n let x = 0, v = 0, t = 0, still = 0;\n while (t < 10) {\n const a = (-k * (x - 1) - c * v) / m;\n v += a * dt;\n x += v * dt;\n t += dt;\n samples.push(x);\n if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) { if (++still > 12) break; } else still = 0;\n }\n const n = samples.length - 1;\n samples[n] = 1;\n const ease: Ease = (p) => {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n const f = p * n, i = Math.floor(f);\n return samples[i] + (samples[i + 1] - samples[i]) * (f - i);\n };\n return [ease, Math.round(t * 1000)];\n}\n\n/** Motion def → one keyframe track per transition group (`[frames, transition]`). */\nexport function fromMotion(def: MotionDef): { frames: Frame[]; transition: MotionTransition; props: string[] }[] {\n const base = def.transition || {};\n const groups = new Map<string, string[]>();\n for (const k of Object.keys(def.animate)) {\n const own = base[k] && typeof base[k] === 'object' ? k : '';\n groups.set(own, [...(groups.get(own) || []), k]);\n }\n return Array.from(groups.entries()).map(([g, props]) => {\n const tr: MotionTransition = g ? { ...base, ...(base[g] as MotionTransition) } : base;\n const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? (def.animate[p] as V[]).length : 1)));\n const n = Math.max(2, len);\n const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));\n const frames: Frame[] = times.map((offset) => ({ offset, props: {} }));\n for (const p of props) {\n const v = def.animate[p];\n const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];\n const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];\n list.forEach((x, i) => { if (x !== undefined && x !== null) frames[i].props[p] = x as V; });\n }\n if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {\n (tr.ease as (string | number[])[]).forEach((e, i) => { if (frames[i]) frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });\n }\n return { frames, transition: tr, props };\n });\n}\n\n/**\n * Apply `initial` immediately and play `animate` with the transition.\n * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.\n */\nexport function playMotion(target: Target, def: MotionDef, o: { paused?: boolean } = {}): Timeline {\n const tl = new Timeline({});\n if (def.initial) for (const [k, v] of Object.entries(def.initial)) framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);\n for (const { frames, transition: tr } of fromMotion(def)) {\n let ease: Ease | undefined;\n let dur = (tr.duration ?? 0.3) * 1000;\n if (tr.type === 'spring') [ease, dur] = springEase({ ...tr, duration: tr.duration });\n else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number') ease = motionEase(tr.ease as string | number[] | undefined);\n const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;\n const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });\n tl.add(child, (tr.delay || 0) * 1000);\n }\n if (!o.paused) tl.play();\n return tl;\n}\n\nexport interface FormatMotionApi {\n fromMotion: typeof fromMotion;\n playMotion: typeof playMotion;\n springEase: typeof springEase;\n motionEase: typeof motionEase;\n}\n\n/** The module object for `use(formatMotion)`. */\nexport const formatMotion: RuntimeModule<FormatMotionApi> = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };\n","// CDN build: load runtime.iife.js first, then this file → registers motionary/runtime/format-motion and adds its API to window.MotionaryRuntime.\nimport { register } from '../registry';\nimport { formatMotion } from '../format-motion';\nexport * from '../format-motion';\nregister(formatMotion);\n"],"names":["transformToProps","t","x","y","rotate","scale","out","re","m","rest","exec","replace","args","split","filter","Boolean","parseFloat","undefined","scaleX","scaleY","skewX","skewY","trim","expandProps","props","k","v","Object","entries","assign","tweenable","parseValue","framesToTimeline","target","frames","o","dur","duration","fs","sort","a","b","offset","map","f","tl","Timeline","repeat","yoyo","delay","onUpdate","onComplete","keys","Array","from","Set","flatMap","filled","last","next","i","length","def","ease","unshift","segDur","Math","max","to","discrete","push","add","Tween","easing","parseEase","paused","call","style","setProperty","c","toLowerCase","String","play","NAMES","linear","easeIn","easeOut","easeInOut","circIn","circOut","circInOut","backIn","backOut","backInOut","anticipate","motionEase","e","isArray","cubicBezier","EASES","n","Error","springEase","stiffness","damping","mass","bounce","zeta","min","w","PI","sqrt","dt","samples","still","abs","p","floor","round","fromMotion","base","transition","groups","Map","animate","own","set","get","g","tr","len","times","_","arr","initial","fill","forEach","join","playMotion","seek","type","rep","Infinity","child","repeatType","formatMotion","id","version","RUNTIME_VERSION","requires","api","register"],"mappings":"gCA4CM,SAAUA,EAAiBC,GAC/B,IAAKA,GAAW,SAANA,EAAc,MAAO,CAAEC,EAAG,EAAGC,EAAG,EAAGC,OAAQ,EAAGC,MAAO,GAC/D,MAAMC,EAAuC,CAAA,EACvCC,EAAK,qCACX,IAAIC,EACAC,EAAOR,EACX,KAAQO,EAAID,EAAGG,KAAKT,IAAK,CACvBQ,EAAOA,EAAKE,QAAQH,EAAE,GAAI,IAC1B,MAAMI,EAAOJ,EAAE,GAAGK,MAAM,UAAUC,OAAOC,SAC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CACT,CAUO,MAAMoG,EAA+C,CAAEC,GAAI,gBAAiBC,QAASC,EAAAA,gBAAiBC,SAAU,CAAC,QAASC,IAAK,CAAE/B,aAAYmB,aAAYpC,aAAYP,eC7I5KwD,EAAAA,SAASN"}
@@ -0,0 +1,132 @@
1
+ import { R as RUNTIME_VERSION } from '../chunks/registry-jF8VIA_9.js';
2
+ import { c as cubicBezier, E as EASES, T as Timeline } from '../chunks/tween-DDObu9iA.js';
3
+ import { f as framesToTimeline } from '../chunks/keyframes-CyH_abhI.js';
4
+
5
+ /**
6
+ * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
7
+ * keyframe JSON with the runtime:
8
+ *
9
+ * ```json
10
+ * { "initial": { "opacity": 0, "y": 40 },
11
+ * "animate": { "opacity": 1, "y": [40, -8, 0], "rotate": 0 },
12
+ * "transition": { "duration": 0.6, "ease": "easeOut", "times": [0, 0.7, 1], "delay": 0.1,
13
+ * "repeat": 1, "repeatType": "reverse", "opacity": { "duration": 0.3 } } }
14
+ * ```
15
+ *
16
+ * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as
17
+ * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,
18
+ * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /
19
+ * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),
20
+ * per-property transitions, and `type: "spring"` (`stiffness`, `damping`, `mass`,
21
+ * or `bounce` + `duration`) simulated into an easing curve.
22
+ * Not supported: `layout`, gestures (`whileHover` …), variants propagation,
23
+ * `staggerChildren` (use the runtime timeline `stagger`).
24
+ */
25
+ const NAMES = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };
26
+ /** A Motion ease → runtime ease. */
27
+ function motionEase(e) {
28
+ if (Array.isArray(e))
29
+ return cubicBezier(e[0], e[1], e[2], e[3]);
30
+ if (!e)
31
+ return EASES['cubic-out'];
32
+ const n = NAMES[e] || e;
33
+ if (!EASES[n])
34
+ throw new Error(`[motionary] format-motion: unknown ease "${e}"`);
35
+ return EASES[n];
36
+ }
37
+ /** Simulate a damped spring (unit step) → [ease, duration ms]. */
38
+ function springEase(o) {
39
+ let k = o.stiffness ?? 100, c = o.damping ?? 10;
40
+ const m = o.mass ?? 1;
41
+ if (o.bounce !== undefined && o.duration !== undefined) {
42
+ // map bounce + duration to stiffness / damping (critical damping at bounce 0)
43
+ const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));
44
+ const w = (2 * Math.PI) / Math.max(0.05, o.duration);
45
+ k = m * w * w;
46
+ c = 2 * zeta * Math.sqrt(k * m);
47
+ }
48
+ const dt = 1 / 120;
49
+ const samples = [0];
50
+ let x = 0, v = 0, t = 0, still = 0;
51
+ while (t < 10) {
52
+ const a = (-k * (x - 1) - c * v) / m;
53
+ v += a * dt;
54
+ x += v * dt;
55
+ t += dt;
56
+ samples.push(x);
57
+ if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) {
58
+ if (++still > 12)
59
+ break;
60
+ }
61
+ else
62
+ still = 0;
63
+ }
64
+ const n = samples.length - 1;
65
+ samples[n] = 1;
66
+ const ease = (p) => {
67
+ if (p <= 0)
68
+ return 0;
69
+ if (p >= 1)
70
+ return 1;
71
+ const f = p * n, i = Math.floor(f);
72
+ return samples[i] + (samples[i + 1] - samples[i]) * (f - i);
73
+ };
74
+ return [ease, Math.round(t * 1000)];
75
+ }
76
+ /** Motion def → one keyframe track per transition group (`[frames, transition]`). */
77
+ function fromMotion(def) {
78
+ const base = def.transition || {};
79
+ const groups = new Map();
80
+ for (const k of Object.keys(def.animate)) {
81
+ const own = base[k] && typeof base[k] === 'object' ? k : '';
82
+ groups.set(own, [...(groups.get(own) || []), k]);
83
+ }
84
+ return Array.from(groups.entries()).map(([g, props]) => {
85
+ const tr = g ? { ...base, ...base[g] } : base;
86
+ const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? def.animate[p].length : 1)));
87
+ const n = Math.max(2, len);
88
+ const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));
89
+ const frames = times.map((offset) => ({ offset, props: {} }));
90
+ for (const p of props) {
91
+ const v = def.animate[p];
92
+ const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];
93
+ const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];
94
+ list.forEach((x, i) => { if (x !== undefined && x !== null)
95
+ frames[i].props[p] = x; });
96
+ }
97
+ if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {
98
+ tr.ease.forEach((e, i) => { if (frames[i])
99
+ frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });
100
+ }
101
+ return { frames, transition: tr, props };
102
+ });
103
+ }
104
+ /**
105
+ * Apply `initial` immediately and play `animate` with the transition.
106
+ * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.
107
+ */
108
+ function playMotion(target, def, o = {}) {
109
+ const tl = new Timeline({});
110
+ if (def.initial)
111
+ for (const [k, v] of Object.entries(def.initial))
112
+ framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);
113
+ for (const { frames, transition: tr } of fromMotion(def)) {
114
+ let ease;
115
+ let dur = (tr.duration ?? 0.3) * 1000;
116
+ if (tr.type === 'spring')
117
+ [ease, dur] = springEase({ ...tr, duration: tr.duration });
118
+ else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number')
119
+ ease = motionEase(tr.ease);
120
+ const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;
121
+ const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });
122
+ tl.add(child, (tr.delay || 0) * 1000);
123
+ }
124
+ if (!o.paused)
125
+ tl.play();
126
+ return tl;
127
+ }
128
+ /** The module object for `use(formatMotion)`. */
129
+ const formatMotion = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };
130
+
131
+ export { formatMotion, fromMotion, motionEase, playMotion, springEase };
132
+ //# sourceMappingURL=format-motion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-motion.js","sources":["../../src/runtime/format-motion.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style\n * keyframe JSON with the runtime:\n *\n * ```json\n * { \"initial\": { \"opacity\": 0, \"y\": 40 },\n * \"animate\": { \"opacity\": 1, \"y\": [40, -8, 0], \"rotate\": 0 },\n * \"transition\": { \"duration\": 0.6, \"ease\": \"easeOut\", \"times\": [0, 0.7, 1], \"delay\": 0.1,\n * \"repeat\": 1, \"repeatType\": \"reverse\", \"opacity\": { \"duration\": 0.3 } } }\n * ```\n *\n * Supported: `initial` / `animate` (numbers, unit strings, colours, arrays as\n * keyframes), the transform shorthands `x y scale scaleX scaleY rotate skewX skewY`,\n * transition `duration` / `delay` (seconds) / `ease` (names or `[x1, y1, x2, y2]`) /\n * `times` / `repeat` (`Infinity` ok) / `repeatType` (`loop`, `reverse`, `mirror`),\n * per-property transitions, and `type: \"spring\"` (`stiffness`, `damping`, `mass`,\n * or `bounce` + `duration`) simulated into an easing curve.\n * Not supported: `layout`, gestures (`whileHover` …), variants propagation,\n * `staggerChildren` (use the runtime timeline `stagger`).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { Timeline, type Target } from './tween';\nimport { cubicBezier, type Ease, EASES } from './ease';\nimport { framesToTimeline, type Frame } from './keyframes';\n\ntype V = number | string;\nexport interface MotionTransition {\n duration?: number;\n delay?: number;\n ease?: string | number[] | (string | number[])[];\n times?: number[];\n repeat?: number;\n repeatType?: 'loop' | 'reverse' | 'mirror';\n type?: 'tween' | 'spring' | 'keyframes' | 'inertia';\n stiffness?: number;\n damping?: number;\n mass?: number;\n bounce?: number;\n [prop: string]: unknown;\n}\nexport interface MotionDef {\n initial?: Record<string, V> | false;\n animate: Record<string, V | V[]>;\n transition?: MotionTransition;\n}\n\nconst NAMES: Record<string, string> = { linear: 'linear', easeIn: 'cubic-in', easeOut: 'cubic-out', easeInOut: 'cubic-in-out', circIn: 'circ-in', circOut: 'circ-out', circInOut: 'circ-in-out', backIn: 'back-in', backOut: 'back-out', backInOut: 'back-in-out', anticipate: 'back-in-out' };\n\n/** A Motion ease → runtime ease. */\nexport function motionEase(e: string | number[] | undefined): Ease {\n if (Array.isArray(e)) return cubicBezier(e[0], e[1], e[2], e[3]);\n if (!e) return EASES['cubic-out'];\n const n = NAMES[e] || e;\n if (!EASES[n]) throw new Error(`[motionary] format-motion: unknown ease \"${e}\"`);\n return EASES[n];\n}\n\n/** Simulate a damped spring (unit step) → [ease, duration ms]. */\nexport function springEase(o: { stiffness?: number; damping?: number; mass?: number; bounce?: number; duration?: number }): [Ease, number] {\n let k = o.stiffness ?? 100, c = o.damping ?? 10;\n const m = o.mass ?? 1;\n if (o.bounce !== undefined && o.duration !== undefined) {\n // map bounce + duration to stiffness / damping (critical damping at bounce 0)\n const zeta = 1 - Math.min(0.95, Math.max(0, o.bounce));\n const w = (2 * Math.PI) / Math.max(0.05, o.duration);\n k = m * w * w;\n c = 2 * zeta * Math.sqrt(k * m);\n }\n const dt = 1 / 120;\n const samples: number[] = [0];\n let x = 0, v = 0, t = 0, still = 0;\n while (t < 10) {\n const a = (-k * (x - 1) - c * v) / m;\n v += a * dt;\n x += v * dt;\n t += dt;\n samples.push(x);\n if (Math.abs(x - 1) < 0.001 && Math.abs(v) < 0.01) { if (++still > 12) break; } else still = 0;\n }\n const n = samples.length - 1;\n samples[n] = 1;\n const ease: Ease = (p) => {\n if (p <= 0) return 0;\n if (p >= 1) return 1;\n const f = p * n, i = Math.floor(f);\n return samples[i] + (samples[i + 1] - samples[i]) * (f - i);\n };\n return [ease, Math.round(t * 1000)];\n}\n\n/** Motion def → one keyframe track per transition group (`[frames, transition]`). */\nexport function fromMotion(def: MotionDef): { frames: Frame[]; transition: MotionTransition; props: string[] }[] {\n const base = def.transition || {};\n const groups = new Map<string, string[]>();\n for (const k of Object.keys(def.animate)) {\n const own = base[k] && typeof base[k] === 'object' ? k : '';\n groups.set(own, [...(groups.get(own) || []), k]);\n }\n return Array.from(groups.entries()).map(([g, props]) => {\n const tr: MotionTransition = g ? { ...base, ...(base[g] as MotionTransition) } : base;\n const len = Math.max(...props.map((p) => (Array.isArray(def.animate[p]) ? (def.animate[p] as V[]).length : 1)));\n const n = Math.max(2, len);\n const times = tr.times && tr.times.length === n ? tr.times : Array.from({ length: n }, (_, i) => i / (n - 1));\n const frames: Frame[] = times.map((offset) => ({ offset, props: {} }));\n for (const p of props) {\n const v = def.animate[p];\n const arr = Array.isArray(v) ? v : [def.initial && p in def.initial ? def.initial[p] : undefined, v];\n const list = arr.length === n ? arr : [...Array(n - arr.length).fill(arr[0]), ...arr];\n list.forEach((x, i) => { if (x !== undefined && x !== null) frames[i].props[p] = x as V; });\n }\n if (Array.isArray(tr.ease) && tr.ease.length && (Array.isArray(tr.ease[0]) || typeof tr.ease[0] === 'string')) {\n (tr.ease as (string | number[])[]).forEach((e, i) => { if (frames[i]) frames[i].easing = Array.isArray(e) ? `cubic-bezier(${e.join(',')})` : NAMES[e] || e; });\n }\n return { frames, transition: tr, props };\n });\n}\n\n/**\n * Apply `initial` immediately and play `animate` with the transition.\n * Returns a runtime `Timeline` (one child per transition group), playing unless `paused`.\n */\nexport function playMotion(target: Target, def: MotionDef, o: { paused?: boolean } = {}): Timeline {\n const tl = new Timeline({});\n if (def.initial) for (const [k, v] of Object.entries(def.initial)) framesToTimeline(target, [{ offset: 0, props: { [k]: v } }], { duration: 0 }).seek(0);\n for (const { frames, transition: tr } of fromMotion(def)) {\n let ease: Ease | undefined;\n let dur = (tr.duration ?? 0.3) * 1000;\n if (tr.type === 'spring') [ease, dur] = springEase({ ...tr, duration: tr.duration });\n else if (!Array.isArray(tr.ease) || typeof tr.ease[0] === 'number') ease = motionEase(tr.ease as string | number[] | undefined);\n const rep = tr.repeat === Infinity ? -1 : tr.repeat || 0;\n const child = framesToTimeline(target, frames, { duration: dur, ease, repeat: rep, yoyo: rep !== 0 && tr.repeatType !== 'loop' && !!tr.repeatType });\n tl.add(child, (tr.delay || 0) * 1000);\n }\n if (!o.paused) tl.play();\n return tl;\n}\n\nexport interface FormatMotionApi {\n fromMotion: typeof fromMotion;\n playMotion: typeof playMotion;\n springEase: typeof springEase;\n motionEase: typeof motionEase;\n}\n\n/** The module object for `use(formatMotion)`. */\nexport const formatMotion: RuntimeModule<FormatMotionApi> = { id: 'format-motion', version: RUNTIME_VERSION, requires: ['core'], api: { fromMotion, playMotion, springEase, motionEase } };\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA2BH,MAAM,KAAK,GAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE;AAE9R;AACM,SAAU,UAAU,CAAC,CAAgC,EAAA;AACzD,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,OAAO,KAAK,CAAC,WAA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AI,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;AAAE,YAAA,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,IAAqC,CAAC;QAC/H,MAAM,GAAG,GAAG,EAAE,CAAC,MAAM,KAAK,QAAQ,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,IAAI,CAAC;AACxD,QAAA,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,KAAK,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC;AACpJ,QAAA,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC;IACvC;IACA,IAAI,CAAC,CAAC,CAAC,MAAM;QAAE,EAAE,CAAC,IAAI,EAAE;AACxB,IAAA,OAAO,EAAE;AACX;AASA;AACO,MAAM,YAAY,GAAmC,EAAE,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE;;;;"}
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ var registry = require('./chunks/registry-C0xLNq3-.cjs');
4
+ var tween$1 = require('./chunks/tween-JEthWrjo.cjs');
5
+
6
+ /**
7
+ * `motionary/runtime` (10.1) — Motionary's own zero-dependency animation
8
+ * runtime, the one prerequisite for runtime-powered components:
9
+ *
10
+ * - shared **ticker** (`getTicker()`): one rAF loop for everything;
11
+ * - **tween + timeline** engine with easing (`tween()`, `timeline()`, `EASES`, `cubicBezier()`);
12
+ * - **module registry** (`use()`, `requireModule()`, `hasModule()`) with a
13
+ * clear `RuntimeModuleError` (install / import / CDN instructions) when a
14
+ * component needs a module that was not registered.
15
+ *
16
+ * Every other module lives at its own subpath (`motionary/runtime/format-css`,
17
+ * `motionary/runtime/format-motion`, …) so you only pay for what you import.
18
+ * SSR-safe (no `window` access at import) and usable in Web Workers.
19
+ *
20
+ * ```ts
21
+ * import { use, tween } from 'motionary/runtime';
22
+ * use(); // registers the core (components can now find it)
23
+ * tween('.box', { to: { x: 120, opacity: 1 }, duration: 500, ease: 'back-out' });
24
+ * ```
25
+ */
26
+ /** The core as a module object. */
27
+ const core = {
28
+ id: 'core',
29
+ version: registry.RUNTIME_VERSION,
30
+ api: { version: registry.RUNTIME_VERSION, getTicker: tween$1.getTicker, tween, timeline: tween$1.timeline, Tween: tween$1.Tween, Timeline: tween$1.Timeline, EASES: tween$1.EASES, parseEase: tween$1.parseEase, cubicBezier: tween$1.cubicBezier, steps: tween$1.steps },
31
+ };
32
+ /** Tween targets (objects, elements, lists or a CSS selector). See `TweenOptions`. */
33
+ function tween(target, o) {
34
+ return tween$1.tween(resolveTargets(target), o);
35
+ }
36
+ /** Selector strings become element lists (only where `document` exists). */
37
+ function resolveTargets(t) {
38
+ if (typeof t === 'string') {
39
+ if (typeof document === 'undefined')
40
+ throw new Error('[motionary] selector targets need a document — pass objects or elements instead');
41
+ return Array.from(document.querySelectorAll(t));
42
+ }
43
+ return t;
44
+ }
45
+ /**
46
+ * Register the core plus any modules (`use(formatCss, formatMotion)`).
47
+ * Call once at start-up, before runtime-powered components mount.
48
+ */
49
+ function use(...mods) {
50
+ return registry.register(core, ...mods);
51
+ }
52
+
53
+ exports.RUNTIME_CDN = registry.RUNTIME_CDN;
54
+ exports.RUNTIME_VERSION = registry.RUNTIME_VERSION;
55
+ exports.RuntimeModuleError = registry.RuntimeModuleError;
56
+ exports.hasModule = registry.hasModule;
57
+ exports.missingMessage = registry.missingMessage;
58
+ exports.moduleCdn = registry.moduleCdn;
59
+ exports.modulePath = registry.modulePath;
60
+ exports.register = registry.register;
61
+ exports.registeredModules = registry.registeredModules;
62
+ exports.registry = registry.registry;
63
+ exports.requireModule = registry.requireModule;
64
+ exports.EASES = tween$1.EASES;
65
+ exports.Playable = tween$1.Playable;
66
+ exports.Timeline = tween$1.Timeline;
67
+ exports.Tween = tween$1.Tween;
68
+ exports.cubicBezier = tween$1.cubicBezier;
69
+ exports.getTicker = tween$1.getTicker;
70
+ exports.parseEase = tween$1.parseEase;
71
+ exports.parseValue = tween$1.parseValue;
72
+ exports.steps = tween$1.steps;
73
+ exports.timeline = tween$1.timeline;
74
+ exports.core = core;
75
+ exports.resolveTargets = resolveTargets;
76
+ exports.tween = tween;
77
+ exports.use = use;
78
+ //# sourceMappingURL=runtime.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.cjs","sources":["../src/runtime/index.ts"],"sourcesContent":["/**\n * `motionary/runtime` (10.1) — Motionary's own zero-dependency animation\n * runtime, the one prerequisite for runtime-powered components:\n *\n * - shared **ticker** (`getTicker()`): one rAF loop for everything;\n * - **tween + timeline** engine with easing (`tween()`, `timeline()`, `EASES`, `cubicBezier()`);\n * - **module registry** (`use()`, `requireModule()`, `hasModule()`) with a\n * clear `RuntimeModuleError` (install / import / CDN instructions) when a\n * component needs a module that was not registered.\n *\n * Every other module lives at its own subpath (`motionary/runtime/format-css`,\n * `motionary/runtime/format-motion`, …) so you only pay for what you import.\n * SSR-safe (no `window` access at import) and usable in Web Workers.\n *\n * ```ts\n * import { use, tween } from 'motionary/runtime';\n * use(); // registers the core (components can now find it)\n * tween('.box', { to: { x: 120, opacity: 1 }, duration: 500, ease: 'back-out' });\n * ```\n */\nimport { register, RUNTIME_VERSION, type RuntimeModule, type RuntimeRegistry } from './registry';\nimport { getTicker } from './ticker';\nimport { tween as rawTween, timeline, Tween, Timeline, type TweenOptions, type Playable } from './tween';\nimport { EASES, parseEase, cubicBezier, steps } from './ease';\n\nexport { registry, register, requireModule, hasModule, registeredModules, missingMessage, modulePath, moduleCdn, RuntimeModuleError, RUNTIME_VERSION, RUNTIME_CDN } from './registry';\nexport type { RuntimeModule, RuntimeRegistry } from './registry';\nexport { getTicker } from './ticker';\nexport type { Ticker, TickFn } from './ticker';\nexport { timeline, Tween, Timeline, Playable, parseValue } from './tween';\nexport type { TweenOptions, TimelineOptions, PlayOptions, Props, Target, Position } from './tween';\nexport { EASES, parseEase, cubicBezier, steps } from './ease';\nexport type { Ease } from './ease';\n\n/** The core module's API (what `requireModule('core')` returns). */\nexport interface CoreApi {\n version: string;\n getTicker: typeof getTicker;\n tween: (target: any, o: import('./tween').TweenOptions) => import('./tween').Playable;\n timeline: typeof timeline;\n Tween: typeof Tween;\n Timeline: typeof Timeline;\n EASES: typeof EASES;\n parseEase: typeof parseEase;\n cubicBezier: typeof cubicBezier;\n steps: typeof steps;\n}\n\n/** The core as a module object. */\nexport const core: RuntimeModule<CoreApi> = {\n id: 'core',\n version: RUNTIME_VERSION,\n api: { version: RUNTIME_VERSION, getTicker, tween, timeline, Tween, Timeline, EASES, parseEase, cubicBezier, steps },\n};\n\n/** Tween targets (objects, elements, lists or a CSS selector). See `TweenOptions`. */\nexport function tween(target: any, o: TweenOptions): Playable {\n return rawTween(resolveTargets(target), o);\n}\n\n/** Selector strings become element lists (only where `document` exists). */\nexport function resolveTargets(t: any): any {\n if (typeof t === 'string') {\n if (typeof document === 'undefined') throw new Error('[motionary] selector targets need a document — pass objects or elements instead');\n return Array.from(document.querySelectorAll(t));\n }\n return t;\n}\n\n/**\n * Register the core plus any modules (`use(formatCss, formatMotion)`).\n * Call once at start-up, before runtime-powered components mount.\n */\nexport function use(...mods: RuntimeModule[]): RuntimeRegistry {\n return register(core as RuntimeModule, ...mods);\n}\n"],"names":["RUNTIME_VERSION","getTicker","timeline","Tween","Timeline","EASES","parseEase","cubicBezier","steps","rawTween","register"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AA6BH;AACO,MAAM,IAAI,GAA2B;AAC1C,IAAA,EAAE,EAAE,MAAM;AACV,IAAA,OAAO,EAAEA,wBAAe;IACxB,GAAG,EAAE,EAAE,OAAO,EAAEA,wBAAe,aAAEC,iBAAS,EAAE,KAAK,YAAEC,gBAAQ,SAAEC,aAAK,YAAEC,gBAAQ,SAAEC,aAAK,aAAEC,iBAAS,eAAEC,mBAAW,SAAEC,aAAK,EAAE;;AAGtH;AACM,SAAU,KAAK,CAAC,MAAW,EAAE,CAAe,EAAA;IAChD,OAAOC,aAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAC5C;AAEA;AACM,SAAU,cAAc,CAAC,CAAM,EAAA;AACnC,IAAA,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE;QACzB,IAAI,OAAO,QAAQ,KAAK,WAAW;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC;QACvI,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACjD;AACA,IAAA,OAAO,CAAC;AACV;AAEA;;;AAGG;AACG,SAAU,GAAG,CAAC,GAAG,IAAqB,EAAA;AAC1C,IAAA,OAAOC,iBAAQ,CAAC,IAAqB,EAAE,GAAG,IAAI,CAAC;AACjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}