weapp-vite 7.3.0 → 7.5.0

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.
Files changed (91) hide show
  1. package/README.md +154 -6
  2. package/bin/bootstrap.js +14 -1
  3. package/dist/adapters-CcHrsYaj.mjs +1 -0
  4. package/dist/analyze-ZJUvEdaY.mjs +248 -0
  5. package/dist/auto-import-components/resolvers.mjs +1 -2
  6. package/dist/auto-import-presets/wevu-router.mjs +1 -2
  7. package/dist/auto-import-presets/wevu.mjs +1 -2
  8. package/dist/auto-routes.mjs +2 -1
  9. package/dist/budget-BD7VqLCl.d.mts +178 -0
  10. package/dist/chunkStrategy-DRA5WpB-.mjs +1436 -0
  11. package/dist/cli-acceptance.d.mts +1 -0
  12. package/dist/cli-acceptance.mjs +21 -0
  13. package/dist/cli.mjs +1918 -2089
  14. package/dist/compatibility.mjs +1 -2
  15. package/dist/{config-1J4rToMR.d.mts → config-V0L-IAJf.d.mts} +419 -39
  16. package/dist/config.d.mts +2 -2
  17. package/dist/config.mjs +1 -1
  18. package/dist/constants-DEZdcsMn.mjs +85 -0
  19. package/dist/{createContext-cqr9Y4EV.mjs → createCompilerContextInstance-DJH_P_nZ.mjs} +17602 -15886
  20. package/dist/createContext-BqYzHhY9.mjs +12 -0
  21. package/dist/dashboard/analyze.d.mts +48 -0
  22. package/dist/dashboard/analyze.mjs +1 -0
  23. package/dist/dashboard/vite.d.mts +9 -0
  24. package/dist/dashboard/vite.mjs +44 -0
  25. package/dist/dashboard-DvqF3Key.mjs +1842 -0
  26. package/dist/dashboard.d.mts +3 -0
  27. package/dist/dashboard.mjs +1 -0
  28. package/dist/dashboardViteBridge-Dy3nAD4m.mjs +299 -0
  29. package/dist/dev-fR5GiJRO.mjs +63 -0
  30. package/dist/devProvider-BGBkw28J.mjs +1050 -0
  31. package/dist/docs/README.md +154 -6
  32. package/dist/docs/ai-workflows.md +4 -0
  33. package/dist/docs/doctor.md +38 -0
  34. package/dist/docs/getting-started.md +52 -1
  35. package/dist/docs/index.md +6 -2
  36. package/dist/docs/mcp.md +94 -1
  37. package/dist/docs/testing.md +29 -2
  38. package/dist/docs/troubleshooting.md +8 -0
  39. package/dist/docs/uni-app-component-libraries.md +8 -7
  40. package/dist/docs/upload.md +226 -0
  41. package/dist/docs/vite-plugin.md +171 -0
  42. package/dist/docs/vue-sfc.md +19 -0
  43. package/dist/docs/weapp-config.md +374 -2
  44. package/dist/docs/wevu-authoring.md +10 -0
  45. package/dist/doctor-worker.d.mts +1 -0
  46. package/dist/doctor-worker.mjs +59 -0
  47. package/dist/doctor.d.mts +144 -0
  48. package/dist/doctor.mjs +848 -0
  49. package/dist/eslint.mjs +1 -2
  50. package/dist/file-DRb4eWqw.mjs +1 -0
  51. package/dist/{file-CKB0Tn8Z.mjs → file-sC3jD7Fh.mjs} +16 -93
  52. package/dist/files-BqxFIPRp.mjs +45 -0
  53. package/dist/getInstance-DiGSzBNI.mjs +28 -0
  54. package/dist/getInstance-SiE6WZRh.mjs +1 -0
  55. package/dist/index-C9HjUX5c.d.mts +741 -0
  56. package/dist/index.d.mts +10 -8
  57. package/dist/index.mjs +3 -2
  58. package/dist/json.d.mts +1 -1
  59. package/dist/json.mjs +1 -2
  60. package/dist/lifecycle-BROTlwSL.mjs +320 -0
  61. package/dist/loadConfig-C3BQhz7F.mjs +59 -0
  62. package/dist/loadConfig-VGtBF4qm.mjs +1 -0
  63. package/dist/logger-DGn5iEVN.mjs +1 -0
  64. package/dist/{mcp-BG6TliEg.mjs → mcp-Cj8Maqo6.mjs} +16 -7
  65. package/dist/mcp-D3Yh24Cj.mjs +529 -0
  66. package/dist/mcp.d.mts +6 -3
  67. package/dist/mcp.mjs +1 -2
  68. package/dist/package-7swhyLmf.mjs +91 -0
  69. package/dist/path-doV773b7.mjs +103 -0
  70. package/dist/platform-CnkySBKz.mjs +175 -0
  71. package/dist/processCleanup-B6KA30Zc.mjs +77 -0
  72. package/dist/protocol-vg8HGJ4n.mjs +138 -0
  73. package/dist/{resolvers-icNxkpcy.mjs → resolvers-Dod-euqX.mjs} +4 -1
  74. package/dist/resolvers.mjs +1 -2
  75. package/dist/runtime.mjs +1 -2
  76. package/dist/session-PskhD-nZ.mjs +390 -0
  77. package/dist/test.d.mts +1 -0
  78. package/dist/test.mjs +201 -44
  79. package/dist/types.d.mts +2 -2
  80. package/dist/upload-D4msblBf.mjs +562 -0
  81. package/dist/upload-worker.d.mts +1 -0
  82. package/dist/upload-worker.mjs +161 -0
  83. package/dist/utils-CJSCgEj6.mjs +1094 -0
  84. package/dist/vite.d.mts +9 -0
  85. package/dist/vite.mjs +270 -0
  86. package/dist/volar.d.mts +2 -2
  87. package/dist/web-apis.mjs +1 -2
  88. package/package.json +85 -37
  89. package/dist/file-CvgkbGIx.mjs +0 -2
  90. package/dist/getInstance-CZ1s63zd.mjs +0 -2
  91. package/dist/logger-mt4mSTqV.mjs +0 -2
