@jesscss/less-parser 2.0.0-alpha.8 → 2.0.0-alpha.9

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.
Files changed (58) hide show
  1. package/README.md +27 -10
  2. package/lib/ast/grammar.d.ts +2 -0
  3. package/lib/ast/grammar.d.ts.map +1 -0
  4. package/lib/grammar.cjs +39855 -31054
  5. package/lib/grammar.d.ts.map +1 -1
  6. package/lib/grammar.js +39855 -31054
  7. package/lib/index.cjs +49609 -15
  8. package/lib/index.d.ts +4 -9
  9. package/lib/index.d.ts.map +1 -1
  10. package/lib/index.js +49607 -5
  11. package/lib/parse-error.d.ts +15 -0
  12. package/lib/parse-error.d.ts.map +1 -0
  13. package/package.json +9 -24
  14. package/lib/builders.d.ts +0 -381
  15. package/lib/builders.d.ts.map +0 -1
  16. package/lib/functional-parser.cjs +0 -2654
  17. package/lib/functional-parser.d.ts +0 -18
  18. package/lib/functional-parser.d.ts.map +0 -1
  19. package/lib/functional-parser.js +0 -2589
  20. package/lib/jess.cjs +0 -3968
  21. package/lib/jess.d.ts +0 -7
  22. package/lib/jess.d.ts.map +0 -1
  23. package/lib/jess.js +0 -3962
  24. package/lib/lessParser.d.ts +0 -38
  25. package/lib/lessParser.d.ts.map +0 -1
  26. package/lib/lessRecursiveParser.d.ts +0 -99
  27. package/lib/lessRecursiveParser.d.ts.map +0 -1
  28. package/lib/lessTokens.d.ts +0 -23
  29. package/lib/lessTokens.d.ts.map +0 -1
  30. package/lib/productions/guards.d.ts +0 -113
  31. package/lib/productions/guards.d.ts.map +0 -1
  32. package/lib/productions/index.d.ts +0 -5
  33. package/lib/productions/index.d.ts.map +0 -1
  34. package/lib/productions/root.d.ts +0 -38
  35. package/lib/productions/root.d.ts.map +0 -1
  36. package/lib/productions/selectors.d.ts +0 -41
  37. package/lib/productions/selectors.d.ts.map +0 -1
  38. package/lib/productions/values.d.ts +0 -35
  39. package/lib/productions/values.d.ts.map +0 -1
  40. package/lib/utils.d.ts +0 -9
  41. package/lib/utils.d.ts.map +0 -1
  42. package/src/__tests__/debug-log.ts +0 -35
  43. package/src/__tests__/wall5-parse.test.ts +0 -67
  44. package/src/builders.ts +0 -3190
  45. package/src/cst.ts +0 -25
  46. package/src/functional-parser.ts +0 -162
  47. package/src/grammar.ts +0 -870
  48. package/src/index.ts +0 -19
  49. package/src/jess.ts +0 -6
  50. package/src/lessParser.ts +0 -120
  51. package/src/lessRecursiveParser.ts +0 -279
  52. package/src/lessTokens.ts +0 -350
  53. package/src/productions/guards.ts +0 -1066
  54. package/src/productions/index.ts +0 -29
  55. package/src/productions/root.ts +0 -1613
  56. package/src/productions/selectors.ts +0 -1309
  57. package/src/productions/values.ts +0 -1449
  58. package/src/utils.ts +0 -178
@@ -0,0 +1,15 @@
1
+ /** Structured failure from the public direct Less parser. */
2
+ export declare class LessParseError extends SyntaxError {
3
+ readonly code: 'parse/syntax-error';
4
+ readonly offset: number;
5
+ readonly expected: readonly string[];
6
+ constructor(offset: number, expected: readonly string[]);
7
+ }
8
+ /** Less 5 deliberately rejects interpolation inside the CSS @charset token. */
9
+ export declare class LessDynamicCharsetError extends SyntaxError {
10
+ readonly code: 'parse/dynamic-charset';
11
+ readonly offset: number;
12
+ readonly endOffset: number;
13
+ constructor(offset: number, endOffset: number);
14
+ }
15
+ //# sourceMappingURL=parse-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-error.d.ts","sourceRoot":"","sources":["../src/parse-error.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,IAAI,EAAG,oBAAoB,CAAU;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAErC,YAAY,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,MAAM,EAAE,EAMtD;CACF;AAED,+EAA+E;AAC/E,qBAAa,uBAAwB,SAAQ,WAAW;IACtD,QAAQ,CAAC,IAAI,EAAG,uBAAuB,CAAU;IACjD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,YAAY,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAK5C;CACF"}
package/package.json CHANGED
@@ -4,48 +4,38 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "2.0.0-alpha.8",
7
+ "version": "2.0.0-alpha.9",
8
8
  "description": "Jess LESS parser",
