@tsparticles/plugin-hsl-color 3.9.1 → 4.0.0-alpha.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/207.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 207.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_hsl_color=this.webpackChunk_tsparticles_plugin_hsl_color||[]).push([[207],{207(s,a,e){e.d(a,{HslColorManager:()=>n});var l,t=e(303);!function(s){s[s.h=1]="h",s[s.s=2]="s",s[s.l=3]="l",s[s.a=5]="a"}(l||(l={}));const h=/hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;class n{constructor(){this.key="hsl"}accepts(s){return s.startsWith("hsl")}handleColor(s){const a=s.value.hsl??s.value;if(Object.hasOwn(a,"h")||Object.hasOwn(a,"s")||Object.hasOwn(a,"l"))return(0,t.hslToRgb)(a)}handleRangeColor(s){const a=s.value.hsl??s.value;if(Object.hasOwn(a,"h")||Object.hasOwn(a,"s")||Object.hasOwn(a,"l"))return(0,t.hslToRgb)({h:(0,t.getRangeValue)(a.h),l:(0,t.getRangeValue)(a.l),s:(0,t.getRangeValue)(a.s)})}parseString(s){if(!this.accepts(s))return;const a=h.exec(s);return a?(0,t.hslaToRgba)({a:a.length>4?(0,t.parseAlpha)(a[l.a]):1,h:parseInt(a[l.h]??"0",10),l:parseInt(a[l.l]??"0",10),s:parseInt(a[l.s]??"0",10)}):void 0}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles HSL Color Plugin v4.0.0-alpha.0 by Matteo Bruni */
@@ -6,38 +6,43 @@ var HslIndexes;
6
6
  HslIndexes[HslIndexes["l"] = 3] = "l";
7
7
  HslIndexes[HslIndexes["a"] = 5] = "a";
8
8
  })(HslIndexes || (HslIndexes = {}));
9
+ const hslRegex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;
9
10
  export class HslColorManager {
10
11
  constructor() {
11
12
  this.key = "hsl";
12
- this.stringPrefix = "hsl";
13
+ }
14
+ accepts(input) {
15
+ return input.startsWith("hsl");
13
16
  }
14
17
  handleColor(color) {
15
18
  const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
16
- if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
17
- return hslToRgb(hslColor);
19
+ if (!Object.hasOwn(hslColor, "h") && !Object.hasOwn(hslColor, "s") && !Object.hasOwn(hslColor, "l")) {
20
+ return;
18
21
  }
22
+ return hslToRgb(hslColor);
19
23
  }
20
24
  handleRangeColor(color) {
21
25
  const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
22
- if (hslColor.h !== undefined && hslColor.l !== undefined) {
23
- return hslToRgb({
24
- h: getRangeValue(hslColor.h),
25
- l: getRangeValue(hslColor.l),
26
- s: getRangeValue(hslColor.s),
27
- });
26
+ if (!Object.hasOwn(hslColor, "h") && !Object.hasOwn(hslColor, "s") && !Object.hasOwn(hslColor, "l")) {
27
+ return;
28
28
  }
29
+ return hslToRgb({
30
+ h: getRangeValue(hslColor.h),
31
+ l: getRangeValue(hslColor.l),
32
+ s: getRangeValue(hslColor.s),
33
+ });
29
34
  }
30
35
  parseString(input) {
31
- if (!input.startsWith("hsl")) {
36
+ if (!this.accepts(input)) {
32
37
  return;
33
38
  }
34
- const regex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
39
+ const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
35
40
  return result
36
41
  ? hslaToRgba({
37
42
  a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
38
- h: parseInt(result[HslIndexes.h], radix),
39
- l: parseInt(result[HslIndexes.l], radix),
40
- s: parseInt(result[HslIndexes.s], radix),
43
+ h: parseInt(result[HslIndexes.h] ?? "0", radix),
44
+ l: parseInt(result[HslIndexes.l] ?? "0", radix),
45
+ s: parseInt(result[HslIndexes.s] ?? "0", radix),
41
46
  })
42
47
  : undefined;
43
48
  }
package/browser/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { HslColorManager } from "./HslColorManager.js";
2
- export async function loadHslColorPlugin(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addColorManager(new HslColorManager(), refresh);
1
+ export function loadHslColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { HslColorManager } = await import("./HslColorManager.js");
5
+ e.addColorManager(new HslColorManager());
6
+ });
5
7
  }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HslColorManager = void 0;
4
- const engine_1 = require("@tsparticles/engine");
1
+ import { getRangeValue, hslToRgb, hslaToRgba, parseAlpha, } from "@tsparticles/engine";
5
2
  var HslIndexes;
6
3
  (function (HslIndexes) {
7
4
  HslIndexes[HslIndexes["h"] = 1] = "h";
@@ -9,40 +6,44 @@ var HslIndexes;
9
6
  HslIndexes[HslIndexes["l"] = 3] = "l";
10
7
  HslIndexes[HslIndexes["a"] = 5] = "a";
11
8
  })(HslIndexes || (HslIndexes = {}));
12
- class HslColorManager {
9
+ const hslRegex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;
10
+ export class HslColorManager {
13
11
  constructor() {
14
12
  this.key = "hsl";
15
- this.stringPrefix = "hsl";
13
+ }
14
+ accepts(input) {
15
+ return input.startsWith("hsl");
16
16
  }
17
17
  handleColor(color) {
18
18
  const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
19
- if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
20
- return (0, engine_1.hslToRgb)(hslColor);
19
+ if (!Object.hasOwn(hslColor, "h") && !Object.hasOwn(hslColor, "s") && !Object.hasOwn(hslColor, "l")) {
20
+ return;
21
21
  }
22
+ return hslToRgb(hslColor);
22
23
  }
23
24
  handleRangeColor(color) {
24
25
  const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
25
- if (hslColor.h !== undefined && hslColor.l !== undefined) {
26
- return (0, engine_1.hslToRgb)({
27
- h: (0, engine_1.getRangeValue)(hslColor.h),
28
- l: (0, engine_1.getRangeValue)(hslColor.l),
29
- s: (0, engine_1.getRangeValue)(hslColor.s),
30
- });
26
+ if (!Object.hasOwn(hslColor, "h") && !Object.hasOwn(hslColor, "s") && !Object.hasOwn(hslColor, "l")) {
27
+ return;
31
28
  }
29
+ return hslToRgb({
30
+ h: getRangeValue(hslColor.h),
31
+ l: getRangeValue(hslColor.l),
32
+ s: getRangeValue(hslColor.s),
33
+ });
32
34
  }
33
35
  parseString(input) {
34
- if (!input.startsWith("hsl")) {
36
+ if (!this.accepts(input)) {
35
37
  return;
36
38
  }
37
- const regex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
39
+ const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
38
40
  return result
39
- ? (0, engine_1.hslaToRgba)({
40
- a: result.length > minLength ? (0, engine_1.parseAlpha)(result[HslIndexes.a]) : defaultAlpha,
41
- h: parseInt(result[HslIndexes.h], radix),
42
- l: parseInt(result[HslIndexes.l], radix),
43
- s: parseInt(result[HslIndexes.s], radix),
41
+ ? hslaToRgba({
42
+ a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
43
+ h: parseInt(result[HslIndexes.h] ?? "0", radix),
44
+ l: parseInt(result[HslIndexes.l] ?? "0", radix),
45
+ s: parseInt(result[HslIndexes.s] ?? "0", radix),
44
46
  })
45
47
  : undefined;
46
48
  }
47
49
  }
48
- exports.HslColorManager = HslColorManager;
package/cjs/index.js CHANGED
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadHslColorPlugin = loadHslColorPlugin;
4
- const HslColorManager_js_1 = require("./HslColorManager.js");
5
- async function loadHslColorPlugin(engine, refresh = true) {
6
- engine.checkVersion("3.9.1");
7
- await engine.addColorManager(new HslColorManager_js_1.HslColorManager(), refresh);
1
+ export function loadHslColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { HslColorManager } = await import("./HslColorManager.js");
5
+ e.addColorManager(new HslColorManager());
6
+ });
8
7
  }
@@ -0,0 +1,30 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.0
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_plugin_hsl_color"] = this["webpackChunk_tsparticles_plugin_hsl_color"] || []).push([["dist_browser_HslColorManager_js"],{
19
+
20
+ /***/ "./dist/browser/HslColorManager.js"
21
+ /*!*****************************************!*\
22
+ !*** ./dist/browser/HslColorManager.js ***!
23
+ \*****************************************/
24
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
25
+
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ HslColorManager: () => (/* binding */ HslColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nvar HslIndexes;\n(function (HslIndexes) {\n HslIndexes[HslIndexes[\"h\"] = 1] = \"h\";\n HslIndexes[HslIndexes[\"s\"] = 2] = \"s\";\n HslIndexes[HslIndexes[\"l\"] = 3] = \"l\";\n HslIndexes[HslIndexes[\"a\"] = 5] = \"a\";\n})(HslIndexes || (HslIndexes = {}));\nconst hslRegex = /hsla?\\(\\s*(\\d+)\\s*[\\s,]\\s*(\\d+)%\\s*[\\s,]\\s*(\\d+)%\\s*([\\s,]\\s*(0|1|0?\\.\\d+|(\\d{1,3})%)\\s*)?\\)/i;\nclass HslColorManager {\n constructor() {\n this.key = \"hsl\";\n }\n accepts(input) {\n return input.startsWith(\"hsl\");\n }\n handleColor(color) {\n const colorValue = color.value,\n hslColor = colorValue.hsl ?? color.value;\n if (!Object.hasOwn(hslColor, \"h\") && !Object.hasOwn(hslColor, \"s\") && !Object.hasOwn(hslColor, \"l\")) {\n return;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.hslToRgb)(hslColor);\n }\n handleRangeColor(color) {\n const colorValue = color.value,\n hslColor = colorValue.hsl ?? color.value;\n if (!Object.hasOwn(hslColor, \"h\") && !Object.hasOwn(hslColor, \"s\") && !Object.hasOwn(hslColor, \"l\")) {\n return;\n }\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.hslToRgb)({\n h: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(hslColor.h),\n l: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(hslColor.l),\n s: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(hslColor.s)\n });\n }\n parseString(input) {\n if (!this.accepts(input)) {\n return;\n }\n const result = hslRegex.exec(input),\n minLength = 4,\n defaultAlpha = 1,\n radix = 10;\n return result ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.hslaToRgba)({\n a: result.length > minLength ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[HslIndexes.a]) : defaultAlpha,\n h: parseInt(result[HslIndexes.h] ?? \"0\", radix),\n l: parseInt(result[HslIndexes.l] ?? \"0\", radix),\n s: parseInt(result[HslIndexes.s] ?? \"0\", radix)\n }) : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-hsl-color/./dist/browser/HslColorManager.js?\n}");
27
+
28
+ /***/ }
29
+
30
+ }]);
@@ -6,38 +6,43 @@ var HslIndexes;
6
6
  HslIndexes[HslIndexes["l"] = 3] = "l";
7
7
  HslIndexes[HslIndexes["a"] = 5] = "a";
8
8
  })(HslIndexes || (HslIndexes = {}));
9
+ const hslRegex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;
9
10
  export class HslColorManager {
10
11
  constructor() {
11
12
  this.key = "hsl";
12
- this.stringPrefix = "hsl";
13
+ }
14
+ accepts(input) {
15
+ return input.startsWith("hsl");
13
16
  }
14
17
  handleColor(color) {
15
18
  const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
16
- if (hslColor.h !== undefined && hslColor.s !== undefined && hslColor.l !== undefined) {
17
- return hslToRgb(hslColor);
19
+ if (!Object.hasOwn(hslColor, "h") && !Object.hasOwn(hslColor, "s") && !Object.hasOwn(hslColor, "l")) {
20
+ return;
18
21
  }
22
+ return hslToRgb(hslColor);
19
23
  }
20
24
  handleRangeColor(color) {
21
25
  const colorValue = color.value, hslColor = colorValue.hsl ?? color.value;
22
- if (hslColor.h !== undefined && hslColor.l !== undefined) {
23
- return hslToRgb({
24
- h: getRangeValue(hslColor.h),
25
- l: getRangeValue(hslColor.l),
26
- s: getRangeValue(hslColor.s),
27
- });
26
+ if (!Object.hasOwn(hslColor, "h") && !Object.hasOwn(hslColor, "s") && !Object.hasOwn(hslColor, "l")) {
27
+ return;
28
28
  }
29
+ return hslToRgb({
30
+ h: getRangeValue(hslColor.h),
31
+ l: getRangeValue(hslColor.l),
32
+ s: getRangeValue(hslColor.s),
33
+ });
29
34
  }
30
35
  parseString(input) {
31
- if (!input.startsWith("hsl")) {
36
+ if (!this.accepts(input)) {
32
37
  return;
33
38
  }
34
- const regex = /hsla?\(\s*(\d+)\s*[\s,]\s*(\d+)%\s*[\s,]\s*(\d+)%\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
39
+ const result = hslRegex.exec(input), minLength = 4, defaultAlpha = 1, radix = 10;
35
40
  return result
36
41
  ? hslaToRgba({
37
42
  a: result.length > minLength ? parseAlpha(result[HslIndexes.a]) : defaultAlpha,
38
- h: parseInt(result[HslIndexes.h], radix),
39
- l: parseInt(result[HslIndexes.l], radix),
40
- s: parseInt(result[HslIndexes.s], radix),
43
+ h: parseInt(result[HslIndexes.h] ?? "0", radix),
44
+ l: parseInt(result[HslIndexes.l] ?? "0", radix),
45
+ s: parseInt(result[HslIndexes.s] ?? "0", radix),
41
46
  })
42
47
  : undefined;
43
48
  }
package/esm/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { HslColorManager } from "./HslColorManager.js";
2
- export async function loadHslColorPlugin(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addColorManager(new HslColorManager(), refresh);
1
+ export function loadHslColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { HslColorManager } = await import("./HslColorManager.js");
5
+ e.addColorManager(new HslColorManager());
6
+ });
5
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-hsl-color",
3
- "version": "3.9.1",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "tsParticles HSL color plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -100,9 +100,10 @@
100
100
  "./package.json": "./package.json"
101
101
  },
102
102
  "dependencies": {
103
- "@tsparticles/engine": "3.9.1"
103
+ "@tsparticles/engine": "4.0.0-alpha.0"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"
107
- }
107
+ },
108
+ "type": "module"
108
109
  }