snowies 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 +35 -25
- package/dist/auto.cjs +180 -80
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.d.cts +1 -1
- package/dist/auto.d.ts +1 -1
- package/dist/auto.js +33 -8
- package/dist/auto.js.map +1 -1
- package/dist/{chunk-FUI4H26T.js → chunk-XZHF76OT.js} +151 -80
- package/dist/chunk-XZHF76OT.js.map +1 -0
- package/dist/index.cjs +148 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -14
- package/dist/index.d.ts +3 -14
- package/dist/index.js +1 -1
- package/dist/snowies.global.js +49 -40
- package/dist/snowies.global.js.map +1 -1
- package/dist/{types-KVWKDlXl.d.cts → types-DE9NRAb4.d.cts} +18 -13
- package/dist/{types-KVWKDlXl.d.ts → types-DE9NRAb4.d.ts} +18 -13
- package/package.json +1 -1
- package/dist/chunk-FUI4H26T.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -313,7 +313,10 @@ function createLights(options) {
|
|
|
313
313
|
const colors = resolvePalette(options.palette);
|
|
314
314
|
const bulbCount = Math.max(6, Math.min(64, Math.round(options.bulbs)));
|
|
315
315
|
const mobileCutoff = Math.max(10, Math.round(bulbCount * 0.45));
|
|
316
|
-
const bg = BACKDROP_STYLES[options.backdrop] ?? BACKDROP_STYLES.
|
|
316
|
+
const bg = BACKDROP_STYLES[options.backdrop] ?? BACKDROP_STYLES.transparent;
|
|
317
|
+
const animMode = options.animation ?? "twinkle";
|
|
318
|
+
const glassAnimCss = animMode === "steady" ? "opacity: 0.96;" : animMode === "wave" ? "animation: glass-wave 2.4s ease-in-out var(--wave-delay) infinite;" : "animation: glass-glow var(--bulb-duration) ease-in-out var(--bulb-delay) infinite alternate;";
|
|
319
|
+
const haloAnimCss = animMode === "steady" ? "opacity: 0.28;" : animMode === "wave" ? "animation: halo-wave 2.4s ease-in-out var(--wave-delay) infinite;" : "animation: halo-glow var(--bulb-duration) ease-in-out var(--bulb-delay) infinite alternate;";
|
|
317
320
|
const style = document.createElement("style");
|
|
318
321
|
style.textContent = `
|
|
319
322
|
:host { display: block; line-height: 0; }
|
|
@@ -329,7 +332,8 @@ function createLights(options) {
|
|
|
329
332
|
margin: 0;
|
|
330
333
|
border: 0;
|
|
331
334
|
box-sizing: border-box;
|
|
332
|
-
overflow:
|
|
335
|
+
overflow-x: clip;
|
|
336
|
+
overflow-y: visible;
|
|
333
337
|
background: ${bg};
|
|
334
338
|
cursor: ${options.interactive ? "pointer" : "default"};
|
|
335
339
|
-webkit-tap-highlight-color: transparent;
|
|
@@ -386,7 +390,7 @@ function createLights(options) {
|
|
|
386
390
|
radial-gradient(ellipse at 50% 35%, var(--bulb-core) 5%, var(--bulb-color) 80%);
|
|
387
391
|
box-shadow: 0 0 5px var(--bulb-color), 0 0 12px var(--bulb-color);
|
|
388
392
|
will-change: opacity, transform;
|
|
389
|
-
|
|
393
|
+
${glassAnimCss}
|
|
390
394
|
transition: transform 0.25s ease, opacity 0.25s ease;
|
|
391
395
|
}
|
|
392
396
|
.filament {
|
|
@@ -399,16 +403,16 @@ function createLights(options) {
|
|
|
399
403
|
.halo {
|
|
400
404
|
position: absolute;
|
|
401
405
|
z-index: 0;
|
|
402
|
-
top: 2px;
|
|
406
|
+
top: -2px;
|
|
403
407
|
left: 50%;
|
|
404
|
-
width:
|
|
405
|
-
height:
|
|
408
|
+
width: 58px;
|
|
409
|
+
height: 58px;
|
|
406
410
|
transform: translateX(-50%);
|
|
407
|
-
background: radial-gradient(ellipse
|
|
411
|
+
background: radial-gradient(ellipse at 50% 44%, var(--bulb-color) 0%, transparent 66%);
|
|
408
412
|
opacity: 0.2;
|
|
409
413
|
pointer-events: none;
|
|
410
414
|
will-change: opacity;
|
|
411
|
-
|
|
415
|
+
${haloAnimCss}
|
|
412
416
|
transition: opacity 0.25s ease;
|
|
413
417
|
}
|
|
414
418
|
.lamp.is-near .glass,
|
|
@@ -434,6 +438,14 @@ function createLights(options) {
|
|
|
434
438
|
from { opacity: 0.12; }
|
|
435
439
|
to { opacity: 0.34; }
|
|
436
440
|
}
|
|
441
|
+
@keyframes glass-wave {
|
|
442
|
+
0%, 58%, 100% { opacity: 0.58; transform: scale(0.97); }
|
|
443
|
+
22% { opacity: 1; transform: scale(1.1); }
|
|
444
|
+
}
|
|
445
|
+
@keyframes halo-wave {
|
|
446
|
+
0%, 58%, 100% { opacity: 0.08; }
|
|
447
|
+
22% { opacity: 0.52; }
|
|
448
|
+
}
|
|
437
449
|
@media (max-width: 640px) {
|
|
438
450
|
.lamp:nth-of-type(n + ${mobileCutoff + 1}) { display: none; }
|
|
439
451
|
}
|
|
@@ -443,9 +455,10 @@ function createLights(options) {
|
|
|
443
455
|
`;
|
|
444
456
|
const strip = document.createElement(options.interactive ? "button" : "div");
|
|
445
457
|
strip.className = "strip";
|
|
458
|
+
strip.setAttribute("data-animation", animMode);
|
|
446
459
|
if (options.interactive) {
|
|
447
460
|
strip.setAttribute("type", "button");
|
|
448
|
-
strip.setAttribute("aria-label", options.ariaLabel
|
|
461
|
+
strip.setAttribute("aria-label", options.ariaLabel || "Illuminate Christmas lights");
|
|
449
462
|
} else {
|
|
450
463
|
strip.setAttribute("aria-hidden", "true");
|
|
451
464
|
}
|
|
@@ -464,6 +477,7 @@ function createLights(options) {
|
|
|
464
477
|
lamp.style.setProperty("--bulb-color", c.color);
|
|
465
478
|
lamp.style.setProperty("--bulb-core", c.core);
|
|
466
479
|
lamp.style.setProperty("--bulb-delay", `${i * -0.43}s`);
|
|
480
|
+
lamp.style.setProperty("--wave-delay", `${(i * -0.1).toFixed(2)}s`);
|
|
467
481
|
lamp.style.setProperty("--bulb-duration", `${3.4 + i % 5 * 0.35}s`);
|
|
468
482
|
lamp.style.setProperty("--bulb-cord", `${4 + i % 3 * 2}px`);
|
|
469
483
|
lamp.style.setProperty("--bulb-tilt", `${i % 2 ? 5 : -5}deg`);
|
|
@@ -546,6 +560,37 @@ function createPrng(initialSeed = 202611) {
|
|
|
546
560
|
return seed / 4294967296;
|
|
547
561
|
};
|
|
548
562
|
}
|
|
563
|
+
function parseRgbLuminance(color) {
|
|
564
|
+
const match = /rgba?\(\s*(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:\s*[,/]\s*(\d*(?:\.\d+)?))?\s*\)/i.exec(
|
|
565
|
+
color
|
|
566
|
+
);
|
|
567
|
+
if (!match) return null;
|
|
568
|
+
const alpha = match[4] !== void 0 && match[4] !== "" ? Number(match[4]) : 1;
|
|
569
|
+
if (Number.isNaN(alpha) || alpha < 0.1) return null;
|
|
570
|
+
const r = Number(match[1]);
|
|
571
|
+
const g = Number(match[2]);
|
|
572
|
+
const b = Number(match[3]);
|
|
573
|
+
return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
|
|
574
|
+
}
|
|
575
|
+
function detectLightBackground() {
|
|
576
|
+
if (typeof window === "undefined" || typeof document === "undefined") return false;
|
|
577
|
+
const candidates = [document.body, document.documentElement];
|
|
578
|
+
for (const el of candidates) {
|
|
579
|
+
if (!el) continue;
|
|
580
|
+
const bg = window.getComputedStyle(el).backgroundColor;
|
|
581
|
+
const lum = parseRgbLuminance(bg);
|
|
582
|
+
if (lum !== null) {
|
|
583
|
+
return lum > 0.55;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
if (typeof window.matchMedia === "function") {
|
|
587
|
+
return window.matchMedia("(prefers-color-scheme: light)").matches;
|
|
588
|
+
}
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
function resolveContrasting(setting) {
|
|
592
|
+
return setting === "auto" ? detectLightBackground() : Boolean(setting);
|
|
593
|
+
}
|
|
549
594
|
function createFlakeSprite(contrasting, soft) {
|
|
550
595
|
if (typeof document === "undefined") return null;
|
|
551
596
|
const size = soft ? 32 : 20;
|
|
@@ -594,8 +639,18 @@ function createSnow(options) {
|
|
|
594
639
|
return { destroy() {
|
|
595
640
|
} };
|
|
596
641
|
}
|
|
597
|
-
|
|
598
|
-
|
|
642
|
+
let isContrasting = resolveContrasting(options.contrasting);
|
|
643
|
+
let sharpSprite = createFlakeSprite(isContrasting, false);
|
|
644
|
+
let softSprite = createFlakeSprite(isContrasting, true);
|
|
645
|
+
const refreshContrasting = () => {
|
|
646
|
+
if (options.contrasting !== "auto") return;
|
|
647
|
+
const next = detectLightBackground();
|
|
648
|
+
if (next !== isContrasting) {
|
|
649
|
+
isContrasting = next;
|
|
650
|
+
sharpSprite = createFlakeSprite(isContrasting, false);
|
|
651
|
+
softSprite = createFlakeSprite(isContrasting, true);
|
|
652
|
+
}
|
|
653
|
+
};
|
|
599
654
|
let width = window.innerWidth;
|
|
600
655
|
let height = window.innerHeight;
|
|
601
656
|
let flakes = [];
|
|
@@ -603,6 +658,8 @@ function createSnow(options) {
|
|
|
603
658
|
let lastTime = 0;
|
|
604
659
|
let paused = document.visibilityState === "hidden";
|
|
605
660
|
let destroyed = false;
|
|
661
|
+
let targetWind = 0;
|
|
662
|
+
let currentWind = 0;
|
|
606
663
|
const initFlakes = () => {
|
|
607
664
|
const random = createPrng(202611);
|
|
608
665
|
const count = resolveCount(options.density, width);
|
|
@@ -641,10 +698,18 @@ function createSnow(options) {
|
|
|
641
698
|
const dt = Math.min((now - lastTime) / 1e3, 0.05);
|
|
642
699
|
lastTime = now;
|
|
643
700
|
const t = now / 1e3;
|
|
701
|
+
if (options.mouseWind) {
|
|
702
|
+
currentWind += (targetWind - currentWind) * Math.min(1, dt * 3.2);
|
|
703
|
+
}
|
|
644
704
|
ctx.clearRect(0, 0, width, height);
|
|
645
705
|
for (let i = 0; i < flakes.length; i++) {
|
|
646
706
|
const f = flakes[i];
|
|
647
707
|
f.y += f.speedY * dt;
|
|
708
|
+
if (options.mouseWind && Math.abs(currentWind) > 2e-3) {
|
|
709
|
+
f.x += currentWind * 58 * (0.45 + f.layer * 0.42) * dt;
|
|
710
|
+
if (f.x < -24) f.x += width + 48;
|
|
711
|
+
else if (f.x > width + 24) f.x -= width + 48;
|
|
712
|
+
}
|
|
648
713
|
const xOffset = options.wind ? Math.sin(t * f.driftFreq + f.phase) * f.driftAmp : 0;
|
|
649
714
|
const drawX = f.x + xOffset;
|
|
650
715
|
if (f.y > height + f.radius * 2) {
|
|
@@ -660,7 +725,7 @@ function createSnow(options) {
|
|
|
660
725
|
const drawSize = f.radius * (f.layer === 2 ? 3.2 : 2.5);
|
|
661
726
|
ctx.drawImage(sprite, drawX - drawSize / 2, f.y - drawSize / 2, drawSize, drawSize);
|
|
662
727
|
} else {
|
|
663
|
-
ctx.fillStyle =
|
|
728
|
+
ctx.fillStyle = isContrasting ? "#d7edff" : "#ffffff";
|
|
664
729
|
ctx.beginPath();
|
|
665
730
|
ctx.arc(drawX, f.y, f.radius, 0, Math.PI * 2);
|
|
666
731
|
ctx.fill();
|
|
@@ -680,9 +745,33 @@ function createSnow(options) {
|
|
|
680
745
|
rafId = window.requestAnimationFrame(render);
|
|
681
746
|
}
|
|
682
747
|
};
|
|
748
|
+
const handlePointerMove = (event) => {
|
|
749
|
+
targetWind = (event.clientX / Math.max(1, width) - 0.5) * 2;
|
|
750
|
+
};
|
|
751
|
+
const handlePointerLeave = () => {
|
|
752
|
+
targetWind = 0;
|
|
753
|
+
};
|
|
683
754
|
resize();
|
|
684
755
|
window.addEventListener("resize", resize, { passive: true });
|
|
685
756
|
document.addEventListener("visibilitychange", handleVisibility);
|
|
757
|
+
if (options.mouseWind) {
|
|
758
|
+
window.addEventListener("pointermove", handlePointerMove, { passive: true });
|
|
759
|
+
document.documentElement.addEventListener("pointerleave", handlePointerLeave, { passive: true });
|
|
760
|
+
}
|
|
761
|
+
let observer = null;
|
|
762
|
+
if (options.contrasting === "auto" && typeof MutationObserver !== "undefined") {
|
|
763
|
+
observer = new MutationObserver(refreshContrasting);
|
|
764
|
+
observer.observe(document.documentElement, {
|
|
765
|
+
attributes: true,
|
|
766
|
+
attributeFilter: ["class", "style", "data-theme"]
|
|
767
|
+
});
|
|
768
|
+
if (document.body) {
|
|
769
|
+
observer.observe(document.body, {
|
|
770
|
+
attributes: true,
|
|
771
|
+
attributeFilter: ["class", "style", "data-theme"]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
}
|
|
686
775
|
if (!paused) {
|
|
687
776
|
rafId = window.requestAnimationFrame(render);
|
|
688
777
|
}
|
|
@@ -692,6 +781,11 @@ function createSnow(options) {
|
|
|
692
781
|
if (rafId) window.cancelAnimationFrame(rafId);
|
|
693
782
|
window.removeEventListener("resize", resize);
|
|
694
783
|
document.removeEventListener("visibilitychange", handleVisibility);
|
|
784
|
+
if (options.mouseWind) {
|
|
785
|
+
window.removeEventListener("pointermove", handlePointerMove);
|
|
786
|
+
document.documentElement.removeEventListener("pointerleave", handlePointerLeave);
|
|
787
|
+
}
|
|
788
|
+
observer?.disconnect();
|
|
695
789
|
canvas.remove();
|
|
696
790
|
}
|
|
697
791
|
};
|
|
@@ -886,16 +980,16 @@ function createToggleButton(options, initialActive, onToggle) {
|
|
|
886
980
|
// src/presets.ts
|
|
887
981
|
var DEFAULT_CONFIG = {
|
|
888
982
|
preset: "classic",
|
|
889
|
-
locale: "en",
|
|
890
983
|
enabled: true,
|
|
891
984
|
respectReducedMotion: true,
|
|
892
985
|
schedule: false,
|
|
893
986
|
snow: {
|
|
894
987
|
enabled: true,
|
|
895
988
|
density: "medium",
|
|
896
|
-
contrasting:
|
|
989
|
+
contrasting: "auto",
|
|
897
990
|
speed: 1,
|
|
898
991
|
wind: true,
|
|
992
|
+
mouseWind: true,
|
|
899
993
|
zIndex: 9990
|
|
900
994
|
},
|
|
901
995
|
lights: {
|
|
@@ -904,9 +998,11 @@ var DEFAULT_CONFIG = {
|
|
|
904
998
|
backdrop: "transparent",
|
|
905
999
|
bulbs: 32,
|
|
906
1000
|
palette: "classic",
|
|
1001
|
+
animation: "twinkle",
|
|
907
1002
|
interactive: true,
|
|
908
1003
|
pushBody: false,
|
|
909
1004
|
zIndex: 9995,
|
|
1005
|
+
ariaLabel: "Illuminate Christmas lights",
|
|
910
1006
|
container: null
|
|
911
1007
|
},
|
|
912
1008
|
buttonBurst: {
|
|
@@ -931,51 +1027,75 @@ var DEFAULT_CONFIG = {
|
|
|
931
1027
|
offset: 16,
|
|
932
1028
|
persist: true,
|
|
933
1029
|
storageKey: "snowies:enabled",
|
|
934
|
-
labelOn: "
|
|
935
|
-
labelOff: "
|
|
936
|
-
textOn: "
|
|
937
|
-
textOff: "
|
|
1030
|
+
labelOn: "Disable Christmas effects",
|
|
1031
|
+
labelOff: "Enable Christmas effects",
|
|
1032
|
+
textOn: "Holiday",
|
|
1033
|
+
textOff: "Paused",
|
|
938
1034
|
zIndex: 9999
|
|
939
1035
|
}
|
|
940
1036
|
};
|
|
941
1037
|
var PRESETS = {
|
|
942
1038
|
classic: {
|
|
943
|
-
snow: { enabled: true, density: "medium", contrasting:
|
|
944
|
-
lights: {
|
|
1039
|
+
snow: { enabled: true, density: "medium", contrasting: "auto", mouseWind: true },
|
|
1040
|
+
lights: {
|
|
1041
|
+
enabled: true,
|
|
1042
|
+
position: "fixed",
|
|
1043
|
+
backdrop: "transparent",
|
|
1044
|
+
palette: "classic",
|
|
1045
|
+
animation: "twinkle"
|
|
1046
|
+
},
|
|
945
1047
|
buttonBurst: { enabled: true },
|
|
946
1048
|
buttonSnow: { enabled: true, mode: "manual", style: "subtle" },
|
|
947
1049
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
948
1050
|
},
|
|
949
1051
|
minimal: {
|
|
950
|
-
snow: { enabled: true, density: "light", contrasting:
|
|
1052
|
+
snow: { enabled: true, density: "light", contrasting: "auto", speed: 0.85, mouseWind: false },
|
|
951
1053
|
lights: { enabled: false },
|
|
952
1054
|
buttonBurst: { enabled: false },
|
|
953
1055
|
buttonSnow: { enabled: false },
|
|
954
1056
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
955
1057
|
},
|
|
956
1058
|
festive: {
|
|
957
|
-
snow: { enabled: true, density: "heavy", contrasting:
|
|
958
|
-
lights: {
|
|
1059
|
+
snow: { enabled: true, density: "heavy", contrasting: "auto", speed: 1.1, mouseWind: true },
|
|
1060
|
+
lights: {
|
|
1061
|
+
enabled: true,
|
|
1062
|
+
position: "fixed",
|
|
1063
|
+
backdrop: "pine",
|
|
1064
|
+
palette: "classic",
|
|
1065
|
+
animation: "wave"
|
|
1066
|
+
},
|
|
959
1067
|
buttonBurst: { enabled: true, particles: 56, crystals: true },
|
|
960
1068
|
buttonSnow: { enabled: true, mode: "manual", style: "fluffy" },
|
|
961
1069
|
toggleButton: { enabled: true, variant: "pill", theme: "festive" }
|
|
962
1070
|
},
|
|
963
1071
|
light: {
|
|
964
|
-
snow: { enabled: true, density: "medium", contrasting: true },
|
|
965
|
-
lights: {
|
|
1072
|
+
snow: { enabled: true, density: "medium", contrasting: true, mouseWind: true },
|
|
1073
|
+
lights: {
|
|
1074
|
+
enabled: true,
|
|
1075
|
+
position: "fixed",
|
|
1076
|
+
backdrop: "transparent",
|
|
1077
|
+
palette: "ice",
|
|
1078
|
+
animation: "twinkle"
|
|
1079
|
+
},
|
|
966
1080
|
buttonBurst: { enabled: true },
|
|
967
1081
|
buttonSnow: { enabled: true, mode: "manual", style: "subtle" },
|
|
968
1082
|
toggleButton: { enabled: true, variant: "icon", theme: "light" }
|
|
969
1083
|
},
|
|
970
1084
|
"lights-only": {
|
|
971
1085
|
snow: { enabled: false },
|
|
972
|
-
lights: {
|
|
1086
|
+
lights: {
|
|
1087
|
+
enabled: true,
|
|
1088
|
+
position: "fixed",
|
|
1089
|
+
backdrop: "transparent",
|
|
1090
|
+
palette: "classic",
|
|
1091
|
+
animation: "twinkle"
|
|
1092
|
+
},
|
|
973
1093
|
buttonBurst: { enabled: false },
|
|
974
1094
|
buttonSnow: { enabled: false },
|
|
975
1095
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
976
1096
|
},
|
|
977
1097
|
"snow-only": {
|
|
978
|
-
snow: { enabled: true, density: "medium", contrasting:
|
|
1098
|
+
snow: { enabled: true, density: "medium", contrasting: "auto", mouseWind: true },
|
|
979
1099
|
lights: { enabled: false },
|
|
980
1100
|
buttonBurst: { enabled: false },
|
|
981
1101
|
buttonSnow: { enabled: false },
|
|
@@ -983,40 +1103,6 @@ var PRESETS = {
|
|
|
983
1103
|
}
|
|
984
1104
|
};
|
|
985
1105
|
|
|
986
|
-
// src/utils/i18n.ts
|
|
987
|
-
var MESSAGES = {
|
|
988
|
-
en: {
|
|
989
|
-
toggleLabelOn: "Disable Christmas effects",
|
|
990
|
-
toggleLabelOff: "Enable Christmas effects",
|
|
991
|
-
toggleTextOn: "Holiday",
|
|
992
|
-
toggleTextOff: "Paused",
|
|
993
|
-
lightsAriaLabel: "Illuminate Christmas lights"
|
|
994
|
-
},
|
|
995
|
-
es: {
|
|
996
|
-
toggleLabelOn: "Desactivar efectos navide\xF1os",
|
|
997
|
-
toggleLabelOff: "Activar efectos navide\xF1os",
|
|
998
|
-
toggleTextOn: "Navidad",
|
|
999
|
-
toggleTextOff: "Pausado",
|
|
1000
|
-
lightsAriaLabel: "Hacer brillar las luces navide\xF1as"
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
function resolveLocale(locale = "auto") {
|
|
1004
|
-
if (locale === "es" || locale === "en") return locale;
|
|
1005
|
-
if (typeof document !== "undefined") {
|
|
1006
|
-
const docLang = document.documentElement?.lang?.toLowerCase();
|
|
1007
|
-
if (docLang) {
|
|
1008
|
-
return docLang.startsWith("es") ? "es" : "en";
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
if (typeof navigator !== "undefined" && navigator.language) {
|
|
1012
|
-
return navigator.language.toLowerCase().startsWith("es") ? "es" : "en";
|
|
1013
|
-
}
|
|
1014
|
-
return "en";
|
|
1015
|
-
}
|
|
1016
|
-
function getMessages(locale = "auto") {
|
|
1017
|
-
return MESSAGES[resolveLocale(locale)];
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
1106
|
// src/utils/config.ts
|
|
1021
1107
|
function mergeFeature(base, presetOverride, userOverride) {
|
|
1022
1108
|
let result = { ...base };
|
|
@@ -1036,33 +1122,18 @@ function resolveConfig(options = {}, previous) {
|
|
|
1036
1122
|
const presetName = options.preset ?? previous?.preset ?? DEFAULT_CONFIG.preset;
|
|
1037
1123
|
const presetDef = options.preset ? PRESETS[presetName] ?? {} : previous ? {} : PRESETS[presetName] ?? {};
|
|
1038
1124
|
const base = previous && !options.preset ? previous : DEFAULT_CONFIG;
|
|
1039
|
-
const locale = resolveLocale(options.locale ?? previous?.locale ?? "auto");
|
|
1040
|
-
const msg = MESSAGES[locale];
|
|
1041
|
-
const localeChanged = !previous || options.locale !== void 0 || options.preset !== void 0;
|
|
1042
|
-
const lights = mergeFeature(base.lights, presetDef.lights, options.lights);
|
|
1043
|
-
const userLights = typeof options.lights === "object" ? options.lights : void 0;
|
|
1044
|
-
if (localeChanged && !userLights?.ariaLabel) {
|
|
1045
|
-
lights.ariaLabel = msg.lightsAriaLabel;
|
|
1046
|
-
}
|
|
1047
1125
|
const toggleButton = mergeFeature(base.toggleButton, presetDef.toggleButton, options.toggleButton);
|
|
1048
1126
|
const userToggle = typeof options.toggleButton === "object" ? options.toggleButton : void 0;
|
|
1049
|
-
if (localeChanged) {
|
|
1050
|
-
if (!userToggle?.labelOn) toggleButton.labelOn = msg.toggleLabelOn;
|
|
1051
|
-
if (!userToggle?.labelOff) toggleButton.labelOff = msg.toggleLabelOff;
|
|
1052
|
-
if (!userToggle?.textOn) toggleButton.textOn = msg.toggleTextOn;
|
|
1053
|
-
if (!userToggle?.textOff) toggleButton.textOff = msg.toggleTextOff;
|
|
1054
|
-
}
|
|
1055
1127
|
if (userToggle?.style && base.toggleButton.style) {
|
|
1056
1128
|
toggleButton.style = { ...base.toggleButton.style, ...userToggle.style };
|
|
1057
1129
|
}
|
|
1058
1130
|
return {
|
|
1059
1131
|
preset: presetName,
|
|
1060
|
-
locale,
|
|
1061
1132
|
enabled: options.enabled ?? base.enabled,
|
|
1062
1133
|
respectReducedMotion: options.respectReducedMotion ?? base.respectReducedMotion,
|
|
1063
1134
|
schedule: options.schedule !== void 0 ? options.schedule : base.schedule,
|
|
1064
1135
|
snow: mergeFeature(base.snow, presetDef.snow, options.snow),
|
|
1065
|
-
lights,
|
|
1136
|
+
lights: mergeFeature(base.lights, presetDef.lights, options.lights),
|
|
1066
1137
|
buttonBurst: mergeFeature(base.buttonBurst, presetDef.buttonBurst, options.buttonBurst),
|
|
1067
1138
|
buttonSnow: mergeFeature(base.buttonSnow, presetDef.buttonSnow, options.buttonSnow),
|
|
1068
1139
|
toggleButton,
|
|
@@ -1257,7 +1328,6 @@ function createSnowies(options = {}) {
|
|
|
1257
1328
|
}
|
|
1258
1329
|
|
|
1259
1330
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
1260
|
-
exports.MESSAGES = MESSAGES;
|
|
1261
1331
|
exports.PRESETS = PRESETS;
|
|
1262
1332
|
exports.createButtonBurst = createButtonBurst;
|
|
1263
1333
|
exports.createButtonSnow = createButtonSnow;
|
|
@@ -1265,8 +1335,6 @@ exports.createLights = createLights;
|
|
|
1265
1335
|
exports.createSnow = createSnow;
|
|
1266
1336
|
exports.createSnowies = createSnowies;
|
|
1267
1337
|
exports.createToggleButton = createToggleButton;
|
|
1268
|
-
exports.getMessages = getMessages;
|
|
1269
1338
|
exports.isWithinSchedule = isWithinSchedule;
|
|
1270
|
-
exports.resolveLocale = resolveLocale;
|
|
1271
1339
|
//# sourceMappingURL=index.cjs.map
|
|
1272
1340
|
//# sourceMappingURL=index.cjs.map
|