@tsparticles/cli-command-create 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/.cache/eslint/.eslintcache +1 -0
- package/.dependency-cruiser.cjs +382 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/dist/create.d.ts +3 -0
- package/dist/create.js +10 -0
- package/dist/plugin/create-plugin.d.ts +8 -0
- package/dist/plugin/create-plugin.js +136 -0
- package/dist/plugin/plugin.d.ts +3 -0
- package/dist/plugin/plugin.js +34 -0
- package/dist/preset/create-preset.d.ts +8 -0
- package/dist/preset/create-preset.js +154 -0
- package/dist/preset/preset.d.ts +3 -0
- package/dist/preset/preset.js +34 -0
- package/dist/shape/create-shape.d.ts +8 -0
- package/dist/shape/create-shape.js +137 -0
- package/dist/shape/shape.d.ts +3 -0
- package/dist/shape/shape.js +34 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/eslint.config.js +22 -0
- package/files/create-plugin/README.md +74 -0
- package/files/create-plugin/src/PluginInstance.ts +18 -0
- package/files/create-plugin/src/browser.ts +10 -0
- package/files/create-plugin/src/index.lazy.ts +10 -0
- package/files/create-plugin/src/index.ts +9 -0
- package/files/create-plugin/src/plugin.ts +36 -0
- package/files/create-preset/README.md +144 -0
- package/files/create-preset/images/sample.png +0 -0
- package/files/create-preset/src/browser.ts +10 -0
- package/files/create-preset/src/bundle.ts +17 -0
- package/files/create-preset/src/index.lazy.ts +14 -0
- package/files/create-preset/src/index.ts +13 -0
- package/files/create-preset/src/options.ts +6 -0
- package/files/create-shape/README.md +75 -0
- package/files/create-shape/src/ShapeDrawer.ts +16 -0
- package/files/create-shape/src/browser.ts +10 -0
- package/files/create-shape/src/index.lazy.ts +10 -0
- package/files/create-shape/src/index.ts +9 -0
- package/package.json +81 -0
- package/renovate.json +9 -0
- package/src/create.ts +14 -0
- package/src/plugin/create-plugin.ts +198 -0
- package/src/plugin/plugin.ts +46 -0
- package/src/preset/create-preset.ts +218 -0
- package/src/preset/preset.ts +46 -0
- package/src/shape/create-shape.ts +200 -0
- package/src/shape/shape.ts +46 -0
- package/src/tsconfig.json +9 -0
- package/tests/create-plugin.test.ts +40 -0
- package/tests/create-preset.test.ts +40 -0
- package/tests/create-shape.test.ts +40 -0
- package/tests/tsconfig.json +15 -0
- package/tsconfig.json +53 -0
- package/vitest.config.ts +11 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[](https://particles.js.org)
|
|
2
|
+
|
|
3
|
+
# tsParticles Template Plugin
|
|
4
|
+
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/tsparticles-plugin-template)
|
|
6
|
+
[](https://www.npmjs.com/package/tsparticles-plugin-template)
|
|
7
|
+
[](https://www.npmjs.com/package/tsparticles-plugin-template) [](https://github.com/sponsors/matteobruni)
|
|
8
|
+
|
|
9
|
+
[tsParticles](https://github.com/matteobruni/tsparticles) plugin for particles template.
|
|
10
|
+
|
|
11
|
+
## How to use it
|
|
12
|
+
|
|
13
|
+
### CDN / Vanilla JS / jQuery
|
|
14
|
+
|
|
15
|
+
The CDN/Vanilla version JS has one required file in vanilla configuration:
|
|
16
|
+
|
|
17
|
+
Including the `tsparticles.plugin.template.min.js` file will export the function to load the plugin:
|
|
18
|
+
|
|
19
|
+
```javascript
|
|
20
|
+
loadTemplatePlugin;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Usage
|
|
24
|
+
|
|
25
|
+
Once the scripts are loaded you can set up `tsParticles` and the plugin like this:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
(async () => {
|
|
29
|
+
await loadTemplatePlugin(tsParticles);
|
|
30
|
+
|
|
31
|
+
await tsParticles.load({
|
|
32
|
+
id: "tsparticles",
|
|
33
|
+
options: {
|
|
34
|
+
/* options */
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
})();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### ESM / CommonJS
|
|
41
|
+
|
|
42
|
+
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
43
|
+
|
|
44
|
+
```shell
|
|
45
|
+
$ npm install tsparticles-plugin-template
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
or
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
$ yarn add tsparticles-plugin-template
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then you need to import it in the app, like this:
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
58
|
+
const { loadTemplatePlugin } = require("tsparticles-plugin-template");
|
|
59
|
+
|
|
60
|
+
(async () => {
|
|
61
|
+
await loadTemplatePlugin(tsParticles);
|
|
62
|
+
})();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
or
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
69
|
+
import { loadTemplatePlugin } from "tsparticles-plugin-template";
|
|
70
|
+
|
|
71
|
+
(async () => {
|
|
72
|
+
await loadTemplatePlugin(tsParticles);
|
|
73
|
+
})();
|
|
74
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { /*type Container, type Engine,*/ type IContainerPlugin } from "@tsparticles/engine";
|
|
2
|
+
|
|
3
|
+
export class PluginInstance implements IContainerPlugin {
|
|
4
|
+
/*
|
|
5
|
+
private readonly _container;
|
|
6
|
+
private readonly _engine;
|
|
7
|
+
|
|
8
|
+
constructor(container: Container, engine: Engine) {
|
|
9
|
+
/*this._container = container;
|
|
10
|
+
this._engine = engine;
|
|
11
|
+
}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
async init(): Promise<void> {
|
|
15
|
+
// add your plugin initialization here, replace the empty promise
|
|
16
|
+
return await Promise.resolve();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { loadTemplatePlugin } from "./index.js";
|
|
2
|
+
|
|
3
|
+
const globalObject = globalThis as typeof globalThis & {
|
|
4
|
+
__tsParticlesInternals?: Record<string, unknown>;
|
|
5
|
+
loadTemplatePlugin?: typeof loadTemplatePlugin;
|
|
6
|
+
};
|
|
7
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
8
|
+
globalObject.loadTemplatePlugin = loadTemplatePlugin;
|
|
9
|
+
|
|
10
|
+
export * from "./index.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param engine - The engine instance
|
|
5
|
+
*/
|
|
6
|
+
export async function loadTemplatePlugin(engine: Engine): Promise<void> {
|
|
7
|
+
const { Plugin } = await import("./plugin.js");
|
|
8
|
+
|
|
9
|
+
await engine.addPlugin(new Plugin(/*engine*/));
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
import { Plugin } from "./plugin.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param engine - The engine instance
|
|
6
|
+
*/
|
|
7
|
+
export async function loadTemplatePlugin(engine: Engine): Promise<void> {
|
|
8
|
+
await engine.addPlugin(new Plugin(/*engine*/));
|
|
9
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
[](https://particles.js.org)
|
|
2
|
+
|
|
3
|
+
# tsParticles Template Preset
|
|
4
|
+
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/tsparticles-preset-template) [](https://www.npmjs.com/package/tsparticles-preset-template) [](https://www.npmjs.com/package/tsparticles-preset-template)
|
|
6
|
+
|
|
7
|
+
[tsParticles](https://github.com/matteobruni/tsparticles) preset template.
|
|
8
|
+
|
|
9
|
+
## Sample
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
## How to use it
|
|
14
|
+
|
|
15
|
+
### CDN / Vanilla JS / jQuery
|
|
16
|
+
|
|
17
|
+
The first step is installing [tsParticles](https://github.com/matteobruni/tsparticles) following the instructions for
|
|
18
|
+
vanilla javascript in the main project [here](https://github.com/matteobruni/tsparticles)
|
|
19
|
+
|
|
20
|
+
Once installed you need one more script to be included in your page (or you can download that
|
|
21
|
+
from [jsDelivr](https://www.jsdelivr.com/package/npm/tsparticles-preset-template):
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/@tsparticles/engine@2/tsparticles.engine.min.js"></script>
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/tsparticles-preset-template/tsparticles.preset.template.min.js"></script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
This script **MUST** be placed after the `tsParticles` one.
|
|
29
|
+
|
|
30
|
+
#### Bundle
|
|
31
|
+
|
|
32
|
+
A bundled script can also be used, this will include every needed plugin needed by the preset.
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<script src="https://cdn.jsdelivr.net/npm/tsparticles-preset-template/tsparticles.preset.template.bundle.min.js"></script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Usage
|
|
39
|
+
|
|
40
|
+
Once the scripts are loaded you can set up `tsParticles` like this:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
(async () => {
|
|
44
|
+
await tsParticles.load("tsparticles", {
|
|
45
|
+
preset: "template",
|
|
46
|
+
});
|
|
47
|
+
})();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Customization
|
|
51
|
+
|
|
52
|
+
**Important**
|
|
53
|
+
You can override all the options defining the properties like in any standard `tsParticles` installation.
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
(async () => {
|
|
57
|
+
await tsParticles.load("tsparticles", {
|
|
58
|
+
particles: {
|
|
59
|
+
shape: {
|
|
60
|
+
type: "square"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
preset: "template"
|
|
64
|
+
});
|
|
65
|
+
})();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Like in the sample above, the circles will be replaced by squares.
|
|
69
|
+
|
|
70
|
+
### React.js / Preact / Inferno
|
|
71
|
+
|
|
72
|
+
_The syntax for `React.js`, `Preact` and `Inferno` is the same_.
|
|
73
|
+
|
|
74
|
+
This sample uses the class component syntax, but you can use hooks as well (if the library supports it).
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
import Particles from "react-particles";
|
|
78
|
+
import { Engine } from "@tsparticles/engine";
|
|
79
|
+
import { loadTemplatePreset } from "tsparticles-preset-template";
|
|
80
|
+
|
|
81
|
+
export class ParticlesContainer extends React.PureComponent<IProps> {
|
|
82
|
+
// this customizes the component tsParticles installation
|
|
83
|
+
async customInit(engine: Engine) {
|
|
84
|
+
// this adds the preset to tsParticles, you can safely use the
|
|
85
|
+
await loadTemplatePreset(engine);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
render() {
|
|
89
|
+
const options = {
|
|
90
|
+
preset: "template",
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return <Particles options={options} init={this.customInit} />;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Vue (2.x and 3.x)
|
|
99
|
+
|
|
100
|
+
_The syntax for `Vue.js 2.x` and `3.x` is the same_
|
|
101
|
+
|
|
102
|
+
```vue
|
|
103
|
+
<Particles id="tsparticles" :particlesInit="particlesInit" url="http://foo.bar/particles.json" />
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
async function particlesInit(engine: Engine) {
|
|
108
|
+
await loadTemplatePreset(main);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Angular
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
|
|
116
|
+
<ng-particles
|
|
117
|
+
[id]="id"
|
|
118
|
+
[options]="particlesOptions"
|
|
119
|
+
[particlesInit]="particlesInit"
|
|
120
|
+
></ng-particles>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
async function particlesInit(engine: Engine): Promise<void> {
|
|
125
|
+
loadTemplatePreset(engine);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Svelte
|
|
130
|
+
|
|
131
|
+
```sveltehtml
|
|
132
|
+
|
|
133
|
+
<Particles
|
|
134
|
+
id="tsparticles"
|
|
135
|
+
url="{particlesUrl}"
|
|
136
|
+
particlesInit="{particlesInit}"
|
|
137
|
+
/>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
let particlesInit = async (engine) => {
|
|
142
|
+
await loadTemplatePreset(engine);
|
|
143
|
+
};
|
|
144
|
+
```
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { loadTemplatePreset } from "./index.js";
|
|
2
|
+
|
|
3
|
+
const globalObject = globalThis as typeof globalThis & {
|
|
4
|
+
__tsParticlesInternals?: Record<string, unknown>;
|
|
5
|
+
loadTemplatePreset?: typeof loadTemplatePreset;
|
|
6
|
+
};
|
|
7
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
8
|
+
globalObject.loadTemplatePreset = loadTemplatePreset;
|
|
9
|
+
|
|
10
|
+
export * from "./index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { loadTemplatePreset } from "./index.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { loadTemplatePreset } from "./index.js";
|
|
5
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
6
|
+
|
|
7
|
+
void loadTemplatePreset(tsParticles);
|
|
8
|
+
|
|
9
|
+
export { loadTemplatePreset, tsParticles };
|
|
10
|
+
|
|
11
|
+
const globalObject = globalThis as typeof globalThis & {
|
|
12
|
+
__tsParticlesInternals?: Record<string, unknown>;
|
|
13
|
+
loadTemplatePreset?: typeof loadTemplatePreset;
|
|
14
|
+
};
|
|
15
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
16
|
+
|
|
17
|
+
globalObject.loadTemplatePreset = loadTemplatePreset;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param engine - the engine instance to load the preset into
|
|
6
|
+
*/
|
|
7
|
+
export async function loadTemplatePreset(engine: Engine): Promise<void> {
|
|
8
|
+
const { options } = await import("./options.js");
|
|
9
|
+
|
|
10
|
+
// TODO: additional modules must be loaded here
|
|
11
|
+
|
|
12
|
+
// Adds the preset to the engine, with the given options
|
|
13
|
+
await engine.addPreset("#template#", options);
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
import { options } from "./options.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param engine - the engine instance to load the preset into
|
|
7
|
+
*/
|
|
8
|
+
export async function loadTemplatePreset(engine: Engine): Promise<void> {
|
|
9
|
+
// TODO: additional modules must be loaded here
|
|
10
|
+
|
|
11
|
+
// Adds the preset to the engine, with the given options
|
|
12
|
+
await engine.addPreset("#template#", options);
|
|
13
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[](https://particles.js.org)
|
|
2
|
+
|
|
3
|
+
# tsParticles Template Shape
|
|
4
|
+
|
|
5
|
+
[](https://www.jsdelivr.com/package/npm/tsparticles-shape-template)
|
|
6
|
+
[](https://www.npmjs.com/package/tsparticles-shape-template)
|
|
7
|
+
[](https://www.npmjs.com/package/tsparticles-shape-template) [](https://github.com/sponsors/matteobruni)
|
|
8
|
+
|
|
9
|
+
[tsParticles](https://github.com/matteobruni/tsparticles) additional template shape.
|
|
10
|
+
|
|
11
|
+
## How to use it
|
|
12
|
+
|
|
13
|
+
### CDN / Vanilla JS / jQuery
|
|
14
|
+
|
|
15
|
+
The CDN/Vanilla version JS has one required file in vanilla configuration:
|
|
16
|
+
|
|
17
|
+
Including the `tsparticles.shape.template.min.js` file will export the function to load the shape:
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
loadTemplateShape
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Usage
|
|
24
|
+
|
|
25
|
+
Once the scripts are loaded you can set up `tsParticles` and the shape like this:
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
(async () => {
|
|
29
|
+
await loadTemplateShape(tsParticles);
|
|
30
|
+
|
|
31
|
+
await tsParticles.load({
|
|
32
|
+
id: "tsparticles",
|
|
33
|
+
options: {
|
|
34
|
+
/* options */
|
|
35
|
+
/* here you can use particles.shape.type: "template" */
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
})();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### ESM / CommonJS
|
|
42
|
+
|
|
43
|
+
This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
$ npm install tsparticles-shape-template
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
or
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
$ yarn add tsparticles-shape-template
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then you need to import it in the app, like this:
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
const { tsParticles } = require("@tsparticles/engine");
|
|
59
|
+
const { loadTemplateShape } = require("tsparticles-shape-template");
|
|
60
|
+
|
|
61
|
+
(async () => {
|
|
62
|
+
await loadTemplateShape(tsParticles);
|
|
63
|
+
})();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
or
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
import { tsParticles } from "@tsparticles/engine";
|
|
70
|
+
import { loadTemplateShape } from "tsparticles-shape-template";
|
|
71
|
+
|
|
72
|
+
(async () => {
|
|
73
|
+
await loadTemplateShape(tsParticles);
|
|
74
|
+
})();
|
|
75
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IShapeDrawData, IShapeDrawer } from "@tsparticles/engine";
|
|
2
|
+
|
|
3
|
+
export class ShapeDrawer implements IShapeDrawer {
|
|
4
|
+
readonly validTypes = ["#template#"] as const;
|
|
5
|
+
|
|
6
|
+
draw(_data: IShapeDrawData): void {
|
|
7
|
+
// draw the particle using the context
|
|
8
|
+
// which is already centered in the particle position
|
|
9
|
+
// colors are already handled, just draw the shape
|
|
10
|
+
// the bounds are -radius to radius
|
|
11
|
+
// delta is the frame time difference between the last frame and this one, in ms, use it for animated shapes
|
|
12
|
+
// pixelRatio is the canvas ratio used by the tsParticles instance, you may need it for density-independent shapes
|
|
13
|
+
// the parameters have an underscore prefix because they're not used in this example
|
|
14
|
+
// the underscore prefix can be removed for used parameters, the unused ones can be removed too
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { loadTemplateShape } from "./index.js";
|
|
2
|
+
|
|
3
|
+
const globalObject = globalThis as typeof globalThis & {
|
|
4
|
+
__tsParticlesInternals?: Record<string, unknown>;
|
|
5
|
+
loadTemplateShape?: typeof loadTemplateShape;
|
|
6
|
+
};
|
|
7
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
8
|
+
globalObject.loadTemplateShape = loadTemplateShape;
|
|
9
|
+
|
|
10
|
+
export * from "./index.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @param engine - the engine instance to load the shape into
|
|
5
|
+
*/
|
|
6
|
+
export async function loadTemplateShape(engine: Engine): Promise<void> {
|
|
7
|
+
const { ShapeDrawer } = await import("./ShapeDrawer.js");
|
|
8
|
+
|
|
9
|
+
await engine.addShape(new ShapeDrawer());
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Engine } from "@tsparticles/engine";
|
|
2
|
+
import { ShapeDrawer } from "./ShapeDrawer.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @param engine - the engine instance to load the shape into
|
|
6
|
+
*/
|
|
7
|
+
export async function loadTemplateShape(engine: Engine): Promise<void> {
|
|
8
|
+
await engine.addShape(new ShapeDrawer());
|
|
9
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tsparticles/cli-command-create",
|
|
3
|
+
"version": "4.0.0-beta.12",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"tagVersionPrefix": "v"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/tsparticles/tsparticles.git",
|
|
13
|
+
"directory": "cli/commands/create"
|
|
14
|
+
},
|
|
15
|
+
"prettier": "@tsparticles/prettier-config",
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"commander": "^14"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@swc/core": "^1.15.32",
|
|
21
|
+
"eslint": "^10.3.0",
|
|
22
|
+
"eslint-config-prettier": "^10.1.8",
|
|
23
|
+
"eslint-plugin-jsdoc": "^62.9.0",
|
|
24
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
25
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
26
|
+
"klaw": "^4.1.0",
|
|
27
|
+
"lookpath": "^1.2.3",
|
|
28
|
+
"dependency-cruiser": "^17.3.10",
|
|
29
|
+
"path-scurry": "^2.0.2",
|
|
30
|
+
"prettier": "^3.8.3",
|
|
31
|
+
"prettier-plugin-multiline-arrays": "^4.1.7",
|
|
32
|
+
"prompts": "^2.4.2",
|
|
33
|
+
"rimraf": "^6.1.3",
|
|
34
|
+
"swc-loader": "^0.2.7",
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"typescript-eslint": "^8.59.1",
|
|
37
|
+
"webpack": "^5.106.2",
|
|
38
|
+
"@tsparticles/cli-create-utils": "^4.0.0-beta.12",
|
|
39
|
+
"@tsparticles/depcruise-config": "^4.0.0-beta.12",
|
|
40
|
+
"@tsparticles/prettier-config": "^4.0.0-beta.12",
|
|
41
|
+
"@tsparticles/eslint-config": "^4.0.0-beta.12",
|
|
42
|
+
"@tsparticles/tsconfig": "^4.0.0-beta.12",
|
|
43
|
+
"@tsparticles/webpack-plugin": "^4.0.0-beta.12"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/estree": "^1.0.8",
|
|
47
|
+
"@types/klaw": "^3.0.7",
|
|
48
|
+
"@types/node": "^25.6.0",
|
|
49
|
+
"@types/prompts": "^2.4.9",
|
|
50
|
+
"@types/webpack-env": "^1.18.8",
|
|
51
|
+
"browserslist": "^4.28.2",
|
|
52
|
+
"commander": "^14.0.3",
|
|
53
|
+
"copyfiles": "^2.4.1",
|
|
54
|
+
"cross-env": "^10.1.0",
|
|
55
|
+
"terser-webpack-plugin": "^5.5.0",
|
|
56
|
+
"ts-node": "^10.9.2",
|
|
57
|
+
"vitest": "^4.1.5",
|
|
58
|
+
"webpack-bundle-analyzer": "^5.3.0",
|
|
59
|
+
"webpack-cli": "^7.0.2"
|
|
60
|
+
},
|
|
61
|
+
"description": "tsParticles CLI",
|
|
62
|
+
"main": "dist/create.js",
|
|
63
|
+
"author": "Matteo Bruni <matteo.bruni@me.com>",
|
|
64
|
+
"scripts": {
|
|
65
|
+
"prettify:ci:src": "prettier --check ./src/*",
|
|
66
|
+
"prettify:ci:readme": "prettier --check ./README.md",
|
|
67
|
+
"prettify:src": "prettier --write ./src/*",
|
|
68
|
+
"prettify:readme": "prettier --write ./README.md",
|
|
69
|
+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --cache --cache-location .cache/eslint/.eslintcache --cache-strategy metadata --fix",
|
|
70
|
+
"lint:ci": "eslint src --ext .js,.jsx,.ts,.tsx --cache --cache-location .cache/eslint/.eslintcache --cache-strategy metadata",
|
|
71
|
+
"circular-deps": "depcruise src --include-only '^src' --validate --output-type err-long",
|
|
72
|
+
"compile": "pnpm run build:ts",
|
|
73
|
+
"compile:ci": "pnpm run build:ts",
|
|
74
|
+
"build:ts": "pnpm run build:ts:cjs",
|
|
75
|
+
"build:ts:cjs": "tsc -p src",
|
|
76
|
+
"test": "vitest run",
|
|
77
|
+
"build": "pnpm run clear:dist && pnpm run prettify:src && pnpm run lint && pnpm run compile && pnpm run circular-deps && pnpm run prettify:readme",
|
|
78
|
+
"build:ci": "pnpm run clear:dist && pnpm run prettify:ci:src && pnpm run lint:ci && pnpm run compile:ci && pnpm run prettify:ci:readme",
|
|
79
|
+
"clear:dist": "rimraf ./dist"
|
|
80
|
+
}
|
|
81
|
+
}
|
package/renovate.json
ADDED
package/src/create.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { pluginCommand } from "./plugin/plugin.js";
|
|
3
|
+
import { presetCommand } from "./preset/preset.js";
|
|
4
|
+
import { shapeCommand } from "./shape/shape.js";
|
|
5
|
+
|
|
6
|
+
const createCommand = new Command("create");
|
|
7
|
+
|
|
8
|
+
createCommand.description("Create a new tsParticles project");
|
|
9
|
+
|
|
10
|
+
createCommand.addCommand(pluginCommand);
|
|
11
|
+
createCommand.addCommand(presetCommand);
|
|
12
|
+
createCommand.addCommand(shapeCommand);
|
|
13
|
+
|
|
14
|
+
export { createCommand };
|