@unocss/preset-icons 0.44.7 → 0.45.4

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 CHANGED
@@ -14,6 +14,7 @@ const presetIcons = core.createPresetIcons(async (options) => {
14
14
  return cdn.loadIcon;
15
15
  });
16
16
 
17
+ exports.combineLoaders = core.combineLoaders;
17
18
  exports.createPresetIcons = core.createPresetIcons;
18
19
  exports["default"] = presetIcons;
19
20
  exports.presetIcons = presetIcons;
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { IconsOptions } from './core.js';
3
- export { IconsOptions, createPresetIcons } from './core.js';
3
+ export { IconsOptions, combineLoaders, createPresetIcons } from './core.js';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
package/dist/browser.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { c as createCDNLoader, l as loadIcon } from './chunks/cdn.mjs';
2
2
  import { createPresetIcons } from './core.mjs';
3
- export { createPresetIcons } from './core.mjs';
3
+ export { combineLoaders, createPresetIcons } from './core.mjs';
4
4
  import 'ohmyfetch';
5
5
  import '@unocss/core';
6
6
 
@@ -14,6 +14,9 @@ const defaults = Object.freeze({
14
14
  rotate: 0
15
15
  });
16
16
 
17
+ const allKeys = Object.keys(defaults);
18
+ allKeys.filter((key) => key !== "width" && key !== "height");
19
+
17
20
  const iconDefaults = Object.freeze({
18
21
  left: 0,
19
22
  top: 0,
@@ -87,6 +90,14 @@ function getIconData(data, name, full = false) {
87
90
  return result && full ? fullIcon(result) : result;
88
91
  }
89
92
 
93
+ for (const prop in iconDefaults) {
94
+ typeof iconDefaults[prop];
95
+ }
96
+
97
+ Object.keys(iconDefaults).concat([
98
+ "provider"
99
+ ]);
100
+
90
101
  const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
91
102
  const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
92
103
  function calculateSize(size, ratio, precision) {
@@ -248,10 +259,188 @@ function iconToSVG(icon, customisations) {
248
259
  return result;
249
260
  }
250
261
 
262
+ "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
263
+
251
264
  function trimSVG(str) {
252
265
  return str.replace(/(["';{}><])\s*\n\s*/g, "$1").replace(/\s*\n\s*/g, " ").replace(/\s+"/g, '"').replace(/="\s+/g, '="').trim();
253
266
  }
254
267
 
268
+ function add(keyword, colors) {
269
+ const type = "rgb";
270
+ const r = colors[0];
271
+ const length = colors.length;
272
+ ({
273
+ type,
274
+ r,
275
+ g: length > 1 ? colors[1] : r,
276
+ b: length > 2 ? colors[2] : r,
277
+ alpha: length > 3 ? colors[3] : 1
278
+ });
279
+ }
280
+ add("silver", [192]);
281
+ add("gray", [128]);
282
+ add("white", [255]);
283
+ add("maroon", [128, 0, 0]);
284
+ add("red", [255, 0, 0]);
285
+ add("purple", [128, 0]);
286
+ add("fuchsia", [255, 0]);
287
+ add("green", [0, 128]);
288
+ add("lime", [0, 255]);
289
+ add("olive", [128, 128, 0]);
290
+ add("yellow", [255, 255, 0]);
291
+ add("navy", [0, 0, 128]);
292
+ add("blue", [0, 0, 255]);
293
+ add("teal", [0, 128, 128]);
294
+ add("aqua", [0, 255, 255]);
295
+ add("aliceblue", [240, 248, 255]);
296
+ add("antiquewhite", [250, 235, 215]);
297
+ add("aqua", [0, 255, 255]);
298
+ add("aquamarine", [127, 255, 212]);
299
+ add("azure", [240, 255, 255]);
300
+ add("beige", [245, 245, 220]);
301
+ add("bisque", [255, 228, 196]);
302
+ add("black", [0]);
303
+ add("blanchedalmond", [255, 235, 205]);
304
+ add("blue", [0, 0, 255]);
305
+ add("blueviolet", [138, 43, 226]);
306
+ add("brown", [165, 42, 42]);
307
+ add("burlywood", [222, 184, 135]);
308
+ add("cadetblue", [95, 158, 160]);
309
+ add("chartreuse", [127, 255, 0]);
310
+ add("chocolate", [210, 105, 30]);
311
+ add("coral", [255, 127, 80]);
312
+ add("cornflowerblue", [100, 149, 237]);
313
+ add("cornsilk", [255, 248, 220]);
314
+ add("crimson", [220, 20, 60]);
315
+ add("cyan", [0, 255, 255]);
316
+ add("darkblue", [0, 0, 139]);
317
+ add("darkcyan", [0, 139, 139]);
318
+ add("darkgoldenrod", [184, 134, 11]);
319
+ add("darkgray", [169]);
320
+ add("darkgreen", [0, 100]);
321
+ add("darkgrey", [169]);
322
+ add("darkkhaki", [189, 183, 107]);
323
+ add("darkmagenta", [139, 0]);
324
+ add("darkolivegreen", [85, 107, 47]);
325
+ add("darkorange", [255, 140, 0]);
326
+ add("darkorchid", [153, 50, 204]);
327
+ add("darkred", [139, 0, 0]);
328
+ add("darksalmon", [233, 150, 122]);
329
+ add("darkseagreen", [143, 188]);
330
+ add("darkslateblue", [72, 61, 139]);
331
+ add("darkslategray", [47, 79, 79]);
332
+ add("darkslategrey", [47, 79, 79]);
333
+ add("darkturquoise", [0, 206, 209]);
334
+ add("darkviolet", [148, 0, 211]);
335
+ add("deeppink", [255, 20, 147]);
336
+ add("deepskyblue", [0, 191, 255]);
337
+ add("dimgray", [105]);
338
+ add("dimgrey", [105]);
339
+ add("dodgerblue", [30, 144, 255]);
340
+ add("firebrick", [178, 34, 34]);
341
+ add("floralwhite", [255, 250, 240]);
342
+ add("forestgreen", [34, 139]);
343
+ add("fuchsia", [255, 0]);
344
+ add("gainsboro", [220]);
345
+ add("ghostwhite", [248, 248, 255]);
346
+ add("gold", [255, 215, 0]);
347
+ add("goldenrod", [218, 165, 32]);
348
+ add("gray", [128]);
349
+ add("green", [0, 128]);
350
+ add("greenyellow", [173, 255, 47]);
351
+ add("grey", [128]);
352
+ add("honeydew", [240, 255]);
353
+ add("hotpink", [255, 105, 180]);
354
+ add("indianred", [205, 92, 92]);
355
+ add("indigo", [75, 0, 130]);
356
+ add("ivory", [255, 255, 240]);
357
+ add("khaki", [240, 230, 140]);
358
+ add("lavender", [230, 230, 250]);
359
+ add("lavenderblush", [255, 240, 245]);
360
+ add("lawngreen", [124, 252, 0]);
361
+ add("lemonchiffon", [255, 250, 205]);
362
+ add("lightblue", [173, 216, 230]);
363
+ add("lightcoral", [240, 128, 128]);
364
+ add("lightcyan", [224, 255, 255]);
365
+ add("lightgoldenrodyellow", [250, 250, 210]);
366
+ add("lightgray", [211]);
367
+ add("lightgreen", [144, 238]);
368
+ add("lightgrey", [211]);
369
+ add("lightpink", [255, 182, 193]);
370
+ add("lightsalmon", [255, 160, 122]);
371
+ add("lightseagreen", [32, 178, 170]);
372
+ add("lightskyblue", [135, 206, 250]);
373
+ add("lightslategray", [119, 136, 153]);
374
+ add("lightslategrey", [119, 136, 153]);
375
+ add("lightsteelblue", [176, 196, 222]);
376
+ add("lightyellow", [255, 255, 224]);
377
+ add("lime", [0, 255]);
378
+ add("limegreen", [50, 205]);
379
+ add("linen", [250, 240, 230]);
380
+ add("magenta", [255, 0]);
381
+ add("maroon", [128, 0, 0]);
382
+ add("mediumaquamarine", [102, 205, 170]);
383
+ add("mediumblue", [0, 0, 205]);
384
+ add("mediumorchid", [186, 85, 211]);
385
+ add("mediumpurple", [147, 112, 219]);
386
+ add("mediumseagreen", [60, 179, 113]);
387
+ add("mediumslateblue", [123, 104, 238]);
388
+ add("mediumspringgreen", [0, 250, 154]);
389
+ add("mediumturquoise", [72, 209, 204]);
390
+ add("mediumvioletred", [199, 21, 133]);
391
+ add("midnightblue", [25, 25, 112]);
392
+ add("mintcream", [245, 255, 250]);
393
+ add("mistyrose", [255, 228, 225]);
394
+ add("moccasin", [255, 228, 181]);
395
+ add("navajowhite", [255, 222, 173]);
396
+ add("navy", [0, 0, 128]);
397
+ add("oldlace", [253, 245, 230]);
398
+ add("olive", [128, 128, 0]);
399
+ add("olivedrab", [107, 142, 35]);
400
+ add("orange", [255, 165, 0]);
401
+ add("orangered", [255, 69, 0]);
402
+ add("orchid", [218, 112, 214]);
403
+ add("palegoldenrod", [238, 232, 170]);
404
+ add("palegreen", [152, 251]);
405
+ add("paleturquoise", [175, 238, 238]);
406
+ add("palevioletred", [219, 112, 147]);
407
+ add("papayawhip", [255, 239, 213]);
408
+ add("peachpuff", [255, 218, 185]);
409
+ add("peru", [205, 133, 63]);
410
+ add("pink", [255, 192, 203]);
411
+ add("plum", [221, 160]);
412
+ add("powderblue", [176, 224, 230]);
413
+ add("purple", [128, 0]);
414
+ add("rebeccapurple", [102, 51, 153]);
415
+ add("red", [255, 0, 0]);
416
+ add("rosybrown", [188, 143, 143]);
417
+ add("royalblue", [65, 105, 225]);
418
+ add("saddlebrown", [139, 69, 19]);
419
+ add("salmon", [250, 128, 114]);
420
+ add("sandybrown", [244, 164, 96]);
421
+ add("seagreen", [46, 139, 87]);
422
+ add("seashell", [255, 245, 238]);
423
+ add("sienna", [160, 82, 45]);
424
+ add("silver", [192]);
425
+ add("skyblue", [135, 206, 235]);
426
+ add("slateblue", [106, 90, 205]);
427
+ add("slategray", [112, 128, 144]);
428
+ add("slategrey", [112, 128, 144]);
429
+ add("snow", [255, 250, 250]);
430
+ add("springgreen", [0, 255, 127]);
431
+ add("steelblue", [70, 130, 180]);
432
+ add("tan", [210, 180, 140]);
433
+ add("teal", [0, 128, 128]);
434
+ add("thistle", [216, 191]);
435
+ add("tomato", [255, 99, 71]);
436
+ add("turquoise", [64, 224, 208]);
437
+ add("violet", [238, 130]);
438
+ add("wheat", [245, 222, 179]);
439
+ add("white", [255]);
440
+ add("whitesmoke", [245]);
441
+ add("yellow", [255, 255, 0]);
442
+ add("yellowgreen", [154, 205, 50]);
443
+
255
444
  const svgWidthRegex = /width\s*=\s*["'](\w+)["']/;
256
445
  const svgHeightRegex = /height\s*=\s*["'](\w+)["']/;
257
446
  function configureSvgSize(svg, props, scale) {
@@ -12,6 +12,9 @@ const defaults = Object.freeze({
12
12
  rotate: 0
13
13
  });
14
14
 
15
+ const allKeys = Object.keys(defaults);
16
+ allKeys.filter((key) => key !== "width" && key !== "height");
17
+
15
18
  const iconDefaults = Object.freeze({
16
19
  left: 0,
17
20
  top: 0,
@@ -85,6 +88,14 @@ function getIconData(data, name, full = false) {
85
88
  return result && full ? fullIcon(result) : result;
86
89
  }
87
90
 
91
+ for (const prop in iconDefaults) {
92
+ typeof iconDefaults[prop];
93
+ }
94
+
95
+ Object.keys(iconDefaults).concat([
96
+ "provider"
97
+ ]);
98
+
88
99
  const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
89
100
  const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
90
101
  function calculateSize(size, ratio, precision) {
@@ -246,10 +257,188 @@ function iconToSVG(icon, customisations) {
246
257
  return result;
247
258
  }
248
259
 
260
+ "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
261
+
249
262
  function trimSVG(str) {
250
263
  return str.replace(/(["';{}><])\s*\n\s*/g, "$1").replace(/\s*\n\s*/g, " ").replace(/\s+"/g, '"').replace(/="\s+/g, '="').trim();
251
264
  }
252
265
 
266
+ function add(keyword, colors) {
267
+ const type = "rgb";
268
+ const r = colors[0];
269
+ const length = colors.length;
270
+ ({
271
+ type,
272
+ r,
273
+ g: length > 1 ? colors[1] : r,
274
+ b: length > 2 ? colors[2] : r,
275
+ alpha: length > 3 ? colors[3] : 1
276
+ });
277
+ }
278
+ add("silver", [192]);
279
+ add("gray", [128]);
280
+ add("white", [255]);
281
+ add("maroon", [128, 0, 0]);
282
+ add("red", [255, 0, 0]);
283
+ add("purple", [128, 0]);
284
+ add("fuchsia", [255, 0]);
285
+ add("green", [0, 128]);
286
+ add("lime", [0, 255]);
287
+ add("olive", [128, 128, 0]);
288
+ add("yellow", [255, 255, 0]);
289
+ add("navy", [0, 0, 128]);
290
+ add("blue", [0, 0, 255]);
291
+ add("teal", [0, 128, 128]);
292
+ add("aqua", [0, 255, 255]);
293
+ add("aliceblue", [240, 248, 255]);
294
+ add("antiquewhite", [250, 235, 215]);
295
+ add("aqua", [0, 255, 255]);
296
+ add("aquamarine", [127, 255, 212]);
297
+ add("azure", [240, 255, 255]);
298
+ add("beige", [245, 245, 220]);
299
+ add("bisque", [255, 228, 196]);
300
+ add("black", [0]);
301
+ add("blanchedalmond", [255, 235, 205]);
302
+ add("blue", [0, 0, 255]);
303
+ add("blueviolet", [138, 43, 226]);
304
+ add("brown", [165, 42, 42]);
305
+ add("burlywood", [222, 184, 135]);
306
+ add("cadetblue", [95, 158, 160]);
307
+ add("chartreuse", [127, 255, 0]);
308
+ add("chocolate", [210, 105, 30]);
309
+ add("coral", [255, 127, 80]);
310
+ add("cornflowerblue", [100, 149, 237]);
311
+ add("cornsilk", [255, 248, 220]);
312
+ add("crimson", [220, 20, 60]);
313
+ add("cyan", [0, 255, 255]);
314
+ add("darkblue", [0, 0, 139]);
315
+ add("darkcyan", [0, 139, 139]);
316
+ add("darkgoldenrod", [184, 134, 11]);
317
+ add("darkgray", [169]);
318
+ add("darkgreen", [0, 100]);
319
+ add("darkgrey", [169]);
320
+ add("darkkhaki", [189, 183, 107]);
321
+ add("darkmagenta", [139, 0]);
322
+ add("darkolivegreen", [85, 107, 47]);
323
+ add("darkorange", [255, 140, 0]);
324
+ add("darkorchid", [153, 50, 204]);
325
+ add("darkred", [139, 0, 0]);
326
+ add("darksalmon", [233, 150, 122]);
327
+ add("darkseagreen", [143, 188]);
328
+ add("darkslateblue", [72, 61, 139]);
329
+ add("darkslategray", [47, 79, 79]);
330
+ add("darkslategrey", [47, 79, 79]);
331
+ add("darkturquoise", [0, 206, 209]);
332
+ add("darkviolet", [148, 0, 211]);
333
+ add("deeppink", [255, 20, 147]);
334
+ add("deepskyblue", [0, 191, 255]);
335
+ add("dimgray", [105]);
336
+ add("dimgrey", [105]);
337
+ add("dodgerblue", [30, 144, 255]);
338
+ add("firebrick", [178, 34, 34]);
339
+ add("floralwhite", [255, 250, 240]);
340
+ add("forestgreen", [34, 139]);
341
+ add("fuchsia", [255, 0]);
342
+ add("gainsboro", [220]);
343
+ add("ghostwhite", [248, 248, 255]);
344
+ add("gold", [255, 215, 0]);
345
+ add("goldenrod", [218, 165, 32]);
346
+ add("gray", [128]);
347
+ add("green", [0, 128]);
348
+ add("greenyellow", [173, 255, 47]);
349
+ add("grey", [128]);
350
+ add("honeydew", [240, 255]);
351
+ add("hotpink", [255, 105, 180]);
352
+ add("indianred", [205, 92, 92]);
353
+ add("indigo", [75, 0, 130]);
354
+ add("ivory", [255, 255, 240]);
355
+ add("khaki", [240, 230, 140]);
356
+ add("lavender", [230, 230, 250]);
357
+ add("lavenderblush", [255, 240, 245]);
358
+ add("lawngreen", [124, 252, 0]);
359
+ add("lemonchiffon", [255, 250, 205]);
360
+ add("lightblue", [173, 216, 230]);
361
+ add("lightcoral", [240, 128, 128]);
362
+ add("lightcyan", [224, 255, 255]);
363
+ add("lightgoldenrodyellow", [250, 250, 210]);
364
+ add("lightgray", [211]);
365
+ add("lightgreen", [144, 238]);
366
+ add("lightgrey", [211]);
367
+ add("lightpink", [255, 182, 193]);
368
+ add("lightsalmon", [255, 160, 122]);
369
+ add("lightseagreen", [32, 178, 170]);
370
+ add("lightskyblue", [135, 206, 250]);
371
+ add("lightslategray", [119, 136, 153]);
372
+ add("lightslategrey", [119, 136, 153]);
373
+ add("lightsteelblue", [176, 196, 222]);
374
+ add("lightyellow", [255, 255, 224]);
375
+ add("lime", [0, 255]);
376
+ add("limegreen", [50, 205]);
377
+ add("linen", [250, 240, 230]);
378
+ add("magenta", [255, 0]);
379
+ add("maroon", [128, 0, 0]);
380
+ add("mediumaquamarine", [102, 205, 170]);
381
+ add("mediumblue", [0, 0, 205]);
382
+ add("mediumorchid", [186, 85, 211]);
383
+ add("mediumpurple", [147, 112, 219]);
384
+ add("mediumseagreen", [60, 179, 113]);
385
+ add("mediumslateblue", [123, 104, 238]);
386
+ add("mediumspringgreen", [0, 250, 154]);
387
+ add("mediumturquoise", [72, 209, 204]);
388
+ add("mediumvioletred", [199, 21, 133]);
389
+ add("midnightblue", [25, 25, 112]);
390
+ add("mintcream", [245, 255, 250]);
391
+ add("mistyrose", [255, 228, 225]);
392
+ add("moccasin", [255, 228, 181]);
393
+ add("navajowhite", [255, 222, 173]);
394
+ add("navy", [0, 0, 128]);
395
+ add("oldlace", [253, 245, 230]);
396
+ add("olive", [128, 128, 0]);
397
+ add("olivedrab", [107, 142, 35]);
398
+ add("orange", [255, 165, 0]);
399
+ add("orangered", [255, 69, 0]);
400
+ add("orchid", [218, 112, 214]);
401
+ add("palegoldenrod", [238, 232, 170]);
402
+ add("palegreen", [152, 251]);
403
+ add("paleturquoise", [175, 238, 238]);
404
+ add("palevioletred", [219, 112, 147]);
405
+ add("papayawhip", [255, 239, 213]);
406
+ add("peachpuff", [255, 218, 185]);
407
+ add("peru", [205, 133, 63]);
408
+ add("pink", [255, 192, 203]);
409
+ add("plum", [221, 160]);
410
+ add("powderblue", [176, 224, 230]);
411
+ add("purple", [128, 0]);
412
+ add("rebeccapurple", [102, 51, 153]);
413
+ add("red", [255, 0, 0]);
414
+ add("rosybrown", [188, 143, 143]);
415
+ add("royalblue", [65, 105, 225]);
416
+ add("saddlebrown", [139, 69, 19]);
417
+ add("salmon", [250, 128, 114]);
418
+ add("sandybrown", [244, 164, 96]);
419
+ add("seagreen", [46, 139, 87]);
420
+ add("seashell", [255, 245, 238]);
421
+ add("sienna", [160, 82, 45]);
422
+ add("silver", [192]);
423
+ add("skyblue", [135, 206, 235]);
424
+ add("slateblue", [106, 90, 205]);
425
+ add("slategray", [112, 128, 144]);
426
+ add("slategrey", [112, 128, 144]);
427
+ add("snow", [255, 250, 250]);
428
+ add("springgreen", [0, 255, 127]);
429
+ add("steelblue", [70, 130, 180]);
430
+ add("tan", [210, 180, 140]);
431
+ add("teal", [0, 128, 128]);
432
+ add("thistle", [216, 191]);
433
+ add("tomato", [255, 99, 71]);
434
+ add("turquoise", [64, 224, 208]);
435
+ add("violet", [238, 130]);
436
+ add("wheat", [245, 222, 179]);
437
+ add("white", [255]);
438
+ add("whitesmoke", [245]);
439
+ add("yellow", [255, 255, 0]);
440
+ add("yellowgreen", [154, 205, 50]);
441
+
253
442
  const svgWidthRegex = /width\s*=\s*["'](\w+)["']/;
254
443
  const svgHeightRegex = /height\s*=\s*["'](\w+)["']/;
255
444
  function configureSvgSize(svg, props, scale) {
package/dist/core.cjs CHANGED
@@ -110,5 +110,15 @@ function createPresetIcons(lookupIconLoader) {
110
110
  };
111
111
  };
112
112
  }
113
+ function combineLoaders(loaders) {
114
+ return (...args) => {
115
+ for (const loader of loaders) {
116
+ const result = loader(...args);
117
+ if (result)
118
+ return result;
119
+ }
120
+ };
121
+ }
113
122
 
123
+ exports.combineLoaders = combineLoaders;
114
124
  exports.createPresetIcons = createPresetIcons;
package/dist/core.d.ts CHANGED
@@ -78,5 +78,6 @@ interface IconsOptions {
78
78
  }
79
79
 
80
80
  declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): (options?: IconsOptions) => Preset;
81
+ declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
81
82
 
82
- export { IconsOptions, createPresetIcons };
83
+ export { IconsOptions, combineLoaders, createPresetIcons };
package/dist/core.mjs CHANGED
@@ -106,5 +106,14 @@ function createPresetIcons(lookupIconLoader) {
106
106
  };
107
107
  };
108
108
  }
109
+ function combineLoaders(loaders) {
110
+ return (...args) => {
111
+ for (const loader of loaders) {
112
+ const result = loader(...args);
113
+ if (result)
114
+ return result;
115
+ }
116
+ };
117
+ }
109
118
 
110
- export { createPresetIcons };
119
+ export { combineLoaders, createPresetIcons };
package/dist/index.cjs CHANGED
@@ -10,25 +10,30 @@ require('@unocss/core');
10
10
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions.deno;
11
11
  const isVSCode = isNode && !!process.env.VSCODE_CWD;
12
12
 
13
+ async function createNodeLoader() {
14
+ try {
15
+ return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
16
+ } catch {
17
+ }
18
+ try {
19
+ return require("@iconify/utils/lib/loader/node-loader.cjs");
20
+ } catch {
21
+ }
22
+ }
13
23
  const presetIcons = core.createPresetIcons(async (options) => {
14
24
  const {
15
25
  cdn: cdn$1
16
26
  } = options;
27
+ const loaders = [];
28
+ if (isNode && !isVSCode)
29
+ loaders.push(await createNodeLoader());
17
30
  if (cdn$1)
18
- return cdn.createCDNLoader(cdn$1);
19
- if (isNode && !isVSCode) {
20
- try {
21
- return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
22
- } catch {
23
- }
24
- try {
25
- return require("@iconify/utils/lib/loader/node-loader.cjs");
26
- } catch {
27
- }
28
- }
29
- return cdn.loadIcon;
31
+ loaders.push(cdn.createCDNLoader(cdn$1));
32
+ loaders.push(cdn.loadIcon);
33
+ return core.combineLoaders(loaders);
30
34
  });
31
35
 
36
+ exports.combineLoaders = core.combineLoaders;
32
37
  exports.createPresetIcons = core.createPresetIcons;
33
38
  exports["default"] = presetIcons;
34
39
  exports.presetIcons = presetIcons;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { IconsOptions } from './core.js';
3
- export { IconsOptions, createPresetIcons } from './core.js';
3
+ export { IconsOptions, combineLoaders, createPresetIcons } from './core.js';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
package/dist/index.mjs CHANGED
@@ -1,29 +1,33 @@
1
1
  import { c as createCDNLoader, l as loadIcon } from './chunks/cdn.mjs';
2
- import { createPresetIcons } from './core.mjs';
3
- export { createPresetIcons } from './core.mjs';
2
+ import { createPresetIcons, combineLoaders } from './core.mjs';
3
+ export { combineLoaders, createPresetIcons } from './core.mjs';
4
4
  import 'ohmyfetch';
5
5
  import '@unocss/core';
6
6
 
7
7
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions.deno;
8
8
  const isVSCode = isNode && !!process.env.VSCODE_CWD;
9
9
 
10
+ async function createNodeLoader() {
11
+ try {
12
+ return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
13
+ } catch {
14
+ }
15
+ try {
16
+ return require("@iconify/utils/lib/loader/node-loader.cjs");
17
+ } catch {
18
+ }
19
+ }
10
20
  const presetIcons = createPresetIcons(async (options) => {
11
21
  const {
12
22
  cdn
13
23
  } = options;
24
+ const loaders = [];
25
+ if (isNode && !isVSCode)
26
+ loaders.push(await createNodeLoader());
14
27
  if (cdn)
15
- return createCDNLoader(cdn);
16
- if (isNode && !isVSCode) {
17
- try {
18
- return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
19
- } catch {
20
- }
21
- try {
22
- return require("@iconify/utils/lib/loader/node-loader.cjs");
23
- } catch {
24
- }
25
- }
26
- return loadIcon;
28
+ loaders.push(createCDNLoader(cdn));
29
+ loaders.push(loadIcon);
30
+ return combineLoaders(loaders);
27
31
  });
28
32
 
29
33
  export { presetIcons as default, presetIcons };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-icons",
3
- "version": "0.44.7",
3
+ "version": "0.45.4",
4
4
  "description": "Pure CSS Icons for UnoCSS",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  ],
49
49
  "dependencies": {
50
50
  "@iconify/utils": "^1.0.33",
51
- "@unocss/core": "0.44.7",
51
+ "@unocss/core": "0.45.4",
52
52
  "ohmyfetch": "^0.4.18"
53
53
  },
54
54
  "devDependencies": {