Skip to content

Commit

Permalink
Merge pull request #41 from tsparticles/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
matteobruni authored Mar 3, 2024
2 parents f759905 + 3e2ef15 commit c71cf9b
Show file tree
Hide file tree
Showing 13 changed files with 1,773 additions and 1,286 deletions.
37 changes: 3 additions & 34 deletions files/create-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
import type { Container, Engine, IPlugin, ISourceOptions, Options } from "@tsparticles/engine";
import { PluginInstance } from "./PluginInstance";

/**
*/
class Plugin implements IPlugin {
readonly id;

private readonly _engine;

constructor(engine: Engine) {
this.id = "#template#";

this._engine = engine;
}

getPlugin(container: Container): PluginInstance {
return new PluginInstance(container, this._engine);
}

loadOptions(_options: Options, _source?: ISourceOptions): void {
if (!this.needsPlugin()) {
// ignore plugin options when not needed

return;
}

// Load your options here
}

needsPlugin(_options?: ISourceOptions): boolean {
return true; // add your condition here, replace true with condition if needed
}
}
import type { Engine } from "@tsparticles/engine";

/**
* @param engine - The engine instance
*/
export async function loadTemplatePlugin(engine: Engine): Promise<void> {
const { Plugin } = await import("./plugin.js");

await engine.addPlugin(new Plugin(engine));
}
36 changes: 36 additions & 0 deletions files/create-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { type Container, type Engine, type IPlugin, type ISourceOptions, type Options } from "@tsparticles/engine";
import type { PluginInstance } from "./PluginInstance.js";

/**
*/
export class Plugin implements IPlugin {
readonly id;

private readonly _engine;

constructor(engine: Engine) {
this.id = "#template#";

this._engine = engine;
}

async getPlugin(container: Container): Promise<PluginInstance> {
const { PluginInstance } = await import("./PluginInstance.js");

return new PluginInstance(container, this._engine);
}

loadOptions(_options: Options, _source?: ISourceOptions): void {
if (!this.needsPlugin()) {
// ignore plugin options when not needed

return;
}

// Load your options here
}

needsPlugin(_options?: ISourceOptions): boolean {
return true; // add your condition here, replace true with condition if needed
}
}
3 changes: 2 additions & 1 deletion files/create-preset/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { Engine } from "@tsparticles/engine";
import { options } from "./options";

