@pixerate/flair 0.9.0 → 0.10.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.
@@ -0,0 +1,375 @@
1
+ /**
2
+ * Vector motion: animated SVG pictures described as data. A picture changes in
3
+ * steps (step 0 when it starts, step n at `steps[n - 1]` ms), and everything
4
+ * here is a pure function of its arguments, so a frame comes out the same
5
+ * however it is reached (played, stepped for a recording, or seeked).
6
+ */
7
+ /** Easing curves by name. */
8
+ declare const EASES: {
9
+ readonly linear: (t: number) => number;
10
+ readonly "in-out": (t: number) => number;
11
+ readonly out: (t: number) => number;
12
+ };
13
+ type EaseName = keyof typeof EASES;
14
+ /** How long a change takes by default, in ms. */
15
+ declare const STEP_MS = 800;
16
+ /**
17
+ * When `step` starts, in ms since the media started (step 0 at 0, step n at
18
+ * `steps[n - 1]`), or undefined if it has not started yet.
19
+ */
20
+ declare function stepStart(steps: readonly number[], step: number): number | undefined;
21
+ /**
22
+ * How far a change that plays on `step` (after `delay` ms, over `ms`) has
23
+ * got at `timeMs`, eased: 0 before it starts, 1 once it is over.
24
+ */
25
+ declare function stepProgress(steps: readonly number[], timeMs: number, step: number, options?: {
26
+ delay?: number;
27
+ ms?: number;
28
+ ease?: EaseName;
29
+ }): number;
30
+ /** The key an item in a list of data keeps from one state to the next. */
31
+ type DataKey = (item: unknown, index: number) => string;
32
+ /**
33
+ * Keys items by their `id`, `key`, `name` or `label` (or a link's `source`
34
+ * and `target`), else by position.
35
+ */
36
+ declare const defaultDataKey: DataKey;
37
+ /**
38
+ * Data between two states, `u` of the way from `a` to `b`. Numbers blend;
39
+ * lists match their items by key (`keyOf`), so each keeps its identity and
40
+ * moves rather than jumping, with items only in `b` growing from nothing and
41
+ * items only in `a` shrinking away; objects blend field by field; anything
42
+ * else changes halfway.
43
+ */
44
+ declare function lerpData<D>(a: D, b: D, u: number, keyOf?: DataKey): D;
45
+ /**
46
+ * The data to show at `timeMs`, for media whose data has a state per step:
47
+ * `states[n]` is shown from step n (the last one stays), reached by moving
48
+ * from the state before it over `ms`.
49
+ */
50
+ declare function stepData<D>(states: readonly D[], steps: readonly number[], timeMs: number, options?: {
51
+ ms?: number;
52
+ ease?: EaseName;
53
+ keyOf?: DataKey;
54
+ }): D;
55
+ /**
56
+ * An animated SVG picture: markup plus changes to its elements. Draw it with
57
+ * `SvgPlayer` (or `svgView`), or compute frames yourself with `svgFrame`.
58
+ */
59
+ interface SvgMotion {
60
+ /** One self-contained `<svg>` with a `viewBox`: no scripts, no outside links. */
61
+ svg: string;
62
+ /** Changes to its elements, each on a step. */
63
+ animate?: SvgAnimation[];
64
+ }
65
+ /** A box in an SVG's `viewBox` units: `[x, y, width, height]`. */
66
+ type SvgBox = readonly [number, number, number, number];
67
+ /** A change to one element of an {@link SvgMotion}, or (with `view`) to the whole picture. */
68
+ interface SvgAnimation {
69
+ /** The element's `id` in the SVG (not needed for `view`). */
70
+ id?: string;
71
+ /** The step it plays on: 0 (default) when the media starts, 1 with the next shot, and so on. */
72
+ step?: number;
73
+ /** Ms after the step starts. */
74
+ delay?: number;
75
+ /** How long it takes, in ms (default {@link STEP_MS}). */
76
+ ms?: number;
77
+ ease?: EaseName;
78
+ /**
79
+ * Attributes from one value to another: numbers, colours (`#rrggbb`), or
80
+ * strings whose numbers change while the rest stays the same (a path's
81
+ * `d`, a `transform`, `points`).
82
+ */
83
+ attrs?: Record<string, readonly [string | number, string | number]>;
84
+ /** Draws a line or outline on along its length, from 0 to 1 (or between two fractions). */
85
+ draw?: boolean | readonly [number, number];
86
+ /**
87
+ * Zooms and pans the whole picture to frame a box (`[x, y, width, height]`
88
+ * in the `viewBox`'s units) or an element by id (with a margin round it),
89
+ * from where the last `view` left it (at first, the whole `viewBox`).
90
+ */
91
+ view?: SvgBox | string;
92
+ /**
93
+ * Moves the element along a path (by id) from its start to its end, or
94
+ * between the fractions in `at`; draw the element round (0, 0), like a
95
+ * circle at `cx="0" cy="0"`.
96
+ */
97
+ along?: string;
98
+ /** How far along the path `along` moves the element, from and to (default [0, 1]). */
99
+ at?: readonly [number, number];
100
+ /** Counts the element's text from one number to the other. */
101
+ count?: readonly [number, number];
102
+ /** How a count is written: `{n}` stands for the number ("{n}%", "$ {n}M"). */
103
+ format?: string;
104
+ /** Decimals in a count (default 0). */
105
+ decimals?: number;
106
+ /**
107
+ * Writes this text into the element letter by letter: none of it when the
108
+ * change starts, all of it when it ends (a typewriter).
109
+ */
110
+ write?: string;
111
+ /**
112
+ * With `write`: letters not yet written show characters picked from this
113
+ * string, changing every {@link SCRAMBLE_MS} ms, so the text decodes
114
+ * rather than types. The same time always picks the same characters.
115
+ */
116
+ scramble?: string;
117
+ /** With `write`: shown after the written letters while it writes ("▌", "|"). */
118
+ caret?: string;
119
+ }
120
+ /** How often scrambled letters change, in ms (see `SvgAnimation.scramble`). */
121
+ declare const SCRAMBLE_MS = 50;
122
+ /**
123
+ * `text` with `u` (0–1) of its letters written (see `SvgAnimation.write`):
124
+ * the rest scrambled from `scramble` (picked by `timeMs`) or left off, then
125
+ * the caret while it is unfinished. Letters are code points, so emoji and
126
+ * accents are never split.
127
+ */
128
+ declare function writtenText(text: string, u: number, options?: {
129
+ scramble?: string;
130
+ caret?: string;
131
+ timeMs?: number;
132
+ }): string;
133
+ /** What one element of an animated SVG shows at a time. */
134
+ interface SvgElementFrame {
135
+ attrs: Record<string, string>;
136
+ /** How much of its length is drawn, 0–1. */
137
+ draw?: number;
138
+ text?: string;
139
+ /** Where it is along a path: the path's id and the fraction of its length. */
140
+ along?: {
141
+ path: string;
142
+ at: number;
143
+ };
144
+ /**
145
+ * The whole picture's framing (on the frame for {@link SVG_PICTURE}): `u`
146
+ * of the way from one view to the next, `null` being the whole `viewBox`.
147
+ */
148
+ view?: {
149
+ from: SvgBox | string | null;
150
+ to: SvgBox | string;
151
+ u: number;
152
+ };
153
+ }
154
+ /** The key of the whole picture's frame in {@link svgFrame}'s result (for `view`). */
155
+ declare const SVG_PICTURE = "";
156
+ /** A value `u` of the way between two attribute values (see `SvgAnimation.attrs`). */
157
+ declare function lerpAttr(a: string | number, b: string | number, u: number): string;
158
+ /** Formats a number for a count animation (`{n}` stands for the rounded number). */
159
+ declare function formatCount(value: number, options?: {
160
+ decimals?: number;
161
+ format?: string;
162
+ }): string;
163
+ /**
164
+ * What each animated element shows at `timeMs`. For each attribute (or
165
+ * line, count or writing) the latest change to have started wins; before the first
166
+ * one starts, the element shows that change's starting value, so something
167
+ * that grows in later is hidden until then.
168
+ */
169
+ declare function svgFrame(animations: readonly SvgAnimation[], steps: readonly number[], timeMs: number): Map<string, SvgElementFrame>;
170
+ /**
171
+ * The opening tag of the root element at the start of `markup` (up to its
172
+ * first `>`), cut out without a regular expression, so checks on it stay
173
+ * linear however long or odd the markup is.
174
+ */
175
+ declare function svgOpeningTag(markup: string): string;
176
+ /** Problems with an {@link SvgMotion}, as sentences; none when it can be drawn. */
177
+ declare function svgMotionIssues(motion: unknown): string[];
178
+
179
+ /**
180
+ * Time source for generative animations and playback.
181
+ * By default that is real time (animation frames and timers).
182
+ * A ManualClock instead moves only when told to, enabling frame-exact
183
+ * rendering, video recording, scrubbing, or fast simulation without waiting.
184
+ */
185
+ interface Clock {
186
+ /** Current time in milliseconds. */
187
+ now(): number;
188
+ /** Resolves on the next frame. */
189
+ frame(): Promise<void>;
190
+ /** Resolves after `ms` milliseconds of this clock's time. */
191
+ sleep(ms: number): Promise<void>;
192
+ /**
193
+ * Whether the clock follows wall time. Live clocks stop when the tab is in
194
+ * the background (browsers pause animation frames there).
195
+ */
196
+ readonly live: boolean;
197
+ }
198
+ declare const pageHidden: () => boolean;
199
+ declare const realClock: Clock;
200
+ /**
201
+ * A clock that only moves when {@link advance} or {@link tick} is called.
202
+ * Each call fires the sleeps that fall due, in order, letting awaiting code
203
+ * run before the next sleep fires, then resolves pending frames.
204
+ */
205
+ declare class ManualClock implements Clock {
206
+ readonly live = false;
207
+ private time;
208
+ private frames;
209
+ private sleepers;
210
+ private seq;
211
+ constructor(start?: number);
212
+ now(): number;
213
+ frame(): Promise<void>;
214
+ sleep(ms: number): Promise<void>;
215
+ get pending(): boolean;
216
+ advance(ms: number): Promise<void>;
217
+ tick(fps?: number): Promise<void>;
218
+ }
219
+ /**
220
+ * A repeatable pseudo-random number in [0, 1) for a key and index.
221
+ * Useful for deterministic, reproducible animations.
222
+ */
223
+ declare function jitter(key: string, n: number): number;
224
+
225
+ /**
226
+ * Drawing animated SVG pictures (see `SvgMotion`) in the DOM: a sanitising
227
+ * parser, a view that applies frames, and a player that runs on a `Clock`.
228
+ */
229
+
230
+ /**
231
+ * The `<svg>` in `markup`, parsed and made safe to show: no scripts, event
232
+ * handlers, `<foreignObject>` or links outside itself. Undefined when it is
233
+ * not an SVG.
234
+ */
235
+ declare function parseSvg(markup: string): SVGSVGElement | undefined;
236
+ interface SvgViewOptions {
237
+ /** Called with the id of the innermost element with an id that is clicked. */
238
+ onPick?: (id: string) => void;
239
+ }
240
+ /** An {@link SvgMotion} drawn into an element; call `draw` with a time to show it then. */
241
+ interface SvgView {
242
+ /** A `div` filled by the picture; put it anywhere. */
243
+ readonly element: HTMLDivElement;
244
+ /** Shows the picture at `timeMs`, with steps starting at `steps` (ms). */
245
+ draw(timeMs: number, steps?: readonly number[]): void;
246
+ /** An image of the picture as drawn now. */
247
+ capture(pixels: {
248
+ width: number;
249
+ height: number;
250
+ }): Promise<HTMLCanvasElement | undefined>;
251
+ }
252
+ /** Shows an {@link SvgMotion} as a live view; with `onPick`, clicks report the id of the element clicked. */
253
+ declare function svgView(motion: SvgMotion, options?: SvgViewOptions): SvgView;
254
+ /** How long an {@link SvgMotion} runs: its last change's end, in ms (at least 1). */
255
+ declare function svgDuration(motion: SvgMotion, steps?: readonly number[]): number;
256
+ interface SvgPlayerOptions extends SvgViewOptions {
257
+ /** Time source (default: animation frames). Pass a `ManualClock` to step frames yourself. */
258
+ clock?: Clock;
259
+ /** Start playing at once (default `true`). */
260
+ autoplay?: boolean;
261
+ /** Start again at the end (default `true`). */
262
+ loop?: boolean;
263
+ /** Loop length in ms (default: the picture's own, see {@link svgDuration}, plus `hold`). */
264
+ duration?: number;
265
+ /** Ms to rest on the last frame before looping (default 600). */
266
+ hold?: number;
267
+ /** Playback speed (default 1). */
268
+ speed?: number;
269
+ /** Step start times in ms, for pictures that change on steps (default none). */
270
+ steps?: readonly number[];
271
+ /** Pause the animation loop when scrolled out of view via IntersectionObserver (default false). */
272
+ pauseWhenHidden?: boolean;
273
+ /** Wait to start playing until the element enters the viewport via IntersectionObserver (default false). When true, autoplay is deferred until first visible. */
274
+ playOnEnter?: boolean;
275
+ /** Hide the view (`visibility: hidden`) whenever playback is paused or reset (default false). */
276
+ hideWhenPaused?: boolean;
277
+ /**
278
+ * Plays in answer to the pointer instead of on its own (see {@link SvgTrigger}):
279
+ * `"hover"` and `"press"` play to the end while hovered or held and back to
280
+ * the start after; `"click"` plays the next step on each click, starting
281
+ * over after the last. `autoplay`, `loop` and `steps` are ignored.
282
+ */
283
+ trigger?: SvgTrigger;
284
+ /** The element whose pointer events trigger it (default the container). */
285
+ triggerTarget?: HTMLElement;
286
+ }
287
+ /** What makes a triggered {@link SvgPlayer} play. */
288
+ type SvgTrigger = "hover" | "press" | "click";
289
+ /**
290
+ * Plays an {@link SvgMotion} inside `container`: loops by default, and can be
291
+ * paused, sought and sped up. Dispose it to stop and remove the picture.
292
+ */
293
+ declare class SvgPlayer {
294
+ private readonly container;
295
+ readonly view: SvgView;
296
+ private readonly clock;
297
+ private steps;
298
+ private readonly loop;
299
+ private length;
300
+ private readonly motion;
301
+ private readonly trigger?;
302
+ private readonly triggerTarget?;
303
+ /** With a hover or press trigger: 1 playing to the end, -1 back to the start. */
304
+ private direction;
305
+ /** With a click trigger: when each click came, in ms of playback. */
306
+ private clicks;
307
+ private readonly hideWhenPaused;
308
+ private speed;
309
+ private time;
310
+ private last;
311
+ private playing;
312
+ private disposed;
313
+ private wasPlayingBeforeHidden;
314
+ private hasEnteredViewport;
315
+ private intersectionObserver?;
316
+ constructor(container: HTMLElement, motion: SvgMotion, options?: SvgPlayerOptions);
317
+ /** The loop length in ms. */
318
+ get duration(): number;
319
+ /** The time shown, in ms. */
320
+ get currentTime(): number;
321
+ get isPlaying(): boolean;
322
+ play(): void;
323
+ pause(): void;
324
+ /** Stops playback, rewinds to `0 ms`, and hides the view if `hideWhenPaused` is enabled. */
325
+ reset(): void;
326
+ /** Shows the picture at `ms` (wrapped into the loop when looping). */
327
+ seek(ms: number): void;
328
+ setSpeed(speed: number): void;
329
+ /**
330
+ * Plays to the end (`true`) or back to the start (`false`) from wherever it
331
+ * is: what a hover or press trigger does, for hosts that drive it themselves
332
+ * (a hovered card, a focused button).
333
+ */
334
+ setActive(active: boolean): void;
335
+ /**
336
+ * Plays the picture's next step (what a click trigger does): steps 1, 2, …
337
+ * in turn, then step 1 again, so a picture whose last step leads back to
338
+ * how it started toggles; one with no steps plays again from the start.
339
+ */
340
+ advance(): void;
341
+ dispose(): void;
342
+ private onEnter;
343
+ private onLeave;
344
+ private onClick;
345
+ private listen;
346
+ private run;
347
+ }
348
+ interface AnimateCountOptions {
349
+ /** Starting number. */
350
+ from: number;
351
+ /** Ending number. */
352
+ to: number;
353
+ /** Duration in ms (default {@link STEP_MS}). */
354
+ ms?: number;
355
+ /** Delay before starting in ms (default 0). */
356
+ delay?: number;
357
+ /** Easing curve (default `"out"`). */
358
+ ease?: EaseName;
359
+ /** Number of decimal places (default 0). */
360
+ decimals?: number;
361
+ /** Format template where `{n}` is replaced by the formatted number (default `"{n}"`). */
362
+ format?: string;
363
+ /** Time source (default: animation frames). */
364
+ clock?: Clock;
365
+ /** Called with each formatted text frame (and raw numeric value). */
366
+ onUpdate: (text: string, value: number) => void;
367
+ }
368
+ /**
369
+ * Counts a number from `from` to `to` over `ms` using Flair's easing curves
370
+ * and `Clock`, calling `onUpdate` with the formatted string on each frame.
371
+ * Returns a cancel function that stops the animation.
372
+ */
373
+ declare function animateCount(options: AnimateCountOptions): () => void;
374
+
375
+ export { type AnimateCountOptions as A, svgMotionIssues as B, type Clock as C, type DataKey as D, EASES as E, svgOpeningTag as F, svgView as G, writtenText as H, ManualClock as M, type SvgMotion as S, type SvgTrigger as a, type EaseName as b, SCRAMBLE_MS as c, STEP_MS as d, SVG_PICTURE as e, type SvgAnimation as f, type SvgBox as g, type SvgElementFrame as h, SvgPlayer as i, type SvgPlayerOptions as j, type SvgView as k, type SvgViewOptions as l, animateCount as m, defaultDataKey as n, formatCount as o, jitter as p, lerpAttr as q, lerpData as r, pageHidden as s, parseSvg as t, realClock as u, stepData as v, stepProgress as w, stepStart as x, svgDuration as y, svgFrame as z };
@@ -1,8 +1,8 @@
1
1
  import { C as ControlValue, a as ControlDef } from './controls-Syr6drzO.js';
