@wevu/compiler 6.16.27 → 6.16.29
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 +18 -1
- package/dist/index.mjs +108 -14
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -251,6 +251,7 @@ interface TemplateCompileResult {
|
|
|
251
251
|
code: string;
|
|
252
252
|
warnings: string[];
|
|
253
253
|
scopedSlotComponents?: ScopedSlotComponentAsset[];
|
|
254
|
+
slotFallbackWrapperComponent?: SlotFallbackWrapperComponentAsset;
|
|
254
255
|
componentGenerics?: Record<string, true>;
|
|
255
256
|
classStyleRuntime?: ClassStyleRuntime;
|
|
256
257
|
classStyleBindings?: ClassStyleBinding[];
|
|
@@ -288,6 +289,7 @@ interface TemplateCompileOptions {
|
|
|
288
289
|
scopedSlotsRequireProps?: boolean;
|
|
289
290
|
slotSingleRootNoWrapper?: boolean;
|
|
290
291
|
slotFallbackWrapper?: SlotFallbackWrapperConfig;
|
|
292
|
+
slotFallbackWrapperStrategy?: SlotFallbackWrapperStrategy;
|
|
291
293
|
slotMultipleInstance?: boolean;
|
|
292
294
|
classStyleRuntime?: ClassStyleRuntime | 'auto';
|
|
293
295
|
objectLiteralBindMode?: ObjectLiteralBindMode;
|
|
@@ -303,6 +305,20 @@ interface TemplateCompileOptions {
|
|
|
303
305
|
* 作用域插槽编译模式。
|
|
304
306
|
*/
|
|
305
307
|
type ScopedSlotsCompilerMode = 'auto' | 'augmented' | 'off';
|
|
308
|
+
/**
|
|
309
|
+
* 命名插槽 fallback 容器默认策略。
|
|
310
|
+
*/
|
|
311
|
+
type SlotFallbackWrapperStrategy = 'view' | 'virtual-host';
|
|
312
|
+
/**
|
|
313
|
+
* 命名插槽 fallback 虚拟宿主组件资源描述。
|
|
314
|
+
*/
|
|
315
|
+
interface SlotFallbackWrapperComponentAsset {
|
|
316
|
+
tagName: string;
|
|
317
|
+
componentBase: string;
|
|
318
|
+
template: string;
|
|
319
|
+
script: string;
|
|
320
|
+
config: Record<string, any>;
|
|
321
|
+
}
|
|
306
322
|
/**
|
|
307
323
|
* 命名插槽 fallback 容器策略匹配器。
|
|
308
324
|
*/
|
|
@@ -440,6 +456,7 @@ interface VueTransformResult {
|
|
|
440
456
|
config?: string;
|
|
441
457
|
cssModules?: Record<string, Record<string, string>>;
|
|
442
458
|
scopedSlotComponents?: TemplateCompileResult['scopedSlotComponents'];
|
|
459
|
+
slotFallbackWrapperComponent?: TemplateCompileResult['slotFallbackWrapperComponent'];
|
|
443
460
|
componentGenerics?: TemplateCompileResult['componentGenerics'];
|
|
444
461
|
classStyleWxs?: boolean;
|
|
445
462
|
meta?: {
|
|
@@ -917,4 +934,4 @@ interface CollectVueTemplateTagsOptions {
|
|
|
917
934
|
*/
|
|
918
935
|
declare function collectVueTemplateTags(template: string, options: CollectVueTemplateTagsOptions): Set<string>;
|
|
919
936
|
//#endregion
|
|
920
|
-
export { type AstEngineName, type AutoImportTagsOptions, type AutoUsingComponentsOptions, CLASS_STYLE_WXS_FILE, CLASS_STYLE_WXS_MODULE, type ClassStyleBinding, type ClassStyleRuntime, type CollectVueTemplateTagsOptions, type CompileVueFileOptions, type ForParseResult, type InlineExpressionAsset, type JsLikeLang, type JsonConfig, type JsonMergeContext, type JsonMergeStage, type JsonMergeStrategy, type MiniProgramPlatform, type ModuleResolver, type MpPlatform, RESERVED_VUE_COMPONENT_TAGS, type ReadAndParseSfcOptions, type ResolveSfcBlockSrcOptions, type ResolvedUsingComponentInfo, type ResolvedUsingComponentPath, type ScopedSlotComponentAsset, type StyleCompileOptions, type StyleCompileResult, type TemplateCompileOptions, type TemplateCompileResult, type TemplateRefBinding, type TransformResult, type TransformScriptOptions, VUE_COMPONENT_TAG_RE, type VueTransformResult, WE_VU_MODULE_ID, WE_VU_PAGE_HOOK_TO_FEATURE, WE_VU_RUNTIME_APIS, type WevuDefaults, WevuPageFeatureFlag, WevuPageHookName, WevuRuntimeApiName, alipayPlatform, buildClassStyleComputedCode, buildClassStyleWxsTag, builtinComponentsSet, clearFileCaches, collectTargetOptionsObjectsFromCode, collectVueTemplateTags, collectWevuFeaturesFromCodeReachableImports, collectWevuPageFeatureFlags, collectWevuPageFeatureFlagsFromCode, compileConfigBlocks, compileJsxFile, compileVueFile as compileSfc, compileVueFile, compileVueStyleToWxss as compileStyle, compileVueStyleToWxss, compileVueTemplateToWxml as compileTemplate, compileVueTemplateToWxml, createJsonMerger, createPageEntryMatcher, defaultMiniProgramPlatform, defaultMiniProgramTemplatePlatform, defaultPlatform, evaluateJsLikeConfig, extractJsonMacroFromScriptSetup, generateScopedId, getClassStyleWxsSource, getDefaultMiniProgramPlatform, getDefaultMiniProgramTemplatePlatform, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeatureFlagsIntoOptionsObject, injectWevuPageFeaturesInJs, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isInvalidate, isJsonLikeLang, loadCache, mergeJsonWithStrategy, mtimeCache, normalizeConfigLang, pathExists, preprocessScriptSetupSrc, preprocessScriptSrc, readAndParseSfc, readFile, resolveClassStyleWxsLocation, resolveJsLikeLang, resolveSfcBlockSrc, restoreScriptSetupSrc, restoreScriptSrc, stripJsonMacroCallsFromCode, swanPlatform, transformScript, transformScript as transformSfcScript, ttPlatform, wechatPlatform };
|
|
937
|
+
export { type AstEngineName, type AutoImportTagsOptions, type AutoUsingComponentsOptions, CLASS_STYLE_WXS_FILE, CLASS_STYLE_WXS_MODULE, type ClassStyleBinding, type ClassStyleRuntime, type CollectVueTemplateTagsOptions, type CompileVueFileOptions, type ForParseResult, type InlineExpressionAsset, type JsLikeLang, type JsonConfig, type JsonMergeContext, type JsonMergeStage, type JsonMergeStrategy, type MiniProgramPlatform, type ModuleResolver, type MpPlatform, RESERVED_VUE_COMPONENT_TAGS, type ReadAndParseSfcOptions, type ResolveSfcBlockSrcOptions, type ResolvedUsingComponentInfo, type ResolvedUsingComponentPath, type ScopedSlotComponentAsset, type SlotFallbackWrapperComponentAsset, type SlotFallbackWrapperStrategy, type StyleCompileOptions, type StyleCompileResult, type TemplateCompileOptions, type TemplateCompileResult, type TemplateRefBinding, type TransformResult, type TransformScriptOptions, VUE_COMPONENT_TAG_RE, type VueTransformResult, WE_VU_MODULE_ID, WE_VU_PAGE_HOOK_TO_FEATURE, WE_VU_RUNTIME_APIS, type WevuDefaults, WevuPageFeatureFlag, WevuPageHookName, WevuRuntimeApiName, alipayPlatform, buildClassStyleComputedCode, buildClassStyleWxsTag, builtinComponentsSet, clearFileCaches, collectTargetOptionsObjectsFromCode, collectVueTemplateTags, collectWevuFeaturesFromCodeReachableImports, collectWevuPageFeatureFlags, collectWevuPageFeatureFlagsFromCode, compileConfigBlocks, compileJsxFile, compileVueFile as compileSfc, compileVueFile, compileVueStyleToWxss as compileStyle, compileVueStyleToWxss, compileVueTemplateToWxml as compileTemplate, compileVueTemplateToWxml, createJsonMerger, createPageEntryMatcher, defaultMiniProgramPlatform, defaultMiniProgramTemplatePlatform, defaultPlatform, evaluateJsLikeConfig, extractJsonMacroFromScriptSetup, generateScopedId, getClassStyleWxsSource, getDefaultMiniProgramPlatform, getDefaultMiniProgramTemplatePlatform, getMiniProgramTemplatePlatform, getSfcCheckMtime, injectWevuPageFeatureFlagsIntoOptionsObject, injectWevuPageFeaturesInJs, injectWevuPageFeaturesInJsWithResolver, invalidateFileCache, isAutoImportCandidateTag, isBuiltinComponent, isInvalidate, isJsonLikeLang, loadCache, mergeJsonWithStrategy, mtimeCache, normalizeConfigLang, pathExists, preprocessScriptSetupSrc, preprocessScriptSrc, readAndParseSfc, readFile, resolveClassStyleWxsLocation, resolveJsLikeLang, resolveSfcBlockSrc, restoreScriptSetupSrc, restoreScriptSrc, stripJsonMacroCallsFromCode, swanPlatform, transformScript, transformScript as transformSfcScript, ttPlatform, wechatPlatform };
|
package/dist/index.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import os from "node:os";
|
|
|
13
13
|
import process from "node:process";
|
|
14
14
|
import { collectFeatureFlagsFromCode, collectJsxImportedComponentsAndDefaultExportFromBabelAst, collectJsxTemplateTagsFromBabelExpression, getRenderPropertyFromComponentOptions, parseJsLikeWithEngine, resolveRenderExpressionFromComponentOptions, toStaticObjectKey, unwrapTypeScriptExpression } from "@weapp-vite/ast";
|
|
15
15
|
import { LRUCache } from "lru-cache";
|
|
16
|
-
import { WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_FUNCTION_PROP_PATHS_KEY, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_PAGE_KEY, WEVU_LAYOUT_HOSTS_KEY, WEVU_LAYOUT_HOST_ID_PREFIX, WEVU_LAYOUT_HOST_REF_PREFIX, WEVU_MODEL_HANDLER, WEVU_OWNER_HANDLER, WEVU_PROPS_ALIASES_KEY, WEVU_PROPS_DERIVED_KEYS_KEY, WEVU_PROPS_KEY, WEVU_SLOT_NAMES_ATTR, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_KEY, WEVU_SLOT_OWNER_PROXY_KEY, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_PROPS_DATA_KEY, WEVU_SLOT_PROPS_KEY, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY, WEVU_TEMPLATE_REFS_KEY, WEVU_TEMPLATE_REF_CLASS_PREFIX } from "@weapp-core/constants";
|
|
16
|
+
import { WEVU_CLASS_STYLE_RUNTIME_FILE, WEVU_CLASS_STYLE_RUNTIME_MODULE, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_FUNCTION_PROP_PATHS_KEY, WEVU_INLINE_HANDLER, WEVU_INLINE_MAP_KEY, WEVU_IS_PAGE_KEY, WEVU_LAYOUT_HOSTS_KEY, WEVU_LAYOUT_HOST_ID_PREFIX, WEVU_LAYOUT_HOST_REF_PREFIX, WEVU_MODEL_HANDLER, WEVU_OWNER_HANDLER, WEVU_PROPS_ALIASES_KEY, WEVU_PROPS_DERIVED_KEYS_KEY, WEVU_PROPS_KEY, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE, WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME, WEVU_SLOT_NAMES_ATTR, WEVU_SLOT_NAMES_PROP, WEVU_SLOT_OWNER_ID_ATTR, WEVU_SLOT_OWNER_ID_KEY, WEVU_SLOT_OWNER_ID_PROP, WEVU_SLOT_OWNER_KEY, WEVU_SLOT_OWNER_PROXY_KEY, WEVU_SLOT_PROPS_ATTR, WEVU_SLOT_PROPS_DATA_KEY, WEVU_SLOT_PROPS_KEY, WEVU_SLOT_SCOPE_ATTR, WEVU_SLOT_SCOPE_KEY, WEVU_TEMPLATE_REFS_KEY, WEVU_TEMPLATE_REF_CLASS_PREFIX } from "@weapp-core/constants";
|
|
17
17
|
import { compileScript, parse } from "vue/compiler-sfc";
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import { parse as parse$1 } from "@vue/compiler-dom";
|
|
@@ -6964,13 +6964,8 @@ function matchesSlotFallbackWrapperMatcher(matcher, value) {
|
|
|
6964
6964
|
if (Array.isArray(matcher)) return matcher.some((item) => matchesSlotFallbackWrapperMatcher(item, value));
|
|
6965
6965
|
return typeof matcher === "string" ? matcher === value : matcher.test(value);
|
|
6966
6966
|
}
|
|
6967
|
-
function normalizeSlotFallbackWrapperTag(tag
|
|
6968
|
-
|
|
6969
|
-
if (normalized === "block") {
|
|
6970
|
-
context.warnings.push("slot fallback wrapper 不支持配置为 block,已回退为 view。");
|
|
6971
|
-
return "view";
|
|
6972
|
-
}
|
|
6973
|
-
return normalized;
|
|
6967
|
+
function normalizeSlotFallbackWrapperTag(tag) {
|
|
6968
|
+
return tag?.trim() || "view";
|
|
6974
6969
|
}
|
|
6975
6970
|
function mergeSlotFallbackWrapperAttrs(base, override) {
|
|
6976
6971
|
if (!base) return override;
|
|
@@ -6982,16 +6977,16 @@ function mergeSlotFallbackWrapperAttrs(base, override) {
|
|
|
6982
6977
|
}
|
|
6983
6978
|
function resolveSlotFallbackWrapper(context, info) {
|
|
6984
6979
|
const resolved = {
|
|
6985
|
-
tag: normalizeSlotFallbackWrapperTag(context.slotFallbackWrapper.tag
|
|
6980
|
+
tag: normalizeSlotFallbackWrapperTag(context.slotFallbackWrapper.tag),
|
|
6986
6981
|
attrs: context.slotFallbackWrapper.attrs,
|
|
6987
6982
|
singleRootNoWrapper: context.slotFallbackWrapper.singleRootNoWrapper ?? context.slotSingleRootNoWrapper
|
|
6988
6983
|
};
|
|
6989
6984
|
for (const rule of context.slotFallbackWrapper.rules) if (matchesSlotFallbackWrapperMatcher(rule.component, info.component) && matchesSlotFallbackWrapperMatcher(rule.componentName, info.componentName) && matchesSlotFallbackWrapperMatcher(rule.slot, info.slot)) {
|
|
6990
|
-
if (rule.tag) resolved.tag = normalizeSlotFallbackWrapperTag(rule.tag
|
|
6985
|
+
if (rule.tag) resolved.tag = normalizeSlotFallbackWrapperTag(rule.tag);
|
|
6991
6986
|
if (rule.attrs) resolved.attrs = mergeSlotFallbackWrapperAttrs(resolved.attrs, rule.attrs);
|
|
6992
6987
|
if (rule.singleRootNoWrapper !== void 0) resolved.singleRootNoWrapper = rule.singleRootNoWrapper;
|
|
6993
6988
|
}
|
|
6994
|
-
if (info.local?.tag) resolved.tag = normalizeSlotFallbackWrapperTag(info.local.tag
|
|
6989
|
+
if (info.local?.tag) resolved.tag = normalizeSlotFallbackWrapperTag(info.local.tag);
|
|
6995
6990
|
if (info.local?.staticClass !== void 0) resolved.staticClass = info.local.staticClass;
|
|
6996
6991
|
if (info.local?.dynamicClassExp !== void 0) resolved.dynamicClassExp = info.local.dynamicClassExp;
|
|
6997
6992
|
if (info.local?.staticStyle !== void 0) resolved.staticStyle = info.local.staticStyle;
|
|
@@ -7766,13 +7761,23 @@ const HTML_VOID_TAGS = new Set([
|
|
|
7766
7761
|
"track",
|
|
7767
7762
|
"wbr"
|
|
7768
7763
|
]);
|
|
7769
|
-
function
|
|
7764
|
+
function resolveSlotFallbackWrapperComponent(strategy) {
|
|
7765
|
+
if (strategy !== "virtual-host") return;
|
|
7766
|
+
return {
|
|
7767
|
+
tagName: WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME,
|
|
7768
|
+
componentBase: WEVU_SLOT_FALLBACK_VIRTUAL_HOST_BASE,
|
|
7769
|
+
template: "<slot></slot>",
|
|
7770
|
+
script: "Component({options:{virtualHost:true,multipleSlots:true}})",
|
|
7771
|
+
config: { component: true }
|
|
7772
|
+
};
|
|
7773
|
+
}
|
|
7774
|
+
function resolveSlotFallbackWrapperConfig(config, strategy) {
|
|
7770
7775
|
if (typeof config === "string") return {
|
|
7771
7776
|
tag: config || "view",
|
|
7772
7777
|
rules: []
|
|
7773
7778
|
};
|
|
7774
7779
|
return {
|
|
7775
|
-
tag: config?.tag || "view",
|
|
7780
|
+
tag: config?.tag || (strategy === "virtual-host" ? WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME : "view"),
|
|
7776
7781
|
attrs: config?.attrs,
|
|
7777
7782
|
singleRootNoWrapper: config?.singleRootNoWrapper,
|
|
7778
7783
|
rules: config?.rules ?? []
|
|
@@ -7788,7 +7793,9 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
7788
7793
|
const wxsExtension = options?.wxsExtension;
|
|
7789
7794
|
const scopedSlotsRequireProps = options?.scopedSlotsRequireProps ?? options?.scopedSlotsCompiler !== "augmented";
|
|
7790
7795
|
const slotSingleRootNoWrapper = options?.slotSingleRootNoWrapper ?? false;
|
|
7791
|
-
const
|
|
7796
|
+
const slotFallbackWrapperStrategy = options?.slotFallbackWrapperStrategy ?? "view";
|
|
7797
|
+
const slotFallbackWrapper = resolveSlotFallbackWrapperConfig(options?.slotFallbackWrapper, slotFallbackWrapperStrategy);
|
|
7798
|
+
const slotFallbackWrapperComponent = slotFallbackWrapper.tag === WEVU_SLOT_FALLBACK_VIRTUAL_HOST_TAG_NAME ? resolveSlotFallbackWrapperComponent(slotFallbackWrapperStrategy) : void 0;
|
|
7792
7799
|
const htmlTagToWxmlMap = resolveHtmlTagToWxmlMap(options?.htmlTagToWxml);
|
|
7793
7800
|
try {
|
|
7794
7801
|
const ast = parse$1(template, {
|
|
@@ -7811,6 +7818,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
7811
7818
|
scopedSlotsRequireProps,
|
|
7812
7819
|
slotSingleRootNoWrapper,
|
|
7813
7820
|
slotFallbackWrapper,
|
|
7821
|
+
slotFallbackWrapperComponent,
|
|
7814
7822
|
slotMultipleInstance: options?.slotMultipleInstance ?? true,
|
|
7815
7823
|
scopedSlotComponents: [],
|
|
7816
7824
|
componentGenerics: {},
|
|
@@ -7846,6 +7854,7 @@ function compileVueTemplateToWxml(template, filename, options) {
|
|
|
7846
7854
|
warnings
|
|
7847
7855
|
};
|
|
7848
7856
|
if (context.scopedSlotComponents.length) result.scopedSlotComponents = context.scopedSlotComponents;
|
|
7857
|
+
if (context.slotFallbackWrapperComponent && wxml.includes(`<${context.slotFallbackWrapperComponent.tagName}`)) result.slotFallbackWrapperComponent = context.slotFallbackWrapperComponent;
|
|
7849
7858
|
if (Object.keys(context.componentGenerics).length) result.componentGenerics = context.componentGenerics;
|
|
7850
7859
|
if (context.classStyleWxs) result.classStyleWxs = true;
|
|
7851
7860
|
if (context.classStyleBindings.length) {
|
|
@@ -8715,6 +8724,89 @@ function composeSourceMaps(transformedMap, originalMap) {
|
|
|
8715
8724
|
return null;
|
|
8716
8725
|
}
|
|
8717
8726
|
//#endregion
|
|
8727
|
+
//#region src/plugins/vue/transform/compileVueFile/reservedProps.ts
|
|
8728
|
+
const RESERVED_SCRIPT_SETUP_PROPS = new Set([
|
|
8729
|
+
"id",
|
|
8730
|
+
"class",
|
|
8731
|
+
"slot"
|
|
8732
|
+
]);
|
|
8733
|
+
const RESERVED_PROPS_WARNING = "defineProps 中声明 id/class/slot 可能无法在小程序 properties 中正确取值,请改用其他 prop 名称。";
|
|
8734
|
+
function getStaticKeyName(key) {
|
|
8735
|
+
if (t.isIdentifier(key)) return key.name;
|
|
8736
|
+
if (t.isStringLiteral(key)) return key.value;
|
|
8737
|
+
}
|
|
8738
|
+
function getTypePropertyName(key) {
|
|
8739
|
+
if (t.isIdentifier(key)) return key.name;
|
|
8740
|
+
if (t.isStringLiteral(key)) return key.value;
|
|
8741
|
+
}
|
|
8742
|
+
function isReservedScriptSetupProp(name) {
|
|
8743
|
+
return name != null && RESERVED_SCRIPT_SETUP_PROPS.has(name);
|
|
8744
|
+
}
|
|
8745
|
+
function runtimePropsContainReservedName(node) {
|
|
8746
|
+
if (t.isObjectExpression(node)) return node.properties.some((prop) => t.isObjectProperty(prop) && !prop.computed && isReservedScriptSetupProp(getStaticKeyName(prop.key)));
|
|
8747
|
+
if (t.isArrayExpression(node)) return node.elements.some((element) => t.isStringLiteral(element) && isReservedScriptSetupProp(element.value));
|
|
8748
|
+
return false;
|
|
8749
|
+
}
|
|
8750
|
+
function createTypeScope(ast) {
|
|
8751
|
+
const scope = /* @__PURE__ */ new Map();
|
|
8752
|
+
traverse(ast, {
|
|
8753
|
+
TSInterfaceDeclaration(path) {
|
|
8754
|
+
scope.set(path.node.id.name, path.node.body);
|
|
8755
|
+
},
|
|
8756
|
+
TSTypeAliasDeclaration(path) {
|
|
8757
|
+
scope.set(path.node.id.name, path.node.typeAnnotation);
|
|
8758
|
+
}
|
|
8759
|
+
});
|
|
8760
|
+
return scope;
|
|
8761
|
+
}
|
|
8762
|
+
function typePropsContainReservedName(typeNode, scope, seen = /* @__PURE__ */ new Set()) {
|
|
8763
|
+
if (!typeNode) return false;
|
|
8764
|
+
if (t.isTSTypeLiteral(typeNode)) return typeNode.members.some((member) => {
|
|
8765
|
+
return t.isTSPropertySignature(member) && !member.computed && isReservedScriptSetupProp(getTypePropertyName(member.key));
|
|
8766
|
+
});
|
|
8767
|
+
if (t.isTSInterfaceBody(typeNode)) return typeNode.body.some((member) => {
|
|
8768
|
+
return t.isTSPropertySignature(member) && !member.computed && isReservedScriptSetupProp(getTypePropertyName(member.key));
|
|
8769
|
+
});
|
|
8770
|
+
if (t.isTSIntersectionType(typeNode)) return typeNode.types.some((item) => typePropsContainReservedName(item, scope, seen));
|
|
8771
|
+
if (t.isTSTypeReference(typeNode) && t.isIdentifier(typeNode.typeName)) {
|
|
8772
|
+
const typeName = typeNode.typeName.name;
|
|
8773
|
+
if (seen.has(typeName)) return false;
|
|
8774
|
+
const resolved = scope.get(typeName);
|
|
8775
|
+
if (!resolved) return false;
|
|
8776
|
+
seen.add(typeName);
|
|
8777
|
+
return typePropsContainReservedName(resolved, scope, seen);
|
|
8778
|
+
}
|
|
8779
|
+
return false;
|
|
8780
|
+
}
|
|
8781
|
+
function hasDefinePropsReservedName(scriptSetupCode) {
|
|
8782
|
+
let hasReservedName = false;
|
|
8783
|
+
try {
|
|
8784
|
+
const ast = parseJsLike(scriptSetupCode);
|
|
8785
|
+
const typeScope = createTypeScope(ast);
|
|
8786
|
+
traverse(ast, { CallExpression(path) {
|
|
8787
|
+
const callee = path.node.callee;
|
|
8788
|
+
if (!t.isIdentifier(callee, { name: "defineProps" })) return;
|
|
8789
|
+
if (runtimePropsContainReservedName(path.node.arguments[0])) {
|
|
8790
|
+
hasReservedName = true;
|
|
8791
|
+
path.stop();
|
|
8792
|
+
return;
|
|
8793
|
+
}
|
|
8794
|
+
const typeParam = path.node.typeParameters?.params?.[0];
|
|
8795
|
+
if (typePropsContainReservedName(typeParam, typeScope)) {
|
|
8796
|
+
hasReservedName = true;
|
|
8797
|
+
path.stop();
|
|
8798
|
+
}
|
|
8799
|
+
} });
|
|
8800
|
+
} catch {
|
|
8801
|
+
return false;
|
|
8802
|
+
}
|
|
8803
|
+
return hasReservedName;
|
|
8804
|
+
}
|
|
8805
|
+
function warnReservedScriptSetupProps(scriptSetupCode, warn) {
|
|
8806
|
+
if (!scriptSetupCode || !hasDefinePropsReservedName(scriptSetupCode)) return;
|
|
8807
|
+
warn?.(RESERVED_PROPS_WARNING);
|
|
8808
|
+
}
|
|
8809
|
+
//#endregion
|
|
8718
8810
|
//#region src/plugins/vue/transform/compileVueFile/script.ts
|
|
8719
8811
|
const TYPE_ONLY_DEFINE_PROPS_RE = /\bdefineProps\s*</;
|
|
8720
8812
|
function resolveScriptSetupPropsAliases(bindings) {
|
|
@@ -8815,6 +8907,7 @@ async function compileScriptPhase(descriptor, descriptorForCompile, filename, op
|
|
|
8815
8907
|
id: filename,
|
|
8816
8908
|
isProd: false
|
|
8817
8909
|
});
|
|
8910
|
+
warnReservedScriptSetupProps(descriptorForCompile.scriptSetup?.content, options?.warn);
|
|
8818
8911
|
propsAliases ??= resolveScriptSetupPropsAliases(scriptCompiled.bindings);
|
|
8819
8912
|
scriptCode = scriptCompiled.content;
|
|
8820
8913
|
propsDerivedKeys = resolveEffectivePropsDerivedKeys(scriptCompiled.bindings, scriptCode);
|
|
@@ -8898,6 +8991,7 @@ function compileTemplatePhase(descriptor, filename, options, result) {
|
|
|
8898
8991
|
const templateCompiled = compileVueTemplateToWxml(descriptor.template.content, filename, options);
|
|
8899
8992
|
result.template = templateCompiled.code;
|
|
8900
8993
|
if (templateCompiled.scopedSlotComponents?.length) result.scopedSlotComponents = templateCompiled.scopedSlotComponents;
|
|
8994
|
+
if (templateCompiled.slotFallbackWrapperComponent) result.slotFallbackWrapperComponent = templateCompiled.slotFallbackWrapperComponent;
|
|
8901
8995
|
if (templateCompiled.componentGenerics && Object.keys(templateCompiled.componentGenerics).length) result.componentGenerics = templateCompiled.componentGenerics;
|
|
8902
8996
|
if (templateCompiled.classStyleWxs) result.classStyleWxs = true;
|
|
8903
8997
|
return templateCompiled;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevu/compiler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.16.
|
|
4
|
+
"version": "6.16.29",
|
|
5
5
|
"description": "wevu 编译器基础包,面向小程序模板的编译与转换",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
"@vue/compiler-core": "^3.5.35",
|
|
46
46
|
"@vue/compiler-dom": "^3.5.35",
|
|
47
47
|
"comment-json": "^5.0.0",
|
|
48
|
-
"lru-cache": "^11.5.
|
|
48
|
+
"lru-cache": "^11.5.1",
|
|
49
49
|
"magic-string": "^0.30.21",
|
|
50
50
|
"merge": "^2.1.1",
|
|
51
51
|
"pathe": "^2.0.3",
|
|
52
52
|
"vue": "^3.5.35",
|
|
53
|
-
"@weapp-core/constants": "0.1.
|
|
53
|
+
"@weapp-core/constants": "0.1.12",
|
|
54
54
|
"@weapp-core/shared": "3.0.4",
|
|
55
|
-
"@weapp-vite/ast": "6.16.
|
|
55
|
+
"@weapp-vite/ast": "6.16.29",
|
|
56
56
|
"rolldown-require": "2.0.18"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|