@pikacss/plugin-icons 0.0.30 → 0.0.32

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 CHANGED
@@ -1,155 +1,163 @@
1
- 'use strict';
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));
2
26
 
3
- const utils = require('@iconify/utils');
4
- const core = require('@pikacss/core');
5
- const presetIcons = require('@unocss/preset-icons');
6
- const ofetch = require('ofetch');
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");
7
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
+ }
8
53
  function icons() {
9
- return createIconsPlugin(createIconsLoader);
54
+ return createIconsPlugin(createIconsLoader);
10
55
  }
11
56
  function createCDNLoader(cdnBase) {
12
- return presetIcons.createCDNFetchLoader(ofetch.$fetch, cdnBase);
57
+ return (0, __unocss_preset_icons.createCDNFetchLoader)(ofetch.$fetch, cdnBase);
13
58
  }
14
59
  async function createIconsLoader(config) {
15
- const {
16
- cdn
17
- } = config;
18
- const loaders = [];
19
- const {
20
- isNode,
21
- isVSCode,
22
- isESLint
23
- } = presetIcons.getEnvFlags();
24
- if (isNode && !isVSCode && !isESLint) {
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);
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);
33
70
  }
34
71
  const globalColonRE = /:/g;
35
72
  function createIconsPlugin(lookupIconLoader) {
36
- let engine;
37
- let iconsConfig;
38
- return core.defineEnginePlugin({
39
- name: "icons",
40
- configureRawConfig: async (config) => {
41
- iconsConfig = config.icons || {};
42
- },
43
- configureEngine: async (_engine) => {
44
- engine = _engine;
45
- const {
46
- scale = 1,
47
- mode = "auto",
48
- prefix = "i-",
49
- iconifyCollectionsNames,
50
- collections: customCollections,
51
- customizations = {},
52
- autoInstall = false,
53
- collectionsNodeResolvePath,
54
- unit,
55
- extraProperties = {},
56
- processor,
57
- autocomplete: _autocomplete
58
- } = iconsConfig;
59
- const loaderOptions = {
60
- addXmlNs: true,
61
- scale,
62
- customCollections,
63
- autoInstall,
64
- cwd: collectionsNodeResolvePath,
65
- // avoid warn from @iconify/loader: we'll warn below if not found
66
- warn: void 0,
67
- customizations: {
68
- ...customizations,
69
- additionalProps: { ...extraProperties },
70
- trimCustomSvg: true,
71
- async iconCustomizer(collection, icon, props) {
72
- await customizations.iconCustomizer?.(collection, icon, props);
73
- if (unit) {
74
- if (!props.width)
75
- props.width = `${scale}${unit}`;
76
- if (!props.height)
77
- props.height = `${scale}${unit}`;
78
- }
79
- }
80
- }
81
- };
82
- const prefixRE = new RegExp(`^(${[prefix].flat().join("|")})`);
83
- const autocompletePrefix = [prefix].flat();
84
- const autocomplete = [
85
- ...autocompletePrefix,
86
- ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])
87
- ];
88
- let iconLoader;
89
- engine.shortcuts.add({
90
- shortcut: new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
91
- value: async (match) => {
92
- let [full, body, _mode = mode] = match;
93
- iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
94
- const usedProps = {};
95
- const parsed = await presetIcons.parseIconWithLoader(
96
- body,
97
- iconLoader,
98
- { ...loaderOptions, usedProps },
99
- iconifyCollectionsNames
100
- );
101
- if (parsed == null) {
102
- core.warn(`failed to load icon "${full}"`);
103
- return {};
104
- }
105
- const url = `url("data:image/svg+xml;utf8,${utils.encodeSvgForCss(parsed.svg)}")`;
106
- const varName = `--${engine.config.prefix}svg-icon-${body.replace(globalColonRE, "-")}`;
107
- if (engine.variables.store.has(varName) === false) {
108
- engine.variables.add({
109
- [varName]: {
110
- value: url,
111
- autocomplete: { asValueOf: "-", asProperty: false },
112
- pruneUnused: true
113
- }
114
- });
115
- }
116
- if (_mode === "auto")
117
- _mode = parsed.svg.includes("currentColor") ? "mask" : "bg";
118
- let styleItem;
119
- if (_mode === "mask") {
120
- styleItem = {
121
- "--svg-icon": `var(${varName})`,
122
- "-webkit-mask": "var(--svg-icon) no-repeat",
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
- });
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
+ (0, __pikacss_core.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
+ });
153
160
  }
154
161
 
155
- exports.icons = icons;
162
+ //#endregion
163
+ exports.icons = icons;
package/dist/index.d.cts CHANGED
@@ -1,27 +1,28 @@
1
- import { Simplify, StyleItem, EnginePlugin } from '@pikacss/core';
2
- import { IconsOptions } from '@unocss/preset-icons';
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
- collection: string;
6
- name: string;
7
- svg: string;
8
- mode?: IconsConfig['mode'];
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
- * 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[];
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
- interface EngineConfig {
22
- icons?: IconsConfig;
23
- }
22
+ interface EngineConfig {
23
+ icons?: IconsConfig;
24
+ }
24
25
  }
25
26
  declare function icons(): EnginePlugin;
26
-
27
- export { type IconsConfig, icons };
27
+ //#endregion
28
+ export { IconsConfig, icons };
package/dist/index.d.mts CHANGED
@@ -1,27 +1,28 @@
1
- import { Simplify, StyleItem, EnginePlugin } from '@pikacss/core';
2
- import { IconsOptions } from '@unocss/preset-icons';
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
- collection: string;
6
- name: string;
7
- svg: string;
8
- mode?: IconsConfig['mode'];
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
- * 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[];
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
- interface EngineConfig {
22
- icons?: IconsConfig;
23
- }
22
+ interface EngineConfig {
23
+ icons?: IconsConfig;
24
+ }
24
25
  }
25
26
  declare function icons(): EnginePlugin;
26
-
27
- export { type IconsConfig, icons };
27
+ //#endregion
28
+ export { IconsConfig, icons };
package/dist/index.mjs CHANGED
@@ -1,153 +1,135 @@
1
- import { encodeSvgForCss, loadIcon } from '@iconify/utils';
2
- import { defineEnginePlugin, warn } from '@pikacss/core';
3
- import { parseIconWithLoader, getEnvFlags, createNodeLoader, combineLoaders, createCDNFetchLoader } from '@unocss/preset-icons';
4
- import { $fetch } from 'ofetch';
1
+ import process from "node:process";
2
+ import { encodeSvgForCss, loadIcon } from "@iconify/utils";
3
+ import { defineEnginePlugin, warn } from "@pikacss/core";
4
+ import { combineLoaders, createCDNFetchLoader, createNodeLoader, parseIconWithLoader } from "@unocss/preset-icons";
5
+ import { $fetch } from "ofetch";
5
6
 
7
+ //#region src/index.ts
8
+ /**
9
+ * Environment flags helper function to detect the current runtime environment.
10
+ * This replaces the removed `getEnvFlags` export from `@unocss/preset-icons` v66+.
11
+ *
12
+ * @returns An object containing:
13
+ * - `isNode`: Whether the code is running in a Node.js environment
14
+ * - `isVSCode`: Whether the code is running within VS Code (extension host)
15
+ * - `isESLint`: Whether the code is running within ESLint
16
+ */
17
+ function getEnvFlags() {
18
+ const isNode = typeof process !== "undefined" && typeof process.versions?.node !== "undefined";
19
+ return {
20
+ isNode,
21
+ isVSCode: isNode && !!process.env.VSCODE_PID,
22
+ isESLint: isNode && !!process.env.ESLINT
23
+ };
24
+ }
6
25
  function icons() {
7
- return createIconsPlugin(createIconsLoader);
26
+ return createIconsPlugin(createIconsLoader);
8
27
  }
9
28
  function createCDNLoader(cdnBase) {
10
- return createCDNFetchLoader($fetch, cdnBase);
29
+ return createCDNFetchLoader($fetch, cdnBase);
11
30
  }
12
31
  async function createIconsLoader(config) {
13
- const {
14
- cdn
15
- } = config;
16
- const loaders = [];
17
- const {
18
- isNode,
19
- isVSCode,
20
- isESLint
21
- } = getEnvFlags();
22
- if (isNode && !isVSCode && !isESLint) {
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);
32
+ const { cdn } = config;
33
+ const loaders = [];
34
+ const { isNode, isVSCode, isESLint } = getEnvFlags();
35
+ if (isNode && !isVSCode && !isESLint) {
36
+ const nodeLoader = await createNodeLoader();
37
+ if (nodeLoader != null) loaders.push(nodeLoader);
38
+ }
39
+ if (cdn) loaders.push(createCDNLoader(cdn));
40
+ loaders.push(loadIcon);
41
+ return combineLoaders(loaders);
31
42
  }
32
43
  const globalColonRE = /:/g;
33
44
  function createIconsPlugin(lookupIconLoader) {
34
- let engine;
35
- let iconsConfig;
36
- return defineEnginePlugin({
37
- name: "icons",
38
- configureRawConfig: async (config) => {
39
- iconsConfig = config.icons || {};
40
- },
41
- configureEngine: async (_engine) => {
42
- engine = _engine;
43
- const {
44
- scale = 1,
45
- mode = "auto",
46
- prefix = "i-",
47
- iconifyCollectionsNames,
48
- collections: customCollections,
49
- customizations = {},
50
- autoInstall = false,
51
- collectionsNodeResolvePath,
52
- unit,
53
- extraProperties = {},
54
- processor,
55
- autocomplete: _autocomplete
56
- } = iconsConfig;
57
- const loaderOptions = {
58
- addXmlNs: true,
59
- scale,
60
- customCollections,
61
- autoInstall,
62
- cwd: collectionsNodeResolvePath,
63
- // avoid warn from @iconify/loader: we'll warn below if not found
64
- warn: void 0,
65
- customizations: {
66
- ...customizations,
67
- additionalProps: { ...extraProperties },
68
- trimCustomSvg: true,
69
- async iconCustomizer(collection, icon, props) {
70
- await customizations.iconCustomizer?.(collection, icon, props);
71
- if (unit) {
72
- if (!props.width)
73
- props.width = `${scale}${unit}`;
74
- if (!props.height)
75
- props.height = `${scale}${unit}`;
76
- }
77
- }
78
- }
79
- };
80
- const prefixRE = new RegExp(`^(${[prefix].flat().join("|")})`);
81
- const autocompletePrefix = [prefix].flat();
82
- const autocomplete = [
83
- ...autocompletePrefix,
84
- ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])
85
- ];
86
- let iconLoader;
87
- engine.shortcuts.add({
88
- shortcut: new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
89
- value: async (match) => {
90
- let [full, body, _mode = mode] = match;
91
- iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
92
- const usedProps = {};
93
- const parsed = await parseIconWithLoader(
94
- body,
95
- iconLoader,
96
- { ...loaderOptions, usedProps },
97
- iconifyCollectionsNames
98
- );
99
- if (parsed == null) {
100
- warn(`failed to load icon "${full}"`);
101
- return {};
102
- }
103
- const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(parsed.svg)}")`;
104
- const varName = `--${engine.config.prefix}svg-icon-${body.replace(globalColonRE, "-")}`;
105
- if (engine.variables.store.has(varName) === false) {
106
- engine.variables.add({
107
- [varName]: {
108
- value: url,
109
- autocomplete: { asValueOf: "-", asProperty: false },
110
- pruneUnused: true
111
- }
112
- });
113
- }
114
- if (_mode === "auto")
115
- _mode = parsed.svg.includes("currentColor") ? "mask" : "bg";
116
- let styleItem;
117
- if (_mode === "mask") {
118
- styleItem = {
119
- "--svg-icon": `var(${varName})`,
120
- "-webkit-mask": "var(--svg-icon) no-repeat",
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
- });
45
+ let engine;
46
+ let iconsConfig;
47
+ return defineEnginePlugin({
48
+ name: "icons",
49
+ configureRawConfig: async (config) => {
50
+ iconsConfig = config.icons || {};
51
+ },
52
+ configureEngine: async (_engine) => {
53
+ engine = _engine;
54
+ const { scale = 1, mode = "auto", prefix = "i-", iconifyCollectionsNames, collections: customCollections, customizations = {}, autoInstall = false, collectionsNodeResolvePath, unit, extraProperties = {}, processor, autocomplete: _autocomplete } = iconsConfig;
55
+ const loaderOptions = {
56
+ addXmlNs: true,
57
+ scale,
58
+ customCollections,
59
+ autoInstall,
60
+ cwd: collectionsNodeResolvePath,
61
+ warn: void 0,
62
+ customizations: {
63
+ ...customizations,
64
+ additionalProps: { ...extraProperties },
65
+ trimCustomSvg: true,
66
+ async iconCustomizer(collection, icon, props) {
67
+ await customizations.iconCustomizer?.(collection, icon, props);
68
+ if (unit) {
69
+ if (!props.width) props.width = `${scale}${unit}`;
70
+ if (!props.height) props.height = `${scale}${unit}`;
71
+ }
72
+ }
73
+ }
74
+ };
75
+ const prefixRE = /* @__PURE__ */ new RegExp(`^(${[prefix].flat().join("|")})`);
76
+ const autocompletePrefix = [prefix].flat();
77
+ const autocomplete = [...autocompletePrefix, ...autocompletePrefix.flatMap((p) => _autocomplete?.map((a) => `${p}${a.replace(prefixRE, "")}`) || [])];
78
+ let iconLoader;
79
+ engine.shortcuts.add({
80
+ shortcut: /* @__PURE__ */ new RegExp(`^(?:${[prefix].flat().join("|")})([\\w:-]+)(?:\\?(mask|bg|auto))?$`),
81
+ value: async (match) => {
82
+ let [full, body, _mode = mode] = match;
83
+ iconLoader = iconLoader || await lookupIconLoader(iconsConfig);
84
+ const usedProps = {};
85
+ const parsed = await parseIconWithLoader(body, iconLoader, {
86
+ ...loaderOptions,
87
+ usedProps
88
+ }, iconifyCollectionsNames);
89
+ if (parsed == null) {
90
+ warn(`failed to load icon "${full}"`);
91
+ return {};
92
+ }
93
+ const url = `url("data:image/svg+xml;utf8,${encodeSvgForCss(parsed.svg)}")`;
94
+ const varName = `--${engine.config.prefix}svg-icon-${body.replace(globalColonRE, "-")}`;
95
+ if (engine.variables.store.has(varName) === false) engine.variables.add({ [varName]: {
96
+ value: url,
97
+ autocomplete: {
98
+ asValueOf: "-",
99
+ asProperty: false
100
+ },
101
+ pruneUnused: true
102
+ } });
103
+ if (_mode === "auto") _mode = parsed.svg.includes("currentColor") ? "mask" : "bg";
104
+ let styleItem;
105
+ if (_mode === "mask") styleItem = {
106
+ "--svg-icon": `var(${varName})`,
107
+ "-webkit-mask": "var(--svg-icon) no-repeat",
108
+ "mask": "var(--svg-icon) no-repeat",
109
+ "-webkit-mask-size": "100% 100%",
110
+ "mask-size": "100% 100%",
111
+ "background-color": "currentColor",
112
+ "color": "inherit",
113
+ ...usedProps
114
+ };
115
+ else styleItem = {
116
+ "--svg-icon": `var(${varName})`,
117
+ "background": "var(--svg-icon) no-repeat",
118
+ "background-size": "100% 100%",
119
+ "background-color": "transparent",
120
+ ...usedProps
121
+ };
122
+ processor?.(styleItem, {
123
+ ...parsed,
124
+ mode: _mode
125
+ });
126
+ return styleItem;
127
+ },
128
+ autocomplete
129
+ });
130
+ }
131
+ });
151
132
  }
152
133
 
153
- export { icons };
134
+ //#endregion
135
+ export { icons };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.0.30",
7
+ "version": "0.0.32",
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.ts",
33
+ "types": "dist/index.d.mts",
34
34
  "files": [
35
35
  "dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@iconify/utils": "^2.3.0",
39
- "@unocss/preset-icons": "^65.4.3",
40
- "ofetch": "^1.4.1",
41
- "@pikacss/core": "0.0.30"
38
+ "@iconify/utils": "^3.1.0",
39
+ "@unocss/preset-icons": "^66.5.9",
40
+ "ofetch": "^1.5.1",
41
+ "@pikacss/core": "0.0.32"
42
42
  },
43
43
  "scripts": {
44
- "build": "unbuild",
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 };