weapp-vite 7.5.0 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -6
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/bin/bootstrap.js +9 -4
- package/bin/bootstrap.test.ts +82 -1
- package/bin/nodeVersionWarning.js +17 -0
- package/bin/nodeVersionWarning.test.ts +30 -0
- package/dist/action-BD56SQh4.mjs +254 -0
- package/dist/action-CPtgEl6p.mjs +94 -0
- package/dist/action-le0bNff_.mjs +1102 -0
- package/dist/action-ytG5oFAw.mjs +138 -0
- package/dist/action-zmJrU8PC.mjs +245 -0
- package/dist/{analyze-ZJUvEdaY.mjs → analyze-DCZo-sJd.mjs} +4 -71
- package/dist/artifacts-TrTX9_jj.mjs +104 -0
- package/dist/assets-XyhpYtGl.mjs +630 -0
- package/dist/auto-import-components/resolvers.d.mts +1 -1
- package/dist/auto-import-components/resolvers.mjs +1 -1
- package/dist/auto-import-presets/wevu-router.d.mts +1 -1
- package/dist/auto-import-presets/wevu-router.mjs +1 -1
- package/dist/auto-import-presets/wevu.d.mts +1 -1
- package/dist/auto-import-presets/wevu.mjs +1 -1
- package/dist/auto-import-presets.d.mts +2 -2
- package/dist/auto-import-presets.mjs +2 -2
- package/dist/auto-routes.d.mts +1 -3
- package/dist/auto-routes.mjs +3 -4
- package/dist/{budget-BD7VqLCl.d.mts → budget-DTPngJU0.d.mts} +1 -10
- package/dist/budget-_Mu-4GKn.mjs +63 -0
- package/dist/builtProject-B145uOt5.mjs +534 -0
- package/dist/{package-7swhyLmf.mjs → classifier-CNTJOYQL.mjs} +5 -9
- package/dist/cli-acceptance.mjs +3 -4
- package/dist/cli.mjs +142 -4569
- package/dist/{config-DRGcCi3h.mjs → config-59ZWhCIf.mjs} +1 -2
- package/dist/{config-V0L-IAJf.d.mts → config-BNx2BODw.d.mts} +145 -150
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +3 -3
- package/dist/{constants-DEZdcsMn.mjs → constants-BOe8mgqL.mjs} +2 -4
- package/dist/{createCompilerContextInstance-DJH_P_nZ.mjs → createCompilerContextInstance-BXSdH2E8.mjs} +19930 -14019
- package/dist/{createContext-BqYzHhY9.mjs → createContext-W0TeXxbo.mjs} +7 -5
- package/dist/dashboard/analyze.d.mts +1 -7
- package/dist/dashboard/analyze.mjs +3 -1
- package/dist/dashboard/vite.d.mts +2 -4
- package/dist/dashboard/vite.mjs +1 -2
- package/dist/dashboard.d.mts +2 -2
- package/dist/dashboard.mjs +1733 -1
- package/dist/dashboardTransport-C9290QgS.mjs +15 -0
- package/dist/{dashboardViteBridge-Dy3nAD4m.mjs → dashboardViteBridge-B7QgQo94.mjs} +11 -11
- package/dist/{dev-fR5GiJRO.mjs → dev-D1QSExwk.mjs} +6 -3
- package/dist/devProvider-Bcvz5nu4.mjs +4966 -0
- package/dist/docs/README.md +14 -6
- package/dist/docs/ai-workflows.md +2 -0
- package/dist/docs/mcp.md +11 -1
- package/dist/docs/troubleshooting.md +16 -0
- package/dist/docs/vue-sfc.md +25 -2
- package/dist/docs/weapp-config.md +29 -0
- package/dist/docs/wevu-authoring.md +2 -0
- package/dist/doctor-worker.mjs +5 -5
- package/dist/doctor.d.mts +2 -8
- package/dist/doctor.mjs +24 -31
- package/dist/engine-Mnnm_ALP.mjs +53 -0
- package/dist/file-5eEfbK60.mjs +1 -0
- package/dist/{file-sC3jD7Fh.mjs → file-D8mp5GmB.mjs} +50 -26
- package/dist/{files-BqxFIPRp.mjs → files-Cy9jURJu.mjs} +1 -2
- package/dist/forwardConsole-D2Q0RIqc.mjs +509 -0
- package/dist/getInstance-BXNVH7sU.mjs +1 -0
- package/dist/{getInstance-DiGSzBNI.mjs → getInstance-DfNlbr-X.mjs} +2 -3
- package/dist/history-dKxzoHmN.mjs +774 -0
- package/dist/i18n.d.mts +1 -3
- package/dist/i18n.mjs +1 -2
- package/dist/{index-C9HjUX5c.d.mts → index-DIZJRrvK.d.mts} +1 -24
- package/dist/{index-CaXAtb9e.d.mts → index-SnaW3cvA.d.mts} +0 -12
- package/dist/index.d.mts +3 -7
- package/dist/index.mjs +6 -6
- package/dist/{json-BL8Dhhk6.mjs → json-Cvon2mw5.mjs} +1 -2
- package/dist/json.d.mts +1 -1
- package/dist/json.mjs +1 -1
- package/dist/lib-CJyMBzoe.mjs +140 -0
- package/dist/{lifecycle-BROTlwSL.mjs → lifecycle-CUo8PMQc.mjs} +123 -33
- package/dist/{loadConfig-C3BQhz7F.mjs → loadConfig-CKIdfW4o.mjs} +2 -3
- package/dist/loadConfig-D4WGJcYp.mjs +1 -0
- package/dist/logBuildAppFinish-DOBoof6S.mjs +54 -0
- package/dist/mcp-D88QvQgG.mjs +84 -0
- package/dist/{mcp-Cj8Maqo6.mjs → mcp-ovJgl1N9.mjs} +2 -4
- package/dist/mcp.d.mts +1 -3
- package/dist/mcp.mjs +1 -1
- package/dist/mcpClient-C8JzVZ46.mjs +283 -0
- package/dist/{processCleanup-B6KA30Zc.mjs → metadata-HlDKtlsu.mjs} +2 -21
- package/dist/nodeEnv-zq1EymWj.mjs +6 -0
- package/dist/openIde-QoYKhuuM.mjs +643 -0
- package/dist/options-Cz8vZ-0w.mjs +33 -0
- package/dist/{chunkStrategy-DRA5WpB-.mjs → package-DR62fAzP.mjs} +32 -31
- package/dist/path-E1OjBJAl.mjs +43 -0
- package/dist/{platform-CnkySBKz.mjs → platform-BiMpsZIb.mjs} +1 -2
- package/dist/{pluginHost--CaeyWpA.mjs → pluginHost-vn8Vty1J.mjs} +1 -2
- package/dist/processCleanup-DzB64WI8.mjs +18 -0
- package/dist/{protocol-vg8HGJ4n.mjs → protocol-HiSJRrSO.mjs} +43 -41
- package/dist/reader-wzPH_W8A.mjs +92 -0
- package/dist/realpathScope-DwlLaCk3.mjs +22 -0
- package/dist/report-PJVyo-UZ.mjs +105 -0
- package/dist/{path-doV773b7.mjs → resolvedId-DaxPh_yV.mjs} +5 -50
- package/dist/{resolvers-Dod-euqX.mjs → resolvers-CKYqmRD_.mjs} +10 -20
- package/dist/resolvers.d.mts +1 -1
- package/dist/resolvers.mjs +1 -1
- package/dist/{routes-C7fCmf92.d.mts → routes-DvAFX29h.d.mts} +0 -2
- package/dist/{runtime-Ee2HY6gR.d.mts → runtime-BL4RjBRa.d.mts} +1 -9
- package/dist/runtime-CKtMVERT.mjs +42 -0
- package/dist/{runtime-D6VCNhNY.mjs → runtime-DDUCb7pP.mjs} +4 -8
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/schematics-DikfOjMD.mjs +90 -0
- package/dist/{session-PskhD-nZ.mjs → session-COrQJYif.mjs} +81 -21
- package/dist/test.d.mts +1 -3
- package/dist/test.mjs +54 -30
- package/dist/types-BK2EQ3Jm.d.mts +37 -0
- package/dist/{types-CgZn5X6j.d.mts → types-e2BMP9NU.d.mts} +1 -4
- package/dist/types.d.mts +4 -4
- package/dist/{upload-D4msblBf.mjs → upload-Chal5b3w.mjs} +118 -24
- package/dist/upload-worker.mjs +3 -5
- package/dist/{utils-CJSCgEj6.mjs → utils-CTGSZp4j.mjs} +72 -146
- package/dist/vite.d.mts +2 -4
- package/dist/vite.mjs +55 -21
- package/dist/volar.mjs +1 -2
- package/dist/{wevu-BQWUU7br.mjs → wevu-BaihCXO9.mjs} +1 -2
- package/dist/wevu-DTtSOyxB.d.mts +3 -0
- package/dist/{wevu-router-Dg1LnBlg.mjs → wevu-router-BIoxDbnu.mjs} +1 -2
- package/dist/wevu-router-CdWurGQ4.d.mts +3 -0
- package/dist/wxs-7V7MPzeW.mjs +1 -0
- package/dist/wxs-BdHHXltv.mjs +110 -0
- package/package.json +62 -53
- 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
- package/dist/wevu-C4KEC5kO.d.mts +0 -5
- package/dist/wevu-router-Cg2sIkIE.d.mts +0 -5
package/dist/i18n.d.mts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { t as WeappI18nConfig } from "./types-
|
|
1
|
+
import { t as WeappI18nConfig } from "./types-e2BMP9NU.mjs";
|
|
2
2
|
import { I18nGlobal, I18nGlobal as I18nGlobal$1, I18nInstance, I18nInstance as I18nInstance$1, I18nLocaleChangeSubscription } from "@weapp-vite/i18n";
|
|
3
|
-
//#region src/i18n.d.ts
|
|
4
3
|
export declare const behavior: I18nInstance$1["behavior"];
|
|
5
4
|
export declare const i18n: I18nInstance$1;
|
|
6
5
|
export declare const global: I18nGlobal$1;
|
|
7
6
|
export declare const page: typeof Page;
|
|
8
|
-
//#endregion
|
|
9
7
|
export type { I18nGlobal, I18nInstance, I18nLocaleChangeSubscription, WeappI18nConfig };
|
package/dist/i18n.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WEAPP_I18N_RUNTIME_MARKER } from "@weapp-core/constants";
|
|
2
|
-
|
|
2
|
+
// src/i18n.ts
|
|
3
3
|
function unavailable() {
|
|
4
4
|
throw new Error("weapp-vite/i18n 只能在启用 weapp.i18n 的小程序构建中使用。");
|
|
5
5
|
}
|
|
@@ -11,5 +11,4 @@ const i18n = {
|
|
|
11
11
|
};
|
|
12
12
|
const global = unavailable;
|
|
13
13
|
const page = unavailable;
|
|
14
|
-
//#endregion
|
|
15
14
|
export { behavior, global, i18n, page };
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { a as AnalyzeSubpackagesResult } from "./budget-BD7VqLCl.mjs";
|
|
1
|
+
import { a as AnalyzeSubpackagesResult } from "./budget-DTPngJU0.mjs";
|
|
3
2
|
import { DevframeDefinition } from "devframe";
|
|
4
3
|
import { z } from "zod";
|
|
5
|
-
//#region src/dashboard/artifacts.d.ts
|
|
6
4
|
interface DashboardArtifactFile {
|
|
7
5
|
readonly size: number;
|
|
8
6
|
readonly content?: string;
|
|
@@ -14,16 +12,12 @@ declare function createDashboardArtifactSnapshot(): {
|
|
|
14
12
|
files: DashboardArtifactFiles;
|
|
15
13
|
capture(fileName: string, source: string | Uint8Array): void;
|
|
16
14
|
};
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/dashboard/paths.d.ts
|
|
19
15
|
type DashboardFileKind = 'artifact' | 'source';
|
|
20
16
|
interface DashboardContentRoots {
|
|
21
17
|
pluginRoot?: string;
|
|
22
18
|
projectRoot?: string;
|
|
23
19
|
srcRoot?: string;
|
|
24
20
|
}
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/dashboard/schema.d.ts
|
|
27
21
|
declare const dashboardFileRangeSchema: z.ZodObject<{
|
|
28
22
|
offset: z.ZodNumber;
|
|
29
23
|
totalCharacters: z.ZodNumber;
|
|
@@ -43,8 +37,6 @@ declare const dashboardFileReadRequestSchema: z.ZodObject<{
|
|
|
43
37
|
revision: z.ZodNumber;
|
|
44
38
|
}, z.core.$strip>;
|
|
45
39
|
type DashboardFileReadRequest = z.infer<typeof dashboardFileReadRequestSchema>;
|
|
46
|
-
//#endregion
|
|
47
|
-
//#region src/dashboard/content.d.ts
|
|
48
40
|
interface DashboardFileContent {
|
|
49
41
|
content: string;
|
|
50
42
|
kind: DashboardFileKind;
|
|
@@ -53,8 +45,6 @@ interface DashboardFileContent {
|
|
|
53
45
|
size: number;
|
|
54
46
|
range?: DashboardFileRange;
|
|
55
47
|
}
|
|
56
|
-
//#endregion
|
|
57
|
-
//#region src/dashboard/eventsQuery.d.ts
|
|
58
48
|
declare const dashboardRuntimeEventsQueryRequestSchema: z.ZodObject<{
|
|
59
49
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
60
50
|
command: "command";
|
|
@@ -134,8 +124,6 @@ declare const dashboardRuntimeEventsPageSchema: z.ZodObject<{
|
|
|
134
124
|
}, z.core.$strip>;
|
|
135
125
|
type DashboardRuntimeEventsQueryRequest = z.infer<typeof dashboardRuntimeEventsQueryRequestSchema>;
|
|
136
126
|
type DashboardRuntimeEventsPage = z.infer<typeof dashboardRuntimeEventsPageSchema>;
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/dashboard/events.d.ts
|
|
139
127
|
type DashboardRuntimeEventKind = 'command' | 'build' | 'diagnostic' | 'hmr' | 'system';
|
|
140
128
|
type DashboardRuntimeEventLevel = 'info' | 'success' | 'warning' | 'error';
|
|
141
129
|
interface DashboardRuntimeEvent extends DashboardRuntimeEventInput {
|
|
@@ -179,8 +167,6 @@ interface DashboardRuntimeEventInput {
|
|
|
179
167
|
tags?: string[];
|
|
180
168
|
profile?: DashboardRuntimeEventProfile;
|
|
181
169
|
}
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/dashboard/investigations/types.d.ts
|
|
184
170
|
type DashboardInvestigationTarget = {
|
|
185
171
|
kind: 'package';
|
|
186
172
|
packageId: string;
|
|
@@ -295,8 +281,6 @@ interface DashboardVerifyInvestigationRequest extends DashboardInvestigationRequ
|
|
|
295
281
|
report: DashboardReportIdentity;
|
|
296
282
|
summary: string;
|
|
297
283
|
}
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/dashboard/payload.d.ts
|
|
300
284
|
interface DashboardAnalyzePayloadDescriptor {
|
|
301
285
|
characters: number;
|
|
302
286
|
hash: string;
|
|
@@ -318,8 +302,6 @@ interface DashboardAnalyzePage {
|
|
|
318
302
|
revision: number;
|
|
319
303
|
target: DashboardAnalyzePageRequest['target'];
|
|
320
304
|
}
|
|
321
|
-
//#endregion
|
|
322
|
-
//#region src/dashboard/queries/schema.d.ts
|
|
323
305
|
declare const analyzeQuerySchema: z.ZodObject<{
|
|
324
306
|
revision: z.ZodNumber;
|
|
325
307
|
target: z.ZodDefault<z.ZodEnum<{
|
|
@@ -674,12 +656,8 @@ type DashboardModulesQuery = z.input<typeof modulesQuerySchema>;
|
|
|
674
656
|
type DashboardModulesPage = z.output<typeof modulesPageSchema>;
|
|
675
657
|
type DashboardComparisonQuery = z.input<typeof comparisonQuerySchema>;
|
|
676
658
|
type DashboardComparisonPage = z.output<typeof comparisonPageSchema>;
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region src/dashboard/assets.d.ts
|
|
679
659
|
/** 定位可选仪表盘包的原生构建 SPA;未安装或尚未构建时返回 undefined。 */
|
|
680
660
|
declare function resolveDashboardClientAssets(cwd?: string): string | undefined;
|
|
681
|
-
//#endregion
|
|
682
|
-
//#region src/dashboard/index.d.ts
|
|
683
661
|
/** 报告与产物在发布后不可再修改;控制器只保留引用,不复制或清空调用方的 Map。 */
|
|
684
662
|
interface DashboardAnalyzeSnapshot {
|
|
685
663
|
current: AnalyzeSubpackagesResult;
|
|
@@ -737,5 +715,4 @@ declare module 'devframe' {
|
|
|
737
715
|
}
|
|
738
716
|
/** 创建只读分析与任务元数据能力,不执行外部工作,也不修改宿主认证策略。 */
|
|
739
717
|
declare function createAnalyzeDashboardDevframe({ snapshot: initialSnapshot, roots, initialEvents, clientAssets }: CreateAnalyzeDashboardDevframeOptions): AnalyzeDashboardDevframeController;
|
|
740
|
-
//#endregion
|
|
741
718
|
export { DashboardInvestigationReceiptInput as A, DashboardRuntimeEventInput as B, DashboardClaimInvestigationRequest as C, DashboardInvestigationClaim as D, DashboardInvestigation as E, DashboardObjectMeasurements as F, DashboardFileReadRequest as G, DashboardRuntimeEventsPage as H, DashboardProposeInvestigationRequest as I, DashboardArtifactFiles as J, DashboardContentRoots as K, DashboardReportIdentity as L, DashboardInvestigationStatus as M, DashboardInvestigationTarget as N, DashboardInvestigationProposal as O, DashboardInvestigationsState as P, DashboardVerifyInvestigationRequest as R, DashboardAuthorizeInvestigationRequest as S, DashboardCreateInvestigationRequest as T, DashboardRuntimeEventsQueryRequest as U, DashboardRuntimeEventProfile as V, DashboardFileContent as W, createDashboardArtifactSnapshot as Y, DashboardAnalyzePage as _, createAnalyzeDashboardDevframe as a, DashboardAnalyzePayloadsDescriptor as b, DashboardAnalyzeSummary as c, DashboardComparisonPage as d, DashboardComparisonQuery as f, DashboardPackagesQuery as g, DashboardPackagesPage as h, DashboardDevframeState as i, DashboardInvestigationRequest as j, DashboardInvestigationProposalInput as k, DashboardArtifactsPage as l, DashboardModulesQuery as m, CreateAnalyzeDashboardDevframeOptions as n, resolveDashboardClientAssets as o, DashboardModulesPage as p, DashboardArtifactFile as q, DashboardAnalyzeSnapshot as r, DashboardAnalyzeQuery as s, AnalyzeDashboardDevframeController as t, DashboardArtifactsQuery as u, DashboardAnalyzePageRequest as v, DashboardCompleteInvestigationRequest as w, DashboardAgentInvestigationRequest as x, DashboardAnalyzePayloadDescriptor as y, DashboardRuntimeEvent as z };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/auto-import-components/resolvers/types.d.ts
|
|
2
1
|
interface ResolvedValue {
|
|
3
2
|
name: string;
|
|
4
3
|
from: string;
|
|
@@ -64,11 +63,7 @@ interface Options {
|
|
|
64
63
|
};
|
|
65
64
|
}
|
|
66
65
|
type CreateResolver = (options?: Options) => Resolver;
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/auto-import-components/resolvers/tdesign.d.ts
|
|
69
66
|
declare const TDesignResolver: CreateResolver;
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/auto-import-components/resolvers/uviewPlus.d.ts
|
|
72
67
|
interface UviewPlusResolverOptions {
|
|
73
68
|
supportFilesStrategy?: ResolverSupportFilesStrategy;
|
|
74
69
|
}
|
|
@@ -76,14 +71,8 @@ interface UviewPlusResolverOptions {
|
|
|
76
71
|
* 创建 uview-plus 的 Vue SFC 自动导入解析器。
|
|
77
72
|
*/
|
|
78
73
|
declare function UviewPlusResolver(options?: UviewPlusResolverOptions): ResolverObject;
|
|
79
|
-
//#endregion
|
|
80
|
-
//#region src/auto-import-components/resolvers/vant.d.ts
|
|
81
74
|
declare const VantResolver: CreateResolver;
|
|
82
|
-
//#endregion
|
|
83
|
-
//#region src/auto-import-components/resolvers/weui.d.ts
|
|
84
75
|
declare const WeuiResolver: CreateResolver;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/auto-import-components/resolvers/wotUi.d.ts
|
|
87
76
|
interface WotUiResolverOptions extends Pick<Options, 'supportFilesStrategy'> {
|
|
88
77
|
prefix?: string;
|
|
89
78
|
}
|
|
@@ -91,5 +80,4 @@ interface WotUiResolverOptions extends Pick<Options, 'supportFilesStrategy'> {
|
|
|
91
80
|
* 创建 Wot UI 的 Vue SFC 自动导入解析器。
|
|
92
81
|
*/
|
|
93
82
|
declare function WotUiResolver(options?: WotUiResolverOptions): ResolverObject;
|
|
94
|
-
//#endregion
|
|
95
83
|
export { UviewPlusResolver as a, CreateResolver as c, ResolvedValue as d, Resolver as f, ResolverSupportFilesStrategy as g, ResolverObject as h, VantResolver as i, ExternalMetadataFileCandidates as l, ResolverMeta as m, WotUiResolverOptions as n, UviewPlusResolverOptions as o, ResolverFn as p, WeuiResolver as r, TDesignResolver as s, WotUiResolver as t, Options as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { t as WeappI18nConfig } from "./types-
|
|
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-
|
|
4
|
-
//#region src/runtime/compilerSession/context.d.ts
|
|
1
|
+
import { $ as WeappCompilerOutputRequest, A as Ref, Ar as WEAPP_VITE_HOST_NAME, Br as WeappViteRuntime, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fr as resolveWeappViteHostMeta, Gn as JsonMergeContext, Gr as getSupportedWeappVitePlatforms, Hr as WeappViteTargetInput, I as RolldownPluginOption, Ir as ResolveWeappViteTargetOptions, Jn as JsonMergeStrategy, Jr as resolveWeappViteTarget, Kn as JsonMergeFunction, Kr as getSupportedWeappViteTargetDescriptors, L as RolldownWatchOptions, Lr as ResolvedWeappViteTarget, M as RolldownBuild, Mr as applyWeappViteHostMeta, N as RolldownOptions, Nr as createWeappViteHostMeta, O as Plugin, P as RolldownOutput, Pr as isWeappViteHost, Q as WeappCompilerHmrRequest, R as RolldownWatcher, Rr as WEB_PLATFORM_ALIASES, S as CompilerContext, St as WeappViteConfig, T as ConfigEnv, Ur as WeappViteTargetKind, Vr as WeappViteTargetDescriptor, Wn as JsonConfig, Wr as WebPlatform, X as WeappCompilerHmrAsset, Z as WeappCompilerHmrPreparation, _ as definePageJson, _n as WxmlTransformNode, a as UserConfigFnNoEnvPlain, an as WxmlRemoveAttrRule, at as WeappCompilerPluginOption, bn as MultiPlatformProjectConfig, c as UserConfigFnPromise, cn as WxmlValidationContext, ct as WeappCompilerSourceClaim, d as Component, dn as WxmlAttribute, et as WeappCompilerPlugin, f as Page, fn as WxmlAttributeValue, g as defineComponentJson, gn as WxmlTransformContext, h as defineAppJson, hn as WxmlTransform, i as UserConfigFnNoEnv, it as WeappCompilerPluginFactory, j as ResolvedConfig, jr as WeappViteHostMeta, k as PluginOption, l as defineConfig, ln as WxmlValidationDiagnostic, lt as WeappCompilerSourceRequest, m as Theme, mn as WxmlSourceLocation, n as UserConfigExport, nt as WeappCompilerPluginContext, o as UserConfigFnObject, on as WxmlRemoveOptions, ot as WeappCompilerPluginPhase, p as Sitemap, pn as WxmlElementInfo, qn as JsonMergeStage, qr as isWebPlatform, r as UserConfigFn, rt as WeappCompilerPluginController, s as UserConfigFnObjectPlain, sn as WxmlValidate, st as WeappCompilerResourceKind, t as UserConfig, tt as WeappCompilerPluginCapabilities, u as App, un as WxmlValidationVisitor, ut as WeappCompilerTransformResult, v as defineSitemapJson, vn as WxmlTransformResult, w as ComputedDefinitions, xn as MultiPlatformProjectConfigs, y as defineThemeJson, yn as WxmlTransformVisitor, z as ViteDevServer, zr as WeappVitePlatform } from "./config-BNx2BODw.mjs";
|
|
2
|
+
import { t as WeappI18nConfig } from "./types-e2BMP9NU.mjs";
|
|
3
|
+
import { a as LayoutHostContext, c as LayoutHostResolver, d as unregisterLayoutHosts, f as waitForLayoutHost, i as LayoutHostBridge, l as registerLayoutHosts, m as createWevuComponent, n as defineProps, o as LayoutHostEntry, p as WevuComponentOptions, r as setPageLayout, s as LayoutHostResolveOptions, t as defineEmits, u as resolveLayoutHost } from "./runtime-BL4RjBRa.mjs";
|
|
5
4
|
interface InitializeCompilerContextOptions extends Partial<LoadConfigOptions> {
|
|
6
5
|
syncSupportFiles?: boolean;
|
|
7
6
|
syncAutoImportSupportFiles?: boolean;
|
|
8
7
|
preloadAppEntry?: boolean;
|
|
9
8
|
}
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/createContext.d.ts
|
|
12
9
|
interface CreateCompilerContextOptions extends InitializeCompilerContextOptions {
|
|
13
10
|
key?: string;
|
|
14
11
|
}
|
|
15
12
|
/** 保留历史活动上下文适配;新宿主通过 CompilerSession 创建独立会话。 */
|
|
16
13
|
export declare function createCompilerContext(options?: CreateCompilerContextOptions): Promise<CompilerContext>;
|
|
17
|
-
//#endregion
|
|
18
14
|
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,7 +1,7 @@
|
|
|
1
|
-
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost
|
|
2
|
-
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-
|
|
3
|
-
import { t as defineConfig } from "./config-
|
|
4
|
-
import { a as getSupportedWeappViteTargetDescriptors, i as getSupportedWeappVitePlatforms, o as isWebPlatform, r as WEB_PLATFORM_ALIASES, s as resolveWeappViteTarget } from "./createCompilerContextInstance-
|
|
5
|
-
import { t as createCompilerContext } from "./createContext-
|
|
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-
|
|
1
|
+
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-vn8Vty1J.mjs";
|
|
2
|
+
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-Cvon2mw5.mjs";
|
|
3
|
+
import { t as defineConfig } from "./config-59ZWhCIf.mjs";
|
|
4
|
+
import { a as getSupportedWeappViteTargetDescriptors, i as getSupportedWeappVitePlatforms, o as isWebPlatform, r as WEB_PLATFORM_ALIASES, s as resolveWeappViteTarget } from "./createCompilerContextInstance-BXSdH2E8.mjs";
|
|
5
|
+
import { t as createCompilerContext } from "./createContext-W0TeXxbo.mjs";
|
|
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-DDUCb7pP.mjs";
|
|
7
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 };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/json.ts
|
|
2
2
|
/**
|
|
3
3
|
* @description 定义 app.json(支持直接对象或函数形式)
|
|
4
4
|
*/
|
|
@@ -29,5 +29,4 @@ const defineSitemapJson = (config) => {
|
|
|
29
29
|
const defineThemeJson = (config) => {
|
|
30
30
|
return config;
|
|
31
31
|
};
|
|
32
|
-
//#endregion
|
|
33
32
|
export { defineThemeJson as a, defineSitemapJson as i, defineComponentJson as n, definePageJson as r, defineAppJson as t };
|
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-BNx2BODw.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 +1 @@
|
|
|
1
|
-
export { t as defineAppJson, n as defineComponentJson, r as definePageJson, i as defineSitemapJson, a as defineThemeJson } from "./json-
|
|
1
|
+
export { t as defineAppJson, n as defineComponentJson, r as definePageJson, i as defineSitemapJson, a as defineThemeJson } from "./json-Cvon2mw5.mjs";
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { o as stripLeadingSlashes, r as normalizeRelativePath } from "./path-E1OjBJAl.mjs";
|
|
2
|
+
import { c as findJsEntry, d as findVueEntry } from "./file-D8mp5GmB.mjs";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
import { isObject, removeExtensionDeep } from "@weapp-core/shared";
|
|
5
|
+
import { fs } from "@weapp-core/shared/fs";
|
|
6
|
+
// src/runtime/compilerSession/tasks.ts
|
|
7
|
+
/** 任一子构建失败后仍等待所有已启动任务,保留最先排列的原始错误。 */
|
|
8
|
+
async function waitForBuildTasks(tasks) {
|
|
9
|
+
const results = await Promise.allSettled(tasks);
|
|
10
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
11
|
+
if (failure?.status === "rejected") throw failure.reason;
|
|
12
|
+
return results.map((result) => result.value);
|
|
13
|
+
}
|
|
14
|
+
// src/runtime/utils/object.ts
|
|
15
|
+
function hasOwn(source, key) {
|
|
16
|
+
return Object.prototype.hasOwnProperty.call(source, key);
|
|
17
|
+
}
|
|
18
|
+
// src/runtime/lib.ts
|
|
19
|
+
function hasLibEntry(entry) {
|
|
20
|
+
if (!entry) return false;
|
|
21
|
+
if (typeof entry === "string") return entry.trim().length > 0;
|
|
22
|
+
if (Array.isArray(entry)) return entry.length > 0;
|
|
23
|
+
if (isObject(entry)) return Object.keys(entry).length > 0;
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
function resolveWeappLibConfig(options) {
|
|
27
|
+
const { cwd, srcRoot, config } = options;
|
|
28
|
+
if (!config) return;
|
|
29
|
+
const root = config.root ?? srcRoot ?? "";
|
|
30
|
+
const resolvedRoot = path.resolve(cwd, root || ".");
|
|
31
|
+
const userDtsOptions = typeof config.dts === "object" && config.dts ? config.dts : void 0;
|
|
32
|
+
const resolvedDtsEnabled = typeof config.dts === "boolean" ? config.dts : userDtsOptions?.enabled !== false;
|
|
33
|
+
const resolvedDtsMode = userDtsOptions?.mode ?? "internal";
|
|
34
|
+
const resolvedDts = {
|
|
35
|
+
...userDtsOptions,
|
|
36
|
+
enabled: resolvedDtsEnabled,
|
|
37
|
+
mode: resolvedDtsMode
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
enabled: hasLibEntry(config.entry),
|
|
41
|
+
entry: config.entry,
|
|
42
|
+
root: resolvedRoot,
|
|
43
|
+
outDir: config.outDir,
|
|
44
|
+
preservePath: config.preservePath !== false,
|
|
45
|
+
fileName: config.fileName,
|
|
46
|
+
componentJson: config.componentJson ?? "auto",
|
|
47
|
+
dts: resolvedDts,
|
|
48
|
+
source: config
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function normalizeLibName(value) {
|
|
52
|
+
return stripLeadingSlashes(normalizeRelativePath(value));
|
|
53
|
+
}
|
|
54
|
+
async function resolveEntryFile(root, entry) {
|
|
55
|
+
const resolved = path.isAbsolute(entry) ? entry : path.resolve(root, entry);
|
|
56
|
+
if (path.extname(resolved)) {
|
|
57
|
+
if (await fs.pathExists(resolved)) return resolved;
|
|
58
|
+
}
|
|
59
|
+
const jsEntry = await findJsEntry(resolved);
|
|
60
|
+
if (jsEntry.path) return jsEntry.path;
|
|
61
|
+
const vueEntry = await findVueEntry(resolved);
|
|
62
|
+
if (vueEntry) return vueEntry;
|
|
63
|
+
if (await fs.pathExists(resolved)) return resolved;
|
|
64
|
+
}
|
|
65
|
+
function resolveEntryName(options) {
|
|
66
|
+
const { explicitName, preservePath, relativeId } = options;
|
|
67
|
+
if (explicitName) return normalizeLibName(explicitName);
|
|
68
|
+
const base = removeExtensionDeep(relativeId);
|
|
69
|
+
if (!preservePath) return normalizeLibName(path.basename(base));
|
|
70
|
+
return normalizeLibName(base);
|
|
71
|
+
}
|
|
72
|
+
function resolveOutputBase(options) {
|
|
73
|
+
const { entryName, entryPath, config } = options;
|
|
74
|
+
const fileName = config.fileName;
|
|
75
|
+
if (!fileName) return normalizeLibName(entryName);
|
|
76
|
+
let resolved;
|
|
77
|
+
if (typeof fileName === "function") {
|
|
78
|
+
resolved = fileName({
|
|
79
|
+
name: entryName,
|
|
80
|
+
input: entryPath
|
|
81
|
+
});
|
|
82
|
+
if (typeof resolved !== "string") throw new TypeError("`weapp.lib.fileName` 必须返回字符串。");
|
|
83
|
+
} else resolved = fileName.includes("[name]") ? fileName.replace(/\[name\]/g, entryName) : fileName;
|
|
84
|
+
const normalized = normalizeLibName(resolved);
|
|
85
|
+
if (!normalized) throw new Error("`weapp.lib.fileName` 解析结果为空,请检查配置。");
|
|
86
|
+
return normalizeLibName(removeExtensionDeep(normalized));
|
|
87
|
+
}
|
|
88
|
+
function createLibEntryFileNameResolver(libConfig) {
|
|
89
|
+
if (!libConfig.fileName) return;
|
|
90
|
+
return (chunkInfo) => {
|
|
91
|
+
return `${resolveOutputBase({
|
|
92
|
+
entryName: chunkInfo.name,
|
|
93
|
+
entryPath: chunkInfo.facadeModuleId ?? "",
|
|
94
|
+
config: libConfig
|
|
95
|
+
})}.js`;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function resolveWeappLibEntries(configService, libConfig) {
|
|
99
|
+
const entry = libConfig.entry;
|
|
100
|
+
const root = libConfig.root || configService.absoluteSrcRoot;
|
|
101
|
+
const preservePath = libConfig.preservePath;
|
|
102
|
+
const entries = [];
|
|
103
|
+
if (typeof entry === "string") entries.push({ path: entry });
|
|
104
|
+
else if (Array.isArray(entry)) for (const item of entry) entries.push({ path: item });
|
|
105
|
+
else if (isObject(entry)) for (const [name, value] of Object.entries(entry)) entries.push({
|
|
106
|
+
name,
|
|
107
|
+
path: value
|
|
108
|
+
});
|
|
109
|
+
if (!entries.length) throw new Error("`weapp.lib.entry` 不能为空,请配置库模式入口。");
|
|
110
|
+
if (typeof libConfig.fileName === "string" && !libConfig.fileName.includes("[name]") && entries.length > 1) throw new Error("`weapp.lib.fileName` 在多入口模式下必须包含 `[name]` 占位符。");
|
|
111
|
+
const outputNames = /* @__PURE__ */ new Set();
|
|
112
|
+
const resolved = [];
|
|
113
|
+
for (const item of entries) {
|
|
114
|
+
const entryPath = await resolveEntryFile(root, item.path);
|
|
115
|
+
if (!entryPath) throw new Error(`未找到 lib 入口文件:${item.path}`);
|
|
116
|
+
const relativeId = normalizeRelativePath(configService.relativeAbsoluteSrcRoot(entryPath));
|
|
117
|
+
const entryName = resolveEntryName({
|
|
118
|
+
explicitName: item.name,
|
|
119
|
+
preservePath,
|
|
120
|
+
relativeId
|
|
121
|
+
});
|
|
122
|
+
if (!entryName) throw new Error(`lib 入口解析失败:${item.path}`);
|
|
123
|
+
const outputBase = resolveOutputBase({
|
|
124
|
+
entryName,
|
|
125
|
+
entryPath,
|
|
126
|
+
config: libConfig
|
|
127
|
+
});
|
|
128
|
+
if (outputNames.has(outputBase)) throw new Error(`lib 输出路径冲突:${outputBase}`);
|
|
129
|
+
outputNames.add(outputBase);
|
|
130
|
+
const relativeBase = normalizeLibName(removeExtensionDeep(relativeId));
|
|
131
|
+
resolved.push({
|
|
132
|
+
name: entryName,
|
|
133
|
+
input: entryPath,
|
|
134
|
+
relativeBase,
|
|
135
|
+
outputBase
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return resolved;
|
|
139
|
+
}
|
|
140
|
+
export { hasOwn as a, resolveWeappLibEntries as i, hasLibEntry as n, waitForBuildTasks as o, resolveWeappLibConfig as r, createLibEntryFileNameResolver as t };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
+
import { WEAPP_VITE_DEV_SERVER_CLOSE_KEY, WEAPP_VITE_HOST_RESTART_CONFIG_KEY } from "@weapp-core/constants";
|
|
2
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
|
-
|
|
4
|
-
const serverCloseRecord = Symbol(
|
|
4
|
+
// src/devLifecycle/server.ts
|
|
5
|
+
const serverCloseRecord = Symbol.for(WEAPP_VITE_DEV_SERVER_CLOSE_KEY);
|
|
5
6
|
const dispatchedRecords = /* @__PURE__ */ new WeakMap();
|
|
6
7
|
const dispatchedCloses = /* @__PURE__ */ new WeakMap();
|
|
7
8
|
function onceClose(close) {
|
|
@@ -78,8 +79,7 @@ function replaceDevServerClose(server, close) {
|
|
|
78
79
|
record.close = onceClose(() => close.call(server));
|
|
79
80
|
return previous;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
//#region src/devLifecycle/shutdown.ts
|
|
82
|
+
// src/devLifecycle/shutdown.ts
|
|
83
83
|
const operations = new AsyncLocalStorage();
|
|
84
84
|
/** 获取当前开发命令的资源归属;异步回调可以继承归属,但不能继承已结束的内部操作权限。 */
|
|
85
85
|
function getDevShutdownScope() {
|
|
@@ -105,7 +105,7 @@ var DevShutdownScope = class {
|
|
|
105
105
|
process.on("SIGTERM", this.onSigterm);
|
|
106
106
|
process.on("disconnect", this.onDisconnect);
|
|
107
107
|
process.stdin?.on?.("end", this.onStdinEnd);
|
|
108
|
-
if (process.connected === false) this.request("disconnect");
|
|
108
|
+
if (process.connected === false && typeof process.disconnect === "function") this.request("disconnect");
|
|
109
109
|
}
|
|
110
110
|
get stopping() {
|
|
111
111
|
return this.reason !== void 0;
|
|
@@ -202,12 +202,28 @@ var DevShutdownScope = class {
|
|
|
202
202
|
function createDevShutdownScope(options) {
|
|
203
203
|
return new DevShutdownScope(options);
|
|
204
204
|
}
|
|
205
|
-
|
|
206
|
-
//#region src/vite/lifecycle.ts
|
|
205
|
+
// src/vite/lifecycle.ts
|
|
207
206
|
const hostLifecycleKey = Symbol.for("weapp-vite:host-lifecycle");
|
|
207
|
+
function createHostOperations() {
|
|
208
|
+
const operations = new AsyncLocalStorage();
|
|
209
|
+
return {
|
|
210
|
+
isInternal: () => operations.getStore()?.active === true,
|
|
211
|
+
run: (action) => {
|
|
212
|
+
const operation = { active: true };
|
|
213
|
+
return operations.run(operation, async () => {
|
|
214
|
+
try {
|
|
215
|
+
return await action();
|
|
216
|
+
} finally {
|
|
217
|
+
operation.active = false;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
208
223
|
const hostData = /* @__PURE__ */ new WeakMap();
|
|
209
224
|
async function settleHostCleanup(tasks) {
|
|
210
|
-
const
|
|
225
|
+
const results = await Promise.allSettled(tasks);
|
|
226
|
+
const errors = [...new Set(results.flatMap((result) => result.status === "rejected" ? [result.reason] : []))];
|
|
211
227
|
if (errors.length) throw errors.length === 1 ? errors[0] : new AggregateError(errors, "Host cleanup failed");
|
|
212
228
|
}
|
|
213
229
|
async function discardRestartData(data, status) {
|
|
@@ -215,6 +231,23 @@ async function discardRestartData(data, status) {
|
|
|
215
231
|
data?.clear();
|
|
216
232
|
await settleHostCleanup(entries.map(async (entry) => await entry.dispose?.(status)));
|
|
217
233
|
}
|
|
234
|
+
/** 在配置合并后、编译准备前接管重启链;函数载体不会被 Vite 深拷贝。 */
|
|
235
|
+
function takeHostLifecycle(config) {
|
|
236
|
+
const inline = config;
|
|
237
|
+
const carrier = inline[WEAPP_VITE_HOST_RESTART_CONFIG_KEY];
|
|
238
|
+
const inherited = typeof carrier === "function" ? carrier[hostLifecycleKey] : inline[hostLifecycleKey];
|
|
239
|
+
if (inherited) {
|
|
240
|
+
delete inline[WEAPP_VITE_HOST_RESTART_CONFIG_KEY];
|
|
241
|
+
delete inline[hostLifecycleKey];
|
|
242
|
+
}
|
|
243
|
+
return inherited;
|
|
244
|
+
}
|
|
245
|
+
/** 需要参与配置准备的数据在 configureServer 之前读取,且只能接管一次。 */
|
|
246
|
+
function takeHostConfigRestartData(lifecycle, key) {
|
|
247
|
+
const value = lifecycle?.data.get(key)?.value;
|
|
248
|
+
lifecycle?.data.delete(key);
|
|
249
|
+
return value;
|
|
250
|
+
}
|
|
218
251
|
/** 重启附带数据仅属于这一条宿主链,不写入调用方配置或共享的进程缓存。 */
|
|
219
252
|
async function setHostRestartData(server, key, value, dispose) {
|
|
220
253
|
const data = hostData.get(server);
|
|
@@ -234,46 +267,99 @@ function takeHostRestartData(server, key) {
|
|
|
234
267
|
return value;
|
|
235
268
|
}
|
|
236
269
|
/** 关闭等待正在替换服务器的重启,避免旧入口返回后新会话继续写出。 */
|
|
237
|
-
function bindHostLifecycle(server, closeSession) {
|
|
270
|
+
function bindHostLifecycle(server, closeSession, preparedLifecycle, isRetired, finalize) {
|
|
238
271
|
const nativeRestart = server.restart.bind(server);
|
|
239
272
|
const generation = getDevServerCloseRecord(server);
|
|
240
273
|
const nativeClose = generation.close;
|
|
274
|
+
const hostWatcher = server.watcher;
|
|
275
|
+
const nativeWatcherClose = hostWatcher?.close.bind(hostWatcher);
|
|
276
|
+
let watcherCloseTask;
|
|
277
|
+
const closeHostWatcher = () => watcherCloseTask ??= Promise.resolve().then(() => nativeWatcherClose?.()).then(() => {});
|
|
278
|
+
if (hostWatcher) hostWatcher.close = closeHostWatcher;
|
|
241
279
|
const scope = getDevShutdownScope();
|
|
242
280
|
const inlineConfig = server.config.inlineConfig;
|
|
243
|
-
const inherited = inlineConfig
|
|
281
|
+
const inherited = preparedLifecycle ?? takeHostLifecycle(inlineConfig);
|
|
282
|
+
const operations = inherited?.operations ?? createHostOperations();
|
|
244
283
|
const inheritedRestart = inherited?.restartTask;
|
|
284
|
+
let inheritedRestartSettled = !inheritedRestart;
|
|
285
|
+
inheritedRestart?.then(() => {
|
|
286
|
+
inheritedRestartSettled = true;
|
|
287
|
+
}, () => {
|
|
288
|
+
inheritedRestartSettled = true;
|
|
289
|
+
});
|
|
245
290
|
const data = /* @__PURE__ */ new Map();
|
|
246
291
|
hostData.set(server, {
|
|
247
292
|
incoming: inherited?.data,
|
|
248
293
|
outgoing: data
|
|
249
294
|
});
|
|
250
|
-
delete inlineConfig[hostLifecycleKey];
|
|
251
295
|
const stopping = Promise.withResolvers();
|
|
252
296
|
let restartTask;
|
|
253
297
|
let closeTask;
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
298
|
+
let retired = false;
|
|
299
|
+
for (const environment of Object.values(server.environments ?? {})) {
|
|
300
|
+
const listen = environment.listen.bind(environment);
|
|
301
|
+
environment.listen = async (...args) => {
|
|
302
|
+
if (!retired && !isRetired?.()) await listen(...args);
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const replacements = /* @__PURE__ */ new Set();
|
|
306
|
+
let restartCleanupFailure;
|
|
307
|
+
const discardRestartResources = async (status) => {
|
|
308
|
+
const active = getDevServerCloseRecord(server);
|
|
309
|
+
const abandoned = [...replacements].filter((replacement) => replacement !== active);
|
|
310
|
+
replacements.clear();
|
|
311
|
+
await settleHostCleanup([discardRestartData(data, status), ...abandoned.map((replacement) => Promise.resolve().then(() => replacement.close()))]).catch((error) => {
|
|
312
|
+
restartCleanupFailure ??= { error };
|
|
313
|
+
throw error;
|
|
314
|
+
});
|
|
259
315
|
};
|
|
260
316
|
const closeResources = async () => {
|
|
317
|
+
retired = true;
|
|
261
318
|
stopping.resolve();
|
|
319
|
+
const pendingRestart = restartTask;
|
|
262
320
|
const sessionCleanup = settleHostCleanup([
|
|
263
|
-
Promise.resolve().then(closeSession),
|
|
321
|
+
Promise.resolve().then(() => closeSession("close")),
|
|
264
322
|
discardRestartData(data, "incomplete"),
|
|
265
323
|
discardRestartData(inherited?.data, "incomplete")
|
|
266
324
|
]);
|
|
267
|
-
|
|
325
|
+
const hostCleanup = (async () => {
|
|
268
326
|
await sessionCleanup.catch(() => {});
|
|
269
|
-
await
|
|
327
|
+
await pendingRestart?.catch(() => {});
|
|
270
328
|
const current = getDevServerCloseRecord(server);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
329
|
+
await settleHostCleanup([closeHostWatcher(), Promise.resolve().then(() => current !== generation ? current.close() : nativeClose())]);
|
|
330
|
+
})();
|
|
331
|
+
const restartCleanup = (async () => {
|
|
332
|
+
await pendingRestart;
|
|
333
|
+
if (restartCleanupFailure) throw restartCleanupFailure.error;
|
|
334
|
+
})();
|
|
335
|
+
await settleHostCleanup([(async () => {
|
|
336
|
+
await settleHostCleanup([sessionCleanup, hostCleanup]);
|
|
337
|
+
if (!restartCleanupFailure && inheritedRestartSettled) await finalize?.();
|
|
338
|
+
})(), restartCleanup]);
|
|
339
|
+
};
|
|
340
|
+
const closeLocal = () => operations.run(closeResources);
|
|
341
|
+
const close = () => closeTask ??= scope ? scope.run("cleanup", closeLocal) : closeLocal();
|
|
342
|
+
const lifecycle = {
|
|
343
|
+
data,
|
|
344
|
+
operations,
|
|
345
|
+
close: inherited?.close ?? close,
|
|
346
|
+
registerReplacement(replacement) {
|
|
347
|
+
replacements.delete(getDevServerCloseRecord(server));
|
|
348
|
+
replacements.add(replacement);
|
|
349
|
+
},
|
|
350
|
+
get restartTask() {
|
|
351
|
+
return restartTask;
|
|
352
|
+
}
|
|
274
353
|
};
|
|
275
|
-
const close = () => closeTask ??= scope ? scope.run("cleanup", closeResources) : closeResources();
|
|
276
354
|
replaceDevServerClose(server, close);
|
|
355
|
+
if (inherited) {
|
|
356
|
+
const previousGate = generation.gate;
|
|
357
|
+
generation.gate = (closeResources) => {
|
|
358
|
+
const dispatch = () => operations.isInternal() ? closeResources() : inherited.close();
|
|
359
|
+
return previousGate ? previousGate(dispatch) : dispatch();
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
inherited?.registerReplacement(generation);
|
|
277
363
|
server.restart = (force) => {
|
|
278
364
|
if (closeTask || scope?.stopping) return close();
|
|
279
365
|
const restart = async () => {
|
|
@@ -282,12 +368,16 @@ function bindHostLifecycle(server, closeSession) {
|
|
|
282
368
|
if (closeTask || scope?.stopping) return;
|
|
283
369
|
}
|
|
284
370
|
try {
|
|
285
|
-
|
|
371
|
+
retired = true;
|
|
372
|
+
await closeSession("restart");
|
|
373
|
+
if (closeTask || scope?.stopping) return;
|
|
374
|
+
await closeHostWatcher();
|
|
286
375
|
if (closeTask || scope?.stopping) return;
|
|
287
376
|
const config = server.config;
|
|
377
|
+
const carrier = Object.assign(() => {}, { [hostLifecycleKey]: lifecycle });
|
|
288
378
|
const restartConfig = {
|
|
289
379
|
...config.inlineConfig,
|
|
290
|
-
[
|
|
380
|
+
[WEAPP_VITE_HOST_RESTART_CONFIG_KEY]: carrier
|
|
291
381
|
};
|
|
292
382
|
const restartHostConfig = {
|
|
293
383
|
...config,
|
|
@@ -296,25 +386,25 @@ function bindHostLifecycle(server, closeSession) {
|
|
|
296
386
|
server.config = restartHostConfig;
|
|
297
387
|
try {
|
|
298
388
|
await nativeRestart(force);
|
|
389
|
+
if (getDevServerCloseRecord(server) === generation) throw new Error("[weapp-vite] Vite 重启未完成替换宿主交接,请查看原始初始化错误。");
|
|
299
390
|
} finally {
|
|
300
|
-
delete restartConfig[
|
|
391
|
+
delete restartConfig[WEAPP_VITE_HOST_RESTART_CONFIG_KEY];
|
|
301
392
|
if (server.config === restartHostConfig) server.config = config;
|
|
302
393
|
}
|
|
303
394
|
} catch (error) {
|
|
304
395
|
try {
|
|
305
|
-
await
|
|
396
|
+
await discardRestartResources("failed");
|
|
306
397
|
} catch (cleanupError) {
|
|
307
|
-
throw new AggregateError([error, cleanupError], "Host restart and
|
|
398
|
+
throw new AggregateError([error, cleanupError], "Host restart and resource cleanup failed", { cause: error });
|
|
308
399
|
}
|
|
309
400
|
throw error;
|
|
310
|
-
} finally {
|
|
311
|
-
await discardRestartData(data, "incomplete");
|
|
312
401
|
}
|
|
402
|
+
await discardRestartResources("incomplete");
|
|
313
403
|
};
|
|
314
|
-
|
|
404
|
+
const runRestart = () => operations.run(restart);
|
|
405
|
+
return restartTask ??= (scope ? scope.run("restart", runRestart) : runRestart()).finally(() => {
|
|
315
406
|
restartTask = void 0;
|
|
316
407
|
});
|
|
317
408
|
};
|
|
318
409
|
}
|
|
319
|
-
|
|
320
|
-
export { getDevShutdownScope as a, createDevShutdownScope as i, setHostRestartData as n, getDevServerCloseRecord as o, takeHostRestartData as r, replaceDevServerClose as s, bindHostLifecycle as t };
|
|
410
|
+
export { takeHostRestartData as a, getDevServerCloseRecord as c, takeHostLifecycle as i, replaceDevServerClose as l, setHostRestartData as n, createDevShutdownScope as o, takeHostConfigRestartData as r, getDevShutdownScope as s, bindHostLifecycle as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as createCjsConfigLoadError, C as loadViteConfigFile, t as resolveWeappConfigFile } from "./utils-CTGSZp4j.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import path from "pathe";
|
|
4
4
|
import { defu } from "@weapp-core/shared";
|
|
5
|
-
|
|
5
|
+
// src/cli/loadConfig.ts
|
|
6
6
|
async function loadConfig(configFile) {
|
|
7
7
|
const cwd = process.cwd();
|
|
8
8
|
let resolvedConfigFile = configFile;
|
|
@@ -55,5 +55,4 @@ async function loadConfig(configFile) {
|
|
|
55
55
|
dependencies: Array.from(dependencySet)
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
//#endregion
|
|
59
58
|
export { loadConfig as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as loadConfig } from "./loadConfig-CKIdfW4o.mjs";
|