@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/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
1
|
# Jess - Less parser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Translates a Less string to a Jess AST.
|
|
4
|
+
|
|
5
|
+
## Ideas
|
|
6
|
+
|
|
7
|
+
### Converting Less 1.x-5.x to Less 6
|
|
8
|
+
|
|
9
|
+
1. Auto-wrap parens around division to dis-ambiguate.
|
|
10
|
+
2. Convert `@import` to `@use` and `@include` syntax.
|
|
11
|
+
3. Throw errors on `@plugin` and ask to refactor with `@from`
|
|
12
|
+
4. Convert function references to `@from '#less' ([func])`
|
|
13
|
+
5. Add parentheses after mixin calls e.g. `.ns > .mixin;` to `.ns.mixin();`
|
|
14
|
+
6. Convert local imports from `@import 'local'` to `@include './local.less'`
|
|
15
|
+
7. Convert `@import (less) './file.css';` to `@include './file.css' as less;`
|
|
16
|
+
8. Convert `@import (inline) './file.css';` to `@include './file.css' as text;`
|
|
17
|
+
9. Convert `@import (reference) './file.less';` to `@use './file.less';`
|
|
18
|
+
10. Files that consume variables, mixins, or rules (like with extend) should have a `@use` added.
|
|
19
|
+
11. Don't allow `.class` as a value in a declaration. Convert to `\.class` e.g. `@foo: .class` should be converted to `@foo: \.class` (or `selector(.class)`?).
|
|
20
|
+
12. In a custom property value, convert `@variable` to `@{variable}`.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Converting Less 1.x-4.x to Jess
|
|
24
|
+
|
|
25
|
+
1. Auto-wrap expressions (like math) with `$()`
|
|
26
|
+
2. Convert mixin definitions `.my-mixin()` to `@mixin my-mixin()`
|
|
27
|
+
3. Convert mixin calls to function calls: `#ns > .mixin()` to `$ns.mixin()`
|
|
28
|
+
4. Throw errors on mixed case mixins: `.my-mixin()` and `.myMixin()`
|
|
29
|
+
5. Throw errors on mixed hash and class mixins: `#my-mixin()` and `.my-mixin()`
|
|
30
|
+
5. Convert variable declarations `@my-var` with `$my-var`
|
|
31
|
+
6. Convert interpolated vars `@{my-var}` to `$(my-var)`
|
|
32
|
+
7. Convert property references `$prop` to `$[prop]`
|
|
33
|
+
8. Convert color names in expressions to hex values (or wrapped in `color()`?) (because Jess doesn't support color keywords in expressions). Alternatively, should Jess allow `keyword` to denote keywords?
|
|
34
|
+
9. Convert `@rest...` to `...rest`
|
|
35
|
+
10. Convert `.rules()` to `@include .rules()` if `.rules` is a selector. What if it's a selector and mixin? Maybe something like `@include .rules, $rules();`? This might change the execution order from Less though.
|
|
36
|
+
11. Convert `@foo: extract(@bar, 1)` to `@let foo: $bar[0];`?
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const syncLog: (data: object) => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synchronous debug logging utility for tests.
|
|
3
|
+
* This file is in __tests__ so it won't be included in the public API.
|
|
4
|
+
*/
|
|
5
|
+
import { appendFileSync, existsSync, mkdirSync } from 'fs';
|
|
6
|
+
import { join, dirname } from 'path';
|
|
7
|
+
// Find monorepo root by looking for pnpm-workspace.yaml
|
|
8
|
+
function findMonorepoRoot(start) {
|
|
9
|
+
let dir = start;
|
|
10
|
+
while (dir !== '/') {
|
|
11
|
+
if (existsSync(join(dir, 'pnpm-workspace.yaml'))) {
|
|
12
|
+
return dir;
|
|
13
|
+
}
|
|
14
|
+
dir = dirname(dir);
|
|
15
|
+
}
|
|
16
|
+
return process.cwd();
|
|
17
|
+
}
|
|
18
|
+
const ROOT = findMonorepoRoot(__dirname);
|
|
19
|
+
const LOG_DIR = join(ROOT, '.cursor');
|
|
20
|
+
const LOG_PATH = process.env.DEBUG_LOG_PATH || join(LOG_DIR, 'debug.log');
|
|
21
|
+
// Ensure directory exists
|
|
22
|
+
try {
|
|
23
|
+
mkdirSync(LOG_DIR, { recursive: true });
|
|
24
|
+
}
|
|
25
|
+
catch { }
|
|
26
|
+
export const syncLog = (data) => {
|
|
27
|
+
try {
|
|
28
|
+
appendFileSync(LOG_PATH, JSON.stringify(data) + '\n');
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Ignore errors
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingUR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AC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,11 +1,33 @@
|
|
|
1
|
-
import { Lexer } from 'chevrotain';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export * from './
|
|
1
|
+
import { type CstNode, Lexer } from 'chevrotain';
|
|
2
|
+
import { LessActionsParser, type LessParserConfig } from './lessActionsParser.js';
|
|
3
|
+
import type { ConditionalPick } from 'type-fest';
|
|
4
|
+
import type { Rules, IParseResult } from '@jesscss/core';
|
|
5
|
+
export * from './lessActionsParser.js';
|
|
6
|
+
export * from './lessTokens.js';
|
|
7
|
+
export type LessRules = keyof ConditionalPick<LessActionsParser, () => CstNode>;
|
|
8
|
+
export type SyntacticContentAssistSuggestion = {
|
|
9
|
+
nextTokenType: string;
|
|
10
|
+
nextTokenLabel?: string;
|
|
11
|
+
ruleStack: string[];
|
|
12
|
+
occurrenceStack: number[];
|
|
13
|
+
};
|
|
6
14
|
export declare class Parser {
|
|
7
15
|
lexer: Lexer;
|
|
8
|
-
parser
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
/** @todo - return Jess AST as parser */
|
|
17
|
+
parser: LessActionsParser;
|
|
18
|
+
constructor(config?: LessParserConfig);
|
|
19
|
+
parse(text: string): IParseResult<Rules>;
|
|
20
|
+
parse(text: string, rule: 'stylesheet', ...args: Parameters<LessActionsParser['stylesheet']>): IParseResult<Rules>;
|
|
21
|
+
parse<T extends LessRules = LessRules>(text: string, rule?: T, ...args: Parameters<LessActionsParser[T]>): IParseResult;
|
|
22
|
+
/**
|
|
23
|
+
* IDE helper: suggest next possible token types at `offset` using Chevrotain's
|
|
24
|
+
* syntactic content assist. This is syntactic-only (not semantic completion).
|
|
25
|
+
*
|
|
26
|
+
* Note: content assist is significantly slower than normal parsing, so it
|
|
27
|
+
* should be called on-demand (e.g. near the cursor).
|
|
28
|
+
*/
|
|
29
|
+
suggest(text: string, init: {
|
|
30
|
+
offset: number;
|
|
31
|
+
rule?: LessRules;
|
|
32
|
+
}): SyntacticContentAssistSuggestion[];
|
|
11
33
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,38 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { Lexer } from 'chevrotain';
|
|
2
|
+
import { lessTokens, lessFragments } from './lessTokens.js';
|
|
3
|
+
import { createLexerDefinition } from '@jesscss/css-parser';
|
|
4
|
+
import { LessActionsParser } from './lessActionsParser.js';
|
|
5
|
+
import { LessErrorMessageProvider } from './lessErrorMessageProvider.js';
|
|
6
|
+
export * from './lessActionsParser.js';
|
|
7
|
+
export * from './lessTokens.js';
|
|
8
|
+
const errorMessageProvider = new LessErrorMessageProvider();
|
|
9
|
+
export class Parser {
|
|
10
|
+
lexer;
|
|
11
|
+
/** @todo - return Jess AST as parser */
|
|
12
|
+
parser;
|
|
13
|
+
constructor(config = {}) {
|
|
14
|
+
config = {
|
|
15
|
+
errorMessageProvider,
|
|
16
|
+
/**
|
|
17
|
+
* Override this if you want a stricter Less/CSS parser.
|
|
18
|
+
* @todo - Allow overriding when parsing a single rule.
|
|
19
|
+
*/
|
|
20
|
+
looseMode: true,
|
|
21
|
+
skipValidations: process.env.TEST !== 'true',
|
|
22
|
+
...config
|
|
23
|
+
};
|
|
24
|
+
const { lexer, T } = createLexerDefinition(lessFragments(), lessTokens());
|
|
25
|
+
this.lexer = new Lexer(lexer, {
|
|
24
26
|
ensureOptimizations: true,
|
|
25
|
-
skipValidations: process.env
|
|
27
|
+
skipValidations: process.env.TEST !== 'true'
|
|
26
28
|
});
|
|
27
|
-
this.parser = new
|
|
29
|
+
this.parser = new LessActionsParser(lexer, T, config);
|
|
30
|
+
/** Not sure why this is necessary, but Less tests were a problem */
|
|
31
|
+
this.parse = this.parse.bind(this);
|
|
28
32
|
}
|
|
29
|
-
parse(text) {
|
|
33
|
+
parse(text, rule = 'stylesheet', ...args) {
|
|
30
34
|
const parser = this.parser;
|
|
31
35
|
const lexerResult = this.lexer.tokenize(text);
|
|
32
36
|
const lexedTokens = lexerResult.tokens;
|
|
37
|
+
// Reset warnings BEFORE setting input, in case input setter does something that affects warnings
|
|
38
|
+
parser.warnings = [];
|
|
33
39
|
parser.input = lexedTokens;
|
|
34
|
-
const
|
|
35
|
-
|
|
40
|
+
const tree = parser[rule](...args);
|
|
41
|
+
// Capture warnings immediately after parsing to ensure they're not lost
|
|
42
|
+
const warnings = [...parser.warnings];
|
|
43
|
+
if (parser.errors.length > 0) {
|
|
44
|
+
const firstError = parser.errors[0];
|
|
45
|
+
const firstToken = firstError?.token;
|
|
46
|
+
}
|
|
47
|
+
return { tree, lexerResult, errors: parser.errors, warnings };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* IDE helper: suggest next possible token types at `offset` using Chevrotain's
|
|
51
|
+
* syntactic content assist. This is syntactic-only (not semantic completion).
|
|
52
|
+
*
|
|
53
|
+
* Note: content assist is significantly slower than normal parsing, so it
|
|
54
|
+
* should be called on-demand (e.g. near the cursor).
|
|
55
|
+
*/
|
|
56
|
+
suggest(text, init) {
|
|
57
|
+
const { offset, rule = 'stylesheet' } = init;
|
|
58
|
+
const prefix = text.slice(0, Math.max(0, offset));
|
|
59
|
+
const lexerResult = this.lexer.tokenize(prefix);
|
|
60
|
+
const tokens = lexerResult.tokens;
|
|
61
|
+
try {
|
|
62
|
+
const paths = this.parser.computeContentAssist(rule, tokens);
|
|
63
|
+
return paths.map(p => ({
|
|
64
|
+
nextTokenType: p.nextTokenType.name,
|
|
65
|
+
nextTokenLabel: p.nextTokenType.LABEL,
|
|
66
|
+
ruleStack: p.ruleStack,
|
|
67
|
+
occurrenceStack: p.occurrenceStack
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
36
73
|
}
|
|
37
74
|
}
|
|
38
|
-
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,EAAoC,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAwC,MAAM,wBAAwB,CAAC;AACjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIzE,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAEhC,MAAM,oBAAoB,GAAG,IAAI,wBAAwB,EAAE,CAAC;AAW5D,MAAM,OAAO,MAAM;IACjB,KAAK,CAAQ;IACb,wCAAwC;IACxC,MAAM,CAAoB;IAE1B,YACE,SAA2B,EAAE;QAE7B,MAAM,GAAG;YACP,oBAAoB;YACpB;;;eAGG;YACH,SAAS,EAAE,IAAI;YACf,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM;YAC5C,GAAG,MAAM;SACV,CAAC;QACF,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,qBAAqB,CAAC,aAAa,EAA0D,EAAE,UAAU,EAAE,CAAC,CAAC;QAElI,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE;YAC5B,mBAAmB,EAAE,IAAI;YACzB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM;SAC7C,CAAC,CAAC;QACH,IAAI,CAAC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,CAAC,CAAC;QAClD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,MAAM,GAAa,WAAW,CAAC,MAAM,CAAC;QAC5C,IAAI,CAAC;YACH,MAAM,KAAK,GAAI,IAAI,CAAC,MAAc,CAAC,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAkC,CAAC;YACvG,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACrB,aAAa,EAAE,CAAC,CAAC,aAAa,CAAC,IAAI;gBACnC,cAAc,EAAG,CAAC,CAAC,aAAqB,CAAC,KAAK;gBAC9C,SAAS,EAAE,CAAC,CAAC,SAAS;gBACtB,eAAe,EAAE,CAAC,CAAC,eAAe;aACnC,CAAC,CAAC,CAAC;QACN,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { TokenVocabulary, TokenType, IToken } from 'chevrotain';
|
|
2
|
+
import { type Rule, type RuleContext as CssRuleContext, type CssParserConfig, CssActionsParser, type CssTokenType, type TokenMap as CssTokenMap } from '@jesscss/css-parser';
|
|
3
|
+
import { Reference, type MathMode, type Node, type Extend, type ComplexSelector, type Selector } from '@jesscss/core';
|
|
4
|
+
import { type LessExtraTokenType } from './lessTokens.js';
|
|
5
|
+
export type LessParserConfig = CssParserConfig & {
|
|
6
|
+
/**
|
|
7
|
+
* Is less strict with certain CSS rules and Less syntax
|
|
8
|
+
* that the old Less parser allowed.
|
|
9
|
+
*
|
|
10
|
+
* @note This will also enable CSS legacyMode unless
|
|
11
|
+
* legacyMode is explicitly false.
|
|
12
|
+
*/
|
|
13
|
+
looseMode?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Controls whether mixins and detached rulesets "leak" their inner rules.
|
|
16
|
+
* When true (default):
|
|
17
|
+
* - Mixins: Mixin and VarDeclaration nodes are 'public' and 'optional' respectively
|
|
18
|
+
* - Detached rulesets: Mixin and VarDeclaration nodes are 'public' and 'private' respectively
|
|
19
|
+
* When false:
|
|
20
|
+
* - Both mixins and detached rulesets: Mixin and VarDeclaration nodes are 'private'
|
|
21
|
+
*/
|
|
22
|
+
leakyRules?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Less math evaluation mode. Used during parsing to decide whether a given
|
|
25
|
+
* `Operation` should be represented as an `Expression` for Less→Jess conversion.
|
|
26
|
+
*
|
|
27
|
+
* Mirrors runtime behavior in `Context.shouldOperate()`.
|
|
28
|
+
*
|
|
29
|
+
* @default 'parens-division'
|
|
30
|
+
*/
|
|
31
|
+
mathMode?: MathMode;
|
|
32
|
+
/**
|
|
33
|
+
* When enabled (default), the parser will wrap the *outermost* Less math/value
|
|
34
|
+
* expressions (math operations, variable references, and chained mixin/variable
|
|
35
|
+
* calls) in an `Expression({ parens: true })`.
|
|
36
|
+
*
|
|
37
|
+
* This is purely a parse-time AST shape choice to support Less→Jess conversion.
|
|
38
|
+
*
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
wrapOuterExpressions?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type CombinedTokenMap = Record<CssTokenType, TokenType> & Record<LessExtraTokenType, TokenType>;
|
|
44
|
+
export type TokenMap = CombinedTokenMap;
|
|
45
|
+
export interface ExtendTarget {
|
|
46
|
+
selector?: Selector;
|
|
47
|
+
target: Selector;
|
|
48
|
+
flag: IToken | undefined;
|
|
49
|
+
}
|
|
50
|
+
export type RuleContext = CssRuleContext & {
|
|
51
|
+
selector?: Selector;
|
|
52
|
+
hasDefault?: boolean;
|
|
53
|
+
/** Selectors in a selector sequence are extended */
|
|
54
|
+
allExtended?: boolean;
|
|
55
|
+
/** Mixin definition */
|
|
56
|
+
isDefinition?: boolean;
|
|
57
|
+
allowAnonymousMixins?: boolean;
|
|
58
|
+
requireAccessorsAfterMixinCall?: boolean;
|
|
59
|
+
inValueList?: boolean;
|
|
60
|
+
allowComma?: boolean;
|
|
61
|
+
/** Allow passing in the currently constructed Node */
|
|
62
|
+
node?: Node;
|
|
63
|
+
ruleIsFinished?: boolean;
|
|
64
|
+
sequences?: Array<ComplexSelector | Extend>;
|
|
65
|
+
asReference?: boolean;
|
|
66
|
+
/** For :extend(...) */
|
|
67
|
+
extendTargets?: ExtendTarget[];
|
|
68
|
+
extendNodes?: Extend[];
|
|
69
|
+
/** Inside an extend production - prevents 'all' from being consumed as selector */
|
|
70
|
+
inExtend?: boolean;
|
|
71
|
+
/** Inside a custom property value - used for deprecation warnings */
|
|
72
|
+
inCustomPropertyValue?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* When true, the current production should wrap the *outermost* parsed value
|
|
75
|
+
* (if it is a Less expression) in `Expression({ parens: true })`.
|
|
76
|
+
*
|
|
77
|
+
* This flag should only be set by value-entry productions (e.g. `valueSequence`)
|
|
78
|
+
* and must be cleared for nested parsing so Expressions never contain Expressions.
|
|
79
|
+
*/
|
|
80
|
+
wrapInExpression?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Parse-time equivalent of `Context.parenFrames`. This is a boolean stack
|
|
83
|
+
* (not a depth counter) because some productions (notably `Call`) intentionally
|
|
84
|
+
* push `false` to disable the ambient "in parens" math behavior.
|
|
85
|
+
*/
|
|
86
|
+
parenFrames?: boolean[];
|
|
87
|
+
/**
|
|
88
|
+
* Parse-time equivalent of `Context.calcFrames`.
|
|
89
|
+
*/
|
|
90
|
+
calcFrames?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Tracks where a detached ruleset literal is parsed from so we can
|
|
93
|
+
* disambiguate Collection vs anonymous mixin semantics.
|
|
94
|
+
*/
|
|
95
|
+
detachedRulesetUsage?: 'function-arg' | 'mixin-arg' | 'default-param';
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Unlike the historical Less parser, this parser
|
|
99
|
+
* avoids all backtracking
|
|
100
|
+
*/
|
|
101
|
+
export declare class LessActionsParser extends CssActionsParser {
|
|
102
|
+
T: CssTokenMap;
|
|
103
|
+
looseMode: boolean;
|
|
104
|
+
leakyRules: boolean;
|
|
105
|
+
/** Warnings collected during parsing */
|
|
106
|
+
warnings: Array<{
|
|
107
|
+
message: string;
|
|
108
|
+
token?: IToken;
|
|
109
|
+
deprecation?: string;
|
|
110
|
+
}>;
|
|
111
|
+
expressionSum: Rule;
|
|
112
|
+
expressionProduct: Rule;
|
|
113
|
+
expressionValue: Rule;
|
|
114
|
+
functionValueList: Rule;
|
|
115
|
+
ifFunction: Rule;
|
|
116
|
+
booleanFunction: Rule;
|
|
117
|
+
wrappedDeclarationList: Rule;
|
|
118
|
+
varDeclarationOrCall: Rule;
|
|
119
|
+
varName: Rule;
|
|
120
|
+
selectorCapture: Rule;
|
|
121
|
+
valueReference: Rule;
|
|
122
|
+
varReference: Rule;
|
|
123
|
+
mixinReference: Rule;
|
|
124
|
+
mixinName: Rule;
|
|
125
|
+
mixinOrQualifiedRule: Rule;
|
|
126
|
+
qualifiedRuleBody: Rule;
|
|
127
|
+
mixinArgs: Rule;
|
|
128
|
+
mixinArgList: Rule;
|
|
129
|
+
mixinArg: Rule;
|
|
130
|
+
anonymousMixinDefinition: Rule;
|
|
131
|
+
callArgument: Rule;
|
|
132
|
+
extend: Rule;
|
|
133
|
+
ampersandExtend: Rule;
|
|
134
|
+
lookupOrCall: Rule;
|
|
135
|
+
comparison: Rule;
|
|
136
|
+
guard: Rule;
|
|
137
|
+
guardDefault: Rule;
|
|
138
|
+
guardOr: Rule;
|
|
139
|
+
guardAnd: Rule;
|
|
140
|
+
guardInParens: Rule;
|
|
141
|
+
guardInner: Rule;
|
|
142
|
+
guardWithCondition: Rule;
|
|
143
|
+
guardWithConditionValue: Rule;
|
|
144
|
+
exportAtRule: Rule;
|
|
145
|
+
/** See `LessParserConfig.mathMode` */
|
|
146
|
+
mathMode: MathMode;
|
|
147
|
+
/** See `LessParserConfig.wrapOuterExpressions` */
|
|
148
|
+
wrapOuterExpressions: boolean;
|
|
149
|
+
constructor(tokenVocabulary: TokenVocabulary, T: any, config?: LessParserConfig);
|
|
150
|
+
protected processValueToken(token: IToken, ctx?: RuleContext): Reference | Node<unknown, import("core/lib/tree/node-base.js").NodeOptions>;
|
|
151
|
+
/**
|
|
152
|
+
* Emits a deprecation warning during parsing.
|
|
153
|
+
* Only collects warnings during the non-recording phase.
|
|
154
|
+
*/
|
|
155
|
+
protected warnDeprecation(message: string, token?: IToken, deprecationId?: string): void;
|
|
156
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { tokenMatcher } from 'chevrotain';
|
|
2
|
+
// import { LLStarLookaheadStrategy } from 'chevrotain-allstar'
|
|
3
|
+
import { CssActionsParser, productions as cssProductions } from '@jesscss/css-parser';
|
|
4
|
+
import { Reference, DefaultGuard, Interpolated, Any, Bool } from '@jesscss/core';
|
|
5
|
+
import { getInterpolatedOrString } from './utils.js';
|
|
6
|
+
import * as productions from './productions.js';
|
|
7
|
+
/**
|
|
8
|
+
* Unlike the historical Less parser, this parser
|
|
9
|
+
* avoids all backtracking
|
|
10
|
+
*/
|
|
11
|
+
export class LessActionsParser extends CssActionsParser {
|
|
12
|
+
looseMode;
|
|
13
|
+
leakyRules;
|
|
14
|
+
/** Warnings collected during parsing */
|
|
15
|
+
warnings = [];
|
|
16
|
+
expressionSum;
|
|
17
|
+
expressionProduct;
|
|
18
|
+
expressionValue;
|
|
19
|
+
functionValueList;
|
|
20
|
+
booleanFunction;
|
|
21
|
+
wrappedDeclarationList;
|
|
22
|
+
varDeclarationOrCall;
|
|
23
|
+
varName;
|
|
24
|
+
selectorCapture;
|
|
25
|
+
valueReference;
|
|
26
|
+
varReference;
|
|
27
|
+
// mixins
|
|
28
|
+
mixinReference;
|
|
29
|
+
mixinName;
|
|
30
|
+
mixinOrQualifiedRule;
|
|
31
|
+
qualifiedRuleBody;
|
|
32
|
+
// mixinDefinition!: Rule;
|
|
33
|
+
// mixinCall!: Rule;
|
|
34
|
+
// mixinCallStatement!: Rule;
|
|
35
|
+
mixinArgs;
|
|
36
|
+
mixinArgList;
|
|
37
|
+
mixinArg;
|
|
38
|
+
anonymousMixinDefinition;
|
|
39
|
+
callArgument;
|
|
40
|
+
extend;
|
|
41
|
+
ampersandExtend;
|
|
42
|
+
// namespaces
|
|
43
|
+
// accessors!: Rule;
|
|
44
|
+
lookupOrCall;
|
|
45
|
+
comparison;
|
|
46
|
+
guard;
|
|
47
|
+
guardDefault;
|
|
48
|
+
guardOr;
|
|
49
|
+
guardAnd;
|
|
50
|
+
guardInParens;
|
|
51
|
+
guardInner;
|
|
52
|
+
guardWithCondition;
|
|
53
|
+
guardWithConditionValue;
|
|
54
|
+
exportAtRule;
|
|
55
|
+
/** See `LessParserConfig.mathMode` */
|
|
56
|
+
mathMode;
|
|
57
|
+
/** See `LessParserConfig.wrapOuterExpressions` */
|
|
58
|
+
wrapOuterExpressions;
|
|
59
|
+
constructor(tokenVocabulary, T, config = {}) {
|
|
60
|
+
let { legacyMode, looseMode = true, leakyRules = true, mathMode = 'parens-division', wrapOuterExpressions = true, ...rest } = config;
|
|
61
|
+
legacyMode = legacyMode ?? looseMode;
|
|
62
|
+
super(tokenVocabulary, T, { legacyMode, ...rest });
|
|
63
|
+
this.looseMode = looseMode;
|
|
64
|
+
this.leakyRules = leakyRules;
|
|
65
|
+
this.mathMode = mathMode;
|
|
66
|
+
this.wrapOuterExpressions = wrapOuterExpressions;
|
|
67
|
+
this.warnings = [];
|
|
68
|
+
const $ = this;
|
|
69
|
+
/** Less extensions */
|
|
70
|
+
for (let [key, value] of Object.entries(productions)) {
|
|
71
|
+
// @ts-expect-error - this is fine
|
|
72
|
+
let rule = value.call(this, T);
|
|
73
|
+
if (key in cssProductions) {
|
|
74
|
+
this.OVERRIDE_RULE(key, rule);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.RULE(key, rule);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if ($.constructor === LessActionsParser) {
|
|
81
|
+
$.performSelfAnalysis();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
processValueToken(token, ctx) {
|
|
85
|
+
let tokenType = token.tokenType;
|
|
86
|
+
const TT = this.T;
|
|
87
|
+
const tokenName = tokenType.name;
|
|
88
|
+
// Check if this is an AtKeyword token (can be consumed via T.AtName category or T.Value category)
|
|
89
|
+
// Also check tokenMatcher in case the token type name check doesn't work
|
|
90
|
+
if (tokenType.name === 'AtKeyword' || tokenMatcher(token, this.T.AtKeyword)) {
|
|
91
|
+
if (!this.RECORDING_PHASE && ctx?.inCustomPropertyValue) {
|
|
92
|
+
const atName = token.image;
|
|
93
|
+
const ident = token.image.slice(1);
|
|
94
|
+
this.warnDeprecation(`"${atName}" in custom property values is treated as literal text, not a variable reference. Use "\@{${ident}}" if you want it to be evaluated.`, token, 'variable-in-unknown-value');
|
|
95
|
+
return new Any(token.image, { role: 'any' }, this.getLocationInfo(token), this.context);
|
|
96
|
+
}
|
|
97
|
+
return new Reference(token.image.slice(1), { type: 'variable' }, this.getLocationInfo(token), this.context);
|
|
98
|
+
}
|
|
99
|
+
else if (tokenType.name === 'PropertyReference') {
|
|
100
|
+
if (!this.RECORDING_PHASE) {
|
|
101
|
+
if (ctx?.inCustomPropertyValue) {
|
|
102
|
+
const atName = token.image;
|
|
103
|
+
const ident = token.image.slice(1);
|
|
104
|
+
this.warnDeprecation(`"${atName}" in custom property values is treated as literal text, not a property reference. Use "\${${ident}}" if you want it to be evaluated.`, token, 'property-in-unknown-value');
|
|
105
|
+
return new Any(token.image, { role: 'any' }, this.getLocationInfo(token), this.context);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return super.processValueToken(token, ctx);
|
|
109
|
+
}
|
|
110
|
+
else if (tokenType === TT['DefaultGuardFunc']) {
|
|
111
|
+
return new DefaultGuard(token.image, undefined, this.getLocationInfo(token), this.context);
|
|
112
|
+
}
|
|
113
|
+
else if (tokenType.name === 'JavaScript'
|
|
114
|
+
|| (TT['JavaScript'] && tokenMatcher(token, TT['JavaScript']))) {
|
|
115
|
+
throw new Error('Inline JavaScript using backticks is not supported. Use @use to import a JavaScript/TypeScript module instead. Script-module documentation is coming soon.');
|
|
116
|
+
}
|
|
117
|
+
else if (tokenType === TT['InterpolatedIdent']) {
|
|
118
|
+
const result = getInterpolatedOrString(token.image, this.getLocationInfo(token), this.context);
|
|
119
|
+
if (result instanceof Interpolated) {
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
return new Any(result, { role: 'ident' }, this.getLocationInfo(token), this.context);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else if (tokenType === TT['PlainIdent']) {
|
|
127
|
+
// Parse true/false as Bool nodes in Less
|
|
128
|
+
const image = token.image;
|
|
129
|
+
if (image === 'true' || image === 'false') {
|
|
130
|
+
return new Bool(image === 'true', undefined, this.getLocationInfo(token), this.context);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return super.processValueToken(token, ctx);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Emits a deprecation warning during parsing.
|
|
137
|
+
* Only collects warnings during the non-recording phase.
|
|
138
|
+
*/
|
|
139
|
+
warnDeprecation(message, token, deprecationId) {
|
|
140
|
+
if (!this.RECORDING_PHASE) {
|
|
141
|
+
this.warnings.push({ message, token, deprecation: deprecationId });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=lessActionsParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lessActionsParser.js","sourceRoot":"","sources":["../src/lessActionsParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,+DAA+D;AAC/D,OAAO,EAIL,gBAAgB,EAChB,WAAW,IAAI,cAAc,EAG9B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,YAAY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ACzC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAC1B,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,OAAO,EAAE,CAAC;gBAC1C,OAAO,IAAI,IAAI,CAAC,KAAK,KAAK,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED;;;OAGG;IACO,eAAe,CAAC,OAAe,EAAE,KAAc,EAAE,aAAsB;QAC/E,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lessErrorMessageProvider.js","sourceRoot":"","sources":["../src/lessErrorMessageProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,OAAO,wBAAyB,SAAQ,uBAAuB;CAAG"}
|
package/lib/lessTokens.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type RawModeConfig, type TokenNames } from '@jesscss/css-parser';
|
|
2
|
+
/**
|
|
3
|
+
* Less-specific token names introduced by merges below
|
|
4
|
+
*
|
|
5
|
+
* @todo - Can't we infer this from the tokens?
|
|
6
|
+
*/
|
|
7
|
+
export type LessExtraTokenType = 'Ellipsis' | 'AtKeywordLessExtension' | 'Interpolated' | 'LineComment' | 'PlusAssign' | 'UnderscoreAssign' | 'AnonMixinStart' | 'GtEqAlias' | 'LtEqAlias' | 'Extend' | 'AmpersandExtend' | 'AllFlag' | 'When' | 'WhenFunctionStart' | 'VarOrProp' | 'NestedReference' | 'PropertyReference' | 'Percent' | 'FormatFunction' | 'IfFunction' | 'BooleanFunction' | 'DefaultGuardIdent' | 'DefaultGuardFunc' | 'JavaScript' | 'InterpolatedIdent' | 'InterpolatedCustomProperty' | 'InterpolatedSelector';
|
|
8
|
+
declare function $preBuildTokens(): {
|
|
9
|
+
modes: any;
|
|
10
|
+
defaultMode: "Default";
|
|
11
|
+
};
|
|
12
|
+
export declare const Fragments: string[][];
|
|
13
|
+
export declare const Tokens: {
|
|
14
|
+
modes: any;
|
|
15
|
+
defaultMode: "Default";
|
|
16
|
+
};
|
|
17
|
+
type ReturnTokens = ReturnType<typeof $preBuildTokens>;
|
|
18
|
+
type TokenModes = ReturnTokens['modes'];
|
|
19
|
+
export type LessTokenType = TokenNames<TokenModes[keyof TokenModes]>;
|
|
20
|
+
export declare const lessFragments: () => ReadonlyArray<Readonly<[string, string]>>;
|
|
21
|
+
export declare const lessTokens: () => RawModeConfig;
|
|
22
|
+
export {};
|