@pikacss/plugin-icons 0.0.42 → 0.0.44
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.mjs +2 -2
- package/package.json +4 -9
- package/dist/index.cjs +0 -163
- package/dist/index.d.cts +0 -28
package/dist/index.mjs
CHANGED
|
@@ -72,12 +72,12 @@ function createIconsPlugin(lookupIconLoader) {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
|
-
const prefixRE =
|
|
75
|
+
const prefixRE = new RegExp(`^(${[prefix].flat().join("|")})`);
|
|
76
76
|
const autocompletePrefix = [prefix].flat();
|
|
77
77
|
const autocomplete = [...autocompletePrefix, ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])];
|
|
78
78
|
let iconLoader;
|
|
79
79
|
engine.shortcuts.add({
|
|
80
|
-
shortcut:
|
|
80
|
+
shortcut: new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
|
|
81
81
|
value: async (match) => {
|
|
82
82
|
let [full, body, _mode = mode] = match;
|
|
83
83
|
iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikacss/plugin-icons",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.44",
|
|
5
5
|
"author": "DevilTea <ch19980814@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -25,14 +25,9 @@
|
|
|
25
25
|
"import": {
|
|
26
26
|
"types": "./dist/index.d.mts",
|
|
27
27
|
"default": "./dist/index.mjs"
|
|
28
|
-
},
|
|
29
|
-
"require": {
|
|
30
|
-
"types": "./dist/index.d.cts",
|
|
31
|
-
"default": "./dist/index.cjs"
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
},
|
|
35
|
-
"main": "dist/index.cjs",
|
|
36
31
|
"module": "dist/index.mjs",
|
|
37
32
|
"types": "dist/index.d.mts",
|
|
38
33
|
"publishConfig": {
|
|
@@ -42,15 +37,15 @@
|
|
|
42
37
|
"dist"
|
|
43
38
|
],
|
|
44
39
|
"peerDependencies": {
|
|
45
|
-
"@pikacss/core": "0.0.
|
|
40
|
+
"@pikacss/core": "0.0.44"
|
|
46
41
|
},
|
|
47
42
|
"dependencies": {
|
|
48
43
|
"@iconify/utils": "^3.1.0",
|
|
49
|
-
"@unocss/preset-icons": "^66.
|
|
44
|
+
"@unocss/preset-icons": "^66.6.1",
|
|
50
45
|
"ofetch": "^1.5.1"
|
|
51
46
|
},
|
|
52
47
|
"devDependencies": {
|
|
53
|
-
"@pikacss/core": "0.0.
|
|
48
|
+
"@pikacss/core": "0.0.44"
|
|
54
49
|
},
|
|
55
50
|
"scripts": {
|
|
56
51
|
"build": "tsdown && pnpm exec publint",
|
package/dist/index.cjs
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
-
__defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
-
value: mod,
|
|
24
|
-
enumerable: true
|
|
25
|
-
}) : target, mod));
|
|
26
|
-
|
|
27
|
-
//#endregion
|
|
28
|
-
let node_process = require("node:process");
|
|
29
|
-
node_process = __toESM(node_process);
|
|
30
|
-
let _iconify_utils = require("@iconify/utils");
|
|
31
|
-
let _pikacss_core = require("@pikacss/core");
|
|
32
|
-
let _unocss_preset_icons = require("@unocss/preset-icons");
|
|
33
|
-
let ofetch = require("ofetch");
|
|
34
|
-
|
|
35
|
-
//#region src/index.ts
|
|
36
|
-
/**
|
|
37
|
-
* Environment flags helper function to detect the current runtime environment.
|
|
38
|
-
* This replaces the removed `getEnvFlags` export from `@unocss/preset-icons` v66+.
|
|
39
|
-
*
|
|
40
|
-
* @returns An object containing:
|
|
41
|
-
* - `isNode`: Whether the code is running in a Node.js environment
|
|
42
|
-
* - `isVSCode`: Whether the code is running within VS Code (extension host)
|
|
43
|
-
* - `isESLint`: Whether the code is running within ESLint
|
|
44
|
-
*/
|
|
45
|
-
function getEnvFlags() {
|
|
46
|
-
const isNode = typeof node_process.default !== "undefined" && typeof node_process.default.versions?.node !== "undefined";
|
|
47
|
-
return {
|
|
48
|
-
isNode,
|
|
49
|
-
isVSCode: isNode && !!node_process.default.env.VSCODE_PID,
|
|
50
|
-
isESLint: isNode && !!node_process.default.env.ESLINT
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function icons() {
|
|
54
|
-
return createIconsPlugin(createIconsLoader);
|
|
55
|
-
}
|
|
56
|
-
function createCDNLoader(cdnBase) {
|
|
57
|
-
return (0, _unocss_preset_icons.createCDNFetchLoader)(ofetch.$fetch, cdnBase);
|
|
58
|
-
}
|
|
59
|
-
async function createIconsLoader(config) {
|
|
60
|
-
const { cdn } = config;
|
|
61
|
-
const loaders = [];
|
|
62
|
-
const { isNode, isVSCode, isESLint } = getEnvFlags();
|
|
63
|
-
if (isNode && !isVSCode && !isESLint) {
|
|
64
|
-
const nodeLoader = await (0, _unocss_preset_icons.createNodeLoader)();
|
|
65
|
-
if (nodeLoader != null) loaders.push(nodeLoader);
|
|
66
|
-
}
|
|
67
|
-
if (cdn) loaders.push(createCDNLoader(cdn));
|
|
68
|
-
loaders.push(_iconify_utils.loadIcon);
|
|
69
|
-
return (0, _unocss_preset_icons.combineLoaders)(loaders);
|
|
70
|
-
}
|
|
71
|
-
const globalColonRE = /:/g;
|
|
72
|
-
function createIconsPlugin(lookupIconLoader) {
|
|
73
|
-
let engine;
|
|
74
|
-
let iconsConfig;
|
|
75
|
-
return (0, _pikacss_core.defineEnginePlugin)({
|
|
76
|
-
name: "icons",
|
|
77
|
-
configureRawConfig: async (config) => {
|
|
78
|
-
iconsConfig = config.icons || {};
|
|
79
|
-
},
|
|
80
|
-
configureEngine: async (_engine) => {
|
|
81
|
-
engine = _engine;
|
|
82
|
-
const { scale = 1, mode = "auto", prefix = "i-", iconifyCollectionsNames, collections: customCollections, customizations = {}, autoInstall = false, collectionsNodeResolvePath, unit, extraProperties = {}, processor, autocomplete: _autocomplete } = iconsConfig;
|
|
83
|
-
const loaderOptions = {
|
|
84
|
-
addXmlNs: true,
|
|
85
|
-
scale,
|
|
86
|
-
customCollections,
|
|
87
|
-
autoInstall,
|
|
88
|
-
cwd: collectionsNodeResolvePath,
|
|
89
|
-
warn: void 0,
|
|
90
|
-
customizations: {
|
|
91
|
-
...customizations,
|
|
92
|
-
additionalProps: { ...extraProperties },
|
|
93
|
-
trimCustomSvg: true,
|
|
94
|
-
async iconCustomizer(collection, icon, props) {
|
|
95
|
-
await customizations.iconCustomizer?.(collection, icon, props);
|
|
96
|
-
if (unit) {
|
|
97
|
-
if (!props.width) props.width = `${scale}${unit}`;
|
|
98
|
-
if (!props.height) props.height = `${scale}${unit}`;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
const prefixRE = /* @__PURE__ */ new RegExp(`^(${[prefix].flat().join("|")})`);
|
|
104
|
-
const autocompletePrefix = [prefix].flat();
|
|
105
|
-
const autocomplete = [...autocompletePrefix, ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])];
|
|
106
|
-
let iconLoader;
|
|
107
|
-
engine.shortcuts.add({
|
|
108
|
-
shortcut: /* @__PURE__ */ new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
|
|
109
|
-
value: async (match) => {
|
|
110
|
-
let [full, body, _mode = mode] = match;
|
|
111
|
-
iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
|
|
112
|
-
const usedProps = {};
|
|
113
|
-
const parsed = await (0, _unocss_preset_icons.parseIconWithLoader)(body, iconLoader, {
|
|
114
|
-
...loaderOptions,
|
|
115
|
-
usedProps
|
|
116
|
-
}, iconifyCollectionsNames);
|
|
117
|
-
if (parsed == null) {
|
|
118
|
-
_pikacss_core.log.warn(`failed to load icon "${full}"`);
|
|
119
|
-
return {};
|
|
120
|
-
}
|
|
121
|
-
const url = `url("data:image/svg+xml;utf8,${(0, _iconify_utils.encodeSvgForCss)(parsed.svg)}")`;
|
|
122
|
-
const varName = `--${engine.config.prefix}svg-icon-${body.replace(globalColonRE, "-")}`;
|
|
123
|
-
if (engine.variables.store.has(varName) === false) engine.variables.add({ [varName]: {
|
|
124
|
-
value: url,
|
|
125
|
-
autocomplete: {
|
|
126
|
-
asValueOf: "-",
|
|
127
|
-
asProperty: false
|
|
128
|
-
},
|
|
129
|
-
pruneUnused: true
|
|
130
|
-
} });
|
|
131
|
-
if (_mode === "auto") _mode = parsed.svg.includes("currentColor") ? "mask" : "bg";
|
|
132
|
-
let styleItem;
|
|
133
|
-
if (_mode === "mask") styleItem = {
|
|
134
|
-
"--svg-icon": `var(${varName})`,
|
|
135
|
-
"-webkit-mask": "var(--svg-icon) no-repeat",
|
|
136
|
-
"mask": "var(--svg-icon) no-repeat",
|
|
137
|
-
"-webkit-mask-size": "100% 100%",
|
|
138
|
-
"mask-size": "100% 100%",
|
|
139
|
-
"background-color": "currentColor",
|
|
140
|
-
"color": "inherit",
|
|
141
|
-
...usedProps
|
|
142
|
-
};
|
|
143
|
-
else styleItem = {
|
|
144
|
-
"--svg-icon": `var(${varName})`,
|
|
145
|
-
"background": "var(--svg-icon) no-repeat",
|
|
146
|
-
"background-size": "100% 100%",
|
|
147
|
-
"background-color": "transparent",
|
|
148
|
-
...usedProps
|
|
149
|
-
};
|
|
150
|
-
processor?.(styleItem, {
|
|
151
|
-
...parsed,
|
|
152
|
-
mode: _mode
|
|
153
|
-
});
|
|
154
|
-
return styleItem;
|
|
155
|
-
},
|
|
156
|
-
autocomplete
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
//#endregion
|
|
163
|
-
exports.icons = icons;
|
package/dist/index.d.cts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { EnginePlugin, Simplify, StyleItem } from "@pikacss/core";
|
|
2
|
-
import { IconsOptions } from "@unocss/preset-icons";
|
|
3
|
-
|
|
4
|
-
//#region src/index.d.ts
|
|
5
|
-
interface IconMeta {
|
|
6
|
-
collection: string;
|
|
7
|
-
name: string;
|
|
8
|
-
svg: string;
|
|
9
|
-
mode?: IconsConfig['mode'];
|
|
10
|
-
}
|
|
11
|
-
type IconsConfig = Simplify<Omit<IconsOptions, 'warn' | 'layer' | 'processor' | 'customFetcher'> & {
|
|
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[];
|
|
20
|
-
}>;
|
|
21
|
-
declare module '@pikacss/core' {
|
|
22
|
-
interface EngineConfig {
|
|
23
|
-
icons?: IconsConfig;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
declare function icons(): EnginePlugin;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { IconsConfig, icons };
|