@iconify/tools 2.1.0 → 2.1.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/lib/colors/detect.cjs +68 -0
- package/lib/colors/detect.d.ts +15 -0
- package/lib/colors/detect.mjs +64 -0
- package/lib/colors/parse.cjs +31 -7
- package/lib/colors/parse.d.ts +1 -1
- package/lib/colors/parse.mjs +31 -7
- package/lib/colors/validate.cjs +9 -3
- package/lib/colors/validate.d.ts +1 -1
- package/lib/colors/validate.mjs +9 -3
- package/lib/css/parser/error.cjs +1 -1
- package/lib/css/parser/error.mjs +1 -1
- package/lib/css/parser/strings.cjs +10 -2
- package/lib/css/parser/strings.mjs +10 -2
- package/lib/css/parser/tokens.cjs +133 -109
- package/lib/css/parser/tokens.mjs +133 -109
- package/lib/download/api/cache.cjs +28 -21
- package/lib/download/api/cache.mjs +28 -21
- package/lib/download/git/branch.cjs +1 -1
- package/lib/download/git/branch.mjs +1 -1
- package/lib/download/git/hash.cjs +1 -1
- package/lib/download/git/hash.mjs +1 -1
- package/lib/download/git/index.cjs +7 -4
- package/lib/download/git/index.mjs +7 -4
- package/lib/download/git/reset.cjs +1 -2
- package/lib/download/git/reset.mjs +1 -2
- package/lib/download/github/index.cjs +10 -7
- package/lib/download/github/index.mjs +10 -7
- package/lib/download/gitlab/hash.cjs +3 -1
- package/lib/download/gitlab/hash.mjs +3 -1
- package/lib/download/gitlab/index.cjs +9 -6
- package/lib/download/gitlab/index.mjs +9 -6
- package/lib/download/index.cjs +4 -3
- package/lib/download/index.mjs +4 -3
- package/lib/download/npm/index.cjs +12 -8
- package/lib/download/npm/index.mjs +12 -8
- package/lib/download/npm/version.cjs +4 -2
- package/lib/download/npm/version.mjs +4 -2
- package/lib/export/directory.d.ts +1 -1
- package/lib/export/helpers/types-version.cjs +3 -1
- package/lib/export/helpers/types-version.mjs +3 -1
- package/lib/export/icon-package.d.ts +1 -1
- package/lib/export/json-package.cjs +13 -3
- package/lib/export/json-package.d.ts +1 -1
- package/lib/export/json-package.mjs +13 -3
- package/lib/icon-set/index.cjs +20 -8
- package/lib/icon-set/index.d.ts +1 -1
- package/lib/icon-set/index.mjs +20 -8
- package/lib/icon-set/match.d.ts +1 -1
- package/lib/icon-set/merge.d.ts +1 -1
- package/lib/icon-set/modified.d.ts +1 -1
- package/lib/icon-set/props.d.ts +1 -1
- package/lib/icon-set/tags.cjs +97 -0
- package/lib/icon-set/tags.d.ts +22 -0
- package/lib/icon-set/tags.mjs +91 -0
- package/lib/icon-set/types.d.ts +1 -1
- package/lib/import/directory.cjs +4 -1
- package/lib/import/directory.d.ts +1 -1
- package/lib/import/directory.mjs +4 -1
- package/lib/import/figma/index.cjs +5 -2
- package/lib/import/figma/index.d.ts +1 -1
- package/lib/import/figma/index.mjs +5 -2
- package/lib/import/figma/nodes.cjs +6 -2
- package/lib/import/figma/nodes.d.ts +2 -2
- package/lib/import/figma/nodes.mjs +6 -2
- package/lib/import/figma/query.cjs +29 -15
- package/lib/import/figma/query.d.ts +1 -1
- package/lib/import/figma/query.mjs +29 -15
- package/lib/import/figma/types/nodes.d.ts +1 -1
- package/lib/import/figma/types/options.d.ts +1 -1
- package/lib/import/figma/types/result.d.ts +1 -1
- package/lib/index.cjs +6 -3
- package/lib/index.d.ts +3 -1
- package/lib/index.mjs +4 -3
- package/lib/misc/compare-dirs.cjs +3 -1
- package/lib/misc/compare-dirs.mjs +3 -1
- package/lib/misc/exec.cjs +7 -8
- package/lib/misc/exec.mjs +7 -8
- package/lib/misc/keyword.cjs +4 -1
- package/lib/misc/keyword.mjs +4 -1
- package/lib/misc/scan.cjs +3 -1
- package/lib/misc/scan.mjs +3 -1
- package/lib/optimise/flags.cjs +9 -3
- package/lib/optimise/flags.d.ts +1 -1
- package/lib/optimise/flags.mjs +9 -3
- package/lib/optimise/global-style.cjs +10 -3
- package/lib/optimise/global-style.d.ts +1 -1
- package/lib/optimise/global-style.mjs +10 -3
- package/lib/optimise/scale.d.ts +1 -1
- package/lib/optimise/svgo.d.ts +1 -1
- package/lib/svg/analyse.cjs +20 -6
- package/lib/svg/analyse.d.ts +1 -1
- package/lib/svg/analyse.mjs +20 -6
- package/lib/svg/cleanup/attribs.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.cjs +7 -2
- package/lib/svg/cleanup/bad-tags.d.ts +1 -1
- package/lib/svg/cleanup/bad-tags.mjs +7 -2
- package/lib/svg/cleanup/inline-style.cjs +12 -4
- package/lib/svg/cleanup/inline-style.d.ts +1 -1
- package/lib/svg/cleanup/inline-style.mjs +12 -4
- package/lib/svg/cleanup/root-style.d.ts +1 -1
- package/lib/svg/cleanup/root-svg.d.ts +1 -1
- package/lib/svg/cleanup/svgo-style.d.ts +1 -1
- package/lib/svg/cleanup.d.ts +1 -1
- package/lib/svg/data/attributes.cjs +0 -1
- package/lib/svg/data/attributes.mjs +0 -1
- package/lib/svg/index.cjs +12 -3
- package/lib/svg/index.d.ts +2 -2
- package/lib/svg/index.mjs +12 -3
- package/lib/svg/parse-style.cjs +13 -8
- package/lib/svg/parse-style.d.ts +1 -1
- package/lib/svg/parse-style.mjs +13 -8
- package/lib/svg/parse.d.ts +1 -1
- package/package.json +23 -8
- package/lib/types-6360d61e.d.ts +0 -261
|
@@ -47,122 +47,146 @@ function getTokens(css) {
|
|
|
47
47
|
}
|
|
48
48
|
throw css_parser_error.styleParseError("Invalid css rule", css, textQueue[0]?.index);
|
|
49
49
|
};
|
|
50
|
-
findTokens(css, ['"', "'", "/*", "{", "}", ";", "url(", "\\"]).forEach(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
switch (token.token) {
|
|
55
|
-
case "/*": {
|
|
56
|
-
textQueue.push({
|
|
57
|
-
type: "chunk",
|
|
58
|
-
text: css.slice(start, token.index),
|
|
59
|
-
index: start
|
|
60
|
-
});
|
|
61
|
-
start = token.index;
|
|
62
|
-
const end = css.indexOf("*/", start + 2);
|
|
63
|
-
if (end === -1) {
|
|
64
|
-
throw css_parser_error.styleParseError("Missing comment closing statement", css, start);
|
|
65
|
-
}
|
|
66
|
-
start = end + 2;
|
|
67
|
-
break;
|
|
50
|
+
findTokens(css, ['"', "'", "/*", "{", "}", ";", "url(", "\\"]).forEach(
|
|
51
|
+
(token) => {
|
|
52
|
+
if (token.index < start) {
|
|
53
|
+
return;
|
|
68
54
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
55
|
+
switch (token.token) {
|
|
56
|
+
case "/*": {
|
|
57
|
+
textQueue.push({
|
|
58
|
+
type: "chunk",
|
|
59
|
+
text: css.slice(start, token.index),
|
|
60
|
+
index: start
|
|
61
|
+
});
|
|
62
|
+
start = token.index;
|
|
63
|
+
const end = css.indexOf("*/", start + 2);
|
|
64
|
+
if (end === -1) {
|
|
65
|
+
throw css_parser_error.styleParseError(
|
|
66
|
+
"Missing comment closing statement",
|
|
67
|
+
css,
|
|
68
|
+
start
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
start = end + 2;
|
|
72
|
+
break;
|
|
87
73
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
74
|
+
case "\\":
|
|
75
|
+
textQueue.push({
|
|
76
|
+
type: "chunk",
|
|
77
|
+
text: css.slice(start, token.index + 2),
|
|
78
|
+
index: start
|
|
79
|
+
});
|
|
80
|
+
start = token.index + 2;
|
|
81
|
+
break;
|
|
82
|
+
case "url(": {
|
|
83
|
+
textQueue.push({
|
|
84
|
+
type: "chunk",
|
|
85
|
+
text: css.slice(start, token.index),
|
|
86
|
+
index: start
|
|
87
|
+
});
|
|
88
|
+
start = token.index;
|
|
89
|
+
const end = css_parser_strings.findEndOfURL(css, start);
|
|
90
|
+
if (typeof end !== "number") {
|
|
91
|
+
throw end;
|
|
92
|
+
}
|
|
93
|
+
textQueue.push({
|
|
94
|
+
type: "url",
|
|
95
|
+
text: css.slice(start, end),
|
|
96
|
+
index: start
|
|
97
|
+
});
|
|
98
|
+
start = end;
|
|
99
|
+
break;
|
|
107
100
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
throw css_parser_error.styleParseError("Invalid css rule", css, start);
|
|
101
|
+
case '"':
|
|
102
|
+
case "'": {
|
|
103
|
+
textQueue.push({
|
|
104
|
+
type: "chunk",
|
|
105
|
+
text: css.slice(start, token.index),
|
|
106
|
+
index: start
|
|
107
|
+
});
|
|
108
|
+
start = token.index;
|
|
109
|
+
const end = css_parser_strings.findEndOfQuotedString(
|
|
110
|
+
css,
|
|
111
|
+
token.token,
|
|
112
|
+
start
|
|
113
|
+
);
|
|
114
|
+
if (end === null) {
|
|
115
|
+
throw css_parser_error.styleParseError(
|
|
116
|
+
"Missing closing " + token.token,
|
|
117
|
+
css,
|
|
118
|
+
start
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
textQueue.push({
|
|
122
|
+
type: "quoted-string",
|
|
123
|
+
text: css.slice(start, end),
|
|
124
|
+
index: start
|
|
125
|
+
});
|
|
126
|
+
start = end;
|
|
127
|
+
break;
|
|
136
128
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
129
|
+
case ";": {
|
|
130
|
+
textQueue.push({
|
|
131
|
+
type: "chunk",
|
|
132
|
+
text: css.slice(start, token.index),
|
|
133
|
+
index: start
|
|
134
|
+
});
|
|
135
|
+
checkRule(token.token);
|
|
136
|
+
start = token.index + 1;
|
|
137
|
+
textQueue = [];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "{": {
|
|
141
|
+
textQueue.push({
|
|
142
|
+
type: "chunk",
|
|
143
|
+
text: css.slice(start, token.index),
|
|
144
|
+
index: start
|
|
145
|
+
});
|
|
146
|
+
const item = css_parser_text.textTokensToSelector(textQueue);
|
|
147
|
+
if (!item) {
|
|
148
|
+
throw css_parser_error.styleParseError(
|
|
149
|
+
"Invalid css rule",
|
|
150
|
+
css,
|
|
151
|
+
start
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
items.push(item);
|
|
155
|
+
start = token.index + 1;
|
|
156
|
+
textQueue = [];
|
|
157
|
+
depth++;
|
|
158
|
+
break;
|
|
156
159
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
case "}": {
|
|
161
|
+
textQueue.push({
|
|
162
|
+
type: "chunk",
|
|
163
|
+
text: css.slice(start, token.index),
|
|
164
|
+
index: start
|
|
165
|
+
});
|
|
166
|
+
checkRule("");
|
|
167
|
+
items.push({
|
|
168
|
+
type: "close",
|
|
169
|
+
index: token.index
|
|
170
|
+
});
|
|
171
|
+
if (!depth) {
|
|
172
|
+
throw css_parser_error.styleParseError(
|
|
173
|
+
"Unexpected }",
|
|
174
|
+
css,
|
|
175
|
+
token.index
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
depth--;
|
|
179
|
+
start = token.index + 1;
|
|
180
|
+
textQueue = [];
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
default:
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Forgot to parse token: ${token.token}`
|
|
186
|
+
);
|
|
161
187
|
}
|
|
162
|
-
default:
|
|
163
|
-
throw new Error(`Forgot to parse token: ${token.token}`);
|
|
164
188
|
}
|
|
165
|
-
|
|
189
|
+
);
|
|
166
190
|
if (depth) {
|
|
167
191
|
return css_parser_error.styleParseError("Missing }", css);
|
|
168
192
|
}
|
|
@@ -43,122 +43,146 @@ function getTokens(css) {
|
|
|
43
43
|
}
|
|
44
44
|
throw styleParseError("Invalid css rule", css, textQueue[0]?.index);
|
|
45
45
|
};
|
|
46
|
-
findTokens(css, ['"', "'", "/*", "{", "}", ";", "url(", "\\"]).forEach(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
switch (token.token) {
|
|
51
|
-
case "/*": {
|
|
52
|
-
textQueue.push({
|
|
53
|
-
type: "chunk",
|
|
54
|
-
text: css.slice(start, token.index),
|
|
55
|
-
index: start
|
|
56
|
-
});
|
|
57
|
-
start = token.index;
|
|
58
|
-
const end = css.indexOf("*/", start + 2);
|
|
59
|
-
if (end === -1) {
|
|
60
|
-
throw styleParseError("Missing comment closing statement", css, start);
|
|
61
|
-
}
|
|
62
|
-
start = end + 2;
|
|
63
|
-
break;
|
|
46
|
+
findTokens(css, ['"', "'", "/*", "{", "}", ";", "url(", "\\"]).forEach(
|
|
47
|
+
(token) => {
|
|
48
|
+
if (token.index < start) {
|
|
49
|
+
return;
|
|
64
50
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
51
|
+
switch (token.token) {
|
|
52
|
+
case "/*": {
|
|
53
|
+
textQueue.push({
|
|
54
|
+
type: "chunk",
|
|
55
|
+
text: css.slice(start, token.index),
|
|
56
|
+
index: start
|
|
57
|
+
});
|
|
58
|
+
start = token.index;
|
|
59
|
+
const end = css.indexOf("*/", start + 2);
|
|
60
|
+
if (end === -1) {
|
|
61
|
+
throw styleParseError(
|
|
62
|
+
"Missing comment closing statement",
|
|
63
|
+
css,
|
|
64
|
+
start
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
start = end + 2;
|
|
68
|
+
break;
|
|
83
69
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
70
|
+
case "\\":
|
|
71
|
+
textQueue.push({
|
|
72
|
+
type: "chunk",
|
|
73
|
+
text: css.slice(start, token.index + 2),
|
|
74
|
+
index: start
|
|
75
|
+
});
|
|
76
|
+
start = token.index + 2;
|
|
77
|
+
break;
|
|
78
|
+
case "url(": {
|
|
79
|
+
textQueue.push({
|
|
80
|
+
type: "chunk",
|
|
81
|
+
text: css.slice(start, token.index),
|
|
82
|
+
index: start
|
|
83
|
+
});
|
|
84
|
+
start = token.index;
|
|
85
|
+
const end = findEndOfURL(css, start);
|
|
86
|
+
if (typeof end !== "number") {
|
|
87
|
+
throw end;
|
|
88
|
+
}
|
|
89
|
+
textQueue.push({
|
|
90
|
+
type: "url",
|
|
91
|
+
text: css.slice(start, end),
|
|
92
|
+
index: start
|
|
93
|
+
});
|
|
94
|
+
start = end;
|
|
95
|
+
break;
|
|
103
96
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
throw styleParseError("Invalid css rule", css, start);
|
|
97
|
+
case '"':
|
|
98
|
+
case "'": {
|
|
99
|
+
textQueue.push({
|
|
100
|
+
type: "chunk",
|
|
101
|
+
text: css.slice(start, token.index),
|
|
102
|
+
index: start
|
|
103
|
+
});
|
|
104
|
+
start = token.index;
|
|
105
|
+
const end = findEndOfQuotedString(
|
|
106
|
+
css,
|
|
107
|
+
token.token,
|
|
108
|
+
start
|
|
109
|
+
);
|
|
110
|
+
if (end === null) {
|
|
111
|
+
throw styleParseError(
|
|
112
|
+
"Missing closing " + token.token,
|
|
113
|
+
css,
|
|
114
|
+
start
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
textQueue.push({
|
|
118
|
+
type: "quoted-string",
|
|
119
|
+
text: css.slice(start, end),
|
|
120
|
+
index: start
|
|
121
|
+
});
|
|
122
|
+
start = end;
|
|
123
|
+
break;
|
|
132
124
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
125
|
+
case ";": {
|
|
126
|
+
textQueue.push({
|
|
127
|
+
type: "chunk",
|
|
128
|
+
text: css.slice(start, token.index),
|
|
129
|
+
index: start
|
|
130
|
+
});
|
|
131
|
+
checkRule(token.token);
|
|
132
|
+
start = token.index + 1;
|
|
133
|
+
textQueue = [];
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "{": {
|
|
137
|
+
textQueue.push({
|
|
138
|
+
type: "chunk",
|
|
139
|
+
text: css.slice(start, token.index),
|
|
140
|
+
index: start
|
|
141
|
+
});
|
|
142
|
+
const item = textTokensToSelector(textQueue);
|
|
143
|
+
if (!item) {
|
|
144
|
+
throw styleParseError(
|
|
145
|
+
"Invalid css rule",
|
|
146
|
+
css,
|
|
147
|
+
start
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
items.push(item);
|
|
151
|
+
start = token.index + 1;
|
|
152
|
+
textQueue = [];
|
|
153
|
+
depth++;
|
|
154
|
+
break;
|
|
152
155
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
case "}": {
|
|
157
|
+
textQueue.push({
|
|
158
|
+
type: "chunk",
|
|
159
|
+
text: css.slice(start, token.index),
|
|
160
|
+
index: start
|
|
161
|
+
});
|
|
162
|
+
checkRule("");
|
|
163
|
+
items.push({
|
|
164
|
+
type: "close",
|
|
165
|
+
index: token.index
|
|
166
|
+
});
|
|
167
|
+
if (!depth) {
|
|
168
|
+
throw styleParseError(
|
|
169
|
+
"Unexpected }",
|
|
170
|
+
css,
|
|
171
|
+
token.index
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
depth--;
|
|
175
|
+
start = token.index + 1;
|
|
176
|
+
textQueue = [];
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
default:
|
|
180
|
+
throw new Error(
|
|
181
|
+
`Forgot to parse token: ${token.token}`
|
|
182
|
+
);
|
|
157
183
|
}
|
|
158
|
-
default:
|
|
159
|
-
throw new Error(`Forgot to parse token: ${token.token}`);
|
|
160
184
|
}
|
|
161
|
-
|
|
185
|
+
);
|
|
162
186
|
if (depth) {
|
|
163
187
|
return styleParseError("Missing }", css);
|
|
164
188
|
}
|
|
@@ -18,15 +18,16 @@ function apiCacheKey(query) {
|
|
|
18
18
|
}
|
|
19
19
|
async function storeAPICache(options, key, data) {
|
|
20
20
|
const expires = Date.now() + options.ttl * 1e3;
|
|
21
|
-
const filename = options.dir + "/" + key + "." + expires + ".json";
|
|
21
|
+
const filename = options.dir + "/" + key + "." + expires.toString() + ".json";
|
|
22
22
|
if (!storedFiles[options.dir]) {
|
|
23
23
|
await getStoredFiles(options.dir);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const content = {
|
|
26
26
|
version: cacheVersion,
|
|
27
27
|
expires,
|
|
28
28
|
data
|
|
29
|
-
}
|
|
29
|
+
};
|
|
30
|
+
await fs.promises.writeFile(filename, JSON.stringify(content, null, 4), "utf8");
|
|
30
31
|
storedFiles[options.dir][key] = {
|
|
31
32
|
filename,
|
|
32
33
|
expires
|
|
@@ -42,7 +43,9 @@ async function getAPICache(dir, key) {
|
|
|
42
43
|
}
|
|
43
44
|
const time = Date.now();
|
|
44
45
|
try {
|
|
45
|
-
const content = JSON.parse(
|
|
46
|
+
const content = JSON.parse(
|
|
47
|
+
await fs.promises.readFile(item.filename, "utf8")
|
|
48
|
+
);
|
|
46
49
|
return content.version === cacheVersion && content.expires > time ? content.data : null;
|
|
47
50
|
} catch (err) {
|
|
48
51
|
return null;
|
|
@@ -61,23 +64,27 @@ async function getStoredFiles(dir, clear = false) {
|
|
|
61
64
|
});
|
|
62
65
|
} catch (err) {
|
|
63
66
|
}
|
|
64
|
-
await misc_scan.scanDirectory(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
await misc_scan.scanDirectory(
|
|
68
|
+
dir,
|
|
69
|
+
async (ext, file, subdir, path) => {
|
|
70
|
+
if (ext !== ".json") {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
const filename = path + subdir + file + ext;
|
|
74
|
+
const parts = file.split(".");
|
|
75
|
+
const expires = parseInt(parts.pop());
|
|
76
|
+
if (clear || expires < time || parts.length !== 1) {
|
|
77
|
+
await fs.promises.unlink(filename);
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const cacheKey = parts[0];
|
|
81
|
+
storage[cacheKey] = {
|
|
82
|
+
filename,
|
|
83
|
+
expires
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
false
|
|
87
|
+
);
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
exports.apiCacheKey = apiCacheKey;
|
|
@@ -14,15 +14,16 @@ function apiCacheKey(query) {
|
|
|
14
14
|
}
|
|
15
15
|
async function storeAPICache(options, key, data) {
|
|
16
16
|
const expires = Date.now() + options.ttl * 1e3;
|
|
17
|
-
const filename = options.dir + "/" + key + "." + expires + ".json";
|
|
17
|
+
const filename = options.dir + "/" + key + "." + expires.toString() + ".json";
|
|
18
18
|
if (!storedFiles[options.dir]) {
|
|
19
19
|
await getStoredFiles(options.dir);
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
const content = {
|
|
22
22
|
version: cacheVersion,
|
|
23
23
|
expires,
|
|
24
24
|
data
|
|
25
|
-
}
|
|
25
|
+
};
|
|
26
|
+
await promises.writeFile(filename, JSON.stringify(content, null, 4), "utf8");
|
|
26
27
|
storedFiles[options.dir][key] = {
|
|
27
28
|
filename,
|
|
28
29
|
expires
|
|
@@ -38,7 +39,9 @@ async function getAPICache(dir, key) {
|
|
|
38
39
|
}
|
|
39
40
|
const time = Date.now();
|
|
40
41
|
try {
|
|
41
|
-
const content = JSON.parse(
|
|
42
|
+
const content = JSON.parse(
|
|
43
|
+
await promises.readFile(item.filename, "utf8")
|
|
44
|
+
);
|
|
42
45
|
return content.version === cacheVersion && content.expires > time ? content.data : null;
|
|
43
46
|
} catch (err) {
|
|
44
47
|
return null;
|
|
@@ -57,23 +60,27 @@ async function getStoredFiles(dir, clear = false) {
|
|
|
57
60
|
});
|
|
58
61
|
} catch (err) {
|
|
59
62
|
}
|
|
60
|
-
await scanDirectory(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
await scanDirectory(
|
|
64
|
+
dir,
|
|
65
|
+
async (ext, file, subdir, path) => {
|
|
66
|
+
if (ext !== ".json") {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
const filename = path + subdir + file + ext;
|
|
70
|
+
const parts = file.split(".");
|
|
71
|
+
const expires = parseInt(parts.pop());
|
|
72
|
+
if (clear || expires < time || parts.length !== 1) {
|
|
73
|
+
await promises.unlink(filename);
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const cacheKey = parts[0];
|
|
77
|
+
storage[cacheKey] = {
|
|
78
|
+
filename,
|
|
79
|
+
expires
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
false
|
|
83
|
+
);
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
export { apiCacheKey, clearAPICache, getAPICache, storeAPICache };
|