@css-modules-kit/core 0.0.1
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/LICENSE +21 -0
- package/dist/checker.d.ts +7 -0
- package/dist/checker.d.ts.map +1 -0
- package/dist/checker.js +46 -0
- package/dist/checker.js.map +1 -0
- package/dist/config.d.ts +101 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +200 -0
- package/dist/config.js.map +1 -0
- package/dist/diagnostic.d.ts +34 -0
- package/dist/diagnostic.d.ts.map +1 -0
- package/dist/diagnostic.js +3 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/dts-creator.d.ts +56 -0
- package/dist/dts-creator.d.ts.map +1 -0
- package/dist/dts-creator.js +95 -0
- package/dist/dts-creator.js.map +1 -0
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +18 -0
- package/dist/error.js.map +1 -0
- package/dist/export-builder.d.ts +23 -0
- package/dist/export-builder.d.ts.map +1 -0
- package/dist/export-builder.js +34 -0
- package/dist/export-builder.js.map +1 -0
- package/dist/external-file.d.ts +2 -0
- package/dist/external-file.d.ts.map +1 -0
- package/dist/external-file.js +3 -0
- package/dist/external-file.js.map +1 -0
- package/dist/file.d.ts +28 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/file.js +73 -0
- package/dist/file.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/language-plugin.d.ts +23 -0
- package/dist/language-plugin.d.ts.map +1 -0
- package/dist/language-plugin.js +73 -0
- package/dist/language-plugin.js.map +1 -0
- package/dist/parser/at-import-parser.d.ts +14 -0
- package/dist/parser/at-import-parser.d.ts.map +1 -0
- package/dist/parser/at-import-parser.js +47 -0
- package/dist/parser/at-import-parser.js.map +1 -0
- package/dist/parser/at-value-parser.d.ts +44 -0
- package/dist/parser/at-value-parser.d.ts.map +1 -0
- package/dist/parser/at-value-parser.js +147 -0
- package/dist/parser/at-value-parser.js.map +1 -0
- package/dist/parser/css-module-parser.d.ts +93 -0
- package/dist/parser/css-module-parser.d.ts.map +1 -0
- package/dist/parser/css-module-parser.js +96 -0
- package/dist/parser/css-module-parser.js.map +1 -0
- package/dist/parser/diagnostic.d.ts +34 -0
- package/dist/parser/diagnostic.d.ts.map +1 -0
- package/dist/parser/diagnostic.js +3 -0
- package/dist/parser/diagnostic.js.map +1 -0
- package/dist/parser/location.d.ts +34 -0
- package/dist/parser/location.d.ts.map +1 -0
- package/dist/parser/location.js +9 -0
- package/dist/parser/location.js.map +1 -0
- package/dist/parser/rule-parser.d.ts +19 -0
- package/dist/parser/rule-parser.d.ts.map +1 -0
- package/dist/parser/rule-parser.js +122 -0
- package/dist/parser/rule-parser.js.map +1 -0
- package/dist/path.d.ts +11 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/path.js +43 -0
- package/dist/path.js.map +1 -0
- package/dist/resolver.d.ts +13 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +50 -0
- package/dist/resolver.js.map +1 -0
- package/dist/semantic-builder.d.ts +23 -0
- package/dist/semantic-builder.d.ts.map +1 -0
- package/dist/semantic-builder.js +33 -0
- package/dist/semantic-builder.js.map +1 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +7 -0
- package/dist/util.js.map +1 -0
- package/package.json +54 -0
- package/src/checker.ts +66 -0
- package/src/config.ts +285 -0
- package/src/diagnostic.ts +37 -0
- package/src/dts-creator.ts +128 -0
- package/src/error.ts +13 -0
- package/src/export-builder.ts +51 -0
- package/src/file.ts +83 -0
- package/src/index.ts +38 -0
- package/src/parser/at-import-parser.ts +47 -0
- package/src/parser/at-value-parser.ts +177 -0
- package/src/parser/css-module-parser.ts +193 -0
- package/src/parser/location.ts +43 -0
- package/src/parser/rule-parser.ts +140 -0
- package/src/path.ts +40 -0
- package/src/resolver.ts +57 -0
- package/src/typing/typescript.d.ts +19 -0
- package/src/util.ts +3 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAtValue = parseAtValue;
|
|
4
|
+
const VALUE_IMPORT_PATTERN = /^(.+?)\s+from\s+("[^"]*"|'[^']*')$/du;
|
|
5
|
+
const VALUE_DEFINITION_PATTERN = /(?:\s+|^)([\w-]+):?(.*?)$/du;
|
|
6
|
+
const IMPORTED_ITEM_PATTERN = /^([\w-]+)(?:\s+as\s+([\w-]+))?/du;
|
|
7
|
+
/**
|
|
8
|
+
* Parse the `@value` rule.
|
|
9
|
+
* Forked from https://github.com/css-modules/postcss-modules-values/blob/v4.0.0/src/index.js.
|
|
10
|
+
*
|
|
11
|
+
* @license
|
|
12
|
+
* ISC License (ISC)
|
|
13
|
+
* Copyright (c) 2015, Glen Maddern
|
|
14
|
+
*
|
|
15
|
+
* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
|
|
16
|
+
* provided that the above copyright notice and this permission notice appear in all copies.
|
|
17
|
+
*
|
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING
|
|
19
|
+
* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
20
|
+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
21
|
+
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
|
|
22
|
+
* THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
// MEMO: css-modules-kit does not support `@value` with parentheses (e.g., `@value (a, b) from '...';`) to simplify the implementation.
|
|
25
|
+
// MEMO: css-modules-kit does not support `@value` with variable module name (e.g., `@value a from moduleName;`) to simplify the implementation.
|
|
26
|
+
function parseAtValue(atValue) {
|
|
27
|
+
const matchesForValueImport = atValue.params.match(VALUE_IMPORT_PATTERN);
|
|
28
|
+
const diagnostics = [];
|
|
29
|
+
if (matchesForValueImport) {
|
|
30
|
+
const [, importedItems, from] = matchesForValueImport;
|
|
31
|
+
// The length of the `@value ` part in `@value import1 from '...'`
|
|
32
|
+
const baseLength = 6 + (atValue.raws.afterName?.length ?? 0);
|
|
33
|
+
let lastItemIndex = 0;
|
|
34
|
+
const values = [];
|
|
35
|
+
for (const alias of importedItems.split(/\s*,\s*/u)) {
|
|
36
|
+
const currentItemIndex = importedItems.indexOf(alias, lastItemIndex);
|
|
37
|
+
lastItemIndex = currentItemIndex;
|
|
38
|
+
const matchesForImportedItem = alias.match(IMPORTED_ITEM_PATTERN);
|
|
39
|
+
if (matchesForImportedItem) {
|
|
40
|
+
const [, name, localName] = matchesForImportedItem;
|
|
41
|
+
const nameIndex = matchesForImportedItem.indices[1][0];
|
|
42
|
+
const start = {
|
|
43
|
+
line: atValue.source.start.line,
|
|
44
|
+
column: atValue.source.start.column + baseLength + currentItemIndex + nameIndex,
|
|
45
|
+
offset: atValue.source.start.offset + baseLength + currentItemIndex + nameIndex,
|
|
46
|
+
};
|
|
47
|
+
const end = {
|
|
48
|
+
line: start.line,
|
|
49
|
+
column: start.column + name.length,
|
|
50
|
+
offset: start.offset + name.length,
|
|
51
|
+
};
|
|
52
|
+
const result = { name, loc: { start, end } };
|
|
53
|
+
if (localName === undefined) {
|
|
54
|
+
values.push(result);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const localNameIndex = matchesForImportedItem.indices[2][0];
|
|
58
|
+
const start = {
|
|
59
|
+
line: atValue.source.start.line,
|
|
60
|
+
column: atValue.source.start.column + baseLength + currentItemIndex + localNameIndex,
|
|
61
|
+
offset: atValue.source.start.offset + baseLength + currentItemIndex + localNameIndex,
|
|
62
|
+
};
|
|
63
|
+
const end = {
|
|
64
|
+
line: start.line,
|
|
65
|
+
column: start.column + localName.length,
|
|
66
|
+
offset: start.offset + localName.length,
|
|
67
|
+
};
|
|
68
|
+
values.push({ ...result, localName, localLoc: { start, end } });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const start = {
|
|
73
|
+
line: atValue.source.start.line,
|
|
74
|
+
column: atValue.source.start.column + baseLength + currentItemIndex,
|
|
75
|
+
};
|
|
76
|
+
const end = {
|
|
77
|
+
line: start.line,
|
|
78
|
+
column: start.column + alias.length,
|
|
79
|
+
};
|
|
80
|
+
diagnostics.push({
|
|
81
|
+
type: 'syntactic',
|
|
82
|
+
fileName: atValue.source.input.file,
|
|
83
|
+
start,
|
|
84
|
+
end,
|
|
85
|
+
text: `\`${alias}\` is invalid syntax.`,
|
|
86
|
+
category: 'error',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// `from` is surrounded by quotes (e.g., `"./test.module.css"`). So, remove the quotes.
|
|
91
|
+
const normalizedFrom = from.slice(1, -1);
|
|
92
|
+
const fromIndex = matchesForValueImport.indices[2][0] + 1;
|
|
93
|
+
const start = {
|
|
94
|
+
line: atValue.source.start.line,
|
|
95
|
+
column: atValue.source.start.column + baseLength + fromIndex,
|
|
96
|
+
offset: atValue.source.start.offset + baseLength + fromIndex,
|
|
97
|
+
};
|
|
98
|
+
const end = {
|
|
99
|
+
line: start.line,
|
|
100
|
+
column: start.column + normalizedFrom.length,
|
|
101
|
+
offset: start.offset + normalizedFrom.length,
|
|
102
|
+
};
|
|
103
|
+
const parsedAtValue = {
|
|
104
|
+
type: 'valueImportDeclaration',
|
|
105
|
+
values,
|
|
106
|
+
from: normalizedFrom,
|
|
107
|
+
fromLoc: { start, end },
|
|
108
|
+
};
|
|
109
|
+
return { atValue: parsedAtValue, diagnostics };
|
|
110
|
+
}
|
|
111
|
+
const matchesForValueDefinition = `${atValue.params}${atValue.raws.between}`.match(VALUE_DEFINITION_PATTERN);
|
|
112
|
+
if (matchesForValueDefinition) {
|
|
113
|
+
const [, name, _value] = matchesForValueDefinition;
|
|
114
|
+
if (name === undefined)
|
|
115
|
+
throw new Error(`unreachable`);
|
|
116
|
+
/** The index of the `<name>` in `@value <name>: <value>;`. */
|
|
117
|
+
const nameIndex = 6 + (atValue.raws.afterName?.length ?? 0) + matchesForValueDefinition.indices[1][0];
|
|
118
|
+
const start = {
|
|
119
|
+
line: atValue.source.start.line,
|
|
120
|
+
column: atValue.source.start.column + nameIndex,
|
|
121
|
+
offset: atValue.source.start.offset + nameIndex,
|
|
122
|
+
};
|
|
123
|
+
const end = {
|
|
124
|
+
line: start.line,
|
|
125
|
+
column: start.column + name.length,
|
|
126
|
+
offset: start.offset + name.length,
|
|
127
|
+
};
|
|
128
|
+
const parsedAtValue = { type: 'valueDeclaration', name, loc: { start, end } };
|
|
129
|
+
return { atValue: parsedAtValue, diagnostics };
|
|
130
|
+
}
|
|
131
|
+
diagnostics.push({
|
|
132
|
+
type: 'syntactic',
|
|
133
|
+
fileName: atValue.source.input.file,
|
|
134
|
+
start: {
|
|
135
|
+
line: atValue.source.start.line,
|
|
136
|
+
column: atValue.source.start.column,
|
|
137
|
+
},
|
|
138
|
+
end: {
|
|
139
|
+
line: atValue.source.end.line,
|
|
140
|
+
column: atValue.source.end.column + 1,
|
|
141
|
+
},
|
|
142
|
+
text: `\`${atValue.toString()}\` is a invalid syntax.`,
|
|
143
|
+
category: 'error',
|
|
144
|
+
});
|
|
145
|
+
return { diagnostics };
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=at-value-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"at-value-parser.js","sourceRoot":"","sources":["../../src/parser/at-value-parser.ts"],"names":[],"mappings":";;AAqDA,oCA2HC;AAlJD,MAAM,oBAAoB,GAAG,s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AAa,GAAG,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAW,CAAC;QACvF,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC;IACjD,CAAC;IACD,WAAW,CAAC,IAAI,CAAC;QACf,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,OAAO,CAAC,MAAO,CAAC,KAAK,CAAC,IAAK;QACrC,KAAK,EAAE;YACL,IAAI,EAAE,OAAO,CAAC,MAAO,CAAC,KAAM,CAAC,IAAI;YACjC,MAAM,EAAE,OAAO,CAAC,MAAO,CAAC,KAAM,CAAC,MAAM;SACtC;QACD,GAAG,EAAE;YACH,IAAI,EAAE,OAAO,CAAC,MAAO,CAAC,GAAI,CAAC,IAAI;YAC/B,MAAM,EAAE,OAAO,CAAC,MAAO,CAAC,GAAI,CAAC,MAAM,GAAG,CAAC;SACxC;QACD,IAAI,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,yBAAyB;QACtD,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IACH,OAAO,EAAE,WAAW,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { SyntacticDiagnostic } from '../diagnostic.js';
|
|
2
|
+
import { type Location } from './location.js';
|
|
3
|
+
/** The item being exported from a CSS module file (a.k.a. token). */
|
|
4
|
+
export interface Token {
|
|
5
|
+
/** The token name. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The location of the token in the source file. */
|
|
8
|
+
loc: Location;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A token importer using `@import '...'`.
|
|
12
|
+
* `@import` imports all tokens from the file. Therefore, it does not have
|
|
13
|
+
* the name of the imported token unlike {@link AtValueTokenImporter}.
|
|
14
|
+
*/
|
|
15
|
+
export interface AtImportTokenImporter {
|
|
16
|
+
type: 'import';
|
|
17
|
+
/**
|
|
18
|
+
* The specifier of the file from which the token is imported.
|
|
19
|
+
* This is a string before being resolved and unquoted.
|
|
20
|
+
* @example `@import './a.module.css'` would have `from` as `'./a.module.css'`.
|
|
21
|
+
*/
|
|
22
|
+
from: string;
|
|
23
|
+
/** The location of the `from` in *.module.css file. */
|
|
24
|
+
fromLoc: Location;
|
|
25
|
+
}
|
|
26
|
+
/** A token importer using `@value ... from '...'`. */
|
|
27
|
+
export interface AtValueTokenImporter {
|
|
28
|
+
type: 'value';
|
|
29
|
+
/** The values imported from the file. */
|
|
30
|
+
values: AtValueTokenImporterValue[];
|
|
31
|
+
/**
|
|
32
|
+
* The specifier of the file from which the token is imported.
|
|
33
|
+
* This is a string before being resolved and unquoted.
|
|
34
|
+
* @example `@value a from './a.module.css'` would have `from` as `'./a.module.css'`.
|
|
35
|
+
*/
|
|
36
|
+
from: string;
|
|
37
|
+
/** The location of the `from` in *.module.css file. */
|
|
38
|
+
fromLoc: Location;
|
|
39
|
+
}
|
|
40
|
+
/** A value imported from a CSS module file using `@value ... from '...'`. */
|
|
41
|
+
export interface AtValueTokenImporterValue {
|
|
42
|
+
/**
|
|
43
|
+
* The name of the token in the file from which it is imported.
|
|
44
|
+
* @example `@value a from './a.module.css'` would have `name` as `'a'`.
|
|
45
|
+
* @example `@value a as b from './a.module.css'` would have `name` as `'a'`.
|
|
46
|
+
*/
|
|
47
|
+
name: string;
|
|
48
|
+
/** The location of the `name` in *.module.css file. */
|
|
49
|
+
loc: Location;
|
|
50
|
+
/**
|
|
51
|
+
* The name of the token in the current file.
|
|
52
|
+
* @example `@value a from './a.module.css'` would not have `localName`.
|
|
53
|
+
* @example `@value a as b from './a.module.css'` would have `localName` as `'b'`.
|
|
54
|
+
*/
|
|
55
|
+
localName?: string;
|
|
56
|
+
/**
|
|
57
|
+
* The location of the `localName` in *.module.css file.
|
|
58
|
+
* This is `undefined` when `localName` is `undefined`.
|
|
59
|
+
*/
|
|
60
|
+
localLoc?: Location;
|
|
61
|
+
}
|
|
62
|
+
export type TokenImporter = AtImportTokenImporter | AtValueTokenImporter;
|
|
63
|
+
export interface CSSModule {
|
|
64
|
+
/** Absolute path of the file */
|
|
65
|
+
fileName: string;
|
|
66
|
+
/**
|
|
67
|
+
* List of token names defined in the file.
|
|
68
|
+
* @example
|
|
69
|
+
* Consider the following file:
|
|
70
|
+
* ```css
|
|
71
|
+
* .foo { color: red }
|
|
72
|
+
* .bar, .baz { color: red }
|
|
73
|
+
* ```
|
|
74
|
+
* The `localTokens` for this file would be `['foo', 'bar', 'baz']`.
|
|
75
|
+
*/
|
|
76
|
+
localTokens: Token[];
|
|
77
|
+
/**
|
|
78
|
+
* List of token importers in the file.
|
|
79
|
+
* Token importer is a statement that imports tokens from another file.
|
|
80
|
+
*/
|
|
81
|
+
tokenImporters: TokenImporter[];
|
|
82
|
+
}
|
|
83
|
+
export interface ParseCSSModuleOptions {
|
|
84
|
+
fileName: string;
|
|
85
|
+
dashedIdents: boolean;
|
|
86
|
+
safe: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface ParseCSSModuleResult {
|
|
89
|
+
cssModule: CSSModule;
|
|
90
|
+
diagnostics: SyntacticDiagnostic[];
|
|
91
|
+
}
|
|
92
|
+
export declare function parseCSSModule(text: string, { fileName, safe }: ParseCSSModuleOptions): ParseCSSModuleResult;
|
|
93
|
+
//# sourceMappingURL=css-module-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-module-parser.d.ts","sourceRoot":"","sources":["../../src/parser/css-module-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAG5D,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAuD9C,qEAAqE;AACrE,MAAM,WAAW,KAAK;IACpB,sBAAsB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,GAAG,EAAE,QAAQ,CAAC;CACf;AAED;;;;GAIG;AACH,MAA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+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseCSSModule = parseCSSModule;
|
|
7
|
+
const postcss_1 = require("postcss");
|
|
8
|
+
const postcss_safe_parser_1 = __importDefault(require("postcss-safe-parser"));
|
|
9
|
+
const at_import_parser_js_1 = require("./at-import-parser.js");
|
|
10
|
+
const at_value_parser_js_1 = require("./at-value-parser.js");
|
|
11
|
+
const rule_parser_js_1 = require("./rule-parser.js");
|
|
12
|
+
function isAtRuleNode(node) {
|
|
13
|
+
return node.type === 'atrule';
|
|
14
|
+
}
|
|
15
|
+
function isAtImportNode(node) {
|
|
16
|
+
return isAtRuleNode(node) && node.name === 'import';
|
|
17
|
+
}
|
|
18
|
+
function isAtValueNode(node) {
|
|
19
|
+
return isAtRuleNode(node) && node.name === 'value';
|
|
20
|
+
}
|
|
21
|
+
function isRuleNode(node) {
|
|
22
|
+
return node.type === 'rule';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Collect tokens from the AST.
|
|
26
|
+
*/
|
|
27
|
+
function collectTokens(ast) {
|
|
28
|
+
const allDiagnostics = [];
|
|
29
|
+
const localTokens = [];
|
|
30
|
+
const tokenImporters = [];
|
|
31
|
+
ast.walk((node) => {
|
|
32
|
+
if (isAtImportNode(node)) {
|
|
33
|
+
const parsed = (0, at_import_parser_js_1.parseAtImport)(node);
|
|
34
|
+
if (parsed !== undefined) {
|
|
35
|
+
tokenImporters.push({ type: 'import', ...parsed });
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else if (isAtValueNode(node)) {
|
|
39
|
+
const { atValue, diagnostics } = (0, at_value_parser_js_1.parseAtValue)(node);
|
|
40
|
+
allDiagnostics.push(...diagnostics);
|
|
41
|
+
if (atValue === undefined)
|
|
42
|
+
return;
|
|
43
|
+
if (atValue.type === 'valueDeclaration') {
|
|
44
|
+
localTokens.push({ name: atValue.name, loc: atValue.loc });
|
|
45
|
+
}
|
|
46
|
+
else if (atValue.type === 'valueImportDeclaration') {
|
|
47
|
+
tokenImporters.push({ ...atValue, type: 'value' });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (isRuleNode(node)) {
|
|
51
|
+
const { classSelectors, diagnostics } = (0, rule_parser_js_1.parseRule)(node);
|
|
52
|
+
allDiagnostics.push(...diagnostics);
|
|
53
|
+
for (const classSelector of classSelectors) {
|
|
54
|
+
localTokens.push(classSelector);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return { localTokens, tokenImporters, diagnostics: allDiagnostics };
|
|
59
|
+
}
|
|
60
|
+
function parseCSSModule(text, { fileName, safe }) {
|
|
61
|
+
let ast;
|
|
62
|
+
try {
|
|
63
|
+
const parser = safe ? postcss_safe_parser_1.default : postcss_1.parse;
|
|
64
|
+
ast = parser(text, { from: fileName });
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
if (e instanceof postcss_1.CssSyntaxError) {
|
|
68
|
+
const start = { line: e.line ?? 1, column: e.column ?? 1 };
|
|
69
|
+
return {
|
|
70
|
+
cssModule: { fileName, localTokens: [], tokenImporters: [] },
|
|
71
|
+
diagnostics: [
|
|
72
|
+
{
|
|
73
|
+
type: 'syntactic',
|
|
74
|
+
fileName,
|
|
75
|
+
start,
|
|
76
|
+
...(e.endLine !== undefined &&
|
|
77
|
+
e.endColumn !== undefined && {
|
|
78
|
+
end: { line: e.endLine, column: e.endColumn },
|
|
79
|
+
}),
|
|
80
|
+
text: e.reason,
|
|
81
|
+
category: 'error',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
throw e;
|
|
87
|
+
}
|
|
88
|
+
const { localTokens, tokenImporters, diagnostics } = collectTokens(ast);
|
|
89
|
+
const cssModule = {
|
|
90
|
+
fileName,
|
|
91
|
+
localTokens,
|
|
92
|
+
tokenImporters,
|
|
93
|
+
};
|
|
94
|
+
return { cssModule, diagnostics };
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=css-module-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css-module-parser.js","sourceRoot":"","sources":["../../src/parser/css-module-parser.ts"],"names":[],"mappings":";;;;;AA8JA,wCAkCC;AA/LD,qCAAgD;AAChD,8EAA6C;AAE7C,+DAAsD;AACtD,6DAAoD;AAEpD,qDAA6C;AAK7C,SAAS,YAAY,CAAC,IAAU;IAC9B,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED,SAAS,cAAc,CAAC,IAAU;IAChC,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC;AACtD,CAAC;AAED,SAAS,aAAa,CAAC,IAAU;IAC/B,OAAO,YAAY,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,IAAU;IAC5B,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,GAAS;IAC9B,MAAM,cAAc,GAA0B,EAAE,CAAC;IACjD,MAAM,WAAW,GAAY,EAAE,CAAC;IAChC,MAAM,cAAc,GAAoB,EAAE,CAAC;IAC3C,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,MAAM,GAAG,IAAA,mCAAa,EAAC,IAAI,CAAC,CAAC;YACnC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;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CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,wBAAc,EAAE,CAAC;YAChC,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC3D,OAAO;gBACL,SAAS,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE;gBAC5D,WAAW,EAAE;oBACX;wBACE,IAAI,EAAE,WAAW;wBACjB,QAAQ;wBACR,KAAK;wBACL,GAAG,CAAC,CAAC,CAAC,OAAO,KAAK,SAAS;4BACzB,CAAC,CAAC,SAAS,KAAK,SAAS,IAAI;4BAC3B,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE;yBAC9C,CAAC;wBACJ,IAAI,EAAE,CAAC,CAAC,MAAM;wBACd,QAAQ,EAAE,OAAO;qBAClB;iBACF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;IACD,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG;QAChB,QAAQ;QACR,WAAW;QACX,cAAc;KACf,CAAC;IACF,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type DiagnosticCategory = 'error';
|
|
2
|
+
export interface DiagnosticPosition {
|
|
3
|
+
/** The line number in the source file. It is 1-based. */
|
|
4
|
+
line: number;
|
|
5
|
+
/** The column number in the source file. It is 1-based. */
|
|
6
|
+
column: number;
|
|
7
|
+
}
|
|
8
|
+
export type Diagnostic = SemanticDiagnostic | SyntacticDiagnostic;
|
|
9
|
+
interface DiagnosticBase {
|
|
10
|
+
/** Text of diagnostic message. */
|
|
11
|
+
text: string;
|
|
12
|
+
/** The category of the diagnostic message. */
|
|
13
|
+
category: DiagnosticCategory;
|
|
14
|
+
}
|
|
15
|
+
export interface SemanticDiagnostic extends DiagnosticBase {
|
|
16
|
+
type: 'semantic';
|
|
17
|
+
/** The filename of the file in which the diagnostic occurred */
|
|
18
|
+
fileName?: string;
|
|
19
|
+
/** Starting file position at which text applies. It is inclusive. */
|
|
20
|
+
start?: DiagnosticPosition;
|
|
21
|
+
/** The last file position at which the text applies. It is exclusive. */
|
|
22
|
+
end?: DiagnosticPosition;
|
|
23
|
+
}
|
|
24
|
+
export interface SyntacticDiagnostic extends DiagnosticBase {
|
|
25
|
+
type: 'syntactic';
|
|
26
|
+
/** The filename of the file in which the diagnostic occurred */
|
|
27
|
+
fileName: string;
|
|
28
|
+
/** Starting file position at which text applies. It is inclusive. */
|
|
29
|
+
start: DiagnosticPosition;
|
|
30
|
+
/** The last file position at which the text applies. It is exclusive. */
|
|
31
|
+
end?: DiagnosticPosition;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=diagnostic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../src/parser/diagnostic.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEzC,MAAM,WAAW,kBAAkB;IACjC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAElE,UAAU,cAAc;IACtB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,QAAQ,EAAE,kBAAkB,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,IAAI,EAAE,UAAU,CAAC;IACjB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,0EAA0E;IAC1E,GAAG,CAAC,EAAE,kBAAkB,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,IAAI,EAAE,WAAW,CAAC;IAClB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,KAAK,EAAE,kBAAkB,CAAC;IAC1B,0EAA0E;IAC1E,GAAG,CAAC,EAAE,kBAAkB,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../../src/parser/diagnostic.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Rule } from 'postcss';
|
|
2
|
+
import type selectorParser from 'postcss-selector-parser';
|
|
3
|
+
import type { DiagnosticPosition } from '../diagnostic.js';
|
|
4
|
+
export interface Position {
|
|
5
|
+
/**
|
|
6
|
+
* The line number in the source file. It is 1-based.
|
|
7
|
+
* This is compatible with postcss and tsserver.
|
|
8
|
+
*/
|
|
9
|
+
line: number;
|
|
10
|
+
/**
|
|
11
|
+
* The column number in the source file. It is 1-based.
|
|
12
|
+
* This is compatible with postcss and tsserver.
|
|
13
|
+
*/
|
|
14
|
+
column: number;
|
|
15
|
+
/** The offset in the source file. It is 0-based. */
|
|
16
|
+
offset: number;
|
|
17
|
+
}
|
|
18
|
+
export interface Location {
|
|
19
|
+
/**
|
|
20
|
+
* The starting position of the node. It is inclusive.
|
|
21
|
+
* This is compatible with postcss and tsserver.
|
|
22
|
+
*/
|
|
23
|
+
start: Position;
|
|
24
|
+
/**
|
|
25
|
+
* The ending position of the node. It is exclusive.
|
|
26
|
+
* This is compatible with tsserver, but not postcss.
|
|
27
|
+
*/
|
|
28
|
+
end: Position;
|
|
29
|
+
}
|
|
30
|
+
export declare function calcDiagnosticsLocationForSelectorParserNode(rule: Rule, node: selectorParser.Node): {
|
|
31
|
+
start: DiagnosticPosition;
|
|
32
|
+
end: DiagnosticPosition;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=location.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../src/parser/location.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IAEH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IAEH,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,KAAK,EAAE,QAAQ,CAAC;IAChB;;;OAGG;IAEH,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,wBAAgB,4CAA4C,CAC1D,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,cAAc,CAAC,IAAI,GACxB;IAAE,KAAK,EAAE,kBAAkB,CAAC;IAAC,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAIxD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calcDiagnosticsLocationForSelectorParserNode = calcDiagnosticsLocationForSelectorParserNode;
|
|
4
|
+
function calcDiagnosticsLocationForSelectorParserNode(rule, node) {
|
|
5
|
+
const start = rule.positionBy({ index: node.sourceIndex });
|
|
6
|
+
const end = rule.positionBy({ index: node.sourceIndex + node.toString().length });
|
|
7
|
+
return { start, end };
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/parser/location.ts"],"names":[],"mappings":";;AAmCA,oGAOC;AAPD,SAAgB,4CAA4C,CAC1D,IAAU,EACV,IAAyB;IAEzB,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;IAClF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Rule } from 'postcss';
|
|
2
|
+
import type { SyntacticDiagnostic } from '../diagnostic.js';
|
|
3
|
+
import { type Location } from './location.js';
|
|
4
|
+
interface ClassSelector {
|
|
5
|
+
/** The class name. It does not include the leading dot. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The location of the class selector. */
|
|
8
|
+
loc: Location;
|
|
9
|
+
}
|
|
10
|
+
interface ParseRuleResult {
|
|
11
|
+
classSelectors: ClassSelector[];
|
|
12
|
+
diagnostics: SyntacticDiagnostic[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parse a rule and collect local class selectors.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseRule(rule: Rule): ParseRuleResult;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=rule-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-parser.d.ts","sourceRoot":"","sources":["../../src/parser/rule-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAgD,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAiG5F,UAAU,aAAa;IACrB,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,UAAU,eAAe;IACvB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAwBrD"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseRule = parseRule;
|
|
7
|
+
const postcss_selector_parser_1 = __importDefault(require("postcss-selector-parser"));
|
|
8
|
+
const location_js_1 = require("./location.js");
|
|
9
|
+
function flatCollectResults(results) {
|
|
10
|
+
const classNames = [];
|
|
11
|
+
const diagnostics = [];
|
|
12
|
+
for (const result of results) {
|
|
13
|
+
classNames.push(...result.classNames);
|
|
14
|
+
diagnostics.push(...result.diagnostics);
|
|
15
|
+
}
|
|
16
|
+
return { classNames, diagnostics };
|
|
17
|
+
}
|
|
18
|
+
const JS_IDENTIFIER_PATTERN = /^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;
|
|
19
|
+
function convertClassNameToCollectResult(rule, node) {
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- `raws` property is defined if `node` has escaped characters.
|
|
21
|
+
const name = node.raws?.value ?? node.value;
|
|
22
|
+
if (!JS_IDENTIFIER_PATTERN.test(name)) {
|
|
23
|
+
const diagnostic = {
|
|
24
|
+
type: 'syntactic',
|
|
25
|
+
fileName: rule.source.input.file,
|
|
26
|
+
...(0, location_js_1.calcDiagnosticsLocationForSelectorParserNode)(rule, node),
|
|
27
|
+
text: `\`${name}\` is not allowed because it is not a valid JavaScript identifier.`,
|
|
28
|
+
category: 'error',
|
|
29
|
+
};
|
|
30
|
+
return { classNames: [], diagnostics: [diagnostic] };
|
|
31
|
+
}
|
|
32
|
+
return { classNames: [node], diagnostics: [] };
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Collect local class names from the AST.
|
|
36
|
+
* This function is based on the behavior of postcss-modules-local-by-default.
|
|
37
|
+
*
|
|
38
|
+
* @see https://github.com/css-modules/postcss-modules-local-by-default/blob/38119276608ef14821797cfc0242b3c7dead69af/src/index.js
|
|
39
|
+
* @see https://github.com/css-modules/postcss-modules-local-by-default/blob/38119276608ef14821797cfc0242b3c7dead69af/test/index.test.js
|
|
40
|
+
* @example `.local1 :global(.global1) .local2 :local(.local3)` => `[".local1", ".local2", ".local3"]`
|
|
41
|
+
*/
|
|
42
|
+
function collectLocalClassNames(rule, root) {
|
|
43
|
+
return visitNode(root, undefined);
|
|
44
|
+
function visitNode(node, wrappedBy) {
|
|
45
|
+
if (postcss_selector_parser_1.default.isClassName(node)) {
|
|
46
|
+
switch (wrappedBy) {
|
|
47
|
+
// If the class name is wrapped by `:local(...)` or `:global(...)`,
|
|
48
|
+
// the scope is determined by the wrapper.
|
|
49
|
+
case ':local(...)':
|
|
50
|
+
return convertClassNameToCollectResult(rule, node);
|
|
51
|
+
case ':global(...)':
|
|
52
|
+
return { classNames: [], diagnostics: [] };
|
|
53
|
+
// If the class name is not wrapped by `:local(...)` or `:global(...)`,
|
|
54
|
+
// the scope is determined by the mode.
|
|
55
|
+
default:
|
|
56
|
+
// Mode is customizable in css-loader, but we don't support it for simplicity. We fix the mode to 'local'.
|
|
57
|
+
return convertClassNameToCollectResult(rule, node);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (postcss_selector_parser_1.default.isPseudo(node) && (node.value === ':local' || node.value === ':global')) {
|
|
61
|
+
if (node.nodes.length === 0) {
|
|
62
|
+
// `node` is `:local` or `:global` (without any arguments)
|
|
63
|
+
// We don't support `:local` and `:global` (without any arguments) because they are complex.
|
|
64
|
+
const diagnostic = {
|
|
65
|
+
type: 'syntactic',
|
|
66
|
+
fileName: rule.source.input.file,
|
|
67
|
+
...(0, location_js_1.calcDiagnosticsLocationForSelectorParserNode)(rule, node),
|
|
68
|
+
text: `\`${node.value}\` is not supported. Use \`${node.value}(...)\` instead.`,
|
|
69
|
+
category: 'error',
|
|
70
|
+
};
|
|
71
|
+
return { classNames: [], diagnostics: [diagnostic] };
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// `node` is `:local(...)` or `:global(...)` (with arguments)
|
|
75
|
+
if (wrappedBy !== undefined) {
|
|
76
|
+
const diagnostic = {
|
|
77
|
+
type: 'syntactic',
|
|
78
|
+
fileName: rule.source.input.file,
|
|
79
|
+
...(0, location_js_1.calcDiagnosticsLocationForSelectorParserNode)(rule, node),
|
|
80
|
+
text: `A \`${node.value}(...)\` is not allowed inside of \`${wrappedBy}\`.`,
|
|
81
|
+
category: 'error',
|
|
82
|
+
};
|
|
83
|
+
return { classNames: [], diagnostics: [diagnostic] };
|
|
84
|
+
}
|
|
85
|
+
return flatCollectResults(node.nodes.map((child) => visitNode(child, node.value === ':local' ? ':local(...)' : ':global(...)')));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else if (postcss_selector_parser_1.default.isContainer(node)) {
|
|
89
|
+
return flatCollectResults(node.nodes.map((child) => visitNode(child, wrappedBy)));
|
|
90
|
+
}
|
|
91
|
+
return { classNames: [], diagnostics: [] };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parse a rule and collect local class selectors.
|
|
96
|
+
*/
|
|
97
|
+
function parseRule(rule) {
|
|
98
|
+
const root = (0, postcss_selector_parser_1.default)().astSync(rule);
|
|
99
|
+
const result = collectLocalClassNames(rule, root);
|
|
100
|
+
const classSelectors = result.classNames.map((className) => {
|
|
101
|
+
// If `rule` is `.a, .b { color: red; }` and `className` is `.b`,
|
|
102
|
+
// `rule.source` is `{ start: { line: 1, column: 1 }, end: { line: 1, column: 22 } }`
|
|
103
|
+
// And `className.source` is `{ start: { line: 1, column: 5 }, end: { line: 1, column: 6 } }`.
|
|
104
|
+
const start = {
|
|
105
|
+
line: rule.source.start.line + className.source.start.line - 1,
|
|
106
|
+
column: rule.source.start.column + className.source.start.column,
|
|
107
|
+
offset: rule.source.start.offset + className.sourceIndex + 1,
|
|
108
|
+
};
|
|
109
|
+
const end = {
|
|
110
|
+
// The end line is always the same as the start line, as a class selector cannot break in the middle.
|
|
111
|
+
line: start.line,
|
|
112
|
+
column: start.column + className.value.length,
|
|
113
|
+
offset: start.offset + className.value.length,
|
|
114
|
+
};
|
|
115
|
+
return {
|
|
116
|
+
name: className.value,
|
|
117
|
+
loc: { start, end },
|
|
118
|
+
};
|
|
119
|
+
});
|
|
120
|
+
return { classSelectors, diagnostics: result.diagnostics };
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=rule-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule-parser.js","sourceRoot":"","sources":["../../src/parser/rule-parser.ts"],"names":[],"mappings":";;;;;AAmHA,8BAwBC;AA1ID,sFAAqD;AAErD,+CAA4F;AAO5F,SAAS,kBAAkB,CAAC,OAAwB;IAClD,MAAM,UAAU,GAA+B,EAAE,CAAC;IAClD,MAAM,WAAW,GAA0B,EAAE,CAAC;IAC9C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;IAC1C,CA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YACV,qGAAqG;YACrG,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM;YAC7C,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM;SAC9C,CAAC;QACF,OAAO;YACL,IAAI,EAAE,SAAS,CAAC,KAAK;YACrB,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE;SACpB,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AAC7D,CAAC"}
|
package/dist/path.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ParsedPath } from 'node:path';
|
|
2
|
+
export declare function slash(path: string): string;
|
|
3
|
+
export declare function join(...paths: string[]): string;
|
|
4
|
+
export declare function resolve(...paths: string[]): string;
|
|
5
|
+
export declare function relative(from: string, to: string): string;
|
|
6
|
+
export declare function dirname(path: string): string;
|
|
7
|
+
export declare function basename(path: string): string;
|
|
8
|
+
export declare function parse(path: string): ParsedPath;
|
|
9
|
+
export declare const matchesGlob: (path: string, pattern: string) => boolean;
|
|
10
|
+
export declare const isAbsolute: (path: string) => boolean;
|
|
11
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAK5C,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE/C;AAED,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAElD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAG9C;AAGD,eAAO,MAAM,WAAW,4CAAuB,CAAC;AAGhD,eAAO,MAAM,UAAU,2BAAsB,CAAC"}
|