@fangzhongya/icons 0.0.47 → 0.0.48
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/{chunk-3KD5D7YV.js → chunk-3KXKNLJB.js} +1 -1
- package/dist/{chunk-EAFBDDBA.cjs → chunk-5BK6X4ZA.cjs} +1 -1
- package/dist/index.json +1 -1
- package/dist/json.cjs +2 -2
- package/dist/json.d.cts +1 -1
- package/dist/json.d.ts +1 -1
- package/dist/json.js +1 -1
- package/dist/vite/index.cjs +30 -16
- package/dist/vite/index.d.cts +5 -1
- package/dist/vite/index.d.ts +5 -1
- package/dist/vite/index.js +30 -16
- package/package.json +1 -1
package/dist/index.json
CHANGED
package/dist/json.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5BK6X4ZAcjs = require('./chunk-5BK6X4ZA.cjs');
|
|
4
4
|
require('./chunk-75ZPJI57.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = _chunk5BK6X4ZAcjs.json_default;
|
package/dist/json.d.cts
CHANGED
package/dist/json.d.ts
CHANGED
package/dist/json.js
CHANGED
package/dist/vite/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkYJVFENGGcjs = require('../chunk-YJVFENGG.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk5BK6X4ZAcjs = require('../chunk-5BK6X4ZA.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunkBXEIRESQcjs = require('../chunk-BXEIRESQ.cjs');
|
|
@@ -929,6 +929,7 @@ function simpleFangIcon(options = {}) {
|
|
|
929
929
|
dynamic = true,
|
|
930
930
|
virtual = false,
|
|
931
931
|
replaced = true,
|
|
932
|
+
alias = "icon",
|
|
932
933
|
customReplacement
|
|
933
934
|
} = options;
|
|
934
935
|
if (options.mobile) {
|
|
@@ -988,6 +989,7 @@ function simpleFangIcon(options = {}) {
|
|
|
988
989
|
import FangIcon from '@fangzhongya/icons/icon/index'
|
|
989
990
|
import { icons } from '@fangzhongya/icons/async'
|
|
990
991
|
import { lineToLargeHump } from '@fangzhongya/utils/name/lineToLargeHump';
|
|
992
|
+
const alias = lineToLargeHump(${alias})
|
|
991
993
|
const component = defineComponent({
|
|
992
994
|
name: '${name}',
|
|
993
995
|
props: {
|
|
@@ -1011,7 +1013,11 @@ function simpleFangIcon(options = {}) {
|
|
|
1011
1013
|
const name = props.name;
|
|
1012
1014
|
if (typeof name === 'string' && (props.type === '${runType}' ||
|
|
1013
1015
|
(!props.type && props.default === '${runType}'))) {
|
|
1014
|
-
|
|
1016
|
+
let n = lineToLargeHump(name)
|
|
1017
|
+
if(n.startsWith(alias)){
|
|
1018
|
+
n = n.substring(alias.length);
|
|
1019
|
+
}
|
|
1020
|
+
const icon = icons[n];
|
|
1015
1021
|
if(icon) return icon;
|
|
1016
1022
|
}
|
|
1017
1023
|
return name;
|
|
@@ -1089,7 +1095,8 @@ function simpleFangIcon(options = {}) {
|
|
|
1089
1095
|
component,
|
|
1090
1096
|
type,
|
|
1091
1097
|
dynamic,
|
|
1092
|
-
customReplacement
|
|
1098
|
+
customReplacement,
|
|
1099
|
+
alias
|
|
1093
1100
|
);
|
|
1094
1101
|
imports.add(imptext);
|
|
1095
1102
|
if (text !== component.fullMatch) {
|
|
@@ -1222,42 +1229,49 @@ function findComponents(code, name) {
|
|
|
1222
1229
|
}
|
|
1223
1230
|
return components;
|
|
1224
1231
|
}
|
|
1225
|
-
function getText(iconName, match) {
|
|
1226
|
-
const svg = _chunkYJVFENGGcjs.getIconifySVG.call(void 0,
|
|
1232
|
+
function getText(iconName, match, name) {
|
|
1233
|
+
const svg = _chunkYJVFENGGcjs.getIconifySVG.call(void 0, _chunk5BK6X4ZAcjs.json_default, name);
|
|
1227
1234
|
const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`</${match.componentName}>`, "");
|
|
1228
1235
|
const text = `${s}${svg}</${match.componentName}>`;
|
|
1229
1236
|
return { text, imptext: "" };
|
|
1230
1237
|
}
|
|
1231
|
-
function getImportName(iconName) {
|
|
1232
|
-
return _chunkBXEIRESQcjs.lineToLargeHump.call(void 0, "
|
|
1238
|
+
function getImportName(iconName, alias) {
|
|
1239
|
+
return _chunkBXEIRESQcjs.lineToLargeHump.call(void 0, alias + "-" + iconName);
|
|
1233
1240
|
}
|
|
1234
|
-
function getVue(iconName, match) {
|
|
1241
|
+
function getVue(iconName, match, name, alias = "icon") {
|
|
1235
1242
|
const text = match.fullMatch.replace(
|
|
1236
1243
|
`name="${iconName}"`,
|
|
1237
|
-
`:name="${getImportName(
|
|
1244
|
+
`:name="${getImportName(name, alias)}"`
|
|
1238
1245
|
);
|
|
1239
1246
|
return {
|
|
1240
1247
|
text,
|
|
1241
1248
|
imptext: `import ${getImportName(
|
|
1242
|
-
|
|
1243
|
-
|
|
1249
|
+
name,
|
|
1250
|
+
alias
|
|
1251
|
+
)} from '@fangzhongya/icons/vue/${name}'`
|
|
1244
1252
|
};
|
|
1245
1253
|
}
|
|
1246
|
-
function replaceComponent(match, type, dynamic, customReplacement) {
|
|
1254
|
+
function replaceComponent(match, type, dynamic, customReplacement, alias) {
|
|
1247
1255
|
const { attributes } = match;
|
|
1248
1256
|
const iconName = attributes.name;
|
|
1249
1257
|
if (customReplacement) {
|
|
1250
|
-
return customReplacement(iconName, attributes);
|
|
1258
|
+
return customReplacement(iconName, attributes, alias);
|
|
1251
1259
|
}
|
|
1252
|
-
let
|
|
1260
|
+
let name = iconName;
|
|
1261
|
+
if (alias) {
|
|
1262
|
+
if (iconName && iconName.startsWith(alias + "-")) {
|
|
1263
|
+
name = iconName.substring(alias.length + 1);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
let svgContent = _chunk5BK6X4ZAcjs.json_default.icons[iconName] || _chunk5BK6X4ZAcjs.json_default.icons[name];
|
|
1253
1267
|
if (!svgContent) {
|
|
1254
1268
|
return { text: match.fullMatch, imptext: "" };
|
|
1255
1269
|
}
|
|
1256
1270
|
if (!attributes.type && type == runType || attributes.type === runType) {
|
|
1257
1271
|
if (dynamic) {
|
|
1258
|
-
return getVue(iconName, match);
|
|
1272
|
+
return getVue(iconName, match, name, alias);
|
|
1259
1273
|
} else {
|
|
1260
|
-
return getText(iconName, match);
|
|
1274
|
+
return getText(iconName, match, name);
|
|
1261
1275
|
}
|
|
1262
1276
|
}
|
|
1263
1277
|
if (type === "pub" && !attributes.type && !attributes.default) {
|
package/dist/vite/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
type IconReplacement = (iconName: string, attributes: ComponentAttributes) => {
|
|
3
|
+
type IconReplacement = (iconName: string, attributes: ComponentAttributes, alias?: string) => {
|
|
4
4
|
text: string;
|
|
5
5
|
imptext: string;
|
|
6
6
|
};
|
|
@@ -34,6 +34,10 @@ interface PluginOptions {
|
|
|
34
34
|
* 是否动态更新
|
|
35
35
|
*/
|
|
36
36
|
dynamic?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 别名
|
|
39
|
+
*/
|
|
40
|
+
alias?: string;
|
|
37
41
|
}
|
|
38
42
|
interface ComponentAttributes {
|
|
39
43
|
name: string;
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
type IconReplacement = (iconName: string, attributes: ComponentAttributes) => {
|
|
3
|
+
type IconReplacement = (iconName: string, attributes: ComponentAttributes, alias?: string) => {
|
|
4
4
|
text: string;
|
|
5
5
|
imptext: string;
|
|
6
6
|
};
|
|
@@ -34,6 +34,10 @@ interface PluginOptions {
|
|
|
34
34
|
* 是否动态更新
|
|
35
35
|
*/
|
|
36
36
|
dynamic?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 别名
|
|
39
|
+
*/
|
|
40
|
+
alias?: string;
|
|
37
41
|
}
|
|
38
42
|
interface ComponentAttributes {
|
|
39
43
|
name: string;
|
package/dist/vite/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "../chunk-YGLV5TML.js";
|
|
4
4
|
import {
|
|
5
5
|
json_default
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-3KXKNLJB.js";
|
|
7
7
|
import {
|
|
8
8
|
lineToLargeHump
|
|
9
9
|
} from "../chunk-J4G2OFZ4.js";
|
|
@@ -929,6 +929,7 @@ function simpleFangIcon(options = {}) {
|
|
|
929
929
|
dynamic = true,
|
|
930
930
|
virtual = false,
|
|
931
931
|
replaced = true,
|
|
932
|
+
alias = "icon",
|
|
932
933
|
customReplacement
|
|
933
934
|
} = options;
|
|
934
935
|
if (options.mobile) {
|
|
@@ -988,6 +989,7 @@ function simpleFangIcon(options = {}) {
|
|
|
988
989
|
import FangIcon from '@fangzhongya/icons/icon/index'
|
|
989
990
|
import { icons } from '@fangzhongya/icons/async'
|
|
990
991
|
import { lineToLargeHump } from '@fangzhongya/utils/name/lineToLargeHump';
|
|
992
|
+
const alias = lineToLargeHump(${alias})
|
|
991
993
|
const component = defineComponent({
|
|
992
994
|
name: '${name}',
|
|
993
995
|
props: {
|
|
@@ -1011,7 +1013,11 @@ function simpleFangIcon(options = {}) {
|
|
|
1011
1013
|
const name = props.name;
|
|
1012
1014
|
if (typeof name === 'string' && (props.type === '${runType}' ||
|
|
1013
1015
|
(!props.type && props.default === '${runType}'))) {
|
|
1014
|
-
|
|
1016
|
+
let n = lineToLargeHump(name)
|
|
1017
|
+
if(n.startsWith(alias)){
|
|
1018
|
+
n = n.substring(alias.length);
|
|
1019
|
+
}
|
|
1020
|
+
const icon = icons[n];
|
|
1015
1021
|
if(icon) return icon;
|
|
1016
1022
|
}
|
|
1017
1023
|
return name;
|
|
@@ -1089,7 +1095,8 @@ function simpleFangIcon(options = {}) {
|
|
|
1089
1095
|
component,
|
|
1090
1096
|
type,
|
|
1091
1097
|
dynamic,
|
|
1092
|
-
customReplacement
|
|
1098
|
+
customReplacement,
|
|
1099
|
+
alias
|
|
1093
1100
|
);
|
|
1094
1101
|
imports.add(imptext);
|
|
1095
1102
|
if (text !== component.fullMatch) {
|
|
@@ -1222,42 +1229,49 @@ function findComponents(code, name) {
|
|
|
1222
1229
|
}
|
|
1223
1230
|
return components;
|
|
1224
1231
|
}
|
|
1225
|
-
function getText(iconName, match) {
|
|
1226
|
-
const svg = getIconifySVG(json_default,
|
|
1232
|
+
function getText(iconName, match, name) {
|
|
1233
|
+
const svg = getIconifySVG(json_default, name);
|
|
1227
1234
|
const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`</${match.componentName}>`, "");
|
|
1228
1235
|
const text = `${s}${svg}</${match.componentName}>`;
|
|
1229
1236
|
return { text, imptext: "" };
|
|
1230
1237
|
}
|
|
1231
|
-
function getImportName(iconName) {
|
|
1232
|
-
return lineToLargeHump("
|
|
1238
|
+
function getImportName(iconName, alias) {
|
|
1239
|
+
return lineToLargeHump(alias + "-" + iconName);
|
|
1233
1240
|
}
|
|
1234
|
-
function getVue(iconName, match) {
|
|
1241
|
+
function getVue(iconName, match, name, alias = "icon") {
|
|
1235
1242
|
const text = match.fullMatch.replace(
|
|
1236
1243
|
`name="${iconName}"`,
|
|
1237
|
-
`:name="${getImportName(
|
|
1244
|
+
`:name="${getImportName(name, alias)}"`
|
|
1238
1245
|
);
|
|
1239
1246
|
return {
|
|
1240
1247
|
text,
|
|
1241
1248
|
imptext: `import ${getImportName(
|
|
1242
|
-
|
|
1243
|
-
|
|
1249
|
+
name,
|
|
1250
|
+
alias
|
|
1251
|
+
)} from '@fangzhongya/icons/vue/${name}'`
|
|
1244
1252
|
};
|
|
1245
1253
|
}
|
|
1246
|
-
function replaceComponent(match, type, dynamic, customReplacement) {
|
|
1254
|
+
function replaceComponent(match, type, dynamic, customReplacement, alias) {
|
|
1247
1255
|
const { attributes } = match;
|
|
1248
1256
|
const iconName = attributes.name;
|
|
1249
1257
|
if (customReplacement) {
|
|
1250
|
-
return customReplacement(iconName, attributes);
|
|
1258
|
+
return customReplacement(iconName, attributes, alias);
|
|
1251
1259
|
}
|
|
1252
|
-
let
|
|
1260
|
+
let name = iconName;
|
|
1261
|
+
if (alias) {
|
|
1262
|
+
if (iconName && iconName.startsWith(alias + "-")) {
|
|
1263
|
+
name = iconName.substring(alias.length + 1);
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
let svgContent = json_default.icons[iconName] || json_default.icons[name];
|
|
1253
1267
|
if (!svgContent) {
|
|
1254
1268
|
return { text: match.fullMatch, imptext: "" };
|
|
1255
1269
|
}
|
|
1256
1270
|
if (!attributes.type && type == runType || attributes.type === runType) {
|
|
1257
1271
|
if (dynamic) {
|
|
1258
|
-
return getVue(iconName, match);
|
|
1272
|
+
return getVue(iconName, match, name, alias);
|
|
1259
1273
|
} else {
|
|
1260
|
-
return getText(iconName, match);
|
|
1274
|
+
return getText(iconName, match, name);
|
|
1261
1275
|
}
|
|
1262
1276
|
}
|
|
1263
1277
|
if (type === "pub" && !attributes.type && !attributes.default) {
|