weapp-vite 7.5.0 → 7.7.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 (135) hide show
  1. package/README.md +14 -6
  2. package/THIRD_PARTY_NOTICES.md +60 -0
  3. package/bin/bootstrap.js +9 -4
  4. package/bin/bootstrap.test.ts +82 -1
  5. package/bin/nodeVersionWarning.js +17 -0
  6. package/bin/nodeVersionWarning.test.ts +30 -0
  7. package/dist/action-BD56SQh4.mjs +254 -0
  8. package/dist/action-CPtgEl6p.mjs +94 -0
  9. package/dist/action-le0bNff_.mjs +1102 -0
  10. package/dist/action-ytG5oFAw.mjs +138 -0
  11. package/dist/action-zmJrU8PC.mjs +245 -0
  12. package/dist/{analyze-ZJUvEdaY.mjs → analyze-DCZo-sJd.mjs} +4 -71
  13. package/dist/artifacts-TrTX9_jj.mjs +104 -0
  14. package/dist/assets-XyhpYtGl.mjs +630 -0
  15. package/dist/auto-import-components/resolvers.d.mts +1 -1
  16. package/dist/auto-import-components/resolvers.mjs +1 -1
  17. package/dist/auto-import-presets/wevu-router.d.mts +1 -1
  18. package/dist/auto-import-presets/wevu-router.mjs +1 -1
  19. package/dist/auto-import-presets/wevu.d.mts +1 -1
  20. package/dist/auto-import-presets/wevu.mjs +1 -1
  21. package/dist/auto-import-presets.d.mts +2 -2
  22. package/dist/auto-import-presets.mjs +2 -2
  23. package/dist/auto-routes.d.mts +1 -3
  24. package/dist/auto-routes.mjs +3 -4
  25. package/dist/{budget-BD7VqLCl.d.mts → budget-DTPngJU0.d.mts} +1 -10
  26. package/dist/budget-_Mu-4GKn.mjs +63 -0
  27. package/dist/builtProject-B145uOt5.mjs +534 -0
  28. package/dist/{package-7swhyLmf.mjs → classifier-CNTJOYQL.mjs} +5 -9
  29. package/dist/cli-acceptance.mjs +3 -4
  30. package/dist/cli.mjs +142 -4569
  31. package/dist/{config-DRGcCi3h.mjs → config-59ZWhCIf.mjs} +1 -2
  32. package/dist/{config-V0L-IAJf.d.mts → config-BNx2BODw.d.mts} +145 -150
  33. package/dist/config.d.mts +2 -2
  34. package/dist/config.mjs +3 -3
  35. package/dist/{constants-DEZdcsMn.mjs → constants-BOe8mgqL.mjs} +2 -4
  36. package/dist/{createCompilerContextInstance-DJH_P_nZ.mjs → createCompilerContextInstance-BXSdH2E8.mjs} +19930 -14019
  37. package/dist/{createContext-BqYzHhY9.mjs → createContext-W0TeXxbo.mjs} +7 -5
  38. package/dist/dashboard/analyze.d.mts +1 -7
  39. package/dist/dashboard/analyze.mjs +3 -1
  40. package/dist/dashboard/vite.d.mts +2 -4
  41. package/dist/dashboard/vite.mjs +1 -2
  42. package/dist/dashboard.d.mts +2 -2
  43. package/dist/dashboard.mjs +1733 -1
  44. package/dist/dashboardTransport-C9290QgS.mjs +15 -0
  45. package/dist/{dashboardViteBridge-Dy3nAD4m.mjs → dashboardViteBridge-B7QgQo94.mjs} +11 -11
  46. package/dist/{dev-fR5GiJRO.mjs → dev-D1QSExwk.mjs} +6 -3
  47. package/dist/devProvider-Bcvz5nu4.mjs +4966 -0
  48. package/dist/docs/README.md +14 -6
  49. package/dist/docs/ai-workflows.md +2 -0
  50. package/dist/docs/mcp.md +11 -1
  51. package/dist/docs/troubleshooting.md +16 -0
  52. package/dist/docs/vue-sfc.md +25 -2
  53. package/dist/docs/weapp-config.md +29 -0
  54. package/dist/docs/wevu-authoring.md +2 -0
  55. package/dist/doctor-worker.mjs +5 -5
  56. package/dist/doctor.d.mts +2 -8
  57. package/dist/doctor.mjs +24 -31
  58. package/dist/engine-Mnnm_ALP.mjs +53 -0
  59. package/dist/file-5eEfbK60.mjs +1 -0
  60. package/dist/{file-sC3jD7Fh.mjs → file-D8mp5GmB.mjs} +50 -26
  61. package/dist/{files-BqxFIPRp.mjs → files-Cy9jURJu.mjs} +1 -2
  62. package/dist/forwardConsole-D2Q0RIqc.mjs +509 -0
  63. package/dist/getInstance-BXNVH7sU.mjs +1 -0
  64. package/dist/{getInstance-DiGSzBNI.mjs → getInstance-DfNlbr-X.mjs} +2 -3
  65. package/dist/history-dKxzoHmN.mjs +774 -0
  66. package/dist/i18n.d.mts +1 -3
  67. package/dist/i18n.mjs +1 -2
  68. package/dist/{index-C9HjUX5c.d.mts → index-DIZJRrvK.d.mts} +1 -24
  69. package/dist/{index-CaXAtb9e.d.mts → index-SnaW3cvA.d.mts} +0 -12
  70. package/dist/index.d.mts +3 -7
  71. package/dist/index.mjs +6 -6
  72. package/dist/{json-BL8Dhhk6.mjs → json-Cvon2mw5.mjs} +1 -2
  73. package/dist/json.d.mts +1 -1
  74. package/dist/json.mjs +1 -1
  75. package/dist/lib-CJyMBzoe.mjs +140 -0
  76. package/dist/{lifecycle-BROTlwSL.mjs → lifecycle-CUo8PMQc.mjs} +123 -33
  77. package/dist/{loadConfig-C3BQhz7F.mjs → loadConfig-CKIdfW4o.mjs} +2 -3
  78. package/dist/loadConfig-D4WGJcYp.mjs +1 -0
  79. package/dist/logBuildAppFinish-DOBoof6S.mjs +54 -0
  80. package/dist/mcp-D88QvQgG.mjs +84 -0
  81. package/dist/{mcp-Cj8Maqo6.mjs → mcp-ovJgl1N9.mjs} +2 -4
  82. package/dist/mcp.d.mts +1 -3
  83. package/dist/mcp.mjs +1 -1
  84. package/dist/mcpClient-C8JzVZ46.mjs +283 -0
  85. package/dist/{processCleanup-B6KA30Zc.mjs → metadata-HlDKtlsu.mjs} +2 -21
  86. package/dist/nodeEnv-zq1EymWj.mjs +6 -0
  87. package/dist/openIde-QoYKhuuM.mjs +643 -0
  88. package/dist/options-Cz8vZ-0w.mjs +33 -0
  89. package/dist/{chunkStrategy-DRA5WpB-.mjs → package-DR62fAzP.mjs} +32 -31
  90. package/dist/path-E1OjBJAl.mjs +43 -0
  91. package/dist/{platform-CnkySBKz.mjs → platform-BiMpsZIb.mjs} +1 -2
  92. package/dist/{pluginHost--CaeyWpA.mjs → pluginHost-vn8Vty1J.mjs} +1 -2
  93. package/dist/processCleanup-DzB64WI8.mjs +18 -0
  94. package/dist/{protocol-vg8HGJ4n.mjs → protocol-HiSJRrSO.mjs} +43 -41
  95. package/dist/reader-wzPH_W8A.mjs +92 -0
  96. package/dist/realpathScope-DwlLaCk3.mjs +22 -0
  97. package/dist/report-PJVyo-UZ.mjs +105 -0
  98. package/dist/{path-doV773b7.mjs → resolvedId-DaxPh_yV.mjs} +5 -50
  99. package/dist/{resolvers-Dod-euqX.mjs → resolvers-CKYqmRD_.mjs} +10 -20
  100. package/dist/resolvers.d.mts +1 -1
  101. package/dist/resolvers.mjs +1 -1
  102. package/dist/{routes-C7fCmf92.d.mts → routes-DvAFX29h.d.mts} +0 -2
  103. package/dist/{runtime-Ee2HY6gR.d.mts → runtime-BL4RjBRa.d.mts} +1 -9
  104. package/dist/runtime-CKtMVERT.mjs +42 -0
  105. package/dist/{runtime-D6VCNhNY.mjs → runtime-DDUCb7pP.mjs} +4 -8
  106. package/dist/runtime.d.mts +1 -1
  107. package/dist/runtime.mjs +1 -1
  108. package/dist/schematics-DikfOjMD.mjs +90 -0
  109. package/dist/{session-PskhD-nZ.mjs → session-COrQJYif.mjs} +81 -21
  110. package/dist/test.d.mts +1 -3
  111. package/dist/test.mjs +54 -30
  112. package/dist/types-BK2EQ3Jm.d.mts +37 -0
  113. package/dist/{types-CgZn5X6j.d.mts → types-e2BMP9NU.d.mts} +1 -4
  114. package/dist/types.d.mts +4 -4
  115. package/dist/{upload-D4msblBf.mjs → upload-Chal5b3w.mjs} +118 -24
  116. package/dist/upload-worker.mjs +3 -5
  117. package/dist/{utils-CJSCgEj6.mjs → utils-CTGSZp4j.mjs} +72 -146
  118. package/dist/vite.d.mts +2 -4
  119. package/dist/vite.mjs +55 -21
  120. package/dist/volar.mjs +1 -2
  121. package/dist/{wevu-BQWUU7br.mjs → wevu-BaihCXO9.mjs} +1 -2
  122. package/dist/wevu-DTtSOyxB.d.mts +3 -0
  123. package/dist/{wevu-router-Dg1LnBlg.mjs → wevu-router-BIoxDbnu.mjs} +1 -2
  124. package/dist/wevu-router-CdWurGQ4.d.mts +3 -0
  125. package/dist/wxs-7V7MPzeW.mjs +1 -0
  126. package/dist/wxs-BdHHXltv.mjs +110 -0
  127. package/package.json +62 -53
  128. package/dist/dashboard-DvqF3Key.mjs +0 -1842
  129. package/dist/devProvider-BGBkw28J.mjs +0 -1050
  130. package/dist/file-DRb4eWqw.mjs +0 -1
  131. package/dist/getInstance-SiE6WZRh.mjs +0 -1
  132. package/dist/loadConfig-VGtBF4qm.mjs +0 -1
  133. package/dist/mcp-D3Yh24Cj.mjs +0 -529
  134. package/dist/wevu-C4KEC5kO.d.mts +0 -5
  135. package/dist/wevu-router-Cg2sIkIE.d.mts +0 -5