@@ -0,0 +1,161 @@
1
+ import { i as terminateUploadDescendants, r as redactUploadSecrets, t as prepareUpload } from "./upload-D4msblBf.mjs";
2
+ import process from "node:process";
3
+ //#region src/cli/upload/uploadResult.ts
4
+ function record(value) {
5
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
6
+ }
7
+ function text(value, secrets) {
8
+ if (typeof value !== "string" || !value.trim() || value.includes("\0")) return;
9
+ return redactUploadSecrets(value.trim(), secrets);
10
+ }
11
+ function bytes(value) {
12
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
13
+ }
14
+ function link(value, secrets, scheme = false) {
15
+ if (typeof value !== "string" || !value.trim() || /[\s\p{Cc}]/u.test(value.trim())) return;
16
+ try {
17
+ const url = new URL(value);
18
+ if (!(scheme ? [
19
+ "http:",
20
+ "https:",
21
+ "baiduboxapp:",
22
+ "swan:"
23
+ ] : ["http:", "https:"]).includes(url.protocol) || url.username || url.password) return;
24
+ return text(value, secrets);
25
+ } catch {
26
+ return;
27
+ }
28
+ }
29
+ function base64(value, secrets) {
30
+ if (typeof value !== "string") return;
31
+ const source = value.trim();
32
+ const content = source.replace(/^data:image\/(?:png|jpe?g|gif|webp);base64,/i, "");
33
+ if (!content || !/^(?:[a-z\d+/]{4})*(?:[a-z\d+/]{2}==|[a-z\d+/]{3}=)?$/i.test(content)) return;
34
+ return text(source, secrets);
35
+ }
36
+ /** 按官方上传结果选择字段;可选信息无效时丢弃,不把已完成上传改判失败。 */
37
+ function normalizeUploadResult(platform, value, secrets) {
38
+ const input = record(value);
39
+ const result = {};
40
+ if (!input) return result;
41
+ if (platform === "weapp") {
42
+ if (Array.isArray(input.subPackageInfo)) result.subPackages = input.subPackageInfo.flatMap((value) => {
43
+ const item = record(value);
44
+ const name = text(item?.name, secrets);
45
+ const size = bytes(item?.size);
46
+ return name !== void 0 && size !== void 0 ? [{
47
+ name,
48
+ size
49
+ }] : [];
50
+ });
51
+ if (Array.isArray(input.pluginInfo)) result.plugins = input.pluginInfo.flatMap((value) => {
52
+ const item = record(value);
53
+ const appid = text(item?.pluginProviderAppid, secrets);
54
+ const version = text(item?.version, secrets);
55
+ const size = bytes(item?.size);
56
+ return appid !== void 0 && version !== void 0 && size !== void 0 ? [{
57
+ appid,
58
+ version,
59
+ size
60
+ }] : [];
61
+ });
62
+ } else if (platform === "alipay") {
63
+ const sdkVersion = text(input.version, secrets);
64
+ const qrCodeUrl = link(input.experienceQrCodeUrl, secrets);
65
+ if (sdkVersion !== void 0) result.sdkVersion = sdkVersion;
66
+ if (qrCodeUrl !== void 0) result.qrCodeUrl = qrCodeUrl;
67
+ } else if (platform === "tt") {
68
+ const previewUrl = link(input.shortUrl, secrets);
69
+ const qrCodeFile = text(input.qrcodeFilePath, secrets);
70
+ if (previewUrl !== void 0) result.previewUrl = previewUrl;
71
+ if (qrCodeFile !== void 0) result.qrCodeFile = qrCodeFile;
72
+ } else if (platform === "jd") {
73
+ const qrCodeUrl = link(input.imgUrl, secrets);
74
+ const qrCodeBase64 = base64(input.base64Data, secrets);
75
+ if (qrCodeUrl !== void 0) result.qrCodeUrl = qrCodeUrl;
76
+ if (qrCodeBase64 !== void 0) result.qrCodeBase64 = qrCodeBase64;
77
+ } else if (platform === "swan") {
78
+ const previewUrl = link(input.schemeUrlOpti, secrets, true) ?? link(input.schemeUrl, secrets, true);
79
+ const fileSize = bytes(input.fileSize);
80
+ if (previewUrl !== void 0) result.previewUrl = previewUrl;
81
+ if (fileSize !== void 0) result.fileSize = fileSize;
82
+ if (Array.isArray(input.warningList)) result.warnings = input.warningList.flatMap((value) => {
83
+ const warning = text(value, secrets);
84
+ return warning === void 0 ? [] : [warning];
85
+ });
86
+ }
87
+ return result;
88
+ }
89
+ //#endregion
90
+ //#region src/cli/upload/worker.ts
91
+ process.once("disconnect", () => process.exit(1));
92
+ process.once("SIGINT", () => process.exit(1));
93
+ process.once("SIGTERM", () => process.exit(1));
94
+ process.once("exit", () => {
95
+ try {
96
+ terminateUploadDescendants(process.pid);
97
+ } catch {
98
+ process.stderr.write("无法确认本地 SDK 子进程已全部终止。\n");
99
+ process.exitCode = 1;
100
+ }
101
+ });
102
+ try {
103
+ let input = "";
104
+ for await (const chunk of process.stdin) input += String(chunk);
105
+ const { platform, context, action } = JSON.parse(input);
106
+ if (action !== "upload" && action !== "preview") throw new Error("不支持的上传或预览操作。");
107
+ const upload = await prepareUpload(platform, context, action);
108
+ await new Promise((resolve, reject) => {
109
+ const onMessage = (message) => {
110
+ if (message && typeof message === "object" && "type" in message && message.type === "run" && "action" in message && message.action === action) {
111
+ process.off("message", onMessage);
112
+ resolve();
113
+ }
114
+ };
115
+ if (!process.send) {
116
+ reject(/* @__PURE__ */ new Error("上传 worker 缺少父进程 IPC 通道。"));
117
+ return;
118
+ }
119
+ process.on("message", onMessage);
120
+ process.send({
121
+ type: "started",
122
+ action
123
+ }, (error) => {
124
+ if (error) {
125
+ process.off("message", onMessage);
126
+ reject(error);
127
+ }
128
+ });
129
+ });
130
+ const onProgress = (event) => {
131
+ const safeEvent = {
132
+ type: event.type,
133
+ ...typeof event.message === "string" ? { message: redactUploadSecrets(event.message, upload.secrets) } : {},
134
+ ...typeof event.percent === "number" && Number.isFinite(event.percent) ? { percent: event.percent } : {}
135
+ };
136
+ process.send?.({
137
+ type: "progress",
138
+ action,
139
+ event: safeEvent
140
+ }, (error) => {
141
+ if (error) process.exit(1);
142
+ });
143
+ };
144
+ const rawResult = await upload.run(onProgress);
145
+ const result = action === "upload" ? normalizeUploadResult(platform, rawResult, upload.secrets) : rawResult;
146
+ const finish = () => process.stderr.write("", () => process.stdout.write("", () => process.exit(0)));
147
+ if (process.send) process.send({
148
+ type: "completed",
149
+ action,
150
+ result
151
+ }, (error) => {
152
+ if (error) process.exit(1);
153
+ finish();
154
+ });
155
+ else finish();
156
+ } catch (error) {
157
+ const message = error instanceof Error ? error.message : String(error);
158
+ process.stderr.write(`${message}\n`, () => process.exit(1));
159
+ }
160
+ //#endregion
161
+ export {};