motionary 6.8.0 → 7.0.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/CHANGELOG.md +39 -0
- package/README.md +2 -2
- package/README_ja.md +2 -2
- package/README_zh.md +2 -2
- package/bin/usa-codemod-7.mjs +91 -0
- package/dist/chunks/{gpu-CsP2ZB3x.js → gpu-Bkw605Ds.js} +183 -5
- package/dist/chunks/gpu-Bkw605Ds.js.map +1 -0
- package/dist/chunks/{gpu-BBRLgEzM.cjs → gpu-Dx0H875w.cjs} +187 -4
- package/dist/chunks/gpu-Dx0H875w.cjs.map +1 -0
- package/dist/chunks/{index-tags-wv0R_vkO.cjs → index-tags-BTMwrfgV.cjs} +3 -3
- package/dist/chunks/index-tags-BTMwrfgV.cjs.map +1 -0
- package/dist/chunks/{index-tags-DucKMQr_.js → index-tags-C04JP8g4.js} +3 -3
- package/dist/chunks/index-tags-C04JP8g4.js.map +1 -0
- package/dist/chunks/player-C-TwEEy6.js +516 -0
- package/dist/chunks/player-C-TwEEy6.js.map +1 -0
- package/dist/chunks/player-PS6_FzNw.cjs +525 -0
- package/dist/chunks/player-PS6_FzNw.cjs.map +1 -0
- package/dist/components/a11y.cjs +1 -1
- package/dist/components/a11y.d.cts +2 -2
- package/dist/components/a11y.d.ts +2 -2
- package/dist/components/a11y.js +1 -1
- package/dist/components/angular.cjs +2 -2
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +5 -36
- package/dist/components/angular.d.ts +5 -36
- package/dist/components/angular.js +2 -2
- package/dist/components/angular.js.map +1 -1
- package/dist/components/effects.cjs +13 -522
- package/dist/components/effects.cjs.map +1 -1
- package/dist/components/effects.js +5 -513
- package/dist/components/effects.js.map +1 -1
- package/dist/components/fx-3d.cjs +2 -2
- package/dist/components/fx-3d.cjs.map +1 -1
- package/dist/components/fx-3d.d.cts +2 -2
- package/dist/components/fx-3d.d.ts +2 -2
- package/dist/components/fx-3d.js +2 -2
- package/dist/components/fx-3d.js.map +1 -1
- package/dist/components/fx-focus.cjs +125 -0
- package/dist/components/fx-focus.cjs.map +1 -0
- package/dist/components/fx-focus.d.cts +65 -0
- package/dist/components/fx-focus.d.ts +65 -0
- package/dist/components/fx-focus.js +122 -0
- package/dist/components/fx-focus.js.map +1 -0
- package/dist/components/fx-gpu.cjs +2 -2
- package/dist/components/fx-gpu.d.cts +2 -2
- package/dist/components/fx-gpu.d.ts +2 -2
- package/dist/components/fx-gpu.js +1 -1
- package/dist/components/fx-light.cjs +2 -2
- package/dist/components/fx-light.cjs.map +1 -1
- package/dist/components/fx-light.d.cts +2 -2
- package/dist/components/fx-light.d.ts +2 -2
- package/dist/components/fx-light.js +2 -2
- package/dist/components/fx-light.js.map +1 -1
- package/dist/components/fx-morph.cjs +2 -2
- package/dist/components/fx-morph.cjs.map +1 -1
- package/dist/components/fx-morph.d.cts +2 -2
- package/dist/components/fx-morph.d.ts +2 -2
- package/dist/components/fx-morph.js +2 -2
- package/dist/components/fx-morph.js.map +1 -1
- package/dist/components/fx-physics.cjs +2 -2
- package/dist/components/fx-physics.cjs.map +1 -1
- package/dist/components/fx-physics.d.cts +2 -2
- package/dist/components/fx-physics.d.ts +2 -2
- package/dist/components/fx-physics.js +2 -2
- package/dist/components/fx-physics.js.map +1 -1
- package/dist/components/fx-text.cjs +2 -2
- package/dist/components/fx-text.cjs.map +1 -1
- package/dist/components/fx-text.d.cts +2 -2
- package/dist/components/fx-text.d.ts +2 -2
- package/dist/components/fx-text.js +2 -2
- package/dist/components/fx-text.js.map +1 -1
- package/dist/components/fx-transitions.cjs +2 -2
- package/dist/components/fx-transitions.cjs.map +1 -1
- package/dist/components/fx-transitions.d.cts +2 -2
- package/dist/components/fx-transitions.d.ts +2 -2
- package/dist/components/fx-transitions.js +2 -2
- package/dist/components/fx-transitions.js.map +1 -1
- package/dist/components/fx-weather.cjs +2 -2
- package/dist/components/fx-weather.cjs.map +1 -1
- package/dist/components/fx-weather.d.cts +2 -2
- package/dist/components/fx-weather.d.ts +2 -2
- package/dist/components/fx-weather.js +2 -2
- package/dist/components/fx-weather.js.map +1 -1
- package/dist/components/fx2.cjs +37 -22
- package/dist/components/fx2.cjs.map +1 -1
- package/dist/components/fx2.d.cts +135 -14
- package/dist/components/fx2.d.ts +135 -14
- package/dist/components/fx2.js +25 -21
- package/dist/components/fx2.js.map +1 -1
- package/dist/components/interaction.cjs +11 -94
- package/dist/components/interaction.cjs.map +1 -1
- package/dist/components/interaction.css +0 -1
- package/dist/components/interaction.d.cts +3 -21
- package/dist/components/interaction.d.ts +3 -21
- package/dist/components/interaction.js +12 -94
- package/dist/components/interaction.js.map +1 -1
- package/dist/components/jsx.d.cts +2 -2
- package/dist/components/jsx.d.ts +2 -2
- package/dist/components/lazy.cjs +1 -1
- package/dist/components/lazy.d.cts +2 -2
- package/dist/components/lazy.d.ts +2 -2
- package/dist/components/lazy.js +1 -1
- package/dist/components/lite.cjs +115 -256
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +116 -255
- package/dist/components/lite.js.map +1 -1
- package/dist/components/marketplace.cjs +82 -0
- package/dist/components/marketplace.cjs.map +1 -0
- package/dist/components/marketplace.d.cts +108 -0
- package/dist/components/marketplace.d.ts +108 -0
- package/dist/components/marketplace.js +77 -0
- package/dist/components/marketplace.js.map +1 -0
- package/dist/components/perf.cjs +1 -1
- package/dist/components/perf.d.cts +2 -2
- package/dist/components/perf.d.ts +2 -2
- package/dist/components/perf.js +1 -1
- package/dist/components/react.cjs +2 -2
- package/dist/components/react.cjs.map +1 -1
- package/dist/components/react.js +2 -2
- package/dist/components/react.js.map +1 -1
- package/dist/components/solid.cjs +2 -2
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +4 -35
- package/dist/components/solid.d.ts +4 -35
- package/dist/components/solid.js +2 -2
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +2 -2
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +5 -36
- package/dist/components/svelte.d.ts +5 -36
- package/dist/components/svelte.js +2 -2
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/ui.cjs +16 -74
- package/dist/components/ui.cjs.map +1 -1
- package/dist/components/ui.css +0 -1
- package/dist/components/ui.d.cts +3 -18
- package/dist/components/ui.d.ts +3 -18
- package/dist/components/ui.js +17 -74
- package/dist/components/ui.js.map +1 -1
- package/dist/components/vue.cjs +2 -2
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +5 -36
- package/dist/components/vue.d.ts +5 -36
- package/dist/components/vue.js +2 -2
- package/dist/components/vue.js.map +1 -1
- package/dist/components/widgets.cjs +622 -53
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +106 -2
- package/dist/components/widgets.d.ts +106 -2
- package/dist/components/widgets.js +615 -54
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs +1 -3
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +0 -2
- package/dist/components.d.cts +6 -39
- package/dist/components.d.ts +6 -39
- package/dist/components.js +3 -3
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +12 -12
- package/docs/accessibility.md +2 -2
- package/docs/components.md +41 -2
- package/docs/deprecations.md +4 -0
- package/docs/frameworks-ssr.md +4 -4
- package/docs/hybrid-apps.md +2 -2
- package/docs/upgrading-7.md +43 -0
- package/docs/windows-apps.md +1 -1
- package/package.json +133 -2
- package/dist/chunks/gpu-BBRLgEzM.cjs.map +0 -1
- package/dist/chunks/gpu-CsP2ZB3x.js.map +0 -1
- package/dist/chunks/index-tags-DucKMQr_.js.map +0 -1
- package/dist/chunks/index-tags-wv0R_vkO.cjs.map +0 -1
package/dist/components/fx2.d.ts
CHANGED
|
@@ -41,6 +41,69 @@ interface EffectDefinition<O extends Record<string, unknown> = Record<string, an
|
|
|
41
41
|
run(el: HTMLElement, options: O, ctx: EffectContext): void | Cleanup | Animation | null | Promise<unknown>;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
/**
|
|
45
|
+
* 6.9 — effect marketplace manifest (`motionary/components/marketplace`).
|
|
46
|
+
*
|
|
47
|
+
* A third-party effect pack is an ES module that exports its effects (an
|
|
48
|
+
* `EffectDefinition[]` as `effects` or `default`) plus a JSON manifest:
|
|
49
|
+
*
|
|
50
|
+
* ```json
|
|
51
|
+
* { "format": "motionary/effect-pack", "version": 1,
|
|
52
|
+
* "name": "@acme/motion-snow", "packVersion": "1.2.0",
|
|
53
|
+
* "description": "Snow and frost effects", "license": "MIT",
|
|
54
|
+
* "author": "Acme", "entry": "./dist/index.js", "requires": ">=6.9",
|
|
55
|
+
* "effects": [{ "name": "frost", "kind": "background", "description": "…",
|
|
56
|
+
* "defaults": { "speed": 1 } }] }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* `packManifest()` writes one from your effects, `validateManifest()` checks
|
|
60
|
+
* one (format, semver, unique kebab-case names, known kinds, effects match
|
|
61
|
+
* the module), and `loadEffectPack()` imports a pack (URL or module),
|
|
62
|
+
* validates it and registers its effects — refusing names that already
|
|
63
|
+
* exist unless `override`.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
declare const EFFECT_PACK_FORMAT = "motionary/effect-pack";
|
|
67
|
+
interface EffectPackManifest {
|
|
68
|
+
format: typeof EFFECT_PACK_FORMAT;
|
|
69
|
+
version: 1;
|
|
70
|
+
name: string;
|
|
71
|
+
packVersion: string;
|
|
72
|
+
description?: string;
|
|
73
|
+
license?: string;
|
|
74
|
+
author?: string;
|
|
75
|
+
homepage?: string;
|
|
76
|
+
entry?: string;
|
|
77
|
+
requires?: string;
|
|
78
|
+
keywords?: string[];
|
|
79
|
+
effects: {
|
|
80
|
+
name: string;
|
|
81
|
+
kind: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
defaults?: Record<string, unknown>;
|
|
84
|
+
}[];
|
|
85
|
+
}
|
|
86
|
+
/** Build a manifest from an effect pack. */
|
|
87
|
+
declare function packManifest(name: string, packVersion: string, effects: EffectDefinition[], extra?: Partial<Omit<EffectPackManifest, 'format' | 'version' | 'name' | 'packVersion' | 'effects'>>): EffectPackManifest;
|
|
88
|
+
/** Check a manifest (and optionally the module's effects against it). */
|
|
89
|
+
declare function validateManifest(m: unknown, effects?: EffectDefinition[]): {
|
|
90
|
+
ok: boolean;
|
|
91
|
+
errors: string[];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Import an effect pack (a URL / specifier, or an already imported module
|
|
95
|
+
* with `effects` / `default` and `manifest`), validate and register it.
|
|
96
|
+
* Returns the registered effect names.
|
|
97
|
+
*/
|
|
98
|
+
declare function loadEffectPack(src: string | {
|
|
99
|
+
effects?: EffectDefinition[];
|
|
100
|
+
default?: EffectDefinition[];
|
|
101
|
+
manifest?: EffectPackManifest;
|
|
102
|
+
}, opts?: {
|
|
103
|
+
manifest?: EffectPackManifest;
|
|
104
|
+
override?: boolean;
|
|
105
|
+
}): Promise<string[]>;
|
|
106
|
+
|
|
44
107
|
/**
|
|
45
108
|
* 6.2 — GPU effect pack (`motionary/components/fx-gpu`), registered through
|
|
46
109
|
* `registerEffect()`:
|
|
@@ -58,7 +121,7 @@ interface EffectDefinition<O extends Record<string, unknown> = Record<string, an
|
|
|
58
121
|
|
|
59
122
|
declare const GPU_FX: EffectDefinition[];
|
|
60
123
|
/** Register the 6.2 GPU pack (idempotent). */
|
|
61
|
-
declare function
|
|
124
|
+
declare function registerGpuPack(): void;
|
|
62
125
|
|
|
63
126
|
/**
|
|
64
127
|
* 6.3 — Text effects 3.0 (`motionary/components/fx-text`), registered through
|
|
@@ -84,7 +147,7 @@ declare function registerGpuEffects(): void;
|
|
|
84
147
|
declare function splitChars(el: HTMLElement): HTMLElement[];
|
|
85
148
|
declare const TEXT3_FX: EffectDefinition[];
|
|
86
149
|
/** Register the 6.3 text pack (idempotent). */
|
|
87
|
-
declare function
|
|
150
|
+
declare function registerTextPack(): void;
|
|
88
151
|
|
|
89
152
|
/**
|
|
90
153
|
* 6.4 — Light & materials (`motionary/components/fx-light`), registered
|
|
@@ -112,7 +175,7 @@ declare function registerTextEffects3(): void;
|
|
|
112
175
|
declare function trackPointer(el: HTMLElement, ctx: EffectContext, fn: (x: number, y: number, inside: boolean) => void, x0?: number, y0?: number): () => void;
|
|
113
176
|
declare const LIGHT_FX: EffectDefinition[];
|
|
114
177
|
/** Register the 6.4 light & materials pack (idempotent). */
|
|
115
|
-
declare function
|
|
178
|
+
declare function registerLightPack(): void;
|
|
116
179
|
|
|
117
180
|
/**
|
|
118
181
|
* 6.5 — 3D scene cards (`motionary/components/fx-3d`), registered through
|
|
@@ -135,7 +198,7 @@ declare function registerLightEffects(): void;
|
|
|
135
198
|
|
|
136
199
|
declare const DEPTH3_FX: EffectDefinition[];
|
|
137
200
|
/** Register the 6.5 3D pack (idempotent). */
|
|
138
|
-
declare function
|
|
201
|
+
declare function register3dPack(): void;
|
|
139
202
|
|
|
140
203
|
/**
|
|
141
204
|
* 6.6 — Morph & SVG 2.0 (`motionary/components/fx-morph`), registered
|
|
@@ -162,7 +225,7 @@ declare function samplePath(d: string, n?: number): [number, number][] | null;
|
|
|
162
225
|
declare const pointsToPath: (pts: [number, number][]) => string;
|
|
163
226
|
declare const MORPH2_FX: EffectDefinition[];
|
|
164
227
|
/** Register the 6.6 morph & SVG pack (idempotent). */
|
|
165
|
-
declare function
|
|
228
|
+
declare function registerMorphPack(): void;
|
|
166
229
|
|
|
167
230
|
/**
|
|
168
231
|
* 6.7 — Transitions 2.0 (`motionary/components/fx-transitions`), registered
|
|
@@ -195,7 +258,7 @@ declare function pageTransition(update: () => void | Promise<void>, effect?: str
|
|
|
195
258
|
/** Opt a multi-page site into cross-document view transitions with an effect's look. Returns a remover. */
|
|
196
259
|
declare function crossDocumentTransitions(effect?: string, duration?: number): () => void;
|
|
197
260
|
/** Register the 6.7 transitions pack (idempotent). */
|
|
198
|
-
declare function
|
|
261
|
+
declare function registerTransitionsPack(): void;
|
|
199
262
|
|
|
200
263
|
/**
|
|
201
264
|
* 6.8 — Weather & ambience (`motionary/components/fx-weather`), registered
|
|
@@ -221,7 +284,7 @@ declare function registerTransitionEffects2(): void;
|
|
|
221
284
|
declare function skyAt(hour: number): [string, string];
|
|
222
285
|
declare const WEATHER_FX: EffectDefinition[];
|
|
223
286
|
/** Register the 6.8 weather & ambience pack (idempotent). */
|
|
224
|
-
declare function
|
|
287
|
+
declare function registerWeatherPack(): void;
|
|
225
288
|
|
|
226
289
|
/**
|
|
227
290
|
* 6.8 — Interactive physics 2.0 (`motionary/components/fx-physics`) on a tiny
|
|
@@ -268,7 +331,28 @@ declare class VerletWorld {
|
|
|
268
331
|
}
|
|
269
332
|
declare const PHYSICS2_FX: EffectDefinition[];
|
|
270
333
|
/** Register the 6.8 physics 2.0 pack (idempotent). */
|
|
271
|
-
declare function
|
|
334
|
+
declare function registerPhysicsPack(): void;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* 6.9 — Focus & feedback (`motionary/components/fx-focus`), registered
|
|
338
|
+
* through `registerEffect()`:
|
|
339
|
+
*
|
|
340
|
+
* - `focus-draw` (kind `attention`) — a rounded ring draws itself around the
|
|
341
|
+
* element, then fades (great on `focus`).
|
|
342
|
+
* - `marching-ants` (kind `loop`) — a dashed selection border that marches
|
|
343
|
+
* (drop targets, selections).
|
|
344
|
+
* - `success-check` (kind `click`) — a check mark draws over the element on a
|
|
345
|
+
* soft green disc, then fades away.
|
|
346
|
+
* - `highlight-sweep` (kind `attention`) — a highlighter stroke sweeps
|
|
347
|
+
* behind the element's text.
|
|
348
|
+
*
|
|
349
|
+
* Overlays are SVG / spans marked `aria-hidden` and removed when done.
|
|
350
|
+
* Reduced motion: a plain fade of the final state (marching-ants is static).
|
|
351
|
+
*/
|
|
352
|
+
|
|
353
|
+
declare const FOCUS_FX: EffectDefinition[];
|
|
354
|
+
/** Register the 6.9 focus & feedback pack (idempotent). */
|
|
355
|
+
declare function registerFocusPack(): void;
|
|
272
356
|
|
|
273
357
|
/**
|
|
274
358
|
* 5.5 — generative backgrounds on Canvas 2D, registered through
|
|
@@ -314,6 +398,8 @@ interface GenerativeSpec {
|
|
|
314
398
|
/** GLSL shared by every shader: uniforms, hash, value noise, fbm. */
|
|
315
399
|
declare const GLSL_HEAD = "#version 300 es\nprecision highp float;\nuniform vec2 u_res;uniform float u_t;uniform vec3 u_c0,u_c1,u_c2;uniform vec2 u_ptr;uniform float u_speed,u_scale;\nout vec4 o;\nfloat h(vec2 p){return fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453);}\nfloat n(vec2 p){vec2 i=floor(p),f=fract(p);f=f*f*(3.-2.*f);return mix(mix(h(i),h(i+vec2(1,0)),f.x),mix(h(i+vec2(0,1)),h(i+1.),f.x),f.y);}\nfloat fbm(vec2 p){float v=0.,a=.5;for(int k=0;k<5;k++){v+=a*n(p);p=p*2.03+vec2(1.7,9.2);a*=.5;}return v;}\n";
|
|
316
400
|
interface ShaderSpec {
|
|
401
|
+
/** 7.0: hand-written WGSL statements for the WebGPU backend (default: `glslToWgsl(body)`). */
|
|
402
|
+
wgsl?: string;
|
|
317
403
|
/** GLSL body of `main()`: `uv` (0–1), `p` (aspect-corrected, scaled), `t` (s × speed) are in scope; write `o`. */
|
|
318
404
|
body: string;
|
|
319
405
|
/** Canvas 2D fallback. */
|
|
@@ -322,7 +408,9 @@ interface ShaderSpec {
|
|
|
322
408
|
declare function supportsWebGL2(): boolean;
|
|
323
409
|
/**
|
|
324
410
|
* Mount a shader background behind `el` (options: `colors` [3 hex], `speed`,
|
|
325
|
-
* `scale`, `quality`, `backend` = `'auto' | 'webgl2' | 'canvas'`).
|
|
411
|
+
* `scale`, `quality`, `backend` = `'auto' | 'webgpu' | 'webgl2' | 'canvas'`).
|
|
412
|
+
* 7.0: `auto` tries WebGPU first, then WebGL2, then Canvas 2D
|
|
413
|
+
* (`el.dataset.usaBackend` names the one running). Returns the cleanup.
|
|
326
414
|
*/
|
|
327
415
|
declare function shaderBackground(el: HTMLElement, fx: EffectContext, spec: ShaderSpec, o: any): () => void;
|
|
328
416
|
/**
|
|
@@ -331,6 +419,39 @@ declare function shaderBackground(el: HTMLElement, fx: EffectContext, spec: Shad
|
|
|
331
419
|
*/
|
|
332
420
|
declare function fieldFallback(color: (x: number, y: number, t: number, o: any) => [number, number, number], cell?: number): GenerativeSpec;
|
|
333
421
|
|
|
422
|
+
/**
|
|
423
|
+
* 7.0 — WebGPU backend for the shader backgrounds (`shaderBackground()`).
|
|
424
|
+
*
|
|
425
|
+
* Every 6.x shader is written once as a small GLSL `main()` body. 7.0 runs it
|
|
426
|
+
* on **WebGPU** where the browser has it: `glslToWgsl()` translates the body
|
|
427
|
+
* (types, constructors, literals, loops, uniforms) into a WGSL fragment
|
|
428
|
+
* shader with the same noise helpers; a spec can also ship hand-written
|
|
429
|
+
* `wgsl`. If WebGPU is missing, the adapter / device is refused, or the
|
|
430
|
+
* shader does not compile, the effect falls back to **WebGL2**, then to the
|
|
431
|
+
* Canvas 2D fallback — `el.dataset.usaBackend` says which one runs.
|
|
432
|
+
*/
|
|
433
|
+
|
|
434
|
+
/** WGSL shared by every shader: uniforms, hash, value noise, fbm (mirrors `GLSL_HEAD`). */
|
|
435
|
+
declare const WGSL_HEAD = "struct U{res:vec2f,ptr:vec2f,t:f32,speed:f32,scale:f32,pad:f32,c0:vec4f,c1:vec4f,c2:vec4f};\n@group(0) @binding(0) var<uniform> u:U;\nfn h(p:vec2f)->f32{return fract(sin(dot(p,vec2f(127.1,311.7)))*43758.5453);}\nfn n(p:vec2f)->f32{let i=floor(p);var f=fract(p);f=f*f*(3.0-2.0*f);return mix(mix(h(i),h(i+vec2f(1.0,0.0)),f.x),mix(h(i+vec2f(0.0,1.0)),h(i+vec2f(1.0,1.0)),f.x),f.y);}\nfn fbm(p0:vec2f)->f32{var v=0.0;var a=0.5;var p=p0;for(var k=0;k<5;k++){v+=a*n(p);p=p*2.03+vec2f(1.7,9.2);a*=0.5;}return v;}\n@vertex fn vs(@builtin(vertex_index) i:u32)->@builtin(position) vec4f{var q=array<vec2f,3>(vec2f(-1.0,-1.0),vec2f(3.0,-1.0),vec2f(-1.0,3.0));return vec4f(q[i],0.0,1.0);}\n";
|
|
436
|
+
/**
|
|
437
|
+
* Translate a GLSL `main()` body (the 6.x `ShaderSpec.body` dialect) to WGSL
|
|
438
|
+
* statements. Throws on constructs it does not support (ternaries, `mod`,
|
|
439
|
+
* `discard`, user functions) so the caller can fall back to WebGL2.
|
|
440
|
+
*/
|
|
441
|
+
declare function glslToWgsl(body: string): string;
|
|
442
|
+
/** The full WGSL module for a body. */
|
|
443
|
+
declare const wgslModule: (body: string) => string;
|
|
444
|
+
/** `true` when `navigator.gpu` exists (the adapter may still be refused). */
|
|
445
|
+
declare const supportsWebGPU: () => boolean;
|
|
446
|
+
/**
|
|
447
|
+
* Start a WebGPU shader background behind `el`. Resolves to its cleanup, or
|
|
448
|
+
* `null` when WebGPU cannot run this shader (the caller falls back).
|
|
449
|
+
*/
|
|
450
|
+
declare function webgpuBackground(el: HTMLElement, fx: EffectContext, spec: {
|
|
451
|
+
body: string;
|
|
452
|
+
wgsl?: string;
|
|
453
|
+
}, o: any): Promise<(() => void) | null>;
|
|
454
|
+
|
|
334
455
|
/**
|
|
335
456
|
* The 6.x effect packs, one entry each (`motionary/components/fx-gpu`, …) so
|
|
336
457
|
* their size budgets stay separate. This module (`registerFx2()`) registers
|
|
@@ -338,9 +459,9 @@ declare function fieldFallback(color: (x: number, y: number, t: number, o: any)
|
|
|
338
459
|
*/
|
|
339
460
|
|
|
340
461
|
/** The 6.x effect packs by name. */
|
|
341
|
-
declare const
|
|
342
|
-
/** Register every 6.x pack (idempotent). */
|
|
343
|
-
declare function
|
|
462
|
+
declare const EFFECT_PACKS: Record<string, EffectDefinition[]>;
|
|
463
|
+
/** Register every 6.x effect pack (idempotent). */
|
|
464
|
+
declare function registerEffectPacks(): void;
|
|
344
465
|
|
|
345
|
-
export { DEPTH3_FX,
|
|
346
|
-
export type { ShaderSpec };
|
|
466
|
+
export { DEPTH3_FX, EFFECT_PACKS, EFFECT_PACK_FORMAT, FOCUS_FX, GLSL_HEAD, GPU_FX, LIGHT_FX, MORPH2_FX, PHYSICS2_FX, TEXT3_FX, TRANSITIONS2_FX, VerletWorld, WEATHER_FX, WGSL_HEAD, crossDocumentTransitions, fieldFallback, glslToWgsl, loadEffectPack, packManifest, pageTransition, pointsToPath, register3dPack, registerEffectPacks, registerFocusPack, registerGpuPack, registerLightPack, registerMorphPack, registerPhysicsPack, registerTextPack, registerTransitionsPack, registerWeatherPack, samplePath, shaderBackground, skyAt, splitChars, supportsWebGL2, supportsWebGPU, trackPointer, validateManifest, webgpuBackground, wgslModule };
|
|
467
|
+
export type { EffectPackManifest, ShaderSpec };
|
package/dist/components/fx2.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { EFFECT_PACK_FORMAT, loadEffectPack, packManifest, validateManifest } from './marketplace.js';
|
|
2
|
+
import { G as GPU_FX, r as registerGpuPack } from '../chunks/gpu-Bkw605Ds.js';
|
|
3
|
+
export { a as GLSL_HEAD, W as WGSL_HEAD, f as fieldFallback, g as glslToWgsl, s as shaderBackground, b as supportsWebGL2, c as supportsWebGPU, w as webgpuBackground, d as wgslModule } from '../chunks/gpu-Bkw605Ds.js';
|
|
4
|
+
import { TEXT3_FX, registerTextPack } from './fx-text.js';
|
|
4
5
|
export { splitChars } from './fx-text.js';
|
|
5
|
-
import { LIGHT_FX,
|
|
6
|
+
import { LIGHT_FX, registerLightPack } from './fx-light.js';
|
|
6
7
|
export { trackPointer } from './fx-light.js';
|
|
7
|
-
import { DEPTH3_FX,
|
|
8
|
-
import { MORPH2_FX,
|
|
8
|
+
import { DEPTH3_FX, register3dPack } from './fx-3d.js';
|
|
9
|
+
import { MORPH2_FX, registerMorphPack } from './fx-morph.js';
|
|
9
10
|
export { pointsToPath, samplePath } from './fx-morph.js';
|
|
10
|
-
import { TRANSITIONS2_FX,
|
|
11
|
+
import { TRANSITIONS2_FX, registerTransitionsPack } from './fx-transitions.js';
|
|
11
12
|
export { crossDocumentTransitions, pageTransition } from './fx-transitions.js';
|
|
12
|
-
import { WEATHER_FX,
|
|
13
|
+
import { WEATHER_FX, registerWeatherPack } from './fx-weather.js';
|
|
13
14
|
export { skyAt } from './fx-weather.js';
|
|
14
|
-
import { PHYSICS2_FX,
|
|
15
|
+
import { PHYSICS2_FX, registerPhysicsPack } from './fx-physics.js';
|
|
15
16
|
export { VerletWorld } from './fx-physics.js';
|
|
17
|
+
import { FOCUS_FX, registerFocusPack } from './fx-focus.js';
|
|
16
18
|
import '../chunks/registry-D23neB4M.js';
|
|
17
19
|
import '../chunks/base-DchG4q_S.js';
|
|
18
20
|
import '../chunks/generative-2LhxG5BJ.js';
|
|
19
21
|
import '../chunks/shared-CkKHWrtJ.js';
|
|
20
22
|
|
|
21
23
|
/** The 6.x effect packs by name. */
|
|
22
|
-
const
|
|
24
|
+
const EFFECT_PACKS = {
|
|
23
25
|
gpu: GPU_FX,
|
|
24
26
|
text: TEXT3_FX,
|
|
25
27
|
light: LIGHT_FX,
|
|
@@ -28,18 +30,20 @@ const FX2_PACKS = {
|
|
|
28
30
|
transitions: TRANSITIONS2_FX,
|
|
29
31
|
weather: WEATHER_FX,
|
|
30
32
|
physics: PHYSICS2_FX,
|
|
33
|
+
focus: FOCUS_FX,
|
|
31
34
|
};
|
|
32
|
-
/** Register every 6.x pack (idempotent). */
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
/** Register every 6.x effect pack (idempotent). */
|
|
36
|
+
function registerEffectPacks() {
|
|
37
|
+
registerGpuPack();
|
|
38
|
+
registerTextPack();
|
|
39
|
+
registerLightPack();
|
|
40
|
+
register3dPack();
|
|
41
|
+
registerMorphPack();
|
|
42
|
+
registerTransitionsPack();
|
|
43
|
+
registerWeatherPack();
|
|
44
|
+
registerPhysicsPack();
|
|
45
|
+
registerFocusPack();
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
export { DEPTH3_FX,
|
|
48
|
+
export { DEPTH3_FX, EFFECT_PACKS, FOCUS_FX, GPU_FX, LIGHT_FX, MORPH2_FX, PHYSICS2_FX, TEXT3_FX, TRANSITIONS2_FX, WEATHER_FX, register3dPack, registerEffectPacks, registerFocusPack, registerGpuPack, registerLightPack, registerMorphPack, registerPhysicsPack, registerTextPack, registerTransitionsPack, registerWeatherPack };
|
|
45
49
|
//# sourceMappingURL=fx2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fx2.js","sources":["../../src/components/fx2/index.ts"],"sourcesContent":["/**\n * The 6.x effect packs, one entry each (`motionary/components/fx-gpu`, …) so\n * their size budgets stay separate. This module (`registerFx2()`) registers\n * them all — used by dist/widgets.umd.js and the showcase.\n */\nimport type { EffectDefinition } from '../fx/registry';\nimport { GPU_FX,
|
|
1
|
+
{"version":3,"file":"fx2.js","sources":["../../src/components/fx2/index.ts"],"sourcesContent":["/**\n * The 6.x effect packs, one entry each (`motionary/components/fx-gpu`, …) so\n * their size budgets stay separate. This module (`registerFx2()`) registers\n * them all — used by dist/widgets.umd.js and the showcase.\n */\nimport type { EffectDefinition } from '../fx/registry';\nexport { EFFECT_PACK_FORMAT, packManifest, validateManifest, loadEffectPack } from './manifest';\nexport type { EffectPackManifest } from './manifest';\nimport { GPU_FX, registerGpuPack } from './gpu';\nimport { TEXT3_FX, registerTextPack, splitChars } from './text3';\nimport { LIGHT_FX, registerLightPack, trackPointer } from './light';\nimport { DEPTH3_FX, register3dPack } from './depth3';\nimport { MORPH2_FX, registerMorphPack, samplePath, pointsToPath } from './morph2';\nimport { TRANSITIONS2_FX, registerTransitionsPack, pageTransition, crossDocumentTransitions } from './transitions2';\nimport { WEATHER_FX, registerWeatherPack, skyAt } from './weather';\nimport { PHYSICS2_FX, registerPhysicsPack, VerletWorld } from './physics2';\nimport { FOCUS_FX, registerFocusPack } from './focus';\n\nexport { GPU_FX, registerGpuPack, TEXT3_FX, registerTextPack, splitChars };\nexport { shaderBackground, supportsWebGL2, fieldFallback, GLSL_HEAD } from './gl';\nexport { supportsWebGPU, glslToWgsl, wgslModule, webgpuBackground, WGSL_HEAD } from './webgpu';\nexport type { ShaderSpec } from './gl';\n\nexport { LIGHT_FX, registerLightPack, trackPointer };\n\nexport { DEPTH3_FX, register3dPack };\n\nexport { MORPH2_FX, registerMorphPack, samplePath, pointsToPath };\n\nexport { TRANSITIONS2_FX, registerTransitionsPack, pageTransition, crossDocumentTransitions };\n\nexport { WEATHER_FX, registerWeatherPack, skyAt };\n\nexport { PHYSICS2_FX, registerPhysicsPack, VerletWorld };\n\nexport { FOCUS_FX, registerFocusPack };\n\n/** The 6.x effect packs by name. */\nexport const EFFECT_PACKS: Record<string, EffectDefinition[]> = {\n gpu: GPU_FX,\n text: TEXT3_FX,\n light: LIGHT_FX,\n depth: DEPTH3_FX,\n morph: MORPH2_FX,\n transitions: TRANSITIONS2_FX,\n weather: WEATHER_FX,\n physics: PHYSICS2_FX,\n focus: FOCUS_FX,\n};\n\n/** Register every 6.x effect pack (idempotent). */\nexport function registerEffectPacks(): void {\n registerGpuPack();\n registerTextPack();\n registerLightPack();\n register3dPack();\n registerMorphPack();\n registerTransitionsPack();\n registerWeatherPack();\n registerPhysicsPack();\n registerFocusPack();\n}\n\n\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA;AACO,MAAM,YAAY,GAAuC;AAC9D,IAAA,GAAG,EAAE,MAAM;AACX,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,KAAK,EAAE,QAAQ;AACf,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,WAAW,EAAE,eAAe;AAC5B,IAAA,OAAO,EAAE,UAAU;AACnB,IAAA,OAAO,EAAE,WAAW;AACpB,IAAA,KAAK,EAAE,QAAQ;;AAGjB;SACgB,mBAAmB,GAAA;AACjC,IAAA,eAAe,EAAE;AACjB,IAAA,gBAAgB,EAAE;AAClB,IAAA,iBAAiB,EAAE;AACnB,IAAA,cAAc,EAAE;AAChB,IAAA,iBAAiB,EAAE;AACnB,IAAA,uBAAuB,EAAE;AACzB,IAAA,mBAAmB,EAAE;AACrB,IAAA,mBAAmB,EAAE;AACrB,IAAA,iBAAiB,EAAE;AACrB;;;;"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var base = require('../chunks/base-BaQV-2ha.cjs');
|
|
4
4
|
|
|
5
|
-
var css$
|
|
5
|
+
var css$4 = "usa-ripple{position:relative;display:inline-block;overflow:hidden;isolation:isolate;border-radius:inherit;-webkit-tap-highlight-color:transparent}usa-ripple[block]{display:block}usa-ripple .usa-ripple-wave{position:absolute;border-radius:50%;pointer-events:none;transform:scale(0);z-index:-1;will-change:transform,opacity}";
|
|
6
6
|
|
|
7
7
|
function defineRipple(tag = 'usa-ripple') {
|
|
8
8
|
return base.defineElement(tag, (Base) => class UsaRipple extends Base {
|
|
@@ -49,10 +49,10 @@ function defineRipple(tag = 'usa-ripple') {
|
|
|
49
49
|
else
|
|
50
50
|
setTimeout(() => wave.remove(), 0);
|
|
51
51
|
}
|
|
52
|
-
}, { id: 'ripple', text: css$
|
|
52
|
+
}, { id: 'ripple', text: css$4 });
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
var css$
|
|
55
|
+
var css$3 = "usa-magnetic{display:inline-block}usa-magnetic>*{transform:translate3d(var(--usa-mx,0px),var(--usa-my,0px),0);transition:transform 0.6s cubic-bezier(0.34,1.56,0.64,1)}usa-magnetic[data-active]>*{transition-duration:0.15s;transition-timing-function:ease-out}@media (prefers-reduced-motion:reduce){usa-magnetic>*,usa-tilt,usa-toggle .usa-toggle-knob{transition:none}}";
|
|
56
56
|
|
|
57
57
|
function defineMagnetic(tag = 'usa-magnetic') {
|
|
58
58
|
return base.defineElement(tag, (Base) => class UsaMagnetic extends Base {
|
|
@@ -109,10 +109,10 @@ function defineMagnetic(tag = 'usa-magnetic') {
|
|
|
109
109
|
this._frame = 0;
|
|
110
110
|
this.release();
|
|
111
111
|
}
|
|
112
|
-
}, { id: 'magnetic', text: css$
|
|
112
|
+
}, { id: 'magnetic', text: css$3 });
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
var css$
|
|
115
|
+
var css$2 = "usa-tilt{display:block;position:relative;transform-style:preserve-3d;transition:transform 0.5s cubic-bezier(0.22,1,0.36,1);will-change:transform}usa-tilt[data-active]{transition-duration:0.12s}usa-tilt .usa-tilt-glare{position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity 0.3s ease;background:radial-gradient(circle at var(--usa-glare-x,50%) var(--usa-glare-y,50%),rgb(255 255 255 / 0.35),transparent 55%);mix-blend-mode:soft-light}usa-tilt[data-active] .usa-tilt-glare{opacity:1}";
|
|
116
116
|
|
|
117
117
|
function defineTilt(tag = 'usa-tilt') {
|
|
118
118
|
return base.defineElement(tag, (Base) => class UsaTilt extends Base {
|
|
@@ -181,10 +181,10 @@ function defineTilt(tag = 'usa-tilt') {
|
|
|
181
181
|
unmount() {
|
|
182
182
|
this.reset();
|
|
183
183
|
}
|
|
184
|
-
}, { id: 'tilt', text: css$
|
|
184
|
+
}, { id: 'tilt', text: css$2 });
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
var css$
|
|
187
|
+
var css$1 = "usa-spotlight{display:block;--usa-spot-size:160px;--usa-spot-color:rgb(255 255 255 / 0.55);--usa-spot-border:1px}usa-spotlight .usa-spotlight-item{position:relative;isolation:isolate}usa-spotlight .usa-spotlight-item::before,usa-spotlight .usa-spotlight-item::after{content:\"\";position:absolute;inset:0;border-radius:inherit;pointer-events:none;opacity:0;transition:opacity 0.25s ease}usa-spotlight .usa-spotlight-item::before{padding:var(--usa-spot-border);background:radial-gradient(var(--usa-spot-size) circle at var(--usa-spot-x,-999px) var(--usa-spot-y,-999px),var(--usa-spot-color),transparent 70%);-webkit-mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0);mask:linear-gradient(#000 0 0) content-box exclude,linear-gradient(#000 0 0)}usa-spotlight .usa-spotlight-item::after{z-index:-1;background:radial-gradient(calc(var(--usa-spot-size) * 0.9) circle at var(--usa-spot-x,-999px) var(--usa-spot-y,-999px),color-mix(in srgb,var(--usa-spot-color) 30%,transparent),transparent 70%)}usa-spotlight[data-lit] .usa-spotlight-item::before{opacity:1}usa-spotlight[data-lit] .usa-spotlight-item:hover::after{opacity:1}usa-spotlight[no-fill] .usa-spotlight-item::after{display:none}";
|
|
188
188
|
|
|
189
189
|
function defineSpotlight(tag = 'usa-spotlight') {
|
|
190
190
|
return base.defineElement(tag, (Base) => class UsaSpotlight extends Base {
|
|
@@ -246,10 +246,10 @@ function defineSpotlight(tag = 'usa-spotlight') {
|
|
|
246
246
|
this._frame = 0;
|
|
247
247
|
this.removeAttribute('data-lit');
|
|
248
248
|
}
|
|
249
|
-
}, { id: 'spotlight', text: css$
|
|
249
|
+
}, { id: 'spotlight', text: css$1 });
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
var css
|
|
252
|
+
var css = "usa-press{display:inline-block;touch-action:manipulation;-webkit-tap-highlight-color:transparent}usa-press[block]{display:block}";
|
|
253
253
|
|
|
254
254
|
function definePress(tag = 'usa-press') {
|
|
255
255
|
return base.defineElement(tag, (Base) => class UsaPress extends Base {
|
|
@@ -315,94 +315,13 @@ function definePress(tag = 'usa-press') {
|
|
|
315
315
|
this._anim = null;
|
|
316
316
|
this._down = false;
|
|
317
317
|
}
|
|
318
|
-
}, { id: 'press', text: css
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
var css = "usa-toggle{--usa-toggle-w:40px;--usa-toggle-h:20px;--usa-toggle-on:var(--usa-accent,#7c5cff);--usa-toggle-off:transparent;--usa-toggle-line:currentColor;display:inline-flex;align-items:center;gap:0.6em;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;vertical-align:middle}usa-toggle[disabled]{cursor:not-allowed;opacity:0.45}usa-toggle .usa-toggle-track{position:relative;flex:none;width:var(--usa-toggle-w);height:var(--usa-toggle-h);border-radius:999px;box-sizing:border-box;border:1px solid color-mix(in srgb,var(--usa-toggle-line) 60%,transparent);background:var(--usa-toggle-off);transition:background-color 0.2s ease,border-color 0.2s ease}usa-toggle .usa-toggle-knob{position:absolute;top:50%;left:3px;width:calc(var(--usa-toggle-h) - 8px);height:calc(var(--usa-toggle-h) - 8px);margin-top:calc((var(--usa-toggle-h) - 8px) / -2);border-radius:999px;background:color-mix(in srgb,var(--usa-toggle-line) 75%,transparent);transform-origin:left center;transition:transform 0.28s cubic-bezier(0.34,1.4,0.64,1),background-color 0.2s ease}usa-toggle:hover .usa-toggle-knob{transform:scale(1.15)}usa-toggle[data-pressed] .usa-toggle-knob{transform:scaleX(1.45)}usa-toggle[checked] .usa-toggle-track{background:var(--usa-toggle-on);border-color:var(--usa-toggle-on)}usa-toggle[checked] .usa-toggle-knob{background:#fff;transform:translateX(calc(var(--usa-toggle-w) - var(--usa-toggle-h)));transform-origin:right center}usa-toggle[checked]:hover .usa-toggle-knob{transform:translateX(calc(var(--usa-toggle-w) - var(--usa-toggle-h))) scale(1.15)}usa-toggle[checked][data-pressed] .usa-toggle-knob{transform:translateX(calc(var(--usa-toggle-w) - var(--usa-toggle-h) - 4px)) scaleX(1.45)}usa-toggle:focus-visible{outline:none}usa-toggle:focus-visible .usa-toggle-track{outline:2px solid var(--usa-toggle-on);outline-offset:2px}";
|
|
322
|
-
|
|
323
|
-
function defineToggle(tag = 'usa-toggle') {
|
|
324
|
-
return base.defineElement(tag, (Base) => { var _a; return _a = class UsaToggle extends Base {
|
|
325
|
-
static get observedAttributes() {
|
|
326
|
-
return ['checked', 'disabled', 'label'];
|
|
327
|
-
}
|
|
328
|
-
constructor() {
|
|
329
|
-
super();
|
|
330
|
-
this._internals = null;
|
|
331
|
-
try {
|
|
332
|
-
this._internals = typeof this.attachInternals === 'function' ? this.attachInternals() : null;
|
|
333
|
-
}
|
|
334
|
-
catch {
|
|
335
|
-
this._internals = null;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
get checked() {
|
|
339
|
-
return this.hasAttribute('checked');
|
|
340
|
-
}
|
|
341
|
-
set checked(v) {
|
|
342
|
-
this.toggleAttribute('checked', !!v);
|
|
343
|
-
}
|
|
344
|
-
get disabled() {
|
|
345
|
-
return this.hasAttribute('disabled');
|
|
346
|
-
}
|
|
347
|
-
set disabled(v) {
|
|
348
|
-
this.toggleAttribute('disabled', !!v);
|
|
349
|
-
}
|
|
350
|
-
changed() {
|
|
351
|
-
this.sync();
|
|
352
|
-
}
|
|
353
|
-
sync() {
|
|
354
|
-
this.setAttribute('aria-checked', String(this.checked));
|
|
355
|
-
this.setAttribute('aria-disabled', String(this.disabled));
|
|
356
|
-
this.tabIndex = this.disabled ? -1 : 0;
|
|
357
|
-
const label = this.getAttribute('label');
|
|
358
|
-
if (label && !this.hasAttribute('aria-label'))
|
|
359
|
-
this.setAttribute('aria-label', label);
|
|
360
|
-
this._internals?.setFormValue?.(this.checked ? this.str('value', 'on') : null);
|
|
361
|
-
}
|
|
362
|
-
mount() {
|
|
363
|
-
if (!this.querySelector(':scope > .usa-toggle-track')) {
|
|
364
|
-
const track = document.createElement('span');
|
|
365
|
-
track.className = 'usa-toggle-track';
|
|
366
|
-
track.setAttribute('aria-hidden', 'true');
|
|
367
|
-
const knob = document.createElement('span');
|
|
368
|
-
knob.className = 'usa-toggle-knob';
|
|
369
|
-
track.append(knob);
|
|
370
|
-
this.prepend(track);
|
|
371
|
-
}
|
|
372
|
-
this.setAttribute('role', 'switch');
|
|
373
|
-
this.sync();
|
|
374
|
-
this.listen(this, 'click', () => this.toggle());
|
|
375
|
-
this.listen(this, 'keydown', (e) => {
|
|
376
|
-
if (e.key === ' ' || e.key === 'Enter') {
|
|
377
|
-
e.preventDefault();
|
|
378
|
-
if (!e.repeat)
|
|
379
|
-
this.toggle();
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
this.listen(this, 'pointerdown', () => !this.disabled && this.setAttribute('data-pressed', ''));
|
|
383
|
-
for (const t of ['pointerup', 'pointerleave', 'pointercancel'])
|
|
384
|
-
this.listen(this, t, () => this.removeAttribute('data-pressed'));
|
|
385
|
-
}
|
|
386
|
-
toggle(force) {
|
|
387
|
-
if (this.disabled)
|
|
388
|
-
return;
|
|
389
|
-
const next = force === undefined ? !this.checked : force;
|
|
390
|
-
if (next === this.checked)
|
|
391
|
-
return;
|
|
392
|
-
this.checked = next;
|
|
393
|
-
this.sync();
|
|
394
|
-
this.dispatchEvent(new Event('change', { bubbles: true }));
|
|
395
|
-
this.emit('change', { checked: next });
|
|
396
|
-
}
|
|
397
|
-
},
|
|
398
|
-
_a.formAssociated = true,
|
|
399
|
-
_a; }, { id: 'toggle', text: css });
|
|
318
|
+
}, { id: 'press', text: css });
|
|
400
319
|
}
|
|
401
320
|
|
|
402
321
|
/**
|
|
403
322
|
* motionary/components/interaction — micro-interactions.
|
|
404
323
|
* `<usa-ripple>`, `<usa-magnetic>`, `<usa-tilt>`, `<usa-spotlight>`,
|
|
405
|
-
* `<usa-press
|
|
324
|
+
* `<usa-press>`.
|
|
406
325
|
*/
|
|
407
326
|
/** Register every component of this category under its default tag. */
|
|
408
327
|
function defineInteractionComponents() {
|
|
@@ -411,7 +330,6 @@ function defineInteractionComponents() {
|
|
|
411
330
|
defineTilt();
|
|
412
331
|
defineSpotlight();
|
|
413
332
|
definePress();
|
|
414
|
-
defineToggle();
|
|
415
333
|
}
|
|
416
334
|
|
|
417
335
|
exports.defineInteractionComponents = defineInteractionComponents;
|
|
@@ -420,5 +338,4 @@ exports.definePress = definePress;
|
|
|
420
338
|
exports.defineRipple = defineRipple;
|
|
421
339
|
exports.defineSpotlight = defineSpotlight;
|
|
422
340
|
exports.defineTilt = defineTilt;
|
|
423
|
-
exports.defineToggle = defineToggle;
|
|
424
341
|
//# sourceMappingURL=interaction.cjs.map
|