@@ -1,11 +1,11 @@
1
- import { a as parseSidecarModuleId, i as parseLogicalEntryId, o as parseSidecarSourceRequest } from "./protocol-vg8HGJ4n.mjs";
2
- import { r as normalizeRelativePath } from "./path-doV773b7.mjs";
1
+ import { a as parseSidecarModuleId, i as parseLogicalEntryId, s as parseSidecarSourceRequest } from "./protocol-HiSJRrSO.mjs";
2
+ import { r as normalizeRelativePath } from "./path-E1OjBJAl.mjs";
3
3
  import { posix } from "pathe";
4
4
  import { removeExtensionDeep } from "@weapp-core/shared";
5
5
  import { Buffer } from "node:buffer";
6
6
  import MagicString from "magic-string";
7
7
  import remapping from "@jridgewell/remapping";
8
- //#region src/runtime/chunkStrategy/state.ts
8
+ // src/runtime/chunkStrategy/state.ts
9
9
  const sharedChunkDiagnostics = /* @__PURE__ */ new Map();
10
10
  const takeImportersMap = /* @__PURE__ */ new Map();
11
11
  const forceDuplicateSharedChunks = /* @__PURE__ */ new Set();
@@ -57,8 +57,7 @@ function setCachedSharedChunkName(moduleId, value) {
57
57
  if (!moduleId) return;
58
58
  sharedChunkNameCache.set(moduleId, value ?? null);
59
59
  }
