@tsparticles/plugin-infection 4.0.0-beta.0 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[800],{800(e,t,i){i.d(t,{InfectionPluginInstance:()=>o});var n=i(303);class a{_container;constructor(e){this._container=e}startInfection(e,t){let i=this._container.actualOptions.infection,{infection:n}=e;!i||!n||t>i.stages.length||t<0||(n.delay=0,n.delayStage=t)}updateInfection(e,t){let i=this._container.actualOptions.infection,{infection:a}=e;if(!i||!a)return;let o=i.stages,s=o.length;if(void 0!==a.delay&&void 0!==a.delayStage){let e=a.delayStage;if(e>s||e<0)return;a.delay>=i.delay*n.millisecondsToSeconds?(a.stage=e,a.time=0,delete a.delay,delete a.delayStage):a.delay+=t}else delete a.delay,delete a.delayStage;if(void 0!==a.stage&&void 0!==a.time){let i=o[a.stage];i?.duration!==void 0&&i.duration>=0&&a.time>i.duration*n.millisecondsToSeconds?this._nextInfectionStage(e):a.time+=t}else delete a.stage,delete a.time}updateInfectionStage(e,t){let i=this._container.actualOptions,{infection:n}=e;!i.infection||!n||t>i.infection.stages.length||t<0||void 0!==n.stage&&n.stage>t||(n.stage=t,n.time=0)}_nextInfectionStage=e=>{let t=this._container.actualOptions.infection,{infection:i}=e;if(!t||!i)return;let n=t.stages.length;!(n<=0)&&void 0!==i.stage&&(i.time=0,n<=++i.stage&&(t.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))}}class o{_container;constructor(e){this._container=e,this._container.infecter=new a(this._container)}particleFillColor(e){let t=this._container.actualOptions;if(!e.infection||!t.infection)return;let i=e.infection.stage,n=t.infection.stages;return void 0===i?void 0:n[i]?.color}particleStrokeColor(e){return this.particleFillColor(e)}particlesSetup(){let e=this._container.actualOptions;if(e.infection)for(let t=0;t<e.infection.infections;t++){let e=this._container.particles.filter(e=>(e.infection??={},void 0===e.infection.stage)),t=(0,n.itemFromArray)(e);t&&this._container.infecter?.startInfection(t,0)}}}}}]);
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[321],{321(e,t,i){i.d(t,{InfectionPluginInstance:()=>o});var n=i(303);class a{_container;constructor(e){this._container=e}startInfection(e,t){let i=this._container.actualOptions.infection,{infection:n}=e;!i||!n||t>i.stages.length||t<0||(n.delay=0,n.delayStage=t)}updateInfection(e,t){let i=this._container.actualOptions.infection,{infection:a}=e;if(!i||!a)return;let o=i.stages,s=o.length;if(void 0!==a.delay&&void 0!==a.delayStage){let e=a.delayStage;if(e>s||e<0)return;a.delay>=i.delay*n.millisecondsToSeconds?(a.stage=e,a.time=0,delete a.delay,delete a.delayStage):a.delay+=t}else delete a.delay,delete a.delayStage;if(void 0!==a.stage&&void 0!==a.time){let i=o[a.stage];i?.duration!==void 0&&i.duration>=0&&a.time>i.duration*n.millisecondsToSeconds?this._nextInfectionStage(e):a.time+=t}else delete a.stage,delete a.time}updateInfectionStage(e,t){let i=this._container.actualOptions,{infection:n}=e;!i.infection||!n||t>i.infection.stages.length||t<0||void 0!==n.stage&&n.stage>t||(n.stage=t,n.time=0)}_nextInfectionStage=e=>{let t=this._container.actualOptions.infection,{infection:i}=e;if(!t||!i)return;let n=t.stages.length;!(n<=0)&&void 0!==i.stage&&(i.time=0,n<=++i.stage&&(t.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))}}class o{_container;constructor(e){this._container=e,this._container.infecter=new a(this._container)}particleFillColor(e){let t=this._container.actualOptions;if(!e.infection||!t.infection)return;let i=e.infection.stage,n=t.infection.stages;return void 0===i?void 0:n[i]?.color}particleStrokeColor(e){return this.particleFillColor(e)}particlesSetup(){let e=this._container.actualOptions;if(e.infection)for(let t=0;t<e.infection.infections;t++){let e=this._container.particles.filter(e=>(e.infection??={},void 0===e.infection.stage)),t=(0,n.itemFromArray)(e);t&&this._container.infecter?.startInfection(t,0)}}}}}]);
@@ -1 +1 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[392],{392(i,e,t){t.r(e),t.d(e,{InfectionPlugin:()=>a});var s=t(303);class n{color;duration;infectedStage;radius;rate;constructor(){this.color=new s.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(i){(0,s.isNull)(i)||(void 0!==i.color&&(this.color=s.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{cure;delay;enable;infections;stages;constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(i){(0,s.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=>{let e=new n;return e.load(i),e})))}}class a{id="infection";async getPlugin(i){let{InfectionPluginInstance:e}=await t.e(800).then(t.bind(t,800));return new e(i)}loadOptions(i,e,t){if(!this.needsPlugin(e)&&!this.needsPlugin(t))return;let s=e.infection;s?.load===void 0&&(e.infection=s=new o),s.load(t?.infection)}needsPlugin(i){return i?.infection?.enable??!1}}}}]);
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[734],{734(i,e,t){t.r(e),t.d(e,{InfectionPlugin:()=>a});var s=t(303);class n{color;duration;infectedStage;radius;rate;constructor(){this.color=new s.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(i){(0,s.isNull)(i)||(void 0!==i.color&&(this.color=s.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{cure;delay;enable;infections;stages;constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(i){(0,s.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=>{let e=new n;return e.load(i),e})))}}class a{id="infection";async getPlugin(i){let{InfectionPluginInstance:e}=await t.e(321).then(t.bind(t,321));return new e(i)}loadOptions(i,e,t){if(!this.needsPlugin(e)&&!this.needsPlugin(t))return;let s=e.infection;s?.load===void 0&&(e.infection=s=new o),s.load(t?.infection)}needsPlugin(i){return i?.infection?.enable??!1}}}}]);
package/951.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[951],{951(e,t,i){i.d(t,{ParticlesInfecter:()=>s});var n=i(303),a=i(702);class s extends a.ParticlesInteractorBase{_maxDistance;constructor(e){super(e),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(){}init(){}interact(e,t,i){let a=this.container.infecter;if(!a||(a.updateInfection(e,i.value),e.infection?.stage===void 0))return;let s=this.container,c=s.actualOptions.infection;if(!c?.enable||c.stages.length<1)return;let o=c.stages[e.infection.stage];if(!o)return;this._maxDistance=Math.max(this._maxDistance,o.radius);let r=s.retina.pixelRatio,f=e.getRadius()*n.double+o.radius*r,g=e.getPosition(),l=o.infectedStage??e.infection.stage,u=s.particles.grid.queryCircle(g,f),d=o.rate,p=u.length;for(let t of u)if(!(t===e||t.destroyed||t.spawning||t.infection?.stage!==void 0&&t.infection.stage===e.infection.stage||(0,n.getRandom)()>=d/p)){if(t.infection?.stage===void 0)a.startInfection(t,l);else if(t.infection.stage<e.infection.stage)a.updateInfectionStage(t,l);else if(t.infection.stage>e.infection.stage){let i=c.stages[t.infection.stage];if(!i)continue;let n=i.infectedStage??t.infection.stage;a.updateInfectionStage(e,n)}}}isEnabled(){return this.container.actualOptions.infection?.enable??!1}reset(){}}}}]);
package/browser/index.js CHANGED
@@ -1,13 +1,14 @@
1
+ import {} from "@tsparticles/engine";
1
2
  export async function loadInfectionPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
3
+ engine.checkVersion("4.0.0-beta.2");
4
+ await engine.pluginManager.register(async (e) => {
4
5
  const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
5
6
  import("@tsparticles/plugin-interactivity"),
6
7
  import("./InfectionPlugin.js"),
7
8
  ]);
8
9
  ensureInteractivityPluginLoaded(e);
9
- e.addPlugin(new InfectionPlugin());
10
- e.addInteractor?.("particlesInfection", async (container) => {
10
+ e.pluginManager.addPlugin(new InfectionPlugin());
11
+ e.pluginManager.addInteractor?.("particlesInfection", async (container) => {
11
12
  const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
12
13
  return new ParticlesInfecter(container);
13
14
  });
package/cjs/index.js CHANGED
@@ -1,13 +1,14 @@
1
+ import {} from "@tsparticles/engine";
1
2
  export async function loadInfectionPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
3
+ engine.checkVersion("4.0.0-beta.2");
4
+ await engine.pluginManager.register(async (e) => {
4
5
  const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
5
6
  import("@tsparticles/plugin-interactivity"),
6
7
  import("./InfectionPlugin.js"),
7
8
  ]);
8
9
  ensureInteractivityPluginLoaded(e);
9
- e.addPlugin(new InfectionPlugin());
10
- e.addInteractor?.("particlesInfection", async (container) => {
10
+ e.pluginManager.addPlugin(new InfectionPlugin());
11
+ e.pluginManager.addInteractor?.("particlesInfection", async (container) => {
11
12
  const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
12
13
  return new ParticlesInfecter(container);
13
14
  });
@@ -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-beta.0
7
+ * v4.0.0-beta.2
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -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-beta.0
7
+ * v4.0.0-beta.2
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -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-beta.0
7
+ * v4.0.0-beta.2
8
8
  */
9
9
  "use strict";
10
10
  /*
package/esm/index.js CHANGED
@@ -1,13 +1,14 @@
1
+ import {} from "@tsparticles/engine";
1
2
  export async function loadInfectionPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
3
+ engine.checkVersion("4.0.0-beta.2");
4
+ await engine.pluginManager.register(async (e) => {
4
5
  const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
5
6
  import("@tsparticles/plugin-interactivity"),
6
7
  import("./InfectionPlugin.js"),
7
8
  ]);
8
9
  ensureInteractivityPluginLoaded(e);
9
- e.addPlugin(new InfectionPlugin());
10
- e.addInteractor?.("particlesInfection", async (container) => {
10
+ e.pluginManager.addPlugin(new InfectionPlugin());
11
+ e.pluginManager.addInteractor?.("particlesInfection", async (container) => {
11
12
  const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
12
13
  return new ParticlesInfecter(container);
13
14
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-infection",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "tsParticles infection plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -94,14 +94,13 @@
94
94
  "browser": "./browser/index.js",
95
95
  "import": "./esm/index.js",
96
96
  "require": "./cjs/index.js",
97
- "umd": "./umd/index.js",
98
- "default": "./cjs/index.js"
97
+ "default": "./esm/index.js"
99
98
  },
100
99
  "./package.json": "./package.json"
101
100
  },
102
- "dependencies": {
103
- "@tsparticles/engine": "4.0.0-beta.0",
104
- "@tsparticles/plugin-interactivity": "4.0.0-beta.0"
101
+ "peerDependencies": {
102
+ "@tsparticles/engine": "4.0.0-beta.1",
103
+ "@tsparticles/plugin-interactivity": "4.0.0-beta.1"
105
104
  },
106
105
  "publishConfig": {
107
106
  "access": "public"