@tbela99/css-parser 0.7.1 → 0.9.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/.editorconfig +484 -0
- package/README.md +140 -84
- package/dist/index-umd-web.js +8461 -51655
- package/dist/index.cjs +8437 -51636
- package/dist/index.d.ts +220 -68
- package/dist/lib/ast/expand.js +46 -9
- package/dist/lib/ast/features/calc.js +76 -12
- package/dist/lib/ast/features/inlinecssvariables.js +6 -1
- package/dist/lib/ast/features/prefix.js +17 -9
- package/dist/lib/ast/features/shorthand.js +1 -0
- package/dist/lib/ast/math/expression.js +299 -11
- package/dist/lib/ast/math/math.js +7 -1
- package/dist/lib/ast/minify.js +30 -16
- package/dist/lib/ast/types.js +59 -49
- package/dist/lib/ast/walk.js +92 -18
- package/dist/lib/parser/declaration/list.js +1 -0
- package/dist/lib/parser/declaration/map.js +60 -52
- package/dist/lib/parser/declaration/set.js +1 -12
- package/dist/lib/parser/parse.js +371 -119
- package/dist/lib/parser/tokenize.js +31 -6
- package/dist/lib/parser/utils/declaration.js +2 -2
- package/dist/lib/parser/utils/type.js +6 -6
- package/dist/lib/renderer/color/a98rgb.js +1 -0
- package/dist/lib/renderer/color/color.js +1 -0
- package/dist/lib/renderer/color/colormix.js +1 -0
- package/dist/lib/renderer/color/hex.js +2 -1
- package/dist/lib/renderer/color/hsl.js +2 -1
- package/dist/lib/renderer/color/hwb.js +3 -2
- package/dist/lib/renderer/color/lab.js +2 -1
- package/dist/lib/renderer/color/lch.js +2 -1
- package/dist/lib/renderer/color/oklab.js +3 -2
- package/dist/lib/renderer/color/oklch.js +2 -1
- package/dist/lib/renderer/color/p3.js +2 -1
- package/dist/lib/renderer/color/prophotoRgb.js +56 -0
- package/dist/lib/renderer/color/prophotorgb.js +1 -1
- package/dist/lib/renderer/color/rec2020.js +1 -0
- package/dist/lib/renderer/color/relativecolor.js +52 -28
- package/dist/lib/renderer/color/rgb.js +2 -1
- package/dist/lib/renderer/color/srgb.js +3 -2
- package/dist/lib/renderer/color/utils/components.js +1 -0
- package/dist/lib/renderer/color/utils/constants.js +2 -1
- package/dist/lib/renderer/color/xyz.js +2 -1
- package/dist/lib/renderer/color/xyzd50.js +1 -0
- package/dist/lib/renderer/render.js +62 -12
- package/dist/lib/syntax/syntax.js +362 -4
- package/dist/lib/validation/at-rules/container.js +353 -0
- package/dist/lib/validation/at-rules/counter-style.js +78 -0
- package/dist/lib/validation/at-rules/custom-media.js +52 -0
- package/dist/lib/validation/at-rules/document.js +114 -0
- package/dist/lib/validation/at-rules/else.js +5 -0
- package/dist/lib/validation/at-rules/font-feature-values.js +52 -0
- package/dist/lib/validation/at-rules/import.js +199 -0
- package/dist/lib/validation/at-rules/keyframes.js +70 -0
- package/dist/lib/validation/at-rules/layer.js +30 -0
- package/dist/lib/validation/at-rules/media.js +254 -0
- package/dist/lib/validation/at-rules/namespace.js +85 -0
- package/dist/lib/validation/at-rules/page-margin-box.js +56 -0
- package/dist/lib/validation/at-rules/page.js +88 -0
- package/dist/lib/validation/at-rules/supports.js +262 -0
- package/dist/lib/validation/at-rules/when.js +178 -0
- package/dist/lib/validation/atrule.js +187 -0
- package/dist/lib/validation/config.js +35 -2
- package/dist/lib/validation/config.json.js +1683 -50905
- package/dist/lib/validation/declaration.js +102 -0
- package/dist/lib/validation/parser/parse.js +1137 -7
- package/dist/lib/validation/parser/types.js +28 -12
- package/dist/lib/validation/selector.js +26 -444
- package/dist/lib/validation/syntax.js +1475 -0
- package/dist/lib/validation/syntaxes/complex-selector-list.js +45 -0
- package/dist/lib/validation/syntaxes/complex-selector.js +53 -0
- package/dist/lib/validation/syntaxes/compound-selector.js +226 -0
- package/dist/lib/validation/syntaxes/family-name.js +91 -0
- package/dist/lib/validation/syntaxes/image.js +29 -0
- package/dist/lib/validation/syntaxes/keyframe-block-list.js +27 -0
- package/dist/lib/validation/syntaxes/keyframe-selector.js +137 -0
- package/dist/lib/validation/syntaxes/layer-name.js +67 -0
- package/dist/lib/validation/syntaxes/relative-selector-list.js +57 -0
- package/dist/lib/validation/syntaxes/relative-selector.js +36 -0
- package/dist/lib/validation/syntaxes/selector-list.js +5 -0
- package/dist/lib/validation/syntaxes/selector.js +5 -0
- package/dist/lib/validation/syntaxes/url.js +75 -0
- package/dist/lib/validation/utils/list.js +24 -0
- package/dist/lib/validation/utils/whitespace.js +22 -0
- package/dist/node/index.js +5 -5
- package/dist/web/index.js +5 -1
- package/dist/web/load.js +1 -0
- package/package.json +16 -14
- package/dist/lib/ast/utils/minifyfeature.js +0 -9
- package/dist/lib/iterable/weakset.js +0 -58
- package/dist/lib/parser/utils/syntax.js +0 -450
|
@@ -4,11 +4,12 @@ import { getComponents } from './color/utils/components.js';
|
|
|
4
4
|
import { reduceHexValue, srgb2hexvalues, rgb2hex, hsl2hex, hwb2hex, cmyk2hex, oklab2hex, oklch2hex, lab2hex, lch2hex } from './color/hex.js';
|
|
5
5
|
import { EnumToken } from '../ast/types.js';
|
|
6
6
|
import '../ast/minify.js';
|
|
7
|
+
import '../ast/walk.js';
|
|
7
8
|
import { expand } from '../ast/expand.js';
|
|
8
9
|
import { colorMix } from './color/colormix.js';
|
|
9
10
|
import { parseRelativeColor } from './color/relativecolor.js';
|
|
10
11
|
import { SourceMap } from './sourcemap/sourcemap.js';
|
|
11
|
-
import { isColor, isNewLine } from '../syntax/syntax.js';
|
|
12
|
+
import { isColor, mathFuncs, isNewLine } from '../syntax/syntax.js';
|
|
12
13
|
|
|
13
14
|
const colorsFunc = ['rgb', 'rgba', 'hsl', 'hsla', 'hwb', 'device-cmyk', 'color-mix', 'color', 'oklab', 'lab', 'oklch', 'lch', 'light-dark'];
|
|
14
15
|
function reduceNumber(val) {
|
|
@@ -40,16 +41,27 @@ function update(position, str) {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* render ast
|
|
46
|
+
* @param data
|
|
47
|
+
* @param options
|
|
48
|
+
*/
|
|
43
49
|
function doRender(data, options = {}) {
|
|
50
|
+
const minify = options.minify ?? true;
|
|
51
|
+
const beautify = options.beautify ?? !minify;
|
|
44
52
|
options = {
|
|
45
|
-
...(
|
|
53
|
+
...(beautify ? {
|
|
54
|
+
indent: ' ',
|
|
55
|
+
newLine: '\n',
|
|
56
|
+
} : {
|
|
46
57
|
indent: '',
|
|
47
58
|
newLine: '',
|
|
59
|
+
}),
|
|
60
|
+
...(minify ? {
|
|
61
|
+
removeEmpty: true,
|
|
48
62
|
removeComments: true
|
|
49
63
|
} : {
|
|
50
|
-
|
|
51
|
-
newLine: '\n',
|
|
52
|
-
compress: false,
|
|
64
|
+
removeEmpty: false,
|
|
53
65
|
removeComments: false,
|
|
54
66
|
}), sourcemap: false, convertColor: true, expandNestingRules: false, preserveLicense: false, ...options
|
|
55
67
|
};
|
|
@@ -117,7 +129,18 @@ function updateSourceMap(node, options, cache, sourcemap, position, str) {
|
|
|
117
129
|
}
|
|
118
130
|
update(position, str);
|
|
119
131
|
}
|
|
120
|
-
|
|
132
|
+
/**
|
|
133
|
+
* render ast node
|
|
134
|
+
* @param data
|
|
135
|
+
* @param options
|
|
136
|
+
* @param sourcemap
|
|
137
|
+
* @param position
|
|
138
|
+
* @param errors
|
|
139
|
+
* @param reducer
|
|
140
|
+
* @param cache
|
|
141
|
+
* @param level
|
|
142
|
+
* @param indents
|
|
143
|
+
*/
|
|
121
144
|
function renderAstNode(data, options, sourcemap, position, errors, reducer, cache, level = 0, indents = []) {
|
|
122
145
|
if (indents.length < level + 1) {
|
|
123
146
|
indents.push(options.indent.repeat(level));
|
|
@@ -193,6 +216,9 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
|
|
|
193
216
|
}
|
|
194
217
|
return `${css}${options.newLine}${indentSub}${str}`;
|
|
195
218
|
}, '');
|
|
219
|
+
if (options.removeEmpty && children === '') {
|
|
220
|
+
return '';
|
|
221
|
+
}
|
|
196
222
|
if (children.endsWith(';')) {
|
|
197
223
|
children = children.slice(0, -1);
|
|
198
224
|
}
|
|
@@ -201,12 +227,21 @@ function renderAstNode(data, options, sourcemap, position, errors, reducer, cach
|
|
|
201
227
|
}
|
|
202
228
|
return data.sel + `${options.indent}{${options.newLine}` + (children === '' ? '' : indentSub + children + options.newLine) + indent + `}`;
|
|
203
229
|
case EnumToken.InvalidRuleTokenType:
|
|
230
|
+
case EnumToken.InvalidAtRuleTokenType:
|
|
204
231
|
return '';
|
|
205
232
|
default:
|
|
233
|
+
// return renderToken(data as Token, options, cache, reducer, errors);
|
|
206
234
|
throw new Error(`render: unexpected token ${JSON.stringify(data, null, 1)}`);
|
|
207
235
|
}
|
|
208
|
-
return '';
|
|
209
236
|
}
|
|
237
|
+
/**
|
|
238
|
+
* render ast token
|
|
239
|
+
* @param token
|
|
240
|
+
* @param options
|
|
241
|
+
* @param cache
|
|
242
|
+
* @param reducer
|
|
243
|
+
* @param errors
|
|
244
|
+
*/
|
|
210
245
|
function renderToken(token, options = {}, cache = Object.create(null), reducer, errors) {
|
|
211
246
|
if (reducer == null) {
|
|
212
247
|
reducer = function (acc, curr) {
|
|
@@ -394,19 +429,18 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
394
429
|
case EnumToken.TimelineFunctionTokenType:
|
|
395
430
|
case EnumToken.GridTemplateFuncTokenType:
|
|
396
431
|
if (token.typ == EnumToken.FunctionTokenType &&
|
|
397
|
-
token.val
|
|
432
|
+
mathFuncs.includes(token.val) &&
|
|
398
433
|
token.chi.length == 1 &&
|
|
399
|
-
token.chi[0].typ
|
|
400
|
-
|
|
434
|
+
![EnumToken.BinaryExpressionTokenType, EnumToken.FractionTokenType, EnumToken.IdenTokenType].includes(token.chi[0].typ) &&
|
|
435
|
+
// @ts-ignore
|
|
401
436
|
token.chi[0].val?.typ != EnumToken.FractionTokenType) {
|
|
402
|
-
// calc(200px) => 200px
|
|
403
437
|
return token.chi.reduce((acc, curr) => acc + renderToken(curr, options, cache, reducer), '');
|
|
404
438
|
}
|
|
405
439
|
// @ts-ignore
|
|
406
440
|
return ( /* options.minify && 'Pseudo-class-func' == token.typ && token.val.slice(0, 2) == '::' ? token.val.slice(1) :*/token.val ?? '') + '(' + token.chi.reduce(reducer, '') + ')';
|
|
407
441
|
case EnumToken.MatchExpressionTokenType:
|
|
408
442
|
return renderToken(token.l, options, cache, reducer, errors) +
|
|
409
|
-
renderToken(
|
|
443
|
+
renderToken(token.op, options, cache, reducer, errors) +
|
|
410
444
|
renderToken(token.r, options, cache, reducer, errors) +
|
|
411
445
|
(token.attr ? ' ' + token.attr : '');
|
|
412
446
|
case EnumToken.NameSpaceAttributeTokenType:
|
|
@@ -419,6 +453,7 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
419
453
|
case EnumToken.StartParensTokenType:
|
|
420
454
|
return '(';
|
|
421
455
|
case EnumToken.DelimTokenType:
|
|
456
|
+
case EnumToken.EqualMatchTokenType:
|
|
422
457
|
return '=';
|
|
423
458
|
case EnumToken.IncludeMatchTokenType:
|
|
424
459
|
return '~=';
|
|
@@ -587,6 +622,7 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
587
622
|
case EnumToken.StringTokenType:
|
|
588
623
|
case EnumToken.LiteralTokenType:
|
|
589
624
|
case EnumToken.DashedIdenTokenType:
|
|
625
|
+
case EnumToken.PseudoPageTokenType:
|
|
590
626
|
case EnumToken.ClassSelectorTokenType:
|
|
591
627
|
return /* options.minify && 'Pseudo-class' == token.typ && '::' == token.val.slice(0, 2) ? token.val.slice(1) : */ token.val;
|
|
592
628
|
case EnumToken.NestingSelectorTokenType:
|
|
@@ -595,6 +631,20 @@ function renderToken(token, options = {}, cache = Object.create(null), reducer,
|
|
|
595
631
|
return '[' + token.chi.reduce((acc, curr) => acc + renderToken(curr, options, cache), '');
|
|
596
632
|
case EnumToken.InvalidClassSelectorTokenType:
|
|
597
633
|
return token.val;
|
|
634
|
+
case EnumToken.DeclarationNodeType:
|
|
635
|
+
return token.nam + ':' + token.val.reduce((acc, curr) => acc + renderToken(curr, options, cache), '');
|
|
636
|
+
case EnumToken.MediaQueryConditionTokenType:
|
|
637
|
+
return renderToken(token.l, options, cache, reducer, errors) + renderToken(token.op, options, cache, reducer, errors) + token.r.reduce((acc, curr) => acc + renderToken(curr, options, cache), '');
|
|
638
|
+
case EnumToken.MediaFeatureTokenType:
|
|
639
|
+
return token.val;
|
|
640
|
+
case EnumToken.MediaFeatureNotTokenType:
|
|
641
|
+
return 'not ' + renderToken(token.val, options, cache, reducer, errors);
|
|
642
|
+
case EnumToken.MediaFeatureOnlyTokenType:
|
|
643
|
+
return 'only ' + renderToken(token.val, options, cache, reducer, errors);
|
|
644
|
+
case EnumToken.MediaFeatureAndTokenType:
|
|
645
|
+
return 'and';
|
|
646
|
+
case EnumToken.MediaFeatureOrTokenType:
|
|
647
|
+
return 'or';
|
|
598
648
|
default:
|
|
599
649
|
throw new Error(`render: unexpected token ${JSON.stringify(token, null, 1)}`);
|
|
600
650
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { colorsFunc } from '../renderer/render.js';
|
|
2
2
|
import { EnumToken } from '../ast/types.js';
|
|
3
3
|
import '../ast/minify.js';
|
|
4
|
+
import '../ast/walk.js';
|
|
4
5
|
import '../parser/parse.js';
|
|
5
6
|
import '../parser/utils/config.js';
|
|
6
7
|
import { COLORS_NAMES } from '../renderer/color/utils/constants.js';
|
|
@@ -15,6 +16,350 @@ const dimensionUnits = new Set([
|
|
|
15
16
|
'lvh', 'lvi', 'lvmax', 'lvw', 'mm', 'pc', 'pt', 'px', 'rem', 'rlh', 'svb',
|
|
16
17
|
'svh', 'svi', 'svmin', 'svw', 'vb', 'vh', 'vi', 'vmax', 'vmin', 'vw'
|
|
17
18
|
]);
|
|
19
|
+
const fontFormat = ['collection', 'embedded-opentype', 'opentype', 'svg', 'truetype', 'woff', 'woff2'];
|
|
20
|
+
const colorFontTech = ['color-colrv0', 'color-colrv1', 'color-svg', 'color-sbix', 'color-cbdt'];
|
|
21
|
+
const fontFeaturesTech = ['features-opentype', 'features-aat', 'features-graphite', 'incremental-patch', 'incremental-range', 'incremental-auto', 'variations', 'palettes'];
|
|
22
|
+
// https://drafts.csswg.org/mediaqueries/#media-types
|
|
23
|
+
const mediaTypes = ['all', 'print', 'screen',
|
|
24
|
+
/* deprecated */
|
|
25
|
+
'aural', 'braille', 'embossed', 'handheld', 'projection', 'tty', 'tv', 'speech'];
|
|
26
|
+
// https://www.w3.org/TR/css-values-4/#math-function
|
|
27
|
+
const mathFuncs = ['calc', 'clamp', 'min', 'max', 'round', 'mod', 'rem', 'sin', 'cos', 'tan', 'asin', 'acos', 'atan', 'atan2', 'pow', 'sqrt', 'hypot', 'log', 'exp', 'abs', 'sign'];
|
|
28
|
+
const webkitPseudoAliasMap = {
|
|
29
|
+
'-webkit-autofill': 'autofill',
|
|
30
|
+
'-webkit-any': 'is',
|
|
31
|
+
'-moz-any': 'is',
|
|
32
|
+
'-webkit-border-after': 'border-block-end',
|
|
33
|
+
'-webkit-border-after-color': 'border-block-end-color',
|
|
34
|
+
'-webkit-border-after-style': 'border-block-end-style',
|
|
35
|
+
'-webkit-border-after-width': 'border-block-end-width',
|
|
36
|
+
'-webkit-border-before': 'border-block-start',
|
|
37
|
+
'-webkit-border-before-color': 'border-block-start-color',
|
|
38
|
+
'-webkit-border-before-style': 'border-block-start-style',
|
|
39
|
+
'-webkit-border-before-width': 'border-block-start-width',
|
|
40
|
+
'-webkit-border-end': 'border-inline-end',
|
|
41
|
+
'-webkit-border-end-color': 'border-inline-end-color',
|
|
42
|
+
'-webkit-border-end-style': 'border-inline-end-style',
|
|
43
|
+
'-webkit-border-end-width': 'border-inline-end-width',
|
|
44
|
+
'-webkit-border-start': 'border-inline-start',
|
|
45
|
+
'-webkit-border-start-color': 'border-inline-start-color',
|
|
46
|
+
'-webkit-border-start-style': 'border-inline-start-style',
|
|
47
|
+
'-webkit-border-start-width': 'border-inline-start-width',
|
|
48
|
+
'-webkit-box-align': 'align-items',
|
|
49
|
+
'-webkit-box-direction': 'flex-direction',
|
|
50
|
+
'-webkit-box-flex': 'flex-grow',
|
|
51
|
+
'-webkit-box-lines': 'flex-flow',
|
|
52
|
+
'-webkit-box-ordinal-group': 'order',
|
|
53
|
+
'-webkit-box-orient': 'flex-direction',
|
|
54
|
+
'-webkit-box-pack': 'justify-content',
|
|
55
|
+
'-webkit-column-break-after': 'break-after',
|
|
56
|
+
'-webkit-column-break-before': 'break-before',
|
|
57
|
+
'-webkit-column-break-inside': 'break-inside',
|
|
58
|
+
'-webkit-font-feature-settings': 'font-feature-settings',
|
|
59
|
+
'-webkit-hyphenate-character': 'hyphenate-character',
|
|
60
|
+
'-webkit-initial-letter': 'initial-letter',
|
|
61
|
+
'-webkit-margin-end': 'margin-block-end',
|
|
62
|
+
'-webkit-margin-start': 'margin-block-start',
|
|
63
|
+
'-webkit-padding-after': 'padding-block-end',
|
|
64
|
+
'-webkit-padding-before': 'padding-block-start',
|
|
65
|
+
'-webkit-padding-end': 'padding-inline-end',
|
|
66
|
+
'-webkit-padding-start': 'padding-inline-start',
|
|
67
|
+
'-webkit-min-device-pixel-ratio': 'min-resolution',
|
|
68
|
+
'-webkit-max-device-pixel-ratio': 'max-resolution'
|
|
69
|
+
};
|
|
70
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/WebKit_Extensions
|
|
71
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar
|
|
72
|
+
const webkitExtensions = new Set([
|
|
73
|
+
'-webkit-app-region',
|
|
74
|
+
'-webkit-border-horizontal-spacing',
|
|
75
|
+
'-webkit-border-vertical-spacing',
|
|
76
|
+
'-webkit-box-reflect',
|
|
77
|
+
'-webkit-column-axis',
|
|
78
|
+
'-webkit-column-progression',
|
|
79
|
+
'-webkit-cursor-visibility',
|
|
80
|
+
'-webkit-font-smoothing',
|
|
81
|
+
'-webkit-hyphenate-limit-after',
|
|
82
|
+
'-webkit-hyphenate-limit-before',
|
|
83
|
+
'-webkit-hyphenate-limit-lines',
|
|
84
|
+
'-webkit-line-align',
|
|
85
|
+
'-webkit-line-box-contain',
|
|
86
|
+
'-webkit-line-clamp',
|
|
87
|
+
'-webkit-line-grid',
|
|
88
|
+
'-webkit-line-snap',
|
|
89
|
+
'-webkit-locale',
|
|
90
|
+
'-webkit-logical-height',
|
|
91
|
+
'-webkit-logical-width',
|
|
92
|
+
'-webkit-margin-after',
|
|
93
|
+
'-webkit-margin-before',
|
|
94
|
+
'-webkit-mask-box-image-outset',
|
|
95
|
+
'-webkit-mask-box-image-repeat',
|
|
96
|
+
'-webkit-mask-box-image-slice',
|
|
97
|
+
'-webkit-mask-box-image-source',
|
|
98
|
+
'-webkit-mask-box-image-width',
|
|
99
|
+
'-webkit-mask-box-image',
|
|
100
|
+
'-webkit-mask-composite',
|
|
101
|
+
'-webkit-mask-position-x',
|
|
102
|
+
'-webkit-mask-position-y',
|
|
103
|
+
'-webkit-mask-repeat-x',
|
|
104
|
+
'-webkit-mask-repeat-y',
|
|
105
|
+
'-webkit-mask-source-type',
|
|
106
|
+
'-webkit-max-logical-height',
|
|
107
|
+
'-webkit-max-logical-width',
|
|
108
|
+
'-webkit-min-logical-height',
|
|
109
|
+
'-webkit-min-logical-width',
|
|
110
|
+
'-webkit-nbsp-mode',
|
|
111
|
+
'-webkit-perspective-origin-x',
|
|
112
|
+
'-webkit-perspective-origin-y',
|
|
113
|
+
'-webkit-rtl-ordering',
|
|
114
|
+
'-webkit-tap-highlight-color',
|
|
115
|
+
'-webkit-text-decoration-skip',
|
|
116
|
+
'-webkit-text-decorations-in-effect',
|
|
117
|
+
'-webkit-text-fill-color',
|
|
118
|
+
'-webkit-text-security',
|
|
119
|
+
'-webkit-text-stroke-color',
|
|
120
|
+
'-webkit-text-stroke-width',
|
|
121
|
+
'-webkit-text-stroke',
|
|
122
|
+
'-webkit-text-zoom',
|
|
123
|
+
'-webkit-touch-callout',
|
|
124
|
+
'-webkit-transform-origin-x',
|
|
125
|
+
'-webkit-transform-origin-y',
|
|
126
|
+
'-webkit-transform-origin-z',
|
|
127
|
+
'-webkit-user-drag',
|
|
128
|
+
'-webkit-user-modify',
|
|
129
|
+
'-webkit-border-after',
|
|
130
|
+
'-webkit-border-after-color',
|
|
131
|
+
'-webkit-border-after-style',
|
|
132
|
+
'-webkit-border-after-width',
|
|
133
|
+
'-webkit-border-before',
|
|
134
|
+
'-webkit-border-before-color',
|
|
135
|
+
'-webkit-border-before-style',
|
|
136
|
+
'-webkit-border-before-width',
|
|
137
|
+
'-webkit-border-end',
|
|
138
|
+
'-webkit-border-end-color',
|
|
139
|
+
'-webkit-border-end-style',
|
|
140
|
+
'-webkit-border-end-width',
|
|
141
|
+
'-webkit-border-start',
|
|
142
|
+
'-webkit-border-start-color',
|
|
143
|
+
'-webkit-border-start-style',
|
|
144
|
+
'-webkit-border-start-width',
|
|
145
|
+
'-webkit-box-align',
|
|
146
|
+
'-webkit-box-direction',
|
|
147
|
+
'-webkit-box-flex-group',
|
|
148
|
+
'-webkit-box-flex',
|
|
149
|
+
'-webkit-box-lines',
|
|
150
|
+
'-webkit-box-ordinal-group',
|
|
151
|
+
'-webkit-box-orient',
|
|
152
|
+
'-webkit-box-pack',
|
|
153
|
+
'-webkit-column-break-after',
|
|
154
|
+
'-webkit-column-break-before',
|
|
155
|
+
'-webkit-column-break-inside',
|
|
156
|
+
'-webkit-font-feature-settings',
|
|
157
|
+
'-webkit-hyphenate-character',
|
|
158
|
+
'-webkit-initial-letter',
|
|
159
|
+
'-webkit-margin-end',
|
|
160
|
+
'-webkit-margin-start',
|
|
161
|
+
'-webkit-padding-after',
|
|
162
|
+
'-webkit-padding-before',
|
|
163
|
+
'-webkit-padding-end',
|
|
164
|
+
'-webkit-padding-start',
|
|
165
|
+
'-webkit-fill-available',
|
|
166
|
+
':-webkit-animating-full-screen-transition',
|
|
167
|
+
':-webkit-any',
|
|
168
|
+
':-webkit-any-link',
|
|
169
|
+
':-webkit-autofill',
|
|
170
|
+
':-webkit-autofill-strong-password',
|
|
171
|
+
':-webkit-drag',
|
|
172
|
+
':-webkit-full-page-media',
|
|
173
|
+
':-webkit-full-screen*',
|
|
174
|
+
':-webkit-full-screen-ancestor',
|
|
175
|
+
':-webkit-full-screen-document',
|
|
176
|
+
':-webkit-full-screen-controls-hidden',
|
|
177
|
+
'::-webkit-file-upload-button*',
|
|
178
|
+
'::-webkit-inner-spin-button',
|
|
179
|
+
'::-webkit-input-placeholder',
|
|
180
|
+
'::-webkit-meter-bar',
|
|
181
|
+
'::-webkit-meter-even-less-good-value',
|
|
182
|
+
'::-webkit-meter-inner-element',
|
|
183
|
+
'::-webkit-meter-optimum-value',
|
|
184
|
+
'::-webkit-meter-suboptimum-value',
|
|
185
|
+
'::-webkit-progress-bar',
|
|
186
|
+
'::-webkit-progress-inner-element',
|
|
187
|
+
'::-webkit-progress-value',
|
|
188
|
+
'::-webkit-search-cancel-button',
|
|
189
|
+
'::-webkit-search-results-button',
|
|
190
|
+
'::-webkit-slider-runnable-track',
|
|
191
|
+
'::-webkit-slider-thumb',
|
|
192
|
+
'-webkit-animation',
|
|
193
|
+
'-webkit-device-pixel-ratio',
|
|
194
|
+
'-webkit-transform-2d',
|
|
195
|
+
'-webkit-transform-3d',
|
|
196
|
+
'-webkit-transition',
|
|
197
|
+
'::-webkit-scrollbar',
|
|
198
|
+
'::-webkit-scrollbar-button',
|
|
199
|
+
'::-webkit-scrollbar',
|
|
200
|
+
'::-webkit-scrollbar-thumb',
|
|
201
|
+
'::-webkit-scrollbar-track',
|
|
202
|
+
'::-webkit-scrollbar-track-piece',
|
|
203
|
+
'::-webkit-scrollbar:vertical',
|
|
204
|
+
'::-webkit-scrollbar-corner ',
|
|
205
|
+
'::-webkit-resizer',
|
|
206
|
+
':vertical',
|
|
207
|
+
':horizontal',
|
|
208
|
+
]);
|
|
209
|
+
// https://developer.mozilla.org/en-US/docs/Web/CSS/Mozilla_Extensions
|
|
210
|
+
const mozExtensions = new Set([
|
|
211
|
+
'-moz-box-align',
|
|
212
|
+
'-moz-box-direction',
|
|
213
|
+
'-moz-box-flex',
|
|
214
|
+
'-moz-box-ordinal-group',
|
|
215
|
+
'-moz-box-orient',
|
|
216
|
+
'-moz-box-pack',
|
|
217
|
+
'-moz-float-edge',
|
|
218
|
+
'-moz-force-broken-image-icon',
|
|
219
|
+
'-moz-image-region',
|
|
220
|
+
'-moz-orient',
|
|
221
|
+
'-moz-osx-font-smoothing',
|
|
222
|
+
'-moz-user-focus',
|
|
223
|
+
'-moz-user-input',
|
|
224
|
+
'-moz-user-modify',
|
|
225
|
+
'-moz-animation',
|
|
226
|
+
'-moz-animation-delay',
|
|
227
|
+
'-moz-animation-direction',
|
|
228
|
+
'-moz-animation-duration',
|
|
229
|
+
'-moz-animation-fill-mode',
|
|
230
|
+
'-moz-animation-iteration-count',
|
|
231
|
+
'-moz-animation-name',
|
|
232
|
+
'-moz-animation-play-state',
|
|
233
|
+
'-moz-animation-timing-function',
|
|
234
|
+
'-moz-appearance',
|
|
235
|
+
'-moz-backface-visibility',
|
|
236
|
+
'-moz-background-clip',
|
|
237
|
+
'-moz-background-origin',
|
|
238
|
+
'-moz-background-inline-policy',
|
|
239
|
+
'-moz-background-size',
|
|
240
|
+
'-moz-border-end',
|
|
241
|
+
'-moz-border-end-color',
|
|
242
|
+
'-moz-border-end-style',
|
|
243
|
+
'-moz-border-end-width',
|
|
244
|
+
'-moz-border-image',
|
|
245
|
+
'-moz-border-start',
|
|
246
|
+
'-moz-border-start-color',
|
|
247
|
+
'-moz-border-start-style',
|
|
248
|
+
'-moz-border-start-width',
|
|
249
|
+
'-moz-box-sizing',
|
|
250
|
+
'clip-path',
|
|
251
|
+
'-moz-column-count',
|
|
252
|
+
'-moz-column-fill',
|
|
253
|
+
'-moz-column-gap',
|
|
254
|
+
'-moz-column-width',
|
|
255
|
+
'-moz-column-rule',
|
|
256
|
+
'-moz-column-rule-width',
|
|
257
|
+
'-moz-column-rule-style',
|
|
258
|
+
'-moz-column-rule-color',
|
|
259
|
+
'filter',
|
|
260
|
+
'-moz-font-feature-settings',
|
|
261
|
+
'-moz-font-language-override',
|
|
262
|
+
'-moz-hyphens',
|
|
263
|
+
'-moz-margin-end',
|
|
264
|
+
'-moz-margin-start',
|
|
265
|
+
'mask',
|
|
266
|
+
'-moz-opacity',
|
|
267
|
+
'-moz-outline',
|
|
268
|
+
'-moz-outline-color',
|
|
269
|
+
'-moz-outline-offset',
|
|
270
|
+
'-moz-outline-style',
|
|
271
|
+
'-moz-outline-width',
|
|
272
|
+
'-moz-padding-end',
|
|
273
|
+
'-moz-padding-start',
|
|
274
|
+
'-moz-perspective',
|
|
275
|
+
'-moz-perspective-origin',
|
|
276
|
+
'pointer-events',
|
|
277
|
+
'-moz-tab-size',
|
|
278
|
+
'-moz-text-align-last',
|
|
279
|
+
'-moz-text-decoration-color',
|
|
280
|
+
'-moz-text-decoration-line',
|
|
281
|
+
'-moz-text-decoration-style',
|
|
282
|
+
'-moz-text-size-adjust',
|
|
283
|
+
'-moz-transform',
|
|
284
|
+
'-moz-transform-origin',
|
|
285
|
+
'-moz-transform-style',
|
|
286
|
+
'-moz-transition',
|
|
287
|
+
'-moz-transition-delay',
|
|
288
|
+
'-moz-transition-duration',
|
|
289
|
+
'-moz-transition-property',
|
|
290
|
+
'-moz-transition-timing-function',
|
|
291
|
+
'-moz-user-select',
|
|
292
|
+
'-moz-initial',
|
|
293
|
+
'-moz-appearance',
|
|
294
|
+
'-moz-linear-gradient',
|
|
295
|
+
'-moz-radial-gradient',
|
|
296
|
+
'-moz-element',
|
|
297
|
+
'-moz-image-rect',
|
|
298
|
+
'::-moz-anonymous-block',
|
|
299
|
+
'::-moz-anonymous-positioned-block',
|
|
300
|
+
':-moz-any',
|
|
301
|
+
':-moz-any-link',
|
|
302
|
+
':-moz-broken',
|
|
303
|
+
'::-moz-canvas',
|
|
304
|
+
'::-moz-color-swatch',
|
|
305
|
+
'::-moz-cell-content',
|
|
306
|
+
':-moz-drag-over',
|
|
307
|
+
':-moz-first-node',
|
|
308
|
+
'::-moz-focus-inner',
|
|
309
|
+
'::-moz-focus-outer',
|
|
310
|
+
':-moz-full-screen',
|
|
311
|
+
':-moz-full-screen-ancestor',
|
|
312
|
+
':-moz-handler-blocked',
|
|
313
|
+
':-moz-handler-crashed',
|
|
314
|
+
':-moz-handler-disabled',
|
|
315
|
+
'::-moz-inline-table',
|
|
316
|
+
':-moz-last-node',
|
|
317
|
+
'::-moz-list-bullet',
|
|
318
|
+
'::-moz-list-number',
|
|
319
|
+
':-moz-loading',
|
|
320
|
+
':-moz-locale-dir',
|
|
321
|
+
':-moz-locale-dir',
|
|
322
|
+
':-moz-lwtheme',
|
|
323
|
+
':-moz-lwtheme-brighttext',
|
|
324
|
+
':-moz-lwtheme-darktext',
|
|
325
|
+
'::-moz-meter-bar',
|
|
326
|
+
':-moz-native-anonymous',
|
|
327
|
+
':-moz-only-whitespace',
|
|
328
|
+
'::-moz-pagebreak',
|
|
329
|
+
'::-moz-pagecontent',
|
|
330
|
+
':-moz-placeholder',
|
|
331
|
+
'::-moz-placeholder',
|
|
332
|
+
'::-moz-progress-bar',
|
|
333
|
+
'::-moz-range-progress',
|
|
334
|
+
'::-moz-range-thumb',
|
|
335
|
+
'::-moz-range-track',
|
|
336
|
+
':-moz-read-only',
|
|
337
|
+
':-moz-read-write',
|
|
338
|
+
'::-moz-scrolled-canvas',
|
|
339
|
+
'::-moz-scrolled-content',
|
|
340
|
+
'::-moz-selection',
|
|
341
|
+
':-moz-submit-invalid',
|
|
342
|
+
':-moz-suppressed',
|
|
343
|
+
'::-moz-svg-foreign-content',
|
|
344
|
+
'::-moz-table',
|
|
345
|
+
'::-moz-table-cell',
|
|
346
|
+
'::-moz-table-column',
|
|
347
|
+
'::-moz-table-column-group',
|
|
348
|
+
'::-moz-table-outer',
|
|
349
|
+
'::-moz-table-row',
|
|
350
|
+
'::-moz-table-row-group',
|
|
351
|
+
':-moz-ui-invalid',
|
|
352
|
+
':-moz-ui-valid',
|
|
353
|
+
':-moz-user-disabled',
|
|
354
|
+
'::-moz-viewport',
|
|
355
|
+
'::-moz-viewport-scroll',
|
|
356
|
+
':-moz-window-inactive',
|
|
357
|
+
'-moz-device-pixel-ratio',
|
|
358
|
+
'-moz-os-version',
|
|
359
|
+
'-moz-touch-enabled',
|
|
360
|
+
'-moz-windows-glass',
|
|
361
|
+
'-moz-alt-content'
|
|
362
|
+
]);
|
|
18
363
|
function isLength(dimension) {
|
|
19
364
|
return 'unit' in dimension && dimensionUnits.has(dimension.unit.toLowerCase());
|
|
20
365
|
}
|
|
@@ -89,7 +434,7 @@ function isColor(token) {
|
|
|
89
434
|
return false;
|
|
90
435
|
}
|
|
91
436
|
}
|
|
92
|
-
if (children[i].typ == EnumToken.FunctionTokenType && !
|
|
437
|
+
if (children[i].typ == EnumToken.FunctionTokenType && !mathFuncs.includes(children[i].val)) {
|
|
93
438
|
return false;
|
|
94
439
|
}
|
|
95
440
|
}
|
|
@@ -184,7 +529,7 @@ function isColor(token) {
|
|
|
184
529
|
}
|
|
185
530
|
continue;
|
|
186
531
|
}
|
|
187
|
-
if (v.typ == EnumToken.FunctionTokenType && (v.val
|
|
532
|
+
if (v.typ == EnumToken.FunctionTokenType && (mathFuncs.includes(v.val) || v.val == 'var' || colorsFunc.includes(v.val))) {
|
|
188
533
|
continue;
|
|
189
534
|
}
|
|
190
535
|
if (![EnumToken.ColorTokenType, EnumToken.IdenTokenType, EnumToken.NumberTokenType, EnumToken.AngleTokenType, EnumToken.PercentageTokenType, EnumToken.CommaTokenType, EnumToken.WhitespaceTokenType, EnumToken.LiteralTokenType].includes(v.typ)) {
|
|
@@ -207,7 +552,7 @@ function isNonAscii(codepoint) {
|
|
|
207
552
|
}
|
|
208
553
|
function isIdentStart(codepoint) {
|
|
209
554
|
// _
|
|
210
|
-
return codepoint == 0x5f || isLetter(codepoint) || isNonAscii(codepoint);
|
|
555
|
+
return codepoint == 0x5f || isLetter(codepoint) || isNonAscii(codepoint) || codepoint == REVERSE_SOLIDUS;
|
|
211
556
|
}
|
|
212
557
|
function isDigit(codepoint) {
|
|
213
558
|
return codepoint >= 0x30 && codepoint <= 0x39;
|
|
@@ -238,6 +583,19 @@ function isIdent(name) {
|
|
|
238
583
|
if (!isIdentStart(codepoint)) {
|
|
239
584
|
return false;
|
|
240
585
|
}
|
|
586
|
+
if (codepoint == REVERSE_SOLIDUS) {
|
|
587
|
+
codepoint = name.codePointAt(i + 1);
|
|
588
|
+
if (!isIdentCodepoint(codepoint)) {
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
i += String.fromCodePoint(codepoint).length;
|
|
592
|
+
if (i < j) {
|
|
593
|
+
codepoint = name.codePointAt(i);
|
|
594
|
+
if (!isIdentCodepoint(codepoint)) {
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
241
599
|
while (i < j) {
|
|
242
600
|
i += codepoint < 0x80 ? 1 : String.fromCodePoint(codepoint).length;
|
|
243
601
|
codepoint = name.charCodeAt(i);
|
|
@@ -453,4 +811,4 @@ function isWhiteSpace(codepoint) {
|
|
|
453
811
|
codepoint == 0xa || codepoint == 0xc || codepoint == 0xd;
|
|
454
812
|
}
|
|
455
813
|
|
|
456
|
-
export { isAngle, isAtKeyword, isColor, isColorspace, isDigit, isDimension, isFlex, isFrequency, isFunction, isHash, isHexColor, isHueInterpolationMethod, isIdent, isIdentCodepoint, isIdentStart, isLength, isNewLine, isNonPrintable, isNumber, isPercentage, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, parseDimension };
|
|
814
|
+
export { colorFontTech, fontFeaturesTech, fontFormat, isAngle, isAtKeyword, isColor, isColorspace, isDigit, isDimension, isFlex, isFrequency, isFunction, isHash, isHexColor, isHueInterpolationMethod, isIdent, isIdentCodepoint, isIdentStart, isLength, isNewLine, isNonPrintable, isNumber, isPercentage, isPolarColorspace, isPseudo, isRectangularOrthogonalColorspace, isResolution, isTime, isWhiteSpace, mathFuncs, mediaTypes, mozExtensions, parseDimension, webkitExtensions, webkitPseudoAliasMap };
|