@vureact/compiler-core 1.8.1 → 1.8.4

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.1
2
+ * @vureact/compiler-core v1.8.4
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -39,7 +39,7 @@ var RUNTIME_PACKAGES = {
39
39
  },
40
40
  runtime: {
41
41
  name: PACKAGE_NAME.runtime,
42
- version: "^1.1.0"
42
+ version: "^1.1.1"
43
43
  }
44
44
  };
45
45
  var STYLE_MODULE_NAME = "$style";
@@ -311,7 +311,8 @@ var ADAPTER_RULES = {
311
311
  type: "rename"
312
312
  },
313
313
  dirOn: {
314
- target: "dir.On",
314
+ // fix: https://github.com/vureact-js/core/issues/49
315
+ target: "dir.on",
315
316
  package: PACKAGE_NAME.runtime,
316
317
  type: "rename"
317
318
  },
@@ -568,7 +569,8 @@ function buildJsxChildrenProcessor(nodeIR, ctx, state) {
568
569
  }
569
570
  function buildJsxChildren(children, ctx) {
570
571
  const result = [];
571
- for (const childIR of children) {
572
+ const normalizedChildren = Array.isArray(children) ? children : [];
573
+ for (const childIR of normalizedChildren) {
572
574
  const jsxNode = buildJsxNode(childIR, ctx);
573
575
  if (!jsxNode) continue;
574
576
  result.push(jsxNode);
@@ -1314,9 +1316,6 @@ function resolveComponentName(ctx) {
1314
1316
  if (!name) {
1315
1317
  const defaultName = basename(filename).split(".")[0] || `FC${genHashByXXH(filename)}`;
1316
1318
  name = capitalize(camelCase(defaultName));
1317
- logger.warn(`Unnamed component detected. Using file name: <${name}>`, {
1318
- file: filename
1319
- });
1320
1319
  }
1321
1320
  scriptData.declaredOptions.name = name;
1322
1321
  return t13.identifier(name);
@@ -3223,8 +3222,51 @@ function resolveSfcCssImport(ctx) {
3223
3222
  scriptIR.imports.push(importDecl);
3224
3223
  }
3225
3224
 
3226
- // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
3225
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-vue-type-as-any.ts
3227
3226
  import * as t25 from "@babel/types";
3227
+ function resolveVueTypeAsAny(ctx) {
3228
+ return {
3229
+ TSTypeReference(path8) {
3230
+ if (isVueTypeRef(path8)) {
3231
+ replaceNode(path8, t25.tsAnyKeyword(), path8.node);
3232
+ }
3233
+ }
3234
+ };
3235
+ }
3236
+ function isVueTypeRef(path8) {
3237
+ const id = resolveTypeNameId(path8.node.typeName);
3238
+ return id !== null && isVueImport(id, path8);
3239
+ }
3240
+ function resolveTypeNameId(typeName) {
3241
+ if (t25.isIdentifier(typeName)) {
3242
+ return typeName;
3243
+ }
3244
+ if (t25.isTSQualifiedName(typeName)) {
3245
+ let node = typeName;
3246
+ while (t25.isTSQualifiedName(node)) {
3247
+ node = node.left;
3248
+ }
3249
+ return t25.isIdentifier(node) ? node : null;
3250
+ }
3251
+ return null;
3252
+ }
3253
+ function isVueImport(id, path8) {
3254
+ const binding = path8.scope.getBinding(id.name);
3255
+ if (!binding) return false;
3256
+ const bp = binding.path;
3257
+ if (!bp.isImportSpecifier() && !bp.isImportDefaultSpecifier()) {
3258
+ return false;
3259
+ }
3260
+ const importDecl = bp.parentPath;
3261
+ if (!importDecl.isImportDeclaration()) {
3262
+ return false;
3263
+ }
3264
+ const moduleName = importDecl.node.source.value;
3265
+ return VUE_PACKAGES.some((pkg) => moduleName.includes(pkg));
3266
+ }
3267
+
3268
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
3269
+ import * as t26 from "@babel/types";
3228
3270
  function resolveDefineAsyncComponent(ctx) {
3229
3271
  return {
3230
3272
  CallExpression(path8) {
@@ -3233,11 +3275,11 @@ function resolveDefineAsyncComponent(ctx) {
3233
3275
  return;
3234
3276
  }
3235
3277
  const [arg] = node.arguments;
3236
- if (!t25.isObjectExpression(arg)) {
3278
+ if (!t26.isObjectExpression(arg)) {
3237
3279
  return;
3238
3280
  }
3239
3281
  for (const prop of arg.properties) {
3240
- if (!t25.isObjectProperty(prop) || !t25.isIdentifier(prop.key) || prop.key.name !== "hydrate") {
3282
+ if (!t26.isObjectProperty(prop) || !t26.isIdentifier(prop.key) || prop.key.name !== "hydrate") {
3241
3283
  continue;
3242
3284
  }
3243
3285
  logger.warn('Unsupported option "hydrate"', {
@@ -3252,24 +3294,24 @@ function resolveDefineAsyncComponent(ctx) {
3252
3294
  }
3253
3295
 
3254
3296
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
3255
- import * as t27 from "@babel/types";
3297
+ import * as t28 from "@babel/types";
3256
3298
 
3257
3299
  // src/core/transform/sfc/script/shared/hook-creator.ts
3258
- import * as t26 from "@babel/types";
3300
+ import * as t27 from "@babel/types";
3259
3301
  function createUseCallback(body, deps) {
3260
- return t26.callExpression(t26.identifier(REACT_API_MAP.useCallback), [
3302
+ return t27.callExpression(t27.identifier(REACT_API_MAP.useCallback), [
3261
3303
  body,
3262
- deps ?? t26.arrayExpression([])
3304
+ deps ?? t27.arrayExpression([])
3263
3305
  ]);
3264
3306
  }
3265
3307
  function createUseMemo(body, deps) {
3266
- return t26.callExpression(t26.identifier(REACT_API_MAP.useMemo), [
3267
- t26.arrowFunctionExpression([], body),
3268
- deps ?? t26.arrayExpression([])
3308
+ return t27.callExpression(t27.identifier(REACT_API_MAP.useMemo), [
3309
+ t27.arrowFunctionExpression([], body),
3310
+ deps ?? t27.arrayExpression([])
3269
3311
  ]);
3270
3312
  }
3271
3313
  function createUseImperativeHandle(refId, init) {
3272
- return t26.callExpression(t26.identifier(REACT_API_MAP.useImperativeHandle), [refId, init]);
3314
+ return t27.callExpression(t27.identifier(REACT_API_MAP.useImperativeHandle), [refId, init]);
3273
3315
  }
3274
3316
 
3275
3317
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
@@ -3290,16 +3332,16 @@ function resolveDefineExpose(ctx) {
3290
3332
  const adapter = ADAPTER_RULES.react[MACRO_API_NAMES.expose];
3291
3333
  recordImport(ctx, adapter.package, REACT_API_MAP.forwardRef);
3292
3334
  recordImport(ctx, adapter.package, adapter.target);
3293
- if (!t27.isObjectExpression(expose) && !t27.isFunction(expose)) {
3335
+ if (!t28.isObjectExpression(expose) && !t28.isFunction(expose)) {
3294
3336
  logger.warn("Non-deterministic object literal may cause unknown risks.", {
3295
3337
  file: filename,
3296
3338
  loc: expose.loc,
3297
3339
  source: scriptData.source
3298
3340
  });
3299
3341
  }
3300
- const init = !t27.isFunction(expose) ? t27.arrowFunctionExpression([], expose) : expose;
3342
+ const init = !t28.isFunction(expose) ? t28.arrowFunctionExpression([], expose) : expose;
3301
3343
  const { forwardRef } = scriptData;
3302
- const newNode = createUseImperativeHandle(t27.identifier(forwardRef.refField), init);
3344
+ const newNode = createUseImperativeHandle(t28.identifier(forwardRef.refField), init);
3303
3345
  forwardRef.enabled = true;
3304
3346
  replaceNode(path8, newNode, node);
3305
3347
  }
@@ -3320,7 +3362,7 @@ function resolveDefineOptions(ctx) {
3320
3362
  }
3321
3363
 
3322
3364
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-emit-calls.ts
3323
- import * as t28 from "@babel/types";
3365
+ import * as t29 from "@babel/types";
3324
3366
  function resolveEmitCalls(ctx) {
3325
3367
  const formatEmitEventName = (raw) => {
3326
3368
  if (raw.startsWith("update:")) {
@@ -3334,7 +3376,7 @@ function resolveEmitCalls(ctx) {
3334
3376
  CallExpression(path8) {
3335
3377
  const { node } = path8;
3336
3378
  const { filename, templateData, scriptData } = ctx;
3337
- if (!t28.isIdentifier(node.callee)) return;
3379
+ if (!t29.isIdentifier(node.callee)) return;
3338
3380
  const { name } = node.callee;
3339
3381
  const checkIfFromDefineEmits = () => {
3340
3382
  let result = false;
@@ -3346,7 +3388,7 @@ function resolveEmitCalls(ctx) {
3346
3388
  const binding = path8.scope.getBinding(name);
3347
3389
  if (binding) {
3348
3390
  const parent = binding.path.node;
3349
- if (t28.isVariableDeclarator(parent) && t28.isCallExpression(parent.init) && t28.isIdentifier(parent.init.callee)) {
3391
+ if (t29.isVariableDeclarator(parent) && t29.isCallExpression(parent.init) && t29.isIdentifier(parent.init.callee)) {
3350
3392
  result = parent.init.callee.name === MACRO_API_NAMES.emits;
3351
3393
  }
3352
3394
  }
@@ -3356,9 +3398,9 @@ function resolveEmitCalls(ctx) {
3356
3398
  if (!checkIfFromDefineEmits()) return;
3357
3399
  const [callee, ...args] = node.arguments;
3358
3400
  let propCall;
3359
- if (t28.isStringLiteral(callee)) {
3401
+ if (t29.isStringLiteral(callee)) {
3360
3402
  const eventName = formatEmitEventName(callee.value);
3361
- propCall = createPropCall(ctx.propField, t28.identifier(eventName), args);
3403
+ propCall = createPropCall(ctx.propField, t29.identifier(eventName), args);
3362
3404
  } else {
3363
3405
  propCall = createPropCall(ctx.propField, callee, args, true);
3364
3406
  logger.error(
@@ -3375,38 +3417,38 @@ function resolveEmitCalls(ctx) {
3375
3417
  };
3376
3418
  }
3377
3419
  function createPropCall(rootName, callee, args, computed = false) {
3378
- return t28.optionalCallExpression(
3379
- t28.memberExpression(t28.identifier(rootName), callee, computed),
3420
+ return t29.optionalCallExpression(
3421
+ t29.memberExpression(t29.identifier(rootName), callee, computed),
3380
3422
  args,
3381
3423
  true
3382
3424
  );
3383
3425
  }
3384
3426
 
3385
3427
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/index.ts
3386
- import * as t36 from "@babel/types";
3428
+ import * as t37 from "@babel/types";
3387
3429
 
3388
3430
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-emits.ts
3389
- import * as t30 from "@babel/types";
3431
+ import * as t31 from "@babel/types";
3390
3432
 
3391
3433
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/shared.ts
3392
- import * as t29 from "@babel/types";
3434
+ import * as t30 from "@babel/types";
3393
3435
  function cloneCallableParams(params) {
3394
3436
  const cloneCallableParam = (param, index) => {
3395
- if (t29.isRestElement(param)) {
3437
+ if (t30.isRestElement(param)) {
3396
3438
  const arg = param.argument;
3397
- const name = t29.isIdentifier(arg) ? arg.name : `args${index}`;
3398
- const rest = t29.restElement(t29.identifier(name));
3399
- rest.typeAnnotation = param.typeAnnotation || (t29.isIdentifier(arg) ? arg.typeAnnotation : null) || t29.tsTypeAnnotation(t29.tsArrayType(t29.tsAnyKeyword()));
3439
+ const name = t30.isIdentifier(arg) ? arg.name : `args${index}`;
3440
+ const rest = t30.restElement(t30.identifier(name));
3441
+ rest.typeAnnotation = param.typeAnnotation || (t30.isIdentifier(arg) ? arg.typeAnnotation : null) || t30.tsTypeAnnotation(t30.tsArrayType(t30.tsAnyKeyword()));
3400
3442
  return rest;
3401
3443
  }
3402
- if (t29.isIdentifier(param)) {
3403
- const id = t29.identifier(param.name || `arg${index}`);
3444
+ if (t30.isIdentifier(param)) {
3445
+ const id = t30.identifier(param.name || `arg${index}`);
3404
3446
  id.optional = param.optional;
3405
- id.typeAnnotation = param.typeAnnotation || t29.tsTypeAnnotation(t29.tsAnyKeyword());
3447
+ id.typeAnnotation = param.typeAnnotation || t30.tsTypeAnnotation(t30.tsAnyKeyword());
3406
3448
  return id;
3407
3449
  }
3408
- const fallback = t29.identifier(`arg${index}`);
3409
- fallback.typeAnnotation = t29.tsTypeAnnotation(t29.tsAnyKeyword());
3450
+ const fallback = t30.identifier(`arg${index}`);
3451
+ fallback.typeAnnotation = t30.tsTypeAnnotation(t30.tsAnyKeyword());
3410
3452
  return fallback;
3411
3453
  };
3412
3454
  return params.map(cloneCallableParam);
@@ -3416,18 +3458,18 @@ function cloneCallableParams(params) {
3416
3458
  function resolveEmitsTopLevelTypes(ctx) {
3417
3459
  return {
3418
3460
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path8) {
3419
- if (!t30.isProgram(path8.parent)) return;
3461
+ if (!t31.isProgram(path8.parent)) return;
3420
3462
  const { node } = path8;
3421
- if (t30.isTSInterfaceDeclaration(node)) {
3422
- const typeLiteral = t30.tsTypeLiteral(node.body.body);
3463
+ if (t31.isTSInterfaceDeclaration(node)) {
3464
+ const typeLiteral = t31.tsTypeLiteral(node.body.body);
3423
3465
  if (!hasEmitsSignatureInType(typeLiteral)) return;
3424
3466
  const resolved = resolveTopLevelEmitType(typeLiteral);
3425
- if (resolved && t30.isTSTypeLiteral(resolved)) {
3467
+ if (resolved && t31.isTSTypeLiteral(resolved)) {
3426
3468
  node.body.body = resolved.members;
3427
3469
  }
3428
3470
  return;
3429
3471
  }
3430
- if (t30.isTSTypeAliasDeclaration(node)) {
3472
+ if (t31.isTSTypeAliasDeclaration(node)) {
3431
3473
  if (!hasEmitsSignatureInType(node.typeAnnotation)) return;
3432
3474
  const resolved = resolveTopLevelEmitType(node.typeAnnotation);
3433
3475
  if (resolved) {
@@ -3438,47 +3480,47 @@ function resolveEmitsTopLevelTypes(ctx) {
3438
3480
  };
3439
3481
  }
3440
3482
  function resolveTopLevelEmitType(tsType) {
3441
- if (t30.isTSParenthesizedType(tsType)) {
3483
+ if (t31.isTSParenthesizedType(tsType)) {
3442
3484
  return resolveTopLevelEmitType(tsType.typeAnnotation);
3443
3485
  }
3444
- if (t30.isTSTypeReference(tsType)) {
3486
+ if (t31.isTSTypeReference(tsType)) {
3445
3487
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3446
3488
  return tsType;
3447
3489
  }
3448
3490
  const params = tsType.typeParameters.params.map((param) => resolveTopLevelEmitType(param)).filter(Boolean);
3449
- return t30.tsTypeReference(
3491
+ return t31.tsTypeReference(
3450
3492
  tsType.typeName,
3451
- t30.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3493
+ t31.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3452
3494
  );
3453
3495
  }
3454
- if (t30.isTSIntersectionType(tsType)) {
3496
+ if (t31.isTSIntersectionType(tsType)) {
3455
3497
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
3456
3498
  if (!types.length) return null;
3457
3499
  if (types.length === 1) return types[0];
3458
- return t30.tsIntersectionType(types);
3500
+ return t31.tsIntersectionType(types);
3459
3501
  }
3460
- if (t30.isTSUnionType(tsType)) {
3502
+ if (t31.isTSUnionType(tsType)) {
3461
3503
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
3462
3504
  if (!types.length) return null;
3463
3505
  if (types.length === 1) return types[0];
3464
- return t30.tsUnionType(types);
3506
+ return t31.tsUnionType(types);
3465
3507
  }
3466
- if (t30.isTSTypeLiteral(tsType)) {
3508
+ if (t31.isTSTypeLiteral(tsType)) {
3467
3509
  const members = [];
3468
3510
  for (const member of tsType.members) {
3469
- if (t30.isTSCallSignatureDeclaration(member)) {
3511
+ if (t31.isTSCallSignatureDeclaration(member)) {
3470
3512
  members.push(...resolveEmitPropsFromCallSignature(member));
3471
3513
  continue;
3472
3514
  }
3473
3515
  members.push(member);
3474
3516
  }
3475
3517
  if (!members.length) return null;
3476
- return t30.tsTypeLiteral(members);
3518
+ return t31.tsTypeLiteral(members);
3477
3519
  }
3478
- if (t30.isTSFunctionType(tsType)) {
3520
+ if (t31.isTSFunctionType(tsType)) {
3479
3521
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
3480
3522
  if (!props.length) return null;
3481
- return t30.tsTypeLiteral(props);
3523
+ return t31.tsTypeLiteral(props);
3482
3524
  }
3483
3525
  return tsType;
3484
3526
  }
@@ -3499,41 +3541,41 @@ function processInferredTypes(ctx, runtimeArg) {
3499
3541
  propsTSIface: { emitTypes }
3500
3542
  } = ctx.scriptData;
3501
3543
  const members = [];
3502
- if (t30.isArrayExpression(runtimeArg)) {
3544
+ if (t31.isArrayExpression(runtimeArg)) {
3503
3545
  for (const element of runtimeArg.elements) {
3504
- if (!element || !t30.isStringLiteral(element)) continue;
3546
+ if (!element || !t31.isStringLiteral(element)) continue;
3505
3547
  const handlerName = resolveEmitHandlerName(element.value);
3506
3548
  const key = buildKey(handlerName);
3507
- const fnType = t30.tsFunctionType(
3549
+ const fnType = t31.tsFunctionType(
3508
3550
  null,
3509
3551
  [createRestAnyParam("args")],
3510
- t30.tsTypeAnnotation(t30.tsAnyKeyword())
3552
+ t31.tsTypeAnnotation(t31.tsAnyKeyword())
3511
3553
  );
3512
- const prop = t30.tsPropertySignature(key, t30.tsTypeAnnotation(fnType));
3554
+ const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
3513
3555
  prop.optional = true;
3514
3556
  members.push(prop);
3515
3557
  }
3516
3558
  if (members.length) {
3517
- emitTypes.push(t30.tsTypeLiteral(members));
3559
+ emitTypes.push(t31.tsTypeLiteral(members));
3518
3560
  }
3519
3561
  return;
3520
3562
  }
3521
- if (t30.isObjectExpression(runtimeArg)) {
3563
+ if (t31.isObjectExpression(runtimeArg)) {
3522
3564
  for (const prop of runtimeArg.properties) {
3523
- if (!t30.isObjectProperty(prop)) continue;
3524
- if (t30.isSpreadElement(prop)) continue;
3565
+ if (!t31.isObjectProperty(prop)) continue;
3566
+ if (t31.isSpreadElement(prop)) continue;
3525
3567
  const rawName = resolvePropName(prop.key);
3526
3568
  if (!rawName) continue;
3527
3569
  const handlerName = resolveEmitHandlerName(rawName);
3528
3570
  const key = buildKey(handlerName);
3529
- const params = t30.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
3530
- const fnType = t30.tsFunctionType(null, params, t30.tsTypeAnnotation(t30.tsAnyKeyword()));
3531
- const propSig = t30.tsPropertySignature(key, t30.tsTypeAnnotation(fnType));
3571
+ const params = t31.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
3572
+ const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(t31.tsAnyKeyword()));
3573
+ const propSig = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
3532
3574
  propSig.optional = true;
3533
3575
  members.push(propSig);
3534
3576
  }
3535
3577
  if (members.length) {
3536
- emitTypes.push(t30.tsTypeLiteral(members));
3578
+ emitTypes.push(t31.tsTypeLiteral(members));
3537
3579
  }
3538
3580
  }
3539
3581
  }
@@ -3554,129 +3596,129 @@ function resolveEmitHandlerName(rawName) {
3554
3596
  return `on${name}`;
3555
3597
  }
3556
3598
  function resolvePropName(key) {
3557
- if (t30.isIdentifier(key)) return key.name;
3558
- if (t30.isStringLiteral(key)) return key.value;
3559
- if (t30.isNumericLiteral(key)) return String(key.value);
3599
+ if (t31.isIdentifier(key)) return key.name;
3600
+ if (t31.isStringLiteral(key)) return key.value;
3601
+ if (t31.isNumericLiteral(key)) return String(key.value);
3560
3602
  return null;
3561
3603
  }
3562
3604
  function buildKey(name) {
3563
- return t30.isValidIdentifier(name) ? t30.identifier(name) : t30.stringLiteral(name);
3605
+ return t31.isValidIdentifier(name) ? t31.identifier(name) : t31.stringLiteral(name);
3564
3606
  }
3565
3607
  function createRestAnyParam(name) {
3566
- const id = t30.identifier(name);
3567
- const rest = t30.restElement(id);
3568
- rest.typeAnnotation = t30.tsTypeAnnotation(t30.tsArrayType(t30.tsAnyKeyword()));
3608
+ const id = t31.identifier(name);
3609
+ const rest = t31.restElement(id);
3610
+ rest.typeAnnotation = t31.tsTypeAnnotation(t31.tsArrayType(t31.tsAnyKeyword()));
3569
3611
  return rest;
3570
3612
  }
3571
3613
  function resolveRuntimeTupleParams(value) {
3572
3614
  const params = [];
3573
3615
  value.elements.forEach((element, index) => {
3574
3616
  if (!element) return;
3575
- if (t30.isSpreadElement(element)) {
3617
+ if (t31.isSpreadElement(element)) {
3576
3618
  params.push(createRestAnyParam(`args${index}`));
3577
3619
  return;
3578
3620
  }
3579
- if (t30.isIdentifier(element)) {
3580
- const id = t30.identifier(element.name);
3581
- id.typeAnnotation = element.typeAnnotation || t30.tsTypeAnnotation(t30.tsAnyKeyword());
3621
+ if (t31.isIdentifier(element)) {
3622
+ const id = t31.identifier(element.name);
3623
+ id.typeAnnotation = element.typeAnnotation || t31.tsTypeAnnotation(t31.tsAnyKeyword());
3582
3624
  params.push(id);
3583
3625
  return;
3584
3626
  }
3585
- if (t30.isTSAsExpression(element)) {
3586
- const id = t30.identifier(`arg${index}`);
3587
- id.typeAnnotation = t30.tsTypeAnnotation(element.typeAnnotation);
3627
+ if (t31.isTSAsExpression(element)) {
3628
+ const id = t31.identifier(`arg${index}`);
3629
+ id.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
3588
3630
  params.push(id);
3589
3631
  return;
3590
3632
  }
3591
- const fallback = t30.identifier(`arg${index}`);
3592
- fallback.typeAnnotation = t30.tsTypeAnnotation(t30.tsAnyKeyword());
3633
+ const fallback = t31.identifier(`arg${index}`);
3634
+ fallback.typeAnnotation = t31.tsTypeAnnotation(t31.tsAnyKeyword());
3593
3635
  params.push(fallback);
3594
3636
  });
3595
3637
  return params;
3596
3638
  }
3597
3639
  function resolveExplicitEmitType(tsType) {
3598
- if (t30.isTSParenthesizedType(tsType)) {
3640
+ if (t31.isTSParenthesizedType(tsType)) {
3599
3641
  return resolveExplicitEmitType(tsType.typeAnnotation);
3600
3642
  }
3601
- if (t30.isTSTypeReference(tsType)) {
3643
+ if (t31.isTSTypeReference(tsType)) {
3602
3644
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3603
3645
  return tsType;
3604
3646
  }
3605
3647
  const params = tsType.typeParameters.params.map((param) => resolveExplicitEmitType(param)).filter(Boolean);
3606
- return t30.tsTypeReference(
3648
+ return t31.tsTypeReference(
3607
3649
  tsType.typeName,
3608
- t30.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3650
+ t31.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3609
3651
  );
3610
3652
  }
3611
- if (t30.isTSIntersectionType(tsType)) {
3653
+ if (t31.isTSIntersectionType(tsType)) {
3612
3654
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
3613
3655
  if (!types.length) return null;
3614
3656
  if (types.length === 1) return types[0];
3615
- return t30.tsIntersectionType(types);
3657
+ return t31.tsIntersectionType(types);
3616
3658
  }
3617
- if (t30.isTSUnionType(tsType)) {
3659
+ if (t31.isTSUnionType(tsType)) {
3618
3660
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
3619
3661
  if (!types.length) return null;
3620
3662
  if (types.length === 1) return types[0];
3621
- return t30.tsUnionType(types);
3663
+ return t31.tsUnionType(types);
3622
3664
  }
3623
- if (t30.isTSTypeLiteral(tsType)) {
3665
+ if (t31.isTSTypeLiteral(tsType)) {
3624
3666
  const members = [];
3625
3667
  for (const member of tsType.members) {
3626
- if (t30.isTSPropertySignature(member)) {
3668
+ if (t31.isTSPropertySignature(member)) {
3627
3669
  const prop = resolveEmitPropFromPropertySignature(member);
3628
3670
  if (prop) members.push(prop);
3629
3671
  continue;
3630
3672
  }
3631
- if (t30.isTSCallSignatureDeclaration(member)) {
3673
+ if (t31.isTSCallSignatureDeclaration(member)) {
3632
3674
  members.push(...resolveEmitPropsFromCallSignature(member));
3633
3675
  continue;
3634
3676
  }
3635
3677
  }
3636
3678
  if (!members.length) return null;
3637
- return t30.tsTypeLiteral(members);
3679
+ return t31.tsTypeLiteral(members);
3638
3680
  }
3639
- if (t30.isTSFunctionType(tsType)) {
3681
+ if (t31.isTSFunctionType(tsType)) {
3640
3682
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
3641
3683
  if (!props.length) return null;
3642
- return t30.tsTypeLiteral(props);
3684
+ return t31.tsTypeLiteral(props);
3643
3685
  }
3644
3686
  return tsType;
3645
3687
  }
3646
3688
  function hasEmitsSignatureInType(tsType) {
3647
- if (t30.isTSParenthesizedType(tsType)) {
3689
+ if (t31.isTSParenthesizedType(tsType)) {
3648
3690
  return hasEmitsSignatureInType(tsType.typeAnnotation);
3649
3691
  }
3650
- if (t30.isTSTypeReference(tsType)) {
3692
+ if (t31.isTSTypeReference(tsType)) {
3651
3693
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3652
3694
  return false;
3653
3695
  }
3654
3696
  return tsType.typeParameters.params.some(hasEmitsSignatureInType);
3655
3697
  }
3656
- if (t30.isTSIntersectionType(tsType) || t30.isTSUnionType(tsType)) {
3698
+ if (t31.isTSIntersectionType(tsType) || t31.isTSUnionType(tsType)) {
3657
3699
  return tsType.types.some(hasEmitsSignatureInType);
3658
3700
  }
3659
- if (t30.isTSTypeLiteral(tsType)) {
3701
+ if (t31.isTSTypeLiteral(tsType)) {
3660
3702
  return tsType.members.some(hasEmitsSignatureInMember);
3661
3703
  }
3662
- if (t30.isTSFunctionType(tsType)) {
3704
+ if (t31.isTSFunctionType(tsType)) {
3663
3705
  return isEmitsCallable(tsType.parameters);
3664
3706
  }
3665
3707
  return false;
3666
3708
  }
3667
3709
  function hasEmitsSignatureInMember(member) {
3668
- if (t30.isTSCallSignatureDeclaration(member)) {
3710
+ if (t31.isTSCallSignatureDeclaration(member)) {
3669
3711
  return isEmitsCallable(member.parameters);
3670
3712
  }
3671
3713
  return false;
3672
3714
  }
3673
3715
  function isEmitsCallable(parameters) {
3674
3716
  const [eventParam] = parameters;
3675
- if (!eventParam || !t30.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3717
+ if (!eventParam || !t31.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3676
3718
  return false;
3677
3719
  }
3678
3720
  const { typeAnnotation } = eventParam;
3679
- if (t30.isNoop(typeAnnotation)) return false;
3721
+ if (t31.isNoop(typeAnnotation)) return false;
3680
3722
  return resolveEventNames(typeAnnotation.typeAnnotation).length > 0;
3681
3723
  }
3682
3724
  function resolveEmitPropFromPropertySignature(member) {
@@ -3686,19 +3728,19 @@ function resolveEmitPropFromPropertySignature(member) {
3686
3728
  const key = buildKey(handlerName);
3687
3729
  const typeAnnotation = member.typeAnnotation?.typeAnnotation;
3688
3730
  let params = [];
3689
- let returnType = t30.tsAnyKeyword();
3690
- if (typeAnnotation && t30.isTSFunctionType(typeAnnotation)) {
3731
+ let returnType = t31.tsAnyKeyword();
3732
+ if (typeAnnotation && t31.isTSFunctionType(typeAnnotation)) {
3691
3733
  params = cloneCallableParams(typeAnnotation.parameters);
3692
3734
  returnType = typeAnnotation.typeAnnotation?.typeAnnotation ?? returnType;
3693
- } else if (typeAnnotation && t30.isTSTupleType(typeAnnotation)) {
3735
+ } else if (typeAnnotation && t31.isTSTupleType(typeAnnotation)) {
3694
3736
  params = resolveTupleTypeParams(typeAnnotation);
3695
3737
  } else if (typeAnnotation) {
3696
- const id = t30.identifier("value");
3697
- id.typeAnnotation = t30.tsTypeAnnotation(typeAnnotation);
3738
+ const id = t31.identifier("value");
3739
+ id.typeAnnotation = t31.tsTypeAnnotation(typeAnnotation);
3698
3740
  params = [id];
3699
3741
  }
3700
- const fnType = t30.tsFunctionType(null, params, t30.tsTypeAnnotation(returnType));
3701
- const prop = t30.tsPropertySignature(key, t30.tsTypeAnnotation(fnType));
3742
+ const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(returnType));
3743
+ const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
3702
3744
  prop.optional = !!member.optional;
3703
3745
  return prop;
3704
3746
  }
@@ -3707,32 +3749,32 @@ function resolveEmitPropsFromCallSignature(member) {
3707
3749
  }
3708
3750
  function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
3709
3751
  const [eventParam, ...restParams] = parameters;
3710
- if (!eventParam || !t30.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3752
+ if (!eventParam || !t31.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3711
3753
  return [];
3712
3754
  }
3713
3755
  const { typeAnnotation: paramTypeAnnotation } = eventParam;
3714
- if (t30.isNoop(paramTypeAnnotation)) return [];
3756
+ if (t31.isNoop(paramTypeAnnotation)) return [];
3715
3757
  const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
3716
3758
  if (!eventNames.length) return [];
3717
- const returnType = typeAnnotation?.typeAnnotation ?? t30.tsAnyKeyword();
3759
+ const returnType = typeAnnotation?.typeAnnotation ?? t31.tsAnyKeyword();
3718
3760
  return eventNames.map((eventName) => {
3719
3761
  const handlerName = resolveEmitHandlerName(eventName);
3720
3762
  const key = buildKey(handlerName);
3721
3763
  const params = cloneCallableParams(restParams);
3722
- const fnType = t30.tsFunctionType(null, params, t30.tsTypeAnnotation(returnType));
3723
- const prop = t30.tsPropertySignature(key, t30.tsTypeAnnotation(fnType));
3764
+ const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(returnType));
3765
+ const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
3724
3766
  prop.optional = true;
3725
3767
  return prop;
3726
3768
  });
3727
3769
  }
3728
3770
  function resolveEventNames(type) {
3729
- if (t30.isTSLiteralType(type) && t30.isStringLiteral(type.literal)) {
3771
+ if (t31.isTSLiteralType(type) && t31.isStringLiteral(type.literal)) {
3730
3772
  return [type.literal.value];
3731
3773
  }
3732
- if (t30.isTSUnionType(type)) {
3774
+ if (t31.isTSUnionType(type)) {
3733
3775
  return type.types.flatMap(resolveEventNames);
3734
3776
  }
3735
- if (t30.isTSParenthesizedType(type)) {
3777
+ if (t31.isTSParenthesizedType(type)) {
3736
3778
  return resolveEventNames(type.typeAnnotation);
3737
3779
  }
3738
3780
  return [];
@@ -3745,44 +3787,44 @@ function resolveTupleTypeParams(tuple) {
3745
3787
  return params;
3746
3788
  }
3747
3789
  function resolveTupleElementParam(element, index) {
3748
- const isNamedTuple = typeof t30.isTSNamedTupleMember === "function" && t30.isTSNamedTupleMember(element);
3790
+ const isNamedTuple = typeof t31.isTSNamedTupleMember === "function" && t31.isTSNamedTupleMember(element);
3749
3791
  if (isNamedTuple) {
3750
3792
  const tupleMember = element;
3751
3793
  const name = tupleMember.label?.name || `arg${index}`;
3752
3794
  let innerType = tupleMember.elementType;
3753
3795
  let optional = tupleMember.optional;
3754
- if (t30.isTSOptionalType(innerType)) {
3796
+ if (t31.isTSOptionalType(innerType)) {
3755
3797
  optional = true;
3756
3798
  innerType = innerType.typeAnnotation;
3757
3799
  }
3758
- if (t30.isTSRestType(innerType)) {
3759
- const rest = t30.restElement(t30.identifier(name));
3760
- rest.typeAnnotation = t30.tsTypeAnnotation(innerType.typeAnnotation);
3800
+ if (t31.isTSRestType(innerType)) {
3801
+ const rest = t31.restElement(t31.identifier(name));
3802
+ rest.typeAnnotation = t31.tsTypeAnnotation(innerType.typeAnnotation);
3761
3803
  return rest;
3762
3804
  }
3763
- const id2 = t30.identifier(name);
3805
+ const id2 = t31.identifier(name);
3764
3806
  id2.optional = optional;
3765
- id2.typeAnnotation = t30.tsTypeAnnotation(innerType);
3807
+ id2.typeAnnotation = t31.tsTypeAnnotation(innerType);
3766
3808
  return id2;
3767
3809
  }
3768
- if (t30.isTSRestType(element)) {
3769
- const rest = t30.restElement(t30.identifier(`args${index}`));
3770
- rest.typeAnnotation = t30.tsTypeAnnotation(element.typeAnnotation);
3810
+ if (t31.isTSRestType(element)) {
3811
+ const rest = t31.restElement(t31.identifier(`args${index}`));
3812
+ rest.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
3771
3813
  return rest;
3772
3814
  }
3773
- if (t30.isTSOptionalType(element)) {
3774
- const id2 = t30.identifier(`arg${index}`);
3815
+ if (t31.isTSOptionalType(element)) {
3816
+ const id2 = t31.identifier(`arg${index}`);
3775
3817
  id2.optional = true;
3776
- id2.typeAnnotation = t30.tsTypeAnnotation(element.typeAnnotation);
3818
+ id2.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
3777
3819
  return id2;
3778
3820
  }
3779
- const id = t30.identifier(`arg${index}`);
3780
- id.typeAnnotation = t30.tsTypeAnnotation(element);
3821
+ const id = t31.identifier(`arg${index}`);
3822
+ id.typeAnnotation = t31.tsTypeAnnotation(element);
3781
3823
  return id;
3782
3824
  }
3783
3825
 
3784
3826
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-props.ts
3785
- import * as t31 from "@babel/types";
3827
+ import * as t32 from "@babel/types";
3786
3828
  function resolveDefinePropsIface(path8, ctx) {
3787
3829
  const { node } = path8;
3788
3830
  const [runtimeArg] = node.arguments;
@@ -3802,38 +3844,38 @@ function processInferredTypes2(ctx, runtimeArg) {
3802
3844
  } = scriptData;
3803
3845
  if (!runtimeArg) return;
3804
3846
  const members = [];
3805
- if (t31.isArrayExpression(runtimeArg)) {
3847
+ if (t32.isArrayExpression(runtimeArg)) {
3806
3848
  for (const element of runtimeArg.elements) {
3807
- if (!element || !t31.isStringLiteral(element)) continue;
3808
- const key = t31.isValidIdentifier(element.value) ? t31.identifier(element.value) : t31.stringLiteral(element.value);
3809
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(t31.tsAnyKeyword()));
3849
+ if (!element || !t32.isStringLiteral(element)) continue;
3850
+ const key = t32.isValidIdentifier(element.value) ? t32.identifier(element.value) : t32.stringLiteral(element.value);
3851
+ const prop = t32.tsPropertySignature(key, t32.tsTypeAnnotation(t32.tsAnyKeyword()));
3810
3852
  prop.optional = true;
3811
3853
  members.push(prop);
3812
3854
  }
3813
3855
  if (members.length) {
3814
- propsTypes.push(t31.tsTypeLiteral(members));
3856
+ propsTypes.push(t32.tsTypeLiteral(members));
3815
3857
  }
3816
3858
  return;
3817
3859
  }
3818
- if (t31.isObjectExpression(runtimeArg)) {
3860
+ if (t32.isObjectExpression(runtimeArg)) {
3819
3861
  for (const prop of runtimeArg.properties) {
3820
- if (!t31.isObjectProperty(prop)) continue;
3821
- if (t31.isSpreadElement(prop)) continue;
3862
+ if (!t32.isObjectProperty(prop)) continue;
3863
+ if (t32.isSpreadElement(prop)) continue;
3822
3864
  const key = prop.key;
3823
3865
  let propName = null;
3824
- if (t31.isIdentifier(key)) propName = key.name;
3825
- if (t31.isStringLiteral(key)) propName = key.value;
3826
- if (t31.isNumericLiteral(key)) propName = String(key.value);
3866
+ if (t32.isIdentifier(key)) propName = key.name;
3867
+ if (t32.isStringLiteral(key)) propName = key.value;
3868
+ if (t32.isNumericLiteral(key)) propName = String(key.value);
3827
3869
  if (!propName) continue;
3828
3870
  const { type, required } = resolveRuntimePropMeta(prop.value);
3829
- const tsType = type ?? t31.tsAnyKeyword();
3830
- const tsKey = t31.isValidIdentifier(propName) ? t31.identifier(propName) : t31.stringLiteral(propName);
3831
- const tsProp = t31.tsPropertySignature(tsKey, t31.tsTypeAnnotation(tsType));
3871
+ const tsType = type ?? t32.tsAnyKeyword();
3872
+ const tsKey = t32.isValidIdentifier(propName) ? t32.identifier(propName) : t32.stringLiteral(propName);
3873
+ const tsProp = t32.tsPropertySignature(tsKey, t32.tsTypeAnnotation(tsType));
3832
3874
  tsProp.optional = !required;
3833
3875
  members.push(tsProp);
3834
3876
  }
3835
3877
  if (members.length) {
3836
- propsTypes.push(t31.tsTypeLiteral(members));
3878
+ propsTypes.push(t32.tsTypeLiteral(members));
3837
3879
  }
3838
3880
  return;
3839
3881
  }
@@ -3847,42 +3889,42 @@ function processInferredTypes2(ctx, runtimeArg) {
3847
3889
  );
3848
3890
  }
3849
3891
  function resolveRuntimePropMeta(value) {
3850
- if (t31.isIdentifier(value)) {
3892
+ if (t32.isIdentifier(value)) {
3851
3893
  return {
3852
3894
  type: mapRuntimeTypeToTSType(value),
3853
3895
  required: false
3854
3896
  };
3855
3897
  }
3856
- if (t31.isArrayExpression(value)) {
3898
+ if (t32.isArrayExpression(value)) {
3857
3899
  return {
3858
3900
  type: resolveRuntimeUnionType(value),
3859
3901
  required: false
3860
3902
  };
3861
3903
  }
3862
- if (!t31.isObjectExpression(value)) {
3904
+ if (!t32.isObjectExpression(value)) {
3863
3905
  return { required: false };
3864
3906
  }
3865
3907
  let type;
3866
3908
  let required = false;
3867
3909
  for (const prop of value.properties) {
3868
- if (!t31.isObjectProperty(prop)) continue;
3869
- if (t31.isSpreadElement(prop)) continue;
3910
+ if (!t32.isObjectProperty(prop)) continue;
3911
+ if (t32.isSpreadElement(prop)) continue;
3870
3912
  const key = prop.key;
3871
- const propName = t31.isIdentifier(key) ? key.name : t31.isStringLiteral(key) ? key.value : null;
3913
+ const propName = t32.isIdentifier(key) ? key.name : t32.isStringLiteral(key) ? key.value : null;
3872
3914
  if (!propName) continue;
3873
3915
  if (propName === "type") {
3874
3916
  const valueNode = prop.value;
3875
- if (t31.isArrayExpression(valueNode)) {
3917
+ if (t32.isArrayExpression(valueNode)) {
3876
3918
  type = resolveRuntimeUnionType(valueNode);
3877
3919
  continue;
3878
3920
  }
3879
- if (t31.isIdentifier(valueNode)) {
3921
+ if (t32.isIdentifier(valueNode)) {
3880
3922
  type = mapRuntimeTypeToTSType(valueNode);
3881
3923
  continue;
3882
3924
  }
3883
3925
  }
3884
3926
  if (propName === "required") {
3885
- if (t31.isBooleanLiteral(prop.value)) {
3927
+ if (t32.isBooleanLiteral(prop.value)) {
3886
3928
  required = prop.value.value;
3887
3929
  }
3888
3930
  }
@@ -3892,80 +3934,80 @@ function resolveRuntimePropMeta(value) {
3892
3934
  function resolveRuntimeUnionType(value) {
3893
3935
  const types = [];
3894
3936
  for (const element of value.elements) {
3895
- if (!element || !t31.isIdentifier(element)) continue;
3937
+ if (!element || !t32.isIdentifier(element)) continue;
3896
3938
  const resolved = mapRuntimeTypeToTSType(element);
3897
3939
  if (resolved) types.push(resolved);
3898
3940
  }
3899
- if (!types.length) return t31.tsAnyKeyword();
3941
+ if (!types.length) return t32.tsAnyKeyword();
3900
3942
  if (types.length === 1) return types[0];
3901
- return t31.tsUnionType(types);
3943
+ return t32.tsUnionType(types);
3902
3944
  }
3903
3945
  function mapRuntimeTypeToTSType(value) {
3904
3946
  switch (value.name) {
3905
3947
  case "String":
3906
- return t31.tsStringKeyword();
3948
+ return t32.tsStringKeyword();
3907
3949
  case "Number":
3908
- return t31.tsNumberKeyword();
3950
+ return t32.tsNumberKeyword();
3909
3951
  case "Boolean":
3910
- return t31.tsBooleanKeyword();
3952
+ return t32.tsBooleanKeyword();
3911
3953
  case "Object":
3912
- return t31.tsTypeLiteral([]);
3954
+ return t32.tsTypeLiteral([]);
3913
3955
  case "Array":
3914
- return t31.tsArrayType(t31.tsAnyKeyword());
3956
+ return t32.tsArrayType(t32.tsAnyKeyword());
3915
3957
  case "Function":
3916
- return t31.tsFunctionType(null, [], t31.tsTypeAnnotation(t31.tsAnyKeyword()));
3958
+ return t32.tsFunctionType(null, [], t32.tsTypeAnnotation(t32.tsAnyKeyword()));
3917
3959
  case "Symbol":
3918
- return t31.tsSymbolKeyword();
3960
+ return t32.tsSymbolKeyword();
3919
3961
  case "BigInt":
3920
- return t31.tsBigIntKeyword();
3962
+ return t32.tsBigIntKeyword();
3921
3963
  default:
3922
- return t31.tsAnyKeyword();
3964
+ return t32.tsAnyKeyword();
3923
3965
  }
3924
3966
  }
3925
3967
 
3926
3968
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/type-resolver.ts
3927
- import * as t34 from "@babel/types";
3969
+ import * as t35 from "@babel/types";
3928
3970
 
3929
3971
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/slot-builder.ts
3930
- import * as t32 from "@babel/types";
3972
+ import * as t33 from "@babel/types";
3931
3973
  var SLOT_DEFAULT_NAME = "default";
3932
3974
  var SLOT_CHILDREN_NAME = "children";
3933
3975
  var SLOT_FN_PARAM_NAME = "props";
3934
3976
  function buildSlotPropSignature(rawName, params, optional) {
3935
3977
  const propName = rawName === SLOT_DEFAULT_NAME ? SLOT_CHILDREN_NAME : rawName;
3936
- const key = t32.isValidIdentifier(propName) ? t32.identifier(propName) : t32.stringLiteral(propName);
3937
- const reactNodeType = t32.tsTypeAnnotation(
3938
- t32.tsTypeReference(t32.identifier(REACT_API_MAP.ReactNode))
3978
+ const key = t33.isValidIdentifier(propName) ? t33.identifier(propName) : t33.stringLiteral(propName);
3979
+ const reactNodeType = t33.tsTypeAnnotation(
3980
+ t33.tsTypeReference(t33.identifier(REACT_API_MAP.ReactNode))
3939
3981
  );
3940
3982
  let typeAnnotation;
3941
3983
  if (rawName === SLOT_DEFAULT_NAME && params.length === 0 || params.length === 0) {
3942
3984
  typeAnnotation = reactNodeType;
3943
3985
  } else {
3944
- const fnType = t32.tsFunctionType(null, params, reactNodeType);
3945
- typeAnnotation = t32.tsTypeAnnotation(fnType);
3986
+ const fnType = t33.tsFunctionType(null, params, reactNodeType);
3987
+ typeAnnotation = t33.tsTypeAnnotation(fnType);
3946
3988
  }
3947
- const prop = t32.tsPropertySignature(key, typeAnnotation);
3989
+ const prop = t33.tsPropertySignature(key, typeAnnotation);
3948
3990
  prop.optional = optional;
3949
3991
  return prop;
3950
3992
  }
3951
3993
  function createSlotScopeParam(props, ctx) {
3952
- const paramId = t32.identifier(SLOT_FN_PARAM_NAME);
3994
+ const paramId = t33.identifier(SLOT_FN_PARAM_NAME);
3953
3995
  const propsSigns = [];
3954
3996
  const { reactiveBindings } = ctx.templateData;
3955
3997
  props.forEach(({ prop, tsType }) => {
3956
3998
  const foundBindingValue = reactiveBindings[prop]?.value;
3957
3999
  const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
3958
- const typeAnnotation = foundBindingTypes ? t32.tsTypeAnnotation(foundBindingTypes) : tsType;
3959
- const key = t32.isValidIdentifier(prop) ? t32.identifier(prop) : t32.stringLiteral(prop);
3960
- const propSign = t32.tsPropertySignature(key, typeAnnotation);
4000
+ const typeAnnotation = foundBindingTypes ? t33.tsTypeAnnotation(foundBindingTypes) : tsType;
4001
+ const key = t33.isValidIdentifier(prop) ? t33.identifier(prop) : t33.stringLiteral(prop);
4002
+ const propSign = t33.tsPropertySignature(key, typeAnnotation);
3961
4003
  propsSigns.push(propSign);
3962
4004
  });
3963
- paramId.typeAnnotation = t32.tsTypeAnnotation(t32.tsTypeLiteral(propsSigns));
4005
+ paramId.typeAnnotation = t33.tsTypeAnnotation(t33.tsTypeLiteral(propsSigns));
3964
4006
  return paramId;
3965
4007
  }
3966
4008
 
3967
4009
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/utils.ts
3968
- import * as t33 from "@babel/types";
4010
+ import * as t34 from "@babel/types";
3969
4011
  function recordReactNode(ctx) {
3970
4012
  if (!ctx.scriptData.lang.startsWith("ts")) {
3971
4013
  return;
@@ -3981,16 +4023,16 @@ function collectLocalTypeDeclarations(path8) {
3981
4023
  return declarations;
3982
4024
  }
3983
4025
  for (const statement of programPath.node.body) {
3984
- if (t33.isTSInterfaceDeclaration(statement)) {
4026
+ if (t34.isTSInterfaceDeclaration(statement)) {
3985
4027
  declarations.set(statement.id.name, {
3986
- type: t33.tsTypeLiteral(statement.body.body),
4028
+ type: t34.tsTypeLiteral(statement.body.body),
3987
4029
  // 将接口体转换为类型字面量
3988
4030
  hasTypeParameters: !!statement.typeParameters?.params.length
3989
4031
  // 检查是否有泛型参数
3990
4032
  });
3991
4033
  continue;
3992
4034
  }
3993
- if (t33.isTSTypeAliasDeclaration(statement)) {
4035
+ if (t34.isTSTypeAliasDeclaration(statement)) {
3994
4036
  declarations.set(statement.id.name, {
3995
4037
  type: statement.typeAnnotation,
3996
4038
  // 直接使用类型注解
@@ -3999,16 +4041,16 @@ function collectLocalTypeDeclarations(path8) {
3999
4041
  });
4000
4042
  continue;
4001
4043
  }
4002
- if (t33.isExportNamedDeclaration(statement) && statement.declaration) {
4044
+ if (t34.isExportNamedDeclaration(statement) && statement.declaration) {
4003
4045
  const declaration = statement.declaration;
4004
- if (t33.isTSInterfaceDeclaration(declaration)) {
4046
+ if (t34.isTSInterfaceDeclaration(declaration)) {
4005
4047
  declarations.set(declaration.id.name, {
4006
- type: t33.tsTypeLiteral(declaration.body.body),
4048
+ type: t34.tsTypeLiteral(declaration.body.body),
4007
4049
  // 将接口体转换为类型字面量
4008
4050
  hasTypeParameters: !!declaration.typeParameters?.params.length
4009
4051
  // 检查是否有泛型参数
4010
4052
  });
4011
- } else if (t33.isTSTypeAliasDeclaration(declaration)) {
4053
+ } else if (t34.isTSTypeAliasDeclaration(declaration)) {
4012
4054
  declarations.set(declaration.id.name, {
4013
4055
  type: declaration.typeAnnotation,
4014
4056
  // 直接使用类型注解
@@ -4021,22 +4063,22 @@ function collectLocalTypeDeclarations(path8) {
4021
4063
  return declarations;
4022
4064
  }
4023
4065
  function resolvePropName2(key) {
4024
- if (t33.isIdentifier(key)) {
4066
+ if (t34.isIdentifier(key)) {
4025
4067
  return key.name;
4026
4068
  }
4027
- if (t33.isStringLiteral(key)) {
4069
+ if (t34.isStringLiteral(key)) {
4028
4070
  return key.value;
4029
4071
  }
4030
- if (t33.isNumericLiteral(key)) {
4072
+ if (t34.isNumericLiteral(key)) {
4031
4073
  return String(key.value);
4032
4074
  }
4033
4075
  return null;
4034
4076
  }
4035
4077
  function resolveCallableType(tsType) {
4036
- if (t33.isTSFunctionType(tsType)) {
4078
+ if (t34.isTSFunctionType(tsType)) {
4037
4079
  return tsType;
4038
4080
  }
4039
- if (t33.isTSParenthesizedType(tsType)) {
4081
+ if (t34.isTSParenthesizedType(tsType)) {
4040
4082
  return resolveCallableType(tsType.typeAnnotation);
4041
4083
  }
4042
4084
  return null;
@@ -4045,10 +4087,10 @@ function resolveCallableType(tsType) {
4045
4087
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/type-resolver.ts
4046
4088
  var SLOT_DEFAULT_NAME2 = "default";
4047
4089
  function resolveSlotType(tsType, options) {
4048
- if (t34.isTSParenthesizedType(tsType)) {
4090
+ if (t35.isTSParenthesizedType(tsType)) {
4049
4091
  return resolveSlotType(tsType.typeAnnotation, options);
4050
4092
  }
4051
- if (t34.isTSTypeReference(tsType)) {
4093
+ if (t35.isTSTypeReference(tsType)) {
4052
4094
  let shouldRecordReactNode = false;
4053
4095
  if (tsType.typeParameters?.params.length) {
4054
4096
  const params = [];
@@ -4064,11 +4106,11 @@ function resolveSlotType(tsType, options) {
4064
4106
  };
4065
4107
  }
4066
4108
  return {
4067
- type: t34.tsTypeReference(tsType.typeName, t34.tsTypeParameterInstantiation(params)),
4109
+ type: t35.tsTypeReference(tsType.typeName, t35.tsTypeParameterInstantiation(params)),
4068
4110
  shouldRecordReactNode
4069
4111
  };
4070
4112
  }
4071
- if (!t34.isIdentifier(tsType.typeName)) {
4113
+ if (!t35.isIdentifier(tsType.typeName)) {
4072
4114
  return {
4073
4115
  type: tsType,
4074
4116
  shouldRecordReactNode: false
@@ -4099,7 +4141,7 @@ function resolveSlotType(tsType, options) {
4099
4141
  }
4100
4142
  return resolved;
4101
4143
  }
4102
- if (t34.isTSIntersectionType(tsType)) {
4144
+ if (t35.isTSIntersectionType(tsType)) {
4103
4145
  const types = [];
4104
4146
  let shouldRecordReactNode = false;
4105
4147
  for (const item of tsType.types) {
@@ -4122,11 +4164,11 @@ function resolveSlotType(tsType, options) {
4122
4164
  };
4123
4165
  }
4124
4166
  return {
4125
- type: t34.tsIntersectionType(types),
4167
+ type: t35.tsIntersectionType(types),
4126
4168
  shouldRecordReactNode
4127
4169
  };
4128
4170
  }
4129
- if (t34.isTSUnionType(tsType)) {
4171
+ if (t35.isTSUnionType(tsType)) {
4130
4172
  const types = [];
4131
4173
  let shouldRecordReactNode = false;
4132
4174
  for (const item of tsType.types) {
@@ -4149,11 +4191,11 @@ function resolveSlotType(tsType, options) {
4149
4191
  };
4150
4192
  }
4151
4193
  return {
4152
- type: t34.tsUnionType(types),
4194
+ type: t35.tsUnionType(types),
4153
4195
  shouldRecordReactNode
4154
4196
  };
4155
4197
  }
4156
- if (t34.isTSTypeLiteral(tsType)) {
4198
+ if (t35.isTSTypeLiteral(tsType)) {
4157
4199
  const members = [];
4158
4200
  let shouldRecordReactNode = false;
4159
4201
  for (const item of tsType.members) {
@@ -4168,11 +4210,11 @@ function resolveSlotType(tsType, options) {
4168
4210
  };
4169
4211
  }
4170
4212
  return {
4171
- type: t34.tsTypeLiteral(members),
4213
+ type: t35.tsTypeLiteral(members),
4172
4214
  shouldRecordReactNode
4173
4215
  };
4174
4216
  }
4175
- if (t34.isTSFunctionType(tsType)) {
4217
+ if (t35.isTSFunctionType(tsType)) {
4176
4218
  const props = buildSlotPropSignature(
4177
4219
  SLOT_DEFAULT_NAME2,
4178
4220
  cloneCallableParams(tsType.parameters),
@@ -4180,7 +4222,7 @@ function resolveSlotType(tsType, options) {
4180
4222
  // 默认插槽不是可选的
4181
4223
  );
4182
4224
  return {
4183
- type: t34.tsTypeLiteral([props]),
4225
+ type: t35.tsTypeLiteral([props]),
4184
4226
  shouldRecordReactNode: true
4185
4227
  // 函数类型总是需要记录 ReactNode
4186
4228
  };
@@ -4191,7 +4233,7 @@ function resolveSlotType(tsType, options) {
4191
4233
  };
4192
4234
  }
4193
4235
  function resolveSlotPropFromMember(member) {
4194
- if (t34.isTSMethodSignature(member)) {
4236
+ if (t35.isTSMethodSignature(member)) {
4195
4237
  const rawName = resolvePropName2(member.key);
4196
4238
  if (!rawName) {
4197
4239
  return {
@@ -4206,7 +4248,7 @@ function resolveSlotPropFromMember(member) {
4206
4248
  // 方法签名总是可调用,需要记录 ReactNode
4207
4249
  };
4208
4250
  }
4209
- if (t34.isTSPropertySignature(member)) {
4251
+ if (t35.isTSPropertySignature(member)) {
4210
4252
  const rawName = resolvePropName2(member.key);
4211
4253
  if (!rawName) {
4212
4254
  return {
@@ -4229,7 +4271,7 @@ function resolveSlotPropFromMember(member) {
4229
4271
  // 可调用属性需要记录 ReactNode
4230
4272
  };
4231
4273
  }
4232
- if (t34.isTSCallSignatureDeclaration(member)) {
4274
+ if (t35.isTSCallSignatureDeclaration(member)) {
4233
4275
  const params = cloneCallableParams(member.parameters);
4234
4276
  return {
4235
4277
  member: buildSlotPropSignature(SLOT_DEFAULT_NAME2, params, true),
@@ -4269,7 +4311,7 @@ function resolveDefineSlotsIface(path8, ctx) {
4269
4311
  }
4270
4312
 
4271
4313
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/template-slots.ts
4272
- import * as t35 from "@babel/types";
4314
+ import * as t36 from "@babel/types";
4273
4315
  function resolveTemplateSlotIface(ctx) {
4274
4316
  if (ctx.inputType !== "sfc") return;
4275
4317
  const {
@@ -4287,7 +4329,7 @@ function resolveTemplateSlotIface(ctx) {
4287
4329
  }
4288
4330
  if (tsMembers.length) {
4289
4331
  recordReactNode(ctx);
4290
- slotTypes.push(t35.tsTypeLiteral(tsMembers));
4332
+ slotTypes.push(t36.tsTypeLiteral(tsMembers));
4291
4333
  }
4292
4334
  }
4293
4335
 
@@ -4339,9 +4381,9 @@ function resolveCompIProps(ctx, ast) {
4339
4381
  }
4340
4382
  const n = declaredOptions.name || "Comp";
4341
4383
  const ns = `I${camelCase(capitalize(n))}Props`;
4342
- const typeNode = t36.tsIntersectionType(tsTypes);
4343
- const typeAliasDecl = t36.tsTypeAliasDeclaration(t36.identifier(ns), null, typeNode);
4344
- const exportDecl = t36.exportNamedDeclaration(typeAliasDecl);
4384
+ const typeNode = t37.tsIntersectionType(tsTypes);
4385
+ const typeAliasDecl = t37.tsTypeAliasDeclaration(t37.identifier(ns), null, typeNode);
4386
+ const exportDecl = t37.exportNamedDeclaration(typeAliasDecl);
4345
4387
  propsTSIface.name = ns;
4346
4388
  const scriptIR = getScriptIR(ctx);
4347
4389
  scriptIR.exports.push(exportDecl);
@@ -4349,15 +4391,15 @@ function resolveCompIProps(ctx, ast) {
4349
4391
  }
4350
4392
 
4351
4393
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-use-attrs.ts
4352
- import * as t37 from "@babel/types";
4394
+ import * as t38 from "@babel/types";
4353
4395
  function resolveUseAttrs(ctx) {
4354
4396
  return {
4355
4397
  VariableDeclarator(path8) {
4356
4398
  const { init, id } = path8.node;
4357
4399
  if (!init) return;
4358
4400
  const initPath = path8.get("init");
4359
- const propsIdentifier = t37.identifier(ctx.propField);
4360
- if (t37.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
4401
+ const propsIdentifier = t38.identifier(ctx.propField);
4402
+ if (t38.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
4361
4403
  const typeAssertion = createPropsTypeAssertion(propsIdentifier, init.typeAnnotation);
4362
4404
  replaceNode(initPath, typeAssertion, init);
4363
4405
  return;
@@ -4368,13 +4410,13 @@ function resolveUseAttrs(ctx) {
4368
4410
  const isTS = ctx.scriptData.lang.startsWith("ts");
4369
4411
  if (isTS) {
4370
4412
  let typeAnnotation = null;
4371
- if (t37.isIdentifier(id) && t37.isTSTypeAnnotation(id.typeAnnotation)) {
4413
+ if (t38.isIdentifier(id) && t38.isTSTypeAnnotation(id.typeAnnotation)) {
4372
4414
  typeAnnotation = id.typeAnnotation.typeAnnotation;
4373
4415
  id.typeAnnotation = null;
4374
4416
  } else {
4375
- typeAnnotation = t37.tsTypeReference(
4376
- t37.identifier("Record"),
4377
- t37.tsTypeParameterInstantiation([t37.tsStringKeyword(), t37.tsUnknownKeyword()])
4417
+ typeAnnotation = t38.tsTypeReference(
4418
+ t38.identifier("Record"),
4419
+ t38.tsTypeParameterInstantiation([t38.tsStringKeyword(), t38.tsUnknownKeyword()])
4378
4420
  );
4379
4421
  }
4380
4422
  const propsTypeAssertion = createPropsTypeAssertion(propsIdentifier, typeAnnotation);
@@ -4386,18 +4428,18 @@ function resolveUseAttrs(ctx) {
4386
4428
  };
4387
4429
  }
4388
4430
  function isUseAttrsCall(expr) {
4389
- return t37.isCallExpression(expr) && isCalleeNamed(expr, VUE_API_MAP.useAttrs);
4431
+ return t38.isCallExpression(expr) && isCalleeNamed(expr, VUE_API_MAP.useAttrs);
4390
4432
  }
4391
4433
  function createPropsTypeAssertion(propsIdentifier, typeAnnotation) {
4392
- return t37.tsAsExpression(propsIdentifier, typeAnnotation);
4434
+ return t38.tsAsExpression(propsIdentifier, typeAnnotation);
4393
4435
  }
4394
4436
 
4395
4437
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
4396
- import * as t43 from "@babel/types";
4438
+ import * as t44 from "@babel/types";
4397
4439
 
4398
4440
  // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4399
4441
  import { traverse as traverse2 } from "@babel/core";
4400
- import * as t42 from "@babel/types";
4442
+ import * as t43 from "@babel/types";
4401
4443
 
4402
4444
  // src/core/transform/sfc/script/shared/dependency-analyzer/binding-utils.ts
4403
4445
  function isBindingDeclaredInsideBoundary(binding, boundary) {
@@ -4416,7 +4458,7 @@ function isReactiveBinding(node) {
4416
4458
  }
4417
4459
 
4418
4460
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-checker.ts
4419
- import * as t38 from "@babel/types";
4461
+ import * as t39 from "@babel/types";
4420
4462
  function isEligibleBindingSource(binding) {
4421
4463
  if (binding.kind === "param") {
4422
4464
  return false;
@@ -4426,57 +4468,57 @@ function isEligibleBindingSource(binding) {
4426
4468
  const declaratorPath = getVariableDeclaratorPath(bindingPath);
4427
4469
  const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
4428
4470
  const nodeInit = declaratorPath?.node.init;
4429
- const isReactiveApiCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && t38.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4430
- const isHookCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4431
- const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t38.isArrowFunctionExpression(nodeInit) || t38.isFunctionExpression(nodeInit));
4471
+ const isReactiveApiCallVarBinding = !!declaratorPath && t39.isCallExpression(nodeInit) && t39.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4472
+ const isHookCallVarBinding = !!declaratorPath && t39.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4473
+ const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t39.isArrowFunctionExpression(nodeInit) || t39.isFunctionExpression(nodeInit));
4432
4474
  const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(declaratorPath?.node) || isReactiveBinding(bindingPath.node));
4433
4475
  return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
4434
4476
  }
4435
4477
  function isReactValidDependencyExpr(node) {
4436
- if (t38.isIdentifier(node)) {
4478
+ if (t39.isIdentifier(node)) {
4437
4479
  return true;
4438
4480
  }
4439
- if (t38.isMemberExpression(node) || t38.isOptionalMemberExpression(node)) {
4481
+ if (t39.isMemberExpression(node) || t39.isOptionalMemberExpression(node)) {
4440
4482
  return isStaticMemberChain(node);
4441
4483
  }
4442
4484
  return false;
4443
4485
  }
4444
4486
  function isStaticMemberChain(node) {
4445
4487
  let current = node;
4446
- while (t38.isMemberExpression(current) || t38.isOptionalMemberExpression(current)) {
4447
- if (!current.computed && !t38.isIdentifier(current.property)) {
4488
+ while (t39.isMemberExpression(current) || t39.isOptionalMemberExpression(current)) {
4489
+ if (!current.computed && !t39.isIdentifier(current.property)) {
4448
4490
  return false;
4449
4491
  }
4450
- if (current.computed && !t38.isStringLiteral(current.property) && !t38.isNumericLiteral(current.property)) {
4492
+ if (current.computed && !t39.isStringLiteral(current.property) && !t39.isNumericLiteral(current.property)) {
4451
4493
  return false;
4452
4494
  }
4453
4495
  current = current.object;
4454
4496
  }
4455
- return t38.isIdentifier(current);
4497
+ return t39.isIdentifier(current);
4456
4498
  }
4457
4499
  function isHookLikeCallee(callee) {
4458
- if (t38.isIdentifier(callee)) {
4500
+ if (t39.isIdentifier(callee)) {
4459
4501
  return callee.name.startsWith("use");
4460
4502
  }
4461
- if (t38.isMemberExpression(callee) && !callee.computed && t38.isIdentifier(callee.property)) {
4503
+ if (t39.isMemberExpression(callee) && !callee.computed && t39.isIdentifier(callee.property)) {
4462
4504
  return callee.property.name.startsWith("use");
4463
4505
  }
4464
4506
  return false;
4465
4507
  }
4466
4508
 
4467
4509
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-key.ts
4468
- import * as t39 from "@babel/types";
4510
+ import * as t40 from "@babel/types";
4469
4511
  function getDependencyKey(exp) {
4470
- if (t39.isIdentifier(exp)) {
4512
+ if (t40.isIdentifier(exp)) {
4471
4513
  return exp.name;
4472
4514
  }
4473
- if (t39.isMemberExpression(exp) || t39.isOptionalMemberExpression(exp)) {
4515
+ if (t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp)) {
4474
4516
  const objectKey = getDependencyKey(exp.object);
4475
4517
  const opt = exp.optional ? "?" : "";
4476
- if (!exp.computed && t39.isIdentifier(exp.property)) {
4518
+ if (!exp.computed && t40.isIdentifier(exp.property)) {
4477
4519
  return `${objectKey}${opt}.${exp.property.name}`;
4478
4520
  }
4479
- if (t39.isStringLiteral(exp.property) || t39.isNumericLiteral(exp.property)) {
4521
+ if (t40.isStringLiteral(exp.property) || t40.isNumericLiteral(exp.property)) {
4480
4522
  return `${objectKey}${opt}[${JSON.stringify(exp.property.value)}]`;
4481
4523
  }
4482
4524
  return `${objectKey}${opt}[*]`;
@@ -4485,40 +4527,40 @@ function getDependencyKey(exp) {
4485
4527
  }
4486
4528
 
4487
4529
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-normalizer.ts
4488
- import * as t40 from "@babel/types";
4530
+ import * as t41 from "@babel/types";
4489
4531
  function normalizeDependencyExpr(path8, rootName, ctx) {
4490
- if (t40.isIdentifier(path8.node)) {
4491
- return t40.identifier(path8.node.name);
4532
+ if (t41.isIdentifier(path8.node)) {
4533
+ return t41.identifier(path8.node.name);
4492
4534
  }
4493
- if (t40.isMemberExpression(path8.node) || t40.isOptionalMemberExpression(path8.node)) {
4535
+ if (t41.isMemberExpression(path8.node) || t41.isOptionalMemberExpression(path8.node)) {
4494
4536
  if (rootName === ctx.propField) {
4495
4537
  const safePropsExp = ensureOptionalForMemberChain(path8.node);
4496
4538
  if (isReactValidDependencyExpr(safePropsExp)) {
4497
- return t40.cloneNode(safePropsExp, true);
4539
+ return t41.cloneNode(safePropsExp, true);
4498
4540
  }
4499
- return t40.identifier(rootName);
4541
+ return t41.identifier(rootName);
4500
4542
  }
4501
4543
  const normalizedExp = normalizeMemberForCallSite(path8, path8.node);
4502
- const safeExp = t40.isMemberExpression(normalizedExp) || t40.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4544
+ const safeExp = t41.isMemberExpression(normalizedExp) || t41.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4503
4545
  if (isReactValidDependencyExpr(safeExp)) {
4504
- return t40.cloneNode(safeExp, true);
4546
+ return t41.cloneNode(safeExp, true);
4505
4547
  }
4506
- return t40.identifier(rootName);
4548
+ return t41.identifier(rootName);
4507
4549
  }
4508
4550
  return null;
4509
4551
  }
4510
4552
  function normalizeSourcedDependency(exp) {
4511
- if (t40.isIdentifier(exp)) {
4512
- return t40.identifier(exp.name);
4553
+ if (t41.isIdentifier(exp)) {
4554
+ return t41.identifier(exp.name);
4513
4555
  }
4514
- if (t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp)) {
4556
+ if (t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp)) {
4515
4557
  const root = findRootIdentifier(exp);
4516
4558
  if (!root) return null;
4517
- const safeExp = t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4559
+ const safeExp = t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4518
4560
  if (isReactValidDependencyExpr(safeExp)) {
4519
- return t40.cloneNode(safeExp, true);
4561
+ return t41.cloneNode(safeExp, true);
4520
4562
  }
4521
- return t40.identifier(root.name);
4563
+ return t41.identifier(root.name);
4522
4564
  }
4523
4565
  return null;
4524
4566
  }
@@ -4528,7 +4570,7 @@ function normalizeMemberForCallSite(path8, node) {
4528
4570
  if (!isDirectCallee) {
4529
4571
  return node;
4530
4572
  }
4531
- if (!t40.isExpression(node.object)) {
4573
+ if (!t41.isExpression(node.object)) {
4532
4574
  return node;
4533
4575
  }
4534
4576
  return node.object;
@@ -4537,15 +4579,23 @@ function ensureOptionalForMemberChain(node) {
4537
4579
  if (!hasTrailingMemberAccess(node)) {
4538
4580
  return node;
4539
4581
  }
4540
- if (t40.isOptionalMemberExpression(node) && node.optional) {
4541
- return node;
4542
- }
4543
- const object = t40.cloneNode(node.object, true);
4544
- const property = t40.cloneNode(node.property, true);
4545
- return t40.optionalMemberExpression(object, property, node.computed, true);
4582
+ const rebuildWithOptionalChain = (node2) => {
4583
+ const safeObject = ensureOptionalForMemberChain(node2.object);
4584
+ if (safeObject !== node2.object) {
4585
+ const property = t41.cloneNode(node2.property, true);
4586
+ return t41.optionalMemberExpression(safeObject, property, node2.computed, true);
4587
+ }
4588
+ if (t41.isMemberExpression(node2)) {
4589
+ const object = t41.cloneNode(node2.object, true);
4590
+ const property = t41.cloneNode(node2.property, true);
4591
+ return t41.optionalMemberExpression(object, property, node2.computed, true);
4592
+ }
4593
+ return node2;
4594
+ };
4595
+ return rebuildWithOptionalChain(node);
4546
4596
  }
4547
4597
  function hasTrailingMemberAccess(node) {
4548
- return t40.isMemberExpression(node.object) || t40.isOptionalMemberExpression(node.object);
4598
+ return t41.isMemberExpression(node.object) || t41.isOptionalMemberExpression(node.object);
4549
4599
  }
4550
4600
 
4551
4601
  // src/core/transform/sfc/script/shared/dependency-analyzer/shared-utils.ts
@@ -4560,7 +4610,7 @@ function isNestedMemberObject(path8) {
4560
4610
  }
4561
4611
 
4562
4612
  // src/core/transform/sfc/script/shared/dependency-analyzer/trace-utils.ts
4563
- import * as t41 from "@babel/types";
4613
+ import * as t42 from "@babel/types";
4564
4614
  function traceBindingSource(binding, seen, depth) {
4565
4615
  if (depth <= 0) return null;
4566
4616
  const declaratorPath = getVariableDeclaratorPath(binding.path);
@@ -4572,7 +4622,7 @@ function traceBindingSource(binding, seen, depth) {
4572
4622
  }
4573
4623
  function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4574
4624
  if (depth <= 0) return null;
4575
- if (t41.isIdentifier(exp)) {
4625
+ if (t42.isIdentifier(exp)) {
4576
4626
  const sourceBinding = scope.getBinding(exp.name);
4577
4627
  if (!sourceBinding) return null;
4578
4628
  if (isEligibleBindingSource(sourceBinding)) {
@@ -4580,13 +4630,13 @@ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4580
4630
  }
4581
4631
  return traceBindingSource(sourceBinding, seen, depth - 1);
4582
4632
  }
4583
- if (t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp)) {
4633
+ if (t42.isMemberExpression(exp) || t42.isOptionalMemberExpression(exp)) {
4584
4634
  const root = findRootIdentifier(exp);
4585
4635
  if (!root) return null;
4586
4636
  const sourceBinding = scope.getBinding(root.name);
4587
4637
  if (!sourceBinding) return null;
4588
4638
  if (isEligibleBindingSource(sourceBinding)) {
4589
- return t41.cloneNode(exp);
4639
+ return t42.cloneNode(exp);
4590
4640
  }
4591
4641
  const sourcedRoot = traceBindingSource(sourceBinding, seen, depth - 1);
4592
4642
  if (sourcedRoot) {
@@ -4594,17 +4644,17 @@ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4594
4644
  if (rebuilt) {
4595
4645
  return rebuilt;
4596
4646
  }
4597
- return t41.cloneNode(sourcedRoot, true);
4647
+ return t42.cloneNode(sourcedRoot, true);
4598
4648
  }
4599
4649
  }
4600
4650
  return null;
4601
4651
  }
4602
4652
  function rebuildMemberWithNewRoot(node, nextRoot) {
4603
4653
  const replacedObject = (() => {
4604
- if (t41.isIdentifier(node.object)) {
4605
- return t41.cloneNode(nextRoot, true);
4654
+ if (t42.isIdentifier(node.object)) {
4655
+ return t42.cloneNode(nextRoot, true);
4606
4656
  }
4607
- if (t41.isMemberExpression(node.object) || t41.isOptionalMemberExpression(node.object)) {
4657
+ if (t42.isMemberExpression(node.object) || t42.isOptionalMemberExpression(node.object)) {
4608
4658
  return rebuildMemberWithNewRoot(node.object, nextRoot);
4609
4659
  }
4610
4660
  return null;
@@ -4612,15 +4662,15 @@ function rebuildMemberWithNewRoot(node, nextRoot) {
4612
4662
  if (!replacedObject) {
4613
4663
  return null;
4614
4664
  }
4615
- const property = t41.cloneNode(node.property, true);
4616
- if (t41.isMemberExpression(node)) {
4617
- return t41.memberExpression(
4665
+ const property = t42.cloneNode(node.property, true);
4666
+ if (t42.isMemberExpression(node)) {
4667
+ return t42.memberExpression(
4618
4668
  replacedObject,
4619
4669
  property,
4620
4670
  node.computed
4621
4671
  );
4622
4672
  }
4623
- return t41.optionalMemberExpression(
4673
+ return t42.optionalMemberExpression(
4624
4674
  replacedObject,
4625
4675
  property,
4626
4676
  node.computed,
@@ -4631,9 +4681,9 @@ function rebuildMemberWithNewRoot(node, nextRoot) {
4631
4681
  // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4632
4682
  function analyzeDeps(node, ctx, parentPath) {
4633
4683
  if (!parentPath) {
4634
- return t42.arrayExpression([]);
4684
+ return t43.arrayExpression([]);
4635
4685
  }
4636
- const isFnExpr = t42.isArrowFunctionExpression(node) || t42.isFunctionExpression(node);
4686
+ const isFnExpr = t43.isArrowFunctionExpression(node) || t43.isFunctionExpression(node);
4637
4687
  const analyzeTarget = isFnExpr ? node.body : node;
4638
4688
  const bindingLocalBoundary = isFnExpr ? node : analyzeTarget;
4639
4689
  const deps = /* @__PURE__ */ new Map();
@@ -4643,13 +4693,13 @@ function analyzeDeps(node, ctx, parentPath) {
4643
4693
  }
4644
4694
  const analyzeTargetPath = parentPath && parentPath.node === analyzeTarget ? parentPath : null;
4645
4695
  if (analyzeTargetPath) {
4646
- if (t42.isMemberExpression(analyzeTarget) || t42.isOptionalMemberExpression(analyzeTarget)) {
4696
+ if (t43.isMemberExpression(analyzeTarget) || t43.isOptionalMemberExpression(analyzeTarget)) {
4647
4697
  const rootId = findRootIdentifier(analyzeTarget);
4648
4698
  if (rootId) {
4649
4699
  tryAddDependency(analyzeTargetPath, rootId.name, analyzeTargetPath.scope);
4650
4700
  processedIdentifiers.add(rootId);
4651
4701
  }
4652
- } else if (t42.isIdentifier(analyzeTarget)) {
4702
+ } else if (t43.isIdentifier(analyzeTarget)) {
4653
4703
  tryAddDependency(analyzeTargetPath, analyzeTarget.name, analyzeTargetPath.scope);
4654
4704
  }
4655
4705
  }
@@ -4701,7 +4751,7 @@ function analyzeDeps(node, ctx, parentPath) {
4701
4751
  }
4702
4752
  }
4703
4753
  }
4704
- return t42.arrayExpression(Array.from(deps.values()));
4754
+ return t43.arrayExpression(Array.from(deps.values()));
4705
4755
  }
4706
4756
 
4707
4757
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
@@ -4717,7 +4767,7 @@ function resolveAnalysisOnlyAdapter(ctx) {
4717
4767
  if (!isVueApiReference(path8, apiName)) {
4718
4768
  return;
4719
4769
  }
4720
- if (t43.isCallExpression(node)) {
4770
+ if (t44.isCallExpression(node)) {
4721
4771
  resolveCallNode(path8, adapter, ctx);
4722
4772
  } else {
4723
4773
  replaceIdName(node, adapter.target);
@@ -4727,11 +4777,11 @@ function resolveAnalysisOnlyAdapter(ctx) {
4727
4777
  };
4728
4778
  }
4729
4779
  function getApiName(node) {
4730
- const isCallNode = t43.isCallExpression(node);
4780
+ const isCallNode = t44.isCallExpression(node);
4731
4781
  let apiName = "";
4732
- if (t43.isIdentifier(node)) {
4782
+ if (t44.isIdentifier(node)) {
4733
4783
  apiName = node.name;
4734
- } else if (isCallNode && t43.isIdentifier(node.callee)) {
4784
+ } else if (isCallNode && t44.isIdentifier(node.callee)) {
4735
4785
  apiName = node.callee.name;
4736
4786
  }
4737
4787
  return apiName;
@@ -4741,7 +4791,7 @@ function resolveCallNode(path8, adapter, ctx) {
4741
4791
  const { arguments: args } = node;
4742
4792
  if (!args.length) return;
4743
4793
  const fn = args[0];
4744
- if (!t43.isArrowFunctionExpression(fn) && !t43.isFunctionExpression(fn)) {
4794
+ if (!t44.isArrowFunctionExpression(fn) && !t44.isFunctionExpression(fn)) {
4745
4795
  return;
4746
4796
  }
4747
4797
  const fnPath = path8.get("arguments")[0];
@@ -4773,7 +4823,7 @@ function isVueImportBinding(binding) {
4773
4823
  return false;
4774
4824
  }
4775
4825
  const parent = bindingPath.parentPath?.node;
4776
- if (!parent || !t43.isImportDeclaration(parent)) {
4826
+ if (!parent || !t44.isImportDeclaration(parent)) {
4777
4827
  return false;
4778
4828
  }
4779
4829
  const source = parent.source.value.toLowerCase();
@@ -4841,7 +4891,7 @@ function isSkip(path8) {
4841
4891
  }
4842
4892
 
4843
4893
  // src/core/transform/sfc/script/syntax-processor/process/resolve-element-ref.ts
4844
- import * as t44 from "@babel/types";
4894
+ import * as t45 from "@babel/types";
4845
4895
  function resolveElementRef(ctx) {
4846
4896
  return {
4847
4897
  CallExpression(path8) {
@@ -4859,14 +4909,14 @@ function resolveElementRef(ctx) {
4859
4909
  }
4860
4910
  if (isCompRefBindings) {
4861
4911
  const varDeclaratorPath = getVariableDeclaratorPath(path8)?.node;
4862
- if (!t44.isIdentifier(varDeclaratorPath?.id)) {
4912
+ if (!t45.isIdentifier(varDeclaratorPath?.id)) {
4863
4913
  return;
4864
4914
  }
4865
4915
  const varName = varDeclaratorPath.id.name;
4866
4916
  const compRef = refBindings.componentRefs[varName];
4867
4917
  if (!compRef) return;
4868
4918
  }
4869
- node.arguments[0] = t44.identifier("null");
4919
+ node.arguments[0] = t45.identifier("null");
4870
4920
  resolveTypeParameters(ctx, path8);
4871
4921
  replaceCallName(node, REACT_API_MAP.useRef);
4872
4922
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
@@ -4891,27 +4941,27 @@ function resolveTypeParameters(ctx, path8) {
4891
4941
  const compBindingMeta = refBindings.componentRefs[idName];
4892
4942
  if (!node.typeParameters && (domBindingMeta || compBindingMeta)) {
4893
4943
  const type = compBindingMeta ? "any" : domBindingMeta.htmlType;
4894
- node.typeParameters = t44.tsTypeParameterInstantiation([t44.tsTypeReference(t44.identifier(type))]);
4944
+ node.typeParameters = t45.tsTypeParameterInstantiation([t45.tsTypeReference(t45.identifier(type))]);
4895
4945
  }
4896
4946
  }
4897
4947
  function resolveRefValueToCurrent(path8) {
4898
4948
  const { node } = path8;
4899
- if (node.computed || !t44.isIdentifier(node.property) || node.property.name !== "value") {
4949
+ if (node.computed || !t45.isIdentifier(node.property) || node.property.name !== "value") {
4900
4950
  return;
4901
4951
  }
4902
4952
  const rootPath = findRootVariablePath(path8);
4903
- if (!rootPath?.node || !t44.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4953
+ if (!rootPath?.node || !t45.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4904
4954
  return;
4905
4955
  }
4906
4956
  const rootId = findRootIdentifier(node);
4907
- if (!t44.isIdentifier(node.object) || node.object.name !== rootId?.name) {
4957
+ if (!t45.isIdentifier(node.object) || node.object.name !== rootId?.name) {
4908
4958
  return;
4909
4959
  }
4910
4960
  node.property.name = "current";
4911
4961
  }
4912
4962
 
4913
4963
  // src/core/transform/sfc/script/syntax-processor/process/resolve-expression-memo.ts
4914
- import * as t45 from "@babel/types";
4964
+ import * as t46 from "@babel/types";
4915
4965
  function resolveExprMemo(ctx, ast) {
4916
4966
  const isScriptFile = ctx.inputType !== "sfc";
4917
4967
  return {
@@ -4923,11 +4973,11 @@ function resolveExprMemo(ctx, ast) {
4923
4973
  if (!atComponentOrHookRoot(path8, ast.program, isScriptFile)) {
4924
4974
  return false;
4925
4975
  }
4926
- if (!t45.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
4976
+ if (!t46.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
4927
4977
  return false;
4928
4978
  }
4929
- if (t45.isFunction(init)) return false;
4930
- if (t45.isCallExpression(init) && t45.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
4979
+ if (t46.isFunction(init)) return false;
4980
+ if (t46.isCallExpression(init) && t46.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
4931
4981
  return false;
4932
4982
  }
4933
4983
  return true;
@@ -4946,16 +4996,16 @@ function resolveExprMemo(ctx, ast) {
4946
4996
  }
4947
4997
 
4948
4998
  // src/core/transform/sfc/script/syntax-processor/process/resolve-lint-rules.ts
4949
- import * as t46 from "@babel/types";
4999
+ import * as t47 from "@babel/types";
4950
5000
  function resolveLintRules(ctx, ast) {
4951
5001
  const inScriptFile = ctx.inputType !== "sfc";
4952
5002
  return {
4953
5003
  CallExpression(path8) {
4954
5004
  const { node, parentPath } = path8;
4955
- if (!t46.isIdentifier(node.callee)) return;
5005
+ if (!t47.isIdentifier(node.callee)) return;
4956
5006
  const { name: callName } = node.callee;
4957
- const addLog = (t52) => {
4958
- logger.error(t52, {
5007
+ const addLog = (t53) => {
5008
+ logger.error(t53, {
4959
5009
  file: ctx.filename,
4960
5010
  source: ctx.scriptData.source,
4961
5011
  loc: node.loc
@@ -5000,7 +5050,7 @@ function resolveLintRules(ctx, ast) {
5000
5050
 
5001
5051
  // src/core/transform/sfc/script/syntax-processor/process/resolve-provide.ts
5002
5052
  import { generate as generate2 } from "@babel/generator";
5003
- import * as t47 from "@babel/types";
5053
+ import * as t48 from "@babel/types";
5004
5054
  function resolveProvide(ctx) {
5005
5055
  if (ctx.inputType === "style") return {};
5006
5056
  return {
@@ -5032,13 +5082,13 @@ function findOrCreateCtxProvider(root) {
5032
5082
  function assignProviderValue(target, key, value) {
5033
5083
  const getRawExp = (exp) => {
5034
5084
  if (!exp) return "''";
5035
- if (t47.isStringLiteral(exp)) {
5085
+ if (t48.isStringLiteral(exp)) {
5036
5086
  return JSON.stringify(exp.value);
5037
5087
  }
5038
- if (t47.isNumericLiteral(exp)) {
5088
+ if (t48.isNumericLiteral(exp)) {
5039
5089
  return exp.value.toString();
5040
5090
  }
5041
- if (t47.isIdentifier(exp)) {
5091
+ if (t48.isIdentifier(exp)) {
5042
5092
  return exp.name;
5043
5093
  }
5044
5094
  try {
@@ -5054,16 +5104,16 @@ function assignProviderValue(target, key, value) {
5054
5104
  }
5055
5105
 
5056
5106
  // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-adapter.ts
5057
- import * as t48 from "@babel/types";
5107
+ import * as t49 from "@babel/types";
5058
5108
  function resolveRenameAdapter(ctx) {
5059
5109
  return {
5060
5110
  "CallExpression|Identifier"(path8) {
5061
5111
  const node = path8.node;
5062
- const isCallNode = t48.isCallExpression(node);
5112
+ const isCallNode = t49.isCallExpression(node);
5063
5113
  let apiName = "";
5064
- if (t48.isIdentifier(node)) {
5114
+ if (t49.isIdentifier(node)) {
5065
5115
  apiName = node.name;
5066
- } else if (isCallNode && t48.isIdentifier(node.callee)) {
5116
+ } else if (isCallNode && t49.isIdentifier(node.callee)) {
5067
5117
  apiName = node.callee.name;
5068
5118
  }
5069
5119
  if (!apiName) {
@@ -5125,7 +5175,7 @@ function isVueImportBinding2(binding) {
5125
5175
  return false;
5126
5176
  }
5127
5177
  const parent = bindingPath.parentPath?.node;
5128
- if (!parent || !t48.isImportDeclaration(parent)) {
5178
+ if (!parent || !t49.isImportDeclaration(parent)) {
5129
5179
  return false;
5130
5180
  }
5131
5181
  const source = parent.source.value.toLowerCase();
@@ -5169,7 +5219,12 @@ function processVueSyntax2(ast, ctx) {
5169
5219
  excludeBabel: [resolveTemplateSlotIface, resolveCompIProps]
5170
5220
  },
5171
5221
  postprocess: {
5172
- applyBabel: [resolveRuntimeImports, resolveASTChunks],
5222
+ applyBabel: [
5223
+ // 该 resolver 需确保放在所有类型处理之后,移除之前
5224
+ resolveVueTypeAsAny,
5225
+ resolveRuntimeImports,
5226
+ resolveASTChunks
5227
+ ],
5173
5228
  excludeBabel: [resolveSfcCssImport]
5174
5229
  }
5175
5230
  });
@@ -5262,13 +5317,13 @@ function isRouterLinkBooleanCustomProp(prop) {
5262
5317
  }
5263
5318
 
5264
5319
  // src/core/transform/sfc/template/shared/prop-ir-utils.ts
5265
- import * as t50 from "@babel/types";
5320
+ import * as t51 from "@babel/types";
5266
5321
 
5267
5322
  // src/shared/string-code-types.ts
5268
5323
  import { parseExpression as parseExpression3 } from "@babel/parser";
5269
- import * as t49 from "@babel/types";
5324
+ import * as t50 from "@babel/types";
5270
5325
  var strCodeTypes = {
5271
- isIdentifier: isIdentifier28,
5326
+ isIdentifier: isIdentifier29,
5272
5327
  isSimpleExpression,
5273
5328
  isStringLiteral: isStringLiteral13
5274
5329
  };
@@ -5279,30 +5334,30 @@ function isSimpleExpression(code, excludeVar = false) {
5279
5334
  } catch {
5280
5335
  return false;
5281
5336
  }
5282
- if (t49.isLiteral(node)) {
5337
+ if (t50.isLiteral(node)) {
5283
5338
  return true;
5284
5339
  }
5285
- if (!excludeVar && t49.isIdentifier(node)) {
5340
+ if (!excludeVar && t50.isIdentifier(node)) {
5286
5341
  return true;
5287
5342
  }
5288
- if (t49.isMemberExpression(node)) {
5289
- return isSimpleExpression(node.object) && t49.isIdentifier(node.property);
5343
+ if (t50.isMemberExpression(node)) {
5344
+ return isSimpleExpression(node.object) && t50.isIdentifier(node.property);
5290
5345
  }
5291
- if (t49.isObjectExpression(node) || t49.isArrayExpression(node)) {
5346
+ if (t50.isObjectExpression(node) || t50.isArrayExpression(node)) {
5292
5347
  return false;
5293
5348
  }
5294
- if (t49.isCallExpression(node) || t49.isAssignmentExpression(node)) {
5349
+ if (t50.isCallExpression(node) || t50.isAssignmentExpression(node)) {
5295
5350
  return false;
5296
5351
  }
5297
- if (t49.isBinaryExpression(node) || t49.isUnaryExpression(node)) {
5352
+ if (t50.isBinaryExpression(node) || t50.isUnaryExpression(node)) {
5298
5353
  return true;
5299
5354
  }
5300
5355
  return false;
5301
5356
  }
5302
- function isIdentifier28(code) {
5357
+ function isIdentifier29(code) {
5303
5358
  try {
5304
5359
  const node = parseExpression3(code);
5305
- return t49.isIdentifier(node);
5360
+ return t50.isIdentifier(node);
5306
5361
  } catch {
5307
5362
  return false;
5308
5363
  }
@@ -5310,7 +5365,7 @@ function isIdentifier28(code) {
5310
5365
  function isStringLiteral13(code) {
5311
5366
  try {
5312
5367
  const node = parseExpression3(code);
5313
- return t49.isStringLiteral(node);
5368
+ return t50.isStringLiteral(node);
5314
5369
  } catch {
5315
5370
  return false;
5316
5371
  }
@@ -5450,9 +5505,10 @@ function resolvePropAsBabelExp(ir, ctx) {
5450
5505
  const value = ir.value;
5451
5506
  const valueContent = value.content;
5452
5507
  const mergedItems = value.merge;
5508
+ const rule = ADAPTER_RULES.runtime;
5453
5509
  const setNameIdentifier = (target, valueName) => {
5454
5510
  target.content = valueName;
5455
- target.ast = t50.jsxIdentifier(valueName);
5511
+ target.ast = t51.jsxIdentifier(valueName);
5456
5512
  };
5457
5513
  const setValueExpression = (target, content, isStringLiteral14) => {
5458
5514
  target.content = content;
@@ -5460,38 +5516,41 @@ function resolvePropAsBabelExp(ir, ctx) {
5460
5516
  };
5461
5517
  const createRuntimeCall = (fnName, args) => {
5462
5518
  const fnArgs = args.filter(Boolean).join(",");
5463
- return `${fnName}(${fnArgs})`;
5519
+ const valIsUndef = fnName === rule.dirOn.target && args?.[1] === "undefined";
5520
+ const isTs = ctx.scriptData.lang.startsWith("ts");
5521
+ const safeTypeAssertion = isTs ? valIsUndef ? "as never" : "" : "";
5522
+ return `${fnName}(${fnArgs}) ${safeTypeAssertion}`;
5464
5523
  };
5465
5524
  const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral14) => {
5466
5525
  if (setName && nameIdentifier) {
5467
5526
  setNameIdentifier(nameExp, nameIdentifier);
5468
5527
  }
5469
- const dir = ADAPTER_RULES.runtime.dir;
5528
+ const dir = rule.dir;
5470
5529
  recordImport(ctx, dir.package, dir.target);
5471
5530
  setValueExpression(value.babelExp, expression, isStringLiteral14);
5472
5531
  };
5473
5532
  if (ir.isKeyLessVBind) {
5474
- const dirKeyless = ADAPTER_RULES.runtime.dirKeyless;
5533
+ const dirKeyless = rule.dirKeyless;
5475
5534
  const expression = createRuntimeCall(dirKeyless.target, [valueContent]);
5476
5535
  applyRuntimeExpression(expression, false);
5477
5536
  return;
5478
5537
  }
5479
5538
  if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
5480
- const dirCls = ADAPTER_RULES.runtime.dirCls;
5539
+ const dirCls = rule.dirCls;
5481
5540
  const arg = mergedItems?.join(",") || wrapSingleQuotes(valueContent);
5482
5541
  const expression = createRuntimeCall(dirCls.target, [arg]);
5483
5542
  applyRuntimeExpression(expression, true, name);
5484
5543
  return;
5485
5544
  }
5486
5545
  if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || mergedItems?.some((item) => !isSimpleStyle(item)))) {
5487
- const dirStyle = ADAPTER_RULES.runtime.dirStyle;
5546
+ const dirStyle = rule.dirStyle;
5488
5547
  const arg = mergedItems?.join(",") || valueContent;
5489
5548
  const expression = createRuntimeCall(dirStyle.target, [arg]);
5490
5549
  applyRuntimeExpression(expression, true, name);
5491
5550
  return;
5492
5551
  }
5493
5552
  if (ir.type === 3 /* EVENT */ && ir.modifiers?.length) {
5494
- const dirOn = ADAPTER_RULES.runtime.dirOn;
5553
+ const dirOn = rule.dirOn;
5495
5554
  const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
5496
5555
  const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
5497
5556
  applyRuntimeExpression(expression, true, name);
@@ -6199,14 +6258,15 @@ function applyValueModifiers(valueExp, modifiers) {
6199
6258
  }
6200
6259
 
6201
6260
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-on.ts
6202
- import * as t51 from "@babel/types";
6261
+ import * as t52 from "@babel/types";
6203
6262
  function resolveVOn(directive, ir, ctx, nodeIR) {
6204
6263
  const arg = directive.arg;
6205
6264
  const exp = directive.exp;
6206
6265
  const modifiers = directive.modifiers.map((item) => item.content);
6207
6266
  const captureIndex = resolveCaptureModifier(modifiers);
6208
6267
  const eventName = resolveEventName(arg.content, captureIndex);
6209
- const handler = resolveHandler(exp.content.trim(), ctx, modifiers);
6268
+ const handlerContent = exp?.content?.trim() || "undefined";
6269
+ const handler = resolveHandler(handlerContent, ctx, modifiers);
6210
6270
  const originalVueEventName = modifiers.length ? `${arg.content}.${modifiers.join(".")}` : "";
6211
6271
  const eventIR = createPropsIR(directive.rawName, eventName, handler);
6212
6272
  eventIR.type = 3 /* EVENT */;
@@ -6256,10 +6316,10 @@ function resolveHandler(handlerContent, ctx, modifiers) {
6256
6316
  return handler;
6257
6317
  }
6258
6318
  function isConsoleCall(expr) {
6259
- return t51.isCallExpression(expr) && t51.isMemberExpression(expr.callee) && t51.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6319
+ return t52.isCallExpression(expr) && t52.isMemberExpression(expr.callee) && t52.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6260
6320
  }
6261
6321
  function isFnReference(expr) {
6262
- return t51.isIdentifier(expr) || t51.isMemberExpression(expr) || t51.isFunction(expr);
6322
+ return t52.isIdentifier(expr) || t52.isMemberExpression(expr) || t52.isFunction(expr);
6263
6323
  }
6264
6324
 
6265
6325
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
@@ -6491,11 +6551,8 @@ function resolveSlotOutletNode(node, nodeIR, ctx, parentIR, childrenIR) {
6491
6551
  function resolveSlotProps(node, ctx) {
6492
6552
  const result = {
6493
6553
  name: "children",
6494
- // 默认插槽名为'children'
6495
6554
  isScope: false,
6496
- // 默认非作用域插槽
6497
6555
  props: []
6498
- // 作用域参数列表
6499
6556
  };
6500
6557
  const { source, filename } = ctx;
6501
6558
  const addSlotProp = (key, value) => {
@@ -6519,9 +6576,12 @@ function resolveSlotProps(node, ctx) {
6519
6576
  continue;
6520
6577
  }
6521
6578
  if (prop.type === NodeTypes9.DIRECTIVE) {
6579
+ warnUnsupportedVueDollarVar(ctx, prop);
6580
+ if (!prop.arg) {
6581
+ continue;
6582
+ }
6522
6583
  const arg = prop.arg;
6523
6584
  const exp = prop.exp;
6524
- warnUnsupportedVueDollarVar(ctx, prop);
6525
6585
  if (!arg.isStatic) {
6526
6586
  logger.warn("Avoid using dynamic slot names, as they may lead to unexpected behavior.", {
6527
6587
  source,
@@ -6530,7 +6590,7 @@ function resolveSlotProps(node, ctx) {
6530
6590
  });
6531
6591
  }
6532
6592
  const key = arg.content;
6533
- const value = exp.content.trim();
6593
+ const value = exp?.content?.trim() || "undefined";
6534
6594
  if (key === "name") {
6535
6595
  result.name = camelCase(value);
6536
6596
  } else {
@@ -6612,7 +6672,7 @@ function transform(ast, ctx, options) {
6612
6672
  }
6613
6673
 
6614
6674
  // package.json
6615
- var version = "1.8.1";
6675
+ var version = "1.8.4";
6616
6676
  var bin = {
6617
6677
  vureact: "bin/vureact.js"
6618
6678
  };
@@ -7036,13 +7096,6 @@ var Helper = class {
7036
7096
  }
7037
7097
  logger.clear();
7038
7098
  }
7039
- printCompileInfo(file, duration) {
7040
- this.print(
7041
- kleur4.green("Compiled"),
7042
- kleur4.dim(normalizePath(this.relativePath(file))),
7043
- kleur4.gray(`(${duration})`)
7044
- );
7045
- }
7046
7099
  print(...message) {
7047
7100
  if (this.compilerOpts.watch) {
7048
7101
  const time = (/* @__PURE__ */ new Date()).toLocaleTimeString();
@@ -7817,6 +7870,9 @@ var FileProcessor = class {
7817
7870
  }
7818
7871
  }
7819
7872
  await this.cacheManager.updateCacheIncrementally(processed, key);
7873
+ if (this.fileCompiler.getIsCache() && !existingCache) {
7874
+ await this.cacheManager.flushCache(key);
7875
+ }
7820
7876
  }
7821
7877
  return processed;
7822
7878
  }
@@ -8156,7 +8212,7 @@ var ViteBootstrapper = class {
8156
8212
  newPkg.devDependencies = newDevDeps;
8157
8213
  newPkg = output?.packageJson?.(newPkg) || newPkg;
8158
8214
  await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
8159
- this.spinner.succeed("Initialized Vite React environment");
8215
+ this.spinner.succeed("Vite React environment initialized");
8160
8216
  return true;
8161
8217
  }
8162
8218
  /**
@@ -8292,7 +8348,7 @@ var FileCompiler = class extends BaseCompiler {
8292
8348
  const { viteBootstrapper, fileProcessor, cacheManager, pipelineManager, assetManager } = this.manager;
8293
8349
  let startTime = 0;
8294
8350
  try {
8295
- this.updateSpinner("Initializing Vite React env...");
8351
+ this.updateSpinner("Initializing environment...");
8296
8352
  await viteBootstrapper.bootstrapIfNeeded();
8297
8353
  const cacheMap = await cacheManager.loadAllCache();
8298
8354
  startTime = performance.now();