@@ -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";
2830import { loadSoundsPlugin } from "@tsparticles/plugin-sounds" ;
2931import { loadTrailEffect } from "@tsparticles/effect-trail" ;
3032
33+ declare const __VERSION__ : string ;
34+
3135const minSplitCount = 2 ;
3236
3337let 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
378385fireworks . init = async ( ) : Promise < void > => {
379- await initPlugins ( ) ;
386+ await initPlugins ( tsParticles ) ;
380387} ;
381388
382- fireworks . version = tsParticles . version ;
389+ fireworks . version = __VERSION__ ;
383390
384391if ( ! isSsr ( ) ) {
385392 window . fireworks = fireworks ;
0 commit comments