@tbela99/css-parser 2.2.0 → 2.3.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 +24 -0
- package/dist/{lib/ast → ast}/arena-node.js +1 -1
- package/dist/{lib/ast → ast}/arena.js +1 -1
- package/dist/{lib/ast → ast}/cache.js +39 -23
- package/dist/{lib/ast → ast}/features/calc.js +1 -1
- package/dist/{lib/ast → ast}/features/if.js +1 -1
- package/dist/ast/features/index.d.ts +7 -0
- package/dist/{lib/ast → ast}/features/index.js +1 -1
- package/dist/{lib/ast → ast}/features/inlinecssvariables.js +1 -1
- package/dist/{lib/ast → ast}/features/mixin.js +1 -1
- package/dist/{lib/ast → ast}/features/prefix.js +1 -1
- package/dist/{lib/ast → ast}/features/shorthand.js +1 -1
- package/dist/{lib/ast → ast}/features/transform.js +1 -1
- package/dist/{lib/ast → ast}/features/type.js +1 -1
- package/dist/{lib/ast → ast}/math/expression.js +1 -1
- package/dist/{lib/ast → ast}/math/math.js +1 -1
- package/dist/{lib/ast → ast}/minify.js +1 -1
- package/dist/{lib/ast → ast}/mixins/custom-function.js +1 -1
- package/dist/{lib/ast → ast}/mixins/utils.js +1 -1
- package/dist/{lib/ast → ast}/mixins/variables.js +1 -1
- package/dist/{lib/ast → ast}/strings.js +5 -1
- package/dist/{lib/ast → ast}/transform/compute.js +1 -1
- package/dist/{lib/ast → ast}/transform/matrix.js +1 -1
- package/dist/{lib/ast → ast}/transform/minify.js +1 -1
- package/dist/{lib/ast → ast}/transform/perspective.js +1 -1
- package/dist/{lib/ast → ast}/transform/rotate.js +1 -1
- package/dist/{lib/ast → ast}/transform/scale.js +1 -1
- package/dist/{lib/ast → ast}/transform/skew.js +1 -1
- package/dist/{lib/ast → ast}/transform/translate.js +1 -1
- package/dist/{lib/ast → ast}/transform/utils.js +1 -1
- package/dist/{lib/ast → ast}/types.js +1 -1
- package/dist/{lib/ast → ast}/walk.js +1 -1
- package/dist/data/properties.json.js +1 -1
- package/dist/data/validation.json.js +26 -20
- package/dist/{lib/fs → fs}/resolve.js +1 -1
- package/dist/index-umd-web.js +2755 -126
- package/dist/index.d.ts +6 -2
- package/dist/node.js +21 -21
- package/dist/{lib/parser → parser}/declaration/list.js +1 -1
- package/dist/{lib/parser → parser}/declaration/map.js +1 -1
- package/dist/{lib/parser → parser}/declaration/set.js +1 -1
- package/dist/{lib/parser → parser}/input.js +1 -1
- package/dist/{lib/parser → parser}/linesmap.js +1 -1
- package/dist/{lib/parser → parser}/parse.js +20 -21
- package/dist/{lib/parser → parser}/source.js +2 -2
- package/dist/{lib/parser → parser}/tokenize.js +1 -1
- package/dist/{lib/parser → parser}/utils/angle.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-container.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-font-feature-values.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-generic.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-import.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-media.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-support.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule-when-else.js +1 -1
- package/dist/{lib/parser → parser}/utils/at-rule.js +1 -1
- package/dist/{lib/parser → parser}/utils/base64.js +1 -1
- package/dist/{lib/parser → parser}/utils/cache.js +1 -1
- package/dist/{lib/parser → parser}/utils/canonical.js +1 -1
- package/dist/{lib/parser → parser}/utils/codes.js +1 -1
- package/dist/{lib/parser → parser}/utils/config.js +2 -2
- package/dist/{lib/parser → parser}/utils/declaration.js +1 -1
- package/dist/{lib/parser → parser}/utils/eq.js +1 -1
- package/dist/{lib/parser → parser}/utils/hash.js +1 -1
- package/dist/{lib/parser → parser}/utils/selector.js +38 -28
- package/dist/{lib/parser → parser}/utils/text.js +1 -1
- package/dist/{lib/parser → parser}/utils/token.js +1 -1
- package/dist/{lib/parser → parser}/utils/type.js +1 -1
- package/dist/{lib/printer/sourcemap → printer}/lib/codec.js +1 -1
- package/dist/{lib/printer → printer}/render.js +184 -23
- package/dist/{lib/printer → printer}/result.js +1 -1
- package/dist/{lib/printer/sourcemap → printer}/sourcemap.js +3 -2
- package/dist/{lib/printer → printer}/writer.js +1 -1
- package/dist/{lib/syntax → syntax}/color/a98rgb.js +1 -1
- package/dist/{lib/syntax → syntax}/color/alpha.js +1 -1
- package/dist/{lib/syntax → syntax}/color/cmyk.js +1 -1
- package/dist/{lib/syntax → syntax}/color/color-mix.js +1 -1
- package/dist/{lib/syntax → syntax}/color/color.js +1 -1
- package/dist/{lib/syntax → syntax}/color/hex.js +1 -1
- package/dist/{lib/syntax → syntax}/color/hsl.js +1 -1
- package/dist/{lib/syntax → syntax}/color/hwb.js +1 -1
- package/dist/{lib/syntax → syntax}/color/lab.js +1 -1
- package/dist/{lib/syntax → syntax}/color/lch.js +1 -1
- package/dist/{lib/syntax → syntax}/color/oklab.js +1 -1
- package/dist/{lib/syntax → syntax}/color/oklch.js +1 -1
- package/dist/{lib/syntax → syntax}/color/p3.js +1 -1
- package/dist/{lib/syntax → syntax}/color/prophotorgb.js +1 -1
- package/dist/{lib/syntax → syntax}/color/rec2020.js +1 -1
- package/dist/{lib/syntax → syntax}/color/relative-color.js +1 -1
- package/dist/{lib/syntax → syntax}/color/rgb.js +1 -1
- package/dist/{lib/syntax → syntax}/color/srgb.js +1 -1
- package/dist/{lib/syntax → syntax}/color/utils/color-type.js +1 -1
- package/dist/{lib/syntax → syntax}/color/utils/colorspace.js +1 -1
- package/dist/{lib/syntax → syntax}/color/utils/components.js +1 -1
- package/dist/{lib/syntax → syntax}/color/utils/distance.js +1 -1
- package/dist/{lib/syntax → syntax}/color/utils/make-color.js +1 -1
- package/dist/{lib/syntax → syntax}/color/utils/matrix.js +1 -1
- package/dist/{lib/syntax → syntax}/color/xyz.js +1 -1
- package/dist/{lib/syntax → syntax}/color/xyzd50.js +1 -1
- package/dist/{lib/syntax → syntax}/constants.js +2 -2
- package/dist/{lib/syntax → syntax}/syntax.js +1 -1
- package/dist/types.js +1 -1
- package/dist/utils/sync.js +3 -3
- package/dist/validation/compiled/builtins.js +32 -0
- package/dist/validation/compiled/runtime.js +705 -0
- package/dist/validation/compiled/syntaxes.js +1620 -0
- package/dist/{lib/validation → validation}/config.js +41 -7
- package/dist/{lib/validation → validation}/first.js +6 -3
- package/dist/{lib/validation → validation}/match.js +87 -14
- package/dist/{lib/validation → validation}/parser/parse.js +1 -1
- package/dist/{lib/validation → validation}/parser/typedef.js +1 -1
- package/dist/{lib/validation → validation}/utils/list.js +1 -1
- package/dist/version.js +2 -2
- package/dist/web.js +23 -23
- package/package.json +4 -2
- package/dist/types.d.ts +0 -21
- package/dist/utils/sync.d.ts +0 -16
- package/dist/version.d.ts +0 -4
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node, deno, bun and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 2.
|
|
5
|
+
Version: 2.3.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { getAngle, convertColor } from '../syntax/color/color.js';
|
|
9
9
|
import { reduceHexValue } from '../syntax/color/hex.js';
|
|
10
10
|
import { EnumToken, ColorType, EnumAstNodeStatus } from '../ast/types.js';
|
|
11
|
-
import { SourceMap } from './sourcemap
|
|
11
|
+
import { SourceMap } from './sourcemap.js';
|
|
12
12
|
import { pseudoElements, anglePrecision, urlTokenMatcher, isFunctionType } from '../syntax/constants.js';
|
|
13
13
|
import { minifyNumber, toPrecisionAngle, toPrecisionValue, reducegradientBackgroundPosition, reduceConicColorStops, reduceColorStops, parseColor, isWhiteSpace } from '../syntax/syntax.js';
|
|
14
14
|
import { equalsIgnoreCase } from '../parser/utils/text.js';
|
|
@@ -228,6 +228,10 @@ function resolveRenderOptions(options) {
|
|
|
228
228
|
*
|
|
229
229
|
* @internal
|
|
230
230
|
*/
|
|
231
|
+
/**
|
|
232
|
+
* `CSS_PARSER_CHECK_SIZE`: the computed sizes are checked against the rendered sizes (tests)
|
|
233
|
+
*/
|
|
234
|
+
const checkSize = globalThis.process?.env?.CSS_PARSER_CHECK_SIZE != null;
|
|
231
235
|
class NodeRenderer {
|
|
232
236
|
/**
|
|
233
237
|
* An instance is kept alive: the hidden class of the instances would otherwise be collected by a full garbage
|
|
@@ -303,11 +307,17 @@ class NodeRenderer {
|
|
|
303
307
|
if (!this.direct) {
|
|
304
308
|
return RenderResult.codeLength(doRender(arena, node, this.options, null, this.cache.memo));
|
|
305
309
|
}
|
|
306
|
-
// the
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
310
|
+
// the size is computed from the sizes of the parts: the node is not rendered
|
|
311
|
+
const size = nodeSize(arena, node, this.resolved, this.reducer, this.cache, 0) >> 1;
|
|
312
|
+
if (checkSize) {
|
|
313
|
+
const writer = this.writer;
|
|
314
|
+
writer.reset();
|
|
315
|
+
renderAstNode(arena, node, this.resolved, null, this.location, null, this.errors, this.reducer, this.cache, writer, 0, this.indents);
|
|
316
|
+
if (size !== writer.codeLength) {
|
|
317
|
+
throw new Error(`computed size of node ${node} (${size}) differs from its rendered size (${writer.codeLength})`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return size;
|
|
311
321
|
}
|
|
312
322
|
}
|
|
313
323
|
/**
|
|
@@ -943,15 +953,38 @@ function renderDeclaration(arena, node, options, cache, reducer) {
|
|
|
943
953
|
return rendered;
|
|
944
954
|
}
|
|
945
955
|
/**
|
|
946
|
-
*
|
|
947
|
-
* tokens) are rendered and encoded once per render: the bytes written first are copied
|
|
956
|
+
* the rendered value of a declaration (without the name): rendered once per structure, see {@link RenderMemo}
|
|
948
957
|
* @param arena
|
|
949
958
|
* @param node declaration
|
|
950
959
|
* @param options
|
|
951
960
|
* @param cache
|
|
952
961
|
* @param reducer
|
|
953
|
-
* @param
|
|
962
|
+
* @param slot the memo slot of the declaration when it has been looked up, -1 otherwise
|
|
954
963
|
*/
|
|
964
|
+
function declarationValue(arena, node, options, cache, reducer, slot = -1) {
|
|
965
|
+
const memo = getRenderMemo(cache, options);
|
|
966
|
+
if (memo !== null) {
|
|
967
|
+
if (slot === -1) {
|
|
968
|
+
// the name is part of the key
|
|
969
|
+
slot = memo.declarations.list(arena, arena.firstToken[node], arena.name[node]);
|
|
970
|
+
}
|
|
971
|
+
const value = memo.values[slot];
|
|
972
|
+
if (value !== undefined) {
|
|
973
|
+
return value;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
if (options.minifyValues && isUnminifiedDeclaration(arena, node)) {
|
|
977
|
+
// override options to avoid minifying values for custom properties
|
|
978
|
+
options = { ...options, minifyValues: false };
|
|
979
|
+
// override the reducer
|
|
980
|
+
reducer = createReducer(arena, options, cache);
|
|
981
|
+
}
|
|
982
|
+
const value = renderDeclarationValue(arena, node, options.minifyValues, reducer).trimEnd();
|
|
983
|
+
if (memo !== null) {
|
|
984
|
+
memo.values[slot] = value;
|
|
985
|
+
}
|
|
986
|
+
return value;
|
|
987
|
+
}
|
|
955
988
|
function writeDeclaration(arena, node, options, cache, reducer, writer) {
|
|
956
989
|
const memo = getRenderMemo(cache, options);
|
|
957
990
|
let slot = -1;
|
|
@@ -968,19 +1001,7 @@ function writeDeclaration(arena, node, options, cache, reducer, writer) {
|
|
|
968
1001
|
const start = writer.length;
|
|
969
1002
|
const extra = writer.extra;
|
|
970
1003
|
// the rendered value of an identical declaration, rendered to another buffer (see NodeRenderer)
|
|
971
|
-
|
|
972
|
-
if (value === undefined) {
|
|
973
|
-
if (options.minifyValues && isUnminifiedDeclaration(arena, node)) {
|
|
974
|
-
// override options to avoid minifying values for custom properties
|
|
975
|
-
options = { ...options, minifyValues: false };
|
|
976
|
-
// override the reducer
|
|
977
|
-
reducer = createReducer(arena, options, cache);
|
|
978
|
-
}
|
|
979
|
-
value = renderDeclarationValue(arena, node, options.minifyValues, reducer).trimEnd();
|
|
980
|
-
if (memo !== null) {
|
|
981
|
-
memo.values[slot] = value;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
1004
|
+
const value = declarationValue(arena, node, options, cache, reducer, slot);
|
|
984
1005
|
// the parts are written directly: `name`, `:`, `indent`, `value`. the name is copied from the string table
|
|
985
1006
|
writeString(arena, arena.name[node], writer);
|
|
986
1007
|
writer.writeByte(0x3a);
|
|
@@ -992,6 +1013,146 @@ function writeDeclaration(arena, node, options, cache, reducer, writer) {
|
|
|
992
1013
|
memo.locate(slot, writer, start, extra);
|
|
993
1014
|
}
|
|
994
1015
|
}
|
|
1016
|
+
/**
|
|
1017
|
+
* the size of a rendered node, computed without rendering it: the declarations are measured from their rendered values
|
|
1018
|
+
* (rendered once per structure, see {@link declarationValue}), the layout follows {@link renderAstNode} (no source
|
|
1019
|
+
* map). the result is `size * 2 + 1` when the output ends with a semicolon, `size * 2` otherwise (0 when the node
|
|
1020
|
+
* renders nothing): no object is allocated
|
|
1021
|
+
* @param arena
|
|
1022
|
+
* @param data
|
|
1023
|
+
* @param options
|
|
1024
|
+
* @param reducer
|
|
1025
|
+
* @param cache
|
|
1026
|
+
* @param level
|
|
1027
|
+
*/
|
|
1028
|
+
function nodeSize(arena, data, options, reducer, cache, level) {
|
|
1029
|
+
const optIndent = options.indent;
|
|
1030
|
+
const newLine = options.newLine;
|
|
1031
|
+
const indentLength = optIndent.length * level;
|
|
1032
|
+
const typ = arena.dataTypes[data];
|
|
1033
|
+
switch (typ) {
|
|
1034
|
+
case EnumToken.DeclarationNodeType: {
|
|
1035
|
+
const value = declarationValue(arena, data, options, cache, reducer);
|
|
1036
|
+
return ((arena.stringLength(arena.name[data]) + 1 + optIndent.length + value.length) * 2 +
|
|
1037
|
+
(value.endsWith(";") ? 1 : 0));
|
|
1038
|
+
}
|
|
1039
|
+
case EnumToken.CommentNodeType:
|
|
1040
|
+
case EnumToken.CDOCOMMNodeType: {
|
|
1041
|
+
const id = arena.stringValue[data];
|
|
1042
|
+
if (arena.stringStartsWith(id, "/*# sourceMappingURL=")) {
|
|
1043
|
+
return 0;
|
|
1044
|
+
}
|
|
1045
|
+
if (!options.removeComments || (options.preserveLicense && arena.stringStartsWith(id, "/*!"))) {
|
|
1046
|
+
const length = arena.stringLength(id);
|
|
1047
|
+
return length * 2 + (length > 0 && arena.stringCodeAt(id, length - 1) === 0x3b ? 1 : 0);
|
|
1048
|
+
}
|
|
1049
|
+
return 0;
|
|
1050
|
+
}
|
|
1051
|
+
case EnumToken.StyleSheetNodeType: {
|
|
1052
|
+
let size = 0;
|
|
1053
|
+
let empty = true;
|
|
1054
|
+
let last = 0;
|
|
1055
|
+
for (let node = arena.firstChild[data]; node !== 0; node = arena.nextSibling[node]) {
|
|
1056
|
+
const child = nodeSize(arena, node, options, reducer, cache, level);
|
|
1057
|
+
if (child >= 2) {
|
|
1058
|
+
if (!empty) {
|
|
1059
|
+
size += newLine.length;
|
|
1060
|
+
}
|
|
1061
|
+
size += child >> 1;
|
|
1062
|
+
empty = false;
|
|
1063
|
+
last = child & 1;
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
return size * 2 + last;
|
|
1067
|
+
}
|
|
1068
|
+
case EnumToken.AtRuleNodeType:
|
|
1069
|
+
case EnumToken.RuleNodeType:
|
|
1070
|
+
case EnumToken.KeyframesRuleNodeType:
|
|
1071
|
+
case EnumToken.KeyframesAtRuleNodeType: {
|
|
1072
|
+
const isAtRule = typ === EnumToken.AtRuleNodeType || typ === EnumToken.KeyframesAtRuleNodeType;
|
|
1073
|
+
const nameId = arena.name[data];
|
|
1074
|
+
const valueId = arena.stringValue[data];
|
|
1075
|
+
let size = 0;
|
|
1076
|
+
if (indentLength > 0 && newLine !== "") {
|
|
1077
|
+
size += newLine.length;
|
|
1078
|
+
}
|
|
1079
|
+
size += indentLength;
|
|
1080
|
+
if (isAtRule) {
|
|
1081
|
+
size += 1 + arena.stringLength(nameId);
|
|
1082
|
+
if (arena.stringLength(valueId) > 0) {
|
|
1083
|
+
size += (optIndent || " ").length + arena.stringLength(valueId);
|
|
1084
|
+
}
|
|
1085
|
+
if (!(arena.flags[data] & EnumAstNodeStatus.HasChildren)) {
|
|
1086
|
+
return (size + 1) * 2 + 1;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
size += arena.stringLength(nameId);
|
|
1091
|
+
}
|
|
1092
|
+
size += optIndent.length + 1;
|
|
1093
|
+
const indentSubLength = optIndent.length * (level + 1);
|
|
1094
|
+
let body = 0;
|
|
1095
|
+
let semicolon = false;
|
|
1096
|
+
for (let node = arena.firstChild[data]; node !== 0; node = arena.nextSibling[node]) {
|
|
1097
|
+
const nodeType = arena.dataTypes[node];
|
|
1098
|
+
if (nodeType === EnumToken.DeclarationNodeType) {
|
|
1099
|
+
body +=
|
|
1100
|
+
(semicolon ? 1 : 0) +
|
|
1101
|
+
newLine.length +
|
|
1102
|
+
indentSubLength +
|
|
1103
|
+
(nodeSize(arena, node, options, reducer, cache, level + 1) >> 1);
|
|
1104
|
+
semicolon = true;
|
|
1105
|
+
}
|
|
1106
|
+
else if (nodeType === EnumToken.CommentNodeType) {
|
|
1107
|
+
const commentId = arena.stringValue[node];
|
|
1108
|
+
if (options.removeComments && (!options.preserveLicense || !arena.stringStartsWith(commentId, "/*!"))) {
|
|
1109
|
+
continue;
|
|
1110
|
+
}
|
|
1111
|
+
const length = arena.stringLength(commentId);
|
|
1112
|
+
if (length > 0) {
|
|
1113
|
+
body += (semicolon ? 1 : 0) + newLine.length + indentSubLength + length;
|
|
1114
|
+
// a trailing semicolon is removed: it is written before the next node
|
|
1115
|
+
semicolon = arena.stringCodeAt(commentId, length - 1) === 0x3b;
|
|
1116
|
+
if (semicolon) {
|
|
1117
|
+
body--;
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
else {
|
|
1122
|
+
const child = nodeSize(arena, node, options, reducer, cache, level + 1);
|
|
1123
|
+
if (child >= 2) {
|
|
1124
|
+
body += (semicolon ? 1 : 0) + (child >> 1);
|
|
1125
|
+
switch (nodeType) {
|
|
1126
|
+
case EnumToken.AtRuleNodeType:
|
|
1127
|
+
case EnumToken.KeyframesAtRuleNodeType:
|
|
1128
|
+
semicolon = !(arena.flags[node] & EnumAstNodeStatus.HasChildren);
|
|
1129
|
+
break;
|
|
1130
|
+
case EnumToken.RuleNodeType:
|
|
1131
|
+
case EnumToken.KeyframesRuleNodeType:
|
|
1132
|
+
semicolon = false;
|
|
1133
|
+
break;
|
|
1134
|
+
default:
|
|
1135
|
+
semicolon = (child & 1) === 1;
|
|
1136
|
+
}
|
|
1137
|
+
if (semicolon) {
|
|
1138
|
+
body--;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
if (options.removeEmpty &&
|
|
1144
|
+
body === 0 &&
|
|
1145
|
+
!(typ === EnumToken.AtRuleNodeType &&
|
|
1146
|
+
(arena.stringEquals(nameId, "apply") ||
|
|
1147
|
+
arena.stringEquals(nameId, "mixin") ||
|
|
1148
|
+
arena.stringEquals(nameId, "function")))) {
|
|
1149
|
+
return 0;
|
|
1150
|
+
}
|
|
1151
|
+
return (size + body + newLine.length + indentLength + 1) * 2;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return 0;
|
|
1155
|
+
}
|
|
995
1156
|
/**
|
|
996
1157
|
* render the value tokens of a declaration with the reducer. with minifyValues, the whitespace that is not needed is
|
|
997
1158
|
* skipped like {@link filterValues} does, without copying the tokens into an array: the whitespace before
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node, deno, bun and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 2.
|
|
5
|
+
Version: 2.3.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
|
-
import { toBase64 } from '
|
|
8
|
+
import { toBase64 } from '../parser/utils/base64.js';
|
|
9
9
|
import { decode, encode } from './lib/codec.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -116,6 +116,7 @@ class SourceMap {
|
|
|
116
116
|
this.sourcesContent = sourcemaps.sourcesContent?.slice() ?? [];
|
|
117
117
|
const decodedMappings = sourcemaps.mappings
|
|
118
118
|
.split(";")
|
|
119
|
+
// @ts-ignore
|
|
119
120
|
.map((mapping) => mapping.split(",").map((mapping) => decode(mapping)));
|
|
120
121
|
this.line = decodedMappings.length - 1;
|
|
121
122
|
for (let index = 0; index < decodedMappings.length; index++) {
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node, deno, bun and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 2.
|
|
5
|
+
Version: 2.3.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { EnumToken } from '../ast/types.js';
|
|
9
|
-
import config from '
|
|
9
|
+
import config from '../data/validation.json.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Used by the validation parser
|
package/dist/types.js
CHANGED
package/dist/utils/sync.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node, deno, bun and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version: 2.
|
|
5
|
+
Version: 2.3.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
|
-
import { EnumToken } from '../
|
|
9
|
-
import { dirname } from '../
|
|
8
|
+
import { EnumToken } from '../ast/types.js';
|
|
9
|
+
import { dirname } from '../fs/resolve.js';
|
|
10
10
|
import { ResponseType } from '../types.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
CSS parser, minifier and validator for node, deno, bun and the browser
|
|
3
|
+
|
|
4
|
+
Author(s): Thierry Bela
|
|
5
|
+
Version: 2.3.0
|
|
6
|
+
License: MIT
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* the types validated by the code of matchProperty() (src/validation/match.ts), before their definition (if any): the
|
|
10
|
+
* compiled matchers call matchProperty() for them (see leaf() in ./runtime.ts). the other types are compiled from
|
|
11
|
+
* their definition. keep in sync with the switch of matchProperty() and with its calc() types
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* the built in types that read the whitespace or the tokens after the value being matched: the compiled matchers
|
|
15
|
+
* skip the whitespace, the interpreter validates the values of these types
|
|
16
|
+
*/
|
|
17
|
+
const rawTypes = new Set([
|
|
18
|
+
"type-selector",
|
|
19
|
+
"compound-selector",
|
|
20
|
+
"complex-selector",
|
|
21
|
+
"subclass-selector",
|
|
22
|
+
"attribute-selector",
|
|
23
|
+
"complex-selector-unit",
|
|
24
|
+
"pseudo-compound-selector",
|
|
25
|
+
"forgiving-relative-selector-list",
|
|
26
|
+
"complex-selector-list",
|
|
27
|
+
"size-feature",
|
|
28
|
+
"style-feature",
|
|
29
|
+
"css-type",
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
export { rawTypes };
|