@unocss/preset-icons 0.56.5 → 0.57.0

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,19 +2,24 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const cdn = require('./shared/preset-icons.ab2cc9e5.cjs');
6
- const core = require('./core.cjs');
5
+ const cdn = require('./shared/preset-icons.a1ceafd7.cjs');
6
+ const core = require('./shared/preset-icons.ce788be4.cjs');
7
7
  require('ofetch');
8
8
  require('@unocss/core');
9
9
 
10
10
  const presetIcons = core.createPresetIcons(async (options) => {
11
- const { cdn: cdn$1 } = options;
11
+ const fetcher = options?.customFetch;
12
+ const cdn$1 = options?.cdn;
13
+ if (fetcher && cdn$1)
14
+ return core.createCDNFetchLoader(fetcher, cdn$1);
12
15
  if (cdn$1)
13
16
  return cdn.createCDNLoader(cdn$1);
14
- return cdn.loadIcon;
17
+ return core.loadIcon;
15
18
  });
16
19
 
17
20
  exports.combineLoaders = core.combineLoaders;
21
+ exports.createCDNFetchLoader = core.createCDNFetchLoader;
18
22
  exports.createPresetIcons = core.createPresetIcons;
23
+ exports.icons = core.icons;
19
24
  exports.default = presetIcons;
20
25
  exports.presetIcons = presetIcons;
@@ -1,6 +1,6 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { IconsOptions } from './core.cjs';
3
- export { combineLoaders, createPresetIcons } from './core.cjs';
3
+ export { combineLoaders, createCDNFetchLoader, createPresetIcons, icons } from './core.cjs';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
@@ -1,6 +1,6 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
2
  import { IconsOptions } from './core.mjs';
3
- export { combineLoaders, createPresetIcons } from './core.mjs';
3
+ export { combineLoaders, createCDNFetchLoader, createPresetIcons, icons } from './core.mjs';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
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 { combineLoaders, createPresetIcons } from './core.js';
3
+ export { combineLoaders, createCDNFetchLoader, createPresetIcons, icons } from './core.js';
4
4
  import '@iconify/utils/lib/loader/types';
5
5
  import '@iconify/types';
6
6
 
package/dist/browser.mjs CHANGED
@@ -1,14 +1,17 @@
1
- import { c as createCDNLoader, l as loadIcon } from './shared/preset-icons.e13a0979.mjs';
2
- import { createPresetIcons } from './core.mjs';
3
- export { combineLoaders } from './core.mjs';
1
+ import { c as createCDNLoader } from './shared/preset-icons.218019cc.mjs';
2
+ import { c as createPresetIcons, b as createCDNFetchLoader, l as loadIcon } from './shared/preset-icons.b90d6d31.mjs';
3
+ export { a as combineLoaders, i as icons } from './shared/preset-icons.b90d6d31.mjs';
4
4
  import 'ofetch';
5
5
  import '@unocss/core';
6
6
 
7
7
  const presetIcons = createPresetIcons(async (options) => {
8
- const { cdn } = options;
8
+ const fetcher = options?.customFetch;
9
+ const cdn = options?.cdn;
10
+ if (fetcher && cdn)
11
+ return createCDNFetchLoader(fetcher, cdn);
9
12
  if (cdn)
10
13
  return createCDNLoader(cdn);
11
14
  return loadIcon;
12
15
  });
13
16
 
14
- export { createPresetIcons, presetIcons as default, presetIcons };
17
+ export { createCDNFetchLoader, createPresetIcons, presetIcons as default, presetIcons };
package/dist/core.cjs CHANGED
@@ -1,137 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const core = require('@unocss/core');
3
+ require('@unocss/core');
4
+ const core = require('./shared/preset-icons.ce788be4.cjs');
4
5
 
5
- function encodeSVGforURL(svg) {
6
- return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
7
- }
8
6
 
