@stylexjs/babel-plugin 0.17.4 → 0.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.js +77 -39
- package/lib/index.d.ts +6 -1
- package/lib/index.js +53 -17
- package/lib/shared/common-types.d.ts +1 -0
- package/lib/shared/common-types.js.flow +1 -0
- package/lib/shared/preprocess-rules/application-order.d.ts +2 -0
- package/lib/shared/preprocess-rules/application-order.js.flow +1 -0
- package/lib/shared/preprocess-rules/index.d.ts +4 -1
- package/lib/shared/preprocess-rules/index.js.flow +1 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.d.ts +2 -0
- package/lib/shared/preprocess-rules/legacy-expand-shorthands.js.flow +1 -0
- package/lib/shared/types/index.d.ts +1 -0
- package/lib/shared/utils/normalizers/zero-dimensions.d.ts +1 -1
- package/lib/shared/utils/normalizers/zero-dimensions.js.flow +1 -1
- package/lib/utils/state-manager.d.ts +2 -0
- package/lib/utils/state-manager.js.flow +1 -0
- package/package.json +5 -5
package/lib/index.browser.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var parser = require('postcss-value-parser');
|
|
5
|
-
var stylex = require('@stylexjs/stylex');
|
|
1
|
+
import { packages } from '@babel/standalone';
|
|
2
|
+
import parser from 'postcss-value-parser';
|
|
3
|
+
import { legacyMerge, props } from '@stylexjs/stylex';
|
|
6
4
|
|
|
7
5
|
const {
|
|
8
6
|
arrayExpression, arrowFunctionExpression, binaryExpression, booleanLiteral,
|
|
@@ -16,7 +14,7 @@ const {
|
|
|
16
14
|
isUpdateExpression, isValidIdentifier, isVariableDeclaration, jsxAttribute,
|
|
17
15
|
jsxIdentifier, memberExpression, nullLiteral, numericLiteral, objectExpression,
|
|
18
16
|
objectProperty, stringLiteral, unaryExpression, variableDeclaration, variableDeclarator
|
|
19
|
-
} =
|
|
17
|
+
} = packages.types;
|
|
20
18
|
|
|
21
19
|
var types = /*#__PURE__*/Object.freeze({
|
|
22
20
|
__proto__: null,
|
|
@@ -79,7 +77,11 @@ function getAugmentedNamespace(n) {
|
|
|
79
77
|
var f = n.default;
|
|
80
78
|
if (typeof f == "function") {
|
|
81
79
|
var a = function a () {
|
|
82
|
-
|
|
80
|
+
var isInstance = false;
|
|
81
|
+
try {
|
|
82
|
+
isInstance = this instanceof a;
|
|
83
|
+
} catch {}
|
|
84
|
+
if (isInstance) {
|
|
83
85
|
return Reflect.construct(f, arguments, this.constructor);
|
|
84
86
|
}
|
|
85
87
|
return f.apply(this, arguments);
|
|
@@ -1238,22 +1240,22 @@ var hasRequiredLib$2;
|
|
|
1238
1240
|
function requireLib$2 () {
|
|
1239
1241
|
if (hasRequiredLib$2) return lib$2;
|
|
1240
1242
|
hasRequiredLib$2 = 1;
|
|
1241
|
-
(function (exports) {
|
|
1243
|
+
(function (exports$1) {
|
|
1242
1244
|
|
|
1243
|
-
Object.defineProperty(exports, "__esModule", {
|
|
1245
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
1244
1246
|
value: true
|
|
1245
1247
|
});
|
|
1246
|
-
Object.defineProperty(exports, "ImportInjector", {
|
|
1248
|
+
Object.defineProperty(exports$1, "ImportInjector", {
|
|
1247
1249
|
enumerable: true,
|
|
1248
1250
|
get: function () {
|
|
1249
1251
|
return _importInjector.default;
|
|
1250
1252
|
}
|
|
1251
1253
|
});
|
|
1252
|
-
exports.addDefault = addDefault;
|
|
1253
|
-
exports.addNamed = addNamed;
|
|
1254
|
-
exports.addNamespace = addNamespace;
|
|
1255
|
-
exports.addSideEffect = addSideEffect;
|
|
1256
|
-
Object.defineProperty(exports, "isModule", {
|
|
1254
|
+
exports$1.addDefault = addDefault;
|
|
1255
|
+
exports$1.addNamed = addNamed;
|
|
1256
|
+
exports$1.addNamespace = addNamespace;
|
|
1257
|
+
exports$1.addSideEffect = addSideEffect;
|
|
1258
|
+
Object.defineProperty(exports$1, "isModule", {
|
|
1257
1259
|
enumerable: true,
|
|
1258
1260
|
get: function () {
|
|
1259
1261
|
return _isModule.default;
|
|
@@ -1439,6 +1441,7 @@ const defaultOptions = {
|
|
|
1439
1441
|
classNamePrefix: 'x',
|
|
1440
1442
|
dev: false,
|
|
1441
1443
|
debug: false,
|
|
1444
|
+
propertyValidationMode: 'silent',
|
|
1442
1445
|
enableDebugClassNames: false,
|
|
1443
1446
|
enableDevClassNames: false,
|
|
1444
1447
|
enableDebugDataProp: true,
|
|
@@ -1530,6 +1533,7 @@ class StateManager {
|
|
|
1530
1533
|
const configuredImportSources = logAndDefault(checkImportSources, options.importSources ?? defaultOptions.importSources, [], 'options.importSources');
|
|
1531
1534
|
const importSources = [name, 'stylex', ...configuredImportSources];
|
|
1532
1535
|
const styleResolution = logAndDefault(unionOf3(literal('application-order'), literal('property-specificity'), literal('legacy-expand-shorthands')), options.styleResolution ?? defaultOptions.styleResolution, 'property-specificity', 'options.styleResolution');
|
|
1536
|
+
const propertyValidationMode = logAndDefault(unionOf3(literal('throw'), literal('warn'), literal('silent')), options.propertyValidationMode ?? defaultOptions.propertyValidationMode, 'silent', 'options.propertyValidationMode');
|
|
1533
1537
|
const unstable_moduleResolution = logAndDefault(unionOf(nullish(), CheckModuleResolution), options.unstable_moduleResolution, null, 'options.unstable_moduleResolution');
|
|
1534
1538
|
const treeshakeCompensation = logAndDefault(boolean(), options.treeshakeCompensation ?? defaultOptions.treeshakeCompensation, false, 'options.treeshakeCompensation');
|
|
1535
1539
|
const aliasesOption = logAndDefault(unionOf(nullish(), objectOf(unionOf(string(), array(string())))), options.aliases, null, 'options.aliases');
|
|
@@ -1546,6 +1550,7 @@ class StateManager {
|
|
|
1546
1550
|
debug,
|
|
1547
1551
|
definedStylexCSSVariables: {},
|
|
1548
1552
|
dev,
|
|
1553
|
+
propertyValidationMode,
|
|
1549
1554
|
enableDebugClassNames,
|
|
1550
1555
|
enableDebugDataProp,
|
|
1551
1556
|
enableDevClassNames,
|
|
@@ -2066,6 +2071,15 @@ const shorthands$2 = {
|
|
|
2066
2071
|
borderTopRightRadius: value => [['borderTopRightRadius', value], ['borderStartStartRadius', null], ['borderStartEndRadius', null]],
|
|
2067
2072
|
borderBottomLeftRadius: value => [['borderBottomLeftRadius', value], ['borderEndStartRadius', null], ['borderEndEndRadius', null]],
|
|
2068
2073
|
borderBottomRightRadius: value => [['borderBottomRightRadius', value], ['borderEndStartRadius', null], ['borderEndEndRadius', null]],
|
|
2074
|
+
cornerShape: value => [['cornerShape', value], ['cornerStartStartShape', null], ['cornerStartEndShape', null], ['cornerEndStartShape', null], ['cornerEndEndShape', null], ['cornerTopLeftShape', null], ['cornerTopRightShape', null], ['cornerBottomLeftShape', null], ['cornerBottomRightShape', null]],
|
|
2075
|
+
cornerStartStartShape: value => [['cornerStartStartShape', value], ['cornerTopLeftShape', null], ['cornerTopRightShape', null]],
|
|
2076
|
+
cornerStartEndShape: value => [['cornerStartEndShape', value], ['cornerTopLeftShape', null], ['cornerTopRightShape', null]],
|
|
2077
|
+
cornerEndStartShape: value => [['cornerEndStartShape', value], ['cornerBottomLeftShape', null], ['cornerBottomRightShape', null]],
|
|
2078
|
+
cornerEndEndShape: value => [['cornerEndEndShape', value], ['cornerBottomLeftShape', null], ['cornerBottomRightShape', null]],
|
|
2079
|
+
cornerTopLeftShape: value => [['cornerTopLeftShape', value], ['cornerStartStartShape', null], ['cornerStartEndShape', null]],
|
|
2080
|
+
cornerTopRightShape: value => [['cornerTopRightShape', value], ['cornerStartStartShape', null], ['cornerStartEndShape', null]],
|
|
2081
|
+
cornerBottomLeftShape: value => [['cornerBottomLeftShape', value], ['cornerEndStartShape', null], ['cornerEndEndShape', null]],
|
|
2082
|
+
cornerBottomRightShape: value => [['cornerBottomRightShape', value], ['cornerEndStartShape', null], ['cornerEndEndShape', null]],
|
|
2069
2083
|
borderImage: value => [['borderImage', value], ['borderImageOutset', null], ['borderImageRepeat', null], ['borderImageSlice', null], ['borderImageSource', null], ['borderImageWidth', null]],
|
|
2070
2084
|
columnRule: value => [['columnRule', value], ['columnRuleColor', null], ['columnRuleStyle', null], ['columnRuleWidth', null]],
|
|
2071
2085
|
columns: value => [['columns', value], ['columnCount', null], ['columnWidth', null]],
|
|
@@ -2563,7 +2577,19 @@ function flatMapExpandedShorthands(objEntry, options) {
|
|
|
2563
2577
|
if (Array.isArray(value)) {
|
|
2564
2578
|
throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
|
|
2565
2579
|
}
|
|
2566
|
-
|
|
2580
|
+
try {
|
|
2581
|
+
return expansion(value);
|
|
2582
|
+
} catch (error) {
|
|
2583
|
+
const validationMode = options.propertyValidationMode ?? 'silent';
|
|
2584
|
+
if (validationMode === 'throw') {
|
|
2585
|
+
throw error;
|
|
2586
|
+
} else if (validationMode === 'warn') {
|
|
2587
|
+
console.warn(`[stylex] ${error.message}`);
|
|
2588
|
+
return [];
|
|
2589
|
+
} else {
|
|
2590
|
+
return [];
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2567
2593
|
}
|
|
2568
2594
|
return [[key, value]];
|
|
2569
2595
|
}
|
|
@@ -2581,8 +2607,8 @@ var hasRequiredDist;
|
|
|
2581
2607
|
function requireDist () {
|
|
2582
2608
|
if (hasRequiredDist) return dist;
|
|
2583
2609
|
hasRequiredDist = 1;
|
|
2584
|
-
(function (exports) {
|
|
2585
|
-
class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=t;}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,o,t,r){super(e,n,o,t),this.token=r;}}const e={UnexpectedNewLineInString:"Unexpected newline while consuming a string token.",UnexpectedEOFInString:"Unexpected EOF while consuming a string token.",UnexpectedEOFInComment:"Unexpected EOF while consuming a comment.",UnexpectedEOFInURL:"Unexpected EOF while consuming a url token.",UnexpectedEOFInEscapedCodePoint:"Unexpected EOF while consuming an escaped code point.",UnexpectedCharacterInURL:"Unexpected character while consuming a url token.",InvalidEscapeSequenceInURL:"Invalid escape sequence while consuming a url token.",InvalidEscapeSequenceAfterBackslash:'Invalid escape sequence after "\\"'},n="undefined"!=typeof globalThis&&"structuredClone"in globalThis;const o=13,t=45,r=10,s=43,i=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===t&&e.source.codePointAt(e.cursor+3)===t}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||95===e}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===t}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||(0===e||(!!isSurrogate(e)||e>=65536)))}function isNewLine(e){return e===r||e===o||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===o||12===e}function isSurrogate(e){return e>=55296&&e<=57343}function checkIfTwoCodePointsAreAValidEscape(e){return 92===e.source.codePointAt(e.cursor)&&!isNewLine(e.source.codePointAt(e.cursor+1)??-1)}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.source.codePointAt(n.cursor)===t?n.source.codePointAt(n.cursor+1)===t||(!!isIdentStartCodePoint(n.source.codePointAt(n.cursor+1)??-1)||92===n.source.codePointAt(n.cursor+1)&&!isNewLine(n.source.codePointAt(n.cursor+2)??-1)):!!isIdentStartCodePoint(n.source.codePointAt(n.cursor)??-1)||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.source.codePointAt(e.cursor)===s||e.source.codePointAt(e.cursor)===t?!!isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1)||46===e.source.codePointAt(e.cursor+1)&&isDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1):46===e.source.codePointAt(e.cursor)?isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1):isDigitCodePoint(e.source.codePointAt(e.cursor)??-1)}function checkIfTwoCodePointsStartAComment(e){return 47===e.source.codePointAt(e.cursor)&&42===e.source.codePointAt(e.cursor+1)}function checkIfThreeCodePointsWouldStartCDC(e){return e.source.codePointAt(e.cursor)===t&&e.source.codePointAt(e.cursor+1)===t&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function consumeComment(n,o){for(o.advanceCodePoint(2);;){const t=o.readCodePoint();if(void 0===t){const t=[exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],t)),t}if(42===t&&(void 0!==o.source.codePointAt(o.cursor)&&47===o.source.codePointAt(o.cursor))){o.advanceCodePoint();break}}return [exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(n,t){const s=t.readCodePoint();if(void 0===s)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),i;if(isHexDigitCodePoint(s)){const e=[s];let n;for(;void 0!==(n=t.source.codePointAt(t.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?i:c}return 0===s||isSurrogate(s)?i:s}function consumeIdentSequence(e,n){const o=[];for(;;){const t=n.source.codePointAt(n.cursor)??-1;if(0===t||isSurrogate(t))o.push(i),n.advanceCodePoint(+(t>65535)+1);else if(isIdentCodePoint(t))o.push(t),n.advanceCodePoint(+(t>65535)+1);else {if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n));}}}function consumeHashToken(e,n){n.advanceCodePoint();const o=n.source.codePointAt(n.cursor);if(void 0!==o&&(isIdentCodePoint(o)||checkIfTwoCodePointsAreAValidEscape(n))){let o=exports.HashType.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(o=exports.HashType.ID);const t=consumeIdentSequence(e,n);return [exports.TokenType.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t),type:o}]}return [exports.TokenType.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let o=exports.NumberType.Integer;for(n.source.codePointAt(n.cursor)!==s&&n.source.codePointAt(n.cursor)!==t||n.advanceCodePoint();isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(46===n.source.codePointAt(n.cursor)&&isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint(2),o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(101===n.source.codePointAt(n.cursor)||69===n.source.codePointAt(n.cursor)){if(isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))n.advanceCodePoint(2);else {if(n.source.codePointAt(n.cursor+1)!==t&&n.source.codePointAt(n.cursor+1)!==s||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return o;n.advanceCodePoint(3);}for(o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();}return o}function consumeNumericToken(e,n){let o;{const e=n.source.codePointAt(n.cursor);e===t?o="-":e===s&&(o="+");}const r=consumeNumber(0,n),i=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const t=consumeIdentSequence(e,n);return [exports.TokenType.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r,unit:String.fromCodePoint(...t)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[exports.TokenType.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o}]):[exports.TokenType.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return [exports.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}exports.TokenType=void 0,(c=exports.TokenType||(exports.TokenType={})).Comment="comment",c.AtKeyword="at-keyword-token",c.BadString="bad-string-token",c.BadURL="bad-url-token",c.CDC="CDC-token",c.CDO="CDO-token",c.Colon="colon-token",c.Comma="comma-token",c.Delim="delim-token",c.Dimension="dimension-token",c.EOF="EOF-token",c.Function="function-token",c.Hash="hash-token",c.Ident="ident-token",c.Number="number-token",c.Percentage="percentage-token",c.Semicolon="semicolon-token",c.String="string-token",c.URL="url-token",c.Whitespace="whitespace-token",c.OpenParen="(-token",c.CloseParen=")-token",c.OpenSquare="[-token",c.CloseSquare="]-token",c.OpenCurly="{-token",c.CloseCurly="}-token",c.UnicodeRange="unicode-range-token",exports.NumberType=void 0,(a=exports.NumberType||(exports.NumberType={})).Integer="integer",a.Number="number",exports.HashType=void 0,(u=exports.HashType||(exports.HashType={})).Unrestricted="unrestricted",u.ID="id";class Reader{cursor=0;source="";representationStart=0;representationEnd=-1;constructor(e){this.source=e;}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.cursor-1;}readCodePoint(){const e=this.source.codePointAt(this.cursor);if(void 0!==e)return this.cursor=this.cursor+1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.cursor-1;}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1;}}function consumeStringToken(n,t){let s="";const c=t.readCodePoint();for(;;){const a=t.readCodePoint();if(void 0===a){const o=[exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,t.representationStart,t.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],o)),o}if(isNewLine(a)){t.unreadCodePoint();const s=[exports.TokenType.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r?t.representationEnd+2:t.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],s)),s}if(a===c)return [exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];if(92!==a)0===a||isSurrogate(a)?s+=String.fromCodePoint(i):s+=String.fromCodePoint(a);else {if(void 0===t.source.codePointAt(t.cursor))continue;if(isNewLine(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint();continue}s+=String.fromCodePoint(consumeEscapedCodePoint(n,t));}}}function checkIfCodePointsMatchURLIdent(e){return !(3!==e.length||117!==e[0]&&85!==e[0]||114!==e[1]&&82!==e[1]||108!==e[2]&&76!==e[2])}function consumeBadURL(e,n){for(;;){const o=n.source.codePointAt(n.cursor);if(void 0===o)return;if(41===o)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint();}}function consumeUrlToken(n,o){for(;isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();let t="";for(;;){if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===o.source.codePointAt(o.cursor))return o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];if(isWhitespace(o.source.codePointAt(o.cursor)??-1)){for(o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===o.source.codePointAt(o.cursor)?(o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}]):(consumeBadURL(n,o),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}const s=o.source.codePointAt(o.cursor);if(34===s||39===s||40===s||(11===(r=s??-1)||127===r||0<=r&&r<=8||14<=r&&r<=31)){consumeBadURL(n,o);const t=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"],t)),t}if(92===s){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),t+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}consumeBadURL(n,o);const r=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],r)),r}0===o.source.codePointAt(o.cursor)||isSurrogate(o.source.codePointAt(o.cursor)??-1)?(t+=String.fromCodePoint(i),o.advanceCodePoint()):(t+=o.source[o.cursor],o.advanceCodePoint());}var r;}function consumeIdentLikeToken(e,n){const o=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return [exports.TokenType.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];if(checkIfCodePointsMatchURLIdent(o)){n.advanceCodePoint();let t=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){t+=1,n.advanceCodePoint(1);continue}const s=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===s||39===s)return t>0&&n.unreadCodePoint(t),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return !(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==s||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const o=[],r=[];let s;for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&isHexDigitCodePoint(s);)o.push(s),n.advanceCodePoint();for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&63===s;)0===r.length&&r.push(...o),o.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===t&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(s=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(s);)r.push(s),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...o),16);return [exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const i=parseInt(String.fromCodePoint(...o),16),c=parseInt(String.fromCodePoint(...r),16);return [exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenizer(n,i){const c=n.css.valueOf(),a=n.unicodeRangesAllowed??false,u=new Reader(c),d={onParseError:i?.onParseError??noop};return {nextToken:function nextToken(){u.resetRepresentation();const n=u.source.codePointAt(u.cursor);if(void 0===n)return [exports.TokenType.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(u))return consumeComment(d,u);if(a&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(u))return consumeUnicodeRangeToken(0,u);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(d,u);if(isDigitCodePoint(n))return consumeNumericToken(d,u);switch(n){case 44:return u.advanceCodePoint(),[exports.TokenType.Comma,",",u.representationStart,u.representationEnd,void 0];case 58:return u.advanceCodePoint(),[exports.TokenType.Colon,":",u.representationStart,u.representationEnd,void 0];case 59:return u.advanceCodePoint(),[exports.TokenType.Semicolon,";",u.representationStart,u.representationEnd,void 0];case 40:return u.advanceCodePoint(),[exports.TokenType.OpenParen,"(",u.representationStart,u.representationEnd,void 0];case 41:return u.advanceCodePoint(),[exports.TokenType.CloseParen,")",u.representationStart,u.representationEnd,void 0];case 91:return u.advanceCodePoint(),[exports.TokenType.OpenSquare,"[",u.representationStart,u.representationEnd,void 0];case 93:return u.advanceCodePoint(),[exports.TokenType.CloseSquare,"]",u.representationStart,u.representationEnd,void 0];case 123:return u.advanceCodePoint(),[exports.TokenType.OpenCurly,"{",u.representationStart,u.representationEnd,void 0];case 125:return u.advanceCodePoint(),[exports.TokenType.CloseCurly,"}",u.representationStart,u.representationEnd,void 0];case 39:case 34:return consumeStringToken(d,u);case 35:return consumeHashToken(d,u);case s:case 46:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]);case r:case o:case 12:case 9:case 32:return consumeWhiteSpace(u);case t:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):checkIfThreeCodePointsWouldStartCDC(u)?(u.advanceCodePoint(3),[exports.TokenType.CDC,"--\x3e",u.representationStart,u.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)?consumeIdentLikeToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,"-",u.representationStart,u.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(u)?(u.advanceCodePoint(4),[exports.TokenType.CDO,"\x3c!--",u.representationStart,u.representationEnd,void 0]):(u.advanceCodePoint(),[exports.TokenType.Delim,"<",u.representationStart,u.representationEnd,{value:"<"}]);case 64:if(u.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)){const e=consumeIdentSequence(d,u);return [exports.TokenType.AtKeyword,u.source.slice(u.representationStart,u.representationEnd+1),u.representationStart,u.representationEnd,{value:String.fromCodePoint(...e)}]}return [exports.TokenType.Delim,"@",u.representationStart,u.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(u))return consumeIdentLikeToken(d,u);u.advanceCodePoint();const n=[exports.TokenType.Delim,"\\",u.representationStart,u.representationEnd,{value:"\\"}];return d.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,u.representationStart,u.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],n)),n}}return u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]},endOfFile:function endOfFile(){return void 0===u.source.codePointAt(u.cursor)}}}function noop(){}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,i),n=1;else if(e[0]===t&&e[1]===t)n=2;else if(e[0]===t&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else {if(e[0]===t&&!e[1])return [92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]));}for(let o=n;o<e.length;o++)0!==e[o]?isIdentCodePoint(e[o])||(o+=insertEscapedCharacter(e,o,e[o])):(e.splice(o,1,i),o++);return e}function insertEscapedCharacter(e,n,o){return e.splice(n,1,92,o),1}function insertEscapedCodePoint(e,n,o){const t=o.toString(16),r=[];for(const e of t)r.push(e.codePointAt(0));return e.splice(n,1,92,...r,32),1+r.length}const d=Object.values(exports.TokenType);exports.ParseError=ParseError,exports.ParseErrorMessage=e,exports.ParseErrorWithToken=ParseErrorWithToken,exports.cloneTokens=function cloneTokens(e){return n?structuredClone(e):JSON.parse(JSON.stringify(e))},exports.isToken=function isToken(e){return !!Array.isArray(e)&&(!(e.length<4)&&(!!d.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))},exports.isTokenAtKeyword=function isTokenAtKeyword(e){return !!e&&e[0]===exports.TokenType.AtKeyword},exports.isTokenBadString=function isTokenBadString(e){return !!e&&e[0]===exports.TokenType.BadString},exports.isTokenBadURL=function isTokenBadURL(e){return !!e&&e[0]===exports.TokenType.BadURL},exports.isTokenCDC=function isTokenCDC(e){return !!e&&e[0]===exports.TokenType.CDC},exports.isTokenCDO=function isTokenCDO(e){return !!e&&e[0]===exports.TokenType.CDO},exports.isTokenCloseCurly=function isTokenCloseCurly(e){return !!e&&e[0]===exports.TokenType.CloseCurly},exports.isTokenCloseParen=function isTokenCloseParen(e){return !!e&&e[0]===exports.TokenType.CloseParen},exports.isTokenCloseSquare=function isTokenCloseSquare(e){return !!e&&e[0]===exports.TokenType.CloseSquare},exports.isTokenColon=function isTokenColon(e){return !!e&&e[0]===exports.TokenType.Colon},exports.isTokenComma=function isTokenComma(e){return !!e&&e[0]===exports.TokenType.Comma},exports.isTokenComment=function isTokenComment(e){return !!e&&e[0]===exports.TokenType.Comment},exports.isTokenDelim=function isTokenDelim(e){return !!e&&e[0]===exports.TokenType.Delim},exports.isTokenDimension=function isTokenDimension(e){return !!e&&e[0]===exports.TokenType.Dimension},exports.isTokenEOF=function isTokenEOF(e){return !!e&&e[0]===exports.TokenType.EOF},exports.isTokenFunction=function isTokenFunction(e){return !!e&&e[0]===exports.TokenType.Function},exports.isTokenHash=function isTokenHash(e){return !!e&&e[0]===exports.TokenType.Hash},exports.isTokenIdent=function isTokenIdent(e){return !!e&&e[0]===exports.TokenType.Ident},exports.isTokenNumber=function isTokenNumber(e){return !!e&&e[0]===exports.TokenType.Number},exports.isTokenNumeric=function isTokenNumeric(e){if(!e)return false;switch(e[0]){case exports.TokenType.Dimension:case exports.TokenType.Number:case exports.TokenType.Percentage:return true;default:return false}},exports.isTokenOpenCurly=function isTokenOpenCurly(e){return !!e&&e[0]===exports.TokenType.OpenCurly},exports.isTokenOpenParen=function isTokenOpenParen(e){return !!e&&e[0]===exports.TokenType.OpenParen},exports.isTokenOpenSquare=function isTokenOpenSquare(e){return !!e&&e[0]===exports.TokenType.OpenSquare},exports.isTokenPercentage=function isTokenPercentage(e){return !!e&&e[0]===exports.TokenType.Percentage},exports.isTokenSemicolon=function isTokenSemicolon(e){return !!e&&e[0]===exports.TokenType.Semicolon},exports.isTokenString=function isTokenString(e){return !!e&&e[0]===exports.TokenType.String},exports.isTokenURL=function isTokenURL(e){return !!e&&e[0]===exports.TokenType.URL},exports.isTokenUnicodeRange=function isTokenUnicodeRange(e){return !!e&&e[0]===exports.TokenType.UnicodeRange},exports.isTokenWhiteSpaceOrComment=function isTokenWhiteSpaceOrComment(e){if(!e)return false;switch(e[0]){case exports.TokenType.Whitespace:case exports.TokenType.Comment:return true;default:return false}},exports.isTokenWhitespace=function isTokenWhitespace(e){return !!e&&e[0]===exports.TokenType.Whitespace},exports.mirrorVariant=function mirrorVariant(e){switch(e[0]){case exports.TokenType.OpenParen:return [exports.TokenType.CloseParen,")",-1,-1,void 0];case exports.TokenType.CloseParen:return [exports.TokenType.OpenParen,"(",-1,-1,void 0];case exports.TokenType.OpenCurly:return [exports.TokenType.CloseCurly,"}",-1,-1,void 0];case exports.TokenType.CloseCurly:return [exports.TokenType.OpenCurly,"{",-1,-1,void 0];case exports.TokenType.OpenSquare:return [exports.TokenType.CloseSquare,"]",-1,-1,void 0];case exports.TokenType.CloseSquare:return [exports.TokenType.OpenSquare,"[",-1,-1,void 0];default:return null}},exports.mirrorVariantType=function mirrorVariantType(e){switch(e){case exports.TokenType.OpenParen:return exports.TokenType.CloseParen;case exports.TokenType.CloseParen:return exports.TokenType.OpenParen;case exports.TokenType.OpenCurly:return exports.TokenType.CloseCurly;case exports.TokenType.CloseCurly:return exports.TokenType.OpenCurly;case exports.TokenType.OpenSquare:return exports.TokenType.CloseSquare;case exports.TokenType.CloseSquare:return exports.TokenType.OpenSquare;default:return null}},exports.mutateIdent=function mutateIdent(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=String.fromCodePoint(...serializeIdent(o));e[1]=t,e[4].value=n;},exports.mutateUnit=function mutateUnit(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=serializeIdent(o);101===t[0]&&insertEscapedCodePoint(t,0,t[0]);const r=String.fromCodePoint(...t),s="+"===e[4].signCharacter?e[4].signCharacter:"",i=e[4].value.toString();e[1]=`${s}${i}${r}`,e[4].unit=n;},exports.stringify=function stringify(...e){let n="";for(let o=0;o<e.length;o++)n+=e[o][1];return n},exports.tokenize=function tokenize(e,n){const o=tokenizer(e,n),t=[];for(;!o.endOfFile();)t.push(o.nextToken());return t.push(o.nextToken()),t},exports.tokenizer=tokenizer;
|
|
2610
|
+
(function (exports$1) {
|
|
2611
|
+
class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=t;}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,o,t,r){super(e,n,o,t),this.token=r;}}const e={UnexpectedNewLineInString:"Unexpected newline while consuming a string token.",UnexpectedEOFInString:"Unexpected EOF while consuming a string token.",UnexpectedEOFInComment:"Unexpected EOF while consuming a comment.",UnexpectedEOFInURL:"Unexpected EOF while consuming a url token.",UnexpectedEOFInEscapedCodePoint:"Unexpected EOF while consuming an escaped code point.",UnexpectedCharacterInURL:"Unexpected character while consuming a url token.",InvalidEscapeSequenceInURL:"Invalid escape sequence while consuming a url token.",InvalidEscapeSequenceAfterBackslash:'Invalid escape sequence after "\\"'},n="undefined"!=typeof globalThis&&"structuredClone"in globalThis;const o=13,t=45,r=10,s=43,i=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===t&&e.source.codePointAt(e.cursor+3)===t}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||95===e}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===t}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||(0===e||(!!isSurrogate(e)||e>=65536)))}function isNewLine(e){return e===r||e===o||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===o||12===e}function isSurrogate(e){return e>=55296&&e<=57343}function checkIfTwoCodePointsAreAValidEscape(e){return 92===e.source.codePointAt(e.cursor)&&!isNewLine(e.source.codePointAt(e.cursor+1)??-1)}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.source.codePointAt(n.cursor)===t?n.source.codePointAt(n.cursor+1)===t||(!!isIdentStartCodePoint(n.source.codePointAt(n.cursor+1)??-1)||92===n.source.codePointAt(n.cursor+1)&&!isNewLine(n.source.codePointAt(n.cursor+2)??-1)):!!isIdentStartCodePoint(n.source.codePointAt(n.cursor)??-1)||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.source.codePointAt(e.cursor)===s||e.source.codePointAt(e.cursor)===t?!!isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1)||46===e.source.codePointAt(e.cursor+1)&&isDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1):46===e.source.codePointAt(e.cursor)?isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1):isDigitCodePoint(e.source.codePointAt(e.cursor)??-1)}function checkIfTwoCodePointsStartAComment(e){return 47===e.source.codePointAt(e.cursor)&&42===e.source.codePointAt(e.cursor+1)}function checkIfThreeCodePointsWouldStartCDC(e){return e.source.codePointAt(e.cursor)===t&&e.source.codePointAt(e.cursor+1)===t&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function consumeComment(n,o){for(o.advanceCodePoint(2);;){const t=o.readCodePoint();if(void 0===t){const t=[exports$1.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],t)),t}if(42===t&&(void 0!==o.source.codePointAt(o.cursor)&&47===o.source.codePointAt(o.cursor))){o.advanceCodePoint();break}}return [exports$1.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(n,t){const s=t.readCodePoint();if(void 0===s)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),i;if(isHexDigitCodePoint(s)){const e=[s];let n;for(;void 0!==(n=t.source.codePointAt(t.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?i:c}return 0===s||isSurrogate(s)?i:s}function consumeIdentSequence(e,n){const o=[];for(;;){const t=n.source.codePointAt(n.cursor)??-1;if(0===t||isSurrogate(t))o.push(i),n.advanceCodePoint(+(t>65535)+1);else if(isIdentCodePoint(t))o.push(t),n.advanceCodePoint(+(t>65535)+1);else {if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n));}}}function consumeHashToken(e,n){n.advanceCodePoint();const o=n.source.codePointAt(n.cursor);if(void 0!==o&&(isIdentCodePoint(o)||checkIfTwoCodePointsAreAValidEscape(n))){let o=exports$1.HashType.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(o=exports$1.HashType.ID);const t=consumeIdentSequence(e,n);return [exports$1.TokenType.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t),type:o}]}return [exports$1.TokenType.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let o=exports$1.NumberType.Integer;for(n.source.codePointAt(n.cursor)!==s&&n.source.codePointAt(n.cursor)!==t||n.advanceCodePoint();isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(46===n.source.codePointAt(n.cursor)&&isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint(2),o=exports$1.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(101===n.source.codePointAt(n.cursor)||69===n.source.codePointAt(n.cursor)){if(isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))n.advanceCodePoint(2);else {if(n.source.codePointAt(n.cursor+1)!==t&&n.source.codePointAt(n.cursor+1)!==s||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return o;n.advanceCodePoint(3);}for(o=exports$1.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();}return o}function consumeNumericToken(e,n){let o;{const e=n.source.codePointAt(n.cursor);e===t?o="-":e===s&&(o="+");}const r=consumeNumber(0,n),i=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const t=consumeIdentSequence(e,n);return [exports$1.TokenType.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r,unit:String.fromCodePoint(...t)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[exports$1.TokenType.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o}]):[exports$1.TokenType.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return [exports$1.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}exports$1.TokenType=void 0,(c=exports$1.TokenType||(exports$1.TokenType={})).Comment="comment",c.AtKeyword="at-keyword-token",c.BadString="bad-string-token",c.BadURL="bad-url-token",c.CDC="CDC-token",c.CDO="CDO-token",c.Colon="colon-token",c.Comma="comma-token",c.Delim="delim-token",c.Dimension="dimension-token",c.EOF="EOF-token",c.Function="function-token",c.Hash="hash-token",c.Ident="ident-token",c.Number="number-token",c.Percentage="percentage-token",c.Semicolon="semicolon-token",c.String="string-token",c.URL="url-token",c.Whitespace="whitespace-token",c.OpenParen="(-token",c.CloseParen=")-token",c.OpenSquare="[-token",c.CloseSquare="]-token",c.OpenCurly="{-token",c.CloseCurly="}-token",c.UnicodeRange="unicode-range-token",exports$1.NumberType=void 0,(a=exports$1.NumberType||(exports$1.NumberType={})).Integer="integer",a.Number="number",exports$1.HashType=void 0,(u=exports$1.HashType||(exports$1.HashType={})).Unrestricted="unrestricted",u.ID="id";class Reader{cursor=0;source="";representationStart=0;representationEnd=-1;constructor(e){this.source=e;}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.cursor-1;}readCodePoint(){const e=this.source.codePointAt(this.cursor);if(void 0!==e)return this.cursor=this.cursor+1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.cursor-1;}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1;}}function consumeStringToken(n,t){let s="";const c=t.readCodePoint();for(;;){const a=t.readCodePoint();if(void 0===a){const o=[exports$1.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,t.representationStart,t.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],o)),o}if(isNewLine(a)){t.unreadCodePoint();const s=[exports$1.TokenType.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r?t.representationEnd+2:t.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],s)),s}if(a===c)return [exports$1.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];if(92!==a)0===a||isSurrogate(a)?s+=String.fromCodePoint(i):s+=String.fromCodePoint(a);else {if(void 0===t.source.codePointAt(t.cursor))continue;if(isNewLine(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint();continue}s+=String.fromCodePoint(consumeEscapedCodePoint(n,t));}}}function checkIfCodePointsMatchURLIdent(e){return !(3!==e.length||117!==e[0]&&85!==e[0]||114!==e[1]&&82!==e[1]||108!==e[2]&&76!==e[2])}function consumeBadURL(e,n){for(;;){const o=n.source.codePointAt(n.cursor);if(void 0===o)return;if(41===o)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint();}}function consumeUrlToken(n,o){for(;isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();let t="";for(;;){if(void 0===o.source.codePointAt(o.cursor)){const r=[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===o.source.codePointAt(o.cursor))return o.advanceCodePoint(),[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];if(isWhitespace(o.source.codePointAt(o.cursor)??-1)){for(o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();if(void 0===o.source.codePointAt(o.cursor)){const r=[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===o.source.codePointAt(o.cursor)?(o.advanceCodePoint(),[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}]):(consumeBadURL(n,o),[exports$1.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}const s=o.source.codePointAt(o.cursor);if(34===s||39===s||40===s||(11===(r=s??-1)||127===r||0<=r&&r<=8||14<=r&&r<=31)){consumeBadURL(n,o);const t=[exports$1.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"],t)),t}if(92===s){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),t+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}consumeBadURL(n,o);const r=[exports$1.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],r)),r}0===o.source.codePointAt(o.cursor)||isSurrogate(o.source.codePointAt(o.cursor)??-1)?(t+=String.fromCodePoint(i),o.advanceCodePoint()):(t+=o.source[o.cursor],o.advanceCodePoint());}var r;}function consumeIdentLikeToken(e,n){const o=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return [exports$1.TokenType.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];if(checkIfCodePointsMatchURLIdent(o)){n.advanceCodePoint();let t=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){t+=1,n.advanceCodePoint(1);continue}const s=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===s||39===s)return t>0&&n.unreadCodePoint(t),[exports$1.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[exports$1.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return !(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==s||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const o=[],r=[];let s;for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&isHexDigitCodePoint(s);)o.push(s),n.advanceCodePoint();for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&63===s;)0===r.length&&r.push(...o),o.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===t&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(s=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(s);)r.push(s),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...o),16);return [exports$1.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const i=parseInt(String.fromCodePoint(...o),16),c=parseInt(String.fromCodePoint(...r),16);return [exports$1.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenizer(n,i){const c=n.css.valueOf(),a=n.unicodeRangesAllowed??false,u=new Reader(c),d={onParseError:i?.onParseError??noop};return {nextToken:function nextToken(){u.resetRepresentation();const n=u.source.codePointAt(u.cursor);if(void 0===n)return [exports$1.TokenType.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(u))return consumeComment(d,u);if(a&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(u))return consumeUnicodeRangeToken(0,u);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(d,u);if(isDigitCodePoint(n))return consumeNumericToken(d,u);switch(n){case 44:return u.advanceCodePoint(),[exports$1.TokenType.Comma,",",u.representationStart,u.representationEnd,void 0];case 58:return u.advanceCodePoint(),[exports$1.TokenType.Colon,":",u.representationStart,u.representationEnd,void 0];case 59:return u.advanceCodePoint(),[exports$1.TokenType.Semicolon,";",u.representationStart,u.representationEnd,void 0];case 40:return u.advanceCodePoint(),[exports$1.TokenType.OpenParen,"(",u.representationStart,u.representationEnd,void 0];case 41:return u.advanceCodePoint(),[exports$1.TokenType.CloseParen,")",u.representationStart,u.representationEnd,void 0];case 91:return u.advanceCodePoint(),[exports$1.TokenType.OpenSquare,"[",u.representationStart,u.representationEnd,void 0];case 93:return u.advanceCodePoint(),[exports$1.TokenType.CloseSquare,"]",u.representationStart,u.representationEnd,void 0];case 123:return u.advanceCodePoint(),[exports$1.TokenType.OpenCurly,"{",u.representationStart,u.representationEnd,void 0];case 125:return u.advanceCodePoint(),[exports$1.TokenType.CloseCurly,"}",u.representationStart,u.representationEnd,void 0];case 39:case 34:return consumeStringToken(d,u);case 35:return consumeHashToken(d,u);case s:case 46:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):(u.advanceCodePoint(),[exports$1.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]);case r:case o:case 12:case 9:case 32:return consumeWhiteSpace(u);case t:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):checkIfThreeCodePointsWouldStartCDC(u)?(u.advanceCodePoint(3),[exports$1.TokenType.CDC,"--\x3e",u.representationStart,u.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)?consumeIdentLikeToken(d,u):(u.advanceCodePoint(),[exports$1.TokenType.Delim,"-",u.representationStart,u.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(u)?(u.advanceCodePoint(4),[exports$1.TokenType.CDO,"\x3c!--",u.representationStart,u.representationEnd,void 0]):(u.advanceCodePoint(),[exports$1.TokenType.Delim,"<",u.representationStart,u.representationEnd,{value:"<"}]);case 64:if(u.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)){const e=consumeIdentSequence(d,u);return [exports$1.TokenType.AtKeyword,u.source.slice(u.representationStart,u.representationEnd+1),u.representationStart,u.representationEnd,{value:String.fromCodePoint(...e)}]}return [exports$1.TokenType.Delim,"@",u.representationStart,u.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(u))return consumeIdentLikeToken(d,u);u.advanceCodePoint();const n=[exports$1.TokenType.Delim,"\\",u.representationStart,u.representationEnd,{value:"\\"}];return d.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,u.representationStart,u.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],n)),n}}return u.advanceCodePoint(),[exports$1.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]},endOfFile:function endOfFile(){return void 0===u.source.codePointAt(u.cursor)}}}function noop(){}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,i),n=1;else if(e[0]===t&&e[1]===t)n=2;else if(e[0]===t&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else {if(e[0]===t&&!e[1])return [92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]));}for(let o=n;o<e.length;o++)0!==e[o]?isIdentCodePoint(e[o])||(o+=insertEscapedCharacter(e,o,e[o])):(e.splice(o,1,i),o++);return e}function insertEscapedCharacter(e,n,o){return e.splice(n,1,92,o),1}function insertEscapedCodePoint(e,n,o){const t=o.toString(16),r=[];for(const e of t)r.push(e.codePointAt(0));return e.splice(n,1,92,...r,32),1+r.length}const d=Object.values(exports$1.TokenType);exports$1.ParseError=ParseError,exports$1.ParseErrorMessage=e,exports$1.ParseErrorWithToken=ParseErrorWithToken,exports$1.cloneTokens=function cloneTokens(e){return n?structuredClone(e):JSON.parse(JSON.stringify(e))},exports$1.isToken=function isToken(e){return !!Array.isArray(e)&&(!(e.length<4)&&(!!d.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))},exports$1.isTokenAtKeyword=function isTokenAtKeyword(e){return !!e&&e[0]===exports$1.TokenType.AtKeyword},exports$1.isTokenBadString=function isTokenBadString(e){return !!e&&e[0]===exports$1.TokenType.BadString},exports$1.isTokenBadURL=function isTokenBadURL(e){return !!e&&e[0]===exports$1.TokenType.BadURL},exports$1.isTokenCDC=function isTokenCDC(e){return !!e&&e[0]===exports$1.TokenType.CDC},exports$1.isTokenCDO=function isTokenCDO(e){return !!e&&e[0]===exports$1.TokenType.CDO},exports$1.isTokenCloseCurly=function isTokenCloseCurly(e){return !!e&&e[0]===exports$1.TokenType.CloseCurly},exports$1.isTokenCloseParen=function isTokenCloseParen(e){return !!e&&e[0]===exports$1.TokenType.CloseParen},exports$1.isTokenCloseSquare=function isTokenCloseSquare(e){return !!e&&e[0]===exports$1.TokenType.CloseSquare},exports$1.isTokenColon=function isTokenColon(e){return !!e&&e[0]===exports$1.TokenType.Colon},exports$1.isTokenComma=function isTokenComma(e){return !!e&&e[0]===exports$1.TokenType.Comma},exports$1.isTokenComment=function isTokenComment(e){return !!e&&e[0]===exports$1.TokenType.Comment},exports$1.isTokenDelim=function isTokenDelim(e){return !!e&&e[0]===exports$1.TokenType.Delim},exports$1.isTokenDimension=function isTokenDimension(e){return !!e&&e[0]===exports$1.TokenType.Dimension},exports$1.isTokenEOF=function isTokenEOF(e){return !!e&&e[0]===exports$1.TokenType.EOF},exports$1.isTokenFunction=function isTokenFunction(e){return !!e&&e[0]===exports$1.TokenType.Function},exports$1.isTokenHash=function isTokenHash(e){return !!e&&e[0]===exports$1.TokenType.Hash},exports$1.isTokenIdent=function isTokenIdent(e){return !!e&&e[0]===exports$1.TokenType.Ident},exports$1.isTokenNumber=function isTokenNumber(e){return !!e&&e[0]===exports$1.TokenType.Number},exports$1.isTokenNumeric=function isTokenNumeric(e){if(!e)return false;switch(e[0]){case exports$1.TokenType.Dimension:case exports$1.TokenType.Number:case exports$1.TokenType.Percentage:return true;default:return false}},exports$1.isTokenOpenCurly=function isTokenOpenCurly(e){return !!e&&e[0]===exports$1.TokenType.OpenCurly},exports$1.isTokenOpenParen=function isTokenOpenParen(e){return !!e&&e[0]===exports$1.TokenType.OpenParen},exports$1.isTokenOpenSquare=function isTokenOpenSquare(e){return !!e&&e[0]===exports$1.TokenType.OpenSquare},exports$1.isTokenPercentage=function isTokenPercentage(e){return !!e&&e[0]===exports$1.TokenType.Percentage},exports$1.isTokenSemicolon=function isTokenSemicolon(e){return !!e&&e[0]===exports$1.TokenType.Semicolon},exports$1.isTokenString=function isTokenString(e){return !!e&&e[0]===exports$1.TokenType.String},exports$1.isTokenURL=function isTokenURL(e){return !!e&&e[0]===exports$1.TokenType.URL},exports$1.isTokenUnicodeRange=function isTokenUnicodeRange(e){return !!e&&e[0]===exports$1.TokenType.UnicodeRange},exports$1.isTokenWhiteSpaceOrComment=function isTokenWhiteSpaceOrComment(e){if(!e)return false;switch(e[0]){case exports$1.TokenType.Whitespace:case exports$1.TokenType.Comment:return true;default:return false}},exports$1.isTokenWhitespace=function isTokenWhitespace(e){return !!e&&e[0]===exports$1.TokenType.Whitespace},exports$1.mirrorVariant=function mirrorVariant(e){switch(e[0]){case exports$1.TokenType.OpenParen:return [exports$1.TokenType.CloseParen,")",-1,-1,void 0];case exports$1.TokenType.CloseParen:return [exports$1.TokenType.OpenParen,"(",-1,-1,void 0];case exports$1.TokenType.OpenCurly:return [exports$1.TokenType.CloseCurly,"}",-1,-1,void 0];case exports$1.TokenType.CloseCurly:return [exports$1.TokenType.OpenCurly,"{",-1,-1,void 0];case exports$1.TokenType.OpenSquare:return [exports$1.TokenType.CloseSquare,"]",-1,-1,void 0];case exports$1.TokenType.CloseSquare:return [exports$1.TokenType.OpenSquare,"[",-1,-1,void 0];default:return null}},exports$1.mirrorVariantType=function mirrorVariantType(e){switch(e){case exports$1.TokenType.OpenParen:return exports$1.TokenType.CloseParen;case exports$1.TokenType.CloseParen:return exports$1.TokenType.OpenParen;case exports$1.TokenType.OpenCurly:return exports$1.TokenType.CloseCurly;case exports$1.TokenType.CloseCurly:return exports$1.TokenType.OpenCurly;case exports$1.TokenType.OpenSquare:return exports$1.TokenType.CloseSquare;case exports$1.TokenType.CloseSquare:return exports$1.TokenType.OpenSquare;default:return null}},exports$1.mutateIdent=function mutateIdent(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=String.fromCodePoint(...serializeIdent(o));e[1]=t,e[4].value=n;},exports$1.mutateUnit=function mutateUnit(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=serializeIdent(o);101===t[0]&&insertEscapedCodePoint(t,0,t[0]);const r=String.fromCodePoint(...t),s="+"===e[4].signCharacter?e[4].signCharacter:"",i=e[4].value.toString();e[1]=`${s}${i}${r}`,e[4].unit=n;},exports$1.stringify=function stringify(...e){let n="";for(let o=0;o<e.length;o++)n+=e[o][1];return n},exports$1.tokenize=function tokenize(e,n){const o=tokenizer(e,n),t=[];for(;!o.endOfFile();)t.push(o.nextToken());return t.push(o.nextToken()),t},exports$1.tokenizer=tokenizer;
|
|
2586
2612
|
} (dist));
|
|
2587
2613
|
return dist;
|
|
2588
2614
|
}
|
|
@@ -3858,36 +3884,36 @@ var hasRequiredProperties;
|
|
|
3858
3884
|
function requireProperties () {
|
|
3859
3885
|
if (hasRequiredProperties) return properties;
|
|
3860
3886
|
hasRequiredProperties = 1;
|
|
3861
|
-
(function (exports) {
|
|
3887
|
+
(function (exports$1) {
|
|
3862
3888
|
|
|
3863
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3889
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
3864
3890
|
value: true
|
|
3865
3891
|
});
|
|
3866
|
-
Object.defineProperty(exports, "BorderRadiusIndividual", {
|
|
3892
|
+
Object.defineProperty(exports$1, "BorderRadiusIndividual", {
|
|
3867
3893
|
enumerable: true,
|
|
3868
3894
|
get: function () {
|
|
3869
3895
|
return _borderRadius.BorderRadiusIndividual;
|
|
3870
3896
|
}
|
|
3871
3897
|
});
|
|
3872
|
-
Object.defineProperty(exports, "BorderRadiusShorthand", {
|
|
3898
|
+
Object.defineProperty(exports$1, "BorderRadiusShorthand", {
|
|
3873
3899
|
enumerable: true,
|
|
3874
3900
|
get: function () {
|
|
3875
3901
|
return _borderRadius.BorderRadiusShorthand;
|
|
3876
3902
|
}
|
|
3877
3903
|
});
|
|
3878
|
-
Object.defineProperty(exports, "BoxShadow", {
|
|
3904
|
+
Object.defineProperty(exports$1, "BoxShadow", {
|
|
3879
3905
|
enumerable: true,
|
|
3880
3906
|
get: function () {
|
|
3881
3907
|
return _boxShadow.BoxShadow;
|
|
3882
3908
|
}
|
|
3883
3909
|
});
|
|
3884
|
-
Object.defineProperty(exports, "BoxShadowList", {
|
|
3910
|
+
Object.defineProperty(exports$1, "BoxShadowList", {
|
|
3885
3911
|
enumerable: true,
|
|
3886
3912
|
get: function () {
|
|
3887
3913
|
return _boxShadow.BoxShadowList;
|
|
3888
3914
|
}
|
|
3889
3915
|
});
|
|
3890
|
-
Object.defineProperty(exports, "Transform", {
|
|
3916
|
+
Object.defineProperty(exports$1, "Transform", {
|
|
3891
3917
|
enumerable: true,
|
|
3892
3918
|
get: function () {
|
|
3893
3919
|
return _transform.Transform;
|
|
@@ -4512,22 +4538,22 @@ var hasRequiredLib$1;
|
|
|
4512
4538
|
function requireLib$1 () {
|
|
4513
4539
|
if (hasRequiredLib$1) return lib$1;
|
|
4514
4540
|
hasRequiredLib$1 = 1;
|
|
4515
|
-
(function (exports) {
|
|
4541
|
+
(function (exports$1) {
|
|
4516
4542
|
|
|
4517
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4543
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
4518
4544
|
value: true
|
|
4519
4545
|
});
|
|
4520
|
-
Object.defineProperty(exports, "lastMediaQueryWinsTransform", {
|
|
4546
|
+
Object.defineProperty(exports$1, "lastMediaQueryWinsTransform", {
|
|
4521
4547
|
enumerable: true,
|
|
4522
4548
|
get: function () {
|
|
4523
4549
|
return _mediaQueryTransform.lastMediaQueryWinsTransform;
|
|
4524
4550
|
}
|
|
4525
4551
|
});
|
|
4526
|
-
exports.tokenParser = exports.properties = void 0;
|
|
4552
|
+
exports$1.tokenParser = exports$1.properties = void 0;
|
|
4527
4553
|
var _tokenParser = _interopRequireWildcard(requireTokenParser());
|
|
4528
|
-
exports.tokenParser = _tokenParser;
|
|
4554
|
+
exports$1.tokenParser = _tokenParser;
|
|
4529
4555
|
var _properties = _interopRequireWildcard(requireProperties());
|
|
4530
|
-
exports.properties = _properties;
|
|
4556
|
+
exports$1.properties = _properties;
|
|
4531
4557
|
var _mediaQueryTransform = requireMediaQueryTransform();
|
|
4532
4558
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
4533
4559
|
} (lib$1));
|
|
@@ -4710,7 +4736,10 @@ const angles = ['deg', 'grad', 'turn', 'rad'];
|
|
|
4710
4736
|
const timings = ['ms', 's'];
|
|
4711
4737
|
const fraction = 'fr';
|
|
4712
4738
|
const percentage$1 = '%';
|
|
4713
|
-
function normalizeZeroDimensions(ast,
|
|
4739
|
+
function normalizeZeroDimensions(ast, key) {
|
|
4740
|
+
if (typeof key === 'string' && key.startsWith('--')) {
|
|
4741
|
+
return ast;
|
|
4742
|
+
}
|
|
4714
4743
|
let endFunction = 0;
|
|
4715
4744
|
ast.walk(node => {
|
|
4716
4745
|
if (node.type === 'function' && !endFunction) {
|
|
@@ -5155,6 +5184,15 @@ function requirePropertyPriorities () {
|
|
|
5155
5184
|
longHandPhysical.add('border-top-right-radius');
|
|
5156
5185
|
longHandPhysical.add('border-bottom-left-radius');
|
|
5157
5186
|
longHandPhysical.add('border-bottom-right-radius');
|
|
5187
|
+
shorthandsOfLonghands.add('corner-shape');
|
|
5188
|
+
longHandLogical.add('corner-start-start-shape');
|
|
5189
|
+
longHandLogical.add('corner-start-end-shape');
|
|
5190
|
+
longHandLogical.add('corner-end-start-shape');
|
|
5191
|
+
longHandLogical.add('corner-end-end-shape');
|
|
5192
|
+
longHandPhysical.add('corner-top-left-shape');
|
|
5193
|
+
longHandPhysical.add('corner-top-right-shape');
|
|
5194
|
+
longHandPhysical.add('corner-bottom-left-shape');
|
|
5195
|
+
longHandPhysical.add('corner-bottom-right-shape');
|
|
5158
5196
|
longHandLogical.add('box-shadow');
|
|
5159
5197
|
longHandLogical.add('accent-color');
|
|
5160
5198
|
longHandLogical.add('appearance');
|
|
@@ -6741,9 +6779,9 @@ function convertObjectToAST(obj) {
|
|
|
6741
6779
|
return objectExpression(Object.entries(obj).map(([key, value]) => objectProperty(isValidIdentifier(key, false) ? identifier(key) : stringLiteral(key), typeof value === 'string' ? stringLiteral(value) : typeof value === 'number' ? numericLiteral(value) : typeof value === 'boolean' ? booleanLiteral(value) : value === null ? nullLiteral() : convertObjectToAST(value))));
|
|
6742
6780
|
}
|
|
6743
6781
|
|
|
6744
|
-
const parseSync =
|
|
6782
|
+
const parseSync = packages.parser.parse;
|
|
6745
6783
|
|
|
6746
|
-
var traverse =
|
|
6784
|
+
var traverse = packages.traverse.default;
|
|
6747
6785
|
|
|
6748
6786
|
const IMPORT_FILE_PARSING_ERROR = `There was error when attempting to parse the imported file.
|
|
6749
6787
|
Please ensure that the 'babelrc' file is configured to be able to parse this file.
|
|
@@ -8504,7 +8542,7 @@ function parseNullableStyle$1(node, state) {
|
|
|
8504
8542
|
function makeStringExpression$1(values) {
|
|
8505
8543
|
const conditions = values.filter(v => Array.isArray(v)).map(v => v[0]);
|
|
8506
8544
|
if (conditions.length === 0) {
|
|
8507
|
-
return stringLiteral(
|
|
8545
|
+
return stringLiteral(legacyMerge(...values));
|
|
8508
8546
|
}
|
|
8509
8547
|
const conditionPermutations = genConditionPermutations$1(conditions.length);
|
|
8510
8548
|
const objEntries = conditionPermutations.map(permutation => {
|
|
@@ -8518,7 +8556,7 @@ function makeStringExpression$1(values) {
|
|
|
8518
8556
|
}
|
|
8519
8557
|
});
|
|
8520
8558
|
const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
|
|
8521
|
-
return objectProperty(numericLiteral(key), stringLiteral(
|
|
8559
|
+
return objectProperty(numericLiteral(key), stringLiteral(legacyMerge(...args)));
|
|
8522
8560
|
});
|
|
8523
8561
|
const objExpressions = objectExpression(objEntries);
|
|
8524
8562
|
const conditionsToKey = genBitwiseOrOfConditions$1(conditions);
|
|
@@ -8767,7 +8805,7 @@ function parseNullableStyle(path, state, evaluatePathFnConfig) {
|
|
|
8767
8805
|
function makeStringExpression(values) {
|
|
8768
8806
|
const conditions = values.filter(v => v instanceof ConditionalStyle).map(v => v.test);
|
|
8769
8807
|
if (conditions.length === 0) {
|
|
8770
|
-
const result =
|
|
8808
|
+
const result = props(values);
|
|
8771
8809
|
return convertObjectToAST(result);
|
|
8772
8810
|
}
|
|
8773
8811
|
const conditionPermutations = genConditionPermutations(conditions.length);
|
|
@@ -8785,7 +8823,7 @@ function makeStringExpression(values) {
|
|
|
8785
8823
|
}
|
|
8786
8824
|
});
|
|
8787
8825
|
const key = permutation.reduce((soFar, bool) => soFar << 1 | (bool ? 1 : 0), 0);
|
|
8788
|
-
return objectProperty(numericLiteral(key), convertObjectToAST(
|
|
8826
|
+
return objectProperty(numericLiteral(key), convertObjectToAST(props(args)));
|
|
8789
8827
|
});
|
|
8790
8828
|
const objExpressions = objectExpression(objEntries);
|
|
8791
8829
|
const conditionsToKey = genBitwiseOrOfConditions(conditions);
|
|
@@ -9363,4 +9401,4 @@ function addSpecificityLevel(selector, index) {
|
|
|
9363
9401
|
return `${beforeCurly}${pseudo}${afterCurly}`;
|
|
9364
9402
|
}
|
|
9365
9403
|
|
|
9366
|
-
|
|
9404
|
+
export { styleXTransform as default };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
2
7
|
/**
|
|
3
8
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
9
|
*
|
package/lib/index.js
CHANGED
|
@@ -327,6 +327,7 @@ const defaultOptions = {
|
|
|
327
327
|
classNamePrefix: 'x',
|
|
328
328
|
dev: false,
|
|
329
329
|
debug: false,
|
|
330
|
+
propertyValidationMode: 'silent',
|
|
330
331
|
enableDebugClassNames: false,
|
|
331
332
|
enableDevClassNames: false,
|
|
332
333
|
enableDebugDataProp: true,
|
|
@@ -418,6 +419,7 @@ class StateManager {
|
|
|
418
419
|
const configuredImportSources = logAndDefault(checkImportSources, options.importSources ?? defaultOptions.importSources, [], 'options.importSources');
|
|
419
420
|
const importSources = [name, 'stylex', ...configuredImportSources];
|
|
420
421
|
const styleResolution = logAndDefault(unionOf3(literal('application-order'), literal('property-specificity'), literal('legacy-expand-shorthands')), options.styleResolution ?? defaultOptions.styleResolution, 'property-specificity', 'options.styleResolution');
|
|
422
|
+
const propertyValidationMode = logAndDefault(unionOf3(literal('throw'), literal('warn'), literal('silent')), options.propertyValidationMode ?? defaultOptions.propertyValidationMode, 'silent', 'options.propertyValidationMode');
|
|
421
423
|
const unstable_moduleResolution = logAndDefault(unionOf(nullish(), CheckModuleResolution), options.unstable_moduleResolution, null, 'options.unstable_moduleResolution');
|
|
422
424
|
const treeshakeCompensation = logAndDefault(boolean(), options.treeshakeCompensation ?? defaultOptions.treeshakeCompensation, false, 'options.treeshakeCompensation');
|
|
423
425
|
const aliasesOption = logAndDefault(unionOf(nullish(), objectOf(unionOf(string(), array(string())))), options.aliases, null, 'options.aliases');
|
|
@@ -434,6 +436,7 @@ class StateManager {
|
|
|
434
436
|
debug,
|
|
435
437
|
definedStylexCSSVariables: {},
|
|
436
438
|
dev,
|
|
439
|
+
propertyValidationMode,
|
|
437
440
|
enableDebugClassNames,
|
|
438
441
|
enableDebugDataProp,
|
|
439
442
|
enableDevClassNames,
|
|
@@ -954,6 +957,15 @@ const shorthands$2 = {
|
|
|
954
957
|
borderTopRightRadius: value => [['borderTopRightRadius', value], ['borderStartStartRadius', null], ['borderStartEndRadius', null]],
|
|
955
958
|
borderBottomLeftRadius: value => [['borderBottomLeftRadius', value], ['borderEndStartRadius', null], ['borderEndEndRadius', null]],
|
|
956
959
|
borderBottomRightRadius: value => [['borderBottomRightRadius', value], ['borderEndStartRadius', null], ['borderEndEndRadius', null]],
|
|
960
|
+
cornerShape: value => [['cornerShape', value], ['cornerStartStartShape', null], ['cornerStartEndShape', null], ['cornerEndStartShape', null], ['cornerEndEndShape', null], ['cornerTopLeftShape', null], ['cornerTopRightShape', null], ['cornerBottomLeftShape', null], ['cornerBottomRightShape', null]],
|
|
961
|
+
cornerStartStartShape: value => [['cornerStartStartShape', value], ['cornerTopLeftShape', null], ['cornerTopRightShape', null]],
|
|
962
|
+
cornerStartEndShape: value => [['cornerStartEndShape', value], ['cornerTopLeftShape', null], ['cornerTopRightShape', null]],
|
|
963
|
+
cornerEndStartShape: value => [['cornerEndStartShape', value], ['cornerBottomLeftShape', null], ['cornerBottomRightShape', null]],
|
|
964
|
+
cornerEndEndShape: value => [['cornerEndEndShape', value], ['cornerBottomLeftShape', null], ['cornerBottomRightShape', null]],
|
|
965
|
+
cornerTopLeftShape: value => [['cornerTopLeftShape', value], ['cornerStartStartShape', null], ['cornerStartEndShape', null]],
|
|
966
|
+
cornerTopRightShape: value => [['cornerTopRightShape', value], ['cornerStartStartShape', null], ['cornerStartEndShape', null]],
|
|
967
|
+
cornerBottomLeftShape: value => [['cornerBottomLeftShape', value], ['cornerEndStartShape', null], ['cornerEndEndShape', null]],
|
|
968
|
+
cornerBottomRightShape: value => [['cornerBottomRightShape', value], ['cornerEndStartShape', null], ['cornerEndEndShape', null]],
|
|
957
969
|
borderImage: value => [['borderImage', value], ['borderImageOutset', null], ['borderImageRepeat', null], ['borderImageSlice', null], ['borderImageSource', null], ['borderImageWidth', null]],
|
|
958
970
|
columnRule: value => [['columnRule', value], ['columnRuleColor', null], ['columnRuleStyle', null], ['columnRuleWidth', null]],
|
|
959
971
|
columns: value => [['columns', value], ['columnCount', null], ['columnWidth', null]],
|
|
@@ -1451,7 +1463,19 @@ function flatMapExpandedShorthands(objEntry, options) {
|
|
|
1451
1463
|
if (Array.isArray(value)) {
|
|
1452
1464
|
throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
|
|
1453
1465
|
}
|
|
1454
|
-
|
|
1466
|
+
try {
|
|
1467
|
+
return expansion(value);
|
|
1468
|
+
} catch (error) {
|
|
1469
|
+
const validationMode = options.propertyValidationMode ?? 'silent';
|
|
1470
|
+
if (validationMode === 'throw') {
|
|
1471
|
+
throw error;
|
|
1472
|
+
} else if (validationMode === 'warn') {
|
|
1473
|
+
console.warn(`[stylex] ${error.message}`);
|
|
1474
|
+
return [];
|
|
1475
|
+
} else {
|
|
1476
|
+
return [];
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1455
1479
|
}
|
|
1456
1480
|
return [[key, value]];
|
|
1457
1481
|
}
|
|
@@ -1469,8 +1493,8 @@ var hasRequiredDist;
|
|
|
1469
1493
|
function requireDist () {
|
|
1470
1494
|
if (hasRequiredDist) return dist;
|
|
1471
1495
|
hasRequiredDist = 1;
|
|
1472
|
-
(function (exports) {
|
|
1473
|
-
class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=t;}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,o,t,r){super(e,n,o,t),this.token=r;}}const e={UnexpectedNewLineInString:"Unexpected newline while consuming a string token.",UnexpectedEOFInString:"Unexpected EOF while consuming a string token.",UnexpectedEOFInComment:"Unexpected EOF while consuming a comment.",UnexpectedEOFInURL:"Unexpected EOF while consuming a url token.",UnexpectedEOFInEscapedCodePoint:"Unexpected EOF while consuming an escaped code point.",UnexpectedCharacterInURL:"Unexpected character while consuming a url token.",InvalidEscapeSequenceInURL:"Invalid escape sequence while consuming a url token.",InvalidEscapeSequenceAfterBackslash:'Invalid escape sequence after "\\"'},n="undefined"!=typeof globalThis&&"structuredClone"in globalThis;const o=13,t=45,r=10,s=43,i=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===t&&e.source.codePointAt(e.cursor+3)===t}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||95===e}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===t}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||(0===e||(!!isSurrogate(e)||e>=65536)))}function isNewLine(e){return e===r||e===o||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===o||12===e}function isSurrogate(e){return e>=55296&&e<=57343}function checkIfTwoCodePointsAreAValidEscape(e){return 92===e.source.codePointAt(e.cursor)&&!isNewLine(e.source.codePointAt(e.cursor+1)??-1)}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.source.codePointAt(n.cursor)===t?n.source.codePointAt(n.cursor+1)===t||(!!isIdentStartCodePoint(n.source.codePointAt(n.cursor+1)??-1)||92===n.source.codePointAt(n.cursor+1)&&!isNewLine(n.source.codePointAt(n.cursor+2)??-1)):!!isIdentStartCodePoint(n.source.codePointAt(n.cursor)??-1)||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.source.codePointAt(e.cursor)===s||e.source.codePointAt(e.cursor)===t?!!isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1)||46===e.source.codePointAt(e.cursor+1)&&isDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1):46===e.source.codePointAt(e.cursor)?isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1):isDigitCodePoint(e.source.codePointAt(e.cursor)??-1)}function checkIfTwoCodePointsStartAComment(e){return 47===e.source.codePointAt(e.cursor)&&42===e.source.codePointAt(e.cursor+1)}function checkIfThreeCodePointsWouldStartCDC(e){return e.source.codePointAt(e.cursor)===t&&e.source.codePointAt(e.cursor+1)===t&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function consumeComment(n,o){for(o.advanceCodePoint(2);;){const t=o.readCodePoint();if(void 0===t){const t=[exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],t)),t}if(42===t&&(void 0!==o.source.codePointAt(o.cursor)&&47===o.source.codePointAt(o.cursor))){o.advanceCodePoint();break}}return [exports.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(n,t){const s=t.readCodePoint();if(void 0===s)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),i;if(isHexDigitCodePoint(s)){const e=[s];let n;for(;void 0!==(n=t.source.codePointAt(t.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?i:c}return 0===s||isSurrogate(s)?i:s}function consumeIdentSequence(e,n){const o=[];for(;;){const t=n.source.codePointAt(n.cursor)??-1;if(0===t||isSurrogate(t))o.push(i),n.advanceCodePoint(+(t>65535)+1);else if(isIdentCodePoint(t))o.push(t),n.advanceCodePoint(+(t>65535)+1);else {if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n));}}}function consumeHashToken(e,n){n.advanceCodePoint();const o=n.source.codePointAt(n.cursor);if(void 0!==o&&(isIdentCodePoint(o)||checkIfTwoCodePointsAreAValidEscape(n))){let o=exports.HashType.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(o=exports.HashType.ID);const t=consumeIdentSequence(e,n);return [exports.TokenType.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t),type:o}]}return [exports.TokenType.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let o=exports.NumberType.Integer;for(n.source.codePointAt(n.cursor)!==s&&n.source.codePointAt(n.cursor)!==t||n.advanceCodePoint();isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(46===n.source.codePointAt(n.cursor)&&isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint(2),o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(101===n.source.codePointAt(n.cursor)||69===n.source.codePointAt(n.cursor)){if(isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))n.advanceCodePoint(2);else {if(n.source.codePointAt(n.cursor+1)!==t&&n.source.codePointAt(n.cursor+1)!==s||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return o;n.advanceCodePoint(3);}for(o=exports.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();}return o}function consumeNumericToken(e,n){let o;{const e=n.source.codePointAt(n.cursor);e===t?o="-":e===s&&(o="+");}const r=consumeNumber(0,n),i=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const t=consumeIdentSequence(e,n);return [exports.TokenType.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r,unit:String.fromCodePoint(...t)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[exports.TokenType.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o}]):[exports.TokenType.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return [exports.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}exports.TokenType=void 0,(c=exports.TokenType||(exports.TokenType={})).Comment="comment",c.AtKeyword="at-keyword-token",c.BadString="bad-string-token",c.BadURL="bad-url-token",c.CDC="CDC-token",c.CDO="CDO-token",c.Colon="colon-token",c.Comma="comma-token",c.Delim="delim-token",c.Dimension="dimension-token",c.EOF="EOF-token",c.Function="function-token",c.Hash="hash-token",c.Ident="ident-token",c.Number="number-token",c.Percentage="percentage-token",c.Semicolon="semicolon-token",c.String="string-token",c.URL="url-token",c.Whitespace="whitespace-token",c.OpenParen="(-token",c.CloseParen=")-token",c.OpenSquare="[-token",c.CloseSquare="]-token",c.OpenCurly="{-token",c.CloseCurly="}-token",c.UnicodeRange="unicode-range-token",exports.NumberType=void 0,(a=exports.NumberType||(exports.NumberType={})).Integer="integer",a.Number="number",exports.HashType=void 0,(u=exports.HashType||(exports.HashType={})).Unrestricted="unrestricted",u.ID="id";class Reader{cursor=0;source="";representationStart=0;representationEnd=-1;constructor(e){this.source=e;}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.cursor-1;}readCodePoint(){const e=this.source.codePointAt(this.cursor);if(void 0!==e)return this.cursor=this.cursor+1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.cursor-1;}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1;}}function consumeStringToken(n,t){let s="";const c=t.readCodePoint();for(;;){const a=t.readCodePoint();if(void 0===a){const o=[exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,t.representationStart,t.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],o)),o}if(isNewLine(a)){t.unreadCodePoint();const s=[exports.TokenType.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r?t.representationEnd+2:t.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],s)),s}if(a===c)return [exports.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];if(92!==a)0===a||isSurrogate(a)?s+=String.fromCodePoint(i):s+=String.fromCodePoint(a);else {if(void 0===t.source.codePointAt(t.cursor))continue;if(isNewLine(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint();continue}s+=String.fromCodePoint(consumeEscapedCodePoint(n,t));}}}function checkIfCodePointsMatchURLIdent(e){return !(3!==e.length||117!==e[0]&&85!==e[0]||114!==e[1]&&82!==e[1]||108!==e[2]&&76!==e[2])}function consumeBadURL(e,n){for(;;){const o=n.source.codePointAt(n.cursor);if(void 0===o)return;if(41===o)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint();}}function consumeUrlToken(n,o){for(;isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();let t="";for(;;){if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===o.source.codePointAt(o.cursor))return o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];if(isWhitespace(o.source.codePointAt(o.cursor)??-1)){for(o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();if(void 0===o.source.codePointAt(o.cursor)){const r=[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===o.source.codePointAt(o.cursor)?(o.advanceCodePoint(),[exports.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}]):(consumeBadURL(n,o),[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}const s=o.source.codePointAt(o.cursor);if(34===s||39===s||40===s||(11===(r=s??-1)||127===r||0<=r&&r<=8||14<=r&&r<=31)){consumeBadURL(n,o);const t=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"],t)),t}if(92===s){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),t+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}consumeBadURL(n,o);const r=[exports.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],r)),r}0===o.source.codePointAt(o.cursor)||isSurrogate(o.source.codePointAt(o.cursor)??-1)?(t+=String.fromCodePoint(i),o.advanceCodePoint()):(t+=o.source[o.cursor],o.advanceCodePoint());}var r;}function consumeIdentLikeToken(e,n){const o=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return [exports.TokenType.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];if(checkIfCodePointsMatchURLIdent(o)){n.advanceCodePoint();let t=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){t+=1,n.advanceCodePoint(1);continue}const s=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===s||39===s)return t>0&&n.unreadCodePoint(t),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[exports.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return !(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==s||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const o=[],r=[];let s;for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&isHexDigitCodePoint(s);)o.push(s),n.advanceCodePoint();for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&63===s;)0===r.length&&r.push(...o),o.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===t&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(s=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(s);)r.push(s),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...o),16);return [exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const i=parseInt(String.fromCodePoint(...o),16),c=parseInt(String.fromCodePoint(...r),16);return [exports.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenizer(n,i){const c=n.css.valueOf(),a=n.unicodeRangesAllowed??false,u=new Reader(c),d={onParseError:i?.onParseError??noop};return {nextToken:function nextToken(){u.resetRepresentation();const n=u.source.codePointAt(u.cursor);if(void 0===n)return [exports.TokenType.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(u))return consumeComment(d,u);if(a&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(u))return consumeUnicodeRangeToken(0,u);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(d,u);if(isDigitCodePoint(n))return consumeNumericToken(d,u);switch(n){case 44:return u.advanceCodePoint(),[exports.TokenType.Comma,",",u.representationStart,u.representationEnd,void 0];case 58:return u.advanceCodePoint(),[exports.TokenType.Colon,":",u.representationStart,u.representationEnd,void 0];case 59:return u.advanceCodePoint(),[exports.TokenType.Semicolon,";",u.representationStart,u.representationEnd,void 0];case 40:return u.advanceCodePoint(),[exports.TokenType.OpenParen,"(",u.representationStart,u.representationEnd,void 0];case 41:return u.advanceCodePoint(),[exports.TokenType.CloseParen,")",u.representationStart,u.representationEnd,void 0];case 91:return u.advanceCodePoint(),[exports.TokenType.OpenSquare,"[",u.representationStart,u.representationEnd,void 0];case 93:return u.advanceCodePoint(),[exports.TokenType.CloseSquare,"]",u.representationStart,u.representationEnd,void 0];case 123:return u.advanceCodePoint(),[exports.TokenType.OpenCurly,"{",u.representationStart,u.representationEnd,void 0];case 125:return u.advanceCodePoint(),[exports.TokenType.CloseCurly,"}",u.representationStart,u.representationEnd,void 0];case 39:case 34:return consumeStringToken(d,u);case 35:return consumeHashToken(d,u);case s:case 46:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]);case r:case o:case 12:case 9:case 32:return consumeWhiteSpace(u);case t:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):checkIfThreeCodePointsWouldStartCDC(u)?(u.advanceCodePoint(3),[exports.TokenType.CDC,"--\x3e",u.representationStart,u.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)?consumeIdentLikeToken(d,u):(u.advanceCodePoint(),[exports.TokenType.Delim,"-",u.representationStart,u.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(u)?(u.advanceCodePoint(4),[exports.TokenType.CDO,"\x3c!--",u.representationStart,u.representationEnd,void 0]):(u.advanceCodePoint(),[exports.TokenType.Delim,"<",u.representationStart,u.representationEnd,{value:"<"}]);case 64:if(u.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)){const e=consumeIdentSequence(d,u);return [exports.TokenType.AtKeyword,u.source.slice(u.representationStart,u.representationEnd+1),u.representationStart,u.representationEnd,{value:String.fromCodePoint(...e)}]}return [exports.TokenType.Delim,"@",u.representationStart,u.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(u))return consumeIdentLikeToken(d,u);u.advanceCodePoint();const n=[exports.TokenType.Delim,"\\",u.representationStart,u.representationEnd,{value:"\\"}];return d.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,u.representationStart,u.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],n)),n}}return u.advanceCodePoint(),[exports.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]},endOfFile:function endOfFile(){return void 0===u.source.codePointAt(u.cursor)}}}function noop(){}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,i),n=1;else if(e[0]===t&&e[1]===t)n=2;else if(e[0]===t&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else {if(e[0]===t&&!e[1])return [92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]));}for(let o=n;o<e.length;o++)0!==e[o]?isIdentCodePoint(e[o])||(o+=insertEscapedCharacter(e,o,e[o])):(e.splice(o,1,i),o++);return e}function insertEscapedCharacter(e,n,o){return e.splice(n,1,92,o),1}function insertEscapedCodePoint(e,n,o){const t=o.toString(16),r=[];for(const e of t)r.push(e.codePointAt(0));return e.splice(n,1,92,...r,32),1+r.length}const d=Object.values(exports.TokenType);exports.ParseError=ParseError,exports.ParseErrorMessage=e,exports.ParseErrorWithToken=ParseErrorWithToken,exports.cloneTokens=function cloneTokens(e){return n?structuredClone(e):JSON.parse(JSON.stringify(e))},exports.isToken=function isToken(e){return !!Array.isArray(e)&&(!(e.length<4)&&(!!d.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))},exports.isTokenAtKeyword=function isTokenAtKeyword(e){return !!e&&e[0]===exports.TokenType.AtKeyword},exports.isTokenBadString=function isTokenBadString(e){return !!e&&e[0]===exports.TokenType.BadString},exports.isTokenBadURL=function isTokenBadURL(e){return !!e&&e[0]===exports.TokenType.BadURL},exports.isTokenCDC=function isTokenCDC(e){return !!e&&e[0]===exports.TokenType.CDC},exports.isTokenCDO=function isTokenCDO(e){return !!e&&e[0]===exports.TokenType.CDO},exports.isTokenCloseCurly=function isTokenCloseCurly(e){return !!e&&e[0]===exports.TokenType.CloseCurly},exports.isTokenCloseParen=function isTokenCloseParen(e){return !!e&&e[0]===exports.TokenType.CloseParen},exports.isTokenCloseSquare=function isTokenCloseSquare(e){return !!e&&e[0]===exports.TokenType.CloseSquare},exports.isTokenColon=function isTokenColon(e){return !!e&&e[0]===exports.TokenType.Colon},exports.isTokenComma=function isTokenComma(e){return !!e&&e[0]===exports.TokenType.Comma},exports.isTokenComment=function isTokenComment(e){return !!e&&e[0]===exports.TokenType.Comment},exports.isTokenDelim=function isTokenDelim(e){return !!e&&e[0]===exports.TokenType.Delim},exports.isTokenDimension=function isTokenDimension(e){return !!e&&e[0]===exports.TokenType.Dimension},exports.isTokenEOF=function isTokenEOF(e){return !!e&&e[0]===exports.TokenType.EOF},exports.isTokenFunction=function isTokenFunction(e){return !!e&&e[0]===exports.TokenType.Function},exports.isTokenHash=function isTokenHash(e){return !!e&&e[0]===exports.TokenType.Hash},exports.isTokenIdent=function isTokenIdent(e){return !!e&&e[0]===exports.TokenType.Ident},exports.isTokenNumber=function isTokenNumber(e){return !!e&&e[0]===exports.TokenType.Number},exports.isTokenNumeric=function isTokenNumeric(e){if(!e)return false;switch(e[0]){case exports.TokenType.Dimension:case exports.TokenType.Number:case exports.TokenType.Percentage:return true;default:return false}},exports.isTokenOpenCurly=function isTokenOpenCurly(e){return !!e&&e[0]===exports.TokenType.OpenCurly},exports.isTokenOpenParen=function isTokenOpenParen(e){return !!e&&e[0]===exports.TokenType.OpenParen},exports.isTokenOpenSquare=function isTokenOpenSquare(e){return !!e&&e[0]===exports.TokenType.OpenSquare},exports.isTokenPercentage=function isTokenPercentage(e){return !!e&&e[0]===exports.TokenType.Percentage},exports.isTokenSemicolon=function isTokenSemicolon(e){return !!e&&e[0]===exports.TokenType.Semicolon},exports.isTokenString=function isTokenString(e){return !!e&&e[0]===exports.TokenType.String},exports.isTokenURL=function isTokenURL(e){return !!e&&e[0]===exports.TokenType.URL},exports.isTokenUnicodeRange=function isTokenUnicodeRange(e){return !!e&&e[0]===exports.TokenType.UnicodeRange},exports.isTokenWhiteSpaceOrComment=function isTokenWhiteSpaceOrComment(e){if(!e)return false;switch(e[0]){case exports.TokenType.Whitespace:case exports.TokenType.Comment:return true;default:return false}},exports.isTokenWhitespace=function isTokenWhitespace(e){return !!e&&e[0]===exports.TokenType.Whitespace},exports.mirrorVariant=function mirrorVariant(e){switch(e[0]){case exports.TokenType.OpenParen:return [exports.TokenType.CloseParen,")",-1,-1,void 0];case exports.TokenType.CloseParen:return [exports.TokenType.OpenParen,"(",-1,-1,void 0];case exports.TokenType.OpenCurly:return [exports.TokenType.CloseCurly,"}",-1,-1,void 0];case exports.TokenType.CloseCurly:return [exports.TokenType.OpenCurly,"{",-1,-1,void 0];case exports.TokenType.OpenSquare:return [exports.TokenType.CloseSquare,"]",-1,-1,void 0];case exports.TokenType.CloseSquare:return [exports.TokenType.OpenSquare,"[",-1,-1,void 0];default:return null}},exports.mirrorVariantType=function mirrorVariantType(e){switch(e){case exports.TokenType.OpenParen:return exports.TokenType.CloseParen;case exports.TokenType.CloseParen:return exports.TokenType.OpenParen;case exports.TokenType.OpenCurly:return exports.TokenType.CloseCurly;case exports.TokenType.CloseCurly:return exports.TokenType.OpenCurly;case exports.TokenType.OpenSquare:return exports.TokenType.CloseSquare;case exports.TokenType.CloseSquare:return exports.TokenType.OpenSquare;default:return null}},exports.mutateIdent=function mutateIdent(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=String.fromCodePoint(...serializeIdent(o));e[1]=t,e[4].value=n;},exports.mutateUnit=function mutateUnit(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=serializeIdent(o);101===t[0]&&insertEscapedCodePoint(t,0,t[0]);const r=String.fromCodePoint(...t),s="+"===e[4].signCharacter?e[4].signCharacter:"",i=e[4].value.toString();e[1]=`${s}${i}${r}`,e[4].unit=n;},exports.stringify=function stringify(...e){let n="";for(let o=0;o<e.length;o++)n+=e[o][1];return n},exports.tokenize=function tokenize(e,n){const o=tokenizer(e,n),t=[];for(;!o.endOfFile();)t.push(o.nextToken());return t.push(o.nextToken()),t},exports.tokenizer=tokenizer;
|
|
1496
|
+
(function (exports$1) {
|
|
1497
|
+
class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,o,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=o,this.parserState=t;}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,o,t,r){super(e,n,o,t),this.token=r;}}const e={UnexpectedNewLineInString:"Unexpected newline while consuming a string token.",UnexpectedEOFInString:"Unexpected EOF while consuming a string token.",UnexpectedEOFInComment:"Unexpected EOF while consuming a comment.",UnexpectedEOFInURL:"Unexpected EOF while consuming a url token.",UnexpectedEOFInEscapedCodePoint:"Unexpected EOF while consuming an escaped code point.",UnexpectedCharacterInURL:"Unexpected character while consuming a url token.",InvalidEscapeSequenceInURL:"Invalid escape sequence while consuming a url token.",InvalidEscapeSequenceAfterBackslash:'Invalid escape sequence after "\\"'},n="undefined"!=typeof globalThis&&"structuredClone"in globalThis;const o=13,t=45,r=10,s=43,i=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===t&&e.source.codePointAt(e.cursor+3)===t}function isDigitCodePoint(e){return e>=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCII_IdentCodePoint(e)||95===e}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===t}function isNonASCII_IdentCodePoint(e){return 183===e||8204===e||8205===e||8255===e||8256===e||8204===e||(192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||(0===e||(!!isSurrogate(e)||e>=65536)))}function isNewLine(e){return e===r||e===o||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===o||12===e}function isSurrogate(e){return e>=55296&&e<=57343}function checkIfTwoCodePointsAreAValidEscape(e){return 92===e.source.codePointAt(e.cursor)&&!isNewLine(e.source.codePointAt(e.cursor+1)??-1)}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.source.codePointAt(n.cursor)===t?n.source.codePointAt(n.cursor+1)===t||(!!isIdentStartCodePoint(n.source.codePointAt(n.cursor+1)??-1)||92===n.source.codePointAt(n.cursor+1)&&!isNewLine(n.source.codePointAt(n.cursor+2)??-1)):!!isIdentStartCodePoint(n.source.codePointAt(n.cursor)??-1)||checkIfTwoCodePointsAreAValidEscape(n)}function checkIfThreeCodePointsWouldStartANumber(e){return e.source.codePointAt(e.cursor)===s||e.source.codePointAt(e.cursor)===t?!!isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1)||46===e.source.codePointAt(e.cursor+1)&&isDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1):46===e.source.codePointAt(e.cursor)?isDigitCodePoint(e.source.codePointAt(e.cursor+1)??-1):isDigitCodePoint(e.source.codePointAt(e.cursor)??-1)}function checkIfTwoCodePointsStartAComment(e){return 47===e.source.codePointAt(e.cursor)&&42===e.source.codePointAt(e.cursor+1)}function checkIfThreeCodePointsWouldStartCDC(e){return e.source.codePointAt(e.cursor)===t&&e.source.codePointAt(e.cursor+1)===t&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function consumeComment(n,o){for(o.advanceCodePoint(2);;){const t=o.readCodePoint();if(void 0===t){const t=[exports$1.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,o.representationStart,o.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],t)),t}if(42===t&&(void 0!==o.source.codePointAt(o.cursor)&&47===o.source.codePointAt(o.cursor))){o.advanceCodePoint();break}}return [exports$1.TokenType.Comment,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0]}function consumeEscapedCodePoint(n,t){const s=t.readCodePoint();if(void 0===s)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),i;if(isHexDigitCodePoint(s)){const e=[s];let n;for(;void 0!==(n=t.source.codePointAt(t.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?i:c}return 0===s||isSurrogate(s)?i:s}function consumeIdentSequence(e,n){const o=[];for(;;){const t=n.source.codePointAt(n.cursor)??-1;if(0===t||isSurrogate(t))o.push(i),n.advanceCodePoint(+(t>65535)+1);else if(isIdentCodePoint(t))o.push(t),n.advanceCodePoint(+(t>65535)+1);else {if(!checkIfTwoCodePointsAreAValidEscape(n))return o;n.advanceCodePoint(),o.push(consumeEscapedCodePoint(e,n));}}}function consumeHashToken(e,n){n.advanceCodePoint();const o=n.source.codePointAt(n.cursor);if(void 0!==o&&(isIdentCodePoint(o)||checkIfTwoCodePointsAreAValidEscape(n))){let o=exports$1.HashType.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(o=exports$1.HashType.ID);const t=consumeIdentSequence(e,n);return [exports$1.TokenType.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t),type:o}]}return [exports$1.TokenType.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let o=exports$1.NumberType.Integer;for(n.source.codePointAt(n.cursor)!==s&&n.source.codePointAt(n.cursor)!==t||n.advanceCodePoint();isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(46===n.source.codePointAt(n.cursor)&&isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint(2),o=exports$1.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();if(101===n.source.codePointAt(n.cursor)||69===n.source.codePointAt(n.cursor)){if(isDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))n.advanceCodePoint(2);else {if(n.source.codePointAt(n.cursor+1)!==t&&n.source.codePointAt(n.cursor+1)!==s||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return o;n.advanceCodePoint(3);}for(o=exports$1.NumberType.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint();}return o}function consumeNumericToken(e,n){let o;{const e=n.source.codePointAt(n.cursor);e===t?o="-":e===s&&(o="+");}const r=consumeNumber(0,n),i=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const t=consumeIdentSequence(e,n);return [exports$1.TokenType.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r,unit:String.fromCodePoint(...t)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[exports$1.TokenType.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o}]):[exports$1.TokenType.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:i,signCharacter:o,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return [exports$1.TokenType.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}exports$1.TokenType=void 0,(c=exports$1.TokenType||(exports$1.TokenType={})).Comment="comment",c.AtKeyword="at-keyword-token",c.BadString="bad-string-token",c.BadURL="bad-url-token",c.CDC="CDC-token",c.CDO="CDO-token",c.Colon="colon-token",c.Comma="comma-token",c.Delim="delim-token",c.Dimension="dimension-token",c.EOF="EOF-token",c.Function="function-token",c.Hash="hash-token",c.Ident="ident-token",c.Number="number-token",c.Percentage="percentage-token",c.Semicolon="semicolon-token",c.String="string-token",c.URL="url-token",c.Whitespace="whitespace-token",c.OpenParen="(-token",c.CloseParen=")-token",c.OpenSquare="[-token",c.CloseSquare="]-token",c.OpenCurly="{-token",c.CloseCurly="}-token",c.UnicodeRange="unicode-range-token",exports$1.NumberType=void 0,(a=exports$1.NumberType||(exports$1.NumberType={})).Integer="integer",a.Number="number",exports$1.HashType=void 0,(u=exports$1.HashType||(exports$1.HashType={})).Unrestricted="unrestricted",u.ID="id";class Reader{cursor=0;source="";representationStart=0;representationEnd=-1;constructor(e){this.source=e;}advanceCodePoint(e=1){this.cursor=this.cursor+e,this.representationEnd=this.cursor-1;}readCodePoint(){const e=this.source.codePointAt(this.cursor);if(void 0!==e)return this.cursor=this.cursor+1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor=this.cursor-e,this.representationEnd=this.cursor-1;}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1;}}function consumeStringToken(n,t){let s="";const c=t.readCodePoint();for(;;){const a=t.readCodePoint();if(void 0===a){const o=[exports$1.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,t.representationStart,t.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],o)),o}if(isNewLine(a)){t.unreadCodePoint();const s=[exports$1.TokenType.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r?t.representationEnd+2:t.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],s)),s}if(a===c)return [exports$1.TokenType.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:s}];if(92!==a)0===a||isSurrogate(a)?s+=String.fromCodePoint(i):s+=String.fromCodePoint(a);else {if(void 0===t.source.codePointAt(t.cursor))continue;if(isNewLine(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===o&&t.source.codePointAt(t.cursor+1)===r&&t.advanceCodePoint(),t.advanceCodePoint();continue}s+=String.fromCodePoint(consumeEscapedCodePoint(n,t));}}}function checkIfCodePointsMatchURLIdent(e){return !(3!==e.length||117!==e[0]&&85!==e[0]||114!==e[1]&&82!==e[1]||108!==e[2]&&76!==e[2])}function consumeBadURL(e,n){for(;;){const o=n.source.codePointAt(n.cursor);if(void 0===o)return;if(41===o)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint();}}function consumeUrlToken(n,o){for(;isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();let t="";for(;;){if(void 0===o.source.codePointAt(o.cursor)){const r=[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===o.source.codePointAt(o.cursor))return o.advanceCodePoint(),[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];if(isWhitespace(o.source.codePointAt(o.cursor)??-1)){for(o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1);)o.advanceCodePoint();if(void 0===o.source.codePointAt(o.cursor)){const r=[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===o.source.codePointAt(o.cursor)?(o.advanceCodePoint(),[exports$1.TokenType.URL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:t}]):(consumeBadURL(n,o),[exports$1.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0])}const s=o.source.codePointAt(o.cursor);if(34===s||39===s||40===s||(11===(r=s??-1)||127===r||0<=r&&r<=8||14<=r&&r<=31)){consumeBadURL(n,o);const t=[exports$1.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"],t)),t}if(92===s){if(checkIfTwoCodePointsAreAValidEscape(o)){o.advanceCodePoint(),t+=String.fromCodePoint(consumeEscapedCodePoint(n,o));continue}consumeBadURL(n,o);const r=[exports$1.TokenType.BadURL,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,o.representationStart,o.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],r)),r}0===o.source.codePointAt(o.cursor)||isSurrogate(o.source.codePointAt(o.cursor)??-1)?(t+=String.fromCodePoint(i),o.advanceCodePoint()):(t+=o.source[o.cursor],o.advanceCodePoint());}var r;}function consumeIdentLikeToken(e,n){const o=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return [exports$1.TokenType.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];if(checkIfCodePointsMatchURLIdent(o)){n.advanceCodePoint();let t=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){t+=1,n.advanceCodePoint(1);continue}const s=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===s||39===s)return t>0&&n.unreadCodePoint(t),[exports$1.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[exports$1.TokenType.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return !(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==s||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const o=[],r=[];let s;for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&isHexDigitCodePoint(s);)o.push(s),n.advanceCodePoint();for(;void 0!==(s=n.source.codePointAt(n.cursor))&&o.length<6&&63===s;)0===r.length&&r.push(...o),o.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===t&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(s=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(s);)r.push(s),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...o),16);return [exports$1.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const i=parseInt(String.fromCodePoint(...o),16),c=parseInt(String.fromCodePoint(...r),16);return [exports$1.TokenType.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:i,endOfRange:c}]}function tokenizer(n,i){const c=n.css.valueOf(),a=n.unicodeRangesAllowed??false,u=new Reader(c),d={onParseError:i?.onParseError??noop};return {nextToken:function nextToken(){u.resetRepresentation();const n=u.source.codePointAt(u.cursor);if(void 0===n)return [exports$1.TokenType.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(u))return consumeComment(d,u);if(a&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(u))return consumeUnicodeRangeToken(0,u);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(d,u);if(isDigitCodePoint(n))return consumeNumericToken(d,u);switch(n){case 44:return u.advanceCodePoint(),[exports$1.TokenType.Comma,",",u.representationStart,u.representationEnd,void 0];case 58:return u.advanceCodePoint(),[exports$1.TokenType.Colon,":",u.representationStart,u.representationEnd,void 0];case 59:return u.advanceCodePoint(),[exports$1.TokenType.Semicolon,";",u.representationStart,u.representationEnd,void 0];case 40:return u.advanceCodePoint(),[exports$1.TokenType.OpenParen,"(",u.representationStart,u.representationEnd,void 0];case 41:return u.advanceCodePoint(),[exports$1.TokenType.CloseParen,")",u.representationStart,u.representationEnd,void 0];case 91:return u.advanceCodePoint(),[exports$1.TokenType.OpenSquare,"[",u.representationStart,u.representationEnd,void 0];case 93:return u.advanceCodePoint(),[exports$1.TokenType.CloseSquare,"]",u.representationStart,u.representationEnd,void 0];case 123:return u.advanceCodePoint(),[exports$1.TokenType.OpenCurly,"{",u.representationStart,u.representationEnd,void 0];case 125:return u.advanceCodePoint(),[exports$1.TokenType.CloseCurly,"}",u.representationStart,u.representationEnd,void 0];case 39:case 34:return consumeStringToken(d,u);case 35:return consumeHashToken(d,u);case s:case 46:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):(u.advanceCodePoint(),[exports$1.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]);case r:case o:case 12:case 9:case 32:return consumeWhiteSpace(u);case t:return checkIfThreeCodePointsWouldStartANumber(u)?consumeNumericToken(d,u):checkIfThreeCodePointsWouldStartCDC(u)?(u.advanceCodePoint(3),[exports$1.TokenType.CDC,"--\x3e",u.representationStart,u.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)?consumeIdentLikeToken(d,u):(u.advanceCodePoint(),[exports$1.TokenType.Delim,"-",u.representationStart,u.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(u)?(u.advanceCodePoint(4),[exports$1.TokenType.CDO,"\x3c!--",u.representationStart,u.representationEnd,void 0]):(u.advanceCodePoint(),[exports$1.TokenType.Delim,"<",u.representationStart,u.representationEnd,{value:"<"}]);case 64:if(u.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,u)){const e=consumeIdentSequence(d,u);return [exports$1.TokenType.AtKeyword,u.source.slice(u.representationStart,u.representationEnd+1),u.representationStart,u.representationEnd,{value:String.fromCodePoint(...e)}]}return [exports$1.TokenType.Delim,"@",u.representationStart,u.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(u))return consumeIdentLikeToken(d,u);u.advanceCodePoint();const n=[exports$1.TokenType.Delim,"\\",u.representationStart,u.representationEnd,{value:"\\"}];return d.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,u.representationStart,u.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"],n)),n}}return u.advanceCodePoint(),[exports$1.TokenType.Delim,u.source[u.representationStart],u.representationStart,u.representationEnd,{value:u.source[u.representationStart]}]},endOfFile:function endOfFile(){return void 0===u.source.codePointAt(u.cursor)}}}function noop(){}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,i),n=1;else if(e[0]===t&&e[1]===t)n=2;else if(e[0]===t&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else {if(e[0]===t&&!e[1])return [92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]));}for(let o=n;o<e.length;o++)0!==e[o]?isIdentCodePoint(e[o])||(o+=insertEscapedCharacter(e,o,e[o])):(e.splice(o,1,i),o++);return e}function insertEscapedCharacter(e,n,o){return e.splice(n,1,92,o),1}function insertEscapedCodePoint(e,n,o){const t=o.toString(16),r=[];for(const e of t)r.push(e.codePointAt(0));return e.splice(n,1,92,...r,32),1+r.length}const d=Object.values(exports$1.TokenType);exports$1.ParseError=ParseError,exports$1.ParseErrorMessage=e,exports$1.ParseErrorWithToken=ParseErrorWithToken,exports$1.cloneTokens=function cloneTokens(e){return n?structuredClone(e):JSON.parse(JSON.stringify(e))},exports$1.isToken=function isToken(e){return !!Array.isArray(e)&&(!(e.length<4)&&(!!d.includes(e[0])&&("string"==typeof e[1]&&("number"==typeof e[2]&&"number"==typeof e[3]))))},exports$1.isTokenAtKeyword=function isTokenAtKeyword(e){return !!e&&e[0]===exports$1.TokenType.AtKeyword},exports$1.isTokenBadString=function isTokenBadString(e){return !!e&&e[0]===exports$1.TokenType.BadString},exports$1.isTokenBadURL=function isTokenBadURL(e){return !!e&&e[0]===exports$1.TokenType.BadURL},exports$1.isTokenCDC=function isTokenCDC(e){return !!e&&e[0]===exports$1.TokenType.CDC},exports$1.isTokenCDO=function isTokenCDO(e){return !!e&&e[0]===exports$1.TokenType.CDO},exports$1.isTokenCloseCurly=function isTokenCloseCurly(e){return !!e&&e[0]===exports$1.TokenType.CloseCurly},exports$1.isTokenCloseParen=function isTokenCloseParen(e){return !!e&&e[0]===exports$1.TokenType.CloseParen},exports$1.isTokenCloseSquare=function isTokenCloseSquare(e){return !!e&&e[0]===exports$1.TokenType.CloseSquare},exports$1.isTokenColon=function isTokenColon(e){return !!e&&e[0]===exports$1.TokenType.Colon},exports$1.isTokenComma=function isTokenComma(e){return !!e&&e[0]===exports$1.TokenType.Comma},exports$1.isTokenComment=function isTokenComment(e){return !!e&&e[0]===exports$1.TokenType.Comment},exports$1.isTokenDelim=function isTokenDelim(e){return !!e&&e[0]===exports$1.TokenType.Delim},exports$1.isTokenDimension=function isTokenDimension(e){return !!e&&e[0]===exports$1.TokenType.Dimension},exports$1.isTokenEOF=function isTokenEOF(e){return !!e&&e[0]===exports$1.TokenType.EOF},exports$1.isTokenFunction=function isTokenFunction(e){return !!e&&e[0]===exports$1.TokenType.Function},exports$1.isTokenHash=function isTokenHash(e){return !!e&&e[0]===exports$1.TokenType.Hash},exports$1.isTokenIdent=function isTokenIdent(e){return !!e&&e[0]===exports$1.TokenType.Ident},exports$1.isTokenNumber=function isTokenNumber(e){return !!e&&e[0]===exports$1.TokenType.Number},exports$1.isTokenNumeric=function isTokenNumeric(e){if(!e)return false;switch(e[0]){case exports$1.TokenType.Dimension:case exports$1.TokenType.Number:case exports$1.TokenType.Percentage:return true;default:return false}},exports$1.isTokenOpenCurly=function isTokenOpenCurly(e){return !!e&&e[0]===exports$1.TokenType.OpenCurly},exports$1.isTokenOpenParen=function isTokenOpenParen(e){return !!e&&e[0]===exports$1.TokenType.OpenParen},exports$1.isTokenOpenSquare=function isTokenOpenSquare(e){return !!e&&e[0]===exports$1.TokenType.OpenSquare},exports$1.isTokenPercentage=function isTokenPercentage(e){return !!e&&e[0]===exports$1.TokenType.Percentage},exports$1.isTokenSemicolon=function isTokenSemicolon(e){return !!e&&e[0]===exports$1.TokenType.Semicolon},exports$1.isTokenString=function isTokenString(e){return !!e&&e[0]===exports$1.TokenType.String},exports$1.isTokenURL=function isTokenURL(e){return !!e&&e[0]===exports$1.TokenType.URL},exports$1.isTokenUnicodeRange=function isTokenUnicodeRange(e){return !!e&&e[0]===exports$1.TokenType.UnicodeRange},exports$1.isTokenWhiteSpaceOrComment=function isTokenWhiteSpaceOrComment(e){if(!e)return false;switch(e[0]){case exports$1.TokenType.Whitespace:case exports$1.TokenType.Comment:return true;default:return false}},exports$1.isTokenWhitespace=function isTokenWhitespace(e){return !!e&&e[0]===exports$1.TokenType.Whitespace},exports$1.mirrorVariant=function mirrorVariant(e){switch(e[0]){case exports$1.TokenType.OpenParen:return [exports$1.TokenType.CloseParen,")",-1,-1,void 0];case exports$1.TokenType.CloseParen:return [exports$1.TokenType.OpenParen,"(",-1,-1,void 0];case exports$1.TokenType.OpenCurly:return [exports$1.TokenType.CloseCurly,"}",-1,-1,void 0];case exports$1.TokenType.CloseCurly:return [exports$1.TokenType.OpenCurly,"{",-1,-1,void 0];case exports$1.TokenType.OpenSquare:return [exports$1.TokenType.CloseSquare,"]",-1,-1,void 0];case exports$1.TokenType.CloseSquare:return [exports$1.TokenType.OpenSquare,"[",-1,-1,void 0];default:return null}},exports$1.mirrorVariantType=function mirrorVariantType(e){switch(e){case exports$1.TokenType.OpenParen:return exports$1.TokenType.CloseParen;case exports$1.TokenType.CloseParen:return exports$1.TokenType.OpenParen;case exports$1.TokenType.OpenCurly:return exports$1.TokenType.CloseCurly;case exports$1.TokenType.CloseCurly:return exports$1.TokenType.OpenCurly;case exports$1.TokenType.OpenSquare:return exports$1.TokenType.CloseSquare;case exports$1.TokenType.CloseSquare:return exports$1.TokenType.OpenSquare;default:return null}},exports$1.mutateIdent=function mutateIdent(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=String.fromCodePoint(...serializeIdent(o));e[1]=t,e[4].value=n;},exports$1.mutateUnit=function mutateUnit(e,n){const o=[];for(const e of n)o.push(e.codePointAt(0));const t=serializeIdent(o);101===t[0]&&insertEscapedCodePoint(t,0,t[0]);const r=String.fromCodePoint(...t),s="+"===e[4].signCharacter?e[4].signCharacter:"",i=e[4].value.toString();e[1]=`${s}${i}${r}`,e[4].unit=n;},exports$1.stringify=function stringify(...e){let n="";for(let o=0;o<e.length;o++)n+=e[o][1];return n},exports$1.tokenize=function tokenize(e,n){const o=tokenizer(e,n),t=[];for(;!o.endOfFile();)t.push(o.nextToken());return t.push(o.nextToken()),t},exports$1.tokenizer=tokenizer;
|
|
1474
1498
|
} (dist));
|
|
1475
1499
|
return dist;
|
|
1476
1500
|
}
|
|
@@ -2746,36 +2770,36 @@ var hasRequiredProperties;
|
|
|
2746
2770
|
function requireProperties () {
|
|
2747
2771
|
if (hasRequiredProperties) return properties;
|
|
2748
2772
|
hasRequiredProperties = 1;
|
|
2749
|
-
(function (exports) {
|
|
2773
|
+
(function (exports$1) {
|
|
2750
2774
|
|
|
2751
|
-
Object.defineProperty(exports, "__esModule", {
|
|
2775
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
2752
2776
|
value: true
|
|
2753
2777
|
});
|
|
2754
|
-
Object.defineProperty(exports, "BorderRadiusIndividual", {
|
|
2778
|
+
Object.defineProperty(exports$1, "BorderRadiusIndividual", {
|
|
2755
2779
|
enumerable: true,
|
|
2756
2780
|
get: function () {
|
|
2757
2781
|
return _borderRadius.BorderRadiusIndividual;
|
|
2758
2782
|
}
|
|
2759
2783
|
});
|
|
2760
|
-
Object.defineProperty(exports, "BorderRadiusShorthand", {
|
|
2784
|
+
Object.defineProperty(exports$1, "BorderRadiusShorthand", {
|
|
2761
2785
|
enumerable: true,
|
|
2762
2786
|
get: function () {
|
|
2763
2787
|
return _borderRadius.BorderRadiusShorthand;
|
|
2764
2788
|
}
|
|
2765
2789
|
});
|
|
2766
|
-
Object.defineProperty(exports, "BoxShadow", {
|
|
2790
|
+
Object.defineProperty(exports$1, "BoxShadow", {
|
|
2767
2791
|
enumerable: true,
|
|
2768
2792
|
get: function () {
|
|
2769
2793
|
return _boxShadow.BoxShadow;
|
|
2770
2794
|
}
|
|
2771
2795
|
});
|
|
2772
|
-
Object.defineProperty(exports, "BoxShadowList", {
|
|
2796
|
+
Object.defineProperty(exports$1, "BoxShadowList", {
|
|
2773
2797
|
enumerable: true,
|
|
2774
2798
|
get: function () {
|
|
2775
2799
|
return _boxShadow.BoxShadowList;
|
|
2776
2800
|
}
|
|
2777
2801
|
});
|
|
2778
|
-
Object.defineProperty(exports, "Transform", {
|
|
2802
|
+
Object.defineProperty(exports$1, "Transform", {
|
|
2779
2803
|
enumerable: true,
|
|
2780
2804
|
get: function () {
|
|
2781
2805
|
return _transform.Transform;
|
|
@@ -3400,22 +3424,22 @@ var hasRequiredLib$1;
|
|
|
3400
3424
|
function requireLib$1 () {
|
|
3401
3425
|
if (hasRequiredLib$1) return lib$1;
|
|
3402
3426
|
hasRequiredLib$1 = 1;
|
|
3403
|
-
(function (exports) {
|
|
3427
|
+
(function (exports$1) {
|
|
3404
3428
|
|
|
3405
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3429
|
+
Object.defineProperty(exports$1, "__esModule", {
|
|
3406
3430
|
value: true
|
|
3407
3431
|
});
|
|
3408
|
-
Object.defineProperty(exports, "lastMediaQueryWinsTransform", {
|
|
3432
|
+
Object.defineProperty(exports$1, "lastMediaQueryWinsTransform", {
|
|
3409
3433
|
enumerable: true,
|
|
3410
3434
|
get: function () {
|
|
3411
3435
|
return _mediaQueryTransform.lastMediaQueryWinsTransform;
|
|
3412
3436
|
}
|
|
3413
3437
|
});
|
|
3414
|
-
exports.tokenParser = exports.properties = void 0;
|
|
3438
|
+
exports$1.tokenParser = exports$1.properties = void 0;
|
|
3415
3439
|
var _tokenParser = _interopRequireWildcard(requireTokenParser());
|
|
3416
|
-
exports.tokenParser = _tokenParser;
|
|
3440
|
+
exports$1.tokenParser = _tokenParser;
|
|
3417
3441
|
var _properties = _interopRequireWildcard(requireProperties());
|
|
3418
|
-
exports.properties = _properties;
|
|
3442
|
+
exports$1.properties = _properties;
|
|
3419
3443
|
var _mediaQueryTransform = requireMediaQueryTransform();
|
|
3420
3444
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
3421
3445
|
} (lib$1));
|
|
@@ -3598,7 +3622,10 @@ const angles = ['deg', 'grad', 'turn', 'rad'];
|
|
|
3598
3622
|
const timings = ['ms', 's'];
|
|
3599
3623
|
const fraction = 'fr';
|
|
3600
3624
|
const percentage$1 = '%';
|
|
3601
|
-
function normalizeZeroDimensions(ast,
|
|
3625
|
+
function normalizeZeroDimensions(ast, key) {
|
|
3626
|
+
if (typeof key === 'string' && key.startsWith('--')) {
|
|
3627
|
+
return ast;
|
|
3628
|
+
}
|
|
3602
3629
|
let endFunction = 0;
|
|
3603
3630
|
ast.walk(node => {
|
|
3604
3631
|
if (node.type === 'function' && !endFunction) {
|
|
@@ -4043,6 +4070,15 @@ function requirePropertyPriorities () {
|
|
|
4043
4070
|
longHandPhysical.add('border-top-right-radius');
|
|
4044
4071
|
longHandPhysical.add('border-bottom-left-radius');
|
|
4045
4072
|
longHandPhysical.add('border-bottom-right-radius');
|
|
4073
|
+
shorthandsOfLonghands.add('corner-shape');
|
|
4074
|
+
longHandLogical.add('corner-start-start-shape');
|
|
4075
|
+
longHandLogical.add('corner-start-end-shape');
|
|
4076
|
+
longHandLogical.add('corner-end-start-shape');
|
|
4077
|
+
longHandLogical.add('corner-end-end-shape');
|
|
4078
|
+
longHandPhysical.add('corner-top-left-shape');
|
|
4079
|
+
longHandPhysical.add('corner-top-right-shape');
|
|
4080
|
+
longHandPhysical.add('corner-bottom-left-shape');
|
|
4081
|
+
longHandPhysical.add('corner-bottom-right-shape');
|
|
4046
4082
|
longHandLogical.add('box-shadow');
|
|
4047
4083
|
longHandLogical.add('accent-color');
|
|
4048
4084
|
longHandLogical.add('appearance');
|
|
@@ -41,6 +41,7 @@ export type StyleXOptions = Readonly<{
|
|
|
41
41
|
debug: null | undefined | boolean;
|
|
42
42
|
definedStylexCSSVariables?: { [key: string]: unknown };
|
|
43
43
|
dev: boolean;
|
|
44
|
+
propertyValidationMode?: 'throw' | 'warn' | 'silent';
|
|
44
45
|
enableDebugClassNames?: null | undefined | boolean;
|
|
45
46
|
enableDebugDataProp?: null | undefined | boolean;
|
|
46
47
|
enableDevClassNames?: null | undefined | boolean;
|
|
@@ -48,6 +48,7 @@ export type StyleXOptions = $ReadOnly<{
|
|
|
48
48
|
debug: ?boolean,
|
|
49
49
|
definedStylexCSSVariables?: { [key: string]: mixed },
|
|
50
50
|
dev: boolean,
|
|
51
|
+
propertyValidationMode?: 'throw' | 'warn' | 'silent',
|
|
51
52
|
enableDebugClassNames?: ?boolean,
|
|
52
53
|
enableDebugDataProp?: ?boolean,
|
|
53
54
|
enableDevClassNames?: ?boolean,
|
|
@@ -23,6 +23,7 @@ import type { TStyleValue } from '../common-types';
|
|
|
23
23
|
* - [x] border-inline-start
|
|
24
24
|
* - [x] border-left
|
|
25
25
|
* - [x] border-radius
|
|
26
|
+
* - [x] corner-shape
|
|
26
27
|
* - [x] border-right
|
|
27
28
|
* - [x] border-style
|
|
28
29
|
* - [x] border-top
|
|
@@ -74,6 +75,7 @@ import type { TStyleValue } from '../common-types';
|
|
|
74
75
|
* - [x] border-inline-start
|
|
75
76
|
* - [x] border-left
|
|
76
77
|
* - [x] border-radius
|
|
78
|
+
* - [x] corner-shape
|
|
77
79
|
* - [x] border-right
|
|
78
80
|
* - [x] border-style
|
|
79
81
|
* - [x] border-top
|
|
@@ -13,6 +13,9 @@ export declare function getExpandedKeys(
|
|
|
13
13
|
): ReadonlyArray<string>;
|
|
14
14
|
declare function flatMapExpandedShorthands(
|
|
15
15
|
objEntry: Readonly<[string, TStyleValue]>,
|
|
16
|
-
options: Readonly<{
|
|
16
|
+
options: Readonly<{
|
|
17
|
+
styleResolution: StyleXOptions['styleResolution'];
|
|
18
|
+
propertyValidationMode?: StyleXOptions['propertyValidationMode'];
|
|
19
|
+
}>,
|
|
17
20
|
): ReadonlyArray<[string, TStyleValue]>;
|
|
18
21
|
export default flatMapExpandedShorthands;
|
|
@@ -17,6 +17,7 @@ declare export default function flatMapExpandedShorthands(
|
|
|
17
17
|
objEntry: $ReadOnly<[string, TStyleValue]>,
|
|
18
18
|
options: $ReadOnly<{
|
|
19
19
|
styleResolution: StyleXOptions['styleResolution'],
|
|
20
|
+
propertyValidationMode?: StyleXOptions['propertyValidationMode'],
|
|
20
21
|
...
|
|
21
22
|
}>,
|
|
22
23
|
): $ReadOnlyArray<[string, TStyleValue]>;
|
|
@@ -27,6 +27,7 @@ export declare type LOGICAL_FLOAT_END_VAR = typeof LOGICAL_FLOAT_END_VAR;
|
|
|
27
27
|
* - [x] border-inline-start
|
|
28
28
|
* - [ ] border-left
|
|
29
29
|
* - [x] border-radius
|
|
30
|
+
* - [ ] corner-shape
|
|
30
31
|
* - [ ] border-right
|
|
31
32
|
* - [x] border-style
|
|
32
33
|
* - [ ] border-top
|
|
@@ -74,6 +75,7 @@ export declare type LOGICAL_FLOAT_END_VAR = typeof LOGICAL_FLOAT_END_VAR;
|
|
|
74
75
|
* - [x] border-inline-start
|
|
75
76
|
* - [ ] border-left
|
|
76
77
|
* - [x] border-radius
|
|
78
|
+
* - [ ] corner-shape
|
|
77
79
|
* - [ ] border-right
|
|
78
80
|
* - [x] border-style
|
|
79
81
|
* - [ ] border-top
|
|
@@ -50,6 +50,7 @@ export type StyleXOptions = Readonly<
|
|
|
50
50
|
| null
|
|
51
51
|
| undefined
|
|
52
52
|
| Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
|
|
53
|
+
propertyValidationMode?: 'throw' | 'warn' | 'silent';
|
|
53
54
|
enableDebugClassNames?: boolean;
|
|
54
55
|
enableDebugDataProp?: boolean;
|
|
55
56
|
enableDevClassNames?: boolean;
|
|
@@ -76,6 +77,7 @@ export type StyleXOptions = Readonly<
|
|
|
76
77
|
| null
|
|
77
78
|
| undefined
|
|
78
79
|
| Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
|
|
80
|
+
propertyValidationMode?: 'throw' | 'warn' | 'silent';
|
|
79
81
|
enableDebugClassNames?: boolean;
|
|
80
82
|
enableDebugDataProp?: boolean;
|
|
81
83
|
enableDevClassNames?: boolean;
|
|
@@ -47,6 +47,7 @@ type ModuleResolution =
|
|
|
47
47
|
export type StyleXOptions = $ReadOnly<{
|
|
48
48
|
...RuntimeOptions,
|
|
49
49
|
aliases?: ?$ReadOnly<{ [string]: string | $ReadOnlyArray<string> }>,
|
|
50
|
+
propertyValidationMode?: 'throw' | 'warn' | 'silent',
|
|
50
51
|
enableDebugClassNames?: boolean,
|
|
51
52
|
enableDebugDataProp?: boolean,
|
|
52
53
|
enableDevClassNames?: boolean,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexjs/babel-plugin",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.5",
|
|
4
4
|
"description": "StyleX babel plugin.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"browser": "lib/index.browser.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"prebuild": "gen-types -i src/ -o lib/",
|
|
15
15
|
"build": "rollup --config ./rollup.config.mjs",
|
|
16
|
-
"build-haste": "HASTE=true rollup --config ./rollup.config.mjs",
|
|
16
|
+
"build-haste": "cross-env HASTE=true rollup --config ./rollup.config.mjs",
|
|
17
17
|
"build-watch": "rollup --config ./rollup.config.mjs --watch",
|
|
18
18
|
"test": "jest --coverage"
|
|
19
19
|
},
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@babel/traverse": "^7.26.8",
|
|
24
24
|
"@babel/types": "^7.26.8",
|
|
25
25
|
"@dual-bundle/import-meta-resolve": "^4.1.0",
|
|
26
|
-
"@stylexjs/shared": "0.17.
|
|
27
|
-
"@stylexjs/stylex": "0.17.
|
|
26
|
+
"@stylexjs/shared": "0.17.5",
|
|
27
|
+
"@stylexjs/stylex": "0.17.5",
|
|
28
28
|
"postcss-value-parser": "^4.1.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"babel-plugin-syntax-hermes-parser": "^0.32.1",
|
|
38
38
|
"path-browserify": "^1.0.1",
|
|
39
39
|
"rollup": "^4.24.0",
|
|
40
|
-
"scripts": "0.17.
|
|
40
|
+
"scripts": "0.17.5"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"flow_modules/*",
|