@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.
@@ -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
  /*
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/plugin-interactivity"), require("@tsparticles/engine"));
19
+ module.exports = factory(require("@tsparticles/engine"), require("@tsparticles/plugin-interactivity"));
20
20
  else if(typeof define === 'function' && define.amd)
21
- define(["@tsparticles/plugin-interactivity", "@tsparticles/engine"], factory);
21
+ define(["@tsparticles/engine", "@tsparticles/plugin-interactivity"], factory);
22
22
  else {
23
- var a = typeof exports === 'object' ? factory(require("@tsparticles/plugin-interactivity"), require("@tsparticles/engine")) : factory(root["window"], root["window"]);
23
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine"), require("@tsparticles/plugin-interactivity")) : 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_plugin_interactivity__, __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__, __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__) => {
27
27
  return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
@@ -54,7 +54,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
54
54
  \*******************************/
55
55
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
56
56
 
57
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadInfectionPlugin: () => (/* binding */ loadInfectionPlugin)\n/* harmony export */ });\nasync function loadInfectionPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register(async (e)=>{\n const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin }] = await Promise.all([\n Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19)),\n __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPlugin.js */ \"./dist/browser/InfectionPlugin.js\"))\n ]);\n ensureInteractivityPluginLoaded(e);\n e.addPlugin(new InfectionPlugin());\n e.addInteractor?.(\"particlesInfection\", async (container)=>{\n const { ParticlesInfecter } = 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\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/index.js?\n}");
57
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadInfectionPlugin: () => (/* binding */ loadInfectionPlugin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nasync function loadInfectionPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.2\");\n await engine.pluginManager.register(async (e)=>{\n const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin }] = await Promise.all([\n Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19)),\n __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPlugin.js */ \"./dist/browser/InfectionPlugin.js\"))\n ]);\n ensureInteractivityPluginLoaded(e);\n e.pluginManager.addPlugin(new InfectionPlugin());\n e.pluginManager.addInteractor?.(\"particlesInfection\", async (container)=>{\n const { ParticlesInfecter } = 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\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/index.js?\n}");
58
58
 
59
59
  /***/ }