60
- //#endregion
61
- //#region src/utils/sourcemap.ts
60
+ // src/utils/sourcemap.ts
62
61
  function isEncodedSourceMapLike(value) {
63
62
  return Boolean(value && typeof value === "object" && "version" in value && typeof value.version === "number" && "mappings" in value && "names" in value && "sources" in value);
64
63
  }
@@ -89,8 +88,7 @@ function labelSourceMapInput(value, fileName, code) {
89
88
  sourcesContent: map.sources.map((source, index) => map.sourcesContent?.[index] ?? (source === "" ? code : null))
90
89
  };
91
90
  }
92
- //#endregion
93
- //#region src/utils/outputChunk.ts
91
+ // src/utils/outputChunk.ts
94
92
  const INLINE_SOURCE_MAP_RE = /\n?\/\/[#@]\s*sourceMappingURL=(data:application\/json\S*)\s*$/u;
95
93
  function resolveInlineSourceMap(code) {
96
94
  const match = INLINE_SOURCE_MAP_RE.exec(code);
@@ -143,6 +141,18 @@ function applyMagicStringChunkRewrite(chunk, magicString, options) {
143
141
  return true;
144
142
  }
145
143
  /**
144
+ * 原子地提交一次 chunk 改写;映射组合失败时保留原始 chunk。
145
+ */
146
+ function applyAtomicMagicStringChunkRewrite(chunk, magicString, options) {
147
+ const staged = { ...chunk };
148
+ const changed = applyMagicStringChunkRewrite(staged, magicString, options);
149
+ Object.assign(chunk, {
150
+ code: staged.code,
151
+ map: staged.map
152
+ });
153
+ return changed;
154
+ }
155
+ /**
146
156
  * 在 chunk 当前代码上执行一次可追踪编辑。
147
157
  */
148
158
  function editOutputChunkCode(chunk, edit, options) {
@@ -234,15 +244,13 @@ function syncOutputChunkSourceMapAssets(bundle) {
234
244
  }
235
245
  return synced;
236
246
  }
237
- //#endregion
238
- //#region src/runtime/chunkStrategy/utils.ts
247
+ // src/runtime/chunkStrategy/utils.ts
239
248
  function createRelativeImport(fromFile, toFile) {
240
249
  const relative = posix.relative(posix.dirname(fromFile), toFile);
241
250
  if (!relative || relative.startsWith(".")) return relative || "./";
242
251
  return `./${relative}`;
243
252
  }
244
- //#endregion
245
- //#region src/runtime/chunkStrategy/bundle.ts
253
+ // src/runtime/chunkStrategy/bundle.ts
246
254
  function escapeRegExp(value) {
247
255
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
248
256
  }
@@ -536,8 +544,7 @@ function updateImporters(bundle, importerToChunk, originalFileName, index) {
536
544
  }
537
545
  }
538
546
  }
