@tsparticles/plugin-hex-color 3.7.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.
@@ -0,0 +1,138 @@
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
+ * v3.7.0
8
+ */
9
+ /*
10
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
+ * This devtool is neither made for production nor for readable output files.
12
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
13
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
+ * or disable the default devtool with "devtool: false".
15
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
16
+ */
17
+ (function webpackUniversalModuleDefinition(root, factory) {
18
+ if(typeof exports === 'object' && typeof module === 'object')
19
+ module.exports = factory(require("@tsparticles/engine"));
20
+ else if(typeof define === 'function' && define.amd)
21
+ define(["@tsparticles/engine"], factory);
22
+ else {
23
+ var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
24
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
25
+ }
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
27
+ return /******/ (() => { // webpackBootstrap
28
+ /******/ "use strict";
29
+ /******/ var __webpack_modules__ = ({
30
+
31
+ /***/ "./dist/browser/HexColorManager.js":
32
+ /*!*****************************************!*\
33
+ !*** ./dist/browser/HexColorManager.js ***!
34
+ \*****************************************/
35
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
+
37
+ 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 this.stringPrefix = \"#\";\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\") {\n return;\n }\n if (!hexColor?.startsWith(this.stringPrefix)) {\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] !== undefined ? parseInt(result[RgbIndexes.a], hexRadix) / alphaFactor : defaultAlpha,\n b: parseInt(result[RgbIndexes.b], hexRadix),\n g: parseInt(result[RgbIndexes.g], hexRadix),\n r: parseInt(result[RgbIndexes.r], hexRadix)\n } : undefined;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-hex-color/./dist/browser/HexColorManager.js?");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "./dist/browser/index.js":
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
46
+
47
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadHexColorPlugin: () => (/* binding */ loadHexColorPlugin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _HexColorManager_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HexColorManager.js */ \"./dist/browser/HexColorManager.js\");\n\n\nasync function loadHexColorPlugin(engine, refresh = true) {\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.assertValidVersion)(engine, \"3.7.0\");\n await engine.addColorManager(new _HexColorManager_js__WEBPACK_IMPORTED_MODULE_1__.HexColorManager(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-hex-color/./dist/browser/index.js?");
48
+
49
+ /***/ }),
50
+
51
+ /***/ "@tsparticles/engine":
52
+ /*!*********************************************************************************************************************************!*\
53
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
54
+ \*********************************************************************************************************************************/
55
+ /***/ ((module) => {
56
+
57
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
58
+
59
+ /***/ })
60
+
61
+ /******/ });
62
+ /************************************************************************/
63
+ /******/ // The module cache
64
+ /******/ var __webpack_module_cache__ = {};
65
+ /******/
66
+ /******/ // The require function
67
+ /******/ function __webpack_require__(moduleId) {
68
+ /******/ // Check if module is in cache
69
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
70
+ /******/ if (cachedModule !== undefined) {
71
+ /******/ return cachedModule.exports;
72
+ /******/ }
73
+ /******/ // Create a new module (and put it into the cache)
74
+ /******/ var module = __webpack_module_cache__[moduleId] = {
75
+ /******/ // no module.id needed
76
+ /******/ // no module.loaded needed
77
+ /******/ exports: {}
78
+ /******/ };
79
+ /******/
80
+ /******/ // Execute the module function
81
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
82
+ /******/
83
+ /******/ // Return the exports of the module
84
+ /******/ return module.exports;
85
+ /******/ }
86
+ /******/
87
+ /************************************************************************/
88
+ /******/ /* webpack/runtime/compat get default export */
89
+ /******/ (() => {
90
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
91
+ /******/ __webpack_require__.n = (module) => {
92
+ /******/ var getter = module && module.__esModule ?
93
+ /******/ () => (module['default']) :
94
+ /******/ () => (module);
95
+ /******/ __webpack_require__.d(getter, { a: getter });
96
+ /******/ return getter;
97
+ /******/ };
98
+ /******/ })();
99
+ /******/
100
+ /******/ /* webpack/runtime/define property getters */
101
+ /******/ (() => {
102
+ /******/ // define getter functions for harmony exports
103
+ /******/ __webpack_require__.d = (exports, definition) => {
104
+ /******/ for(var key in definition) {
105
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
106
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
107
+ /******/ }
108
+ /******/ }
109
+ /******/ };
110
+ /******/ })();
111
+ /******/
112
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
113
+ /******/ (() => {
114
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
115
+ /******/ })();
116
+ /******/
117
+ /******/ /* webpack/runtime/make namespace object */
118
+ /******/ (() => {
119
+ /******/ // define __esModule on exports
120
+ /******/ __webpack_require__.r = (exports) => {
121
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
122
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
123
+ /******/ }
124
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
125
+ /******/ };
126
+ /******/ })();
127
+ /******/
128
+ /************************************************************************/
129
+ /******/
130
+ /******/ // startup
131
+ /******/ // Load entry module and return exports
132
+ /******/ // This entry module can't be inlined because the eval devtool is used.
133
+ /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
134
+ /******/
135
+ /******/ return __webpack_exports__;
136
+ /******/ })()
137
+ ;
138
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.plugin.hexColor.min.js.LICENSE.txt */
2
+ !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],r);else{var t="object"==typeof exports?r(require("@tsparticles/engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{var r={303:r=>{r.exports=e}},t={};function o(e){var n=t[e];if(void 0!==n)return n.exports;var a=t[e]={exports:{}};return r[e](a,a.exports,o),a.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};o.r(n),o.d(n,{loadHexColorPlugin:()=>d});var a,i=o(303);!function(e){e[e.r=1]="r",e[e.g=2]="g",e[e.b=3]="b",e[e.a=4]="a"}(a||(a={}));const s=/^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,f=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;class p{constructor(){this.key="hex",this.stringPrefix="#"}handleColor(e){return this._parseString(e.value)}handleRangeColor(e){return this._parseString(e.value)}parseString(e){return this._parseString(e)}_parseString(e){if("string"!=typeof e)return;if(!e?.startsWith(this.stringPrefix))return;const r=e.replace(s,((e,r,t,o,n)=>r+r+t+t+o+o+(void 0!==n?n+n:""))),t=f.exec(r);return t?{a:void 0!==t[a.a]?parseInt(t[a.a],16)/255:1,b:parseInt(t[a.b],16),g:parseInt(t[a.g],16),r:parseInt(t[a.r],16)}:void 0}}async function d(e,r=!0){(0,i.assertValidVersion)(e,"3.7.0"),await e.addColorManager(new p,r)}return n})()));
@@ -0,0 +1 @@
1
+ /*! tsParticles Hex Color Plugin v3.7.0 by Matteo Bruni */
@@ -0,0 +1,10 @@
1
+ import type { IColor, IColorManager, IRangeColor, IRgb, IRgba } from "@tsparticles/engine";
2
+ export declare class HexColorManager implements IColorManager {
3
+ readonly key: string;
4
+ readonly stringPrefix: string;
5
+ constructor();
6
+ handleColor(color: IColor): IRgb | undefined;
7
+ handleRangeColor(color: IRangeColor): IRgb | undefined;
8
+ parseString(input: string): IRgba | undefined;
9
+ private _parseString;
10
+ }
@@ -0,0 +1,2 @@
1
+ import { type Engine } from "@tsparticles/engine";
2
+ export declare function loadHexColorPlugin(engine: Engine, refresh?: boolean): Promise<void>;
@@ -0,0 +1,58 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HexColorManager = void 0;
13
+ var RgbIndexes;
14
+ (function (RgbIndexes) {
15
+ RgbIndexes[RgbIndexes["r"] = 1] = "r";
16
+ RgbIndexes[RgbIndexes["g"] = 2] = "g";
17
+ RgbIndexes[RgbIndexes["b"] = 3] = "b";
18
+ RgbIndexes[RgbIndexes["a"] = 4] = "a";
19
+ })(RgbIndexes || (RgbIndexes = {}));
20
+ 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;
21
+ class HexColorManager {
22
+ constructor() {
23
+ this.key = "hex";
24
+ this.stringPrefix = "#";
25
+ }
26
+ handleColor(color) {
27
+ return this._parseString(color.value);
28
+ }
29
+ handleRangeColor(color) {
30
+ return this._parseString(color.value);
31
+ }
32
+ parseString(input) {
33
+ return this._parseString(input);
34
+ }
35
+ _parseString(hexColor) {
36
+ if (typeof hexColor !== "string") {
37
+ return;
38
+ }
39
+ if (!hexColor?.startsWith(this.stringPrefix)) {
40
+ return;
41
+ }
42
+ const hexFixed = hexColor.replace(shorthandHexRegex, (_, r, g, b, a) => {
43
+ return r + r + g + g + b + b + (a !== undefined ? a + a : "");
44
+ }), result = hexRegex.exec(hexFixed);
45
+ return result
46
+ ? {
47
+ a: result[RgbIndexes.a] !== undefined
48
+ ? parseInt(result[RgbIndexes.a], hexRadix) / alphaFactor
49
+ : defaultAlpha,
50
+ b: parseInt(result[RgbIndexes.b], hexRadix),
51
+ g: parseInt(result[RgbIndexes.g], hexRadix),
52
+ r: parseInt(result[RgbIndexes.r], hexRadix),
53
+ }
54
+ : undefined;
55
+ }
56
+ }
57
+ exports.HexColorManager = HexColorManager;
58
+ });
package/umd/index.js ADDED
@@ -0,0 +1,19 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "@tsparticles/engine", "./HexColorManager.js"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.loadHexColorPlugin = loadHexColorPlugin;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ const HexColorManager_js_1 = require("./HexColorManager.js");
15
+ async function loadHexColorPlugin(engine, refresh = true) {
16
+ (0, engine_1.assertValidVersion)(engine, "3.7.0");
17
+ await engine.addColorManager(new HexColorManager_js_1.HexColorManager(), refresh);
18
+ }
19
+ });