@tsparticles/plugin-infection 4.0.0-alpha.2 → 4.0.0-alpha.4

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 (38) hide show
  1. package/249.min.js +2 -0
  2. package/249.min.js.LICENSE.txt +1 -0
  3. package/713.min.js +2 -0
  4. package/713.min.js.LICENSE.txt +1 -0
  5. package/835.min.js +2 -0
  6. package/835.min.js.LICENSE.txt +1 -0
  7. package/browser/InfectionPlugin.js +4 -4
  8. package/browser/{InfectionInstance.js → InfectionPluginInstance.js} +1 -1
  9. package/browser/ParticlesInfecter.js +4 -3
  10. package/browser/index.js +4 -3
  11. package/cjs/InfectionPlugin.js +4 -4
  12. package/cjs/{InfectionInstance.js → InfectionPluginInstance.js} +1 -1
  13. package/cjs/ParticlesInfecter.js +4 -3
  14. package/cjs/index.js +4 -3
  15. package/dist_browser_InfectionPluginInstance_js.js +40 -0
  16. package/dist_browser_InfectionPlugin_js.js +2 -22
  17. package/dist_browser_ParticlesInfecter_js.js +2 -2
  18. package/esm/InfectionPlugin.js +4 -4
  19. package/esm/{InfectionInstance.js → InfectionPluginInstance.js} +1 -1
  20. package/esm/ParticlesInfecter.js +4 -3
  21. package/esm/index.js +4 -3
  22. package/package.json +3 -2
  23. package/report.html +1 -1
  24. package/tsparticles.plugin.infection.js +48 -20
  25. package/tsparticles.plugin.infection.min.js +1 -1
  26. package/tsparticles.plugin.infection.min.js.LICENSE.txt +1 -1
  27. package/types/InfectionPlugin.d.ts +3 -4
  28. package/types/{InfectionInstance.d.ts → InfectionPluginInstance.d.ts} +1 -1
  29. package/types/ParticlesInfecter.d.ts +3 -2
  30. package/types/Types.d.ts +5 -4
  31. package/umd/InfectionPlugin.js +39 -5
  32. package/umd/{InfectionInstance.js → InfectionPluginInstance.js} +3 -3
  33. package/umd/ParticlesInfecter.js +6 -5
  34. package/umd/index.js +5 -4
  35. package/492.min.js +0 -2
  36. package/492.min.js.LICENSE.txt +0 -1
  37. package/796.min.js +0 -2
  38. package/796.min.js.LICENSE.txt +0 -1
