Spaces:
Paused
Paused
Upload folder using huggingface_hub (part 6)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- node_modules/@babel/types/lib/validators/isVar.js +15 -0
- node_modules/@babel/types/lib/validators/isVar.js.map +1 -0
- node_modules/@babel/types/lib/validators/matchesPattern.js +44 -0
- node_modules/@babel/types/lib/validators/matchesPattern.js.map +1 -0
- node_modules/@babel/types/lib/validators/react/isCompatTag.js +11 -0
- node_modules/@babel/types/lib/validators/react/isCompatTag.js.map +1 -0
- node_modules/@babel/types/lib/validators/react/isReactComponent.js +11 -0
- node_modules/@babel/types/lib/validators/react/isReactComponent.js.map +1 -0
- node_modules/@babel/types/lib/validators/validate.js +42 -0
- node_modules/@babel/types/lib/validators/validate.js.map +1 -0
- node_modules/@babel/types/package.json +39 -0
- node_modules/@bcoe/v8-coverage/LICENSE.md +21 -0
- node_modules/@bcoe/v8-coverage/LICENSE.txt +14 -0
- node_modules/@bcoe/v8-coverage/README.md +11 -0
- node_modules/@bcoe/v8-coverage/package.json +29 -0
- node_modules/@bcoe/v8-coverage/src/lib/ascii.js +145 -0
- node_modules/@bcoe/v8-coverage/src/lib/clone.js +75 -0
- node_modules/@bcoe/v8-coverage/src/lib/compare.js +44 -0
- node_modules/@bcoe/v8-coverage/src/lib/index.js +41 -0
- node_modules/@bcoe/v8-coverage/src/lib/merge.js +353 -0
- node_modules/@bcoe/v8-coverage/src/lib/normalize.js +96 -0
- node_modules/@bcoe/v8-coverage/src/lib/range-tree.js +157 -0
- node_modules/@borewit/text-codec/LICENSE.txt +9 -0
- node_modules/@borewit/text-codec/README.md +87 -0
- node_modules/@borewit/text-codec/lib/index.d.ts +6 -0
- node_modules/@borewit/text-codec/lib/index.js +380 -0
- node_modules/@borewit/text-codec/package.json +70 -0
- node_modules/@bramus/specificity/LICENSE +19 -0
- node_modules/@bramus/specificity/README.md +164 -0
- node_modules/@bramus/specificity/bin/cli.js +14 -0
- node_modules/@bramus/specificity/dist/index.cjs +8 -0
- node_modules/@bramus/specificity/dist/index.cjs.map +0 -0
- node_modules/@bramus/specificity/dist/index.js +8 -0
- node_modules/@bramus/specificity/dist/index.js.map +0 -0
- node_modules/@bramus/specificity/index.d.ts +59 -0
- node_modules/@bramus/specificity/package.json +92 -0
- node_modules/@bramus/specificity/src/core/calculate.js +260 -0
- node_modules/@bramus/specificity/src/core/index.js +1 -0
- node_modules/@bramus/specificity/src/index.js +135 -0
- node_modules/@bramus/specificity/src/util/compare.js +23 -0
- node_modules/@bramus/specificity/src/util/filter.js +13 -0
- node_modules/@bramus/specificity/src/util/index.js +3 -0
- node_modules/@bramus/specificity/src/util/sort.js +21 -0
- node_modules/@csstools/color-helpers/CHANGELOG.md +9 -0
- node_modules/@csstools/color-helpers/LICENSE.md +18 -0
- node_modules/@csstools/color-helpers/README.md +32 -0
- node_modules/@csstools/color-helpers/dist/index.d.ts +429 -0
- node_modules/@csstools/color-helpers/dist/index.mjs +263 -0
- node_modules/@csstools/color-helpers/package.json +55 -0
- node_modules/@csstools/css-calc/CHANGELOG.md +9 -0
node_modules/@babel/types/lib/validators/isVar.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = isVar;
|
| 7 |
+
var _index = require("./generated/index.js");
|
| 8 |
+
var BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
|
| 9 |
+
function isVar(node) {
|
| 10 |
+
return (0, _index.isVariableDeclaration)(node, {
|
| 11 |
+
kind: "var"
|
| 12 |
+
}) && !node[BLOCK_SCOPED_SYMBOL];
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
//# sourceMappingURL=isVar.js.map
|
node_modules/@babel/types/lib/validators/isVar.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_index","require","BLOCK_SCOPED_SYMBOL","Symbol","for","isVar","node","isVariableDeclaration","kind"],"sources":["../../src/validators/isVar.ts"],"sourcesContent":["import { isVariableDeclaration } from \"./generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nif (!process.env.BABEL_8_BREAKING) {\n // eslint-disable-next-line no-var\n var BLOCK_SCOPED_SYMBOL = Symbol.for(\"var used to be block scoped\");\n}\n\n/**\n * Check if the input `node` is a variable declaration.\n */\nexport default function isVar(node: t.Node | null | undefined): boolean {\n if (process.env.BABEL_8_BREAKING) {\n return isVariableDeclaration(node) && node.kind === \"var\";\n } else {\n return (\n isVariableDeclaration(node, { kind: \"var\" }) &&\n !(\n // @ts-expect-error document private properties\n node[BLOCK_SCOPED_SYMBOL]\n )\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAKE,IAAIC,mBAAmB,GAAGC,MAAM,CAACC,GAAG,CAAC,6BAA6B,CAAC;AAMtD,SAASC,KAAKA,CAACC,IAA+B,EAAW;EAIpE,OACE,IAAAC,4BAAqB,EAACD,IAAI,EAAE;IAAEE,IAAI,EAAE;EAAM,CAAC,CAAC,IAC5C,CAEEF,IAAI,CAACJ,mBAAmB,CACzB;AAGP","ignoreList":[]}
|
node_modules/@babel/types/lib/validators/matchesPattern.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = matchesPattern;
|
| 7 |
+
var _index = require("./generated/index.js");
|
| 8 |
+
function isMemberExpressionLike(node) {
|
| 9 |
+
return (0, _index.isMemberExpression)(node) || (0, _index.isMetaProperty)(node);
|
| 10 |
+
}
|
| 11 |
+
function matchesPattern(member, match, allowPartial) {
|
| 12 |
+
if (!isMemberExpressionLike(member)) return false;
|
| 13 |
+
const parts = Array.isArray(match) ? match : match.split(".");
|
| 14 |
+
const nodes = [];
|
| 15 |
+
let node;
|
| 16 |
+
for (node = member; isMemberExpressionLike(node); node = (_object = node.object) != null ? _object : node.meta) {
|
| 17 |
+
var _object;
|
| 18 |
+
nodes.push(node.property);
|
| 19 |
+
}
|
| 20 |
+
nodes.push(node);
|
| 21 |
+
if (nodes.length < parts.length) return false;
|
| 22 |
+
if (!allowPartial && nodes.length > parts.length) return false;
|
| 23 |
+
for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) {
|
| 24 |
+
const node = nodes[j];
|
| 25 |
+
let value;
|
| 26 |
+
if ((0, _index.isIdentifier)(node)) {
|
| 27 |
+
value = node.name;
|
| 28 |
+
} else if ((0, _index.isStringLiteral)(node)) {
|
| 29 |
+
value = node.value;
|
| 30 |
+
} else if ((0, _index.isThisExpression)(node)) {
|
| 31 |
+
value = "this";
|
| 32 |
+
} else if ((0, _index.isSuper)(node)) {
|
| 33 |
+
value = "super";
|
| 34 |
+
} else if ((0, _index.isPrivateName)(node)) {
|
| 35 |
+
value = "#" + node.id.name;
|
| 36 |
+
} else {
|
| 37 |
+
return false;
|
| 38 |
+
}
|
| 39 |
+
if (parts[i] !== value) return false;
|
| 40 |
+
}
|
| 41 |
+
return true;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
//# sourceMappingURL=matchesPattern.js.map
|
node_modules/@babel/types/lib/validators/matchesPattern.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_index","require","isMemberExpressionLike","node","isMemberExpression","isMetaProperty","matchesPattern","member","match","allowPartial","parts","Array","isArray","split","nodes","_object","object","meta","push","property","length","i","j","value","isIdentifier","name","isStringLiteral","isThisExpression","isSuper","isPrivateName","id"],"sources":["../../src/validators/matchesPattern.ts"],"sourcesContent":["import {\n isIdentifier,\n isMetaProperty,\n isMemberExpression,\n isPrivateName,\n isStringLiteral,\n isSuper,\n isThisExpression,\n} from \"./generated/index.ts\";\nimport type * as t from \"../index.ts\";\n\nfunction isMemberExpressionLike(\n node: t.Node,\n): node is t.MemberExpression | t.MetaProperty {\n return isMemberExpression(node) || isMetaProperty(node);\n}\n\n/**\n * Determines whether or not the input node `member` matches the\n * input `match`.\n *\n * For example, given the match `React.createClass` it would match the\n * parsed nodes of `React.createClass` and `React[\"createClass\"]`.\n */\nexport default function matchesPattern(\n member: t.Node | null | undefined,\n match: string | string[],\n allowPartial?: boolean,\n): boolean {\n // not a member expression\n if (!isMemberExpressionLike(member)) return false;\n\n const parts = Array.isArray(match) ? match : match.split(\".\");\n const nodes = [];\n\n let node;\n for (\n node = member;\n isMemberExpressionLike(node);\n node = (node as t.MemberExpression).object ?? (node as t.MetaProperty).meta\n ) {\n nodes.push(node.property);\n }\n nodes.push(node);\n\n if (nodes.length < parts.length) return false;\n if (!allowPartial && nodes.length > parts.length) return false;\n\n for (let i = 0, j = nodes.length - 1; i < parts.length; i++, j--) {\n const node = nodes[j];\n let value;\n if (isIdentifier(node)) {\n value = node.name;\n } else if (isStringLiteral(node)) {\n value = node.value;\n } else if (isThisExpression(node)) {\n value = \"this\";\n } else if (isSuper(node)) {\n value = \"super\";\n } else if (isPrivateName(node)) {\n value = \"#\" + node.id.name;\n } else {\n return false;\n }\n\n if (parts[i] !== value) return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAWA,SAASC,sBAAsBA,CAC7BC,IAAY,EACiC;EAC7C,OAAO,IAAAC,yBAAkB,EAACD,IAAI,CAAC,IAAI,IAAAE,qBAAc,EAACF,IAAI,CAAC;AACzD;AASe,SAASG,cAAcA,CACpCC,MAAiC,EACjCC,KAAwB,EACxBC,YAAsB,EACb;EAET,IAAI,CAACP,sBAAsB,CAACK,MAAM,CAAC,EAAE,OAAO,KAAK;EAEjD,MAAMG,KAAK,GAAGC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;EAC7D,MAAMC,KAAK,GAAG,EAAE;EAEhB,IAAIX,IAAI;EACR,KACEA,IAAI,GAAGI,MAAM,EACbL,sBAAsB,CAACC,IAAI,CAAC,EAC5BA,IAAI,IAAAY,OAAA,GAAIZ,IAAI,CAAwBa,MAAM,YAAAD,OAAA,GAAKZ,IAAI,CAAoBc,IAAI,EAC3E;IAAA,IAAAF,OAAA;IACAD,KAAK,CAACI,IAAI,CAACf,IAAI,CAACgB,QAAQ,CAAC;EAC3B;EACAL,KAAK,CAACI,IAAI,CAACf,IAAI,CAAC;EAEhB,IAAIW,KAAK,CAACM,MAAM,GAAGV,KAAK,CAACU,MAAM,EAAE,OAAO,KAAK;EAC7C,IAAI,CAACX,YAAY,IAAIK,KAAK,CAACM,MAAM,GAAGV,KAAK,CAACU,MAAM,EAAE,OAAO,KAAK;EAE9D,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAGR,KAAK,CAACM,MAAM,GAAG,CAAC,EAAEC,CAAC,GAAGX,KAAK,CAACU,MAAM,EAAEC,CAAC,EAAE,EAAEC,CAAC,EAAE,EAAE;IAChE,MAAMnB,IAAI,GAAGW,KAAK,CAACQ,CAAC,CAAC;IACrB,IAAIC,KAAK;IACT,IAAI,IAAAC,mBAAY,EAACrB,IAAI,CAAC,EAAE;MACtBoB,KAAK,GAAGpB,IAAI,CAACsB,IAAI;IACnB,CAAC,MAAM,IAAI,IAAAC,sBAAe,EAACvB,IAAI,CAAC,EAAE;MAChCoB,KAAK,GAAGpB,IAAI,CAACoB,KAAK;IACpB,CAAC,MAAM,IAAI,IAAAI,uBAAgB,EAACxB,IAAI,CAAC,EAAE;MACjCoB,KAAK,GAAG,MAAM;IAChB,CAAC,MAAM,IAAI,IAAAK,cAAO,EAACzB,IAAI,CAAC,EAAE;MACxBoB,KAAK,GAAG,OAAO;IACjB,CAAC,MAAM,IAAI,IAAAM,oBAAa,EAAC1B,IAAI,CAAC,EAAE;MAC9BoB,KAAK,GAAG,GAAG,GAAGpB,IAAI,CAAC2B,EAAE,CAACL,IAAI;IAC5B,CAAC,MAAM;MACL,OAAO,KAAK;IACd;IAEA,IAAIf,KAAK,CAACW,CAAC,CAAC,KAAKE,KAAK,EAAE,OAAO,KAAK;EACtC;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
|
node_modules/@babel/types/lib/validators/react/isCompatTag.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = isCompatTag;
|
| 7 |
+
function isCompatTag(tagName) {
|
| 8 |
+
return !!tagName && /^[a-z]/.test(tagName);
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
//# sourceMappingURL=isCompatTag.js.map
|
node_modules/@babel/types/lib/validators/react/isCompatTag.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["isCompatTag","tagName","test"],"sources":["../../../src/validators/react/isCompatTag.ts"],"sourcesContent":["export default function isCompatTag(tagName?: string): boolean {\n // Must start with a lowercase ASCII letter\n return !!tagName && /^[a-z]/.test(tagName);\n}\n"],"mappings":";;;;;;AAAe,SAASA,WAAWA,CAACC,OAAgB,EAAW;EAE7D,OAAO,CAAC,CAACA,OAAO,IAAI,QAAQ,CAACC,IAAI,CAACD,OAAO,CAAC;AAC5C","ignoreList":[]}
|
node_modules/@babel/types/lib/validators/react/isReactComponent.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = void 0;
|
| 7 |
+
var _buildMatchMemberExpression = require("../buildMatchMemberExpression.js");
|
| 8 |
+
const isReactComponent = (0, _buildMatchMemberExpression.default)("React.Component");
|
| 9 |
+
var _default = exports.default = isReactComponent;
|
| 10 |
+
|
| 11 |
+
//# sourceMappingURL=isReactComponent.js.map
|
node_modules/@babel/types/lib/validators/react/isReactComponent.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_buildMatchMemberExpression","require","isReactComponent","buildMatchMemberExpression","_default","exports","default"],"sources":["../../../src/validators/react/isReactComponent.ts"],"sourcesContent":["import buildMatchMemberExpression from \"../buildMatchMemberExpression.ts\";\n\nconst isReactComponent = buildMatchMemberExpression(\"React.Component\");\n\nexport default isReactComponent;\n"],"mappings":";;;;;;AAAA,IAAAA,2BAAA,GAAAC,OAAA;AAEA,MAAMC,gBAAgB,GAAG,IAAAC,mCAA0B,EAAC,iBAAiB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAExDJ,gBAAgB","ignoreList":[]}
|
node_modules/@babel/types/lib/validators/validate.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
|
| 3 |
+
Object.defineProperty(exports, "__esModule", {
|
| 4 |
+
value: true
|
| 5 |
+
});
|
| 6 |
+
exports.default = validate;
|
| 7 |
+
exports.validateChild = validateChild;
|
| 8 |
+
exports.validateField = validateField;
|
| 9 |
+
exports.validateInternal = validateInternal;
|
| 10 |
+
var _index = require("../definitions/index.js");
|
| 11 |
+
function validate(node, key, val) {
|
| 12 |
+
if (!node) return;
|
| 13 |
+
const fields = _index.NODE_FIELDS[node.type];
|
| 14 |
+
if (!fields) return;
|
| 15 |
+
const field = fields[key];
|
| 16 |
+
validateField(node, key, val, field);
|
| 17 |
+
validateChild(node, key, val);
|
| 18 |
+
}
|
| 19 |
+
function validateInternal(field, node, key, val, maybeNode) {
|
| 20 |
+
if (!(field != null && field.validate)) return;
|
| 21 |
+
if (field.optional && val == null) return;
|
| 22 |
+
field.validate(node, key, val);
|
| 23 |
+
if (maybeNode) {
|
| 24 |
+
var _NODE_PARENT_VALIDATI;
|
| 25 |
+
const type = val.type;
|
| 26 |
+
if (type == null) return;
|
| 27 |
+
(_NODE_PARENT_VALIDATI = _index.NODE_PARENT_VALIDATIONS[type]) == null || _NODE_PARENT_VALIDATI.call(_index.NODE_PARENT_VALIDATIONS, node, key, val);
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
function validateField(node, key, val, field) {
|
| 31 |
+
if (!(field != null && field.validate)) return;
|
| 32 |
+
if (field.optional && val == null) return;
|
| 33 |
+
field.validate(node, key, val);
|
| 34 |
+
}
|
| 35 |
+
function validateChild(node, key, val) {
|
| 36 |
+
var _NODE_PARENT_VALIDATI2;
|
| 37 |
+
const type = val == null ? void 0 : val.type;
|
| 38 |
+
if (type == null) return;
|
| 39 |
+
(_NODE_PARENT_VALIDATI2 = _index.NODE_PARENT_VALIDATIONS[type]) == null || _NODE_PARENT_VALIDATI2.call(_index.NODE_PARENT_VALIDATIONS, node, key, val);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
//# sourceMappingURL=validate.js.map
|
node_modules/@babel/types/lib/validators/validate.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version":3,"names":["_index","require","validate","node","key","val","fields","NODE_FIELDS","type","field","validateField","validateChild","validateInternal","maybeNode","optional","_NODE_PARENT_VALIDATI","NODE_PARENT_VALIDATIONS","call","_NODE_PARENT_VALIDATI2"],"sources":["../../src/validators/validate.ts"],"sourcesContent":["import {\n NODE_FIELDS,\n NODE_PARENT_VALIDATIONS,\n type FieldOptions,\n} from \"../definitions/index.ts\";\nimport type * as t from \"../index.ts\";\n\nexport default function validate(\n node: t.Node | undefined | null,\n key: string,\n val: unknown,\n): void {\n if (!node) return;\n\n const fields = NODE_FIELDS[node.type];\n if (!fields) return;\n\n const field = fields[key];\n validateField(node, key, val, field);\n validateChild(node, key, val);\n}\n\nexport function validateInternal(\n field: FieldOptions,\n node: t.Node | undefined | null,\n key: string,\n val: unknown,\n maybeNode?: 1,\n): void {\n if (!field?.validate) return;\n if (field.optional && val == null) return;\n\n field.validate(node, key, val);\n\n if (maybeNode) {\n const type = (val as t.Node).type;\n if (type == null) return;\n NODE_PARENT_VALIDATIONS[type]?.(node, key, val);\n }\n}\n\nexport function validateField(\n node: t.Node | undefined | null,\n key: string,\n val: unknown,\n field: FieldOptions | undefined | null,\n): void {\n if (!field?.validate) return;\n if (field.optional && val == null) return;\n\n field.validate(node, key, val);\n}\n\nexport function validateChild(\n node: t.Node | undefined | null,\n key: string | { toString(): string },\n val?: unknown,\n) {\n const type = (val as t.Node)?.type;\n if (type == null) return;\n NODE_PARENT_VALIDATIONS[type]?.(node, key, val);\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAOe,SAASC,QAAQA,CAC9BC,IAA+B,EAC/BC,GAAW,EACXC,GAAY,EACN;EACN,IAAI,CAACF,IAAI,EAAE;EAEX,MAAMG,MAAM,GAAGC,kBAAW,CAACJ,IAAI,CAACK,IAAI,CAAC;EACrC,IAAI,CAACF,MAAM,EAAE;EAEb,MAAMG,KAAK,GAAGH,MAAM,CAACF,GAAG,CAAC;EACzBM,aAAa,CAACP,IAAI,EAAEC,GAAG,EAAEC,GAAG,EAAEI,KAAK,CAAC;EACpCE,aAAa,CAACR,IAAI,EAAEC,GAAG,EAAEC,GAAG,CAAC;AAC/B;AAEO,SAASO,gBAAgBA,CAC9BH,KAAmB,EACnBN,IAA+B,EAC/BC,GAAW,EACXC,GAAY,EACZQ,SAAa,EACP;EACN,IAAI,EAACJ,KAAK,YAALA,KAAK,CAAEP,QAAQ,GAAE;EACtB,IAAIO,KAAK,CAACK,QAAQ,IAAIT,GAAG,IAAI,IAAI,EAAE;EAEnCI,KAAK,CAACP,QAAQ,CAACC,IAAI,EAAEC,GAAG,EAAEC,GAAG,CAAC;EAE9B,IAAIQ,SAAS,EAAE;IAAA,IAAAE,qBAAA;IACb,MAAMP,IAAI,GAAIH,GAAG,CAAYG,IAAI;IACjC,IAAIA,IAAI,IAAI,IAAI,EAAE;IAClB,CAAAO,qBAAA,GAAAC,8BAAuB,CAACR,IAAI,CAAC,aAA7BO,qBAAA,CAAAE,IAAA,CAAAD,8BAAuB,EAASb,IAAI,EAAEC,GAAG,EAAEC,GAAG,CAAC;EACjD;AACF;AAEO,SAASK,aAAaA,CAC3BP,IAA+B,EAC/BC,GAAW,EACXC,GAAY,EACZI,KAAsC,EAChC;EACN,IAAI,EAACA,KAAK,YAALA,KAAK,CAAEP,QAAQ,GAAE;EACtB,IAAIO,KAAK,CAACK,QAAQ,IAAIT,GAAG,IAAI,IAAI,EAAE;EAEnCI,KAAK,CAACP,QAAQ,CAACC,IAAI,EAAEC,GAAG,EAAEC,GAAG,CAAC;AAChC;AAEO,SAASM,aAAaA,CAC3BR,IAA+B,EAC/BC,GAAoC,EACpCC,GAAa,EACb;EAAA,IAAAa,sBAAA;EACA,MAAMV,IAAI,GAAIH,GAAG,oBAAHA,GAAG,CAAaG,IAAI;EAClC,IAAIA,IAAI,IAAI,IAAI,EAAE;EAClB,CAAAU,sBAAA,GAAAF,8BAAuB,CAACR,IAAI,CAAC,aAA7BU,sBAAA,CAAAD,IAAA,CAAAD,8BAAuB,EAASb,IAAI,EAAEC,GAAG,EAAEC,GAAG,CAAC;AACjD","ignoreList":[]}
|
node_modules/@babel/types/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@babel/types",
|
| 3 |
+
"version": "7.29.7",
|
| 4 |
+
"description": "Babel Types is a Lodash-esque utility library for AST nodes",
|
| 5 |
+
"author": "The Babel Team (https://babel.dev/team)",
|
| 6 |
+
"homepage": "https://babel.dev/docs/en/next/babel-types",
|
| 7 |
+
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20types%22+is%3Aopen",
|
| 8 |
+
"license": "MIT",
|
| 9 |
+
"publishConfig": {
|
| 10 |
+
"access": "public"
|
| 11 |
+
},
|
| 12 |
+
"repository": {
|
| 13 |
+
"type": "git",
|
| 14 |
+
"url": "https://github.com/babel/babel.git",
|
| 15 |
+
"directory": "packages/babel-types"
|
| 16 |
+
},
|
| 17 |
+
"main": "./lib/index.js",
|
| 18 |
+
"dependencies": {
|
| 19 |
+
"@babel/helper-string-parser": "^7.29.7",
|
| 20 |
+
"@babel/helper-validator-identifier": "^7.29.7"
|
| 21 |
+
},
|
| 22 |
+
"devDependencies": {
|
| 23 |
+
"@babel/generator": "^7.29.7",
|
| 24 |
+
"@babel/helper-fixtures": "^7.29.7",
|
| 25 |
+
"@babel/parser": "^7.29.7"
|
| 26 |
+
},
|
| 27 |
+
"engines": {
|
| 28 |
+
"node": ">=6.9.0"
|
| 29 |
+
},
|
| 30 |
+
"type": "commonjs",
|
| 31 |
+
"types": "./lib/index-legacy.d.ts",
|
| 32 |
+
"typesVersions": {
|
| 33 |
+
">=4.1": {
|
| 34 |
+
"lib/index-legacy.d.ts": [
|
| 35 |
+
"lib/index.d.ts"
|
| 36 |
+
]
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
}
|
node_modules/@bcoe/v8-coverage/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright © 2015-2017 Charles Samborski
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
node_modules/@bcoe/v8-coverage/LICENSE.txt
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2017, Contributors
|
| 2 |
+
|
| 3 |
+
Permission to use, copy, modify, and/or distribute this software
|
| 4 |
+
for any purpose with or without fee is hereby granted, provided
|
| 5 |
+
that the above copyright notice and this permission notice
|
| 6 |
+
appear in all copies.
|
| 7 |
+
|
| 8 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 9 |
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
| 10 |
+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
|
| 11 |
+
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
|
| 12 |
+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
| 13 |
+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
| 14 |
+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
node_modules/@bcoe/v8-coverage/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# V8 Coverage
|
| 2 |
+
|
| 3 |
+
[](https://www.npmjs.com/package/@c88/v8-coverage)
|
| 4 |
+
[](https://github.com/demurgos/v8-coverage)
|
| 5 |
+
[](https://travis-ci.org/demurgos/v8-coverage)
|
| 6 |
+
[](https://ci.appveyor.com/project/demurgos/v8-coverage)
|
| 7 |
+
[](https://codecov.io/gh/demurgos/v8-coverage)
|
| 8 |
+
|
| 9 |
+
## License
|
| 10 |
+
|
| 11 |
+
[MIT License](./LICENSE.md)
|
node_modules/@bcoe/v8-coverage/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@bcoe/v8-coverage",
|
| 3 |
+
"version": "1.0.2",
|
| 4 |
+
"description": "Helper functions for V8 coverage files.",
|
| 5 |
+
"author": "Charles Samborski <demurgos@demurgos.net> (https://demurgos.net)",
|
| 6 |
+
"license": "MIT",
|
| 7 |
+
"main": "./src/lib/index.js",
|
| 8 |
+
"repository": {
|
| 9 |
+
"type": "git",
|
| 10 |
+
"url": "git://github.com/bcoe/v8-coverage.git"
|
| 11 |
+
},
|
| 12 |
+
"scripts": {
|
| 13 |
+
"test": "c8 mocha ./src/test/*.js",
|
| 14 |
+
"posttest": "prettier --check ./src/lib/*.js",
|
| 15 |
+
"fix": "prettier --write ./src/lib/*.js"
|
| 16 |
+
},
|
| 17 |
+
"devDependencies": {
|
| 18 |
+
"c8": "^10.1.2",
|
| 19 |
+
"chai": "^4.5.0",
|
| 20 |
+
"mocha": "^11.0.1",
|
| 21 |
+
"prettier": "3.4.2"
|
| 22 |
+
},
|
| 23 |
+
"engines": {
|
| 24 |
+
"node": ">=18"
|
| 25 |
+
},
|
| 26 |
+
"files": [
|
| 27 |
+
"./src/lib"
|
| 28 |
+
]
|
| 29 |
+
}
|
node_modules/@bcoe/v8-coverage/src/lib/ascii.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const { compareRangeCovs } = require("./compare");
|
| 2 |
+
|
| 3 |
+
function emitForest(trees) {
|
| 4 |
+
return emitForestLines(trees).join("\n");
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
function emitForestLines(trees) {
|
| 8 |
+
const colMap = getColMap(trees);
|
| 9 |
+
const header = emitOffsets(colMap);
|
| 10 |
+
return [header, ...trees.map((tree) => emitTree(tree, colMap).join("\n"))];
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
function getColMap(trees) {
|
| 14 |
+
const eventSet = new Set();
|
| 15 |
+
for (const tree of trees) {
|
| 16 |
+
const stack = [tree];
|
| 17 |
+
while (stack.length > 0) {
|
| 18 |
+
const cur = stack.pop();
|
| 19 |
+
eventSet.add(cur.start);
|
| 20 |
+
eventSet.add(cur.end);
|
| 21 |
+
for (const child of cur.children) {
|
| 22 |
+
stack.push(child);
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
const events = [...eventSet];
|
| 27 |
+
events.sort((a, b) => a - b);
|
| 28 |
+
let maxDigits = 1;
|
| 29 |
+
for (const event of events) {
|
| 30 |
+
maxDigits = Math.max(maxDigits, event.toString(10).length);
|
| 31 |
+
}
|
| 32 |
+
const colWidth = maxDigits + 3;
|
| 33 |
+
const colMap = new Map();
|
| 34 |
+
for (const [i, event] of events.entries()) {
|
| 35 |
+
colMap.set(event, i * colWidth);
|
| 36 |
+
}
|
| 37 |
+
return colMap;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
function emitTree(tree, colMap) {
|
| 41 |
+
const layers = [];
|
| 42 |
+
let nextLayer = [tree];
|
| 43 |
+
while (nextLayer.length > 0) {
|
| 44 |
+
const layer = nextLayer;
|
| 45 |
+
layers.push(layer);
|
| 46 |
+
nextLayer = [];
|
| 47 |
+
for (const node of layer) {
|
| 48 |
+
for (const child of node.children) {
|
| 49 |
+
nextLayer.push(child);
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
return layers.map((layer) => emitTreeLayer(layer, colMap));
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function parseFunctionRanges(text, offsetMap) {
|
| 57 |
+
const result = [];
|
| 58 |
+
for (const line of text.split("\n")) {
|
| 59 |
+
for (const range of parseTreeLayer(line, offsetMap)) {
|
| 60 |
+
result.push(range);
|
| 61 |
+
}
|
| 62 |
+
}
|
| 63 |
+
result.sort(compareRangeCovs);
|
| 64 |
+
return result;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
*
|
| 69 |
+
* @param layer Sorted list of disjoint trees.
|
| 70 |
+
* @param colMap
|
| 71 |
+
*/
|
| 72 |
+
function emitTreeLayer(layer, colMap) {
|
| 73 |
+
const line = [];
|
| 74 |
+
let curIdx = 0;
|
| 75 |
+
for (const { start, end, count } of layer) {
|
| 76 |
+
const startIdx = colMap.get(start);
|
| 77 |
+
const endIdx = colMap.get(end);
|
| 78 |
+
if (startIdx > curIdx) {
|
| 79 |
+
line.push(" ".repeat(startIdx - curIdx));
|
| 80 |
+
}
|
| 81 |
+
line.push(emitRange(count, endIdx - startIdx));
|
| 82 |
+
curIdx = endIdx;
|
| 83 |
+
}
|
| 84 |
+
return line.join("");
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
function parseTreeLayer(text, offsetMap) {
|
| 88 |
+
const result = [];
|
| 89 |
+
const regex = /\[(\d+)-*\)/gs;
|
| 90 |
+
while (true) {
|
| 91 |
+
const match = regex.exec(text);
|
| 92 |
+
if (match === null) {
|
| 93 |
+
break;
|
| 94 |
+
}
|
| 95 |
+
const startIdx = match.index;
|
| 96 |
+
const endIdx = startIdx + match[0].length;
|
| 97 |
+
const count = parseInt(match[1], 10);
|
| 98 |
+
const startOffset = offsetMap.get(startIdx);
|
| 99 |
+
const endOffset = offsetMap.get(endIdx);
|
| 100 |
+
if (startOffset === undefined || endOffset === undefined) {
|
| 101 |
+
throw new Error(`Invalid offsets for: ${JSON.stringify(text)}`);
|
| 102 |
+
}
|
| 103 |
+
result.push({ startOffset, endOffset, count });
|
| 104 |
+
}
|
| 105 |
+
return result;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
function emitRange(count, len) {
|
| 109 |
+
const rangeStart = `[${count.toString(10)}`;
|
| 110 |
+
const rangeEnd = ")";
|
| 111 |
+
const hyphensLen = len - (rangeStart.length + rangeEnd.length);
|
| 112 |
+
const hyphens = "-".repeat(Math.max(0, hyphensLen));
|
| 113 |
+
return `${rangeStart}${hyphens}${rangeEnd}`;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
function emitOffsets(colMap) {
|
| 117 |
+
let line = "";
|
| 118 |
+
for (const [event, col] of colMap) {
|
| 119 |
+
if (line.length < col) {
|
| 120 |
+
line += " ".repeat(col - line.length);
|
| 121 |
+
}
|
| 122 |
+
line += event.toString(10);
|
| 123 |
+
}
|
| 124 |
+
return line;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
function parseOffsets(text) {
|
| 128 |
+
const result = new Map();
|
| 129 |
+
const regex = /\d+/gs;
|
| 130 |
+
while (true) {
|
| 131 |
+
const match = regex.exec(text);
|
| 132 |
+
if (match === null) {
|
| 133 |
+
break;
|
| 134 |
+
}
|
| 135 |
+
result.set(match.index, parseInt(match[0], 10));
|
| 136 |
+
}
|
| 137 |
+
return result;
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
module.exports = {
|
| 141 |
+
emitForest,
|
| 142 |
+
emitForestLines,
|
| 143 |
+
parseFunctionRanges,
|
| 144 |
+
parseOffsets,
|
| 145 |
+
};
|
node_modules/@bcoe/v8-coverage/src/lib/clone.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Creates a deep copy of a process coverage.
|
| 3 |
+
*
|
| 4 |
+
* @param processCov Process coverage to clone.
|
| 5 |
+
* @return Cloned process coverage.
|
| 6 |
+
*/
|
| 7 |
+
function cloneProcessCov(processCov) {
|
| 8 |
+
const result = [];
|
| 9 |
+
for (const scriptCov of processCov.result) {
|
| 10 |
+
result.push(cloneScriptCov(scriptCov));
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
return {
|
| 14 |
+
result,
|
| 15 |
+
};
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* Creates a deep copy of a script coverage.
|
| 20 |
+
*
|
| 21 |
+
* @param scriptCov Script coverage to clone.
|
| 22 |
+
* @return Cloned script coverage.
|
| 23 |
+
*/
|
| 24 |
+
function cloneScriptCov(scriptCov) {
|
| 25 |
+
const functions = [];
|
| 26 |
+
for (const functionCov of scriptCov.functions) {
|
| 27 |
+
functions.push(cloneFunctionCov(functionCov));
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
return {
|
| 31 |
+
scriptId: scriptCov.scriptId,
|
| 32 |
+
url: scriptCov.url,
|
| 33 |
+
functions,
|
| 34 |
+
};
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
/**
|
| 38 |
+
* Creates a deep copy of a function coverage.
|
| 39 |
+
*
|
| 40 |
+
* @param functionCov Function coverage to clone.
|
| 41 |
+
* @return Cloned function coverage.
|
| 42 |
+
*/
|
| 43 |
+
function cloneFunctionCov(functionCov) {
|
| 44 |
+
const ranges = [];
|
| 45 |
+
for (const rangeCov of functionCov.ranges) {
|
| 46 |
+
ranges.push(cloneRangeCov(rangeCov));
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return {
|
| 50 |
+
functionName: functionCov.functionName,
|
| 51 |
+
ranges,
|
| 52 |
+
isBlockCoverage: functionCov.isBlockCoverage,
|
| 53 |
+
};
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* Creates a deep copy of a function coverage.
|
| 58 |
+
*
|
| 59 |
+
* @param rangeCov Range coverage to clone.
|
| 60 |
+
* @return Cloned range coverage.
|
| 61 |
+
*/
|
| 62 |
+
function cloneRangeCov(rangeCov) {
|
| 63 |
+
return {
|
| 64 |
+
startOffset: rangeCov.startOffset,
|
| 65 |
+
endOffset: rangeCov.endOffset,
|
| 66 |
+
count: rangeCov.count,
|
| 67 |
+
};
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
module.exports = {
|
| 71 |
+
cloneProcessCov,
|
| 72 |
+
cloneScriptCov,
|
| 73 |
+
cloneFunctionCov,
|
| 74 |
+
cloneRangeCov,
|
| 75 |
+
};
|
node_modules/@bcoe/v8-coverage/src/lib/compare.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Compares two script coverages.
|
| 3 |
+
*
|
| 4 |
+
* The result corresponds to the comparison of their `url` value (alphabetical sort).
|
| 5 |
+
*/
|
| 6 |
+
function compareScriptCovs(a, b) {
|
| 7 |
+
if (a.url === b.url) {
|
| 8 |
+
return 0;
|
| 9 |
+
} else if (a.url < b.url) {
|
| 10 |
+
return -1;
|
| 11 |
+
} else {
|
| 12 |
+
return 1;
|
| 13 |
+
}
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* Compares two function coverages.
|
| 18 |
+
*
|
| 19 |
+
* The result corresponds to the comparison of the root ranges.
|
| 20 |
+
*/
|
| 21 |
+
function compareFunctionCovs(a, b) {
|
| 22 |
+
return compareRangeCovs(a.ranges[0], b.ranges[0]);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Compares two range coverages.
|
| 27 |
+
*
|
| 28 |
+
* The ranges are first ordered by ascending `startOffset` and then by
|
| 29 |
+
* descending `endOffset`.
|
| 30 |
+
* This corresponds to a pre-order tree traversal.
|
| 31 |
+
*/
|
| 32 |
+
function compareRangeCovs(a, b) {
|
| 33 |
+
if (a.startOffset !== b.startOffset) {
|
| 34 |
+
return a.startOffset - b.startOffset;
|
| 35 |
+
} else {
|
| 36 |
+
return b.endOffset - a.endOffset;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
module.exports = {
|
| 41 |
+
compareScriptCovs,
|
| 42 |
+
compareFunctionCovs,
|
| 43 |
+
compareRangeCovs,
|
| 44 |
+
};
|
node_modules/@bcoe/v8-coverage/src/lib/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const {
|
| 2 |
+
emitForest,
|
| 3 |
+
emitForestLines,
|
| 4 |
+
parseFunctionRanges,
|
| 5 |
+
parseOffsets,
|
| 6 |
+
} = require("./ascii");
|
| 7 |
+
const {
|
| 8 |
+
cloneFunctionCov,
|
| 9 |
+
cloneProcessCov,
|
| 10 |
+
cloneScriptCov,
|
| 11 |
+
cloneRangeCov,
|
| 12 |
+
} = require("./clone");
|
| 13 |
+
const {
|
| 14 |
+
compareScriptCovs,
|
| 15 |
+
compareFunctionCovs,
|
| 16 |
+
compareRangeCovs,
|
| 17 |
+
} = require("./compare");
|
| 18 |
+
const {
|
| 19 |
+
mergeFunctionCovs,
|
| 20 |
+
mergeProcessCovs,
|
| 21 |
+
mergeScriptCovs,
|
| 22 |
+
} = require("./merge");
|
| 23 |
+
const { RangeTree } = require("./range-tree");
|
| 24 |
+
|
| 25 |
+
module.exports = {
|
| 26 |
+
emitForest,
|
| 27 |
+
emitForestLines,
|
| 28 |
+
parseFunctionRanges,
|
| 29 |
+
parseOffsets,
|
| 30 |
+
cloneFunctionCov,
|
| 31 |
+
cloneProcessCov,
|
| 32 |
+
cloneScriptCov,
|
| 33 |
+
cloneRangeCov,
|
| 34 |
+
compareScriptCovs,
|
| 35 |
+
compareFunctionCovs,
|
| 36 |
+
compareRangeCovs,
|
| 37 |
+
mergeFunctionCovs,
|
| 38 |
+
mergeProcessCovs,
|
| 39 |
+
mergeScriptCovs,
|
| 40 |
+
RangeTree,
|
| 41 |
+
};
|
node_modules/@bcoe/v8-coverage/src/lib/merge.js
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const {
|
| 2 |
+
deepNormalizeScriptCov,
|
| 3 |
+
normalizeFunctionCov,
|
| 4 |
+
normalizeProcessCov,
|
| 5 |
+
normalizeRangeTree,
|
| 6 |
+
normalizeScriptCov,
|
| 7 |
+
} = require("./normalize");
|
| 8 |
+
const { RangeTree } = require("./range-tree");
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* Merges a list of process coverages.
|
| 12 |
+
*
|
| 13 |
+
* The result is normalized.
|
| 14 |
+
* The input values may be mutated, it is not safe to use them after passing
|
| 15 |
+
* them to this function.
|
| 16 |
+
* The computation is synchronous.
|
| 17 |
+
*
|
| 18 |
+
* @param processCovs Process coverages to merge.
|
| 19 |
+
* @return Merged process coverage.
|
| 20 |
+
*/
|
| 21 |
+
function mergeProcessCovs(processCovs) {
|
| 22 |
+
if (processCovs.length === 0) {
|
| 23 |
+
return { result: [] };
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
const urlToScripts = new Map();
|
| 27 |
+
for (const processCov of processCovs) {
|
| 28 |
+
for (const scriptCov of processCov.result) {
|
| 29 |
+
let scriptCovs = urlToScripts.get(scriptCov.url);
|
| 30 |
+
if (scriptCovs === undefined) {
|
| 31 |
+
scriptCovs = [];
|
| 32 |
+
urlToScripts.set(scriptCov.url, scriptCovs);
|
| 33 |
+
}
|
| 34 |
+
scriptCovs.push(scriptCov);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
const result = [];
|
| 39 |
+
for (const scripts of urlToScripts.values()) {
|
| 40 |
+
// assert: `scripts.length > 0`
|
| 41 |
+
result.push(mergeScriptCovs(scripts));
|
| 42 |
+
}
|
| 43 |
+
const merged = { result };
|
| 44 |
+
|
| 45 |
+
normalizeProcessCov(merged);
|
| 46 |
+
return merged;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* Merges a list of matching script coverages.
|
| 51 |
+
*
|
| 52 |
+
* Scripts are matching if they have the same `url`.
|
| 53 |
+
* The result is normalized.
|
| 54 |
+
* The input values may be mutated, it is not safe to use them after passing
|
| 55 |
+
* them to this function.
|
| 56 |
+
* The computation is synchronous.
|
| 57 |
+
*
|
| 58 |
+
* @param scriptCovs Process coverages to merge.
|
| 59 |
+
* @return Merged script coverage, or `undefined` if the input list was empty.
|
| 60 |
+
*/
|
| 61 |
+
function mergeScriptCovs(scriptCovs) {
|
| 62 |
+
if (scriptCovs.length === 0) {
|
| 63 |
+
return undefined;
|
| 64 |
+
} else if (scriptCovs.length === 1) {
|
| 65 |
+
const merged = scriptCovs[0];
|
| 66 |
+
deepNormalizeScriptCov(merged);
|
| 67 |
+
return merged;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
const first = scriptCovs[0];
|
| 71 |
+
const scriptId = first.scriptId;
|
| 72 |
+
const url = first.url;
|
| 73 |
+
|
| 74 |
+
const rangeToFuncs = new Map();
|
| 75 |
+
for (const scriptCov of scriptCovs) {
|
| 76 |
+
for (const funcCov of scriptCov.functions) {
|
| 77 |
+
const rootRange = stringifyFunctionRootRange(funcCov);
|
| 78 |
+
let funcCovs = rangeToFuncs.get(rootRange);
|
| 79 |
+
|
| 80 |
+
if (
|
| 81 |
+
funcCovs === undefined ||
|
| 82 |
+
// if the entry in rangeToFuncs is function-level granularity and
|
| 83 |
+
// the new coverage is block-level, prefer block-level.
|
| 84 |
+
(!funcCovs[0].isBlockCoverage && funcCov.isBlockCoverage)
|
| 85 |
+
) {
|
| 86 |
+
funcCovs = [];
|
| 87 |
+
rangeToFuncs.set(rootRange, funcCovs);
|
| 88 |
+
} else if (funcCovs[0].isBlockCoverage && !funcCov.isBlockCoverage) {
|
| 89 |
+
// if the entry in rangeToFuncs is block-level granularity, we should
|
| 90 |
+
// not append function level granularity.
|
| 91 |
+
continue;
|
| 92 |
+
}
|
| 93 |
+
funcCovs.push(funcCov);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
const functions = [];
|
| 98 |
+
for (const funcCovs of rangeToFuncs.values()) {
|
| 99 |
+
// assert: `funcCovs.length > 0`
|
| 100 |
+
functions.push(mergeFunctionCovs(funcCovs));
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
const merged = { scriptId, url, functions };
|
| 104 |
+
normalizeScriptCov(merged);
|
| 105 |
+
return merged;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/**
|
| 109 |
+
* Returns a string representation of the root range of the function.
|
| 110 |
+
*
|
| 111 |
+
* This string can be used to match function with same root range.
|
| 112 |
+
* The string is derived from the start and end offsets of the root range of
|
| 113 |
+
* the function.
|
| 114 |
+
* This assumes that `ranges` is non-empty (true for valid function coverages).
|
| 115 |
+
*
|
| 116 |
+
* @param funcCov Function coverage with the range to stringify
|
| 117 |
+
* @internal
|
| 118 |
+
*/
|
| 119 |
+
function stringifyFunctionRootRange(funcCov) {
|
| 120 |
+
const rootRange = funcCov.ranges[0];
|
| 121 |
+
return `${rootRange.startOffset.toString(10)};${rootRange.endOffset.toString(10)}`;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Merges a list of matching function coverages.
|
| 126 |
+
*
|
| 127 |
+
* Functions are matching if their root ranges have the same span.
|
| 128 |
+
* The result is normalized.
|
| 129 |
+
* The input values may be mutated, it is not safe to use them after passing
|
| 130 |
+
* them to this function.
|
| 131 |
+
* The computation is synchronous.
|
| 132 |
+
*
|
| 133 |
+
* @param funcCovs Function coverages to merge.
|
| 134 |
+
* @return Merged function coverage, or `undefined` if the input list was empty.
|
| 135 |
+
*/
|
| 136 |
+
function mergeFunctionCovs(funcCovs) {
|
| 137 |
+
if (funcCovs.length === 0) {
|
| 138 |
+
return undefined;
|
| 139 |
+
} else if (funcCovs.length === 1) {
|
| 140 |
+
const merged = funcCovs[0];
|
| 141 |
+
normalizeFunctionCov(merged);
|
| 142 |
+
return merged;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
const functionName = funcCovs[0].functionName;
|
| 146 |
+
|
| 147 |
+
const trees = [];
|
| 148 |
+
for (const funcCov of funcCovs) {
|
| 149 |
+
// assert: `fn.ranges.length > 0`
|
| 150 |
+
// assert: `fn.ranges` is sorted
|
| 151 |
+
trees.push(RangeTree.fromSortedRanges(funcCov.ranges));
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
// assert: `trees.length > 0`
|
| 155 |
+
const mergedTree = mergeRangeTrees(trees);
|
| 156 |
+
normalizeRangeTree(mergedTree);
|
| 157 |
+
const ranges = mergedTree.toRanges();
|
| 158 |
+
const isBlockCoverage = !(ranges.length === 1 && ranges[0].count === 0);
|
| 159 |
+
|
| 160 |
+
const merged = { functionName, ranges, isBlockCoverage };
|
| 161 |
+
// assert: `merged` is normalized
|
| 162 |
+
return merged;
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/**
|
| 166 |
+
* @precondition Same `start` and `end` for all the trees
|
| 167 |
+
*/
|
| 168 |
+
function mergeRangeTrees(trees) {
|
| 169 |
+
if (trees.length <= 1) {
|
| 170 |
+
return trees[0];
|
| 171 |
+
}
|
| 172 |
+
const first = trees[0];
|
| 173 |
+
let delta = 0;
|
| 174 |
+
for (const tree of trees) {
|
| 175 |
+
delta += tree.delta;
|
| 176 |
+
}
|
| 177 |
+
const children = mergeRangeTreeChildren(trees);
|
| 178 |
+
return new RangeTree(first.start, first.end, delta, children);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
class RangeTreeWithParent {
|
| 182 |
+
parentIndex;
|
| 183 |
+
tree;
|
| 184 |
+
|
| 185 |
+
constructor(parentIndex, tree) {
|
| 186 |
+
this.parentIndex = parentIndex;
|
| 187 |
+
this.tree = tree;
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
class StartEvent {
|
| 192 |
+
offset;
|
| 193 |
+
trees;
|
| 194 |
+
|
| 195 |
+
constructor(offset, trees) {
|
| 196 |
+
this.offset = offset;
|
| 197 |
+
this.trees = trees;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
static compare(a, b) {
|
| 201 |
+
return a.offset - b.offset;
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
class StartEventQueue {
|
| 206 |
+
queue;
|
| 207 |
+
nextIndex;
|
| 208 |
+
pendingOffset;
|
| 209 |
+
pendingTrees;
|
| 210 |
+
|
| 211 |
+
constructor(queue) {
|
| 212 |
+
this.queue = queue;
|
| 213 |
+
this.nextIndex = 0;
|
| 214 |
+
this.pendingOffset = 0;
|
| 215 |
+
this.pendingTrees = undefined;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
static fromParentTrees(parentTrees) {
|
| 219 |
+
const startToTrees = new Map();
|
| 220 |
+
for (const [parentIndex, parentTree] of parentTrees.entries()) {
|
| 221 |
+
for (const child of parentTree.children) {
|
| 222 |
+
let trees = startToTrees.get(child.start);
|
| 223 |
+
if (trees === undefined) {
|
| 224 |
+
trees = [];
|
| 225 |
+
startToTrees.set(child.start, trees);
|
| 226 |
+
}
|
| 227 |
+
trees.push(new RangeTreeWithParent(parentIndex, child));
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
const queue = [];
|
| 231 |
+
for (const [startOffset, trees] of startToTrees) {
|
| 232 |
+
queue.push(new StartEvent(startOffset, trees));
|
| 233 |
+
}
|
| 234 |
+
queue.sort(StartEvent.compare);
|
| 235 |
+
return new StartEventQueue(queue);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
setPendingOffset(offset) {
|
| 239 |
+
this.pendingOffset = offset;
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
pushPendingTree(tree) {
|
| 243 |
+
if (this.pendingTrees === undefined) {
|
| 244 |
+
this.pendingTrees = [];
|
| 245 |
+
}
|
| 246 |
+
this.pendingTrees.push(tree);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
next() {
|
| 250 |
+
const pendingTrees = this.pendingTrees;
|
| 251 |
+
const nextEvent = this.queue[this.nextIndex];
|
| 252 |
+
if (pendingTrees === undefined) {
|
| 253 |
+
this.nextIndex++;
|
| 254 |
+
return nextEvent;
|
| 255 |
+
} else if (nextEvent === undefined) {
|
| 256 |
+
this.pendingTrees = undefined;
|
| 257 |
+
return new StartEvent(this.pendingOffset, pendingTrees);
|
| 258 |
+
} else {
|
| 259 |
+
if (this.pendingOffset < nextEvent.offset) {
|
| 260 |
+
this.pendingTrees = undefined;
|
| 261 |
+
return new StartEvent(this.pendingOffset, pendingTrees);
|
| 262 |
+
} else {
|
| 263 |
+
if (this.pendingOffset === nextEvent.offset) {
|
| 264 |
+
this.pendingTrees = undefined;
|
| 265 |
+
for (const tree of pendingTrees) {
|
| 266 |
+
nextEvent.trees.push(tree);
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
this.nextIndex++;
|
| 270 |
+
return nextEvent;
|
| 271 |
+
}
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
function mergeRangeTreeChildren(parentTrees) {
|
| 277 |
+
const result = [];
|
| 278 |
+
const startEventQueue = StartEventQueue.fromParentTrees(parentTrees);
|
| 279 |
+
const parentToNested = new Map();
|
| 280 |
+
let openRange;
|
| 281 |
+
|
| 282 |
+
while (true) {
|
| 283 |
+
const event = startEventQueue.next();
|
| 284 |
+
if (event === undefined) {
|
| 285 |
+
break;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
if (openRange !== undefined && openRange.end <= event.offset) {
|
| 289 |
+
result.push(nextChild(openRange, parentToNested));
|
| 290 |
+
openRange = undefined;
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
if (openRange === undefined) {
|
| 294 |
+
let openRangeEnd = event.offset + 1;
|
| 295 |
+
for (const { parentIndex, tree } of event.trees) {
|
| 296 |
+
openRangeEnd = Math.max(openRangeEnd, tree.end);
|
| 297 |
+
insertChild(parentToNested, parentIndex, tree);
|
| 298 |
+
}
|
| 299 |
+
startEventQueue.setPendingOffset(openRangeEnd);
|
| 300 |
+
openRange = { start: event.offset, end: openRangeEnd };
|
| 301 |
+
} else {
|
| 302 |
+
for (const { parentIndex, tree } of event.trees) {
|
| 303 |
+
if (tree.end > openRange.end) {
|
| 304 |
+
const right = tree.split(openRange.end);
|
| 305 |
+
startEventQueue.pushPendingTree(
|
| 306 |
+
new RangeTreeWithParent(parentIndex, right),
|
| 307 |
+
);
|
| 308 |
+
}
|
| 309 |
+
insertChild(parentToNested, parentIndex, tree);
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
}
|
| 313 |
+
if (openRange !== undefined) {
|
| 314 |
+
result.push(nextChild(openRange, parentToNested));
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
return result;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
function insertChild(parentToNested, parentIndex, tree) {
|
| 321 |
+
let nested = parentToNested.get(parentIndex);
|
| 322 |
+
if (nested === undefined) {
|
| 323 |
+
nested = [];
|
| 324 |
+
parentToNested.set(parentIndex, nested);
|
| 325 |
+
}
|
| 326 |
+
nested.push(tree);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
function nextChild(openRange, parentToNested) {
|
| 330 |
+
const matchingTrees = [];
|
| 331 |
+
|
| 332 |
+
for (const nested of parentToNested.values()) {
|
| 333 |
+
if (
|
| 334 |
+
nested.length === 1 &&
|
| 335 |
+
nested[0].start === openRange.start &&
|
| 336 |
+
nested[0].end === openRange.end
|
| 337 |
+
) {
|
| 338 |
+
matchingTrees.push(nested[0]);
|
| 339 |
+
} else {
|
| 340 |
+
matchingTrees.push(
|
| 341 |
+
new RangeTree(openRange.start, openRange.end, 0, nested),
|
| 342 |
+
);
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
parentToNested.clear();
|
| 346 |
+
return mergeRangeTrees(matchingTrees);
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
module.exports = {
|
| 350 |
+
mergeProcessCovs,
|
| 351 |
+
mergeScriptCovs,
|
| 352 |
+
mergeFunctionCovs,
|
| 353 |
+
};
|
node_modules/@bcoe/v8-coverage/src/lib/normalize.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const {
|
| 2 |
+
compareFunctionCovs,
|
| 3 |
+
compareRangeCovs,
|
| 4 |
+
compareScriptCovs,
|
| 5 |
+
} = require("./compare");
|
| 6 |
+
const { RangeTree } = require("./range-tree");
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Normalizes a process coverage.
|
| 10 |
+
*
|
| 11 |
+
* Sorts the scripts alphabetically by `url`.
|
| 12 |
+
* Reassigns script ids: the script at index `0` receives `"0"`, the script at
|
| 13 |
+
* index `1` receives `"1"` etc.
|
| 14 |
+
* This does not normalize the script coverages.
|
| 15 |
+
*
|
| 16 |
+
* @param processCov Process coverage to normalize.
|
| 17 |
+
*/
|
| 18 |
+
function normalizeProcessCov(processCov) {
|
| 19 |
+
processCov.result.sort(compareScriptCovs);
|
| 20 |
+
for (const [scriptId, scriptCov] of processCov.result.entries()) {
|
| 21 |
+
scriptCov.scriptId = scriptId.toString(10);
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* Normalizes a process coverage deeply.
|
| 27 |
+
*
|
| 28 |
+
* Normalizes the script coverages deeply, then normalizes the process coverage
|
| 29 |
+
* itself.
|
| 30 |
+
*
|
| 31 |
+
* @param processCov Process coverage to normalize.
|
| 32 |
+
*/
|
| 33 |
+
function deepNormalizeProcessCov(processCov) {
|
| 34 |
+
for (const scriptCov of processCov.result) {
|
| 35 |
+
deepNormalizeScriptCov(scriptCov);
|
| 36 |
+
}
|
| 37 |
+
normalizeProcessCov(processCov);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* Normalizes a script coverage.
|
| 42 |
+
*
|
| 43 |
+
* Sorts the function by root range (pre-order sort).
|
| 44 |
+
* This does not normalize the function coverages.
|
| 45 |
+
*
|
| 46 |
+
* @param scriptCov Script coverage to normalize.
|
| 47 |
+
*/
|
| 48 |
+
function normalizeScriptCov(scriptCov) {
|
| 49 |
+
scriptCov.functions.sort(compareFunctionCovs);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Normalizes a script coverage deeply.
|
| 54 |
+
*
|
| 55 |
+
* Normalizes the function coverages deeply, then normalizes the script coverage
|
| 56 |
+
* itself.
|
| 57 |
+
*
|
| 58 |
+
* @param scriptCov Script coverage to normalize.
|
| 59 |
+
*/
|
| 60 |
+
function deepNormalizeScriptCov(scriptCov) {
|
| 61 |
+
for (const funcCov of scriptCov.functions) {
|
| 62 |
+
normalizeFunctionCov(funcCov);
|
| 63 |
+
}
|
| 64 |
+
normalizeScriptCov(scriptCov);
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* Normalizes a function coverage.
|
| 69 |
+
*
|
| 70 |
+
* Sorts the ranges (pre-order sort).
|
| 71 |
+
* TODO: Tree-based normalization of the ranges.
|
| 72 |
+
*
|
| 73 |
+
* @param funcCov Function coverage to normalize.
|
| 74 |
+
*/
|
| 75 |
+
function normalizeFunctionCov(funcCov) {
|
| 76 |
+
funcCov.ranges.sort(compareRangeCovs);
|
| 77 |
+
const tree = RangeTree.fromSortedRanges(funcCov.ranges);
|
| 78 |
+
normalizeRangeTree(tree);
|
| 79 |
+
funcCov.ranges = tree.toRanges();
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* @internal
|
| 84 |
+
*/
|
| 85 |
+
function normalizeRangeTree(tree) {
|
| 86 |
+
tree.normalize();
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
module.exports = {
|
| 90 |
+
normalizeProcessCov,
|
| 91 |
+
deepNormalizeProcessCov,
|
| 92 |
+
normalizeScriptCov,
|
| 93 |
+
deepNormalizeScriptCov,
|
| 94 |
+
normalizeFunctionCov,
|
| 95 |
+
normalizeRangeTree,
|
| 96 |
+
};
|
node_modules/@bcoe/v8-coverage/src/lib/range-tree.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class RangeTree {
|
| 2 |
+
start;
|
| 3 |
+
end;
|
| 4 |
+
delta;
|
| 5 |
+
children;
|
| 6 |
+
|
| 7 |
+
constructor(start, end, delta, children) {
|
| 8 |
+
this.start = start;
|
| 9 |
+
this.end = end;
|
| 10 |
+
this.delta = delta;
|
| 11 |
+
this.children = children;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* @precodition `ranges` are well-formed and pre-order sorted
|
| 16 |
+
*/
|
| 17 |
+
static fromSortedRanges(ranges) {
|
| 18 |
+
let root;
|
| 19 |
+
// Stack of parent trees and parent counts.
|
| 20 |
+
const stack = [];
|
| 21 |
+
for (const range of ranges) {
|
| 22 |
+
const node = new RangeTree(
|
| 23 |
+
range.startOffset,
|
| 24 |
+
range.endOffset,
|
| 25 |
+
range.count,
|
| 26 |
+
[],
|
| 27 |
+
);
|
| 28 |
+
if (root === undefined) {
|
| 29 |
+
root = node;
|
| 30 |
+
stack.push([node, range.count]);
|
| 31 |
+
continue;
|
| 32 |
+
}
|
| 33 |
+
let parent;
|
| 34 |
+
let parentCount;
|
| 35 |
+
while (true) {
|
| 36 |
+
[parent, parentCount] = stack[stack.length - 1];
|
| 37 |
+
// assert: `top !== undefined` (the ranges are sorted)
|
| 38 |
+
if (range.startOffset < parent.end) {
|
| 39 |
+
break;
|
| 40 |
+
} else {
|
| 41 |
+
stack.pop();
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
if (stack.length === 0) {
|
| 45 |
+
break;
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
node.delta -= parentCount;
|
| 49 |
+
parent.children.push(node);
|
| 50 |
+
stack.push([node, range.count]);
|
| 51 |
+
}
|
| 52 |
+
return root;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
normalize() {
|
| 56 |
+
const children = [];
|
| 57 |
+
let curEnd;
|
| 58 |
+
let head;
|
| 59 |
+
const tail = [];
|
| 60 |
+
for (const child of this.children) {
|
| 61 |
+
if (head === undefined) {
|
| 62 |
+
head = child;
|
| 63 |
+
} else if (child.delta === head.delta && child.start === curEnd) {
|
| 64 |
+
tail.push(child);
|
| 65 |
+
} else {
|
| 66 |
+
endChain();
|
| 67 |
+
head = child;
|
| 68 |
+
}
|
| 69 |
+
curEnd = child.end;
|
| 70 |
+
}
|
| 71 |
+
if (head !== undefined) {
|
| 72 |
+
endChain();
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if (children.length === 1) {
|
| 76 |
+
const child = children[0];
|
| 77 |
+
if (child.start === this.start && child.end === this.end) {
|
| 78 |
+
this.delta += child.delta;
|
| 79 |
+
this.children = child.children;
|
| 80 |
+
// `.lazyCount` is zero for both (both are after normalization)
|
| 81 |
+
return;
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
this.children = children;
|
| 86 |
+
|
| 87 |
+
function endChain() {
|
| 88 |
+
if (tail.length !== 0) {
|
| 89 |
+
head.end = tail[tail.length - 1].end;
|
| 90 |
+
for (const tailTree of tail) {
|
| 91 |
+
for (const subChild of tailTree.children) {
|
| 92 |
+
subChild.delta += tailTree.delta - head.delta;
|
| 93 |
+
head.children.push(subChild);
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
tail.length = 0;
|
| 97 |
+
}
|
| 98 |
+
head.normalize();
|
| 99 |
+
children.push(head);
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* @precondition `tree.start < value && value < tree.end`
|
| 105 |
+
* @return RangeTree Right part
|
| 106 |
+
*/
|
| 107 |
+
split(value) {
|
| 108 |
+
let leftChildLen = this.children.length;
|
| 109 |
+
let mid;
|
| 110 |
+
|
| 111 |
+
// TODO(perf): Binary search (check overhead)
|
| 112 |
+
for (let i = 0; i < this.children.length; i++) {
|
| 113 |
+
const child = this.children[i];
|
| 114 |
+
if (child.start < value && value < child.end) {
|
| 115 |
+
mid = child.split(value);
|
| 116 |
+
leftChildLen = i + 1;
|
| 117 |
+
break;
|
| 118 |
+
} else if (child.start >= value) {
|
| 119 |
+
leftChildLen = i;
|
| 120 |
+
break;
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
const rightLen = this.children.length - leftChildLen;
|
| 125 |
+
const rightChildren = this.children.splice(leftChildLen, rightLen);
|
| 126 |
+
if (mid !== undefined) {
|
| 127 |
+
rightChildren.unshift(mid);
|
| 128 |
+
}
|
| 129 |
+
const result = new RangeTree(value, this.end, this.delta, rightChildren);
|
| 130 |
+
this.end = value;
|
| 131 |
+
return result;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/**
|
| 135 |
+
* Get the range coverages corresponding to the tree.
|
| 136 |
+
*
|
| 137 |
+
* The ranges are pre-order sorted.
|
| 138 |
+
*/
|
| 139 |
+
toRanges() {
|
| 140 |
+
const ranges = [];
|
| 141 |
+
// Stack of parent trees and counts.
|
| 142 |
+
const stack = [[this, 0]];
|
| 143 |
+
while (stack.length > 0) {
|
| 144 |
+
const [cur, parentCount] = stack.pop();
|
| 145 |
+
const count = parentCount + cur.delta;
|
| 146 |
+
ranges.push({ startOffset: cur.start, endOffset: cur.end, count });
|
| 147 |
+
for (let i = cur.children.length - 1; i >= 0; i--) {
|
| 148 |
+
stack.push([cur.children[i], count]);
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
return ranges;
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
module.exports = {
|
| 156 |
+
RangeTree,
|
| 157 |
+
};
|
node_modules/@borewit/text-codec/LICENSE.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The MIT License (MIT)
|
| 2 |
+
|
| 3 |
+
Copyright © 2025 Borewit
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 6 |
+
|
| 7 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 8 |
+
|
| 9 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
node_modules/@borewit/text-codec/README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[](https://github.com/Borewit/text-codec/actions/workflows/ci.yml)
|
| 2 |
+
[](https://www.npmjs.com/package/@borewit/text-codec)
|
| 3 |
+
[](https://npmcharts.com/compare/@borewit/text-codec?interval=30)
|
| 4 |
+

|
| 5 |
+
[](LICENSE.txt)
|
| 6 |
+
|
| 7 |
+
# `@borewit/text-codec`
|
| 8 |
+
|
| 9 |
+
A **lightweight polyfill for text encoders and decoders** covering a small set of commonly used encodings.
|
| 10 |
+
|
| 11 |
+
Some JavaScript runtimes provide limited or inconsistent encoding support through `TextEncoder` and `TextDecoder`.
|
| 12 |
+
Examples include environments like **Hermes (React Native)** or certain **Node.js builds with limited ICU support**.
|
| 13 |
+
|
| 14 |
+
This module provides **reliable encode/decode support for a small set of encodings that may be missing or unreliable in those environments**.
|
| 15 |
+
|
| 16 |
+
- If a native UTF-8 `TextEncoder` / `TextDecoder` is available, it is used.
|
| 17 |
+
- All other encodings are implemented by this library.
|
| 18 |
+
|
| 19 |
+
## Supported encodings
|
| 20 |
+
|
| 21 |
+
- `utf-8` / `utf8`
|
| 22 |
+
- `utf-16le`
|
| 23 |
+
- `ascii`
|
| 24 |
+
- `latin1` / `iso-8859-1`
|
| 25 |
+
- `windows-1252`
|
| 26 |
+
|
| 27 |
+
These encodings are commonly encountered in metadata formats and legacy text data.
|
| 28 |
+
|
| 29 |
+
## ✨ Features
|
| 30 |
+
|
| 31 |
+
- Encoding and decoding utilities
|
| 32 |
+
- Lightweight
|
| 33 |
+
- Typed API
|
| 34 |
+
|
| 35 |
+
## 📦 Installation
|
| 36 |
+
|
| 37 |
+
```sh
|
| 38 |
+
npm install @borewit/text-codec
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
# 📚 API Documentation
|
| 42 |
+
|
| 43 |
+
## `textDecode(bytes, encoding): string`
|
| 44 |
+
|
| 45 |
+
Decodes binary data into a JavaScript string.
|
| 46 |
+
|
| 47 |
+
**Parameters**
|
| 48 |
+
- `bytes` (`Uint8Array`) — The binary data to decode.
|
| 49 |
+
- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `"utf-8"`.
|
| 50 |
+
|
| 51 |
+
**Returns**
|
| 52 |
+
- `string` — The decoded text.
|
| 53 |
+
|
| 54 |
+
**Example**
|
| 55 |
+
```js
|
| 56 |
+
import { textDecode } from "@borewit/text-codec";
|
| 57 |
+
|
| 58 |
+
const bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);
|
| 59 |
+
const text = textDecode(bytes, "ascii");
|
| 60 |
+
console.log(text); // "Hello"
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
## `textEncode(input, encoding): Uint8Array`
|
| 64 |
+
|
| 65 |
+
Encodes a JavaScript string into binary form using the specified encoding.
|
| 66 |
+
|
| 67 |
+
**Parameters**
|
| 68 |
+
|
| 69 |
+
- `input` (`string`) — The string to encode.
|
| 70 |
+
- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `"utf-8"`.
|
| 71 |
+
|
| 72 |
+
**Returns**
|
| 73 |
+
|
| 74 |
+
`Uint8Array` — The encoded binary data.
|
| 75 |
+
|
| 76 |
+
Example:
|
| 77 |
+
```js
|
| 78 |
+
import { textEncode } from "@borewit/text-codec";
|
| 79 |
+
|
| 80 |
+
const bytes = textEncode("Hello", "utf-16le");
|
| 81 |
+
console.log(bytes); // Uint8Array([...])
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## 📜 Licence
|
| 85 |
+
|
| 86 |
+
This project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.
|
| 87 |
+
|
node_modules/@borewit/text-codec/lib/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type SupportedEncoding = "utf-8" | "utf8" | "utf-16le" | "us-ascii" | "ascii" | "latin1" | "iso-8859-1" | "windows-1252";
|
| 2 |
+
/**
|
| 3 |
+
* Decode text from binary data
|
| 4 |
+
*/
|
| 5 |
+
export declare function textDecode(bytes: Uint8Array, encoding?: SupportedEncoding): string;
|
| 6 |
+
export declare function textEncode(input?: string, encoding?: SupportedEncoding): Uint8Array;
|
node_modules/@borewit/text-codec/lib/index.js
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const WINDOWS_1252_EXTRA = {
|
| 2 |
+
0x80: "€", 0x82: "‚", 0x83: "ƒ", 0x84: "„", 0x85: "…", 0x86: "†",
|
| 3 |
+
0x87: "‡", 0x88: "ˆ", 0x89: "‰", 0x8a: "Š", 0x8b: "‹", 0x8c: "Œ",
|
| 4 |
+
0x8e: "Ž", 0x91: "‘", 0x92: "’", 0x93: "“", 0x94: "”", 0x95: "•",
|
| 5 |
+
0x96: "–", 0x97: "—", 0x98: "˜", 0x99: "™", 0x9a: "š", 0x9b: "›",
|
| 6 |
+
0x9c: "œ", 0x9e: "ž", 0x9f: "Ÿ",
|
| 7 |
+
};
|
| 8 |
+
const WINDOWS_1252_REVERSE = {};
|
| 9 |
+
for (const [code, char] of Object.entries(WINDOWS_1252_EXTRA)) {
|
| 10 |
+
WINDOWS_1252_REVERSE[char] = Number.parseInt(code, 10);
|
| 11 |
+
}
|
| 12 |
+
let _utf8Decoder;
|
| 13 |
+
let _utf8Encoder;
|
| 14 |
+
function utf8Decoder() {
|
| 15 |
+
if (typeof globalThis.TextDecoder === "undefined")
|
| 16 |
+
return undefined;
|
| 17 |
+
return (_utf8Decoder !== null && _utf8Decoder !== void 0 ? _utf8Decoder : (_utf8Decoder = new globalThis.TextDecoder("utf-8")));
|
| 18 |
+
}
|
| 19 |
+
function utf8Encoder() {
|
| 20 |
+
if (typeof globalThis.TextEncoder === "undefined")
|
| 21 |
+
return undefined;
|
| 22 |
+
return (_utf8Encoder !== null && _utf8Encoder !== void 0 ? _utf8Encoder : (_utf8Encoder = new globalThis.TextEncoder()));
|
| 23 |
+
}
|
| 24 |
+
const CHUNK = 32 * 1024;
|
| 25 |
+
const REPLACEMENT = 0xfffd;
|
| 26 |
+
/**
|
| 27 |
+
* Decode text from binary data
|
| 28 |
+
*/
|
| 29 |
+
export function textDecode(bytes, encoding = "utf-8") {
|
| 30 |
+
switch (encoding.toLowerCase()) {
|
| 31 |
+
case "utf-8":
|
| 32 |
+
case "utf8": {
|
| 33 |
+
const dec = utf8Decoder();
|
| 34 |
+
return dec ? dec.decode(bytes) : decodeUTF8(bytes);
|
| 35 |
+
}
|
| 36 |
+
case "utf-16le":
|
| 37 |
+
return decodeUTF16LE(bytes);
|
| 38 |
+
case "us-ascii":
|
| 39 |
+
case "ascii":
|
| 40 |
+
return decodeASCII(bytes);
|
| 41 |
+
case "latin1":
|
| 42 |
+
case "iso-8859-1":
|
| 43 |
+
return decodeLatin1(bytes);
|
| 44 |
+
case "windows-1252":
|
| 45 |
+
return decodeWindows1252(bytes);
|
| 46 |
+
default:
|
| 47 |
+
throw new RangeError(`Encoding '${encoding}' not supported`);
|
| 48 |
+
}
|
| 49 |
+
}
|
| 50 |
+
export function textEncode(input = "", encoding = "utf-8") {
|
| 51 |
+
switch (encoding.toLowerCase()) {
|
| 52 |
+
case "utf-8":
|
| 53 |
+
case "utf8": {
|
| 54 |
+
const enc = utf8Encoder();
|
| 55 |
+
return enc ? enc.encode(input) : encodeUTF8(input);
|
| 56 |
+
}
|
| 57 |
+
case "utf-16le":
|
| 58 |
+
return encodeUTF16LE(input);
|
| 59 |
+
case "us-ascii":
|
| 60 |
+
case "ascii":
|
| 61 |
+
return encodeASCII(input);
|
| 62 |
+
case "latin1":
|
| 63 |
+
case "iso-8859-1":
|
| 64 |
+
return encodeLatin1(input);
|
| 65 |
+
case "windows-1252":
|
| 66 |
+
return encodeWindows1252(input);
|
| 67 |
+
default:
|
| 68 |
+
throw new RangeError(`Encoding '${encoding}' not supported`);
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
function appendCodePoint(out, cp) {
|
| 72 |
+
if (cp <= 0xffff) {
|
| 73 |
+
out.push(String.fromCharCode(cp));
|
| 74 |
+
return;
|
| 75 |
+
}
|
| 76 |
+
cp -= 0x10000;
|
| 77 |
+
out.push(String.fromCharCode(0xd800 + (cp >> 10), 0xdc00 + (cp & 0x3ff)));
|
| 78 |
+
}
|
| 79 |
+
function flushChunk(parts, chunk) {
|
| 80 |
+
if (chunk.length === 0)
|
| 81 |
+
return;
|
| 82 |
+
parts.push(String.fromCharCode.apply(null, chunk));
|
| 83 |
+
chunk.length = 0;
|
| 84 |
+
}
|
| 85 |
+
function pushCodeUnit(parts, chunk, codeUnit) {
|
| 86 |
+
chunk.push(codeUnit);
|
| 87 |
+
if (chunk.length >= CHUNK)
|
| 88 |
+
flushChunk(parts, chunk);
|
| 89 |
+
}
|
| 90 |
+
function pushCodePoint(parts, chunk, cp) {
|
| 91 |
+
if (cp <= 0xffff) {
|
| 92 |
+
pushCodeUnit(parts, chunk, cp);
|
| 93 |
+
return;
|
| 94 |
+
}
|
| 95 |
+
cp -= 0x10000;
|
| 96 |
+
pushCodeUnit(parts, chunk, 0xd800 + (cp >> 10));
|
| 97 |
+
pushCodeUnit(parts, chunk, 0xdc00 + (cp & 0x3ff));
|
| 98 |
+
}
|
| 99 |
+
function decodeUTF8(bytes) {
|
| 100 |
+
const parts = [];
|
| 101 |
+
const chunk = [];
|
| 102 |
+
let i = 0;
|
| 103 |
+
// Match TextDecoder("utf-8") default BOM handling
|
| 104 |
+
if (bytes.length >= 3 &&
|
| 105 |
+
bytes[0] === 0xef &&
|
| 106 |
+
bytes[1] === 0xbb &&
|
| 107 |
+
bytes[2] === 0xbf) {
|
| 108 |
+
i = 3;
|
| 109 |
+
}
|
| 110 |
+
while (i < bytes.length) {
|
| 111 |
+
const b1 = bytes[i];
|
| 112 |
+
if (b1 <= 0x7f) {
|
| 113 |
+
pushCodeUnit(parts, chunk, b1);
|
| 114 |
+
i++;
|
| 115 |
+
continue;
|
| 116 |
+
}
|
| 117 |
+
// Invalid leading bytes: continuation byte or impossible prefixes
|
| 118 |
+
if (b1 < 0xc2 || b1 > 0xf4) {
|
| 119 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 120 |
+
i++;
|
| 121 |
+
continue;
|
| 122 |
+
}
|
| 123 |
+
// 2-byte sequence
|
| 124 |
+
if (b1 <= 0xdf) {
|
| 125 |
+
if (i + 1 >= bytes.length) {
|
| 126 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 127 |
+
i++;
|
| 128 |
+
continue;
|
| 129 |
+
}
|
| 130 |
+
const b2 = bytes[i + 1];
|
| 131 |
+
if ((b2 & 0xc0) !== 0x80) {
|
| 132 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 133 |
+
i++;
|
| 134 |
+
continue;
|
| 135 |
+
}
|
| 136 |
+
const cp = ((b1 & 0x1f) << 6) | (b2 & 0x3f);
|
| 137 |
+
pushCodeUnit(parts, chunk, cp);
|
| 138 |
+
i += 2;
|
| 139 |
+
continue;
|
| 140 |
+
}
|
| 141 |
+
// 3-byte sequence
|
| 142 |
+
if (b1 <= 0xef) {
|
| 143 |
+
if (i + 2 >= bytes.length) {
|
| 144 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 145 |
+
i++;
|
| 146 |
+
continue;
|
| 147 |
+
}
|
| 148 |
+
const b2 = bytes[i + 1];
|
| 149 |
+
const b3 = bytes[i + 2];
|
| 150 |
+
const valid = (b2 & 0xc0) === 0x80 &&
|
| 151 |
+
(b3 & 0xc0) === 0x80 &&
|
| 152 |
+
!(b1 === 0xe0 && b2 < 0xa0) && // overlong
|
| 153 |
+
!(b1 === 0xed && b2 >= 0xa0); // surrogate range
|
| 154 |
+
if (!valid) {
|
| 155 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 156 |
+
i++;
|
| 157 |
+
continue;
|
| 158 |
+
}
|
| 159 |
+
const cp = ((b1 & 0x0f) << 12) |
|
| 160 |
+
((b2 & 0x3f) << 6) |
|
| 161 |
+
(b3 & 0x3f);
|
| 162 |
+
pushCodeUnit(parts, chunk, cp);
|
| 163 |
+
i += 3;
|
| 164 |
+
continue;
|
| 165 |
+
}
|
| 166 |
+
// 4-byte sequence
|
| 167 |
+
if (i + 3 >= bytes.length) {
|
| 168 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 169 |
+
i++;
|
| 170 |
+
continue;
|
| 171 |
+
}
|
| 172 |
+
const b2 = bytes[i + 1];
|
| 173 |
+
const b3 = bytes[i + 2];
|
| 174 |
+
const b4 = bytes[i + 3];
|
| 175 |
+
const valid = (b2 & 0xc0) === 0x80 &&
|
| 176 |
+
(b3 & 0xc0) === 0x80 &&
|
| 177 |
+
(b4 & 0xc0) === 0x80 &&
|
| 178 |
+
!(b1 === 0xf0 && b2 < 0x90) && // overlong
|
| 179 |
+
!(b1 === 0xf4 && b2 > 0x8f); // > U+10FFFF
|
| 180 |
+
if (!valid) {
|
| 181 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 182 |
+
i++;
|
| 183 |
+
continue;
|
| 184 |
+
}
|
| 185 |
+
const cp = ((b1 & 0x07) << 18) |
|
| 186 |
+
((b2 & 0x3f) << 12) |
|
| 187 |
+
((b3 & 0x3f) << 6) |
|
| 188 |
+
(b4 & 0x3f);
|
| 189 |
+
pushCodePoint(parts, chunk, cp);
|
| 190 |
+
i += 4;
|
| 191 |
+
}
|
| 192 |
+
flushChunk(parts, chunk);
|
| 193 |
+
return parts.join("");
|
| 194 |
+
}
|
| 195 |
+
function decodeUTF16LE(bytes) {
|
| 196 |
+
const parts = [];
|
| 197 |
+
const chunk = [];
|
| 198 |
+
const len = bytes.length;
|
| 199 |
+
let i = 0;
|
| 200 |
+
while (i + 1 < len) {
|
| 201 |
+
const u1 = bytes[i] | (bytes[i + 1] << 8);
|
| 202 |
+
i += 2;
|
| 203 |
+
// High surrogate
|
| 204 |
+
if (u1 >= 0xd800 && u1 <= 0xdbff) {
|
| 205 |
+
if (i + 1 < len) {
|
| 206 |
+
const u2 = bytes[i] | (bytes[i + 1] << 8);
|
| 207 |
+
if (u2 >= 0xdc00 && u2 <= 0xdfff) {
|
| 208 |
+
pushCodeUnit(parts, chunk, u1);
|
| 209 |
+
pushCodeUnit(parts, chunk, u2);
|
| 210 |
+
i += 2;
|
| 211 |
+
}
|
| 212 |
+
else {
|
| 213 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
else {
|
| 217 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 218 |
+
}
|
| 219 |
+
continue;
|
| 220 |
+
}
|
| 221 |
+
// Lone low surrogate
|
| 222 |
+
if (u1 >= 0xdc00 && u1 <= 0xdfff) {
|
| 223 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 224 |
+
continue;
|
| 225 |
+
}
|
| 226 |
+
pushCodeUnit(parts, chunk, u1);
|
| 227 |
+
}
|
| 228 |
+
// Odd trailing byte
|
| 229 |
+
if (i < len) {
|
| 230 |
+
pushCodeUnit(parts, chunk, REPLACEMENT);
|
| 231 |
+
}
|
| 232 |
+
flushChunk(parts, chunk);
|
| 233 |
+
return parts.join("");
|
| 234 |
+
}
|
| 235 |
+
function decodeASCII(bytes) {
|
| 236 |
+
const parts = [];
|
| 237 |
+
for (let i = 0; i < bytes.length; i += CHUNK) {
|
| 238 |
+
const end = Math.min(bytes.length, i + CHUNK);
|
| 239 |
+
const codes = new Array(end - i);
|
| 240 |
+
for (let j = i, k = 0; j < end; j++, k++) {
|
| 241 |
+
codes[k] = bytes[j] & 0x7f;
|
| 242 |
+
}
|
| 243 |
+
parts.push(String.fromCharCode.apply(null, codes));
|
| 244 |
+
}
|
| 245 |
+
return parts.join("");
|
| 246 |
+
}
|
| 247 |
+
function decodeLatin1(bytes) {
|
| 248 |
+
const parts = [];
|
| 249 |
+
for (let i = 0; i < bytes.length; i += CHUNK) {
|
| 250 |
+
const end = Math.min(bytes.length, i + CHUNK);
|
| 251 |
+
const codes = new Array(end - i);
|
| 252 |
+
for (let j = i, k = 0; j < end; j++, k++) {
|
| 253 |
+
codes[k] = bytes[j];
|
| 254 |
+
}
|
| 255 |
+
parts.push(String.fromCharCode.apply(null, codes));
|
| 256 |
+
}
|
| 257 |
+
return parts.join("");
|
| 258 |
+
}
|
| 259 |
+
function decodeWindows1252(bytes) {
|
| 260 |
+
const parts = [];
|
| 261 |
+
let out = "";
|
| 262 |
+
for (let i = 0; i < bytes.length; i++) {
|
| 263 |
+
const b = bytes[i];
|
| 264 |
+
const extra = b >= 0x80 && b <= 0x9f ? WINDOWS_1252_EXTRA[b] : undefined;
|
| 265 |
+
out += extra !== null && extra !== void 0 ? extra : String.fromCharCode(b);
|
| 266 |
+
if (out.length >= CHUNK) {
|
| 267 |
+
parts.push(out);
|
| 268 |
+
out = "";
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
if (out)
|
| 272 |
+
parts.push(out);
|
| 273 |
+
return parts.join("");
|
| 274 |
+
}
|
| 275 |
+
function encodeUTF8(str) {
|
| 276 |
+
const out = [];
|
| 277 |
+
for (let i = 0; i < str.length; i++) {
|
| 278 |
+
let cp = str.charCodeAt(i);
|
| 279 |
+
// Valid surrogate pair
|
| 280 |
+
if (cp >= 0xd800 && cp <= 0xdbff) {
|
| 281 |
+
if (i + 1 < str.length) {
|
| 282 |
+
const lo = str.charCodeAt(i + 1);
|
| 283 |
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
| 284 |
+
cp = 0x10000 + ((cp - 0xd800) << 10) + (lo - 0xdc00);
|
| 285 |
+
i++;
|
| 286 |
+
}
|
| 287 |
+
else {
|
| 288 |
+
cp = REPLACEMENT;
|
| 289 |
+
}
|
| 290 |
+
}
|
| 291 |
+
else {
|
| 292 |
+
cp = REPLACEMENT;
|
| 293 |
+
}
|
| 294 |
+
}
|
| 295 |
+
else if (cp >= 0xdc00 && cp <= 0xdfff) {
|
| 296 |
+
// Lone low surrogate
|
| 297 |
+
cp = REPLACEMENT;
|
| 298 |
+
}
|
| 299 |
+
if (cp < 0x80) {
|
| 300 |
+
out.push(cp);
|
| 301 |
+
}
|
| 302 |
+
else if (cp < 0x800) {
|
| 303 |
+
out.push(0xc0 | (cp >> 6), 0x80 | (cp & 0x3f));
|
| 304 |
+
}
|
| 305 |
+
else if (cp < 0x10000) {
|
| 306 |
+
out.push(0xe0 | (cp >> 12), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
|
| 307 |
+
}
|
| 308 |
+
else {
|
| 309 |
+
out.push(0xf0 | (cp >> 18), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
|
| 310 |
+
}
|
| 311 |
+
}
|
| 312 |
+
return new Uint8Array(out);
|
| 313 |
+
}
|
| 314 |
+
function encodeUTF16LE(str) {
|
| 315 |
+
// Preserve JS string code units, but do not emit non-well-formed UTF-16.
|
| 316 |
+
// Replace lone surrogates with U+FFFD.
|
| 317 |
+
const units = [];
|
| 318 |
+
for (let i = 0; i < str.length; i++) {
|
| 319 |
+
const u = str.charCodeAt(i);
|
| 320 |
+
if (u >= 0xd800 && u <= 0xdbff) {
|
| 321 |
+
if (i + 1 < str.length) {
|
| 322 |
+
const lo = str.charCodeAt(i + 1);
|
| 323 |
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
| 324 |
+
units.push(u, lo);
|
| 325 |
+
i++;
|
| 326 |
+
}
|
| 327 |
+
else {
|
| 328 |
+
units.push(REPLACEMENT);
|
| 329 |
+
}
|
| 330 |
+
}
|
| 331 |
+
else {
|
| 332 |
+
units.push(REPLACEMENT);
|
| 333 |
+
}
|
| 334 |
+
continue;
|
| 335 |
+
}
|
| 336 |
+
if (u >= 0xdc00 && u <= 0xdfff) {
|
| 337 |
+
units.push(REPLACEMENT);
|
| 338 |
+
continue;
|
| 339 |
+
}
|
| 340 |
+
units.push(u);
|
| 341 |
+
}
|
| 342 |
+
const out = new Uint8Array(units.length * 2);
|
| 343 |
+
for (let i = 0; i < units.length; i++) {
|
| 344 |
+
const code = units[i];
|
| 345 |
+
const o = i * 2;
|
| 346 |
+
out[o] = code & 0xff;
|
| 347 |
+
out[o + 1] = code >>> 8;
|
| 348 |
+
}
|
| 349 |
+
return out;
|
| 350 |
+
}
|
| 351 |
+
function encodeASCII(str) {
|
| 352 |
+
const out = new Uint8Array(str.length);
|
| 353 |
+
for (let i = 0; i < str.length; i++)
|
| 354 |
+
out[i] = str.charCodeAt(i) & 0x7f;
|
| 355 |
+
return out;
|
| 356 |
+
}
|
| 357 |
+
function encodeLatin1(str) {
|
| 358 |
+
const out = new Uint8Array(str.length);
|
| 359 |
+
for (let i = 0; i < str.length; i++)
|
| 360 |
+
out[i] = str.charCodeAt(i) & 0xff;
|
| 361 |
+
return out;
|
| 362 |
+
}
|
| 363 |
+
function encodeWindows1252(str) {
|
| 364 |
+
const out = new Uint8Array(str.length);
|
| 365 |
+
for (let i = 0; i < str.length; i++) {
|
| 366 |
+
const ch = str[i];
|
| 367 |
+
const code = ch.charCodeAt(0);
|
| 368 |
+
if (WINDOWS_1252_REVERSE[ch] !== undefined) {
|
| 369 |
+
out[i] = WINDOWS_1252_REVERSE[ch];
|
| 370 |
+
continue;
|
| 371 |
+
}
|
| 372 |
+
if ((code >= 0x00 && code <= 0x7f) ||
|
| 373 |
+
(code >= 0xa0 && code <= 0xff)) {
|
| 374 |
+
out[i] = code;
|
| 375 |
+
continue;
|
| 376 |
+
}
|
| 377 |
+
out[i] = 0x3f; // '?'
|
| 378 |
+
}
|
| 379 |
+
return out;
|
| 380 |
+
}
|
node_modules/@borewit/text-codec/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@borewit/text-codec",
|
| 3 |
+
"version": "0.2.2",
|
| 4 |
+
"description": "Text Decoder",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"exports": "./lib/index.js",
|
| 7 |
+
"types": "lib/index.d.ts",
|
| 8 |
+
"files": [
|
| 9 |
+
"lib/index.js",
|
| 10 |
+
"lib/index.d.ts"
|
| 11 |
+
],
|
| 12 |
+
"scripts": {
|
| 13 |
+
"clean": "del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map",
|
| 14 |
+
"build": "npm run compile",
|
| 15 |
+
"prepublishOnly": "npm run build",
|
| 16 |
+
"compile:src": "tsc --p lib --sourceMap false",
|
| 17 |
+
"compile:test": "tsc --p test",
|
| 18 |
+
"compile": "npm run compile:src && npm run compile:test",
|
| 19 |
+
"lint": "biome check",
|
| 20 |
+
"test": "mocha",
|
| 21 |
+
"update-biome": "npm install --save-dev --save-exact @biomejs/biome@latest && npx @biomejs/biome migrate --write"
|
| 22 |
+
},
|
| 23 |
+
"devDependencies": {
|
| 24 |
+
"@biomejs/biome": "2.4.6",
|
| 25 |
+
"@types/chai": "^5.2.2",
|
| 26 |
+
"@types/mocha": "^10.0.10",
|
| 27 |
+
"chai": "^6.2.2",
|
| 28 |
+
"mocha": "^11.7.5",
|
| 29 |
+
"ts-node": "^10.9.2",
|
| 30 |
+
"typescript": "^5.9.3"
|
| 31 |
+
},
|
| 32 |
+
"keywords": [
|
| 33 |
+
"TextDecoder",
|
| 34 |
+
"TextEncoder",
|
| 35 |
+
"decoder",
|
| 36 |
+
"decoding",
|
| 37 |
+
"encod",
|
| 38 |
+
"encoding",
|
| 39 |
+
"decode",
|
| 40 |
+
"text",
|
| 41 |
+
"ascii",
|
| 42 |
+
"utf-8",
|
| 43 |
+
"utf8",
|
| 44 |
+
"utf-16le",
|
| 45 |
+
"latin1",
|
| 46 |
+
"iso-8859-1",
|
| 47 |
+
"windows-1252",
|
| 48 |
+
"charset",
|
| 49 |
+
"encoding",
|
| 50 |
+
"decoding",
|
| 51 |
+
"polyfill",
|
| 52 |
+
"character-set",
|
| 53 |
+
"latin",
|
| 54 |
+
"hermes",
|
| 55 |
+
"react"
|
| 56 |
+
],
|
| 57 |
+
"repository": {
|
| 58 |
+
"type": "git",
|
| 59 |
+
"url": "git+https://github.com/Borewit/text-codec.git"
|
| 60 |
+
},
|
| 61 |
+
"author": {
|
| 62 |
+
"name": "Borewit",
|
| 63 |
+
"url": "https://github.com/Borewit"
|
| 64 |
+
},
|
| 65 |
+
"funding": {
|
| 66 |
+
"type": "github",
|
| 67 |
+
"url": "https://github.com/sponsors/Borewit"
|
| 68 |
+
},
|
| 69 |
+
"license": "MIT"
|
| 70 |
+
}
|
node_modules/@bramus/specificity/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2022 Bramus Van Damme - https://www.bram.us/
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 4 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 5 |
+
in the Software without restriction, including without limitation the rights
|
| 6 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 7 |
+
copies of the Software, and to permit persons to whom the Software is furnished
|
| 8 |
+
to do so, subject to the following conditions:
|
| 9 |
+
|
| 10 |
+
The above copyright notice and this permission notice shall be included in all
|
| 11 |
+
copies or substantial portions of the Software.
|
| 12 |
+
|
| 13 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 14 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 15 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 16 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 17 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 18 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 19 |
+
THE SOFTWARE.
|
node_modules/@bramus/specificity/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[](https://codepen.io/bramus/pen/WNXyoYm)
|
| 2 |
+
|
| 3 |
+
# Specificity
|
| 4 |
+
|
| 5 |
+
`@bramus/specificity` is a package to calculate the specificity of CSS Selectors. It also includes some convenience functions to compare, sort, and filter an array of specificity values.
|
| 6 |
+
|
| 7 |
+
Supports [Selectors Level 4](https://www.w3.org/TR/selectors-4/), including those special cases `:is()`, `:where()`, `:not()`, etc.
|
| 8 |
+
|
| 9 |
+
Demo: [https://codepen.io/bramus/pen/WNXyoYm](https://codepen.io/bramus/pen/WNXyoYm)
|
| 10 |
+
|
| 11 |
+
## Installation
|
| 12 |
+
|
| 13 |
+
```bash
|
| 14 |
+
npm i @bramus/specificity
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
## Usage / Example
|
| 18 |
+
|
| 19 |
+
At its core, `@bramus/specificity` exposes a `Specificity` class. Its static `calculate` method can be used to calculate the specificity of a given CSS [Selector List](https://www.w3.org/TR/selectors-4/#grouping) string.
|
| 20 |
+
|
| 21 |
+
```js
|
| 22 |
+
import Specificity from '@bramus/specificity';
|
| 23 |
+
|
| 24 |
+
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
|
| 25 |
+
```
|
| 26 |
+
|
| 27 |
+
Because `calculate` accepts a [Selector List](https://www.w3.org/TR/selectors-4/#grouping) — which can contain more than 1 [Selector](https://www.w3.org/TR/selectors-4/#selector) — it will always return an array, with each entry being a `Specificity` instance — one per found selector.
|
| 28 |
+
|
| 29 |
+
```js
|
| 30 |
+
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
|
| 31 |
+
specificities.map((s) => s.toString()); // ~> ["(0,1,3)","(1,0,0)"]
|
| 32 |
+
```
|
| 33 |
+
|
| 34 |
+
💡 If you know you’re passing only a single Selector into `calculate()`, you can use JavaScript’s built-in destructuring to keep your variable names clean.
|
| 35 |
+
|
| 36 |
+
```js
|
| 37 |
+
const [s] = Specificity.calculate('header:where(#top) nav li:nth-child(2n)');
|
| 38 |
+
s.toString(); // ~> "(0,1,3)"
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
💡 Under the hood, `@bramus/specificity` uses [CSSTree](https://github.com/csstree/csstree) to do the parsing of strings to Selectors. As a result, the `calculate` method also accepts a [CSSTree AST](https://github.com/csstree/csstree/blob/master/docs/ast.md) of the types `Selector` and `SelectorList`.
|
| 42 |
+
|
| 43 |
+
If you have a pre-parsed CSSTree AST of the type `Selector` you can pass it into `Specificity.calculateForAST()`. It [performs slightly better](#benchmark) than `Specificity.calculate()` as it needs to check fewer things. It differs from `Specificity.calculate()` in that it does not return an array of `Specificity` instances but only a single value.
|
| 44 |
+
|
| 45 |
+
## The Return Format
|
| 46 |
+
|
| 47 |
+
A calculated specificity is represented as an instance of the `Specificity` class. The `Specificity` class includes methods to get the specificity value in a certain format, along with some convenience methods to compare it against other instances.
|
| 48 |
+
|
| 49 |
+
```js
|
| 50 |
+
// 🚀 Thunderbirds are go!
|
| 51 |
+
import Specificity from '@bramus/specificity';
|
| 52 |
+
|
| 53 |
+
// ✨ Calculate specificity for each Selector in the given Selector List
|
| 54 |
+
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
|
| 55 |
+
|
| 56 |
+
// 🚚 The values in the array are instances of the Specificity class
|
| 57 |
+
const s = specificities[0]; // Instance of Specificity
|
| 58 |
+
|
| 59 |
+
// 👀 Read the specificity value using one of its accessors
|
| 60 |
+
s.value; // { a: 0, b: 1, c: 3 }
|
| 61 |
+
s.a; // 0
|
| 62 |
+
s.b; // 1
|
| 63 |
+
s.c; // 3
|
| 64 |
+
|
| 65 |
+
// 🛠 Convert the calculated value to various formats using one of the toXXX() instance methods
|
| 66 |
+
s.toString(); // "(0,1,3)"
|
| 67 |
+
s.toArray(); // [0, 1, 3]
|
| 68 |
+
s.toObject(); // { a: 0, b: 1, c: 3 }
|
| 69 |
+
|
| 70 |
+
// 💡 Extract the matched selector string
|
| 71 |
+
s.selectorString(); // "header:where(#top) nav li:nth-child(2n)"
|
| 72 |
+
|
| 73 |
+
// 🔀 Use one of its instance comparison methods to compare it to another Specificity instance
|
| 74 |
+
s.isEqualTo(specificities[1]); // false
|
| 75 |
+
s.isGreaterThan(specificities[1]); // false
|
| 76 |
+
s.isLessThan(specificities[1]); // true
|
| 77 |
+
|
| 78 |
+
// 💻 Don’t worry about JSON.stringify()
|
| 79 |
+
JSON.stringify(s);
|
| 80 |
+
// {
|
| 81 |
+
// "selector": 'header:where(#top) nav li:nth-child(2n)',
|
| 82 |
+
// "asObject": { "a": 0, "b": 1, "c": 3 },
|
| 83 |
+
// "asArray": [0, 1, 3],
|
| 84 |
+
// "asString": "(0,1,3)",
|
| 85 |
+
// }
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
## Utility Functions (Static Methods)
|
| 89 |
+
|
| 90 |
+
This package also exposes some utility functions to work with specificities. These utility functions are all exposed as static methods on the `Specificity` class.
|
| 91 |
+
|
| 92 |
+
- Comparing:
|
| 93 |
+
|
| 94 |
+
- `Specificity.compare(s1, s2)`: Compares s1 to s2. Returns a value that can be:
|
| 95 |
+
- `> 0` = Sort s2 before s1 _(i.e. s1 is more specific than s2)_
|
| 96 |
+
- `0` = Keep original order of s1 and s2 _(i.e. s1 and s2 are equally specific)_
|
| 97 |
+
- `< 0` = Sort s1 before s2 _(i.e. s1 is less specific than s2)_
|
| 98 |
+
- `Specificity.equals(s1, s2)`: Returns `true` if s1 and s2 have the same specificity. If not, `false` is returned.
|
| 99 |
+
- `Specificity.greaterThan(s1, s2)`: Returns `true` if s1 has a higher specificity than s2. If not, `false` is returned.
|
| 100 |
+
- `Specificity.lessThan(s1, s2)`: Returns `true` if s1 has a lower specificity than s2. If not, `false` is returned.
|
| 101 |
+
|
| 102 |
+
- Sorting:
|
| 103 |
+
|
| 104 |
+
- `Specificity.sortAsc(s1, s2, …, sN)`: Sorts the given specificities in ascending order _(low specificity to high specificity)_
|
| 105 |
+
- `Specificity.sortDesc(s1, s2, …, sN)`: Sorts the given specificities in descending order _(high specificity to low specificity)_
|
| 106 |
+
|
| 107 |
+
- Filtering:
|
| 108 |
+
- `Specificity.min(s1, s2, …, sN)`: Filters out the value with the lowest specificity
|
| 109 |
+
- `Specificity.max(s1, s2, …, sN)`: Filters out the value with the highest specificity
|
| 110 |
+
|
| 111 |
+
A specificity passed into any of these utility functions can be any of:
|
| 112 |
+
|
| 113 |
+
- An instance of the included `Specificity` class
|
| 114 |
+
- A simple Object such as `{'a': 1, 'b': 0, 'c': 2}`
|
| 115 |
+
|
| 116 |
+
## Utility Functions (Standalone)
|
| 117 |
+
|
| 118 |
+
All static methods the `Specificity` class exposes are also exported as standalone functions using [Subpath Exports](https://nodejs.org/api/packages.html#subpath-exports).
|
| 119 |
+
|
| 120 |
+
If you're only interested in including some of these functions into your project you can import them from their Subpath. As a result, your bundle size will be reduced greatly _(except for including the standalone `calculate`, as it returns an array of `Specificity` instances that relies on the whole lot)_
|
| 121 |
+
|
| 122 |
+
```js
|
| 123 |
+
import { calculate, calculateForAST } from '@bramus/specificity/core';
|
| 124 |
+
import { compare, equals, greaterThan, lessThan } from '@bramus/specificity/compare';
|
| 125 |
+
import { min, max } from '@bramus/specificity/filter';
|
| 126 |
+
import { sortAsc, sortDesc } from '@bramus/specificity/sort';
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
## Type Definitions
|
| 130 |
+
|
| 131 |
+
Although `@bramus/specificity` is written in Vanilla JavaScript, it does include [Type Definitions](https://www.typescriptlang.org/docs/handbook/2/type-declarations.html) which are exposed via its `package.json`.
|
| 132 |
+
|
| 133 |
+
## Binary/CLI
|
| 134 |
+
|
| 135 |
+
`@bramus/specificity` exposes a binary named `specificity` to calculate the specificity of a given selector list on the CLI. For each selector that it finds, it'll print out the calculated specificity as a string on a new line.
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
$ specificity "header:where(#top) nav li:nth-child(2n), #doormat"
|
| 139 |
+
(0,1,3)
|
| 140 |
+
(1,0,0)
|
| 141 |
+
```
|
| 142 |
+
|
| 143 |
+
## Benchmark
|
| 144 |
+
|
| 145 |
+
A benchmark is included, which you can invoke using `npm run benchmark`.
|
| 146 |
+
|
| 147 |
+
Sample results (tested on a MacBook Air M3):
|
| 148 |
+
|
| 149 |
+
```
|
| 150 |
+
Specificity.calculate(string) x 420,682 ops/sec ±0.34% (98 runs sampled)
|
| 151 |
+
Specificity.calculate(ast) - using SelectorList x 8,994,080 ops/sec ±0.25% (98 runs sampled)
|
| 152 |
+
Specificity.calculate(ast) - using Selector x 11,054,856 ops/sec ±0.39% (91 runs sampled)
|
| 153 |
+
Specificity.calculateForAST(ast) x 12,652,322 ops/sec ±0.35% (96 runs sampled)
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## License
|
| 157 |
+
|
| 158 |
+
`@bramus/specificity` is released under the MIT public license. See the enclosed `LICENSE` for details.
|
| 159 |
+
|
| 160 |
+
## Acknowledgements
|
| 161 |
+
|
| 162 |
+
The idea to create this package was sparked by [the wonderful Specificity Calculator created by Kilian Valkhof / Polypane](https://polypane.app/css-specificity-calculator/), a highly educational tool that not only calculates the specificity, but also explains which parts are responsible for it.
|
| 163 |
+
|
| 164 |
+
The heavy lifting of doing the actual parsing of Selectors is done by [CSSTree](https://github.com/csstree/csstree).
|
node_modules/@bramus/specificity/bin/cli.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
import Specificity from '../dist/index.js';
|
| 3 |
+
|
| 4 |
+
if (!process.argv[2]) {
|
| 5 |
+
console.error('❌ Missing selector argument');
|
| 6 |
+
process.exit(1);
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
try {
|
| 10 |
+
const specificities = Specificity.calculate(process.argv[2]);
|
| 11 |
+
console.log(specificities.map((specificity) => `${specificity}`).join('\n'));
|
| 12 |
+
} catch (e) {
|
| 13 |
+
console.error(`❌ ${e.message}`);
|
| 14 |
+
}
|
node_modules/@bramus/specificity/dist/index.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var Kn=Object.create;var Tt=Object.defineProperty;var Qn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var Xn=Object.getPrototypeOf,Jn=Object.prototype.hasOwnProperty;var De=e=>Tt(e,"__esModule",{value:!0});var lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vt=(e,t)=>{for(var r in t)Tt(e,r,{get:t[r],enumerable:!0})},Pe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of $n(t))!Jn.call(e,s)&&(r||s!=="default")&&Tt(e,s,{get:()=>t[s],enumerable:!(n=Qn(t,s))||n.enumerable});return e},Zn=(e,t)=>Pe(De(Tt(e!=null?Kn(Xn(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),ti=(e=>(t,r)=>e&&e.get(t)||(r=Pe(De({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Ue=lt(se=>{var Be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");se.encode=function(e){if(0<=e&&e<Be.length)return Be[e];throw new TypeError("Must be between 0 and 63: "+e)};se.decode=function(e){var t=65,r=90,n=97,s=122,o=48,a=57,h=43,l=47,i=26,c=52;return t<=e&&e<=r?e-t:n<=e&&e<=s?e-n+i:o<=e&&e<=a?e-o+c:e==h?62:e==l?63:-1}});var qe=lt(ae=>{var We=Ue(),oe=5,Ve=1<<oe,He=Ve-1,Ge=Ve;function li(e){return e<0?(-e<<1)+1:(e<<1)+0}function hi(e){var t=(e&1)===1,r=e>>1;return t?-r:r}ae.encode=function(t){var r="",n,s=li(t);do n=s&He,s>>>=oe,s>0&&(n|=Ge),r+=We.encode(n);while(s>0);return r};ae.decode=function(t,r,n){var s=t.length,o=0,a=0,h,l;do{if(r>=s)throw new Error("Expected more digits in base 64 VLQ value.");if(l=We.decode(t.charCodeAt(r++)),l===-1)throw new Error("Invalid base64 digit: "+t.charAt(r-1));h=!!(l&Ge),l&=He,o=o+(l<<a),a+=oe}while(h);n.value=hi(o),n.rest=r}});var Ut=lt(N=>{function ui(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}N.getArg=ui;var Ye=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,fi=/^data:.+\,.+$/;function Ct(e){var t=e.match(Ye);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}N.urlParse=Ct;function ft(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}N.urlGenerate=ft;var pi=32;function mi(e){var t=[];return function(r){for(var n=0;n<t.length;n++)if(t[n].input===r){var s=t[0];return t[0]=t[n],t[n]=s,t[0].result}var o=e(r);return t.unshift({input:r,result:o}),t.length>pi&&t.pop(),o}}var ce=mi(function(t){var r=t,n=Ct(t);if(n){if(!n.path)return t;r=n.path}for(var s=N.isAbsolute(r),o=[],a=0,h=0;;)if(a=h,h=r.indexOf("/",a),h===-1){o.push(r.slice(a));break}else for(o.push(r.slice(a,h));h<r.length&&r[h]==="/";)h++;for(var l,i=0,h=o.length-1;h>=0;h--)l=o[h],l==="."?o.splice(h,1):l===".."?i++:i>0&&(l===""?(o.splice(h+1,i),i=0):(o.splice(h,2),i--));return r=o.join("/"),r===""&&(r=s?"/":"."),n?(n.path=r,ft(n)):r});N.normalize=ce;function je(e,t){e===""&&(e="."),t===""&&(t=".");var r=Ct(t),n=Ct(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),ft(r);if(r||t.match(fi))return t;if(n&&!n.host&&!n.path)return n.host=t,ft(n);var s=t.charAt(0)==="/"?t:ce(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=s,ft(n)):s}N.join=je;N.isAbsolute=function(e){return e.charAt(0)==="/"||Ye.test(e)};function di(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var r=0;t.indexOf(e+"/")!==0;){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/)))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)}N.relative=di;var ze=function(){var e=Object.create(null);return!("__proto__"in e)}();function Ke(e){return e}function xi(e){return Qe(e)?"$"+e:e}N.toSetString=ze?Ke:xi;function ki(e){return Qe(e)?e.slice(1):e}N.fromSetString=ze?Ke:ki;function Qe(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function Si(e,t,r){var n=K(e.source,t.source);return n!==0||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositions=Si;function gi(e,t,r){var n;return n=e.originalLine-t.originalLine,n!==0||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositionsNoSource=gi;function Ci(e,t,r){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0||r)||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:K(e.name,t.name)}N.compareByGeneratedPositionsDeflated=Ci;function yi(e,t,r){var n=e.generatedColumn-t.generatedColumn;return n!==0||r||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:K(e.name,t.name)}N.compareByGeneratedPositionsDeflatedNoLine=yi;function K(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function bi(e,t){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=K(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:K(e.name,t.name)}N.compareByGeneratedPositionsInflated=bi;function Li(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}N.parseSourceMapInput=Li;function Ti(e,t,r){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),r){var n=Ct(r);if(!n)throw new Error("sourceMapURL could not be parsed");if(n.path){var s=n.path.lastIndexOf("/");s>=0&&(n.path=n.path.substring(0,s+1))}t=je(ft(n),t)}return ce(t)}N.computeSourceURL=Ti});var Xe=lt($e=>{var le=Ut(),he=Object.prototype.hasOwnProperty,it=typeof Map<"u";function Q(){this._array=[],this._set=it?new Map:Object.create(null)}Q.fromArray=function(t,r){for(var n=new Q,s=0,o=t.length;s<o;s++)n.add(t[s],r);return n};Q.prototype.size=function(){return it?this._set.size:Object.getOwnPropertyNames(this._set).length};Q.prototype.add=function(t,r){var n=it?t:le.toSetString(t),s=it?this.has(t):he.call(this._set,n),o=this._array.length;(!s||r)&&this._array.push(t),s||(it?this._set.set(t,o):this._set[n]=o)};Q.prototype.has=function(t){if(it)return this._set.has(t);var r=le.toSetString(t);return he.call(this._set,r)};Q.prototype.indexOf=function(t){if(it){var r=this._set.get(t);if(r>=0)return r}else{var n=le.toSetString(t);if(he.call(this._set,n))return this._set[n]}throw new Error('"'+t+'" is not in the set.')};Q.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Q.prototype.toArray=function(){return this._array.slice()};$e.ArraySet=Q});var tr=lt(Ze=>{var Je=Ut();function vi(e,t){var r=e.generatedLine,n=t.generatedLine,s=e.generatedColumn,o=t.generatedColumn;return n>r||n==r&&o>=s||Je.compareByGeneratedPositionsInflated(e,t)<=0}function Wt(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Wt.prototype.unsortedForEach=function(t,r){this._array.forEach(t,r)};Wt.prototype.add=function(t){vi(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Wt.prototype.toArray=function(){return this._sorted||(this._array.sort(Je.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};Ze.MappingList=Wt});var rr=lt(er=>{var yt=qe(),v=Ut(),Vt=Xe().ArraySet,Ei=tr().MappingList;function W(e){e||(e={}),this._file=v.getArg(e,"file",null),this._sourceRoot=v.getArg(e,"sourceRoot",null),this._skipValidation=v.getArg(e,"skipValidation",!1),this._sources=new Vt,this._names=new Vt,this._mappings=new Ei,this._sourcesContents=null}W.prototype._version=3;W.fromSourceMap=function(t){var r=t.sourceRoot,n=new W({file:t.file,sourceRoot:r});return t.eachMapping(function(s){var o={generated:{line:s.generatedLine,column:s.generatedColumn}};s.source!=null&&(o.source=s.source,r!=null&&(o.source=v.relative(r,o.source)),o.original={line:s.originalLine,column:s.originalColumn},s.name!=null&&(o.name=s.name)),n.addMapping(o)}),t.sources.forEach(function(s){var o=s;r!==null&&(o=v.relative(r,s)),n._sources.has(o)||n._sources.add(o);var a=t.sourceContentFor(s);a!=null&&n.setSourceContent(s,a)}),n};W.prototype.addMapping=function(t){var r=v.getArg(t,"generated"),n=v.getArg(t,"original",null),s=v.getArg(t,"source",null),o=v.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,s,o),s!=null&&(s=String(s),this._sources.has(s)||this._sources.add(s)),o!=null&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:s,name:o})};W.prototype.setSourceContent=function(t,r){var n=t;this._sourceRoot!=null&&(n=v.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[v.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[v.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};W.prototype.applySourceMap=function(t,r,n){var s=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);s=t.file}var o=this._sourceRoot;o!=null&&(s=v.relative(o,s));var a=new Vt,h=new Vt;this._mappings.unsortedForEach(function(l){if(l.source===s&&l.originalLine!=null){var i=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});i.source!=null&&(l.source=i.source,n!=null&&(l.source=v.join(n,l.source)),o!=null&&(l.source=v.relative(o,l.source)),l.originalLine=i.line,l.originalColumn=i.column,i.name!=null&&(l.name=i.name))}var c=l.source;c!=null&&!a.has(c)&&a.add(c);var f=l.name;f!=null&&!h.has(f)&&h.add(f)},this),this._sources=a,this._names=h,t.sources.forEach(function(l){var i=t.sourceContentFor(l);i!=null&&(n!=null&&(l=v.join(n,l)),o!=null&&(l=v.relative(o,l)),this.setSourceContent(l,i))},this)};W.prototype._validateMapping=function(t,r,n,s){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!s)){if(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:s}))}};W.prototype._serializeMappings=function(){for(var t=0,r=1,n=0,s=0,o=0,a=0,h="",l,i,c,f,k=this._mappings.toArray(),S=0,T=k.length;S<T;S++){if(i=k[S],l="",i.generatedLine!==r)for(t=0;i.generatedLine!==r;)l+=";",r++;else if(S>0){if(!v.compareByGeneratedPositionsInflated(i,k[S-1]))continue;l+=","}l+=yt.encode(i.generatedColumn-t),t=i.generatedColumn,i.source!=null&&(f=this._sources.indexOf(i.source),l+=yt.encode(f-a),a=f,l+=yt.encode(i.originalLine-1-s),s=i.originalLine-1,l+=yt.encode(i.originalColumn-n),n=i.originalColumn,i.name!=null&&(c=this._names.indexOf(i.name),l+=yt.encode(c-o),o=c)),h+=l}return h};W.prototype._generateSourcesContent=function(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=v.relative(r,n));var s=v.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,s)?this._sourcesContents[s]:null},this)};W.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};W.prototype.toString=function(){return JSON.stringify(this.toJSON())};er.SourceMapGenerator=W});var gs={};vt(gs,{default:()=>Ie});function I(e){return e>=48&&e<=57}function z(e){return I(e)||e>=65&&e<=70||e>=97&&e<=102}function wt(e){return e>=65&&e<=90}function ei(e){return e>=97&&e<=122}function ri(e){return wt(e)||ei(e)}function ni(e){return e>=128}function Et(e){return ri(e)||ni(e)||e===95}function At(e){return Et(e)||I(e)||e===45}function ii(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function dt(e){return e===10||e===13||e===12}function $(e){return dt(e)||e===32||e===9}function R(e,t){return!(e!==92||dt(t)||t===0)}function Nt(e,t,r){return e===45?Et(t)||t===45||R(t,r):Et(e)?!0:e===92?R(e,t):!1}function It(e,t,r){return e===43||e===45?I(t)?2:t===46&&I(r)?3:0:e===46?I(t)?2:0:I(e)?1:0}function Dt(e){return e===65279||e===65534?1:0}var Xt=new Array(128),si=128,xt=130,Jt=131,Pt=132,Zt=133;for(let e=0;e<Xt.length;e++)Xt[e]=$(e)&&xt||I(e)&&Jt||Et(e)&&Pt||ii(e)&&Zt||e||si;function Ft(e){return e<128?Xt[e]:Pt}function ht(e,t){return t<e.length?e.charCodeAt(t):0}function Rt(e,t,r){return r===13&&ht(e,t+1)===10?2:1}function ee(e,t,r){let n=e.charCodeAt(t);return wt(n)&&(n=n|32),n===r}function et(e,t,r,n){if(r-t!==n.length||t<0||r>e.length)return!1;for(let s=t;s<r;s++){let o=n.charCodeAt(s-t),a=e.charCodeAt(s);if(wt(a)&&(a=a|32),a!==o)return!1}return!0}function Re(e,t){for(;t>=0&&$(e.charCodeAt(t));t--);return t+1}function kt(e,t){for(;t<e.length&&$(e.charCodeAt(t));t++);return t}function te(e,t){for(;t<e.length&&I(e.charCodeAt(t));t++);return t}function X(e,t){if(t+=2,z(ht(e,t-1))){for(let n=Math.min(e.length,t+5);t<n&&z(ht(e,t));t++);let r=ht(e,t);$(r)&&(t+=Rt(e,t,r))}return t}function St(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(!At(r)){if(R(r,ht(e,t+1))){t=X(e,t)-1;continue}break}}return t}function Ot(e,t){let r=e.charCodeAt(t);if((r===43||r===45)&&(r=e.charCodeAt(t+=1)),I(r)&&(t=te(e,t+1),r=e.charCodeAt(t)),r===46&&I(e.charCodeAt(t+1))&&(t+=2,t=te(e,t)),ee(e,t,101)){let n=0;r=e.charCodeAt(t+1),(r===45||r===43)&&(n=1,r=e.charCodeAt(t+2)),I(r)&&(t=te(e,t+1+n+1))}return t}function _t(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(r===41){t++;break}R(r,ht(e,t+1))&&(t=X(e,t))}return t}function re(e){if(e.length===1&&!z(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var gt=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"];function ut(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Oe=10,oi=12,_e=13;function Me(e){let t=e.source,r=t.length,n=t.length>0?Dt(t.charCodeAt(0)):0,s=ut(e.lines,r),o=ut(e.columns,r),a=e.startLine,h=e.startColumn;for(let l=n;l<r;l++){let i=t.charCodeAt(l);s[l]=a,o[l]=h++,(i===Oe||i===_e||i===oi)&&(i===_e&&l+1<r&&t.charCodeAt(l+1)===Oe&&(l++,s[l]=a,o[l]=h),a++,h=1)}s[r]=a,o[r]=h,e.lines=s,e.columns=o,e.computed=!0}var ne=class{constructor(){this.lines=null,this.columns=null,this.computed=!1}setSource(t,r=0,n=1,s=1){this.source=t,this.startOffset=r,this.startLine=n,this.startColumn=s,this.computed=!1}getLocation(t,r){return this.computed||Me(this),{source:r,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,r,n){return this.computed||Me(this),{source:n,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+r,line:this.lines[r],column:this.columns[r]}}}};var M=16777215,V=24,ai=new Map([[2,22],[21,22],[19,20],[23,24]]),ie=class{constructor(t,r){this.setSource(t,r)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",r=()=>{}){t=String(t||"");let n=t.length,s=ut(this.offsetAndType,t.length+1),o=ut(this.balance,t.length+1),a=0,h=0,l=0,i=-1;for(this.offsetAndType=null,this.balance=null,r(t,(c,f,k)=>{switch(c){default:o[a]=n;break;case h:{let S=l&M;for(l=o[S],h=l>>V,o[a]=S,o[S++]=a;S<a;S++)o[S]===n&&(o[S]=a);break}case 21:case 2:case 19:case 23:o[a]=l,h=ai.get(c),l=h<<V|a;break}s[a++]=c<<V|k,i===-1&&(i=f)}),s[a]=0<<V|n,o[a]=n,o[n]=n;l!==0;){let c=l&M;l=o[c],o[c]=n}this.source=t,this.firstCharOffset=i===-1?0:i,this.tokenCount=a,this.offsetAndType=s,this.balance=o,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>V:0}lookupTypeNonSC(t){for(let r=this.tokenIndex;r<this.tokenCount;r++){let n=this.offsetAndType[r]>>V;if(n!==13&&n!==25&&t--===0)return n}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&M:this.source.length}lookupOffsetNonSC(t){for(let r=this.tokenIndex;r<this.tokenCount;r++){let n=this.offsetAndType[r]>>V;if(n!==13&&n!==25&&t--===0)return r-this.tokenIndex}return 0}lookupValue(t,r){return t+=this.tokenIndex,t<this.tokenCount?et(this.source,this.offsetAndType[t-1]&M,this.offsetAndType[t]&M,r):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&M:this.offsetAndType[this.tokenCount]&M:this.firstCharOffset}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,r){return r?this.lookupType(r)===9&&this.source.charCodeAt(this.lookupOffset(r))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let r=this.tokenIndex+t;r<this.tokenCount?(this.tokenIndex=r,this.tokenStart=this.offsetAndType[r-1]&M,r=this.offsetAndType[r],this.tokenType=r>>V,this.tokenEnd=r&M):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>V,this.tokenEnd=t&M):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,r){let n=t,s,o;t:for(;n<this.tokenCount;n++){if(s=this.balance[n],s<t)break t;switch(o=n>0?this.offsetAndType[n-1]&M:this.firstCharOffset,r(this.source.charCodeAt(o))){case 1:break t;case 2:n++;break t;default:this.balance[s]===n&&(n=s)}}this.skip(n-this.tokenIndex)}forEachToken(t){for(let r=0,n=this.firstCharOffset;r<this.tokenCount;r++){let s=n,o=this.offsetAndType[r],a=o&M,h=o>>V;n=a,t(h,s,a,r)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((r,n,s,o)=>{t[o]={idx:o,type:gt[r],chunk:this.source.substring(n,s),balance:this.balance[o]}}),t}};function Bt(e,t){function r(f){return f<h?e.charCodeAt(f):0}function n(){if(i=Ot(e,i),Nt(r(i),r(i+1),r(i+2))){c=12,i=St(e,i);return}if(r(i)===37){c=11,i++;return}c=10}function s(){let f=i;if(i=St(e,i),et(e,f,i,"url")&&r(i)===40){if(i=kt(e,i+1),r(i)===34||r(i)===39){c=2,i=f+4;return}a();return}if(r(i)===40){c=2,i++;return}c=1}function o(f){for(f||(f=r(i++)),c=5;i<e.length;i++){let k=e.charCodeAt(i);switch(Ft(k)){case f:i++;return;case xt:if(dt(k)){i+=Rt(e,i,k),c=6;return}break;case 92:if(i===e.length-1)break;let S=r(i+1);dt(S)?i+=Rt(e,i+1,S):R(k,S)&&(i=X(e,i)-1);break}}}function a(){for(c=7,i=kt(e,i);i<e.length;i++){let f=e.charCodeAt(i);switch(Ft(f)){case 41:i++;return;case xt:if(i=kt(e,i),r(i)===41||i>=e.length){i<e.length&&i++;return}i=_t(e,i),c=8;return;case 34:case 39:case 40:case Zt:i=_t(e,i),c=8;return;case 92:if(R(f,r(i+1))){i=X(e,i)-1;break}i=_t(e,i),c=8;return}}}e=String(e||"");let h=e.length,l=Dt(r(0)),i=l,c;for(;i<h;){let f=e.charCodeAt(i);switch(Ft(f)){case xt:c=13,i=kt(e,i+1);break;case 34:o();break;case 35:At(r(i+1))||R(r(i+1),r(i+2))?(c=4,i=St(e,i+1)):(c=9,i++);break;case 39:o();break;case 40:c=21,i++;break;case 41:c=22,i++;break;case 43:It(f,r(i+1),r(i+2))?n():(c=9,i++);break;case 44:c=18,i++;break;case 45:It(f,r(i+1),r(i+2))?n():r(i+1)===45&&r(i+2)===62?(c=15,i=i+3):Nt(f,r(i+1),r(i+2))?s():(c=9,i++);break;case 46:It(f,r(i+1),r(i+2))?n():(c=9,i++);break;case 47:r(i+1)===42?(c=25,i=e.indexOf("*/",i+2),i=i===-1?e.length:i+2):(c=9,i++);break;case 58:c=16,i++;break;case 59:c=17,i++;break;case 60:r(i+1)===33&&r(i+2)===45&&r(i+3)===45?(c=14,i=i+4):(c=9,i++);break;case 64:Nt(r(i+1),r(i+2),r(i+3))?(c=3,i=St(e,i+1)):(c=9,i++);break;case 91:c=19,i++;break;case 92:R(f,r(i+1))?s():(c=9,i++);break;case 93:c=20,i++;break;case 123:c=23,i++;break;case 125:c=24,i++;break;case Jt:n();break;case Pt:s();break;default:c=9,i++}t(c,l,l=i)}}var ir=Zn(rr(),1),nr=new Set(["Atrule","Selector","Declaration"]);function sr(e){let t=new ir.SourceMapGenerator,r={line:1,column:0},n={line:0,column:0},s={line:1,column:0},o={generated:s},a=1,h=0,l=!1,i=e.node;e.node=function(k){if(k.loc&&k.loc.start&&nr.has(k.type)){let S=k.loc.start.line,T=k.loc.start.column-1;(n.line!==S||n.column!==T)&&(n.line=S,n.column=T,r.line=a,r.column=h,l&&(l=!1,(r.line!==s.line||r.column!==s.column)&&t.addMapping(o)),l=!0,t.addMapping({source:k.loc.source,original:n,generated:r}))}i.call(this,k),l&&nr.has(k.type)&&(s.line=a,s.column=h)};let c=e.emit;e.emit=function(k,S,T){for(let j=0;j<k.length;j++)k.charCodeAt(j)===10?(a++,h=0):h++;c(k,S,T)};let f=e.result;return e.result=function(){return l&&t.addMapping(o),{css:f(),map:t}},e}var Ht={};vt(Ht,{safe:()=>fe,spec:()=>Ii});var wi=43,Ai=45,ue=(e,t)=>{if(e===9&&(e=t),typeof e=="string"){let r=e.charCodeAt(0);return r>127?32768:r<<8}return e},or=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],Ni=or.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function ar(e){let t=new Set(e.map(([r,n])=>ue(r)<<16|ue(n)));return function(r,n,s){let o=ue(n,s),a=s.charCodeAt(0);return(a===Ai&&n!==1&&n!==2&&n!==15||a===wi?t.has(r<<16|a<<8):t.has(r<<16|o))&&this.emit(" ",13,!0),o}}var Ii=ar(or),fe=ar(Ni);var Di=92;function Pi(e,t){if(typeof t=="function"){let r=null;e.children.forEach(n=>{r!==null&&t.call(this,r),this.node(n),r=n});return}e.children.forEach(this.node,this)}function Fi(e){Bt(e,(t,r,n)=>{this.token(t,e.slice(r,n))})}function cr(e){let t=new Map;for(let[r,n]of Object.entries(e.node))typeof(n.generate||n)=="function"&&t.set(r,n.generate||n);return function(r,n){let s="",o=0,a={node(l){if(t.has(l.type))t.get(l.type).call(h,l);else throw new Error("Unknown node type: "+l.type)},tokenBefore:fe,token(l,i){o=this.tokenBefore(o,l,i),this.emit(i,l,!1),l===9&&i.charCodeAt(0)===Di&&this.emit(`
|
| 2 |
+
`,13,!0)},emit(l){s+=l},result(){return s}};n&&(typeof n.decorator=="function"&&(a=n.decorator(a)),n.sourceMap&&(a=sr(a)),n.mode in Ht&&(a.tokenBefore=Ht[n.mode]));let h={node:l=>a.node(l),children:Pi,token:(l,i)=>a.token(l,i),tokenize:Fi};return a.node(r),a.result()}}var Se={};vt(Se,{AnPlusB:()=>hr,Atrule:()=>ur,AtrulePrelude:()=>fr,AttributeSelector:()=>dr,Block:()=>xr,Brackets:()=>kr,CDC:()=>Sr,CDO:()=>gr,ClassSelector:()=>yr,Combinator:()=>Tr,Comment:()=>vr,Condition:()=>Er,Declaration:()=>wr,DeclarationList:()=>Ar,Dimension:()=>Nr,Feature:()=>Ir,FeatureFunction:()=>Dr,FeatureRange:()=>Pr,Function:()=>Fr,GeneralEnclosed:()=>Rr,Hash:()=>Or,IdSelector:()=>Ur,Identifier:()=>Mr,Layer:()=>Wr,LayerList:()=>Vr,MediaQuery:()=>Hr,MediaQueryList:()=>Gr,NestingSelector:()=>Yr,Nth:()=>zr,Number:()=>Kr,Operator:()=>$r,Parentheses:()=>Xr,Percentage:()=>Zr,PseudoClassSelector:()=>en,PseudoElementSelector:()=>nn,Ratio:()=>sn,Raw:()=>an,Rule:()=>cn,Scope:()=>ln,Selector:()=>un,SelectorList:()=>pn,String:()=>Sn,StyleSheet:()=>gn,SupportsDeclaration:()=>Cn,TypeSelector:()=>Ln,UnicodeRange:()=>Tn,Url:()=>En,Value:()=>wn,WhiteSpace:()=>An});var Y=43,_=45,Gt=110,st=!0,Ri=!1;function qt(e,t){let r=this.tokenStart+e,n=this.charCodeAt(r);for((n===Y||n===_)&&(t&&this.error("Number sign is not allowed"),r++);r<this.tokenEnd;r++)I(this.charCodeAt(r))||this.error("Integer is expected",r)}function pt(e){return qt.call(this,0,e)}function Z(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let r="";switch(t){case Gt:r="N is expected";break;case _:r="HyphenMinus is expected";break}this.error(r,this.tokenStart+e)}}function pe(){let e=0,t=0,r=this.tokenType;for(;r===13||r===25;)r=this.lookupType(++e);if(r!==10)if(this.isDelim(Y,e)||this.isDelim(_,e)){t=this.isDelim(Y,e)?Y:_;do r=this.lookupType(++e);while(r===13||r===25);r!==10&&(this.skip(e),pt.call(this,st))}else return null;return e>0&&this.skip(e),t===0&&(r=this.charCodeAt(this.tokenStart),r!==Y&&r!==_&&this.error("Number sign is expected")),pt.call(this,t!==0),t===_?"-"+this.consume(10):this.consume(10)}function lr(){let e=this.tokenStart,t=null,r=null;if(this.tokenType===10)pt.call(this,Ri),r=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,_))switch(t="-1",Z.call(this,1,Gt),this.tokenEnd-this.tokenStart){case 2:this.next(),r=pe.call(this);break;case 3:Z.call(this,2,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,2,_),qt.call(this,3,st),this.next(),r=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Y)&&this.lookupType(1)===1){let n=0;switch(t="1",this.isDelim(Y)&&(n=1,this.next()),Z.call(this,0,Gt),this.tokenEnd-this.tokenStart){case 1:this.next(),r=pe.call(this);break;case 2:Z.call(this,1,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,1,_),qt.call(this,2,st),this.next(),r=this.substrToCursor(e+n+1)}}else if(this.tokenType===12){let n=this.charCodeAt(this.tokenStart),s=n===Y||n===_,o=this.tokenStart+s;for(;o<this.tokenEnd&&I(this.charCodeAt(o));o++);o===this.tokenStart+s&&this.error("Integer is expected",this.tokenStart+s),Z.call(this,o-this.tokenStart,Gt),t=this.substring(e,o),o+1===this.tokenEnd?(this.next(),r=pe.call(this)):(Z.call(this,o-this.tokenStart+1,_),o+2===this.tokenEnd?(this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10)):(qt.call(this,o-this.tokenStart+2,st),this.next(),r=this.substrToCursor(o+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Y&&(t=t.substr(1)),r!==null&&r.charCodeAt(0)===Y&&(r=r.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:r}}function hr(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let r=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+r)}else this.tokenize(t)}else this.tokenize(e.b)}function ur(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?(this.token(23,"{"),this.node(e.block),this.token(24,"}")):this.token(17,";")}function fr(e){this.children(e)}var Oi=36,pr=42,Yt=61,_i=94,me=124,Mi=126;function Bi(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(pr)?(t=!0,this.next()):this.isDelim(me)||this.eat(1),this.isDelim(me)?this.charCodeAt(this.tokenStart+1)!==Yt?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Ui(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==Yt&&t!==Mi&&t!==_i&&t!==Oi&&t!==pr&&t!==me&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==Yt&&(this.isDelim(Yt)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function mr(){let e=this.tokenStart,t,r=null,n=null,s=null;return this.eat(19),this.skipSC(),t=Bi.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(r=Ui.call(this),this.skipSC(),n=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(s=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:r,value:n,flags:s}}function dr(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}function xr(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}function kr(e){this.token(9,"["),this.children(e),this.token(9,"]")}function Sr(){this.token(15,"-->")}function gr(){this.token(14,"<!--")}var Wi=46;function Cr(){return this.eatDelim(Wi),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function yr(e){this.token(9,"."),this.token(1,e.name)}var Vi=43,br=47,Hi=62,Gi=126;function Lr(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case Hi:case Vi:case Gi:this.next();break;case br:this.next(),this.eatIdent("deep"),this.eatDelim(br);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function Tr(e){this.tokenize(e.name)}function vr(e){this.token(25,"/*"+e.value+"*/")}function Er(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}function wr(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function Ar(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}function Nr(e){this.token(12,e.value+e.unit)}function Ir(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}function Dr(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}function Pr(e){this.token(21,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(22,")")}function Fr(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}function Rr(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}function Or(e){this.token(4,"#"+e.value)}function _r(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function Mr(e){this.token(1,e.name)}function Br(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function Ur(e){this.token(9,"#"+e.name)}function Wr(e){this.tokenize(e.name)}function Vr(e){this.children(e,()=>this.token(18,","))}function Hr(e){e.mediaType?(e.modifier&&this.token(1,e.modifier),this.token(1,e.mediaType),e.condition&&(this.token(1,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}function Gr(e){this.children(e,()=>this.token(18,","))}var qi=38;function qr(){let e=this.tokenStart;return this.eatDelim(qi),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function Yr(){this.token(9,"&")}function jr(){this.skipSC();let e=this.tokenStart,t=e,r=null,n;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?n=this.Identifier():n=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),r=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:n,selector:r}}function zr(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}function Kr(e){this.token(10,e.value)}function Qr(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function $r(e){this.tokenize(e.value)}function Xr(e){this.token(21,"("),this.children(e),this.token(22,")")}function Jr(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function Zr(e){this.token(11,e.value+"%")}function tn(){let e=this.tokenStart,t=null,r,n;return this.eat(16),this.tokenType===2?(r=this.consumeFunctionName(),n=r.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),t=this.pseudo[n].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):r=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:r,children:t}}function en(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}function rn(){let e=this.tokenStart,t=null,r,n;return this.eat(16),this.eat(16),this.tokenType===2?(r=this.consumeFunctionName(),n=r.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),t=this.pseudo[n].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):r=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:r,children:t}}function nn(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}function sn(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}function Yi(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function on(e,t){let r=this.getTokenStart(this.tokenIndex),n;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>r?n=Yi.call(this):n=this.tokenStart,{type:"Raw",loc:this.getLocation(r,n),value:this.substring(r,n)}}function an(e){this.tokenize(e.value)}function cn(e){this.node(e.prelude),this.token(23,"{"),this.node(e.block),this.token(24,"}")}function ln(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}function hn(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function un(e){this.children(e)}function fn(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function pn(e){this.children(e,()=>this.token(18,","))}var de=92,mn=34,dn=39;function xe(e){let t=e.length,r=e.charCodeAt(0),n=r===mn||r===dn?1:0,s=n===1&&t>1&&e.charCodeAt(t-1)===r?t-2:t-1,o="";for(let a=n;a<=s;a++){let h=e.charCodeAt(a);if(h===de){if(a===s){a!==t-1&&(o=e.substr(a+1));break}if(h=e.charCodeAt(++a),R(de,h)){let l=a-1,i=X(e,l);a=i-1,o+=re(e.substring(l+1,i))}else h===13&&e.charCodeAt(a+1)===10&&a++}else o+=e[a]}return o}function xn(e,t){let r=t?"'":'"',n=t?dn:mn,s="",o=!1;for(let a=0;a<e.length;a++){let h=e.charCodeAt(a);if(h===0){s+="\uFFFD";continue}if(h<=31||h===127){s+="\\"+h.toString(16),o=!0;continue}h===n||h===de?(s+="\\"+e.charAt(a),o=!1):(o&&(z(h)||$(h))&&(s+=" "),s+=e.charAt(a),o=!1)}return r+s+r}function kn(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:xe(this.consume(5))}}function Sn(e){this.token(5,xn(e.value))}function gn(e){this.children(e)}function Cn(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var zi=42,yn=124;function ke(){this.tokenType!==1&&this.isDelim(zi)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function bn(){let e=this.tokenStart;return this.isDelim(yn)?(this.next(),ke.call(this)):(ke.call(this),this.isDelim(yn)&&(this.next(),ke.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Ln(e){this.tokenize(e.name)}function Tn(e){this.tokenize(e.value)}var Ki=32,Qi=92,$i=34,Xi=39,Ji=40,Zi=41;function vn(e){let t="",r=!1;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);if(s===0){t+="\uFFFD";continue}if(s<=31||s===127){t+="\\"+s.toString(16),r=!0;continue}s===Ki||s===Qi||s===$i||s===Xi||s===Ji||s===Zi?(t+="\\"+e.charAt(n),r=!1):(r&&z(s)&&(t+=" "),t+=e.charAt(n),r=!1)}return"url("+t+")"}function En(e){this.token(7,vn(e.value))}function wn(e){this.children(e)}var Ka=Object.freeze({type:"WhiteSpace",loc:null,value:" "});function An(e){this.token(13,e.value)}var Nn={node:Se};var In=cr(Nn);var mt=null,P=class{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return P.createItem(t)}allocateCursor(t,r){let n;return mt!==null?(n=mt,mt=mt.cursor,n.prev=t,n.next=r,n.cursor=this.cursor):n={prev:t,next:r,cursor:this.cursor},this.cursor=n,n}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=mt,mt=t}updateCursors(t,r,n,s){let{cursor:o}=this;for(;o!==null;)o.prev===t&&(o.prev=r),o.next===n&&(o.next=s),o=o.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let r=this.head;r!==null;r=r.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let r=null;this.head=null;for(let n of t){let s=P.createItem(n);r!==null?r.next=s:this.head=s,s.prev=r,r=s}return this.tail=r,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,r=this){let n=this.allocateCursor(null,this.head);for(;n.next!==null;){let s=n.next;n.next=s.next,t.call(r,s.data,s,this)}this.releaseCursor()}forEachRight(t,r=this){let n=this.allocateCursor(this.tail,null);for(;n.prev!==null;){let s=n.prev;n.prev=s.prev,t.call(r,s.data,s,this)}this.releaseCursor()}reduce(t,r,n=this){let s=this.allocateCursor(null,this.head),o=r,a;for(;s.next!==null;)a=s.next,s.next=a.next,o=t.call(n,o,a.data,a,this);return this.releaseCursor(),o}reduceRight(t,r,n=this){let s=this.allocateCursor(this.tail,null),o=r,a;for(;s.prev!==null;)a=s.prev,s.prev=a.prev,o=t.call(n,o,a.data,a,this);return this.releaseCursor(),o}some(t,r=this){for(let n=this.head;n!==null;n=n.next)if(t.call(r,n.data,n,this))return!0;return!1}map(t,r=this){let n=new P;for(let s=this.head;s!==null;s=s.next)n.appendData(t.call(r,s.data,s,this));return n}filter(t,r=this){let n=new P;for(let s=this.head;s!==null;s=s.next)t.call(r,s.data,s,this)&&n.appendData(s.data);return n}nextUntil(t,r,n=this){if(t===null)return;let s=this.allocateCursor(null,t);for(;s.next!==null;){let o=s.next;if(s.next=o.next,r.call(n,o.data,o,this))break}this.releaseCursor()}prevUntil(t,r,n=this){if(t===null)return;let s=this.allocateCursor(t,null);for(;s.prev!==null;){let o=s.prev;if(s.prev=o.prev,r.call(n,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new P;for(let r of this)t.appendData(r);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(P.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(P.createItem(t))}insert(t,r=null){if(r!==null)if(this.updateCursors(r.prev,t,r,t),r.prev===null){if(this.head!==r)throw new Error("before doesn't belong to list");this.head=t,r.prev=t,t.next=r,this.updateCursors(null,t)}else r.prev.next=t,t.prev=r.prev,r.prev=t,t.next=r;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,r){return this.insert(P.createItem(t),r)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(P.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(P.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,r){return t.head===null?this:(r!=null?(this.updateCursors(r.prev,t.tail,r,t.head),r.prev!==null?(r.prev.next=t.head,t.head.prev=r.prev):this.head=t.head,r.prev=t.tail,t.tail.next=r):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,r){"head"in r?this.insertList(r,t):this.insert(r,t),this.remove(t)}};function Dn(e,t){let r=Object.create(SyntaxError.prototype),n=new Error;return Object.assign(r,{name:e,message:t,get stack(){return(n.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
|
| 3 |
+
`)}})}var ge=100,Pn=60,Fn=" ";function Rn({source:e,line:t,column:r,baseLine:n,baseColumn:s},o){function a(T,j){return i.slice(T,j).map((tt,$t)=>String(T+$t+1).padStart(k)+" |"+tt).join(`
|
| 4 |
+
`)}let h=`
|
| 5 |
+
`.repeat(Math.max(n-1,0)),l=" ".repeat(Math.max(s-1,0)),i=(h+l+e).split(/\r\n?|\n|\f/),c=Math.max(1,t-o)-1,f=Math.min(t+o,i.length+1),k=Math.max(4,String(f).length)+1,S=0;r+=(Fn.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length,r>ge&&(S=r-Pn+3,r=Pn-2);for(let T=c;T<=f;T++)T>=0&&T<i.length&&(i[T]=i[T].replace(/\t/g,Fn),i[T]=(S>0&&i[T].length>S?"\u2026":"")+i[T].substr(S,ge-2)+(i[T].length>S+ge-1?"\u2026":""));return[a(c,t),new Array(r+k+2).join("-")+"^",a(t,f)].filter(Boolean).join(`
|
| 6 |
+
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Ce(e,t,r,n,s,o=1,a=1){return Object.assign(Dn("SyntaxError",e),{source:t,offset:r,line:n,column:s,sourceFragment(l){return Rn({source:t,line:n,column:s,baseLine:o,baseColumn:a},isNaN(l)?0:l)},get formattedMessage(){return`Parse error: ${e}
|
| 7 |
+
`+Rn({source:t,line:n,column:s,baseLine:o,baseColumn:a},2)}})}function On(e){let t=this.createList(),r=!1,n={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:r=!0,this.next();continue}let s=e.getNode.call(this,n);if(s===void 0)break;r&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,s,t,n),r=!1),t.push(s)}return r&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,n),t}var _n=()=>{},es=33,rs=35,ye=59,Mn=123,Bn=0;function ns(e){return function(){return this[e]()}}function be(e){let t=Object.create(null);for(let r of Object.keys(e)){let n=e[r],s=n.parse||n;s&&(t[r]=s)}return t}function is(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:be(e.atrule),pseudo:be(e.pseudo),node:be(e.node)};for(let[r,n]of Object.entries(e.parseContext))switch(typeof n){case"function":t.context[r]=n;break;case"string":t.context[r]=ns(n);break}return{config:t,...t,...t.node}}function Un(e){let t="",r="<unknown>",n=!1,s=_n,o=!1,a=new ne,h=Object.assign(new ie,is(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:On,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(i){return i===Mn?1:0},consumeUntilLeftCurlyBracketOrSemicolon(i){return i===Mn||i===ye?1:0},consumeUntilExclamationMarkOrSemicolon(i){return i===es||i===ye?1:0},consumeUntilSemicolonIncluded(i){return i===ye?2:0},createList(){return new P},createSingleNodeList(i){return new P().appendData(i)},getFirstListNode(i){return i&&i.first},getLastListNode(i){return i&&i.last},parseWithFallback(i,c){let f=this.tokenIndex;try{return i.call(this)}catch(k){if(o)throw k;this.skip(f-this.tokenIndex);let S=c.call(this);return o=!0,s(k,S),o=!1,S}},lookupNonWSType(i){let c;do if(c=this.lookupType(i++),c!==13&&c!==25)return c;while(c!==Bn);return Bn},charCodeAt(i){return i>=0&&i<t.length?t.charCodeAt(i):0},substring(i,c){return t.substring(i,c)},substrToCursor(i){return this.source.substring(i,this.tokenStart)},cmpChar(i,c){return ee(t,i,c)},cmpStr(i,c,f){return et(t,i,c,f)},consume(i){let c=this.tokenStart;return this.eat(i),this.substrToCursor(c)},consumeFunctionName(){let i=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),i},consumeNumber(i){let c=t.substring(this.tokenStart,Ot(t,this.tokenStart));return this.eat(i),c},eat(i){if(this.tokenType!==i){let c=gt[i].slice(0,-6).replace(/-/g," ").replace(/^./,S=>S.toUpperCase()),f=`${/[[\](){}]/.test(c)?`"${c}"`:c} is expected`,k=this.tokenStart;switch(i){case 1:this.tokenType===2||this.tokenType===7?(k=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(rs)&&(this.next(),k++,f="Name is expected");break;case 11:this.tokenType===10&&(k=this.tokenEnd,f="Percent sign is expected");break}this.error(f,k)}this.next()},eatIdent(i){(this.tokenType!==1||this.lookupValue(0,i)===!1)&&this.error(`Identifier "${i}" is expected`),this.next()},eatDelim(i){this.isDelim(i)||this.error(`Delim "${String.fromCharCode(i)}" is expected`),this.next()},getLocation(i,c){return n?a.getLocationRange(i,c,r):null},getLocationFromList(i){if(n){let c=this.getFirstListNode(i),f=this.getLastListNode(i);return a.getLocationRange(c!==null?c.loc.start.offset-a.startOffset:this.tokenStart,f!==null?f.loc.end.offset-a.startOffset:this.tokenStart,r)}return null},error(i,c){let f=typeof c<"u"&&c<t.length?a.getLocation(c):this.eof?a.getLocation(Re(t,t.length-1)):a.getLocation(this.tokenStart);throw new Ce(i||"Unexpected input",t,f.offset,f.line,f.column,a.startLine,a.startColumn)}});return Object.assign(function(i,c){t=i,c=c||{},h.setSource(t,Bt),a.setSource(t,c.offset,c.line,c.column),r=c.filename||"<unknown>",n=Boolean(c.positions),s=typeof c.onParseError=="function"?c.onParseError:_n,o=!1,h.parseAtrulePrelude="parseAtrulePrelude"in c?Boolean(c.parseAtrulePrelude):!0,h.parseRulePrelude="parseRulePrelude"in c?Boolean(c.parseRulePrelude):!0,h.parseValue="parseValue"in c?Boolean(c.parseValue):!0,h.parseCustomProperty="parseCustomProperty"in c?Boolean(c.parseCustomProperty):!1;let{context:f="default",onComment:k}=c;if(!(f in h.context))throw new Error("Unknown context `"+f+"`");typeof k=="function"&&h.forEachToken((T,j,tt)=>{if(T===25){let $t=h.getLocation(j,tt),zn=et(t,tt-2,tt,"*/")?t.slice(j+2,tt-2):t.slice(j+2,tt);k(zn,$t)}});let S=h.context[f].call(h,c);return h.eof||h.error(),S},{SyntaxError:Ce,config:h.config})}var os=35,as=38,cs=42,ls=43,hs=47,Wn=46,us=62,fs=124,ps=126;function ms(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function ds(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===Wn&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case ls:case us:case ps:case hs:return this.Combinator();case Wn:return this.ClassSelector();case cs:case fs:return this.TypeSelector();case os:return this.IdSelector();case as:return this.NestingSelector()}break}}}var Le={onWhiteSpace:ms,getNode:ds};function Vn(){let e=this.createList();this.skipSC();t:for(;!this.eof;){switch(this.tokenType){case 1:e.push(this.Identifier());break;case 5:e.push(this.String());break;case 18:e.push(this.Operator());break;case 22:break t;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return e}var ot={parse(){return this.createSingleNodeList(this.SelectorList())}},Te={parse(){return this.createSingleNodeList(this.Selector())}},xs={parse(){return this.createSingleNodeList(this.Identifier())}},ks={parse:Vn},jt={parse(){return this.createSingleNodeList(this.Nth())}},Hn={dir:xs,has:ot,lang:ks,matches:ot,is:ot,"-moz-any":ot,"-webkit-any":ot,where:ot,not:ot,"nth-child":jt,"nth-last-child":jt,"nth-last-of-type":jt,"nth-of-type":jt,slotted:Te,host:Te,"host-context":Te};var ve={};vt(ve,{AnPlusB:()=>lr,AttributeSelector:()=>mr,ClassSelector:()=>Cr,Combinator:()=>Lr,IdSelector:()=>Br,Identifier:()=>_r,NestingSelector:()=>qr,Nth:()=>jr,Operator:()=>Qr,Percentage:()=>Jr,PseudoClassSelector:()=>tn,PseudoElementSelector:()=>rn,Raw:()=>on,Selector:()=>hn,SelectorList:()=>fn,String:()=>kn,TypeSelector:()=>bn});var Gn={parseContext:{default:"SelectorList",selectorList:"SelectorList",selector:"Selector"},scope:{Selector:Le},atrule:{},pseudo:Hn,node:ve};var Ee=Un(Gn);var at=(e,t)=>e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a,we=(e,t)=>at(e,t)===0,Ae=(e,t)=>at(e,t)>0,Ne=(e,t)=>at(e,t)<0;var qn=(e,t="ASC")=>{let r=e.sort(at);return t==="DESC"?r.reverse():r},zt=(...e)=>qn(e,"ASC"),Kt=(...e)=>qn(e,"DESC");var bt=(...e)=>Kt(...e)[0],Yn=(...e)=>zt(...e)[0];var Lt=e=>{if(!e||e.type!=="Selector")throw new TypeError("Passed in source is not a Selector AST");let t=0,r=0,n=0;return e.children.forEach(s=>{switch(s.type){case"IdSelector":t+=1;break;case"AttributeSelector":case"ClassSelector":r+=1;break;case"PseudoClassSelector":switch(s.name.toLowerCase()){case"where":break;case"-webkit-any":case"any":s.children?.first&&(r+=1);break;case"-moz-any":case"is":case"matches":case"not":case"has":if(s.children?.first){let a=bt(...ct(s.children.first));t+=a.a,r+=a.b,n+=a.c}break;case"nth-child":case"nth-last-child":if(r+=1,s.children?.first?.selector){let a=bt(...ct(s.children.first.selector));t+=a.a,r+=a.b,n+=a.c}break;case"host-context":case"host":if(r+=1,s.children?.first?.children){let a={type:"Selector",children:[]},h=!1;s.children.first.children.forEach(i=>{if(h)return!1;if(i.type==="Combinator")return h=!0,!1;a.children.push(i)});let l=ct(a)[0];t+=l.a,r+=l.b,n+=l.c}break;case"after":case"before":case"first-letter":case"first-line":n+=1;break;default:r+=1;break}break;case"PseudoElementSelector":switch(s.name){case"slotted":if(n+=1,s.children?.first?.children){let a={type:"Selector",children:[]},h=!1;s.children.first.children.forEach(i=>{if(h)return!1;if(i.type==="Combinator")return h=!0,!1;a.children.push(i)});let l=ct(a)[0];t+=l.a,r+=l.b,n+=l.c}break;case"view-transition-group":case"view-transition-image-pair":case"view-transition-old":case"view-transition-new":if(s.children?.first?.value==="*")break;n+=1;break;default:n+=1;break}break;case"TypeSelector":let o=s.name;o.includes("|")&&(o=o.split("|")[1]),o!=="*"&&(n+=1);break;default:break}}),new Ie({a:t,b:r,c:n},e)},Ss=e=>{if(typeof e=="string"||e instanceof String)try{return Ee(e,{context:"selectorList"})}catch(t){throw new TypeError(`Could not convert passed in source '${e}' to SelectorList: ${t.message}`)}if(e instanceof Object){if(e.type&&["Selector","SelectorList"].includes(e.type))return e;if(e.type&&e.type==="Raw")try{return Ee(e.value,{context:"selectorList"})}catch(t){throw new TypeError(`Could not convert passed in source to SelectorList: ${t.message}`)}throw new TypeError("Passed in source is an Object but no AST / AST of the type Selector or SelectorList")}throw new TypeError("Passed in source is not a String nor an Object. I don't know what to do with it.")},ct=e=>{if(!e)return[];let t=Ss(e);if(t.type==="Selector")return[Lt(e)];if(t.type==="SelectorList"){let r=[];return t.children.forEach(n=>{let s=Lt(n);r.push(s)}),r}};var Qt=class extends Error{constructor(){super("Manipulating a Specificity instance is not allowed. Instead, create a new Specificity()")}},jn=class{constructor(t,r=null){this.value=t,this.selector=r}get a(){return this.value.a}set a(t){throw new Qt}get b(){return this.value.b}set b(t){throw new Qt}get c(){return this.value.c}set c(t){throw new Qt}selectorString(){return typeof this.selector=="string"||this.selector instanceof String?this.selector:this.selector instanceof Object&&this.selector.type==="Selector"?In(this.selector):""}toObject(){return this.value}toArray(){return[this.value.a,this.value.b,this.value.c]}toString(){return`(${this.value.a},${this.value.b},${this.value.c})`}toJSON(){return{selector:this.selectorString(),asObject:this.toObject(),asArray:this.toArray(),asString:this.toString()}}isEqualTo(t){return we(this,t)}isGreaterThan(t){return Ae(this,t)}isLessThan(t){return Ne(this,t)}static calculate(t){return ct(t)}static calculateForAST(t){return Lt(t)}static compare(t,r){return at(t,r)}static equals(t,r){return we(t,r)}static lessThan(t,r){return Ne(t,r)}static greaterThan(t,r){return Ae(t,r)}static min(...t){return Yn(...t)}static max(...t){return bt(...t)}static sortAsc(...t){return zt(...t)}static sortDesc(...t){return Kt(...t)}},Ie=jn;module.exports=ti(gs);
|
| 8 |
+
//# sourceMappingURL=index.cjs.map
|
node_modules/@bramus/specificity/dist/index.cjs.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
node_modules/@bramus/specificity/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var jn=Object.create;var Tt=Object.defineProperty;var zn=Object.getOwnPropertyDescriptor;var Kn=Object.getOwnPropertyNames;var Qn=Object.getPrototypeOf,$n=Object.prototype.hasOwnProperty;var Xn=e=>Tt(e,"__esModule",{value:!0});var lt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),$t=(e,t)=>{for(var r in t)Tt(e,r,{get:t[r],enumerable:!0})},Jn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Kn(t))!$n.call(e,s)&&(r||s!=="default")&&Tt(e,s,{get:()=>t[s],enumerable:!(n=zn(t,s))||n.enumerable});return e},Zn=(e,t)=>Jn(Xn(Tt(e!=null?jn(Qn(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var _e=lt(se=>{var Oe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");se.encode=function(e){if(0<=e&&e<Oe.length)return Oe[e];throw new TypeError("Must be between 0 and 63: "+e)};se.decode=function(e){var t=65,r=90,n=97,s=122,o=48,a=57,h=43,l=47,i=26,c=52;return t<=e&&e<=r?e-t:n<=e&&e<=s?e-n+i:o<=e&&e<=a?e-o+c:e==h?62:e==l?63:-1}});var Ve=lt(ae=>{var Me=_e(),oe=5,Be=1<<oe,Ue=Be-1,We=Be;function ci(e){return e<0?(-e<<1)+1:(e<<1)+0}function li(e){var t=(e&1)===1,r=e>>1;return t?-r:r}ae.encode=function(t){var r="",n,s=ci(t);do n=s&Ue,s>>>=oe,s>0&&(n|=We),r+=Me.encode(n);while(s>0);return r};ae.decode=function(t,r,n){var s=t.length,o=0,a=0,h,l;do{if(r>=s)throw new Error("Expected more digits in base 64 VLQ value.");if(l=Me.decode(t.charCodeAt(r++)),l===-1)throw new Error("Invalid base64 digit: "+t.charAt(r-1));h=!!(l&We),l&=Ue,o=o+(l<<a),a+=oe}while(h);n.value=li(o),n.rest=r}});var Bt=lt(N=>{function hi(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}N.getArg=hi;var He=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/,ui=/^data:.+\,.+$/;function Ct(e){var t=e.match(He);return t?{scheme:t[1],auth:t[2],host:t[3],port:t[4],path:t[5]}:null}N.urlParse=Ct;function ft(e){var t="";return e.scheme&&(t+=e.scheme+":"),t+="//",e.auth&&(t+=e.auth+"@"),e.host&&(t+=e.host),e.port&&(t+=":"+e.port),e.path&&(t+=e.path),t}N.urlGenerate=ft;var fi=32;function pi(e){var t=[];return function(r){for(var n=0;n<t.length;n++)if(t[n].input===r){var s=t[0];return t[0]=t[n],t[n]=s,t[0].result}var o=e(r);return t.unshift({input:r,result:o}),t.length>fi&&t.pop(),o}}var ce=pi(function(t){var r=t,n=Ct(t);if(n){if(!n.path)return t;r=n.path}for(var s=N.isAbsolute(r),o=[],a=0,h=0;;)if(a=h,h=r.indexOf("/",a),h===-1){o.push(r.slice(a));break}else for(o.push(r.slice(a,h));h<r.length&&r[h]==="/";)h++;for(var l,i=0,h=o.length-1;h>=0;h--)l=o[h],l==="."?o.splice(h,1):l===".."?i++:i>0&&(l===""?(o.splice(h+1,i),i=0):(o.splice(h,2),i--));return r=o.join("/"),r===""&&(r=s?"/":"."),n?(n.path=r,ft(n)):r});N.normalize=ce;function Ge(e,t){e===""&&(e="."),t===""&&(t=".");var r=Ct(t),n=Ct(e);if(n&&(e=n.path||"/"),r&&!r.scheme)return n&&(r.scheme=n.scheme),ft(r);if(r||t.match(ui))return t;if(n&&!n.host&&!n.path)return n.host=t,ft(n);var s=t.charAt(0)==="/"?t:ce(e.replace(/\/+$/,"")+"/"+t);return n?(n.path=s,ft(n)):s}N.join=Ge;N.isAbsolute=function(e){return e.charAt(0)==="/"||He.test(e)};function mi(e,t){e===""&&(e="."),e=e.replace(/\/$/,"");for(var r=0;t.indexOf(e+"/")!==0;){var n=e.lastIndexOf("/");if(n<0||(e=e.slice(0,n),e.match(/^([^\/]+:\/)?\/*$/)))return t;++r}return Array(r+1).join("../")+t.substr(e.length+1)}N.relative=mi;var qe=function(){var e=Object.create(null);return!("__proto__"in e)}();function Ye(e){return e}function di(e){return je(e)?"$"+e:e}N.toSetString=qe?Ye:di;function xi(e){return je(e)?e.slice(1):e}N.fromSetString=qe?Ye:xi;function je(e){if(!e)return!1;var t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(var r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function ki(e,t,r){var n=K(e.source,t.source);return n!==0||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositions=ki;function Si(e,t,r){var n;return n=e.originalLine-t.originalLine,n!==0||(n=e.originalColumn-t.originalColumn,n!==0||r)||(n=e.generatedColumn-t.generatedColumn,n!==0)||(n=e.generatedLine-t.generatedLine,n!==0)?n:K(e.name,t.name)}N.compareByOriginalPositionsNoSource=Si;function gi(e,t,r){var n=e.generatedLine-t.generatedLine;return n!==0||(n=e.generatedColumn-t.generatedColumn,n!==0||r)||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:K(e.name,t.name)}N.compareByGeneratedPositionsDeflated=gi;function Ci(e,t,r){var n=e.generatedColumn-t.generatedColumn;return n!==0||r||(n=K(e.source,t.source),n!==0)||(n=e.originalLine-t.originalLine,n!==0)||(n=e.originalColumn-t.originalColumn,n!==0)?n:K(e.name,t.name)}N.compareByGeneratedPositionsDeflatedNoLine=Ci;function K(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function yi(e,t){var r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=K(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:K(e.name,t.name)}N.compareByGeneratedPositionsInflated=yi;function bi(e){return JSON.parse(e.replace(/^\)]}'[^\n]*\n/,""))}N.parseSourceMapInput=bi;function Li(e,t,r){if(t=t||"",e&&(e[e.length-1]!=="/"&&t[0]!=="/"&&(e+="/"),t=e+t),r){var n=Ct(r);if(!n)throw new Error("sourceMapURL could not be parsed");if(n.path){var s=n.path.lastIndexOf("/");s>=0&&(n.path=n.path.substring(0,s+1))}t=Ge(ft(n),t)}return ce(t)}N.computeSourceURL=Li});var Ke=lt(ze=>{var le=Bt(),he=Object.prototype.hasOwnProperty,it=typeof Map<"u";function Q(){this._array=[],this._set=it?new Map:Object.create(null)}Q.fromArray=function(t,r){for(var n=new Q,s=0,o=t.length;s<o;s++)n.add(t[s],r);return n};Q.prototype.size=function(){return it?this._set.size:Object.getOwnPropertyNames(this._set).length};Q.prototype.add=function(t,r){var n=it?t:le.toSetString(t),s=it?this.has(t):he.call(this._set,n),o=this._array.length;(!s||r)&&this._array.push(t),s||(it?this._set.set(t,o):this._set[n]=o)};Q.prototype.has=function(t){if(it)return this._set.has(t);var r=le.toSetString(t);return he.call(this._set,r)};Q.prototype.indexOf=function(t){if(it){var r=this._set.get(t);if(r>=0)return r}else{var n=le.toSetString(t);if(he.call(this._set,n))return this._set[n]}throw new Error('"'+t+'" is not in the set.')};Q.prototype.at=function(t){if(t>=0&&t<this._array.length)return this._array[t];throw new Error("No element indexed by "+t)};Q.prototype.toArray=function(){return this._array.slice()};ze.ArraySet=Q});var Xe=lt($e=>{var Qe=Bt();function Ti(e,t){var r=e.generatedLine,n=t.generatedLine,s=e.generatedColumn,o=t.generatedColumn;return n>r||n==r&&o>=s||Qe.compareByGeneratedPositionsInflated(e,t)<=0}function Ut(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}Ut.prototype.unsortedForEach=function(t,r){this._array.forEach(t,r)};Ut.prototype.add=function(t){Ti(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))};Ut.prototype.toArray=function(){return this._sorted||(this._array.sort(Qe.compareByGeneratedPositionsInflated),this._sorted=!0),this._array};$e.MappingList=Ut});var Ze=lt(Je=>{var yt=Ve(),v=Bt(),Wt=Ke().ArraySet,vi=Xe().MappingList;function W(e){e||(e={}),this._file=v.getArg(e,"file",null),this._sourceRoot=v.getArg(e,"sourceRoot",null),this._skipValidation=v.getArg(e,"skipValidation",!1),this._sources=new Wt,this._names=new Wt,this._mappings=new vi,this._sourcesContents=null}W.prototype._version=3;W.fromSourceMap=function(t){var r=t.sourceRoot,n=new W({file:t.file,sourceRoot:r});return t.eachMapping(function(s){var o={generated:{line:s.generatedLine,column:s.generatedColumn}};s.source!=null&&(o.source=s.source,r!=null&&(o.source=v.relative(r,o.source)),o.original={line:s.originalLine,column:s.originalColumn},s.name!=null&&(o.name=s.name)),n.addMapping(o)}),t.sources.forEach(function(s){var o=s;r!==null&&(o=v.relative(r,s)),n._sources.has(o)||n._sources.add(o);var a=t.sourceContentFor(s);a!=null&&n.setSourceContent(s,a)}),n};W.prototype.addMapping=function(t){var r=v.getArg(t,"generated"),n=v.getArg(t,"original",null),s=v.getArg(t,"source",null),o=v.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,s,o),s!=null&&(s=String(s),this._sources.has(s)||this._sources.add(s)),o!=null&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n!=null&&n.line,originalColumn:n!=null&&n.column,source:s,name:o})};W.prototype.setSourceContent=function(t,r){var n=t;this._sourceRoot!=null&&(n=v.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[v.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[v.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))};W.prototype.applySourceMap=function(t,r,n){var s=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);s=t.file}var o=this._sourceRoot;o!=null&&(s=v.relative(o,s));var a=new Wt,h=new Wt;this._mappings.unsortedForEach(function(l){if(l.source===s&&l.originalLine!=null){var i=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});i.source!=null&&(l.source=i.source,n!=null&&(l.source=v.join(n,l.source)),o!=null&&(l.source=v.relative(o,l.source)),l.originalLine=i.line,l.originalColumn=i.column,i.name!=null&&(l.name=i.name))}var c=l.source;c!=null&&!a.has(c)&&a.add(c);var f=l.name;f!=null&&!h.has(f)&&h.add(f)},this),this._sources=a,this._names=h,t.sources.forEach(function(l){var i=t.sourceContentFor(l);i!=null&&(n!=null&&(l=v.join(n,l)),o!=null&&(l=v.relative(o,l)),this.setSourceContent(l,i))},this)};W.prototype._validateMapping=function(t,r,n,s){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!s)){if(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n)return;throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:s}))}};W.prototype._serializeMappings=function(){for(var t=0,r=1,n=0,s=0,o=0,a=0,h="",l,i,c,f,k=this._mappings.toArray(),S=0,T=k.length;S<T;S++){if(i=k[S],l="",i.generatedLine!==r)for(t=0;i.generatedLine!==r;)l+=";",r++;else if(S>0){if(!v.compareByGeneratedPositionsInflated(i,k[S-1]))continue;l+=","}l+=yt.encode(i.generatedColumn-t),t=i.generatedColumn,i.source!=null&&(f=this._sources.indexOf(i.source),l+=yt.encode(f-a),a=f,l+=yt.encode(i.originalLine-1-s),s=i.originalLine-1,l+=yt.encode(i.originalColumn-n),n=i.originalColumn,i.name!=null&&(c=this._names.indexOf(i.name),l+=yt.encode(c-o),o=c)),h+=l}return h};W.prototype._generateSourcesContent=function(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=v.relative(r,n));var s=v.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,s)?this._sourcesContents[s]:null},this)};W.prototype.toJSON=function(){var t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t};W.prototype.toString=function(){return JSON.stringify(this.toJSON())};Je.SourceMapGenerator=W});function I(e){return e>=48&&e<=57}function z(e){return I(e)||e>=65&&e<=70||e>=97&&e<=102}function Et(e){return e>=65&&e<=90}function ti(e){return e>=97&&e<=122}function ei(e){return Et(e)||ti(e)}function ri(e){return e>=128}function vt(e){return ei(e)||ri(e)||e===95}function wt(e){return vt(e)||I(e)||e===45}function ni(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function dt(e){return e===10||e===13||e===12}function $(e){return dt(e)||e===32||e===9}function R(e,t){return!(e!==92||dt(t)||t===0)}function At(e,t,r){return e===45?vt(t)||t===45||R(t,r):vt(e)?!0:e===92?R(e,t):!1}function Nt(e,t,r){return e===43||e===45?I(t)?2:t===46&&I(r)?3:0:e===46?I(t)?2:0:I(e)?1:0}function It(e){return e===65279||e===65534?1:0}var Xt=new Array(128),ii=128,xt=130,Jt=131,Dt=132,Zt=133;for(let e=0;e<Xt.length;e++)Xt[e]=$(e)&&xt||I(e)&&Jt||vt(e)&&Dt||ni(e)&&Zt||e||ii;function Pt(e){return e<128?Xt[e]:Dt}function ht(e,t){return t<e.length?e.charCodeAt(t):0}function Ft(e,t,r){return r===13&&ht(e,t+1)===10?2:1}function ee(e,t,r){let n=e.charCodeAt(t);return Et(n)&&(n=n|32),n===r}function et(e,t,r,n){if(r-t!==n.length||t<0||r>e.length)return!1;for(let s=t;s<r;s++){let o=n.charCodeAt(s-t),a=e.charCodeAt(s);if(Et(a)&&(a=a|32),a!==o)return!1}return!0}function De(e,t){for(;t>=0&&$(e.charCodeAt(t));t--);return t+1}function kt(e,t){for(;t<e.length&&$(e.charCodeAt(t));t++);return t}function te(e,t){for(;t<e.length&&I(e.charCodeAt(t));t++);return t}function X(e,t){if(t+=2,z(ht(e,t-1))){for(let n=Math.min(e.length,t+5);t<n&&z(ht(e,t));t++);let r=ht(e,t);$(r)&&(t+=Ft(e,t,r))}return t}function St(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(!wt(r)){if(R(r,ht(e,t+1))){t=X(e,t)-1;continue}break}}return t}function Rt(e,t){let r=e.charCodeAt(t);if((r===43||r===45)&&(r=e.charCodeAt(t+=1)),I(r)&&(t=te(e,t+1),r=e.charCodeAt(t)),r===46&&I(e.charCodeAt(t+1))&&(t+=2,t=te(e,t)),ee(e,t,101)){let n=0;r=e.charCodeAt(t+1),(r===45||r===43)&&(n=1,r=e.charCodeAt(t+2)),I(r)&&(t=te(e,t+1+n+1))}return t}function Ot(e,t){for(;t<e.length;t++){let r=e.charCodeAt(t);if(r===41){t++;break}R(r,ht(e,t+1))&&(t=X(e,t))}return t}function re(e){if(e.length===1&&!z(e.charCodeAt(0)))return e[0];let t=parseInt(e,16);return(t===0||t>=55296&&t<=57343||t>1114111)&&(t=65533),String.fromCodePoint(t)}var gt=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"];function ut(e=null,t){return e===null||e.length<t?new Uint32Array(Math.max(t+1024,16384)):e}var Pe=10,si=12,Fe=13;function Re(e){let t=e.source,r=t.length,n=t.length>0?It(t.charCodeAt(0)):0,s=ut(e.lines,r),o=ut(e.columns,r),a=e.startLine,h=e.startColumn;for(let l=n;l<r;l++){let i=t.charCodeAt(l);s[l]=a,o[l]=h++,(i===Pe||i===Fe||i===si)&&(i===Fe&&l+1<r&&t.charCodeAt(l+1)===Pe&&(l++,s[l]=a,o[l]=h),a++,h=1)}s[r]=a,o[r]=h,e.lines=s,e.columns=o,e.computed=!0}var ne=class{constructor(){this.lines=null,this.columns=null,this.computed=!1}setSource(t,r=0,n=1,s=1){this.source=t,this.startOffset=r,this.startLine=n,this.startColumn=s,this.computed=!1}getLocation(t,r){return this.computed||Re(this),{source:r,offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]}}getLocationRange(t,r,n){return this.computed||Re(this),{source:n,start:{offset:this.startOffset+t,line:this.lines[t],column:this.columns[t]},end:{offset:this.startOffset+r,line:this.lines[r],column:this.columns[r]}}}};var M=16777215,V=24,oi=new Map([[2,22],[21,22],[19,20],[23,24]]),ie=class{constructor(t,r){this.setSource(t,r)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(t="",r=()=>{}){t=String(t||"");let n=t.length,s=ut(this.offsetAndType,t.length+1),o=ut(this.balance,t.length+1),a=0,h=0,l=0,i=-1;for(this.offsetAndType=null,this.balance=null,r(t,(c,f,k)=>{switch(c){default:o[a]=n;break;case h:{let S=l&M;for(l=o[S],h=l>>V,o[a]=S,o[S++]=a;S<a;S++)o[S]===n&&(o[S]=a);break}case 21:case 2:case 19:case 23:o[a]=l,h=oi.get(c),l=h<<V|a;break}s[a++]=c<<V|k,i===-1&&(i=f)}),s[a]=0<<V|n,o[a]=n,o[n]=n;l!==0;){let c=l&M;l=o[c],o[c]=n}this.source=t,this.firstCharOffset=i===-1?0:i,this.tokenCount=a,this.offsetAndType=s,this.balance=o,this.reset(),this.next()}lookupType(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t]>>V:0}lookupTypeNonSC(t){for(let r=this.tokenIndex;r<this.tokenCount;r++){let n=this.offsetAndType[r]>>V;if(n!==13&&n!==25&&t--===0)return n}return 0}lookupOffset(t){return t+=this.tokenIndex,t<this.tokenCount?this.offsetAndType[t-1]&M:this.source.length}lookupOffsetNonSC(t){for(let r=this.tokenIndex;r<this.tokenCount;r++){let n=this.offsetAndType[r]>>V;if(n!==13&&n!==25&&t--===0)return r-this.tokenIndex}return 0}lookupValue(t,r){return t+=this.tokenIndex,t<this.tokenCount?et(this.source,this.offsetAndType[t-1]&M,this.offsetAndType[t]&M,r):!1}getTokenStart(t){return t===this.tokenIndex?this.tokenStart:t>0?t<this.tokenCount?this.offsetAndType[t-1]&M:this.offsetAndType[this.tokenCount]&M:this.firstCharOffset}substrToCursor(t){return this.source.substring(t,this.tokenStart)}isBalanceEdge(t){return this.balance[this.tokenIndex]<t}isDelim(t,r){return r?this.lookupType(r)===9&&this.source.charCodeAt(this.lookupOffset(r))===t:this.tokenType===9&&this.source.charCodeAt(this.tokenStart)===t}skip(t){let r=this.tokenIndex+t;r<this.tokenCount?(this.tokenIndex=r,this.tokenStart=this.offsetAndType[r-1]&M,r=this.offsetAndType[r],this.tokenType=r>>V,this.tokenEnd=r&M):(this.tokenIndex=this.tokenCount,this.next())}next(){let t=this.tokenIndex+1;t<this.tokenCount?(this.tokenIndex=t,this.tokenStart=this.tokenEnd,t=this.offsetAndType[t],this.tokenType=t>>V,this.tokenEnd=t&M):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=0,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===13||this.tokenType===25;)this.next()}skipUntilBalanced(t,r){let n=t,s,o;t:for(;n<this.tokenCount;n++){if(s=this.balance[n],s<t)break t;switch(o=n>0?this.offsetAndType[n-1]&M:this.firstCharOffset,r(this.source.charCodeAt(o))){case 1:break t;case 2:n++;break t;default:this.balance[s]===n&&(n=s)}}this.skip(n-this.tokenIndex)}forEachToken(t){for(let r=0,n=this.firstCharOffset;r<this.tokenCount;r++){let s=n,o=this.offsetAndType[r],a=o&M,h=o>>V;n=a,t(h,s,a,r)}}dump(){let t=new Array(this.tokenCount);return this.forEachToken((r,n,s,o)=>{t[o]={idx:o,type:gt[r],chunk:this.source.substring(n,s),balance:this.balance[o]}}),t}};function Mt(e,t){function r(f){return f<h?e.charCodeAt(f):0}function n(){if(i=Rt(e,i),At(r(i),r(i+1),r(i+2))){c=12,i=St(e,i);return}if(r(i)===37){c=11,i++;return}c=10}function s(){let f=i;if(i=St(e,i),et(e,f,i,"url")&&r(i)===40){if(i=kt(e,i+1),r(i)===34||r(i)===39){c=2,i=f+4;return}a();return}if(r(i)===40){c=2,i++;return}c=1}function o(f){for(f||(f=r(i++)),c=5;i<e.length;i++){let k=e.charCodeAt(i);switch(Pt(k)){case f:i++;return;case xt:if(dt(k)){i+=Ft(e,i,k),c=6;return}break;case 92:if(i===e.length-1)break;let S=r(i+1);dt(S)?i+=Ft(e,i+1,S):R(k,S)&&(i=X(e,i)-1);break}}}function a(){for(c=7,i=kt(e,i);i<e.length;i++){let f=e.charCodeAt(i);switch(Pt(f)){case 41:i++;return;case xt:if(i=kt(e,i),r(i)===41||i>=e.length){i<e.length&&i++;return}i=Ot(e,i),c=8;return;case 34:case 39:case 40:case Zt:i=Ot(e,i),c=8;return;case 92:if(R(f,r(i+1))){i=X(e,i)-1;break}i=Ot(e,i),c=8;return}}}e=String(e||"");let h=e.length,l=It(r(0)),i=l,c;for(;i<h;){let f=e.charCodeAt(i);switch(Pt(f)){case xt:c=13,i=kt(e,i+1);break;case 34:o();break;case 35:wt(r(i+1))||R(r(i+1),r(i+2))?(c=4,i=St(e,i+1)):(c=9,i++);break;case 39:o();break;case 40:c=21,i++;break;case 41:c=22,i++;break;case 43:Nt(f,r(i+1),r(i+2))?n():(c=9,i++);break;case 44:c=18,i++;break;case 45:Nt(f,r(i+1),r(i+2))?n():r(i+1)===45&&r(i+2)===62?(c=15,i=i+3):At(f,r(i+1),r(i+2))?s():(c=9,i++);break;case 46:Nt(f,r(i+1),r(i+2))?n():(c=9,i++);break;case 47:r(i+1)===42?(c=25,i=e.indexOf("*/",i+2),i=i===-1?e.length:i+2):(c=9,i++);break;case 58:c=16,i++;break;case 59:c=17,i++;break;case 60:r(i+1)===33&&r(i+2)===45&&r(i+3)===45?(c=14,i=i+4):(c=9,i++);break;case 64:At(r(i+1),r(i+2),r(i+3))?(c=3,i=St(e,i+1)):(c=9,i++);break;case 91:c=19,i++;break;case 92:R(f,r(i+1))?s():(c=9,i++);break;case 93:c=20,i++;break;case 123:c=23,i++;break;case 125:c=24,i++;break;case Jt:n();break;case Dt:s();break;default:c=9,i++}t(c,l,l=i)}}var er=Zn(Ze(),1),tr=new Set(["Atrule","Selector","Declaration"]);function rr(e){let t=new er.SourceMapGenerator,r={line:1,column:0},n={line:0,column:0},s={line:1,column:0},o={generated:s},a=1,h=0,l=!1,i=e.node;e.node=function(k){if(k.loc&&k.loc.start&&tr.has(k.type)){let S=k.loc.start.line,T=k.loc.start.column-1;(n.line!==S||n.column!==T)&&(n.line=S,n.column=T,r.line=a,r.column=h,l&&(l=!1,(r.line!==s.line||r.column!==s.column)&&t.addMapping(o)),l=!0,t.addMapping({source:k.loc.source,original:n,generated:r}))}i.call(this,k),l&&tr.has(k.type)&&(s.line=a,s.column=h)};let c=e.emit;e.emit=function(k,S,T){for(let j=0;j<k.length;j++)k.charCodeAt(j)===10?(a++,h=0):h++;c(k,S,T)};let f=e.result;return e.result=function(){return l&&t.addMapping(o),{css:f(),map:t}},e}var Vt={};$t(Vt,{safe:()=>fe,spec:()=>Ni});var Ei=43,wi=45,ue=(e,t)=>{if(e===9&&(e=t),typeof e=="string"){let r=e.charCodeAt(0);return r>127?32768:r<<8}return e},nr=[[1,1],[1,2],[1,7],[1,8],[1,"-"],[1,10],[1,11],[1,12],[1,15],[1,21],[3,1],[3,2],[3,7],[3,8],[3,"-"],[3,10],[3,11],[3,12],[3,15],[4,1],[4,2],[4,7],[4,8],[4,"-"],[4,10],[4,11],[4,12],[4,15],[12,1],[12,2],[12,7],[12,8],[12,"-"],[12,10],[12,11],[12,12],[12,15],["#",1],["#",2],["#",7],["#",8],["#","-"],["#",10],["#",11],["#",12],["#",15],["-",1],["-",2],["-",7],["-",8],["-","-"],["-",10],["-",11],["-",12],["-",15],[10,1],[10,2],[10,7],[10,8],[10,10],[10,11],[10,12],[10,"%"],[10,15],["@",1],["@",2],["@",7],["@",8],["@","-"],["@",15],[".",10],[".",11],[".",12],["+",10],["+",11],["+",12],["/","*"]],Ai=nr.concat([[1,4],[12,4],[4,4],[3,21],[3,5],[3,16],[11,11],[11,12],[11,2],[11,"-"],[22,1],[22,2],[22,11],[22,12],[22,4],[22,"-"]]);function ir(e){let t=new Set(e.map(([r,n])=>ue(r)<<16|ue(n)));return function(r,n,s){let o=ue(n,s),a=s.charCodeAt(0);return(a===wi&&n!==1&&n!==2&&n!==15||a===Ei?t.has(r<<16|a<<8):t.has(r<<16|o))&&this.emit(" ",13,!0),o}}var Ni=ir(nr),fe=ir(Ai);var Ii=92;function Di(e,t){if(typeof t=="function"){let r=null;e.children.forEach(n=>{r!==null&&t.call(this,r),this.node(n),r=n});return}e.children.forEach(this.node,this)}function Pi(e){Mt(e,(t,r,n)=>{this.token(t,e.slice(r,n))})}function sr(e){let t=new Map;for(let[r,n]of Object.entries(e.node))typeof(n.generate||n)=="function"&&t.set(r,n.generate||n);return function(r,n){let s="",o=0,a={node(l){if(t.has(l.type))t.get(l.type).call(h,l);else throw new Error("Unknown node type: "+l.type)},tokenBefore:fe,token(l,i){o=this.tokenBefore(o,l,i),this.emit(i,l,!1),l===9&&i.charCodeAt(0)===Ii&&this.emit(`
|
| 2 |
+
`,13,!0)},emit(l){s+=l},result(){return s}};n&&(typeof n.decorator=="function"&&(a=n.decorator(a)),n.sourceMap&&(a=rr(a)),n.mode in Vt&&(a.tokenBefore=Vt[n.mode]));let h={node:l=>a.node(l),children:Di,token:(l,i)=>a.token(l,i),tokenize:Pi};return a.node(r),a.result()}}var Se={};$t(Se,{AnPlusB:()=>ar,Atrule:()=>cr,AtrulePrelude:()=>lr,AttributeSelector:()=>fr,Block:()=>pr,Brackets:()=>mr,CDC:()=>dr,CDO:()=>xr,ClassSelector:()=>Sr,Combinator:()=>yr,Comment:()=>br,Condition:()=>Lr,Declaration:()=>Tr,DeclarationList:()=>vr,Dimension:()=>Er,Feature:()=>wr,FeatureFunction:()=>Ar,FeatureRange:()=>Nr,Function:()=>Ir,GeneralEnclosed:()=>Dr,Hash:()=>Pr,IdSelector:()=>_r,Identifier:()=>Rr,Layer:()=>Mr,LayerList:()=>Br,MediaQuery:()=>Ur,MediaQueryList:()=>Wr,NestingSelector:()=>Hr,Nth:()=>qr,Number:()=>Yr,Operator:()=>zr,Parentheses:()=>Kr,Percentage:()=>$r,PseudoClassSelector:()=>Jr,PseudoElementSelector:()=>tn,Ratio:()=>en,Raw:()=>nn,Rule:()=>sn,Scope:()=>on,Selector:()=>cn,SelectorList:()=>hn,String:()=>dn,StyleSheet:()=>xn,SupportsDeclaration:()=>kn,TypeSelector:()=>Cn,UnicodeRange:()=>yn,Url:()=>Ln,Value:()=>Tn,WhiteSpace:()=>vn});var Y=43,_=45,Ht=110,st=!0,Fi=!1;function Gt(e,t){let r=this.tokenStart+e,n=this.charCodeAt(r);for((n===Y||n===_)&&(t&&this.error("Number sign is not allowed"),r++);r<this.tokenEnd;r++)I(this.charCodeAt(r))||this.error("Integer is expected",r)}function pt(e){return Gt.call(this,0,e)}function Z(e,t){if(!this.cmpChar(this.tokenStart+e,t)){let r="";switch(t){case Ht:r="N is expected";break;case _:r="HyphenMinus is expected";break}this.error(r,this.tokenStart+e)}}function pe(){let e=0,t=0,r=this.tokenType;for(;r===13||r===25;)r=this.lookupType(++e);if(r!==10)if(this.isDelim(Y,e)||this.isDelim(_,e)){t=this.isDelim(Y,e)?Y:_;do r=this.lookupType(++e);while(r===13||r===25);r!==10&&(this.skip(e),pt.call(this,st))}else return null;return e>0&&this.skip(e),t===0&&(r=this.charCodeAt(this.tokenStart),r!==Y&&r!==_&&this.error("Number sign is expected")),pt.call(this,t!==0),t===_?"-"+this.consume(10):this.consume(10)}function or(){let e=this.tokenStart,t=null,r=null;if(this.tokenType===10)pt.call(this,Fi),r=this.consume(10);else if(this.tokenType===1&&this.cmpChar(this.tokenStart,_))switch(t="-1",Z.call(this,1,Ht),this.tokenEnd-this.tokenStart){case 2:this.next(),r=pe.call(this);break;case 3:Z.call(this,2,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,2,_),Gt.call(this,3,st),this.next(),r=this.substrToCursor(e+2)}else if(this.tokenType===1||this.isDelim(Y)&&this.lookupType(1)===1){let n=0;switch(t="1",this.isDelim(Y)&&(n=1,this.next()),Z.call(this,0,Ht),this.tokenEnd-this.tokenStart){case 1:this.next(),r=pe.call(this);break;case 2:Z.call(this,1,_),this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10);break;default:Z.call(this,1,_),Gt.call(this,2,st),this.next(),r=this.substrToCursor(e+n+1)}}else if(this.tokenType===12){let n=this.charCodeAt(this.tokenStart),s=n===Y||n===_,o=this.tokenStart+s;for(;o<this.tokenEnd&&I(this.charCodeAt(o));o++);o===this.tokenStart+s&&this.error("Integer is expected",this.tokenStart+s),Z.call(this,o-this.tokenStart,Ht),t=this.substring(e,o),o+1===this.tokenEnd?(this.next(),r=pe.call(this)):(Z.call(this,o-this.tokenStart+1,_),o+2===this.tokenEnd?(this.next(),this.skipSC(),pt.call(this,st),r="-"+this.consume(10)):(Gt.call(this,o-this.tokenStart+2,st),this.next(),r=this.substrToCursor(o+1)))}else this.error();return t!==null&&t.charCodeAt(0)===Y&&(t=t.substr(1)),r!==null&&r.charCodeAt(0)===Y&&(r=r.substr(1)),{type:"AnPlusB",loc:this.getLocation(e,this.tokenStart),a:t,b:r}}function ar(e){if(e.a){let t=e.a==="+1"&&"n"||e.a==="1"&&"n"||e.a==="-1"&&"-n"||e.a+"n";if(e.b){let r=e.b[0]==="-"||e.b[0]==="+"?e.b:"+"+e.b;this.tokenize(t+r)}else this.tokenize(t)}else this.tokenize(e.b)}function cr(e){this.token(3,"@"+e.name),e.prelude!==null&&this.node(e.prelude),e.block?(this.token(23,"{"),this.node(e.block),this.token(24,"}")):this.token(17,";")}function lr(e){this.children(e)}var Ri=36,hr=42,qt=61,Oi=94,me=124,_i=126;function Mi(){this.eof&&this.error("Unexpected end of input");let e=this.tokenStart,t=!1;return this.isDelim(hr)?(t=!0,this.next()):this.isDelim(me)||this.eat(1),this.isDelim(me)?this.charCodeAt(this.tokenStart+1)!==qt?(this.next(),this.eat(1)):t&&this.error("Identifier is expected",this.tokenEnd):t&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Bi(){let e=this.tokenStart,t=this.charCodeAt(e);return t!==qt&&t!==_i&&t!==Oi&&t!==Ri&&t!==hr&&t!==me&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),t!==qt&&(this.isDelim(qt)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(e)}function ur(){let e=this.tokenStart,t,r=null,n=null,s=null;return this.eat(19),this.skipSC(),t=Mi.call(this),this.skipSC(),this.tokenType!==20&&(this.tokenType!==1&&(r=Bi.call(this),this.skipSC(),n=this.tokenType===5?this.String():this.Identifier(),this.skipSC()),this.tokenType===1&&(s=this.consume(1),this.skipSC())),this.eat(20),{type:"AttributeSelector",loc:this.getLocation(e,this.tokenStart),name:t,matcher:r,value:n,flags:s}}function fr(e){this.token(9,"["),this.node(e.name),e.matcher!==null&&(this.tokenize(e.matcher),this.node(e.value)),e.flags!==null&&this.token(1,e.flags),this.token(9,"]")}function pr(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}function mr(e){this.token(9,"["),this.children(e),this.token(9,"]")}function dr(){this.token(15,"-->")}function xr(){this.token(14,"<!--")}var Ui=46;function kr(){return this.eatDelim(Ui),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(1)}}function Sr(e){this.token(9,"."),this.token(1,e.name)}var Wi=43,gr=47,Vi=62,Hi=126;function Cr(){let e=this.tokenStart,t;switch(this.tokenType){case 13:t=" ";break;case 9:switch(this.charCodeAt(this.tokenStart)){case Vi:case Wi:case Hi:this.next();break;case gr:this.next(),this.eatIdent("deep"),this.eatDelim(gr);break;default:this.error("Combinator is expected")}t=this.substrToCursor(e);break}return{type:"Combinator",loc:this.getLocation(e,this.tokenStart),name:t}}function yr(e){this.tokenize(e.name)}function br(e){this.token(25,"/*"+e.value+"*/")}function Lr(e){e.children.forEach(t=>{t.type==="Condition"?(this.token(21,"("),this.node(t),this.token(22,")")):this.node(t)})}function Tr(e){this.token(1,e.property),this.token(16,":"),this.node(e.value),e.important&&(this.token(9,"!"),this.token(1,e.important===!0?"important":e.important))}function vr(e){this.children(e,t=>{t.type==="Declaration"&&this.token(17,";")})}function Er(e){this.token(12,e.value+e.unit)}function wr(e){this.token(21,"("),this.token(1,e.name),e.value!==null&&(this.token(16,":"),this.node(e.value)),this.token(22,")")}function Ar(e){this.token(2,e.feature+"("),this.node(e.value),this.token(22,")")}function Nr(e){this.token(21,"("),this.node(e.left),this.tokenize(e.leftComparison),this.node(e.middle),e.right&&(this.tokenize(e.rightComparison),this.node(e.right)),this.token(22,")")}function Ir(e){this.token(2,e.name+"("),this.children(e),this.token(22,")")}function Dr(e){e.function?this.token(2,e.function+"("):this.token(21,"("),this.children(e),this.token(22,")")}function Pr(e){this.token(4,"#"+e.value)}function Fr(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(1)}}function Rr(e){this.token(1,e.name)}function Or(){let e=this.tokenStart;return this.eat(4),{type:"IdSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e+1)}}function _r(e){this.token(9,"#"+e.name)}function Mr(e){this.tokenize(e.name)}function Br(e){this.children(e,()=>this.token(18,","))}function Ur(e){e.mediaType?(e.modifier&&this.token(1,e.modifier),this.token(1,e.mediaType),e.condition&&(this.token(1,"and"),this.node(e.condition))):e.condition&&this.node(e.condition)}function Wr(e){this.children(e,()=>this.token(18,","))}var Gi=38;function Vr(){let e=this.tokenStart;return this.eatDelim(Gi),{type:"NestingSelector",loc:this.getLocation(e,this.tokenStart)}}function Hr(){this.token(9,"&")}function Gr(){this.skipSC();let e=this.tokenStart,t=e,r=null,n;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?n=this.Identifier():n=this.AnPlusB(),t=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),r=this.SelectorList(),t=this.tokenStart),{type:"Nth",loc:this.getLocation(e,t),nth:n,selector:r}}function qr(e){this.node(e.nth),e.selector!==null&&(this.token(1,"of"),this.node(e.selector))}function Yr(e){this.token(10,e.value)}function jr(){let e=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(e,this.tokenStart),value:this.substrToCursor(e)}}function zr(e){this.tokenize(e.value)}function Kr(e){this.token(21,"("),this.children(e),this.token(22,")")}function Qr(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(11)}}function $r(e){this.token(11,e.value+"%")}function Xr(){let e=this.tokenStart,t=null,r,n;return this.eat(16),this.tokenType===2?(r=this.consumeFunctionName(),n=r.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),t=this.pseudo[n].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):r=this.consume(1),{type:"PseudoClassSelector",loc:this.getLocation(e,this.tokenStart),name:r,children:t}}function Jr(e){this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}function Zr(){let e=this.tokenStart,t=null,r,n;return this.eat(16),this.eat(16),this.tokenType===2?(r=this.consumeFunctionName(),n=r.toLowerCase(),this.lookupNonWSType(0)==22?t=this.createList():hasOwnProperty.call(this.pseudo,n)?(this.skipSC(),t=this.pseudo[n].call(this),this.skipSC()):(t=this.createList(),t.push(this.Raw(null,!1))),this.eat(22)):r=this.consume(1),{type:"PseudoElementSelector",loc:this.getLocation(e,this.tokenStart),name:r,children:t}}function tn(e){this.token(16,":"),this.token(16,":"),e.children===null?this.token(1,e.name):(this.token(2,e.name+"("),this.children(e),this.token(22,")"))}function en(e){this.node(e.left),this.token(9,"/"),e.right?this.node(e.right):this.node(10,1)}function qi(){return this.tokenIndex>0&&this.lookupType(-1)===13?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}function rn(e,t){let r=this.getTokenStart(this.tokenIndex),n;return this.skipUntilBalanced(this.tokenIndex,e||this.consumeUntilBalanceEnd),t&&this.tokenStart>r?n=qi.call(this):n=this.tokenStart,{type:"Raw",loc:this.getLocation(r,n),value:this.substring(r,n)}}function nn(e){this.tokenize(e.value)}function sn(e){this.node(e.prelude),this.token(23,"{"),this.node(e.block),this.token(24,"}")}function on(e){e.root&&(this.token(21,"("),this.node(e.root),this.token(22,")")),e.limit&&(this.token(1,"to"),this.token(21,"("),this.node(e.limit),this.token(22,")"))}function an(){let e=this.readSequence(this.scope.Selector);return this.getFirstListNode(e)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(e),children:e}}function cn(e){this.children(e)}function ln(){let e=this.createList();for(;!this.eof;){if(e.push(this.Selector()),this.tokenType===18){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(e),children:e}}function hn(e){this.children(e,()=>this.token(18,","))}var de=92,un=34,fn=39;function xe(e){let t=e.length,r=e.charCodeAt(0),n=r===un||r===fn?1:0,s=n===1&&t>1&&e.charCodeAt(t-1)===r?t-2:t-1,o="";for(let a=n;a<=s;a++){let h=e.charCodeAt(a);if(h===de){if(a===s){a!==t-1&&(o=e.substr(a+1));break}if(h=e.charCodeAt(++a),R(de,h)){let l=a-1,i=X(e,l);a=i-1,o+=re(e.substring(l+1,i))}else h===13&&e.charCodeAt(a+1)===10&&a++}else o+=e[a]}return o}function pn(e,t){let r=t?"'":'"',n=t?fn:un,s="",o=!1;for(let a=0;a<e.length;a++){let h=e.charCodeAt(a);if(h===0){s+="\uFFFD";continue}if(h<=31||h===127){s+="\\"+h.toString(16),o=!0;continue}h===n||h===de?(s+="\\"+e.charAt(a),o=!1):(o&&(z(h)||$(h))&&(s+=" "),s+=e.charAt(a),o=!1)}return r+s+r}function mn(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:xe(this.consume(5))}}function dn(e){this.token(5,pn(e.value))}function xn(e){this.children(e)}function kn(e){this.token(21,"("),this.node(e.declaration),this.token(22,")")}var ji=42,Sn=124;function ke(){this.tokenType!==1&&this.isDelim(ji)===!1&&this.error("Identifier or asterisk is expected"),this.next()}function gn(){let e=this.tokenStart;return this.isDelim(Sn)?(this.next(),ke.call(this)):(ke.call(this),this.isDelim(Sn)&&(this.next(),ke.call(this))),{type:"TypeSelector",loc:this.getLocation(e,this.tokenStart),name:this.substrToCursor(e)}}function Cn(e){this.tokenize(e.name)}function yn(e){this.tokenize(e.value)}var zi=32,Ki=92,Qi=34,$i=39,Xi=40,Ji=41;function bn(e){let t="",r=!1;for(let n=0;n<e.length;n++){let s=e.charCodeAt(n);if(s===0){t+="\uFFFD";continue}if(s<=31||s===127){t+="\\"+s.toString(16),r=!0;continue}s===zi||s===Ki||s===Qi||s===$i||s===Xi||s===Ji?(t+="\\"+e.charAt(n),r=!1):(r&&z(s)&&(t+=" "),t+=e.charAt(n),r=!1)}return"url("+t+")"}function Ln(e){this.token(7,bn(e.value))}function Tn(e){this.children(e)}var ja=Object.freeze({type:"WhiteSpace",loc:null,value:" "});function vn(e){this.token(13,e.value)}var En={node:Se};var wn=sr(En);var mt=null,P=class{static createItem(t){return{prev:null,next:null,data:t}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(t){return P.createItem(t)}allocateCursor(t,r){let n;return mt!==null?(n=mt,mt=mt.cursor,n.prev=t,n.next=r,n.cursor=this.cursor):n={prev:t,next:r,cursor:this.cursor},this.cursor=n,n}releaseCursor(){let{cursor:t}=this;this.cursor=t.cursor,t.prev=null,t.next=null,t.cursor=mt,mt=t}updateCursors(t,r,n,s){let{cursor:o}=this;for(;o!==null;)o.prev===t&&(o.prev=r),o.next===n&&(o.next=s),o=o.cursor}*[Symbol.iterator](){for(let t=this.head;t!==null;t=t.next)yield t.data}get size(){let t=0;for(let r=this.head;r!==null;r=r.next)t++;return t}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(t){let r=null;this.head=null;for(let n of t){let s=P.createItem(n);r!==null?r.next=s:this.head=s,s.prev=r,r=s}return this.tail=r,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(t,r=this){let n=this.allocateCursor(null,this.head);for(;n.next!==null;){let s=n.next;n.next=s.next,t.call(r,s.data,s,this)}this.releaseCursor()}forEachRight(t,r=this){let n=this.allocateCursor(this.tail,null);for(;n.prev!==null;){let s=n.prev;n.prev=s.prev,t.call(r,s.data,s,this)}this.releaseCursor()}reduce(t,r,n=this){let s=this.allocateCursor(null,this.head),o=r,a;for(;s.next!==null;)a=s.next,s.next=a.next,o=t.call(n,o,a.data,a,this);return this.releaseCursor(),o}reduceRight(t,r,n=this){let s=this.allocateCursor(this.tail,null),o=r,a;for(;s.prev!==null;)a=s.prev,s.prev=a.prev,o=t.call(n,o,a.data,a,this);return this.releaseCursor(),o}some(t,r=this){for(let n=this.head;n!==null;n=n.next)if(t.call(r,n.data,n,this))return!0;return!1}map(t,r=this){let n=new P;for(let s=this.head;s!==null;s=s.next)n.appendData(t.call(r,s.data,s,this));return n}filter(t,r=this){let n=new P;for(let s=this.head;s!==null;s=s.next)t.call(r,s.data,s,this)&&n.appendData(s.data);return n}nextUntil(t,r,n=this){if(t===null)return;let s=this.allocateCursor(null,t);for(;s.next!==null;){let o=s.next;if(s.next=o.next,r.call(n,o.data,o,this))break}this.releaseCursor()}prevUntil(t,r,n=this){if(t===null)return;let s=this.allocateCursor(t,null);for(;s.prev!==null;){let o=s.prev;if(s.prev=o.prev,r.call(n,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){let t=new P;for(let r of this)t.appendData(r);return t}prepend(t){return this.updateCursors(null,t,this.head,t),this.head!==null?(this.head.prev=t,t.next=this.head):this.tail=t,this.head=t,this}prependData(t){return this.prepend(P.createItem(t))}append(t){return this.insert(t)}appendData(t){return this.insert(P.createItem(t))}insert(t,r=null){if(r!==null)if(this.updateCursors(r.prev,t,r,t),r.prev===null){if(this.head!==r)throw new Error("before doesn't belong to list");this.head=t,r.prev=t,t.next=r,this.updateCursors(null,t)}else r.prev.next=t,t.prev=r.prev,r.prev=t,t.next=r;else this.updateCursors(this.tail,t,null,t),this.tail!==null?(this.tail.next=t,t.prev=this.tail):this.head=t,this.tail=t;return this}insertData(t,r){return this.insert(P.createItem(t),r)}remove(t){if(this.updateCursors(t,t.prev,t,t.next),t.prev!==null)t.prev.next=t.next;else{if(this.head!==t)throw new Error("item doesn't belong to list");this.head=t.next}if(t.next!==null)t.next.prev=t.prev;else{if(this.tail!==t)throw new Error("item doesn't belong to list");this.tail=t.prev}return t.prev=null,t.next=null,t}push(t){this.insert(P.createItem(t))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(t){this.prepend(P.createItem(t))}shift(){return this.head!==null?this.remove(this.head):null}prependList(t){return this.insertList(t,this.head)}appendList(t){return this.insertList(t)}insertList(t,r){return t.head===null?this:(r!=null?(this.updateCursors(r.prev,t.tail,r,t.head),r.prev!==null?(r.prev.next=t.head,t.head.prev=r.prev):this.head=t.head,r.prev=t.tail,t.tail.next=r):(this.updateCursors(this.tail,t.tail,null,t.head),this.tail!==null?(this.tail.next=t.head,t.head.prev=this.tail):this.head=t.head,this.tail=t.tail),t.head=null,t.tail=null,this)}replace(t,r){"head"in r?this.insertList(r,t):this.insert(r,t),this.remove(t)}};function An(e,t){let r=Object.create(SyntaxError.prototype),n=new Error;return Object.assign(r,{name:e,message:t,get stack(){return(n.stack||"").replace(/^(.+\n){1,3}/,`${e}: ${t}
|
| 3 |
+
`)}})}var ge=100,Nn=60,In=" ";function Dn({source:e,line:t,column:r,baseLine:n,baseColumn:s},o){function a(T,j){return i.slice(T,j).map((tt,Qt)=>String(T+Qt+1).padStart(k)+" |"+tt).join(`
|
| 4 |
+
`)}let h=`
|
| 5 |
+
`.repeat(Math.max(n-1,0)),l=" ".repeat(Math.max(s-1,0)),i=(h+l+e).split(/\r\n?|\n|\f/),c=Math.max(1,t-o)-1,f=Math.min(t+o,i.length+1),k=Math.max(4,String(f).length)+1,S=0;r+=(In.length-1)*(i[t-1].substr(0,r-1).match(/\t/g)||[]).length,r>ge&&(S=r-Nn+3,r=Nn-2);for(let T=c;T<=f;T++)T>=0&&T<i.length&&(i[T]=i[T].replace(/\t/g,In),i[T]=(S>0&&i[T].length>S?"\u2026":"")+i[T].substr(S,ge-2)+(i[T].length>S+ge-1?"\u2026":""));return[a(c,t),new Array(r+k+2).join("-")+"^",a(t,f)].filter(Boolean).join(`
|
| 6 |
+
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Ce(e,t,r,n,s,o=1,a=1){return Object.assign(An("SyntaxError",e),{source:t,offset:r,line:n,column:s,sourceFragment(l){return Dn({source:t,line:n,column:s,baseLine:o,baseColumn:a},isNaN(l)?0:l)},get formattedMessage(){return`Parse error: ${e}
|
| 7 |
+
`+Dn({source:t,line:n,column:s,baseLine:o,baseColumn:a},2)}})}function Pn(e){let t=this.createList(),r=!1,n={recognizer:e};for(;!this.eof;){switch(this.tokenType){case 25:this.next();continue;case 13:r=!0,this.next();continue}let s=e.getNode.call(this,n);if(s===void 0)break;r&&(e.onWhiteSpace&&e.onWhiteSpace.call(this,s,t,n),r=!1),t.push(s)}return r&&e.onWhiteSpace&&e.onWhiteSpace.call(this,null,t,n),t}var Fn=()=>{},ts=33,es=35,ye=59,Rn=123,On=0;function rs(e){return function(){return this[e]()}}function be(e){let t=Object.create(null);for(let r of Object.keys(e)){let n=e[r],s=n.parse||n;s&&(t[r]=s)}return t}function ns(e){let t={context:Object.create(null),features:Object.assign(Object.create(null),e.features),scope:Object.assign(Object.create(null),e.scope),atrule:be(e.atrule),pseudo:be(e.pseudo),node:be(e.node)};for(let[r,n]of Object.entries(e.parseContext))switch(typeof n){case"function":t.context[r]=n;break;case"string":t.context[r]=rs(n);break}return{config:t,...t,...t.node}}function _n(e){let t="",r="<unknown>",n=!1,s=Fn,o=!1,a=new ne,h=Object.assign(new ie,ns(e||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:Pn,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(i){return i===Rn?1:0},consumeUntilLeftCurlyBracketOrSemicolon(i){return i===Rn||i===ye?1:0},consumeUntilExclamationMarkOrSemicolon(i){return i===ts||i===ye?1:0},consumeUntilSemicolonIncluded(i){return i===ye?2:0},createList(){return new P},createSingleNodeList(i){return new P().appendData(i)},getFirstListNode(i){return i&&i.first},getLastListNode(i){return i&&i.last},parseWithFallback(i,c){let f=this.tokenIndex;try{return i.call(this)}catch(k){if(o)throw k;this.skip(f-this.tokenIndex);let S=c.call(this);return o=!0,s(k,S),o=!1,S}},lookupNonWSType(i){let c;do if(c=this.lookupType(i++),c!==13&&c!==25)return c;while(c!==On);return On},charCodeAt(i){return i>=0&&i<t.length?t.charCodeAt(i):0},substring(i,c){return t.substring(i,c)},substrToCursor(i){return this.source.substring(i,this.tokenStart)},cmpChar(i,c){return ee(t,i,c)},cmpStr(i,c,f){return et(t,i,c,f)},consume(i){let c=this.tokenStart;return this.eat(i),this.substrToCursor(c)},consumeFunctionName(){let i=t.substring(this.tokenStart,this.tokenEnd-1);return this.eat(2),i},consumeNumber(i){let c=t.substring(this.tokenStart,Rt(t,this.tokenStart));return this.eat(i),c},eat(i){if(this.tokenType!==i){let c=gt[i].slice(0,-6).replace(/-/g," ").replace(/^./,S=>S.toUpperCase()),f=`${/[[\](){}]/.test(c)?`"${c}"`:c} is expected`,k=this.tokenStart;switch(i){case 1:this.tokenType===2||this.tokenType===7?(k=this.tokenEnd-1,f="Identifier is expected but function found"):f="Identifier is expected";break;case 4:this.isDelim(es)&&(this.next(),k++,f="Name is expected");break;case 11:this.tokenType===10&&(k=this.tokenEnd,f="Percent sign is expected");break}this.error(f,k)}this.next()},eatIdent(i){(this.tokenType!==1||this.lookupValue(0,i)===!1)&&this.error(`Identifier "${i}" is expected`),this.next()},eatDelim(i){this.isDelim(i)||this.error(`Delim "${String.fromCharCode(i)}" is expected`),this.next()},getLocation(i,c){return n?a.getLocationRange(i,c,r):null},getLocationFromList(i){if(n){let c=this.getFirstListNode(i),f=this.getLastListNode(i);return a.getLocationRange(c!==null?c.loc.start.offset-a.startOffset:this.tokenStart,f!==null?f.loc.end.offset-a.startOffset:this.tokenStart,r)}return null},error(i,c){let f=typeof c<"u"&&c<t.length?a.getLocation(c):this.eof?a.getLocation(De(t,t.length-1)):a.getLocation(this.tokenStart);throw new Ce(i||"Unexpected input",t,f.offset,f.line,f.column,a.startLine,a.startColumn)}});return Object.assign(function(i,c){t=i,c=c||{},h.setSource(t,Mt),a.setSource(t,c.offset,c.line,c.column),r=c.filename||"<unknown>",n=Boolean(c.positions),s=typeof c.onParseError=="function"?c.onParseError:Fn,o=!1,h.parseAtrulePrelude="parseAtrulePrelude"in c?Boolean(c.parseAtrulePrelude):!0,h.parseRulePrelude="parseRulePrelude"in c?Boolean(c.parseRulePrelude):!0,h.parseValue="parseValue"in c?Boolean(c.parseValue):!0,h.parseCustomProperty="parseCustomProperty"in c?Boolean(c.parseCustomProperty):!1;let{context:f="default",onComment:k}=c;if(!(f in h.context))throw new Error("Unknown context `"+f+"`");typeof k=="function"&&h.forEachToken((T,j,tt)=>{if(T===25){let Qt=h.getLocation(j,tt),Yn=et(t,tt-2,tt,"*/")?t.slice(j+2,tt-2):t.slice(j+2,tt);k(Yn,Qt)}});let S=h.context[f].call(h,c);return h.eof||h.error(),S},{SyntaxError:Ce,config:h.config})}var ss=35,os=38,as=42,cs=43,ls=47,Mn=46,hs=62,us=124,fs=126;function ps(e,t){t.last!==null&&t.last.type!=="Combinator"&&e!==null&&e.type!=="Combinator"&&t.push({type:"Combinator",loc:null,name:" "})}function ms(){switch(this.tokenType){case 19:return this.AttributeSelector();case 4:return this.IdSelector();case 16:return this.lookupType(1)===16?this.PseudoElementSelector():this.PseudoClassSelector();case 1:return this.TypeSelector();case 10:case 11:return this.Percentage();case 12:this.charCodeAt(this.tokenStart)===Mn&&this.error("Identifier is expected",this.tokenStart+1);break;case 9:{switch(this.charCodeAt(this.tokenStart)){case cs:case hs:case fs:case ls:return this.Combinator();case Mn:return this.ClassSelector();case as:case us:return this.TypeSelector();case ss:return this.IdSelector();case os:return this.NestingSelector()}break}}}var Le={onWhiteSpace:ps,getNode:ms};function Bn(){let e=this.createList();this.skipSC();t:for(;!this.eof;){switch(this.tokenType){case 1:e.push(this.Identifier());break;case 5:e.push(this.String());break;case 18:e.push(this.Operator());break;case 22:break t;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return e}var ot={parse(){return this.createSingleNodeList(this.SelectorList())}},Te={parse(){return this.createSingleNodeList(this.Selector())}},ds={parse(){return this.createSingleNodeList(this.Identifier())}},xs={parse:Bn},Yt={parse(){return this.createSingleNodeList(this.Nth())}},Un={dir:ds,has:ot,lang:xs,matches:ot,is:ot,"-moz-any":ot,"-webkit-any":ot,where:ot,not:ot,"nth-child":Yt,"nth-last-child":Yt,"nth-last-of-type":Yt,"nth-of-type":Yt,slotted:Te,host:Te,"host-context":Te};var ve={};$t(ve,{AnPlusB:()=>or,AttributeSelector:()=>ur,ClassSelector:()=>kr,Combinator:()=>Cr,IdSelector:()=>Or,Identifier:()=>Fr,NestingSelector:()=>Vr,Nth:()=>Gr,Operator:()=>jr,Percentage:()=>Qr,PseudoClassSelector:()=>Xr,PseudoElementSelector:()=>Zr,Raw:()=>rn,Selector:()=>an,SelectorList:()=>ln,String:()=>mn,TypeSelector:()=>gn});var Wn={parseContext:{default:"SelectorList",selectorList:"SelectorList",selector:"Selector"},scope:{Selector:Le},atrule:{},pseudo:Un,node:ve};var Ee=_n(Wn);var at=(e,t)=>e.a===t.a?e.b===t.b?e.c-t.c:e.b-t.b:e.a-t.a,we=(e,t)=>at(e,t)===0,Ae=(e,t)=>at(e,t)>0,Ne=(e,t)=>at(e,t)<0;var Vn=(e,t="ASC")=>{let r=e.sort(at);return t==="DESC"?r.reverse():r},jt=(...e)=>Vn(e,"ASC"),zt=(...e)=>Vn(e,"DESC");var bt=(...e)=>zt(...e)[0],Hn=(...e)=>jt(...e)[0];var Lt=e=>{if(!e||e.type!=="Selector")throw new TypeError("Passed in source is not a Selector AST");let t=0,r=0,n=0;return e.children.forEach(s=>{switch(s.type){case"IdSelector":t+=1;break;case"AttributeSelector":case"ClassSelector":r+=1;break;case"PseudoClassSelector":switch(s.name.toLowerCase()){case"where":break;case"-webkit-any":case"any":s.children?.first&&(r+=1);break;case"-moz-any":case"is":case"matches":case"not":case"has":if(s.children?.first){let a=bt(...ct(s.children.first));t+=a.a,r+=a.b,n+=a.c}break;case"nth-child":case"nth-last-child":if(r+=1,s.children?.first?.selector){let a=bt(...ct(s.children.first.selector));t+=a.a,r+=a.b,n+=a.c}break;case"host-context":case"host":if(r+=1,s.children?.first?.children){let a={type:"Selector",children:[]},h=!1;s.children.first.children.forEach(i=>{if(h)return!1;if(i.type==="Combinator")return h=!0,!1;a.children.push(i)});let l=ct(a)[0];t+=l.a,r+=l.b,n+=l.c}break;case"after":case"before":case"first-letter":case"first-line":n+=1;break;default:r+=1;break}break;case"PseudoElementSelector":switch(s.name){case"slotted":if(n+=1,s.children?.first?.children){let a={type:"Selector",children:[]},h=!1;s.children.first.children.forEach(i=>{if(h)return!1;if(i.type==="Combinator")return h=!0,!1;a.children.push(i)});let l=ct(a)[0];t+=l.a,r+=l.b,n+=l.c}break;case"view-transition-group":case"view-transition-image-pair":case"view-transition-old":case"view-transition-new":if(s.children?.first?.value==="*")break;n+=1;break;default:n+=1;break}break;case"TypeSelector":let o=s.name;o.includes("|")&&(o=o.split("|")[1]),o!=="*"&&(n+=1);break;default:break}}),new Gn({a:t,b:r,c:n},e)},ks=e=>{if(typeof e=="string"||e instanceof String)try{return Ee(e,{context:"selectorList"})}catch(t){throw new TypeError(`Could not convert passed in source '${e}' to SelectorList: ${t.message}`)}if(e instanceof Object){if(e.type&&["Selector","SelectorList"].includes(e.type))return e;if(e.type&&e.type==="Raw")try{return Ee(e.value,{context:"selectorList"})}catch(t){throw new TypeError(`Could not convert passed in source to SelectorList: ${t.message}`)}throw new TypeError("Passed in source is an Object but no AST / AST of the type Selector or SelectorList")}throw new TypeError("Passed in source is not a String nor an Object. I don't know what to do with it.")},ct=e=>{if(!e)return[];let t=ks(e);if(t.type==="Selector")return[Lt(e)];if(t.type==="SelectorList"){let r=[];return t.children.forEach(n=>{let s=Lt(n);r.push(s)}),r}};var Kt=class extends Error{constructor(){super("Manipulating a Specificity instance is not allowed. Instead, create a new Specificity()")}},qn=class{constructor(t,r=null){this.value=t,this.selector=r}get a(){return this.value.a}set a(t){throw new Kt}get b(){return this.value.b}set b(t){throw new Kt}get c(){return this.value.c}set c(t){throw new Kt}selectorString(){return typeof this.selector=="string"||this.selector instanceof String?this.selector:this.selector instanceof Object&&this.selector.type==="Selector"?wn(this.selector):""}toObject(){return this.value}toArray(){return[this.value.a,this.value.b,this.value.c]}toString(){return`(${this.value.a},${this.value.b},${this.value.c})`}toJSON(){return{selector:this.selectorString(),asObject:this.toObject(),asArray:this.toArray(),asString:this.toString()}}isEqualTo(t){return we(this,t)}isGreaterThan(t){return Ae(this,t)}isLessThan(t){return Ne(this,t)}static calculate(t){return ct(t)}static calculateForAST(t){return Lt(t)}static compare(t,r){return at(t,r)}static equals(t,r){return we(t,r)}static lessThan(t,r){return Ne(t,r)}static greaterThan(t,r){return Ae(t,r)}static min(...t){return Hn(...t)}static max(...t){return bt(...t)}static sortAsc(...t){return jt(...t)}static sortDesc(...t){return zt(...t)}},Gn=qn;export{Gn as default};
|
| 8 |
+
//# sourceMappingURL=index.js.map
|
node_modules/@bramus/specificity/dist/index.js.map
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
node_modules/@bramus/specificity/index.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Types & Classes
|
| 2 |
+
export type SpecificityArray = [number, number, number];
|
| 3 |
+
export type SpecificityObject = { a: number; b: number; c: number };
|
| 4 |
+
|
| 5 |
+
export default class Specificity {
|
| 6 |
+
static calculate(selector: string | CSSTreeAST): Array<Specificity>;
|
| 7 |
+
static calculateForAST(selectorAST: CSSTreeAST): Specificity;
|
| 8 |
+
static compare(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): number;
|
| 9 |
+
static equals(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
|
| 10 |
+
static lessThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
|
| 11 |
+
static greaterThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
|
| 12 |
+
static min(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
|
| 13 |
+
static max(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
|
| 14 |
+
static sortAsc(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
|
| 15 |
+
static sortDesc(...specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
|
| 16 |
+
constructor(value: SpecificityObject, selector?: any);
|
| 17 |
+
value: SpecificityObject;
|
| 18 |
+
selector: string | CSSTreeAST;
|
| 19 |
+
set a(arg: number);
|
| 20 |
+
get a(): number;
|
| 21 |
+
set b(arg: number);
|
| 22 |
+
get b(): number;
|
| 23 |
+
set c(arg: number);
|
| 24 |
+
get c(): number;
|
| 25 |
+
selectorString(): string;
|
| 26 |
+
toObject(): SpecificityObject;
|
| 27 |
+
toArray(): SpecificityArray;
|
| 28 |
+
toString(): string;
|
| 29 |
+
toJSON(): {
|
| 30 |
+
selector: string;
|
| 31 |
+
asObject: SpecificityObject;
|
| 32 |
+
asArray: SpecificityArray;
|
| 33 |
+
asString: string;
|
| 34 |
+
};
|
| 35 |
+
isEqualTo(otherSpecificity: SpecificityInstanceOrObject): boolean;
|
| 36 |
+
isGreaterThan(otherSpecificity: SpecificityInstanceOrObject): boolean;
|
| 37 |
+
isLessThan(otherSpecificity: SpecificityInstanceOrObject): boolean;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
type SpecificityInstanceOrObject = Specificity | SpecificityObject;
|
| 41 |
+
type CSSTreeAST = Object; // @TODO: Define shape
|
| 42 |
+
|
| 43 |
+
// CORE
|
| 44 |
+
export function calculate(selector: string | CSSTreeAST): Array<Specificity>;
|
| 45 |
+
export function calculateForAST(selectorAST: CSSTreeAST): Specificity;
|
| 46 |
+
|
| 47 |
+
// UTIL: COMPARE
|
| 48 |
+
export function equals(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
|
| 49 |
+
export function greaterThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
|
| 50 |
+
export function lessThan(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): boolean;
|
| 51 |
+
export function compare(s1: SpecificityInstanceOrObject, s2: SpecificityInstanceOrObject): number;
|
| 52 |
+
|
| 53 |
+
// UTIL: FILTER
|
| 54 |
+
export function min(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
|
| 55 |
+
export function max(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject;
|
| 56 |
+
|
| 57 |
+
// UTIL: SORT
|
| 58 |
+
export function sortAsc(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject[];
|
| 59 |
+
export function sortDesc(specificities: SpecificityInstanceOrObject[]): SpecificityInstanceOrObject[];
|
node_modules/@bramus/specificity/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@bramus/specificity",
|
| 3 |
+
"version": "2.4.2",
|
| 4 |
+
"description": "Calculate specificity of a CSS Selector",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"main": "./dist/index.cjs",
|
| 7 |
+
"module": "./dist/index.js",
|
| 8 |
+
"exports": {
|
| 9 |
+
".": {
|
| 10 |
+
"browser": "./dist/index.js",
|
| 11 |
+
"import": "./dist/index.js",
|
| 12 |
+
"require": "./dist/index.cjs"
|
| 13 |
+
},
|
| 14 |
+
"./core": {
|
| 15 |
+
"import": "./src/core/index.js"
|
| 16 |
+
},
|
| 17 |
+
"./util": {
|
| 18 |
+
"import": "./src/util/index.js"
|
| 19 |
+
},
|
| 20 |
+
"./compare": {
|
| 21 |
+
"import": "./src/util/compare.js"
|
| 22 |
+
},
|
| 23 |
+
"./filter": {
|
| 24 |
+
"import": "./src/util/filter.js"
|
| 25 |
+
},
|
| 26 |
+
"./sort": {
|
| 27 |
+
"import": "./src/util/sort.js"
|
| 28 |
+
}
|
| 29 |
+
},
|
| 30 |
+
"unpkg": "./dist/index.js",
|
| 31 |
+
"jsdelivr": "./dist/index.js",
|
| 32 |
+
"files": [
|
| 33 |
+
"bin",
|
| 34 |
+
"src",
|
| 35 |
+
"dist",
|
| 36 |
+
"index.d.ts"
|
| 37 |
+
],
|
| 38 |
+
"types": "./index.d.ts",
|
| 39 |
+
"bin": {
|
| 40 |
+
"specificity": "./bin/cli.js"
|
| 41 |
+
},
|
| 42 |
+
"scripts": {
|
| 43 |
+
"build-esm": "esbuild --bundle ./src/index.js --outfile=./dist/index.js --format=esm --sourcemap --minify",
|
| 44 |
+
"build-cjs": "esbuild --bundle ./src/index.js --outfile=./dist/index.cjs --format=cjs --sourcemap --minify",
|
| 45 |
+
"lint": "prettier --check '{src,test}/**/*.{ts,tsx,js,jsx}'",
|
| 46 |
+
"format": "prettier --write '{src,test}/**/*.{ts,tsx,js,jsx}'",
|
| 47 |
+
"build": "npm run build-esm && npm run build-cjs",
|
| 48 |
+
"prepack": "npm run prevent-dirty-tree && npm run test",
|
| 49 |
+
"prepublish": "npm run build",
|
| 50 |
+
"pretest": "npm run build",
|
| 51 |
+
"test": "mocha",
|
| 52 |
+
"prebenchmark": "npm run build",
|
| 53 |
+
"benchmark": "node ./benchmark/bench.cjs",
|
| 54 |
+
"beta-version-patch": "npm version $(semver $npm_package_version -i prerelease --preid beta)",
|
| 55 |
+
"beta-version-minor": "npm version $(semver $npm_package_version -i preminor --preid beta)",
|
| 56 |
+
"beta-version-major": "npm version $(semver $npm_package_version -i premajor --preid beta)",
|
| 57 |
+
"rc-version": "npm version $(semver $npm_package_version -i prerelease --preid rc)",
|
| 58 |
+
"final-release": "npm version $(semver $npm_package_version -i)",
|
| 59 |
+
"preversion": "npm run prevent-dirty-tree && npm run test",
|
| 60 |
+
"prevent-dirty-tree": "exit $(git status --porcelain | wc -l)"
|
| 61 |
+
},
|
| 62 |
+
"repository": {
|
| 63 |
+
"type": "git",
|
| 64 |
+
"url": "git+https://github.com/bramus/specificity.git"
|
| 65 |
+
},
|
| 66 |
+
"keywords": [
|
| 67 |
+
"css",
|
| 68 |
+
"specificity"
|
| 69 |
+
],
|
| 70 |
+
"author": {
|
| 71 |
+
"name": "Bramus Van Damme",
|
| 72 |
+
"email": "bramus@bram.us",
|
| 73 |
+
"twitter": "@bramus",
|
| 74 |
+
"web": "https://www.bram.us/"
|
| 75 |
+
},
|
| 76 |
+
"license": "MIT",
|
| 77 |
+
"bugs": {
|
| 78 |
+
"url": "https://github.com/bramus/specificity/issues"
|
| 79 |
+
},
|
| 80 |
+
"homepage": "https://github.com/bramus/specificity#readme",
|
| 81 |
+
"devDependencies": {
|
| 82 |
+
"benchmark": "^2.1.4",
|
| 83 |
+
"esbuild": "^0.25.0",
|
| 84 |
+
"microtime": "^3.1.1",
|
| 85 |
+
"mocha": "^11.1.0",
|
| 86 |
+
"prettier": "^3.5.1",
|
| 87 |
+
"semver": "^7.7.1"
|
| 88 |
+
},
|
| 89 |
+
"dependencies": {
|
| 90 |
+
"css-tree": "^3.0.0"
|
| 91 |
+
}
|
| 92 |
+
}
|
node_modules/@bramus/specificity/src/core/calculate.js
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import parse from 'css-tree/selector-parser';
|
| 2 |
+
import Specificity from '../index.js';
|
| 3 |
+
import { max } from './../util/index.js';
|
| 4 |
+
|
| 5 |
+
/** @param {import('css-tree').Selector} selectorAST */
|
| 6 |
+
const calculateForAST = (selectorAST) => {
|
| 7 |
+
// Quit while you're ahead
|
| 8 |
+
if (!selectorAST || selectorAST.type !== 'Selector') {
|
| 9 |
+
throw new TypeError(`Passed in source is not a Selector AST`);
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
// https://www.w3.org/TR/selectors-4/#specificity-rules
|
| 13 |
+
let a = 0; /* ID Selectors */
|
| 14 |
+
let b = 0; /* Class selectors, Attributes selectors, and Pseudo-classes */
|
| 15 |
+
let c = 0; /* Type selectors and Pseudo-elements */
|
| 16 |
+
|
| 17 |
+
selectorAST.children.forEach((child) => {
|
| 18 |
+
switch (child.type) {
|
| 19 |
+
case 'IdSelector':
|
| 20 |
+
a += 1;
|
| 21 |
+
break;
|
| 22 |
+
|
| 23 |
+
case 'AttributeSelector':
|
| 24 |
+
case 'ClassSelector':
|
| 25 |
+
b += 1;
|
| 26 |
+
break;
|
| 27 |
+
|
| 28 |
+
case 'PseudoClassSelector':
|
| 29 |
+
switch (child.name.toLowerCase()) {
|
| 30 |
+
// “The specificity of a :where() pseudo-class is replaced by zero.”
|
| 31 |
+
case 'where':
|
| 32 |
+
// Noop :)
|
| 33 |
+
break;
|
| 34 |
+
|
| 35 |
+
case '-webkit-any':
|
| 36 |
+
case 'any':
|
| 37 |
+
if (child.children?.first) {
|
| 38 |
+
b += 1;
|
| 39 |
+
}
|
| 40 |
+
break;
|
| 41 |
+
|
| 42 |
+
// “The specificity of an :is(), :not(), or :has() pseudo-class is replaced by the specificity of the most specific complex selector in its selector list argument.“
|
| 43 |
+
case '-moz-any':
|
| 44 |
+
case 'is':
|
| 45 |
+
case 'matches':
|
| 46 |
+
case 'not':
|
| 47 |
+
case 'has':
|
| 48 |
+
if (child.children?.first) {
|
| 49 |
+
// Calculate Specificity from nested SelectorList
|
| 50 |
+
const max1 = max(...calculate(child.children.first));
|
| 51 |
+
|
| 52 |
+
// Adjust orig specificity
|
| 53 |
+
a += max1.a;
|
| 54 |
+
b += max1.b;
|
| 55 |
+
c += max1.c;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
break;
|
| 59 |
+
|
| 60 |
+
// “The specificity of an :nth-child() or :nth-last-child() selector is the specificity of the pseudo class itself (counting as one pseudo-class selector) plus the specificity of the most specific complex selector in its selector list argument”
|
| 61 |
+
case 'nth-child':
|
| 62 |
+
case 'nth-last-child':
|
| 63 |
+
b += 1;
|
| 64 |
+
|
| 65 |
+
if (child.children?.first?.selector) {
|
| 66 |
+
// Calculate Specificity from SelectorList
|
| 67 |
+
const max2 = max(...calculate(child.children.first.selector));
|
| 68 |
+
|
| 69 |
+
// Adjust orig specificity
|
| 70 |
+
a += max2.a;
|
| 71 |
+
b += max2.b;
|
| 72 |
+
c += max2.c;
|
| 73 |
+
}
|
| 74 |
+
break;
|
| 75 |
+
|
| 76 |
+
// “The specificity of :host is that of a pseudo-class. The specificity of :host() is that of a pseudo-class, plus the specificity of its argument.”
|
| 77 |
+
// “The specificity of :host-context() is that of a pseudo-class, plus the specificity of its argument.”
|
| 78 |
+
case 'host-context':
|
| 79 |
+
case 'host':
|
| 80 |
+
b += 1;
|
| 81 |
+
|
| 82 |
+
if (child.children?.first?.children) {
|
| 83 |
+
// Workaround to a css-tree bug in which it allows complex selectors instead of only compound selectors
|
| 84 |
+
// We work around it by filtering out any Combinator and successive Selectors
|
| 85 |
+
const childAST = { type: 'Selector', children: [] };
|
| 86 |
+
let foundCombinator = false;
|
| 87 |
+
child.children.first.children.forEach((entry) => {
|
| 88 |
+
if (foundCombinator) return false;
|
| 89 |
+
if (entry.type === 'Combinator') {
|
| 90 |
+
foundCombinator = true;
|
| 91 |
+
return false;
|
| 92 |
+
}
|
| 93 |
+
childAST.children.push(entry);
|
| 94 |
+
});
|
| 95 |
+
|
| 96 |
+
// Calculate Specificity from Selector
|
| 97 |
+
const childSpecificity = calculate(childAST)[0];
|
| 98 |
+
|
| 99 |
+
// Adjust orig specificity
|
| 100 |
+
a += childSpecificity.a;
|
| 101 |
+
b += childSpecificity.b;
|
| 102 |
+
c += childSpecificity.c;
|
| 103 |
+
}
|
| 104 |
+
break;
|
| 105 |
+
|
| 106 |
+
// Improper use of Pseudo-Class Selectors instead of a Pseudo-Element
|
| 107 |
+
// @ref https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements#index
|
| 108 |
+
case 'after':
|
| 109 |
+
case 'before':
|
| 110 |
+
case 'first-letter':
|
| 111 |
+
case 'first-line':
|
| 112 |
+
c += 1;
|
| 113 |
+
break;
|
| 114 |
+
|
| 115 |
+
default:
|
| 116 |
+
b += 1;
|
| 117 |
+
break;
|
| 118 |
+
}
|
| 119 |
+
break;
|
| 120 |
+
|
| 121 |
+
case 'PseudoElementSelector':
|
| 122 |
+
switch (child.name) {
|
| 123 |
+
// “The specificity of ::slotted() is that of a pseudo-element, plus the specificity of its argument.”
|
| 124 |
+
case 'slotted':
|
| 125 |
+
c += 1;
|
| 126 |
+
|
| 127 |
+
if (child.children?.first?.children) {
|
| 128 |
+
// Workaround to a css-tree bug in which it allows complex selectors instead of only compound selectors
|
| 129 |
+
// We work around it by filtering out any Combinator and successive Selectors
|
| 130 |
+
const childAST = { type: 'Selector', children: [] };
|
| 131 |
+
let foundCombinator = false;
|
| 132 |
+
child.children.first.children.forEach((entry) => {
|
| 133 |
+
if (foundCombinator) return false;
|
| 134 |
+
if (entry.type === 'Combinator') {
|
| 135 |
+
foundCombinator = true;
|
| 136 |
+
return false;
|
| 137 |
+
}
|
| 138 |
+
childAST.children.push(entry);
|
| 139 |
+
});
|
| 140 |
+
|
| 141 |
+
// Calculate Specificity from Selector
|
| 142 |
+
const childSpecificity = calculate(childAST)[0];
|
| 143 |
+
|
| 144 |
+
// Adjust orig specificity
|
| 145 |
+
a += childSpecificity.a;
|
| 146 |
+
b += childSpecificity.b;
|
| 147 |
+
c += childSpecificity.c;
|
| 148 |
+
}
|
| 149 |
+
break;
|
| 150 |
+
|
| 151 |
+
case 'view-transition-group':
|
| 152 |
+
case 'view-transition-image-pair':
|
| 153 |
+
case 'view-transition-old':
|
| 154 |
+
case 'view-transition-new':
|
| 155 |
+
// The specificity of a view-transition selector with a * argument is zero.
|
| 156 |
+
if (child.children?.first?.value === '*') {
|
| 157 |
+
break;
|
| 158 |
+
}
|
| 159 |
+
// The specificity of a view-transition selector with an argument is the same
|
| 160 |
+
// as for other pseudo - elements, and is equivalent to a type selector.
|
| 161 |
+
c += 1;
|
| 162 |
+
break;
|
| 163 |
+
|
| 164 |
+
default:
|
| 165 |
+
c += 1;
|
| 166 |
+
break;
|
| 167 |
+
}
|
| 168 |
+
break;
|
| 169 |
+
|
| 170 |
+
case 'TypeSelector':
|
| 171 |
+
// Omit namespace
|
| 172 |
+
let typeSelector = child.name;
|
| 173 |
+
if (typeSelector.includes('|')) {
|
| 174 |
+
typeSelector = typeSelector.split('|')[1];
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
// “Ignore the universal selector”
|
| 178 |
+
if (typeSelector !== '*') {
|
| 179 |
+
c += 1;
|
| 180 |
+
}
|
| 181 |
+
break;
|
| 182 |
+
|
| 183 |
+
default:
|
| 184 |
+
// NOOP
|
| 185 |
+
break;
|
| 186 |
+
}
|
| 187 |
+
});
|
| 188 |
+
|
| 189 |
+
return new Specificity({ a, b, c }, selectorAST);
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
const convertToAST = (source) => {
|
| 193 |
+
// The passed in argument was a String.
|
| 194 |
+
// ~> Let's try and parse to an AST
|
| 195 |
+
if (typeof source === 'string' || source instanceof String) {
|
| 196 |
+
try {
|
| 197 |
+
return parse(source, {
|
| 198 |
+
context: 'selectorList',
|
| 199 |
+
});
|
| 200 |
+
} catch (e) {
|
| 201 |
+
throw new TypeError(`Could not convert passed in source '${source}' to SelectorList: ${e.message}`);
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
// The passed in argument was an Object.
|
| 206 |
+
// ~> Let's verify if it's a AST of the type Selector or SelectorList
|
| 207 |
+
if (source instanceof Object) {
|
| 208 |
+
if (source.type && ['Selector', 'SelectorList'].includes(source.type)) {
|
| 209 |
+
return source;
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
// Manually parsing subtree when the child is of the type Raw, most likely due to https://github.com/csstree/csstree/issues/151
|
| 213 |
+
if (source.type && source.type === 'Raw') {
|
| 214 |
+
try {
|
| 215 |
+
return parse(source.value, {
|
| 216 |
+
context: 'selectorList',
|
| 217 |
+
});
|
| 218 |
+
} catch (e) {
|
| 219 |
+
throw new TypeError(`Could not convert passed in source to SelectorList: ${e.message}`);
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
throw new TypeError(`Passed in source is an Object but no AST / AST of the type Selector or SelectorList`);
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
throw new TypeError(`Passed in source is not a String nor an Object. I don't know what to do with it.`);
|
| 227 |
+
};
|
| 228 |
+
|
| 229 |
+
/**
|
| 230 |
+
* @param {string} selector
|
| 231 |
+
* @returns {Specificity[]}
|
| 232 |
+
*/
|
| 233 |
+
const calculate = (selector) => {
|
| 234 |
+
// Quit while you're ahead
|
| 235 |
+
if (!selector) {
|
| 236 |
+
return [];
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
// Make sure we have a SelectorList AST
|
| 240 |
+
// If not, an exception will be thrown
|
| 241 |
+
const ast = convertToAST(selector);
|
| 242 |
+
|
| 243 |
+
// Selector?
|
| 244 |
+
if (ast.type === 'Selector') {
|
| 245 |
+
return [calculateForAST(selector)];
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// SelectorList?
|
| 249 |
+
// ~> Calculate Specificity for each contained Selector
|
| 250 |
+
if (ast.type === 'SelectorList') {
|
| 251 |
+
const specificities = [];
|
| 252 |
+
ast.children.forEach((childAST) => {
|
| 253 |
+
const specificity = calculateForAST(childAST);
|
| 254 |
+
specificities.push(specificity);
|
| 255 |
+
});
|
| 256 |
+
return specificities;
|
| 257 |
+
}
|
| 258 |
+
};
|
| 259 |
+
|
| 260 |
+
export { calculate, calculateForAST };
|
node_modules/@bramus/specificity/src/core/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export { calculate, calculateForAST } from './calculate.js';
|
node_modules/@bramus/specificity/src/index.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import generate from 'css-tree/generator';
|
| 2 |
+
|
| 3 |
+
import { calculate, calculateForAST } from './core/index.js';
|
| 4 |
+
import { compare, equals, greaterThan, lessThan } from './util/compare.js';
|
| 5 |
+
import { min, max } from './util/filter.js';
|
| 6 |
+
import { sortAsc, sortDesc } from './util/sort.js';
|
| 7 |
+
|
| 8 |
+
class NotAllowedError extends Error {
|
| 9 |
+
constructor() {
|
| 10 |
+
super('Manipulating a Specificity instance is not allowed. Instead, create a new Specificity()');
|
| 11 |
+
}
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
class Specificity {
|
| 15 |
+
constructor(value, selector = null) {
|
| 16 |
+
this.value = value;
|
| 17 |
+
this.selector = selector;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
get a() {
|
| 21 |
+
return this.value.a;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
set a(val) {
|
| 25 |
+
throw new NotAllowedError();
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
get b() {
|
| 29 |
+
return this.value.b;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
set b(val) {
|
| 33 |
+
throw new NotAllowedError();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
get c() {
|
| 37 |
+
return this.value.c;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
set c(val) {
|
| 41 |
+
throw new NotAllowedError();
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
selectorString() {
|
| 45 |
+
// this.selector already is a String
|
| 46 |
+
if (typeof this.selector === 'string' || this.selector instanceof String) {
|
| 47 |
+
return this.selector;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
// this.selector is a Selector as parsed by CSSTree
|
| 51 |
+
if (this.selector instanceof Object) {
|
| 52 |
+
if (this.selector.type === 'Selector') {
|
| 53 |
+
return generate(this.selector);
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// this.selector is something else …
|
| 58 |
+
return '';
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
toObject() {
|
| 62 |
+
return this.value;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
toArray() {
|
| 66 |
+
return [this.value.a, this.value.b, this.value.c];
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
toString() {
|
| 70 |
+
return `(${this.value.a},${this.value.b},${this.value.c})`;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
toJSON() {
|
| 74 |
+
return {
|
| 75 |
+
selector: this.selectorString(),
|
| 76 |
+
asObject: this.toObject(),
|
| 77 |
+
asArray: this.toArray(),
|
| 78 |
+
asString: this.toString(),
|
| 79 |
+
};
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
isEqualTo(otherSpecificity) {
|
| 83 |
+
return equals(this, otherSpecificity);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
isGreaterThan(otherSpecificity) {
|
| 87 |
+
return greaterThan(this, otherSpecificity);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
isLessThan(otherSpecificity) {
|
| 91 |
+
return lessThan(this, otherSpecificity);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
static calculate(selector) {
|
| 95 |
+
return calculate(selector);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
static calculateForAST(selector) {
|
| 99 |
+
return calculateForAST(selector);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
static compare(s1, s2) {
|
| 103 |
+
return compare(s1, s2);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
static equals(s1, s2) {
|
| 107 |
+
return equals(s1, s2);
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
static lessThan(s1, s2) {
|
| 111 |
+
return lessThan(s1, s2);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
static greaterThan(s1, s2) {
|
| 115 |
+
return greaterThan(s1, s2);
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
static min(...specificities) {
|
| 119 |
+
return min(...specificities);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
static max(...specificities) {
|
| 123 |
+
return max(...specificities);
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
static sortAsc(...specificities) {
|
| 127 |
+
return sortAsc(...specificities);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
static sortDesc(...specificities) {
|
| 131 |
+
return sortDesc(...specificities);
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
|
| 135 |
+
export default Specificity;
|
node_modules/@bramus/specificity/src/util/compare.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const compare = (s1, s2) => {
|
| 2 |
+
if (s1.a === s2.a) {
|
| 3 |
+
if (s1.b === s2.b) {
|
| 4 |
+
return s1.c - s2.c;
|
| 5 |
+
}
|
| 6 |
+
return s1.b - s2.b;
|
| 7 |
+
}
|
| 8 |
+
return s1.a - s2.a;
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
const equals = (s1, s2) => {
|
| 12 |
+
return compare(s1, s2) === 0;
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
const greaterThan = (s1, s2) => {
|
| 16 |
+
return compare(s1, s2) > 0;
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
const lessThan = (s1, s2) => {
|
| 20 |
+
return compare(s1, s2) < 0;
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
export { compare, equals, greaterThan, lessThan };
|
node_modules/@bramus/specificity/src/util/filter.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { sortAsc, sortDesc } from './sort.js';
|
| 2 |
+
|
| 3 |
+
const max = (...specificities) => {
|
| 4 |
+
const sorted = sortDesc(...specificities);
|
| 5 |
+
return sorted[0];
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
const min = (...specificities) => {
|
| 9 |
+
const sorted = sortAsc(...specificities);
|
| 10 |
+
return sorted[0];
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
export { max, min };
|
node_modules/@bramus/specificity/src/util/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './compare.js';
|
| 2 |
+
export * from './sort.js';
|
| 3 |
+
export * from './filter.js';
|
node_modules/@bramus/specificity/src/util/sort.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { compare } from './compare.js';
|
| 2 |
+
|
| 3 |
+
const sort = (specificities, order = 'ASC') => {
|
| 4 |
+
const sorted = specificities.sort(compare);
|
| 5 |
+
|
| 6 |
+
if (order === 'DESC') {
|
| 7 |
+
return sorted.reverse();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
return sorted;
|
| 11 |
+
};
|
| 12 |
+
|
| 13 |
+
const sortAsc = (...specificities) => {
|
| 14 |
+
return sort(specificities, 'ASC');
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
const sortDesc = (...specificities) => {
|
| 18 |
+
return sort(specificities, 'DESC');
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
export { sortAsc, sortDesc };
|
node_modules/@csstools/color-helpers/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changes to Color Helpers
|
| 2 |
+
|
| 3 |
+
### 6.0.2
|
| 4 |
+
|
| 5 |
+
_February 21, 2026_
|
| 6 |
+
|
| 7 |
+
- Updated: gamut mapping algorithm
|
| 8 |
+
|
| 9 |
+
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers/CHANGELOG.md)
|
node_modules/@csstools/color-helpers/LICENSE.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT No Attribution (MIT-0)
|
| 2 |
+
|
| 3 |
+
Copyright © CSSTools Contributors
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
| 6 |
+
this software and associated documentation files (the “Software”), to deal in
|
| 7 |
+
the Software without restriction, including without limitation the rights to
|
| 8 |
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
| 9 |
+
of the Software, and to permit persons to whom the Software is furnished to do
|
| 10 |
+
so.
|
| 11 |
+
|
| 12 |
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 13 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 14 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 15 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 16 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 17 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 18 |
+
SOFTWARE.
|
node_modules/@csstools/color-helpers/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Color Helpers <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
|
| 2 |
+
|
| 3 |
+
[<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/color-helpers.svg" height="20">][npm-url]
|
| 4 |
+
[<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
|
| 5 |
+
[<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
|
| 6 |
+
|
| 7 |
+
## Usage
|
| 8 |
+
|
| 9 |
+
Add [Color Helpers] to your project:
|
| 10 |
+
|
| 11 |
+
```bash
|
| 12 |
+
npm install @csstools/color-helpers --save-dev
|
| 13 |
+
```
|
| 14 |
+
|
| 15 |
+
This package exists to join all the different color functions scattered among the Colors 4 and Colors 5 plugins we maintain such as:
|
| 16 |
+
|
| 17 |
+
* [PostCSS Color Function]
|
| 18 |
+
* [PostCSS Lab Function]
|
| 19 |
+
* [PostCSS OKLab Function]
|
| 20 |
+
|
| 21 |
+
## Copyright
|
| 22 |
+
|
| 23 |
+
This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/tree/main/css-color-4. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 24 |
+
|
| 25 |
+
[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
|
| 26 |
+
[discord]: https://discord.gg/bUadyRwkJS
|
| 27 |
+
[npm-url]: https://www.npmjs.com/package/@csstools/color-helpers
|
| 28 |
+
|
| 29 |
+
[Color Helpers]: https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers
|
| 30 |
+
[PostCSS Color Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function
|
| 31 |
+
[PostCSS Lab Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-lab-functionw
|
| 32 |
+
[PostCSS OKLab Function]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-oklab-function
|
node_modules/@csstools/color-helpers/dist/index.d.ts
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* @param {Color} color [r, g, b]
|
| 3 |
+
* - Red as number 0..1;
|
| 4 |
+
* - Green as number 0..1;
|
| 5 |
+
* - Blue as number 0..1;
|
| 6 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 7 |
+
*/
|
| 8 |
+
export declare function a98_RGB_to_XYZ_D50(x: Color): Color;
|
| 9 |
+
|
| 10 |
+
export declare function clip(color: Color): Color;
|
| 11 |
+
|
| 12 |
+
export declare type Color = [number, number, number];
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* WCAG 2.1 contrast ratio
|
| 16 |
+
*/
|
| 17 |
+
export declare function contrast_ratio_wcag_2_1(color1: Color, color2: Color): number;
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Convert an array of linear-light display-p3 RGB in the range 0.0-1.0
|
| 21 |
+
* to gamma corrected form
|
| 22 |
+
*
|
| 23 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 24 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 25 |
+
*/
|
| 26 |
+
export declare function gam_P3(RGB: Color): Color;
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form
|
| 30 |
+
* Extended transfer function:
|
| 31 |
+
* For negative values, linear portion extends on reflection
|
| 32 |
+
* of axis, then uses reflected pow below that
|
| 33 |
+
*
|
| 34 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 35 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 36 |
+
* @see https://en.wikipedia.org/wiki/SRGB
|
| 37 |
+
*/
|
| 38 |
+
export declare function gam_sRGB(RGB: Color): Color;
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* @param {Color} color [h, s, l]
|
| 42 |
+
* - Hue as degrees 0..360;
|
| 43 |
+
* - Saturation as number 0..100;
|
| 44 |
+
* - Lightness as number 0..100;
|
| 45 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 46 |
+
*/
|
| 47 |
+
export declare function HSL_to_XYZ_D50(x: Color): Color;
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* @param {Color} color [h, w, b]
|
| 51 |
+
* - Hue as degrees 0..360;
|
| 52 |
+
* - Whiteness as number 0..100;
|
| 53 |
+
* - Blackness as number 0..100;
|
| 54 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 55 |
+
*/
|
| 56 |
+
export declare function HWB_to_XYZ_D50(x: Color): Color;
|
| 57 |
+
|
| 58 |
+
export declare function inGamut(x: Color): boolean;
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* @param {Color} color [l, a, b]
|
| 62 |
+
* - Lightness as number 0..100;
|
| 63 |
+
* - a as number -160..160;
|
| 64 |
+
* - b as number -160..160;
|
| 65 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 66 |
+
*/
|
| 67 |
+
export declare function Lab_to_XYZ_D50(x: Color): Color;
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* @param {Color} color [l, c, h]
|
| 71 |
+
* - Lightness as number 0..100;
|
| 72 |
+
* - Chroma as number 0..230;
|
| 73 |
+
* - Hue as degrees 0..360;
|
| 74 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 75 |
+
*/
|
| 76 |
+
export declare function LCH_to_XYZ_D50(x: Color): Color;
|
| 77 |
+
|
| 78 |
+
/**
|
| 79 |
+
* Convert an array of display-p3 RGB values in the range 0.0 - 1.0
|
| 80 |
+
* to linear light (un-companded) form.
|
| 81 |
+
*
|
| 82 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 83 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 84 |
+
*/
|
| 85 |
+
export declare function lin_P3(RGB: Color): Color;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Convert an array of linear-light display-p3 values to CIE XYZ
|
| 89 |
+
* using D65 (no chromatic adaptation)
|
| 90 |
+
*
|
| 91 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 92 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 93 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 94 |
+
*/
|
| 95 |
+
export declare function lin_P3_to_XYZ(rgb: Color): Color;
|
| 96 |
+
|
| 97 |
+
/**
|
| 98 |
+
* @param {Color} color [r, g, b]
|
| 99 |
+
* - Red as number 0..1;
|
| 100 |
+
* - Green as number 0..1;
|
| 101 |
+
* - Blue as number 0..1;
|
| 102 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 103 |
+
*/
|
| 104 |
+
export declare function lin_P3_to_XYZ_D50(x: Color): Color;
|
| 105 |
+
|
| 106 |
+
/**
|
| 107 |
+
* Convert an array of of sRGB values where in-gamut values are in the range
|
| 108 |
+
* [0 - 1] to linear light (un-companded) form.
|
| 109 |
+
* Extended transfer function:
|
| 110 |
+
* For negative values, linear portion is extended on reflection of axis,
|
| 111 |
+
* then reflected power function is used.
|
| 112 |
+
*
|
| 113 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 114 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 115 |
+
* @see https://en.wikipedia.org/wiki/SRGB
|
| 116 |
+
*/
|
| 117 |
+
export declare function lin_sRGB(RGB: Color): Color;
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* Convert an array of linear-light sRGB values to CIE XYZ
|
| 121 |
+
* using sRGB's own white, D65 (no chromatic adaptation)
|
| 122 |
+
*
|
| 123 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 124 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 125 |
+
*/
|
| 126 |
+
export declare function lin_sRGB_to_XYZ(rgb: Color): Color;
|
| 127 |
+
|
| 128 |
+
/**
|
| 129 |
+
* @param {Color} color [r, g, b]
|
| 130 |
+
* - Red as number 0..1;
|
| 131 |
+
* - Green as number 0..1;
|
| 132 |
+
* - Blue as number 0..1;
|
| 133 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 134 |
+
*/
|
| 135 |
+
export declare function lin_sRGB_to_XYZ_D50(x: Color): Color;
|
| 136 |
+
|
| 137 |
+
export declare function mapGamut(startOKLCH: Color, toDestination: (x: Color) => Color, fromDestination: (x: Color) => Color): Color;
|
| 138 |
+
|
| 139 |
+
/**
|
| 140 |
+
* @license MIT https://github.com/facelessuser/coloraide/blob/main/LICENSE.md
|
| 141 |
+
*/
|
| 142 |
+
export declare function mapGamutRayTrace(startOKLCH: Color, toLinear: (x: Color) => Color, fromLinear: (x: Color) => Color): Color;
|
| 143 |
+
|
| 144 |
+
export declare const namedColors: Record<string, Color>;
|
| 145 |
+
|
| 146 |
+
/**
|
| 147 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 148 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 149 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
| 150 |
+
*/
|
| 151 |
+
export declare function OKLab_to_OKLCH(OKLab: Color): Color;
|
| 152 |
+
|
| 153 |
+
/**
|
| 154 |
+
* Given OKLab, convert to XYZ relative to D65
|
| 155 |
+
*
|
| 156 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 157 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 158 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
| 159 |
+
*/
|
| 160 |
+
export declare function OKLab_to_XYZ(OKLab: Color): Color;
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* @param {Color} color [l, a, b]
|
| 164 |
+
* - Lightness as number 0..1;
|
| 165 |
+
* - a as number 0..0.5;
|
| 166 |
+
* - b as number 0..0.5;
|
| 167 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 168 |
+
*/
|
| 169 |
+
export declare function OKLab_to_XYZ_D50(x: Color): Color;
|
| 170 |
+
|
| 171 |
+
/**
|
| 172 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 173 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 174 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
| 175 |
+
*/
|
| 176 |
+
export declare function OKLCH_to_OKLab(OKLCH: Color): Color;
|
| 177 |
+
|
| 178 |
+
/**
|
| 179 |
+
* @param {Color} color [l, c, h]
|
| 180 |
+
* - Lightness as number 0..1;
|
| 181 |
+
* - Chroma as number 0..0.5;
|
| 182 |
+
* - Hue as degrees 0..360;
|
| 183 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 184 |
+
*/
|
| 185 |
+
export declare function OKLCH_to_XYZ_D50(x: Color): Color;
|
| 186 |
+
|
| 187 |
+
/**
|
| 188 |
+
* @param {Color} color [r, g, b]
|
| 189 |
+
* - Red as number 0..1;
|
| 190 |
+
* - Green as number 0..1;
|
| 191 |
+
* - Blue as number 0..1;
|
| 192 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 193 |
+
*/
|
| 194 |
+
export declare function P3_to_XYZ_D50(x: Color): Color;
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* @param {Color} color [r, g, b]
|
| 198 |
+
* - Red as number 0..1;
|
| 199 |
+
* - Green as number 0..1;
|
| 200 |
+
* - Blue as number 0..1;
|
| 201 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 202 |
+
*/
|
| 203 |
+
export declare function ProPhoto_RGB_to_XYZ_D50(x: Color): Color;
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* @param {Color} color [r, g, b]
|
| 207 |
+
* - Red as number 0..1;
|
| 208 |
+
* - Green as number 0..1;
|
| 209 |
+
* - Blue as number 0..1;
|
| 210 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 211 |
+
*/
|
| 212 |
+
export declare function rec_2020_to_XYZ_D50(x: Color): Color;
|
| 213 |
+
|
| 214 |
+
/**
|
| 215 |
+
* @param {Color} color [r, g, b]
|
| 216 |
+
* - Red as number 0..1;
|
| 217 |
+
* - Green as number 0..1;
|
| 218 |
+
* - Blue as number 0..1;
|
| 219 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 220 |
+
*/
|
| 221 |
+
export declare function sRGB_to_XYZ_D50(x: Color): Color;
|
| 222 |
+
|
| 223 |
+
/**
|
| 224 |
+
* @param {Color} color [x, y, z]
|
| 225 |
+
* - X as number 0..1;
|
| 226 |
+
* - Y as number 0..1;
|
| 227 |
+
* - Z as number 0..1;
|
| 228 |
+
* @return {Color} a98 sRGB [r, g, b]
|
| 229 |
+
* - Red as number 0..1;
|
| 230 |
+
* - Green as number 0..1;
|
| 231 |
+
* - Blue as number 0..1;
|
| 232 |
+
*/
|
| 233 |
+
export declare function XYZ_D50_to_a98_RGB(x: Color): Color;
|
| 234 |
+
|
| 235 |
+
/**
|
| 236 |
+
* @param {Color} color [x, y, z]
|
| 237 |
+
* - X as number 0..1;
|
| 238 |
+
* - Y as number 0..1;
|
| 239 |
+
* - Z as number 0..1;
|
| 240 |
+
* @return {Color} HSL [r, g, b]
|
| 241 |
+
* - Hue as degrees 0..360;
|
| 242 |
+
* - Saturation as number 0..100;
|
| 243 |
+
* - Lightness as number 0..100;
|
| 244 |
+
*/
|
| 245 |
+
export declare function XYZ_D50_to_HSL(x: Color): Color;
|
| 246 |
+
|
| 247 |
+
/**
|
| 248 |
+
* @param {Color} color [x, y, z]
|
| 249 |
+
* - X as number 0..1;
|
| 250 |
+
* - Y as number 0..1;
|
| 251 |
+
* - Z as number 0..1;
|
| 252 |
+
* @return {Color} HWB [r, g, b]
|
| 253 |
+
* - Hue as degrees 0..360;
|
| 254 |
+
* - Whiteness as number 0..100;
|
| 255 |
+
* - Blackness as number 0..100;
|
| 256 |
+
*/
|
| 257 |
+
export declare function XYZ_D50_to_HWB(x: Color): Color;
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* @param {Color} color [x, y, z]
|
| 261 |
+
* - X as number 0..1;
|
| 262 |
+
* - Y as number 0..1;
|
| 263 |
+
* - Z as number 0..1;
|
| 264 |
+
* @return {Color} Lab [r, g, b]
|
| 265 |
+
* - Lightness as number 0..100;
|
| 266 |
+
* - a as number -160..160;
|
| 267 |
+
* - b as number -160..160;
|
| 268 |
+
*/
|
| 269 |
+
export declare function XYZ_D50_to_Lab(x: Color): Color;
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
* @param {Color} color [x, y, z]
|
| 273 |
+
* - X as number 0..1;
|
| 274 |
+
* - Y as number 0..1;
|
| 275 |
+
* - Z as number 0..1;
|
| 276 |
+
* @return {Color} LCH [r, g, b]
|
| 277 |
+
* - Lightness as number 0..100;
|
| 278 |
+
* - Chroma as number 0..230;
|
| 279 |
+
* - Hue as degrees 0..360;
|
| 280 |
+
*/
|
| 281 |
+
export declare function XYZ_D50_to_LCH(x: Color): Color;
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* @param {Color} color [x, y, z]
|
| 285 |
+
* - X as number 0..1;
|
| 286 |
+
* - Y as number 0..1;
|
| 287 |
+
* - Z as number 0..1;
|
| 288 |
+
* @return {Color} P3 [r, g, b]
|
| 289 |
+
* - R as number 0..1;
|
| 290 |
+
* - G as number 0..1;
|
| 291 |
+
* - B as number 0..1;
|
| 292 |
+
*/
|
| 293 |
+
export declare function XYZ_D50_to_lin_P3(x: Color): Color;
|
| 294 |
+
|
| 295 |
+
/**
|
| 296 |
+
* @param {Color} color [x, y, z]
|
| 297 |
+
* - X as number 0..1;
|
| 298 |
+
* - Y as number 0..1;
|
| 299 |
+
* - Z as number 0..1;
|
| 300 |
+
* @return {Color} linear sRGB [r, g, b]
|
| 301 |
+
* - Red as number 0..1;
|
| 302 |
+
* - Green as number 0..1;
|
| 303 |
+
* - Blue as number 0..1;
|
| 304 |
+
*/
|
| 305 |
+
export declare function XYZ_D50_to_lin_sRGB(x: Color): Color;
|
| 306 |
+
|
| 307 |
+
/**
|
| 308 |
+
* @param {Color} color [x, y, z]
|
| 309 |
+
* - X as number 0..1;
|
| 310 |
+
* - Y as number 0..1;
|
| 311 |
+
* - Z as number 0..1;
|
| 312 |
+
* @return {Color} OKLab [r, g, b]
|
| 313 |
+
* - Lightness as number 0..1;
|
| 314 |
+
* - a as number 0..0.5;
|
| 315 |
+
* - b as number 0..0.5;
|
| 316 |
+
*/
|
| 317 |
+
export declare function XYZ_D50_to_OKLab(x: Color): Color;
|
| 318 |
+
|
| 319 |
+
/**
|
| 320 |
+
* @param {Color} color [x, y, z]
|
| 321 |
+
* - X as number 0..1;
|
| 322 |
+
* - Y as number 0..1;
|
| 323 |
+
* - Z as number 0..1;
|
| 324 |
+
* @return {Color} OKLCH [r, g, b]
|
| 325 |
+
* - Lightness as number 0..1;
|
| 326 |
+
* - Chroma as number 0..0.5;
|
| 327 |
+
* - Hue as degrees 0..360;
|
| 328 |
+
*/
|
| 329 |
+
export declare function XYZ_D50_to_OKLCH(x: Color): Color;
|
| 330 |
+
|
| 331 |
+
/**
|
| 332 |
+
* @param {Color} color [x, y, z]
|
| 333 |
+
* - X as number 0..1;
|
| 334 |
+
* - Y as number 0..1;
|
| 335 |
+
* - Z as number 0..1;
|
| 336 |
+
* @return {Color} P3 [r, g, b]
|
| 337 |
+
* - R as number 0..1;
|
| 338 |
+
* - G as number 0..1;
|
| 339 |
+
* - B as number 0..1;
|
| 340 |
+
*/
|
| 341 |
+
export declare function XYZ_D50_to_P3(x: Color): Color;
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
* @param {Color} color [x, y, z]
|
| 345 |
+
* - X as number 0..1;
|
| 346 |
+
* - Y as number 0..1;
|
| 347 |
+
* - Z as number 0..1;
|
| 348 |
+
* @return {Color} ProPhoto [r, g, b]
|
| 349 |
+
* - Red as number 0..1;
|
| 350 |
+
* - Green as number 0..1;
|
| 351 |
+
* - Blue as number 0..1;
|
| 352 |
+
*/
|
| 353 |
+
export declare function XYZ_D50_to_ProPhoto(x: Color): Color;
|
| 354 |
+
|
| 355 |
+
/**
|
| 356 |
+
* @param {Color} color [x, y, z]
|
| 357 |
+
* - X as number 0..1;
|
| 358 |
+
* - Y as number 0..1;
|
| 359 |
+
* - Z as number 0..1;
|
| 360 |
+
* @return {Color} rec 2020 [r, g, b]
|
| 361 |
+
* - Red as number 0..1;
|
| 362 |
+
* - Green as number 0..1;
|
| 363 |
+
* - Blue as number 0..1;
|
| 364 |
+
*/
|
| 365 |
+
export declare function XYZ_D50_to_rec_2020(x: Color): Color;
|
| 366 |
+
|
| 367 |
+
/**
|
| 368 |
+
* @param {Color} color [x, y, z]
|
| 369 |
+
* - X as number 0..1;
|
| 370 |
+
* - Y as number 0..1;
|
| 371 |
+
* - Z as number 0..1;
|
| 372 |
+
* @return {Color} sRGB [r, g, b]
|
| 373 |
+
* - Red as number 0..1;
|
| 374 |
+
* - Green as number 0..1;
|
| 375 |
+
* - Blue as number 0..1;
|
| 376 |
+
*/
|
| 377 |
+
export declare function XYZ_D50_to_sRGB(x: Color): Color;
|
| 378 |
+
|
| 379 |
+
/**
|
| 380 |
+
* @param {Color} color [x, y, z]
|
| 381 |
+
* - X as number 0..1;
|
| 382 |
+
* - Y as number 0..1;
|
| 383 |
+
* - Z as number 0..1;
|
| 384 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 385 |
+
*/
|
| 386 |
+
export declare function XYZ_D50_to_XYZ_D50(x: Color): Color;
|
| 387 |
+
|
| 388 |
+
/**
|
| 389 |
+
* @param {Color} color [x, y, z]
|
| 390 |
+
* - X as number 0..1;
|
| 391 |
+
* - Y as number 0..1;
|
| 392 |
+
* - Z as number 0..1;
|
| 393 |
+
* @return {Color} D65 XYZ [x, y, z]
|
| 394 |
+
*/
|
| 395 |
+
export declare function XYZ_D50_to_XYZ_D65(x: Color): Color;
|
| 396 |
+
|
| 397 |
+
/**
|
| 398 |
+
* @param {Color} color [x, y, z]
|
| 399 |
+
* - X as number 0..1;
|
| 400 |
+
* - Y as number 0..1;
|
| 401 |
+
* - Z as number 0..1;
|
| 402 |
+
* @return {Color} D50 XYZ [x, y, z]
|
| 403 |
+
*/
|
| 404 |
+
export declare function XYZ_D65_to_XYZ_D50(x: Color): Color;
|
| 405 |
+
|
| 406 |
+
/**
|
| 407 |
+
* Convert XYZ to linear-light P3
|
| 408 |
+
*
|
| 409 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 410 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 411 |
+
*/
|
| 412 |
+
export declare function XYZ_to_lin_P3(XYZ: Color): Color;
|
| 413 |
+
|
| 414 |
+
/**
|
| 415 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 416 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 417 |
+
*/
|
| 418 |
+
export declare function XYZ_to_lin_sRGB(XYZ: Color): Color;
|
| 419 |
+
|
| 420 |
+
/**
|
| 421 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 422 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 423 |
+
*
|
| 424 |
+
* XYZ <-> LMS matrices recalculated for consistent reference white
|
| 425 |
+
* @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
|
| 426 |
+
*/
|
| 427 |
+
export declare function XYZ_to_OKLab(XYZ: Color): Color;
|
| 428 |
+
|
| 429 |
+
export { }
|
node_modules/@csstools/color-helpers/dist/index.mjs
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function multiplyMatrices(t,n){return[t[0]*n[0]+t[1]*n[1]+t[2]*n[2],t[3]*n[0]+t[4]*n[1]+t[5]*n[2],t[6]*n[0]+t[7]*n[1]+t[8]*n[2]]}const t=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
|
| 2 |
+
/**
|
| 3 |
+
* Bradford chromatic adaptation from D50 to D65
|
| 4 |
+
*
|
| 5 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 6 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 7 |
+
*/function D50_to_D65(n){return multiplyMatrices(t,n)}const n=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
|
| 8 |
+
/**
|
| 9 |
+
* Bradford chromatic adaptation from D65 to D50
|
| 10 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 11 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 12 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
|
| 13 |
+
*/function D65_to_D50(t){return multiplyMatrices(n,t)}
|
| 14 |
+
/**
|
| 15 |
+
* @param {number} hue - Hue as degrees 0..360
|
| 16 |
+
* @param {number} sat - Saturation as percentage 0..100
|
| 17 |
+
* @param {number} light - Lightness as percentage 0..100
|
| 18 |
+
* @return {number[]} Array of sRGB components; in-gamut colors in range [0..1]
|
| 19 |
+
*
|
| 20 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 21 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 22 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js
|
| 23 |
+
*/function HSL_to_sRGB(t){let n=t[0]%360;const _=t[1]/100,o=t[2]/100;return n<0&&(n+=360),[HSL_to_sRGB_channel(0,n,_,o),HSL_to_sRGB_channel(8,n,_,o),HSL_to_sRGB_channel(4,n,_,o)]}function HSL_to_sRGB_channel(t,n,_,o){const e=(t+n/30)%12;return o-_*Math.min(o,1-o)*Math.max(-1,Math.min(e-3,9-e,1))}
|
| 24 |
+
/**
|
| 25 |
+
* @param {number} hue - Hue as degrees 0..360
|
| 26 |
+
* @param {number} white - Whiteness as percentage 0..100
|
| 27 |
+
* @param {number} black - Blackness as percentage 0..100
|
| 28 |
+
* @return {number[]} Array of RGB components 0..1
|
| 29 |
+
*
|
| 30 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 31 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 32 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js
|
| 33 |
+
*/function HWB_to_sRGB(t){const n=t[0],_=t[1]/100,o=t[2]/100;if(_+o>=1){const t=_/(_+o);return[t,t,t]}const e=HSL_to_sRGB([n,100,50]),a=1-_-o;return[e[0]*a+_,e[1]*a+_,e[2]*a+_]}
|
| 34 |
+
/**
|
| 35 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 36 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 37 |
+
*/function LCH_to_Lab(t){const n=t[2]*Math.PI/180;return[t[0],t[1]*Math.cos(n),t[1]*Math.sin(n)]}
|
| 38 |
+
/**
|
| 39 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 40 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 41 |
+
*/function Lab_to_LCH(t){const n=Math.sqrt(Math.pow(t[1],2)+Math.pow(t[2],2));let _=180*Math.atan2(t[2],t[1])/Math.PI;return _<0&&(_+=360),n<=.0015&&(_=NaN),[t[0],n,_]}const _=[.3457/.3585,1,.2958/.3585];
|
| 42 |
+
/**
|
| 43 |
+
* Convert Lab to D50-adapted XYZ
|
| 44 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 45 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 46 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 47 |
+
*/function Lab_to_XYZ(t){const n=24389/27,o=216/24389,e=(t[0]+16)/116,a=t[1]/500+e,r=e-t[2]/200;return[(Math.pow(a,3)>o?Math.pow(a,3):(116*a-16)/n)*_[0],(t[0]>8?Math.pow((t[0]+16)/116,3):t[0]/n)*_[1],(Math.pow(r,3)>o?Math.pow(r,3):(116*r-16)/n)*_[2]]}
|
| 48 |
+
/**
|
| 49 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 50 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 51 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
| 52 |
+
*/function OKLCH_to_OKLab(t){const n=t[2]*Math.PI/180;return[t[0],t[1]*Math.cos(n),t[1]*Math.sin(n)]}
|
| 53 |
+
/**
|
| 54 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 55 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 56 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
| 57 |
+
*/function OKLab_to_OKLCH(t){const n=Math.sqrt(t[1]**2+t[2]**2);let _=180*Math.atan2(t[2],t[1])/Math.PI;return _<0&&(_+=360),n<=4e-6&&(_=NaN),[t[0],n,_]}const o=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],e=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
|
| 58 |
+
/**
|
| 59 |
+
* Given OKLab, convert to XYZ relative to D65
|
| 60 |
+
*
|
| 61 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 62 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 63 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
| 64 |
+
*/
|
| 65 |
+
function OKLab_to_XYZ(t){const n=multiplyMatrices(e,t);return multiplyMatrices(o,[n[0]**3,n[1]**3,n[2]**3])}
|
| 66 |
+
/**
|
| 67 |
+
* Assuming XYZ is relative to D50, convert to CIE Lab
|
| 68 |
+
* from CIE standard, which now defines these as a rational fraction
|
| 69 |
+
*
|
| 70 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 71 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 72 |
+
*/function XYZ_to_Lab(t){const n=compute_f(t[0]/_[0]),o=compute_f(t[1]/_[1]);return[116*o-16,500*(n-o),200*(o-compute_f(t[2]/_[2]))]}const a=216/24389,r=24389/27;function compute_f(t){return t>a?Math.cbrt(t):(r*t+16)/116}const l=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],i=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
|
| 73 |
+
/**
|
| 74 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 75 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 76 |
+
*
|
| 77 |
+
* XYZ <-> LMS matrices recalculated for consistent reference white
|
| 78 |
+
* @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
|
| 79 |
+
*/
|
| 80 |
+
function XYZ_to_OKLab(t){const n=multiplyMatrices(l,t);return multiplyMatrices(i,[Math.cbrt(n[0]),Math.cbrt(n[1]),Math.cbrt(n[2])])}const c=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474];
|
| 81 |
+
/**
|
| 82 |
+
* Convert XYZ to linear-light rec2020
|
| 83 |
+
*
|
| 84 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 85 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 86 |
+
*/const u=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415];
|
| 87 |
+
/**
|
| 88 |
+
* Convert XYZ to linear-light P3
|
| 89 |
+
*
|
| 90 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 91 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 92 |
+
*/function XYZ_to_lin_P3(t){return multiplyMatrices(u,t)}const s=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452];
|
| 93 |
+
/**
|
| 94 |
+
* Convert D50 XYZ to linear-light prophoto-rgb
|
| 95 |
+
*
|
| 96 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 97 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 98 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 99 |
+
*/const h=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040];
|
| 100 |
+
/**
|
| 101 |
+
* Convert XYZ to linear-light a98-rgb
|
| 102 |
+
*
|
| 103 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 104 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 105 |
+
*/const m=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667];
|
| 106 |
+
/**
|
| 107 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 108 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 109 |
+
*/function XYZ_to_lin_sRGB(t){return multiplyMatrices(m,t)}
|
| 110 |
+
/**
|
| 111 |
+
* Convert an array of linear-light rec2020 RGB in the range 0.0-1.0
|
| 112 |
+
* to gamma corrected form ITU-R BT.2020-2 p.4
|
| 113 |
+
*
|
| 114 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 115 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 116 |
+
*/function gam_2020_channel(t){const n=t<0?-1:1,_=Math.abs(t);return n*Math.pow(_,1/2.4)}
|
| 117 |
+
/**
|
| 118 |
+
* Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form
|
| 119 |
+
* Extended transfer function:
|
| 120 |
+
* For negative values, linear portion extends on reflection
|
| 121 |
+
* of axis, then uses reflected pow below that
|
| 122 |
+
*
|
| 123 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 124 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 125 |
+
* @see https://en.wikipedia.org/wiki/SRGB
|
| 126 |
+
*/function gam_sRGB(t){return[gam_sRGB_channel(t[0]),gam_sRGB_channel(t[1]),gam_sRGB_channel(t[2])]}function gam_sRGB_channel(t){const n=t<0?-1:1,_=Math.abs(t);return _>.0031308?n*(1.055*Math.pow(_,1/2.4)-.055):12.92*t}
|
| 127 |
+
/**
|
| 128 |
+
* Convert an array of linear-light display-p3 RGB in the range 0.0-1.0
|
| 129 |
+
* to gamma corrected form
|
| 130 |
+
*
|
| 131 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 132 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 133 |
+
*/function gam_P3(t){return gam_sRGB(t)}
|
| 134 |
+
/**
|
| 135 |
+
* Convert an array of linear-light prophoto-rgb in the range 0.0-1.0
|
| 136 |
+
* to gamma corrected form.
|
| 137 |
+
* Transfer curve is gamma 1.8 with a small linear portion.
|
| 138 |
+
*
|
| 139 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 140 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 141 |
+
*/const D=1/512;function gam_ProPhoto_channel(t){const n=t<0?-1:1,_=Math.abs(t);return _>=D?n*Math.pow(_,1/1.8):16*t}
|
| 142 |
+
/**
|
| 143 |
+
* Convert an array of linear-light a98-rgb in the range 0.0-1.0
|
| 144 |
+
* to gamma corrected form. Negative values are also now accepted
|
| 145 |
+
*
|
| 146 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 147 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 148 |
+
*/function gam_a98rgb_channel(t){const n=t<0?-1:1,_=Math.abs(t);return n*Math.pow(_,256/563)}
|
| 149 |
+
/**
|
| 150 |
+
* Convert an array of rec2020 RGB values in the range 0.0 - 1.0
|
| 151 |
+
* to linear light (un-companded) form.
|
| 152 |
+
* ITU-R BT.2020-2 p.4
|
| 153 |
+
*
|
| 154 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 155 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 156 |
+
*/function lin_2020_channel(t){const n=t<0?-1:1,_=Math.abs(t);return n*Math.pow(_,2.4)}const b=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
|
| 157 |
+
/**
|
| 158 |
+
* Convert an array of linear-light rec2020 values to CIE XYZ
|
| 159 |
+
* using D65 (no chromatic adaptation)
|
| 160 |
+
*
|
| 161 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 162 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 163 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 164 |
+
*/
|
| 165 |
+
/**
|
| 166 |
+
* Convert an array of of sRGB values where in-gamut values are in the range
|
| 167 |
+
* [0 - 1] to linear light (un-companded) form.
|
| 168 |
+
* Extended transfer function:
|
| 169 |
+
* For negative values, linear portion is extended on reflection of axis,
|
| 170 |
+
* then reflected power function is used.
|
| 171 |
+
*
|
| 172 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 173 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 174 |
+
* @see https://en.wikipedia.org/wiki/SRGB
|
| 175 |
+
*/
|
| 176 |
+
function lin_sRGB(t){return[lin_sRGB_channel(t[0]),lin_sRGB_channel(t[1]),lin_sRGB_channel(t[2])]}function lin_sRGB_channel(t){const n=t<0?-1:1,_=Math.abs(t);return _<=.04045?t/12.92:n*Math.pow((_+.055)/1.055,2.4)}
|
| 177 |
+
/**
|
| 178 |
+
* Convert an array of display-p3 RGB values in the range 0.0 - 1.0
|
| 179 |
+
* to linear light (un-companded) form.
|
| 180 |
+
*
|
| 181 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 182 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 183 |
+
*/function lin_P3(t){return lin_sRGB(t)}const g=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
|
| 184 |
+
/**
|
| 185 |
+
* Convert an array of linear-light display-p3 values to CIE XYZ
|
| 186 |
+
* using D65 (no chromatic adaptation)
|
| 187 |
+
*
|
| 188 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 189 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 190 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 191 |
+
*/function lin_P3_to_XYZ(t){return multiplyMatrices(g,t)}
|
| 192 |
+
/**
|
| 193 |
+
* Convert an array of prophoto-rgb values where in-gamut Colors are in the
|
| 194 |
+
* range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is
|
| 195 |
+
* gamma 1.8 with a small linear portion. Extended transfer function
|
| 196 |
+
*
|
| 197 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 198 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 199 |
+
*/const X=16/512;function lin_ProPhoto_channel(t){const n=t<0?-1:1,_=Math.abs(t);return _<=X?t/16:n*Math.pow(_,1.8)}const Y=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
|
| 200 |
+
/**
|
| 201 |
+
* Convert an array of linear-light prophoto-rgb values to CIE D50 XYZ.
|
| 202 |
+
* Matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy.
|
| 203 |
+
*
|
| 204 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 205 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 206 |
+
* @see see https://github.com/w3c/csswg-drafts/issues/7675
|
| 207 |
+
*/function lin_a98rgb_channel(t){const n=t<0?-1:1,_=Math.abs(t);return n*Math.pow(_,563/256)}const Z=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835];
|
| 208 |
+
/**
|
| 209 |
+
* Convert an array of linear-light a98-rgb values to CIE XYZ
|
| 210 |
+
* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 211 |
+
* has greater numerical precision than section 4.3.5.3 of
|
| 212 |
+
* https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf
|
| 213 |
+
* but the values below were calculated from first principles
|
| 214 |
+
* from the chromaticity coordinates of R G B W
|
| 215 |
+
*
|
| 216 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 217 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 218 |
+
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
| 219 |
+
* @see https://www.adobe.com/digitalimag/pdfs/AdobeRGB1998.pdf
|
| 220 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/matrixmaker.html
|
| 221 |
+
*/const f=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270];
|
| 222 |
+
/**
|
| 223 |
+
* Convert an array of linear-light sRGB values to CIE XYZ
|
| 224 |
+
* using sRGB's own white, D65 (no chromatic adaptation)
|
| 225 |
+
*
|
| 226 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 227 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 228 |
+
*/function lin_sRGB_to_XYZ(t){return multiplyMatrices(f,t)}
|
| 229 |
+
/**
|
| 230 |
+
* Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL.
|
| 231 |
+
*
|
| 232 |
+
* @param {Color} RGB [r, g, b]
|
| 233 |
+
* - Red component 0..1
|
| 234 |
+
* - Green component 0..1
|
| 235 |
+
* - Blue component 0..1
|
| 236 |
+
* @return {number[]} Array of HSL values: Hue as degrees 0..360, Saturation and Lightness as percentages 0..100
|
| 237 |
+
*
|
| 238 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 239 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 240 |
+
*
|
| 241 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/better-rgbToHsl.js
|
| 242 |
+
*/function sRGB_to_HSL(t){const n=t[0],_=t[1],o=t[2],e=Math.max(n,_,o),a=Math.min(n,_,o),r=(a+e)/2,l=e-a;let i=Number.NaN,c=0;if(0!==Math.round(1e5*l)){const t=Math.round(1e5*r);switch(c=0===t||1e5===t?0:(e-r)/Math.min(r,1-r),e){case n:i=(_-o)/l+(_<o?6:0);break;case _:i=(o-n)/l+2;break;case o:i=(n-_)/l+4}i*=60}c<0&&(i+=180,c=Math.abs(c)),i>=360&&(i-=360);return c<=1e-5&&(i=NaN),[i,100*c,100*r]}function sRGB_to_Hue(t){const n=t[0],_=t[1],o=t[2],e=Math.max(n,_,o),a=Math.min(n,_,o);let r=Number.NaN;const l=e-a;if(0!==l){switch(e){case n:r=(_-o)/l+(_<o?6:0);break;case _:r=(o-n)/l+2;break;case o:r=(n-_)/l+4}r*=60}return r>=360&&(r-=360),r}function sRGB_to_XYZ_D50(t){let n=t;return n=lin_sRGB(n),n=lin_sRGB_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_sRGB(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_lin_sRGB(n),n=gam_sRGB(n),n}function HSL_to_XYZ_D50(t){let n=t;return n=HSL_to_sRGB(n),n=lin_sRGB(n),n=lin_sRGB_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_HSL(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_lin_sRGB(n),n=gam_sRGB(n),n=sRGB_to_HSL(n),n}function HWB_to_XYZ_D50(t){let n=t;return n=HWB_to_sRGB(n),n=lin_sRGB(n),n=lin_sRGB_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_HWB(t){let n=t;n=D50_to_D65(n),n=XYZ_to_lin_sRGB(n);const _=gam_sRGB(n),o=Math.min(_[0],_[1],_[2]),e=1-Math.max(_[0],_[1],_[2]);let a=sRGB_to_Hue(_);return o+e>=.99999&&(a=NaN),[a,100*o,100*e]}function Lab_to_XYZ_D50(t){let n=t;return n=Lab_to_XYZ(n),n}function XYZ_D50_to_Lab(t){let n=t;return n=XYZ_to_Lab(n),n}function LCH_to_XYZ_D50(t){let n=t;return n=LCH_to_Lab(n),n=Lab_to_XYZ(n),n}function XYZ_D50_to_LCH(t){let n=t;return n=XYZ_to_Lab(n),n=Lab_to_LCH(n),n}function OKLab_to_XYZ_D50(t){let n=t;return n=OKLab_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_OKLab(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_OKLab(n),n}function OKLCH_to_XYZ_D50(t){let n=t;return n=OKLCH_to_OKLab(n),n=OKLab_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_OKLCH(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_OKLab(n),n=OKLab_to_OKLCH(n),n}function lin_sRGB_to_XYZ_D50(t){let n=t;return n=lin_sRGB_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_lin_sRGB(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_lin_sRGB(n),n}function a98_RGB_to_XYZ_D50(t){let n=t;
|
| 243 |
+
/**
|
| 244 |
+
* Convert an array of a98-rgb values in the range 0.0 - 1.0
|
| 245 |
+
* to linear light (un-companded) form. Negative values are also now accepted
|
| 246 |
+
*
|
| 247 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 248 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 249 |
+
*/
|
| 250 |
+
var _;return n=[lin_a98rgb_channel((_=n)[0]),lin_a98rgb_channel(_[1]),lin_a98rgb_channel(_[2])],n=multiplyMatrices(Z,n),n=D65_to_D50(n),n}function XYZ_D50_to_a98_RGB(t){let n=t;var _;return n=D50_to_D65(n),n=multiplyMatrices(h,n),n=[gam_a98rgb_channel((_=n)[0]),gam_a98rgb_channel(_[1]),gam_a98rgb_channel(_[2])],n}function P3_to_XYZ_D50(t){let n=t;return n=lin_P3(n),n=lin_P3_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_P3(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_lin_P3(n),n=gam_P3(n),n}function lin_P3_to_XYZ_D50(t){let n=t;return n=lin_P3_to_XYZ(n),n=D65_to_D50(n),n}function XYZ_D50_to_lin_P3(t){let n=t;return n=D50_to_D65(n),n=XYZ_to_lin_P3(n),n}function rec_2020_to_XYZ_D50(t){let n=t;var _;return n=[lin_2020_channel((_=n)[0]),lin_2020_channel(_[1]),lin_2020_channel(_[2])],n=multiplyMatrices(b,n),n=D65_to_D50(n),n}function XYZ_D50_to_rec_2020(t){let n=t;var _;return n=D50_to_D65(n),n=multiplyMatrices(c,n),n=[gam_2020_channel((_=n)[0]),gam_2020_channel(_[1]),gam_2020_channel(_[2])],n}function ProPhoto_RGB_to_XYZ_D50(t){let n=t;var _;return n=[lin_ProPhoto_channel((_=n)[0]),lin_ProPhoto_channel(_[1]),lin_ProPhoto_channel(_[2])],n=multiplyMatrices(Y,n),n}function XYZ_D50_to_ProPhoto(t){let n=t;var _;return n=multiplyMatrices(s,n),n=[gam_ProPhoto_channel((_=n)[0]),gam_ProPhoto_channel(_[1]),gam_ProPhoto_channel(_[2])],n}function XYZ_D65_to_XYZ_D50(t){let n=t;return n=D65_to_D50(n),n}function XYZ_D50_to_XYZ_D65(t){let n=t;return n=D50_to_D65(n),n}function XYZ_D50_to_XYZ_D50(t){return t}function inGamut(t){return t[0]>=-1e-4&&t[0]<=1.0001&&t[1]>=-1e-4&&t[1]<=1.0001&&t[2]>=-1e-4&&t[2]<=1.0001}function clip(t){return[t[0]<0?0:t[0]>1?1:t[0],t[1]<0?0:t[1]>1?1:t[1],t[2]<0?0:t[2]>1?1:t[2]]}
|
| 251 |
+
/**
|
| 252 |
+
* @description Calculate deltaE OK which is the simple root sum of squares
|
| 253 |
+
* @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1
|
| 254 |
+
* @param {number[]} sample - Array of OKLab values: L as 0..1, a and b as -1..1
|
| 255 |
+
* @return {number} How different a color sample is from reference
|
| 256 |
+
*
|
| 257 |
+
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
| 258 |
+
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
| 259 |
+
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/deltaEOK.js
|
| 260 |
+
*/function deltaEOK(t,n){const[_,o,e]=t,[a,r,l]=n,i=_-a,c=o-r,u=e-l;return Math.sqrt(i**2+c**2+u**2)}const M=.02,p=1e-4;function mapGamut(t,n,_){const o=t;let e=clip(n(o)),a=deltaEOK(OKLCH_to_OKLab(_(e)),OKLCH_to_OKLab(o));if(a<M)return e;let r=0,l=o[1],i=!0;for(;l-r>p;){const t=(r+l)/2;if(o[1]=t,i&&inGamut(n(o)))r=t;else if(e=clip(n(o)),a=deltaEOK(OKLCH_to_OKLab(_(e)),OKLCH_to_OKLab(o)),a<M){if(M-a<p)return e;i=!1,r=t}else l=t}return clip(n([...o]))}
|
| 261 |
+
/**
|
| 262 |
+
* @license MIT https://github.com/facelessuser/coloraide/blob/main/LICENSE.md
|
| 263 |
+
*/function mapGamutRayTrace(t,n,_){const o=t[0],e=t[2];let a=n(t);const r=n([o,0,e]);for(let t=0;t<4;t++){if(t>0){const t=_(a);t[0]=o,t[2]=e,a=n(t)}const l=rayTraceBox(r,a);if(!l)break;a=l}return clip(a)}function rayTraceBox(t,n){let _=1/0,o=-1/0;const e=[0,0,0];for(let a=0;a<3;a++){const r=t[a],l=n[a]-r;e[a]=l;const i=0,c=1;if(Math.abs(l)>1e-15){const t=1/l,n=(i-r)*t,e=(c-r)*t;o=Math.max(Math.min(n,e),o),_=Math.min(Math.max(n,e),_)}else if(r<i||r>c)return!1}return!(o>_||_<0)&&(o<0&&(o=_),!!isFinite(o)&&[t[0]+e[0]*o,t[1]+e[1]*o,t[2]+e[2]*o])}const d={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function luminance(t){const[n,_,o]=t.map(t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4));return.2126*n+.7152*_+.0722*o}function contrast_ratio_wcag_2_1(t,n){const _=luminance(t),o=luminance(n);return(Math.max(_,o)+.05)/(Math.min(_,o)+.05)}export{HSL_to_XYZ_D50,HWB_to_XYZ_D50,LCH_to_XYZ_D50,Lab_to_XYZ_D50,OKLCH_to_OKLab,OKLCH_to_XYZ_D50,OKLab_to_OKLCH,OKLab_to_XYZ,OKLab_to_XYZ_D50,P3_to_XYZ_D50,ProPhoto_RGB_to_XYZ_D50,XYZ_D50_to_HSL,XYZ_D50_to_HWB,XYZ_D50_to_LCH,XYZ_D50_to_Lab,XYZ_D50_to_OKLCH,XYZ_D50_to_OKLab,XYZ_D50_to_P3,XYZ_D50_to_ProPhoto,XYZ_D50_to_XYZ_D50,XYZ_D50_to_XYZ_D65,XYZ_D50_to_a98_RGB,XYZ_D50_to_lin_P3,XYZ_D50_to_lin_sRGB,XYZ_D50_to_rec_2020,XYZ_D50_to_sRGB,XYZ_D65_to_XYZ_D50,XYZ_to_OKLab,XYZ_to_lin_P3,XYZ_to_lin_sRGB,a98_RGB_to_XYZ_D50,clip,contrast_ratio_wcag_2_1,gam_P3,gam_sRGB,inGamut,lin_P3,lin_P3_to_XYZ,lin_P3_to_XYZ_D50,lin_sRGB,lin_sRGB_to_XYZ,lin_sRGB_to_XYZ_D50,mapGamut,mapGamutRayTrace,d as namedColors,rec_2020_to_XYZ_D50,sRGB_to_XYZ_D50};
|
node_modules/@csstools/color-helpers/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@csstools/color-helpers",
|
| 3 |
+
"description": "Color helpers to ease transformation between formats, gamut, etc",
|
| 4 |
+
"version": "6.0.2",
|
| 5 |
+
"contributors": [
|
| 6 |
+
{
|
| 7 |
+
"name": "Antonio Laguna",
|
| 8 |
+
"email": "antonio@laguna.es",
|
| 9 |
+
"url": "https://antonio.laguna.es"
|
| 10 |
+
},
|
| 11 |
+
{
|
| 12 |
+
"name": "Romain Menke",
|
| 13 |
+
"email": "romainmenke@gmail.com"
|
| 14 |
+
}
|
| 15 |
+
],
|
| 16 |
+
"license": "MIT-0",
|
| 17 |
+
"funding": [
|
| 18 |
+
{
|
| 19 |
+
"type": "github",
|
| 20 |
+
"url": "https://github.com/sponsors/csstools"
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"type": "opencollective",
|
| 24 |
+
"url": "https://opencollective.com/csstools"
|
| 25 |
+
}
|
| 26 |
+
],
|
| 27 |
+
"engines": {
|
| 28 |
+
"node": ">=20.19.0"
|
| 29 |
+
},
|
| 30 |
+
"type": "module",
|
| 31 |
+
"exports": {
|
| 32 |
+
".": {
|
| 33 |
+
"types": "./dist/index.d.ts",
|
| 34 |
+
"default": "./dist/index.mjs"
|
| 35 |
+
}
|
| 36 |
+
},
|
| 37 |
+
"files": [
|
| 38 |
+
"CHANGELOG.md",
|
| 39 |
+
"LICENSE.md",
|
| 40 |
+
"README.md",
|
| 41 |
+
"dist"
|
| 42 |
+
],
|
| 43 |
+
"scripts": {},
|
| 44 |
+
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/color-helpers#readme",
|
| 45 |
+
"repository": {
|
| 46 |
+
"type": "git",
|
| 47 |
+
"url": "git+https://github.com/csstools/postcss-plugins.git",
|
| 48 |
+
"directory": "packages/color-helpers"
|
| 49 |
+
},
|
| 50 |
+
"bugs": "https://github.com/csstools/postcss-plugins/issues",
|
| 51 |
+
"keywords": [
|
| 52 |
+
"colors",
|
| 53 |
+
"css"
|
| 54 |
+
]
|
| 55 |
+
}
|
node_modules/@csstools/css-calc/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Changes to CSS Calc
|
| 2 |
+
|
| 3 |
+
### 3.2.1
|
| 4 |
+
|
| 5 |
+
_May 13, 2026_
|
| 6 |
+
|
| 7 |
+
- Update `round(line-width, 1.2345px)` to match the latest spec
|
| 8 |
+
|
| 9 |
+
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md)
|