@tsparticles/updater-life 3.0.0-alpha.1 → 3.0.0-beta.1

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
- * v3.0.0-alpha.1
7
+ * v3.0.0-beta.1
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadLifeUpdater": () => (/* binding */ loadLifeUpdater)
94
+ loadLifeUpdater: () => (/* binding */ loadLifeUpdater)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -190,7 +190,7 @@ class LifeUpdater {
190
190
  options.life = new Life();
191
191
  }
192
192
  for (const source of sources) {
193
- options.life.load(source === null || source === void 0 ? void 0 : source.life);
193
+ options.life.load(source?.life);
194
194
  }
195
195
  }
196
196
  update(particle, delta) {
@@ -250,8 +250,8 @@ class LifeUpdater {
250
250
  }
251
251
  ;// CONCATENATED MODULE: ./dist/browser/index.js
252
252
 
253
- async function loadLifeUpdater(engine) {
254
- await engine.addParticleUpdater("life", container => new LifeUpdater(container));
253
+ async function loadLifeUpdater(engine, refresh = true) {
254
+ await engine.addParticleUpdater("life", container => new LifeUpdater(container), refresh);
255
255
  }
256
256
  })();
257
257
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.updater.life.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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{loadLifeUpdater:()=>s});var e=i(533);class t extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class n extends e.ValueWithRandom{constructor(){super(),this.random.minimumValue=1e-4,this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class a{constructor(){this.count=0,this.delay=new t,this.duration=new n}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}class r{constructor(e){this.container=e}init(t){const n=this.container,i=t.options.life;i&&(t.life={delay:n.retina.reduceFactor?(0,e.getRangeValue)(i.delay.value)*(i.delay.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*1e3:0,delayTime:0,duration:n.retina.reduceFactor?(0,e.getRangeValue)(i.duration.value)*(i.duration.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*1e3:0,time:0,count:i.count},t.life.duration<=0&&(t.life.duration=-1),t.life.count<=0&&(t.life.count=-1),t.life&&(t.spawning=t.life.delay>0))}isEnabled(e){return!e.destroyed}loadOptions(e,...t){e.life||(e.life=new a);for(const n of t)e.life.load(null==n?void 0:n.life)}update(t,n){if(!this.isEnabled(t)||!t.life)return;const i=t.life;let o=!1;if(t.spawning){if(i.delayTime+=n.value,!(i.delayTime>=t.life.delay))return;o=!0,t.spawning=!1,i.delayTime=0,i.time=0}if(-1===i.duration)return;if(t.spawning)return;if(o?i.time=0:i.time+=n.value,i.time<i.duration)return;if(i.time=0,t.life.count>0&&t.life.count--,0===t.life.count)return void t.destroy();const a=this.container.canvas.size,r=(0,e.setRangeValue)(0,a.width),s=(0,e.setRangeValue)(0,a.width);t.position.x=(0,e.randomInRange)(r),t.position.y=(0,e.randomInRange)(s),t.spawning=!0,i.delayTime=0,i.time=0,t.reset();const l=t.options.life;l&&(i.delay=1e3*(0,e.getRangeValue)(l.delay.value),i.duration=1e3*(0,e.getRangeValue)(l.duration.value))}}async function s(e){await e.addParticleUpdater("life",(e=>new r(e)))}})(),o})()));
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 n="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,i),a.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{loadLifeUpdater:()=>s});var e=i(533);class t extends e.ValueWithRandom{constructor(){super(),this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class n extends e.ValueWithRandom{constructor(){super(),this.random.minimumValue=1e-4,this.sync=!1}load(e){e&&(super.load(e),void 0!==e.sync&&(this.sync=e.sync))}}class a{constructor(){this.count=0,this.delay=new t,this.duration=new n}load(e){e&&(void 0!==e.count&&(this.count=e.count),this.delay.load(e.delay),this.duration.load(e.duration))}}class r{constructor(e){this.container=e}init(t){const n=this.container,i=t.options.life;i&&(t.life={delay:n.retina.reduceFactor?(0,e.getRangeValue)(i.delay.value)*(i.delay.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*1e3:0,delayTime:0,duration:n.retina.reduceFactor?(0,e.getRangeValue)(i.duration.value)*(i.duration.sync?1:(0,e.getRandom)())/n.retina.reduceFactor*1e3:0,time:0,count:i.count},t.life.duration<=0&&(t.life.duration=-1),t.life.count<=0&&(t.life.count=-1),t.life&&(t.spawning=t.life.delay>0))}isEnabled(e){return!e.destroyed}loadOptions(e,...t){e.life||(e.life=new a);for(const n of t)e.life.load(n?.life)}update(t,n){if(!this.isEnabled(t)||!t.life)return;const i=t.life;let o=!1;if(t.spawning){if(i.delayTime+=n.value,!(i.delayTime>=t.life.delay))return;o=!0,t.spawning=!1,i.delayTime=0,i.time=0}if(-1===i.duration)return;if(t.spawning)return;if(o?i.time=0:i.time+=n.value,i.time<i.duration)return;if(i.time=0,t.life.count>0&&t.life.count--,0===t.life.count)return void t.destroy();const a=this.container.canvas.size,r=(0,e.setRangeValue)(0,a.width),s=(0,e.setRangeValue)(0,a.width);t.position.x=(0,e.randomInRange)(r),t.position.y=(0,e.randomInRange)(s),t.spawning=!0,i.delayTime=0,i.time=0,t.reset();const l=t.options.life;l&&(i.delay=1e3*(0,e.getRangeValue)(l.delay.value),i.duration=1e3*(0,e.getRangeValue)(l.duration.value))}}async function s(e,t=!0){await e.addParticleUpdater("life",(e=>new r(e)),t)}})(),o})()));
@@ -1,8 +1 @@
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
- * v3.0.0-alpha.1
8
- */
1
+ /*! tsParticles Life Updater v3.0.0-beta.1 by Matteo Bruni */
@@ -1,23 +1,5 @@
1
- import type { Container, IDelta, IParticleUpdater, IParticlesOptions, Particle, ParticlesOptions, RecursivePartial } from "@tsparticles/engine";
2
- import type { ILife } from "./Options/Interfaces/ILife";
3
- import { Life } from "./Options/Classes/Life";
4
- interface IParticleLife {
5
- count: number;
6
- delay: number;
7
- delayTime: number;
8
- duration: number;
9
- time: number;
10
- }
11
- type ILifeParticlesOptions = IParticlesOptions & {
12
- life?: ILife;
13
- };
14
- type LifeParticlesOptions = ParticlesOptions & {
15
- life?: Life;
16
- };
17
- type LifeParticle = Particle & {
18
- life?: IParticleLife;
19
- options: LifeParticlesOptions;
20
- };
1
+ import { type Container, type IDelta, type IParticleUpdater, type Particle, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { ILifeParticlesOptions, LifeParticle, LifeParticlesOptions } from "./Types.js";
21
3
  export declare class LifeUpdater implements IParticleUpdater {
22
4
  private readonly container;
23
5
  constructor(container: Container);
@@ -26,4 +8,3 @@ export declare class LifeUpdater implements IParticleUpdater {
26
8
  loadOptions(options: LifeParticlesOptions, ...sources: (RecursivePartial<ILifeParticlesOptions> | undefined)[]): void;
27
9
  update(particle: LifeParticle, delta: IDelta): void;
28
10
  }
29
- export {};
@@ -1,7 +1,7 @@
1
1
  import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
- import type { ILife } from "../Interfaces/ILife";
3
- import { LifeDelay } from "./LifeDelay";
4
- import { LifeDuration } from "./LifeDuration";
2
+ import type { ILife } from "../Interfaces/ILife.js";
3
+ import { LifeDelay } from "./LifeDelay.js";
4
+ import { LifeDuration } from "./LifeDuration.js";
5
5
  export declare class Life implements ILife, IOptionLoader<ILife> {
6
6
  count: number;
7
7
  delay: LifeDelay;
@@ -1,6 +1,5 @@
1
- import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
- import type { ILifeDelay } from "../Interfaces/ILifeDelay";
3
- import { ValueWithRandom } from "@tsparticles/engine";
1
+ import { type IOptionLoader, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
2
+ import type { ILifeDelay } from "../Interfaces/ILifeDelay.js";
4
3
  export declare class LifeDelay extends ValueWithRandom implements ILifeDelay, IOptionLoader<ILifeDelay> {
5
4
  sync: boolean;
6
5
  constructor();
@@ -1,6 +1,5 @@
1
- import type { IOptionLoader, RecursivePartial } from "@tsparticles/engine";
2
- import type { ILifeDuration } from "../Interfaces/ILifeDuration";
3
- import { ValueWithRandom } from "@tsparticles/engine";
1
+ import { type IOptionLoader, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
2
+ import type { ILifeDuration } from "../Interfaces/ILifeDuration.js";
4
3
  export declare class LifeDuration extends ValueWithRandom implements ILifeDuration, IOptionLoader<ILifeDuration> {
5
4
  sync: boolean;
6
5
  constructor();
@@ -1,5 +1,5 @@
1
- import type { ILifeDelay } from "./ILifeDelay";
2
- import type { ILifeDuration } from "./ILifeDuration";
1
+ import type { ILifeDelay } from "./ILifeDelay.js";
2
+ import type { ILifeDuration } from "./ILifeDuration.js";
3
3
  export interface ILife {
4
4
  count: number;
5
5
  delay: ILifeDelay;
@@ -0,0 +1,20 @@
1
+ import type { IParticlesOptions, Particle, ParticlesOptions } from "@tsparticles/engine";
2
+ import type { ILife } from "./Options/Interfaces/ILife.js";
3
+ import type { Life } from "./Options/Classes/Life.js";
4
+ export interface IParticleLife {
5
+ count: number;
6
+ delay: number;
7
+ delayTime: number;
8
+ duration: number;
9
+ time: number;
10
+ }
11
+ export type ILifeParticlesOptions = IParticlesOptions & {
12
+ life?: ILife;
13
+ };
14
+ export type LifeParticlesOptions = ParticlesOptions & {
15
+ life?: Life;
16
+ };
17
+ export type LifeParticle = Particle & {
18
+ life?: IParticleLife;
19
+ options: LifeParticlesOptions;
20
+ };
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadLifeUpdater(engine: Engine): Promise<void>;
2
+ export declare function loadLifeUpdater(engine: Engine, refresh?: boolean): Promise<void>;
@@ -4,14 +4,14 @@
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", "./Options/Classes/Life"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Life.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.LifeUpdater = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
- const Life_1 = require("./Options/Classes/Life");
14
+ const Life_js_1 = require("./Options/Classes/Life.js");
15
15
  class LifeUpdater {
16
16
  constructor(container) {
17
17
  this.container = container;
@@ -51,10 +51,10 @@
51
51
  }
52
52
  loadOptions(options, ...sources) {
53
53
  if (!options.life) {
54
- options.life = new Life_1.Life();
54
+ options.life = new Life_js_1.Life();
55
55
  }
56
56
  for (const source of sources) {
57
- options.life.load(source === null || source === void 0 ? void 0 : source.life);
57
+ options.life.load(source?.life);
58
58
  }
59
59
  }
60
60
  update(particle, delta) {
@@ -4,19 +4,19 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./LifeDelay", "./LifeDuration"], factory);
7
+ define(["require", "exports", "./LifeDelay.js", "./LifeDuration.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Life = void 0;
13
- const LifeDelay_1 = require("./LifeDelay");
14
- const LifeDuration_1 = require("./LifeDuration");
13
+ const LifeDelay_js_1 = require("./LifeDelay.js");
14
+ const LifeDuration_js_1 = require("./LifeDuration.js");
15
15
  class Life {
16
16
  constructor() {
17
17
  this.count = 0;
18
- this.delay = new LifeDelay_1.LifeDelay();
19
- this.duration = new LifeDuration_1.LifeDuration();
18
+ this.delay = new LifeDelay_js_1.LifeDelay();
19
+ this.duration = new LifeDuration_js_1.LifeDuration();
20
20
  }
21
21
  load(data) {
22
22
  if (!data) {
package/umd/Types.js ADDED
@@ -0,0 +1,12 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ });
package/umd/index.js CHANGED
@@ -4,15 +4,15 @@
4
4
  if (v !== undefined) module.exports = v;
5
5
  }
6
6
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./LifeUpdater"], factory);
7
+ define(["require", "exports", "./LifeUpdater.js"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadLifeUpdater = void 0;
13
- const LifeUpdater_1 = require("./LifeUpdater");
14
- async function loadLifeUpdater(engine) {
15
- await engine.addParticleUpdater("life", (container) => new LifeUpdater_1.LifeUpdater(container));
13
+ const LifeUpdater_js_1 = require("./LifeUpdater.js");
14
+ async function loadLifeUpdater(engine, refresh = true) {
15
+ await engine.addParticleUpdater("life", (container) => new LifeUpdater_js_1.LifeUpdater(container), refresh);
16
16
  }
17
17
  exports.loadLifeUpdater = loadLifeUpdater;
18
18
  });