weapp-vite 7.5.0 → 7.6.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 (93) hide show
  1. package/README.md +8 -2
  2. package/THIRD_PARTY_NOTICES.md +60 -0
  3. package/dist/action-B3YZMA-h.mjs +255 -0
  4. package/dist/action-BELcDNNv.mjs +139 -0
  5. package/dist/action-BOk3vGI7.mjs +1110 -0
  6. package/dist/action-DlC6JYpt.mjs +95 -0
  7. package/dist/action-zEDY7oh_.mjs +247 -0
  8. package/dist/{analyze-ZJUvEdaY.mjs → analyze-DN79YOAH.mjs} +1 -65
  9. package/dist/artifacts-BOyC9Fy-.mjs +106 -0
  10. package/dist/assets-C5_YYXNk.mjs +637 -0
  11. package/dist/auto-routes.mjs +2 -2
  12. package/dist/{budget-BD7VqLCl.d.mts → budget-CTLOHwgI.d.mts} +1 -2
  13. package/dist/budget-EOeEycc_.mjs +65 -0
  14. package/dist/builtProject-C29udgXY.mjs +541 -0
  15. package/dist/{chunkStrategy-DRA5WpB-.mjs → chunkStrategy-DY_LZIIe.mjs} +15 -3
  16. package/dist/{package-7swhyLmf.mjs → classifier-DBJY__kg.mjs} +4 -7
  17. package/dist/cli-acceptance.mjs +1 -1
  18. package/dist/cli.mjs +110 -4506
  19. package/dist/{config-V0L-IAJf.d.mts → config-Bf6DWhyb.d.mts} +136 -49
  20. package/dist/config.d.mts +2 -2
  21. package/dist/{createCompilerContextInstance-DJH_P_nZ.mjs → createCompilerContextInstance-aYwi8wQt.mjs} +15235 -9523
  22. package/dist/{createContext-BqYzHhY9.mjs → createContext-tApLtII-.mjs} +6 -3
  23. package/dist/dashboard/analyze.d.mts +1 -1
  24. package/dist/dashboard/analyze.mjs +3 -1
  25. package/dist/dashboard/vite.d.mts +1 -1
  26. package/dist/dashboard.d.mts +2 -2
  27. package/dist/dashboard.mjs +1749 -1
  28. package/dist/dashboardTransport-C_Y6jMp-.mjs +16 -0
  29. package/dist/{dashboardViteBridge-Dy3nAD4m.mjs → dashboardViteBridge-DCGR43aM.mjs} +8 -5
  30. package/dist/{dev-fR5GiJRO.mjs → dev-C2fgr_Xd.mjs} +5 -1
  31. package/dist/devProvider-D-hTfsEO.mjs +3027 -0
  32. package/dist/docs/README.md +8 -2
  33. package/dist/docs/mcp.md +10 -0
  34. package/dist/docs/troubleshooting.md +8 -0
  35. package/dist/docs/vue-sfc.md +25 -2
  36. package/dist/doctor-worker.mjs +3 -2
  37. package/dist/doctor.d.mts +2 -2
  38. package/dist/doctor.mjs +15 -13
  39. package/dist/engine-C66J0HLz.mjs +54 -0
  40. package/dist/{file-sC3jD7Fh.mjs → file-CcIOmqhC.mjs} +47 -19
  41. package/dist/file-DtcteQ4G.mjs +1 -0
  42. package/dist/forwardConsole-B0Reo8Lf.mjs +511 -0
  43. package/dist/getInstance-BAIaU2y9.mjs +1 -0
  44. package/dist/{getInstance-DiGSzBNI.mjs → getInstance-Dt9IQDKr.mjs} +1 -1
  45. package/dist/history-BIiRCzbq.mjs +784 -0
  46. package/dist/i18n.d.mts +1 -1
  47. package/dist/{index-C9HjUX5c.d.mts → index-D5rgBzYZ.d.mts} +1 -2
  48. package/dist/index.d.mts +3 -3
  49. package/dist/index.mjs +2 -2
  50. package/dist/json.d.mts +1 -1
  51. package/dist/lib-DjccSI1B.mjs +143 -0
  52. package/dist/{lifecycle-BROTlwSL.mjs → lifecycle-C36WSbQS.mjs} +120 -27
  53. package/dist/{loadConfig-C3BQhz7F.mjs → loadConfig-BWIsDXR4.mjs} +1 -1
  54. package/dist/loadConfig-D-BpBgsk.mjs +1 -0
  55. package/dist/logBuildAppFinish-ChjwATMv.mjs +57 -0
  56. package/dist/mcp-CYgX9HpO.mjs +86 -0
  57. package/dist/mcp.d.mts +1 -1
  58. package/dist/mcpClient-DVLvFLZv.mjs +287 -0
  59. package/dist/{processCleanup-B6KA30Zc.mjs → metadata-hwF7QRcS.mjs} +1 -19
  60. package/dist/nodeEnv-BmH8UZPR.mjs +7 -0
  61. package/dist/openIde-CroqOgk5.mjs +648 -0
  62. package/dist/options-jqFwfD1G.mjs +34 -0
  63. package/dist/package-Cmakyy3J.mjs +4 -0
  64. package/dist/path-CYYIQGS7.mjs +44 -0
  65. package/dist/processCleanup-BQn2kTcK.mjs +19 -0
  66. package/dist/{protocol-vg8HGJ4n.mjs → protocol-Cg6Jdlvb.mjs} +42 -39
  67. package/dist/reader-sh_POQ9-.mjs +93 -0
  68. package/dist/realpathScope-Tf9mz-fh.mjs +23 -0
  69. package/dist/report-hyonPGbZ.mjs +107 -0
  70. package/dist/{path-doV773b7.mjs → resolvedId-CiDl7SC1.mjs} +3 -46
  71. package/dist/runtime-CLUhQsdA.mjs +43 -0
  72. package/dist/{runtime-Ee2HY6gR.d.mts → runtime-DpVf714f.d.mts} +1 -1
  73. package/dist/runtime.d.mts +1 -1
  74. package/dist/schematics-kO26eQRT.mjs +91 -0
  75. package/dist/{session-PskhD-nZ.mjs → session-D3zsdzIy.mjs} +71 -9
  76. package/dist/test.mjs +10 -8
  77. package/dist/{types-CgZn5X6j.d.mts → types-D-kfuyVa.d.mts} +1 -2
  78. package/dist/types-D0FFexRF.d.mts +39 -0
  79. package/dist/types.d.mts +2 -2
  80. package/dist/{upload-D4msblBf.mjs → upload-DozK8UdN.mjs} +109 -5
  81. package/dist/upload-worker.mjs +1 -1
  82. package/dist/{utils-CJSCgEj6.mjs → utils-Dy51PYAC.mjs} +56 -116
  83. package/dist/vite.d.mts +1 -1
  84. package/dist/vite.mjs +51 -12
  85. package/dist/wxs-BT8btflA.mjs +112 -0
  86. package/dist/wxs-Z4VQDeJ_.mjs +1 -0
  87. package/package.json +52 -46
  88. package/dist/dashboard-DvqF3Key.mjs +0 -1842
  89. package/dist/devProvider-BGBkw28J.mjs +0 -1050
  90. package/dist/file-DRb4eWqw.mjs +0 -1
  91. package/dist/getInstance-SiE6WZRh.mjs +0 -1
  92. package/dist/loadConfig-VGtBF4qm.mjs +0 -1
  93. package/dist/mcp-D3Yh24Cj.mjs +0 -529
