@tsparticles/particles 4.1.2 → 4.2.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/browser/ParticlesInstance.js +11 -1
- package/browser/particles.js +2 -2
- package/browser/particles.lazy.js +2 -2
- package/browser/utils.js +10 -3
- package/cjs/ParticlesInstance.js +11 -1
- package/cjs/particles.js +2 -2
- package/cjs/particles.lazy.js +2 -2
- package/cjs/utils.js +10 -3
- package/esm/ParticlesInstance.js +11 -1
- package/esm/particles.js +2 -2
- package/esm/particles.lazy.js +2 -2
- package/esm/utils.js +10 -3
- package/package.json +49 -8
- package/report.html +1 -1
- package/tsparticles.particles.bundle.js +1073 -1710
- package/tsparticles.particles.bundle.min.js +1 -1
- package/tsparticles.particles.js +23 -7
- package/tsparticles.particles.min.js +1 -1
- package/types/ParticlesInstance.d.ts +3 -1
- package/types/utils.d.ts +1 -0
package/tsparticles.particles.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* tsParticles v4.
|
|
2
|
+
/* tsParticles v4.2.0 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine'), require('@tsparticles/basic'), require('@tsparticles/plugin-interactivity'), require('@tsparticles/interaction-particles-collisions'), require('@tsparticles/interaction-particles-links')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine', '@tsparticles/basic', '@tsparticles/plugin-interactivity', '@tsparticles/interaction-particles-collisions', '@tsparticles/interaction-particles-links'], factory) :
|
|
6
6
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.bundles = global.__tsParticlesInternals.bundles || {}, global.__tsParticlesInternals.bundles.particles = global.__tsParticlesInternals.bundles.particles || {}), global.__tsParticlesInternals.engine, global.__tsParticlesInternals.bundles.basic, global.__tsParticlesInternals.plugins.interactivity, global.__tsParticlesInternals.interactions.particlesCollisions, global.__tsParticlesInternals.interactions.particlesLinks));
|
|
7
7
|
})(this, (function (exports, engine, basic, pluginInteractivity, interactionParticlesCollisions, interactionParticlesLinks) { 'use strict';
|
|
8
8
|
|
|
9
|
-
const instances = new Map()
|
|
9
|
+
const instances = new Map();
|
|
10
|
+
function deleteParticlesInstance(id) {
|
|
11
|
+
instances.delete(id);
|
|
12
|
+
}
|
|
13
|
+
const defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
|
|
10
14
|
function getDefaultOptions(options, canvas) {
|
|
11
15
|
return {
|
|
12
16
|
fullScreen: {
|
|
@@ -49,7 +53,10 @@
|
|
|
49
53
|
return existing;
|
|
50
54
|
}
|
|
51
55
|
if (existing) {
|
|
52
|
-
|
|
56
|
+
if (!existing.destroyed) {
|
|
57
|
+
return existing;
|
|
58
|
+
}
|
|
59
|
+
instances.delete(id);
|
|
53
60
|
}
|
|
54
61
|
const create = async () => {
|
|
55
62
|
const particlesOptions = getDefaultOptions(sourceOptions, canvas), container = await engine.load({ id, element: canvas, options: particlesOptions });
|
|
@@ -57,7 +64,7 @@
|
|
|
57
64
|
instances.delete(id);
|
|
58
65
|
return;
|
|
59
66
|
}
|
|
60
|
-
const { ParticlesInstance } = await Promise.resolve().then(function () { return ParticlesInstance$1; }), instance = new ParticlesInstance(container);
|
|
67
|
+
const { ParticlesInstance } = await Promise.resolve().then(function () { return ParticlesInstance$1; }), instance = new ParticlesInstance(container, id);
|
|
61
68
|
instances.set(id, instance);
|
|
62
69
|
return instance;
|
|
63
70
|
}, createPromise = create();
|
|
@@ -67,7 +74,7 @@
|
|
|
67
74
|
|
|
68
75
|
let initPromise = null;
|
|
69
76
|
async function doInitPlugins(engine) {
|
|
70
|
-
engine.checkVersion("4.
|
|
77
|
+
engine.checkVersion("4.2.0");
|
|
71
78
|
await engine.pluginManager.register(async (e) => {
|
|
72
79
|
const loadParticlesInteractivity = async (e) => {
|
|
73
80
|
await pluginInteractivity.loadInteractivityPlugin(e);
|
|
@@ -110,7 +117,7 @@
|
|
|
110
117
|
particles.init = async () => {
|
|
111
118
|
await initPlugins(engine.tsParticles);
|
|
112
119
|
};
|
|
113
|
-
particles.version = "4.
|
|
120
|
+
particles.version = "4.2.0";
|
|
114
121
|
globalThis.particles = particles;
|
|
115
122
|
|
|
116
123
|
const globalObject = globalThis;
|
|
@@ -119,8 +126,17 @@
|
|
|
119
126
|
|
|
120
127
|
class ParticlesInstance {
|
|
121
128
|
#container;
|
|
122
|
-
|
|
129
|
+
#id;
|
|
130
|
+
constructor(container, id) {
|
|
123
131
|
this.#container = container;
|
|
132
|
+
this.#id = id;
|
|
133
|
+
}
|
|
134
|
+
get destroyed() {
|
|
135
|
+
return this.#container.destroyed;
|
|
136
|
+
}
|
|
137
|
+
destroy() {
|
|
138
|
+
this.#container.destroy();
|
|
139
|
+
deleteParticlesInstance(this.#id);
|
|
124
140
|
}
|
|
125
141
|
pause() {
|
|
126
142
|
this.#container.pause();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine"),require("@tsparticles/basic"),require("@tsparticles/plugin-interactivity"),require("@tsparticles/interaction-particles-collisions"),require("@tsparticles/interaction-particles-links")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine","@tsparticles/basic","@tsparticles/plugin-interactivity","@tsparticles/interaction-particles-collisions","@tsparticles/interaction-particles-links"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.bundles.particles=t.__tsParticlesInternals.bundles.particles||{}),t.__tsParticlesInternals.engine,t.__tsParticlesInternals.bundles.basic,t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.interactions.particlesCollisions,t.__tsParticlesInternals.interactions.particlesLinks)}(this,function(t,s,e,n,a,l){"use strict";const r=new Map;async function i(t,s,e,n){const a=r.get(s);if(a instanceof Promise)return a;if(a)return a;const l=(async()=>{const a=function(t,s){return{fullScreen:{enable:!s},particles:{number:{value:t.count??80},color:{value:t.color??"#fff"},links:{enable:t.links??!1,color:t.linksColor??"#fff",distance:t.linksLength??100},collisions:{enable:t.collisions??!1},move:{enable:!0,speed:t.speed??3},opacity:{value:t.opacity??1},shape:{type:t.shape??"circle"},size:{value:t.radius??3}}}}(e,n),l=await t.load({id:s,element:n,options:a});if(!l)return void r.delete(s);const{ParticlesInstance:i}=await Promise.resolve().then(function(){return P}),c=new i(l);return r.set(s,c),c})();return r.set(s,l),l}let c=null;async function _(t){return c||(c=async function(t){t.checkVersion("4.
|
|
1
|
+
!function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine"),require("@tsparticles/basic"),require("@tsparticles/plugin-interactivity"),require("@tsparticles/interaction-particles-collisions"),require("@tsparticles/interaction-particles-links")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine","@tsparticles/basic","@tsparticles/plugin-interactivity","@tsparticles/interaction-particles-collisions","@tsparticles/interaction-particles-links"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.bundles.particles=t.__tsParticlesInternals.bundles.particles||{}),t.__tsParticlesInternals.engine,t.__tsParticlesInternals.bundles.basic,t.__tsParticlesInternals.plugins.interactivity,t.__tsParticlesInternals.interactions.particlesCollisions,t.__tsParticlesInternals.interactions.particlesLinks)}(this,function(t,s,e,n,a,l){"use strict";const r=new Map;async function i(t,s,e,n){const a=r.get(s);if(a instanceof Promise)return a;if(a){if(!a.destroyed)return a;r.delete(s)}const l=(async()=>{const a=function(t,s){return{fullScreen:{enable:!s},particles:{number:{value:t.count??80},color:{value:t.color??"#fff"},links:{enable:t.links??!1,color:t.linksColor??"#fff",distance:t.linksLength??100},collisions:{enable:t.collisions??!1},move:{enable:!0,speed:t.speed??3},opacity:{value:t.opacity??1},shape:{type:t.shape??"circle"},size:{value:t.radius??3}}}}(e,n),l=await t.load({id:s,element:n,options:a});if(!l)return void r.delete(s);const{ParticlesInstance:i}=await Promise.resolve().then(function(){return P}),c=new i(l,s);return r.set(s,c),c})();return r.set(s,l),l}let c=null;async function _(t){return c||(c=async function(t){t.checkVersion("4.2.0"),await t.pluginManager.register(async t=>{await Promise.all([e.loadBasic(t),(async t=>{await n.loadInteractivityPlugin(t),await Promise.all([a.loadParticlesCollisionsInteraction(t),l.loadParticlesLinksInteraction(t)])})(t)])})}(t),c)}async function o(t,e){let n,a;return await _(s.tsParticles),s.isString(t)?(n=t,a=e??{}):(n="particles",a=t??{}),i(s.tsParticles,n,a)}o.create=async(t,e)=>{await _(s.tsParticles);const n=t?.id??"particles";return i(s.tsParticles,n,e??{},t??void 0)},o.init=async()=>{await _(s.tsParticles)},o.version="4.2.0",globalThis.particles=o;const p=globalThis;p.__tsParticlesInternals=p.__tsParticlesInternals??{},p.particles=o;var P=Object.freeze({__proto__:null,ParticlesInstance:class{#t;#s;constructor(t,s){this.#t=t,this.#s=s}get destroyed(){return this.#t.destroyed}destroy(){var t;this.#t.destroy(),t=this.#s,r.delete(t)}pause(){this.#t.pause()}play(){this.#t.play()}stop(){this.#t.stop()}}});t.particles=o}),globalThis.__tsParticlesInternals=globalThis.__tsParticlesInternals||{},globalThis.__tsParticlesInternals.engine&&globalThis.__tsParticlesInternals.engine.tsParticles||(globalThis.__tsParticlesInternals.engine=globalThis.__tsParticlesInternals.bundles.particles||{}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Container } from "@tsparticles/engine";
|
|
2
2
|
export declare class ParticlesInstance {
|
|
3
3
|
#private;
|
|
4
|
-
constructor(container: Container);
|
|
4
|
+
constructor(container: Container, id: string);
|
|
5
|
+
get destroyed(): boolean;
|
|
6
|
+
destroy(): void;
|
|
5
7
|
pause(): void;
|
|
6
8
|
play(): void;
|
|
7
9
|
stop(): void;
|
package/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Engine, RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { IParticlesOptions } from "./IParticlesOptions.js";
|
|
3
3
|
import type { ParticlesInstance } from "./ParticlesInstance.js";
|
|
4
|
+
export declare function deleteParticlesInstance(id: string): void;
|
|
4
5
|
export declare function getParticlesInstance(engine: Engine, id: string, sourceOptions: RecursivePartial<IParticlesOptions>, canvas?: HTMLCanvasElement): Promise<ParticlesInstance | undefined>;
|