@tsparticles/react 4.0.5 → 4.1.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/{dist/Particles.js → Particles.js} +8 -4
- package/package.json +7 -50
- package/README.md +0 -348
- /package/{dist/IParticlesProps.js → IParticlesProps.js} +0 -0
- /package/{dist/ParticlesProvider.js → ParticlesProvider.js} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/lib → lib}/IParticlesProps.d.ts +0 -0
- /package/{dist/lib → lib}/Particles.d.ts +0 -0
- /package/{dist/lib → lib}/ParticlesProvider.d.ts +0 -0
- /package/{dist/lib → lib}/index.d.ts +0 -0
|
@@ -7,15 +7,19 @@ var i = (i) => {
|
|
|
7
7
|
let { className: a, id: o, options: s, particlesLoaded: c, style: l, url: u } = i, { loaded: d } = e();
|
|
8
8
|
return t(() => {
|
|
9
9
|
if (!d) return;
|
|
10
|
-
let e;
|
|
10
|
+
let e, t = !1;
|
|
11
11
|
return n.load({
|
|
12
12
|
id: o ?? "tsparticles",
|
|
13
13
|
url: u,
|
|
14
14
|
options: s
|
|
15
|
-
}).then((
|
|
16
|
-
|
|
15
|
+
}).then((n) => {
|
|
16
|
+
if (t) {
|
|
17
|
+
n?.destroy();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
e = n, c?.(n);
|
|
17
21
|
}), () => {
|
|
18
|
-
e?.destroy();
|
|
22
|
+
t = !0, e?.destroy();
|
|
19
23
|
};
|
|
20
24
|
}, [
|
|
21
25
|
o,
|
package/package.json
CHANGED
|
@@ -1,70 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/tsparticles/tsparticles.git",
|
|
8
8
|
"directory": "wrappers/react"
|
|
9
9
|
},
|
|
10
|
-
"main": "
|
|
11
|
-
"types": "
|
|
10
|
+
"main": "./index.js",
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./
|
|
15
|
-
"default": "./
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
15
|
+
"default": "./index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"dev": "vite",
|
|
20
|
-
"build": "prettier --write README.md && pnpm run prettify && tsc && vite build",
|
|
21
|
-
"build:ci": "prettier --check README.md && pnpm run prettify:ci && tsc && vite build",
|
|
22
|
-
"lint": "eslint . --max-warnings 0",
|
|
23
|
-
"preview": "vite preview",
|
|
24
|
-
"prettify": "prettier --write \"src/**/*.{ts,tsx}\" && prettier --write \"lib/**/*.{ts,tsx}\"",
|
|
25
|
-
"prettify:ci": "prettier --check \"src/**/*.{ts,tsx}\" && prettier --check \"lib/**/*.{ts,tsx}\"",
|
|
26
|
-
"prepublishOnly": "pnpm run build"
|
|
27
|
-
},
|
|
28
|
-
"files": [
|
|
29
|
-
"dist"
|
|
30
|
-
],
|
|
31
18
|
"license": "MIT",
|
|
32
19
|
"peerDependencies": {
|
|
33
|
-
"@tsparticles/engine": "
|
|
20
|
+
"@tsparticles/engine": "4.1.1",
|
|
34
21
|
"react": ">=16.8.0",
|
|
35
22
|
"react-dom": ">=16.8.0"
|
|
36
23
|
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@tsparticles/engine": "4.0.5",
|
|
39
|
-
"@types/react": "^19.2.14",
|
|
40
|
-
"@types/react-dom": "^19.2.3",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "^8.58.1",
|
|
42
|
-
"@typescript-eslint/parser": "^8.58.1",
|
|
43
|
-
"@vitejs/plugin-react": "^6.0.1",
|
|
44
|
-
"eslint": "^10.2.0",
|
|
45
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
46
|
-
"eslint-plugin-react-refresh": "^0.5.2",
|
|
47
|
-
"glob": "^13.0.6",
|
|
48
|
-
"react": "^19.2.5",
|
|
49
|
-
"react-dom": "^19.2.5",
|
|
50
|
-
"typescript": "^6.0.2",
|
|
51
|
-
"vite": "^8.0.8",
|
|
52
|
-
"vite-plugin-dts": "^4.5.4",
|
|
53
|
-
"vite-plugin-lib-inject-css": "^2.2.2"
|
|
54
|
-
},
|
|
55
|
-
"nx": {
|
|
56
|
-
"targets": {
|
|
57
|
-
"build": {
|
|
58
|
-
"inputs": [
|
|
59
|
-
"production",
|
|
60
|
-
"^production",
|
|
61
|
-
"{projectRoot}/lib/**/*"
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
24
|
"publishConfig": {
|
|
67
25
|
"access": "public"
|
|
68
|
-
}
|
|
69
|
-
"gitHead": "4d8b281f8097386714300e39b0004b903f9df87b"
|
|
26
|
+
}
|
|
70
27
|
}
|
package/README.md
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
[](https://particles.js.org)
|
|
2
|
-
|
|
3
|
-
# @tsparticles/react
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/@tsparticles/react) [](https://www.npmjs.com/package/@tsparticles/react) [](https://github.com/sponsors/matteobruni)
|
|
6
|
-
|
|
7
|
-
Official [tsParticles](https://github.com/tsparticles/tsparticles) ReactJS component
|
|
8
|
-
|
|
9
|
-
If you are using Next.js, prefer [@tsparticles/nextjs](https://www.npmjs.com/package/@tsparticles/nextjs) for a Next-first integration layer.
|
|
10
|
-
|
|
11
|
-
[](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [](https://discord.gg/hACwv45Hme) [](https://t.me/tsparticles)
|
|
12
|
-
|
|
13
|
-
[](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tsparticles") <a href="https://www.buymeacoffee.com/matteobruni"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a beer&emoji=🍺&slug=matteobruni&button_colour=5F7FFF&font_colour=ffffff&font_family=Arial&outline_colour=000000&coffee_colour=FFDD00"></a>
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```shell
|
|
18
|
-
npm install @tsparticles/react
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
or
|
|
22
|
-
|
|
23
|
-
```shell
|
|
24
|
-
yarn add @tsparticles/react
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### TypeScript Installation
|
|
28
|
-
|
|
29
|
-
```shell
|
|
30
|
-
npm install @tsparticles/react @tsparticles/engine
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
or
|
|
34
|
-
|
|
35
|
-
```shell
|
|
36
|
-
yarn add @tsparticles/react @tsparticles/engine
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
[@tsparticles/engine](https://npmjs.com/package/@tsparticles/engine) is the core package for [tsParticles](https://particles.js.org), it contains useful types like `ISourceOptions`, `Engine` or `Container`.
|
|
40
|
-
|
|
41
|
-
### React templates
|
|
42
|
-
|
|
43
|
-
Starting from version 1.17.0 there are two official React templates:
|
|
44
|
-
|
|
45
|
-
- `cra-template-particles`: Simple ReactJS template with full screen particles, using JavaScript
|
|
46
|
-
- `cra-template-particles-typescript`: Simple ReactJS template with full screen particles, using TypeScript
|
|
47
|
-
|
|
48
|
-
You can install them using `create-react-app` like this:
|
|
49
|
-
|
|
50
|
-
```shell
|
|
51
|
-
$ create-react-app your_app --template particles
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
or
|
|
55
|
-
|
|
56
|
-
```shell
|
|
57
|
-
$ create-react-app your_app --template particles-typescript
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## How to use
|
|
61
|
-
|
|
62
|
-
### Code
|
|
63
|
-
|
|
64
|
-
`ParticlesProvider` is required and receives one async `init` callback.
|
|
65
|
-
That callback is executed only once for the app lifecycle.
|
|
66
|
-
|
|
67
|
-
Examples:
|
|
68
|
-
|
|
69
|
-
#### Options object
|
|
70
|
-
|
|
71
|
-
##### JavaScript support - object
|
|
72
|
-
|
|
73
|
-
```jsx
|
|
74
|
-
import { useMemo } from "react";
|
|
75
|
-
import Particles, { ParticlesProvider } from "@tsparticles/react";
|
|
76
|
-
// import { loadAll } from "@tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
|
|
77
|
-
// import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
|
|
78
|
-
import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
|
|
79
|
-
// import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
|
|
80
|
-
|
|
81
|
-
const particlesInit = async engine => {
|
|
82
|
-
await loadSlim(engine);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const App = () => {
|
|
86
|
-
const particlesLoaded = container => {
|
|
87
|
-
console.log(container);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const options = useMemo(
|
|
91
|
-
() => ({
|
|
92
|
-
background: {
|
|
93
|
-
color: {
|
|
94
|
-
value: "#0d47a1",
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
fpsLimit: 120,
|
|
98
|
-
interactivity: {
|
|
99
|
-
events: {
|
|
100
|
-
onClick: {
|
|
101
|
-
enable: true,
|
|
102
|
-
mode: "push",
|
|
103
|
-
},
|
|
104
|
-
onHover: {
|
|
105
|
-
enable: true,
|
|
106
|
-
mode: "repulse",
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
modes: {
|
|
110
|
-
push: {
|
|
111
|
-
quantity: 4,
|
|
112
|
-
},
|
|
113
|
-
repulse: {
|
|
114
|
-
distance: 200,
|
|
115
|
-
duration: 0.4,
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
particles: {
|
|
120
|
-
color: {
|
|
121
|
-
value: "#ffffff",
|
|
122
|
-
},
|
|
123
|
-
links: {
|
|
124
|
-
color: "#ffffff",
|
|
125
|
-
distance: 150,
|
|
126
|
-
enable: true,
|
|
127
|
-
opacity: 0.5,
|
|
128
|
-
width: 1,
|
|
129
|
-
},
|
|
130
|
-
move: {
|
|
131
|
-
direction: "none",
|
|
132
|
-
enable: true,
|
|
133
|
-
outModes: {
|
|
134
|
-
default: "bounce",
|
|
135
|
-
},
|
|
136
|
-
random: false,
|
|
137
|
-
speed: 6,
|
|
138
|
-
straight: false,
|
|
139
|
-
},
|
|
140
|
-
number: {
|
|
141
|
-
density: {
|
|
142
|
-
enable: true,
|
|
143
|
-
},
|
|
144
|
-
value: 80,
|
|
145
|
-
},
|
|
146
|
-
opacity: {
|
|
147
|
-
value: 0.5,
|
|
148
|
-
},
|
|
149
|
-
shape: {
|
|
150
|
-
type: "circle",
|
|
151
|
-
},
|
|
152
|
-
size: {
|
|
153
|
-
value: { min: 1, max: 5 },
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
detectRetina: true,
|
|
157
|
-
}),
|
|
158
|
-
[],
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<ParticlesProvider init={particlesInit}>
|
|
163
|
-
<Particles id="tsparticles" particlesLoaded={particlesLoaded} options={options} />
|
|
164
|
-
</ParticlesProvider>
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
##### TypeScript support - object
|
|
170
|
-
|
|
171
|
-
```tsx
|
|
172
|
-
import { useMemo } from "react";
|
|
173
|
-
import Particles, { ParticlesProvider } from "@tsparticles/react";
|
|
174
|
-
import { type Container, type Engine, type ISourceOptions, MoveDirection, OutMode } from "@tsparticles/engine";
|
|
175
|
-
// import { loadAll } from "@tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
|
|
176
|
-
// import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
|
|
177
|
-
import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
|
|
178
|
-
// import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
|
|
179
|
-
|
|
180
|
-
const particlesInit = async (engine: Engine): Promise<void> => {
|
|
181
|
-
await loadSlim(engine);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const App = () => {
|
|
185
|
-
const particlesLoaded = async (container?: Container): Promise<void> => {
|
|
186
|
-
console.log(container);
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
const options: ISourceOptions = useMemo(
|
|
190
|
-
() => ({
|
|
191
|
-
background: {
|
|
192
|
-
color: {
|
|
193
|
-
value: "#0d47a1",
|
|
194
|
-
},
|
|
195
|
-
},
|
|
196
|
-
fpsLimit: 120,
|
|
197
|
-
interactivity: {
|
|
198
|
-
events: {
|
|
199
|
-
onClick: {
|
|
200
|
-
enable: true,
|
|
201
|
-
mode: "push",
|
|
202
|
-
},
|
|
203
|
-
onHover: {
|
|
204
|
-
enable: true,
|
|
205
|
-
mode: "repulse",
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
modes: {
|
|
209
|
-
push: {
|
|
210
|
-
quantity: 4,
|
|
211
|
-
},
|
|
212
|
-
repulse: {
|
|
213
|
-
distance: 200,
|
|
214
|
-
duration: 0.4,
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
particles: {
|
|
219
|
-
color: {
|
|
220
|
-
value: "#ffffff",
|
|
221
|
-
},
|
|
222
|
-
links: {
|
|
223
|
-
color: "#ffffff",
|
|
224
|
-
distance: 150,
|
|
225
|
-
enable: true,
|
|
226
|
-
opacity: 0.5,
|
|
227
|
-
width: 1,
|
|
228
|
-
},
|
|
229
|
-
move: {
|
|
230
|
-
direction: MoveDirection.none,
|
|
231
|
-
enable: true,
|
|
232
|
-
outModes: {
|
|
233
|
-
default: OutMode.out,
|
|
234
|
-
},
|
|
235
|
-
random: false,
|
|
236
|
-
speed: 6,
|
|
237
|
-
straight: false,
|
|
238
|
-
},
|
|
239
|
-
number: {
|
|
240
|
-
density: {
|
|
241
|
-
enable: true,
|
|
242
|
-
},
|
|
243
|
-
value: 80,
|
|
244
|
-
},
|
|
245
|
-
opacity: {
|
|
246
|
-
value: 0.5,
|
|
247
|
-
},
|
|
248
|
-
shape: {
|
|
249
|
-
type: "circle",
|
|
250
|
-
},
|
|
251
|
-
size: {
|
|
252
|
-
value: { min: 1, max: 5 },
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
detectRetina: true,
|
|
256
|
-
}),
|
|
257
|
-
[],
|
|
258
|
-
);
|
|
259
|
-
|
|
260
|
-
return (
|
|
261
|
-
<ParticlesProvider init={particlesInit}>
|
|
262
|
-
<Particles id="tsparticles" particlesLoaded={particlesLoaded} options={options} />
|
|
263
|
-
</ParticlesProvider>
|
|
264
|
-
);
|
|
265
|
-
};
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
#### Remote url
|
|
269
|
-
|
|
270
|
-
##### JavaScript support - url
|
|
271
|
-
|
|
272
|
-
```jsx
|
|
273
|
-
import Particles, { ParticlesProvider } from "@tsparticles/react";
|
|
274
|
-
// import { loadAll } from "@tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
|
|
275
|
-
// import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
|
|
276
|
-
import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
|
|
277
|
-
// import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
|
|
278
|
-
|
|
279
|
-
const particlesInit = async engine => {
|
|
280
|
-
await loadSlim(engine);
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const App = () => {
|
|
284
|
-
const particlesLoaded = container => {
|
|
285
|
-
console.log(container);
|
|
286
|
-
};
|
|
287
|
-
|
|
288
|
-
return (
|
|
289
|
-
<ParticlesProvider init={particlesInit}>
|
|
290
|
-
<Particles id="tsparticles" url="http://foo.bar/particles.json" particlesLoaded={particlesLoaded} />
|
|
291
|
-
</ParticlesProvider>
|
|
292
|
-
);
|
|
293
|
-
};
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
##### TypeScript support - url
|
|
297
|
-
|
|
298
|
-
```tsx
|
|
299
|
-
import Particles, { ParticlesProvider } from "@tsparticles/react";
|
|
300
|
-
import type { Container, Engine } from "@tsparticles/engine";
|
|
301
|
-
// import { loadAll } from "@tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
|
|
302
|
-
// import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
|
|
303
|
-
import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
|
|
304
|
-
// import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
|
|
305
|
-
|
|
306
|
-
const particlesInit = async (engine: Engine): Promise<void> => {
|
|
307
|
-
await loadSlim(engine);
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
const App = () => {
|
|
311
|
-
const particlesLoaded = (container?: Container) => {
|
|
312
|
-
console.log(container);
|
|
313
|
-
};
|
|
314
|
-
|
|
315
|
-
return (
|
|
316
|
-
<ParticlesProvider init={particlesInit}>
|
|
317
|
-
<Particles id="tsparticles" url="http://foo.bar/particles.json" particlesLoaded={particlesLoaded} />
|
|
318
|
-
</ParticlesProvider>
|
|
319
|
-
);
|
|
320
|
-
};
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
### Props
|
|
324
|
-
|
|
325
|
-
| Prop | Type | Definition |
|
|
326
|
-
| --------- | ------ | ---------------------------------------------------- |
|
|
327
|
-
| id | string | The id of the element. |
|
|
328
|
-
| options | object | The options of the particles instance. |
|
|
329
|
-
| url | string | The remote options url, called using an AJAX request |
|
|
330
|
-
| style | object | The style of the canvas element. |
|
|
331
|
-
| className | string | The class name of the canvas wrapper. |
|
|
332
|
-
|
|
333
|
-
#### particles.json
|
|
334
|
-
|
|
335
|
-
Find all configuration
|
|
336
|
-
options [here](https://particles.js.org/docs/interfaces/tsParticles_Engine.Options_Interfaces_IOptions.IOptions.html).
|
|
337
|
-
|
|
338
|
-
You can find sample configurations [here](https://github.com/tsparticles/tsparticles/tree/main/utils/configs/src) 📖
|
|
339
|
-
|
|
340
|
-
## Demos
|
|
341
|
-
|
|
342
|
-
Preset demos can be found [here](https://particles.js.org/samples/presets/index.html)
|
|
343
|
-
|
|
344
|
-
There's also a CodePen collection actively maintained and updated [here](https://codepen.io/collection/DPOage)
|
|
345
|
-
|
|
346
|
-
Report bugs and issues [here](https://github.com/tsparticles/tsparticles/issues)
|
|
347
|
-
|
|
348
|
-
[tsParticle Website](https://particles.js.org)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|