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/dashboard.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
|
|
1
|
+
import { a as AnalyzeSubpackagesResult } from "./budget-BD7VqLCl.mjs";
|
|
2
|
+
import { A as DashboardInvestigationReceiptInput, B as DashboardRuntimeEventInput, C as DashboardClaimInvestigationRequest, D as DashboardInvestigationClaim, E as DashboardInvestigation, F as DashboardObjectMeasurements, G as DashboardFileReadRequest, H as DashboardRuntimeEventsPage, I as DashboardProposeInvestigationRequest, J as DashboardArtifactFiles, K as DashboardContentRoots, L as DashboardReportIdentity, M as DashboardInvestigationStatus, N as DashboardInvestigationTarget, O as DashboardInvestigationProposal, P as DashboardInvestigationsState, R as DashboardVerifyInvestigationRequest, S as DashboardAuthorizeInvestigationRequest, T as DashboardCreateInvestigationRequest, U as DashboardRuntimeEventsQueryRequest, V as DashboardRuntimeEventProfile, W as DashboardFileContent, Y as createDashboardArtifactSnapshot, _ as DashboardAnalyzePage, a as createAnalyzeDashboardDevframe, b as DashboardAnalyzePayloadsDescriptor, c as DashboardAnalyzeSummary, d as DashboardComparisonPage, f as DashboardComparisonQuery, g as DashboardPackagesQuery, h as DashboardPackagesPage, i as DashboardDevframeState, j as DashboardInvestigationRequest, k as DashboardInvestigationProposalInput, l as DashboardArtifactsPage, m as DashboardModulesQuery, n as CreateAnalyzeDashboardDevframeOptions, o as resolveDashboardClientAssets, p as DashboardModulesPage, q as DashboardArtifactFile, r as DashboardAnalyzeSnapshot, s as DashboardAnalyzeQuery, t as AnalyzeDashboardDevframeController, u as DashboardArtifactsQuery, v as DashboardAnalyzePageRequest, w as DashboardCompleteInvestigationRequest, x as DashboardAgentInvestigationRequest, y as DashboardAnalyzePayloadDescriptor, z as DashboardRuntimeEvent } from "./index-C9HjUX5c.mjs";
|
|
3
|
+
export { AnalyzeDashboardDevframeController, type AnalyzeSubpackagesResult, CreateAnalyzeDashboardDevframeOptions, type DashboardAgentInvestigationRequest, type DashboardAnalyzePage, type DashboardAnalyzePageRequest, type DashboardAnalyzePayloadDescriptor, type DashboardAnalyzePayloadsDescriptor, type DashboardAnalyzeQuery, DashboardAnalyzeSnapshot, type DashboardAnalyzeSummary, type DashboardArtifactFile, type DashboardArtifactFiles, type DashboardArtifactsPage, type DashboardArtifactsQuery, type DashboardAuthorizeInvestigationRequest, type DashboardClaimInvestigationRequest, type DashboardComparisonPage, type DashboardComparisonQuery, type DashboardCompleteInvestigationRequest, type DashboardContentRoots, type DashboardCreateInvestigationRequest, DashboardDevframeState, type DashboardFileContent, type DashboardFileReadRequest, type DashboardInvestigation, type DashboardInvestigationClaim, type DashboardInvestigationProposal, type DashboardInvestigationProposalInput, type DashboardInvestigationReceiptInput, type DashboardInvestigationRequest, type DashboardInvestigationStatus, type DashboardInvestigationTarget, type DashboardInvestigationsState, type DashboardModulesPage, type DashboardModulesQuery, type DashboardObjectMeasurements, type DashboardPackagesPage, type DashboardPackagesQuery, type DashboardProposeInvestigationRequest, type DashboardReportIdentity, type DashboardRuntimeEvent, type DashboardRuntimeEventInput, type DashboardRuntimeEventProfile, type DashboardRuntimeEventsPage, type DashboardRuntimeEventsQueryRequest, type DashboardVerifyInvestigationRequest, createAnalyzeDashboardDevframe, createDashboardArtifactSnapshot, resolveDashboardClientAssets };
|
package/dist/dashboard.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createAnalyzeDashboardDevframe, createDashboardArtifactSnapshot, resolveDashboardClientAssets };
|
|
1
|
+
export { t as createAnalyzeDashboardDevframe, a as createDashboardArtifactSnapshot, r as resolveDashboardClientAssets } from "./dashboard-DvqF3Key.mjs";
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import path from "pathe";
|
|
3
|
+
import { defineRpcFunction } from "devframe";
|
|
4
|
+
import { Server } from "node:http";
|
|
5
|
+
import { createUi } from "@devframes/hub-ui";
|
|
6
|
+
import { initHub } from "@devframes/hub/initiate";
|
|
7
|
+
import { DEVFRAME_CONNECTION_META_FILENAME, DEVFRAME_SSE_ROUTE, DEVFRAME_WS_ROUTE } from "devframe/constants";
|
|
8
|
+
import { initDevframe } from "devframe/initiate";
|
|
9
|
+
import { toNodeHandler } from "@modelcontextprotocol/node";
|
|
10
|
+
import { createMcpFetchHandler } from "devframe/adapters/mcp";
|
|
11
|
+
import { registerDevframeInstance } from "devframe/internal";
|
|
12
|
+
import { isLoopbackAddress, validateOriginCandidate } from "devframe/utils/origin";
|
|
13
|
+
//#region src/cli/analyze/dashboardMcp.ts
|
|
14
|
+
const MCP_ROUTE = "__mcp";
|
|
15
|
+
/** MCP 只公开 Dashboard 的 Agent RPC,不继承宿主工具、浏览器 OTP 或共享状态。 */
|
|
16
|
+
async function createDashboardMcp(instance, httpServer, options) {
|
|
17
|
+
const context = await instance.context;
|
|
18
|
+
const prefix = `${options.id}:`;
|
|
19
|
+
const getTool = (id) => {
|
|
20
|
+
const tool = context.agent.getTool(id);
|
|
21
|
+
return tool?.kind === "rpc" && tool.id.startsWith(prefix) ? tool : void 0;
|
|
22
|
+
};
|
|
23
|
+
const agent = Object.create(context.agent);
|
|
24
|
+
agent.list = () => ({
|
|
25
|
+
tools: context.agent.list().tools.filter((tool) => tool.kind === "rpc" && tool.id.startsWith(prefix)),
|
|
26
|
+
resources: []
|
|
27
|
+
});
|
|
28
|
+
agent.getTool = getTool;
|
|
29
|
+
agent.invoke = (id, args) => {
|
|
30
|
+
const tool = getTool(id);
|
|
31
|
+
if (!tool) throw new Error("Dashboard MCP tool is not available.");
|
|
32
|
+
return context.agent.invoke(tool.id, args);
|
|
33
|
+
};
|
|
34
|
+
agent.read = () => {
|
|
35
|
+
throw new Error("Dashboard MCP resources are not available.");
|
|
36
|
+
};
|
|
37
|
+
const handler = createMcpFetchHandler({
|
|
38
|
+
...context,
|
|
39
|
+
agent
|
|
40
|
+
}, {
|
|
41
|
+
serverName: `${options.id} (devframe)`,
|
|
42
|
+
serverVersion: options.version ?? "0.0.0",
|
|
43
|
+
exposeSharedState: false,
|
|
44
|
+
allowedOrigins: []
|
|
45
|
+
});
|
|
46
|
+
const base = options.base ?? instance.base;
|
|
47
|
+
const route = `${base}${MCP_ROUTE}`;
|
|
48
|
+
let registration;
|
|
49
|
+
let closing;
|
|
50
|
+
let closed = false;
|
|
51
|
+
const nodeHandler = toNodeHandler({ async fetch(request) {
|
|
52
|
+
const origin = request.headers.get("origin");
|
|
53
|
+
if (!origin || validateOriginCandidate(origin, []) !== origin) return new Response("Forbidden", { status: 403 });
|
|
54
|
+
return handler.fetch(request);
|
|
55
|
+
} });
|
|
56
|
+
return {
|
|
57
|
+
route,
|
|
58
|
+
async nodeMiddleware(request, response) {
|
|
59
|
+
const remoteAddress = request.socket.remoteAddress;
|
|
60
|
+
if (!remoteAddress || !isLoopbackAddress(remoteAddress)) {
|
|
61
|
+
response.writeHead(403);
|
|
62
|
+
response.end("Forbidden");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
await nodeHandler(request, response);
|
|
66
|
+
},
|
|
67
|
+
discoveryMiddleware: toNodeHandler({ async fetch() {
|
|
68
|
+
return Response.json({
|
|
69
|
+
...instance.connectionMeta(),
|
|
70
|
+
mcp: { path: MCP_ROUTE }
|
|
71
|
+
});
|
|
72
|
+
} }),
|
|
73
|
+
register() {
|
|
74
|
+
if (closed || registration || !httpServer.listening) return;
|
|
75
|
+
const address = httpServer.address();
|
|
76
|
+
if (!address || typeof address === "string") return;
|
|
77
|
+
const hostname = address.address === "::" || address.address === "0.0.0.0" ? "localhost" : address.address.includes(":") ? `[${address.address}]` : address.address;
|
|
78
|
+
registration = registerDevframeInstance({
|
|
79
|
+
pid: process.pid,
|
|
80
|
+
port: address.port,
|
|
81
|
+
origin: `http://${hostname}:${address.port}`,
|
|
82
|
+
basePath: base,
|
|
83
|
+
id: options.id,
|
|
84
|
+
name: options.name,
|
|
85
|
+
rootDir: path.resolve(options.projectRoot),
|
|
86
|
+
mcp: { path: route },
|
|
87
|
+
startedAt: Date.now()
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
close() {
|
|
91
|
+
if (!closing) {
|
|
92
|
+
closed = true;
|
|
93
|
+
closing = Promise.resolve().then(async () => {
|
|
94
|
+
const errors = [];
|
|
95
|
+
for (const release of [() => registration?.unregister(), () => handler.dispose()]) try {
|
|
96
|
+
await release();
|
|
97
|
+
} catch (error) {
|
|
98
|
+
errors.push(error);
|
|
99
|
+
}
|
|
100
|
+
if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Dashboard MCP cleanup failed");
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return closing;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/cli/analyze/dashboardPolicy.ts
|
|
109
|
+
const rejectDashboardSharedStateSet = defineRpcFunction({
|
|
110
|
+
name: "devframe:rpc:server-state:set",
|
|
111
|
+
type: "action",
|
|
112
|
+
handler: () => {
|
|
113
|
+
throw new Error("Dashboard Devframe shared state 只允许服务端修改。");
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const rejectDashboardSharedStatePatch = defineRpcFunction({
|
|
117
|
+
name: "devframe:rpc:server-state:patch",
|
|
118
|
+
type: "action",
|
|
119
|
+
handler: () => {
|
|
120
|
+
throw new Error("Dashboard Devframe shared state 只允许服务端修改。");
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
/** 独立宿主在开放 RPC 前禁止全局共享状态写入,不影响嵌入宿主的策略。 */
|
|
124
|
+
function withStandaloneDashboardPolicy(definition) {
|
|
125
|
+
return {
|
|
126
|
+
...definition,
|
|
127
|
+
async setup(ctx, info) {
|
|
128
|
+
ctx.rpc.register(rejectDashboardSharedStateSet, true);
|
|
129
|
+
ctx.rpc.register(rejectDashboardSharedStatePatch, true);
|
|
130
|
+
await definition.setup?.(ctx, info);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/cli/analyze/dashboardViteBridge.ts
|
|
136
|
+
const ANALYZE_DASHBOARD_DEVFRAME_BASE = "/__weapp-vite/";
|
|
137
|
+
const ANALYZE_DASHBOARD_HUB_BASE = "/__devframes/";
|
|
138
|
+
const transportPaths = /* @__PURE__ */ new Set([
|
|
139
|
+
`${ANALYZE_DASHBOARD_DEVFRAME_BASE}${DEVFRAME_CONNECTION_META_FILENAME}`,
|
|
140
|
+
`${ANALYZE_DASHBOARD_DEVFRAME_BASE}${DEVFRAME_SSE_ROUTE}`,
|
|
141
|
+
`${ANALYZE_DASHBOARD_DEVFRAME_BASE}${DEVFRAME_WS_ROUTE}`
|
|
142
|
+
]);
|
|
143
|
+
function createAnalyzeDashboardViteBridge(controller, options = {}) {
|
|
144
|
+
const hosts = /* @__PURE__ */ new WeakMap();
|
|
145
|
+
const ownedHosts = /* @__PURE__ */ new Set();
|
|
146
|
+
let activeHost;
|
|
147
|
+
let closing;
|
|
148
|
+
let stopped = false;
|
|
149
|
+
return {
|
|
150
|
+
name: "weapp-vite:dashboard-devframe",
|
|
151
|
+
apply: "serve",
|
|
152
|
+
configureServer(server) {
|
|
153
|
+
if (stopped) throw new Error("Dashboard bridge is already closed.");
|
|
154
|
+
const httpServer = server.httpServer instanceof Server ? server.httpServer : void 0;
|
|
155
|
+
let instance;
|
|
156
|
+
let mcp;
|
|
157
|
+
let starting;
|
|
158
|
+
let acquiring;
|
|
159
|
+
let hostClosing;
|
|
160
|
+
let closed = false;
|
|
161
|
+
const onListening = () => mcp?.register();
|
|
162
|
+
const host = {
|
|
163
|
+
start() {
|
|
164
|
+
if (closed) throw new Error("Dashboard host is already closed.");
|
|
165
|
+
starting ??= (async () => {
|
|
166
|
+
try {
|
|
167
|
+
acquiring = Promise.resolve().then(async () => {
|
|
168
|
+
if (closed) return;
|
|
169
|
+
if (!httpServer) throw new Error("Dashboard requires the Dashboard Vite HTTP server.");
|
|
170
|
+
if (options.uiHost === "hub") {
|
|
171
|
+
instance = initHub({
|
|
172
|
+
base: ANALYZE_DASHBOARD_HUB_BASE,
|
|
173
|
+
name: "weapp-vite DevTools",
|
|
174
|
+
cwd: options.projectRoot ?? process.cwd(),
|
|
175
|
+
server: httpServer,
|
|
176
|
+
allowedOrigins: [],
|
|
177
|
+
auth: true,
|
|
178
|
+
mcp: false,
|
|
179
|
+
register: false,
|
|
180
|
+
ui: createUi({ branding: {
|
|
181
|
+
productName: "weapp-vite DevTools",
|
|
182
|
+
logo: controller.definition.icon
|
|
183
|
+
} }),
|
|
184
|
+
configure: (ctx) => ctx.install({
|
|
185
|
+
...controller.definition,
|
|
186
|
+
basePath: ANALYZE_DASHBOARD_DEVFRAME_BASE
|
|
187
|
+
})
|
|
188
|
+
});
|
|
189
|
+
await instance.ready;
|
|
190
|
+
} else {
|
|
191
|
+
instance = initDevframe(withStandaloneDashboardPolicy(controller.definition), {
|
|
192
|
+
base: ANALYZE_DASHBOARD_DEVFRAME_BASE,
|
|
193
|
+
distDir: false,
|
|
194
|
+
server: httpServer,
|
|
195
|
+
allowedOrigins: [],
|
|
196
|
+
auth: true,
|
|
197
|
+
mcp: false,
|
|
198
|
+
register: false
|
|
199
|
+
});
|
|
200
|
+
await instance.ready;
|
|
201
|
+
}
|
|
202
|
+
if (!closed) mcp = await createDashboardMcp(instance, httpServer, {
|
|
203
|
+
projectRoot: options.projectRoot ?? process.cwd(),
|
|
204
|
+
id: controller.definition.id,
|
|
205
|
+
name: controller.definition.name,
|
|
206
|
+
version: controller.definition.version,
|
|
207
|
+
base: ANALYZE_DASHBOARD_DEVFRAME_BASE
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
await acquiring;
|
|
211
|
+
if (closed) throw new Error("Dashboard host initialization was cancelled by shutdown.");
|
|
212
|
+
activeHost = host;
|
|
213
|
+
httpServer?.once("listening", onListening);
|
|
214
|
+
httpServer?.once("close", host.onClose);
|
|
215
|
+
httpServer?.once("error", host.onClose);
|
|
216
|
+
onListening();
|
|
217
|
+
} catch (error) {
|
|
218
|
+
await host.close().catch(() => {});
|
|
219
|
+
if (!activeHost) controller.dispose();
|
|
220
|
+
throw error;
|
|
221
|
+
}
|
|
222
|
+
})();
|
|
223
|
+
return starting;
|
|
224
|
+
},
|
|
225
|
+
close() {
|
|
226
|
+
if (!hostClosing) {
|
|
227
|
+
closed = true;
|
|
228
|
+
if (activeHost === host) activeHost = void 0;
|
|
229
|
+
httpServer?.off("listening", onListening);
|
|
230
|
+
httpServer?.off("close", host.onClose);
|
|
231
|
+
httpServer?.off("error", host.onClose);
|
|
232
|
+
hostClosing = Promise.resolve().then(async () => {
|
|
233
|
+
await acquiring?.catch(() => {});
|
|
234
|
+
const errors = [];
|
|
235
|
+
for (const release of [() => mcp?.close(), () => instance?.close()]) try {
|
|
236
|
+
await release();
|
|
237
|
+
} catch (error) {
|
|
238
|
+
errors.push(error);
|
|
239
|
+
}
|
|
240
|
+
if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Dashboard host cleanup failed");
|
|
241
|
+
ownedHosts.delete(host);
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return hostClosing;
|
|
245
|
+
},
|
|
246
|
+
onClose() {
|
|
247
|
+
host.close().catch((error) => server.config.logger.error(String(error)));
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
hosts.set(server.config, host);
|
|
251
|
+
ownedHosts.add(host);
|
|
252
|
+
server.middlewares.use((request, response, next) => {
|
|
253
|
+
if (closed || !instance) {
|
|
254
|
+
next();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const url = request.url ?? "/";
|
|
258
|
+
const queryIndex = url.indexOf("?");
|
|
259
|
+
const pathname = queryIndex < 0 ? url : url.slice(0, queryIndex);
|
|
260
|
+
if (mcp && pathname === mcp.route) {
|
|
261
|
+
mcp.nodeMiddleware(request, response).catch(next);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (mcp && pathname === `/__weapp-vite/${DEVFRAME_CONNECTION_META_FILENAME}`) {
|
|
265
|
+
mcp.discoveryMiddleware(request, response).catch(next);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (options.uiHost === "hub") {
|
|
269
|
+
if (pathname === "/__devframes/".slice(0, -1) || pathname.startsWith("/__devframes/")) instance.nodeMiddleware(request, response, next);
|
|
270
|
+
else next();
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (transportPaths.has(pathname)) instance.nodeMiddleware(request, response, next);
|
|
274
|
+
else next();
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
async buildStart() {
|
|
278
|
+
await hosts.get(this.environment.getTopLevelConfig())?.start();
|
|
279
|
+
},
|
|
280
|
+
async closeBundle() {
|
|
281
|
+
await hosts.get(this.environment.getTopLevelConfig())?.close();
|
|
282
|
+
},
|
|
283
|
+
closeServer({ reason }) {
|
|
284
|
+
if (reason === "close" && !activeHost) controller.dispose();
|
|
285
|
+
},
|
|
286
|
+
close() {
|
|
287
|
+
if (!closing) {
|
|
288
|
+
stopped = true;
|
|
289
|
+
closing = Promise.allSettled([...ownedHosts].map((host) => host.close())).then((results) => {
|
|
290
|
+
const errors = results.flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
291
|
+
if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Dashboard bridge cleanup failed");
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return closing;
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
//#endregion
|
|
299
|
+
export { ANALYZE_DASHBOARD_DEVFRAME_BASE, ANALYZE_DASHBOARD_HUB_BASE, createAnalyzeDashboardViteBridge };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { E as createViteWatchIgnored, m as notifyDevModuleGraphHost, t as createDevModuleGraphPlugin } from "./devProvider-BGBkw28J.mjs";
|
|
2
|
+
import { WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY } from "@weapp-core/constants";
|
|
3
|
+
//#region src/vite/dev.ts
|
|
4
|
+
/** 宿主仅提供依赖图和服务生命周期;小程序快照沿用原生构建落盘。 */
|
|
5
|
+
function prepareDevHostConfig(session, merged, user) {
|
|
6
|
+
const ctx = session.context;
|
|
7
|
+
if (session.statefulController) {
|
|
8
|
+
const { plugins: _plugins, configFile: _configFile, ...normalized } = merged;
|
|
9
|
+
return {
|
|
10
|
+
plugins: [...session.statefulController.plugins, ...merged.plugins ?? []],
|
|
11
|
+
config: {
|
|
12
|
+
...normalized,
|
|
13
|
+
logLevel: user.logLevel,
|
|
14
|
+
customLogger: user.customLogger,
|
|
15
|
+
appType: "custom",
|
|
16
|
+
define: {
|
|
17
|
+
...merged.define,
|
|
18
|
+
App: `globalThis[${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)}].App`,
|
|
19
|
+
Page: `globalThis[${JSON.stringify(WEAPP_VITE_STATEFUL_HMR_BRIDGE_KEY)}].Page`
|
|
20
|
+
},
|
|
21
|
+
optimizeDeps: {
|
|
22
|
+
noDiscovery: true,
|
|
23
|
+
include: [],
|
|
24
|
+
entries: []
|
|
25
|
+
},
|
|
26
|
+
experimental: {
|
|
27
|
+
...merged.experimental,
|
|
28
|
+
bundledDev: true
|
|
29
|
+
},
|
|
30
|
+
server: {
|
|
31
|
+
...merged.server,
|
|
32
|
+
...user.server,
|
|
33
|
+
hmr: user.server?.hmr,
|
|
34
|
+
watch: {
|
|
35
|
+
...user.server?.watch,
|
|
36
|
+
ignored: createViteWatchIgnored(ctx.configService.cwd, ctx.configService.outDir, user.server?.watch?.ignored)
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
build: {
|
|
40
|
+
...merged.build,
|
|
41
|
+
watch: void 0,
|
|
42
|
+
write: false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
plugins: [createDevModuleGraphPlugin(ctx, merged, (change) => notifyDevModuleGraphHost(ctx, change))],
|
|
49
|
+
config: {
|
|
50
|
+
appType: "custom",
|
|
51
|
+
resolve: merged.resolve,
|
|
52
|
+
define: merged.define,
|
|
53
|
+
optimizeDeps: {
|
|
54
|
+
noDiscovery: true,
|
|
55
|
+
include: [],
|
|
56
|
+
entries: []
|
|
57
|
+
},
|
|
58
|
+
server: { watch: { ignored: createViteWatchIgnored(ctx.configService.cwd, ctx.configService.outDir, user.server?.watch?.ignored) } }
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { prepareDevHostConfig };
|