@tsparticles/plugin-emitters 4.0.0-beta.1 → 4.0.0-beta.2

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 (70) hide show
  1. package/410.min.js +1 -0
  2. package/49.min.js +1 -0
  3. package/592.min.js +1 -1
  4. package/764.min.js +1 -1
  5. package/browser/addEmittersShapesManager.js +7 -0
  6. package/browser/ensureEmittersPluginLoaded.js +5 -0
  7. package/browser/getEmittersInstancesManager.js +11 -0
  8. package/browser/index.js +5 -24
  9. package/browser/interaction.js +18 -0
  10. package/browser/plugin.js +14 -0
  11. package/cjs/addEmittersShapesManager.js +7 -0
  12. package/cjs/ensureEmittersPluginLoaded.js +5 -0
  13. package/cjs/getEmittersInstancesManager.js +11 -0
  14. package/cjs/index.js +5 -24
  15. package/cjs/interaction.js +18 -0
  16. package/cjs/plugin.js +14 -0
  17. package/dist_browser_EmitterInstance_js.js +1 -1
  18. package/dist_browser_EmittersInstancesManager_js.js +1 -1
  19. package/dist_browser_EmittersInteractor_js.js +1 -1
  20. package/dist_browser_EmittersPluginInstance_js.js +1 -1
  21. package/dist_browser_EmittersPlugin_js.js +1 -1
  22. package/dist_browser_ShapeManager_js.js +1 -1
  23. package/dist_browser_addEmittersShapesManager_js.js +30 -0
  24. package/dist_browser_getEmittersInstancesManager_js.js +30 -0
  25. package/esm/addEmittersShapesManager.js +7 -0
  26. package/esm/ensureEmittersPluginLoaded.js +5 -0
  27. package/esm/getEmittersInstancesManager.js +11 -0
  28. package/esm/index.js +5 -24
  29. package/esm/interaction.js +18 -0
  30. package/esm/plugin.js +14 -0
  31. package/package.json +22 -4
  32. package/report.html +1 -1
  33. package/tsparticles.plugin.emitters.js +32 -2
  34. package/tsparticles.plugin.emitters.min.js +2 -2
  35. package/types/addEmittersShapesManager.d.ts +2 -0
  36. package/types/ensureEmittersPluginLoaded.d.ts +2 -0
  37. package/types/getEmittersInstancesManager.d.ts +3 -0
  38. package/types/index.d.ts +1 -1
  39. package/types/interaction.d.ts +9 -0
  40. package/types/plugin.d.ts +9 -0
  41. package/umd/EmitterContainer.js +0 -12
  42. package/umd/EmitterInstance.js +0 -358
  43. package/umd/EmitterShapeBase.js +0 -30
  44. package/umd/EmittersEngine.js +0 -12
  45. package/umd/EmittersInstancesManager.js +0 -119
  46. package/umd/EmittersInteractor.js +0 -130
  47. package/umd/EmittersPlugin.js +0 -80
  48. package/umd/EmittersPluginInstance.js +0 -58
  49. package/umd/Enums/EmitterClickMode.js +0 -17
  50. package/umd/IEmitterShape.js +0 -12
  51. package/umd/IEmitterShapeGenerator.js +0 -12
  52. package/umd/IRandomPositionData.js +0 -12
  53. package/umd/Options/Classes/Emitter.js +0 -93
  54. package/umd/Options/Classes/EmitterLife.js +0 -41
  55. package/umd/Options/Classes/EmitterRate.js +0 -34
  56. package/umd/Options/Classes/EmitterShape.js +0 -38
  57. package/umd/Options/Classes/EmitterShapeReplace.js +0 -34
  58. package/umd/Options/Classes/EmitterSize.js +0 -39
  59. package/umd/Options/Classes/EmitterSpawn.js +0 -32
  60. package/umd/Options/Interfaces/IEmitter.js +0 -12
  61. package/umd/Options/Interfaces/IEmitterLife.js +0 -12
  62. package/umd/Options/Interfaces/IEmitterRate.js +0 -12
  63. package/umd/Options/Interfaces/IEmitterShape.js +0 -12
  64. package/umd/Options/Interfaces/IEmitterShapeReplace.js +0 -12
  65. package/umd/Options/Interfaces/IEmitterSize.js +0 -12
  66. package/umd/Options/Interfaces/IEmitterSpawn.js +0 -12
  67. package/umd/ShapeManager.js +0 -28
  68. package/umd/constants.js +0 -17
  69. package/umd/index.js +0 -79
  70. package/umd/types.js +0 -12
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-interactivity","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,n,o,a={303(e){e.exports=t},702(t){t.exports=e}},s={};function l(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return a[e](r,r.exports,l),r.exports}l.m=a,c=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);l.r(r);var i={};p=p||[null,c({}),c([]),c(c)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~p.indexOf(n);n=c(n))Object.getOwnPropertyNames(n).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,l.d(r,i),r},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>""+e+".min.js",l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u={},l.l=(e,t,r,i)=>{if(u[e])return void u[e].push(t);if(void 0!==r)for(var n,o,a=document.getElementsByTagName("script"),s=0;s<a.length;s++){var p=a[s];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/plugin-emitters:"+r){n=p;break}}n||(o=!0,(n=document.createElement("script")).charset="utf-8",l.nc&&n.setAttribute("nonce",l.nc),n.setAttribute("data-webpack","@tsparticles/plugin-emitters:"+r),n.src=e),u[e]=[t];var c=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var i=u[e];if(delete u[e],n.parentNode&&n.parentNode.removeChild(n),i&&i.forEach(e=>e(r)),t)return t(r)},d=setTimeout(c.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=c.bind(null,n.onerror),n.onload=c.bind(null,n.onload),o&&document.head.appendChild(n)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(d=l.g.location+"");var p,c,u,d,f=l.g.document;if(!d&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(d=f.currentScript.src),!d)){var h=f.getElementsByTagName("script");if(h.length)for(var g=h.length-1;g>-1&&(!d||!/^http(s?):/.test(d));)d=h[g--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");l.p=d=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={833:0},l.f.j=(e,t)=>{var i=l.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var n=new Promise((t,n)=>i=r[e]=[t,n]);t.push(i[2]=n);var o=l.p+l.u(e),a=Error();l.l(o,t=>{if(l.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
2
- (`+n+": "+o+")",a.name="ChunkLoadError",a.type=n,a.request=o,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,n,[o,a,s]=t,p=0;if(o.some(e=>0!==r[e])){for(i in a)l.o(a,i)&&(l.m[i]=a[i]);s&&s(l)}for(e&&e(t);p<o.length;p++)n=o[p],l.o(r,n)&&r[n]&&r[n][0](),r[n]=0},(n=this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).forEach(i.bind(null,0)),n.push=i.bind(null,n.push.bind(n));var m={};l.r(m),l.d(m,{EmitterClickMode:()=>o,EmitterShapeBase:()=>b,ensureEmittersPluginLoaded:()=>v,loadEmittersPlugin:()=>y});class b{fill;options;position;size;constructor(e,t,r,i){this.position=e,this.size=t,this.fill=r,this.options=i}resize(e,t){this.position=e,this.size=t}}async function y(e){e.checkVersion("4.0.0-beta.1"),await e.pluginManager.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{ShapeManager:r},{EmittersInstancesManager:i},{EmittersPlugin:n}]=await Promise.all([Promise.resolve().then(l.t.bind(l,702,19)),l.e(592).then(l.bind(l,592)),l.e(764).then(l.bind(l,764)),l.e(392).then(l.bind(l,392))]),o=e.pluginManager,a=new i(o);t(e),o.emitterShapeManager??=new r,o.addEmitterShapeGenerator??=(e,t)=>{o.emitterShapeManager?.addShapeGenerator(e,t)},o.addPlugin(new n(a)),o.addInteractor?.("externalEmitters",async e=>{let{EmittersInteractor:t}=await l.e(414).then(l.bind(l,414));return new t(a,e)})})}function v(e){if(!e.pluginManager.addEmitterShapeGenerator)throw Error("tsParticles Emitters Plugin is not loaded")}return(o||(o={})).emitter="emitter",m})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-interactivity","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,n,o,a={303(e){e.exports=t},702(t){t.exports=e}},s={};function l(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return a[e](r,r.exports,l),r.exports}l.m=a,p=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);l.r(r);var i={};c=c||[null,p({}),p([]),p(p)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~c.indexOf(n);n=p(n))Object.getOwnPropertyNames(n).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,l.d(r,i),r},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>""+e+".min.js",l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u={},l.l=(e,t,r,i)=>{if(u[e])return void u[e].push(t);if(void 0!==r)for(var n,o,a=document.getElementsByTagName("script"),s=0;s<a.length;s++){var c=a[s];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/plugin-emitters:"+r){n=c;break}}n||(o=!0,(n=document.createElement("script")).charset="utf-8",l.nc&&n.setAttribute("nonce",l.nc),n.setAttribute("data-webpack","@tsparticles/plugin-emitters:"+r),n.src=e),u[e]=[t];var p=(t,r)=>{n.onerror=n.onload=null,clearTimeout(d);var i=u[e];if(delete u[e],n.parentNode&&n.parentNode.removeChild(n),i&&i.forEach(e=>e(r)),t)return t(r)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=p.bind(null,n.onerror),n.onload=p.bind(null,n.onload),o&&document.head.appendChild(n)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(d=l.g.location+"");var c,p,u,d,f=l.g.document;if(!d&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(d=f.currentScript.src),!d)){var g=f.getElementsByTagName("script");if(g.length)for(var h=g.length-1;h>-1&&(!d||!/^http(s?):/.test(d));)d=g[h--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");l.p=d=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={833:0},l.f.j=(e,t)=>{var i=l.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var n=new Promise((t,n)=>i=r[e]=[t,n]);t.push(i[2]=n);var o=l.p+l.u(e),a=Error();l.l(o,t=>{if(l.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
2
+ (`+n+": "+o+")",a.name="ChunkLoadError",a.type=n,a.request=o,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,n,[o,a,s]=t,c=0;if(o.some(e=>0!==r[e])){for(i in a)l.o(a,i)&&(l.m[i]=a[i]);s&&s(l)}for(e&&e(t);c<o.length;c++)n=o[c],l.o(r,n)&&r[n]&&r[n][0](),r[n]=0},(n=this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).forEach(i.bind(null,0)),n.push=i.bind(null,n.push.bind(n));var b={};async function m(e){e.checkVersion("4.0.0-beta.2"),await e.pluginManager.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{addEmittersShapesManager:r},{getEmittersInstancesManager:i}]=await Promise.all([Promise.resolve().then(l.t.bind(l,702,19)),l.e(49).then(l.bind(l,49)),l.e(410).then(l.bind(l,410))]),n=await i(e);t(e),await r(e),e.pluginManager.addInteractor?.("externalEmitters",async e=>{let{EmittersInteractor:t}=await l.e(414).then(l.bind(l,414));return new t(n,e)})})}async function y(e){e.checkVersion("4.0.0-beta.2"),await e.pluginManager.register(async e=>{let[{addEmittersShapesManager:t},{getEmittersInstancesManager:r},{EmittersPlugin:i}]=await Promise.all([l.e(49).then(l.bind(l,49)),l.e(410).then(l.bind(l,410)),l.e(392).then(l.bind(l,392))]),n=await r(e);await t(e),e.pluginManager.addPlugin(new i(n))})}function v(e){if(!e.pluginManager.addEmitterShapeGenerator)throw Error("tsParticles Emitters Plugin is not loaded")}l.r(b),l.d(b,{EmitterClickMode:()=>o,EmitterShapeBase:()=>w,ensureEmittersPluginLoaded:()=>v,loadEmittersPlugin:()=>j});class w{fill;options;position;size;constructor(e,t,r,i){this.position=e,this.size=t,this.fill=r,this.options=i}resize(e,t){this.position=e,this.size=t}}async function j(e){await y(e),await m(e)}return(o||(o={})).emitter="emitter",b})());
@@ -0,0 +1,2 @@
1
+ import type { EmittersEngine } from "./EmittersEngine.js";
2
+ export declare function addEmittersShapesManager(e: EmittersEngine): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { EmittersEngine } from "./EmittersEngine.js";
2
+ export declare function ensureEmittersPluginLoaded(e: EmittersEngine): void;
@@ -0,0 +1,3 @@
1
+ import type { EmittersInstancesManager } from "./EmittersInstancesManager.js";
2
+ import type { Engine } from "@tsparticles/engine";
3
+ export declare function getEmittersInstancesManager(e: Engine): Promise<EmittersInstancesManager>;
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { EmittersEngine } from "./EmittersEngine.js";
2
2
  export declare function loadEmittersPlugin(engine: EmittersEngine): Promise<void>;