2
- import { S as SvgMotion } from './motion-Ce0lmzm3.js';
2
+ import { S as SvgMotion, a as SvgTrigger } from './svg-CpeanaE_.js';
3
3
 
4
4
  /** What an effect is for, used to group the catalog. */
5
- type EffectCategory = "gradient" | "organic" | "pattern" | "light" | "space" | "retro" | "image" | "overlay" | "text" | "morph" | "transition" | "loader" | "data" | "icon";
5
+ type EffectCategory = "gradient" | "organic" | "pattern" | "light" | "space" | "retro" | "image" | "overlay" | "text" | "morph" | "interaction" | "transition" | "loader" | "data" | "icon";
6
6
  /** Every category, in the order the catalog lists them. */
7
7
  declare const EFFECT_CATEGORIES: readonly EffectCategory[];
8
8
  /** Named control values: a look an effect can be switched to. */
@@ -67,6 +67,12 @@ interface VectorEffect extends EffectBase {
67
67
  derived?: (values: Record<string, ControlValue>) => Record<string, string | number>;
68
68
  /** Ms to rest on the last frame before it loops (default 600). */
69
69
  hold?: number;
70
+ /**
71
+ * Plays in answer to the pointer rather than on a loop: pass it to
72
+ * `SvgPlayer` (`{ trigger: effect.trigger }`). Click-triggered pictures
73
+ * change on steps, each click playing the next.
74
+ */
75
+ trigger?: SvgTrigger;
70
76
  }
