@tsparticles/updater-twinkle 4.0.0-beta.0 → 4.0.0-beta.10

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.
@@ -1 +1 @@
1
- "use strict";(this.webpackChunk_tsparticles_updater_twinkle=this.webpackChunk_tsparticles_updater_twinkle||[]).push([[190],{190(e,o,t){t.d(o,{TwinkleUpdater:()=>n});var l=t(303);class i{color;enable;frequency;opacity;constructor(){this.enable=!1,this.frequency=.05,this.opacity=1}load(e){(0,l.isNull)(e)||(void 0!==e.color&&(this.color=l.OptionsColor.create(this.color,e.color)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.frequency&&(this.frequency=e.frequency),void 0!==e.opacity&&(this.opacity=(0,l.setRangeValue)(e.opacity)))}}class r{enable;fillColor;frequency;opacity;strokeColor;constructor(){this.enable=!1,this.frequency=.05,this.opacity=1}load(e){(0,l.isNull)(e)||(void 0!==e.fillColor&&(this.fillColor=l.OptionsColor.create(this.fillColor,e.fillColor)),void 0!==e.strokeColor&&(this.strokeColor=l.OptionsColor.create(this.strokeColor,e.strokeColor)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.frequency&&(this.frequency=e.frequency),void 0!==e.opacity&&(this.opacity=(0,l.setRangeValue)(e.opacity)))}}class s{links;particles;constructor(){this.links=new i,this.particles=new r}load(e){(0,l.isNull)(e)||(this.links.load(e.links),this.particles.load(e.particles))}}class n{_engine;constructor(e){this._engine=e}getColorStyles(e,o,t,i){let r=e.options,{container:s}=e,n=r.twinkle;if(!n)return{};let a=n.particles,c=a.enable&&(0,l.getRandom)()<a.frequency,p=e.options.zIndex,u=(1-e.zIndexFactor)**p.opacityRate,h=c?(0,l.getRangeValue)(a.opacity)*u:i,d=(0,l.rangeColorToHsl)(this._engine,a.fillColor),y=(0,l.rangeColorToHsl)(this._engine,a.strokeColor),f=(()=>{if(d)return(0,l.getStyleFromHsl)(d,s.hdr,h)})(),k=(()=>{if(y)return(0,l.getStyleFromHsl)(y,s.hdr,h)})(),C={},b=c&&(!!f||!!k);return C.fill=b?f:void 0,C.stroke=b?k:void 0,C}init(){}isEnabled(e){let o=e.options.twinkle;return!!o&&o.particles.enable}loadOptions(e,...o){for(let t of(e.twinkle??=new s,o))e.twinkle.load(t?.twinkle)}update(){}}}}]);
1
+ "use strict";(this.webpackChunk_tsparticles_updater_twinkle=this.webpackChunk_tsparticles_updater_twinkle||[]).push([[842],{842(e,t,o){o.d(t,{TwinkleUpdater:()=>n});var l=o(303);class i{color;enable;frequency;opacity;constructor(){this.enable=!1,this.frequency=.05,this.opacity=1}load(e){(0,l.isNull)(e)||(void 0!==e.color&&(this.color=l.OptionsColor.create(this.color,e.color)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.frequency&&(this.frequency=e.frequency),void 0!==e.opacity&&(this.opacity=(0,l.setRangeValue)(e.opacity)))}}class r{enable;fillColor;frequency;opacity;strokeColor;constructor(){this.enable=!1,this.frequency=.05,this.opacity=1}load(e){(0,l.isNull)(e)||(void 0!==e.fillColor&&(this.fillColor=l.OptionsColor.create(this.fillColor,e.fillColor)),void 0!==e.strokeColor&&(this.strokeColor=l.OptionsColor.create(this.strokeColor,e.strokeColor)),void 0!==e.enable&&(this.enable=e.enable),void 0!==e.frequency&&(this.frequency=e.frequency),void 0!==e.opacity&&(this.opacity=(0,l.setRangeValue)(e.opacity)))}}class s{links;particles;constructor(){this.links=new i,this.particles=new r}load(e){(0,l.isNull)(e)||(this.links.load(e.links),this.particles.load(e.particles))}}class n{_container;_pluginManager;constructor(e,t){this._pluginManager=e,this._container=t}getColorStyles(e,t,o,i){let r=e.options,{_container:s}=this,n=r.twinkle;if(!n)return{};let a=n.particles,c=a.enable&&(0,l.getRandom)()<a.frequency,p=e.options.zIndex,u=(1-e.zIndexFactor)**p.opacityRate,h=c?(0,l.getRangeValue)(a.opacity)*u:i,d=(0,l.rangeColorToHsl)(this._pluginManager,a.fillColor),y=(0,l.rangeColorToHsl)(this._pluginManager,a.strokeColor),f=(()=>{if(d)return(0,l.getStyleFromHsl)(d,s.hdr,h)})(),k=(()=>{if(y)return(0,l.getStyleFromHsl)(y,s.hdr,h)})(),C={},g=c&&(!!f||!!k);return C.fill=g?f:void 0,C.stroke=g?k:void 0,C}init(){}isEnabled(e){let t=e.options.twinkle;return!!t&&t.particles.enable}loadOptions(e,...t){for(let o of(e.twinkle??=new s,t))e.twinkle.load(o?.twinkle)}update(){}}}}]);
package/README.md CHANGED
@@ -8,6 +8,12 @@
8
8
 
9
9
  [tsParticles](https://github.com/tsparticles/tsparticles) updater plugin for twinkle animations.
10
10
 
11
+ ## Quick checklist
12
+
13
+ 1. Install `@tsparticles/engine` (or use the CDN bundle below)
14
+ 2. Call the package loader function(s) before `tsParticles.load(...)`
15
+ 3. Apply the package options in your `tsParticles.load(...)` config
16
+
11
17
  ## How to use it
12
18
 
13
19
  ### CDN / Vanilla JS / jQuery
@@ -72,3 +78,26 @@ import { loadTwinkleUpdater } from "@tsparticles/updater-twinkle";
72
78
  await loadTwinkleUpdater(tsParticles);
73
79
  })();
74
80
  ```
81
+
82
+ ## Option mapping
83
+
84
+ - Primary options key: `particles.twinkle`
85
+
86
+ ```json
87
+ {
88
+ "particles": {
89
+ "twinkle": {}
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Common pitfalls
95
+
96
+ - Calling `tsParticles.load(...)` before `loadTwinkleUpdater(...)`
97
+ - Verify required peer packages before enabling advanced options
98
+ - Change one option group at a time to isolate regressions quickly
99
+
100
+ ## Related docs
101
+
102
+ - All packages catalog: <https://github.com/tsparticles/tsparticles>
103
+ - Main docs: <https://particles.js.org/docs/>
@@ -1,16 +1,18 @@
1
1
  import { getRandom, getRangeValue, getStyleFromHsl, rangeColorToHsl, } from "@tsparticles/engine";
2
2
  import { Twinkle } from "./Options/Classes/Twinkle.js";
3
3
  export class TwinkleUpdater {
4
- _engine;
5
- constructor(engine) {
6
- this._engine = engine;
4
+ _container;
5
+ _pluginManager;
6
+ constructor(pluginManager, container) {
7
+ this._pluginManager = pluginManager;
8
+ this._container = container;
7
9
  }
8
10
  getColorStyles(particle, _context, _radius, opacity) {
9
- const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions["twinkle"];
11
+ const pOptions = particle.options, { _container: container } = this, twinkleOptions = pOptions["twinkle"];
10
12
  if (!twinkleOptions) {
11
13
  return {};
12
14
  }
13
- const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = rangeColorToHsl(this._engine, twinkle.fillColor), twinkleStrokeRgb = rangeColorToHsl(this._engine, twinkle.strokeColor), getTwinkleFillStyle = () => {
15
+ const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = rangeColorToHsl(this._pluginManager, twinkle.fillColor), twinkleStrokeRgb = rangeColorToHsl(this._pluginManager, twinkle.strokeColor), getTwinkleFillStyle = () => {
14
16
  if (!twinkleFillRgb) {
15
17
  return undefined;
16
18
  }
package/browser/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadTwinkleUpdater(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(e => {
4
- e.addParticleUpdater("twinkle", async () => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addParticleUpdater("twinkle", async (container) => {
5
5
  const { TwinkleUpdater } = await import("./TwinkleUpdater.js");
6
- return new TwinkleUpdater(e);
6
+ return new TwinkleUpdater(e.pluginManager, container);
7
7
  });
8
8
  });
9
9
  }
@@ -1,16 +1,18 @@
1
1
  import { getRandom, getRangeValue, getStyleFromHsl, rangeColorToHsl, } from "@tsparticles/engine";
2
2
  import { Twinkle } from "./Options/Classes/Twinkle.js";
3
3
  export class TwinkleUpdater {
4
- _engine;
5
- constructor(engine) {
6
- this._engine = engine;
4
+ _container;
5
+ _pluginManager;
6
+ constructor(pluginManager, container) {
7
+ this._pluginManager = pluginManager;
8
+ this._container = container;
7
9
  }
8
10
  getColorStyles(particle, _context, _radius, opacity) {
9
- const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions["twinkle"];
11
+ const pOptions = particle.options, { _container: container } = this, twinkleOptions = pOptions["twinkle"];
10
12
  if (!twinkleOptions) {
11
13
  return {};
12
14
  }
13
- const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = rangeColorToHsl(this._engine, twinkle.fillColor), twinkleStrokeRgb = rangeColorToHsl(this._engine, twinkle.strokeColor), getTwinkleFillStyle = () => {
15
+ const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = rangeColorToHsl(this._pluginManager, twinkle.fillColor), twinkleStrokeRgb = rangeColorToHsl(this._pluginManager, twinkle.strokeColor), getTwinkleFillStyle = () => {
14
16
  if (!twinkleFillRgb) {
15
17
  return undefined;
16
18
  }
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadTwinkleUpdater(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(e => {
4
- e.addParticleUpdater("twinkle", async () => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addParticleUpdater("twinkle", async (container) => {
5
5
  const { TwinkleUpdater } = await import("./TwinkleUpdater.js");
6
- return new TwinkleUpdater(e);
6
+ return new TwinkleUpdater(e.pluginManager, container);
7
7
  });
8
8
  });
9
9
  }
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.0
7
+ * v4.0.0-beta.10
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -53,7 +53,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
53
53
  \****************************************/
54
54
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
55
55
 
56
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TwinkleUpdater: () => (/* binding */ TwinkleUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Twinkle_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Twinkle.js */ \"./dist/browser/Options/Classes/Twinkle.js\");\n\n\nclass TwinkleUpdater {\n _engine;\n constructor(engine){\n this._engine = engine;\n }\n getColorStyles(particle, _context, _radius, opacity) {\n const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions[\"twinkle\"];\n if (!twinkleOptions) {\n return {};\n }\n const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToHsl)(this._engine, twinkle.fillColor), twinkleStrokeRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToHsl)(this._engine, twinkle.strokeColor), getTwinkleFillStyle = ()=>{\n if (!twinkleFillRgb) {\n return undefined;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(twinkleFillRgb, container.hdr, twinklingOpacity);\n }, getTwinkleStrokeStyle = ()=>{\n if (!twinkleStrokeRgb) {\n return undefined;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(twinkleStrokeRgb, container.hdr, twinklingOpacity);\n }, twinkleFillStyle = getTwinkleFillStyle(), twinkleStrokeStyle = getTwinkleStrokeStyle(), res = {}, needsTwinkle = twinkling && (!!twinkleFillStyle || !!twinkleStrokeStyle);\n res.fill = needsTwinkle ? twinkleFillStyle : undefined;\n res.stroke = needsTwinkle ? twinkleStrokeStyle : undefined;\n return res;\n }\n init() {}\n isEnabled(particle) {\n const pOptions = particle.options, twinkleOptions = pOptions.twinkle;\n if (!twinkleOptions) {\n return false;\n }\n return twinkleOptions.particles.enable;\n }\n loadOptions(options, ...sources) {\n options.twinkle ??= new _Options_Classes_Twinkle_js__WEBPACK_IMPORTED_MODULE_1__.Twinkle();\n for (const source of sources){\n options.twinkle.load(source?.twinkle);\n }\n }\n update() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/updater-twinkle/./dist/browser/TwinkleUpdater.js?\n}");
56
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TwinkleUpdater: () => (/* binding */ TwinkleUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Twinkle_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Twinkle.js */ \"./dist/browser/Options/Classes/Twinkle.js\");\n\n\nclass TwinkleUpdater {\n _container;\n _pluginManager;\n constructor(pluginManager, container){\n this._pluginManager = pluginManager;\n this._container = container;\n }\n getColorStyles(particle, _context, _radius, opacity) {\n const pOptions = particle.options, { _container: container } = this, twinkleOptions = pOptions[\"twinkle\"];\n if (!twinkleOptions) {\n return {};\n }\n const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToHsl)(this._pluginManager, twinkle.fillColor), twinkleStrokeRgb = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToHsl)(this._pluginManager, twinkle.strokeColor), getTwinkleFillStyle = ()=>{\n if (!twinkleFillRgb) {\n return undefined;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(twinkleFillRgb, container.hdr, twinklingOpacity);\n }, getTwinkleStrokeStyle = ()=>{\n if (!twinkleStrokeRgb) {\n return undefined;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(twinkleStrokeRgb, container.hdr, twinklingOpacity);\n }, twinkleFillStyle = getTwinkleFillStyle(), twinkleStrokeStyle = getTwinkleStrokeStyle(), res = {}, needsTwinkle = twinkling && (!!twinkleFillStyle || !!twinkleStrokeStyle);\n res.fill = needsTwinkle ? twinkleFillStyle : undefined;\n res.stroke = needsTwinkle ? twinkleStrokeStyle : undefined;\n return res;\n }\n init() {}\n isEnabled(particle) {\n const pOptions = particle.options, twinkleOptions = pOptions.twinkle;\n if (!twinkleOptions) {\n return false;\n }\n return twinkleOptions.particles.enable;\n }\n loadOptions(options, ...sources) {\n options.twinkle ??= new _Options_Classes_Twinkle_js__WEBPACK_IMPORTED_MODULE_1__.Twinkle();\n for (const source of sources){\n options.twinkle.load(source?.twinkle);\n }\n }\n update() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/updater-twinkle/./dist/browser/TwinkleUpdater.js?\n}");
57
57
 
58
58
  /***/ }
59
59
 
@@ -1,16 +1,18 @@
1
1
  import { getRandom, getRangeValue, getStyleFromHsl, rangeColorToHsl, } from "@tsparticles/engine";
2
2
  import { Twinkle } from "./Options/Classes/Twinkle.js";
3
3
  export class TwinkleUpdater {
4
- _engine;
5
- constructor(engine) {
6
- this._engine = engine;
4
+ _container;
5
+ _pluginManager;
6
+ constructor(pluginManager, container) {
7
+ this._pluginManager = pluginManager;
8
+ this._container = container;
7
9
  }
8
10
  getColorStyles(particle, _context, _radius, opacity) {
9
- const pOptions = particle.options, { container } = particle, twinkleOptions = pOptions["twinkle"];
11
+ const pOptions = particle.options, { _container: container } = this, twinkleOptions = pOptions["twinkle"];
10
12
  if (!twinkleOptions) {
11
13
  return {};
12
14
  }
13
- const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = rangeColorToHsl(this._engine, twinkle.fillColor), twinkleStrokeRgb = rangeColorToHsl(this._engine, twinkle.strokeColor), getTwinkleFillStyle = () => {
15
+ const twinkle = twinkleOptions.particles, twinkling = twinkle.enable && getRandom() < twinkle.frequency, zIndexOptions = particle.options.zIndex, zOffset = 1, zOpacityFactor = (zOffset - particle.zIndexFactor) ** zIndexOptions.opacityRate, twinklingOpacity = twinkling ? getRangeValue(twinkle.opacity) * zOpacityFactor : opacity, twinkleFillRgb = rangeColorToHsl(this._pluginManager, twinkle.fillColor), twinkleStrokeRgb = rangeColorToHsl(this._pluginManager, twinkle.strokeColor), getTwinkleFillStyle = () => {
14
16
  if (!twinkleFillRgb) {
15
17
  return undefined;
16
18
  }
package/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  export async function loadTwinkleUpdater(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(e => {
4
- e.addParticleUpdater("twinkle", async () => {
2
+ engine.checkVersion("4.0.0-beta.10");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addParticleUpdater("twinkle", async (container) => {
5
5
  const { TwinkleUpdater } = await import("./TwinkleUpdater.js");
6
- return new TwinkleUpdater(e);
6
+ return new TwinkleUpdater(e.pluginManager, container);
7
7
  });
8
8
  });
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-twinkle",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.10",
4
4
  "description": "tsParticles particles twinkle updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -81,13 +81,12 @@
81
81
  "browser": "./browser/index.js",
82
82
  "import": "./esm/index.js",
83
83
  "require": "./cjs/index.js",
84
- "umd": "./umd/index.js",
85
- "default": "./cjs/index.js"
84
+ "default": "./esm/index.js"
86
85
  },
87
86
  "./package.json": "./package.json"
88
87
  },
89
- "dependencies": {
90
- "@tsparticles/engine": "4.0.0-beta.0"
88
+ "peerDependencies": {
89
+ "@tsparticles/engine": "4.0.0-beta.10"
91
90
  },
92
91
  "publishConfig": {
93
92
  "access": "public"