weapp-vite 7.4.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 (126) hide show
  1. package/README.md +59 -3
  2. package/THIRD_PARTY_NOTICES.md +60 -0
  3. package/bin/bootstrap.js +14 -1
  4. package/dist/action-B3YZMA-h.mjs +255 -0
  5. package/dist/action-BELcDNNv.mjs +139 -0
  6. package/dist/action-BOk3vGI7.mjs +1110 -0
  7. package/dist/action-DlC6JYpt.mjs +95 -0
  8. package/dist/action-zEDY7oh_.mjs +247 -0
  9. package/dist/adapters-CcHrsYaj.mjs +1 -0
  10. package/dist/analyze-DN79YOAH.mjs +184 -0
  11. package/dist/artifacts-BOyC9Fy-.mjs +106 -0
  12. package/dist/assets-C5_YYXNk.mjs +637 -0
  13. package/dist/auto-import-components/resolvers.mjs +1 -2
  14. package/dist/auto-import-presets/wevu-router.mjs +1 -2
  15. package/dist/auto-import-presets/wevu.mjs +1 -2
  16. package/dist/auto-routes.mjs +2 -1
  17. package/dist/budget-CTLOHwgI.d.mts +177 -0
  18. package/dist/budget-EOeEycc_.mjs +65 -0
  19. package/dist/builtProject-C29udgXY.mjs +541 -0
  20. package/dist/chunkStrategy-DY_LZIIe.mjs +1448 -0
  21. package/dist/classifier-DBJY__kg.mjs +88 -0
  22. package/dist/cli-acceptance.d.mts +1 -0
  23. package/dist/cli-acceptance.mjs +21 -0
  24. package/dist/cli.mjs +519 -5049
  25. package/dist/compatibility.mjs +1 -2
  26. package/dist/{config-Dbvj5yK7.d.mts → config-Bf6DWhyb.d.mts} +220 -76
  27. package/dist/config.d.mts +3 -3
  28. package/dist/config.mjs +1 -1
  29. package/dist/{constants-WOsG3Eqd.mjs → constants-DEZdcsMn.mjs} +1 -1
  30. package/dist/{createContext-UOEgeYnA.mjs → createCompilerContextInstance-aYwi8wQt.mjs} +36862 -32020
  31. package/dist/createContext-tApLtII-.mjs +15 -0
  32. package/dist/dashboard/analyze.d.mts +48 -0
  33. package/dist/dashboard/analyze.mjs +3 -0
  34. package/dist/dashboard/vite.d.mts +1 -1
  35. package/dist/dashboard.d.mts +3 -2
  36. package/dist/dashboard.mjs +1748 -1
  37. package/dist/dashboardTransport-C_Y6jMp-.mjs +16 -0
  38. package/dist/dashboardViteBridge-DCGR43aM.mjs +302 -0
  39. package/dist/dev-C2fgr_Xd.mjs +67 -0
  40. package/dist/devProvider-D-hTfsEO.mjs +3027 -0
  41. package/dist/docs/README.md +59 -3
  42. package/dist/docs/ai-workflows.md +4 -0
  43. package/dist/docs/doctor.md +38 -0
  44. package/dist/docs/getting-started.md +3 -1
  45. package/dist/docs/index.md +3 -1
  46. package/dist/docs/mcp.md +104 -1
  47. package/dist/docs/testing.md +29 -2
  48. package/dist/docs/troubleshooting.md +16 -0
  49. package/dist/docs/uni-app-component-libraries.md +8 -7
  50. package/dist/docs/upload.md +40 -3
  51. package/dist/docs/vite-plugin.md +171 -0
  52. package/dist/docs/vue-sfc.md +42 -0
  53. package/dist/docs/weapp-config.md +54 -0
  54. package/dist/docs/wevu-authoring.md +10 -0
  55. package/dist/doctor-worker.d.mts +1 -0
  56. package/dist/doctor-worker.mjs +60 -0
  57. package/dist/doctor.d.mts +144 -0
  58. package/dist/doctor.mjs +850 -0
  59. package/dist/engine-C66J0HLz.mjs +54 -0
  60. package/dist/eslint.mjs +1 -2
  61. package/dist/{file-giE9UMZa.mjs → file-CcIOmqhC.mjs} +58 -24
  62. package/dist/file-DtcteQ4G.mjs +1 -0
  63. package/dist/files-BqxFIPRp.mjs +45 -0
  64. package/dist/forwardConsole-B0Reo8Lf.mjs +511 -0
  65. package/dist/getInstance-BAIaU2y9.mjs +1 -0
  66. package/dist/getInstance-Dt9IQDKr.mjs +28 -0
  67. package/dist/history-BIiRCzbq.mjs +784 -0
  68. package/dist/i18n.d.mts +1 -1
  69. package/dist/index-D5rgBzYZ.d.mts +740 -0
  70. package/dist/index.d.mts +12 -10
  71. package/dist/index.mjs +3 -2
  72. package/dist/json.d.mts +1 -1
  73. package/dist/json.mjs +1 -2
  74. package/dist/lib-DjccSI1B.mjs +143 -0
  75. package/dist/lifecycle-C36WSbQS.mjs +413 -0
  76. package/dist/loadConfig-BWIsDXR4.mjs +59 -0
  77. package/dist/loadConfig-D-BpBgsk.mjs +1 -0
  78. package/dist/logBuildAppFinish-ChjwATMv.mjs +57 -0
  79. package/dist/logger-DGn5iEVN.mjs +1 -0
  80. package/dist/mcp-CYgX9HpO.mjs +86 -0
  81. package/dist/{mcp-BG6TliEg.mjs → mcp-Cj8Maqo6.mjs} +16 -7
  82. package/dist/mcp.d.mts +6 -3
  83. package/dist/mcp.mjs +1 -2
  84. package/dist/mcpClient-DVLvFLZv.mjs +287 -0
  85. package/dist/metadata-hwF7QRcS.mjs +59 -0
  86. package/dist/nodeEnv-BmH8UZPR.mjs +7 -0
  87. package/dist/openIde-CroqOgk5.mjs +648 -0
  88. package/dist/options-jqFwfD1G.mjs +34 -0
  89. package/dist/package-Cmakyy3J.mjs +4 -0
  90. package/dist/path-CYYIQGS7.mjs +44 -0
  91. package/dist/{platform-DTWs5QRi.mjs → platform-CnkySBKz.mjs} +1 -1
  92. package/dist/processCleanup-BQn2kTcK.mjs +19 -0
  93. package/dist/protocol-Cg6Jdlvb.mjs +141 -0
  94. package/dist/reader-sh_POQ9-.mjs +93 -0
  95. package/dist/realpathScope-Tf9mz-fh.mjs +23 -0
  96. package/dist/report-hyonPGbZ.mjs +107 -0
  97. package/dist/resolvedId-CiDl7SC1.mjs +60 -0
  98. package/dist/{resolvers-icNxkpcy.mjs → resolvers-Dod-euqX.mjs} +4 -1
  99. package/dist/resolvers.mjs +1 -2
  100. package/dist/runtime-CLUhQsdA.mjs +43 -0
  101. package/dist/{runtime-Ee2HY6gR.d.mts → runtime-DpVf714f.d.mts} +1 -1
  102. package/dist/runtime.d.mts +1 -1
  103. package/dist/runtime.mjs +1 -2
  104. package/dist/schematics-kO26eQRT.mjs +91 -0
  105. package/dist/session-D3zsdzIy.mjs +452 -0
  106. package/dist/test.d.mts +1 -0
  107. package/dist/test.mjs +204 -45
  108. package/dist/{types-CgZn5X6j.d.mts → types-D-kfuyVa.d.mts} +1 -2
  109. package/dist/types-D0FFexRF.d.mts +39 -0
  110. package/dist/types.d.mts +3 -3
  111. package/dist/{upload-D0RcEWrq.mjs → upload-DozK8UdN.mjs} +278 -15
  112. package/dist/upload-worker.mjs +136 -3
  113. package/dist/utils-Dy51PYAC.mjs +1034 -0
  114. package/dist/vite.d.mts +9 -0
  115. package/dist/vite.mjs +309 -0
  116. package/dist/volar.d.mts +2 -2
  117. package/dist/web-apis.mjs +1 -2
  118. package/dist/wxs-BT8btflA.mjs +112 -0
  119. package/dist/wxs-Z4VQDeJ_.mjs +1 -0
  120. package/package.json +80 -48
  121. package/dist/adapters-BwnMMIZR.mjs +0 -2
  122. package/dist/dashboard-BzaVesmQ.mjs +0 -558
  123. package/dist/file-D19nbDoN.mjs +0 -2
  124. package/dist/getInstance-CYF1vl5l.mjs +0 -2
  125. package/dist/index-DbqVupg0.d.mts +0 -246
  126. package/dist/logger-mt4mSTqV.mjs +0 -2
