@unocss/preset-icons 0.58.9 → 0.59.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.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { c as createCDNLoader } from './shared/preset-icons.BAlQvmXS.mjs';
2
- import { c as createPresetIcons, b as createCDNFetchLoader, l as loadIcon } from './shared/preset-icons.BBMLRFol.mjs';
3
- export { a as combineLoaders, g as getEnvFlags, i as icons } from './shared/preset-icons.BBMLRFol.mjs';
1
+ import { c as createCDNLoader } from './shared/preset-icons.CMXqj_Gx.mjs';
2
+ import { c as createPresetIcons, b as createCDNFetchLoader, l as loadIcon } from './shared/preset-icons.CBQgN1kC.mjs';
3
+ export { a as combineLoaders, g as getEnvFlags, i as icons } from './shared/preset-icons.CBQgN1kC.mjs';
4
4
  import 'ofetch';
5
5
  import '@unocss/core';
6
6
 
package/dist/core.d.mts CHANGED
@@ -201,6 +201,7 @@ var collections = [
201
201
  "majesticons",
202
202
  "maki",
203
203
  "map",
204
+ "marketeq",
204
205
  "material-symbols-light",
205
206
  "material-symbols",
206
207
  "mdi-light",
package/dist/core.d.ts CHANGED
@@ -201,6 +201,7 @@ var collections = [
201
201
  "majesticons",
202
202
  "maki",
203
203
  "map",
204
+ "marketeq",
204
205
  "material-symbols-light",
205
206
  "material-symbols",
206
207
  "mdi-light",
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import '@unocss/core';
2
- export { a as combineLoaders, b as createCDNFetchLoader, c as createPresetIcons, g as getEnvFlags, i as icons } from './shared/preset-icons.BBMLRFol.mjs';
2
+ export { a as combineLoaders, b as createCDNFetchLoader, c as createPresetIcons, g as getEnvFlags, i as icons } from './shared/preset-icons.CBQgN1kC.mjs';
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { c as createCDNLoader } from './shared/preset-icons.BAlQvmXS.mjs';
2
- import { c as createPresetIcons, g as getEnvFlags, a as combineLoaders, l as loadIcon } from './shared/preset-icons.BBMLRFol.mjs';
3
- export { b as createCDNFetchLoader, i as icons } from './shared/preset-icons.BBMLRFol.mjs';
1
+ import { c as createCDNLoader } from './shared/preset-icons.CMXqj_Gx.mjs';
2
+ import { c as createPresetIcons, g as getEnvFlags, a as combineLoaders, l as loadIcon } from './shared/preset-icons.CBQgN1kC.mjs';
3
+ export { b as createCDNFetchLoader, i as icons } from './shared/preset-icons.CBQgN1kC.mjs';
4
4
  import 'ofetch';
5
5
  import '@unocss/core';
6
6
 
@@ -636,6 +636,7 @@ var collections = [
636
636
  "majesticons",
637
637
  "maki",
638
638
  "map",
639
+ "marketeq",
639
640
  "material-symbols-light",
640
641
  "material-symbols",
641
642
  "mdi-light",
@@ -1,5 +1,5 @@
1
1
  import { $fetch } from 'ofetch';
2
- import { b as createCDNFetchLoader } from './preset-icons.BBMLRFol.mjs';
2
+ import { b as createCDNFetchLoader } from './preset-icons.CBQgN1kC.mjs';
3
3
 
4
4
  function createCDNLoader(cdnBase) {
5
5
  return createCDNFetchLoader($fetch, cdnBase);
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-icons",
3
- "version": "0.58.9",
3
+ "type": "module",
4
+ "version": "0.59.0",
4
5
  "description": "Pure CSS Icons for UnoCSS",
5
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
7
  "license": "MIT",
@@ -24,24 +25,29 @@
24
25
  "sideEffects": false,
25
26
  "exports": {
26
27
  ".": {
27
- "types": "./dist/index.d.ts",
28
- "import": "./dist/index.mjs",
29
- "require": "./dist/index.cjs"
28
+ "types": "./dist/index.d.mts",
29
+ "default": "./dist/index.mjs"
30
30
  },
31
31
  "./browser": {
32
- "types": "./dist/browser.d.ts",
33
- "import": "./dist/browser.mjs",
34
- "require": "./dist/browser.cjs"
32
+ "types": "./dist/browser.d.mts",
33
+ "default": "./dist/browser.mjs"
35
34
  },
36
35
  "./core": {
37
- "types": "./dist/core.d.ts",
38
- "import": "./dist/core.mjs",
39
- "require": "./dist/core.cjs"
36
+ "types": "./dist/core.d.mts",
37
+ "default": "./dist/core.mjs"
40
38
  }
41
39
  },
42
- "main": "dist/index.cjs",
40
+ "main": "dist/index.mjs",
43
41
  "module": "dist/index.mjs",
44
42
  "types": "dist/index.d.ts",
43
+ "typesVersions": {
44
+ "*": {
45
+ "*": [
46
+ "./dist/*",
47
+ "./*"
48
+ ]
49
+ }
50
+ },
45
51
  "files": [
46
52
  "*.css",
47
53
  "dist"
@@ -49,7 +55,7 @@
49
55
  "dependencies": {
50
56
  "@iconify/utils": "^2.1.22",
51
57
  "ofetch": "^1.3.4",
52
- "@unocss/core": "0.58.9"
58
+ "@unocss/core": "0.59.0"
53
59
  },
54
60
  "devDependencies": {
55
61
  "@iconify/types": "^2.0.0"
package/dist/browser.cjs DELETED
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const cdn = require('./shared/preset-icons.DDHG4xNZ.cjs');
6
- const core = require('./shared/preset-icons.De8FRNb6.cjs');
7
- require('ofetch');
8
- require('@unocss/core');
9
-
10
- const presetIcons = core.createPresetIcons(async (options) => {
11
- const fetcher = options?.customFetch;
12
- const cdn$1 = options?.cdn;
13
- if (fetcher && cdn$1)
14
- return core.createCDNFetchLoader(fetcher, cdn$1);
15
- if (cdn$1)
16
- return cdn.createCDNLoader(cdn$1);
17
- return core.loadIcon;
18
- });
19
-
20
- exports.combineLoaders = core.combineLoaders;
21
- exports.createCDNFetchLoader = core.createCDNFetchLoader;
22
- exports.createPresetIcons = core.createPresetIcons;
23
- exports.getEnvFlags = core.getEnvFlags;
24
- exports.icons = core.icons;
25
- exports.default = presetIcons;
26
- exports.presetIcons = presetIcons;
@@ -1,9 +0,0 @@
1
- import * as _unocss_core from '@unocss/core';
2
- import { IconsOptions } from './core.cjs';
3
- export { combineLoaders, createCDNFetchLoader, createPresetIcons, getEnvFlags, icons } from './core.cjs';
4
- import '@iconify/utils/lib/loader/types';
5
- import '@iconify/types';
6
-
7
- declare const presetIcons: _unocss_core.PresetFactory<object, IconsOptions>;
8
-
9
- export { IconsOptions, presetIcons as default, presetIcons };
package/dist/core.cjs DELETED
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- require('@unocss/core');
4
- const core = require('./shared/preset-icons.De8FRNb6.cjs');
5
-
6
-
7
-
8
- exports.combineLoaders = core.combineLoaders;
9
- exports.createCDNFetchLoader = core.createCDNFetchLoader;
10
- exports.createPresetIcons = core.createPresetIcons;
11
- exports.getEnvFlags = core.getEnvFlags;
12
- exports.icons = core.icons;
package/dist/core.d.cts DELETED
@@ -1,281 +0,0 @@
1
- import * as _unocss_core from '@unocss/core';
2
- import { Awaitable } from '@unocss/core';
3
- import { CustomIconLoader, InlineCollection, IconCustomizations, UniversalIconLoader } from '@iconify/utils/lib/loader/types';
4
- import { IconifyJSON } from '@iconify/types';
5
-
6
- interface IconsOptions {
7
- /**
8
- * Scale related to the current font size (1em).
9
- *
10
- * @default 1
11
- */
12
- scale?: number;
13
- /**
14
- * Mode of generated CSS icons.
15
- *
16
- * - `mask` - use background color and the `mask` property for monochrome icons
17
- * - `background-img` - use background image for the icons, colors are static
18
- * - `auto` - smartly decide mode between `mask` and `background-img` per icon based on its style
19
- *
20
- * @default 'auto'
21
- * @see https://antfu.me/posts/icons-in-pure-css
22
- */
23
- mode?: 'mask' | 'background-img' | 'auto';
24
- /**
25
- * Class prefix for matching icon rules.
26
- *
27
- * @default `i-`
28
- */
29
- prefix?: string | string[];
30
- /**
31
- * Extra CSS properties applied to the generated CSS
32
- *
33
- * @default {}
34
- */
35
- extraProperties?: Record<string, string>;
36
- /**
37
- * Emit warning when missing icons are matched
38
- *
39
- * @default false
40
- */
41
- warn?: boolean;
42
- /**
43
- * In Node.js environment, the preset will search for the installed iconify dataset automatically.
44
- * When using in the browser, this options is provided to provide dataset with custom loading mechanism.
45
- */
46
- collections?: Record<string, (() => Awaitable<IconifyJSON>) | undefined | CustomIconLoader | InlineCollection>;
47
- /**
48
- * Rule layer
49
- *
50
- * @default 'icons'
51
- */
52
- layer?: string;
53
- /**
54
- * Custom icon customizations.
55
- */
56
- customizations?: Omit<IconCustomizations, 'additionalProps' | 'trimCustomSvg'>;
57
- /**
58
- * Auto install icon sources package when the usages is detected
59
- *
60
- * Only effective in Node.js environment.
61
- *
62
- * @default false
63
- */
64
- autoInstall?: boolean;
65
- /**
66
- * Path to resolve the iconify collections in Node.js environment.
67
- *
68
- * @default process.cwd()
69
- */
70
- collectionsNodeResolvePath?: string;
71
- /**
72
- * Custom icon unit.
73
- *
74
- * @default `em`
75
- */
76
- unit?: string;
77
- /**
78
- * Load icons from CDN. Should starts with `https://` and ends with `/`
79
- *
80
- * Recommends:
81
- * - https://esm.sh/
82
- * - https://cdn.skypack.dev/
83
- */
84
- cdn?: string;
85
- /**
86
- * Custom fetch function to provide the icon data.
87
- */
88
- customFetch?: (url: string) => Promise<any>;
89
- }
90
-
91
- function getDefaultExportFromCjs (x) {
92
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
93
- }
94
-
95
- var collections = [
96
- "academicons",
97
- "akar-icons",
98
- "ant-design",
99
- "arcticons",
100
- "basil",
101
- "bi",
102
- "bitcoin-icons",
103
- "bpmn",
104
- "brandico",
105
- "bx",
106
- "bxl",
107
- "bxs",
108
- "bytesize",
109
- "carbon",
110
- "cbi",
111
- "charm",
112
- "ci",
113
- "cib",
114
- "cif",
115
- "cil",
116
- "circle-flags",
117
- "circum",
118
- "clarity",
119
- "codicon",
120
- "covid",
121
- "cryptocurrency-color",
122
- "cryptocurrency",
123
- "dashicons",
124
- "devicon-line",
125
- "devicon-original",
126
- "devicon-plain",
127
- "devicon",
128
- "ei",
129
- "el",
130
- "emblemicons",
131
- "emojione-monotone",
132
- "emojione-v1",
133
- "emojione",
134
- "entypo-social",
135
- "entypo",
136
- "eos-icons",
137
- "ep",
138
- "et",
139
- "eva",
140
- "f7",
141
- "fa-brands",
142
- "fa-regular",
143
- "fa-solid",
144
- "fa",
145
- "fa6-brands",
146
- "fa6-regular",
147
- "fa6-solid",
148
- "fad",
149
- "fe",
150
- "feather",
151
- "file-icons",
152
- "flag",
153
- "flagpack",
154
- "flat-color-icons",
155
- "flat-ui",
156
- "flowbite",
157
- "fluent-emoji-flat",
158
- "fluent-emoji-high-contrast",
159
- "fluent-emoji",
160
- "fluent-mdl2",
161
- "fluent",
162
- "fontelico",
163
- "fontisto",
164
- "formkit",
165
- "foundation",
166
- "fxemoji",
167
- "gala",
168
- "game-icons",
169
- "geo",
170
- "gg",
171
- "gis",
172
- "gravity-ui",
173
- "gridicons",
174
- "grommet-icons",
175
- "guidance",
176
- "healthicons",
177
- "heroicons-outline",
178
- "heroicons-solid",
179
- "heroicons",
180
- "humbleicons",
181
- "ic",
182
- "icomoon-free",
183
- "icon-park-outline",
184
- "icon-park-solid",
185
- "icon-park-twotone",
186
- "icon-park",
187
- "iconamoon",
188
- "iconoir",
189
- "icons8",
190
- "il",
191
- "ion",
192
- "iwwa",
193
- "jam",
194
- "la",
195
- "lets-icons",
196
- "line-md",
197
- "logos",
198
- "ls",
199
- "lucide",
200
- "mage",
201
- "majesticons",
202
- "maki",
203
- "map",
204
- "material-symbols-light",
205
- "material-symbols",
206
- "mdi-light",
207
- "mdi",
208
- "medical-icon",
209
- "memory",
210
- "meteocons",
211
- "mi",
212
- "mingcute",
213
- "mono-icons",
214
- "mynaui",
215
- "nimbus",
216
- "nonicons",
217
- "noto-v1",
218
- "noto",
219
- "octicon",
220
- "oi",
221
- "ooui",
222
- "openmoji",
223
- "oui",
224
- "pajamas",
225
- "pepicons-pencil",
226
- "pepicons-pop",
227
- "pepicons-print",
228
- "pepicons",
229
- "ph",
230
- "pixelarticons",
231
- "prime",
232
- "ps",
233
- "quill",
234
- "radix-icons",
235
- "raphael",
236
- "ri",
237
- "si-glyph",
238
- "simple-icons",
239
- "simple-line-icons",
240
- "skill-icons",
241
- "solar",
242
- "streamline-emojis",
243
- "streamline",
244
- "subway",
245
- "svg-spinners",
246
- "system-uicons",
247
- "tabler",
248
- "tdesign",
249
- "teenyicons",
250
- "topcoat",
251
- "twemoji",
252
- "typcn",
253
- "uil",
254
- "uim",
255
- "uis",
256
- "uit",
257
- "uiw",
258
- "unjs",
259
- "vaadin",
260
- "vs",
261
- "vscode-icons",
262
- "websymbol",
263
- "whh",
264
- "wi",
265
- "wpf",
266
- "zmdi",
267
- "zondicons"
268
- ];
269
-
270
- var collections$1 = /*@__PURE__*/getDefaultExportFromCjs(collections);
271
-
272
- declare function createPresetIcons(lookupIconLoader: (options: IconsOptions) => Promise<UniversalIconLoader>): _unocss_core.PresetFactory<object, IconsOptions>;
273
- declare function combineLoaders(loaders: UniversalIconLoader[]): UniversalIconLoader;
274
- declare function createCDNFetchLoader(fetcher: (url: string) => Promise<any>, cdnBase: string): UniversalIconLoader;
275
- declare function getEnvFlags(): {
276
- isNode: boolean;
277
- isVSCode: boolean;
278
- isESLint: boolean;
279
- };
280
-
281
- export { type IconsOptions, combineLoaders, createCDNFetchLoader, createPresetIcons, getEnvFlags, collections$1 as icons };
package/dist/index.cjs DELETED
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const cdn = require('./shared/preset-icons.DDHG4xNZ.cjs');
6
- const core = require('./shared/preset-icons.De8FRNb6.cjs');
7
- require('ofetch');
8
- require('@unocss/core');
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").loadNodeIcon;
17
- } catch {
18
- }
19
- }
20
- const presetIcons = /* @__PURE__ */ core.createPresetIcons(async (options) => {
21
- const {
22
- cdn: cdn$1
23
- } = options;
24
- const loaders = [];
25
- const {
26
- isNode,
27
- isVSCode,
28
- isESLint
29
- } = core.getEnvFlags();
30
- if (isNode && !isVSCode && !isESLint) {
31
- const nodeLoader = await createNodeLoader();
32
- if (nodeLoader !== void 0)
33
- loaders.push(nodeLoader);
34
- }
35
- if (cdn$1)
36
- loaders.push(cdn.createCDNLoader(cdn$1));
37
- loaders.push(core.loadIcon);
38
- return core.combineLoaders(loaders);
39
- });
40
-
41
- exports.combineLoaders = core.combineLoaders;
42
- exports.createCDNFetchLoader = core.createCDNFetchLoader;
43
- exports.createPresetIcons = core.createPresetIcons;
44
- exports.getEnvFlags = core.getEnvFlags;
45
- exports.icons = core.icons;
46
- exports.default = presetIcons;
47
- exports.presetIcons = presetIcons;
package/dist/index.d.cts DELETED
@@ -1,22 +0,0 @@
1
- import * as _unocss_core from '@unocss/core';
2
- import { IconsOptions } from './core.cjs';
3
- export { combineLoaders, createCDNFetchLoader, createPresetIcons, getEnvFlags, icons } from './core.cjs';
4
- import '@iconify/utils/lib/loader/types';
5
- import '@iconify/types';
6
-
7
- /**
8
- * Use any icon with Pure CSS for UnoCSS.
9
- *
10
- * @example
11
- *
12
- * ```html
13
- * <div class="i-mdi-alarm"></div>
14
- * <div class="i-logos-vue text-3xl"></div>
15
- * <button class="i-carbon-sun dark:i-carbon-moon"></div>
16
- * ```
17
- *
18
- * @see https://unocss.dev/presets/icons
19
- */
20
- declare const presetIcons: _unocss_core.PresetFactory<object, IconsOptions>;
21
-
22
- export { IconsOptions, presetIcons as default, presetIcons };
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- const ofetch = require('ofetch');
4
- const core = require('./preset-icons.De8FRNb6.cjs');
5
-
6
- function createCDNLoader(cdnBase) {
7
- return core.createCDNFetchLoader(ofetch.$fetch, cdnBase);
8
- }
9
-
10
- exports.createCDNLoader = createCDNLoader;
@@ -1,862 +0,0 @@
1
- 'use strict';
2
-
3
- const core = require('@unocss/core');
4
-
5
- const defaultIconDimensions = Object.freeze(
6
- {
7
- left: 0,
8
- top: 0,
9
- width: 16,
10
- height: 16
11
- }
12
- );
13
- const defaultIconTransformations = Object.freeze({
14
- rotate: 0,
15
- vFlip: false,
16
- hFlip: false
17
- });
18
- const defaultIconProps = Object.freeze({
19
- ...defaultIconDimensions,
20
- ...defaultIconTransformations
21
- });
22
- const defaultExtendedIconProps = Object.freeze({
23
- ...defaultIconProps,
24
- body: "",
25
- hidden: false
26
- });
27
-
28
- const defaultIconSizeCustomisations = Object.freeze({
29
- width: null,
30
- height: null
31
- });
32
- const defaultIconCustomisations = Object.freeze({
33
- // Dimensions
34
- ...defaultIconSizeCustomisations,
35
- // Transformations
36
- ...defaultIconTransformations
37
- });
38
-
39
- function mergeIconTransformations(obj1, obj2) {
40
- const result = {};
41
- if (!obj1.hFlip !== !obj2.hFlip) {
42
- result.hFlip = true;
43
- }
44
- if (!obj1.vFlip !== !obj2.vFlip) {
45
- result.vFlip = true;
46
- }
47
- const rotate = ((obj1.rotate || 0) + (obj2.rotate || 0)) % 4;
48
- if (rotate) {
49
- result.rotate = rotate;
50
- }
51
- return result;
52
- }
53
-
54
- function mergeIconData(parent, child) {
55
- const result = mergeIconTransformations(parent, child);
56
- for (const key in defaultExtendedIconProps) {
57
- if (key in defaultIconTransformations) {
58
- if (key in parent && !(key in result)) {
59
- result[key] = defaultIconTransformations[key];
60
- }
61
- } else if (key in child) {
62
- result[key] = child[key];
63
- } else if (key in parent) {
64
- result[key] = parent[key];
65
- }
66
- }
67
- return result;
68
- }
69
-
70
- function getIconsTree(data, names) {
71
- const icons = data.icons;
72
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
73
- const resolved = /* @__PURE__ */ Object.create(null);
74
- function resolve(name) {
75
- if (icons[name]) {
76
- return resolved[name] = [];
77
- }
78
- if (!(name in resolved)) {
79
- resolved[name] = null;
80
- const parent = aliases[name] && aliases[name].parent;
81
- const value = parent && resolve(parent);
82
- if (value) {
83
- resolved[name] = [parent].concat(value);
84
- }
85
- }
86
- return resolved[name];
87
- }
88
- (names || Object.keys(icons).concat(Object.keys(aliases))).forEach(resolve);
89
- return resolved;
90
- }
91
-
92
- function internalGetIconData(data, name, tree) {
93
- const icons = data.icons;
94
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
95
- let currentProps = {};
96
- function parse(name2) {
97
- currentProps = mergeIconData(
98
- icons[name2] || aliases[name2],
99
- currentProps
100
- );
101
- }
102
- parse(name);
103
- tree.forEach(parse);
104
- return mergeIconData(data, currentProps);
105
- }
106
- function getIconData(data, name) {
107
- if (data.icons[name]) {
108
- return internalGetIconData(data, name, []);
109
- }
110
- const tree = getIconsTree(data, [name])[name];
111
- return tree ? internalGetIconData(data, name, tree) : null;
112
- }
113
-
114
- const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
115
- const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
116
- function calculateSize(size, ratio, precision) {
117
- if (ratio === 1) {
118
- return size;
119
- }
120
- precision = precision || 100;
121
- if (typeof size === "number") {
122
- return Math.ceil(size * ratio * precision) / precision;
123
- }
124
- if (typeof size !== "string") {
125
- return size;
126
- }
127
- const oldParts = size.split(unitsSplit);
128
- if (oldParts === null || !oldParts.length) {
129
- return size;
130
- }
131
- const newParts = [];
132
- let code = oldParts.shift();
133
- let isNumber = unitsTest.test(code);
134
- while (true) {
135
- if (isNumber) {
136
- const num = parseFloat(code);
137
- if (isNaN(num)) {
138
- newParts.push(code);
139
- } else {
140
- newParts.push(Math.ceil(num * ratio * precision) / precision);
141
- }
142
- } else {
143
- newParts.push(code);
144
- }
145
- code = oldParts.shift();
146
- if (code === void 0) {
147
- return newParts.join("");
148
- }
149
- isNumber = !isNumber;
150
- }
151
- }
152
-
153
- function splitSVGDefs(content, tag = "defs") {
154
- let defs = "";
155
- const index = content.indexOf("<" + tag);
156
- while (index >= 0) {
157
- const start = content.indexOf(">", index);
158
- const end = content.indexOf("</" + tag);
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 mergeDefsAndContent(defs, content) {
175
- return defs ? "<defs>" + defs + "</defs>" + content : content;
176
- }
177
- function wrapSVGContent(body, start, end) {
178
- const split = splitSVGDefs(body);
179
- return mergeDefsAndContent(split.defs, start + split.content + end);
180
- }
181
-
182
- const isUnsetKeyword = (value) => value === "unset" || value === "undefined" || value === "none";
183
- function iconToSVG(icon, customisations) {
184
- const fullIcon = {
185
- ...defaultIconProps,
186
- ...icon
187
- };
188
- const fullCustomisations = {
189
- ...defaultIconCustomisations,
190
- ...customisations
191
- };
192
- const box = {
193
- left: fullIcon.left,
194
- top: fullIcon.top,
195
- width: fullIcon.width,
196
- height: fullIcon.height
197
- };
198
- let body = fullIcon.body;
199
- [fullIcon, fullCustomisations].forEach((props) => {
200
- const transformations = [];
201
- const hFlip = props.hFlip;
202
- const vFlip = props.vFlip;
203
- let rotation = props.rotate;
204
- if (hFlip) {
205
- if (vFlip) {
206
- rotation += 2;
207
- } else {
208
- transformations.push(
209
- "translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")"
210
- );
211
- transformations.push("scale(-1 1)");
212
- box.top = box.left = 0;
213
- }
214
- } else if (vFlip) {
215
- transformations.push(
216
- "translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")"
217
- );
218
- transformations.push("scale(1 -1)");
219
- box.top = box.left = 0;
220
- }
221
- let tempValue;
222
- if (rotation < 0) {
223
- rotation -= Math.floor(rotation / 4) * 4;
224
- }
225
- rotation = rotation % 4;
226
- switch (rotation) {
227
- case 1:
228
- tempValue = box.height / 2 + box.top;
229
- transformations.unshift(
230
- "rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")"
231
- );
232
- break;
233
- case 2:
234
- transformations.unshift(
235
- "rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")"
236
- );
237
- break;
238
- case 3:
239
- tempValue = box.width / 2 + box.left;
240
- transformations.unshift(
241
- "rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")"
242
- );
243
- break;
244
- }
245
- if (rotation % 2 === 1) {
246
- if (box.left !== box.top) {
247
- tempValue = box.left;
248
- box.left = box.top;
249
- box.top = tempValue;
250
- }
251
- if (box.width !== box.height) {
252
- tempValue = box.width;
253
- box.width = box.height;
254
- box.height = tempValue;
255
- }
256
- }
257
- if (transformations.length) {
258
- body = wrapSVGContent(
259
- body,
260
- '<g transform="' + transformations.join(" ") + '">',
261
- "</g>"
262
- );
263
- }
264
- });
265
- const customisationsWidth = fullCustomisations.width;
266
- const customisationsHeight = fullCustomisations.height;
267
- const boxWidth = box.width;
268
- const boxHeight = box.height;
269
- let width;
270
- let height;
271
- if (customisationsWidth === null) {
272
- height = customisationsHeight === null ? "1em" : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
273
- width = calculateSize(height, boxWidth / boxHeight);
274
- } else {
275
- width = customisationsWidth === "auto" ? boxWidth : customisationsWidth;
276
- height = customisationsHeight === null ? calculateSize(width, boxHeight / boxWidth) : customisationsHeight === "auto" ? boxHeight : customisationsHeight;
277
- }
278
- const attributes = {};
279
- const setAttr = (prop, value) => {
280
- if (!isUnsetKeyword(value)) {
281
- attributes[prop] = value.toString();
282
- }
283
- };
284
- setAttr("width", width);
285
- setAttr("height", height);
286
- const viewBox = [box.left, box.top, boxWidth, boxHeight];
287
- attributes.viewBox = viewBox.join(" ");
288
- return {
289
- attributes,
290
- viewBox,
291
- body
292
- };
293
- }
294
-
295
- function encodeSVGforURL(svg) {
296
- return svg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/</g, "%3C").replace(/>/g, "%3E").replace(/\s+/g, " ");
297
- }
298
-
299
- function encodeSvgForCss(svg) {
300
- let useSvg = svg.startsWith("<svg>") ? svg.replace("<svg>", "<svg >") : svg;
301
- if (!useSvg.includes(" xmlns:xlink=") && useSvg.includes(" xlink:")) {
302
- useSvg = useSvg.replace(
303
- "<svg ",
304
- '<svg xmlns:xlink="http://www.w3.org/1999/xlink" '
305
- );
306
- }
307
- if (!useSvg.includes(" xmlns=")) {
308
- useSvg = useSvg.replace(
309
- "<svg ",
310
- '<svg xmlns="http://www.w3.org/2000/svg" '
311
- );
312
- }
313
- return encodeSVGforURL(useSvg);
314
- }
315
-
316
- function trimSVG(str) {
317
- 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();
318
- }
319
-
320
- const svgWidthRegex = /\swidth\s*=\s*["']([\w.]+)["']/;
321
- const svgHeightRegex = /\sheight\s*=\s*["']([\w.]+)["']/;
322
- const svgTagRegex = /<svg\s+/;
323
- function configureSvgSize(svg, props, scale) {
324
- const svgNode = svg.slice(0, svg.indexOf(">"));
325
- const check = (prop, regex) => {
326
- const result = regex.exec(svgNode);
327
- const isSet = result != null;
328
- const propValue = props[prop];
329
- if (!propValue && !isUnsetKeyword(propValue)) {
330
- if (typeof scale === "number") {
331
- if (scale > 0) {
332
- props[prop] = `${scale}em`;
333
- }
334
- } else if (result) {
335
- props[prop] = result[1];
336
- }
337
- }
338
- return isSet;
339
- };
340
- return [check("width", svgWidthRegex), check("height", svgHeightRegex)];
341
- }
342
- async function mergeIconProps(svg, collection, icon, options, propsProvider, afterCustomizations) {
343
- const { scale, addXmlNs = false } = options ?? {};
344
- const { additionalProps = {}, iconCustomizer } = options?.customizations ?? {};
345
- const props = await propsProvider?.() ?? {};
346
- await iconCustomizer?.(collection, icon, props);
347
- Object.keys(additionalProps).forEach((p) => {
348
- const v = additionalProps[p];
349
- if (v !== void 0 && v !== null)
350
- props[p] = v;
351
- });
352
- afterCustomizations?.(props);
353
- const [widthOnSvg, heightOnSvg] = configureSvgSize(svg, props, scale);
354
- if (addXmlNs) {
355
- if (!svg.includes("xmlns=") && !props["xmlns"]) {
356
- props["xmlns"] = "http://www.w3.org/2000/svg";
357
- }
358
- if (!svg.includes("xmlns:xlink=") && svg.includes("xlink:") && !props["xmlns:xlink"]) {
359
- props["xmlns:xlink"] = "http://www.w3.org/1999/xlink";
360
- }
361
- }
362
- const propsToAdd = Object.keys(props).map(
363
- (p) => p === "width" && widthOnSvg || p === "height" && heightOnSvg ? null : `${p}="${props[p]}"`
364
- ).filter((p) => p != null);
365
- if (propsToAdd.length) {
366
- svg = svg.replace(svgTagRegex, `<svg ${propsToAdd.join(" ")} `);
367
- }
368
- if (options) {
369
- const { defaultStyle, defaultClass } = options;
370
- if (defaultClass && !svg.includes("class=")) {
371
- svg = svg.replace(svgTagRegex, `<svg class="${defaultClass}" `);
372
- }
373
- if (defaultStyle && !svg.includes("style=")) {
374
- svg = svg.replace(svgTagRegex, `<svg style="${defaultStyle}" `);
375
- }
376
- }
377
- const usedProps = options?.usedProps;
378
- if (usedProps) {
379
- Object.keys(additionalProps).forEach((p) => {
380
- const v = props[p];
381
- if (v !== void 0 && v !== null)
382
- usedProps[p] = v;
383
- });
384
- if (typeof props.width !== "undefined" && props.width !== null) {
385
- usedProps.width = props.width;
386
- }
387
- if (typeof props.height !== "undefined" && props.height !== null) {
388
- usedProps.height = props.height;
389
- }
390
- }
391
- return svg;
392
- }
393
-
394
- async function getCustomIcon(custom, collection, icon, options) {
395
- let result;
396
- try {
397
- if (typeof custom === "function") {
398
- result = await custom(icon);
399
- } else {
400
- const inline = custom[icon];
401
- result = typeof inline === "function" ? await inline() : inline;
402
- }
403
- } catch (err) {
404
- console.warn(
405
- `Failed to load custom icon "${icon}" in "${collection}":`,
406
- err
407
- );
408
- return;
409
- }
410
- if (result) {
411
- const cleanupIdx = result.indexOf("<svg");
412
- if (cleanupIdx > 0)
413
- result = result.slice(cleanupIdx);
414
- const { transform } = options?.customizations ?? {};
415
- result = typeof transform === "function" ? await transform(result, collection, icon) : result;
416
- if (!result.startsWith("<svg")) {
417
- console.warn(
418
- `Custom icon "${icon}" in "${collection}" is not a valid SVG`
419
- );
420
- return result;
421
- }
422
- return await mergeIconProps(
423
- options?.customizations?.trimCustomSvg === true ? trimSVG(result) : result,
424
- collection,
425
- icon,
426
- options,
427
- void 0
428
- );
429
- }
430
- }
431
-
432
- async function searchForIcon(iconSet, collection, ids, options) {
433
- let iconData;
434
- const { customize } = options?.customizations ?? {};
435
- for (const id of ids) {
436
- iconData = getIconData(iconSet, id);
437
- if (iconData) {
438
- let defaultCustomizations = { ...defaultIconCustomisations };
439
- if (typeof customize === "function")
440
- defaultCustomizations = customize(defaultCustomizations);
441
- const {
442
- attributes: { width, height, ...restAttributes },
443
- body
444
- } = iconToSVG(iconData, defaultCustomizations);
445
- const scale = options?.scale;
446
- return await mergeIconProps(
447
- // DON'T remove space on <svg >
448
- `<svg >${body}</svg>`,
449
- collection,
450
- id,
451
- options,
452
- () => {
453
- return { ...restAttributes };
454
- },
455
- (props) => {
456
- const check = (prop, defaultValue) => {
457
- const propValue = props[prop];
458
- let value;
459
- if (!isUnsetKeyword(propValue)) {
460
- if (propValue) {
461
- return;
462
- }
463
- if (typeof scale === "number") {
464
- if (scale) {
465
- value = `${scale}em`;
466
- }
467
- } else {
468
- value = defaultValue;
469
- }
470
- }
471
- if (!value) {
472
- delete props[prop];
473
- } else {
474
- props[prop] = value;
475
- }
476
- };
477
- check("width", width);
478
- check("height", height);
479
- }
480
- );
481
- }
482
- }
483
- }
484
-
485
- const loadIcon = async (collection, icon, options) => {
486
- const custom = options?.customCollections?.[collection];
487
- if (custom) {
488
- if (typeof custom === "function") {
489
- let result;
490
- try {
491
- result = await custom(icon);
492
- } catch (err) {
493
- console.warn(
494
- `Failed to load custom icon "${icon}" in "${collection}":`,
495
- err
496
- );
497
- return;
498
- }
499
- if (result) {
500
- if (typeof result === "string") {
501
- return await getCustomIcon(
502
- () => result,
503
- collection,
504
- icon,
505
- options
506
- );
507
- }
508
- if ("icons" in result) {
509
- const ids = [
510
- icon,
511
- icon.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(),
512
- icon.replace(/([a-z])(\d+)/g, "$1-$2")
513
- ];
514
- return await searchForIcon(
515
- result,
516
- collection,
517
- ids,
518
- options
519
- );
520
- }
521
- }
522
- } else {
523
- return await getCustomIcon(custom, collection, icon, options);
524
- }
525
- }
526
- };
527
-
528
- function getDefaultExportFromCjs (x) {
529
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
530
- }
531
-
532
- var collections = [
533
- "academicons",
534
- "akar-icons",
535
- "ant-design",
536
- "arcticons",
537
- "basil",
538
- "bi",
539
- "bitcoin-icons",
540
- "bpmn",
541
- "brandico",
542
- "bx",
543
- "bxl",
544
- "bxs",
545
- "bytesize",
546
- "carbon",
547
- "cbi",
548
- "charm",
549
- "ci",
550
- "cib",
551
- "cif",
552
- "cil",
553
- "circle-flags",
554
- "circum",
555
- "clarity",
556
- "codicon",
557
- "covid",
558
- "cryptocurrency-color",
559
- "cryptocurrency",
560
- "dashicons",
561
- "devicon-line",
562
- "devicon-original",
563
- "devicon-plain",
564
- "devicon",
565
- "ei",
566
- "el",
567
- "emblemicons",
568
- "emojione-monotone",
569
- "emojione-v1",
570
- "emojione",
571
- "entypo-social",
572
- "entypo",
573
- "eos-icons",
574
- "ep",
575
- "et",
576
- "eva",
577
- "f7",
578
- "fa-brands",
579
- "fa-regular",
580
- "fa-solid",
581
- "fa",
582
- "fa6-brands",
583
- "fa6-regular",
584
- "fa6-solid",
585
- "fad",
586
- "fe",
587
- "feather",
588
- "file-icons",
589
- "flag",
590
- "flagpack",
591
- "flat-color-icons",
592
- "flat-ui",
593
- "flowbite",
594
- "fluent-emoji-flat",
595
- "fluent-emoji-high-contrast",
596
- "fluent-emoji",
597
- "fluent-mdl2",
598
- "fluent",
599
- "fontelico",
600
- "fontisto",
601
- "formkit",
602
- "foundation",
603
- "fxemoji",
604
- "gala",
605
- "game-icons",
606
- "geo",
607
- "gg",
608
- "gis",
609
- "gravity-ui",
610
- "gridicons",
611
- "grommet-icons",
612
- "guidance",
613
- "healthicons",
614
- "heroicons-outline",
615
- "heroicons-solid",
616
- "heroicons",
617
- "humbleicons",
618
- "ic",
619
- "icomoon-free",
620
- "icon-park-outline",
621
- "icon-park-solid",
622
- "icon-park-twotone",
623
- "icon-park",
624
- "iconamoon",
625
- "iconoir",
626
- "icons8",
627
- "il",
628
- "ion",
629
- "iwwa",
630
- "jam",
631
- "la",
632
- "lets-icons",
633
- "line-md",
634
- "logos",
635
- "ls",
636
- "lucide",
637
- "mage",
638
- "majesticons",
639
- "maki",
640
- "map",
641
- "material-symbols-light",
642
- "material-symbols",
643
- "mdi-light",
644
- "mdi",
645
- "medical-icon",
646
- "memory",
647
- "meteocons",
648
- "mi",
649
- "mingcute",
650
- "mono-icons",
651
- "mynaui",
652
- "nimbus",
653
- "nonicons",
654
- "noto-v1",
655
- "noto",
656
- "octicon",
657
- "oi",
658
- "ooui",
659
- "openmoji",
660
- "oui",
661
- "pajamas",
662
- "pepicons-pencil",
663
- "pepicons-pop",
664
- "pepicons-print",
665
- "pepicons",
666
- "ph",
667
- "pixelarticons",
668
- "prime",
669
- "ps",
670
- "quill",
671
- "radix-icons",
672
- "raphael",
673
- "ri",
674
- "si-glyph",
675
- "simple-icons",
676
- "simple-line-icons",
677
- "skill-icons",
678
- "solar",
679
- "streamline-emojis",
680
- "streamline",
681
- "subway",
682
- "svg-spinners",
683
- "system-uicons",
684
- "tabler",
685
- "tdesign",
686
- "teenyicons",
687
- "topcoat",
688
- "twemoji",
689
- "typcn",
690
- "uil",
691
- "uim",
692
- "uis",
693
- "uit",
694
- "uiw",
695
- "unjs",
696
- "vaadin",
697
- "vs",
698
- "vscode-icons",
699
- "websymbol",
700
- "whh",
701
- "wi",
702
- "wpf",
703
- "zmdi",
704
- "zondicons"
705
- ];
706
-
707
- const icons = /*@__PURE__*/getDefaultExportFromCjs(collections);
708
-
709
- const COLLECTION_NAME_PARTS_MAX = 3;
710
- function createPresetIcons(lookupIconLoader) {
711
- return core.definePreset((options = {}) => {
712
- const {
713
- scale = 1,
714
- mode = "auto",
715
- prefix = "i-",
716
- warn = false,
717
- collections: customCollections,
718
- extraProperties = {},
719
- customizations = {},
720
- autoInstall = false,
721
- collectionsNodeResolvePath,
722
- layer = "icons",
723
- unit
724
- } = options;
725
- const flags = getEnvFlags();
726
- const loaderOptions = {
727
- addXmlNs: true,
728
- scale,
729
- customCollections,
730
- autoInstall,
731
- cwd: collectionsNodeResolvePath,
732
- // avoid warn from @iconify/loader: we'll warn below if not found
733
- warn: void 0,
734
- customizations: {
735
- ...customizations,
736
- additionalProps: { ...extraProperties },
737
- trimCustomSvg: true,
738
- async iconCustomizer(collection, icon, props) {
739
- await customizations.iconCustomizer?.(collection, icon, props);
740
- if (unit) {
741
- if (!props.width)
742
- props.width = `${scale}${unit}`;
743
- if (!props.height)
744
- props.height = `${scale}${unit}`;
745
- }
746
- }
747
- }
748
- };
749
- let iconLoader;
750
- return {
751
- name: "@unocss/preset-icons",
752
- enforce: "pre",
753
- options,
754
- layers: { icons: -30 },
755
- rules: [[
756
- /^([a-z0-9:_-]+)(?:\?(mask|bg|auto))?$/,
757
- async ([full, body, _mode = mode]) => {
758
- let collection = "";
759
- let name = "";
760
- let svg;
761
- iconLoader = iconLoader || await lookupIconLoader(options);
762
- const usedProps = {};
763
- if (body.includes(":")) {
764
- [collection, name] = body.split(":");
765
- svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
766
- } else {
767
- const parts = body.split(/-/g);
768
- for (let i = COLLECTION_NAME_PARTS_MAX; i >= 1; i--) {
769
- collection = parts.slice(0, i).join("-");
770
- name = parts.slice(i).join("-");
771
- svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
772
- if (svg)
773
- break;
774
- }
775
- }
776
- if (!svg) {
777
- if (warn && !flags.isESLint)
778
- core.warnOnce(`failed to load icon "${full}"`);
779
- return;
780
- }
781
- const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(svg)}")`;
782
- if (_mode === "auto")
783
- _mode = svg.includes("currentColor") ? "mask" : "bg";
784
- if (_mode === "mask") {
785
- return {
786
- "--un-icon": url,
787
- "-webkit-mask": "var(--un-icon) no-repeat",
788
- "mask": "var(--un-icon) no-repeat",
789
- "-webkit-mask-size": "100% 100%",
790
- "mask-size": "100% 100%",
791
- "background-color": "currentColor",
792
- // for Safari https://github.com/elk-zone/elk/pull/264
793
- "color": "inherit",
794
- ...usedProps
795
- };
796
- } else {
797
- return {
798
- "background": `${url} no-repeat`,
799
- "background-size": "100% 100%",
800
- "background-color": "transparent",
801
- ...usedProps
802
- };
803
- }
804
- },
805
- { layer, prefix }
806
- ]]
807
- };
808
- });
809
- }
810
- function combineLoaders(loaders) {
811
- return async (...args) => {
812
- for (const loader of loaders) {
813
- if (!loader)
814
- continue;
815
- const result = await loader(...args);
816
- if (result)
817
- return result;
818
- }
819
- };
820
- }
821
- function createCDNFetchLoader(fetcher, cdnBase) {
822
- const cache = /* @__PURE__ */ new Map();
823
- function fetchCollection(name) {
824
- if (!icons.includes(name))
825
- return void 0;
826
- if (!cache.has(name))
827
- cache.set(name, fetcher(`${cdnBase}@iconify-json/${name}/icons.json`));
828
- return cache.get(name);
829
- }
830
- return async (collection, icon, options) => {
831
- let result = await loadIcon(collection, icon, options);
832
- if (result)
833
- return result;
834
- const iconSet = await fetchCollection(collection);
835
- if (iconSet) {
836
- const ids = [
837
- icon,
838
- icon.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(),
839
- icon.replace(/([a-z])(\d+)/g, "$1-$2")
840
- ];
841
- result = await searchForIcon(iconSet, collection, ids, options);
842
- }
843
- return result;
844
- };
845
- }
846
- function getEnvFlags() {
847
- const isNode = typeof process !== "undefined" && process.stdout && !process.versions.deno;
848
- const isVSCode = isNode && !!process.env.VSCODE_CWD;
849
- const isESLint = isNode && !!process.env.ESLINT;
850
- return {
851
- isNode,
852
- isVSCode,
853
- isESLint
854
- };
855
- }
856
-
857
- exports.combineLoaders = combineLoaders;
858
- exports.createCDNFetchLoader = createCDNFetchLoader;
859
- exports.createPresetIcons = createPresetIcons;
860
- exports.getEnvFlags = getEnvFlags;
861
- exports.icons = icons;
862
- exports.loadIcon = loadIcon;