@@ -0,0 +1,44 @@
1
+ import path from "pathe";
2
+ import { normalize } from "node:path";
3
+ //#region src/utils/path.ts
4
+ const BACKSLASH_RE = /\\/g;
5
+ const LEADING_SLASH_RE = /^[\\/]+/;
6
+ const DUPLICATE_SLASH_RE = /\/{2,}/g;
7
+ const TRIM_SLASH_RE = /^\/+|\/+$/g;
8
+ const WINDOWS_DEVICE_RE = /^\\\\\?\\/;
9
+ const WINDOWS_UNC_PREFIX = /^\\\\\?\\UNC\\/;
10
+ function stripWindowsDevicePath(value) {
11
+ if (WINDOWS_UNC_PREFIX.test(value)) return `\\\\${value.slice(8)}`;
12
+ if (WINDOWS_DEVICE_RE.test(value)) return value.slice(4);
13
+ return value;
14
+ }
15
+ function toPosixPath(value) {
16
+ return value.replace(BACKSLASH_RE, "/");
17
+ }
18
+ function normalizePath(value) {
19
+ if (!value) return value;
20
+ const cleaned = stripWindowsDevicePath(value);
21
+ return toPosixPath(path.normalize(cleaned));
22
+ }
23
+ function normalizeRelativePath(value) {
24
+ if (value === "") return value;
25
+ return normalizePath(value);
26
+ }
27
+ function normalizeWatchPath(value) {
28
+ if (!value) return value;
29
+ const posix = toPosixPath(stripWindowsDevicePath(value));
30
+ return toPosixPath(normalize(posix));
31
+ }
32
+ function stripLeadingSlashes(value) {
33
+ return value.replace(LEADING_SLASH_RE, "");
34
+ }
35
+ function normalizeRoot(root) {
36
+ return toPosixPath(root).replace(DUPLICATE_SLASH_RE, "/").replace(TRIM_SLASH_RE, "");
37
+ }
38
+ function isPathInside(parent, target) {
39
+ if (!parent) return false;
40
+ const relative = path.relative(normalizePath(parent), normalizePath(target));
41
+ return relative === "" || relative !== ".." && !relative.startsWith("../") && !path.isAbsolute(relative);
42
+ }
43
+ //#endregion
44
+ export { normalizeWatchPath as a, normalizeRoot as i, normalizePath as n, stripLeadingSlashes as o, normalizeRelativePath as r, toPosixPath as s, isPathInside as t };
@@ -0,0 +1,19 @@
1
+ import process from "node:process";
2
+ //#region src/cli/processCleanup.ts
3
+ function isSassEmbeddedChild(handle) {
4
+ if (!handle || typeof handle !== "object") return false;
5
+ const child = handle;
6
+ const spawnfile = typeof child.spawnfile === "string" ? child.spawnfile : "";
7
+ const spawnargs = Array.isArray(child.spawnargs) ? child.spawnargs : [];
8
+ return Boolean("kill" in handle && "spawnfile" in handle && (spawnfile.includes("sass-embedded") || spawnfile.includes("dart-sass") && spawnargs.includes("--embedded")));
9
+ }
10
+ function terminateStaleSassEmbeddedProcess() {
11
+ const getHandles = process._getActiveHandles;
12
+ const handles = typeof getHandles === "function" ? getHandles() : void 0;
13
+ if (!Array.isArray(handles)) return;
14
+ for (const handle of handles) if (isSassEmbeddedChild(handle)) try {
15
+ handle.kill();
16
+ } catch {}
17
+ }
18
+ //#endregion
19
+ export { terminateStaleSassEmbeddedProcess as t };
@@ -1,27 +1,6 @@
1
- import path from "pathe";
2
- import { realpathSync } from "node:fs";
1
+ import { t as resolveRealpath } from "./realpathScope-Tf9mz-fh.mjs";
3
2
  import { WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX, WEAPP_VITE_LOGICAL_ENTRY_VIRTUAL_PREFIX, WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER, WEAPP_VITE_SIDECAR_QUERY_MARKER, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX, WEAPP_VITE_SIDECAR_VIRTUAL_PREFIX } from "@weapp-core/constants";
