@unocss/language-server 66.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/bin/unocss-language-server.js +2 -0
- package/dist/babel.cjs +246 -0
- package/dist/chunk-C9ebiww4.mjs +32 -0
- package/dist/dist-BUrt6dYo.cjs +193 -0
- package/dist/dist-Dwf-d4OE.mjs +175 -0
- package/dist/index.d.mts +156 -0
- package/dist/index.mjs +12482 -0
- package/dist/jiti-B459FbZV.cjs +4477 -0
- package/dist/loader-CxlILAbz.mjs +572 -0
- package/dist/multipart-parser-D3zGHRx2.mjs +168 -0
- package/dist/multipart-parser-s9tbX9e1.cjs +178 -0
- package/dist/node-B8nS8lcG.cjs +313 -0
- package/dist/node-CautW6cw.cjs +4024 -0
- package/dist/node-DvibxqDE.mjs +302 -0
- package/dist/node-loader-BO0uvH6Z.cjs +7151 -0
- package/dist/node-loader-DpZIWCu9.mjs +7144 -0
- package/dist/node-rKyHxxpg.mjs +3973 -0
- package/dist/prompt-BJqhZQ-_.cjs +851 -0
- package/dist/server.cjs +55261 -0
- package/dist/server.d.cts +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
2
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
3
|
+
function normalizeWindowsPath(input = "") {
|
|
4
|
+
if (!input) return input;
|
|
5
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
6
|
+
}
|
|
7
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
8
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
9
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
10
|
+
const normalize = function(path) {
|
|
11
|
+
if (path.length === 0) return ".";
|
|
12
|
+
path = normalizeWindowsPath(path);
|
|
13
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
14
|
+
const isPathAbsolute = isAbsolute(path);
|
|
15
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
16
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
17
|
+
if (path.length === 0) {
|
|
18
|
+
if (isPathAbsolute) return "/";
|
|
19
|
+
return trailingSeparator ? "./" : ".";
|
|
20
|
+
}
|
|
21
|
+
if (trailingSeparator) path += "/";
|
|
22
|
+
if (_DRIVE_LETTER_RE.test(path)) path += "/";
|
|
23
|
+
if (isUNCPath) {
|
|
24
|
+
if (!isPathAbsolute) return `//./${path}`;
|
|
25
|
+
return `//${path}`;
|
|
26
|
+
}
|
|
27
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
28
|
+
};
|
|
29
|
+
const join = function(...segments) {
|
|
30
|
+
let path = "";
|
|
31
|
+
for (const seg of segments) {
|
|
32
|
+
if (!seg) continue;
|
|
33
|
+
if (path.length > 0) {
|
|
34
|
+
const pathTrailing = path[path.length - 1] === "/";
|
|
35
|
+
const segLeading = seg[0] === "/";
|
|
36
|
+
if (pathTrailing && segLeading) path += seg.slice(1);
|
|
37
|
+
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
38
|
+
} else path += seg;
|
|
39
|
+
}
|
|
40
|
+
return normalize(path);
|
|
41
|
+
};
|
|
42
|
+
function cwd() {
|
|
43
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
44
|
+
return "/";
|
|
45
|
+
}
|
|
46
|
+
const resolve = function(...arguments_) {
|
|
47
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
48
|
+
let resolvedPath = "";
|
|
49
|
+
let resolvedAbsolute = false;
|
|
50
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
51
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
52
|
+
if (!path || path.length === 0) continue;
|
|
53
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
54
|
+
resolvedAbsolute = isAbsolute(path);
|
|
55
|
+
}
|
|
56
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
57
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
|
|
58
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
59
|
+
};
|
|
60
|
+
function normalizeString(path, allowAboveRoot) {
|
|
61
|
+
let res = "";
|
|
62
|
+
let lastSegmentLength = 0;
|
|
63
|
+
let lastSlash = -1;
|
|
64
|
+
let dots = 0;
|
|
65
|
+
let char = null;
|
|
66
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
67
|
+
if (index < path.length) char = path[index];
|
|
68
|
+
else if (char === "/") break;
|
|
69
|
+
else char = "/";
|
|
70
|
+
if (char === "/") {
|
|
71
|
+
if (lastSlash === index - 1 || dots === 1);
|
|
72
|
+
else if (dots === 2) {
|
|
73
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
74
|
+
if (res.length > 2) {
|
|
75
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
76
|
+
if (lastSlashIndex === -1) {
|
|
77
|
+
res = "";
|
|
78
|
+
lastSegmentLength = 0;
|
|
79
|
+
} else {
|
|
80
|
+
res = res.slice(0, lastSlashIndex);
|
|
81
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
82
|
+
}
|
|
83
|
+
lastSlash = index;
|
|
84
|
+
dots = 0;
|
|
85
|
+
continue;
|
|
86
|
+
} else if (res.length > 0) {
|
|
87
|
+
res = "";
|
|
88
|
+
lastSegmentLength = 0;
|
|
89
|
+
lastSlash = index;
|
|
90
|
+
dots = 0;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (allowAboveRoot) {
|
|
95
|
+
res += res.length > 0 ? "/.." : "..";
|
|
96
|
+
lastSegmentLength = 2;
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
|
|
100
|
+
else res = path.slice(lastSlash + 1, index);
|
|
101
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
102
|
+
}
|
|
103
|
+
lastSlash = index;
|
|
104
|
+
dots = 0;
|
|
105
|
+
} else if (char === "." && dots !== -1) ++dots;
|
|
106
|
+
else dots = -1;
|
|
107
|
+
}
|
|
108
|
+
return res;
|
|
109
|
+
}
|
|
110
|
+
const isAbsolute = function(p) {
|
|
111
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/svg/trim.js
|
|
116
|
+
/**
|
|
117
|
+
* Remove whitespace
|
|
118
|
+
*/
|
|
119
|
+
function trimSVG(str) {
|
|
120
|
+
return str.replace(/(['"])\s*\n\s*([^>\\/\s])/g, "$1 $2").replace(/(["';{}><])\s*\n\s*/g, "$1").replace(/\s*\n\s*/g, " ").replace(/\s+"/g, "\"").replace(/="\s+/g, "=\"").replace(/(\s)+\/>/g, "/>").trim();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/svg/size.js
|
|
125
|
+
/**
|
|
126
|
+
* Regular expressions for calculating dimensions
|
|
127
|
+
*/
|
|
128
|
+
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
|
|
129
|
+
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
|
|
130
|
+
function calculateSize(size, ratio, precision) {
|
|
131
|
+
if (ratio === 1) return size;
|
|
132
|
+
precision = precision || 100;
|
|
133
|
+
if (typeof size === "number") return Math.ceil(size * ratio * precision) / precision;
|
|
134
|
+
if (typeof size !== "string") return size;
|
|
135
|
+
const oldParts = size.split(unitsSplit);
|
|
136
|
+
if (oldParts === null || !oldParts.length) return size;
|
|
137
|
+
const newParts = [];
|
|
138
|
+
let code = oldParts.shift();
|
|
139
|
+
let isNumber = unitsTest.test(code);
|
|
140
|
+
while (true) {
|
|
141
|
+
if (isNumber) {
|
|
142
|
+
const num = parseFloat(code);
|
|
143
|
+
if (isNaN(num)) newParts.push(code);
|
|
144
|
+
else newParts.push(Math.ceil(num * ratio * precision) / precision);
|
|
145
|
+
} else newParts.push(code);
|
|
146
|
+
code = oldParts.shift();
|
|
147
|
+
if (code === void 0) return newParts.join("");
|
|
148
|
+
isNumber = !isNumber;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/icon/defaults.js
|
|
154
|
+
/** Default values for dimensions */
|
|
155
|
+
const defaultIconDimensions = Object.freeze({
|
|
156
|
+
left: 0,
|
|
157
|
+
top: 0,
|
|
158
|
+
width: 16,
|
|
159
|
+
height: 16
|
|
160
|
+
});
|
|
161
|
+
/** Default values for transformations */
|
|
162
|
+
const defaultIconTransformations = Object.freeze({
|
|
163
|
+
rotate: 0,
|
|
164
|
+
vFlip: false,
|
|
165
|
+
hFlip: false
|
|
166
|
+
});
|
|
167
|
+
/** Default values for all optional IconifyIcon properties */
|
|
168
|
+
const defaultIconProps = Object.freeze({
|
|
169
|
+
...defaultIconDimensions,
|
|
170
|
+
...defaultIconTransformations
|
|
171
|
+
});
|
|
172
|
+
/** Default values for all properties used in ExtendedIconifyIcon */
|
|
173
|
+
const defaultExtendedIconProps = Object.freeze({
|
|
174
|
+
...defaultIconProps,
|
|
175
|
+
body: "",
|
|
176
|
+
hidden: false
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/customisations/defaults.js
|
|
181
|
+
/**
|
|
182
|
+
* Default icon customisations values
|
|
183
|
+
*/
|
|
184
|
+
const defaultIconSizeCustomisations = Object.freeze({
|
|
185
|
+
width: null,
|
|
186
|
+
height: null
|
|
187
|
+
});
|
|
188
|
+
const defaultIconCustomisations = Object.freeze({
|
|
189
|
+
...defaultIconSizeCustomisations,
|
|
190
|
+
...defaultIconTransformations
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/svg/defs.js
|
|
195
|
+
function splitSVGDefs(content, tag = "defs") {
|
|
196
|
+
let defs = "";
|
|
197
|
+
const index = content.indexOf("<" + tag);
|
|
198
|
+
while (index >= 0) {
|
|
199
|
+
const start = content.indexOf(">", index);
|
|
200
|
+
const end = content.indexOf("</" + tag);
|
|
201
|
+
if (start === -1 || end === -1) break;
|
|
202
|
+
const endEnd = content.indexOf(">", end);
|
|
203
|
+
if (endEnd === -1) break;
|
|
204
|
+
defs += content.slice(start + 1, end).trim();
|
|
205
|
+
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
defs,
|
|
209
|
+
content
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Merge defs and content
|
|
214
|
+
*/
|
|
215
|
+
function mergeDefsAndContent(defs, content) {
|
|
216
|
+
return defs ? "<defs>" + defs + "</defs>" + content : content;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Wrap SVG content, without wrapping definitions
|
|
220
|
+
*/
|
|
221
|
+
function wrapSVGContent(body, start, end) {
|
|
222
|
+
const split = splitSVGDefs(body);
|
|
223
|
+
return mergeDefsAndContent(split.defs, start + split.content + end);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
//#endregion
|
|
227
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/svg/build.js
|
|
228
|
+
/**
|
|
229
|
+
* Check if value should be unset. Allows multiple keywords
|
|
230
|
+
*/
|
|
231
|
+
const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
232
|
+
/**
|
|
233
|
+
* Get SVG attributes and content from icon + customisations
|
|
234
|
+
*
|
|
235
|
+
* Does not generate style to make it compatible with frameworks that use objects for style, such as React.
|
|
236
|
+
* Instead, it generates 'inline' value. If true, rendering engine should add verticalAlign: -0.125em to icon.
|
|
237
|
+
*
|
|
238
|
+
* Customisations should be normalised by platform specific parser.
|
|
239
|
+
* Result should be converted to <svg> by platform specific parser.
|
|
240
|
+
* Use replaceIDs to generate unique IDs for body.
|
|
241
|
+
*/
|
|
242
|
+
function iconToSVG(icon, customisations) {
|
|
243
|
+
const fullIcon = {
|
|
244
|
+
...defaultIconProps,
|
|
245
|
+
...icon
|
|
246
|
+
};
|
|
247
|
+
const fullCustomisations = {
|
|
248
|
+
...defaultIconCustomisations,
|
|
249
|
+
...customisations
|
|
250
|
+
};
|
|
251
|
+
const box = {
|
|
252
|
+
left: fullIcon.left,
|
|
253
|
+
top: fullIcon.top,
|
|
254
|
+
width: fullIcon.width,
|
|
255
|
+
height: fullIcon.height
|
|
256
|
+
};
|
|
257
|
+
let body = fullIcon.body;
|
|
258
|
+
[fullIcon, fullCustomisations].forEach((props) => {
|
|
259
|
+
const transformations = [];
|
|
260
|
+
const hFlip = props.hFlip;
|
|
261
|
+
const vFlip = props.vFlip;
|
|
262
|
+
let rotation = props.rotate;
|
|
263
|
+
if (hFlip) if (vFlip) rotation += 2;
|
|
264
|
+
else {
|
|
265
|
+
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
|
|
266
|
+
transformations.push("scale(-1 1)");
|
|
267
|
+
box.top = box.left = 0;
|
|
268
|
+
}
|
|
269
|
+
else if (vFlip) {
|
|
270
|
+
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
|
|
271
|
+
transformations.push("scale(1 -1)");
|
|
272
|
+
box.top = box.left = 0;
|
|
273
|
+
}
|
|
274
|
+
let tempValue;
|
|
275
|
+
if (rotation < 0) rotation -= Math.floor(rotation / 4) * 4;
|
|
276
|
+
rotation = rotation % 4;
|
|
277
|
+
switch (rotation) {
|
|
278
|
+
case 1:
|
|
279
|
+
tempValue = box.height / 2 + box.top;
|
|
280
|
+
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
281
|
+
break;
|
|
282
|
+
case 2:
|
|
283
|
+
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
|
|
284
|
+
break;
|
|
285
|
+
case 3:
|
|
286
|
+
tempValue = box.width / 2 + box.left;
|
|
287
|
+
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
if (rotation % 2 === 1) {
|
|
291
|
+
if (box.left !== box.top) {
|
|
292
|
+
tempValue = box.left;
|
|
293
|
+
box.left = box.top;
|
|
294
|
+
box.top = tempValue;
|
|
295
|
+
}
|
|
296
|
+
if (box.width !== box.height) {
|
|
297
|
+
tempValue = box.width;
|
|
298
|
+
box.width = box.height;
|
|
299
|
+
box.height = tempValue;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (transformations.length) body = wrapSVGContent(body, "<g transform=\"" + transformations.join(" ") + "\">", "</g>");
|
|
303
|
+
});
|
|
304
|
+
const customisationsWidth = fullCustomisations.width;
|
|
305
|
+
const customisationsHeight = fullCustomisations.height;
|
|
306
|
+
const boxWidth = box.width;
|
|
307
|
+
const boxHeight = box.height;
|
|
308
|
+
let width;
|
|
309
|
+
let height;
|
|
310
|
+
if (customisationsWidth === null) {
|
|
311
|
+
height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
312
|
+
width = calculateSize(height, boxWidth / boxHeight);
|
|
313
|
+
} else {
|
|
314
|
+
width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
|
|
315
|
+
height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
|
|
316
|
+
}
|
|
317
|
+
const attributes = {};
|
|
318
|
+
const setAttr = (prop, value) => {
|
|
319
|
+
if (!isUnsetKeyword(value)) attributes[prop] = value.toString();
|
|
320
|
+
};
|
|
321
|
+
setAttr("width", width);
|
|
322
|
+
setAttr("height", height);
|
|
323
|
+
const viewBox = [
|
|
324
|
+
box.left,
|
|
325
|
+
box.top,
|
|
326
|
+
boxWidth,
|
|
327
|
+
boxHeight
|
|
328
|
+
];
|
|
329
|
+
attributes.viewBox = viewBox.join(" ");
|
|
330
|
+
return {
|
|
331
|
+
attributes,
|
|
332
|
+
viewBox,
|
|
333
|
+
body
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
//#endregion
|
|
338
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/loader/utils.js
|
|
339
|
+
const svgWidthRegex = /\swidth\s*=\s*["']([\w.]+)["']/;
|
|
340
|
+
const svgHeightRegex = /\sheight\s*=\s*["']([\w.]+)["']/;
|
|
341
|
+
const svgTagRegex = /<svg\s+/;
|
|
342
|
+
function configureSvgSize(svg, props, scale) {
|
|
343
|
+
const svgNode = svg.slice(0, svg.indexOf(">"));
|
|
344
|
+
const check = (prop, regex) => {
|
|
345
|
+
const result = regex.exec(svgNode);
|
|
346
|
+
const isSet = result != null;
|
|
347
|
+
const propValue = props[prop];
|
|
348
|
+
if (!propValue && !isUnsetKeyword(propValue)) {
|
|
349
|
+
if (typeof scale === "number") {
|
|
350
|
+
if (scale > 0) props[prop] = calculateSize(result?.[1] ?? "1em", scale);
|
|
351
|
+
} else if (result) props[prop] = result[1];
|
|
352
|
+
}
|
|
353
|
+
return isSet;
|
|
354
|
+
};
|
|
355
|
+
return [check("width", svgWidthRegex), check("height", svgHeightRegex)];
|
|
356
|
+
}
|
|
357
|
+
async function mergeIconProps(svg, collection, icon, options, propsProvider, afterCustomizations) {
|
|
358
|
+
const { scale, addXmlNs = false } = options ?? {};
|
|
359
|
+
const { additionalProps = {}, iconCustomizer } = options?.customizations ?? {};
|
|
360
|
+
const props = await propsProvider?.() ?? {};
|
|
361
|
+
await iconCustomizer?.(collection, icon, props);
|
|
362
|
+
Object.keys(additionalProps).forEach((p) => {
|
|
363
|
+
const v = additionalProps[p];
|
|
364
|
+
if (v !== void 0 && v !== null) props[p] = v;
|
|
365
|
+
});
|
|
366
|
+
afterCustomizations?.(props);
|
|
367
|
+
const [widthOnSvg, heightOnSvg] = configureSvgSize(svg, props, scale);
|
|
368
|
+
if (addXmlNs) {
|
|
369
|
+
if (!svg.includes("xmlns=") && !props["xmlns"]) props["xmlns"] = "http://www.w3.org/2000/svg";
|
|
370
|
+
if (!svg.includes("xmlns:xlink=") && svg.includes("xlink:") && !props["xmlns:xlink"]) props["xmlns:xlink"] = "http://www.w3.org/1999/xlink";
|
|
371
|
+
}
|
|
372
|
+
const propsToAdd = Object.keys(props).map((p) => p === "width" && widthOnSvg || p === "height" && heightOnSvg ? null : `${p}="${props[p]}"`).filter((p) => p != null);
|
|
373
|
+
if (propsToAdd.length) svg = svg.replace(svgTagRegex, `<svg ${propsToAdd.join(" ")} `);
|
|
374
|
+
if (options) {
|
|
375
|
+
const { defaultStyle, defaultClass } = options;
|
|
376
|
+
if (defaultClass && !svg.includes("class=")) svg = svg.replace(svgTagRegex, `<svg class="${defaultClass}" `);
|
|
377
|
+
if (defaultStyle && !svg.includes("style=")) svg = svg.replace(svgTagRegex, `<svg style="${defaultStyle}" `);
|
|
378
|
+
}
|
|
379
|
+
const usedProps = options?.usedProps;
|
|
380
|
+
if (usedProps) {
|
|
381
|
+
Object.keys(additionalProps).forEach((p) => {
|
|
382
|
+
const v = props[p];
|
|
383
|
+
if (v !== void 0 && v !== null) usedProps[p] = v;
|
|
384
|
+
});
|
|
385
|
+
if (typeof props.width !== "undefined" && props.width !== null) usedProps.width = props.width;
|
|
386
|
+
if (typeof props.height !== "undefined" && props.height !== null) usedProps.height = props.height;
|
|
387
|
+
}
|
|
388
|
+
return svg;
|
|
389
|
+
}
|
|
390
|
+
function getPossibleIconNames(icon) {
|
|
391
|
+
return [
|
|
392
|
+
icon,
|
|
393
|
+
icon.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(),
|
|
394
|
+
icon.replace(/([a-z])(\d+)/g, "$1-$2")
|
|
395
|
+
];
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/loader/custom.js
|
|
400
|
+
/**
|
|
401
|
+
* Get custom icon from inline collection or using loader
|
|
402
|
+
*/
|
|
403
|
+
async function getCustomIcon(custom, collection, icon, options) {
|
|
404
|
+
let result;
|
|
405
|
+
try {
|
|
406
|
+
if (typeof custom === "function") result = await custom(icon);
|
|
407
|
+
else {
|
|
408
|
+
const inline = custom[icon];
|
|
409
|
+
result = typeof inline === "function" ? await inline() : inline;
|
|
410
|
+
}
|
|
411
|
+
} catch (err) {
|
|
412
|
+
console.warn(`Failed to load custom icon "${icon}" in "${collection}":`, err);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (result) {
|
|
416
|
+
const cleanupIdx = result.indexOf("<svg");
|
|
417
|
+
if (cleanupIdx > 0) result = result.slice(cleanupIdx);
|
|
418
|
+
const { transform } = options?.customizations ?? {};
|
|
419
|
+
result = typeof transform === "function" ? await transform(result, collection, icon) : result;
|
|
420
|
+
if (!result.startsWith("<svg")) {
|
|
421
|
+
console.warn(`Custom icon "${icon}" in "${collection}" is not a valid SVG`);
|
|
422
|
+
return result;
|
|
423
|
+
}
|
|
424
|
+
return await mergeIconProps(options?.customizations?.trimCustomSvg === true ? trimSVG(result) : result, collection, icon, options, void 0);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/icon/transformations.js
|
|
430
|
+
/**
|
|
431
|
+
* Merge transformations
|
|
432
|
+
*/
|
|
433
|
+
function mergeIconTransformations(obj1, obj2) {
|
|
434
|
+
const result = {};
|
|
435
|
+
if (!obj1.hFlip !== !obj2.hFlip) result.hFlip = true;
|
|
436
|
+
if (!obj1.vFlip !== !obj2.vFlip) result.vFlip = true;
|
|
437
|
+
const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
|
|
438
|
+
if (rotate) result.rotate = rotate;
|
|
439
|
+
return result;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/icon/merge.js
|
|
444
|
+
/**
|
|
445
|
+
* Merge icon and alias
|
|
446
|
+
*
|
|
447
|
+
* Can also be used to merge default values and icon
|
|
448
|
+
*/
|
|
449
|
+
function mergeIconData(parent, child) {
|
|
450
|
+
const result = mergeIconTransformations(parent, child);
|
|
451
|
+
for (const key in defaultExtendedIconProps) if (key in defaultIconTransformations) {
|
|
452
|
+
if (key in parent && !(key in result)) result[key] = defaultIconTransformations[key];
|
|
453
|
+
} else if (key in child) result[key] = child[key];
|
|
454
|
+
else if (key in parent) result[key] = parent[key];
|
|
455
|
+
return result;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
//#endregion
|
|
459
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/icon-set/tree.js
|
|
460
|
+
/**
|
|
461
|
+
* Resolve icon set icons
|
|
462
|
+
*
|
|
463
|
+
* Returns parent icon for each icon
|
|
464
|
+
*/
|
|
465
|
+
function getIconsTree(data, names) {
|
|
466
|
+
const icons = data.icons;
|
|
467
|
+
const aliases = data.aliases || Object.create(null);
|
|
468
|
+
const resolved = Object.create(null);
|
|
469
|
+
function resolve$1(name) {
|
|
470
|
+
if (icons[name]) return resolved[name] = [];
|
|
471
|
+
if (!(name in resolved)) {
|
|
472
|
+
resolved[name] = null;
|
|
473
|
+
const parent = aliases[name] && aliases[name].parent;
|
|
474
|
+
const value = parent && resolve$1(parent);
|
|
475
|
+
if (value) resolved[name] = [parent].concat(value);
|
|
476
|
+
}
|
|
477
|
+
return resolved[name];
|
|
478
|
+
}
|
|
479
|
+
(names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve$1);
|
|
480
|
+
return resolved;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/icon-set/get-icon.js
|
|
485
|
+
/**
|
|
486
|
+
* Get icon data, using prepared aliases tree
|
|
487
|
+
*/
|
|
488
|
+
function internalGetIconData(data, name, tree) {
|
|
489
|
+
const icons = data.icons;
|
|
490
|
+
const aliases = data.aliases || Object.create(null);
|
|
491
|
+
let currentProps = {};
|
|
492
|
+
function parse(name$1) {
|
|
493
|
+
currentProps = mergeIconData(icons[name$1] || aliases[name$1], currentProps);
|
|
494
|
+
}
|
|
495
|
+
parse(name);
|
|
496
|
+
tree.forEach(parse);
|
|
497
|
+
return mergeIconData(data, currentProps);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Get data for icon
|
|
501
|
+
*/
|
|
502
|
+
function getIconData(data, name) {
|
|
503
|
+
if (data.icons[name]) return internalGetIconData(data, name, []);
|
|
504
|
+
const tree = getIconsTree(data, [name])[name];
|
|
505
|
+
return tree ? internalGetIconData(data, name, tree) : null;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/loader/modern.js
|
|
510
|
+
async function searchForIcon(iconSet, collection, ids, options) {
|
|
511
|
+
let iconData;
|
|
512
|
+
const { customize } = options?.customizations ?? {};
|
|
513
|
+
for (const id of ids) {
|
|
514
|
+
iconData = getIconData(iconSet, id);
|
|
515
|
+
if (iconData) {
|
|
516
|
+
let defaultCustomizations = { ...defaultIconCustomisations };
|
|
517
|
+
if (typeof customize === "function") {
|
|
518
|
+
iconData = Object.assign({}, iconData);
|
|
519
|
+
defaultCustomizations = customize(defaultCustomizations, iconData, `${collection}:${id}`) ?? defaultCustomizations;
|
|
520
|
+
}
|
|
521
|
+
const { attributes: { width, height, ...restAttributes }, body } = iconToSVG(iconData, defaultCustomizations);
|
|
522
|
+
const scale = options?.scale;
|
|
523
|
+
return await mergeIconProps(`<svg >${body}</svg>`, collection, id, options, () => {
|
|
524
|
+
return { ...restAttributes };
|
|
525
|
+
}, (props) => {
|
|
526
|
+
const check = (prop, defaultValue) => {
|
|
527
|
+
const propValue = props[prop];
|
|
528
|
+
let value;
|
|
529
|
+
if (!isUnsetKeyword(propValue)) {
|
|
530
|
+
if (propValue) return;
|
|
531
|
+
if (typeof scale === "number") {
|
|
532
|
+
if (scale) value = calculateSize(defaultValue ?? "1em", scale);
|
|
533
|
+
} else value = defaultValue;
|
|
534
|
+
}
|
|
535
|
+
if (!value) delete props[prop];
|
|
536
|
+
else props[prop] = value;
|
|
537
|
+
};
|
|
538
|
+
check("width", width);
|
|
539
|
+
check("height", height);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
//#endregion
|
|
546
|
+
//#region ../../node_modules/.pnpm/@iconify+utils@3.1.0/node_modules/@iconify/utils/lib/loader/loader.js
|
|
547
|
+
const loadIcon = async (collection, icon, options) => {
|
|
548
|
+
const custom = options?.customCollections?.[collection];
|
|
549
|
+
if (custom) if (typeof custom === "function") {
|
|
550
|
+
let result;
|
|
551
|
+
try {
|
|
552
|
+
result = await custom(icon);
|
|
553
|
+
} catch (err) {
|
|
554
|
+
console.warn(`Failed to load custom icon "${icon}" in "${collection}":`, err);
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (result) {
|
|
558
|
+
if (typeof result === "string") return await getCustomIcon(() => result, collection, icon, options);
|
|
559
|
+
if ("icons" in result) {
|
|
560
|
+
const ids = [
|
|
561
|
+
icon,
|
|
562
|
+
icon.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(),
|
|
563
|
+
icon.replace(/([a-z])(\d+)/g, "$1-$2")
|
|
564
|
+
];
|
|
565
|
+
return await searchForIcon(result, collection, ids, options);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
} else return await getCustomIcon(custom, collection, icon, options);
|
|
569
|
+
};
|
|
570
|
+
|
|
571
|
+
//#endregion
|
|
572
|
+
export { join as a, isAbsolute as i, searchForIcon as n, resolve as o, getPossibleIconNames as r, loadIcon as t };
|