71
77
  type EffectDefinition = ShaderEffect | VectorEffect;
72
78
  /** The types a vector effect's `{{name: type …}}` placeholder can declare. */
@@ -1,6 +1,4 @@
1
- import { a as EaseName, S as SvgMotion } from '../motion-Ce0lmzm3.js';
2
- export { D as DataKey, E as EASES, b as SCRAMBLE_MS, c as STEP_MS, d as SVG_PICTURE, e as SvgAnimation, f as SvgBox, g as SvgElementFrame, h as defaultDataKey, i as formatCount, l as lerpAttr, j as lerpData, s as stepData, k as stepProgress, m as stepStart, n as svgFrame, o as svgMotionIssues, p as svgOpeningTag, w as writtenText } from '../motion-Ce0lmzm3.js';
3
- import { C as Clock } from '../clock-BhdXWH-n.js';
1
+ export { A as AnimateCountOptions, D as DataKey, E as EASES, b as EaseName, c as SCRAMBLE_MS, d as STEP_MS, e as SVG_PICTURE, f as SvgAnimation, g as SvgBox, h as SvgElementFrame, S as SvgMotion, i as SvgPlayer, j as SvgPlayerOptions, a as SvgTrigger, k as SvgView, l as SvgViewOptions, m as animateCount, n as defaultDataKey, o as formatCount, q as lerpAttr, r as lerpData, t as parseSvg, v as stepData, w as stepProgress, x as stepStart, y as svgDuration, z as svgFrame, B as svgMotionIssues, F as svgOpeningTag, G as svgView, H as writtenText } from '../svg-CpeanaE_.js';
4
2
 
