@tsparticles/fireworks 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/LICENSE +21 -0
- package/README.md +92 -0
- package/browser/FireworkOptions.js +63 -0
- package/browser/IFireworkOptions.js +1 -0
- package/browser/bundle.js +2 -0
- package/browser/fireworks.js +264 -0
- package/browser/index.js +1 -0
- package/cjs/FireworkOptions.js +67 -0
- package/cjs/IFireworkOptions.js +2 -0
- package/cjs/bundle.js +18 -0
- package/cjs/fireworks.js +268 -0
- package/cjs/index.js +17 -0
- package/esm/FireworkOptions.js +63 -0
- package/esm/IFireworkOptions.js +1 -0
- package/esm/bundle.js +2 -0
- package/esm/fireworks.js +264 -0
- package/esm/index.js +1 -0
- package/package.json +103 -0
- package/report.html +39 -0
- package/tsparticles.fireworks.bundle.js +8752 -0
- package/tsparticles.fireworks.bundle.min.js +2 -0
- package/tsparticles.fireworks.bundle.min.js.LICENSE.txt +1 -0
- package/tsparticles.fireworks.js +717 -0
- package/tsparticles.fireworks.min.js +2 -0
- package/tsparticles.fireworks.min.js.LICENSE.txt +1 -0
- package/types/FireworkOptions.d.ts +15 -0
- package/types/IFireworkOptions.d.ts +12 -0
- package/types/bundle.d.ts +2 -0
- package/types/fireworks.d.ts +21 -0
- package/types/index.d.ts +4 -0
- package/umd/FireworkOptions.js +77 -0
- package/umd/IFireworkOptions.js +12 -0
- package/umd/bundle.js +28 -0
- package/umd/fireworks.js +278 -0
- package/umd/index.js +27 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.fireworks.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/updater-destroy"),require("@tsparticles/plugin-emitters"),require("@tsparticles/updater-life"),require("@tsparticles/shape-line"),require("@tsparticles/plugin-sounds"),require("@tsparticles/updater-stroke-color"),require("@tsparticles/move-base"),require("@tsparticles/shape-circle"),require("@tsparticles/updater-color"),require("@tsparticles/updater-opacity"),require("@tsparticles/updater-out-modes"),require("@tsparticles/updater-size"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/updater-destroy","@tsparticles/plugin-emitters","@tsparticles/updater-life","@tsparticles/shape-line","@tsparticles/plugin-sounds","@tsparticles/updater-stroke-color","@tsparticles/move-base","@tsparticles/shape-circle","@tsparticles/updater-color","@tsparticles/updater-opacity","@tsparticles/updater-out-modes","@tsparticles/updater-size"],t);else{var a="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/updater-destroy"),require("@tsparticles/plugin-emitters"),require("@tsparticles/updater-life"),require("@tsparticles/shape-line"),require("@tsparticles/plugin-sounds"),require("@tsparticles/updater-stroke-color"),require("@tsparticles/move-base"),require("@tsparticles/shape-circle"),require("@tsparticles/updater-color"),require("@tsparticles/updater-opacity"),require("@tsparticles/updater-out-modes"),require("@tsparticles/updater-size")):t(e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window,e.window);for(var i in a)("object"==typeof exports?exports:e)[i]=a[i]}}(this,((e,t,a,i,s,r,o,n,l,c,p,d,u)=>(()=>{"use strict";var h={533:t=>{t.exports=e},619:e=>{e.exports=n},68:e=>{e.exports=a},490:e=>{e.exports=r},163:e=>{e.exports=l},137:e=>{e.exports=s},501:e=>{e.exports=c},344:e=>{e.exports=t},84:e=>{e.exports=i},686:e=>{e.exports=p},290:e=>{e.exports=d},2:e=>{e.exports=u},204:e=>{e.exports=o}},m={};function v(e){var t=m[e];if(void 0!==t)return t.exports;var a=m[e]={exports:{}};return h[e](a,a.exports,v),a.exports}v.d=(e,t)=>{for(var a in t)v.o(t,a)&&!v.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},v.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),v.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var y={};return(()=>{v.r(y),v.d(y,{fireworks:()=>P});var e=v(533);class t{constructor(){this.brightness={min:-30,max:30},this.colors=["#ff595e","#ffca3a","#8ac926","#1982c4","#6a4c93"],this.gravity=5,this.minHeight={min:10,max:30},this.rate=20,this.saturation={min:-30,max:30},this.sounds=!0,this.speed={min:5,max:15},this.splitCount={min:75,max:150}}load(t){t&&(void 0!==t.colors&&((0,e.isArray)(t.colors)?this.colors=[...t.colors]:this.colors=t.colors),void 0!==t.brightness&&(this.brightness=(0,e.setRangeValue)(t.brightness)),void 0!==t.gravity&&(this.gravity=(0,e.setRangeValue)(t.gravity)),void 0!==t.minHeight&&(this.minHeight=(0,e.setRangeValue)(t.minHeight)),void 0!==t.rate&&(this.rate=(0,e.setRangeValue)(t.rate)),void 0!==t.saturation&&(this.saturation=(0,e.setRangeValue)(t.saturation)),void 0!==t.sounds&&(this.sounds=t.sounds),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)),void 0!==t.splitCount&&(this.splitCount=(0,e.setRangeValue)(t.splitCount)))}}var a=v(619),i=v(163),s=v(501),r=v(686),o=v(290),n=v(2);var l=v(344),c=v(68),p=v(84),d=v(137);class u{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,e.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class h extends e.ValueWithRandom{constructor(){super(),this.animation=new u,this.direction="clockwise",this.path=!1,this.value=0}load(e){e&&(super.load(e),void 0!==e.direction&&(this.direction=e.direction),this.animation.load(e.animation),void 0!==e.path&&(this.path=e.path))}}class m{constructor(e){this.container=e}init(t){const a=t.options.rotate;if(!a)return;t.rotate={enable:a.animation.enable,value:(0,e.getRangeValue)(a.value)*Math.PI/180},t.pathRotation=a.path;let i=a.direction;if("random"===i){i=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(i){case"counter-clockwise":case"counterClockwise":t.rotate.status="decreasing";break;case"clockwise":t.rotate.status="increasing"}const s=a.animation;s.enable&&(t.rotate.decay=1-(0,e.getRangeValue)(s.decay),t.rotate.velocity=(0,e.getRangeValue)(s.speed)/360*this.container.retina.reduceFactor,s.sync||(t.rotate.velocity*=(0,e.getRandom)())),t.rotation=t.rotate.value}isEnabled(e){const t=e.options.rotate;return!!t&&(!e.destroyed&&!e.spawning&&t.animation.enable&&!t.path)}loadOptions(e,...t){e.rotate||(e.rotate=new h);for(const a of t)e.rotate.load(a?.rotate)}update(e,t){this.isEnabled(e)&&(!function(e,t){const a=e.rotate,i=e.options.rotate;if(!a||!i)return;const s=i.animation,r=(a.velocity??0)*t.factor,o=2*Math.PI,n=a.decay??1;s.enable&&("increasing"===a.status?(a.value+=r,a.value>o&&(a.value-=o)):(a.value-=r,a.value<0&&(a.value+=o)),a.velocity&&1!==n&&(a.velocity*=n))}(e,t),e.rotation=e.rotate?.value??0)}}var g=v(490),w=v(204);let f=!1,b=!1;const x=e=>"line"===e.data.particle.shape;class q{constructor(e){this._container=e}pause(){this._container.pause()}play(){this._container.play()}stop(){this._container.stop()}}async function R(){if(!f){if(b)return new Promise((e=>{const t=setInterval((()=>{f&&(clearInterval(t),e())}),100)}));b=!0,await(0,c.loadEmittersPlugin)(e.tsParticles,!1),await(0,g.loadSoundsPlugin)(e.tsParticles,!1),await(0,d.loadLineShape)(e.tsParticles,!1),await async function(e,t=!0){await e.addParticleUpdater("rotate",(e=>new m(e)),t)}(e.tsParticles,!1),await(0,l.loadDestroyUpdater)(e.tsParticles,!1),await(0,p.loadLifeUpdater)(e.tsParticles,!1),await(0,w.loadStrokeColorUpdater)(e.tsParticles,!1),await async function(e,t=!0){await(0,a.loadBaseMover)(e,!1),await(0,i.loadCircleShape)(e,!1),await(0,s.loadColorUpdater)(e,!1),await(0,r.loadOpacityUpdater)(e,!1),await(0,o.loadOutModesUpdater)(e,!1),await(0,n.loadSizeUpdater)(e,!1),await e.refresh(t)}(e.tsParticles,!1),b=!1,f=!0}}async function P(a,i){let s;await R();const r=new t;(0,e.isString)(a)?(s=a,r.load(i)):(s="fireworks",r.load(a));const o={detectRetina:!0,background:{color:"#000"},fpsLimit:120,emitters:{direction:"top",life:{count:0,duration:.1,delay:.1},rate:{delay:(0,e.isNumber)(r.rate)?1/r.rate:{min:1/(0,e.getRangeMin)(r.rate),max:1/(0,e.getRangeMax)(r.rate)},quantity:1},size:{width:100,height:0},position:{y:100,x:50}},particles:{number:{value:0},color:{value:r.colors},destroy:{mode:"split",bounds:{top:(0,e.setRangeValue)(r.minHeight)},split:{sizeOffset:!1,count:1,factor:{value:.333333},rate:{value:r.splitCount},colorOffset:{s:r.saturation,l:r.brightness},particles:{stroke:{width:0},number:{value:0},opacity:{value:{min:.1,max:1},animation:{enable:!0,speed:.7,sync:!1,startValue:"max",destroy:"min"}},shape:{type:"circle"},size:{value:{min:1,max:2},animation:{enable:!0,speed:5,count:1,sync:!1,startValue:"min",destroy:"none"}},life:{count:1,duration:{value:{min:.25,max:.5}}},move:{decay:{min:.05,max:.1},enable:!0,gravity:{enable:!0,inverse:!1,acceleration:(0,e.setRangeValue)(r.gravity)},speed:(0,e.setRangeValue)(r.speed),direction:"none",outModes:"destroy"}}}},life:{count:1},shape:{type:"line",options:{line:{cap:"round"}}},size:{value:{min:.1,max:50},animation:{enable:!0,sync:!0,speed:90,startValue:"max",destroy:"min"}},stroke:{color:{value:"#ffffff"},width:.5},rotate:{path:!0},move:{enable:!0,gravity:{acceleration:15,enable:!0,inverse:!0,maxSpeed:100},speed:{min:10,max:20},outModes:{default:"destroy",top:"none"},trail:{fill:{color:"#000"},enable:!0,length:10}}},sounds:{enable:r.sounds,events:[{event:"particleRemoved",filter:x,audio:["https://particles.js.org/audio/explosion0.mp3","https://particles.js.org/audio/explosion1.mp3","https://particles.js.org/audio/explosion2.mp3"]}],volume:50}},n=await e.tsParticles.load({id:s,options:o});if(n)return new q(n)}P.version=e.tsParticles.version,(0,e.isSsr)()||(window.fireworks=P)})(),y})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Fireworks v3.0.0-beta.0 by Matteo Bruni */
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type IOptionLoader, type RangeValue, type RecursivePartial, type SingleOrMultiple } from "@tsparticles/engine";
|
|
2
|
+
import type { IFireworkOptions } from "./IFireworkOptions";
|
|
3
|
+
export declare class FireworkOptions implements IFireworkOptions, IOptionLoader<IFireworkOptions> {
|
|
4
|
+
brightness: RangeValue;
|
|
5
|
+
colors: SingleOrMultiple<string>;
|
|
6
|
+
gravity: RangeValue;
|
|
7
|
+
minHeight: RangeValue;
|
|
8
|
+
rate: RangeValue;
|
|
9
|
+
saturation: RangeValue;
|
|
10
|
+
sounds: boolean;
|
|
11
|
+
speed: RangeValue;
|
|
12
|
+
splitCount: RangeValue;
|
|
13
|
+
constructor();
|
|
14
|
+
load(data?: RecursivePartial<IFireworkOptions>): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RangeValue, SingleOrMultiple } from "@tsparticles/engine";
|
|
2
|
+
export interface IFireworkOptions {
|
|
3
|
+
brightness: RangeValue;
|
|
4
|
+
colors: SingleOrMultiple<string>;
|
|
5
|
+
gravity: RangeValue;
|
|
6
|
+
minHeight: RangeValue;
|
|
7
|
+
rate: RangeValue;
|
|
8
|
+
saturation: RangeValue;
|
|
9
|
+
sounds: boolean;
|
|
10
|
+
speed: RangeValue;
|
|
11
|
+
splitCount: RangeValue;
|
|
12
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Container, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IFireworkOptions } from "./IFireworkOptions";
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
fireworks: ((idOrOptions: string | RecursivePartial<IFireworkOptions>, sourceOptions?: RecursivePartial<IFireworkOptions>) => Promise<FireworksInstance | undefined>) & {
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare class FireworksInstance {
|
|
11
|
+
private readonly _container;
|
|
12
|
+
constructor(container: Container);
|
|
13
|
+
pause(): void;
|
|
14
|
+
play(): void;
|
|
15
|
+
stop(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function fireworks(idOrOptions: string | RecursivePartial<IFireworkOptions>, sourceOptions?: RecursivePartial<IFireworkOptions>): Promise<FireworksInstance | undefined>;
|
|
18
|
+
export declare namespace fireworks {
|
|
19
|
+
var version: string;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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.FireworkOptions = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class FireworkOptions {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.brightness = {
|
|
17
|
+
min: -30,
|
|
18
|
+
max: 30,
|
|
19
|
+
};
|
|
20
|
+
this.colors = ["#ff595e", "#ffca3a", "#8ac926", "#1982c4", "#6a4c93"];
|
|
21
|
+
this.gravity = 5;
|
|
22
|
+
this.minHeight = {
|
|
23
|
+
min: 10,
|
|
24
|
+
max: 30,
|
|
25
|
+
};
|
|
26
|
+
this.rate = 20;
|
|
27
|
+
this.saturation = {
|
|
28
|
+
min: -30,
|
|
29
|
+
max: 30,
|
|
30
|
+
};
|
|
31
|
+
this.sounds = true;
|
|
32
|
+
this.speed = { min: 5, max: 15 };
|
|
33
|
+
this.splitCount = {
|
|
34
|
+
min: 75,
|
|
35
|
+
max: 150,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
load(data) {
|
|
39
|
+
if (!data) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (data.colors !== undefined) {
|
|
43
|
+
if ((0, engine_1.isArray)(data.colors)) {
|
|
44
|
+
this.colors = [...data.colors];
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
this.colors = data.colors;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (data.brightness !== undefined) {
|
|
51
|
+
this.brightness = (0, engine_1.setRangeValue)(data.brightness);
|
|
52
|
+
}
|
|
53
|
+
if (data.gravity !== undefined) {
|
|
54
|
+
this.gravity = (0, engine_1.setRangeValue)(data.gravity);
|
|
55
|
+
}
|
|
56
|
+
if (data.minHeight !== undefined) {
|
|
57
|
+
this.minHeight = (0, engine_1.setRangeValue)(data.minHeight);
|
|
58
|
+
}
|
|
59
|
+
if (data.rate !== undefined) {
|
|
60
|
+
this.rate = (0, engine_1.setRangeValue)(data.rate);
|
|
61
|
+
}
|
|
62
|
+
if (data.saturation !== undefined) {
|
|
63
|
+
this.saturation = (0, engine_1.setRangeValue)(data.saturation);
|
|
64
|
+
}
|
|
65
|
+
if (data.sounds !== undefined) {
|
|
66
|
+
this.sounds = data.sounds;
|
|
67
|
+
}
|
|
68
|
+
if (data.speed !== undefined) {
|
|
69
|
+
this.speed = (0, engine_1.setRangeValue)(data.speed);
|
|
70
|
+
}
|
|
71
|
+
if (data.splitCount !== undefined) {
|
|
72
|
+
this.splitCount = (0, engine_1.setRangeValue)(data.splitCount);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.FireworkOptions = FireworkOptions;
|
|
77
|
+
});
|
|
@@ -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/bundle.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", ".", "@tsparticles/engine"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("."), exports);
|
|
27
|
+
__exportStar(require("@tsparticles/engine"), exports);
|
|
28
|
+
});
|
package/umd/fireworks.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
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", "./FireworkOptions", "@tsparticles/basic", "@tsparticles/updater-destroy", "@tsparticles/plugin-emitters", "@tsparticles/updater-life", "@tsparticles/shape-line", "@tsparticles/updater-rotate", "@tsparticles/plugin-sounds", "@tsparticles/updater-stroke-color"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fireworks = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const FireworkOptions_1 = require("./FireworkOptions");
|
|
15
|
+
const basic_1 = require("@tsparticles/basic");
|
|
16
|
+
const updater_destroy_1 = require("@tsparticles/updater-destroy");
|
|
17
|
+
const plugin_emitters_1 = require("@tsparticles/plugin-emitters");
|
|
18
|
+
const updater_life_1 = require("@tsparticles/updater-life");
|
|
19
|
+
const shape_line_1 = require("@tsparticles/shape-line");
|
|
20
|
+
const updater_rotate_1 = require("@tsparticles/updater-rotate");
|
|
21
|
+
const plugin_sounds_1 = require("@tsparticles/plugin-sounds");
|
|
22
|
+
const updater_stroke_color_1 = require("@tsparticles/updater-stroke-color");
|
|
23
|
+
let initialized = false;
|
|
24
|
+
let initializing = false;
|
|
25
|
+
const explodeSoundCheck = (args) => {
|
|
26
|
+
const data = args.data;
|
|
27
|
+
return data.particle.shape === "line";
|
|
28
|
+
};
|
|
29
|
+
class FireworksInstance {
|
|
30
|
+
constructor(container) {
|
|
31
|
+
this._container = container;
|
|
32
|
+
}
|
|
33
|
+
pause() {
|
|
34
|
+
this._container.pause();
|
|
35
|
+
}
|
|
36
|
+
play() {
|
|
37
|
+
this._container.play();
|
|
38
|
+
}
|
|
39
|
+
stop() {
|
|
40
|
+
this._container.stop();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function initPlugins() {
|
|
44
|
+
if (initialized) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (initializing) {
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const interval = setInterval(() => {
|
|
50
|
+
if (!initialized) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
clearInterval(interval);
|
|
54
|
+
resolve();
|
|
55
|
+
}, 100);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
initializing = true;
|
|
59
|
+
await (0, plugin_emitters_1.loadEmittersPlugin)(engine_1.tsParticles, false);
|
|
60
|
+
await (0, plugin_sounds_1.loadSoundsPlugin)(engine_1.tsParticles, false);
|
|
61
|
+
await (0, shape_line_1.loadLineShape)(engine_1.tsParticles, false);
|
|
62
|
+
await (0, updater_rotate_1.loadRotateUpdater)(engine_1.tsParticles, false);
|
|
63
|
+
await (0, updater_destroy_1.loadDestroyUpdater)(engine_1.tsParticles, false);
|
|
64
|
+
await (0, updater_life_1.loadLifeUpdater)(engine_1.tsParticles, false);
|
|
65
|
+
await (0, updater_stroke_color_1.loadStrokeColorUpdater)(engine_1.tsParticles, false);
|
|
66
|
+
await (0, basic_1.loadBasic)(engine_1.tsParticles, false);
|
|
67
|
+
initializing = false;
|
|
68
|
+
initialized = true;
|
|
69
|
+
}
|
|
70
|
+
async function fireworks(idOrOptions, sourceOptions) {
|
|
71
|
+
await initPlugins();
|
|
72
|
+
let id;
|
|
73
|
+
const options = new FireworkOptions_1.FireworkOptions();
|
|
74
|
+
if ((0, engine_1.isString)(idOrOptions)) {
|
|
75
|
+
id = idOrOptions;
|
|
76
|
+
options.load(sourceOptions);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
id = "fireworks";
|
|
80
|
+
options.load(idOrOptions);
|
|
81
|
+
}
|
|
82
|
+
const particlesOptions = {
|
|
83
|
+
detectRetina: true,
|
|
84
|
+
background: {
|
|
85
|
+
color: "#000",
|
|
86
|
+
},
|
|
87
|
+
fpsLimit: 120,
|
|
88
|
+
emitters: {
|
|
89
|
+
direction: "top",
|
|
90
|
+
life: {
|
|
91
|
+
count: 0,
|
|
92
|
+
duration: 0.1,
|
|
93
|
+
delay: 0.1,
|
|
94
|
+
},
|
|
95
|
+
rate: {
|
|
96
|
+
delay: (0, engine_1.isNumber)(options.rate)
|
|
97
|
+
? 1 / options.rate
|
|
98
|
+
: { min: 1 / (0, engine_1.getRangeMin)(options.rate), max: 1 / (0, engine_1.getRangeMax)(options.rate) },
|
|
99
|
+
quantity: 1,
|
|
100
|
+
},
|
|
101
|
+
size: {
|
|
102
|
+
width: 100,
|
|
103
|
+
height: 0,
|
|
104
|
+
},
|
|
105
|
+
position: {
|
|
106
|
+
y: 100,
|
|
107
|
+
x: 50,
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
particles: {
|
|
111
|
+
number: {
|
|
112
|
+
value: 0,
|
|
113
|
+
},
|
|
114
|
+
color: {
|
|
115
|
+
value: options.colors,
|
|
116
|
+
},
|
|
117
|
+
destroy: {
|
|
118
|
+
mode: "split",
|
|
119
|
+
bounds: {
|
|
120
|
+
top: (0, engine_1.setRangeValue)(options.minHeight),
|
|
121
|
+
},
|
|
122
|
+
split: {
|
|
123
|
+
sizeOffset: false,
|
|
124
|
+
count: 1,
|
|
125
|
+
factor: {
|
|
126
|
+
value: 0.333333,
|
|
127
|
+
},
|
|
128
|
+
rate: {
|
|
129
|
+
value: options.splitCount,
|
|
130
|
+
},
|
|
131
|
+
colorOffset: {
|
|
132
|
+
s: options.saturation,
|
|
133
|
+
l: options.brightness,
|
|
134
|
+
},
|
|
135
|
+
particles: {
|
|
136
|
+
stroke: {
|
|
137
|
+
width: 0,
|
|
138
|
+
},
|
|
139
|
+
number: {
|
|
140
|
+
value: 0,
|
|
141
|
+
},
|
|
142
|
+
opacity: {
|
|
143
|
+
value: {
|
|
144
|
+
min: 0.1,
|
|
145
|
+
max: 1,
|
|
146
|
+
},
|
|
147
|
+
animation: {
|
|
148
|
+
enable: true,
|
|
149
|
+
speed: 0.7,
|
|
150
|
+
sync: false,
|
|
151
|
+
startValue: "max",
|
|
152
|
+
destroy: "min",
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
shape: {
|
|
156
|
+
type: "circle",
|
|
157
|
+
},
|
|
158
|
+
size: {
|
|
159
|
+
value: { min: 1, max: 2 },
|
|
160
|
+
animation: {
|
|
161
|
+
enable: true,
|
|
162
|
+
speed: 5,
|
|
163
|
+
count: 1,
|
|
164
|
+
sync: false,
|
|
165
|
+
startValue: "min",
|
|
166
|
+
destroy: "none",
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
life: {
|
|
170
|
+
count: 1,
|
|
171
|
+
duration: {
|
|
172
|
+
value: {
|
|
173
|
+
min: 0.25,
|
|
174
|
+
max: 0.5,
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
move: {
|
|
179
|
+
decay: { min: 0.05, max: 0.1 },
|
|
180
|
+
enable: true,
|
|
181
|
+
gravity: {
|
|
182
|
+
enable: true,
|
|
183
|
+
inverse: false,
|
|
184
|
+
acceleration: (0, engine_1.setRangeValue)(options.gravity),
|
|
185
|
+
},
|
|
186
|
+
speed: (0, engine_1.setRangeValue)(options.speed),
|
|
187
|
+
direction: "none",
|
|
188
|
+
outModes: "destroy",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
life: {
|
|
194
|
+
count: 1,
|
|
195
|
+
},
|
|
196
|
+
shape: {
|
|
197
|
+
type: "line",
|
|
198
|
+
options: {
|
|
199
|
+
line: {
|
|
200
|
+
cap: "round",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
size: {
|
|
205
|
+
value: {
|
|
206
|
+
min: 0.1,
|
|
207
|
+
max: 50,
|
|
208
|
+
},
|
|
209
|
+
animation: {
|
|
210
|
+
enable: true,
|
|
211
|
+
sync: true,
|
|
212
|
+
speed: 90,
|
|
213
|
+
startValue: "max",
|
|
214
|
+
destroy: "min",
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
stroke: {
|
|
218
|
+
color: {
|
|
219
|
+
value: "#ffffff",
|
|
220
|
+
},
|
|
221
|
+
width: 0.5,
|
|
222
|
+
},
|
|
223
|
+
rotate: {
|
|
224
|
+
path: true,
|
|
225
|
+
},
|
|
226
|
+
move: {
|
|
227
|
+
enable: true,
|
|
228
|
+
gravity: {
|
|
229
|
+
acceleration: 15,
|
|
230
|
+
enable: true,
|
|
231
|
+
inverse: true,
|
|
232
|
+
maxSpeed: 100,
|
|
233
|
+
},
|
|
234
|
+
speed: {
|
|
235
|
+
min: 10,
|
|
236
|
+
max: 20,
|
|
237
|
+
},
|
|
238
|
+
outModes: {
|
|
239
|
+
default: "destroy",
|
|
240
|
+
top: "none",
|
|
241
|
+
},
|
|
242
|
+
trail: {
|
|
243
|
+
fill: {
|
|
244
|
+
color: "#000",
|
|
245
|
+
},
|
|
246
|
+
enable: true,
|
|
247
|
+
length: 10,
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
sounds: {
|
|
252
|
+
enable: options.sounds,
|
|
253
|
+
events: [
|
|
254
|
+
{
|
|
255
|
+
event: "particleRemoved",
|
|
256
|
+
filter: explodeSoundCheck,
|
|
257
|
+
audio: [
|
|
258
|
+
"https://particles.js.org/audio/explosion0.mp3",
|
|
259
|
+
"https://particles.js.org/audio/explosion1.mp3",
|
|
260
|
+
"https://particles.js.org/audio/explosion2.mp3",
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
volume: 50,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
const container = await engine_1.tsParticles.load({ id, options: particlesOptions });
|
|
268
|
+
if (!container) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
return new FireworksInstance(container);
|
|
272
|
+
}
|
|
273
|
+
exports.fireworks = fireworks;
|
|
274
|
+
fireworks.version = engine_1.tsParticles.version;
|
|
275
|
+
if (!(0, engine_1.isSsr)()) {
|
|
276
|
+
window.fireworks = fireworks;
|
|
277
|
+
}
|
|
278
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", "./fireworks"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("./fireworks"), exports);
|
|
27
|
+
});
|