kuinetic 0.3.0 → 0.4.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 (54) hide show
  1. package/README.md +2 -2
  2. package/dist/esm/{chunk-7NW4OLOC.mjs → chunk-CG37RODK.mjs} +906 -428
  3. package/dist/esm/{chunk-DAVDOYOS.mjs → chunk-W7U4A2NK.mjs} +625 -124
  4. package/dist/esm/{chunk-4QKMEDM4.mjs → chunk-Y2FP56K5.mjs} +2501 -1694
  5. package/dist/esm/core/index.mjs +2 -2
  6. package/dist/esm/effects/index.mjs +2 -2
  7. package/dist/esm/index.mjs +3 -3
  8. package/dist/esm/notes/index.mjs +75 -8
  9. package/dist/kuinetic.all.js +3977 -2221
  10. package/dist/kuinetic.all.min.js +4 -2
  11. package/dist/kuinetic.css +1248 -46
  12. package/dist/kuinetic.js +3976 -2220
  13. package/dist/kuinetic.min.css +1 -1
  14. package/dist/kuinetic.min.js +3 -1
  15. package/dist/kuinetic.notes.js +1 -1
  16. package/dist/types/core/animator.d.ts +61 -2
  17. package/dist/types/core/attrs.d.ts +0 -2
  18. package/dist/types/core/auto-motion.d.ts +139 -0
  19. package/dist/types/core/cadence.d.ts +90 -0
  20. package/dist/types/core/channels.d.ts +4 -0
  21. package/dist/types/core/compile.d.ts +14 -2
  22. package/dist/types/core/deck-viewer.d.ts +2 -0
  23. package/dist/types/core/declarations.d.ts +6 -0
  24. package/dist/types/core/derived/group-gate.d.ts +18 -4
  25. package/dist/types/core/describe.d.ts +1 -1
  26. package/dist/types/core/element-config.d.ts +3 -4
  27. package/dist/types/core/instances.d.ts +27 -3
  28. package/dist/types/core/params.d.ts +1 -2
  29. package/dist/types/core/parse.d.ts +20 -1
  30. package/dist/types/core/pause-scope.d.ts +40 -0
  31. package/dist/types/core/play.d.ts +2 -2
  32. package/dist/types/core/registry.d.ts +16 -1
  33. package/dist/types/core/repeat.d.ts +6 -4
  34. package/dist/types/core/sequence.d.ts +10 -0
  35. package/dist/types/core/stagger-config.d.ts +23 -101
  36. package/dist/types/core/stagger-keys.d.ts +2 -4
  37. package/dist/types/core/stagger.d.ts +12 -21
  38. package/dist/types/core/types.d.ts +65 -18
  39. package/dist/types/effects/auto-motion.d.ts +20 -123
  40. package/dist/types/effects/carousel/deck.d.ts +5 -0
  41. package/dist/types/effects/carousel/drag.d.ts +5 -0
  42. package/dist/types/effects/carousel/row-copies.d.ts +3 -0
  43. package/dist/types/effects/carousel/shape-fit.d.ts +8 -0
  44. package/dist/types/effects/catalog/feedback.d.ts +1 -1
  45. package/dist/types/effects/catalog/media-shared.d.ts +10 -0
  46. package/dist/types/effects/catalog/pause-scope.d.ts +20 -0
  47. package/dist/types/effects/catalog/text-shared.d.ts +4 -0
  48. package/dist/types/effects/scroll-mechanics/snap-autoplay.d.ts +20 -0
  49. package/dist/types/effects/step-index.d.ts +19 -1
  50. package/dist/types/effects/svg/morph-loop.d.ts +2 -0
  51. package/dist/types/effects/tween/waypoints.d.ts +1 -1
  52. package/dist/types/showcase/media-source.d.ts +1 -0
  53. package/dist/types/showcase/youtube.d.ts +3 -0
  54. package/package.json +1 -1
