@vureact/compiler-core 1.8.5 → 1.10.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vureact/compiler-core v1.8.5
2
+ * @vureact/compiler-core v1.10.0
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -48,7 +48,9 @@ var MACRO_API_NAMES = {
48
48
  emits: "defineEmits",
49
49
  slots: "defineSlots",
50
50
  options: "defineOptions",
51
- expose: "defineExpose"
51
+ expose: "defineExpose",
52
+ model: "defineModel",
53
+ defaults: "withDefaults"
52
54
  };
53
55
  var DOLLAR_IDENTIFIERS = [
54
56
  "$data",
@@ -402,6 +404,11 @@ var ADAPTER_RULES = {
402
404
  }
403
405
  }
404
406
  };
407
+ var AUTO_IMPORTED_APIS = new Set(
408
+ Object.entries(ADAPTER_RULES).flatMap(
409
+ ([_, rules]) => Object.keys(rules).filter((key) => !key.startsWith("dir"))
410
+ )
411
+ );
405
412
 
406
413
  // src/consts/vue-api-map.ts
407
414
  var VUE_API_MAP = {
@@ -950,21 +957,21 @@ var Logger = class {
950
957
  }
951
958
  printAll(opts) {
952
959
  if (this.logs.length === 0) {
953
- console.log("No logs to display.");
960
+ !opts?._testMode && console.log("No logs to display.");
954
961
  return;
955
962
  }
956
963
  const orderedLogs = this.getOrderedLogs(opts);
957
964
  for (const log of orderedLogs) {
958
- console.log();
965
+ !opts?._testMode && console.log();
959
966
  console.log(this.formatHeader(log));
960
967
  const context = this.formatContext(log);
961
968
  if (context) {
962
969
  console.log(context);
963
970
  }
964
- console.log();
971
+ !opts?._testMode && console.log();
965
972
  }
966
973
  this.printSummary();
967
- console.log();
974
+ !opts?._testMode && console.log();
968
975
  }
969
976
  clear() {
970
977
  this.logs = [];
@@ -1060,7 +1067,7 @@ function buildStandardProp(nodeIR) {
1060
1067
  babelExp: { ast: keyAST },
1061
1068
  value: {
1062
1069
  content,
1063
- isStringLiteral: isStringLiteral14,
1070
+ isStringLiteral: isStringLiteral16,
1064
1071
  babelExp: { ast: valueAST }
1065
1072
  }
1066
1073
  } = nodeIR;
@@ -1069,7 +1076,7 @@ function buildStandardProp(nodeIR) {
1069
1076
  }
1070
1077
  let value;
1071
1078
  if (content !== "true") {
1072
- value = isStringLiteral14 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
1079
+ value = isStringLiteral16 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
1073
1080
  }
1074
1081
  return t9.jsxAttribute(keyAST, value);
1075
1082
  }
@@ -1266,6 +1273,7 @@ var REACT_API_MAP = {
1266
1273
  memo: "memo",
1267
1274
  useRef: "useRef",
1268
1275
  useMemo: "useMemo",
1276
+ useEffect: "useEffect",
1269
1277
  ReactNode: "ReactNode",
1270
1278
  forwardRef: "forwardRef",
1271
1279
  useCallback: "useCallback",
@@ -1642,11 +1650,11 @@ function replaceIdName(id, newName) {
1642
1650
  id.loc.identifierName = newName;
1643
1651
  }
1644
1652
  }
1645
- function stringValueToTSType(ctx, input, tsTypeAnnotation7) {
1653
+ function stringValueToTSType(ctx, input, tsTypeAnnotation8) {
1646
1654
  const { filename, scriptData } = ctx;
1647
1655
  const exp = stringToExpr(input, scriptData.lang, filename);
1648
1656
  const ts = expressionToTSType(exp);
1649
- return tsTypeAnnotation7 ? t15.tsTypeAnnotation(ts) : ts;
1657
+ return tsTypeAnnotation8 ? t15.tsTypeAnnotation(ts) : ts;
1650
1658
  }
1651
1659
  function expressionToTSType(exp) {
1652
1660
  if (t15.isStringLiteral(exp)) return t15.tsStringKeyword();
@@ -1740,6 +1748,28 @@ function cleanNodeComments(node) {
1740
1748
  node.innerComments = null;
1741
1749
  node.trailingComments = null;
1742
1750
  }
1751
+ function mapRuntimeTypeToTSType(value) {
1752
+ switch (value.name) {
1753
+ case "String":
1754
+ return t15.tsStringKeyword();
1755
+ case "Number":
1756
+ return t15.tsNumberKeyword();
1757
+ case "Boolean":
1758
+ return t15.tsBooleanKeyword();
1759
+ case "Object":
1760
+ return t15.tsTypeLiteral([]);
1761
+ case "Array":
1762
+ return t15.tsArrayType(t15.tsAnyKeyword());
1763
+ case "Function":
1764
+ return t15.tsFunctionType(null, [], t15.tsTypeAnnotation(t15.tsAnyKeyword()));
1765
+ case "Symbol":
1766
+ return t15.tsSymbolKeyword();
1767
+ case "BigInt":
1768
+ return t15.tsBigIntKeyword();
1769
+ default:
1770
+ return t15.tsAnyKeyword();
1771
+ }
1772
+ }
1743
1773
 
1744
1774
  // src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-declared-options.ts
1745
1775
  function resolveDeclaredOptions(path8, ctx) {
@@ -2218,6 +2248,7 @@ var REACTIVE_TYPE_MAP = {
2218
2248
  toRefs: "ref",
2219
2249
  customRef: "ref",
2220
2250
  shallowRef: "ref",
2251
+ defineModel: "ref",
2221
2252
  reactive: "reactive",
2222
2253
  shallowReactive: "reactive",
2223
2254
  computed: "ref",
@@ -2257,7 +2288,7 @@ function resolveReactiveBindings(node, ctx) {
2257
2288
  source: callName,
2258
2289
  reactiveType: getReactiveType(callName)
2259
2290
  };
2260
- if (callName === MACRO_API_NAMES.props) {
2291
+ if (callName === MACRO_API_NAMES.props || callName === MACRO_API_NAMES.defaults) {
2261
2292
  ctx.propField = varName;
2262
2293
  }
2263
2294
  }
@@ -3277,8 +3308,236 @@ function isVueImport(id, path8) {
3277
3308
  return VUE_PACKAGES.some((pkg) => moduleName.includes(pkg));
3278
3309
  }
3279
3310
 
3280
- // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
3311
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-with-defaults.ts
3312
+ import * as t28 from "@babel/types";
3313
+
3314
+ // src/core/transform/sfc/script/shared/hook-creator.ts
3281
3315
  import * as t26 from "@babel/types";
3316
+ function createUseCallback(body, deps) {
3317
+ return t26.callExpression(t26.identifier(REACT_API_MAP.useCallback), [
3318
+ body,
3319
+ deps ?? t26.arrayExpression([])
3320
+ ]);
3321
+ }
3322
+ function createUseMemo(body, deps) {
3323
+ return t26.callExpression(t26.identifier(REACT_API_MAP.useMemo), [
3324
+ t26.arrowFunctionExpression([], body),
3325
+ deps ?? t26.arrayExpression([])
3326
+ ]);
3327
+ }
3328
+ function createUseImperativeHandle(refId, init) {
3329
+ return t26.callExpression(t26.identifier(REACT_API_MAP.useImperativeHandle), [refId, init]);
3330
+ }
3331
+ function createUseUpdated(body, deps) {
3332
+ const adapter = ADAPTER_RULES.runtime.onUpdated;
3333
+ return t26.callExpression(t26.identifier(adapter.target), [
3334
+ t26.arrowFunctionExpression([], body),
3335
+ deps ?? t26.identifier("undefined")
3336
+ ]);
3337
+ }
3338
+
3339
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-with-defaults.ts
3340
+ import * as t27 from "@babel/types";
3341
+ var WITH_DEFAULTS_PLACEHOLDER = " from withDefaults ";
3342
+ function resolveWithDefaultsOptions(ctx, ast) {
3343
+ if (ctx.inputType !== "sfc") return {};
3344
+ return {
3345
+ CallExpression(path8) {
3346
+ const { node } = path8;
3347
+ const { filename, scriptData } = ctx;
3348
+ if (!isCalleeNamed(node, MACRO_API_NAMES.defaults)) {
3349
+ return;
3350
+ }
3351
+ const declaratorPath = getVariableDeclaratorPath(path8);
3352
+ if (!declaratorPath) {
3353
+ logger.error(
3354
+ `withDefaults() must be assigned to a variable (e.g., const props = withDefaults(...)).`,
3355
+ { file: filename, source: scriptData.source, loc: node.loc }
3356
+ );
3357
+ return;
3358
+ }
3359
+ const varName = t27.isIdentifier(declaratorPath.node.id) ? declaratorPath.node.id.name : void 0;
3360
+ if (!varName) {
3361
+ logger.error("withDefaults() could not determine the variable name from the declaration.", {
3362
+ file: filename,
3363
+ source: scriptData.source,
3364
+ loc: node.loc
3365
+ });
3366
+ return;
3367
+ }
3368
+ ctx.propField = `vr${capitalize(ctx.propField)}`;
3369
+ const [defineProps, defaults] = node.arguments;
3370
+ if (!node.arguments.length) {
3371
+ logger.error("withDefaults() requires at least one argument (defineProps call).", {
3372
+ file: filename,
3373
+ source: scriptData.source,
3374
+ loc: node.loc
3375
+ });
3376
+ return;
3377
+ }
3378
+ if (!t27.isCallExpression(defineProps)) {
3379
+ logger.error(
3380
+ "withDefaults() first argument must be a call to defineProps (e.g., defineProps({...})).",
3381
+ { file: filename, source: scriptData.source, loc: defineProps?.loc }
3382
+ );
3383
+ return;
3384
+ }
3385
+ if (defaults && !t27.isObjectExpression(defaults)) {
3386
+ logger.error(
3387
+ 'withDefaults() second argument must be an object literal (e.g., { msg: "hello" }).',
3388
+ { file: filename, source: scriptData.source, loc: defaults?.loc }
3389
+ );
3390
+ return;
3391
+ }
3392
+ recordPropsWithDefaults(ctx, varName, defineProps, defaults, node);
3393
+ declaratorPath.parentPath.insertAfter(createPlaceholder(node));
3394
+ replaceNode(path8, defineProps, node);
3395
+ }
3396
+ };
3397
+ }
3398
+ function recordPropsWithDefaults(ctx, varName, defineProps, defaults, withDefaults) {
3399
+ const { scriptData } = ctx;
3400
+ const { start, end, loc, leadingComments, innerComments, trailingComments } = withDefaults;
3401
+ const values = flattenDefaultValues(defaults);
3402
+ const getTypeParameters = () => {
3403
+ if (!scriptData.lang.startsWith("ts")) {
3404
+ return;
3405
+ }
3406
+ const { propsTypes } = scriptData.propsTSIface;
3407
+ const typeParameters = defineProps.typeParameters || (propsTypes.length ? t27.tSTypeParameterInstantiation(propsTypes) : void 0);
3408
+ if (typeParameters) {
3409
+ return t27.tsTypeParameterInstantiation([
3410
+ t27.tsTypeReference(t27.identifier("Readonly"), typeParameters)
3411
+ ]);
3412
+ }
3413
+ };
3414
+ scriptData.propsWithDefaults = {
3415
+ varName,
3416
+ values,
3417
+ start,
3418
+ end,
3419
+ loc,
3420
+ leadingComments,
3421
+ innerComments,
3422
+ trailingComments,
3423
+ typeParameters: getTypeParameters()
3424
+ };
3425
+ }
3426
+ function flattenDefaultValues(expr) {
3427
+ if (!expr) return;
3428
+ if (!t27.isObjectExpression(expr)) {
3429
+ return expr;
3430
+ }
3431
+ const properties = expr.properties.map((prop) => {
3432
+ if (!t27.isObjectProperty(prop)) {
3433
+ return prop;
3434
+ }
3435
+ const value = prop.value;
3436
+ if (t27.isArrowFunctionExpression(value) && t27.isBlockStatement(value.body)) {
3437
+ const returnStmt = value.body.body.find(
3438
+ (stmt) => t27.isReturnStatement(stmt)
3439
+ );
3440
+ if (returnStmt?.argument) {
3441
+ return t27.objectProperty(prop.key, returnStmt.argument, prop.computed);
3442
+ }
3443
+ }
3444
+ if (t27.isArrowFunctionExpression(value) && !t27.isBlockStatement(value.body)) {
3445
+ return t27.objectProperty(prop.key, value.body, prop.computed);
3446
+ }
3447
+ return prop;
3448
+ });
3449
+ return t27.objectExpression(properties);
3450
+ }
3451
+ function createPlaceholder(node) {
3452
+ const placeholder = t27.emptyStatement();
3453
+ const leadingComments = [
3454
+ {
3455
+ type: "CommentBlock",
3456
+ value: WITH_DEFAULTS_PLACEHOLDER,
3457
+ start: node.start,
3458
+ end: node.end
3459
+ }
3460
+ ];
3461
+ placeholder.leadingComments = leadingComments;
3462
+ return placeholder;
3463
+ }
3464
+
3465
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-with-defaults.ts
3466
+ function resolveWithDefaults(ctx) {
3467
+ const { inputType, scriptData } = ctx;
3468
+ const propsWithDefaults = scriptData.propsWithDefaults;
3469
+ if (inputType !== "sfc" || !propsWithDefaults?.values) return {};
3470
+ return {
3471
+ Program: {
3472
+ exit(programPath) {
3473
+ const { body } = programPath.node;
3474
+ const placeholderIndex = findPlaceholderIndex(body);
3475
+ if (placeholderIndex === -1) return;
3476
+ const placeholder = body[placeholderIndex];
3477
+ const { varName, values, typeParameters } = propsWithDefaults;
3478
+ const varDeclaration = createVarDeclaration(
3479
+ varName,
3480
+ values,
3481
+ typeParameters,
3482
+ ctx.propField,
3483
+ propsWithDefaults
3484
+ );
3485
+ varDeclaration.leadingComments = placeholder.leadingComments;
3486
+ body.splice(placeholderIndex, 0, varDeclaration);
3487
+ recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useMemo);
3488
+ }
3489
+ }
3490
+ };
3491
+ }
3492
+ function findPlaceholderIndex(body) {
3493
+ return body.findIndex((stmt) => {
3494
+ if (!t28.isEmptyStatement(stmt) || !stmt.leadingComments) {
3495
+ return false;
3496
+ }
3497
+ return stmt.leadingComments.some(
3498
+ (comment) => comment.type === "CommentBlock" && comment.value === WITH_DEFAULTS_PLACEHOLDER
3499
+ );
3500
+ });
3501
+ }
3502
+ function createVarDeclaration(varName, values, typeParameters, propField, sourceInfo) {
3503
+ const { mergeMembers } = buildMergeLogic(values, propField);
3504
+ const deps = t28.arrayExpression([t28.identifier(propField)]);
3505
+ const useMemoCall = createUseMemo(t28.objectExpression(mergeMembers), deps);
3506
+ if (typeParameters) {
3507
+ useMemoCall.typeParameters = typeParameters;
3508
+ }
3509
+ useMemoCall.start = sourceInfo.start;
3510
+ useMemoCall.end = sourceInfo.end;
3511
+ useMemoCall.loc = sourceInfo.loc;
3512
+ useMemoCall.leadingComments = sourceInfo.leadingComments;
3513
+ useMemoCall.innerComments = sourceInfo.innerComments;
3514
+ useMemoCall.trailingComments = sourceInfo.trailingComments;
3515
+ const varDeclarator = t28.variableDeclarator(t28.identifier(varName), useMemoCall);
3516
+ return t28.variableDeclaration("const", [varDeclarator]);
3517
+ }
3518
+ function buildMergeLogic(values, propField) {
3519
+ const mergeMembers = [];
3520
+ const propFieldIdent = t28.identifier(propField);
3521
+ mergeMembers.push(t28.spreadElement(propFieldIdent));
3522
+ for (const defaultProp of values.properties) {
3523
+ if (!t28.isObjectProperty(defaultProp)) continue;
3524
+ const key = defaultProp.key;
3525
+ if (!t28.isIdentifier(key) && !t28.isStringLiteral(key)) continue;
3526
+ const keyName = t28.isIdentifier(key) ? key.name : key.value;
3527
+ const propAccess = t28.memberExpression(propFieldIdent, t28.identifier(keyName), false);
3528
+ const logicalExpr = t28.logicalExpression("??", propAccess, defaultProp.value);
3529
+ mergeMembers.push(
3530
+ t28.objectProperty(
3531
+ t28.isIdentifier(key) ? t28.identifier(keyName) : t28.stringLiteral(keyName),
3532
+ logicalExpr
3533
+ )
3534
+ );
3535
+ }
3536
+ return { mergeMembers };
3537
+ }
3538
+
3539
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
3540
+ import * as t29 from "@babel/types";
3282
3541
  function resolveDefineAsyncComponent(ctx) {
3283
3542
  return {
3284
3543
  CallExpression(path8) {
@@ -3287,11 +3546,11 @@ function resolveDefineAsyncComponent(ctx) {
3287
3546
  return;
3288
3547
  }
3289
3548
  const [arg] = node.arguments;
3290
- if (!t26.isObjectExpression(arg)) {
3549
+ if (!t29.isObjectExpression(arg)) {
3291
3550
  return;
3292
3551
  }
3293
3552
  for (const prop of arg.properties) {
3294
- if (!t26.isObjectProperty(prop) || !t26.isIdentifier(prop.key) || prop.key.name !== "hydrate") {
3553
+ if (!t29.isObjectProperty(prop) || !t29.isIdentifier(prop.key) || prop.key.name !== "hydrate") {
3295
3554
  continue;
3296
3555
  }
3297
3556
  logger.warn('Unsupported option "hydrate"', {
@@ -3306,27 +3565,7 @@ function resolveDefineAsyncComponent(ctx) {
3306
3565
  }
3307
3566
 
3308
3567
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
3309
- import * as t28 from "@babel/types";
3310
-
3311
- // src/core/transform/sfc/script/shared/hook-creator.ts
3312
- import * as t27 from "@babel/types";
3313
- function createUseCallback(body, deps) {
3314
- return t27.callExpression(t27.identifier(REACT_API_MAP.useCallback), [
3315
- body,
3316
- deps ?? t27.arrayExpression([])
3317
- ]);
3318
- }
3319
- function createUseMemo(body, deps) {
3320
- return t27.callExpression(t27.identifier(REACT_API_MAP.useMemo), [
3321
- t27.arrowFunctionExpression([], body),
3322
- deps ?? t27.arrayExpression([])
3323
- ]);
3324
- }
3325
- function createUseImperativeHandle(refId, init) {
3326
- return t27.callExpression(t27.identifier(REACT_API_MAP.useImperativeHandle), [refId, init]);
3327
- }
3328
-
3329
- // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
3568
+ import * as t30 from "@babel/types";
3330
3569
  function resolveDefineExpose(ctx) {
3331
3570
  if (ctx.inputType !== "sfc") return {};
3332
3571
  return {
@@ -3344,22 +3583,242 @@ function resolveDefineExpose(ctx) {
3344
3583
  const adapter = ADAPTER_RULES.react[MACRO_API_NAMES.expose];
3345
3584
  recordImport(ctx, adapter.package, REACT_API_MAP.forwardRef);
3346
3585
  recordImport(ctx, adapter.package, adapter.target);
3347
- if (!t28.isObjectExpression(expose) && !t28.isFunction(expose)) {
3586
+ if (!t30.isObjectExpression(expose) && !t30.isFunction(expose)) {
3348
3587
  logger.warn("Non-deterministic object literal may cause unknown risks.", {
3349
3588
  file: filename,
3350
3589
  loc: expose.loc,
3351
3590
  source: scriptData.source
3352
3591
  });
3353
3592
  }
3354
- const init = !t28.isFunction(expose) ? t28.arrowFunctionExpression([], expose) : expose;
3593
+ const init = !t30.isFunction(expose) ? t30.arrowFunctionExpression([], expose) : expose;
3355
3594
  const { forwardRef } = scriptData;
3356
- const newNode = createUseImperativeHandle(t28.identifier(forwardRef.refField), init);
3595
+ const newNode = createUseImperativeHandle(t30.identifier(forwardRef.refField), init);
3357
3596
  forwardRef.enabled = true;
3358
3597
  replaceNode(path8, newNode, node);
3359
3598
  }
3360
3599
  };
3361
3600
  }
3362
3601
 
3602
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-model.ts
3603
+ import * as t31 from "@babel/types";
3604
+ function resolveDefineModel(ctx, ast) {
3605
+ if (ctx.inputType !== "sfc") return {};
3606
+ return {
3607
+ CallExpression(path8) {
3608
+ const { node } = path8;
3609
+ if (!isCalleeNamed(node, MACRO_API_NAMES.model)) {
3610
+ return;
3611
+ }
3612
+ if (!validateDefineModelUsage(path8, ctx)) {
3613
+ return;
3614
+ }
3615
+ const propInfo = extractPropInfo(node, ctx);
3616
+ replaceToUseVRef(node, propInfo, ctx);
3617
+ resolveAutoUpdate(ast, path8, propInfo, ctx);
3618
+ resolveInterface(propInfo, ctx);
3619
+ }
3620
+ };
3621
+ }
3622
+ function validateDefineModelUsage(path8, ctx) {
3623
+ const { node, parent } = path8;
3624
+ const { filename, scriptData } = ctx;
3625
+ const [arg1, arg2] = node.arguments;
3626
+ if (!t31.isObjectExpression(arg1) && !t31.isStringLiteral(arg1)) {
3627
+ logger.error(`Invalid argument type for defineModel. Expected a string.`, {
3628
+ file: filename,
3629
+ source: scriptData.source,
3630
+ loc: arg1?.loc
3631
+ });
3632
+ return false;
3633
+ }
3634
+ const hasUnsupportedOption = (arg) => {
3635
+ if (!t31.isObjectExpression(arg)) {
3636
+ return false;
3637
+ }
3638
+ const result = arg.properties.some((prop) => {
3639
+ if ((t31.isObjectProperty(prop) || t31.isObjectMethod(prop)) && t31.isIdentifier(prop.key)) {
3640
+ const keyName = prop.key.name;
3641
+ if (keyName === "get" || keyName === "set" || keyName === "validator") {
3642
+ logger.error(`defineModel does not support '${keyName}' option.`, {
3643
+ file: filename,
3644
+ source: scriptData.source,
3645
+ loc: prop.key.loc
3646
+ });
3647
+ return true;
3648
+ }
3649
+ }
3650
+ });
3651
+ return !!result;
3652
+ };
3653
+ const isValidVariableAssignment = () => {
3654
+ const varDeclaration = path8.parentPath.parentPath;
3655
+ if (varDeclaration?.isVariableDeclaration() && varDeclaration.node.declarations.length === 1 && t31.isArrayPattern(varDeclaration.node.declarations[0]?.id)) {
3656
+ logger.error(
3657
+ `defineModel return value cannot be destructured with array pattern. Please use single variable assignment.`,
3658
+ {
3659
+ file: filename,
3660
+ source: scriptData.source,
3661
+ loc: varDeclaration.node.loc
3662
+ }
3663
+ );
3664
+ return false;
3665
+ }
3666
+ return true;
3667
+ };
3668
+ return !hasUnsupportedOption(arg1) && !hasUnsupportedOption(arg2) && isValidVariableAssignment();
3669
+ }
3670
+ function extractPropInfo(node, ctx) {
3671
+ const [arg1, arg2] = node.arguments;
3672
+ const propInfo = {
3673
+ name: "modelValue",
3674
+ updateEventName: "onUpdateModelValue",
3675
+ type: void 0,
3676
+ required: false,
3677
+ default: void 0
3678
+ };
3679
+ const findObjectProperty = (objExpr, propName) => {
3680
+ return objExpr.properties.find(
3681
+ (prop) => t31.isObjectProperty(prop) && t31.isIdentifier(prop.key) && prop.key.name === propName
3682
+ );
3683
+ };
3684
+ const setPropName = (info, value) => {
3685
+ if (!value.trim()) return;
3686
+ info.name = value;
3687
+ info.updateEventName = `onUpdate${capitalize(camelCase(value))}`;
3688
+ };
3689
+ const extractPropInfoFromObject = (objExpr) => {
3690
+ const result = {};
3691
+ const nameProp = findObjectProperty(objExpr, "name");
3692
+ const typeProp = findObjectProperty(objExpr, "type");
3693
+ const defaultProp = findObjectProperty(objExpr, "default");
3694
+ const requiredProp = findObjectProperty(objExpr, "required");
3695
+ if (nameProp && t31.isStringLiteral(nameProp.value)) {
3696
+ setPropName(result, nameProp.value.value);
3697
+ }
3698
+ if (defaultProp) {
3699
+ result.default = defaultProp.value;
3700
+ }
3701
+ if (requiredProp && t31.isBooleanLiteral(requiredProp.value)) {
3702
+ result.required = requiredProp.value.value;
3703
+ }
3704
+ if (typeProp && t31.isIdentifier(typeProp.value)) {
3705
+ result.type = mapRuntimeTypeToTSType(typeProp.value);
3706
+ } else if (node.typeParameters) {
3707
+ const [typeParam] = node.typeParameters.params;
3708
+ if (t31.isTSType(typeParam)) {
3709
+ result.type = typeParam;
3710
+ }
3711
+ } else if (defaultProp) {
3712
+ result.type = expressionToTSType(defaultProp.value);
3713
+ }
3714
+ return result;
3715
+ };
3716
+ const safeAssign = (target, source) => {
3717
+ if (source.name !== void 0) {
3718
+ target.name = source.name;
3719
+ }
3720
+ if (source.updateEventName !== void 0) {
3721
+ target.updateEventName = source.updateEventName;
3722
+ }
3723
+ if (source.type !== void 0) {
3724
+ target.type = source.type;
3725
+ }
3726
+ if (source.required !== void 0) {
3727
+ target.required = source.required;
3728
+ }
3729
+ if (source.default !== void 0) {
3730
+ target.default = source.default;
3731
+ }
3732
+ };
3733
+ const extractTypeFromTypeParams = (info) => {
3734
+ if (!node.typeParameters) return;
3735
+ const isDefaultAny = !info.type || t31.isTSAnyKeyword(info.type);
3736
+ if (!isDefaultAny) return;
3737
+ const [typeParam] = node.typeParameters.params;
3738
+ if (t31.isTSType(typeParam)) {
3739
+ info.type = typeParam;
3740
+ }
3741
+ };
3742
+ if (t31.isStringLiteral(arg1)) {
3743
+ setPropName(propInfo, arg1.value);
3744
+ extractTypeFromTypeParams(propInfo);
3745
+ } else if (t31.isObjectExpression(arg1)) {
3746
+ safeAssign(propInfo, extractPropInfoFromObject(arg1));
3747
+ }
3748
+ if (!t31.isObjectExpression(arg1) && t31.isObjectExpression(arg2)) {
3749
+ safeAssign(propInfo, extractPropInfoFromObject(arg2));
3750
+ }
3751
+ return propInfo;
3752
+ }
3753
+ function replaceToUseVRef(node, propInfo, ctx) {
3754
+ const refAdapter = ADAPTER_RULES.runtime.ref;
3755
+ replaceCallName(node, refAdapter.target);
3756
+ recordImport(ctx, refAdapter.package, refAdapter.target);
3757
+ const defaultValue = propInfo.default;
3758
+ const propRef = t31.identifier(`${ctx.propField}.${propInfo.name}`);
3759
+ if (!defaultValue) {
3760
+ node.arguments = [propRef];
3761
+ } else {
3762
+ node.arguments = [t31.logicalExpression("??", propRef, defaultValue)];
3763
+ }
3764
+ if (ctx.scriptData.lang.startsWith("ts") && !node.typeParameters && propInfo.type) {
3765
+ node.typeParameters = t31.tsTypeParameterInstantiation([propInfo.type]);
3766
+ }
3767
+ }
3768
+ function resolveAutoUpdate(ast, path8, propInfo, ctx) {
3769
+ const { parent } = path8;
3770
+ if (!t31.isVariableDeclarator(parent)) {
3771
+ return;
3772
+ }
3773
+ const modelId = parent.id;
3774
+ if (!t31.isIdentifier(modelId)) {
3775
+ return;
3776
+ }
3777
+ const memberAccess = t31.memberExpression(
3778
+ t31.identifier(ctx.propField),
3779
+ t31.identifier(propInfo.updateEventName)
3780
+ );
3781
+ const dep = t31.memberExpression(modelId, t31.identifier("value"));
3782
+ const updateCall = t31.optionalCallExpression(memberAccess, [dep], true);
3783
+ const callExpr = createUseUpdated(
3784
+ t31.blockStatement([t31.expressionStatement(updateCall)]),
3785
+ t31.arrayExpression([dep])
3786
+ );
3787
+ ast.program.body.push(t31.expressionStatement(callExpr));
3788
+ const adapter = ADAPTER_RULES.runtime.onUpdated;
3789
+ recordImport(ctx, adapter.package, adapter.target);
3790
+ }
3791
+ function resolveInterface(propInfo, ctx) {
3792
+ const { name, updateEventName, required } = propInfo;
3793
+ const { lang, propsTSIface } = ctx.scriptData;
3794
+ if (!lang.startsWith("ts")) {
3795
+ return;
3796
+ }
3797
+ const propType = propInfo.type || t31.tsAnyKeyword();
3798
+ const propSignature = t31.tsPropertySignature(
3799
+ t31.isValidIdentifier(name) ? t31.identifier(name) : t31.stringLiteral(name),
3800
+ t31.tsTypeAnnotation(propType)
3801
+ );
3802
+ propSignature.optional = !required;
3803
+ const emitArg = t31.identifier("arg");
3804
+ emitArg.typeAnnotation = t31.tsTypeAnnotation(propType);
3805
+ const emitSignature = t31.tsPropertySignature(
3806
+ t31.isValidIdentifier(updateEventName) ? t31.identifier(updateEventName) : t31.stringLiteral(updateEventName),
3807
+ t31.tsTypeAnnotation(t31.tsFunctionType(null, [emitArg], t31.tsTypeAnnotation(t31.tsVoidKeyword())))
3808
+ );
3809
+ emitSignature.optional = true;
3810
+ const appendToTypeLiteral = (list, member) => {
3811
+ const existing = list.find((item) => t31.isTSTypeLiteral(item));
3812
+ if (existing) {
3813
+ existing.members.push(member);
3814
+ } else {
3815
+ list.push(t31.tsTypeLiteral([member]));
3816
+ }
3817
+ };
3818
+ appendToTypeLiteral(propsTSIface.propsTypes, propSignature);
3819
+ appendToTypeLiteral(propsTSIface.emitTypes, emitSignature);
3820
+ }
3821
+
3363
3822
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-options.ts
3364
3823
  function resolveDefineOptions(ctx) {
3365
3824
  return {
@@ -3374,7 +3833,7 @@ function resolveDefineOptions(ctx) {
3374
3833
  }
3375
3834
 
3376
3835
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-emit-calls.ts
3377
- import * as t29 from "@babel/types";
3836
+ import * as t32 from "@babel/types";
3378
3837
  function resolveEmitCalls(ctx) {
3379
3838
  const formatEmitEventName = (raw) => {
3380
3839
  if (raw.startsWith("update:")) {
@@ -3388,7 +3847,7 @@ function resolveEmitCalls(ctx) {
3388
3847
  CallExpression(path8) {
3389
3848
  const { node } = path8;
3390
3849
  const { filename, templateData, scriptData } = ctx;
3391
- if (!t29.isIdentifier(node.callee)) return;
3850
+ if (!t32.isIdentifier(node.callee)) return;
3392
3851
  const { name } = node.callee;
3393
3852
  const checkIfFromDefineEmits = () => {
3394
3853
  let result = false;
@@ -3400,7 +3859,7 @@ function resolveEmitCalls(ctx) {
3400
3859
  const binding = path8.scope.getBinding(name);
3401
3860
  if (binding) {
3402
3861
  const parent = binding.path.node;
3403
- if (t29.isVariableDeclarator(parent) && t29.isCallExpression(parent.init) && t29.isIdentifier(parent.init.callee)) {
3862
+ if (t32.isVariableDeclarator(parent) && t32.isCallExpression(parent.init) && t32.isIdentifier(parent.init.callee)) {
3404
3863
  result = parent.init.callee.name === MACRO_API_NAMES.emits;
3405
3864
  }
3406
3865
  }
@@ -3410,9 +3869,9 @@ function resolveEmitCalls(ctx) {
3410
3869
  if (!checkIfFromDefineEmits()) return;
3411
3870
  const [callee, ...args] = node.arguments;
3412
3871
  let propCall;
3413
- if (t29.isStringLiteral(callee)) {
3872
+ if (t32.isStringLiteral(callee)) {
3414
3873
  const eventName = formatEmitEventName(callee.value);
3415
- propCall = createPropCall(ctx.propField, t29.identifier(eventName), args);
3874
+ propCall = createPropCall(ctx.propField, t32.identifier(eventName), args);
3416
3875
  } else {
3417
3876
  propCall = createPropCall(ctx.propField, callee, args, true);
3418
3877
  logger.error(
@@ -3429,38 +3888,38 @@ function resolveEmitCalls(ctx) {
3429
3888
  };
3430
3889
  }
3431
3890
  function createPropCall(rootName, callee, args, computed = false) {
3432
- return t29.optionalCallExpression(
3433
- t29.memberExpression(t29.identifier(rootName), callee, computed),
3891
+ return t32.optionalCallExpression(
3892
+ t32.memberExpression(t32.identifier(rootName), callee, computed),
3434
3893
  args,
3435
3894
  true
3436
3895
  );
3437
3896
  }
3438
3897
 
3439
3898
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/index.ts
3440
- import * as t37 from "@babel/types";
3899
+ import * as t40 from "@babel/types";
3441
3900
 
3442
3901
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-emits.ts
3443
- import * as t31 from "@babel/types";
3902
+ import * as t34 from "@babel/types";
3444
3903
 
3445
3904
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/shared.ts
3446
- import * as t30 from "@babel/types";
3905
+ import * as t33 from "@babel/types";
3447
3906
  function cloneCallableParams(params) {
3448
3907
  const cloneCallableParam = (param, index) => {
3449
- if (t30.isRestElement(param)) {
3908
+ if (t33.isRestElement(param)) {
3450
3909
  const arg = param.argument;
3451
- const name = t30.isIdentifier(arg) ? arg.name : `args${index}`;
3452
- const rest = t30.restElement(t30.identifier(name));
3453
- rest.typeAnnotation = param.typeAnnotation || (t30.isIdentifier(arg) ? arg.typeAnnotation : null) || t30.tsTypeAnnotation(t30.tsArrayType(t30.tsAnyKeyword()));
3910
+ const name = t33.isIdentifier(arg) ? arg.name : `args${index}`;
3911
+ const rest = t33.restElement(t33.identifier(name));
3912
+ rest.typeAnnotation = param.typeAnnotation || (t33.isIdentifier(arg) ? arg.typeAnnotation : null) || t33.tsTypeAnnotation(t33.tsArrayType(t33.tsAnyKeyword()));
3454
3913
  return rest;
3455
3914
  }
3456
- if (t30.isIdentifier(param)) {
3457
- const id = t30.identifier(param.name || `arg${index}`);
3915
+ if (t33.isIdentifier(param)) {
3916
+ const id = t33.identifier(param.name || `arg${index}`);
3458
3917
  id.optional = param.optional;
3459
- id.typeAnnotation = param.typeAnnotation || t30.tsTypeAnnotation(t30.tsAnyKeyword());
3918
+ id.typeAnnotation = param.typeAnnotation || t33.tsTypeAnnotation(t33.tsAnyKeyword());
3460
3919
  return id;
3461
3920
  }
3462
- const fallback = t30.identifier(`arg${index}`);
3463
- fallback.typeAnnotation = t30.tsTypeAnnotation(t30.tsAnyKeyword());
3921
+ const fallback = t33.identifier(`arg${index}`);
3922
+ fallback.typeAnnotation = t33.tsTypeAnnotation(t33.tsAnyKeyword());
3464
3923
  return fallback;
3465
3924
  };
3466
3925
  return params.map(cloneCallableParam);
@@ -3470,18 +3929,18 @@ function cloneCallableParams(params) {
3470
3929
  function resolveEmitsTopLevelTypes(ctx) {
3471
3930
  return {
3472
3931
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path8) {
3473
- if (!t31.isProgram(path8.parent)) return;
3932
+ if (!t34.isProgram(path8.parent)) return;
3474
3933
  const { node } = path8;
3475
- if (t31.isTSInterfaceDeclaration(node)) {
3476
- const typeLiteral = t31.tsTypeLiteral(node.body.body);
3934
+ if (t34.isTSInterfaceDeclaration(node)) {
3935
+ const typeLiteral = t34.tsTypeLiteral(node.body.body);
3477
3936
  if (!hasEmitsSignatureInType(typeLiteral)) return;
3478
3937
  const resolved = resolveTopLevelEmitType(typeLiteral);
3479
- if (resolved && t31.isTSTypeLiteral(resolved)) {
3938
+ if (resolved && t34.isTSTypeLiteral(resolved)) {
3480
3939
  node.body.body = resolved.members;
3481
3940
  }
3482
3941
  return;
3483
3942
  }
3484
- if (t31.isTSTypeAliasDeclaration(node)) {
3943
+ if (t34.isTSTypeAliasDeclaration(node)) {
3485
3944
  if (!hasEmitsSignatureInType(node.typeAnnotation)) return;
3486
3945
  const resolved = resolveTopLevelEmitType(node.typeAnnotation);
3487
3946
  if (resolved) {
@@ -3492,47 +3951,47 @@ function resolveEmitsTopLevelTypes(ctx) {
3492
3951
  };
3493
3952
  }
3494
3953
  function resolveTopLevelEmitType(tsType) {
3495
- if (t31.isTSParenthesizedType(tsType)) {
3954
+ if (t34.isTSParenthesizedType(tsType)) {
3496
3955
  return resolveTopLevelEmitType(tsType.typeAnnotation);
3497
3956
  }
3498
- if (t31.isTSTypeReference(tsType)) {
3957
+ if (t34.isTSTypeReference(tsType)) {
3499
3958
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3500
3959
  return tsType;
3501
3960
  }
3502
3961
  const params = tsType.typeParameters.params.map((param) => resolveTopLevelEmitType(param)).filter(Boolean);
3503
- return t31.tsTypeReference(
3962
+ return t34.tsTypeReference(
3504
3963
  tsType.typeName,
3505
- t31.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3964
+ t34.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3506
3965
  );
3507
3966
  }
3508
- if (t31.isTSIntersectionType(tsType)) {
3967
+ if (t34.isTSIntersectionType(tsType)) {
3509
3968
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
3510
3969
  if (!types.length) return null;
3511
3970
  if (types.length === 1) return types[0];
3512
- return t31.tsIntersectionType(types);
3971
+ return t34.tsIntersectionType(types);
3513
3972
  }
3514
- if (t31.isTSUnionType(tsType)) {
3973
+ if (t34.isTSUnionType(tsType)) {
3515
3974
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
3516
3975
  if (!types.length) return null;
3517
3976
  if (types.length === 1) return types[0];
3518
- return t31.tsUnionType(types);
3977
+ return t34.tsUnionType(types);
3519
3978
  }
3520
- if (t31.isTSTypeLiteral(tsType)) {
3979
+ if (t34.isTSTypeLiteral(tsType)) {
3521
3980
  const members = [];
3522
3981
  for (const member of tsType.members) {
3523
- if (t31.isTSCallSignatureDeclaration(member)) {
3982
+ if (t34.isTSCallSignatureDeclaration(member)) {
3524
3983
  members.push(...resolveEmitPropsFromCallSignature(member));
3525
3984
  continue;
3526
3985
  }
3527
3986
  members.push(member);
3528
3987
  }
3529
3988
  if (!members.length) return null;
3530
- return t31.tsTypeLiteral(members);
3989
+ return t34.tsTypeLiteral(members);
3531
3990
  }
3532
- if (t31.isTSFunctionType(tsType)) {
3991
+ if (t34.isTSFunctionType(tsType)) {
3533
3992
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
3534
3993
  if (!props.length) return null;
3535
- return t31.tsTypeLiteral(props);
3994
+ return t34.tsTypeLiteral(props);
3536
3995
  }
3537
3996
  return tsType;
3538
3997
  }
@@ -3553,41 +4012,41 @@ function processInferredTypes(ctx, runtimeArg) {
3553
4012
  propsTSIface: { emitTypes }
3554
4013
  } = ctx.scriptData;
3555
4014
  const members = [];
3556
- if (t31.isArrayExpression(runtimeArg)) {
4015
+ if (t34.isArrayExpression(runtimeArg)) {
3557
4016
  for (const element of runtimeArg.elements) {
3558
- if (!element || !t31.isStringLiteral(element)) continue;
4017
+ if (!element || !t34.isStringLiteral(element)) continue;
3559
4018
  const handlerName = resolveEmitHandlerName(element.value);
3560
4019
  const key = buildKey(handlerName);
3561
- const fnType = t31.tsFunctionType(
4020
+ const fnType = t34.tsFunctionType(
3562
4021
  null,
3563
4022
  [createRestAnyParam("args")],
3564
- t31.tsTypeAnnotation(t31.tsAnyKeyword())
4023
+ t34.tsTypeAnnotation(t34.tsAnyKeyword())
3565
4024
  );
3566
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
4025
+ const prop = t34.tsPropertySignature(key, t34.tsTypeAnnotation(fnType));
3567
4026
  prop.optional = true;
3568
4027
  members.push(prop);
3569
4028
  }
3570
4029
  if (members.length) {
3571
- emitTypes.push(t31.tsTypeLiteral(members));
4030
+ emitTypes.push(t34.tsTypeLiteral(members));
3572
4031
  }
3573
4032
  return;
3574
4033
  }
3575
- if (t31.isObjectExpression(runtimeArg)) {
4034
+ if (t34.isObjectExpression(runtimeArg)) {
3576
4035
  for (const prop of runtimeArg.properties) {
3577
- if (!t31.isObjectProperty(prop)) continue;
3578
- if (t31.isSpreadElement(prop)) continue;
4036
+ if (!t34.isObjectProperty(prop)) continue;
4037
+ if (t34.isSpreadElement(prop)) continue;
3579
4038
  const rawName = resolvePropName(prop.key);
3580
4039
  if (!rawName) continue;
3581
4040
  const handlerName = resolveEmitHandlerName(rawName);
3582
4041
  const key = buildKey(handlerName);
3583
- const params = t31.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
3584
- const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(t31.tsAnyKeyword()));
3585
- const propSig = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
4042
+ const params = t34.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
4043
+ const fnType = t34.tsFunctionType(null, params, t34.tsTypeAnnotation(t34.tsAnyKeyword()));
4044
+ const propSig = t34.tsPropertySignature(key, t34.tsTypeAnnotation(fnType));
3586
4045
  propSig.optional = true;
3587
4046
  members.push(propSig);
3588
4047
  }
3589
4048
  if (members.length) {
3590
- emitTypes.push(t31.tsTypeLiteral(members));
4049
+ emitTypes.push(t34.tsTypeLiteral(members));
3591
4050
  }
3592
4051
  }
3593
4052
  }
@@ -3608,129 +4067,129 @@ function resolveEmitHandlerName(rawName) {
3608
4067
  return `on${name}`;
3609
4068
  }
3610
4069
  function resolvePropName(key) {
3611
- if (t31.isIdentifier(key)) return key.name;
3612
- if (t31.isStringLiteral(key)) return key.value;
3613
- if (t31.isNumericLiteral(key)) return String(key.value);
4070
+ if (t34.isIdentifier(key)) return key.name;
4071
+ if (t34.isStringLiteral(key)) return key.value;
4072
+ if (t34.isNumericLiteral(key)) return String(key.value);
3614
4073
  return null;
3615
4074
  }
3616
4075
  function buildKey(name) {
3617
- return t31.isValidIdentifier(name) ? t31.identifier(name) : t31.stringLiteral(name);
4076
+ return t34.isValidIdentifier(name) ? t34.identifier(name) : t34.stringLiteral(name);
3618
4077
  }
3619
4078
  function createRestAnyParam(name) {
3620
- const id = t31.identifier(name);
3621
- const rest = t31.restElement(id);
3622
- rest.typeAnnotation = t31.tsTypeAnnotation(t31.tsArrayType(t31.tsAnyKeyword()));
4079
+ const id = t34.identifier(name);
4080
+ const rest = t34.restElement(id);
4081
+ rest.typeAnnotation = t34.tsTypeAnnotation(t34.tsArrayType(t34.tsAnyKeyword()));
3623
4082
  return rest;
3624
4083
  }
3625
4084
  function resolveRuntimeTupleParams(value) {
3626
4085
  const params = [];
3627
4086
  value.elements.forEach((element, index) => {
3628
4087
  if (!element) return;
3629
- if (t31.isSpreadElement(element)) {
4088
+ if (t34.isSpreadElement(element)) {
3630
4089
  params.push(createRestAnyParam(`args${index}`));
3631
4090
  return;
3632
4091
  }
3633
- if (t31.isIdentifier(element)) {
3634
- const id = t31.identifier(element.name);
3635
- id.typeAnnotation = element.typeAnnotation || t31.tsTypeAnnotation(t31.tsAnyKeyword());
4092
+ if (t34.isIdentifier(element)) {
4093
+ const id = t34.identifier(element.name);
4094
+ id.typeAnnotation = element.typeAnnotation || t34.tsTypeAnnotation(t34.tsAnyKeyword());
3636
4095
  params.push(id);
3637
4096
  return;
3638
4097
  }
3639
- if (t31.isTSAsExpression(element)) {
3640
- const id = t31.identifier(`arg${index}`);
3641
- id.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
4098
+ if (t34.isTSAsExpression(element)) {
4099
+ const id = t34.identifier(`arg${index}`);
4100
+ id.typeAnnotation = t34.tsTypeAnnotation(element.typeAnnotation);
3642
4101
  params.push(id);
3643
4102
  return;
3644
4103
  }
3645
- const fallback = t31.identifier(`arg${index}`);
3646
- fallback.typeAnnotation = t31.tsTypeAnnotation(t31.tsAnyKeyword());
4104
+ const fallback = t34.identifier(`arg${index}`);
4105
+ fallback.typeAnnotation = t34.tsTypeAnnotation(t34.tsAnyKeyword());
3647
4106
  params.push(fallback);
3648
4107
  });
3649
4108
  return params;
3650
4109
  }
3651
4110
  function resolveExplicitEmitType(tsType) {
3652
- if (t31.isTSParenthesizedType(tsType)) {
4111
+ if (t34.isTSParenthesizedType(tsType)) {
3653
4112
  return resolveExplicitEmitType(tsType.typeAnnotation);
3654
4113
  }
3655
- if (t31.isTSTypeReference(tsType)) {
4114
+ if (t34.isTSTypeReference(tsType)) {
3656
4115
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3657
4116
  return tsType;
3658
4117
  }
3659
4118
  const params = tsType.typeParameters.params.map((param) => resolveExplicitEmitType(param)).filter(Boolean);
3660
- return t31.tsTypeReference(
4119
+ return t34.tsTypeReference(
3661
4120
  tsType.typeName,
3662
- t31.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
4121
+ t34.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3663
4122
  );
3664
4123
  }
3665
- if (t31.isTSIntersectionType(tsType)) {
4124
+ if (t34.isTSIntersectionType(tsType)) {
3666
4125
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
3667
4126
  if (!types.length) return null;
3668
4127
  if (types.length === 1) return types[0];
3669
- return t31.tsIntersectionType(types);
4128
+ return t34.tsIntersectionType(types);
3670
4129
  }
3671
- if (t31.isTSUnionType(tsType)) {
4130
+ if (t34.isTSUnionType(tsType)) {
3672
4131
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
3673
4132
  if (!types.length) return null;
3674
4133
  if (types.length === 1) return types[0];
3675
- return t31.tsUnionType(types);
4134
+ return t34.tsUnionType(types);
3676
4135
  }
3677
- if (t31.isTSTypeLiteral(tsType)) {
4136
+ if (t34.isTSTypeLiteral(tsType)) {
3678
4137
  const members = [];
3679
4138
  for (const member of tsType.members) {
3680
- if (t31.isTSPropertySignature(member)) {
4139
+ if (t34.isTSPropertySignature(member)) {
3681
4140
  const prop = resolveEmitPropFromPropertySignature(member);
3682
4141
  if (prop) members.push(prop);
3683
4142
  continue;
3684
4143
  }
3685
- if (t31.isTSCallSignatureDeclaration(member)) {
4144
+ if (t34.isTSCallSignatureDeclaration(member)) {
3686
4145
  members.push(...resolveEmitPropsFromCallSignature(member));
3687
4146
  continue;
3688
4147
  }
3689
4148
  }
3690
4149
  if (!members.length) return null;
3691
- return t31.tsTypeLiteral(members);
4150
+ return t34.tsTypeLiteral(members);
3692
4151
  }
3693
- if (t31.isTSFunctionType(tsType)) {
4152
+ if (t34.isTSFunctionType(tsType)) {
3694
4153
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
3695
4154
  if (!props.length) return null;
3696
- return t31.tsTypeLiteral(props);
4155
+ return t34.tsTypeLiteral(props);
3697
4156
  }
3698
4157
  return tsType;
3699
4158
  }
3700
4159
  function hasEmitsSignatureInType(tsType) {
3701
- if (t31.isTSParenthesizedType(tsType)) {
4160
+ if (t34.isTSParenthesizedType(tsType)) {
3702
4161
  return hasEmitsSignatureInType(tsType.typeAnnotation);
3703
4162
  }
3704
- if (t31.isTSTypeReference(tsType)) {
4163
+ if (t34.isTSTypeReference(tsType)) {
3705
4164
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3706
4165
  return false;
3707
4166
  }
3708
4167
  return tsType.typeParameters.params.some(hasEmitsSignatureInType);
3709
4168
  }
3710
- if (t31.isTSIntersectionType(tsType) || t31.isTSUnionType(tsType)) {
4169
+ if (t34.isTSIntersectionType(tsType) || t34.isTSUnionType(tsType)) {
3711
4170
  return tsType.types.some(hasEmitsSignatureInType);
3712
4171
  }
3713
- if (t31.isTSTypeLiteral(tsType)) {
4172
+ if (t34.isTSTypeLiteral(tsType)) {
3714
4173
  return tsType.members.some(hasEmitsSignatureInMember);
3715
4174
  }
3716
- if (t31.isTSFunctionType(tsType)) {
4175
+ if (t34.isTSFunctionType(tsType)) {
3717
4176
  return isEmitsCallable(tsType.parameters);
3718
4177
  }
3719
4178
  return false;
3720
4179
  }
3721
4180
  function hasEmitsSignatureInMember(member) {
3722
- if (t31.isTSCallSignatureDeclaration(member)) {
4181
+ if (t34.isTSCallSignatureDeclaration(member)) {
3723
4182
  return isEmitsCallable(member.parameters);
3724
4183
  }
3725
4184
  return false;
3726
4185
  }
3727
4186
  function isEmitsCallable(parameters) {
3728
4187
  const [eventParam] = parameters;
3729
- if (!eventParam || !t31.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
4188
+ if (!eventParam || !t34.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3730
4189
  return false;
3731
4190
  }
3732
4191
  const { typeAnnotation } = eventParam;
3733
- if (t31.isNoop(typeAnnotation)) return false;
4192
+ if (t34.isNoop(typeAnnotation)) return false;
3734
4193
  return resolveEventNames(typeAnnotation.typeAnnotation).length > 0;
3735
4194
  }
3736
4195
  function resolveEmitPropFromPropertySignature(member) {
@@ -3740,19 +4199,19 @@ function resolveEmitPropFromPropertySignature(member) {
3740
4199
  const key = buildKey(handlerName);
3741
4200
  const typeAnnotation = member.typeAnnotation?.typeAnnotation;
3742
4201
  let params = [];
3743
- let returnType = t31.tsAnyKeyword();
3744
- if (typeAnnotation && t31.isTSFunctionType(typeAnnotation)) {
4202
+ let returnType = t34.tsAnyKeyword();
4203
+ if (typeAnnotation && t34.isTSFunctionType(typeAnnotation)) {
3745
4204
  params = cloneCallableParams(typeAnnotation.parameters);
3746
4205
  returnType = typeAnnotation.typeAnnotation?.typeAnnotation ?? returnType;
3747
- } else if (typeAnnotation && t31.isTSTupleType(typeAnnotation)) {
4206
+ } else if (typeAnnotation && t34.isTSTupleType(typeAnnotation)) {
3748
4207
  params = resolveTupleTypeParams(typeAnnotation);
3749
4208
  } else if (typeAnnotation) {
3750
- const id = t31.identifier("value");
3751
- id.typeAnnotation = t31.tsTypeAnnotation(typeAnnotation);
4209
+ const id = t34.identifier("value");
4210
+ id.typeAnnotation = t34.tsTypeAnnotation(typeAnnotation);
3752
4211
  params = [id];
3753
4212
  }
3754
- const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(returnType));
3755
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
4213
+ const fnType = t34.tsFunctionType(null, params, t34.tsTypeAnnotation(returnType));
4214
+ const prop = t34.tsPropertySignature(key, t34.tsTypeAnnotation(fnType));
3756
4215
  prop.optional = !!member.optional;
3757
4216
  return prop;
3758
4217
  }
@@ -3761,32 +4220,32 @@ function resolveEmitPropsFromCallSignature(member) {
3761
4220
  }
3762
4221
  function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
3763
4222
  const [eventParam, ...restParams] = parameters;
3764
- if (!eventParam || !t31.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
4223
+ if (!eventParam || !t34.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3765
4224
  return [];
3766
4225
  }
3767
4226
  const { typeAnnotation: paramTypeAnnotation } = eventParam;
3768
- if (t31.isNoop(paramTypeAnnotation)) return [];
4227
+ if (t34.isNoop(paramTypeAnnotation)) return [];
3769
4228
  const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
3770
4229
  if (!eventNames.length) return [];
3771
- const returnType = typeAnnotation?.typeAnnotation ?? t31.tsAnyKeyword();
4230
+ const returnType = typeAnnotation?.typeAnnotation ?? t34.tsAnyKeyword();
3772
4231
  return eventNames.map((eventName) => {
3773
4232
  const handlerName = resolveEmitHandlerName(eventName);
3774
4233
  const key = buildKey(handlerName);
3775
4234
  const params = cloneCallableParams(restParams);
3776
- const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(returnType));
3777
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
4235
+ const fnType = t34.tsFunctionType(null, params, t34.tsTypeAnnotation(returnType));
4236
+ const prop = t34.tsPropertySignature(key, t34.tsTypeAnnotation(fnType));
3778
4237
  prop.optional = true;
3779
4238
  return prop;
3780
4239
  });
3781
4240
  }
3782
4241
  function resolveEventNames(type) {
3783
- if (t31.isTSLiteralType(type) && t31.isStringLiteral(type.literal)) {
4242
+ if (t34.isTSLiteralType(type) && t34.isStringLiteral(type.literal)) {
3784
4243
  return [type.literal.value];
3785
4244
  }
3786
- if (t31.isTSUnionType(type)) {
4245
+ if (t34.isTSUnionType(type)) {
3787
4246
  return type.types.flatMap(resolveEventNames);
3788
4247
  }
3789
- if (t31.isTSParenthesizedType(type)) {
4248
+ if (t34.isTSParenthesizedType(type)) {
3790
4249
  return resolveEventNames(type.typeAnnotation);
3791
4250
  }
3792
4251
  return [];
@@ -3799,44 +4258,44 @@ function resolveTupleTypeParams(tuple) {
3799
4258
  return params;
3800
4259
  }
3801
4260
  function resolveTupleElementParam(element, index) {
3802
- const isNamedTuple = typeof t31.isTSNamedTupleMember === "function" && t31.isTSNamedTupleMember(element);
4261
+ const isNamedTuple = typeof t34.isTSNamedTupleMember === "function" && t34.isTSNamedTupleMember(element);
3803
4262
  if (isNamedTuple) {
3804
4263
  const tupleMember = element;
3805
4264
  const name = tupleMember.label?.name || `arg${index}`;
3806
4265
  let innerType = tupleMember.elementType;
3807
4266
  let optional = tupleMember.optional;
3808
- if (t31.isTSOptionalType(innerType)) {
4267
+ if (t34.isTSOptionalType(innerType)) {
3809
4268
  optional = true;
3810
4269
  innerType = innerType.typeAnnotation;
3811
4270
  }
3812
- if (t31.isTSRestType(innerType)) {
3813
- const rest = t31.restElement(t31.identifier(name));
3814
- rest.typeAnnotation = t31.tsTypeAnnotation(innerType.typeAnnotation);
4271
+ if (t34.isTSRestType(innerType)) {
4272
+ const rest = t34.restElement(t34.identifier(name));
4273
+ rest.typeAnnotation = t34.tsTypeAnnotation(innerType.typeAnnotation);
3815
4274
  return rest;
3816
4275
  }
3817
- const id2 = t31.identifier(name);
4276
+ const id2 = t34.identifier(name);
3818
4277
  id2.optional = optional;
3819
- id2.typeAnnotation = t31.tsTypeAnnotation(innerType);
4278
+ id2.typeAnnotation = t34.tsTypeAnnotation(innerType);
3820
4279
  return id2;
3821
4280
  }
3822
- if (t31.isTSRestType(element)) {
3823
- const rest = t31.restElement(t31.identifier(`args${index}`));
3824
- rest.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
4281
+ if (t34.isTSRestType(element)) {
4282
+ const rest = t34.restElement(t34.identifier(`args${index}`));
4283
+ rest.typeAnnotation = t34.tsTypeAnnotation(element.typeAnnotation);
3825
4284
  return rest;
3826
4285
  }
3827
- if (t31.isTSOptionalType(element)) {
3828
- const id2 = t31.identifier(`arg${index}`);
4286
+ if (t34.isTSOptionalType(element)) {
4287
+ const id2 = t34.identifier(`arg${index}`);
3829
4288
  id2.optional = true;
3830
- id2.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
4289
+ id2.typeAnnotation = t34.tsTypeAnnotation(element.typeAnnotation);
3831
4290
  return id2;
3832
4291
  }
3833
- const id = t31.identifier(`arg${index}`);
3834
- id.typeAnnotation = t31.tsTypeAnnotation(element);
4292
+ const id = t34.identifier(`arg${index}`);
4293
+ id.typeAnnotation = t34.tsTypeAnnotation(element);
3835
4294
  return id;
3836
4295
  }
3837
4296
 
3838
4297
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-props.ts
3839
- import * as t32 from "@babel/types";
4298
+ import * as t35 from "@babel/types";
3840
4299
  function resolveDefinePropsIface(path8, ctx) {
3841
4300
  const { node } = path8;
3842
4301
  const [runtimeArg] = node.arguments;
@@ -3856,38 +4315,38 @@ function processInferredTypes2(ctx, runtimeArg) {
3856
4315
  } = scriptData;
3857
4316
  if (!runtimeArg) return;
3858
4317
  const members = [];
3859
- if (t32.isArrayExpression(runtimeArg)) {
4318
+ if (t35.isArrayExpression(runtimeArg)) {
3860
4319
  for (const element of runtimeArg.elements) {
3861
- if (!element || !t32.isStringLiteral(element)) continue;
3862
- const key = t32.isValidIdentifier(element.value) ? t32.identifier(element.value) : t32.stringLiteral(element.value);
3863
- const prop = t32.tsPropertySignature(key, t32.tsTypeAnnotation(t32.tsAnyKeyword()));
4320
+ if (!element || !t35.isStringLiteral(element)) continue;
4321
+ const key = t35.isValidIdentifier(element.value) ? t35.identifier(element.value) : t35.stringLiteral(element.value);
4322
+ const prop = t35.tsPropertySignature(key, t35.tsTypeAnnotation(t35.tsAnyKeyword()));
3864
4323
  prop.optional = true;
3865
4324
  members.push(prop);
3866
4325
  }
3867
4326
  if (members.length) {
3868
- propsTypes.push(t32.tsTypeLiteral(members));
4327
+ propsTypes.push(t35.tsTypeLiteral(members));
3869
4328
  }
3870
4329
  return;
3871
4330
  }
3872
- if (t32.isObjectExpression(runtimeArg)) {
4331
+ if (t35.isObjectExpression(runtimeArg)) {
3873
4332
  for (const prop of runtimeArg.properties) {
3874
- if (!t32.isObjectProperty(prop)) continue;
3875
- if (t32.isSpreadElement(prop)) continue;
4333
+ if (!t35.isObjectProperty(prop)) continue;
4334
+ if (t35.isSpreadElement(prop)) continue;
3876
4335
  const key = prop.key;
3877
4336
  let propName = null;
3878
- if (t32.isIdentifier(key)) propName = key.name;
3879
- if (t32.isStringLiteral(key)) propName = key.value;
3880
- if (t32.isNumericLiteral(key)) propName = String(key.value);
4337
+ if (t35.isIdentifier(key)) propName = key.name;
4338
+ if (t35.isStringLiteral(key)) propName = key.value;
4339
+ if (t35.isNumericLiteral(key)) propName = String(key.value);
3881
4340
  if (!propName) continue;
3882
4341
  const { type, required } = resolveRuntimePropMeta(prop.value);
3883
- const tsType = type ?? t32.tsAnyKeyword();
3884
- const tsKey = t32.isValidIdentifier(propName) ? t32.identifier(propName) : t32.stringLiteral(propName);
3885
- const tsProp = t32.tsPropertySignature(tsKey, t32.tsTypeAnnotation(tsType));
4342
+ const tsType = type ?? t35.tsAnyKeyword();
4343
+ const tsKey = t35.isValidIdentifier(propName) ? t35.identifier(propName) : t35.stringLiteral(propName);
4344
+ const tsProp = t35.tsPropertySignature(tsKey, t35.tsTypeAnnotation(tsType));
3886
4345
  tsProp.optional = !required;
3887
4346
  members.push(tsProp);
3888
4347
  }
3889
4348
  if (members.length) {
3890
- propsTypes.push(t32.tsTypeLiteral(members));
4349
+ propsTypes.push(t35.tsTypeLiteral(members));
3891
4350
  }
3892
4351
  return;
3893
4352
  }
@@ -3901,42 +4360,42 @@ function processInferredTypes2(ctx, runtimeArg) {
3901
4360
  );
3902
4361
  }
3903
4362
  function resolveRuntimePropMeta(value) {
3904
- if (t32.isIdentifier(value)) {
4363
+ if (t35.isIdentifier(value)) {
3905
4364
  return {
3906
4365
  type: mapRuntimeTypeToTSType(value),
3907
4366
  required: false
3908
4367
  };
3909
4368
  }
3910
- if (t32.isArrayExpression(value)) {
4369
+ if (t35.isArrayExpression(value)) {
3911
4370
  return {
3912
4371
  type: resolveRuntimeUnionType(value),
3913
4372
  required: false
3914
4373
  };
3915
4374
  }
3916
- if (!t32.isObjectExpression(value)) {
4375
+ if (!t35.isObjectExpression(value)) {
3917
4376
  return { required: false };
3918
4377
  }
3919
4378
  let type;
3920
4379
  let required = false;
3921
4380
  for (const prop of value.properties) {
3922
- if (!t32.isObjectProperty(prop)) continue;
3923
- if (t32.isSpreadElement(prop)) continue;
4381
+ if (!t35.isObjectProperty(prop)) continue;
4382
+ if (t35.isSpreadElement(prop)) continue;
3924
4383
  const key = prop.key;
3925
- const propName = t32.isIdentifier(key) ? key.name : t32.isStringLiteral(key) ? key.value : null;
4384
+ const propName = t35.isIdentifier(key) ? key.name : t35.isStringLiteral(key) ? key.value : null;
3926
4385
  if (!propName) continue;
3927
4386
  if (propName === "type") {
3928
4387
  const valueNode = prop.value;
3929
- if (t32.isArrayExpression(valueNode)) {
4388
+ if (t35.isArrayExpression(valueNode)) {
3930
4389
  type = resolveRuntimeUnionType(valueNode);
3931
4390
  continue;
3932
4391
  }
3933
- if (t32.isIdentifier(valueNode)) {
4392
+ if (t35.isIdentifier(valueNode)) {
3934
4393
  type = mapRuntimeTypeToTSType(valueNode);
3935
4394
  continue;
3936
4395
  }
3937
4396
  }
3938
4397
  if (propName === "required") {
3939
- if (t32.isBooleanLiteral(prop.value)) {
4398
+ if (t35.isBooleanLiteral(prop.value)) {
3940
4399
  required = prop.value.value;
3941
4400
  }
3942
4401
  }
@@ -3946,80 +4405,58 @@ function resolveRuntimePropMeta(value) {
3946
4405
  function resolveRuntimeUnionType(value) {
3947
4406
  const types = [];
3948
4407
  for (const element of value.elements) {
3949
- if (!element || !t32.isIdentifier(element)) continue;
4408
+ if (!element || !t35.isIdentifier(element)) continue;
3950
4409
  const resolved = mapRuntimeTypeToTSType(element);
3951
4410
  if (resolved) types.push(resolved);
3952
4411
  }
3953
- if (!types.length) return t32.tsAnyKeyword();
4412
+ if (!types.length) return t35.tsAnyKeyword();
3954
4413
  if (types.length === 1) return types[0];
3955
- return t32.tsUnionType(types);
3956
- }
3957
- function mapRuntimeTypeToTSType(value) {
3958
- switch (value.name) {
3959
- case "String":
3960
- return t32.tsStringKeyword();
3961
- case "Number":
3962
- return t32.tsNumberKeyword();
3963
- case "Boolean":
3964
- return t32.tsBooleanKeyword();
3965
- case "Object":
3966
- return t32.tsTypeLiteral([]);
3967
- case "Array":
3968
- return t32.tsArrayType(t32.tsAnyKeyword());
3969
- case "Function":
3970
- return t32.tsFunctionType(null, [], t32.tsTypeAnnotation(t32.tsAnyKeyword()));
3971
- case "Symbol":
3972
- return t32.tsSymbolKeyword();
3973
- case "BigInt":
3974
- return t32.tsBigIntKeyword();
3975
- default:
3976
- return t32.tsAnyKeyword();
3977
- }
4414
+ return t35.tsUnionType(types);
3978
4415
  }
3979
4416
 
3980
4417
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/type-resolver.ts
3981
- import * as t35 from "@babel/types";
4418
+ import * as t38 from "@babel/types";
3982
4419
 
3983
4420
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/slot-builder.ts
3984
- import * as t33 from "@babel/types";
4421
+ import * as t36 from "@babel/types";
3985
4422
  var SLOT_DEFAULT_NAME = "default";
3986
4423
  var SLOT_CHILDREN_NAME = "children";
3987
4424
  var SLOT_FN_PARAM_NAME = "props";
3988
4425
  function buildSlotPropSignature(rawName, params, optional) {
3989
4426
  const propName = rawName === SLOT_DEFAULT_NAME ? SLOT_CHILDREN_NAME : rawName;
3990
- const key = t33.isValidIdentifier(propName) ? t33.identifier(propName) : t33.stringLiteral(propName);
3991
- const reactNodeType = t33.tsTypeAnnotation(
3992
- t33.tsTypeReference(t33.identifier(REACT_API_MAP.ReactNode))
4427
+ const key = t36.isValidIdentifier(propName) ? t36.identifier(propName) : t36.stringLiteral(propName);
4428
+ const reactNodeType = t36.tsTypeAnnotation(
4429
+ t36.tsTypeReference(t36.identifier(REACT_API_MAP.ReactNode))
3993
4430
  );
3994
4431
  let typeAnnotation;
3995
4432
  if (rawName === SLOT_DEFAULT_NAME && params.length === 0 || params.length === 0) {
3996
4433
  typeAnnotation = reactNodeType;
3997
4434
  } else {
3998
- const fnType = t33.tsFunctionType(null, params, reactNodeType);
3999
- typeAnnotation = t33.tsTypeAnnotation(fnType);
4435
+ const fnType = t36.tsFunctionType(null, params, reactNodeType);
4436
+ typeAnnotation = t36.tsTypeAnnotation(fnType);
4000
4437
  }
4001
- const prop = t33.tsPropertySignature(key, typeAnnotation);
4438
+ const prop = t36.tsPropertySignature(key, typeAnnotation);
4002
4439
  prop.optional = optional;
4003
4440
  return prop;
4004
4441
  }
4005
4442
  function createSlotScopeParam(props, ctx) {
4006
- const paramId = t33.identifier(SLOT_FN_PARAM_NAME);
4443
+ const paramId = t36.identifier(SLOT_FN_PARAM_NAME);
4007
4444
  const propsSigns = [];
4008
4445
  const { reactiveBindings } = ctx.templateData;
4009
4446
  props.forEach(({ prop, tsType }) => {
4010
4447
  const foundBindingValue = reactiveBindings[prop]?.value;
4011
4448
  const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
4012
- const typeAnnotation = foundBindingTypes ? t33.tsTypeAnnotation(foundBindingTypes) : tsType;
4013
- const key = t33.isValidIdentifier(prop) ? t33.identifier(prop) : t33.stringLiteral(prop);
4014
- const propSign = t33.tsPropertySignature(key, typeAnnotation);
4449
+ const typeAnnotation = foundBindingTypes ? t36.tsTypeAnnotation(foundBindingTypes) : tsType;
4450
+ const key = t36.isValidIdentifier(prop) ? t36.identifier(prop) : t36.stringLiteral(prop);
4451
+ const propSign = t36.tsPropertySignature(key, typeAnnotation);
4015
4452
  propsSigns.push(propSign);
4016
4453
  });
4017
- paramId.typeAnnotation = t33.tsTypeAnnotation(t33.tsTypeLiteral(propsSigns));
4454
+ paramId.typeAnnotation = t36.tsTypeAnnotation(t36.tsTypeLiteral(propsSigns));
4018
4455
  return paramId;
4019
4456
  }
4020
4457
 
4021
4458
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/utils.ts
4022
- import * as t34 from "@babel/types";
4459
+ import * as t37 from "@babel/types";
4023
4460
  function recordReactNode(ctx) {
4024
4461
  if (!ctx.scriptData.lang.startsWith("ts")) {
4025
4462
  return;
@@ -4035,16 +4472,16 @@ function collectLocalTypeDeclarations(path8) {
4035
4472
  return declarations;
4036
4473
  }
4037
4474
  for (const statement of programPath.node.body) {
4038
- if (t34.isTSInterfaceDeclaration(statement)) {
4475
+ if (t37.isTSInterfaceDeclaration(statement)) {
4039
4476
  declarations.set(statement.id.name, {
4040
- type: t34.tsTypeLiteral(statement.body.body),
4477
+ type: t37.tsTypeLiteral(statement.body.body),
4041
4478
  // 将接口体转换为类型字面量
4042
4479
  hasTypeParameters: !!statement.typeParameters?.params.length
4043
4480
  // 检查是否有泛型参数
4044
4481
  });
4045
4482
  continue;
4046
4483
  }
4047
- if (t34.isTSTypeAliasDeclaration(statement)) {
4484
+ if (t37.isTSTypeAliasDeclaration(statement)) {
4048
4485
  declarations.set(statement.id.name, {
4049
4486
  type: statement.typeAnnotation,
4050
4487
  // 直接使用类型注解
@@ -4053,16 +4490,16 @@ function collectLocalTypeDeclarations(path8) {
4053
4490
  });
4054
4491
  continue;
4055
4492
  }
4056
- if (t34.isExportNamedDeclaration(statement) && statement.declaration) {
4493
+ if (t37.isExportNamedDeclaration(statement) && statement.declaration) {
4057
4494
  const declaration = statement.declaration;
4058
- if (t34.isTSInterfaceDeclaration(declaration)) {
4495
+ if (t37.isTSInterfaceDeclaration(declaration)) {
4059
4496
  declarations.set(declaration.id.name, {
4060
- type: t34.tsTypeLiteral(declaration.body.body),
4497
+ type: t37.tsTypeLiteral(declaration.body.body),
4061
4498
  // 将接口体转换为类型字面量
4062
4499
  hasTypeParameters: !!declaration.typeParameters?.params.length
4063
4500
  // 检查是否有泛型参数
4064
4501
  });
4065
- } else if (t34.isTSTypeAliasDeclaration(declaration)) {
4502
+ } else if (t37.isTSTypeAliasDeclaration(declaration)) {
4066
4503
  declarations.set(declaration.id.name, {
4067
4504
  type: declaration.typeAnnotation,
4068
4505
  // 直接使用类型注解
@@ -4075,22 +4512,22 @@ function collectLocalTypeDeclarations(path8) {
4075
4512
  return declarations;
4076
4513
  }
4077
4514
  function resolvePropName2(key) {
4078
- if (t34.isIdentifier(key)) {
4515
+ if (t37.isIdentifier(key)) {
4079
4516
  return key.name;
4080
4517
  }
4081
- if (t34.isStringLiteral(key)) {
4518
+ if (t37.isStringLiteral(key)) {
4082
4519
  return key.value;
4083
4520
  }
4084
- if (t34.isNumericLiteral(key)) {
4521
+ if (t37.isNumericLiteral(key)) {
4085
4522
  return String(key.value);
4086
4523
  }
4087
4524
  return null;
4088
4525
  }
4089
4526
  function resolveCallableType(tsType) {
4090
- if (t34.isTSFunctionType(tsType)) {
4527
+ if (t37.isTSFunctionType(tsType)) {
4091
4528
  return tsType;
4092
4529
  }
4093
- if (t34.isTSParenthesizedType(tsType)) {
4530
+ if (t37.isTSParenthesizedType(tsType)) {
4094
4531
  return resolveCallableType(tsType.typeAnnotation);
4095
4532
  }
4096
4533
  return null;
@@ -4099,10 +4536,10 @@ function resolveCallableType(tsType) {
4099
4536
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/type-resolver.ts
4100
4537
  var SLOT_DEFAULT_NAME2 = "default";
4101
4538
  function resolveSlotType(tsType, options) {
4102
- if (t35.isTSParenthesizedType(tsType)) {
4539
+ if (t38.isTSParenthesizedType(tsType)) {
4103
4540
  return resolveSlotType(tsType.typeAnnotation, options);
4104
4541
  }
4105
- if (t35.isTSTypeReference(tsType)) {
4542
+ if (t38.isTSTypeReference(tsType)) {
4106
4543
  let shouldRecordReactNode = false;
4107
4544
  if (tsType.typeParameters?.params.length) {
4108
4545
  const params = [];
@@ -4118,11 +4555,11 @@ function resolveSlotType(tsType, options) {
4118
4555
  };
4119
4556
  }
4120
4557
  return {
4121
- type: t35.tsTypeReference(tsType.typeName, t35.tsTypeParameterInstantiation(params)),
4558
+ type: t38.tsTypeReference(tsType.typeName, t38.tsTypeParameterInstantiation(params)),
4122
4559
  shouldRecordReactNode
4123
4560
  };
4124
4561
  }
4125
- if (!t35.isIdentifier(tsType.typeName)) {
4562
+ if (!t38.isIdentifier(tsType.typeName)) {
4126
4563
  return {
4127
4564
  type: tsType,
4128
4565
  shouldRecordReactNode: false
@@ -4153,7 +4590,7 @@ function resolveSlotType(tsType, options) {
4153
4590
  }
4154
4591
  return resolved;
4155
4592
  }
4156
- if (t35.isTSIntersectionType(tsType)) {
4593
+ if (t38.isTSIntersectionType(tsType)) {
4157
4594
  const types = [];
4158
4595
  let shouldRecordReactNode = false;
4159
4596
  for (const item of tsType.types) {
@@ -4176,11 +4613,11 @@ function resolveSlotType(tsType, options) {
4176
4613
  };
4177
4614
  }
4178
4615
  return {
4179
- type: t35.tsIntersectionType(types),
4616
+ type: t38.tsIntersectionType(types),
4180
4617
  shouldRecordReactNode
4181
4618
  };
4182
4619
  }
4183
- if (t35.isTSUnionType(tsType)) {
4620
+ if (t38.isTSUnionType(tsType)) {
4184
4621
  const types = [];
4185
4622
  let shouldRecordReactNode = false;
4186
4623
  for (const item of tsType.types) {
@@ -4203,11 +4640,11 @@ function resolveSlotType(tsType, options) {
4203
4640
  };
4204
4641
  }
4205
4642
  return {
4206
- type: t35.tsUnionType(types),
4643
+ type: t38.tsUnionType(types),
4207
4644
  shouldRecordReactNode
4208
4645
  };
4209
4646
  }
4210
- if (t35.isTSTypeLiteral(tsType)) {
4647
+ if (t38.isTSTypeLiteral(tsType)) {
4211
4648
  const members = [];
4212
4649
  let shouldRecordReactNode = false;
4213
4650
  for (const item of tsType.members) {
@@ -4222,11 +4659,11 @@ function resolveSlotType(tsType, options) {
4222
4659
  };
4223
4660
  }
4224
4661
  return {
4225
- type: t35.tsTypeLiteral(members),
4662
+ type: t38.tsTypeLiteral(members),
4226
4663
  shouldRecordReactNode
4227
4664
  };
4228
4665
  }
4229
- if (t35.isTSFunctionType(tsType)) {
4666
+ if (t38.isTSFunctionType(tsType)) {
4230
4667
  const props = buildSlotPropSignature(
4231
4668
  SLOT_DEFAULT_NAME2,
4232
4669
  cloneCallableParams(tsType.parameters),
@@ -4234,7 +4671,7 @@ function resolveSlotType(tsType, options) {
4234
4671
  // 默认插槽不是可选的
4235
4672
  );
4236
4673
  return {
4237
- type: t35.tsTypeLiteral([props]),
4674
+ type: t38.tsTypeLiteral([props]),
4238
4675
  shouldRecordReactNode: true
4239
4676
  // 函数类型总是需要记录 ReactNode
4240
4677
  };
@@ -4245,7 +4682,7 @@ function resolveSlotType(tsType, options) {
4245
4682
  };
4246
4683
  }
4247
4684
  function resolveSlotPropFromMember(member) {
4248
- if (t35.isTSMethodSignature(member)) {
4685
+ if (t38.isTSMethodSignature(member)) {
4249
4686
  const rawName = resolvePropName2(member.key);
4250
4687
  if (!rawName) {
4251
4688
  return {
@@ -4260,7 +4697,7 @@ function resolveSlotPropFromMember(member) {
4260
4697
  // 方法签名总是可调用,需要记录 ReactNode
4261
4698
  };
4262
4699
  }
4263
- if (t35.isTSPropertySignature(member)) {
4700
+ if (t38.isTSPropertySignature(member)) {
4264
4701
  const rawName = resolvePropName2(member.key);
4265
4702
  if (!rawName) {
4266
4703
  return {
@@ -4283,7 +4720,7 @@ function resolveSlotPropFromMember(member) {
4283
4720
  // 可调用属性需要记录 ReactNode
4284
4721
  };
4285
4722
  }
4286
- if (t35.isTSCallSignatureDeclaration(member)) {
4723
+ if (t38.isTSCallSignatureDeclaration(member)) {
4287
4724
  const params = cloneCallableParams(member.parameters);
4288
4725
  return {
4289
4726
  member: buildSlotPropSignature(SLOT_DEFAULT_NAME2, params, true),
@@ -4323,7 +4760,7 @@ function resolveDefineSlotsIface(path8, ctx) {
4323
4760
  }
4324
4761
 
4325
4762
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/template-slots.ts
4326
- import * as t36 from "@babel/types";
4763
+ import * as t39 from "@babel/types";
4327
4764
  function resolveTemplateSlotIface(ctx) {
4328
4765
  if (ctx.inputType !== "sfc") return;
4329
4766
  const {
@@ -4341,7 +4778,7 @@ function resolveTemplateSlotIface(ctx) {
4341
4778
  }
4342
4779
  if (tsMembers.length) {
4343
4780
  recordReactNode(ctx);
4344
- slotTypes.push(t36.tsTypeLiteral(tsMembers));
4781
+ slotTypes.push(t39.tsTypeLiteral(tsMembers));
4345
4782
  }
4346
4783
  }
4347
4784
 
@@ -4393,9 +4830,9 @@ function resolveCompIProps(ctx, ast) {
4393
4830
  }
4394
4831
  const n = declaredOptions.name || "Comp";
4395
4832
  const ns = `I${camelCase(capitalize(n))}Props`;
4396
- const typeNode = t37.tsIntersectionType(tsTypes);
4397
- const typeAliasDecl = t37.tsTypeAliasDeclaration(t37.identifier(ns), null, typeNode);
4398
- const exportDecl = t37.exportNamedDeclaration(typeAliasDecl);
4833
+ const typeNode = t40.tsIntersectionType(tsTypes);
4834
+ const typeAliasDecl = t40.tsTypeAliasDeclaration(t40.identifier(ns), null, typeNode);
4835
+ const exportDecl = t40.exportNamedDeclaration(typeAliasDecl);
4399
4836
  propsTSIface.name = ns;
4400
4837
  const scriptIR = getScriptIR(ctx);
4401
4838
  scriptIR.exports.push(exportDecl);
@@ -4403,15 +4840,15 @@ function resolveCompIProps(ctx, ast) {
4403
4840
  }
4404
4841
 
4405
4842
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-use-attrs.ts
4406
- import * as t38 from "@babel/types";
4843
+ import * as t41 from "@babel/types";
4407
4844
  function resolveUseAttrs(ctx) {
4408
4845
  return {
4409
4846
  VariableDeclarator(path8) {
4410
4847
  const { init, id } = path8.node;
4411
4848
  if (!init) return;
4412
4849
  const initPath = path8.get("init");
4413
- const propsIdentifier = t38.identifier(ctx.propField);
4414
- if (t38.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
4850
+ const propsIdentifier = t41.identifier(ctx.propField);
4851
+ if (t41.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
4415
4852
  const typeAssertion = createPropsTypeAssertion(propsIdentifier, init.typeAnnotation);
4416
4853
  replaceNode(initPath, typeAssertion, init);
4417
4854
  return;
@@ -4422,13 +4859,13 @@ function resolveUseAttrs(ctx) {
4422
4859
  const isTS = ctx.scriptData.lang.startsWith("ts");
4423
4860
  if (isTS) {
4424
4861
  let typeAnnotation = null;
4425
- if (t38.isIdentifier(id) && t38.isTSTypeAnnotation(id.typeAnnotation)) {
4862
+ if (t41.isIdentifier(id) && t41.isTSTypeAnnotation(id.typeAnnotation)) {
4426
4863
  typeAnnotation = id.typeAnnotation.typeAnnotation;
4427
4864
  id.typeAnnotation = null;
4428
4865
  } else {
4429
- typeAnnotation = t38.tsTypeReference(
4430
- t38.identifier("Record"),
4431
- t38.tsTypeParameterInstantiation([t38.tsStringKeyword(), t38.tsUnknownKeyword()])
4866
+ typeAnnotation = t41.tsTypeReference(
4867
+ t41.identifier("Record"),
4868
+ t41.tsTypeParameterInstantiation([t41.tsStringKeyword(), t41.tsUnknownKeyword()])
4432
4869
  );
4433
4870
  }
4434
4871
  const propsTypeAssertion = createPropsTypeAssertion(propsIdentifier, typeAnnotation);
@@ -4440,18 +4877,18 @@ function resolveUseAttrs(ctx) {
4440
4877
  };
4441
4878
  }
4442
4879
  function isUseAttrsCall(expr) {
4443
- return t38.isCallExpression(expr) && isCalleeNamed(expr, VUE_API_MAP.useAttrs);
4880
+ return t41.isCallExpression(expr) && isCalleeNamed(expr, VUE_API_MAP.useAttrs);
4444
4881
  }
4445
4882
  function createPropsTypeAssertion(propsIdentifier, typeAnnotation) {
4446
- return t38.tsAsExpression(propsIdentifier, typeAnnotation);
4883
+ return t41.tsAsExpression(propsIdentifier, typeAnnotation);
4447
4884
  }
4448
4885
 
4449
4886
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
4450
- import * as t44 from "@babel/types";
4887
+ import * as t48 from "@babel/types";
4451
4888
 
4452
4889
  // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4453
4890
  import { traverse as traverse2 } from "@babel/core";
4454
- import * as t43 from "@babel/types";
4891
+ import * as t46 from "@babel/types";
4455
4892
 
4456
4893
  // src/core/transform/sfc/script/shared/dependency-analyzer/binding-utils.ts
4457
4894
  function isBindingDeclaredInsideBoundary(binding, boundary) {
@@ -4470,7 +4907,7 @@ function isReactiveBinding(node) {
4470
4907
  }
4471
4908
 
4472
4909
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-checker.ts
4473
- import * as t39 from "@babel/types";
4910
+ import * as t42 from "@babel/types";
4474
4911
  function isEligibleBindingSource(binding) {
4475
4912
  if (binding.kind === "param") {
4476
4913
  return false;
@@ -4480,57 +4917,57 @@ function isEligibleBindingSource(binding) {
4480
4917
  const declaratorPath = getVariableDeclaratorPath(bindingPath);
4481
4918
  const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
4482
4919
  const nodeInit = declaratorPath?.node.init;
4483
- const isReactiveApiCallVarBinding = !!declaratorPath && t39.isCallExpression(nodeInit) && t39.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4484
- const isHookCallVarBinding = !!declaratorPath && t39.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4485
- const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t39.isArrowFunctionExpression(nodeInit) || t39.isFunctionExpression(nodeInit));
4920
+ const isReactiveApiCallVarBinding = !!declaratorPath && t42.isCallExpression(nodeInit) && t42.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4921
+ const isHookCallVarBinding = !!declaratorPath && t42.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4922
+ const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t42.isArrowFunctionExpression(nodeInit) || t42.isFunctionExpression(nodeInit));
4486
4923
  const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(declaratorPath?.node) || isReactiveBinding(bindingPath.node));
4487
4924
  return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
4488
4925
  }
4489
4926
  function isReactValidDependencyExpr(node) {
4490
- if (t39.isIdentifier(node)) {
4927
+ if (t42.isIdentifier(node)) {
4491
4928
  return true;
4492
4929
  }
4493
- if (t39.isMemberExpression(node) || t39.isOptionalMemberExpression(node)) {
4930
+ if (t42.isMemberExpression(node) || t42.isOptionalMemberExpression(node)) {
4494
4931
  return isStaticMemberChain(node);
4495
4932
  }
4496
4933
  return false;
4497
4934
  }
4498
4935
  function isStaticMemberChain(node) {
4499
4936
  let current = node;
4500
- while (t39.isMemberExpression(current) || t39.isOptionalMemberExpression(current)) {
4501
- if (!current.computed && !t39.isIdentifier(current.property)) {
4937
+ while (t42.isMemberExpression(current) || t42.isOptionalMemberExpression(current)) {
4938
+ if (!current.computed && !t42.isIdentifier(current.property)) {
4502
4939
  return false;
4503
4940
  }
4504
- if (current.computed && !t39.isStringLiteral(current.property) && !t39.isNumericLiteral(current.property)) {
4941
+ if (current.computed && !t42.isStringLiteral(current.property) && !t42.isNumericLiteral(current.property)) {
4505
4942
  return false;
4506
4943
  }
4507
4944
  current = current.object;
4508
4945
  }
4509
- return t39.isIdentifier(current);
4946
+ return t42.isIdentifier(current);
4510
4947
  }
4511
4948
  function isHookLikeCallee(callee) {
4512
- if (t39.isIdentifier(callee)) {
4949
+ if (t42.isIdentifier(callee)) {
4513
4950
  return callee.name.startsWith("use");
4514
4951
  }
4515
- if (t39.isMemberExpression(callee) && !callee.computed && t39.isIdentifier(callee.property)) {
4952
+ if (t42.isMemberExpression(callee) && !callee.computed && t42.isIdentifier(callee.property)) {
4516
4953
  return callee.property.name.startsWith("use");
4517
4954
  }
4518
4955
  return false;
4519
4956
  }
4520
4957
 
4521
4958
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-key.ts
4522
- import * as t40 from "@babel/types";
4959
+ import * as t43 from "@babel/types";
4523
4960
  function getDependencyKey(exp) {
4524
- if (t40.isIdentifier(exp)) {
4961
+ if (t43.isIdentifier(exp)) {
4525
4962
  return exp.name;
4526
4963
  }
4527
- if (t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp)) {
4964
+ if (t43.isMemberExpression(exp) || t43.isOptionalMemberExpression(exp)) {
4528
4965
  const objectKey = getDependencyKey(exp.object);
4529
4966
  const opt = exp.optional ? "?" : "";
4530
- if (!exp.computed && t40.isIdentifier(exp.property)) {
4967
+ if (!exp.computed && t43.isIdentifier(exp.property)) {
4531
4968
  return `${objectKey}${opt}.${exp.property.name}`;
4532
4969
  }
4533
- if (t40.isStringLiteral(exp.property) || t40.isNumericLiteral(exp.property)) {
4970
+ if (t43.isStringLiteral(exp.property) || t43.isNumericLiteral(exp.property)) {
4534
4971
  return `${objectKey}${opt}[${JSON.stringify(exp.property.value)}]`;
4535
4972
  }
4536
4973
  return `${objectKey}${opt}[*]`;
@@ -4539,40 +4976,40 @@ function getDependencyKey(exp) {
4539
4976
  }
4540
4977
 
4541
4978
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-normalizer.ts
4542
- import * as t41 from "@babel/types";
4979
+ import * as t44 from "@babel/types";
4543
4980
  function normalizeDependencyExpr(path8, rootName, ctx) {
4544
- if (t41.isIdentifier(path8.node)) {
4545
- return t41.identifier(path8.node.name);
4981
+ if (t44.isIdentifier(path8.node)) {
4982
+ return t44.identifier(path8.node.name);
4546
4983
  }
4547
- if (t41.isMemberExpression(path8.node) || t41.isOptionalMemberExpression(path8.node)) {
4984
+ if (t44.isMemberExpression(path8.node) || t44.isOptionalMemberExpression(path8.node)) {
4548
4985
  if (rootName === ctx.propField) {
4549
4986
  const safePropsExp = ensureOptionalForMemberChain(path8.node);
4550
4987
  if (isReactValidDependencyExpr(safePropsExp)) {
4551
- return t41.cloneNode(safePropsExp, true);
4988
+ return t44.cloneNode(safePropsExp, true);
4552
4989
  }
4553
- return t41.identifier(rootName);
4990
+ return t44.identifier(rootName);
4554
4991
  }
4555
4992
  const normalizedExp = normalizeMemberForCallSite(path8, path8.node);
4556
- const safeExp = t41.isMemberExpression(normalizedExp) || t41.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4993
+ const safeExp = t44.isMemberExpression(normalizedExp) || t44.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4557
4994
  if (isReactValidDependencyExpr(safeExp)) {
4558
- return t41.cloneNode(safeExp, true);
4995
+ return t44.cloneNode(safeExp, true);
4559
4996
  }
4560
- return t41.identifier(rootName);
4997
+ return t44.identifier(rootName);
4561
4998
  }
4562
4999
  return null;
4563
5000
  }
4564
5001
  function normalizeSourcedDependency(exp) {
4565
- if (t41.isIdentifier(exp)) {
4566
- return t41.identifier(exp.name);
5002
+ if (t44.isIdentifier(exp)) {
5003
+ return t44.identifier(exp.name);
4567
5004
  }
4568
- if (t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp)) {
5005
+ if (t44.isMemberExpression(exp) || t44.isOptionalMemberExpression(exp)) {
4569
5006
  const root = findRootIdentifier(exp);
4570
5007
  if (!root) return null;
4571
- const safeExp = t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
5008
+ const safeExp = t44.isMemberExpression(exp) || t44.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4572
5009
  if (isReactValidDependencyExpr(safeExp)) {
4573
- return t41.cloneNode(safeExp, true);
5010
+ return t44.cloneNode(safeExp, true);
4574
5011
  }
4575
- return t41.identifier(root.name);
5012
+ return t44.identifier(root.name);
4576
5013
  }
4577
5014
  return null;
4578
5015
  }
@@ -4582,7 +5019,7 @@ function normalizeMemberForCallSite(path8, node) {
4582
5019
  if (!isDirectCallee) {
4583
5020
  return node;
4584
5021
  }
4585
- if (!t41.isExpression(node.object)) {
5022
+ if (!t44.isExpression(node.object)) {
4586
5023
  return node;
4587
5024
  }
4588
5025
  return node.object;
@@ -4594,20 +5031,20 @@ function ensureOptionalForMemberChain(node) {
4594
5031
  const rebuildWithOptionalChain = (node2) => {
4595
5032
  const safeObject = ensureOptionalForMemberChain(node2.object);
4596
5033
  if (safeObject !== node2.object) {
4597
- const property = t41.cloneNode(node2.property, true);
4598
- return t41.optionalMemberExpression(safeObject, property, node2.computed, true);
5034
+ const property = t44.cloneNode(node2.property, true);
5035
+ return t44.optionalMemberExpression(safeObject, property, node2.computed, true);
4599
5036
  }
4600
- if (t41.isMemberExpression(node2)) {
4601
- const object = t41.cloneNode(node2.object, true);
4602
- const property = t41.cloneNode(node2.property, true);
4603
- return t41.optionalMemberExpression(object, property, node2.computed, true);
5037
+ if (t44.isMemberExpression(node2)) {
5038
+ const object = t44.cloneNode(node2.object, true);
5039
+ const property = t44.cloneNode(node2.property, true);
5040
+ return t44.optionalMemberExpression(object, property, node2.computed, true);
4604
5041
  }
4605
5042
  return node2;
4606
5043
  };
4607
5044
  return rebuildWithOptionalChain(node);
4608
5045
  }
4609
5046
  function hasTrailingMemberAccess(node) {
4610
- return t41.isMemberExpression(node.object) || t41.isOptionalMemberExpression(node.object);
5047
+ return t44.isMemberExpression(node.object) || t44.isOptionalMemberExpression(node.object);
4611
5048
  }
4612
5049
 
4613
5050
  // src/core/transform/sfc/script/shared/dependency-analyzer/shared-utils.ts
@@ -4622,7 +5059,7 @@ function isNestedMemberObject(path8) {
4622
5059
  }
4623
5060
 
4624
5061
  // src/core/transform/sfc/script/shared/dependency-analyzer/trace-utils.ts
4625
- import * as t42 from "@babel/types";
5062
+ import * as t45 from "@babel/types";
4626
5063
  function traceBindingSource(binding, seen, depth) {
4627
5064
  if (depth <= 0) return null;
4628
5065
  const declaratorPath = getVariableDeclaratorPath(binding.path);
@@ -4634,7 +5071,7 @@ function traceBindingSource(binding, seen, depth) {
4634
5071
  }
4635
5072
  function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4636
5073
  if (depth <= 0) return null;
4637
- if (t42.isIdentifier(exp)) {
5074
+ if (t45.isIdentifier(exp)) {
4638
5075
  const sourceBinding = scope.getBinding(exp.name);
4639
5076
  if (!sourceBinding) return null;
4640
5077
  if (isEligibleBindingSource(sourceBinding)) {
@@ -4642,13 +5079,13 @@ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4642
5079
  }
4643
5080
  return traceBindingSource(sourceBinding, seen, depth - 1);
4644
5081
  }
4645
- if (t42.isMemberExpression(exp) || t42.isOptionalMemberExpression(exp)) {
5082
+ if (t45.isMemberExpression(exp) || t45.isOptionalMemberExpression(exp)) {
4646
5083
  const root = findRootIdentifier(exp);
4647
5084
  if (!root) return null;
4648
5085
  const sourceBinding = scope.getBinding(root.name);
4649
5086
  if (!sourceBinding) return null;
4650
5087
  if (isEligibleBindingSource(sourceBinding)) {
4651
- return t42.cloneNode(exp);
5088
+ return t45.cloneNode(exp);
4652
5089
  }
4653
5090
  const sourcedRoot = traceBindingSource(sourceBinding, seen, depth - 1);
4654
5091
  if (sourcedRoot) {
@@ -4656,17 +5093,17 @@ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4656
5093
  if (rebuilt) {
4657
5094
  return rebuilt;
4658
5095
  }
4659
- return t42.cloneNode(sourcedRoot, true);
5096
+ return t45.cloneNode(sourcedRoot, true);
4660
5097
  }
4661
5098
  }
4662
5099
  return null;
4663
5100
  }
4664
5101
  function rebuildMemberWithNewRoot(node, nextRoot) {
4665
5102
  const replacedObject = (() => {
4666
- if (t42.isIdentifier(node.object)) {
4667
- return t42.cloneNode(nextRoot, true);
5103
+ if (t45.isIdentifier(node.object)) {
5104
+ return t45.cloneNode(nextRoot, true);
4668
5105
  }
4669
- if (t42.isMemberExpression(node.object) || t42.isOptionalMemberExpression(node.object)) {
5106
+ if (t45.isMemberExpression(node.object) || t45.isOptionalMemberExpression(node.object)) {
4670
5107
  return rebuildMemberWithNewRoot(node.object, nextRoot);
4671
5108
  }
4672
5109
  return null;
@@ -4674,15 +5111,15 @@ function rebuildMemberWithNewRoot(node, nextRoot) {
4674
5111
  if (!replacedObject) {
4675
5112
  return null;
4676
5113
  }
4677
- const property = t42.cloneNode(node.property, true);
4678
- if (t42.isMemberExpression(node)) {
4679
- return t42.memberExpression(
5114
+ const property = t45.cloneNode(node.property, true);
5115
+ if (t45.isMemberExpression(node)) {
5116
+ return t45.memberExpression(
4680
5117
  replacedObject,
4681
5118
  property,
4682
5119
  node.computed
4683
5120
  );
4684
5121
  }
4685
- return t42.optionalMemberExpression(
5122
+ return t45.optionalMemberExpression(
4686
5123
  replacedObject,
4687
5124
  property,
4688
5125
  node.computed,
@@ -4693,9 +5130,9 @@ function rebuildMemberWithNewRoot(node, nextRoot) {
4693
5130
  // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4694
5131
  function analyzeDeps(node, ctx, parentPath) {
4695
5132
  if (!parentPath) {
4696
- return t43.arrayExpression([]);
5133
+ return t46.arrayExpression([]);
4697
5134
  }
4698
- const isFnExpr = t43.isArrowFunctionExpression(node) || t43.isFunctionExpression(node);
5135
+ const isFnExpr = t46.isArrowFunctionExpression(node) || t46.isFunctionExpression(node);
4699
5136
  const analyzeTarget = isFnExpr ? node.body : node;
4700
5137
  const bindingLocalBoundary = isFnExpr ? node : analyzeTarget;
4701
5138
  const deps = /* @__PURE__ */ new Map();
@@ -4705,13 +5142,13 @@ function analyzeDeps(node, ctx, parentPath) {
4705
5142
  }
4706
5143
  const analyzeTargetPath = parentPath && parentPath.node === analyzeTarget ? parentPath : null;
4707
5144
  if (analyzeTargetPath) {
4708
- if (t43.isMemberExpression(analyzeTarget) || t43.isOptionalMemberExpression(analyzeTarget)) {
5145
+ if (t46.isMemberExpression(analyzeTarget) || t46.isOptionalMemberExpression(analyzeTarget)) {
4709
5146
  const rootId = findRootIdentifier(analyzeTarget);
4710
5147
  if (rootId) {
4711
5148
  tryAddDependency(analyzeTargetPath, rootId.name, analyzeTargetPath.scope);
4712
5149
  processedIdentifiers.add(rootId);
4713
5150
  }
4714
- } else if (t43.isIdentifier(analyzeTarget)) {
5151
+ } else if (t46.isIdentifier(analyzeTarget)) {
4715
5152
  tryAddDependency(analyzeTargetPath, analyzeTarget.name, analyzeTargetPath.scope);
4716
5153
  }
4717
5154
  }
@@ -4763,55 +5200,54 @@ function analyzeDeps(node, ctx, parentPath) {
4763
5200
  }
4764
5201
  }
4765
5202
  }
4766
- return t43.arrayExpression(Array.from(deps.values()));
5203
+ return t46.arrayExpression(Array.from(deps.values()));
4767
5204
  }
4768
5205
 
4769
- // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
4770
- function resolveAnalysisOnlyAdapter(ctx) {
5206
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-adapter.ts
5207
+ import * as t47 from "@babel/types";
5208
+ function resolveRenameAdapter(ctx) {
4771
5209
  return {
4772
5210
  "CallExpression|Identifier"(path8) {
4773
5211
  const node = path8.node;
4774
- const apiName = getApiName(node);
4775
- const adapter = ADAPTER_RULES.runtime[apiName];
4776
- if (!adapter || adapter.type !== "analyzed-deps") {
5212
+ const isCallNode = t47.isCallExpression(node);
5213
+ let apiName = "";
5214
+ if (t47.isIdentifier(node)) {
5215
+ apiName = node.name;
5216
+ } else if (isCallNode && t47.isIdentifier(node.callee)) {
5217
+ apiName = node.callee.name;
5218
+ }
5219
+ if (!apiName) {
5220
+ return;
5221
+ }
5222
+ const runtimeAdapter = ADAPTER_RULES.runtime[apiName];
5223
+ const routerAdapter = ADAPTER_RULES.router[apiName];
5224
+ const adapter = runtimeAdapter || routerAdapter;
5225
+ if (!adapter || adapter.type !== "rename") {
4777
5226
  return;
4778
5227
  }
4779
5228
  if (!isVueApiReference(path8, apiName)) {
4780
5229
  return;
4781
5230
  }
4782
- if (t44.isCallExpression(node)) {
4783
- resolveCallNode(path8, adapter, ctx);
5231
+ if (adapter.isTrackable) {
5232
+ const reactiveType = getReactiveType(apiName);
5233
+ const declaratorPath = getVariableDeclaratorPath(path8);
5234
+ setScriptNodeMeta(declaratorPath?.node, {
5235
+ is_reactive: true,
5236
+ reactive_type: reactiveType
5237
+ });
5238
+ }
5239
+ if (isCallNode) {
5240
+ replaceCallName(node, adapter.target);
4784
5241
  } else {
4785
5242
  replaceIdName(node, adapter.target);
4786
5243
  }
5244
+ if (adapter.package === PACKAGE_NAME.router && !ctx.route) {
5245
+ ctx.route = true;
5246
+ }
4787
5247
  recordImport(ctx, adapter.package, adapter.target);
4788
5248
  }
4789
5249
  };
4790
5250
  }
4791
- function getApiName(node) {
4792
- const isCallNode = t44.isCallExpression(node);
4793
- let apiName = "";
4794
- if (t44.isIdentifier(node)) {
4795
- apiName = node.name;
4796
- } else if (isCallNode && t44.isIdentifier(node.callee)) {
4797
- apiName = node.callee.name;
4798
- }
4799
- return apiName;
4800
- }
4801
- function resolveCallNode(path8, adapter, ctx) {
4802
- const { node } = path8;
4803
- const { arguments: args } = node;
4804
- if (!args.length) return;
4805
- const fn = args[0];
4806
- if (!t44.isArrowFunctionExpression(fn) && !t44.isFunctionExpression(fn)) {
4807
- return;
4808
- }
4809
- const fnPath = path8.get("arguments")[0];
4810
- const deps = analyzeDeps(fn, ctx, fnPath);
4811
- args.push(deps);
4812
- replaceCallName(node, adapter.target);
4813
- recordImport(ctx, adapter.package, adapter.target);
4814
- }
4815
5251
  function isVueApiReference(path8, apiName) {
4816
5252
  if (path8.isIdentifier()) {
4817
5253
  if (path8.parentPath.isCallExpression() && path8.parentPath.node.callee === path8.node) {
@@ -4821,12 +5257,11 @@ function isVueApiReference(path8, apiName) {
4821
5257
  return false;
4822
5258
  }
4823
5259
  }
4824
- if (path8.isCallExpression()) {
4825
- const callee = path8.get("callee");
4826
- if (!callee.isIdentifier()) return false;
4827
- return isVueImportBinding(callee.scope.getBinding(apiName));
5260
+ const binding = path8.isCallExpression() ? path8.get("callee").scope.getBinding(apiName) : path8.scope.getBinding(apiName);
5261
+ if (binding) {
5262
+ return isVueImportBinding(binding);
4828
5263
  }
4829
- return isVueImportBinding(path8.scope.getBinding(apiName));
5264
+ return AUTO_IMPORTED_APIS.has(apiName);
4830
5265
  }
4831
5266
  function isVueImportBinding(binding) {
4832
5267
  if (!binding) return false;
@@ -4835,7 +5270,7 @@ function isVueImportBinding(binding) {
4835
5270
  return false;
4836
5271
  }
4837
5272
  const parent = bindingPath.parentPath?.node;
4838
- if (!parent || !t44.isImportDeclaration(parent)) {
5273
+ if (!parent || !t47.isImportDeclaration(parent)) {
4839
5274
  return false;
4840
5275
  }
4841
5276
  const source = parent.source.value.toLowerCase();
@@ -4848,6 +5283,53 @@ function isVueImportBinding(binding) {
4848
5283
  return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
4849
5284
  }
4850
5285
 
5286
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
5287
+ function resolveAnalysisOnlyAdapter(ctx) {
5288
+ return {
5289
+ "CallExpression|Identifier"(path8) {
5290
+ const node = path8.node;
5291
+ const apiName = getApiName(node);
5292
+ const adapter = ADAPTER_RULES.runtime[apiName];
5293
+ if (!adapter || adapter.type !== "analyzed-deps") {
5294
+ return;
5295
+ }
5296
+ if (!isVueApiReference(path8, apiName)) {
5297
+ return;
5298
+ }
5299
+ if (t48.isCallExpression(node)) {
5300
+ resolveCallNode(path8, adapter, ctx);
5301
+ } else {
5302
+ replaceIdName(node, adapter.target);
5303
+ }
5304
+ recordImport(ctx, adapter.package, adapter.target);
5305
+ }
5306
+ };
5307
+ }
5308
+ function getApiName(node) {
5309
+ const isCallNode = t48.isCallExpression(node);
5310
+ let apiName = "";
5311
+ if (t48.isIdentifier(node)) {
5312
+ apiName = node.name;
5313
+ } else if (isCallNode && t48.isIdentifier(node.callee)) {
5314
+ apiName = node.callee.name;
5315
+ }
5316
+ return apiName;
5317
+ }
5318
+ function resolveCallNode(path8, adapter, ctx) {
5319
+ const { node } = path8;
5320
+ const { arguments: args } = node;
5321
+ if (!args.length) return;
5322
+ const fn = args[0];
5323
+ if (!t48.isArrowFunctionExpression(fn) && !t48.isFunctionExpression(fn)) {
5324
+ return;
5325
+ }
5326
+ const fnPath = path8.get("arguments")[0];
5327
+ const deps = analyzeDeps(fn, ctx, fnPath);
5328
+ args.push(deps);
5329
+ replaceCallName(node, adapter.target);
5330
+ recordImport(ctx, adapter.package, adapter.target);
5331
+ }
5332
+
4851
5333
  // src/core/transform/sfc/script/syntax-processor/process/resolve-arrow-deps.ts
4852
5334
  function resolveArrowFnDeps(ctx, ast) {
4853
5335
  return {
@@ -4903,7 +5385,7 @@ function isSkip(path8) {
4903
5385
  }
4904
5386
 
4905
5387
  // src/core/transform/sfc/script/syntax-processor/process/resolve-element-ref.ts
4906
- import * as t45 from "@babel/types";
5388
+ import * as t49 from "@babel/types";
4907
5389
  function resolveElementRef(ctx) {
4908
5390
  return {
4909
5391
  CallExpression(path8) {
@@ -4921,14 +5403,14 @@ function resolveElementRef(ctx) {
4921
5403
  }
4922
5404
  if (isCompRefBindings) {
4923
5405
  const varDeclaratorPath = getVariableDeclaratorPath(path8)?.node;
4924
- if (!t45.isIdentifier(varDeclaratorPath?.id)) {
5406
+ if (!t49.isIdentifier(varDeclaratorPath?.id)) {
4925
5407
  return;
4926
5408
  }
4927
5409
  const varName = varDeclaratorPath.id.name;
4928
5410
  const compRef = refBindings.componentRefs[varName];
4929
5411
  if (!compRef) return;
4930
5412
  }
4931
- node.arguments[0] = t45.identifier("null");
5413
+ node.arguments[0] = t49.identifier("null");
4932
5414
  resolveTypeParameters(ctx, path8);
4933
5415
  replaceCallName(node, REACT_API_MAP.useRef);
4934
5416
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
@@ -4953,27 +5435,27 @@ function resolveTypeParameters(ctx, path8) {
4953
5435
  const compBindingMeta = refBindings.componentRefs[idName];
4954
5436
  if (!node.typeParameters && (domBindingMeta || compBindingMeta)) {
4955
5437
  const type = compBindingMeta ? "any" : domBindingMeta.htmlType;
4956
- node.typeParameters = t45.tsTypeParameterInstantiation([t45.tsTypeReference(t45.identifier(type))]);
5438
+ node.typeParameters = t49.tsTypeParameterInstantiation([t49.tsTypeReference(t49.identifier(type))]);
4957
5439
  }
4958
5440
  }
4959
5441
  function resolveRefValueToCurrent(path8) {
4960
5442
  const { node } = path8;
4961
- if (node.computed || !t45.isIdentifier(node.property) || node.property.name !== "value") {
5443
+ if (node.computed || !t49.isIdentifier(node.property) || node.property.name !== "value") {
4962
5444
  return;
4963
5445
  }
4964
5446
  const rootPath = findRootVariablePath(path8);
4965
- if (!rootPath?.node || !t45.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
5447
+ if (!rootPath?.node || !t49.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4966
5448
  return;
4967
5449
  }
4968
5450
  const rootId = findRootIdentifier(node);
4969
- if (!t45.isIdentifier(node.object) || node.object.name !== rootId?.name) {
5451
+ if (!t49.isIdentifier(node.object) || node.object.name !== rootId?.name) {
4970
5452
  return;
4971
5453
  }
4972
5454
  node.property.name = "current";
4973
5455
  }
4974
5456
 
4975
5457
  // src/core/transform/sfc/script/syntax-processor/process/resolve-expression-memo.ts
4976
- import * as t46 from "@babel/types";
5458
+ import * as t50 from "@babel/types";
4977
5459
  function resolveExprMemo(ctx, ast) {
4978
5460
  const isScriptFile = ctx.inputType !== "sfc";
4979
5461
  return {
@@ -4985,11 +5467,11 @@ function resolveExprMemo(ctx, ast) {
4985
5467
  if (!atComponentOrHookRoot(path8, ast.program, isScriptFile)) {
4986
5468
  return false;
4987
5469
  }
4988
- if (!t46.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
5470
+ if (!t50.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
4989
5471
  return false;
4990
5472
  }
4991
- if (t46.isFunction(init)) return false;
4992
- if (t46.isCallExpression(init) && t46.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
5473
+ if (t50.isFunction(init)) return false;
5474
+ if (t50.isCallExpression(init) && t50.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
4993
5475
  return false;
4994
5476
  }
4995
5477
  return true;
@@ -5008,16 +5490,16 @@ function resolveExprMemo(ctx, ast) {
5008
5490
  }
5009
5491
 
5010
5492
  // src/core/transform/sfc/script/syntax-processor/process/resolve-lint-rules.ts
5011
- import * as t47 from "@babel/types";
5493
+ import * as t51 from "@babel/types";
5012
5494
  function resolveLintRules(ctx, ast) {
5013
5495
  const inScriptFile = ctx.inputType !== "sfc";
5014
5496
  return {
5015
5497
  CallExpression(path8) {
5016
5498
  const { node, parentPath } = path8;
5017
- if (!t47.isIdentifier(node.callee)) return;
5499
+ if (!t51.isIdentifier(node.callee)) return;
5018
5500
  const { name: callName } = node.callee;
5019
- const addLog = (t53) => {
5020
- logger.error(t53, {
5501
+ const addLog = (t56) => {
5502
+ logger.error(t56, {
5021
5503
  file: ctx.filename,
5022
5504
  source: ctx.scriptData.source,
5023
5505
  loc: node.loc
@@ -5062,7 +5544,7 @@ function resolveLintRules(ctx, ast) {
5062
5544
 
5063
5545
  // src/core/transform/sfc/script/syntax-processor/process/resolve-provide.ts
5064
5546
  import { generate as generate2 } from "@babel/generator";
5065
- import * as t48 from "@babel/types";
5547
+ import * as t52 from "@babel/types";
5066
5548
  function resolveProvide(ctx) {
5067
5549
  const { filename, scriptData, inputType } = ctx;
5068
5550
  if (inputType !== "sfc") {
@@ -5105,13 +5587,13 @@ function findOrCreateCtxProvider(root) {
5105
5587
  function assignProviderValue(target, key, value) {
5106
5588
  const getRawExp = (exp) => {
5107
5589
  if (!exp) return "''";
5108
- if (t48.isStringLiteral(exp)) {
5590
+ if (t52.isStringLiteral(exp)) {
5109
5591
  return JSON.stringify(exp.value);
5110
5592
  }
5111
- if (t48.isNumericLiteral(exp)) {
5593
+ if (t52.isNumericLiteral(exp)) {
5112
5594
  return exp.value.toString();
5113
5595
  }
5114
- if (t48.isIdentifier(exp)) {
5596
+ if (t52.isIdentifier(exp)) {
5115
5597
  return exp.name;
5116
5598
  }
5117
5599
  try {
@@ -5126,96 +5608,13 @@ function assignProviderValue(target, key, value) {
5126
5608
  target.provide = {};
5127
5609
  }
5128
5610
 
5129
- // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-adapter.ts
5130
- import * as t49 from "@babel/types";
5131
- function resolveRenameAdapter(ctx) {
5132
- return {
5133
- "CallExpression|Identifier"(path8) {
5134
- const node = path8.node;
5135
- const isCallNode = t49.isCallExpression(node);
5136
- let apiName = "";
5137
- if (t49.isIdentifier(node)) {
5138
- apiName = node.name;
5139
- } else if (isCallNode && t49.isIdentifier(node.callee)) {
5140
- apiName = node.callee.name;
5141
- }
5142
- if (!apiName) {
5143
- return;
5144
- }
5145
- const runtimeAdapter = ADAPTER_RULES.runtime[apiName];
5146
- const routerAdapter = ADAPTER_RULES.router[apiName];
5147
- const adapter = runtimeAdapter || routerAdapter;
5148
- if (!adapter || adapter.type !== "rename") {
5149
- return;
5150
- }
5151
- if (!isVueApiReference2(path8, apiName)) {
5152
- return;
5153
- }
5154
- if (adapter.isTrackable) {
5155
- const reactiveType = getReactiveType(apiName);
5156
- const declaratorPath = getVariableDeclaratorPath(path8);
5157
- setScriptNodeMeta(declaratorPath?.node, {
5158
- is_reactive: true,
5159
- reactive_type: reactiveType
5160
- });
5161
- }
5162
- if (isCallNode) {
5163
- replaceCallName(node, adapter.target);
5164
- } else {
5165
- replaceIdName(node, adapter.target);
5166
- }
5167
- if (adapter.package === PACKAGE_NAME.router && !ctx.route) {
5168
- ctx.route = true;
5169
- }
5170
- recordImport(ctx, adapter.package, adapter.target);
5171
- }
5172
- };
5173
- }
5174
- function isVueApiReference2(path8, apiName) {
5175
- const whitelist = [VUE_API_MAP.defineAsyncComponent];
5176
- if (whitelist.includes(apiName)) {
5177
- return true;
5178
- }
5179
- if (path8.isIdentifier()) {
5180
- if (path8.parentPath.isCallExpression() && path8.parentPath.node.callee === path8.node) {
5181
- return false;
5182
- }
5183
- if (!path8.isReferencedIdentifier()) {
5184
- return false;
5185
- }
5186
- }
5187
- if (path8.isCallExpression()) {
5188
- const callee = path8.get("callee");
5189
- if (!callee.isIdentifier()) return false;
5190
- return isVueImportBinding2(callee.scope.getBinding(apiName));
5191
- }
5192
- return isVueImportBinding2(path8.scope.getBinding(apiName));
5193
- }
5194
- function isVueImportBinding2(binding) {
5195
- if (!binding) return false;
5196
- const bindingPath = binding.path;
5197
- if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
5198
- return false;
5199
- }
5200
- const parent = bindingPath.parentPath?.node;
5201
- if (!parent || !t49.isImportDeclaration(parent)) {
5202
- return false;
5203
- }
5204
- const source = parent.source.value.toLowerCase();
5205
- if (source.startsWith("@vue/")) {
5206
- return true;
5207
- }
5208
- if (source === "vue-router" || source.startsWith("vue-router/")) {
5209
- return true;
5210
- }
5211
- return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
5212
- }
5213
-
5214
5611
  // src/core/transform/sfc/script/syntax-processor/index.ts
5215
5612
  function processVueSyntax2(ast, ctx) {
5216
5613
  vueSyntaxProcessor2(ast, ctx, {
5217
5614
  preprocess: {
5218
5615
  applyBabel: [
5616
+ // feature: https://github.com/vureact-js/core/issues/63
5617
+ resolveWithDefaultsOptions,
5219
5618
  resolvePropsIface,
5220
5619
  resolveEmitsTopLevelTypes,
5221
5620
  resolveDefineOptions,
@@ -5223,7 +5622,9 @@ function processVueSyntax2(ast, ctx) {
5223
5622
  resolveDefineAsyncComponent,
5224
5623
  resolveEmitCalls,
5225
5624
  // feature: https://github.com/vureact-js/core/issues/6
5226
- resolveUseAttrs
5625
+ resolveUseAttrs,
5626
+ // feature: https://github.com/vureact-js/core/issues/56
5627
+ resolveDefineModel
5227
5628
  ]
5228
5629
  },
5229
5630
  process: {
@@ -5242,6 +5643,8 @@ function processVueSyntax2(ast, ctx) {
5242
5643
  },
5243
5644
  postprocess: {
5244
5645
  applyBabel: [
5646
+ // feature: https://github.com/vureact-js/core/issues/63
5647
+ resolveWithDefaults,
5245
5648
  // 该 resolver 需确保放在所有类型处理之后,移除之前
5246
5649
  resolveVueTypeAsAny,
5247
5650
  resolveRuntimeImports,
@@ -5266,7 +5669,6 @@ function vueSyntaxProcessor2(ast, ctx, options) {
5266
5669
  }
5267
5670
 
5268
5671
  // src/core/transform/sfc/script/index.ts
5269
- var SCRIPT_IR_KEY = "__vureact_script_block_ir";
5270
5672
  function resolveScript2(ast, ctx) {
5271
5673
  const scriptIR = createScriptIR();
5272
5674
  setScriptIR(ctx, scriptIR);
@@ -5280,14 +5682,14 @@ function resolveScript2(ast, ctx) {
5280
5682
  return scriptIR;
5281
5683
  }
5282
5684
  function getScriptIR(ctx) {
5283
- const ir = ctx.scriptData[SCRIPT_IR_KEY];
5685
+ const ir = ctx.scriptData.__vureact_script_block_ir;
5284
5686
  if (!ir) {
5285
5687
  throw new Error("Script IR is not initialized for current compilation context");
5286
5688
  }
5287
5689
  return ir;
5288
5690
  }
5289
5691
  function setScriptIR(ctx, ir) {
5290
- ctx.scriptData[SCRIPT_IR_KEY] = ir;
5692
+ ctx.scriptData.__vureact_script_block_ir = ir;
5291
5693
  }
5292
5694
  function createScriptIR() {
5293
5695
  return {
@@ -5339,15 +5741,15 @@ function isRouterLinkBooleanCustomProp(prop) {
5339
5741
  }
5340
5742
 
5341
5743
  // src/core/transform/sfc/template/shared/prop-ir-utils.ts
5342
- import * as t51 from "@babel/types";
5744
+ import * as t54 from "@babel/types";
5343
5745
 
5344
5746
  // src/shared/string-code-types.ts
5345
5747
  import { parseExpression as parseExpression3 } from "@babel/parser";
5346
- import * as t50 from "@babel/types";
5748
+ import * as t53 from "@babel/types";
5347
5749
  var strCodeTypes = {
5348
- isIdentifier: isIdentifier29,
5750
+ isIdentifier: isIdentifier32,
5349
5751
  isSimpleExpression,
5350
- isStringLiteral: isStringLiteral13
5752
+ isStringLiteral: isStringLiteral15
5351
5753
  };
5352
5754
  function isSimpleExpression(code, excludeVar = false) {
5353
5755
  let node;
@@ -5356,38 +5758,38 @@ function isSimpleExpression(code, excludeVar = false) {
5356
5758
  } catch {
5357
5759
  return false;
5358
5760
  }
5359
- if (t50.isLiteral(node)) {
5761
+ if (t53.isLiteral(node)) {
5360
5762
  return true;
5361
5763
  }
5362
- if (!excludeVar && t50.isIdentifier(node)) {
5764
+ if (!excludeVar && t53.isIdentifier(node)) {
5363
5765
  return true;
5364
5766
  }
5365
- if (t50.isMemberExpression(node)) {
5366
- return isSimpleExpression(node.object) && t50.isIdentifier(node.property);
5767
+ if (t53.isMemberExpression(node)) {
5768
+ return isSimpleExpression(node.object) && t53.isIdentifier(node.property);
5367
5769
  }
5368
- if (t50.isObjectExpression(node) || t50.isArrayExpression(node)) {
5770
+ if (t53.isObjectExpression(node) || t53.isArrayExpression(node)) {
5369
5771
  return false;
5370
5772
  }
5371
- if (t50.isCallExpression(node) || t50.isAssignmentExpression(node)) {
5773
+ if (t53.isCallExpression(node) || t53.isAssignmentExpression(node)) {
5372
5774
  return false;
5373
5775
  }
5374
- if (t50.isBinaryExpression(node) || t50.isUnaryExpression(node)) {
5776
+ if (t53.isBinaryExpression(node) || t53.isUnaryExpression(node)) {
5375
5777
  return true;
5376
5778
  }
5377
5779
  return false;
5378
5780
  }
5379
- function isIdentifier29(code) {
5781
+ function isIdentifier32(code) {
5380
5782
  try {
5381
5783
  const node = parseExpression3(code);
5382
- return t50.isIdentifier(node);
5784
+ return t53.isIdentifier(node);
5383
5785
  } catch {
5384
5786
  return false;
5385
5787
  }
5386
5788
  }
5387
- function isStringLiteral13(code) {
5789
+ function isStringLiteral15(code) {
5388
5790
  try {
5389
5791
  const node = parseExpression3(code);
5390
- return t50.isStringLiteral(node);
5792
+ return t53.isStringLiteral(node);
5391
5793
  } catch {
5392
5794
  return false;
5393
5795
  }
@@ -5530,11 +5932,11 @@ function resolvePropAsBabelExp(ir, ctx) {
5530
5932
  const rule = ADAPTER_RULES.runtime;
5531
5933
  const setNameIdentifier = (target, valueName) => {
5532
5934
  target.content = valueName;
5533
- target.ast = t51.jsxIdentifier(valueName);
5935
+ target.ast = t54.jsxIdentifier(valueName);
5534
5936
  };
5535
- const setValueExpression = (target, content, isStringLiteral14) => {
5937
+ const setValueExpression = (target, content, isStringLiteral16) => {
5536
5938
  target.content = content;
5537
- target.ast = resolveStringExpr(content, ctx, isStringLiteral14);
5939
+ target.ast = resolveStringExpr(content, ctx, isStringLiteral16);
5538
5940
  };
5539
5941
  const createRuntimeCall = (fnName, args) => {
5540
5942
  const fnArgs = args.filter(Boolean).join(",");
@@ -5543,13 +5945,13 @@ function resolvePropAsBabelExp(ir, ctx) {
5543
5945
  const safeTypeAssertion = isTs ? valIsUndef ? "as never" : "" : "";
5544
5946
  return `${fnName}(${fnArgs}) ${safeTypeAssertion}`;
5545
5947
  };
5546
- const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral14) => {
5948
+ const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral16) => {
5547
5949
  if (setName && nameIdentifier) {
5548
5950
  setNameIdentifier(nameExp, nameIdentifier);
5549
5951
  }
5550
5952
  const dir = rule.dir;
5551
5953
  recordImport(ctx, dir.package, dir.target);
5552
- setValueExpression(value.babelExp, expression, isStringLiteral14);
5954
+ setValueExpression(value.babelExp, expression, isStringLiteral16);
5553
5955
  };
5554
5956
  if (ir.isKeyLessVBind) {
5555
5957
  const dirKeyless = rule.dirKeyless;
@@ -5970,12 +6372,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
5970
6372
  content = propsIR.value.content = parseStyleString(content);
5971
6373
  }
5972
6374
  if (isDynamic) {
5973
- const isStringLiteral14 = strCodeTypes.isStringLiteral(content);
5974
- if (isStringLiteral14) {
6375
+ const isStringLiteral16 = strCodeTypes.isStringLiteral(content);
6376
+ if (isStringLiteral16) {
5975
6377
  content = normalizeString(content);
5976
6378
  propsIR.value.content = content;
5977
6379
  }
5978
- propsIR.value.isStringLiteral = isStringLiteral14;
6380
+ propsIR.value.isStringLiteral = isStringLiteral16;
5979
6381
  }
5980
6382
  const existing = findSameProp(nodeIR.props, propsIR);
5981
6383
  if (existing) {
@@ -6280,7 +6682,7 @@ function applyValueModifiers(valueExp, modifiers) {
6280
6682
  }
6281
6683
 
6282
6684
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-on.ts
6283
- import * as t52 from "@babel/types";
6685
+ import * as t55 from "@babel/types";
6284
6686
  function resolveVOn(directive, ir, ctx, nodeIR) {
6285
6687
  const arg = directive.arg;
6286
6688
  const exp = directive.exp;
@@ -6338,10 +6740,10 @@ function resolveHandler(handlerContent, ctx, modifiers) {
6338
6740
  return handler;
6339
6741
  }
6340
6742
  function isConsoleCall(expr) {
6341
- return t52.isCallExpression(expr) && t52.isMemberExpression(expr.callee) && t52.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6743
+ return t55.isCallExpression(expr) && t55.isMemberExpression(expr.callee) && t55.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6342
6744
  }
6343
6745
  function isFnReference(expr) {
6344
- return t52.isIdentifier(expr) || t52.isMemberExpression(expr) || t52.isFunction(expr);
6746
+ return t55.isIdentifier(expr) || t55.isMemberExpression(expr) || t55.isFunction(expr);
6345
6747
  }
6346
6748
 
6347
6749
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
@@ -6694,7 +7096,7 @@ function transform(ast, ctx, options) {
6694
7096
  }
6695
7097
 
6696
7098
  // package.json
6697
- var version = "1.8.5";
7099
+ var version = "1.10.0";
6698
7100
  var bin = {
6699
7101
  vureact: "bin/vureact.js"
6700
7102
  };
@@ -7248,7 +7650,8 @@ var CompilationContext = class {
7248
7650
  refField: "expose"
7249
7651
  },
7250
7652
  declaredOptions: {},
7251
- source: ""
7653
+ source: "",
7654
+ __vureact_script_block_ir: void 0
7252
7655
  },
7253
7656
  styleData: {
7254
7657
  filePath: ""
@@ -8376,9 +8779,11 @@ var FileCompiler = class extends BaseCompiler {
8376
8779
  startTime = performance.now();
8377
8780
  this.updateSpinner("Scanning files...");
8378
8781
  const scanFiles = fileProcessor.scanFiles();
8379
- this.updateSpinner("Compiling Vue to React...");
8782
+ this.updateSpinner("Compiling components...");
8380
8783
  const sfcCount = await pipelineManager.runSFC(scanFiles.vue, cacheMap);
8784
+ this.updateSpinner("Compiling scripts...");
8381
8785
  const scriptCount = await pipelineManager.runScript(scanFiles.script, cacheMap);
8786
+ this.updateSpinner("Compiling styles...");
8382
8787
  const styleCount = await pipelineManager.runStyle(scanFiles.style, cacheMap);
8383
8788
  this.updateSpinner("Copying assets...");
8384
8789
  const assetCount = await assetManager.runAsset(scanFiles.assets, cacheMap);
@@ -8436,7 +8841,7 @@ var FileCompiler = class extends BaseCompiler {
8436
8841
  return await this.manager.cleanupManager.removeOutputPath(targetPath, type);
8437
8842
  }
8438
8843
  showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount) {
8439
- this.spinner.succeed(`Build completed in ${endTime}`);
8844
+ this.spinner.succeed(`Vue compiled to React in ${endTime}`);
8440
8845
  if (sfcCount || scriptCount || styleCount || assetCount) {
8441
8846
  const stats = [];
8442
8847
  if (sfcCount) stats.push(`${sfcCount} ${kleur8.dim("SFC(s)")}`);