Skip to content

Commit 90234ac

Browse files
committed
build: updated deps and template generation
1 parent bcc6701 commit 90234ac

File tree

8 files changed

+139
-129
lines changed

8 files changed

+139
-129
lines changed

files/create-plugin/src/index.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,10 @@
1-
import type { Container, Engine, IPlugin, ISourceOptions, Options } from "@tsparticles/engine";
2-
import { PluginInstance } from "./PluginInstance";
3-
4-
/**
5-
*/
6-
class Plugin implements IPlugin {
7-
readonly id;
8-
9-
private readonly _engine;
10-
11-
constructor(engine: Engine) {
12-
this.id = "#template#";
13-
14-
this._engine = engine;
15-
}
16-
17-
getPlugin(container: Container): PluginInstance {
18-
return new PluginInstance(container, this._engine);
19-
}
20-
21-
loadOptions(_options: Options, _source?: ISourceOptions): void {
22-
if (!this.needsPlugin()) {
23-
// ignore plugin options when not needed
24-
25-
return;
26-
}
27-
28-
// Load your options here
29-
}
30-
31-
needsPlugin(_options?: ISourceOptions): boolean {
32-
return true; // add your condition here, replace true with condition if needed
33-
}
34-
}
1+
import type { Engine } from "@tsparticles/engine";
352

363
/**
374
* @param engine - The engine instance
385
*/
396
export async function loadTemplatePlugin(engine: Engine): Promise<void> {
7+
const { Plugin } = await import("./plugin.js");
8+
409
await engine.addPlugin(new Plugin(engine));
4110
}

files/create-plugin/src/plugin.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { type Container, type Engine, type IPlugin, type ISourceOptions, type Options } from "@tsparticles/engine";
2+
import type { PluginInstance } from "./PluginInstance.js";
3+
4+
/**
5+
*/
6+
export class Plugin implements IPlugin {
7+
readonly id;
8+
9+
private readonly _engine;
10+
11+
constructor(engine: Engine) {
12+
this.id = "#template#";
13+
14+
this._engine = engine;
15+
}
16+
17+
async getPlugin(container: Container): Promise<PluginInstance> {
18+
const { PluginInstance } = await import("./PluginInstance.js");
19+
20+
return new PluginInstance(container, this._engine);
21+
}
22+
23+
loadOptions(_options: Options, _source?: ISourceOptions): void {
24+
if (!this.needsPlugin()) {
25+
// ignore plugin options when not needed
26+
27+
return;
28+
}
29+
30+
// Load your options here
31+
}
32+
33+
needsPlugin(_options?: ISourceOptions): boolean {
34+
return true; // add your condition here, replace true with condition if needed
35+
}
36+
}

files/create-preset/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { Engine } from "@tsparticles/engine";
2-
import { options } from "./options";
32

43
/**
54
*
65
* @param engine - the engine instance to load the preset into
76
*/
87
export async function loadTemplatePreset(engine: Engine): Promise<void> {
8+
const { options } = await import("./options");
9+
910
// TODO: additional modules must be loaded here
1011

1112
// Adds the preset to the engine, with the given options
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { IShapeDrawData, IShapeDrawer } from "@tsparticles/engine";
22

33
export class ShapeDrawer implements IShapeDrawer {
4-
draw(_data: IShapeDrawData): void {
4+
async draw(_data: IShapeDrawData): Promise<void> {
55
// draw the particle using the context
66
// which is already centered in the particle position
77
// colors are already handled, just draw the shape
@@ -10,5 +10,8 @@ export class ShapeDrawer implements IShapeDrawer {
1010
// pixelRatio is the canvas ratio used by the tsParticles instance, you may need it for density-independent shapes
1111
// the parameters have an underscore prefix because they're not used in this example
1212
// the underscore prefix can be removed for used parameters, the unused ones can be removed too
13+
14+
// remove this if there's already an await call
15+
await Promise.resolve();
1316
}
1417
}

files/create-shape/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import type { Engine } from "@tsparticles/engine";
2-
import { ShapeDrawer } from "./ShapeDrawer";
32

43
/**
54
* @param engine - the engine instance to load the shape into
65
*/
76
export async function loadTemplateShape(engine: Engine): Promise<void> {
7+
const { ShapeDrawer } = await import("./ShapeDrawer");
8+
89
await engine.addShape("#template#", new ShapeDrawer());
910
}

files/empty-project/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@
8484
"devDependencies": {
8585
"@babel/core": "^7.23.9",
8686
"@tsparticles/cli": "^2.0.5",
87-
"@tsparticles/eslint-config": "^2.1.0",
87+
"@tsparticles/eslint-config": "^2.1.4",
8888
"@tsparticles/prettier-config": "^2.1.0",
8989
"@tsparticles/tsconfig": "^2.0.1",
90-
"@tsparticles/webpack-plugin": "^2.1.0",
90+
"@tsparticles/webpack-plugin": "^2.1.4",
9191
"@types/webpack-env": "^1.18.4",
92-
"@typescript-eslint/eslint-plugin": "^6.19.1",
93-
"@typescript-eslint/parser": "^6.19.1",
92+
"@typescript-eslint/eslint-plugin": "^6.20.0",
93+
"@typescript-eslint/parser": "^6.20.0",
9494
"babel-loader": "^9.1.3",
9595
"browserslist": "^4.22.3",
9696
"copyfiles": "^2.4.1",
@@ -105,6 +105,6 @@
105105
"webpack-cli": "^5.1.4"
106106
},
107107
"dependencies": {
108-
"@tsparticles/engine": "^3.0.3"
108+
"@tsparticles/engine": "^3.2.0"
109109
}
110110
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@
2828
"version": "node scripts/postversion.js && git add files/empty-project/package.json"
2929
},
3030
"dependencies": {
31-
"@tsparticles/eslint-config": "^2.1.0",
31+
"@tsparticles/eslint-config": "^2.1.4",
3232
"@tsparticles/prettier-config": "^2.1.0",
3333
"@tsparticles/tsconfig": "^2.0.1",
34-
"@tsparticles/webpack-plugin": "^2.1.0",
35-
"@typescript-eslint/eslint-plugin": "^6.19.1",
36-
"@typescript-eslint/parser": "^6.19.1",
34+
"@tsparticles/webpack-plugin": "^2.1.4",
35+
"@typescript-eslint/eslint-plugin": "^6.20.0",
36+
"@typescript-eslint/parser": "^6.20.0",
3737
"commander": "^11.1.0",
3838
"eslint": "^8.56.0",
3939
"eslint-config-prettier": "^9.1.0",
@@ -55,7 +55,7 @@
5555
"@types/fs-extra": "^11.0.4",
5656
"@types/klaw": "^3.0.6",
5757
"@types/mocha": "^10.0.6",
58-
"@types/node": "^20.11.9",
58+
"@types/node": "^20.11.13",
5959
"@types/prompts": "^2.4.9",
6060
"chai": "^4.4.0",
6161
"cross-env": "^7.0.3",

0 commit comments

Comments
 (0)