weapp-vite 7.5.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/dist/action-B3YZMA-h.mjs +255 -0
- package/dist/action-BELcDNNv.mjs +139 -0
- package/dist/action-BOk3vGI7.mjs +1110 -0
- package/dist/action-DlC6JYpt.mjs +95 -0
- package/dist/action-zEDY7oh_.mjs +247 -0
- package/dist/{analyze-ZJUvEdaY.mjs → analyze-DN79YOAH.mjs} +1 -65
- package/dist/artifacts-BOyC9Fy-.mjs +106 -0
- package/dist/assets-C5_YYXNk.mjs +637 -0
- package/dist/auto-routes.mjs +2 -2
- package/dist/{budget-BD7VqLCl.d.mts → budget-CTLOHwgI.d.mts} +1 -2
- package/dist/budget-EOeEycc_.mjs +65 -0
- package/dist/builtProject-C29udgXY.mjs +541 -0
- package/dist/{chunkStrategy-DRA5WpB-.mjs → chunkStrategy-DY_LZIIe.mjs} +15 -3
- package/dist/{package-7swhyLmf.mjs → classifier-DBJY__kg.mjs} +4 -7
- package/dist/cli-acceptance.mjs +1 -1
- package/dist/cli.mjs +110 -4506
- package/dist/{config-V0L-IAJf.d.mts → config-Bf6DWhyb.d.mts} +136 -49
- package/dist/config.d.mts +2 -2
- package/dist/{createCompilerContextInstance-DJH_P_nZ.mjs → createCompilerContextInstance-aYwi8wQt.mjs} +15235 -9523
- package/dist/{createContext-BqYzHhY9.mjs → createContext-tApLtII-.mjs} +6 -3
- package/dist/dashboard/analyze.d.mts +1 -1
- package/dist/dashboard/analyze.mjs +3 -1
- package/dist/dashboard/vite.d.mts +1 -1
- package/dist/dashboard.d.mts +2 -2
- package/dist/dashboard.mjs +1749 -1
- package/dist/dashboardTransport-C_Y6jMp-.mjs +16 -0
- package/dist/{dashboardViteBridge-Dy3nAD4m.mjs → dashboardViteBridge-DCGR43aM.mjs} +8 -5
- package/dist/{dev-fR5GiJRO.mjs → dev-C2fgr_Xd.mjs} +5 -1
- package/dist/devProvider-D-hTfsEO.mjs +3027 -0
- package/dist/docs/README.md +8 -2
- package/dist/docs/mcp.md +10 -0
- package/dist/docs/troubleshooting.md +8 -0
- package/dist/docs/vue-sfc.md +25 -2
- package/dist/doctor-worker.mjs +3 -2
- package/dist/doctor.d.mts +2 -2
- package/dist/doctor.mjs +15 -13
- package/dist/engine-C66J0HLz.mjs +54 -0
- package/dist/{file-sC3jD7Fh.mjs → file-CcIOmqhC.mjs} +47 -19
- package/dist/file-DtcteQ4G.mjs +1 -0
- package/dist/forwardConsole-B0Reo8Lf.mjs +511 -0
- package/dist/getInstance-BAIaU2y9.mjs +1 -0
- package/dist/{getInstance-DiGSzBNI.mjs → getInstance-Dt9IQDKr.mjs} +1 -1
- package/dist/history-BIiRCzbq.mjs +784 -0
- package/dist/i18n.d.mts +1 -1
- package/dist/{index-C9HjUX5c.d.mts → index-D5rgBzYZ.d.mts} +1 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/json.d.mts +1 -1
- package/dist/lib-DjccSI1B.mjs +143 -0
- package/dist/{lifecycle-BROTlwSL.mjs → lifecycle-C36WSbQS.mjs} +120 -27
- package/dist/{loadConfig-C3BQhz7F.mjs → loadConfig-BWIsDXR4.mjs} +1 -1
- package/dist/loadConfig-D-BpBgsk.mjs +1 -0
- package/dist/logBuildAppFinish-ChjwATMv.mjs +57 -0
- package/dist/mcp-CYgX9HpO.mjs +86 -0
- package/dist/mcp.d.mts +1 -1
- package/dist/mcpClient-DVLvFLZv.mjs +287 -0
- package/dist/{processCleanup-B6KA30Zc.mjs → metadata-hwF7QRcS.mjs} +1 -19
- package/dist/nodeEnv-BmH8UZPR.mjs +7 -0
- package/dist/openIde-CroqOgk5.mjs +648 -0
- package/dist/options-jqFwfD1G.mjs +34 -0
- package/dist/package-Cmakyy3J.mjs +4 -0
- package/dist/path-CYYIQGS7.mjs +44 -0
- package/dist/processCleanup-BQn2kTcK.mjs +19 -0
- package/dist/{protocol-vg8HGJ4n.mjs → protocol-Cg6Jdlvb.mjs} +42 -39
- package/dist/reader-sh_POQ9-.mjs +93 -0
- package/dist/realpathScope-Tf9mz-fh.mjs +23 -0
- package/dist/report-hyonPGbZ.mjs +107 -0
- package/dist/{path-doV773b7.mjs → resolvedId-CiDl7SC1.mjs} +3 -46
- package/dist/runtime-CLUhQsdA.mjs +43 -0
- package/dist/{runtime-Ee2HY6gR.d.mts → runtime-DpVf714f.d.mts} +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/schematics-kO26eQRT.mjs +91 -0
- package/dist/{session-PskhD-nZ.mjs → session-D3zsdzIy.mjs} +71 -9
- package/dist/test.mjs +10 -8
- package/dist/{types-CgZn5X6j.d.mts → types-D-kfuyVa.d.mts} +1 -2
- package/dist/types-D0FFexRF.d.mts +39 -0
- package/dist/types.d.mts +2 -2
- package/dist/{upload-D4msblBf.mjs → upload-DozK8UdN.mjs} +109 -5
- package/dist/upload-worker.mjs +1 -1
- package/dist/{utils-CJSCgEj6.mjs → utils-Dy51PYAC.mjs} +56 -116
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +51 -12
- package/dist/wxs-BT8btflA.mjs +112 -0
- package/dist/wxs-Z4VQDeJ_.mjs +1 -0
- package/package.json +52 -46
- package/dist/dashboard-DvqF3Key.mjs +0 -1842
- package/dist/devProvider-BGBkw28J.mjs +0 -1050
- package/dist/file-DRb4eWqw.mjs +0 -1
- package/dist/getInstance-SiE6WZRh.mjs +0 -1
- package/dist/loadConfig-VGtBF4qm.mjs +0 -1
- package/dist/mcp-D3Yh24Cj.mjs +0 -529
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { F as resolveNpmDistDirName, L as resolveTargetDependencies, M as resolveMainBuildDependencyPatterns, N as resolveNpmBuildCandidateDependenciesSync, f as attachDevModuleGraphHost } from "./devProvider-
|
|
4
|
-
import {
|
|
1
|
+
import { B as resolveHmrRuntimeDecision, D as getStatefulHmrHost, E as createStatefulHmrHostPlugins, F as prepareClassicIdeConfig, I as attachHmrRuntimeSession, L as createHmrRuntimeSession, N as syncManagedTsconfigFiles, O as createSharedBuildConfig, P as getInitialBuildInputObservation, S as createOxcRuntimeSupport, T as attachStatefulHmrHost, _ as clearStatefulHmrSnapshot, b as createPackageBuilder, d as buildStatefulHmrSnapshot, f as prepareStatefulHmrSnapshot, g as StatefulHmrSnapshotHandoff, h as prepareStatefulClassicHandoff, k as getHmrRuntimeCapabilityFallback, m as captureWatchDependencies, p as checkAppWorkersOptions, u as CompilerSession, v as offerStatefulHmrSnapshot, x as settlePackageBuilds, y as getPackNpmRelationList, z as findSkylineRendererFiles } from "./createCompilerContextInstance-aYwi8wQt.mjs";
|
|
2
|
+
import { t as resolveRealpath } from "./realpathScope-Tf9mz-fh.mjs";
|
|
3
|
+
import { F as resolveNpmDistDirName, L as resolveTargetDependencies, M as resolveMainBuildDependencyPatterns, N as resolveNpmBuildCandidateDependenciesSync, f as attachDevModuleGraphHost } from "./devProvider-D-hTfsEO.mjs";
|
|
4
|
+
import { g as pruneOwnedAssetFiles } from "./utils-Dy51PYAC.mjs";
|
|
5
|
+
import { n as loadHostRolldownBuild } from "./engine-C66J0HLz.mjs";
|
|
5
6
|
import path from "pathe";
|
|
6
7
|
import { mkdtemp, readFile, readdir, rm } from "node:fs/promises";
|
|
7
8
|
import { build } from "vite";
|
|
8
9
|
import { createHash } from "node:crypto";
|
|
9
|
-
import { Buffer } from "node:buffer";
|
|
10
10
|
import os from "node:os";
|
|
11
|
+
import { Buffer } from "node:buffer";
|
|
11
12
|
//#region src/vite/npm/sourcemap.ts
|
|
12
13
|
const URL_SCHEME = /^[a-z][a-z\d+.-]*:/i;
|
|
13
14
|
const INLINE_MAP = /(\/\/[#@]\s*sourceMappingURL=data:application\/json(?:;charset=[^;,]*)?;base64,)([a-z\d+/=]+)/gi;
|
|
@@ -277,12 +278,23 @@ async function publishOwnedNpmAssets(cwd, hostOutDir, external) {
|
|
|
277
278
|
}
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region src/vite/session.ts
|
|
281
|
+
const runtimeOwners = /* @__PURE__ */ new WeakMap();
|
|
280
282
|
/** 标准插件的目标校验和依赖准备,共享底层编译会话生命周期。 */
|
|
281
283
|
var WeappBuildSession = class extends CompilerSession {
|
|
284
|
+
hmrRuntimeSession;
|
|
282
285
|
dependencyBuild;
|
|
283
286
|
validating;
|
|
287
|
+
hostClosing;
|
|
288
|
+
terminalClosing;
|
|
284
289
|
isWeb = false;
|
|
285
290
|
statefulController;
|
|
291
|
+
constructor(hmrRuntimeSession = createHmrRuntimeSession()) {
|
|
292
|
+
super();
|
|
293
|
+
this.hmrRuntimeSession = hmrRuntimeSession;
|
|
294
|
+
runtimeOwners.set(hmrRuntimeSession, this);
|
|
295
|
+
this.onClose(attachHmrRuntimeSession(this.context, hmrRuntimeSession));
|
|
296
|
+
this.onClose(() => clearStatefulHmrSnapshot(this.context));
|
|
297
|
+
}
|
|
286
298
|
async prepare(config, cwd, mode, isDev = false) {
|
|
287
299
|
if (!config.resolve?.preserveSymlinks) try {
|
|
288
300
|
cwd = resolveRealpath(cwd);
|
|
@@ -307,16 +319,61 @@ var WeappBuildSession = class extends CompilerSession {
|
|
|
307
319
|
if (!merged) throw new Error("[weapp-vite] Web 目标不能禁用 weapp.web。");
|
|
308
320
|
return merged;
|
|
309
321
|
}
|
|
310
|
-
|
|
322
|
+
await prepareClassicIdeConfig(this.context);
|
|
323
|
+
if (isDev && this.hmrRuntimeSession.resolve(resolveHmrRuntimeDecision({
|
|
311
324
|
platform: service.platform,
|
|
312
325
|
configured: service.weappViteConfig.hmr?.runtime,
|
|
313
326
|
compileHotReLoad: service.projectPrivateConfig.setting?.compileHotReLoad
|
|
314
|
-
}).runtime === "stateful-experimental") {
|
|
315
|
-
if (service.platform !== "weapp")
|
|
316
|
-
|
|
327
|
+
})).runtime === "stateful-experimental") {
|
|
328
|
+
if (service.platform !== "weapp") this.hmrRuntimeSession.requestClassic({
|
|
329
|
+
code: "platform",
|
|
330
|
+
message: "当前小程序平台不支持状态保持热更新。"
|
|
331
|
+
});
|
|
332
|
+
else await this.run(async () => {
|
|
333
|
+
try {
|
|
334
|
+
const snapshot = prepareStatefulHmrSnapshot(await buildStatefulHmrSnapshot(service.loadOptions, void 0, this.context, void 0, []));
|
|
335
|
+
const skylineFiles = findSkylineRendererFiles(snapshot.output);
|
|
336
|
+
if (skylineFiles.length) {
|
|
337
|
+
this.hmrRuntimeSession.requestClassic({
|
|
338
|
+
code: "skyline",
|
|
339
|
+
message: "微信 Skyline 暂不支持状态保持 HMR。",
|
|
340
|
+
files: skylineFiles
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
await offerStatefulHmrSnapshot(this.context, new StatefulHmrSnapshotHandoff(snapshot, snapshot.inputs));
|
|
345
|
+
this.statefulController = createStatefulHmrHostPlugins(this.context);
|
|
346
|
+
} catch (error) {
|
|
347
|
+
const fallback = getHmrRuntimeCapabilityFallback(error);
|
|
348
|
+
if (!fallback) throw error;
|
|
349
|
+
this.hmrRuntimeSession.requestClassic(fallback);
|
|
350
|
+
}
|
|
351
|
+
});
|
|
317
352
|
}
|
|
318
353
|
return this.context.configService.merge(void 0, createSharedBuildConfig(this.context.configService, this.context.scanService));
|
|
319
354
|
}
|
|
355
|
+
/** 只关闭本代资源;宿主负责在原生 watcher 和服务器均退出后恢复 IDE 设置。 */
|
|
356
|
+
closeHostGeneration(reason) {
|
|
357
|
+
if (!this.hostClosing) {
|
|
358
|
+
if (reason === "restart" && this.hmrRuntimeSession.fallback) prepareStatefulClassicHandoff(this.context);
|
|
359
|
+
this.hostClosing = super.close();
|
|
360
|
+
}
|
|
361
|
+
return this.hostClosing;
|
|
362
|
+
}
|
|
363
|
+
/** 无宿主的构建或首次配置失败可直接释放,已绑定宿主必须走其关闭门禁。 */
|
|
364
|
+
close(reason = "close") {
|
|
365
|
+
return reason === "restart" ? this.closeHostGeneration(reason) : this.terminalClosing ??= this.closeHostGeneration(reason).then(() => this.releaseClassicIdeConfig());
|
|
366
|
+
}
|
|
367
|
+
/** 只释放仍未被替换宿主接管的 owner,初始化失败和遗弃交接使用同一关闭门禁。 */
|
|
368
|
+
async releaseClassicIdeConfig() {
|
|
369
|
+
await super.close();
|
|
370
|
+
if (runtimeOwners.get(this.hmrRuntimeSession) === this) await this.hmrRuntimeSession.classicIdeConfig.close();
|
|
371
|
+
}
|
|
372
|
+
/** 原生宿主链已完全退出后,连同尚未绑定宿主的失败替换代一起释放。 */
|
|
373
|
+
async releaseHostClassicIdeConfig() {
|
|
374
|
+
await runtimeOwners.get(this.hmrRuntimeSession)?.closeHostGeneration("close");
|
|
375
|
+
await this.hmrRuntimeSession.classicIdeConfig.close();
|
|
376
|
+
}
|
|
320
377
|
validateEntries() {
|
|
321
378
|
if (this.validating && !this.isClosing) return this.validating;
|
|
322
379
|
if (this.state !== "ready" && this.state !== "building") return Promise.reject(/* @__PURE__ */ new Error(`[weapp-vite] 无法从 ${this.state} 状态开始构建。`));
|
|
@@ -330,6 +387,9 @@ var WeappBuildSession = class extends CompilerSession {
|
|
|
330
387
|
await syncManagedTsconfigFiles(this.context);
|
|
331
388
|
if (this.isClosing) throw new Error("[weapp-vite] 构建会话已关闭。");
|
|
332
389
|
this.state = "building";
|
|
390
|
+
}).catch((error) => {
|
|
391
|
+
getInitialBuildInputObservation(this.context.configService)?.close();
|
|
392
|
+
throw error;
|
|
333
393
|
}).finally(() => {
|
|
334
394
|
this.validating = void 0;
|
|
335
395
|
});
|
|
@@ -345,7 +405,9 @@ var WeappBuildSession = class extends CompilerSession {
|
|
|
345
405
|
let reportedReady = false;
|
|
346
406
|
const reportReady = () => {
|
|
347
407
|
if (started && successful && !reportedReady && !this.isClosing) {
|
|
408
|
+
if (this.statefulController && this.hmrRuntimeSession.phase === "switching") return;
|
|
348
409
|
reportedReady = true;
|
|
410
|
+
if (!this.statefulController) this.hmrRuntimeSession.markClassic();
|
|
349
411
|
server.config.logger.info(`[weapp-vite] 小程序开发产物已就绪 (${this.statefulController ? "stateful-experimental" : "classic"})`);
|
|
350
412
|
}
|
|
351
413
|
};
|
package/dist/test.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as parseSidecarModuleId, i as parseLogicalEntryId } from "./protocol-
|
|
1
|
+
import { m as captureWatchDependencies, u as CompilerSession } from "./createCompilerContextInstance-aYwi8wQt.mjs";
|
|
2
|
+
import { a as parseSidecarModuleId, i as parseLogicalEntryId } from "./protocol-Cg6Jdlvb.mjs";
|
|
3
|
+
import { Q as chokidar_default } from "./devProvider-D-hTfsEO.mjs";
|
|
4
|
+
import { n as normalizePath, t as isPathInside } from "./path-CYYIQGS7.mjs";
|
|
3
5
|
import process from "node:process";
|
|
4
6
|
import path from "node:path";
|
|
5
7
|
import fs from "node:fs/promises";
|
|
6
8
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
-
import chokidar from "chokidar";
|
|
8
9
|
//#region src/testArtifact/inputs.ts
|
|
9
10
|
const sessionId = randomUUID();
|
|
10
11
|
const excludedDirectories = /* @__PURE__ */ new Set([
|
|
@@ -137,10 +138,11 @@ async function buildTestArtifact(options = {}) {
|
|
|
137
138
|
sourceRootPath: ctx.configService.absoluteSrcRoot
|
|
138
139
|
};
|
|
139
140
|
const paths = [...dependencies, outDir];
|
|
141
|
+
const fingerprint = await fingerprintPaths(paths);
|
|
140
142
|
const stable = (await Promise.all([...discoveredInputs].map(async ([file, fingerprint]) => await fingerprint === await fingerprintPaths([file])))).every(Boolean) && before === await fingerprintPaths(initialInputs, [outDir]);
|
|
141
143
|
artifactInputs.set(artifact, {
|
|
142
144
|
paths,
|
|
143
|
-
fingerprint: stable ?
|
|
145
|
+
fingerprint: stable ? fingerprint : ""
|
|
144
146
|
});
|
|
145
147
|
return artifact;
|
|
146
148
|
} finally {
|
|
@@ -156,13 +158,13 @@ async function watchTestArtifact(options = {}) {
|
|
|
156
158
|
let dirty = false;
|
|
157
159
|
let forced = false;
|
|
158
160
|
let closing;
|
|
159
|
-
const watchedInputs = () => artifactInputs.get(artifact).paths.
|
|
161
|
+
const watchedInputs = () => [...new Map(artifactInputs.get(artifact).paths.map((file) => [normalizePath(file), file])).values()].filter((file) => !isPathInside(artifact.miniprogramRootPath, file) && (normalizePath(file) === normalizePath(artifact.sourceRootPath) || !isPathInside(artifact.sourceRootPath, file)));
|
|
160
162
|
let watched = watchedInputs();
|
|
161
|
-
const watcher =
|
|
163
|
+
const watcher = chokidar_default.watch(watched, {
|
|
162
164
|
ignoreInitial: true,
|
|
163
165
|
ignored(file) {
|
|
164
|
-
if (watched.some((input) =>
|
|
165
|
-
return /[/\\](?:node_modules|\.git|\.weapp-vite)(?:[/\\]|$)/.test(file) ||
|
|
166
|
+
if (watched.some((input) => isPathInside(file, input))) return false;
|
|
167
|
+
return /[/\\](?:node_modules|\.git|\.weapp-vite)(?:[/\\]|$)/.test(file) || isPathInside(artifact.miniprogramRootPath, file);
|
|
166
168
|
}
|
|
167
169
|
});
|
|
168
170
|
const requestRebuild = (force) => {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/analyze/glassEasel/types.d.ts
|
|
2
|
+
type GlassEaselDiagnosticCode = 'GE001' | 'GE002' | 'GE003' | 'GE004' | 'GE005' | 'GE006';
|
|
3
|
+
type GlassEaselDiagnosticSeverity = 'error' | 'warning';
|
|
4
|
+
interface GlassEaselDiagnostic {
|
|
5
|
+
code: GlassEaselDiagnosticCode;
|
|
6
|
+
severity: GlassEaselDiagnosticSeverity;
|
|
7
|
+
message: string;
|
|
8
|
+
file: string;
|
|
9
|
+
line?: number;
|
|
10
|
+
column?: number;
|
|
11
|
+
normalized?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/** 每个 source/output owner 的最近分析事实;日志去重状态不属于当前事实。 */
|
|
14
|
+
interface GlassEaselAnalysisFact {
|
|
15
|
+
kind: 'output' | 'source';
|
|
16
|
+
scope?: string;
|
|
17
|
+
detected: boolean;
|
|
18
|
+
diagnostics: Map<string, GlassEaselDiagnostic>;
|
|
19
|
+
sourceIds: Set<string>;
|
|
20
|
+
}
|
|
21
|
+
interface GlassEaselAnalyzeResult {
|
|
22
|
+
detected: boolean;
|
|
23
|
+
minimumBaseLibrary: '3.8.12';
|
|
24
|
+
migrationGuide: string;
|
|
25
|
+
diagnostics: GlassEaselDiagnostic[];
|
|
26
|
+
summary: {
|
|
27
|
+
errors: number;
|
|
28
|
+
warnings: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface GlassEaselTemplateFinding {
|
|
32
|
+
code: Extract<GlassEaselDiagnosticCode, 'GE002' | 'GE003' | 'GE004'>;
|
|
33
|
+
severity: GlassEaselDiagnosticSeverity;
|
|
34
|
+
message: string;
|
|
35
|
+
start: number;
|
|
36
|
+
normalized?: boolean;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { GlassEaselAnalyzeResult as n, GlassEaselTemplateFinding as r, GlassEaselAnalysisFact as t };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as Resolver } from "./index-CaXAtb9e.mjs";
|
|
2
2
|
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-C7fCmf92.mjs";
|
|
3
|
-
import { $ as
|
|
4
|
-
import { t as WeappI18nConfig } from "./types-
|
|
3
|
+
import { $ as WeappCompilerOutputRequest, $n as NpmPackageFilesConfig, $t as WeappUniAppConfig, A as Ref, An as GenerateDirsOptions, At as WeappAppPreludeConfig, B as BindingErrorLike, Bn as GenerateTemplateInlineSource, Br as WeappViteRuntime, Bt as WeappInjectWeapiConfig, Cn as AliasOptions, Cr as WeappLibVueTscOptions, Ct as AutoImportComponents, D as MethodDefinitions, Dn as CopyGlobs, Dr as WeappManagedSharedTsconfigConfig, Dt as HandleWxmlOptions, E as InlineConfig, En as ChunksConfig, Er as WeappManagedServerTsconfigConfig, Et as EnhanceWxmlOptions, F as RolldownPlugin, Fn as GenerateTemplate, Ft as WeappBuildScopeConfig, G as EntryJsonFragment, Gn as JsonMergeContext, Gt as WeappPreloadNetwork, H as BaseEntry, Hn as GenerateTemplatesConfig, Ht as WeappInjectWebRuntimeGlobalsTarget, I as RolldownPluginOption, In as GenerateTemplateContext, It as WeappBuildScopeObjectConfig, J as ScanComponentItem, Jn as JsonMergeStrategy, Jt as WeappReactConfig, K as PageEntry, Kn as JsonMergeFunction, Kt as WeappPreloadRule, L as RolldownWatchOptions, Ln as GenerateTemplateEntry, Lt as WeappHmrConfig, M as RolldownBuild, Mn as GenerateFileType, Mt as WeappAutoRoutesConfig, N as RolldownOptions, Nn as GenerateFilenamesOptions, Nt as WeappAutoRoutesInclude, O as Plugin, On as CopyOptions, Or as WeappManagedTypeScriptConfig, Ot as MultiPlatformConfig, P as RolldownOutput, Pn as GenerateOptions, Pt as WeappAutoRoutesIncludePattern, Q as WeappCompilerHmrRequest, Qn as NpmMainPackageConfig, Qt as WeappSubPackageConfig, R as RolldownWatcher, Rn as GenerateTemplateFactory, Rt as WeappInjectRequestGlobalsConfig, Sn as Alias, Sr as WeappLibInternalDtsOptions, St as WeappViteConfig, T as ConfigEnv, Tn as BuildNpmPackageMeta, Tr as WeappManagedNodeTsconfigConfig, Tt as EnhanceOptions, U as ComponentEntry, Un as JsFormat, Ut as WeappMcpConfig, V as AppEntry, Vn as GenerateTemplateScope, Vt as WeappInjectWebRuntimeGlobalsConfig, W as Entry, Wn as JsonConfig, Wt as WeappNpmConfig, X as WeappCompilerHmrAsset, Xn as NpmBuildOptions, Xt as WeappRouteRule, Y as WxmlDep, Yn as MpPlatform, Yt as WeappRequestRuntimeConfig, Z as WeappCompilerHmrPreparation, Zn as NpmDependencyPattern, Zt as WeappRouteRules, _n as WxmlTransformNode, _r as WeappLibComponentJson, _t as WeappDebugConfig, an as WxmlRemoveAttrRule, ar as SharedChunkMode, at as WeappCompilerPluginOption, b as ChangeEvent, bn as MultiPlatformProjectConfig, br as WeappLibEntryContext, bt as WeappTailwindcssOptions, cn as WxmlValidationContext, cr as StyleConfigEntry, ct as WeappCompilerSourceClaim, dn as WxmlAttribute, dr as StyleScope, dt as ProjectConfig, en as WeappVueConfig, er as NpmPluginPackageConfig, et as WeappCompilerPlugin, fn as WxmlAttributeValue, fr as SubPackage, ft as SubPackageMetaValue, gn as WxmlTransformContext, gr as SubPackageStyleScope, gt as WeappAnalyzeHistoryConfig, hn as WxmlTransform, hr as SubPackageStyleEntry, ht as WeappAnalyzeConfig, in as WeappWorkerConfig, ir as SharedChunkDynamicImports, it as WeappCompilerPluginFactory, j as ResolvedConfig, jn as GenerateExtensionsOptions, jr as WeappViteHostMeta, jt as WeappAppPreludeMode, k as PluginOption, kn as DeprecatedInlineDynamicImports, kr as WeappWebConfig, kt as ScanWxmlOptions, ln as WxmlValidationDiagnostic, lr as StyleConfigObject, lt as WeappCompilerSourceRequest, mn as WxmlSourceLocation, mr as SubPackageStyleConfigObject, mt as WeappAnalyzeBudgetConfig, nn as WeappWebRuntimeConfig, nr as NpmSubPackageConfig, nt as WeappCompilerPluginContext, on as WxmlRemoveOptions, or as SharedChunkOverride, ot as WeappCompilerPluginPhase, pn as WxmlElementInfo, pr as SubPackageStyleConfigEntry, pt as UserConfig, q as ComponentsMap, qn as JsonMergeStage, qt as WeappReactCompilerConfig, rn as WeappWevuConfig, rr as ResolvedAlias, rt as WeappCompilerPluginController, sn as WxmlValidate, sr as SharedChunkStrategy, st as WeappCompilerResourceKind, tn as WeappVueTemplateConfig, tr as NpmStrategy, tt as WeappCompilerPluginCapabilities, un as WxmlValidationVisitor, ur as StyleEntry, ut as WeappCompilerTransformResult, vn as WxmlTransformResult, vr as WeappLibConfig, vt as WeappForwardConsoleConfig, w as ComputedDefinitions, wn as AlipayNpmMode, wr as WeappManagedAppTsconfigConfig, wt as AutoImportComponentsOption, x as WeappVitePluginApi, xn as MultiPlatformProjectConfigs, xr as WeappLibFileName, xt as WeappUploadConfig, yn as WxmlTransformVisitor, yr as WeappLibDtsOptions, yt as WeappForwardConsoleLogLevel, z as ViteDevServer, zn as GenerateTemplateFileSource, zt as WeappInjectRequestGlobalsTarget } from "./config-Bf6DWhyb.mjs";
|
|
4
|
+
import { t as WeappI18nConfig } from "./types-D-kfuyVa.mjs";
|
|
5
5
|
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, DeprecatedInlineDynamicImports, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, type JsonConfig, type JsonMergeContext, type JsonMergeFunction, type JsonMergeStage, type JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, MultiPlatformProjectConfig, MultiPlatformProjectConfigs, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPackageFilesConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, StyleConfigEntry, StyleConfigObject, StyleEntry, StyleScope, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, type WeappCompilerHmrAsset, type WeappCompilerHmrPreparation, type WeappCompilerHmrRequest, WeappCompilerOutputRequest, WeappCompilerPlugin, WeappCompilerPluginCapabilities, WeappCompilerPluginContext, WeappCompilerPluginController, WeappCompilerPluginFactory, WeappCompilerPluginOption, WeappCompilerPluginPhase, WeappCompilerResourceKind, WeappCompilerSourceClaim, WeappCompilerSourceRequest, WeappCompilerTransformResult, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, type WeappI18nConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappPreloadNetwork, WeappPreloadRule, WeappReactCompilerConfig, WeappReactConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappTailwindcssOptions, WeappUniAppConfig, WeappUploadConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlAttribute, WxmlAttributeValue, WxmlDep, WxmlElementInfo, WxmlRemoveAttrRule, WxmlRemoveOptions, WxmlSourceLocation, WxmlTransform, WxmlTransformContext, WxmlTransformNode, WxmlTransformResult, WxmlTransformVisitor, WxmlValidate, WxmlValidationContext, WxmlValidationDiagnostic, WxmlValidationVisitor };
|
|
@@ -6,17 +6,121 @@ import { pathToFileURL } from "node:url";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { mkdir, readFile, stat } from "node:fs/promises";
|
|
8
8
|
import { getPackageInfo } from "local-pkg";
|
|
9
|
+
import { Buffer } from "node:buffer";
|
|
10
|
+
import { performance } from "node:perf_hooks";
|
|
9
11
|
import { execFile, execFileSync } from "node:child_process";
|
|
12
|
+
//#region src/cli/upload/processTreeDiagnostics.ts
|
|
13
|
+
const diagnostics = /* @__PURE__ */ new WeakMap();
|
|
14
|
+
const MARKER_PREFIX = "[weapp-vite:upload-process-tree:v1]";
|
|
15
|
+
const MARKER_RE = /^\[weapp-vite:upload-process-tree:v1\] (script-enter|parent-query-start|parent-query-end|children-query-start|children-query-end) (\d{1,9}) (\d{1,16})$/;
|
|
16
|
+
const ERROR_CODES = /* @__PURE__ */ new Set([
|
|
17
|
+
"ETIMEDOUT",
|
|
18
|
+
"ENOENT",
|
|
19
|
+
"EACCES",
|
|
20
|
+
"EPERM",
|
|
21
|
+
"ENOBUFS",
|
|
22
|
+
"EIO",
|
|
23
|
+
"UNKNOWN"
|
|
24
|
+
]);
|
|
25
|
+
const SIGNALS = /* @__PURE__ */ new Set([
|
|
26
|
+
"SIGTERM",
|
|
27
|
+
"SIGKILL",
|
|
28
|
+
"SIGINT",
|
|
29
|
+
"SIGABRT"
|
|
30
|
+
]);
|
|
31
|
+
/** 标记只写入诊断管道,不进入供清理使用的 PID 输出。 */
|
|
32
|
+
const WINDOWS_PROCESS_TREE_DIAGNOSTIC_SETUP = `\$wvTreeClock = [Diagnostics.Stopwatch]::StartNew(); function Write-WvTreeStage([string]\$stage) { [Console]::Error.WriteLine('${MARKER_PREFIX} ' + $stage + ' ' + $wvTreeClock.ElapsedMilliseconds + ' ' + [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds()) }; `;
|
|
33
|
+
function processTreeStageCommand(stage) {
|
|
34
|
+
return `Write-WvTreeStage '${stage}'; `;
|
|
35
|
+
}
|
|
36
|
+
function readMarkers(stderr, elapsedMs) {
|
|
37
|
+
const text = Buffer.isBuffer(stderr) ? stderr.subarray(0, 8192).toString("utf8") : typeof stderr === "string" ? Buffer.from(stderr.slice(0, 8192)).subarray(0, 8192).toString("utf8") : "";
|
|
38
|
+
const markers = [];
|
|
39
|
+
for (const line of text.split(/\r?\n/)) {
|
|
40
|
+
const match = MARKER_RE.exec(line);
|
|
41
|
+
if (!match) continue;
|
|
42
|
+
const elapsed = Number(match[2]);
|
|
43
|
+
const utc = Number(match[3]);
|
|
44
|
+
if (!Number.isSafeInteger(elapsed) || elapsed > elapsedMs || !Number.isSafeInteger(utc) || markers.length >= 8) return [];
|
|
45
|
+
markers.push({
|
|
46
|
+
stage: match[1],
|
|
47
|
+
elapsedMs: elapsed,
|
|
48
|
+
utcMs: utc
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const expected = markers[1]?.stage === "parent-query-start" ? [
|
|
52
|
+
"script-enter",
|
|
53
|
+
"parent-query-start",
|
|
54
|
+
"parent-query-end",
|
|
55
|
+
"children-query-start",
|
|
56
|
+
"children-query-end"
|
|
57
|
+
] : [
|
|
58
|
+
"script-enter",
|
|
59
|
+
"children-query-start",
|
|
60
|
+
"children-query-end"
|
|
61
|
+
];
|
|
62
|
+
return markers.every((marker, index) => marker.stage === expected[index] && marker.elapsedMs >= (markers[index - 1]?.elapsedMs ?? 0)) ? markers : [];
|
|
63
|
+
}
|
|
64
|
+
function describeQuery(error, elapsedMs, utcStart, utcEnd) {
|
|
65
|
+
const failure = error;
|
|
66
|
+
const markers = readMarkers(failure.stderr, elapsedMs);
|
|
67
|
+
const first = markers[0];
|
|
68
|
+
const last = markers.at(-1);
|
|
69
|
+
const result = {
|
|
70
|
+
elapsedMs,
|
|
71
|
+
stage: last?.stage ?? "before-script-entry-or-unobserved"
|
|
72
|
+
};
|
|
73
|
+
if (typeof failure.code === "string" && ERROR_CODES.has(failure.code)) result.code = failure.code;
|
|
74
|
+
if (typeof failure.signal === "string" && SIGNALS.has(failure.signal)) result.signal = failure.signal;
|
|
75
|
+
if (typeof failure.status === "number" && Number.isSafeInteger(failure.status)) result.status = failure.status;
|
|
76
|
+
const startupMs = first && first.utcMs - utcStart;
|
|
77
|
+
if (first && startupMs !== void 0 && startupMs >= 0 && startupMs <= elapsedMs && Math.abs(utcEnd - utcStart - elapsedMs) <= 5 && markers.every((marker) => Math.abs(marker.utcMs - first.utcMs - (marker.elapsedMs - first.elapsedMs)) <= 5)) {
|
|
78
|
+
result.startupMs = startupMs;
|
|
79
|
+
if (last?.stage === "parent-query-start" || last?.stage === "children-query-start") result.activeQueryMs = Math.max(0, elapsedMs - startupMs - (last.elapsedMs - first.elapsedMs));
|
|
80
|
+
}
|
|
81
|
+
for (const [name, key] of [["parent", "parentQueryMs"], ["children", "childrenQueryMs"]]) {
|
|
82
|
+
const start = markers.find((marker) => marker.stage === `${name}-query-start`);
|
|
83
|
+
const end = markers.find((marker) => marker.stage === `${name}-query-end`);
|
|
84
|
+
if (start && end) result[key] = end.elapsedMs - start.elapsedMs;
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
/** 只附带标量诊断,保持清理失败的原始异常身份与控制流。 */
|
|
89
|
+
function observeWindowsProcessTreeQuery(run) {
|
|
90
|
+
const startedAt = performance.now();
|
|
91
|
+
const utcStart = Date.now();
|
|
92
|
+
try {
|
|
93
|
+
return run();
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error && typeof error === "object") {
|
|
96
|
+
const elapsedMs = Math.max(0, Math.round(performance.now() - startedAt));
|
|
97
|
+
diagnostics.set(error, {
|
|
98
|
+
elapsedMs,
|
|
99
|
+
stage: "before-script-entry-or-unobserved"
|
|
100
|
+
});
|
|
101
|
+
try {
|
|
102
|
+
diagnostics.set(error, describeQuery(error, elapsedMs, utcStart, Date.now()));
|
|
103
|
+
} catch {}
|
|
104
|
+
}
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Windows 查询只展示白名单诊断,不能回显异常中携带的命令或原始 stderr。 */
|
|
109
|
+
function describeUploadProcessTreeError(error) {
|
|
110
|
+
const diagnostic = error && typeof error === "object" ? diagnostics.get(error) : void 0;
|
|
111
|
+
return diagnostic ? `PowerShell 进程归属查询失败 ${JSON.stringify(diagnostic)}` : String(error);
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
10
114
|
//#region src/cli/upload/processTree.ts
|
|
11
115
|
function childPids(pid, lifetime) {
|
|
12
116
|
if (process.platform === "win32") {
|
|
13
117
|
const since = lifetime ? `[DateTimeOffset]::FromUnixTimeMilliseconds(${lifetime.start}).UtcDateTime` : `(Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}').CreationDate.ToUniversalTime()`;
|
|
14
118
|
const until = lifetime ? `[DateTimeOffset]::FromUnixTimeMilliseconds(${lifetime.end}).UtcDateTime` : "[DateTime]::UtcNow";
|
|
15
|
-
return execFileSync("powershell.exe", [
|
|
119
|
+
return observeWindowsProcessTreeQuery(() => execFileSync("powershell.exe", [
|
|
16
120
|
"-NoProfile",
|
|
17
121
|
"-NonInteractive",
|
|
18
122
|
"-Command",
|
|
19
|
-
`$ErrorActionPreference = 'Stop'; $since = ${since}; $until = ${until}; Get-CimInstance Win32_Process -Filter 'ParentProcessId = ${pid}' | Where-Object {
|
|
123
|
+
`$ErrorActionPreference = 'Stop'; ${WINDOWS_PROCESS_TREE_DIAGNOSTIC_SETUP}${processTreeStageCommand("script-enter")}${lifetime ? "" : processTreeStageCommand("parent-query-start")}$since = ${since}; ${lifetime ? "" : processTreeStageCommand("parent-query-end")}$until = ${until}; ${processTreeStageCommand("children-query-start")}Get-CimInstance Win32_Process -Filter 'ParentProcessId = ${pid}' | Where-Object { $_.CreationDate.ToUniversalTime() -ge $since -and $_.CreationDate.ToUniversalTime() -le $until } | Select-Object -ExpandProperty ProcessId; ${processTreeStageCommand("children-query-end")}`
|
|
20
124
|
], {
|
|
21
125
|
encoding: "utf8",
|
|
22
126
|
windowsHide: true,
|
|
@@ -24,9 +128,9 @@ function childPids(pid, lifetime) {
|
|
|
24
128
|
stdio: [
|
|
25
129
|
"ignore",
|
|
26
130
|
"pipe",
|
|
27
|
-
"
|
|
131
|
+
"pipe"
|
|
28
132
|
]
|
|
29
|
-
}).split(/\s+/).map(Number).filter((value) => Number.isSafeInteger(value) && value > 0);
|
|
133
|
+
})).split(/\s+/).map(Number).filter((value) => Number.isSafeInteger(value) && value > 0);
|
|
30
134
|
}
|
|
31
135
|
const output = execFileSync("ps", [
|
|
32
136
|
"-A",
|
|
@@ -559,4 +663,4 @@ function prepareUpload(platform, context, action = "upload") {
|
|
|
559
663
|
return providers[platform](context, action);
|
|
560
664
|
}
|
|
561
665
|
//#endregion
|
|
562
|
-
export { terminateUploadProcess as a, terminateUploadDescendants as i, resolveUploadPlatforms as n, redactUploadSecrets as r, prepareUpload as t };
|
|
666
|
+
export { terminateUploadProcess as a, terminateUploadDescendants as i, resolveUploadPlatforms as n, describeUploadProcessTreeError as o, redactUploadSecrets as r, prepareUpload as t };
|
package/dist/upload-worker.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as terminateUploadDescendants, r as redactUploadSecrets, t as prepareUpload } from "./upload-
|
|
1
|
+
import { i as terminateUploadDescendants, r as redactUploadSecrets, t as prepareUpload } from "./upload-DozK8UdN.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
//#region src/cli/upload/uploadResult.ts
|
|
4
4
|
function record(value) {
|