@unocss/preset-icons 0.44.3 → 0.44.7
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/README.md +4 -0
- package/dist/browser.cjs +19 -0
- package/dist/browser.d.ts +9 -0
- package/dist/browser.mjs +14 -0
- package/dist/chunks/cdn.cjs +440 -0
- package/dist/chunks/cdn.mjs +437 -0
- package/dist/core.cjs +114 -0
- package/dist/core.d.ts +82 -0
- package/dist/core.mjs +110 -0
- package/dist/index.cjs +20 -139
- package/dist/index.d.ts +7 -80
- package/dist/index.mjs +18 -137
- package/package.json +12 -2
package/dist/core.mjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { warnOnce } from '@unocss/core';
|
|
2
|
+
|
|
3
|
+
function encodeSvgForCss(svg) {
|
|
4
|
+
let useSvg = svg.startsWith("<svg>") ? svg.replace("<svg>", "<svg >") : svg;
|
|
5
|
+
if (!useSvg.includes(" xmlns:xlink=") && useSvg.includes(" xlink:")) {
|
|
6
|
+
useSvg = useSvg.replace("<svg ", '<svg xmlns:xlink="http://www.w3.org/1999/xlink" ');
|
|
7
|
+
}
|
|
8
|
+
if (!useSvg.includes(" xmlns=")) {
|
|
9
|
+
useSvg = useSvg.replace("<svg ", '<svg xmlns="http://www.w3.org/2000/svg" ');
|
|
10
|
+
}
|
|
11
|
+
return useSvg.replace(/"/g, "'").replace(/%/g, "%25").replace(/#/g, "%23").replace(/{/g, "%7B").replace(/}/g, "%7D").replace(/</g, "%3C").replace(/>/g, "%3E");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const COLLECTION_NAME_PARTS_MAX = 3;
|
|
15
|
+
function createPresetIcons(lookupIconLoader) {
|
|
16
|
+
return function presetIcons(options = {}) {
|
|
17
|
+
const {
|
|
18
|
+
scale = 1,
|
|
19
|
+
mode = "auto",
|
|
20
|
+
prefix = "i-",
|
|
21
|
+
warn = false,
|
|
22
|
+
collections: customCollections,
|
|
23
|
+
extraProperties = {},
|
|
24
|
+
customizations = {},
|
|
25
|
+
autoInstall = false,
|
|
26
|
+
layer = "icons",
|
|
27
|
+
unit
|
|
28
|
+
} = options;
|
|
29
|
+
const loaderOptions = {
|
|
30
|
+
addXmlNs: true,
|
|
31
|
+
scale,
|
|
32
|
+
customCollections,
|
|
33
|
+
autoInstall,
|
|
34
|
+
warn: void 0,
|
|
35
|
+
customizations: {
|
|
36
|
+
...customizations,
|
|
37
|
+
additionalProps: { ...extraProperties },
|
|
38
|
+
trimCustomSvg: true,
|
|
39
|
+
async iconCustomizer(collection, icon, props) {
|
|
40
|
+
await customizations.iconCustomizer?.(collection, icon, props);
|
|
41
|
+
if (unit) {
|
|
42
|
+
if (!props.width)
|
|
43
|
+
props.width = `${scale}${unit}`;
|
|
44
|
+
if (!props.height)
|
|
45
|
+
props.height = `${scale}${unit}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
let iconLoader;
|
|
51
|
+
return {
|
|
52
|
+
name: "@unocss/preset-icons",
|
|
53
|
+
enforce: "pre",
|
|
54
|
+
options,
|
|
55
|
+
layers: { icons: -30 },
|
|
56
|
+
rules: [[
|
|
57
|
+
/^([a-z0-9:-]+)(?:\?(mask|bg|auto))?$/,
|
|
58
|
+
async ([full, body, _mode = mode]) => {
|
|
59
|
+
let collection = "";
|
|
60
|
+
let name = "";
|
|
61
|
+
let svg;
|
|
62
|
+
iconLoader = iconLoader || await lookupIconLoader(options);
|
|
63
|
+
const usedProps = {};
|
|
64
|
+
if (body.includes(":")) {
|
|
65
|
+
[collection, name] = body.split(":");
|
|
66
|
+
svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
|
|
67
|
+
} else {
|
|
68
|
+
const parts = body.split(/-/g);
|
|
69
|
+
for (let i = COLLECTION_NAME_PARTS_MAX; i >= 1; i--) {
|
|
70
|
+
collection = parts.slice(0, i).join("-");
|
|
71
|
+
name = parts.slice(i).join("-");
|
|
72
|
+
svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
|
|
73
|
+
if (svg)
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!svg) {
|
|
78
|
+
if (warn)
|
|
79
|
+
warnOnce(`failed to load icon "${full}"`);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(svg)}")`;
|
|
83
|
+
if (_mode === "auto")
|
|
84
|
+
_mode = svg.includes("currentColor") ? "mask" : "bg";
|
|
85
|
+
if (_mode === "mask") {
|
|
86
|
+
return {
|
|
87
|
+
"--un-icon": url,
|
|
88
|
+
"mask": "var(--un-icon) no-repeat",
|
|
89
|
+
"mask-size": "100% 100%",
|
|
90
|
+
"-webkit-mask": "var(--un-icon) no-repeat",
|
|
91
|
+
"-webkit-mask-size": "100% 100%",
|
|
92
|
+
"background-color": "currentColor",
|
|
93
|
+
...usedProps
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
return {
|
|
97
|
+
"background": `${url} no-repeat`,
|
|
98
|
+
"background-size": "100% 100%",
|
|
99
|
+
"background-color": "transparent",
|
|
100
|
+
...usedProps
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
{ layer, prefix }
|
|
105
|
+
]]
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { createPresetIcons };
|
package/dist/index.cjs
CHANGED
|
@@ -2,152 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const modern = require('@iconify/utils/lib/loader/modern');
|
|
10
|
-
const ohmyfetch = require('ohmyfetch');
|
|
5
|
+
const cdn = require('./chunks/cdn.cjs');
|
|
6
|
+
const core = require('./core.cjs');
|
|
7
|
+
require('ohmyfetch');
|
|
8
|
+
require('@unocss/core');
|
|
11
9
|
|
|
12
10
|
const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions.deno;
|
|
13
11
|
const isVSCode = isNode && !!process.env.VSCODE_CWD;
|
|
14
12
|
|
|
15
|
-
const
|
|
16
|
-
function createCDNLoader(cdnBase) {
|
|
17
|
-
const cache = /* @__PURE__ */ new Map();
|
|
18
|
-
function fetchCollection(name) {
|
|
19
|
-
if (!supportedCollection.includes(name))
|
|
20
|
-
return void 0;
|
|
21
|
-
if (!cache.has(name))
|
|
22
|
-
cache.set(name, ohmyfetch.$fetch(`${cdnBase}@iconify-json/${name}/icons.json`));
|
|
23
|
-
return cache.get(name);
|
|
24
|
-
}
|
|
25
|
-
return async (collection, icon, options) => {
|
|
26
|
-
let result = await loader.loadIcon(collection, icon, options);
|
|
27
|
-
if (result)
|
|
28
|
-
return result;
|
|
29
|
-
const iconSet = await fetchCollection(collection);
|
|
30
|
-
if (iconSet) {
|
|
31
|
-
const ids = [
|
|
32
|
-
icon,
|
|
33
|
-
icon.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(),
|
|
34
|
-
icon.replace(/([a-z])(\d+)/g, "$1-$2")
|
|
35
|
-
];
|
|
36
|
-
result = await modern.searchForIcon(iconSet, collection, ids, options);
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const COLLECTION_NAME_PARTS_MAX = 3;
|
|
43
|
-
const preset = (options = {}) => {
|
|
13
|
+
const presetIcons = core.createPresetIcons(async (options) => {
|
|
44
14
|
const {
|
|
45
|
-
|
|
46
|
-
mode = "auto",
|
|
47
|
-
prefix = "i-",
|
|
48
|
-
warn = false,
|
|
49
|
-
collections: customCollections,
|
|
50
|
-
extraProperties = {},
|
|
51
|
-
customizations = {},
|
|
52
|
-
autoInstall = false,
|
|
53
|
-
layer = "icons",
|
|
54
|
-
unit,
|
|
55
|
-
cdn
|
|
15
|
+
cdn: cdn$1
|
|
56
16
|
} = options;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
customizations: {
|
|
64
|
-
...customizations,
|
|
65
|
-
additionalProps: { ...extraProperties },
|
|
66
|
-
trimCustomSvg: true,
|
|
67
|
-
async iconCustomizer(collection, icon, props) {
|
|
68
|
-
await customizations.iconCustomizer?.(collection, icon, props);
|
|
69
|
-
if (unit) {
|
|
70
|
-
if (!props.width)
|
|
71
|
-
props.width = `${scale}${unit}`;
|
|
72
|
-
if (!props.height)
|
|
73
|
-
props.height = `${scale}${unit}`;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
17
|
+
if (cdn$1)
|
|
18
|
+
return cdn.createCDNLoader(cdn$1);
|
|
19
|
+
if (isNode && !isVSCode) {
|
|
20
|
+
try {
|
|
21
|
+
return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
|
|
22
|
+
} catch {
|
|
76
23
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return createCDNLoader(cdn);
|
|
81
|
-
if (isNode && !isVSCode) {
|
|
82
|
-
try {
|
|
83
|
-
return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
|
|
84
|
-
} catch {
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
return require("@iconify/utils/lib/loader/node-loader.cjs");
|
|
88
|
-
} catch {
|
|
89
|
-
}
|
|
24
|
+
try {
|
|
25
|
+
return require("@iconify/utils/lib/loader/node-loader.cjs");
|
|
26
|
+
} catch {
|
|
90
27
|
}
|
|
91
|
-
return utils.loadIcon;
|
|
92
28
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
name: "@unocss/preset-icons",
|
|
96
|
-
enforce: "pre",
|
|
97
|
-
options,
|
|
98
|
-
layers: { icons: -30 },
|
|
99
|
-
rules: [[
|
|
100
|
-
/^([a-z0-9:-]+)(?:\?(mask|bg|auto))?$/,
|
|
101
|
-
async ([full, body, _mode = mode]) => {
|
|
102
|
-
let collection = "";
|
|
103
|
-
let name = "";
|
|
104
|
-
let svg;
|
|
105
|
-
iconLoader = iconLoader || await lookupIconLoader();
|
|
106
|
-
const usedProps = {};
|
|
107
|
-
if (body.includes(":")) {
|
|
108
|
-
[collection, name] = body.split(":");
|
|
109
|
-
svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
|
|
110
|
-
} else {
|
|
111
|
-
const parts = body.split(/-/g);
|
|
112
|
-
for (let i = COLLECTION_NAME_PARTS_MAX; i >= 1; i--) {
|
|
113
|
-
collection = parts.slice(0, i).join("-");
|
|
114
|
-
name = parts.slice(i).join("-");
|
|
115
|
-
svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
|
|
116
|
-
if (svg)
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
if (!svg) {
|
|
121
|
-
if (warn)
|
|
122
|
-
core.warnOnce(`failed to load icon "${full}"`);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss.encodeSvgForCss(svg)}")`;
|
|
126
|
-
if (_mode === "auto")
|
|
127
|
-
_mode = svg.includes("currentColor") ? "mask" : "bg";
|
|
128
|
-
if (_mode === "mask") {
|
|
129
|
-
return {
|
|
130
|
-
"--un-icon": url,
|
|
131
|
-
"mask": "var(--un-icon) no-repeat",
|
|
132
|
-
"mask-size": "100% 100%",
|
|
133
|
-
"-webkit-mask": "var(--un-icon) no-repeat",
|
|
134
|
-
"-webkit-mask-size": "100% 100%",
|
|
135
|
-
"background-color": "currentColor",
|
|
136
|
-
...usedProps
|
|
137
|
-
};
|
|
138
|
-
} else {
|
|
139
|
-
return {
|
|
140
|
-
"background": `${url} no-repeat`,
|
|
141
|
-
"background-size": "100% 100%",
|
|
142
|
-
"background-color": "transparent",
|
|
143
|
-
...usedProps
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{ layer, prefix }
|
|
148
|
-
]]
|
|
149
|
-
};
|
|
150
|
-
};
|
|
29
|
+
return cdn.loadIcon;
|
|
30
|
+
});
|
|
151
31
|
|
|
152
|
-
exports
|
|
153
|
-
exports
|
|
32
|
+
exports.createPresetIcons = core.createPresetIcons;
|
|
33
|
+
exports["default"] = presetIcons;
|
|
34
|
+
exports.presetIcons = presetIcons;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,82 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import * as _unocss_core from '@unocss/core';
|
|
2
|
+
import { IconsOptions } from './core.js';
|
|
3
|
+
export { IconsOptions, createPresetIcons } from './core.js';
|
|
4
|
+
import '@iconify/utils/lib/loader/types';
|
|
5
|
+
import '@iconify/types';
|
|
4
6
|
|
|
5
|
-
|
|
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;
|
|
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
|
-
}
|
|
7
|
+
declare const presetIcons: (options?: IconsOptions) => _unocss_core.Preset<{}>;
|
|
79
8
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export { IconsOptions, preset as default, preset };
|
|
9
|
+
export { presetIcons as default, presetIcons };
|
package/dist/index.mjs
CHANGED
|
@@ -1,148 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { $fetch } from 'ohmyfetch';
|
|
1
|
+
import { c as createCDNLoader, l as loadIcon } from './chunks/cdn.mjs';
|
|
2
|
+
import { createPresetIcons } from './core.mjs';
|
|
3
|
+
export { createPresetIcons } from './core.mjs';
|
|
4
|
+
import 'ohmyfetch';
|
|
5
|
+
import '@unocss/core';
|
|
7
6
|
|
|
8
7
|
const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions.deno;
|
|
9
8
|
const isVSCode = isNode && !!process.env.VSCODE_CWD;
|
|
10
9
|
|
|
11
|
-
const
|
|
12
|
-
function createCDNLoader(cdnBase) {
|
|
13
|
-
const cache = /* @__PURE__ */ new Map();
|
|
14
|
-
function fetchCollection(name) {
|
|
15
|
-
if (!supportedCollection.includes(name))
|
|
16
|
-
return void 0;
|
|
17
|
-
if (!cache.has(name))
|
|
18
|
-
cache.set(name, $fetch(`${cdnBase}@iconify-json/${name}/icons.json`));
|
|
19
|
-
return cache.get(name);
|
|
20
|
-
}
|
|
21
|
-
return async (collection, icon, options) => {
|
|
22
|
-
let result = await loadIcon(collection, icon, options);
|
|
23
|
-
if (result)
|
|
24
|
-
return result;
|
|
25
|
-
const iconSet = await fetchCollection(collection);
|
|
26
|
-
if (iconSet) {
|
|
27
|
-
const ids = [
|
|
28
|
-
icon,
|
|
29
|
-
icon.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase(),
|
|
30
|
-
icon.replace(/([a-z])(\d+)/g, "$1-$2")
|
|
31
|
-
];
|
|
32
|
-
result = await searchForIcon(iconSet, collection, ids, options);
|
|
33
|
-
}
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const COLLECTION_NAME_PARTS_MAX = 3;
|
|
39
|
-
const preset = (options = {}) => {
|
|
10
|
+
const presetIcons = createPresetIcons(async (options) => {
|
|
40
11
|
const {
|
|
41
|
-
scale = 1,
|
|
42
|
-
mode = "auto",
|
|
43
|
-
prefix = "i-",
|
|
44
|
-
warn = false,
|
|
45
|
-
collections: customCollections,
|
|
46
|
-
extraProperties = {},
|
|
47
|
-
customizations = {},
|
|
48
|
-
autoInstall = false,
|
|
49
|
-
layer = "icons",
|
|
50
|
-
unit,
|
|
51
12
|
cdn
|
|
52
13
|
} = options;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
customizations: {
|
|
60
|
-
...customizations,
|
|
61
|
-
additionalProps: { ...extraProperties },
|
|
62
|
-
trimCustomSvg: true,
|
|
63
|
-
async iconCustomizer(collection, icon, props) {
|
|
64
|
-
await customizations.iconCustomizer?.(collection, icon, props);
|
|
65
|
-
if (unit) {
|
|
66
|
-
if (!props.width)
|
|
67
|
-
props.width = `${scale}${unit}`;
|
|
68
|
-
if (!props.height)
|
|
69
|
-
props.height = `${scale}${unit}`;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
14
|
+
if (cdn)
|
|
15
|
+
return createCDNLoader(cdn);
|
|
16
|
+
if (isNode && !isVSCode) {
|
|
17
|
+
try {
|
|
18
|
+
return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
|
|
19
|
+
} catch {
|
|
72
20
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return createCDNLoader(cdn);
|
|
77
|
-
if (isNode && !isVSCode) {
|
|
78
|
-
try {
|
|
79
|
-
return await import('@iconify/utils/lib/loader/node-loader').then((i) => i?.loadNodeIcon);
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
return require("@iconify/utils/lib/loader/node-loader.cjs");
|
|
84
|
-
} catch {
|
|
85
|
-
}
|
|
21
|
+
try {
|
|
22
|
+
return require("@iconify/utils/lib/loader/node-loader.cjs");
|
|
23
|
+
} catch {
|
|
86
24
|
}
|
|
87
|
-
return loadIcon$1;
|
|
88
25
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
name: "@unocss/preset-icons",
|
|
92
|
-
enforce: "pre",
|
|
93
|
-
options,
|
|
94
|
-
layers: { icons: -30 },
|
|
95
|
-
rules: [[
|
|
96
|
-
/^([a-z0-9:-]+)(?:\?(mask|bg|auto))?$/,
|
|
97
|
-
async ([full, body, _mode = mode]) => {
|
|
98
|
-
let collection = "";
|
|
99
|
-
let name = "";
|
|
100
|
-
let svg;
|
|
101
|
-
iconLoader = iconLoader || await lookupIconLoader();
|
|
102
|
-
const usedProps = {};
|
|
103
|
-
if (body.includes(":")) {
|
|
104
|
-
[collection, name] = body.split(":");
|
|
105
|
-
svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
|
|
106
|
-
} else {
|
|
107
|
-
const parts = body.split(/-/g);
|
|
108
|
-
for (let i = COLLECTION_NAME_PARTS_MAX; i >= 1; i--) {
|
|
109
|
-
collection = parts.slice(0, i).join("-");
|
|
110
|
-
name = parts.slice(i).join("-");
|
|
111
|
-
svg = await iconLoader(collection, name, { ...loaderOptions, usedProps });
|
|
112
|
-
if (svg)
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!svg) {
|
|
117
|
-
if (warn)
|
|
118
|
-
warnOnce(`failed to load icon "${full}"`);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(svg)}")`;
|
|
122
|
-
if (_mode === "auto")
|
|
123
|
-
_mode = svg.includes("currentColor") ? "mask" : "bg";
|
|
124
|
-
if (_mode === "mask") {
|
|
125
|
-
return {
|
|
126
|
-
"--un-icon": url,
|
|
127
|
-
"mask": "var(--un-icon) no-repeat",
|
|
128
|
-
"mask-size": "100% 100%",
|
|
129
|
-
"-webkit-mask": "var(--un-icon) no-repeat",
|
|
130
|
-
"-webkit-mask-size": "100% 100%",
|
|
131
|
-
"background-color": "currentColor",
|
|
132
|
-
...usedProps
|
|
133
|
-
};
|
|
134
|
-
} else {
|
|
135
|
-
return {
|
|
136
|
-
"background": `${url} no-repeat`,
|
|
137
|
-
"background-size": "100% 100%",
|
|
138
|
-
"background-color": "transparent",
|
|
139
|
-
...usedProps
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
{ layer, prefix }
|
|
144
|
-
]]
|
|
145
|
-
};
|
|
146
|
-
};
|
|
26
|
+
return loadIcon;
|
|
27
|
+
});
|
|
147
28
|
|
|
148
|
-
export {
|
|
29
|
+
export { presetIcons as default, presetIcons };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unocss/preset-icons",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.7",
|
|
4
4
|
"description": "Pure CSS Icons for UnoCSS",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,6 +27,16 @@
|
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
28
|
"require": "./dist/index.cjs",
|
|
29
29
|
"import": "./dist/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./browser": {
|
|
32
|
+
"types": "./dist/browser.d.ts",
|
|
33
|
+
"require": "./dist/browser.cjs",
|
|
34
|
+
"import": "./dist/browser.mjs"
|
|
35
|
+
},
|
|
36
|
+
"./core": {
|
|
37
|
+
"types": "./dist/core.d.ts",
|
|
38
|
+
"require": "./dist/core.cjs",
|
|
39
|
+
"import": "./dist/core.mjs"
|
|
30
40
|
}
|
|
31
41
|
},
|
|
32
42
|
"main": "dist/index.cjs",
|
|
@@ -38,7 +48,7 @@
|
|
|
38
48
|
],
|
|
39
49
|
"dependencies": {
|
|
40
50
|
"@iconify/utils": "^1.0.33",
|
|
41
|
-
"@unocss/core": "0.44.
|
|
51
|
+
"@unocss/core": "0.44.7",
|
|
42
52
|
"ohmyfetch": "^0.4.18"
|
|
43
53
|
},
|
|
44
54
|
"devDependencies": {
|