@tsparticles/plugin-rgb-color 3.9.0 → 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/379.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 379.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_rgb_color=this.webpackChunk_tsparticles_plugin_rgb_color||[]).push([[379],{379(r,e,s){s.d(e,{RgbColorManager:()=>g});var a,t=s(303);!function(r){r[r.r=1]="r",r[r.g=2]="g",r[r.b=3]="b",r[r.a=5]="a"}(a||(a={}));const n=/rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;class g{constructor(){this.key="rgb"}accepts(r){return r.startsWith("rgb")}handleColor(r){const e=r.value.rgb??r.value;if(Object.hasOwn(e,"r"))return e}handleRangeColor(r){const e=r.value.rgb??r.value;if(Object.hasOwn(e,"r"))return{r:(0,t.getRangeValue)(e.r),g:(0,t.getRangeValue)(e.g),b:(0,t.getRangeValue)(e.b)}}parseString(r){if(!this.accepts(r))return;const e=n.exec(r);return e?{a:e.length>4?(0,t.parseAlpha)(e[a.a]):1,b:parseInt(e[a.b]??"0",10),g:parseInt(e[a.g]??"0",10),r:parseInt(e[a.r]??"0",10)}:void 0}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles RGB Color Plugin v4.0.0-alpha.0 by Matteo Bruni */
@@ -6,38 +6,43 @@ var RgbIndexes;
6
6
  RgbIndexes[RgbIndexes["b"] = 3] = "b";
7
7
  RgbIndexes[RgbIndexes["a"] = 5] = "a";
8
8
  })(RgbIndexes || (RgbIndexes = {}));
9
+ const rgbRegex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;
9
10
  export class RgbColorManager {
10
11
  constructor() {
11
12
  this.key = "rgb";
12
- this.stringPrefix = "rgb";
13
+ }
14
+ accepts(input) {
15
+ return input.startsWith("rgb");
13
16
  }
14
17
  handleColor(color) {
15
18
  const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
16
- if (rgbColor.r !== undefined) {
17
- return rgbColor;
19
+ if (!Object.hasOwn(rgbColor, "r")) {
20
+ return;
18
21
  }
22
+ return rgbColor;
19
23
  }
20
24
  handleRangeColor(color) {
21
25
  const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
22
- if (rgbColor.r !== undefined) {
23
- return {
24
- r: getRangeValue(rgbColor.r),
25
- g: getRangeValue(rgbColor.g),
26
- b: getRangeValue(rgbColor.b),
27
- };
26
+ if (!Object.hasOwn(rgbColor, "r")) {
27
+ return;
28
28
  }
29
+ return {
30
+ r: getRangeValue(rgbColor.r),
31
+ g: getRangeValue(rgbColor.g),
32
+ b: getRangeValue(rgbColor.b),
33
+ };
29
34
  }
30
35
  parseString(input) {
31
- if (!input.startsWith(this.stringPrefix)) {
36
+ if (!this.accepts(input)) {
32
37
  return;
33
38
  }
34
- const regex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
39
+ const result = rgbRegex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
35
40
  return result
36
41
  ? {
37
42
  a: result.length > minLength ? parseAlpha(result[RgbIndexes.a]) : defaultAlpha,
38
- b: parseInt(result[RgbIndexes.b], radix),
39
- g: parseInt(result[RgbIndexes.g], radix),
40
- r: parseInt(result[RgbIndexes.r], radix),
43
+ b: parseInt(result[RgbIndexes.b] ?? "0", radix),
44
+ g: parseInt(result[RgbIndexes.g] ?? "0", radix),
45
+ r: parseInt(result[RgbIndexes.r] ?? "0", radix),
41
46
  }
42
47
  : undefined;
43
48
  }
package/browser/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { RgbColorManager } from "./RgbColorManager.js";
2
- export async function loadRgbColorPlugin(engine, refresh = true) {
3
- engine.checkVersion("3.9.0");
4
- await engine.addColorManager(new RgbColorManager(), refresh);
1
+ export function loadRgbColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { RgbColorManager } = await import("./RgbColorManager.js");
5
+ e.addColorManager(new RgbColorManager());
6
+ });
5
7
  }
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RgbColorManager = void 0;
4
- const engine_1 = require("@tsparticles/engine");
1
+ import { getRangeValue, parseAlpha, } from "@tsparticles/engine";
5
2
  var RgbIndexes;
6
3
  (function (RgbIndexes) {
7
4
  RgbIndexes[RgbIndexes["r"] = 1] = "r";
@@ -9,40 +6,44 @@ var RgbIndexes;
9
6
  RgbIndexes[RgbIndexes["b"] = 3] = "b";
10
7
  RgbIndexes[RgbIndexes["a"] = 5] = "a";
11
8
  })(RgbIndexes || (RgbIndexes = {}));
12
- class RgbColorManager {
9
+ const rgbRegex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;
10
+ export class RgbColorManager {
13
11
  constructor() {
14
12
  this.key = "rgb";
15
- this.stringPrefix = "rgb";
13
+ }
14
+ accepts(input) {
15
+ return input.startsWith("rgb");
16
16
  }
17
17
  handleColor(color) {
18
18
  const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
19
- if (rgbColor.r !== undefined) {
20
- return rgbColor;
19
+ if (!Object.hasOwn(rgbColor, "r")) {
20
+ return;
21
21
  }
22
+ return rgbColor;
22
23
  }
23
24
  handleRangeColor(color) {
24
25
  const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
25
- if (rgbColor.r !== undefined) {
26
- return {
27
- r: (0, engine_1.getRangeValue)(rgbColor.r),
28
- g: (0, engine_1.getRangeValue)(rgbColor.g),
29
- b: (0, engine_1.getRangeValue)(rgbColor.b),
30
- };
26
+ if (!Object.hasOwn(rgbColor, "r")) {
27
+ return;
31
28
  }
29
+ return {
30
+ r: getRangeValue(rgbColor.r),
31
+ g: getRangeValue(rgbColor.g),
32
+ b: getRangeValue(rgbColor.b),
33
+ };
32
34
  }
33
35
  parseString(input) {
34
- if (!input.startsWith(this.stringPrefix)) {
36
+ if (!this.accepts(input)) {
35
37
  return;
36
38
  }
37
- const regex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
39
+ const result = rgbRegex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
38
40
  return result
39
41
  ? {
40
- a: result.length > minLength ? (0, engine_1.parseAlpha)(result[RgbIndexes.a]) : defaultAlpha,
41
- b: parseInt(result[RgbIndexes.b], radix),
42
- g: parseInt(result[RgbIndexes.g], radix),
43
- r: parseInt(result[RgbIndexes.r], radix),
42
+ a: result.length > minLength ? parseAlpha(result[RgbIndexes.a]) : defaultAlpha,
43
+ b: parseInt(result[RgbIndexes.b] ?? "0", radix),
44
+ g: parseInt(result[RgbIndexes.g] ?? "0", radix),
45
+ r: parseInt(result[RgbIndexes.r] ?? "0", radix),
44
46
  }
45
47
  : undefined;
46
48
  }
47
49
  }
48
- exports.RgbColorManager = RgbColorManager;
package/cjs/index.js CHANGED
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadRgbColorPlugin = loadRgbColorPlugin;
4
- const RgbColorManager_js_1 = require("./RgbColorManager.js");
5
- async function loadRgbColorPlugin(engine, refresh = true) {
6
- engine.checkVersion("3.9.0");
7
- await engine.addColorManager(new RgbColorManager_js_1.RgbColorManager(), refresh);
1
+ export function loadRgbColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { RgbColorManager } = await import("./RgbColorManager.js");
5
+ e.addColorManager(new RgbColorManager());
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_rgb_color"] = this["webpackChunk_tsparticles_plugin_rgb_color"] || []).push([["dist_browser_RgbColorManager_js"],{
19
+
20
+ /***/ "./dist/browser/RgbColorManager.js"
21
+ /*!*****************************************!*\
22
+ !*** ./dist/browser/RgbColorManager.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 */ RgbColorManager: () => (/* binding */ RgbColorManager)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nvar RgbIndexes;\n(function (RgbIndexes) {\n RgbIndexes[RgbIndexes[\"r\"] = 1] = \"r\";\n RgbIndexes[RgbIndexes[\"g\"] = 2] = \"g\";\n RgbIndexes[RgbIndexes[\"b\"] = 3] = \"b\";\n RgbIndexes[RgbIndexes[\"a\"] = 5] = \"a\";\n})(RgbIndexes || (RgbIndexes = {}));\nconst rgbRegex = /rgba?\\(\\s*(\\d{1,3})\\s*[\\s,]\\s*(\\d{1,3})\\s*[\\s,]\\s*(\\d{1,3})\\s*([\\s,]\\s*(0|1|0?\\.\\d+|(\\d{1,3})%)\\s*)?\\)/i;\nclass RgbColorManager {\n constructor() {\n this.key = \"rgb\";\n }\n accepts(input) {\n return input.startsWith(\"rgb\");\n }\n handleColor(color) {\n const colorValue = color.value,\n rgbColor = colorValue.rgb ?? color.value;\n if (!Object.hasOwn(rgbColor, \"r\")) {\n return;\n }\n return rgbColor;\n }\n handleRangeColor(color) {\n const colorValue = color.value,\n rgbColor = colorValue.rgb ?? color.value;\n if (!Object.hasOwn(rgbColor, \"r\")) {\n return;\n }\n return {\n r: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rgbColor.r),\n g: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rgbColor.g),\n b: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rgbColor.b)\n };\n }\n parseString(input) {\n if (!this.accepts(input)) {\n return;\n }\n const result = rgbRegex.exec(input),\n radix = 10,\n minLength = 4,\n defaultAlpha = 1;\n return result ? {\n a: result.length > minLength ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.parseAlpha)(result[RgbIndexes.a]) : defaultAlpha,\n b: parseInt(result[RgbIndexes.b] ?? \"0\", radix),\n g: parseInt(result[RgbIndexes.g] ?? \"0\", radix),\n r: parseInt(result[RgbIndexes.r] ?? \"0\", radix)\n } : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-rgb-color/./dist/browser/RgbColorManager.js?\n}");
27
+
28
+ /***/ }
29
+
30
+ }]);
@@ -6,38 +6,43 @@ var RgbIndexes;
6
6
  RgbIndexes[RgbIndexes["b"] = 3] = "b";
7
7
  RgbIndexes[RgbIndexes["a"] = 5] = "a";
8
8
  })(RgbIndexes || (RgbIndexes = {}));
9
+ const rgbRegex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i;
9
10
  export class RgbColorManager {
10
11
  constructor() {
11
12
  this.key = "rgb";
12
- this.stringPrefix = "rgb";
13
+ }
14
+ accepts(input) {
15
+ return input.startsWith("rgb");
13
16
  }
14
17
  handleColor(color) {
15
18
  const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
16
- if (rgbColor.r !== undefined) {
17
- return rgbColor;
19
+ if (!Object.hasOwn(rgbColor, "r")) {
20
+ return;
18
21
  }
22
+ return rgbColor;
19
23
  }
20
24
  handleRangeColor(color) {
21
25
  const colorValue = color.value, rgbColor = colorValue.rgb ?? color.value;
22
- if (rgbColor.r !== undefined) {
23
- return {
24
- r: getRangeValue(rgbColor.r),
25
- g: getRangeValue(rgbColor.g),
26
- b: getRangeValue(rgbColor.b),
27
- };
26
+ if (!Object.hasOwn(rgbColor, "r")) {
27
+ return;
28
28
  }
29
+ return {
30
+ r: getRangeValue(rgbColor.r),
31
+ g: getRangeValue(rgbColor.g),
32
+ b: getRangeValue(rgbColor.b),
33
+ };
29
34
  }
30
35
  parseString(input) {
31
- if (!input.startsWith(this.stringPrefix)) {
36
+ if (!this.accepts(input)) {
32
37
  return;
33
38
  }
34
- const regex = /rgba?\(\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*[\s,]\s*(\d{1,3})\s*([\s,]\s*(0|1|0?\.\d+|(\d{1,3})%)\s*)?\)/i, result = regex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
39
+ const result = rgbRegex.exec(input), radix = 10, minLength = 4, defaultAlpha = 1;
35
40
  return result
36
41
  ? {
37
42
  a: result.length > minLength ? parseAlpha(result[RgbIndexes.a]) : defaultAlpha,
38
- b: parseInt(result[RgbIndexes.b], radix),
39
- g: parseInt(result[RgbIndexes.g], radix),
40
- r: parseInt(result[RgbIndexes.r], radix),
43
+ b: parseInt(result[RgbIndexes.b] ?? "0", radix),
44
+ g: parseInt(result[RgbIndexes.g] ?? "0", radix),
45
+ r: parseInt(result[RgbIndexes.r] ?? "0", radix),
41
46
  }
42
47
  : undefined;
43
48
  }
package/esm/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { RgbColorManager } from "./RgbColorManager.js";
2
- export async function loadRgbColorPlugin(engine, refresh = true) {
3
- engine.checkVersion("3.9.0");
4
- await engine.addColorManager(new RgbColorManager(), refresh);
1
+ export function loadRgbColorPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { RgbColorManager } = await import("./RgbColorManager.js");
5
+ e.addColorManager(new RgbColorManager());
6
+ });
5
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-rgb-color",
3
- "version": "3.9.0",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "tsParticles RGB 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.0"
103
+ "@tsparticles/engine": "4.0.0-alpha.0"
104
104
  },
105
105
  "publishConfig": {
106
106
  "access": "public"
107
- }
107
+ },
108
+ "type": "module"
108
109
  }