@tsparticles/plugin-hex-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/69.min.js +2 -0
- package/69.min.js.LICENSE.txt +1 -0
- package/browser/HexColorManager.js +8 -11
- package/browser/index.js +6 -4
- package/cjs/HexColorManager.js +9 -16
- package/cjs/index.js +6 -7
- package/dist_browser_HexColorManager_js.js +30 -0
- package/esm/HexColorManager.js +8 -11
- package/esm/index.js +6 -4
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.plugin.hexColor.js +206 -15
- package/tsparticles.plugin.hexColor.min.js +1 -1
- package/tsparticles.plugin.hexColor.min.js.LICENSE.txt +1 -1
- package/types/HexColorManager.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/HexColorManager.js +8 -11
- package/umd/index.js +41 -5
package/69.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 69.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_plugin_hex_color=this.webpackChunk_tsparticles_plugin_hex_color||[]).push([[69],{69(r,a,t){var e;t.d(a,{HexColorManager:()=>i}),function(r){r[r.r=1]="r",r[r.g=2]="g",r[r.b=3]="b",r[r.a=4]="a"}(e||(e={}));const s=/^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;class i{constructor(){this.key="hex"}accepts(r){return r.startsWith("#")}handleColor(r){return this._parseString(r.value)}handleRangeColor(r){return this._parseString(r.value)}parseString(r){return this._parseString(r)}_parseString(r){if("string"!=typeof r||!this.accepts(r))return;const a=r.replace(s,((r,a,t,e,s)=>a+a+t+t+e+e+(void 0!==s?s+s:""))),t=n.exec(a);return t?{a:t[e.a]?parseInt(t[e.a],16)/255:1,b:parseInt(t[e.b]??"0",16),g:parseInt(t[e.g]??"0",16),r:parseInt(t[e.r]??"0",16)}:void 0}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Hex Color Plugin v4.0.0-alpha.0 by Matteo Bruni */
|
|
@@ -9,7 +9,9 @@ const shorthandHexRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i, hexRegex
|
|
|
9
9
|
export class HexColorManager {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.key = "hex";
|
|
12
|
-
|
|
12
|
+
}
|
|
13
|
+
accepts(input) {
|
|
14
|
+
return input.startsWith("#");
|
|
13
15
|
}
|
|
14
16
|
handleColor(color) {
|
|
15
17
|
return this._parseString(color.value);
|
|
@@ -21,10 +23,7 @@ export class HexColorManager {
|
|
|
21
23
|
return this._parseString(input);
|
|
22
24
|
}
|
|
23
25
|
_parseString(hexColor) {
|
|
24
|
-
if (typeof hexColor !== "string") {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (!hexColor?.startsWith(this.stringPrefix)) {
|
|
26
|
+
if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
const hexFixed = hexColor.replace(shorthandHexRegex, (_, r, g, b, a) => {
|
|
@@ -32,12 +31,10 @@ export class HexColorManager {
|
|
|
32
31
|
}), result = hexRegex.exec(hexFixed);
|
|
33
32
|
return result
|
|
34
33
|
? {
|
|
35
|
-
a: result[RgbIndexes.a]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
g: parseInt(result[RgbIndexes.g], hexRadix),
|
|
40
|
-
r: parseInt(result[RgbIndexes.r], hexRadix),
|
|
34
|
+
a: result[RgbIndexes.a] ? parseInt(result[RgbIndexes.a], hexRadix) / alphaFactor : defaultAlpha,
|
|
35
|
+
b: parseInt(result[RgbIndexes.b] ?? "0", hexRadix),
|
|
36
|
+
g: parseInt(result[RgbIndexes.g] ?? "0", hexRadix),
|
|
37
|
+
r: parseInt(result[RgbIndexes.r] ?? "0", hexRadix),
|
|
41
38
|
}
|
|
42
39
|
: undefined;
|
|
43
40
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
1
|
+
export function loadHexColorPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { HexColorManager } = await import("./HexColorManager.js");
|
|
5
|
+
e.addColorManager(new HexColorManager());
|
|
6
|
+
});
|
|
5
7
|
}
|
package/cjs/HexColorManager.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HexColorManager = void 0;
|
|
4
1
|
var RgbIndexes;
|
|
5
2
|
(function (RgbIndexes) {
|
|
6
3
|
RgbIndexes[RgbIndexes["r"] = 1] = "r";
|
|
@@ -9,10 +6,12 @@ var RgbIndexes;
|
|
|
9
6
|
RgbIndexes[RgbIndexes["a"] = 4] = "a";
|
|
10
7
|
})(RgbIndexes || (RgbIndexes = {}));
|
|
11
8
|
const shorthandHexRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i, hexRegex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i, hexRadix = 16, defaultAlpha = 1, alphaFactor = 0xff;
|
|
12
|
-
class HexColorManager {
|
|
9
|
+
export class HexColorManager {
|
|
13
10
|
constructor() {
|
|
14
11
|
this.key = "hex";
|
|
15
|
-
|
|
12
|
+
}
|
|
13
|
+
accepts(input) {
|
|
14
|
+
return input.startsWith("#");
|
|
16
15
|
}
|
|
17
16
|
handleColor(color) {
|
|
18
17
|
return this._parseString(color.value);
|
|
@@ -24,10 +23,7 @@ class HexColorManager {
|
|
|
24
23
|
return this._parseString(input);
|
|
25
24
|
}
|
|
26
25
|
_parseString(hexColor) {
|
|
27
|
-
if (typeof hexColor !== "string") {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (!hexColor?.startsWith(this.stringPrefix)) {
|
|
26
|
+
if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
|
|
31
27
|
return;
|
|
32
28
|
}
|
|
33
29
|
const hexFixed = hexColor.replace(shorthandHexRegex, (_, r, g, b, a) => {
|
|
@@ -35,14 +31,11 @@ class HexColorManager {
|
|
|
35
31
|
}), result = hexRegex.exec(hexFixed);
|
|
36
32
|
return result
|
|
37
33
|
? {
|
|
38
|
-
a: result[RgbIndexes.a]
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
g: parseInt(result[RgbIndexes.g], hexRadix),
|
|
43
|
-
r: parseInt(result[RgbIndexes.r], hexRadix),
|
|
34
|
+
a: result[RgbIndexes.a] ? parseInt(result[RgbIndexes.a], hexRadix) / alphaFactor : defaultAlpha,
|
|
35
|
+
b: parseInt(result[RgbIndexes.b] ?? "0", hexRadix),
|
|
36
|
+
g: parseInt(result[RgbIndexes.g] ?? "0", hexRadix),
|
|
37
|
+
r: parseInt(result[RgbIndexes.r] ?? "0", hexRadix),
|
|
44
38
|
}
|
|
45
39
|
: undefined;
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
|
-
exports.HexColorManager = HexColorManager;
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
await engine.addColorManager(new HexColorManager_js_1.HexColorManager(), refresh);
|
|
1
|
+
export function loadHexColorPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { HexColorManager } = await import("./HexColorManager.js");
|
|
5
|
+
e.addColorManager(new HexColorManager());
|
|
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_hex_color"] = this["webpackChunk_tsparticles_plugin_hex_color"] || []).push([["dist_browser_HexColorManager_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/HexColorManager.js"
|
|
21
|
+
/*!*****************************************!*\
|
|
22
|
+
!*** ./dist/browser/HexColorManager.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 */ HexColorManager: () => (/* binding */ HexColorManager)\n/* harmony export */ });\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\"] = 4] = \"a\";\n})(RgbIndexes || (RgbIndexes = {}));\nconst shorthandHexRegex = /^#?([a-f\\d])([a-f\\d])([a-f\\d])([a-f\\d])?$/i,\n hexRegex = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})?$/i,\n hexRadix = 16,\n defaultAlpha = 1,\n alphaFactor = 0xff;\nclass HexColorManager {\n constructor() {\n this.key = \"hex\";\n }\n accepts(input) {\n return input.startsWith(\"#\");\n }\n handleColor(color) {\n return this._parseString(color.value);\n }\n handleRangeColor(color) {\n return this._parseString(color.value);\n }\n parseString(input) {\n return this._parseString(input);\n }\n _parseString(hexColor) {\n if (typeof hexColor !== \"string\" || !this.accepts(hexColor)) {\n return;\n }\n const hexFixed = hexColor.replace(shorthandHexRegex, (_, r, g, b, a) => {\n return r + r + g + g + b + b + (a !== undefined ? a + a : \"\");\n }),\n result = hexRegex.exec(hexFixed);\n return result ? {\n a: result[RgbIndexes.a] ? parseInt(result[RgbIndexes.a], hexRadix) / alphaFactor : defaultAlpha,\n b: parseInt(result[RgbIndexes.b] ?? \"0\", hexRadix),\n g: parseInt(result[RgbIndexes.g] ?? \"0\", hexRadix),\n r: parseInt(result[RgbIndexes.r] ?? \"0\", hexRadix)\n } : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-hex-color/./dist/browser/HexColorManager.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ }
|
|
29
|
+
|
|
30
|
+
}]);
|
package/esm/HexColorManager.js
CHANGED
|
@@ -9,7 +9,9 @@ const shorthandHexRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i, hexRegex
|
|
|
9
9
|
export class HexColorManager {
|
|
10
10
|
constructor() {
|
|
11
11
|
this.key = "hex";
|
|
12
|
-
|
|
12
|
+
}
|
|
13
|
+
accepts(input) {
|
|
14
|
+
return input.startsWith("#");
|
|
13
15
|
}
|
|
14
16
|
handleColor(color) {
|
|
15
17
|
return this._parseString(color.value);
|
|
@@ -21,10 +23,7 @@ export class HexColorManager {
|
|
|
21
23
|
return this._parseString(input);
|
|
22
24
|
}
|
|
23
25
|
_parseString(hexColor) {
|
|
24
|
-
if (typeof hexColor !== "string") {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
if (!hexColor?.startsWith(this.stringPrefix)) {
|
|
26
|
+
if (typeof hexColor !== "string" || !this.accepts(hexColor)) {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
const hexFixed = hexColor.replace(shorthandHexRegex, (_, r, g, b, a) => {
|
|
@@ -32,12 +31,10 @@ export class HexColorManager {
|
|
|
32
31
|
}), result = hexRegex.exec(hexFixed);
|
|
33
32
|
return result
|
|
34
33
|
? {
|
|
35
|
-
a: result[RgbIndexes.a]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
g: parseInt(result[RgbIndexes.g], hexRadix),
|
|
40
|
-
r: parseInt(result[RgbIndexes.r], hexRadix),
|
|
34
|
+
a: result[RgbIndexes.a] ? parseInt(result[RgbIndexes.a], hexRadix) / alphaFactor : defaultAlpha,
|
|
35
|
+
b: parseInt(result[RgbIndexes.b] ?? "0", hexRadix),
|
|
36
|
+
g: parseInt(result[RgbIndexes.g] ?? "0", hexRadix),
|
|
37
|
+
r: parseInt(result[RgbIndexes.r] ?? "0", hexRadix),
|
|
41
38
|
}
|
|
42
39
|
: undefined;
|
|
43
40
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
1
|
+
export function loadHexColorPlugin(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(async (e) => {
|
|
4
|
+
const { HexColorManager } = await import("./HexColorManager.js");
|
|
5
|
+
e.addColorManager(new HexColorManager());
|
|
6
|
+
});
|
|
5
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-hex-color",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles hex 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": "
|
|
103
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
104
104
|
},
|
|
105
105
|
"publishConfig": {
|
|
106
106
|
"access": "public"
|
|
107
|
-
}
|
|
107
|
+
},
|
|
108
|
+
"type": "module"
|
|
108
109
|
}
|