g-ui-web 1.4.39 → 1.4.41
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/lib/g-ui-web.cjs +65 -158
- package/lib/g-ui-web.iife.js +66 -159
- package/lib/g-ui-web.iife.js.gz +0 -0
- package/lib/g-ui-web.js +61860 -82552
- package/lib/g-ui-web.js.gz +0 -0
- package/lib/g-ui-web.umd.cjs +66 -159
- package/lib/plugins/index.cjs +17 -28
- package/lib/plugins/index.mjs +17 -28
- package/lib/text-select/src/index.vue.d.ts +1 -1
- package/package.json +1 -1
package/lib/plugins/index.cjs
CHANGED
|
@@ -88,8 +88,8 @@ var init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then(({ export
|
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
// packages/plugins/component-usage.ts
|
|
91
|
-
var
|
|
92
|
-
var
|
|
91
|
+
var import_fs = require("fs");
|
|
92
|
+
var import_path = require("path");
|
|
93
93
|
function componentUsagePlugin(options = {}) {
|
|
94
94
|
const { libraryName = "", reportUrl = "", extraData = {}, enableInDev = false } = options;
|
|
95
95
|
const importStats = {
|
|
@@ -163,21 +163,14 @@ function componentUsagePlugin(options = {}) {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
if (id.endsWith(".vue")) {
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
importStats.totalImports++;
|
|
175
|
-
}
|
|
176
|
-
if (Array.isArray(node.children)) {
|
|
177
|
-
node.children.forEach(walkNode);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
descriptor.template.ast.children.forEach(walkNode);
|
|
166
|
+
const tagRegex = /<(g-[a-z][a-z0-9-]*)/g;
|
|
167
|
+
let match;
|
|
168
|
+
while ((match = tagRegex.exec(code)) !== null) {
|
|
169
|
+
const tag = match[1];
|
|
170
|
+
const currentCount = importStats.componentCount.get(tag) || 0;
|
|
171
|
+
importStats.componentCount.set(tag, currentCount + 1);
|
|
172
|
+
componentsInFile.push(tag);
|
|
173
|
+
importStats.totalImports++;
|
|
181
174
|
}
|
|
182
175
|
}
|
|
183
176
|
if (componentsInFile.length > 0) {
|
|
@@ -189,8 +182,8 @@ function componentUsagePlugin(options = {}) {
|
|
|
189
182
|
}
|
|
190
183
|
return null;
|
|
191
184
|
},
|
|
192
|
-
//
|
|
193
|
-
async
|
|
185
|
+
// 构建结束时发送数据
|
|
186
|
+
async buildEnd() {
|
|
194
187
|
if (!isBuild && !enableInDev) return;
|
|
195
188
|
if (hasReported) return;
|
|
196
189
|
hasReported = true;
|
|
@@ -208,15 +201,11 @@ function componentUsagePlugin(options = {}) {
|
|
|
208
201
|
topComponents: [...importStats.componentCount.entries()].sort((a, b) => b[1] - a[1]).slice(0, 20).map(([name, count]) => ({ name, count })),
|
|
209
202
|
...extraData
|
|
210
203
|
};
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
console.log(`
|
|
215
|
-
|
|
216
|
-
console.log("\n Top 10 \u7EC4\u4EF6:");
|
|
217
|
-
reportData.topComponents.slice(0, 10).forEach((item, index) => {
|
|
218
|
-
console.log(` ${index + 1}. ${item.name}: ${item.count} \u6B21`);
|
|
219
|
-
});
|
|
204
|
+
const outputPath = (0, import_path.resolve)(process.cwd(), "component-usage-report.json");
|
|
205
|
+
(0, import_fs.mkdirSync)((0, import_path.dirname)(outputPath), { recursive: true });
|
|
206
|
+
(0, import_fs.writeFileSync)(outputPath, JSON.stringify(reportData, null, 2), "utf-8");
|
|
207
|
+
console.log(`
|
|
208
|
+
\u{1F4CA} \u7EC4\u4EF6\u5F15\u7528\u7EDF\u8BA1\u62A5\u544A\u5DF2\u751F\u6210: ${outputPath}`);
|
|
220
209
|
if (reportUrl) {
|
|
221
210
|
try {
|
|
222
211
|
const response = await fetch(reportUrl, {
|
package/lib/plugins/index.mjs
CHANGED
|
@@ -62,8 +62,8 @@ var init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then(({ export
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
// packages/plugins/component-usage.ts
|
|
65
|
-
import {
|
|
66
|
-
import {
|
|
65
|
+
import { writeFileSync, mkdirSync } from "fs";
|
|
66
|
+
import { resolve, dirname } from "path";
|
|
67
67
|
function componentUsagePlugin(options = {}) {
|
|
68
68
|
const { libraryName = "", reportUrl = "", extraData = {}, enableInDev = false } = options;
|
|
69
69
|
const importStats = {
|
|
@@ -137,21 +137,14 @@ function componentUsagePlugin(options = {}) {
|
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
139
|
if (id.endsWith(".vue")) {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
importStats.totalImports++;
|
|
149
|
-
}
|
|
150
|
-
if (Array.isArray(node.children)) {
|
|
151
|
-
node.children.forEach(walkNode);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
descriptor.template.ast.children.forEach(walkNode);
|
|
140
|
+
const tagRegex = /<(g-[a-z][a-z0-9-]*)/g;
|
|
141
|
+
let match;
|
|
142
|
+
while ((match = tagRegex.exec(code)) !== null) {
|
|
143
|
+
const tag = match[1];
|
|
144
|
+
const currentCount = importStats.componentCount.get(tag) || 0;
|
|
145
|
+
importStats.componentCount.set(tag, currentCount + 1);
|
|
146
|
+
componentsInFile.push(tag);
|
|
147
|
+
importStats.totalImports++;
|
|
155
148
|
}
|
|
156
149
|
}
|
|
157
150
|
if (componentsInFile.length > 0) {
|
|
@@ -163,8 +156,8 @@ function componentUsagePlugin(options = {}) {
|
|
|
163
156
|
}
|
|
164
157
|
return null;
|
|
165
158
|
},
|
|
166
|
-
//
|
|
167
|
-
async
|
|
159
|
+
// 构建结束时发送数据
|
|
160
|
+
async buildEnd() {
|
|
168
161
|
if (!isBuild && !enableInDev) return;
|
|
169
162
|
if (hasReported) return;
|
|
170
163
|
hasReported = true;
|
|
@@ -182,15 +175,11 @@ function componentUsagePlugin(options = {}) {
|
|
|
182
175
|
topComponents: [...importStats.componentCount.entries()].sort((a, b) => b[1] - a[1]).slice(0, 20).map(([name, count]) => ({ name, count })),
|
|
183
176
|
...extraData
|
|
184
177
|
};
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
console.log(`
|
|
189
|
-
|
|
190
|
-
console.log("\n Top 10 \u7EC4\u4EF6:");
|
|
191
|
-
reportData.topComponents.slice(0, 10).forEach((item, index) => {
|
|
192
|
-
console.log(` ${index + 1}. ${item.name}: ${item.count} \u6B21`);
|
|
193
|
-
});
|
|
178
|
+
const outputPath = resolve(process.cwd(), "component-usage-report.json");
|
|
179
|
+
mkdirSync(dirname(outputPath), { recursive: true });
|
|
180
|
+
writeFileSync(outputPath, JSON.stringify(reportData, null, 2), "utf-8");
|
|
181
|
+
console.log(`
|
|
182
|
+
\u{1F4CA} \u7EC4\u4EF6\u5F15\u7528\u7EDF\u8BA1\u62A5\u544A\u5DF2\u751F\u6210: ${outputPath}`);
|
|
194
183
|
if (reportUrl) {
|
|
195
184
|
try {
|
|
196
185
|
const response = await fetch(reportUrl, {
|
|
@@ -187,7 +187,7 @@ declare function __VLS_template(): {
|
|
|
187
187
|
contentRef: Ref<HTMLElement | undefined>;
|
|
188
188
|
triggeringElementRef: Ref<any>;
|
|
189
189
|
referenceElementRef: Ref<any>;
|
|
190
|
-
}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("
|
|
190
|
+
}, unknown, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, ("click" | "visible-change" | "command")[], import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, {
|
|
191
191
|
readonly disabled: boolean;
|
|
192
192
|
readonly maxHeight: string | number;
|
|
193
193
|
readonly size: string;
|