@fangzhongya/icons 0.0.16 → 0.0.17

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.
@@ -8,7 +8,7 @@ var _chunkOSHAEKZLcjs = require('../chunk-OSHAEKZL.cjs');
8
8
  require('../chunk-IIVF4KK5.cjs');
9
9
 
10
10
 
11
- var _chunk5NH4G6UJcjs = require('../chunk-5NH4G6UJ.cjs');
11
+ var _chunkP3DB3N7Ycjs = require('../chunk-P3DB3N7Y.cjs');
12
12
  require('../chunk-75ZPJI57.cjs');
13
13
 
14
14
  // packages/vite/index.ts
@@ -20,12 +20,12 @@ function simpleFangIcon(options = {}) {
20
20
  type = "svg",
21
21
  directory = "./svg",
22
22
  dynamic = true,
23
+ virtual = false,
24
+ replaced = true,
23
25
  customReplacement
24
26
  } = options;
25
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
26
27
  if (type === "pub" && options.mobile) {
27
28
  const outDir = _path.join.call(void 0, "./public/", directory);
28
- console.log("outDir", outDir);
29
29
  _chunkV6F7B2R3cjs.runDev.call(void 0, {
30
30
  issort: true,
31
31
  dir: "./node_modules/@fangzhongya/icons/dist/svg",
@@ -36,112 +36,115 @@ function simpleFangIcon(options = {}) {
36
36
  isNeader: false
37
37
  });
38
38
  }
39
- const targetComponents = Array.isArray(name) ? name : [name];
40
- const pub = `
41
- import { defineComponent, h,} from 'vue'
42
- import FangIcon from '@fangzhongya/icons/icon/index'
43
- const component = defineComponent({
44
- name: '${name}',
45
- props: {
46
- name: {
47
- type: [String, Object],
48
- },
49
- default: {
50
- type: String,
51
- default: '${type}'
39
+ const plugin = {
40
+ name: "simple-fang-icon"
41
+ };
42
+ if (virtual) {
43
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
44
+ const pub = `
45
+ import { defineComponent, h,} from 'vue'
46
+ import FangIcon from '@fangzhongya/icons/icon/index'
47
+ const component = defineComponent({
48
+ name: '${name}',
49
+ props: {
50
+ name: {
51
+ type: [String, Object],
52
+ },
53
+ default: {
54
+ type: String,
55
+ default: '${type}'
56
+ },
57
+ directory: {
58
+ type: String,
59
+ default: '${directory}'
60
+ }
52
61
  },
53
- directory: {
54
- type: String,
55
- default: '${directory}'
62
+ setup(props, { attrs }) {
63
+ return () => {
64
+ return h(FangIcon, {
65
+ ...attrs,
66
+ name: props.name,
67
+ default: props.default,
68
+ directory: props.directory
69
+ });
70
+ };
56
71
  }
57
- },
58
- setup(props, { attrs }) {
59
- return () => {
60
- return h(FangIcon, {
61
- ...attrs,
62
- name: props.name,
63
- default: props.default,
64
- directory: props.directory
65
- });
66
- };
67
- }
68
- });
69
- // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
70
- export const install = (app) => {
71
- app.component('${name}', component)
72
- };
73
-
74
- export default component;`;
75
- const svg = `
76
- import { defineComponent, h, computed} from 'vue'
77
- import FangIcon from '@fangzhongya/icons/icon/index'
78
- import icons from '@fangzhongya/icons/async'
79
- const component = defineComponent({
80
- name: '${name}',
81
- props: {
82
- name: {
83
- type: [String, Object],
84
- },
85
- type: {
86
- type: String,
87
- },
88
- default: {
89
- type: String,
90
- default: '${type}'
72
+ });
73
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
74
+ export const install = (app) => {
75
+ app.component('${name}', component)
76
+ };
77
+
78
+ export default component;`;
79
+ const svg = `
80
+ import { defineComponent, h, computed} from 'vue'
81
+ import FangIcon from '@fangzhongya/icons/icon/index'
82
+ import icons from '@fangzhongya/icons/async'
83
+ const component = defineComponent({
84
+ name: '${name}',
85
+ props: {
86
+ name: {
87
+ type: [String, Object],
88
+ },
89
+ type: {
90
+ type: String,
91
+ },
92
+ default: {
93
+ type: String,
94
+ default: '${type}'
95
+ },
96
+ directory: {
97
+ type: String,
98
+ default: '${directory}'
99
+ }
91
100
  },
92
- directory: {
93
- type: String,
94
- default: '${directory}'
95
- }
96
- },
97
- setup(props, { attrs }) {
98
- const iconName = computed(() => {
99
- const name = props.name;
100
- if (typeof name === 'string' && (props.type === 'svg' ||
101
- (!props.type && props.default === 'svg'))) {
102
- const icon = icons[name];
103
- if(icon){
104
- return icon;
101
+ setup(props, { attrs }) {
102
+ const iconName = computed(() => {
103
+ const name = props.name;
104
+ if (typeof name === 'string' && (props.type === 'svg' ||
105
+ (!props.type && props.default === 'svg'))) {
106
+ const icon = icons[name];
107
+ if(icon){
108
+ return icon;
109
+ }
105
110
  }
106
- }
107
- return name;
108
- });
109
- return () => {
110
- return h(FangIcon, {
111
- ...attrs,
112
- name: iconName.value,
113
- type: props.type,
114
- default: props.default,
115
- directory: props.directory
111
+ return name;
116
112
  });
117
- };
118
- }
119
- });
120
- // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
121
- export const install = (app) => {
122
- app.component('${name}', component)
123
- };
124
-
125
- export default component;`;
126
- const text = type === "svg" ? svg : pub;
127
- return {
128
- name: "simple-fang-icon",
129
- resolveId(id) {
113
+ return () => {
114
+ return h(FangIcon, {
115
+ ...attrs,
116
+ name: iconName.value,
117
+ type: props.type,
118
+ default: props.default,
119
+ directory: props.directory
120
+ });
121
+ };
122
+ }
123
+ });
124
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
125
+ export const install = (app) => {
126
+ app.component('${name}', component)
127
+ };
128
+
129
+ export default component;`;
130
+ const text = type === "svg" ? svg : pub;
131
+ plugin.resolveId = function(id) {
130
132
  if (id === virtualModuleId) {
131
133
  return resolvedVirtualModuleId;
132
134
  }
133
135
  return void 0;
134
- },
135
- load(id) {
136
+ };
137
+ plugin.load = function(id) {
136
138
  if (id === resolvedVirtualModuleId) {
137
139
  return text;
138
140
  }
139
141
  return null;
140
- },
141
- // 使用 enforce 确保在 Vue 插件之前执行
142
- enforce: "pre",
143
- // 转换代码
144
- transform(code, id) {
142
+ };
143
+ }
144
+ if (replaced) {
145
+ const targetComponents = Array.isArray(name) ? name : [name];
146
+ plugin.enforce = "pre";
147
+ plugin.transform = function(code, id) {
145
148
  if (!shouldProcess(id)) {
146
149
  return null;
147
150
  }
@@ -156,15 +159,15 @@ export default component;`;
156
159
  for (let i = components.length - 1; i >= 0; i--) {
157
160
  const component = components[i];
158
161
  if (component) {
159
- const { text: text2, imptext } = replaceComponent(
162
+ const { text, imptext } = replaceComponent(
160
163
  component,
161
164
  type,
162
165
  dynamic,
163
166
  customReplacement
164
167
  );
165
168
  imports.add(imptext);
166
- if (text2 !== component.fullMatch) {
167
- transformedCode = transformedCode.slice(0, component.start) + text2 + transformedCode.slice(component.end);
169
+ if (text !== component.fullMatch) {
170
+ transformedCode = transformedCode.slice(0, component.start) + text + transformedCode.slice(component.end);
168
171
  replacedCount++;
169
172
  }
170
173
  }
@@ -185,9 +188,8 @@ export default component;`;
185
188
  console.error(`\u5904\u7406\u6587\u4EF6 ${id} \u65F6\u51FA\u9519:`, error);
186
189
  }
187
190
  return null;
188
- },
189
- // 处理热更新
190
- handleHotUpdate({
191
+ };
192
+ plugin.handleHotUpdate = function({
191
193
  file,
192
194
  server
193
195
  }) {
@@ -197,8 +199,9 @@ export default component;`;
197
199
  });
198
200
  return [];
199
201
  }
200
- }
201
- };
202
+ };
203
+ }
204
+ return plugin;
202
205
  }
203
206
  function parseAttributes(attrString) {
204
207
  const attributes = { name: "" };
@@ -287,7 +290,7 @@ function findComponents(code, name) {
287
290
  return components;
288
291
  }
289
292
  function getText(iconName, match) {
290
- const svg = _chunkOSHAEKZLcjs.getIconifySVG.call(void 0, _chunk5NH4G6UJcjs.json_default, iconName, 'v-bind="scope"');
293
+ const svg = _chunkOSHAEKZLcjs.getIconifySVG.call(void 0, _chunkP3DB3N7Ycjs.json_default, iconName, 'v-bind="scope"');
291
294
  const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`name='${iconName}'`, "").replace(`</${match.componentName}>`, "");
292
295
  const text = `${s}<template #default="scope">${svg}</template></${match.componentName}>`;
293
296
  return { text, imptext: "" };
@@ -310,7 +313,7 @@ function replaceComponent(match, type, dynamic, customReplacement) {
310
313
  if (customReplacement) {
311
314
  return customReplacement(iconName, attributes);
312
315
  }
313
- let svgContent = _chunk5NH4G6UJcjs.json_default.icons[iconName];
316
+ let svgContent = _chunkP3DB3N7Ycjs.json_default.icons[iconName];
314
317
  if (!svgContent) {
315
318
  return { text: match.fullMatch, imptext: "" };
316
319
  }
@@ -7,8 +7,10 @@ type IconReplacement = (iconName: string, attributes: ComponentAttributes) => {
7
7
  interface PluginOptions {
8
8
  name?: string;
9
9
  type?: string;
10
- customReplacement?: IconReplacement;
11
10
  directory?: string;
11
+ customReplacement?: IconReplacement;
12
+ virtual?: boolean;
13
+ replaced?: boolean;
12
14
  mobile?: boolean;
13
15
  dynamic?: boolean;
14
16
  }
@@ -7,8 +7,10 @@ type IconReplacement = (iconName: string, attributes: ComponentAttributes) => {
7
7
  interface PluginOptions {
8
8
  name?: string;
9
9
  type?: string;
10
- customReplacement?: IconReplacement;
11
10
  directory?: string;
11
+ customReplacement?: IconReplacement;
12
+ virtual?: boolean;
13
+ replaced?: boolean;
12
14
  mobile?: boolean;
13
15
  dynamic?: boolean;
14
16
  }
@@ -8,7 +8,7 @@ import {
8
8
  import "../chunk-MOHILOKE.js";
9
9
  import {
10
10
  json_default
11
- } from "../chunk-RDKCKIKJ.js";
11
+ } from "../chunk-CDXRU53D.js";
12
12
  import "../chunk-MLKGABMK.js";
13
13
 
14
14
  // packages/vite/index.ts
@@ -20,12 +20,12 @@ function simpleFangIcon(options = {}) {
20
20
  type = "svg",
21
21
  directory = "./svg",
22
22
  dynamic = true,
23
+ virtual = false,
24
+ replaced = true,
23
25
  customReplacement
24
26
  } = options;
25
- const resolvedVirtualModuleId = "\0" + virtualModuleId;
26
27
  if (type === "pub" && options.mobile) {
27
28
  const outDir = join("./public/", directory);
28
- console.log("outDir", outDir);
29
29
  runDev({
30
30
  issort: true,
31
31
  dir: "./node_modules/@fangzhongya/icons/dist/svg",
@@ -36,112 +36,115 @@ function simpleFangIcon(options = {}) {
36
36
  isNeader: false
37
37
  });
38
38
  }
39
- const targetComponents = Array.isArray(name) ? name : [name];
40
- const pub = `
41
- import { defineComponent, h,} from 'vue'
42
- import FangIcon from '@fangzhongya/icons/icon/index'
43
- const component = defineComponent({
44
- name: '${name}',
45
- props: {
46
- name: {
47
- type: [String, Object],
48
- },
49
- default: {
50
- type: String,
51
- default: '${type}'
39
+ const plugin = {
40
+ name: "simple-fang-icon"
41
+ };
42
+ if (virtual) {
43
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
44
+ const pub = `
45
+ import { defineComponent, h,} from 'vue'
46
+ import FangIcon from '@fangzhongya/icons/icon/index'
47
+ const component = defineComponent({
48
+ name: '${name}',
49
+ props: {
50
+ name: {
51
+ type: [String, Object],
52
+ },
53
+ default: {
54
+ type: String,
55
+ default: '${type}'
56
+ },
57
+ directory: {
58
+ type: String,
59
+ default: '${directory}'
60
+ }
52
61
  },
53
- directory: {
54
- type: String,
55
- default: '${directory}'
62
+ setup(props, { attrs }) {
63
+ return () => {
64
+ return h(FangIcon, {
65
+ ...attrs,
66
+ name: props.name,
67
+ default: props.default,
68
+ directory: props.directory
69
+ });
70
+ };
56
71
  }
57
- },
58
- setup(props, { attrs }) {
59
- return () => {
60
- return h(FangIcon, {
61
- ...attrs,
62
- name: props.name,
63
- default: props.default,
64
- directory: props.directory
65
- });
66
- };
67
- }
68
- });
69
- // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
70
- export const install = (app) => {
71
- app.component('${name}', component)
72
- };
73
-
74
- export default component;`;
75
- const svg = `
76
- import { defineComponent, h, computed} from 'vue'
77
- import FangIcon from '@fangzhongya/icons/icon/index'
78
- import icons from '@fangzhongya/icons/async'
79
- const component = defineComponent({
80
- name: '${name}',
81
- props: {
82
- name: {
83
- type: [String, Object],
84
- },
85
- type: {
86
- type: String,
87
- },
88
- default: {
89
- type: String,
90
- default: '${type}'
72
+ });
73
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
74
+ export const install = (app) => {
75
+ app.component('${name}', component)
76
+ };
77
+
78
+ export default component;`;
79
+ const svg = `
80
+ import { defineComponent, h, computed} from 'vue'
81
+ import FangIcon from '@fangzhongya/icons/icon/index'
82
+ import icons from '@fangzhongya/icons/async'
83
+ const component = defineComponent({
84
+ name: '${name}',
85
+ props: {
86
+ name: {
87
+ type: [String, Object],
88
+ },
89
+ type: {
90
+ type: String,
91
+ },
92
+ default: {
93
+ type: String,
94
+ default: '${type}'
95
+ },
96
+ directory: {
97
+ type: String,
98
+ default: '${directory}'
99
+ }
91
100
  },
92
- directory: {
93
- type: String,
94
- default: '${directory}'
95
- }
96
- },
97
- setup(props, { attrs }) {
98
- const iconName = computed(() => {
99
- const name = props.name;
100
- if (typeof name === 'string' && (props.type === 'svg' ||
101
- (!props.type && props.default === 'svg'))) {
102
- const icon = icons[name];
103
- if(icon){
104
- return icon;
101
+ setup(props, { attrs }) {
102
+ const iconName = computed(() => {
103
+ const name = props.name;
104
+ if (typeof name === 'string' && (props.type === 'svg' ||
105
+ (!props.type && props.default === 'svg'))) {
106
+ const icon = icons[name];
107
+ if(icon){
108
+ return icon;
109
+ }
105
110
  }
106
- }
107
- return name;
108
- });
109
- return () => {
110
- return h(FangIcon, {
111
- ...attrs,
112
- name: iconName.value,
113
- type: props.type,
114
- default: props.default,
115
- directory: props.directory
111
+ return name;
116
112
  });
117
- };
118
- }
119
- });
120
- // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
121
- export const install = (app) => {
122
- app.component('${name}', component)
123
- };
124
-
125
- export default component;`;
126
- const text = type === "svg" ? svg : pub;
127
- return {
128
- name: "simple-fang-icon",
129
- resolveId(id) {
113
+ return () => {
114
+ return h(FangIcon, {
115
+ ...attrs,
116
+ name: iconName.value,
117
+ type: props.type,
118
+ default: props.default,
119
+ directory: props.directory
120
+ });
121
+ };
122
+ }
123
+ });
124
+ // \u5BFC\u51FA\u5B89\u88C5\u51FD\u6570
125
+ export const install = (app) => {
126
+ app.component('${name}', component)
127
+ };
128
+
129
+ export default component;`;
130
+ const text = type === "svg" ? svg : pub;
131
+ plugin.resolveId = function(id) {
130
132
  if (id === virtualModuleId) {
131
133
  return resolvedVirtualModuleId;
132
134
  }
133
135
  return void 0;
134
- },
135
- load(id) {
136
+ };
137
+ plugin.load = function(id) {
136
138
  if (id === resolvedVirtualModuleId) {
137
139
  return text;
138
140
  }
139
141
  return null;
140
- },
141
- // 使用 enforce 确保在 Vue 插件之前执行
142
- enforce: "pre",
143
- // 转换代码
144
- transform(code, id) {
142
+ };
143
+ }
144
+ if (replaced) {
145
+ const targetComponents = Array.isArray(name) ? name : [name];
146
+ plugin.enforce = "pre";
147
+ plugin.transform = function(code, id) {
145
148
  if (!shouldProcess(id)) {
146
149
  return null;
147
150
  }
@@ -156,15 +159,15 @@ export default component;`;
156
159
  for (let i = components.length - 1; i >= 0; i--) {
157
160
  const component = components[i];
158
161
  if (component) {
159
- const { text: text2, imptext } = replaceComponent(
162
+ const { text, imptext } = replaceComponent(
160
163
  component,
161
164
  type,
162
165
  dynamic,
163
166
  customReplacement
164
167
  );
165
168
  imports.add(imptext);
166
- if (text2 !== component.fullMatch) {
167
- transformedCode = transformedCode.slice(0, component.start) + text2 + transformedCode.slice(component.end);
169
+ if (text !== component.fullMatch) {
170
+ transformedCode = transformedCode.slice(0, component.start) + text + transformedCode.slice(component.end);
168
171
  replacedCount++;
169
172
  }
170
173
  }
@@ -185,9 +188,8 @@ export default component;`;
185
188
  console.error(`\u5904\u7406\u6587\u4EF6 ${id} \u65F6\u51FA\u9519:`, error);
186
189
  }
187
190
  return null;
188
- },
189
- // 处理热更新
190
- handleHotUpdate({
191
+ };
192
+ plugin.handleHotUpdate = function({
191
193
  file,
192
194
  server
193
195
  }) {
@@ -197,8 +199,9 @@ export default component;`;
197
199
  });
198
200
  return [];
199
201
  }
200
- }
201
- };
202
+ };
203
+ }
204
+ return plugin;
202
205
  }
203
206
  function parseAttributes(attrString) {
204
207
  const attributes = { name: "" };
@@ -5,7 +5,7 @@ var _chunkOSHAEKZLcjs = require('../chunk-OSHAEKZL.cjs');
5
5
  require('../chunk-IIVF4KK5.cjs');
6
6
 
7
7
 
8
- var _chunk5NH4G6UJcjs = require('../chunk-5NH4G6UJ.cjs');
8
+ var _chunkP3DB3N7Ycjs = require('../chunk-P3DB3N7Y.cjs');
9
9
  require('../chunk-75ZPJI57.cjs');
10
10
 
11
11
  // packages/vite/index2.ts
@@ -96,7 +96,7 @@ function findComponents(code, name) {
96
96
  return components;
97
97
  }
98
98
  function getText(iconName, match) {
99
- const svg = _chunkOSHAEKZLcjs.getIconifySVG.call(void 0, _chunk5NH4G6UJcjs.json_default, iconName, 'v-bind="scope"');
99
+ const svg = _chunkOSHAEKZLcjs.getIconifySVG.call(void 0, _chunkP3DB3N7Ycjs.json_default, iconName, 'v-bind="scope"');
100
100
  const s = match.fullMatch.replace(`name="${iconName}"`, "").replace(`name='${iconName}'`, "").replace(`</${match.componentName}>`, "");
101
101
  const text = `${s}<template #default="scope">${svg}</template></${match.componentName}>`;
102
102
  return { text, imptext: "" };
@@ -119,7 +119,7 @@ function replaceComponent(match, type, dynamic, customReplacement) {
119
119
  if (customReplacement) {
120
120
  return customReplacement(iconName, attributes);
121
121
  }
122
- let svgContent = _chunk5NH4G6UJcjs.json_default.icons[iconName];
122
+ let svgContent = _chunkP3DB3N7Ycjs.json_default.icons[iconName];
123
123
  if (!svgContent) {
124
124
  return { text: match.fullMatch, imptext: "" };
125
125
  }
@@ -5,7 +5,7 @@ import {
5
5
  import "../chunk-MOHILOKE.js";
6
6
  import {
7
7
  json_default
8
- } from "../chunk-RDKCKIKJ.js";
8
+ } from "../chunk-CDXRU53D.js";
9
9
  import "../chunk-MLKGABMK.js";
10
10
 
11
11
  // packages/vite/index2.ts