@wevu/compiler 7.2.2 → 7.3.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 +37 -13
- package/dist/index.mjs +12 -12
- 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
|
/**
|
|
@@ -194,6 +208,17 @@ export declare const WE_VU_INTERNAL_TEMPLATE_APIS: readonly ["normalizeClass", "
|
|
|
194
208
|
*/
|
|
195
209
|
export declare function resolveWevuInternalImportModuleId(apiName: string): "virtual:weapp-vite/runtime" | "virtual:weapp-vite/runtime/reactivity" | "virtual:weapp-vite/runtime/template";
|
|
196
210
|
//#endregion
|
|
211
|
+
//#region src/utils/sourcemap.d.ts
|
|
212
|
+
interface EncodedSourceMapLike {
|
|
213
|
+
version: number | string;
|
|
214
|
+
file?: string;
|
|
215
|
+
names: string[];
|
|
216
|
+
sourceRoot?: string;
|
|
217
|
+
sources: string[];
|
|
218
|
+
sourcesContent?: Array<string | null>;
|
|
219
|
+
mappings: string;
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
197
222
|
//#region src/plugins/utils/vueSfcBlockSrc.d.ts
|
|
198
223
|
/**
|
|
199
224
|
* 解析 SFC block `src` 的配置。
|
|
@@ -273,17 +298,6 @@ export declare function getSfcCheckMtime(config?: {
|
|
|
273
298
|
isDev?: boolean;
|
|
274
299
|
}): boolean;
|
|
275
300
|
//#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
301
|
//#region ../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/lib/index.d.ts
|
|
288
302
|
interface BaseComment {
|
|
289
303
|
value: string;
|
|
@@ -1834,7 +1848,7 @@ export declare function stripPageDeclaration(source: string, filename: string):
|
|
|
1834
1848
|
*
|
|
1835
1849
|
* @internal
|
|
1836
1850
|
*/
|
|
1837
|
-
declare const WE_VU_RUNTIME_CAPABILITY_ORDER: readonly ["patchStrategy", "templateRefs", "inlineEvents", "setDataHighFrequencyWarning", "scopedSlots", "layout"];
|
|
1851
|
+
declare const WE_VU_RUNTIME_CAPABILITY_ORDER: readonly ["patchStrategy", "templateRefs", "inlineEvents", "setDataHighFrequencyWarning", "scopedSlots", "layout", "jsxIslands"];
|
|
1838
1852
|
/**
|
|
1839
1853
|
* wevu 编译器内部使用的运行时能力名称。
|
|
1840
1854
|
*
|
|
@@ -2063,6 +2077,8 @@ interface TemplateCompileResult {
|
|
|
2063
2077
|
* v-for 解析结果。
|
|
2064
2078
|
*/
|
|
2065
2079
|
interface ForParseResult {
|
|
2080
|
+
/** 无法拆分为完整别名与列表的非法循环表达式诊断。 */
|
|
2081
|
+
error?: string;
|
|
2066
2082
|
listExp?: string;
|
|
2067
2083
|
rawListExp?: string;
|
|
2068
2084
|
listExpAst?: Expression;
|
|
@@ -2569,10 +2585,18 @@ type VueSfcBlockSignatures = Readonly<Record<VueSfcBlockType, string>>;
|
|
|
2569
2585
|
type VueSfcBlockChanges = VueSfcBlockType[];
|
|
2570
2586
|
interface VueSfcHmrSignatures {
|
|
2571
2587
|
readonly blockSignatures?: VueSfcBlockSignatures;
|
|
2588
|
+
/**
|
|
2589
|
+
* 按 compiler provider 归属的内容签名,供宿主在不依赖具体 provider 名称的情况下维护 HMR 状态。
|
|
2590
|
+
*/
|
|
2591
|
+
readonly contentSignatures?: Readonly<Record<string, string>>;
|
|
2572
2592
|
readonly hasTemplate?: boolean;
|
|
2573
2593
|
readonly nonJsonSignature?: string;
|
|
2574
2594
|
readonly scriptSignature?: string;
|
|
2575
2595
|
readonly styleIndependentSignature?: string;
|
|
2596
|
+
/** 按 provider 归属的模板内容签名。 */
|
|
2597
|
+
readonly templateContentSignatures?: Readonly<Record<string, string>>;
|
|
2598
|
+
/** 按 provider 归属的脚本内容签名。 */
|
|
2599
|
+
readonly scriptContentSignatures?: Readonly<Record<string, string>>;
|
|
2576
2600
|
readonly tailwindContentSignature?: string;
|
|
2577
2601
|
readonly tailwindScriptContentSignature?: string;
|
|
2578
2602
|
readonly tailwindTemplateContentSignature?: string;
|