@tsparticles/particles 4.0.0-beta.12
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 +22 -0
- package/README.md +112 -0
- package/browser/IParticlesOptions.js +1 -0
- package/browser/ParticlesInstance.js +15 -0
- package/browser/browser.js +5 -0
- package/browser/bundle.js +6 -0
- package/browser/index.js +1 -0
- package/browser/index.lazy.js +1 -0
- package/browser/package.json +1 -0
- package/browser/particles.js +53 -0
- package/browser/particles.lazy.js +54 -0
- package/browser/types.js +1 -0
- package/browser/utils.js +55 -0
- package/cjs/IParticlesOptions.js +1 -0
- package/cjs/ParticlesInstance.js +15 -0
- package/cjs/browser.js +5 -0
- package/cjs/bundle.js +6 -0
- package/cjs/index.js +1 -0
- package/cjs/index.lazy.js +1 -0
- package/cjs/package.json +1 -0
- package/cjs/particles.js +53 -0
- package/cjs/particles.lazy.js +54 -0
- package/cjs/types.js +1 -0
- package/cjs/utils.js +55 -0
- package/esm/IParticlesOptions.js +1 -0
- package/esm/ParticlesInstance.js +15 -0
- package/esm/browser.js +5 -0
- package/esm/bundle.js +6 -0
- package/esm/index.js +1 -0
- package/esm/index.lazy.js +1 -0
- package/esm/package.json +1 -0
- package/esm/particles.js +53 -0
- package/esm/particles.lazy.js +54 -0
- package/esm/types.js +1 -0
- package/esm/utils.js +55 -0
- package/package.json +53 -0
- package/report.html +4950 -0
- package/tsparticles.particles.bundle.js +7819 -0
- package/tsparticles.particles.bundle.min.js +1 -0
- package/tsparticles.particles.js +145 -0
- package/tsparticles.particles.min.js +1 -0
- package/types/IParticlesOptions.d.ts +13 -0
- package/types/ParticlesInstance.d.ts +8 -0
- package/types/browser.d.ts +1 -0
- package/types/bundle.d.ts +3 -0
- package/types/index.d.ts +4 -0
- package/types/index.lazy.d.ts +4 -0
- package/types/particles.d.ts +17 -0
- package/types/particles.lazy.d.ts +17 -0
- package/types/types.d.ts +6 -0
- package/types/utils.d.ts +4 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { isString, tsParticles } from "@tsparticles/engine/lazy";
|
|
2
|
+
import { getParticlesInstance } from "./utils.js";
|
|
3
|
+
let initPromise = null;
|
|
4
|
+
async function doInitPlugins(engine) {
|
|
5
|
+
engine.checkVersion("4.0.0-beta.12");
|
|
6
|
+
await engine.pluginManager.register(async (e) => {
|
|
7
|
+
const [{ loadBasic }, { loadInteractivityPlugin }, { loadParticlesCollisionsInteraction }, { loadParticlesLinksInteraction },] = await Promise.all([
|
|
8
|
+
import("@tsparticles/basic/lazy"),
|
|
9
|
+
import("@tsparticles/plugin-interactivity/lazy"),
|
|
10
|
+
import("@tsparticles/interaction-particles-collisions/lazy"),
|
|
11
|
+
import("@tsparticles/interaction-particles-links/lazy"),
|
|
12
|
+
]), loadParticlesInteractivity = async (e) => {
|
|
13
|
+
await loadInteractivityPlugin(e);
|
|
14
|
+
await Promise.all([
|
|
15
|
+
loadParticlesCollisionsInteraction(e),
|
|
16
|
+
loadParticlesLinksInteraction(e),
|
|
17
|
+
]);
|
|
18
|
+
};
|
|
19
|
+
await Promise.all([
|
|
20
|
+
loadBasic(e),
|
|
21
|
+
loadParticlesInteractivity(e),
|
|
22
|
+
]);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function initPlugins(engine) {
|
|
26
|
+
if (initPromise) {
|
|
27
|
+
return initPromise;
|
|
28
|
+
}
|
|
29
|
+
initPromise = doInitPlugins(engine);
|
|
30
|
+
return initPromise;
|
|
31
|
+
}
|
|
32
|
+
export async function particles(idOrOptions, sourceOptions) {
|
|
33
|
+
await initPlugins(tsParticles);
|
|
34
|
+
let id, options;
|
|
35
|
+
if (isString(idOrOptions)) {
|
|
36
|
+
id = idOrOptions;
|
|
37
|
+
options = sourceOptions ?? {};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
id = "particles";
|
|
41
|
+
options = idOrOptions ?? {};
|
|
42
|
+
}
|
|
43
|
+
return getParticlesInstance(tsParticles, id, options);
|
|
44
|
+
}
|
|
45
|
+
particles.create = async (canvas, options) => {
|
|
46
|
+
await initPlugins(tsParticles);
|
|
47
|
+
const id = canvas.id || "particles";
|
|
48
|
+
return getParticlesInstance(tsParticles, id, options ?? {}, canvas);
|
|
49
|
+
};
|
|
50
|
+
particles.init = async () => {
|
|
51
|
+
await initPlugins(tsParticles);
|
|
52
|
+
};
|
|
53
|
+
particles.version = "4.0.0-beta.12";
|
|
54
|
+
globalThis.particles = particles;
|
package/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/utils.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const instances = new Map(), defaultCount = 80, defaultLinksWidth = 100, defaultSpeed = 3, defaultOpacity = 1, defaultRadius = 3;
|
|
2
|
+
function getDefaultOptions(options) {
|
|
3
|
+
return {
|
|
4
|
+
particles: {
|
|
5
|
+
number: {
|
|
6
|
+
value: options.count ?? defaultCount,
|
|
7
|
+
},
|
|
8
|
+
color: {
|
|
9
|
+
value: options.color ?? "#fff",
|
|
10
|
+
},
|
|
11
|
+
links: {
|
|
12
|
+
enable: options.links ?? false,
|
|
13
|
+
color: options.linksColor ?? "#fff",
|
|
14
|
+
distance: options.linksLength ?? defaultLinksWidth,
|
|
15
|
+
},
|
|
16
|
+
collisions: {
|
|
17
|
+
enable: options.collisions ?? false,
|
|
18
|
+
},
|
|
19
|
+
move: {
|
|
20
|
+
enable: true,
|
|
21
|
+
speed: options.speed ?? defaultSpeed,
|
|
22
|
+
},
|
|
23
|
+
opacity: {
|
|
24
|
+
value: options.opacity ?? defaultOpacity,
|
|
25
|
+
},
|
|
26
|
+
shape: {
|
|
27
|
+
type: options.shape ?? "circle",
|
|
28
|
+
},
|
|
29
|
+
size: {
|
|
30
|
+
value: options.radius ?? defaultRadius,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export async function getParticlesInstance(engine, id, sourceOptions, canvas) {
|
|
36
|
+
const existing = instances.get(id);
|
|
37
|
+
if (existing instanceof Promise) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
if (existing) {
|
|
41
|
+
return existing;
|
|
42
|
+
}
|
|
43
|
+
const create = async () => {
|
|
44
|
+
const particlesOptions = getDefaultOptions(sourceOptions), container = await engine.load({ id, element: canvas, options: particlesOptions });
|
|
45
|
+
if (!container) {
|
|
46
|
+
instances.delete(id);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { ParticlesInstance } = await import("./ParticlesInstance.js"), instance = new ParticlesInstance(container);
|
|
50
|
+
instances.set(id, instance);
|
|
51
|
+
return instance;
|
|
52
|
+
}, createPromise = create();
|
|
53
|
+
instances.set(id, createPromise);
|
|
54
|
+
return createPromise;
|
|
55
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/particles",
|
|
3
|
+
"version": "4.0.0-beta.12",
|
|
4
|
+
"description": "Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
|
|
5
|
+
"homepage": "https://particles.js.org",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/tsparticles/tsparticles.git",
|
|
9
|
+
"directory": "bundles/particles"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"particles",
|
|
13
|
+
"tsparticles",
|
|
14
|
+
"canvas"
|
|
15
|
+
],
|
|
16
|
+
"author": "Matteo Bruni <matteo.bruni@me.com>",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"jsdelivr": "tsparticles.particles.bundle.min.js",
|
|
20
|
+
"unpkg": "tsparticles.particles.bundle.min.js",
|
|
21
|
+
"browser": "browser/index.js",
|
|
22
|
+
"main": "cjs/index.js",
|
|
23
|
+
"module": "esm/index.js",
|
|
24
|
+
"types": "types/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./types/index.d.ts",
|
|
28
|
+
"browser": "./browser/index.js",
|
|
29
|
+
"import": "./esm/index.js",
|
|
30
|
+
"require": "./cjs/index.js",
|
|
31
|
+
"default": "./esm/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./lazy": {
|
|
34
|
+
"types": "./types/index.lazy.d.ts",
|
|
35
|
+
"browser": "./browser/index.lazy.js",
|
|
36
|
+
"import": "./esm/index.lazy.js",
|
|
37
|
+
"require": "./cjs/index.lazy.js",
|
|
38
|
+
"default": "./esm/index.lazy.js"
|
|
39
|
+
},
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@tsparticles/basic": "4.0.0-beta.12",
|
|
44
|
+
"@tsparticles/engine": "4.0.0-beta.12",
|
|
45
|
+
"@tsparticles/interaction-particles-collisions": "4.0.0-beta.12",
|
|
46
|
+
"@tsparticles/interaction-particles-links": "4.0.0-beta.12",
|
|
47
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.12"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"type": "module"
|
|
53
|
+
}
|