Skip to content

Commit 4133772

Browse files
committed
chore(engine): refactoring on easings/color managers
chore(engine): moved all color managers from the engine to their plugins
1 parent 3afdbbb commit 4133772

199 files changed

Lines changed: 2372 additions & 422 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bundles/all/src/index.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Engine } from "@tsparticles/engine";
1+
import { type Engine, assertValidVersion } from "@tsparticles/engine";
22
import { initPjs } from "@tsparticles/pjs";
33
import { loadArrowShape } from "@tsparticles/shape-arrow";
44
import { loadBubbleEffect } from "@tsparticles/effect-bubble";
@@ -49,6 +49,8 @@ import { loadSpiralShape } from "@tsparticles/shape-spiral";
4949
import { loadTrailEffect } from "@tsparticles/effect-trail";
5050
import { loadZigZagPath } from "@tsparticles/path-zig-zag";
5151

52+
declare const __VERSION__: string;
53+
5254
/**
5355
* Loads the slime bundle with all plugins needed for running the tsParticles All package.
5456
* This function must be called to make tsParticles All work.
@@ -59,21 +61,23 @@ import { loadZigZagPath } from "@tsparticles/path-zig-zag";
5961
* @param refresh -
6062
*/
6163
export async function loadAll(engine: Engine, refresh = true): Promise<void> {
64+
assertValidVersion(engine, __VERSION__);
65+
6266
initPjs(engine);
6367

6468
await loadFull(engine, false);
6569

66-
await loadHsvColorPlugin();
67-
await loadNamedColorPlugin();
68-
await loadOklchColorPlugin();
69-
await loadEasingBackPlugin();
70-
await loadEasingCircPlugin();
71-
await loadEasingCubicPlugin();
72-
await loadEasingExpoPlugin();
73-
await loadEasingLinearPlugin();
74-
await loadEasingQuartPlugin();
75-
await loadEasingQuintPlugin();
76-
await loadEasingSinePlugin();
70+
await loadHsvColorPlugin(engine, false);
71+
await loadNamedColorPlugin(engine, false);
72+
await loadOklchColorPlugin(engine, false);
73+
await loadEasingBackPlugin(engine, false);
74+
await loadEasingCircPlugin(engine, false);
75+
await loadEasingCubicPlugin(engine, false);
76+
await loadEasingExpoPlugin(engine, false);
77+
await loadEasingLinearPlugin(engine, false);
78+
await loadEasingQuartPlugin(engine, false);
79+
await loadEasingQuintPlugin(engine, false);
80+
await loadEasingSinePlugin(engine, false);
7781

7882
await loadEmittersShapeCanvas(engine, false);
7983
await loadEmittersShapePath(engine, false);

bundles/basic/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
- [@tsparticles/engine](https://github.com/tsparticles/tsparticles/tree/main/engine)
1212
- [@tsparticles/move-base](https://github.com/tsparticles/tsparticles/tree/main/move/base)
13+
- [@tsparticles/plugin-hex-color](https://github.com/tsparticles/tsparticles/tree/main/plugins/colors/hexColor)
14+
- [@tsparticles/plugin-hsl-color](https://github.com/tsparticles/tsparticles/tree/main/plugins/colors/hslColor)
15+
- [@tsparticles/plugin-rgb-color](https://github.com/tsparticles/tsparticles/tree/main/plugins/colors/rgbColor)
1316
- [@tsparticles/shape-circle](https://github.com/tsparticles/tsparticles/tree/main/shapes/circle)
1417
- [@tsparticles/updater-color](https://github.com/tsparticles/tsparticles/tree/main/updaters/color)
1518
- [@tsparticles/updater-opacity](https://github.com/tsparticles/tsparticles/tree/main/updaters/opacity)

bundles/basic/package.dist.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
"dependencies": {
102102
"@tsparticles/engine": "3.6.0",
103103
"@tsparticles/move-base": "3.6.0",
104+
"@tsparticles/plugin-hex-color": "3.6.0",
105+
"@tsparticles/plugin-hsl-color": "3.6.0",
106+
"@tsparticles/plugin-rgb-color": "3.6.0",
104107
"@tsparticles/shape-circle": "3.6.0",
105108
"@tsparticles/updater-color": "3.6.0",
106109
"@tsparticles/updater-opacity": "3.6.0",

bundles/basic/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109
"dependencies": {
110110
"@tsparticles/engine": "workspace:3.6.0",
111111
"@tsparticles/move-base": "workspace:3.6.0",
112+
"@tsparticles/plugin-hex-color": "workspace:3.6.0",
113+
"@tsparticles/plugin-hsl-color": "workspace:3.6.0",
114+
"@tsparticles/plugin-rgb-color": "workspace:3.6.0",
112115
"@tsparticles/shape-circle": "workspace:3.6.0",
113116
"@tsparticles/updater-color": "workspace:3.6.0",
114117
"@tsparticles/updater-opacity": "workspace:3.6.0",

bundles/basic/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import type { Engine } from "@tsparticles/engine";
1+
import { type Engine, assertValidVersion } from "@tsparticles/engine";
22
import { loadBaseMover } from "@tsparticles/move-base";
33
import { loadCircleShape } from "@tsparticles/shape-circle";
44
import { loadColorUpdater } from "@tsparticles/updater-color";
5+
import { loadHexColorPlugin } from "@tsparticles/plugin-hex-color";
6+
import { loadHslColorPlugin } from "@tsparticles/plugin-hsl-color";
57
import { loadOpacityUpdater } from "@tsparticles/updater-opacity";
68
import { loadOutModesUpdater } from "@tsparticles/updater-out-modes";
9+
import { loadRgbColorPlugin } from "@tsparticles/plugin-rgb-color";
710
import { loadSizeUpdater } from "@tsparticles/updater-size";
811

12+
declare const __VERSION__: string;
13+
914
/**
1015
* Loads the slime bundle with all plugins needed for running the tsParticles Basic package.
1116
* This function must be called to make tsParticles Basic work.
@@ -16,6 +21,12 @@ import { loadSizeUpdater } from "@tsparticles/updater-size";
1621
* @param refresh -
1722
*/
1823
export async function loadBasic(engine: Engine, refresh = true): Promise<void> {
24+
assertValidVersion(engine, __VERSION__);
25+
26+
await loadHexColorPlugin(engine, false);
27+
await loadHslColorPlugin(engine, false);
28+
await loadRgbColorPlugin(engine, false);
29+
1930
await loadBaseMover(engine, false);
2031

2132
await loadCircleShape(engine, false);

bundles/confetti/src/confetti.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type Engine,
44
type ISourceOptions,
55
type RecursivePartial,
6+
assertValidVersion,
67
isSsr,
78
isString,
89
millisecondsToSeconds,
@@ -26,6 +27,8 @@ import { loadStarShape } from "@tsparticles/shape-star";
2627
import { loadTiltUpdater } from "@tsparticles/updater-tilt";
2728
import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
2829

30+
declare const __VERSION__: string;
31+
2932
const defaultGravity = 9.81,
3033
sizeFactor = 5,
3134
speedFactor = 3,
@@ -115,6 +118,8 @@ async function initPlugins(engine: Engine): Promise<void> {
115118

116119
initializing = true;
117120

121+
assertValidVersion(engine, __VERSION__);
122+
118123
await loadEmittersPlugin(engine, false);
119124
await loadMotionPlugin(engine, false);
120125
await loadCardsShape(engine, false);
@@ -493,7 +498,7 @@ confetti.init = async (): Promise<void> => {
493498
/**
494499
*
495500
*/
496-
confetti.version = tsParticles.version;
501+
confetti.version = __VERSION__;
497502

498503
if (!isSsr()) {
499504
window.confetti = confetti;

bundles/fireworks/src/fireworks.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import {
22
type Container,
33
type CustomEventArgs,
44
DestroyType,
5+
type Engine,
56
EventType,
67
type ISourceOptions,
78
MoveDirection,
89
OutMode,
910
type Particle,
1011
type RecursivePartial,
1112
StartValueType,
13+
assertValidVersion,
1214
getRangeMax,
1315
getRangeMin,
1416
isNumber,
@@ -28,6 +30,8 @@ import { loadRotateUpdater } from "@tsparticles/updater-rotate";
2830
import { loadSoundsPlugin } from "@tsparticles/plugin-sounds";
2931
import { loadTrailEffect } from "@tsparticles/effect-trail";
3032

33+
declare const __VERSION__: string;
34+
3135
const minSplitCount = 2;
3236

3337
let initialized = false;
@@ -80,8 +84,9 @@ class FireworksInstance {
8084
}
8185

8286
/**
87+
* @param engine - the engine to use for loading all plugins
8388
*/
84-
async function initPlugins(): Promise<void> {
89+
async function initPlugins(engine: Engine): Promise<void> {
8590
if (initialized) {
8691
return;
8792
}
@@ -102,14 +107,16 @@ async function initPlugins(): Promise<void> {
102107

103108
initializing = true;
104109

105-
await loadEmittersPlugin(tsParticles, false);
106-
await loadEmittersShapeSquare(tsParticles, false);
107-
await loadSoundsPlugin(tsParticles, false);
108-
await loadRotateUpdater(tsParticles, false);
109-
await loadDestroyUpdater(tsParticles, false);
110-
await loadLifeUpdater(tsParticles, false);
111-
await loadTrailEffect(tsParticles, false);
112-
await loadBasic(tsParticles, false);
110+
assertValidVersion(engine, __VERSION__);
111+
112+
await loadEmittersPlugin(engine, false);
113+
await loadEmittersShapeSquare(engine, false);
114+
await loadSoundsPlugin(engine, false);
115+
await loadRotateUpdater(engine, false);
116+
await loadDestroyUpdater(engine, false);
117+
await loadLifeUpdater(engine, false);
118+
await loadTrailEffect(engine, false);
119+
await loadBasic(engine, false);
113120

114121
initializing = false;
115122
initialized = true;
@@ -327,7 +334,7 @@ async function getFireworksInstance(
327334
sourceOptions: RecursivePartial<IFireworkOptions>,
328335
canvas?: HTMLCanvasElement,
329336
): Promise<FireworksInstance | undefined> {
330-
await initPlugins();
337+
await initPlugins(tsParticles);
331338

332339
const options = new FireworkOptions();
333340

@@ -376,10 +383,10 @@ fireworks.create = async (
376383
};
377384

378385
fireworks.init = async (): Promise<void> => {
379-
await initPlugins();
386+
await initPlugins(tsParticles);
380387
};
381388

382-
fireworks.version = tsParticles.version;
389+
fireworks.version = __VERSION__;
383390

384391
if (!isSsr()) {
385392
window.fireworks = fireworks;

bundles/full/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Engine } from "@tsparticles/engine";
1+
import { type Engine, assertValidVersion } from "@tsparticles/engine";
22
import { loadAbsorbersPlugin } from "@tsparticles/plugin-absorbers";
33
import { loadDestroyUpdater } from "@tsparticles/updater-destroy";
44
import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
@@ -12,6 +12,8 @@ import { loadTiltUpdater } from "@tsparticles/updater-tilt";
1212
import { loadTwinkleUpdater } from "@tsparticles/updater-twinkle";
1313
import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
1414

15+
declare const __VERSION__: string;
16+
1517
/**
1618
* Loads the full bundle with all plugins needed for running the tsParticles package.
1719
* This function must be called to make tsParticles work.
@@ -22,6 +24,8 @@ import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
2224
* @param refresh -
2325
*/
2426
export async function loadFull(engine: Engine, refresh = true): Promise<void> {
27+
assertValidVersion(engine, __VERSION__);
28+
2529
await loadDestroyUpdater(engine, false);
2630
await loadRollUpdater(engine, false);
2731
await loadTiltUpdater(engine, false);

bundles/pjs/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
/**
22
* [[include:pjsMigration.md]]
33
*/
4-
import { type Container, type Engine } from "@tsparticles/engine";
4+
import { type Container, type Engine, assertValidVersion } from "@tsparticles/engine";
55
import type { IParticlesJS } from "./VincentGarreau/IParticlesJS.js";
66
import { Particles } from "./marcbruederlin/Particles.js";
77
import { initParticlesJS } from "./VincentGarreau/particles.js";
88

9+
declare const __VERSION__: string;
10+
911
declare global {
1012
interface Window {
1113
/**
@@ -54,6 +56,8 @@ const initPjs = (
5456
*/
5557
particlesJS: IParticlesJS;
5658
} => {
59+
assertValidVersion(engine, __VERSION__);
60+
5761
const { particlesJS, pJSDom } = initParticlesJS(engine);
5862

5963
window.particlesJS = particlesJS;

bundles/slim/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Engine } from "@tsparticles/engine";
1+
import { type Engine, assertValidVersion } from "@tsparticles/engine";
22
import { loadBasic } from "@tsparticles/basic";
33
import { loadEasingQuadPlugin } from "@tsparticles/plugin-easing-quad";
44
import { loadEmojiShape } from "@tsparticles/shape-emoji";
@@ -25,6 +25,8 @@ import { loadSquareShape } from "@tsparticles/shape-square";
2525
import { loadStarShape } from "@tsparticles/shape-star";
2626
import { loadStrokeColorUpdater } from "@tsparticles/updater-stroke-color";
2727

28+
declare const __VERSION__: string;
29+
2830
/**
2931
* Loads the slime bundle with all plugins needed for running the tsParticles Slim package.
3032
* This function must be called to make tsParticles Slim work.
@@ -35,6 +37,8 @@ import { loadStrokeColorUpdater } from "@tsparticles/updater-stroke-color";
3537
* @param refresh -
3638
*/
3739
export async function loadSlim(engine: Engine, refresh = true): Promise<void> {
40+
assertValidVersion(engine, __VERSION__);
41+
3842
await loadParallaxMover(engine, false);
3943

4044
await loadExternalAttractInteraction(engine, false);
@@ -52,7 +56,7 @@ export async function loadSlim(engine: Engine, refresh = true): Promise<void> {
5256
await loadParticlesCollisionsInteraction(engine, false);
5357
await loadParticlesLinksInteraction(engine, false);
5458

55-
await loadEasingQuadPlugin();
59+
await loadEasingQuadPlugin(engine, false);
5660

5761
await loadEmojiShape(engine, false);
5862
await loadImageShape(engine, false);

0 commit comments

Comments
 (0)