Leon4gr45 commited on
Commit
909f4df
·
verified ·
1 Parent(s): 78901f4

Upload folder using huggingface_hub (part 6)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/@csstools/css-calc/LICENSE.md +20 -0
  2. node_modules/@csstools/css-calc/README.md +132 -0
  3. node_modules/@csstools/css-calc/dist/index.d.ts +106 -0
  4. node_modules/@csstools/css-calc/dist/index.mjs +1 -0
  5. node_modules/@csstools/css-calc/package.json +59 -0
  6. node_modules/@csstools/css-color-parser/CHANGELOG.md +9 -0
  7. node_modules/@csstools/css-color-parser/LICENSE.md +20 -0
  8. node_modules/@csstools/css-color-parser/README.md +37 -0
  9. node_modules/@csstools/css-color-parser/dist/index.d.ts +168 -0
  10. node_modules/@csstools/css-color-parser/dist/index.mjs +1 -0
  11. node_modules/@csstools/css-color-parser/package.json +64 -0
  12. node_modules/@csstools/css-parser-algorithms/CHANGELOG.md +11 -0
  13. node_modules/@csstools/css-parser-algorithms/LICENSE.md +20 -0
  14. node_modules/@csstools/css-parser-algorithms/README.md +119 -0
  15. node_modules/@csstools/css-parser-algorithms/dist/index.d.ts +604 -0
  16. node_modules/@csstools/css-parser-algorithms/dist/index.mjs +1 -0
  17. node_modules/@csstools/css-parser-algorithms/package.json +58 -0
  18. node_modules/@csstools/css-syntax-patches-for-csstree/CHANGELOG.md +10 -0
  19. node_modules/@csstools/css-syntax-patches-for-csstree/LICENSE.md +18 -0
  20. node_modules/@csstools/css-syntax-patches-for-csstree/README.md +43 -0
  21. node_modules/@csstools/css-syntax-patches-for-csstree/dist/index.d.ts +5 -0
  22. node_modules/@csstools/css-syntax-patches-for-csstree/dist/index.json +794 -0
  23. node_modules/@csstools/css-syntax-patches-for-csstree/package.json +56 -0
  24. node_modules/@csstools/css-tokenizer/CHANGELOG.md +10 -0
  25. node_modules/@csstools/css-tokenizer/LICENSE.md +20 -0
  26. node_modules/@csstools/css-tokenizer/README.md +111 -0
  27. node_modules/@csstools/css-tokenizer/dist/index.d.ts +593 -0
  28. node_modules/@csstools/css-tokenizer/dist/index.mjs +1 -0
  29. node_modules/@csstools/css-tokenizer/package.json +55 -0
  30. node_modules/@emnapi/core/LICENSE +21 -0
  31. node_modules/@emnapi/core/README.md +1 -0
  32. node_modules/@emnapi/core/dist/emnapi-core.cjs.js +0 -0
  33. node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts +420 -0
  34. node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js +0 -0
  35. node_modules/@emnapi/core/dist/emnapi-core.d.mts +420 -0
  36. node_modules/@emnapi/core/dist/emnapi-core.d.ts +422 -0
  37. node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js +0 -0
  38. node_modules/@emnapi/core/dist/emnapi-core.js +0 -0
  39. node_modules/@emnapi/core/dist/emnapi-core.min.d.mts +420 -0
  40. node_modules/@emnapi/core/dist/emnapi-core.min.js +0 -0
  41. node_modules/@emnapi/core/dist/emnapi-core.min.mjs +0 -0
  42. node_modules/@emnapi/core/dist/emnapi-core.mjs +0 -0
  43. node_modules/@emnapi/core/index.js +5 -0
  44. node_modules/@emnapi/core/package.json +49 -0
  45. node_modules/@emnapi/runtime/LICENSE +21 -0
  46. node_modules/@emnapi/runtime/README.md +1 -0
  47. node_modules/@emnapi/runtime/dist/emnapi.cjs.js +1381 -0
  48. node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts +671 -0
  49. node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js +1 -0
  50. node_modules/@emnapi/runtime/dist/emnapi.d.mts +671 -0
node_modules/@csstools/css-calc/LICENSE.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/@csstools/css-calc/README.md ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Calc <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-calc.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+ [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
+
7
+ Implemented from : https://drafts.csswg.org/css-values-4/ on 2023-02-17
8
+
9
+ ## Usage
10
+
11
+ Add [CSS calc] to your project:
12
+
13
+ ```bash
14
+ npm install @csstools/css-calc @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev
15
+ ```
16
+
17
+ ### With string values :
18
+
19
+ ```mjs
20
+ import { calc } from '@csstools/css-calc';
21
+
22
+ // '20'
23
+ console.log(calc('calc(10 * 2)'));
24
+ ```
25
+
26
+ ### With component values :
27
+
28
+ ```mjs
29
+ import { stringify, tokenizer } from '@csstools/css-tokenizer';
30
+ import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser-algorithms';
31
+ import { calcFromComponentValues } from '@csstools/css-calc';
32
+
33
+ const t = tokenizer({
34
+ css: 'calc(10 * 2)',
35
+ });
36
+
37
+ const tokens = [];
38
+
39
+ {
40
+ while (!t.endOfFile()) {
41
+ tokens.push(t.nextToken());
42
+ }
43
+
44
+ tokens.push(t.nextToken()); // EOF-token
45
+ }
46
+
47
+ const result = parseCommaSeparatedListOfComponentValues(tokens, {});
48
+
49
+ // filter or mutate the component values
50
+
51
+ const calcResult = calcFromComponentValues(result, { precision: 5, toCanonicalUnits: true });
52
+
53
+ // filter or mutate the component values even further
54
+
55
+ const calcResultStr = calcResult.map((componentValues) => {
56
+ return componentValues.map((x) => stringify(...x.tokens())).join('');
57
+ }).join(',');
58
+
59
+ // '20'
60
+ console.log(calcResultStr);
61
+ ```
62
+
63
+ ### Options
64
+
65
+ #### `precision` :
66
+
67
+ The default precision is fairly high.
68
+ It aims to be high enough to make rounding unnoticeable in the browser.
69
+
70
+ You can set it to a lower number to suit your needs.
71
+
72
+ ```mjs
73
+ import { calc } from '@csstools/css-calc';
74
+
75
+ // '0.3'
76
+ console.log(calc('calc(1 / 3)', { precision: 1 }));
77
+ // '0.33'
78
+ console.log(calc('calc(1 / 3)', { precision: 2 }));
79
+ ```
80
+
81
+ #### `globals` :
82
+
83
+ Pass global values as a map of key value pairs.
84
+
85
+ > Example : Relative color syntax (`lch(from pink calc(l / 2) c h)`) exposes color channel information as ident tokens.
86
+ > By passing globals for `l`, `c` and `h` it is possible to solve nested `calc()`'s.
87
+
88
+ ```mjs
89
+ import { calc } from '@csstools/css-calc';
90
+
91
+ const globals = new Map([
92
+ ['a', '10px'],
93
+ ['b', '2rem'],
94
+ ]);
95
+
96
+ // '20px'
97
+ console.log(calc('calc(a * 2)', { globals: globals }));
98
+ // '6rem'
99
+ console.log(calc('calc(b * 3)', { globals: globals }));
100
+ ```
101
+
102
+ #### `toCanonicalUnits` :
103
+
104
+ By default this package will try to preserve units.
105
+ The heuristic to do this is very simplistic.
106
+ We take the first unit we encounter and try to convert other dimensions to that unit.
107
+
108
+ This better matches what users expect from a CSS dev tool.
109
+
110
+ If you want to have outputs that are closes to CSS serialized values you can pass `toCanonicalUnits: true`.
111
+
112
+ ```mjs
113
+ import { calc } from '@csstools/css-calc';
114
+
115
+ // '20hz'
116
+ console.log(calc('calc(0.01khz + 10hz)', { toCanonicalUnits: true }));
117
+
118
+ // '20hz'
119
+ console.log(calc('calc(10hz + 0.01khz)', { toCanonicalUnits: true }));
120
+
121
+ // '0.02khz' !!!
122
+ console.log(calc('calc(0.01khz + 10hz)', { toCanonicalUnits: false }));
123
+
124
+ // '20hz'
125
+ console.log(calc('calc(10hz + 0.01khz)', { toCanonicalUnits: false }));
126
+ ```
127
+
128
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
129
+ [discord]: https://discord.gg/bUadyRwkJS
130
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-calc
131
+
132
+ [CSS calc]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc
node_modules/@csstools/css-calc/dist/index.d.ts ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ComponentValue } from '@csstools/css-parser-algorithms';
2
+ import type { TokenDimension } from '@csstools/css-tokenizer';
3
+ import type { TokenNumber } from '@csstools/css-tokenizer';
4
+ import type { TokenPercentage } from '@csstools/css-tokenizer';
5
+
6
+ export declare function calc(css: string, options?: conversionOptions): string;
7
+
8
+ export declare function calcFromComponentValues(componentValuesList: Array<Array<ComponentValue>>, options?: conversionOptions): Array<Array<ComponentValue>>;
9
+
10
+ export declare type conversionOptions = {
11
+ /**
12
+ * If a calc expression can not be solved the parse error might be reported through this callback.
13
+ * Not all cases are covered. Open an issue if you need specific errors reported.
14
+ *
15
+ * Values are recursively visited and at each nesting level an attempt is made to solve the expression.
16
+ * Errors can be reported multiple times as a result of this.
17
+ */
18
+ onParseError?: (error: ParseError) => void;
19
+ /**
20
+ * Pass global values as a map of key value pairs.
21
+ */
22
+ globals?: GlobalsWithStrings;
23
+ /**
24
+ * The default precision is fairly high.
25
+ * It aims to be high enough to make rounding unnoticeable in the browser.
26
+ * You can set it to a lower number to suite your needs.
27
+ */
28
+ precision?: number;
29
+ /**
30
+ * The CSS pixel length of one device pixel.
31
+ * Used when rounding to `line-width` and similar features
32
+ */
33
+ devicePixelLength?: number;
34
+ /**
35
+ * By default this package will try to preserve units.
36
+ * The heuristic to do this is very simplistic.
37
+ * We take the first unit we encounter and try to convert other dimensions to that unit.
38
+ *
39
+ * This better matches what users expect from a CSS dev tool.
40
+ *
41
+ * If you want to have outputs that are closes to CSS serialized values you can set `true`.
42
+ */
43
+ toCanonicalUnits?: boolean;
44
+ /**
45
+ * Convert NaN, Infinity, ... into standard representable values.
46
+ */
47
+ censorIntoStandardRepresentableValues?: boolean;
48
+ /**
49
+ * Some percentages resolve against other values and might be negative or positive depending on context.
50
+ * Raw percentages are more likely to be safe to simplify outside of a browser context
51
+ *
52
+ * @see https://drafts.csswg.org/css-values-4/#calc-simplification
53
+ */
54
+ rawPercentages?: boolean;
55
+ /**
56
+ * The values used to generate random value cache keys.
57
+ */
58
+ randomCaching?: {
59
+ /**
60
+ * The name of the property the random function is used in.
61
+ */
62
+ propertyName: string;
63
+ /**
64
+ * N is the index of the random function among other random functions in the same property value.
65
+ */
66
+ propertyN: number;
67
+ /**
68
+ * An element ID identifying the element the style is being applied to.
69
+ * When omitted any `random()` call will not be computed.
70
+ */
71
+ elementID: string;
72
+ /**
73
+ * A document ID identifying the Document the styles are from.
74
+ * When omitted any `random()` call will not be computed.
75
+ */
76
+ documentID: string;
77
+ };
78
+ };
79
+
80
+ export declare type GlobalsWithStrings = Map<string, TokenDimension | TokenNumber | TokenPercentage | string>;
81
+
82
+ export declare const mathFunctionNames: Set<string>;
83
+
84
+ /**
85
+ * Any errors are reported through the `onParseError` callback.
86
+ */
87
+ export declare class ParseError extends Error {
88
+ /** The index of the start character of the current token. */
89
+ sourceStart: number;
90
+ /** The index of the end character of the current token. */
91
+ sourceEnd: number;
92
+ constructor(message: string, sourceStart: number, sourceEnd: number);
93
+ }
94
+
95
+ export declare const ParseErrorMessage: {
96
+ UnexpectedAdditionOfDimensionOrPercentageWithNumber: string;
97
+ UnexpectedSubtractionOfDimensionOrPercentageWithNumber: string;
98
+ };
99
+
100
+ export declare class ParseErrorWithComponentValues extends ParseError {
101
+ /** The associated component values. */
102
+ componentValues: Array<ComponentValue>;
103
+ constructor(message: string, componentValues: Array<ComponentValue>);
104
+ }
105
+
106
+ export { }
node_modules/@csstools/css-calc/dist/index.mjs ADDED
@@ -0,0 +1 @@
 
 
1
+ import{sourceIndices as e,TokenNode as n,isTokenNode as t,isWhitespaceNode as r,isCommentNode as a,isWhiteSpaceOrCommentNode as u,isSimpleBlockNode as i,isFunctionNode as o,FunctionNode as l,WhitespaceNode as c,parseCommaSeparatedListOfComponentValues as s,walk as v}from"@csstools/css-parser-algorithms";import{isTokenDimension as f,TokenType as m,NumberType as p,mutateUnit as d,isTokenNumber as C,isTokenPercentage as g,isTokenIdent as D,isTokenNumeric as h,isTokenOpenParen as N,isTokenDelim as B,isTokenComma as A,isToken as b,tokenizer as F,tokenize as w,stringify as E,isTokenColon as I,isTokenSemicolon as S}from"@csstools/css-tokenizer";class ParseError extends Error{sourceStart;sourceEnd;constructor(e,n,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=t}}class ParseErrorWithComponentValues extends ParseError{componentValues;constructor(n,t){super(n,...e(t)),this.componentValues=t}}const y={UnexpectedAdditionOfDimensionOrPercentageWithNumber:"Unexpected addition of a dimension or percentage with a number.",UnexpectedSubtractionOfDimensionOrPercentageWithNumber:"Unexpected subtraction of a dimension or percentage with a number."},M=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(M,e=>String.fromCharCode(e.charCodeAt(0)+32))}const T={cm:"px",in:"px",mm:"px",pc:"px",pt:"px",px:"px",q:"px",deg:"deg",grad:"deg",rad:"deg",turn:"deg",ms:"s",s:"s",hz:"hz",khz:"hz"},x=new Map([["cm",e=>e],["mm",e=>10*e],["q",e=>40*e],["in",e=>e/2.54],["pc",e=>e/2.54*6],["pt",e=>e/2.54*72],["px",e=>e/2.54*96]]),P=new Map([["deg",e=>e],["grad",e=>e/.9],["rad",e=>e/180*Math.PI],["turn",e=>e/360]]),k=new Map([["deg",e=>.9*e],["grad",e=>e],["rad",e=>.9*e/180*Math.PI],["turn",e=>.9*e/360]]),W=new Map([["hz",e=>e],["khz",e=>e/1e3]]),O=new Map([["cm",e=>2.54*e],["mm",e=>25.4*e],["q",e=>25.4*e*4],["in",e=>e],["pc",e=>6*e],["pt",e=>72*e],["px",e=>96*e]]),U=new Map([["hz",e=>1e3*e],["khz",e=>e]]),L=new Map([["cm",e=>e/10],["mm",e=>e],["q",e=>4*e],["in",e=>e/25.4],["pc",e=>e/25.4*6],["pt",e=>e/25.4*72],["px",e=>e/25.4*96]]),$=new Map([["ms",e=>e],["s",e=>e/1e3]]),V=new Map([["cm",e=>e/6*2.54],["mm",e=>e/6*25.4],["q",e=>e/6*25.4*4],["in",e=>e/6],["pc",e=>e],["pt",e=>e/6*72],["px",e=>e/6*96]]),Z=new Map([["cm",e=>e/72*2.54],["mm",e=>e/72*25.4],["q",e=>e/72*25.4*4],["in",e=>e/72],["pc",e=>e/72*6],["pt",e=>e],["px",e=>e/72*96]]),z=new Map([["cm",e=>e/96*2.54],["mm",e=>e/96*25.4],["q",e=>e/96*25.4*4],["in",e=>e/96],["pc",e=>e/96*6],["pt",e=>e/96*72],["px",e=>e]]),q=new Map([["cm",e=>e/4/10],["mm",e=>e/4],["q",e=>e],["in",e=>e/4/25.4],["pc",e=>e/4/25.4*6],["pt",e=>e/4/25.4*72],["px",e=>e/4/25.4*96]]),G=new Map([["deg",e=>180*e/Math.PI],["grad",e=>180*e/Math.PI/.9],["rad",e=>e],["turn",e=>180*e/Math.PI/360]]),R=new Map([["ms",e=>1e3*e],["s",e=>e]]),j=new Map([["deg",e=>360*e],["grad",e=>360*e/.9],["rad",e=>360*e/180*Math.PI],["turn",e=>e]]),Y=new Map([["cm",x],["mm",L],["q",q],["in",O],["pc",V],["pt",Z],["px",z],["ms",$],["s",R],["deg",P],["grad",k],["rad",G],["turn",j],["hz",W],["khz",U]]);function convertUnit(e,n){if(!f(e))return n;if(!f(n))return n;const t=toLowerCaseAZ(e[4].unit),r=toLowerCaseAZ(n[4].unit);if(t===r)return n;const a=Y.get(r);if(!a)return n;const u=a.get(t);if(!u)return n;const i=u(n[4].value),o=[m.Dimension,"",n[2],n[3],{...n[4],signCharacter:i<0?"-":void 0,type:Number.isInteger(i)?p.Integer:p.Number,value:i}];return d(o,e[4].unit),o}function toCanonicalUnit(e){if(!f(e))return e;const n=toLowerCaseAZ(e[4].unit),t=T[n];if(n===t)return e;const r=Y.get(n);if(!r)return e;const a=r.get(t);if(!a)return e;const u=a(e[4].value),i=[m.Dimension,"",e[2],e[3],{...e[4],signCharacter:u<0?"-":void 0,type:Number.isInteger(u)?p.Integer:p.Number,value:u}];return d(i,t),i}function addition(e,t){if(2!==e.length)return-1;const r=e[0].value;let a=e[1].value;if(C(r)&&C(a)){const e=r[4].value+a[4].value;return new n([m.Number,e.toString(),r[2],a[3],{value:e,type:r[4].type===p.Integer&&a[4].type===p.Integer?p.Integer:p.Number}])}if(g(r)&&g(a)){const e=r[4].value+a[4].value;return new n([m.Percentage,e.toString()+"%",r[2],a[3],{value:e}])}if(f(r)&&f(a)&&(a=convertUnit(r,a),toLowerCaseAZ(r[4].unit)===toLowerCaseAZ(a[4].unit))){const e=r[4].value+a[4].value;return new n([m.Dimension,e.toString()+r[4].unit,r[2],a[3],{value:e,type:r[4].type===p.Integer&&a[4].type===p.Integer?p.Integer:p.Number,unit:r[4].unit}])}return(C(r)&&(f(a)||g(a))||C(a)&&(f(r)||g(r)))&&t.onParseError?.(new ParseErrorWithComponentValues(y.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function division(e){if(2!==e.length)return-1;const t=e[0].value,r=e[1].value;if(C(t)&&C(r)){const e=t[4].value/r[4].value;return new n([m.Number,e.toString(),t[2],r[3],{value:e,type:Number.isInteger(e)?p.Integer:p.Number}])}if(g(t)&&C(r)){const e=t[4].value/r[4].value;return new n([m.Percentage,e.toString()+"%",t[2],r[3],{value:e}])}if(f(t)&&C(r)){const e=t[4].value/r[4].value;return new n([m.Dimension,e.toString()+t[4].unit,t[2],r[3],{value:e,type:Number.isInteger(e)?p.Integer:p.Number,unit:t[4].unit}])}return-1}function isCalculation(e){return!!e&&"object"==typeof e&&"inputs"in e&&Array.isArray(e.inputs)&&"operation"in e}function solve(e,n){if(-1===e)return-1;const r=[];for(let a=0;a<e.inputs.length;a++){const u=e.inputs[a];if(t(u)){r.push(u);continue}const i=solve(u,n);if(-1===i)return-1;r.push(i)}return e.operation(r,n)}function multiplication(e){if(2!==e.length)return-1;const t=e[0].value,r=e[1].value;if(C(t)&&C(r)){const e=t[4].value*r[4].value;return new n([m.Number,e.toString(),t[2],r[3],{value:e,type:t[4].type===p.Integer&&r[4].type===p.Integer?p.Integer:p.Number}])}if(g(t)&&C(r)){const e=t[4].value*r[4].value;return new n([m.Percentage,e.toString()+"%",t[2],r[3],{value:e}])}if(C(t)&&g(r)){const e=t[4].value*r[4].value;return new n([m.Percentage,e.toString()+"%",t[2],r[3],{value:e}])}if(f(t)&&C(r)){const e=t[4].value*r[4].value;return new n([m.Dimension,e.toString()+t[4].unit,t[2],r[3],{value:e,type:t[4].type===p.Integer&&r[4].type===p.Integer?p.Integer:p.Number,unit:t[4].unit}])}if(C(t)&&f(r)){const e=t[4].value*r[4].value;return new n([m.Dimension,e.toString()+r[4].unit,t[2],r[3],{value:e,type:t[4].type===p.Integer&&r[4].type===p.Integer?p.Integer:p.Number,unit:r[4].unit}])}return-1}function resolveGlobalsAndConstants(e,r){for(let a=0;a<e.length;a++){const u=e[a];if(!t(u))continue;const i=u.value;if(!D(i))continue;const o=toLowerCaseAZ(i[4].value);switch(o){case"e":e.splice(a,1,new n([m.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:p.Number}]));break;case"pi":e.splice(a,1,new n([m.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:p.Number}]));break;case"infinity":e.splice(a,1,new n([m.Number,"infinity",i[2],i[3],{value:1/0,type:p.Number}]));break;case"-infinity":e.splice(a,1,new n([m.Number,"-infinity",i[2],i[3],{value:-1/0,type:p.Number}]));break;case"nan":e.splice(a,1,new n([m.Number,"NaN",i[2],i[3],{value:Number.NaN,type:p.Number}]));break;default:if(r.has(o)){const t=r.get(o);e.splice(a,1,new n(t))}}}return e}function unary(e){if(1!==e.length)return-1;const n=e[0].value;return h(n)?e[0]:-1}function resultToCalculation(e,n,t){return f(n)?dimensionToCalculation(e,n[4].unit,t):g(n)?percentageToCalculation(e,t):C(n)?numberToCalculation(e,t):-1}function dimensionToCalculation(e,t,r){const a=e.tokens();return{inputs:[new n([m.Dimension,r.toString()+t,a[0][2],a[a.length-1][3],{value:r,type:Number.isInteger(r)?p.Integer:p.Number,unit:t}])],operation:unary}}function percentageToCalculation(e,t){const r=e.tokens();return{inputs:[new n([m.Percentage,t.toString()+"%",r[0][2],r[r.length-1][3],{value:t}])],operation:unary}}function numberToCalculation(e,t){const r=e.tokens();return{inputs:[new n([m.Number,t.toString(),r[0][2],r[r.length-1][3],{value:t,type:Number.isInteger(t)?p.Integer:p.Number}])],operation:unary}}function solveACos(e,n){const t=n.value;if(!C(t))return-1;return dimensionToCalculation(e,"rad",Math.acos(t[4].value))}function solveASin(e,n){const t=n.value;if(!C(t))return-1;return dimensionToCalculation(e,"rad",Math.asin(t[4].value))}function solveATan(e,n){const t=n.value;if(!C(t))return-1;return dimensionToCalculation(e,"rad",Math.atan(t[4].value))}function isDimensionOrNumber(e){return f(e)||C(e)}function arrayOfSameNumeric(e){if(0===e.length)return!0;const n=e[0];if(!h(n))return!1;if(1===e.length)return!0;if(f(n)){const t=toLowerCaseAZ(n[4].unit);for(let r=1;r<e.length;r++){const a=e[r];if(n[0]!==a[0])return!1;if(t!==toLowerCaseAZ(a[4].unit))return!1}return!0}for(let t=1;t<e.length;t++){const r=e[t];if(n[0]!==r[0])return!1}return!0}function twoOfSameNumeric(e,n){return!!h(e)&&(f(e)?e[0]===n[0]&&toLowerCaseAZ(e[4].unit)===toLowerCaseAZ(n[4].unit):e[0]===n[0])}function solveATan2(e,n,t){const r=n.value;if(!isDimensionOrNumber(r))return-1;const a=convertUnit(r,t.value);if(!twoOfSameNumeric(r,a))return-1;return dimensionToCalculation(e,"rad",Math.atan2(r[4].value,a[4].value))}function solveAbs(e,n,t){const r=n.value;if(!h(r))return-1;if(!t.rawPercentages&&g(r))return-1;return resultToCalculation(e,r,Math.abs(r[4].value))}function solveClamp(e,n,r,a,u){if(!t(n)||!t(r)||!t(a))return-1;const i=n.value;if(!h(i))return-1;if(!u.rawPercentages&&g(i))return-1;const o=convertUnit(i,r.value);if(!twoOfSameNumeric(i,o))return-1;const l=convertUnit(i,a.value);if(!twoOfSameNumeric(i,l))return-1;return resultToCalculation(e,i,Math.max(i[4].value,Math.min(o[4].value,l[4].value)))}function solveCos(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;let r=t[4].value;if(f(t))switch(t[4].unit.toLowerCase()){case"rad":break;case"deg":r=P.get("rad")(t[4].value);break;case"grad":r=k.get("rad")(t[4].value);break;case"turn":r=j.get("rad")(t[4].value);break;default:return-1}return r=Math.cos(r),numberToCalculation(e,r)}function solveExp(e,n){const t=n.value;if(!C(t))return-1;return numberToCalculation(e,Math.exp(t[4].value))}function solveHypot(e,n,r){if(!n.every(t))return-1;const a=n[0].value;if(!h(a))return-1;if(!r.rawPercentages&&g(a))return-1;const u=n.map(e=>convertUnit(a,e.value));if(!arrayOfSameNumeric(u))return-1;const i=u.map(e=>e[4].value),o=Math.hypot(...i);return resultToCalculation(e,a,o)}function solveMax(e,n,r){if(!n.every(t))return-1;const a=n[0].value;if(!h(a))return-1;if(!r.rawPercentages&&g(a))return-1;const u=n.map(e=>convertUnit(a,e.value));if(!arrayOfSameNumeric(u))return-1;const i=u.map(e=>e[4].value),o=Math.max(...i);return resultToCalculation(e,a,o)}function solveMin(e,n,r){if(!n.every(t))return-1;const a=n[0].value;if(!h(a))return-1;if(!r.rawPercentages&&g(a))return-1;const u=n.map(e=>convertUnit(a,e.value));if(!arrayOfSameNumeric(u))return-1;const i=u.map(e=>e[4].value),o=Math.min(...i);return resultToCalculation(e,a,o)}function solveMod(e,n,t){const r=n.value;if(!h(r))return-1;const a=convertUnit(r,t.value);if(!twoOfSameNumeric(r,a))return-1;let u;return u=0===a[4].value?Number.NaN:Number.isFinite(r[4].value)&&(Number.isFinite(a[4].value)||(a[4].value!==Number.POSITIVE_INFINITY||r[4].value!==Number.NEGATIVE_INFINITY&&!Object.is(0*r[4].value,-0))&&(a[4].value!==Number.NEGATIVE_INFINITY||r[4].value!==Number.POSITIVE_INFINITY&&!Object.is(0*r[4].value,0)))?Number.isFinite(a[4].value)?(r[4].value%a[4].value+a[4].value)%a[4].value:r[4].value:Number.NaN,resultToCalculation(e,r,u)}function solvePow(e,n,t){const r=n.value,a=t.value;if(!C(r))return-1;if(!twoOfSameNumeric(r,a))return-1;return numberToCalculation(e,Math.pow(r[4].value,a[4].value))}function solveRem(e,n,t){const r=n.value;if(!h(r))return-1;const a=convertUnit(r,t.value);if(!twoOfSameNumeric(r,a))return-1;let u;return u=0===a[4].value?Number.NaN:Number.isFinite(r[4].value)?Number.isFinite(a[4].value)?r[4].value%a[4].value:r[4].value:Number.NaN,resultToCalculation(e,r,u)}function snapAsBorderWidth(e,n,t){if(!f(n))return-1;const r=t.devicePixelLength??1,a=[m.Dimension,`${r}px`,n[2],n[3],{value:r,type:p.Integer,unit:"px"}],u=convertUnit(a,n);if(!twoOfSameNumeric(u,a))return-1;if(Number.isInteger(u[4].value/r))return resultToCalculation(e,n,n[4].value);if(u[4].value>0){if(u[4].value<r)return resultToCalculation(e,n,convertUnit(n,a)[4].value);const t=Math.floor(u[4].value/a[4].value)*a[4].value;return u[4].value=t,resultToCalculation(e,n,convertUnit(n,u)[4].value)}if(Math.abs(u[4].value)<r)return resultToCalculation(e,n,-1*convertUnit(n,a)[4].value);const i=Math.ceil(u[4].value/a[4].value)*a[4].value;return u[4].value=i,resultToCalculation(e,n,convertUnit(n,u)[4].value)}function solveRound(e,n,t,r,a){const u=t.value;if(!h(u))return-1;if("line-width"===n&&!f(u))return-1;if(!a.rawPercentages&&g(u))return-1;const i=convertUnit(u,r.value);if(!twoOfSameNumeric(u,i))return-1;let o;if(0===i[4].value)o=Number.NaN;else if(Number.isFinite(u[4].value)||Number.isFinite(i[4].value))if(!Number.isFinite(u[4].value)&&Number.isFinite(i[4].value))o=u[4].value;else if(Number.isFinite(u[4].value)&&!Number.isFinite(i[4].value))switch(n){case"down":o=u[4].value<0?-1/0:Object.is(-0,0*u[4].value)?-0:0;break;case"up":o=u[4].value>0?1/0:Object.is(0,0*u[4].value)?0:-0;break;default:o=Object.is(0,0*u[4].value)?0:-0}else switch(n){case"down":o=Math.floor(u[4].value/i[4].value)*i[4].value;break;case"up":o=Math.ceil(u[4].value/i[4].value)*i[4].value;break;case"to-zero":o=Math.trunc(u[4].value/i[4].value)*i[4].value;break;default:{let t=Math.floor(u[4].value/i[4].value)*i[4].value,r=Math.ceil(u[4].value/i[4].value)*i[4].value;if(t>r){const e=t;t=r,r=e}const l=Math.abs(u[4].value-t),c=Math.abs(u[4].value-r);if(o="line-width"===n&&u[4].value>=0&&(0===r||0===t)?0!==r?r:t:l===c?r:l<c?t:r,"line-width"===n){const n=solve(resultToCalculation(e,u,o),a);return-1===n?-1:snapAsBorderWidth(e,n.value,a)}break}}else o=Number.NaN;return resultToCalculation(e,u,o)}function solveSign(e,n,t){const r=n.value;if(!h(r))return-1;if(!t.rawPercentages&&g(r))return-1;return numberToCalculation(e,Math.sign(r[4].value))}function solveSin(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;let r=t[4].value;if(f(t))switch(toLowerCaseAZ(t[4].unit)){case"rad":break;case"deg":r=P.get("rad")(t[4].value);break;case"grad":r=k.get("rad")(t[4].value);break;case"turn":r=j.get("rad")(t[4].value);break;default:return-1}return r=Math.sin(r),numberToCalculation(e,r)}function solveSqrt(e,n){const t=n.value;if(!C(t))return-1;return numberToCalculation(e,Math.sqrt(t[4].value))}function solveTan(e,n){const t=n.value;if(!isDimensionOrNumber(t))return-1;const r=t[4].value;let a=0,u=t[4].value;if(f(t))switch(toLowerCaseAZ(t[4].unit)){case"rad":a=G.get("deg")(r);break;case"deg":a=r,u=P.get("rad")(r);break;case"grad":a=k.get("deg")(r),u=k.get("rad")(r);break;case"turn":a=j.get("deg")(r),u=j.get("rad")(r);break;default:return-1}const i=a/90;return u=a%90==0&&i%2!=0?i>0?1/0:-1/0:Math.tan(u),numberToCalculation(e,u)}function subtraction(e,t){if(2!==e.length)return-1;const r=e[0].value;let a=e[1].value;if(C(r)&&C(a)){const e=r[4].value-a[4].value;return new n([m.Number,e.toString(),r[2],a[3],{value:e,type:r[4].type===p.Integer&&a[4].type===p.Integer?p.Integer:p.Number}])}if(g(r)&&g(a)){const e=r[4].value-a[4].value;return new n([m.Percentage,e.toString()+"%",r[2],a[3],{value:e}])}if(f(r)&&f(a)&&(a=convertUnit(r,a),toLowerCaseAZ(r[4].unit)===toLowerCaseAZ(a[4].unit))){const e=r[4].value-a[4].value;return new n([m.Dimension,e.toString()+r[4].unit,r[2],a[3],{value:e,type:r[4].type===p.Integer&&a[4].type===p.Integer?p.Integer:p.Number,unit:r[4].unit}])}return(C(r)&&(f(a)||g(a))||C(a)&&(f(r)||g(r)))&&t.onParseError?.(new ParseErrorWithComponentValues(y.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function solveLog(e,n){if(1===n.length){const r=n[0];if(!r||!t(r))return-1;const a=r.value;if(!C(a))return-1;return numberToCalculation(e,Math.log(a[4].value))}if(2===n.length){const r=n[0];if(!r||!t(r))return-1;const a=r.value;if(!C(a))return-1;const u=n[1];if(!u||!t(u))return-1;const i=u.value;if(!C(i))return-1;return numberToCalculation(e,Math.log(a[4].value)/Math.log(i[4].value))}return-1}const _=/^none$/i;function isNone(e){if(Array.isArray(e)){const n=e.filter(e=>!(r(e)&&a(e)));return 1===n.length&&isNone(n[0])}if(!t(e))return!1;const n=e.value;return!!D(n)&&_.test(n[4].value)}const H=String.fromCodePoint(0);function solveRandom(e,n,t,r,a,u){if(-1===n.fixed&&!u.randomCaching)return-1;u.randomCaching||(u.randomCaching={propertyName:"",propertyN:0,elementID:"",documentID:""}),u.randomCaching&&!u.randomCaching.propertyN&&(u.randomCaching.propertyN=0);const i=t.value;if(!h(i))return-1;const o=convertUnit(i,r.value);if(!twoOfSameNumeric(i,o))return-1;let l=null;if(a&&(l=convertUnit(i,a.value),!twoOfSameNumeric(i,l)))return-1;if(!Number.isFinite(i[4].value))return resultToCalculation(e,i,Number.NaN);if(!Number.isFinite(o[4].value))return resultToCalculation(e,i,Number.NaN);if(!Number.isFinite(o[4].value-i[4].value))return resultToCalculation(e,i,Number.NaN);if(l&&!Number.isFinite(l[4].value))return resultToCalculation(e,i,i[4].value);const c=-1===n.fixed?sfc32(crc32([n.dashedIdent?n.dashedIdent:`${u.randomCaching?.propertyName} ${u.randomCaching.propertyN++}`,n.elementShared?"":u.randomCaching.elementID,u.randomCaching.documentID].join(H))):()=>n.fixed;let s=i[4].value,v=o[4].value;if(s>v&&([s,v]=[v,s]),l&&(l[4].value<=0||Math.abs(s-v)/l[4].value>1e10)&&(l=null),l){const n=Math.max(l[4].value/1e3,1e-9),t=[s];let r=0;for(;;){r+=l[4].value;const e=s+r;if(!(e+n<v)){t.push(v);break}if(t.push(e),e+l[4].value-n>v)break}const a=c();return resultToCalculation(e,i,Number(t[Math.floor(t.length*a)].toFixed(5)))}const f=c();return resultToCalculation(e,i,Number((f*(v-s)+s).toFixed(5)))}function sfc32(e=.34944106645296036,n=.19228640875738723,t=.8784393832007205,r=.04850964319275053){return()=>{const a=((e|=0)+(n|=0)|0)+(r|=0)|0;return r=r+1|0,e=n^n>>>9,n=(t|=0)+(t<<3)|0,t=(t=t<<21|t>>>11)+a|0,(a>>>0)/4294967296}}function crc32(e){let n,t,r=0;r^=-1;for(let a=0,u=e.length;a<u;a++)t=255&(r^e.charCodeAt(a)),n=Number("0x"+"00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D".substring(9*t,9*t+8)),r=r>>>8^n;return(-1^r)>>>0}const J=new Map([["abs",function abs(e,n,t){return singleNodeSolver(e,n,t,solveAbs)}],["acos",function acos(e,n,t){return singleNodeSolver(e,n,t,solveACos)}],["asin",function asin(e,n,t){return singleNodeSolver(e,n,t,solveASin)}],["atan",function atan(e,n,t){return singleNodeSolver(e,n,t,solveATan)}],["atan2",function atan2(e,n,t){return twoCommaSeparatedNodesSolver(e,n,t,solveATan2)}],["calc",calc$1],["clamp",function clamp(r,a,i){const o=resolveGlobalsAndConstants([...r.value.filter(e=>!u(e))],a),c=[],s=[],v=[];{let e=c;for(let n=0;n<o.length;n++){const r=o[n];if(t(r)&&A(r.value)){if(e===v)return-1;if(e===s){e=v;continue}if(e===c){e=s;continue}return-1}e.push(r)}}const f=isNone(c),p=isNone(v);if(f&&p)return calc$1(calcWrapper(r,s),a,i);const d=solve(calc$1(calcWrapper(r,s),a,i),i);if(-1===d)return-1;if(f){const t=solve(calc$1(calcWrapper(r,v),a,i),i);return-1===t?-1:solveMin((C=r,g=d,D=t,new l([m.Function,"min(",C.name[2],C.name[3],{value:"min"}],[m.CloseParen,")",C.endToken[2],C.endToken[3],void 0],[g,new n([m.Comma,",",...e(g),void 0]),D])),[d,t],i)}if(p){const e=solve(calc$1(calcWrapper(r,c),a,i),i);return-1===e?-1:solveMax(maxWrapper(r,e,d),[e,d],i)}var C,g,D;const h=solve(calc$1(calcWrapper(r,c),a,i),i);if(-1===h)return-1;const N=solve(calc$1(calcWrapper(r,v),a,i),i);if(-1===N)return-1;return solveClamp(r,h,d,N,i)}],["cos",function cos(e,n,t){return singleNodeSolver(e,n,t,solveCos)}],["exp",function exp(e,n,t){return singleNodeSolver(e,n,t,solveExp)}],["hypot",function hypot(e,n,t){return variadicNodesSolver(e,n,t,solveHypot)}],["log",function log(e,n,t){return variadicNodesSolver(e,n,t,solveLog)}],["max",function max(e,n,t){return variadicNodesSolver(e,n,t,solveMax)}],["min",function min(e,n,t){return variadicNodesSolver(e,n,t,solveMin)}],["mod",function mod(e,n,t){return twoCommaSeparatedNodesSolver(e,n,t,solveMod)}],["pow",function pow(e,n,t){return twoCommaSeparatedNodesSolver(e,n,t,solvePow)}],["random",function random(e,n,t){const r=parseRandomValueSharing(e,e.value.filter(e=>!u(e)),n,t);if(-1===r)return-1;const[a,i]=r,o=variadicArguments(e,i,n,t);if(-1===o)return-1;const[l,c,s]=o;if(!l||!c)return-1;return solveRandom(e,a,l,c,s,t)}],["rem",function rem(e,n,t){return twoCommaSeparatedNodesSolver(e,n,t,solveRem)}],["round",function round(e,r,a){const i=resolveGlobalsAndConstants([...e.value.filter(e=>!u(e))],r);let o="",l=!1;const c=[],s=[];{let e=c;for(let n=0;n<i.length;n++){const r=i[n];if(!o&&0===c.length&&0===s.length&&t(r)&&D(r.value)){const e=r.value[4].value.toLowerCase();if(K.has(e)){o=e;continue}}if(t(r)&&A(r.value)){if(e===s)return-1;if(e===c&&o&&0===c.length)continue;if(e===c){l=!0,e=s;continue}return-1}e.push(r)}}const v=solve(calc$1(calcWrapper(e,c),r,a),a);if(-1===v)return-1;if("line-width"===o){const e=convertUnit([m.Dimension,"1px",v.value[2],v.value[3],{value:1,type:p.Integer,unit:"px"}],v.value);if(!f(e)||"px"!==e[4].unit)return-1}if(!l&&0===s.length){if("line-width"===o)return snapAsBorderWidth(e,v.value,a);s.push(new n([m.Number,"1",v.value[2],v.value[3],{value:1,type:p.Integer}]))}const d=solve(calc$1(calcWrapper(e,s),r,a),a);if(-1===d)return-1;o||(o="nearest");return solveRound(e,o,v,d,a)}],["sign",function sign(e,n,t){return singleNodeSolver(e,n,t,solveSign)}],["sin",function sin(e,n,t){return singleNodeSolver(e,n,t,solveSin)}],["sqrt",function sqrt(e,n,t){return singleNodeSolver(e,n,t,solveSqrt)}],["tan",function tan(e,n,t){return singleNodeSolver(e,n,t,solveTan)}]]);function calc$1(e,n,r){const a=resolveGlobalsAndConstants([...e.value.filter(e=>!u(e))],n);if(1===a.length&&t(a[0]))return{inputs:[a[0]],operation:unary};let l=0;for(;l<a.length;){const e=a[l];if(i(e)&&N(e.startToken)){const t=calc$1(e,n,r);if(-1===t)return-1;a.splice(l,1,t);continue}if(o(e)){const t=J.get(e.getName().toLowerCase());if(!t)return-1;const u=t(e,n,r);if(-1===u)return-1;a.splice(l,1,u);continue}l++}if(l=0,1===a.length&&isCalculation(a[0]))return a[0];for(;l<a.length;){const e=a[l];if(!e||!t(e)&&!isCalculation(e)){l++;continue}const n=a[l+1];if(!n||!t(n)){l++;continue}const r=n.value;if(!B(r)||"*"!==r[4].value&&"/"!==r[4].value){l++;continue}const u=a[l+2];if(!u||!t(u)&&!isCalculation(u))return-1;"*"!==r[4].value?"/"!==r[4].value?l++:a.splice(l,3,{inputs:[e,u],operation:division}):a.splice(l,3,{inputs:[e,u],operation:multiplication})}if(l=0,1===a.length&&isCalculation(a[0]))return a[0];for(;l<a.length;){const e=a[l];if(!e||!t(e)&&!isCalculation(e)){l++;continue}const n=a[l+1];if(!n||!t(n)){l++;continue}const r=n.value;if(!B(r)||"+"!==r[4].value&&"-"!==r[4].value){l++;continue}const u=a[l+2];if(!u||!t(u)&&!isCalculation(u))return-1;"+"!==r[4].value?"-"!==r[4].value?l++:a.splice(l,3,{inputs:[e,u],operation:subtraction}):a.splice(l,3,{inputs:[e,u],operation:addition})}return 1===a.length&&isCalculation(a[0])?a[0]:-1}function singleNodeSolver(e,n,t,r){const a=singleArgument(e,n,t);return-1===a?-1:r(e,a,t)}function singleArgument(e,n,t){const r=resolveGlobalsAndConstants([...e.value.filter(e=>!u(e))],n),a=solve(calc$1(calcWrapper(e,r),n,t),t);return-1===a?-1:a}function twoCommaSeparatedNodesSolver(e,n,t,r){const a=twoCommaSeparatedArguments(e,n,t);if(-1===a)return-1;const[u,i]=a;return r(e,u,i,t)}function twoCommaSeparatedArguments(e,n,r){const a=resolveGlobalsAndConstants([...e.value.filter(e=>!u(e))],n),i=[],o=[];{let e=i;for(let n=0;n<a.length;n++){const r=a[n];if(t(r)&&A(r.value)){if(e===o)return-1;if(e===i){e=o;continue}return-1}e.push(r)}}const l=solve(calc$1(calcWrapper(e,i),n,r),r);if(-1===l)return-1;const c=solve(calc$1(calcWrapper(e,o),n,r),r);return-1===c?-1:[l,c]}function variadicNodesSolver(e,n,t,r){const a=variadicArguments(e,e.value,n,t);return-1===a?-1:r(e,a,t)}function variadicArguments(e,n,r,a){const i=resolveGlobalsAndConstants([...n.filter(e=>!u(e))],r),o=[];{const n=[];let u=[];for(let e=0;e<i.length;e++){const r=i[e];t(r)&&A(r.value)?(n.push(u),u=[]):u.push(r)}n.push(u);for(let t=0;t<n.length;t++){if(0===n[t].length)return-1;const u=solve(calc$1(calcWrapper(e,n[t]),r,a),a);if(-1===u)return-1;o.push(u)}}return o}const K=new Set(["nearest","line-width","up","down","to-zero"]);function parseRandomValueSharing(e,n,r,a){const u={isAuto:!1,dashedIdent:"",fixed:-1,elementShared:!1},i=n[0];if(!t(i)||!D(i.value))return[u,n];for(let i=0;i<n.length;i++){const o=n[i];if(!t(o))return-1;if(A(o.value))return[u,n.slice(i+1)];if(!D(o.value))return-1;const l=o.value[4].value.toLowerCase();if("element-shared"!==l){if("fixed"===l){if(u.elementShared||u.dashedIdent||u.isAuto)return-1;i++;const t=n[i];if(!t)return-1;const o=solve(calc$1(calcWrapper(e,[t]),r,a),a);if(-1===o)return-1;if(!C(o.value))return-1;if(o.value[4].value<0||o.value[4].value>1)return-1;u.fixed=Math.max(0,Math.min(o.value[4].value,1-1e-9));continue}if("auto"!==l)if(l.startsWith("--")){if(-1!==u.fixed||u.isAuto)return-1;u.dashedIdent=l}else;else{if(-1!==u.fixed||u.dashedIdent)return-1;u.isAuto=!0}}else{if(-1!==u.fixed)return-1;u.elementShared=!0}}return-1}function calcWrapper(e,n){return new l([m.Function,"calc(",e.name[2],e.name[3],{value:"calc"}],[m.CloseParen,")",e.endToken[2],e.endToken[3],void 0],n)}function maxWrapper(t,r,a){return new l([m.Function,"max(",t.name[2],t.name[3],{value:"max"}],[m.CloseParen,")",t.endToken[2],t.endToken[3],void 0],[r,new n([m.Comma,",",...e(r),void 0]),a])}function patchNaN(e){if(-1===e)return-1;if(o(e))return e;const t=e.value;return h(t)&&Number.isNaN(t[4].value)?C(t)?new l([m.Function,"calc(",t[2],t[3],{value:"calc"}],[m.CloseParen,")",t[2],t[3],void 0],[new n([m.Ident,"NaN",t[2],t[3],{value:"NaN"}])]):f(t)?new l([m.Function,"calc(",t[2],t[3],{value:"calc"}],[m.CloseParen,")",t[2],t[3],void 0],[new n([m.Ident,"NaN",t[2],t[3],{value:"NaN"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Delim,"*",t[2],t[3],{value:"*"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Dimension,"1"+t[4].unit,t[2],t[3],{value:1,type:p.Integer,unit:t[4].unit}])]):g(t)?new l([m.Function,"calc(",t[2],t[3],{value:"calc"}],[m.CloseParen,")",t[2],t[3],void 0],[new n([m.Ident,"NaN",t[2],t[3],{value:"NaN"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Delim,"*",t[2],t[3],{value:"*"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Percentage,"1%",t[2],t[3],{value:1}])]):-1:e}function patchInfinity(e){if(-1===e)return-1;if(o(e))return e;const t=e.value;if(!h(t))return e;if(Number.isFinite(t[4].value)||Number.isNaN(t[4].value))return e;let r="";return Number.NEGATIVE_INFINITY===t[4].value&&(r="-"),C(t)?new l([m.Function,"calc(",t[2],t[3],{value:"calc"}],[m.CloseParen,")",t[2],t[3],void 0],[new n([m.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}])]):f(t)?new l([m.Function,"calc(",t[2],t[3],{value:"calc"}],[m.CloseParen,")",t[2],t[3],void 0],[new n([m.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Delim,"*",t[2],t[3],{value:"*"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Dimension,"1"+t[4].unit,t[2],t[3],{value:1,type:p.Integer,unit:t[4].unit}])]):new l([m.Function,"calc(",t[2],t[3],{value:"calc"}],[m.CloseParen,")",t[2],t[3],void 0],[new n([m.Ident,r+"infinity",t[2],t[3],{value:r+"infinity"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Delim,"*",t[2],t[3],{value:"*"}]),new c([[m.Whitespace," ",t[2],t[3],void 0]]),new n([m.Percentage,"1%",t[2],t[3],{value:1}])])}function patchMinusZero(e){if(-1===e)return-1;if(o(e))return e;const n=e.value;return h(n)&&Object.is(-0,n[4].value)?("-0"===n[1]||(g(n)?n[1]="-0%":f(n)?n[1]="-0"+n[4].unit:n[1]="-0"),e):e}function patchPrecision(e,n=13){if(-1===e)return-1;if(n<=0)return e;if(o(e))return e;const t=e.value;if(!h(t))return e;if(Number.isInteger(t[4].value))return e;const r=Number(t[4].value.toFixed(n)).toString();return C(t)?t[1]=r:g(t)?t[1]=r+"%":f(t)&&(t[1]=r+t[4].unit),e}function patchCanonicalUnit(e){return-1===e?-1:o(e)?e:f(e.value)?(e.value=toCanonicalUnit(e.value),e):e}function patchCalcResult(e,n){let t=e;return n?.toCanonicalUnits&&(t=patchCanonicalUnit(t)),t=patchPrecision(t,n?.precision),t=patchMinusZero(t),n?.censorIntoStandardRepresentableValues||(t=patchNaN(t),t=patchInfinity(t)),t}function tokenizeGlobals(e){const n=new Map;if(!e)return n;for(const[t,r]of e)if(b(r))n.set(t,r);else if("string"==typeof r){const e=F({css:r}),a=e.nextToken();if(e.nextToken(),!e.endOfFile())continue;if(!h(a))continue;n.set(t,a);continue}return n}function calc(e,n){return calcFromComponentValues(s(w({css:e}),{}),n).map(e=>e.map(e=>E(...e.tokens())).join("")).join(",")}function calcFromComponentValues(e,n){const t=tokenizeGlobals(n?.globals);return replaceComponentValues(e,e=>{if(!o(e))return;const r=J.get(e.getName().toLowerCase());if(!r)return;const a=patchCalcResult(solve(r(e,t,n??{}),n??{}),n);return-1!==a?a:void 0})}function replaceComponentValues(n,r){for(let a=0;a<n.length;a++){const i=n[a];v(i,(n,a)=>{if("number"!=typeof a)return;const i=r(n.node);if(!i)return;const o=[i],l=n.parent.value[a-1];t(l)&&B(l.value)&&("-"===l.value[4].value||"+"===l.value[4].value)&&o.splice(0,0,new c([[m.Whitespace," ",...e(n.node),void 0]]));const s=n.parent.value[a+1];!s||u(s)||t(s)&&(A(s.value)||I(s.value)||S(s.value)||B(s.value)&&"-"!==s.value[4].value&&"+"!==s.value[4].value)||o.push(new c([[m.Whitespace," ",...e(n.node),void 0]])),n.parent.value.splice(a,1,...o)})}return n}const Q=new Set(J.keys());export{ParseError,y as ParseErrorMessage,ParseErrorWithComponentValues,calc,calcFromComponentValues,Q as mathFunctionNames};
node_modules/@csstools/css-calc/package.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-calc",
3
+ "description": "Solve CSS math expressions",
4
+ "version": "3.2.1",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "engines": {
28
+ "node": ">=20.19.0"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.mjs"
35
+ }
36
+ },
37
+ "files": [
38
+ "CHANGELOG.md",
39
+ "LICENSE.md",
40
+ "README.md",
41
+ "dist"
42
+ ],
43
+ "peerDependencies": {
44
+ "@csstools/css-parser-algorithms": "^4.0.0",
45
+ "@csstools/css-tokenizer": "^4.0.0"
46
+ },
47
+ "scripts": {},
48
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc#readme",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
52
+ "directory": "packages/css-calc"
53
+ },
54
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
55
+ "keywords": [
56
+ "calc",
57
+ "css"
58
+ ]
59
+ }
node_modules/@csstools/css-color-parser/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ # Changes to CSS Color Parser
2
+
3
+ ### 4.1.7
4
+
5
+ _June 14, 2026_
6
+
7
+ - Fix normalization of `hue` to `[0, 360]` range when `hue` is not finite
8
+
9
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md)
node_modules/@csstools/css-color-parser/LICENSE.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/@csstools/css-color-parser/README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Color Parser <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-color-parser.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+ [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
+
7
+ ## Usage
8
+
9
+ Add [CSS Color Parser] to your project:
10
+
11
+ ```bash
12
+ npm install @csstools/css-color-parser @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev
13
+ ```
14
+
15
+ ```ts
16
+ import { color } from '@csstools/css-color-parser';
17
+ import { isFunctionNode, parseComponentValue } from '@csstools/css-parser-algorithms';
18
+ import { serializeRGB } from '@csstools/css-color-parser';
19
+ import { tokenize } from '@csstools/css-tokenizer';
20
+
21
+ // color() expects a parsed component value.
22
+ const hwbComponentValue = parseComponentValue(tokenize({ css: 'hwb(10deg 10% 20%)' }));
23
+ const colorData = color(hwbComponentValue);
24
+ if (colorData) {
25
+ console.log(colorData);
26
+
27
+ // serializeRGB() returns a component value.
28
+ const rgbComponentValue = serializeRGB(colorData);
29
+ console.log(rgbComponentValue.toString());
30
+ }
31
+ ```
32
+
33
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
34
+ [discord]: https://discord.gg/bUadyRwkJS
35
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-color-parser
36
+
37
+ [CSS Color Parser]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser
node_modules/@csstools/css-color-parser/dist/index.d.ts ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Color } from '@csstools/color-helpers';
2
+ import type { ComponentValue } from '@csstools/css-parser-algorithms';
3
+ import { FunctionNode } from '@csstools/css-parser-algorithms';
4
+
5
+ /**
6
+ * Convert a color function to a `ColorData` object.
7
+ *
8
+ * @param {ComponentValue} colorNode - The color function to be converted.
9
+ * @returns {ColorData|false} The color function as a `ColorData` object or `false` if it could not be converted.
10
+ */
11
+ export declare function color(colorNode: ComponentValue): ColorData | false;
12
+
13
+ /**
14
+ * A color data object.
15
+ * It contains as much information as possible about the color and the original parsed syntax.
16
+ */
17
+ export declare interface ColorData {
18
+ /**
19
+ * The color notation of the color data.
20
+ *
21
+ * We use "color notation" and not "color space" because these represent the original notation and not the actual color space.
22
+ * The actual color space is however always implied by the color notation.
23
+ */
24
+ colorNotation: ColorNotation;
25
+ /**
26
+ * The color channels.
27
+ * This is always an array of three numbers
28
+ * but the channels can only be interpreted by looking at the color notation.
29
+ */
30
+ channels: Color;
31
+ /**
32
+ * The alpha channel.
33
+ * This is either a number between `0` and `1` or a `ComponentValue` object.
34
+ *
35
+ * Since most computations are not dependent on the alpha channel,
36
+ * we allow things like `var(--some-alpha)` as an alpha channel value for most inputs.
37
+ */
38
+ alpha: number | ComponentValue;
39
+ /**
40
+ * Information about the original syntax.
41
+ */
42
+ syntaxFlags: Set<SyntaxFlag>;
43
+ }
44
+
45
+ /**
46
+ * Check if a color data object fits the `display-p3` gamut.
47
+ *
48
+ * @param {ColorData} x - The color data to be checked.
49
+ * @returns {boolean} Whether the color data fits the `display-p3` gamut.
50
+ */
51
+ export declare function colorDataFitsDisplayP3_Gamut(x: ColorData): boolean;
52
+
53
+ /**
54
+ * Check if a color data object fits the `sRGB` gamut.
55
+ *
56
+ * @param {ColorData} x - The color data to be checked.
57
+ * @returns {boolean} Whether the color data fits the `sRGB` gamut.
58
+ */
59
+ export declare function colorDataFitsRGB_Gamut(x: ColorData): boolean;
60
+
61
+ export declare enum ColorNotation {
62
+ /** Adobe 1999, expressed through `color(a98-rgb 0 0 0)` */
63
+ A98_RGB = "a98-rgb",
64
+ /** Display P3, expressed through `color(display-p3 0 0 0)` */
65
+ Display_P3 = "display-p3",
66
+ /** Display P3, expressed through `color(display-p3-linear 0 0 0)` */
67
+ Linear_Display_P3 = "display-p3-linear",
68
+ /** Hex, expressed through `#000` */
69
+ HEX = "hex",
70
+ /** HSL, expressed through `hsl(0 0% 0%)` */
71
+ HSL = "hsl",
72
+ /** HWB, expressed through `hwb(0 0% 0%)` */
73
+ HWB = "hwb",
74
+ /** LCH, expressed through `lch(0 0% 0deg)` */
75
+ LCH = "lch",
76
+ /** Lab, expressed through `lab(0 0 0)` */
77
+ Lab = "lab",
78
+ /** Linear sRGB, expressed through `color(linear-srgb 0 0 0)` */
79
+ Linear_sRGB = "srgb-linear",
80
+ /** Oklch, expressed through `oklch(0 0% 0deg)` */
81
+ OKLCH = "oklch",
82
+ /** Oklab, expressed through `oklab(0 0 0)` */
83
+ OKLab = "oklab",
84
+ /** ProPhoto RGB, expressed through `color(prophoto-rgb 0 0 0)` */
85
+ ProPhoto_RGB = "prophoto-rgb",
86
+ /** RGB, expressed through `rgb(0 0 0)` */
87
+ RGB = "rgb",
88
+ /** sRGB, expressed through `color(srgb 0 0 0)` */
89
+ sRGB = "srgb",
90
+ /** Rec. 2020, expressed through `color(rec2020 0 0 0)` */
91
+ Rec2020 = "rec2020",
92
+ /** XYZ, expressed through `color(xyz-d50 0 0 0)` */
93
+ XYZ_D50 = "xyz-d50",
94
+ /** XYZ, expressed through `color(xyz-d65 0 0 0)` */
95
+ XYZ_D65 = "xyz-d65"
96
+ }
97
+
98
+ export declare function serializeHSL(color: ColorData, gamutMapping?: boolean): FunctionNode;
99
+
100
+ /**
101
+ * Convert color data to component values in the OKLCH color space.
102
+ * The return value can be converted to a string by calling `toString()` on it.
103
+ *
104
+ * @param {ColorData} color - The color data to be serialized.
105
+ * @returns {FunctionNode} The serialized color data as a FunctionNode object.
106
+ */
107
+ export declare function serializeOKLCH(color: ColorData): FunctionNode;
108
+
109
+ /**
110
+ * Convert color data to component values in the display-p3 color space.
111
+ * The return value can be converted to a string by calling `toString()` on it.
112
+ *
113
+ * @param {ColorData} color - The color data to be serialized.
114
+ * @param {boolean} gamutMapping - Whether to perform gamut mapping, defaults to `true`.
115
+ * @returns {FunctionNode} The serialized color data as a FunctionNode object.
116
+ */
117
+ export declare function serializeP3(color: ColorData, gamutMapping?: boolean): FunctionNode;
118
+
119
+ /**
120
+ * Convert color data to component values in the srgb color space.
121
+ * The return value can be converted to a string by calling `toString()` on it.
122
+ *
123
+ * @param {ColorData} color - The color data to be serialized.
124
+ * @param {boolean} gamutMapping - Whether to perform gamut mapping, defaults to `true`.
125
+ * @returns {FunctionNode} The serialized color data as a FunctionNode object.
126
+ */
127
+ export declare function serializeRGB(color: ColorData, gamutMapping?: boolean): FunctionNode;
128
+
129
+ export declare enum SyntaxFlag {
130
+ /** Is a color keyword, e.g. `transparent`, `currentColor`, ... */
131
+ ColorKeyword = "color-keyword",
132
+ /** Has an explicit alpha channel */
133
+ HasAlpha = "has-alpha",
134
+ /** Has a channel with a dimension value, e.g. `50deg` */
135
+ HasDimensionValues = "has-dimension-values",
136
+ /** Has a channel with the `none` keyword */
137
+ HasNoneKeywords = "has-none-keywords",
138
+ /** Has a channel with a number value */
139
+ HasNumberValues = "has-number-values",
140
+ /** Has an alpha channel with a percentage value */
141
+ HasPercentageAlpha = "has-percentage-alpha",
142
+ /** Has a channel with a percentage value */
143
+ HasPercentageValues = "has-percentage-values",
144
+ /** Has an alpha channel with a `var()` function value */
145
+ HasVariableAlpha = "has-variable-alpha",
146
+ /** Is Hex notation */
147
+ Hex = "hex",
148
+ /** Is legacy HSL, e.g. `hsl(50deg, 0%, 0%)` */
149
+ LegacyHSL = "legacy-hsl",
150
+ /** Is legacy RGB, e.g. `rgb(0, 0, 0)` */
151
+ LegacyRGB = "legacy-rgb",
152
+ /** Is a named color, e.g. `red`, `blue` */
153
+ NamedColor = "named-color",
154
+ /** Is a relative color syntax, e.g. `rgb(from purple r g b)` */
155
+ RelativeColorSyntax = "relative-color-syntax",
156
+ /** Is a mixed color, e.g. `color-mix(in oklch, red, blue)` */
157
+ ColorMix = "color-mix",
158
+ /** Is a variadic mixed color, e.g. `color-mix(in oklch, red)` `color-mix(in oklch, red, blue, green)` */
159
+ ColorMixVariadic = "color-mix-variadic",
160
+ /** Is a contrasting color, e.g. `contrast-color()` */
161
+ ContrastColor = "contrast-color",
162
+ /** Is a relative alpha syntax `alpha(from red / 0.5)` */
163
+ RelativeAlphaSyntax = "relative-alpha-syntax",
164
+ /** Is an experimental color syntax */
165
+ Experimental = "experimental"
166
+ }
167
+
168
+ export { }
node_modules/@csstools/css-color-parser/dist/index.mjs ADDED
@@ -0,0 +1 @@
 
 
1
+ import{TokenType as e,NumberType as a,isTokenIdent as n,isTokenPercentage as r,isTokenNumber as o,isTokenDelim as t,isTokenNumeric as l,isTokenComma as s,isTokenDimension as u,isTokenHash as i}from"@csstools/css-tokenizer";import{XYZ_D50_to_XYZ_D65 as c,XYZ_D50_to_XYZ_D50 as h,XYZ_D50_to_OKLab as m,XYZ_D50_to_OKLCH as N,XYZ_D50_to_LCH as p,XYZ_D50_to_Lab as b,XYZ_D50_to_HWB as v,XYZ_D50_to_HSL as f,XYZ_D50_to_a98_RGB as g,XYZ_D50_to_ProPhoto as y,XYZ_D50_to_rec_2020 as d,XYZ_D50_to_lin_P3 as _,XYZ_D50_to_P3 as C,XYZ_D50_to_lin_sRGB as w,XYZ_D50_to_sRGB as x,XYZ_D65_to_XYZ_D50 as L,OKLCH_to_XYZ_D50 as H,LCH_to_XYZ_D50 as k,OKLab_to_XYZ_D50 as P,Lab_to_XYZ_D50 as S,HWB_to_XYZ_D50 as D,HSL_to_XYZ_D50 as F,ProPhoto_RGB_to_XYZ_D50 as M,a98_RGB_to_XYZ_D50 as z,rec_2020_to_XYZ_D50 as Z,lin_P3_to_XYZ_D50 as R,P3_to_XYZ_D50 as B,lin_sRGB_to_XYZ_D50 as V,sRGB_to_XYZ_D50 as T,namedColors as G,inGamut as A,clip as X,gam_sRGB as K,mapGamutRayTrace as Y,OKLCH_to_OKLab as I,OKLab_to_XYZ as O,XYZ_to_lin_sRGB as W,lin_sRGB_to_XYZ as E,XYZ_to_OKLab as U,OKLab_to_OKLCH as $,contrast_ratio_wcag_2_1 as j,gam_P3 as q,XYZ_to_lin_P3 as J,lin_P3_to_XYZ as Q}from"@csstools/color-helpers";import{isWhitespaceNode as ee,isCommentNode as ae,isTokenNode as ne,isFunctionNode as re,TokenNode as oe,isWhiteSpaceOrCommentNode as te,replaceComponentValues as le,FunctionNode as se,WhitespaceNode as ue}from"@csstools/css-parser-algorithms";import{mathFunctionNames as ie,calcFromComponentValues as ce}from"@csstools/css-calc";var he,me;function convertNaNToZero(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function colorData_to_XYZ_D50(e){switch(e.colorNotation){case he.HEX:case he.RGB:case he.sRGB:return{...e,colorNotation:he.XYZ_D50,channels:T(convertNaNToZero(e.channels))};case he.Linear_sRGB:return{...e,colorNotation:he.XYZ_D50,channels:V(convertNaNToZero(e.channels))};case he.Display_P3:return{...e,colorNotation:he.XYZ_D50,channels:B(convertNaNToZero(e.channels))};case he.Linear_Display_P3:return{...e,colorNotation:he.XYZ_D50,channels:R(convertNaNToZero(e.channels))};case he.Rec2020:return{...e,colorNotation:he.XYZ_D50,channels:Z(convertNaNToZero(e.channels))};case he.A98_RGB:return{...e,colorNotation:he.XYZ_D50,channels:z(convertNaNToZero(e.channels))};case he.ProPhoto_RGB:return{...e,colorNotation:he.XYZ_D50,channels:M(convertNaNToZero(e.channels))};case he.HSL:return{...e,colorNotation:he.XYZ_D50,channels:F(convertNaNToZero(e.channels))};case he.HWB:return{...e,colorNotation:he.XYZ_D50,channels:D(convertNaNToZero(e.channels))};case he.Lab:return{...e,colorNotation:he.XYZ_D50,channels:S(convertNaNToZero(e.channels))};case he.OKLab:return{...e,colorNotation:he.XYZ_D50,channels:P(convertNaNToZero(e.channels))};case he.LCH:return{...e,colorNotation:he.XYZ_D50,channels:k(convertNaNToZero(e.channels))};case he.OKLCH:return{...e,colorNotation:he.XYZ_D50,channels:H(convertNaNToZero(e.channels))};case he.XYZ_D50:return{...e,colorNotation:he.XYZ_D50,channels:h(convertNaNToZero(e.channels))};case he.XYZ_D65:return{...e,colorNotation:he.XYZ_D50,channels:L(convertNaNToZero(e.channels))};default:throw new Error("Unsupported color notation")}}!function(e){e.A98_RGB="a98-rgb",e.Display_P3="display-p3",e.Linear_Display_P3="display-p3-linear",e.HEX="hex",e.HSL="hsl",e.HWB="hwb",e.LCH="lch",e.Lab="lab",e.Linear_sRGB="srgb-linear",e.OKLCH="oklch",e.OKLab="oklab",e.ProPhoto_RGB="prophoto-rgb",e.RGB="rgb",e.sRGB="srgb",e.Rec2020="rec2020",e.XYZ_D50="xyz-d50",e.XYZ_D65="xyz-d65"}(he||(he={})),function(e){e.ColorKeyword="color-keyword",e.HasAlpha="has-alpha",e.HasDimensionValues="has-dimension-values",e.HasNoneKeywords="has-none-keywords",e.HasNumberValues="has-number-values",e.HasPercentageAlpha="has-percentage-alpha",e.HasPercentageValues="has-percentage-values",e.HasVariableAlpha="has-variable-alpha",e.Hex="hex",e.LegacyHSL="legacy-hsl",e.LegacyRGB="legacy-rgb",e.NamedColor="named-color",e.RelativeColorSyntax="relative-color-syntax",e.ColorMix="color-mix",e.ColorMixVariadic="color-mix-variadic",e.ContrastColor="contrast-color",e.RelativeAlphaSyntax="relative-alpha-syntax",e.Experimental="experimental"}(me||(me={}));const Ne=new Set([he.A98_RGB,he.Display_P3,he.Linear_Display_P3,he.HEX,he.Linear_sRGB,he.ProPhoto_RGB,he.RGB,he.sRGB,he.Rec2020,he.XYZ_D50,he.XYZ_D65]);function colorDataTo(e,a){(e={...e}).channels=convertPowerlessComponentsToMissingComponents(e.channels,e.colorNotation);const n={...e};if(e.colorNotation!==a){const e=colorData_to_XYZ_D50(n);switch(a){case he.HEX:case he.RGB:n.colorNotation=he.RGB,n.channels=x(e.channels);break;case he.sRGB:n.colorNotation=he.sRGB,n.channels=x(e.channels);break;case he.Linear_sRGB:n.colorNotation=he.Linear_sRGB,n.channels=w(e.channels);break;case he.Display_P3:n.colorNotation=he.Display_P3,n.channels=C(e.channels);break;case he.Linear_Display_P3:n.colorNotation=he.Linear_Display_P3,n.channels=_(e.channels);break;case he.Rec2020:n.colorNotation=he.Rec2020,n.channels=d(e.channels);break;case he.ProPhoto_RGB:n.colorNotation=he.ProPhoto_RGB,n.channels=y(e.channels);break;case he.A98_RGB:n.colorNotation=he.A98_RGB,n.channels=g(e.channels);break;case he.HSL:n.colorNotation=he.HSL,n.channels=f(e.channels);break;case he.HWB:n.colorNotation=he.HWB,n.channels=v(e.channels);break;case he.Lab:n.colorNotation=he.Lab,n.channels=b(e.channels);break;case he.LCH:n.colorNotation=he.LCH,n.channels=p(e.channels);break;case he.OKLCH:n.colorNotation=he.OKLCH,n.channels=N(e.channels);break;case he.OKLab:n.colorNotation=he.OKLab,n.channels=m(e.channels);break;case he.XYZ_D50:n.colorNotation=he.XYZ_D50,n.channels=h(e.channels);break;case he.XYZ_D65:n.colorNotation=he.XYZ_D65,n.channels=c(e.channels);break;default:throw new Error("Unsupported color notation")}}else n.channels=convertNaNToZero(e.channels);if(a===e.colorNotation)n.channels=carryForwardMissingComponents(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(Ne.has(a)&&Ne.has(e.colorNotation))n.channels=carryForwardMissingComponents(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(a){case he.HSL:switch(e.colorNotation){case he.HWB:n.channels=carryForwardMissingComponents(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case he.Lab:case he.OKLab:n.channels=carryForwardMissingComponents(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case he.LCH:case he.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=carryForwardMissingComponents(e.channels,[],[],n.channels,[],[])}break;case he.HWB:switch(e.colorNotation){case he.HSL:n.channels=carryForwardMissingComponents(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case he.LCH:case he.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=carryForwardMissingComponents(e.channels,[],[],n.channels,[],[])}break;case he.Lab:case he.OKLab:switch(e.colorNotation){case he.HSL:n.channels=carryForwardMissingComponents(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case he.Lab:case he.OKLab:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case he.LCH:case he.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=carryForwardMissingComponents(e.channels,[],[],n.channels,[],[])}break;case he.LCH:case he.OKLCH:switch(e.colorNotation){case he.HSL:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case he.HWB:n.channels=carryForwardMissingComponents(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case he.Lab:case he.OKLab:n.channels=carryForwardMissingComponents(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case he.LCH:case he.OKLCH:n.channels=carryForwardMissingComponents(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=carryForwardMissingComponents(e.channels,[],[],n.channels,[],[])}break;default:n.channels=carryForwardMissingComponents(e.channels,[],[],n.channels,[],[])}return n}function convertPowerlessComponentsToMissingComponents(e,a){const n=[...e];switch(a){case he.HSL:!Number.isNaN(n[1])&&n[1]<=.001&&(n[0]=Number.NaN);break;case he.HWB:!Number.isNaN(n[1])&&!Number.isNaN(n[2])&&Math.max(0,n[1])+Math.max(0,n[2])>=99.999&&(n[0]=Number.NaN);break;case he.LCH:!Number.isNaN(n[1])&&n[1]<=.0015&&(n[2]=Number.NaN);break;case he.OKLCH:!Number.isNaN(n[1])&&n[1]<=4e-6&&(n[2]=Number.NaN)}return n}function convertPowerlessComponentsToZeroValuesForDisplay(e,a){const n=[...e];switch(a){case he.HSL:(reducePrecision(n[2])<=0||reducePrecision(n[2])>=100)&&(n[0]=Number.NaN,n[1]=Number.NaN),!Number.isNaN(n[1])&&n[1]<=.001&&(n[0]=Number.NaN);break;case he.HWB:!Number.isNaN(n[1])&&!Number.isNaN(n[2])&&Math.max(0,n[1])+Math.max(0,n[2])>=99.999&&(n[0]=Number.NaN);break;case he.Lab:(reducePrecision(n[0])<=0||reducePrecision(n[0])>=100)&&(n[1]=Number.NaN,n[2]=Number.NaN);break;case he.LCH:!Number.isNaN(n[1])&&n[1]<=.0015&&(n[2]=Number.NaN),(reducePrecision(n[0])<=0||reducePrecision(n[0])>=100)&&(n[1]=Number.NaN,n[2]=Number.NaN);break;case he.OKLab:(reducePrecision(n[0])<=0||reducePrecision(n[0])>=1)&&(n[1]=Number.NaN,n[2]=Number.NaN);break;case he.OKLCH:!Number.isNaN(n[1])&&n[1]<=4e-6&&(n[2]=Number.NaN),(reducePrecision(n[0])<=0||reducePrecision(n[0])>=1)&&(n[1]=Number.NaN,n[2]=Number.NaN)}return n}function carryForwardMissingComponents(e,a,n,r,o,t){if(a.length<3&&e.every(Number.isNaN))return[Number.NaN,Number.NaN,Number.NaN];const l=[...r];for(let n=0;n<a.length;n++)Number.isNaN(e[a[n]])&&(l[o[n]]=Number.NaN);if(n.length&&n.every(a=>Number.isNaN(e[a])))for(let e=0;e<t.length;e++)l[t[e]]=Number.NaN;return l}function normalizeRelativeColorDataChannels(e){const a=new Map;switch(e.colorNotation){case he.RGB:case he.HEX:a.set("r",dummyNumberToken(255*e.channels[0])),a.set("g",dummyNumberToken(255*e.channels[1])),a.set("b",dummyNumberToken(255*e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case he.HSL:a.set("h",dummyNumberToken(e.channels[0])),a.set("s",dummyNumberToken(e.channels[1])),a.set("l",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case he.HWB:a.set("h",dummyNumberToken(e.channels[0])),a.set("w",dummyNumberToken(e.channels[1])),a.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case he.Lab:case he.OKLab:a.set("l",dummyNumberToken(e.channels[0])),a.set("a",dummyNumberToken(e.channels[1])),a.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case he.LCH:case he.OKLCH:a.set("l",dummyNumberToken(e.channels[0])),a.set("c",dummyNumberToken(e.channels[1])),a.set("h",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case he.sRGB:case he.A98_RGB:case he.Display_P3:case he.Linear_Display_P3:case he.Rec2020:case he.Linear_sRGB:case he.ProPhoto_RGB:a.set("r",dummyNumberToken(e.channels[0])),a.set("g",dummyNumberToken(e.channels[1])),a.set("b",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha));break;case he.XYZ_D50:case he.XYZ_D65:a.set("x",dummyNumberToken(e.channels[0])),a.set("y",dummyNumberToken(e.channels[1])),a.set("z",dummyNumberToken(e.channels[2])),"number"==typeof e.alpha&&a.set("alpha",dummyNumberToken(e.alpha))}return a}function noneToZeroInRelativeColorDataChannels(e){const a=new Map(e);for(const[n,r]of e)Number.isNaN(r[4].value)&&a.set(n,dummyNumberToken(0));return a}function dummyNumberToken(n){return Number.isNaN(n)?[e.Number,"none",-1,-1,{value:Number.NaN,type:a.Number}]:[e.Number,n.toString(),-1,-1,{value:n,type:a.Number}]}function reducePrecision(e,a=7){if(Number.isNaN(e))return 0;const n=Math.pow(10,a);return Math.round(e*n)/n}function colorDataFitsRGB_Gamut(e){const a={...e,channels:[...e.channels]};a.channels=convertPowerlessComponentsToZeroValuesForDisplay(a.channels,a.colorNotation);return!colorDataTo(a,he.RGB).channels.find(e=>e<-1e-5||e>1.00001)}function colorDataFitsDisplayP3_Gamut(e){const a={...e,channels:[...e.channels]};a.channels=convertPowerlessComponentsToZeroValuesForDisplay(a.channels,a.colorNotation);return!colorDataTo(a,he.Display_P3).channels.find(e=>e<-1e-5||e>1.00001)}function normalize(e,a,n,r){return Math.min(Math.max(e/a,n),r)}const pe=/[A-Z]/g;function toLowerCaseAZ(e){return e.replace(pe,e=>String.fromCharCode(e.charCodeAt(0)+32))}function normalize_Color_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(r(t)){3!==l&&s.syntaxFlags.add(me.HasPercentageValues);let n=normalize(t[4].value,100,-2147483647,2147483647);return 3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=normalize(t[4].value,1,-2147483647,2147483647);return 3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}const be=new Set(["srgb","srgb-linear","display-p3","display-p3-linear","a98-rgb","prophoto-rgb","rec2020","xyz","xyz-d50","xyz-d65"]);function color$1(e,a){const r=[],s=[],u=[],i=[];let c,h,m=!1,N=!1;const p={colorNotation:he.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};let b=r;for(let o=0;o<e.value.length;o++){let v=e.value[o];if(ee(v)||ae(v))for(;ee(e.value[o+1])||ae(e.value[o+1]);)o++;else if(b===r&&r.length&&(b=s),b===s&&s.length&&(b=u),ne(v)&&t(v.value)&&"/"===v.value[4].value){if(b===i)return!1;b=i}else{if(re(v)){if(b===i&&"var"===toLowerCaseAZ(v.getName())){p.syntaxFlags.add(me.HasVariableAlpha),b.push(v);continue}if(!ie.has(toLowerCaseAZ(v.getName())))return!1;const[[e]]=ce([[v]],{censorIntoStandardRepresentableValues:!0,globals:h,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!ne(e)||!l(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),v=e}if(b===r&&0===r.length&&ne(v)&&n(v.value)&&be.has(toLowerCaseAZ(v.value[4].value))){if(m)return!1;m=toLowerCaseAZ(v.value[4].value),p.colorNotation=colorSpaceNameToColorNotation(m),N&&(N.colorNotation!==p.colorNotation&&(N=colorDataTo(N,p.colorNotation)),c=normalizeRelativeColorDataChannels(N),h=noneToZeroInRelativeColorDataChannels(c))}else if(b===r&&0===r.length&&ne(v)&&n(v.value)&&"from"===toLowerCaseAZ(v.value[4].value)){if(N)return!1;if(m)return!1;for(;ee(e.value[o+1])||ae(e.value[o+1]);)o++;if(o++,v=e.value[o],N=a(v),!1===N)return!1;N.syntaxFlags.has(me.Experimental)&&p.syntaxFlags.add(me.Experimental),p.syntaxFlags.add(me.RelativeColorSyntax)}else{if(!ne(v))return!1;if(n(v.value)&&c&&c.has(toLowerCaseAZ(v.value[4].value))){b.push(new oe(c.get(toLowerCaseAZ(v.value[4].value))));continue}b.push(v)}}}if(!m)return!1;if(1!==b.length)return!1;if(1!==r.length||1!==s.length||1!==u.length)return!1;if(!ne(r[0])||!ne(s[0])||!ne(u[0]))return!1;if(c&&!c.has("alpha"))return!1;const v=normalize_Color_ChannelValues(r[0].value,0,p);if(!v||!o(v))return!1;const f=normalize_Color_ChannelValues(s[0].value,1,p);if(!f||!o(f))return!1;const g=normalize_Color_ChannelValues(u[0].value,2,p);if(!g||!o(g))return!1;const y=[v,f,g];if(1===i.length)if(p.syntaxFlags.add(me.HasAlpha),ne(i[0])){const e=normalize_Color_ChannelValues(i[0].value,3,p);if(!e||!o(e))return!1;y.push(e)}else p.alpha=i[0];else if(c&&c.has("alpha")){const e=normalize_Color_ChannelValues(c.get("alpha"),3,p);if(!e||!o(e))return!1;y.push(e)}return p.channels=[y[0][4].value,y[1][4].value,y[2][4].value],4===y.length&&(p.alpha=y[3][4].value),p}function colorSpaceNameToColorNotation(e){switch(e){case"srgb":return he.sRGB;case"srgb-linear":return he.Linear_sRGB;case"display-p3":return he.Display_P3;case"display-p3-linear":return he.Linear_Display_P3;case"a98-rgb":return he.A98_RGB;case"prophoto-rgb":return he.ProPhoto_RGB;case"rec2020":return he.Rec2020;case"xyz":case"xyz-d65":return he.XYZ_D65;case"xyz-d50":return he.XYZ_D50;default:throw new Error("Unknown color space name: "+e)}}const ve=new Set(["srgb","srgb-linear","display-p3","display-p3-linear","a98-rgb","prophoto-rgb","rec2020","lab","oklab","xyz","xyz-d50","xyz-d65"]),fe=new Set(["hsl","hwb","lch","oklch"]),ge=new Set(["shorter","longer","increasing","decreasing"]);function colorMix(e,a){let r=null,o=null,t=null,l=!1;for(let u=0;u<e.value.length;u++){const i=e.value[u];if(!te(i)){if(!(r||ne(i)&&n(i.value)&&"in"===toLowerCaseAZ(i.value[4].value)))return colorMixRectangular("oklab",colorMixComponents(e.value,a));if(ne(i)&&n(i.value)){if(!r&&"in"===toLowerCaseAZ(i.value[4].value)){r=i;continue}if(r&&!o){o=toLowerCaseAZ(i.value[4].value);continue}if(r&&o&&!t&&fe.has(o)){t=toLowerCaseAZ(i.value[4].value);continue}if(r&&o&&t&&!l&&"hue"===toLowerCaseAZ(i.value[4].value)){l=!0;continue}return!1}return!(!ne(i)||!s(i.value))&&(!!o&&(t||l?!!(t&&l&&fe.has(o)&&ge.has(t))&&colorMixPolar(o,t,colorMixComponents(e.value.slice(u+1),a)):ve.has(o)?colorMixRectangular(o,colorMixComponents(e.value.slice(u+1),a)):!!fe.has(o)&&colorMixPolar(o,"shorter",colorMixComponents(e.value.slice(u+1),a))))}}return!1}function colorMixComponents(e,a){const n=[];let o=!1,t=!1;for(let u=0;u<e.length;u++){let i=e[u];if(!te(i)){if(!ne(i)||!s(i.value)){if(!o){const e=a(i);if(e){o=e;continue}}if(!t){if(re(i)&&ie.has(toLowerCaseAZ(i.getName()))){if([[i]]=ce([[i]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!i||!ne(i)||!l(i.value))return!1;Number.isNaN(i.value[4].value)&&(i.value[4].value=0)}if(ne(i)&&r(i.value)&&i.value[4].value>=0){t=i.value[4].value;continue}}return!1}if(!o)return!1;n.push({color:o,percentage:t}),o=!1,t=!1}}return!!o&&(n.push({color:o,percentage:t}),n)}function colorMixRectangular(e,a){if(!a||!a.length)return!1;for(const e of a)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;const{items:n,leftover:r}=normalizeMixPercentages(a,!0),o=1-r/100;let t;switch(e){case"srgb":t=he.RGB;break;case"srgb-linear":t=he.Linear_sRGB;break;case"display-p3":t=he.Display_P3;break;case"display-p3-linear":t=he.Linear_Display_P3;break;case"a98-rgb":t=he.A98_RGB;break;case"prophoto-rgb":t=he.ProPhoto_RGB;break;case"rec2020":t=he.Rec2020;break;case"lab":t=he.Lab;break;case"oklab":t=he.OKLab;break;case"xyz-d50":t=he.XYZ_D50;break;case"xyz":case"xyz-d65":t=he.XYZ_D65;break;default:return!1}if(1===n.length){const e=colorDataTo(n[0].color,t);return e.colorNotation=t,e.syntaxFlags.add(me.ColorMixVariadic),"number"!=typeof e.alpha?!1:(e.alpha=e.alpha*o,e)}for(n.reverse();n.length>=2;){const e=n.pop(),a=n.pop();if(!e||!a)return!1;const r=e.percentage+a.percentage,o=r>0?a.percentage/r:.5,l=colorMixRectangularPair(t,e.color,a.color,o);if(!l)return!1;n.push({color:l,percentage:r})}const l=n[0]?.color;return!!l&&("number"==typeof l.alpha&&(l.alpha=l.alpha*o,a.some(e=>e.color.syntaxFlags.has(me.Experimental))&&l.syntaxFlags.add(me.Experimental),2!==a.length&&l.syntaxFlags.add(me.ColorMixVariadic),l))}function colorMixRectangularPair(e,a,n,r){let o=a.alpha;if("number"!=typeof o)return!1;let t=n.alpha;if("number"!=typeof t)return!1;o=Number.isNaN(o)?t:o,t=Number.isNaN(t)?o:t;const l=colorDataTo(a,e).channels,s=colorDataTo(n,e).channels;l[0]=fillInMissingComponent(l[0],s[0]),s[0]=fillInMissingComponent(s[0],l[0]),l[1]=fillInMissingComponent(l[1],s[1]),s[1]=fillInMissingComponent(s[1],l[1]),l[2]=fillInMissingComponent(l[2],s[2]),s[2]=fillInMissingComponent(s[2],l[2]),l[0]=premultiply(l[0],o),l[1]=premultiply(l[1],o),l[2]=premultiply(l[2],o),s[0]=premultiply(s[0],t),s[1]=premultiply(s[1],t),s[2]=premultiply(s[2],t);const u=interpolate(o,t,r);return{colorNotation:e,channels:[un_premultiply(interpolate(l[0],s[0],r),u),un_premultiply(interpolate(l[1],s[1],r),u),un_premultiply(interpolate(l[2],s[2],r),u)],alpha:u,syntaxFlags:new Set([me.ColorMix])}}function colorMixPolar(e,a,n){if(!n||!n.length)return!1;for(const e of n)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;const{items:r,leftover:o}=normalizeMixPercentages(n,!0),t=1-o/100;let l;switch(e){case"hsl":l=he.HSL;break;case"hwb":l=he.HWB;break;case"lch":l=he.LCH;break;case"oklch":l=he.OKLCH;break;default:return!1}if(1===r.length){const e=colorDataTo(r[0].color,l);return e.colorNotation=l,e.syntaxFlags.add(me.ColorMixVariadic),"number"!=typeof e.alpha?!1:(e.alpha=e.alpha*t,e)}for(r.reverse();r.length>=2;){const e=r.pop(),n=r.pop();if(!e||!n)return!1;const o=e.percentage+n.percentage,t=o>0?n.percentage/o:.5,s=colorMixPolarPair(l,a,e.color,n.color,t);if(!s)return!1;r.push({color:s,percentage:o})}const s=r[0]?.color;return!!s&&("number"==typeof s.alpha&&(s.alpha=s.alpha*t,n.some(e=>e.color.syntaxFlags.has(me.Experimental))&&s.syntaxFlags.add(me.Experimental),2!==n.length&&s.syntaxFlags.add(me.ColorMixVariadic),s))}function colorMixPolarPair(e,a,n,r,o){let t=0,l=0,s=0,u=0,i=0,c=0,h=n.alpha;if("number"!=typeof h)return!1;let m=r.alpha;if("number"!=typeof m)return!1;h=Number.isNaN(h)?m:h,m=Number.isNaN(m)?h:m;const N=colorDataTo(n,e).channels,p=colorDataTo(r,e).channels;switch(e){case he.HSL:case he.HWB:t=N[0],l=p[0],s=N[1],u=p[1],i=N[2],c=p[2];break;case he.LCH:case he.OKLCH:s=N[0],u=p[0],i=N[1],c=p[1],t=N[2],l=p[2]}if(s=fillInMissingComponent(s,u),u=fillInMissingComponent(u,s),i=fillInMissingComponent(i,c),c=fillInMissingComponent(c,i),t=fillInMissingComponent(t,l),l=fillInMissingComponent(l,t),Number.isNaN(t)&&Number.isNaN(l));else{Number.isNaN(t)?t=0:Number.isNaN(l)&&(l=0);const e=l-t;switch(a){case"shorter":e>180?t+=360:e<-180&&(l+=360);break;case"longer":-180<e&&e<180&&(e>0?t+=360:l+=360);break;case"increasing":e<0&&(l+=360);break;case"decreasing":e>0&&(t+=360);break;default:throw new Error("Unknown hue interpolation method")}}s=premultiply(s,h),i=premultiply(i,h),u=premultiply(u,m),c=premultiply(c,m);let b=[0,0,0];const v=interpolate(h,m,o);switch(e){case he.HSL:case he.HWB:b=[interpolate(t,l,o),un_premultiply(interpolate(s,u,o),v),un_premultiply(interpolate(i,c,o),v)];break;case he.LCH:case he.OKLCH:b=[un_premultiply(interpolate(s,u,o),v),un_premultiply(interpolate(i,c,o),v),interpolate(t,l,o)]}return{colorNotation:e,channels:b,alpha:v,syntaxFlags:new Set([me.ColorMix])}}function fillInMissingComponent(e,a){return Number.isNaN(e)?a:e}function interpolate(e,a,n){return e*(1-n)+a*n}function premultiply(e,a){return Number.isNaN(a)?e:Number.isNaN(e)?Number.NaN:e*a}function un_premultiply(e,a){return 0===a||Number.isNaN(a)?e:Number.isNaN(e)?Number.NaN:e/a}function normalizeMixPercentages(e,a=!1){let n=0,r=0;for(const a of e)a.percentage&&(n+=a.percentage),!1===a.percentage&&r++;n=Math.min(100,n);for(const a of e)!1===a.percentage&&(a.percentage=(100-n)/r);const o=e.slice();let t=0;for(const e of o)t+=e.percentage;if(t>100||t>0&&a)for(const e of o)e.percentage=e.percentage*(100/t);let l=0;return t<100&&(l=100-t),{items:o,leftover:l}}function hex(e){const a=toLowerCaseAZ(e[4].value);if(a.match(/[^a-f0-9]/))return!1;const n={colorNotation:he.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([me.Hex])},r=a.length;if(3===r){const e=a[0],r=a[1],o=a[2];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(o+o,16)/255],n}if(6===r){const e=a[0]+a[1],r=a[2]+a[3],o=a[4]+a[5];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(o,16)/255],n}if(4===r){const e=a[0],r=a[1],o=a[2],t=a[3];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(o+o,16)/255],n.alpha=parseInt(t+t,16)/255,n.syntaxFlags.add(me.HasAlpha),n}if(8===r){const e=a[0]+a[1],r=a[2]+a[3],o=a[4]+a[5],t=a[6]+a[7];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(o,16)/255],n.alpha=parseInt(t,16)/255,n.syntaxFlags.add(me.HasAlpha),n}return!1}function normalizeHue(n){if(o(n))return Number.isNaN(n[4].value)||Number.isFinite(n[4].value)||(n[4].value=0),n[4].value=n[4].value%360,n[4].value<0&&(n[4].value+=360),n[1]=n[4].value.toString(),n;if(u(n)){let r=n[4].value;switch(toLowerCaseAZ(n[4].unit)){case"deg":break;case"rad":r=180*n[4].value/Math.PI;break;case"grad":r=.9*n[4].value;break;case"turn":r=360*n[4].value;break;default:return!1}return Number.isNaN(n[4].value)||Number.isFinite(n[4].value)||(n[4].value=0),r%=360,r<0&&(r+=360),[e.Number,r.toString(),n[2],n[3],{value:r,type:a.Number}]}return!1}function normalize_legacy_HSL_ChannelValues(n,t,l){if(0===t){const e=normalizeHue(n);return!1!==e&&(u(n)&&l.syntaxFlags.add(me.HasDimensionValues),e)}if(r(n)){3===t?l.syntaxFlags.add(me.HasPercentageAlpha):l.syntaxFlags.add(me.HasPercentageValues);let r=normalize(n[4].value,1,0,100);return 3===t&&(r=normalize(n[4].value,100,0,1)),[e.Number,r.toString(),n[2],n[3],{value:r,type:a.Number}]}if(o(n)){if(3!==t)return!1;let r=normalize(n[4].value,1,0,100);return 3===t&&(r=normalize(n[4].value,1,0,1)),[e.Number,r.toString(),n[2],n[3],{value:r,type:a.Number}]}return!1}function normalize_modern_HSL_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(0===l){const e=normalizeHue(t);return!1!==e&&(u(t)&&s.syntaxFlags.add(me.HasDimensionValues),e)}if(r(t)){3===l?s.syntaxFlags.add(me.HasPercentageAlpha):s.syntaxFlags.add(me.HasPercentageValues);let n=t[4].value;return 3===l?n=normalize(t[4].value,100,0,1):1===l&&(n=normalize(t[4].value,1,0,2147483647)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=t[4].value;return 3===l?n=normalize(t[4].value,1,0,1):1===l&&(n=normalize(t[4].value,1,0,2147483647)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function threeChannelLegacySyntax(e,a,n,r){const t=[],u=[],i=[],c=[],h={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)};let m=t;for(let a=0;a<e.value.length;a++){let n=e.value[a];if(!ee(n)&&!ae(n)){if(ne(n)&&s(n.value)){if(m===t){m=u;continue}if(m===u){m=i;continue}if(m===i){m=c;continue}if(m===c)return!1}if(re(n)){if(m===c&&"var"===n.getName().toLowerCase()){h.syntaxFlags.add(me.HasVariableAlpha),m.push(n);continue}if(!ie.has(n.getName().toLowerCase()))return!1;const[[e]]=ce([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!ne(e)||!l(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),n=e}if(!ne(n))return!1;m.push(n)}}if(1!==m.length)return!1;if(1!==t.length||1!==u.length||1!==i.length)return!1;if(!ne(t[0])||!ne(u[0])||!ne(i[0]))return!1;const N=a(t[0].value,0,h);if(!N||!o(N))return!1;const p=a(u[0].value,1,h);if(!p||!o(p))return!1;const b=a(i[0].value,2,h);if(!b||!o(b))return!1;const v=[N,p,b];if(1===c.length)if(h.syntaxFlags.add(me.HasAlpha),ne(c[0])){const e=a(c[0].value,3,h);if(!e||!o(e))return!1;v.push(e)}else h.alpha=c[0];return h.channels=[v[0][4].value,v[1][4].value,v[2][4].value],4===v.length&&(h.alpha=v[3][4].value),h}function threeChannelSpaceSeparated(e,a,r,s,u){const i=[],c=[],h=[],m=[];let N,p,b=!1;const v={colorNotation:r,channels:[0,0,0],alpha:1,syntaxFlags:new Set(s)};let f=i;for(let a=0;a<e.value.length;a++){let o=e.value[a];if(ee(o)||ae(o))for(;ee(e.value[a+1])||ae(e.value[a+1]);)a++;else if(f===i&&i.length&&(f=c),f===c&&c.length&&(f=h),ne(o)&&t(o.value)&&"/"===o.value[4].value){if(f===m)return!1;f=m}else{if(re(o)){if(f===m&&"var"===o.getName().toLowerCase()){v.syntaxFlags.add(me.HasVariableAlpha),f.push(o);continue}if(!ie.has(o.getName().toLowerCase()))return!1;const[[e]]=ce([[o]],{censorIntoStandardRepresentableValues:!0,globals:p,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!ne(e)||!l(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),o=e}if(f===i&&0===i.length&&ne(o)&&n(o.value)&&"from"===o.value[4].value.toLowerCase()){if(b)return!1;for(;ee(e.value[a+1])||ae(e.value[a+1]);)a++;if(a++,o=e.value[a],b=u(o),!1===b)return!1;b.syntaxFlags.has(me.Experimental)&&v.syntaxFlags.add(me.Experimental),v.syntaxFlags.add(me.RelativeColorSyntax),b.colorNotation!==r&&(b=colorDataTo(b,r)),N=normalizeRelativeColorDataChannels(b),p=noneToZeroInRelativeColorDataChannels(N)}else{if(!ne(o))return!1;if(n(o.value)&&N){const e=o.value[4].value.toLowerCase();if(N.has(e)){f.push(new oe(N.get(e)));continue}}f.push(o)}}}if(1!==f.length)return!1;if(1!==i.length||1!==c.length||1!==h.length)return!1;if(!ne(i[0])||!ne(c[0])||!ne(h[0]))return!1;if(N&&!N.has("alpha"))return!1;const g=a(i[0].value,0,v);if(!g||!o(g))return!1;const y=a(c[0].value,1,v);if(!y||!o(y))return!1;const d=a(h[0].value,2,v);if(!d||!o(d))return!1;const _=[g,y,d];if(1===m.length)if(v.syntaxFlags.add(me.HasAlpha),ne(m[0])){const e=a(m[0].value,3,v);if(!e||!o(e))return!1;_.push(e)}else v.alpha=m[0];else if(N&&N.has("alpha")){const e=a(N.get("alpha"),3,v);if(!e||!o(e))return!1;_.push(e)}return v.channels=[_[0][4].value,_[1][4].value,_[2][4].value],4===_.length&&(v.alpha=_[3][4].value),v}function hsl(e,a){if(e.value.some(e=>ne(e)&&s(e.value))){const a=hslCommaSeparated(e);if(!1!==a)return a}{const n=hslSpaceSeparated(e,a);if(!1!==n)return n}return!1}function hslCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_HSL_ChannelValues,he.HSL,[me.LegacyHSL])}function hslSpaceSeparated(e,a){return threeChannelSpaceSeparated(e,normalize_modern_HSL_ChannelValues,he.HSL,[],a)}function normalize_HWB_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(0===l){const e=normalizeHue(t);return!1!==e&&(u(t)&&s.syntaxFlags.add(me.HasDimensionValues),e)}if(r(t)){3===l?s.syntaxFlags.add(me.HasPercentageAlpha):s.syntaxFlags.add(me.HasPercentageValues);let n=t[4].value;return 3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=t[4].value;return 3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function normalize_Lab_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(r(t)){3!==l&&s.syntaxFlags.add(me.HasPercentageValues);let n=normalize(t[4].value,1,0,100);return 1===l||2===l?n=normalize(t[4].value,.8,-2147483647,2147483647):3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=normalize(t[4].value,1,0,100);return 1===l||2===l?n=normalize(t[4].value,1,-2147483647,2147483647):3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function lab(e,a){return threeChannelSpaceSeparated(e,normalize_Lab_ChannelValues,he.Lab,[],a)}function normalize_LCH_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(2===l){const e=normalizeHue(t);return!1!==e&&(u(t)&&s.syntaxFlags.add(me.HasDimensionValues),e)}if(r(t)){3!==l&&s.syntaxFlags.add(me.HasPercentageValues);let n=normalize(t[4].value,1,0,100);return 1===l?n=normalize(t[4].value,100/150,0,2147483647):3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=normalize(t[4].value,1,0,100);return 1===l?n=normalize(t[4].value,1,0,2147483647):3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function lch(e,a){return threeChannelSpaceSeparated(e,normalize_LCH_ChannelValues,he.LCH,[],a)}const ye=new Map;for(const[e,a]of Object.entries(G))ye.set(e,a);function namedColor(e){const a=ye.get(toLowerCaseAZ(e));return!!a&&{colorNotation:he.RGB,channels:[a[0]/255,a[1]/255,a[2]/255],alpha:1,syntaxFlags:new Set([me.ColorKeyword,me.NamedColor])}}function normalize_OKLab_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(r(t)){3!==l&&s.syntaxFlags.add(me.HasPercentageValues);let n=normalize(t[4].value,100,0,1);return 1===l||2===l?n=normalize(t[4].value,250,-2147483647,2147483647):3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=normalize(t[4].value,1,0,1);return 1===l||2===l?n=normalize(t[4].value,1,-2147483647,2147483647):3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function oklab(e,a){return threeChannelSpaceSeparated(e,normalize_OKLab_ChannelValues,he.OKLab,[],a)}function normalize_OKLCH_ChannelValues(t,l,s){if(n(t)&&"none"===toLowerCaseAZ(t[4].value))return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(2===l){const e=normalizeHue(t);return!1!==e&&(u(t)&&s.syntaxFlags.add(me.HasDimensionValues),e)}if(r(t)){3!==l&&s.syntaxFlags.add(me.HasPercentageValues);let n=normalize(t[4].value,100,0,1);return 1===l?n=normalize(t[4].value,250,0,2147483647):3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=normalize(t[4].value,1,0,1);return 1===l?n=normalize(t[4].value,1,0,2147483647):3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function oklch(e,a){return threeChannelSpaceSeparated(e,normalize_OKLCH_ChannelValues,he.OKLCH,[],a)}function normalize_legacy_sRGB_ChannelValues(n,t,l){if(r(n)){3===t?l.syntaxFlags.add(me.HasPercentageAlpha):l.syntaxFlags.add(me.HasPercentageValues);const r=normalize(n[4].value,100,0,1);return[e.Number,r.toString(),n[2],n[3],{value:r,type:a.Number}]}if(o(n)){3!==t&&l.syntaxFlags.add(me.HasNumberValues);let r=normalize(n[4].value,255,0,1);return 3===t&&(r=normalize(n[4].value,1,0,1)),[e.Number,r.toString(),n[2],n[3],{value:r,type:a.Number}]}return!1}function normalize_modern_sRGB_ChannelValues(t,l,s){if(n(t)&&"none"===t[4].value.toLowerCase())return s.syntaxFlags.add(me.HasNoneKeywords),[e.Number,"none",t[2],t[3],{value:Number.NaN,type:a.Number}];if(r(t)){3!==l&&s.syntaxFlags.add(me.HasPercentageValues);let n=normalize(t[4].value,100,-2147483647,2147483647);return 3===l&&(n=normalize(t[4].value,100,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}if(o(t)){3!==l&&s.syntaxFlags.add(me.HasNumberValues);let n=normalize(t[4].value,255,-2147483647,2147483647);return 3===l&&(n=normalize(t[4].value,1,0,1)),[e.Number,n.toString(),t[2],t[3],{value:n,type:a.Number}]}return!1}function rgb(e,a){if(e.value.some(e=>ne(e)&&s(e.value))){const a=rgbCommaSeparated(e);if(!1!==a)return(!a.syntaxFlags.has(me.HasNumberValues)||!a.syntaxFlags.has(me.HasPercentageValues))&&a}else{const n=rgbSpaceSeparated(e,a);if(!1!==n)return n}return!1}function rgbCommaSeparated(e){return threeChannelLegacySyntax(e,normalize_legacy_sRGB_ChannelValues,he.RGB,[me.LegacyRGB])}function rgbSpaceSeparated(e,a){return threeChannelSpaceSeparated(e,normalize_modern_sRGB_ChannelValues,he.RGB,[],a)}function XYZ_D50_to_sRGB_Gamut(e){const a=x(e);if(A(a))return X(a);let n=e;return n=N(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),K(Y(n,oklch_to_lin_srgb,lin_srgb_to_oklch))}function oklch_to_lin_srgb(e){return e=I(e),e=O(e),W(e)}function lin_srgb_to_oklch(e){return e=E(e),e=U(e),$(e)}function contrastColor(e,a){let n=!1;for(let r=0;r<e.value.length;r++){const o=e.value[r];if(!ee(o)&&!ae(o)&&(n||(n=a(o),!n)))return!1}if(!n)return!1;n.channels=convertNaNToZero(n.channels),n.channels=XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(n).channels),n.colorNotation=he.sRGB;const r={colorNotation:he.RGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([me.ContrastColor,me.Experimental])},o=j(n.channels,[1,1,1]),t=j(n.channels,[0,0,0]);return r.channels=o>t?[1,1,1]:[0,0,0],r}function alpha(e,a){let r,s,u=!1,i=!1,c=!1;const h={colorNotation:he.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};for(let m=0;m<e.value.length;m++){let N=e.value[m];if(ee(N)||ae(N))for(;ee(e.value[m+1])||ae(e.value[m+1]);)m++;else if(c&&!u&&!i&&ne(N)&&t(N.value)&&"/"===N.value[4].value)u=!0;else{if(re(N)&&ie.has(toLowerCaseAZ(N.getName()))){const[[e]]=ce([[N]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!ne(e)||!l(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),N=e}if(u||i||!ne(N)||!n(N.value)||"from"!==toLowerCaseAZ(N.value[4].value)){if(!u)return!1;if(i)return!1;if(ne(N)){if(n(N.value)&&"alpha"===toLowerCaseAZ(N.value[4].value)&&r&&r.has("alpha")){h.alpha=r.get("alpha")[4].value,i=!0;continue}const e=normalize_Color_ChannelValues(N.value,3,h);if(!e||!o(e))return!1;h.alpha=e[4].value,i=!0;continue}if(re(N)){const e=le([[N]],e=>{if(ne(e)&&n(e.value)&&"alpha"===toLowerCaseAZ(e.value[4].value)&&r&&r.has("alpha"))return new oe(r.get("alpha"))});h.alpha=e[0][0],i=!0;continue}return!1}if(c)return!1;for(;ee(e.value[m+1])||ae(e.value[m+1]);)m++;if(m++,N=e.value[m],c=a(N),!1===c)return!1;r=normalizeRelativeColorDataChannels(c),s=noneToZeroInRelativeColorDataChannels(r),h.syntaxFlags=new Set(c.syntaxFlags),h.syntaxFlags.add(me.RelativeAlphaSyntax),h.channels=[...c.channels],h.colorNotation=c.colorNotation,h.alpha=c.alpha}}return!!r&&h}function XYZ_D50_to_P3_Gamut(e){const a=C(e);if(A(a))return X(a);let n=e;return n=N(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),q(Y(n,oklch_to_lin_p3,lin_p3_to_oklch))}function oklch_to_lin_p3(e){return e=I(e),e=O(e),J(e)}function lin_p3_to_oklch(e){return e=Q(e),e=U(e),$(e)}function toPrecision(e,a=7){e=+e,a=+a;const n=(Math.floor(Math.abs(e))+"").length;if(a>n)return+e.toFixed(a-n);{const r=10**(n-a);return Math.round(e/r)*r}}function serializeWithAlpha(n,r,o,t){const l=[e.CloseParen,")",-1,-1,void 0];if("number"==typeof n.alpha){const s=Math.min(1,Math.max(0,toPrecision(Number.isNaN(n.alpha)?0:n.alpha)));return 1===toPrecision(s,4)?new se(r,l,t):new se(r,l,[...t,new ue([o]),new oe([e.Delim,"/",-1,-1,{value:"/"}]),new ue([o]),new oe([e.Number,toPrecision(s,4).toString(),-1,-1,{value:n.alpha,type:a.Integer}])])}return new se(r,l,[...t,new ue([o]),new oe([e.Delim,"/",-1,-1,{value:"/"}]),new ue([o]),n.alpha])}function serializeP3(n,r=!0){n.channels=convertPowerlessComponentsToZeroValuesForDisplay(n.channels,n.colorNotation);let o=n.channels.map(e=>Number.isNaN(e)?0:e);r?o=XYZ_D50_to_P3_Gamut(colorData_to_XYZ_D50(n).channels):n.colorNotation!==he.Display_P3&&(o=C(colorData_to_XYZ_D50(n).channels));const t=r?Math.min(1,Math.max(0,toPrecision(o[0],6))):toPrecision(o[0],6),l=r?Math.min(1,Math.max(0,toPrecision(o[1],6))):toPrecision(o[1],6),s=r?Math.min(1,Math.max(0,toPrecision(o[2],6))):toPrecision(o[2],6),u=[e.Function,"color(",-1,-1,{value:"color"}],i=[e.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(n,u,i,[new oe([e.Ident,"display-p3",-1,-1,{value:"display-p3"}]),new ue([i]),new oe([e.Number,t.toString(),-1,-1,{value:o[0],type:a.Number}]),new ue([i]),new oe([e.Number,l.toString(),-1,-1,{value:o[1],type:a.Number}]),new ue([i]),new oe([e.Number,s.toString(),-1,-1,{value:o[2],type:a.Number}])])}function serializeRGB(n,r=!0){let o;n.channels=convertPowerlessComponentsToZeroValuesForDisplay(n.channels,n.colorNotation),o=r?XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(n).channels):x(colorData_to_XYZ_D50(n).channels);const t=Math.min(255,Math.max(0,Math.round(255*toPrecision(o[0])))),l=Math.min(255,Math.max(0,Math.round(255*toPrecision(o[1])))),s=Math.min(255,Math.max(0,Math.round(255*toPrecision(o[2])))),u=[e.CloseParen,")",-1,-1,void 0],i=[e.Whitespace," ",-1,-1,void 0],c=[e.Comma,",",-1,-1,void 0],h=[new oe([e.Number,t.toString(),-1,-1,{value:Math.min(255,255*Math.max(0,o[0])),type:a.Integer}]),new oe(c),new ue([i]),new oe([e.Number,l.toString(),-1,-1,{value:Math.min(255,255*Math.max(0,o[1])),type:a.Integer}]),new oe(c),new ue([i]),new oe([e.Number,s.toString(),-1,-1,{value:Math.min(255,255*Math.max(0,o[2])),type:a.Integer}])];if("number"==typeof n.alpha){const r=Math.min(1,Math.max(0,toPrecision(Number.isNaN(n.alpha)?0:n.alpha)));return 1===toPrecision(r,4)?new se([e.Function,"rgb(",-1,-1,{value:"rgb"}],u,h):new se([e.Function,"rgba(",-1,-1,{value:"rgba"}],u,[...h,new oe(c),new ue([i]),new oe([e.Number,toPrecision(r,4).toString(),-1,-1,{value:n.alpha,type:a.Number}])])}return new se([e.Function,"rgba(",-1,-1,{value:"rgba"}],u,[...h,new oe(c),new ue([i]),n.alpha])}function serializeHSL(n,r=!0){let o;n.channels=convertPowerlessComponentsToZeroValuesForDisplay(n.channels,n.colorNotation),o=f(r?T(XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(n).channels)):colorData_to_XYZ_D50(n).channels),o=o.map(e=>Number.isNaN(e)?0:e);const t=Math.min(360,Math.max(0,Math.round(toPrecision(o[0])))),l=Math.min(100,Math.max(0,Math.round(toPrecision(o[1])))),s=Math.min(100,Math.max(0,Math.round(toPrecision(o[2])))),u=[e.CloseParen,")",-1,-1,void 0],i=[e.Whitespace," ",-1,-1,void 0],c=[e.Comma,",",-1,-1,void 0],h=[new oe([e.Number,t.toString(),-1,-1,{value:o[0],type:a.Integer}]),new oe(c),new ue([i]),new oe([e.Percentage,l.toString()+"%",-1,-1,{value:o[1]}]),new oe(c),new ue([i]),new oe([e.Percentage,s.toString()+"%",-1,-1,{value:o[2]}])];if("number"==typeof n.alpha){const r=Math.min(1,Math.max(0,toPrecision(Number.isNaN(n.alpha)?0:n.alpha)));return 1===toPrecision(r,4)?new se([e.Function,"hsl(",-1,-1,{value:"hsl"}],u,h):new se([e.Function,"hsla(",-1,-1,{value:"hsla"}],u,[...h,new oe(c),new ue([i]),new oe([e.Number,toPrecision(r,4).toString(),-1,-1,{value:n.alpha,type:a.Number}])])}return new se([e.Function,"hsla(",-1,-1,{value:"hsla"}],u,[...h,new oe(c),new ue([i]),n.alpha])}function serializeOKLCH(n){n.channels=convertPowerlessComponentsToZeroValuesForDisplay(n.channels,n.colorNotation);let r=n.channels.map(e=>Number.isNaN(e)?0:e);n.colorNotation!==he.OKLCH&&(r=N(colorData_to_XYZ_D50(n).channels));const o=toPrecision(r[0],6),t=toPrecision(r[1],6),l=toPrecision(r[2],6),s=[e.Function,"oklch(",-1,-1,{value:"oklch"}],u=[e.Whitespace," ",-1,-1,void 0];return serializeWithAlpha(n,s,u,[new oe([e.Number,o.toString(),-1,-1,{value:r[0],type:a.Number}]),new ue([u]),new oe([e.Number,t.toString(),-1,-1,{value:r[1],type:a.Number}]),new ue([u]),new oe([e.Number,l.toString(),-1,-1,{value:r[2],type:a.Number}])])}function color(e){if(re(e)){switch(toLowerCaseAZ(e.getName())){case"rgb":case"rgba":return rgb(e,color);case"hsl":case"hsla":return hsl(e,color);case"hwb":return a=color,threeChannelSpaceSeparated(e,normalize_HWB_ChannelValues,he.HWB,[],a);case"lab":return lab(e,color);case"lch":return lch(e,color);case"oklab":return oklab(e,color);case"oklch":return oklch(e,color);case"color":return color$1(e,color);case"color-mix":return colorMix(e,color);case"contrast-color":return contrastColor(e,color);case"alpha":return alpha(e,color)}}var a;if(ne(e)){if(i(e.value))return hex(e.value);if(n(e.value)){const a=namedColor(e.value[4].value);return!1!==a?a:"transparent"===toLowerCaseAZ(e.value[4].value)&&{colorNotation:he.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([me.ColorKeyword])}}}return!1}export{he as ColorNotation,me as SyntaxFlag,color,colorDataFitsDisplayP3_Gamut,colorDataFitsRGB_Gamut,serializeHSL,serializeOKLCH,serializeP3,serializeRGB};
node_modules/@csstools/css-color-parser/package.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-color-parser",
3
+ "description": "Parse CSS color values",
4
+ "version": "4.1.7",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "engines": {
28
+ "node": ">=20.19.0"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.mjs"
35
+ }
36
+ },
37
+ "files": [
38
+ "CHANGELOG.md",
39
+ "LICENSE.md",
40
+ "README.md",
41
+ "dist"
42
+ ],
43
+ "dependencies": {
44
+ "@csstools/color-helpers": "^6.0.2",
45
+ "@csstools/css-calc": "^3.2.1"
46
+ },
47
+ "peerDependencies": {
48
+ "@csstools/css-parser-algorithms": "^4.0.0",
49
+ "@csstools/css-tokenizer": "^4.0.0"
50
+ },
51
+ "scripts": {},
52
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser#readme",
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
56
+ "directory": "packages/css-color-parser"
57
+ },
58
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
59
+ "keywords": [
60
+ "color",
61
+ "css",
62
+ "parser"
63
+ ]
64
+ }
node_modules/@csstools/css-parser-algorithms/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changes to CSS Parser Algorithms
2
+
3
+ ### 4.0.0
4
+
5
+ _January 14, 2026_
6
+
7
+ - Updated: Support for Node `20.19.0` or later (major).
8
+ - Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes.
9
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`4.0.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#400) (major)
10
+
11
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md)
node_modules/@csstools/css-parser-algorithms/LICENSE.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/@csstools/css-parser-algorithms/README.md ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Parser Algorithms <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-parser-algorithms.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+ [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
+
7
+ Implemented from : https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/
8
+
9
+ ## API
10
+
11
+ [Read the API docs](./docs/css-parser-algorithms.md)
12
+
13
+ ## Usage
14
+
15
+ Add [CSS Parser Algorithms] to your project:
16
+
17
+ ```bash
18
+ npm install @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev
19
+ ```
20
+
21
+ [CSS Parser Algorithms] only accepts tokenized CSS.
22
+ It must be used together with `@csstools/css-tokenizer`.
23
+
24
+
25
+ ```js
26
+ import { tokenizer, TokenType } from '@csstools/css-tokenizer';
27
+ import { parseComponentValue } from '@csstools/css-parser-algorithms';
28
+
29
+ const myCSS = `@media only screen and (min-width: 768rem) {
30
+ .foo {
31
+ content: 'Some content!' !important;
32
+ }
33
+ }
34
+ `;
35
+
36
+ const t = tokenizer({
37
+ css: myCSS,
38
+ });
39
+
40
+ const tokens = [];
41
+
42
+ {
43
+ while (!t.endOfFile()) {
44
+ tokens.push(t.nextToken());
45
+ }
46
+
47
+ tokens.push(t.nextToken()); // EOF-token
48
+ }
49
+
50
+ const options = {
51
+ onParseError: ((err) => {
52
+ throw err;
53
+ }),
54
+ };
55
+
56
+ const result = parseComponentValue(tokens, options);
57
+
58
+ console.log(result);
59
+ ```
60
+
61
+ ### Available functions
62
+
63
+ - [`parseComponentValue`](https://www.w3.org/TR/css-syntax-3/#parse-component-value)
64
+ - [`parseListOfComponentValues`](https://www.w3.org/TR/css-syntax-3/#parse-list-of-component-values)
65
+ - [`parseCommaSeparatedListOfComponentValues`](https://www.w3.org/TR/css-syntax-3/#parse-comma-separated-list-of-component-values)
66
+
67
+ ### Utilities
68
+
69
+ #### `gatherNodeAncestry`
70
+
71
+ The AST does not expose the entire ancestry of each node.
72
+ The walker methods do provide access to the current parent, but also not the entire ancestry.
73
+
74
+ To gather the entire ancestry for a a given sub tree of the AST you can use `gatherNodeAncestry`.
75
+ The result is a `Map` with the child nodes as keys and the parents as values.
76
+ This allows you to lookup any ancestor of any node.
77
+
78
+ ```js
79
+ import { parseComponentValue } from '@csstools/css-parser-algorithms';
80
+
81
+ const result = parseComponentValue(tokens, options);
82
+ const ancestry = gatherNodeAncestry(result);
83
+ ```
84
+
85
+ ### Options
86
+
87
+ ```ts
88
+ {
89
+ onParseError?: (error: ParseError) => void
90
+ }
91
+ ```
92
+
93
+ #### `onParseError`
94
+
95
+ The parser algorithms are forgiving and won't stop when a parse error is encountered.
96
+ Parse errors also aren't tokens.
97
+
98
+ To receive parsing error information you can set a callback.
99
+
100
+ Parser errors will try to inform you about the point in the parsing logic the error happened.
101
+ This tells you the kind of error.
102
+
103
+ ## Goals and non-goals
104
+
105
+ Things this package aims to be:
106
+ - specification compliant CSS parser
107
+ - a reliable low level package to be used in CSS sub-grammars
108
+
109
+ What it is not:
110
+ - opinionated
111
+ - fast
112
+ - small
113
+ - a replacement for PostCSS (PostCSS is fast and also an ecosystem)
114
+
115
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
116
+ [discord]: https://discord.gg/bUadyRwkJS
117
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-parser-algorithms
118
+
119
+ [CSS Parser Algorithms]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms
node_modules/@csstools/css-parser-algorithms/dist/index.d.ts ADDED
@@ -0,0 +1,604 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Parse CSS following the {@link https://drafts.csswg.org/css-syntax/#parsing | CSS Syntax Level 3 specification}.
3
+ *
4
+ * @remarks
5
+ * The tokenizing and parsing tools provided by CSS Tools are designed to be low level and generic with strong ties to their respective specifications.
6
+ *
7
+ * Any analysis or mutation of CSS source code should be done with the least powerful tool that can accomplish the task.
8
+ * For many applications it is sufficient to work with tokens.
9
+ * 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.
10
+ *
11
+ * The implementation of the AST nodes is kept lightweight and simple.
12
+ * Do not expect magic methods, instead assume that arrays and class instances behave like any other JavaScript.
13
+ *
14
+ * @example
15
+ * Parse a string of CSS into a component value:
16
+ * ```js
17
+ * import { tokenize } from '@csstools/css-tokenizer';
18
+ * import { parseComponentValue } from '@csstools/css-parser-algorithms';
19
+ *
20
+ * const myCSS = `calc(1px * 2)`;
21
+ *
22
+ * const componentValue = parseComponentValue(tokenize({
23
+ * css: myCSS,
24
+ * }));
25
+ *
26
+ * console.log(componentValue);
27
+ * ```
28
+ *
29
+ * @example
30
+ * Use the right algorithm for the job.
31
+ *
32
+ * Algorithms that can parse larger structures (comma-separated lists, ...) can also parse smaller structures.
33
+ * However, the opposite is not true.
34
+ *
35
+ * If your context allows a list of component values, use {@link parseListOfComponentValues}:
36
+ * ```js
37
+ * import { tokenize } from '@csstools/css-tokenizer';
38
+ * import { parseListOfComponentValues } from '@csstools/css-parser-algorithms';
39
+ *
40
+ * parseListOfComponentValues(tokenize({ css: `10x 20px` }));
41
+ * ```
42
+ *
43
+ * If your context allows a comma-separated list of component values, use {@link parseCommaSeparatedListOfComponentValues}:
44
+ * ```js
45
+ * import { tokenize } from '@csstools/css-tokenizer';
46
+ * import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser-algorithms';
47
+ *
48
+ * parseCommaSeparatedListOfComponentValues(tokenize({ css: `20deg, 50%, 30%` }));
49
+ * ```
50
+ *
51
+ * @example
52
+ * Use the stateful walkers to keep track of the context of a given component value.
53
+ *
54
+ * ```js
55
+ * import { tokenize } from '@csstools/css-tokenizer';
56
+ * import { parseComponentValue, isSimpleBlockNode } from '@csstools/css-parser-algorithms';
57
+ *
58
+ * const myCSS = `calc(1px * (5 / 2))`;
59
+ *
60
+ * const componentValue = parseComponentValue(tokenize({ css: myCSS }));
61
+ *
62
+ * let state = { inSimpleBlock: false };
63
+ * componentValue.walk((entry) => {
64
+ * if (isSimpleBlockNode(entry)) {
65
+ * entry.state.inSimpleBlock = true;
66
+ * return;
67
+ * }
68
+ *
69
+ * if (entry.state.inSimpleBlock) {
70
+ * console.log(entry.node.toString()); // `5`, ...
71
+ * }
72
+ * }, state);
73
+ * ```
74
+ *
75
+ * @packageDocumentation
76
+ */
77
+
78
+ import type { CSSToken } from '@csstools/css-tokenizer';
79
+ import { ParseError } from '@csstools/css-tokenizer';
80
+ import type { TokenFunction } from '@csstools/css-tokenizer';
81
+
82
+ export declare class CommentNode {
83
+ /**
84
+ * The node type, always `ComponentValueType.Comment`
85
+ */
86
+ type: ComponentValueType;
87
+ /**
88
+ * The comment token.
89
+ */
90
+ value: CSSToken;
91
+ constructor(value: CSSToken);
92
+ /**
93
+ * Retrieve the tokens for the current comment.
94
+ * This is the inverse of parsing from a list of tokens.
95
+ */
96
+ tokens(): Array<CSSToken>;
97
+ /**
98
+ * Convert the current comment to a string.
99
+ * This is not a true serialization.
100
+ * It is purely a concatenation of the string representation of the tokens.
101
+ */
102
+ toString(): string;
103
+ /**
104
+ * @internal
105
+ *
106
+ * A debug helper to convert the current object to a JSON representation.
107
+ * This is useful in asserts and to store large ASTs in files.
108
+ */
109
+ toJSON(): Record<string, unknown>;
110
+ /**
111
+ * @internal
112
+ */
113
+ isCommentNode(): this is CommentNode;
114
+ /**
115
+ * @internal
116
+ */
117
+ static isCommentNode(x: unknown): x is CommentNode;
118
+ }
119
+
120
+ export declare type ComponentValue = FunctionNode | SimpleBlockNode | WhitespaceNode | CommentNode | TokenNode;
121
+
122
+ export declare enum ComponentValueType {
123
+ Function = "function",
124
+ SimpleBlock = "simple-block",
125
+ Whitespace = "whitespace",
126
+ Comment = "comment",
127
+ Token = "token"
128
+ }
129
+
130
+ export declare type ContainerNode = FunctionNode | SimpleBlockNode;
131
+
132
+ export declare abstract class ContainerNodeBaseClass {
133
+ /**
134
+ * The contents of the `Function` or `Simple Block`.
135
+ * This is a list of component values.
136
+ */
137
+ value: Array<ComponentValue>;
138
+ /**
139
+ * Retrieve the index of the given item in the current node.
140
+ * For most node types this will be trivially implemented as `this.value.indexOf(item)`.
141
+ */
142
+ indexOf(item: ComponentValue): number | string;
143
+ /**
144
+ * Retrieve the item at the given index in the current node.
145
+ * For most node types this will be trivially implemented as `this.value[index]`.
146
+ */
147
+ at(index: number | string): ComponentValue | undefined;
148
+ /**
149
+ * Iterates over each item in the `value` array of the current node.
150
+ *
151
+ * @param cb - The callback function to execute for each item.
152
+ * The function receives an object containing the current node (`node`), its parent (`parent`),
153
+ * and an optional `state` object.
154
+ * A second parameter is the index of the current node.
155
+ * The function can return `false` to stop the iteration.
156
+ *
157
+ * @param state - An optional state object that can be used to pass additional information to the callback function.
158
+ * The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
159
+ *
160
+ * @returns `false` if the iteration was halted, `undefined` otherwise.
161
+ */
162
+ forEach<T extends Record<string, unknown>, U extends ContainerNode>(this: U, cb: (entry: {
163
+ node: ComponentValue;
164
+ parent: ContainerNode;
165
+ state?: T;
166
+ }, index: number | string) => boolean | void, state?: T): false | undefined;
167
+ /**
168
+ * Walks the current node and all its children.
169
+ *
170
+ * @param cb - The callback function to execute for each item.
171
+ * The function receives an object containing the current node (`node`), its parent (`parent`),
172
+ * and an optional `state` object.
173
+ * A second parameter is the index of the current node.
174
+ * The function can return `false` to stop the iteration.
175
+ *
176
+ * @param state - An optional state object that can be used to pass additional information to the callback function.
177
+ * The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
178
+ * However changes are passed down to child node iterations.
179
+ *
180
+ * @returns `false` if the iteration was halted, `undefined` otherwise.
181
+ */
182
+ walk<T extends Record<string, unknown>, U extends ContainerNode>(this: U, cb: (entry: {
183
+ node: ComponentValue;
184
+ parent: ContainerNode;
185
+ state?: T;
186
+ }, index: number | string) => boolean | void, state?: T): false | undefined;
187
+ }
188
+
189
+ /**
190
+ * Iterates over each item in a list of component values.
191
+ *
192
+ * @param cb - The callback function to execute for each item.
193
+ * The function receives an object containing the current node (`node`), its parent (`parent`),
194
+ * and an optional `state` object.
195
+ * A second parameter is the index of the current node.
196
+ * The function can return `false` to stop the iteration.
197
+ *
198
+ * @param state - An optional state object that can be used to pass additional information to the callback function.
199
+ * The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
200
+ *
201
+ * @returns `false` if the iteration was halted, `undefined` otherwise.
202
+ */
203
+ export declare function forEach<T extends Record<string, unknown>>(componentValues: Array<ComponentValue>, cb: (entry: {
204
+ node: ComponentValue;
205
+ parent: ContainerNode | {
206
+ value: Array<ComponentValue>;
207
+ };
208
+ state?: T;
209
+ }, index: number | string) => boolean | void, state?: T): false | undefined;
210
+
211
+ /**
212
+ * A function node.
213
+ *
214
+ * @example
215
+ * ```js
216
+ * const node = parseComponentValue(tokenize('calc(1 + 1)'));
217
+ *
218
+ * isFunctionNode(node); // true
219
+ * node.getName(); // 'calc'
220
+ * ```
221
+ */
222
+ export declare class FunctionNode extends ContainerNodeBaseClass {
223
+ /**
224
+ * The node type, always `ComponentValueType.Function`
225
+ */
226
+ type: ComponentValueType;
227
+ /**
228
+ * The token for the name of the function.
229
+ */
230
+ name: TokenFunction;
231
+ /**
232
+ * The token for the closing parenthesis of the function.
233
+ * If the function is unclosed, this will be an EOF token.
234
+ */
235
+ endToken: CSSToken;
236
+ constructor(name: TokenFunction, endToken: CSSToken, value: Array<ComponentValue>);
237
+ /**
238
+ * Retrieve the name of the current function.
239
+ * This is the parsed and unescaped name of the function.
240
+ */
241
+ getName(): string;
242
+ /**
243
+ * Normalize the current function:
244
+ * 1. if the "endToken" is EOF, replace with a ")-token"
245
+ */
246
+ normalize(): void;
247
+ /**
248
+ * Retrieve the tokens for the current function.
249
+ * This is the inverse of parsing from a list of tokens.
250
+ */
251
+ tokens(): Array<CSSToken>;
252
+ /**
253
+ * Convert the current function to a string.
254
+ * This is not a true serialization.
255
+ * It is purely a concatenation of the string representation of the tokens.
256
+ */
257
+ toString(): string;
258
+ /**
259
+ * @internal
260
+ *
261
+ * A debug helper to convert the current object to a JSON representation.
262
+ * This is useful in asserts and to store large ASTs in files.
263
+ */
264
+ toJSON(): unknown;
265
+ /**
266
+ * @internal
267
+ */
268
+ isFunctionNode(): this is FunctionNode;
269
+ /**
270
+ * @internal
271
+ */
272
+ static isFunctionNode(x: unknown): x is FunctionNode;
273
+ }
274
+
275
+ /**
276
+ * AST nodes do not have a `parent` property or method.
277
+ * This makes it harder to traverse the AST upwards.
278
+ * This function builds a `Map<Child, Parent>` that can be used to lookup ancestors of a node.
279
+ *
280
+ * @remarks
281
+ * There is no magic behind this or the map it returns.
282
+ * Mutating the AST will not update the map.
283
+ *
284
+ * Types are erased and any content of the map has type `unknown`.
285
+ * If someone knows a clever way to type this, please let us know.
286
+ *
287
+ * @example
288
+ * ```js
289
+ * const ancestry = gatherNodeAncestry(mediaQuery);
290
+ * mediaQuery.walk((entry) => {
291
+ * const node = entry.node; // directly exposed
292
+ * const parent = entry.parent; // directly exposed
293
+ * const grandParent: unknown = ancestry.get(parent); // lookup
294
+ *
295
+ * console.log('node', node);
296
+ * console.log('parent', parent);
297
+ * console.log('grandParent', grandParent);
298
+ * });
299
+ * ```
300
+ */
301
+ export declare function gatherNodeAncestry(node: {
302
+ walk(cb: (entry: {
303
+ node: unknown;
304
+ parent: unknown;
305
+ }, index: number | string) => boolean | void): false | undefined;
306
+ }): Map<unknown, unknown>;
307
+
308
+ /**
309
+ * Check if the current object is a `CommentNode`.
310
+ * This is a type guard.
311
+ */
312
+ export declare function isCommentNode(x: unknown): x is CommentNode;
313
+
314
+ /**
315
+ * Check if the current object is a `FunctionNode`.
316
+ * This is a type guard.
317
+ */
318
+ export declare function isFunctionNode(x: unknown): x is FunctionNode;
319
+
320
+ /**
321
+ * Check if the current object is a `SimpleBlockNode`.
322
+ * This is a type guard.
323
+ */
324
+ export declare function isSimpleBlockNode(x: unknown): x is SimpleBlockNode;
325
+
326
+ /**
327
+ * Check if the current object is a `TokenNode`.
328
+ * This is a type guard.
329
+ */
330
+ export declare function isTokenNode(x: unknown): x is TokenNode;
331
+
332
+ /**
333
+ * Check if the current object is a `WhitespaceNode`.
334
+ * This is a type guard.
335
+ */
336
+ export declare function isWhitespaceNode(x: unknown): x is WhitespaceNode;
337
+
338
+ /**
339
+ * Check if the current object is a `WhiteSpaceNode` or a `CommentNode`.
340
+ * This is a type guard.
341
+ */
342
+ export declare function isWhiteSpaceOrCommentNode(x: unknown): x is WhitespaceNode | CommentNode;
343
+
344
+ /**
345
+ * Parse a comma-separated list of component values.
346
+ *
347
+ * @example
348
+ * ```js
349
+ * import { tokenize } from '@csstools/css-tokenizer';
350
+ * import { parseCommaSeparatedListOfComponentValues } from '@csstools/css-parser-algorithms';
351
+ *
352
+ * parseCommaSeparatedListOfComponentValues(tokenize({ css: `20deg, 50%, 30%` }));
353
+ * ```
354
+ */
355
+ export declare function parseCommaSeparatedListOfComponentValues(tokens: Array<CSSToken>, options?: {
356
+ onParseError?: (error: ParseError) => void;
357
+ }): Array<Array<ComponentValue>>;
358
+
359
+ /**
360
+ * Parse a single component value.
361
+ *
362
+ * @example
363
+ * ```js
364
+ * import { tokenize } from '@csstools/css-tokenizer';
365
+ * import { parseComponentValue } from '@csstools/css-parser-algorithms';
366
+ *
367
+ * parseComponentValue(tokenize({ css: `10px` }));
368
+ * parseComponentValue(tokenize({ css: `calc((10px + 1x) * 4)` }));
369
+ * ```
370
+ */
371
+ export declare function parseComponentValue(tokens: Array<CSSToken>, options?: {
372
+ onParseError?: (error: ParseError) => void;
373
+ }): ComponentValue | undefined;
374
+
375
+ /**
376
+ * Parse a list of component values.
377
+ *
378
+ * @example
379
+ * ```js
380
+ * import { tokenize } from '@csstools/css-tokenizer';
381
+ * import { parseListOfComponentValues } from '@csstools/css-parser-algorithms';
382
+ *
383
+ * parseListOfComponentValues(tokenize({ css: `20deg 30%` }));
384
+ * ```
385
+ */
386
+ export declare function parseListOfComponentValues(tokens: Array<CSSToken>, options?: {
387
+ onParseError?: (error: ParseError) => void;
388
+ }): Array<ComponentValue>;
389
+
390
+ /**
391
+ * Replace specific component values in a list of component values.
392
+ * A helper for the most common and simplistic cases when mutating an AST.
393
+ */
394
+ export declare function replaceComponentValues(componentValuesList: Array<Array<ComponentValue>>, replaceWith: (componentValue: ComponentValue) => Array<ComponentValue> | ComponentValue | void): Array<Array<ComponentValue>>;
395
+
396
+ /**
397
+ * A simple block node.
398
+ *
399
+ * @example
400
+ * ```js
401
+ * const node = parseComponentValue(tokenize('[foo=bar]'));
402
+ *
403
+ * isSimpleBlockNode(node); // true
404
+ * node.startToken; // [TokenType.OpenSquare, '[', 0, 0, undefined]
405
+ * ```
406
+ */
407
+ export declare class SimpleBlockNode extends ContainerNodeBaseClass {
408
+ /**
409
+ * The node type, always `ComponentValueType.SimpleBlock`
410
+ */
411
+ type: ComponentValueType;
412
+ /**
413
+ * The token for the opening token of the block.
414
+ */
415
+ startToken: CSSToken;
416
+ /**
417
+ * The token for the closing token of the block.
418
+ * If the block is closed it will be the mirror variant of the `startToken`.
419
+ * If the block is unclosed, this will be an EOF token.
420
+ */
421
+ endToken: CSSToken;
422
+ constructor(startToken: CSSToken, endToken: CSSToken, value: Array<ComponentValue>);
423
+ /**
424
+ * Normalize the current simple block
425
+ * 1. if the "endToken" is EOF, replace with the mirror token of the "startToken"
426
+ */
427
+ normalize(): void;
428
+ /**
429
+ * Retrieve the tokens for the current simple block.
430
+ * This is the inverse of parsing from a list of tokens.
431
+ */
432
+ tokens(): Array<CSSToken>;
433
+ /**
434
+ * Convert the current simple block to a string.
435
+ * This is not a true serialization.
436
+ * It is purely a concatenation of the string representation of the tokens.
437
+ */
438
+ toString(): string;
439
+ /**
440
+ * @internal
441
+ *
442
+ * A debug helper to convert the current object to a JSON representation.
443
+ * This is useful in asserts and to store large ASTs in files.
444
+ */
445
+ toJSON(): unknown;
446
+ /**
447
+ * @internal
448
+ */
449
+ isSimpleBlockNode(): this is SimpleBlockNode;
450
+ /**
451
+ * @internal
452
+ */
453
+ static isSimpleBlockNode(x: unknown): x is SimpleBlockNode;
454
+ }
455
+
456
+ /**
457
+ * Returns the start and end index of a node in the CSS source string.
458
+ */
459
+ export declare function sourceIndices(x: {
460
+ tokens(): Array<CSSToken>;
461
+ } | Array<{
462
+ tokens(): Array<CSSToken>;
463
+ }>): [number, number];
464
+
465
+ /**
466
+ * Concatenate the string representation of a collection of component values.
467
+ * This is not a proper serializer that will handle escaping and whitespace.
468
+ * It only produces valid CSS for token lists that are also valid.
469
+ */
470
+ export declare function stringify(componentValueLists: Array<Array<ComponentValue>>): string;
471
+
472
+ export declare class TokenNode {
473
+ /**
474
+ * The node type, always `ComponentValueType.Token`
475
+ */
476
+ type: ComponentValueType;
477
+ /**
478
+ * The token.
479
+ */
480
+ value: CSSToken;
481
+ constructor(value: CSSToken);
482
+ /**
483
+ * This is the inverse of parsing from a list of tokens.
484
+ */
485
+ tokens(): [CSSToken];
486
+ /**
487
+ * Convert the current token to a string.
488
+ * This is not a true serialization.
489
+ * It is purely the string representation of token.
490
+ */
491
+ toString(): string;
492
+ /**
493
+ * @internal
494
+ *
495
+ * A debug helper to convert the current object to a JSON representation.
496
+ * This is useful in asserts and to store large ASTs in files.
497
+ */
498
+ toJSON(): Record<string, unknown>;
499
+ /**
500
+ * @internal
501
+ */
502
+ isTokenNode(): this is TokenNode;
503
+ /**
504
+ * @internal
505
+ */
506
+ static isTokenNode(x: unknown): x is TokenNode;
507
+ }
508
+
509
+ /**
510
+ * Walks each item in a list of component values all of their children.
511
+ *
512
+ * @param cb - The callback function to execute for each item.
513
+ * The function receives an object containing the current node (`node`), its parent (`parent`),
514
+ * and an optional `state` object.
515
+ * A second parameter is the index of the current node.
516
+ * The function can return `false` to stop the iteration.
517
+ *
518
+ * @param state - An optional state object that can be used to pass additional information to the callback function.
519
+ * The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.
520
+ * However changes are passed down to child node iterations.
521
+ *
522
+ * @returns `false` if the iteration was halted, `undefined` otherwise.
523
+ *
524
+ * @example
525
+ * ```js
526
+ * import { tokenize } from '@csstools/css-tokenizer';
527
+ * import { parseListOfComponentValues, isSimpleBlockNode } from '@csstools/css-parser-algorithms';
528
+ *
529
+ * const myCSS = `calc(1px * (5 / 2)) 10px`;
530
+ *
531
+ * const componentValues = parseListOfComponentValues(tokenize({ css: myCSS }));
532
+ *
533
+ * let state = { inSimpleBlock: false };
534
+ * walk(componentValues, (entry) => {
535
+ * if (isSimpleBlockNode(entry)) {
536
+ * entry.state.inSimpleBlock = true;
537
+ * return;
538
+ * }
539
+ *
540
+ * if (entry.state.inSimpleBlock) {
541
+ * console.log(entry.node.toString()); // `5`, ...
542
+ * }
543
+ * }, state);
544
+ * ```
545
+ */
546
+ export declare function walk<T extends Record<string, unknown>>(componentValues: Array<ComponentValue>, cb: (entry: {
547
+ node: ComponentValue;
548
+ parent: ContainerNode | {
549
+ value: Array<ComponentValue>;
550
+ };
551
+ state?: T;
552
+ }, index: number | string) => boolean | void, state?: T): false | undefined;
553
+
554
+ /**
555
+ * Generate a function that finds the next element that should be visited when walking an AST.
556
+ * Rules :
557
+ * 1. the previous iteration is used as a reference, so any checks are relative to the start of the current iteration.
558
+ * 2. the next element always appears after the current index.
559
+ * 3. the next element always exists in the list.
560
+ * 4. replacing an element does not cause the replaced element to be visited.
561
+ * 5. removing an element does not cause elements to be skipped.
562
+ * 6. an element added later in the list will be visited.
563
+ */
564
+ export declare function walkerIndexGenerator<T>(initialList: Array<T>): (list: Array<T>, child: T, index: number) => number;
565
+
566
+ export declare class WhitespaceNode {
567
+ /**
568
+ * The node type, always `ComponentValueType.WhiteSpace`
569
+ */
570
+ type: ComponentValueType;
571
+ /**
572
+ * The list of consecutive whitespace tokens.
573
+ */
574
+ value: Array<CSSToken>;
575
+ constructor(value: Array<CSSToken>);
576
+ /**
577
+ * Retrieve the tokens for the current whitespace.
578
+ * This is the inverse of parsing from a list of tokens.
579
+ */
580
+ tokens(): Array<CSSToken>;
581
+ /**
582
+ * Convert the current whitespace to a string.
583
+ * This is not a true serialization.
584
+ * It is purely a concatenation of the string representation of the tokens.
585
+ */
586
+ toString(): string;
587
+ /**
588
+ * @internal
589
+ *
590
+ * A debug helper to convert the current object to a JSON representation.
591
+ * This is useful in asserts and to store large ASTs in files.
592
+ */
593
+ toJSON(): Record<string, unknown>;
594
+ /**
595
+ * @internal
596
+ */
597
+ isWhitespaceNode(): this is WhitespaceNode;
598
+ /**
599
+ * @internal
600
+ */
601
+ static isWhitespaceNode(x: unknown): x is WhitespaceNode;
602
+ }
603
+
604
+ export { }
node_modules/@csstools/css-parser-algorithms/dist/index.mjs ADDED
@@ -0,0 +1 @@
 
 
1
+ import{isTokenEOF as e,TokenType as n,isToken as t,stringify as o,mirrorVariant as s,isTokenOpenParen as i,isTokenOpenCurly as r,isTokenOpenSquare as a,isTokenFunction as c,isTokenWhitespace as u,isTokenComment as l,mirrorVariantType as d,ParseError as h,isTokenWhiteSpaceOrComment as p,isTokenCloseParen as m,isTokenComma as k}from"@csstools/css-tokenizer";var f;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(e,n){const t=n[0];if(i(t)||r(t)||a(t)){const t=consumeSimpleBlock(e,n);return{advance:t.advance,node:t.node}}if(c(t)){const t=consumeFunction(e,n);return{advance:t.advance,node:t.node}}if(u(t)){const t=consumeWhitespace(e,n);return{advance:t.advance,node:t.node}}if(l(t)){const t=consumeComment(e,n);return{advance:t.advance,node:t.node}}return{advance:1,node:new TokenNode(t)}}!function(e){e.Function="function",e.SimpleBlock="simple-block",e.Whitespace="whitespace",e.Comment="comment",e.Token="token"}(f||(f={}));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=f.Function;name;endToken;constructor(e,n,t){super(),this.name=e,this.endToken=n,this.value=t}getName(){return this.name[4].value}normalize(){e(this.endToken)&&(this.endToken=[n.CloseParen,")",-1,-1,void 0])}tokens(){return e(this.endToken)?[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=>t(e)?o(e):e.toString()).join("");return o(this.name)+e+o(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===f.Function)}}function consumeFunction(n,t){const o=[];let s=1;for(;;){const i=t[s];if(!i||e(i))return n.onParseError(new h("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],i,o)};if(m(i))return{advance:s+1,node:new FunctionNode(t[0],i,o)};if(p(i)){const e=consumeAllCommentsAndWhitespace(n,t.slice(s));s+=e.advance,o.push(...e.nodes);continue}const r=consumeComponentValue(n,t.slice(s));s+=r.advance,o.push(r.node)}}class SimpleBlockNode extends ContainerNodeBaseClass{type=f.SimpleBlock;startToken;endToken;constructor(e,n,t){super(),this.startToken=e,this.endToken=n,this.value=t}normalize(){if(e(this.endToken)){const e=s(this.startToken);e&&(this.endToken=e)}}tokens(){return e(this.endToken)?[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=>t(e)?o(e):e.toString()).join("");return o(this.startToken)+e+o(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===f.SimpleBlock)}}function consumeSimpleBlock(n,t){const o=d(t[0][0]);if(!o)throw new Error("Failed to parse, a mirror variant must exist for all block open tokens.");const s=[];let i=1;for(;;){const r=t[i];if(!r||e(r))return n.onParseError(new h("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],r,s)};if(r[0]===o)return{advance:i+1,node:new SimpleBlockNode(t[0],r,s)};if(p(r)){const e=consumeAllCommentsAndWhitespace(n,t.slice(i));i+=e.advance,s.push(...e.nodes);continue}const a=consumeComponentValue(n,t.slice(i));i+=a.advance,s.push(a.node)}}class WhitespaceNode{type=f.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return o(...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===f.Whitespace)}}function consumeWhitespace(e,n){let t=0;for(;;){const e=n[t];if(!u(e))return{advance:t,node:new WhitespaceNode(n.slice(0,t))};t++}}class CommentNode{type=f.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return o(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===f.Comment)}}function consumeComment(e,n){return{advance:1,node:new CommentNode(n[0])}}function consumeAllCommentsAndWhitespace(e,n){const t=[];let o=0;for(;;){if(u(n[o])){const e=consumeWhitespace(0,n.slice(o));o+=e.advance,t.push(e.node);continue}if(!l(n[o]))return{advance:o,nodes:t};t.push(new CommentNode(n[o])),o++}}class TokenNode{type=f.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===f.Token)}}function parseComponentValue(t,o){const s={onParseError:o?.onParseError??(()=>{})},i=[...t];e(i[i.length-1])||i.push([n.EOF,"",i[i.length-1][2],i[i.length-1][3],void 0]);const r=consumeComponentValue(s,i);if(e(i[Math.min(r.advance,i.length-1)]))return r.node;s.onParseError(new h("Expected EOF after parsing a component value.",t[0][2],t[t.length-1][3],["5.3.9. Parse a component value","Expected EOF"]))}function parseListOfComponentValues(t,o){const s={onParseError:o?.onParseError??(()=>{})},i=[...t];e(i[i.length-1])&&i.push([n.EOF,"",i[i.length-1][2],i[i.length-1][3],void 0]);const r=[];let a=0;for(;;){if(!i[a]||e(i[a]))return r;const n=consumeComponentValue(s,i.slice(a));r.push(n.node),a+=n.advance}}function parseCommaSeparatedListOfComponentValues(t,o){const s={onParseError:o?.onParseError??(()=>{})},i=[...t];if(0===t.length)return[];e(i[i.length-1])&&i.push([n.EOF,"",i[i.length-1][2],i[i.length-1][3],void 0]);const r=[];let a=[],c=0;for(;;){if(!i[c]||e(i[c]))return a.length&&r.push(a),r;if(k(i[c])){r.push(a),a=[],c++;continue}const n=consumeComponentValue(s,t.slice(c));a.push(n.node),c+=n.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&&(Array.isArray(o)?e.parent.value.splice(t,1,...o):e.parent.value.splice(t,1,o))})}return e}function stringify(e){return e.map(e=>e.map(e=>o(...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 isWhiteSpaceOrCommentNode(e){return isWhitespaceNode(e)||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,f as ComponentValueType,ContainerNodeBaseClass,FunctionNode,SimpleBlockNode,TokenNode,WhitespaceNode,forEach,gatherNodeAncestry,isCommentNode,isFunctionNode,isSimpleBlockNode,isTokenNode,isWhiteSpaceOrCommentNode,isWhitespaceNode,parseCommaSeparatedListOfComponentValues,parseComponentValue,parseListOfComponentValues,replaceComponentValues,sourceIndices,stringify,walk,walkerIndexGenerator};
node_modules/@csstools/css-parser-algorithms/package.json ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-parser-algorithms",
3
+ "description": "Algorithms to help you parse CSS from an array of tokens.",
4
+ "version": "4.0.0",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "engines": {
28
+ "node": ">=20.19.0"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.mjs"
35
+ }
36
+ },
37
+ "files": [
38
+ "CHANGELOG.md",
39
+ "LICENSE.md",
40
+ "README.md",
41
+ "dist"
42
+ ],
43
+ "peerDependencies": {
44
+ "@csstools/css-tokenizer": "^4.0.0"
45
+ },
46
+ "scripts": {},
47
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms#readme",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
51
+ "directory": "packages/css-parser-algorithms"
52
+ },
53
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
54
+ "keywords": [
55
+ "css",
56
+ "parser"
57
+ ]
58
+ }
node_modules/@csstools/css-syntax-patches-for-csstree/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changes to CSS Syntax Patches For CSSTree
2
+
3
+ ### 1.1.5
4
+
5
+ _June 3, 2026_
6
+
7
+ - Update `@webref/css` to [`v8.5.7`](https://github.com/w3c/webref/releases/tag/%40webref%2Fcss%408.5.7)
8
+ - Patch `@position-try` and `@page`
9
+
10
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-syntax-patches-for-csstree/CHANGELOG.md)
node_modules/@csstools/css-syntax-patches-for-csstree/LICENSE.md ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT No Attribution (MIT-0)
2
+
3
+ Copyright © CSSTools Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the “Software”), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so.
11
+
12
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
node_modules/@csstools/css-syntax-patches-for-csstree/README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Syntax Patches For CSSTree <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-syntax-patches-for-csstree.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+
6
+ Patch [csstree](https://github.com/csstree/csstree) syntax definitions with the latest data from CSS specifications.
7
+
8
+ ## Usage
9
+
10
+ ```bash
11
+ npm install @csstools/css-syntax-patches-for-csstree
12
+ ```
13
+
14
+ ```js
15
+ import { fork } from 'css-tree';
16
+ import syntax_patches from '@csstools/css-syntax-patches-for-csstree' with { type: 'json' };
17
+
18
+ const forkedLexer = fork({
19
+ atrules: syntax_patches.next.atrules,
20
+ properties: syntax_patches.next.properties,
21
+ types: syntax_patches.next.types,
22
+ }).lexer;
23
+ ```
24
+
25
+ ## `next`
26
+
27
+ ```js
28
+ import syntax_patches from '@csstools/css-syntax-patches-for-csstree' with { type: 'json' };
29
+
30
+ console.log(syntax_patches.next);
31
+ // ^^^^
32
+ ```
33
+
34
+ CSS specifications are often still in flux and various parts might change or disappear altogether.
35
+ Specifications also contains parts that haven't been implemented yet in a browser.
36
+ Only CSS that is widely adopted can be expected to be stable.
37
+
38
+ The `next` grouping contains a combination of what is currently valid in browsers and the progress in various specifications.
39
+
40
+ _In the future more groupings might be added._
41
+
42
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
43
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-syntax-patches-for-csstree
node_modules/@csstools/css-syntax-patches-for-csstree/dist/index.d.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export const next: {
2
+ atrules: Record<string, { descriptors: Record<string, string> }>,
3
+ properties: Record<string, string>,
4
+ types: Record<string, string>,
5
+ }
node_modules/@csstools/css-syntax-patches-for-csstree/dist/index.json ADDED
@@ -0,0 +1,794 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "next": {
3
+ "atrules": {
4
+ "color-profile": {
5
+ "descriptors": {
6
+ "components": "<ident>#",
7
+ "rendering-intent": "relative-colorimetric | absolute-colorimetric | perceptual | saturation",
8
+ "src": "<url>"
9
+ }
10
+ },
11
+ "font-face": {
12
+ "descriptors": {
13
+ "ascent-override": "[ normal | <percentage [0,∞]> ]{1,2}",
14
+ "descent-override": "[ normal | <percentage [0,∞]> ]{1,2}",
15
+ "font-family": "<font-family-name>",
16
+ "font-language-override": "normal | <string>",
17
+ "font-named-instance": "auto | <string>",
18
+ "font-size": "auto | [ <number> ]{1,2}",
19
+ "font-style": "auto | normal | italic | left | right | oblique [ <angle [-90deg,90deg]>{1,2} ]?",
20
+ "font-weight": "| auto",
21
+ "font-width": "auto | <'font-width'>{1,2}",
22
+ "line-gap-override": "[ normal | <percentage [0,∞]> ]{1,2}",
23
+ "size-adjust": "<percentage [0,∞]>",
24
+ "src": "<font-src-list>",
25
+ "subscript-position-override": "[ normal | from-font | <percentage> ]{1,2}",
26
+ "subscript-size-override": "[ normal | from-font | <percentage [0,∞]> ]{1,2}",
27
+ "superscript-position-override": "[ normal | from-font | <percentage> ]{1,2}",
28
+ "superscript-size-override": "[ normal | from-font | <percentage [0,∞]> ]{1,2}",
29
+ "unicode-range": "<unicode-range-token>#"
30
+ }
31
+ },
32
+ "font-feature-values": {
33
+ "descriptors": {
34
+ "font-display": "auto | block | swap | fallback | optional"
35
+ }
36
+ },
37
+ "font-palette-values": {
38
+ "descriptors": {
39
+ "font-family": "<font-family-name>#"
40
+ }
41
+ },
42
+ "function": {
43
+ "descriptors": {
44
+ "result": "<declaration-value>?"
45
+ }
46
+ },
47
+ "page": {
48
+ "descriptors": {
49
+ "margin": "<'margin'>",
50
+ "margin-bottom": "<'margin-bottom'>",
51
+ "margin-left": "<'margin-left'>",
52
+ "margin-right": "<'margin-right'>",
53
+ "margin-top": "<'margin-top'>",
54
+ "page-margin-safety": "none | clamp | add"
55
+ }
56
+ },
57
+ "position-try": {
58
+ "descriptors": {
59
+ "position-anchor": "<'position-anchor'>",
60
+ "position-area": "<'position-area'>"
61
+ }
62
+ }
63
+ },
64
+ "properties": {
65
+ "align-self": "auto | <overflow-position>? [ normal | <self-position> ] | stretch | <baseline-position> | anchor-center",
66
+ "alignment-baseline": "auto | before-edge | text-before-edge | after-edge | text-after-edge | baseline | <baseline-metric>",
67
+ "all": " | revert-rule",
68
+ "anchor-name": "none | <anchor-name>#",
69
+ "anchor-scope": "none | all | <anchor-name>#",
70
+ "animation-range-center": "[ normal | [ <length-percentage> | <timeline-range-center-subject> <length-percentage>? ] ]#",
71
+ "appearance": "none | auto | base | base-select | <compat-auto> | <compat-special> | base",
72
+ "background-blend-mode": "<'mix-blend-mode'>#",
73
+ "background-position-block": "[ center | [ [ start | end ]? <length-percentage>? ]! ]#",
74
+ "background-position-inline": "[ center | [ [ start | end ]? <length-percentage>? ]! ]#",
75
+ "background-repeat-block": "<repetition>#",
76
+ "background-repeat-inline": "<repetition>#",
77
+ "background-repeat-x": "<repetition>#",
78
+ "background-repeat-y": "<repetition>#",
79
+ "background-tbd": "<bg-layer>#",
80
+ "baseline-shift": "<length-percentage> | sub | super | top | center | bottom",
81
+ "block-ellipsis": "no-ellipsis | auto | <string>",
82
+ "block-step": "<'block-step-size'> || <'block-step-insert'> || <'block-step-align'> || <'block-step-round'>",
83
+ "block-step-align": "auto | center | start | end",
84
+ "block-step-insert": "margin-box | padding-box | content-box",
85
+ "block-step-round": "up | down | nearest",
86
+ "block-step-size": "none | <length [0,∞]>",
87
+ "bookmark-label": "<content-list>",
88
+ "bookmark-level": "none | <integer [1,∞]>",
89
+ "bookmark-state": "open | closed",
90
+ "border-block-clip": "<'border-top-clip'>",
91
+ "border-block-end": "<line-width> || <line-style> || <color>",
92
+ "border-block-end-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
93
+ "border-block-end-color": "<color> | <image-1D>",
94
+ "border-block-end-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
95
+ "border-block-end-style": "<line-style>",
96
+ "border-block-end-width": "<line-width>",
97
+ "border-block-start": "<line-width> || <line-style> || <color>",
98
+ "border-block-start-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
99
+ "border-block-start-color": "<color> | <image-1D>",
100
+ "border-block-start-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
101
+ "border-block-start-style": "<line-style>",
102
+ "border-block-start-width": "<line-width>",
103
+ "border-bottom-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
104
+ "border-bottom-color": "<color> | <image-1D>",
105
+ "border-bottom-left-radius": "<border-radius>",
106
+ "border-bottom-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
107
+ "border-bottom-right-radius": "<border-radius>",
108
+ "border-boundary": "none | parent | display",
109
+ "border-clip": "<'border-top-clip'>",
110
+ "border-color": "[ <color> | <image-1D> ]{1,4}",
111
+ "border-end-end-radius": "<border-radius>",
112
+ "border-end-start-radius": "<border-radius>",
113
+ "border-inline-clip": "<'border-top-clip'>",
114
+ "border-inline-end": "<line-width> || <line-style> || <color>",
115
+ "border-inline-end-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
116
+ "border-inline-end-color": "<color> | <image-1D>",
117
+ "border-inline-end-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
118
+ "border-inline-end-style": "<line-style>",
119
+ "border-inline-end-width": "<line-width>",
120
+ "border-inline-start": "<line-width> || <line-style> || <color>",
121
+ "border-inline-start-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
122
+ "border-inline-start-color": "<color> | <image-1D>",
123
+ "border-inline-start-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
124
+ "border-inline-start-style": "<line-style>",
125
+ "border-inline-start-width": "<line-width>",
126
+ "border-left-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
127
+ "border-left-color": "<color> | <image-1D>",
128
+ "border-left-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
129
+ "border-limit": "all | [ sides | corners ] <length-percentage [0,∞]>? | [ top | right | bottom | left ] <length-percentage [0,∞]>",
130
+ "border-right-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
131
+ "border-right-color": "<color> | <image-1D>",
132
+ "border-right-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
133
+ "border-shape": "none | [ <basic-shape> <geometry-box>? ]{1,2}",
134
+ "border-spacing": "<length [0,∞]>{1,2}",
135
+ "border-start-end-radius": "<border-radius>",
136
+ "border-start-start-radius": "<border-radius>",
137
+ "border-style": "<'border-top-style'>{1,4}",
138
+ "border-top-clip": "none | [ <length-percentage [0,∞]> | <flex> ]+",
139
+ "border-top-color": "<color> | <image-1D>",
140
+ "border-top-left-radius": "<border-radius>",
141
+ "border-top-radius": "<length-percentage [0,∞]>{1,2} [ / <length-percentage [0,∞]>{1,2} ]?",
142
+ "border-top-right-radius": "<border-radius>",
143
+ "border-width": "<'border-top-width'>{1,4}",
144
+ "box-shadow": "<spread-shadow>#",
145
+ "box-shadow-blur": "<length [0,∞]>#",
146
+ "box-shadow-color": "<color>#",
147
+ "box-shadow-offset": "[ none | <length>{1,2} ]#",
148
+ "box-shadow-position": "[ outset | inset ]#",
149
+ "box-shadow-spread": "<length>#",
150
+ "box-snap": "none | block-start | block-end | center | baseline | last-baseline",
151
+ "caret-color": "auto | <color> [ auto | <color> ]?",
152
+ "clear": "| block-start | block-end | top | bottom | both-inline | both-block",
153
+ "clip": "rect( <top> , <right> , <bottom> , <left> ) | rect( <top> <right> <bottom> <left> ) | auto",
154
+ "color-adjust": "<'print-color-adjust'>",
155
+ "color-interpolation": "auto | sRGB | linearRGB",
156
+ "column-count": "auto | <integer [1,∞]>",
157
+ "column-fill": "| balance-all",
158
+ "column-gap": "normal | <length-percentage [0,∞]> | <line-width>",
159
+ "column-rule": "<gap-rule-list> | <gap-auto-rule-list>",
160
+ "column-rule-break": "none | normal | intersection",
161
+ "column-rule-color": "<line-color-list> | <auto-line-color-list>",
162
+ "column-rule-inset": "<'column-rule-inset-cap'> [ / <'column-rule-inset-junction'> ]?",
163
+ "column-rule-inset-cap": "<inset-value> <inset-value>?",
164
+ "column-rule-inset-cap-end": "<inset-value>",
165
+ "column-rule-inset-cap-start": "<inset-value>",
166
+ "column-rule-inset-end": "<inset-value>",
167
+ "column-rule-inset-junction": "<inset-value> <inset-value>?",
168
+ "column-rule-inset-junction-end": "<inset-value>",
169
+ "column-rule-inset-junction-start": "<inset-value>",
170
+ "column-rule-inset-start": "<inset-value>",
171
+ "column-rule-style": "<line-style-list> | <auto-line-style-list>",
172
+ "column-rule-visibility-items": "all | around | between | normal",
173
+ "column-rule-width": "<line-width-list> | <auto-line-width-list>",
174
+ "column-span": "| <integer [1,∞]> | auto",
175
+ "column-width": "auto | <length [0,∞]> | min-content | max-content | fit-content( <length-percentage> )",
176
+ "contain": "none | strict | content | [ [ size | inline-size ] || layout || style || paint ]",
177
+ "contain-intrinsic-block-size": "auto? [ none | <length [0,∞]> ]",
178
+ "contain-intrinsic-height": "auto? [ none | <length [0,∞]> ]",
179
+ "contain-intrinsic-inline-size": "auto? [ none | <length [0,∞]> ]",
180
+ "contain-intrinsic-size": "[ auto? [ none | <length [0,∞]> ] ]{1,2}",
181
+ "contain-intrinsic-width": "auto? [ none | <length [0,∞]> ]",
182
+ "container-type": "normal | [ [ size | inline-size ] || scroll-state ]",
183
+ "content": "| <element()>",
184
+ "continue": "auto | discard | collapse | -webkit-legacy | overflow | paginate | fragments",
185
+ "copy-into": "none | [ [ <custom-ident> <content-level> ] [, <custom-ident> <content-level> ]* ]?",
186
+ "corner": "<'border-radius'> || <'corner-shape'>",
187
+ "corner-block-end": "<'border-top-radius'> || <'corner-top-shape'>",
188
+ "corner-block-end-shape": "<'corner-top-left-shape'>{1,2}",
189
+ "corner-block-start": "<'border-top-radius'> || <'corner-top-shape'>",
190
+ "corner-block-start-shape": "<'corner-top-left-shape'>{1,2}",
191
+ "corner-bottom": "<'border-top-radius'> || <'corner-top-shape'>",
192
+ "corner-bottom-left": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
193
+ "corner-bottom-right": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
194
+ "corner-bottom-shape": "<'corner-top-left-shape'>{1,2}",
195
+ "corner-end-end": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
196
+ "corner-end-start": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
197
+ "corner-inline-end": "<'border-top-radius'> || <'corner-top-shape'>",
198
+ "corner-inline-end-shape": "<'corner-top-left-shape'>{1,2}",
199
+ "corner-inline-start": "<'border-top-radius'> || <'corner-top-shape'>",
200
+ "corner-inline-start-shape": "<'corner-top-left-shape'>{1,2}",
201
+ "corner-left": "<'border-top-radius'> || <'corner-top-shape'>",
202
+ "corner-left-shape": "<'corner-top-left-shape'>{1,2}",
203
+ "corner-right": "<'border-top-radius'> || <'corner-top-shape'>",
204
+ "corner-right-shape": "<'corner-top-left-shape'>{1,2}",
205
+ "corner-shape": "<'corner-top-left-shape'>{1,4}",
206
+ "corner-start-end": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
207
+ "corner-start-start": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
208
+ "corner-top": "<'border-top-radius'> || <'corner-top-shape'>",
209
+ "corner-top-left": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
210
+ "corner-top-right": "<'border-top-left-radius'> || <'corner-top-left-shape'>",
211
+ "corner-top-shape": "<'corner-top-left-shape'>{1,2}",
212
+ "cursor": "[ <cursor-image> , ]* <cursor-predefined>",
213
+ "cx": "<length-percentage>",
214
+ "cy": "<length-percentage>",
215
+ "display": "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | <-non-standard-display> | grid-lanes | inline-grid-lanes | <display-outside> || [ <display-inside> | math ]",
216
+ "dominant-baseline": "use-script | no-change | reset-size | text-after-edge | text-before-edge | auto | <baseline-metric>",
217
+ "event-trigger": "none | [ <'event-trigger-name'> <'event-trigger-source'> ]#",
218
+ "event-trigger-name": "none | <dashed-ident>#",
219
+ "event-trigger-source": "[ none | <event-trigger-event>+ [ / <event-trigger-event>+ ]? ]#",
220
+ "fill-break": "bounding-box | slice | clone",
221
+ "fill-color": "<color>",
222
+ "fill-image": "<paint>#",
223
+ "fill-opacity": "<'opacity'>",
224
+ "fill-origin": "match-parent | fill-box | stroke-box | content-box | padding-box | border-box",
225
+ "fill-position": "<position>#",
226
+ "fill-repeat": "<repeat-style>#",
227
+ "fill-size": "<bg-size>#",
228
+ "filter": "none | <filter-value-list>",
229
+ "flex-grow": "<number [0,∞]>",
230
+ "flex-line-count": "<integer [1,∞]>",
231
+ "flex-shrink": "<number [0,∞]>",
232
+ "flex-wrap": "nowrap | [ wrap | wrap-reverse ] || balance",
233
+ "float": "| block-start | block-end | snap-block | snap-block( <length> , [ start | end | near ]? ) | snap-inline | snap-inline( <length> , [ left | right | near ]? ) | top | bottom | footnote",
234
+ "float-defer": "<integer> | last | none",
235
+ "float-offset": "<length-percentage>",
236
+ "float-reference": "inline | column | region | page",
237
+ "flow-from": "<custom-ident> | none",
238
+ "flow-into": "none | <custom-ident> [ element | content ]?",
239
+ "flow-tolerance": "normal | <length-percentage [0,∞]> | infinite",
240
+ "font": "[ [ <'font-style'> || <font-variant-css2> || <'font-weight'> || <font-width-css3> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'># ] | <system-font-family-name> | <-non-standard-font>",
241
+ "font-family": "[ <font-family-name> | <generic-font-family> ]#",
242
+ "font-size-adjust": "none | [ ex-height | cap-height | ch-width | ic-width | ic-height ]? [ from-font | <number [0,∞]> ]",
243
+ "font-stretch": "normal | <percentage [0,∞]> | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded",
244
+ "font-style": "normal | italic | left | right | oblique <angle [-90deg,90deg]>?",
245
+ "font-synthesis-style": "auto | none | oblique-only",
246
+ "font-variant": "normal | none | [ [ <common-lig-values> || <discretionary-lig-values> || <historical-lig-values> || <contextual-alt-values> ] || [ small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps ] || [ stylistic( <font-feature-value-name> ) || historical-forms || styleset( <font-feature-value-name># ) || character-variant( <font-feature-value-name># ) || swash( <font-feature-value-name> ) || ornaments( <font-feature-value-name> ) || annotation( <font-feature-value-name> ) ] || [ <numeric-figure-values> || <numeric-spacing-values> || <numeric-fraction-values> || ordinal || slashed-zero ] || [ <east-asian-variant-values> || <east-asian-width-values> || ruby ] || [ sub | super ] || [ text | emoji | unicode ] ]",
247
+ "font-variant-alternates": "normal | [ stylistic( <font-feature-value-name> ) || historical-forms || styleset( <font-feature-value-name># ) || character-variant( <font-feature-value-name># ) || swash( <font-feature-value-name> ) || ornaments( <font-feature-value-name> ) || annotation( <font-feature-value-name> ) ]",
248
+ "font-variation-settings": "normal | [ <opentype-tag> <number> ]#",
249
+ "footnote-display": "block | inline | compact",
250
+ "footnote-policy": "auto | line | block",
251
+ "frame-sizing": "auto | content-width | content-height | content-block-size | content-inline-size",
252
+ "glyph-orientation-vertical": "auto | 0deg | 90deg | 0 | 90",
253
+ "grid-column-gap": "normal | <length-percentage [0,∞]> | <line-width>",
254
+ "grid-gap": "<'row-gap'> <'column-gap'>?",
255
+ "grid-row-gap": "normal | <length-percentage [0,∞]> | <line-width>",
256
+ "height": "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain | <-non-standard-size>",
257
+ "hyphenate-limit-last": "none | always | column | page | spread",
258
+ "hyphenate-limit-lines": "no-limit | <integer>",
259
+ "hyphenate-limit-zone": "<length-percentage>",
260
+ "image-animation": "normal | paused | stopped | running",
261
+ "image-orientation": "from-image | none | [ <angle> || flip ]",
262
+ "image-rendering": "auto | smooth | high-quality | pixelated | crisp-edges | <-non-standard-image-rendering>",
263
+ "initial-letter": "normal | <number [1,∞]> <integer [1,∞]> | <number [1,∞]> && [ drop | raise ]?",
264
+ "initial-letter-align": "[ border-box? [ alphabetic | ideographic | hanging | leading ]? ]!",
265
+ "initial-letter-wrap": "none | first | all | grid | <length-percentage>",
266
+ "inline-sizing": "normal | stretch",
267
+ "input-security": "auto | none",
268
+ "isolation": "<isolation-mode>",
269
+ "justify-self": "auto | <overflow-position>? [ normal | <self-position> | left | right ] | stretch | <baseline-position> | anchor-center",
270
+ "line-clamp": "none | [ <integer [1,∞]> || <'block-ellipsis'> ] -webkit-legacy?",
271
+ "line-fit-edge": "leading | <text-edge>",
272
+ "line-grid": "match-parent | create",
273
+ "line-height": "normal | <number [0,∞]> | <length-percentage [0,∞]>",
274
+ "line-height-step": "<length [0,∞]>",
275
+ "line-padding": "<length>",
276
+ "line-snap": "none | baseline | contain",
277
+ "link-parameters": "none | <param()>#",
278
+ "list-style": "<'list-style-position'> || <'list-style-image'> || <'list-style-type'>",
279
+ "margin-break": "auto | keep | discard",
280
+ "margin-trim": "none | [ block || inline ] | [ block-start || inline-start || block-end || inline-end ]",
281
+ "marker": "none | <marker-ref>",
282
+ "marker-end": "none | <marker-ref>",
283
+ "marker-mid": "none | <marker-ref>",
284
+ "marker-side": "match-self | match-parent",
285
+ "marker-start": "none | <marker-ref>",
286
+ "mask-border-outset": "<'border-image-outset'>",
287
+ "mask-border-repeat": "<'border-image-repeat'>",
288
+ "mask-border-slice": "<'border-image-slice'>",
289
+ "mask-border-source": "<'border-image-source'>",
290
+ "mask-border-width": "<'border-image-width'>",
291
+ "max-height": "none | <length-percentage [0,∞]> | min-content | max-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain | <-non-standard-size>",
292
+ "max-lines": "none | <integer [1,∞]>",
293
+ "max-width": "none | <length-percentage [0,∞]> | min-content | max-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain | <-non-standard-size>",
294
+ "min-height": "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain | <-non-standard-size>",
295
+ "min-intrinsic-sizing": "legacy | zero-if-scroll || zero-if-extrinsic",
296
+ "min-width": "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain | <-non-standard-size>",
297
+ "mix-blend-mode": "<blend-mode> | plus-lighter",
298
+ "object-fit": "fill | none | [ contain | cover ] || scale-down",
299
+ "orphans": "<integer [1,∞]>",
300
+ "outline-color": "auto | <'border-top-color'>",
301
+ "overflow": "<'overflow-block'>{1,2} | <-non-standard-overflow>",
302
+ "overflow-block": "| <-non-standard-overflow>",
303
+ "overflow-clip-margin": "<visual-box> || <length>",
304
+ "overflow-clip-margin-block": "<visual-box> || <length>",
305
+ "overflow-clip-margin-block-end": "<visual-box> || <length>",
306
+ "overflow-clip-margin-block-start": "<visual-box> || <length>",
307
+ "overflow-clip-margin-bottom": "<visual-box> || <length>",
308
+ "overflow-clip-margin-inline": "<visual-box> || <length>",
309
+ "overflow-clip-margin-inline-end": "<visual-box> || <length>",
310
+ "overflow-clip-margin-inline-start": "<visual-box> || <length>",
311
+ "overflow-clip-margin-left": "<visual-box> || <length>",
312
+ "overflow-clip-margin-right": "<visual-box> || <length>",
313
+ "overflow-clip-margin-top": "<visual-box> || <length>",
314
+ "overflow-inline": "| <-non-standard-overflow>",
315
+ "overflow-x": "| <-non-standard-overflow>",
316
+ "overflow-y": "| <-non-standard-overflow>",
317
+ "overscroll-behavior": "[ contain | none | auto | chain ]{1,2}",
318
+ "overscroll-behavior-block": "contain | none | auto | chain",
319
+ "overscroll-behavior-inline": "contain | none | auto | chain",
320
+ "overscroll-behavior-x": "contain | none | auto | chain",
321
+ "overscroll-behavior-y": "contain | none | auto | chain",
322
+ "path-length": "none | @ @ unknown symbol \" number [ 0 , ∞ ] \"",
323
+ "pause-after": "<time [0s,∞]> | none | x-weak | weak | medium | strong | x-strong",
324
+ "pause-before": "<time [0s,∞]> | none | x-weak | weak | medium | strong | x-strong",
325
+ "perspective": "none | <length [0,∞]>",
326
+ "pointer-events": "| bounding-box",
327
+ "pointer-timeline": "[ <'pointer-timeline-name'> <'pointer-timeline-axis'>? ]#",
328
+ "pointer-timeline-axis": "[ block | inline | x | y ]#",
329
+ "pointer-timeline-name": "[ none | <dashed-ident> ]#",
330
+ "position": "| <running()>",
331
+ "position-anchor": "| normal | match-parent",
332
+ "position-try-fallbacks": "none | [ [ <dashed-ident> || <try-tactic> ] | <position-area> ]#",
333
+ "position-visibility": "always | [ anchor-valid || anchor-visible || no-overflow ]",
334
+ "quotes": "| match-parent",
335
+ "r": "<length-percentage>",
336
+ "region-fragment": "auto | break",
337
+ "rest-after": "<time [0s,∞]> | none | x-weak | weak | medium | strong | x-strong",
338
+ "rest-before": "<time [0s,∞]> | none | x-weak | weak | medium | strong | x-strong",
339
+ "row-gap": "normal | <length-percentage [0,∞]> | <line-width>",
340
+ "row-rule": "<gap-rule-list> | <gap-auto-rule-list>",
341
+ "row-rule-break": "none | normal | intersection",
342
+ "row-rule-color": "<line-color-list> | <auto-line-color-list>",
343
+ "row-rule-inset": "<'column-rule-inset-cap'> [ / <'column-rule-inset-junction'> ]?",
344
+ "row-rule-inset-cap": "<inset-value> <inset-value>?",
345
+ "row-rule-inset-cap-end": "<inset-value>",
346
+ "row-rule-inset-cap-start": "<inset-value>",
347
+ "row-rule-inset-end": "<inset-value>",
348
+ "row-rule-inset-junction": "<inset-value> <inset-value>?",
349
+ "row-rule-inset-junction-end": "<inset-value>",
350
+ "row-rule-inset-junction-start": "<inset-value>",
351
+ "row-rule-inset-start": "<inset-value>",
352
+ "row-rule-style": "<line-style-list> | <auto-line-style-list>",
353
+ "row-rule-visibility-items": "all | around | between | normal",
354
+ "row-rule-width": "<line-width-list> | <auto-line-width-list>",
355
+ "ruby-merge": "separate | merge | auto",
356
+ "ruby-overhang": "auto | spaces",
357
+ "rule": "<'column-rule'>",
358
+ "rule-break": "<'column-rule-break'>",
359
+ "rule-color": "<'column-rule-color'>",
360
+ "rule-inset": "<'column-rule-inset'>",
361
+ "rule-inset-cap": "<'column-rule-inset-cap'>",
362
+ "rule-inset-end": "<'column-rule-inset-end'>",
363
+ "rule-inset-junction": "<'column-rule-inset-junction'>",
364
+ "rule-inset-start": "<'column-rule-inset-start'>",
365
+ "rule-overlap": "row-over-column | column-over-row",
366
+ "rule-style": "<'column-rule-style'>",
367
+ "rule-visibility-items": "<'column-rule-visibility-items'>",
368
+ "rule-width": "<'column-rule-width'>",
369
+ "rx": "<length-percentage> | auto",
370
+ "ry": "<length-percentage> | auto",
371
+ "scroll-marker-group": "none | [ [ before | after ] || [ links | tabs ] ]",
372
+ "scroll-padding": "[ auto | <length-percentage [0,∞]> ]{1,4}",
373
+ "scroll-padding-block": "[ auto | <length-percentage [0,∞]> ]{1,2}",
374
+ "scroll-padding-block-end": "auto | <length-percentage [0,∞]>",
375
+ "scroll-padding-block-start": "auto | <length-percentage [0,∞]>",
376
+ "scroll-padding-bottom": "auto | <length-percentage [0,∞]>",
377
+ "scroll-padding-inline": "[ auto | <length-percentage [0,∞]> ]{1,2}",
378
+ "scroll-padding-inline-end": "auto | <length-percentage [0,∞]>",
379
+ "scroll-padding-inline-start": "auto | <length-percentage [0,∞]>",
380
+ "scroll-padding-left": "auto | <length-percentage [0,∞]>",
381
+ "scroll-padding-right": "auto | <length-percentage [0,∞]>",
382
+ "scroll-padding-top": "auto | <length-percentage [0,∞]>",
383
+ "shape-inside": "auto | outside-shape | [ <basic-shape> || shape-box ] | <image> | display",
384
+ "shape-margin": "<length-percentage [0,∞]>",
385
+ "shape-padding": "<length-percentage [0,∞]>",
386
+ "slider-orientation": "auto | left-to-right | right-to-left | top-to-bottom | bottom-to-top",
387
+ "spatial-navigation-action": "auto | focus | scroll",
388
+ "spatial-navigation-contain": "auto | contain",
389
+ "spatial-navigation-function": "normal | grid",
390
+ "string-set": "none | [ <custom-ident> <string>+ ]#",
391
+ "stroke-align": "center | inset | outset",
392
+ "stroke-alignment": "center | inner | outer",
393
+ "stroke-break": "bounding-box | slice | clone",
394
+ "stroke-color": "<color>#",
395
+ "stroke-dash-corner": "none | <length>",
396
+ "stroke-dash-justify": "none | [ stretch | compress ] || [ dashes || gaps ]",
397
+ "stroke-dashadjust": "none | [ stretch | compress ] [ dashes | gaps ]?",
398
+ "stroke-dasharray": "none | [ <length-percentage> | <number> ]+#",
399
+ "stroke-dashcorner": "none | <length>",
400
+ "stroke-dashoffset": "<length-percentage> | <number>",
401
+ "stroke-image": "<paint>#",
402
+ "stroke-linejoin": "[ crop | arcs | miter ] || [ bevel | round | fallback ]",
403
+ "stroke-miterlimit": "<number>",
404
+ "stroke-origin": "match-parent | fill-box | stroke-box | content-box | padding-box | border-box",
405
+ "stroke-position": "<position>#",
406
+ "stroke-repeat": "<repeat-style>#",
407
+ "stroke-size": "<bg-size>#",
408
+ "stroke-width": "[ <length-percentage> | <line-width> | <number> ]#",
409
+ "tab-size": "<number [0,∞]> | <length [0,∞]>",
410
+ "text-align": "| <string> | justify-all",
411
+ "text-align-all": "start | end | left | right | center | <string> | justify | match-parent",
412
+ "text-align-last": "| match-parent",
413
+ "text-combine-upright": "none | all | [ digits <integer [2,4]>? ]",
414
+ "text-decoration-skip": "none | auto",
415
+ "text-decoration-skip-box": "none | all",
416
+ "text-decoration-skip-self": "auto | skip-all | [ skip-underline || skip-overline || skip-line-through ] | no-skip",
417
+ "text-decoration-skip-spaces": "none | all | [ start || end ]",
418
+ "text-decoration-thickness": "auto | from-font | <length-percentage> | <line-width>",
419
+ "text-emphasis-skip": "spaces || punctuation || symbols || narrow",
420
+ "text-fit": "[ none | grow | shrink ] [ consistent | per-line | per-line-all ]? <percentage>?",
421
+ "text-group-align": "none | start | end | left | right | center",
422
+ "text-indent": "[ <length-percentage> ] && hanging? && each-line?",
423
+ "text-justify": "[ auto | none | inter-word | inter-character | ruby ] || no-compress",
424
+ "text-overflow": "[ clip | ellipsis | <string> | fade | fade( [ <length> | <percentage> ] ) ]{1,2}",
425
+ "text-shadow": "none | <shadow>#",
426
+ "text-size-adjust": "auto | none | <percentage [0,∞]>",
427
+ "text-spacing": "none | auto | <spacing-trim> || <autospace>",
428
+ "text-spacing-trim": "<spacing-trim> | auto",
429
+ "text-underline-offset": "auto | <length-percentage>",
430
+ "text-underline-position": "auto | [ from-font | under ] || [ left | right ]",
431
+ "text-wrap-style": "auto | balance | stable | pretty | avoid-orphans",
432
+ "timeline-scope": "| all",
433
+ "timeline-trigger": "none | [ <'timeline-trigger-name'> <'timeline-trigger-source'> <'timeline-trigger-activation-range'> [ / <'timeline-trigger-active-range'> ]? ]#",
434
+ "timeline-trigger-activation-range": "[ <'timeline-trigger-activation-range-start'> <'timeline-trigger-activation-range-end'>? ]#",
435
+ "timeline-trigger-activation-range-end": "[ normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#",
436
+ "timeline-trigger-activation-range-start": "[ normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#",
437
+ "timeline-trigger-active-range": "[ <'timeline-trigger-active-range-start'> <'timeline-trigger-active-range-end'>? ]#",
438
+ "timeline-trigger-active-range-end": "[ auto | normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#",
439
+ "timeline-trigger-active-range-start": "[ auto | normal | <length-percentage> | <timeline-range-name> <length-percentage>? ]#",
440
+ "transform-origin": "[ left | center | right | top | bottom | <length-percentage> ] | [ left | center | right | <length-percentage> ] [ top | center | bottom | <length-percentage> ] <length>? | [ [ center | left | right ] && [ center | top | bottom ] ] <length>?",
441
+ "transition-duration": "<time [0s,∞]>#",
442
+ "user-select": "auto | text | none | contain | all",
443
+ "vertical-align": "[ first | last ] || <'alignment-baseline'> || <'baseline-shift'>",
444
+ "view-transition-group": "normal | contain | nearest | <custom-ident>",
445
+ "view-transition-scope": "none | all",
446
+ "visibility": "visible | hidden | force-hidden | collapse",
447
+ "voice-duration": "auto | <time [0s,∞]>",
448
+ "voice-family": "[ <voice-family-name> | <generic-voice> ]# | preserve",
449
+ "voice-pitch": "<frequency [0Hz,∞]> && absolute | [ [ x-low | low | medium | high | x-high ] || [ <frequency [0Hz,∞]> | <semitones> | <percentage> ] ]",
450
+ "voice-range": "<frequency [0Hz,∞]> && absolute | [ [ x-low | low | medium | high | x-high ] || [ <frequency [0Hz,∞]> | <semitones> | <percentage> ] ]",
451
+ "voice-rate": "[ normal | x-slow | slow | medium | fast | x-fast ] || <percentage [0,∞]>",
452
+ "white-space": "normal | pre | pre-wrap | pre-line | [ <'white-space-collapse'> || <'text-wrap'> || <'white-space-trim'> ]",
453
+ "white-space-collapse": "collapse | discard | preserve | preserve-breaks | preserve-spaces | break-spaces",
454
+ "widows": "<integer [1,∞]>",
455
+ "width": "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content( <length-percentage [0,∞]> ) | <calc-size()> | <anchor-size()> | stretch | fit-content | contain | <-non-standard-size>",
456
+ "window-drag": "none | move",
457
+ "word-break": "| manual",
458
+ "word-space-transform": "none | [ space | ideographic-space ] && auto-phrase?",
459
+ "word-spacing": "normal | <length-percentage>",
460
+ "word-wrap": "| anywhere",
461
+ "wrap-after": "auto | avoid | avoid-line | avoid-flex | line | flex",
462
+ "wrap-before": "auto | avoid | avoid-line | avoid-flex | line | flex",
463
+ "wrap-flow": "auto | both | start | end | minimum | maximum | clear",
464
+ "wrap-inside": "auto | avoid",
465
+ "wrap-through": "wrap | none",
466
+ "x": "<length-percentage>",
467
+ "y": "<length-percentage>",
468
+ "zoom": "normal | reset | <number [0,∞]> | <percentage [0,∞]>"
469
+ },
470
+ "types": {
471
+ "dashed-ident": "<custom-property-name>",
472
+ "unicode-range-token": "<urange>",
473
+ "active-navigation-condition": "<navigation-relation>? [ <route-location> | link-href ]?",
474
+ "alpha()": "alpha( [ from <color> ] [ / [ <alpha-value> | alpha | none ] ]? )",
475
+ "an+b": "odd | even | <integer> | <n-dimension> | '+'? n | -n | <ndashdigit-dimension> | '+'? <ndashdigit-ident> | <dashndashdigit-ident> | <n-dimension> <signed-integer> | '+'? n <signed-integer> | -n <signed-integer> | <ndash-dimension> <signless-integer> | '+'? n- <signless-integer> | -n- <signless-integer> | <n-dimension> [ '+' | '-' ] <signless-integer> | '+'? n [ '+' | '-' ] <signless-integer> | -n [ '+' | '-' ] <signless-integer>",
476
+ "anchored-feature": "fallback : <'position-try-fallbacks'>",
477
+ "anchored-in-parens": "( <anchored-query> ) | ( <anchored-feature> ) | <general-enclosed>",
478
+ "anchored-query": "not <anchored-in-parens> | <anchored-in-parens> [ [ and <anchored-in-parens> ]* | [ or <anchored-in-parens> ]* ] | <anchored-feature>",
479
+ "angle-percentage": "[ <angle> | <percentage> ]",
480
+ "arc-command": "arc <command-end-point> [ [ of <length-percentage>{1,2} ] && <arc-sweep>? && <arc-size>? && [ rotate <angle> ]? ]",
481
+ "arc-size": "large | small",
482
+ "arc-sweep": "cw | ccw",
483
+ "attr-args": "attr( <declaration-value> , <declaration-value>? )",
484
+ "attr-name": "[ [ <ident-token>? '|' ]? <ident-token> ]",
485
+ "auto-line-color-list": "<line-color-or-repeat>#? , <auto-repeat-line-color> , <line-color-or-repeat>#?",
486
+ "auto-line-style-list": "<line-style-or-repeat>#? , <auto-repeat-line-style> , <line-style-or-repeat>#?",
487
+ "auto-line-width-list": "<line-width-or-repeat>#? , <auto-repeat-line-width> , <line-width-or-repeat>#?",
488
+ "auto-repeat": "repeat( [ auto-fill | auto-fit ] , [ <line-names>? <track-size> ]+ <line-names>? )",
489
+ "auto-repeat-line-color": "repeat( auto , [ <color> ]# )",
490
+ "auto-repeat-line-style": "repeat( auto , [ <line-style> ]# )",
491
+ "auto-repeat-line-width": "repeat( auto , [ <line-width> ]# )",
492
+ "base-descriptor": "base-url : stylesheet | document | <url>",
493
+ "baseline-metric": "text-bottom | alphabetic | ideographic | middle | central | mathematical | hanging | text-top",
494
+ "baseline-position": "[ first | last ]? && baseline",
495
+ "basic-shape": "<basic-shape-rect> | <circle()> | <ellipse()> | <polygon()> | <path()> | <shape()>",
496
+ "bg-clip": "<visual-box> | [ border-area || text ]",
497
+ "bg-layer": "<bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <bg-clip> || <visual-box>",
498
+ "bg-position": "<position> | <position-three>",
499
+ "blend-mode": "normal | multiply | screen | overlay | darken | lighten | color-dodge | color-burn | soft-light | hard-light | difference | exclusion | hue | saturation | color | luminosity",
500
+ "border-radius": "<slash-separated-border-radius-syntax> | <legacy-border-radius-syntax>",
501
+ "calc-interpolate()": "calc-interpolate( [ <progress-source> && [ by <easing-function> ]? && <easing-function>? ] , <input-position>{1,2} : <calc-sum> , [ <easing-function>? , <input-position>{1,2} : <calc-sum> ]#? )",
502
+ "calc-keyword": "e | pi | infinity | -infinity | NaN",
503
+ "calc-mix()": "calc-mix( [ <calc-sum> <percentage [0,100]>? ]# )",
504
+ "calc-product": "<calc-value> [ [ '*' | / ] <calc-value> ]*",
505
+ "calc-size-basis": "[ <size-keyword> | <calc-size()> | <calc-sum> ]",
506
+ "calc-size()": "calc-size( [ [ <calc-size-basis> , [ <calc-sum> | size ] ] | [ any , <calc-sum> ] ] )",
507
+ "calc-value": "<number> | <dimension> | <percentage> | <calc-keyword> | ( <calc-sum> )",
508
+ "cf-image": "[ <image> | <color> ] && <percentage [0,100]>?",
509
+ "circle()": "circle( [ <radial-extent> | <length-percentage [0,∞]> ]? [ at <position> ]? )",
510
+ "clamp()": "clamp( [ <calc-sum> | none ] , <calc-sum> , [ <calc-sum> | none ] )",
511
+ "color": "<color-base> | currentColor | <system-color> | <contrast-color()> | <device-cmyk()> | <light-dark-color> | <-non-standard-color>",
512
+ "color-font-tech": "[ color-COLRv0 | color-COLRv1 | color-SVG | color-sbix | color-CBDT ]",
513
+ "color-function": "<rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <lab()> | <lch()> | <oklab()> | <oklch()> | <ictcp()> | <jzazbz()> | <jzczhz()> | <alpha()> | <color()> | <hdr-color()>",
514
+ "color-interpolate()": "color-interpolate( [ <progress-source> && [ by <easing-function> ]? && <easing-function>? && <color-interpolation-method>? ] , <input-position>{1,2} : <color> , [ [ <easing-function> || <color-interpolation-method> ]? , <input-position>{1,2} : <color> ]#? )",
515
+ "color-layers()": "color-layers( [ <blend-mode> , ]? <color># )",
516
+ "color-mix()": "color-mix( <color-interpolation-method>? , [ <color> && <percentage [0,100]>? ]# )",
517
+ "color-stripe": "<color> && [ <length-percentage> | <flex> ]?",
518
+ "color()": "color( [ from <color> ]? [ <custom-params> | [ <predefined-rgb> [ <number> | <percentage> | r | g | b | alpha | none ]{3} [ / [ <alpha-value> | r | g | b | alpha | none ] ]? ] | [ <xyz-space> [ <number> | <percentage> | x | y | z | alpha | none ]{3} [ / [ <alpha-value> | x | y | z | alpha | none ] ]? ] ] )",
519
+ "colorspace-params": "[ <custom-params> | <predefined-rgb-params> | <xyz-params> ]",
520
+ "combinator": "'>' | '+' | '~' | [ '|' '|' ] | [ / <wq-name> / ]",
521
+ "command-end-point": "[ to <position> | by <coordinate-pair> ]",
522
+ "composite-mode": "clear | copy | source-over | destination-over | source-in | destination-in | source-out | destination-out | source-atop | destination-atop | xor | lighter | plus-darker | plus-lighter",
523
+ "container-condition": "[ <container-name>? <container-query>? ]!",
524
+ "content-level": "element | content | text | <attr()> | <counter>",
525
+ "content-list": "[ <string> | contents | <image> | <counter> | <quote> | <target> | <leader()> | <attr()> | <string()> | <content()> ]+",
526
+ "content()": "content( [ text | before | after | first-letter | marker ]? )",
527
+ "contrast-color()": "contrast-color( <color> )",
528
+ "control-point": "[ <position> | <relative-control-point> ]",
529
+ "control-value()": "control-value( <type>? )",
530
+ "coord-box": "<paint-box> | view-box",
531
+ "coordinate-pair": "<length-percentage>{2}",
532
+ "counter-style": "<counter-style-name> | <symbols()>",
533
+ "cross-fade()": "cross-fade( <cf-image># )",
534
+ "cross-origin-modifier": "cross-origin( anonymous | use-credentials )",
535
+ "css-type": "<syntax-component> | <type()>",
536
+ "cubic-bezier-easing-function": "ease | ease-in | ease-out | ease-in-out | <cubic-bezier()>",
537
+ "cursor-image": "[ <url> | <url-set> ] <number>{2}?",
538
+ "curve-command": "curve [ [ to <position> with <control-point> [ / <control-point> ]? ] | [ by <coordinate-pair> with <relative-control-point> [ / <relative-control-point> ]? ] ]",
539
+ "custom-arg": "'$' <ident-token>",
540
+ "default-value": "<declaration-value>",
541
+ "deprecated-color": "ActiveBorder | ActiveCaption | AppWorkspace | Background | ButtonHighlight | ButtonShadow | CaptionText | InactiveBorder | InactiveCaption | InactiveCaptionText | InfoBackground | InfoText | Menu | MenuText | Scrollbar | ThreeDDarkShadow | ThreeDFace | ThreeDHighlight | ThreeDLightShadow | ThreeDShadow | Window | WindowFrame | WindowText",
542
+ "element()": "element( <id-selector> )",
543
+ "env-args": "env( <declaration-value> , <declaration-value>? )",
544
+ "env()": "env( <custom-ident> <integer [0,∞]>* , <declaration-value>? )",
545
+ "event-trigger-event": "activate | interest | click | touch | dblclick | keypress( <string> ) | . . .",
546
+ "fade()": "fade( [ <length-percentage> ] )",
547
+ "feature-tag-value": "<opentype-tag> [ <integer [0,∞]> | on | off ]?",
548
+ "filter()": "filter( [ <image> | <string> ] , <filter-value-list> )",
549
+ "final-bg-layer": "<bg-image> || <bg-position> [ / <bg-size> ]? || <repeat-style> || <attachment> || <bg-clip> || <visual-box> || <'background-color'>",
550
+ "first-valid()": "first-valid( <declaration-value># )",
551
+ "fit-content()": "fit-content( <length-percentage> )",
552
+ "fixed-breadth": "<length-percentage [0,∞]>",
553
+ "font-family-name": "<string> | <custom-ident>+",
554
+ "font-feature-index": "<integer>",
555
+ "font-feature-value-name": "<ident>",
556
+ "font-features-tech": "[ features-opentype | features-aat | features-graphite ]",
557
+ "font-format": "[ <string> | collection | embedded-opentype | opentype | svg | truetype | woff | woff2 ]",
558
+ "font-src": "<url> [ format( <font-format> ) ]? [ tech( <font-tech># ) ]? | local( <font-family-name> )",
559
+ "font-src-list": "[ <url> [ format( <font-format> ) ]? [ tech( <font-tech># ) ]? | local( <family-name> ) ]#",
560
+ "font-tech": "[ <font-features-tech> | <color-font-tech> | variations | palettes | incremental ]",
561
+ "font-weight-absolute": "[ normal | bold | <number [1,1000]> ]",
562
+ "frequency-percentage": "[ <frequency> | <percentage> ]",
563
+ "function-parameter": "<custom-property-name> <css-type>? [ : <default-value> ]?",
564
+ "gap-auto-repeat-rule": "repeat( auto , <gap-rule># )",
565
+ "gap-auto-rule-list": "<gap-rule-or-repeat>#? , <gap-auto-repeat-rule> , <gap-rule-or-repeat>#?",
566
+ "gap-repeat-rule": "repeat( <integer [1,∞]> , <gap-rule># )",
567
+ "gap-rule": "<line-width> || <line-style> || <color>",
568
+ "gap-rule-list": "<gap-rule-or-repeat>#",
569
+ "gap-rule-or-repeat": "<gap-rule> | <gap-repeat-rule>",
570
+ "generic-font-complete": "serif | sans-serif | system-ui | cursive | fantasy | math | monospace",
571
+ "generic-font-family": "<generic-font-script-specific> | <generic-font-complete> | <generic-font-incomplete> | <-non-standard-generic-family>",
572
+ "generic-font-incomplete": "ui-serif | ui-sans-serif | ui-monospace | ui-rounded",
573
+ "generic-font-script-specific": "generic( fangsong ) | generic( kai ) | generic( khmer-mul ) | generic( nastaliq )",
574
+ "generic-voice": "<age>? <gender> <integer>?",
575
+ "gradient": "[ <linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()> | <conic-gradient()> | <repeating-conic-gradient()> | <-legacy-gradient> ]",
576
+ "grid-line": "auto | <custom-ident> | [ [ <integer [-∞,-1]> | <integer [1,∞]> ] && <custom-ident>? ] | [ span && [ <integer [1,∞]> || <custom-ident> ] ]",
577
+ "hdr-color()": "color-hdr( [ <color> && <number [0,∞]>? ]#{2} )",
578
+ "horizontal-line-command": "hline [ to [ <length-percentage> | left | center | right | x-start | x-end ] | by <length-percentage> ]",
579
+ "hsl()": "[ <legacy-hsl-syntax> | <modern-hsl-syntax> ]",
580
+ "hsla()": "[ <legacy-hsla-syntax> | <modern-hsla-syntax> ]",
581
+ "hwb()": "hwb( [ from <color> ]? [ <hue> | h | w | b | alpha | none ] [ <percentage> | <number> | h | w | b | alpha | none ] [ <percentage> | <number> | h | w | b | alpha | none ] [ / [ <alpha-value> | h | w | b | alpha | none ] ]? )",
582
+ "ictcp()": "ictcp( [ from <color> ]? [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )",
583
+ "ident-arg": "<string> | <integer> | <ident>",
584
+ "ident()": "ident( <ident-arg>+ )",
585
+ "if-args": "if( [ <if-args-branch> ; ]* <if-args-branch> ;? )",
586
+ "if-args-branch": "<declaration-value> : <declaration-value>?",
587
+ "if-branch": "<if-condition> : <declaration-value>?",
588
+ "if-condition": "<boolean-expr[<if-test>]> | else",
589
+ "if-test": "supports( [ <ident> : <declaration-value> ] | <supports-condition> ) | media( <media-feature> | <media-condition> ) | style( <style-query> )",
590
+ "if()": "if( [ <if-branch> ; ]* <if-branch> ;? )",
591
+ "image": "<url> | <image()> | <image-set()> | <element()> | <paint()> | <cross-fade()> | <gradient> | <light-dark-image>",
592
+ "image-1D": "<stripes()>",
593
+ "image-set-option": "[ <image> | <string> ] [ <resolution> || type( <string> ) ]?",
594
+ "image-src": "[ <url> | <string> ]",
595
+ "image-tags": "[ ltr | rtl ]",
596
+ "import-conditions": "[ supports( [ <supports-condition> | <declaration> ] ) ]? <media-query-list>?",
597
+ "inflexible-breadth": "<length-percentage [0,∞]> | min-content | max-content | auto",
598
+ "inherit-args": "inherit( <declaration-value> , <declaration-value>? )",
599
+ "inherit()": "inherit( <custom-property-name> , <declaration-value>? )",
600
+ "init-descriptor": "<init-descriptor-name> : <string>",
601
+ "init-descriptor-name": "protocol | hostname | port | pathname | search | hash",
602
+ "input-position": "<percentage> | <number> | <dimension>",
603
+ "inset-value": "<length-percentage> | overlap-join",
604
+ "integrity-modifier": "integrity( <string> )",
605
+ "interpolate()": "interpolate( [ <progress-source> && [ by <easing-function> ]? && <easing-function>? ] , <input-position>{1,2} : <whole-value> , [ <easing-function>? , <input-position>{1,2} : <whole-value> ]#? ) | interpolate( <progress-source> && [ by <easing-function> ]? && <easing-function>? of <keyframes-name> )",
606
+ "isolation-mode": "auto | isolate",
607
+ "jzazbz()": "jzazbz( [ from <color> ]? [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ / [ <alpha-value> | none ] ]? )",
608
+ "jzczhz()": "jzczhz( [ from <color> ]? [ <percentage> | <number> | none ] [ <percentage> | <number> | none ] [ <hue> | none ] [ / [ <alpha-value> | none ] ]? )",
609
+ "lab()": "lab( [ from <color> ]? [ <percentage> | <number> | l | a | b | alpha | none ] [ <percentage> | <number> | l | a | b | alpha | none ] [ <percentage> | <number> | l | a | b | alpha | none ] [ / [ <alpha-value> | l | a | b | alpha | none ] ]? )",
610
+ "layout-box": "<visual-box> | margin-box",
611
+ "lch()": "lch( [ from <color> ]? [ <percentage> | <number> | l | c | h | alpha | none ] [ <percentage> | <number> | l | c | h | alpha | none ] [ <hue> | l | c | h | alpha | none ] [ / [ <alpha-value> | l | c | h | alpha | none ] ]? )",
612
+ "legacy-border-radius-syntax": "<length-percentage [0,∞]>{1,2}",
613
+ "legacy-hsl-syntax": "hsl( <hue> , <percentage> , <percentage> , <alpha-value>? )",
614
+ "legacy-hsla-syntax": "hsla( <hue> , <percentage> , <percentage> , <alpha-value>? )",
615
+ "legacy-pseudo-element-selector": ": [ before | after | first-line | first-letter ]",
616
+ "legacy-rgb-syntax": "rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )",
617
+ "legacy-rgba-syntax": "rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )",
618
+ "length-percentage": "[ <length> | <percentage> ]",
619
+ "light-dark-color": "light-dark( <color> , <color> )",
620
+ "light-dark-image": "light-dark( [ <image> | none ] , [ <image> | none ] )",
621
+ "light-dark()": "<light-dark-color> | <light-dark-image>",
622
+ "line-color-list": "<line-color-or-repeat>#",
623
+ "line-color-or-repeat": "[ <color> | <repeat-line-color> ]",
624
+ "line-command": "line <command-end-point>",
625
+ "line-style-list": "<line-style-or-repeat>#",
626
+ "line-style-or-repeat": "[ <line-style> | <repeat-line-style> ]",
627
+ "line-width": "<length [0,∞]> | hairline | thin | medium | thick",
628
+ "line-width-list": "<line-width-or-repeat>#",
629
+ "line-width-or-repeat": "[ <line-width> | <repeat-line-width> ]",
630
+ "marker-ref": "<url>",
631
+ "media-and": "and <media-in-parens>",
632
+ "media-condition": "<media-not> | <media-in-parens> [ <media-and>* | <media-or>* ]",
633
+ "media-condition-without-or": "<media-not> | <media-in-parens> <media-and>*",
634
+ "media-feature": "[ <mf-plain> | <mf-boolean> | <mf-range> ]",
635
+ "media-import-condition": "<media-query-list>",
636
+ "media-in-parens": "( <media-condition> ) | ( <media-feature> ) | <general-enclosed>",
637
+ "media-or": "or <media-in-parens>",
638
+ "media()": "media( [ <mf-plain> | <mf-boolean> | <mf-range> ] )",
639
+ "mf-comparison": "<mf-lt> | <mf-gt> | <mf-eq>",
640
+ "mf-eq": "'='",
641
+ "mf-gt": "'>' '='?",
642
+ "mf-lt": "'<' '='?",
643
+ "mf-range": "<mf-name> <mf-comparison> <mf-value> | <mf-value> <mf-comparison> <mf-name> | <mf-value> <mf-lt> <mf-name> <mf-lt> <mf-value> | <mf-value> <mf-gt> <mf-name> <mf-gt> <mf-value>",
644
+ "modern-hsl-syntax": "hsl( [ from <color> ]? [ <hue> | h | s | l | alpha | none ] [ <percentage> | <number> | h | s | l | alpha | none ] [ <percentage> | <number> | h | s | l | alpha | none ] [ / [ <alpha-value> | h | s | l | alpha | none ] ]? )",
645
+ "modern-hsla-syntax": "hsla( [ from <color> ]? [ <hue> | h | s | l | alpha | none ] [ <percentage> | <number> | h | s | l | alpha | none ] [ <percentage> | <number> | h | s | l | alpha | none ] [ / [ <alpha-value> | h | s | l | alpha | none ] ]? )",
646
+ "modern-rgb-syntax": "rgb( [ from <color> ]? [ <number> | <percentage> | r | g | b | alpha | none ]{3} [ / [ <alpha-value> | r | g | b | alpha | none ] ]? )",
647
+ "modern-rgba-syntax": "rgba( [ from <color> ]? [ <number> | <percentage> | r | g | b | alpha | none ]{3} [ / [ <alpha-value> | r | g | b | alpha | none ] ]? )",
648
+ "move-command": "move <command-end-point>",
649
+ "mq-boolean": "<integer [0,1]>",
650
+ "named-color": "| transparent",
651
+ "navigation-condition": "not <navigation-in-parens> | <navigation-in-parens> [ and <navigation-in-parens> ]* | <navigation-in-parens> [ or <navigation-in-parens> ]*",
652
+ "navigation-in-parens": "( <navigation-condition> ) | ( <navigation-test> ) | <general-enclosed>",
653
+ "navigation-location-between-test": "between : <route-location> and <route-location>",
654
+ "navigation-location-keyword": "at | with | from | to",
655
+ "navigation-location-test": "<navigation-location-keyword> : <route-location>",
656
+ "navigation-phase-keyword": "loading | ready | committed",
657
+ "navigation-phase-test": "phase : <navigation-phase-keyword>",
658
+ "navigation-relation": "at | with | from | to",
659
+ "navigation-test": "<navigation-location-test> | <navigation-location-between-test> | <navigation-type-test> | <navigation-phase-test>",
660
+ "navigation-type-keyword": "traverse | back | forward | reload",
661
+ "navigation-type-test": "history : <navigation-type-keyword>",
662
+ "number-optional-number": "<number> <number>?",
663
+ "oklab()": "oklab( [ from <color> ]? [ <percentage> | <number> | l | a | b | alpha | none ] [ <percentage> | <number> | l | a | b | alpha | none ] [ <percentage> | <number> | l | a | b | alpha | none ] [ / [ <alpha-value> | l | a | b | alpha | none ] ]? )",
664
+ "oklch()": "oklch( [ from <color> ]? [ <percentage> | <number> | l | c | h | alpha | none ] [ <percentage> | <number> | l | c | h | alpha | none ] [ <hue> | l | c | h | alpha | none ] [ / [ <alpha-value> | l | c | h | alpha | none ] ]? )",
665
+ "opentype-tag": "<string>",
666
+ "outline-line-style": "| auto",
667
+ "page-selector": "[ <ident-token>? <pseudo-page>* ]!",
668
+ "page-selector-list": "<page-selector>#",
669
+ "paint": "none | <color> | <url> [ none | <color> ]? | context-fill | context-stroke | <image> | <svg-paint>",
670
+ "param()": "param( <dashed-ident> , <declaration-value>? )",
671
+ "pattern-descriptor": "pattern : <url-pattern()>",
672
+ "pointer-axis": "block | inline | x | y",
673
+ "pointer-source": "root | nearest | self",
674
+ "pointer()": "pointer( [ <pointer-source> || <pointer-axis> ]? )",
675
+ "points": "[ <number>+ ]#",
676
+ "polygon()": "polygon( <'fill-rule'>? [ round <length> ]? , [ <length-percentage> <length-percentage> ]# )",
677
+ "position": "<position-one> | <position-two> | <position-four>",
678
+ "position-area": "[ [ left | center | right | span-left | span-right | x-start | x-end | span-x-start | span-x-end | self-x-start | self-x-end | span-self-x-start | span-self-x-end | span-all ] || [ top | center | bottom | span-top | span-bottom | y-start | y-end | span-y-start | span-y-end | self-y-start | self-y-end | span-self-y-start | span-self-y-end | span-all ] | [ block-start | center | block-end | span-block-start | span-block-end | span-all ] || [ inline-start | center | inline-end | span-inline-start | span-inline-end | span-all ] | [ self-block-start | center | self-block-end | span-self-block-start | span-self-block-end | span-all ] || [ self-inline-start | center | self-inline-end | span-self-inline-start | span-self-inline-end | span-all ] | [ start | center | end | span-start | span-end | span-all ]{1,2} | [ self-start | center | self-end | span-self-start | span-self-end | span-all ]{1,2} ]",
679
+ "position-area-query": "[ [ left | center | right | span-left | span-right | x-start | x-end | span-x-start | span-x-end | self-x-start | self-x-end | span-self-x-start | span-self-x-end | span-all | any ] || [ top | center | bottom | span-top | span-bottom | y-start | y-end | span-y-start | span-y-end | self-y-start | self-y-end | span-self-y-start | span-self-y-end | span-all | any ] | [ block-start | center | block-end | span-block-start | span-block-end | span-all | any ] || [ inline-start | center | inline-end | span-inline-start | span-inline-end | span-all | any ] | [ self-block-start | center | self-block-end | span-self-block-start | span-self-block-end | span-all | any ] || [ self-inline-start | center | self-inline-end | span-self-inline-start | span-self-inline-end | span-all | any ] | [ start | center | end | span-start | span-end | span-all | any ]{1,2} | [ self-start | center | self-end | span-self-start | span-self-end | span-all | any ]{1,2} ]",
680
+ "position-four": "[ [ [ left | right | x-start | x-end ] <length-percentage> ] && [ [ top | bottom | y-start | y-end ] <length-percentage> ] | [ [ block-start | block-end ] <length-percentage> ] && [ [ inline-start | inline-end ] <length-percentage> ] | [ [ start | end ] <length-percentage> ]{2} ]",
681
+ "position-one": "[ left | center | right | top | bottom | x-start | x-end | y-start | y-end | block-start | block-end | inline-start | inline-end | <length-percentage> ]",
682
+ "position-three": "[ [ left | center | right ] && [ [ top | bottom ] <length-percentage> ] | [ [ left | right ] <length-percentage> ] && [ top | center | bottom ] ]",
683
+ "position-two": "[ [ left | center | right | x-start | x-end ] && [ top | center | bottom | y-start | y-end ] | [ left | center | right | x-start | x-end | <length-percentage> ] [ top | center | bottom | y-start | y-end | <length-percentage> ] | [ block-start | center | block-end ] && [ inline-start | center | inline-end ] | [ start | center | end ]{2} ]",
684
+ "predefined-rgb": "| rec2100-pq | rec2100-hlg | rec2100-linear",
685
+ "progress-source": "<percentage> | <number> | <dimension> | <'animation-timeline'>",
686
+ "progress()": "progress( <calc-sum> , <calc-sum> , <calc-sum> )",
687
+ "pseudo-class-selector": ": <ident-token> | : <function-token> <any-value> )",
688
+ "pseudo-element-selector": ": <pseudo-class-selector> | <legacy-pseudo-element-selector>",
689
+ "pt-class-selector": "[ '.' <custom-ident> ]+",
690
+ "pt-name-and-class-selector": "<pt-name-selector> <pt-class-selector>? | <pt-class-selector>",
691
+ "pt-name-selector": "'*' | <custom-ident>",
692
+ "query-in-parens": "( <container-query> ) | ( <size-feature> ) | style( <style-query> ) | scroll-state( <scroll-state-query> ) | <general-enclosed>",
693
+ "random-cache-key": "<dashed-ident> || element-scoped || [ property-scoped | property-index-scoped | <random-ua-ident> ]",
694
+ "random-item-args": "random-item( <declaration-value> , [ <declaration-value>? ]# )",
695
+ "random-item()": "random-item( <random-key> , [ <declaration-value>? ]# )",
696
+ "random-key": "auto | <random-cache-key> | fixed <number [0,1]>",
697
+ "random-ua-ident": "<custom-ident>",
698
+ "random()": "random( <random-key>? , <calc-sum> , <calc-sum> , <calc-sum>? )",
699
+ "ray-size": "<radial-extent> | sides",
700
+ "rectangular-color-space": "srgb | srgb-linear | display-p3 | display-p3-linear | a98-rgb | prophoto-rgb | rec2020 | lab | oklab | <xyz-space>",
701
+ "referrer-policy-modifier": "referrer-policy( no-referrer | no-referrer-when-downgrade | same-origin | origin | strict-origin | origin-when-cross-origin | strict-origin-when-cross-origin | unsafe-url )",
702
+ "relative-control-point": "<coordinate-pair> [ from [ start | end | origin ] ]?",
703
+ "repeat-line-color": "repeat( [ <integer [1,∞]> ] , [ <color> ]# )",
704
+ "repeat-line-style": "repeat( [ <integer [1,∞]> ] , [ <line-style> ]# )",
705
+ "repeat-line-width": "repeat( [ <integer [1,∞]> ] , [ <line-width> ]# )",
706
+ "repeat-style": "repeat-x | repeat-y | repeat-block | repeat-inline | <repetition>{1,2}",
707
+ "repetition": "repeat | space | round | no-repeat",
708
+ "request-url-modifier": "<cross-origin-modifier> | <integrity-modifier> | <referrer-policy-modifier>",
709
+ "rgb()": "[ <legacy-rgb-syntax> | <modern-rgb-syntax> ]",
710
+ "rgba()": "[ <legacy-rgba-syntax> | <modern-rgba-syntax> ]",
711
+ "round()": "round( <rounding-strategy>? , <calc-sum> , <calc-sum>? )",
712
+ "rounding-strategy": "| line-width",
713
+ "route-descriptor": "<pattern-descriptor> | <init-descriptor> | <base-descriptor>",
714
+ "route-location": "<route-name> | <url-pattern()> | <url>",
715
+ "route-name": "<dashed-ident>",
716
+ "route-rule": "@route <dashed-ident> { <declaration-list> }",
717
+ "running()": "running( <custom-ident> )",
718
+ "scope-boundaries": "[ [ ( <scope-start> ) ]? [ to ( <scope-end> ) ]? ]!",
719
+ "scope-end": "<selector-list>",
720
+ "scope-start": "<selector-list>",
721
+ "scroll-button-direction": "up | down | left | right | block-start | block-end | inline-start | inline-end | prev | next",
722
+ "scroll-state-feature": "[ <scroll-state-feature-plain> | <scroll-state-feature-boolean> ]",
723
+ "scroll-state-feature-boolean": "<scroll-state-feature-name>",
724
+ "scroll-state-feature-name": "<ident>",
725
+ "scroll-state-feature-plain": "<scroll-state-feature-name> : <scroll-state-feature-value>",
726
+ "scroll-state-feature-value": "<ident>",
727
+ "shadow": "<color>? && [ <length>{2} [ <length [0,∞]> <length>? ]? ] && inset?",
728
+ "shape-box": "<visual-box> | margin-box | half-border-box",
729
+ "shape-command": "<move-command> | <line-command> | close | <horizontal-line-command> | <vertical-line-command> | <curve-command> | <smooth-command> | <arc-command>",
730
+ "shape()": "shape( <'fill-rule'>? from <position> , <shape-command># )",
731
+ "single-animation-iteration-count": "infinite | <number [0,∞]>",
732
+ "size-keyword": "auto | max-content | min-content | stretch",
733
+ "slash-separated-border-radius-syntax": "<length-percentage [0,∞]> [ / <length-percentage [0,∞]> ]?",
734
+ "smooth-command": "smooth [ [ to <position> [ with <control-point> ]? ] | [ by <coordinate-pair> [ with <relative-control-point> ]? ] ]",
735
+ "snap-block()": "snap-block( <length> , [ start | end | near ]? )",
736
+ "snap-inline()": "snap-inline( <length> , [ left | right | near ]? )",
737
+ "source-size": "<media-condition> <source-size-value> | auto",
738
+ "source-size-list": "<source-size>#? , <source-size-value>",
739
+ "source-size-value": "<length> | auto",
740
+ "spacing-trim": "space-all | normal | space-first | trim-start | trim-both | trim-all",
741
+ "spread-shadow": "<'box-shadow-color'>? && [ [ none | <length>{2} ] [ <'box-shadow-blur'> <'box-shadow-spread'>? ]? ] && <'box-shadow-position'>?",
742
+ "src()": "src( <string> <url-modifier>* )",
743
+ "string()": "string( <custom-ident> , [ first | start | last | first-except ]? )",
744
+ "stripes()": "stripes( <color-stripe># )",
745
+ "style-feature": "<style-feature-plain> | <style-feature-boolean> | <style-range>",
746
+ "style-feature-boolean": "<style-feature-name>",
747
+ "style-feature-plain": "<style-feature-name> : <style-feature-value>",
748
+ "style-feature-value": "<declaration-value>",
749
+ "style-in-parens": "( <style-query> ) | ( <style-feature> ) | <general-enclosed>",
750
+ "style-query": "not <style-in-parens> | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ] | <style-feature>",
751
+ "style-range": "<style-range-value> <mf-comparison> <style-range-value> | <style-range-value> <mf-lt> <style-range-value> <mf-lt> <style-range-value> | <style-range-value> <mf-gt> <style-range-value> <mf-gt> <style-range-value>",
752
+ "style-range-value": "<custom-property-name> | <style-feature-value>",
753
+ "supports-at-rule-fn": "at-rule( <at-keyword-token> )",
754
+ "supports-condition-name": "<custom-ident>",
755
+ "supports-decl": "( [ <declaration> | <supports-condition-name> ] )",
756
+ "supports-env-fn": "env( <ident> )",
757
+ "supports-feature": "<supports-selector-fn> | <supports-font-tech-fn> | <supports-font-format-fn> | <supports-at-rule-fn> | <supports-named-feature-fn> | <supports-env-fn> | <supports-decl>",
758
+ "supports-font-format-fn": "font-format( <font-format> )",
759
+ "supports-font-tech-fn": "font-tech( <font-tech> )",
760
+ "supports-import-condition": "supports( [ <supports-condition> | <declaration> ] )",
761
+ "supports-named-feature-fn": "named-feature( <ident> )",
762
+ "supports()": "supports( <declaration> )",
763
+ "svg-paint": "child | child( <integer> )",
764
+ "syntax-multiplier": "[ '#' | '+' ]",
765
+ "system-color": "AccentColor | AccentColorText | ActiveText | ButtonBorder | ButtonFace | ButtonText | Canvas | CanvasText | Field | FieldText | GrayText | Highlight | HighlightText | LinkText | Mark | MarkText | SelectedItem | SelectedItemText | VisitedText | <deprecated-color>",
766
+ "system-font-family-name": "caption | icon | menu | message-box | small-caption | status-bar",
767
+ "target-contrast": "<wcag2>",
768
+ "text-edge": "[ text | ideographic | ideographic-ink ] | [ text | ideographic | ideographic-ink | cap | ex ] [ text | ideographic | ideographic-ink | alphabetic ]",
769
+ "time-percentage": "[ <time> | <percentage> ]",
770
+ "timeline-range-center-subject": "<ident>",
771
+ "toggle()": "toggle( <any-value># )",
772
+ "track-breadth": "<length-percentage [0,∞]> | <flex [0,∞]> | min-content | max-content | auto",
773
+ "track-size": "<track-breadth> | minmax( <inflexible-breadth> , <track-breadth> ) | fit-content( <length-percentage [0,∞]> )",
774
+ "transform-function": "<scale3d()> | <scale()> | <scaleX()> | <scaleY()> | <scaleZ()> | <translate3d()> | <translate()> | <translateX()> | <translateY()> | <translateZ()> | <rotate3d()> | <rotate()> | <rotateX()> | <rotateY()> | <rotateZ()> | <skew()> | <skewX()> | <skewY()> | <matrix3d()> | <matrix()> | <perspective()>",
775
+ "transform-interpolate()": "transform-interpolate( [ <progress-source> && [ by <easing-function> ]? && <easing-function>? ] , <input-position>{1,2} : <transform-list> , [ <easing-function>? , <input-position>{1,2} : <transform-list> ]#? )",
776
+ "transform-mix()": "transform-mix( [ <transform-list> && <percentage [0,100]> ]# )",
777
+ "try-tactic": "flip-block || flip-inline || flip-start || flip-x || flip-y",
778
+ "type": "'<' [ number | string ] '>'",
779
+ "type()": "type( <syntax> )",
780
+ "url": "<url()> | <src()> | <url-token>",
781
+ "url-pattern()": "url-pattern( <string> )",
782
+ "url-set": "image-set( <url-set-option># )",
783
+ "url-set-option": "[ <url> | <string> ] [ <resolution> || type( <string> ) ]?",
784
+ "url-set()": "url-set( <url-set-option># )",
785
+ "url()": "url( <string> <url-modifier>* ) | <url-token>",
786
+ "var-args": "var( <declaration-value> , <declaration-value>? )",
787
+ "vertical-line-command": "vline [ to [ <length-percentage> | top | center | bottom | y-start | y-end ] | by <length-percentage> ]",
788
+ "voice-family-name": "<string> | <custom-ident>+",
789
+ "wcag2": "wcag2 | wcag2( [ <number> | [ aa | aaa ] && large? ] )",
790
+ "whole-value": "<declaration-value>",
791
+ "style-feature-name": "<dashed-ident> | -moz-appearance | -moz-background-clip | -moz-binding | -moz-border-bottom-colors | -moz-border-left-colors | -moz-border-radius-bottomleft | -moz-border-radius-bottomright | -moz-border-radius-topleft | -moz-border-radius-topright | -moz-border-right-colors | -moz-border-top-colors | -moz-context-properties | -moz-control-character-visibility | -moz-float-edge | -moz-force-broken-image-icon | -moz-orient | -moz-osx-font-smoothing | -moz-outline-radius | -moz-outline-radius-bottomleft | -moz-outline-radius-bottomright | -moz-outline-radius-topleft | -moz-outline-radius-topright | -moz-stack-sizing | -moz-text-blink | -moz-user-focus | -moz-user-input | -moz-user-modify | -moz-user-select | -moz-window-dragging | -moz-window-shadow | -ms-accelerator | -ms-block-progression | -ms-content-zoom-chaining | -ms-content-zoom-limit | -ms-content-zoom-limit-max | -ms-content-zoom-limit-min | -ms-content-zoom-snap | -ms-content-zoom-snap-points | -ms-content-zoom-snap-type | -ms-content-zooming | -ms-filter | -ms-flex-align | -ms-flex-item-align | -ms-flex-line-pack | -ms-flex-negative | -ms-flex-order | -ms-flex-pack | -ms-flex-positive | -ms-flex-preferred-size | -ms-flow-from | -ms-flow-into | -ms-grid-column-align | -ms-grid-columns | -ms-grid-row-align | -ms-grid-rows | -ms-high-contrast-adjust | -ms-hyphenate-limit-chars | -ms-hyphenate-limit-last | -ms-hyphenate-limit-lines | -ms-hyphenate-limit-zone | -ms-ime-align | -ms-interpolation-mode | -ms-overflow-style | -ms-scroll-chaining | -ms-scroll-limit | -ms-scroll-limit-x-max | -ms-scroll-limit-x-min | -ms-scroll-limit-y-max | -ms-scroll-limit-y-min | -ms-scroll-rails | -ms-scroll-snap-points-x | -ms-scroll-snap-points-y | -ms-scroll-snap-type | -ms-scroll-snap-x | -ms-scroll-snap-y | -ms-scroll-translation | -ms-scrollbar-3dlight-color | -ms-scrollbar-arrow-color | -ms-scrollbar-base-color | -ms-scrollbar-darkshadow-color | -ms-scrollbar-face-color | -ms-scrollbar-highlight-color | -ms-scrollbar-shadow-color | -ms-scrollbar-track-color | -ms-text-autospace | -ms-touch-select | -ms-user-select | -ms-wrap-flow | -ms-wrap-margin | -ms-wrap-through | -webkit-appearance | -webkit-background-clip | -webkit-border-before | -webkit-border-before-color | -webkit-border-before-style | -webkit-border-before-width | -webkit-box-reflect | -webkit-column-break-after | -webkit-column-break-before | -webkit-column-break-inside | -webkit-font-smoothing | -webkit-line-clamp | -webkit-mask | -webkit-mask-attachment | -webkit-mask-box-image | -webkit-mask-clip | -webkit-mask-composite | -webkit-mask-image | -webkit-mask-origin | -webkit-mask-position | -webkit-mask-position-x | -webkit-mask-position-y | -webkit-mask-repeat | -webkit-mask-repeat-x | -webkit-mask-repeat-y | -webkit-mask-size | -webkit-overflow-scrolling | -webkit-print-color-adjust | -webkit-tap-highlight-color | -webkit-text-fill-color | -webkit-text-security | -webkit-text-stroke | -webkit-text-stroke-color | -webkit-text-stroke-width | -webkit-touch-callout | -webkit-user-drag | -webkit-user-modify | -webkit-user-select | accent-color | align-content | align-items | align-self | align-tracks | alignment-baseline | all | anchor-name | anchor-scope | animation | animation-composition | animation-delay | animation-direction | animation-duration | animation-fill-mode | animation-iteration-count | animation-name | animation-play-state | animation-range | animation-range-center | animation-range-end | animation-range-start | animation-timeline | animation-timing-function | animation-trigger | appearance | aspect-ratio | backdrop-filter | backface-visibility | background | background-attachment | background-blend-mode | background-clip | background-color | background-image | background-origin | background-position | background-position-block | background-position-inline | background-position-x | background-position-y | background-repeat | background-repeat-block | background-repeat-inline | background-repeat-x | background-repeat-y | background-size | background-tbd | baseline-shift | baseline-source | behavior | block-ellipsis | block-size | block-step | block-step-align | block-step-insert | block-step-round | block-step-size | bookmark-label | bookmark-level | bookmark-state | border | border-block | border-block-clip | border-block-color | border-block-end | border-block-end-clip | border-block-end-color | border-block-end-radius | border-block-end-style | border-block-end-width | border-block-start | border-block-start-clip | border-block-start-color | border-block-start-radius | border-block-start-style | border-block-start-width | border-block-style | border-block-width | border-bottom | border-bottom-clip | border-bottom-color | border-bottom-left-radius | border-bottom-radius | border-bottom-right-radius | border-bottom-style | border-bottom-width | border-boundary | border-clip | border-collapse | border-color | border-end-end-radius | border-end-start-radius | border-image | border-image-outset | border-image-repeat | border-image-slice | border-image-source | border-image-width | border-inline | border-inline-clip | border-inline-color | border-inline-end | border-inline-end-clip | border-inline-end-color | border-inline-end-radius | border-inline-end-style | border-inline-end-width | border-inline-start | border-inline-start-clip | border-inline-start-color | border-inline-start-radius | border-inline-start-style | border-inline-start-width | border-inline-style | border-inline-width | border-left | border-left-clip | border-left-color | border-left-radius | border-left-style | border-left-width | border-limit | border-radius | border-right | border-right-clip | border-right-color | border-right-radius | border-right-style | border-right-width | border-shape | border-spacing | border-start-end-radius | border-start-start-radius | border-style | border-top | border-top-clip | border-top-color | border-top-left-radius | border-top-radius | border-top-right-radius | border-top-style | border-top-width | border-width | bottom | box-align | box-decoration-break | box-direction | box-flex | box-flex-group | box-lines | box-ordinal-group | box-orient | box-pack | box-shadow | box-shadow-blur | box-shadow-color | box-shadow-offset | box-shadow-position | box-shadow-spread | box-sizing | box-snap | break-after | break-before | break-inside | caption-side | caret | caret-animation | caret-color | caret-shape | clear | clip | clip-path | clip-rule | color | color-adjust | color-interpolation | color-interpolation-filters | color-scheme | column-count | column-fill | column-gap | column-height | column-rule | column-rule-break | column-rule-color | column-rule-inset | column-rule-inset-cap | column-rule-inset-cap-end | column-rule-inset-cap-start | column-rule-inset-end | column-rule-inset-junction | column-rule-inset-junction-end | column-rule-inset-junction-start | column-rule-inset-start | column-rule-style | column-rule-visibility-items | column-rule-width | column-span | column-width | column-wrap | columns | contain | contain-intrinsic-block-size | contain-intrinsic-height | contain-intrinsic-inline-size | contain-intrinsic-size | contain-intrinsic-width | container | container-name | container-type | content | content-visibility | continue | copy-into | corner | corner-block-end | corner-block-end-shape | corner-block-start | corner-block-start-shape | corner-bottom | corner-bottom-left | corner-bottom-left-shape | corner-bottom-right | corner-bottom-right-shape | corner-bottom-shape | corner-end-end | corner-end-end-shape | corner-end-start | corner-end-start-shape | corner-inline-end | corner-inline-end-shape | corner-inline-start | corner-inline-start-shape | corner-left | corner-left-shape | corner-right | corner-right-shape | corner-shape | corner-start-end | corner-start-end-shape | corner-start-start | corner-start-start-shape | corner-top | corner-top-left | corner-top-left-shape | corner-top-right | corner-top-right-shape | corner-top-shape | counter-increment | counter-reset | counter-set | cue | cue-after | cue-before | cursor | cx | cy | d | direction | display | dominant-baseline | dynamic-range-limit | empty-cells | event-trigger | event-trigger-name | event-trigger-source | field-sizing | fill | fill-break | fill-color | fill-image | fill-opacity | fill-origin | fill-position | fill-repeat | fill-rule | fill-size | filter | flex | flex-basis | flex-direction | flex-flow | flex-grow | flex-line-count | flex-shrink | flex-wrap | float | float-defer | float-offset | float-reference | flood-color | flood-opacity | flow-from | flow-into | flow-tolerance | font | font-family | font-feature-settings | font-kerning | font-language-override | font-optical-sizing | font-palette | font-size | font-size-adjust | font-smooth | font-stretch | font-style | font-synthesis | font-synthesis-position | font-synthesis-small-caps | font-synthesis-style | font-synthesis-weight | font-variant | font-variant-alternates | font-variant-caps | font-variant-east-asian | font-variant-emoji | font-variant-ligatures | font-variant-numeric | font-variant-position | font-variation-settings | font-weight | font-width | footnote-display | footnote-policy | forced-color-adjust | frame-sizing | gap | glyph-orientation-horizontal | glyph-orientation-vertical | grid | grid-area | grid-auto-columns | grid-auto-flow | grid-auto-rows | grid-column | grid-column-end | grid-column-gap | grid-column-start | grid-gap | grid-row | grid-row-end | grid-row-gap | grid-row-start | grid-template | grid-template-areas | grid-template-columns | grid-template-rows | hanging-punctuation | height | hyphenate-character | hyphenate-limit-chars | hyphenate-limit-last | hyphenate-limit-lines | hyphenate-limit-zone | hyphens | image-animation | image-orientation | image-rendering | image-resolution | ime-mode | initial-letter | initial-letter-align | initial-letter-wrap | inline-size | inline-sizing | input-security | inset | inset-block | inset-block-end | inset-block-start | inset-inline | inset-inline-end | inset-inline-start | interactivity | interest-delay | interest-delay-end | interest-delay-start | interpolate-size | isolation | justify-content | justify-items | justify-self | justify-tracks | kerning | left | letter-spacing | lighting-color | line-break | line-clamp | line-fit-edge | line-grid | line-height | line-height-step | line-padding | line-snap | link-parameters | list-style | list-style-image | list-style-position | list-style-type | margin | margin-block | margin-block-end | margin-block-start | margin-bottom | margin-break | margin-inline | margin-inline-end | margin-inline-start | margin-left | margin-right | margin-top | margin-trim | marker | marker-end | marker-mid | marker-side | marker-start | mask | mask-border | mask-border-mode | mask-border-outset | mask-border-repeat | mask-border-slice | mask-border-source | mask-border-width | mask-clip | mask-composite | mask-image | mask-mode | mask-origin | mask-position | mask-repeat | mask-size | mask-type | masonry-auto-flow | math-depth | math-shift | math-style | max-block-size | max-height | max-inline-size | max-lines | max-width | min-block-size | min-height | min-inline-size | min-intrinsic-sizing | min-width | mix-blend-mode | nav-down | nav-left | nav-right | nav-up | object-fit | object-position | object-view-box | offset | offset-anchor | offset-distance | offset-path | offset-position | offset-rotate | opacity | order | orphans | outline | outline-color | outline-offset | outline-style | outline-width | overflow | overflow-anchor | overflow-block | overflow-clip-box | overflow-clip-margin | overflow-clip-margin-block | overflow-clip-margin-block-end | overflow-clip-margin-block-start | overflow-clip-margin-bottom | overflow-clip-margin-inline | overflow-clip-margin-inline-end | overflow-clip-margin-inline-start | overflow-clip-margin-left | overflow-clip-margin-right | overflow-clip-margin-top | overflow-inline | overflow-wrap | overflow-x | overflow-y | overlay | overscroll-behavior | overscroll-behavior-block | overscroll-behavior-inline | overscroll-behavior-x | overscroll-behavior-y | padding | padding-block | padding-block-end | padding-block-start | padding-bottom | padding-inline | padding-inline-end | padding-inline-start | padding-left | padding-right | padding-top | page | page-break-after | page-break-before | page-break-inside | paint-order | path-length | pause | pause-after | pause-before | perspective | perspective-origin | place-content | place-items | place-self | pointer-events | pointer-timeline | pointer-timeline-axis | pointer-timeline-name | position | position-anchor | position-area | position-try | position-try-fallbacks | position-try-options | position-try-order | position-visibility | print-color-adjust | quotes | r | reading-flow | reading-order | region-fragment | resize | rest | rest-after | rest-before | right | rotate | row-gap | row-rule | row-rule-break | row-rule-color | row-rule-inset | row-rule-inset-cap | row-rule-inset-cap-end | row-rule-inset-cap-start | row-rule-inset-end | row-rule-inset-junction | row-rule-inset-junction-end | row-rule-inset-junction-start | row-rule-inset-start | row-rule-style | row-rule-visibility-items | row-rule-width | ruby-align | ruby-merge | ruby-overhang | ruby-position | rule | rule-break | rule-color | rule-inset | rule-inset-cap | rule-inset-end | rule-inset-junction | rule-inset-start | rule-overlap | rule-style | rule-visibility-items | rule-width | rx | ry | scale | scroll-behavior | scroll-initial-target | scroll-margin | scroll-margin-block | scroll-margin-block-end | scroll-margin-block-start | scroll-margin-bottom | scroll-margin-inline | scroll-margin-inline-end | scroll-margin-inline-start | scroll-margin-left | scroll-margin-right | scroll-margin-top | scroll-marker-group | scroll-padding | scroll-padding-block | scroll-padding-block-end | scroll-padding-block-start | scroll-padding-bottom | scroll-padding-inline | scroll-padding-inline-end | scroll-padding-inline-start | scroll-padding-left | scroll-padding-right | scroll-padding-top | scroll-snap-align | scroll-snap-coordinate | scroll-snap-destination | scroll-snap-points-x | scroll-snap-points-y | scroll-snap-stop | scroll-snap-type | scroll-snap-type-x | scroll-snap-type-y | scroll-target-group | scroll-timeline | scroll-timeline-axis | scroll-timeline-name | scrollbar-color | scrollbar-gutter | scrollbar-width | shape-image-threshold | shape-inside | shape-margin | shape-outside | shape-padding | shape-rendering | slider-orientation | spatial-navigation-action | spatial-navigation-contain | spatial-navigation-function | speak | speak-as | stop-color | stop-opacity | string-set | stroke | stroke-align | stroke-alignment | stroke-break | stroke-color | stroke-dash-corner | stroke-dash-justify | stroke-dashadjust | stroke-dasharray | stroke-dashcorner | stroke-dashoffset | stroke-image | stroke-linecap | stroke-linejoin | stroke-miterlimit | stroke-opacity | stroke-origin | stroke-position | stroke-repeat | stroke-size | stroke-width | tab-size | table-layout | text-align | text-align-all | text-align-last | text-anchor | text-autospace | text-box | text-box-edge | text-box-trim | text-combine-upright | text-decoration | text-decoration-color | text-decoration-inset | text-decoration-line | text-decoration-skip | text-decoration-skip-box | text-decoration-skip-ink | text-decoration-skip-self | text-decoration-skip-spaces | text-decoration-style | text-decoration-thickness | text-emphasis | text-emphasis-color | text-emphasis-position | text-emphasis-skip | text-emphasis-style | text-fit | text-group-align | text-indent | text-justify | text-orientation | text-overflow | text-rendering | text-shadow | text-size-adjust | text-spacing | text-spacing-trim | text-transform | text-underline-offset | text-underline-position | text-wrap | text-wrap-mode | text-wrap-style | timeline-scope | timeline-trigger | timeline-trigger-activation-range | timeline-trigger-activation-range-end | timeline-trigger-activation-range-start | timeline-trigger-active-range | timeline-trigger-active-range-end | timeline-trigger-active-range-start | timeline-trigger-exit-range | timeline-trigger-exit-range-end | timeline-trigger-exit-range-start | timeline-trigger-name | timeline-trigger-range | timeline-trigger-range-end | timeline-trigger-range-start | timeline-trigger-source | top | touch-action | transform | transform-box | transform-origin | transform-style | transition | transition-behavior | transition-delay | transition-duration | transition-property | transition-timing-function | translate | trigger-scope | unicode-bidi | user-select | vector-effect | vertical-align | view-timeline | view-timeline-axis | view-timeline-inset | view-timeline-name | view-transition-class | view-transition-group | view-transition-name | view-transition-scope | visibility | voice-balance | voice-duration | voice-family | voice-pitch | voice-range | voice-rate | voice-stress | voice-volume | white-space | white-space-collapse | white-space-trim | widows | width | will-change | window-drag | word-break | word-space-transform | word-spacing | word-wrap | wrap-after | wrap-before | wrap-flow | wrap-inside | wrap-through | writing-mode | x | y | z-index | zoom"
792
+ }
793
+ }
794
+ }
node_modules/@csstools/css-syntax-patches-for-csstree/package.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-syntax-patches-for-csstree",
3
+ "description": "CSS syntax patches for CSS tree",
4
+ "version": "1.1.5",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT-0",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "main": "dist/index.json",
28
+ "types": "dist/index.d.ts",
29
+ "files": [
30
+ "CHANGELOG.md",
31
+ "LICENSE.md",
32
+ "README.md",
33
+ "dist"
34
+ ],
35
+ "peerDependencies": {
36
+ "css-tree": "^3.2.1"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "css-tree": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "scripts": {},
44
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-syntax-patches-for-csstree#readme",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
48
+ "directory": "packages/css-syntax-patches-for-csstree"
49
+ },
50
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
51
+ "keywords": [
52
+ "css",
53
+ "csstree",
54
+ "syntax"
55
+ ]
56
+ }
node_modules/@csstools/css-tokenizer/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changes to CSS Tokenizer
2
+
3
+ ### 4.0.0
4
+
5
+ _January 14, 2026_
6
+
7
+ - Updated: Support for Node `20.19.0` or later (major).
8
+ - Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes.
9
+
10
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md)
node_modules/@csstools/css-tokenizer/LICENSE.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/@csstools/css-tokenizer/README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Tokenizer <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-tokenizer.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+ [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
+
7
+ Implemented from : https://drafts.csswg.org/css-syntax/
8
+
9
+ ## API
10
+
11
+ [Read the API docs](./docs/css-tokenizer.md)
12
+
13
+ ## Usage
14
+
15
+ Add [CSS Tokenizer] to your project:
16
+
17
+ ```bash
18
+ npm install @csstools/css-tokenizer --save-dev
19
+ ```
20
+
21
+ ```js
22
+ import { tokenize } from '@csstools/css-tokenizer';
23
+
24
+ const myCSS = `@media only screen and (min-width: 768rem) {
25
+ .foo {
26
+ content: 'Some content!' !important;
27
+ }
28
+ }
29
+ `;
30
+
31
+ const tokens = tokenize({
32
+ css: myCSS,
33
+ });
34
+
35
+ console.log(tokens);
36
+ ```
37
+
38
+ Or use the streaming interface:
39
+
40
+ ```js
41
+ import { tokenizer, TokenType } from '@csstools/css-tokenizer';
42
+
43
+ const myCSS = `@media only screen and (min-width: 768rem) {
44
+ .foo {
45
+ content: 'Some content!' !important;
46
+ }
47
+ }
48
+ `;
49
+
50
+ const t = tokenizer({
51
+ css: myCSS,
52
+ });
53
+
54
+ while (true) {
55
+ const token = t.nextToken();
56
+ if (token[0] === TokenType.EOF) {
57
+ break;
58
+ }
59
+
60
+ console.log(token);
61
+ }
62
+ ```
63
+
64
+ ### Options
65
+
66
+ ```ts
67
+ {
68
+ onParseError?: (error: ParseError) => void
69
+ }
70
+ ```
71
+
72
+ #### `onParseError`
73
+
74
+ The tokenizer is forgiving and won't stop when a parse error is encountered.
75
+
76
+ To receive parsing error information you can set a callback.
77
+
78
+ ```js
79
+ import { tokenizer, TokenType } from '@csstools/css-tokenizer';
80
+
81
+ const t = tokenizer({
82
+ css: '\\',
83
+ }, { onParseError: (err) => console.warn(err) });
84
+
85
+ while (true) {
86
+ const token = t.nextToken();
87
+ if (token[0] === TokenType.EOF) {
88
+ break;
89
+ }
90
+ }
91
+ ```
92
+
93
+ Parser errors will try to inform you where in the tokenizer logic the error happened.
94
+ This tells you what kind of error occurred.
95
+
96
+ ## Order of priorities
97
+
98
+ 1. specification compliance
99
+ 2. correctness
100
+ 3. reliability
101
+ 4. tokenizing and serializing must round trip losslessly
102
+ 5. exposing useful aspects about the source code
103
+ 6. runtime performance
104
+ 7. package size
105
+
106
+
107
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
108
+ [discord]: https://discord.gg/bUadyRwkJS
109
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-tokenizer
110
+
111
+ [CSS Tokenizer]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer
node_modules/@csstools/css-tokenizer/dist/index.d.ts ADDED
@@ -0,0 +1,593 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Tokenize CSS following the {@link https://drafts.csswg.org/css-syntax/#tokenization | CSS Syntax Level 3 specification}.
3
+ *
4
+ * @remarks
5
+ * The tokenizing and parsing tools provided by CSS Tools are designed to be low level and generic with strong ties to their respective specifications.
6
+ *
7
+ * Any analysis or mutation of CSS source code should be done with the least powerful tool that can accomplish the task.
8
+ * For many applications it is sufficient to work with tokens.
9
+ * 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.
10
+ *
11
+ * @example
12
+ * Tokenize a string of CSS into an array of tokens:
13
+ * ```js
14
+ * import { tokenize } from '@csstools/css-tokenizer';
15
+ *
16
+ * const myCSS = `@media only screen and (min-width: 768rem) {
17
+ * .foo {
18
+ * content: 'Some content!' !important;
19
+ * }
20
+ * }
21
+ * `;
22
+ *
23
+ * const tokens = tokenize({
24
+ * css: myCSS,
25
+ * });
26
+ *
27
+ * console.log(tokens);
28
+ * ```
29
+ *
30
+ * @packageDocumentation
31
+ */
32
+
33
+ /**
34
+ * Deep clone a list of tokens.
35
+ * Useful for mutations without altering the original list.
36
+ */
37
+ export declare function cloneTokens(tokens: Array<CSSToken>): Array<CSSToken>;
38
+
39
+ /**
40
+ * The union of all possible CSS tokens
41
+ */
42
+ export declare type CSSToken = TokenAtKeyword | TokenBadString | TokenBadURL | TokenCDC | TokenCDO | TokenColon | TokenComma | TokenComment | TokenDelim | TokenDimension | TokenEOF | TokenFunction | TokenHash | TokenIdent | TokenNumber | TokenPercentage | TokenSemicolon | TokenString | TokenURL | TokenWhitespace | TokenOpenParen | TokenCloseParen | TokenOpenSquare | TokenCloseSquare | TokenOpenCurly | TokenCloseCurly | TokenUnicodeRange;
43
+
44
+ /**
45
+ * The type of hash token
46
+ */
47
+ export declare enum HashType {
48
+ /**
49
+ * The hash token did not start with an ident sequence (e.g. `#-2`)
50
+ */
51
+ Unrestricted = "unrestricted",
52
+ /**
53
+ * The hash token started with an ident sequence (e.g. `#foo`)
54
+ * Only hash tokens with the "id" type are valid ID selectors.
55
+ */
56
+ ID = "id"
57
+ }
58
+
59
+ /**
60
+ * Assert that a given value has the general structure of a CSS token:
61
+ * 1. is an array.
62
+ * 2. has at least four items.
63
+ * 3. has a known token type.
64
+ * 4. has a string representation.
65
+ * 5. has a start position.
66
+ * 6. has an end position.
67
+ */
68
+ export declare function isToken(x: any): x is CSSToken;
69
+
70
+ export declare function isTokenAtKeyword(x?: CSSToken | null): x is TokenAtKeyword;
71
+
72
+ export declare function isTokenBadString(x?: CSSToken | null): x is TokenBadString;
73
+
74
+ export declare function isTokenBadURL(x?: CSSToken | null): x is TokenBadURL;
75
+
76
+ export declare function isTokenCDC(x?: CSSToken | null): x is TokenCDC;
77
+
78
+ export declare function isTokenCDO(x?: CSSToken | null): x is TokenCDO;
79
+
80
+ export declare function isTokenCloseCurly(x?: CSSToken | null): x is TokenCloseCurly;
81
+
82
+ export declare function isTokenCloseParen(x?: CSSToken | null): x is TokenCloseParen;
83
+
84
+ export declare function isTokenCloseSquare(x?: CSSToken | null): x is TokenCloseSquare;
85
+
86
+ export declare function isTokenColon(x?: CSSToken | null): x is TokenColon;
87
+
88
+ export declare function isTokenComma(x?: CSSToken | null): x is TokenComma;
89
+
90
+ export declare function isTokenComment(x?: CSSToken | null): x is TokenComment;
91
+
92
+ export declare function isTokenDelim(x?: CSSToken | null): x is TokenDelim;
93
+
94
+ export declare function isTokenDimension(x?: CSSToken | null): x is TokenDimension;
95
+
96
+ export declare function isTokenEOF(x?: CSSToken | null): x is TokenEOF;
97
+
98
+ export declare function isTokenFunction(x?: CSSToken | null): x is TokenFunction;
99
+
100
+ export declare function isTokenHash(x?: CSSToken | null): x is TokenHash;
101
+
102
+ export declare function isTokenIdent(x?: CSSToken | null): x is TokenIdent;
103
+
104
+ export declare function isTokenNumber(x?: CSSToken | null): x is TokenNumber;
105
+
106
+ /**
107
+ * Assert that a token is a numeric token
108
+ */
109
+ export declare function isTokenNumeric(x?: CSSToken | null): x is NumericToken;
110
+
111
+ export declare function isTokenOpenCurly(x?: CSSToken | null): x is TokenOpenCurly;
112
+
113
+ export declare function isTokenOpenParen(x?: CSSToken | null): x is TokenOpenParen;
114
+
115
+ export declare function isTokenOpenSquare(x?: CSSToken | null): x is TokenOpenSquare;
116
+
117
+ export declare function isTokenPercentage(x?: CSSToken | null): x is TokenPercentage;
118
+
119
+ export declare function isTokenSemicolon(x?: CSSToken | null): x is TokenSemicolon;
120
+
121
+ export declare function isTokenString(x?: CSSToken | null): x is TokenString;
122
+
123
+ export declare function isTokenUnicodeRange(x?: CSSToken | null): x is TokenUnicodeRange;
124
+
125
+ export declare function isTokenURL(x?: CSSToken | null): x is TokenURL;
126
+
127
+ export declare function isTokenWhitespace(x?: CSSToken | null): x is TokenWhitespace;
128
+
129
+ /**
130
+ * Assert that a token is a whitespace or comment token
131
+ */
132
+ export declare function isTokenWhiteSpaceOrComment(x?: CSSToken | null): x is TokenWhitespace | TokenComment;
133
+
134
+ /**
135
+ * Get the mirror variant of a given token
136
+ *
137
+ * @example
138
+ *
139
+ * ```js
140
+ * const input = [TokenType.OpenParen, '(', 0, 1, undefined];
141
+ * const output = mirrorVariant(input);
142
+ *
143
+ * console.log(output); // [TokenType.CloseParen, ')', -1, -1, undefined]
144
+ * ```
145
+ */
146
+ export declare function mirrorVariant(token: CSSToken): CSSToken | null;
147
+
148
+ /**
149
+ * Get the mirror variant type of a given token type
150
+ *
151
+ * @example
152
+ *
153
+ * ```js
154
+ * const input = TokenType.OpenParen;
155
+ * const output = mirrorVariantType(input);
156
+ *
157
+ * console.log(output); // TokenType.CloseParen
158
+ * ```
159
+ */
160
+ export declare function mirrorVariantType(type: TokenType): TokenType | null;
161
+
162
+ /**
163
+ * Set the ident value and update the string representation.
164
+ * This handles escaping.
165
+ */
166
+ export declare function mutateIdent(ident: TokenIdent, newValue: string): void;
167
+
168
+ /**
169
+ * Set the unit and update the string representation.
170
+ * This handles escaping.
171
+ */
172
+ export declare function mutateUnit(ident: TokenDimension, newUnit: string): void;
173
+
174
+ /**
175
+ * The type of number token
176
+ * Either `integer` or `number`
177
+ */
178
+ export declare enum NumberType {
179
+ Integer = "integer",
180
+ Number = "number"
181
+ }
182
+
183
+ /**
184
+ * The union of all possible CSS tokens that represent a numeric value
185
+ */
186
+ export declare type NumericToken = TokenDimension | TokenNumber | TokenPercentage;
187
+
188
+ /**
189
+ * The CSS Tokenizer is forgiving and will never throw on invalid input.
190
+ * Any errors are reported through the `onParseError` callback.
191
+ */
192
+ export declare class ParseError extends Error {
193
+ /** The index of the start character of the current token. */
194
+ sourceStart: number;
195
+ /** The index of the end character of the current token. */
196
+ sourceEnd: number;
197
+ /** The parser steps that preceded the error. */
198
+ parserState: Array<string>;
199
+ constructor(message: string, sourceStart: number, sourceEnd: number, parserState: Array<string>);
200
+ }
201
+
202
+ export declare const ParseErrorMessage: {
203
+ UnexpectedNewLineInString: string;
204
+ UnexpectedEOFInString: string;
205
+ UnexpectedEOFInComment: string;
206
+ UnexpectedEOFInURL: string;
207
+ UnexpectedEOFInEscapedCodePoint: string;
208
+ UnexpectedCharacterInURL: string;
209
+ InvalidEscapeSequenceInURL: string;
210
+ InvalidEscapeSequenceAfterBackslash: string;
211
+ };
212
+
213
+ export declare class ParseErrorWithToken extends ParseError {
214
+ /** The associated token. */
215
+ token: CSSToken;
216
+ constructor(message: string, sourceStart: number, sourceEnd: number, parserState: Array<string>, token: CSSToken);
217
+ }
218
+
219
+ /**
220
+ * Concatenate the string representation of a list of tokens.
221
+ * This is not a proper serializer that will handle escaping and whitespace.
222
+ * It only produces valid CSS for a token list that is also valid.
223
+ */
224
+ export declare function stringify(...tokens: Array<CSSToken>): string;
225
+
226
+ /**
227
+ * The CSS Token interface
228
+ *
229
+ * @remarks
230
+ * CSS Tokens are fully typed and have a strict structure.
231
+ * This makes it easier to iterate and analyze a token stream.
232
+ *
233
+ * The string representation and the parsed value are stored separately for many token types.
234
+ * It is always assumed that the string representation will be used when stringifying, while the parsed value should be used when analyzing tokens.
235
+ */
236
+ export declare interface Token<T extends TokenType, U> extends Array<T | string | number | U> {
237
+ /**
238
+ * The type of token
239
+ */
240
+ 0: T;
241
+ /**
242
+ * The token representation
243
+ *
244
+ * @remarks
245
+ * This field will be used when stringifying the token.
246
+ * Any stored value is assumed to be valid CSS.
247
+ *
248
+ * You should never use this field when analyzing the token when there is a parsed value available.
249
+ * But you must store mutated values here.
250
+ */
251
+ 1: string;
252
+ /**
253
+ * Start position of representation
254
+ */
255
+ 2: number;
256
+ /**
257
+ * End position of representation
258
+ */
259
+ 3: number;
260
+ /**
261
+ * Extra data
262
+ *
263
+ * @remarks
264
+ * This holds the parsed value of each token.
265
+ * These values are unescaped, unquoted, converted to numbers, etc.
266
+ *
267
+ * You should always use this field when analyzing the token.
268
+ * But you must not assume that mutating only this field will have any effect.
269
+ */
270
+ 4: U;
271
+ }
272
+
273
+ export declare interface TokenAtKeyword extends Token<TokenType.AtKeyword, {
274
+ /**
275
+ * The unescaped at-keyword name without the leading `@`.
276
+ */
277
+ value: string;
278
+ }> {
279
+ }
280
+
281
+ export declare interface TokenBadString extends Token<TokenType.BadString, undefined> {
282
+ }
283
+
284
+ export declare interface TokenBadURL extends Token<TokenType.BadURL, undefined> {
285
+ }
286
+
287
+ export declare interface TokenCDC extends Token<TokenType.CDC, undefined> {
288
+ }
289
+
290
+ export declare interface TokenCDO extends Token<TokenType.CDO, undefined> {
291
+ }
292
+
293
+ export declare interface TokenCloseCurly extends Token<TokenType.CloseCurly, undefined> {
294
+ }
295
+
296
+ export declare interface TokenCloseParen extends Token<TokenType.CloseParen, undefined> {
297
+ }
298
+
299
+ export declare interface TokenCloseSquare extends Token<TokenType.CloseSquare, undefined> {
300
+ }
301
+
302
+ export declare interface TokenColon extends Token<TokenType.Colon, undefined> {
303
+ }
304
+
305
+ export declare interface TokenComma extends Token<TokenType.Comma, undefined> {
306
+ }
307
+
308
+ export declare interface TokenComment extends Token<TokenType.Comment, undefined> {
309
+ }
310
+
311
+ export declare interface TokenDelim extends Token<TokenType.Delim, {
312
+ /**
313
+ * The delim character.
314
+ */
315
+ value: string;
316
+ }> {
317
+ }
318
+
319
+ export declare interface TokenDimension extends Token<TokenType.Dimension, {
320
+ /**
321
+ * The numeric value.
322
+ */
323
+ value: number;
324
+ /**
325
+ * The unescaped unit name.
326
+ */
327
+ unit: string;
328
+ /**
329
+ * `integer` or `number`
330
+ */
331
+ type: NumberType;
332
+ /**
333
+ * The sign character as it appeared in the source.
334
+ * This is only useful if you need to determine if a value was written as "2px" or "+2px".
335
+ */
336
+ signCharacter?: '+' | '-';
337
+ }> {
338
+ }
339
+
340
+ export declare interface TokenEOF extends Token<TokenType.EOF, undefined> {
341
+ }
342
+
343
+ export declare interface TokenFunction extends Token<TokenType.Function, {
344
+ /**
345
+ * The unescaped function name without the trailing `(`.
346
+ */
347
+ value: string;
348
+ }> {
349
+ }
350
+
351
+ export declare interface TokenHash extends Token<TokenType.Hash, {
352
+ /**
353
+ * The unescaped hash value without the leading `#`.
354
+ */
355
+ value: string;
356
+ /**
357
+ * The hash type.
358
+ */
359
+ type: HashType;
360
+ }> {
361
+ }
362
+
363
+ export declare interface TokenIdent extends Token<TokenType.Ident, {
364
+ /**
365
+ * The unescaped ident value.
366
+ */
367
+ value: string;
368
+ }> {
369
+ }
370
+
371
+ /**
372
+ * Tokenize a CSS string into a list of tokens.
373
+ */
374
+ export declare function tokenize(input: {
375
+ css: {
376
+ valueOf(): string;
377
+ };
378
+ unicodeRangesAllowed?: boolean;
379
+ }, options?: {
380
+ onParseError?: (error: ParseError) => void;
381
+ }): Array<CSSToken>;
382
+
383
+ /**
384
+ * Create a tokenizer for a CSS string.
385
+ */
386
+ export declare function tokenizer(input: {
387
+ css: {
388
+ valueOf(): string;
389
+ };
390
+ unicodeRangesAllowed?: boolean;
391
+ }, options?: {
392
+ onParseError?: (error: ParseError) => void;
393
+ }): {
394
+ nextToken: () => CSSToken;
395
+ endOfFile: () => boolean;
396
+ };
397
+
398
+ export declare interface TokenNumber extends Token<TokenType.Number, {
399
+ /**
400
+ * The numeric value.
401
+ */
402
+ value: number;
403
+ /**
404
+ * `integer` or `number`
405
+ */
406
+ type: NumberType;
407
+ /**
408
+ * The sign character as it appeared in the source.
409
+ * This is only useful if you need to determine if a value was written as "2" or "+2".
410
+ */
411
+ signCharacter?: '+' | '-';
412
+ }> {
413
+ }
414
+
415
+ export declare interface TokenOpenCurly extends Token<TokenType.OpenCurly, undefined> {
416
+ }
417
+
418
+ export declare interface TokenOpenParen extends Token<TokenType.OpenParen, undefined> {
419
+ }
420
+
421
+ export declare interface TokenOpenSquare extends Token<TokenType.OpenSquare, undefined> {
422
+ }
423
+
424
+ export declare interface TokenPercentage extends Token<TokenType.Percentage, {
425
+ /**
426
+ * The numeric value.
427
+ */
428
+ value: number;
429
+ /**
430
+ * The sign character as it appeared in the source.
431
+ * This is only useful if you need to determine if a value was written as "2%" or "+2%".
432
+ */
433
+ signCharacter?: '+' | '-';
434
+ }> {
435
+ }
436
+
437
+ export declare interface TokenSemicolon extends Token<TokenType.Semicolon, undefined> {
438
+ }
439
+
440
+ export declare interface TokenString extends Token<TokenType.String, {
441
+ /**
442
+ * The unescaped string value without the leading and trailing quotes.
443
+ */
444
+ value: string;
445
+ }> {
446
+ }
447
+
448
+ /**
449
+ * All possible CSS token types
450
+ */
451
+ export declare enum TokenType {
452
+ /**
453
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#comment-diagram}
454
+ */
455
+ Comment = "comment",
456
+ /**
457
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-at-keyword-token}
458
+ */
459
+ AtKeyword = "at-keyword-token",
460
+ /**
461
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-bad-string-token}
462
+ */
463
+ BadString = "bad-string-token",
464
+ /**
465
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-bad-url-token}
466
+ */
467
+ BadURL = "bad-url-token",
468
+ /**
469
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-cdc-token}
470
+ */
471
+ CDC = "CDC-token",
472
+ /**
473
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-cdo-token}
474
+ */
475
+ CDO = "CDO-token",
476
+ /**
477
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-colon-token}
478
+ */
479
+ Colon = "colon-token",
480
+ /**
481
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-comma-token}
482
+ */
483
+ Comma = "comma-token",
484
+ /**
485
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-delim-token}
486
+ */
487
+ Delim = "delim-token",
488
+ /**
489
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-dimension-token}
490
+ */
491
+ Dimension = "dimension-token",
492
+ /**
493
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-eof-token}
494
+ */
495
+ EOF = "EOF-token",
496
+ /**
497
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-function-token}
498
+ */
499
+ Function = "function-token",
500
+ /**
501
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-hash-token}
502
+ */
503
+ Hash = "hash-token",
504
+ /**
505
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-ident-token}
506
+ */
507
+ Ident = "ident-token",
508
+ /**
509
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-percentage-token}
510
+ */
511
+ Number = "number-token",
512
+ /**
513
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-percentage-token}
514
+ */
515
+ Percentage = "percentage-token",
516
+ /**
517
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-semicolon-token}
518
+ */
519
+ Semicolon = "semicolon-token",
520
+ /**
521
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-string-token}
522
+ */
523
+ String = "string-token",
524
+ /**
525
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-url-token}
526
+ */
527
+ URL = "url-token",
528
+ /**
529
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#typedef-whitespace-token}
530
+ */
531
+ Whitespace = "whitespace-token",
532
+ /**
533
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-open-paren}
534
+ */
535
+ OpenParen = "(-token",
536
+ /**
537
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-close-paren}
538
+ */
539
+ CloseParen = ")-token",
540
+ /**
541
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-open-square}
542
+ */
543
+ OpenSquare = "[-token",
544
+ /**
545
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-close-square}
546
+ */
547
+ CloseSquare = "]-token",
548
+ /**
549
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-open-curly}
550
+ */
551
+ OpenCurly = "{-token",
552
+ /**
553
+ * @see {@link https://www.w3.org/TR/2021/CRD-css-syntax-3-20211224/#tokendef-close-curly}
554
+ */
555
+ CloseCurly = "}-token",
556
+ /**
557
+ * Only appears in the token stream when the `unicodeRangesAllowed` option is set to true.
558
+ *
559
+ * @example
560
+ * ```js
561
+ * import { tokenize } from '@csstools/css-tokenizer';
562
+ *
563
+ * const tokens = tokenize({
564
+ * css: `U+0025-00FF, U+4??`,
565
+ * unicodeRangesAllowed: true,
566
+ * });
567
+ *
568
+ * console.log(tokens);
569
+ * ```
570
+ *
571
+ * @see {@link https://drafts.csswg.org/css-syntax/#typedef-unicode-range-token}
572
+ */
573
+ UnicodeRange = "unicode-range-token"
574
+ }
575
+
576
+ export declare interface TokenUnicodeRange extends Token<TokenType.UnicodeRange, {
577
+ startOfRange: number;
578
+ endOfRange: number;
579
+ }> {
580
+ }
581
+
582
+ export declare interface TokenURL extends Token<TokenType.URL, {
583
+ /**
584
+ * The unescaped URL value without the leading `url(` and trailing `)`.
585
+ */
586
+ value: string;
587
+ }> {
588
+ }
589
+
590
+ export declare interface TokenWhitespace extends Token<TokenType.Whitespace, undefined> {
591
+ }
592
+
593
+ export { }
node_modules/@csstools/css-tokenizer/dist/index.mjs ADDED
@@ -0,0 +1 @@
 
 
1
+ class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,t,o){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=t,this.parserState=o}}class ParseErrorWithToken extends ParseError{token;constructor(e,n,t,o,r){super(e,n,t,o),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;function cloneTokens(e){return n?structuredClone(e):JSON.parse(JSON.stringify(e))}function stringify(...e){let n="";for(let t=0;t<e.length;t++)n+=e[t][1];return n}const t=13,o=45,r=10,i=43,s=65533;function checkIfFourCodePointsWouldStartCDO(e){return 60===e.source.codePointAt(e.cursor)&&33===e.source.codePointAt(e.cursor+1)&&e.source.codePointAt(e.cursor+2)===o&&e.source.codePointAt(e.cursor+3)===o}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===o}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 isNonPrintableCodePoint(e){return 11===e||127===e||0<=e&&e<=8||14<=e&&e<=31}function isNewLine(e){return e===r||e===t||12===e}function isWhitespace(e){return 32===e||e===r||9===e||e===t||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)===o?n.source.codePointAt(n.cursor+1)===o||(!!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)===i||e.source.codePointAt(e.cursor)===o?!!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)===o&&e.source.codePointAt(e.cursor+1)===o&&62===e.source.codePointAt(e.cursor+2)}var c,a,u;function mirrorVariantType(e){switch(e){case c.OpenParen:return c.CloseParen;case c.CloseParen:return c.OpenParen;case c.OpenCurly:return c.CloseCurly;case c.CloseCurly:return c.OpenCurly;case c.OpenSquare:return c.CloseSquare;case c.CloseSquare:return c.OpenSquare;default:return null}}function mirrorVariant(e){switch(e[0]){case c.OpenParen:return[c.CloseParen,")",-1,-1,void 0];case c.CloseParen:return[c.OpenParen,"(",-1,-1,void 0];case c.OpenCurly:return[c.CloseCurly,"}",-1,-1,void 0];case c.CloseCurly:return[c.OpenCurly,"{",-1,-1,void 0];case c.OpenSquare:return[c.CloseSquare,"]",-1,-1,void 0];case c.CloseSquare:return[c.OpenSquare,"[",-1,-1,void 0];default:return null}}function consumeComment(n,t){for(t.advanceCodePoint(2);;){const o=t.readCodePoint();if(void 0===o){const o=[c.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInComment,t.representationStart,t.representationEnd,["4.3.2. Consume comments","Unexpected EOF"],o)),o}if(42===o&&(void 0!==t.source.codePointAt(t.cursor)&&47===t.source.codePointAt(t.cursor))){t.advanceCodePoint();break}}return[c.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function consumeEscapedCodePoint(n,o){const i=o.readCodePoint();if(void 0===i)return n.onParseError(new ParseError(e.UnexpectedEOFInEscapedCodePoint,o.representationStart,o.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),s;if(isHexDigitCodePoint(i)){const e=[i];let n;for(;void 0!==(n=o.source.codePointAt(o.cursor))&&isHexDigitCodePoint(n)&&e.length<6;)e.push(n),o.advanceCodePoint();isWhitespace(o.source.codePointAt(o.cursor)??-1)&&(o.source.codePointAt(o.cursor)===t&&o.source.codePointAt(o.cursor+1)===r&&o.advanceCodePoint(),o.advanceCodePoint());const c=parseInt(String.fromCodePoint(...e),16);return 0===c||isSurrogate(c)||c>1114111?s:c}return 0===i||isSurrogate(i)?s:i}function consumeIdentSequence(e,n){const t=[];for(;;){const o=n.source.codePointAt(n.cursor)??-1;if(0===o||isSurrogate(o))t.push(s),n.advanceCodePoint(+(o>65535)+1);else if(isIdentCodePoint(o))t.push(o),n.advanceCodePoint(+(o>65535)+1);else{if(!checkIfTwoCodePointsAreAValidEscape(n))return t;n.advanceCodePoint(),t.push(consumeEscapedCodePoint(e,n))}}}function consumeHashToken(e,n){n.advanceCodePoint();const t=n.source.codePointAt(n.cursor);if(void 0!==t&&(isIdentCodePoint(t)||checkIfTwoCodePointsAreAValidEscape(n))){let t=u.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)&&(t=u.ID);const o=consumeIdentSequence(e,n);return[c.Hash,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...o),type:t}]}return[c.Delim,"#",n.representationStart,n.representationEnd,{value:"#"}]}function consumeNumber(e,n){let t=a.Integer;for(n.source.codePointAt(n.cursor)!==i&&n.source.codePointAt(n.cursor)!==o||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),t=a.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)!==o&&n.source.codePointAt(n.cursor+1)!==i||!isDigitCodePoint(n.source.codePointAt(n.cursor+2)??-1))return t;n.advanceCodePoint(3)}for(t=a.Number;isDigitCodePoint(n.source.codePointAt(n.cursor)??-1);)n.advanceCodePoint()}return t}function consumeNumericToken(e,n){let t;{const e=n.source.codePointAt(n.cursor);e===o?t="-":e===i&&(t="+")}const r=consumeNumber(0,n),s=parseFloat(n.source.slice(n.representationStart,n.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,n)){const o=consumeIdentSequence(e,n);return[c.Dimension,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:s,signCharacter:t,type:r,unit:String.fromCodePoint(...o)}]}return 37===n.source.codePointAt(n.cursor)?(n.advanceCodePoint(),[c.Percentage,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:s,signCharacter:t}]):[c.Number,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:s,signCharacter:t,type:r}]}function consumeWhiteSpace(e){for(;isWhitespace(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[c.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}!function(e){e.Comment="comment",e.AtKeyword="at-keyword-token",e.BadString="bad-string-token",e.BadURL="bad-url-token",e.CDC="CDC-token",e.CDO="CDO-token",e.Colon="colon-token",e.Comma="comma-token",e.Delim="delim-token",e.Dimension="dimension-token",e.EOF="EOF-token",e.Function="function-token",e.Hash="hash-token",e.Ident="ident-token",e.Number="number-token",e.Percentage="percentage-token",e.Semicolon="semicolon-token",e.String="string-token",e.URL="url-token",e.Whitespace="whitespace-token",e.OpenParen="(-token",e.CloseParen=")-token",e.OpenSquare="[-token",e.CloseSquare="]-token",e.OpenCurly="{-token",e.CloseCurly="}-token",e.UnicodeRange="unicode-range-token"}(c||(c={})),function(e){e.Integer="integer",e.Number="number"}(a||(a={})),function(e){e.Unrestricted="unrestricted",e.ID="id"}(u||(u={}));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,o){let i="";const a=o.readCodePoint();for(;;){const u=o.readCodePoint();if(void 0===u){const t=[c.String,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:i}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInString,o.representationStart,o.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"],t)),t}if(isNewLine(u)){o.unreadCodePoint();const i=[c.BadString,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedNewLineInString,o.representationStart,o.source.codePointAt(o.cursor)===t&&o.source.codePointAt(o.cursor+1)===r?o.representationEnd+2:o.representationEnd+1,["4.3.5. Consume a string token","Unexpected newline"],i)),i}if(u===a)return[c.String,o.source.slice(o.representationStart,o.representationEnd+1),o.representationStart,o.representationEnd,{value:i}];if(92!==u)0===u||isSurrogate(u)?i+=String.fromCodePoint(s):i+=String.fromCodePoint(u);else{if(void 0===o.source.codePointAt(o.cursor))continue;if(isNewLine(o.source.codePointAt(o.cursor)??-1)){o.source.codePointAt(o.cursor)===t&&o.source.codePointAt(o.cursor+1)===r&&o.advanceCodePoint(),o.advanceCodePoint();continue}i+=String.fromCodePoint(consumeEscapedCodePoint(n,o))}}}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 t=n.source.codePointAt(n.cursor);if(void 0===t)return;if(41===t)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint()}}function consumeUrlToken(n,t){for(;isWhitespace(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let o="";for(;;){if(void 0===t.source.codePointAt(t.cursor)){const r=[c.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:o}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,t.representationStart,t.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"],r)),r}if(41===t.source.codePointAt(t.cursor))return t.advanceCodePoint(),[c.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:o}];if(isWhitespace(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();isWhitespace(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(void 0===t.source.codePointAt(t.cursor)){const r=[c.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:o}];return n.onParseError(new ParseErrorWithToken(e.UnexpectedEOFInURL,t.representationStart,t.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"],r)),r}return 41===t.source.codePointAt(t.cursor)?(t.advanceCodePoint(),[c.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:o}]):(consumeBadURL(n,t),[c.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0])}const r=t.source.codePointAt(t.cursor);if(34===r||39===r||40===r||isNonPrintableCodePoint(r??-1)){consumeBadURL(n,t);const o=[c.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.UnexpectedCharacterInURL,t.representationStart,t.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"],o)),o}if(92===r){if(checkIfTwoCodePointsAreAValidEscape(t)){t.advanceCodePoint(),o+=String.fromCodePoint(consumeEscapedCodePoint(n,t));continue}consumeBadURL(n,t);const r=[c.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return n.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceInURL,t.representationStart,t.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===t.source.codePointAt(t.cursor)||isSurrogate(t.source.codePointAt(t.cursor)??-1)?(o+=String.fromCodePoint(s),t.advanceCodePoint()):(o+=t.source[t.cursor],t.advanceCodePoint())}}function consumeIdentLikeToken(e,n){const t=consumeIdentSequence(e,n);if(40!==n.source.codePointAt(n.cursor))return[c.Ident,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t)}];if(checkIfCodePointsMatchURLIdent(t)){n.advanceCodePoint();let o=0;for(;;){const e=isWhitespace(n.source.codePointAt(n.cursor)??-1),r=isWhitespace(n.source.codePointAt(n.cursor+1)??-1);if(e&&r){o+=1,n.advanceCodePoint(1);continue}const i=e?n.source.codePointAt(n.cursor+1):n.source.codePointAt(n.cursor);if(34===i||39===i)return o>0&&n.unreadCodePoint(o),[c.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t)}];break}return consumeUrlToken(e,n)}return n.advanceCodePoint(),[c.Function,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{value:String.fromCodePoint(...t)}]}function checkIfThreeCodePointsWouldStartAUnicodeRange(e){return!(117!==e.source.codePointAt(e.cursor)&&85!==e.source.codePointAt(e.cursor)||e.source.codePointAt(e.cursor+1)!==i||63!==e.source.codePointAt(e.cursor+2)&&!isHexDigitCodePoint(e.source.codePointAt(e.cursor+2)??-1))}function consumeUnicodeRangeToken(e,n){n.advanceCodePoint(2);const t=[],r=[];let i;for(;void 0!==(i=n.source.codePointAt(n.cursor))&&t.length<6&&isHexDigitCodePoint(i);)t.push(i),n.advanceCodePoint();for(;void 0!==(i=n.source.codePointAt(n.cursor))&&t.length<6&&63===i;)0===r.length&&r.push(...t),t.push(48),r.push(70),n.advanceCodePoint();if(!r.length&&n.source.codePointAt(n.cursor)===o&&isHexDigitCodePoint(n.source.codePointAt(n.cursor+1)??-1))for(n.advanceCodePoint();void 0!==(i=n.source.codePointAt(n.cursor))&&r.length<6&&isHexDigitCodePoint(i);)r.push(i),n.advanceCodePoint();if(!r.length){const e=parseInt(String.fromCodePoint(...t),16);return[c.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:e,endOfRange:e}]}const s=parseInt(String.fromCodePoint(...t),16),a=parseInt(String.fromCodePoint(...r),16);return[c.UnicodeRange,n.source.slice(n.representationStart,n.representationEnd+1),n.representationStart,n.representationEnd,{startOfRange:s,endOfRange:a}]}function tokenize(e,n){const t=tokenizer(e,n),o=[];for(;!t.endOfFile();)o.push(t.nextToken());return o.push(t.nextToken()),o}function tokenizer(n,s){const a=n.css.valueOf(),u=n.unicodeRangesAllowed??!1,d=new Reader(a),p={onParseError:s?.onParseError??noop};return{nextToken:function nextToken(){d.resetRepresentation();const n=d.source.codePointAt(d.cursor);if(void 0===n)return[c.EOF,"",-1,-1,void 0];if(47===n&&checkIfTwoCodePointsStartAComment(d))return consumeComment(p,d);if(u&&(117===n||85===n)&&checkIfThreeCodePointsWouldStartAUnicodeRange(d))return consumeUnicodeRangeToken(0,d);if(isIdentStartCodePoint(n))return consumeIdentLikeToken(p,d);if(isDigitCodePoint(n))return consumeNumericToken(p,d);switch(n){case 44:return d.advanceCodePoint(),[c.Comma,",",d.representationStart,d.representationEnd,void 0];case 58:return d.advanceCodePoint(),[c.Colon,":",d.representationStart,d.representationEnd,void 0];case 59:return d.advanceCodePoint(),[c.Semicolon,";",d.representationStart,d.representationEnd,void 0];case 40:return d.advanceCodePoint(),[c.OpenParen,"(",d.representationStart,d.representationEnd,void 0];case 41:return d.advanceCodePoint(),[c.CloseParen,")",d.representationStart,d.representationEnd,void 0];case 91:return d.advanceCodePoint(),[c.OpenSquare,"[",d.representationStart,d.representationEnd,void 0];case 93:return d.advanceCodePoint(),[c.CloseSquare,"]",d.representationStart,d.representationEnd,void 0];case 123:return d.advanceCodePoint(),[c.OpenCurly,"{",d.representationStart,d.representationEnd,void 0];case 125:return d.advanceCodePoint(),[c.CloseCurly,"}",d.representationStart,d.representationEnd,void 0];case 39:case 34:return consumeStringToken(p,d);case 35:return consumeHashToken(p,d);case i:case 46:return checkIfThreeCodePointsWouldStartANumber(d)?consumeNumericToken(p,d):(d.advanceCodePoint(),[c.Delim,d.source[d.representationStart],d.representationStart,d.representationEnd,{value:d.source[d.representationStart]}]);case r:case t:case 12:case 9:case 32:return consumeWhiteSpace(d);case o:return checkIfThreeCodePointsWouldStartANumber(d)?consumeNumericToken(p,d):checkIfThreeCodePointsWouldStartCDC(d)?(d.advanceCodePoint(3),[c.CDC,"--\x3e",d.representationStart,d.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,d)?consumeIdentLikeToken(p,d):(d.advanceCodePoint(),[c.Delim,"-",d.representationStart,d.representationEnd,{value:"-"}]);case 60:return checkIfFourCodePointsWouldStartCDO(d)?(d.advanceCodePoint(4),[c.CDO,"\x3c!--",d.representationStart,d.representationEnd,void 0]):(d.advanceCodePoint(),[c.Delim,"<",d.representationStart,d.representationEnd,{value:"<"}]);case 64:if(d.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,d)){const e=consumeIdentSequence(p,d);return[c.AtKeyword,d.source.slice(d.representationStart,d.representationEnd+1),d.representationStart,d.representationEnd,{value:String.fromCodePoint(...e)}]}return[c.Delim,"@",d.representationStart,d.representationEnd,{value:"@"}];case 92:{if(checkIfTwoCodePointsAreAValidEscape(d))return consumeIdentLikeToken(p,d);d.advanceCodePoint();const n=[c.Delim,"\\",d.representationStart,d.representationEnd,{value:"\\"}];return p.onParseError(new ParseErrorWithToken(e.InvalidEscapeSequenceAfterBackslash,d.representationStart,d.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 d.advanceCodePoint(),[c.Delim,d.source[d.representationStart],d.representationStart,d.representationEnd,{value:d.source[d.representationStart]}]},endOfFile:function endOfFile(){return void 0===d.source.codePointAt(d.cursor)}}}function noop(){}function mutateIdent(e,n){const t=[];for(const e of n)t.push(e.codePointAt(0));const o=String.fromCodePoint(...serializeIdent(t));e[1]=o,e[4].value=n}function mutateUnit(e,n){const t=[];for(const e of n)t.push(e.codePointAt(0));const o=serializeIdent(t);101===o[0]&&insertEscapedCodePoint(o,0,o[0]);const r=String.fromCodePoint(...o),i="+"===e[4].signCharacter?e[4].signCharacter:"",s=e[4].value.toString();e[1]=`${i}${s}${r}`,e[4].unit=n}function serializeIdent(e){let n=0;if(0===e[0])e.splice(0,1,s),n=1;else if(e[0]===o&&e[1]===o)n=2;else if(e[0]===o&&e[1])n=2,isIdentStartCodePoint(e[1])||(n+=insertEscapedCodePoint(e,1,e[1]));else{if(e[0]===o&&!e[1])return[92,e[0]];isIdentStartCodePoint(e[0])?n=1:(n=1,n+=insertEscapedCodePoint(e,0,e[0]))}for(let t=n;t<e.length;t++)0!==e[t]?isIdentCodePoint(e[t])||(t+=insertEscapedCharacter(e,t,e[t])):(e.splice(t,1,s),t++);return e}function insertEscapedCharacter(e,n,t){return e.splice(n,1,92,t),1}function insertEscapedCodePoint(e,n,t){const o=t.toString(16),r=[];for(const e of o)r.push(e.codePointAt(0));return e.splice(n,1,92,...r,32),1+r.length}const d=Object.values(c);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]))))}function isTokenNumeric(e){if(!e)return!1;switch(e[0]){case c.Dimension:case c.Number:case c.Percentage:return!0;default:return!1}}function isTokenWhiteSpaceOrComment(e){if(!e)return!1;switch(e[0]){case c.Whitespace:case c.Comment:return!0;default:return!1}}function isTokenAtKeyword(e){return!!e&&e[0]===c.AtKeyword}function isTokenBadString(e){return!!e&&e[0]===c.BadString}function isTokenBadURL(e){return!!e&&e[0]===c.BadURL}function isTokenCDC(e){return!!e&&e[0]===c.CDC}function isTokenCDO(e){return!!e&&e[0]===c.CDO}function isTokenColon(e){return!!e&&e[0]===c.Colon}function isTokenComma(e){return!!e&&e[0]===c.Comma}function isTokenComment(e){return!!e&&e[0]===c.Comment}function isTokenDelim(e){return!!e&&e[0]===c.Delim}function isTokenDimension(e){return!!e&&e[0]===c.Dimension}function isTokenEOF(e){return!!e&&e[0]===c.EOF}function isTokenFunction(e){return!!e&&e[0]===c.Function}function isTokenHash(e){return!!e&&e[0]===c.Hash}function isTokenIdent(e){return!!e&&e[0]===c.Ident}function isTokenNumber(e){return!!e&&e[0]===c.Number}function isTokenPercentage(e){return!!e&&e[0]===c.Percentage}function isTokenSemicolon(e){return!!e&&e[0]===c.Semicolon}function isTokenString(e){return!!e&&e[0]===c.String}function isTokenURL(e){return!!e&&e[0]===c.URL}function isTokenWhitespace(e){return!!e&&e[0]===c.Whitespace}function isTokenOpenParen(e){return!!e&&e[0]===c.OpenParen}function isTokenCloseParen(e){return!!e&&e[0]===c.CloseParen}function isTokenOpenSquare(e){return!!e&&e[0]===c.OpenSquare}function isTokenCloseSquare(e){return!!e&&e[0]===c.CloseSquare}function isTokenOpenCurly(e){return!!e&&e[0]===c.OpenCurly}function isTokenCloseCurly(e){return!!e&&e[0]===c.CloseCurly}function isTokenUnicodeRange(e){return!!e&&e[0]===c.UnicodeRange}export{u as HashType,a as NumberType,ParseError,e as ParseErrorMessage,ParseErrorWithToken,c as TokenType,cloneTokens,isToken,isTokenAtKeyword,isTokenBadString,isTokenBadURL,isTokenCDC,isTokenCDO,isTokenCloseCurly,isTokenCloseParen,isTokenCloseSquare,isTokenColon,isTokenComma,isTokenComment,isTokenDelim,isTokenDimension,isTokenEOF,isTokenFunction,isTokenHash,isTokenIdent,isTokenNumber,isTokenNumeric,isTokenOpenCurly,isTokenOpenParen,isTokenOpenSquare,isTokenPercentage,isTokenSemicolon,isTokenString,isTokenURL,isTokenUnicodeRange,isTokenWhiteSpaceOrComment,isTokenWhitespace,mirrorVariant,mirrorVariantType,mutateIdent,mutateUnit,stringify,tokenize,tokenizer};
node_modules/@csstools/css-tokenizer/package.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-tokenizer",
3
+ "description": "Tokenize CSS",
4
+ "version": "4.0.0",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "engines": {
28
+ "node": ">=20.19.0"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.mjs"
35
+ }
36
+ },
37
+ "files": [
38
+ "CHANGELOG.md",
39
+ "LICENSE.md",
40
+ "README.md",
41
+ "dist"
42
+ ],
43
+ "scripts": {},
44
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer#readme",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
48
+ "directory": "packages/css-tokenizer"
49
+ },
50
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
51
+ "keywords": [
52
+ "css",
53
+ "tokenizer"
54
+ ]
55
+ }
node_modules/@emnapi/core/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Toyobayashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/@emnapi/core/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ See [https://github.com/toyobayashi/emnapi](https://github.com/toyobayashi/emnapi)
node_modules/@emnapi/core/dist/emnapi-core.cjs.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/dist/emnapi-core.cjs.min.d.ts ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ import type { Context } from '@emnapi/runtime';
4
+ import type { ReferenceOwnership } from '@emnapi/runtime';
5
+ import type { Worker as Worker_2 } from 'worker_threads';
6
+
7
+ /** @public */
8
+ export declare type BaseCreateOptions = {
9
+ filename?: string
10
+ nodeBinding?: NodeBinding
11
+ reuseWorker?: ThreadManagerOptionsMain['reuseWorker']
12
+ asyncWorkPoolSize?: number
13
+ waitThreadStart?: MainThreadBaseOptions['waitThreadStart']
14
+ onCreateWorker?: (info: CreateWorkerInfo) => any
15
+ print?: (str: string) => void
16
+ printErr?: (str: string) => void
17
+ postMessage?: (msg: any) => any
18
+ }
19
+
20
+ /** @public */
21
+ export declare interface BaseOptions {
22
+ wasi: WASIInstance;
23
+ version?: 'preview1';
24
+ wasm64?: boolean;
25
+ }
26
+
27
+ /** @public */
28
+ export declare interface ChildThreadOptions extends BaseOptions {
29
+ childThread: true;
30
+ postMessage?: (data: any) => void;
31
+ }
32
+
33
+ /** @public */
34
+ export declare interface CleanupThreadPayload {
35
+ tid: number;
36
+ }
37
+
38
+ /** @public */
39
+ export declare interface CommandInfo<T extends CommandType> {
40
+ type: T;
41
+ payload: CommandPayloadMap[T];
42
+ }
43
+
44
+ /** @public */
45
+ export declare interface CommandPayloadMap {
46
+ load: LoadPayload;
47
+ loaded: LoadedPayload;
48
+ start: StartPayload;
49
+ 'cleanup-thread': CleanupThreadPayload;
50
+ 'terminate-all-threads': TerminateAllThreadsPayload;
51
+ 'spawn-thread': SpawnThreadPayload;
52
+ }
53
+
54
+ /** @public */
55
+ export declare type CommandType = keyof CommandPayloadMap;
56
+
57
+ /** @public */
58
+ export declare function createInstanceProxy(instance: WebAssembly.Instance, memory?: WebAssembly.Memory | (() => WebAssembly.Memory)): WebAssembly.Instance;
59
+
60
+ /** @public */
61
+ export declare function createNapiModule (
62
+ options: CreateOptions
63
+ ): NapiModule
64
+
65
+ /** @public */
66
+ export declare type CreateOptions = BaseCreateOptions & ({
67
+ context: Context
68
+ childThread?: boolean
69
+ } | {
70
+ context?: Context
71
+ childThread: true
72
+ })
73
+
74
+ /** @public */
75
+ export declare interface CreateWorkerInfo {
76
+ type: 'thread' | 'async-work'
77
+ name: string
78
+ }
79
+
80
+ /** @public */
81
+ export declare interface InitOptions {
82
+ instance: WebAssembly.Instance
83
+ module: WebAssembly.Module
84
+ memory?: WebAssembly.Memory
85
+ table?: WebAssembly.Table
86
+ }
87
+
88
+ export declare type InputType = string | URL | Response | BufferSource | WebAssembly.Module;
89
+
90
+ /** @public */
91
+ export declare interface InstantiatedSource extends LoadedSource {
92
+ napiModule: NapiModule;
93
+ }
94
+
95
+ /** @public */
96
+ export declare function instantiateNapiModule(
97
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
98
+ wasmInput: InputType | Promise<InputType>, options: InstantiateOptions): Promise<InstantiatedSource>;
99
+
100
+ /** @public */
101
+ export declare function instantiateNapiModuleSync(wasmInput: BufferSource | WebAssembly.Module, options: InstantiateOptions): InstantiatedSource;
102
+
103
+ /** @public */
104
+ export declare type InstantiateOptions = CreateOptions & LoadOptions;
105
+
106
+ /** @public */
107
+ export declare function isSharedArrayBuffer(value: any): value is SharedArrayBuffer;
108
+
109
+ /** @public */
110
+ export declare function isTrapError(e: Error): e is WebAssembly.RuntimeError;
111
+
112
+ /** @public */
113
+ export declare interface LoadedPayload {
114
+ }
115
+
116
+ /** @public */
117
+ export declare interface LoadedSource extends WebAssembly.WebAssemblyInstantiatedSource {
118
+ usedInstance: WebAssembly.Instance;
119
+ }
120
+
121
+ /** @public */
122
+ export declare function loadNapiModule(napiModule: NapiModule,
123
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
124
+ wasmInput: InputType | Promise<InputType>, options?: LoadOptions): Promise<LoadedSource>;
125
+
126
+ /** @public */
127
+ export declare function loadNapiModuleSync(napiModule: NapiModule, wasmInput: BufferSource | WebAssembly.Module, options?: LoadOptions): LoadedSource;
128
+
129
+ /** @public */
130
+ export declare interface LoadOptions {
131
+ wasi?: WASIInstance;
132
+ overwriteImports?: (importObject: WebAssembly.Imports) => WebAssembly.Imports;
133
+ beforeInit?: (source: WebAssembly.WebAssemblyInstantiatedSource) => void;
134
+ getMemory?: (exports: WebAssembly.Exports) => WebAssembly.Memory;
135
+ getTable?: (exports: WebAssembly.Exports) => WebAssembly.Table;
136
+ }
137
+
138
+ /** @public */
139
+ export declare interface LoadPayload {
140
+ wasmModule: WebAssembly.Module;
141
+ wasmMemory: WebAssembly.Memory;
142
+ sab?: Int32Array;
143
+ }
144
+
145
+ /** @public */
146
+ export declare interface MainThreadBaseOptions extends BaseOptions {
147
+ waitThreadStart?: boolean | number;
148
+ }
149
+
150
+ /** @public */
151
+ export declare type MainThreadOptions = MainThreadOptionsWithThreadManager | MainThreadOptionsCreateThreadManager;
152
+
153
+ /** @public */
154
+ export declare interface MainThreadOptionsCreateThreadManager extends MainThreadBaseOptions, ThreadManagerOptionsMain {
155
+ }
156
+
157
+ /** @public */
158
+ export declare interface MainThreadOptionsWithThreadManager extends MainThreadBaseOptions {
159
+ threadManager?: ThreadManager | (() => ThreadManager);
160
+ }
161
+
162
+ /** @public */
163
+ export declare interface MessageEventData<T extends CommandType> {
164
+ __emnapi__: CommandInfo<T>;
165
+ }
166
+
167
+ /** @public */
168
+ export declare class MessageHandler extends ThreadMessageHandler {
169
+ napiModule: NapiModule | undefined;
170
+ constructor(options: MessageHandlerOptions);
171
+ instantiate(data: LoadPayload): InstantiatedSource | PromiseLike<InstantiatedSource>;
172
+ handle(e: WorkerMessageEvent): void;
173
+ }
174
+
175
+ /** @public */
176
+ export declare interface MessageHandlerOptions extends ThreadMessageHandlerOptions {
177
+ onLoad: (data: LoadPayload) => InstantiatedSource | PromiseLike<InstantiatedSource>;
178
+ }
179
+
180
+ /** @public */
181
+ export declare interface NapiModule {
182
+ imports: {
183
+ env: any
184
+ napi: any
185
+ emnapi: any
186
+ }
187
+ exports: any
188
+ loaded: boolean
189
+ filename: string
190
+ childThread: boolean
191
+ emnapi: {
192
+ syncMemory<T extends ArrayBuffer | ArrayBufferView> (
193
+ js_to_wasm: boolean,
194
+ arrayBufferOrView: T,
195
+ offset?: number,
196
+ len?: number
197
+ ): T
198
+ getMemoryAddress (arrayBufferOrView: ArrayBuffer | ArrayBufferView): PointerInfo
199
+ addSendListener (worker: any): boolean
200
+ }
201
+
202
+ init (options: InitOptions): any
203
+ initWorker (arg: number, func: [number, number]): void
204
+ postMessage?: (msg: any) => any
205
+
206
+ waitThreadStart: boolean | number
207
+ /* Excluded from this release type: PThread */}
208
+
209
+ /** @public */
210
+ export declare interface NodeBinding {
211
+ node: {
212
+ emitAsyncInit: Function
213
+ emitAsyncDestroy: Function
214
+ makeCallback: Function
215
+ }
216
+ napi: {
217
+ asyncInit: Function
218
+ asyncDestroy: Function
219
+ makeCallback: Function
220
+ }
221
+ }
222
+
223
+ /** @public */
224
+ export declare interface PointerInfo {
225
+ address: number
226
+ ownership: ReferenceOwnership
227
+ runtimeAllocated: 0 | 1
228
+ }
229
+
230
+ /** @public */
231
+ export declare interface ReuseWorkerOptions {
232
+ /**
233
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size | PTHREAD_POOL_SIZE}
234
+ */
235
+ size: number;
236
+ /**
237
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size-strict | PTHREAD_POOL_SIZE_STRICT}
238
+ */
239
+ strict?: boolean;
240
+ }
241
+
242
+ /** @public */
243
+ export declare interface SpawnThreadPayload {
244
+ startArg: number;
245
+ errorOrTid: number;
246
+ }
247
+
248
+ /** @public */
249
+ export declare interface StartPayload {
250
+ tid: number;
251
+ arg: number;
252
+ sab?: Int32Array;
253
+ }
254
+
255
+ /** @public */
256
+ export declare interface StartResult {
257
+ exitCode: number;
258
+ instance: WebAssembly.Instance;
259
+ }
260
+
261
+ /** @public */
262
+ export declare interface TerminateAllThreadsPayload {
263
+ }
264
+
265
+ /** @public */
266
+ export declare class ThreadManager {
267
+ unusedWorkers: WorkerLike[];
268
+ runningWorkers: WorkerLike[];
269
+ pthreads: Record<number, WorkerLike>;
270
+ get nextWorkerID(): number;
271
+ wasmModule: WebAssembly.Module | null;
272
+ wasmMemory: WebAssembly.Memory | null;
273
+ private readonly messageEvents;
274
+ private readonly _childThread;
275
+ private readonly _onCreateWorker;
276
+ private readonly _reuseWorker;
277
+ private readonly _beforeLoad?;
278
+ /* Excluded from this release type: printErr */
279
+ threadSpawn?: ((startArg: number, errorOrTid?: number) => number);
280
+ constructor(options: ThreadManagerOptions);
281
+ init(): void;
282
+ initMainThread(): void;
283
+ private preparePool;
284
+ shouldPreloadWorkers(): boolean;
285
+ loadWasmModuleToAllWorkers(): Promise<WorkerLike[]>;
286
+ preloadWorkers(): Promise<WorkerLike[]>;
287
+ setup(wasmModule: WebAssembly.Module, wasmMemory: WebAssembly.Memory): void;
288
+ markId(worker: WorkerLike): number;
289
+ returnWorkerToPool(worker: WorkerLike): void;
290
+ loadWasmModuleToWorker(worker: WorkerLike, sab?: Int32Array): Promise<WorkerLike>;
291
+ allocateUnusedWorker(): WorkerLike;
292
+ getNewWorker(sab?: Int32Array): WorkerLike | undefined;
293
+ cleanThread(worker: WorkerLike, tid: number, force?: boolean): void;
294
+ terminateWorker(worker: WorkerLike): void;
295
+ terminateAllThreads(): void;
296
+ addMessageEventListener(worker: WorkerLike, onMessage: (e: WorkerMessageEvent) => void): () => void;
297
+ fireMessageEvent(worker: WorkerLike, e: WorkerMessageEvent): void;
298
+ }
299
+
300
+ /** @public */
301
+ export declare type ThreadManagerOptions = ThreadManagerOptionsMain | ThreadManagerOptionsChild;
302
+
303
+ /** @public */
304
+ export declare interface ThreadManagerOptionsBase {
305
+ printErr?: (message: string) => void;
306
+ threadSpawn?: (startArg: number, errorOrTid?: number) => number;
307
+ }
308
+
309
+ /** @public */
310
+ export declare interface ThreadManagerOptionsChild extends ThreadManagerOptionsBase {
311
+ childThread: true;
312
+ }
313
+
314
+ /** @public */
315
+ export declare interface ThreadManagerOptionsMain extends ThreadManagerOptionsBase {
316
+ beforeLoad?: (worker: WorkerLike) => any;
317
+ reuseWorker?: boolean | number | ReuseWorkerOptions;
318
+ onCreateWorker: WorkerFactory;
319
+ childThread?: false;
320
+ }
321
+
322
+ /** @public */
323
+ export declare class ThreadMessageHandler {
324
+ protected instance: WebAssembly.Instance | undefined;
325
+ private messagesBeforeLoad;
326
+ protected postMessage: (message: any) => void;
327
+ protected onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
328
+ protected onError: (error: Error, type: WorkerMessageType) => void;
329
+ constructor(options?: ThreadMessageHandlerOptions);
330
+ /** @virtual */
331
+ instantiate(data: LoadPayload): WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
332
+ /** @virtual */
333
+ handle(e: WorkerMessageEvent<MessageEventData<WorkerMessageType>>): void;
334
+ private _load;
335
+ private _start;
336
+ protected _loaded(err: Error | null, source: WebAssembly.WebAssemblyInstantiatedSource | null, payload: LoadPayload): void;
337
+ protected handleAfterLoad<E extends WorkerMessageEvent>(e: E, f: (e: E) => void): void;
338
+ }
339
+
340
+ /** @public */
341
+ export declare interface ThreadMessageHandlerOptions {
342
+ onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
343
+ onError?: (error: Error, type: WorkerMessageType) => void;
344
+ postMessage?: (message: any) => void;
345
+ }
346
+
347
+ export declare const version: string;
348
+
349
+ /** @public */
350
+ export declare interface WASIInstance {
351
+ readonly wasiImport?: Record<string, any>;
352
+ initialize(instance: object): void;
353
+ start(instance: object): number;
354
+ getImportObject?(): any;
355
+ }
356
+
357
+ /** @public */
358
+ export declare class WASIThreads {
359
+ PThread: ThreadManager | undefined;
360
+ private wasmMemory;
361
+ private wasmInstance;
362
+ private readonly threadSpawn;
363
+ readonly childThread: boolean;
364
+ private readonly postMessage;
365
+ readonly wasi: WASIInstance;
366
+ constructor(options: WASIThreadsOptions);
367
+ getImportObject(): {
368
+ wasi: WASIThreadsImports;
369
+ };
370
+ setup(wasmInstance: WebAssembly.Instance, wasmModule: WebAssembly.Module, wasmMemory?: WebAssembly.Memory): void;
371
+ preloadWorkers(): Promise<WorkerLike[]>;
372
+ /**
373
+ * It's ok to call this method to a WASI command module.
374
+ *
375
+ * in child thread, must call this method instead of {@link WASIThreads.start} even if it's a WASI command module
376
+ *
377
+ * @returns A proxied WebAssembly instance if in child thread, other wise the original instance
378
+ */
379
+ initialize(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): WebAssembly.Instance;
380
+ /**
381
+ * Equivalent to calling {@link WASIThreads.initialize} and then calling {@link WASIInstance.start}
382
+ * ```js
383
+ * this.initialize(instance, module, memory)
384
+ * this.wasi.start(instance)
385
+ * ```
386
+ */
387
+ start(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): StartResult;
388
+ terminateAllThreads(): void;
389
+ }
390
+
391
+ /** @public */
392
+ export declare interface WASIThreadsImports {
393
+ 'thread-spawn': (startArg: number, errorOrTid?: number) => number;
394
+ }
395
+
396
+ /** @public */
397
+ export declare type WASIThreadsOptions = MainThreadOptions | ChildThreadOptions;
398
+
399
+ /** @public */
400
+ export declare type WorkerFactory = (ctx: {
401
+ type: string;
402
+ name: string;
403
+ }) => WorkerLike;
404
+
405
+ /** @public */
406
+ export declare type WorkerLike = (Worker | Worker_2) & {
407
+ whenLoaded?: Promise<WorkerLike>;
408
+ loaded?: boolean;
409
+ __emnapi_tid?: number;
410
+ };
411
+
412
+ /** @public */
413
+ export declare interface WorkerMessageEvent<T = any> {
414
+ data: T;
415
+ }
416
+
417
+ /** @public */
418
+ export declare type WorkerMessageType = 'load' | 'start';
419
+
420
+ export { }
node_modules/@emnapi/core/dist/emnapi-core.cjs.min.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/dist/emnapi-core.d.mts ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ import type { Context } from '@emnapi/runtime';
4
+ import type { ReferenceOwnership } from '@emnapi/runtime';
5
+ import type { Worker as Worker_2 } from 'worker_threads';
6
+
7
+ /** @public */
8
+ export declare type BaseCreateOptions = {
9
+ filename?: string
10
+ nodeBinding?: NodeBinding
11
+ reuseWorker?: ThreadManagerOptionsMain['reuseWorker']
12
+ asyncWorkPoolSize?: number
13
+ waitThreadStart?: MainThreadBaseOptions['waitThreadStart']
14
+ onCreateWorker?: (info: CreateWorkerInfo) => any
15
+ print?: (str: string) => void
16
+ printErr?: (str: string) => void
17
+ postMessage?: (msg: any) => any
18
+ }
19
+
20
+ /** @public */
21
+ export declare interface BaseOptions {
22
+ wasi: WASIInstance;
23
+ version?: 'preview1';
24
+ wasm64?: boolean;
25
+ }
26
+
27
+ /** @public */
28
+ export declare interface ChildThreadOptions extends BaseOptions {
29
+ childThread: true;
30
+ postMessage?: (data: any) => void;
31
+ }
32
+
33
+ /** @public */
34
+ export declare interface CleanupThreadPayload {
35
+ tid: number;
36
+ }
37
+
38
+ /** @public */
39
+ export declare interface CommandInfo<T extends CommandType> {
40
+ type: T;
41
+ payload: CommandPayloadMap[T];
42
+ }
43
+
44
+ /** @public */
45
+ export declare interface CommandPayloadMap {
46
+ load: LoadPayload;
47
+ loaded: LoadedPayload;
48
+ start: StartPayload;
49
+ 'cleanup-thread': CleanupThreadPayload;
50
+ 'terminate-all-threads': TerminateAllThreadsPayload;
51
+ 'spawn-thread': SpawnThreadPayload;
52
+ }
53
+
54
+ /** @public */
55
+ export declare type CommandType = keyof CommandPayloadMap;
56
+
57
+ /** @public */
58
+ export declare function createInstanceProxy(instance: WebAssembly.Instance, memory?: WebAssembly.Memory | (() => WebAssembly.Memory)): WebAssembly.Instance;
59
+
60
+ /** @public */
61
+ export declare function createNapiModule (
62
+ options: CreateOptions
63
+ ): NapiModule
64
+
65
+ /** @public */
66
+ export declare type CreateOptions = BaseCreateOptions & ({
67
+ context: Context
68
+ childThread?: boolean
69
+ } | {
70
+ context?: Context
71
+ childThread: true
72
+ })
73
+
74
+ /** @public */
75
+ export declare interface CreateWorkerInfo {
76
+ type: 'thread' | 'async-work'
77
+ name: string
78
+ }
79
+
80
+ /** @public */
81
+ export declare interface InitOptions {
82
+ instance: WebAssembly.Instance
83
+ module: WebAssembly.Module
84
+ memory?: WebAssembly.Memory
85
+ table?: WebAssembly.Table
86
+ }
87
+
88
+ export declare type InputType = string | URL | Response | BufferSource | WebAssembly.Module;
89
+
90
+ /** @public */
91
+ export declare interface InstantiatedSource extends LoadedSource {
92
+ napiModule: NapiModule;
93
+ }
94
+
95
+ /** @public */
96
+ export declare function instantiateNapiModule(
97
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
98
+ wasmInput: InputType | Promise<InputType>, options: InstantiateOptions): Promise<InstantiatedSource>;
99
+
100
+ /** @public */
101
+ export declare function instantiateNapiModuleSync(wasmInput: BufferSource | WebAssembly.Module, options: InstantiateOptions): InstantiatedSource;
102
+
103
+ /** @public */
104
+ export declare type InstantiateOptions = CreateOptions & LoadOptions;
105
+
106
+ /** @public */
107
+ export declare function isSharedArrayBuffer(value: any): value is SharedArrayBuffer;
108
+
109
+ /** @public */
110
+ export declare function isTrapError(e: Error): e is WebAssembly.RuntimeError;
111
+
112
+ /** @public */
113
+ export declare interface LoadedPayload {
114
+ }
115
+
116
+ /** @public */
117
+ export declare interface LoadedSource extends WebAssembly.WebAssemblyInstantiatedSource {
118
+ usedInstance: WebAssembly.Instance;
119
+ }
120
+
121
+ /** @public */
122
+ export declare function loadNapiModule(napiModule: NapiModule,
123
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
124
+ wasmInput: InputType | Promise<InputType>, options?: LoadOptions): Promise<LoadedSource>;
125
+
126
+ /** @public */
127
+ export declare function loadNapiModuleSync(napiModule: NapiModule, wasmInput: BufferSource | WebAssembly.Module, options?: LoadOptions): LoadedSource;
128
+
129
+ /** @public */
130
+ export declare interface LoadOptions {
131
+ wasi?: WASIInstance;
132
+ overwriteImports?: (importObject: WebAssembly.Imports) => WebAssembly.Imports;
133
+ beforeInit?: (source: WebAssembly.WebAssemblyInstantiatedSource) => void;
134
+ getMemory?: (exports: WebAssembly.Exports) => WebAssembly.Memory;
135
+ getTable?: (exports: WebAssembly.Exports) => WebAssembly.Table;
136
+ }
137
+
138
+ /** @public */
139
+ export declare interface LoadPayload {
140
+ wasmModule: WebAssembly.Module;
141
+ wasmMemory: WebAssembly.Memory;
142
+ sab?: Int32Array;
143
+ }
144
+
145
+ /** @public */
146
+ export declare interface MainThreadBaseOptions extends BaseOptions {
147
+ waitThreadStart?: boolean | number;
148
+ }
149
+
150
+ /** @public */
151
+ export declare type MainThreadOptions = MainThreadOptionsWithThreadManager | MainThreadOptionsCreateThreadManager;
152
+
153
+ /** @public */
154
+ export declare interface MainThreadOptionsCreateThreadManager extends MainThreadBaseOptions, ThreadManagerOptionsMain {
155
+ }
156
+
157
+ /** @public */
158
+ export declare interface MainThreadOptionsWithThreadManager extends MainThreadBaseOptions {
159
+ threadManager?: ThreadManager | (() => ThreadManager);
160
+ }
161
+
162
+ /** @public */
163
+ export declare interface MessageEventData<T extends CommandType> {
164
+ __emnapi__: CommandInfo<T>;
165
+ }
166
+
167
+ /** @public */
168
+ export declare class MessageHandler extends ThreadMessageHandler {
169
+ napiModule: NapiModule | undefined;
170
+ constructor(options: MessageHandlerOptions);
171
+ instantiate(data: LoadPayload): InstantiatedSource | PromiseLike<InstantiatedSource>;
172
+ handle(e: WorkerMessageEvent): void;
173
+ }
174
+
175
+ /** @public */
176
+ export declare interface MessageHandlerOptions extends ThreadMessageHandlerOptions {
177
+ onLoad: (data: LoadPayload) => InstantiatedSource | PromiseLike<InstantiatedSource>;
178
+ }
179
+
180
+ /** @public */
181
+ export declare interface NapiModule {
182
+ imports: {
183
+ env: any
184
+ napi: any
185
+ emnapi: any
186
+ }
187
+ exports: any
188
+ loaded: boolean
189
+ filename: string
190
+ childThread: boolean
191
+ emnapi: {
192
+ syncMemory<T extends ArrayBuffer | ArrayBufferView> (
193
+ js_to_wasm: boolean,
194
+ arrayBufferOrView: T,
195
+ offset?: number,
196
+ len?: number
197
+ ): T
198
+ getMemoryAddress (arrayBufferOrView: ArrayBuffer | ArrayBufferView): PointerInfo
199
+ addSendListener (worker: any): boolean
200
+ }
201
+
202
+ init (options: InitOptions): any
203
+ initWorker (arg: number, func: [number, number]): void
204
+ postMessage?: (msg: any) => any
205
+
206
+ waitThreadStart: boolean | number
207
+ /* Excluded from this release type: PThread */}
208
+
209
+ /** @public */
210
+ export declare interface NodeBinding {
211
+ node: {
212
+ emitAsyncInit: Function
213
+ emitAsyncDestroy: Function
214
+ makeCallback: Function
215
+ }
216
+ napi: {
217
+ asyncInit: Function
218
+ asyncDestroy: Function
219
+ makeCallback: Function
220
+ }
221
+ }
222
+
223
+ /** @public */
224
+ export declare interface PointerInfo {
225
+ address: number
226
+ ownership: ReferenceOwnership
227
+ runtimeAllocated: 0 | 1
228
+ }
229
+
230
+ /** @public */
231
+ export declare interface ReuseWorkerOptions {
232
+ /**
233
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size | PTHREAD_POOL_SIZE}
234
+ */
235
+ size: number;
236
+ /**
237
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size-strict | PTHREAD_POOL_SIZE_STRICT}
238
+ */
239
+ strict?: boolean;
240
+ }
241
+
242
+ /** @public */
243
+ export declare interface SpawnThreadPayload {
244
+ startArg: number;
245
+ errorOrTid: number;
246
+ }
247
+
248
+ /** @public */
249
+ export declare interface StartPayload {
250
+ tid: number;
251
+ arg: number;
252
+ sab?: Int32Array;
253
+ }
254
+
255
+ /** @public */
256
+ export declare interface StartResult {
257
+ exitCode: number;
258
+ instance: WebAssembly.Instance;
259
+ }
260
+
261
+ /** @public */
262
+ export declare interface TerminateAllThreadsPayload {
263
+ }
264
+
265
+ /** @public */
266
+ export declare class ThreadManager {
267
+ unusedWorkers: WorkerLike[];
268
+ runningWorkers: WorkerLike[];
269
+ pthreads: Record<number, WorkerLike>;
270
+ get nextWorkerID(): number;
271
+ wasmModule: WebAssembly.Module | null;
272
+ wasmMemory: WebAssembly.Memory | null;
273
+ private readonly messageEvents;
274
+ private readonly _childThread;
275
+ private readonly _onCreateWorker;
276
+ private readonly _reuseWorker;
277
+ private readonly _beforeLoad?;
278
+ /* Excluded from this release type: printErr */
279
+ threadSpawn?: ((startArg: number, errorOrTid?: number) => number);
280
+ constructor(options: ThreadManagerOptions);
281
+ init(): void;
282
+ initMainThread(): void;
283
+ private preparePool;
284
+ shouldPreloadWorkers(): boolean;
285
+ loadWasmModuleToAllWorkers(): Promise<WorkerLike[]>;
286
+ preloadWorkers(): Promise<WorkerLike[]>;
287
+ setup(wasmModule: WebAssembly.Module, wasmMemory: WebAssembly.Memory): void;
288
+ markId(worker: WorkerLike): number;
289
+ returnWorkerToPool(worker: WorkerLike): void;
290
+ loadWasmModuleToWorker(worker: WorkerLike, sab?: Int32Array): Promise<WorkerLike>;
291
+ allocateUnusedWorker(): WorkerLike;
292
+ getNewWorker(sab?: Int32Array): WorkerLike | undefined;
293
+ cleanThread(worker: WorkerLike, tid: number, force?: boolean): void;
294
+ terminateWorker(worker: WorkerLike): void;
295
+ terminateAllThreads(): void;
296
+ addMessageEventListener(worker: WorkerLike, onMessage: (e: WorkerMessageEvent) => void): () => void;
297
+ fireMessageEvent(worker: WorkerLike, e: WorkerMessageEvent): void;
298
+ }
299
+
300
+ /** @public */
301
+ export declare type ThreadManagerOptions = ThreadManagerOptionsMain | ThreadManagerOptionsChild;
302
+
303
+ /** @public */
304
+ export declare interface ThreadManagerOptionsBase {
305
+ printErr?: (message: string) => void;
306
+ threadSpawn?: (startArg: number, errorOrTid?: number) => number;
307
+ }
308
+
309
+ /** @public */
310
+ export declare interface ThreadManagerOptionsChild extends ThreadManagerOptionsBase {
311
+ childThread: true;
312
+ }
313
+
314
+ /** @public */
315
+ export declare interface ThreadManagerOptionsMain extends ThreadManagerOptionsBase {
316
+ beforeLoad?: (worker: WorkerLike) => any;
317
+ reuseWorker?: boolean | number | ReuseWorkerOptions;
318
+ onCreateWorker: WorkerFactory;
319
+ childThread?: false;
320
+ }
321
+
322
+ /** @public */
323
+ export declare class ThreadMessageHandler {
324
+ protected instance: WebAssembly.Instance | undefined;
325
+ private messagesBeforeLoad;
326
+ protected postMessage: (message: any) => void;
327
+ protected onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
328
+ protected onError: (error: Error, type: WorkerMessageType) => void;
329
+ constructor(options?: ThreadMessageHandlerOptions);
330
+ /** @virtual */
331
+ instantiate(data: LoadPayload): WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
332
+ /** @virtual */
333
+ handle(e: WorkerMessageEvent<MessageEventData<WorkerMessageType>>): void;
334
+ private _load;
335
+ private _start;
336
+ protected _loaded(err: Error | null, source: WebAssembly.WebAssemblyInstantiatedSource | null, payload: LoadPayload): void;
337
+ protected handleAfterLoad<E extends WorkerMessageEvent>(e: E, f: (e: E) => void): void;
338
+ }
339
+
340
+ /** @public */
341
+ export declare interface ThreadMessageHandlerOptions {
342
+ onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
343
+ onError?: (error: Error, type: WorkerMessageType) => void;
344
+ postMessage?: (message: any) => void;
345
+ }
346
+
347
+ export declare const version: string;
348
+
349
+ /** @public */
350
+ export declare interface WASIInstance {
351
+ readonly wasiImport?: Record<string, any>;
352
+ initialize(instance: object): void;
353
+ start(instance: object): number;
354
+ getImportObject?(): any;
355
+ }
356
+
357
+ /** @public */
358
+ export declare class WASIThreads {
359
+ PThread: ThreadManager | undefined;
360
+ private wasmMemory;
361
+ private wasmInstance;
362
+ private readonly threadSpawn;
363
+ readonly childThread: boolean;
364
+ private readonly postMessage;
365
+ readonly wasi: WASIInstance;
366
+ constructor(options: WASIThreadsOptions);
367
+ getImportObject(): {
368
+ wasi: WASIThreadsImports;
369
+ };
370
+ setup(wasmInstance: WebAssembly.Instance, wasmModule: WebAssembly.Module, wasmMemory?: WebAssembly.Memory): void;
371
+ preloadWorkers(): Promise<WorkerLike[]>;
372
+ /**
373
+ * It's ok to call this method to a WASI command module.
374
+ *
375
+ * in child thread, must call this method instead of {@link WASIThreads.start} even if it's a WASI command module
376
+ *
377
+ * @returns A proxied WebAssembly instance if in child thread, other wise the original instance
378
+ */
379
+ initialize(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): WebAssembly.Instance;
380
+ /**
381
+ * Equivalent to calling {@link WASIThreads.initialize} and then calling {@link WASIInstance.start}
382
+ * ```js
383
+ * this.initialize(instance, module, memory)
384
+ * this.wasi.start(instance)
385
+ * ```
386
+ */
387
+ start(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): StartResult;
388
+ terminateAllThreads(): void;
389
+ }
390
+
391
+ /** @public */
392
+ export declare interface WASIThreadsImports {
393
+ 'thread-spawn': (startArg: number, errorOrTid?: number) => number;
394
+ }
395
+
396
+ /** @public */
397
+ export declare type WASIThreadsOptions = MainThreadOptions | ChildThreadOptions;
398
+
399
+ /** @public */
400
+ export declare type WorkerFactory = (ctx: {
401
+ type: string;
402
+ name: string;
403
+ }) => WorkerLike;
404
+
405
+ /** @public */
406
+ export declare type WorkerLike = (Worker | Worker_2) & {
407
+ whenLoaded?: Promise<WorkerLike>;
408
+ loaded?: boolean;
409
+ __emnapi_tid?: number;
410
+ };
411
+
412
+ /** @public */
413
+ export declare interface WorkerMessageEvent<T = any> {
414
+ data: T;
415
+ }
416
+
417
+ /** @public */
418
+ export declare type WorkerMessageType = 'load' | 'start';
419
+
420
+ export { }
node_modules/@emnapi/core/dist/emnapi-core.d.ts ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ import type { Context } from '@emnapi/runtime';
4
+ import type { ReferenceOwnership } from '@emnapi/runtime';
5
+ import type { Worker as Worker_2 } from 'worker_threads';
6
+
7
+ /** @public */
8
+ export declare type BaseCreateOptions = {
9
+ filename?: string
10
+ nodeBinding?: NodeBinding
11
+ reuseWorker?: ThreadManagerOptionsMain['reuseWorker']
12
+ asyncWorkPoolSize?: number
13
+ waitThreadStart?: MainThreadBaseOptions['waitThreadStart']
14
+ onCreateWorker?: (info: CreateWorkerInfo) => any
15
+ print?: (str: string) => void
16
+ printErr?: (str: string) => void
17
+ postMessage?: (msg: any) => any
18
+ }
19
+
20
+ /** @public */
21
+ export declare interface BaseOptions {
22
+ wasi: WASIInstance;
23
+ version?: 'preview1';
24
+ wasm64?: boolean;
25
+ }
26
+
27
+ /** @public */
28
+ export declare interface ChildThreadOptions extends BaseOptions {
29
+ childThread: true;
30
+ postMessage?: (data: any) => void;
31
+ }
32
+
33
+ /** @public */
34
+ export declare interface CleanupThreadPayload {
35
+ tid: number;
36
+ }
37
+
38
+ /** @public */
39
+ export declare interface CommandInfo<T extends CommandType> {
40
+ type: T;
41
+ payload: CommandPayloadMap[T];
42
+ }
43
+
44
+ /** @public */
45
+ export declare interface CommandPayloadMap {
46
+ load: LoadPayload;
47
+ loaded: LoadedPayload;
48
+ start: StartPayload;
49
+ 'cleanup-thread': CleanupThreadPayload;
50
+ 'terminate-all-threads': TerminateAllThreadsPayload;
51
+ 'spawn-thread': SpawnThreadPayload;
52
+ }
53
+
54
+ /** @public */
55
+ export declare type CommandType = keyof CommandPayloadMap;
56
+
57
+ /** @public */
58
+ export declare function createInstanceProxy(instance: WebAssembly.Instance, memory?: WebAssembly.Memory | (() => WebAssembly.Memory)): WebAssembly.Instance;
59
+
60
+ /** @public */
61
+ export declare function createNapiModule (
62
+ options: CreateOptions
63
+ ): NapiModule
64
+
65
+ /** @public */
66
+ export declare type CreateOptions = BaseCreateOptions & ({
67
+ context: Context
68
+ childThread?: boolean
69
+ } | {
70
+ context?: Context
71
+ childThread: true
72
+ })
73
+
74
+ /** @public */
75
+ export declare interface CreateWorkerInfo {
76
+ type: 'thread' | 'async-work'
77
+ name: string
78
+ }
79
+
80
+ /** @public */
81
+ export declare interface InitOptions {
82
+ instance: WebAssembly.Instance
83
+ module: WebAssembly.Module
84
+ memory?: WebAssembly.Memory
85
+ table?: WebAssembly.Table
86
+ }
87
+
88
+ export declare type InputType = string | URL | Response | BufferSource | WebAssembly.Module;
89
+
90
+ /** @public */
91
+ export declare interface InstantiatedSource extends LoadedSource {
92
+ napiModule: NapiModule;
93
+ }
94
+
95
+ /** @public */
96
+ export declare function instantiateNapiModule(
97
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
98
+ wasmInput: InputType | Promise<InputType>, options: InstantiateOptions): Promise<InstantiatedSource>;
99
+
100
+ /** @public */
101
+ export declare function instantiateNapiModuleSync(wasmInput: BufferSource | WebAssembly.Module, options: InstantiateOptions): InstantiatedSource;
102
+
103
+ /** @public */
104
+ export declare type InstantiateOptions = CreateOptions & LoadOptions;
105
+
106
+ /** @public */
107
+ export declare function isSharedArrayBuffer(value: any): value is SharedArrayBuffer;
108
+
109
+ /** @public */
110
+ export declare function isTrapError(e: Error): e is WebAssembly.RuntimeError;
111
+
112
+ /** @public */
113
+ export declare interface LoadedPayload {
114
+ }
115
+
116
+ /** @public */
117
+ export declare interface LoadedSource extends WebAssembly.WebAssemblyInstantiatedSource {
118
+ usedInstance: WebAssembly.Instance;
119
+ }
120
+
121
+ /** @public */
122
+ export declare function loadNapiModule(napiModule: NapiModule,
123
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
124
+ wasmInput: InputType | Promise<InputType>, options?: LoadOptions): Promise<LoadedSource>;
125
+
126
+ /** @public */
127
+ export declare function loadNapiModuleSync(napiModule: NapiModule, wasmInput: BufferSource | WebAssembly.Module, options?: LoadOptions): LoadedSource;
128
+
129
+ /** @public */
130
+ export declare interface LoadOptions {
131
+ wasi?: WASIInstance;
132
+ overwriteImports?: (importObject: WebAssembly.Imports) => WebAssembly.Imports;
133
+ beforeInit?: (source: WebAssembly.WebAssemblyInstantiatedSource) => void;
134
+ getMemory?: (exports: WebAssembly.Exports) => WebAssembly.Memory;
135
+ getTable?: (exports: WebAssembly.Exports) => WebAssembly.Table;
136
+ }
137
+
138
+ /** @public */
139
+ export declare interface LoadPayload {
140
+ wasmModule: WebAssembly.Module;
141
+ wasmMemory: WebAssembly.Memory;
142
+ sab?: Int32Array;
143
+ }
144
+
145
+ /** @public */
146
+ export declare interface MainThreadBaseOptions extends BaseOptions {
147
+ waitThreadStart?: boolean | number;
148
+ }
149
+
150
+ /** @public */
151
+ export declare type MainThreadOptions = MainThreadOptionsWithThreadManager | MainThreadOptionsCreateThreadManager;
152
+
153
+ /** @public */
154
+ export declare interface MainThreadOptionsCreateThreadManager extends MainThreadBaseOptions, ThreadManagerOptionsMain {
155
+ }
156
+
157
+ /** @public */
158
+ export declare interface MainThreadOptionsWithThreadManager extends MainThreadBaseOptions {
159
+ threadManager?: ThreadManager | (() => ThreadManager);
160
+ }
161
+
162
+ /** @public */
163
+ export declare interface MessageEventData<T extends CommandType> {
164
+ __emnapi__: CommandInfo<T>;
165
+ }
166
+
167
+ /** @public */
168
+ export declare class MessageHandler extends ThreadMessageHandler {
169
+ napiModule: NapiModule | undefined;
170
+ constructor(options: MessageHandlerOptions);
171
+ instantiate(data: LoadPayload): InstantiatedSource | PromiseLike<InstantiatedSource>;
172
+ handle(e: WorkerMessageEvent): void;
173
+ }
174
+
175
+ /** @public */
176
+ export declare interface MessageHandlerOptions extends ThreadMessageHandlerOptions {
177
+ onLoad: (data: LoadPayload) => InstantiatedSource | PromiseLike<InstantiatedSource>;
178
+ }
179
+
180
+ /** @public */
181
+ export declare interface NapiModule {
182
+ imports: {
183
+ env: any
184
+ napi: any
185
+ emnapi: any
186
+ }
187
+ exports: any
188
+ loaded: boolean
189
+ filename: string
190
+ childThread: boolean
191
+ emnapi: {
192
+ syncMemory<T extends ArrayBuffer | ArrayBufferView> (
193
+ js_to_wasm: boolean,
194
+ arrayBufferOrView: T,
195
+ offset?: number,
196
+ len?: number
197
+ ): T
198
+ getMemoryAddress (arrayBufferOrView: ArrayBuffer | ArrayBufferView): PointerInfo
199
+ addSendListener (worker: any): boolean
200
+ }
201
+
202
+ init (options: InitOptions): any
203
+ initWorker (arg: number, func: [number, number]): void
204
+ postMessage?: (msg: any) => any
205
+
206
+ waitThreadStart: boolean | number
207
+ /* Excluded from this release type: PThread */}
208
+
209
+ /** @public */
210
+ export declare interface NodeBinding {
211
+ node: {
212
+ emitAsyncInit: Function
213
+ emitAsyncDestroy: Function
214
+ makeCallback: Function
215
+ }
216
+ napi: {
217
+ asyncInit: Function
218
+ asyncDestroy: Function
219
+ makeCallback: Function
220
+ }
221
+ }
222
+
223
+ /** @public */
224
+ export declare interface PointerInfo {
225
+ address: number
226
+ ownership: ReferenceOwnership
227
+ runtimeAllocated: 0 | 1
228
+ }
229
+
230
+ /** @public */
231
+ export declare interface ReuseWorkerOptions {
232
+ /**
233
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size | PTHREAD_POOL_SIZE}
234
+ */
235
+ size: number;
236
+ /**
237
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size-strict | PTHREAD_POOL_SIZE_STRICT}
238
+ */
239
+ strict?: boolean;
240
+ }
241
+
242
+ /** @public */
243
+ export declare interface SpawnThreadPayload {
244
+ startArg: number;
245
+ errorOrTid: number;
246
+ }
247
+
248
+ /** @public */
249
+ export declare interface StartPayload {
250
+ tid: number;
251
+ arg: number;
252
+ sab?: Int32Array;
253
+ }
254
+
255
+ /** @public */
256
+ export declare interface StartResult {
257
+ exitCode: number;
258
+ instance: WebAssembly.Instance;
259
+ }
260
+
261
+ /** @public */
262
+ export declare interface TerminateAllThreadsPayload {
263
+ }
264
+
265
+ /** @public */
266
+ export declare class ThreadManager {
267
+ unusedWorkers: WorkerLike[];
268
+ runningWorkers: WorkerLike[];
269
+ pthreads: Record<number, WorkerLike>;
270
+ get nextWorkerID(): number;
271
+ wasmModule: WebAssembly.Module | null;
272
+ wasmMemory: WebAssembly.Memory | null;
273
+ private readonly messageEvents;
274
+ private readonly _childThread;
275
+ private readonly _onCreateWorker;
276
+ private readonly _reuseWorker;
277
+ private readonly _beforeLoad?;
278
+ /* Excluded from this release type: printErr */
279
+ threadSpawn?: ((startArg: number, errorOrTid?: number) => number);
280
+ constructor(options: ThreadManagerOptions);
281
+ init(): void;
282
+ initMainThread(): void;
283
+ private preparePool;
284
+ shouldPreloadWorkers(): boolean;
285
+ loadWasmModuleToAllWorkers(): Promise<WorkerLike[]>;
286
+ preloadWorkers(): Promise<WorkerLike[]>;
287
+ setup(wasmModule: WebAssembly.Module, wasmMemory: WebAssembly.Memory): void;
288
+ markId(worker: WorkerLike): number;
289
+ returnWorkerToPool(worker: WorkerLike): void;
290
+ loadWasmModuleToWorker(worker: WorkerLike, sab?: Int32Array): Promise<WorkerLike>;
291
+ allocateUnusedWorker(): WorkerLike;
292
+ getNewWorker(sab?: Int32Array): WorkerLike | undefined;
293
+ cleanThread(worker: WorkerLike, tid: number, force?: boolean): void;
294
+ terminateWorker(worker: WorkerLike): void;
295
+ terminateAllThreads(): void;
296
+ addMessageEventListener(worker: WorkerLike, onMessage: (e: WorkerMessageEvent) => void): () => void;
297
+ fireMessageEvent(worker: WorkerLike, e: WorkerMessageEvent): void;
298
+ }
299
+
300
+ /** @public */
301
+ export declare type ThreadManagerOptions = ThreadManagerOptionsMain | ThreadManagerOptionsChild;
302
+
303
+ /** @public */
304
+ export declare interface ThreadManagerOptionsBase {
305
+ printErr?: (message: string) => void;
306
+ threadSpawn?: (startArg: number, errorOrTid?: number) => number;
307
+ }
308
+
309
+ /** @public */
310
+ export declare interface ThreadManagerOptionsChild extends ThreadManagerOptionsBase {
311
+ childThread: true;
312
+ }
313
+
314
+ /** @public */
315
+ export declare interface ThreadManagerOptionsMain extends ThreadManagerOptionsBase {
316
+ beforeLoad?: (worker: WorkerLike) => any;
317
+ reuseWorker?: boolean | number | ReuseWorkerOptions;
318
+ onCreateWorker: WorkerFactory;
319
+ childThread?: false;
320
+ }
321
+
322
+ /** @public */
323
+ export declare class ThreadMessageHandler {
324
+ protected instance: WebAssembly.Instance | undefined;
325
+ private messagesBeforeLoad;
326
+ protected postMessage: (message: any) => void;
327
+ protected onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
328
+ protected onError: (error: Error, type: WorkerMessageType) => void;
329
+ constructor(options?: ThreadMessageHandlerOptions);
330
+ /** @virtual */
331
+ instantiate(data: LoadPayload): WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
332
+ /** @virtual */
333
+ handle(e: WorkerMessageEvent<MessageEventData<WorkerMessageType>>): void;
334
+ private _load;
335
+ private _start;
336
+ protected _loaded(err: Error | null, source: WebAssembly.WebAssemblyInstantiatedSource | null, payload: LoadPayload): void;
337
+ protected handleAfterLoad<E extends WorkerMessageEvent>(e: E, f: (e: E) => void): void;
338
+ }
339
+
340
+ /** @public */
341
+ export declare interface ThreadMessageHandlerOptions {
342
+ onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
343
+ onError?: (error: Error, type: WorkerMessageType) => void;
344
+ postMessage?: (message: any) => void;
345
+ }
346
+
347
+ export declare const version: string;
348
+
349
+ /** @public */
350
+ export declare interface WASIInstance {
351
+ readonly wasiImport?: Record<string, any>;
352
+ initialize(instance: object): void;
353
+ start(instance: object): number;
354
+ getImportObject?(): any;
355
+ }
356
+
357
+ /** @public */
358
+ export declare class WASIThreads {
359
+ PThread: ThreadManager | undefined;
360
+ private wasmMemory;
361
+ private wasmInstance;
362
+ private readonly threadSpawn;
363
+ readonly childThread: boolean;
364
+ private readonly postMessage;
365
+ readonly wasi: WASIInstance;
366
+ constructor(options: WASIThreadsOptions);
367
+ getImportObject(): {
368
+ wasi: WASIThreadsImports;
369
+ };
370
+ setup(wasmInstance: WebAssembly.Instance, wasmModule: WebAssembly.Module, wasmMemory?: WebAssembly.Memory): void;
371
+ preloadWorkers(): Promise<WorkerLike[]>;
372
+ /**
373
+ * It's ok to call this method to a WASI command module.
374
+ *
375
+ * in child thread, must call this method instead of {@link WASIThreads.start} even if it's a WASI command module
376
+ *
377
+ * @returns A proxied WebAssembly instance if in child thread, other wise the original instance
378
+ */
379
+ initialize(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): WebAssembly.Instance;
380
+ /**
381
+ * Equivalent to calling {@link WASIThreads.initialize} and then calling {@link WASIInstance.start}
382
+ * ```js
383
+ * this.initialize(instance, module, memory)
384
+ * this.wasi.start(instance)
385
+ * ```
386
+ */
387
+ start(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): StartResult;
388
+ terminateAllThreads(): void;
389
+ }
390
+
391
+ /** @public */
392
+ export declare interface WASIThreadsImports {
393
+ 'thread-spawn': (startArg: number, errorOrTid?: number) => number;
394
+ }
395
+
396
+ /** @public */
397
+ export declare type WASIThreadsOptions = MainThreadOptions | ChildThreadOptions;
398
+
399
+ /** @public */
400
+ export declare type WorkerFactory = (ctx: {
401
+ type: string;
402
+ name: string;
403
+ }) => WorkerLike;
404
+
405
+ /** @public */
406
+ export declare type WorkerLike = (Worker | Worker_2) & {
407
+ whenLoaded?: Promise<WorkerLike>;
408
+ loaded?: boolean;
409
+ __emnapi_tid?: number;
410
+ };
411
+
412
+ /** @public */
413
+ export declare interface WorkerMessageEvent<T = any> {
414
+ data: T;
415
+ }
416
+
417
+ /** @public */
418
+ export declare type WorkerMessageType = 'load' | 'start';
419
+
420
+ export { }
421
+
422
+ export as namespace emnapiCore;
node_modules/@emnapi/core/dist/emnapi-core.esm-bundler.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/dist/emnapi-core.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/dist/emnapi-core.min.d.mts ADDED
@@ -0,0 +1,420 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="node" />
2
+
3
+ import type { Context } from '@emnapi/runtime';
4
+ import type { ReferenceOwnership } from '@emnapi/runtime';
5
+ import type { Worker as Worker_2 } from 'worker_threads';
6
+
7
+ /** @public */
8
+ export declare type BaseCreateOptions = {
9
+ filename?: string
10
+ nodeBinding?: NodeBinding
11
+ reuseWorker?: ThreadManagerOptionsMain['reuseWorker']
12
+ asyncWorkPoolSize?: number
13
+ waitThreadStart?: MainThreadBaseOptions['waitThreadStart']
14
+ onCreateWorker?: (info: CreateWorkerInfo) => any
15
+ print?: (str: string) => void
16
+ printErr?: (str: string) => void
17
+ postMessage?: (msg: any) => any
18
+ }
19
+
20
+ /** @public */
21
+ export declare interface BaseOptions {
22
+ wasi: WASIInstance;
23
+ version?: 'preview1';
24
+ wasm64?: boolean;
25
+ }
26
+
27
+ /** @public */
28
+ export declare interface ChildThreadOptions extends BaseOptions {
29
+ childThread: true;
30
+ postMessage?: (data: any) => void;
31
+ }
32
+
33
+ /** @public */
34
+ export declare interface CleanupThreadPayload {
35
+ tid: number;
36
+ }
37
+
38
+ /** @public */
39
+ export declare interface CommandInfo<T extends CommandType> {
40
+ type: T;
41
+ payload: CommandPayloadMap[T];
42
+ }
43
+
44
+ /** @public */
45
+ export declare interface CommandPayloadMap {
46
+ load: LoadPayload;
47
+ loaded: LoadedPayload;
48
+ start: StartPayload;
49
+ 'cleanup-thread': CleanupThreadPayload;
50
+ 'terminate-all-threads': TerminateAllThreadsPayload;
51
+ 'spawn-thread': SpawnThreadPayload;
52
+ }
53
+
54
+ /** @public */
55
+ export declare type CommandType = keyof CommandPayloadMap;
56
+
57
+ /** @public */
58
+ export declare function createInstanceProxy(instance: WebAssembly.Instance, memory?: WebAssembly.Memory | (() => WebAssembly.Memory)): WebAssembly.Instance;
59
+
60
+ /** @public */
61
+ export declare function createNapiModule (
62
+ options: CreateOptions
63
+ ): NapiModule
64
+
65
+ /** @public */
66
+ export declare type CreateOptions = BaseCreateOptions & ({
67
+ context: Context
68
+ childThread?: boolean
69
+ } | {
70
+ context?: Context
71
+ childThread: true
72
+ })
73
+
74
+ /** @public */
75
+ export declare interface CreateWorkerInfo {
76
+ type: 'thread' | 'async-work'
77
+ name: string
78
+ }
79
+
80
+ /** @public */
81
+ export declare interface InitOptions {
82
+ instance: WebAssembly.Instance
83
+ module: WebAssembly.Module
84
+ memory?: WebAssembly.Memory
85
+ table?: WebAssembly.Table
86
+ }
87
+
88
+ export declare type InputType = string | URL | Response | BufferSource | WebAssembly.Module;
89
+
90
+ /** @public */
91
+ export declare interface InstantiatedSource extends LoadedSource {
92
+ napiModule: NapiModule;
93
+ }
94
+
95
+ /** @public */
96
+ export declare function instantiateNapiModule(
97
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
98
+ wasmInput: InputType | Promise<InputType>, options: InstantiateOptions): Promise<InstantiatedSource>;
99
+
100
+ /** @public */
101
+ export declare function instantiateNapiModuleSync(wasmInput: BufferSource | WebAssembly.Module, options: InstantiateOptions): InstantiatedSource;
102
+
103
+ /** @public */
104
+ export declare type InstantiateOptions = CreateOptions & LoadOptions;
105
+
106
+ /** @public */
107
+ export declare function isSharedArrayBuffer(value: any): value is SharedArrayBuffer;
108
+
109
+ /** @public */
110
+ export declare function isTrapError(e: Error): e is WebAssembly.RuntimeError;
111
+
112
+ /** @public */
113
+ export declare interface LoadedPayload {
114
+ }
115
+
116
+ /** @public */
117
+ export declare interface LoadedSource extends WebAssembly.WebAssemblyInstantiatedSource {
118
+ usedInstance: WebAssembly.Instance;
119
+ }
120
+
121
+ /** @public */
122
+ export declare function loadNapiModule(napiModule: NapiModule,
123
+ /** Only support `BufferSource` or `WebAssembly.Module` on Node.js */
124
+ wasmInput: InputType | Promise<InputType>, options?: LoadOptions): Promise<LoadedSource>;
125
+
126
+ /** @public */
127
+ export declare function loadNapiModuleSync(napiModule: NapiModule, wasmInput: BufferSource | WebAssembly.Module, options?: LoadOptions): LoadedSource;
128
+
129
+ /** @public */
130
+ export declare interface LoadOptions {
131
+ wasi?: WASIInstance;
132
+ overwriteImports?: (importObject: WebAssembly.Imports) => WebAssembly.Imports;
133
+ beforeInit?: (source: WebAssembly.WebAssemblyInstantiatedSource) => void;
134
+ getMemory?: (exports: WebAssembly.Exports) => WebAssembly.Memory;
135
+ getTable?: (exports: WebAssembly.Exports) => WebAssembly.Table;
136
+ }
137
+
138
+ /** @public */
139
+ export declare interface LoadPayload {
140
+ wasmModule: WebAssembly.Module;
141
+ wasmMemory: WebAssembly.Memory;
142
+ sab?: Int32Array;
143
+ }
144
+
145
+ /** @public */
146
+ export declare interface MainThreadBaseOptions extends BaseOptions {
147
+ waitThreadStart?: boolean | number;
148
+ }
149
+
150
+ /** @public */
151
+ export declare type MainThreadOptions = MainThreadOptionsWithThreadManager | MainThreadOptionsCreateThreadManager;
152
+
153
+ /** @public */
154
+ export declare interface MainThreadOptionsCreateThreadManager extends MainThreadBaseOptions, ThreadManagerOptionsMain {
155
+ }
156
+
157
+ /** @public */
158
+ export declare interface MainThreadOptionsWithThreadManager extends MainThreadBaseOptions {
159
+ threadManager?: ThreadManager | (() => ThreadManager);
160
+ }
161
+
162
+ /** @public */
163
+ export declare interface MessageEventData<T extends CommandType> {
164
+ __emnapi__: CommandInfo<T>;
165
+ }
166
+
167
+ /** @public */
168
+ export declare class MessageHandler extends ThreadMessageHandler {
169
+ napiModule: NapiModule | undefined;
170
+ constructor(options: MessageHandlerOptions);
171
+ instantiate(data: LoadPayload): InstantiatedSource | PromiseLike<InstantiatedSource>;
172
+ handle(e: WorkerMessageEvent): void;
173
+ }
174
+
175
+ /** @public */
176
+ export declare interface MessageHandlerOptions extends ThreadMessageHandlerOptions {
177
+ onLoad: (data: LoadPayload) => InstantiatedSource | PromiseLike<InstantiatedSource>;
178
+ }
179
+
180
+ /** @public */
181
+ export declare interface NapiModule {
182
+ imports: {
183
+ env: any
184
+ napi: any
185
+ emnapi: any
186
+ }
187
+ exports: any
188
+ loaded: boolean
189
+ filename: string
190
+ childThread: boolean
191
+ emnapi: {
192
+ syncMemory<T extends ArrayBuffer | ArrayBufferView> (
193
+ js_to_wasm: boolean,
194
+ arrayBufferOrView: T,
195
+ offset?: number,
196
+ len?: number
197
+ ): T
198
+ getMemoryAddress (arrayBufferOrView: ArrayBuffer | ArrayBufferView): PointerInfo
199
+ addSendListener (worker: any): boolean
200
+ }
201
+
202
+ init (options: InitOptions): any
203
+ initWorker (arg: number, func: [number, number]): void
204
+ postMessage?: (msg: any) => any
205
+
206
+ waitThreadStart: boolean | number
207
+ /* Excluded from this release type: PThread */}
208
+
209
+ /** @public */
210
+ export declare interface NodeBinding {
211
+ node: {
212
+ emitAsyncInit: Function
213
+ emitAsyncDestroy: Function
214
+ makeCallback: Function
215
+ }
216
+ napi: {
217
+ asyncInit: Function
218
+ asyncDestroy: Function
219
+ makeCallback: Function
220
+ }
221
+ }
222
+
223
+ /** @public */
224
+ export declare interface PointerInfo {
225
+ address: number
226
+ ownership: ReferenceOwnership
227
+ runtimeAllocated: 0 | 1
228
+ }
229
+
230
+ /** @public */
231
+ export declare interface ReuseWorkerOptions {
232
+ /**
233
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size | PTHREAD_POOL_SIZE}
234
+ */
235
+ size: number;
236
+ /**
237
+ * @see {@link https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size-strict | PTHREAD_POOL_SIZE_STRICT}
238
+ */
239
+ strict?: boolean;
240
+ }
241
+
242
+ /** @public */
243
+ export declare interface SpawnThreadPayload {
244
+ startArg: number;
245
+ errorOrTid: number;
246
+ }
247
+
248
+ /** @public */
249
+ export declare interface StartPayload {
250
+ tid: number;
251
+ arg: number;
252
+ sab?: Int32Array;
253
+ }
254
+
255
+ /** @public */
256
+ export declare interface StartResult {
257
+ exitCode: number;
258
+ instance: WebAssembly.Instance;
259
+ }
260
+
261
+ /** @public */
262
+ export declare interface TerminateAllThreadsPayload {
263
+ }
264
+
265
+ /** @public */
266
+ export declare class ThreadManager {
267
+ unusedWorkers: WorkerLike[];
268
+ runningWorkers: WorkerLike[];
269
+ pthreads: Record<number, WorkerLike>;
270
+ get nextWorkerID(): number;
271
+ wasmModule: WebAssembly.Module | null;
272
+ wasmMemory: WebAssembly.Memory | null;
273
+ private readonly messageEvents;
274
+ private readonly _childThread;
275
+ private readonly _onCreateWorker;
276
+ private readonly _reuseWorker;
277
+ private readonly _beforeLoad?;
278
+ /* Excluded from this release type: printErr */
279
+ threadSpawn?: ((startArg: number, errorOrTid?: number) => number);
280
+ constructor(options: ThreadManagerOptions);
281
+ init(): void;
282
+ initMainThread(): void;
283
+ private preparePool;
284
+ shouldPreloadWorkers(): boolean;
285
+ loadWasmModuleToAllWorkers(): Promise<WorkerLike[]>;
286
+ preloadWorkers(): Promise<WorkerLike[]>;
287
+ setup(wasmModule: WebAssembly.Module, wasmMemory: WebAssembly.Memory): void;
288
+ markId(worker: WorkerLike): number;
289
+ returnWorkerToPool(worker: WorkerLike): void;
290
+ loadWasmModuleToWorker(worker: WorkerLike, sab?: Int32Array): Promise<WorkerLike>;
291
+ allocateUnusedWorker(): WorkerLike;
292
+ getNewWorker(sab?: Int32Array): WorkerLike | undefined;
293
+ cleanThread(worker: WorkerLike, tid: number, force?: boolean): void;
294
+ terminateWorker(worker: WorkerLike): void;
295
+ terminateAllThreads(): void;
296
+ addMessageEventListener(worker: WorkerLike, onMessage: (e: WorkerMessageEvent) => void): () => void;
297
+ fireMessageEvent(worker: WorkerLike, e: WorkerMessageEvent): void;
298
+ }
299
+
300
+ /** @public */
301
+ export declare type ThreadManagerOptions = ThreadManagerOptionsMain | ThreadManagerOptionsChild;
302
+
303
+ /** @public */
304
+ export declare interface ThreadManagerOptionsBase {
305
+ printErr?: (message: string) => void;
306
+ threadSpawn?: (startArg: number, errorOrTid?: number) => number;
307
+ }
308
+
309
+ /** @public */
310
+ export declare interface ThreadManagerOptionsChild extends ThreadManagerOptionsBase {
311
+ childThread: true;
312
+ }
313
+
314
+ /** @public */
315
+ export declare interface ThreadManagerOptionsMain extends ThreadManagerOptionsBase {
316
+ beforeLoad?: (worker: WorkerLike) => any;
317
+ reuseWorker?: boolean | number | ReuseWorkerOptions;
318
+ onCreateWorker: WorkerFactory;
319
+ childThread?: false;
320
+ }
321
+
322
+ /** @public */
323
+ export declare class ThreadMessageHandler {
324
+ protected instance: WebAssembly.Instance | undefined;
325
+ private messagesBeforeLoad;
326
+ protected postMessage: (message: any) => void;
327
+ protected onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
328
+ protected onError: (error: Error, type: WorkerMessageType) => void;
329
+ constructor(options?: ThreadMessageHandlerOptions);
330
+ /** @virtual */
331
+ instantiate(data: LoadPayload): WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
332
+ /** @virtual */
333
+ handle(e: WorkerMessageEvent<MessageEventData<WorkerMessageType>>): void;
334
+ private _load;
335
+ private _start;
336
+ protected _loaded(err: Error | null, source: WebAssembly.WebAssemblyInstantiatedSource | null, payload: LoadPayload): void;
337
+ protected handleAfterLoad<E extends WorkerMessageEvent>(e: E, f: (e: E) => void): void;
338
+ }
339
+
340
+ /** @public */
341
+ export declare interface ThreadMessageHandlerOptions {
342
+ onLoad?: (data: LoadPayload) => WebAssembly.WebAssemblyInstantiatedSource | PromiseLike<WebAssembly.WebAssemblyInstantiatedSource>;
343
+ onError?: (error: Error, type: WorkerMessageType) => void;
344
+ postMessage?: (message: any) => void;
345
+ }
346
+
347
+ export declare const version: string;
348
+
349
+ /** @public */
350
+ export declare interface WASIInstance {
351
+ readonly wasiImport?: Record<string, any>;
352
+ initialize(instance: object): void;
353
+ start(instance: object): number;
354
+ getImportObject?(): any;
355
+ }
356
+
357
+ /** @public */
358
+ export declare class WASIThreads {
359
+ PThread: ThreadManager | undefined;
360
+ private wasmMemory;
361
+ private wasmInstance;
362
+ private readonly threadSpawn;
363
+ readonly childThread: boolean;
364
+ private readonly postMessage;
365
+ readonly wasi: WASIInstance;
366
+ constructor(options: WASIThreadsOptions);
367
+ getImportObject(): {
368
+ wasi: WASIThreadsImports;
369
+ };
370
+ setup(wasmInstance: WebAssembly.Instance, wasmModule: WebAssembly.Module, wasmMemory?: WebAssembly.Memory): void;
371
+ preloadWorkers(): Promise<WorkerLike[]>;
372
+ /**
373
+ * It's ok to call this method to a WASI command module.
374
+ *
375
+ * in child thread, must call this method instead of {@link WASIThreads.start} even if it's a WASI command module
376
+ *
377
+ * @returns A proxied WebAssembly instance if in child thread, other wise the original instance
378
+ */
379
+ initialize(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): WebAssembly.Instance;
380
+ /**
381
+ * Equivalent to calling {@link WASIThreads.initialize} and then calling {@link WASIInstance.start}
382
+ * ```js
383
+ * this.initialize(instance, module, memory)
384
+ * this.wasi.start(instance)
385
+ * ```
386
+ */
387
+ start(instance: WebAssembly.Instance, module: WebAssembly.Module, memory?: WebAssembly.Memory): StartResult;
388
+ terminateAllThreads(): void;
389
+ }
390
+
391
+ /** @public */
392
+ export declare interface WASIThreadsImports {
393
+ 'thread-spawn': (startArg: number, errorOrTid?: number) => number;
394
+ }
395
+
396
+ /** @public */
397
+ export declare type WASIThreadsOptions = MainThreadOptions | ChildThreadOptions;
398
+
399
+ /** @public */
400
+ export declare type WorkerFactory = (ctx: {
401
+ type: string;
402
+ name: string;
403
+ }) => WorkerLike;
404
+
405
+ /** @public */
406
+ export declare type WorkerLike = (Worker | Worker_2) & {
407
+ whenLoaded?: Promise<WorkerLike>;
408
+ loaded?: boolean;
409
+ __emnapi_tid?: number;
410
+ };
411
+
412
+ /** @public */
413
+ export declare interface WorkerMessageEvent<T = any> {
414
+ data: T;
415
+ }
416
+
417
+ /** @public */
418
+ export declare type WorkerMessageType = 'load' | 'start';
419
+
420
+ export { }
node_modules/@emnapi/core/dist/emnapi-core.min.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/dist/emnapi-core.min.mjs ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/dist/emnapi-core.mjs ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@emnapi/core/index.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
2
+ module.exports = require('./dist/emnapi-core.cjs.min.js')
3
+ } else {
4
+ module.exports = require('./dist/emnapi-core.cjs.js')
5
+ }
node_modules/@emnapi/core/package.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@emnapi/core",
3
+ "version": "1.10.0",
4
+ "description": "emnapi core",
5
+ "main": "index.js",
6
+ "module": "./dist/emnapi-core.esm-bundler.js",
7
+ "types": "./dist/emnapi-core.d.ts",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": {
12
+ "module": "./dist/emnapi-core.d.ts",
13
+ "import": "./dist/emnapi-core.d.mts",
14
+ "default": "./dist/emnapi-core.d.ts"
15
+ },
16
+ "module": "./dist/emnapi-core.esm-bundler.js",
17
+ "import": "./dist/emnapi-core.mjs",
18
+ "default": "./index.js"
19
+ },
20
+ "./dist/emnapi-core.cjs.min": {
21
+ "types": "./dist/emnapi-core.d.ts",
22
+ "default": "./dist/emnapi-core.cjs.min.js"
23
+ },
24
+ "./dist/emnapi-core.min.mjs": {
25
+ "types": "./dist/emnapi-core.d.mts",
26
+ "default": "./dist/emnapi-core.min.mjs"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@emnapi/wasi-threads": "1.2.1",
31
+ "tslib": "^2.4.0"
32
+ },
33
+ "scripts": {
34
+ "build": "node ./script/build.js"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/toyobayashi/emnapi.git"
39
+ },
40
+ "author": "toyobayashi",
41
+ "license": "MIT",
42
+ "bugs": {
43
+ "url": "https://github.com/toyobayashi/emnapi/issues"
44
+ },
45
+ "homepage": "https://github.com/toyobayashi/emnapi#readme",
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }
node_modules/@emnapi/runtime/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Toyobayashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/@emnapi/runtime/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ See [https://github.com/toyobayashi/emnapi](https://github.com/toyobayashi/emnapi)
node_modules/@emnapi/runtime/dist/emnapi.cjs.js ADDED
@@ -0,0 +1,1381 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const externalValue = new WeakMap();
2
+ function isExternal(object) {
3
+ return externalValue.has(object);
4
+ }
5
+ const External = (() => {
6
+ function External(value) {
7
+ Object.setPrototypeOf(this, null);
8
+ externalValue.set(this, value);
9
+ }
10
+ External.prototype = null;
11
+ return External;
12
+ })();
13
+ function getExternalValue(external) {
14
+ if (!isExternal(external)) {
15
+ throw new TypeError('not external');
16
+ }
17
+ return externalValue.get(external);
18
+ }
19
+
20
+ const supportNewFunction = (function () {
21
+ let f;
22
+ try {
23
+ f = new Function();
24
+ }
25
+ catch (_) {
26
+ return false;
27
+ }
28
+ return typeof f === 'function';
29
+ })();
30
+ const _global = (function () {
31
+ if (typeof globalThis !== 'undefined')
32
+ return globalThis;
33
+ let g = (function () { return this; })();
34
+ if (!g && supportNewFunction) {
35
+ try {
36
+ g = new Function('return this')();
37
+ }
38
+ catch (_) { }
39
+ }
40
+ if (!g) {
41
+ if (typeof __webpack_public_path__ === 'undefined') {
42
+ if (typeof global !== 'undefined')
43
+ return global;
44
+ }
45
+ if (typeof window !== 'undefined')
46
+ return window;
47
+ if (typeof self !== 'undefined')
48
+ return self;
49
+ }
50
+ return g;
51
+ })();
52
+ class TryCatch {
53
+ constructor() {
54
+ this._exception = undefined;
55
+ this._caught = false;
56
+ }
57
+ isEmpty() {
58
+ return !this._caught;
59
+ }
60
+ hasCaught() {
61
+ return this._caught;
62
+ }
63
+ exception() {
64
+ return this._exception;
65
+ }
66
+ setError(err) {
67
+ this._caught = true;
68
+ this._exception = err;
69
+ }
70
+ reset() {
71
+ this._caught = false;
72
+ this._exception = undefined;
73
+ }
74
+ extractException() {
75
+ const e = this._exception;
76
+ this.reset();
77
+ return e;
78
+ }
79
+ }
80
+ const canSetFunctionName = (function () {
81
+ var _a;
82
+ try {
83
+ return Boolean((_a = Object.getOwnPropertyDescriptor(Function.prototype, 'name')) === null || _a === void 0 ? void 0 : _a.configurable);
84
+ }
85
+ catch (_) {
86
+ return false;
87
+ }
88
+ })();
89
+ const supportReflect = typeof Reflect === 'object';
90
+ const supportFinalizer = (typeof FinalizationRegistry !== 'undefined') && (typeof WeakRef !== 'undefined');
91
+ const supportWeakSymbol = (function () {
92
+ try {
93
+ const sym = Symbol();
94
+ new WeakRef(sym);
95
+ new WeakMap().set(sym, undefined);
96
+ }
97
+ catch (_) {
98
+ return false;
99
+ }
100
+ return true;
101
+ })();
102
+ const supportBigInt = typeof BigInt !== 'undefined';
103
+ function isReferenceType(v) {
104
+ return (typeof v === 'object' && v !== null) || typeof v === 'function';
105
+ }
106
+ const _require = (function () {
107
+ let nativeRequire;
108
+ if (typeof __webpack_public_path__ !== 'undefined') {
109
+ nativeRequire = (function () {
110
+ return typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : undefined;
111
+ })();
112
+ }
113
+ else {
114
+ nativeRequire = (function () {
115
+ return typeof __webpack_public_path__ !== 'undefined' ? (typeof __non_webpack_require__ !== 'undefined' ? __non_webpack_require__ : undefined) : (typeof require !== 'undefined' ? require : undefined);
116
+ })();
117
+ }
118
+ return nativeRequire;
119
+ })();
120
+ const _MessageChannel = typeof MessageChannel === 'function'
121
+ ? MessageChannel
122
+ : (function () {
123
+ try {
124
+ return _require('worker_threads').MessageChannel;
125
+ }
126
+ catch (_) { }
127
+ return undefined;
128
+ })();
129
+ const _setImmediate = typeof setImmediate === 'function'
130
+ ? setImmediate
131
+ : function (callback) {
132
+ if (typeof callback !== 'function') {
133
+ throw new TypeError('The "callback" argument must be of type function');
134
+ }
135
+ if (_MessageChannel) {
136
+ let channel = new _MessageChannel();
137
+ channel.port1.onmessage = function () {
138
+ channel.port1.onmessage = null;
139
+ channel = undefined;
140
+ callback();
141
+ };
142
+ channel.port2.postMessage(null);
143
+ }
144
+ else {
145
+ setTimeout(callback, 0);
146
+ }
147
+ };
148
+ const _Buffer = typeof Buffer === 'function'
149
+ ? Buffer
150
+ : (function () {
151
+ try {
152
+ return _require('buffer').Buffer;
153
+ }
154
+ catch (_) { }
155
+ return undefined;
156
+ })();
157
+ const version = "1.11.1";
158
+ const NODE_API_SUPPORTED_VERSION_MIN = 1;
159
+ const NODE_API_SUPPORTED_VERSION_MAX = 10;
160
+ const NAPI_VERSION_EXPERIMENTAL = 2147483647;
161
+ const NODE_API_DEFAULT_MODULE_API_VERSION = 8;
162
+
163
+ class Handle {
164
+ constructor(id, value) {
165
+ this.id = id;
166
+ this.value = value;
167
+ }
168
+ data() {
169
+ return getExternalValue(this.value);
170
+ }
171
+ isNumber() {
172
+ return typeof this.value === 'number';
173
+ }
174
+ isBigInt() {
175
+ return typeof this.value === 'bigint';
176
+ }
177
+ isString() {
178
+ return typeof this.value === 'string';
179
+ }
180
+ isFunction() {
181
+ return typeof this.value === 'function';
182
+ }
183
+ isExternal() {
184
+ return isExternal(this.value);
185
+ }
186
+ isObject() {
187
+ return typeof this.value === 'object' && this.value !== null;
188
+ }
189
+ isArray() {
190
+ return Array.isArray(this.value);
191
+ }
192
+ isArrayBuffer() {
193
+ return (this.value instanceof ArrayBuffer);
194
+ }
195
+ isTypedArray() {
196
+ return (ArrayBuffer.isView(this.value)) && !(this.value instanceof DataView);
197
+ }
198
+ isBuffer(BufferConstructor) {
199
+ if (ArrayBuffer.isView(this.value))
200
+ return true;
201
+ BufferConstructor !== null && BufferConstructor !== void 0 ? BufferConstructor : (BufferConstructor = _Buffer);
202
+ return typeof BufferConstructor === 'function' && BufferConstructor.isBuffer(this.value);
203
+ }
204
+ isDataView() {
205
+ return (this.value instanceof DataView);
206
+ }
207
+ isDate() {
208
+ return (this.value instanceof Date);
209
+ }
210
+ isPromise() {
211
+ return (this.value instanceof Promise);
212
+ }
213
+ isBoolean() {
214
+ return typeof this.value === 'boolean';
215
+ }
216
+ isUndefined() {
217
+ return this.value === undefined;
218
+ }
219
+ isSymbol() {
220
+ return typeof this.value === 'symbol';
221
+ }
222
+ isNull() {
223
+ return this.value === null;
224
+ }
225
+ dispose() {
226
+ this.value = undefined;
227
+ }
228
+ }
229
+ class ConstHandle extends Handle {
230
+ constructor(id, value) {
231
+ super(id, value);
232
+ }
233
+ dispose() { }
234
+ }
235
+ class HandleStore {
236
+ constructor() {
237
+ this._values = [
238
+ undefined,
239
+ HandleStore.UNDEFINED,
240
+ HandleStore.NULL,
241
+ HandleStore.FALSE,
242
+ HandleStore.TRUE,
243
+ HandleStore.GLOBAL
244
+ ];
245
+ this._next = HandleStore.MIN_ID;
246
+ }
247
+ push(value) {
248
+ let h;
249
+ const next = this._next;
250
+ const values = this._values;
251
+ if (next < values.length) {
252
+ h = values[next];
253
+ h.value = value;
254
+ }
255
+ else {
256
+ h = new Handle(next, value);
257
+ values[next] = h;
258
+ }
259
+ this._next++;
260
+ return h;
261
+ }
262
+ erase(start, end) {
263
+ this._next = start;
264
+ const values = this._values;
265
+ for (let i = start; i < end; ++i) {
266
+ values[i].dispose();
267
+ }
268
+ }
269
+ get(id) {
270
+ return this._values[id];
271
+ }
272
+ swap(a, b) {
273
+ const values = this._values;
274
+ const h = values[a];
275
+ values[a] = values[b];
276
+ values[a].id = Number(a);
277
+ values[b] = h;
278
+ h.id = Number(b);
279
+ }
280
+ dispose() {
281
+ this._values.length = HandleStore.MIN_ID;
282
+ this._next = HandleStore.MIN_ID;
283
+ }
284
+ }
285
+ HandleStore.UNDEFINED = new ConstHandle(1, undefined);
286
+ HandleStore.NULL = new ConstHandle(2, null);
287
+ HandleStore.FALSE = new ConstHandle(3, false);
288
+ HandleStore.TRUE = new ConstHandle(4, true);
289
+ HandleStore.GLOBAL = new ConstHandle(5, _global);
290
+ HandleStore.MIN_ID = 6;
291
+
292
+ class HandleScope {
293
+ constructor(handleStore, id, parentScope, start, end = start) {
294
+ this.handleStore = handleStore;
295
+ this.id = id;
296
+ this.parent = parentScope;
297
+ this.child = null;
298
+ if (parentScope !== null)
299
+ parentScope.child = this;
300
+ this.start = start;
301
+ this.end = end;
302
+ this._escapeCalled = false;
303
+ this.callbackInfo = {
304
+ thiz: undefined,
305
+ data: 0,
306
+ args: undefined,
307
+ fn: undefined
308
+ };
309
+ }
310
+ add(value) {
311
+ const h = this.handleStore.push(value);
312
+ this.end++;
313
+ return h;
314
+ }
315
+ addExternal(data) {
316
+ return this.add(new External(data));
317
+ }
318
+ dispose() {
319
+ if (this._escapeCalled)
320
+ this._escapeCalled = false;
321
+ if (this.start === this.end)
322
+ return;
323
+ this.handleStore.erase(this.start, this.end);
324
+ }
325
+ escape(handle) {
326
+ if (this._escapeCalled)
327
+ return null;
328
+ this._escapeCalled = true;
329
+ if (handle < this.start || handle >= this.end) {
330
+ return null;
331
+ }
332
+ this.handleStore.swap(handle, this.start);
333
+ const h = this.handleStore.get(this.start);
334
+ this.start++;
335
+ this.parent.end++;
336
+ return h;
337
+ }
338
+ escapeCalled() {
339
+ return this._escapeCalled;
340
+ }
341
+ }
342
+
343
+ class ScopeStore {
344
+ constructor() {
345
+ this._rootScope = new HandleScope(null, 0, null, 1, HandleStore.MIN_ID);
346
+ this.currentScope = this._rootScope;
347
+ this._values = [undefined];
348
+ }
349
+ get(id) {
350
+ return this._values[id];
351
+ }
352
+ openScope(handleStore) {
353
+ const currentScope = this.currentScope;
354
+ let scope = currentScope.child;
355
+ if (scope !== null) {
356
+ scope.start = scope.end = currentScope.end;
357
+ }
358
+ else {
359
+ const id = currentScope.id + 1;
360
+ scope = new HandleScope(handleStore, id, currentScope, currentScope.end);
361
+ this._values[id] = scope;
362
+ }
363
+ this.currentScope = scope;
364
+ return scope;
365
+ }
366
+ closeScope() {
367
+ const scope = this.currentScope;
368
+ this.currentScope = scope.parent;
369
+ scope.dispose();
370
+ }
371
+ dispose() {
372
+ this.currentScope = this._rootScope;
373
+ this._values.length = 1;
374
+ }
375
+ }
376
+
377
+ class RefTracker {
378
+ constructor() {
379
+ this._next = null;
380
+ this._prev = null;
381
+ }
382
+ dispose() { }
383
+ finalize() { }
384
+ link(list) {
385
+ this._prev = list;
386
+ this._next = list._next;
387
+ if (this._next !== null) {
388
+ this._next._prev = this;
389
+ }
390
+ list._next = this;
391
+ }
392
+ unlink() {
393
+ if (this._prev !== null) {
394
+ this._prev._next = this._next;
395
+ }
396
+ if (this._next !== null) {
397
+ this._next._prev = this._prev;
398
+ }
399
+ this._prev = null;
400
+ this._next = null;
401
+ }
402
+ static finalizeAll(list) {
403
+ while (list._next !== null) {
404
+ list._next.finalize();
405
+ }
406
+ }
407
+ }
408
+
409
+ class Finalizer {
410
+ constructor(envObject, _finalizeCallback = 0, _finalizeData = 0, _finalizeHint = 0) {
411
+ this.envObject = envObject;
412
+ this._finalizeCallback = _finalizeCallback;
413
+ this._finalizeData = _finalizeData;
414
+ this._finalizeHint = _finalizeHint;
415
+ this._makeDynCall_vppp = envObject.makeDynCall_vppp;
416
+ }
417
+ callback() { return this._finalizeCallback; }
418
+ data() { return this._finalizeData; }
419
+ hint() { return this._finalizeHint; }
420
+ resetEnv() {
421
+ this.envObject = undefined;
422
+ }
423
+ resetFinalizer() {
424
+ this._finalizeCallback = 0;
425
+ this._finalizeData = 0;
426
+ this._finalizeHint = 0;
427
+ }
428
+ callFinalizer() {
429
+ const finalize_callback = this._finalizeCallback;
430
+ const finalize_data = this._finalizeData;
431
+ const finalize_hint = this._finalizeHint;
432
+ this.resetFinalizer();
433
+ if (!finalize_callback)
434
+ return;
435
+ const fini = Number(finalize_callback);
436
+ if (!this.envObject) {
437
+ this._makeDynCall_vppp(fini)(0, finalize_data, finalize_hint);
438
+ }
439
+ else {
440
+ this.envObject.callFinalizer(fini, finalize_data, finalize_hint);
441
+ }
442
+ }
443
+ dispose() {
444
+ this.envObject = undefined;
445
+ this._makeDynCall_vppp = undefined;
446
+ }
447
+ }
448
+
449
+ class TrackedFinalizer extends RefTracker {
450
+ static create(envObject, finalize_callback, finalize_data, finalize_hint) {
451
+ const finalizer = new TrackedFinalizer(envObject, finalize_callback, finalize_data, finalize_hint);
452
+ finalizer.link(envObject.finalizing_reflist);
453
+ return finalizer;
454
+ }
455
+ constructor(envObject, finalize_callback, finalize_data, finalize_hint) {
456
+ super();
457
+ this._finalizer = new Finalizer(envObject, finalize_callback, finalize_data, finalize_hint);
458
+ }
459
+ data() {
460
+ return this._finalizer.data();
461
+ }
462
+ dispose() {
463
+ if (!this._finalizer)
464
+ return;
465
+ this.unlink();
466
+ this._finalizer.envObject.dequeueFinalizer(this);
467
+ this._finalizer.dispose();
468
+ this._finalizer = undefined;
469
+ super.dispose();
470
+ }
471
+ finalize() {
472
+ this.unlink();
473
+ let error;
474
+ let caught = false;
475
+ try {
476
+ this._finalizer.callFinalizer();
477
+ }
478
+ catch (err) {
479
+ caught = true;
480
+ error = err;
481
+ }
482
+ this.dispose();
483
+ if (caught) {
484
+ throw error;
485
+ }
486
+ }
487
+ }
488
+
489
+ function throwNodeApiVersionError(moduleName, moduleApiVersion) {
490
+ const errorMessage = `${moduleName} requires Node-API version ${moduleApiVersion}, but this version of Node.js only supports version ${NODE_API_SUPPORTED_VERSION_MAX} add-ons.`;
491
+ throw new Error(errorMessage);
492
+ }
493
+ function handleThrow(envObject, value) {
494
+ if (envObject.terminatedOrTerminating()) {
495
+ return;
496
+ }
497
+ throw value;
498
+ }
499
+ class Env {
500
+ constructor(ctx, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort) {
501
+ this.ctx = ctx;
502
+ this.moduleApiVersion = moduleApiVersion;
503
+ this.makeDynCall_vppp = makeDynCall_vppp;
504
+ this.makeDynCall_vp = makeDynCall_vp;
505
+ this.abort = abort;
506
+ this.openHandleScopes = 0;
507
+ this.instanceData = null;
508
+ this.tryCatch = new TryCatch();
509
+ this.refs = 1;
510
+ this.reflist = new RefTracker();
511
+ this.finalizing_reflist = new RefTracker();
512
+ this.pendingFinalizers = [];
513
+ this.lastError = {
514
+ errorCode: 0,
515
+ engineErrorCode: 0,
516
+ engineReserved: 0
517
+ };
518
+ this.inGcFinalizer = false;
519
+ this._bindingMap = new WeakMap();
520
+ this.id = 0;
521
+ }
522
+ canCallIntoJs() {
523
+ return true;
524
+ }
525
+ terminatedOrTerminating() {
526
+ return !this.canCallIntoJs();
527
+ }
528
+ ref() {
529
+ this.refs++;
530
+ }
531
+ unref() {
532
+ this.refs--;
533
+ if (this.refs === 0) {
534
+ this.dispose();
535
+ }
536
+ }
537
+ ensureHandle(value) {
538
+ return this.ctx.ensureHandle(value);
539
+ }
540
+ ensureHandleId(value) {
541
+ return this.ensureHandle(value).id;
542
+ }
543
+ clearLastError() {
544
+ const lastError = this.lastError;
545
+ if (lastError.errorCode !== 0)
546
+ lastError.errorCode = 0;
547
+ if (lastError.engineErrorCode !== 0)
548
+ lastError.engineErrorCode = 0;
549
+ if (lastError.engineReserved !== 0)
550
+ lastError.engineReserved = 0;
551
+ return 0;
552
+ }
553
+ setLastError(error_code, engine_error_code = 0, engine_reserved = 0) {
554
+ const lastError = this.lastError;
555
+ if (lastError.errorCode !== error_code)
556
+ lastError.errorCode = error_code;
557
+ if (lastError.engineErrorCode !== engine_error_code)
558
+ lastError.engineErrorCode = engine_error_code;
559
+ if (lastError.engineReserved !== engine_reserved)
560
+ lastError.engineReserved = engine_reserved;
561
+ return error_code;
562
+ }
563
+ getReturnStatus() {
564
+ return !this.tryCatch.hasCaught() ? 0 : this.setLastError(10);
565
+ }
566
+ callIntoModule(fn, handleException = handleThrow) {
567
+ const openHandleScopesBefore = this.openHandleScopes;
568
+ this.clearLastError();
569
+ const r = fn(this);
570
+ if (openHandleScopesBefore !== this.openHandleScopes) {
571
+ this.abort('open_handle_scopes != open_handle_scopes_before');
572
+ }
573
+ if (this.tryCatch.hasCaught()) {
574
+ const err = this.tryCatch.extractException();
575
+ handleException(this, err);
576
+ }
577
+ return r;
578
+ }
579
+ invokeFinalizerFromGC(finalizer) {
580
+ if (this.moduleApiVersion !== NAPI_VERSION_EXPERIMENTAL) {
581
+ this.enqueueFinalizer(finalizer);
582
+ }
583
+ else {
584
+ const saved = this.inGcFinalizer;
585
+ this.inGcFinalizer = true;
586
+ try {
587
+ finalizer.finalize();
588
+ }
589
+ finally {
590
+ this.inGcFinalizer = saved;
591
+ }
592
+ }
593
+ }
594
+ checkGCAccess() {
595
+ if (this.moduleApiVersion === NAPI_VERSION_EXPERIMENTAL && this.inGcFinalizer) {
596
+ this.abort('Finalizer is calling a function that may affect GC state.\n' +
597
+ 'The finalizers are run directly from GC and must not affect GC ' +
598
+ 'state.\n' +
599
+ 'Use `node_api_post_finalizer` from inside of the finalizer to work ' +
600
+ 'around this issue.\n' +
601
+ 'It schedules the call as a new task in the event loop.');
602
+ }
603
+ }
604
+ enqueueFinalizer(finalizer) {
605
+ if (this.pendingFinalizers.indexOf(finalizer) === -1) {
606
+ this.pendingFinalizers.push(finalizer);
607
+ }
608
+ }
609
+ dequeueFinalizer(finalizer) {
610
+ const index = this.pendingFinalizers.indexOf(finalizer);
611
+ if (index !== -1) {
612
+ this.pendingFinalizers.splice(index, 1);
613
+ }
614
+ }
615
+ deleteMe() {
616
+ RefTracker.finalizeAll(this.finalizing_reflist);
617
+ RefTracker.finalizeAll(this.reflist);
618
+ this.tryCatch.extractException();
619
+ this.ctx.envStore.remove(this.id);
620
+ }
621
+ dispose() {
622
+ if (this.id === 0)
623
+ return;
624
+ this.deleteMe();
625
+ this.finalizing_reflist.dispose();
626
+ this.reflist.dispose();
627
+ this.id = 0;
628
+ }
629
+ initObjectBinding(value) {
630
+ const binding = {
631
+ wrapped: 0,
632
+ tag: null
633
+ };
634
+ this._bindingMap.set(value, binding);
635
+ return binding;
636
+ }
637
+ getObjectBinding(value) {
638
+ if (this._bindingMap.has(value)) {
639
+ return this._bindingMap.get(value);
640
+ }
641
+ return this.initObjectBinding(value);
642
+ }
643
+ setInstanceData(data, finalize_cb, finalize_hint) {
644
+ if (this.instanceData) {
645
+ this.instanceData.dispose();
646
+ }
647
+ this.instanceData = TrackedFinalizer.create(this, finalize_cb, data, finalize_hint);
648
+ }
649
+ getInstanceData() {
650
+ return this.instanceData ? this.instanceData.data() : 0;
651
+ }
652
+ }
653
+ class NodeEnv extends Env {
654
+ constructor(ctx, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding) {
655
+ super(ctx, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort);
656
+ this.filename = filename;
657
+ this.nodeBinding = nodeBinding;
658
+ this.destructing = false;
659
+ this.finalizationScheduled = false;
660
+ }
661
+ deleteMe() {
662
+ this.destructing = true;
663
+ this.drainFinalizerQueue();
664
+ super.deleteMe();
665
+ }
666
+ canCallIntoJs() {
667
+ return super.canCallIntoJs() && this.ctx.canCallIntoJs();
668
+ }
669
+ triggerFatalException(err) {
670
+ if (this.nodeBinding) {
671
+ this.nodeBinding.napi.fatalException(err);
672
+ }
673
+ else {
674
+ if (typeof process === 'object' && process !== null && typeof process._fatalException === 'function') {
675
+ const handled = process._fatalException(err);
676
+ if (!handled) {
677
+ console.error(err);
678
+ process.exit(1);
679
+ }
680
+ }
681
+ else {
682
+ throw err;
683
+ }
684
+ }
685
+ }
686
+ callbackIntoModule(enforceUncaughtExceptionPolicy, fn) {
687
+ return this.callIntoModule(fn, (envObject, err) => {
688
+ if (envObject.terminatedOrTerminating()) {
689
+ return;
690
+ }
691
+ const hasProcess = typeof process === 'object' && process !== null;
692
+ const hasForceFlag = hasProcess ? Boolean(process.execArgv && (process.execArgv.indexOf('--force-node-api-uncaught-exceptions-policy') !== -1)) : false;
693
+ if (envObject.moduleApiVersion < 10 && !hasForceFlag && !enforceUncaughtExceptionPolicy) {
694
+ const warn = hasProcess && typeof process.emitWarning === 'function'
695
+ ? process.emitWarning
696
+ : function (warning, type, code) {
697
+ if (warning instanceof Error) {
698
+ console.warn(warning.toString());
699
+ }
700
+ else {
701
+ const prefix = code ? `[${code}] ` : '';
702
+ console.warn(`${prefix}${type || 'Warning'}: ${warning}`);
703
+ }
704
+ };
705
+ warn('Uncaught Node-API callback exception detected, please run node with option --force-node-api-uncaught-exceptions-policy=true to handle those exceptions properly.', 'DeprecationWarning', 'DEP0168');
706
+ return;
707
+ }
708
+ envObject.triggerFatalException(err);
709
+ });
710
+ }
711
+ callFinalizer(cb, data, hint) {
712
+ this.callFinalizerInternal(1, cb, data, hint);
713
+ }
714
+ callFinalizerInternal(forceUncaught, cb, data, hint) {
715
+ const f = this.makeDynCall_vppp(cb);
716
+ const env = this.id;
717
+ const scope = this.ctx.openScope(this);
718
+ try {
719
+ this.callbackIntoModule(Boolean(forceUncaught), () => { f(env, data, hint); });
720
+ }
721
+ finally {
722
+ this.ctx.closeScope(this, scope);
723
+ }
724
+ }
725
+ enqueueFinalizer(finalizer) {
726
+ super.enqueueFinalizer(finalizer);
727
+ if (!this.finalizationScheduled && !this.destructing) {
728
+ this.finalizationScheduled = true;
729
+ this.ref();
730
+ _setImmediate(() => {
731
+ this.finalizationScheduled = false;
732
+ this.unref();
733
+ this.drainFinalizerQueue();
734
+ });
735
+ }
736
+ }
737
+ drainFinalizerQueue() {
738
+ while (this.pendingFinalizers.length > 0) {
739
+ const refTracker = this.pendingFinalizers.shift();
740
+ refTracker.finalize();
741
+ }
742
+ }
743
+ }
744
+ function newEnv(ctx, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding) {
745
+ moduleApiVersion = typeof moduleApiVersion !== 'number' ? NODE_API_DEFAULT_MODULE_API_VERSION : moduleApiVersion;
746
+ if (moduleApiVersion < NODE_API_DEFAULT_MODULE_API_VERSION) {
747
+ moduleApiVersion = NODE_API_DEFAULT_MODULE_API_VERSION;
748
+ }
749
+ else if (moduleApiVersion > NODE_API_SUPPORTED_VERSION_MAX && moduleApiVersion !== NAPI_VERSION_EXPERIMENTAL) {
750
+ throwNodeApiVersionError(filename, moduleApiVersion);
751
+ }
752
+ const env = new NodeEnv(ctx, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding);
753
+ ctx.envStore.add(env);
754
+ ctx.addCleanupHook(env, () => { env.unref(); }, 0);
755
+ return env;
756
+ }
757
+
758
+ class EmnapiError extends Error {
759
+ constructor(message) {
760
+ super(message);
761
+ const ErrorConstructor = new.target;
762
+ const proto = ErrorConstructor.prototype;
763
+ if (!(this instanceof EmnapiError)) {
764
+ const setPrototypeOf = Object.setPrototypeOf;
765
+ if (typeof setPrototypeOf === 'function') {
766
+ setPrototypeOf.call(Object, this, proto);
767
+ }
768
+ else {
769
+ this.__proto__ = proto;
770
+ }
771
+ if (typeof Error.captureStackTrace === 'function') {
772
+ Error.captureStackTrace(this, ErrorConstructor);
773
+ }
774
+ }
775
+ }
776
+ }
777
+ Object.defineProperty(EmnapiError.prototype, 'name', {
778
+ configurable: true,
779
+ writable: true,
780
+ value: 'EmnapiError'
781
+ });
782
+ class NotSupportWeakRefError extends EmnapiError {
783
+ constructor(api, message) {
784
+ super(`${api}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${message ? ` ${message}` : ''}`);
785
+ }
786
+ }
787
+ Object.defineProperty(NotSupportWeakRefError.prototype, 'name', {
788
+ configurable: true,
789
+ writable: true,
790
+ value: 'NotSupportWeakRefError'
791
+ });
792
+ class NotSupportBufferError extends EmnapiError {
793
+ constructor(api, message) {
794
+ super(`${api}: The current runtime does not support "Buffer". Consider using buffer polyfill to make sure \`globalThis.Buffer\` is defined.${message ? ` ${message}` : ''}`);
795
+ }
796
+ }
797
+ Object.defineProperty(NotSupportBufferError.prototype, 'name', {
798
+ configurable: true,
799
+ writable: true,
800
+ value: 'NotSupportBufferError'
801
+ });
802
+
803
+ class StrongRef {
804
+ constructor(value) {
805
+ this._value = value;
806
+ }
807
+ deref() {
808
+ return this._value;
809
+ }
810
+ dispose() {
811
+ this._value = undefined;
812
+ }
813
+ }
814
+ class Persistent {
815
+ constructor(value) {
816
+ this._ref = new StrongRef(value);
817
+ }
818
+ setWeak(param, callback) {
819
+ if (!supportFinalizer || this._ref === undefined || this._ref instanceof WeakRef)
820
+ return;
821
+ const value = this._ref.deref();
822
+ try {
823
+ Persistent._registry.register(value, this, this);
824
+ const weakRef = new WeakRef(value);
825
+ this._ref.dispose();
826
+ this._ref = weakRef;
827
+ this._param = param;
828
+ this._callback = callback;
829
+ }
830
+ catch (err) {
831
+ if (typeof value === 'symbol') ;
832
+ else {
833
+ throw err;
834
+ }
835
+ }
836
+ }
837
+ clearWeak() {
838
+ if (!supportFinalizer || this._ref === undefined)
839
+ return;
840
+ if (this._ref instanceof WeakRef) {
841
+ try {
842
+ Persistent._registry.unregister(this);
843
+ }
844
+ catch (_) { }
845
+ this._param = undefined;
846
+ this._callback = undefined;
847
+ const value = this._ref.deref();
848
+ if (value === undefined) {
849
+ this._ref = value;
850
+ }
851
+ else {
852
+ this._ref = new StrongRef(value);
853
+ }
854
+ }
855
+ }
856
+ reset() {
857
+ if (supportFinalizer) {
858
+ try {
859
+ Persistent._registry.unregister(this);
860
+ }
861
+ catch (_) { }
862
+ }
863
+ this._param = undefined;
864
+ this._callback = undefined;
865
+ if (this._ref instanceof StrongRef) {
866
+ this._ref.dispose();
867
+ }
868
+ this._ref = undefined;
869
+ }
870
+ isEmpty() {
871
+ return this._ref === undefined;
872
+ }
873
+ deref() {
874
+ if (this._ref === undefined)
875
+ return undefined;
876
+ return this._ref.deref();
877
+ }
878
+ }
879
+ Persistent._registry = supportFinalizer
880
+ ? new FinalizationRegistry((value) => {
881
+ value._ref = undefined;
882
+ const callback = value._callback;
883
+ const param = value._param;
884
+ value._callback = undefined;
885
+ value._param = undefined;
886
+ if (typeof callback === 'function') {
887
+ callback(param);
888
+ }
889
+ })
890
+ : undefined;
891
+
892
+ exports.ReferenceOwnership = void 0;
893
+ (function (ReferenceOwnership) {
894
+ ReferenceOwnership[ReferenceOwnership["kRuntime"] = 0] = "kRuntime";
895
+ ReferenceOwnership[ReferenceOwnership["kUserland"] = 1] = "kUserland";
896
+ })(exports.ReferenceOwnership || (exports.ReferenceOwnership = {}));
897
+ function canBeHeldWeakly(value) {
898
+ return value.isObject() || value.isFunction() || value.isSymbol();
899
+ }
900
+ class Reference extends RefTracker {
901
+ static weakCallback(ref) {
902
+ ref.persistent.reset();
903
+ ref.invokeFinalizerFromGC();
904
+ }
905
+ static create(envObject, handle_id, initialRefcount, ownership, _unused1, _unused2, _unused3) {
906
+ const ref = new Reference(envObject, handle_id, initialRefcount, ownership);
907
+ envObject.ctx.refStore.add(ref);
908
+ ref.link(envObject.reflist);
909
+ return ref;
910
+ }
911
+ constructor(envObject, handle_id, initialRefcount, ownership) {
912
+ super();
913
+ this.envObject = envObject;
914
+ this._refcount = initialRefcount;
915
+ this._ownership = ownership;
916
+ const handle = envObject.ctx.handleStore.get(handle_id);
917
+ this.canBeWeak = canBeHeldWeakly(handle);
918
+ this.persistent = new Persistent(handle.value);
919
+ this.id = 0;
920
+ if (initialRefcount === 0) {
921
+ this._setWeak();
922
+ }
923
+ }
924
+ ref() {
925
+ if (this.persistent.isEmpty()) {
926
+ return 0;
927
+ }
928
+ if (++this._refcount === 1 && this.canBeWeak) {
929
+ this.persistent.clearWeak();
930
+ }
931
+ return this._refcount;
932
+ }
933
+ unref() {
934
+ if (this.persistent.isEmpty() || this._refcount === 0) {
935
+ return 0;
936
+ }
937
+ if (--this._refcount === 0) {
938
+ this._setWeak();
939
+ }
940
+ return this._refcount;
941
+ }
942
+ get(envObject = this.envObject) {
943
+ if (this.persistent.isEmpty()) {
944
+ return 0;
945
+ }
946
+ const obj = this.persistent.deref();
947
+ const handle = envObject.ensureHandle(obj);
948
+ return handle.id;
949
+ }
950
+ resetFinalizer() { }
951
+ data() { return 0; }
952
+ refcount() { return this._refcount; }
953
+ ownership() { return this._ownership; }
954
+ callUserFinalizer() { }
955
+ invokeFinalizerFromGC() {
956
+ this.finalize();
957
+ }
958
+ _setWeak() {
959
+ if (this.canBeWeak) {
960
+ this.persistent.setWeak(this, Reference.weakCallback);
961
+ }
962
+ else {
963
+ this.persistent.reset();
964
+ }
965
+ }
966
+ finalize() {
967
+ this.persistent.reset();
968
+ const deleteMe = this._ownership === exports.ReferenceOwnership.kRuntime;
969
+ this.unlink();
970
+ this.callUserFinalizer();
971
+ if (deleteMe) {
972
+ this.dispose();
973
+ }
974
+ }
975
+ dispose() {
976
+ if (this.id === 0)
977
+ return;
978
+ this.unlink();
979
+ this.persistent.reset();
980
+ this.envObject.ctx.refStore.remove(this.id);
981
+ super.dispose();
982
+ this.envObject = undefined;
983
+ this.id = 0;
984
+ }
985
+ }
986
+ class ReferenceWithData extends Reference {
987
+ static create(envObject, value, initialRefcount, ownership, data) {
988
+ const reference = new ReferenceWithData(envObject, value, initialRefcount, ownership, data);
989
+ envObject.ctx.refStore.add(reference);
990
+ reference.link(envObject.reflist);
991
+ return reference;
992
+ }
993
+ constructor(envObject, value, initialRefcount, ownership, _data) {
994
+ super(envObject, value, initialRefcount, ownership);
995
+ this._data = _data;
996
+ }
997
+ data() {
998
+ return this._data;
999
+ }
1000
+ }
1001
+ class ReferenceWithFinalizer extends Reference {
1002
+ static create(envObject, value, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint) {
1003
+ const reference = new ReferenceWithFinalizer(envObject, value, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint);
1004
+ envObject.ctx.refStore.add(reference);
1005
+ reference.link(envObject.finalizing_reflist);
1006
+ return reference;
1007
+ }
1008
+ constructor(envObject, value, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint) {
1009
+ super(envObject, value, initialRefcount, ownership);
1010
+ this._finalizer = new Finalizer(envObject, finalize_callback, finalize_data, finalize_hint);
1011
+ }
1012
+ resetFinalizer() {
1013
+ this._finalizer.resetFinalizer();
1014
+ }
1015
+ data() {
1016
+ return this._finalizer.data();
1017
+ }
1018
+ callUserFinalizer() {
1019
+ this._finalizer.callFinalizer();
1020
+ }
1021
+ invokeFinalizerFromGC() {
1022
+ this._finalizer.envObject.invokeFinalizerFromGC(this);
1023
+ }
1024
+ dispose() {
1025
+ if (!this._finalizer)
1026
+ return;
1027
+ this._finalizer.envObject.dequeueFinalizer(this);
1028
+ this._finalizer.dispose();
1029
+ super.dispose();
1030
+ this._finalizer = undefined;
1031
+ }
1032
+ }
1033
+
1034
+ class Deferred {
1035
+ static create(ctx, value) {
1036
+ const deferred = new Deferred(ctx, value);
1037
+ ctx.deferredStore.add(deferred);
1038
+ return deferred;
1039
+ }
1040
+ constructor(ctx, value) {
1041
+ this.id = 0;
1042
+ this.ctx = ctx;
1043
+ this.value = value;
1044
+ }
1045
+ resolve(value) {
1046
+ this.value.resolve(value);
1047
+ this.dispose();
1048
+ }
1049
+ reject(reason) {
1050
+ this.value.reject(reason);
1051
+ this.dispose();
1052
+ }
1053
+ dispose() {
1054
+ this.ctx.deferredStore.remove(this.id);
1055
+ this.id = 0;
1056
+ this.value = null;
1057
+ this.ctx = null;
1058
+ }
1059
+ }
1060
+
1061
+ class Store {
1062
+ constructor() {
1063
+ this._values = [undefined];
1064
+ this._values.length = 4;
1065
+ this._size = 1;
1066
+ this._freeList = [];
1067
+ }
1068
+ add(value) {
1069
+ let id;
1070
+ if (this._freeList.length) {
1071
+ id = this._freeList.shift();
1072
+ }
1073
+ else {
1074
+ id = this._size;
1075
+ this._size++;
1076
+ const capacity = this._values.length;
1077
+ if (id >= capacity) {
1078
+ this._values.length = capacity + (capacity >> 1) + 16;
1079
+ }
1080
+ }
1081
+ value.id = id;
1082
+ this._values[id] = value;
1083
+ }
1084
+ get(id) {
1085
+ return this._values[id];
1086
+ }
1087
+ has(id) {
1088
+ return this._values[id] !== undefined;
1089
+ }
1090
+ remove(id) {
1091
+ const value = this._values[id];
1092
+ if (value) {
1093
+ value.id = 0;
1094
+ this._values[id] = undefined;
1095
+ this._freeList.push(Number(id));
1096
+ }
1097
+ }
1098
+ dispose() {
1099
+ for (let i = 1; i < this._size; ++i) {
1100
+ const value = this._values[i];
1101
+ value === null || value === void 0 ? void 0 : value.dispose();
1102
+ }
1103
+ this._values = [undefined];
1104
+ this._size = 1;
1105
+ this._freeList = [];
1106
+ }
1107
+ }
1108
+
1109
+ const kMaxReasonableBytes = BigInt(1) << BigInt(60);
1110
+ const kMinReasonableBytes = -kMaxReasonableBytes;
1111
+ class ExternalMemory {
1112
+ constructor(onChange) {
1113
+ this.total = BigInt(0);
1114
+ this.onChange = onChange !== null && onChange !== void 0 ? onChange : null;
1115
+ }
1116
+ adjust(changeInBytes) {
1117
+ changeInBytes = BigInt(changeInBytes);
1118
+ if (!(kMinReasonableBytes <= changeInBytes && changeInBytes < kMaxReasonableBytes)) {
1119
+ throw new RangeError(`changeInBytes ${changeInBytes} is out of reasonable range`);
1120
+ }
1121
+ const old = this.total;
1122
+ this.total += changeInBytes;
1123
+ const amount = this.total;
1124
+ const onChange = this.onChange;
1125
+ if (changeInBytes) {
1126
+ onChange === null || onChange === void 0 ? void 0 : onChange(amount, old, changeInBytes);
1127
+ }
1128
+ return amount;
1129
+ }
1130
+ }
1131
+
1132
+ class CleanupHookCallback {
1133
+ constructor(envObject, fn, arg, order) {
1134
+ this.envObject = envObject;
1135
+ this.fn = fn;
1136
+ this.arg = arg;
1137
+ this.order = order;
1138
+ }
1139
+ }
1140
+ class CleanupQueue {
1141
+ constructor() {
1142
+ this._cleanupHooks = [];
1143
+ this._cleanupHookCounter = 0;
1144
+ }
1145
+ empty() {
1146
+ return this._cleanupHooks.length === 0;
1147
+ }
1148
+ add(envObject, fn, arg) {
1149
+ if (this._cleanupHooks.filter((hook) => (hook.envObject === envObject && hook.fn === fn && hook.arg === arg)).length > 0) {
1150
+ throw new Error('Can not add same fn and arg twice');
1151
+ }
1152
+ this._cleanupHooks.push(new CleanupHookCallback(envObject, fn, arg, this._cleanupHookCounter++));
1153
+ }
1154
+ remove(envObject, fn, arg) {
1155
+ for (let i = 0; i < this._cleanupHooks.length; ++i) {
1156
+ const hook = this._cleanupHooks[i];
1157
+ if (hook.envObject === envObject && hook.fn === fn && hook.arg === arg) {
1158
+ this._cleanupHooks.splice(i, 1);
1159
+ return;
1160
+ }
1161
+ }
1162
+ }
1163
+ drain() {
1164
+ const hooks = this._cleanupHooks.slice();
1165
+ hooks.sort((a, b) => (b.order - a.order));
1166
+ for (let i = 0; i < hooks.length; ++i) {
1167
+ const cb = hooks[i];
1168
+ if (typeof cb.fn === 'number') {
1169
+ cb.envObject.makeDynCall_vp(cb.fn)(cb.arg);
1170
+ }
1171
+ else {
1172
+ cb.fn(cb.arg);
1173
+ }
1174
+ this._cleanupHooks.splice(this._cleanupHooks.indexOf(cb), 1);
1175
+ }
1176
+ }
1177
+ dispose() {
1178
+ this._cleanupHooks.length = 0;
1179
+ this._cleanupHookCounter = 0;
1180
+ }
1181
+ }
1182
+ class NodejsWaitingRequestCounter {
1183
+ constructor() {
1184
+ this.refHandle = new _MessageChannel().port1;
1185
+ this.count = 0;
1186
+ }
1187
+ increase() {
1188
+ if (this.count === 0) {
1189
+ if (this.refHandle.ref) {
1190
+ this.refHandle.ref();
1191
+ }
1192
+ }
1193
+ this.count++;
1194
+ }
1195
+ decrease() {
1196
+ if (this.count === 0)
1197
+ return;
1198
+ if (this.count === 1) {
1199
+ if (this.refHandle.unref) {
1200
+ this.refHandle.unref();
1201
+ }
1202
+ }
1203
+ this.count--;
1204
+ }
1205
+ }
1206
+ class Context {
1207
+ constructor(options) {
1208
+ this._isStopping = false;
1209
+ this._canCallIntoJs = true;
1210
+ this._suppressDestroy = false;
1211
+ this.envStore = new Store();
1212
+ this.scopeStore = new ScopeStore();
1213
+ this.refStore = new Store();
1214
+ this.deferredStore = new Store();
1215
+ this.handleStore = new HandleStore();
1216
+ this.feature = {
1217
+ supportReflect,
1218
+ supportFinalizer,
1219
+ supportWeakSymbol,
1220
+ supportBigInt,
1221
+ supportNewFunction,
1222
+ canSetFunctionName,
1223
+ setImmediate: _setImmediate,
1224
+ Buffer: _Buffer,
1225
+ MessageChannel: _MessageChannel
1226
+ };
1227
+ this.cleanupQueue = new CleanupQueue();
1228
+ this._externalMemory = new ExternalMemory(options === null || options === void 0 ? void 0 : options.onExternalMemoryChange);
1229
+ if (typeof process === 'object' && process !== null && typeof process.once === 'function') {
1230
+ this.refCounter = new NodejsWaitingRequestCounter();
1231
+ process.once('beforeExit', () => {
1232
+ if (!this._suppressDestroy) {
1233
+ this.destroy();
1234
+ }
1235
+ });
1236
+ }
1237
+ }
1238
+ suppressDestroy() {
1239
+ this._suppressDestroy = true;
1240
+ }
1241
+ getRuntimeVersions() {
1242
+ return {
1243
+ version,
1244
+ NODE_API_SUPPORTED_VERSION_MAX,
1245
+ NAPI_VERSION_EXPERIMENTAL,
1246
+ NODE_API_DEFAULT_MODULE_API_VERSION
1247
+ };
1248
+ }
1249
+ createNotSupportWeakRefError(api, message) {
1250
+ return new NotSupportWeakRefError(api, message);
1251
+ }
1252
+ createNotSupportBufferError(api, message) {
1253
+ return new NotSupportBufferError(api, message);
1254
+ }
1255
+ createReference(envObject, handle_id, initialRefcount, ownership) {
1256
+ return Reference.create(envObject, handle_id, initialRefcount, ownership);
1257
+ }
1258
+ createReferenceWithData(envObject, handle_id, initialRefcount, ownership, data) {
1259
+ return ReferenceWithData.create(envObject, handle_id, initialRefcount, ownership, data);
1260
+ }
1261
+ createReferenceWithFinalizer(envObject, handle_id, initialRefcount, ownership, finalize_callback = 0, finalize_data = 0, finalize_hint = 0) {
1262
+ return ReferenceWithFinalizer.create(envObject, handle_id, initialRefcount, ownership, finalize_callback, finalize_data, finalize_hint);
1263
+ }
1264
+ createDeferred(value) {
1265
+ return Deferred.create(this, value);
1266
+ }
1267
+ adjustAmountOfExternalAllocatedMemory(changeInBytes) {
1268
+ return this._externalMemory.adjust(changeInBytes);
1269
+ }
1270
+ createEnv(filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding) {
1271
+ return newEnv(this, filename, moduleApiVersion, makeDynCall_vppp, makeDynCall_vp, abort, nodeBinding);
1272
+ }
1273
+ createTrackedFinalizer(envObject, finalize_callback, finalize_data, finalize_hint) {
1274
+ return TrackedFinalizer.create(envObject, finalize_callback, finalize_data, finalize_hint);
1275
+ }
1276
+ getCurrentScope() {
1277
+ return this.scopeStore.currentScope;
1278
+ }
1279
+ addToCurrentScope(value) {
1280
+ return this.scopeStore.currentScope.add(value);
1281
+ }
1282
+ openScope(envObject) {
1283
+ const scope = this.scopeStore.openScope(this.handleStore);
1284
+ if (envObject)
1285
+ envObject.openHandleScopes++;
1286
+ return scope;
1287
+ }
1288
+ closeScope(envObject, _scope) {
1289
+ if (envObject && envObject.openHandleScopes === 0)
1290
+ return;
1291
+ this.scopeStore.closeScope();
1292
+ if (envObject)
1293
+ envObject.openHandleScopes--;
1294
+ }
1295
+ ensureHandle(value) {
1296
+ switch (value) {
1297
+ case undefined: return HandleStore.UNDEFINED;
1298
+ case null: return HandleStore.NULL;
1299
+ case true: return HandleStore.TRUE;
1300
+ case false: return HandleStore.FALSE;
1301
+ case _global: return HandleStore.GLOBAL;
1302
+ }
1303
+ return this.addToCurrentScope(value);
1304
+ }
1305
+ addCleanupHook(envObject, fn, arg) {
1306
+ this.cleanupQueue.add(envObject, fn, arg);
1307
+ }
1308
+ removeCleanupHook(envObject, fn, arg) {
1309
+ this.cleanupQueue.remove(envObject, fn, arg);
1310
+ }
1311
+ runCleanup() {
1312
+ while (!this.cleanupQueue.empty()) {
1313
+ this.cleanupQueue.drain();
1314
+ }
1315
+ }
1316
+ increaseWaitingRequestCounter() {
1317
+ var _a;
1318
+ (_a = this.refCounter) === null || _a === void 0 ? void 0 : _a.increase();
1319
+ }
1320
+ decreaseWaitingRequestCounter() {
1321
+ var _a;
1322
+ (_a = this.refCounter) === null || _a === void 0 ? void 0 : _a.decrease();
1323
+ }
1324
+ setCanCallIntoJs(value) {
1325
+ this._canCallIntoJs = value;
1326
+ }
1327
+ setStopping(value) {
1328
+ this._isStopping = value;
1329
+ }
1330
+ canCallIntoJs() {
1331
+ return this._canCallIntoJs && !this._isStopping;
1332
+ }
1333
+ destroy() {
1334
+ this.setStopping(true);
1335
+ this.setCanCallIntoJs(false);
1336
+ this.runCleanup();
1337
+ }
1338
+ }
1339
+ let defaultContext;
1340
+ function createContext(options) {
1341
+ return new Context(options);
1342
+ }
1343
+ function getDefaultContext() {
1344
+ if (!defaultContext) {
1345
+ defaultContext = createContext();
1346
+ }
1347
+ return defaultContext;
1348
+ }
1349
+
1350
+ exports.ConstHandle = ConstHandle;
1351
+ exports.Context = Context;
1352
+ exports.Deferred = Deferred;
1353
+ exports.EmnapiError = EmnapiError;
1354
+ exports.Env = Env;
1355
+ exports.External = External;
1356
+ exports.Finalizer = Finalizer;
1357
+ exports.Handle = Handle;
1358
+ exports.HandleScope = HandleScope;
1359
+ exports.HandleStore = HandleStore;
1360
+ exports.NAPI_VERSION_EXPERIMENTAL = NAPI_VERSION_EXPERIMENTAL;
1361
+ exports.NODE_API_DEFAULT_MODULE_API_VERSION = NODE_API_DEFAULT_MODULE_API_VERSION;
1362
+ exports.NODE_API_SUPPORTED_VERSION_MAX = NODE_API_SUPPORTED_VERSION_MAX;
1363
+ exports.NODE_API_SUPPORTED_VERSION_MIN = NODE_API_SUPPORTED_VERSION_MIN;
1364
+ exports.NodeEnv = NodeEnv;
1365
+ exports.NotSupportBufferError = NotSupportBufferError;
1366
+ exports.NotSupportWeakRefError = NotSupportWeakRefError;
1367
+ exports.Persistent = Persistent;
1368
+ exports.RefTracker = RefTracker;
1369
+ exports.Reference = Reference;
1370
+ exports.ReferenceWithData = ReferenceWithData;
1371
+ exports.ReferenceWithFinalizer = ReferenceWithFinalizer;
1372
+ exports.ScopeStore = ScopeStore;
1373
+ exports.Store = Store;
1374
+ exports.TrackedFinalizer = TrackedFinalizer;
1375
+ exports.TryCatch = TryCatch;
1376
+ exports.createContext = createContext;
1377
+ exports.getDefaultContext = getDefaultContext;
1378
+ exports.getExternalValue = getExternalValue;
1379
+ exports.isExternal = isExternal;
1380
+ exports.isReferenceType = isReferenceType;
1381
+ exports.version = version;
node_modules/@emnapi/runtime/dist/emnapi.cjs.min.d.ts ADDED
@@ -0,0 +1,671 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export declare type Ptr = number | bigint
2
+
3
+ export declare interface IBuffer extends Uint8Array {}
4
+ export declare interface BufferCtor {
5
+ readonly prototype: IBuffer
6
+ /** @deprecated */
7
+ new (...args: any[]): IBuffer
8
+ from: {
9
+ (buffer: ArrayBufferLike): IBuffer
10
+ (buffer: ArrayBufferLike, byteOffset: number, length: number): IBuffer
11
+ }
12
+ alloc: (size: number) => IBuffer
13
+ isBuffer: (obj: unknown) => obj is IBuffer
14
+ }
15
+
16
+ export declare const enum GlobalHandle {
17
+ UNDEFINED = 1,
18
+ NULL,
19
+ FALSE,
20
+ TRUE,
21
+ GLOBAL
22
+ }
23
+
24
+ export declare const enum Version {
25
+ NODE_API_SUPPORTED_VERSION_MIN = 1,
26
+ NODE_API_DEFAULT_MODULE_API_VERSION = 8,
27
+ NODE_API_SUPPORTED_VERSION_MAX = 10,
28
+ NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ export declare type Pointer<T> = number
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ export declare type PointerPointer<T> = number
34
+ export declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
35
+ export declare type Const<T> = T
36
+
37
+ export declare type void_p = Pointer<void>
38
+ export declare type void_pp = Pointer<void_p>
39
+ export declare type bool = number
40
+ export declare type char = number
41
+ export declare type char_p = Pointer<char>
42
+ export declare type unsigned_char = number
43
+ export declare type const_char = Const<char>
44
+ export declare type const_char_p = Pointer<const_char>
45
+ export declare type char16_t_p = number
46
+ export declare type const_char16_t_p = number
47
+
48
+ export declare type short = number
49
+ export declare type unsigned_short = number
50
+ export declare type int = number
51
+ export declare type unsigned_int = number
52
+ export declare type long = number
53
+ export declare type unsigned_long = number
54
+ export declare type long_long = bigint
55
+ export declare type unsigned_long_long = bigint
56
+ export declare type float = number
57
+ export declare type double = number
58
+ export declare type long_double = number
59
+ export declare type size_t = number
60
+
61
+ export declare type int8_t = number
62
+ export declare type uint8_t = number
63
+ export declare type int16_t = number
64
+ export declare type uint16_t = number
65
+ export declare type int32_t = number
66
+ export declare type uint32_t = number
67
+ export declare type int64_t = bigint
68
+ export declare type uint64_t = bigint
69
+ export declare type napi_env = Pointer<unknown>
70
+
71
+ export declare type napi_value = Pointer<unknown>
72
+ export declare type napi_ref = Pointer<unknown>
73
+ export declare type napi_deferred = Pointer<unknown>
74
+ export declare type napi_handle_scope = Pointer<unknown>
75
+ export declare type napi_escapable_handle_scope = Pointer<unknown>
76
+
77
+ export declare type napi_addon_register_func = FunctionPointer<(env: napi_env, exports: napi_value) => napi_value>
78
+
79
+ export declare type napi_callback_info = Pointer<unknown>
80
+ export declare type napi_callback = FunctionPointer<(env: napi_env, info: napi_callback_info) => napi_value>
81
+
82
+ export declare interface napi_extended_error_info {
83
+ error_message: const_char_p
84
+ engine_reserved: void_p
85
+ engine_error_code: uint32_t
86
+ error_code: napi_status
87
+ }
88
+
89
+ export declare interface napi_property_descriptor {
90
+ // One of utf8name or name should be NULL.
91
+ utf8name: const_char_p
92
+ name: napi_value
93
+
94
+ method: napi_callback
95
+ getter: napi_callback
96
+ setter: napi_callback
97
+ value: napi_value
98
+ /* napi_property_attributes */
99
+ attributes: number
100
+ data: void_p
101
+ }
102
+
103
+ export declare type napi_finalize = FunctionPointer<(
104
+ env: napi_env,
105
+ finalize_data: void_p,
106
+ finalize_hint: void_p
107
+ ) => void>
108
+
109
+ export declare interface node_module {
110
+ nm_version: int32_t
111
+ nm_flags: uint32_t
112
+ nm_filename: Pointer<const_char>
113
+ nm_register_func: napi_addon_register_func
114
+ nm_modname: Pointer<const_char>
115
+ nm_priv: Pointer<void>
116
+ reserved: PointerPointer<void>
117
+ }
118
+
119
+ export declare interface napi_node_version {
120
+ major: uint32_t
121
+ minor: uint32_t
122
+ patch: uint32_t
123
+ release: const_char_p
124
+ }
125
+
126
+ export declare interface emnapi_emscripten_version {
127
+ major: uint32_t
128
+ minor: uint32_t
129
+ patch: uint32_t
130
+ }
131
+
132
+ export declare const enum napi_status {
133
+ napi_ok,
134
+ napi_invalid_arg,
135
+ napi_object_expected,
136
+ napi_string_expected,
137
+ napi_name_expected,
138
+ napi_function_expected,
139
+ napi_number_expected,
140
+ napi_boolean_expected,
141
+ napi_array_expected,
142
+ napi_generic_failure,
143
+ napi_pending_exception,
144
+ napi_cancelled,
145
+ napi_escape_called_twice,
146
+ napi_handle_scope_mismatch,
147
+ napi_callback_scope_mismatch,
148
+ napi_queue_full,
149
+ napi_closing,
150
+ napi_bigint_expected,
151
+ napi_date_expected,
152
+ napi_arraybuffer_expected,
153
+ napi_detachable_arraybuffer_expected,
154
+ napi_would_deadlock, // unused
155
+ napi_no_external_buffers_allowed,
156
+ napi_cannot_run_js
157
+ }
158
+
159
+ export declare const enum napi_property_attributes {
160
+ napi_default = 0,
161
+ napi_writable = 1 << 0,
162
+ napi_enumerable = 1 << 1,
163
+ napi_configurable = 1 << 2,
164
+
165
+ // Used with napi_define_class to distinguish static properties
166
+ // from instance properties. Ignored by napi_define_properties.
167
+ napi_static = 1 << 10,
168
+
169
+ /// #ifdef NAPI_EXPERIMENTAL
170
+ // Default for class methods.
171
+ napi_default_method = napi_writable | napi_configurable,
172
+
173
+ // Default for object properties, like in JS obj[prop].
174
+ napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable
175
+ /// #endif // NAPI_EXPERIMENTAL
176
+ }
177
+
178
+ export declare const enum napi_valuetype {
179
+ napi_undefined,
180
+ napi_null,
181
+ napi_boolean,
182
+ napi_number,
183
+ napi_string,
184
+ napi_symbol,
185
+ napi_object,
186
+ napi_function,
187
+ napi_external,
188
+ napi_bigint
189
+ }
190
+
191
+ export declare const enum napi_typedarray_type {
192
+ napi_int8_array,
193
+ napi_uint8_array,
194
+ napi_uint8_clamped_array,
195
+ napi_int16_array,
196
+ napi_uint16_array,
197
+ napi_int32_array,
198
+ napi_uint32_array,
199
+ napi_float32_array,
200
+ napi_float64_array,
201
+ napi_bigint64_array,
202
+ napi_biguint64_array,
203
+ napi_float16_array,
204
+ }
205
+
206
+ export declare const enum napi_key_collection_mode {
207
+ napi_key_include_prototypes,
208
+ napi_key_own_only
209
+ }
210
+
211
+ export declare const enum napi_key_filter {
212
+ napi_key_all_properties = 0,
213
+ napi_key_writable = 1,
214
+ napi_key_enumerable = 1 << 1,
215
+ napi_key_configurable = 1 << 2,
216
+ napi_key_skip_strings = 1 << 3,
217
+ napi_key_skip_symbols = 1 << 4
218
+ }
219
+
220
+ export declare const enum napi_key_conversion {
221
+ napi_key_keep_numbers,
222
+ napi_key_numbers_to_strings
223
+ }
224
+
225
+ export declare const enum emnapi_memory_view_type {
226
+ emnapi_int8_array,
227
+ emnapi_uint8_array,
228
+ emnapi_uint8_clamped_array,
229
+ emnapi_int16_array,
230
+ emnapi_uint16_array,
231
+ emnapi_int32_array,
232
+ emnapi_uint32_array,
233
+ emnapi_float32_array,
234
+ emnapi_float64_array,
235
+ emnapi_bigint64_array,
236
+ emnapi_biguint64_array,
237
+ emnapi_float16_array,
238
+ emnapi_data_view = -1,
239
+ emnapi_buffer = -2
240
+ }
241
+
242
+ export declare const enum napi_threadsafe_function_call_mode {
243
+ napi_tsfn_nonblocking,
244
+ napi_tsfn_blocking
245
+ }
246
+
247
+ export declare const enum napi_threadsafe_function_release_mode {
248
+ napi_tsfn_release,
249
+ napi_tsfn_abort
250
+ }
251
+ export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
252
+
253
+ export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
254
+ constructor(id: number, value: S);
255
+ dispose(): void;
256
+ }
257
+
258
+ export declare class Context {
259
+ private _isStopping;
260
+ private _canCallIntoJs;
261
+ private _suppressDestroy;
262
+ envStore: Store<Env>;
263
+ scopeStore: ScopeStore;
264
+ refStore: Store<Reference>;
265
+ deferredStore: Store<Deferred<any>>;
266
+ handleStore: HandleStore;
267
+ private readonly refCounter?;
268
+ private readonly cleanupQueue;
269
+ private readonly _externalMemory;
270
+ feature: {
271
+ supportReflect: boolean;
272
+ supportFinalizer: boolean;
273
+ supportWeakSymbol: boolean;
274
+ supportBigInt: boolean;
275
+ supportNewFunction: boolean;
276
+ canSetFunctionName: boolean;
277
+ setImmediate: (callback: () => void) => void;
278
+ Buffer: BufferCtor | undefined;
279
+ MessageChannel: {
280
+ new (): MessageChannel;
281
+ prototype: MessageChannel;
282
+ } | undefined;
283
+ };
284
+ constructor(options?: ContextOptions);
285
+ /**
286
+ * Suppress the destroy on `beforeExit` event in Node.js.
287
+ * Call this method if you want to keep the context and
288
+ * all associated {@link Env | Env} alive,
289
+ * this also means that cleanup hooks will not be called.
290
+ * After call this method, you should call
291
+ * {@link Context.destroy | `Context.prototype.destroy`} method manually.
292
+ */
293
+ suppressDestroy(): void;
294
+ getRuntimeVersions(): {
295
+ version: string;
296
+ NODE_API_SUPPORTED_VERSION_MAX: Version;
297
+ NAPI_VERSION_EXPERIMENTAL: Version;
298
+ NODE_API_DEFAULT_MODULE_API_VERSION: Version;
299
+ };
300
+ createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
301
+ createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
302
+ createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
303
+ createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
304
+ createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
305
+ createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
306
+ adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
307
+ createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
308
+ createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
309
+ getCurrentScope(): HandleScope | null;
310
+ addToCurrentScope<V>(value: V): Handle<V>;
311
+ openScope(envObject?: Env): HandleScope;
312
+ closeScope(envObject?: Env, _scope?: HandleScope): void;
313
+ ensureHandle<S>(value: S): Handle<S>;
314
+ addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
315
+ removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
316
+ runCleanup(): void;
317
+ increaseWaitingRequestCounter(): void;
318
+ decreaseWaitingRequestCounter(): void;
319
+ setCanCallIntoJs(value: boolean): void;
320
+ setStopping(value: boolean): void;
321
+ canCallIntoJs(): boolean;
322
+ /**
323
+ * Destroy the context and call cleanup hooks.
324
+ * Associated {@link Env | Env} will be destroyed.
325
+ */
326
+ destroy(): void;
327
+ }
328
+
329
+ export declare interface ContextOptions {
330
+ onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
331
+ }
332
+
333
+ export declare function createContext(options?: ContextOptions): Context;
334
+
335
+ export declare class Deferred<T = any> implements IStoreValue {
336
+ static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
337
+ id: number;
338
+ ctx: Context;
339
+ value: IDeferrdValue<T>;
340
+ constructor(ctx: Context, value: IDeferrdValue<T>);
341
+ resolve(value: T): void;
342
+ reject(reason?: any): void;
343
+ dispose(): void;
344
+ }
345
+
346
+ export declare class EmnapiError extends Error {
347
+ constructor(message?: string);
348
+ }
349
+
350
+ export declare abstract class Env implements IStoreValue {
351
+ readonly ctx: Context;
352
+ moduleApiVersion: number;
353
+ makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
354
+ makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
355
+ abort: (msg?: string) => never;
356
+ id: number;
357
+ openHandleScopes: number;
358
+ instanceData: TrackedFinalizer | null;
359
+ tryCatch: TryCatch;
360
+ refs: number;
361
+ reflist: RefTracker;
362
+ finalizing_reflist: RefTracker;
363
+ pendingFinalizers: RefTracker[];
364
+ lastError: {
365
+ errorCode: napi_status;
366
+ engineErrorCode: number;
367
+ engineReserved: Ptr;
368
+ };
369
+ inGcFinalizer: boolean;
370
+ constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
371
+ /** @virtual */
372
+ canCallIntoJs(): boolean;
373
+ terminatedOrTerminating(): boolean;
374
+ ref(): void;
375
+ unref(): void;
376
+ ensureHandle<S>(value: S): Handle<S>;
377
+ ensureHandleId(value: any): napi_value;
378
+ clearLastError(): napi_status;
379
+ setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
380
+ getReturnStatus(): napi_status;
381
+ callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
382
+ /** @virtual */
383
+ abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
384
+ invokeFinalizerFromGC(finalizer: RefTracker): void;
385
+ checkGCAccess(): void;
386
+ /** @virtual */
387
+ enqueueFinalizer(finalizer: RefTracker): void;
388
+ /** @virtual */
389
+ dequeueFinalizer(finalizer: RefTracker): void;
390
+ /** @virtual */
391
+ deleteMe(): void;
392
+ dispose(): void;
393
+ private readonly _bindingMap;
394
+ initObjectBinding<S extends object>(value: S): IReferenceBinding;
395
+ getObjectBinding<S extends object>(value: S): IReferenceBinding;
396
+ setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
397
+ getInstanceData(): number;
398
+ }
399
+
400
+ /** @public */
401
+ declare interface External_2 extends Record<any, any> {
402
+ }
403
+
404
+ /** @public */
405
+ declare const External_2: {
406
+ new (value: number | bigint): External_2;
407
+ prototype: null;
408
+ };
409
+ export { External_2 as External }
410
+
411
+ export declare class Finalizer {
412
+ envObject: Env;
413
+ private _finalizeCallback;
414
+ private _finalizeData;
415
+ private _finalizeHint;
416
+ private _makeDynCall_vppp;
417
+ constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
418
+ callback(): napi_finalize;
419
+ data(): void_p;
420
+ hint(): void_p;
421
+ resetEnv(): void;
422
+ resetFinalizer(): void;
423
+ callFinalizer(): void;
424
+ dispose(): void;
425
+ }
426
+
427
+ export declare function getDefaultContext(): Context;
428
+
429
+ /** @public */
430
+ export declare function getExternalValue(external: External_2): number | bigint;
431
+
432
+ export declare class Handle<S> {
433
+ id: number;
434
+ value: S;
435
+ constructor(id: number, value: S);
436
+ data(): void_p;
437
+ isNumber(): boolean;
438
+ isBigInt(): boolean;
439
+ isString(): boolean;
440
+ isFunction(): boolean;
441
+ isExternal(): boolean;
442
+ isObject(): boolean;
443
+ isArray(): boolean;
444
+ isArrayBuffer(): boolean;
445
+ isTypedArray(): boolean;
446
+ isBuffer(BufferConstructor?: BufferCtor): boolean;
447
+ isDataView(): boolean;
448
+ isDate(): boolean;
449
+ isPromise(): boolean;
450
+ isBoolean(): boolean;
451
+ isUndefined(): boolean;
452
+ isSymbol(): boolean;
453
+ isNull(): boolean;
454
+ dispose(): void;
455
+ }
456
+
457
+ export declare class HandleScope {
458
+ handleStore: HandleStore;
459
+ id: number;
460
+ parent: HandleScope | null;
461
+ child: HandleScope | null;
462
+ start: number;
463
+ end: number;
464
+ private _escapeCalled;
465
+ callbackInfo: ICallbackInfo;
466
+ constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
467
+ add<V>(value: V): Handle<V>;
468
+ addExternal(data: void_p): Handle<object>;
469
+ dispose(): void;
470
+ escape(handle: number): Handle<any> | null;
471
+ escapeCalled(): boolean;
472
+ }
473
+
474
+ export declare class HandleStore {
475
+ static UNDEFINED: ConstHandle<undefined>;
476
+ static NULL: ConstHandle<null>;
477
+ static FALSE: ConstHandle<false>;
478
+ static TRUE: ConstHandle<true>;
479
+ static GLOBAL: ConstHandle<typeof globalThis>;
480
+ static MIN_ID: 6;
481
+ private readonly _values;
482
+ private _next;
483
+ push<S>(value: S): Handle<S>;
484
+ erase(start: number, end: number): void;
485
+ get(id: Ptr): Handle<any> | undefined;
486
+ swap(a: number, b: number): void;
487
+ dispose(): void;
488
+ }
489
+
490
+ export declare interface ICallbackInfo {
491
+ thiz: any;
492
+ data: void_p;
493
+ args: ArrayLike<any>;
494
+ fn: Function;
495
+ }
496
+
497
+ export declare interface IDeferrdValue<T = any> {
498
+ resolve: (value: T) => void;
499
+ reject: (reason?: any) => void;
500
+ }
501
+
502
+ export declare interface IReferenceBinding {
503
+ wrapped: number;
504
+ tag: Uint32Array | null;
505
+ }
506
+
507
+ /** @public */
508
+ export declare function isExternal(object: unknown): object is External_2;
509
+
510
+ export declare function isReferenceType(v: any): v is object;
511
+
512
+ export declare interface IStoreValue {
513
+ id: number;
514
+ dispose(): void;
515
+ [x: string]: any;
516
+ }
517
+
518
+ export declare const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
519
+
520
+ export declare const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
521
+
522
+ export declare const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
523
+
524
+ export declare const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
525
+
526
+ export declare class NodeEnv extends Env {
527
+ filename: string;
528
+ private readonly nodeBinding?;
529
+ destructing: boolean;
530
+ finalizationScheduled: boolean;
531
+ constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
532
+ deleteMe(): void;
533
+ canCallIntoJs(): boolean;
534
+ triggerFatalException(err: any): void;
535
+ callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
536
+ callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
537
+ callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
538
+ enqueueFinalizer(finalizer: RefTracker): void;
539
+ drainFinalizerQueue(): void;
540
+ }
541
+
542
+ export declare class NotSupportBufferError extends EmnapiError {
543
+ constructor(api: string, message: string);
544
+ }
545
+
546
+ export declare class NotSupportWeakRefError extends EmnapiError {
547
+ constructor(api: string, message: string);
548
+ }
549
+
550
+ export declare class Persistent<T> {
551
+ private _ref;
552
+ private _param;
553
+ private _callback;
554
+ private static readonly _registry;
555
+ constructor(value: T);
556
+ setWeak<P>(param: P, callback: (param: P) => void): void;
557
+ clearWeak(): void;
558
+ reset(): void;
559
+ isEmpty(): boolean;
560
+ deref(): T | undefined;
561
+ }
562
+
563
+ export declare class Reference extends RefTracker implements IStoreValue {
564
+ private static weakCallback;
565
+ id: number;
566
+ envObject: Env;
567
+ private readonly canBeWeak;
568
+ private _refcount;
569
+ private readonly _ownership;
570
+ persistent: Persistent<object>;
571
+ static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
572
+ protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
573
+ ref(): number;
574
+ unref(): number;
575
+ get(envObject?: Env): napi_value;
576
+ /** @virtual */
577
+ resetFinalizer(): void;
578
+ /** @virtual */
579
+ data(): void_p;
580
+ refcount(): number;
581
+ ownership(): ReferenceOwnership;
582
+ /** @virtual */
583
+ protected callUserFinalizer(): void;
584
+ /** @virtual */
585
+ protected invokeFinalizerFromGC(): void;
586
+ private _setWeak;
587
+ finalize(): void;
588
+ dispose(): void;
589
+ }
590
+
591
+ export declare enum ReferenceOwnership {
592
+ kRuntime = 0,
593
+ kUserland = 1
594
+ }
595
+
596
+ export declare class ReferenceWithData extends Reference {
597
+ private readonly _data;
598
+ static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
599
+ private constructor();
600
+ data(): void_p;
601
+ }
602
+
603
+ export declare class ReferenceWithFinalizer extends Reference {
604
+ private _finalizer;
605
+ static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
606
+ private constructor();
607
+ resetFinalizer(): void;
608
+ data(): void_p;
609
+ protected callUserFinalizer(): void;
610
+ protected invokeFinalizerFromGC(): void;
611
+ dispose(): void;
612
+ }
613
+
614
+ export declare class RefTracker {
615
+ /** @virtual */
616
+ dispose(): void;
617
+ /** @virtual */
618
+ finalize(): void;
619
+ private _next;
620
+ private _prev;
621
+ link(list: RefTracker): void;
622
+ unlink(): void;
623
+ static finalizeAll(list: RefTracker): void;
624
+ }
625
+
626
+ export declare class ScopeStore {
627
+ private readonly _rootScope;
628
+ currentScope: HandleScope;
629
+ private readonly _values;
630
+ constructor();
631
+ get(id: number): HandleScope | undefined;
632
+ openScope(handleStore: HandleStore): HandleScope;
633
+ closeScope(): void;
634
+ dispose(): void;
635
+ }
636
+
637
+ export declare class Store<V extends IStoreValue> {
638
+ protected _values: Array<V | undefined>;
639
+ private _freeList;
640
+ private _size;
641
+ constructor();
642
+ add(value: V): void;
643
+ get(id: Ptr): V | undefined;
644
+ has(id: Ptr): boolean;
645
+ remove(id: Ptr): void;
646
+ dispose(): void;
647
+ }
648
+
649
+ export declare class TrackedFinalizer extends RefTracker {
650
+ private _finalizer;
651
+ static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
652
+ private constructor();
653
+ data(): void_p;
654
+ dispose(): void;
655
+ finalize(): void;
656
+ }
657
+
658
+ export declare class TryCatch {
659
+ private _exception;
660
+ private _caught;
661
+ isEmpty(): boolean;
662
+ hasCaught(): boolean;
663
+ exception(): any;
664
+ setError(err: any): void;
665
+ reset(): void;
666
+ extractException(): any;
667
+ }
668
+
669
+ export declare const version: string;
670
+
671
+ export { }
node_modules/@emnapi/runtime/dist/emnapi.cjs.min.js ADDED
@@ -0,0 +1 @@
 
 
1
+ const e=new WeakMap;function t(t){return e.has(t)}const i=(()=>{function t(t){Object.setPrototypeOf(this,null),e.set(this,t)}return t.prototype=null,t})();function s(i){if(!t(i))throw new TypeError("not external");return e.get(i)}const n=function(){let e;try{e=new Function}catch(e){return!1}return"function"==typeof e}(),r=function(){if("undefined"!=typeof globalThis)return globalThis;let e=function(){return this}();if(!e&&n)try{e=new Function("return this")()}catch(e){}if(!e){if("undefined"==typeof __webpack_public_path__&&"undefined"!=typeof global)return global;if("undefined"!=typeof window)return window;if("undefined"!=typeof self)return self}return e}();class o{constructor(){this._exception=void 0,this._caught=!1}isEmpty(){return!this._caught}hasCaught(){return this._caught}exception(){return this._exception}setError(e){this._caught=!0,this._exception=e}reset(){this._caught=!1,this._exception=void 0}extractException(){const e=this._exception;return this.reset(),e}}const a=function(){var e;try{return Boolean(null===(e=Object.getOwnPropertyDescriptor(Function.prototype,"name"))||void 0===e?void 0:e.configurable)}catch(e){return!1}}(),l="object"==typeof Reflect,c="undefined"!=typeof FinalizationRegistry&&"undefined"!=typeof WeakRef,h=function(){try{const e=Symbol();new WeakRef(e),(new WeakMap).set(e,void 0)}catch(e){return!1}return!0}(),u="undefined"!=typeof BigInt;const p=function(){let e;return e="undefined"!=typeof __webpack_public_path__||"undefined"!=typeof __webpack_public_path__?"undefined"!=typeof __non_webpack_require__?__non_webpack_require__:void 0:"undefined"!=typeof require?require:void 0,e}(),f="function"==typeof MessageChannel?MessageChannel:function(){try{return p("worker_threads").MessageChannel}catch(e){}}(),d="function"==typeof setImmediate?setImmediate:function(e){if("function"!=typeof e)throw new TypeError('The "callback" argument must be of type function');if(f){let t=new f;t.port1.onmessage=function(){t.port1.onmessage=null,t=void 0,e()},t.port2.postMessage(null)}else setTimeout(e,0)},_="function"==typeof Buffer?Buffer:function(){try{return p("buffer").Buffer}catch(e){}}(),v="1.11.1",g=2147483647;class y{constructor(e,t){this.id=e,this.value=t}data(){return s(this.value)}isNumber(){return"number"==typeof this.value}isBigInt(){return"bigint"==typeof this.value}isString(){return"string"==typeof this.value}isFunction(){return"function"==typeof this.value}isExternal(){return t(this.value)}isObject(){return"object"==typeof this.value&&null!==this.value}isArray(){return Array.isArray(this.value)}isArrayBuffer(){return this.value instanceof ArrayBuffer}isTypedArray(){return ArrayBuffer.isView(this.value)&&!(this.value instanceof DataView)}isBuffer(e){return!!ArrayBuffer.isView(this.value)||(null!=e||(e=_),"function"==typeof e&&e.isBuffer(this.value))}isDataView(){return this.value instanceof DataView}isDate(){return this.value instanceof Date}isPromise(){return this.value instanceof Promise}isBoolean(){return"boolean"==typeof this.value}isUndefined(){return void 0===this.value}isSymbol(){return"symbol"==typeof this.value}isNull(){return null===this.value}dispose(){this.value=void 0}}class x extends y{constructor(e,t){super(e,t)}dispose(){}}class z{constructor(){this._values=[void 0,z.UNDEFINED,z.NULL,z.FALSE,z.TRUE,z.GLOBAL],this._next=z.MIN_ID}push(e){let t;const i=this._next,s=this._values;return i<s.length?(t=s[i],t.value=e):(t=new y(i,e),s[i]=t),this._next++,t}erase(e,t){this._next=e;const i=this._values;for(let s=e;s<t;++s)i[s].dispose()}get(e){return this._values[e]}swap(e,t){const i=this._values,s=i[e];i[e]=i[t],i[e].id=Number(e),i[t]=s,s.id=Number(t)}dispose(){this._values.length=z.MIN_ID,this._next=z.MIN_ID}}z.UNDEFINED=new x(1,void 0),z.NULL=new x(2,null),z.FALSE=new x(3,!1),z.TRUE=new x(4,!0),z.GLOBAL=new x(5,r),z.MIN_ID=6;class k{constructor(e,t,i,s,n=s){this.handleStore=e,this.id=t,this.parent=i,this.child=null,null!==i&&(i.child=this),this.start=s,this.end=n,this._escapeCalled=!1,this.callbackInfo={thiz:void 0,data:0,args:void 0,fn:void 0}}add(e){const t=this.handleStore.push(e);return this.end++,t}addExternal(e){return this.add(new i(e))}dispose(){this._escapeCalled&&(this._escapeCalled=!1),this.start!==this.end&&this.handleStore.erase(this.start,this.end)}escape(e){if(this._escapeCalled)return null;if(this._escapeCalled=!0,e<this.start||e>=this.end)return null;this.handleStore.swap(e,this.start);const t=this.handleStore.get(this.start);return this.start++,this.parent.end++,t}escapeCalled(){return this._escapeCalled}}class b{constructor(){this._rootScope=new k(null,0,null,1,z.MIN_ID),this.currentScope=this._rootScope,this._values=[void 0]}get(e){return this._values[e]}openScope(e){const t=this.currentScope;let i=t.child;if(null!==i)i.start=i.end=t.end;else{const s=t.id+1;i=new k(e,s,t,t.end),this._values[s]=i}return this.currentScope=i,i}closeScope(){const e=this.currentScope;this.currentScope=e.parent,e.dispose()}dispose(){this.currentScope=this._rootScope,this._values.length=1}}class w{constructor(){this._next=null,this._prev=null}dispose(){}finalize(){}link(e){this._prev=e,this._next=e._next,null!==this._next&&(this._next._prev=this),e._next=this}unlink(){null!==this._prev&&(this._prev._next=this._next),null!==this._next&&(this._next._prev=this._prev),this._prev=null,this._next=null}static finalizeAll(e){for(;null!==e._next;)e._next.finalize()}}class m{constructor(e,t=0,i=0,s=0){this.envObject=e,this._finalizeCallback=t,this._finalizeData=i,this._finalizeHint=s,this._makeDynCall_vppp=e.makeDynCall_vppp}callback(){return this._finalizeCallback}data(){return this._finalizeData}hint(){return this._finalizeHint}resetEnv(){this.envObject=void 0}resetFinalizer(){this._finalizeCallback=0,this._finalizeData=0,this._finalizeHint=0}callFinalizer(){const e=this._finalizeCallback,t=this._finalizeData,i=this._finalizeHint;if(this.resetFinalizer(),!e)return;const s=Number(e);this.envObject?this.envObject.callFinalizer(s,t,i):this._makeDynCall_vppp(s)(0,t,i)}dispose(){this.envObject=void 0,this._makeDynCall_vppp=void 0}}class E extends w{static create(e,t,i,s){const n=new E(e,t,i,s);return n.link(e.finalizing_reflist),n}constructor(e,t,i,s){super(),this._finalizer=new m(e,t,i,s)}data(){return this._finalizer.data()}dispose(){this._finalizer&&(this.unlink(),this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),this._finalizer=void 0,super.dispose())}finalize(){let e;this.unlink();let t=!1;try{this._finalizer.callFinalizer()}catch(i){t=!0,e=i}if(this.dispose(),t)throw e}}function S(e,t){if(!e.terminatedOrTerminating())throw t}class C{constructor(e,t,i,s,n){this.ctx=e,this.moduleApiVersion=t,this.makeDynCall_vppp=i,this.makeDynCall_vp=s,this.abort=n,this.openHandleScopes=0,this.instanceData=null,this.tryCatch=new o,this.refs=1,this.reflist=new w,this.finalizing_reflist=new w,this.pendingFinalizers=[],this.lastError={errorCode:0,engineErrorCode:0,engineReserved:0},this.inGcFinalizer=!1,this._bindingMap=new WeakMap,this.id=0}canCallIntoJs(){return!0}terminatedOrTerminating(){return!this.canCallIntoJs()}ref(){this.refs++}unref(){this.refs--,0===this.refs&&this.dispose()}ensureHandle(e){return this.ctx.ensureHandle(e)}ensureHandleId(e){return this.ensureHandle(e).id}clearLastError(){const e=this.lastError;return 0!==e.errorCode&&(e.errorCode=0),0!==e.engineErrorCode&&(e.engineErrorCode=0),0!==e.engineReserved&&(e.engineReserved=0),0}setLastError(e,t=0,i=0){const s=this.lastError;return s.errorCode!==e&&(s.errorCode=e),s.engineErrorCode!==t&&(s.engineErrorCode=t),s.engineReserved!==i&&(s.engineReserved=i),e}getReturnStatus(){return this.tryCatch.hasCaught()?this.setLastError(10):0}callIntoModule(e,t=S){const i=this.openHandleScopes;this.clearLastError();const s=e(this);if(i!==this.openHandleScopes&&this.abort("open_handle_scopes != open_handle_scopes_before"),this.tryCatch.hasCaught()){t(this,this.tryCatch.extractException())}return s}invokeFinalizerFromGC(e){if(this.moduleApiVersion!==g)this.enqueueFinalizer(e);else{const t=this.inGcFinalizer;this.inGcFinalizer=!0;try{e.finalize()}finally{this.inGcFinalizer=t}}}checkGCAccess(){this.moduleApiVersion===g&&this.inGcFinalizer&&this.abort("Finalizer is calling a function that may affect GC state.\nThe finalizers are run directly from GC and must not affect GC state.\nUse `node_api_post_finalizer` from inside of the finalizer to work around this issue.\nIt schedules the call as a new task in the event loop.")}enqueueFinalizer(e){-1===this.pendingFinalizers.indexOf(e)&&this.pendingFinalizers.push(e)}dequeueFinalizer(e){const t=this.pendingFinalizers.indexOf(e);-1!==t&&this.pendingFinalizers.splice(t,1)}deleteMe(){w.finalizeAll(this.finalizing_reflist),w.finalizeAll(this.reflist),this.tryCatch.extractException(),this.ctx.envStore.remove(this.id)}dispose(){0!==this.id&&(this.deleteMe(),this.finalizing_reflist.dispose(),this.reflist.dispose(),this.id=0)}initObjectBinding(e){const t={wrapped:0,tag:null};return this._bindingMap.set(e,t),t}getObjectBinding(e){return this._bindingMap.has(e)?this._bindingMap.get(e):this.initObjectBinding(e)}setInstanceData(e,t,i){this.instanceData&&this.instanceData.dispose(),this.instanceData=E.create(this,t,e,i)}getInstanceData(){return this.instanceData?this.instanceData.data():0}}class F extends C{constructor(e,t,i,s,n,r,o){super(e,i,s,n,r),this.filename=t,this.nodeBinding=o,this.destructing=!1,this.finalizationScheduled=!1}deleteMe(){this.destructing=!0,this.drainFinalizerQueue(),super.deleteMe()}canCallIntoJs(){return super.canCallIntoJs()&&this.ctx.canCallIntoJs()}triggerFatalException(e){if(this.nodeBinding)this.nodeBinding.napi.fatalException(e);else{if("object"!=typeof process||null===process||"function"!=typeof process._fatalException)throw e;process._fatalException(e)||(console.error(e),process.exit(1))}}callbackIntoModule(e,t){return this.callIntoModule(t,(t,i)=>{if(t.terminatedOrTerminating())return;const s="object"==typeof process&&null!==process,n=!!s&&Boolean(process.execArgv&&-1!==process.execArgv.indexOf("--force-node-api-uncaught-exceptions-policy"));if(t.moduleApiVersion<10&&!n&&!e){return void(s&&"function"==typeof process.emitWarning?process.emitWarning:function(e,t,i){if(e instanceof Error)console.warn(e.toString());else{const s=i?`[${i}] `:"";console.warn(`${s}${t||"Warning"}: ${e}`)}})("Uncaught Node-API callback exception detected, please run node with option --force-node-api-uncaught-exceptions-policy=true to handle those exceptions properly.","DeprecationWarning","DEP0168")}t.triggerFatalException(i)})}callFinalizer(e,t,i){this.callFinalizerInternal(1,e,t,i)}callFinalizerInternal(e,t,i,s){const n=this.makeDynCall_vppp(t),r=this.id,o=this.ctx.openScope(this);try{this.callbackIntoModule(Boolean(e),()=>{n(r,i,s)})}finally{this.ctx.closeScope(this,o)}}enqueueFinalizer(e){super.enqueueFinalizer(e),this.finalizationScheduled||this.destructing||(this.finalizationScheduled=!0,this.ref(),d(()=>{this.finalizationScheduled=!1,this.unref(),this.drainFinalizerQueue()}))}drainFinalizerQueue(){for(;this.pendingFinalizers.length>0;){this.pendingFinalizers.shift().finalize()}}}function I(e,t,i,s,n,r,o){(i="number"!=typeof i?8:i)<8?i=8:i>10&&i!==g&&function(e,t){throw new Error(`${e} requires Node-API version ${t}, but this version of Node.js only supports version 10 add-ons.`)}(t,i);const a=new F(e,t,i,s,n,r,o);return e.envStore.add(a),e.addCleanupHook(a,()=>{a.unref()},0),a}class O extends Error{constructor(e){super(e);const t=new.target,i=t.prototype;if(!(this instanceof O)){const e=Object.setPrototypeOf;"function"==typeof e?e.call(Object,this,i):this.__proto__=i,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}}}Object.defineProperty(O.prototype,"name",{configurable:!0,writable:!0,value:"EmnapiError"});class D extends O{constructor(e,t){super(`${e}: The current runtime does not support "FinalizationRegistry" and "WeakRef".${t?` ${t}`:""}`)}}Object.defineProperty(D.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportWeakRefError"});class R extends O{constructor(e,t){super(`${e}: The current runtime does not support "Buffer". Consider using buffer polyfill to make sure \`globalThis.Buffer\` is defined.${t?` ${t}`:""}`)}}Object.defineProperty(R.prototype,"name",{configurable:!0,writable:!0,value:"NotSupportBufferError"});class N{constructor(e){this._value=e}deref(){return this._value}dispose(){this._value=void 0}}class A{constructor(e){this._ref=new N(e)}setWeak(e,t){if(!c||void 0===this._ref||this._ref instanceof WeakRef)return;const i=this._ref.deref();try{A._registry.register(i,this,this);const s=new WeakRef(i);this._ref.dispose(),this._ref=s,this._param=e,this._callback=t}catch(e){if("symbol"!=typeof i)throw e}}clearWeak(){if(c&&void 0!==this._ref&&this._ref instanceof WeakRef){try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0;const e=this._ref.deref();this._ref=void 0===e?e:new N(e)}}reset(){if(c)try{A._registry.unregister(this)}catch(e){}this._param=void 0,this._callback=void 0,this._ref instanceof N&&this._ref.dispose(),this._ref=void 0}isEmpty(){return void 0===this._ref}deref(){if(void 0!==this._ref)return this._ref.deref()}}var H;A._registry=c?new FinalizationRegistry(e=>{e._ref=void 0;const t=e._callback,i=e._param;e._callback=void 0,e._param=void 0,"function"==typeof t&&t(i)}):void 0,exports.ReferenceOwnership=void 0,(H=exports.ReferenceOwnership||(exports.ReferenceOwnership={}))[H.kRuntime=0]="kRuntime",H[H.kUserland=1]="kUserland";class j extends w{static weakCallback(e){e.persistent.reset(),e.invokeFinalizerFromGC()}static create(e,t,i,s,n,r,o){const a=new j(e,t,i,s);return e.ctx.refStore.add(a),a.link(e.reflist),a}constructor(e,t,i,s){super(),this.envObject=e,this._refcount=i,this._ownership=s;const n=e.ctx.handleStore.get(t);var r;this.canBeWeak=(r=n).isObject()||r.isFunction()||r.isSymbol(),this.persistent=new A(n.value),this.id=0,0===i&&this._setWeak()}ref(){return this.persistent.isEmpty()?0:(1===++this._refcount&&this.canBeWeak&&this.persistent.clearWeak(),this._refcount)}unref(){return this.persistent.isEmpty()||0===this._refcount?0:(0===--this._refcount&&this._setWeak(),this._refcount)}get(e=this.envObject){if(this.persistent.isEmpty())return 0;const t=this.persistent.deref();return e.ensureHandle(t).id}resetFinalizer(){}data(){return 0}refcount(){return this._refcount}ownership(){return this._ownership}callUserFinalizer(){}invokeFinalizerFromGC(){this.finalize()}_setWeak(){this.canBeWeak?this.persistent.setWeak(this,j.weakCallback):this.persistent.reset()}finalize(){this.persistent.reset();const e=this._ownership===exports.ReferenceOwnership.kRuntime;this.unlink(),this.callUserFinalizer(),e&&this.dispose()}dispose(){0!==this.id&&(this.unlink(),this.persistent.reset(),this.envObject.ctx.refStore.remove(this.id),super.dispose(),this.envObject=void 0,this.id=0)}}class B extends j{static create(e,t,i,s,n){const r=new B(e,t,i,s,n);return e.ctx.refStore.add(r),r.link(e.reflist),r}constructor(e,t,i,s,n){super(e,t,i,s),this._data=n}data(){return this._data}}class M extends j{static create(e,t,i,s,n,r,o){const a=new M(e,t,i,s,n,r,o);return e.ctx.refStore.add(a),a.link(e.finalizing_reflist),a}constructor(e,t,i,s,n,r,o){super(e,t,i,s),this._finalizer=new m(e,n,r,o)}resetFinalizer(){this._finalizer.resetFinalizer()}data(){return this._finalizer.data()}callUserFinalizer(){this._finalizer.callFinalizer()}invokeFinalizerFromGC(){this._finalizer.envObject.invokeFinalizerFromGC(this)}dispose(){this._finalizer&&(this._finalizer.envObject.dequeueFinalizer(this),this._finalizer.dispose(),super.dispose(),this._finalizer=void 0)}}class T{static create(e,t){const i=new T(e,t);return e.deferredStore.add(i),i}constructor(e,t){this.id=0,this.ctx=e,this.value=t}resolve(e){this.value.resolve(e),this.dispose()}reject(e){this.value.reject(e),this.dispose()}dispose(){this.ctx.deferredStore.remove(this.id),this.id=0,this.value=null,this.ctx=null}}class W{constructor(){this._values=[void 0],this._values.length=4,this._size=1,this._freeList=[]}add(e){let t;if(this._freeList.length)t=this._freeList.shift();else{t=this._size,this._size++;const e=this._values.length;t>=e&&(this._values.length=e+(e>>1)+16)}e.id=t,this._values[t]=e}get(e){return this._values[e]}has(e){return void 0!==this._values[e]}remove(e){const t=this._values[e];t&&(t.id=0,this._values[e]=void 0,this._freeList.push(Number(e)))}dispose(){for(let e=1;e<this._size;++e){const t=this._values[e];null==t||t.dispose()}this._values=[void 0],this._size=1,this._freeList=[]}}const L=BigInt(1)<<BigInt(60),P=-L;class U{constructor(e){this.total=BigInt(0),this.onChange=null!=e?e:null}adjust(e){if(e=BigInt(e),!(P<=e&&e<L))throw new RangeError(`changeInBytes ${e} is out of reasonable range`);const t=this.total;this.total+=e;const i=this.total,s=this.onChange;return e&&(null==s||s(i,t,e)),i}}class V{constructor(e,t,i,s){this.envObject=e,this.fn=t,this.arg=i,this.order=s}}class G{constructor(){this._cleanupHooks=[],this._cleanupHookCounter=0}empty(){return 0===this._cleanupHooks.length}add(e,t,i){if(this._cleanupHooks.filter(s=>s.envObject===e&&s.fn===t&&s.arg===i).length>0)throw new Error("Can not add same fn and arg twice");this._cleanupHooks.push(new V(e,t,i,this._cleanupHookCounter++))}remove(e,t,i){for(let s=0;s<this._cleanupHooks.length;++s){const n=this._cleanupHooks[s];if(n.envObject===e&&n.fn===t&&n.arg===i)return void this._cleanupHooks.splice(s,1)}}drain(){const e=this._cleanupHooks.slice();e.sort((e,t)=>t.order-e.order);for(let t=0;t<e.length;++t){const i=e[t];"number"==typeof i.fn?i.envObject.makeDynCall_vp(i.fn)(i.arg):i.fn(i.arg),this._cleanupHooks.splice(this._cleanupHooks.indexOf(i),1)}}dispose(){this._cleanupHooks.length=0,this._cleanupHookCounter=0}}class q{constructor(){this.refHandle=(new f).port1,this.count=0}increase(){0===this.count&&this.refHandle.ref&&this.refHandle.ref(),this.count++}decrease(){0!==this.count&&(1===this.count&&this.refHandle.unref&&this.refHandle.unref(),this.count--)}}class ${constructor(e){this._isStopping=!1,this._canCallIntoJs=!0,this._suppressDestroy=!1,this.envStore=new W,this.scopeStore=new b,this.refStore=new W,this.deferredStore=new W,this.handleStore=new z,this.feature={supportReflect:l,supportFinalizer:c,supportWeakSymbol:h,supportBigInt:u,supportNewFunction:n,canSetFunctionName:a,setImmediate:d,Buffer:_,MessageChannel:f},this.cleanupQueue=new G,this._externalMemory=new U(null==e?void 0:e.onExternalMemoryChange),"object"==typeof process&&null!==process&&"function"==typeof process.once&&(this.refCounter=new q,process.once("beforeExit",()=>{this._suppressDestroy||this.destroy()}))}suppressDestroy(){this._suppressDestroy=!0}getRuntimeVersions(){return{version:v,NODE_API_SUPPORTED_VERSION_MAX:10,NAPI_VERSION_EXPERIMENTAL:g,NODE_API_DEFAULT_MODULE_API_VERSION:8}}createNotSupportWeakRefError(e,t){return new D(e,t)}createNotSupportBufferError(e,t){return new R(e,t)}createReference(e,t,i,s){return j.create(e,t,i,s)}createReferenceWithData(e,t,i,s,n){return B.create(e,t,i,s,n)}createReferenceWithFinalizer(e,t,i,s,n=0,r=0,o=0){return M.create(e,t,i,s,n,r,o)}createDeferred(e){return T.create(this,e)}adjustAmountOfExternalAllocatedMemory(e){return this._externalMemory.adjust(e)}createEnv(e,t,i,s,n,r){return I(this,e,t,i,s,n,r)}createTrackedFinalizer(e,t,i,s){return E.create(e,t,i,s)}getCurrentScope(){return this.scopeStore.currentScope}addToCurrentScope(e){return this.scopeStore.currentScope.add(e)}openScope(e){const t=this.scopeStore.openScope(this.handleStore);return e&&e.openHandleScopes++,t}closeScope(e,t){e&&0===e.openHandleScopes||(this.scopeStore.closeScope(),e&&e.openHandleScopes--)}ensureHandle(e){switch(e){case void 0:return z.UNDEFINED;case null:return z.NULL;case!0:return z.TRUE;case!1:return z.FALSE;case r:return z.GLOBAL}return this.addToCurrentScope(e)}addCleanupHook(e,t,i){this.cleanupQueue.add(e,t,i)}removeCleanupHook(e,t,i){this.cleanupQueue.remove(e,t,i)}runCleanup(){for(;!this.cleanupQueue.empty();)this.cleanupQueue.drain()}increaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.increase()}decreaseWaitingRequestCounter(){var e;null===(e=this.refCounter)||void 0===e||e.decrease()}setCanCallIntoJs(e){this._canCallIntoJs=e}setStopping(e){this._isStopping=e}canCallIntoJs(){return this._canCallIntoJs&&!this._isStopping}destroy(){this.setStopping(!0),this.setCanCallIntoJs(!1),this.runCleanup()}}let J;function Q(e){return new $(e)}exports.ConstHandle=x,exports.Context=$,exports.Deferred=T,exports.EmnapiError=O,exports.Env=C,exports.External=i,exports.Finalizer=m,exports.Handle=y,exports.HandleScope=k,exports.HandleStore=z,exports.NAPI_VERSION_EXPERIMENTAL=g,exports.NODE_API_DEFAULT_MODULE_API_VERSION=8,exports.NODE_API_SUPPORTED_VERSION_MAX=10,exports.NODE_API_SUPPORTED_VERSION_MIN=1,exports.NodeEnv=F,exports.NotSupportBufferError=R,exports.NotSupportWeakRefError=D,exports.Persistent=A,exports.RefTracker=w,exports.Reference=j,exports.ReferenceWithData=B,exports.ReferenceWithFinalizer=M,exports.ScopeStore=b,exports.Store=W,exports.TrackedFinalizer=E,exports.TryCatch=o,exports.createContext=Q,exports.getDefaultContext=function(){return J||(J=Q()),J},exports.getExternalValue=s,exports.isExternal=t,exports.isReferenceType=function(e){return"object"==typeof e&&null!==e||"function"==typeof e},exports.version=v;
node_modules/@emnapi/runtime/dist/emnapi.d.mts ADDED
@@ -0,0 +1,671 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export declare type Ptr = number | bigint
2
+
3
+ export declare interface IBuffer extends Uint8Array {}
4
+ export declare interface BufferCtor {
5
+ readonly prototype: IBuffer
6
+ /** @deprecated */
7
+ new (...args: any[]): IBuffer
8
+ from: {
9
+ (buffer: ArrayBufferLike): IBuffer
10
+ (buffer: ArrayBufferLike, byteOffset: number, length: number): IBuffer
11
+ }
12
+ alloc: (size: number) => IBuffer
13
+ isBuffer: (obj: unknown) => obj is IBuffer
14
+ }
15
+
16
+ export declare const enum GlobalHandle {
17
+ UNDEFINED = 1,
18
+ NULL,
19
+ FALSE,
20
+ TRUE,
21
+ GLOBAL
22
+ }
23
+
24
+ export declare const enum Version {
25
+ NODE_API_SUPPORTED_VERSION_MIN = 1,
26
+ NODE_API_DEFAULT_MODULE_API_VERSION = 8,
27
+ NODE_API_SUPPORTED_VERSION_MAX = 10,
28
+ NAPI_VERSION_EXPERIMENTAL = 2147483647 // INT_MAX
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ export declare type Pointer<T> = number
32
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
+ export declare type PointerPointer<T> = number
34
+ export declare type FunctionPointer<T extends (...args: any[]) => any> = Pointer<T>
35
+ export declare type Const<T> = T
36
+
37
+ export declare type void_p = Pointer<void>
38
+ export declare type void_pp = Pointer<void_p>
39
+ export declare type bool = number
40
+ export declare type char = number
41
+ export declare type char_p = Pointer<char>
42
+ export declare type unsigned_char = number
43
+ export declare type const_char = Const<char>
44
+ export declare type const_char_p = Pointer<const_char>
45
+ export declare type char16_t_p = number
46
+ export declare type const_char16_t_p = number
47
+
48
+ export declare type short = number
49
+ export declare type unsigned_short = number
50
+ export declare type int = number
51
+ export declare type unsigned_int = number
52
+ export declare type long = number
53
+ export declare type unsigned_long = number
54
+ export declare type long_long = bigint
55
+ export declare type unsigned_long_long = bigint
56
+ export declare type float = number
57
+ export declare type double = number
58
+ export declare type long_double = number
59
+ export declare type size_t = number
60
+
61
+ export declare type int8_t = number
62
+ export declare type uint8_t = number
63
+ export declare type int16_t = number
64
+ export declare type uint16_t = number
65
+ export declare type int32_t = number
66
+ export declare type uint32_t = number
67
+ export declare type int64_t = bigint
68
+ export declare type uint64_t = bigint
69
+ export declare type napi_env = Pointer<unknown>
70
+
71
+ export declare type napi_value = Pointer<unknown>
72
+ export declare type napi_ref = Pointer<unknown>
73
+ export declare type napi_deferred = Pointer<unknown>
74
+ export declare type napi_handle_scope = Pointer<unknown>
75
+ export declare type napi_escapable_handle_scope = Pointer<unknown>
76
+
77
+ export declare type napi_addon_register_func = FunctionPointer<(env: napi_env, exports: napi_value) => napi_value>
78
+
79
+ export declare type napi_callback_info = Pointer<unknown>
80
+ export declare type napi_callback = FunctionPointer<(env: napi_env, info: napi_callback_info) => napi_value>
81
+
82
+ export declare interface napi_extended_error_info {
83
+ error_message: const_char_p
84
+ engine_reserved: void_p
85
+ engine_error_code: uint32_t
86
+ error_code: napi_status
87
+ }
88
+
89
+ export declare interface napi_property_descriptor {
90
+ // One of utf8name or name should be NULL.
91
+ utf8name: const_char_p
92
+ name: napi_value
93
+
94
+ method: napi_callback
95
+ getter: napi_callback
96
+ setter: napi_callback
97
+ value: napi_value
98
+ /* napi_property_attributes */
99
+ attributes: number
100
+ data: void_p
101
+ }
102
+
103
+ export declare type napi_finalize = FunctionPointer<(
104
+ env: napi_env,
105
+ finalize_data: void_p,
106
+ finalize_hint: void_p
107
+ ) => void>
108
+
109
+ export declare interface node_module {
110
+ nm_version: int32_t
111
+ nm_flags: uint32_t
112
+ nm_filename: Pointer<const_char>
113
+ nm_register_func: napi_addon_register_func
114
+ nm_modname: Pointer<const_char>
115
+ nm_priv: Pointer<void>
116
+ reserved: PointerPointer<void>
117
+ }
118
+
119
+ export declare interface napi_node_version {
120
+ major: uint32_t
121
+ minor: uint32_t
122
+ patch: uint32_t
123
+ release: const_char_p
124
+ }
125
+
126
+ export declare interface emnapi_emscripten_version {
127
+ major: uint32_t
128
+ minor: uint32_t
129
+ patch: uint32_t
130
+ }
131
+
132
+ export declare const enum napi_status {
133
+ napi_ok,
134
+ napi_invalid_arg,
135
+ napi_object_expected,
136
+ napi_string_expected,
137
+ napi_name_expected,
138
+ napi_function_expected,
139
+ napi_number_expected,
140
+ napi_boolean_expected,
141
+ napi_array_expected,
142
+ napi_generic_failure,
143
+ napi_pending_exception,
144
+ napi_cancelled,
145
+ napi_escape_called_twice,
146
+ napi_handle_scope_mismatch,
147
+ napi_callback_scope_mismatch,
148
+ napi_queue_full,
149
+ napi_closing,
150
+ napi_bigint_expected,
151
+ napi_date_expected,
152
+ napi_arraybuffer_expected,
153
+ napi_detachable_arraybuffer_expected,
154
+ napi_would_deadlock, // unused
155
+ napi_no_external_buffers_allowed,
156
+ napi_cannot_run_js
157
+ }
158
+
159
+ export declare const enum napi_property_attributes {
160
+ napi_default = 0,
161
+ napi_writable = 1 << 0,
162
+ napi_enumerable = 1 << 1,
163
+ napi_configurable = 1 << 2,
164
+
165
+ // Used with napi_define_class to distinguish static properties
166
+ // from instance properties. Ignored by napi_define_properties.
167
+ napi_static = 1 << 10,
168
+
169
+ /// #ifdef NAPI_EXPERIMENTAL
170
+ // Default for class methods.
171
+ napi_default_method = napi_writable | napi_configurable,
172
+
173
+ // Default for object properties, like in JS obj[prop].
174
+ napi_default_jsproperty = napi_writable | napi_enumerable | napi_configurable
175
+ /// #endif // NAPI_EXPERIMENTAL
176
+ }
177
+
178
+ export declare const enum napi_valuetype {
179
+ napi_undefined,
180
+ napi_null,
181
+ napi_boolean,
182
+ napi_number,
183
+ napi_string,
184
+ napi_symbol,
185
+ napi_object,
186
+ napi_function,
187
+ napi_external,
188
+ napi_bigint
189
+ }
190
+
191
+ export declare const enum napi_typedarray_type {
192
+ napi_int8_array,
193
+ napi_uint8_array,
194
+ napi_uint8_clamped_array,
195
+ napi_int16_array,
196
+ napi_uint16_array,
197
+ napi_int32_array,
198
+ napi_uint32_array,
199
+ napi_float32_array,
200
+ napi_float64_array,
201
+ napi_bigint64_array,
202
+ napi_biguint64_array,
203
+ napi_float16_array,
204
+ }
205
+
206
+ export declare const enum napi_key_collection_mode {
207
+ napi_key_include_prototypes,
208
+ napi_key_own_only
209
+ }
210
+
211
+ export declare const enum napi_key_filter {
212
+ napi_key_all_properties = 0,
213
+ napi_key_writable = 1,
214
+ napi_key_enumerable = 1 << 1,
215
+ napi_key_configurable = 1 << 2,
216
+ napi_key_skip_strings = 1 << 3,
217
+ napi_key_skip_symbols = 1 << 4
218
+ }
219
+
220
+ export declare const enum napi_key_conversion {
221
+ napi_key_keep_numbers,
222
+ napi_key_numbers_to_strings
223
+ }
224
+
225
+ export declare const enum emnapi_memory_view_type {
226
+ emnapi_int8_array,
227
+ emnapi_uint8_array,
228
+ emnapi_uint8_clamped_array,
229
+ emnapi_int16_array,
230
+ emnapi_uint16_array,
231
+ emnapi_int32_array,
232
+ emnapi_uint32_array,
233
+ emnapi_float32_array,
234
+ emnapi_float64_array,
235
+ emnapi_bigint64_array,
236
+ emnapi_biguint64_array,
237
+ emnapi_float16_array,
238
+ emnapi_data_view = -1,
239
+ emnapi_buffer = -2
240
+ }
241
+
242
+ export declare const enum napi_threadsafe_function_call_mode {
243
+ napi_tsfn_nonblocking,
244
+ napi_tsfn_blocking
245
+ }
246
+
247
+ export declare const enum napi_threadsafe_function_release_mode {
248
+ napi_tsfn_release,
249
+ napi_tsfn_abort
250
+ }
251
+ export declare type CleanupHookCallbackFunction = number | ((arg: number) => void);
252
+
253
+ export declare class ConstHandle<S extends undefined | null | boolean | typeof globalThis> extends Handle<S> {
254
+ constructor(id: number, value: S);
255
+ dispose(): void;
256
+ }
257
+
258
+ export declare class Context {
259
+ private _isStopping;
260
+ private _canCallIntoJs;
261
+ private _suppressDestroy;
262
+ envStore: Store<Env>;
263
+ scopeStore: ScopeStore;
264
+ refStore: Store<Reference>;
265
+ deferredStore: Store<Deferred<any>>;
266
+ handleStore: HandleStore;
267
+ private readonly refCounter?;
268
+ private readonly cleanupQueue;
269
+ private readonly _externalMemory;
270
+ feature: {
271
+ supportReflect: boolean;
272
+ supportFinalizer: boolean;
273
+ supportWeakSymbol: boolean;
274
+ supportBigInt: boolean;
275
+ supportNewFunction: boolean;
276
+ canSetFunctionName: boolean;
277
+ setImmediate: (callback: () => void) => void;
278
+ Buffer: BufferCtor | undefined;
279
+ MessageChannel: {
280
+ new (): MessageChannel;
281
+ prototype: MessageChannel;
282
+ } | undefined;
283
+ };
284
+ constructor(options?: ContextOptions);
285
+ /**
286
+ * Suppress the destroy on `beforeExit` event in Node.js.
287
+ * Call this method if you want to keep the context and
288
+ * all associated {@link Env | Env} alive,
289
+ * this also means that cleanup hooks will not be called.
290
+ * After call this method, you should call
291
+ * {@link Context.destroy | `Context.prototype.destroy`} method manually.
292
+ */
293
+ suppressDestroy(): void;
294
+ getRuntimeVersions(): {
295
+ version: string;
296
+ NODE_API_SUPPORTED_VERSION_MAX: Version;
297
+ NAPI_VERSION_EXPERIMENTAL: Version;
298
+ NODE_API_DEFAULT_MODULE_API_VERSION: Version;
299
+ };
300
+ createNotSupportWeakRefError(api: string, message: string): NotSupportWeakRefError;
301
+ createNotSupportBufferError(api: string, message: string): NotSupportBufferError;
302
+ createReference(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership): Reference;
303
+ createReferenceWithData(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): Reference;
304
+ createReferenceWithFinalizer(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback?: napi_finalize, finalize_data?: void_p, finalize_hint?: void_p): Reference;
305
+ createDeferred<T = any>(value: IDeferrdValue<T>): Deferred<T>;
306
+ adjustAmountOfExternalAllocatedMemory(changeInBytes: number | bigint): bigint;
307
+ createEnv(filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any): Env;
308
+ createTrackedFinalizer(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
309
+ getCurrentScope(): HandleScope | null;
310
+ addToCurrentScope<V>(value: V): Handle<V>;
311
+ openScope(envObject?: Env): HandleScope;
312
+ closeScope(envObject?: Env, _scope?: HandleScope): void;
313
+ ensureHandle<S>(value: S): Handle<S>;
314
+ addCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
315
+ removeCleanupHook(envObject: Env, fn: CleanupHookCallbackFunction, arg: number): void;
316
+ runCleanup(): void;
317
+ increaseWaitingRequestCounter(): void;
318
+ decreaseWaitingRequestCounter(): void;
319
+ setCanCallIntoJs(value: boolean): void;
320
+ setStopping(value: boolean): void;
321
+ canCallIntoJs(): boolean;
322
+ /**
323
+ * Destroy the context and call cleanup hooks.
324
+ * Associated {@link Env | Env} will be destroyed.
325
+ */
326
+ destroy(): void;
327
+ }
328
+
329
+ export declare interface ContextOptions {
330
+ onExternalMemoryChange?: (current: bigint, old: bigint, delta: bigint) => any;
331
+ }
332
+
333
+ export declare function createContext(options?: ContextOptions): Context;
334
+
335
+ export declare class Deferred<T = any> implements IStoreValue {
336
+ static create<T = any>(ctx: Context, value: IDeferrdValue<T>): Deferred;
337
+ id: number;
338
+ ctx: Context;
339
+ value: IDeferrdValue<T>;
340
+ constructor(ctx: Context, value: IDeferrdValue<T>);
341
+ resolve(value: T): void;
342
+ reject(reason?: any): void;
343
+ dispose(): void;
344
+ }
345
+
346
+ export declare class EmnapiError extends Error {
347
+ constructor(message?: string);
348
+ }
349
+
350
+ export declare abstract class Env implements IStoreValue {
351
+ readonly ctx: Context;
352
+ moduleApiVersion: number;
353
+ makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void;
354
+ makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void;
355
+ abort: (msg?: string) => never;
356
+ id: number;
357
+ openHandleScopes: number;
358
+ instanceData: TrackedFinalizer | null;
359
+ tryCatch: TryCatch;
360
+ refs: number;
361
+ reflist: RefTracker;
362
+ finalizing_reflist: RefTracker;
363
+ pendingFinalizers: RefTracker[];
364
+ lastError: {
365
+ errorCode: napi_status;
366
+ engineErrorCode: number;
367
+ engineReserved: Ptr;
368
+ };
369
+ inGcFinalizer: boolean;
370
+ constructor(ctx: Context, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never);
371
+ /** @virtual */
372
+ canCallIntoJs(): boolean;
373
+ terminatedOrTerminating(): boolean;
374
+ ref(): void;
375
+ unref(): void;
376
+ ensureHandle<S>(value: S): Handle<S>;
377
+ ensureHandleId(value: any): napi_value;
378
+ clearLastError(): napi_status;
379
+ setLastError(error_code: napi_status, engine_error_code?: uint32_t, engine_reserved?: void_p): napi_status;
380
+ getReturnStatus(): napi_status;
381
+ callIntoModule<T>(fn: (env: Env) => T, handleException?: (envObject: Env, value: any) => void): T;
382
+ /** @virtual */
383
+ abstract callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
384
+ invokeFinalizerFromGC(finalizer: RefTracker): void;
385
+ checkGCAccess(): void;
386
+ /** @virtual */
387
+ enqueueFinalizer(finalizer: RefTracker): void;
388
+ /** @virtual */
389
+ dequeueFinalizer(finalizer: RefTracker): void;
390
+ /** @virtual */
391
+ deleteMe(): void;
392
+ dispose(): void;
393
+ private readonly _bindingMap;
394
+ initObjectBinding<S extends object>(value: S): IReferenceBinding;
395
+ getObjectBinding<S extends object>(value: S): IReferenceBinding;
396
+ setInstanceData(data: number, finalize_cb: number, finalize_hint: number): void;
397
+ getInstanceData(): number;
398
+ }
399
+
400
+ /** @public */
401
+ declare interface External_2 extends Record<any, any> {
402
+ }
403
+
404
+ /** @public */
405
+ declare const External_2: {
406
+ new (value: number | bigint): External_2;
407
+ prototype: null;
408
+ };
409
+ export { External_2 as External }
410
+
411
+ export declare class Finalizer {
412
+ envObject: Env;
413
+ private _finalizeCallback;
414
+ private _finalizeData;
415
+ private _finalizeHint;
416
+ private _makeDynCall_vppp;
417
+ constructor(envObject: Env, _finalizeCallback?: napi_finalize, _finalizeData?: void_p, _finalizeHint?: void_p);
418
+ callback(): napi_finalize;
419
+ data(): void_p;
420
+ hint(): void_p;
421
+ resetEnv(): void;
422
+ resetFinalizer(): void;
423
+ callFinalizer(): void;
424
+ dispose(): void;
425
+ }
426
+
427
+ export declare function getDefaultContext(): Context;
428
+
429
+ /** @public */
430
+ export declare function getExternalValue(external: External_2): number | bigint;
431
+
432
+ export declare class Handle<S> {
433
+ id: number;
434
+ value: S;
435
+ constructor(id: number, value: S);
436
+ data(): void_p;
437
+ isNumber(): boolean;
438
+ isBigInt(): boolean;
439
+ isString(): boolean;
440
+ isFunction(): boolean;
441
+ isExternal(): boolean;
442
+ isObject(): boolean;
443
+ isArray(): boolean;
444
+ isArrayBuffer(): boolean;
445
+ isTypedArray(): boolean;
446
+ isBuffer(BufferConstructor?: BufferCtor): boolean;
447
+ isDataView(): boolean;
448
+ isDate(): boolean;
449
+ isPromise(): boolean;
450
+ isBoolean(): boolean;
451
+ isUndefined(): boolean;
452
+ isSymbol(): boolean;
453
+ isNull(): boolean;
454
+ dispose(): void;
455
+ }
456
+
457
+ export declare class HandleScope {
458
+ handleStore: HandleStore;
459
+ id: number;
460
+ parent: HandleScope | null;
461
+ child: HandleScope | null;
462
+ start: number;
463
+ end: number;
464
+ private _escapeCalled;
465
+ callbackInfo: ICallbackInfo;
466
+ constructor(handleStore: HandleStore, id: number, parentScope: HandleScope | null, start: number, end?: number);
467
+ add<V>(value: V): Handle<V>;
468
+ addExternal(data: void_p): Handle<object>;
469
+ dispose(): void;
470
+ escape(handle: number): Handle<any> | null;
471
+ escapeCalled(): boolean;
472
+ }
473
+
474
+ export declare class HandleStore {
475
+ static UNDEFINED: ConstHandle<undefined>;
476
+ static NULL: ConstHandle<null>;
477
+ static FALSE: ConstHandle<false>;
478
+ static TRUE: ConstHandle<true>;
479
+ static GLOBAL: ConstHandle<typeof globalThis>;
480
+ static MIN_ID: 6;
481
+ private readonly _values;
482
+ private _next;
483
+ push<S>(value: S): Handle<S>;
484
+ erase(start: number, end: number): void;
485
+ get(id: Ptr): Handle<any> | undefined;
486
+ swap(a: number, b: number): void;
487
+ dispose(): void;
488
+ }
489
+
490
+ export declare interface ICallbackInfo {
491
+ thiz: any;
492
+ data: void_p;
493
+ args: ArrayLike<any>;
494
+ fn: Function;
495
+ }
496
+
497
+ export declare interface IDeferrdValue<T = any> {
498
+ resolve: (value: T) => void;
499
+ reject: (reason?: any) => void;
500
+ }
501
+
502
+ export declare interface IReferenceBinding {
503
+ wrapped: number;
504
+ tag: Uint32Array | null;
505
+ }
506
+
507
+ /** @public */
508
+ export declare function isExternal(object: unknown): object is External_2;
509
+
510
+ export declare function isReferenceType(v: any): v is object;
511
+
512
+ export declare interface IStoreValue {
513
+ id: number;
514
+ dispose(): void;
515
+ [x: string]: any;
516
+ }
517
+
518
+ export declare const NAPI_VERSION_EXPERIMENTAL = Version.NAPI_VERSION_EXPERIMENTAL;
519
+
520
+ export declare const NODE_API_DEFAULT_MODULE_API_VERSION = Version.NODE_API_DEFAULT_MODULE_API_VERSION;
521
+
522
+ export declare const NODE_API_SUPPORTED_VERSION_MAX = Version.NODE_API_SUPPORTED_VERSION_MAX;
523
+
524
+ export declare const NODE_API_SUPPORTED_VERSION_MIN = Version.NODE_API_SUPPORTED_VERSION_MIN;
525
+
526
+ export declare class NodeEnv extends Env {
527
+ filename: string;
528
+ private readonly nodeBinding?;
529
+ destructing: boolean;
530
+ finalizationScheduled: boolean;
531
+ constructor(ctx: Context, filename: string, moduleApiVersion: number, makeDynCall_vppp: (cb: Ptr) => (a: Ptr, b: Ptr, c: Ptr) => void, makeDynCall_vp: (cb: Ptr) => (a: Ptr) => void, abort: (msg?: string) => never, nodeBinding?: any);
532
+ deleteMe(): void;
533
+ canCallIntoJs(): boolean;
534
+ triggerFatalException(err: any): void;
535
+ callbackIntoModule<T>(enforceUncaughtExceptionPolicy: boolean, fn: (env: Env) => T): T;
536
+ callFinalizer(cb: napi_finalize, data: void_p, hint: void_p): void;
537
+ callFinalizerInternal(forceUncaught: int, cb: napi_finalize, data: void_p, hint: void_p): void;
538
+ enqueueFinalizer(finalizer: RefTracker): void;
539
+ drainFinalizerQueue(): void;
540
+ }
541
+
542
+ export declare class NotSupportBufferError extends EmnapiError {
543
+ constructor(api: string, message: string);
544
+ }
545
+
546
+ export declare class NotSupportWeakRefError extends EmnapiError {
547
+ constructor(api: string, message: string);
548
+ }
549
+
550
+ export declare class Persistent<T> {
551
+ private _ref;
552
+ private _param;
553
+ private _callback;
554
+ private static readonly _registry;
555
+ constructor(value: T);
556
+ setWeak<P>(param: P, callback: (param: P) => void): void;
557
+ clearWeak(): void;
558
+ reset(): void;
559
+ isEmpty(): boolean;
560
+ deref(): T | undefined;
561
+ }
562
+
563
+ export declare class Reference extends RefTracker implements IStoreValue {
564
+ private static weakCallback;
565
+ id: number;
566
+ envObject: Env;
567
+ private readonly canBeWeak;
568
+ private _refcount;
569
+ private readonly _ownership;
570
+ persistent: Persistent<object>;
571
+ static create(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, _unused1?: void_p, _unused2?: void_p, _unused3?: void_p): Reference;
572
+ protected constructor(envObject: Env, handle_id: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership);
573
+ ref(): number;
574
+ unref(): number;
575
+ get(envObject?: Env): napi_value;
576
+ /** @virtual */
577
+ resetFinalizer(): void;
578
+ /** @virtual */
579
+ data(): void_p;
580
+ refcount(): number;
581
+ ownership(): ReferenceOwnership;
582
+ /** @virtual */
583
+ protected callUserFinalizer(): void;
584
+ /** @virtual */
585
+ protected invokeFinalizerFromGC(): void;
586
+ private _setWeak;
587
+ finalize(): void;
588
+ dispose(): void;
589
+ }
590
+
591
+ export declare enum ReferenceOwnership {
592
+ kRuntime = 0,
593
+ kUserland = 1
594
+ }
595
+
596
+ export declare class ReferenceWithData extends Reference {
597
+ private readonly _data;
598
+ static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, data: void_p): ReferenceWithData;
599
+ private constructor();
600
+ data(): void_p;
601
+ }
602
+
603
+ export declare class ReferenceWithFinalizer extends Reference {
604
+ private _finalizer;
605
+ static create(envObject: Env, value: napi_value, initialRefcount: uint32_t, ownership: ReferenceOwnership, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): ReferenceWithFinalizer;
606
+ private constructor();
607
+ resetFinalizer(): void;
608
+ data(): void_p;
609
+ protected callUserFinalizer(): void;
610
+ protected invokeFinalizerFromGC(): void;
611
+ dispose(): void;
612
+ }
613
+
614
+ export declare class RefTracker {
615
+ /** @virtual */
616
+ dispose(): void;
617
+ /** @virtual */
618
+ finalize(): void;
619
+ private _next;
620
+ private _prev;
621
+ link(list: RefTracker): void;
622
+ unlink(): void;
623
+ static finalizeAll(list: RefTracker): void;
624
+ }
625
+
626
+ export declare class ScopeStore {
627
+ private readonly _rootScope;
628
+ currentScope: HandleScope;
629
+ private readonly _values;
630
+ constructor();
631
+ get(id: number): HandleScope | undefined;
632
+ openScope(handleStore: HandleStore): HandleScope;
633
+ closeScope(): void;
634
+ dispose(): void;
635
+ }
636
+
637
+ export declare class Store<V extends IStoreValue> {
638
+ protected _values: Array<V | undefined>;
639
+ private _freeList;
640
+ private _size;
641
+ constructor();
642
+ add(value: V): void;
643
+ get(id: Ptr): V | undefined;
644
+ has(id: Ptr): boolean;
645
+ remove(id: Ptr): void;
646
+ dispose(): void;
647
+ }
648
+
649
+ export declare class TrackedFinalizer extends RefTracker {
650
+ private _finalizer;
651
+ static create(envObject: Env, finalize_callback: napi_finalize, finalize_data: void_p, finalize_hint: void_p): TrackedFinalizer;
652
+ private constructor();
653
+ data(): void_p;
654
+ dispose(): void;
655
+ finalize(): void;
656
+ }
657
+
658
+ export declare class TryCatch {
659
+ private _exception;
660
+ private _caught;
661
+ isEmpty(): boolean;
662
+ hasCaught(): boolean;
663
+ exception(): any;
664
+ setError(err: any): void;
665
+ reset(): void;
666
+ extractException(): any;
667
+ }
668
+
669
+ export declare const version: string;
670
+
671
+ export { }