@wevu/compiler 7.2.2 → 7.4.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 +3 -3
- package/dist/index.d.mts +44 -13
- package/dist/index.mjs +16 -16
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ console.log(result.template)
|
|
|
41
41
|
|
|
42
42
|
### 编译诊断
|
|
43
43
|
|
|
44
|
-
`compileTemplate` 始终返回 `diagnostics
|
|
44
|
+
`compileTemplate` 始终返回 `diagnostics`,供调用方检查错误和警告。`compileSfc`(`compileVueFile`)遇到 error 级模板诊断或 SFC 解析错误时,会抛出公开的 `CompilerDiagnosticError`,不会返回静默降级的产物;warning 仍随成功结果返回。`compileJsxFile` 在存在 JSX 诊断时返回 `diagnostics`。每条诊断以及 `CompilerDiagnosticError` 均包含稳定的 `code`、`severity`、`message`、`filename`、`source` 和可选 `loc`。
|
|
45
45
|
|
|
46
46
|
这是一次 clean cutover:原有 `warnings: string[]` 字段已移除,调用方应改读 `diagnostics`,需要展示文本时使用 `diagnostic.message`。
|
|
47
47
|
|
|
@@ -60,9 +60,9 @@ for (const diagnostic of result.diagnostics) {
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
稳定 code:`WV1001`(模板转换警告)、`WV1002`(模板表达式警告)、`WV1003`(JSX 警告)、`WV2001
|
|
63
|
+
稳定 code:`WV1001`(模板转换警告)、`WV1002`(模板表达式警告)、`WV1003`(JSX 警告)、`WV2001`(模板解析错误,含非法 `v-for`)、`WV2002`(模板编译错误)、`WV2003`(SFC 解析错误)。SFC 解析错误通过 `cause` 保留原始 Vue 错误及其数值 code,不将其混入稳定的 `WV*` code。
|
|
64
64
|
|
|
65
|
-
`loc.start` / `loc.end` 使用半开区间;`offset` 从 0 开始,`line` / `column` 从 1 开始。`compileSfc` 会将内联 `<template>` 位置映射到完整 SFC 源码;外部 `<template src>`
|
|
65
|
+
`loc.start` / `loc.end` 使用半开区间;`offset` 从 0 开始,`line` / `column` 从 1 开始。`compileSfc` 会将内联 `<template>` 位置映射到完整 SFC 源码;外部 `<template src>` 则使用解析后的外部文件名和其自身位置。内置 `<json>` 和 `defineOptions` 改写后的 SFC 重解析错误也映射回输入源码,不依赖 `sourceMap` 开关。模板与 JSX 自有诊断会按 `diagnostic.message` 原样、仅一次地适配到 `warn` 回调;结构化消费应检查返回的 `diagnostics`,并捕获 `CompilerDiagnosticError`。
|
|
66
66
|
|
|
67
67
|
使用页面特性工具:
|
|
68
68
|
|
package/dist/index.d.mts
CHANGED
|
@@ -18,7 +18,7 @@ export declare const builtinComponentsSet: Set<string>;
|
|
|
18
18
|
export declare function isBuiltinComponent(tag: string): boolean;
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/types/diagnostics.d.ts
|
|
21
|
-
type CompilerDiagnosticCode = 'WV1002' | 'WV1003' | 'WV2002' | 'WV2001' | 'WV1001';
|
|
21
|
+
type CompilerDiagnosticCode = 'WV1002' | 'WV1003' | 'WV2003' | 'WV2002' | 'WV2001' | 'WV1001';
|
|
22
22
|
type CompilerDiagnosticSeverity = 'error' | 'warning';
|
|
23
23
|
type CompilerDiagnosticSource = 'expression' | 'jsx' | 'script' | 'sfc' | 'style' | 'template';
|
|
24
24
|
/**
|
|
@@ -47,6 +47,20 @@ interface CompilerDiagnostic {
|
|
|
47
47
|
source: CompilerDiagnosticSource;
|
|
48
48
|
loc?: SourceSpan;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* 携带结构化编译诊断的致命错误。
|
|
52
|
+
*/
|
|
53
|
+
export declare class CompilerDiagnosticError extends Error implements CompilerDiagnostic {
|
|
54
|
+
readonly code: CompilerDiagnosticCode;
|
|
55
|
+
readonly severity: CompilerDiagnosticSeverity;
|
|
56
|
+
readonly filename: string;
|
|
57
|
+
readonly source: CompilerDiagnosticSource;
|
|
58
|
+
readonly loc?: SourceSpan;
|
|
59
|
+
readonly cause?: unknown;
|
|
60
|
+
constructor(diagnostic: CompilerDiagnostic, options?: {
|
|
61
|
+
cause?: unknown;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
50
64
|
//#endregion
|
|
51
65
|
//#region src/types/bindingManifest.d.ts
|
|
52
66
|
/**
|
|
@@ -120,6 +134,7 @@ export declare function createRuntimeBindingManifest(manifest: WevuBindingManife
|
|
|
120
134
|
//#region src/constants.d.ts
|
|
121
135
|
export declare const WE_VU_PAGE_HOOK_TO_FEATURE: {
|
|
122
136
|
readonly onPageScroll: "enableOnPageScroll";
|
|
137
|
+
readonly usePageScrollRestoration: "enableOnPageScroll";
|
|
123
138
|
readonly onPullDownRefresh: "enableOnPullDownRefresh";
|
|
124
139
|
readonly onReachBottom: "enableOnReachBottom";
|
|
125
140
|
readonly onRouteDone: "enableOnRouteDone";
|
|
@@ -166,6 +181,8 @@ export declare const WE_VU_RUNTIME_MODULE_IDS: readonly ["wevu", "wevu/internal-
|
|
|
166
181
|
* 判断模块 ID 是否为 wevu 运行时入口。
|
|
167
182
|
*/
|
|
168
183
|
export declare function isWevuRuntimeModuleId(moduleId: string): boolean;
|
|
184
|
+
/** 页面特性可由独立 router 入口的适配器启用,但该入口不提供组件工厂。 */
|
|
185
|
+
export declare function isWevuPageFeatureModuleId(moduleId: string): boolean;
|
|
169
186
|
/**
|
|
170
187
|
* wevu 运行时 API 名称映射。
|
|
171
188
|
*/
|
|
@@ -194,6 +211,17 @@ export declare const WE_VU_INTERNAL_TEMPLATE_APIS: readonly ["normalizeClass", "
|
|
|
194
211
|
*/
|
|
195
212
|
export declare function resolveWevuInternalImportModuleId(apiName: string): "virtual:weapp-vite/runtime" | "virtual:weapp-vite/runtime/reactivity" | "virtual:weapp-vite/runtime/template";
|
|
196
213
|
//#endregion
|
|
214
|
+
//#region src/utils/sourcemap.d.ts
|
|
215
|
+
interface EncodedSourceMapLike {
|
|
216
|
+
version: number | string;
|
|
217
|
+
file?: string;
|
|
218
|
+
names: string[];
|
|
219
|
+
sourceRoot?: string;
|
|
220
|
+
sources: string[];
|
|
221
|
+
sourcesContent?: Array<string | null>;
|
|
222
|
+
mappings: string;
|
|
223
|
+
}
|
|
224
|
+
//#endregion
|
|
197
225
|
//#region src/plugins/utils/vueSfcBlockSrc.d.ts
|
|
198
226
|
/**
|
|
199
227
|
* 解析 SFC block `src` 的配置。
|
|
@@ -273,17 +301,6 @@ export declare function getSfcCheckMtime(config?: {
|
|
|
273
301
|
isDev?: boolean;
|
|
274
302
|
}): boolean;
|
|
275
303
|
//#endregion
|
|
276
|
-
//#region src/utils/sourcemap.d.ts
|
|
277
|
-
interface EncodedSourceMapLike {
|
|
278
|
-
version: number | string;
|
|
279
|
-
file?: string;
|
|
280
|
-
names: string[];
|
|
281
|
-
sourceRoot?: string;
|
|
282
|
-
sources: string[];
|
|
283
|
-
sourcesContent?: Array<string | null>;
|
|
284
|
-
mappings: string;
|
|
285
|
-
}
|
|
286
|
-
//#endregion
|
|
287
304
|
//#region ../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/lib/index.d.ts
|
|
288
305
|
interface BaseComment {
|
|
289
306
|
value: string;
|
|
@@ -1834,7 +1851,7 @@ export declare function stripPageDeclaration(source: string, filename: string):
|
|
|
1834
1851
|
*
|
|
1835
1852
|
* @internal
|
|
1836
1853
|
*/
|
|
1837
|
-
declare const WE_VU_RUNTIME_CAPABILITY_ORDER: readonly ["patchStrategy", "templateRefs", "inlineEvents", "setDataHighFrequencyWarning", "scopedSlots", "layout"];
|
|
1854
|
+
declare const WE_VU_RUNTIME_CAPABILITY_ORDER: readonly ["patchStrategy", "templateRefs", "inlineEvents", "setDataHighFrequencyWarning", "scopedSlots", "layout", "jsxIslands"];
|
|
1838
1855
|
/**
|
|
1839
1856
|
* wevu 编译器内部使用的运行时能力名称。
|
|
1840
1857
|
*
|
|
@@ -2063,6 +2080,8 @@ interface TemplateCompileResult {
|
|
|
2063
2080
|
* v-for 解析结果。
|
|
2064
2081
|
*/
|
|
2065
2082
|
interface ForParseResult {
|
|
2083
|
+
/** 无法拆分为完整别名与列表的非法循环表达式诊断。 */
|
|
2084
|
+
error?: string;
|
|
2066
2085
|
listExp?: string;
|
|
2067
2086
|
rawListExp?: string;
|
|
2068
2087
|
listExpAst?: Expression;
|
|
@@ -2106,6 +2125,10 @@ interface TemplateCompileOptions {
|
|
|
2106
2125
|
objectLiteralBindMode?: ObjectLiteralBindMode;
|
|
2107
2126
|
mustacheInterpolation?: MustacheInterpolationMode;
|
|
2108
2127
|
formatWxml?: boolean;
|
|
2128
|
+
/**
|
|
2129
|
+
* 保留模板注释,供最终产物阶段统一处理;默认移除。
|
|
2130
|
+
*/
|
|
2131
|
+
preserveComments?: boolean;
|
|
2109
2132
|
runtimeBindingManifest?: WevuRuntimeBindingManifestMode;
|
|
2110
2133
|
wxsExtension?: string;
|
|
2111
2134
|
classStyleWxsSrc?: string;
|
|
@@ -2569,10 +2592,18 @@ type VueSfcBlockSignatures = Readonly<Record<VueSfcBlockType, string>>;
|
|
|
2569
2592
|
type VueSfcBlockChanges = VueSfcBlockType[];
|
|
2570
2593
|
interface VueSfcHmrSignatures {
|
|
2571
2594
|
readonly blockSignatures?: VueSfcBlockSignatures;
|
|
2595
|
+
/**
|
|
2596
|
+
* 按 compiler provider 归属的内容签名,供宿主在不依赖具体 provider 名称的情况下维护 HMR 状态。
|
|
2597
|
+
*/
|
|
2598
|
+
readonly contentSignatures?: Readonly<Record<string, string>>;
|
|
2572
2599
|
readonly hasTemplate?: boolean;
|
|
2573
2600
|
readonly nonJsonSignature?: string;
|
|
2574
2601
|
readonly scriptSignature?: string;
|
|
2575
2602
|
readonly styleIndependentSignature?: string;
|
|
2603
|
+
/** 按 provider 归属的模板内容签名。 */
|
|
2604
|
+
readonly templateContentSignatures?: Readonly<Record<string, string>>;
|
|
2605
|
+
/** 按 provider 归属的脚本内容签名。 */
|
|
2606
|
+
readonly scriptContentSignatures?: Readonly<Record<string, string>>;
|
|
2576
2607
|
readonly tailwindContentSignature?: string;
|
|
2577
2608
|
readonly tailwindScriptContentSignature?: string;
|
|
2578
2609
|
readonly tailwindTemplateContentSignature?: string;
|