@jesscss/less-parser 2.0.0-alpha.11 → 2.0.0-alpha.12
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 +55 -11
- package/lib/chunks/parse-with.cjs +172 -0
- package/lib/chunks/parse-with.js +161 -0
- package/lib/chunks/trivia-labels.cjs +18 -0
- package/lib/chunks/trivia-labels.js +13 -0
- package/lib/cst/positions.cjs +24 -0
- package/lib/cst/positions.d.ts +8 -0
- package/lib/cst/positions.d.ts.map +1 -0
- package/lib/cst/positions.js +21 -0
- package/lib/cst.cjs +11 -4
- package/lib/cst.d.ts +8 -2
- package/lib/cst.d.ts.map +1 -1
- package/lib/cst.js +10 -4
- package/lib/grammar/ast/positions.cjs +21592 -0
- package/lib/grammar/ast/positions.d.ts +3 -0
- package/lib/grammar/ast/positions.d.ts.map +1 -0
- package/lib/grammar/ast/positions.js +21591 -0
- package/lib/grammar/ast.cjs +98033 -0
- package/lib/grammar/ast.d.ts +11 -0
- package/lib/grammar/ast.d.ts.map +1 -0
- package/lib/grammar/ast.js +98032 -0
- package/lib/grammar/cst/positions.cjs +21592 -0
- package/lib/grammar/cst/positions.d.ts +3 -0
- package/lib/grammar/cst/positions.d.ts.map +1 -0
- package/lib/grammar/cst/positions.js +21591 -0
- package/lib/grammar/cst.cjs +21591 -0
- package/lib/grammar/cst.d.ts +3 -0
- package/lib/grammar/cst.d.ts.map +1 -0
- package/lib/grammar/cst.js +21590 -0
- package/lib/grammar.d.ts +6 -3
- package/lib/grammar.d.ts.map +1 -1
- package/lib/index.cjs +25 -63
- package/lib/index.d.ts +17 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +18 -57
- package/lib/parse-error.cjs +160 -0
- package/lib/parse-error.d.ts +26 -0
- package/lib/parse-error.d.ts.map +1 -1
- package/lib/parse-error.js +152 -0
- package/lib/parse-state.d.ts +39 -0
- package/lib/parse-state.d.ts.map +1 -0
- package/lib/parse-with.d.ts +25 -0
- package/lib/parse-with.d.ts.map +1 -0
- package/lib/positions.cjs +24 -0
- package/lib/positions.d.ts +20 -0
- package/lib/positions.d.ts.map +1 -0
- package/lib/positions.js +14 -0
- package/lib/trivia-labels.d.ts +11 -0
- package/lib/trivia-labels.d.ts.map +1 -0
- package/package.json +43 -13
- package/lib/grammar.cjs +0 -5
- package/lib/grammar.js +0 -2
- package/lib/grammar2.cjs +0 -141792
- package/lib/grammar2.js +0 -141733
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-state.d.ts","sourceRoot":"","sources":["../src/parse-state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;CAC7B;AAED,+EAA+E;AAC/E,eAAO,MAAM,sBAAsB,EAAE,QAA4B,CAAC;AAYlE;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAqBpE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ISafeParseResult, MathMode } from '@jesscss/core';
|
|
2
|
+
import { type Stylesheet } from '@jesscss/core/ast';
|
|
3
|
+
import type { lessGrammar } from './grammar/ast.js';
|
|
4
|
+
/** The rule map both compiled Less AST variants expose. */
|
|
5
|
+
export type LessAstGrammar = typeof lessGrammar;
|
|
6
|
+
/**
|
|
7
|
+
* What the caller must tell the Less grammar before it can lower correctly.
|
|
8
|
+
*
|
|
9
|
+
* `mathMode` is here — and not on the evaluator — because Less's `math:` policy
|
|
10
|
+
* decides, per operation, whether arithmetic happens with no enclosing math
|
|
11
|
+
* context. That is a decision the GRAMMAR makes and writes onto the node
|
|
12
|
+
* (`Operation.mathOutsideParens`); eval reads the node and never re-derives it
|
|
13
|
+
* from ambient config (§12.6b). AST v1 had this polarity and v2 lost it.
|
|
14
|
+
*/
|
|
15
|
+
export interface LessParseOptions {
|
|
16
|
+
readonly mathMode?: MathMode;
|
|
17
|
+
}
|
|
18
|
+
export declare function parseWith(grammar: LessAstGrammar, input: string, options?: LessParseOptions): Stylesheet;
|
|
19
|
+
/**
|
|
20
|
+
* The `safeParse` body for the product plugin path. Parser packages own
|
|
21
|
+
* recognition facts; this boundary attaches file/source context once and
|
|
22
|
+
* returns normalized diagnostics for compiler and CLI consumers to render.
|
|
23
|
+
*/
|
|
24
|
+
export declare function safeParseWith(grammar: LessAstGrammar, filePath: string, input: string, options?: LessParseOptions): ISafeParseResult;
|
|
25
|
+
//# sourceMappingURL=parse-with.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-with.d.ts","sourceRoot":"","sources":["../src/parse-with.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAa,MAAM,eAAe,CAAC;AAS3E,OAAO,EAaL,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,2DAA2D;AAC3D,MAAM,MAAM,cAAc,GAAG,OAAO,WAAW,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;CAC9B;AAyHD,wBAAgB,SAAS,CACvB,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,gBAAqB,GAC7B,UAAU,CAgEZ;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,gBAAqB,GAC7B,gBAAgB,CAWlB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_parse_with = require("./chunks/parse-with.cjs");
|
|
3
|
+
const require_parse_error = require("./parse-error.cjs");
|
|
4
|
+
let src_grammar_ast_positions_js = require("./grammar/ast/positions.cjs");
|
|
5
|
+
//#region src/positions.ts
|
|
6
|
+
/** Parse Less into the canonical AST v2 document with line/column facts. */
|
|
7
|
+
function parse(input, options = {}) {
|
|
8
|
+
return require_parse_with.parseWith(src_grammar_ast_positions_js.lessPositionsGrammar, input, options);
|
|
9
|
+
}
|
|
10
|
+
/** `safeParse` over the line-aware table: diagnostics carry parser line facts. */
|
|
11
|
+
function safeParse(filePath, input, options = {}) {
|
|
12
|
+
return require_parse_with.safeParseWith(src_grammar_ast_positions_js.lessPositionsGrammar, filePath, input, options);
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.LessBareVariableInterpolationError = require_parse_error.LessBareVariableInterpolationError;
|
|
16
|
+
exports.LessDynamicCharsetError = require_parse_error.LessDynamicCharsetError;
|
|
17
|
+
exports.LessImportPostludeError = require_parse_error.LessImportPostludeError;
|
|
18
|
+
exports.LessInlineJavaScriptError = require_parse_error.LessInlineJavaScriptError;
|
|
19
|
+
exports.LessParseError = require_parse_error.LessParseError;
|
|
20
|
+
exports.LessUnparenthesizedMixinGuardError = require_parse_error.LessUnparenthesizedMixinGuardError;
|
|
21
|
+
exports.LessUnsupportedMixinNameError = require_parse_error.LessUnsupportedMixinNameError;
|
|
22
|
+
exports.LessUnsupportedVariableNameError = require_parse_error.LessUnsupportedVariableNameError;
|
|
23
|
+
exports.parse = parse;
|
|
24
|
+
exports.safeParse = safeParse;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The line-aware Less AST entry.
|
|
3
|
+
*
|
|
4
|
+
* `parse`/`safeParse` here are the `.` entry's functions bound to the compiled
|
|
5
|
+
* table that tracks lines and columns, so every span carries
|
|
6
|
+
* `startLine`/`startColumn` and a `LessParseError` reports a real line. The
|
|
7
|
+
* choice is an import rather than an option because Node executes every
|
|
8
|
+
* statically imported module: a single `parse` that named both tables would
|
|
9
|
+
* cost every caller both, and the tables are multiple megabytes each.
|
|
10
|
+
*/
|
|
11
|
+
import type { ISafeParseResult } from '@jesscss/core';
|
|
12
|
+
import type { Stylesheet } from '@jesscss/core/ast';
|
|
13
|
+
import { type LessParseOptions } from './parse-with.js';
|
|
14
|
+
export type { LessParseOptions } from './parse-with.js';
|
|
15
|
+
export { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError } from './parse-error.js';
|
|
16
|
+
/** Parse Less into the canonical AST v2 document with line/column facts. */
|
|
17
|
+
export declare function parse(input: string, options?: LessParseOptions): Stylesheet;
|
|
18
|
+
/** `safeParse` over the line-aware table: diagnostics carry parser line facts. */
|
|
19
|
+
export declare function safeParse(filePath: string, input: string, options?: LessParseOptions): ISafeParseResult;
|
|
20
|
+
//# sourceMappingURL=positions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"positions.d.ts","sourceRoot":"","sources":["../src/positions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAA4B,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAElF,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EACL,kCAAkC,EAClC,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,cAAc,EACd,kCAAkC,EAClC,6BAA6B,EAC7B,gCAAgC,EACjC,MAAM,kBAAkB,CAAC;AAE1B,4EAA4E;AAC5E,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,UAAU,CAE/E;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CACvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,gBAAqB,GAC7B,gBAAgB,CAElB"}
|
package/lib/positions.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { n as safeParseWith, t as parseWith } from "./chunks/parse-with.js";
|
|
2
|
+
import { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError } from "./parse-error.js";
|
|
3
|
+
import { lessPositionsGrammar } from "./grammar/ast/positions.js";
|
|
4
|
+
//#region src/positions.ts
|
|
5
|
+
/** Parse Less into the canonical AST v2 document with line/column facts. */
|
|
6
|
+
function parse(input, options = {}) {
|
|
7
|
+
return parseWith(lessPositionsGrammar, input, options);
|
|
8
|
+
}
|
|
9
|
+
/** `safeParse` over the line-aware table: diagnostics carry parser line facts. */
|
|
10
|
+
function safeParse(filePath, input, options = {}) {
|
|
11
|
+
return safeParseWith(lessPositionsGrammar, filePath, input, options);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { LessBareVariableInterpolationError, LessDynamicCharsetError, LessImportPostludeError, LessInlineJavaScriptError, LessParseError, LessUnparenthesizedMixinGuardError, LessUnsupportedMixinNameError, LessUnsupportedVariableNameError, parse, safeParse };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root-trivia label selection for the Less grammar.
|
|
3
|
+
*
|
|
4
|
+
* This is a plain fact about the grammar's trivia arm labels, so it lives in a
|
|
5
|
+
* leaf module with no imports. Reading it from the CST entry instead would make
|
|
6
|
+
* every consumer of the package entry load the compiled CST grammar tables:
|
|
7
|
+
* Node's ESM loader does not tree-shake, so an unused named import still
|
|
8
|
+
* executes the module it is taken from, and each table is multiple megabytes.
|
|
9
|
+
*/
|
|
10
|
+
export declare const commentTriviaLabels: readonly ['lineComment', 'blockComment'];
|
|
11
|
+
//# sourceMappingURL=trivia-labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trivia-labels.d.ts","sourceRoot":"","sources":["../src/trivia-labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,mBAAmB,YAAI,aAAa,EAAE,cAAc,CAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "2.0.0-alpha.
|
|
7
|
+
"version": "2.0.0-alpha.12",
|
|
8
8
|
"engines": {
|
|
9
|
-
"node": "^20.19.0 || >=22.
|
|
9
|
+
"node": "^20.19.0 || >=22.18.0"
|
|
10
10
|
},
|
|
11
11
|
"description": "Jess LESS parser",
|
|
12
12
|
"main": "lib/index.cjs",
|
|
@@ -17,15 +17,45 @@
|
|
|
17
17
|
"import": "./lib/index.js",
|
|
18
18
|
"require": "./lib/index.cjs"
|
|
19
19
|
},
|
|
20
|
+
"./positions": {
|
|
21
|
+
"types": "./lib/positions.d.ts",
|
|
22
|
+
"import": "./lib/positions.js",
|
|
23
|
+
"require": "./lib/positions.cjs"
|
|
24
|
+
},
|
|
20
25
|
"./cst": {
|
|
21
26
|
"types": "./lib/cst.d.ts",
|
|
22
27
|
"import": "./lib/cst.js",
|
|
23
28
|
"require": "./lib/cst.cjs"
|
|
24
29
|
},
|
|
30
|
+
"./cst/positions": {
|
|
31
|
+
"types": "./lib/cst/positions.d.ts",
|
|
32
|
+
"import": "./lib/cst/positions.js",
|
|
33
|
+
"require": "./lib/cst/positions.cjs"
|
|
34
|
+
},
|
|
25
35
|
"./grammar": {
|
|
26
|
-
"types": "./lib/grammar.d.ts",
|
|
27
|
-
"import": "./lib/grammar.js",
|
|
28
|
-
"require": "./lib/grammar.cjs"
|
|
36
|
+
"types": "./lib/grammar/ast.d.ts",
|
|
37
|
+
"import": "./lib/grammar/ast.js",
|
|
38
|
+
"require": "./lib/grammar/ast.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./grammar/ast": {
|
|
41
|
+
"types": "./lib/grammar/ast.d.ts",
|
|
42
|
+
"import": "./lib/grammar/ast.js",
|
|
43
|
+
"require": "./lib/grammar/ast.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./grammar/ast/positions": {
|
|
46
|
+
"types": "./lib/grammar/ast/positions.d.ts",
|
|
47
|
+
"import": "./lib/grammar/ast/positions.js",
|
|
48
|
+
"require": "./lib/grammar/ast/positions.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./grammar/cst": {
|
|
51
|
+
"types": "./lib/grammar/cst.d.ts",
|
|
52
|
+
"import": "./lib/grammar/cst.js",
|
|
53
|
+
"require": "./lib/grammar/cst.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./grammar/cst/positions": {
|
|
56
|
+
"types": "./lib/grammar/cst/positions.d.ts",
|
|
57
|
+
"import": "./lib/grammar/cst/positions.js",
|
|
58
|
+
"require": "./lib/grammar/cst/positions.cjs"
|
|
29
59
|
},
|
|
30
60
|
"./package.json": "./package.json"
|
|
31
61
|
},
|
|
@@ -34,11 +64,11 @@
|
|
|
34
64
|
],
|
|
35
65
|
"dependencies": {
|
|
36
66
|
"known-css-properties": "~0.37.0",
|
|
37
|
-
"@jesscss/css-parser": "2.0.0-alpha.
|
|
67
|
+
"@jesscss/css-parser": "2.0.0-alpha.12"
|
|
38
68
|
},
|
|
39
69
|
"peerDependencies": {
|
|
40
|
-
"parseman": "^0.
|
|
41
|
-
"@jesscss/core": "2.0.0-alpha.
|
|
70
|
+
"parseman": "^0.50.1",
|
|
71
|
+
"@jesscss/core": "2.0.0-alpha.12"
|
|
42
72
|
},
|
|
43
73
|
"peerDependenciesMeta": {
|
|
44
74
|
"@jesscss/core": {
|
|
@@ -48,12 +78,12 @@
|
|
|
48
78
|
"devDependencies": {
|
|
49
79
|
"@types/node": "^18.19.31",
|
|
50
80
|
"less": "^4.6.3",
|
|
51
|
-
"parseman": "^0.
|
|
81
|
+
"parseman": "^0.50.1",
|
|
52
82
|
"postcss-less": "~6.0.0",
|
|
53
83
|
"tsx": "~4.21.0",
|
|
54
|
-
"@jesscss/core": "2.0.0-alpha.
|
|
55
|
-
"@jesscss/shared": "2.0.0-alpha.
|
|
56
|
-
"@jesscss/
|
|
84
|
+
"@jesscss/core": "2.0.0-alpha.12",
|
|
85
|
+
"@jesscss/parser-shared": "2.0.0-alpha.12",
|
|
86
|
+
"@jesscss/shared": "2.0.0-alpha.1"
|
|
57
87
|
},
|
|
58
88
|
"author": "Matthew Dean <matthew-dean@users.noreply.github.com>",
|
|
59
89
|
"license": "MIT",
|
|
@@ -65,7 +95,7 @@
|
|
|
65
95
|
"scripts": {
|
|
66
96
|
"ci": "pnpm build && pnpm test",
|
|
67
97
|
"build": "pnpm --filter @jesscss/parser-shared build && pnpm compile",
|
|
68
|
-
"compile": "tsdown --tsconfig tsconfig.build.json --no-dts && tsc -p tsconfig.build.json --emitDeclarationOnly
|
|
98
|
+
"compile": "node -e \"require('node:fs').rmSync('lib',{recursive:true,force:true})\" && tsdown --tsconfig tsconfig.build.json --no-dts && tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
69
99
|
"dev": "tsdown --tsconfig tsconfig.build.json --watch",
|
|
70
100
|
"test": "cross-env TEST=true vitest --watch=false",
|
|
71
101
|
"test:coverage": "cross-env TEST=true vitest --coverage",
|
package/lib/grammar.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_grammar = require("./grammar2.cjs");
|
|
3
|
-
exports.lessAstGrammar = require_grammar.lessAstGrammar;
|
|
4
|
-
exports.lessCstGrammar = require_grammar.lessCstGrammar;
|
|
5
|
-
exports.lessGrammar = require_grammar.lessGrammar;
|
package/lib/grammar.js
DELETED