fancy-ui-vue 0.3.0 → 0.4.1

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 (102) hide show
  1. package/README.md +9 -6
  2. package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +23 -12
  3. package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +10 -1
  4. package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +6 -0
  5. package/dist/components/bg-falling-stars/bg-falling-stars-core.js +24 -2
  6. package/dist/components/bg-stars/StarsBackground.vue.js +1 -1
  7. package/dist/components/bg-stars/StarsBackground.vue2.js +13 -1
  8. package/dist/components/bg-stars/bg-stars-core.d.ts +6 -0
  9. package/dist/components/bg-stars/bg-stars-core.js +21 -1
  10. package/dist/components/book/Book.vue.js +5 -83
  11. package/dist/components/book/Book.vue2.js +82 -1
  12. package/dist/components/box-reveal/BoxReveal.vue.js +5 -47
  13. package/dist/components/box-reveal/BoxReveal.vue2.js +48 -1
  14. package/dist/components/compare/StarField.vue.js +1 -1
  15. package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
  16. package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +14 -5
  17. package/dist/components/flickering-grid/FlickeringGrid.vue.js +19 -1
  18. package/dist/components/flickering-grid/flickering-grid-core.d.ts +6 -0
  19. package/dist/components/flickering-grid/flickering-grid-core.js +30 -1
  20. package/dist/components/flip-words/FlipWords.vue.js +1 -1
  21. package/dist/components/flip-words/FlipWords.vue2.js +14 -7
  22. package/dist/components/hyper-text/HyperText.vue.js +6 -97
  23. package/dist/components/hyper-text/HyperText.vue2.js +101 -0
  24. package/dist/components/letter-pullup/LetterPullup.vue.js +6 -38
  25. package/dist/components/letter-pullup/LetterPullup.vue2.js +40 -0
  26. package/dist/components/logo-cloud/AnimatedLogoCloud.vue.js +1 -1
  27. package/dist/components/magnetic-field/MagnetPuck.vue.d.ts +51 -0
  28. package/dist/components/magnetic-field/MagnetPuck.vue.js +7 -0
  29. package/dist/components/magnetic-field/MagnetPuck.vue2.js +191 -0
  30. package/dist/components/magnetic-field/MagneticField.vue.d.ts +39 -0
  31. package/dist/components/magnetic-field/MagneticField.vue.js +7 -0
  32. package/dist/components/magnetic-field/MagneticField.vue2.js +157 -0
  33. package/dist/components/magnetic-field/MagneticItem.vue.d.ts +28 -0
  34. package/dist/components/magnetic-field/MagneticItem.vue.js +7 -0
  35. package/dist/components/magnetic-field/MagneticItem.vue2.js +72 -0
  36. package/dist/components/magnetic-field/index.d.ts +10 -0
  37. package/dist/components/magnetic-field/magnetic-field-core.d.ts +163 -0
  38. package/dist/components/magnetic-field/magnetic-field-core.js +534 -0
  39. package/dist/components/magnetic-field/magnetic-field-source.d.ts +58 -0
  40. package/dist/components/magnetic-field/magnetic-field-source.js +58 -0
  41. package/dist/components/magnetic-field/types.d.ts +14 -0
  42. package/dist/components/magnetic-field/types.js +5 -0
  43. package/dist/components/matrix-rain/MatrixRain.vue.js +20 -1
  44. package/dist/components/matrix-rain/matrix-rain-core.d.ts +6 -0
  45. package/dist/components/matrix-rain/matrix-rain-core.js +28 -6
  46. package/dist/components/noise-reveal/NoiseReveal.vue.js +7 -0
  47. package/dist/components/noise-reveal/noise-reveal-core.js +23 -7
  48. package/dist/components/pixel-scene/PixelScene.vue.d.ts +60 -0
  49. package/dist/components/pixel-scene/PixelScene.vue.js +184 -0
  50. package/dist/components/pixel-scene/PixelScene.vue2.js +4 -0
  51. package/dist/components/pixel-scene/index.d.ts +4 -0
  52. package/dist/components/pixel-scene/pixel-scene-core.d.ts +256 -0
  53. package/dist/components/pixel-scene/pixel-scene-core.js +878 -0
  54. package/dist/components/pixel-scene/pixel-scene-hdr.d.ts +68 -0
  55. package/dist/components/pixel-scene/pixel-scene-hdr.js +312 -0
  56. package/dist/components/pixel-scene/pixel-scene-scenes.d.ts +31 -0
  57. package/dist/components/pixel-scene/pixel-scene-scenes.js +1074 -0
  58. package/dist/components/ripple/Ripple.vue.js +1 -1
  59. package/dist/components/ripple/Ripple.vue2.js +6 -1
  60. package/dist/components/sparkles/Sparkles.vue.js +10 -1
  61. package/dist/components/sparkles/sparkles-core.d.ts +6 -0
  62. package/dist/components/sparkles/sparkles-core.js +26 -2
  63. package/dist/components/sparkles-text/SparklesText.vue.js +6 -88
  64. package/dist/components/sparkles-text/SparklesText.vue2.js +100 -0
  65. package/dist/components/story-thread/StoryNode.vue.d.ts +11 -0
  66. package/dist/components/story-thread/StoryNode.vue.js +7 -0
  67. package/dist/components/story-thread/StoryNode.vue2.js +23 -0
  68. package/dist/components/story-thread/StoryThread.vue.d.ts +56 -0
  69. package/dist/components/story-thread/StoryThread.vue.js +7 -0
  70. package/dist/components/story-thread/StoryThread.vue2.js +103 -0
  71. package/dist/components/story-thread/index.d.ts +5 -0
  72. package/dist/components/story-thread/story-thread-core.d.ts +119 -0
  73. package/dist/components/story-thread/story-thread-core.js +491 -0
  74. package/dist/components/story-thread/types.d.ts +1 -0
  75. package/dist/components/sun-switch/SunSwitch.vue.d.ts +61 -0
  76. package/dist/components/sun-switch/SunSwitch.vue.js +7 -0
  77. package/dist/components/sun-switch/SunSwitch.vue2.js +559 -0
  78. package/dist/components/sun-switch/index.d.ts +4 -0
  79. package/dist/components/sun-switch/pixel-wave-core.d.ts +82 -0
  80. package/dist/components/sun-switch/pixel-wave-core.js +508 -0
  81. package/dist/components/sun-switch/sun-switch-core.d.ts +251 -0
  82. package/dist/components/sun-switch/sun-switch-core.js +546 -0
  83. package/dist/components/sun-switch/sun-switch-hdr.d.ts +70 -0
  84. package/dist/components/sun-switch/sun-switch-hdr.js +311 -0
  85. package/dist/components/terminal-text/TerminalText.vue.js +1 -1
  86. package/dist/components/terminal-text/TerminalText.vue2.js +36 -4
  87. package/dist/components/text-generate-effect/TextGenerateEffect.vue.js +5 -72
  88. package/dist/components/text-generate-effect/TextGenerateEffect.vue2.js +74 -1
  89. package/dist/components/text-reveal-card/TextRevealCard.vue.js +5 -101
  90. package/dist/components/text-reveal-card/TextRevealCard.vue2.js +98 -1
  91. package/dist/components/text-reveal-card/TextRevealStars.vue.js +1 -1
  92. package/dist/components/text-reveal-card/TextRevealStars.vue2.js +29 -12
  93. package/dist/components/tracing-beam/TracingBeam.vue.d.ts +20 -1
  94. package/dist/components/tracing-beam/TracingBeam.vue.js +5 -164
  95. package/dist/components/tracing-beam/TracingBeam.vue2.js +168 -1
  96. package/dist/index.d.ts +4 -0
  97. package/dist/index.js +361 -338
  98. package/dist/styles.css +731 -89
  99. package/package.json +1 -1
  100. package/dist/components/hyper-text/HyperText.vue3.js +0 -5
  101. package/dist/components/letter-pullup/LetterPullup.vue3.js +0 -5
  102. package/dist/components/sparkles-text/SparklesText.vue3.js +0 -5
