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.
- package/README.md +9 -6
- package/dist/components/animated-testimonials/AnimatedTestimonials.vue.js +23 -12
- package/dist/components/bg-falling-stars/FallingStarsBg.vue.js +10 -1
- package/dist/components/bg-falling-stars/bg-falling-stars-core.d.ts +6 -0
- package/dist/components/bg-falling-stars/bg-falling-stars-core.js +24 -2
- package/dist/components/bg-stars/StarsBackground.vue.js +1 -1
- package/dist/components/bg-stars/StarsBackground.vue2.js +13 -1
- package/dist/components/bg-stars/bg-stars-core.d.ts +6 -0
- package/dist/components/bg-stars/bg-stars-core.js +21 -1
- package/dist/components/book/Book.vue.js +5 -83
- package/dist/components/book/Book.vue2.js +82 -1
- package/dist/components/box-reveal/BoxReveal.vue.js +5 -47
- package/dist/components/box-reveal/BoxReveal.vue2.js +48 -1
- package/dist/components/compare/StarField.vue.js +1 -1
- package/dist/components/container-text-flip/ContainerTextFlip.vue.js +1 -1
- package/dist/components/container-text-flip/ContainerTextFlip.vue2.js +14 -5
- package/dist/components/flickering-grid/FlickeringGrid.vue.js +19 -1
- package/dist/components/flickering-grid/flickering-grid-core.d.ts +6 -0
- package/dist/components/flickering-grid/flickering-grid-core.js +30 -1
- package/dist/components/flip-words/FlipWords.vue.js +1 -1
- package/dist/components/flip-words/FlipWords.vue2.js +14 -7
- package/dist/components/hyper-text/HyperText.vue.js +6 -97
- package/dist/components/hyper-text/HyperText.vue2.js +101 -0
- package/dist/components/letter-pullup/LetterPullup.vue.js +6 -38
- package/dist/components/letter-pullup/LetterPullup.vue2.js +40 -0
- package/dist/components/logo-cloud/AnimatedLogoCloud.vue.js +1 -1
- package/dist/components/magnetic-field/MagnetPuck.vue.d.ts +51 -0
- package/dist/components/magnetic-field/MagnetPuck.vue.js +7 -0
- package/dist/components/magnetic-field/MagnetPuck.vue2.js +191 -0
- package/dist/components/magnetic-field/MagneticField.vue.d.ts +39 -0
- package/dist/components/magnetic-field/MagneticField.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticField.vue2.js +157 -0
- package/dist/components/magnetic-field/MagneticItem.vue.d.ts +28 -0
- package/dist/components/magnetic-field/MagneticItem.vue.js +7 -0
- package/dist/components/magnetic-field/MagneticItem.vue2.js +72 -0
- package/dist/components/magnetic-field/index.d.ts +10 -0
- package/dist/components/magnetic-field/magnetic-field-core.d.ts +163 -0
- package/dist/components/magnetic-field/magnetic-field-core.js +534 -0
- package/dist/components/magnetic-field/magnetic-field-source.d.ts +58 -0
- package/dist/components/magnetic-field/magnetic-field-source.js +58 -0
- package/dist/components/magnetic-field/types.d.ts +14 -0
- package/dist/components/magnetic-field/types.js +5 -0
- package/dist/components/matrix-rain/MatrixRain.vue.js +20 -1
- package/dist/components/matrix-rain/matrix-rain-core.d.ts +6 -0
- package/dist/components/matrix-rain/matrix-rain-core.js +28 -6
- package/dist/components/noise-reveal/NoiseReveal.vue.js +7 -0
- package/dist/components/noise-reveal/noise-reveal-core.js +23 -7
- package/dist/components/pixel-scene/PixelScene.vue.d.ts +60 -0
- package/dist/components/pixel-scene/PixelScene.vue.js +184 -0
- package/dist/components/pixel-scene/PixelScene.vue2.js +4 -0
- package/dist/components/pixel-scene/index.d.ts +4 -0
- package/dist/components/pixel-scene/pixel-scene-core.d.ts +256 -0
- package/dist/components/pixel-scene/pixel-scene-core.js +878 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.d.ts +68 -0
- package/dist/components/pixel-scene/pixel-scene-hdr.js +312 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.d.ts +31 -0
- package/dist/components/pixel-scene/pixel-scene-scenes.js +1074 -0
- package/dist/components/ripple/Ripple.vue.js +1 -1
- package/dist/components/ripple/Ripple.vue2.js +6 -1
- package/dist/components/sparkles/Sparkles.vue.js +10 -1
- package/dist/components/sparkles/sparkles-core.d.ts +6 -0
- package/dist/components/sparkles/sparkles-core.js +26 -2
- package/dist/components/sparkles-text/SparklesText.vue.js +6 -88
- package/dist/components/sparkles-text/SparklesText.vue2.js +100 -0
- package/dist/components/story-thread/StoryNode.vue.d.ts +11 -0
- package/dist/components/story-thread/StoryNode.vue.js +7 -0
- package/dist/components/story-thread/StoryNode.vue2.js +23 -0
- package/dist/components/story-thread/StoryThread.vue.d.ts +56 -0
- package/dist/components/story-thread/StoryThread.vue.js +7 -0
- package/dist/components/story-thread/StoryThread.vue2.js +103 -0
- package/dist/components/story-thread/index.d.ts +5 -0
- package/dist/components/story-thread/story-thread-core.d.ts +119 -0
- package/dist/components/story-thread/story-thread-core.js +491 -0
- package/dist/components/story-thread/types.d.ts +1 -0
- package/dist/components/sun-switch/SunSwitch.vue.d.ts +61 -0
- package/dist/components/sun-switch/SunSwitch.vue.js +7 -0
- package/dist/components/sun-switch/SunSwitch.vue2.js +559 -0
- package/dist/components/sun-switch/index.d.ts +4 -0
- package/dist/components/sun-switch/pixel-wave-core.d.ts +82 -0
- package/dist/components/sun-switch/pixel-wave-core.js +508 -0
- package/dist/components/sun-switch/sun-switch-core.d.ts +251 -0
- package/dist/components/sun-switch/sun-switch-core.js +546 -0
- package/dist/components/sun-switch/sun-switch-hdr.d.ts +70 -0
- package/dist/components/sun-switch/sun-switch-hdr.js +311 -0
- package/dist/components/terminal-text/TerminalText.vue.js +1 -1
- package/dist/components/terminal-text/TerminalText.vue2.js +36 -4
- package/dist/components/text-generate-effect/TextGenerateEffect.vue.js +5 -72
- package/dist/components/text-generate-effect/TextGenerateEffect.vue2.js +74 -1
- package/dist/components/text-reveal-card/TextRevealCard.vue.js +5 -101
- package/dist/components/text-reveal-card/TextRevealCard.vue2.js +98 -1
- package/dist/components/text-reveal-card/TextRevealStars.vue.js +1 -1
- package/dist/components/text-reveal-card/TextRevealStars.vue2.js +29 -12
- package/dist/components/tracing-beam/TracingBeam.vue.d.ts +20 -1
- package/dist/components/tracing-beam/TracingBeam.vue.js +5 -164
- package/dist/components/tracing-beam/TracingBeam.vue2.js +168 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +361 -338
- package/dist/styles.css +731 -89
- package/package.json +1 -1
- package/dist/components/hyper-text/HyperText.vue3.js +0 -5
- package/dist/components/letter-pullup/LetterPullup.vue3.js +0 -5
- package/dist/components/sparkles-text/SparklesText.vue3.js +0 -5
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
const SUN_HDR_PEAK = 4.9;
|
|
2
|
+
const SUN_HDR_RESTARTS = 3;
|
|
3
|
+
const SUN_HDR_RESTART_MS = 600;
|
|
4
|
+
const FPI = 8;
|
|
5
|
+
const START_CAPACITY = 1024;
|
|
6
|
+
const FORMAT = "rgba16float";
|
|
7
|
+
const WGSL = (
|
|
8
|
+
/* wgsl */
|
|
9
|
+
`
|
|
10
|
+
struct Frame { size: vec2f, dot: f32, pad: f32 };
|
|
11
|
+
@group(0) @binding(0) var<uniform> frame: Frame;
|
|
12
|
+
struct In { @location(0) cell: vec4f, @location(1) colour: vec4f };
|
|
13
|
+
struct Out { @builtin(position) pos: vec4f, @location(0) colour: vec4f };
|
|
14
|
+
@vertex fn vs(@builtin(vertex_index) vi: u32, inst: In) -> Out {
|
|
15
|
+
let corners = array<vec2f, 6>(vec2f(0, 0), vec2f(1, 0), vec2f(0, 1), vec2f(0, 1), vec2f(1, 0), vec2f(1, 1));
|
|
16
|
+
let p = inst.cell.xy + corners[vi] * frame.dot;
|
|
17
|
+
var o: Out;
|
|
18
|
+
o.pos = vec4f(p.x / frame.size.x * 2.0 - 1.0, 1.0 - p.y / frame.size.y * 2.0, 0.0, 1.0);
|
|
19
|
+
o.colour = inst.colour;
|
|
20
|
+
return o;
|
|
21
|
+
}
|
|
22
|
+
// a hard square at the pre-encoded colour; nothing else
|
|
23
|
+
@fragment fn fs(o: Out) -> @location(0) vec4f { return vec4f(o.colour.rgb, 1.0); }
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
const LINEAR = new Float32Array(256);
|
|
27
|
+
for (let i = 0; i < 256; i++) {
|
|
28
|
+
const c = i / 255;
|
|
29
|
+
LINEAR[i] = c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
30
|
+
}
|
|
31
|
+
function srgbToLinear(c8) {
|
|
32
|
+
return LINEAR[Math.min(255, Math.max(0, Math.round(c8)))];
|
|
33
|
+
}
|
|
34
|
+
function encodeExt(v) {
|
|
35
|
+
return v <= 31308e-7 ? 12.92 * v : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
|
|
36
|
+
}
|
|
37
|
+
function encodeGlowChannel(c8, glow) {
|
|
38
|
+
const g = Math.min(SUN_HDR_PEAK, Math.max(0, glow));
|
|
39
|
+
return encodeExt(srgbToLinear(c8) * g);
|
|
40
|
+
}
|
|
41
|
+
function sunHdrAvailable() {
|
|
42
|
+
try {
|
|
43
|
+
if (typeof navigator === "undefined" || typeof window === "undefined") return false;
|
|
44
|
+
if (!navigator.gpu) return false;
|
|
45
|
+
return typeof window.matchMedia === "function" && window.matchMedia("(dynamic-range: high)").matches;
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function hdrCapacityFor(n) {
|
|
51
|
+
let c = START_CAPACITY;
|
|
52
|
+
while (c < n) c *= 2;
|
|
53
|
+
return c;
|
|
54
|
+
}
|
|
55
|
+
function createSunHdrSquares() {
|
|
56
|
+
let data = new Float32Array(START_CAPACITY * FPI);
|
|
57
|
+
let n = 0;
|
|
58
|
+
return {
|
|
59
|
+
get n() {
|
|
60
|
+
return n;
|
|
61
|
+
},
|
|
62
|
+
get data() {
|
|
63
|
+
return data;
|
|
64
|
+
},
|
|
65
|
+
clear() {
|
|
66
|
+
n = 0;
|
|
67
|
+
},
|
|
68
|
+
push(px, py, rgb, glow) {
|
|
69
|
+
if (!(glow > 0) || rgb < 0) return;
|
|
70
|
+
if ((n + 1) * FPI > data.length) {
|
|
71
|
+
const next = new Float32Array(hdrCapacityFor(n + 1) * FPI);
|
|
72
|
+
next.set(data);
|
|
73
|
+
data = next;
|
|
74
|
+
}
|
|
75
|
+
const o = n * FPI;
|
|
76
|
+
data[o] = px;
|
|
77
|
+
data[o + 1] = py;
|
|
78
|
+
data[o + 2] = 0;
|
|
79
|
+
data[o + 3] = 0;
|
|
80
|
+
data[o + 4] = encodeGlowChannel(rgb >> 16 & 255, glow);
|
|
81
|
+
data[o + 5] = encodeGlowChannel(rgb >> 8 & 255, glow);
|
|
82
|
+
data[o + 6] = encodeGlowChannel(rgb & 255, glow);
|
|
83
|
+
data[o + 7] = 1;
|
|
84
|
+
n++;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
let shared = null;
|
|
89
|
+
const PIPELINES = /* @__PURE__ */ new WeakMap();
|
|
90
|
+
function acquire(gpu) {
|
|
91
|
+
if (!shared) {
|
|
92
|
+
const s = { device: Promise.resolve(null), refs: 0, onLost: /* @__PURE__ */ new Set() };
|
|
93
|
+
s.device = (async () => {
|
|
94
|
+
const adapter = await gpu.requestAdapter();
|
|
95
|
+
if (!adapter) return null;
|
|
96
|
+
const device = await adapter.requestDevice();
|
|
97
|
+
void device.lost.then(() => {
|
|
98
|
+
if (shared === s) shared = null;
|
|
99
|
+
for (const fn of [...s.onLost]) fn();
|
|
100
|
+
s.onLost.clear();
|
|
101
|
+
});
|
|
102
|
+
return device;
|
|
103
|
+
})().catch(() => null);
|
|
104
|
+
shared = s;
|
|
105
|
+
}
|
|
106
|
+
shared.refs++;
|
|
107
|
+
return shared;
|
|
108
|
+
}
|
|
109
|
+
function release(s) {
|
|
110
|
+
s.refs--;
|
|
111
|
+
if (s.refs > 0) return;
|
|
112
|
+
if (shared === s) shared = null;
|
|
113
|
+
s.onLost.clear();
|
|
114
|
+
void s.device.then((d) => d?.destroy());
|
|
115
|
+
}
|
|
116
|
+
function pipelineFor(device) {
|
|
117
|
+
let p = PIPELINES.get(device);
|
|
118
|
+
if (p) return p;
|
|
119
|
+
const module = device.createShaderModule({ code: WGSL });
|
|
120
|
+
p = device.createRenderPipeline({
|
|
121
|
+
layout: "auto",
|
|
122
|
+
vertex: {
|
|
123
|
+
module,
|
|
124
|
+
entryPoint: "vs",
|
|
125
|
+
buffers: [
|
|
126
|
+
{
|
|
127
|
+
arrayStride: FPI * 4,
|
|
128
|
+
stepMode: "instance",
|
|
129
|
+
attributes: [
|
|
130
|
+
{ shaderLocation: 0, offset: 0, format: "float32x4" },
|
|
131
|
+
{ shaderLocation: 1, offset: 16, format: "float32x4" }
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
fragment: {
|
|
137
|
+
module,
|
|
138
|
+
entryPoint: "fs",
|
|
139
|
+
targets: [
|
|
140
|
+
{
|
|
141
|
+
format: FORMAT,
|
|
142
|
+
blend: {
|
|
143
|
+
color: { srcFactor: "one", dstFactor: "one", operation: "max" },
|
|
144
|
+
alpha: { srcFactor: "one", dstFactor: "one", operation: "max" }
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
primitive: { topology: "triangle-list" }
|
|
150
|
+
});
|
|
151
|
+
PIPELINES.set(device, p);
|
|
152
|
+
return p;
|
|
153
|
+
}
|
|
154
|
+
async function startSunHdr(canvas) {
|
|
155
|
+
if (!sunHdrAvailable()) return null;
|
|
156
|
+
const gpu = navigator.gpu;
|
|
157
|
+
if (!gpu) return null;
|
|
158
|
+
const s = acquire(gpu);
|
|
159
|
+
let held = true;
|
|
160
|
+
const drop = () => {
|
|
161
|
+
if (held) {
|
|
162
|
+
held = false;
|
|
163
|
+
release(s);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
try {
|
|
167
|
+
const device = await s.device;
|
|
168
|
+
if (!device) {
|
|
169
|
+
drop();
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
const context = canvas.getContext("webgpu");
|
|
173
|
+
if (!context) {
|
|
174
|
+
drop();
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
context.configure({
|
|
178
|
+
device,
|
|
179
|
+
format: FORMAT,
|
|
180
|
+
alphaMode: "premultiplied",
|
|
181
|
+
colorSpace: "srgb",
|
|
182
|
+
toneMapping: { mode: "extended" }
|
|
183
|
+
});
|
|
184
|
+
let extended = false;
|
|
185
|
+
try {
|
|
186
|
+
const applied = context.getConfiguration?.();
|
|
187
|
+
extended = applied?.toneMapping?.mode === "extended";
|
|
188
|
+
} catch {
|
|
189
|
+
extended = false;
|
|
190
|
+
}
|
|
191
|
+
if (!extended) {
|
|
192
|
+
try {
|
|
193
|
+
context.unconfigure();
|
|
194
|
+
} catch {
|
|
195
|
+
}
|
|
196
|
+
drop();
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
const pipeline = pipelineFor(device);
|
|
200
|
+
const uniform = device.createBuffer({
|
|
201
|
+
size: 16,
|
|
202
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
203
|
+
});
|
|
204
|
+
const uniformData = new Float32Array(4);
|
|
205
|
+
const bindGroup = device.createBindGroup({
|
|
206
|
+
layout: pipeline.getBindGroupLayout(0),
|
|
207
|
+
entries: [{ binding: 0, resource: { buffer: uniform } }]
|
|
208
|
+
});
|
|
209
|
+
const sink = createSunHdrSquares();
|
|
210
|
+
let capacity = START_CAPACITY;
|
|
211
|
+
let instances = device.createBuffer({
|
|
212
|
+
size: capacity * FPI * 4,
|
|
213
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
|
|
214
|
+
});
|
|
215
|
+
let destroyed = false;
|
|
216
|
+
let count = 0;
|
|
217
|
+
let resolveLost = () => {
|
|
218
|
+
};
|
|
219
|
+
const lost = new Promise((r) => {
|
|
220
|
+
resolveLost = r;
|
|
221
|
+
});
|
|
222
|
+
const onLost = () => {
|
|
223
|
+
destroyed = true;
|
|
224
|
+
resolveLost();
|
|
225
|
+
};
|
|
226
|
+
s.onLost.add(onLost);
|
|
227
|
+
const layer = {
|
|
228
|
+
sink,
|
|
229
|
+
get lost() {
|
|
230
|
+
return lost;
|
|
231
|
+
},
|
|
232
|
+
get count() {
|
|
233
|
+
return count;
|
|
234
|
+
},
|
|
235
|
+
render(width, height, size) {
|
|
236
|
+
if (destroyed || width <= 0 || height <= 0) return;
|
|
237
|
+
if (canvas.width !== width) canvas.width = width;
|
|
238
|
+
if (canvas.height !== height) canvas.height = height;
|
|
239
|
+
const k = sink.n;
|
|
240
|
+
if (k > capacity) {
|
|
241
|
+
capacity = hdrCapacityFor(k);
|
|
242
|
+
instances.destroy();
|
|
243
|
+
instances = device.createBuffer({
|
|
244
|
+
size: capacity * FPI * 4,
|
|
245
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
count = k;
|
|
249
|
+
uniformData[0] = width;
|
|
250
|
+
uniformData[1] = height;
|
|
251
|
+
uniformData[2] = size;
|
|
252
|
+
uniformData[3] = 0;
|
|
253
|
+
try {
|
|
254
|
+
device.queue.writeBuffer(uniform, 0, uniformData);
|
|
255
|
+
if (k) device.queue.writeBuffer(instances, 0, sink.data, 0, k * FPI);
|
|
256
|
+
const encoder = device.createCommandEncoder();
|
|
257
|
+
const pass = encoder.beginRenderPass({
|
|
258
|
+
colorAttachments: [
|
|
259
|
+
{
|
|
260
|
+
view: context.getCurrentTexture().createView(),
|
|
261
|
+
clearValue: { r: 0, g: 0, b: 0, a: 0 },
|
|
262
|
+
loadOp: "clear",
|
|
263
|
+
storeOp: "store"
|
|
264
|
+
}
|
|
265
|
+
]
|
|
266
|
+
});
|
|
267
|
+
if (k) {
|
|
268
|
+
pass.setPipeline(pipeline);
|
|
269
|
+
pass.setBindGroup(0, bindGroup);
|
|
270
|
+
pass.setVertexBuffer(0, instances);
|
|
271
|
+
pass.draw(6, k);
|
|
272
|
+
}
|
|
273
|
+
pass.end();
|
|
274
|
+
device.queue.submit([encoder.finish()]);
|
|
275
|
+
} catch {
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
destroy() {
|
|
279
|
+
if (destroyed && !held) return;
|
|
280
|
+
destroyed = true;
|
|
281
|
+
s.onLost.delete(onLost);
|
|
282
|
+
try {
|
|
283
|
+
context.unconfigure();
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
try {
|
|
287
|
+
uniform.destroy();
|
|
288
|
+
instances.destroy();
|
|
289
|
+
} catch {
|
|
290
|
+
}
|
|
291
|
+
drop();
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
return layer;
|
|
295
|
+
} catch {
|
|
296
|
+
drop();
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
export {
|
|
301
|
+
SUN_HDR_PEAK,
|
|
302
|
+
SUN_HDR_RESTARTS,
|
|
303
|
+
SUN_HDR_RESTART_MS,
|
|
304
|
+
createSunHdrSquares,
|
|
305
|
+
encodeExt,
|
|
306
|
+
encodeGlowChannel,
|
|
307
|
+
hdrCapacityFor,
|
|
308
|
+
srgbToLinear,
|
|
309
|
+
startSunHdr,
|
|
310
|
+
sunHdrAvailable
|
|
311
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./TerminalText.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const TerminalText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const TerminalText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-4e11cdd8"]]);
|
|
5
5
|
export {
|
|
6
6
|
TerminalText as default
|
|
7
7
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineComponent, ref, onMounted, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createCommentVNode, Fragment, renderList, createElementVNode, toDisplayString } from "vue";
|
|
2
2
|
import { cn } from "../../utils.js";
|
|
3
|
+
import { useReducedMotion } from "../../internals/motion/use-media-query.js";
|
|
3
4
|
const _hoisted_1 = {
|
|
4
5
|
key: 0,
|
|
5
6
|
class: "cursor-blink"
|
|
@@ -26,6 +27,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
26
27
|
const GLITCH_GLYPHS = "アイウエオ@#$%&!?░▒▓█▄▀■□▪▫";
|
|
27
28
|
const displayedLines = ref([]);
|
|
28
29
|
const done = ref(false);
|
|
30
|
+
const reducedMotion = useReducedMotion();
|
|
29
31
|
const glitchState = ref(null);
|
|
30
32
|
let timeouts = [];
|
|
31
33
|
let glitchLoopId = null;
|
|
@@ -40,6 +42,15 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
40
42
|
glitchRestoreId = null;
|
|
41
43
|
}
|
|
42
44
|
}
|
|
45
|
+
function restoreGlitch() {
|
|
46
|
+
const live = glitchState.value;
|
|
47
|
+
if (!live) return;
|
|
48
|
+
const { lineIdx, charIdx, original } = live;
|
|
49
|
+
displayedLines.value = displayedLines.value.map(
|
|
50
|
+
(line, idx) => idx === lineIdx ? line.slice(0, charIdx) + original + line.slice(charIdx + 1) : line
|
|
51
|
+
);
|
|
52
|
+
glitchState.value = null;
|
|
53
|
+
}
|
|
43
54
|
function scheduleTimeout(fn, ms) {
|
|
44
55
|
const id = setTimeout(fn, ms);
|
|
45
56
|
timeouts.push(id);
|
|
@@ -49,11 +60,23 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
49
60
|
timeouts.forEach(clearTimeout);
|
|
50
61
|
timeouts = [];
|
|
51
62
|
}
|
|
63
|
+
let streamedReduced = false;
|
|
64
|
+
function showAllLines() {
|
|
65
|
+
clearAllTimeouts();
|
|
66
|
+
displayedLines.value = [...__props.lines];
|
|
67
|
+
done.value = true;
|
|
68
|
+
__props.onComplete?.();
|
|
69
|
+
}
|
|
52
70
|
function streamLines() {
|
|
53
71
|
clearAllTimeouts();
|
|
54
72
|
displayedLines.value = [];
|
|
55
73
|
done.value = false;
|
|
56
74
|
glitchState.value = null;
|
|
75
|
+
streamedReduced = reducedMotion.value;
|
|
76
|
+
if (streamedReduced) {
|
|
77
|
+
scheduleTimeout(showAllLines, __props.delay);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
57
80
|
let totalDelay = __props.delay;
|
|
58
81
|
for (let lineIdx = 0; lineIdx < __props.lines.length; lineIdx++) {
|
|
59
82
|
const line = __props.lines[lineIdx];
|
|
@@ -117,7 +140,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
117
140
|
}
|
|
118
141
|
onMounted(() => {
|
|
119
142
|
streamLines();
|
|
120
|
-
if (__props.glitch) startGlitchLoop();
|
|
143
|
+
if (__props.glitch && !reducedMotion.value) startGlitchLoop();
|
|
121
144
|
});
|
|
122
145
|
watch(
|
|
123
146
|
[() => JSON.stringify(__props.lines), () => __props.speed, () => __props.delay],
|
|
@@ -127,13 +150,22 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
127
150
|
{ flush: "post" }
|
|
128
151
|
);
|
|
129
152
|
watch(
|
|
130
|
-
() =>
|
|
153
|
+
() => reducedMotion.value,
|
|
131
154
|
(value) => {
|
|
155
|
+
if (!value || done.value || streamedReduced) return;
|
|
156
|
+
streamedReduced = true;
|
|
157
|
+
showAllLines();
|
|
158
|
+
},
|
|
159
|
+
{ flush: "post" }
|
|
160
|
+
);
|
|
161
|
+
watch(
|
|
162
|
+
[() => __props.glitch, () => reducedMotion.value],
|
|
163
|
+
([value, reduced]) => {
|
|
132
164
|
stopGlitchLoop();
|
|
133
|
-
if (value) {
|
|
165
|
+
if (value && !reduced) {
|
|
134
166
|
startGlitchLoop();
|
|
135
167
|
} else {
|
|
136
|
-
|
|
168
|
+
restoreGlitch();
|
|
137
169
|
}
|
|
138
170
|
},
|
|
139
171
|
{ flush: "post" }
|
|
@@ -1,74 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
__name: "TextGenerateEffect",
|
|
6
|
-
props: {
|
|
7
|
-
words: {},
|
|
8
|
-
filter: { type: Boolean, default: true },
|
|
9
|
-
duration: { default: 0.7 },
|
|
10
|
-
delay: { default: 0 },
|
|
11
|
-
stagger: { default: 200 },
|
|
12
|
-
class: { type: [Boolean, null, String, Object, Array] }
|
|
13
|
-
},
|
|
14
|
-
setup(__props) {
|
|
15
|
-
const wordsArray = computed(() => __props.words.split(" "));
|
|
16
|
-
const scopeRef = useTemplateRef("scopeRef");
|
|
17
|
-
let revealSpans = null;
|
|
18
|
-
let revealTimeout = null;
|
|
19
|
-
function stopReveal() {
|
|
20
|
-
if (revealTimeout) clearTimeout(revealTimeout);
|
|
21
|
-
revealTimeout = null;
|
|
22
|
-
revealSpans?.forEach((span) => {
|
|
23
|
-
if (span._tid) clearTimeout(span._tid);
|
|
24
|
-
});
|
|
25
|
-
revealSpans = null;
|
|
26
|
-
}
|
|
27
|
-
function startReveal() {
|
|
28
|
-
const scope = scopeRef.value;
|
|
29
|
-
if (!scope) return;
|
|
30
|
-
const spans = scope.querySelectorAll("span");
|
|
31
|
-
revealSpans = spans;
|
|
32
|
-
revealTimeout = setTimeout(() => {
|
|
33
|
-
revealTimeout = null;
|
|
34
|
-
spans.forEach((span, index) => {
|
|
35
|
-
span._tid = setTimeout(() => {
|
|
36
|
-
span.style.opacity = "1";
|
|
37
|
-
span.style.filter = __props.filter ? "blur(0px)" : "none";
|
|
38
|
-
}, index * __props.stagger);
|
|
39
|
-
});
|
|
40
|
-
}, __props.delay);
|
|
41
|
-
}
|
|
42
|
-
onMounted(startReveal);
|
|
43
|
-
watch(
|
|
44
|
-
() => __props.words,
|
|
45
|
-
() => {
|
|
46
|
-
stopReveal();
|
|
47
|
-
startReveal();
|
|
48
|
-
},
|
|
49
|
-
{ flush: "post" }
|
|
50
|
-
);
|
|
51
|
-
onBeforeUnmount(stopReveal);
|
|
52
|
-
return (_ctx, _cache) => {
|
|
53
|
-
return openBlock(), createElementBlock("div", {
|
|
54
|
-
class: normalizeClass(unref(cn)("leading-snug tracking-wide", __props.class))
|
|
55
|
-
}, [
|
|
56
|
-
createElementVNode("div", {
|
|
57
|
-
ref_key: "scopeRef",
|
|
58
|
-
ref: scopeRef
|
|
59
|
-
}, [
|
|
60
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(wordsArray.value, (word, idx) => {
|
|
61
|
-
return openBlock(), createElementBlock("span", {
|
|
62
|
-
key: word + idx,
|
|
63
|
-
class: "inline-block",
|
|
64
|
-
style: normalizeStyle(`opacity: 0; filter: ${__props.filter ? "blur(10px)" : "none"}; transition: opacity ${__props.duration}s, filter ${__props.duration}s;`)
|
|
65
|
-
}, toDisplayString(word) + " ", 5);
|
|
66
|
-
}), 128))
|
|
67
|
-
], 512)
|
|
68
|
-
], 2);
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
});
|
|
1
|
+
import _sfc_main from "./TextGenerateEffect.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const TextGenerateEffect = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-3e55378a"]]);
|
|
72
5
|
export {
|
|
73
|
-
|
|
6
|
+
TextGenerateEffect as default
|
|
74
7
|
};
|
|
@@ -1,4 +1,77 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineComponent, computed, useTemplateRef, onMounted, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, Fragment, renderList, normalizeStyle, toDisplayString } from "vue";
|
|
2
|
+
import { cn } from "../../utils.js";
|
|
3
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
4
|
+
...{ name: "TextGenerateEffect", inheritAttrs: false },
|
|
5
|
+
__name: "TextGenerateEffect",
|
|
6
|
+
props: {
|
|
7
|
+
words: {},
|
|
8
|
+
filter: { type: Boolean, default: true },
|
|
9
|
+
duration: { default: 0.7 },
|
|
10
|
+
delay: { default: 0 },
|
|
11
|
+
stagger: { default: 200 },
|
|
12
|
+
class: { type: [Boolean, null, String, Object, Array] }
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
const wordsArray = computed(() => __props.words.split(" "));
|
|
16
|
+
const scopeRef = useTemplateRef("scopeRef");
|
|
17
|
+
let revealSpans = null;
|
|
18
|
+
let revealTimeout = null;
|
|
19
|
+
function stopReveal() {
|
|
20
|
+
if (revealTimeout) clearTimeout(revealTimeout);
|
|
21
|
+
revealTimeout = null;
|
|
22
|
+
revealSpans?.forEach((span) => {
|
|
23
|
+
if (span._tid) clearTimeout(span._tid);
|
|
24
|
+
});
|
|
25
|
+
revealSpans = null;
|
|
26
|
+
}
|
|
27
|
+
function startReveal() {
|
|
28
|
+
const scope = scopeRef.value;
|
|
29
|
+
if (!scope) return;
|
|
30
|
+
const spans = scope.querySelectorAll("span");
|
|
31
|
+
revealSpans = spans;
|
|
32
|
+
revealTimeout = setTimeout(() => {
|
|
33
|
+
revealTimeout = null;
|
|
34
|
+
spans.forEach((span, index) => {
|
|
35
|
+
span._tid = setTimeout(() => {
|
|
36
|
+
span.style.opacity = "1";
|
|
37
|
+
span.style.filter = __props.filter ? "blur(0px)" : "none";
|
|
38
|
+
}, index * __props.stagger);
|
|
39
|
+
});
|
|
40
|
+
}, __props.delay);
|
|
41
|
+
}
|
|
42
|
+
onMounted(startReveal);
|
|
43
|
+
watch(
|
|
44
|
+
() => __props.words,
|
|
45
|
+
() => {
|
|
46
|
+
stopReveal();
|
|
47
|
+
startReveal();
|
|
48
|
+
},
|
|
49
|
+
{ flush: "post" }
|
|
50
|
+
);
|
|
51
|
+
onBeforeUnmount(stopReveal);
|
|
52
|
+
return (_ctx, _cache) => {
|
|
53
|
+
return openBlock(), createElementBlock("div", {
|
|
54
|
+
class: normalizeClass(unref(cn)("text-generate-effect leading-snug tracking-wide", __props.class))
|
|
55
|
+
}, [
|
|
56
|
+
createElementVNode("div", {
|
|
57
|
+
ref_key: "scopeRef",
|
|
58
|
+
ref: scopeRef
|
|
59
|
+
}, [
|
|
60
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(wordsArray.value, (word, idx) => {
|
|
61
|
+
return openBlock(), createElementBlock("span", {
|
|
62
|
+
key: word + idx,
|
|
63
|
+
class: "tge-word inline-block",
|
|
64
|
+
style: normalizeStyle({
|
|
65
|
+
"--tge-duration": `${__props.duration}s`,
|
|
66
|
+
"--tge-blur": __props.filter ? "blur(10px)" : "none"
|
|
67
|
+
})
|
|
68
|
+
}, toDisplayString(word) + " ", 5);
|
|
69
|
+
}), 128))
|
|
70
|
+
], 512)
|
|
71
|
+
], 2);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
});
|
|
2
75
|
export {
|
|
3
76
|
_sfc_main as default
|
|
4
77
|
};
|
|
@@ -1,103 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
const _hoisted_2 = { class: "overflow-hidden [mask-image:linear-gradient(to_bottom,transparent,white,transparent)]" };
|
|
6
|
-
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
-
...{ name: "TextRevealCard", inheritAttrs: false },
|
|
8
|
-
__name: "TextRevealCard",
|
|
9
|
-
props: {
|
|
10
|
-
class: { type: [Boolean, null, String, Object, Array], default: "" },
|
|
11
|
-
starsCount: { default: 130 },
|
|
12
|
-
starsClass: { default: "" },
|
|
13
|
-
starsSeed: {}
|
|
14
|
-
},
|
|
15
|
-
setup(__props) {
|
|
16
|
-
const cardRef = useTemplateRef("cardRef");
|
|
17
|
-
const widthPercentage = ref(0);
|
|
18
|
-
const isMouseOver = ref(false);
|
|
19
|
-
const rotateDeg = computed(() => (widthPercentage.value - 50) * 0.1);
|
|
20
|
-
function mouseMoveHandler(event) {
|
|
21
|
-
event.preventDefault();
|
|
22
|
-
const card = cardRef.value;
|
|
23
|
-
if (card) {
|
|
24
|
-
const rect = card.getBoundingClientRect();
|
|
25
|
-
const relativeX = event.clientX - rect.left;
|
|
26
|
-
widthPercentage.value = relativeX / rect.width * 100;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function mouseLeaveHandler() {
|
|
30
|
-
isMouseOver.value = false;
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
if (!isMouseOver.value) {
|
|
33
|
-
widthPercentage.value = 0;
|
|
34
|
-
}
|
|
35
|
-
}, 100);
|
|
36
|
-
}
|
|
37
|
-
function mouseEnterHandler() {
|
|
38
|
-
isMouseOver.value = true;
|
|
39
|
-
}
|
|
40
|
-
function touchMoveHandler(event) {
|
|
41
|
-
const card = cardRef.value;
|
|
42
|
-
if (card) {
|
|
43
|
-
const rect = card.getBoundingClientRect();
|
|
44
|
-
const relativeX = event.touches[0].clientX - rect.left;
|
|
45
|
-
widthPercentage.value = relativeX / rect.width * 100;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return (_ctx, _cache) => {
|
|
49
|
-
return openBlock(), createElementBlock("div", {
|
|
50
|
-
ref_key: "cardRef",
|
|
51
|
-
ref: cardRef,
|
|
52
|
-
class: normalizeClass(
|
|
53
|
-
unref(cn)(
|
|
54
|
-
"relative w-full max-w-[40rem] touch-pan-y touch-pinch-zoom overflow-hidden rounded-lg border border-white/[0.08] bg-[#1d1c20] p-4 sm:p-6 md:p-8",
|
|
55
|
-
__props.class
|
|
56
|
-
)
|
|
57
|
-
),
|
|
58
|
-
role: "presentation",
|
|
59
|
-
onMouseenter: mouseEnterHandler,
|
|
60
|
-
onMouseleave: mouseLeaveHandler,
|
|
61
|
-
onMousemove: mouseMoveHandler,
|
|
62
|
-
onTouchstart: mouseEnterHandler,
|
|
63
|
-
onTouchend: mouseLeaveHandler,
|
|
64
|
-
onTouchmove: touchMoveHandler
|
|
65
|
-
}, [
|
|
66
|
-
renderSlot(_ctx.$slots, "default"),
|
|
67
|
-
createElementVNode("div", _hoisted_1, [
|
|
68
|
-
createElementVNode("div", {
|
|
69
|
-
style: normalizeStyle({
|
|
70
|
-
width: "100%",
|
|
71
|
-
opacity: widthPercentage.value > 0 ? 1 : 0,
|
|
72
|
-
clipPath: `inset(0 ${100 - widthPercentage.value}% 0 0)`,
|
|
73
|
-
transition: isMouseOver.value ? "none" : "all 0.4s ease-out"
|
|
74
|
-
}),
|
|
75
|
-
class: "absolute z-20 bg-[#1d1c20] will-change-transform"
|
|
76
|
-
}, [
|
|
77
|
-
renderSlot(_ctx.$slots, "text")
|
|
78
|
-
], 4),
|
|
79
|
-
createElementVNode("div", {
|
|
80
|
-
style: normalizeStyle({
|
|
81
|
-
left: `${widthPercentage.value}%`,
|
|
82
|
-
transform: `rotate(${rotateDeg.value}deg)`,
|
|
83
|
-
opacity: widthPercentage.value > 0 ? 1 : 0,
|
|
84
|
-
transition: isMouseOver.value ? "none" : "all 0.4s ease-out"
|
|
85
|
-
}),
|
|
86
|
-
class: "absolute z-50 h-40 w-[8px] bg-gradient-to-b from-transparent via-neutral-800 to-transparent will-change-transform"
|
|
87
|
-
}, null, 4),
|
|
88
|
-
createElementVNode("div", _hoisted_2, [
|
|
89
|
-
renderSlot(_ctx.$slots, "revealText"),
|
|
90
|
-
createVNode(TextRevealStars, {
|
|
91
|
-
starsCount: __props.starsCount,
|
|
92
|
-
class: normalizeClass(__props.starsClass),
|
|
93
|
-
seed: __props.starsSeed
|
|
94
|
-
}, null, 8, ["starsCount", "class", "seed"])
|
|
95
|
-
])
|
|
96
|
-
])
|
|
97
|
-
], 34);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
});
|
|
1
|
+
import _sfc_main from "./TextRevealCard.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
+
const TextRevealCard = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7675d2f2"]]);
|
|
101
5
|
export {
|
|
102
|
-
|
|
6
|
+
TextRevealCard as default
|
|
103
7
|
};
|