@@ -0,0 +1,139 @@
1
+ import type { PrepareContext } from './effect-context.js';
2
+ import type { Cleanup } from './types.js';
3
+ /**
4
+ * The library's one scheduler for motion that starts on its own: a deck's continuous `spin:` and
5
+ * stepped `autoplay:`, a scroll-snap strip's `autoplay:`, and an element's `every:` cadence.
6
+ *
7
+ * It began in `effects/` beside `step-index.ts`, serving only the decks. It moved into `core/` when
8
+ * `every:` became an element-scoped grammar key: the animator (core) runs that cadence, and core may
9
+ * not import effects, so the choice was between duplicating the pause rules below in core — the
10
+ * second copy of exactly the drift this module exists to prevent (`showcase/slideshow.ts` is
11
+ * already one) — and moving the single copy to where both layers can reach it. `effects/auto-motion.ts`
12
+ * keeps the deck-facing half (`createDeckMotion`, the three shared params) and re-exports these names
13
+ * so every existing importer keeps working. Nothing in here knows about positions or shapes: the
14
+ * caller hands in how to `step` (and, for a spatial deck, how to `advance` by a fraction).
15
+ *
16
+ * Both kinds of motion are the same question asked at two grains — "when nobody is touching it,
17
+ * where does it go next?" — and both have to answer the same follow-ups identically, which is why
18
+ * they share one scheduler rather than each growing its own: when to stop (hover, keyboard focus, a
19
+ * hidden tab, offscreen, reduced motion, a paused scope, the author's pause control), how to yield
20
+ * to a person (a drag or a control press takes over, then the motion resumes from wherever it was
21
+ * left), how to hand the transition back and forth (a frame-driven spin must not also be eased), and
22
+ * how to tear down.
23
+ *
24
+ * ## Why `requestAnimationFrame` writing the deck's own position, and not a CSS animation
25
+ *
26
+ * The obvious CSS answer — register `--kui-step-position` with `@property` and run an infinite
27
+ * linear `@keyframes` over it — fails the one requirement that matters most here: a drag, a click
28
+ * and the spin must all move *one* number. A CSS animation owns its value; the drag would have to
29
+ * read the animated position back out of `getComputedStyle` at `pointerdown`, cancel the animation,
30
+ * drive the deck from JavaScript, and then restart the keyframe at a negative `animation-delay`
31
+ * computed to land on wherever the release settled. That is two sources of truth reconciled by
32
+ * arithmetic on every hand-off, and the "no snap-back when spin resumes" requirement is precisely
33
+ * the bug that reconciliation produces when it is off by one frame.
34
+ *
35
+ * Writing the continuous `position` the deck already has (the same number the drag moves and the
36
+ * controls set) makes the hand-off free: pausing is "stop adding to it", resuming is "start adding
37
+ * to it again", and a drag in between simply moved it. It costs nothing the CSS route would have
38
+ * saved — an animated custom property is recomputed on the main thread either way, because the
39
+ * geometry reading it is a `calc()` the compositor cannot run.
40
+ *
41
+ * `autoplay:` does not need frames at all: it is a timer that presses "next", and the stylesheet's
42
+ * own transition does the travel, exactly as it does for a click. Same model as
43
+ * `showcase/slideshow.ts`'s `autoplay:`, whose pause rules this mirrors.
44
+ */
45
+ /**
46
+ * The shortest period either kind of motion may be set to, in milliseconds.
47
+ *
48
+ * The same floor `slideshow`'s `autoplay:` has and for the same reason: below it, content moves
49
+ * faster than it can be read, and a whole ring turning in under two seconds is a strobe rather than
50
+ * a carousel. Clamped with a warning rather than refused, so a typo still produces a working deck.
51
+ */
52
+ export declare const MIN_PERIOD_MS = 2000;
53
+ /**
54
+ * The longest frame a spin will integrate over, in milliseconds.
55
+ *
56
+ * A dropped frame or a debugger pause otherwise arrives as one enormous `dt` and the ring leaps.
57
+ * Capping it turns a hitch into a brief slow-down, which is the less surprising failure. Resuming
58
+ * from a pause never relies on this — the first frame after a resume only records its timestamp.
59
+ */
60
+ export declare const MAX_FRAME_MS = 100;
61
+ /**
62
+ * An authored signed period, floored to {@link MIN_PERIOD_MS} in magnitude.
63
+ *
64
+ * Pure and exported so the clamp and the sign rule are assertable without a clock. `0` means off
65
+ * and stays `0`; the sign is the direction and survives the clamp.
66
+ *
67
+ * @param ms - Authored period in milliseconds; negative runs backwards.
68
+ * @returns The period to run at, or `0` for off.
69
+ * @complexity O(1) time and space.
70
+ * @overallScore 100
71
+ */
72
+ export declare function clampPeriod(ms: number): number;
73
+ /**
74
+ * How far one frame advances the deck, in whole cycles of it.
75
+ *
76
+ * A cycle is every slide passing once — one revolution of a full ring. Expressed in cycles rather
77
+ * than places so the rate an author writes (`spin:40s`) is independent of how many slides there
78
+ * are: adding a card to a 40-second ring keeps it a 40-second ring rather than slowing each card.
79
+ *
80
+ * @param dtMs - Milliseconds since the previous frame, before capping.
81
+ * @param periodMs - Signed milliseconds per cycle; non-zero.
82
+ * @complexity O(1) time and space.
83
+ * @overallScore 100
84
+ */
85
+ export declare function cyclesFor(dtMs: number, periodMs: number): number;
86
+ export interface AutoMotionRequest {
87
+ el: Element;
88
+ /**
89
+ * The host facts the scheduler reads: the realm (timers, frames, the observer), the document
90
+ * (visibility, the viewer and pause-scope events) and the reduced-motion preference. A narrow pick
91
+ * of `PrepareContext`, so core callers with no prepare context (`createCadence`) can use it.
92
+ */
93
+ ctx: Pick<PrepareContext, 'win' | 'doc' | 'reducedMotion'>;
94
+ /** Signed milliseconds per full cycle of continuous spin, already clamped; `0` is off. */
95
+ spinMs: number;
96
+ /** Signed milliseconds between autoplay steps, already clamped; `0` is off. */
97
+ autoplayMs: number;
98
+ /** How long a manual move takes to settle, so the motion does not resume mid-transition. */
99
+ settleMs: number;
100
+ /** Whether the pointer resting on the deck pauses it. Omitted, it does. See `HOVER_PARAM`. */
101
+ pauseOnHover?: boolean;
102
+ /**
103
+ * Move the deck on by a (signed) fraction of a full cycle. Absent on a deck that cannot spin; such
104
+ * a deck always has `spinMs` 0 (`motionPeriods`), so nothing ever calls it.
105
+ */
106
+ advance?(cycles: number): void;
107
+ /** Step the deck one place. */
108
+ step(direction: 1 | -1): void;
109
+ /**
110
+ * Publish whether frames, rather than the stylesheet's transition, are driving the deck. Absent,
111
+ * and never called, on a deck that cannot spin — see `advance`.
112
+ */
113
+ setSpinning?(spinning: boolean): void;
114
+ /** Called whenever the author-facing paused state changes, to mirror it onto pause controls. */
115
+ onPausedChange(paused: boolean): void;
116
+ /** Optional elapsed share of the current autoplay period; absent means no timer frames. */
117
+ onAutoplayProgress?(progress: number): void;
118
+ /** Begin as if the author's pause control were already pressed. See `createDeckMotion`. */
119
+ startPaused?: boolean;
120
+ }
121
+ export interface AutoMotion {
122
+ /** Whether any motion was configured at all. */
123
+ readonly enabled: boolean;
124
+ /** A person moved the deck: hand the transition back and hold off for one settle period. */
125
+ interrupt(): void;
126
+ /** A gesture is (or is no longer) in progress; nothing moves on its own while one is. */
127
+ hold(holding: boolean): void;
128
+ /** The author's pause control was pressed. */
129
+ toggle(): void;
130
+ release: Cleanup;
131
+ }
132
+ /**
133
+ * Start the deck's own motion and return the handle its manual inputs talk to.
134
+ *
135
+ * @returns A controller; `enabled` is false (and every method inert) when neither motion was set.
136
+ * @complexity O(1) per event and per frame; O(1) space.
137
+ * @overallScore 100
138
+ */
139
+ export declare function createAutoMotion(request: AutoMotionRequest): AutoMotion;
@@ -0,0 +1,90 @@
1
+ import type { CompiledDocument } from './compile.js';
2
+ import type { PrepareContext } from './effect-context.js';
3
+ import type { Cleanup } from './types.js';
4
+ /**
5
+ * The runtime half of `every:` — "while this element is on screen, the tab is visible, nothing
6
+ * pauses it and the visitor has not asked for reduced motion, perform one demonstration step every
7
+ * period" — as a thin layer over the library's one scheduler.
8
+ *
9
+ * It is `createAutoMotion` configured as a pure timer (`autoplayMs`, no spin, no settle), so the pause
10
+ * rules are not restated here: offscreen, hidden tab, keyboard focus, a paused scope and reduced
11
+ * motion all come from the scheduler, which a deck's `autoplay:` and a scroll-snap strip's share. A
12
+ * private `setInterval` would have been the third copy of those rules (decks, `slideshow`, this).
13
+ *
14
+ * Two deliberate departures from a deck's defaults:
15
+ *
16
+ * - **Hover does not pause it.** A demo loop is not text to read, and a pointer resting on a tile
17
+ * would otherwise freeze exactly the tile the visitor is looking at. Keyboard focus still pauses,
18
+ * and WCAG 2.2.2's "a way to pause" is served by the `pause-scope` control.
19
+ * - **Reduced motion never arms it.** The scheduler starts paused under that preference and a cadence
20
+ * has no play control to lift it, which is the point: no demo loop for a visitor who asked for none.
21
+ *
22
+ * What a *step* is lives in the animator (`Animator#cadenceTick`) because it needs the element's
23
+ * lifecycle state; this module only decides *when*.
24
+ */
25
+ /** What {@link createCadence} needs. */
26
+ export interface CadenceRequest {
27
+ el: Element;
28
+ /** The authored period in milliseconds; floored to the scheduler's 2s minimum with a warning. */
29
+ periodMs: number;
30
+ /** The realm, document and reduced-motion preference the scheduler reads. */
31
+ host: Pick<PrepareContext, 'win' | 'doc' | 'reducedMotion'>;
32
+ /** Perform one demonstration step. Called only while nothing pauses the cadence. */
33
+ tick(): void;
34
+ warn(message: string): void;
35
+ }
36
+ /**
37
+ * Start a cadence on one element.
38
+ *
39
+ * A period of `0` (or one that is not finite) arms nothing and says why, rather than looping at the
40
+ * floor: `every:0s` is more likely a typo than a request for the fastest loop allowed.
41
+ *
42
+ * @returns Its release; always safe to call, including twice.
43
+ * @complexity O(1) time and space.
44
+ * @overallScore 100
45
+ */
46
+ export declare function createCadence(request: CadenceRequest): {
47
+ release: Cleanup;
48
+ };
49
+ /**
50
+ * Read an `every:` value into milliseconds.
51
+ *
52
+ * `parse.ts` validates the token as a non-negative `s`/`ms` time.
53
+ * {@link createCadence} rejects periods that overflow when converted to milliseconds.
54
+ *
55
+ * @complexity O(n) time in the token length; O(1) space.
56
+ * @overallScore 100
57
+ */
58
+ export declare function everyToMs(every: string): number;
59
+ /**
60
+ * The cycle hooks of the host group's composed primitives, as thunks that run them.
61
+ *
62
+ * A thunk reads its params exactly as `js-effect-preparer.ts` does for the same entry (preset
63
+ * defaults under the authored values, validated against the entry's own schema), so a hook sees the
64
+ * values the effect itself runs with — `auto-height`'s `attribute:` is the author's, not a default.
65
+ * Each thunk is isolated: a hook that throws is warned about and the next one still runs, mirroring
66
+ * `startInstance`, so one bad hook cannot stop the cadence.
67
+ *
68
+ * Only the host group's entries count. A `target:` group's entries act on derived matches, and a
69
+ * cycle hook is handed the host element; calling it for a group would mutate the wrong node. When a
70
+ * group names a primitive that has a hook, the animator says so once ({@link hasGroupedCycle}) and
71
+ * the group replays instead.
72
+ *
73
+ * @param el - The element the cadence is on (the host).
74
+ * @param document - The element's compiled document; an empty selector identifies its host group.
75
+ * @param warn - The element's warning sink.
76
+ * @returns One thunk per host-group entry whose primitive declares `cycle`; empty when none do.
77
+ * @complexity O(e) time and space in composed effects.
78
+ * @overallScore 100
79
+ */
80
+ export declare function cycleThunks(el: Element, document: CompiledDocument, warn: (message: string) => void): Array<() => void>;
81
+ /**
82
+ * Whether a `target:` group (not the host's own) composes a primitive with a cycle hook.
83
+ *
84
+ * Separate from {@link cycleThunks} so the animator can say it once, when a cadence is created,
85
+ * instead of on every replay's recompile.
86
+ *
87
+ * @complexity O(e) time in composed effects; O(1) space.
88
+ * @overallScore 100
89
+ */
90
+ export declare function hasGroupedCycle(document: CompiledDocument): boolean;
@@ -54,6 +54,8 @@ export interface ChannelClaim {
54
54
  * knowledge, not this module's.
55
55
  */
56
56
  inlineAnimation?: boolean;
57
+ /** Prior CSS claims whose active interval ends before this claim starts. */
58
+ follows?: Set<ChannelClaim>;
57
59
  }