package/dist/index.d.mts CHANGED
@@ -1,16 +1,18 @@
1
- import { $ as WeappCompilerHmrRequest, A as PluginOption, B as ViteDevServer, Br as WeappVitePlatform, Ct as WeappViteConfig, D as InlineConfig, E as ConfigEnv, F as RolldownOutput, Fr as isWeappViteHost, Gr as WebPlatform, Hr as WeappViteTargetDescriptor, I as RolldownPlugin, Ir as resolveWeappViteHostMeta, Jr as isWebPlatform, Kr as getSupportedWeappVitePlatforms, L as RolldownPluginOption, Lr as ResolveWeappViteTargetOptions, M as ResolvedConfig, Mr as WeappViteHostMeta, N as RolldownBuild, Nr as applyWeappViteHostMeta, O as MethodDefinitions, P as RolldownOptions, Pr as createWeappViteHostMeta, Q as WeappCompilerHmrPreparation, R as RolldownWatchOptions, Rr as ResolvedWeappViteTarget, S as CompilerContext, Sn as MultiPlatformProjectConfigs, T as ComputedDefinitions, Ur as WeappViteTargetInput, Vr as WeappViteRuntime, Wr as WeappViteTargetKind, Yr as resolveWeappViteTarget, Z as WeappCompilerHmrAsset, _ as definePageJson, _n as WxmlTransformContext, a as UserConfigFnNoEnvPlain, at as WeappCompilerPluginFactory, bn as WxmlTransformVisitor, c as UserConfigFnPromise, cn as WxmlValidate, ct as WeappCompilerResourceKind, d as Component, dn as WxmlValidationVisitor, dt as WeappCompilerTransformResult, et as WeappCompilerOutputRequest, f as Page, fn as WxmlAttribute, g as defineComponentJson, gn as WxmlTransform, h as defineAppJson, hn as WxmlSourceLocation, i as UserConfigFnNoEnv, it as WeappCompilerPluginController, j as Ref, jr as WEAPP_VITE_HOST_NAME, k as Plugin, l as defineConfig, ln as WxmlValidationContext, lt as WeappCompilerSourceClaim, m as Theme, mn as WxmlElementInfo, n as UserConfigExport, nt as WeappCompilerPluginCapabilities, o as UserConfigFnObject, on as WxmlRemoveAttrRule, ot as WeappCompilerPluginOption, p as Sitemap, pn as WxmlAttributeValue, qr as getSupportedWeappViteTargetDescriptors, r as UserConfigFn, rt as WeappCompilerPluginContext, s as UserConfigFnObjectPlain, sn as WxmlRemoveOptions, st as WeappCompilerPluginPhase, t as UserConfig, tt as WeappCompilerPlugin, u as App, un as WxmlValidationDiagnostic, ut as WeappCompilerSourceRequest, v as defineSitemapJson, vn as WxmlTransformNode, w as LoadConfigOptions, xn as MultiPlatformProjectConfig, y as defineThemeJson, yn as WxmlTransformResult, z as RolldownWatcher, zr as WEB_PLATFORM_ALIASES } from "./config-Dbvj5yK7.mjs";
2
- import { t as WeappI18nConfig } from "./types-CgZn5X6j.mjs";
3
- 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";
4
- //#region src/createContext.d.ts
5
- interface CreateCompilerContextOptions extends Partial<LoadConfigOptions> {
6
- key?: string;
1
+ import { $ as WeappCompilerOutputRequest, A as Ref, Ar as WEAPP_VITE_HOST_NAME, Br as WeappViteRuntime, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fr as resolveWeappViteHostMeta, Gn as JsonMergeContext, Gr as getSupportedWeappVitePlatforms, Hr as WeappViteTargetInput, I as RolldownPluginOption, Ir as ResolveWeappViteTargetOptions, Jn as JsonMergeStrategy, Jr as resolveWeappViteTarget, Kn as JsonMergeFunction, Kr as getSupportedWeappViteTargetDescriptors, L as RolldownWatchOptions, Lr as ResolvedWeappViteTarget, M as RolldownBuild, Mr as applyWeappViteHostMeta, N as RolldownOptions, Nr as createWeappViteHostMeta, O as Plugin, P as RolldownOutput, Pr as isWeappViteHost, Q as WeappCompilerHmrRequest, R as RolldownWatcher, Rr as WEB_PLATFORM_ALIASES, S as CompilerContext, St as WeappViteConfig, T as ConfigEnv, Ur as WeappViteTargetKind, Vr as WeappViteTargetDescriptor, Wn as JsonConfig, Wr as WebPlatform, X as WeappCompilerHmrAsset, Z as WeappCompilerHmrPreparation, _ as definePageJson, _n as WxmlTransformNode, a as UserConfigFnNoEnvPlain, an as WxmlRemoveAttrRule, at as WeappCompilerPluginOption, bn as MultiPlatformProjectConfig, c as UserConfigFnPromise, cn as WxmlValidationContext, ct as WeappCompilerSourceClaim, d as Component, dn as WxmlAttribute, et as WeappCompilerPlugin, f as Page, fn as WxmlAttributeValue, g as defineComponentJson, gn as WxmlTransformContext, h as defineAppJson, hn as WxmlTransform, i as UserConfigFnNoEnv, it as WeappCompilerPluginFactory, j as ResolvedConfig, jr as WeappViteHostMeta, k as PluginOption, l as defineConfig, ln as WxmlValidationDiagnostic, lt as WeappCompilerSourceRequest, m as Theme, mn as WxmlSourceLocation, n as UserConfigExport, nt as WeappCompilerPluginContext, o as UserConfigFnObject, on as WxmlRemoveOptions, ot as WeappCompilerPluginPhase, p as Sitemap, pn as WxmlElementInfo, qn as JsonMergeStage, qr as isWebPlatform, r as UserConfigFn, rt as WeappCompilerPluginController, s as UserConfigFnObjectPlain, sn as WxmlValidate, st as WeappCompilerResourceKind, t as UserConfig, tt as WeappCompilerPluginCapabilities, u as App, un as WxmlValidationVisitor, ut as WeappCompilerTransformResult, v as defineSitemapJson, vn as WxmlTransformResult, w as ComputedDefinitions, xn as MultiPlatformProjectConfigs, y as defineThemeJson, yn as WxmlTransformVisitor, z as ViteDevServer, zr as WeappVitePlatform } from "./config-Bf6DWhyb.mjs";
2
+ import { t as WeappI18nConfig } from "./types-D-kfuyVa.mjs";
3
+ 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";
4
+ //#region src/runtime/compilerSession/context.d.ts
5
+ interface InitializeCompilerContextOptions extends Partial<LoadConfigOptions> {
7
6
  syncSupportFiles?: boolean;
8
7
  syncAutoImportSupportFiles?: boolean;
9
8
  preloadAppEntry?: boolean;
10
9
  }
11
- /**
12
- * @description 创建并初始化编译上下文(加载配置、扫描入口)
13
- */
10
+ //#endregion
11
+ //#region src/createContext.d.ts
12
+ interface CreateCompilerContextOptions extends InitializeCompilerContextOptions {
13
+ key?: string;
14
+ }
15
+ /** 保留历史活动上下文适配;新宿主通过 CompilerSession 创建独立会话。 */
14
16
  export declare function createCompilerContext(options?: CreateCompilerContextOptions): Promise<CompilerContext>;
15
17
  //#endregion
16
- export { type App, type Component, type ComputedDefinitions, type ConfigEnv, type InlineConfig, type LayoutHostBridge, type LayoutHostContext, type LayoutHostEntry, type LayoutHostResolveOptions, type LayoutHostResolver, type MethodDefinitions, type MultiPlatformProjectConfig, type MultiPlatformProjectConfigs, type Page, type Plugin, type PluginOption, type Ref, ResolveWeappViteTargetOptions, type ResolvedConfig, ResolvedWeappViteTarget, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, type ViteDevServer, WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, type WeappCompilerHmrAsset, type WeappCompilerHmrPreparation, type WeappCompilerHmrRequest, WeappCompilerOutputRequest, WeappCompilerPlugin, WeappCompilerPluginCapabilities, WeappCompilerPluginContext, WeappCompilerPluginController, WeappCompilerPluginFactory, WeappCompilerPluginOption, WeappCompilerPluginPhase, WeappCompilerResourceKind, WeappCompilerSourceClaim, WeappCompilerSourceRequest, WeappCompilerTransformResult, type WeappI18nConfig, type WeappViteConfig, WeappViteHostMeta, WeappVitePlatform, WeappViteRuntime, WeappViteTargetDescriptor, WeappViteTargetInput, WeappViteTargetKind, WebPlatform, type WevuComponentOptions, type WxmlAttribute, type WxmlAttributeValue, type WxmlElementInfo, type WxmlRemoveAttrRule, type WxmlRemoveOptions, type WxmlSourceLocation, type WxmlTransform, type WxmlTransformContext, type WxmlTransformNode, type WxmlTransformResult, type WxmlTransformVisitor, type WxmlValidate, type WxmlValidationContext, type WxmlValidationDiagnostic, type WxmlValidationVisitor, applyWeappViteHostMeta, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
18
+ export { type App, type Component, type ComputedDefinitions, type ConfigEnv, type InlineConfig, type JsonConfig, type JsonMergeContext, type JsonMergeFunction, type JsonMergeStage, type JsonMergeStrategy, type LayoutHostBridge, type LayoutHostContext, type LayoutHostEntry, type LayoutHostResolveOptions, type LayoutHostResolver, type MethodDefinitions, type MultiPlatformProjectConfig, type MultiPlatformProjectConfigs, type Page, type Plugin, type PluginOption, type Ref, ResolveWeappViteTargetOptions, type ResolvedConfig, ResolvedWeappViteTarget, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, type ViteDevServer, WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, type WeappCompilerHmrAsset, type WeappCompilerHmrPreparation, type WeappCompilerHmrRequest, WeappCompilerOutputRequest, WeappCompilerPlugin, WeappCompilerPluginCapabilities, WeappCompilerPluginContext, WeappCompilerPluginController, WeappCompilerPluginFactory, WeappCompilerPluginOption, WeappCompilerPluginPhase, WeappCompilerResourceKind, WeappCompilerSourceClaim, WeappCompilerSourceRequest, WeappCompilerTransformResult, type WeappI18nConfig, type WeappViteConfig, WeappViteHostMeta, WeappVitePlatform, WeappViteRuntime, WeappViteTargetDescriptor, WeappViteTargetInput, WeappViteTargetKind, WebPlatform, type WevuComponentOptions, type WxmlAttribute, type WxmlAttributeValue, type WxmlElementInfo, type WxmlRemoveAttrRule, type WxmlRemoveOptions, type WxmlSourceLocation, type WxmlTransform, type WxmlTransformContext, type WxmlTransformNode, type WxmlTransformResult, type WxmlTransformVisitor, type WxmlValidate, type WxmlValidationContext, type WxmlValidationDiagnostic, type WxmlValidationVisitor, applyWeappViteHostMeta, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-BL8Dhhk6.mjs";
2
1
  import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost--CaeyWpA.mjs";
2
+ import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-BL8Dhhk6.mjs";
3
3
  import { t as defineConfig } from "./config-DRGcCi3h.mjs";
4
- import { c as getSupportedWeappViteTargetDescriptors, l as isWebPlatform, o as WEB_PLATFORM_ALIASES, s as getSupportedWeappVitePlatforms, t as createCompilerContext, u as resolveWeappViteTarget } from "./createContext-UOEgeYnA.mjs";
4
+ import { a as getSupportedWeappViteTargetDescriptors, i as getSupportedWeappVitePlatforms, o as isWebPlatform, r as WEB_PLATFORM_ALIASES, s as resolveWeappViteTarget } from "./createCompilerContextInstance-aYwi8wQt.mjs";
5
+ import { t as createCompilerContext } from "./createContext-tApLtII-.mjs";
5
6
  import { a as resolveLayoutHost, c as createWevuComponent, i as registerLayoutHosts, n as defineProps, o as unregisterLayoutHosts, r as setPageLayout, s as waitForLayoutHost, t as defineEmits } from "./runtime-D6VCNhNY.mjs";
6
7
  export { WEAPP_VITE_HOST_NAME, WEB_PLATFORM_ALIASES, applyWeappViteHostMeta, createCompilerContext, createWeappViteHostMeta, createWevuComponent, defineAppJson, defineComponentJson, defineConfig, defineEmits, definePageJson, defineProps, defineSitemapJson, defineThemeJson, getSupportedWeappVitePlatforms, getSupportedWeappViteTargetDescriptors, isWeappViteHost, isWebPlatform, registerLayoutHosts, resolveLayoutHost, resolveWeappViteHostMeta, resolveWeappViteTarget, setPageLayout, unregisterLayoutHosts, waitForLayoutHost };
package/dist/json.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-Dbvj5yK7.mjs";
1
+ import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-Bf6DWhyb.mjs";
2
2
  export { type App, type Component, type Page, type Sitemap, type Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
package/dist/json.mjs CHANGED
@@ -1,2 +1 @@
1
- import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-BL8Dhhk6.mjs";
2
- export { defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
1
+ export { t as defineAppJson, n as defineComponentJson, r as definePageJson, i as defineSitemapJson, a as defineThemeJson } from "./json-BL8Dhhk6.mjs";
@@ -0,0 +1,143 @@
1
+ import { o as stripLeadingSlashes, r as normalizeRelativePath } from "./path-CYYIQGS7.mjs";
2
+ import { c as findJsEntry, d as findVueEntry } from "./file-CcIOmqhC.mjs";
3
+ import path from "pathe";
4
+ import { isObject, removeExtensionDeep } from "@weapp-core/shared";
5
+ import { fs } from "@weapp-core/shared/fs";
6
+ //#region src/runtime/compilerSession/tasks.ts
7
+ /** 任一子构建失败后仍等待所有已启动任务,保留最先排列的原始错误。 */
8
+ async function waitForBuildTasks(tasks) {
9
+ const results = await Promise.allSettled(tasks);
10
+ const failure = results.find((result) => result.status === "rejected");
11
+ if (failure?.status === "rejected") throw failure.reason;
12
+ return results.map((result) => result.value);
13
+ }
14
+ //#endregion
15
+ //#region src/runtime/utils/object.ts
16
+ function hasOwn(source, key) {
17
+ return Object.prototype.hasOwnProperty.call(source, key);
18
+ }
19
+ //#endregion
20
+ //#region src/runtime/lib.ts
21
+ function hasLibEntry(entry) {
22
+ if (!entry) return false;
23
+ if (typeof entry === "string") return entry.trim().length > 0;
24
+ if (Array.isArray(entry)) return entry.length > 0;
25
+ if (isObject(entry)) return Object.keys(entry).length > 0;
26
+ return false;
27
+ }
28
+ function resolveWeappLibConfig(options) {
29
+ const { cwd, srcRoot, config } = options;
30
+ if (!config) return;
31
+ const root = config.root ?? srcRoot ?? "";
32
+ const resolvedRoot = path.resolve(cwd, root || ".");
33
+ const userDtsOptions = typeof config.dts === "object" && config.dts ? config.dts : void 0;
34
+ const resolvedDtsEnabled = typeof config.dts === "boolean" ? config.dts : userDtsOptions?.enabled !== false;
35
+ const resolvedDtsMode = userDtsOptions?.mode ?? "internal";
36
+ const resolvedDts = {
37
+ ...userDtsOptions,
38
+ enabled: resolvedDtsEnabled,
39
+ mode: resolvedDtsMode
40
+ };
41
+ return {
42
+ enabled: hasLibEntry(config.entry),
43
+ entry: config.entry,
44
+ root: resolvedRoot,
45
+ outDir: config.outDir,
46
+ preservePath: config.preservePath !== false,
47
+ fileName: config.fileName,
48
+ componentJson: config.componentJson ?? "auto",
49
+ dts: resolvedDts,
50
+ source: config
51
+ };
52
+ }
53
+ function normalizeLibName(value) {
54
+ return stripLeadingSlashes(normalizeRelativePath(value));
55
+ }
56
+ async function resolveEntryFile(root, entry) {
57
+ const resolved = path.isAbsolute(entry) ? entry : path.resolve(root, entry);
58
+ if (path.extname(resolved)) {
59
+ if (await fs.pathExists(resolved)) return resolved;
60
+ }
61
+ const jsEntry = await findJsEntry(resolved);
62
+ if (jsEntry.path) return jsEntry.path;
63
+ const vueEntry = await findVueEntry(resolved);
64
+ if (vueEntry) return vueEntry;
65
+ if (await fs.pathExists(resolved)) return resolved;
66
+ }
67
+ function resolveEntryName(options) {
68
+ const { explicitName, preservePath, relativeId } = options;
69
+ if (explicitName) return normalizeLibName(explicitName);
70
+ const base = removeExtensionDeep(relativeId);
71
+ if (!preservePath) return normalizeLibName(path.basename(base));
72
+ return normalizeLibName(base);
73
+ }
74
+ function resolveOutputBase(options) {
75
+ const { entryName, entryPath, config } = options;
76
+ const fileName = config.fileName;
77
+ if (!fileName) return normalizeLibName(entryName);
78
+ let resolved;
79
+ if (typeof fileName === "function") {
80
+ resolved = fileName({
81
+ name: entryName,
82
+ input: entryPath
83
+ });
84
+ if (typeof resolved !== "string") throw new TypeError("`weapp.lib.fileName` 必须返回字符串。");
85
+ } else resolved = fileName.includes("[name]") ? fileName.replace(/\[name\]/g, entryName) : fileName;
86
+ const normalized = normalizeLibName(resolved);
87
+ if (!normalized) throw new Error("`weapp.lib.fileName` 解析结果为空,请检查配置。");
88
+ return normalizeLibName(removeExtensionDeep(normalized));
89
+ }
90
+ function createLibEntryFileNameResolver(libConfig) {
91
+ if (!libConfig.fileName) return;
92
+ return (chunkInfo) => {
93
+ return `${resolveOutputBase({
94
+ entryName: chunkInfo.name,
95
+ entryPath: chunkInfo.facadeModuleId ?? "",
96
+ config: libConfig
97
+ })}.js`;
98
+ };
99
+ }
100
+ async function resolveWeappLibEntries(configService, libConfig) {
101
+ const entry = libConfig.entry;
102
+ const root = libConfig.root || configService.absoluteSrcRoot;
103
+ const preservePath = libConfig.preservePath;
104
+ const entries = [];
105
+ if (typeof entry === "string") entries.push({ path: entry });
106
+ else if (Array.isArray(entry)) for (const item of entry) entries.push({ path: item });
107
+ else if (isObject(entry)) for (const [name, value] of Object.entries(entry)) entries.push({
108
+ name,
109
+ path: value
110
+ });
111
+ if (!entries.length) throw new Error("`weapp.lib.entry` 不能为空,请配置库模式入口。");
112
+ if (typeof libConfig.fileName === "string" && !libConfig.fileName.includes("[name]") && entries.length > 1) throw new Error("`weapp.lib.fileName` 在多入口模式下必须包含 `[name]` 占位符。");
113
+ const outputNames = /* @__PURE__ */ new Set();
114
+ const resolved = [];
115
+ for (const item of entries) {
116
+ const entryPath = await resolveEntryFile(root, item.path);
117
+ if (!entryPath) throw new Error(`未找到 lib 入口文件:${item.path}`);
118
+ const relativeId = normalizeRelativePath(configService.relativeAbsoluteSrcRoot(entryPath));
119
+ const entryName = resolveEntryName({
120
+ explicitName: item.name,
121
+ preservePath,
122
+ relativeId
123
+ });
124
+ if (!entryName) throw new Error(`lib 入口解析失败:${item.path}`);
125
+ const outputBase = resolveOutputBase({
126
+ entryName,
127
+ entryPath,
128
+ config: libConfig
129
+ });
130
+ if (outputNames.has(outputBase)) throw new Error(`lib 输出路径冲突:${outputBase}`);
131
+ outputNames.add(outputBase);
132
+ const relativeBase = normalizeLibName(removeExtensionDeep(relativeId));
133
+ resolved.push({
134
+ name: entryName,
135
+ input: entryPath,
136
+ relativeBase,
137
+ outputBase
138
+ });
139
+ }
140
+ return resolved;
141
+ }
142
+ //#endregion
143
+ export { hasOwn as a, resolveWeappLibEntries as i, hasLibEntry as n, waitForBuildTasks as o, resolveWeappLibConfig as r, createLibEntryFileNameResolver as t };
@@ -0,0 +1,413 @@
1
+ import process from "node:process";
2
+ import { WEAPP_VITE_DEV_SERVER_CLOSE_KEY, WEAPP_VITE_HOST_RESTART_CONFIG_KEY } from "@weapp-core/constants";
3
+ import { AsyncLocalStorage } from "node:async_hooks";
4
+ //#region src/devLifecycle/server.ts
5
+ const serverCloseRecord = Symbol.for(WEAPP_VITE_DEV_SERVER_CLOSE_KEY);
6
+ const dispatchedRecords = /* @__PURE__ */ new WeakMap();
7
+ const dispatchedCloses = /* @__PURE__ */ new WeakMap();
8
+ function onceClose(close) {
9
+ let closing;
10
+ return () => {
11
+ if (!closing) {
12
+ const completion = Promise.withResolvers();
13
+ closing = completion.promise;
14
+ try {
15
+ completion.resolve(close());
16
+ } catch (error) {
17
+ completion.reject(error);
18
+ }
19
+ }
20
+ return closing;
21
+ };
22
+ }
23
+ function wrapUserClose(server, close, previous) {
24
+ return onceClose(async () => {
25
+ try {
26
+ await close.call(server);
27
+ } catch (error) {
28
+ try {
29
+ await previous();
30
+ } catch (cleanupError) {
31
+ if (cleanupError !== error) throw new AggregateError([error, cleanupError], "User and host close failed", { cause: error });
32
+ }
33
+ throw error;
34
+ }
35
+ });
36
+ }
37
+ function dispatchClose(record) {
38
+ const localClose = record.close;
39
+ let dispatched = dispatchedCloses.get(localClose);
40
+ if (!dispatched) {
41
+ dispatched = () => record.gate ? record.gate(localClose) : localClose();
42
+ dispatchedCloses.set(localClose, dispatched);
43
+ dispatchedRecords.set(dispatched, {
44
+ record,
45
+ close: localClose
46
+ });
47
+ }
48
+ return dispatched;
49
+ }
50
+ /** 每代宿主持有独立资源关闭入口,Vite 原生交接同时复制该记录和公共方法。 */
51
+ function getDevServerCloseRecord(server) {
52
+ const host = server;
53
+ if (host[serverCloseRecord]) return host[serverCloseRecord];
54
+ const record = { close: onceClose(server.close.bind(server)) };
55
+ host[serverCloseRecord] = record;
56
+ Object.defineProperty(host, "close", {
57
+ configurable: true,
58
+ enumerable: true,
59
+ get() {
60
+ return dispatchClose(host[serverCloseRecord]);
61
+ },
62
+ set(close) {
63
+ const incoming = dispatchedRecords.get(close);
64
+ if (incoming) {
65
+ host[serverCloseRecord] = incoming.record;
66
+ incoming.record.close = incoming.close;
67
+ } else {
68
+ const current = host[serverCloseRecord];
69
+ current.close = wrapUserClose(server, close, current.close);
70
+ }
71
+ }
72
+ });
73
+ return record;
74
+ }
75
+ /** 仅替换本代资源清理,公共退出等待边界始终留在最外层。 */
76
+ function replaceDevServerClose(server, close) {
77
+ const record = getDevServerCloseRecord(server);
78
+ const previous = record.close;
79
+ record.close = onceClose(() => close.call(server));
80
+ return previous;
81
+ }
82
+ //#endregion
83
+ //#region src/devLifecycle/shutdown.ts
84
+ const operations = new AsyncLocalStorage();
85
+ /** 获取当前开发命令的资源归属;异步回调可以继承归属,但不能继承已结束的内部操作权限。 */
86
+ function getDevShutdownScope() {
87
+ return operations.getStore()?.scope;
88
+ }
89
+ /** 开发命令统一持有退出请求、在途启动与资源释放,Vite 只能在全部收尾后结束进程。 */
90
+ var DevShutdownScope = class {
91
+ options;
92
+ requested = Promise.withResolvers();
93
+ completed = Promise.withResolvers();
94
+ pending = /* @__PURE__ */ new Set();
95
+ cleanups = /* @__PURE__ */ new Set();
96
+ errors = /* @__PURE__ */ new Set();
97
+ closing;
98
+ failure;
99
+ finished = false;
100
+ reason;
101
+ signal = this.requested.promise;
102
+ done = this.completed.promise;
103
+ constructor(options = {}) {
104
+ this.options = options;
105
+ process.on("SIGINT", this.onSigint);
106
+ process.on("SIGTERM", this.onSigterm);
107
+ process.on("disconnect", this.onDisconnect);
108
+ process.stdin?.on?.("end", this.onStdinEnd);
109
+ if (process.connected === false && typeof process.disconnect === "function") this.request("disconnect");
110
+ }
111
+ get stopping() {
112
+ return this.reason !== void 0;
113
+ }
114
+ isInternalOperation() {
115
+ const operation = operations.getStore();
116
+ return operation?.scope === this && operation.active;
117
+ }
118
+ run(phase, action) {
119
+ if (this.finished) return Promise.reject(/* @__PURE__ */ new Error("Cannot start an operation after development shutdown completed"));
120
+ const tracked = phase !== "cleanup" || !this.isInternalOperation();
121
+ const operation = {
122
+ scope: this,
123
+ phase,
124
+ active: true
125
+ };
126
+ const task = operations.run(operation, async () => {
127
+ try {
128
+ return await action();
129
+ } catch (error) {
130
+ if (this.stopping) this.errors.add(error);
131
+ throw error;
132
+ } finally {
133
+ operation.active = false;
134
+ }
135
+ });
136
+ if (tracked) {
137
+ this.pending.add(task);
138
+ task.finally(() => this.pending.delete(task)).catch(() => {});
139
+ }
140
+ return task;
141
+ }
142
+ own(cleanup) {
143
+ if (this.finished) throw new Error("Cannot acquire a resource after development shutdown completed");
144
+ this.cleanups.add(cleanup);
145
+ return () => {
146
+ this.cleanups.delete(cleanup);
147
+ };
148
+ }
149
+ request(reason = "close") {
150
+ if (!this.reason) {
151
+ this.reason = reason;
152
+ this.requested.resolve();
153
+ }
154
+ this.closing ??= Promise.resolve().then(() => this.drain());
155
+ }
156
+ async close(error) {
157
+ if (error !== void 0) this.errors.add(error);
158
+ this.request();
159
+ await this.done;
160
+ if (this.errors.size) throw this.failure;
161
+ }
162
+ onSigint = () => this.request("SIGINT");
163
+ onSigterm = () => this.request("SIGTERM");
164
+ onDisconnect = () => this.request("disconnect");
165
+ onStdinEnd = () => this.request("stdin");
166
+ async drain() {
167
+ try {
168
+ while (this.pending.size || this.cleanups.size) {
169
+ if (this.pending.size) {
170
+ const results = await Promise.allSettled([...this.pending]);
171
+ for (const result of results) if (result.status === "rejected") this.errors.add(result.reason);
172
+ continue;
173
+ }
174
+ const cleanup = [...this.cleanups].at(-1);
175
+ this.cleanups.delete(cleanup);
176
+ try {
177
+ await this.run("cleanup", cleanup);
178
+ } catch (error) {
179
+ this.errors.add(error);
180
+ }
181
+ }
182
+ if (this.errors.size) {
183
+ const errors = [...this.errors];
184
+ this.failure = errors.length === 1 ? errors[0] : new AggregateError(errors, "Development shutdown failed", { cause: errors[0] });
185
+ process.exitCode = 1;
186
+ try {
187
+ this.options.reportError?.(this.failure);
188
+ } catch (reportError) {
189
+ process.stderr?.write?.(`Development shutdown error: ${String(this.failure)}; reporting failed: ${String(reportError)}\n`);
190
+ }
191
+ } else if (!process.exitCode) process.exitCode = this.reason === "SIGINT" ? 130 : this.reason === "SIGTERM" ? 143 : 0;
192
+ } finally {
193
+ this.finished = true;
194
+ process.off("SIGINT", this.onSigint);
195
+ process.off("SIGTERM", this.onSigterm);
196
+ process.off("disconnect", this.onDisconnect);
197
+ process.stdin?.off?.("end", this.onStdinEnd);
198
+ if (process.connected) process.disconnect?.();
199
+ this.completed.resolve();
200
+ }
201
+ }
202
+ };
203
+ function createDevShutdownScope(options) {
204
+ return new DevShutdownScope(options);
205
+ }
206
+ //#endregion
207
+ //#region src/vite/lifecycle.ts
208
+ const hostLifecycleKey = Symbol.for("weapp-vite:host-lifecycle");
209
+ function createHostOperations() {
210
+ const operations = new AsyncLocalStorage();
211
+ return {
212
+ isInternal: () => operations.getStore()?.active === true,
213
+ run: (action) => {
214
+ const operation = { active: true };
215
+ return operations.run(operation, async () => {
216
+ try {
217
+ return await action();
218
+ } finally {
219
+ operation.active = false;
220
+ }
221
+ });
222
+ }
223
+ };
224
+ }
225
+ const hostData = /* @__PURE__ */ new WeakMap();
226
+ async function settleHostCleanup(tasks) {
227
+ const results = await Promise.allSettled(tasks);
228
+ const errors = [...new Set(results.flatMap((result) => result.status === "rejected" ? [result.reason] : []))];
229
+ if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Host cleanup failed");
230
+ }
231
+ async function discardRestartData(data, status) {
232
+ const entries = [...data?.values() ?? []];
233
+ data?.clear();
234
+ await settleHostCleanup(entries.map(async (entry) => await entry.dispose?.(status)));
235
+ }
236
+ /** 在配置合并后、编译准备前接管重启链;函数载体不会被 Vite 深拷贝。 */
237
+ function takeHostLifecycle(config) {
238
+ const inline = config;
239
+ const carrier = inline[WEAPP_VITE_HOST_RESTART_CONFIG_KEY];
240
+ const inherited = typeof carrier === "function" ? carrier[hostLifecycleKey] : inline[hostLifecycleKey];
241
+ if (inherited) {
242
+ delete inline[WEAPP_VITE_HOST_RESTART_CONFIG_KEY];
243
+ delete inline[hostLifecycleKey];
244
+ }
245
+ return inherited;
246
+ }
247
+ /** 需要参与配置准备的数据在 configureServer 之前读取,且只能接管一次。 */
248
+ function takeHostConfigRestartData(lifecycle, key) {
249
+ const value = lifecycle?.data.get(key)?.value;
250
+ lifecycle?.data.delete(key);
251
+ return value;
252
+ }
253
+ /** 重启附带数据仅属于这一条宿主链,不写入调用方配置或共享的进程缓存。 */
254
+ async function setHostRestartData(server, key, value, dispose) {
255
+ const data = hostData.get(server);
256
+ if (!data) throw new Error("Cannot hand off data without a bound host lifecycle");
257
+ const previous = data.outgoing.get(key);
258
+ data.outgoing.set(key, {
259
+ value,
260
+ dispose
261
+ });
262
+ await previous?.dispose?.("incomplete");
263
+ }
264
+ /** 新宿主只能接管一次;读取即释放旧链持有的引用。 */
265
+ function takeHostRestartData(server, key) {
266
+ const data = hostData.get(server)?.incoming;
267
+ const value = data?.get(key)?.value;
268
+ data?.delete(key);
269
+ return value;
270
+ }
271
+ /** 关闭等待正在替换服务器的重启,避免旧入口返回后新会话继续写出。 */
272
+ function bindHostLifecycle(server, closeSession, preparedLifecycle, isRetired, finalize) {
273
+ const nativeRestart = server.restart.bind(server);
274
+ const generation = getDevServerCloseRecord(server);
275
+ const nativeClose = generation.close;
276
+ const hostWatcher = server.watcher;
277
+ const nativeWatcherClose = hostWatcher?.close.bind(hostWatcher);
278
+ let watcherCloseTask;
279
+ const closeHostWatcher = () => watcherCloseTask ??= Promise.resolve().then(() => nativeWatcherClose?.()).then(() => {});
280
+ if (hostWatcher) hostWatcher.close = closeHostWatcher;
281
+ const scope = getDevShutdownScope();
282
+ const inlineConfig = server.config.inlineConfig;
283
+ const inherited = preparedLifecycle ?? takeHostLifecycle(inlineConfig);
284
+ const operations = inherited?.operations ?? createHostOperations();
285
+ const inheritedRestart = inherited?.restartTask;
286
+ let inheritedRestartSettled = !inheritedRestart;
287
+ inheritedRestart?.then(() => {
288
+ inheritedRestartSettled = true;
289
+ }, () => {
290
+ inheritedRestartSettled = true;
291
+ });
292
+ const data = /* @__PURE__ */ new Map();
293
+ hostData.set(server, {
294
+ incoming: inherited?.data,
295
+ outgoing: data
296
+ });
297
+ const stopping = Promise.withResolvers();
298
+ let restartTask;
299
+ let closeTask;
300
+ let retired = false;
301
+ for (const environment of Object.values(server.environments ?? {})) {
302
+ const listen = environment.listen.bind(environment);
303
+ environment.listen = async (...args) => {
304
+ if (!retired && !isRetired?.()) await listen(...args);
305
+ };
306
+ }
307
+ const replacements = /* @__PURE__ */ new Set();
308
+ let restartCleanupFailure;
309
+ const discardRestartResources = async (status) => {
310
+ const active = getDevServerCloseRecord(server);
311
+ const abandoned = [...replacements].filter((replacement) => replacement !== active);
312
+ replacements.clear();
313
+ await settleHostCleanup([discardRestartData(data, status), ...abandoned.map((replacement) => Promise.resolve().then(() => replacement.close()))]).catch((error) => {
314
+ restartCleanupFailure ??= { error };
315
+ throw error;
316
+ });
317
+ };
318
+ const closeResources = async () => {
319
+ retired = true;
320
+ stopping.resolve();
321
+ const pendingRestart = restartTask;
322
+ const sessionCleanup = settleHostCleanup([
323
+ Promise.resolve().then(() => closeSession("close")),
324
+ discardRestartData(data, "incomplete"),
325
+ discardRestartData(inherited?.data, "incomplete")
326
+ ]);
327
+ const hostCleanup = (async () => {
328
+ await sessionCleanup.catch(() => {});
329
+ await pendingRestart?.catch(() => {});
330
+ const current = getDevServerCloseRecord(server);
331
+ await settleHostCleanup([closeHostWatcher(), Promise.resolve().then(() => current !== generation ? current.close() : nativeClose())]);
332
+ })();
333
+ const restartCleanup = (async () => {
334
+ await pendingRestart;
335
+ if (restartCleanupFailure) throw restartCleanupFailure.error;
336
+ })();
337
+ await settleHostCleanup([(async () => {
338
+ await settleHostCleanup([sessionCleanup, hostCleanup]);
339
+ if (!restartCleanupFailure && inheritedRestartSettled) await finalize?.();
340
+ })(), restartCleanup]);
341
+ };
342
+ const closeLocal = () => operations.run(closeResources);
343
+ const close = () => closeTask ??= scope ? scope.run("cleanup", closeLocal) : closeLocal();
344
+ const lifecycle = {
345
+ data,
346
+ operations,
347
+ close: inherited?.close ?? close,
348
+ registerReplacement(replacement) {
349
+ replacements.delete(getDevServerCloseRecord(server));
350
+ replacements.add(replacement);
351
+ },
352
+ get restartTask() {
353
+ return restartTask;
354
+ }
355
+ };
356
+ replaceDevServerClose(server, close);
357
+ if (inherited) {
358
+ const previousGate = generation.gate;
359
+ generation.gate = (closeResources) => {
360
+ const dispatch = () => operations.isInternal() ? closeResources() : inherited.close();
361
+ return previousGate ? previousGate(dispatch) : dispatch();
362
+ };
363
+ }
364
+ inherited?.registerReplacement(generation);
365
+ server.restart = (force) => {
366
+ if (closeTask || scope?.stopping) return close();
367
+ const restart = async () => {
368
+ if (inheritedRestart) {
369
+ await Promise.race([inheritedRestart, stopping.promise]);
370
+ if (closeTask || scope?.stopping) return;
371
+ }
372
+ try {
373
+ retired = true;
374
+ await closeSession("restart");
375
+ if (closeTask || scope?.stopping) return;
376
+ await closeHostWatcher();
377
+ if (closeTask || scope?.stopping) return;
378
+ const config = server.config;
379
+ const carrier = Object.assign(() => {}, { [hostLifecycleKey]: lifecycle });
380
+ const restartConfig = {
381
+ ...config.inlineConfig,
382
+ [WEAPP_VITE_HOST_RESTART_CONFIG_KEY]: carrier
383
+ };
384
+ const restartHostConfig = {
385
+ ...config,
386
+ inlineConfig: restartConfig
387
+ };
388
+ server.config = restartHostConfig;
389
+ try {
390
+ await nativeRestart(force);
391
+ if (getDevServerCloseRecord(server) === generation) throw new Error("[weapp-vite] Vite 重启未完成替换宿主交接,请查看原始初始化错误。");
392
+ } finally {
393
+ delete restartConfig[WEAPP_VITE_HOST_RESTART_CONFIG_KEY];
394
+ if (server.config === restartHostConfig) server.config = config;
395
+ }
396
+ } catch (error) {
397
+ try {
398
+ await discardRestartResources("failed");
399
+ } catch (cleanupError) {
400
+ throw new AggregateError([error, cleanupError], "Host restart and resource cleanup failed", { cause: error });
401
+ }
402
+ throw error;
403
+ }
404
+ await discardRestartResources("incomplete");
405
+ };
406
+ const runRestart = () => operations.run(restart);
407
+ return restartTask ??= (scope ? scope.run("restart", runRestart) : runRestart()).finally(() => {
408
+ restartTask = void 0;
409
+ });
410
+ };
411
+ }
412
+ //#endregion
413
+ export { takeHostRestartData as a, getDevServerCloseRecord as c, takeHostLifecycle as i, replaceDevServerClose as l, setHostRestartData as n, createDevShutdownScope as o, takeHostConfigRestartData as r, getDevShutdownScope as s, bindHostLifecycle as t };