@tsparticles/confetti 4.0.0-beta.9 → 4.0.1

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.
Files changed (166) hide show
  1. package/README.md +106 -107
  2. package/browser/ConfettiParams.js +1 -0
  3. package/browser/browser.js +5 -0
  4. package/browser/bundle.js +4 -0
  5. package/browser/confetti.js +37 -302
  6. package/browser/confetti.lazy.js +96 -0
  7. package/browser/index.lazy.js +1 -0
  8. package/browser/types.js +1 -0
  9. package/browser/utils.js +279 -0
  10. package/cjs/ConfettiParams.js +1 -0
  11. package/cjs/browser.js +5 -0
  12. package/cjs/bundle.js +4 -0
  13. package/cjs/confetti.js +37 -302
  14. package/cjs/confetti.lazy.js +96 -0
  15. package/cjs/index.lazy.js +1 -0
  16. package/cjs/types.js +1 -0
  17. package/cjs/utils.js +279 -0
  18. package/esm/ConfettiParams.js +1 -0
  19. package/esm/browser.js +5 -0
  20. package/esm/bundle.js +4 -0
  21. package/esm/confetti.js +37 -302
  22. package/esm/confetti.lazy.js +96 -0
  23. package/esm/index.lazy.js +1 -0
  24. package/esm/types.js +1 -0
  25. package/esm/utils.js +279 -0
  26. package/package.json +24 -17
  27. package/report.html +4949 -94
  28. package/tsparticles.confetti.bundle.js +9847 -977
  29. package/tsparticles.confetti.bundle.min.js +1 -2
  30. package/tsparticles.confetti.js +512 -322
  31. package/tsparticles.confetti.min.js +1 -1
  32. package/types/ConfettiParams.d.ts +7 -0
  33. package/types/browser.d.ts +1 -0
  34. package/types/confetti.d.ts +3 -10
  35. package/types/confetti.lazy.d.ts +16 -0
  36. package/types/index.d.ts +1 -0
  37. package/types/index.lazy.d.ts +5 -0
  38. package/types/types.d.ts +4 -0
  39. package/types/utils.d.ts +7 -0
  40. package/1080.min.js +0 -1
  41. package/1241.min.js +0 -1
  42. package/1336.min.js +0 -1
  43. package/1581.min.js +0 -1
  44. package/1583.min.js +0 -1
  45. package/1712.min.js +0 -1
  46. package/1723.min.js +0 -1
  47. package/189.min.js +0 -1
  48. package/2066.min.js +0 -1
  49. package/2127.min.js +0 -1
  50. package/2182.min.js +0 -1
  51. package/2270.min.js +0 -1
  52. package/2528.min.js +0 -1
  53. package/2602.min.js +0 -1
  54. package/2760.min.js +0 -1
  55. package/3047.min.js +0 -1
  56. package/3073.min.js +0 -1
  57. package/3443.min.js +0 -1
  58. package/3583.min.js +0 -1
  59. package/374.min.js +0 -1
  60. package/382.min.js +0 -1
  61. package/404.min.js +0 -1
  62. package/4067.min.js +0 -1
  63. package/4068.min.js +0 -1
  64. package/4077.min.js +0 -1
  65. package/4086.min.js +0 -1
  66. package/4186.min.js +0 -1
  67. package/4217.min.js +0 -1
  68. package/4427.min.js +0 -1
  69. package/4519.min.js +0 -1
  70. package/4626.min.js +0 -1
  71. package/4657.min.js +0 -1
  72. package/5048.min.js +0 -1
  73. package/5294.min.js +0 -1
  74. package/5344.min.js +0 -1
  75. package/5601.min.js +0 -1
  76. package/6055.min.js +0 -1
  77. package/6171.min.js +0 -1
  78. package/6192.min.js +0 -1
  79. package/6265.min.js +0 -1
  80. package/6466.min.js +0 -1
  81. package/648.min.js +0 -1
  82. package/6943.min.js +0 -1
  83. package/6957.min.js +0 -1
  84. package/6972.min.js +0 -1
  85. package/6996.min.js +0 -1
  86. package/7162.min.js +0 -1
  87. package/7175.min.js +0 -1
  88. package/7213.min.js +0 -1
  89. package/7259.min.js +0 -1
  90. package/7316.min.js +0 -1
  91. package/7711.min.js +0 -1
  92. package/7757.min.js +0 -1
  93. package/7775.min.js +0 -1
  94. package/8204.min.js +0 -1
  95. package/8630.min.js +0 -1
  96. package/8731.min.js +0 -1
  97. package/8855.min.js +0 -1
  98. package/9674.min.js +0 -1
  99. package/9726.min.js +0 -1
  100. package/980.min.js +0 -1
  101. package/9835.min.js +0 -1
  102. package/9907.min.js +0 -1
  103. package/basic_dist_browser_index_js.js +0 -30
  104. package/engine_dist_browser_Core_Container_js.js +0 -100
  105. package/plugins_colors_hex_dist_browser_HexColorManager_js.js +0 -30
  106. package/plugins_colors_hex_dist_browser_index_js.js +0 -30
  107. package/plugins_colors_hsl_dist_browser_HslColorManager_js.js +0 -30
  108. package/plugins_colors_hsl_dist_browser_index_js.js +0 -30
  109. package/plugins_colors_rgb_dist_browser_RgbColorManager_js.js +0 -30
  110. package/plugins_colors_rgb_dist_browser_index_js.js +0 -30
  111. package/plugins_emitters_dist_browser_EmitterInstance_js.js +0 -30
  112. package/plugins_emitters_dist_browser_EmittersInstancesManager_js.js +0 -100
  113. package/plugins_emitters_dist_browser_EmittersPluginInstance_js.js +0 -30
  114. package/plugins_emitters_dist_browser_EmittersPlugin_js.js +0 -100
  115. package/plugins_emitters_dist_browser_ShapeManager_js.js +0 -30
  116. package/plugins_emitters_dist_browser_addEmittersShapesManager_js.js +0 -30
  117. package/plugins_emitters_dist_browser_getEmittersInstancesManager_js.js +0 -30
  118. package/plugins_emitters_dist_browser_plugin_js.js +0 -50
  119. package/plugins_motion_dist_browser_MotionPluginInstance_js.js +0 -30
  120. package/plugins_motion_dist_browser_MotionPlugin_js.js +0 -50
  121. package/plugins_motion_dist_browser_index_js.js +0 -30
  122. package/plugins_move_dist_browser_MovePluginInstance_js.js +0 -40
  123. package/plugins_move_dist_browser_MovePlugin_js.js +0 -30
  124. package/plugins_move_dist_browser_index_js.js +0 -30
  125. package/shapes_cards_dist_browser_clubs_ClubDrawer_js.js +0 -30
  126. package/shapes_cards_dist_browser_diamonds_DiamondDrawer_js.js +0 -30
  127. package/shapes_cards_dist_browser_hearts_HeartDrawer_js.js +0 -30
  128. package/shapes_cards_dist_browser_paths_js.js +0 -70
  129. package/shapes_cards_dist_browser_spades_SpadeDrawer_js.js +0 -30
  130. package/shapes_cards_dist_browser_suits_js.js +0 -70
  131. package/shapes_circle_dist_browser_CircleDrawer_js.js +0 -40
  132. package/shapes_circle_dist_browser_index_js.js +0 -30
  133. package/shapes_emoji_dist_browser_EmojiDrawer_js.js +0 -50
  134. package/shapes_emoji_dist_browser_index_js.js +0 -40
  135. package/shapes_heart_dist_browser_HeartDrawer_js.js +0 -40
  136. package/shapes_heart_dist_browser_index_js.js +0 -30
  137. package/shapes_image_dist_browser_GifUtils_Utils_js.js +0 -70
  138. package/shapes_image_dist_browser_ImageDrawer_js.js +0 -30
  139. package/shapes_image_dist_browser_ImagePreloaderInstance_js.js +0 -30
  140. package/shapes_image_dist_browser_ImagePreloader_js.js +0 -40
  141. package/shapes_image_dist_browser_index_js.js +0 -40
  142. package/shapes_polygon_dist_browser_PolygonDrawer_js.js +0 -50
  143. package/shapes_polygon_dist_browser_TriangleDrawer_js.js +0 -50
  144. package/shapes_polygon_dist_browser_index_js.js +0 -30
  145. package/shapes_square_dist_browser_SquareDrawer_js.js +0 -40
  146. package/shapes_square_dist_browser_index_js.js +0 -30
  147. package/shapes_star_dist_browser_StarDrawer_js.js +0 -40
  148. package/shapes_star_dist_browser_index_js.js +0 -30
  149. package/updaters_fillColor_dist_browser_FillColorUpdater_js.js +0 -30
  150. package/updaters_fillColor_dist_browser_index_js.js +0 -30
  151. package/updaters_life_dist_browser_LifeUpdater_js.js +0 -70
  152. package/updaters_life_dist_browser_index_js.js +0 -30
  153. package/updaters_opacity_dist_browser_OpacityUpdater_js.js +0 -30
  154. package/updaters_opacity_dist_browser_index_js.js +0 -30
  155. package/updaters_outModes_dist_browser_OutOfCanvasUpdater_js.js +0 -80
  156. package/updaters_outModes_dist_browser_index_js.js +0 -30
  157. package/updaters_roll_dist_browser_RollUpdater_js.js +0 -70
  158. package/updaters_roll_dist_browser_index_js.js +0 -30
  159. package/updaters_rotate_dist_browser_RotateUpdater_js.js +0 -50
  160. package/updaters_rotate_dist_browser_index_js.js +0 -30
  161. package/updaters_size_dist_browser_SizeUpdater_js.js +0 -30
  162. package/updaters_size_dist_browser_index_js.js +0 -30
  163. package/updaters_tilt_dist_browser_TiltUpdater_js.js +0 -60
  164. package/updaters_tilt_dist_browser_index_js.js +0 -30
  165. package/updaters_wobble_dist_browser_WobbleUpdater_js.js +0 -60
  166. package/updaters_wobble_dist_browser_index_js.js +0 -30
