@tsparticles/plugin-emitters 4.0.0-alpha.8 → 4.0.0-beta.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 (99) hide show
  1. package/526.min.js +1 -0
  2. package/588.min.js +1 -0
  3. package/772.min.js +1 -0
  4. package/784.min.js +1 -0
  5. package/795.min.js +1 -0
  6. package/803.min.js +1 -0
  7. package/README.md +5 -0
  8. package/browser/EmitterInstance.js +109 -65
  9. package/browser/EmitterShapeBase.js +4 -0
  10. package/browser/EmittersInstancesManager.js +2 -0
  11. package/browser/EmittersInteractor.js +5 -1
  12. package/browser/EmittersPlugin.js +2 -1
  13. package/browser/EmittersPluginInstance.js +2 -0
  14. package/browser/Options/Classes/Emitter.js +25 -3
  15. package/browser/Options/Classes/EmitterLife.js +4 -0
  16. package/browser/Options/Classes/EmitterRate.js +2 -0
  17. package/browser/Options/Classes/EmitterShape.js +3 -0
  18. package/browser/Options/Classes/EmitterShapeReplace.js +2 -0
  19. package/browser/Options/Classes/EmitterSize.js +3 -0
  20. package/browser/Options/Classes/EmitterSpawn.js +18 -0
  21. package/browser/Options/Interfaces/IEmitterSpawn.js +1 -0
  22. package/browser/index.js +13 -3
  23. package/cjs/EmitterInstance.js +109 -65
  24. package/cjs/EmitterShapeBase.js +4 -0
  25. package/cjs/EmittersInstancesManager.js +2 -0
  26. package/cjs/EmittersInteractor.js +5 -1
  27. package/cjs/EmittersPlugin.js +2 -1
  28. package/cjs/EmittersPluginInstance.js +2 -0
  29. package/cjs/Options/Classes/Emitter.js +25 -3
  30. package/cjs/Options/Classes/EmitterLife.js +4 -0
  31. package/cjs/Options/Classes/EmitterRate.js +2 -0
  32. package/cjs/Options/Classes/EmitterShape.js +3 -0
  33. package/cjs/Options/Classes/EmitterShapeReplace.js +2 -0
  34. package/cjs/Options/Classes/EmitterSize.js +3 -0
  35. package/cjs/Options/Classes/EmitterSpawn.js +18 -0
  36. package/cjs/Options/Interfaces/IEmitterSpawn.js +1 -0
  37. package/cjs/index.js +13 -3
  38. package/dist_browser_EmitterInstance_js.js +2 -2
  39. package/dist_browser_EmittersInstancesManager_js.js +18 -8
  40. package/dist_browser_EmittersInteractor_js.js +19 -9
  41. package/dist_browser_EmittersPluginInstance_js.js +2 -2
  42. package/dist_browser_EmittersPlugin_js.js +18 -8
  43. package/dist_browser_ShapeManager_js.js +2 -2
  44. package/esm/EmitterInstance.js +109 -65
  45. package/esm/EmitterShapeBase.js +4 -0
  46. package/esm/EmittersInstancesManager.js +2 -0
  47. package/esm/EmittersInteractor.js +5 -1
  48. package/esm/EmittersPlugin.js +2 -1
  49. package/esm/EmittersPluginInstance.js +2 -0
  50. package/esm/Options/Classes/Emitter.js +25 -3
  51. package/esm/Options/Classes/EmitterLife.js +4 -0
  52. package/esm/Options/Classes/EmitterRate.js +2 -0
  53. package/esm/Options/Classes/EmitterShape.js +3 -0
  54. package/esm/Options/Classes/EmitterShapeReplace.js +2 -0
  55. package/esm/Options/Classes/EmitterSize.js +3 -0
  56. package/esm/Options/Classes/EmitterSpawn.js +18 -0
  57. package/esm/Options/Interfaces/IEmitterSpawn.js +1 -0
  58. package/esm/index.js +13 -3
  59. package/package.json +3 -3
  60. package/report.html +1 -1
  61. package/tsparticles.plugin.emitters.js +44 -32
  62. package/tsparticles.plugin.emitters.min.js +2 -2
  63. package/types/EmitterInstance.d.ts +6 -1
  64. package/types/EmittersInteractor.d.ts +1 -0
  65. package/types/EmittersPlugin.d.ts +1 -1
  66. package/types/IEmitterShapeGenerator.d.ts +2 -2
  67. package/types/Options/Classes/Emitter.d.ts +4 -1
  68. package/types/Options/Classes/EmitterSpawn.d.ts +7 -0
  69. package/types/Options/Interfaces/IEmitter.d.ts +4 -1
  70. package/types/Options/Interfaces/IEmitterSpawn.d.ts +5 -0
  71. package/types/index.d.ts +1 -0
  72. package/umd/EmitterInstance.js +108 -64
  73. package/umd/EmitterShapeBase.js +4 -0
  74. package/umd/EmittersInstancesManager.js +2 -0
  75. package/umd/EmittersInteractor.js +5 -1
  76. package/umd/EmittersPlugin.js +2 -1
  77. package/umd/EmittersPluginInstance.js +2 -0
  78. package/umd/Options/Classes/Emitter.js +26 -4
  79. package/umd/Options/Classes/EmitterLife.js +4 -0
  80. package/umd/Options/Classes/EmitterRate.js +2 -0
  81. package/umd/Options/Classes/EmitterShape.js +3 -0
  82. package/umd/Options/Classes/EmitterShapeReplace.js +2 -0
  83. package/umd/Options/Classes/EmitterSize.js +3 -0
  84. package/umd/Options/Classes/EmitterSpawn.js +32 -0
  85. package/umd/Options/Interfaces/IEmitterSpawn.js +12 -0
  86. package/umd/index.js +14 -3
  87. package/129.min.js +0 -2
  88. package/129.min.js.LICENSE.txt +0 -1
  89. package/246.min.js +0 -2
  90. package/246.min.js.LICENSE.txt +0 -1
  91. package/330.min.js +0 -2
  92. package/330.min.js.LICENSE.txt +0 -1
  93. package/490.min.js +0 -2
  94. package/490.min.js.LICENSE.txt +0 -1
  95. package/849.min.js +0 -2
  96. package/849.min.js.LICENSE.txt +0 -1
  97. package/940.min.js +0 -2
  98. package/940.min.js.LICENSE.txt +0 -1
  99. package/tsparticles.plugin.emitters.min.js.LICENSE.txt +0 -1
