@unocss/preset-icons 0.55.1 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cdn = require('./shared/preset-icons.31963db2.cjs');
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');
@@ -16,5 +16,5 @@ const presetIcons = core.createPresetIcons(async (options) => {
16
16
 
17
17
  exports.combineLoaders = core.combineLoaders;
18
18
  exports.createPresetIcons = core.createPresetIcons;
19
- exports["default"] = presetIcons;
19
+ exports.default = presetIcons;
20
20
  exports.presetIcons = presetIcons;
@@ -0,0 +1,9 @@
1
+ import * as _unocss_core from '@unocss/core';
2
+ import { IconsOptions } from './core.cjs';
3
+ export { combineLoaders, createPresetIcons } from './core.cjs';
4
+ import '@iconify/utils/lib/loader/types';
5
+ import '@iconify/types';
6
+
7
+ declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<object>;
8
+
9
+ export { IconsOptions, presetIcons as default, presetIcons };
@@ -0,0 +1,9 @@
1
+ import * as _unocss_core from '@unocss/core';
2
+ import { IconsOptions } from './core.mjs';
3
+ export { combineLoaders, createPresetIcons } from './core.mjs';
4
+ import '@iconify/utils/lib/loader/types';
5
+ import '@iconify/types';
6
+
7
+ declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<object>;
8
+
9
+ export { IconsOptions, presetIcons as default, presetIcons };
package/dist/browser.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { IconsOptions } from './core.js';
3
- export { IconsOptions, combineLoaders, createPresetIcons } from './core.js';
3
+ export { combineLoaders, createPresetIcons } from './core.js';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
7
7
  declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<object>;
8
8
 
9
- export { presetIcons as default, presetIcons };
9
+ export { IconsOptions, presetIcons as default, presetIcons };
package/dist/browser.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.ab54575d.mjs';
1
+ import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.05307f91.mjs';
2
2
  import { createPresetIcons } from './core.mjs';
3
- export { combineLoaders, createPresetIcons } from './core.mjs';
3
+ export { combineLoaders } from './core.mjs';
4
4
  import 'ofetch';
5
5
  import '@unocss/core';
6
6
 
@@ -11,4 +11,4 @@ const presetIcons = createPresetIcons(async (options) => {
11
11
  return loadIcon;
12
12
  });
13
13
 
14
- export { presetIcons as default, presetIcons };
14
+ export { createPresetIcons, presetIcons as default, presetIcons };
package/dist/core.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  const core = require('@unocss/core');
6
4
 
7
5
  function encodeSVGforURL(svg) {
@@ -45,6 +43,7 @@ function createPresetIcons(lookupIconLoader) {
45
43
  scale,
46
44
  customCollections,
47
45
  autoInstall,
46
+ // avoid warn from @iconify/loader: we'll warn below if not found
48
47
  warn: void 0,
49
48
  customizations: {
50
49
  ...customizations,
@@ -104,6 +103,7 @@ function createPresetIcons(lookupIconLoader) {
104
103
  "-webkit-mask-size": "100% 100%",
105
104
  "mask-size": "100% 100%",
106
105
  "background-color": "currentColor",
106
+ // for Safari https://github.com/elk-zone/elk/pull/264
107
107
  "color": "inherit",
108
108
  ...usedProps
109
109
  };
@@ -0,0 +1,83 @@
1
+ import { Awaitable, Preset } from '@unocss/core';
2
+ import { CustomIconLoader, InlineCollection, IconCustomizations, UniversalIconLoader } from '@iconify/utils/lib/loader/types';
3
+ import { IconifyJSON } from '@iconify/types';
4
+
5
+ interface IconsOptions {
6
+ /**
7
+ * Scale related to the current font size (1em).
8
+ *
9
+ * @default 1
10
+ */
11
+ scale?: number;
12
+ /**
13
+ * Mode of generated CSS icons.
14
+ *
15
+ * - `mask` - use background color and the `mask` property for monochrome icons
16
+ * - `background-img` - use background image for the icons, colors are static
17
+ * - `auto` - smartly decide mode between `mask` and `background-img` per icon based on its style
18
+ *
19
+ * @default 'auto'
20
+ * @see https://antfu.me/posts/icons-in-pure-css
21
+ */
22
+ mode?: 'mask' | 'background-img' | 'auto';
23
+ /**
24
+ * Class prefix for matching icon rules.
25
+ *
26
+ * @default `i-`
27
+ */
28
+ prefix?: string | string[];
29
+ /**
30
+ * Extra CSS properties applied to the generated CSS
31
+ *
32
+ * @default {}
33
+ */
34
+ extraProperties?: Record<string, string>;
35
+ /**
36
+ * Emit warning when missing icons are matched
37
+ *
38
+ * @default false
39
+ */
40
+ warn?: boolean;
41
+ /**
42
+ * In Node.js environment, the preset will search for the installed iconify dataset automatically.
43
+ * When using in the browser, this options is provided to provide dataset with custom loading mechanism.
44
+ */
45
+ collections?: Record<string, (() => Awaitable<IconifyJSON>) | undefined | CustomIconLoader | InlineCollection>;
46
+ /**
47
+ * Rule layer
48
+ *
49
+ * @default 'icons'
50
+ */
51
+ layer?: string;
52
+ /**
53
+ * Custom icon customizations.
54
+ */
55
+ customizations?: Omit<IconCustomizations, 'additionalProps' | 'trimCustomSvg'>;
56
+ /**
57
+ * Auto install icon sources package when the usages is detected
58
+ *
59
+ * **WARNING**: only on `node` environment, on `browser` this option will be ignored.
60
+ *
61
+ * @default false
62
+ */
63
+ autoInstall?: boolean;
64
+ /**
65
+ * Custom icon unit.
66
+ *
67
+ * @default `em`
68
+ */
69
+ unit?: string;
70
+ /**
71
+ * Load icons from CDN. Should starts with `https://` and ends with `/`
72
+ *
73
+ * Recommends:
74
+ * - https://esm.sh/
75
+ * - https://cdn.skypack.dev/
76
+ */
77
+ cdn?: string;
78
+ }
79
+
80
+ declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): (options?: IconsOptions) => Preset;
81
+ declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
82
+
83
+ export { type IconsOptions, combineLoaders, createPresetIcons };
@@ -0,0 +1,83 @@
1
+ import { Awaitable, Preset } from '@unocss/core';
2
+ import { CustomIconLoader, InlineCollection, IconCustomizations, UniversalIconLoader } from '@iconify/utils/lib/loader/types';
3
+ import { IconifyJSON } from '@iconify/types';
4
+
5
+ interface IconsOptions {
6
+ /**
7
+ * Scale related to the current font size (1em).
8
+ *
9
+ * @default 1
10
+ */
11
+ scale?: number;
12
+ /**
13
+ * Mode of generated CSS icons.
14
+ *
15
+ * - `mask` - use background color and the `mask` property for monochrome icons
16
+ * - `background-img` - use background image for the icons, colors are static
17
+ * - `auto` - smartly decide mode between `mask` and `background-img` per icon based on its style
18
+ *
19
+ * @default 'auto'
20
+ * @see https://antfu.me/posts/icons-in-pure-css
21
+ */
22
+ mode?: 'mask' | 'background-img' | 'auto';
23
+ /**
24
+ * Class prefix for matching icon rules.
25
+ *
26
+ * @default `i-`
27
+ */
28
+ prefix?: string | string[];
29
+ /**
30
+ * Extra CSS properties applied to the generated CSS
31
+ *
32
+ * @default {}
33
+ */
34
+ extraProperties?: Record<string, string>;
35
+ /**
36
+ * Emit warning when missing icons are matched
37
+ *
38
+ * @default false
39
+ */
40
+ warn?: boolean;
41
+ /**
42
+ * In Node.js environment, the preset will search for the installed iconify dataset automatically.
43
+ * When using in the browser, this options is provided to provide dataset with custom loading mechanism.
44
+ */
45
+ collections?: Record<string, (() => Awaitable<IconifyJSON>) | undefined | CustomIconLoader | InlineCollection>;
46
+ /**
47
+ * Rule layer
48
+ *
49
+ * @default 'icons'
50
+ */
51
+ layer?: string;
52
+ /**
53
+ * Custom icon customizations.
54
+ */
55
+ customizations?: Omit<IconCustomizations, 'additionalProps' | 'trimCustomSvg'>;
56
+ /**
57
+ * Auto install icon sources package when the usages is detected
58
+ *
59
+ * **WARNING**: only on `node` environment, on `browser` this option will be ignored.
60
+ *
61
+ * @default false
62
+ */
63
+ autoInstall?: boolean;
64
+ /**
65
+ * Custom icon unit.
66
+ *
67
+ * @default `em`
68
+ */
69
+ unit?: string;
70
+ /**
71
+ * Load icons from CDN. Should starts with `https://` and ends with `/`
72
+ *
73
+ * Recommends:
74
+ * - https://esm.sh/
75
+ * - https://cdn.skypack.dev/
76
+ */
77
+ cdn?: string;
78
+ }
79
+
80
+ declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): (options?: IconsOptions) => Preset;
81
+ declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
82
+
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/core.mjs CHANGED
@@ -41,6 +41,7 @@ function createPresetIcons(lookupIconLoader) {
41
41
  scale,
42
42
  customCollections,
43
43
  autoInstall,
44
+ // avoid warn from @iconify/loader: we'll warn below if not found
44
45
  warn: void 0,
45
46
  customizations: {
46
47
  ...customizations,
@@ -100,6 +101,7 @@ function createPresetIcons(lookupIconLoader) {
100
101
  "-webkit-mask-size": "100% 100%",
101
102
  "mask-size": "100% 100%",
102
103
  "background-color": "currentColor",
104
+ // for Safari https://github.com/elk-zone/elk/pull/264
103
105
  "color": "inherit",
104
106
  ...usedProps
105
107
  };
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.31963db2.cjs');
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');
@@ -38,5 +38,5 @@ const presetIcons = core.createPresetIcons(async (options) => {
38
38
 
39
39
  exports.combineLoaders = core.combineLoaders;
40
40
  exports.createPresetIcons = core.createPresetIcons;
41
- exports["default"] = presetIcons;
41
+ exports.default = presetIcons;
42
42
  exports.presetIcons = presetIcons;
@@ -0,0 +1,9 @@
1
+ import * as _unocss_core from '@unocss/core';
2
+ import { IconsOptions } from './core.cjs';
3
+ export { combineLoaders, createPresetIcons } from './core.cjs';
4
+ import '@iconify/utils/lib/loader/types';
5
+ import '@iconify/types';
6
+
7
+ declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<object>;
8
+
9
+ export { IconsOptions, presetIcons as default, presetIcons };
@@ -0,0 +1,9 @@
1
+ import * as _unocss_core from '@unocss/core';
2
+ import { IconsOptions } from './core.mjs';
3
+ export { combineLoaders, createPresetIcons } from './core.mjs';
4
+ import '@iconify/utils/lib/loader/types';
5
+ import '@iconify/types';
6
+
7
+ declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<object>;
8
+
9
+ export { IconsOptions, presetIcons as default, presetIcons };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { IconsOptions } from './core.js';
3
- export { IconsOptions, combineLoaders, createPresetIcons } from './core.js';
3
+ export { combineLoaders, createPresetIcons } from './core.js';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
7
7
  declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<object>;
8
8
 
9
- export { presetIcons as default, presetIcons };
9
+ export { IconsOptions, presetIcons as default, presetIcons };
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.ab54575d.mjs';
1
+ import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.05307f91.mjs';
2
2
  import { createPresetIcons, combineLoaders } from './core.mjs';
3
- export { combineLoaders, createPresetIcons } from './core.mjs';
4
3
  import 'ofetch';
5
4
  import '@unocss/core';
6
5
 
@@ -33,4 +32,4 @@ const presetIcons = createPresetIcons(async (options) => {
33
32
  return combineLoaders(loaders);
34
33
  });
35
34
 
36
- export { presetIcons as default, presetIcons };
35
+ export { combineLoaders, createPresetIcons, presetIcons as default, presetIcons };
@@ -111,17 +111,6 @@ function getIconData(data, name) {
111
111
  return tree ? internalGetIconData(data, name, tree) : null;
112
112
  }
113
113
 
114
- ({
115
- provider: "",
116
- aliases: {},
117
- not_found: {},
118
- ...defaultIconDimensions
119
- });
120
-
121
- Object.keys(defaultIconDimensions).concat([
122
- "provider"
123
- ]);
124
-
125
114
  const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
126
115
  const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
127
116
  function calculateSize(size, ratio, precision) {
@@ -161,6 +150,32 @@ function calculateSize(size, ratio, precision) {
161
150
  }
162
151
  }
163
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
+
164
179
  const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
165
180
  function iconToSVG(icon, customisations) {
166
181
  const fullIcon = {
@@ -237,7 +252,11 @@ function iconToSVG(icon, customisations) {
237
252
  }
238
253
  }
239
254
  if (transformations.length) {
240
- body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
255
+ body = wrapSVGContent(
256
+ body,
257
+ '<g transform="' + transformations.join(" ") + '">',
258
+ "</g>"
259
+ );
241
260
  }
242
261
  });
243
262
  const customisationsWidth = fullCustomisations.width;
@@ -261,195 +280,19 @@ function iconToSVG(icon, customisations) {
261
280
  };
262
281
  setAttr("width", width);
263
282
  setAttr("height", height);
264
- attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
283
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
284
+ attributes.viewBox = viewBox.join(" ");
265
285
  return {
266
286
  attributes,
287
+ viewBox,
267
288
  body
268
289
  };
269
290
  }
270
291
 
271
- "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
272
-
273
292
  function trimSVG(str) {
274
293
  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, '="').trim();
275
294
  }
276
295
 
277
- function add(keyword, colors) {
278
- const type = "rgb";
279
- const r = colors[0];
280
- const length = colors.length;
281
- ({
282
- type,
283
- r,
284
- g: length > 1 ? colors[1] : r,
285
- b: length > 2 ? colors[2] : r,
286
- alpha: length > 3 ? colors[3] : 1
287
- });
288
- }
289
- add("silver", [192]);
290
- add("gray", [128]);
291
- add("white", [255]);
292
- add("maroon", [128, 0, 0]);
293
- add("red", [255, 0, 0]);
294
- add("purple", [128, 0]);
295
- add("fuchsia", [255, 0]);
296
- add("green", [0, 128]);
297
- add("lime", [0, 255]);
298
- add("olive", [128, 128, 0]);
299
- add("yellow", [255, 255, 0]);
300
- add("navy", [0, 0, 128]);
301
- add("blue", [0, 0, 255]);
302
- add("teal", [0, 128, 128]);
303
- add("aqua", [0, 255, 255]);
304
- add("aliceblue", [240, 248, 255]);
305
- add("antiquewhite", [250, 235, 215]);
306
- add("aqua", [0, 255, 255]);
307
- add("aquamarine", [127, 255, 212]);
308
- add("azure", [240, 255, 255]);
309
- add("beige", [245, 245, 220]);
310
- add("bisque", [255, 228, 196]);
311
- add("black", [0]);
312
- add("blanchedalmond", [255, 235, 205]);
313
- add("blue", [0, 0, 255]);
314
- add("blueviolet", [138, 43, 226]);
315
- add("brown", [165, 42, 42]);
316
- add("burlywood", [222, 184, 135]);
317
- add("cadetblue", [95, 158, 160]);
318
- add("chartreuse", [127, 255, 0]);
319
- add("chocolate", [210, 105, 30]);
320
- add("coral", [255, 127, 80]);
321
- add("cornflowerblue", [100, 149, 237]);
322
- add("cornsilk", [255, 248, 220]);
323
- add("crimson", [220, 20, 60]);
324
- add("cyan", [0, 255, 255]);
325
- add("darkblue", [0, 0, 139]);
326
- add("darkcyan", [0, 139, 139]);
327
- add("darkgoldenrod", [184, 134, 11]);
328
- add("darkgray", [169]);
329
- add("darkgreen", [0, 100]);
330
- add("darkgrey", [169]);
331
- add("darkkhaki", [189, 183, 107]);
332
- add("darkmagenta", [139, 0]);
333
- add("darkolivegreen", [85, 107, 47]);
334
- add("darkorange", [255, 140, 0]);
335
- add("darkorchid", [153, 50, 204]);
336
- add("darkred", [139, 0, 0]);
337
- add("darksalmon", [233, 150, 122]);
338
- add("darkseagreen", [143, 188]);
339
- add("darkslateblue", [72, 61, 139]);
340
- add("darkslategray", [47, 79, 79]);
341
- add("darkslategrey", [47, 79, 79]);
342
- add("darkturquoise", [0, 206, 209]);
343
- add("darkviolet", [148, 0, 211]);
344
- add("deeppink", [255, 20, 147]);
345
- add("deepskyblue", [0, 191, 255]);
346
- add("dimgray", [105]);
347
- add("dimgrey", [105]);
348
- add("dodgerblue", [30, 144, 255]);
349
- add("firebrick", [178, 34, 34]);
350
- add("floralwhite", [255, 250, 240]);
351
- add("forestgreen", [34, 139]);
352
- add("fuchsia", [255, 0]);
353
- add("gainsboro", [220]);
354
- add("ghostwhite", [248, 248, 255]);
355
- add("gold", [255, 215, 0]);
356
- add("goldenrod", [218, 165, 32]);
357
- add("gray", [128]);
358
- add("green", [0, 128]);
359
- add("greenyellow", [173, 255, 47]);
360
- add("grey", [128]);
361
- add("honeydew", [240, 255]);
362
- add("hotpink", [255, 105, 180]);
363
- add("indianred", [205, 92, 92]);
364
- add("indigo", [75, 0, 130]);
365
- add("ivory", [255, 255, 240]);
366
- add("khaki", [240, 230, 140]);
367
- add("lavender", [230, 230, 250]);
368
- add("lavenderblush", [255, 240, 245]);
369
- add("lawngreen", [124, 252, 0]);
370
- add("lemonchiffon", [255, 250, 205]);
371
- add("lightblue", [173, 216, 230]);
372
- add("lightcoral", [240, 128, 128]);
373
- add("lightcyan", [224, 255, 255]);
374
- add("lightgoldenrodyellow", [250, 250, 210]);
375
- add("lightgray", [211]);
376
- add("lightgreen", [144, 238]);
377
- add("lightgrey", [211]);
378
- add("lightpink", [255, 182, 193]);
379
- add("lightsalmon", [255, 160, 122]);
380
- add("lightseagreen", [32, 178, 170]);
381
- add("lightskyblue", [135, 206, 250]);
382
- add("lightslategray", [119, 136, 153]);
383
- add("lightslategrey", [119, 136, 153]);
384
- add("lightsteelblue", [176, 196, 222]);
385
- add("lightyellow", [255, 255, 224]);
386
- add("lime", [0, 255]);
387
- add("limegreen", [50, 205]);
388
- add("linen", [250, 240, 230]);
389
- add("magenta", [255, 0]);
390
- add("maroon", [128, 0, 0]);
391
- add("mediumaquamarine", [102, 205, 170]);
392
- add("mediumblue", [0, 0, 205]);
393
- add("mediumorchid", [186, 85, 211]);
394
- add("mediumpurple", [147, 112, 219]);
395
- add("mediumseagreen", [60, 179, 113]);
396
- add("mediumslateblue", [123, 104, 238]);
397
- add("mediumspringgreen", [0, 250, 154]);
398
- add("mediumturquoise", [72, 209, 204]);
399
- add("mediumvioletred", [199, 21, 133]);
400
- add("midnightblue", [25, 25, 112]);
401
- add("mintcream", [245, 255, 250]);
402
- add("mistyrose", [255, 228, 225]);
403
- add("moccasin", [255, 228, 181]);
404
- add("navajowhite", [255, 222, 173]);
405
- add("navy", [0, 0, 128]);
406
- add("oldlace", [253, 245, 230]);
407
- add("olive", [128, 128, 0]);
408
- add("olivedrab", [107, 142, 35]);
409
- add("orange", [255, 165, 0]);
410
- add("orangered", [255, 69, 0]);
411
- add("orchid", [218, 112, 214]);
412
- add("palegoldenrod", [238, 232, 170]);
413
- add("palegreen", [152, 251]);
414
- add("paleturquoise", [175, 238, 238]);
415
- add("palevioletred", [219, 112, 147]);
416
- add("papayawhip", [255, 239, 213]);
417
- add("peachpuff", [255, 218, 185]);
418
- add("peru", [205, 133, 63]);
419
- add("pink", [255, 192, 203]);
420
- add("plum", [221, 160]);
421
- add("powderblue", [176, 224, 230]);
422
- add("purple", [128, 0]);
423
- add("rebeccapurple", [102, 51, 153]);
424
- add("red", [255, 0, 0]);
425
- add("rosybrown", [188, 143, 143]);
426
- add("royalblue", [65, 105, 225]);
427
- add("saddlebrown", [139, 69, 19]);
428
- add("salmon", [250, 128, 114]);
429
- add("sandybrown", [244, 164, 96]);
430
- add("seagreen", [46, 139, 87]);
431
- add("seashell", [255, 245, 238]);
432
- add("sienna", [160, 82, 45]);
433
- add("silver", [192]);
434
- add("skyblue", [135, 206, 235]);
435
- add("slateblue", [106, 90, 205]);
436
- add("slategray", [112, 128, 144]);
437
- add("slategrey", [112, 128, 144]);
438
- add("snow", [255, 250, 250]);
439
- add("springgreen", [0, 255, 127]);
440
- add("steelblue", [70, 130, 180]);
441
- add("tan", [210, 180, 140]);
442
- add("teal", [0, 128, 128]);
443
- add("thistle", [216, 191]);
444
- add("tomato", [255, 99, 71]);
445
- add("turquoise", [64, 224, 208]);
446
- add("violet", [238, 130]);
447
- add("wheat", [245, 222, 179]);
448
- add("white", [255]);
449
- add("whitesmoke", [245]);
450
- add("yellow", [255, 255, 0]);
451
- add("yellowgreen", [154, 205, 50]);
452
-
453
296
  const svgWidthRegex = /\swidth\s*=\s*["'](\w+)["']/;
454
297
  const svgHeightRegex = /\sheight\s*=\s*["'](\w+)["']/;
455
298
  const svgTagRegex = /<svg\s+/;
@@ -526,11 +369,19 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
526
369
 
527
370
  async function getCustomIcon(custom, collection, icon, options) {
528
371
  let result;
529
- if (typeof custom === "function") {
530
- result = await custom(icon);
531
- } else {
532
- const inline = custom[icon];
533
- result = typeof inline === "function" ? await inline() : inline;
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;
534
385
  }
535
386
  if (result) {
536
387
  const cleanupIdx = result.indexOf("<svg");
@@ -611,7 +462,16 @@ const loadIcon = async (collection, icon, options) => {
611
462
  const custom = options?.customCollections?.[collection];
612
463
  if (custom) {
613
464
  if (typeof custom === "function") {
614
- const result = await custom(icon);
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
+ }
615
475
  if (result) {
616
476
  if (typeof result === "string") {
617
477
  return await getCustomIcon(
@@ -639,9 +499,12 @@ const loadIcon = async (collection, icon, options) => {
639
499
  return await getCustomIcon(custom, collection, icon, options);
640
500
  }
641
501
  }
642
- return void 0;
643
502
  };
644
503
 
504
+ function getDefaultExportFromCjs (x) {
505
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
506
+ }
507
+
645
508
  var collections = [
646
509
  "academicons",
647
510
  "akar-icons",
@@ -784,6 +647,7 @@ var collections = [
784
647
  "svg-spinners",
785
648
  "system-uicons",
786
649
  "tabler",
650
+ "tdesign",
787
651
  "teenyicons",
788
652
  "topcoat",
789
653
  "twemoji",
@@ -804,10 +668,12 @@ var collections = [
804
668
  "zondicons"
805
669
  ];
806
670
 
671
+ const supportedCollection = /*@__PURE__*/getDefaultExportFromCjs(collections);
672
+
807
673
  function createCDNLoader(cdnBase) {
808
674
  const cache = /* @__PURE__ */ new Map();
809
675
  function fetchCollection(name) {
810
- if (!collections.includes(name))
676
+ if (!supportedCollection.includes(name))
811
677
  return void 0;
812
678
  if (!cache.has(name))
813
679
  cache.set(name, ofetch.$fetch(`${cdnBase}@iconify-json/${name}/icons.json`));
@@ -109,17 +109,6 @@ function getIconData(data, name) {
109
109
  return tree ? internalGetIconData(data, name, tree) : null;
110
110
  }
111
111
 
112
- ({
113
- provider: "",
114
- aliases: {},
115
- not_found: {},
116
- ...defaultIconDimensions
117
- });
118
-
119
- Object.keys(defaultIconDimensions).concat([
120
- "provider"
121
- ]);
122
-
123
112
  const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
124
113
  const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
125
114
  function calculateSize(size, ratio, precision) {
@@ -159,6 +148,32 @@ function calculateSize(size, ratio, precision) {
159
148
  }
160
149
  }
161
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
+
162
177
  const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
163
178
  function iconToSVG(icon, customisations) {
164
179
  const fullIcon = {
@@ -235,7 +250,11 @@ function iconToSVG(icon, customisations) {
235
250
  }
236
251
  }
237
252
  if (transformations.length) {
238
- body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
253
+ body = wrapSVGContent(
254
+ body,
255
+ '<g transform="' + transformations.join(" ") + '">',
256
+ "</g>"
257
+ );
239
258
  }
240
259
  });
241
260
  const customisationsWidth = fullCustomisations.width;
@@ -259,195 +278,19 @@ function iconToSVG(icon, customisations) {
259
278
  };
260
279
  setAttr("width", width);
261
280
  setAttr("height", height);
262
- attributes.viewBox = box.left.toString() + " " + box.top.toString() + " " + boxWidth.toString() + " " + boxHeight.toString();
281
+ const viewBox = [box.left, box.top, boxWidth, boxHeight];
282
+ attributes.viewBox = viewBox.join(" ");
263
283
  return {
264
284
  attributes,
285
+ viewBox,
265
286
  body
266
287
  };
267
288
  }
268
289
 
269
- "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
270
-
271
290
  function trimSVG(str) {
272
291
  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, '="').trim();
273
292
  }
274
293
 
275
- function add(keyword, colors) {
276
- const type = "rgb";
277
- const r = colors[0];
278
- const length = colors.length;
279
- ({
280
- type,
281
- r,
282
- g: length > 1 ? colors[1] : r,
283
- b: length > 2 ? colors[2] : r,
284
- alpha: length > 3 ? colors[3] : 1
285
- });
286
- }
287
- add("silver", [192]);
288
- add("gray", [128]);
289
- add("white", [255]);
290
- add("maroon", [128, 0, 0]);
291
- add("red", [255, 0, 0]);
292
- add("purple", [128, 0]);
293
- add("fuchsia", [255, 0]);
294
- add("green", [0, 128]);
295
- add("lime", [0, 255]);
296
- add("olive", [128, 128, 0]);
297
- add("yellow", [255, 255, 0]);
298
- add("navy", [0, 0, 128]);
299
- add("blue", [0, 0, 255]);
300
- add("teal", [0, 128, 128]);
301
- add("aqua", [0, 255, 255]);
302
- add("aliceblue", [240, 248, 255]);
303
- add("antiquewhite", [250, 235, 215]);
304
- add("aqua", [0, 255, 255]);
305
- add("aquamarine", [127, 255, 212]);
306
- add("azure", [240, 255, 255]);
307
- add("beige", [245, 245, 220]);
308
- add("bisque", [255, 228, 196]);
309
- add("black", [0]);
310
- add("blanchedalmond", [255, 235, 205]);
311
- add("blue", [0, 0, 255]);
312
- add("blueviolet", [138, 43, 226]);
313
- add("brown", [165, 42, 42]);
314
- add("burlywood", [222, 184, 135]);
315
- add("cadetblue", [95, 158, 160]);
316
- add("chartreuse", [127, 255, 0]);
317
- add("chocolate", [210, 105, 30]);
318
- add("coral", [255, 127, 80]);
319
- add("cornflowerblue", [100, 149, 237]);
320
- add("cornsilk", [255, 248, 220]);
321
- add("crimson", [220, 20, 60]);
322
- add("cyan", [0, 255, 255]);
323
- add("darkblue", [0, 0, 139]);
324
- add("darkcyan", [0, 139, 139]);
325
- add("darkgoldenrod", [184, 134, 11]);
326
- add("darkgray", [169]);
327
- add("darkgreen", [0, 100]);
328
- add("darkgrey", [169]);
329
- add("darkkhaki", [189, 183, 107]);
330
- add("darkmagenta", [139, 0]);
331
- add("darkolivegreen", [85, 107, 47]);
332
- add("darkorange", [255, 140, 0]);
333
- add("darkorchid", [153, 50, 204]);
334
- add("darkred", [139, 0, 0]);
335
- add("darksalmon", [233, 150, 122]);
336
- add("darkseagreen", [143, 188]);
337
- add("darkslateblue", [72, 61, 139]);
338
- add("darkslategray", [47, 79, 79]);
339
- add("darkslategrey", [47, 79, 79]);
340
- add("darkturquoise", [0, 206, 209]);
341
- add("darkviolet", [148, 0, 211]);
342
- add("deeppink", [255, 20, 147]);
343
- add("deepskyblue", [0, 191, 255]);
344
- add("dimgray", [105]);
345
- add("dimgrey", [105]);
346
- add("dodgerblue", [30, 144, 255]);
347
- add("firebrick", [178, 34, 34]);
348
- add("floralwhite", [255, 250, 240]);
349
- add("forestgreen", [34, 139]);
350
- add("fuchsia", [255, 0]);
351
- add("gainsboro", [220]);
352
- add("ghostwhite", [248, 248, 255]);
353
- add("gold", [255, 215, 0]);
354
- add("goldenrod", [218, 165, 32]);
355
- add("gray", [128]);
356
- add("green", [0, 128]);
357
- add("greenyellow", [173, 255, 47]);
358
- add("grey", [128]);
359
- add("honeydew", [240, 255]);
360
- add("hotpink", [255, 105, 180]);
361
- add("indianred", [205, 92, 92]);
362
- add("indigo", [75, 0, 130]);
363
- add("ivory", [255, 255, 240]);
364
- add("khaki", [240, 230, 140]);
365
- add("lavender", [230, 230, 250]);
366
- add("lavenderblush", [255, 240, 245]);
367
- add("lawngreen", [124, 252, 0]);
368
- add("lemonchiffon", [255, 250, 205]);
369
- add("lightblue", [173, 216, 230]);
370
- add("lightcoral", [240, 128, 128]);
371
- add("lightcyan", [224, 255, 255]);
372
- add("lightgoldenrodyellow", [250, 250, 210]);
373
- add("lightgray", [211]);
374
- add("lightgreen", [144, 238]);
375
- add("lightgrey", [211]);
376
- add("lightpink", [255, 182, 193]);
377
- add("lightsalmon", [255, 160, 122]);
378
- add("lightseagreen", [32, 178, 170]);
379
- add("lightskyblue", [135, 206, 250]);
380
- add("lightslategray", [119, 136, 153]);
381
- add("lightslategrey", [119, 136, 153]);
382
- add("lightsteelblue", [176, 196, 222]);
383
- add("lightyellow", [255, 255, 224]);
384
- add("lime", [0, 255]);
385
- add("limegreen", [50, 205]);
386
- add("linen", [250, 240, 230]);
387
- add("magenta", [255, 0]);
388
- add("maroon", [128, 0, 0]);
389
- add("mediumaquamarine", [102, 205, 170]);
390
- add("mediumblue", [0, 0, 205]);
391
- add("mediumorchid", [186, 85, 211]);
392
- add("mediumpurple", [147, 112, 219]);
393
- add("mediumseagreen", [60, 179, 113]);
394
- add("mediumslateblue", [123, 104, 238]);
395
- add("mediumspringgreen", [0, 250, 154]);
396
- add("mediumturquoise", [72, 209, 204]);
397
- add("mediumvioletred", [199, 21, 133]);
398
- add("midnightblue", [25, 25, 112]);
399
- add("mintcream", [245, 255, 250]);
400
- add("mistyrose", [255, 228, 225]);
401
- add("moccasin", [255, 228, 181]);
402
- add("navajowhite", [255, 222, 173]);
403
- add("navy", [0, 0, 128]);
404
- add("oldlace", [253, 245, 230]);
405
- add("olive", [128, 128, 0]);
406
- add("olivedrab", [107, 142, 35]);
407
- add("orange", [255, 165, 0]);
408
- add("orangered", [255, 69, 0]);
409
- add("orchid", [218, 112, 214]);
410
- add("palegoldenrod", [238, 232, 170]);
411
- add("palegreen", [152, 251]);
412
- add("paleturquoise", [175, 238, 238]);
413
- add("palevioletred", [219, 112, 147]);
414
- add("papayawhip", [255, 239, 213]);
415
- add("peachpuff", [255, 218, 185]);
416
- add("peru", [205, 133, 63]);
417
- add("pink", [255, 192, 203]);
418
- add("plum", [221, 160]);
419
- add("powderblue", [176, 224, 230]);
420
- add("purple", [128, 0]);
421
- add("rebeccapurple", [102, 51, 153]);
422
- add("red", [255, 0, 0]);
423
- add("rosybrown", [188, 143, 143]);
424
- add("royalblue", [65, 105, 225]);
425
- add("saddlebrown", [139, 69, 19]);
426
- add("salmon", [250, 128, 114]);
427
- add("sandybrown", [244, 164, 96]);
428
- add("seagreen", [46, 139, 87]);
429
- add("seashell", [255, 245, 238]);
430
- add("sienna", [160, 82, 45]);
431
- add("silver", [192]);
432
- add("skyblue", [135, 206, 235]);
433
- add("slateblue", [106, 90, 205]);
434
- add("slategray", [112, 128, 144]);
435
- add("slategrey", [112, 128, 144]);
436
- add("snow", [255, 250, 250]);
437
- add("springgreen", [0, 255, 127]);
438
- add("steelblue", [70, 130, 180]);
439
- add("tan", [210, 180, 140]);
440
- add("teal", [0, 128, 128]);
441
- add("thistle", [216, 191]);
442
- add("tomato", [255, 99, 71]);
443
- add("turquoise", [64, 224, 208]);
444
- add("violet", [238, 130]);
445
- add("wheat", [245, 222, 179]);
446
- add("white", [255]);
447
- add("whitesmoke", [245]);
448
- add("yellow", [255, 255, 0]);
449
- add("yellowgreen", [154, 205, 50]);
450
-
451
294
  const svgWidthRegex = /\swidth\s*=\s*["'](\w+)["']/;
452
295
  const svgHeightRegex = /\sheight\s*=\s*["'](\w+)["']/;
453
296
  const svgTagRegex = /<svg\s+/;
@@ -524,11 +367,19 @@ async function mergeIconProps(svg, collection, icon, options, propsProvider, aft
524
367
 
525
368
  async function getCustomIcon(custom, collection, icon, options) {
526
369
  let result;
527
- if (typeof custom === "function") {
528
- result = await custom(icon);
529
- } else {
530
- const inline = custom[icon];
531
- result = typeof inline === "function" ? await inline() : inline;
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;
532
383
  }
533
384
  if (result) {
534
385
  const cleanupIdx = result.indexOf("<svg");
@@ -609,7 +460,16 @@ const loadIcon = async (collection, icon, options) => {
609
460
  const custom = options?.customCollections?.[collection];
610
461
  if (custom) {
611
462
  if (typeof custom === "function") {
612
- const result = await custom(icon);
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
+ }
613
473
  if (result) {
614
474
  if (typeof result === "string") {
615
475
  return await getCustomIcon(
@@ -637,9 +497,12 @@ const loadIcon = async (collection, icon, options) => {
637
497
  return await getCustomIcon(custom, collection, icon, options);
638
498
  }
639
499
  }
640
- return void 0;
641
500
  };
642
501
 
502
+ function getDefaultExportFromCjs (x) {
503
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
504
+ }
505
+
643
506
  var collections = [
644
507
  "academicons",
645
508
  "akar-icons",
@@ -782,6 +645,7 @@ var collections = [
782
645
  "svg-spinners",
783
646
  "system-uicons",
784
647
  "tabler",
648
+ "tdesign",
785
649
  "teenyicons",
786
650
  "topcoat",
787
651
  "twemoji",
@@ -802,10 +666,12 @@ var collections = [
802
666
  "zondicons"
803
667
  ];
804
668
 
669
+ const supportedCollection = /*@__PURE__*/getDefaultExportFromCjs(collections);
670
+
805
671
  function createCDNLoader(cdnBase) {
806
672
  const cache = /* @__PURE__ */ new Map();
807
673
  function fetchCollection(name) {
808
- if (!collections.includes(name))
674
+ if (!supportedCollection.includes(name))
809
675
  return void 0;
810
676
  if (!cache.has(name))
811
677
  cache.set(name, $fetch(`${cdnBase}@iconify-json/${name}/icons.json`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-icons",
3
- "version": "0.55.1",
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.7",
51
- "ofetch": "^1.1.1",
52
- "@unocss/core": "0.55.1"
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"