9
- function encodeSvgForCss(svg) {
10
- let useSvg = svg.startsWith("<svg>") ? svg.replace("<svg>", "<svg >") : svg;
11
- if (!useSvg.includes(" xmlns:xlink=") && useSvg.includes(" xlink:")) {
12
- useSvg = useSvg.replace(
13
- "<svg ",
14
- '<svg xmlns:xlink="http://www.w3.org/1999/xlink" '
15
- );
16
- }
17
- if (!useSvg.includes(" xmlns=")) {
18
- useSvg = useSvg.replace(
19
- "<svg ",
20
- '<svg xmlns="http://www.w3.org/2000/svg" '
21
- );
22
- }
23
- return encodeSVGforURL(useSvg);
24
- }
25
7
 
26
- const COLLECTION_NAME_PARTS_MAX = 3;
27
- function createPresetIcons(lookupIconLoader) {
28
- return core.definePreset((options = {}) => {
29
- const {
30
- scale = 1,
31
- mode = "auto",
32
- prefix = "i-",
33
- warn = false,
34
- collections: customCollections,
35
- extraProperties = {},
36
- customizations = {},
37
- autoInstall = false,
38
- layer = "icons",
39
- unit
40
- } = options;
41
- const loaderOptions = {
42
- addXmlNs: true,
43
- scale,
44
- customCollections,
45
- autoInstall,
46
- // avoid warn from @iconify/loader: we'll warn below if not found
47
- warn: void 0,
48
- customizations: {
49
- ...customizations,
50
- additionalProps: { ...extraProperties },
51
- trimCustomSvg: true,
52
- async iconCustomizer(collection, icon, props) {
53
- await customizations.iconCustomizer?.(collection, icon, props);
54
- if (unit) {
55
- if (!props.width)
56
- props.width = `${scale}${unit}`;
57
- if (!props.height)
58
- props.height = `${scale}${unit}`;
59
- }
60
- }
61
- }
62
- };
63
- let iconLoader;
64
- return {
65
- name: "@unocss/preset-icons",
66
- enforce: "pre",
67
- options,
68
- layers: { icons: -30 },
69
- rules: [[
70
- /^([a-z0-9:_-]+)(?:\?(mask|bg|auto))?$/,
71
- async ([full, body, _mode = mode]) => {
72
- let collection = "";
73
- let name = "";
74
- let svg;
75
- iconLoader = iconLoader || await lookupIconLoader(options);
76
- const usedProps = {};
77
- if (body.includes(":")) {
78
- [collection, name] = body.split(":");
79
- svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
80
- } else {
81
- const parts = body.split(/-/g);
82
- for (let i = COLLECTION_NAME_PARTS_MAX; i >= 1; i--) {
83
- collection = parts.slice(0, i).join("-");
84
- name = parts.slice(i).join("-");
85
- svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
86
- if (svg)
87
- break;
88
- }
89
- }
90
- if (!svg) {
91
- if (warn)
92
- core.warnOnce(`failed to load icon "${full}"`);
93
- return;
94
- }
95
- const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(svg)}")`;
96
- if (_mode === "auto")
97
- _mode = svg.includes("currentColor") ? "mask" : "bg";
98
- if (_mode === "mask") {
99
- return {
100
- "--un-icon": url,
101
- "-webkit-mask": "var(--un-icon) no-repeat",
102
- "mask": "var(--un-icon) no-repeat",
103
- "-webkit-mask-size": "100% 100%",
104
- "mask-size": "100% 100%",
105
- "background-color": "currentColor",
106
- // for Safari https://github.com/elk-zone/elk/pull/264
107
- "color": "inherit",
108
- ...usedProps
109
- };
110
- } else {
111
- return {
112
- "background": `${url} no-repeat`,
113
- "background-size": "100% 100%",
114
- "background-color": "transparent",
115
- ...usedProps
116
- };
117
- }
118
- },
119
- { layer, prefix }
120
- ]]
121
- };
122
- });
123
- }
124
- function combineLoaders(loaders) {
125
- return async (...args) => {
126
- for (const loader of loaders) {
127
- if (!loader)
128
- continue;
129
- const result = await loader(...args);
130
- if (result)
131
- return result;
132
- }
133
- };
134
- }
135
-
136
- exports.combineLoaders = combineLoaders;
137
- exports.createPresetIcons = createPresetIcons;
8
+ exports.combineLoaders = core.combineLoaders;
9
+ exports.createCDNFetchLoader = core.createCDNFetchLoader;
10
+ exports.createPresetIcons = core.createPresetIcons;
11
+ exports.icons = core.icons;
package/dist/core.d.cts CHANGED
@@ -76,9 +76,184 @@ interface IconsOptions {
76
76
  * - https://cdn.skypack.dev/
77
77
  */
78
78
  cdn?: string;
79
+ /**
80
+ * Custom fetch function to provide the icon data.
81
+ */
82
+ customFetch?: (url: string) => Promise<any>;
83
+ }
84
+
85
+ function getDefaultExportFromCjs (x) {
86
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
79
87
  }
