@tsparticles/all 3.0.2 → 3.0.3

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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v3.0.2
7
+ * v3.0.3
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -5165,7 +5165,7 @@ class Engine {
5165
5165
  return res;
5166
5166
  }
5167
5167
  get version() {
5168
- return "3.0.2";
5168
+ return "3.0.3";
5169
5169
  }
5170
5170
  addConfig(config) {
5171
5171
  const name = config.name ?? "default";
@@ -5280,7 +5280,7 @@ class Engine {
5280
5280
  this._initialized = true;
5281
5281
  }
5282
5282
  async load(params) {
5283
- const id = params.id ?? `tsparticles${Math.floor(getRandom() * 10000)}`,
5283
+ const id = params.id ?? params.element?.id ?? `tsparticles${Math.floor(getRandom() * 10000)}`,
5284
5284
  {
5285
5285
  index,
5286
5286
  url
@@ -10800,8 +10800,9 @@ class EmojiDrawer {
10800
10800
  this._emojiShapeDict = new Map();
10801
10801
  }
10802
10802
  destroy() {
10803
- for (const [, emojiData] of this._emojiShapeDict) {
10803
+ for (const [key, emojiData] of this._emojiShapeDict) {
10804
10804
  emojiData instanceof ImageBitmap && emojiData?.close();
10805
+ this._emojiShapeDict.delete(key);
10805
10806
  }
10806
10807
  }
10807
10808
  draw(data) {
@@ -10836,52 +10837,50 @@ class EmojiDrawer {
10836
10837
  delete particle.emojiData;
10837
10838
  }
10838
10839
  particleInit(container, particle) {
10839
- if (!particle.emojiData) {
10840
- const shapeData = particle.shapeData;
10841
- if (!shapeData?.value) {
10842
- return;
10843
- }
10844
- const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
10845
- font = shapeData.font ?? defaultFont;
10846
- if (!emoji) {
10840
+ const shapeData = particle.shapeData;
10841
+ if (!shapeData?.value) {
10842
+ return;
10843
+ }
10844
+ const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
10845
+ font = shapeData.font ?? defaultFont;
10846
+ if (!emoji) {
10847
+ return;
10848
+ }
10849
+ const key = `${emoji}_${font}`,
10850
+ existingData = this._emojiShapeDict.get(key);
10851
+ if (existingData) {
10852
+ particle.emojiData = existingData;
10853
+ return;
10854
+ }
10855
+ const canvasSize = getRangeMax(particle.size.value) * 2;
10856
+ let emojiData;
10857
+ if (typeof OffscreenCanvas !== "undefined") {
10858
+ const canvas = new OffscreenCanvas(canvasSize, canvasSize),
10859
+ context = canvas.getContext("2d");
10860
+ if (!context) {
10847
10861
  return;
10848
10862
  }
10849
- const key = `${emoji}_${font}`,
10850
- existingData = this._emojiShapeDict.get(key);
10851
- if (existingData) {
10852
- particle.emojiData = existingData;
10863
+ context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
10864
+ context.textBaseline = "middle";
10865
+ context.textAlign = "center";
10866
+ context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
10867
+ emojiData = canvas.transferToImageBitmap();
10868
+ } else {
10869
+ const canvas = document.createElement("canvas");
10870
+ canvas.width = canvasSize;
10871
+ canvas.height = canvasSize;
10872
+ const context = canvas.getContext("2d");
10873
+ if (!context) {
10853
10874
  return;
10854
10875
  }
10855
- const canvasSize = getRangeMax(particle.size.value) * 2;
10856
- let emojiData;
10857
- if (typeof OffscreenCanvas !== "undefined") {
10858
- const canvas = new OffscreenCanvas(canvasSize, canvasSize),
10859
- context = canvas.getContext("2d");
10860
- if (!context) {
10861
- return;
10862
- }
10863
- context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
10864
- context.textBaseline = "middle";
10865
- context.textAlign = "center";
10866
- context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
10867
- emojiData = canvas.transferToImageBitmap();
10868
- } else {
10869
- const canvas = document.createElement("canvas");
10870
- canvas.width = canvasSize;
10871
- canvas.height = canvasSize;
10872
- const context = canvas.getContext("2d");
10873
- if (!context) {
10874
- return;
10875
- }
10876
- context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
10877
- context.textBaseline = "middle";
10878
- context.textAlign = "center";
10879
- context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
10880
- emojiData = canvas;
10881
- }
10882
- this._emojiShapeDict.set(key, emojiData);
10883
- particle.emojiData = emojiData;
10876
+ context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
10877
+ context.textBaseline = "middle";
10878
+ context.textAlign = "center";
10879
+ context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
10880
+ emojiData = canvas;
10884
10881
  }
10882
+ this._emojiShapeDict.set(key, emojiData);
10883
+ particle.emojiData = emojiData;
10885
10884
  }
10886
10885
  }
10887
10886
  ;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js