@pikacss/plugin-icons 0.0.30 → 0.0.31
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/index.cjs +106 -144
- package/dist/index.d.cts +20 -19
- package/dist/index.d.mts +20 -19
- package/dist/index.mjs +106 -142
- package/package.json +5 -6
- package/dist/index.d.ts +0 -27
package/dist/index.cjs
CHANGED
|
@@ -1,155 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const presetIcons = require('@unocss/preset-icons');
|
|
6
|
-
const ofetch = require('ofetch');
|
|
1
|
+
let __iconify_utils = require("@iconify/utils");
|
|
2
|
+
let __pikacss_core = require("@pikacss/core");
|
|
3
|
+
let __unocss_preset_icons = require("@unocss/preset-icons");
|
|
4
|
+
let ofetch = require("ofetch");
|
|
7
5
|
|
|
6
|
+
//#region src/index.ts
|
|
8
7
|
function icons() {
|
|
9
|
-
|
|
8
|
+
return createIconsPlugin(createIconsLoader);
|
|
10
9
|
}
|
|
11
10
|
function createCDNLoader(cdnBase) {
|
|
12
|
-
|
|
11
|
+
return (0, __unocss_preset_icons.createCDNFetchLoader)(ofetch.$fetch, cdnBase);
|
|
13
12
|
}
|
|
14
13
|
async function createIconsLoader(config) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const nodeLoader = await presetIcons.createNodeLoader();
|
|
26
|
-
if (nodeLoader != null)
|
|
27
|
-
loaders.push(nodeLoader);
|
|
28
|
-
}
|
|
29
|
-
if (cdn)
|
|
30
|
-
loaders.push(createCDNLoader(cdn));
|
|
31
|
-
loaders.push(utils.loadIcon);
|
|
32
|
-
return presetIcons.combineLoaders(loaders);
|
|
14
|
+
const { cdn } = config;
|
|
15
|
+
const loaders = [];
|
|
16
|
+
const { isNode, isVSCode, isESLint } = (0, __unocss_preset_icons.getEnvFlags)();
|
|
17
|
+
if (isNode && !isVSCode && !isESLint) {
|
|
18
|
+
const nodeLoader = await (0, __unocss_preset_icons.createNodeLoader)();
|
|
19
|
+
if (nodeLoader != null) loaders.push(nodeLoader);
|
|
20
|
+
}
|
|
21
|
+
if (cdn) loaders.push(createCDNLoader(cdn));
|
|
22
|
+
loaders.push(__iconify_utils.loadIcon);
|
|
23
|
+
return (0, __unocss_preset_icons.combineLoaders)(loaders);
|
|
33
24
|
}
|
|
34
25
|
const globalColonRE = /:/g;
|
|
35
26
|
function createIconsPlugin(lookupIconLoader) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
"mask": "var(--svg-icon) no-repeat",
|
|
124
|
-
"-webkit-mask-size": "100% 100%",
|
|
125
|
-
"mask-size": "100% 100%",
|
|
126
|
-
"background-color": "currentColor",
|
|
127
|
-
// for Safari https://github.com/elk-zone/elk/pull/264
|
|
128
|
-
"color": "inherit",
|
|
129
|
-
...usedProps
|
|
130
|
-
};
|
|
131
|
-
} else {
|
|
132
|
-
styleItem = {
|
|
133
|
-
"--svg-icon": `var(${varName})`,
|
|
134
|
-
"background": "var(--svg-icon) no-repeat",
|
|
135
|
-
"background-size": "100% 100%",
|
|
136
|
-
"background-color": "transparent",
|
|
137
|
-
...usedProps
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
processor?.(
|
|
141
|
-
styleItem,
|
|
142
|
-
{
|
|
143
|
-
...parsed,
|
|
144
|
-
mode: _mode
|
|
145
|
-
}
|
|
146
|
-
);
|
|
147
|
-
return styleItem;
|
|
148
|
-
},
|
|
149
|
-
autocomplete
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
});
|
|
27
|
+
let engine;
|
|
28
|
+
let iconsConfig;
|
|
29
|
+
return (0, __pikacss_core.defineEnginePlugin)({
|
|
30
|
+
name: "icons",
|
|
31
|
+
configureRawConfig: async (config) => {
|
|
32
|
+
iconsConfig = config.icons || {};
|
|
33
|
+
},
|
|
34
|
+
configureEngine: async (_engine) => {
|
|
35
|
+
engine = _engine;
|
|
36
|
+
const { scale = 1, mode = "auto", prefix = "i-", iconifyCollectionsNames, collections: customCollections, customizations = {}, autoInstall = false, collectionsNodeResolvePath, unit, extraProperties = {}, processor, autocomplete: _autocomplete } = iconsConfig;
|
|
37
|
+
const loaderOptions = {
|
|
38
|
+
addXmlNs: true,
|
|
39
|
+
scale,
|
|
40
|
+
customCollections,
|
|
41
|
+
autoInstall,
|
|
42
|
+
cwd: collectionsNodeResolvePath,
|
|
43
|
+
warn: void 0,
|
|
44
|
+
customizations: {
|
|
45
|
+
...customizations,
|
|
46
|
+
additionalProps: { ...extraProperties },
|
|
47
|
+
trimCustomSvg: true,
|
|
48
|
+
async iconCustomizer(collection, icon, props) {
|
|
49
|
+
await customizations.iconCustomizer?.(collection, icon, props);
|
|
50
|
+
if (unit) {
|
|
51
|
+
if (!props.width) props.width = `${scale}${unit}`;
|
|
52
|
+
if (!props.height) props.height = `${scale}${unit}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const prefixRE = /* @__PURE__ */ new RegExp(`^(${[prefix].flat().join("|")})`);
|
|
58
|
+
const autocompletePrefix = [prefix].flat();
|
|
59
|
+
const autocomplete = [...autocompletePrefix, ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])];
|
|
60
|
+
let iconLoader;
|
|
61
|
+
engine.shortcuts.add({
|
|
62
|
+
shortcut: /* @__PURE__ */ new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
|
|
63
|
+
value: async (match) => {
|
|
64
|
+
let [full, body, _mode = mode] = match;
|
|
65
|
+
iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
|
|
66
|
+
const usedProps = {};
|
|
67
|
+
const parsed = await (0, __unocss_preset_icons.parseIconWithLoader)(body, iconLoader, {
|
|
68
|
+
...loaderOptions,
|
|
69
|
+
usedProps
|
|
70
|
+
}, iconifyCollectionsNames);
|
|
71
|
+
if (parsed == null) {
|
|
72
|
+
(0, __pikacss_core.warn)(`failed to load icon "${full}"`);
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
const url = `url("data:image/svg+xml;utf8,${(0, __iconify_utils.encodeSvgForCss)(parsed.svg)}")`;
|
|
76
|
+
const varName = `--${engine.config.prefix}svg-icon-${body.replace(globalColonRE, "-")}`;
|
|
77
|
+
if (engine.variables.store.has(varName) === false) engine.variables.add({ [varName]: {
|
|
78
|
+
value: url,
|
|
79
|
+
autocomplete: {
|
|
80
|
+
asValueOf: "-",
|
|
81
|
+
asProperty: false
|
|
82
|
+
},
|
|
83
|
+
pruneUnused: true
|
|
84
|
+
} });
|
|
85
|
+
if (_mode === "auto") _mode = parsed.svg.includes("currentColor") ? "mask" : "bg";
|
|
86
|
+
let styleItem;
|
|
87
|
+
if (_mode === "mask") styleItem = {
|
|
88
|
+
"--svg-icon": `var(${varName})`,
|
|
89
|
+
"-webkit-mask": "var(--svg-icon) no-repeat",
|
|
90
|
+
"mask": "var(--svg-icon) no-repeat",
|
|
91
|
+
"-webkit-mask-size": "100% 100%",
|
|
92
|
+
"mask-size": "100% 100%",
|
|
93
|
+
"background-color": "currentColor",
|
|
94
|
+
"color": "inherit",
|
|
95
|
+
...usedProps
|
|
96
|
+
};
|
|
97
|
+
else styleItem = {
|
|
98
|
+
"--svg-icon": `var(${varName})`,
|
|
99
|
+
"background": "var(--svg-icon) no-repeat",
|
|
100
|
+
"background-size": "100% 100%",
|
|
101
|
+
"background-color": "transparent",
|
|
102
|
+
...usedProps
|
|
103
|
+
};
|
|
104
|
+
processor?.(styleItem, {
|
|
105
|
+
...parsed,
|
|
106
|
+
mode: _mode
|
|
107
|
+
});
|
|
108
|
+
return styleItem;
|
|
109
|
+
},
|
|
110
|
+
autocomplete
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
153
114
|
}
|
|
154
115
|
|
|
155
|
-
|
|
116
|
+
//#endregion
|
|
117
|
+
exports.icons = icons;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { Simplify, StyleItem
|
|
2
|
-
import { IconsOptions } from
|
|
1
|
+
import { EnginePlugin, Simplify, StyleItem } from "@pikacss/core";
|
|
2
|
+
import { IconsOptions } from "@unocss/preset-icons";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
interface IconMeta {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
collection: string;
|
|
7
|
+
name: string;
|
|
8
|
+
svg: string;
|
|
9
|
+
mode?: IconsConfig['mode'];
|
|
9
10
|
}
|
|
10
11
|
type IconsConfig = Simplify<Omit<IconsOptions, 'warn' | 'layer' | 'processor' | 'customFetcher'> & {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Processor for the CSS object before stringify
|
|
14
|
+
*/
|
|
15
|
+
processor?: (styleItem: StyleItem, meta: Required<IconMeta>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Specify the icons for auto-completion.
|
|
18
|
+
*/
|
|
19
|
+
autocomplete?: string[];
|
|
19
20
|
}>;
|
|
20
21
|
declare module '@pikacss/core' {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
interface EngineConfig {
|
|
23
|
+
icons?: IconsConfig;
|
|
24
|
+
}
|
|
24
25
|
}
|
|
25
26
|
declare function icons(): EnginePlugin;
|
|
26
|
-
|
|
27
|
-
export {
|
|
27
|
+
//#endregion
|
|
28
|
+
export { IconsConfig, icons };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { Simplify, StyleItem
|
|
2
|
-
import { IconsOptions } from
|
|
1
|
+
import { EnginePlugin, Simplify, StyleItem } from "@pikacss/core";
|
|
2
|
+
import { IconsOptions } from "@unocss/preset-icons";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
interface IconMeta {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
collection: string;
|
|
7
|
+
name: string;
|
|
8
|
+
svg: string;
|
|
9
|
+
mode?: IconsConfig['mode'];
|
|
9
10
|
}
|
|
10
11
|
type IconsConfig = Simplify<Omit<IconsOptions, 'warn' | 'layer' | 'processor' | 'customFetcher'> & {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Processor for the CSS object before stringify
|
|
14
|
+
*/
|
|
15
|
+
processor?: (styleItem: StyleItem, meta: Required<IconMeta>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Specify the icons for auto-completion.
|
|
18
|
+
*/
|
|
19
|
+
autocomplete?: string[];
|
|
19
20
|
}>;
|
|
20
21
|
declare module '@pikacss/core' {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
interface EngineConfig {
|
|
23
|
+
icons?: IconsConfig;
|
|
24
|
+
}
|
|
24
25
|
}
|
|
25
26
|
declare function icons(): EnginePlugin;
|
|
26
|
-
|
|
27
|
-
export {
|
|
27
|
+
//#endregion
|
|
28
|
+
export { IconsConfig, icons };
|
package/dist/index.mjs
CHANGED
|
@@ -1,153 +1,117 @@
|
|
|
1
|
-
import { encodeSvgForCss, loadIcon } from
|
|
2
|
-
import { defineEnginePlugin, warn } from
|
|
3
|
-
import {
|
|
4
|
-
import { $fetch } from
|
|
1
|
+
import { encodeSvgForCss, loadIcon } from "@iconify/utils";
|
|
2
|
+
import { defineEnginePlugin, warn } from "@pikacss/core";
|
|
3
|
+
import { combineLoaders, createCDNFetchLoader, createNodeLoader, getEnvFlags, parseIconWithLoader } from "@unocss/preset-icons";
|
|
4
|
+
import { $fetch } from "ofetch";
|
|
5
5
|
|
|
6
|
+
//#region src/index.ts
|
|
6
7
|
function icons() {
|
|
7
|
-
|
|
8
|
+
return createIconsPlugin(createIconsLoader);
|
|
8
9
|
}
|
|
9
10
|
function createCDNLoader(cdnBase) {
|
|
10
|
-
|
|
11
|
+
return createCDNFetchLoader($fetch, cdnBase);
|
|
11
12
|
}
|
|
12
13
|
async function createIconsLoader(config) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const nodeLoader = await createNodeLoader();
|
|
24
|
-
if (nodeLoader != null)
|
|
25
|
-
loaders.push(nodeLoader);
|
|
26
|
-
}
|
|
27
|
-
if (cdn)
|
|
28
|
-
loaders.push(createCDNLoader(cdn));
|
|
29
|
-
loaders.push(loadIcon);
|
|
30
|
-
return combineLoaders(loaders);
|
|
14
|
+
const { cdn } = config;
|
|
15
|
+
const loaders = [];
|
|
16
|
+
const { isNode, isVSCode, isESLint } = getEnvFlags();
|
|
17
|
+
if (isNode && !isVSCode && !isESLint) {
|
|
18
|
+
const nodeLoader = await createNodeLoader();
|
|
19
|
+
if (nodeLoader != null) loaders.push(nodeLoader);
|
|
20
|
+
}
|
|
21
|
+
if (cdn) loaders.push(createCDNLoader(cdn));
|
|
22
|
+
loaders.push(loadIcon);
|
|
23
|
+
return combineLoaders(loaders);
|
|
31
24
|
}
|
|
32
25
|
const globalColonRE = /:/g;
|
|
33
26
|
function createIconsPlugin(lookupIconLoader) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"mask": "var(--svg-icon) no-repeat",
|
|
122
|
-
"-webkit-mask-size": "100% 100%",
|
|
123
|
-
"mask-size": "100% 100%",
|
|
124
|
-
"background-color": "currentColor",
|
|
125
|
-
// for Safari https://github.com/elk-zone/elk/pull/264
|
|
126
|
-
"color": "inherit",
|
|
127
|
-
...usedProps
|
|
128
|
-
};
|
|
129
|
-
} else {
|
|
130
|
-
styleItem = {
|
|
131
|
-
"--svg-icon": `var(${varName})`,
|
|
132
|
-
"background": "var(--svg-icon) no-repeat",
|
|
133
|
-
"background-size": "100% 100%",
|
|
134
|
-
"background-color": "transparent",
|
|
135
|
-
...usedProps
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
processor?.(
|
|
139
|
-
styleItem,
|
|
140
|
-
{
|
|
141
|
-
...parsed,
|
|
142
|
-
mode: _mode
|
|
143
|
-
}
|
|
144
|
-
);
|
|
145
|
-
return styleItem;
|
|
146
|
-
},
|
|
147
|
-
autocomplete
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
});
|
|
27
|
+
let engine;
|
|
28
|
+
let iconsConfig;
|
|
29
|
+
return defineEnginePlugin({
|
|
30
|
+
name: "icons",
|
|
31
|
+
configureRawConfig: async (config) => {
|
|
32
|
+
iconsConfig = config.icons || {};
|
|
33
|
+
},
|
|
34
|
+
configureEngine: async (_engine) => {
|
|
35
|
+
engine = _engine;
|
|
36
|
+
const { scale = 1, mode = "auto", prefix = "i-", iconifyCollectionsNames, collections: customCollections, customizations = {}, autoInstall = false, collectionsNodeResolvePath, unit, extraProperties = {}, processor, autocomplete: _autocomplete } = iconsConfig;
|
|
37
|
+
const loaderOptions = {
|
|
38
|
+
addXmlNs: true,
|
|
39
|
+
scale,
|
|
40
|
+
customCollections,
|
|
41
|
+
autoInstall,
|
|
42
|
+
cwd: collectionsNodeResolvePath,
|
|
43
|
+
warn: void 0,
|
|
44
|
+
customizations: {
|
|
45
|
+
...customizations,
|
|
46
|
+
additionalProps: { ...extraProperties },
|
|
47
|
+
trimCustomSvg: true,
|
|
48
|
+
async iconCustomizer(collection, icon, props) {
|
|
49
|
+
await customizations.iconCustomizer?.(collection, icon, props);
|
|
50
|
+
if (unit) {
|
|
51
|
+
if (!props.width) props.width = `${scale}${unit}`;
|
|
52
|
+
if (!props.height) props.height = `${scale}${unit}`;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const prefixRE = /* @__PURE__ */ new RegExp(`^(${[prefix].flat().join("|")})`);
|
|
58
|
+
const autocompletePrefix = [prefix].flat();
|
|
59
|
+
const autocomplete = [...autocompletePrefix, ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])];
|
|
60
|
+
let iconLoader;
|
|
61
|
+
engine.shortcuts.add({
|
|
62
|
+
shortcut: /* @__PURE__ */ new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
|
|
63
|
+
value: async (match) => {
|
|
64
|
+
let [full, body, _mode = mode] = match;
|
|
65
|
+
iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
|
|
66
|
+
const usedProps = {};
|
|
67
|
+
const parsed = await parseIconWithLoader(body, iconLoader, {
|
|
68
|
+
...loaderOptions,
|
|
69
|
+
usedProps
|
|
70
|
+
}, iconifyCollectionsNames);
|
|
71
|
+
if (parsed == null) {
|
|
72
|
+
warn(`failed to load icon "${full}"`);
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(parsed.svg)}")`;
|
|
76
|
+
const varName = `--${engine.config.prefix}svg-icon-${body.replace(globalColonRE, "-")}`;
|
|
77
|
+
if (engine.variables.store.has(varName) === false) engine.variables.add({ [varName]: {
|
|
78
|
+
value: url,
|
|
79
|
+
autocomplete: {
|
|
80
|
+
asValueOf: "-",
|
|
81
|
+
asProperty: false
|
|
82
|
+
},
|
|
83
|
+
pruneUnused: true
|
|
84
|
+
} });
|
|
85
|
+
if (_mode === "auto") _mode = parsed.svg.includes("currentColor") ? "mask" : "bg";
|
|
86
|
+
let styleItem;
|
|
87
|
+
if (_mode === "mask") styleItem = {
|
|
88
|
+
"--svg-icon": `var(${varName})`,
|
|
89
|
+
"-webkit-mask": "var(--svg-icon) no-repeat",
|
|
90
|
+
"mask": "var(--svg-icon) no-repeat",
|
|
91
|
+
"-webkit-mask-size": "100% 100%",
|
|
92
|
+
"mask-size": "100% 100%",
|
|
93
|
+
"background-color": "currentColor",
|
|
94
|
+
"color": "inherit",
|
|
95
|
+
...usedProps
|
|
96
|
+
};
|
|
97
|
+
else styleItem = {
|
|
98
|
+
"--svg-icon": `var(${varName})`,
|
|
99
|
+
"background": "var(--svg-icon) no-repeat",
|
|
100
|
+
"background-size": "100% 100%",
|
|
101
|
+
"background-color": "transparent",
|
|
102
|
+
...usedProps
|
|
103
|
+
};
|
|
104
|
+
processor?.(styleItem, {
|
|
105
|
+
...parsed,
|
|
106
|
+
mode: _mode
|
|
107
|
+
});
|
|
108
|
+
return styleItem;
|
|
109
|
+
},
|
|
110
|
+
autocomplete
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
151
114
|
}
|
|
152
115
|
|
|
153
|
-
|
|
116
|
+
//#endregion
|
|
117
|
+
export { icons };
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.31",
|
|
8
8
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -30,19 +30,18 @@
|
|
|
30
30
|
},
|
|
31
31
|
"main": "dist/index.cjs",
|
|
32
32
|
"module": "dist/index.mjs",
|
|
33
|
-
"types": "dist/index.d.
|
|
33
|
+
"types": "dist/index.d.mts",
|
|
34
34
|
"files": [
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@iconify/utils": "^2.3.0",
|
|
39
39
|
"@unocss/preset-icons": "^65.4.3",
|
|
40
|
-
"ofetch": "^1.
|
|
41
|
-
"@pikacss/core": "0.0.
|
|
40
|
+
"ofetch": "^1.5.1",
|
|
41
|
+
"@pikacss/core": "0.0.31"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
"build": "
|
|
45
|
-
"stub": "unbuild --stub",
|
|
44
|
+
"build": "tsdown",
|
|
46
45
|
"typecheck": "pnpm typecheck:package && pnpm typecheck:test",
|
|
47
46
|
"typecheck:package": "tsc --project ./tsconfig.package.json --noEmit",
|
|
48
47
|
"typecheck:test": "tsc --project ./tsconfig.tests.json --noEmit",
|
package/dist/index.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Simplify, StyleItem, EnginePlugin } from '@pikacss/core';
|
|
2
|
-
import { IconsOptions } from '@unocss/preset-icons';
|
|
3
|
-
|
|
4
|
-
interface IconMeta {
|
|
5
|
-
collection: string;
|
|
6
|
-
name: string;
|
|
7
|
-
svg: string;
|
|
8
|
-
mode?: IconsConfig['mode'];
|
|
9
|
-
}
|
|
10
|
-
type IconsConfig = Simplify<Omit<IconsOptions, 'warn' | 'layer' | 'processor' | 'customFetcher'> & {
|
|
11
|
-
/**
|
|
12
|
-
* Processor for the CSS object before stringify
|
|
13
|
-
*/
|
|
14
|
-
processor?: (styleItem: StyleItem, meta: Required<IconMeta>) => void;
|
|
15
|
-
/**
|
|
16
|
-
* Specify the icons for auto-completion.
|
|
17
|
-
*/
|
|
18
|
-
autocomplete?: string[];
|
|
19
|
-
}>;
|
|
20
|
-
declare module '@pikacss/core' {
|
|
21
|
-
interface EngineConfig {
|
|
22
|
-
icons?: IconsConfig;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
declare function icons(): EnginePlugin;
|
|
26
|
-
|
|
27
|
-
export { type IconsConfig, icons };
|