@tsparticles/engine 4.0.4 → 4.1.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.
Files changed (102) hide show
  1. package/browser/Core/CanvasManager.js +72 -72
  2. package/browser/Core/Container.js +85 -85
  3. package/browser/Core/Engine.js +11 -11
  4. package/browser/Core/Particle.js +142 -63
  5. package/browser/Core/ParticlesManager.js +138 -138
  6. package/browser/Core/RenderManager.js +110 -110
  7. package/browser/Core/Retina.js +3 -4
  8. package/browser/Core/Utils/EventListeners.js +31 -31
  9. package/browser/Core/Utils/PluginManager.js +26 -26
  10. package/browser/Core/Utils/SpatialHashGrid.js +36 -36
  11. package/browser/Core/Utils/Vectors.js +3 -3
  12. package/browser/Options/Classes/Options.js +13 -13
  13. package/browser/Options/Classes/Particles/ParticlesOptions.js +11 -19
  14. package/browser/Utils/EventDispatcher.js +10 -10
  15. package/browser/exports.js +0 -4
  16. package/cjs/Core/CanvasManager.js +72 -72
  17. package/cjs/Core/Container.js +85 -85
  18. package/cjs/Core/Engine.js +11 -11
  19. package/cjs/Core/Particle.js +142 -63
  20. package/cjs/Core/ParticlesManager.js +138 -138
  21. package/cjs/Core/RenderManager.js +110 -110
  22. package/cjs/Core/Retina.js +3 -4
  23. package/cjs/Core/Utils/EventListeners.js +31 -31
  24. package/cjs/Core/Utils/PluginManager.js +26 -26
  25. package/cjs/Core/Utils/SpatialHashGrid.js +36 -36
  26. package/cjs/Core/Utils/Vectors.js +3 -3
  27. package/cjs/Options/Classes/Options.js +13 -13
  28. package/cjs/Options/Classes/Particles/ParticlesOptions.js +11 -19
  29. package/cjs/Utils/EventDispatcher.js +10 -10
  30. package/cjs/exports.js +0 -4
  31. package/esm/Core/CanvasManager.js +72 -72
  32. package/esm/Core/Container.js +85 -85
  33. package/esm/Core/Engine.js +11 -11
  34. package/esm/Core/Particle.js +142 -63
  35. package/esm/Core/ParticlesManager.js +138 -138
  36. package/esm/Core/RenderManager.js +110 -110
  37. package/esm/Core/Retina.js +3 -4
  38. package/esm/Core/Utils/EventListeners.js +31 -31
  39. package/esm/Core/Utils/PluginManager.js +26 -26
  40. package/esm/Core/Utils/SpatialHashGrid.js +36 -36
  41. package/esm/Core/Utils/Vectors.js +3 -3
  42. package/esm/Options/Classes/Options.js +13 -13
  43. package/esm/Options/Classes/Particles/ParticlesOptions.js +11 -19
  44. package/esm/Utils/EventDispatcher.js +10 -10
  45. package/esm/exports.js +0 -4
  46. package/package.json +1 -1
  47. package/report.html +1 -1
  48. package/tsparticles.engine.js +690 -697
  49. package/tsparticles.engine.min.js +1 -1
  50. package/types/Core/CanvasManager.d.ts +1 -16
  51. package/types/Core/Container.d.ts +1 -18
  52. package/types/Core/Engine.d.ts +1 -3
  53. package/types/Core/Interfaces/IEffectDrawer.d.ts +2 -0
  54. package/types/Core/Interfaces/IParticleCanvasBounds.d.ts +16 -0
  55. package/types/Core/Interfaces/IParticleUpdater.d.ts +1 -0
  56. package/types/Core/Interfaces/IShapeDrawer.d.ts +2 -0
  57. package/types/Core/Particle.d.ts +5 -13
  58. package/types/Core/ParticlesManager.d.ts +1 -28
  59. package/types/Core/RenderManager.d.ts +1 -23
  60. package/types/Core/Retina.d.ts +1 -1
  61. package/types/Core/Utils/EventListeners.d.ts +1 -8
  62. package/types/Core/Utils/PluginManager.d.ts +1 -8
  63. package/types/Core/Utils/SpatialHashGrid.d.ts +1 -12
  64. package/types/Core/Utils/Vectors.d.ts +1 -1
  65. package/types/Options/Classes/Options.d.ts +1 -4
  66. package/types/Options/Classes/Particles/ParticlesOptions.d.ts +1 -7
  67. package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -4
  68. package/types/Utils/EventDispatcher.d.ts +1 -1
  69. package/types/export-types.d.ts +1 -4
  70. package/types/exports.d.ts +0 -4
  71. package/browser/Options/Classes/Particles/Opacity/Opacity.js +0 -21
  72. package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -20
  73. package/browser/Options/Classes/Particles/Size/Size.js +0 -21
  74. package/browser/Options/Classes/Particles/Size/SizeAnimation.js +0 -20
  75. package/browser/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -1
  76. package/cjs/Options/Classes/Particles/Opacity/Opacity.js +0 -21
  77. package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -20
  78. package/cjs/Options/Classes/Particles/Size/Size.js +0 -21
  79. package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +0 -20
  80. package/cjs/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -1
  81. package/cjs/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -1
  82. package/cjs/Options/Interfaces/Particles/Size/ISize.js +0 -1
  83. package/cjs/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -1
  84. package/esm/Options/Classes/Particles/Opacity/Opacity.js +0 -21
  85. package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -20
  86. package/esm/Options/Classes/Particles/Size/Size.js +0 -21
  87. package/esm/Options/Classes/Particles/Size/SizeAnimation.js +0 -20
  88. package/esm/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -1
  89. package/esm/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -1
  90. package/esm/Options/Interfaces/Particles/Size/ISize.js +0 -1
  91. package/esm/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -1
  92. package/types/Options/Classes/Particles/Opacity/Opacity.d.ts +0 -10
  93. package/types/Options/Classes/Particles/Opacity/OpacityAnimation.d.ts +0 -10
  94. package/types/Options/Classes/Particles/Size/Size.d.ts +0 -10
  95. package/types/Options/Classes/Particles/Size/SizeAnimation.d.ts +0 -10
  96. package/types/Options/Interfaces/Particles/Opacity/IOpacity.d.ts +0 -5
  97. package/types/Options/Interfaces/Particles/Opacity/IOpacityAnimation.d.ts +0 -5
  98. package/types/Options/Interfaces/Particles/Size/ISize.d.ts +0 -5
  99. package/types/Options/Interfaces/Particles/Size/ISizeAnimation.d.ts +0 -5
  100. /package/browser/{Options/Interfaces/Particles/Opacity/IOpacity.js → Core/Interfaces/IParticleCanvasBounds.js} +0 -0
  101. /package/{browser/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js → cjs/Core/Interfaces/IParticleCanvasBounds.js} +0 -0
  102. /package/{browser/Options/Interfaces/Particles/Size/ISize.js → esm/Core/Interfaces/IParticleCanvasBounds.js} +0 -0
