@unocss/preset-icons 0.55.2 → 0.55.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/dist/browser.cjs +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.mts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{preset-icons.54d3f633.cjs → preset-icons.03b1ec6a.cjs} +58 -9
- package/dist/shared/{preset-icons.3f82c70f.mjs → preset-icons.05307f91.mjs} +58 -9
- package/package.json +4 -4
package/dist/browser.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const cdn = require('./shared/preset-icons.
|
|
5
|
+
const cdn = require('./shared/preset-icons.03b1ec6a.cjs');
|
|
6
6
|
const core = require('./core.cjs');
|
|
7
7
|
require('ofetch');
|
|
8
8
|
require('@unocss/core');
|
package/dist/browser.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.
|
|
1
|
+
import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.05307f91.mjs';
|
|
2
2
|
import { createPresetIcons } from './core.mjs';
|
|
3
3
|
export { combineLoaders } from './core.mjs';
|
|
4
4
|
import 'ofetch';
|
package/dist/core.d.cts
CHANGED
|
@@ -80,4 +80,4 @@ interface IconsOptions {
|
|
|
80
80
|
declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): (options?: IconsOptions) => Preset;
|
|
81
81
|
declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
|
|
82
82
|
|
|
83
|
-
export { IconsOptions, combineLoaders, createPresetIcons };
|
|
83
|
+
export { type IconsOptions, combineLoaders, createPresetIcons };
|
package/dist/core.d.mts
CHANGED
|
@@ -80,4 +80,4 @@ interface IconsOptions {
|
|
|
80
80
|
declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): (options?: IconsOptions) => Preset;
|
|
81
81
|
declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
|
|
82
82
|
|
|
83
|
-
export { IconsOptions, combineLoaders, createPresetIcons };
|
|
83
|
+
export { type IconsOptions, combineLoaders, createPresetIcons };
|
package/dist/core.d.ts
CHANGED
|
@@ -80,4 +80,4 @@ interface IconsOptions {
|
|
|
80
80
|
declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): (options?: IconsOptions) => Preset;
|
|
81
81
|
declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
|
|
82
82
|
|
|
83
|
-
export { IconsOptions, combineLoaders, createPresetIcons };
|
|
83
|
+
export { type IconsOptions, combineLoaders, createPresetIcons };
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const cdn = require('./shared/preset-icons.
|
|
5
|
+
const cdn = require('./shared/preset-icons.03b1ec6a.cjs');
|
|
6
6
|
const core = require('./core.cjs');
|
|
7
7
|
require('ofetch');
|
|
8
8
|
require('@unocss/core');
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.
|
|
1
|
+
import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.05307f91.mjs';
|
|
2
2
|
import { createPresetIcons, combineLoaders } from './core.mjs';
|
|
3
3
|
import 'ofetch';
|
|
4
4
|
import '@unocss/core';
|
|
@@ -150,6 +150,32 @@ function calculateSize(size, ratio, precision) {
|
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
function splitSVGDefs(content) {
|
|
154
|
+
let defs = "";
|
|
155
|
+
const index = content.indexOf("<defs");
|
|
156
|
+
while (index >= 0) {
|
|
157
|
+
const start = content.indexOf(">", index);
|
|
158
|
+
const end = content.indexOf("</defs");
|
|
159
|
+
if (start === -1 || end === -1) {
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
const endEnd = content.indexOf(">", end);
|
|
163
|
+
if (endEnd === -1) {
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
defs += content.slice(start + 1, end).trim();
|
|
167
|
+
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
defs,
|
|
171
|
+
content
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function wrapSVGContent(body, start, end) {
|
|
175
|
+
const { defs, content } = splitSVGDefs(body);
|
|
176
|
+
return (defs ? "<defs>" + defs + "</defs>" : "") + start + content + end;
|
|
177
|
+
}
|
|
178
|
+
|
|
153
179
|
const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
154
180
|
function iconToSVG(icon, customisations) {
|
|
155
181
|
const fullIcon = {
|
|
@@ -226,7 +252,11 @@ function iconToSVG(icon, customisations) {
|
|
|
226
252
|
}
|
|
227
253
|
}
|
|
228
254
|
if (transformations.length) {
|
|
229
|
-
body =
|
|
255
|
+
body = wrapSVGContent(
|
|
256
|
+
body,
|
|
257
|
+
'<g transform="' + transformations.join(" ") + '">',
|
|
258
|
+
"</g>"
|
|
259
|
+
);
|
|
230
260
|
}
|
|
231
261
|
});
|
|
232
262
|
const customisationsWidth = fullCustomisations.width;
|
|
@@ -250,9 +280,11 @@ function iconToSVG(icon, customisations) {
|
|
|
250
280
|
};
|
|
251
281
|
setAttr("width", width);
|
|
252
282
|
setAttr("height", height);
|
|
253
|
-
|
|
283
|
+
const viewBox = [box.left, box.top, boxWidth, boxHeight];
|
|
284
|
+
attributes.viewBox = viewBox.join(" ");
|
|
254
285
|
return {
|
|
255
286
|
attributes,
|
|
287
|
+
viewBox,
|
|
256
288
|
body
|
|
257
289
|
};
|
|
258
290
|
}
|
|
@@ -337,11 +369,19 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
|
|
|
337
369
|
|
|
338
370
|
async function getCustomIcon(custom, collection, icon, options) {
|
|
339
371
|
let result;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
372
|
+
try {
|
|
373
|
+
if (typeof custom === "function") {
|
|
374
|
+
result = await custom(icon);
|
|
375
|
+
} else {
|
|
376
|
+
const inline = custom[icon];
|
|
377
|
+
result = typeof inline === "function" ? await inline() : inline;
|
|
378
|
+
}
|
|
379
|
+
} catch (err) {
|
|
380
|
+
console.warn(
|
|
381
|
+
`Failed to load custom icon "${icon}" in "${collection}":`,
|
|
382
|
+
err
|
|
383
|
+
);
|
|
384
|
+
return;
|
|
345
385
|
}
|
|
346
386
|
if (result) {
|
|
347
387
|
const cleanupIdx = result.indexOf("<svg");
|
|
@@ -422,7 +462,16 @@ const loadIcon = async (collection, icon, options) => {
|
|
|
422
462
|
const custom = options?.customCollections?.[collection];
|
|
423
463
|
if (custom) {
|
|
424
464
|
if (typeof custom === "function") {
|
|
425
|
-
|
|
465
|
+
let result;
|
|
466
|
+
try {
|
|
467
|
+
result = await custom(icon);
|
|
468
|
+
} catch (err) {
|
|
469
|
+
console.warn(
|
|
470
|
+
`Failed to load custom icon "${icon}" in "${collection}":`,
|
|
471
|
+
err
|
|
472
|
+
);
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
426
475
|
if (result) {
|
|
427
476
|
if (typeof result === "string") {
|
|
428
477
|
return await getCustomIcon(
|
|
@@ -450,7 +499,6 @@ const loadIcon = async (collection, icon, options) => {
|
|
|
450
499
|
return await getCustomIcon(custom, collection, icon, options);
|
|
451
500
|
}
|
|
452
501
|
}
|
|
453
|
-
return void 0;
|
|
454
502
|
};
|
|
455
503
|
|
|
456
504
|
function getDefaultExportFromCjs (x) {
|
|
@@ -599,6 +647,7 @@ var collections = [
|
|
|
599
647
|
"svg-spinners",
|
|
600
648
|
"system-uicons",
|
|
601
649
|
"tabler",
|
|
650
|
+
"tdesign",
|
|
602
651
|
"teenyicons",
|
|
603
652
|
"topcoat",
|
|
604
653
|
"twemoji",
|
|
@@ -148,6 +148,32 @@ function calculateSize(size, ratio, precision) {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
function splitSVGDefs(content) {
|
|
152
|
+
let defs = "";
|
|
153
|
+
const index = content.indexOf("<defs");
|
|
154
|
+
while (index >= 0) {
|
|
155
|
+
const start = content.indexOf(">", index);
|
|
156
|
+
const end = content.indexOf("</defs");
|
|
157
|
+
if (start === -1 || end === -1) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
const endEnd = content.indexOf(">", end);
|
|
161
|
+
if (endEnd === -1) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
defs += content.slice(start + 1, end).trim();
|
|
165
|
+
content = content.slice(0, index).trim() + content.slice(endEnd + 1);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
defs,
|
|
169
|
+
content
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function wrapSVGContent(body, start, end) {
|
|
173
|
+
const { defs, content } = splitSVGDefs(body);
|
|
174
|
+
return (defs ? "<defs>" + defs + "</defs>" : "") + start + content + end;
|
|
175
|
+
}
|
|
176
|
+
|
|
151
177
|
const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
|
|
152
178
|
function iconToSVG(icon, customisations) {
|
|
153
179
|
const fullIcon = {
|
|
@@ -224,7 +250,11 @@ function iconToSVG(icon, customisations) {
|
|
|
224
250
|
}
|
|
225
251
|
}
|
|
226
252
|
if (transformations.length) {
|
|
227
|
-
body =
|
|
253
|
+
body = wrapSVGContent(
|
|
254
|
+
body,
|
|
255
|
+
'<g transform="' + transformations.join(" ") + '">',
|
|
256
|
+
"</g>"
|
|
257
|
+
);
|
|
228
258
|
}
|
|
229
259
|
});
|
|
230
260
|
const customisationsWidth = fullCustomisations.width;
|
|
@@ -248,9 +278,11 @@ function iconToSVG(icon, customisations) {
|
|
|
248
278
|
};
|
|
249
279
|
setAttr("width", width);
|
|
250
280
|
setAttr("height", height);
|
|
251
|
-
|
|
281
|
+
const viewBox = [box.left, box.top, boxWidth, boxHeight];
|
|
282
|
+
attributes.viewBox = viewBox.join(" ");
|
|
252
283
|
return {
|
|
253
284
|
attributes,
|
|
285
|
+
viewBox,
|
|
254
286
|
body
|
|
255
287
|
};
|
|
256
288
|
}
|
|
@@ -335,11 +367,19 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
|
|
|
335
367
|
|
|
336
368
|
async function getCustomIcon(custom, collection, icon, options) {
|
|
337
369
|
let result;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
370
|
+
try {
|
|
371
|
+
if (typeof custom === "function") {
|
|
372
|
+
result = await custom(icon);
|
|
373
|
+
} else {
|
|
374
|
+
const inline = custom[icon];
|
|
375
|
+
result = typeof inline === "function" ? await inline() : inline;
|
|
376
|
+
}
|
|
377
|
+
} catch (err) {
|
|
378
|
+
console.warn(
|
|
379
|
+
`Failed to load custom icon "${icon}" in "${collection}":`,
|
|
380
|
+
err
|
|
381
|
+
);
|
|
382
|
+
return;
|
|
343
383
|
}
|
|
344
384
|
if (result) {
|
|
345
385
|
const cleanupIdx = result.indexOf("<svg");
|
|
@@ -420,7 +460,16 @@ const loadIcon = async (collection, icon, options) => {
|
|
|
420
460
|
const custom = options?.customCollections?.[collection];
|
|
421
461
|
if (custom) {
|
|
422
462
|
if (typeof custom === "function") {
|
|
423
|
-
|
|
463
|
+
let result;
|
|
464
|
+
try {
|
|
465
|
+
result = await custom(icon);
|
|
466
|
+
} catch (err) {
|
|
467
|
+
console.warn(
|
|
468
|
+
`Failed to load custom icon "${icon}" in "${collection}":`,
|
|
469
|
+
err
|
|
470
|
+
);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
424
473
|
if (result) {
|
|
425
474
|
if (typeof result === "string") {
|
|
426
475
|
return await getCustomIcon(
|
|
@@ -448,7 +497,6 @@ const loadIcon = async (collection, icon, options) => {
|
|
|
448
497
|
return await getCustomIcon(custom, collection, icon, options);
|
|
449
498
|
}
|
|
450
499
|
}
|
|
451
|
-
return void 0;
|
|
452
500
|
};
|
|
453
501
|
|
|
454
502
|
function getDefaultExportFromCjs (x) {
|
|
@@ -597,6 +645,7 @@ var collections = [
|
|
|
597
645
|
"svg-spinners",
|
|
598
646
|
"system-uicons",
|
|
599
647
|
"tabler",
|
|
648
|
+
"tdesign",
|
|
600
649
|
"teenyicons",
|
|
601
650
|
"topcoat",
|
|
602
651
|
"twemoji",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-icons",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.3",
|
|
4
4
|
"description": "Pure CSS Icons for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"*.css"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@iconify/utils": "^2.1.
|
|
51
|
-
"ofetch": "^1.
|
|
52
|
-
"@unocss/core": "0.55.
|
|
50
|
+
"@iconify/utils": "^2.1.9",
|
|
51
|
+
"ofetch": "^1.3.3",
|
|
52
|
+
"@unocss/core": "0.55.3"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@iconify/types": "^2.0.0"
|