@hina-ui/vue 1.7.10 → 1.7.11
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/dist/index.js +86 -54
- package/dist/index.js.map +1 -1
- package/dist/shared/behavior/spoiler/painter.ts +87 -60
- package/dist/shared/behavior/spoiler/worklet.ts +7 -9
- package/dist/shared/styles/motion.css +7 -1
- package/dist/shared/styles/spoiler.css +6 -0
- package/dist/shared/styles/typography.css +18 -3
- package/dist/types/shared/src/behavior/spoiler/painter.d.ts +10 -9
- package/dist/types/shared/src/behavior/spoiler/painter.d.ts.map +1 -1
- package/dist/types/shared/src/behavior/spoiler/worklet.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35204,8 +35204,6 @@ var workletMain = () => {
|
|
|
35204
35204
|
const M = Math;
|
|
35205
35205
|
const lcgrand = (seed = 1) => (a = 0, b = 1) => a + M.abs(b - a) * (M.imul(48271, seed = M.imul(214013, seed) + 2531011) & 2147483647) / 2147483647;
|
|
35206
35206
|
const pol2vec = (l, a = 0) => [l * M.cos(a), l * M.sin(a)];
|
|
35207
|
-
const vecmag = ([x, y]) => M.sqrt(x * x + y * y);
|
|
35208
|
-
const vecnorm = ([x, y], l = vecmag([x, y])) => l === 0 ? [0, 0] : [x / l, y / l];
|
|
35209
35207
|
const trapezoidalWave = (l, a, b) => {
|
|
35210
35208
|
const s = M.max(a, l - b);
|
|
35211
35209
|
return (t) => {
|
|
@@ -35313,18 +35311,18 @@ var workletMain = () => {
|
|
|
35313
35311
|
const lineHeight = height - 2 * vgap;
|
|
35314
35312
|
const wordDist = mimicWords ? makeWordDistribution(lineWidth, lineHeight, M.max(12, lineHeight / 4)) : (x) => x * (width - 2 * hgap);
|
|
35315
35313
|
ctx.clearRect(0, 0, size.width, size.height);
|
|
35314
|
+
const l = parseInt(accent[2] ?? "0");
|
|
35315
|
+
const ldir = l > 50 ? -1 : 1;
|
|
35316
|
+
const hue = `hsl(${accent[0]} ${accent[1]} `;
|
|
35316
35317
|
for (let i = 0; i < world.n; ++i) {
|
|
35317
35318
|
const x0 = hgap + wordDist(rand());
|
|
35318
35319
|
const y0 = rand(vgap, height - vgap);
|
|
35319
35320
|
const v0mag = rand(vmin, vmax);
|
|
35320
35321
|
const size0 = rand(1, 1 + sizedev);
|
|
35321
|
-
const l = parseInt(accent[2] ?? "0");
|
|
35322
|
-
const ldir = l > 50 ? -1 : 1;
|
|
35323
35322
|
const lightness = M.floor(clamp(0, l + ldir * rand(0, 30), 100));
|
|
35324
35323
|
const v0 = pol2vec(v0mag, rand(0, M.PI * 2));
|
|
35325
35324
|
const vx0 = v0[0];
|
|
35326
35325
|
const vy0 = v0[1];
|
|
35327
|
-
vecnorm(v0);
|
|
35328
35326
|
const shape = rand() > .5 ? "square" : "circle";
|
|
35329
35327
|
const lifetime = rand(.3, 1.5);
|
|
35330
35328
|
const respawn = rand(0, 1);
|
|
@@ -35335,11 +35333,12 @@ var workletMain = () => {
|
|
|
35335
35333
|
const x = x0 + vx0 * t;
|
|
35336
35334
|
const y = y0 + vy0 * t;
|
|
35337
35335
|
const fade = animateFadeInOut(world, i, fadeDuration);
|
|
35338
|
-
const alpha = fade * (1 - t / lifetime);
|
|
35336
|
+
const alpha = M.round(fade * (1 - t / lifetime) * 100);
|
|
35339
35337
|
const psize = fade * (size0 * visibilityFn(t));
|
|
35338
|
+
if (alpha <= 0 || psize <= 0) continue;
|
|
35339
|
+
ctx.fillStyle = `${hue}${lightness}% / ${alpha}%)`;
|
|
35340
35340
|
for (const [wx, wy] of cycleBounds([x, y], [width, height], psize / 2)) {
|
|
35341
35341
|
ctx.beginPath();
|
|
35342
|
-
ctx.fillStyle = `hsl(${accent[0]} ${accent[1]} ${lightness}% / ${M.round(alpha * 100)}%)`;
|
|
35343
35342
|
if (shape === "square") ctx.rect(wx, wy, psize, psize);
|
|
35344
35343
|
else ctx.arc(wx, wy, psize / 2, 0, M.PI * 2);
|
|
35345
35344
|
ctx.closePath();
|
|
@@ -35367,23 +35366,44 @@ var DEFAULTS = {
|
|
|
35367
35366
|
mimicWords: true,
|
|
35368
35367
|
accent: "0 0% 20%"
|
|
35369
35368
|
};
|
|
35369
|
+
var SPOILER_WORKLET_INPUTS = [
|
|
35370
|
+
"--hn-nz-t",
|
|
35371
|
+
"--hn-nz-stop",
|
|
35372
|
+
"--hn-nz-fade",
|
|
35373
|
+
"--hn-nz-gap",
|
|
35374
|
+
"--hn-nz-accent",
|
|
35375
|
+
"--hn-nz-words",
|
|
35376
|
+
"--hn-nz-density"
|
|
35377
|
+
];
|
|
35370
35378
|
var BLOCK_MAX_TILE = 293;
|
|
35371
35379
|
var INLINE_MAX_TILE = 333;
|
|
35372
35380
|
var GAP_RATIO = 8;
|
|
35373
35381
|
var DEFAULT_FADE_S = 1.5;
|
|
35382
|
+
var CLOCK_S = 3600;
|
|
35383
|
+
var painters = /* @__PURE__ */ new WeakMap();
|
|
35384
|
+
var viewport;
|
|
35385
|
+
function watchViewport() {
|
|
35386
|
+
viewport ??= new IntersectionObserver((entries) => {
|
|
35387
|
+
for (const entry of entries) painters.get(entry.target)?.setInView(entry.isIntersecting);
|
|
35388
|
+
});
|
|
35389
|
+
return viewport;
|
|
35390
|
+
}
|
|
35374
35391
|
var SpoilerPainter = class {
|
|
35375
35392
|
el;
|
|
35376
35393
|
maxFPS = DEFAULTS.fps;
|
|
35377
|
-
|
|
35378
|
-
|
|
35379
|
-
|
|
35380
|
-
|
|
35381
|
-
fadeS = 0;
|
|
35394
|
+
clock = null;
|
|
35395
|
+
settle;
|
|
35396
|
+
running = false;
|
|
35397
|
+
inView = false;
|
|
35382
35398
|
hidden = false;
|
|
35383
35399
|
destroyed = false;
|
|
35384
35400
|
constructor(el, options = {}) {
|
|
35385
35401
|
registerSpoilerWorklet();
|
|
35386
35402
|
this.el = el;
|
|
35403
|
+
painters.set(el, this);
|
|
35404
|
+
watchViewport().observe(el);
|
|
35405
|
+
this.setFade(0);
|
|
35406
|
+
this.setTstop(null);
|
|
35387
35407
|
this.update(options);
|
|
35388
35408
|
}
|
|
35389
35409
|
get isHidden() {
|
|
@@ -35391,11 +35411,17 @@ var SpoilerPainter = class {
|
|
|
35391
35411
|
}
|
|
35392
35412
|
update({ fps = DEFAULTS.fps, gap = DEFAULTS.gap, density = DEFAULTS.density, mimicWords = DEFAULTS.mimicWords, accent = DEFAULTS.accent } = {}) {
|
|
35393
35413
|
if (this.destroyed) return;
|
|
35394
|
-
|
|
35414
|
+
const maxFPS = prefersReducedMotion() ? 0 : fps;
|
|
35415
|
+
if (maxFPS !== this.maxFPS) {
|
|
35416
|
+
this.maxFPS = maxFPS;
|
|
35417
|
+
if (maxFPS > 0) this.clock?.effect?.updateTiming({ easing: this.easing() });
|
|
35418
|
+
else this.stopClock();
|
|
35419
|
+
}
|
|
35395
35420
|
this.el.style.setProperty("--hn-nz-density", String(density));
|
|
35396
35421
|
this.el.style.setProperty("--hn-nz-accent", accent);
|
|
35397
35422
|
const isBlockElement = getComputedStyle(this.el).getPropertyValue("display") !== "inline";
|
|
35398
35423
|
this.useBackgroundStyle("auto", "auto", false);
|
|
35424
|
+
this.el.style.setProperty("--hn-nz-gap", "0px 0px");
|
|
35399
35425
|
if (isBlockElement) {
|
|
35400
35426
|
this.el.style.setProperty("--hn-nz-words", "false");
|
|
35401
35427
|
const rect = this.el.getBoundingClientRect();
|
|
@@ -35419,71 +35445,77 @@ var SpoilerPainter = class {
|
|
|
35419
35445
|
const repeatAndPosition = tile ? "repeat left center" : "no-repeat center center";
|
|
35420
35446
|
this.el.style.background = `paint(hn-spoiler) ${repeatAndPosition} / ${w} ${h}`;
|
|
35421
35447
|
}
|
|
35448
|
+
easing() {
|
|
35449
|
+
return `steps(${Math.round(CLOCK_S * this.maxFPS)})`;
|
|
35450
|
+
}
|
|
35451
|
+
time() {
|
|
35452
|
+
const elapsed = Number(this.clock?.currentTime ?? 0) / 1e3;
|
|
35453
|
+
return this.maxFPS > 0 ? Math.floor(elapsed * this.maxFPS) / this.maxFPS : 0;
|
|
35454
|
+
}
|
|
35422
35455
|
setFade(value) {
|
|
35423
|
-
this.fadeS = value;
|
|
35424
35456
|
this.el.style.setProperty("--hn-nz-fade", `${value}s`);
|
|
35425
35457
|
}
|
|
35426
|
-
setT(value) {
|
|
35427
|
-
this.t = value;
|
|
35428
|
-
this.el.style.setProperty("--hn-nz-t", value.toFixed(3));
|
|
35429
|
-
}
|
|
35430
35458
|
setTstop(value) {
|
|
35431
|
-
this.
|
|
35432
|
-
if (value !== null) this.el.style.setProperty("--hn-nz-stop", value.toFixed(3));
|
|
35433
|
-
else this.el.style.removeProperty("--hn-nz-stop");
|
|
35459
|
+
this.el.style.setProperty("--hn-nz-stop", value === null ? "Infinity" : value.toFixed(3));
|
|
35434
35460
|
}
|
|
35435
35461
|
parseFade(value) {
|
|
35436
35462
|
if (this.maxFPS <= 0) return 0;
|
|
35437
35463
|
return value === true || value === void 0 ? DEFAULT_FADE_S : Number(value);
|
|
35438
35464
|
}
|
|
35465
|
+
sync() {
|
|
35466
|
+
if (!this.clock) return;
|
|
35467
|
+
if (this.running && this.inView) this.clock.play();
|
|
35468
|
+
else this.clock.pause();
|
|
35469
|
+
}
|
|
35470
|
+
stopClock() {
|
|
35471
|
+
clearTimeout(this.settle);
|
|
35472
|
+
this.settle = void 0;
|
|
35473
|
+
this.clock?.cancel();
|
|
35474
|
+
this.clock = null;
|
|
35475
|
+
this.running = false;
|
|
35476
|
+
}
|
|
35477
|
+
setInView(value) {
|
|
35478
|
+
if (this.destroyed || value === this.inView) return;
|
|
35479
|
+
this.inView = value;
|
|
35480
|
+
this.sync();
|
|
35481
|
+
}
|
|
35439
35482
|
hide(animate) {
|
|
35440
35483
|
if (this.destroyed) return;
|
|
35441
35484
|
this.hidden = true;
|
|
35442
35485
|
this.setFade(this.parseFade(animate));
|
|
35443
35486
|
this.setTstop(null);
|
|
35444
|
-
this.
|
|
35445
|
-
this.
|
|
35487
|
+
this.stopClock();
|
|
35488
|
+
if (this.maxFPS <= 0) return;
|
|
35489
|
+
this.clock = this.el.animate({ "--hn-nz-t": [0, CLOCK_S] }, {
|
|
35490
|
+
duration: CLOCK_S * 1e3,
|
|
35491
|
+
easing: this.easing(),
|
|
35492
|
+
iterations: Infinity
|
|
35493
|
+
});
|
|
35494
|
+
this.running = true;
|
|
35495
|
+
this.sync();
|
|
35446
35496
|
}
|
|
35447
35497
|
reveal(animate) {
|
|
35448
35498
|
if (this.destroyed) return;
|
|
35449
35499
|
this.hidden = false;
|
|
35450
35500
|
const duration = this.parseFade(animate);
|
|
35451
35501
|
this.setFade(duration);
|
|
35452
|
-
this.setTstop(this.
|
|
35453
|
-
|
|
35454
|
-
|
|
35455
|
-
|
|
35456
|
-
|
|
35457
|
-
|
|
35458
|
-
|
|
35459
|
-
|
|
35460
|
-
|
|
35461
|
-
this.setT(this.t + dt / 1e3);
|
|
35462
|
-
this.t0 = now;
|
|
35463
|
-
};
|
|
35464
|
-
startAnimation() {
|
|
35465
|
-
this.t0 = performance.now();
|
|
35466
|
-
this.frame(this.t0);
|
|
35467
|
-
}
|
|
35468
|
-
stopAnimation() {
|
|
35469
|
-
if (this.raf !== null) {
|
|
35470
|
-
cancelAnimationFrame(this.raf);
|
|
35471
|
-
this.raf = null;
|
|
35472
|
-
}
|
|
35502
|
+
this.setTstop(this.time());
|
|
35503
|
+
clearTimeout(this.settle);
|
|
35504
|
+
const stop = () => {
|
|
35505
|
+
this.settle = void 0;
|
|
35506
|
+
this.running = false;
|
|
35507
|
+
this.sync();
|
|
35508
|
+
};
|
|
35509
|
+
if (duration <= 0) stop();
|
|
35510
|
+
else this.settle = setTimeout(stop, duration * 1e3 + 1e3 / this.maxFPS);
|
|
35473
35511
|
}
|
|
35474
35512
|
destroy() {
|
|
35475
35513
|
this.destroyed = true;
|
|
35476
|
-
this.
|
|
35514
|
+
this.stopClock();
|
|
35515
|
+
viewport?.unobserve(this.el);
|
|
35516
|
+
painters.delete(this.el);
|
|
35477
35517
|
this.el.style.removeProperty("background");
|
|
35478
|
-
for (const prop of
|
|
35479
|
-
"--hn-nz-t",
|
|
35480
|
-
"--hn-nz-stop",
|
|
35481
|
-
"--hn-nz-fade",
|
|
35482
|
-
"--hn-nz-gap",
|
|
35483
|
-
"--hn-nz-words",
|
|
35484
|
-
"--hn-nz-density",
|
|
35485
|
-
"--hn-nz-accent"
|
|
35486
|
-
]) this.el.style.removeProperty(prop);
|
|
35518
|
+
for (const prop of SPOILER_WORKLET_INPUTS) this.el.style.removeProperty(prop);
|
|
35487
35519
|
}
|
|
35488
35520
|
};
|
|
35489
35521
|
//#endregion
|