@@ -56,53 +56,53 @@ export class CanvasManager {
56
56
  renderCanvas;
57
57
  size;
58
58
  zoom = defaultZoom;
59
- _container;
60
- _generated;
61
- _mutationObserver;
62
- _originalStyle;
63
- _pluginManager;
64
- _pointerEvents;
65
- _resizePlugins;
66
- _standardSize;
67
- _zoomCenter;
59
+ #container;
60
+ #generated;
61
+ #mutationObserver;
62
+ #originalStyle;
63
+ #pluginManager;
64
+ #pointerEvents;
65
+ #resizePlugins;
66
+ #standardSize;
67
+ #zoomCenter;
68
68
  constructor(pluginManager, container) {
69
- this._pluginManager = pluginManager;
70
- this._container = container;
69
+ this.#pluginManager = pluginManager;
70
+ this.#container = container;
71
71
  this.render = new RenderManager(pluginManager, container, this);
72
- this._standardSize = {
72
+ this.#standardSize = {
73
73
  height: 0,
74
74
  width: 0,
75
75
  };
76
- const pxRatio = container.retina.pixelRatio, stdSize = this._standardSize;
76
+ const pxRatio = container.retina.pixelRatio, stdSize = this.#standardSize;
77
77
  this.size = {
78
78
  height: stdSize.height * pxRatio,
79
79
  width: stdSize.width * pxRatio,
80
80
  };
81
- this._generated = false;
82
- this._resizePlugins = [];
83
- this._pointerEvents = "none";
81
+ this.#generated = false;
82
+ this.#resizePlugins = [];
83
+ this.#pointerEvents = "none";
84
84
  }
85
- get _fullScreen() {
86
- return this._container.actualOptions.fullScreen.enable;
85
+ get #fullScreen() {
86
+ return this.#container.actualOptions.fullScreen.enable;
87
87
  }
88
88
  destroy() {
89
89
  this.stop();
90
- if (this._generated) {
90
+ if (this.#generated) {
91
91
  const element = this.domElement;
92
92
  element?.remove();
93
93
  this.domElement = undefined;
94
94
  this.renderCanvas = undefined;
95
95
  }
96
96
  else {
97
- this._resetOriginalStyle();
97
+ this.#resetOriginalStyle();
98
98
  }
99
99
  this.render.destroy();
100
- this._resizePlugins = [];
100
+ this.#resizePlugins = [];
101
101
  }
102
102
  getZoomCenter() {
103
- const pxRatio = this._container.retina.pixelRatio, { width, height } = this.size;
104
- if (this._zoomCenter) {
105
- return this._zoomCenter;
103
+ const pxRatio = this.#container.retina.pixelRatio, { width, height } = this.size;
104
+ if (this.#zoomCenter) {
105
+ return this.#zoomCenter;
106
106
  }
107
107
  return {
108
108
  x: (width * half) / pxRatio,
@@ -110,20 +110,20 @@ export class CanvasManager {
110
110
  };
111
111
  }
112
112
  init() {
113
- this._safeMutationObserver(obs => {
113
+ this.#safeMutationObserver(obs => {
114
114
  obs.disconnect();
115
115
  });
116
- this._mutationObserver = safeMutationObserver(records => {
116
+ this.#mutationObserver = safeMutationObserver(records => {
117
117
  for (const record of records) {
118
118
  if (record.type === "attributes" && record.attributeName === "style") {
119
- this._repairStyle();
119
+ this.#repairStyle();
120
120
  }
121
121
  }
122
122
  });
123
123
  this.resize();
124
- this._initStyle();
124
+ this.#initStyle();
125
125
  this.initBackground();
126
- this._safeMutationObserver(obs => {
126
+ this.#safeMutationObserver(obs => {
127
127
  const element = this.domElement;
128
128
  if (!element || !(element instanceof Node)) {
129
129
  return;
@@ -134,13 +134,13 @@ export class CanvasManager {
134
134
  this.render.init();
135
135
  }
136
136
  initBackground() {
137
- const { _container } = this, options = _container.actualOptions, background = options.background, element = this.domElement;
137
+ const container = this.#container, options = container.actualOptions, background = options.background, element = this.domElement;
138
138
  if (!element) {
139
139
  return;
140
140
  }
141
- const elementStyle = element.style, color = rangeColorToRgb(this._pluginManager, background.color);
141
+ const elementStyle = element.style, color = rangeColorToRgb(this.#pluginManager, background.color);
142
142
  if (color) {
143
- elementStyle.backgroundColor = getStyleFromRgb(color, _container.hdr, background.opacity);
143
+ elementStyle.backgroundColor = getStyleFromRgb(color, container.hdr, background.opacity);
144
144
  }
145
145
  else {
146
146
  elementStyle.backgroundColor = "";
@@ -151,27 +151,27 @@ export class CanvasManager {
151
151
  elementStyle.backgroundSize = background.size || "";
152
152
  }
153
153
  initPlugins() {
154
- this._resizePlugins = [];
155
- for (const plugin of this._container.plugins) {
154
+ this.#resizePlugins = [];
155
+ for (const plugin of this.#container.plugins) {
156
156
  if (plugin.resize) {
157
- this._resizePlugins.push(plugin);
157
+ this.#resizePlugins.push(plugin);
158
158
  }
159
159
  }
160
160
  }
161
161
  loadCanvas(canvas) {
162
- if (this._generated && this.domElement) {
162
+ if (this.#generated && this.domElement) {
163
163
  this.domElement.remove();
164
164
  }
165
- const container = this._container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
165
+ const container = this.#container, domCanvas = isHtmlCanvasElement(canvas) ? canvas : undefined;
166
166
  this.domElement = domCanvas;
167
- this._generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
167
+ this.#generated = domCanvas ? domCanvas.dataset[generatedAttribute] === "true" : false;
168
168
  this.renderCanvas = domCanvas ? getTransferredCanvas(domCanvas) : canvas;
169
169
  const domElement = this.domElement;
170
170
  if (domElement) {
171
171
  domElement.ariaHidden = "true";
172
- this._originalStyle = cloneStyle(domElement.style);
172
+ this.#originalStyle = cloneStyle(domElement.style);
173
173
  }
174
- const standardSize = this._standardSize, renderCanvas = this.renderCanvas;
174
+ const standardSize = this.#standardSize, renderCanvas = this.renderCanvas;
175
175
  if (domElement) {
176
176
  standardSize.height = domElement.offsetHeight;
177
177
  standardSize.width = domElement.offsetWidth;
@@ -180,7 +180,7 @@ export class CanvasManager {
180
180
  standardSize.height = renderCanvas.height;
181
181
  standardSize.width = renderCanvas.width;
182
182
  }
183
- const pxRatio = this._container.retina.pixelRatio, retinaSize = this.size;
183
+ const pxRatio = this.#container.retina.pixelRatio, retinaSize = this.size;
184
184
  renderCanvas.height = retinaSize.height = standardSize.height * pxRatio;
185
185
  renderCanvas.width = retinaSize.width = standardSize.width * pxRatio;
186
186
  const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
@@ -191,12 +191,12 @@ export class CanvasManager {
191
191
  willReadFrequently: false,
192
192
  });
193
193
  this.render.setContext(renderCanvas.getContext("2d", this.render.settings));
194
- this._safeMutationObserver(obs => {
194
+ this.#safeMutationObserver(obs => {
195
195
  obs.disconnect();
196
196
  });
197
197
  container.retina.init();
198
198
  this.initBackground();
199
- this._safeMutationObserver(obs => {
199
+ this.#safeMutationObserver(obs => {
200
200
  const element = this.domElement;
201
201
  if (!element || !(element instanceof Node)) {
202
202
  return;
@@ -209,11 +209,11 @@ export class CanvasManager {
209
209
  if (!element) {
210
210
  return false;
211
211
  }
212
- const container = this._container, renderCanvas = this.renderCanvas;
212
+ const container = this.#container, renderCanvas = this.renderCanvas;
213
213
  if (renderCanvas === undefined) {
214
214
  return false;
215
215
  }
216
- const currentSize = container.canvas._standardSize, newSize = {
216
+ const currentSize = container.canvas.#standardSize, newSize = {
217
217
  width: element.offsetWidth,
218
218
  height: element.offsetHeight,
219
219
  }, pxRatio = container.retina.pixelRatio, retinaSize = {
@@ -232,7 +232,7 @@ export class CanvasManager {
232
232
  const canvasSize = this.size;
233
233
  renderCanvas.width = canvasSize.width = retinaSize.width;
234
234
  renderCanvas.height = canvasSize.height = retinaSize.height;
235
- if (this._container.started) {
235
+ if (this.#container.started) {
236
236
  container.particles.setResizeFactor({
237
237
  width: currentSize.width / oldSize.width,
238
238
  height: currentSize.height / oldSize.height,
@@ -245,46 +245,46 @@ export class CanvasManager {
245
245
  if (!element) {
246
246
  return;
247
247
  }
248
- this._pointerEvents = type;
249
- this._repairStyle();
248
+ this.#pointerEvents = type;
249
+ this.#repairStyle();
250
250
  }
251
251
  setZoom(zoomLevel, center) {
252
252
  this.zoom = zoomLevel;
253
- this._zoomCenter = center;
253
+ this.#zoomCenter = center;
254
254
  }
255
255
  stop() {
256
- this._safeMutationObserver(obs => {
256
+ this.#safeMutationObserver(obs => {
257
257
  obs.disconnect();
258
258
  });
259
- this._mutationObserver = undefined;
259
+ this.#mutationObserver = undefined;
260
260
  this.render.stop();
261
261
  }
262
262
  async windowResize() {
263
263
  if (!this.domElement || !this.resize()) {
264
264
  return;
265
265
  }
266
- const container = this._container, needsRefresh = container.updateActualOptions();
266
+ const container = this.#container, needsRefresh = container.updateActualOptions();
267
267
  container.particles.setDensity();
268
- this._applyResizePlugins();
268
+ this.#applyResizePlugins();
269
269
  if (needsRefresh) {
270
270
  await container.refresh();
271
271
  }
272
272
  }
273
- _applyResizePlugins = () => {
274
- for (const plugin of this._resizePlugins) {
273
+ #applyResizePlugins = () => {
274
+ for (const plugin of this.#resizePlugins) {
275
275
  plugin.resize?.();
276
276
  }
277
277
  };
278
- _initStyle = () => {
279
- const element = this.domElement, options = this._container.actualOptions;
278
+ #initStyle = () => {
279
+ const element = this.domElement, options = this.#container.actualOptions;
280
280
  if (!element) {
281
281
  return;
282
282
  }
283
- if (this._fullScreen) {
284
- this._setFullScreenStyle();
283
+ if (this.#fullScreen) {
284
+ this.#setFullScreenStyle();
285
285
  }
286
286
  else {
287
- this._resetOriginalStyle();
287
+ this.#resetOriginalStyle();
288
288
  }
289
289
  for (const key in options.style) {
290
290
  if (!key || !(key in options.style)) {
@@ -297,44 +297,44 @@ export class CanvasManager {
297
297
  element.style.setProperty(key, value, "important");
298
298
  }
299
299
  };
300
- _repairStyle = () => {
300
+ #repairStyle = () => {
301
301
  const element = this.domElement;
302
302
  if (!element) {
303
303
  return;
304
304
  }
305
- this._safeMutationObserver(observer => {
305
+ this.#safeMutationObserver(observer => {
306
306
  observer.disconnect();
307
307
  });
308
- this._initStyle();
308
+ this.#initStyle();
309
309
  this.initBackground();
310
- const pointerEvents = this._pointerEvents;
310
+ const pointerEvents = this.#pointerEvents;
311
311
  element.style.pointerEvents = pointerEvents;
312
312
  element.style.setProperty("pointer-events", pointerEvents);
313
- this._safeMutationObserver(observer => {
313
+ this.#safeMutationObserver(observer => {
314
314
  if (!(element instanceof Node)) {
315
315
  return;
316
316
  }
317
317
  observer.observe(element, { attributes: true });
318
318
  });
319
319
  };
320
- _resetOriginalStyle = () => {
321
- const element = this.domElement, originalStyle = this._originalStyle;
320
+ #resetOriginalStyle = () => {
321
+ const element = this.domElement, originalStyle = this.#originalStyle;
322
322
  if (!element || !originalStyle) {
323
323
  return;
324
324
  }
325
325
  setStyle(element, originalStyle, true);
326
326
  };
327
- _safeMutationObserver = callback => {
328
- if (!this._mutationObserver) {
327
+ #safeMutationObserver = callback => {
328
+ if (!this.#mutationObserver) {
329
329
  return;
330
330
  }
331
- callback(this._mutationObserver);
331
+ callback(this.#mutationObserver);
332
332
  };
333
- _setFullScreenStyle = () => {
333
+ #setFullScreenStyle = () => {
334
334
  const element = this.domElement;
335
335
  if (!element) {
336
336
  return;
337
337
  }
338
- setStyle(element, getFullScreenStyle(this._container.actualOptions.fullScreen.zIndex), true);
338
+ setStyle(element, getFullScreenStyle(this.#container.actualOptions.fullScreen.zIndex), true);
339
339
  };
340
340
  }
@@ -39,73 +39,73 @@ export class Container {
39
39
  shapeDrawers;
40
40
  started;
41
41
  zLayers;
42
- _delay;
43
- _delayTimeout;
44
- _delta = { value: 0, factor: 0 };
45
- _dispatchCallback;
46
- _drawAnimationFrame;
47
- _duration;
48
- _eventListeners;
49
- _firstStart;
50
- _initialSourceOptions;
51
- _lastFrameTime;
52
- _lifeTime;
53
- _onDestroy;
54
- _options;
55
- _paused;
56
- _pluginManager;
57
- _smooth;
58
- _sourceOptions;
42
+ #delay;
43
+ #delayTimeout;
44
+ #delta = { value: 0, factor: 0 };
45
+ #dispatchCallback;
46
+ #drawAnimationFrame;
47
+ #duration;
48
+ #eventListeners;
49
+ #firstStart;
50
+ #initialSourceOptions;
51
+ #lastFrameTime;
52
+ #lifeTime;
53
+ #onDestroy;
54
+ #options;
55
+ #paused;
56
+ #pluginManager;
57
+ #smooth;
58
+ #sourceOptions;
59
59
  constructor(params) {
60
60
  const { dispatchCallback, pluginManager, id, onDestroy, sourceOptions } = params;
61
- this._pluginManager = pluginManager;
62
- this._dispatchCallback = dispatchCallback;
63
- this._onDestroy = onDestroy;
61
+ this.#pluginManager = pluginManager;
62
+ this.#dispatchCallback = dispatchCallback;
63
+ this.#onDestroy = onDestroy;
64
64
  this.id = Symbol(id);
65
65
  this.fpsLimit = 120;
66
66
  this.hdr = false;
67
- this._smooth = false;
68
- this._delay = 0;
69
- this._duration = 0;
70
- this._lifeTime = 0;
71
- this._firstStart = true;
67
+ this.#smooth = false;
68
+ this.#delay = 0;
69
+ this.#duration = 0;
70
+ this.#lifeTime = 0;
71
+ this.#firstStart = true;
72
72
  this.started = false;
73
73
  this.destroyed = false;
74
- this._paused = true;
75
- this._lastFrameTime = 0;
74
+ this.#paused = true;
75
+ this.#lastFrameTime = 0;
76
76
  this.zLayers = 100;
77
77
  this.pageHidden = false;
78
- this._sourceOptions = sourceOptions;
79
- this._initialSourceOptions = sourceOptions;
78
+ this.#sourceOptions = sourceOptions;
79
+ this.#initialSourceOptions = sourceOptions;
80
80
  this.effectDrawers = new Map();
81
81
  this.shapeDrawers = new Map();
82
82
  this.particleUpdaters = [];
83
83
  this.retina = new Retina(this);
84
- this.canvas = new CanvasManager(this._pluginManager, this);
85
- this.particles = new ParticlesManager(this._pluginManager, this);
84
+ this.canvas = new CanvasManager(this.#pluginManager, this);
85
+ this.particles = new ParticlesManager(this.#pluginManager, this);
86
86
  this.plugins = [];
87
87
  this.particleDestroyedPlugins = [];
88
88
  this.particleCreatedPlugins = [];
89
89
  this.particlePositionPlugins = [];
90
- this._options = loadContainerOptions(this._pluginManager, this);
91
- this.actualOptions = loadContainerOptions(this._pluginManager, this);
92
- this._eventListeners = new EventListeners(this);
90
+ this.#options = loadContainerOptions(this.#pluginManager, this);
91
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this);
92
+ this.#eventListeners = new EventListeners(this);
93
93
  this.dispatchEvent(EventType.containerBuilt);
94
94
  }
95
95
  get animationStatus() {
96
- return !this._paused && !this.pageHidden && guardCheck(this);
96
+ return !this.#paused && !this.pageHidden && guardCheck(this);
97
97
  }
98
98
  get options() {
99
- return this._options;
99
+ return this.#options;
100
100
  }
101
101
  get sourceOptions() {
102
- return this._sourceOptions;
102
+ return this.#sourceOptions;
103
103
  }
104
104
  addLifeTime(value) {
105
- this._lifeTime += value;
105
+ this.#lifeTime += value;
106
106
  }
107
107
  alive() {
108
- return !this._duration || this._lifeTime <= this._duration;
108
+ return !this.#duration || this.#lifeTime <= this.#duration;
109
109
  }
110
110
  destroy(remove = true) {
111
111
  if (!guardCheck(this)) {
@@ -127,13 +127,13 @@ export class Container {
127
127
  this.shapeDrawers = new Map();
128
128
  this.particleUpdaters = [];
129
129
  this.plugins.length = 0;
130
- this._pluginManager.clearPlugins(this);
130
+ this.#pluginManager.clearPlugins(this);
131
131
  this.destroyed = true;
132
- this._onDestroy(remove);
132
+ this.#onDestroy(remove);
133
133
  this.dispatchEvent(EventType.containerDestroyed);
134
134
  }
135
135
  dispatchEvent(type, data) {
136
- this._dispatchCallback(type, {
136
+ this.#dispatchCallback(type, {
137
137
  container: this,
138
138
  data,
139
139
  });
@@ -143,12 +143,12 @@ export class Container {
143
143
  return;
144
144
  }
145
145
  let refreshTime = force;
146
- this._drawAnimationFrame = animate((timestamp) => {
146
+ this.#drawAnimationFrame = animate((timestamp) => {
147
147
  if (refreshTime) {
148
- this._lastFrameTime = undefined;
148
+ this.#lastFrameTime = undefined;
149
149
  refreshTime = false;
150
150
  }
151
- this._nextFrame(timestamp);
151
+ this.#nextFrame(timestamp);
152
152
  });
153
153
  }
154
154
  async export(type, options = {}) {
@@ -170,7 +170,7 @@ export class Container {
170
170
  return;
171
171
  }
172
172
  const allContainerPlugins = new Map();
173
- for (const plugin of this._pluginManager.plugins) {
173
+ for (const plugin of this.#pluginManager.plugins) {
174
174
  const containerPlugin = await plugin.getPlugin(this);
175
175
  if (containerPlugin.preInit) {
176
176
  await containerPlugin.preInit();
@@ -178,8 +178,8 @@ export class Container {
178
178
  allContainerPlugins.set(plugin, containerPlugin);
179
179
  }
180
180
  await this.initDrawersAndUpdaters();
181
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
182
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
181
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
182
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
183
183
  this.plugins.length = 0;
184
184
  this.particleDestroyedPlugins.length = 0;
185
185
  this.particleCreatedPlugins.length = 0;
@@ -206,11 +206,11 @@ export class Container {
206
206
  const { delay, duration, fpsLimit, hdr, smooth, zLayers } = this.actualOptions;
207
207
  this.hdr = hdr;
208
208
  this.zLayers = zLayers;
209
- this._duration = getRangeValue(duration) * millisecondsToSeconds;
210
- this._delay = getRangeValue(delay) * millisecondsToSeconds;
211
- this._lifeTime = 0;
209
+ this.#duration = getRangeValue(duration) * millisecondsToSeconds;
210
+ this.#delay = getRangeValue(delay) * millisecondsToSeconds;
211
+ this.#lifeTime = 0;
212
212
  this.fpsLimit = fpsLimit > minFpsLimit ? fpsLimit : defaultFpsLimit;
213
- this._smooth = smooth;
213
+ this.#smooth = smooth;
214
214
  for (const plugin of this.plugins) {
215
215
  await plugin.init?.();
216
216
  }
@@ -223,7 +223,7 @@ export class Container {
223
223
  this.dispatchEvent(EventType.particlesSetup);
224
224
  }
225
225
  async initDrawersAndUpdaters() {
226
- const pluginManager = this._pluginManager;
226
+ const pluginManager = this.#pluginManager;
227
227
  this.effectDrawers = await pluginManager.getEffectDrawers(this, true);
228
228
  this.shapeDrawers = await pluginManager.getShapeDrawers(this, true);
229
229
  this.particleUpdaters = await pluginManager.getUpdaters(this, true);
@@ -232,18 +232,18 @@ export class Container {
232
232
  if (!guardCheck(this)) {
233
233
  return;
234
234
  }
235
- if (this._drawAnimationFrame !== undefined) {
236
- cancelAnimation(this._drawAnimationFrame);
237
- delete this._drawAnimationFrame;
235
+ if (this.#drawAnimationFrame !== undefined) {
236
+ cancelAnimation(this.#drawAnimationFrame);
237
+ this.#drawAnimationFrame = undefined;
238
238
  }
239
- if (this._paused) {
239
+ if (this.#paused) {
240
240
  return;
241
241
  }
242
242
  for (const plugin of this.plugins) {
243
243
  plugin.pause?.();
244
244
  }
245
245
  if (!this.pageHidden) {
246
- this._paused = true;
246
+ this.#paused = true;
247
247
  }
248
248
  this.dispatchEvent(EventType.containerPaused);
249
249
  }
@@ -251,13 +251,13 @@ export class Container {
251
251
  if (!guardCheck(this)) {
252
252
  return;
253
253
  }
254
- const needsUpdate = this._paused || force;
255
- if (this._firstStart && !this.actualOptions.autoPlay) {
256
- this._firstStart = false;
254
+ const needsUpdate = this.#paused || force;
255
+ if (this.#firstStart && !this.actualOptions.autoPlay) {
256
+ this.#firstStart = false;
257
257
  return;
258
258
  }
259
- if (this._paused) {
260
- this._paused = false;
259
+ if (this.#paused) {
260
+ this.#paused = false;
261
261
  }
262
262
  if (needsUpdate) {
263
263
  for (const plugin of this.plugins) {
@@ -280,10 +280,10 @@ export class Container {
280
280
  if (!guardCheck(this)) {
281
281
  return;
282
282
  }
283
- this._initialSourceOptions = sourceOptions;
284
- this._sourceOptions = sourceOptions;
285
- this._options = loadContainerOptions(this._pluginManager, this, this._initialSourceOptions, this.sourceOptions);
286
- this.actualOptions = loadContainerOptions(this._pluginManager, this, this._options);
283
+ this.#initialSourceOptions = sourceOptions;
284
+ this.#sourceOptions = sourceOptions;
285
+ this.#options = loadContainerOptions(this.#pluginManager, this, this.#initialSourceOptions, this.sourceOptions);
286
+ this.actualOptions = loadContainerOptions(this.#pluginManager, this, this.#options);
287
287
  return this.refresh();
288
288
  }
289
289
  async start() {
@@ -294,7 +294,7 @@ export class Container {
294
294
  this.started = true;
295
295
  await new Promise(resolve => {
296
296
  const start = async () => {
297
- this._eventListeners.addListeners();
297
+ this.#eventListeners.addListeners();
298
298
  for (const plugin of this.plugins) {
299
299
  await plugin.start?.();
300
300
  }
@@ -302,20 +302,20 @@ export class Container {
302
302
  this.play();
303
303
  resolve();
304
304
  };
305
- this._delayTimeout = setTimeout(() => void start(), this._delay);
305
+ this.#delayTimeout = setTimeout(() => void start(), this.#delay);
306
306
  });
307
307
  }
308
308
  stop() {
309
309
  if (!guardCheck(this) || !this.started) {
310
310
  return;
311
311
  }
312
- if (this._delayTimeout) {
313
- clearTimeout(this._delayTimeout);
314
- delete this._delayTimeout;
312
+ if (this.#delayTimeout) {
313
+ clearTimeout(this.#delayTimeout);
314
+ this.#delayTimeout = undefined;
315
315
  }
316
- this._firstStart = true;
316
+ this.#firstStart = true;
317
317
  this.started = false;
318
- this._eventListeners.removeListeners();
318
+ this.#eventListeners.removeListeners();
319
319
  this.pause();
320
320
  this.particles.clear();
321
321
  this.canvas.stop();
@@ -325,7 +325,7 @@ export class Container {
325
325
  this.particleCreatedPlugins.length = 0;
326
326
  this.particleDestroyedPlugins.length = 0;
327
327
  this.particlePositionPlugins.length = 0;
328
- this._sourceOptions = this._options;
328
+ this.#sourceOptions = this.#options;
329
329
  this.dispatchEvent(EventType.containerStopped);
330
330
  }
331
331
  updateActualOptions() {
@@ -337,23 +337,23 @@ export class Container {
337
337
  }
338
338
  return refresh;
339
339
  }
340
- _nextFrame = (timestamp) => {
340
+ #nextFrame = (timestamp) => {
341
341
  try {
342
- if (!this._smooth &&
343
- this._lastFrameTime !== undefined &&
344
- timestamp < this._lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
342
+ if (!this.#smooth &&
343
+ this.#lastFrameTime !== undefined &&
344
+ timestamp < this.#lastFrameTime + millisecondsToSeconds / this.fpsLimit) {
345
345
  this.draw(false);
346
346
  return;
347
347
  }
348
- this._lastFrameTime ??= timestamp;
349
- updateDelta(this._delta, timestamp - this._lastFrameTime, this.fpsLimit, this._smooth);
350
- this.addLifeTime(this._delta.value);
351
- this._lastFrameTime = timestamp;
352
- if (this._delta.value > millisecondsToSeconds) {
348
+ this.#lastFrameTime ??= timestamp;
349
+ updateDelta(this.#delta, timestamp - this.#lastFrameTime, this.fpsLimit, this.#smooth);
350
+ this.addLifeTime(this.#delta.value);
351
+ this.#lastFrameTime = timestamp;
352
+ if (this.#delta.value > millisecondsToSeconds) {
353
353
  this.draw(false);
354
354
  return;
355
355
  }
356
- this.canvas.render.drawParticles(this._delta);
356
+ this.canvas.render.drawParticles(this.#delta);
357
357
  if (!this.alive()) {
358
358
  this.destroy();
359
359
  return;