@tsparticles/engine 4.0.0-alpha.0 → 4.0.0-alpha.2

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.
@@ -1,243 +1,267 @@
1
- const path = require("path"),
2
- particlesJsFoundError = "particles.js-found",
3
- reactParticlesJsFoundError = "react-particles-js-found",
4
- reactParticlesFoundError = "react-particles-found",
5
- reactTsParticlesFoundError = "react-tsparticles-found",
6
- angularParticlesFoundError = "ng-particles-found",
7
- vue2ParticlesFoundError = "vue2-particles-found",
8
- vue3ParticlesFoundError = "vue3-particles-found";
9
-
10
- try {
11
- console.log("Thank you for installing tsParticles.");
12
- console.log("Remember to checkout the official website https://particles.js.org to explore some samples.");
13
- console.log("You can find more samples on CodePen too: https://codepen.io/collection/DPOage");
14
- console.log("If you need documentation you can find it here: https://particles.js.org/docs");
15
- console.log(
16
- "Don't forget to star the tsParticles repository, if you like the project and want to support it: https://github.com/tsparticles/tsparticles"
17
- );
18
-
19
- const pkgSettings = require(path.join(process.env.INIT_CWD, "package.json"));
20
-
21
- if (!pkgSettings) {
22
- return;
23
- }
24
-
25
- const dependencies = pkgSettings.dependencies;
1
+ import path from "path";
2
+ import { fileURLToPath } from "url";
3
+ import fs from "fs-extra";
26
4
 
27
- if (!dependencies) {
28
- return;
29
- }
5
+ async function checkErrors() {
6
+ const angularParticlesFoundError = "ng-particles-found",
7
+ particlesJsFoundError = "particles.js-found",
8
+ reactParticlesJsFoundError = "react-particles-js-found",
9
+ reactParticlesFoundError = "react-particles-found",
10
+ reactTsParticlesFoundError = "react-tsparticles-found",
11
+ svelteParticlesFoundError = "svelte-particles-found",
12
+ vue2ParticlesFoundError = "vue2-particles-found",
13
+ vue3ParticlesFoundError = "vue3-particles-found";
30
14
 
31
- if (dependencies["particles.js"]) {
32
- console.error(
33
- "\x1b[31m%s\x1b[0m",
34
- "The package particles.js can't be installed with tsparticles, since it can lead to unexpected behaviors, please uninstall particles.js and remove it from the package.json file."
15
+ try {
16
+ console.log("Thank you for installing tsParticles.");
17
+ console.log("Remember to checkout the official website https://particles.js.org to explore some samples.");
18
+ console.log("You can find more samples on CodePen too: https://codepen.io/collection/DPOage");
19
+ console.log("If you need documentation you can find it here: https://particles.js.org/docs");
20
+ console.log(
21
+ "Don't forget to star the tsParticles repository, if you like the project and want to support it: https://github.com/tsparticles/tsparticles"
35
22
  );
36
23
 
37
- throw new Error(reactParticlesJsFoundError);
38
- }
24
+ const rootPkgPath = path.join(process.env.INIT_CWD, "package.json"),
25
+ pkgSettings = await fs.readJson(rootPkgPath);
39
26
 
40
- if (dependencies["particlesjs"]) {
41
- console.error(
42
- "\x1b[31m%s\x1b[0m",
43
- "The package particlesjs can't be installed with tsparticles, since it can lead to unexpected behaviors, please uninstall particlesjs and remove it from the package.json file."
44
- );
27
+ if (!pkgSettings) {
28
+ return;
29
+ }
45
30
 
46
- throw new Error(reactParticlesJsFoundError);
47
- }
31
+ const dependencies = pkgSettings.dependencies;
48
32
 
49
- if (dependencies["react-particles-js"]) {
50
- console.error(
51
- "\x1b[31m%s\x1b[0m",
52
- "The package react-particles-js has been deprecated and is not supported anymore."
53
- );
54
- console.error("\x1b[31m%s\x1b[0m", "Please consider switching to react-particles package.");
55
- console.error(
56
- "\x1b[31m%s\x1b[0m",
57
- "This error will be fixed once react-particles-js is removed from the package.json file."
58
- );
33
+ if (!dependencies) {
34
+ return;
35
+ }
59
36
 
60
- throw new Error(reactParticlesJsFoundError);
61
- }
37
+ if (dependencies["particles.js"]) {
38
+ console.error(
39
+ "\x1b[31m%s\x1b[0m",
40
+ "The package particles.js can't be installed with tsparticles, since it can lead to unexpected behaviors, please uninstall particles.js and remove it from the package.json file."
41
+ );
62
42
 
63
- if (dependencies["react-tsparticles"]) {
64
- console.error(
65
- "\x1b[31m%s\x1b[0m",
66
- "The package react-tsparticles has been deprecated and is not supported anymore."
67
- );
68
- console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/react package.");
69
- console.error(
70
- "\x1b[31m%s\x1b[0m",
71
- "This error will be fixed once react-tsparticles is removed from the package.json file."
72
- );
43
+ throw new Error(reactParticlesJsFoundError);
44
+ }
73
45
 
74
- throw new Error(reactTsParticlesFoundError);
75
- }
46
+ if (dependencies["particlesjs"]) {
47
+ console.error(
48
+ "\x1b[31m%s\x1b[0m",
49
+ "The package particlesjs can't be installed with tsparticles, since it can lead to unexpected behaviors, please uninstall particlesjs and remove it from the package.json file."
50
+ );
76
51
 
77
- if (dependencies["react-particles"]) {
78
- console.error(
79
- "\x1b[31m%s\x1b[0m",
80
- "The package react-particles has been deprecated and is not supported anymore."
81
- );
82
- console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/react package.");
83
- console.error(
84
- "\x1b[31m%s\x1b[0m",
85
- "This error will be fixed once react-particles is removed from the package.json file."
86
- );
52
+ throw new Error(reactParticlesJsFoundError);
53
+ }
87
54
 
88
- throw new Error(reactParticlesFoundError);
89
- }
55
+ if (dependencies["react-particles-js"]) {
56
+ console.error(
57
+ "\x1b[31m%s\x1b[0m",
58
+ "The package react-particles-js has been deprecated and is not supported anymore."
59
+ );
60
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to react-particles package.");
61
+ console.error(
62
+ "\x1b[31m%s\x1b[0m",
63
+ "This error will be fixed once react-particles-js is removed from the package.json file."
64
+ );
90
65
 
91
- if (dependencies["react"] || dependencies["next"]) {
92
- if (!dependencies["@tsparticles/react"]) {
93
- console.warn(
94
- "\x1b[43m\x1b[30m%s\x1b[0m",
95
- "Found React installed. Please download react-particles to use tsParticles with a component ready to use and easier to configure."
66
+ throw new Error(reactParticlesJsFoundError);
67
+ }
68
+
69
+ if (dependencies["react-tsparticles"]) {
70
+ console.error(
71
+ "\x1b[31m%s\x1b[0m",
72
+ "The package react-tsparticles has been deprecated and is not supported anymore."
96
73
  );
97
- console.log(
98
- "You can read more about the component here: https://github.com/tsparticles/react/#readme"
74
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/react package.");
75
+ console.error(
76
+ "\x1b[31m%s\x1b[0m",
77
+ "This error will be fixed once react-tsparticles is removed from the package.json file."
99
78
  );
79
+
80
+ throw new Error(reactTsParticlesFoundError);
100
81
  }
101
- }
102
82
 
103
- if (dependencies["ng-particles"]) {
104
- console.error(
105
- "\x1b[31m%s\x1b[0m",
106
- "The package ng-particles has been deprecated and is not supported anymore."
107
- );
108
- console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/angular package.");
109
- console.error(
110
- "\x1b[31m%s\x1b[0m",
111
- "This error will be fixed once ng-particles is removed from the package.json file."
112
- );
83
+ if (dependencies["react-particles"]) {
84
+ console.error(
85
+ "\x1b[31m%s\x1b[0m",
86
+ "The package react-particles has been deprecated and is not supported anymore."
87
+ );
88
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/react package.");
89
+ console.error(
90
+ "\x1b[31m%s\x1b[0m",
91
+ "This error will be fixed once react-particles is removed from the package.json file."
92
+ );
113
93
 
114
- throw new Error(angularParticlesFoundError);
115
- }
94
+ throw new Error(reactParticlesFoundError);
95
+ }
116
96
 
117
- if (dependencies["@angular/core"]) {
118
- if (!dependencies["@tsparticles/angular"]) {
119
- console.warn(
120
- "\x1b[43m\x1b[30m%s\x1b[0m",
121
- "Found Angular installed. Please download ng-particles to use tsParticles with a component ready to use and easier to configure."
97
+ if (dependencies["react"] || dependencies["next"]) {
98
+ if (!dependencies["@tsparticles/react"]) {
99
+ console.warn(
100
+ "\x1b[43m\x1b[30m%s\x1b[0m",
101
+ "Found React installed. Please download react-particles to use tsParticles with a component ready to use and easier to configure."
102
+ );
103
+ console.log(
104
+ "You can read more about the component here: https://github.com/tsparticles/react/#readme"
105
+ );
106
+ }
107
+ }
108
+
109
+ if (dependencies["ng-particles"]) {
110
+ console.error(
111
+ "\x1b[31m%s\x1b[0m",
112
+ "The package ng-particles has been deprecated and is not supported anymore."
113
+ );
114
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/angular package.");
115
+ console.error(
116
+ "\x1b[31m%s\x1b[0m",
117
+ "This error will be fixed once ng-particles is removed from the package.json file."
122
118
  );
123
- console.log("You can read more about the component here: https://github.com/tsparticles/angular/#readme");
119
+
120
+ throw new Error(angularParticlesFoundError);
124
121
  }
125
- }
126
122
 
127
- if (dependencies["vue3-particles"]) {
128
- console.error(
129
- "\x1b[31m%s\x1b[0m",
130
- "The package vue3-particles has been deprecated and is not supported anymore."
131
- );
132
- console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/vue3 package.");
133
- console.error(
134
- "\x1b[31m%s\x1b[0m",
135
- "This error will be fixed once vue3-particles is removed from the package.json file."
136
- );
123
+ if (dependencies["@angular/core"]) {
124
+ if (!dependencies["@tsparticles/angular"]) {
125
+ console.warn(
126
+ "\x1b[43m\x1b[30m%s\x1b[0m",
127
+ "Found Angular installed. Please download ng-particles to use tsParticles with a component ready to use and easier to configure."
128
+ );
129
+ console.log("You can read more about the component here: https://github.com/tsparticles/angular/#readme");
130
+ }
131
+ }
137
132
 
138
- throw new Error(vue3ParticlesFoundError);
139
- }
133
+ if (dependencies["vue3-particles"]) {
134
+ console.error(
135
+ "\x1b[31m%s\x1b[0m",
136
+ "The package vue3-particles has been deprecated and is not supported anymore."
137
+ );
138
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/vue3 package.");
139
+ console.error(
140
+ "\x1b[31m%s\x1b[0m",
141
+ "This error will be fixed once vue3-particles is removed from the package.json file."
142
+ );
140
143
 
141
- if (dependencies["vue2-particles"]) {
142
- console.error(
143
- "\x1b[31m%s\x1b[0m",
144
- "The package vue2-particles has been deprecated and is not supported anymore."
145
- );
146
- console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/vue2 package.");
147
- console.error(
148
- "\x1b[31m%s\x1b[0m",
149
- "This error will be fixed once vue2-particles is removed from the package.json file."
150
- );
144
+ throw new Error(vue3ParticlesFoundError);
145
+ }
151
146
 
152
- throw new Error(vue2ParticlesFoundError);
153
- }
147
+ if (dependencies["vue2-particles"]) {
148
+ console.error(
149
+ "\x1b[31m%s\x1b[0m",
150
+ "The package vue2-particles has been deprecated and is not supported anymore."
151
+ );
152
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/vue2 package.");
153
+ console.error(
154
+ "\x1b[31m%s\x1b[0m",
155
+ "This error will be fixed once vue2-particles is removed from the package.json file."
156
+ );
157
+
158
+ throw new Error(vue2ParticlesFoundError);
159
+ }
154
160
 
155
- if (dependencies["vue"] || dependencies["nuxt"]) {
156
- const vueVersion = dependencies["vue"],
157
- nuxtVersion = dependencies["nuxt"],
158
- vueMajor = (vueVersion || nuxtVersion).split(".")[0];
161
+ if (dependencies["vue"] || dependencies["nuxt"]) {
162
+ const vueVersion = dependencies["vue"],
163
+ nuxtVersion = dependencies["nuxt"],
164
+ vueMajor = (vueVersion || nuxtVersion).split(".")[0];
159
165
 
160
- if (vueMajor > 2) {
161
- if (!dependencies["@tsparticles/vue3"]) {
166
+ if (vueMajor > 2) {
167
+ if (!dependencies["@tsparticles/vue3"]) {
168
+ console.warn(
169
+ "\x1b[43m\x1b[30m%s\x1b[0m",
170
+ "Found Vue 3.x installed. Please Download @tsparticles/vue3 to use tsParticles with a component ready to use and easier to configure."
171
+ );
172
+ console.log(
173
+ "You can read more about the component here: https://github.com/tsparticles/vue3/#readme"
174
+ );
175
+ }
176
+ } else {
177
+ if (!dependencies["@tsparticles/vue2"]) {
178
+ console.warn(
179
+ "\x1b[43m\x1b[30m%s\x1b[0m",
180
+ "Found Vue 2.x installed. Please Download @tsparticles/vue2 to use tsParticles with a component ready to use and easier to configure."
181
+ );
182
+ console.log(
183
+ "You can read more about the component here: https://github.com/tsparticles/vue2/#readme"
184
+ );
185
+ }
186
+ }
187
+ }
188
+
189
+ if (dependencies["svelte"]) {
190
+ if (dependencies["svelte-particles"]) {
191
+ console.error(
192
+ "\x1b[31m%s\x1b[0m",
193
+ "The package svelte-particles has been deprecated and is not supported anymore."
194
+ );
195
+ console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/svelte package.");
196
+ console.error(
197
+ "\x1b[31m%s\x1b[0m",
198
+ "This error will be fixed once svelte-particles is removed from the package.json file."
199
+ );
200
+
201
+ throw new Error(svelteParticlesFoundError);
202
+ }
203
+
204
+ if (!dependencies["@tsparticles/svelte"]) {
162
205
  console.warn(
163
206
  "\x1b[43m\x1b[30m%s\x1b[0m",
164
- "Found Vue 3.x installed. Please Download @tsparticles/vue3 to use tsParticles with a component ready to use and easier to configure."
207
+ "Found Svelte installed. Please Download @tsparticles/svelte to use tsParticles with a component ready to use and easier to configure."
165
208
  );
166
209
  console.log(
167
- "You can read more about the component here: https://github.com/tsparticles/vue3/#readme"
210
+ "You can read more about the component here: https://github.com/tsparticles/svelte/#readme"
168
211
  );
169
212
  }
170
- } else {
171
- if (!dependencies["@tsparticles/vue2"]) {
213
+ }
214
+
215
+ if (dependencies["inferno"]) {
216
+ if (!dependencies["inferno-particles"]) {
172
217
  console.warn(
173
218
  "\x1b[43m\x1b[30m%s\x1b[0m",
174
- "Found Vue 2.x installed. Please Download @tsparticles/vue2 to use tsParticles with a component ready to use and easier to configure."
219
+ "Found Inferno installed. Please Download inferno-particles to use tsParticles with a component ready to use and easier to configure."
175
220
  );
176
221
  console.log(
177
- "You can read more about the component here: https://github.com/tsparticles/vue2/#readme"
222
+ "You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/inferno/README.md"
178
223
  );
179
224
  }
180
225
  }
181
- }
182
226
 
183
- if (dependencies["svelte"]) {
184
- if (!dependencies["svelte-particles"]) {
185
- console.warn(
186
- "\x1b[43m\x1b[30m%s\x1b[0m",
187
- "Found Svelte installed. Please Download svelte-particles to use tsParticles with a component ready to use and easier to configure."
188
- );
189
- console.log(
190
- "You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/svelte/README.md"
191
- );
227
+ if (dependencies["preact"]) {
228
+ if (!dependencies["preact-particles"]) {
229
+ console.warn(
230
+ "\x1b[43m\x1b[30m%s\x1b[0m",
231
+ "Found Preact installed. Please Download preact-particles to use tsParticles with a component ready to use and easier to configure."
232
+ );
233
+ console.log(
234
+ "You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/preact/README.md"
235
+ );
236
+ }
192
237
  }
193
- }
194
238
 
195
- if (dependencies["inferno"]) {
196
- if (!dependencies["inferno-particles"]) {
197
- console.warn(
198
- "\x1b[43m\x1b[30m%s\x1b[0m",
199
- "Found Inferno installed. Please Download inferno-particles to use tsParticles with a component ready to use and easier to configure."
200
- );
201
- console.log(
202
- "You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/inferno/README.md"
203
- );
239
+ if (dependencies["jquery"]) {
240
+ if (!dependencies["jquery-particles"]) {
241
+ console.warn(
242
+ "\x1b[43m\x1b[30m%s\x1b[0m",
243
+ "Found jQuery installed. Please Download jquery-particles to use tsParticles with a plugin ready to use and easier to configure."
244
+ );
245
+ console.log(
246
+ "You can read more about the plugin here: https://github.com/tsparticles/tsparticles/blob/main/components/jquery/README.md"
247
+ );
248
+ }
204
249
  }
205
- }
206
-
207
- if (dependencies["preact"]) {
208
- if (!dependencies["preact-particles"]) {
209
- console.warn(
210
- "\x1b[43m\x1b[30m%s\x1b[0m",
211
- "Found Preact installed. Please Download preact-particles to use tsParticles with a component ready to use and easier to configure."
212
- );
213
- console.log(
214
- "You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/preact/README.md"
215
- );
250
+ } catch (error) {
251
+ if (error.message === reactParticlesJsFoundError ||
252
+ error.message === particlesJsFoundError ||
253
+ error.message === reactParticlesFoundError ||
254
+ error.message === reactTsParticlesFoundError ||
255
+ error.message === angularParticlesFoundError ||
256
+ error.message === vue2ParticlesFoundError ||
257
+ error.message === vue3ParticlesFoundError ||
258
+ error.message === svelteParticlesFoundError
259
+ ) {
260
+ throw error;
216
261
  }
217
- }
218
262
 
219
- if (dependencies["jquery"]) {
220
- if (!dependencies["jquery-particles"]) {
221
- console.warn(
222
- "\x1b[43m\x1b[30m%s\x1b[0m",
223
- "Found jQuery installed. Please Download jquery-particles to use tsParticles with a plugin ready to use and easier to configure."
224
- );
225
- console.log(
226
- "You can read more about the plugin here: https://github.com/tsparticles/tsparticles/blob/main/components/jquery/README.md"
227
- );
228
- }
263
+ console.log(error);
229
264
  }
230
- } catch (error) {
231
- if (error.message === reactParticlesJsFoundError ||
232
- error.message === particlesJsFoundError ||
233
- error.message === reactParticlesFoundError ||
234
- error.message === reactTsParticlesFoundError ||
235
- error.message === angularParticlesFoundError ||
236
- error.message === vue2ParticlesFoundError ||
237
- error.message === vue3ParticlesFoundError
238
- ) {
239
- throw error;
240
- }
241
-
242
- console.log(error);
243
265
  }
266
+
267
+ checkErrors();
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * tsParticles Engine v4.0.0-alpha.0
2
+ * tsParticles Engine v4.0.0-alpha.2
3
3
  * Author: Matteo Bruni
4
4
  * MIT license: https://opensource.org/licenses/MIT
5
5
  * Website: https://particles.js.org/
@@ -36,7 +36,7 @@ return /******/ (() => { // webpackBootstrap
36
36
  \*************************************/
37
37
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
38
38
 
39
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Engine: () => (/* binding */ Engine)\n/* harmony export */ });\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_EventDispatcher_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Utils/EventDispatcher.js */ \"./dist/browser/Utils/EventDispatcher.js\");\n/* harmony import */ var _Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Enums/Types/EventType.js */ \"./dist/browser/Enums/Types/EventType.js\");\n/* harmony import */ var _Utils_LogUtils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Utils/LogUtils.js */ \"./dist/browser/Utils/LogUtils.js\");\n/* harmony import */ var _Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Utils/MathUtils.js */ \"./dist/browser/Utils/MathUtils.js\");\n\n\n\n\n\n\nasync function getItemsFromInitializer(container, map, initializers, force = false) {\n let res = map.get(container);\n if (!res || force) {\n res = await Promise.all([...initializers.values()].map(t => t(container)));\n map.set(container, res);\n }\n return res;\n}\nasync function getDataFromUrl(data) {\n const url = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.itemFromSingleOrMultiple)(data.url, data.index);\n if (!url) {\n return data.fallback;\n }\n const response = await fetch(url);\n if (response.ok) {\n return await response.json();\n }\n (0,_Utils_LogUtils_js__WEBPACK_IMPORTED_MODULE_4__.getLogger)().error(`${response.status.toString()} while retrieving config file`);\n return data.fallback;\n}\nconst getCanvasFromContainer = domContainer => {\n let canvasEl;\n if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasTag) {\n canvasEl = domContainer;\n canvasEl.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] ??= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedFalse;\n } else {\n const existingCanvases = domContainer.getElementsByTagName(_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasTag),\n foundCanvas = existingCanvases[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasFirstIndex];\n if (foundCanvas) {\n canvasEl = foundCanvas;\n canvasEl.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedFalse;\n } else {\n canvasEl = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().createElement(_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasTag);\n canvasEl.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedTrue;\n domContainer.appendChild(canvasEl);\n }\n }\n const fullPercent = \"100%\";\n if (!canvasEl.style.width) {\n canvasEl.style.width = fullPercent;\n }\n if (!canvasEl.style.height) {\n canvasEl.style.height = fullPercent;\n }\n return canvasEl;\n },\n getDomContainer = (id, source) => {\n let domContainer = source ?? (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().getElementById(id);\n if (domContainer) {\n return domContainer;\n }\n domContainer = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().createElement(\"div\");\n domContainer.id = id;\n domContainer.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedTrue;\n (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().body.append(domContainer);\n return domContainer;\n };\nclass Engine {\n constructor() {\n this._configs = new Map();\n this._domArray = [];\n this._eventDispatcher = new _Utils_EventDispatcher_js__WEBPACK_IMPORTED_MODULE_2__.EventDispatcher();\n this._initialized = false;\n this._loadPromises = new Set();\n this.plugins = [];\n this.colorManagers = new Map();\n this.easingFunctions = new Map();\n this._initializers = {\n interactors: new Map(),\n movers: new Map(),\n updaters: new Map()\n };\n this.interactors = new Map();\n this.movers = new Map();\n this.updaters = new Map();\n this.presets = new Map();\n this.effectDrawers = new Map();\n this.shapeDrawers = new Map();\n this.pathGenerators = new Map();\n }\n get configs() {\n const res = {};\n for (const [name, config] of this._configs) {\n res[name] = config;\n }\n return res;\n }\n get items() {\n return this._domArray;\n }\n get version() {\n return \"4.0.0-alpha.0\";\n }\n addColorManager(manager) {\n this.colorManagers.set(manager.key, manager);\n }\n addConfig(config) {\n const key = config.key ?? config.name ?? \"default\";\n this._configs.set(key, config);\n this._eventDispatcher.dispatchEvent(_Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_3__.EventType.configAdded, {\n data: {\n name: key,\n config\n }\n });\n }\n addEasing(name, easing) {\n if (this.easingFunctions.get(name)) {\n return;\n }\n this.easingFunctions.set(name, easing);\n }\n addEffect(effect, drawer) {\n if (this.getEffectDrawer(effect)) {\n return;\n }\n this.effectDrawers.set(effect, drawer);\n }\n addEventListener(type, listener) {\n this._eventDispatcher.addEventListener(type, listener);\n }\n addInteractor(name, interactorInitializer) {\n this._initializers.interactors.set(name, interactorInitializer);\n }\n addMover(name, moverInitializer) {\n this._initializers.movers.set(name, moverInitializer);\n }\n addParticleUpdater(name, updaterInitializer) {\n this._initializers.updaters.set(name, updaterInitializer);\n }\n addPathGenerator(name, generator) {\n if (this.getPathGenerator(name)) {\n return;\n }\n this.pathGenerators.set(name, generator);\n }\n addPlugin(plugin) {\n if (this.getPlugin(plugin.id)) {\n return;\n }\n this.plugins.push(plugin);\n }\n addPreset(preset, options, override = false) {\n if (!(override || !this.getPreset(preset))) {\n return;\n }\n this.presets.set(preset, options);\n }\n addShape(drawer) {\n for (const validType of drawer.validTypes) {\n if (this.getShapeDrawer(validType)) {\n continue;\n }\n this.shapeDrawers.set(validType, drawer);\n }\n }\n checkVersion(pluginVersion) {\n if (this.version === pluginVersion) {\n return;\n }\n throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);\n }\n clearPlugins(container) {\n this.updaters.delete(container);\n this.movers.delete(container);\n this.interactors.delete(container);\n }\n dispatchEvent(type, args) {\n this._eventDispatcher.dispatchEvent(type, args);\n }\n dom() {\n return this.items;\n }\n domItem(index) {\n return this.item(index);\n }\n async getAvailablePlugins(container) {\n const res = new Map();\n for (const plugin of this.plugins) {\n if (plugin.needsPlugin(container.actualOptions)) {\n res.set(plugin.id, await plugin.getPlugin(container));\n }\n }\n return res;\n }\n getEasing(name) {\n return this.easingFunctions.get(name) ?? (value => value);\n }\n getEffectDrawer(type) {\n return this.effectDrawers.get(type);\n }\n async getInteractors(container, force = false) {\n return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);\n }\n async getMovers(container, force = false) {\n return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);\n }\n getPathGenerator(type) {\n return this.pathGenerators.get(type);\n }\n getPlugin(plugin) {\n return this.plugins.find(t => t.id === plugin);\n }\n getPreset(preset) {\n return this.presets.get(preset);\n }\n getShapeDrawer(type) {\n return this.shapeDrawers.get(type);\n }\n getSupportedEffects() {\n return this.effectDrawers.keys();\n }\n getSupportedShapes() {\n return this.shapeDrawers.keys();\n }\n async getUpdaters(container, force = false) {\n return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);\n }\n async init() {\n if (this._initialized) {\n return;\n }\n for (const loadPromise of this._loadPromises) {\n await loadPromise(this);\n }\n this._loadPromises.clear();\n this._initialized = true;\n }\n item(index) {\n const {\n items\n } = this,\n item = items[index];\n if (item?.destroyed) {\n items.splice(index, _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.removeDeleteCount);\n return;\n }\n return item;\n }\n async load(params) {\n await this.init();\n const {\n Container\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Core_Container_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Container.js */ \"./dist/browser/Core/Container.js\")),\n id = params.id ?? params.element?.id ?? `tsparticles${Math.floor((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_5__.getRandom)() * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.loadRandomFactor).toString()}`,\n {\n index,\n url\n } = params,\n options = url ? await getDataFromUrl({\n fallback: params.options,\n url,\n index\n }) : params.options,\n currentOptions = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.itemFromSingleOrMultiple)(options, index),\n {\n items\n } = this,\n oldIndex = items.findIndex(v => v.id.description === id),\n newItem = new Container(this, id, currentOptions);\n if (oldIndex >= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.loadMinIndex) {\n const old = this.item(oldIndex),\n deleteCount = old ? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.one : _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.none;\n if (old && !old.destroyed) {\n old.destroy(false);\n }\n items.splice(oldIndex, deleteCount, newItem);\n } else {\n items.push(newItem);\n }\n const domContainer = getDomContainer(id, params.element),\n canvasEl = getCanvasFromContainer(domContainer);\n newItem.canvas.loadCanvas(canvasEl);\n await newItem.start();\n return newItem;\n }\n loadOptions(options, sourceOptions) {\n this.plugins.forEach(plugin => {\n plugin.loadOptions(options, sourceOptions);\n });\n }\n loadParticlesOptions(container, options, ...sourceOptions) {\n const updaters = this.updaters.get(container);\n if (!updaters) {\n return;\n }\n updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));\n }\n async refresh(refresh = true) {\n if (!refresh) {\n return;\n }\n await Promise.all(this.items.map(t => t.refresh()));\n }\n register(...loadPromises) {\n if (this._initialized) {\n throw new Error(`Register plugins can only be done before calling tsParticles.load()`);\n }\n for (const loadPromise of loadPromises) {\n this._loadPromises.add(loadPromise);\n }\n }\n removeEventListener(type, listener) {\n this._eventDispatcher.removeEventListener(type, listener);\n }\n setOnClickHandler(callback) {\n const {\n items\n } = this;\n if (!items.length) {\n throw new Error(\"Click handlers can only be set after calling tsParticles.load()\");\n }\n items.forEach(item => {\n item.addClickHandler(callback);\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Engine.js?\n}");
39
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Engine: () => (/* binding */ Engine)\n/* harmony export */ });\n/* harmony import */ var _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Utils/Constants.js */ \"./dist/browser/Core/Utils/Constants.js\");\n/* harmony import */ var _Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Utils/Utils.js */ \"./dist/browser/Utils/Utils.js\");\n/* harmony import */ var _Utils_EventDispatcher_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Utils/EventDispatcher.js */ \"./dist/browser/Utils/EventDispatcher.js\");\n/* harmony import */ var _Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Enums/Types/EventType.js */ \"./dist/browser/Enums/Types/EventType.js\");\n/* harmony import */ var _Utils_LogUtils_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Utils/LogUtils.js */ \"./dist/browser/Utils/LogUtils.js\");\n/* harmony import */ var _Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Utils/MathUtils.js */ \"./dist/browser/Utils/MathUtils.js\");\n\n\n\n\n\n\nasync function getItemsFromInitializer(container, map, initializers, force = false) {\n let res = map.get(container);\n if (!res || force) {\n res = await Promise.all([...initializers.values()].map(t => t(container)));\n map.set(container, res);\n }\n return res;\n}\nasync function getDataFromUrl(data) {\n const url = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.itemFromSingleOrMultiple)(data.url, data.index);\n if (!url) {\n return data.fallback;\n }\n const response = await fetch(url);\n if (response.ok) {\n return await response.json();\n }\n (0,_Utils_LogUtils_js__WEBPACK_IMPORTED_MODULE_4__.getLogger)().error(`${response.status.toString()} while retrieving config file`);\n return data.fallback;\n}\nconst getCanvasFromContainer = domContainer => {\n let canvasEl;\n if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasTag) {\n canvasEl = domContainer;\n canvasEl.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] ??= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedFalse;\n } else {\n const existingCanvases = domContainer.getElementsByTagName(_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasTag),\n foundCanvas = existingCanvases[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasFirstIndex];\n if (foundCanvas) {\n canvasEl = foundCanvas;\n canvasEl.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedFalse;\n } else {\n canvasEl = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().createElement(_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.canvasTag);\n canvasEl.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedTrue;\n domContainer.appendChild(canvasEl);\n }\n }\n const fullPercent = \"100%\";\n if (!canvasEl.style.width) {\n canvasEl.style.width = fullPercent;\n }\n if (!canvasEl.style.height) {\n canvasEl.style.height = fullPercent;\n }\n return canvasEl;\n },\n getDomContainer = (id, source) => {\n let domContainer = source ?? (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().getElementById(id);\n if (domContainer) {\n return domContainer;\n }\n domContainer = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().createElement(\"div\");\n domContainer.id = id;\n domContainer.dataset[_Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedAttribute] = _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.generatedTrue;\n (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.safeDocument)().body.append(domContainer);\n return domContainer;\n };\nclass Engine {\n constructor() {\n this._configs = new Map();\n this._domArray = [];\n this._eventDispatcher = new _Utils_EventDispatcher_js__WEBPACK_IMPORTED_MODULE_2__.EventDispatcher();\n this._initialized = false;\n this._loadPromises = new Set();\n this.plugins = [];\n this.colorManagers = new Map();\n this.easingFunctions = new Map();\n this._initializers = {\n interactors: new Map(),\n movers: new Map(),\n updaters: new Map()\n };\n this.interactors = new Map();\n this.movers = new Map();\n this.updaters = new Map();\n this.presets = new Map();\n this.effectDrawers = new Map();\n this.shapeDrawers = new Map();\n this.pathGenerators = new Map();\n }\n get configs() {\n const res = {};\n for (const [name, config] of this._configs) {\n res[name] = config;\n }\n return res;\n }\n get items() {\n return this._domArray;\n }\n get version() {\n return \"4.0.0-alpha.2\";\n }\n addColorManager(manager) {\n this.colorManagers.set(manager.key, manager);\n }\n addConfig(config) {\n const key = config.key ?? config.name ?? \"default\";\n this._configs.set(key, config);\n this._eventDispatcher.dispatchEvent(_Enums_Types_EventType_js__WEBPACK_IMPORTED_MODULE_3__.EventType.configAdded, {\n data: {\n name: key,\n config\n }\n });\n }\n addEasing(name, easing) {\n if (this.easingFunctions.get(name)) {\n return;\n }\n this.easingFunctions.set(name, easing);\n }\n addEffect(effect, drawer) {\n if (this.getEffectDrawer(effect)) {\n return;\n }\n this.effectDrawers.set(effect, drawer);\n }\n addEventListener(type, listener) {\n this._eventDispatcher.addEventListener(type, listener);\n }\n addInteractor(name, interactorInitializer) {\n this._initializers.interactors.set(name, interactorInitializer);\n }\n addMover(name, moverInitializer) {\n this._initializers.movers.set(name, moverInitializer);\n }\n addParticleUpdater(name, updaterInitializer) {\n this._initializers.updaters.set(name, updaterInitializer);\n }\n addPathGenerator(name, generator) {\n if (this.getPathGenerator(name)) {\n return;\n }\n this.pathGenerators.set(name, generator);\n }\n addPlugin(plugin) {\n if (this.getPlugin(plugin.id)) {\n return;\n }\n this.plugins.push(plugin);\n }\n addPreset(preset, options, override = false) {\n if (!(override || !this.getPreset(preset))) {\n return;\n }\n this.presets.set(preset, options);\n }\n addShape(drawer) {\n for (const validType of drawer.validTypes) {\n if (this.getShapeDrawer(validType)) {\n continue;\n }\n this.shapeDrawers.set(validType, drawer);\n }\n }\n checkVersion(pluginVersion) {\n if (this.version === pluginVersion) {\n return;\n }\n throw new Error(`The tsParticles version is different from the loaded plugins version. Engine version: ${this.version}. Plugin version: ${pluginVersion}`);\n }\n clearPlugins(container) {\n this.updaters.delete(container);\n this.movers.delete(container);\n this.interactors.delete(container);\n }\n dispatchEvent(type, args) {\n this._eventDispatcher.dispatchEvent(type, args);\n }\n dom() {\n return this.items;\n }\n domItem(index) {\n return this.item(index);\n }\n async getAvailablePlugins(container) {\n const res = new Map();\n for (const plugin of this.plugins) {\n if (plugin.needsPlugin(container.actualOptions)) {\n res.set(plugin.id, await plugin.getPlugin(container));\n }\n }\n return res;\n }\n getEasing(name) {\n return this.easingFunctions.get(name) ?? (value => value);\n }\n getEffectDrawer(type) {\n return this.effectDrawers.get(type);\n }\n async getInteractors(container, force = false) {\n return getItemsFromInitializer(container, this.interactors, this._initializers.interactors, force);\n }\n async getMovers(container, force = false) {\n return getItemsFromInitializer(container, this.movers, this._initializers.movers, force);\n }\n getPathGenerator(type) {\n return this.pathGenerators.get(type);\n }\n getPlugin(plugin) {\n return this.plugins.find(t => t.id === plugin);\n }\n getPreset(preset) {\n return this.presets.get(preset);\n }\n getShapeDrawer(type) {\n return this.shapeDrawers.get(type);\n }\n getSupportedEffects() {\n return this.effectDrawers.keys();\n }\n getSupportedShapes() {\n return this.shapeDrawers.keys();\n }\n async getUpdaters(container, force = false) {\n return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);\n }\n async init() {\n if (this._initialized) {\n return;\n }\n for (const loadPromise of this._loadPromises) {\n await loadPromise(this);\n }\n this._loadPromises.clear();\n this._initialized = true;\n }\n item(index) {\n const {\n items\n } = this,\n item = items[index];\n if (item?.destroyed) {\n items.splice(index, _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.removeDeleteCount);\n return;\n }\n return item;\n }\n async load(params) {\n await this.init();\n const {\n Container\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Core_Container_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Container.js */ \"./dist/browser/Core/Container.js\")),\n id = params.id ?? params.element?.id ?? `tsparticles${Math.floor((0,_Utils_MathUtils_js__WEBPACK_IMPORTED_MODULE_5__.getRandom)() * _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.loadRandomFactor).toString()}`,\n {\n index,\n url\n } = params,\n options = url ? await getDataFromUrl({\n fallback: params.options,\n url,\n index\n }) : params.options,\n currentOptions = (0,_Utils_Utils_js__WEBPACK_IMPORTED_MODULE_1__.itemFromSingleOrMultiple)(options, index),\n {\n items\n } = this,\n oldIndex = items.findIndex(v => v.id.description === id),\n newItem = new Container(this, id, currentOptions);\n if (oldIndex >= _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.loadMinIndex) {\n const old = this.item(oldIndex),\n deleteCount = old ? _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.one : _Utils_Constants_js__WEBPACK_IMPORTED_MODULE_0__.none;\n if (old && !old.destroyed) {\n old.destroy(false);\n }\n items.splice(oldIndex, deleteCount, newItem);\n } else {\n items.push(newItem);\n }\n const domContainer = getDomContainer(id, params.element),\n canvasEl = getCanvasFromContainer(domContainer);\n newItem.canvas.loadCanvas(canvasEl);\n await newItem.start();\n return newItem;\n }\n loadOptions(options, sourceOptions) {\n this.plugins.forEach(plugin => {\n plugin.loadOptions(options, sourceOptions);\n });\n }\n loadParticlesOptions(container, options, ...sourceOptions) {\n const updaters = this.updaters.get(container);\n if (!updaters) {\n return;\n }\n updaters.forEach(updater => updater.loadOptions?.(options, ...sourceOptions));\n }\n async refresh(refresh = true) {\n if (!refresh) {\n return;\n }\n await Promise.all(this.items.map(t => t.refresh()));\n }\n register(...loadPromises) {\n if (this._initialized) {\n throw new Error(`Register plugins can only be done before calling tsParticles.load()`);\n }\n for (const loadPromise of loadPromises) {\n this._loadPromises.add(loadPromise);\n }\n }\n removeEventListener(type, listener) {\n this._eventDispatcher.removeEventListener(type, listener);\n }\n setOnClickHandler(callback) {\n const {\n items\n } = this;\n if (!items.length) {\n throw new Error(\"Click handlers can only be set after calling tsParticles.load()\");\n }\n items.forEach(item => {\n item.addClickHandler(callback);\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/engine/./dist/browser/Core/Engine.js?\n}");
40
40
 
41
41
  /***/ },
42
42