5
3
  /**
6
4
  * Shape morphing: any SVG paths turned into paths with the same structure, so
@@ -29,120 +27,4 @@ declare function morphSequence(paths: readonly string[], options?: MorphOptions)
29
27
  */
30
28
  declare function morphPaths(from: string, to: string, options?: MorphOptions): [string, string];
31
29
 
32
- /**
33
- * Drawing animated SVG pictures (see `SvgMotion`) in the DOM: a sanitising
34
- * parser, a view that applies frames, and a player that runs on a `Clock`.
35
- */
36
-
37
- /**
38
- * The `<svg>` in `markup`, parsed and made safe to show: no scripts, event
39
- * handlers, `<foreignObject>` or links outside itself. Undefined when it is
40
- * not an SVG.
41
- */
42
- declare function parseSvg(markup: string): SVGSVGElement | undefined;
43
- interface SvgViewOptions {
44
- /** Called with the id of the innermost element with an id that is clicked. */
45
- onPick?: (id: string) => void;
46
- }
47
- /** An {@link SvgMotion} drawn into an element; call `draw` with a time to show it then. */
48
- interface SvgView {
49
- /** A `div` filled by the picture; put it anywhere. */
50
- readonly element: HTMLDivElement;
51
- /** Shows the picture at `timeMs`, with steps starting at `steps` (ms). */
52
- draw(timeMs: number, steps?: readonly number[]): void;
53
- /** An image of the picture as drawn now. */
54
- capture(pixels: {
55
- width: number;
56
- height: number;
57
- }): Promise<HTMLCanvasElement | undefined>;
58
- }
59
- /** Shows an {@link SvgMotion} as a live view; with `onPick`, clicks report the id of the element clicked. */
60
- declare function svgView(motion: SvgMotion, options?: SvgViewOptions): SvgView;
61
- /** How long an {@link SvgMotion} runs: its last change's end, in ms (at least 1). */
62
- declare function svgDuration(motion: SvgMotion, steps?: readonly number[]): number;
63
- interface SvgPlayerOptions extends SvgViewOptions {
64
- /** Time source (default: animation frames). Pass a `ManualClock` to step frames yourself. */
65
- clock?: Clock;
66
- /** Start playing at once (default `true`). */
67
- autoplay?: boolean;
68
- /** Start again at the end (default `true`). */
69
- loop?: boolean;
70
- /** Loop length in ms (default: the picture's own, see {@link svgDuration}, plus `hold`). */
71
- duration?: number;
72
- /** Ms to rest on the last frame before looping (default 600). */
73
- hold?: number;
74
- /** Playback speed (default 1). */
75
- speed?: number;
76
- /** Step start times in ms, for pictures that change on steps (default none). */
77
- steps?: readonly number[];
78
- /** Pause the animation loop when scrolled out of view via IntersectionObserver (default false). */
79
- pauseWhenHidden?: boolean;
80
- /** Wait to start playing until the element enters the viewport via IntersectionObserver (default false). When true, autoplay is deferred until first visible. */
81
- playOnEnter?: boolean;
82
- /** Hide the view (`visibility: hidden`) whenever playback is paused or reset (default false). */
83
- hideWhenPaused?: boolean;
84
- }
85
- /**
86
- * Plays an {@link SvgMotion} inside `container`: loops by default, and can be
87
- * paused, sought and sped up. Dispose it to stop and remove the picture.
88
- */
89
- declare class SvgPlayer {
90
- private readonly container;
91
- readonly view: SvgView;
92
- private readonly clock;
93
- private readonly steps;
94
- private readonly loop;
95
- private readonly length;
96
- private readonly hideWhenPaused;
97
- private speed;
98
- private time;
99
- private last;
100
- private playing;
101
- private disposed;
102
- private wasPlayingBeforeHidden;
103
- private hasEnteredViewport;
104
- private intersectionObserver?;
105
- constructor(container: HTMLElement, motion: SvgMotion, options?: SvgPlayerOptions);
106
- /** The loop length in ms. */
107
- get duration(): number;
108
- /** The time shown, in ms. */
109
- get currentTime(): number;
110
- get isPlaying(): boolean;
111
- play(): void;
112
- pause(): void;
113
- /** Stops playback, rewinds to `0 ms`, and hides the view if `hideWhenPaused` is enabled. */
114
- reset(): void;
115
- /** Shows the picture at `ms` (wrapped into the loop when looping). */
116
- seek(ms: number): void;
117
- setSpeed(speed: number): void;
118
- dispose(): void;
119
- private run;
120
- }
121
- interface AnimateCountOptions {
122
- /** Starting number. */
123
- from: number;
124
- /** Ending number. */
125
- to: number;
126
- /** Duration in ms (default {@link STEP_MS}). */
127
- ms?: number;
128
- /** Delay before starting in ms (default 0). */
129
- delay?: number;
130
- /** Easing curve (default `"out"`). */
131
- ease?: EaseName;
132
- /** Number of decimal places (default 0). */
133
- decimals?: number;
134
- /** Format template where `{n}` is replaced by the formatted number (default `"{n}"`). */
135
- format?: string;
136
- /** Time source (default: animation frames). */
137
- clock?: Clock;
138
- /** Called with each formatted text frame (and raw numeric value). */
139
- onUpdate: (text: string, value: number) => void;
140
- }
141
- /**
142
- * Counts a number from `from` to `to` over `ms` using Flair's easing curves
143
- * and `Clock`, calling `onUpdate` with the formatted string on each frame.
144
- * Returns a cancel function that stops the animation.
145
- */
146
- declare function animateCount(options: AnimateCountOptions): () => void;
147
-
148
- export { type AnimateCountOptions, EaseName, type MorphOptions, SvgMotion, SvgPlayer, type SvgPlayerOptions, type SvgView, type SvgViewOptions, animateCount, morphPaths, morphSequence, parseSvg, svgDuration, svgView };
30
+ export { type MorphOptions, morphPaths, morphSequence };
@@ -20,7 +20,7 @@ import {
20
20
  svgOpeningTag,
21
21
  svgView,
22
22
  writtenText
23
- } from "../chunk-TDMD5XAU.js";
23
+ } from "../chunk-YACVME3D.js";
24
24
  import {
25
25
  morphPaths,
26
26
  morphSequence
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/flair",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Web visual effects and motion graphics: WebGL2 shader effects, animated vector effects, a catalog of ready-made effects, and a UI-agnostic, agent-ready effect editor.",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",