Skip to content

Commit 2fe98a8

Browse files
authored
Merge pull request #18 from tsparticles/dev
v2.0.0
2 parents 8820f9e + f4e87e6 commit 2fe98a8

33 files changed

+505
-949
lines changed

.github/workflows/node.js-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-pnpm-store-
4545
- run: pnpm install --no-frozen-lockfile
46-
- run: npx pnpm run build:ci
47-
- run: npx pnpm test
46+
- run: pnpm run build:ci
47+
- run: pnpm test
4848
pr:
4949
runs-on: ubuntu-latest
5050
if: ${{ github.event_name == 'pull_request' }}
@@ -81,5 +81,5 @@ jobs:
8181
restore-keys: |
8282
${{ runner.os }}-pnpm-store-
8383
- run: pnpm install --no-frozen-lockfile
84-
- run: npx pnpm run build:ci
85-
- run: npx pnpm test
84+
- run: pnpm run build:ci
85+
- run: pnpm test

files/create-plugin/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ $ yarn add tsparticles-plugin-template
5454
Then you need to import it in the app, like this:
5555

5656
```javascript
57-
const { tsParticles } = require("tsparticles-engine");
57+
const { tsParticles } = require("@tsparticles/engine");
5858
const { loadTemplatePlugin } = require("tsparticles-plugin-template");
5959

6060
(async () => {
@@ -65,7 +65,7 @@ const { loadTemplatePlugin } = require("tsparticles-plugin-template");
6565
or
6666

6767
```javascript
68-
import { tsParticles } from "tsparticles-engine";
68+
import { tsParticles } from "@tsparticles/engine";
6969
import { loadTemplatePlugin } from "tsparticles-plugin-template";
7070

7171
(async () => {

files/create-plugin/src/PluginInstance.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type Container, type Engine, type IContainerPlugin } from "tsparticles-engine";
1+
import { type Container, type Engine, type IContainerPlugin } from "@tsparticles/engine";
22

33
export class PluginInstance implements IContainerPlugin {
44
private readonly _container;
@@ -10,6 +10,7 @@ export class PluginInstance implements IContainerPlugin {
1010
}
1111

1212
async init(): Promise<void> {
13-
// add your plugin initialization here
13+
// add your plugin initialization here, replace the empty promise
14+
return await Promise.resolve();
1415
}
1516
}

files/create-plugin/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Container, Engine, IPlugin, ISourceOptions, Options } from "tsparticles-engine";
1+
import type { Container, Engine, IPlugin, ISourceOptions, Options } from "@tsparticles/engine";
22
import { PluginInstance } from "./PluginInstance";
33

44
/**
@@ -20,14 +20,16 @@ class Plugin implements IPlugin {
2020

2121
loadOptions(_options: Options, _source?: ISourceOptions): void {
2222
if (!this.needsPlugin()) {
23+
// ignore plugin options when not needed
24+
2325
return;
2426
}
2527

2628
// Load your options here
2729
}
2830

2931
needsPlugin(_options?: ISourceOptions): boolean {
30-
return true; // add your condition here
32+
return true; // add your condition here, replace true with condition if needed
3133
}
3234
}
3335

files/create-preset/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Once installed you need one more script to be included in your page (or you can
2121
from [jsDelivr](https://www.jsdelivr.com/package/npm/tsparticles-preset-template):
2222

2323
```html
24-
<script src="https://cdn.jsdelivr.net/npm/tsparticles-engine@2/tsparticles.engine.min.js"></script>
24+
<script src="https://cdn.jsdelivr.net/npm/@tsparticles/engine@2/tsparticles.engine.min.js"></script>
2525
<script src="https://cdn.jsdelivr.net/npm/tsparticles-preset-template/tsparticles.preset.template.min.js"></script>
2626
```
2727

@@ -75,7 +75,7 @@ This sample uses the class component syntax, but you can use hooks as well (if t
7575

7676
```javascript
7777
import Particles from "react-particles";
78-
import { Engine } from "tsparticles-engine";
78+
import { Engine } from "@tsparticles/engine";
7979
import { loadTemplatePreset } from "tsparticles-preset-template";
8080

8181
export class ParticlesContainer extends React.PureComponent<IProps> {

files/create-preset/src/bundle.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { loadTemplatePreset } from ".";
2-
import { tsParticles } from "tsparticles-engine";
1+
import { loadTemplatePreset } from "./index.js";
2+
import { tsParticles } from "@tsparticles/engine";
33

4-
loadTemplatePreset(tsParticles);
4+
void loadTemplatePreset(tsParticles);
55

66
export { loadTemplatePreset, tsParticles };

files/create-preset/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { Engine } from "tsparticles-engine";
1+
import type { Engine } from "@tsparticles/engine";
22
import { options } from "./options";
33

44
/**
55
*
66
* @param engine - the engine instance to load the preset into
77
*/
8-
export function loadTemplatePreset(engine: Engine): void {
8+
export async function loadTemplatePreset(engine: Engine): Promise<void> {
99
// TODO: additional modules must be loaded here
1010

1111
// Adds the preset to the engine, with the given options
12-
engine.addPreset("#template#", options);
12+
await engine.addPreset("#template#", options);
1313
}

files/create-preset/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ISourceOptions } from "tsparticles-engine";
1+
import type { ISourceOptions } from "@tsparticles/engine";
22

33
// The options used by the preset
44
export const options: ISourceOptions = {

files/create-shape/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ $ yarn add tsparticles-shape-template
5555
Then you need to import it in the app, like this:
5656

5757
```javascript
58-
const { tsParticles } = require("tsparticles-engine");
58+
const { tsParticles } = require("@tsparticles/engine");
5959
const { loadTemplateShape } = require("tsparticles-shape-template");
6060

6161
(async () => {
@@ -66,7 +66,7 @@ const { loadTemplateShape } = require("tsparticles-shape-template");
6666
or
6767

6868
```javascript
69-
import { tsParticles } from "tsparticles-engine";
69+
import { tsParticles } from "@tsparticles/engine";
7070
import { loadTemplateShape } from "tsparticles-shape-template";
7171

7272
(async () => {

files/create-shape/src/ShapeDrawer.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import type { IDelta, IShapeDrawer, Particle } from "tsparticles-engine";
1+
import type { IShapeDrawData, IShapeDrawer } from "@tsparticles/engine";
22

33
export class ShapeDrawer implements IShapeDrawer {
4-
draw(_context: CanvasRenderingContext2D,
5-
_particle: Particle,
6-
_radius: number,
7-
_opacity: number,
8-
_delta: IDelta,
9-
_pixelRatio: number): void {
4+
draw(_data: IShapeDrawData): void {
105
// draw the particle using the context
116
// which is already centered in the particle position
12-
// colors are already handles, just draw the shape
7+
// colors are already handled, just draw the shape
138
// the bounds are -radius to radius
149
// delta is the frame time difference between the last frame and this one, in ms, use it for animated shapes
1510
// pixelRatio is the canvas ratio used by the tsParticles instance, you may need it for density-independent shapes

0 commit comments

Comments
 (0)