g-ui-web 1.4.39 → 1.4.40

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.
@@ -88,8 +88,6 @@ var init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then(({ export
88
88
  });
89
89
 
90
90
  // packages/plugins/component-usage.ts
91
- var import_compiler_sfc = require("@vue/compiler-sfc");
92
- var import_compiler_dom = require("@vue/compiler-dom");
93
91
  function componentUsagePlugin(options = {}) {
94
92
  const { libraryName = "", reportUrl = "", extraData = {}, enableInDev = false } = options;
95
93
  const importStats = {
@@ -163,21 +161,14 @@ function componentUsagePlugin(options = {}) {
163
161
  });
164
162
  }
165
163
  if (id.endsWith(".vue")) {
166
- const { descriptor } = (0, import_compiler_sfc.parse)(code);
167
- if (descriptor.template?.ast) {
168
- const walkNode = (node) => {
169
- if (node.type === import_compiler_dom.NodeTypes.ELEMENT && node.tag?.startsWith("g-")) {
170
- const tag = node.tag;
171
- const currentCount = importStats.componentCount.get(tag) || 0;
172
- importStats.componentCount.set(tag, currentCount + 1);
173
- componentsInFile.push(tag);
174
- importStats.totalImports++;
175
- }
176
- if (Array.isArray(node.children)) {
177
- node.children.forEach(walkNode);
178
- }
179
- };
180
- descriptor.template.ast.children.forEach(walkNode);
164
+ const tagRegex = /<(g-[a-z][a-z0-9-]*)/g;
165
+ let match;
166
+ while ((match = tagRegex.exec(code)) !== null) {
167
+ const tag = match[1];
168
+ const currentCount = importStats.componentCount.get(tag) || 0;
169
+ importStats.componentCount.set(tag, currentCount + 1);
170
+ componentsInFile.push(tag);
171
+ importStats.totalImports++;
181
172
  }
182
173
  }
183
174
  if (componentsInFile.length > 0) {
@@ -189,8 +180,8 @@ function componentUsagePlugin(options = {}) {
189
180
  }
190
181
  return null;
191
182
  },
192
- // 整个构建完全结束后再统计和上报,确保所有文件都已处理
193
- async closeBundle() {
183
+ // 构建结束时发送数据
184
+ async buildEnd() {
194
185
  if (!isBuild && !enableInDev) return;
195
186
  if (hasReported) return;
196
187
  hasReported = true;
@@ -62,8 +62,6 @@ var init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then(({ export
62
62
  });
63
63
 
64
64
  // packages/plugins/component-usage.ts
65
- import { parse as parseSFC } from "@vue/compiler-sfc";
66
- import { NodeTypes } from "@vue/compiler-dom";
67
65
  function componentUsagePlugin(options = {}) {
68
66
  const { libraryName = "", reportUrl = "", extraData = {}, enableInDev = false } = options;
69
67
  const importStats = {
@@ -137,21 +135,14 @@ function componentUsagePlugin(options = {}) {
137
135
  });
138
136
  }
139
137
  if (id.endsWith(".vue")) {
140
- const { descriptor } = parseSFC(code);
141
- if (descriptor.template?.ast) {
142
- const walkNode = (node) => {
143
- if (node.type === NodeTypes.ELEMENT && node.tag?.startsWith("g-")) {
144
- const tag = node.tag;
145
- const currentCount = importStats.componentCount.get(tag) || 0;
146
- importStats.componentCount.set(tag, currentCount + 1);
147
- componentsInFile.push(tag);
148
- importStats.totalImports++;
149
- }
150
- if (Array.isArray(node.children)) {
151
- node.children.forEach(walkNode);
152
- }
153
- };
154
- descriptor.template.ast.children.forEach(walkNode);
138
+ const tagRegex = /<(g-[a-z][a-z0-9-]*)/g;
139
+ let match;
140
+ while ((match = tagRegex.exec(code)) !== null) {
141
+ const tag = match[1];
142
+ const currentCount = importStats.componentCount.get(tag) || 0;
143
+ importStats.componentCount.set(tag, currentCount + 1);
144
+ componentsInFile.push(tag);
145
+ importStats.totalImports++;
155
146
  }
156
147
  }
157
148
  if (componentsInFile.length > 0) {
@@ -163,8 +154,8 @@ function componentUsagePlugin(options = {}) {
163
154
  }
164
155
  return null;
165
156
  },
166
- // 整个构建完全结束后再统计和上报,确保所有文件都已处理
167
- async closeBundle() {
157
+ // 构建结束时发送数据
158
+ async buildEnd() {
168
159
  if (!isBuild && !enableInDev) return;
169
160
  if (hasReported) return;
170
161
  hasReported = true;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "g-ui-web",
3
3
  "private": false,
4
4
  "description": "可视化组件库",
5
- "version": "1.4.39",
5
+ "version": "1.4.40",
6
6
  "author": "wyu",
7
7
  "license": "MIT",
8
8
  "type": "module",