@tsparticles/slim 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
@@ -6486,8 +6486,9 @@ class EmojiDrawer {
6486
6486
  this._emojiShapeDict = new Map();
6487
6487
  }
6488
6488
  destroy() {
6489
- for (const [, emojiData] of this._emojiShapeDict) {
6489
+ for (const [key, emojiData] of this._emojiShapeDict) {
6490
6490
  emojiData instanceof ImageBitmap && emojiData?.close();
6491
+ this._emojiShapeDict.delete(key);
6491
6492
  }
6492
6493
  }
6493
6494
  draw(data) {
@@ -6522,52 +6523,50 @@ class EmojiDrawer {
6522
6523
  delete particle.emojiData;
6523
6524
  }
6524
6525
  particleInit(container, particle) {
6525
- if (!particle.emojiData) {
6526
- const shapeData = particle.shapeData;
6527
- if (!shapeData?.value) {
6528
- return;
6529
- }
6530
- const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
6531
- font = shapeData.font ?? defaultFont;
6532
- if (!emoji) {
6526
+ const shapeData = particle.shapeData;
6527
+ if (!shapeData?.value) {
6528
+ return;
6529
+ }
6530
+ const emoji = itemFromSingleOrMultiple(shapeData.value, particle.randomIndexData),
6531
+ font = shapeData.font ?? defaultFont;
6532
+ if (!emoji) {
6533
+ return;
6534
+ }
6535
+ const key = `${emoji}_${font}`,
6536
+ existingData = this._emojiShapeDict.get(key);
6537
+ if (existingData) {
6538
+ particle.emojiData = existingData;
6539
+ return;
6540
+ }
6541
+ const canvasSize = getRangeMax(particle.size.value) * 2;
6542
+ let emojiData;
6543
+ if (typeof OffscreenCanvas !== "undefined") {
6544
+ const canvas = new OffscreenCanvas(canvasSize, canvasSize),
6545
+ context = canvas.getContext("2d");
6546
+ if (!context) {
6533
6547
  return;
6534
6548
  }
6535
- const key = `${emoji}_${font}`,
6536
- existingData = this._emojiShapeDict.get(key);
6537
- if (existingData) {
6538
- particle.emojiData = existingData;
6549
+ context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
6550
+ context.textBaseline = "middle";
6551
+ context.textAlign = "center";
6552
+ context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
6553
+ emojiData = canvas.transferToImageBitmap();
6554
+ } else {
6555
+ const canvas = document.createElement("canvas");
6556
+ canvas.width = canvasSize;
6557
+ canvas.height = canvasSize;
6558
+ const context = canvas.getContext("2d");
6559
+ if (!context) {
6539
6560
  return;
6540
6561
  }
6541
- const canvasSize = getRangeMax(particle.size.value) * 2;
6542
- let emojiData;
6543
- if (typeof OffscreenCanvas !== "undefined") {
6544
- const canvas = new OffscreenCanvas(canvasSize, canvasSize),
6545
- context = canvas.getContext("2d");
6546
- if (!context) {
6547
- return;
6548
- }
6549
- context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
6550
- context.textBaseline = "middle";
6551
- context.textAlign = "center";
6552
- context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
6553
- emojiData = canvas.transferToImageBitmap();
6554
- } else {
6555
- const canvas = document.createElement("canvas");
6556
- canvas.width = canvasSize;
6557
- canvas.height = canvasSize;
6558
- const context = canvas.getContext("2d");
6559
- if (!context) {
6560
- return;
6561
- }
6562
- context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
6563
- context.textBaseline = "middle";
6564
- context.textAlign = "center";
6565
- context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
6566
- emojiData = canvas;
6567
- }
6568
- this._emojiShapeDict.set(key, emojiData);
6569
- particle.emojiData = emojiData;
6562
+ context.font = `400 ${getRangeMax(particle.size.value) * 2}px ${font}`;
6563
+ context.textBaseline = "middle";
6564
+ context.textAlign = "center";
6565
+ context.fillText(emoji, getRangeMax(particle.size.value), getRangeMax(particle.size.value));
6566
+ emojiData = canvas;
6570
6567
  }
6568
+ this._emojiShapeDict.set(key, emojiData);
6569
+ particle.emojiData = emojiData;
6571
6570
  }
6572
6571
  }
6573
6572
  ;// CONCATENATED MODULE: ../../shapes/emoji/dist/browser/index.js