@bhsd/common 0.6.5 → 0.6.6
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/dist/index.js +8 -1
- package/dist/index.mjs +8 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -42,8 +42,15 @@ const normalizeTitle = (title) => {
|
|
|
42
42
|
return /[<>[\]|{}]/u.test(decoded) ? decoded : decodeHTML(decoded);
|
|
43
43
|
};
|
|
44
44
|
const numToHex = (d) => Math.round(d * 255).toString(16).padStart(2, "0");
|
|
45
|
+
const regex = /* @__PURE__ */ (() => {
|
|
46
|
+
const hexColor = String.raw`#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\d_])`, rgbValue = String.raw`(?:\d*\.)?\d+%?`, hue = String.raw`(?:\d*\.)?\d+(?:deg|grad|rad|turn)?`, rgbColor = String.raw`rgba?\(\s*(?:${String.raw`${new Array(3).fill(rgbValue).join(String.raw`\s+`)}(?:\s*\/\s*${rgbValue})?`}|${String.raw`${new Array(3).fill(rgbValue).join(String.raw`\s*,\s*`)}(?:\s*,\s*${rgbValue})?`})\s*\)`, hslColor = String.raw`hsla?\(\s*(?:${String.raw`${hue}\s+${rgbValue}\s+${rgbValue}(?:\s*\/\s*${rgbValue})?`}|${String.raw`${hue}${String.raw`\s*,\s*(?:\d*\.)?\d+%`.repeat(2)}(?:\s*,\s*${rgbValue})?`})\s*\)`;
|
|
47
|
+
return {
|
|
48
|
+
full: new RegExp(String.raw`(^|[^\p{L}\d_])(${hexColor}|${rgbColor}|${hslColor})`, "giu"),
|
|
49
|
+
rgb: new RegExp(String.raw`(^|[^\p{L}\d_])(${hexColor}|${rgbColor})`, "giu")
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
45
52
|
const splitColors = (str, hsl = true) => {
|
|
46
|
-
const
|
|
53
|
+
const pieces = [], re = regex[hsl ? "full" : "rgb"];
|
|
47
54
|
re.lastIndex = 0;
|
|
48
55
|
let mt = re.exec(str), lastIndex = 0;
|
|
49
56
|
while (mt) {
|
package/dist/index.mjs
CHANGED
|
@@ -10,8 +10,15 @@ const normalizeTitle = (title) => {
|
|
|
10
10
|
return /[<>[\]|{}]/u.test(decoded) ? decoded : decodeHTML(decoded);
|
|
11
11
|
};
|
|
12
12
|
const numToHex = (d) => Math.round(d * 255).toString(16).padStart(2, "0");
|
|
13
|
+
const regex = /* @__PURE__ */ (() => {
|
|
14
|
+
const hexColor = String.raw`#(?:[\da-f]{3,4}|(?:[\da-f]{2}){3,4})(?![\p{L}\d_])`, rgbValue = String.raw`(?:\d*\.)?\d+%?`, hue = String.raw`(?:\d*\.)?\d+(?:deg|grad|rad|turn)?`, rgbColor = String.raw`rgba?\(\s*(?:${String.raw`${new Array(3).fill(rgbValue).join(String.raw`\s+`)}(?:\s*\/\s*${rgbValue})?`}|${String.raw`${new Array(3).fill(rgbValue).join(String.raw`\s*,\s*`)}(?:\s*,\s*${rgbValue})?`})\s*\)`, hslColor = String.raw`hsla?\(\s*(?:${String.raw`${hue}\s+${rgbValue}\s+${rgbValue}(?:\s*\/\s*${rgbValue})?`}|${String.raw`${hue}${String.raw`\s*,\s*(?:\d*\.)?\d+%`.repeat(2)}(?:\s*,\s*${rgbValue})?`})\s*\)`;
|
|
15
|
+
return {
|
|
16
|
+
full: new RegExp(String.raw`(^|[^\p{L}\d_])(${hexColor}|${rgbColor}|${hslColor})`, "giu"),
|
|
17
|
+
rgb: new RegExp(String.raw`(^|[^\p{L}\d_])(${hexColor}|${rgbColor})`, "giu")
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
13
20
|
const splitColors = (str, hsl = true) => {
|
|
14
|
-
const
|
|
21
|
+
const pieces = [], re = regex[hsl ? "full" : "rgb"];
|
|
15
22
|
re.lastIndex = 0;
|
|
16
23
|
let mt = re.exec(str), lastIndex = 0;
|
|
17
24
|
while (mt) {
|