539
- //#endregion
540
- //#region src/runtime/chunkStrategy/collector.ts
547
+ // src/runtime/chunkStrategy/collector.ts
541
548
  function resolveChunkGraphSourceId(id) {
542
549
  return parseLogicalEntryId(id)?.sourceId ?? parseSidecarModuleId(id)?.ownerId ?? parseSidecarSourceRequest(id)?.ownerId ?? id;
543
550
  }
@@ -661,8 +668,7 @@ function assertModuleScopedToRoot(options) {
661
668
  }
662
669
  }
663
670
  }
664
- //#endregion
665
- //#region src/runtime/chunkStrategy/sourcemap.ts
671
+ // src/runtime/chunkStrategy/sourcemap.ts
666
672
  function isSourceLike(source) {
667
673
  return typeof source === "string" || source instanceof Uint8Array || Buffer.isBuffer(source);
668
674
  }
@@ -723,8 +729,7 @@ function emitSourceMapAsset(ctx, targetFileName, sourceMapAssetInfo, fallbackSou
723
729
  source: cloneSourceLike(fallbackSource)
724
730
  });
725
731
  }
726
- //#endregion
727
- //#region src/runtime/chunkStrategy/apply/runtime.ts
732
+ // src/runtime/chunkStrategy/apply/runtime.ts
728
733
  const ROLLDOWN_RUNTIME_FILE_NAME$2 = "rolldown-runtime.js";