4
- //#region src/utils/realpathScope.ts
5
- let activePaths;
6
- /** 仅在同步图遍历中复用成功的真实路径解析;不跨事件、构建或异步边界保留。 */
7
- function withRealpathScope(read) {
8
- const previous = activePaths;
9
- activePaths ??= /* @__PURE__ */ new Map();
10
- try {
11
- return read();
12
- } finally {
13
- activePaths = previous;
14
- }
15
- }
16
- /** 失败保持原始异常语义,避免缺失文件在随后创建后仍命中失败缓存。 */
17
- function resolveRealpath(file) {
18
- const cached = activePaths?.get(file);
19
- if (cached !== void 0) return cached;
20
- const resolved = realpathSync.native(file);
21
- activePaths?.set(file, resolved);
22
- return resolved;
23
- }
24
- //#endregion
3
+ import path from "pathe";
25
4
  //#region src/moduleGraph/protocol.ts
26
5
  const VIRTUAL_MODULE_SUFFIX = ":module.js";
27
6
  const SIDECAR_SOURCE_JS_SUFFIX = "&lang.js";
@@ -35,8 +14,14 @@ function normalizeProtocolPath(id) {
35
14
  return normalized;
36
15
  }
37
16
  }
38
- function encodePath(id) {
39
- return encodeURIComponent(normalizeProtocolPath(id));
17
+ function normalizeSidecarRequest(ownerId, sourceId, kind, dependencyOnly) {
18
+ const owner = normalizeProtocolPath(ownerId);
19
+ return {
20
+ kind,
21
+ ownerId: owner,
22
+ sourceId: sourceId === ownerId ? owner : normalizeProtocolPath(sourceId),
23
+ ...dependencyOnly ? { dependencyOnly } : {}
24
+ };
40
25
  }
41
26
  function decodePath(id) {
42
27
  return normalizeProtocolPath(decodeURIComponent(id));
@@ -45,8 +30,14 @@ function resolveProtocolPrefix(id, virtualPrefix, resolvedPrefix) {
45
30
  if (id.startsWith(resolvedPrefix)) return id.slice(resolvedPrefix.length);
46
31
  if (id.startsWith(virtualPrefix)) return id.slice(virtualPrefix.length);
47
32
  }
33
+ function serializeLogicalEntry(request, prefix) {
34
+ return `${prefix}${request.type}:${encodeURIComponent(request.sourceId)}${VIRTUAL_MODULE_SUFFIX}`;
35
+ }
48
36
  function createLogicalEntryId(sourceId, type) {
49
- return `${WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX}${type}:${encodePath(sourceId)}${VIRTUAL_MODULE_SUFFIX}`;
37
+ return serializeLogicalEntry({
38
+ sourceId: normalizeProtocolPath(sourceId),
39
+ type
40
+ }, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX);
50
41
  }
51
42
  function parseLogicalEntryId(id) {
52
43
  const request = resolveProtocolPrefix(id, WEAPP_VITE_LOGICAL_ENTRY_VIRTUAL_PREFIX, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX);
@@ -67,8 +58,11 @@ function parseLogicalEntryId(id) {
67
58
  type
68
59
  };
69
60
  }
61
+ function serializeSidecarModule(request, prefix) {
62
+ return `${prefix}${request.kind}:${encodeURIComponent(request.ownerId)}:${encodeURIComponent(request.sourceId)}${VIRTUAL_MODULE_SUFFIX}`;
63
+ }
70
64
  function createSidecarModuleId(ownerId, sourceId, kind) {
71
- return `${WEAPP_VITE_SIDECAR_RESOLVED_PREFIX}${kind}:${encodePath(ownerId)}:${encodePath(sourceId)}${VIRTUAL_MODULE_SUFFIX}`;
65
+ return serializeSidecarModule(normalizeSidecarRequest(ownerId, sourceId, kind), WEAPP_VITE_SIDECAR_RESOLVED_PREFIX);
72
66
  }
73
67
  function parseSidecarModuleId(id) {
74
68
  const request = resolveProtocolPrefix(id, WEAPP_VITE_SIDECAR_VIRTUAL_PREFIX, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX);
@@ -85,19 +79,16 @@ function parseSidecarModuleId(id) {
85
79
  "using-component",
86
80
  "wxs"
87
81
  ].includes(kind)) return;
88
- return {
89
- kind,
90
- ownerId: decodePath(ownerId),
91
- sourceId: decodePath(sourceId)
92
- };
82
+ return normalizeSidecarRequest(decodeURIComponent(ownerId), decodeURIComponent(sourceId), kind);
93
83
  }
94
84
  function createSidecarSourceSpecifier(ownerId, sourceId, kind, dependencyOnly = false) {
95
85
  const emitsStyle = kind === "style" && !dependencyOnly;
96
86
  const queryPrefix = emitsStyle ? "?" : "?raw&";
97
87
  const suffix = emitsStyle ? SIDECAR_SOURCE_STYLE_SUFFIX : SIDECAR_SOURCE_JS_SUFFIX;
98
- return `${normalizeProtocolPath(sourceId)}${queryPrefix}${WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER}=${encodePath(ownerId)}&${WEAPP_VITE_SIDECAR_QUERY_MARKER}=${kind}${suffix}`;
88
+ const normalized = normalizeSidecarRequest(ownerId, sourceId, kind);
89
+ return `${normalized.sourceId}${queryPrefix}${WEAPP_VITE_SIDECAR_OWNER_QUERY_MARKER}=${encodeURIComponent(normalized.ownerId)}&${WEAPP_VITE_SIDECAR_QUERY_MARKER}=${kind}${suffix}`;
99
90
  }
100
- function parseSidecarSourceRequest(id) {
91
+ function readSidecarSourceRequest(id) {
101
92
  const queryIndex = id.indexOf("?");
102
93
  if (queryIndex < 0) return;
103
94
  const query = new URLSearchParams(id.slice(queryIndex + 1));
@@ -123,16 +114,28 @@ function parseSidecarSourceRequest(id) {
123
114
  if (!hasExpectedLang || hasUnexpectedLang || !hasExpectedRawMode) return;
124
115
  return {
125
116
  kind,
126
- ownerId: normalizeProtocolPath(ownerId),
127
- sourceId: normalizeProtocolPath(id.slice(0, queryIndex)),
117
+ ownerId,
118
+ sourceId: id.slice(0, queryIndex),
128
119
  ...dependencyOnly ? { dependencyOnly: true } : {}
129
120
  };
130
121
  }
122
+ function parseSidecarSourceRequest(id) {
123
+ const request = readSidecarSourceRequest(id);
124
+ if (request) return normalizeSidecarRequest(request.ownerId, request.sourceId, request.kind, request.dependencyOnly);
125
+ }
126
+ /** 仅校验协议及交付类型;需要文件身份的图操作仍使用完整路径解析。 */
127
+ function parseSidecarSourceMetadata(id) {
128
+ const request = readSidecarSourceRequest(id);
129
+ if (request) return {
130
+ kind: request.kind,
131
+ ...request.dependencyOnly ? { dependencyOnly: true } : {}
132
+ };
133
+ }
131
134
  function resolveVirtualModuleId(id) {
132
135
  const logicalEntry = parseLogicalEntryId(id);
133
- if (logicalEntry) return createLogicalEntryId(logicalEntry.sourceId, logicalEntry.type);
136
+ if (logicalEntry) return serializeLogicalEntry(logicalEntry, WEAPP_VITE_LOGICAL_ENTRY_RESOLVED_PREFIX);
134
137
  const sidecar = parseSidecarModuleId(id);
135
- if (sidecar) return createSidecarModuleId(sidecar.ownerId, sidecar.sourceId, sidecar.kind);
138
+ if (sidecar) return serializeSidecarModule(sidecar, WEAPP_VITE_SIDECAR_RESOLVED_PREFIX);
136
139
  }
137
140
  //#endregion
138
- export { parseSidecarModuleId as a, resolveRealpath as c, parseLogicalEntryId as i, withRealpathScope as l, createSidecarModuleId as n, parseSidecarSourceRequest as o, createSidecarSourceSpecifier as r, resolveVirtualModuleId as s, createLogicalEntryId as t };
141
+ export { parseSidecarModuleId as a, resolveVirtualModuleId as c, parseLogicalEntryId as i, createSidecarModuleId as n, parseSidecarSourceMetadata as o, createSidecarSourceSpecifier as r, parseSidecarSourceRequest as s, createLogicalEntryId as t };
@@ -0,0 +1,93 @@
1
+ //#region src/analyze/hmr/reader.ts
2
+ const stringFields = [
3
+ "timestamp",
4
+ "eventId",
5
+ "event",
6
+ "file",
7
+ "relativeFile",
8
+ "sourceRootFile",
9
+ "sessionId",
10
+ "buildId",
11
+ "batchId"
12
+ ];
13
+ const collectionFields = ["dirtyReasonSummary", "pendingReasonSummary"];
14
+ function isSourceEvent(value) {
15
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
16
+ const event = value;
17
+ return typeof event.eventId === "string" && (event.file === void 0 || typeof event.file === "string") && (event.event === void 0 || typeof event.event === "string" && [
18
+ "update",
19
+ "create",
20
+ "delete"
21
+ ].includes(event.event)) && typeof event.receivedAtMs === "number" && Number.isFinite(event.receivedAtMs) && event.receivedAtMs >= 0;
22
+ }
23
+ function isSample(value) {
24
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
25
+ const sample = value;
26
+ for (const [key, values] of Object.entries({
27
+ pipeline: ["standard", "stateful"],
28
+ profileMode: [
29
+ "delivery",
30
+ "full",
31
+ "refresh"
32
+ ],
33
+ completionBoundary: ["delivery-acknowledged", "output-published"]
34
+ })) if (sample[key] !== void 0 && (typeof sample[key] !== "string" || !values.includes(sample[key]))) return false;
35
+ if (typeof sample.totalMs !== "number" || !Number.isFinite(sample.totalMs) || sample.totalMs < 0) return false;
36
+ if (stringFields.some((key) => sample[key] !== void 0 && typeof sample[key] !== "string")) return false;
37
+ if (collectionFields.some((key) => {
38
+ const items = sample[key];
39
+ return items !== void 0 && (!Array.isArray(items) || items.some((item) => typeof item !== "string"));
40
+ })) return false;
41
+ if (sample.sourceEvents !== void 0 && (!Array.isArray(sample.sourceEvents) || !sample.sourceEvents.every(isSourceEvent))) return false;
42
+ return Object.entries(sample).every(([key, value]) => {
43
+ if (!key.endsWith("Ms") && !key.endsWith("Count")) return true;
44
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && (!key.endsWith("Count") || Number.isInteger(value));
45
+ });
46
+ }
47
+ /** 旧版仍可读取;不兼容、失败和未完成记录不参与正常耗时统计,缺失阶段不补零。 */
48
+ function readHmrProfileLines(content) {
49
+ const samples = [];
50
+ const coverage = {
51
+ legacy: 0,
52
+ compatible: 0,
53
+ incompatible: 0,
54
+ incomplete: 0,
55
+ invalid: 0
56
+ };
57
+ for (const line of content.split(/\r?\n/)) {
58
+ if (!line.trim()) continue;
59
+ let value;
60
+ try {
61
+ value = JSON.parse(line);
62
+ } catch {
63
+ coverage.invalid += 1;
64
+ continue;
65
+ }
66
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
67
+ coverage.invalid += 1;
68
+ continue;
69
+ }
70
+ const record = value;
71
+ if (record.schemaVersion !== void 0 && record.schemaVersion !== 1) {
72
+ coverage.incompatible += 1;
73
+ continue;
74
+ }
75
+ if (record.status === "incomplete" || record.status === "failed") {
76
+ coverage.incomplete += 1;
77
+ continue;
78
+ }
79
+ if (record.status !== void 0 && record.status !== "complete" || record.schemaVersion === 1 && record.status !== "complete" || !isSample(record)) {
80
+ coverage.invalid += 1;
81
+ continue;
82
+ }
83
+ coverage[record.schemaVersion === void 0 ? "legacy" : "compatible"] += 1;
84
+ samples.push(record);
85
+ }
86
+ return {
87
+ samples,
88
+ coverage,
89
+ skippedLineCount: coverage.incompatible + coverage.incomplete + coverage.invalid
90
+ };
91
+ }
92
+ //#endregion
93
+ export { readHmrProfileLines as t };
@@ -0,0 +1,23 @@
1
+ import { realpathSync } from "node:fs";
2
+ //#region src/utils/realpathScope.ts
3
+ let activePaths;
4
+ /** 仅在同步图遍历中复用成功的真实路径解析;不跨事件、构建或异步边界保留。 */
5
+ function withRealpathScope(read) {
6
+ const previous = activePaths;
7
+ activePaths ??= /* @__PURE__ */ new Map();
8
+ try {
9
+ return read();
10
+ } finally {
11
+ activePaths = previous;
12
+ }
13
+ }
14
+ /** 失败保持原始异常语义,避免缺失文件在随后创建后仍命中失败缓存。 */
15
+ function resolveRealpath(file) {
16
+ const cached = activePaths?.get(file);
17
+ if (cached !== void 0) return cached;
18
+ const resolved = realpathSync.native(file);
19
+ activePaths?.set(file, resolved);
20
+ return resolved;
21
+ }
22
+ //#endregion
23
+ export { withRealpathScope as n, resolveRealpath as t };
@@ -0,0 +1,107 @@
1
+ import process from "node:process";
2
+ import { parseArgs } from "node:util";
3
+ //#region src/cli/upload/options.ts
4
+ function readUploadMetadata(cli) {
5
+ for (const name of [
6
+ "uv",
7
+ "desc",
8
+ "bump"
9
+ ]) {
10
+ const value = cli.options[name];
11
+ if (typeof value === "boolean" || Array.isArray(value) && value.some((item) => typeof item === "boolean")) throw new Error(`--${name} 需要指定字符串参数。`);
12
+ }
13
+ const { values } = parseArgs({
14
+ args: cli.rawArgs.slice(2),
15
+ allowPositionals: true,
16
+ strict: false,
17
+ options: {
18
+ uv: { type: "string" },
19
+ desc: { type: "string" },
20
+ bump: { type: "string" }
21
+ }
22
+ });
23
+ return {
24
+ uv: typeof values.uv === "string" ? values.uv : void 0,
25
+ desc: typeof values.desc === "string" ? values.desc : void 0,
26
+ bump: typeof values.bump === "string" ? values.bump : void 0
27
+ };
28
+ }
29
+ /** 超时只约束单个平台的 SDK 进程,不含构建;未指定时不改变原有等待行为。 */
30
+ function resolveUploadTimeout(value) {
31
+ if (value === void 0) return;
32
+ const seconds = typeof value === "number" ? value : Number(value);
33
+ const milliseconds = Math.round(seconds * 1e3);
34
+ if (typeof value !== "string" && typeof value !== "number" || !Number.isFinite(milliseconds) || milliseconds / 1e3 !== seconds || milliseconds <= 0 || milliseconds > 2147483647) throw new Error("--timeout 必须为正数秒,精度不超过毫秒且不能超过 2147483.647 秒。");
35
+ return milliseconds;
36
+ }
37
+ /** 普通构建不读取上传元数据;上传必须是显式的一次性构建操作。 */
38
+ function resolveBuildUploadOptions(cli, options) {
39
+ if (options.upload !== true) {
40
+ if (options.uv !== void 0 || options.desc !== void 0 || options.bump !== void 0 || options.gitDesc !== void 0 || options.dryRun !== void 0) throw new Error("--uv、--desc、--bump、--git-desc 和 --dry-run 仅能与 --upload 一起使用。");
41
+ return;
42
+ }
43
+ if (options.watch) throw new Error("--upload 不能与 --watch 一起使用,请执行一次性构建。");
44
+ return {
45
+ ...options,
46
+ ...readUploadMetadata(cli)
47
+ };
48
+ }
49
+ //#endregion
50
+ //#region src/cli/upload/report.ts
51
+ var UploadCommandError = class extends Error {
52
+ report;
53
+ constructor(report) {
54
+ super(report.error);
55
+ this.report = report;
56
+ this.name = "UploadCommandError";
57
+ }
58
+ };
59
+ function createFailedUploadReport(error) {
60
+ return {
61
+ schemaVersion: 1,
62
+ action: "upload",
63
+ status: "failed",
64
+ results: [],
65
+ error: error instanceof Error ? error.message : String(error)
66
+ };
67
+ }
68
+ function printUploadProgress(platform, event) {
69
+ const percent = event.percent === void 0 ? "" : ` ${event.percent}%`;
70
+ process.stderr.write(`[upload:${platform}] ${event.type}${percent}${event.message ? ` ${event.message}` : ""}\n`);
71
+ }
72
+ function printUploadSummary(report) {
73
+ const labels = {
74
+ "success": "上传成功",
75
+ "failed": "失败",
76
+ "not-run": "未执行",
77
+ "dry-run": "仅构建",
78
+ "unknown": "远端结果未确认"
79
+ };
80
+ for (const item of report.results) process.stderr.write(`[upload:${item.platform ?? "配置平台"}] ${labels[item.status]}${item.requestedVersion ? ` ${item.requestedVersion}` : ""} (${item.stage})\n`);
81
+ }
82
+ /** JSON 模式独占 stdout,构建配置及第三方工具的普通日志只进入 stderr。 */
83
+ async function outputUploadReport(json, run) {
84
+ const stdoutWrite = process.stdout.write;
85
+ if (json) process.stdout.write = process.stderr.write.bind(process.stderr);
86
+ try {
87
+ let report;
88
+ try {
89
+ report = await run();
90
+ } catch (error) {
91
+ report = error instanceof UploadCommandError ? error.report : createFailedUploadReport(error);
92
+ }
93
+ if (json) {
94
+ await new Promise((resolve, reject) => {
95
+ stdoutWrite.call(process.stdout, `${JSON.stringify(report)}\n`, "utf8", (error) => error ? reject(error) : resolve());
96
+ });
97
+ if (report.status === "failed") process.exitCode = 1;
98
+ } else {
99
+ printUploadSummary(report);
100
+ if (report.status === "failed") throw new UploadCommandError(report);
101
+ }
102
+ } finally {
103
+ process.stdout.write = stdoutWrite;
104
+ }
105
+ }
106
+ //#endregion
107
+ export { resolveBuildUploadOptions as a, readUploadMetadata as i, outputUploadReport as n, resolveUploadTimeout as o, printUploadProgress as r, UploadCommandError as t };
@@ -1,9 +1,7 @@
1
- import path from "pathe";
2
1
  import { fileURLToPath } from "node:url";
3
- import { normalize } from "node:path";
4
2
  //#region src/utils/viteId.ts
5
3
  const VUE_VIRTUAL_MODULE_PREFIX = "\0vue:";
6
- const BACKSLASH_RE$1 = /\\/g;
4
+ const BACKSLASH_RE = /\\/g;
7
5
  const WINDOWS_VITE_AT_FS_DRIVE_RE = /^\/[A-Z]:\//i;
8
6
  function stripViteAtFsPrefix(id) {
9
7
  if (!id.startsWith("/@fs/")) return id;
@@ -29,7 +27,7 @@ function normalizeViteId(id, options) {
29
27
  }
30
28
  if (stripAtFsPrefix) clean = stripViteAtFsPrefix(clean);
31
29
  if (stripLeadingNullByte && clean.startsWith("\0")) clean = clean.slice(1);
32
- if (clean.includes("\\")) clean = clean.replace(BACKSLASH_RE$1, "/");
30
+ if (clean.includes("\\")) clean = clean.replace(BACKSLASH_RE, "/");
33
31
  return clean;
34
32
  }
35
33
  //#endregion
@@ -59,45 +57,4 @@ function normalizeFsResolvedId(id, options) {
59
57
  return normalizeViteId(id, resolveFsResolvedIdNormalizeOptions(options));
60
58
  }
61
59
  //#endregion
62
- //#region src/utils/path.ts
63
- const BACKSLASH_RE = /\\/g;
64
- const LEADING_SLASH_RE = /^[\\/]+/;
65
- const DUPLICATE_SLASH_RE = /\/{2,}/g;
66
- const TRIM_SLASH_RE = /^\/+|\/+$/g;
67
- const WINDOWS_DEVICE_RE = /^\\\\\?\\/;
68
- const WINDOWS_UNC_PREFIX = /^\\\\\?\\UNC\\/;
69
- function stripWindowsDevicePath(value) {
70
- if (WINDOWS_UNC_PREFIX.test(value)) return `\\\\${value.slice(8)}`;
71
- if (WINDOWS_DEVICE_RE.test(value)) return value.slice(4);
72
- return value;
73
- }
74
- function toPosixPath(value) {
75
- return value.replace(BACKSLASH_RE, "/");
76
- }
77
- function normalizePath(value) {
78
- if (!value) return value;
79
- const cleaned = stripWindowsDevicePath(value);
80
- return toPosixPath(path.normalize(cleaned));
81
- }
82
- function normalizeRelativePath(value) {
83
- if (value === "") return value;
84
- return normalizePath(value);
85
- }
86
- function normalizeWatchPath(value) {
87
- if (!value) return value;
88
- const posix = toPosixPath(stripWindowsDevicePath(value));
89
- return toPosixPath(normalize(posix));
90
- }
91
- function stripLeadingSlashes(value) {
92
- return value.replace(LEADING_SLASH_RE, "");
93
- }
94
- function normalizeRoot(root) {
95
- return toPosixPath(root).replace(DUPLICATE_SLASH_RE, "/").replace(TRIM_SLASH_RE, "");
96
- }
97
- function isPathInside(parent, target) {
98
- if (!parent) return false;
99
- const relative = path.relative(parent, target);
100
- return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
101
- }
102
- //#endregion
103
- export { normalizeWatchPath as a, isSkippableResolvedId as c, normalizeRoot as i, normalizeFsResolvedId as l, normalizePath as n, stripLeadingSlashes as o, normalizeRelativePath as r, toPosixPath as s, isPathInside as t, normalizeViteId as u };
60
+ export { normalizeFsResolvedId as n, normalizeViteId as r, isSkippableResolvedId as t };
@@ -0,0 +1,43 @@
1
+ import { l as resolveBackendExecution } from "./createCompilerContextInstance-aYwi8wQt.mjs";
2
+ import { r as logger_default, t as colors } from "./logger-DGn5iEVN.mjs";
3
+ import { defu } from "@weapp-core/shared";
4
+ //#region src/cli/runtime.ts
5
+ function logRuntimeTarget(targets, options = {}) {
6
+ if (options.silent) return;
7
+ if (targets.label === "config") {
8
+ const resolvedPlatform = targets.platform ?? options.resolvedConfigPlatform;
9
+ if (resolvedPlatform) {
10
+ logger_default.info(`目标平台:${colors.green(resolvedPlatform)}`);
11
+ return;
12
+ }
13
+ logger_default.info(`目标平台:使用配置文件中的 ${colors.bold(colors.green("weapp.platform"))}`);
14
+ return;
15
+ }
16
+ logger_default.info(`目标平台:${colors.green(targets.label)}`);
17
+ }
18
+ function resolveRuntimeTargets(options) {
19
+ const rawPlatform = typeof options.platform === "string" ? options.platform : typeof options.p === "string" ? options.p : void 0;
20
+ const execution = resolveBackendExecution(rawPlatform, { warn: (message) => logger_default.warn(message) });
21
+ const miniBackend = execution.get("miniprogram");
22
+ return {
23
+ ...execution,
24
+ platform: miniBackend?.platform,
25
+ rawPlatform
26
+ };
27
+ }
28
+ function resolveConfiguredRuntimeTargets(targets, platform) {
29
+ return targets.rawPlatform === void 0 && platform === "web" ? resolveRuntimeTargets({ platform: "web" }) : targets;
30
+ }
31
+ function createInlineConfig(execution, options = {}) {
32
+ const configs = execution.entries.map((entry) => entry.driver.createInlineConfig({
33
+ execution,
34
+ platform: entry.platform,
35
+ scope: options.scope,
36
+ host: options.host
37
+ })).filter((config) => Boolean(config));
38
+ if (configs.length === 0) return options.inlineConfig;
39
+ const merged = configs.slice(1).reduce((merged, config) => defu(merged, config), configs[0]);
40
+ return options.inlineConfig ? defu(options.inlineConfig, merged) : merged;
41
+ }
42
+ //#endregion
43
+ export { resolveRuntimeTargets as i, logRuntimeTarget as n, resolveConfiguredRuntimeTargets as r, createInlineConfig as t };
@@ -1,4 +1,4 @@
1
- import { ComputedDefinitions, MethodDefinitions, WevuPageLayoutMap } from "wevu";
1
+ import { ComputedDefinitions, MethodDefinitions, WevuPageLayoutMap } from "wevu/types";
2
2
  //#region src/plugins/vue/createWevuComponent.d.ts
3
3
  interface WevuComponentOptions<D extends object = Record<string, any>, C extends ComputedDefinitions = ComputedDefinitions, M extends MethodDefinitions = MethodDefinitions> {
4
4
  data?: () => D;
@@ -1,2 +1,2 @@
1
- import { a as LayoutHostContext, c as LayoutHostResolver, d as unregisterLayoutHosts, f as waitForLayoutHost, i as LayoutHostBridge, l as registerLayoutHosts, m as createWevuComponent, n as defineProps, o as LayoutHostEntry, p as WevuComponentOptions, r as setPageLayout, s as LayoutHostResolveOptions, t as defineEmits, u as resolveLayoutHost } from "./runtime-Ee2HY6gR.mjs";
1
+ import { a as LayoutHostContext, c as LayoutHostResolver, d as unregisterLayoutHosts, f as waitForLayoutHost, i as LayoutHostBridge, l as registerLayoutHosts, m as createWevuComponent, n as defineProps, o as LayoutHostEntry, p as WevuComponentOptions, r as setPageLayout, s as LayoutHostResolveOptions, t as defineEmits, u as resolveLayoutHost } from "./runtime-DpVf714f.mjs";
2
2
  export { type LayoutHostBridge, type LayoutHostContext, type LayoutHostEntry, type LayoutHostResolveOptions, type LayoutHostResolver, type WevuComponentOptions, createWevuComponent, defineEmits, defineProps, registerLayoutHosts, resolveLayoutHost, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
@@ -0,0 +1,91 @@
1
+ import { r as logger_default } from "./logger-DGn5iEVN.mjs";
2
+ import process from "node:process";
3
+ import path from "pathe";
4
+ import { defu } from "@weapp-core/shared";
5
+ import { fs } from "@weapp-core/shared/fs";
6
+ import { generateJs, generateJson, generateWxml, generateWxss } from "@weapp-core/schematics";
7
+ //#region src/schematics.ts
8
+ function composePath(outDir, filename) {
9
+ return `${outDir}${outDir ? "/" : ""}${filename}`;
10
+ }
11
+ const defaultExtensions = {
12
+ js: "js",
13
+ json: "json",
14
+ wxml: "wxml",
15
+ wxss: "wxss"
16
+ };
17
+ function resolveExtension(extension) {
18
+ return extension ? extension.startsWith(".") ? extension : `.${extension}` : "";
19
+ }
20
+ async function readTemplateFile(templatePath, context) {
21
+ const absolutePath = path.isAbsolute(templatePath) ? templatePath : path.resolve(context.cwd, templatePath);
22
+ return fs.readFile(absolutePath, "utf8");
23
+ }
24
+ async function loadTemplate(template, context) {
25
+ if (template === void 0) return;
26
+ if (typeof template === "function") {
27
+ const result = await template(context);
28
+ return result == null ? void 0 : String(result);
29
+ }
30
+ if (typeof template === "string") return readTemplateFile(template, context);
31
+ if ("content" in template && typeof template.content === "string") return template.content;
32
+ if ("path" in template && typeof template.path === "string") return readTemplateFile(template.path, context);
33
+ }
34
+ function resolveTemplate(templates, type, fileType) {
35
+ const scoped = templates?.[type]?.[fileType];
36
+ if (scoped !== void 0) return scoped;
37
+ return templates?.shared?.[fileType];
38
+ }
39
+ async function generate(options) {
40
+ let { fileName, outDir, extensions, type, cwd, templates } = defu(options, {
41
+ type: "component",
42
+ extensions: { ...defaultExtensions },
43
+ cwd: process.cwd(),
44
+ templates: void 0
45
+ });
46
+ if (fileName === void 0) fileName = path.basename(outDir);
47
+ const basepath = path.resolve(cwd, outDir);
48
+ const targetFileTypes = type === "app" ? [
49
+ "js",
50
+ "wxss",
51
+ "json"
52
+ ] : [
53
+ "js",
54
+ "wxss",
55
+ "json",
56
+ "wxml"
57
+ ];
58
+ const files = [];
59
+ for (const fileType of targetFileTypes) {
60
+ const configuredExt = extensions[fileType] ?? defaultExtensions[fileType];
61
+ let resolvedExt = configuredExt;
62
+ let defaultCode;
63
+ if (fileType === "js") defaultCode = generateJs(type);
64
+ else if (fileType === "wxss") defaultCode = generateWxss();
65
+ else if (fileType === "wxml") defaultCode = generateWxml(path.join(outDir, fileName));
66
+ else if (fileType === "json") {
67
+ defaultCode = generateJson(type, configuredExt);
68
+ if (configuredExt === "js" || configuredExt === "ts") resolvedExt = `json.${configuredExt}`;
69
+ }
70
+ const context = {
71
+ type,
72
+ fileType,
73
+ fileName,
74
+ outDir,
75
+ extension: resolvedExt,
76
+ cwd,
77
+ defaultCode
78
+ };
79
+ const finalCode = await loadTemplate(resolveTemplate(templates, type, fileType), context) ?? defaultCode;
80
+ if (finalCode !== void 0) files.push({
81
+ fileName: `${fileName}${resolveExtension(resolvedExt)}`,
82
+ code: finalCode
83
+ });
84
+ }
85
+ for (const { code, fileName } of files) if (code !== void 0) {
86
+ await fs.outputFile(path.resolve(basepath, fileName), code, "utf8");
87
+ logger_default.success(`${composePath(outDir, fileName)} 创建成功!`);
88
+ }
89
+ }
90
+ //#endregion
91
+ export { generate };