@jesscss/less-parser 1.0.8-alpha.6 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -1
- package/lib/__tests__/debug-log.d.ts +1 -0
- package/lib/__tests__/debug-log.js +34 -0
- package/lib/__tests__/debug-log.js.map +1 -0
- package/lib/index.d.ts +30 -8
- package/lib/index.js +66 -29
- package/lib/index.js.map +1 -0
- package/lib/lessActionsParser.d.ts +156 -0
- package/lib/lessActionsParser.js +145 -0
- package/lib/lessActionsParser.js.map +1 -0
- package/lib/lessErrorMessageProvider.d.ts +3 -0
- package/lib/lessErrorMessageProvider.js +4 -0
- package/lib/lessErrorMessageProvider.js.map +1 -0
- package/lib/lessTokens.d.ts +22 -3
- package/lib/lessTokens.js +242 -148
- package/lib/lessTokens.js.map +1 -0
- package/lib/productions.d.ts +181 -0
- package/lib/productions.js +3521 -0
- package/lib/productions.js.map +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +88 -0
- package/lib/utils.js.map +1 -0
- package/package.json +41 -19
- package/lib/lessParser.d.ts +0 -36
- package/lib/lessParser.js +0 -49
- package/lib/productions/atRules.d.ts +0 -2
- package/lib/productions/atRules.js +0 -160
- package/lib/productions/blocks.d.ts +0 -2
- package/lib/productions/blocks.js +0 -60
- package/lib/productions/declarations.d.ts +0 -2
- package/lib/productions/declarations.js +0 -36
- package/lib/productions/interpolation.d.ts +0 -2
- package/lib/productions/interpolation.js +0 -18
- package/lib/productions/mixin.d.ts +0 -2
- package/lib/productions/mixin.js +0 -373
- package/lib/productions/root.d.ts +0 -2
- package/lib/productions/root.js +0 -33
- package/lib/productions/selectors.d.ts +0 -2
- package/lib/productions/selectors.js +0 -91
- package/lib/productions/values.d.ts +0 -2
- package/lib/productions/values.js +0 -305
package/lib/lessTokens.js
CHANGED
|
@@ -1,155 +1,249 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const merges = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
import { rawCssFragments, rawCssTokens, LexerType, groupCapture, SKIPPED_LABEL } from '@jesscss/css-parser';
|
|
2
|
+
function $preBuildFragments() {
|
|
3
|
+
const fragments = rawCssFragments();
|
|
4
|
+
fragments.unshift(['lineComment', '\\/\\/[^\\n\\r]*']);
|
|
5
|
+
fragments.push(['interpolated', '[@$]\\{(?:{{nmchar}}*)\\}']);
|
|
6
|
+
return fragments;
|
|
7
|
+
}
|
|
8
|
+
function $preBuildTokens() {
|
|
9
|
+
const tokens = rawCssTokens();
|
|
10
|
+
/**
|
|
11
|
+
* Keyed by what to insert after
|
|
12
|
+
*
|
|
13
|
+
* @todo - Move merge utility to css-parser
|
|
14
|
+
*/
|
|
15
|
+
const merges = {
|
|
16
|
+
Assign: [
|
|
17
|
+
{
|
|
18
|
+
name: 'Ellipsis',
|
|
19
|
+
pattern: /\.\.\./,
|
|
20
|
+
categories: ['BlockMarker']
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Less's historical parser unfortunately allows
|
|
24
|
+
* at-keywords that are not valid in CSS. One is
|
|
25
|
+
* that Less allows at-keywords to begin with numbers.
|
|
26
|
+
* Another is that it allows an at-rule that only
|
|
27
|
+
* contains a single dash. So we capture this as
|
|
28
|
+
* a separate token.
|
|
29
|
+
*
|
|
30
|
+
* We also do this later in the token stack so that we
|
|
31
|
+
* don't accidentally grab something like
|
|
32
|
+
* @-webkit-keyframes while looking for @-.
|
|
33
|
+
*/
|
|
34
|
+
{
|
|
35
|
+
name: 'AtKeywordLessExtension',
|
|
36
|
+
pattern: '@(?:-|\\d(?:{{nmchar}})*)',
|
|
37
|
+
categories: ['BlockMarker', 'AtName']
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
PlainIdent: [
|
|
41
|
+
{ name: 'Interpolated', pattern: LexerType.NA },
|
|
42
|
+
{
|
|
43
|
+
name: 'LineComment',
|
|
44
|
+
pattern: '{{lineComment}}',
|
|
45
|
+
label: SKIPPED_LABEL
|
|
46
|
+
},
|
|
47
|
+
{ name: 'PlusAssign', pattern: '\\+{{whitespace}}*:', categories: ['BlockMarker', 'Assign'] },
|
|
48
|
+
{
|
|
49
|
+
name: 'UnderscoreAssign',
|
|
50
|
+
pattern: '\\+{{whitespace}}*_{{whitespace}}*:',
|
|
51
|
+
categories: ['BlockMarker', 'Assign']
|
|
52
|
+
},
|
|
53
|
+
{ name: 'AnonMixinStart', pattern: /[.#]\(/, categories: ['BlockMarker'] },
|
|
54
|
+
{ name: 'GtEqAlias', pattern: /=>/, categories: ['CompareOperator'] },
|
|
55
|
+
{ name: 'LtEqAlias', pattern: /=</, categories: ['CompareOperator'] },
|
|
56
|
+
{
|
|
57
|
+
name: 'Extend',
|
|
58
|
+
pattern: /:extend\(/,
|
|
59
|
+
categories: ['BlockMarker']
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'VarOrProp',
|
|
63
|
+
pattern: LexerType.NA
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'NestedReference',
|
|
67
|
+
pattern: ['([@$]+{{ident}}?){2,}', groupCapture],
|
|
68
|
+
start_chars_hint: ['@', '$'],
|
|
69
|
+
categories: ['VarOrProp'],
|
|
70
|
+
line_breaks: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'PropertyReference',
|
|
74
|
+
pattern: '\\${{ident}}',
|
|
75
|
+
categories: ['VarOrProp']
|
|
76
|
+
},
|
|
77
|
+
/** Can be used in unit function or mod operation */
|
|
78
|
+
{
|
|
79
|
+
name: 'Percent',
|
|
80
|
+
pattern: /%/
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'DefaultGuardIdent',
|
|
84
|
+
pattern: /default/,
|
|
85
|
+
longer_alt: 'PlainIdent',
|
|
86
|
+
categories: ['Ident']
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'DefaultGuardFunc',
|
|
90
|
+
pattern: /default(?:\(\))/
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
Ampersand: [
|
|
94
|
+
{
|
|
95
|
+
name: 'AmpersandExtend',
|
|
96
|
+
pattern: /&:extend\(/,
|
|
97
|
+
categories: ['BlockMarker']
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'AllFlag',
|
|
101
|
+
pattern: /!all/,
|
|
102
|
+
categories: ['BlockMarker']
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
UrlStart: [
|
|
106
|
+
/**
|
|
107
|
+
* Keywords that we don't identify as idents
|
|
108
|
+
* should be manually added to other places where an ident is valid.
|
|
109
|
+
*/
|
|
110
|
+
{
|
|
111
|
+
name: 'When',
|
|
112
|
+
pattern: /when/i,
|
|
113
|
+
longer_alt: 'PlainIdent',
|
|
114
|
+
categories: ['BlockMarker']
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
name: 'FormatFunction',
|
|
118
|
+
pattern: /%\(/,
|
|
119
|
+
categories: ['BlockMarker', 'FunctionStart']
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'IfFunction',
|
|
123
|
+
pattern: /if\(/,
|
|
124
|
+
categories: ['BlockMarker', 'FunctionStart']
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
name: 'BooleanFunction',
|
|
128
|
+
pattern: /boolean\(/,
|
|
129
|
+
categories: ['BlockMarker', 'FunctionStart']
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: 'JavaScript',
|
|
133
|
+
pattern: /~?`[^`]*`/,
|
|
134
|
+
line_breaks: true
|
|
135
|
+
}
|
|
136
|
+
],
|
|
28
137
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
138
|
+
* These need to be after any keywords, so that
|
|
139
|
+
* keywords with a longer_alt of `PlainIdent`
|
|
140
|
+
* aren't captured first.
|
|
32
141
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
142
|
+
Signed: [
|
|
143
|
+
{
|
|
144
|
+
name: 'InterpolatedIdent',
|
|
145
|
+
/**
|
|
146
|
+
* Must contain one `@{}`
|
|
147
|
+
* It's too expensive for Chevrotain to capture groups here,
|
|
148
|
+
* so we'll extract the interpolated values later.
|
|
149
|
+
*/
|
|
150
|
+
pattern: '(?:{{ident}}|-)?{{interpolated}}(?:{{interpolated}}|{{nmchar}})*',
|
|
151
|
+
categories: ['Interpolated', 'Selector', 'Ident']
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'InterpolatedCustomProperty',
|
|
155
|
+
/**
|
|
156
|
+
* Must contain one `@{}`
|
|
157
|
+
* It's too expensive for Chevrotain to capture groups here,
|
|
158
|
+
* so we'll extract the interpolated values later.
|
|
159
|
+
*/
|
|
160
|
+
pattern: '--{{ident}}?{{interpolated}}(?:{{interpolated}}|{{nmchar}})*',
|
|
161
|
+
categories: ['Interpolated']
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* Unfortunately, there's grammatical ambiguity between
|
|
165
|
+
* interpolated props and a naked interpolated selector name,
|
|
166
|
+
* making this awkward token necessary.
|
|
167
|
+
*/
|
|
168
|
+
{
|
|
169
|
+
name: 'InterpolatedSelector',
|
|
170
|
+
pattern: ['[.#]{{ident}}?{{interpolated}}(?:{{interpolated}}|{{nmchar}})*', groupCapture],
|
|
171
|
+
categories: ['Interpolated', 'Selector'],
|
|
172
|
+
start_chars_hint: ['.', '#'],
|
|
173
|
+
line_breaks: true
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
};
|
|
177
|
+
let defaultTokens = tokens.modes.Default.slice();
|
|
178
|
+
let tokenLength = defaultTokens.length;
|
|
179
|
+
for (let i = 0; i < tokenLength; i++) {
|
|
180
|
+
let token = defaultTokens[i];
|
|
181
|
+
const { name } = token;
|
|
182
|
+
const copyToken = () => {
|
|
183
|
+
token = structuredClone(token);
|
|
184
|
+
};
|
|
185
|
+
let alterations = true;
|
|
186
|
+
switch (name) {
|
|
187
|
+
/**
|
|
188
|
+
* Less / Sass Ampersand is slightly different
|
|
189
|
+
* from CSS Nesting in that it concatenates, so we
|
|
190
|
+
* need to gobble up the rest of the identifier
|
|
191
|
+
* if present.
|
|
192
|
+
*/
|
|
193
|
+
case 'Ampersand':
|
|
194
|
+
copyToken();
|
|
195
|
+
/**
|
|
196
|
+
* Captures not just ampersands, but "ampersand merges", where
|
|
197
|
+
* the intent of the author was to merge the parent selector with a token
|
|
198
|
+
* suffix or prefix.
|
|
199
|
+
*
|
|
200
|
+
* e.g.
|
|
201
|
+
* 1. &-foo
|
|
202
|
+
* 2. &(foo)
|
|
203
|
+
* 3. &1
|
|
204
|
+
* 4. .foo-&
|
|
205
|
+
*/
|
|
206
|
+
token.pattern = '(?:[.#](?:{{ident}}-)?&|&)(?:\\((?:[.#]|{{nmchar}}|&)+\\)|{{nmchar}}*)';
|
|
207
|
+
token.start_chars_hint = ['&', '.', '#'];
|
|
208
|
+
break;
|
|
209
|
+
case 'DotName':
|
|
210
|
+
case 'HashName':
|
|
211
|
+
copyToken();
|
|
212
|
+
token.longer_alt = 'Ampersand';
|
|
213
|
+
break;
|
|
214
|
+
case 'Divide':
|
|
215
|
+
copyToken();
|
|
216
|
+
token.pattern = /\.?\//;
|
|
217
|
+
break;
|
|
218
|
+
case 'SingleQuoteStart':
|
|
219
|
+
copyToken();
|
|
220
|
+
token.pattern = /~?'/;
|
|
221
|
+
break;
|
|
222
|
+
case 'DoubleQuoteStart':
|
|
223
|
+
copyToken();
|
|
224
|
+
token.pattern = /~?"/;
|
|
225
|
+
break;
|
|
226
|
+
default:
|
|
227
|
+
alterations = false;
|
|
73
228
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// {
|
|
77
|
-
// name: 'AtPlugin',
|
|
78
|
-
// pattern: /@plugin/,
|
|
79
|
-
// longer_alt: 'AtKeyword',
|
|
80
|
-
// categories: ['BlockMarker', 'AtName']
|
|
81
|
-
// }
|
|
82
|
-
// ],
|
|
83
|
-
PlainFunction: [
|
|
84
|
-
/** Can be used in unit function */
|
|
85
|
-
{
|
|
86
|
-
name: 'Percent',
|
|
87
|
-
pattern: /%/
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: 'FormatFunction',
|
|
91
|
-
pattern: /%\(/,
|
|
92
|
-
categories: ['BlockMarker', 'Function']
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'IfFunction',
|
|
96
|
-
pattern: /if\(/,
|
|
97
|
-
categories: ['BlockMarker', 'Function']
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: 'BooleanFunction',
|
|
101
|
-
pattern: /boolean\(/,
|
|
102
|
-
categories: ['BlockMarker', 'Function']
|
|
229
|
+
if (alterations) {
|
|
230
|
+
defaultTokens[i] = token;
|
|
103
231
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
232
|
+
// @ts-expect-error - Suppress index warning
|
|
233
|
+
const merge = merges[name];
|
|
234
|
+
if (merge) {
|
|
235
|
+
/** Insert after current token */
|
|
236
|
+
defaultTokens = defaultTokens.slice(0, i + 1).concat(merge, defaultTokens.slice(i + 1));
|
|
237
|
+
tokens.modes.Default = defaultTokens;
|
|
238
|
+
const mergeLength = merge.length;
|
|
239
|
+
tokenLength += mergeLength;
|
|
240
|
+
i += mergeLength;
|
|
111
241
|
}
|
|
112
|
-
]
|
|
113
|
-
};
|
|
114
|
-
let tokenLength = exports.Tokens.length;
|
|
115
|
-
for (let i = 0; i < tokenLength; i++) {
|
|
116
|
-
let token = exports.Tokens[i];
|
|
117
|
-
let { name, categories } = token;
|
|
118
|
-
const copyToken = () => {
|
|
119
|
-
token = Object.assign({}, token);
|
|
120
|
-
categories = categories ? categories.slice(0) : [];
|
|
121
|
-
};
|
|
122
|
-
let alterations = true;
|
|
123
|
-
switch (name) {
|
|
124
|
-
// Removed in Less v5
|
|
125
|
-
// case 'Divide':
|
|
126
|
-
// copyToken()
|
|
127
|
-
// token.pattern = /\.?\//
|
|
128
|
-
// break
|
|
129
|
-
case 'StringLiteral':
|
|
130
|
-
copyToken();
|
|
131
|
-
token.pattern = '~?{{string1}}|~?{{string2}}';
|
|
132
|
-
break;
|
|
133
|
-
case 'CustomProperty':
|
|
134
|
-
copyToken();
|
|
135
|
-
token.pattern = '--(?:{{nmstart}}{{nmchar}}*)?';
|
|
136
|
-
break;
|
|
137
|
-
case 'AtKeyword':
|
|
138
|
-
copyToken();
|
|
139
|
-
token.categories = categories.concat(['VarOrProp']);
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
alterations = false;
|
|
143
|
-
}
|
|
144
|
-
if (alterations) {
|
|
145
|
-
exports.Tokens[i] = token;
|
|
146
|
-
}
|
|
147
|
-
const merge = merges[name];
|
|
148
|
-
if (merge) {
|
|
149
|
-
/** Insert after current token */
|
|
150
|
-
exports.Tokens = exports.Tokens.slice(0, i + 1).concat(merge, exports.Tokens.slice(i + 1));
|
|
151
|
-
const mergeLength = merge.length;
|
|
152
|
-
tokenLength += mergeLength;
|
|
153
|
-
i += mergeLength;
|
|
154
242
|
}
|
|
243
|
+
return tokens;
|
|
155
244
|
}
|
|
245
|
+
export const Fragments = $preBuildFragments();
|
|
246
|
+
export const Tokens = $preBuildTokens();
|
|
247
|
+
export const lessFragments = () => Fragments;
|
|
248
|
+
export const lessTokens = () => Tokens;
|
|
249
|
+
//# sourceMappingURL=lessTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lessTokens.js","sourceRoot":"","sources":["../src/lessTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,SAAS,EACT,YAAY,EAMZ,aAAa,EACd,MAAM,qBAAqB,CAAC;AAsC7B,SAAS,kBAAkB;IACzB,MAAM,SAAS,GAAG,eAAe,EAA2B,CAAC;IAC7D,SAAS,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC;IACvD,SAAS,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAC,CAAC;IAE9D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,eAAe;IAWtB,MAAM,MAAM,GAAG,YAAY,EAAgC,CAAC;IAE5D;;;;MAIE;IACF,MAAM,MAAM,GAAG;QACb,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,QAAQ;gBACjB,UAAU,EAAE,CAAC,aAAa,CAAC;aAC5B;YACD;;;;;;;;;;;eAWG;YACH;gBACE,IAAI,EAAE,wBAAwB;gBAC9B,OAAO,EAAE,2BAA2B;gBACpC,UAAU,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC;aACtC;SACF;QACD,UA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AAG,OAAO,CAAC;gBACxB,MAAM;YACR,KAAK,kBAAkB;gBACrB,SAAS,EAAE,CAAC;gBACZ,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;gBACtB,MAAM;YACR,KAAK,kBAAkB;gBACrB,SAAS,EAAE,CAAC;gBACZ,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;gBACtB,MAAM;YACR;gBACE,WAAW,GAAG,KAAK,CAAC;QACxB,CAAC;QACD,IAAI,WAAW,EAAE,CAAC;YAChB,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC;QACD,4CAA4C;QAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,KAAK,EAAE,CAAC;YACV,iCAAiC;YACjC,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACvF,MAAM,CAAC,KAAK,CAAC,OAAiC,GAAG,aAAa,CAAC;YAChE,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;YACjC,WAAW,IAAI,WAAW,CAAC;YAC3B,CAAC,IAAI,WAAW,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAmB,EAAE,CAAC;AAC/C,MAAM,CAAC,MAAM,MAAM,GAAG,eAAgB,EAAE,CAAC;AAOzC,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,SAAiE,CAAC;AACrG,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,MAAkC,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { type LessActionsParser as P, type TokenMap, type RuleContext } from './lessActionsParser.js';
|
|
2
|
+
import { type IToken } from 'chevrotain';
|
|
3
|
+
import { type AltContext } from '@jesscss/css-parser';
|
|
4
|
+
import { Node, Block, Any, Ruleset, List, Sequence, Call, Paren, Quoted, AtRule, Mixin, Condition, VarDeclaration, DefaultGuard, StyleImport, Expression, SelectorCapture, CompoundSelector, Rules, Nil, Collection, type Selector, type SimpleSelector } from '@jesscss/core';
|
|
5
|
+
/** Charset moved within `main` (explained in that rule) */
|
|
6
|
+
export declare function stylesheet(this: P, T: TokenMap): (options?: Record<string, any>) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
7
|
+
export declare function main(this: P, T: TokenMap): (ctx?: RuleContext) => Rules | undefined;
|
|
8
|
+
export declare function declarationList(this: P, T: TokenMap): (ctx?: RuleContext) => Rules | undefined;
|
|
9
|
+
export declare function declaration(this: P, T: TokenMap): (ctx?: RuleContext) => import("@jesscss/core").CustomDeclaration | undefined;
|
|
10
|
+
export declare function mediaInParens(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
11
|
+
export declare function containerInParens(this: P, _T: TokenMap, _alt?: AltContext): (ctx?: RuleContext) => any;
|
|
12
|
+
export declare function mfValue(this: P, _T: TokenMap): (ctx?: RuleContext) => any;
|
|
13
|
+
export declare function mfNonIdentifierValue(this: P, T: TokenMap, _alt?: AltContext): (ctx?: RuleContext) => any;
|
|
14
|
+
export declare function wrappedDeclarationList(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
15
|
+
export declare function qualifiedRuleBody(this: P, T: TokenMap): (ctx?: RuleContext) => Ruleset<{
|
|
16
|
+
selector: Selector<any, import("core/lib/tree/node-base.js").NodeOptions>;
|
|
17
|
+
rules: any;
|
|
18
|
+
guard: Condition | undefined;
|
|
19
|
+
}> | undefined;
|
|
20
|
+
export declare function qualifiedRule(this: P, _T: TokenMap, altContext?: AltContext): (ctx?: RuleContext) => any;
|
|
21
|
+
/**
|
|
22
|
+
* In order to not do any backtracking, anything with a class or id selector start
|
|
23
|
+
* will end up here, and everything else will be shunted to the qualified rule.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mixinOrQualifiedRule(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
26
|
+
/**
|
|
27
|
+
* We need to now handle a returned `Extend` node from the complexSelector rule
|
|
28
|
+
*/
|
|
29
|
+
export declare function relativeSelector(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
30
|
+
export declare function compoundSelector(this: P, T: TokenMap): (ctx?: RuleContext) => CompoundSelector | SimpleSelector<any, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* Extended with :extend
|
|
33
|
+
*/
|
|
34
|
+
export declare function complexSelector(this: P, T: TokenMap): (ctx?: RuleContext) => Selector<any, import("core/lib/tree/node-base.js").NodeOptions>;
|
|
35
|
+
/**
|
|
36
|
+
* &:extend(...) statement ending with a semicolon.
|
|
37
|
+
* This is the only valid standalone extend statement in Less.
|
|
38
|
+
*/
|
|
39
|
+
export declare function ampersandExtend(this: P, T: TokenMap): (ctx?: RuleContext) => Nil | undefined;
|
|
40
|
+
export declare function extend(this: P, T: TokenMap): (ctx?: RuleContext) => void;
|
|
41
|
+
export declare function simpleSelector(this: P, T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
42
|
+
export declare function anonymousMixinDefinition(this: P, T: TokenMap): (ctx?: RuleContext) => Mixin | Collection | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Mostly copied from css importAtRule, but it maps
|
|
45
|
+
* differently to Jess nodes depending on if it's meant
|
|
46
|
+
* to be a Jess-style import or just an at-rule
|
|
47
|
+
*/
|
|
48
|
+
export declare function importAtRule(this: P, T: TokenMap): (ctx?: RuleContext) => AtRule | StyleImport | undefined;
|
|
49
|
+
/** Less variables */
|
|
50
|
+
export declare function varDeclarationOrCall(this: P, T: TokenMap): (ctx?: RuleContext) => Expression | VarDeclaration | undefined;
|
|
51
|
+
export declare function selectorCapture(this: P, T: TokenMap): (ctx?: RuleContext) => SelectorCapture | undefined;
|
|
52
|
+
export declare function valueSequence(this: P, _T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | Sequence | undefined;
|
|
53
|
+
export declare function squareValue(this: P, T: TokenMap): (ctx?: RuleContext) => Block | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* In CSS, would be a single value.
|
|
56
|
+
* In Less, these are math expressions which
|
|
57
|
+
* represent a single value. During AST construction,
|
|
58
|
+
* these will be grouped by order of operations.
|
|
59
|
+
*/
|
|
60
|
+
export declare function expressionSum(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
61
|
+
export declare function expressionProduct(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
62
|
+
export declare function expressionValue(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
63
|
+
/**
|
|
64
|
+
* Add interpolation
|
|
65
|
+
*/
|
|
66
|
+
export declare function nthValue(this: P, T: TokenMap): (ctx?: import("@jesscss/css-parser").RuleContext) => Any<"any"> | undefined;
|
|
67
|
+
export declare function knownFunctions(this: P, T: TokenMap): (ctx?: import("@jesscss/css-parser").RuleContext) => any;
|
|
68
|
+
/**
|
|
69
|
+
* Override CSS calc() parsing so we can maintain parse-time `calcFrames`.
|
|
70
|
+
* This is the parse-time analogue of `Call.evalNode`'s calcFrames++/--.
|
|
71
|
+
*/
|
|
72
|
+
export declare function calcFunction(this: P, T: TokenMap): (ctx?: RuleContext) => Call | undefined;
|
|
73
|
+
export declare function ifFunction(this: P, T: TokenMap): (ctx?: RuleContext) => Call | undefined;
|
|
74
|
+
export declare function booleanFunction(this: P, T: TokenMap): (ctx?: RuleContext) => Expression | undefined;
|
|
75
|
+
/** At AST time, join comma-lists together if separated by semis */
|
|
76
|
+
export declare function varReference(this: P, T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
77
|
+
export declare function valueReference(this: P, _T: TokenMap): (ctx?: RuleContext) => any;
|
|
78
|
+
export declare function functionCall(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
79
|
+
export declare function functionCallArgs(this: P, T: TokenMap): (ctx?: RuleContext) => List<Node<unknown, import("core/lib/tree/node-base.js").NodeOptions>> | undefined;
|
|
80
|
+
export declare function value(this: P, T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
81
|
+
export declare function string(this: P, T: TokenMap): (_ctx?: RuleContext) => Quoted | undefined;
|
|
82
|
+
export declare function mathValue(this: P, T: TokenMap): (ctx?: import("@jesscss/css-parser").RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
83
|
+
/** @todo - add interpolation */
|
|
84
|
+
export declare function guard(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
85
|
+
/**
|
|
86
|
+
* 'or' expression
|
|
87
|
+
* Allows an (outer) comma like historical media queries
|
|
88
|
+
*/
|
|
89
|
+
export declare function guardOr(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
90
|
+
export declare function guardDefault(this: P, T: TokenMap): (ctx?: RuleContext) => DefaultGuard | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* 'and' and 'or' expressions
|
|
93
|
+
*
|
|
94
|
+
* In Media queries level 4, you cannot have
|
|
95
|
+
* `([expr]) or ([expr]) and ([expr])` because
|
|
96
|
+
* of evaluation order ambiguity.
|
|
97
|
+
* However, Less allows it.
|
|
98
|
+
*/
|
|
99
|
+
export declare function guardAnd(this: P, T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions>;
|
|
100
|
+
export declare function guardInParens(this: P, T: TokenMap): (ctx: RuleContext) => Paren | undefined;
|
|
101
|
+
export declare function guardInner(this: P, _T: TokenMap): (ctx?: RuleContext) => any;
|
|
102
|
+
export declare function guardWithConditionValue(this: P, T: TokenMap): (ctx?: RuleContext) => void;
|
|
103
|
+
export declare function guardWithCondition(this: P, T: TokenMap): (ctx?: RuleContext) => void;
|
|
104
|
+
/**
|
|
105
|
+
* Currently, Less only allows a single comparison expression,
|
|
106
|
+
* unlike Media Queries Level 4, which allows a left and right
|
|
107
|
+
* comparison.
|
|
108
|
+
*/
|
|
109
|
+
export declare function comparison(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
110
|
+
/**
|
|
111
|
+
* Less (perhaps unwisely) allows bubling of normally document-root
|
|
112
|
+
* at-rules, so we need to override CSS here.
|
|
113
|
+
*/
|
|
114
|
+
export declare function innerAtRule(this: P, T: TokenMap): (ctx?: import("@jesscss/css-parser").RuleContext) => any;
|
|
115
|
+
/**
|
|
116
|
+
* Less override: allow variable reference as the first segment of a layer-name
|
|
117
|
+
* CSS: <ident> ('.' <ident>)*
|
|
118
|
+
* Less: (<var-ref> | <ident>) ('.' <ident>)*
|
|
119
|
+
*/
|
|
120
|
+
export declare function layerName(this: P, T: TokenMap): (ctx?: RuleContext) => Sequence | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* Less override: allow variable reference for @keyframes name
|
|
123
|
+
* CSS: Ident | String
|
|
124
|
+
* Less: valueReference | Ident | String
|
|
125
|
+
*/
|
|
126
|
+
export declare function keyframesName(this: P, T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions>;
|
|
127
|
+
/**
|
|
128
|
+
* One of the rare rules that returns a token, because
|
|
129
|
+
* other rules will transform it differently.
|
|
130
|
+
*/
|
|
131
|
+
export declare function mixinName(this: P, T: TokenMap): (ctx?: RuleContext) => Node<unknown, import("core/lib/tree/node-base.js").NodeOptions> | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Used within a value. These can be
|
|
134
|
+
* chained more recursively, unlike
|
|
135
|
+
* Less 1.x-4.x
|
|
136
|
+
* e.g. .mixin1() > .mixin2[@val1].ns() > .sub-mixin[@val2]
|
|
137
|
+
*
|
|
138
|
+
* This production intelligently decides whether to produce a Call or Reference
|
|
139
|
+
* based on whether there are parentheses at the end:
|
|
140
|
+
* - foo: #id; // Reference
|
|
141
|
+
* - foo: .class; // Reference
|
|
142
|
+
* - foo: #id > .scoped; // Reference
|
|
143
|
+
* - foo: #id > .scoped(); // Call
|
|
144
|
+
* - foo: #id[]; // Reference with accessor
|
|
145
|
+
* - foo: #id > .scoped[foo]; // Reference with accessor
|
|
146
|
+
* - foo: #id > .scoped[@ref](); // Call with accessor
|
|
147
|
+
*/
|
|
148
|
+
export declare function mixinReference(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
149
|
+
export declare function mixinArgs(this: P, T: TokenMap): (ctx?: RuleContext) => List<Node<unknown, import("core/lib/tree/node-base.js").NodeOptions>> | undefined;
|
|
150
|
+
export declare function lookupOrCall(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
151
|
+
/**
|
|
152
|
+
* @see https://lesscss.org/features/#mixins-feature-mixins-parametric-feature
|
|
153
|
+
*
|
|
154
|
+
* This rule is recursive to allow chevrotain-allstar (hopefully) to lookahead
|
|
155
|
+
* and find semi-colon separators vs. commas.
|
|
156
|
+
*/
|
|
157
|
+
export declare function mixinArgList(this: P, T: TokenMap): (ctx?: RuleContext) => List<Node<unknown, import("core/lib/tree/node-base.js").NodeOptions>> | undefined;
|
|
158
|
+
/**
|
|
159
|
+
* Less is more lenient about at-keywords. See lessTokens.ts for more details.
|
|
160
|
+
*/
|
|
161
|
+
export declare function varName(this: P, T: TokenMap): () => IToken;
|
|
162
|
+
/**
|
|
163
|
+
* Originally, we were creating alternatives for mixin calls and mixin definitions
|
|
164
|
+
* that could mostly overlap, which led to longer parsing. Instead, we parse
|
|
165
|
+
* as if it could be either, and then we disambiguate at the end.
|
|
166
|
+
*/
|
|
167
|
+
export declare function mixinArg(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
168
|
+
export declare function callArgument(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
169
|
+
/**
|
|
170
|
+
* Override unknownAtRule to handle @-export for stylesheet forwarding.
|
|
171
|
+
* @-export is like @-compose but with forward semantics and no `with` support.
|
|
172
|
+
*/
|
|
173
|
+
export declare function unknownAtRule(this: P, T: TokenMap): (ctx?: RuleContext) => any;
|
|
174
|
+
/**
|
|
175
|
+
* Parse @-export './foo.jess' [as <namespace>]
|
|
176
|
+
*
|
|
177
|
+
* Creates a StyleImport with forward semantics (members not visible locally but transitive).
|
|
178
|
+
* Does NOT support `with` (unlike @-compose).
|
|
179
|
+
* Participates in evaldTrees caching like @-compose.
|
|
180
|
+
*/
|
|
181
|
+
export declare function exportAtRule(this: P, T: TokenMap): (ctx?: RuleContext) => StyleImport | undefined;
|