UNPKG

@tsparticles/fireworks

Version:

tsParticles fireworks bundle — easily create spectacular fireworks and fountain particle effects with built-in presets. Ready to use components available for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.

68 lines (67 loc) • 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fireworks = fireworks; const lazy_1 = require("@tsparticles/engine/lazy"); const utils_js_1 = require("./utils.js"); let initPromise = null; async function doInitPlugins(engine) { engine.checkVersion("4.6.0"); await engine.pluginManager.register(async (e) => { const [{ loadBasic }, { loadLineShape }, { loadBlendPlugin }, { loadEmittersPluginSimple }, { loadEmittersShapeSquare }, { loadSoundsPlugin }, { loadRotateUpdater }, { loadDestroyUpdater }, { loadLifeUpdater }, { loadPaintUpdater },] = await Promise.all([ import("@tsparticles/basic/lazy"), import("@tsparticles/shape-line"), import("@tsparticles/plugin-blend"), import("@tsparticles/plugin-emitters/plugin"), import("@tsparticles/plugin-emitters-shape-square"), import("@tsparticles/plugin-sounds"), import("@tsparticles/updater-rotate/lazy"), import("@tsparticles/updater-destroy/lazy"), import("@tsparticles/updater-life/lazy"), import("@tsparticles/updater-paint/lazy"), ]), loadEmittersForFireworks = async (e) => { await loadEmittersPluginSimple(e); await loadEmittersShapeSquare(e); }; await Promise.all([ loadBasic(e), loadLineShape(e), loadBlendPlugin(e), loadEmittersForFireworks(e), loadSoundsPlugin(e), loadRotateUpdater(e), loadDestroyUpdater(e), loadLifeUpdater(e), loadPaintUpdater(e), ]); }); } async function initPlugins(engine) { if (initPromise) { return initPromise; } initPromise = doInitPlugins(engine); return initPromise; } async function fireworks(idOrOptions, sourceOptions) { await initPlugins(lazy_1.tsParticles); let id, options; if ((0, lazy_1.isString)(idOrOptions)) { id = idOrOptions; options = sourceOptions ?? {}; } else { id = "fireworks"; options = idOrOptions ?? {}; } return (0, utils_js_1.getFireworksInstance)(lazy_1.tsParticles, id, options); } fireworks.create = async (canvas, options) => { await initPlugins(lazy_1.tsParticles); const id = canvas?.id ?? "fireworks"; return (0, utils_js_1.getFireworksInstance)(lazy_1.tsParticles, id, options ?? {}, canvas ?? undefined); }; fireworks.init = async () => { await initPlugins(lazy_1.tsParticles); }; fireworks.version = "4.6.0"; globalThis.fireworks = fireworks;