package/249.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 249.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[249],{249(e,t,n){n.d(t,{ParticlesInfecter:()=>a});var i=n(303),s=n(702);class a extends s.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}interact(e,t,n){const s=this.container.infecter;if(!s)return;if(s.updateInfection(e,n.value),void 0===e.infection?.stage)return;const a=this.container,c=a.actualOptions.infection;if(!c?.enable||c.stages.length<1)return;const o=c.stages[e.infection.stage];if(!o)return;const r=a.retina.pixelRatio,f=e.getRadius()*i.double+o.radius*r,g=e.getPosition(),u=o.infectedStage??e.infection.stage,l=a.particles.quadTree.queryCircle(g,f),d=o.rate,p=l.length;for(const t of l){const n=t;if(!(n===e||n.destroyed||n.spawning||void 0!==n.infection?.stage&&n.infection.stage===e.infection.stage||(0,i.getRandom)()>=d/p))if(void 0===n.infection?.stage)s.startInfection(n,u);else if(n.infection.stage<e.infection.stage)s.updateInfectionStage(n,u);else if(n.infection.stage>e.infection.stage){const t=c.stages[n.infection.stage];if(!t)continue;const i=t.infectedStage??n.infection.stage;s.updateInfectionStage(e,i)}}}isEnabled(){return this.container.actualOptions.infection?.enable??!1}reset(){}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Infection Plugin v4.0.0-alpha.4 by Matteo Bruni */
package/713.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 713.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[713],{713(i,t,e){e.d(t,{InfectionPlugin:()=>a});var n=e(303);class s{constructor(){this.color=new n.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(i){(0,n.isNull)(i)||(void 0!==i.color&&(this.color=n.OptionsColor.create(this.color,i.color)),this.duration=i.duration,this.infectedStage=i.infectedStage,void 0!==i.radius&&(this.radius=i.radius),void 0!==i.rate&&(this.rate=i.rate))}}class o{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(i){(0,n.isNull)(i)||(void 0!==i.cure&&(this.cure=i.cure),void 0!==i.delay&&(this.delay=i.delay),void 0!==i.enable&&(this.enable=i.enable),void 0!==i.infections&&(this.infections=i.infections),void 0!==i.stages&&(this.stages=i.stages.map((i=>{const t=new s;return t.load(i),t}))))}}class a{constructor(){this.id="infection"}async getPlugin(i){const{InfectionPluginInstance:t}=await e.e(835).then(e.bind(e,835));return new t(i)}loadOptions(i,t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let n=t.infection;void 0===n?.load&&(t.infection=n=new o),n.load(e?.infection)}needsPlugin(i){return i?.infection?.enable??!1}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Infection Plugin v4.0.0-alpha.4 by Matteo Bruni */
package/835.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 835.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[835],{835(t,e,i){i.d(e,{InfectionPluginInstance:()=>s});var n=i(303);class o{constructor(t){this._nextInfectionStage=t=>{const e=this._container.actualOptions.infection,{infection:i}=t;if(!e||!i)return;const n=e.stages.length;n<=0||void 0===i.stage||(i.time=0,n<=++i.stage&&(e.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))},this._container=t}startInfection(t,e){const i=this._container.actualOptions.infection,{infection:n}=t;if(!i||!n)return;e>i.stages.length||e<0||(n.delay=0,n.delayStage=e)}updateInfection(t,e){const i=this._container.actualOptions.infection,{infection:o}=t;if(!i||!o)return;const s=i.stages,a=s.length;if(void 0!==o.delay&&void 0!==o.delayStage){const t=o.delayStage;if(t>a||t<0)return;o.delay>=i.delay*n.millisecondsToSeconds?(o.stage=t,o.time=0,delete o.delay,delete o.delayStage):o.delay+=e}else delete o.delay,delete o.delayStage;if(void 0!==o.stage&&void 0!==o.time){const i=s[o.stage];void 0!==i?.duration&&i.duration>=0&&o.time>i.duration*n.millisecondsToSeconds?this._nextInfectionStage(t):o.time+=e}else delete o.stage,delete o.time}updateInfectionStage(t,e){const i=this._container.actualOptions,{infection:n}=t;if(!i.infection||!n)return;e>i.infection.stages.length||e<0||void 0!==n.stage&&n.stage>e||(n.stage=e,n.time=0)}}class s{constructor(t){this._container=t,this._container.infecter=new o(this._container)}particleFillColor(t){const e=this._container.actualOptions;if(!t.infection||!e.infection)return;const i=t.infection.stage,n=e.infection.stages;return void 0===i?void 0:n[i]?.color}particleStrokeColor(t){return this.particleFillColor(t)}particlesSetup(){const t=this._container.actualOptions;if(t.infection)for(let e=0;e<t.infection.infections;e++){const t=this._container.particles.filter((t=>{const e=t;return e.infection??={},void 0===e.infection.stage})),e=(0,n.itemFromArray)(t);e&&this._container.infecter?.startInfection(e,0)}}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Infection Plugin v4.0.0-alpha.4 by Matteo Bruni */
@@ -1,13 +1,13 @@
1
1
  import { Infection } from "./Options/Classes/Infection.js";
2
- import { InfectionInstance } from "./InfectionInstance.js";
3
2
  export class InfectionPlugin {
4
3
  constructor() {
5
4
  this.id = "infection";
6
5
  }
7
- getPlugin(container) {
8
- return Promise.resolve(new InfectionInstance(container));
6
+ async getPlugin(container) {
7
+ const { InfectionPluginInstance } = await import("./InfectionPluginInstance.js");
8
+ return new InfectionPluginInstance(container);
9
9
  }
10
- loadOptions(options, source) {
10
+ loadOptions(_container, options, source) {
11
11
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
12
12
  return;
13
13
  }
@@ -1,7 +1,7 @@
1
1
  import { itemFromArray } from "@tsparticles/engine";
2
2
  import { Infecter } from "./Infecter.js";
3
3
  const minStage = 0;
4
- export class InfectionInstance {
4
+ export class InfectionPluginInstance {
5
5
  constructor(container) {
6
6
  this._container = container;
7
7
  this._container.infecter = new Infecter(this._container);
@@ -1,5 +1,6 @@
1
- import { ParticlesInteractorBase, getRandom } from "@tsparticles/engine";
2
- const minStagesCount = 1, double = 2;
1
+ import { double, getRandom } from "@tsparticles/engine";
2
+ import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
3
+ const minStagesCount = 1;
3
4
  export class ParticlesInfecter extends ParticlesInteractorBase {
4
5
  constructor(container) {
5
6
  super(container);
@@ -8,7 +9,7 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
8
9
  }
9
10
  init() {
10
11
  }
11
- interact(p1, delta) {
12
+ interact(p1, _interactivityData, delta) {
12
13
  const infecter = this.container.infecter;
13
14
  if (!infecter) {
14
15
  return;
package/browser/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export function loadInfectionPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
2
+ engine.checkVersion("4.0.0-alpha.4");
3
3
  engine.register(async (e) => {
4
- const { InfectionPlugin } = await import("./InfectionPlugin.js");
4
+ const { loadInteractivityPlugin } = await import("@tsparticles/plugin-interactivity"), { InfectionPlugin } = await import("./InfectionPlugin.js");
5
+ loadInteractivityPlugin(e);
5
6
  e.addPlugin(new InfectionPlugin());
6
- e.addInteractor("particlesInfection", async (container) => {
7
+ e.addInteractor?.("particlesInfection", async (container) => {
7
8
  const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
8
9
  return new ParticlesInfecter(container);
9
10
  });
@@ -1,13 +1,13 @@
1
1
  import { Infection } from "./Options/Classes/Infection.js";
2
- import { InfectionInstance } from "./InfectionInstance.js";
3
2
  export class InfectionPlugin {
4
3
  constructor() {
5
4
  this.id = "infection";
6
5
  }
7
- getPlugin(container) {
8
- return Promise.resolve(new InfectionInstance(container));
6
+ async getPlugin(container) {
7
+ const { InfectionPluginInstance } = await import("./InfectionPluginInstance.js");
8
+ return new InfectionPluginInstance(container);
9
9
  }
10
- loadOptions(options, source) {
10
+ loadOptions(_container, options, source) {
11
11
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
12
12
  return;
13
13
  }
@@ -1,7 +1,7 @@
1
1
  import { itemFromArray } from "@tsparticles/engine";
2
2
  import { Infecter } from "./Infecter.js";
3
3
  const minStage = 0;
4
- export class InfectionInstance {
4
+ export class InfectionPluginInstance {
5
5
  constructor(container) {
6
6
  this._container = container;
7
7
  this._container.infecter = new Infecter(this._container);
@@ -1,5 +1,6 @@
1
- import { ParticlesInteractorBase, getRandom } from "@tsparticles/engine";
2
- const minStagesCount = 1, double = 2;
1
+ import { double, getRandom } from "@tsparticles/engine";
2
+ import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
3
+ const minStagesCount = 1;
3
4
  export class ParticlesInfecter extends ParticlesInteractorBase {
4
5
  constructor(container) {
5
6
  super(container);
@@ -8,7 +9,7 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
8
9
  }
9
10
  init() {
10
11
  }
11
- interact(p1, delta) {
12
+ interact(p1, _interactivityData, delta) {
12
13
  const infecter = this.container.infecter;
13
14
  if (!infecter) {
14
15
  return;
package/cjs/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export function loadInfectionPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
2
+ engine.checkVersion("4.0.0-alpha.4");
3
3
  engine.register(async (e) => {
4
- const { InfectionPlugin } = await import("./InfectionPlugin.js");
4
+ const { loadInteractivityPlugin } = await import("@tsparticles/plugin-interactivity"), { InfectionPlugin } = await import("./InfectionPlugin.js");
5
+ loadInteractivityPlugin(e);
5
6
  e.addPlugin(new InfectionPlugin());
6
- e.addInteractor("particlesInfection", async (container) => {
7
+ e.addInteractor?.("particlesInfection", async (container) => {
7
8
  const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
8
9
  return new ParticlesInfecter(container);
9
10
  });
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.4
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_plugin_infection"] = this["webpackChunk_tsparticles_plugin_infection"] || []).push([["dist_browser_InfectionPluginInstance_js"],{
19
+
20
+ /***/ "./dist/browser/Infecter.js"
21
+ /*!**********************************!*\
22
+ !*** ./dist/browser/Infecter.js ***!
23
+ \**********************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Infecter: () => (/* binding */ Infecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minStage = 0,\n minDuration = 0;\nclass Infecter {\n constructor(container) {\n this._nextInfectionStage = particle => {\n const infectionOptions = this._container.actualOptions.infection,\n {\n infection\n } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stagesCount = infectionOptions.stages.length;\n if (stagesCount <= minStage || infection.stage === undefined) {\n return;\n }\n infection.time = 0;\n if (stagesCount <= ++infection.stage) {\n if (infectionOptions.cure) {\n delete infection.stage;\n delete infection.time;\n } else {\n infection.stage = 0;\n infection.time = 0;\n }\n }\n };\n this._container = container;\n }\n startInfection(particle, stage) {\n const infectionOptions = this._container.actualOptions.infection,\n {\n infection\n } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stages = infectionOptions.stages,\n stagesCount = stages.length;\n if (stage > stagesCount || stage < minStage) {\n return;\n }\n infection.delay = 0;\n infection.delayStage = stage;\n }\n updateInfection(particle, delta) {\n const infectionOptions = this._container.actualOptions.infection,\n {\n infection\n } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stages = infectionOptions.stages,\n stagesCount = stages.length;\n if (infection.delay !== undefined && infection.delayStage !== undefined) {\n const stage = infection.delayStage;\n if (stage > stagesCount || stage < minStage) {\n return;\n }\n if (infection.delay >= infectionOptions.delay * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds) {\n infection.stage = stage;\n infection.time = 0;\n delete infection.delay;\n delete infection.delayStage;\n } else {\n infection.delay += delta;\n }\n } else {\n delete infection.delay;\n delete infection.delayStage;\n }\n if (infection.stage !== undefined && infection.time !== undefined) {\n const infectionStage = stages[infection.stage];\n if (infectionStage?.duration !== undefined && infectionStage.duration >= minDuration) {\n if (infection.time > infectionStage.duration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds) {\n this._nextInfectionStage(particle);\n } else {\n infection.time += delta;\n }\n } else {\n infection.time += delta;\n }\n } else {\n delete infection.stage;\n delete infection.time;\n }\n }\n updateInfectionStage(particle, stage) {\n const options = this._container.actualOptions,\n {\n infection\n } = particle;\n if (!options.infection || !infection) {\n return;\n }\n const stagesCount = options.infection.stages.length;\n if (stage > stagesCount || stage < minStage || infection.stage !== undefined && infection.stage > stage) {\n return;\n }\n infection.stage = stage;\n infection.time = 0;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/Infecter.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/InfectionPluginInstance.js"
31
+ /*!*************************************************!*\
32
+ !*** ./dist/browser/InfectionPluginInstance.js ***!
33
+ \*************************************************/
34
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
+
36
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPluginInstance: () => (/* binding */ InfectionPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Infecter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Infecter.js */ \"./dist/browser/Infecter.js\");\n\n\nconst minStage = 0;\nclass InfectionPluginInstance {\n constructor(container) {\n this._container = container;\n this._container.infecter = new _Infecter_js__WEBPACK_IMPORTED_MODULE_1__.Infecter(this._container);\n }\n particleFillColor(particle) {\n const options = this._container.actualOptions;\n if (!particle.infection || !options.infection) {\n return;\n }\n const infectionStage = particle.infection.stage,\n infection = options.infection,\n infectionStages = infection.stages;\n return infectionStage === undefined ? undefined : infectionStages[infectionStage]?.color;\n }\n particleStrokeColor(particle) {\n return this.particleFillColor(particle);\n }\n particlesSetup() {\n const options = this._container.actualOptions;\n if (!options.infection) {\n return;\n }\n for (let i = 0; i < options.infection.infections; i++) {\n const notInfected = this._container.particles.filter(p => {\n const infP = p;\n infP.infection ??= {};\n return infP.infection.stage === undefined;\n });\n const infected = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(notInfected);\n if (!infected) {\n continue;\n }\n this._container.infecter?.startInfection(infected, minStage);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/InfectionPluginInstance.js?\n}");
37
+
38
+ /***/ }
39
+
40
+ }]);
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.4
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -17,33 +17,13 @@
17
17
  */
18
18
  (this["webpackChunk_tsparticles_plugin_infection"] = this["webpackChunk_tsparticles_plugin_infection"] || []).push([["dist_browser_InfectionPlugin_js"],{
19
19
 
20
- /***/ "./dist/browser/Infecter.js"
21
- /*!**********************************!*\
22
- !*** ./dist/browser/Infecter.js ***!
23
- \**********************************/
24
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
-
26
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Infecter: () => (/* binding */ Infecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minStage = 0,\n minDuration = 0;\nclass Infecter {\n constructor(container) {\n this._nextInfectionStage = particle => {\n const infectionOptions = this._container.actualOptions.infection,\n {\n infection\n } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stagesCount = infectionOptions.stages.length;\n if (stagesCount <= minStage || infection.stage === undefined) {\n return;\n }\n infection.time = 0;\n if (stagesCount <= ++infection.stage) {\n if (infectionOptions.cure) {\n delete infection.stage;\n delete infection.time;\n } else {\n infection.stage = 0;\n infection.time = 0;\n }\n }\n };\n this._container = container;\n }\n startInfection(particle, stage) {\n const infectionOptions = this._container.actualOptions.infection,\n {\n infection\n } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stages = infectionOptions.stages,\n stagesCount = stages.length;\n if (stage > stagesCount || stage < minStage) {\n return;\n }\n infection.delay = 0;\n infection.delayStage = stage;\n }\n updateInfection(particle, delta) {\n const infectionOptions = this._container.actualOptions.infection,\n {\n infection\n } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stages = infectionOptions.stages,\n stagesCount = stages.length;\n if (infection.delay !== undefined && infection.delayStage !== undefined) {\n const stage = infection.delayStage;\n if (stage > stagesCount || stage < minStage) {\n return;\n }\n if (infection.delay >= infectionOptions.delay * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds) {\n infection.stage = stage;\n infection.time = 0;\n delete infection.delay;\n delete infection.delayStage;\n } else {\n infection.delay += delta;\n }\n } else {\n delete infection.delay;\n delete infection.delayStage;\n }\n if (infection.stage !== undefined && infection.time !== undefined) {\n const infectionStage = stages[infection.stage];\n if (infectionStage?.duration !== undefined && infectionStage.duration >= minDuration) {\n if (infection.time > infectionStage.duration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds) {\n this._nextInfectionStage(particle);\n } else {\n infection.time += delta;\n }\n } else {\n infection.time += delta;\n }\n } else {\n delete infection.stage;\n delete infection.time;\n }\n }\n updateInfectionStage(particle, stage) {\n const options = this._container.actualOptions,\n {\n infection\n } = particle;\n if (!options.infection || !infection) {\n return;\n }\n const stagesCount = options.infection.stages.length;\n if (stage > stagesCount || stage < minStage || infection.stage !== undefined && infection.stage > stage) {\n return;\n }\n infection.stage = stage;\n infection.time = 0;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/Infecter.js?\n}");
27
-
28
- /***/ },
29
-
30
- /***/ "./dist/browser/InfectionInstance.js"
31
- /*!*******************************************!*\
32
- !*** ./dist/browser/InfectionInstance.js ***!
33
- \*******************************************/
34
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
35
-
36
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionInstance: () => (/* binding */ InfectionInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Infecter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Infecter.js */ \"./dist/browser/Infecter.js\");\n\n\nconst minStage = 0;\nclass InfectionInstance {\n constructor(container) {\n this._container = container;\n this._container.infecter = new _Infecter_js__WEBPACK_IMPORTED_MODULE_1__.Infecter(this._container);\n }\n particleFillColor(particle) {\n const options = this._container.actualOptions;\n if (!particle.infection || !options.infection) {\n return;\n }\n const infectionStage = particle.infection.stage,\n infection = options.infection,\n infectionStages = infection.stages;\n return infectionStage === undefined ? undefined : infectionStages[infectionStage]?.color;\n }\n particleStrokeColor(particle) {\n return this.particleFillColor(particle);\n }\n particlesSetup() {\n const options = this._container.actualOptions;\n if (!options.infection) {\n return;\n }\n for (let i = 0; i < options.infection.infections; i++) {\n const notInfected = this._container.particles.filter(p => {\n const infP = p;\n infP.infection ??= {};\n return infP.infection.stage === undefined;\n });\n const infected = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(notInfected);\n if (!infected) {\n continue;\n }\n this._container.infecter?.startInfection(infected, minStage);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/InfectionInstance.js?\n}");
37
-
38
- /***/ },
39
-
40
20
  /***/ "./dist/browser/InfectionPlugin.js"
41
21
  /*!*****************************************!*\
42
22
  !*** ./dist/browser/InfectionPlugin.js ***!
43
23
  \*****************************************/
44
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
45
25
 
46
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPlugin: () => (/* binding */ InfectionPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Infection.js */ \"./dist/browser/Options/Classes/Infection.js\");\n/* harmony import */ var _InfectionInstance_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./InfectionInstance.js */ \"./dist/browser/InfectionInstance.js\");\n\n\nclass InfectionPlugin {\n constructor() {\n this.id = \"infection\";\n }\n getPlugin(container) {\n return Promise.resolve(new _InfectionInstance_js__WEBPACK_IMPORTED_MODULE_1__.InfectionInstance(container));\n }\n loadOptions(options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let infectionOptions = options.infection;\n if (infectionOptions?.load === undefined) {\n options.infection = infectionOptions = new _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__.Infection();\n }\n infectionOptions.load(source?.infection);\n }\n needsPlugin(options) {\n return options?.infection?.enable ?? false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/InfectionPlugin.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPlugin: () => (/* binding */ InfectionPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Infection.js */ \"./dist/browser/Options/Classes/Infection.js\");\n\nclass InfectionPlugin {\n constructor() {\n this.id = \"infection\";\n }\n async getPlugin(container) {\n const {\n InfectionPluginInstance\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPluginInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPluginInstance.js */ \"./dist/browser/InfectionPluginInstance.js\"));\n return new InfectionPluginInstance(container);\n }\n loadOptions(_container, options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let infectionOptions = options.infection;\n if (infectionOptions?.load === undefined) {\n options.infection = infectionOptions = new _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__.Infection();\n }\n infectionOptions.load(source?.infection);\n }\n needsPlugin(options) {\n return options?.infection?.enable ?? false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/InfectionPlugin.js?\n}");
47
27
 
48
28
  /***/ },
49
29
 
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.4
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -23,7 +23,7 @@
23
23
  \*******************************************/
24
24
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
25
 
26
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesInfecter: () => (/* binding */ ParticlesInfecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minStagesCount = 1,\n double = 2;\nclass ParticlesInfecter extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticlesInteractorBase {\n constructor(container) {\n super(container);\n }\n clear() {}\n init() {}\n interact(p1, delta) {\n const infecter = this.container.infecter;\n if (!infecter) {\n return;\n }\n infecter.updateInfection(p1, delta.value);\n if (p1.infection?.stage === undefined) {\n return;\n }\n const container = this.container,\n options = container.actualOptions,\n infectionOptions = options.infection;\n if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {\n return;\n }\n const infectionStage1 = infectionOptions.stages[p1.infection.stage];\n if (!infectionStage1) {\n return;\n }\n const pxRatio = container.retina.pixelRatio,\n radius = p1.getRadius() * double + infectionStage1.radius * pxRatio,\n pos = p1.getPosition(),\n infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage,\n query = container.particles.quadTree.queryCircle(pos, radius),\n infections = infectionStage1.rate,\n neighbors = query.length;\n for (const p2 of query) {\n const infP2 = p2;\n if (infP2 === p1 || infP2.destroyed || infP2.spawning || !(infP2.infection?.stage === undefined || infP2.infection.stage !== p1.infection.stage) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() >= infections / neighbors) {\n continue;\n }\n if (infP2.infection?.stage === undefined) {\n infecter.startInfection(infP2, infectedStage1);\n } else if (infP2.infection.stage < p1.infection.stage) {\n infecter.updateInfectionStage(infP2, infectedStage1);\n } else if (infP2.infection.stage > p1.infection.stage) {\n const infectionStage2 = infectionOptions.stages[infP2.infection.stage];\n if (!infectionStage2) {\n continue;\n }\n const infectedStage2 = infectionStage2.infectedStage ?? infP2.infection.stage;\n infecter.updateInfectionStage(p1, infectedStage2);\n }\n }\n }\n isEnabled() {\n return this.container.actualOptions.infection?.enable ?? false;\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/ParticlesInfecter.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesInfecter: () => (/* binding */ ParticlesInfecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n\n\nconst minStagesCount = 1;\nclass ParticlesInfecter extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ParticlesInteractorBase {\n constructor(container) {\n super(container);\n }\n clear() {}\n init() {}\n interact(p1, _interactivityData, delta) {\n const infecter = this.container.infecter;\n if (!infecter) {\n return;\n }\n infecter.updateInfection(p1, delta.value);\n if (p1.infection?.stage === undefined) {\n return;\n }\n const container = this.container,\n options = container.actualOptions,\n infectionOptions = options.infection;\n if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {\n return;\n }\n const infectionStage1 = infectionOptions.stages[p1.infection.stage];\n if (!infectionStage1) {\n return;\n }\n const pxRatio = container.retina.pixelRatio,\n radius = p1.getRadius() * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double + infectionStage1.radius * pxRatio,\n pos = p1.getPosition(),\n infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage,\n query = container.particles.quadTree.queryCircle(pos, radius),\n infections = infectionStage1.rate,\n neighbors = query.length;\n for (const p2 of query) {\n const infP2 = p2;\n if (infP2 === p1 || infP2.destroyed || infP2.spawning || !(infP2.infection?.stage === undefined || infP2.infection.stage !== p1.infection.stage) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() >= infections / neighbors) {\n continue;\n }\n if (infP2.infection?.stage === undefined) {\n infecter.startInfection(infP2, infectedStage1);\n } else if (infP2.infection.stage < p1.infection.stage) {\n infecter.updateInfectionStage(infP2, infectedStage1);\n } else if (infP2.infection.stage > p1.infection.stage) {\n const infectionStage2 = infectionOptions.stages[infP2.infection.stage];\n if (!infectionStage2) {\n continue;\n }\n const infectedStage2 = infectionStage2.infectedStage ?? infP2.infection.stage;\n infecter.updateInfectionStage(p1, infectedStage2);\n }\n }\n }\n isEnabled() {\n return this.container.actualOptions.infection?.enable ?? false;\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/ParticlesInfecter.js?\n}");
27
27
 
28
28
  /***/ }
29
29
 
@@ -1,13 +1,13 @@
1
1
  import { Infection } from "./Options/Classes/Infection.js";
2
- import { InfectionInstance } from "./InfectionInstance.js";
3
2
  export class InfectionPlugin {
4
3
  constructor() {
5
4
  this.id = "infection";
6
5
  }
7
- getPlugin(container) {
8
- return Promise.resolve(new InfectionInstance(container));
6
+ async getPlugin(container) {
7
+ const { InfectionPluginInstance } = await import("./InfectionPluginInstance.js");
8
+ return new InfectionPluginInstance(container);
9
9
  }
10
- loadOptions(options, source) {
10
+ loadOptions(_container, options, source) {
11
11
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
12
12
  return;
13
13
  }
@@ -1,7 +1,7 @@
1
1
  import { itemFromArray } from "@tsparticles/engine";
2
2
  import { Infecter } from "./Infecter.js";
3
3
  const minStage = 0;
4
- export class InfectionInstance {
4
+ export class InfectionPluginInstance {
5
5
  constructor(container) {
6
6
  this._container = container;
7
7
  this._container.infecter = new Infecter(this._container);
@@ -1,5 +1,6 @@
1
- import { ParticlesInteractorBase, getRandom } from "@tsparticles/engine";
2
- const minStagesCount = 1, double = 2;
1
+ import { double, getRandom } from "@tsparticles/engine";
2
+ import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
3
+ const minStagesCount = 1;
3
4
  export class ParticlesInfecter extends ParticlesInteractorBase {
4
5
  constructor(container) {
5
6
  super(container);
@@ -8,7 +9,7 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
8
9
  }
9
10
  init() {
10
11
  }
11
- interact(p1, delta) {
12
+ interact(p1, _interactivityData, delta) {
12
13
  const infecter = this.container.infecter;
13
14
  if (!infecter) {
14
15
  return;
package/esm/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export function loadInfectionPlugin(engine) {
2
- engine.checkVersion("4.0.0-alpha.2");
2
+ engine.checkVersion("4.0.0-alpha.4");
3
3
  engine.register(async (e) => {
4
- const { InfectionPlugin } = await import("./InfectionPlugin.js");
4
+ const { loadInteractivityPlugin } = await import("@tsparticles/plugin-interactivity"), { InfectionPlugin } = await import("./InfectionPlugin.js");
5
+ loadInteractivityPlugin(e);
5
6
  e.addPlugin(new InfectionPlugin());
6
- e.addInteractor("particlesInfection", async (container) => {
7
+ e.addInteractor?.("particlesInfection", async (container) => {
7
8
  const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
8
9
  return new ParticlesInfecter(container);
9
10
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-infection",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.4",
4
4
  "description": "tsParticles infection plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,7 +100,8 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "4.0.0-alpha.2"
103
+ "@tsparticles/engine": "4.0.0-alpha.4",
104
+ "@tsparticles/plugin-interactivity": "4.0.0-alpha.4"
104
105
  },
105
106
  "publishConfig": {
106
107
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/plugin-infection [8 Jan 2026 at 10:13]</title>
6
+ <title>@tsparticles/plugin-infection [21 Jan 2026 at 14:46]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.4
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -16,14 +16,14 @@
16
16
  */
17
17
  (function webpackUniversalModuleDefinition(root, factory) {
18
18
  if(typeof exports === 'object' && typeof module === 'object')
19
- module.exports = factory(require("@tsparticles/engine"));
19
+ module.exports = factory(require("@tsparticles/plugin-interactivity"), require("@tsparticles/engine"));
20
20
  else if(typeof define === 'function' && define.amd)
21
- define(["@tsparticles/engine"], factory);
21
+ define(["@tsparticles/plugin-interactivity", "@tsparticles/engine"], factory);
22
22
  else {
23
- var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
23
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/plugin-interactivity"), require("@tsparticles/engine")) : factory(root["window"], root["window"]);
24
24
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
25
25
  }
26
- })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__, __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
27
27
  return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
34
34
  \*******************************/
35
35
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
36
36
 
37
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadInfectionPlugin: () => (/* binding */ loadInfectionPlugin)\n/* harmony export */ });\nfunction loadInfectionPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.2\");\n engine.register(async e => {\n const {\n InfectionPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPlugin.js */ \"./dist/browser/InfectionPlugin.js\"));\n e.addPlugin(new InfectionPlugin());\n e.addInteractor(\"particlesInfection\", async container => {\n const {\n ParticlesInfecter\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ParticlesInfecter_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ParticlesInfecter.js */ \"./dist/browser/ParticlesInfecter.js\"));\n return new ParticlesInfecter(container);\n });\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/index.js?\n}");
37
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadInfectionPlugin: () => (/* binding */ loadInfectionPlugin)\n/* harmony export */ });\nfunction loadInfectionPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.4\");\n engine.register(async e => {\n const {\n loadInteractivityPlugin\n } = await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19)),\n {\n InfectionPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPlugin.js */ \"./dist/browser/InfectionPlugin.js\"));\n loadInteractivityPlugin(e);\n e.addPlugin(new InfectionPlugin());\n e.addInteractor?.(\"particlesInfection\", async container => {\n const {\n ParticlesInfecter\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ParticlesInfecter_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ParticlesInfecter.js */ \"./dist/browser/ParticlesInfecter.js\"));\n return new ParticlesInfecter(container);\n });\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/index.js?\n}");
38
38
 
39
39
  /***/ },
40
40
 
@@ -46,6 +46,16 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
46
46
 
47
47
  module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
48
48
 
49
+ /***/ },
50
+
51
+ /***/ "@tsparticles/plugin-interactivity"
52
+ /*!***************************************************************************************************************************************************************************!*\
53
+ !*** external {"commonjs":"@tsparticles/plugin-interactivity","commonjs2":"@tsparticles/plugin-interactivity","amd":"@tsparticles/plugin-interactivity","root":"window"} ***!
54
+ \***************************************************************************************************************************************************************************/
55
+ (module) {
56
+
57
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
58
+
49
59
  /***/ }
50
60
 
51
61
  /******/ });
@@ -84,6 +94,36 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
84
94
  /******/ __webpack_require__.m = __webpack_modules__;
85
95
  /******/
86
96
  /************************************************************************/
97
+ /******/ /* webpack/runtime/create fake namespace object */
98
+ /******/ (() => {
99
+ /******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
100
+ /******/ var leafPrototypes;
101
+ /******/ // create a fake namespace object
102
+ /******/ // mode & 1: value is a module id, require it
103
+ /******/ // mode & 2: merge all properties of value into the ns
104
+ /******/ // mode & 4: return value when already ns object
105
+ /******/ // mode & 16: return value when it's Promise-like
106
+ /******/ // mode & 8|1: behave like require
107
+ /******/ __webpack_require__.t = function(value, mode) {
108
+ /******/ if(mode & 1) value = this(value);
109
+ /******/ if(mode & 8) return value;
110
+ /******/ if(typeof value === 'object' && value) {
111
+ /******/ if((mode & 4) && value.__esModule) return value;
112
+ /******/ if((mode & 16) && typeof value.then === 'function') return value;
113
+ /******/ }
114
+ /******/ var ns = Object.create(null);
115
+ /******/ __webpack_require__.r(ns);
116
+ /******/ var def = {};
117
+ /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
118
+ /******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
119
+ /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
120
+ /******/ }
121
+ /******/ def['default'] = () => (value);
122
+ /******/ __webpack_require__.d(ns, def);
123
+ /******/ return ns;
124
+ /******/ };
125
+ /******/ })();
126
+ /******/
87
127
  /******/ /* webpack/runtime/define property getters */
88
128
  /******/ (() => {
89
129
  /******/ // define getter functions for harmony exports
@@ -118,18 +158,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
118
158
  /******/ };
119
159
  /******/ })();
120
160
  /******/
121
- /******/ /* webpack/runtime/global */
122
- /******/ (() => {
123
- /******/ __webpack_require__.g = (function() {
124
- /******/ if (typeof globalThis === 'object') return globalThis;
125
- /******/ try {
126
- /******/ return this || new Function('return this')();
127
- /******/ } catch (e) {
128
- /******/ if (typeof window === 'object') return window;
129
- /******/ }
130
- /******/ })();
131
- /******/ })();
132
- /******/
133
161
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
134
162
  /******/ (() => {
135
163
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
@@ -194,8 +222,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
194
222
  /******/ /* webpack/runtime/publicPath */
195
223
  /******/ (() => {
196
224
  /******/ var scriptUrl;
197
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
198
- /******/ var document = __webpack_require__.g.document;
225
+ /******/ if (globalThis.importScripts) scriptUrl = globalThis.location + "";
226
+ /******/ var document = globalThis.document;
199
227
  /******/ if (!scriptUrl && document) {
200
228
  /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
201
229
  /******/ scriptUrl = document.currentScript.src;
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.plugin.infection.min.js.LICENSE.txt */
2
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(e=>(()=>{var t,r,n={303(t){t.exports=e}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var r=o[e]={exports:{}};return n[e](r,r.exports,i),r.exports}i.m=n,i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce(((t,r)=>(i.f[r](e,t),t)),[])),i.u=e=>e+".min.js",i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/plugin-infection:",i.l=(e,n,o,a)=>{if(t[e])t[e].push(n);else{var c,s;if(void 0!==o)for(var l=document.getElementsByTagName("script"),p=0;p<l.length;p++){var u=l[p];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+o){c=u;break}}c||(s=!0,(c=document.createElement("script")).charset="utf-8",i.nc&&c.setAttribute("nonce",i.nc),c.setAttribute("data-webpack",r+o),c.src=e),t[e]=[n];var d=(r,n)=>{c.onerror=c.onload=null,clearTimeout(f);var o=t[e];if(delete t[e],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach((e=>e(n))),r)return r(n)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=d.bind(null,c.onerror),c.onload=d.bind(null,c.onload),s&&document.head.appendChild(c)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.g.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 n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={587:0};i.f.j=(t,r)=>{var n=i.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var o=new Promise(((r,o)=>n=e[t]=[r,o]));r.push(n[2]=o);var a=i.p+i.u(t),c=new Error;i.l(a,(r=>{if(i.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var o=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;c.message="Loading chunk "+t+" failed.\n("+o+": "+a+")",c.name="ChunkLoadError",c.type=o,c.request=a,n[1](c)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,o,[a,c,s]=r,l=0;if(a.some((t=>0!==e[t]))){for(n in c)i.o(c,n)&&(i.m[n]=c[n]);if(s)s(i)}for(t&&t(r);l<a.length;l++)o=a[l],i.o(e,o)&&e[o]&&e[o][0](),e[o]=0},r=this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};function c(e){e.checkVersion("4.0.0-alpha.2"),e.register((async e=>{const{InfectionPlugin:t}=await i.e(492).then(i.bind(i,492));e.addPlugin(new t),e.addInteractor("particlesInfection",(async e=>{const{ParticlesInfecter:t}=await i.e(796).then(i.bind(i,796));return new t(e)}))}))}return i.r(a),i.d(a,{loadInfectionPlugin:()=>c}),a})()));
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 n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,((e,t)=>(()=>{var r,n,i,o,a={303(e){e.exports=t},702(t){t.exports=e}},c={};function l(e){var t=c[e];if(void 0!==t)return t.exports;var r=c[e]={exports:{}};return a[e](r,r.exports,l),r.exports}l.m=a,n=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 i=Object.create(null);l.r(i);var o={};r=r||[null,n({}),n([]),n(n)];for(var a=2&t&&e;("object"==typeof a||"function"==typeof a)&&!~r.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>o[t]=()=>e[t]));return o.default=()=>e,l.d(i,o),i},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),i={},o="@tsparticles/plugin-infection:",l.l=(e,t,r,n)=>{if(i[e])i[e].push(t);else{var a,c;if(void 0!==r)for(var s=document.getElementsByTagName("script"),p=0;p<s.length;p++){var u=s[p];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==o+r){a=u;break}}a||(c=!0,(a=document.createElement("script")).charset="utf-8",l.nc&&a.setAttribute("nonce",l.nc),a.setAttribute("data-webpack",o+r),a.src=e),i[e]=[t];var f=(t,r)=>{a.onerror=a.onload=null,clearTimeout(d);var n=i[e];if(delete i[e],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach((e=>e(r))),t)return t(r)},d=setTimeout(f.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=f.bind(null,a.onerror),a.onload=f.bind(null,a.onload),c&&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 n=r.length-1;n>-1&&(!e||!/^http(s?):/.test(e));)e=r[n--].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={587:0};l.f.j=(t,r)=>{var n=l.o(e,t)?e[t]:void 0;if(0!==n)if(n)r.push(n[2]);else{var i=new Promise(((r,i)=>n=e[t]=[r,i]));r.push(n[2]=i);var o=l.p+l.u(t),a=new Error;l.l(o,(r=>{if(l.o(e,t)&&(0!==(n=e[t])&&(e[t]=void 0),n)){var i=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+i+": "+o+")",a.name="ChunkLoadError",a.type=i,a.request=o,n[1](a)}}),"chunk-"+t,t)}};var t=(t,r)=>{var n,i,[o,a,c]=r,s=0;if(o.some((t=>0!==e[t]))){for(n in a)l.o(a,n)&&(l.m[n]=a[n]);if(c)c(l)}for(t&&t(r);s<o.length;s++)i=o[s],l.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var s={};function p(e){e.checkVersion("4.0.0-alpha.4"),e.register((async e=>{const{loadInteractivityPlugin:t}=await Promise.resolve().then(l.t.bind(l,702,19)),{InfectionPlugin:r}=await l.e(713).then(l.bind(l,713));t(e),e.addPlugin(new r),e.addInteractor?.("particlesInfection",(async e=>{const{ParticlesInfecter:t}=await l.e(249).then(l.bind(l,249));return new t(e)}))}))}return l.r(s),l.d(s,{loadInfectionPlugin:()=>p}),s})()));
@@ -1 +1 @@
1
- /*! tsParticles Infection Plugin v4.0.0-alpha.2 by Matteo Bruni */
1
+ /*! tsParticles Infection Plugin v4.0.0-alpha.4 by Matteo Bruni */
@@ -1,10 +1,9 @@
1
- import type { Container, IPlugin, RecursivePartial } from "@tsparticles/engine";
1
+ import type { Container, IContainerPlugin, IPlugin, RecursivePartial } from "@tsparticles/engine";
2
2
  import type { IInfectionOptions, InfectionOptions } from "./Types.js";
3
- import { InfectionInstance } from "./InfectionInstance.js";
4
3
  export declare class InfectionPlugin implements IPlugin {
5
4
  readonly id: string;
6
5
  constructor();
7
- getPlugin(container: Container): Promise<InfectionInstance>;
8
- loadOptions(options: InfectionOptions, source?: RecursivePartial<IInfectionOptions>): void;
6
+ getPlugin(container: Container): Promise<IContainerPlugin>;
7
+ loadOptions(_container: Container, options: InfectionOptions, source?: RecursivePartial<IInfectionOptions>): void;
9
8
  needsPlugin(options?: RecursivePartial<IInfectionOptions>): boolean;
10
9
  }
@@ -1,6 +1,6 @@
1
1
  import { type IContainerPlugin, type IOptionsColor, type Particle } from "@tsparticles/engine";
2
2
  import type { InfectableContainer, InfectableParticle } from "./Types.js";
3
- export declare class InfectionInstance implements IContainerPlugin {
3
+ export declare class InfectionPluginInstance implements IContainerPlugin {
4
4
  private readonly _container;
5
5
  constructor(container: InfectableContainer);
6
6
  particleFillColor(particle: InfectableParticle): string | IOptionsColor | undefined;
@@ -1,10 +1,11 @@
1
- import { type IDelta, ParticlesInteractorBase } from "@tsparticles/engine";
1
+ import { type IDelta } from "@tsparticles/engine";
2
+ import { type IInteractivityData, ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
2
3
  import type { InfectableContainer, InfectableParticle } from "./Types.js";
3
4
  export declare class ParticlesInfecter extends ParticlesInteractorBase<InfectableContainer> {
4
5
  constructor(container: InfectableContainer);
5
6
  clear(): void;
6
7
  init(): void;
7
- interact(p1: InfectableParticle, delta: IDelta): void;
8
+ interact(p1: InfectableParticle, _interactivityData: IInteractivityData, delta: IDelta): void;
8
9
  isEnabled(): boolean;
9
10
  reset(): void;
10
11
  }
package/types/Types.d.ts CHANGED
@@ -1,21 +1,22 @@
1
- import type { Container, IOptions, Options, Particle } from "@tsparticles/engine";
1
+ import type { IInteractivityOptions, InteractivityContainer, InteractivityOptions } from "@tsparticles/plugin-interactivity";
2
2
  import type { IInfection } from "./Options/Interfaces/IInfection.js";
3
3
  import type { Infecter } from "./Infecter.js";
4
4
  import type { Infection } from "./Options/Classes/Infection.js";
5
+ import type { Particle } from "@tsparticles/engine";
5
6
  export interface IParticleInfection {
6
7
  delay?: number;
7
8
  delayStage?: number;
8
9
  stage?: number;
9
10
  time?: number;
10
11
  }
11
- export type InfectableContainer = Container & {
12
+ export type InfectableContainer = InteractivityContainer & {
12
13
  actualOptions: InfectionOptions;
13
14
  infecter?: Infecter;
14
15
  };
15
- export type IInfectionOptions = IOptions & {
16
+ export type IInfectionOptions = IInteractivityOptions & {
16
17
  infection: IInfection;
17
18
  };
18
- export type InfectionOptions = Options & {
19
+ export type InfectionOptions = InteractivityOptions & {
19
20
  infection?: Infection;
20
21
  };
21
22
  export type InfectableParticle = Particle & {
@@ -1,25 +1,59 @@
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
+ })();
1
34
  (function (factory) {
2
35
  if (typeof module === "object" && typeof module.exports === "object") {
3
36
  var v = factory(require, exports);
4
37
  if (v !== undefined) module.exports = v;
5
38
  }
6
39
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Options/Classes/Infection.js", "./InfectionInstance.js"], factory);
40
+ define(["require", "exports", "./Options/Classes/Infection.js"], factory);
8
41
  }
9
42
  })(function (require, exports) {
10
43
  "use strict";
44
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
45
  Object.defineProperty(exports, "__esModule", { value: true });
12
46
  exports.InfectionPlugin = void 0;
13
47
  const Infection_js_1 = require("./Options/Classes/Infection.js");
14
- const InfectionInstance_js_1 = require("./InfectionInstance.js");
15
48
  class InfectionPlugin {
16
49
  constructor() {
17
50
  this.id = "infection";
18
51
  }
19
- getPlugin(container) {
20
- return Promise.resolve(new InfectionInstance_js_1.InfectionInstance(container));
52
+ async getPlugin(container) {
53
+ const { InfectionPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./InfectionPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./InfectionPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
54
+ return new InfectionPluginInstance(container);
21
55
  }
22
- loadOptions(options, source) {
56
+ loadOptions(_container, options, source) {
23
57
  if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
24
58
  return;
25
59
  }
@@ -9,11 +9,11 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.InfectionInstance = void 0;
12
+ exports.InfectionPluginInstance = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const Infecter_js_1 = require("./Infecter.js");
15
15
  const minStage = 0;
16
- class InfectionInstance {
16
+ class InfectionPluginInstance {
17
17
  constructor(container) {
18
18
  this._container = container;
19
19
  this._container.infecter = new Infecter_js_1.Infecter(this._container);
@@ -48,5 +48,5 @@
48
48
  }
49
49
  }
50
50
  }
51
- exports.InfectionInstance = InfectionInstance;
51
+ exports.InfectionPluginInstance = InfectionPluginInstance;
52
52
  });
@@ -4,15 +4,16 @@
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"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "@tsparticles/plugin-interactivity"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ParticlesInfecter = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- const minStagesCount = 1, double = 2;
15
- class ParticlesInfecter extends engine_1.ParticlesInteractorBase {
14
+ const plugin_interactivity_1 = require("@tsparticles/plugin-interactivity");
15
+ const minStagesCount = 1;
16
+ class ParticlesInfecter extends plugin_interactivity_1.ParticlesInteractorBase {
16
17
  constructor(container) {
17
18
  super(container);
18
19
  }
@@ -20,7 +21,7 @@
20
21
  }
21
22
  init() {
22
23
  }
23
- interact(p1, delta) {
24
+ interact(p1, _interactivityData, delta) {
24
25
  const infecter = this.container.infecter;
25
26
  if (!infecter) {
26
27
  return;
@@ -37,7 +38,7 @@
37
38
  if (!infectionStage1) {
38
39
  return;
39
40
  }
40
- const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
41
+ const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * engine_1.double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.quadTree.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
41
42
  for (const p2 of query) {
42
43
  const infP2 = p2;
43
44
  if (infP2 === p1 ||
package/umd/index.js CHANGED
@@ -45,12 +45,13 @@ var __importStar = (this && this.__importStar) || (function () {
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.loadInfectionPlugin = loadInfectionPlugin;
47
47
  function loadInfectionPlugin(engine) {
48
- engine.checkVersion("4.0.0-alpha.2");
48
+ engine.checkVersion("4.0.0-alpha.4");
49
49
  engine.register(async (e) => {
50
- const { InfectionPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./InfectionPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./InfectionPlugin.js"], resolve_1, reject_1); }).then(__importStar));
50
+ const { loadInteractivityPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("@tsparticles/plugin-interactivity"))) : new Promise((resolve_1, reject_1) => { require(["@tsparticles/plugin-interactivity"], resolve_1, reject_1); }).then(__importStar)), { InfectionPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./InfectionPlugin.js"))) : new Promise((resolve_2, reject_2) => { require(["./InfectionPlugin.js"], resolve_2, reject_2); }).then(__importStar));
51
+ loadInteractivityPlugin(e);
51
52
  e.addPlugin(new InfectionPlugin());
52
- e.addInteractor("particlesInfection", async (container) => {
53
- const { ParticlesInfecter } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ParticlesInfecter.js"))) : new Promise((resolve_2, reject_2) => { require(["./ParticlesInfecter.js"], resolve_2, reject_2); }).then(__importStar));
53
+ e.addInteractor?.("particlesInfection", async (container) => {
54
+ const { ParticlesInfecter } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ParticlesInfecter.js"))) : new Promise((resolve_3, reject_3) => { require(["./ParticlesInfecter.js"], resolve_3, reject_3); }).then(__importStar));
54
55
  return new ParticlesInfecter(container);
55
56
  });
56
57
  });
package/492.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 492.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[492],{492(t,e,i){i.d(e,{InfectionPlugin:()=>r});var n=i(303);class o{constructor(){this.color=new n.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(t){(0,n.isNull)(t)||(void 0!==t.color&&(this.color=n.OptionsColor.create(this.color,t.color)),this.duration=t.duration,this.infectedStage=t.infectedStage,void 0!==t.radius&&(this.radius=t.radius),void 0!==t.rate&&(this.rate=t.rate))}}class s{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(t){(0,n.isNull)(t)||(void 0!==t.cure&&(this.cure=t.cure),void 0!==t.delay&&(this.delay=t.delay),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.infections&&(this.infections=t.infections),void 0!==t.stages&&(this.stages=t.stages.map((t=>{const e=new o;return e.load(t),e}))))}}class a{constructor(t){this._nextInfectionStage=t=>{const e=this._container.actualOptions.infection,{infection:i}=t;if(!e||!i)return;const n=e.stages.length;n<=0||void 0===i.stage||(i.time=0,n<=++i.stage&&(e.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))},this._container=t}startInfection(t,e){const i=this._container.actualOptions.infection,{infection:n}=t;if(!i||!n)return;e>i.stages.length||e<0||(n.delay=0,n.delayStage=e)}updateInfection(t,e){const i=this._container.actualOptions.infection,{infection:o}=t;if(!i||!o)return;const s=i.stages,a=s.length;if(void 0!==o.delay&&void 0!==o.delayStage){const t=o.delayStage;if(t>a||t<0)return;o.delay>=i.delay*n.millisecondsToSeconds?(o.stage=t,o.time=0,delete o.delay,delete o.delayStage):o.delay+=e}else delete o.delay,delete o.delayStage;if(void 0!==o.stage&&void 0!==o.time){const i=s[o.stage];void 0!==i?.duration&&i.duration>=0&&o.time>i.duration*n.millisecondsToSeconds?this._nextInfectionStage(t):o.time+=e}else delete o.stage,delete o.time}updateInfectionStage(t,e){const i=this._container.actualOptions,{infection:n}=t;if(!i.infection||!n)return;e>i.infection.stages.length||e<0||void 0!==n.stage&&n.stage>e||(n.stage=e,n.time=0)}}class c{constructor(t){this._container=t,this._container.infecter=new a(this._container)}particleFillColor(t){const e=this._container.actualOptions;if(!t.infection||!e.infection)return;const i=t.infection.stage,n=e.infection.stages;return void 0===i?void 0:n[i]?.color}particleStrokeColor(t){return this.particleFillColor(t)}particlesSetup(){const t=this._container.actualOptions;if(t.infection)for(let e=0;e<t.infection.infections;e++){const t=this._container.particles.filter((t=>{const e=t;return e.infection??={},void 0===e.infection.stage})),e=(0,n.itemFromArray)(t);e&&this._container.infecter?.startInfection(e,0)}}}class r{constructor(){this.id="infection"}getPlugin(t){return Promise.resolve(new c(t))}loadOptions(t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let i=t.infection;void 0===i?.load&&(t.infection=i=new s),i.load(e?.infection)}needsPlugin(t){return t?.infection?.enable??!1}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Infection Plugin v4.0.0-alpha.2 by Matteo Bruni */
package/796.min.js DELETED
@@ -1,2 +0,0 @@
1
- /*! For license information please see 796.min.js.LICENSE.txt */
2
- (this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[796],{796(t,e,n){n.d(e,{ParticlesInfecter:()=>s});var i=n(303);class s extends i.ParticlesInteractorBase{constructor(t){super(t)}clear(){}init(){}interact(t,e){const n=this.container.infecter;if(!n)return;if(n.updateInfection(t,e.value),void 0===t.infection?.stage)return;const s=this.container,a=s.actualOptions.infection;if(!a?.enable||a.stages.length<1)return;const c=a.stages[t.infection.stage];if(!c)return;const o=s.retina.pixelRatio,r=2*t.getRadius()+c.radius*o,f=t.getPosition(),g=c.infectedStage??t.infection.stage,u=s.particles.quadTree.queryCircle(f,r),l=c.rate,d=u.length;for(const e of u){const s=e;if(!(s===t||s.destroyed||s.spawning||void 0!==s.infection?.stage&&s.infection.stage===t.infection.stage||(0,i.getRandom)()>=l/d))if(void 0===s.infection?.stage)n.startInfection(s,g);else if(s.infection.stage<t.infection.stage)n.updateInfectionStage(s,g);else if(s.infection.stage>t.infection.stage){const e=a.stages[s.infection.stage];if(!e)continue;const i=e.infectedStage??s.infection.stage;n.updateInfectionStage(t,i)}}}isEnabled(){return this.container.actualOptions.infection?.enable??!1}reset(){}}}}]);
@@ -1 +0,0 @@
1
- /*! tsParticles Infection Plugin v4.0.0-alpha.2 by Matteo Bruni */