@tsparticles/plugin-emitters 3.2.2 → 3.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.
Files changed (51) hide show
  1. package/browser/EmitterInstance.js +11 -11
  2. package/browser/Emitters.js +8 -5
  3. package/browser/EmittersPlugin.js +8 -7
  4. package/browser/Enums/EmitterClickMode.js +4 -1
  5. package/browser/Options/Classes/Emitter.js +1 -1
  6. package/browser/Options/Classes/EmitterSize.js +2 -1
  7. package/browser/index.js +3 -2
  8. package/cjs/EmitterInstance.js +10 -10
  9. package/cjs/Emitters.js +9 -29
  10. package/cjs/EmittersPlugin.js +8 -30
  11. package/cjs/Enums/EmitterClickMode.js +5 -0
  12. package/cjs/Options/Classes/Emitter.js +1 -1
  13. package/cjs/Options/Classes/EmitterSize.js +2 -1
  14. package/cjs/index.js +4 -15
  15. package/esm/EmitterInstance.js +11 -11
  16. package/esm/Emitters.js +8 -5
  17. package/esm/EmittersPlugin.js +8 -7
  18. package/esm/Enums/EmitterClickMode.js +4 -1
  19. package/esm/Options/Classes/Emitter.js +1 -1
  20. package/esm/Options/Classes/EmitterSize.js +2 -1
  21. package/esm/index.js +3 -2
  22. package/package.json +2 -2
  23. package/report.html +1 -1
  24. package/tsparticles.plugin.emitters.js +112 -200
  25. package/tsparticles.plugin.emitters.min.js +1 -1
  26. package/tsparticles.plugin.emitters.min.js.LICENSE.txt +1 -1
  27. package/types/EmitterInstance.d.ts +1 -1
  28. package/types/EmitterShapeBase.d.ts +1 -1
  29. package/types/Emitters.d.ts +3 -3
  30. package/types/EmittersPlugin.d.ts +1 -1
  31. package/types/Enums/EmitterClickMode.d.ts +1 -1
  32. package/types/IEmitterShape.d.ts +1 -1
  33. package/umd/EmitterInstance.js +10 -10
  34. package/umd/Emitters.js +10 -31
  35. package/umd/EmittersPlugin.js +9 -32
  36. package/umd/Enums/EmitterClickMode.js +5 -0
  37. package/umd/Options/Classes/Emitter.js +1 -1
  38. package/umd/Options/Classes/EmitterSize.js +3 -2
  39. package/umd/index.js +5 -17
  40. package/113.min.js +0 -2
  41. package/113.min.js.LICENSE.txt +0 -1
  42. package/927.min.js +0 -2
  43. package/927.min.js.LICENSE.txt +0 -1
  44. package/964.min.js +0 -2
  45. package/964.min.js.LICENSE.txt +0 -1
  46. package/973.min.js +0 -2
  47. package/973.min.js.LICENSE.txt +0 -1
  48. package/dist_browser_EmitterInstance_js.js +0 -30
  49. package/dist_browser_EmittersPlugin_js.js +0 -90
  50. package/dist_browser_Emitters_js.js +0 -30
  51. package/dist_browser_ShapeManager_js.js +0 -30