/**
*
* @param engine - the engine instance to load the preset into
*/
export async function loadTemplatePreset(engine: Engine): Promise<void> {
const { options } = await import("./options.js");

// TODO: additional modules must be loaded here

// Adds the preset to the engine, with the given options
Expand Down
3 changes: 2 additions & 1 deletion files/create-shape/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { Engine } from "@tsparticles/engine";
import { ShapeDrawer } from "./ShapeDrawer";

/**
* @param engine - the engine instance to load the shape into
*/
export async function loadTemplateShape(engine: Engine): Promise<void> {
const { ShapeDrawer } = await import("./ShapeDrawer.js");

await engine.addShape("#template#", new ShapeDrawer());
}
2 changes: 1 addition & 1 deletion files/empty-project/package.dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"module": "index.js",
"types": "index.d.ts",
"dependencies": {
"@tsparticles/engine": "^3.0.3"
"@tsparticles/engine": "^3.3.0"
}
}
18 changes: 9 additions & 9 deletions files/empty-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@
"prettier": "@tsparticles/prettier-config",
"devDependencies": {
"@babel/core": "^7.23.9",
"@tsparticles/cli": "^2.0.5",
"@tsparticles/eslint-config": "^2.1.0",
"@tsparticles/prettier-config": "^2.1.0",
"@tsparticles/tsconfig": "^2.0.1",
"@tsparticles/webpack-plugin": "^2.1.0",
"@tsparticles/cli": "^2.3.2",
"@tsparticles/eslint-config": "^2.2.1",
"@tsparticles/prettier-config": "^2.1.6",
"@tsparticles/tsconfig": "^2.1.7",
"@tsparticles/webpack-plugin": "^2.2.1",
"@types/webpack-env": "^1.18.4",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"babel-loader": "^9.1.3",
"browserslist": "^4.22.3",
"browserslist": "^4.23.0",
"copyfiles": "^2.4.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -105,6 +105,6 @@
"webpack-cli": "^5.1.4"
},
"dependencies": {
"@tsparticles/engine": "^3.0.3"
"@tsparticles/engine": "^3.3.0"
}
}
57 changes: 37 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsparticles/cli",
"version": "2.0.5",
"version": "2.3.2",
"license": "MIT",
"bin": {
"tsparticles-cli": "dist/cli.js"
Expand All @@ -16,52 +16,69 @@
"prettify:readme": "prettier --write ./README.md",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
"lint:ci": "eslint src --ext .js,.jsx,.ts,.tsx",
"circular-deps": "madge --circular --extensions ts src",
"compile": "pnpm run build:ts",
"compile:ci": "pnpm run build:ts",
"build:ts": "pnpm run build:ts:cjs",
"build:ts:cjs": "tsc -p src",
"test": "cross-env TS_NODE_PROJECT='./tests/tsconfig.json' nyc mocha --timeout 300000",
"build": "pnpm run clear:dist && pnpm run prettify:src && pnpm run lint && pnpm run compile && pnpm run prettify:readme && chmod +x dist/cli.js && chmod +x dist/build/build.js && chmod +x dist/create/create.js && chmod +x dist/create/preset/preset.js",
"build:ci": "pnpm run clear:dist && pnpm run prettify:ci:src && pnpm run lint:ci && pnpm run compile && pnpm run prettify:ci:readme",
"build": "pnpm run clear:dist && pnpm run prettify:src && pnpm run lint && pnpm run compile && pnpm run circular-deps && pnpm run prettify:readme && chmod +x dist/cli.js && chmod +x dist/build/build.js && chmod +x dist/create/create.js && chmod +x dist/create/preset/preset.js",
"build:ci": "pnpm run clear:dist && pnpm run prettify:ci:src && pnpm run lint:ci && pnpm run compile:ci && pnpm run prettify:ci:readme",
"clear:dist": "rimraf ./dist",
"prepack": "pnpm run build",
"version": "node scripts/postversion.js && git add files/empty-project/package.json"
},
"dependencies": {
"@tsparticles/eslint-config": "^2.1.0",
"@tsparticles/prettier-config": "^2.1.0",
"@tsparticles/tsconfig": "^2.0.1",
"@tsparticles/webpack-plugin": "^2.1.0",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"commander": "^11.1.0",
"eslint": "^8.56.0",
"@tsparticles/eslint-config": "^2.2.1",
"@tsparticles/prettier-config": "^2.1.6",
"@tsparticles/tsconfig": "^2.1.7",
"@tsparticles/webpack-plugin": "^2.2.1",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"commander": "^12.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^48.0.4",
"eslint-plugin-jsdoc": "^48.2.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-tsdoc": "^0.2.17",
"fs-extra": "^11.2.0",
"klaw": "^4.1.0",
"lookpath": "^1.2.2",
"madge": "^6.1.0",
"path-scurry": "^1.10.1",
"prettier": "^3.2.4",
"prettier-plugin-multiline-arrays": "^3.0.1",
"prettier": "^3.2.5",
"prettier-plugin-multiline-arrays": "^3.0.4",
"prompts": "^2.4.2",
"rimraf": "^5.0.5",
"typescript": "^5.3.3",
"webpack": "^5.90.0"
"webpack": "^5.90.3"
},
"devDependencies": {
"@types/chai": "^4.3.11",
"@babel/core": "^7.23.9",
"@tsparticles/cli": "^2.2.4",
"@tsparticles/engine": "^3.3.0",
"@types/chai": "^4.3.12",
"@types/eslint": "^8.56.5",
"@types/fs-extra": "^11.0.4",
"@types/klaw": "^3.0.6",
"@types/madge": "^5.0.3",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.9",
"@types/node": "^20.11.24",
"@types/prompts": "^2.4.9",
"chai": "^4.4.0",
"@types/webpack-env": "^1.18.4",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"babel-loader": "^9.1.3",
"browserslist": "^4.23.0",
"chai": "^4.4.1",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"mocha": "^10.2.0",
"mocha": "^10.3.0",
"nyc": "^15.1.0",
"ts-node": "^10.9.2"
"terser-webpack-plugin": "^5.3.10",
"ts-node": "^10.9.2",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^5.1.4"
},
"description": "tsParticles CLI",
"main": ".eslintrc.js",
Expand Down
Loading

0 comments on commit c71cf9b

Please sign in to comment.