@tbela99/css-parser 1.3.3 → 1.4.0
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/CHANGELOG.md +44 -0
- package/README.md +64 -48
- package/dist/config.json.js +3 -0
- package/dist/index-umd-web.js +2266 -631
- package/dist/index.cjs +2271 -620
- package/dist/index.d.ts +522 -181
- package/dist/lib/ast/expand.js +5 -10
- package/dist/lib/ast/features/calc.js +3 -2
- package/dist/lib/ast/features/inlinecssvariables.js +5 -3
- package/dist/lib/ast/features/prefix.js +1 -1
- package/dist/lib/ast/features/shorthand.js +1 -0
- package/dist/lib/ast/features/transform.js +13 -19
- package/dist/lib/ast/features/type.js +1 -1
- package/dist/lib/ast/minify.js +6 -3
- package/dist/lib/ast/transform/compute.js +2 -4
- package/dist/lib/ast/transform/matrix.js +20 -20
- package/dist/lib/ast/transform/minify.js +105 -12
- package/dist/lib/ast/transform/rotate.js +11 -11
- package/dist/lib/ast/transform/scale.js +6 -6
- package/dist/lib/ast/transform/skew.js +4 -4
- package/dist/lib/ast/transform/translate.js +3 -3
- package/dist/lib/ast/transform/utils.js +30 -37
- package/dist/lib/ast/types.js +76 -5
- package/dist/lib/ast/walk.js +77 -58
- package/dist/lib/fs/resolve.js +69 -10
- package/dist/lib/parser/declaration/list.js +6 -1
- package/dist/lib/parser/parse.js +1169 -312
- package/dist/lib/parser/tokenize.js +33 -20
- package/dist/lib/parser/utils/declaration.js +54 -0
- package/dist/lib/parser/utils/hash.js +86 -0
- package/dist/lib/parser/utils/text.js +8 -0
- package/dist/lib/renderer/render.js +26 -7
- package/dist/lib/syntax/color/relativecolor.js +0 -3
- package/dist/lib/syntax/syntax.js +36 -18
- package/dist/lib/validation/at-rules/container.js +11 -0
- package/dist/lib/validation/at-rules/counter-style.js +11 -0
- package/dist/lib/validation/at-rules/font-feature-values.js +11 -0
- package/dist/lib/validation/at-rules/keyframes.js +11 -0
- package/dist/lib/validation/at-rules/layer.js +11 -0
- package/dist/lib/validation/at-rules/media.js +11 -0
- package/dist/lib/validation/at-rules/page-margin-box.js +11 -0
- package/dist/lib/validation/at-rules/page.js +11 -0
- package/dist/lib/validation/at-rules/supports.js +11 -0
- package/dist/lib/validation/at-rules/when.js +11 -0
- package/dist/lib/validation/config.js +0 -2
- package/dist/lib/validation/config.json.js +36 -4
- package/dist/lib/validation/parser/parse.js +53 -2
- package/dist/lib/validation/syntax.js +204 -36
- package/dist/lib/validation/syntaxes/compound-selector.js +1 -2
- package/dist/lib/validation/syntaxes/relative-selector-list.js +2 -5
- package/dist/node.js +60 -18
- package/dist/types.d.ts +17 -0
- package/dist/types.js +20 -0
- package/dist/web.js +43 -17
- package/package.json +20 -17
- package/dist/lib/validation/parser/types.js +0 -54
package/dist/node.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
|
-
|
|
2
|
+
import { ModuleScopeEnumOptions } from './lib/ast/types.js';
|
|
3
|
+
export { ColorType, EnumToken, ModuleCaseTransformEnum, ValidationLevel } from './lib/ast/types.js';
|
|
3
4
|
export { minify } from './lib/ast/minify.js';
|
|
4
|
-
export {
|
|
5
|
+
export { WalkerEvent, WalkerOptionEnum, walk, walkValues } from './lib/ast/walk.js';
|
|
5
6
|
export { expand } from './lib/ast/expand.js';
|
|
6
7
|
import { doRender } from './lib/renderer/render.js';
|
|
7
8
|
export { renderToken } from './lib/renderer/render.js';
|
|
@@ -14,42 +15,58 @@ export { convertColor } from './lib/syntax/color/color.js';
|
|
|
14
15
|
import './lib/syntax/color/utils/constants.js';
|
|
15
16
|
export { isOkLabClose, okLabDistance } from './lib/syntax/color/utils/distance.js';
|
|
16
17
|
import './lib/validation/config.js';
|
|
17
|
-
import './lib/validation/parser/types.js';
|
|
18
18
|
import './lib/validation/parser/parse.js';
|
|
19
19
|
import './lib/validation/syntaxes/complex-selector.js';
|
|
20
20
|
import './lib/validation/syntax.js';
|
|
21
21
|
import { resolve, matchUrl, dirname } from './lib/fs/resolve.js';
|
|
22
22
|
import { Readable } from 'node:stream';
|
|
23
23
|
import { createReadStream } from 'node:fs';
|
|
24
|
-
import { lstat } from 'node:fs/promises';
|
|
24
|
+
import { readFile, lstat } from 'node:fs/promises';
|
|
25
|
+
import { ResponseType } from './types.js';
|
|
25
26
|
export { FeatureWalkMode } from './lib/ast/features/type.js';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* load file or url as stream
|
|
29
30
|
* @param url
|
|
30
31
|
* @param currentFile
|
|
32
|
+
* @param responseType
|
|
31
33
|
* @throws Error file not found
|
|
32
34
|
*
|
|
33
35
|
* @private
|
|
34
36
|
*/
|
|
35
|
-
async function load(url, currentFile = '.') {
|
|
37
|
+
async function load(url, currentFile = '.', responseType = false) {
|
|
36
38
|
const resolved = resolve(url, currentFile);
|
|
37
|
-
|
|
39
|
+
if (typeof responseType == 'boolean') {
|
|
40
|
+
responseType = responseType ? ResponseType.ReadableStream : ResponseType.Text;
|
|
41
|
+
}
|
|
38
42
|
if (matchUrl.test(resolved.absolute)) {
|
|
39
|
-
return fetch(resolved.absolute).then((response) => {
|
|
43
|
+
return fetch(resolved.absolute).then(async (response) => {
|
|
40
44
|
if (!response.ok) {
|
|
41
45
|
throw new Error(`${response.status} ${response.statusText} ${response.url}`);
|
|
42
46
|
}
|
|
43
|
-
|
|
47
|
+
if (responseType == ResponseType.ArrayBuffer) {
|
|
48
|
+
return response.arrayBuffer();
|
|
49
|
+
}
|
|
50
|
+
return responseType == ResponseType.ReadableStream ? response.body : await response.text();
|
|
44
51
|
});
|
|
45
52
|
}
|
|
46
53
|
try {
|
|
54
|
+
if (responseType == ResponseType.Text) {
|
|
55
|
+
return readFile(resolved.absolute, 'utf-8');
|
|
56
|
+
}
|
|
57
|
+
if (responseType == ResponseType.ArrayBuffer) {
|
|
58
|
+
return readFile(resolved.absolute).then(buffer => buffer.buffer);
|
|
59
|
+
}
|
|
47
60
|
const stats = await lstat(resolved.absolute);
|
|
48
61
|
if (stats.isFile()) {
|
|
49
|
-
return Readable.toWeb(createReadStream(resolved.absolute
|
|
62
|
+
return Readable.toWeb(createReadStream(resolved.absolute, {
|
|
63
|
+
encoding: 'utf-8',
|
|
64
|
+
highWaterMark: 64 * 1024
|
|
65
|
+
}));
|
|
50
66
|
}
|
|
51
67
|
}
|
|
52
68
|
catch (error) {
|
|
69
|
+
console.warn(error);
|
|
53
70
|
}
|
|
54
71
|
throw new Error(`File not found: '${resolved.absolute || url}'`);
|
|
55
72
|
}
|
|
@@ -57,6 +74,7 @@ async function load(url, currentFile = '.') {
|
|
|
57
74
|
* render the ast tree
|
|
58
75
|
* @param data
|
|
59
76
|
* @param options
|
|
77
|
+
* @param mapping
|
|
60
78
|
*
|
|
61
79
|
* Example:
|
|
62
80
|
*
|
|
@@ -81,13 +99,14 @@ async function load(url, currentFile = '.') {
|
|
|
81
99
|
* // }
|
|
82
100
|
* ```
|
|
83
101
|
*/
|
|
84
|
-
function render(data, options = {}) {
|
|
85
|
-
return doRender(data, Object.assign(options, { resolve, dirname, cwd: options.cwd ?? process.cwd() }));
|
|
102
|
+
function render(data, options = {}, mapping) {
|
|
103
|
+
return doRender(data, Object.assign(options, { resolve, dirname, cwd: options.cwd ?? process.cwd() }), mapping);
|
|
86
104
|
}
|
|
87
105
|
/**
|
|
88
106
|
* parse css file
|
|
89
107
|
* @param file url or path
|
|
90
108
|
* @param options
|
|
109
|
+
* @param asStream load file as stream
|
|
91
110
|
*
|
|
92
111
|
* @throws Error file not found
|
|
93
112
|
*
|
|
@@ -106,8 +125,8 @@ function render(data, options = {}) {
|
|
|
106
125
|
* console.log(result.ast);
|
|
107
126
|
* ```
|
|
108
127
|
*/
|
|
109
|
-
async function parseFile(file, options = {}) {
|
|
110
|
-
return load(file).then(stream => parse(stream, { src: file, ...options }));
|
|
128
|
+
async function parseFile(file, options = {}, asStream = false) {
|
|
129
|
+
return Promise.resolve((options.load ?? load)(file, '.', asStream)).then(stream => parse(stream, { src: file, ...options }));
|
|
111
130
|
}
|
|
112
131
|
/**
|
|
113
132
|
* parse css
|
|
@@ -156,14 +175,24 @@ async function parse(stream, options = {}) {
|
|
|
156
175
|
return doParse(stream instanceof ReadableStream ? tokenizeStream(stream) : tokenize({
|
|
157
176
|
stream,
|
|
158
177
|
buffer: '',
|
|
178
|
+
offset: 0,
|
|
159
179
|
position: { ind: 0, lin: 1, col: 1 },
|
|
160
180
|
currentPosition: { ind: -1, lin: 1, col: 0 }
|
|
161
|
-
}), Object.assign(options, {
|
|
181
|
+
}), Object.assign(options, {
|
|
182
|
+
load,
|
|
183
|
+
resolve,
|
|
184
|
+
dirname,
|
|
185
|
+
cwd: options.cwd ?? process.cwd()
|
|
186
|
+
})).then(result => {
|
|
187
|
+
const { revMapping, ...res } = result;
|
|
188
|
+
return res;
|
|
189
|
+
});
|
|
162
190
|
}
|
|
163
191
|
/**
|
|
164
192
|
* transform css file
|
|
165
193
|
* @param file url or path
|
|
166
194
|
* @param options
|
|
195
|
+
* @param asStream load file as stream
|
|
167
196
|
*
|
|
168
197
|
* @throws Error file not found
|
|
169
198
|
*
|
|
@@ -182,8 +211,8 @@ async function parse(stream, options = {}) {
|
|
|
182
211
|
* console.log(result.code);
|
|
183
212
|
* ```
|
|
184
213
|
*/
|
|
185
|
-
async function transformFile(file, options = {}) {
|
|
186
|
-
return load(file).then(stream => transform(stream, { src: file, ...options }));
|
|
214
|
+
async function transformFile(file, options = {}, asStream = false) {
|
|
215
|
+
return Promise.resolve((options.load ?? load)(file, '.', asStream)).then(stream => transform(stream, { src: file, ...options }));
|
|
187
216
|
}
|
|
188
217
|
/**
|
|
189
218
|
* transform css
|
|
@@ -232,8 +261,21 @@ async function transform(css, options = {}) {
|
|
|
232
261
|
options = { minify: true, removeEmpty: true, removeCharset: true, ...options };
|
|
233
262
|
const startTime = performance.now();
|
|
234
263
|
return parse(css, options).then((parseResult) => {
|
|
264
|
+
let mapping = null;
|
|
265
|
+
let importMapping = null;
|
|
266
|
+
if (typeof options.module == 'number' && (options.module & ModuleScopeEnumOptions.ICSS)) {
|
|
267
|
+
mapping = parseResult.mapping;
|
|
268
|
+
importMapping = parseResult.importMapping;
|
|
269
|
+
}
|
|
270
|
+
else if (typeof options.module == 'object' && typeof options.module.scoped == 'number' && (options.module.scoped & ModuleScopeEnumOptions.ICSS)) {
|
|
271
|
+
mapping = parseResult.mapping;
|
|
272
|
+
importMapping = parseResult.importMapping;
|
|
273
|
+
}
|
|
235
274
|
// ast already expanded by parse
|
|
236
|
-
const rendered = render(parseResult.ast, {
|
|
275
|
+
const rendered = render(parseResult.ast, {
|
|
276
|
+
...options,
|
|
277
|
+
expandNestingRules: false
|
|
278
|
+
}, mapping != null ? { mapping, importMapping } : null);
|
|
237
279
|
return {
|
|
238
280
|
...parseResult,
|
|
239
281
|
...rendered,
|
|
@@ -248,4 +290,4 @@ async function transform(css, options = {}) {
|
|
|
248
290
|
});
|
|
249
291
|
}
|
|
250
292
|
|
|
251
|
-
export { dirname, load, parse, parseFile, render, resolve, transform, transformFile };
|
|
293
|
+
export { ModuleScopeEnumOptions, ResponseType, dirname, load, parse, parseFile, render, resolve, transform, transformFile };
|
package/dist/types.d.ts
ADDED
package/dist/types.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* response type
|
|
3
|
+
*/
|
|
4
|
+
var ResponseType;
|
|
5
|
+
(function (ResponseType) {
|
|
6
|
+
/**
|
|
7
|
+
* return text
|
|
8
|
+
*/
|
|
9
|
+
ResponseType[ResponseType["Text"] = 0] = "Text";
|
|
10
|
+
/**
|
|
11
|
+
* return a readable stream
|
|
12
|
+
*/
|
|
13
|
+
ResponseType[ResponseType["ReadableStream"] = 1] = "ReadableStream";
|
|
14
|
+
/**
|
|
15
|
+
* return an arraybuffer
|
|
16
|
+
*/
|
|
17
|
+
ResponseType[ResponseType["ArrayBuffer"] = 2] = "ArrayBuffer";
|
|
18
|
+
})(ResponseType || (ResponseType = {}));
|
|
19
|
+
|
|
20
|
+
export { ResponseType };
|
package/dist/web.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { ModuleScopeEnumOptions } from './lib/ast/types.js';
|
|
2
|
+
export { ColorType, EnumToken, ModuleCaseTransformEnum, ValidationLevel } from './lib/ast/types.js';
|
|
2
3
|
export { minify } from './lib/ast/minify.js';
|
|
3
|
-
export {
|
|
4
|
+
export { WalkerEvent, WalkerOptionEnum, walk, walkValues } from './lib/ast/walk.js';
|
|
4
5
|
export { expand } from './lib/ast/expand.js';
|
|
5
6
|
import { doRender } from './lib/renderer/render.js';
|
|
6
7
|
export { renderToken } from './lib/renderer/render.js';
|
|
@@ -13,11 +14,11 @@ export { convertColor } from './lib/syntax/color/color.js';
|
|
|
13
14
|
import './lib/syntax/color/utils/constants.js';
|
|
14
15
|
export { isOkLabClose, okLabDistance } from './lib/syntax/color/utils/distance.js';
|
|
15
16
|
import './lib/validation/config.js';
|
|
16
|
-
import './lib/validation/parser/types.js';
|
|
17
17
|
import './lib/validation/parser/parse.js';
|
|
18
18
|
import './lib/validation/syntaxes/complex-selector.js';
|
|
19
19
|
import './lib/validation/syntax.js';
|
|
20
20
|
import { matchUrl, resolve, dirname } from './lib/fs/resolve.js';
|
|
21
|
+
import { ResponseType } from './types.js';
|
|
21
22
|
export { FeatureWalkMode } from './lib/ast/features/type.js';
|
|
22
23
|
|
|
23
24
|
/**
|
|
@@ -25,9 +26,13 @@ export { FeatureWalkMode } from './lib/ast/features/type.js';
|
|
|
25
26
|
* @param url
|
|
26
27
|
* @param currentFile
|
|
27
28
|
*
|
|
29
|
+
* @param responseType
|
|
28
30
|
* @private
|
|
29
31
|
*/
|
|
30
|
-
async function load(url, currentFile = '.') {
|
|
32
|
+
async function load(url, currentFile = '.', responseType = false) {
|
|
33
|
+
if (typeof responseType == 'boolean') {
|
|
34
|
+
responseType = responseType ? ResponseType.ReadableStream : ResponseType.Text;
|
|
35
|
+
}
|
|
31
36
|
let t;
|
|
32
37
|
if (matchUrl.test(url)) {
|
|
33
38
|
t = new URL(url);
|
|
@@ -37,21 +42,23 @@ async function load(url, currentFile = '.') {
|
|
|
37
42
|
}
|
|
38
43
|
else {
|
|
39
44
|
const path = resolve(url, currentFile).absolute;
|
|
40
|
-
// @ts-ignore
|
|
41
45
|
t = new URL(path, self.origin);
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
return fetch(t, t.origin != self.origin ? { mode: 'cors' } : {}).then((response) => {
|
|
47
|
+
return fetch(t, t.origin != self.origin ? { mode: 'cors' } : {}).then(async (response) => {
|
|
45
48
|
if (!response.ok) {
|
|
46
49
|
throw new Error(`${response.status} ${response.statusText} ${response.url}`);
|
|
47
50
|
}
|
|
48
|
-
|
|
51
|
+
if (responseType == ResponseType.ArrayBuffer) {
|
|
52
|
+
return response.arrayBuffer();
|
|
53
|
+
}
|
|
54
|
+
return responseType == ResponseType.ReadableStream ? response.body : await response.text();
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
/**
|
|
52
58
|
* render the ast tree
|
|
53
59
|
* @param data
|
|
54
60
|
* @param options
|
|
61
|
+
* @param mapping
|
|
55
62
|
*
|
|
56
63
|
* Example:
|
|
57
64
|
*
|
|
@@ -76,17 +83,18 @@ async function load(url, currentFile = '.') {
|
|
|
76
83
|
* // }
|
|
77
84
|
* ```
|
|
78
85
|
*/
|
|
79
|
-
function render(data, options = {}) {
|
|
86
|
+
function render(data, options = {}, mapping) {
|
|
80
87
|
return doRender(data, Object.assign(options, {
|
|
81
88
|
resolve,
|
|
82
89
|
dirname,
|
|
83
90
|
cwd: options.cwd ?? self.location.pathname.endsWith('/') ? self.location.pathname : dirname(self.location.pathname)
|
|
84
|
-
}));
|
|
91
|
+
}), mapping);
|
|
85
92
|
}
|
|
86
93
|
/**
|
|
87
94
|
* parse css file
|
|
88
95
|
* @param file url or path
|
|
89
96
|
* @param options
|
|
97
|
+
* @param asStream load file as stream
|
|
90
98
|
*
|
|
91
99
|
* @throws Error file not found
|
|
92
100
|
*
|
|
@@ -105,8 +113,8 @@ function render(data, options = {}) {
|
|
|
105
113
|
* console.log(result.ast);
|
|
106
114
|
* ```
|
|
107
115
|
*/
|
|
108
|
-
async function parseFile(file, options = {}) {
|
|
109
|
-
return load(file).then(stream => parse(stream, { src: file, ...options }));
|
|
116
|
+
async function parseFile(file, options = {}, asStream = false) {
|
|
117
|
+
return Promise.resolve((options.load ?? load)(file, '.', asStream)).then(stream => parse(stream, { src: file, ...options }));
|
|
110
118
|
}
|
|
111
119
|
/**
|
|
112
120
|
* parse css
|
|
@@ -140,6 +148,7 @@ async function parse(stream, options = {}) {
|
|
|
140
148
|
return doParse(stream instanceof ReadableStream ? tokenizeStream(stream) : tokenize({
|
|
141
149
|
stream,
|
|
142
150
|
buffer: '',
|
|
151
|
+
offset: 0,
|
|
143
152
|
position: { ind: 0, lin: 1, col: 1 },
|
|
144
153
|
currentPosition: { ind: -1, lin: 1, col: 0 }
|
|
145
154
|
}), Object.assign(options, {
|
|
@@ -147,12 +156,16 @@ async function parse(stream, options = {}) {
|
|
|
147
156
|
resolve,
|
|
148
157
|
dirname,
|
|
149
158
|
cwd: options.cwd ?? self.location.pathname.endsWith('/') ? self.location.pathname : dirname(self.location.pathname)
|
|
150
|
-
}))
|
|
159
|
+
})).then(result => {
|
|
160
|
+
const { revMapping, ...res } = result;
|
|
161
|
+
return res;
|
|
162
|
+
});
|
|
151
163
|
}
|
|
152
164
|
/**
|
|
153
165
|
* transform css file
|
|
154
166
|
* @param file url or path
|
|
155
167
|
* @param options
|
|
168
|
+
* @param asStream load file as stream
|
|
156
169
|
*
|
|
157
170
|
* Example:
|
|
158
171
|
*
|
|
@@ -169,8 +182,8 @@ async function parse(stream, options = {}) {
|
|
|
169
182
|
* console.log(result.code);
|
|
170
183
|
* ```
|
|
171
184
|
*/
|
|
172
|
-
async function transformFile(file, options = {}) {
|
|
173
|
-
return load(file).then(stream => transform(stream, { src: file, ...options }));
|
|
185
|
+
async function transformFile(file, options = {}, asStream = false) {
|
|
186
|
+
return Promise.resolve((options.load ?? load)(file, '.', asStream)).then(stream => transform(stream, { src: file, ...options }));
|
|
174
187
|
}
|
|
175
188
|
/**
|
|
176
189
|
* transform css
|
|
@@ -198,8 +211,21 @@ async function transform(css, options = {}) {
|
|
|
198
211
|
options = { minify: true, removeEmpty: true, removeCharset: true, ...options };
|
|
199
212
|
const startTime = performance.now();
|
|
200
213
|
return parse(css, options).then((parseResult) => {
|
|
214
|
+
let mapping = null;
|
|
215
|
+
let importMapping = null;
|
|
216
|
+
if (typeof options.module == 'number' && (options.module & ModuleScopeEnumOptions.ICSS)) {
|
|
217
|
+
mapping = parseResult.mapping;
|
|
218
|
+
importMapping = parseResult.importMapping;
|
|
219
|
+
}
|
|
220
|
+
else if (typeof options.module == 'object' && typeof options.module.scoped == 'number' && (options.module.scoped & ModuleScopeEnumOptions.ICSS)) {
|
|
221
|
+
mapping = parseResult.mapping;
|
|
222
|
+
importMapping = parseResult.importMapping;
|
|
223
|
+
}
|
|
201
224
|
// ast already expanded by parse
|
|
202
|
-
const rendered = render(parseResult.ast, {
|
|
225
|
+
const rendered = render(parseResult.ast, {
|
|
226
|
+
...options,
|
|
227
|
+
expandNestingRules: false
|
|
228
|
+
}, mapping != null ? { mapping, importMapping } : null);
|
|
203
229
|
return {
|
|
204
230
|
...parseResult,
|
|
205
231
|
...rendered,
|
|
@@ -214,4 +240,4 @@ async function transform(css, options = {}) {
|
|
|
214
240
|
});
|
|
215
241
|
}
|
|
216
242
|
|
|
217
|
-
export { dirname, load, parse, parseFile, render, resolve, transform, transformFile };
|
|
243
|
+
export { ModuleScopeEnumOptions, ResponseType, dirname, load, parse, parseFile, render, resolve, transform, transformFile };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tbela99/css-parser",
|
|
3
3
|
"description": "CSS parser, minifier and validator for node and the browser",
|
|
4
|
-
"version": "v1.
|
|
4
|
+
"version": "v1.4.0",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/node.js",
|
|
7
7
|
"./node": "./dist/node.js",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
17
|
"doc": "typedoc --tsconfig typedoc-tsconfig.jsonc",
|
|
18
|
-
"build": "rollup -c;./build.sh dist/index.d.ts 'declare interface' 'declare type'",
|
|
19
|
-
"test": "web-test-runner \"test/**/web.spec.js\" --timeout=10000 --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.; mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
|
|
20
|
-
"test:web": "web-test-runner \"test/**/web.spec.js\" --timeout 30000 --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.",
|
|
18
|
+
"build": "rollup -c;./build.sh ./dist/index.d.ts 'declare interface' 'declare type'",
|
|
19
|
+
"test": "web-test-runner \"./test/**/web.spec.js\" --timeout=10000 --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.; mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
|
|
20
|
+
"test:web": "web-test-runner \"./test/**/web.spec.js\" --timeout 30000 --node-resolve --playwright --browsers chromium firefox webkit --root-dir=.",
|
|
21
21
|
"test:node": "mocha -p --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
|
|
22
22
|
"test:cov": "c8 -x 'test/specs/**/*.js' --reporter=html --reporter=text --reporter=json-summary mocha --reporter-options='maxDiffSize=1801920' --timeout=10000 \"test/**/node.spec.js\"",
|
|
23
23
|
"test:web-cov": "web-test-runner -x 'test/specs/**/*.js' \"test/**/web.spec.js\" --node-resolve --playwright --browsers chromium firefox webkit --root-dir=. --coverage",
|
|
24
24
|
"profile": "node --enable-source-maps --inspect-brk test/inspect.js",
|
|
25
25
|
"syntax-update": "esno tools/validation.ts",
|
|
26
|
-
"debug": "web-test-runner \"test/**/web.spec.js\" --manual --open --node-resolve --root-dir=."
|
|
26
|
+
"debug": "web-test-runner \"./test/**/web.spec.js\" --manual --open --node-resolve --root-dir=."
|
|
27
27
|
},
|
|
28
28
|
"repository": {
|
|
29
29
|
"type": "git",
|
|
@@ -42,7 +42,10 @@
|
|
|
42
42
|
"css-nesting",
|
|
43
43
|
"css-compiler",
|
|
44
44
|
"nested-css",
|
|
45
|
-
"walker"
|
|
45
|
+
"walker",
|
|
46
|
+
"stream",
|
|
47
|
+
"streaming",
|
|
48
|
+
"streaming-parser"
|
|
46
49
|
],
|
|
47
50
|
"author": "Thierry Bela",
|
|
48
51
|
"license": "MIT OR LGPL-3.0",
|
|
@@ -52,24 +55,24 @@
|
|
|
52
55
|
"homepage": "https://github.com/tbela99/css-parser#readme",
|
|
53
56
|
"devDependencies": {
|
|
54
57
|
"@esm-bundle/chai": "^4.3.4-fix.0",
|
|
55
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
58
|
+
"@rollup/plugin-commonjs": "^28.0.8",
|
|
56
59
|
"@rollup/plugin-json": "^6.1.0",
|
|
57
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
58
|
-
"@rollup/plugin-typescript": "^12.
|
|
59
|
-
"@types/chai": "^5.2.
|
|
60
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
61
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
62
|
+
"@types/chai": "^5.2.3",
|
|
60
63
|
"@types/mocha": "^10.0.10",
|
|
61
|
-
"@types/node": "^24.
|
|
62
|
-
"@types/web": "^0.0.
|
|
64
|
+
"@types/node": "^24.9.1",
|
|
65
|
+
"@types/web": "^0.0.274",
|
|
63
66
|
"@web/test-runner": "^0.20.2",
|
|
64
67
|
"@web/test-runner-playwright": "^0.11.1",
|
|
65
68
|
"c8": "^10.1.3",
|
|
66
69
|
"esno": "^4.8.0",
|
|
67
|
-
"mocha": "^11.7.
|
|
68
|
-
"playwright": "^1.
|
|
69
|
-
"rollup": "^4.
|
|
70
|
-
"rollup-plugin-dts": "^6.2.
|
|
70
|
+
"mocha": "^11.7.4",
|
|
71
|
+
"playwright": "^1.56.1",
|
|
72
|
+
"rollup": "^4.52.5",
|
|
73
|
+
"rollup-plugin-dts": "^6.2.3",
|
|
71
74
|
"tslib": "^2.8.1",
|
|
72
|
-
"typedoc": "^0.28.
|
|
75
|
+
"typedoc": "^0.28.14",
|
|
73
76
|
"typedoc-material-theme": "^1.4.0"
|
|
74
77
|
}
|
|
75
78
|
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var ValidationTokenEnum;
|
|
2
|
-
(function (ValidationTokenEnum) {
|
|
3
|
-
ValidationTokenEnum[ValidationTokenEnum["Root"] = 0] = "Root";
|
|
4
|
-
ValidationTokenEnum[ValidationTokenEnum["Keyword"] = 1] = "Keyword";
|
|
5
|
-
ValidationTokenEnum[ValidationTokenEnum["PropertyType"] = 2] = "PropertyType";
|
|
6
|
-
ValidationTokenEnum[ValidationTokenEnum["DeclarationType"] = 3] = "DeclarationType";
|
|
7
|
-
ValidationTokenEnum[ValidationTokenEnum["AtRule"] = 4] = "AtRule";
|
|
8
|
-
ValidationTokenEnum[ValidationTokenEnum["ValidationFunctionDefinition"] = 5] = "ValidationFunctionDefinition";
|
|
9
|
-
ValidationTokenEnum[ValidationTokenEnum["OpenBracket"] = 6] = "OpenBracket";
|
|
10
|
-
ValidationTokenEnum[ValidationTokenEnum["CloseBracket"] = 7] = "CloseBracket";
|
|
11
|
-
ValidationTokenEnum[ValidationTokenEnum["OpenParenthesis"] = 8] = "OpenParenthesis";
|
|
12
|
-
ValidationTokenEnum[ValidationTokenEnum["CloseParenthesis"] = 9] = "CloseParenthesis";
|
|
13
|
-
ValidationTokenEnum[ValidationTokenEnum["Comma"] = 10] = "Comma";
|
|
14
|
-
ValidationTokenEnum[ValidationTokenEnum["Pipe"] = 11] = "Pipe";
|
|
15
|
-
ValidationTokenEnum[ValidationTokenEnum["Column"] = 12] = "Column";
|
|
16
|
-
ValidationTokenEnum[ValidationTokenEnum["Star"] = 13] = "Star";
|
|
17
|
-
ValidationTokenEnum[ValidationTokenEnum["OpenCurlyBrace"] = 14] = "OpenCurlyBrace";
|
|
18
|
-
ValidationTokenEnum[ValidationTokenEnum["CloseCurlyBrace"] = 15] = "CloseCurlyBrace";
|
|
19
|
-
ValidationTokenEnum[ValidationTokenEnum["HashMark"] = 16] = "HashMark";
|
|
20
|
-
ValidationTokenEnum[ValidationTokenEnum["QuestionMark"] = 17] = "QuestionMark";
|
|
21
|
-
ValidationTokenEnum[ValidationTokenEnum["Function"] = 18] = "Function";
|
|
22
|
-
ValidationTokenEnum[ValidationTokenEnum["Number"] = 19] = "Number";
|
|
23
|
-
ValidationTokenEnum[ValidationTokenEnum["Whitespace"] = 20] = "Whitespace";
|
|
24
|
-
ValidationTokenEnum[ValidationTokenEnum["Parenthesis"] = 21] = "Parenthesis";
|
|
25
|
-
ValidationTokenEnum[ValidationTokenEnum["Bracket"] = 22] = "Bracket";
|
|
26
|
-
ValidationTokenEnum[ValidationTokenEnum["Block"] = 23] = "Block";
|
|
27
|
-
ValidationTokenEnum[ValidationTokenEnum["AtLeastOnce"] = 24] = "AtLeastOnce";
|
|
28
|
-
ValidationTokenEnum[ValidationTokenEnum["Separator"] = 25] = "Separator";
|
|
29
|
-
ValidationTokenEnum[ValidationTokenEnum["Exclamation"] = 26] = "Exclamation";
|
|
30
|
-
ValidationTokenEnum[ValidationTokenEnum["Ampersand"] = 27] = "Ampersand";
|
|
31
|
-
ValidationTokenEnum[ValidationTokenEnum["PipeToken"] = 28] = "PipeToken";
|
|
32
|
-
ValidationTokenEnum[ValidationTokenEnum["ColumnToken"] = 29] = "ColumnToken";
|
|
33
|
-
ValidationTokenEnum[ValidationTokenEnum["AmpersandToken"] = 30] = "AmpersandToken";
|
|
34
|
-
ValidationTokenEnum[ValidationTokenEnum["Parens"] = 31] = "Parens";
|
|
35
|
-
ValidationTokenEnum[ValidationTokenEnum["PseudoClassToken"] = 32] = "PseudoClassToken";
|
|
36
|
-
ValidationTokenEnum[ValidationTokenEnum["PseudoClassFunctionToken"] = 33] = "PseudoClassFunctionToken";
|
|
37
|
-
ValidationTokenEnum[ValidationTokenEnum["StringToken"] = 34] = "StringToken";
|
|
38
|
-
ValidationTokenEnum[ValidationTokenEnum["AtRuleDefinition"] = 35] = "AtRuleDefinition";
|
|
39
|
-
ValidationTokenEnum[ValidationTokenEnum["DeclarationNameToken"] = 36] = "DeclarationNameToken";
|
|
40
|
-
ValidationTokenEnum[ValidationTokenEnum["DeclarationDefinitionToken"] = 37] = "DeclarationDefinitionToken";
|
|
41
|
-
ValidationTokenEnum[ValidationTokenEnum["SemiColon"] = 38] = "SemiColon";
|
|
42
|
-
ValidationTokenEnum[ValidationTokenEnum["Character"] = 39] = "Character";
|
|
43
|
-
ValidationTokenEnum[ValidationTokenEnum["InfinityToken"] = 40] = "InfinityToken";
|
|
44
|
-
})(ValidationTokenEnum || (ValidationTokenEnum = {}));
|
|
45
|
-
var ValidationSyntaxGroupEnum;
|
|
46
|
-
(function (ValidationSyntaxGroupEnum) {
|
|
47
|
-
ValidationSyntaxGroupEnum["Declarations"] = "declarations";
|
|
48
|
-
ValidationSyntaxGroupEnum["Functions"] = "functions";
|
|
49
|
-
ValidationSyntaxGroupEnum["Syntaxes"] = "syntaxes";
|
|
50
|
-
ValidationSyntaxGroupEnum["Selectors"] = "selectors";
|
|
51
|
-
ValidationSyntaxGroupEnum["AtRules"] = "atRules";
|
|
52
|
-
})(ValidationSyntaxGroupEnum || (ValidationSyntaxGroupEnum = {}));
|
|
53
|
-
|
|
54
|
-
export { ValidationSyntaxGroupEnum, ValidationTokenEnum };
|