58
60
  export interface Conflict {
59
61
  channel: Channel;
@@ -78,6 +80,8 @@ export interface Conflict {
78
80
  export declare const CHANNEL_COMPOSITION: Partial<Record<Channel, 'add'>>;
79
81
  /** Whether every channel a claim writes can survive being made additive. */
80
82
  export declare function additiveChannels(channels: readonly Channel[]): boolean;
83
+ /** Whether two claims really contest one of the channels being rescued. */
84
+ export declare function claimsOverlap(a: ChannelClaim, b: ChannelClaim): boolean;
81
85
  /**
82
86
  * Rescue a surviving clash by summing the claims that caused it instead of letting one replace the
83
87
  * other.
@@ -1,3 +1,4 @@
1
+ import type { AnimationTracks } from './declarations.js';
1
2
  import type { ActivationSupportClaim } from './activation.js';
2
3
  import type { Registry, ResolvedEffect } from './registry.js';
3
4
  import type { SequenceStep } from './sequence.js';
@@ -6,6 +7,7 @@ import type { Activation, Channel, EffectSpec, EffectVariant, NamedActivation, P
6
7
  export interface Entry {
7
8
  spec: EffectSpec;
8
9
  resolved: ResolvedEffect;
10
+ tileFit?: 'stretch';
9
11
  /**
10
12
  * Per-spec refinement from `primitive.variantFor`, computed once in `resolveEntries` and carried
11
13
  * on the entry so nothing downstream has to call it a second time. Absent for every primitive
@@ -44,6 +46,7 @@ export interface Entry {
44
46
  target?: string;
45
47
  /** Which tree {@link target} is searched in. Only meaningful when `target` is set. */
46
48
  scope?: TargetScope;
49
+ mountTargets?: CompiledTarget['mountTargets'];
47
50
  /**
48
51
  * `animation-composition` for every track this entry compiles, when the composition resolver had
49
52
  * to make it additive to let a same-channel neighbour survive — see {@link resolveComposition}.
@@ -54,6 +57,9 @@ export interface Entry {
54
57
  * omits an all-`normal` `animation-direction`.
55
58
  */
56
59
  composite?: 'add';
60
+ stagger?: string;
61
+ handoff?: ReadonlySet<Channel>;
62
+ handoffEnd?: boolean;
57
63
  }
58
64
  /**
59
65
  * Channels one entry actually writes — the primitive's declaration, widened by any variant.
@@ -106,6 +112,7 @@ export interface CompiledPlan {
106
112
  * `finished` while the animation was still visibly running.
107
113
  */
108
114
  keyframeNames: string[];
115
+ repeatDelays?: AnimationTracks['repeatDelays'];
109
116
  /** Effects whose renderer needs JS setup. */
110
117
  jsEffects: Entry[];
111
118
  /** Names that are not registered. Must NOT be stamped, or the element is never rescanned. */
@@ -170,9 +177,13 @@ export declare function compile(parsed: ParsedValue, registry: Registry, timelin
170
177
  * itself — see `Entry.target`'s own comment for which primitives those are.
171
178
  */
172
179
  export interface CompiledTarget {
173
- /** `''` for the host group. */
180
+ /** `''` for the host and split groups. */
174
181
  selector: string;
175
182
  scope: TargetScope;
183
+ split?: EffectSpec['split'];
184
+ rows?: EffectSpec['rows'];
185
+ tileFit?: Entry['tileFit'];
186
+ mountTargets?(host: Element, warn: (message: string) => void): Element[];
176
187
  /**
177
188
  * Segment-scoped hoists merged across this group's own member entries, or absent when none of
178
189
  * them carried one — see `SegmentHoists` and `scopeHoists`. Not yet consumed at runtime (that is
@@ -230,10 +241,11 @@ export interface CompiledDocument {
230
241
  * @param parsed - Output of `parse`.
231
242
  * @param registry - Effect catalog to resolve names against.
232
243
  * @param timeline - Element-scoped timeline, used to warn on unsupported combinations.
244
+ * @param repeatDelaySupport - Runtime timing support, or 'reduced' to omit holds for reduced motion.
233
245
  * @complexity O(e * p) time in composed effects and their parameters; O(e) space.
234
246
  * @overallScore 100
235
247
  */
236
- export declare function compileTargets(parsed: ParsedValue, registry: Registry, timeline: Timeline): CompiledDocument;
248
+ export declare function compileTargets(parsed: ParsedValue, registry: Registry, timeline: Timeline, repeatDelaySupport?: boolean | 'reduced'): CompiledDocument;
237
249
  /**
238
250
  * Fold a targeted segment's provisional hoists (`spec.hoists`, from `parse.ts`) back onto the
239
251
  * element-wide `ParsedValue` for any spec whose primitive is not itself a `target:`-declaring one
@@ -28,6 +28,8 @@ export interface DeckViewerRequest {
28
28
  host: Element;
29
29
  /** The deck's cards in order, read at each click so a card added later is included. */
30
30
  cards: () => Iterable<Element>;
31
+ /** The original corresponding to the current position, when positions repeat. */
32
+ activeCard?: () => Element | undefined;
31
33
  doc: Document;
32
34
  reducedMotion: boolean;
33
35
  }
@@ -38,8 +38,12 @@ export interface AnimationTracks {
38
38
  * concatenation and knowing the timeline here would buy nothing else.
39
39
  */
40
40
  ends: string[];
41
+ staggerSpans: string[];
41
42
  easings: string[];
42
43
  iterationCounts: string[];
44
+ fillModes: string[];
45
+ /** Gap in milliseconds, indexed by the corresponding position in animation-name. */
46
+ repeatDelays?: Map<number, number>;
43
47
  /**
44
48
  * One `animation-direction` per track. Almost always every entry is `normal`, which is the CSS
45
49
  * initial value — see {@link declarationsFor} for why that case emits no declaration at all.
@@ -126,3 +130,5 @@ export declare function pushTransitions(segments: string[], owners: Map<string,
126
130
  * @overallScore 100
127
131
  */
128
132
  export declare function declarationsFor(tracks: AnimationTracks, timeline: Timeline): Record<string, string>;
133
+ /** Ordinary DOM members can pick up a nested offset even if their group is staged later. */
134
+ export declare function withNestedStagger(delay: string): string;
@@ -1,4 +1,4 @@
1
- import type { AnimatorPort, DerivedInstallContext } from './types.js';
1
+ import type { AnimatorPort, DerivedInstallContext, LiveTargetGroup } from './types.js';
2
2
  import type { CompiledTarget } from '../compile.js';
3
3
  import type { InstanceState } from '../types.js';
4
4
  /**
@@ -9,9 +9,8 @@ import type { InstanceState } from '../types.js';
9
9
  * match does.
10
10
  */
11
11
  /**
12
- * The gate owner for one derived group: the host itself, when the group's effective stagger keys
13
- * are grouped (`isGroupedKeys`); `undefined` otherwise, meaning each member binds its own gate as
14
- * an ordinary derived install would.
12
+ * Split groups and groups with effective stagger keys bind on the authored host. Other selector
13
+ * groups let each member bind its own gate as an ordinary derived install would.
15
14
  *
16
15
  * The effective keys follow the same "each key decided on its own" rule the rest of `target:`
17
16
  * uses: the group's own scoped hoists (`target.hoists`) override the host's element-wide keys
@@ -42,6 +41,21 @@ export declare function groupGateOwner(port: AnimatorPort, context: DerivedInsta
42
41
  * @overallScore 100
43
42
  */
44
43
  export declare function skipsOwnBinding(state: InstanceState): boolean;
44
+ /**
45
+ * Bind one grouped `target:` group's activation on `host`, when its style plan actually needs a
46
+ * binding at all (`gate === 'deferred'` — the same check `Animator.openGate` makes per element: a
47
+ * group that renders natively or immediately has nothing to gate). Registers the release with
48
+ * {@link registerCleanup} so the binding is torn down when the host is released. Passes no
49
+ * `cross` — a v1 limitation: a grouped target's `actions:` four-way crossings are not wired up,
50
+ * only the two-way activate/deactivate.
51
+ *
52
+ * @param port - The animator's narrow window.
53
+ * @param host - The group's gate owner.
54
+ * @param group - The live group to (maybe) bind.
55
+ * @complexity O(1) time and space — the fan-out lives in the closures this installs, not here.
56
+ * @overallScore 100
57
+ */
58
+ export declare function bindOneGroup(port: AnimatorPort, host: Element, group: LiveTargetGroup): void;
45
59
  /**
46
60
  * Install one activation binding on `host` per grouped live `target:` group, activating (and, for
47
61
  * a paired exit, deactivating) every member in document order through `port.activateOne`/
@@ -48,7 +48,7 @@ export interface ParamDescription {
48
48
  * which has no grammar — any value that passes the escape screen, quoted if it has spaces.
49
49
  */
50
50
  spellings: string[];
51
- /** The closed word list, for `keyword` and `angle|keyword`. */
51
+ /** The closed word list for a keyword or keyword union. */
52
52
  keywords?: readonly string[];
53
53
  minimum?: number;
54
54
  maximum?: number;
@@ -4,14 +4,13 @@ import type { Activation, ParsedValue, SegmentHoists, Timeline } from './types.j
4
4
  export interface ElementAttributes {
5
5
  source: string;
6
6
  on: string | null;
7
- timeline: string | null;
8
7
  threshold: string | null;
9
8
  }
10
9
  export interface ElementConfig {
11
10
  activation: Activation;
12
11
  /** Whether the author named an activation, so a primitive default may fill in when not. */
13
12
  activationAuthored: boolean;
14
- /** Optional selector for the event source named by `data-kui-on`'s `from:` refinement. */
13
+ /** Optional event source selector from inline `via:` or longhand `from:`. */
15
14
  activationSource?: string;
16
15
  /**
17
16
  * What to do at each of the observer's four crossings, when the author wrote `actions:`.
@@ -24,7 +23,7 @@ export interface ElementConfig {
24
23
  timeline: Timeline;
25
24
  timelineAxis?: string;
26
25
  timelineName?: string;
27
- /** Trailing tokens of `data-kui-timeline`, e.g. `entry 0% cover 60%`. */
26
+ /** Explicit `range:` or trailing tokens of a quoted `timeline:`. */
28
27
  range: string;
29
28
  threshold: string;
30
29
  }
@@ -50,7 +49,7 @@ export declare function readAttributes(el: Element): ElementAttributes;
50
49
  * @param attributes - Snapshot from `readAttributes`.
51
50
  * @param parsed - Result of parsing the `data-kui` value, whose hoisted keys win.
52
51
  * @returns Fully defaulted configuration; unknown values fall back rather than throwing.
53
- * @complexity O(k) time in the length of the timeline attribute; O(1) extra space.
52
+ * @complexity O(k) time in the length of the timeline value; O(1) extra space.
54
53
  * @overallScore 100
55
54
  */
56
55
  export declare function resolveConfig(attributes: ElementAttributes, parsed: ParsedValue): ElementConfig;
@@ -7,8 +7,9 @@ import type { Cleanup, EffectInstance } from './types.js';
7
7
  * already holds the from-state, so there is no flash between compilation and activation.
8
8
  *
9
9
  * Repeat activation of the same instance and a fresh instance's first activation both can meet a
10
- * browser-level animation already sitting `finished`, but they need opposite responses. A second
11
- * `activate()` on the same instance is a click-gated toggle (a card flip): reversing playback is
10
+ * browser-level animation already sitting `finished`. A second `activate()` on a click-gated
11
+ * toggle (a card flip) reverses playback, while an unpaired remote trigger or split hover uses
12
+ * the same forward restart as a first activation. For a toggle, reversing playback is
12
13
  * the correct repeat — the property write only matters on the paused-to-running edge, so writing
13
14
  * the same value again is a no-op the browser silently ignores, which is what made two-state
14
15
  * effects look permanently stuck. A fresh instance's *first* activation meeting a `finished`
@@ -19,11 +20,13 @@ import type { Cleanup, EffectInstance } from './types.js';
19
20
  * @param el - Element carrying the compiled animation.
20
21
  * @param ledger - Ledger owning the play-state write.
21
22
  * @param animationNames - Exact keyframe names emitted by the compiled plan.
23
+ * @param mode - `true` for a scrubbed instance, or `restart` for forward replay.
24
+ * @param repeatDelays - Gaps in milliseconds at opted-in animation-name positions.
22
25
  * @returns A lifecycle handle over the element's owned CSS animations.
23
26
  * @complexity O(a) per call in the number of running animations; O(1) space.
24
27
  * @overallScore 100
25
28
  */
26
- export declare function createCssInstance(el: Element, ledger: StyleLedger, animationNames: readonly string[], scrubbed?: boolean): EffectInstance;
29
+ export declare function createCssInstance(el: Element, ledger: StyleLedger, animationNames: readonly string[], mode?: boolean | 'restart', repeatDelays?: ReadonlyMap<number, number>): EffectInstance;
27
30
  /**
28
31
  * What a *finite* JS primitive's setup returns instead of a bare teardown.
29
32
  *
@@ -116,6 +119,8 @@ export interface JsInstanceHooks {
116
119
  * deferred setup only learns which kind it is once it has run. See `EffectInstance.continuous`.
117
120
  */
118
121
  continuous?(): boolean;
122
+ /** Whether the last run produced a real completion. See `EffectInstance.finite`. */
123
+ finite?(): boolean;
119
124
  }
120
125
  /**
121
126
  * Build a JS-rendered instance from a primitive's hooks, filling in the optional operations.
@@ -127,3 +132,22 @@ export interface JsInstanceHooks {
127
132
  * @overallScore 100
128
133
  */
129
134
  export declare function createJsInstance(hooks: JsInstanceHooks): EffectInstance;
135
+ /**
136
+ * Replay a finite JS instance `repeat:` times, or forever.
137
+ *
138
+ * Each iteration is `inner.activate()` again: `deferredInstance` re-runs a finished setup from a
139
+ * clean slate, so replay needs no new mechanism, only a loop. The next iteration is scheduled on
140
+ * the next animation frame, never a microtask, so a run that completes instantly cannot starve the
141
+ * event loop. The loop stops when `inner.finite` is not `true` — a setup that bailed out with a
142
+ * bare cleanup is indistinguishable by shape from a real run, and looping it would spin.
143
+ *
144
+ * Rejected: inferring repeatability at runtime for every JS instance — the compile-time warning
145
+ * would then lie for continuous effects. Repeatability is declared on the primitive instead.
146
+ *
147
+ * @param inner - The instance to replay.
148
+ * @param repeat - The validated `repeat:` value: a positive whole number or `infinite`.
149
+ * @param win - Window supplying `requestAnimationFrame`.
150
+ * @complexity O(1) time and space per iteration.
151
+ * @overallScore 100
152
+ */
153
+ export declare function repeatedInstance(inner: EffectInstance, repeat: string, win: Window): EffectInstance;
@@ -45,8 +45,7 @@ export declare function decimalNumber(raw: string, shift?: number): string | und
45
45
  * The escape screen on its own, for a value that has no type to be validated against.
46
46
  *
47
47
  * Every authored value normally reaches `style.setProperty` through {@link validate}, which runs
48
- * this screen and then a type match. One value cannot take the second half: `data-kui-stagger`'s
49
- * step (and its `cascade:` spelling inside `data-kui`) has always been passed through verbatim so
48
+ * this screen and then a type match. The group time in `cascade:` or `spread:` skips the type match so
50
49
  * that `var(--speed)` and `calc(90ms * 2)` work, and narrowing it to a `<time>` literal now would
51
50
  * break every group written against that promise. That left it as the one authored string in the
52
51
  * library with no screen at all — and `data-kui` is explicitly not assumed to be site-owner text
@@ -40,6 +40,25 @@ export declare function parseActivationAttribute(input: string | null): ParsedAc
40
40
  * @overallScore 100
41
41
  */
42
42
  export declare function parse(input: string): ParsedValue;
43
+ /** A wrapper that declares group timing without declaring an effect of its own. */
44
+ export declare function isGroupOnly(parsed: ParsedValue): boolean;
45
+ /**
46
+ * Every element-scoped key word the parser hoists, in the author's spelling (`on`, not
47
+ * `activation`). Exported so `play()`'s attribute overlay can tell an element-wide key from a
48
+ * per-effect parameter without keeping a second list that drifts when a hoist is added.
49
+ */
50
+ export declare const ELEMENT_HOIST_KEYS: readonly string[];
51
+ /**
52
+ * What kind of token one whitespace-separated piece of a `data-kui` segment is.
53
+ *
54
+ * Exported for the same reason as {@link ELEMENT_HOIST_KEYS}: `play()` rewrites a single token of
55
+ * an authored segment and must classify it with the parser's own rules (`cubic-bezier(.2,.8,.2,1)`
56
+ * is an easing, `600ms` is a time, `a:b` is a pair), not a regex that copies them.
57
+ *
58
+ * @complexity O(n) time in token length; O(1) space.
59
+ * @overallScore 100
60
+ */
61
+ export declare function tokenKind(token: string): 'pair' | 'time' | 'easing' | 'unknown';
43
62
  /**
44
63
  * Write a hoisted value once. A second, differing value across segments is an authoring mistake;
45
64
  * first one wins so behaviour stays deterministic.
@@ -47,4 +66,4 @@ export declare function parse(input: string): ParsedValue;
47
66
  * @complexity O(1) time, O(1) space.
48
67
  * @overallScore 100
49
68
  */
50
- export declare function assignOnce<K extends 'activation' | 'timeline' | 'threshold' | 'actions' | 'cascade' | 'spread' | 'order' | 'cols' | 'along' | 'rm' | 'func'>(result: ParsedValue, key: K, value: ParsedValue[K], label: string): void;
69
+ export declare function assignOnce<K extends 'activation' | 'via' | 'timeline' | 'range' | 'threshold' | 'actions' | 'cascade' | 'spread' | 'order' | 'cols' | 'along' | 'rm' | 'func' | 'every'>(result: ParsedValue, key: K, value: ParsedValue[K], label: string): void;
@@ -0,0 +1,40 @@
1
+ import type { Cleanup } from './types.js';
2
+ /** The ancestor marker a pause control writes on the container whose subtree it pauses. */
3
+ export declare const PAUSE_SCOPE_ATTR = "data-kui-paused";
4
+ /** Dispatched (bubbling) whenever a scope's paused state changes, so schedulers can re-evaluate. */
5
+ export declare const PAUSE_SCOPE_EVENT = "kui:pausescope";
6
+ /**
7
+ * Whether `el`, or any ancestor, sits inside a paused scope.
8
+ *
9
+ * Mirrors `timeScaleOf`: the state is an attribute on an ancestor rather than a registry, so a
10
+ * scheduler needs no handle on whatever primitive wrote it and nothing here has to be torn down.
11
+ *
12
+ * @complexity O(h) in ancestor depth; O(1) space.
13
+ * @overallScore 100
14
+ */
15
+ export declare function isPausedByScope(el: Element): boolean;
16
+ /**
17
+ * Announce that a scope paused or resumed.
18
+ *
19
+ * Built with the document's own realm's `CustomEvent` (a scope in an iframe is heard by that
20
+ * iframe's schedulers) and bubbled from `source` so a listener on the document sees it. Lives here
21
+ * beside the event name so the writer and the readers cannot disagree on the shape.
22
+ *
23
+ * @complexity O(depth) for the bubble; O(1) space.
24
+ * @overallScore 100
25
+ */
26
+ export declare function announcePauseScope(doc: Document, source: Element): void;
27
+ /**
28
+ * Call `onChange` with `el`'s current scope-paused state whenever any scope announces a change.
29
+ *
30
+ * One listener on the document with a re-evaluation on every event, not a listener per scope: the
31
+ * state is read fresh through `isPausedByScope`, so an event from an unrelated scope costs one
32
+ * `closest` and reports an unchanged value, and the watcher never has to know which scope an
33
+ * element belongs to (the same shape as the deck viewer's listener). The callback fires only when
34
+ * the value differs from the last one it was given, so a scheduler can treat each call as an edge.
35
+ *
36
+ * @returns A cleanup that removes the listener.
37
+ * @complexity O(1) to register; O(h) per announced event; O(1) space.
38
+ * @overallScore 100
39
+ */
40
+ export declare function watchPauseScope(el: Element, doc: Document, onChange: (paused: boolean) => void): Cleanup;
@@ -36,8 +36,8 @@ export interface PlayRequest {
36
36
  /**
37
37
  * Play an effect on a selection, returning a handle rather than a bare promise.
38
38
  *
39
- * Options are compiled into the same attribute string an author would write, so the declarative
40
- * and programmatic surfaces share one execution path instead of drifting apart.
39
+ * Keep the first authored step with the requested name and write explicit overrides back to
40
+ * `data-kui`. If no step matches, serialize the effect and options as a new attribute value.
41
41
  *
42
42
  * @param request - Animator, root, target selection, and effect name.
43
43
  * @param options - Timing and effect parameters.
@@ -1,8 +1,19 @@
1
- import type { Preset, Primitive } from './types.js';
1
+ import type { CompiledTarget } from './compile.js';
2
+ import type { Reporter } from './reporter.js';
3
+ import type { Cleanup, EffectSpec, Preset, Primitive } from './types.js';
2
4
  export interface ResolvedEffect {
3
5
  preset: Preset;
4
6
  primitive: Primitive;
5
7
  }
8
+ type SplitUnit = NonNullable<EffectSpec['split']>;
9
+ export interface SplitStage {
10
+ /** Pieces available to claim immediately. */
11
+ cells: Element[];
12
+ restore?: Cleanup;
13
+ /** For a delayed stage, leave `cells` empty and deliver them here once ready. */
14
+ onReady?(install: (cells: Element[]) => void): void;
15
+ }
16
+ type SplitProvider = (host: Element, group: CompiledTarget, reporter: Reporter) => SplitStage | undefined;
6
17
  /**
7
18
  * Name → primitive alias table.
8
19
  *
@@ -20,12 +31,15 @@ export interface ResolvedEffect {
20
31
  export declare class Registry {
21
32
  private primitives;
22
33
  private presets;
34
+ private splitProviders;
23
35
  /** Sorted-name key → preset that renders that combination as one tested keyframe. */
24
36
  private combos;
25
37
  registerPrimitive(primitive: Primitive): this;
26
38
  registerPreset(preset: Preset): this;
27
39
  registerPresets(presets: Preset[]): this;
28
40
  registerPrimitives(primitives: Primitive[]): this;
41
+ registerSplitProvider(unit: SplitUnit, install: SplitProvider): this;
42
+ getSplitProvider(unit: SplitUnit): SplitProvider | undefined;
29
43
  /**
30
44
  * Declare that a set of effect names has a purpose-built single-keyframe implementation.
31
45
  * Checked before channel conflict analysis, so `fade-up` + `blur-in` can resolve to the
@@ -43,3 +57,4 @@ export declare class Registry {
43
57
  export declare function timingProperty(primitiveId: string, name: string): string;
44
58
  /** Levenshtein-lite suggestion for unknown effect names. Dev-mode ergonomics only. */
45
59
  export declare function suggest(name: string, candidates: string[]): string | undefined;
60
+ export {};