3
- export declare function ensureEmittersPluginLoaded(e: EmittersEngine): void;
3
+ export * from "./ensureEmittersPluginLoaded.js";
4
4
  export type * from "./EmitterContainer.js";
5
5
  export * from "./EmitterShapeBase.js";
6
6
  export type * from "./EmittersEngine.js";
@@ -0,0 +1,9 @@
1
+ import type { EmittersEngine } from "./EmittersEngine.js";
2
+ export declare function loadEmittersInteraction(engine: EmittersEngine): Promise<void>;
3
+ export type * from "./EmitterContainer.js";
4
+ export * from "./EmitterShapeBase.js";
5
+ export type * from "./EmittersEngine.js";
6
+ export type * from "./IEmitterShape.js";
7
+ export type * from "./IEmitterShapeGenerator.js";
8
+ export * from "./Enums/EmitterClickMode.js";
9
+ export type * from "./IRandomPositionData.js";
@@ -0,0 +1,9 @@
1
+ import type { EmittersEngine } from "./EmittersEngine.js";
2
+ export declare function loadEmittersPluginSimple(engine: EmittersEngine): Promise<void>;
3
+ export type * from "./EmitterContainer.js";
4
+ export * from "./EmitterShapeBase.js";
5
+ export type * from "./EmittersEngine.js";
6
+ export type * from "./IEmitterShape.js";
7
+ export type * from "./IEmitterShapeGenerator.js";
8
+ export * from "./Enums/EmitterClickMode.js";
9
+ export type * from "./IRandomPositionData.js";
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,358 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Emitter.js", "./Options/Classes/EmitterSize.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.EmitterInstance = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const Emitter_js_1 = require("./Options/Classes/Emitter.js");
15
- const EmitterSize_js_1 = require("./Options/Classes/EmitterSize.js");
16
- const defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1, colorFactor = 3.6, defaultStrokeWidth = 1;
17
- function setParticlesOptionsFillColor(particlesOptions, color, opacity, enable) {
18
- particlesOptions.fill = new engine_1.Fill();
19
- particlesOptions.fill.color = engine_1.AnimatableColor.create(undefined, { value: color });
20
- particlesOptions.fill.enable = enable;
21
- particlesOptions.fill.opacity = opacity;
22
- }
23
- function setParticlesOptionsStrokeColor(particlesOptions, color, opacity, width) {
24
- particlesOptions.stroke = new engine_1.Stroke();
25
- particlesOptions.stroke.color = engine_1.AnimatableColor.create(undefined, { value: color });
26
- particlesOptions.stroke.opacity = opacity;
27
- particlesOptions.stroke.width = width;
28
- }
29
- class EmitterInstance {
30
- fill;
31
- name;
32
- options;
33
- position;
34
- size;
35
- spawnFillColor;
36
- spawnFillEnabled;
37
- spawnFillOpacity;
38
- spawnStrokeColor;
39
- spawnStrokeOpacity;
40
- spawnStrokeWidth;
41
- _container;
42
- _currentDuration;
43
- _currentEmitDelay;
44
- _currentSpawnDelay;
45
- _duration;
46
- _emitDelay;
47
- _firstSpawn;
48
- _immortal;
49
- _initialPosition;
50
- _lifeCount;
51
- _mutationObserver;
52
- _particlesOptions;
53
- _paused;
54
- _pluginManager;
55
- _removeCallback;
56
- _resizeObserver;
57
- _shape;
58
- _size;
59
- _spawnDelay;
60
- _startParticlesAdded;
61
- constructor(pluginManager, container, removeCallback, options, position) {
62
- this._pluginManager = pluginManager;
63
- this._container = container;
64
- this._removeCallback = removeCallback;
65
- this._currentDuration = 0;
66
- this._currentEmitDelay = 0;
67
- this._currentSpawnDelay = 0;
68
- this._initialPosition = position;
69
- if (options instanceof Emitter_js_1.Emitter) {
70
- this.options = options;
71
- }
72
- else {
73
- this.options = new Emitter_js_1.Emitter();
74
- this.options.load(options);
75
- }
76
- this._spawnDelay = container.retina.reduceFactor
77
- ? ((0, engine_1.getRangeValue)(this.options.life.delay ?? defaultLifeDelay) * engine_1.millisecondsToSeconds) /
78
- container.retina.reduceFactor
79
- : Infinity;
80
- this.position = this._initialPosition ?? this._calcPosition();
81
- this.name = this.options.name;
82
- this.fill = this.options.fill;
83
- this._firstSpawn = !this.options.life.wait;
84
- this._startParticlesAdded = false;
85
- const particlesOptions = (0, engine_1.deepExtend)({}, this.options.particles);
86
- particlesOptions.move ??= {};
87
- particlesOptions.move.direction ??= this.options.direction;
88
- if (this.options.spawn.fill?.color) {
89
- this.spawnFillColor = (0, engine_1.rangeColorToHsl)(this._pluginManager, this.options.spawn.fill.color);
90
- }
91
- if (this.options.spawn.stroke?.color) {
92
- this.spawnStrokeColor = (0, engine_1.rangeColorToHsl)(this._pluginManager, this.options.spawn.stroke.color);
93
- }
94
- this._paused = !this.options.autoPlay;
95
- this._particlesOptions = particlesOptions;
96
- this._size = this._calcSize();
97
- this.size = (0, engine_1.getSize)(this._size, this._container.canvas.size);
98
- this._lifeCount = this.options.life.count ?? defaultLifeCount;
99
- this._immortal = this._lifeCount <= minLifeCount;
100
- if (this.options.domId) {
101
- const element = (0, engine_1.safeDocument)().getElementById(this.options.domId);
102
- if (element) {
103
- this._mutationObserver = new MutationObserver(() => {
104
- this.resize();
105
- });
106
- this._resizeObserver = new ResizeObserver(() => {
107
- this.resize();
108
- });
109
- this._mutationObserver.observe(element, {
110
- attributes: true,
111
- attributeFilter: ["style", "width", "height"],
112
- });
113
- this._resizeObserver.observe(element);
114
- }
115
- }
116
- const shapeOptions = this.options.shape, shapeGenerator = this._pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
117
- if (shapeGenerator) {
118
- this._shape = shapeGenerator.generate(this._container, this.position, this.size, this.fill, shapeOptions.options);
119
- }
120
- this._container.dispatchEvent("emitterCreated", {
121
- emitter: this,
122
- });
123
- this.play();
124
- }
125
- externalPause() {
126
- this._paused = true;
127
- this.pause();
128
- }
129
- externalPlay() {
130
- this._paused = false;
131
- this.play();
132
- }
133
- async init() {
134
- await this._shape?.init();
135
- }
136
- pause() {
137
- if (this._paused) {
138
- return;
139
- }
140
- delete this._emitDelay;
141
- }
142
- play() {
143
- if (this._paused) {
144
- return;
145
- }
146
- if (!((this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) &&
147
- (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
148
- return;
149
- }
150
- const container = this._container;
151
- if (this._emitDelay === undefined) {
152
- const delay = (0, engine_1.getRangeValue)(this.options.rate.delay);
153
- this._emitDelay = container.retina.reduceFactor
154
- ? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
155
- : Infinity;
156
- }
157
- if (this._lifeCount > minLifeCount || this._immortal) {
158
- this._prepareToDie();
159
- }
160
- }
161
- resize() {
162
- const initialPosition = this._initialPosition, container = this._container;
163
- this.position =
164
- initialPosition && (0, engine_1.isPointInside)(initialPosition, container.canvas.size, engine_1.Vector.origin)
165
- ? initialPosition
166
- : this._calcPosition();
167
- this._size = this._calcSize();
168
- this.size = (0, engine_1.getSize)(this._size, container.canvas.size);
169
- this._shape?.resize(this.position, this.size);
170
- }
171
- update(delta) {
172
- if (this._paused) {
173
- return;
174
- }
175
- const container = this._container;
176
- if (this._firstSpawn) {
177
- this._firstSpawn = false;
178
- this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
179
- this._currentEmitDelay = this._emitDelay ?? defaultEmitDelay;
180
- }
181
- if (!this._startParticlesAdded) {
182
- this._startParticlesAdded = true;
183
- this._emitParticles(this.options.startCount);
184
- }
185
- if (this._duration !== undefined) {
186
- this._currentDuration += delta.value;
187
- if (this._currentDuration >= this._duration) {
188
- this.pause();
189
- if (this._spawnDelay !== undefined) {
190
- delete this._spawnDelay;
191
- }
192
- if (!this._immortal) {
193
- this._lifeCount--;
194
- }
195
- if (this._lifeCount > minLifeCount || this._immortal) {
196
- this.position = this._calcPosition();
197
- this._shape?.resize(this.position, this.size);
198
- this._spawnDelay = container.retina.reduceFactor
199
- ? ((0, engine_1.getRangeValue)(this.options.life.delay ?? defaultLifeDelay) * engine_1.millisecondsToSeconds) /
200
- container.retina.reduceFactor
201
- : Infinity;
202
- }
203
- else {
204
- this._destroy();
205
- }
206
- this._currentDuration -= this._duration;
207
- delete this._duration;
208
- }
209
- }
210
- if (this._spawnDelay !== undefined) {
211
- this._currentSpawnDelay += delta.value;
212
- if (this._currentSpawnDelay >= this._spawnDelay) {
213
- this._container.dispatchEvent("emitterPlay");
214
- this.play();
215
- this._currentSpawnDelay -= this._spawnDelay;
216
- delete this._spawnDelay;
217
- }
218
- }
219
- if (this._emitDelay !== undefined) {
220
- this._currentEmitDelay += delta.value;
221
- if (this._currentEmitDelay >= this._emitDelay) {
222
- this._emit();
223
- this._currentEmitDelay -= this._emitDelay;
224
- }
225
- }
226
- }
227
- _calcPosition() {
228
- const container = this._container;
229
- if (this.options.domId) {
230
- const element = (0, engine_1.safeDocument)().getElementById(this.options.domId);
231
- if (element) {
232
- const elRect = element.getBoundingClientRect(), pxRatio = container.retina.pixelRatio;
233
- return {
234
- x: (elRect.x + elRect.width * engine_1.half) * pxRatio,
235
- y: (elRect.y + elRect.height * engine_1.half) * pxRatio,
236
- };
237
- }
238
- }
239
- return (0, engine_1.calcPositionOrRandomFromSizeRanged)({
240
- size: container.canvas.size,
241
- position: this.options.position,
242
- });
243
- }
244
- _calcSize() {
245
- const container = this._container;
246
- if (this.options.domId) {
247
- const element = (0, engine_1.safeDocument)().getElementById(this.options.domId);
248
- if (element) {
249
- const elRect = element.getBoundingClientRect();
250
- return {
251
- width: elRect.width * container.retina.pixelRatio,
252
- height: elRect.height * container.retina.pixelRatio,
253
- mode: engine_1.PixelMode.precise,
254
- };
255
- }
256
- }
257
- return (this.options.size ??
258
- (() => {
259
- const size = new EmitterSize_js_1.EmitterSize();
260
- size.load({
261
- height: 0,
262
- mode: engine_1.PixelMode.percent,
263
- width: 0,
264
- });
265
- return size;
266
- })());
267
- }
268
- _destroy = () => {
269
- this._mutationObserver?.disconnect();
270
- this._mutationObserver = undefined;
271
- this._resizeObserver?.disconnect();
272
- this._resizeObserver = undefined;
273
- this._removeCallback(this);
274
- this._container.dispatchEvent("emitterDestroyed", {
275
- emitter: this,
276
- });
277
- };
278
- _emit() {
279
- if (this._paused) {
280
- return;
281
- }
282
- const quantity = (0, engine_1.getRangeValue)(this.options.rate.quantity);
283
- this._emitParticles(quantity);
284
- }
285
- _emitParticles(quantity) {
286
- const singleParticlesOptions = ((0, engine_1.itemFromSingleOrMultiple)(this._particlesOptions) ??
287
- {}), fillHslAnimation = this.options.spawn.fill?.color.animation, fillEnabled = this.options.spawn.fill?.enable ?? !!this.options.spawn.fill?.color, fillOpacity = this.options.spawn.fill?.opacity === undefined
288
- ? engine_1.defaultOpacity
289
- : (0, engine_1.getRangeValue)(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
290
- ? engine_1.defaultOpacity
291
- : (0, engine_1.getRangeValue)(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
292
- ? defaultStrokeWidth
293
- : (0, engine_1.getRangeValue)(this.options.spawn.stroke.width), reduceFactor = this._container.retina.reduceFactor, needsFillColorAnimation = !!fillHslAnimation, needsStrokeColorAnimation = !!strokeHslAnimation, needsShapeData = !!this._shape, needsColorAnimation = needsFillColorAnimation || needsStrokeColorAnimation, needsCopy = needsColorAnimation || needsShapeData, maxValues = needsColorAnimation ? { h: engine_1.hMax, s: engine_1.sMax, l: engine_1.lMax } : null, shapeOptions = this.options.shape;
294
- for (let i = 0; i < quantity * reduceFactor; i++) {
295
- const particlesOptions = needsCopy
296
- ? (0, engine_1.deepExtend)({}, singleParticlesOptions)
297
- : singleParticlesOptions;
298
- this.spawnFillOpacity = fillOpacity;
299
- this.spawnFillEnabled = fillEnabled;
300
- this.spawnStrokeOpacity = strokeOpacity;
301
- this.spawnStrokeWidth = strokeWidth;
302
- if (this.spawnFillColor) {
303
- if (fillHslAnimation && maxValues) {
304
- this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
305
- this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
306
- this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
307
- }
308
- setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
309
- }
310
- if (this.spawnStrokeColor) {
311
- if (strokeHslAnimation && maxValues) {
312
- this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
313
- this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
314
- this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
315
- }
316
- setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
317
- }
318
- let position = this.position;
319
- if (this._shape) {
320
- const shapePosData = this._shape.randomPosition();
321
- if (shapePosData) {
322
- position = shapePosData.position;
323
- const replaceData = shapeOptions.replace;
324
- if (replaceData.color && shapePosData.color) {
325
- setParticlesOptionsFillColor(particlesOptions, shapePosData.color, replaceData.opacity ? (shapePosData.opacity ?? engine_1.defaultOpacity) : engine_1.defaultOpacity, true);
326
- }
327
- }
328
- else {
329
- position = null;
330
- }
331
- }
332
- if (position) {
333
- this._container.particles.addParticle(position, particlesOptions);
334
- }
335
- }
336
- }
337
- _prepareToDie = () => {
338
- if (this._paused) {
339
- return;
340
- }
341
- const duration = this.options.life.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
342
- if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
343
- this._duration = duration * engine_1.millisecondsToSeconds;
344
- }
345
- };
346
- _setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
347
- const container = this._container;
348
- if (!animation.enable) {
349
- return initValue;
350
- }
351
- const colorOffset = (0, engine_1.randomInRangeValue)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = container.retina.reduceFactor
352
- ? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
353
- : Infinity, colorSpeed = (0, engine_1.getRangeValue)(animation.speed);
354
- return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
355
- };
356
- }
357
- exports.EmitterInstance = EmitterInstance;
358
- });
@@ -1,30 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.EmitterShapeBase = void 0;
13
- class EmitterShapeBase {
14
- fill;
15
- options;
16
- position;
17
- size;
18
- constructor(position, size, fill, options) {
19
- this.position = position;
20
- this.size = size;
21
- this.fill = fill;
22
- this.options = options;
23
- }
24
- resize(position, size) {
25
- this.position = position;
26
- this.size = size;
27
- }
28
- }
29
- exports.EmitterShapeBase = EmitterShapeBase;
30
- });
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,119 +0,0 @@
1
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
- if (k2 === undefined) k2 = k;
3
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
- desc = { enumerable: true, get: function() { return m[k]; } };
6
- }
7
- Object.defineProperty(o, k2, desc);
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
- Object.defineProperty(o, "default", { enumerable: true, value: v });
14
- }) : function(o, v) {
15
- o["default"] = v;
16
- });
17
- var __importStar = (this && this.__importStar) || (function () {
18
- var ownKeys = function(o) {
19
- ownKeys = Object.getOwnPropertyNames || function (o) {
20
- var ar = [];
21
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
- return ar;
23
- };
24
- return ownKeys(o);
25
- };
26
- return function (mod) {
27
- if (mod && mod.__esModule) return mod;
28
- var result = {};
29
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
- __setModuleDefault(result, mod);
31
- return result;
32
- };
33
- })();
34
- (function (factory) {
35
- if (typeof module === "object" && typeof module.exports === "object") {
36
- var v = factory(require, exports);
37
- if (v !== undefined) module.exports = v;
38
- }
39
- else if (typeof define === "function" && define.amd) {
40
- define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Emitter.js"], factory);
41
- }
42
- })(function (require, exports) {
43
- "use strict";
44
- var __syncRequire = typeof module === "object" && typeof module.exports === "object";
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.EmittersInstancesManager = void 0;
47
- const engine_1 = require("@tsparticles/engine");
48
- const Emitter_js_1 = require("./Options/Classes/Emitter.js");
49
- const defaultIndex = 0;
50
- class EmittersInstancesManager {
51
- _containerArrays;
52
- _pluginManager;
53
- constructor(pluginManager) {
54
- this._containerArrays = new Map();
55
- this._pluginManager = pluginManager;
56
- }
57
- async addEmitter(container, options, position) {
58
- const emitterOptions = new Emitter_js_1.Emitter();
59
- emitterOptions.load(options);
60
- const { EmitterInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmitterInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./EmitterInstance.js"], resolve_1, reject_1); }).then(__importStar)), emitter = new EmitterInstance(this._pluginManager, container, (emitter) => {
61
- this.removeEmitter(container, emitter);
62
- }, emitterOptions, position);
63
- await emitter.init();
64
- this.getArray(container).push(emitter);
65
- return emitter;
66
- }
67
- clear(container) {
68
- this.initContainer(container);
69
- this._containerArrays.set(container, []);
70
- }
71
- getArray(container) {
72
- this.initContainer(container);
73
- let array = this._containerArrays.get(container);
74
- if (!array) {
75
- array = [];
76
- this._containerArrays.set(container, array);
77
- }
78
- return array;
79
- }
80
- initContainer(container) {
81
- if (this._containerArrays.has(container)) {
82
- return;
83
- }
84
- this._containerArrays.set(container, []);
85
- container.getEmitter = (idxOrName) => {
86
- const array = this.getArray(container);
87
- return idxOrName === undefined || (0, engine_1.isNumber)(idxOrName)
88
- ? array[idxOrName ?? defaultIndex]
89
- : array.find(t => t.name === idxOrName);
90
- };
91
- container.addEmitter = async (options, position) => this.addEmitter(container, options, position);
92
- container.removeEmitter = (idxOrName) => {
93
- const emitter = container.getEmitter?.(idxOrName);
94
- if (emitter) {
95
- this.removeEmitter(container, emitter);
96
- }
97
- };
98
- container.playEmitter = (idxOrName) => {
99
- const emitter = container.getEmitter?.(idxOrName);
100
- if (emitter) {
101
- emitter.externalPlay();
102
- }
103
- };
104
- container.pauseEmitter = (idxOrName) => {
105
- const emitter = container.getEmitter?.(idxOrName);
106
- if (emitter) {
107
- emitter.externalPause();
108
- }
109
- };
110
- }
111
- removeEmitter(container, emitter) {
112
- const index = this.getArray(container).indexOf(emitter), minIndex = 0, deleteCount = 1;
113
- if (index >= minIndex) {
114
- this.getArray(container).splice(index, deleteCount);
115
- }
116
- }
117
- }
118
- exports.EmittersInstancesManager = EmittersInstancesManager;
119
- });