@tsparticles/react 3.0.0 → 4.0.0-beta.12

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/README.md CHANGED
@@ -6,6 +6,8 @@
6
6
 
7
7
  Official [tsParticles](https://github.com/tsparticles/tsparticles) ReactJS component
8
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
+
9
11
  [![Slack](https://particles.js.org/images/slack.png)](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [![Discord](https://particles.js.org/images/discord.png)](https://discord.gg/hACwv45Hme) [![Telegram](https://particles.js.org/images/telegram.png)](https://t.me/tsparticles)
10
12
 
11
13
  [![tsParticles Product Hunt](https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=186113&theme=light)](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>
@@ -36,14 +38,14 @@ yarn add @tsparticles/react @tsparticles/engine
36
38
 
37
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`.
38
40
 
39
- ### create-react-app
41
+ ### React templates
40
42
 
41
- Starting from version 1.17.0 there are two official `create-react-app` templates:
43
+ Starting from version 1.17.0 there are two official React templates:
42
44
 
43
45
  - `cra-template-particles`: Simple ReactJS template with full screen particles, using JavaScript
44
46
  - `cra-template-particles-typescript`: Simple ReactJS template with full screen particles, using TypeScript
45
47
 
46
- You can simply install them using the `create-react-app` command like this:
48
+ You can install them using `create-react-app` like this:
47
49
 
48
50
  ```shell
49
51
  $ create-react-app your_app --template particles
@@ -59,6 +61,9 @@ $ create-react-app your_app --template particles-typescript
59
61
 
60
62
  ### Code
61
63
 
64
+ `ParticlesProvider` is required and receives one async `init` callback.
65
+ That callback is executed only once for the app lifecycle.
66
+
62
67
  Examples:
63
68
 
64
69
  #### Options object
@@ -66,225 +71,197 @@ Examples:
66
71
  ##### JavaScript support - object
67
72
 
68
73
  ```jsx
69
- import { useCallback, useEffect, useState } from "react";
70
- import Particles, { initParticlesEngine } from "@tsparticles/react";
71
- // import { loadAll } from "@/tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
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.
72
77
  // import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
73
78
  import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
74
79
  // import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
75
80
 
81
+ const particlesInit = async engine => {
82
+ await loadSlim(engine);
83
+ };
84
+
76
85
  const App = () => {
77
- const [ init, setInit ] = useState(false);
78
-
79
- // this should be run only once per application lifetime
80
- useEffect(() => {
81
- initParticlesEngine(async (engine) => {
82
- // you can initiate the tsParticles instance (engine) here, adding custom shapes or presets
83
- // this loads the tsparticles package bundle, it's the easiest method for getting everything ready
84
- // starting from v2 you can add only the features you need reducing the bundle size
85
- //await loadAll(engine);
86
- //await loadFull(engine);
87
- await loadSlim(engine);
88
- //await loadBasic(engine);
89
- }).then(() => {
90
- setInit(true);
91
- });
92
- }, []);
93
-
94
- const particlesLoaded = (container) => {
95
- console.log(container);
96
- };
97
-
98
- return (
99
- { init && <Particles
100
- id="tsparticles"
101
- particlesLoaded={particlesLoaded}
102
- options={{
103
- background: {
104
- color: {
105
- value: "#0d47a1",
106
- },
107
- },
108
- fpsLimit: 120,
109
- interactivity: {
110
- events: {
111
- onClick: {
112
- enable: true,
113
- mode: "push",
114
- },
115
- onHover: {
116
- enable: true,
117
- mode: "repulse",
118
- },
119
- resize: true,
120
- },
121
- modes: {
122
- push: {
123
- quantity: 4,
124
- },
125
- repulse: {
126
- distance: 200,
127
- duration: 0.4,
128
- },
129
- },
130
- },
131
- particles: {
132
- color: {
133
- value: "#ffffff",
134
- },
135
- links: {
136
- color: "#ffffff",
137
- distance: 150,
138
- enable: true,
139
- opacity: 0.5,
140
- width: 1,
141
- },
142
- move: {
143
- direction: "none",
144
- enable: true,
145
- outModes: {
146
- default: "bounce",
147
- },
148
- random: false,
149
- speed: 6,
150
- straight: false,
151
- },
152
- number: {
153
- density: {
154
- enable: true,
155
- area: 800,
156
- },
157
- value: 80,
158
- },
159
- opacity: {
160
- value: 0.5,
161
- },
162
- shape: {
163
- type: "circle",
164
- },
165
- size: {
166
- value: { min: 1, max: 5 },
167
- },
168
- },
169
- detectRetina: true,
170
- }}
171
- />
172
- }
173
- )
174
- ;
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
+ );
175
166
  };
176
167
  ```
177
168
 
178
169
  ##### TypeScript support - object
179
170
 
180
171
  ```tsx
181
- import { useCallback, useEffect, useState } from "react";
182
- import Particles, { initParticlesEngine } from "@tsparticles/react";
183
- import type { Container, Engine } from "@tsparticles/engine";
184
- // import { loadAll } from "@/tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
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.
185
176
  // import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
186
177
  import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
187
178
  // import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
188
179
 
180
+ const particlesInit = async (engine: Engine): Promise<void> => {
181
+ await loadSlim(engine);
182
+ };
183
+
189
184
  const App = () => {
190
- const [ init, setInit ] = useState(false);
191
-
192
- // this should be run only once per application lifetime
193
- useEffect(() => {
194
- initParticlesEngine(async (engine) => {
195
- // you can initiate the tsParticles instance (engine) here, adding custom shapes or presets
196
- // this loads the tsparticles package bundle, it's the easiest method for getting everything ready
197
- // starting from v2 you can add only the features you need reducing the bundle size
198
- //await loadAll(engine);
199
- //await loadFull(engine);
200
- await loadSlim(engine);
201
- //await loadBasic(engine);
202
- }).then(() => {
203
- setInit(true);
204
- });
205
- }, []);
206
-
207
- const particlesLoaded = (container) => {
208
- console.log(container);
209
- };
210
-
211
- return (
212
- { init && <Particles
213
- id="tsparticles"
214
- particlesLoaded={particlesLoaded}
215
- options={{
216
- background: {
217
- color: {
218
- value: "#0d47a1",
219
- },
220
- },
221
- fpsLimit: 120,
222
- interactivity: {
223
- events: {
224
- onClick: {
225
- enable: true,
226
- mode: "push",
227
- },
228
- onHover: {
229
- enable: true,
230
- mode: "repulse",
231
- },
232
- resize: true,
233
- },
234
- modes: {
235
- push: {
236
- quantity: 4,
237
- },
238
- repulse: {
239
- distance: 200,
240
- duration: 0.4,
241
- },
242
- },
243
- },
244
- particles: {
245
- color: {
246
- value: "#ffffff",
247
- },
248
- links: {
249
- color: "#ffffff",
250
- distance: 150,
251
- enable: true,
252
- opacity: 0.5,
253
- width: 1,
254
- },
255
- move: {
256
- direction: "none",
257
- enable: true,
258
- outModes: {
259
- default: "bounce",
260
- },
261
- random: false,
262
- speed: 6,
263
- straight: false,
264
- },
265
- number: {
266
- density: {
267
- enable: true,
268
- area: 800,
269
- },
270
- value: 80,
271
- },
272
- opacity: {
273
- value: 0.5,
274
- },
275
- shape: {
276
- type: "circle",
277
- },
278
- size: {
279
- value: { min: 1, max: 5 },
280
- },
281
- },
282
- detectRetina: true,
283
- }}
284
- />
285
- }
286
- )
287
- ;
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
+ );
288
265
  };
289
266
  ```
290
267
 
@@ -293,91 +270,61 @@ const App = () => {
293
270
  ##### JavaScript support - url
294
271
 
295
272
  ```jsx
296
- import { useCallback, useEffect, useState } from "react";
297
- import Particles, { initParticlesEngine } from "@tsparticles/react";
298
- // import { loadAll } from "@/tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
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.
299
275
  // import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
300
276
  import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
301
277
  // import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
302
278
 
279
+ const particlesInit = async engine => {
280
+ await loadSlim(engine);
281
+ };
282
+
303
283
  const App = () => {
304
- const [ init, setInit ] = useState(false);
305
-
306
- // this should be run only once per application lifetime
307
- useEffect(() => {
308
- initParticlesEngine(async (engine) => {
309
- // you can initiate the tsParticles instance (engine) here, adding custom shapes or presets
310
- // this loads the tsparticles package bundle, it's the easiest method for getting everything ready
311
- // starting from v2 you can add only the features you need reducing the bundle size
312
- //await loadAll(engine);
313
- //await loadFull(engine);
314
- await loadSlim(engine);
315
- //await loadBasic(engine);
316
- }).then(() => {
317
- setInit(true);
318
- });
319
- }, []);
320
-
321
- const particlesLoaded = (container) => {
322
- console.log(container);
323
- };
324
-
325
- return (
326
- { init && <Particles id="tsparticles" url="http://foo.bar/particles.json" particlesLoaded={particlesLoaded}/>
327
- }
328
- )
329
- ;
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
+ );
330
293
  };
331
294
  ```
332
295
 
333
296
  ##### TypeScript support - url
334
297
 
335
298
  ```tsx
336
- import { useCallback, useEffect, useState } from "react";
337
- import Particles, { initParticlesEngine } from "@tsparticles/react";
299
+ import Particles, { ParticlesProvider } from "@tsparticles/react";
338
300
  import type { Container, Engine } from "@tsparticles/engine";
339
- // import { loadAll } from "@/tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
301
+ // import { loadAll } from "@tsparticles/all"; // if you are going to use `loadAll`, install the "@tsparticles/all" package too.
340
302
  // import { loadFull } from "tsparticles"; // if you are going to use `loadFull`, install the "tsparticles" package too.
341
303
  import { loadSlim } from "@tsparticles/slim"; // if you are going to use `loadSlim`, install the "@tsparticles/slim" package too.
342
304
  // import { loadBasic } from "@tsparticles/basic"; // if you are going to use `loadBasic`, install the "@tsparticles/basic" package too.
343
305
 
306
+ const particlesInit = async (engine: Engine): Promise<void> => {
307
+ await loadSlim(engine);
308
+ };
309
+
344
310
  const App = () => {
345
- const [ init, setInit ] = useState(false);
346
-
347
- // this should be run only once per application lifetime
348
- useEffect(() => {
349
- initParticlesEngine(async (engine) => {
350
- // you can initiate the tsParticles instance (engine) here, adding custom shapes or presets
351
- // this loads the tsparticles package bundle, it's the easiest method for getting everything ready
352
- // starting from v2 you can add only the features you need reducing the bundle size
353
- //await loadAll(engine);
354
- //await loadFull(engine);
355
- await loadSlim(engine);
356
- //await loadBasic(engine);
357
- }).then(() => {
358
- setInit(true);
359
- });
360
- }, []);
361
-
362
- const particlesLoaded = (container) => {
363
- console.log(container);
364
- };
365
-
366
- return (
367
- { init && <Particles id="tsparticles" url="http://foo.bar/particles.json" particlesLoaded={particlesLoaded}/>
368
- }
369
- )
370
- ;
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
+ );
371
320
  };
372
321
  ```
373
322
 
374
323
  ### Props
375
324
 
376
325
  | Prop | Type | Definition |
377
- |-----------|--------|------------------------------------------------------|
326
+ | --------- | ------ | ---------------------------------------------------- |
378
327
  | id | string | The id of the element. |
379
- | width | string | The width of the canvas. |
380
- | height | string | The height of the canvas. |
381
328
  | options | object | The options of the particles instance. |
382
329
  | url | string | The remote options url, called using an AJAX request |
383
330
  | style | object | The style of the canvas element. |
@@ -1 +0,0 @@
1
-
package/dist/Particles.js CHANGED
@@ -1,18 +1,33 @@
1
- import { jsx as d } from "react/jsx-runtime";
2
- import { useEffect as m } from "react";
3
- import { tsParticles as s } from "@tsparticles/engine";
4
- const f = (t) => {
5
- const i = t.id ?? "tsparticles";
6
- return m(() => {
7
- let e;
8
- return s.load({ id: i, url: t.url, options: t.options }).then((l) => {
9
- var a;
10
- e = l, (a = t.particlesLoaded) == null || a.call(t, l);
11
- }), () => {
12
- e == null || e.destroy();
13
- };
14
- }, [i, t, t.url, t.options]), /* @__PURE__ */ d("div", { id: i, className: t.className });
15
- };
16
- export {
17
- f as default
1
+ import { useParticlesProvider as e } from "./ParticlesProvider.js";
2
+ import { useEffect as t } from "react";
3
+ import { tsParticles as n } from "@tsparticles/engine";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ //#region lib/Particles.tsx
6
+ var i = (i) => {
7
+ let { className: a, id: o, options: s, particlesLoaded: c, style: l, url: u } = i, { loaded: d } = e();
8
+ return t(() => {
9
+ if (!d) return;
10
+ let e;
11
+ return n.load({
12
+ id: o ?? "tsparticles",
13
+ url: u,
14
+ options: s
15
+ }).then((t) => {
16
+ e = t, c?.(t);
17
+ }), () => {
18
+ e?.destroy();
19
+ };
20
+ }, [
21
+ o,
22
+ d,
23
+ s,
24
+ c,
25
+ u
26
+ ]), /* @__PURE__ */ r("div", {
27
+ id: o ?? "tsparticles",
28
+ className: a,
29
+ style: l
30
+ });
18
31
  };
32
+ //#endregion
33
+ export { i as default };
@@ -0,0 +1,35 @@
1
+ import { createContext as e, useContext as t, useEffect as n, useMemo as r, useState as i } from "react";
2
+ import { tsParticles as a } from "@tsparticles/engine";
3
+ import { jsx as o } from "react/jsx-runtime";
4
+ //#region lib/ParticlesProvider.tsx
5
+ var s = !1, c, l, u = e({ loaded: !1 }), d = ({ children: e, init: t }) => {
6
+ let [d, f] = i(s);
7
+ n(() => {
8
+ let e = !1;
9
+ if (!s) {
10
+ if (!c) l = t, c = (async () => {
11
+ await t(a), s = !0;
12
+ })().catch((e) => {
13
+ throw c = void 0, l = void 0, e;
14
+ });
15
+ else if (l && l !== t) throw Error("ParticlesProvider init callback must be stable across the app lifecycle.");
16
+ return c.then(() => {
17
+ e || f(!0);
18
+ }).catch(() => {
19
+ e || f(!1);
20
+ }), () => {
21
+ e = !0;
22
+ };
23
+ }
24
+ }, [t]);
25
+ let p = r(() => ({ loaded: d }), [d]);
26
+ return /* @__PURE__ */ o(u.Provider, {
27
+ value: p,
28
+ children: d ? e : null
29
+ });
30
+ };
31
+ function f() {
32
+ return t(u);
33
+ }
34
+ //#endregion
35
+ export { d as ParticlesProvider, f as useParticlesProvider };
package/dist/index.js CHANGED
@@ -1,12 +1,6 @@
1
- import { tsParticles as i } from "@tsparticles/engine";
2
- import o from "./Particles.js";
3
- import "react/jsx-runtime";
4
- import "react";
5
- async function n(t) {
6
- await t(i);
7
- }
8
- export {
9
- o as Particles,
10
- o as default,
11
- n as initParticlesEngine
12
- };
1
+ import { ParticlesProvider as e, useParticlesProvider as t } from "./ParticlesProvider.js";
2
+ import n from "./Particles.js";
3
+ //#region lib/index.ts
4
+ var r = n;
5
+ //#endregion
6
+ export { n as Particles, e as ParticlesProvider, r as default, t as useParticlesProvider };
@@ -0,0 +1,10 @@
1
+ import { Container, ISourceOptions } from '@tsparticles/engine';
2
+ import { CSSProperties } from 'react';
3
+ export interface IParticlesProps {
4
+ id?: string;
5
+ options?: ISourceOptions;
6
+ url?: string;
7
+ style?: CSSProperties;
8
+ className?: string;
9
+ particlesLoaded?: (container?: Container) => Promise<void> | void;
10
+ }
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { IParticlesProps } from './IParticlesProps';
3
+ declare const Particles: FC<IParticlesProps>;
4
+ export default Particles;
@@ -0,0 +1,12 @@
1
+ import { Engine } from '@tsparticles/engine';
2
+ import { FC, PropsWithChildren } from 'react';
3
+ export type ParticlesPluginRegistrar = (engine: Engine) => Promise<void>;
4
+ export interface IParticlesProviderProps extends PropsWithChildren {
5
+ init: ParticlesPluginRegistrar;
6
+ }
7
+ interface IParticlesProviderContext {
8
+ loaded: boolean;
9
+ }
10
+ export declare const ParticlesProvider: FC<IParticlesProviderProps>;
11
+ export declare function useParticlesProvider(): IParticlesProviderContext;
12
+ export {};
@@ -0,0 +1,5 @@
1
+ import { default as Particles } from './Particles.js';
2
+ export type { IParticlesProps } from './IParticlesProps.js';
3
+ export default Particles;
4
+ export { Particles };
5
+ export { type IParticlesProviderProps, type ParticlesPluginRegistrar, ParticlesProvider, useParticlesProvider, } from './ParticlesProvider.js';
package/package.json CHANGED
@@ -1,45 +1,54 @@
1
1
  {
2
2
  "name": "@tsparticles/react",
3
- "version": "3.0.0",
3
+ "version": "4.0.0-beta.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
6
+ "types": "dist/lib/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/lib/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
7
13
  "scripts": {
8
14
  "dev": "vite",
9
- "build": "tsc && vite build",
10
- "build:ci": "tsc && vite build",
11
- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
15
+ "build": "prettier --write README.md && pnpm run prettify && tsc && vite build",
16
+ "build:ci": "prettier --check README.md && pnpm run prettify:ci && tsc && vite build",
17
+ "lint": "eslint . --max-warnings 0",
12
18
  "preview": "vite preview",
19
+ "prettify": "prettier --write \"src/**/*.{ts,tsx}\" && prettier --write \"lib/**/*.{ts,tsx}\"",
20
+ "prettify:ci": "prettier --check \"src/**/*.{ts,tsx}\" && prettier --check \"lib/**/*.{ts,tsx}\"",
13
21
  "prepublishOnly": "pnpm run build"
14
22
  },
15
23
  "files": [
16
24
  "dist"
17
25
  ],
26
+ "license": "MIT",
18
27
  "peerDependencies": {
19
- "@tsparticles/engine": "^3.0.2",
28
+ "@tsparticles/engine": ">=4.0.0-alpha.0",
20
29
  "react": ">=16.8.0",
21
30
  "react-dom": ">=16.8.0"
22
31
  },
23
32
  "devDependencies": {
24
- "@tsparticles/engine": "^3.0.2",
25
- "@types/react": "^18.2.42",
26
- "@types/react-dom": "^18.2.17",
27
- "@typescript-eslint/eslint-plugin": "^6.13.2",
28
- "@typescript-eslint/parser": "^6.13.2",
29
- "@vitejs/plugin-react": "^4.2.1",
30
- "eslint": "^8.55.0",
31
- "eslint-plugin-react-hooks": "^4.6.0",
32
- "eslint-plugin-react-refresh": "^0.4.5",
33
- "glob": "^10.3.10",
34
- "react": "^18.2.0",
35
- "react-dom": "^18.2.0",
36
- "typescript": "^5.3.3",
37
- "vite": "^5.0.6",
38
- "vite-plugin-dts": "^3.6.4",
39
- "vite-plugin-lib-inject-css": "^1.3.0"
33
+ "@tsparticles/engine": "4.0.0-beta.12",
34
+ "@types/react": "^19.2.14",
35
+ "@types/react-dom": "^19.2.3",
36
+ "@typescript-eslint/eslint-plugin": "^8.58.1",
37
+ "@typescript-eslint/parser": "^8.58.1",
38
+ "@vitejs/plugin-react": "^6.0.1",
39
+ "eslint": "^10.2.0",
40
+ "eslint-plugin-react-hooks": "^7.0.1",
41
+ "eslint-plugin-react-refresh": "^0.5.2",
42
+ "glob": "^13.0.6",
43
+ "react": "^19.2.5",
44
+ "react-dom": "^19.2.5",
45
+ "typescript": "^6.0.2",
46
+ "vite": "^8.0.8",
47
+ "vite-plugin-dts": "^4.5.4",
48
+ "vite-plugin-lib-inject-css": "^2.2.2"
40
49
  },
41
50
  "publishConfig": {
42
51
  "access": "public"
43
52
  },
44
- "gitHead": "06ad7ff6a21833bb7c62c443b2cfb6bbcba58273"
53
+ "gitHead": "bdbc95716ce44665fbecfaca8757445e248b562d"
45
54
  }
@@ -1,10 +0,0 @@
1
- import type { Container, ISourceOptions } from "@tsparticles/engine";
2
- import type { CSSProperties } from "react";
3
- export interface IParticlesProps {
4
- id?: string;
5
- options?: ISourceOptions;
6
- url?: string;
7
- style?: CSSProperties;
8
- className?: string;
9
- particlesLoaded?: (container?: Container) => Promise<void>;
10
- }
@@ -1,4 +0,0 @@
1
- import { FC } from "react";
2
- import type { IParticlesProps } from "./IParticlesProps";
3
- declare const Particles: FC<IParticlesProps>;
4
- export default Particles;
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { Engine } from "@tsparticles/engine";
2
- import Particles from "./Particles";
3
- export type { IParticlesProps, } from "./IParticlesProps";
4
- export declare function initParticlesEngine(cb: (engine: Engine) => Promise<void>): Promise<void>;
5
- export default Particles;
6
- export { Particles };