@wevu/compiler 7.4.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/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import { n as StaticRouteValue, t as StaticPageDeclaration } from "./public-DEO6JWFi.mjs";
1
+ import { n as StaticPageMeta, r as StaticRouteValue, t as StaticPageDeclaration } from "./public-BqBfNRjA.mjs";
2
2
  import { WevuBindingUpdateMode, WevuBindingUpdateMode as WevuBindingUpdateMode$1, WevuRuntimeBindingManifestV1, WevuRuntimeBindingRecordV1 } from "@weapp-core/constants";
3
3
  import { LRUCache } from "lru-cache";
4
+ import MagicString from "magic-string";
4
5
  import { SFCBlock, SFCDescriptor, SFCParseResult, SFCStyleBlock } from "vue/compiler-sfc";
5
6
  import * as t from "@weapp-vite/ast/babelTypes";
6
7
  import { Expression, File } from "@weapp-vite/ast/babelTypes";
@@ -228,6 +229,7 @@ interface EncodedSourceMapLike {
228
229
  */
229
230
  interface ResolveSfcBlockSrcOptions {
230
231
  resolveId?: (source: string, importer?: string) => Promise<string | undefined>;
232
+ /** 自定义读取器的异常原样传出,保留调用方用于重试或重新同步的控制流。 */
231
233
  readFile?: (id: string, options?: {
232
234
  checkMtime?: boolean;
233
235
  }) => Promise<string>;
@@ -1898,6 +1900,10 @@ interface JsonMergeContext {
1898
1900
  filename?: string;
1899
1901
  kind?: 'app' | 'page' | 'component' | 'unknown';
1900
1902
  stage: JsonMergeStage;
1903
+ /** 当前 SFC 页面的静态路由声明。 */
1904
+ routeConfig?: StaticPageDeclaration;
1905
+ /** 整个页面元信息对象可静态提取时提供。 */
1906
+ pageMeta?: StaticPageMeta;
1901
1907
  }
1902
1908
  /**
1903
1909
  * JSON 合并函数。
@@ -1987,6 +1993,8 @@ interface MiniProgramDirectiveAttrs {
1987
1993
  */
1988
1994
  interface MiniProgramPlatform {
1989
1995
  name: string;
1996
+ /** 非微信宿主复用 WXML 语法时,显式关闭原生插槽上下文协议。 */
1997
+ nativeSlotContext?: boolean;
1990
1998
  directives: MiniProgramDirectiveAttrs;
1991
1999
  wrapIf: (exp: string, content: string, renderMustache: (exp: string) => string) => string;
1992
2000
  wrapElseIf: (exp: string, content: string, renderMustache: (exp: string) => string) => string;
@@ -2094,6 +2102,17 @@ interface ForParseResult {
2094
2102
  index?: string;
2095
2103
  key?: string;
2096
2104
  itemAliases?: Record<string, string>;
2105
+ /** 原生声明寻址使用实际 wx:key,不重新计算用户 key 表达式。 */
2106
+ effectiveNativeKey?: {
2107
+ kind: 'field';
2108
+ field: string;
2109
+ } | {
2110
+ kind: 'self';
2111
+ } | {
2112
+ kind: 'position';
2113
+ };
2114
+ /** 源码循环别名与避开祖先及编译器内建标识符的原生别名。 */
2115
+ nativeAliases?: Record<string, string>;
2097
2116
  /** 需要在逻辑层完整执行的原始循环项模式。 */
2098
2117
  itemPattern?: string;
2099
2118
  /** 当前循环项模式是否需要投影,避免模板层近似执行。 */
@@ -2113,10 +2132,16 @@ interface TemplateCompileOptions {
2113
2132
  propsAliases?: Record<string, string>;
2114
2133
  propsDerivedKeys?: string[];
2115
2134
  scriptSetupBindings?: Record<string, unknown>;
2135
+ /** 可能与宿主属性同名的 setup 绑定,通过独立计算字段交付模板。 */
2136
+ scriptSetupPropConflicts?: readonly string[];
2116
2137
  htmlTagToWxml?: boolean | Record<string, string>;
2117
2138
  htmlTagToWxmlTagClass?: boolean;
2118
2139
  scopedSlotsCompiler?: ScopedSlotsCompilerMode;
2119
2140
  scopedSlotsRequireProps?: boolean;
2141
+ /** 显式启用微信原生普通插槽的声明上下文协议;默认关闭。 */
2142
+ nativeSlotContext?: boolean;
2143
+ /** 上下文分析后需要声明协议的组件标签;未提供时保守保留全部 wevu 组件。@internal */
2144
+ nativeSlotContextTags?: ReadonlySet<string>;
2120
2145
  slotSingleRootNoWrapper?: boolean;
2121
2146
  slotFallbackWrapper?: SlotFallbackWrapperConfig;
2122
2147
  slotFallbackWrapperStrategy?: SlotFallbackWrapperStrategy;
@@ -2292,6 +2317,16 @@ export declare function getMiniProgramTemplatePlatform(platform?: MpPlatform): M
2292
2317
  */
2293
2318
  export declare function compileVueTemplateToWxml(template: string, filename: string, options?: TemplateCompileOptions): TemplateCompileResult;
2294
2319
  //#endregion
2320
+ //#region src/plugins/vue/transform/compileVueFile/nativeSlotContext/source.d.ts
2321
+ interface SourceFacts {
2322
+ source: string;
2323
+ descriptor?: SFCDescriptor;
2324
+ invalid?: boolean;
2325
+ ast?: File;
2326
+ }
2327
+ /** 缓存单个源文件的原始输入与解析事实,不保存递归分类或递归任务。 */
2328
+ type NativeSlotContextAnalysisCache = Map<string, Promise<SourceFacts | undefined>>;
2329
+ //#endregion
2295
2330
  //#region src/plugins/vue/transform/compileVueFile/types.d.ts
2296
2331
  interface ResolvedUsingComponentInfo {
2297
2332
  from?: string;
@@ -2316,8 +2351,12 @@ interface VueTransformResult {
2316
2351
  componentGenerics?: TemplateCompileResult['componentGenerics'];
2317
2352
  classStyleWxs?: boolean;
2318
2353
  meta?: {
2354
+ routeConfig?: JsonMergeContext['routeConfig'];
2355
+ pageMeta?: JsonMergeContext['pageMeta'];
2319
2356
  /** @internal */
2320
2357
  componentStyleOptions?: ComponentStyleOptions;
2358
+ /** 已解析模板和计算绑定的注册签名;包含外部模板与静态 JSX 展开。@internal */
2359
+ templateRegistrationSignature?: string;
2321
2360
  /** @internal */
2322
2361
  runtimeCapabilities?: WevuRuntimeCapabilityMetadata;
2323
2362
  hasScriptSetup?: boolean;
@@ -2325,6 +2364,10 @@ interface VueTransformResult {
2325
2364
  jsonMacroHash?: string;
2326
2365
  defineOptionsHash?: string;
2327
2366
  sfcSrcDeps?: string[];
2367
+ /** 模板和脚本外部块的编译输入,变化时必须失效完整编译结果。@internal */
2368
+ sfcSrcCompilationDeps?: string[];
2369
+ /** 原生插槽上下文分析读取的源码依赖,变化时必须重新编译引用方。@internal */
2370
+ nativeSlotContextDeps?: string[];
2328
2371
  /** 已解析样式中的 CSS 变量表达式快照。@internal */
2329
2372
  cssVars?: string[];
2330
2373
  styleBlocks?: SFCStyleBlock[];
@@ -2447,11 +2490,17 @@ interface CompileVueFileOptions {
2447
2490
  mergeStrategy?: JsonMergeStrategy;
2448
2491
  };
2449
2492
  sfcSrc?: ResolveSfcBlockSrcOptions;
2493
+ /** JSX/TSX 跨文件静态展开的同步源码读取;未提供时读取磁盘。 */
2494
+ jsx?: {
2495
+ readFile: (filename: string) => string;
2496
+ };
2450
2497
  wevuDefaults?: WevuDefaults;
2451
2498
  /**
2452
2499
  * 缓存被当前 SFC 引用的 Vue 组件静态元信息,避免重复读取和解析同一组件。
2453
2500
  */
2454
2501
  componentMetaCache?: Map<string, Promise<VueSfcStaticComponentMeta>>;
2502
+ /** 原生插槽上下文分析的单文件事实缓存,不缓存传递闭包。@internal */
2503
+ nativeSlotContextCache?: NativeSlotContextAnalysisCache;
2455
2504
  }
2456
2505
  //#endregion
2457
2506
  //#region src/plugins/jsx/compileJsxFile.d.ts
@@ -2821,6 +2870,12 @@ interface TransformScriptOptions {
2821
2870
  * 当前组件模板包含 scoped slot outlet,需要接收 scoped slot 桥接属性。
2822
2871
  */
2823
2872
  scopedSlotHostProperties?: boolean;
2873
+ /**
2874
+ * 微信原生插槽上下文协议,由 SFC 编译期平台与插槽配置决定。
2875
+ *
2876
+ * @internal
2877
+ */
2878
+ nativeSlotContext?: boolean;
2824
2879
  /**
2825
2880
  * 当前 SFC 的 CSS Modules 映射。
2826
2881
  */
@@ -3009,4 +3064,4 @@ interface CollectVueTemplateTagsOptions {
3009
3064
  */
3010
3065
  export declare function collectVueTemplateTags(template: string, options: CollectVueTemplateTagsOptions): Set<string>;
3011
3066
  //#endregion
3012
- export { type AstEngineName, type AutoImportTagsOptions, type AutoUsingComponentsOptions, type BindingCondition, type ClassStyleBinding, type ClassStyleRuntime, type CollectVueTemplateTagsOptions, type CompileVueFileOptions, type CompilerAppShell, type CompilerDiagnostic, type CompilerDiagnosticCode, type CompilerDiagnosticSeverity, type CompilerDiagnosticSource, type CompilerLayoutPropValue, type CompilerPageLayout, type CompilerPageLayoutPlan, type ComponentStyleOptions, type ComponentStylePrimitive, type ExtractPageDeclarationWithDependenciesResult, type ForParseResult, type InlineExpressionAsset, type JsLikeLang, type JsonConfig, type JsonMergeContext, type JsonMergeStage, type JsonMergeStrategy, type MiniProgramPlatform, type ModuleResolver, type MpPlatform, type ReadAndParseSfcOptions, type ResolveSfcBlockSrcOptions, type ResolvedUsingComponentInfo, type ResolvedUsingComponentPath, type ScopedSlotComponentAsset, type SlotFallbackWrapperComponentAsset, type SlotFallbackWrapperStrategy, type SourcePosition, type SourceSpan, type StaticComponentStyleOption, type StaticPageDeclaration, type StaticRouteValue, type StyleCompileOptions, type StyleCompileResult, type TemplateCompileOptions, type TemplateCompileResult, type TemplateRefBinding, type TransformResult, type TransformScriptOptions, type TransformUniAppSourceOptions, type UniAppCompatibilityTarget, type VueSfcBlockChanges, type VueSfcBlockSignatures, type VueSfcBlockType, type VueSfcHmrSignatures, type VueTransformResult, type WevuBindingDependencyV1, type WevuBindingKind, type WevuBindingManifestFeaturesV1, type WevuBindingManifestV1, type WevuBindingRecordV1, type WevuBindingScopeV1, type WevuBindingUpdateMode, type WevuDefaults, type WevuRuntimeBindingManifestMode, type WevuRuntimeBindingManifestV1, type WevuRuntimeBindingRecordV1, compileVueFile as compileSfc, compileVueStyleToWxss as compileStyle, compileVueTemplateToWxml as compileTemplate, transformScript as transformSfcScript };
3067
+ export { type AstEngineName, type AutoImportTagsOptions, type AutoUsingComponentsOptions, type BindingCondition, type ClassStyleBinding, type ClassStyleRuntime, type CollectVueTemplateTagsOptions, type CompileVueFileOptions, type CompilerAppShell, type CompilerDiagnostic, type CompilerDiagnosticCode, type CompilerDiagnosticSeverity, type CompilerDiagnosticSource, type CompilerLayoutPropValue, type CompilerPageLayout, type CompilerPageLayoutPlan, type ComponentStyleOptions, type ComponentStylePrimitive, type ExtractPageDeclarationWithDependenciesResult, type ForParseResult, type InlineExpressionAsset, type JsLikeLang, type JsonConfig, type JsonMergeContext, type JsonMergeFunction, type JsonMergeStage, type JsonMergeStrategy, type MiniProgramPlatform, type ModuleResolver, type MpPlatform, type ReadAndParseSfcOptions, type ResolveSfcBlockSrcOptions, type ResolvedUsingComponentInfo, type ResolvedUsingComponentPath, type ScopedSlotComponentAsset, type SlotFallbackWrapperComponentAsset, type SlotFallbackWrapperStrategy, type SourcePosition, type SourceSpan, type StaticComponentStyleOption, type StaticPageDeclaration, type StaticPageMeta, type StaticRouteValue, type StyleCompileOptions, type StyleCompileResult, type TemplateCompileOptions, type TemplateCompileResult, type TemplateRefBinding, type TransformResult, type TransformScriptOptions, type TransformUniAppSourceOptions, type UniAppCompatibilityTarget, type VueSfcBlockChanges, type VueSfcBlockSignatures, type VueSfcBlockType, type VueSfcHmrSignatures, type VueTransformResult, type WevuBindingDependencyV1, type WevuBindingKind, type WevuBindingManifestFeaturesV1, type WevuBindingManifestV1, type WevuBindingRecordV1, type WevuBindingScopeV1, type WevuBindingUpdateMode, type WevuDefaults, type WevuRuntimeBindingManifestMode, type WevuRuntimeBindingManifestV1, type WevuRuntimeBindingRecordV1, compileVueFile as compileSfc, compileVueStyleToWxss as compileStyle, compileVueTemplateToWxml as compileTemplate, transformScript as transformSfcScript };