9
9
  "main": "lib/index.cjs",
10
10
  "types": "lib/index.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
13
  "types": "./lib/index.d.ts",
14
- "source": "./src/index.ts",
15
14
  "import": "./lib/index.js",
16
15
  "require": "./lib/index.cjs"
17
16
  },
18
17
  "./cst": {
19
18
  "types": "./lib/cst.d.ts",
20
- "source": "./src/cst.ts",
21
19
  "import": "./lib/cst.js",
22
20
  "require": "./lib/cst.cjs"
23
21
  },
24
22
  "./grammar": {
25
23
  "types": "./lib/grammar.d.ts",
26
- "source": "./src/grammar.ts",
27
24
  "import": "./lib/grammar.js",
28
25
  "require": "./lib/grammar.cjs"
29
26
  },
30
- "./jess": {
31
- "types": "./lib/jess.d.ts",
32
- "source": "./src/jess.ts",
33
- "import": "./lib/jess.js",
34
- "require": "./lib/jess.cjs"
35
- },
36
27
  "./package.json": "./package.json"
37
28
  },
38
29
  "files": [
39
- "lib",
40
- "src"
30
+ "lib"
41
31
  ],
42
32
  "dependencies": {
43
- "chevrotain": "^12.0.0",
44
33
  "known-css-properties": "~0.37.0",
45
- "@jesscss/css-parser": "2.0.0-alpha.8"
34
+ "@jesscss/css-parser": "2.0.0-alpha.9"
46
35
  },
47
36
  "peerDependencies": {
48
- "@jesscss/core": "2.0.0-alpha.8"
37
+ "parseman": "^0.30.0",
38
+ "@jesscss/core": "2.0.0-alpha.9"
49
39
  },
