UNPKG

@tsparticles/engine

Version:

Easily create highly customizable particle, confetti and fireworks 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.

37 lines (36 loc) • 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorCodes = void 0; exports.addErrorMessages = addErrorMessages; exports.getErrorMessage = getErrorMessage; const ErrorMessages_js_1 = require("./ErrorMessages.js"); var ErrorCodes_js_1 = require("./ErrorCodes.js"); Object.defineProperty(exports, "ErrorCodes", { enumerable: true, get: function () { return ErrorCodes_js_1.ErrorCodes; } }); let registeredMessages; const ensureRegisteredMessages = () => { registeredMessages ??= new Map(Object.entries(ErrorMessages_js_1.messages)); return registeredMessages; }, toStringValue = (value) => String(value), format = (template, args) => { return template.replace(/\{(\d+)\}/g, (match, index) => { const arg = args[Number(index)]; return arg === undefined ? match : toStringValue(arg); }); }; function addErrorMessages(extraMessages) { if (typeof process !== "undefined" && process.env.NODE_ENV === "production") { return; } const catalog = ensureRegisteredMessages(); for (const [code, message] of Object.entries(extraMessages)) { if (message !== undefined) { catalog.set(code, message); } } } function getErrorMessage(code, ...args) { if (typeof process !== "undefined" && process.env.NODE_ENV === "production") { return `[tsParticles Error ${code}] https://particles.js.org/errors/#${code}`; } const template = ensureRegisteredMessages().get(code) ?? `Unknown error code ${code}`; return format(template, args); }