@tsparticles/engine 4.0.0-alpha.0 → 4.0.0-alpha.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.
- package/638.min.js.LICENSE.txt +1 -1
- package/browser/Core/Engine.js +1 -1
- package/cjs/Core/Engine.js +1 -1
- package/dist_browser_Core_Container_js.js +1 -1
- package/esm/Core/Engine.js +1 -1
- package/package.json +1 -1
- package/report.html +2 -2
- package/scripts/install.js +201 -196
- package/tsparticles.engine.js +2 -2
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/umd/Core/Engine.js +1 -1
package/scripts/install.js
CHANGED
|
@@ -1,243 +1,248 @@
|
|
|
1
|
-
const path = require("path")
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!pkgSettings) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
function checkErrors() {
|
|
4
|
+
const particlesJsFoundError = "particles.js-found",
|
|
5
|
+
reactParticlesJsFoundError = "react-particles-js-found",
|
|
6
|
+
reactParticlesFoundError = "react-particles-found",
|
|
7
|
+
reactTsParticlesFoundError = "react-tsparticles-found",
|
|
8
|
+
angularParticlesFoundError = "ng-particles-found",
|
|
9
|
+
vue2ParticlesFoundError = "vue2-particles-found",
|
|
10
|
+
vue3ParticlesFoundError = "vue3-particles-found";
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
console.log("Thank you for installing tsParticles.");
|
|
14
|
+
console.log("Remember to checkout the official website https://particles.js.org to explore some samples.");
|
|
15
|
+
console.log("You can find more samples on CodePen too: https://codepen.io/collection/DPOage");
|
|
16
|
+
console.log("If you need documentation you can find it here: https://particles.js.org/docs");
|
|
17
|
+
console.log(
|
|
18
|
+
"Don't forget to star the tsParticles repository, if you like the project and want to support it: https://github.com/tsparticles/tsparticles"
|
|
19
|
+
);
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
const pkgSettings = require(path.join(process.env.INIT_CWD, "package.json"));
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
if (!pkgSettings) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
30
26
|
|
|
31
|
-
|
|
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."
|
|
35
|
-
);
|
|
27
|
+
const dependencies = pkgSettings.dependencies;
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
if (!dependencies) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
if (dependencies["particles.js"]) {
|
|
34
|
+
console.error(
|
|
35
|
+
"\x1b[31m%s\x1b[0m",
|
|
36
|
+
"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."
|
|
37
|
+
);
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
throw new Error(reactParticlesJsFoundError);
|
|
40
|
+
}
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
);
|
|
42
|
+
if (dependencies["particlesjs"]) {
|
|
43
|
+
console.error(
|
|
44
|
+
"\x1b[31m%s\x1b[0m",
|
|
45
|
+
"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."
|
|
46
|
+
);
|
|
59
47
|
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
throw new Error(reactParticlesJsFoundError);
|
|
49
|
+
}
|
|
62
50
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
51
|
+
if (dependencies["react-particles-js"]) {
|
|
52
|
+
console.error(
|
|
53
|
+
"\x1b[31m%s\x1b[0m",
|
|
54
|
+
"The package react-particles-js has been deprecated and is not supported anymore."
|
|
55
|
+
);
|
|
56
|
+
console.error("\x1b[31m%s\x1b[0m", "Please consider switching to react-particles package.");
|
|
57
|
+
console.error(
|
|
58
|
+
"\x1b[31m%s\x1b[0m",
|
|
59
|
+
"This error will be fixed once react-particles-js is removed from the package.json file."
|
|
60
|
+
);
|
|
73
61
|
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
throw new Error(reactParticlesJsFoundError);
|
|
63
|
+
}
|
|
76
64
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
65
|
+
if (dependencies["react-tsparticles"]) {
|
|
66
|
+
console.error(
|
|
67
|
+
"\x1b[31m%s\x1b[0m",
|
|
68
|
+
"The package react-tsparticles has been deprecated and is not supported anymore."
|
|
69
|
+
);
|
|
70
|
+
console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/react package.");
|
|
71
|
+
console.error(
|
|
72
|
+
"\x1b[31m%s\x1b[0m",
|
|
73
|
+
"This error will be fixed once react-tsparticles is removed from the package.json file."
|
|
74
|
+
);
|
|
87
75
|
|
|
88
|
-
|
|
89
|
-
|
|
76
|
+
throw new Error(reactTsParticlesFoundError);
|
|
77
|
+
}
|
|
90
78
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
"Found React installed. Please download react-particles to use tsParticles with a component ready to use and easier to configure."
|
|
79
|
+
if (dependencies["react-particles"]) {
|
|
80
|
+
console.error(
|
|
81
|
+
"\x1b[31m%s\x1b[0m",
|
|
82
|
+
"The package react-particles has been deprecated and is not supported anymore."
|
|
96
83
|
);
|
|
97
|
-
console.
|
|
98
|
-
|
|
84
|
+
console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/react package.");
|
|
85
|
+
console.error(
|
|
86
|
+
"\x1b[31m%s\x1b[0m",
|
|
87
|
+
"This error will be fixed once react-particles is removed from the package.json file."
|
|
99
88
|
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
89
|
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
);
|
|
90
|
+
throw new Error(reactParticlesFoundError);
|
|
91
|
+
}
|
|
113
92
|
|
|
114
|
-
|
|
115
|
-
|
|
93
|
+
if (dependencies["react"] || dependencies["next"]) {
|
|
94
|
+
if (!dependencies["@tsparticles/react"]) {
|
|
95
|
+
console.warn(
|
|
96
|
+
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
97
|
+
"Found React installed. Please download react-particles to use tsParticles with a component ready to use and easier to configure."
|
|
98
|
+
);
|
|
99
|
+
console.log(
|
|
100
|
+
"You can read more about the component here: https://github.com/tsparticles/react/#readme"
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
116
104
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
105
|
+
if (dependencies["ng-particles"]) {
|
|
106
|
+
console.error(
|
|
107
|
+
"\x1b[31m%s\x1b[0m",
|
|
108
|
+
"The package ng-particles has been deprecated and is not supported anymore."
|
|
109
|
+
);
|
|
110
|
+
console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/angular package.");
|
|
111
|
+
console.error(
|
|
112
|
+
"\x1b[31m%s\x1b[0m",
|
|
113
|
+
"This error will be fixed once ng-particles is removed from the package.json file."
|
|
122
114
|
);
|
|
123
|
-
|
|
115
|
+
|
|
116
|
+
throw new Error(angularParticlesFoundError);
|
|
124
117
|
}
|
|
125
|
-
}
|
|
126
118
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
);
|
|
119
|
+
if (dependencies["@angular/core"]) {
|
|
120
|
+
if (!dependencies["@tsparticles/angular"]) {
|
|
121
|
+
console.warn(
|
|
122
|
+
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
123
|
+
"Found Angular installed. Please download ng-particles to use tsParticles with a component ready to use and easier to configure."
|
|
124
|
+
);
|
|
125
|
+
console.log("You can read more about the component here: https://github.com/tsparticles/angular/#readme");
|
|
126
|
+
}
|
|
127
|
+
}
|
|
137
128
|
|
|
138
|
-
|
|
139
|
-
|
|
129
|
+
if (dependencies["vue3-particles"]) {
|
|
130
|
+
console.error(
|
|
131
|
+
"\x1b[31m%s\x1b[0m",
|
|
132
|
+
"The package vue3-particles has been deprecated and is not supported anymore."
|
|
133
|
+
);
|
|
134
|
+
console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/vue3 package.");
|
|
135
|
+
console.error(
|
|
136
|
+
"\x1b[31m%s\x1b[0m",
|
|
137
|
+
"This error will be fixed once vue3-particles is removed from the package.json file."
|
|
138
|
+
);
|
|
140
139
|
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
);
|
|
140
|
+
throw new Error(vue3ParticlesFoundError);
|
|
141
|
+
}
|
|
151
142
|
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
if (dependencies["vue2-particles"]) {
|
|
144
|
+
console.error(
|
|
145
|
+
"\x1b[31m%s\x1b[0m",
|
|
146
|
+
"The package vue2-particles has been deprecated and is not supported anymore."
|
|
147
|
+
);
|
|
148
|
+
console.error("\x1b[31m%s\x1b[0m", "Please consider switching to @tsparticles/vue2 package.");
|
|
149
|
+
console.error(
|
|
150
|
+
"\x1b[31m%s\x1b[0m",
|
|
151
|
+
"This error will be fixed once vue2-particles is removed from the package.json file."
|
|
152
|
+
);
|
|
154
153
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
throw new Error(vue2ParticlesFoundError);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (dependencies["vue"] || dependencies["nuxt"]) {
|
|
158
|
+
const vueVersion = dependencies["vue"],
|
|
159
|
+
nuxtVersion = dependencies["nuxt"],
|
|
160
|
+
vueMajor = (vueVersion || nuxtVersion).split(".")[0];
|
|
161
|
+
|
|
162
|
+
if (vueMajor > 2) {
|
|
163
|
+
if (!dependencies["@tsparticles/vue3"]) {
|
|
164
|
+
console.warn(
|
|
165
|
+
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
166
|
+
"Found Vue 3.x installed. Please Download @tsparticles/vue3 to use tsParticles with a component ready to use and easier to configure."
|
|
167
|
+
);
|
|
168
|
+
console.log(
|
|
169
|
+
"You can read more about the component here: https://github.com/tsparticles/vue3/#readme"
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
if (!dependencies["@tsparticles/vue2"]) {
|
|
174
|
+
console.warn(
|
|
175
|
+
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
176
|
+
"Found Vue 2.x installed. Please Download @tsparticles/vue2 to use tsParticles with a component ready to use and easier to configure."
|
|
177
|
+
);
|
|
178
|
+
console.log(
|
|
179
|
+
"You can read more about the component here: https://github.com/tsparticles/vue2/#readme"
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
159
184
|
|
|
160
|
-
if (
|
|
161
|
-
if (!dependencies["
|
|
185
|
+
if (dependencies["svelte"]) {
|
|
186
|
+
if (!dependencies["svelte-particles"]) {
|
|
162
187
|
console.warn(
|
|
163
188
|
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
164
|
-
"Found
|
|
189
|
+
"Found Svelte installed. Please Download svelte-particles to use tsParticles with a component ready to use and easier to configure."
|
|
165
190
|
);
|
|
166
191
|
console.log(
|
|
167
|
-
"You can read more about the component here: https://github.com/tsparticles/
|
|
192
|
+
"You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/svelte/README.md"
|
|
168
193
|
);
|
|
169
194
|
}
|
|
170
|
-
}
|
|
171
|
-
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (dependencies["inferno"]) {
|
|
198
|
+
if (!dependencies["inferno-particles"]) {
|
|
172
199
|
console.warn(
|
|
173
200
|
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
174
|
-
"Found
|
|
201
|
+
"Found Inferno installed. Please Download inferno-particles to use tsParticles with a component ready to use and easier to configure."
|
|
175
202
|
);
|
|
176
203
|
console.log(
|
|
177
|
-
"You can read more about the component here: https://github.com/tsparticles/
|
|
204
|
+
"You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/inferno/README.md"
|
|
178
205
|
);
|
|
179
206
|
}
|
|
180
207
|
}
|
|
181
|
-
}
|
|
182
208
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
209
|
+
if (dependencies["preact"]) {
|
|
210
|
+
if (!dependencies["preact-particles"]) {
|
|
211
|
+
console.warn(
|
|
212
|
+
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
213
|
+
"Found Preact installed. Please Download preact-particles to use tsParticles with a component ready to use and easier to configure."
|
|
214
|
+
);
|
|
215
|
+
console.log(
|
|
216
|
+
"You can read more about the component here: https://github.com/tsparticles/tsparticles/blob/main/components/preact/README.md"
|
|
217
|
+
);
|
|
218
|
+
}
|
|
192
219
|
}
|
|
193
|
-
}
|
|
194
220
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
221
|
+
if (dependencies["jquery"]) {
|
|
222
|
+
if (!dependencies["jquery-particles"]) {
|
|
223
|
+
console.warn(
|
|
224
|
+
"\x1b[43m\x1b[30m%s\x1b[0m",
|
|
225
|
+
"Found jQuery installed. Please Download jquery-particles to use tsParticles with a plugin ready to use and easier to configure."
|
|
226
|
+
);
|
|
227
|
+
console.log(
|
|
228
|
+
"You can read more about the plugin here: https://github.com/tsparticles/tsparticles/blob/main/components/jquery/README.md"
|
|
229
|
+
);
|
|
230
|
+
}
|
|
204
231
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if (error.message === reactParticlesJsFoundError ||
|
|
234
|
+
error.message === particlesJsFoundError ||
|
|
235
|
+
error.message === reactParticlesFoundError ||
|
|
236
|
+
error.message === reactTsParticlesFoundError ||
|
|
237
|
+
error.message === angularParticlesFoundError ||
|
|
238
|
+
error.message === vue2ParticlesFoundError ||
|
|
239
|
+
error.message === vue3ParticlesFoundError
|
|
240
|
+
) {
|
|
241
|
+
throw error;
|
|
216
242
|
}
|
|
217
|
-
}
|
|
218
243
|
|
|
219
|
-
|
|
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
|
-
}
|
|
229
|
-
}
|
|
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;
|
|
244
|
+
console.log(error);
|
|
240
245
|
}
|
|
241
|
-
|
|
242
|
-
console.log(error);
|
|
243
246
|
}
|
|
247
|
+
|
|
248
|
+
checkErrors();
|
package/tsparticles.engine.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* tsParticles Engine v4.0.0-alpha.
|
|
2
|
+
* tsParticles Engine v4.0.0-alpha.1
|
|
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.1\";\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
|
|