@tsparticles/updater-life 3.0.0-alpha.1 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -12
- package/browser/LifeUpdater.js +2 -2
- package/browser/Types.js +1 -0
- package/browser/index.js +2 -2
- package/cjs/LifeUpdater.js +1 -1
- package/cjs/Types.js +2 -0
- package/cjs/index.js +2 -13
- package/esm/LifeUpdater.js +2 -2
- package/esm/Types.js +1 -0
- package/esm/index.js +2 -2
- package/package.json +6 -5
- package/report.html +4 -4
- package/tsparticles.updater.life.js +5 -5
- package/tsparticles.updater.life.min.js +1 -1
- package/tsparticles.updater.life.min.js.LICENSE.txt +1 -8
- package/types/LifeUpdater.d.ts +2 -21
- package/types/Options/Classes/LifeDelay.d.ts +1 -2
- package/types/Options/Classes/LifeDuration.d.ts +1 -2
- package/types/Types.d.ts +20 -0
- package/types/index.d.ts +1 -1
- package/umd/LifeUpdater.js +1 -1
- package/umd/Types.js +12 -0
- package/umd/index.js +2 -2
|
@@ -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-
|
|
7
|
+
* v3.0.0-beta.0
|
|
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
|
-
|
|
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
|
|
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(
|
|
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.0 by Matteo Bruni */
|
package/types/LifeUpdater.d.ts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
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";
|
|
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,6 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type IOptionLoader, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
|
|
2
2
|
import type { ILifeDelay } from "../Interfaces/ILifeDelay";
|
|
3
|
-
import { ValueWithRandom } from "@tsparticles/engine";
|
|
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
|
|
1
|
+
import { type IOptionLoader, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
|
|
2
2
|
import type { ILifeDuration } from "../Interfaces/ILifeDuration";
|
|
3
|
-
import { ValueWithRandom } from "@tsparticles/engine";
|
|
4
3
|
export declare class LifeDuration extends ValueWithRandom implements ILifeDuration, IOptionLoader<ILifeDuration> {
|
|
5
4
|
sync: boolean;
|
|
6
5
|
constructor();
|
package/types/Types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IParticlesOptions, Particle, ParticlesOptions } from "@tsparticles/engine";
|
|
2
|
+
import type { ILife } from "./Options/Interfaces/ILife";
|
|
3
|
+
import type { Life } from "./Options/Classes/Life";
|
|
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>;
|
package/umd/LifeUpdater.js
CHANGED
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
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.loadLifeUpdater = void 0;
|
|
13
13
|
const LifeUpdater_1 = require("./LifeUpdater");
|
|
14
|
-
async function loadLifeUpdater(engine) {
|
|
15
|
-
await engine.addParticleUpdater("life", (container) => new LifeUpdater_1.LifeUpdater(container));
|
|
14
|
+
async function loadLifeUpdater(engine, refresh = true) {
|
|
15
|
+
await engine.addParticleUpdater("life", (container) => new LifeUpdater_1.LifeUpdater(container), refresh);
|
|
16
16
|
}
|
|
17
17
|
exports.loadLifeUpdater = loadLifeUpdater;
|
|
18
18
|
});
|