60
60
 
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-interactivity","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,n,o={303(e){e.exports=t},702(t){t.exports=e}},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return o[e](r,r.exports,c),r.exports}c.m=o,l=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.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);c.r(r);var i={};s=s||[null,l({}),l([]),l(l)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~s.indexOf(n);n=l(n))Object.getOwnPropertyNames(n).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,c.d(r,i),r},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce((t,r)=>(c.f[r](e,t),t),[])),c.u=e=>""+e+".min.js",c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p={},c.l=(e,t,r,i)=>{if(p[e])return void p[e].push(t);if(void 0!==r)for(var n,o,a=document.getElementsByTagName("script"),s=0;s<a.length;s++){var l=a[s];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")=="@tsparticles/plugin-infection:"+r){n=l;break}}n||(o=!0,(n=document.createElement("script")).charset="utf-8",c.nc&&n.setAttribute("nonce",c.nc),n.setAttribute("data-webpack","@tsparticles/plugin-infection:"+r),n.src=e),p[e]=[t];var u=(t,r)=>{n.onerror=n.onload=null,clearTimeout(f);var i=p[e];if(delete p[e],n.parentNode&&n.parentNode.removeChild(n),i&&i.forEach(e=>e(r)),t)return t(r)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),o&&document.head.appendChild(n)},c.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(u=c.g.location+"");var s,l,p,u,f=c.g.document;if(!u&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(u=f.currentScript.src),!u)){var d=f.getElementsByTagName("script");if(d.length)for(var b=d.length-1;b>-1&&(!u||!/^http(s?):/.test(u));)u=d[b--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");c.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={587:0},c.f.j=(e,t)=>{var i=c.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var n=new Promise((t,n)=>i=r[e]=[t,n]);t.push(i[2]=n);var o=c.p+c.u(e),a=Error();c.l(o,t=>{if(c.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
2
- (`+n+": "+o+")",a.name="ChunkLoadError",a.type=n,a.request=o,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,n,[o,a,s]=t,l=0;if(o.some(e=>0!==r[e])){for(i in a)c.o(a,i)&&(c.m[i]=a[i]);s&&s(c)}for(e&&e(t);l<o.length;l++)n=o[l],c.o(r,n)&&r[n]&&r[n][0](),r[n]=0},(n=this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).forEach(i.bind(null,0)),n.push=i.bind(null,n.push.bind(n));var g={};async function h(e){e.checkVersion("4.0.0-beta.0"),await e.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{InfectionPlugin:r}]=await Promise.all([Promise.resolve().then(c.t.bind(c,702,19)),c.e(392).then(c.bind(c,392))]);t(e),e.addPlugin(new r),e.addInteractor?.("particlesInfection",async e=>{let{ParticlesInfecter:t}=await c.e(91).then(c.bind(c,91));return new t(e)})})}return c.r(g),c.d(g,{loadInfectionPlugin:()=>h}),g})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/plugin-interactivity"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/plugin-interactivity")):t(e.window,e.window);for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(e,t)=>(()=>{"use strict";var r,n,i,o={303(t){t.exports=e},702(e){e.exports=t}},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return o[e](r,r.exports,c),r.exports}c.m=o,l=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.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);c.r(r);var n={};s=s||[null,l({}),l([]),l(l)];for(var i=2&t&&e;("object"==typeof i||"function"==typeof i)&&!~s.indexOf(i);i=l(i))Object.getOwnPropertyNames(i).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,c.d(r,n),r},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce((t,r)=>(c.f[r](e,t),t),[])),c.u=e=>""+e+".min.js",c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p={},c.l=(e,t,r,n)=>{if(p[e])return void p[e].push(t);if(void 0!==r)for(var i,o,a=document.getElementsByTagName("script"),s=0;s<a.length;s++){var l=a[s];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")=="@tsparticles/plugin-infection:"+r){i=l;break}}i||(o=!0,(i=document.createElement("script")).charset="utf-8",c.nc&&i.setAttribute("nonce",c.nc),i.setAttribute("data-webpack","@tsparticles/plugin-infection:"+r),i.src=e),p[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(f);var n=p[e];if(delete p[e],i.parentNode&&i.parentNode.removeChild(i),n&&n.forEach(e=>e(r)),t)return t(r)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),o&&document.head.appendChild(i)},c.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(u=c.g.location+"");var s,l,p,u,f=c.g.document;if(!u&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(u=f.currentScript.src),!u)){var d=f.getElementsByTagName("script");if(d.length)for(var g=d.length-1;g>-1&&(!u||!/^http(s?):/.test(u));)u=d[g--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");c.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={587:0},c.f.j=(e,t)=>{var n=c.o(r,e)?r[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var i=new Promise((t,i)=>n=r[e]=[t,i]);t.push(n[2]=i);var o=c.p+c.u(e),a=Error();c.l(o,t=>{if(c.o(r,e)&&(0!==(n=r[e])&&(r[e]=void 0),n)){var i=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
2
+ (`+i+": "+o+")",a.name="ChunkLoadError",a.type=i,a.request=o,n[1](a)}},"chunk-"+e,e)}},n=(e,t)=>{var n,i,[o,a,s]=t,l=0;if(o.some(e=>0!==r[e])){for(n in a)c.o(a,n)&&(c.m[n]=a[n]);s&&s(c)}for(e&&e(t);l<o.length;l++)i=o[l],c.o(r,i)&&r[i]&&r[i][0](),r[i]=0},(i=this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).forEach(n.bind(null,0)),i.push=n.bind(null,i.push.bind(i));var b={};async function h(e){e.checkVersion("4.0.0-beta.2"),await e.pluginManager.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{InfectionPlugin:r}]=await Promise.all([Promise.resolve().then(c.t.bind(c,702,19)),c.e(734).then(c.bind(c,734))]);t(e),e.pluginManager.addPlugin(new r),e.pluginManager.addInteractor?.("particlesInfection",async e=>{let{ParticlesInfecter:t}=await c.e(951).then(c.bind(c,951));return new t(e)})})}return c.r(b),c.d(b,{loadInfectionPlugin:()=>h}),c(303),b})());
package/91.min.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[91],{91(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/umd/Infecter.js DELETED
@@ -1,111 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Infecter = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const minStage = 0, minDuration = 0;
15
- class Infecter {
16
- _container;
17
- constructor(container) {
18
- this._container = container;
19
- }
20
- startInfection(particle, stage) {
21
- const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
22
- if (!infectionOptions || !infection) {
23
- return;
24
- }
25
- const stages = infectionOptions.stages, stagesCount = stages.length;
26
- if (stage > stagesCount || stage < minStage) {
27
- return;
28
- }
29
- infection.delay = 0;
30
- infection.delayStage = stage;
31
- }
32
- updateInfection(particle, delta) {
33
- const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
34
- if (!infectionOptions || !infection) {
35
- return;
36
- }
37
- const stages = infectionOptions.stages, stagesCount = stages.length;
38
- if (infection.delay !== undefined && infection.delayStage !== undefined) {
39
- const stage = infection.delayStage;
40
- if (stage > stagesCount || stage < minStage) {
41
- return;
42
- }
43
- if (infection.delay >= infectionOptions.delay * engine_1.millisecondsToSeconds) {
44
- infection.stage = stage;
45
- infection.time = 0;
46
- delete infection.delay;
47
- delete infection.delayStage;
48
- }
49
- else {
50
- infection.delay += delta;
51
- }
52
- }
53
- else {
54
- delete infection.delay;
55
- delete infection.delayStage;
56
- }
57
- if (infection.stage !== undefined && infection.time !== undefined) {
58
- const infectionStage = stages[infection.stage];
59
- if (infectionStage?.duration !== undefined && infectionStage.duration >= minDuration) {
60
- if (infection.time > infectionStage.duration * engine_1.millisecondsToSeconds) {
61
- this._nextInfectionStage(particle);
62
- }
63
- else {
64
- infection.time += delta;
65
- }
66
- }
67
- else {
68
- infection.time += delta;
69
- }
70
- }
71
- else {
72
- delete infection.stage;
73
- delete infection.time;
74
- }
75
- }
76
- updateInfectionStage(particle, stage) {
77
- const options = this._container.actualOptions, { infection } = particle;
78
- if (!options.infection || !infection) {
79
- return;
80
- }
81
- const stagesCount = options.infection.stages.length;
82
- if (stage > stagesCount || stage < minStage || (infection.stage !== undefined && infection.stage > stage)) {
83
- return;
84
- }
85
- infection.stage = stage;
86
- infection.time = 0;
87
- }
88
- _nextInfectionStage = particle => {
89
- const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
90
- if (!infectionOptions || !infection) {
91
- return;
92
- }
93
- const stagesCount = infectionOptions.stages.length;
94
- if (stagesCount <= minStage || infection.stage === undefined) {
95
- return;
96
- }
97
- infection.time = 0;
98
- if (stagesCount <= ++infection.stage) {
99
- if (infectionOptions.cure) {
100
- delete infection.stage;
101
- delete infection.time;
102
- }
103
- else {
104
- infection.stage = 0;
105
- infection.time = 0;
106
- }
107
- }
108
- };
109
- }
110
- exports.Infecter = Infecter;
111
- });
@@ -1,69 +0,0 @@
1
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
- if (k2 === undefined) k2 = k;
3
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
- desc = { enumerable: true, get: function() { return m[k]; } };
6
- }
7
- Object.defineProperty(o, k2, desc);
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
- Object.defineProperty(o, "default", { enumerable: true, value: v });
14
- }) : function(o, v) {
15
- o["default"] = v;
16
- });
17
- var __importStar = (this && this.__importStar) || (function () {
18
- var ownKeys = function(o) {
19
- ownKeys = Object.getOwnPropertyNames || function (o) {
20
- var ar = [];
21
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
- return ar;
23
- };
24
- return ownKeys(o);
25
- };
26
- return function (mod) {
27
- if (mod && mod.__esModule) return mod;
28
- var result = {};
29
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
- __setModuleDefault(result, mod);
31
- return result;
32
- };
33
- })();
34
- (function (factory) {
35
- if (typeof module === "object" && typeof module.exports === "object") {
36
- var v = factory(require, exports);
37
- if (v !== undefined) module.exports = v;
38
- }
39
- else if (typeof define === "function" && define.amd) {
40
- define(["require", "exports", "./Options/Classes/Infection.js"], factory);
41
- }
42
- })(function (require, exports) {
43
- "use strict";
44
- var __syncRequire = typeof module === "object" && typeof module.exports === "object";
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.InfectionPlugin = void 0;
47
- const Infection_js_1 = require("./Options/Classes/Infection.js");
48
- class InfectionPlugin {
49
- id = "infection";
50
- async getPlugin(container) {
51
- 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));
52
- return new InfectionPluginInstance(container);
53
- }
54
- loadOptions(_container, options, source) {
55
- if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
56
- return;
57
- }
58
- let infectionOptions = options.infection;
59
- if (infectionOptions?.load === undefined) {
60
- options.infection = infectionOptions = new Infection_js_1.Infection();
61
- }
62
- infectionOptions.load(source?.infection);
63
- }
64
- needsPlugin(options) {
65
- return options?.infection?.enable ?? false;
66
- }
67
- }
68
- exports.InfectionPlugin = InfectionPlugin;
69
- });
@@ -1,52 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./Infecter.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.InfectionPluginInstance = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const Infecter_js_1 = require("./Infecter.js");
15
- const minStage = 0;
16
- class InfectionPluginInstance {
17
- _container;
18
- constructor(container) {
19
- this._container = container;
20
- this._container.infecter = new Infecter_js_1.Infecter(this._container);
21
- }
22
- particleFillColor(particle) {
23
- const options = this._container.actualOptions;
24
- if (!particle.infection || !options.infection) {
25
- return;
26
- }
27
- const infectionStage = particle.infection.stage, infection = options.infection, infectionStages = infection.stages;
28
- return infectionStage === undefined ? undefined : infectionStages[infectionStage]?.color;
29
- }
30
- particleStrokeColor(particle) {
31
- return this.particleFillColor(particle);
32
- }
33
- particlesSetup() {
34
- const options = this._container.actualOptions;
35
- if (!options.infection) {
36
- return;
37
- }
38
- for (let i = 0; i < options.infection.infections; i++) {
39
- const notInfected = this._container.particles.filter(p => {
40
- const infP = p;
41
- infP.infection ??= {};
42
- return infP.infection.stage === undefined;
43
- }), infected = (0, engine_1.itemFromArray)(notInfected);
44
- if (!infected) {
45
- continue;
46
- }
47
- this._container.infecter?.startInfection(infected, minStage);
48
- }
49
- }
50
- }
51
- exports.InfectionPluginInstance = InfectionPluginInstance;
52
- });
@@ -1,55 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "./InfectionStage.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Infection = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const InfectionStage_js_1 = require("./InfectionStage.js");
15
- class Infection {
16
- cure;
17
- delay;
18
- enable;
19
- infections;
20
- stages;
21
- constructor() {
22
- this.cure = false;
23
- this.delay = 0;
24
- this.enable = false;
25
- this.infections = 0;
26
- this.stages = [];
27
- }
28
- load(data) {
29
- if ((0, engine_1.isNull)(data)) {
30
- return;
31
- }
32
- if (data.cure !== undefined) {
33
- this.cure = data.cure;
34
- }
35
- if (data.delay !== undefined) {
36
- this.delay = data.delay;
37
- }
38
- if (data.enable !== undefined) {
39
- this.enable = data.enable;
40
- }
41
- if (data.infections !== undefined) {
42
- this.infections = data.infections;
43
- }
44
- if (data.stages === undefined) {
45
- return;
46
- }
47
- this.stages = data.stages.map(t => {
48
- const s = new InfectionStage_js_1.InfectionStage();
49
- s.load(t);
50
- return s;
51
- });
52
- }
53
- }
54
- exports.Infection = Infection;
55
- });
@@ -1,44 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.InfectionStage = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- class InfectionStage {
15
- color;
16
- duration;
17
- infectedStage;
18
- radius;
19
- rate;
20
- constructor() {
21
- this.color = new engine_1.OptionsColor();
22
- this.color.value = "#ff0000";
23
- this.radius = 0;
24
- this.rate = 1;
25
- }
26
- load(data) {
27
- if ((0, engine_1.isNull)(data)) {
28
- return;
29
- }
30
- if (data.color !== undefined) {
31
- this.color = engine_1.OptionsColor.create(this.color, data.color);
32
- }
33
- this.duration = data.duration;
34
- this.infectedStage = data.infectedStage;
35
- if (data.radius !== undefined) {
36
- this.radius = data.radius;
37
- }
38
- if (data.rate !== undefined) {
39
- this.rate = data.rate;
40
- }
41
- }
42
- }
43
- exports.InfectionStage = InfectionStage;
44
- });
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
@@ -1,80 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "@tsparticles/engine", "@tsparticles/plugin-interactivity"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ParticlesInfecter = void 0;
13
- const engine_1 = require("@tsparticles/engine");
14
- const plugin_interactivity_1 = require("@tsparticles/plugin-interactivity");
15
- const minStagesCount = 1;
16
- class ParticlesInfecter extends plugin_interactivity_1.ParticlesInteractorBase {
17
- _maxDistance;
18
- constructor(container) {
19
- super(container);
20
- this._maxDistance = 0;
21
- }
22
- get maxDistance() {
23
- return this._maxDistance;
24
- }
25
- clear() {
26
- }
27
- init() {
28
- }
29
- interact(p1, _interactivityData, delta) {
30
- const infecter = this.container.infecter;
31
- if (!infecter) {
32
- return;
33
- }
34
- infecter.updateInfection(p1, delta.value);
35
- if (p1.infection?.stage === undefined) {
36
- return;
37
- }
38
- const container = this.container, options = container.actualOptions, infectionOptions = options.infection;
39
- if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {
40
- return;
41
- }
42
- const infectionStage1 = infectionOptions.stages[p1.infection.stage];
43
- if (!infectionStage1) {
44
- return;
45
- }
46
- this._maxDistance = Math.max(this._maxDistance, infectionStage1.radius);
47
- 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.grid.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
48
- for (const p2 of query) {
49
- const infP2 = p2;
50
- if (infP2 === p1 ||
51
- infP2.destroyed ||
52
- infP2.spawning ||
53
- !(infP2.infection?.stage === undefined || infP2.infection.stage !== p1.infection.stage) ||
54
- (0, engine_1.getRandom)() >= infections / neighbors) {
55
- continue;
56
- }
57
- if (infP2.infection?.stage === undefined) {
58
- infecter.startInfection(infP2, infectedStage1);
59
- }
60
- else if (infP2.infection.stage < p1.infection.stage) {
61
- infecter.updateInfectionStage(infP2, infectedStage1);
62
- }
63
- else if (infP2.infection.stage > p1.infection.stage) {
64
- const infectionStage2 = infectionOptions.stages[infP2.infection.stage];
65
- if (!infectionStage2) {
66
- continue;
67
- }
68
- const infectedStage2 = infectionStage2.infectedStage ?? infP2.infection.stage;
69
- infecter.updateInfectionStage(p1, infectedStage2);
70
- }
71
- }
72
- }
73
- isEnabled() {
74
- return this.container.actualOptions.infection?.enable ?? false;
75
- }
76
- reset() {
77
- }
78
- }
79
- exports.ParticlesInfecter = ParticlesInfecter;
80
- });
package/umd/Types.js DELETED
@@ -1,12 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- });
package/umd/index.js DELETED
@@ -1,62 +0,0 @@
1
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
- if (k2 === undefined) k2 = k;
3
- var desc = Object.getOwnPropertyDescriptor(m, k);
4
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
- desc = { enumerable: true, get: function() { return m[k]; } };
6
- }
7
- Object.defineProperty(o, k2, desc);
8
- }) : (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- o[k2] = m[k];
11
- }));
12
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
- Object.defineProperty(o, "default", { enumerable: true, value: v });
14
- }) : function(o, v) {
15
- o["default"] = v;
16
- });
17
- var __importStar = (this && this.__importStar) || (function () {
18
- var ownKeys = function(o) {
19
- ownKeys = Object.getOwnPropertyNames || function (o) {
20
- var ar = [];
21
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
- return ar;
23
- };
24
- return ownKeys(o);
25
- };
26
- return function (mod) {
27
- if (mod && mod.__esModule) return mod;
28
- var result = {};
29
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
- __setModuleDefault(result, mod);
31
- return result;
32
- };
33
- })();
34
- (function (factory) {
35
- if (typeof module === "object" && typeof module.exports === "object") {
36
- var v = factory(require, exports);
37
- if (v !== undefined) module.exports = v;
38
- }
39
- else if (typeof define === "function" && define.amd) {
40
- define(["require", "exports"], factory);
41
- }
42
- })(function (require, exports) {
43
- "use strict";
44
- var __syncRequire = typeof module === "object" && typeof module.exports === "object";
45
- Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.loadInfectionPlugin = loadInfectionPlugin;
47
- async function loadInfectionPlugin(engine) {
48
- engine.checkVersion("4.0.0-beta.0");
49
- await engine.register(async (e) => {
50
- const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
51
- __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),
52
- __syncRequire ? Promise.resolve().then(() => __importStar(require("./InfectionPlugin.js"))) : new Promise((resolve_2, reject_2) => { require(["./InfectionPlugin.js"], resolve_2, reject_2); }).then(__importStar),
53
- ]);
54
- ensureInteractivityPluginLoaded(e);
55
- e.addPlugin(new InfectionPlugin());
56
- e.addInteractor?.("particlesInfection", async (container) => {
57
- 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));
58
- return new ParticlesInfecter(container);
59
- });
60
- });
61
- }
62
- });