729
734
  function applyRuntimeChunkLocalization(bundle, options) {
730
735
  if (!this) throw new Error("applyRuntimeChunkLocalization 需要 PluginContext。");
@@ -833,13 +838,11 @@ function dedupeLookupKeys(values) {
833
838
  function isRuntimeBundleOutput(output) {
834
839
  return output?.type === "chunk" || output?.type === "asset";
835
840
  }
836
- //#endregion
837
- //#region src/runtime/chunkStrategy/constants.ts
841
+ // src/runtime/chunkStrategy/constants.ts
838
842
  const SHARED_CHUNK_VIRTUAL_PREFIX = "weapp_shared_virtual";
839
843
  const SUB_PACKAGE_SHARED_DIR = "weapp-shared";
840
844
  const DEFAULT_SHARED_CHUNK_STRATEGY = "hoist";
841
- //#endregion
842
- //#region src/runtime/chunkStrategy/apply/rewrite.ts
845
+ // src/runtime/chunkStrategy/apply/rewrite.ts
843
846
  const ROLLDOWN_RUNTIME_FILE_NAME$1 = "rolldown-runtime.js";
844
847
  const REGEXP_ESCAPE_PATTERN = /[.*+?^${}()|[\]\\]/g;
845
848
  function createChunkSourceFileNameCandidates(fileName) {
@@ -906,8 +909,7 @@ function createRelativeImportPath(fromFileName, toFileName) {
906
909
  if (!relativePath || relativePath.startsWith(".")) return relativePath || "./";
907
910
  return `./${relativePath}`;
908
911
  }
909
- //#endregion
910
- //#region src/runtime/chunkStrategy/apply/shared/runtime.ts
912
+ // src/runtime/chunkStrategy/apply/shared/runtime.ts
911
913
  const ROLLDOWN_RUNTIME_FILE_NAME = "rolldown-runtime.js";
912
914
  const SLASHES_PATTERN = /[\\/]+/g;
913
915
  function createCrossSubPackageDuplicateBaseName(sourceRoot, fileName) {
@@ -1019,8 +1021,7 @@ function buildDuplicateDiagnostics(args) {
1019
1021
  requiresRuntimeLocalization: chunkReferencesRuntime(args.chunk, ROLLDOWN_RUNTIME_FILE_NAME, new Set(args.sourceRoot ? [posix.join(args.sourceRoot, ROLLDOWN_RUNTIME_FILE_NAME), ROLLDOWN_RUNTIME_FILE_NAME] : [ROLLDOWN_RUNTIME_FILE_NAME]))
1020
1022
  };
1021
1023
  }
1022
- //#endregion
1023
- //#region src/runtime/chunkStrategy/apply/shared/leaks.ts
1024
+ // src/runtime/chunkStrategy/apply/shared/leaks.ts
1024
1025
  function localizeCrossSubPackageChunkLeaks(bundle, options) {
1025
1026
  const { subPackageRoots, reservedFileNames, localizedDuplicateFileMap, onDuplicate } = options;
1026
1027
  if (subPackageRoots.length === 0) return;
@@ -1119,8 +1120,7 @@ function localizeCrossSubPackageChunkLeaks(bundle, options) {
1119
1120
  });
1120
1121
  }
1121
1122
  }
1122
- //#endregion
1123
- //#region src/runtime/chunkStrategy/apply/shared.ts
1123
+ // src/runtime/chunkStrategy/apply/shared.ts
1124
1124
  function applySharedChunkStrategy(bundle, options) {
1125
1125
  if (options.strategy !== "duplicate" && !hasForceDuplicateSharedChunks()) return;
1126
1126
  if (!this) throw new Error("applySharedChunkStrategy 需要 PluginContext。");
@@ -1299,8 +1299,7 @@ function shouldAnalyzeSharedChunkBundle(entries, subPackageRoots) {
1299
1299
  }
1300
1300
  return false;
1301
1301
  }
1302
- //#endregion
1303
- //#region src/runtime/chunkStrategy/naming.ts
1302
+ // src/runtime/chunkStrategy/naming.ts
1304
1303
  function resolveTakeSharedChunkName(options) {
1305
1304
  const { ctx, relativeAbsoluteSrcRoot, subPackageRoots, importers } = options;
1306
1305
  if (!importers.length) return;
@@ -1432,5 +1431,7 @@ function resolveSharedChunkName(options) {
1432
1431
  setCachedSharedChunkName(id, "common");
1433
1432
  return "common";
1434
1433
  }
1435
- //#endregion
1436
- export { syncOutputChunkSourceMapAssets as _, SUB_PACKAGE_SHARED_DIR as a, normalizeEncodedSourceMapLike as b, resolveSubPackagePrefix as c, applyOutputChunkTransform as d, editOutputChunkCode as f, resolveOutputChunkTransformCode as g, replaceOutputChunkCodeRanges as h, SHARED_CHUNK_VIRTUAL_PREFIX as i, appendOutputChunkCode as l, replaceOutputChunkCode as m, applySharedChunkStrategy as n, applyRuntimeChunkLocalization as o, prependOutputChunkCode as p, DEFAULT_SHARED_CHUNK_STRATEGY as r, assertModuleScopedToRoot as s, resolveSharedChunkName as t, applyMagicStringChunkRewrite as u, composeSourceMaps as v, resetTakeImportRegistry as x, labelSourceMapInput as y };
1434
+ // package.json
1435
+ var version = "7.7.0";
1436
+ var engines = { "node": "^22.23.4 || ^24.22.1 || >=26.12.1" };
1437
+ export { normalizeEncodedSourceMapLike as C, labelSourceMapInput as S, replaceOutputChunkCode as _, DEFAULT_SHARED_CHUNK_STRATEGY as a, syncOutputChunkSourceMapAssets as b, applyRuntimeChunkLocalization as c, appendOutputChunkCode as d, applyAtomicMagicStringChunkRewrite as f, prependOutputChunkCode as g, editOutputChunkCode as h, applySharedChunkStrategy as i, assertModuleScopedToRoot as l, applyOutputChunkTransform as m, version as n, SHARED_CHUNK_VIRTUAL_PREFIX as o, applyMagicStringChunkRewrite as p, resolveSharedChunkName as r, SUB_PACKAGE_SHARED_DIR as s, engines as t, resolveSubPackagePrefix as u, replaceOutputChunkCodeRanges as v, resetTakeImportRegistry as w, composeSourceMaps as x, resolveOutputChunkTransformCode as y };
@@ -0,0 +1,43 @@
1
+ import path from "pathe";
2
+ import { normalize } from "node:path";
3
+ // 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
+ export { normalizeWatchPath as a, normalizeRoot as i, normalizePath as n, stripLeadingSlashes as o, normalizeRelativePath as r, toPosixPath as s, isPathInside as t };
@@ -1,6 +1,6 @@
1
1
  import { t as MINI_PROGRAM_PLATFORM_ADAPTERS } from "./adapters-CcHrsYaj.mjs";
2
2
  import { MINI_PROGRAM_PLATFORM_ALIASES, getDefaultMiniProgramPlatform, getMiniProgramAppTypesPackage, getMiniProgramDirectivePrefix, getSupportedMiniProgramPlatforms, normalizeMiniProgramPlatform, resolveMiniProgramPlatform } from "@weapp-core/shared";
3
- //#region src/platform.ts
3
+ // src/platform.ts
4
4
  const DEFAULT_MP_PLATFORM = getDefaultMiniProgramPlatform();
5
5
  const NPM_PROTOCOL_RE = /^npm:/;
6
6
  const EXPLICIT_NPM_DIR_RE = /^\/(?:miniprogram_npm|node_modules)\//;
@@ -171,5 +171,4 @@ function getTypeScriptPlatformOptions(platform) {
171
171
  function getPlatformAppTypesPackage(platform) {
172
172
  return getTypeScriptPlatformOptions(platform).appTypesPackage;
173
173
  }
174
- //#endregion
175
174
  export { shouldNormalizeVueTemplateForPlatform as C, shouldUseProjectRootNpmDir as D, shouldRewriteBundleNpmImports as E, shouldNormalizeUsingComponents as S, shouldRebuildCachedMiniprogramPackage as T, shouldEmitGenericPlaceholderAsset as _, getPlatformNpmDistDirName as a, shouldNormalizeMiniprogramPackage as b, getPreservedNpmDirNames as c, getWxmlDirectivePrefix as d, getWxmlPlatformTransformOptions as f, shouldCopyEsModuleDirectory as g, resolveMiniPlatformWithDefault as h, getPlatformAppTypesPackage as i, getProjectPlatformOptions as l, resolveMiniPlatform as m, getDefaultIdeProjectRoot as n, getPlatformOutputExtensions as o, normalizePlatformNpmImportPath as p, getJsonPlatformOptions as r, getPlatformScriptModuleTag as s, DEFAULT_MP_PLATFORM as t, getSupportedMiniProgramPlatforms$1 as u, shouldFillComponentGenericsDefault as v, shouldPassPlatformArgToIdeOpen as w, shouldNormalizePlatformNpmImportPath as x, shouldHoistNestedMiniprogramDependencies as y };
@@ -1,4 +1,4 @@
1
- //#region src/pluginHost.ts
1
+ // src/pluginHost.ts
2
2
  const WEAPP_VITE_HOST_NAME = "weapp-vite";
3
3
  function createWeappViteHostMeta(runtime, platform) {
4
4
  const meta = {
@@ -23,5 +23,4 @@ function resolveWeappViteHostMeta(config) {
23
23
  function isWeappViteHost(config) {
24
24
  return resolveWeappViteHostMeta(config) !== void 0;
25
25
  }
26
- //#endregion
27
26
  export { resolveWeappViteHostMeta as a, isWeappViteHost as i, applyWeappViteHostMeta as n, createWeappViteHostMeta as r, WEAPP_VITE_HOST_NAME as t };
@@ -0,0 +1,18 @@
1
+ import process from "node:process";
2
+ // 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
+ export { terminateStaleSassEmbeddedProcess as t };
@@ -1,28 +1,7 @@
1
- import path from "pathe";
2
- import { realpathSync } from "node:fs";
1
+ import { t as resolveRealpath } from "./realpathScope-DwlLaCk3.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
25
- //#region src/moduleGraph/protocol.ts
3
+ import path from "pathe";
4
+ // src/moduleGraph/protocol.ts
26
5
  const VIRTUAL_MODULE_SUFFIX = ":module.js";
27
6
  const SIDECAR_SOURCE_JS_SUFFIX = "&lang.js";
28
7
  const SIDECAR_SOURCE_STYLE_SUFFIX = "&lang.css";
@@ -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,27 @@ 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
- //#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 };
140
+ 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,92 @@
1
+ // 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
+ export { readHmrProfileLines as t };
@@ -0,0 +1,22 @@
1
+ import { realpathSync } from "node:fs";
2
+ // 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
+ export { withRealpathScope as n, resolveRealpath as t };
@@ -0,0 +1,105 @@
1
+ import process from "node:process";
2
+ import { parseArgs } from "node:util";
3
+ // 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
+ // src/cli/upload/report.ts
50
+ var UploadCommandError = class extends Error {
51
+ report;
52
+ constructor(report) {
53
+ super(report.error);
54
+ this.report = report;
55
+ this.name = "UploadCommandError";
56
+ }
57
+ };
58
+ function createFailedUploadReport(error) {
59
+ return {
60
+ schemaVersion: 1,
61
+ action: "upload",
62
+ status: "failed",
63
+ results: [],
64
+ error: error instanceof Error ? error.message : String(error)
65
+ };
66
+ }
67
+ function printUploadProgress(platform, event) {
68
+ const percent = event.percent === void 0 ? "" : ` ${event.percent}%`;
69
+ process.stderr.write(`[upload:${platform}] ${event.type}${percent}${event.message ? ` ${event.message}` : ""}\n`);
70
+ }
71
+ function printUploadSummary(report) {
72
+ const labels = {
73
+ "success": "上传成功",
74
+ "failed": "失败",
75
+ "not-run": "未执行",
76
+ "dry-run": "仅构建",
77
+ "unknown": "远端结果未确认"
78
+ };
79
+ for (const item of report.results) process.stderr.write(`[upload:${item.platform ?? "配置平台"}] ${labels[item.status]}${item.requestedVersion ? ` ${item.requestedVersion}` : ""} (${item.stage})\n`);
80
+ }
81
+ /** JSON 模式独占 stdout,构建配置及第三方工具的普通日志只进入 stderr。 */
82
+ async function outputUploadReport(json, run) {
83
+ const stdoutWrite = process.stdout.write;
84
+ if (json) process.stdout.write = process.stderr.write.bind(process.stderr);
85
+ try {
86
+ let report;
87
+ try {
88
+ report = await run();
89
+ } catch (error) {
90
+ report = error instanceof UploadCommandError ? error.report : createFailedUploadReport(error);
91
+ }
92
+ if (json) {
93
+ await new Promise((resolve, reject) => {
94
+ stdoutWrite.call(process.stdout, `${JSON.stringify(report)}\n`, "utf8", (error) => error ? reject(error) : resolve());
95
+ });
96
+ if (report.status === "failed") process.exitCode = 1;
97
+ } else {
98
+ printUploadSummary(report);
99
+ if (report.status === "failed") throw new UploadCommandError(report);
100
+ }
101
+ } finally {
102
+ process.stdout.write = stdoutWrite;
103
+ }
104
+ }
105
+ export { resolveBuildUploadOptions as a, readUploadMetadata as i, outputUploadReport as n, resolveUploadTimeout as o, printUploadProgress as r, UploadCommandError as t };