summaryrefslogtreecommitdiff
path: root/node_modules/@csstools/css-parser-algorithms
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-01-04 11:07:54 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-01-04 11:07:54 +0800
commit275f9dc0bdf3e58aa36b800f55f8648fbc55d8af (patch)
tree81c7cf120fb703cfd5e3162f2366033d9fe5c7f8 /node_modules/@csstools/css-parser-algorithms
parent2b4ab36917baef56c7ce1602966f941be15af785 (diff)
upgrade
Diffstat (limited to 'node_modules/@csstools/css-parser-algorithms')
-rw-r--r--node_modules/@csstools/css-parser-algorithms/CHANGELOG.md14
-rw-r--r--node_modules/@csstools/css-parser-algorithms/README.md4
-rw-r--r--node_modules/@csstools/css-parser-algorithms/dist/index.cjs2
-rw-r--r--node_modules/@csstools/css-parser-algorithms/dist/index.d.ts412
-rw-r--r--node_modules/@csstools/css-parser-algorithms/dist/index.mjs2
-rw-r--r--node_modules/@csstools/css-parser-algorithms/package.json4
6 files changed, 401 insertions, 37 deletions
diff --git a/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md b/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md
index 6d228cd2..802f35cf 100644
--- a/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md
+++ b/node_modules/@csstools/css-parser-algorithms/CHANGELOG.md
@@ -1,5 +1,13 @@
# Changes to CSS Parser Algorithms
+### 2.5.0
+
+_December 31, 2023_
+
+- Add a `forEach` and `walk` function.
+- Improve documentation.
+- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#223) (patch)
+
### 2.4.0
_December 15, 2023_
@@ -16,10 +24,4 @@ _September 24, 2023_
- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#221) (patch)
-### 2.3.1
-
-_July 24, 2023_
-
-- Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#220) (minor)
-
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md)
diff --git a/node_modules/@csstools/css-parser-algorithms/README.md b/node_modules/@csstools/css-parser-algorithms/README.md
index b63c2ce3..3195aff0 100644
--- a/node_modules/@csstools/css-parser-algorithms/README.md
+++ b/node_modules/@csstools/css-parser-algorithms/README.md
@@ -6,6 +6,10 @@
Implemented from : https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/
+## API
+
+[Read the API docs](./docs/css-parser-algorithms.md)
+
## Usage
Add [CSS Parser Algorithms] to your project:
diff --git a/node_modules/@csstools/css-parser-algorithms/dist/index.cjs b/node_modules/@csstools/css-parser-algorithms/dist/index.cjs
index eedf0293..003cd61c 100644
--- a/node_modules/@csstools/css-parser-algorithms/dist/index.cjs
+++ b/node_modules/@csstools/css-parser-algorithms/dist/index.cjs
@@ -1 +1 @@
-"use strict";var e,n=require("@csstools/css-tokenizer");function walkerIndexGenerator(e){let n=e.slice();return(e,o,t)=>{let s=-1;for(let i=n.indexOf(o);i<n.length&&(s=e.indexOf(n[i]),-1===s||s<t);i++);return-1===s||s===t&&o===e[t]&&(s++,s>=e.length)?-1:(n=e.slice(),s)}}function consumeComponentValue(e,o){const t=o[0];if(t[0]===n.TokenType.OpenParen||t[0]===n.TokenType.OpenCurly||t[0]===n.TokenType.OpenSquare){const n=consumeSimpleBlock(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Function){const n=consumeFunction(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Whitespace){const n=consumeWhitespace(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Comment){const n=consumeComment(e,o);return{advance:n.advance,node:n.node}}return{advance:1,node:new TokenNode(t)}}exports.ComponentValueType=void 0,(e=exports.ComponentValueType||(exports.ComponentValueType={})).Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token";class ContainerNodeBaseClass{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,n){if(0===this.value.length)return;const o=walkerIndexGenerator(this.value);let t=0;for(;t<this.value.length;){const s=this.value[t];let i;if(n&&(i={...n}),!1===e({node:s,parent:this,state:i},t))return!1;if(t=o(this.value,s,t),-1===t)break}}walk(e,n){0!==this.value.length&&this.forEach(((n,o)=>!1!==e(n,o)&&((!("walk"in n.node)||!this.value.includes(n.node)||!1!==n.node.walk(e,n.state))&&void 0)),n)}}class FunctionNode extends ContainerNodeBaseClass{type=exports.ComponentValueType.Function;name;endToken;constructor(e,n,o){super(),this.name=e,this.endToken=n,this.value=o}getName(){return this.name[4].value}normalize(){this.endToken[0]===n.TokenType.EOF&&(this.endToken=[n.TokenType.CloseParen,")",-1,-1,void 0])}tokens(){return this.endToken[0]===n.TokenType.EOF?[this.name,...this.value.flatMap((e=>e.tokens()))]:[this.name,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n.isToken(e)?n.stringify(e):e.toString())).join("");return n.stringify(this.name)+e+n.stringify(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===exports.ComponentValueType.Function)}}function consumeFunction(e,o){const t=[];let s=1;for(;;){const i=o[s];if(!i||i[0]===n.TokenType.EOF)return e.onParseError(new n.ParseError("Unexpected EOF while consuming a function.",o[0][2],o[o.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:o.length,node:new FunctionNode(o[0],i,t)};if(i[0]===n.TokenType.CloseParen)return{advance:s+1,node:new FunctionNode(o[0],i,t)};if(i[0]===n.TokenType.Comment||i[0]===n.TokenType.Whitespace){const n=consumeAllCommentsAndWhitespace(e,o.slice(s));s+=n.advance,t.push(...n.nodes);continue}const r=consumeComponentValue(e,o.slice(s));s+=r.advance,t.push(r.node)}}class SimpleBlockNode extends ContainerNodeBaseClass{type=exports.ComponentValueType.SimpleBlock;startToken;endToken;constructor(e,n,o){super(),this.startToken=e,this.endToken=n,this.value=o}normalize(){if(this.endToken[0]===n.TokenType.EOF){const e=n.mirrorVariant(this.startToken);e&&(this.endToken=e)}}tokens(){return this.endToken[0]===n.TokenType.EOF?[this.startToken,...this.value.flatMap((e=>e.tokens()))]:[this.startToken,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n.isToken(e)?n.stringify(e):e.toString())).join("");return n.stringify(this.startToken)+e+n.stringify(this.endToken)}indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===exports.ComponentValueType.SimpleBlock)}}function consumeSimpleBlock(e,o){const t=n.mirrorVariantType(o[0][0]);if(!t)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const s=[];let i=1;for(;;){const r=o[i];if(!r||r[0]===n.TokenType.EOF)return e.onParseError(new n.ParseError("Unexpected EOF while consuming a simple block.",o[0][2],o[o.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:o.length,node:new SimpleBlockNode(o[0],r,s)};if(r[0]===t)return{advance:i+1,node:new SimpleBlockNode(o[0],r,s)};if(r[0]===n.TokenType.Comment||r[0]===n.TokenType.Whitespace){const n=consumeAllCommentsAndWhitespace(e,o.slice(i));i+=n.advance,s.push(...n.nodes);continue}const a=consumeComponentValue(e,o.slice(i));i+=a.advance,s.push(a.node)}}class WhitespaceNode{type=exports.ComponentValueType.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return n.stringify(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===exports.ComponentValueType.Whitespace)}}function consumeWhitespace(e,o){let t=0;for(;;){if(o[t][0]!==n.TokenType.Whitespace)return{advance:t,node:new WhitespaceNode(o.slice(0,t))};t++}}class CommentNode{type=exports.ComponentValueType.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return n.stringify(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===exports.ComponentValueType.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(e,o){const t=[];let s=0;for(;;)if(o[s][0]!==n.TokenType.Whitespace){if(o[s][0]!==n.TokenType.Comment)return{advance:s,nodes:t};t.push(new CommentNode(o[s])),s++}else{const e=consumeWhitespace(0,o.slice(s));s+=e.advance,t.push(e.node)}}class TokenNode{type=exports.ComponentValueType.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return n.stringify(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===exports.ComponentValueType.Token)}}function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)}function isFunctionNode(e){return FunctionNode.isFunctionNode(e)}exports.CommentNode=CommentNode,exports.ContainerNodeBaseClass=ContainerNodeBaseClass,exports.FunctionNode=FunctionNode,exports.SimpleBlockNode=SimpleBlockNode,exports.TokenNode=TokenNode,exports.WhitespaceNode=WhitespaceNode,exports.gatherNodeAncestry=function gatherNodeAncestry(e){const n=new Map;return e.walk((e=>{Array.isArray(e.node)?e.node.forEach((o=>{n.set(o,e.parent)})):n.set(e.node,e.parent)})),n},exports.isCommentNode=function isCommentNode(e){return CommentNode.isCommentNode(e)},exports.isFunctionNode=isFunctionNode,exports.isSimpleBlockNode=isSimpleBlockNode,exports.isTokenNode=function isTokenNode(e){return TokenNode.isTokenNode(e)},exports.isWhitespaceNode=function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)},exports.parseCommaSeparatedListOfComponentValues=function parseCommaSeparatedListOfComponentValues(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];if(0===e.length)return[];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=[],a=0;for(;;){if(!s[a]||s[a][0]===n.TokenType.EOF)return r.length&&i.push(r),i;if(s[a][0]===n.TokenType.Comma){i.push(r),r=[],a++;continue}const o=consumeComponentValue(t,e.slice(a));r.push(o.node),a+=o.advance}},exports.parseComponentValue=function parseComponentValue(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=consumeComponentValue(t,s);if(s[Math.min(i.advance,s.length-1)][0]===n.TokenType.EOF)return i.node;t.onParseError(new n.ParseError("Expected EOF after parsing a component value.",e[0][2],e[e.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))},exports.parseListOfComponentValues=function parseListOfComponentValues(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=0;for(;;){if(!s[r]||s[r][0]===n.TokenType.EOF)return i;const e=consumeComponentValue(t,s.slice(r));i.push(e.node),r+=e.advance}},exports.replaceComponentValues=function replaceComponentValues(e,n){for(let o=0;o<e.length;o++){const t=e[o];for(let e=0;e<t.length;e++){const o=t[e];{const s=n(o);if(s){t.splice(e,1,s);continue}}(isSimpleBlockNode(o)||isFunctionNode(o))&&o.walk(((e,o)=>{if("number"!=typeof o)return;const t=e.node,s=n(t);s&&e.parent.value.splice(o,1,s)}))}}return e},exports.sourceIndices=function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const o=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(o)[1]]}const n=e.tokens(),o=n[0],t=n[n.length-1];return o&&t?[o[2],t[3]]:[0,0]},exports.stringify=function stringify(e){return e.map((e=>e.map((e=>n.stringify(...e.tokens()))).join(""))).join(",")},exports.walkerIndexGenerator=walkerIndexGenerator;
+"use strict";var e,n=require("@csstools/css-tokenizer");function walkerIndexGenerator(e){let n=e.slice();return(e,o,t)=>{let s=-1;for(let r=n.indexOf(o);r<n.length&&(s=e.indexOf(n[r]),-1===s||s<t);r++);return-1===s||s===t&&o===e[t]&&(s++,s>=e.length)?-1:(n=e.slice(),s)}}function consumeComponentValue(e,o){const t=o[0];if(t[0]===n.TokenType.OpenParen||t[0]===n.TokenType.OpenCurly||t[0]===n.TokenType.OpenSquare){const n=consumeSimpleBlock(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Function){const n=consumeFunction(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Whitespace){const n=consumeWhitespace(e,o);return{advance:n.advance,node:n.node}}if(t[0]===n.TokenType.Comment){const n=consumeComment(e,o);return{advance:n.advance,node:n.node}}return{advance:1,node:new TokenNode(t)}}exports.ComponentValueType=void 0,(e=exports.ComponentValueType||(exports.ComponentValueType={})).Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token";class ContainerNodeBaseClass{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,n){if(0===this.value.length)return;const o=walkerIndexGenerator(this.value);let t=0;for(;t<this.value.length;){const s=this.value[t];let r;if(n&&(r={...n}),!1===e({node:s,parent:this,state:r},t))return!1;if(t=o(this.value,s,t),-1===t)break}}walk(e,n){0!==this.value.length&&this.forEach(((n,o)=>!1!==e(n,o)&&((!("walk"in n.node)||!this.value.includes(n.node)||!1!==n.node.walk(e,n.state))&&void 0)),n)}}class FunctionNode extends ContainerNodeBaseClass{type=exports.ComponentValueType.Function;name;endToken;constructor(e,n,o){super(),this.name=e,this.endToken=n,this.value=o}getName(){return this.name[4].value}normalize(){this.endToken[0]===n.TokenType.EOF&&(this.endToken=[n.TokenType.CloseParen,")",-1,-1,void 0])}tokens(){return this.endToken[0]===n.TokenType.EOF?[this.name,...this.value.flatMap((e=>e.tokens()))]:[this.name,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n.isToken(e)?n.stringify(e):e.toString())).join("");return n.stringify(this.name)+e+n.stringify(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===exports.ComponentValueType.Function)}}function consumeFunction(e,o){const t=[];let s=1;for(;;){const r=o[s];if(!r||r[0]===n.TokenType.EOF)return e.onParseError(new n.ParseError("Unexpected EOF while consuming a function.",o[0][2],o[o.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:o.length,node:new FunctionNode(o[0],r,t)};if(r[0]===n.TokenType.CloseParen)return{advance:s+1,node:new FunctionNode(o[0],r,t)};if(r[0]===n.TokenType.Comment||r[0]===n.TokenType.Whitespace){const n=consumeAllCommentsAndWhitespace(e,o.slice(s));s+=n.advance,t.push(...n.nodes);continue}const i=consumeComponentValue(e,o.slice(s));s+=i.advance,t.push(i.node)}}class SimpleBlockNode extends ContainerNodeBaseClass{type=exports.ComponentValueType.SimpleBlock;startToken;endToken;constructor(e,n,o){super(),this.startToken=e,this.endToken=n,this.value=o}normalize(){if(this.endToken[0]===n.TokenType.EOF){const e=n.mirrorVariant(this.startToken);e&&(this.endToken=e)}}tokens(){return this.endToken[0]===n.TokenType.EOF?[this.startToken,...this.value.flatMap((e=>e.tokens()))]:[this.startToken,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n.isToken(e)?n.stringify(e):e.toString())).join("");return n.stringify(this.startToken)+e+n.stringify(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===exports.ComponentValueType.SimpleBlock)}}function consumeSimpleBlock(e,o){const t=n.mirrorVariantType(o[0][0]);if(!t)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const s=[];let r=1;for(;;){const i=o[r];if(!i||i[0]===n.TokenType.EOF)return e.onParseError(new n.ParseError("Unexpected EOF while consuming a simple block.",o[0][2],o[o.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:o.length,node:new SimpleBlockNode(o[0],i,s)};if(i[0]===t)return{advance:r+1,node:new SimpleBlockNode(o[0],i,s)};if(i[0]===n.TokenType.Comment||i[0]===n.TokenType.Whitespace){const n=consumeAllCommentsAndWhitespace(e,o.slice(r));r+=n.advance,s.push(...n.nodes);continue}const a=consumeComponentValue(e,o.slice(r));r+=a.advance,s.push(a.node)}}class WhitespaceNode{type=exports.ComponentValueType.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return n.stringify(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===exports.ComponentValueType.Whitespace)}}function consumeWhitespace(e,o){let t=0;for(;;){if(o[t][0]!==n.TokenType.Whitespace)return{advance:t,node:new WhitespaceNode(o.slice(0,t))};t++}}class CommentNode{type=exports.ComponentValueType.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return n.stringify(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===exports.ComponentValueType.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(e,o){const t=[];let s=0;for(;;)if(o[s][0]!==n.TokenType.Whitespace){if(o[s][0]!==n.TokenType.Comment)return{advance:s,nodes:t};t.push(new CommentNode(o[s])),s++}else{const e=consumeWhitespace(0,o.slice(s));s+=e.advance,t.push(e.node)}}class TokenNode{type=exports.ComponentValueType.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===exports.ComponentValueType.Token)}}function forEach(e,n,o){if(0===e.length)return;const t=walkerIndexGenerator(e);let s=0;for(;s<e.length;){const r=e[s];let i;if(o&&(i={...o}),!1===n({node:r,parent:{value:e},state:i},s))return!1;if(s=t(e,r,s),-1===s)break}}function walk(e,n,o){0!==e.length&&forEach(e,((o,t)=>!1!==n(o,t)&&((!("walk"in o.node)||!e.includes(o.node)||!1!==o.node.walk(n,o.state))&&void 0)),o)}exports.CommentNode=CommentNode,exports.ContainerNodeBaseClass=ContainerNodeBaseClass,exports.FunctionNode=FunctionNode,exports.SimpleBlockNode=SimpleBlockNode,exports.TokenNode=TokenNode,exports.WhitespaceNode=WhitespaceNode,exports.forEach=forEach,exports.gatherNodeAncestry=function gatherNodeAncestry(e){const n=new Map;return e.walk((e=>{Array.isArray(e.node)?e.node.forEach((o=>{n.set(o,e.parent)})):n.set(e.node,e.parent)})),n},exports.isCommentNode=function isCommentNode(e){return CommentNode.isCommentNode(e)},exports.isFunctionNode=function isFunctionNode(e){return FunctionNode.isFunctionNode(e)},exports.isSimpleBlockNode=function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)},exports.isTokenNode=function isTokenNode(e){return TokenNode.isTokenNode(e)},exports.isWhitespaceNode=function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)},exports.parseCommaSeparatedListOfComponentValues=function parseCommaSeparatedListOfComponentValues(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];if(0===e.length)return[];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const r=[];let i=[],a=0;for(;;){if(!s[a]||s[a][0]===n.TokenType.EOF)return i.length&&r.push(i),r;if(s[a][0]===n.TokenType.Comma){r.push(i),i=[],a++;continue}const o=consumeComponentValue(t,e.slice(a));i.push(o.node),a+=o.advance}},exports.parseComponentValue=function parseComponentValue(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const r=consumeComponentValue(t,s);if(s[Math.min(r.advance,s.length-1)][0]===n.TokenType.EOF)return r.node;t.onParseError(new n.ParseError("Expected EOF after parsing a component value.",e[0][2],e[e.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))},exports.parseListOfComponentValues=function parseListOfComponentValues(e,o){const t={onParseError:o?.onParseError??(()=>{})},s=[...e];s[s.length-1][0]!==n.TokenType.EOF&&s.push([n.TokenType.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const r=[];let i=0;for(;;){if(!s[i]||s[i][0]===n.TokenType.EOF)return r;const e=consumeComponentValue(t,s.slice(i));r.push(e.node),i+=e.advance}},exports.replaceComponentValues=function replaceComponentValues(e,n){for(let o=0;o<e.length;o++){walk(e[o],((e,o)=>{if("number"!=typeof o)return;const t=n(e.node);t&&e.parent.value.splice(o,1,t)}))}return e},exports.sourceIndices=function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const o=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(o)[1]]}const n=e.tokens(),o=n[0],t=n[n.length-1];return o&&t?[o[2],t[3]]:[0,0]},exports.stringify=function stringify(e){return e.map((e=>e.map((e=>n.stringify(...e.tokens()))).join(""))).join(",")},exports.walk=walk,exports.walkerIndexGenerator=walkerIndexGenerator;
diff --git a/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts b/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts
index 7df6e14c..9759d057 100644
--- a/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts
+++ b/node_modules/@csstools/css-parser-algorithms/dist/index.d.ts
@@ -1,18 +1,122 @@
+/**
+ * Parse CSS following the {@link https://drafts.csswg.org/css-syntax/#parsing | CSS Syntax Level 3 specification}.
+ *
+ * @remarks
+ * The tokenizing and parsing tools provided by CSS Tools are designed to be low level and generic with strong ties to their respective specifications.
+ *
+ * Any analysis or mutation of CSS source code should be done with the least powerful tool that can accomplish the task.
+ * For many applications it is sufficient to work with tokens.
+ * For others you might need to use {@link https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms | @csstools/css-parser-algorithms} or a more specific parser.
+ *
+ * The implementation of the AST nodes is kept lightweight and simple.
+ * Do not expect magic methods, instead assume that arrays and class instances behave like any other JavaScript.
+ *
+ * @example
+ * Parse a string of CSS into a component value:
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseComponentValue } from '@csstools/css-parser';
+ *
+ * const myCSS = `calc(1px * 2)`;
+ *
+ * const componentValue = parseComponentValue(tokenize({
+ * css: myCSS,
+ * }));
+ *
+ * console.log(componentValue);
+ * ```
+ *
+ * @example
+ * Use the right algorithm for the job.
+ *
+ * Algorithms that can parse larger structures (comma-separated lists, ...) can also parse smaller structures.
+ * However, the opposite is not true.
+ *
+ * If your context allows a list of component values, use {@link parseListOfComponentValues}:
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseListOfComponentValues } from '@csstools/css-parser';
+ *
+ * parseComponentValue(tokenize({ css: `10x 20px` }));
+ * ```
+ *
+ * If your context allows a comma-separated list of component values, use {@link parseCommaSeparatedListOfComponentValues}:
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser';
+ *
+ * parseCommaSeparatedListOfComponentValues(tokenize({ css: `20deg, 50%, 30%` }));
+ * ```
+ *
+ * @example
+ * Use the stateful walkers to keep track of the context of a given component value.
+ *
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseComponentValue, isSimpleBlockNode } from '@csstools/css-parser';
+ *
+ * const myCSS = `calc(1px * (5 / 2))`;
+ *
+ * const componentValue = parseComponentValue(tokenize({ css: myCSS }));
+ *
+ * let state = { inSimpleBlock: false };
+ * componentValue.walk((entry) => {
+ * if (isSimpleBlockNode(entry)) {
+ * entry.state.inSimpleBlock = true;
+ * return;
+ * }
+ *
+ * if (entry.state.inSimpleBlock) {
+ * console.log(entry.node.toString()); // `5`, ...
+ * }
+ * }, state);
+ * ```
+ *
+ * @packageDocumentation
+ */
+
import { CSSToken } from '@csstools/css-tokenizer';
import { ParseError } from '@csstools/css-tokenizer';
import { TokenFunction } from '@csstools/css-tokenizer';
export declare class CommentNode {
+ /**
+ * The node type, always `ComponentValueType.Comment`
+ */
type: ComponentValueType;
+ /**
+ * The comment token.
+ */
value: CSSToken;
constructor(value: CSSToken);
+ /**
+ * Retrieve the tokens for the current comment.
+ * This is the inverse of parsing from a list of tokens.
+ */
tokens(): Array<CSSToken>;
+ /**
+ * Convert the current comment to a string.
+ * This is not a true serialization.
+ * It is purely a concatenation of the string representation of the tokens.
+ */
toString(): string;
+ /**
+ * @internal
+ *
+ * A debug helper to convert the current object to a JSON representation.
+ * This is useful in asserts and to store large ASTs in files.
+ */
toJSON(): {
type: ComponentValueType;
tokens: CSSToken[];
};
+ /**
+ * @internal
+ */
isCommentNode(): this is CommentNode;
+ /**
+ * @internal
+ */
static isCommentNode(x: unknown): x is CommentNode;
}
@@ -57,9 +161,6 @@ export declare abstract class ContainerNodeBaseClass {
* The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
*
* @returns `false` if the iteration was halted, `undefined` otherwise.
- *
- * @template T - The type of the `state` object.
- * @template U - The type of the current node.
*/
forEach<T extends Record<string, unknown>, U extends ContainerNode>(this: U, cb: (entry: {
node: ComponentValue;
@@ -80,9 +181,6 @@ export declare abstract class ContainerNodeBaseClass {
* However changes are passed down to child node iterations.
*
* @returns `false` if the iteration was halted, `undefined` otherwise.
- *
- * @template T - The type of the `state` object.
- * @template U - The type of the current node.
*/
walk<T extends Record<string, unknown>, U extends ContainerNode>(this: U, cb: (entry: {
node: ComponentValue;
@@ -91,10 +189,42 @@ export declare abstract class ContainerNodeBaseClass {
}, index: number | string) => boolean | void, state?: T): false | undefined;
}
+/**
+ * Iterates over each item in a list of component values.
+ *
+ * @param cb - The callback function to execute for each item.
+ * The function receives an object containing the current node (`node`), its parent (`parent`),
+ * and an optional `state` object.
+ * A second parameter is the index of the current node.
+ * The function can return `false` to stop the iteration.
+ *
+ * @param state - An optional state object that can be used to pass additional information to the callback function.
+ * The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
+ *
+ * @returns `false` if the iteration was halted, `undefined` otherwise.
+ */
+export declare function forEach<T extends Record<string, unknown>>(componentValues: Array<ComponentValue>, cb: (entry: {
+ node: ComponentValue;
+ parent: ContainerNode | {
+ value: Array<ComponentValue>;
+ };
+ state?: T;
+}, index: number | string) => boolean | void, state?: T): false | undefined;
+
+/**
+ * A function node.
+ *
+ * @example
+ * ```js
+ * const node = parseComponentValue(tokenize('calc(1 + 1)'));
+ *
+ * isFunctionNode(node); // true
+ * node.getName(); // 'calc'
+ * ```
+ */
export declare class FunctionNode extends ContainerNodeBaseClass {
/**
- * The node type
- * Always `ComponentValueType.Function`
+ * The node type, always `ComponentValueType.Function`
*/
type: ComponentValueType;
/**
@@ -108,43 +238,69 @@ export declare class FunctionNode extends ContainerNodeBaseClass {
endToken: CSSToken;
constructor(name: TokenFunction, endToken: CSSToken, value: Array<ComponentValue>);
/**
- * Retrieve the name of the current Function.
+ * Retrieve the name of the current function.
* This is the parsed and unescaped name of the function.
*/
getName(): string;
/**
- * Normalize the current Function:
- * - if the "endToken" is EOF, replace with a ")-token"
+ * Normalize the current function:
+ * 1. if the "endToken" is EOF, replace with a ")-token"
*/
normalize(): void;
/**
- * Retrieve the tokens for the current Function.
+ * Retrieve the tokens for the current function.
* This is the inverse of parsing from a list of tokens.
*/
tokens(): Array<CSSToken>;
/**
- * Convert the current Function to a string.
+ * Convert the current function to a string.
* This is not a true serialization.
* It is purely a concatenation of the string representation of the tokens.
*/
toString(): string;
/**
+ * @internal
+ *
* A debug helper to convert the current object to a JSON representation.
* This is useful in asserts and to store large ASTs in files.
*/
toJSON(): unknown;
/**
- * Check if the current object is a FunctionNode.
- * This is a type guard to help with type narrowing.
+ * @internal
*/
isFunctionNode(): this is FunctionNode;
/**
- * Check if the given object is a FunctionNode.
- * This is a type guard to help with type narrowing.
+ * @internal
*/
static isFunctionNode(x: unknown): x is FunctionNode;
}
+/**
+ * AST nodes do not have a `parent` property or method.
+ * This makes it harder to traverse the AST upwards.
+ * This function builds a `Map<Child, Parent>` that can be used to lookup ancestors of a node.
+ *
+ * @remarks
+ * There is no magic behind this or the map it returns.
+ * Mutating the AST will not update the map.
+ *
+ * Types are erased and any content of the map has type `unknown`.
+ * If someone knows a clever way to type this, please let us know.
+ *
+ * @example
+ * ```js
+ * const ancestry = gatherNodeAncestry(mediaQuery);
+ * mediaQuery.walk((entry) => {
+ * const node = entry.node; // directly exposed
+ * const parent = entry.parent; // directly exposed
+ * const grandParent: unknown = ancestry.get(parent); // lookup
+ *
+ * console.log('node', node);
+ * console.log('parent', parent);
+ * console.log('grandParent', grandParent);
+ * });
+ * ```
+ */
export declare function gatherNodeAncestry(node: {
walk(cb: (entry: {
node: Array<unknown> | unknown;
@@ -152,46 +308,145 @@ export declare function gatherNodeAncestry(node: {
}, index: number | string) => boolean | void): false | undefined;
}): Map<unknown, unknown>;
+/**
+ * Check if the current object is a `CommentNode`.
+ * This is a type guard.
+ */
export declare function isCommentNode(x: unknown): x is CommentNode;
+/**
+ * Check if the current object is a `FunctionNode`.
+ * This is a type guard.
+ */
export declare function isFunctionNode(x: unknown): x is FunctionNode;
+/**
+ * Check if the current object is a `SimpleBlockNode`.
+ * This is a type guard.
+ */
export declare function isSimpleBlockNode(x: unknown): x is SimpleBlockNode;
+/**
+ * Check if the current object is a `TokenNode`.
+ * This is a type guard.
+ */
export declare function isTokenNode(x: unknown): x is TokenNode;
+/**
+ * Check if the current object is a `WhitespaceNode`.
+ * This is a type guard.
+ */
export declare function isWhitespaceNode(x: unknown): x is WhitespaceNode;
+/**
+ * Parse a comma-separated list of component values.
+ *
+ * @example
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser';
+ *
+ * parseCommaSeparatedListOfComponentValues(tokenize({ css: `20deg, 50%, 30%` }));
+ * ```
+ */
export declare function parseCommaSeparatedListOfComponentValues(tokens: Array<CSSToken>, options?: {
onParseError?: (error: ParseError) => void;
}): ComponentValue[][];
+/**
+ * Parse a single component value.
+ *
+ * @example
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser';
+ *
+ * parseCommaSeparatedListOfComponentValues(tokenize({ css: `10px` }));
+ * parseCommaSeparatedListOfComponentValues(tokenize({ css: `calc((10px + 1x) * 4)` }));
+ * ```
+ */
export declare function parseComponentValue(tokens: Array<CSSToken>, options?: {
onParseError?: (error: ParseError) => void;
}): ComponentValue | undefined;
+/**
+ * Parse a list of component values.
+ *
+ * @example
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseListOfComponentValues } from '@csstools/css-parser';
+ *
+ * parseListOfComponentValues(tokenize({ css: `20deg 30%` }));
+ * ```
+ */
export declare function parseListOfComponentValues(tokens: Array<CSSToken>, options?: {
onParseError?: (error: ParseError) => void;
}): ComponentValue[];
+/**
+ * Replace specific component values in a list of component values.
+ * A helper for the most common and simplistic cases when mutating an AST.
+ */
export declare function replaceComponentValues(componentValuesList: Array<Array<ComponentValue>>, replaceWith: (componentValue: ComponentValue) => ComponentValue | void): ComponentValue[][];
+/**
+ * A simple block node.
+ *
+ * @example
+ * ```js
+ * const node = parseComponentValue(tokenize('[foo=bar]'));
+ *
+ * isSimpleBlockNode(node); // true
+ * node.startToken; // [TokenType.OpenSquare, '[', 0, 0, undefined]
+ * ```
+ */
export declare class SimpleBlockNode extends ContainerNodeBaseClass {
+ /**
+ * The node type, always `ComponentValueType.SimpleBlock`
+ */
type: ComponentValueType;
+ /**
+ * The token for the opening token of the block.
+ */
startToken: CSSToken;
+ /**
+ * The token for the closing token of the block.
+ * If the block is closed it will be the mirror variant of the `startToken`.
+ * If the block is unclosed, this will be an EOF token.
+ */
endToken: CSSToken;
constructor(startToken: CSSToken, endToken: CSSToken, value: Array<ComponentValue>);
/**
- * Normalize the current Simple Block:
- * - if the "endToken" is EOF, replace with the mirror token of the "startToken"
+ * Normalize the current simple block
+ * 1. if the "endToken" is EOF, replace with the mirror token of the "startToken"
*/
normalize(): void;
+ /**
+ * Retrieve the tokens for the current simple block.
+ * This is the inverse of parsing from a list of tokens.
+ */
tokens(): Array<CSSToken>;
+ /**
+ * Convert the current simple block to a string.
+ * This is not a true serialization.
+ * It is purely a concatenation of the string representation of the tokens.
+ */
toString(): string;
- indexOf(item: ComponentValue): number | string;
- at(index: number | string): ComponentValue | undefined;
+ /**
+ * @internal
+ *
+ * A debug helper to convert the current object to a JSON representation.
+ * This is useful in asserts and to store large ASTs in files.
+ */
toJSON(): unknown;
+ /**
+ * @internal
+ */
isSimpleBlockNode(): this is SimpleBlockNode;
+ /**
+ * @internal
+ */
static isSimpleBlockNode(x: unknown): x is SimpleBlockNode;
}
@@ -204,45 +459,148 @@ export declare function sourceIndices(x: {
tokens(): Array<CSSToken>;
}>): [number, number];
+/**
+ * Concatenate the string representation of a collection of component values.
+ * This is not a proper serializer that will handle escaping and whitespace.
+ * It only produces valid CSS for token lists that are also valid.
+ */
export declare function stringify(componentValueLists: Array<Array<ComponentValue>>): string;
export declare class TokenNode {
+ /**
+ * The node type, always `ComponentValueType.Token`
+ */
type: ComponentValueType;
+ /**
+ * The token.
+ */
value: CSSToken;
constructor(value: CSSToken);
+ /**
+ * This is the inverse of parsing from a list of tokens.
+ */
tokens(): Array<CSSToken>;
+ /**
+ * Convert the current token to a string.
+ * This is not a true serialization.
+ * It is purely the string representation of token.
+ */
toString(): string;
+ /**
+ * @internal
+ *
+ * A debug helper to convert the current object to a JSON representation.
+ * This is useful in asserts and to store large ASTs in files.
+ */
toJSON(): {
type: ComponentValueType;
tokens: CSSToken[];
};
+ /**
+ * @internal
+ */
isTokenNode(): this is TokenNode;
+ /**
+ * @internal
+ */
static isTokenNode(x: unknown): x is TokenNode;
}
/**
+ * Walks each item in a list of component values all of their children.
+ *
+ * @param cb - The callback function to execute for each item.
+ * The function receives an object containing the current node (`node`), its parent (`parent`),
+ * and an optional `state` object.
+ * A second parameter is the index of the current node.
+ * The function can return `false` to stop the iteration.
+ *
+ * @param state - An optional state object that can be used to pass additional information to the callback function.
+ * The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
+ * However changes are passed down to child node iterations.
+ *
+ * @returns `false` if the iteration was halted, `undefined` otherwise.
+ *
+ * @example
+ * ```js
+ * import { tokenize } from '@csstools/css-tokenizer';
+ * import { parseListOfComponentValues, isSimpleBlockNode } from '@csstools/css-parser';
+ *
+ * const myCSS = `calc(1px * (5 / 2)) 10px`;
+ *
+ * const componentValues = parseListOfComponentValues(tokenize({ css: myCSS }));
+ *
+ * let state = { inSimpleBlock: false };
+ * walk(componentValues, (entry) => {
+ * if (isSimpleBlockNode(entry)) {
+ * entry.state.inSimpleBlock = true;
+ * return;
+ * }
+ *
+ * if (entry.state.inSimpleBlock) {
+ * console.log(entry.node.toString()); // `5`, ...
+ * }
+ * }, state);
+ * ```
+ */
+export declare function walk<T extends Record<string, unknown>>(componentValues: Array<ComponentValue>, cb: (entry: {
+ node: ComponentValue;
+ parent: ContainerNode | {
+ value: Array<ComponentValue>;
+ };
+ state?: T;
+}, index: number | string) => boolean | void, state?: T): false | undefined;
+
+/**
* Generate a function that finds the next element that should be visited when walking an AST.
* Rules :
- * - the previous iteration is used as a reference, so any checks are relative to the start of the current iteration.
- * - the next element always appears after the current index.
- * - the next element always exists in the list.
- * - replacing an element does not cause the replaced element to be visited.
- * - removing an element does not cause elements to be skipped.
- * - an element added later in the list will be visited.
+ * 1. the previous iteration is used as a reference, so any checks are relative to the start of the current iteration.
+ * 2. the next element always appears after the current index.
+ * 3. the next element always exists in the list.
+ * 4. replacing an element does not cause the replaced element to be visited.
+ * 5. removing an element does not cause elements to be skipped.
+ * 6. an element added later in the list will be visited.
*/
export declare function walkerIndexGenerator<T>(initialList: Array<T>): (list: Array<T>, child: T, index: number) => number;
export declare class WhitespaceNode {
+ /**
+ * The node type, always `ComponentValueType.WhiteSpace`
+ */
type: ComponentValueType;
+ /**
+ * The list of consecutive whitespace tokens.
+ */
value: Array<CSSToken>;
constructor(value: Array<CSSToken>);
+ /**
+ * Retrieve the tokens for the current whitespace.
+ * This is the inverse of parsing from a list of tokens.
+ */
tokens(): Array<CSSToken>;
+ /**
+ * Convert the current whitespace to a string.
+ * This is not a true serialization.
+ * It is purely a concatenation of the string representation of the tokens.
+ */
toString(): string;
+ /**
+ * @internal
+ *
+ * A debug helper to convert the current object to a JSON representation.
+ * This is useful in asserts and to store large ASTs in files.
+ */
toJSON(): {
type: ComponentValueType;
tokens: CSSToken[];
};
+ /**
+ * @internal
+ */
isWhitespaceNode(): this is WhitespaceNode;
+ /**
+ * @internal
+ */
static isWhitespaceNode(x: unknown): x is WhitespaceNode;
}
diff --git a/node_modules/@csstools/css-parser-algorithms/dist/index.mjs b/node_modules/@csstools/css-parser-algorithms/dist/index.mjs
index 63b5ace3..0032d39c 100644
--- a/node_modules/@csstools/css-parser-algorithms/dist/index.mjs
+++ b/node_modules/@csstools/css-parser-algorithms/dist/index.mjs
@@ -1 +1 @@
-import{TokenType as e,isToken as n,stringify as t,mirrorVariant as o,ParseError as s,mirrorVariantType as i}from"@csstools/css-tokenizer";var r;function walkerIndexGenerator(e){let n=e.slice();return(e,t,o)=>{let s=-1;for(let i=n.indexOf(t);i<n.length&&(s=e.indexOf(n[i]),-1===s||s<o);i++);return-1===s||s===o&&t===e[o]&&(s++,s>=e.length)?-1:(n=e.slice(),s)}}function consumeComponentValue(n,t){const o=t[0];if(o[0]===e.OpenParen||o[0]===e.OpenCurly||o[0]===e.OpenSquare){const e=consumeSimpleBlock(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Function){const e=consumeFunction(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Whitespace){const e=consumeWhitespace(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Comment){const e=consumeComment(n,t);return{advance:e.advance,node:e.node}}return{advance:1,node:new TokenNode(o)}}!function(e){e.Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token"}(r||(r={}));class ContainerNodeBaseClass{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,n){if(0===this.value.length)return;const t=walkerIndexGenerator(this.value);let o=0;for(;o<this.value.length;){const s=this.value[o];let i;if(n&&(i={...n}),!1===e({node:s,parent:this,state:i},o))return!1;if(o=t(this.value,s,o),-1===o)break}}walk(e,n){0!==this.value.length&&this.forEach(((n,t)=>!1!==e(n,t)&&((!("walk"in n.node)||!this.value.includes(n.node)||!1!==n.node.walk(e,n.state))&&void 0)),n)}}class FunctionNode extends ContainerNodeBaseClass{type=r.Function;name;endToken;constructor(e,n,t){super(),this.name=e,this.endToken=n,this.value=t}getName(){return this.name[4].value}normalize(){this.endToken[0]===e.EOF&&(this.endToken=[e.CloseParen,")",-1,-1,void 0])}tokens(){return this.endToken[0]===e.EOF?[this.name,...this.value.flatMap((e=>e.tokens()))]:[this.name,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n(e)?t(e):e.toString())).join("");return t(this.name)+e+t(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===r.Function)}}function consumeFunction(n,t){const o=[];let i=1;for(;;){const r=t[i];if(!r||r[0]===e.EOF)return n.onParseError(new s("Unexpected EOF while consuming a function.",t[0][2],t[t.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:t.length,node:new FunctionNode(t[0],r,o)};if(r[0]===e.CloseParen)return{advance:i+1,node:new FunctionNode(t[0],r,o)};if(r[0]===e.Comment||r[0]===e.Whitespace){const e=consumeAllCommentsAndWhitespace(n,t.slice(i));i+=e.advance,o.push(...e.nodes);continue}const a=consumeComponentValue(n,t.slice(i));i+=a.advance,o.push(a.node)}}class SimpleBlockNode extends ContainerNodeBaseClass{type=r.SimpleBlock;startToken;endToken;constructor(e,n,t){super(),this.startToken=e,this.endToken=n,this.value=t}normalize(){if(this.endToken[0]===e.EOF){const e=o(this.startToken);e&&(this.endToken=e)}}tokens(){return this.endToken[0]===e.EOF?[this.startToken,...this.value.flatMap((e=>e.tokens()))]:[this.startToken,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n(e)?t(e):e.toString())).join("");return t(this.startToken)+e+t(this.endToken)}indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===r.SimpleBlock)}}function consumeSimpleBlock(n,t){const o=i(t[0][0]);if(!o)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const r=[];let a=1;for(;;){const i=t[a];if(!i||i[0]===e.EOF)return n.onParseError(new s("Unexpected EOF while consuming a simple block.",t[0][2],t[t.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:t.length,node:new SimpleBlockNode(t[0],i,r)};if(i[0]===o)return{advance:a+1,node:new SimpleBlockNode(t[0],i,r)};if(i[0]===e.Comment||i[0]===e.Whitespace){const e=consumeAllCommentsAndWhitespace(n,t.slice(a));a+=e.advance,r.push(...e.nodes);continue}const c=consumeComponentValue(n,t.slice(a));a+=c.advance,r.push(c.node)}}class WhitespaceNode{type=r.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return t(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===r.Whitespace)}}function consumeWhitespace(n,t){let o=0;for(;;){if(t[o][0]!==e.Whitespace)return{advance:o,node:new WhitespaceNode(t.slice(0,o))};o++}}class CommentNode{type=r.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return t(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===r.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(n,t){const o=[];let s=0;for(;;)if(t[s][0]!==e.Whitespace){if(t[s][0]!==e.Comment)return{advance:s,nodes:o};o.push(new CommentNode(t[s])),s++}else{const e=consumeWhitespace(0,t.slice(s));s+=e.advance,o.push(e.node)}}class TokenNode{type=r.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return t(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===r.Token)}}function parseComponentValue(n,t){const o={onParseError:t?.onParseError??(()=>{})},i=[...n];i[i.length-1][0]!==e.EOF&&i.push([e.EOF,"",i[i.length-1][2],i[i.length-1][3],void 0]);const r=consumeComponentValue(o,i);if(i[Math.min(r.advance,i.length-1)][0]===e.EOF)return r.node;o.onParseError(new s("Expected EOF after parsing a component value.",n[0][2],n[n.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))}function parseListOfComponentValues(n,t){const o={onParseError:t?.onParseError??(()=>{})},s=[...n];s[s.length-1][0]!==e.EOF&&s.push([e.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=0;for(;;){if(!s[r]||s[r][0]===e.EOF)return i;const n=consumeComponentValue(o,s.slice(r));i.push(n.node),r+=n.advance}}function parseCommaSeparatedListOfComponentValues(n,t){const o={onParseError:t?.onParseError??(()=>{})},s=[...n];if(0===n.length)return[];s[s.length-1][0]!==e.EOF&&s.push([e.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=[],a=0;for(;;){if(!s[a]||s[a][0]===e.EOF)return r.length&&i.push(r),i;if(s[a][0]===e.Comma){i.push(r),r=[],a++;continue}const t=consumeComponentValue(o,n.slice(a));r.push(t.node),a+=t.advance}}function gatherNodeAncestry(e){const n=new Map;return e.walk((e=>{Array.isArray(e.node)?e.node.forEach((t=>{n.set(t,e.parent)})):n.set(e.node,e.parent)})),n}function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)}function isFunctionNode(e){return FunctionNode.isFunctionNode(e)}function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)}function isCommentNode(e){return CommentNode.isCommentNode(e)}function isTokenNode(e){return TokenNode.isTokenNode(e)}function replaceComponentValues(e,n){for(let t=0;t<e.length;t++){const o=e[t];for(let e=0;e<o.length;e++){const t=o[e];{const s=n(t);if(s){o.splice(e,1,s);continue}}(isSimpleBlockNode(t)||isFunctionNode(t))&&t.walk(((e,t)=>{if("number"!=typeof t)return;const o=e.node,s=n(o);s&&e.parent.value.splice(t,1,s)}))}}return e}function stringify(e){return e.map((e=>e.map((e=>t(...e.tokens()))).join(""))).join(",")}function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const t=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(t)[1]]}const n=e.tokens(),t=n[0],o=n[n.length-1];return t&&o?[t[2],o[3]]:[0,0]}export{CommentNode,r as ComponentValueType,ContainerNodeBaseClass,FunctionNode,SimpleBlockNode,TokenNode,WhitespaceNode,gatherNodeAncestry,isCommentNode,isFunctionNode,isSimpleBlockNode,isTokenNode,isWhitespaceNode,parseCommaSeparatedListOfComponentValues,parseComponentValue,parseListOfComponentValues,replaceComponentValues,sourceIndices,stringify,walkerIndexGenerator};
+import{TokenType as e,isToken as n,stringify as t,mirrorVariant as o,ParseError as s,mirrorVariantType as i}from"@csstools/css-tokenizer";var r;function walkerIndexGenerator(e){let n=e.slice();return(e,t,o)=>{let s=-1;for(let i=n.indexOf(t);i<n.length&&(s=e.indexOf(n[i]),-1===s||s<o);i++);return-1===s||s===o&&t===e[o]&&(s++,s>=e.length)?-1:(n=e.slice(),s)}}function consumeComponentValue(n,t){const o=t[0];if(o[0]===e.OpenParen||o[0]===e.OpenCurly||o[0]===e.OpenSquare){const e=consumeSimpleBlock(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Function){const e=consumeFunction(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Whitespace){const e=consumeWhitespace(n,t);return{advance:e.advance,node:e.node}}if(o[0]===e.Comment){const e=consumeComment(n,t);return{advance:e.advance,node:e.node}}return{advance:1,node:new TokenNode(o)}}!function(e){e.Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token"}(r||(r={}));class ContainerNodeBaseClass{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if("number"==typeof e)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,n){if(0===this.value.length)return;const t=walkerIndexGenerator(this.value);let o=0;for(;o<this.value.length;){const s=this.value[o];let i;if(n&&(i={...n}),!1===e({node:s,parent:this,state:i},o))return!1;if(o=t(this.value,s,o),-1===o)break}}walk(e,n){0!==this.value.length&&this.forEach(((n,t)=>!1!==e(n,t)&&((!("walk"in n.node)||!this.value.includes(n.node)||!1!==n.node.walk(e,n.state))&&void 0)),n)}}class FunctionNode extends ContainerNodeBaseClass{type=r.Function;name;endToken;constructor(e,n,t){super(),this.name=e,this.endToken=n,this.value=t}getName(){return this.name[4].value}normalize(){this.endToken[0]===e.EOF&&(this.endToken=[e.CloseParen,")",-1,-1,void 0])}tokens(){return this.endToken[0]===e.EOF?[this.name,...this.value.flatMap((e=>e.tokens()))]:[this.name,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n(e)?t(e):e.toString())).join("");return t(this.name)+e+t(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isFunctionNode(){return FunctionNode.isFunctionNode(this)}static isFunctionNode(e){return!!e&&(e instanceof FunctionNode&&e.type===r.Function)}}function consumeFunction(n,t){const o=[];let i=1;for(;;){const r=t[i];if(!r||r[0]===e.EOF)return n.onParseError(new s("Unexpected EOF while consuming a function.",t[0][2],t[t.length-1][3],["5.4.9. Consume a function","Unexpected EOF"])),{advance:t.length,node:new FunctionNode(t[0],r,o)};if(r[0]===e.CloseParen)return{advance:i+1,node:new FunctionNode(t[0],r,o)};if(r[0]===e.Comment||r[0]===e.Whitespace){const e=consumeAllCommentsAndWhitespace(n,t.slice(i));i+=e.advance,o.push(...e.nodes);continue}const a=consumeComponentValue(n,t.slice(i));i+=a.advance,o.push(a.node)}}class SimpleBlockNode extends ContainerNodeBaseClass{type=r.SimpleBlock;startToken;endToken;constructor(e,n,t){super(),this.startToken=e,this.endToken=n,this.value=t}normalize(){if(this.endToken[0]===e.EOF){const e=o(this.startToken);e&&(this.endToken=e)}}tokens(){return this.endToken[0]===e.EOF?[this.startToken,...this.value.flatMap((e=>e.tokens()))]:[this.startToken,...this.value.flatMap((e=>e.tokens())),this.endToken]}toString(){const e=this.value.map((e=>n(e)?t(e):e.toString())).join("");return t(this.startToken)+e+t(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map((e=>e.toJSON()))}}isSimpleBlockNode(){return SimpleBlockNode.isSimpleBlockNode(this)}static isSimpleBlockNode(e){return!!e&&(e instanceof SimpleBlockNode&&e.type===r.SimpleBlock)}}function consumeSimpleBlock(n,t){const o=i(t[0][0]);if(!o)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const r=[];let a=1;for(;;){const i=t[a];if(!i||i[0]===e.EOF)return n.onParseError(new s("Unexpected EOF while consuming a simple block.",t[0][2],t[t.length-1][3],["5.4.8. Consume a simple block","Unexpected EOF"])),{advance:t.length,node:new SimpleBlockNode(t[0],i,r)};if(i[0]===o)return{advance:a+1,node:new SimpleBlockNode(t[0],i,r)};if(i[0]===e.Comment||i[0]===e.Whitespace){const e=consumeAllCommentsAndWhitespace(n,t.slice(a));a+=e.advance,r.push(...e.nodes);continue}const c=consumeComponentValue(n,t.slice(a));a+=c.advance,r.push(c.node)}}class WhitespaceNode{type=r.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return t(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return WhitespaceNode.isWhitespaceNode(this)}static isWhitespaceNode(e){return!!e&&(e instanceof WhitespaceNode&&e.type===r.Whitespace)}}function consumeWhitespace(n,t){let o=0;for(;;){if(t[o][0]!==e.Whitespace)return{advance:o,node:new WhitespaceNode(t.slice(0,o))};o++}}class CommentNode{type=r.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return t(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return CommentNode.isCommentNode(this)}static isCommentNode(e){return!!e&&(e instanceof CommentNode&&e.type===r.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(n,t){const o=[];let s=0;for(;;)if(t[s][0]!==e.Whitespace){if(t[s][0]!==e.Comment)return{advance:s,nodes:o};o.push(new CommentNode(t[s])),s++}else{const e=consumeWhitespace(0,t.slice(s));s+=e.advance,o.push(e.node)}}class TokenNode{type=r.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return TokenNode.isTokenNode(this)}static isTokenNode(e){return!!e&&(e instanceof TokenNode&&e.type===r.Token)}}function parseComponentValue(n,t){const o={onParseError:t?.onParseError??(()=>{})},i=[...n];i[i.length-1][0]!==e.EOF&&i.push([e.EOF,"",i[i.length-1][2],i[i.length-1][3],void 0]);const r=consumeComponentValue(o,i);if(i[Math.min(r.advance,i.length-1)][0]===e.EOF)return r.node;o.onParseError(new s("Expected EOF after parsing a component value.",n[0][2],n[n.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))}function parseListOfComponentValues(n,t){const o={onParseError:t?.onParseError??(()=>{})},s=[...n];s[s.length-1][0]!==e.EOF&&s.push([e.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=0;for(;;){if(!s[r]||s[r][0]===e.EOF)return i;const n=consumeComponentValue(o,s.slice(r));i.push(n.node),r+=n.advance}}function parseCommaSeparatedListOfComponentValues(n,t){const o={onParseError:t?.onParseError??(()=>{})},s=[...n];if(0===n.length)return[];s[s.length-1][0]!==e.EOF&&s.push([e.EOF,"",s[s.length-1][2],s[s.length-1][3],void 0]);const i=[];let r=[],a=0;for(;;){if(!s[a]||s[a][0]===e.EOF)return r.length&&i.push(r),i;if(s[a][0]===e.Comma){i.push(r),r=[],a++;continue}const t=consumeComponentValue(o,n.slice(a));r.push(t.node),a+=t.advance}}function gatherNodeAncestry(e){const n=new Map;return e.walk((e=>{Array.isArray(e.node)?e.node.forEach((t=>{n.set(t,e.parent)})):n.set(e.node,e.parent)})),n}function forEach(e,n,t){if(0===e.length)return;const o=walkerIndexGenerator(e);let s=0;for(;s<e.length;){const i=e[s];let r;if(t&&(r={...t}),!1===n({node:i,parent:{value:e},state:r},s))return!1;if(s=o(e,i,s),-1===s)break}}function walk(e,n,t){0!==e.length&&forEach(e,((t,o)=>!1!==n(t,o)&&((!("walk"in t.node)||!e.includes(t.node)||!1!==t.node.walk(n,t.state))&&void 0)),t)}function replaceComponentValues(e,n){for(let t=0;t<e.length;t++){walk(e[t],((e,t)=>{if("number"!=typeof t)return;const o=n(e.node);o&&e.parent.value.splice(t,1,o)}))}return e}function stringify(e){return e.map((e=>e.map((e=>t(...e.tokens()))).join(""))).join(",")}function isSimpleBlockNode(e){return SimpleBlockNode.isSimpleBlockNode(e)}function isFunctionNode(e){return FunctionNode.isFunctionNode(e)}function isWhitespaceNode(e){return WhitespaceNode.isWhitespaceNode(e)}function isCommentNode(e){return CommentNode.isCommentNode(e)}function isTokenNode(e){return TokenNode.isTokenNode(e)}function sourceIndices(e){if(Array.isArray(e)){const n=e[0];if(!n)return[0,0];const t=e[e.length-1]||n;return[sourceIndices(n)[0],sourceIndices(t)[1]]}const n=e.tokens(),t=n[0],o=n[n.length-1];return t&&o?[t[2],o[3]]:[0,0]}export{CommentNode,r as ComponentValueType,ContainerNodeBaseClass,FunctionNode,SimpleBlockNode,TokenNode,WhitespaceNode,forEach,gatherNodeAncestry,isCommentNode,isFunctionNode,isSimpleBlockNode,isTokenNode,isWhitespaceNode,parseCommaSeparatedListOfComponentValues,parseComponentValue,parseListOfComponentValues,replaceComponentValues,sourceIndices,stringify,walk,walkerIndexGenerator};
diff --git a/node_modules/@csstools/css-parser-algorithms/package.json b/node_modules/@csstools/css-parser-algorithms/package.json
index 560095a7..4494b60f 100644
--- a/node_modules/@csstools/css-parser-algorithms/package.json
+++ b/node_modules/@csstools/css-parser-algorithms/package.json
@@ -1,7 +1,7 @@
{
"name": "@csstools/css-parser-algorithms",
"description": "Algorithms to help you parse CSS from an array of tokens.",
- "version": "2.4.0",
+ "version": "2.5.0",
"contributors": [
{
"name": "Antonio Laguna",
@@ -48,7 +48,7 @@
"dist"
],
"peerDependencies": {
- "@csstools/css-tokenizer": "^2.2.2"
+ "@csstools/css-tokenizer": "^2.2.3"
},
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms#readme",
"repository": {