80
88
 
89
+ var collections = [
90
+ "academicons",
91
+ "akar-icons",
92
+ "ant-design",
93
+ "arcticons",
94
+ "basil",
95
+ "bi",
96
+ "bpmn",
97
+ "brandico",
98
+ "bx",
99
+ "bxl",
100
+ "bxs",
101
+ "bytesize",
102
+ "carbon",
103
+ "charm",
104
+ "ci",
105
+ "cib",
106
+ "cif",
107
+ "cil",
108
+ "circle-flags",
109
+ "circum",
110
+ "clarity",
111
+ "codicon",
112
+ "covid",
113
+ "cryptocurrency-color",
114
+ "cryptocurrency",
115
+ "dashicons",
116
+ "devicon-line",
117
+ "devicon-original",
118
+ "devicon-plain",
119
+ "devicon",
120
+ "ei",
121
+ "el",
122
+ "emblemicons",
123
+ "emojione-monotone",
124
+ "emojione-v1",
125
+ "emojione",
126
+ "entypo-social",
127
+ "entypo",
128
+ "eos-icons",
129
+ "ep",
130
+ "et",
131
+ "eva",
132
+ "fa-brands",
133
+ "fa-regular",
134
+ "fa-solid",
135
+ "fa",
136
+ "fa6-brands",
137
+ "fa6-regular",
138
+ "fa6-solid",
139
+ "fad",
140
+ "fe",
141
+ "feather",
142
+ "file-icons",
143
+ "flag",
144
+ "flagpack",
145
+ "flat-color-icons",
146
+ "flat-ui",
147
+ "fluent-emoji-flat",
148
+ "fluent-emoji-high-contrast",
149
+ "fluent-emoji",
150
+ "fluent-mdl2",
151
+ "fluent",
152
+ "fontelico",
153
+ "fontisto",
154
+ "formkit",
155
+ "foundation",
156
+ "fxemoji",
157
+ "gala",
158
+ "game-icons",
159
+ "geo",
160
+ "gg",
161
+ "gis",
162
+ "gridicons",
163
+ "grommet-icons",
164
+ "guidance",
165
+ "healthicons",
166
+ "heroicons-outline",
167
+ "heroicons-solid",
168
+ "heroicons",
169
+ "humbleicons",
170
+ "ic",
171
+ "icomoon-free",
172
+ "icon-park-outline",
173
+ "icon-park-solid",
174
+ "icon-park-twotone",
175
+ "icon-park",
176
+ "iconamoon",
177
+ "iconoir",
178
+ "icons8",
179
+ "il",
180
+ "ion",
181
+ "iwwa",
182
+ "jam",
183
+ "la",
184
+ "line-md",
185
+ "logos",
186
+ "ls",
187
+ "lucide",
188
+ "majesticons",
189
+ "maki",
190
+ "map",
191
+ "material-symbols",
192
+ "mdi-light",
193
+ "mdi",
194
+ "medical-icon",
195
+ "memory",
196
+ "meteocons",
197
+ "mi",
198
+ "mingcute",
199
+ "mono-icons",
200
+ "nimbus",
201
+ "nonicons",
202
+ "noto-v1",
203
+ "noto",
204
+ "octicon",
205
+ "oi",
206
+ "ooui",
207
+ "openmoji",
208
+ "pajamas",
209
+ "pepicons-pencil",
210
+ "pepicons-pop",
211
+ "pepicons-print",
212
+ "pepicons",
213
+ "ph",
214
+ "pixelarticons",
215
+ "prime",
216
+ "ps",
217
+ "quill",
218
+ "radix-icons",
219
+ "raphael",
220
+ "ri",
221
+ "si-glyph",
222
+ "simple-icons",
223
+ "simple-line-icons",
224
+ "skill-icons",
225
+ "solar",
226
+ "streamline-emojis",
227
+ "streamline",
228
+ "subway",
229
+ "svg-spinners",
230
+ "system-uicons",
231
+ "tabler",
232
+ "tdesign",
233
+ "teenyicons",
234
+ "topcoat",
235
+ "twemoji",
236
+ "typcn",
237
+ "uil",
238
+ "uim",
239
+ "uis",
240
+ "uit",
241
+ "uiw",
242
+ "vaadin",
243
+ "vs",
244
+ "vscode-icons",
245
+ "websymbol",
246
+ "whh",
247
+ "wi",
248
+ "wpf",
249
+ "zmdi",
250
+ "zondicons"
251
+ ];
252
+
253
+ var collections$1 = /*@__PURE__*/getDefaultExportFromCjs(collections);
254
+
81
255
  declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): _unocss_core.PresetFactory<object, IconsOptions>;
