@tsparticles/cli 2.0.5 → 2.1.0
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/.github/workflows/node.js-ci.yml +2 -2
- package/files/create-plugin/src/index.ts +3 -34
- package/files/create-plugin/src/plugin.ts +36 -0
- package/files/create-preset/src/index.ts +2 -1
- package/files/create-shape/src/ShapeDrawer.ts +4 -1
- package/files/create-shape/src/index.ts +2 -1
- package/files/empty-project/package.json +6 -6
- package/package.json +6 -6
|
@@ -35,7 +35,7 @@ jobs:
|
|
|
35
35
|
run: |
|
|
36
36
|
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
|
37
37
|
|
|
38
|
-
- uses: actions/cache@
|
|
38
|
+
- uses: actions/cache@v4
|
|
39
39
|
name: Setup pnpm cache
|
|
40
40
|
with:
|
|
41
41
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
@@ -73,7 +73,7 @@ jobs:
|
|
|
73
73
|
run: |
|
|
74
74
|
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
|
|
75
75
|
|
|
76
|
-
- uses: actions/cache@
|
|
76
|
+
- uses: actions/cache@v4
|
|
77
77
|
name: Setup pnpm cache
|
|
78
78
|
with:
|
|
79
79
|
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
|
|
@@ -1,41 +1,10 @@
|
|
|
1
|
-
import type {
|
|
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";
|
|
35
2
|
|
|
36
3
|
/**
|
|
37
4
|
* @param engine - The engine instance
|
|
38
5
|
*/
|
|
39
6
|
export async function loadTemplatePlugin(engine: Engine): Promise<void> {
|
|
7
|
+
const { Plugin } = await import("./plugin.js");
|
|
8
|
+
|
|
40
9
|
await engine.addPlugin(new Plugin(engine));
|
|
41
10
|
}
|
|
@@ -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
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
import { options } from "./options";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
6
5
|
* @param engine - the engine instance to load the preset into
|
|
7
6
|
*/
|
|
8
7
|
export async function loadTemplatePreset(engine: Engine): Promise<void> {
|
|
8
|
+
const { options } = await import("./options");
|
|
9
|
+
|
|
9
10
|
// TODO: additional modules must be loaded here
|
|
10
11
|
|
|
11
12
|
// Adds the preset to the engine, with the given options
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IShapeDrawData, IShapeDrawer } from "@tsparticles/engine";
|
|
2
2
|
|
|
3
3
|
export class ShapeDrawer implements IShapeDrawer {
|
|
4
|
-
draw(_data: IShapeDrawData): void {
|
|
4
|
+
async draw(_data: IShapeDrawData): Promise<void> {
|
|
5
5
|
// draw the particle using the context
|
|
6
6
|
// which is already centered in the particle position
|
|
7
7
|
// colors are already handled, just draw the shape
|
|
@@ -10,5 +10,8 @@ export class ShapeDrawer implements IShapeDrawer {
|
|
|
10
10
|
// pixelRatio is the canvas ratio used by the tsParticles instance, you may need it for density-independent shapes
|
|
11
11
|
// the parameters have an underscore prefix because they're not used in this example
|
|
12
12
|
// 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();
|
|
13
16
|
}
|
|
14
17
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { Engine } from "@tsparticles/engine";
|
|
2
|
-
import { ShapeDrawer } from "./ShapeDrawer";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* @param engine - the engine instance to load the shape into
|
|
6
5
|
*/
|
|
7
6
|
export async function loadTemplateShape(engine: Engine): Promise<void> {
|
|
7
|
+
const { ShapeDrawer } = await import("./ShapeDrawer");
|
|
8
|
+
|
|
8
9
|
await engine.addShape("#template#", new ShapeDrawer());
|
|
9
10
|
}
|
|
@@ -83,14 +83,14 @@
|
|
|
83
83
|
"prettier": "@tsparticles/prettier-config",
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@babel/core": "^7.23.9",
|
|
86
|
-
"@tsparticles/cli": "^2.0
|
|
87
|
-
"@tsparticles/eslint-config": "^2.1.
|
|
86
|
+
"@tsparticles/cli": "^2.1.0",
|
|
87
|
+
"@tsparticles/eslint-config": "^2.1.4",
|
|
88
88
|
"@tsparticles/prettier-config": "^2.1.0",
|
|
89
89
|
"@tsparticles/tsconfig": "^2.0.1",
|
|
90
|
-
"@tsparticles/webpack-plugin": "^2.1.
|
|
90
|
+
"@tsparticles/webpack-plugin": "^2.1.4",
|
|
91
91
|
"@types/webpack-env": "^1.18.4",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
93
|
-
"@typescript-eslint/parser": "^6.
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
93
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
94
94
|
"babel-loader": "^9.1.3",
|
|
95
95
|
"browserslist": "^4.22.3",
|
|
96
96
|
"copyfiles": "^2.4.1",
|
|
@@ -105,6 +105,6 @@
|
|
|
105
105
|
"webpack-cli": "^5.1.4"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@tsparticles/engine": "^3.0
|
|
108
|
+
"@tsparticles/engine": "^3.2.0"
|
|
109
109
|
}
|
|
110
110
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsparticles-cli": "dist/cli.js"
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
},
|
|
11
11
|
"prettier": "@tsparticles/prettier-config",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@tsparticles/eslint-config": "^2.1.
|
|
13
|
+
"@tsparticles/eslint-config": "^2.1.4",
|
|
14
14
|
"@tsparticles/prettier-config": "^2.1.0",
|
|
15
15
|
"@tsparticles/tsconfig": "^2.0.1",
|
|
16
|
-
"@tsparticles/webpack-plugin": "^2.1.
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
18
|
-
"@typescript-eslint/parser": "^6.
|
|
16
|
+
"@tsparticles/webpack-plugin": "^2.1.4",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
|
18
|
+
"@typescript-eslint/parser": "^6.20.0",
|
|
19
19
|
"commander": "^11.1.0",
|
|
20
20
|
"eslint": "^8.56.0",
|
|
21
21
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/fs-extra": "^11.0.4",
|
|
38
38
|
"@types/klaw": "^3.0.6",
|
|
39
39
|
"@types/mocha": "^10.0.6",
|
|
40
|
-
"@types/node": "^20.11.
|
|
40
|
+
"@types/node": "^20.11.13",
|
|
41
41
|
"@types/prompts": "^2.4.9",
|
|
42
42
|
"chai": "^4.4.0",
|
|
43
43
|
"cross-env": "^7.0.3",
|