kuinetic 0.1.4 → 0.2.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.
- package/README.md +93 -10
- package/dist/esm/advanced/index.mjs +4727 -0
- package/dist/esm/chunk-AEQGC2KM.mjs +189 -0
- package/dist/esm/chunk-MQSNMYRP.mjs +9332 -0
- package/dist/esm/chunk-RVTYN6NZ.mjs +3446 -0
- package/dist/esm/chunk-U43BX5O2.mjs +2984 -0
- package/dist/esm/core/index.mjs +16 -9
- package/dist/esm/effects/index.mjs +19 -4
- package/dist/esm/index.mjs +17 -10
- package/dist/kuinetic.advanced.js +5070 -0
- package/dist/kuinetic.advanced.min.js +749 -0
- package/dist/kuinetic.all.js +15147 -6039
- package/dist/kuinetic.all.min.js +2 -0
- package/dist/kuinetic.css +2801 -318
- package/dist/kuinetic.js +15147 -6038
- package/dist/kuinetic.min.css +1 -0
- package/dist/kuinetic.min.js +7 -0
- package/dist/types/3d/angles.d.ts +30 -0
- package/dist/types/3d/flattening.d.ts +49 -0
- package/dist/types/3d/index.d.ts +36 -0
- package/dist/types/3d/model-3d.d.ts +115 -0
- package/dist/types/3d/register.d.ts +26 -0
- package/dist/types/3d/webgl.d.ts +24 -0
- package/dist/types/advanced/audio.d.ts +322 -0
- package/dist/types/advanced/base.d.ts +233 -0
- package/dist/types/advanced/camera-3d.d.ts +236 -0
- package/dist/types/advanced/fluid-cursor.d.ts +149 -0
- package/dist/types/advanced/gl-utils.d.ts +52 -0
- package/dist/types/advanced/glsl.d.ts +60 -0
- package/dist/types/advanced/index.d.ts +23 -0
- package/dist/types/advanced/particles.d.ts +108 -0
- package/dist/types/advanced/scenes.d.ts +207 -0
- package/dist/types/advanced/shaders.d.ts +972 -0
- package/dist/types/browser/boot.d.ts +72 -0
- package/dist/types/core/activation.d.ts +227 -2
- package/dist/types/core/animator.d.ts +446 -11
- package/dist/types/core/attrs.d.ts +9 -0
- package/dist/types/core/breakpoints.d.ts +260 -0
- package/dist/types/core/bundles.d.ts +71 -0
- package/dist/types/core/callback.d.ts +64 -0
- package/dist/types/core/capabilities.d.ts +47 -0
- package/dist/types/core/channels.d.ts +120 -2
- package/dist/types/core/cloak-selectors.d.ts +47 -0
- package/dist/types/core/compile.d.ts +207 -2
- package/dist/types/core/control.d.ts +218 -0
- package/dist/types/core/declarations.d.ts +128 -0
- package/dist/types/core/derived/aggregate.d.ts +43 -0
- package/dist/types/core/derived/book.d.ts +30 -0
- package/dist/types/core/derived/diagnostics.d.ts +51 -0
- package/dist/types/core/derived/group-gate.d.ts +62 -0
- package/dist/types/core/derived/install.d.ts +110 -0
- package/dist/types/core/derived/late-matches.d.ts +19 -0
- package/dist/types/core/derived/types.d.ts +108 -0
- package/dist/types/core/easing.d.ts +57 -0
- package/dist/types/core/element-config.d.ts +47 -6
- package/dist/types/core/element-size.d.ts +23 -0
- package/dist/types/core/event-sources.d.ts +39 -0
- package/dist/types/core/flip.d.ts +34 -1
- package/dist/types/core/gesture.d.ts +12 -0
- package/dist/types/core/host-facts.d.ts +155 -0
- package/dist/types/core/index.d.ts +7 -3
- package/dist/types/core/owned-styles.d.ts +129 -2
- package/dist/types/core/params.d.ts +48 -0
- package/dist/types/core/parse.d.ts +28 -1
- package/dist/types/core/register-into.d.ts +29 -0
- package/dist/types/core/registry.d.ts +10 -3
- package/dist/types/core/repeat.d.ts +91 -0
- package/dist/types/core/sequence.d.ts +126 -0
- package/dist/types/core/stagger-config.d.ts +199 -0
- package/dist/types/core/stagger-keys.d.ts +63 -0
- package/dist/types/core/stagger.d.ts +187 -6
- package/dist/types/core/style-plan.d.ts +21 -16
- package/dist/types/core/target.d.ts +128 -0
- package/dist/types/core/threshold-reachability.d.ts +45 -0
- package/dist/types/core/time-scale.d.ts +9 -0
- package/dist/types/core/toggle-actions.d.ts +141 -0
- package/dist/types/core/travel.d.ts +59 -0
- package/dist/types/core/types.d.ts +699 -13
- package/dist/types/core/unquoted-selectors.d.ts +53 -0
- package/dist/types/effects/carousel/drag.d.ts +80 -0
- package/dist/types/effects/carousel/index.d.ts +149 -0
- package/dist/types/effects/catalog/discrete.d.ts +13 -0
- package/dist/types/effects/catalog/interaction-proximity.d.ts +24 -0
- package/dist/types/effects/catalog/interaction-reveal.d.ts +248 -0
- package/dist/types/effects/catalog/interaction-shared.d.ts +42 -0
- package/dist/types/effects/catalog/interaction-states.d.ts +68 -0
- package/dist/types/effects/catalog/materials.d.ts +67 -0
- package/dist/types/effects/catalog/media-shared.d.ts +3 -2
- package/dist/types/effects/catalog/numbers-shared.d.ts +8 -5
- package/dist/types/effects/catalog/shared.d.ts +1 -1
- package/dist/types/effects/catalog/text-shared.d.ts +86 -10
- package/dist/types/effects/catalog/transforms.d.ts +13 -0
- package/dist/types/effects/catalog/view-transitions.d.ts +13 -0
- package/dist/types/effects/forms/primitives.d.ts +15 -4
- package/dist/types/effects/gestures/index.d.ts +53 -0
- package/dist/types/effects/index.d.ts +5 -0
- package/dist/types/effects/layout/presets.d.ts +35 -0
- package/dist/types/effects/motion-path/index.d.ts +35 -0
- package/dist/types/effects/scroll-mechanics/params.d.ts +23 -0
- package/dist/types/effects/scroll-mechanics/presets.d.ts +51 -0
- package/dist/types/effects/scroll-mechanics/section-index.d.ts +47 -0
- package/dist/types/effects/shared.d.ts +124 -4
- package/dist/types/effects/step-index.d.ts +121 -0
- package/dist/types/effects/step-marking.d.ts +41 -33
- package/dist/types/effects/svg/icon-parts.d.ts +23 -0
- package/dist/types/effects/three-d/flip-parts.d.ts +46 -0
- package/dist/types/effects/tween/index.d.ts +57 -0
- package/dist/types/effects/tween/properties.d.ts +107 -0
- package/dist/types/effects/tween/waypoints.d.ts +106 -0
- package/dist/types/showcase/compare.d.ts +4 -0
- package/dist/types/showcase/device-frame.d.ts +3 -0
- package/dist/types/showcase/hotspots.d.ts +3 -0
- package/dist/types/showcase/index.d.ts +30 -0
- package/dist/types/showcase/lightbox.d.ts +3 -0
- package/dist/types/showcase/media-source.d.ts +13 -0
- package/dist/types/showcase/modal-shell.d.ts +22 -0
- package/dist/types/showcase/scroll-story.d.ts +4 -0
- package/dist/types/showcase/shared.d.ts +47 -0
- package/dist/types/showcase/slideshow.d.ts +3 -0
- package/dist/types/showcase/slow-mo.d.ts +5 -0
- package/package.json +14 -7
- package/dist/esm/chunk-7WMNPIOZ.mjs +0 -4883
- package/dist/esm/chunk-JT4PZL3A.mjs +0 -773
- package/dist/esm/chunk-TJDDIQRG.mjs +0 -1290
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The self-start shared by every distributed browser bundle.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this file imports nothing
|
|
5
|
+
*
|
|
6
|
+
* The npm/ESM path's guarantee is that importing kUInetic has no side effects — nothing is scanned
|
|
7
|
+
* and the document is not touched until `.start()` is called (see `src/index.ts`'s doc comment and
|
|
8
|
+
* `docs/design.md` §1a). That guarantee is for module consumers, and it still holds absolutely.
|
|
9
|
+
*
|
|
10
|
+
* The `<script src="...">` path has the opposite need: zero lines of JavaScript from the author.
|
|
11
|
+
* Loading the file is the entire integration.
|
|
12
|
+
*
|
|
13
|
+
* Both come out of one source because **this module is not in the library's module graph**. It
|
|
14
|
+
* imports nothing — not from `src/`, not from anywhere — and is reached only by
|
|
15
|
+
* `scripts/build-tiers.mjs`, which bundles it separately and *appends* it to the IIFE outputs. No
|
|
16
|
+
* ESM entry point references `src/browser/`, and nothing under `src/` imports this file, so the
|
|
17
|
+
* side effect is not "tree-shaken away" from `dist/esm/*` — it is unreachable from it.
|
|
18
|
+
* `scripts/verify-tiers.mjs` fails the build if that ever stops being true.
|
|
19
|
+
*
|
|
20
|
+
* Everything it needs, it reads off globals. Everything it is told, it is told through `boot()`'s
|
|
21
|
+
* options by the one call line the build script appends after it.
|
|
22
|
+
*
|
|
23
|
+
* ## The handshake
|
|
24
|
+
*
|
|
25
|
+
* `window.__kuineticRuntime` is a plain data object on purpose. The bug this whole scheme exists to
|
|
26
|
+
* route around is `instanceof` across two independently-bundled copies of the same class (see
|
|
27
|
+
* `asRegistry` in `src/advanced/base.ts`), so nothing here is ever an instance of anything, and no
|
|
28
|
+
* bundle ever tests another bundle's object against its own class.
|
|
29
|
+
*
|
|
30
|
+
* - **Core is the sole animator creator.** Tiers only queue a registration. A tier without core
|
|
31
|
+
* cannot do anything useful, so instead of half-working it names the missing tag in a warning.
|
|
32
|
+
* - **The boot runs at `DOMContentLoaded`** (or immediately, if the document is already past
|
|
33
|
+
* parsing). Plain and `defer` script tags are all guaranteed to have executed by then, in any tag
|
|
34
|
+
* order — which is what makes tag order irrelevant by construction rather than by luck. No bundle
|
|
35
|
+
* reads a global at parse time and gives up, and nothing polls.
|
|
36
|
+
* - The pre-JS cloak (`html[data-kui-cloak]` plus the `kui.cloak` layer, `src/css/base.css`) is
|
|
37
|
+
* pure CSS and covers the window between first paint and the boot, so deferring `start()` this
|
|
38
|
+
* far introduces no flash of un-animated content.
|
|
39
|
+
*
|
|
40
|
+
* ## Opt-out
|
|
41
|
+
*
|
|
42
|
+
* `data-kui-manual` on a bundle's own `<script>` tag means "this bundle does not auto-init". Put it
|
|
43
|
+
* on every tag to get exactly the pre-auto-start behaviour back. Marking *core* manual necessarily
|
|
44
|
+
* disables the whole chain, because core is the only thing that creates an animator — so a tier
|
|
45
|
+
* that sees core go manual stays quiet rather than complaining that core is missing.
|
|
46
|
+
*/
|
|
47
|
+
/** Only what this file calls. Structural, because it cannot import the real types. */
|
|
48
|
+
interface AnimatorLike {
|
|
49
|
+
start(): unknown;
|
|
50
|
+
scan(root?: ParentNode): unknown;
|
|
51
|
+
reset(el: Element): void;
|
|
52
|
+
}
|
|
53
|
+
type Options = Record<string, unknown>;
|
|
54
|
+
/** The IIFE namespace object a bundle built with `--global-name=kuinetic` exposes. */
|
|
55
|
+
interface CoreNamespace {
|
|
56
|
+
kuinetic(options?: Options): AnimatorLike;
|
|
57
|
+
}
|
|
58
|
+
export interface BootOptions {
|
|
59
|
+
/** Names the bundle in warnings: `'core'`, `'advanced'`, `'3d'`. */
|
|
60
|
+
tier: string;
|
|
61
|
+
/** Core passes its own IIFE namespace; a tier passes nothing. */
|
|
62
|
+
core?: CoreNamespace | null;
|
|
63
|
+
/** The global the bundle was built under, so the double-animator guard can rebind it. */
|
|
64
|
+
globalName?: string;
|
|
65
|
+
/** A tier passes its `registerX` function; core passes nothing. */
|
|
66
|
+
register?: ((animator: AnimatorLike) => unknown) | null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Called once per bundle, by the single line `scripts/build-tiers.mjs` appends after this file.
|
|
70
|
+
*/
|
|
71
|
+
export declare function boot(options: BootOptions): void;
|
|
72
|
+
export {};
|
|
@@ -1,11 +1,198 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Reporter } from './reporter.js';
|
|
2
|
+
import type { Crossing } from './toggle-actions.js';
|
|
3
|
+
import type { Activation, Cleanup, NamedActivation } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Activations — one concern, three parts, in the order a value travels through them.
|
|
6
|
+
*
|
|
7
|
+
* First the vocabulary: what an authored `data-kui-on` value *means*, as tables and pure functions
|
|
8
|
+
* with no DOM anywhere in sight, so `parse.ts`, `element-config.ts` and `style-plan.ts` can each
|
|
9
|
+
* ask their own question of it without pulling in a document. Then the binder: how a resolved spec
|
|
10
|
+
* is actually attached to an element, sharing one `IntersectionObserver` per threshold. Then the
|
|
11
|
+
* diagnostics: what the library can still tell an author about a value once the list is open,
|
|
12
|
+
* which needs an element and so cannot live with the first part.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* What an authored `data-kui-on` value *means*, with no DOM anywhere in sight.
|
|
16
|
+
*
|
|
17
|
+
* Kept DOM-free, and kept as a table, because four call sites each need a different slice of the
|
|
18
|
+
* same knowledge and none of them wants the others' dependencies. `parse.ts` has to validate an
|
|
19
|
+
* authored value without touching a document; `element-config.ts` has to do the same for the
|
|
20
|
+
* longhand attribute; `style-plan.ts` only needs to know whether the value starts immediately; the
|
|
21
|
+
* binder below needs the event types to actually listen for. Writing the table once here is what
|
|
22
|
+
* stops those four from drifting apart — which is exactly how the old closed list ended up
|
|
23
|
+
* duplicated as a `Set` in `parse.ts`, a second `Set` in `element-config.ts`, and a `Record` in
|
|
24
|
+
* the binder, three copies that all had to be edited to add one name.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* How one half of an activation is delivered.
|
|
28
|
+
*
|
|
29
|
+
* A tagged union rather than a bare event-name list because the four delivery mechanisms are
|
|
30
|
+
* genuinely different machinery — `load` runs now, `manual` runs never, `enter`/`leave` share an
|
|
31
|
+
* `IntersectionObserver`, and everything else is `addEventListener`. Naming them keeps the
|
|
32
|
+
* binder's dispatch flat, which is the property the binder's own architecture note below asks for.
|
|
33
|
+
*/
|
|
34
|
+
export type ActivationTrigger = {
|
|
35
|
+
readonly kind: 'immediate';
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'manual';
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'observed';
|
|
40
|
+
readonly when: 'enter' | 'leave';
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'events';
|
|
43
|
+
readonly types: readonly string[];
|
|
44
|
+
};
|
|
45
|
+
/** One resolved `data-kui-on` value: what starts the effects, and what plays them back out. */
|
|
46
|
+
export interface ActivationSpec {
|
|
47
|
+
/** The authored value, verbatim, so `data-kui-on` round-trips and fingerprints stay stable. */
|
|
48
|
+
readonly source: Activation;
|
|
49
|
+
/** The authored halves, verbatim — `['pointerenter', 'pointerleave']`. One or two entries. */
|
|
50
|
+
readonly names: readonly string[];
|
|
51
|
+
readonly start: ActivationTrigger;
|
|
52
|
+
/** Present only when the author wrote a pair. */
|
|
53
|
+
readonly end?: ActivationTrigger;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Separator between the two halves of a pair: `data-kui-on="pointerenter/pointerleave"`.
|
|
57
|
+
*
|
|
58
|
+
* A slash rather than a comma, a space, or a second attribute. A comma and a space are both
|
|
59
|
+
* already structural in `parse.ts`'s tokenizer, so either would have forced authors to quote the
|
|
60
|
+
* inline spelling (`on:"pointerenter, pointerleave"`) for the commonest case in the feature — and
|
|
61
|
+
* a second attribute (`data-kui-off`) proliferates attributes for something that is one decision
|
|
62
|
+
* about one element. A slash is inert to the tokenizer, so `on:pointerenter/pointerleave` needs no
|
|
63
|
+
* quoting, and reads the way CSS already writes paired values (`grid-area: 1 / 2`).
|
|
64
|
+
*/
|
|
65
|
+
export declare const PAIR_SEPARATOR = "/";
|
|
66
|
+
export declare function isNamedActivation(name: string): name is NamedActivation;
|
|
67
|
+
/**
|
|
68
|
+
* Resolve a `data-kui-on` value into its start and (optional) end triggers.
|
|
69
|
+
*
|
|
70
|
+
* Total by construction: an unvalidated or malformed value still resolves, to a listener for an
|
|
71
|
+
* event that will simply never fire. That is the open list's own contract — the library cannot
|
|
72
|
+
* know that `cart:updated` is real and `clik` is not — and the diagnostics that make a typo
|
|
73
|
+
* visible live in `validateActivation` and in `animator.ts`, not here.
|
|
74
|
+
*
|
|
75
|
+
* @param activation - Authored value, e.g. `enter`, `pointerenter/pointerleave`, `cart:updated`.
|
|
76
|
+
* @complexity O(n) time in the value's length; O(1) space.
|
|
77
|
+
* @overallScore 100
|
|
78
|
+
*/
|
|
79
|
+
export declare function resolveActivationSpec(activation: Activation): ActivationSpec;
|
|
80
|
+
/**
|
|
81
|
+
* Diagnose an authored `data-kui-on` value without a document.
|
|
82
|
+
*
|
|
83
|
+
* Returns the reasons the value cannot be used at all, so the caller can fall back to the default
|
|
84
|
+
* activation rather than binding something meaningless. It deliberately does *not* police whether
|
|
85
|
+
* an event name is real — that is the open list's whole point, and the check that can be made
|
|
86
|
+
* (does this document know the name?) needs an element, so it lives in `animator.ts`.
|
|
87
|
+
*
|
|
88
|
+
* @returns Zero warnings when the value is usable.
|
|
89
|
+
* @complexity O(n) time in the value's length; O(1) space.
|
|
90
|
+
* @overallScore 100
|
|
91
|
+
*/
|
|
92
|
+
export declare function validateActivation(value: string): string[];
|
|
93
|
+
/**
|
|
94
|
+
* Which kind of machinery starts this activation.
|
|
95
|
+
*
|
|
96
|
+
* Exported so `style-plan.ts` can ask "does this start on its own?" without importing the whole
|
|
97
|
+
* trigger union — it used to compare `config.activation === 'load'`, which a pair like
|
|
98
|
+
* `load/pointerleave` would have quietly failed.
|
|
99
|
+
*
|
|
100
|
+
* @complexity O(n) time in the value's length; O(1) space.
|
|
101
|
+
* @overallScore 100
|
|
102
|
+
*/
|
|
103
|
+
export declare function startKindOf(activation: Activation): ActivationTrigger['kind'];
|
|
104
|
+
/**
|
|
105
|
+
* Whether this activation is spent by its first firing.
|
|
106
|
+
*
|
|
107
|
+
* One-shot `enter` is the library's default and a great deal of existing markup depends on it —
|
|
108
|
+
* the effect plays once and stays. Pairing it is what opts out: an author who wrote an exit half
|
|
109
|
+
* is asking for the binding to stay live, because an exit that fires once and then stops
|
|
110
|
+
* responding is not an exit. Observed activations are the only ones that were ever one-shot;
|
|
111
|
+
* `hover` and `click` deliberately stay bound so a card can flip back.
|
|
112
|
+
*
|
|
113
|
+
* @complexity O(n) time in the value's length; O(1) space.
|
|
114
|
+
* @overallScore 100
|
|
115
|
+
*/
|
|
116
|
+
export declare function isOneShot(spec: ActivationSpec): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The named activations, any one of which authorises `name` against a primitive's declared
|
|
119
|
+
* `supportedActivations`. See `SUPPORT_PROXIES`.
|
|
120
|
+
*
|
|
121
|
+
* @complexity O(1) time, O(1) space.
|
|
122
|
+
* @overallScore 100
|
|
123
|
+
*/
|
|
124
|
+
export declare function authorisingActivations(name: string): readonly NamedActivation[];
|
|
125
|
+
/**
|
|
126
|
+
* Whether this library recognises `type` as a real event name on its own, without asking a
|
|
127
|
+
* document. A `-`, `:` or `.` is treated as a deliberate custom-event namespace and always
|
|
128
|
+
* vouched for — `cart:updated` and `htmx-after-swap` are legitimate activations that no document
|
|
129
|
+
* will ever recognise, and warning about them would make the warning useless.
|
|
130
|
+
*
|
|
131
|
+
* @complexity O(n) time in the list length; O(1) space.
|
|
132
|
+
* @overallScore 100
|
|
133
|
+
*/
|
|
134
|
+
export declare function isKnownEventType(type: string): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Offer the closest activation or event name to a near miss, for a warning that says what to do
|
|
137
|
+
* instead of only what went wrong.
|
|
138
|
+
*
|
|
139
|
+
* @returns The suggestion, or `undefined` when nothing is close enough to be worth offering.
|
|
140
|
+
* @complexity O(k * n * m) time over the candidate list; O(m) space. Only ever runs on the
|
|
141
|
+
* diagnostic path for a name the environment already rejected.
|
|
142
|
+
* @overallScore 100
|
|
143
|
+
*/
|
|
144
|
+
export declare function suggestActivation(name: string): string | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* Bind an authored activation to an element.
|
|
147
|
+
*
|
|
148
|
+
* The delivery mechanisms live in the table above rather than in a switch here, so adding an
|
|
149
|
+
* activation stays a data change and this binder's branch count stays flat —
|
|
150
|
+
* the original architecture note, kept through the change from a closed list of six names to an
|
|
151
|
+
* open one. What used to be `Record<Activation, string[]>` is now a tagged union of four kinds,
|
|
152
|
+
* for the same reason: an event-name list could not express "any name at all" without also
|
|
153
|
+
* claiming that `enter` was an event.
|
|
154
|
+
*/
|
|
155
|
+
/** Everything one binding needs, grouped so the call site reads as one request. */
|
|
156
|
+
export interface ActivationRequest {
|
|
157
|
+
/** `IntersectionObserver` threshold, used only by observed activations. */
|
|
158
|
+
threshold: string;
|
|
159
|
+
/** Selector for the foreign elements whose events drive this animation. */
|
|
160
|
+
from?: string;
|
|
161
|
+
/** Start the effects. */
|
|
162
|
+
activate(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Play them back out.
|
|
165
|
+
*
|
|
166
|
+
* Called only for the exit half of a pair, so a binder consumer that has nothing to reverse can
|
|
167
|
+
* leave it off and the exit half simply goes unbound.
|
|
168
|
+
*/
|
|
169
|
+
deactivate?(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Deliver the four crossings individually instead of the two `activate`/`deactivate` sides.
|
|
172
|
+
*
|
|
173
|
+
* Present only when the element authored `actions:`. The binder's job stops at naming which
|
|
174
|
+
* crossing happened — what a crossing *does* is the animator's, because every verb is either a
|
|
175
|
+
* transition of the element's state machine or a call on a playhead, and the binder owns neither.
|
|
176
|
+
*/
|
|
177
|
+
cross?(crossing: Crossing): void;
|
|
178
|
+
}
|
|
2
179
|
export interface ActivationBinder {
|
|
3
|
-
bind(el: Element, activation: Activation,
|
|
180
|
+
bind(el: Element, activation: Activation, request: ActivationRequest): Cleanup;
|
|
4
181
|
destroy(): void;
|
|
5
182
|
}
|
|
6
183
|
export interface ActivationBinderOptions {
|
|
7
184
|
/** Injected so tests can supply a controllable observer and assert without layout. */
|
|
8
185
|
createObserver?: (callback: IntersectionObserverCallback, options: IntersectionObserverInit) => IntersectionObserver;
|
|
186
|
+
/**
|
|
187
|
+
* Where {@link checkThresholdReachability} reports an unreachable `threshold:`, if anywhere.
|
|
188
|
+
*
|
|
189
|
+
* Bound once for the whole binder rather than threaded through every `bind` call: every observed
|
|
190
|
+
* binding the binder ever makes shares the one diagnostic sink, the same way they already share
|
|
191
|
+
* observers per threshold. Optional because most of this file's own tests construct a binder with
|
|
192
|
+
* nothing to warn into, and the diagnostic is a courtesy the binder degrades out of silently, not
|
|
193
|
+
* a contract it enforces.
|
|
194
|
+
*/
|
|
195
|
+
reporter?: Reporter;
|
|
9
196
|
}
|
|
10
197
|
/**
|
|
11
198
|
* Bind activations to elements, sharing one IntersectionObserver per distinct threshold.
|
|
@@ -19,3 +206,41 @@ export interface ActivationBinderOptions {
|
|
|
19
206
|
* @overallScore 100
|
|
20
207
|
*/
|
|
21
208
|
export declare function createActivationBinder(options?: ActivationBinderOptions): ActivationBinder;
|
|
209
|
+
/**
|
|
210
|
+
* Convert an IntersectionObserver threshold from `"30%"` or `"0.3"` into a clamped ratio.
|
|
211
|
+
*
|
|
212
|
+
* Lives here rather than with the rest of the attribute reading in `element-config.ts`, where it
|
|
213
|
+
* used to sit: the binder above is its only caller, and leaving it there would have made
|
|
214
|
+
* `activation.ts` and `element-config.ts` import each other — a cycle, once `validateActivation`
|
|
215
|
+
* moved into this file. `.dependency-cruiser.cjs` forbids those for a reason, and the honest fix
|
|
216
|
+
* is that a threshold is activation machinery, not element configuration.
|
|
217
|
+
*
|
|
218
|
+
* @param raw - Authored threshold value.
|
|
219
|
+
* @returns A ratio in [0, 1]; unparseable input yields 0 rather than throwing.
|
|
220
|
+
* @complexity O(1) time, O(1) space.
|
|
221
|
+
* @overallScore 100
|
|
222
|
+
*/
|
|
223
|
+
export declare function toThresholdRatio(raw: string): number;
|
|
224
|
+
/**
|
|
225
|
+
* What the library can still tell an author about an authored activation once the list is open.
|
|
226
|
+
*
|
|
227
|
+
* Separate from the vocabulary above because these checks need an element and that half is
|
|
228
|
+
* deliberately DOM-free; separate from `animator.ts` because they are the diagnostics half of one
|
|
229
|
+
* decision and the animator is already at its line budget. Nothing here changes behaviour — every
|
|
230
|
+
* value that reaches these functions has already been bound.
|
|
231
|
+
*/
|
|
232
|
+
/** Everything the checks need, grouped so the call site reads as one request. */
|
|
233
|
+
export interface ActivationDiagnosticsRequest {
|
|
234
|
+
el: Element;
|
|
235
|
+
spec: ActivationSpec;
|
|
236
|
+
/** Declared support from the composed primitives; empty means no primitive claimed anything. */
|
|
237
|
+
supported: NamedActivation[];
|
|
238
|
+
reporter: Reporter;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Report every way an authored activation looks like a mistake.
|
|
242
|
+
*
|
|
243
|
+
* @complexity O(s * a) time in the authored halves and the declared list, both single-digit.
|
|
244
|
+
* @overallScore 100
|
|
245
|
+
*/
|
|
246
|
+
export declare function warnAboutActivation(request: ActivationDiagnosticsRequest): void;
|