@tsparticles/stencil 4.3.1 → 4.4.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/dist/cjs/{Container-DwRv_rua.js → Container-BPdTDiSM.js} +194 -30
- package/dist/cjs/{index-BEJx8swj.js → index-B6adnBft.js} +21 -4
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/stencil-particles.cjs.entry.js +3 -3
- package/dist/collection/components/stencil-particles/stencil-particles.js +2 -2
- package/dist/esm/{Container-COqetWkt.js → Container-DJBmSrgJ.js} +194 -30
- package/dist/esm/{index-uBrXcY8m.js → index-D6pTafK8.js} +21 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/stencil-particles.entry.js +3 -3
- package/dist/tsparticlesstencil/index.esm.js +1 -1
- package/dist/tsparticlesstencil/p-BayVYJDL.js +1 -0
- package/dist/tsparticlesstencil/p-CU7ZW8VD.js +1 -0
- package/dist/tsparticlesstencil/p-b1fa94ec.entry.js +1 -0
- package/dist/tsparticlesstencil/tsparticlesstencil.esm.js +1 -1
- package/package.json +3 -3
- package/dist/tsparticlesstencil/p-0204e6c5.entry.js +0 -1
- package/dist/tsparticlesstencil/p-BMflXhxM.js +0 -1
- package/dist/tsparticlesstencil/p-Buaac_o7.js +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-B6adnBft.js');
|
|
4
4
|
|
|
5
5
|
class BaseRange {
|
|
6
6
|
position;
|
|
@@ -241,6 +241,29 @@ class FullScreen extends OptionLoader {
|
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
const defaultPeakNits = 400, minPeakNits = 0, toStringValue = (value) => String(value);
|
|
245
|
+
class HDROptions extends OptionLoader {
|
|
246
|
+
enable = true;
|
|
247
|
+
mode = index.HdrMode.standard;
|
|
248
|
+
peakNits = defaultPeakNits;
|
|
249
|
+
doLoad(data) {
|
|
250
|
+
if (data.enable !== undefined && !index.isBoolean(data.enable)) {
|
|
251
|
+
throw new Error(`Invalid HDR "enable" value: expected a boolean, got "${String(data.enable)}"`);
|
|
252
|
+
}
|
|
253
|
+
if (data.mode !== undefined &&
|
|
254
|
+
(typeof data.mode !== "string" || !Object.values(index.HdrMode).includes(data.mode))) {
|
|
255
|
+
throw new Error(`Invalid HDR "mode" value: expected one of ${Object.values(index.HdrMode).join(", ")}, got "${toStringValue(data.mode)}"`);
|
|
256
|
+
}
|
|
257
|
+
if (data.peakNits !== undefined &&
|
|
258
|
+
(!index.isNumber(data.peakNits) || !Number.isFinite(data.peakNits) || data.peakNits <= minPeakNits)) {
|
|
259
|
+
throw new Error(`Invalid HDR "peakNits" value: expected a positive number, got "${String(data.peakNits)}"`);
|
|
260
|
+
}
|
|
261
|
+
loadProperty(this, "enable", data.enable);
|
|
262
|
+
loadProperty(this, "mode", data.mode);
|
|
263
|
+
loadProperty(this, "peakNits", data.peakNits);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
244
267
|
class ResizeEvent extends OptionLoader {
|
|
245
268
|
delay = 0.5;
|
|
246
269
|
enable = true;
|
|
@@ -674,7 +697,7 @@ class Options extends OptionLoader {
|
|
|
674
697
|
duration = 0;
|
|
675
698
|
fpsLimit = 120;
|
|
676
699
|
fullScreen;
|
|
677
|
-
hdr
|
|
700
|
+
hdr;
|
|
678
701
|
key;
|
|
679
702
|
name;
|
|
680
703
|
palette;
|
|
@@ -694,6 +717,7 @@ class Options extends OptionLoader {
|
|
|
694
717
|
this.#container = container;
|
|
695
718
|
this.background = new Background();
|
|
696
719
|
this.fullScreen = new FullScreen();
|
|
720
|
+
this.hdr = new HDROptions();
|
|
697
721
|
this.particles = loadParticlesOptions(this.#pluginManager, this.#container);
|
|
698
722
|
this.resize = new ResizeEvent();
|
|
699
723
|
}
|
|
@@ -716,7 +740,15 @@ class Options extends OptionLoader {
|
|
|
716
740
|
loadProperty(this, "detectRetina", data.detectRetina);
|
|
717
741
|
loadRangeProperty(this, "duration", data.duration);
|
|
718
742
|
loadProperty(this, "fpsLimit", data.fpsLimit);
|
|
719
|
-
|
|
743
|
+
const hdrData = data.hdr;
|
|
744
|
+
if (index.isBoolean(hdrData)) {
|
|
745
|
+
this.hdr.enable = hdrData;
|
|
746
|
+
this.hdr.mode = index.HdrMode.standard;
|
|
747
|
+
this.hdr.peakNits = 400;
|
|
748
|
+
}
|
|
749
|
+
else {
|
|
750
|
+
this.hdr.load(hdrData);
|
|
751
|
+
}
|
|
720
752
|
loadProperty(this, "pauseOnBlur", data.pauseOnBlur);
|
|
721
753
|
loadProperty(this, "pauseOnOutsideViewport", data.pauseOnOutsideViewport);
|
|
722
754
|
loadProperty(this, "zLayers", data.zLayers);
|
|
@@ -759,7 +791,7 @@ class Options extends OptionLoader {
|
|
|
759
791
|
}
|
|
760
792
|
}
|
|
761
793
|
|
|
762
|
-
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203;
|
|
794
|
+
const styleCache = new Map(), maxStyleCacheSize = 2000, rgbFixedPrecision = 2, hslFixedPrecision = 2, hdrRgbFixedPrecision = 4, hdrHslFixedPrecision = 4, sdrReferenceWhiteNits = 203, acesA = 2.51, acesB = 0.03, acesC = 2.43, acesD = 0.59, acesE = 0.14, saturationBoost = 1.15, lightnessBoost = 1.05, temperatureR = 1.05, temperatureB = 0.95, contrastFactor = 1.1, luminanceR = 0.2126, luminanceG = 0.7152, luminanceB = 0.0722, dynamicLuminanceFactor = 2, channelCount = 3;
|
|
763
795
|
function getCachedStyle(key, generator) {
|
|
764
796
|
let cached = styleCache.get(key);
|
|
765
797
|
if (!cached) {
|
|
@@ -771,6 +803,42 @@ function getCachedStyle(key, generator) {
|
|
|
771
803
|
}
|
|
772
804
|
return cached;
|
|
773
805
|
}
|
|
806
|
+
function acesFilmic(x) {
|
|
807
|
+
return index.clamp((x * (acesA * x + acesB)) / (x * (acesC * x + acesD) + acesE), index.none, index.one);
|
|
808
|
+
}
|
|
809
|
+
function applyHdrModeAdjustments(r, g, b, mode, maxChannel) {
|
|
810
|
+
switch (mode) {
|
|
811
|
+
case index.HdrMode.vivid: {
|
|
812
|
+
const avg = (r + g + b) / channelCount;
|
|
813
|
+
return {
|
|
814
|
+
b: index.clamp(index.clamp(avg + (b - avg) * saturationBoost, index.none, maxChannel) * lightnessBoost, index.none, maxChannel),
|
|
815
|
+
g: index.clamp(index.clamp(avg + (g - avg) * saturationBoost, index.none, maxChannel) * lightnessBoost, index.none, maxChannel),
|
|
816
|
+
r: index.clamp(index.clamp(avg + (r - avg) * saturationBoost, index.none, maxChannel) * lightnessBoost, index.none, maxChannel),
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
case index.HdrMode.cinematic: {
|
|
820
|
+
const tempR = r * temperatureR, tempB = b * temperatureB, avg = (tempR + g + tempB) / channelCount;
|
|
821
|
+
return {
|
|
822
|
+
b: index.clamp(avg + (tempB - avg) * contrastFactor, index.none, maxChannel),
|
|
823
|
+
g: index.clamp(avg + (g - avg) * contrastFactor, index.none, maxChannel),
|
|
824
|
+
r: index.clamp(avg + (tempR - avg) * contrastFactor, index.none, maxChannel),
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
case index.HdrMode.dynamic: {
|
|
828
|
+
const luminance = luminanceR * r + luminanceG * g + luminanceB * b, vividWeight = Math.min(index.one, luminance * dynamicLuminanceFactor), naturalWeight = index.one - vividWeight, avg = (r + g + b) / channelCount, vividR = index.clamp(avg + (r - avg) * saturationBoost, index.none, maxChannel) * lightnessBoost, vividG = index.clamp(avg + (g - avg) * saturationBoost, index.none, maxChannel) * lightnessBoost, vividB = index.clamp(avg + (b - avg) * saturationBoost, index.none, maxChannel) * lightnessBoost;
|
|
829
|
+
return {
|
|
830
|
+
b: index.clamp(b * naturalWeight + vividB * vividWeight, index.none, maxChannel),
|
|
831
|
+
g: index.clamp(g * naturalWeight + vividG * vividWeight, index.none, maxChannel),
|
|
832
|
+
r: index.clamp(r * naturalWeight + vividR * vividWeight, index.none, maxChannel),
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
case index.HdrMode.standard:
|
|
836
|
+
return { b, g, r };
|
|
837
|
+
case index.HdrMode.natural:
|
|
838
|
+
default:
|
|
839
|
+
return { b, g, r };
|
|
840
|
+
}
|
|
841
|
+
}
|
|
774
842
|
function stringToRgba(pluginManager, input) {
|
|
775
843
|
if (!input) {
|
|
776
844
|
return;
|
|
@@ -908,21 +976,40 @@ function getRandomRgbColor(min, hdr) {
|
|
|
908
976
|
r: getRgbInRangeValue(),
|
|
909
977
|
};
|
|
910
978
|
}
|
|
911
|
-
function getStyleFromRgb(color, hdr, opacity) {
|
|
912
|
-
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? index.defaultOpacity, key =
|
|
913
|
-
|
|
979
|
+
function getStyleFromRgb(color, hdr, opacity, peakNits, mode) {
|
|
980
|
+
const rgbPrecision = hdr ? hdrRgbFixedPrecision : rgbFixedPrecision, op = opacity ?? index.defaultOpacity, key = hdr
|
|
981
|
+
? `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-hdr-${op.toString()}-${(peakNits ?? index.maxNits).toString()}-${mode ?? index.HdrMode.standard}`
|
|
982
|
+
: `rgb-${color.r.toFixed(rgbPrecision)}-${color.g.toFixed(rgbPrecision)}-${color.b.toFixed(rgbPrecision)}-sdr-${op.toString()}`;
|
|
983
|
+
return getCachedStyle(key, () => hdr ? getHdrStyleFromRgb(color, opacity, peakNits, mode) : getSdrStyleFromRgb(color, opacity));
|
|
914
984
|
}
|
|
915
|
-
function getHdrStyleFromRgb(color, opacity, peakNits = index.maxNits) {
|
|
916
|
-
const headroom = peakNits / sdrReferenceWhiteNits;
|
|
917
|
-
return `color(display-p3 ${
|
|
985
|
+
function getHdrStyleFromRgb(color, opacity, peakNits = index.maxNits, mode = index.HdrMode.standard) {
|
|
986
|
+
const headroom = peakNits / sdrReferenceWhiteNits, middleGray = 0.18, mapped = hdrToneMapColor(color, headroom, middleGray, mode);
|
|
987
|
+
return `color(display-p3 ${mapped.r.toString()} ${mapped.g.toString()} ${mapped.b.toString()} / ${(opacity ?? index.defaultOpacity).toString()})`;
|
|
988
|
+
}
|
|
989
|
+
function hdrToneMapColor(color, headroom, middleGray, mode) {
|
|
990
|
+
const rNorm = color.r / index.rgbMax, gNorm = color.g / index.rgbMax, bNorm = color.b / index.rgbMax;
|
|
991
|
+
if (mode !== index.HdrMode.natural && mode !== index.HdrMode.vivid && mode !== index.HdrMode.cinematic && mode !== index.HdrMode.dynamic) {
|
|
992
|
+
return { b: bNorm, g: gNorm, r: rNorm };
|
|
993
|
+
}
|
|
994
|
+
const maxChannel = Math.max(index.one, headroom), luminance = luminanceR * rNorm + luminanceG * gNorm + luminanceB * bNorm, mappedLuminance = hdrToneMap(luminance, headroom, middleGray), scale = luminance > index.none ? mappedLuminance / luminance : index.one;
|
|
995
|
+
return applyHdrModeAdjustments(index.clamp(rNorm * scale, index.none, maxChannel), index.clamp(gNorm * scale, index.none, maxChannel), index.clamp(bNorm * scale, index.none, maxChannel), mode, maxChannel);
|
|
996
|
+
}
|
|
997
|
+
function hdrToneMap(normalized, headroom, middleGray) {
|
|
998
|
+
if (normalized <= middleGray) {
|
|
999
|
+
return acesFilmic(normalized);
|
|
1000
|
+
}
|
|
1001
|
+
const expanded = normalized + (normalized - middleGray) * (headroom - index.one);
|
|
1002
|
+
return acesFilmic(expanded);
|
|
918
1003
|
}
|
|
919
1004
|
function getSdrStyleFromRgb(color, opacity) {
|
|
920
1005
|
return `rgba(${color.r.toString()}, ${color.g.toString()}, ${color.b.toString()}, ${(opacity ?? index.defaultOpacity).toString()})`;
|
|
921
1006
|
}
|
|
922
|
-
function getStyleFromHsl(color, hdr, opacity) {
|
|
923
|
-
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? index.defaultOpacity, key =
|
|
1007
|
+
function getStyleFromHsl(color, hdr, opacity, peakNits, mode) {
|
|
1008
|
+
const hslPrecision = hdr ? hdrHslFixedPrecision : hslFixedPrecision, op = opacity ?? index.defaultOpacity, key = hdr
|
|
1009
|
+
? `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-hdr-${op.toString()}-${(peakNits ?? index.maxNits).toString()}-${mode ?? index.HdrMode.standard}`
|
|
1010
|
+
: `hsl-${color.h.toFixed(hslPrecision)}-${color.s.toFixed(hslPrecision)}-${color.l.toFixed(hslPrecision)}-sdr-${op.toString()}`;
|
|
924
1011
|
return getCachedStyle(key, () => hdr
|
|
925
|
-
? getStyleFromRgb(hslToRgbFloat(color), true, opacity)
|
|
1012
|
+
? getStyleFromRgb(hslToRgbFloat(color), true, opacity, peakNits, mode)
|
|
926
1013
|
: `hsla(${color.h.toString()}, ${color.s.toString()}%, ${color.l.toString()}%, ${op.toString()})`);
|
|
927
1014
|
}
|
|
928
1015
|
function getHslFromAnimation(animation) {
|
|
@@ -1060,7 +1147,11 @@ class RenderManager {
|
|
|
1060
1147
|
if (!fColor && !sColor) {
|
|
1061
1148
|
return;
|
|
1062
1149
|
}
|
|
1063
|
-
const container = this.#container, zIndexOptions = particle.options.zIndex, zIndexFactor = index.zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this.#reusableTransform, colorStyles = this.#reusableColorStyles, fill = fColor
|
|
1150
|
+
const container = this.#container, zIndexOptions = particle.options.zIndex, zIndexFactor = index.zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this.#reusableTransform, colorStyles = this.#reusableColorStyles, fill = fColor
|
|
1151
|
+
? getStyleFromHsl(fColor, container.hdr, fillOpacity * opacity, container.peakNits, container.hdrMode)
|
|
1152
|
+
: undefined, stroke = sColor
|
|
1153
|
+
? getStyleFromHsl(sColor, container.hdr, strokeOpacity * opacity, container.peakNits, container.hdrMode)
|
|
1154
|
+
: fill;
|
|
1064
1155
|
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
1065
1156
|
colorStyles.fill = fill;
|
|
1066
1157
|
colorStyles.stroke = stroke;
|
|
@@ -1394,7 +1485,9 @@ class RenderManager {
|
|
|
1394
1485
|
if (typeof background.element === "string") {
|
|
1395
1486
|
if (typeof document !== "undefined") {
|
|
1396
1487
|
const node = document.querySelector(background.element);
|
|
1397
|
-
if (
|
|
1488
|
+
if ((typeof HTMLCanvasElement !== "undefined" && node instanceof HTMLCanvasElement) ||
|
|
1489
|
+
(typeof HTMLVideoElement !== "undefined" && node instanceof HTMLVideoElement) ||
|
|
1490
|
+
(typeof HTMLImageElement !== "undefined" && node instanceof HTMLImageElement)) {
|
|
1398
1491
|
this.#backgroundElement = node;
|
|
1399
1492
|
}
|
|
1400
1493
|
else if (node) {
|
|
@@ -1405,10 +1498,10 @@ class RenderManager {
|
|
|
1405
1498
|
}
|
|
1406
1499
|
}
|
|
1407
1500
|
}
|
|
1408
|
-
else if (background.element instanceof HTMLCanvasElement ||
|
|
1409
|
-
background.element instanceof OffscreenCanvas ||
|
|
1410
|
-
background.element instanceof HTMLVideoElement ||
|
|
1411
|
-
background.element instanceof HTMLImageElement) {
|
|
1501
|
+
else if ((typeof HTMLCanvasElement !== "undefined" && background.element instanceof HTMLCanvasElement) ||
|
|
1502
|
+
(typeof OffscreenCanvas !== "undefined" && background.element instanceof OffscreenCanvas) ||
|
|
1503
|
+
(typeof HTMLVideoElement !== "undefined" && background.element instanceof HTMLVideoElement) ||
|
|
1504
|
+
(typeof HTMLImageElement !== "undefined" && background.element instanceof HTMLImageElement)) {
|
|
1412
1505
|
this.#backgroundElement = background.element;
|
|
1413
1506
|
}
|
|
1414
1507
|
}
|
|
@@ -1476,6 +1569,7 @@ class CanvasManager {
|
|
|
1476
1569
|
zoom = index.defaultZoom;
|
|
1477
1570
|
#container;
|
|
1478
1571
|
#generated;
|
|
1572
|
+
#hdrMediaListeners;
|
|
1479
1573
|
#mutationObserver;
|
|
1480
1574
|
#originalStyle;
|
|
1481
1575
|
#pluginManager;
|
|
@@ -1540,7 +1634,6 @@ class CanvasManager {
|
|
|
1540
1634
|
});
|
|
1541
1635
|
this.resize();
|
|
1542
1636
|
this.#initStyle();
|
|
1543
|
-
this.initBackground();
|
|
1544
1637
|
this.#safeMutationObserver(obs => {
|
|
1545
1638
|
const element = this.domElement;
|
|
1546
1639
|
if (!element || !(element instanceof Node)) {
|
|
@@ -1550,6 +1643,8 @@ class CanvasManager {
|
|
|
1550
1643
|
});
|
|
1551
1644
|
this.initPlugins();
|
|
1552
1645
|
this.#initContext();
|
|
1646
|
+
this.initBackground();
|
|
1647
|
+
this.#initHdrListeners();
|
|
1553
1648
|
this.render.init();
|
|
1554
1649
|
}
|
|
1555
1650
|
initBackground() {
|
|
@@ -1559,7 +1654,8 @@ class CanvasManager {
|
|
|
1559
1654
|
}
|
|
1560
1655
|
const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
|
|
1561
1656
|
if (color) {
|
|
1562
|
-
|
|
1657
|
+
const hdrOptions = container.actualOptions.hdr;
|
|
1658
|
+
elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity, hdrOptions.peakNits, hdrOptions.mode);
|
|
1563
1659
|
}
|
|
1564
1660
|
else {
|
|
1565
1661
|
elementStyle.backgroundColor = "";
|
|
@@ -1656,6 +1752,7 @@ class CanvasManager {
|
|
|
1656
1752
|
obs.disconnect();
|
|
1657
1753
|
});
|
|
1658
1754
|
this.#mutationObserver = undefined;
|
|
1755
|
+
this.#removeHdrListeners();
|
|
1659
1756
|
this.render.stop();
|
|
1660
1757
|
}
|
|
1661
1758
|
async windowResize() {
|
|
@@ -1675,9 +1772,16 @@ class CanvasManager {
|
|
|
1675
1772
|
}
|
|
1676
1773
|
}
|
|
1677
1774
|
#initContext() {
|
|
1678
|
-
const container = this.#container, canSupportHdr = container.actualOptions.hdr &&
|
|
1775
|
+
const container = this.#container, canSupportHdr = container.actualOptions.hdr.enable &&
|
|
1679
1776
|
index.safeMatchMedia("(color-gamut: p3)")?.matches &&
|
|
1680
1777
|
index.safeMatchMedia("(dynamic-range: high)")?.matches;
|
|
1778
|
+
container.hdr = canSupportHdr ?? false;
|
|
1779
|
+
container.hdrMode = container.actualOptions.hdr.mode;
|
|
1780
|
+
container.peakNits = container.actualOptions.hdr.peakNits;
|
|
1781
|
+
const renderCanvas = this.renderCanvas;
|
|
1782
|
+
if (!renderCanvas) {
|
|
1783
|
+
return;
|
|
1784
|
+
}
|
|
1681
1785
|
this.render.setContextSettings({
|
|
1682
1786
|
alpha: true,
|
|
1683
1787
|
desynchronized: true,
|
|
@@ -1686,11 +1790,47 @@ class CanvasManager {
|
|
|
1686
1790
|
? { colorSpace: "display-p3", colorType: "float16" }
|
|
1687
1791
|
: { colorSpace: "srgb" }),
|
|
1688
1792
|
});
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1793
|
+
let context;
|
|
1794
|
+
try {
|
|
1795
|
+
context = renderCanvas.getContext("2d", this.render.settings);
|
|
1796
|
+
}
|
|
1797
|
+
catch {
|
|
1798
|
+
context = null;
|
|
1799
|
+
}
|
|
1800
|
+
if (canSupportHdr && !context) {
|
|
1801
|
+
container.hdr = false;
|
|
1802
|
+
const sdrSettings = {
|
|
1803
|
+
alpha: true,
|
|
1804
|
+
desynchronized: true,
|
|
1805
|
+
willReadFrequently: false,
|
|
1806
|
+
colorSpace: "srgb",
|
|
1807
|
+
};
|
|
1808
|
+
this.render.setContextSettings(sdrSettings);
|
|
1809
|
+
try {
|
|
1810
|
+
context = renderCanvas.getContext("2d", sdrSettings);
|
|
1811
|
+
}
|
|
1812
|
+
catch {
|
|
1813
|
+
context = null;
|
|
1814
|
+
}
|
|
1692
1815
|
}
|
|
1693
|
-
this.render.setContext(
|
|
1816
|
+
this.render.setContext(context);
|
|
1817
|
+
}
|
|
1818
|
+
#initHdrListeners() {
|
|
1819
|
+
this.#removeHdrListeners();
|
|
1820
|
+
const p3Query = index.safeMatchMedia("(color-gamut: p3)"), hdrQuery = index.safeMatchMedia("(dynamic-range: high)"), handleChange = () => {
|
|
1821
|
+
this.#recreateRenderCanvas();
|
|
1822
|
+
this.#initContext();
|
|
1823
|
+
this.initBackground();
|
|
1824
|
+
}, listeners = [];
|
|
1825
|
+
if (p3Query) {
|
|
1826
|
+
p3Query.addEventListener("change", handleChange);
|
|
1827
|
+
listeners.push({ handler: handleChange, mql: p3Query });
|
|
1828
|
+
}
|
|
1829
|
+
if (hdrQuery) {
|
|
1830
|
+
hdrQuery.addEventListener("change", handleChange);
|
|
1831
|
+
listeners.push({ handler: handleChange, mql: hdrQuery });
|
|
1832
|
+
}
|
|
1833
|
+
this.#hdrMediaListeners = listeners;
|
|
1694
1834
|
}
|
|
1695
1835
|
#initStyle() {
|
|
1696
1836
|
const element = this.domElement, options = this.#container.actualOptions;
|
|
@@ -1714,6 +1854,25 @@ class CanvasManager {
|
|
|
1714
1854
|
element.style.setProperty(key, value, "important");
|
|
1715
1855
|
}
|
|
1716
1856
|
}
|
|
1857
|
+
#recreateRenderCanvas() {
|
|
1858
|
+
const renderCanvas = this.renderCanvas;
|
|
1859
|
+
if (!renderCanvas) {
|
|
1860
|
+
return;
|
|
1861
|
+
}
|
|
1862
|
+
if (this.domElement) {
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
this.renderCanvas = new OffscreenCanvas(renderCanvas.width, renderCanvas.height);
|
|
1866
|
+
}
|
|
1867
|
+
#removeHdrListeners() {
|
|
1868
|
+
if (!this.#hdrMediaListeners) {
|
|
1869
|
+
return;
|
|
1870
|
+
}
|
|
1871
|
+
for (const { handler, mql } of this.#hdrMediaListeners) {
|
|
1872
|
+
mql.removeEventListener("change", handler);
|
|
1873
|
+
}
|
|
1874
|
+
this.#hdrMediaListeners = undefined;
|
|
1875
|
+
}
|
|
1717
1876
|
#repairStyle() {
|
|
1718
1877
|
const element = this.domElement;
|
|
1719
1878
|
if (!element) {
|
|
@@ -2098,9 +2257,9 @@ class Particle {
|
|
|
2098
2257
|
}
|
|
2099
2258
|
getOpacity() {
|
|
2100
2259
|
const zIndexOptions = this.options.zIndex, zIndexFactor = index.zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, baseOpacity = index.getRangeValue(this.opacity?.value ?? index.defaultOpacity), modifierOpacity = this.#applyModifiers(undefined, m => m.opacity), opacity = modifierOpacity ?? baseOpacity, fillOpacity = this.fillOpacity ?? index.defaultOpacity, strokeOpacity = this.strokeOpacity ?? index.defaultOpacity;
|
|
2101
|
-
this.#cachedOpacityData.fillOpacity =
|
|
2260
|
+
this.#cachedOpacityData.fillOpacity = fillOpacity;
|
|
2102
2261
|
this.#cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
2103
|
-
this.#cachedOpacityData.strokeOpacity =
|
|
2262
|
+
this.#cachedOpacityData.strokeOpacity = strokeOpacity;
|
|
2104
2263
|
return this.#cachedOpacityData;
|
|
2105
2264
|
}
|
|
2106
2265
|
getPosition() {
|
|
@@ -2955,6 +3114,7 @@ class Container {
|
|
|
2955
3114
|
effectDrawers;
|
|
2956
3115
|
fpsLimit;
|
|
2957
3116
|
hdr;
|
|
3117
|
+
hdrMode;
|
|
2958
3118
|
id;
|
|
2959
3119
|
pageHidden;
|
|
2960
3120
|
particleCreatedPlugins;
|
|
@@ -2962,6 +3122,7 @@ class Container {
|
|
|
2962
3122
|
particlePositionPlugins;
|
|
2963
3123
|
particleUpdaters;
|
|
2964
3124
|
particles;
|
|
3125
|
+
peakNits;
|
|
2965
3126
|
plugins;
|
|
2966
3127
|
retina;
|
|
2967
3128
|
shapeDrawers;
|
|
@@ -2992,6 +3153,8 @@ class Container {
|
|
|
2992
3153
|
this.id = Symbol(id);
|
|
2993
3154
|
this.fpsLimit = 120;
|
|
2994
3155
|
this.hdr = false;
|
|
3156
|
+
this.hdrMode = index.HdrMode.standard;
|
|
3157
|
+
this.peakNits = 400;
|
|
2995
3158
|
this.#smooth = false;
|
|
2996
3159
|
this.#delay = 0;
|
|
2997
3160
|
this.#duration = 0;
|
|
@@ -3131,8 +3294,9 @@ class Container {
|
|
|
3131
3294
|
this.updateActualOptions();
|
|
3132
3295
|
this.canvas.initBackground();
|
|
3133
3296
|
this.canvas.resize();
|
|
3134
|
-
const { delay, duration, fpsLimit,
|
|
3135
|
-
this.
|
|
3297
|
+
const { delay, duration, fpsLimit, smooth, zLayers } = this.actualOptions, hdrOptions = this.actualOptions.hdr;
|
|
3298
|
+
this.hdrMode = hdrOptions.mode;
|
|
3299
|
+
this.peakNits = hdrOptions.peakNits;
|
|
3136
3300
|
this.zLayers = zLayers;
|
|
3137
3301
|
this.#duration = index.getRangeValue(duration) * index.millisecondsToSeconds;
|
|
3138
3302
|
this.#delay = index.getRangeValue(delay) * index.millisecondsToSeconds;
|
|
@@ -271,6 +271,9 @@ exports.PixelMode = void 0;
|
|
|
271
271
|
PixelMode["percent"] = "percent";
|
|
272
272
|
})(exports.PixelMode || (exports.PixelMode = {}));
|
|
273
273
|
|
|
274
|
+
function isForbiddenKey(key) {
|
|
275
|
+
return key === "__proto__" || key === "constructor" || key === "prototype";
|
|
276
|
+
}
|
|
274
277
|
function hasMatchMedia() {
|
|
275
278
|
return typeof matchMedia !== "undefined";
|
|
276
279
|
}
|
|
@@ -319,7 +322,7 @@ function deepExtend(destination, ...sources) {
|
|
|
319
322
|
if (!hasNested) {
|
|
320
323
|
const sourceDict = source, destDict = destination;
|
|
321
324
|
for (const key of sourceKeys) {
|
|
322
|
-
if (key
|
|
325
|
+
if (isForbiddenKey(key)) {
|
|
323
326
|
continue;
|
|
324
327
|
}
|
|
325
328
|
const v = sourceDict[key];
|
|
@@ -330,7 +333,7 @@ function deepExtend(destination, ...sources) {
|
|
|
330
333
|
continue;
|
|
331
334
|
}
|
|
332
335
|
for (const key of sourceKeys) {
|
|
333
|
-
if (key
|
|
336
|
+
if (isForbiddenKey(key)) {
|
|
334
337
|
continue;
|
|
335
338
|
}
|
|
336
339
|
const sourceDict = source, destDict = destination, value = sourceDict[key];
|
|
@@ -746,7 +749,7 @@ class Engine {
|
|
|
746
749
|
return this.#domArray;
|
|
747
750
|
}
|
|
748
751
|
get version() {
|
|
749
|
-
return "4.
|
|
752
|
+
return "4.4.0";
|
|
750
753
|
}
|
|
751
754
|
addEventListener(type, listener) {
|
|
752
755
|
this.#eventDispatcher.addEventListener(type, listener);
|
|
@@ -781,7 +784,7 @@ class Engine {
|
|
|
781
784
|
if (typeof HTMLElement !== "undefined" && params.element instanceof HTMLElement) {
|
|
782
785
|
domSourceElement = params.element;
|
|
783
786
|
}
|
|
784
|
-
const { Container } = await Promise.resolve().then(function () { return require('./Container-
|
|
787
|
+
const { Container } = await Promise.resolve().then(function () { return require('./Container-BPdTDiSM.js'); }), id = params.id ?? domSourceElement?.id ?? `tsparticles${Math.floor(getRandom() * loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = itemFromSingleOrMultiple(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container({
|
|
785
788
|
dispatchCallback: (eventType, args) => {
|
|
786
789
|
this.dispatchEvent(eventType, args);
|
|
787
790
|
},
|
|
@@ -827,6 +830,10 @@ class Engine {
|
|
|
827
830
|
}
|
|
828
831
|
|
|
829
832
|
function initEngine() {
|
|
833
|
+
const existing = globalThis.tsParticles;
|
|
834
|
+
if (existing?.pluginManager) {
|
|
835
|
+
return existing;
|
|
836
|
+
}
|
|
830
837
|
return new Engine();
|
|
831
838
|
}
|
|
832
839
|
|
|
@@ -851,6 +858,15 @@ var AnimationMode;
|
|
|
851
858
|
AnimationMode["random"] = "random";
|
|
852
859
|
})(AnimationMode || (AnimationMode = {}));
|
|
853
860
|
|
|
861
|
+
exports.HdrMode = void 0;
|
|
862
|
+
(function (HdrMode) {
|
|
863
|
+
HdrMode["standard"] = "standard";
|
|
864
|
+
HdrMode["natural"] = "natural";
|
|
865
|
+
HdrMode["vivid"] = "vivid";
|
|
866
|
+
HdrMode["cinematic"] = "cinematic";
|
|
867
|
+
HdrMode["dynamic"] = "dynamic";
|
|
868
|
+
})(exports.HdrMode || (exports.HdrMode = {}));
|
|
869
|
+
|
|
854
870
|
exports.LimitMode = void 0;
|
|
855
871
|
(function (LimitMode) {
|
|
856
872
|
LimitMode["delete"] = "delete";
|
|
@@ -1025,6 +1041,7 @@ exports.minLimit = minLimit;
|
|
|
1025
1041
|
exports.minStrokeWidth = minStrokeWidth;
|
|
1026
1042
|
exports.minZ = minZ;
|
|
1027
1043
|
exports.minimumSize = minimumSize;
|
|
1044
|
+
exports.none = none;
|
|
1028
1045
|
exports.one = one;
|
|
1029
1046
|
exports.originPoint = originPoint;
|
|
1030
1047
|
exports.phaseNumerator = phaseNumerator;
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-BjS63OiI.js');
|
|
4
|
-
var index$1 = require('./index-
|
|
4
|
+
var index$1 = require('./index-B6adnBft.js');
|
|
5
5
|
|
|
6
6
|
const StencilParticles = class {
|
|
7
7
|
constructor(hostRef) {
|
|
@@ -48,7 +48,7 @@ const StencilParticles = class {
|
|
|
48
48
|
}
|
|
49
49
|
// Load particles directly onto the DOM element.
|
|
50
50
|
// If a container-id is provided, use it so consumers can retrieve the container later.
|
|
51
|
-
const loadParams = Object.assign(Object.assign({ element: this.containerElement }, (this.containerId ? { id: this.containerId } : {})), (this.options ? { options: this.options } : { url: this.url }));
|
|
51
|
+
const loadParams = Object.assign(Object.assign(Object.assign({ element: this.containerElement }, (this.containerId ? { id: this.containerId } : {})), (this.options ? { options: this.options } : {})), (this.url ? { url: this.url } : {}));
|
|
52
52
|
container = await index$1.tsParticles.load(loadParams);
|
|
53
53
|
}
|
|
54
54
|
catch (error) {
|
|
@@ -67,7 +67,7 @@ const StencilParticles = class {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
render() {
|
|
70
|
-
return (index.h("div", { key: '
|
|
70
|
+
return (index.h("div", { key: 'a2468083e697bd937120a4e800456a12d80a6935', id: this.containerId, ref: el => {
|
|
71
71
|
this.containerElement = el;
|
|
72
72
|
}, style: { width: "100%", height: "100%" } }));
|
|
73
73
|
}
|
|
@@ -44,7 +44,7 @@ export class StencilParticles {
|
|
|
44
44
|
}
|
|
45
45
|
// Load particles directly onto the DOM element.
|
|
46
46
|
// If a container-id is provided, use it so consumers can retrieve the container later.
|
|
47
|
-
const loadParams = Object.assign(Object.assign({ element: this.containerElement }, (this.containerId ? { id: this.containerId } : {})), (this.options ? { options: this.options } : { url: this.url }));
|
|
47
|
+
const loadParams = Object.assign(Object.assign(Object.assign({ element: this.containerElement }, (this.containerId ? { id: this.containerId } : {})), (this.options ? { options: this.options } : {})), (this.url ? { url: this.url } : {}));
|
|
48
48
|
container = await tsParticles.load(loadParams);
|
|
49
49
|
}
|
|
50
50
|
catch (error) {
|
|
@@ -63,7 +63,7 @@ export class StencilParticles {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
render() {
|
|
66
|
-
return (h("div", { key: '
|
|
66
|
+
return (h("div", { key: 'a2468083e697bd937120a4e800456a12d80a6935', id: this.containerId, ref: el => {
|
|
67
67
|
this.containerElement = el;
|
|
68
68
|
}, style: { width: "100%", height: "100%" } }));
|
|
69
69
|
}
|