@@ -1,2 +1,2 @@
1
- /*! For license information please see tsparticles.plugin.emitters.min.js.LICENSE.txt */
2
- !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)=>(()=>{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,i=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t)return e;if("object"==typeof e&&e){if(4&t&&e.__esModule)return e;if(16&t&&"function"==typeof e.then)return e}var n=Object.create(null);l.r(n);var o={};r=r||[null,i({}),i([]),i(i)];for(var a=2&t&&e;("object"==typeof a||"function"==typeof a)&&!~r.indexOf(a);a=i(a))Object.getOwnPropertyNames(a).forEach((t=>o[t]=()=>e[t]));return o.default=()=>e,l.d(n,o),n},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.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n={},o="@tsparticles/plugin-emitters:",l.l=(e,t,r,i)=>{if(n[e])n[e].push(t);else{var a,s;if(void 0!==r)for(var c=document.getElementsByTagName("script"),p=0;p<c.length;p++){var u=c[p];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==o+r){a=u;break}}a||(s=!0,(a=document.createElement("script")).charset="utf-8",l.nc&&a.setAttribute("nonce",l.nc),a.setAttribute("data-webpack",o+r),a.src=e),n[e]=[t];var d=(t,r)=>{a.onerror=a.onload=null,clearTimeout(f);var i=n[e];if(delete n[e],a.parentNode&&a.parentNode.removeChild(a),i&&i.forEach((e=>e(r))),t)return t(r)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),s&&document.head.appendChild(a)}},l.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var t=globalThis.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=r[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),l.p=e})(),(()=>{var e={833:0};l.f.j=(t,r)=>{var i=l.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise(((r,n)=>i=e[t]=[r,n]));r.push(i[2]=n);var o=l.p+l.u(t),a=new Error;l.l(o,(r=>{if(l.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+n+": "+o+")",a.name="ChunkLoadError",a.type=n,a.request=o,i[1](a)}}),"chunk-"+t,t)}};var t=(t,r)=>{var i,n,[o,a,s]=r,c=0;if(o.some((t=>0!==e[t]))){for(i in a)l.o(a,i)&&(l.m[i]=a[i]);if(s)s(l)}for(t&&t(r);c<o.length;c++)n=o[c],l.o(e,n)&&e[n]&&e[n][0](),e[n]=0},r=this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var c,p={};l.r(p),l.d(p,{EmitterClickMode:()=>c,EmitterShapeBase:()=>u,loadEmittersPlugin:()=>d});class u{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 d(e){e.checkVersion("4.0.0-alpha.8"),await e.register((async e=>{const{loadInteractivityPlugin:t}=await Promise.resolve().then(l.t.bind(l,702,19)),{ShapeManager:r}=await l.e(490).then(l.bind(l,490)),{EmittersInstancesManager:i}=await l.e(246).then(l.bind(l,246)),{EmittersPlugin:n}=await l.e(330).then(l.bind(l,330)),o=new i(e);await t(e),e.emitterShapeManager??=new r,e.addEmitterShapeGenerator??=(t,r)=>{e.emitterShapeManager?.addShapeGenerator(t,r)},e.addPlugin(new n(o)),e.addInteractor?.("externalEmitters",(async e=>{const{EmittersInteractor:t}=await l.e(940).then(l.bind(l,940));return new t(o,e)}))}))}return function(e){e.emitter="emitter"}(c||(c={})),p})()));
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,o,n,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 o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~c.indexOf(o);o=p(o))Object.getOwnPropertyNames(o).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 o,n,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){o=c;break}}o||(n=!0,(o=document.createElement("script")).charset="utf-8",l.nc&&o.setAttribute("nonce",l.nc),o.setAttribute("data-webpack","@tsparticles/plugin-emitters:"+r),o.src=e),u[e]=[t];var p=(t,r)=>{o.onerror=o.onload=null,clearTimeout(d);var i=u[e];if(delete u[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach(e=>e(r)),t)return t(r)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=p.bind(null,o.onerror),o.onload=p.bind(null,o.onload),n&&document.head.appendChild(o)},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 h=f.getElementsByTagName("script");if(h.length)for(var m=h.length-1;m>-1&&(!d||!/^http(s?):/.test(d));)d=h[m--].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 o=new Promise((t,o)=>i=r[e]=[t,o]);t.push(i[2]=o);var n=l.p+l.u(e),a=Error();l.l(n,t=>{if(l.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var o=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
2
+ (`+o+": "+n+")",a.name="ChunkLoadError",a.type=o,a.request=n,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,o,[n,a,s]=t,c=0;if(n.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<n.length;c++)o=n[c],l.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).forEach(i.bind(null,0)),o.push=i.bind(null,o.push.bind(o));var b={};l.r(b),l.d(b,{EmitterClickMode:()=>n,EmitterShapeBase:()=>g,ensureEmittersPluginLoaded:()=>v,loadEmittersPlugin:()=>y});class g{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.0"),await e.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{ShapeManager:r},{EmittersInstancesManager:i},{EmittersPlugin:o}]=await Promise.all([Promise.resolve().then(l.t.bind(l,702,19)),l.e(772).then(l.bind(l,772)),l.e(784).then(l.bind(l,784)),l.e(588).then(l.bind(l,588))]),n=new i(e);t(e),e.emitterShapeManager??=new r,e.addEmitterShapeGenerator??=(t,r)=>{e.emitterShapeManager?.addShapeGenerator(t,r)},e.addPlugin(new o(n)),e.addInteractor?.("externalEmitters",async e=>{let{EmittersInteractor:t}=await l.e(526).then(l.bind(l,526));return new t(n,e)})})}function v(e){if(!e.addEmitterShapeGenerator)throw Error("tsParticles Emitters Plugin is not loaded")}return(n||(n={})).emitter="emitter",b})());
@@ -10,7 +10,12 @@ export declare class EmitterInstance {
10
10
  options: Emitter;
11
11
  position: ICoordinates;
12
12
  size: IDimension;
13
- spawnColor?: IHsl;
13
+ spawnFillColor?: IHsl;
14
+ spawnFillEnabled?: boolean;
15
+ spawnFillOpacity?: number;
16
+ spawnStrokeColor?: IHsl;
17
+ spawnStrokeOpacity?: number;
18
+ spawnStrokeWidth?: number;
14
19
  private _currentDuration;
15
20
  private _currentEmitDelay;
16
21
  private _currentSpawnDelay;
@@ -6,6 +6,7 @@ import type { EmitterInstance } from "./EmitterInstance.js";
6
6
  import type { EmittersInstancesManager } from "./EmittersInstancesManager.js";
7
7
  export declare class EmittersInteractor extends ExternalInteractorBase<EmitterContainer> {
8
8
  handleClickMode: (mode: string, interactivityData: IInteractivityData) => void;
9
+ readonly maxDistance: number;
9
10
  private readonly _instancesManager;
10
11
  constructor(instancesManager: EmittersInstancesManager, container: EmitterContainer);
11
12
  clear(): void;
@@ -3,7 +3,7 @@ import type { EmitterOptions, IEmitterOptions } from "./types.js";
3
3
  import type { EmitterContainer } from "./EmitterContainer.js";
4
4
  import type { EmittersInstancesManager } from "./EmittersInstancesManager.js";
5
5
  export declare class EmittersPlugin implements IPlugin {
6
- readonly id: string;
6
+ readonly id = "emitters";
7
7
  private readonly _instancesManager;
8
8
  constructor(instancesManager: EmittersInstancesManager);
9
9
  getPlugin(container: EmitterContainer): Promise<IContainerPlugin>;
@@ -1,5 +1,5 @@
1
- import type { ICoordinates, IDimension } from "@tsparticles/engine";
1
+ import type { Container, ICoordinates, IDimension } from "@tsparticles/engine";
2
2
  import type { IEmitterShape } from "./IEmitterShape.js";
3
3
  export interface IEmitterShapeGenerator<TOptions = unknown> {
4
- generate(position: ICoordinates, size: IDimension, fill: boolean, options: TOptions): IEmitterShape;
4
+ generate(container: Container, position: ICoordinates, size: IDimension, fill: boolean, options: TOptions): IEmitterShape;
5
5
  }
@@ -3,6 +3,7 @@ import { EmitterLife } from "./EmitterLife.js";
3
3
  import { EmitterRate } from "./EmitterRate.js";
4
4
  import { EmitterShape } from "./EmitterShape.js";
5
5
  import { EmitterSize } from "./EmitterSize.js";
6
+ import { EmitterSpawn } from "./EmitterSpawn.js";
6
7
  import type { IEmitter } from "../Interfaces/IEmitter.js";
7
8
  export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
8
9
  autoPlay: boolean;
@@ -16,7 +17,9 @@ export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
16
17
  rate: EmitterRate;
17
18
  shape: EmitterShape;
18
19
  size?: EmitterSize;
19
- spawnColor?: AnimatableColor;
20
+ spawn: EmitterSpawn;
21
+ spawnFillColor?: AnimatableColor;
22
+ spawnStrokeColor?: AnimatableColor;
20
23
  startCount: number;
21
24
  constructor();
22
25
  load(data?: RecursivePartial<IEmitter>): void;
@@ -0,0 +1,7 @@
1
+ import { Fill, type IOptionLoader, type RecursivePartial, Stroke } from "@tsparticles/engine";
2
+ import type { IEmitterSpawn } from "../Interfaces/IEmitterSpawn.js";
3
+ export declare class EmitterSpawn implements IEmitterSpawn, IOptionLoader<IEmitterSpawn> {
4
+ fill?: Fill;
5
+ stroke?: Stroke;
6
+ load(data?: RecursivePartial<IEmitterSpawn>): void;
7
+ }
@@ -3,6 +3,7 @@ import type { IEmitterLife } from "./IEmitterLife.js";
3
3
  import type { IEmitterRate } from "./IEmitterRate.js";
4
4
  import type { IEmitterShape } from "./IEmitterShape.js";
5
5
  import type { IEmitterSize } from "./IEmitterSize.js";
6
+ import type { IEmitterSpawn } from "./IEmitterSpawn.js";
6
7
  export interface IEmitter {
7
8
  autoPlay: boolean;
8
9
  direction?: MoveDirection | keyof typeof MoveDirection | MoveDirectionAlt | number;
@@ -15,6 +16,8 @@ export interface IEmitter {
15
16
  rate: IEmitterRate;
16
17
  shape: IEmitterShape;
17
18
  size?: IEmitterSize;
18
- spawnColor?: IAnimatableColor;
19
+ spawn: IEmitterSpawn;
20
+ spawnFillColor?: IAnimatableColor;
21
+ spawnStrokeColor?: IAnimatableColor;
19
22
  startCount: number;
20
23
  }
@@ -0,0 +1,5 @@
1
+ import type { IFill, IStroke } from "@tsparticles/engine";
2
+ export interface IEmitterSpawn {
3
+ fill?: IFill;
4
+ stroke?: IStroke;
5
+ }
package/types/index.d.ts CHANGED
@@ -1,5 +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
4
  export type * from "./EmitterContainer.js";
4
5
  export * from "./EmitterShapeBase.js";
5
6
  export type * from "./EmittersEngine.js";
@@ -13,53 +13,54 @@
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const Emitter_js_1 = require("./Options/Classes/Emitter.js");
15
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;
17
- function setParticlesOptionsColor(particlesOptions, color) {
18
- if (particlesOptions.color) {
19
- particlesOptions.color.value = color;
20
- }
21
- else {
22
- particlesOptions.color = {
23
- value: color,
24
- };
25
- }
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;
26
28
  }
27
29
  class EmitterInstance {
30
+ container;
31
+ removeCallback;
32
+ fill;
33
+ name;
34
+ options;
35
+ position;
36
+ size;
37
+ spawnFillColor;
38
+ spawnFillEnabled;
39
+ spawnFillOpacity;
40
+ spawnStrokeColor;
41
+ spawnStrokeOpacity;
42
+ spawnStrokeWidth;
43
+ _currentDuration;
44
+ _currentEmitDelay;
45
+ _currentSpawnDelay;
46
+ _duration;
47
+ _emitDelay;
48
+ _engine;
49
+ _firstSpawn;
50
+ _immortal;
51
+ _initialPosition;
52
+ _lifeCount;
53
+ _mutationObserver;
54
+ _particlesOptions;
55
+ _paused;
56
+ _resizeObserver;
57
+ _shape;
58
+ _size;
59
+ _spawnDelay;
60
+ _startParticlesAdded;
28
61
  constructor(engine, container, removeCallback, options, position) {
29
62
  this.container = container;
30
63
  this.removeCallback = removeCallback;
31
- this._destroy = () => {
32
- this._mutationObserver?.disconnect();
33
- this._mutationObserver = undefined;
34
- this._resizeObserver?.disconnect();
35
- this._resizeObserver = undefined;
36
- this.removeCallback(this);
37
- this._engine.dispatchEvent("emitterDestroyed", {
38
- container: this.container,
39
- data: {
40
- emitter: this,
41
- },
42
- });
43
- };
44
- this._prepareToDie = () => {
45
- if (this._paused) {
46
- return;
47
- }
48
- const duration = this.options.life.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
49
- if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
50
- this._duration = duration * engine_1.millisecondsToSeconds;
51
- }
52
- };
53
- this._setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
54
- const container = this.container;
55
- if (!animation.enable) {
56
- return initValue;
57
- }
58
- const colorOffset = (0, engine_1.randomInRangeValue)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = container.retina.reduceFactor
59
- ? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
60
- : Infinity, colorSpeed = (0, engine_1.getRangeValue)(animation.speed);
61
- return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
62
- };
63
64
  this._engine = engine;
64
65
  this._currentDuration = 0;
65
66
  this._currentEmitDelay = 0;
@@ -84,8 +85,11 @@
84
85
  const particlesOptions = (0, engine_1.deepExtend)({}, this.options.particles);
85
86
  particlesOptions.move ??= {};
86
87
  particlesOptions.move.direction ??= this.options.direction;
87
- if (this.options.spawnColor) {
88
- this.spawnColor = (0, engine_1.rangeColorToHsl)(this._engine, this.options.spawnColor);
88
+ if (this.options.spawn.fill?.color) {
89
+ this.spawnFillColor = (0, engine_1.rangeColorToHsl)(this._engine, this.options.spawn.fill.color);
90
+ }
91
+ if (this.options.spawn.stroke?.color) {
92
+ this.spawnStrokeColor = (0, engine_1.rangeColorToHsl)(this._engine, this.options.spawn.stroke.color);
89
93
  }
90
94
  this._paused = !this.options.autoPlay;
91
95
  this._particlesOptions = particlesOptions;
@@ -111,7 +115,7 @@
111
115
  }
112
116
  const shapeOptions = this.options.shape, shapeGenerator = this._engine.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
113
117
  if (shapeGenerator) {
114
- this._shape = shapeGenerator.generate(this.position, this.size, this.fill, shapeOptions.options);
118
+ this._shape = shapeGenerator.generate(this.container, this.position, this.size, this.fill, shapeOptions.options);
115
119
  }
116
120
  this._engine.dispatchEvent("emitterCreated", {
117
121
  container,
@@ -213,7 +217,7 @@
213
217
  container: this.container,
214
218
  });
215
219
  this.play();
216
- this._currentSpawnDelay -= this._currentSpawnDelay;
220
+ this._currentSpawnDelay -= this._spawnDelay;
217
221
  delete this._spawnDelay;
218
222
  }
219
223
  }
@@ -266,6 +270,19 @@
266
270
  return size;
267
271
  })());
268
272
  }
273
+ _destroy = () => {
274
+ this._mutationObserver?.disconnect();
275
+ this._mutationObserver = undefined;
276
+ this._resizeObserver?.disconnect();
277
+ this._resizeObserver = undefined;
278
+ this.removeCallback(this);
279
+ this._engine.dispatchEvent("emitterDestroyed", {
280
+ container: this.container,
281
+ data: {
282
+ emitter: this,
283
+ },
284
+ });
285
+ };
269
286
  _emit() {
270
287
  if (this._paused) {
271
288
  return;
@@ -275,18 +292,36 @@
275
292
  }
276
293
  _emitParticles(quantity) {
277
294
  const singleParticlesOptions = ((0, engine_1.itemFromSingleOrMultiple)(this._particlesOptions) ??
278
- {}), hslAnimation = this.options.spawnColor?.animation, reduceFactor = this.container.retina.reduceFactor, needsColorAnimation = !!hslAnimation, needsShapeData = !!this._shape, needsCopy = needsColorAnimation || needsShapeData, maxValues = needsColorAnimation ? { h: engine_1.hMax, s: engine_1.sMax, l: engine_1.lMax } : null, shapeOptions = this.options.shape;
295
+ {}), 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
296
+ ? engine_1.defaultOpacity
297
+ : (0, engine_1.getRangeValue)(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
298
+ ? engine_1.defaultOpacity
299
+ : (0, engine_1.getRangeValue)(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
300
+ ? defaultStrokeWidth
301
+ : (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;
279
302
  for (let i = 0; i < quantity * reduceFactor; i++) {
280
303
  const particlesOptions = needsCopy
281
304
  ? (0, engine_1.deepExtend)({}, singleParticlesOptions)
282
305
  : singleParticlesOptions;
283
- if (this.spawnColor) {
284
- if (hslAnimation && maxValues) {
285
- this.spawnColor.h = this._setColorAnimation(hslAnimation.h, this.spawnColor.h, maxValues.h, colorFactor);
286
- this.spawnColor.s = this._setColorAnimation(hslAnimation.s, this.spawnColor.s, maxValues.s);
287
- this.spawnColor.l = this._setColorAnimation(hslAnimation.l, this.spawnColor.l, maxValues.l);
306
+ this.spawnFillOpacity = fillOpacity;
307
+ this.spawnFillEnabled = fillEnabled;
308
+ this.spawnStrokeOpacity = strokeOpacity;
309
+ this.spawnStrokeWidth = strokeWidth;
310
+ if (this.spawnFillColor) {
311
+ if (fillHslAnimation && maxValues) {
312
+ this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
313
+ this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
314
+ this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
315
+ }
316
+ setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
317
+ }
318
+ if (this.spawnStrokeColor) {
319
+ if (strokeHslAnimation && maxValues) {
320
+ this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
321
+ this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
322
+ this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
288
323
  }
289
- setParticlesOptionsColor(particlesOptions, this.spawnColor);
324
+ setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
290
325
  }
291
326
  let position = this.position;
292
327
  if (this._shape) {
@@ -295,17 +330,7 @@
295
330
  position = shapePosData.position;
296
331
  const replaceData = shapeOptions.replace;
297
332
  if (replaceData.color && shapePosData.color) {
298
- setParticlesOptionsColor(particlesOptions, shapePosData.color);
299
- }
300
- if (replaceData.opacity) {
301
- if (particlesOptions.opacity) {
302
- particlesOptions.opacity.value = shapePosData.opacity;
303
- }
304
- else {
305
- particlesOptions.opacity = {
306
- value: shapePosData.opacity,
307
- };
308
- }
333
+ setParticlesOptionsFillColor(particlesOptions, shapePosData.color, replaceData.opacity ? (shapePosData.opacity ?? engine_1.defaultOpacity) : engine_1.defaultOpacity, true);
309
334
  }
310
335
  }
311
336
  else {
@@ -317,6 +342,25 @@
317
342
  }
318
343
  }
319
344
  }
345
+ _prepareToDie = () => {
346
+ if (this._paused) {
347
+ return;
348
+ }
349
+ const duration = this.options.life.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
350
+ if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
351
+ this._duration = duration * engine_1.millisecondsToSeconds;
352
+ }
353
+ };
354
+ _setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
355
+ const container = this.container;
356
+ if (!animation.enable) {
357
+ return initValue;
358
+ }
359
+ const colorOffset = (0, engine_1.randomInRangeValue)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = container.retina.reduceFactor
360
+ ? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
361
+ : Infinity, colorSpeed = (0, engine_1.getRangeValue)(animation.speed);
362
+ return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
363
+ };
320
364
  }
321
365
  exports.EmitterInstance = EmitterInstance;
322
366
  });
@@ -11,6 +11,10 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EmitterShapeBase = void 0;
13
13
  class EmitterShapeBase {
14
+ fill;
15
+ options;
16
+ position;
17
+ size;
14
18
  constructor(position, size, fill, options) {
15
19
  this.position = position;
16
20
  this.size = size;
@@ -48,6 +48,8 @@ var __importStar = (this && this.__importStar) || (function () {
48
48
  const Emitter_js_1 = require("./Options/Classes/Emitter.js");
49
49
  const defaultIndex = 0;
50
50
  class EmittersInstancesManager {
51
+ _containerArrays;
52
+ _engine;
51
53
  constructor(engine) {
52
54
  this._containerArrays = new Map();
53
55
  this._engine = engine;
@@ -16,9 +16,13 @@
16
16
  const constants_js_1 = require("./constants.js");
17
17
  const emittersMode = "emitters";
18
18
  class EmittersInteractor extends plugin_interactivity_1.ExternalInteractorBase {
19
+ handleClickMode;
20
+ maxDistance;
21
+ _instancesManager;
19
22
  constructor(instancesManager, container) {
20
23
  super(container);
21
24
  this._instancesManager = instancesManager;
25
+ this.maxDistance = 0;
22
26
  this.handleClickMode = (mode, interactivityData) => {
23
27
  const container = this.container, options = container.actualOptions, modeEmitters = options.interactivity.modes.emitters;
24
28
  if (!modeEmitters || mode !== emittersMode) {
@@ -89,7 +93,7 @@
89
93
  options.emitters.value.push(tmp);
90
94
  }
91
95
  }
92
- else if (Object.hasOwn(source.emitters, "value")) {
96
+ else if ("value" in source.emitters) {
93
97
  const emitterModeOptions = source.emitters;
94
98
  options.emitters.random.enable = emitterModeOptions.random?.enable ?? options.emitters.random.enable;
95
99
  options.emitters.random.count = emitterModeOptions.random?.count ?? options.emitters.random.count;
@@ -47,9 +47,10 @@ var __importStar = (this && this.__importStar) || (function () {
47
47
  const engine_1 = require("@tsparticles/engine");
48
48
  const Emitter_js_1 = require("./Options/Classes/Emitter.js");
49
49
  class EmittersPlugin {
50
+ id = "emitters";
51
+ _instancesManager;
50
52
  constructor(instancesManager) {
51
53
  this._instancesManager = instancesManager;
52
- this.id = "emitters";
53
54
  }
54
55
  async getPlugin(container) {
55
56
  const { EmittersPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmittersPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./EmittersPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
@@ -12,6 +12,8 @@
12
12
  exports.EmittersPluginInstance = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class EmittersPluginInstance {
15
+ container;
16
+ _instancesManager;
15
17
  constructor(instancesManager, container) {
16
18
  this.container = container;
17
19
  this._instancesManager = instancesManager;
@@ -4,7 +4,7 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./EmitterLife.js", "./EmitterRate.js", "./EmitterShape.js", "./EmitterSize.js"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./EmitterLife.js", "./EmitterRate.js", "./EmitterShape.js", "./EmitterSize.js", "./EmitterSpawn.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -15,13 +15,30 @@
15
15
  const EmitterRate_js_1 = require("./EmitterRate.js");
16
16
  const EmitterShape_js_1 = require("./EmitterShape.js");
17
17
  const EmitterSize_js_1 = require("./EmitterSize.js");
18
+ const EmitterSpawn_js_1 = require("./EmitterSpawn.js");
18
19
  class Emitter {
20
+ autoPlay;
21
+ direction;
22
+ domId;
23
+ fill;
24
+ life;
25
+ name;
26
+ particles;
27
+ position;
28
+ rate;
29
+ shape;
30
+ size;
31
+ spawn;
32
+ spawnFillColor;
33
+ spawnStrokeColor;
34
+ startCount;
19
35
  constructor() {
20
36
  this.autoPlay = true;
21
37
  this.fill = true;
22
38
  this.life = new EmitterLife_js_1.EmitterLife();
23
39
  this.rate = new EmitterRate_js_1.EmitterRate();
24
40
  this.shape = new EmitterShape_js_1.EmitterShape();
41
+ this.spawn = new EmitterSpawn_js_1.EmitterSpawn();
25
42
  this.startCount = 0;
26
43
  }
27
44
  load(data) {
@@ -49,6 +66,7 @@
49
66
  });
50
67
  this.rate.load(data.rate);
51
68
  this.shape.load(data.shape);
69
+ this.spawn.load(data.spawn);
52
70
  if (data.position !== undefined) {
53
71
  this.position = {};
54
72
  if (data.position.x !== undefined) {
@@ -58,9 +76,13 @@
58
76
  this.position.y = (0, engine_1.setRangeValue)(data.position.y);
59
77
  }
60
78
  }
61
- if (data.spawnColor !== undefined) {
62
- this.spawnColor ??= new engine_1.AnimatableColor();
63
- this.spawnColor.load(data.spawnColor);
79
+ if (data.spawnFillColor !== undefined) {
80
+ this.spawnFillColor ??= new engine_1.AnimatableColor();
81
+ this.spawnFillColor.load(data.spawnFillColor);
82
+ }
83
+ if (data.spawnStrokeColor !== undefined) {
84
+ this.spawnStrokeColor ??= new engine_1.AnimatableColor();
85
+ this.spawnStrokeColor.load(data.spawnStrokeColor);
64
86
  }
65
87
  if (data.startCount !== undefined) {
66
88
  this.startCount = data.startCount;
@@ -12,6 +12,10 @@
12
12
  exports.EmitterLife = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class EmitterLife {
15
+ count;
16
+ delay;
17
+ duration;
18
+ wait;
15
19
  constructor() {
16
20
  this.wait = false;
17
21
  }
@@ -12,6 +12,8 @@
12
12
  exports.EmitterRate = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class EmitterRate {
15
+ delay;
16
+ quantity;
15
17
  constructor() {
16
18
  this.quantity = 1;
17
19
  this.delay = 0.1;
@@ -13,6 +13,9 @@
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const EmitterShapeReplace_js_1 = require("./EmitterShapeReplace.js");
15
15
  class EmitterShape {
16
+ options;
17
+ replace;
18
+ type;
16
19
  constructor() {
17
20
  this.options = {};
18
21
  this.replace = new EmitterShapeReplace_js_1.EmitterShapeReplace();
@@ -12,6 +12,8 @@
12
12
  exports.EmitterShapeReplace = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class EmitterShapeReplace {
15
+ color;
16
+ opacity;
15
17
  constructor() {
16
18
  this.color = false;
17
19
  this.opacity = false;
@@ -12,6 +12,9 @@
12
12
  exports.EmitterSize = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  class EmitterSize {
15
+ height;
16
+ mode;
17
+ width;
15
18
  constructor() {
16
19
  this.mode = engine_1.PixelMode.percent;
17
20
  this.height = 0;
@@ -0,0 +1,32 @@
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"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EmitterSpawn = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ class EmitterSpawn {
15
+ fill;
16
+ stroke;
17
+ load(data) {
18
+ if ((0, engine_1.isNull)(data)) {
19
+ return;
20
+ }
21
+ if (data.fill) {
22
+ this.fill ??= new engine_1.Fill();
23
+ this.fill.load(data.fill);
24
+ }
25
+ if (data.stroke) {
26
+ this.stroke ??= new engine_1.Stroke();
27
+ this.stroke.load(data.stroke);
28
+ }
29
+ }
30
+ }
31
+ exports.EmitterSpawn = EmitterSpawn;
32
+ });
@@ -0,0 +1,12 @@
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
+ });