weapp-vite 7.4.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -1
- package/bin/bootstrap.js +14 -1
- package/dist/adapters-CcHrsYaj.mjs +1 -0
- package/dist/analyze-ZJUvEdaY.mjs +248 -0
- package/dist/auto-import-components/resolvers.mjs +1 -2
- package/dist/auto-import-presets/wevu-router.mjs +1 -2
- package/dist/auto-import-presets/wevu.mjs +1 -2
- package/dist/auto-routes.mjs +2 -1
- package/dist/budget-BD7VqLCl.d.mts +178 -0
- package/dist/chunkStrategy-DRA5WpB-.mjs +1436 -0
- package/dist/cli-acceptance.d.mts +1 -0
- package/dist/cli-acceptance.mjs +21 -0
- package/dist/cli.mjs +1420 -1554
- package/dist/compatibility.mjs +1 -2
- package/dist/{config-Dbvj5yK7.d.mts → config-V0L-IAJf.d.mts} +87 -30
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +1 -1
- package/dist/{constants-WOsG3Eqd.mjs → constants-DEZdcsMn.mjs} +1 -1
- package/dist/{createContext-UOEgeYnA.mjs → createCompilerContextInstance-DJH_P_nZ.mjs} +31278 -32148
- package/dist/createContext-BqYzHhY9.mjs +12 -0
- package/dist/dashboard/analyze.d.mts +48 -0
- package/dist/dashboard/analyze.mjs +1 -0
- package/dist/dashboard/vite.d.mts +1 -1
- package/dist/dashboard-DvqF3Key.mjs +1842 -0
- package/dist/dashboard.d.mts +3 -2
- package/dist/dashboard.mjs +1 -2
- package/dist/dashboardViteBridge-Dy3nAD4m.mjs +299 -0
- package/dist/dev-fR5GiJRO.mjs +63 -0
- package/dist/devProvider-BGBkw28J.mjs +1050 -0
- package/dist/docs/README.md +51 -1
- package/dist/docs/ai-workflows.md +4 -0
- package/dist/docs/doctor.md +38 -0
- package/dist/docs/getting-started.md +3 -1
- package/dist/docs/index.md +3 -1
- package/dist/docs/mcp.md +94 -1
- package/dist/docs/testing.md +29 -2
- package/dist/docs/troubleshooting.md +8 -0
- package/dist/docs/uni-app-component-libraries.md +8 -7
- package/dist/docs/upload.md +40 -3
- package/dist/docs/vite-plugin.md +171 -0
- package/dist/docs/vue-sfc.md +19 -0
- package/dist/docs/weapp-config.md +54 -0
- package/dist/docs/wevu-authoring.md +10 -0
- package/dist/doctor-worker.d.mts +1 -0
- package/dist/doctor-worker.mjs +59 -0
- package/dist/doctor.d.mts +144 -0
- package/dist/doctor.mjs +848 -0
- package/dist/eslint.mjs +1 -2
- package/dist/file-DRb4eWqw.mjs +1 -0
- package/dist/{file-giE9UMZa.mjs → file-sC3jD7Fh.mjs} +15 -9
- package/dist/files-BqxFIPRp.mjs +45 -0
- package/dist/getInstance-DiGSzBNI.mjs +28 -0
- package/dist/getInstance-SiE6WZRh.mjs +1 -0
- package/dist/index-C9HjUX5c.d.mts +741 -0
- package/dist/index.d.mts +10 -8
- package/dist/index.mjs +3 -2
- package/dist/json.d.mts +1 -1
- package/dist/json.mjs +1 -2
- package/dist/lifecycle-BROTlwSL.mjs +320 -0
- package/dist/loadConfig-C3BQhz7F.mjs +59 -0
- package/dist/loadConfig-VGtBF4qm.mjs +1 -0
- package/dist/logger-DGn5iEVN.mjs +1 -0
- package/dist/{mcp-BG6TliEg.mjs → mcp-Cj8Maqo6.mjs} +16 -7
- package/dist/mcp-D3Yh24Cj.mjs +529 -0
- package/dist/mcp.d.mts +6 -3
- package/dist/mcp.mjs +1 -2
- package/dist/package-7swhyLmf.mjs +91 -0
- package/dist/path-doV773b7.mjs +103 -0
- package/dist/{platform-DTWs5QRi.mjs → platform-CnkySBKz.mjs} +1 -1
- package/dist/processCleanup-B6KA30Zc.mjs +77 -0
- package/dist/protocol-vg8HGJ4n.mjs +138 -0
- package/dist/{resolvers-icNxkpcy.mjs → resolvers-Dod-euqX.mjs} +4 -1
- package/dist/resolvers.mjs +1 -2
- package/dist/runtime.mjs +1 -2
- package/dist/session-PskhD-nZ.mjs +390 -0
- package/dist/test.d.mts +1 -0
- package/dist/test.mjs +201 -44
- package/dist/types.d.mts +2 -2
- package/dist/{upload-D0RcEWrq.mjs → upload-D4msblBf.mjs} +174 -15
- package/dist/upload-worker.mjs +136 -3
- package/dist/utils-CJSCgEj6.mjs +1094 -0
- package/dist/vite.d.mts +9 -0
- package/dist/vite.mjs +270 -0
- package/dist/volar.d.mts +2 -2
- package/dist/web-apis.mjs +1 -2
- package/package.json +67 -41
- package/dist/adapters-BwnMMIZR.mjs +0 -2
- package/dist/dashboard-BzaVesmQ.mjs +0 -558
- package/dist/file-D19nbDoN.mjs +0 -2
- package/dist/getInstance-CYF1vl5l.mjs +0 -2
- package/dist/index-DbqVupg0.d.mts +0 -246
- 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-
|
|
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, Gn as JsonConfig, Gr as WebPlatform, Hr as WeappViteTargetDescriptor, I as RolldownPlugin, Ir as resolveWeappViteHostMeta, Jn as JsonMergeStage, Jr as isWebPlatform, Kn as JsonMergeContext, 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, Yn as JsonMergeStrategy, 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, qn as JsonMergeFunction, 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-V0L-IAJf.mjs";
|
|
2
2
|
import { t as WeappI18nConfig } from "./types-CgZn5X6j.mjs";
|
|
3
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/
|
|
5
|
-
interface
|
|
6
|
-
key?: string;
|
|
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
|
-
|
|
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 {
|
|
4
|
+
import { a as getSupportedWeappViteTargetDescriptors, i as getSupportedWeappVitePlatforms, o as isWebPlatform, r as WEB_PLATFORM_ALIASES, s as resolveWeappViteTarget } from "./createCompilerContextInstance-DJH_P_nZ.mjs";
|
|
5
|
+
import { t as createCompilerContext } from "./createContext-BqYzHhY9.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-
|
|
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-V0L-IAJf.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
|
-
|
|
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,320 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
+
//#region src/devLifecycle/server.ts
|
|
4
|
+
const serverCloseRecord = Symbol("weapp-vite:dev-server-close");
|
|
5
|
+
const dispatchedRecords = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const dispatchedCloses = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
function onceClose(close) {
|
|
8
|
+
let closing;
|
|
9
|
+
return () => {
|
|
10
|
+
if (!closing) {
|
|
11
|
+
const completion = Promise.withResolvers();
|
|
12
|
+
closing = completion.promise;
|
|
13
|
+
try {
|
|
14
|
+
completion.resolve(close());
|
|
15
|
+
} catch (error) {
|
|
16
|
+
completion.reject(error);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return closing;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function wrapUserClose(server, close, previous) {
|
|
23
|
+
return onceClose(async () => {
|
|
24
|
+
try {
|
|
25
|
+
await close.call(server);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
try {
|
|
28
|
+
await previous();
|
|
29
|
+
} catch (cleanupError) {
|
|
30
|
+
if (cleanupError !== error) throw new AggregateError([error, cleanupError], "User and host close failed", { cause: error });
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function dispatchClose(record) {
|
|
37
|
+
const localClose = record.close;
|
|
38
|
+
let dispatched = dispatchedCloses.get(localClose);
|
|
39
|
+
if (!dispatched) {
|
|
40
|
+
dispatched = () => record.gate ? record.gate(localClose) : localClose();
|
|
41
|
+
dispatchedCloses.set(localClose, dispatched);
|
|
42
|
+
dispatchedRecords.set(dispatched, {
|
|
43
|
+
record,
|
|
44
|
+
close: localClose
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return dispatched;
|
|
48
|
+
}
|
|
49
|
+
/** 每代宿主持有独立资源关闭入口,Vite 原生交接同时复制该记录和公共方法。 */
|
|
50
|
+
function getDevServerCloseRecord(server) {
|
|
51
|
+
const host = server;
|
|
52
|
+
if (host[serverCloseRecord]) return host[serverCloseRecord];
|
|
53
|
+
const record = { close: onceClose(server.close.bind(server)) };
|
|
54
|
+
host[serverCloseRecord] = record;
|
|
55
|
+
Object.defineProperty(host, "close", {
|
|
56
|
+
configurable: true,
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get() {
|
|
59
|
+
return dispatchClose(host[serverCloseRecord]);
|
|
60
|
+
},
|
|
61
|
+
set(close) {
|
|
62
|
+
const incoming = dispatchedRecords.get(close);
|
|
63
|
+
if (incoming) {
|
|
64
|
+
host[serverCloseRecord] = incoming.record;
|
|
65
|
+
incoming.record.close = incoming.close;
|
|
66
|
+
} else {
|
|
67
|
+
const current = host[serverCloseRecord];
|
|
68
|
+
current.close = wrapUserClose(server, close, current.close);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return record;
|
|
73
|
+
}
|
|
74
|
+
/** 仅替换本代资源清理,公共退出等待边界始终留在最外层。 */
|
|
75
|
+
function replaceDevServerClose(server, close) {
|
|
76
|
+
const record = getDevServerCloseRecord(server);
|
|
77
|
+
const previous = record.close;
|
|
78
|
+
record.close = onceClose(() => close.call(server));
|
|
79
|
+
return previous;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/devLifecycle/shutdown.ts
|
|
83
|
+
const operations = new AsyncLocalStorage();
|
|
84
|
+
/** 获取当前开发命令的资源归属;异步回调可以继承归属,但不能继承已结束的内部操作权限。 */
|
|
85
|
+
function getDevShutdownScope() {
|
|
86
|
+
return operations.getStore()?.scope;
|
|
87
|
+
}
|
|
88
|
+
/** 开发命令统一持有退出请求、在途启动与资源释放,Vite 只能在全部收尾后结束进程。 */
|
|
89
|
+
var DevShutdownScope = class {
|
|
90
|
+
options;
|
|
91
|
+
requested = Promise.withResolvers();
|
|
92
|
+
completed = Promise.withResolvers();
|
|
93
|
+
pending = /* @__PURE__ */ new Set();
|
|
94
|
+
cleanups = /* @__PURE__ */ new Set();
|
|
95
|
+
errors = /* @__PURE__ */ new Set();
|
|
96
|
+
closing;
|
|
97
|
+
failure;
|
|
98
|
+
finished = false;
|
|
99
|
+
reason;
|
|
100
|
+
signal = this.requested.promise;
|
|
101
|
+
done = this.completed.promise;
|
|
102
|
+
constructor(options = {}) {
|
|
103
|
+
this.options = options;
|
|
104
|
+
process.on("SIGINT", this.onSigint);
|
|
105
|
+
process.on("SIGTERM", this.onSigterm);
|
|
106
|
+
process.on("disconnect", this.onDisconnect);
|
|
107
|
+
process.stdin?.on?.("end", this.onStdinEnd);
|
|
108
|
+
if (process.connected === false) this.request("disconnect");
|
|
109
|
+
}
|
|
110
|
+
get stopping() {
|
|
111
|
+
return this.reason !== void 0;
|
|
112
|
+
}
|
|
113
|
+
isInternalOperation() {
|
|
114
|
+
const operation = operations.getStore();
|
|
115
|
+
return operation?.scope === this && operation.active;
|
|
116
|
+
}
|
|
117
|
+
run(phase, action) {
|
|
118
|
+
if (this.finished) return Promise.reject(/* @__PURE__ */ new Error("Cannot start an operation after development shutdown completed"));
|
|
119
|
+
const tracked = phase !== "cleanup" || !this.isInternalOperation();
|
|
120
|
+
const operation = {
|
|
121
|
+
scope: this,
|
|
122
|
+
phase,
|
|
123
|
+
active: true
|
|
124
|
+
};
|
|
125
|
+
const task = operations.run(operation, async () => {
|
|
126
|
+
try {
|
|
127
|
+
return await action();
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (this.stopping) this.errors.add(error);
|
|
130
|
+
throw error;
|
|
131
|
+
} finally {
|
|
132
|
+
operation.active = false;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
if (tracked) {
|
|
136
|
+
this.pending.add(task);
|
|
137
|
+
task.finally(() => this.pending.delete(task)).catch(() => {});
|
|
138
|
+
}
|
|
139
|
+
return task;
|
|
140
|
+
}
|
|
141
|
+
own(cleanup) {
|
|
142
|
+
if (this.finished) throw new Error("Cannot acquire a resource after development shutdown completed");
|
|
143
|
+
this.cleanups.add(cleanup);
|
|
144
|
+
return () => {
|
|
145
|
+
this.cleanups.delete(cleanup);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
request(reason = "close") {
|
|
149
|
+
if (!this.reason) {
|
|
150
|
+
this.reason = reason;
|
|
151
|
+
this.requested.resolve();
|
|
152
|
+
}
|
|
153
|
+
this.closing ??= Promise.resolve().then(() => this.drain());
|
|
154
|
+
}
|
|
155
|
+
async close(error) {
|
|
156
|
+
if (error !== void 0) this.errors.add(error);
|
|
157
|
+
this.request();
|
|
158
|
+
await this.done;
|
|
159
|
+
if (this.errors.size) throw this.failure;
|
|
160
|
+
}
|
|
161
|
+
onSigint = () => this.request("SIGINT");
|
|
162
|
+
onSigterm = () => this.request("SIGTERM");
|
|
163
|
+
onDisconnect = () => this.request("disconnect");
|
|
164
|
+
onStdinEnd = () => this.request("stdin");
|
|
165
|
+
async drain() {
|
|
166
|
+
try {
|
|
167
|
+
while (this.pending.size || this.cleanups.size) {
|
|
168
|
+
if (this.pending.size) {
|
|
169
|
+
const results = await Promise.allSettled([...this.pending]);
|
|
170
|
+
for (const result of results) if (result.status === "rejected") this.errors.add(result.reason);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const cleanup = [...this.cleanups].at(-1);
|
|
174
|
+
this.cleanups.delete(cleanup);
|
|
175
|
+
try {
|
|
176
|
+
await this.run("cleanup", cleanup);
|
|
177
|
+
} catch (error) {
|
|
178
|
+
this.errors.add(error);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (this.errors.size) {
|
|
182
|
+
const errors = [...this.errors];
|
|
183
|
+
this.failure = errors.length === 1 ? errors[0] : new AggregateError(errors, "Development shutdown failed", { cause: errors[0] });
|
|
184
|
+
process.exitCode = 1;
|
|
185
|
+
try {
|
|
186
|
+
this.options.reportError?.(this.failure);
|
|
187
|
+
} catch (reportError) {
|
|
188
|
+
process.stderr?.write?.(`Development shutdown error: ${String(this.failure)}; reporting failed: ${String(reportError)}\n`);
|
|
189
|
+
}
|
|
190
|
+
} else if (!process.exitCode) process.exitCode = this.reason === "SIGINT" ? 130 : this.reason === "SIGTERM" ? 143 : 0;
|
|
191
|
+
} finally {
|
|
192
|
+
this.finished = true;
|
|
193
|
+
process.off("SIGINT", this.onSigint);
|
|
194
|
+
process.off("SIGTERM", this.onSigterm);
|
|
195
|
+
process.off("disconnect", this.onDisconnect);
|
|
196
|
+
process.stdin?.off?.("end", this.onStdinEnd);
|
|
197
|
+
if (process.connected) process.disconnect?.();
|
|
198
|
+
this.completed.resolve();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
function createDevShutdownScope(options) {
|
|
203
|
+
return new DevShutdownScope(options);
|
|
204
|
+
}
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/vite/lifecycle.ts
|
|
207
|
+
const hostLifecycleKey = Symbol.for("weapp-vite:host-lifecycle");
|
|
208
|
+
const hostData = /* @__PURE__ */ new WeakMap();
|
|
209
|
+
async function settleHostCleanup(tasks) {
|
|
210
|
+
const errors = (await Promise.allSettled(tasks)).flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
211
|
+
if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Host cleanup failed");
|
|
212
|
+
}
|
|
213
|
+
async function discardRestartData(data, status) {
|
|
214
|
+
const entries = [...data?.values() ?? []];
|
|
215
|
+
data?.clear();
|
|
216
|
+
await settleHostCleanup(entries.map(async (entry) => await entry.dispose?.(status)));
|
|
217
|
+
}
|
|
218
|
+
/** 重启附带数据仅属于这一条宿主链,不写入调用方配置或共享的进程缓存。 */
|
|
219
|
+
async function setHostRestartData(server, key, value, dispose) {
|
|
220
|
+
const data = hostData.get(server);
|
|
221
|
+
if (!data) throw new Error("Cannot hand off data without a bound host lifecycle");
|
|
222
|
+
const previous = data.outgoing.get(key);
|
|
223
|
+
data.outgoing.set(key, {
|
|
224
|
+
value,
|
|
225
|
+
dispose
|
|
226
|
+
});
|
|
227
|
+
await previous?.dispose?.("incomplete");
|
|
228
|
+
}
|
|
229
|
+
/** 新宿主只能接管一次;读取即释放旧链持有的引用。 */
|
|
230
|
+
function takeHostRestartData(server, key) {
|
|
231
|
+
const data = hostData.get(server)?.incoming;
|
|
232
|
+
const value = data?.get(key)?.value;
|
|
233
|
+
data?.delete(key);
|
|
234
|
+
return value;
|
|
235
|
+
}
|
|
236
|
+
/** 关闭等待正在替换服务器的重启,避免旧入口返回后新会话继续写出。 */
|
|
237
|
+
function bindHostLifecycle(server, closeSession) {
|
|
238
|
+
const nativeRestart = server.restart.bind(server);
|
|
239
|
+
const generation = getDevServerCloseRecord(server);
|
|
240
|
+
const nativeClose = generation.close;
|
|
241
|
+
const scope = getDevShutdownScope();
|
|
242
|
+
const inlineConfig = server.config.inlineConfig;
|
|
243
|
+
const inherited = inlineConfig[hostLifecycleKey];
|
|
244
|
+
const inheritedRestart = inherited?.restartTask;
|
|
245
|
+
const data = /* @__PURE__ */ new Map();
|
|
246
|
+
hostData.set(server, {
|
|
247
|
+
incoming: inherited?.data,
|
|
248
|
+
outgoing: data
|
|
249
|
+
});
|
|
250
|
+
delete inlineConfig[hostLifecycleKey];
|
|
251
|
+
const stopping = Promise.withResolvers();
|
|
252
|
+
let restartTask;
|
|
253
|
+
let closeTask;
|
|
254
|
+
const lifecycle = {
|
|
255
|
+
data,
|
|
256
|
+
get restartTask() {
|
|
257
|
+
return restartTask;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const closeResources = async () => {
|
|
261
|
+
stopping.resolve();
|
|
262
|
+
const sessionCleanup = settleHostCleanup([
|
|
263
|
+
Promise.resolve().then(closeSession),
|
|
264
|
+
discardRestartData(data, "incomplete"),
|
|
265
|
+
discardRestartData(inherited?.data, "incomplete")
|
|
266
|
+
]);
|
|
267
|
+
await settleHostCleanup([sessionCleanup, (async () => {
|
|
268
|
+
await sessionCleanup.catch(() => {});
|
|
269
|
+
await restartTask?.catch(() => {});
|
|
270
|
+
const current = getDevServerCloseRecord(server);
|
|
271
|
+
if (current !== generation) await current.close();
|
|
272
|
+
else await nativeClose();
|
|
273
|
+
})()]);
|
|
274
|
+
};
|
|
275
|
+
const close = () => closeTask ??= scope ? scope.run("cleanup", closeResources) : closeResources();
|
|
276
|
+
replaceDevServerClose(server, close);
|
|
277
|
+
server.restart = (force) => {
|
|
278
|
+
if (closeTask || scope?.stopping) return close();
|
|
279
|
+
const restart = async () => {
|
|
280
|
+
if (inheritedRestart) {
|
|
281
|
+
await Promise.race([inheritedRestart, stopping.promise]);
|
|
282
|
+
if (closeTask || scope?.stopping) return;
|
|
283
|
+
}
|
|
284
|
+
try {
|
|
285
|
+
await closeSession();
|
|
286
|
+
if (closeTask || scope?.stopping) return;
|
|
287
|
+
const config = server.config;
|
|
288
|
+
const restartConfig = {
|
|
289
|
+
...config.inlineConfig,
|
|
290
|
+
[hostLifecycleKey]: lifecycle
|
|
291
|
+
};
|
|
292
|
+
const restartHostConfig = {
|
|
293
|
+
...config,
|
|
294
|
+
inlineConfig: restartConfig
|
|
295
|
+
};
|
|
296
|
+
server.config = restartHostConfig;
|
|
297
|
+
try {
|
|
298
|
+
await nativeRestart(force);
|
|
299
|
+
} finally {
|
|
300
|
+
delete restartConfig[hostLifecycleKey];
|
|
301
|
+
if (server.config === restartHostConfig) server.config = config;
|
|
302
|
+
}
|
|
303
|
+
} catch (error) {
|
|
304
|
+
try {
|
|
305
|
+
await discardRestartData(data, "failed");
|
|
306
|
+
} catch (cleanupError) {
|
|
307
|
+
throw new AggregateError([error, cleanupError], "Host restart and handoff cleanup failed", { cause: error });
|
|
308
|
+
}
|
|
309
|
+
throw error;
|
|
310
|
+
} finally {
|
|
311
|
+
await discardRestartData(data, "incomplete");
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
return restartTask ??= (scope ? scope.run("restart", restart) : restart()).finally(() => {
|
|
315
|
+
restartTask = void 0;
|
|
316
|
+
});
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
export { getDevShutdownScope as a, createDevShutdownScope as i, setHostRestartData as n, getDevServerCloseRecord as o, takeHostRestartData as r, replaceDevServerClose as s, bindHostLifecycle as t };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { E as loadViteConfigFile, M as createCjsConfigLoadError, t as resolveWeappConfigFile } from "./utils-CJSCgEj6.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
import { defu } from "@weapp-core/shared";
|
|
5
|
+
//#region src/cli/loadConfig.ts
|
|
6
|
+
async function loadConfig(configFile) {
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
let resolvedConfigFile = configFile;
|
|
9
|
+
if (resolvedConfigFile && !path.isAbsolute(resolvedConfigFile)) resolvedConfigFile = path.resolve(cwd, resolvedConfigFile);
|
|
10
|
+
const configEnv = {
|
|
11
|
+
command: "serve",
|
|
12
|
+
mode: "development"
|
|
13
|
+
};
|
|
14
|
+
let loaded;
|
|
15
|
+
try {
|
|
16
|
+
loaded = await loadViteConfigFile(configEnv, resolvedConfigFile, cwd, void 0, void 0, "runner");
|
|
17
|
+
} catch (error) {
|
|
18
|
+
const cjsError = createCjsConfigLoadError({
|
|
19
|
+
error,
|
|
20
|
+
configPath: resolvedConfigFile,
|
|
21
|
+
cwd
|
|
22
|
+
});
|
|
23
|
+
if (cjsError) throw cjsError;
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
const weappConfigFilePath = await resolveWeappConfigFile({
|
|
27
|
+
root: cwd,
|
|
28
|
+
specified: resolvedConfigFile
|
|
29
|
+
});
|
|
30
|
+
let weappLoaded;
|
|
31
|
+
if (weappConfigFilePath) {
|
|
32
|
+
const normalizedWeappPath = path.resolve(weappConfigFilePath);
|
|
33
|
+
const normalizedLoadedPath = loaded?.path ? path.resolve(loaded.path) : void 0;
|
|
34
|
+
if (normalizedLoadedPath && normalizedLoadedPath === normalizedWeappPath) weappLoaded = loaded;
|
|
35
|
+
else try {
|
|
36
|
+
weappLoaded = await loadViteConfigFile(configEnv, weappConfigFilePath, cwd, void 0, void 0, "runner");
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const cjsError = createCjsConfigLoadError({
|
|
39
|
+
error,
|
|
40
|
+
configPath: weappConfigFilePath,
|
|
41
|
+
cwd
|
|
42
|
+
});
|
|
43
|
+
if (cjsError) throw cjsError;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!loaded && !weappLoaded) return;
|
|
48
|
+
const config = weappLoaded?.config ? defu(weappLoaded.config, loaded?.config ?? {}) : loaded?.config ?? {};
|
|
49
|
+
const dependencySet = /* @__PURE__ */ new Set();
|
|
50
|
+
for (const dependency of loaded?.dependencies ?? []) dependencySet.add(dependency);
|
|
51
|
+
for (const dependency of weappLoaded?.dependencies ?? []) dependencySet.add(dependency);
|
|
52
|
+
return {
|
|
53
|
+
config,
|
|
54
|
+
path: weappLoaded?.path ?? loaded?.path ?? resolvedConfigFile,
|
|
55
|
+
dependencies: Array.from(dependencySet)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { loadConfig as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as loadConfig } from "./loadConfig-C3BQhz7F.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { configureLogger as n, default as r, colors as t } from "@weapp-core/logger";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { r as logger_default } from "./logger-
|
|
1
|
+
import { r as logger_default } from "./logger-DGn5iEVN.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import {
|
|
3
|
+
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT } from "@weapp-core/constants";
|
|
4
4
|
import { determineAgent } from "@vercel/detect-agent";
|
|
5
|
-
import { DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, DEFAULT_RUNTIME_REST_ENDPOINT, createWeappViteMcpServer, startWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
6
5
|
//#region src/aiEnvironment.ts
|
|
7
6
|
const AI_ENV_KEYS = [
|
|
8
7
|
"CODEX_HOME",
|
|
@@ -74,6 +73,11 @@ function resolveBooleanLikeEnv(value) {
|
|
|
74
73
|
}
|
|
75
74
|
//#endregion
|
|
76
75
|
//#region src/mcp.ts
|
|
76
|
+
/** 创建服务时才加载 MCP 运行时;配置解析与公开常量保持同步。 */
|
|
77
|
+
async function createWeappViteMcpServer(options) {
|
|
78
|
+
const { createWeappViteMcpServer } = await import("@weapp-vite/mcp");
|
|
79
|
+
return createWeappViteMcpServer(options);
|
|
80
|
+
}
|
|
77
81
|
function normalizeEndpoint(input) {
|
|
78
82
|
const value = typeof input === "string" ? input.trim() : "";
|
|
79
83
|
if (!value) return DEFAULT_MCP_ENDPOINT;
|
|
@@ -115,9 +119,14 @@ function resolveWeappMcpConfig(config, options = {}) {
|
|
|
115
119
|
restEndpoint: record.restEndpoint === false ? false : normalizeEndpoint(record.restEndpoint ?? DEFAULT_RUNTIME_REST_ENDPOINT)
|
|
116
120
|
};
|
|
117
121
|
}
|
|
118
|
-
async function startWeappViteMcpServer
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
async function startWeappViteMcpServer(options) {
|
|
123
|
+
const [{ startWeappViteMcpServer: startMcpServer }, { connectMiniProgram, prepareAcceptanceProject, resolveAutomatorSessionOptions }] = await Promise.all([import("@weapp-vite/mcp"), import("weapp-ide-cli")]);
|
|
124
|
+
return startMcpServer({
|
|
125
|
+
runtimeHooks: {
|
|
126
|
+
connectMiniProgram,
|
|
127
|
+
resolveSessionOptions: resolveAutomatorSessionOptions,
|
|
128
|
+
prepareProject: prepareAcceptanceProject
|
|
129
|
+
},
|
|
121
130
|
...options,
|
|
122
131
|
onReady: options?.onReady ?? ((message) => {
|
|
123
132
|
logger_default.info(message);
|
|
@@ -125,4 +134,4 @@ async function startWeappViteMcpServer$1(options) {
|
|
|
125
134
|
});
|
|
126
135
|
}
|
|
127
136
|
//#endregion
|
|
128
|
-
export { createWeappViteMcpServer as a, startWeappViteMcpServer
|
|
137
|
+
export { createWeappViteMcpServer as a, startWeappViteMcpServer as c, DEFAULT_RUNTIME_REST_ENDPOINT as i, detectAiDevelopmentEnvironment as l, DEFAULT_MCP_HOST as n, resolveProjectMcpPort as o, DEFAULT_MCP_PORT as r, resolveWeappMcpConfig as s, DEFAULT_MCP_ENDPOINT as t };
|