82
256
  declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
257
+ declare function createCDNFetchLoader(fetcher: (url: string) => Promise<any>, cdnBase: string): UniversalIconLoader;
83
258
 
84
- export { type IconsOptions, combineLoaders, createPresetIcons };
259
+ export { type IconsOptions, combineLoaders, createCDNFetchLoader, createPresetIcons, collections$1 as icons };
package/dist/core.d.mts CHANGED
@@ -76,9 +76,184 @@ interface IconsOptions {
76
76
  * - https://cdn.skypack.dev/
77
77
  */
78
78
  cdn?: string;
79
+ /**
80
+ * Custom fetch function to provide the icon data.
81
+ */
82
+ customFetch?: (url: string) => Promise<any>;
83
+ }
84
+
85
+ function getDefaultExportFromCjs (x) {
86
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
79
87
  }
80
88
 
89
+ var collections = [
90
+ "academicons",
91
+ "akar-icons",
92
+ "ant-design",
93
+ "arcticons",
94
+ "basil",
95
+ "bi",
96
+ "bpmn",
97
+ "brandico",
98
+ "bx",
99
+ "bxl",
100
+ "bxs",
101
+ "bytesize",
102
+ "carbon",
103
+ "charm",
104
+ "ci",
105
+ "cib",
106
+ "cif",
107
+ "cil",
108
+ "circle-flags",
109
+ "circum",
110
+ "clarity",
111
+ "codicon",
112
+ "covid",
113
+ "cryptocurrency-color",
114
+ "cryptocurrency",
115
+ "dashicons",
116
+ "devicon-line",
117
+ "devicon-original",
118
+ "devicon-plain",
119
+ "devicon",
120
+ "ei",
121
+ "el",
122
+ "emblemicons",
123
+ "emojione-monotone",
124
+ "emojione-v1",
125
+ "emojione",
126
+ "entypo-social",
127
+ "entypo",
128
+ "eos-icons",
129
+ "ep",
130
+ "et",
131
+ "eva",
132
+ "fa-brands",
133
+ "fa-regular",
134
+ "fa-solid",
135
+ "fa",
136
+ "fa6-brands",
137
+ "fa6-regular",
138
+ "fa6-solid",
139
+ "fad",
140
+ "fe",
141
+ "feather",
142
+ "file-icons",
143
+ "flag",
144
+ "flagpack",
145
+ "flat-color-icons",
146
+ "flat-ui",
147
+ "fluent-emoji-flat",
148
+ "fluent-emoji-high-contrast",
149
+ "fluent-emoji",
150
+ "fluent-mdl2",
151
+ "fluent",
152
+ "fontelico",
153
+ "fontisto",
154
+ "formkit",
155
+ "foundation",
156
+ "fxemoji",
157
+ "gala",
158
+ "game-icons",
159
+ "geo",
160
+ "gg",
161
+ "gis",
162
+ "gridicons",
163
+ "grommet-icons",
164
+ "guidance",
165
+ "healthicons",
166
+ "heroicons-outline",
167
+ "heroicons-solid",
168
+ "heroicons",
169
+ "humbleicons",
170
+ "ic",
171
+ "icomoon-free",
172
+ "icon-park-outline",
173
+ "icon-park-solid",
174
+ "icon-park-twotone",
175
+ "icon-park",
176
+ "iconamoon",
177
+ "iconoir",
178
+ "icons8",
179
+ "il",
180
+ "ion",
181
+ "iwwa",
182
+ "jam",
183
+ "la",
184
+ "line-md",
185
+ "logos",
186
+ "ls",
187
+ "lucide",
188
+ "majesticons",
189
+ "maki",
190
+ "map",
191
+ "material-symbols",
192
+ "mdi-light",
193
+ "mdi",
194
+ "medical-icon",
195
+ "memory",
196
+ "meteocons",
197
+ "mi",
198
+ "mingcute",
199
+ "mono-icons",
200
+ "nimbus",
201
+ "nonicons",
202
+ "noto-v1",
203
+ "noto",
204
+ "octicon",
205
+ "oi",
206
+ "ooui",
207
+ "openmoji",
208
+ "pajamas",
209
+ "pepicons-pencil",
210
+ "pepicons-pop",
211
+ "pepicons-print",
212
+ "pepicons",
213
+ "ph",
214
+ "pixelarticons",
215
+ "prime",
216
+ "ps",
217
+ "quill",
218
+ "radix-icons",
219
+ "raphael",
220
+ "ri",
221
+ "si-glyph",
222
+ "simple-icons",
223
+ "simple-line-icons",
224
+ "skill-icons",
225
+ "solar",
226
+ "streamline-emojis",
227
+ "streamline",
228
+ "subway",
229
+ "svg-spinners",
230
+ "system-uicons",
231
+ "tabler",
232
+ "tdesign",
233
+ "teenyicons",
234
+ "topcoat",
235
+ "twemoji",
236
+ "typcn",
237
+ "uil",
238
+ "uim",
239
+ "uis",
240
+ "uit",
241
+ "uiw",
242
+ "vaadin",
243
+ "vs",
244
+ "vscode-icons",
245
+ "websymbol",
246
+ "whh",
247
+ "wi",
248
+ "wpf",
249
+ "zmdi",
250
+ "zondicons"
251
+ ];
252
+
253
+ var collections$1 = /*@__PURE__*/getDefaultExportFromCjs(collections);
254
+
81
255
  declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): _unocss_core.PresetFactory<object, IconsOptions>;
82
256
  declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
257
+ declare function createCDNFetchLoader(fetcher: (url: string) => Promise<any>, cdnBase: string): UniversalIconLoader;
83
258
 
84
- export { type IconsOptions, combineLoaders, createPresetIcons };
259
+ export { type IconsOptions, combineLoaders, createCDNFetchLoader, createPresetIcons, collections$1 as icons };