@@ -1,4 +1,4 @@
1
- import { Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
1
+ import { PixelMode, Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
2
2
  import { Emitter } from "./Options/Classes/Emitter.js";
3
3
  import { EmitterSize } from "./Options/Classes/EmitterSize.js";
4
4
  const half = 0.5, defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1;
@@ -154,7 +154,7 @@ export class EmitterInstance {
154
154
  this.size = getSize(this._size, this.container.canvas.size);
155
155
  this._shape?.resize(this.position, this.size);
156
156
  }
157
- async update(delta) {
157
+ update(delta) {
158
158
  if (this._paused) {
159
159
  return;
160
160
  }
@@ -165,7 +165,7 @@ export class EmitterInstance {
165
165
  }
166
166
  if (!this._startParticlesAdded) {
167
167
  this._startParticlesAdded = true;
168
- await this._emitParticles(this.options.startCount);
168
+ this._emitParticles(this.options.startCount);
169
169
  }
170
170
  if (this._duration !== undefined) {
171
171
  this._currentDuration += delta.value;
@@ -205,7 +205,7 @@ export class EmitterInstance {
205
205
  if (this._emitDelay !== undefined) {
206
206
  this._currentEmitDelay += delta.value;
207
207
  if (this._currentEmitDelay >= this._emitDelay) {
208
- await this._emit();
208
+ this._emit();
209
209
  this._currentEmitDelay -= this._emitDelay;
210
210
  }
211
211
  }
@@ -235,7 +235,7 @@ export class EmitterInstance {
235
235
  return {
236
236
  width: elRect.width * container.retina.pixelRatio,
237
237
  height: elRect.height * container.retina.pixelRatio,
238
- mode: "precise",
238
+ mode: PixelMode.precise,
239
239
  };
240
240
  }
241
241
  }
@@ -244,20 +244,20 @@ export class EmitterInstance {
244
244
  const size = new EmitterSize();
245
245
  size.load({
246
246
  height: 0,
247
- mode: "percent",
247
+ mode: PixelMode.percent,
248
248
  width: 0,
249
249
  });
250
250
  return size;
251
251
  })());
252
252
  }
253
- async _emit() {
253
+ _emit() {
254
254
  if (this._paused) {
255
255
  return;
256
256
  }
257
257
  const quantity = getRangeValue(this.options.rate.quantity);
258
- await this._emitParticles(quantity);
258
+ this._emitParticles(quantity);
259
259
  }
260
- async _emitParticles(quantity) {
260
+ _emitParticles(quantity) {
261
261
  const singleParticlesOptions = itemFromSingleOrMultiple(this._particlesOptions);
262
262
  for (let i = 0; i < quantity; i++) {
263
263
  const particlesOptions = deepExtend({}, singleParticlesOptions);
@@ -278,7 +278,7 @@ export class EmitterInstance {
278
278
  const shapeOptions = this.options.shape;
279
279
  let position = this.position;
280
280
  if (this._shape) {
281
- const shapePosData = await this._shape.randomPosition();
281
+ const shapePosData = this._shape.randomPosition();
282
282
  if (shapePosData) {
283
283
  position = shapePosData.position;
284
284
  const replaceData = shapeOptions.replace;
@@ -301,7 +301,7 @@ export class EmitterInstance {
301
301
  }
302
302
  }
303
303
  if (position) {
304
- await this.container.particles.addParticle(position, particlesOptions);
304
+ this.container.particles.addParticle(position, particlesOptions);
305
305
  }
306
306
  }
307
307
  }
@@ -1,4 +1,7 @@
1
1
  import { arrayRandomIndex, executeOnSingleOrMultiple, isArray, isNumber, itemFromArray, } from "@tsparticles/engine";
2
+ import { Emitter } from "./Options/Classes/Emitter.js";
3
+ import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
4
+ import { EmitterInstance } from "./EmitterInstance.js";
2
5
  export class Emitters {
3
6
  constructor(engine, container) {
4
7
  this.container = container;
@@ -15,7 +18,7 @@ export class Emitters {
15
18
  const defaultIndex = 0;
16
19
  container.getEmitter = (idxOrName) => idxOrName === undefined || isNumber(idxOrName)
17
20
  ? this.array[idxOrName ?? defaultIndex]
18
- : this.array.find((t) => t.name === idxOrName);
21
+ : this.array.find(t => t.name === idxOrName);
19
22
  container.addEmitter = async (options, position) => this.addEmitter(options, position);
20
23
  container.removeEmitter = (idxOrName) => {
21
24
  const emitter = container.getEmitter(idxOrName);
@@ -37,7 +40,7 @@ export class Emitters {
37
40
  };
38
41
  }
39
42
  async addEmitter(options, position) {
40
- const { Emitter } = await import("./Options/Classes/Emitter.js"), { EmitterInstance } = await import("./EmitterInstance.js"), emitterOptions = new Emitter();
43
+ const emitterOptions = new Emitter();
41
44
  emitterOptions.load(options);
42
45
  const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
43
46
  await emitter.init();
@@ -46,7 +49,7 @@ export class Emitters {
46
49
  }
47
50
  handleClickMode(mode) {
48
51
  const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
49
- if (mode !== "emitter") {
52
+ if (mode !== EmitterClickMode.emitter) {
50
53
  return;
51
54
  }
52
55
  let emittersModeOptions;
@@ -116,9 +119,9 @@ export class Emitters {
116
119
  stop() {
117
120
  this.array = [];
118
121
  }
119
- async update(delta) {
122
+ update(delta) {
120
123
  for (const emitter of this.array) {
121
- await emitter.update(delta);
124
+ emitter.update(delta);
122
125
  }
123
126
  }
124
127
  }
@@ -1,20 +1,21 @@
1
1
  import { executeOnSingleOrMultiple, isArray, isInArray, } from "@tsparticles/engine";
2
2
  import { Emitter } from "./Options/Classes/Emitter.js";
3
+ import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
4
+ import { Emitters } from "./Emitters.js";
3
5
  export class EmittersPlugin {
4
6
  constructor(engine) {
5
7
  this._engine = engine;
6
8
  this.id = "emitters";
7
9
  }
8
- async getPlugin(container) {
9
- const { Emitters } = await import("./Emitters.js");
10
- return new Emitters(this._engine, container);
10
+ getPlugin(container) {
11
+ return Promise.resolve(new Emitters(this._engine, container));
11
12
  }
12
13
  loadOptions(options, source) {
13
14
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
14
15
  return;
15
16
  }
16
17
  if (source?.emitters) {
17
- options.emitters = executeOnSingleOrMultiple(source.emitters, (emitter) => {
18
+ options.emitters = executeOnSingleOrMultiple(source.emitters, emitter => {
18
19
  const tmp = new Emitter();
19
20
  tmp.load(emitter);
20
21
  return tmp;
@@ -28,7 +29,7 @@ export class EmittersPlugin {
28
29
  count: 1,
29
30
  enable: true,
30
31
  },
31
- value: interactivityEmitters.map((s) => {
32
+ value: interactivityEmitters.map(s => {
32
33
  const tmp = new Emitter();
33
34
  tmp.load(s);
34
35
  return tmp;
@@ -45,7 +46,7 @@ export class EmittersPlugin {
45
46
  count: emitterMode.random.count ?? defaultCount,
46
47
  enable: emitterMode.random.enable ?? false,
47
48
  },
48
- value: emitterMode.value.map((s) => {
49
+ value: emitterMode.value.map(s => {
49
50
  const tmp = new Emitter();
50
51
  tmp.load(s);
51
52
  return tmp;
@@ -85,6 +86,6 @@ export class EmittersPlugin {
85
86
  return ((isArray(emitters) && !!emitters.length) ||
86
87
  emitters !== undefined ||
87
88
  (!!options.interactivity?.events?.onClick?.mode &&
88
- isInArray("emitter", options.interactivity.events.onClick.mode)));
89
+ isInArray(EmitterClickMode.emitter, options.interactivity.events.onClick.mode)));
89
90
  }
90
91
  }
@@ -1 +1,4 @@
1
- export {};
1
+ export var EmitterClickMode;
2
+ (function (EmitterClickMode) {
3
+ EmitterClickMode["emitter"] = "emitter";
4
+ })(EmitterClickMode || (EmitterClickMode = {}));
@@ -34,7 +34,7 @@ export class Emitter {
34
34
  }
35
35
  this.life.load(data.life);
36
36
  this.name = data.name;
37
- this.particles = executeOnSingleOrMultiple(data.particles, (particles) => {
37
+ this.particles = executeOnSingleOrMultiple(data.particles, particles => {
38
38
  return deepExtend({}, particles);
39
39
  });
40
40
  this.rate.load(data.rate);
@@ -1,6 +1,7 @@
1
+ import { PixelMode } from "@tsparticles/engine";
1
2
  export class EmitterSize {
2
3
  constructor() {
3
- this.mode = "percent";
4
+ this.mode = PixelMode.percent;
4
5
  this.height = 0;
5
6
  this.width = 0;
6
7
  }
package/browser/index.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { EmittersPlugin } from "./EmittersPlugin.js";
2
+ import { ShapeManager } from "./ShapeManager.js";
1
3
  export async function loadEmittersPlugin(engine, refresh = true) {
2
4
  if (!engine.emitterShapeManager) {
3
- const { ShapeManager } = await import("./ShapeManager.js");
4
5
  engine.emitterShapeManager = new ShapeManager(engine);
5
6
  }
6
7
  if (!engine.addEmitterShapeGenerator) {
@@ -8,7 +9,7 @@ export async function loadEmittersPlugin(engine, refresh = true) {
8
9
  engine.emitterShapeManager?.addShapeGenerator(name, generator);
9
10
  };
10
11
  }
11
- const { EmittersPlugin } = await import("./EmittersPlugin.js"), plugin = new EmittersPlugin(engine);
12
+ const plugin = new EmittersPlugin(engine);
12
13
  await engine.addPlugin(plugin, refresh);
13
14
  }
14
15
  export * from "./EmitterContainer.js";
@@ -157,7 +157,7 @@ class EmitterInstance {
157
157
  this.size = (0, engine_1.getSize)(this._size, this.container.canvas.size);
158
158
  this._shape?.resize(this.position, this.size);
159
159
  }
160
- async update(delta) {
160
+ update(delta) {
161
161
  if (this._paused) {
162
162
  return;
163
163
  }
@@ -168,7 +168,7 @@ class EmitterInstance {
168
168
  }
169
169
  if (!this._startParticlesAdded) {
170
170
  this._startParticlesAdded = true;
171
- await this._emitParticles(this.options.startCount);
171
+ this._emitParticles(this.options.startCount);
172
172
  }
173
173
  if (this._duration !== undefined) {
174
174
  this._currentDuration += delta.value;
@@ -208,7 +208,7 @@ class EmitterInstance {
208
208
  if (this._emitDelay !== undefined) {
209
209
  this._currentEmitDelay += delta.value;
210
210
  if (this._currentEmitDelay >= this._emitDelay) {
211
- await this._emit();
211
+ this._emit();
212
212
  this._currentEmitDelay -= this._emitDelay;
213
213
  }
214
214
  }
@@ -238,7 +238,7 @@ class EmitterInstance {
238
238
  return {
239
239
  width: elRect.width * container.retina.pixelRatio,
240
240
  height: elRect.height * container.retina.pixelRatio,
241
- mode: "precise",
241
+ mode: engine_1.PixelMode.precise,
242
242
  };
243
243
  }
244
244
  }
@@ -247,20 +247,20 @@ class EmitterInstance {
247
247
  const size = new EmitterSize_js_1.EmitterSize();
248
248
  size.load({
249
249
  height: 0,
250
- mode: "percent",
250
+ mode: engine_1.PixelMode.percent,
251
251
  width: 0,
252
252
  });
253
253
  return size;
254
254
  })());
255
255
  }
256
- async _emit() {
256
+ _emit() {
257
257
  if (this._paused) {
258
258
  return;
259
259
  }
260
260
  const quantity = (0, engine_1.getRangeValue)(this.options.rate.quantity);
261
- await this._emitParticles(quantity);
261
+ this._emitParticles(quantity);
262
262
  }
263
- async _emitParticles(quantity) {
263
+ _emitParticles(quantity) {
264
264
  const singleParticlesOptions = (0, engine_1.itemFromSingleOrMultiple)(this._particlesOptions);
265
265
  for (let i = 0; i < quantity; i++) {
266
266
  const particlesOptions = (0, engine_1.deepExtend)({}, singleParticlesOptions);
@@ -281,7 +281,7 @@ class EmitterInstance {
281
281
  const shapeOptions = this.options.shape;
282
282
  let position = this.position;
283
283
  if (this._shape) {
284
- const shapePosData = await this._shape.randomPosition();
284
+ const shapePosData = this._shape.randomPosition();
285
285
  if (shapePosData) {
286
286
  position = shapePosData.position;
287
287
  const replaceData = shapeOptions.replace;
@@ -304,7 +304,7 @@ class EmitterInstance {
304
304
  }
305
305
  }
306
306
  if (position) {
307
- await this.container.particles.addParticle(position, particlesOptions);
307
+ this.container.particles.addParticle(position, particlesOptions);
308
308
  }
309
309
  }
310
310
  }
package/cjs/Emitters.js CHANGED
@@ -1,30 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.Emitters = void 0;
27
4
  const engine_1 = require("@tsparticles/engine");
5
+ const Emitter_js_1 = require("./Options/Classes/Emitter.js");
6
+ const EmitterClickMode_js_1 = require("./Enums/EmitterClickMode.js");
7
+ const EmitterInstance_js_1 = require("./EmitterInstance.js");
28
8
  class Emitters {
29
9
  constructor(engine, container) {
30
10
  this.container = container;
@@ -41,7 +21,7 @@ class Emitters {
41
21
  const defaultIndex = 0;
42
22
  container.getEmitter = (idxOrName) => idxOrName === undefined || (0, engine_1.isNumber)(idxOrName)
43
23
  ? this.array[idxOrName ?? defaultIndex]
44
- : this.array.find((t) => t.name === idxOrName);
24
+ : this.array.find(t => t.name === idxOrName);
45
25
  container.addEmitter = async (options, position) => this.addEmitter(options, position);
46
26
  container.removeEmitter = (idxOrName) => {
47
27
  const emitter = container.getEmitter(idxOrName);
@@ -63,16 +43,16 @@ class Emitters {
63
43
  };
64
44
  }
65
45
  async addEmitter(options, position) {
66
- const { Emitter } = await Promise.resolve().then(() => __importStar(require("./Options/Classes/Emitter.js"))), { EmitterInstance } = await Promise.resolve().then(() => __importStar(require("./EmitterInstance.js"))), emitterOptions = new Emitter();
46
+ const emitterOptions = new Emitter_js_1.Emitter();
67
47
  emitterOptions.load(options);
68
- const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
48
+ const emitter = new EmitterInstance_js_1.EmitterInstance(this._engine, this, this.container, emitterOptions, position);
69
49
  await emitter.init();
70
50
  this.array.push(emitter);
71
51
  return emitter;
72
52
  }
73
53
  handleClickMode(mode) {
74
54
  const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
75
- if (mode !== "emitter") {
55
+ if (mode !== EmitterClickMode_js_1.EmitterClickMode.emitter) {
76
56
  return;
77
57
  }
78
58
  let emittersModeOptions;
@@ -142,9 +122,9 @@ class Emitters {
142
122
  stop() {
143
123
  this.array = [];
144
124
  }
145
- async update(delta) {
125
+ update(delta) {
146
126
  for (const emitter of this.array) {
147
- await emitter.update(delta);
127
+ emitter.update(delta);
148
128
  }
149
129
  }
150
130
  }
@@ -1,46 +1,24 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.EmittersPlugin = void 0;
27
4
  const engine_1 = require("@tsparticles/engine");
28
5
  const Emitter_js_1 = require("./Options/Classes/Emitter.js");
6
+ const EmitterClickMode_js_1 = require("./Enums/EmitterClickMode.js");
7
+ const Emitters_js_1 = require("./Emitters.js");
29
8
  class EmittersPlugin {
30
9
  constructor(engine) {
31
10
  this._engine = engine;
32
11
  this.id = "emitters";
33
12
  }
34
- async getPlugin(container) {
35
- const { Emitters } = await Promise.resolve().then(() => __importStar(require("./Emitters.js")));
36
- return new Emitters(this._engine, container);
13
+ getPlugin(container) {
14
+ return Promise.resolve(new Emitters_js_1.Emitters(this._engine, container));
37
15
  }
38
16
  loadOptions(options, source) {
39
17
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
40
18
  return;
41
19
  }
42
20
  if (source?.emitters) {
43
- options.emitters = (0, engine_1.executeOnSingleOrMultiple)(source.emitters, (emitter) => {
21
+ options.emitters = (0, engine_1.executeOnSingleOrMultiple)(source.emitters, emitter => {
44
22
  const tmp = new Emitter_js_1.Emitter();
45
23
  tmp.load(emitter);
46
24
  return tmp;
@@ -54,7 +32,7 @@ class EmittersPlugin {
54
32
  count: 1,
55
33
  enable: true,
56
34
  },
57
- value: interactivityEmitters.map((s) => {
35
+ value: interactivityEmitters.map(s => {
58
36
  const tmp = new Emitter_js_1.Emitter();
59
37
  tmp.load(s);
60
38
  return tmp;
@@ -71,7 +49,7 @@ class EmittersPlugin {
71
49
  count: emitterMode.random.count ?? defaultCount,
72
50
  enable: emitterMode.random.enable ?? false,
73
51
  },
74
- value: emitterMode.value.map((s) => {
52
+ value: emitterMode.value.map(s => {
75
53
  const tmp = new Emitter_js_1.Emitter();
76
54
  tmp.load(s);
77
55
  return tmp;
@@ -111,7 +89,7 @@ class EmittersPlugin {
111
89
  return (((0, engine_1.isArray)(emitters) && !!emitters.length) ||
112
90
  emitters !== undefined ||
113
91
  (!!options.interactivity?.events?.onClick?.mode &&
114
- (0, engine_1.isInArray)("emitter", options.interactivity.events.onClick.mode)));
92
+ (0, engine_1.isInArray)(EmitterClickMode_js_1.EmitterClickMode.emitter, options.interactivity.events.onClick.mode)));
115
93
  }
116
94
  }
117
95
  exports.EmittersPlugin = EmittersPlugin;
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EmitterClickMode = void 0;
4
+ var EmitterClickMode;
5
+ (function (EmitterClickMode) {
6
+ EmitterClickMode["emitter"] = "emitter";
7
+ })(EmitterClickMode || (exports.EmitterClickMode = EmitterClickMode = {}));
@@ -37,7 +37,7 @@ class Emitter {
37
37
  }
38
38
  this.life.load(data.life);
39
39
  this.name = data.name;
40
- this.particles = (0, engine_1.executeOnSingleOrMultiple)(data.particles, (particles) => {
40
+ this.particles = (0, engine_1.executeOnSingleOrMultiple)(data.particles, particles => {
41
41
  return (0, engine_1.deepExtend)({}, particles);
42
42
  });
43
43
  this.rate.load(data.rate);
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EmitterSize = void 0;
4
+ const engine_1 = require("@tsparticles/engine");
4
5
  class EmitterSize {
5
6
  constructor() {
6
- this.mode = "percent";
7
+ this.mode = engine_1.PixelMode.percent;
7
8
  this.height = 0;
8
9
  this.width = 0;
9
10
  }
package/cjs/index.js CHANGED
@@ -10,34 +10,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
17
  exports.loadEmittersPlugin = void 0;
18
+ const EmittersPlugin_js_1 = require("./EmittersPlugin.js");
19
+ const ShapeManager_js_1 = require("./ShapeManager.js");
30
20
  async function loadEmittersPlugin(engine, refresh = true) {
31
21
  if (!engine.emitterShapeManager) {
32
- const { ShapeManager } = await Promise.resolve().then(() => __importStar(require("./ShapeManager.js")));
33
- engine.emitterShapeManager = new ShapeManager(engine);
22
+ engine.emitterShapeManager = new ShapeManager_js_1.ShapeManager(engine);
34
23
  }
35
24
  if (!engine.addEmitterShapeGenerator) {
36
25
  engine.addEmitterShapeGenerator = (name, generator) => {
37
26
  engine.emitterShapeManager?.addShapeGenerator(name, generator);
38
27
  };
39
28
  }
40
- const { EmittersPlugin } = await Promise.resolve().then(() => __importStar(require("./EmittersPlugin.js"))), plugin = new EmittersPlugin(engine);
29
+ const plugin = new EmittersPlugin_js_1.EmittersPlugin(engine);
41
30
  await engine.addPlugin(plugin, refresh);
42
31
  }
43
32
  exports.loadEmittersPlugin = loadEmittersPlugin;
@@ -1,4 +1,4 @@
1
- import { Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
1
+ import { PixelMode, Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
2
2
  import { Emitter } from "./Options/Classes/Emitter.js";
3
3
  import { EmitterSize } from "./Options/Classes/EmitterSize.js";
4
4
  const half = 0.5, defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1;
@@ -154,7 +154,7 @@ export class EmitterInstance {
154
154
  this.size = getSize(this._size, this.container.canvas.size);
155
155
  this._shape?.resize(this.position, this.size);
156
156
  }
157
- async update(delta) {
157
+ update(delta) {
158
158
  if (this._paused) {
159
159
  return;
160
160
  }
@@ -165,7 +165,7 @@ export class EmitterInstance {
165
165
  }
166
166
  if (!this._startParticlesAdded) {
167
167
  this._startParticlesAdded = true;
168
- await this._emitParticles(this.options.startCount);
168
+ this._emitParticles(this.options.startCount);
169
169
  }
170
170
  if (this._duration !== undefined) {
171
171
  this._currentDuration += delta.value;
@@ -205,7 +205,7 @@ export class EmitterInstance {
205
205
  if (this._emitDelay !== undefined) {
206
206
  this._currentEmitDelay += delta.value;
207
207
  if (this._currentEmitDelay >= this._emitDelay) {
208
- await this._emit();
208
+ this._emit();
209
209
  this._currentEmitDelay -= this._emitDelay;
210
210
  }
211
211
  }
@@ -235,7 +235,7 @@ export class EmitterInstance {
235
235
  return {
236
236
  width: elRect.width * container.retina.pixelRatio,
237
237
  height: elRect.height * container.retina.pixelRatio,
238
- mode: "precise",
238
+ mode: PixelMode.precise,
239
239
  };
240
240
  }
241
241
  }
@@ -244,20 +244,20 @@ export class EmitterInstance {
244
244
  const size = new EmitterSize();
245
245
  size.load({
246
246
  height: 0,
247
- mode: "percent",
247
+ mode: PixelMode.percent,
248
248
  width: 0,
249
249
  });
250
250
  return size;
251
251
  })());
252
252
  }
253
- async _emit() {
253
+ _emit() {
254
254
  if (this._paused) {
255
255
  return;
256
256
  }
257
257
  const quantity = getRangeValue(this.options.rate.quantity);
258
- await this._emitParticles(quantity);
258
+ this._emitParticles(quantity);
259
259
  }
260
- async _emitParticles(quantity) {
260
+ _emitParticles(quantity) {
261
261
  const singleParticlesOptions = itemFromSingleOrMultiple(this._particlesOptions);
262
262
  for (let i = 0; i < quantity; i++) {
263
263
  const particlesOptions = deepExtend({}, singleParticlesOptions);
@@ -278,7 +278,7 @@ export class EmitterInstance {
278
278
  const shapeOptions = this.options.shape;
279
279
  let position = this.position;
280
280
  if (this._shape) {
281
- const shapePosData = await this._shape.randomPosition();
281
+ const shapePosData = this._shape.randomPosition();
282
282
  if (shapePosData) {
283
283
  position = shapePosData.position;
284
284
  const replaceData = shapeOptions.replace;
@@ -301,7 +301,7 @@ export class EmitterInstance {
301
301
  }
302
302
  }
303
303
  if (position) {
304
- await this.container.particles.addParticle(position, particlesOptions);
304
+ this.container.particles.addParticle(position, particlesOptions);
305
305
  }
306
306
  }
307
307
  }
package/esm/Emitters.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import { arrayRandomIndex, executeOnSingleOrMultiple, isArray, isNumber, itemFromArray, } from "@tsparticles/engine";
2
+ import { Emitter } from "./Options/Classes/Emitter.js";
3
+ import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
4
+ import { EmitterInstance } from "./EmitterInstance.js";
2
5
  export class Emitters {
3
6
  constructor(engine, container) {
4
7
  this.container = container;
@@ -15,7 +18,7 @@ export class Emitters {
15
18
  const defaultIndex = 0;
16
19
  container.getEmitter = (idxOrName) => idxOrName === undefined || isNumber(idxOrName)
17
20
  ? this.array[idxOrName ?? defaultIndex]
18
- : this.array.find((t) => t.name === idxOrName);
21
+ : this.array.find(t => t.name === idxOrName);
19
22
  container.addEmitter = async (options, position) => this.addEmitter(options, position);
20
23
  container.removeEmitter = (idxOrName) => {
21
24
  const emitter = container.getEmitter(idxOrName);
@@ -37,7 +40,7 @@ export class Emitters {
37
40
  };
38
41
  }
39
42
  async addEmitter(options, position) {
40
- const { Emitter } = await import("./Options/Classes/Emitter.js"), { EmitterInstance } = await import("./EmitterInstance.js"), emitterOptions = new Emitter();
43
+ const emitterOptions = new Emitter();
41
44
  emitterOptions.load(options);
42
45
  const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
43
46
  await emitter.init();
@@ -46,7 +49,7 @@ export class Emitters {
46
49
  }
47
50
  handleClickMode(mode) {
48
51
  const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
49
- if (mode !== "emitter") {
52
+ if (mode !== EmitterClickMode.emitter) {
50
53
  return;
51
54
  }
52
55
  let emittersModeOptions;
@@ -116,9 +119,9 @@ export class Emitters {
116
119
  stop() {
117
120
  this.array = [];
118
121
  }
119
- async update(delta) {
122
+ update(delta) {
120
123
  for (const emitter of this.array) {
121
- await emitter.update(delta);
124
+ emitter.update(delta);
122
125
  }
123
126
  }
124
127
  }