@@ -0,0 +1,508 @@
1
+ import { SUN_PALETTE, easeInOutCubic, parseInk, staircaseHoleClip, paintSheet, paintHalo, staircasePolygon, coverRadiusCells, staircaseRows, gridOffset } from "./sun-switch-core.js";
2
+ import { sunHdrAvailable, startSunHdr } from "./sun-switch-hdr.js";
3
+ const WAVE_ATTR = "data-fancy-sun-waving";
4
+ const WAVE_NAME = "fancy-sun-wave";
5
+ const LIVE_NAME = "fancy-sun-live";
6
+ const WAVE_HDR_NAME = "fancy-sun-wave-hdr";
7
+ const LIVE_HDR_NAME = "fancy-sun-live-hdr";
8
+ const WAVE_STYLE_ID = "fancy-sun-wave-styles";
9
+ const HALO_ATTR = "data-fancy-sun-halo";
10
+ const HALO_HDR_ATTR = "data-fancy-sun-halo-hdr";
11
+ const SHEET_ATTR = "data-fancy-sun-sheet";
12
+ const GHOST_ATTR = "data-fancy-sun-ghost";
13
+ const MAX_WAVE_CANVAS_PIXELS = 16e6;
14
+ function waveCanvasDpr(devicePixelRatio, W, H) {
15
+ const raw = devicePixelRatio > 0 ? devicePixelRatio : 1;
16
+ const dpr = Math.min(2, Math.max(1, Math.floor(raw)));
17
+ return W * H * dpr * dpr > MAX_WAVE_CANVAS_PIXELS ? 1 : dpr;
18
+ }
19
+ const WAVE_CSS = `html[${WAVE_ATTR}]::view-transition-group(root),
20
+ html[${WAVE_ATTR}]::view-transition-old(root),
21
+ html[${WAVE_ATTR}]::view-transition-new(root),
22
+ html[${WAVE_ATTR}]::view-transition-group(${WAVE_NAME}),
23
+ html[${WAVE_ATTR}]::view-transition-new(${WAVE_NAME}),
24
+ html[${WAVE_ATTR}]::view-transition-group(${LIVE_NAME}),
25
+ html[${WAVE_ATTR}]::view-transition-new(${LIVE_NAME}),
26
+ html[${WAVE_ATTR}]::view-transition-group(${WAVE_HDR_NAME}),
27
+ html[${WAVE_ATTR}]::view-transition-new(${WAVE_HDR_NAME}),
28
+ html[${WAVE_ATTR}]::view-transition-group(${LIVE_HDR_NAME}),
29
+ html[${WAVE_ATTR}]::view-transition-new(${LIVE_HDR_NAME}) {
30
+ animation: none;
31
+ mix-blend-mode: normal;
32
+ }
33
+ html[${WAVE_ATTR}]::view-transition-old(${WAVE_NAME}),
34
+ html[${WAVE_ATTR}]::view-transition-old(${LIVE_NAME}),
35
+ html[${WAVE_ATTR}]::view-transition-old(${WAVE_HDR_NAME}),
36
+ html[${WAVE_ATTR}]::view-transition-old(${LIVE_HDR_NAME}) {
37
+ display: none;
38
+ }
39
+ html[${WAVE_ATTR}]::view-transition-new(root) {
40
+ clip-path: polygon(0 0, 0 0, 0 0);
41
+ }
42
+ `;
43
+ const adopted = /* @__PURE__ */ new WeakMap();
44
+ function ensureWaveStyles(doc) {
45
+ const d = doc;
46
+ const Sheet = doc.defaultView?.CSSStyleSheet;
47
+ if (Array.isArray(d.adoptedStyleSheets) && typeof Sheet === "function") {
48
+ const existing = adopted.get(doc);
49
+ if (existing && d.adoptedStyleSheets.includes(existing)) return;
50
+ try {
51
+ const sheet = existing ?? new Sheet();
52
+ if (!existing) sheet.replaceSync(WAVE_CSS);
53
+ d.adoptedStyleSheets = [...d.adoptedStyleSheets, sheet];
54
+ adopted.set(doc, sheet);
55
+ return;
56
+ } catch {
57
+ }
58
+ }
59
+ if (doc.getElementById(WAVE_STYLE_ID)) return;
60
+ const el = doc.createElement("style");
61
+ el.id = WAVE_STYLE_ID;
62
+ el.textContent = WAVE_CSS;
63
+ (doc.head ?? doc.documentElement).append(el);
64
+ }
65
+ function supportsViewTransition(doc) {
66
+ return typeof doc.startViewTransition === "function";
67
+ }
68
+ function firstOpaqueBackground(el) {
69
+ const win = el.ownerDocument.defaultView;
70
+ if (!win) return "#fff";
71
+ const layers = [];
72
+ let base = null;
73
+ for (let n = el; n; n = n.parentElement) {
74
+ const bg = win.getComputedStyle(n).backgroundColor;
75
+ if (!bg) continue;
76
+ const p = parseInk(bg);
77
+ if (!p) {
78
+ if (bg === "transparent") continue;
79
+ base = bg;
80
+ break;
81
+ }
82
+ if (p.a >= 1) {
83
+ base = bg;
84
+ layers.push(p);
85
+ break;
86
+ }
87
+ if (p.a > 0) layers.push(p);
88
+ }
89
+ if (layers.length === 0) return base ?? "#fff";
90
+ const top = layers[0];
91
+ if (layers.length === 1 && top && top.a >= 1) return base ?? "#fff";
92
+ if (base && !parseInk(base)) return base;
93
+ let c = { r: 255, g: 255, b: 255 };
94
+ for (let i = layers.length - 1; i >= 0; i--) {
95
+ const l = layers[i];
96
+ if (!l) continue;
97
+ c = {
98
+ r: l.r * l.a + c.r * (1 - l.a),
99
+ g: l.g * l.a + c.g * (1 - l.a),
100
+ b: l.b * l.a + c.b * (1 - l.a)
101
+ };
102
+ }
103
+ return `rgb(${Math.round(c.r)}, ${Math.round(c.g)}, ${Math.round(c.b)})`;
104
+ }
105
+ const MIN_FLIP_MS = 334;
106
+ let lastFlipAt = -Infinity;
107
+ function flipWait(now) {
108
+ return Math.max(0, lastFlipAt + MIN_FLIP_MS - now);
109
+ }
110
+ function markFlip(now) {
111
+ lastFlipAt = now;
112
+ }
113
+ let active = null;
114
+ function isWaving() {
115
+ return active !== null;
116
+ }
117
+ function report(error) {
118
+ if (typeof console !== "undefined") console.error(error);
119
+ }
120
+ function pixelWave(o) {
121
+ let applied = false;
122
+ const runApply = () => {
123
+ if (applied) return;
124
+ applied = true;
125
+ try {
126
+ o.apply();
127
+ } catch (error) {
128
+ report(error);
129
+ }
130
+ };
131
+ if (active) {
132
+ active.skip();
133
+ runApply();
134
+ return Promise.resolve();
135
+ }
136
+ const doc = typeof document === "undefined" ? null : document;
137
+ const win = doc?.defaultView ?? null;
138
+ if (!doc || !win || !doc.body) {
139
+ runApply();
140
+ return Promise.resolve();
141
+ }
142
+ const reduced = o.reducedMotion ?? (typeof win.matchMedia === "function" && win.matchMedia("(prefers-reduced-motion: reduce)").matches);
143
+ if (reduced) {
144
+ runApply();
145
+ return Promise.resolve();
146
+ }
147
+ const html = doc.documentElement;
148
+ const cell = o.cell && o.cell > 0 ? o.cell : 5;
149
+ const dot = Math.min(o.dot && o.dot > 0 ? o.dot : 4, cell);
150
+ const halo = o.haloCells !== void 0 && o.haloCells >= 0 ? o.haloCells : 9;
151
+ const duration = o.duration !== void 0 && o.duration >= 0 ? o.duration : 1300;
152
+ const palette = o.palette ?? SUN_PALETTE;
153
+ const ease = o.ease ?? easeInOutCubic;
154
+ const now = o.now ?? (() => win.performance.now());
155
+ const scope = (o.mode ?? "document") === "contained" ? o.scope ?? null : null;
156
+ const contained = (o.mode ?? "document") === "contained";
157
+ let W;
158
+ let H;
159
+ let boxLeft = 0;
160
+ let boxTop = 0;
161
+ if (scope) {
162
+ const r = scope.getBoundingClientRect();
163
+ boxLeft = r.left + scope.clientLeft;
164
+ boxTop = r.top + scope.clientTop;
165
+ W = scope.clientWidth;
166
+ H = scope.clientHeight;
167
+ } else {
168
+ W = win.innerWidth;
169
+ H = win.innerHeight;
170
+ }
171
+ const origin = { x: o.origin.x, y: o.origin.y };
172
+ const ox = gridOffset(origin.x - cell / 2, cell);
173
+ const oy = gridOffset(origin.y - cell / 2, cell);
174
+ const tx = (origin.x - ox) / cell;
175
+ const ty = (origin.y - oy) / cell;
176
+ const cover = coverRadiusCells(origin, W, H, cell, halo);
177
+ const dpr = waveCanvasDpr(win.devicePixelRatio, W, H);
178
+ const useVT = !contained && supportsViewTransition(doc) && typeof html.animate === "function";
179
+ const sheetColor = useVT ? "" : o.fill ?? firstOpaqueBackground(scope ?? doc.body);
180
+ const ghost = scope && !useVT ? makeGhost(scope, W, H, sheetColor) : null;
181
+ const canvas = doc.createElement("canvas");
182
+ canvas.setAttribute(HALO_ATTR, "");
183
+ if (!useVT && !ghost) canvas.setAttribute(SHEET_ATTR, "");
184
+ canvas.setAttribute("aria-hidden", "true");
185
+ canvas.width = Math.max(1, Math.round(W * dpr));
186
+ canvas.height = Math.max(1, Math.round(H * dpr));
187
+ const cs = canvas.style;
188
+ cs.position = scope ? "absolute" : "fixed";
189
+ cs.left = "0";
190
+ cs.top = "0";
191
+ cs.width = `${W}px`;
192
+ cs.height = `${H}px`;
193
+ cs.pointerEvents = "none";
194
+ cs.zIndex = "2147483647";
195
+ cs.margin = "0";
196
+ cs.padding = "0";
197
+ cs.border = "0";
198
+ cs.imageRendering = "pixelated";
199
+ let hdrCanvas = null;
200
+ let hdrLayer = null;
201
+ if (o.hdr !== false && sunHdrAvailable()) {
202
+ hdrCanvas = doc.createElement("canvas");
203
+ hdrCanvas.setAttribute(HALO_HDR_ATTR, "");
204
+ hdrCanvas.setAttribute("aria-hidden", "true");
205
+ hdrCanvas.width = canvas.width;
206
+ hdrCanvas.height = canvas.height;
207
+ hdrCanvas.style.cssText = cs.cssText;
208
+ }
209
+ let liveDraw = null;
210
+ if (!useVT && !ghost && o.live && o.live.tagName === "CANVAS") {
211
+ const lr = o.live.getBoundingClientRect();
212
+ liveDraw = {
213
+ el: o.live,
214
+ x: (lr.left - boxLeft) * dpr,
215
+ y: (lr.top - boxTop) * dpr,
216
+ w: lr.width * dpr,
217
+ h: lr.height * dpr
218
+ };
219
+ }
220
+ const hasRaf = typeof win.requestAnimationFrame === "function";
221
+ const request = (cb) => hasRaf ? win.requestAnimationFrame(cb) : win.setTimeout(cb, 16);
222
+ const cancelFrame = (id) => {
223
+ if (!id) return;
224
+ if (hasRaf) win.cancelAnimationFrame(id);
225
+ else win.clearTimeout(id);
226
+ };
227
+ let ctx = null;
228
+ let raf = 0;
229
+ let t0 = null;
230
+ let clipping = useVT;
231
+ let prevAnim = null;
232
+ let lastPoly = "";
233
+ let liveName = "";
234
+ let livePriority = "";
235
+ let liveHdrName = "";
236
+ let liveHdrPriority = "";
237
+ let vt = null;
238
+ let loopDone = false;
239
+ let vtDone = !useVT;
240
+ let done = false;
241
+ let resolve = () => {
242
+ };
243
+ const promise = new Promise((r) => {
244
+ resolve = r;
245
+ });
246
+ const wave = {
247
+ skip() {
248
+ runApply();
249
+ clipping = false;
250
+ prevAnim?.cancel();
251
+ prevAnim = null;
252
+ if (vt) {
253
+ try {
254
+ vt.skipTransition();
255
+ } catch {
256
+ }
257
+ }
258
+ cleanup();
259
+ }
260
+ };
261
+ function cleanup() {
262
+ if (done) return;
263
+ done = true;
264
+ cancelFrame(raf);
265
+ raf = 0;
266
+ canvas.remove();
267
+ hdrCanvas?.remove();
268
+ hdrLayer?.destroy();
269
+ hdrLayer = null;
270
+ ghost?.remove();
271
+ if (useVT) {
272
+ html.removeAttribute(WAVE_ATTR);
273
+ if (o.live) {
274
+ if (liveName) o.live.style.setProperty("view-transition-name", liveName, livePriority);
275
+ else o.live.style.removeProperty("view-transition-name");
276
+ }
277
+ if (o.liveHdr) {
278
+ if (liveHdrName)
279
+ o.liveHdr.style.setProperty("view-transition-name", liveHdrName, liveHdrPriority);
280
+ else o.liveHdr.style.removeProperty("view-transition-name");
281
+ }
282
+ }
283
+ if (active === wave) active = null;
284
+ resolve();
285
+ }
286
+ function maybeFinish() {
287
+ if (loopDone && vtDone) cleanup();
288
+ }
289
+ function frame() {
290
+ raf = 0;
291
+ if (done) return;
292
+ const n = now();
293
+ if (t0 === null) t0 = n;
294
+ const t = duration > 0 ? Math.min(1, Math.max(0, (n - t0) / duration)) : 1;
295
+ const R = ease(t) * cover;
296
+ const rows = staircaseRows(tx, ty, R - halo + 0.5, cell, ox, oy);
297
+ if (ghost) ghost.style.setProperty("clip-path", staircaseHoleClip(rows, W, H));
298
+ if (ctx) {
299
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
300
+ if (!useVT && !ghost) {
301
+ paintSheet(ctx, sheetColor, W, H, dpr, rows);
302
+ if (liveDraw) drawLive(ctx, liveDraw);
303
+ }
304
+ const glow = hdrLayer?.sink ?? null;
305
+ glow?.clear();
306
+ paintHalo(ctx, { cx: tx, cy: ty, R, halo, cell, dot, ox, oy, W, H, palette, dpr, glow });
307
+ hdrLayer?.render(canvas.width, canvas.height, Math.max(1, Math.round(dot * dpr)));
308
+ }
309
+ const poly = clipping && vt ? staircasePolygon(rows) : "";
310
+ if (clipping && vt && poly !== lastPoly) {
311
+ try {
312
+ const keyframes = [{ clipPath: poly }, { clipPath: poly }];
313
+ if (!(prevAnim && setKeyframes(prevAnim, keyframes))) {
314
+ const a = html.animate(keyframes, {
315
+ duration: 1e6,
316
+ fill: "forwards",
317
+ pseudoElement: "::view-transition-new(root)"
318
+ });
319
+ prevAnim?.cancel();
320
+ prevAnim = a;
321
+ }
322
+ lastPoly = poly;
323
+ } catch {
324
+ clipping = false;
325
+ prevAnim?.cancel();
326
+ prevAnim = null;
327
+ try {
328
+ vt.skipTransition();
329
+ } catch {
330
+ }
331
+ }
332
+ }
333
+ if (o.onFront) {
334
+ try {
335
+ o.onFront(R, t);
336
+ } catch (error) {
337
+ report(error);
338
+ }
339
+ }
340
+ if (done) return;
341
+ if (t < 1) {
342
+ raf = request(frame);
343
+ } else {
344
+ prevAnim?.finish();
345
+ loopDone = true;
346
+ maybeFinish();
347
+ }
348
+ }
349
+ active = wave;
350
+ if (ghost && scope) scope.append(ghost);
351
+ (scope ?? doc.body).append(canvas);
352
+ if (hdrCanvas) {
353
+ canvas.after(hdrCanvas);
354
+ void startSunHdr(hdrCanvas).then((layer) => {
355
+ if (done) layer?.destroy();
356
+ else hdrLayer = layer;
357
+ });
358
+ }
359
+ try {
360
+ ctx = typeof canvas.getContext === "function" ? canvas.getContext("2d") : null;
361
+ } catch {
362
+ ctx = null;
363
+ }
364
+ if (useVT) {
365
+ ensureWaveStyles(doc);
366
+ if (o.live) {
367
+ liveName = o.live.style.getPropertyValue("view-transition-name");
368
+ livePriority = o.live.style.getPropertyPriority("view-transition-name");
369
+ o.live.style.setProperty("view-transition-name", LIVE_NAME);
370
+ }
371
+ if (o.liveHdr) {
372
+ liveHdrName = o.liveHdr.style.getPropertyValue("view-transition-name");
373
+ liveHdrPriority = o.liveHdr.style.getPropertyPriority("view-transition-name");
374
+ o.liveHdr.style.setProperty("view-transition-name", LIVE_HDR_NAME);
375
+ }
376
+ canvas.style.setProperty("view-transition-name", WAVE_NAME);
377
+ hdrCanvas?.style.setProperty("view-transition-name", WAVE_HDR_NAME);
378
+ html.setAttribute(WAVE_ATTR, "");
379
+ try {
380
+ const start = doc.startViewTransition;
381
+ vt = start.call(doc, runApply);
382
+ } catch (error) {
383
+ report(error);
384
+ vt = null;
385
+ }
386
+ if (!vt) {
387
+ runApply();
388
+ cleanup();
389
+ return promise;
390
+ }
391
+ const settleVT = () => {
392
+ vtDone = true;
393
+ maybeFinish();
394
+ };
395
+ vt.finished.then(settleVT, settleVT);
396
+ vt.ready.then(
397
+ () => {
398
+ if (!done) raf = request(frame);
399
+ },
400
+ () => {
401
+ loopDone = true;
402
+ maybeFinish();
403
+ }
404
+ );
405
+ } else {
406
+ runApply();
407
+ frame();
408
+ }
409
+ return promise;
410
+ }
411
+ function setKeyframes(anim, keyframes) {
412
+ const effect = anim.effect;
413
+ if (!effect || typeof effect.setKeyframes !== "function") return false;
414
+ try {
415
+ effect.setKeyframes(keyframes);
416
+ return true;
417
+ } catch {
418
+ return false;
419
+ }
420
+ }
421
+ function drawLive(ctx, d) {
422
+ const c = ctx;
423
+ if (typeof c.drawImage !== "function" || !(d.w > 0 && d.h > 0)) return;
424
+ try {
425
+ c.globalCompositeOperation = "source-atop";
426
+ c.drawImage(d.el, d.x, d.y, d.w, d.h);
427
+ } catch {
428
+ } finally {
429
+ c.globalCompositeOperation = "source-over";
430
+ }
431
+ }
432
+ const GHOST_DROP = "iframe, object, embed, video, audio, script";
433
+ function makeGhost(scope, W, H, background) {
434
+ const win = scope.ownerDocument.defaultView;
435
+ const css = win?.CSS;
436
+ try {
437
+ if (!css?.supports?.("clip-path", 'path(evenodd, "M0 0H1V1H0Z")')) return null;
438
+ const ghost = scope.cloneNode(true);
439
+ for (const el of Array.from(ghost.querySelectorAll(GHOST_DROP))) el.remove();
440
+ for (const el of [ghost, ...Array.from(ghost.querySelectorAll("[id], [name]"))]) {
441
+ el.removeAttribute("id");
442
+ el.removeAttribute("name");
443
+ }
444
+ const from = Array.from(scope.querySelectorAll("canvas"));
445
+ const to = Array.from(ghost.querySelectorAll("canvas"));
446
+ from.forEach((src, i) => {
447
+ const dst = to[i];
448
+ if (!dst) return;
449
+ try {
450
+ dst.width = src.width;
451
+ dst.height = src.height;
452
+ dst.getContext("2d")?.drawImage(src, 0, 0);
453
+ } catch {
454
+ }
455
+ });
456
+ ghost.setAttribute(GHOST_ATTR, "");
457
+ ghost.setAttribute("aria-hidden", "true");
458
+ ghost.setAttribute("inert", "");
459
+ const gs = ghost.style;
460
+ gs.position = "absolute";
461
+ gs.left = "0";
462
+ gs.top = "0";
463
+ gs.right = "auto";
464
+ gs.bottom = "auto";
465
+ gs.width = `${W}px`;
466
+ gs.height = `${H}px`;
467
+ gs.minWidth = "0";
468
+ gs.minHeight = "0";
469
+ gs.maxWidth = "none";
470
+ gs.maxHeight = "none";
471
+ gs.margin = "0";
472
+ gs.borderStyle = "none";
473
+ gs.boxSizing = "border-box";
474
+ gs.transform = "none";
475
+ gs.transition = "none";
476
+ gs.overflow = "hidden";
477
+ gs.pointerEvents = "none";
478
+ gs.zIndex = "2147483646";
479
+ if (background) gs.backgroundColor = background;
480
+ gs.setProperty("clip-path", staircaseHoleClip([], W, H));
481
+ return ghost;
482
+ } catch {
483
+ return null;
484
+ }
485
+ }
486
+ export {
487
+ GHOST_ATTR,
488
+ HALO_ATTR,
489
+ HALO_HDR_ATTR,
490
+ LIVE_HDR_NAME,
491
+ LIVE_NAME,
492
+ MAX_WAVE_CANVAS_PIXELS,
493
+ MIN_FLIP_MS,
494
+ SHEET_ATTR,
495
+ WAVE_ATTR,
496
+ WAVE_CSS,
497
+ WAVE_HDR_NAME,
498
+ WAVE_NAME,
499
+ WAVE_STYLE_ID,
500
+ ensureWaveStyles,
501
+ firstOpaqueBackground,
502
+ flipWait,
503
+ isWaving,
504
+ markFlip,
505
+ pixelWave,
506
+ supportsViewTransition,
507
+ waveCanvasDpr
508
+ };