package/cjs/confetti.js CHANGED
@@ -1,42 +1,24 @@
1
- import { isString, millisecondsToSeconds, tsParticles, } from "@tsparticles/engine";
2
- import { ConfettiOptions } from "./ConfettiOptions.js";
3
- let initialized = false, initializing = false;
4
- const ids = new Map(), defaultGravity = 9.81, sizeFactor = 5, speedFactor = 3, decayOffset = 1, disableRotate = 0, disableTilt = 0;
5
- async function initPlugins(engine) {
6
- if (initialized) {
7
- return;
8
- }
9
- if (initializing) {
10
- return new Promise(resolve => {
11
- const timeout = 100, interval = setInterval(() => {
12
- if (!initialized) {
13
- return;
14
- }
15
- clearInterval(interval);
16
- resolve();
17
- }, timeout);
18
- });
19
- }
20
- initializing = true;
21
- engine.checkVersion("4.0.0-beta.9");
1
+ import { isString, tsParticles } from "@tsparticles/engine";
2
+ import { loadBasic } from "@tsparticles/basic";
3
+ import { loadCardSuitsShape } from "@tsparticles/shape-cards/suits";
4
+ import { loadEmittersPluginSimple } from "@tsparticles/plugin-emitters/plugin";
5
+ import { loadEmojiShape } from "@tsparticles/shape-emoji";
6
+ import { loadHeartShape } from "@tsparticles/shape-heart";
7
+ import { loadImageShape } from "@tsparticles/shape-image";
8
+ import { loadLifeUpdater } from "@tsparticles/updater-life";
9
+ import { loadMotionPlugin } from "@tsparticles/plugin-motion";
10
+ import { loadPolygonShape } from "@tsparticles/shape-polygon";
11
+ import { loadRollUpdater } from "@tsparticles/updater-roll";
12
+ import { loadRotateUpdater } from "@tsparticles/updater-rotate";
13
+ import { loadSquareShape } from "@tsparticles/shape-square";
14
+ import { loadStarShape } from "@tsparticles/shape-star";
15
+ import { loadTiltUpdater } from "@tsparticles/updater-tilt";
16
+ import { loadWobbleUpdater } from "@tsparticles/updater-wobble";
17
+ import { setConfetti } from "./utils.js";
18
+ let initPromise = null;
19
+ async function doInitPlugins(engine) {
20
+ engine.checkVersion("4.0.1");
22
21
  await engine.pluginManager.register(async (e) => {
23
- const [{ loadBasic }, { loadEmittersPluginSimple }, { loadMotionPlugin }, { loadCardSuitsShape }, { loadHeartShape }, { loadImageShape }, { loadPolygonShape }, { loadSquareShape }, { loadStarShape }, { loadEmojiShape }, { loadRotateUpdater }, { loadLifeUpdater }, { loadRollUpdater }, { loadTiltUpdater }, { loadWobbleUpdater },] = await Promise.all([
24
- import("@tsparticles/basic"),
25
- import("@tsparticles/plugin-emitters/plugin"),
26
- import("@tsparticles/plugin-motion"),
27
- import("@tsparticles/shape-cards/suits"),
28
- import("@tsparticles/shape-heart"),
29
- import("@tsparticles/shape-image"),
30
- import("@tsparticles/shape-polygon"),
31
- import("@tsparticles/shape-square"),
32
- import("@tsparticles/shape-star"),
33
- import("@tsparticles/shape-emoji"),
34
- import("@tsparticles/updater-rotate"),
35
- import("@tsparticles/updater-life"),
36
- import("@tsparticles/updater-roll"),
37
- import("@tsparticles/updater-tilt"),
38
- import("@tsparticles/updater-wobble"),
39
- ]);
40
22
  await Promise.all([
41
23
  loadBasic(e),
42
24
  loadMotionPlugin(e),
@@ -55,265 +37,13 @@ async function initPlugins(engine) {
55
37
  loadWobbleUpdater(e),
56
38
  ]);
57
39
  });
58
- initializing = false;
59
- initialized = true;
60
40
  }
61
- async function setConfetti(params) {
62
- const actualOptions = new ConfettiOptions();
63
- actualOptions.load(params.options);
64
- let container;
65
- const fpsLimit = 120, fpsLimitFactor = 3.6, opacitySpeed = (actualOptions.ticks * millisecondsToSeconds) / (fpsLimitFactor * millisecondsToSeconds * fpsLimit);
66
- if (ids.has(params.id)) {
67
- container = ids.get(params.id);
68
- if (container && !container.destroyed) {
69
- const alias = container;
70
- if ("addEmitter" in alias) {
71
- await alias.addEmitter?.({
72
- startCount: actualOptions.count,
73
- position: actualOptions.position,
74
- size: {
75
- width: 0,
76
- height: 0,
77
- },
78
- rate: {
79
- delay: 0,
80
- quantity: 0,
81
- },
82
- life: {
83
- duration: 0.1,
84
- count: 1,
85
- },
86
- particles: {
87
- fill: {
88
- color: {
89
- value: actualOptions.colors,
90
- },
91
- enable: true,
92
- },
93
- shape: {
94
- type: actualOptions.shapes,
95
- options: actualOptions.shapeOptions,
96
- },
97
- life: {
98
- count: 1,
99
- },
100
- opacity: {
101
- value: { min: 0, max: 1 },
102
- animation: {
103
- enable: true,
104
- sync: true,
105
- speed: opacitySpeed,
106
- startValue: "max",
107
- destroy: "min",
108
- count: 1,
109
- },
110
- },
111
- size: {
112
- value: sizeFactor * actualOptions.scalar,
113
- },
114
- move: {
115
- angle: {
116
- value: actualOptions.spread,
117
- offset: 0,
118
- },
119
- drift: {
120
- min: -actualOptions.drift,
121
- max: actualOptions.drift,
122
- },
123
- gravity: {
124
- acceleration: actualOptions.gravity * defaultGravity,
125
- },
126
- speed: actualOptions.startVelocity * speedFactor,
127
- decay: decayOffset - actualOptions.decay,
128
- direction: -actualOptions.angle,
129
- },
130
- rotate: {
131
- value: actualOptions.flat
132
- ? disableRotate
133
- : {
134
- min: 0,
135
- max: 360,
136
- },
137
- direction: "random",
138
- animation: {
139
- enable: !actualOptions.flat,
140
- speed: 60,
141
- },
142
- },
143
- tilt: {
144
- direction: "random",
145
- enable: !actualOptions.flat,
146
- value: actualOptions.flat
147
- ? disableTilt
148
- : {
149
- min: 0,
150
- max: 360,
151
- },
152
- animation: {
153
- enable: true,
154
- speed: 60,
155
- },
156
- },
157
- roll: {
158
- darken: {
159
- enable: true,
160
- value: 25,
161
- },
162
- enable: !actualOptions.flat,
163
- speed: {
164
- min: 15,
165
- max: 25,
166
- },
167
- },
168
- wobble: {
169
- distance: 30,
170
- enable: !actualOptions.flat,
171
- speed: {
172
- min: -15,
173
- max: 15,
174
- },
175
- },
176
- },
177
- });
178
- return;
179
- }
180
- }
41
+ async function initPlugins(engine) {
42
+ if (initPromise) {
43
+ return initPromise;
181
44
  }
182
- const particlesOptions = {
183
- fullScreen: {
184
- enable: !params.canvas,
185
- zIndex: actualOptions.zIndex,
186
- },
187
- fpsLimit: 120,
188
- particles: {
189
- number: {
190
- value: 0,
191
- },
192
- fill: {
193
- color: {
194
- value: actualOptions.colors,
195
- },
196
- enable: true,
197
- },
198
- shape: {
199
- type: actualOptions.shapes,
200
- options: actualOptions.shapeOptions,
201
- },
202
- opacity: {
203
- value: { min: 0, max: 1 },
204
- animation: {
205
- enable: true,
206
- sync: true,
207
- speed: opacitySpeed,
208
- startValue: "max",
209
- destroy: "min",
210
- count: 1,
211
- },
212
- },
213
- size: {
214
- value: sizeFactor * actualOptions.scalar,
215
- },
216
- links: {
217
- enable: false,
218
- },
219
- life: {
220
- count: 1,
221
- },
222
- move: {
223
- angle: {
224
- value: actualOptions.spread,
225
- offset: 0,
226
- },
227
- drift: {
228
- min: -actualOptions.drift,
229
- max: actualOptions.drift,
230
- },
231
- enable: true,
232
- gravity: {
233
- enable: true,
234
- acceleration: actualOptions.gravity * defaultGravity,
235
- },
236
- speed: actualOptions.startVelocity * speedFactor,
237
- decay: decayOffset - actualOptions.decay,
238
- direction: -actualOptions.angle,
239
- random: true,
240
- straight: false,
241
- outModes: {
242
- default: "none",
243
- bottom: "destroy",
244
- },
245
- },
246
- rotate: {
247
- value: actualOptions.flat
248
- ? disableRotate
249
- : {
250
- min: 0,
251
- max: 360,
252
- },
253
- direction: "random",
254
- animation: {
255
- enable: !actualOptions.flat,
256
- speed: 60,
257
- },
258
- },
259
- tilt: {
260
- direction: "random",
261
- enable: !actualOptions.flat,
262
- value: actualOptions.flat
263
- ? disableTilt
264
- : {
265
- min: 0,
266
- max: 360,
267
- },
268
- animation: {
269
- enable: true,
270
- speed: 60,
271
- },
272
- },
273
- roll: {
274
- darken: {
275
- enable: true,
276
- value: 25,
277
- },
278
- enable: !actualOptions.flat,
279
- speed: {
280
- min: 15,
281
- max: 25,
282
- },
283
- },
284
- wobble: {
285
- distance: 30,
286
- enable: !actualOptions.flat,
287
- speed: {
288
- min: -15,
289
- max: 15,
290
- },
291
- },
292
- },
293
- motion: {
294
- disable: actualOptions.disableForReducedMotion,
295
- },
296
- emitters: {
297
- name: "confetti",
298
- startCount: actualOptions.count,
299
- position: actualOptions.position,
300
- size: {
301
- width: 0,
302
- height: 0,
303
- },
304
- rate: {
305
- delay: 0,
306
- quantity: 0,
307
- },
308
- life: {
309
- duration: 0.1,
310
- count: 1,
311
- },
312
- },
313
- };
314
- container = await tsParticles.load({ id: params.id, element: params.canvas, options: particlesOptions });
315
- ids.set(params.id, container);
316
- return container;
45
+ initPromise = doInitPlugins(engine);
46
+ return initPromise;
317
47
  }
318
48
  export async function confetti(idOrOptions, confettiOptions) {
319
49
  await initPlugins(tsParticles);
@@ -326,15 +56,20 @@ export async function confetti(idOrOptions, confettiOptions) {
326
56
  id = "confetti";
327
57
  options = idOrOptions;
328
58
  }
329
- return setConfetti({
59
+ return setConfetti(tsParticles, {
330
60
  id,
331
61
  options,
332
62
  });
333
63
  }
334
- confetti.create = async (canvas, options) => {
64
+ confetti.create = async (canvas, options = {}) => {
335
65
  await initPlugins(tsParticles);
336
- const id = canvas.getAttribute("id") ?? "confetti";
337
- canvas.setAttribute("id", id);
66
+ const id = canvas?.getAttribute("id") ?? "confetti";
67
+ canvas?.setAttribute("id", id);
68
+ await setConfetti(tsParticles, {
69
+ id,
70
+ canvas: canvas ?? undefined,
71
+ options,
72
+ });
338
73
  return async (idOrOptions, confettiOptions) => {
339
74
  let subOptions, subId;
340
75
  if (isString(idOrOptions)) {
@@ -345,9 +80,9 @@ confetti.create = async (canvas, options) => {
345
80
  subId = id;
346
81
  subOptions = idOrOptions;
347
82
  }
348
- return setConfetti({
83
+ return setConfetti(tsParticles, {
349
84
  id: subId,
350
- canvas,
85
+ canvas: canvas ?? undefined,
351
86
  options: subOptions,
352
87
  });
353
88
  };
@@ -355,5 +90,5 @@ confetti.create = async (canvas, options) => {
355
90
  confetti.init = async () => {
356
91
  await initPlugins(tsParticles);
357
92
  };
358
- confetti.version = "4.0.0-beta.9";
93
+ confetti.version = "4.0.1";
359
94
  globalThis.confetti = confetti;
@@ -0,0 +1,96 @@
1
+ import { isString, tsParticles } from "@tsparticles/engine/lazy";
2
+ import { setConfetti } from "./utils.js";
3
+ let initPromise = null;
4
+ async function doInitPlugins(engine) {
5
+ engine.checkVersion("4.0.1");
6
+ await engine.pluginManager.register(async (e) => {
7
+ const [{ loadBasic }, { loadEmittersPluginSimple }, { loadMotionPlugin }, { loadCardSuitsShape }, { loadEmojiShape }, { loadHeartShape }, { loadImageShape }, { loadPolygonShape }, { loadSquareShape }, { loadStarShape }, { loadRotateUpdater }, { loadLifeUpdater }, { loadRollUpdater }, { loadTiltUpdater }, { loadWobbleUpdater },] = await Promise.all([
8
+ import("@tsparticles/basic/lazy"),
9
+ import("@tsparticles/plugin-emitters/plugin/lazy"),
10
+ import("@tsparticles/plugin-motion/lazy"),
11
+ import("@tsparticles/shape-cards/suits/lazy"),
12
+ import("@tsparticles/shape-emoji/lazy"),
13
+ import("@tsparticles/shape-heart/lazy"),
14
+ import("@tsparticles/shape-image/lazy"),
15
+ import("@tsparticles/shape-polygon/lazy"),
16
+ import("@tsparticles/shape-square/lazy"),
17
+ import("@tsparticles/shape-star/lazy"),
18
+ import("@tsparticles/updater-rotate/lazy"),
19
+ import("@tsparticles/updater-life/lazy"),
20
+ import("@tsparticles/updater-roll/lazy"),
21
+ import("@tsparticles/updater-tilt/lazy"),
22
+ import("@tsparticles/updater-wobble/lazy"),
23
+ ]);
24
+ await Promise.all([
25
+ loadBasic(e),
26
+ loadMotionPlugin(e),
27
+ loadEmittersPluginSimple(e),
28
+ loadCardSuitsShape(e),
29
+ loadHeartShape(e),
30
+ loadImageShape(e),
31
+ loadPolygonShape(e),
32
+ loadSquareShape(e),
33
+ loadStarShape(e),
34
+ loadEmojiShape(e),
35
+ loadRotateUpdater(e),
36
+ loadLifeUpdater(e),
37
+ loadRollUpdater(e),
38
+ loadTiltUpdater(e),
39
+ loadWobbleUpdater(e),
40
+ ]);
41
+ });
42
+ }
43
+ async function initPlugins(engine) {
44
+ if (initPromise) {
45
+ return initPromise;
46
+ }
47
+ initPromise = doInitPlugins(engine);
48
+ return initPromise;
49
+ }
50
+ export async function confetti(idOrOptions, confettiOptions) {
51
+ await initPlugins(tsParticles);
52
+ let options, id;
53
+ if (isString(idOrOptions)) {
54
+ id = idOrOptions;
55
+ options = confettiOptions ?? {};
56
+ }
57
+ else {
58
+ id = "confetti";
59
+ options = idOrOptions;
60
+ }
61
+ return setConfetti(tsParticles, {
62
+ id,
63
+ options,
64
+ });
65
+ }
66
+ confetti.create = async (canvas, options = {}) => {
67
+ await initPlugins(tsParticles);
68
+ const id = canvas?.getAttribute("id") ?? "confetti";
69
+ canvas?.setAttribute("id", id);
70
+ await setConfetti(tsParticles, {
71
+ id,
72
+ canvas: canvas ?? undefined,
73
+ options,
74
+ });
75
+ return async (idOrOptions, confettiOptions) => {
76
+ let subOptions, subId;
77
+ if (isString(idOrOptions)) {
78
+ subId = idOrOptions;
79
+ subOptions = confettiOptions ?? options;
80
+ }
81
+ else {
82
+ subId = id;
83
+ subOptions = idOrOptions;
84
+ }
85
+ return setConfetti(tsParticles, {
86
+ id: subId,
87
+ canvas: canvas ?? undefined,
88
+ options: subOptions,
89
+ });
90
+ };
91
+ };
92
+ confetti.init = async () => {
93
+ await initPlugins(tsParticles);
94
+ };
95
+ confetti.version = "4.0.1";
96
+ globalThis.confetti = confetti;
@@ -0,0 +1 @@
1
+ export * from "./confetti.lazy.js";
package/cjs/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};