50
40
  "peerDependenciesMeta": {
51
41
  "@jesscss/core": {
@@ -55,9 +45,10 @@
55
45
  "devDependencies": {
56
46
  "@types/node": "^18.19.31",
57
47
  "less": "^4.6.3",
58
- "parseman": "link:/Users/matthew/git/oss/parser-thing",
48
+ "parseman": "0.30.0",
59
49
  "tsx": "~4.21.0",
60
- "@jesscss/core": "2.0.0-alpha.8",
50
+ "@jesscss/core": "2.0.0-alpha.9",
51
+ "@jesscss/internal-css-recognition": "0.0.0",
61
52
  "@jesscss/shared": "2.0.0-alpha.1"
62
53
  },
63
54
  "author": "Matthew Dean <matthew-dean@users.noreply.github.com>",
@@ -69,16 +60,10 @@
69
60
  "module": "lib/index.js",
70
61
  "scripts": {
71
62
  "ci": "pnpm build && pnpm test",
72
- "build": "pnpm compile",
63
+ "build": "pnpm --filter @jesscss/internal-css-recognition build && pnpm compile",
73
64
  "compile": "tsdown --tsconfig tsconfig.build.json --no-dts && tsc -p tsconfig.build.json --emitDeclarationOnly --noCheck",
74
65
  "dev": "tsdown --tsconfig tsconfig.build.json --watch",
75
- "bench": "node --import ../../scripts/parseman-macro-register.mjs --import tsx test/bench.ts",
76
- "bench:save": "node --import ../../scripts/parseman-macro-register.mjs --import tsx test/bench.ts --save",
77
- "bench:memory": "node --expose-gc --import ../../scripts/parseman-macro-register.mjs --import tsx test/bench.ts --memory",
78
- "bench:heap": "node --expose-gc --import ../../scripts/parseman-macro-register.mjs --import tsx test/bench.ts --heap-snapshot",
79
66
  "test": "cross-env TEST=true vitest --watch=false",
80
- "test:debug": "cross-env TEST=true TEST_DEBUG=true vitest --watch=false test/debug-self-analysis.test.ts test/debug-subset-self-analysis.test.ts",
81
- "test:perf": "cross-env TEST=true TEST_PERF=true vitest --watch=false test/perf.test.ts",
82
67
  "test:coverage": "cross-env TEST=true vitest --coverage",
83
68
  "lint:fix": "eslint --fix '**/*.{js,ts}'",
84
69
  "lint": "eslint '**/*.{js,ts}'"
package/lib/builders.d.ts DELETED
@@ -1,381 +0,0 @@
1
- /**
2
- * LessGrammar — builder methods for the Less grammar.
3
- *
4
- * Builder-only class: no grammar rules, no Parséman Parser base.
5
- * Grammar rules live in grammar-fn.ts (macro-compiled functional grammar),
6
- * which uses LessGrammar via a thin BuilderHost subclass.
7
- * Extends CssParser to inherit the shared CSS builder methods.
8
- */
9
- import type { FieldMap, Span } from 'parseman';
10
- import type { CSTLeaf, CSTError } from 'parseman';
11
- import { CssParser, type Spanned, type Component } from '@jesscss/css-parser/jess';
12
- import { type Node, type LocationInfo, Ruleset, type MathMode, Quoted } from '@jesscss/core';
13
- type JessNode = Node<any, any>;
14
- type Child = JessNode | CSTLeaf | CSTError;
15
- export declare class LessGrammar extends CssParser {
16
- /** Math mode governing when arithmetic operates / when `/` divides. Less default. */
17
- mathMode: MathMode;
18
- /** Bare ident/keyword token in value or guard position. */
19
- private _lessKeyword;
20
- private _isKeywordLike;
21
- private _isEmptyKeywordLike;
22
- protected buildNode(type: string, span: Span, children: ReadonlyArray<JessNode | CSTLeaf | CSTError>, _state: unknown, _rawChildren: ReadonlyArray<{
23
- _tag: string;
24
- }>, fields?: FieldMap, triviaLog?: readonly number[]): JessNode;
25
- /**
26
- * The operand of a `Negative` (`-value`). The grammar emits the leading `-`
27
- * as a leaf followed by the operand, which may itself be a node or a bare
28
- * string terminal (e.g. `-@color` → `var(--color)`'s inner `-color-accent`).
29
- * Prefer a node child; otherwise take the operand leaf's text so `Negative`
30
- * coerces it to the canonical node form rather than receiving `undefined`.
31
- */
32
- private _negativeOperand;
33
- private _buildVarDeclaration;
34
- /**
35
- * Build a Less variable reference and its accessor/call chain. Faithful 1:1
36
- * port of the Chevrotain `varReference` + `lookupOrCall` productions
37
- * (productions/values.ts, productions/guards.ts): a `@var` base glued to a
38
- * left-folded chain of `[index]` accessors and `(call)`s. The grammar's
39
- * noTrivia() guarantees the chain is adjacent (no whitespace between segments).
40
- */
41
- private _buildReference;
42
- /**
43
- * Build a namespace INDEXED-accessor value: a `.`/`#` selector-path head glued to
44
- * a `[accessor]` (and any further `[accessor]`/`(call)` chain), e.g.
45
- * `#ns.options[val1]`. The grammar (NsAccessor) captures this as ONE value operand
46
- * so it survives arithmetic folding; here we reassemble it into the mixin-ruleset
47
- * name Reference + accessor chain — the SAME shape the declaration-value
48
- * _assembleSegment path produces for a lone `#ns.options[val1]`. Call-headed forms
49
- * (`.mixin()`, `.mixin()[k]`) do NOT reach here (they keep the GluedParen path).
50
- * Leaves: [ headText, '[', key?, ']', '(', content?, ')' … ].
51
- */
52
- private _buildNsAccessor;
53
- /**
54
- * Apply one `[key]` accessor to `base`, reproducing lookupOrCall's key logic:
55
- * type is `variable` when the key token starts with `@`, else `index`; the key
56
- * text runs through getInterpolatedOrString (handling `$@x`/`@{x}` interpolation),
57
- * and index keys are wrapped in a Quoted.
58
- */
59
- private _applyReferenceAccessor;
60
- /**
61
- * Build mixin-call args for a `(…)` segment in a reference chain from the raw
62
- * captured content. Comma-separated values become a List; an empty segment
63
- * yields null (no args). Sub-structure here is intentionally shallow — the
64
- * accessor-chain call form is rare and no consumer inspects nested arg shape.
65
- */
66
- private _buildRefCallArgs;
67
- private _buildNamedColor;
68
- private _normalizeCompareOp;
69
- /** A guard comparison operator leaf (`=`, `<`, `>=`, `=<`, `=~`, …). */
70
- private _isCompareOpLeaf;
71
- /**
72
- * Split a guard term's ordered components into `left [op right]`. A bare-keyword
73
- * operand (`foo`, `true`) is a leaf string — not a node — so `nodeChildren`
74
- * alone drops it; walk the ordered stream so string operands become real
75
- * keyword nodes (their guard truthiness is decided at eval by `Condition`).
76
- */
77
- private _guardComparison;
78
- private _buildComparison;
79
- /**
80
- * Coerce a `_assembleValue` result — a single Component or a raw space-group
81
- * array — into ONE Node, so it can be a Condition operand. A single string
82
- * becomes a keyword; a space-group array becomes a `Sequence` (the same coercion
83
- * the List serializer applies to a raw group).
84
- */
85
- private _condOperandNode;
86
- /**
87
- * `CondArgTerm` — a name-independent condition-argument term: optional leading
88
- * `not`, a bounded value operand, and an optional `<op> right` comparison. Builds
89
- * a `Condition` (comparison → `[left, op, right]`; bare `not` → `{negate:true}`)
90
- * or, when neither a `not` nor a `compareOp` is present, the plain operand value
91
- * (byte-identical to an ordinary value arg). Multi-token operands (`1px solid`)
92
- * survive as a `Sequence`, unlike the single-operand guard path.
93
- */
94
- private _buildCondArgTerm;
95
- /**
96
- * Fold a left-associative `and`/`or` chain of condition-arg terms into Conditions.
97
- *
98
- * Less accepts a bare `and`/`or` join in value-position condition args (`if(@a > 5
99
- * and @b < 2, …)`) — verified against less@4.6.7 (`if`/`boolean` route their arg
100
- * through `condition()` with no `needsParens`, so bare comparisons split on `and`/
101
- * `or`). We keep accepting the bare form for Less parity, but NORMALIZE the AST so
102
- * each join operand is `Paren`-wrapped: `@a > 5 and @b < 2` builds the SAME tree as
103
- * the explicitly-parenthesised `(@a > 5) and (@b < 2)`. This is a structural
104
- * normalisation only — `Paren(Condition)` evaluates to the same boolean as the bare
105
- * `Condition`, so rendered CSS is byte-identical. A single unjoined operand (one
106
- * node) is untouched (no synthetic Paren).
107
- */
108
- private _buildCondArgJoin;
109
- /** Coerce a default() call/reference into a DefaultGuard, mirroring isDefaultGuardCall. */
110
- private _maybeDefaultGuard;
111
- /** guardInParens: `(` guardOr `)` → Paren, or a bare default() → Paren(DefaultGuard). */
112
- private _buildGuardInParens;
113
- /** A single guard term: optional `not`, then a paren-guard or a comparison/value. */
114
- private _buildGuardTerm;
115
- /** Fold a left-associative chain of terms joined by `and` / `or`. */
116
- private _buildGuardJoin;
117
- /** guard: `when` guardOr — returns the single guardOr child. */
118
- private _buildGuard;
119
- /**
120
- * Deprecated Less `%(format, args…)` string formatting, LOWERED at build time.
121
- *
122
- * Jess already has full string interpolation, so `%()` is redundant Less-4 legacy —
123
- * we emit a `percent-format` deprecation warning and, when the format is a string
124
- * literal, splice its `%[sda]` directives into the canonical `Interpolated` node
125
- * (the same one `@{var}` string interpolation builds), wrapped in a `Quoted` that
126
- * preserves the literal's quote char / escaped flag:
127
- * - `%s` → bare interpolation slot (a Quoted arg inserts with its quotes stripped);
128
- * - `%d`/`%a` → identical bare slot (d/a are the same in Less);
129
- * - `%S`/`%D`/`%A` → the arg WRAPPED in `escape(…)` (URL-encode);
130
- * - `%%` → a literal `%`.
131
- * A dynamic (non-literal) format (`%(hello)`, `%(e("…"), …)`) can't be lowered at
132
- * parse time, so it falls back to a best-effort runtime `%` Call with the same warning.
133
- */
134
- private _buildFormatCall;
135
- /**
136
- * Turn a printf-style format string into an `Interpolated` source + replacements.
137
- * `%[sda]` → one `INTERPOLATION_PLACEHOLDER` slot consuming the next positional arg
138
- * (uppercase → wrapped in `escape(…)` to URL-encode); `%%` → a literal `%`.
139
- */
140
- private _lowerFormatString;
141
- private _buildInterpolatedSelector;
142
- private _buildLessPseudo;
143
- private _buildLessDeclaration;
144
- /**
145
- * Port of `processLegacyMSFilterToken` (lessRecursiveParser.ts): a `progid:…`
146
- * filter value string → Interpolated(role=any) with `@var` runs templated out,
147
- * or a plain Keyword when the run has no variables.
148
- */
149
- private _buildLegacyMSFilter;
150
- private _buildAmpersand;
151
- /** The append value of a `&`-led ampersand token: the suffix after `&` (`&-bar` →
152
- * `-bar`, `&1` → `1`), or undefined for a bare `&`. */
153
- private _ampersandTemplateValue;
154
- /**
155
- * A single extend target inside `extend( … )`: a complex selector plus its
156
- * optional `all` / `!all` flag (selectors.ts `complexSelector`'s OPTION2 flag).
157
- * Produced as an `Extend` carrier the surrounding pseudo/statement groups.
158
- */
159
- private _buildExtendTarget;
160
- /**
161
- * `:extend( … )` pseudo form (selectors.ts `extend`): groups its ExtendTarget
162
- * children. Targets sharing one flag collapse to a single Extend whose target is
163
- * a SelectorList (or the lone selector); mixed flags stay as one Extend each,
164
- * returned in a List. Mirrors mergeExtends' target-and-flag grouping.
165
- */
166
- private _buildExtendPseudo;
167
- /**
168
- * `&:extend( … );` (or bare `:extend( … );`) statement form (selectors.ts
169
- * `ampersandExtend`). The ExtendPseudo child already carries the grouped
170
- * Extend(s); the leading `&` is just the statement marker.
171
- */
172
- private _buildExtendStatement;
173
- /**
174
- * Decode a single `[key]` accessor into its Less lookup-key AST — the ONE shared
175
- * decoder for every accessor-chain builder path (var-decl value, declaration value,
176
- * at-rule prelude, namespace ref). Accepts either a raw authored key STRING (the
177
- * text inside the brackets, e.g. `@@foo`, `$@x`, `bar`, ``), or a SquareParen `Paren`
178
- * node whose inner content the grammar already parsed (a raw string or a `@var`
179
- * Reference). Returns the key exactly as the reference lookupOrCall production would:
180
- *
181
- * `[]` → -1 (index, empty)
182
- * `[@@name]` → Reference{type:variable,key:name} (dynamic variable lookup)
183
- * `[$@name]` / `[@$name]` → Quoted(Interpolated(@name)) (dynamic property lookup)
184
- * `[@name]` → 'name' (static variable lookup; bare string key)
185
- * `[$name]` → Quoted('name') (property lookup; `$` marker dropped)
186
- * `[name]` → Quoted('name') (index)
187
- *
188
- * Exactly one `@`/`$` marker is the lookup marker and is never kept.
189
- */
190
- private _decodeAccessorKey;
191
- protected _assembleSegment(seg: Spanned[], loc: LocationInfo): Component;
192
- private _buildEscapedValue;
193
- private _buildInterpValue;
194
- /**
195
- * A quoted string value. Unlike plain CSS, Less interpolates `@{var}` / `${prop}`
196
- * inside quoted (and escaped `~"…"`) strings and inside `@import` paths. When the
197
- * raw content holds an interpolation, split it into an `Interpolated` value the same
198
- * way the reference parser's `processStringInterpolation` does (source with
199
- * INTERPOLATION_PLACEHOLDER, `@var`/`$prop` references in `replacements`); otherwise
200
- * fall through to the plain CSS builder (bare-string value).
201
- */
202
- /**
203
- * The Less `Url` grammar tokenizes the inner string as bare leaves (no child
204
- * node), so the css base builder wraps a quoted url body in a raw-string
205
- * `Quoted` — which never interpolates `@{var}`/`${prop}`. Less 4.x DOES resolve
206
- * interpolation inside a QUOTED url body (`url("@{base}/@{i}.svg")`), the same as
207
- * any other quoted string, so route the quoted inner through the same
208
- * interpolation-aware construction `_buildQuoted` uses. Unquoted url bodies stay
209
- * verbatim (Less 4.x leaves `url(@{x})` literal), as does a quoted body with no
210
- * interpolation.
211
- */
212
- protected _buildUrl(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode;
213
- protected _buildQuoted(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode | Quoted;
214
- /**
215
- * Build an escaped `~'…'` Quoted (at-rule prelude position), interpolating any
216
- * `@{var}` / `${prop}` in its body the same way `_buildQuoted` does — so
217
- * `~'@{a} / @{b}'` renders its substituted values instead of literal text.
218
- */
219
- private _buildEscapedQuoted;
220
- /**
221
- * Split a quoted-string body on `@{…}` / `${…}` interpolations into an
222
- * `Interpolated` (source + reference replacements). Port of the reference parser's
223
- * `processStringInterpolation`/`findInterpolations` (productions/values.ts): brace
224
- * matching is nesting-aware, and a nested-interpolated name resolves through a
225
- * variable Reference wrapped in an Expression.
226
- */
227
- private _buildStringInterpolation;
228
- /**
229
- * Locate `@{…}` / `${…}` interpolation runs in a string, counting nested braces so
230
- * `@{@{x}}` and `@{fn(a, b)}` are matched whole. Returns start/end/prefix/content.
231
- */
232
- private _findInterpolations;
233
- protected _buildCall(rawChildren: ReadonlyArray<{
234
- _tag: string;
235
- }>, loc: LocationInfo): JessNode;
236
- private _buildLessCustomDecl;
237
- /**
238
- * `--foo: { color: @a; }` — a curly-brace custom-property value whose body
239
- * opportunistically structured as a declaration list (customCurlyBlock in the
240
- * grammar), so nested `@var`/calls evaluate normally instead of staying opaque
241
- * text. Wrapped in a Block(type: 'curly') so `{`/`}` re-render around it.
242
- */
243
- private _buildLessCustomBlock;
244
- private _warnDeprecatedValue;
245
- private _warnCustomPropVars;
246
- private _warnAtRulePreludeVars;
247
- /**
248
- * The first bare `@ident` reference in an at-rule prelude that is deprecated
249
- * under Less 4.x PR #4462 (`variable-in-at-rule-prelude`), or null when there
250
- * is none. A bare `@var` in a *structural* (top-level) prelude position still
251
- * resolves but is deprecated in favour of `@{var}` interpolation; the scan
252
- * therefore ignores, mirroring `hasTopLevelBareVariable` / `warnBareAtRuleVariable`:
253
- * - the leading at-rule name itself (`@media`, `@-moz-document`, …);
254
- * - `@{ident}` interpolation — the supported migration target;
255
- * - a `@var` inside `(...)` — a declaration/feature value (e.g. the `@size`
256
- * in `@media (min-width: @size)`), which stays valid;
257
- * - `@`/`(` characters inside string literals, which are not structural.
258
- */
259
- private _firstTopLevelBareAtVar;
260
- private _buildMixinCall;
261
- /**
262
- * `@name(...)` (no `:`) → a detached-ruleset variable CALL. Faithful port of
263
- * `varDeclarationOrCall`'s LParen branch (selectors.ts): build a `Reference`
264
- * over the var name (`type: 'variable', role: 'name'`), wrap in a `Call` with
265
- * the (optional) args, and wrap THAT in an `Expression` (a top-level variable
266
- * call is an expression, not a parenthesized one). `!important` sets
267
- * `markImportant` on the Call, mirroring the production.
268
- */
269
- private _buildVarCall;
270
- /** `...` or `@name...` variadic arg → `Rest`. Definition-shape (string name); a
271
- * CALL turns it into `Rest(Reference)` via `_convertArgsForCall`. */
272
- private _buildRest;
273
- /** `@name: value` named arg/param → `VarDeclaration`. The value is assembled by the
274
- * shared value builder (`_assembleValue`) — the same machinery as a declaration
275
- * value, so trivia and Keyword-ification are handled and no manual trimming is
276
- * needed. Named args flow through function calls too; the runtime decides whether
277
- * the target accepts them. */
278
- private _buildNamedArg;
279
- /** Mixin-call args are assembled by the SAME builder as function-call args
280
- * (`_assembleArgs` via `_betweenParens`) — identical comma/semicolon and value
281
- * handling. Named args are `VarDeclaration`s and variadic args `Rest`, which pass
282
- * through as single components. A bare `@name` is a `Reference` (the call shape);
283
- * the mixin-DEFINITION builder reinterprets a lone `@name` as a param. */
284
- private _buildMixinArgs;
285
- /** Less forbids mixing the COMMA and SEMICOLON argument separators: once a
286
- * semicolon separates args, a comma is a value-list separator, so a semicolon-group
287
- * may not hold 2+ named params (`@a: 1, @b: 2`). `_assembleArgs` renders such a group
288
- * as a List of ≥2 VarDeclarations. (This is purely about the `,` vs `;` argument
289
- * separators — a `/` inside a value is unrelated and never checked.) Applies to BOTH
290
- * mixin and function calls (args are unified). */
291
- private _checkMixedArgDelimiters;
292
- /**
293
- * Lower Less `;`-separated call args to the unified Jess representation: the outer
294
- * args `List{ sep: ';' }` becomes comma-separated, and each element that is itself
295
- * a comma-`List` (a `;`-group that held a comma-list) is wrapped in an escaped
296
- * `Paren` — the same shape Jess authors write as `~(1, 2)`. So
297
- * `.mixin(1, 2; 3, 4)` and Jess `mixin(~(1, 2), ~(3, 4))` converge on one AST.
298
- *
299
- * The escaped `Paren` evaluates to its inner value STRIPPED (paren.ts §escaped),
300
- * so `~(1, 2)` binds/renders identically to the bare list `1, 2` — representation
301
- * only, semantics unchanged. Scalar (non-List) elements pass through untouched.
302
- *
303
- * MUST run AFTER `_checkMixedArgDelimiters` (which inspects the `;`-List).
304
- */
305
- private _lowerSemiArgs;
306
- /**
307
- * Mixin-DEFINITION param conversion. With combinator-composed args a bare `@name`
308
- * value parses as a `Reference{variable}` (the CALL shape); in a DEFINITION it is a
309
- * param, so convert it to `VarDeclaration(name, Nil)`. Named params (`@a: 1`),
310
- * variadic (`Rest`) and pattern-match values stay as-is. Returns a NEW List (the
311
- * def/call split must not mutate a shared node).
312
- */
313
- private _convertArgsForDefinition;
314
- /**
315
- * Mixin-CALL argument conversion (reference `convertArgsForCall`, root.ts).
316
- * `_buildMixinArgs` builds bare `@name` args as definition-style VarDeclarations
317
- * (Nil value) — correct for a DEFINITION param, but in a CALL a bare `@name` is a
318
- * variable being PASSED, i.e. a `Reference{type:variable}`. Named args (`@a: 1`)
319
- * and value args stay as-is; a `Rest('name')` becomes `Rest(Reference{variable})`.
320
- * Returns a NEW List (the def/call split must not mutate a shared node).
321
- */
322
- private _convertArgsForCall;
323
- private _buildAnonMixin;
324
- /**
325
- * `each(<iterable>, { … })` → a `For` control node (the $for shape), not a Call.
326
- * The value(s) before the comma are the iterable; the callback block's body becomes
327
- * the loop rules. A literal block callback carries no captured params here, so the
328
- * pattern defaults to the Less `[value, key, index]` triple.
329
- */
330
- /** A bare detached ruleset `{ … }` in value / argument position → a Mixin holding
331
- * its rules (same shape `@var: { … }` produces in `_buildVarDeclaration`). */
332
- private _buildDetachedRuleset;
333
- private _buildEachFor;
334
- private _eachPattern;
335
- private _buildMixinOrQualified;
336
- private _extractExtendsFromSelectorText;
337
- private _selectorHasNestedExtend;
338
- private _treeHasExtend;
339
- /**
340
- * A guarded ruleset (`sel when …`) is parsed by the shared CSS builder, which
341
- * has no `when` concept, so the Guard CST child folds into the body as the
342
- * first rule — always a Paren/Condition/DefaultGuard. Lift it into the
343
- * ruleset's `guard` field (rebuilt through the canonical Ruleset ctor so the
344
- * guard is adopted) so it gates output instead of rendering as a `{ true }`
345
- * body. Non-guarded rulesets never begin their body with one of these node
346
- * types, so the leading-node check is unambiguous.
347
- */
348
- private _liftRulesetGuard;
349
- protected _buildRuleset(children: ReadonlyArray<Child>, rawChildren: ReadonlyArray<{
350
- _tag: string;
351
- }>, loc: LocationInfo): Ruleset;
352
- private _extractExtendsFromSelector;
353
- private static _isCssUrl;
354
- private _buildImportAtRuleFromPrelude;
355
- protected _buildAtRuleBlock(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode;
356
- /**
357
- * Shared AtRule assembly used by both the flat `AtRuleBlock` builder and the
358
- * structured, committed `QueryAtRuleBlock` builder. `preludeText` is the raw
359
- * prelude source (already `{`/`}` stripped); routing it through
360
- * `_buildAtRulePrelude` keeps the emitted AST identical regardless of which
361
- * grammar rule matched.
362
- */
363
- private _buildAtRuleFromParts;
364
- /**
365
- * Builder for the structured, committed `@media`/`@container`/`@supports`
366
- * query block. The grammar rule parses the prelude with real query structure
367
- * (so a stray/unbalanced bracket is rejected instead of swallowed) and commits
368
- * on `expect('{')`, but the AST is reconstructed from the prelude source text
369
- * via the shared `_buildAtRuleFromParts` path — so well-formed queries emit the
370
- * exact same AtRule the flat `AtRuleBlock` builder would.
371
- */
372
- private _buildLessQueryAtRuleBlock;
373
- private _buildAtRulePrelude;
374
- protected _buildAtRuleStatement(children: ReadonlyArray<Child>, loc: LocationInfo): JessNode;
375
- private _buildUseAtRuleFromPrelude;
376
- private _parenToArgs;
377
- private _tryParseNamespaceRef;
378
- private _assembleLessValue;
379
- }
380
- export {};
381
- //# sourceMappingURL=builders.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,SAAS,EACU,KAAK,OAAO,EAAE,KAAK,SAAS,EAChD,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,KAAK,IAAI,EACT,KAAK,YAAY,EACI,OAAO,EAeC,KAAK,QAAQ,EAK1C,MAAM,EAOP,MAAM,eAAe,CAAC;AAMvB,KAAK,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC/B,KAAK,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;AAwB3C,qBAAa,WAAY,SAAQ,SAAS;IACxC,qFAAqF;IACrF,QAAQ,EAAE,QAAQ,CAAqB;IAEvC,2DAA2D;IAC3D,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,mBAAmB;IAQ3B,UAAmB,SAAS,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,aAAa,CAAC,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC,EACtD,MAAM,EAAE,OAAO,EACf,YAAY,EAAE,aAAa,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EAC7C,MAAM,CAAC,EAAE,QAAQ,EACjB,SAAS,GAAE,SAAS,MAAM,EAAO,GAChC,QAAQ,CA0DV;IAID;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,oB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