@vureact/compiler-core 1.8.4 → 1.9.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.4
2
+ * @vureact/compiler-core v1.9.0
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -48,7 +48,8 @@ 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"
52
53
  };
53
54
  var DOLLAR_IDENTIFIERS = [
54
55
  "$data",
@@ -950,21 +951,21 @@ var Logger = class {
950
951
  }
951
952
  printAll(opts) {
952
953
  if (this.logs.length === 0) {
953
- console.log("No logs to display.");
954
+ !opts?._testMode && console.log("No logs to display.");
954
955
  return;
955
956
  }
956
957
  const orderedLogs = this.getOrderedLogs(opts);
957
958
  for (const log of orderedLogs) {
958
- console.log();
959
+ !opts?._testMode && console.log();
959
960
  console.log(this.formatHeader(log));
960
961
  const context = this.formatContext(log);
961
962
  if (context) {
962
963
  console.log(context);
963
964
  }
964
- console.log();
965
+ !opts?._testMode && console.log();
965
966
  }
966
967
  this.printSummary();
967
- console.log();
968
+ !opts?._testMode && console.log();
968
969
  }
969
970
  clear() {
970
971
  this.logs = [];
@@ -1060,7 +1061,7 @@ function buildStandardProp(nodeIR) {
1060
1061
  babelExp: { ast: keyAST },
1061
1062
  value: {
1062
1063
  content,
1063
- isStringLiteral: isStringLiteral14,
1064
+ isStringLiteral: isStringLiteral15,
1064
1065
  babelExp: { ast: valueAST }
1065
1066
  }
1066
1067
  } = nodeIR;
@@ -1069,7 +1070,7 @@ function buildStandardProp(nodeIR) {
1069
1070
  }
1070
1071
  let value;
1071
1072
  if (content !== "true") {
1072
- value = isStringLiteral14 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
1073
+ value = isStringLiteral15 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
1073
1074
  }
1074
1075
  return t9.jsxAttribute(keyAST, value);
1075
1076
  }
@@ -1180,26 +1181,38 @@ function buildCtxProviderNode(nodeIR, ctx, children) {
1180
1181
 
1181
1182
  // src/core/codegen/component/jsx/syntax-processor/postprocess/build-root-jsx.ts
1182
1183
  function buildRootJsxProcessor(nodeIR, ctx, state) {
1183
- if (!state.rootChildren.length) {
1184
- state.result = null;
1184
+ const { rootChildren } = state;
1185
+ const { provide } = ctx.scriptData;
1186
+ const hasProvide = provide.isOccupied;
1187
+ const hasChildren = rootChildren.length > 0;
1188
+ const setResult = (elem) => {
1189
+ state.result = elem ?? null;
1190
+ };
1191
+ if (hasProvide) {
1192
+ const provider = buildCtxProviderNode(provide, ctx, rootChildren);
1193
+ if (!hasChildren) {
1194
+ setResult(buildFragmentNode([provider]));
1195
+ } else {
1196
+ setResult(provider);
1197
+ }
1185
1198
  return;
1186
1199
  }
1187
- const { provide } = ctx.scriptData;
1188
- if (provide.isOccupied) {
1189
- state.result = buildCtxProviderNode(provide, ctx, state.rootChildren);
1200
+ if (!hasChildren) {
1201
+ setResult();
1190
1202
  return;
1191
1203
  }
1192
- state.result = buildFragmentNode(state.rootChildren);
1204
+ setResult(buildFragmentNode(rootChildren));
1193
1205
  void nodeIR;
1194
1206
  }
1195
1207
 
1196
1208
  // src/core/codegen/component/jsx/syntax-processor/index.ts
1197
1209
  function buildJSXChild(nodeIR, ctx) {
1210
+ const templateIR = nodeIR || { children: [] };
1198
1211
  const state = {
1199
1212
  rootChildren: [],
1200
1213
  result: null
1201
1214
  };
1202
- jsxBuilder(nodeIR, ctx, state, {
1215
+ jsxBuilder(templateIR, ctx, state, {
1203
1216
  preprocess: [],
1204
1217
  process: [buildJsxChildrenProcessor],
1205
1218
  postprocess: [buildRootJsxProcessor]
@@ -1217,7 +1230,7 @@ function jsxBuilder(nodeIR, ctx, state, options) {
1217
1230
 
1218
1231
  // src/core/codegen/component/jsx/index.ts
1219
1232
  function buildJSX(nodeIR, ctx) {
1220
- if (!nodeIR?.children.length) {
1233
+ if (!nodeIR?.children.length && ctx.inputType !== "sfc") {
1221
1234
  return null;
1222
1235
  }
1223
1236
  return buildJSXChild(nodeIR, ctx);
@@ -1254,6 +1267,7 @@ var REACT_API_MAP = {
1254
1267
  memo: "memo",
1255
1268
  useRef: "useRef",
1256
1269
  useMemo: "useMemo",
1270
+ useEffect: "useEffect",
1257
1271
  ReactNode: "ReactNode",
1258
1272
  forwardRef: "forwardRef",
1259
1273
  useCallback: "useCallback",
@@ -1630,11 +1644,11 @@ function replaceIdName(id, newName) {
1630
1644
  id.loc.identifierName = newName;
1631
1645
  }
1632
1646
  }
1633
- function stringValueToTSType(ctx, input, tsTypeAnnotation7) {
1647
+ function stringValueToTSType(ctx, input, tsTypeAnnotation8) {
1634
1648
  const { filename, scriptData } = ctx;
1635
1649
  const exp = stringToExpr(input, scriptData.lang, filename);
1636
1650
  const ts = expressionToTSType(exp);
1637
- return tsTypeAnnotation7 ? t15.tsTypeAnnotation(ts) : ts;
1651
+ return tsTypeAnnotation8 ? t15.tsTypeAnnotation(ts) : ts;
1638
1652
  }
1639
1653
  function expressionToTSType(exp) {
1640
1654
  if (t15.isStringLiteral(exp)) return t15.tsStringKeyword();
@@ -1728,6 +1742,28 @@ function cleanNodeComments(node) {
1728
1742
  node.innerComments = null;
1729
1743
  node.trailingComments = null;
1730
1744
  }
1745
+ function mapRuntimeTypeToTSType(value) {
1746
+ switch (value.name) {
1747
+ case "String":
1748
+ return t15.tsStringKeyword();
1749
+ case "Number":
1750
+ return t15.tsNumberKeyword();
1751
+ case "Boolean":
1752
+ return t15.tsBooleanKeyword();
1753
+ case "Object":
1754
+ return t15.tsTypeLiteral([]);
1755
+ case "Array":
1756
+ return t15.tsArrayType(t15.tsAnyKeyword());
1757
+ case "Function":
1758
+ return t15.tsFunctionType(null, [], t15.tsTypeAnnotation(t15.tsAnyKeyword()));
1759
+ case "Symbol":
1760
+ return t15.tsSymbolKeyword();
1761
+ case "BigInt":
1762
+ return t15.tsBigIntKeyword();
1763
+ default:
1764
+ return t15.tsAnyKeyword();
1765
+ }
1766
+ }
1731
1767
 
1732
1768
  // src/core/parse/sfc/postprocess/resolve-script-metadata/resolve-declared-options.ts
1733
1769
  function resolveDeclaredOptions(path8, ctx) {
@@ -2206,6 +2242,7 @@ var REACTIVE_TYPE_MAP = {
2206
2242
  toRefs: "ref",
2207
2243
  customRef: "ref",
2208
2244
  shallowRef: "ref",
2245
+ defineModel: "ref",
2209
2246
  reactive: "reactive",
2210
2247
  shallowReactive: "reactive",
2211
2248
  computed: "ref",
@@ -3313,6 +3350,13 @@ function createUseMemo(body, deps) {
3313
3350
  function createUseImperativeHandle(refId, init) {
3314
3351
  return t27.callExpression(t27.identifier(REACT_API_MAP.useImperativeHandle), [refId, init]);
3315
3352
  }
3353
+ function createUseUpdated(body, deps) {
3354
+ const adapter = ADAPTER_RULES.runtime.onUpdated;
3355
+ return t27.callExpression(t27.identifier(adapter.target), [
3356
+ t27.arrowFunctionExpression([], body),
3357
+ deps ?? t27.identifier("undefined")
3358
+ ]);
3359
+ }
3316
3360
 
3317
3361
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
3318
3362
  function resolveDefineExpose(ctx) {
@@ -3348,6 +3392,226 @@ function resolveDefineExpose(ctx) {
3348
3392
  };
3349
3393
  }
3350
3394
 
3395
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-model.ts
3396
+ import * as t29 from "@babel/types";
3397
+ function resolveDefineModel(ctx, ast) {
3398
+ if (ctx.inputType !== "sfc") return {};
3399
+ return {
3400
+ CallExpression(path8) {
3401
+ const { node } = path8;
3402
+ if (!isCalleeNamed(node, MACRO_API_NAMES.model)) {
3403
+ return;
3404
+ }
3405
+ if (!validateDefineModelUsage(path8, ctx)) {
3406
+ return;
3407
+ }
3408
+ const propInfo = extractPropInfo(node, ctx);
3409
+ replaceToUseVRef(node, propInfo, ctx);
3410
+ resolveAutoUpdate(ast, path8, propInfo, ctx);
3411
+ resolveInterface(propInfo, ctx);
3412
+ }
3413
+ };
3414
+ }
3415
+ function validateDefineModelUsage(path8, ctx) {
3416
+ const { node, parent } = path8;
3417
+ const { filename, scriptData } = ctx;
3418
+ const [arg1, arg2] = node.arguments;
3419
+ if (!t29.isObjectExpression(arg1) && !t29.isStringLiteral(arg1)) {
3420
+ logger.error(`Invalid argument type for defineModel. Expected a string.`, {
3421
+ file: filename,
3422
+ source: scriptData.source,
3423
+ loc: arg1?.loc
3424
+ });
3425
+ return false;
3426
+ }
3427
+ const hasUnsupportedOption = (arg) => {
3428
+ if (!t29.isObjectExpression(arg)) {
3429
+ return false;
3430
+ }
3431
+ const result = arg.properties.some((prop) => {
3432
+ if ((t29.isObjectProperty(prop) || t29.isObjectMethod(prop)) && t29.isIdentifier(prop.key)) {
3433
+ const keyName = prop.key.name;
3434
+ if (keyName === "get" || keyName === "set" || keyName === "validator") {
3435
+ logger.error(`defineModel does not support '${keyName}' option.`, {
3436
+ file: filename,
3437
+ source: scriptData.source,
3438
+ loc: prop.key.loc
3439
+ });
3440
+ return true;
3441
+ }
3442
+ }
3443
+ });
3444
+ return !!result;
3445
+ };
3446
+ const isValidVariableAssignment = () => {
3447
+ const varDeclaration = path8.parentPath.parentPath;
3448
+ if (varDeclaration?.isVariableDeclaration() && varDeclaration.node.declarations.length === 1 && t29.isArrayPattern(varDeclaration.node.declarations[0]?.id)) {
3449
+ logger.error(
3450
+ `defineModel return value cannot be destructured with array pattern. Please use single variable assignment.`,
3451
+ {
3452
+ file: filename,
3453
+ source: scriptData.source,
3454
+ loc: varDeclaration.node.loc
3455
+ }
3456
+ );
3457
+ return false;
3458
+ }
3459
+ return true;
3460
+ };
3461
+ return !hasUnsupportedOption(arg1) && !hasUnsupportedOption(arg2) && isValidVariableAssignment();
3462
+ }
3463
+ function extractPropInfo(node, ctx) {
3464
+ const [arg1, arg2] = node.arguments;
3465
+ const propInfo = {
3466
+ name: "modelValue",
3467
+ updateEventName: "onUpdateModelValue",
3468
+ type: void 0,
3469
+ required: false,
3470
+ default: void 0
3471
+ };
3472
+ const findObjectProperty = (objExpr, propName) => {
3473
+ return objExpr.properties.find(
3474
+ (prop) => t29.isObjectProperty(prop) && t29.isIdentifier(prop.key) && prop.key.name === propName
3475
+ );
3476
+ };
3477
+ const setPropName = (info, value) => {
3478
+ if (!value.trim()) return;
3479
+ info.name = value;
3480
+ info.updateEventName = `onUpdate${capitalize(camelCase(value))}`;
3481
+ };
3482
+ const extractPropInfoFromObject = (objExpr) => {
3483
+ const result = {};
3484
+ const nameProp = findObjectProperty(objExpr, "name");
3485
+ const typeProp = findObjectProperty(objExpr, "type");
3486
+ const defaultProp = findObjectProperty(objExpr, "default");
3487
+ const requiredProp = findObjectProperty(objExpr, "required");
3488
+ if (nameProp && t29.isStringLiteral(nameProp.value)) {
3489
+ setPropName(result, nameProp.value.value);
3490
+ }
3491
+ if (defaultProp) {
3492
+ result.default = defaultProp.value;
3493
+ }
3494
+ if (requiredProp && t29.isBooleanLiteral(requiredProp.value)) {
3495
+ result.required = requiredProp.value.value;
3496
+ }
3497
+ if (typeProp && t29.isIdentifier(typeProp.value)) {
3498
+ result.type = mapRuntimeTypeToTSType(typeProp.value);
3499
+ } else if (node.typeParameters) {
3500
+ const [typeParam] = node.typeParameters.params;
3501
+ if (t29.isTSType(typeParam)) {
3502
+ result.type = typeParam;
3503
+ }
3504
+ } else if (defaultProp) {
3505
+ result.type = expressionToTSType(defaultProp.value);
3506
+ }
3507
+ return result;
3508
+ };
3509
+ const safeAssign = (target, source) => {
3510
+ if (source.name !== void 0) {
3511
+ target.name = source.name;
3512
+ }
3513
+ if (source.updateEventName !== void 0) {
3514
+ target.updateEventName = source.updateEventName;
3515
+ }
3516
+ if (source.type !== void 0) {
3517
+ target.type = source.type;
3518
+ }
3519
+ if (source.required !== void 0) {
3520
+ target.required = source.required;
3521
+ }
3522
+ if (source.default !== void 0) {
3523
+ target.default = source.default;
3524
+ }
3525
+ };
3526
+ const extractTypeFromTypeParams = (info) => {
3527
+ if (!node.typeParameters) return;
3528
+ const isDefaultAny = !info.type || t29.isTSAnyKeyword(info.type);
3529
+ if (!isDefaultAny) return;
3530
+ const [typeParam] = node.typeParameters.params;
3531
+ if (t29.isTSType(typeParam)) {
3532
+ info.type = typeParam;
3533
+ }
3534
+ };
3535
+ if (t29.isStringLiteral(arg1)) {
3536
+ setPropName(propInfo, arg1.value);
3537
+ extractTypeFromTypeParams(propInfo);
3538
+ } else if (t29.isObjectExpression(arg1)) {
3539
+ safeAssign(propInfo, extractPropInfoFromObject(arg1));
3540
+ }
3541
+ if (!t29.isObjectExpression(arg1) && t29.isObjectExpression(arg2)) {
3542
+ safeAssign(propInfo, extractPropInfoFromObject(arg2));
3543
+ }
3544
+ return propInfo;
3545
+ }
3546
+ function replaceToUseVRef(node, propInfo, ctx) {
3547
+ const refAdapter = ADAPTER_RULES.runtime.ref;
3548
+ replaceCallName(node, refAdapter.target);
3549
+ recordImport(ctx, refAdapter.package, refAdapter.target);
3550
+ const defaultValue = propInfo.default;
3551
+ const propRef = t29.identifier(`${ctx.propField}.${propInfo.name}`);
3552
+ if (!defaultValue) {
3553
+ node.arguments = [propRef];
3554
+ } else {
3555
+ node.arguments = [t29.logicalExpression("??", propRef, defaultValue)];
3556
+ }
3557
+ if (ctx.scriptData.lang.startsWith("ts") && !node.typeParameters && propInfo.type) {
3558
+ node.typeParameters = t29.tsTypeParameterInstantiation([propInfo.type]);
3559
+ }
3560
+ }
3561
+ function resolveAutoUpdate(ast, path8, propInfo, ctx) {
3562
+ const { parent } = path8;
3563
+ if (!t29.isVariableDeclarator(parent)) {
3564
+ return;
3565
+ }
3566
+ const modelId = parent.id;
3567
+ if (!t29.isIdentifier(modelId)) {
3568
+ return;
3569
+ }
3570
+ const memberAccess = t29.memberExpression(
3571
+ t29.identifier(ctx.propField),
3572
+ t29.identifier(propInfo.updateEventName)
3573
+ );
3574
+ const dep = t29.memberExpression(modelId, t29.identifier("value"));
3575
+ const updateCall = t29.optionalCallExpression(memberAccess, [dep], true);
3576
+ const callExpr = createUseUpdated(
3577
+ t29.blockStatement([t29.expressionStatement(updateCall)]),
3578
+ t29.arrayExpression([dep])
3579
+ );
3580
+ ast.program.body.push(t29.expressionStatement(callExpr));
3581
+ const adapter = ADAPTER_RULES.runtime.onUpdated;
3582
+ recordImport(ctx, adapter.package, adapter.target);
3583
+ }
3584
+ function resolveInterface(propInfo, ctx) {
3585
+ const { name, updateEventName, required } = propInfo;
3586
+ const { lang, propsTSIface } = ctx.scriptData;
3587
+ if (!lang.startsWith("ts")) {
3588
+ return;
3589
+ }
3590
+ const propType = propInfo.type || t29.tsAnyKeyword();
3591
+ const propSignature = t29.tsPropertySignature(
3592
+ t29.isValidIdentifier(name) ? t29.identifier(name) : t29.stringLiteral(name),
3593
+ t29.tsTypeAnnotation(propType)
3594
+ );
3595
+ propSignature.optional = !required;
3596
+ const emitArg = t29.identifier("arg");
3597
+ emitArg.typeAnnotation = t29.tsTypeAnnotation(propType);
3598
+ const emitSignature = t29.tsPropertySignature(
3599
+ t29.isValidIdentifier(updateEventName) ? t29.identifier(updateEventName) : t29.stringLiteral(updateEventName),
3600
+ t29.tsTypeAnnotation(t29.tsFunctionType(null, [emitArg], t29.tsTypeAnnotation(t29.tsVoidKeyword())))
3601
+ );
3602
+ emitSignature.optional = true;
3603
+ const appendToTypeLiteral = (list, member) => {
3604
+ const existing = list.find((item) => t29.isTSTypeLiteral(item));
3605
+ if (existing) {
3606
+ existing.members.push(member);
3607
+ } else {
3608
+ list.push(t29.tsTypeLiteral([member]));
3609
+ }
3610
+ };
3611
+ appendToTypeLiteral(propsTSIface.propsTypes, propSignature);
3612
+ appendToTypeLiteral(propsTSIface.emitTypes, emitSignature);
3613
+ }
3614
+
3351
3615
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-options.ts
3352
3616
  function resolveDefineOptions(ctx) {
3353
3617
  return {
@@ -3362,7 +3626,7 @@ function resolveDefineOptions(ctx) {
3362
3626
  }
3363
3627
 
3364
3628
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-emit-calls.ts
3365
- import * as t29 from "@babel/types";
3629
+ import * as t30 from "@babel/types";
3366
3630
  function resolveEmitCalls(ctx) {
3367
3631
  const formatEmitEventName = (raw) => {
3368
3632
  if (raw.startsWith("update:")) {
@@ -3376,7 +3640,7 @@ function resolveEmitCalls(ctx) {
3376
3640
  CallExpression(path8) {
3377
3641
  const { node } = path8;
3378
3642
  const { filename, templateData, scriptData } = ctx;
3379
- if (!t29.isIdentifier(node.callee)) return;
3643
+ if (!t30.isIdentifier(node.callee)) return;
3380
3644
  const { name } = node.callee;
3381
3645
  const checkIfFromDefineEmits = () => {
3382
3646
  let result = false;
@@ -3388,7 +3652,7 @@ function resolveEmitCalls(ctx) {
3388
3652
  const binding = path8.scope.getBinding(name);
3389
3653
  if (binding) {
3390
3654
  const parent = binding.path.node;
3391
- if (t29.isVariableDeclarator(parent) && t29.isCallExpression(parent.init) && t29.isIdentifier(parent.init.callee)) {
3655
+ if (t30.isVariableDeclarator(parent) && t30.isCallExpression(parent.init) && t30.isIdentifier(parent.init.callee)) {
3392
3656
  result = parent.init.callee.name === MACRO_API_NAMES.emits;
3393
3657
  }
3394
3658
  }
@@ -3398,9 +3662,9 @@ function resolveEmitCalls(ctx) {
3398
3662
  if (!checkIfFromDefineEmits()) return;
3399
3663
  const [callee, ...args] = node.arguments;
3400
3664
  let propCall;
3401
- if (t29.isStringLiteral(callee)) {
3665
+ if (t30.isStringLiteral(callee)) {
3402
3666
  const eventName = formatEmitEventName(callee.value);
3403
- propCall = createPropCall(ctx.propField, t29.identifier(eventName), args);
3667
+ propCall = createPropCall(ctx.propField, t30.identifier(eventName), args);
3404
3668
  } else {
3405
3669
  propCall = createPropCall(ctx.propField, callee, args, true);
3406
3670
  logger.error(
@@ -3417,38 +3681,38 @@ function resolveEmitCalls(ctx) {
3417
3681
  };
3418
3682
  }
3419
3683
  function createPropCall(rootName, callee, args, computed = false) {
3420
- return t29.optionalCallExpression(
3421
- t29.memberExpression(t29.identifier(rootName), callee, computed),
3684
+ return t30.optionalCallExpression(
3685
+ t30.memberExpression(t30.identifier(rootName), callee, computed),
3422
3686
  args,
3423
3687
  true
3424
3688
  );
3425
3689
  }
3426
3690
 
3427
3691
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/index.ts
3428
- import * as t37 from "@babel/types";
3692
+ import * as t38 from "@babel/types";
3429
3693
 
3430
3694
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-emits.ts
3431
- import * as t31 from "@babel/types";
3695
+ import * as t32 from "@babel/types";
3432
3696
 
3433
3697
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/shared.ts
3434
- import * as t30 from "@babel/types";
3698
+ import * as t31 from "@babel/types";
3435
3699
  function cloneCallableParams(params) {
3436
3700
  const cloneCallableParam = (param, index) => {
3437
- if (t30.isRestElement(param)) {
3701
+ if (t31.isRestElement(param)) {
3438
3702
  const arg = param.argument;
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()));
3703
+ const name = t31.isIdentifier(arg) ? arg.name : `args${index}`;
3704
+ const rest = t31.restElement(t31.identifier(name));
3705
+ rest.typeAnnotation = param.typeAnnotation || (t31.isIdentifier(arg) ? arg.typeAnnotation : null) || t31.tsTypeAnnotation(t31.tsArrayType(t31.tsAnyKeyword()));
3442
3706
  return rest;
3443
3707
  }
3444
- if (t30.isIdentifier(param)) {
3445
- const id = t30.identifier(param.name || `arg${index}`);
3708
+ if (t31.isIdentifier(param)) {
3709
+ const id = t31.identifier(param.name || `arg${index}`);
3446
3710
  id.optional = param.optional;
3447
- id.typeAnnotation = param.typeAnnotation || t30.tsTypeAnnotation(t30.tsAnyKeyword());
3711
+ id.typeAnnotation = param.typeAnnotation || t31.tsTypeAnnotation(t31.tsAnyKeyword());
3448
3712
  return id;
3449
3713
  }
3450
- const fallback = t30.identifier(`arg${index}`);
3451
- fallback.typeAnnotation = t30.tsTypeAnnotation(t30.tsAnyKeyword());
3714
+ const fallback = t31.identifier(`arg${index}`);
3715
+ fallback.typeAnnotation = t31.tsTypeAnnotation(t31.tsAnyKeyword());
3452
3716
  return fallback;
3453
3717
  };
3454
3718
  return params.map(cloneCallableParam);
@@ -3458,18 +3722,18 @@ function cloneCallableParams(params) {
3458
3722
  function resolveEmitsTopLevelTypes(ctx) {
3459
3723
  return {
3460
3724
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path8) {
3461
- if (!t31.isProgram(path8.parent)) return;
3725
+ if (!t32.isProgram(path8.parent)) return;
3462
3726
  const { node } = path8;
3463
- if (t31.isTSInterfaceDeclaration(node)) {
3464
- const typeLiteral = t31.tsTypeLiteral(node.body.body);
3727
+ if (t32.isTSInterfaceDeclaration(node)) {
3728
+ const typeLiteral = t32.tsTypeLiteral(node.body.body);
3465
3729
  if (!hasEmitsSignatureInType(typeLiteral)) return;
3466
3730
  const resolved = resolveTopLevelEmitType(typeLiteral);
3467
- if (resolved && t31.isTSTypeLiteral(resolved)) {
3731
+ if (resolved && t32.isTSTypeLiteral(resolved)) {
3468
3732
  node.body.body = resolved.members;
3469
3733
  }
3470
3734
  return;
3471
3735
  }
3472
- if (t31.isTSTypeAliasDeclaration(node)) {
3736
+ if (t32.isTSTypeAliasDeclaration(node)) {
3473
3737
  if (!hasEmitsSignatureInType(node.typeAnnotation)) return;
3474
3738
  const resolved = resolveTopLevelEmitType(node.typeAnnotation);
3475
3739
  if (resolved) {
@@ -3480,47 +3744,47 @@ function resolveEmitsTopLevelTypes(ctx) {
3480
3744
  };
3481
3745
  }
3482
3746
  function resolveTopLevelEmitType(tsType) {
3483
- if (t31.isTSParenthesizedType(tsType)) {
3747
+ if (t32.isTSParenthesizedType(tsType)) {
3484
3748
  return resolveTopLevelEmitType(tsType.typeAnnotation);
3485
3749
  }
3486
- if (t31.isTSTypeReference(tsType)) {
3750
+ if (t32.isTSTypeReference(tsType)) {
3487
3751
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3488
3752
  return tsType;
3489
3753
  }
3490
3754
  const params = tsType.typeParameters.params.map((param) => resolveTopLevelEmitType(param)).filter(Boolean);
3491
- return t31.tsTypeReference(
3755
+ return t32.tsTypeReference(
3492
3756
  tsType.typeName,
3493
- t31.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3757
+ t32.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3494
3758
  );
3495
3759
  }
3496
- if (t31.isTSIntersectionType(tsType)) {
3760
+ if (t32.isTSIntersectionType(tsType)) {
3497
3761
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
3498
3762
  if (!types.length) return null;
3499
3763
  if (types.length === 1) return types[0];
3500
- return t31.tsIntersectionType(types);
3764
+ return t32.tsIntersectionType(types);
3501
3765
  }
3502
- if (t31.isTSUnionType(tsType)) {
3766
+ if (t32.isTSUnionType(tsType)) {
3503
3767
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
3504
3768
  if (!types.length) return null;
3505
3769
  if (types.length === 1) return types[0];
3506
- return t31.tsUnionType(types);
3770
+ return t32.tsUnionType(types);
3507
3771
  }
3508
- if (t31.isTSTypeLiteral(tsType)) {
3772
+ if (t32.isTSTypeLiteral(tsType)) {
3509
3773
  const members = [];
3510
3774
  for (const member of tsType.members) {
3511
- if (t31.isTSCallSignatureDeclaration(member)) {
3775
+ if (t32.isTSCallSignatureDeclaration(member)) {
3512
3776
  members.push(...resolveEmitPropsFromCallSignature(member));
3513
3777
  continue;
3514
3778
  }
3515
3779
  members.push(member);
3516
3780
  }
3517
3781
  if (!members.length) return null;
3518
- return t31.tsTypeLiteral(members);
3782
+ return t32.tsTypeLiteral(members);
3519
3783
  }
3520
- if (t31.isTSFunctionType(tsType)) {
3784
+ if (t32.isTSFunctionType(tsType)) {
3521
3785
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
3522
3786
  if (!props.length) return null;
3523
- return t31.tsTypeLiteral(props);
3787
+ return t32.tsTypeLiteral(props);
3524
3788
  }
3525
3789
  return tsType;
3526
3790
  }
@@ -3541,41 +3805,41 @@ function processInferredTypes(ctx, runtimeArg) {
3541
3805
  propsTSIface: { emitTypes }
3542
3806
  } = ctx.scriptData;
3543
3807
  const members = [];
3544
- if (t31.isArrayExpression(runtimeArg)) {
3808
+ if (t32.isArrayExpression(runtimeArg)) {
3545
3809
  for (const element of runtimeArg.elements) {
3546
- if (!element || !t31.isStringLiteral(element)) continue;
3810
+ if (!element || !t32.isStringLiteral(element)) continue;
3547
3811
  const handlerName = resolveEmitHandlerName(element.value);
3548
3812
  const key = buildKey(handlerName);
3549
- const fnType = t31.tsFunctionType(
3813
+ const fnType = t32.tsFunctionType(
3550
3814
  null,
3551
3815
  [createRestAnyParam("args")],
3552
- t31.tsTypeAnnotation(t31.tsAnyKeyword())
3816
+ t32.tsTypeAnnotation(t32.tsAnyKeyword())
3553
3817
  );
3554
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
3818
+ const prop = t32.tsPropertySignature(key, t32.tsTypeAnnotation(fnType));
3555
3819
  prop.optional = true;
3556
3820
  members.push(prop);
3557
3821
  }
3558
3822
  if (members.length) {
3559
- emitTypes.push(t31.tsTypeLiteral(members));
3823
+ emitTypes.push(t32.tsTypeLiteral(members));
3560
3824
  }
3561
3825
  return;
3562
3826
  }
3563
- if (t31.isObjectExpression(runtimeArg)) {
3827
+ if (t32.isObjectExpression(runtimeArg)) {
3564
3828
  for (const prop of runtimeArg.properties) {
3565
- if (!t31.isObjectProperty(prop)) continue;
3566
- if (t31.isSpreadElement(prop)) continue;
3829
+ if (!t32.isObjectProperty(prop)) continue;
3830
+ if (t32.isSpreadElement(prop)) continue;
3567
3831
  const rawName = resolvePropName(prop.key);
3568
3832
  if (!rawName) continue;
3569
3833
  const handlerName = resolveEmitHandlerName(rawName);
3570
3834
  const key = buildKey(handlerName);
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));
3835
+ const params = t32.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
3836
+ const fnType = t32.tsFunctionType(null, params, t32.tsTypeAnnotation(t32.tsAnyKeyword()));
3837
+ const propSig = t32.tsPropertySignature(key, t32.tsTypeAnnotation(fnType));
3574
3838
  propSig.optional = true;
3575
3839
  members.push(propSig);
3576
3840
  }
3577
3841
  if (members.length) {
3578
- emitTypes.push(t31.tsTypeLiteral(members));
3842
+ emitTypes.push(t32.tsTypeLiteral(members));
3579
3843
  }
3580
3844
  }
3581
3845
  }
@@ -3596,129 +3860,129 @@ function resolveEmitHandlerName(rawName) {
3596
3860
  return `on${name}`;
3597
3861
  }
3598
3862
  function resolvePropName(key) {
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);
3863
+ if (t32.isIdentifier(key)) return key.name;
3864
+ if (t32.isStringLiteral(key)) return key.value;
3865
+ if (t32.isNumericLiteral(key)) return String(key.value);
3602
3866
  return null;
3603
3867
  }
3604
3868
  function buildKey(name) {
3605
- return t31.isValidIdentifier(name) ? t31.identifier(name) : t31.stringLiteral(name);
3869
+ return t32.isValidIdentifier(name) ? t32.identifier(name) : t32.stringLiteral(name);
3606
3870
  }
3607
3871
  function createRestAnyParam(name) {
3608
- const id = t31.identifier(name);
3609
- const rest = t31.restElement(id);
3610
- rest.typeAnnotation = t31.tsTypeAnnotation(t31.tsArrayType(t31.tsAnyKeyword()));
3872
+ const id = t32.identifier(name);
3873
+ const rest = t32.restElement(id);
3874
+ rest.typeAnnotation = t32.tsTypeAnnotation(t32.tsArrayType(t32.tsAnyKeyword()));
3611
3875
  return rest;
3612
3876
  }
3613
3877
  function resolveRuntimeTupleParams(value) {
3614
3878
  const params = [];
3615
3879
  value.elements.forEach((element, index) => {
3616
3880
  if (!element) return;
3617
- if (t31.isSpreadElement(element)) {
3881
+ if (t32.isSpreadElement(element)) {
3618
3882
  params.push(createRestAnyParam(`args${index}`));
3619
3883
  return;
3620
3884
  }
3621
- if (t31.isIdentifier(element)) {
3622
- const id = t31.identifier(element.name);
3623
- id.typeAnnotation = element.typeAnnotation || t31.tsTypeAnnotation(t31.tsAnyKeyword());
3885
+ if (t32.isIdentifier(element)) {
3886
+ const id = t32.identifier(element.name);
3887
+ id.typeAnnotation = element.typeAnnotation || t32.tsTypeAnnotation(t32.tsAnyKeyword());
3624
3888
  params.push(id);
3625
3889
  return;
3626
3890
  }
3627
- if (t31.isTSAsExpression(element)) {
3628
- const id = t31.identifier(`arg${index}`);
3629
- id.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
3891
+ if (t32.isTSAsExpression(element)) {
3892
+ const id = t32.identifier(`arg${index}`);
3893
+ id.typeAnnotation = t32.tsTypeAnnotation(element.typeAnnotation);
3630
3894
  params.push(id);
3631
3895
  return;
3632
3896
  }
3633
- const fallback = t31.identifier(`arg${index}`);
3634
- fallback.typeAnnotation = t31.tsTypeAnnotation(t31.tsAnyKeyword());
3897
+ const fallback = t32.identifier(`arg${index}`);
3898
+ fallback.typeAnnotation = t32.tsTypeAnnotation(t32.tsAnyKeyword());
3635
3899
  params.push(fallback);
3636
3900
  });
3637
3901
  return params;
3638
3902
  }
3639
3903
  function resolveExplicitEmitType(tsType) {
3640
- if (t31.isTSParenthesizedType(tsType)) {
3904
+ if (t32.isTSParenthesizedType(tsType)) {
3641
3905
  return resolveExplicitEmitType(tsType.typeAnnotation);
3642
3906
  }
3643
- if (t31.isTSTypeReference(tsType)) {
3907
+ if (t32.isTSTypeReference(tsType)) {
3644
3908
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3645
3909
  return tsType;
3646
3910
  }
3647
3911
  const params = tsType.typeParameters.params.map((param) => resolveExplicitEmitType(param)).filter(Boolean);
3648
- return t31.tsTypeReference(
3912
+ return t32.tsTypeReference(
3649
3913
  tsType.typeName,
3650
- t31.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3914
+ t32.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3651
3915
  );
3652
3916
  }
3653
- if (t31.isTSIntersectionType(tsType)) {
3917
+ if (t32.isTSIntersectionType(tsType)) {
3654
3918
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
3655
3919
  if (!types.length) return null;
3656
3920
  if (types.length === 1) return types[0];
3657
- return t31.tsIntersectionType(types);
3921
+ return t32.tsIntersectionType(types);
3658
3922
  }
3659
- if (t31.isTSUnionType(tsType)) {
3923
+ if (t32.isTSUnionType(tsType)) {
3660
3924
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
3661
3925
  if (!types.length) return null;
3662
3926
  if (types.length === 1) return types[0];
3663
- return t31.tsUnionType(types);
3927
+ return t32.tsUnionType(types);
3664
3928
  }
3665
- if (t31.isTSTypeLiteral(tsType)) {
3929
+ if (t32.isTSTypeLiteral(tsType)) {
3666
3930
  const members = [];
3667
3931
  for (const member of tsType.members) {
3668
- if (t31.isTSPropertySignature(member)) {
3932
+ if (t32.isTSPropertySignature(member)) {
3669
3933
  const prop = resolveEmitPropFromPropertySignature(member);
3670
3934
  if (prop) members.push(prop);
3671
3935
  continue;
3672
3936
  }
3673
- if (t31.isTSCallSignatureDeclaration(member)) {
3937
+ if (t32.isTSCallSignatureDeclaration(member)) {
3674
3938
  members.push(...resolveEmitPropsFromCallSignature(member));
3675
3939
  continue;
3676
3940
  }
3677
3941
  }
3678
3942
  if (!members.length) return null;
3679
- return t31.tsTypeLiteral(members);
3943
+ return t32.tsTypeLiteral(members);
3680
3944
  }
3681
- if (t31.isTSFunctionType(tsType)) {
3945
+ if (t32.isTSFunctionType(tsType)) {
3682
3946
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
3683
3947
  if (!props.length) return null;
3684
- return t31.tsTypeLiteral(props);
3948
+ return t32.tsTypeLiteral(props);
3685
3949
  }
3686
3950
  return tsType;
3687
3951
  }
3688
3952
  function hasEmitsSignatureInType(tsType) {
3689
- if (t31.isTSParenthesizedType(tsType)) {
3953
+ if (t32.isTSParenthesizedType(tsType)) {
3690
3954
  return hasEmitsSignatureInType(tsType.typeAnnotation);
3691
3955
  }
3692
- if (t31.isTSTypeReference(tsType)) {
3956
+ if (t32.isTSTypeReference(tsType)) {
3693
3957
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
3694
3958
  return false;
3695
3959
  }
3696
3960
  return tsType.typeParameters.params.some(hasEmitsSignatureInType);
3697
3961
  }
3698
- if (t31.isTSIntersectionType(tsType) || t31.isTSUnionType(tsType)) {
3962
+ if (t32.isTSIntersectionType(tsType) || t32.isTSUnionType(tsType)) {
3699
3963
  return tsType.types.some(hasEmitsSignatureInType);
3700
3964
  }
3701
- if (t31.isTSTypeLiteral(tsType)) {
3965
+ if (t32.isTSTypeLiteral(tsType)) {
3702
3966
  return tsType.members.some(hasEmitsSignatureInMember);
3703
3967
  }
3704
- if (t31.isTSFunctionType(tsType)) {
3968
+ if (t32.isTSFunctionType(tsType)) {
3705
3969
  return isEmitsCallable(tsType.parameters);
3706
3970
  }
3707
3971
  return false;
3708
3972
  }
3709
3973
  function hasEmitsSignatureInMember(member) {
3710
- if (t31.isTSCallSignatureDeclaration(member)) {
3974
+ if (t32.isTSCallSignatureDeclaration(member)) {
3711
3975
  return isEmitsCallable(member.parameters);
3712
3976
  }
3713
3977
  return false;
3714
3978
  }
3715
3979
  function isEmitsCallable(parameters) {
3716
3980
  const [eventParam] = parameters;
3717
- if (!eventParam || !t31.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3981
+ if (!eventParam || !t32.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3718
3982
  return false;
3719
3983
  }
3720
3984
  const { typeAnnotation } = eventParam;
3721
- if (t31.isNoop(typeAnnotation)) return false;
3985
+ if (t32.isNoop(typeAnnotation)) return false;
3722
3986
  return resolveEventNames(typeAnnotation.typeAnnotation).length > 0;
3723
3987
  }
3724
3988
  function resolveEmitPropFromPropertySignature(member) {
@@ -3728,19 +3992,19 @@ function resolveEmitPropFromPropertySignature(member) {
3728
3992
  const key = buildKey(handlerName);
3729
3993
  const typeAnnotation = member.typeAnnotation?.typeAnnotation;
3730
3994
  let params = [];
3731
- let returnType = t31.tsAnyKeyword();
3732
- if (typeAnnotation && t31.isTSFunctionType(typeAnnotation)) {
3995
+ let returnType = t32.tsAnyKeyword();
3996
+ if (typeAnnotation && t32.isTSFunctionType(typeAnnotation)) {
3733
3997
  params = cloneCallableParams(typeAnnotation.parameters);
3734
3998
  returnType = typeAnnotation.typeAnnotation?.typeAnnotation ?? returnType;
3735
- } else if (typeAnnotation && t31.isTSTupleType(typeAnnotation)) {
3999
+ } else if (typeAnnotation && t32.isTSTupleType(typeAnnotation)) {
3736
4000
  params = resolveTupleTypeParams(typeAnnotation);
3737
4001
  } else if (typeAnnotation) {
3738
- const id = t31.identifier("value");
3739
- id.typeAnnotation = t31.tsTypeAnnotation(typeAnnotation);
4002
+ const id = t32.identifier("value");
4003
+ id.typeAnnotation = t32.tsTypeAnnotation(typeAnnotation);
3740
4004
  params = [id];
3741
4005
  }
3742
- const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(returnType));
3743
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
4006
+ const fnType = t32.tsFunctionType(null, params, t32.tsTypeAnnotation(returnType));
4007
+ const prop = t32.tsPropertySignature(key, t32.tsTypeAnnotation(fnType));
3744
4008
  prop.optional = !!member.optional;
3745
4009
  return prop;
3746
4010
  }
@@ -3749,32 +4013,32 @@ function resolveEmitPropsFromCallSignature(member) {
3749
4013
  }
3750
4014
  function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
3751
4015
  const [eventParam, ...restParams] = parameters;
3752
- if (!eventParam || !t31.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
4016
+ if (!eventParam || !t32.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
3753
4017
  return [];
3754
4018
  }
3755
4019
  const { typeAnnotation: paramTypeAnnotation } = eventParam;
3756
- if (t31.isNoop(paramTypeAnnotation)) return [];
4020
+ if (t32.isNoop(paramTypeAnnotation)) return [];
3757
4021
  const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
3758
4022
  if (!eventNames.length) return [];
3759
- const returnType = typeAnnotation?.typeAnnotation ?? t31.tsAnyKeyword();
4023
+ const returnType = typeAnnotation?.typeAnnotation ?? t32.tsAnyKeyword();
3760
4024
  return eventNames.map((eventName) => {
3761
4025
  const handlerName = resolveEmitHandlerName(eventName);
3762
4026
  const key = buildKey(handlerName);
3763
4027
  const params = cloneCallableParams(restParams);
3764
- const fnType = t31.tsFunctionType(null, params, t31.tsTypeAnnotation(returnType));
3765
- const prop = t31.tsPropertySignature(key, t31.tsTypeAnnotation(fnType));
4028
+ const fnType = t32.tsFunctionType(null, params, t32.tsTypeAnnotation(returnType));
4029
+ const prop = t32.tsPropertySignature(key, t32.tsTypeAnnotation(fnType));
3766
4030
  prop.optional = true;
3767
4031
  return prop;
3768
4032
  });
3769
4033
  }
3770
4034
  function resolveEventNames(type) {
3771
- if (t31.isTSLiteralType(type) && t31.isStringLiteral(type.literal)) {
4035
+ if (t32.isTSLiteralType(type) && t32.isStringLiteral(type.literal)) {
3772
4036
  return [type.literal.value];
3773
4037
  }
3774
- if (t31.isTSUnionType(type)) {
4038
+ if (t32.isTSUnionType(type)) {
3775
4039
  return type.types.flatMap(resolveEventNames);
3776
4040
  }
3777
- if (t31.isTSParenthesizedType(type)) {
4041
+ if (t32.isTSParenthesizedType(type)) {
3778
4042
  return resolveEventNames(type.typeAnnotation);
3779
4043
  }
3780
4044
  return [];
@@ -3787,44 +4051,44 @@ function resolveTupleTypeParams(tuple) {
3787
4051
  return params;
3788
4052
  }
3789
4053
  function resolveTupleElementParam(element, index) {
3790
- const isNamedTuple = typeof t31.isTSNamedTupleMember === "function" && t31.isTSNamedTupleMember(element);
4054
+ const isNamedTuple = typeof t32.isTSNamedTupleMember === "function" && t32.isTSNamedTupleMember(element);
3791
4055
  if (isNamedTuple) {
3792
4056
  const tupleMember = element;
3793
4057
  const name = tupleMember.label?.name || `arg${index}`;
3794
4058
  let innerType = tupleMember.elementType;
3795
4059
  let optional = tupleMember.optional;
3796
- if (t31.isTSOptionalType(innerType)) {
4060
+ if (t32.isTSOptionalType(innerType)) {
3797
4061
  optional = true;
3798
4062
  innerType = innerType.typeAnnotation;
3799
4063
  }
3800
- if (t31.isTSRestType(innerType)) {
3801
- const rest = t31.restElement(t31.identifier(name));
3802
- rest.typeAnnotation = t31.tsTypeAnnotation(innerType.typeAnnotation);
4064
+ if (t32.isTSRestType(innerType)) {
4065
+ const rest = t32.restElement(t32.identifier(name));
4066
+ rest.typeAnnotation = t32.tsTypeAnnotation(innerType.typeAnnotation);
3803
4067
  return rest;
3804
4068
  }
3805
- const id2 = t31.identifier(name);
4069
+ const id2 = t32.identifier(name);
3806
4070
  id2.optional = optional;
3807
- id2.typeAnnotation = t31.tsTypeAnnotation(innerType);
4071
+ id2.typeAnnotation = t32.tsTypeAnnotation(innerType);
3808
4072
  return id2;
3809
4073
  }
3810
- if (t31.isTSRestType(element)) {
3811
- const rest = t31.restElement(t31.identifier(`args${index}`));
3812
- rest.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
4074
+ if (t32.isTSRestType(element)) {
4075
+ const rest = t32.restElement(t32.identifier(`args${index}`));
4076
+ rest.typeAnnotation = t32.tsTypeAnnotation(element.typeAnnotation);
3813
4077
  return rest;
3814
4078
  }
3815
- if (t31.isTSOptionalType(element)) {
3816
- const id2 = t31.identifier(`arg${index}`);
4079
+ if (t32.isTSOptionalType(element)) {
4080
+ const id2 = t32.identifier(`arg${index}`);
3817
4081
  id2.optional = true;
3818
- id2.typeAnnotation = t31.tsTypeAnnotation(element.typeAnnotation);
4082
+ id2.typeAnnotation = t32.tsTypeAnnotation(element.typeAnnotation);
3819
4083
  return id2;
3820
4084
  }
3821
- const id = t31.identifier(`arg${index}`);
3822
- id.typeAnnotation = t31.tsTypeAnnotation(element);
4085
+ const id = t32.identifier(`arg${index}`);
4086
+ id.typeAnnotation = t32.tsTypeAnnotation(element);
3823
4087
  return id;
3824
4088
  }
3825
4089
 
3826
4090
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-props.ts
3827
- import * as t32 from "@babel/types";
4091
+ import * as t33 from "@babel/types";
3828
4092
  function resolveDefinePropsIface(path8, ctx) {
3829
4093
  const { node } = path8;
3830
4094
  const [runtimeArg] = node.arguments;
@@ -3844,38 +4108,38 @@ function processInferredTypes2(ctx, runtimeArg) {
3844
4108
  } = scriptData;
3845
4109
  if (!runtimeArg) return;
3846
4110
  const members = [];
3847
- if (t32.isArrayExpression(runtimeArg)) {
4111
+ if (t33.isArrayExpression(runtimeArg)) {
3848
4112
  for (const element of runtimeArg.elements) {
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()));
4113
+ if (!element || !t33.isStringLiteral(element)) continue;
4114
+ const key = t33.isValidIdentifier(element.value) ? t33.identifier(element.value) : t33.stringLiteral(element.value);
4115
+ const prop = t33.tsPropertySignature(key, t33.tsTypeAnnotation(t33.tsAnyKeyword()));
3852
4116
  prop.optional = true;
3853
4117
  members.push(prop);
3854
4118
  }
3855
4119
  if (members.length) {
3856
- propsTypes.push(t32.tsTypeLiteral(members));
4120
+ propsTypes.push(t33.tsTypeLiteral(members));
3857
4121
  }
3858
4122
  return;
3859
4123
  }
3860
- if (t32.isObjectExpression(runtimeArg)) {
4124
+ if (t33.isObjectExpression(runtimeArg)) {
3861
4125
  for (const prop of runtimeArg.properties) {
3862
- if (!t32.isObjectProperty(prop)) continue;
3863
- if (t32.isSpreadElement(prop)) continue;
4126
+ if (!t33.isObjectProperty(prop)) continue;
4127
+ if (t33.isSpreadElement(prop)) continue;
3864
4128
  const key = prop.key;
3865
4129
  let propName = null;
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);
4130
+ if (t33.isIdentifier(key)) propName = key.name;
4131
+ if (t33.isStringLiteral(key)) propName = key.value;
4132
+ if (t33.isNumericLiteral(key)) propName = String(key.value);
3869
4133
  if (!propName) continue;
3870
4134
  const { type, required } = resolveRuntimePropMeta(prop.value);
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));
4135
+ const tsType = type ?? t33.tsAnyKeyword();
4136
+ const tsKey = t33.isValidIdentifier(propName) ? t33.identifier(propName) : t33.stringLiteral(propName);
4137
+ const tsProp = t33.tsPropertySignature(tsKey, t33.tsTypeAnnotation(tsType));
3874
4138
  tsProp.optional = !required;
3875
4139
  members.push(tsProp);
3876
4140
  }
3877
4141
  if (members.length) {
3878
- propsTypes.push(t32.tsTypeLiteral(members));
4142
+ propsTypes.push(t33.tsTypeLiteral(members));
3879
4143
  }
3880
4144
  return;
3881
4145
  }
@@ -3889,42 +4153,42 @@ function processInferredTypes2(ctx, runtimeArg) {
3889
4153
  );
3890
4154
  }
3891
4155
  function resolveRuntimePropMeta(value) {
3892
- if (t32.isIdentifier(value)) {
4156
+ if (t33.isIdentifier(value)) {
3893
4157
  return {
3894
4158
  type: mapRuntimeTypeToTSType(value),
3895
4159
  required: false
3896
4160
  };
3897
4161
  }
3898
- if (t32.isArrayExpression(value)) {
4162
+ if (t33.isArrayExpression(value)) {
3899
4163
  return {
3900
4164
  type: resolveRuntimeUnionType(value),
3901
4165
  required: false
3902
4166
  };
3903
4167
  }
3904
- if (!t32.isObjectExpression(value)) {
4168
+ if (!t33.isObjectExpression(value)) {
3905
4169
  return { required: false };
3906
4170
  }
3907
4171
  let type;
3908
4172
  let required = false;
3909
4173
  for (const prop of value.properties) {
3910
- if (!t32.isObjectProperty(prop)) continue;
3911
- if (t32.isSpreadElement(prop)) continue;
4174
+ if (!t33.isObjectProperty(prop)) continue;
4175
+ if (t33.isSpreadElement(prop)) continue;
3912
4176
  const key = prop.key;
3913
- const propName = t32.isIdentifier(key) ? key.name : t32.isStringLiteral(key) ? key.value : null;
4177
+ const propName = t33.isIdentifier(key) ? key.name : t33.isStringLiteral(key) ? key.value : null;
3914
4178
  if (!propName) continue;
3915
4179
  if (propName === "type") {
3916
4180
  const valueNode = prop.value;
3917
- if (t32.isArrayExpression(valueNode)) {
4181
+ if (t33.isArrayExpression(valueNode)) {
3918
4182
  type = resolveRuntimeUnionType(valueNode);
3919
4183
  continue;
3920
4184
  }
3921
- if (t32.isIdentifier(valueNode)) {
4185
+ if (t33.isIdentifier(valueNode)) {
3922
4186
  type = mapRuntimeTypeToTSType(valueNode);
3923
4187
  continue;
3924
4188
  }
3925
4189
  }
3926
4190
  if (propName === "required") {
3927
- if (t32.isBooleanLiteral(prop.value)) {
4191
+ if (t33.isBooleanLiteral(prop.value)) {
3928
4192
  required = prop.value.value;
3929
4193
  }
3930
4194
  }
@@ -3934,80 +4198,58 @@ function resolveRuntimePropMeta(value) {
3934
4198
  function resolveRuntimeUnionType(value) {
3935
4199
  const types = [];
3936
4200
  for (const element of value.elements) {
3937
- if (!element || !t32.isIdentifier(element)) continue;
4201
+ if (!element || !t33.isIdentifier(element)) continue;
3938
4202
  const resolved = mapRuntimeTypeToTSType(element);
3939
4203
  if (resolved) types.push(resolved);
3940
4204
  }
3941
- if (!types.length) return t32.tsAnyKeyword();
4205
+ if (!types.length) return t33.tsAnyKeyword();
3942
4206
  if (types.length === 1) return types[0];
3943
- return t32.tsUnionType(types);
3944
- }
3945
- function mapRuntimeTypeToTSType(value) {
3946
- switch (value.name) {
3947
- case "String":
3948
- return t32.tsStringKeyword();
3949
- case "Number":
3950
- return t32.tsNumberKeyword();
3951
- case "Boolean":
3952
- return t32.tsBooleanKeyword();
3953
- case "Object":
3954
- return t32.tsTypeLiteral([]);
3955
- case "Array":
3956
- return t32.tsArrayType(t32.tsAnyKeyword());
3957
- case "Function":
3958
- return t32.tsFunctionType(null, [], t32.tsTypeAnnotation(t32.tsAnyKeyword()));
3959
- case "Symbol":
3960
- return t32.tsSymbolKeyword();
3961
- case "BigInt":
3962
- return t32.tsBigIntKeyword();
3963
- default:
3964
- return t32.tsAnyKeyword();
3965
- }
4207
+ return t33.tsUnionType(types);
3966
4208
  }
3967
4209
 
3968
4210
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/type-resolver.ts
3969
- import * as t35 from "@babel/types";
4211
+ import * as t36 from "@babel/types";
3970
4212
 
3971
4213
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/slot-builder.ts
3972
- import * as t33 from "@babel/types";
4214
+ import * as t34 from "@babel/types";
3973
4215
  var SLOT_DEFAULT_NAME = "default";
3974
4216
  var SLOT_CHILDREN_NAME = "children";
3975
4217
  var SLOT_FN_PARAM_NAME = "props";
3976
4218
  function buildSlotPropSignature(rawName, params, optional) {
3977
4219
  const propName = rawName === SLOT_DEFAULT_NAME ? SLOT_CHILDREN_NAME : rawName;
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))
4220
+ const key = t34.isValidIdentifier(propName) ? t34.identifier(propName) : t34.stringLiteral(propName);
4221
+ const reactNodeType = t34.tsTypeAnnotation(
4222
+ t34.tsTypeReference(t34.identifier(REACT_API_MAP.ReactNode))
3981
4223
  );
3982
4224
  let typeAnnotation;
3983
4225
  if (rawName === SLOT_DEFAULT_NAME && params.length === 0 || params.length === 0) {
3984
4226
  typeAnnotation = reactNodeType;
3985
4227
  } else {
3986
- const fnType = t33.tsFunctionType(null, params, reactNodeType);
3987
- typeAnnotation = t33.tsTypeAnnotation(fnType);
4228
+ const fnType = t34.tsFunctionType(null, params, reactNodeType);
4229
+ typeAnnotation = t34.tsTypeAnnotation(fnType);
3988
4230
  }
3989
- const prop = t33.tsPropertySignature(key, typeAnnotation);
4231
+ const prop = t34.tsPropertySignature(key, typeAnnotation);
3990
4232
  prop.optional = optional;
3991
4233
  return prop;
3992
4234
  }
3993
4235
  function createSlotScopeParam(props, ctx) {
3994
- const paramId = t33.identifier(SLOT_FN_PARAM_NAME);
4236
+ const paramId = t34.identifier(SLOT_FN_PARAM_NAME);
3995
4237
  const propsSigns = [];
3996
4238
  const { reactiveBindings } = ctx.templateData;
3997
4239
  props.forEach(({ prop, tsType }) => {
3998
4240
  const foundBindingValue = reactiveBindings[prop]?.value;
3999
4241
  const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
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);
4242
+ const typeAnnotation = foundBindingTypes ? t34.tsTypeAnnotation(foundBindingTypes) : tsType;
4243
+ const key = t34.isValidIdentifier(prop) ? t34.identifier(prop) : t34.stringLiteral(prop);
4244
+ const propSign = t34.tsPropertySignature(key, typeAnnotation);
4003
4245
  propsSigns.push(propSign);
4004
4246
  });
4005
- paramId.typeAnnotation = t33.tsTypeAnnotation(t33.tsTypeLiteral(propsSigns));
4247
+ paramId.typeAnnotation = t34.tsTypeAnnotation(t34.tsTypeLiteral(propsSigns));
4006
4248
  return paramId;
4007
4249
  }
4008
4250
 
4009
4251
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/utils.ts
4010
- import * as t34 from "@babel/types";
4252
+ import * as t35 from "@babel/types";
4011
4253
  function recordReactNode(ctx) {
4012
4254
  if (!ctx.scriptData.lang.startsWith("ts")) {
4013
4255
  return;
@@ -4023,16 +4265,16 @@ function collectLocalTypeDeclarations(path8) {
4023
4265
  return declarations;
4024
4266
  }
4025
4267
  for (const statement of programPath.node.body) {
4026
- if (t34.isTSInterfaceDeclaration(statement)) {
4268
+ if (t35.isTSInterfaceDeclaration(statement)) {
4027
4269
  declarations.set(statement.id.name, {
4028
- type: t34.tsTypeLiteral(statement.body.body),
4270
+ type: t35.tsTypeLiteral(statement.body.body),
4029
4271
  // 将接口体转换为类型字面量
4030
4272
  hasTypeParameters: !!statement.typeParameters?.params.length
4031
4273
  // 检查是否有泛型参数
4032
4274
  });
4033
4275
  continue;
4034
4276
  }
4035
- if (t34.isTSTypeAliasDeclaration(statement)) {
4277
+ if (t35.isTSTypeAliasDeclaration(statement)) {
4036
4278
  declarations.set(statement.id.name, {
4037
4279
  type: statement.typeAnnotation,
4038
4280
  // 直接使用类型注解
@@ -4041,16 +4283,16 @@ function collectLocalTypeDeclarations(path8) {
4041
4283
  });
4042
4284
  continue;
4043
4285
  }
4044
- if (t34.isExportNamedDeclaration(statement) && statement.declaration) {
4286
+ if (t35.isExportNamedDeclaration(statement) && statement.declaration) {
4045
4287
  const declaration = statement.declaration;
4046
- if (t34.isTSInterfaceDeclaration(declaration)) {
4288
+ if (t35.isTSInterfaceDeclaration(declaration)) {
4047
4289
  declarations.set(declaration.id.name, {
4048
- type: t34.tsTypeLiteral(declaration.body.body),
4290
+ type: t35.tsTypeLiteral(declaration.body.body),
4049
4291
  // 将接口体转换为类型字面量
4050
4292
  hasTypeParameters: !!declaration.typeParameters?.params.length
4051
4293
  // 检查是否有泛型参数
4052
4294
  });
4053
- } else if (t34.isTSTypeAliasDeclaration(declaration)) {
4295
+ } else if (t35.isTSTypeAliasDeclaration(declaration)) {
4054
4296
  declarations.set(declaration.id.name, {
4055
4297
  type: declaration.typeAnnotation,
4056
4298
  // 直接使用类型注解
@@ -4063,22 +4305,22 @@ function collectLocalTypeDeclarations(path8) {
4063
4305
  return declarations;
4064
4306
  }
4065
4307
  function resolvePropName2(key) {
4066
- if (t34.isIdentifier(key)) {
4308
+ if (t35.isIdentifier(key)) {
4067
4309
  return key.name;
4068
4310
  }
4069
- if (t34.isStringLiteral(key)) {
4311
+ if (t35.isStringLiteral(key)) {
4070
4312
  return key.value;
4071
4313
  }
4072
- if (t34.isNumericLiteral(key)) {
4314
+ if (t35.isNumericLiteral(key)) {
4073
4315
  return String(key.value);
4074
4316
  }
4075
4317
  return null;
4076
4318
  }
4077
4319
  function resolveCallableType(tsType) {
4078
- if (t34.isTSFunctionType(tsType)) {
4320
+ if (t35.isTSFunctionType(tsType)) {
4079
4321
  return tsType;
4080
4322
  }
4081
- if (t34.isTSParenthesizedType(tsType)) {
4323
+ if (t35.isTSParenthesizedType(tsType)) {
4082
4324
  return resolveCallableType(tsType.typeAnnotation);
4083
4325
  }
4084
4326
  return null;
@@ -4087,10 +4329,10 @@ function resolveCallableType(tsType) {
4087
4329
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/type-resolver.ts
4088
4330
  var SLOT_DEFAULT_NAME2 = "default";
4089
4331
  function resolveSlotType(tsType, options) {
4090
- if (t35.isTSParenthesizedType(tsType)) {
4332
+ if (t36.isTSParenthesizedType(tsType)) {
4091
4333
  return resolveSlotType(tsType.typeAnnotation, options);
4092
4334
  }
4093
- if (t35.isTSTypeReference(tsType)) {
4335
+ if (t36.isTSTypeReference(tsType)) {
4094
4336
  let shouldRecordReactNode = false;
4095
4337
  if (tsType.typeParameters?.params.length) {
4096
4338
  const params = [];
@@ -4106,11 +4348,11 @@ function resolveSlotType(tsType, options) {
4106
4348
  };
4107
4349
  }
4108
4350
  return {
4109
- type: t35.tsTypeReference(tsType.typeName, t35.tsTypeParameterInstantiation(params)),
4351
+ type: t36.tsTypeReference(tsType.typeName, t36.tsTypeParameterInstantiation(params)),
4110
4352
  shouldRecordReactNode
4111
4353
  };
4112
4354
  }
4113
- if (!t35.isIdentifier(tsType.typeName)) {
4355
+ if (!t36.isIdentifier(tsType.typeName)) {
4114
4356
  return {
4115
4357
  type: tsType,
4116
4358
  shouldRecordReactNode: false
@@ -4141,7 +4383,7 @@ function resolveSlotType(tsType, options) {
4141
4383
  }
4142
4384
  return resolved;
4143
4385
  }
4144
- if (t35.isTSIntersectionType(tsType)) {
4386
+ if (t36.isTSIntersectionType(tsType)) {
4145
4387
  const types = [];
4146
4388
  let shouldRecordReactNode = false;
4147
4389
  for (const item of tsType.types) {
@@ -4164,11 +4406,11 @@ function resolveSlotType(tsType, options) {
4164
4406
  };
4165
4407
  }
4166
4408
  return {
4167
- type: t35.tsIntersectionType(types),
4409
+ type: t36.tsIntersectionType(types),
4168
4410
  shouldRecordReactNode
4169
4411
  };
4170
4412
  }
4171
- if (t35.isTSUnionType(tsType)) {
4413
+ if (t36.isTSUnionType(tsType)) {
4172
4414
  const types = [];
4173
4415
  let shouldRecordReactNode = false;
4174
4416
  for (const item of tsType.types) {
@@ -4191,11 +4433,11 @@ function resolveSlotType(tsType, options) {
4191
4433
  };
4192
4434
  }
4193
4435
  return {
4194
- type: t35.tsUnionType(types),
4436
+ type: t36.tsUnionType(types),
4195
4437
  shouldRecordReactNode
4196
4438
  };
4197
4439
  }
4198
- if (t35.isTSTypeLiteral(tsType)) {
4440
+ if (t36.isTSTypeLiteral(tsType)) {
4199
4441
  const members = [];
4200
4442
  let shouldRecordReactNode = false;
4201
4443
  for (const item of tsType.members) {
@@ -4210,11 +4452,11 @@ function resolveSlotType(tsType, options) {
4210
4452
  };
4211
4453
  }
4212
4454
  return {
4213
- type: t35.tsTypeLiteral(members),
4455
+ type: t36.tsTypeLiteral(members),
4214
4456
  shouldRecordReactNode
4215
4457
  };
4216
4458
  }
4217
- if (t35.isTSFunctionType(tsType)) {
4459
+ if (t36.isTSFunctionType(tsType)) {
4218
4460
  const props = buildSlotPropSignature(
4219
4461
  SLOT_DEFAULT_NAME2,
4220
4462
  cloneCallableParams(tsType.parameters),
@@ -4222,7 +4464,7 @@ function resolveSlotType(tsType, options) {
4222
4464
  // 默认插槽不是可选的
4223
4465
  );
4224
4466
  return {
4225
- type: t35.tsTypeLiteral([props]),
4467
+ type: t36.tsTypeLiteral([props]),
4226
4468
  shouldRecordReactNode: true
4227
4469
  // 函数类型总是需要记录 ReactNode
4228
4470
  };
@@ -4233,7 +4475,7 @@ function resolveSlotType(tsType, options) {
4233
4475
  };
4234
4476
  }
4235
4477
  function resolveSlotPropFromMember(member) {
4236
- if (t35.isTSMethodSignature(member)) {
4478
+ if (t36.isTSMethodSignature(member)) {
4237
4479
  const rawName = resolvePropName2(member.key);
4238
4480
  if (!rawName) {
4239
4481
  return {
@@ -4248,7 +4490,7 @@ function resolveSlotPropFromMember(member) {
4248
4490
  // 方法签名总是可调用,需要记录 ReactNode
4249
4491
  };
4250
4492
  }
4251
- if (t35.isTSPropertySignature(member)) {
4493
+ if (t36.isTSPropertySignature(member)) {
4252
4494
  const rawName = resolvePropName2(member.key);
4253
4495
  if (!rawName) {
4254
4496
  return {
@@ -4271,7 +4513,7 @@ function resolveSlotPropFromMember(member) {
4271
4513
  // 可调用属性需要记录 ReactNode
4272
4514
  };
4273
4515
  }
4274
- if (t35.isTSCallSignatureDeclaration(member)) {
4516
+ if (t36.isTSCallSignatureDeclaration(member)) {
4275
4517
  const params = cloneCallableParams(member.parameters);
4276
4518
  return {
4277
4519
  member: buildSlotPropSignature(SLOT_DEFAULT_NAME2, params, true),
@@ -4311,7 +4553,7 @@ function resolveDefineSlotsIface(path8, ctx) {
4311
4553
  }
4312
4554
 
4313
4555
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/template-slots.ts
4314
- import * as t36 from "@babel/types";
4556
+ import * as t37 from "@babel/types";
4315
4557
  function resolveTemplateSlotIface(ctx) {
4316
4558
  if (ctx.inputType !== "sfc") return;
4317
4559
  const {
@@ -4329,7 +4571,7 @@ function resolveTemplateSlotIface(ctx) {
4329
4571
  }
4330
4572
  if (tsMembers.length) {
4331
4573
  recordReactNode(ctx);
4332
- slotTypes.push(t36.tsTypeLiteral(tsMembers));
4574
+ slotTypes.push(t37.tsTypeLiteral(tsMembers));
4333
4575
  }
4334
4576
  }
4335
4577
 
@@ -4381,9 +4623,9 @@ function resolveCompIProps(ctx, ast) {
4381
4623
  }
4382
4624
  const n = declaredOptions.name || "Comp";
4383
4625
  const ns = `I${camelCase(capitalize(n))}Props`;
4384
- const typeNode = t37.tsIntersectionType(tsTypes);
4385
- const typeAliasDecl = t37.tsTypeAliasDeclaration(t37.identifier(ns), null, typeNode);
4386
- const exportDecl = t37.exportNamedDeclaration(typeAliasDecl);
4626
+ const typeNode = t38.tsIntersectionType(tsTypes);
4627
+ const typeAliasDecl = t38.tsTypeAliasDeclaration(t38.identifier(ns), null, typeNode);
4628
+ const exportDecl = t38.exportNamedDeclaration(typeAliasDecl);
4387
4629
  propsTSIface.name = ns;
4388
4630
  const scriptIR = getScriptIR(ctx);
4389
4631
  scriptIR.exports.push(exportDecl);
@@ -4391,15 +4633,15 @@ function resolveCompIProps(ctx, ast) {
4391
4633
  }
4392
4634
 
4393
4635
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-use-attrs.ts
4394
- import * as t38 from "@babel/types";
4636
+ import * as t39 from "@babel/types";
4395
4637
  function resolveUseAttrs(ctx) {
4396
4638
  return {
4397
4639
  VariableDeclarator(path8) {
4398
4640
  const { init, id } = path8.node;
4399
4641
  if (!init) return;
4400
4642
  const initPath = path8.get("init");
4401
- const propsIdentifier = t38.identifier(ctx.propField);
4402
- if (t38.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
4643
+ const propsIdentifier = t39.identifier(ctx.propField);
4644
+ if (t39.isTSAsExpression(init) && isUseAttrsCall(init.expression)) {
4403
4645
  const typeAssertion = createPropsTypeAssertion(propsIdentifier, init.typeAnnotation);
4404
4646
  replaceNode(initPath, typeAssertion, init);
4405
4647
  return;
@@ -4410,13 +4652,13 @@ function resolveUseAttrs(ctx) {
4410
4652
  const isTS = ctx.scriptData.lang.startsWith("ts");
4411
4653
  if (isTS) {
4412
4654
  let typeAnnotation = null;
4413
- if (t38.isIdentifier(id) && t38.isTSTypeAnnotation(id.typeAnnotation)) {
4655
+ if (t39.isIdentifier(id) && t39.isTSTypeAnnotation(id.typeAnnotation)) {
4414
4656
  typeAnnotation = id.typeAnnotation.typeAnnotation;
4415
4657
  id.typeAnnotation = null;
4416
4658
  } else {
4417
- typeAnnotation = t38.tsTypeReference(
4418
- t38.identifier("Record"),
4419
- t38.tsTypeParameterInstantiation([t38.tsStringKeyword(), t38.tsUnknownKeyword()])
4659
+ typeAnnotation = t39.tsTypeReference(
4660
+ t39.identifier("Record"),
4661
+ t39.tsTypeParameterInstantiation([t39.tsStringKeyword(), t39.tsUnknownKeyword()])
4420
4662
  );
4421
4663
  }
4422
4664
  const propsTypeAssertion = createPropsTypeAssertion(propsIdentifier, typeAnnotation);
@@ -4428,18 +4670,18 @@ function resolveUseAttrs(ctx) {
4428
4670
  };
4429
4671
  }
4430
4672
  function isUseAttrsCall(expr) {
4431
- return t38.isCallExpression(expr) && isCalleeNamed(expr, VUE_API_MAP.useAttrs);
4673
+ return t39.isCallExpression(expr) && isCalleeNamed(expr, VUE_API_MAP.useAttrs);
4432
4674
  }
4433
4675
  function createPropsTypeAssertion(propsIdentifier, typeAnnotation) {
4434
- return t38.tsAsExpression(propsIdentifier, typeAnnotation);
4676
+ return t39.tsAsExpression(propsIdentifier, typeAnnotation);
4435
4677
  }
4436
4678
 
4437
4679
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
4438
- import * as t44 from "@babel/types";
4680
+ import * as t45 from "@babel/types";
4439
4681
 
4440
4682
  // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4441
4683
  import { traverse as traverse2 } from "@babel/core";
4442
- import * as t43 from "@babel/types";
4684
+ import * as t44 from "@babel/types";
4443
4685
 
4444
4686
  // src/core/transform/sfc/script/shared/dependency-analyzer/binding-utils.ts
4445
4687
  function isBindingDeclaredInsideBoundary(binding, boundary) {
@@ -4458,7 +4700,7 @@ function isReactiveBinding(node) {
4458
4700
  }
4459
4701
 
4460
4702
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-checker.ts
4461
- import * as t39 from "@babel/types";
4703
+ import * as t40 from "@babel/types";
4462
4704
  function isEligibleBindingSource(binding) {
4463
4705
  if (binding.kind === "param") {
4464
4706
  return false;
@@ -4468,57 +4710,57 @@ function isEligibleBindingSource(binding) {
4468
4710
  const declaratorPath = getVariableDeclaratorPath(bindingPath);
4469
4711
  const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
4470
4712
  const nodeInit = declaratorPath?.node.init;
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));
4713
+ const isReactiveApiCallVarBinding = !!declaratorPath && t40.isCallExpression(nodeInit) && t40.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4714
+ const isHookCallVarBinding = !!declaratorPath && t40.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4715
+ const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t40.isArrowFunctionExpression(nodeInit) || t40.isFunctionExpression(nodeInit));
4474
4716
  const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(declaratorPath?.node) || isReactiveBinding(bindingPath.node));
4475
4717
  return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
4476
4718
  }
4477
4719
  function isReactValidDependencyExpr(node) {
4478
- if (t39.isIdentifier(node)) {
4720
+ if (t40.isIdentifier(node)) {
4479
4721
  return true;
4480
4722
  }
4481
- if (t39.isMemberExpression(node) || t39.isOptionalMemberExpression(node)) {
4723
+ if (t40.isMemberExpression(node) || t40.isOptionalMemberExpression(node)) {
4482
4724
  return isStaticMemberChain(node);
4483
4725
  }
4484
4726
  return false;
4485
4727
  }
4486
4728
  function isStaticMemberChain(node) {
4487
4729
  let current = node;
4488
- while (t39.isMemberExpression(current) || t39.isOptionalMemberExpression(current)) {
4489
- if (!current.computed && !t39.isIdentifier(current.property)) {
4730
+ while (t40.isMemberExpression(current) || t40.isOptionalMemberExpression(current)) {
4731
+ if (!current.computed && !t40.isIdentifier(current.property)) {
4490
4732
  return false;
4491
4733
  }
4492
- if (current.computed && !t39.isStringLiteral(current.property) && !t39.isNumericLiteral(current.property)) {
4734
+ if (current.computed && !t40.isStringLiteral(current.property) && !t40.isNumericLiteral(current.property)) {
4493
4735
  return false;
4494
4736
  }
4495
4737
  current = current.object;
4496
4738
  }
4497
- return t39.isIdentifier(current);
4739
+ return t40.isIdentifier(current);
4498
4740
  }
4499
4741
  function isHookLikeCallee(callee) {
4500
- if (t39.isIdentifier(callee)) {
4742
+ if (t40.isIdentifier(callee)) {
4501
4743
  return callee.name.startsWith("use");
4502
4744
  }
4503
- if (t39.isMemberExpression(callee) && !callee.computed && t39.isIdentifier(callee.property)) {
4745
+ if (t40.isMemberExpression(callee) && !callee.computed && t40.isIdentifier(callee.property)) {
4504
4746
  return callee.property.name.startsWith("use");
4505
4747
  }
4506
4748
  return false;
4507
4749
  }
4508
4750
 
4509
4751
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-key.ts
4510
- import * as t40 from "@babel/types";
4752
+ import * as t41 from "@babel/types";
4511
4753
  function getDependencyKey(exp) {
4512
- if (t40.isIdentifier(exp)) {
4754
+ if (t41.isIdentifier(exp)) {
4513
4755
  return exp.name;
4514
4756
  }
4515
- if (t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp)) {
4757
+ if (t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp)) {
4516
4758
  const objectKey = getDependencyKey(exp.object);
4517
4759
  const opt = exp.optional ? "?" : "";
4518
- if (!exp.computed && t40.isIdentifier(exp.property)) {
4760
+ if (!exp.computed && t41.isIdentifier(exp.property)) {
4519
4761
  return `${objectKey}${opt}.${exp.property.name}`;
4520
4762
  }
4521
- if (t40.isStringLiteral(exp.property) || t40.isNumericLiteral(exp.property)) {
4763
+ if (t41.isStringLiteral(exp.property) || t41.isNumericLiteral(exp.property)) {
4522
4764
  return `${objectKey}${opt}[${JSON.stringify(exp.property.value)}]`;
4523
4765
  }
4524
4766
  return `${objectKey}${opt}[*]`;
@@ -4527,40 +4769,40 @@ function getDependencyKey(exp) {
4527
4769
  }
4528
4770
 
4529
4771
  // src/core/transform/sfc/script/shared/dependency-analyzer/dep-normalizer.ts
4530
- import * as t41 from "@babel/types";
4772
+ import * as t42 from "@babel/types";
4531
4773
  function normalizeDependencyExpr(path8, rootName, ctx) {
4532
- if (t41.isIdentifier(path8.node)) {
4533
- return t41.identifier(path8.node.name);
4774
+ if (t42.isIdentifier(path8.node)) {
4775
+ return t42.identifier(path8.node.name);
4534
4776
  }
4535
- if (t41.isMemberExpression(path8.node) || t41.isOptionalMemberExpression(path8.node)) {
4777
+ if (t42.isMemberExpression(path8.node) || t42.isOptionalMemberExpression(path8.node)) {
4536
4778
  if (rootName === ctx.propField) {
4537
4779
  const safePropsExp = ensureOptionalForMemberChain(path8.node);
4538
4780
  if (isReactValidDependencyExpr(safePropsExp)) {
4539
- return t41.cloneNode(safePropsExp, true);
4781
+ return t42.cloneNode(safePropsExp, true);
4540
4782
  }
4541
- return t41.identifier(rootName);
4783
+ return t42.identifier(rootName);
4542
4784
  }
4543
4785
  const normalizedExp = normalizeMemberForCallSite(path8, path8.node);
4544
- const safeExp = t41.isMemberExpression(normalizedExp) || t41.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4786
+ const safeExp = t42.isMemberExpression(normalizedExp) || t42.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4545
4787
  if (isReactValidDependencyExpr(safeExp)) {
4546
- return t41.cloneNode(safeExp, true);
4788
+ return t42.cloneNode(safeExp, true);
4547
4789
  }
4548
- return t41.identifier(rootName);
4790
+ return t42.identifier(rootName);
4549
4791
  }
4550
4792
  return null;
4551
4793
  }
4552
4794
  function normalizeSourcedDependency(exp) {
4553
- if (t41.isIdentifier(exp)) {
4554
- return t41.identifier(exp.name);
4795
+ if (t42.isIdentifier(exp)) {
4796
+ return t42.identifier(exp.name);
4555
4797
  }
4556
- if (t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp)) {
4798
+ if (t42.isMemberExpression(exp) || t42.isOptionalMemberExpression(exp)) {
4557
4799
  const root = findRootIdentifier(exp);
4558
4800
  if (!root) return null;
4559
- const safeExp = t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4801
+ const safeExp = t42.isMemberExpression(exp) || t42.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4560
4802
  if (isReactValidDependencyExpr(safeExp)) {
4561
- return t41.cloneNode(safeExp, true);
4803
+ return t42.cloneNode(safeExp, true);
4562
4804
  }
4563
- return t41.identifier(root.name);
4805
+ return t42.identifier(root.name);
4564
4806
  }
4565
4807
  return null;
4566
4808
  }
@@ -4570,7 +4812,7 @@ function normalizeMemberForCallSite(path8, node) {
4570
4812
  if (!isDirectCallee) {
4571
4813
  return node;
4572
4814
  }
4573
- if (!t41.isExpression(node.object)) {
4815
+ if (!t42.isExpression(node.object)) {
4574
4816
  return node;
4575
4817
  }
4576
4818
  return node.object;
@@ -4582,20 +4824,20 @@ function ensureOptionalForMemberChain(node) {
4582
4824
  const rebuildWithOptionalChain = (node2) => {
4583
4825
  const safeObject = ensureOptionalForMemberChain(node2.object);
4584
4826
  if (safeObject !== node2.object) {
4585
- const property = t41.cloneNode(node2.property, true);
4586
- return t41.optionalMemberExpression(safeObject, property, node2.computed, true);
4827
+ const property = t42.cloneNode(node2.property, true);
4828
+ return t42.optionalMemberExpression(safeObject, property, node2.computed, true);
4587
4829
  }
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);
4830
+ if (t42.isMemberExpression(node2)) {
4831
+ const object = t42.cloneNode(node2.object, true);
4832
+ const property = t42.cloneNode(node2.property, true);
4833
+ return t42.optionalMemberExpression(object, property, node2.computed, true);
4592
4834
  }
4593
4835
  return node2;
4594
4836
  };
4595
4837
  return rebuildWithOptionalChain(node);
4596
4838
  }
4597
4839
  function hasTrailingMemberAccess(node) {
4598
- return t41.isMemberExpression(node.object) || t41.isOptionalMemberExpression(node.object);
4840
+ return t42.isMemberExpression(node.object) || t42.isOptionalMemberExpression(node.object);
4599
4841
  }
4600
4842
 
4601
4843
  // src/core/transform/sfc/script/shared/dependency-analyzer/shared-utils.ts
@@ -4610,7 +4852,7 @@ function isNestedMemberObject(path8) {
4610
4852
  }
4611
4853
 
4612
4854
  // src/core/transform/sfc/script/shared/dependency-analyzer/trace-utils.ts
4613
- import * as t42 from "@babel/types";
4855
+ import * as t43 from "@babel/types";
4614
4856
  function traceBindingSource(binding, seen, depth) {
4615
4857
  if (depth <= 0) return null;
4616
4858
  const declaratorPath = getVariableDeclaratorPath(binding.path);
@@ -4622,7 +4864,7 @@ function traceBindingSource(binding, seen, depth) {
4622
4864
  }
4623
4865
  function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4624
4866
  if (depth <= 0) return null;
4625
- if (t42.isIdentifier(exp)) {
4867
+ if (t43.isIdentifier(exp)) {
4626
4868
  const sourceBinding = scope.getBinding(exp.name);
4627
4869
  if (!sourceBinding) return null;
4628
4870
  if (isEligibleBindingSource(sourceBinding)) {
@@ -4630,13 +4872,13 @@ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4630
4872
  }
4631
4873
  return traceBindingSource(sourceBinding, seen, depth - 1);
4632
4874
  }
4633
- if (t42.isMemberExpression(exp) || t42.isOptionalMemberExpression(exp)) {
4875
+ if (t43.isMemberExpression(exp) || t43.isOptionalMemberExpression(exp)) {
4634
4876
  const root = findRootIdentifier(exp);
4635
4877
  if (!root) return null;
4636
4878
  const sourceBinding = scope.getBinding(root.name);
4637
4879
  if (!sourceBinding) return null;
4638
4880
  if (isEligibleBindingSource(sourceBinding)) {
4639
- return t42.cloneNode(exp);
4881
+ return t43.cloneNode(exp);
4640
4882
  }
4641
4883
  const sourcedRoot = traceBindingSource(sourceBinding, seen, depth - 1);
4642
4884
  if (sourcedRoot) {
@@ -4644,17 +4886,17 @@ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4644
4886
  if (rebuilt) {
4645
4887
  return rebuilt;
4646
4888
  }
4647
- return t42.cloneNode(sourcedRoot, true);
4889
+ return t43.cloneNode(sourcedRoot, true);
4648
4890
  }
4649
4891
  }
4650
4892
  return null;
4651
4893
  }
4652
4894
  function rebuildMemberWithNewRoot(node, nextRoot) {
4653
4895
  const replacedObject = (() => {
4654
- if (t42.isIdentifier(node.object)) {
4655
- return t42.cloneNode(nextRoot, true);
4896
+ if (t43.isIdentifier(node.object)) {
4897
+ return t43.cloneNode(nextRoot, true);
4656
4898
  }
4657
- if (t42.isMemberExpression(node.object) || t42.isOptionalMemberExpression(node.object)) {
4899
+ if (t43.isMemberExpression(node.object) || t43.isOptionalMemberExpression(node.object)) {
4658
4900
  return rebuildMemberWithNewRoot(node.object, nextRoot);
4659
4901
  }
4660
4902
  return null;
@@ -4662,15 +4904,15 @@ function rebuildMemberWithNewRoot(node, nextRoot) {
4662
4904
  if (!replacedObject) {
4663
4905
  return null;
4664
4906
  }
4665
- const property = t42.cloneNode(node.property, true);
4666
- if (t42.isMemberExpression(node)) {
4667
- return t42.memberExpression(
4907
+ const property = t43.cloneNode(node.property, true);
4908
+ if (t43.isMemberExpression(node)) {
4909
+ return t43.memberExpression(
4668
4910
  replacedObject,
4669
4911
  property,
4670
4912
  node.computed
4671
4913
  );
4672
4914
  }
4673
- return t42.optionalMemberExpression(
4915
+ return t43.optionalMemberExpression(
4674
4916
  replacedObject,
4675
4917
  property,
4676
4918
  node.computed,
@@ -4681,9 +4923,9 @@ function rebuildMemberWithNewRoot(node, nextRoot) {
4681
4923
  // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4682
4924
  function analyzeDeps(node, ctx, parentPath) {
4683
4925
  if (!parentPath) {
4684
- return t43.arrayExpression([]);
4926
+ return t44.arrayExpression([]);
4685
4927
  }
4686
- const isFnExpr = t43.isArrowFunctionExpression(node) || t43.isFunctionExpression(node);
4928
+ const isFnExpr = t44.isArrowFunctionExpression(node) || t44.isFunctionExpression(node);
4687
4929
  const analyzeTarget = isFnExpr ? node.body : node;
4688
4930
  const bindingLocalBoundary = isFnExpr ? node : analyzeTarget;
4689
4931
  const deps = /* @__PURE__ */ new Map();
@@ -4693,13 +4935,13 @@ function analyzeDeps(node, ctx, parentPath) {
4693
4935
  }
4694
4936
  const analyzeTargetPath = parentPath && parentPath.node === analyzeTarget ? parentPath : null;
4695
4937
  if (analyzeTargetPath) {
4696
- if (t43.isMemberExpression(analyzeTarget) || t43.isOptionalMemberExpression(analyzeTarget)) {
4938
+ if (t44.isMemberExpression(analyzeTarget) || t44.isOptionalMemberExpression(analyzeTarget)) {
4697
4939
  const rootId = findRootIdentifier(analyzeTarget);
4698
4940
  if (rootId) {
4699
4941
  tryAddDependency(analyzeTargetPath, rootId.name, analyzeTargetPath.scope);
4700
4942
  processedIdentifiers.add(rootId);
4701
4943
  }
4702
- } else if (t43.isIdentifier(analyzeTarget)) {
4944
+ } else if (t44.isIdentifier(analyzeTarget)) {
4703
4945
  tryAddDependency(analyzeTargetPath, analyzeTarget.name, analyzeTargetPath.scope);
4704
4946
  }
4705
4947
  }
@@ -4751,7 +4993,7 @@ function analyzeDeps(node, ctx, parentPath) {
4751
4993
  }
4752
4994
  }
4753
4995
  }
4754
- return t43.arrayExpression(Array.from(deps.values()));
4996
+ return t44.arrayExpression(Array.from(deps.values()));
4755
4997
  }
4756
4998
 
4757
4999
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
@@ -4767,7 +5009,7 @@ function resolveAnalysisOnlyAdapter(ctx) {
4767
5009
  if (!isVueApiReference(path8, apiName)) {
4768
5010
  return;
4769
5011
  }
4770
- if (t44.isCallExpression(node)) {
5012
+ if (t45.isCallExpression(node)) {
4771
5013
  resolveCallNode(path8, adapter, ctx);
4772
5014
  } else {
4773
5015
  replaceIdName(node, adapter.target);
@@ -4777,11 +5019,11 @@ function resolveAnalysisOnlyAdapter(ctx) {
4777
5019
  };
4778
5020
  }
4779
5021
  function getApiName(node) {
4780
- const isCallNode = t44.isCallExpression(node);
5022
+ const isCallNode = t45.isCallExpression(node);
4781
5023
  let apiName = "";
4782
- if (t44.isIdentifier(node)) {
5024
+ if (t45.isIdentifier(node)) {
4783
5025
  apiName = node.name;
4784
- } else if (isCallNode && t44.isIdentifier(node.callee)) {
5026
+ } else if (isCallNode && t45.isIdentifier(node.callee)) {
4785
5027
  apiName = node.callee.name;
4786
5028
  }
4787
5029
  return apiName;
@@ -4791,7 +5033,7 @@ function resolveCallNode(path8, adapter, ctx) {
4791
5033
  const { arguments: args } = node;
4792
5034
  if (!args.length) return;
4793
5035
  const fn = args[0];
4794
- if (!t44.isArrowFunctionExpression(fn) && !t44.isFunctionExpression(fn)) {
5036
+ if (!t45.isArrowFunctionExpression(fn) && !t45.isFunctionExpression(fn)) {
4795
5037
  return;
4796
5038
  }
4797
5039
  const fnPath = path8.get("arguments")[0];
@@ -4823,7 +5065,7 @@ function isVueImportBinding(binding) {
4823
5065
  return false;
4824
5066
  }
4825
5067
  const parent = bindingPath.parentPath?.node;
4826
- if (!parent || !t44.isImportDeclaration(parent)) {
5068
+ if (!parent || !t45.isImportDeclaration(parent)) {
4827
5069
  return false;
4828
5070
  }
4829
5071
  const source = parent.source.value.toLowerCase();
@@ -4891,7 +5133,7 @@ function isSkip(path8) {
4891
5133
  }
4892
5134
 
4893
5135
  // src/core/transform/sfc/script/syntax-processor/process/resolve-element-ref.ts
4894
- import * as t45 from "@babel/types";
5136
+ import * as t46 from "@babel/types";
4895
5137
  function resolveElementRef(ctx) {
4896
5138
  return {
4897
5139
  CallExpression(path8) {
@@ -4909,14 +5151,14 @@ function resolveElementRef(ctx) {
4909
5151
  }
4910
5152
  if (isCompRefBindings) {
4911
5153
  const varDeclaratorPath = getVariableDeclaratorPath(path8)?.node;
4912
- if (!t45.isIdentifier(varDeclaratorPath?.id)) {
5154
+ if (!t46.isIdentifier(varDeclaratorPath?.id)) {
4913
5155
  return;
4914
5156
  }
4915
5157
  const varName = varDeclaratorPath.id.name;
4916
5158
  const compRef = refBindings.componentRefs[varName];
4917
5159
  if (!compRef) return;
4918
5160
  }
4919
- node.arguments[0] = t45.identifier("null");
5161
+ node.arguments[0] = t46.identifier("null");
4920
5162
  resolveTypeParameters(ctx, path8);
4921
5163
  replaceCallName(node, REACT_API_MAP.useRef);
4922
5164
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
@@ -4941,27 +5183,27 @@ function resolveTypeParameters(ctx, path8) {
4941
5183
  const compBindingMeta = refBindings.componentRefs[idName];
4942
5184
  if (!node.typeParameters && (domBindingMeta || compBindingMeta)) {
4943
5185
  const type = compBindingMeta ? "any" : domBindingMeta.htmlType;
4944
- node.typeParameters = t45.tsTypeParameterInstantiation([t45.tsTypeReference(t45.identifier(type))]);
5186
+ node.typeParameters = t46.tsTypeParameterInstantiation([t46.tsTypeReference(t46.identifier(type))]);
4945
5187
  }
4946
5188
  }
4947
5189
  function resolveRefValueToCurrent(path8) {
4948
5190
  const { node } = path8;
4949
- if (node.computed || !t45.isIdentifier(node.property) || node.property.name !== "value") {
5191
+ if (node.computed || !t46.isIdentifier(node.property) || node.property.name !== "value") {
4950
5192
  return;
4951
5193
  }
4952
5194
  const rootPath = findRootVariablePath(path8);
4953
- if (!rootPath?.node || !t45.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
5195
+ if (!rootPath?.node || !t46.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4954
5196
  return;
4955
5197
  }
4956
5198
  const rootId = findRootIdentifier(node);
4957
- if (!t45.isIdentifier(node.object) || node.object.name !== rootId?.name) {
5199
+ if (!t46.isIdentifier(node.object) || node.object.name !== rootId?.name) {
4958
5200
  return;
4959
5201
  }
4960
5202
  node.property.name = "current";
4961
5203
  }
4962
5204
 
4963
5205
  // src/core/transform/sfc/script/syntax-processor/process/resolve-expression-memo.ts
4964
- import * as t46 from "@babel/types";
5206
+ import * as t47 from "@babel/types";
4965
5207
  function resolveExprMemo(ctx, ast) {
4966
5208
  const isScriptFile = ctx.inputType !== "sfc";
4967
5209
  return {
@@ -4973,11 +5215,11 @@ function resolveExprMemo(ctx, ast) {
4973
5215
  if (!atComponentOrHookRoot(path8, ast.program, isScriptFile)) {
4974
5216
  return false;
4975
5217
  }
4976
- if (!t46.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
5218
+ if (!t47.isVariableDeclaration(path8.parent) || path8.parent.kind !== "const") {
4977
5219
  return false;
4978
5220
  }
4979
- if (t46.isFunction(init)) return false;
4980
- if (t46.isCallExpression(init) && t46.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
5221
+ if (t47.isFunction(init)) return false;
5222
+ if (t47.isCallExpression(init) && t47.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
4981
5223
  return false;
4982
5224
  }
4983
5225
  return true;
@@ -4996,16 +5238,16 @@ function resolveExprMemo(ctx, ast) {
4996
5238
  }
4997
5239
 
4998
5240
  // src/core/transform/sfc/script/syntax-processor/process/resolve-lint-rules.ts
4999
- import * as t47 from "@babel/types";
5241
+ import * as t48 from "@babel/types";
5000
5242
  function resolveLintRules(ctx, ast) {
5001
5243
  const inScriptFile = ctx.inputType !== "sfc";
5002
5244
  return {
5003
5245
  CallExpression(path8) {
5004
5246
  const { node, parentPath } = path8;
5005
- if (!t47.isIdentifier(node.callee)) return;
5247
+ if (!t48.isIdentifier(node.callee)) return;
5006
5248
  const { name: callName } = node.callee;
5007
- const addLog = (t53) => {
5008
- logger.error(t53, {
5249
+ const addLog = (t54) => {
5250
+ logger.error(t54, {
5009
5251
  file: ctx.filename,
5010
5252
  source: ctx.scriptData.source,
5011
5253
  loc: node.loc
@@ -5050,16 +5292,27 @@ function resolveLintRules(ctx, ast) {
5050
5292
 
5051
5293
  // src/core/transform/sfc/script/syntax-processor/process/resolve-provide.ts
5052
5294
  import { generate as generate2 } from "@babel/generator";
5053
- import * as t48 from "@babel/types";
5295
+ import * as t49 from "@babel/types";
5054
5296
  function resolveProvide(ctx) {
5055
- if (ctx.inputType === "style") return {};
5297
+ const { filename, scriptData, inputType } = ctx;
5298
+ if (inputType !== "sfc") {
5299
+ return {};
5300
+ }
5056
5301
  return {
5057
5302
  CallExpression(path8) {
5058
5303
  const { node } = path8;
5304
+ if (inputType.startsWith("script")) {
5305
+ logger.error("provide() call found outside of SFC <script setup> context.", {
5306
+ file: filename,
5307
+ source: scriptData.source,
5308
+ loc: node.loc
5309
+ });
5310
+ return;
5311
+ }
5059
5312
  const providerTarget = ADAPTER_RULES.runtime[VUE_API_MAP.provide]?.target;
5060
5313
  const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
5061
5314
  if (!isProvideCall) return;
5062
- const { provide } = ctx.scriptData;
5315
+ const { provide } = scriptData;
5063
5316
  const [key, value] = node.arguments;
5064
5317
  const target = findOrCreateCtxProvider(provide);
5065
5318
  const adapter = ADAPTER_RULES.runtime[VUE_API_MAP.provide];
@@ -5082,13 +5335,13 @@ function findOrCreateCtxProvider(root) {
5082
5335
  function assignProviderValue(target, key, value) {
5083
5336
  const getRawExp = (exp) => {
5084
5337
  if (!exp) return "''";
5085
- if (t48.isStringLiteral(exp)) {
5338
+ if (t49.isStringLiteral(exp)) {
5086
5339
  return JSON.stringify(exp.value);
5087
5340
  }
5088
- if (t48.isNumericLiteral(exp)) {
5341
+ if (t49.isNumericLiteral(exp)) {
5089
5342
  return exp.value.toString();
5090
5343
  }
5091
- if (t48.isIdentifier(exp)) {
5344
+ if (t49.isIdentifier(exp)) {
5092
5345
  return exp.name;
5093
5346
  }
5094
5347
  try {
@@ -5104,16 +5357,16 @@ function assignProviderValue(target, key, value) {
5104
5357
  }
5105
5358
 
5106
5359
  // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-adapter.ts
5107
- import * as t49 from "@babel/types";
5360
+ import * as t50 from "@babel/types";
5108
5361
  function resolveRenameAdapter(ctx) {
5109
5362
  return {
5110
5363
  "CallExpression|Identifier"(path8) {
5111
5364
  const node = path8.node;
5112
- const isCallNode = t49.isCallExpression(node);
5365
+ const isCallNode = t50.isCallExpression(node);
5113
5366
  let apiName = "";
5114
- if (t49.isIdentifier(node)) {
5367
+ if (t50.isIdentifier(node)) {
5115
5368
  apiName = node.name;
5116
- } else if (isCallNode && t49.isIdentifier(node.callee)) {
5369
+ } else if (isCallNode && t50.isIdentifier(node.callee)) {
5117
5370
  apiName = node.callee.name;
5118
5371
  }
5119
5372
  if (!apiName) {
@@ -5175,7 +5428,7 @@ function isVueImportBinding2(binding) {
5175
5428
  return false;
5176
5429
  }
5177
5430
  const parent = bindingPath.parentPath?.node;
5178
- if (!parent || !t49.isImportDeclaration(parent)) {
5431
+ if (!parent || !t50.isImportDeclaration(parent)) {
5179
5432
  return false;
5180
5433
  }
5181
5434
  const source = parent.source.value.toLowerCase();
@@ -5200,17 +5453,18 @@ function processVueSyntax2(ast, ctx) {
5200
5453
  resolveDefineAsyncComponent,
5201
5454
  resolveEmitCalls,
5202
5455
  // feature: https://github.com/vureact-js/core/issues/6
5203
- resolveUseAttrs
5456
+ resolveUseAttrs,
5457
+ // feature: https://github.com/vureact-js/core/issues/56
5458
+ resolveDefineModel
5204
5459
  ]
5205
5460
  },
5206
5461
  process: {
5207
5462
  applyBabel: [
5208
5463
  resolveElementRef,
5209
- // provide 需要在 rename 之前收集并移除原始调用,避免被重命名后失配
5210
- resolveProvide,
5211
5464
  resolveRenameAdapter,
5212
- // fix:在分析函数前分析可优化为 useMemo 的顶层变量声明,
5213
- // 使得后续能够被函数依赖分析
5465
+ // fix: https://github.com/vureact-js/core/issues/46
5466
+ resolveProvide,
5467
+ // fix:在分析函数前分析可优化为 useMemo 的顶层变量声明,使得后续能够被函数依赖分析
5214
5468
  resolveExprMemo,
5215
5469
  resolveArrowFnDeps,
5216
5470
  resolveAnalysisOnlyAdapter,
@@ -5244,7 +5498,6 @@ function vueSyntaxProcessor2(ast, ctx, options) {
5244
5498
  }
5245
5499
 
5246
5500
  // src/core/transform/sfc/script/index.ts
5247
- var SCRIPT_IR_KEY = "__vureact_script_block_ir";
5248
5501
  function resolveScript2(ast, ctx) {
5249
5502
  const scriptIR = createScriptIR();
5250
5503
  setScriptIR(ctx, scriptIR);
@@ -5258,14 +5511,14 @@ function resolveScript2(ast, ctx) {
5258
5511
  return scriptIR;
5259
5512
  }
5260
5513
  function getScriptIR(ctx) {
5261
- const ir = ctx.scriptData[SCRIPT_IR_KEY];
5514
+ const ir = ctx.scriptData.__vureact_script_block_ir;
5262
5515
  if (!ir) {
5263
5516
  throw new Error("Script IR is not initialized for current compilation context");
5264
5517
  }
5265
5518
  return ir;
5266
5519
  }
5267
5520
  function setScriptIR(ctx, ir) {
5268
- ctx.scriptData[SCRIPT_IR_KEY] = ir;
5521
+ ctx.scriptData.__vureact_script_block_ir = ir;
5269
5522
  }
5270
5523
  function createScriptIR() {
5271
5524
  return {
@@ -5317,15 +5570,15 @@ function isRouterLinkBooleanCustomProp(prop) {
5317
5570
  }
5318
5571
 
5319
5572
  // src/core/transform/sfc/template/shared/prop-ir-utils.ts
5320
- import * as t51 from "@babel/types";
5573
+ import * as t52 from "@babel/types";
5321
5574
 
5322
5575
  // src/shared/string-code-types.ts
5323
5576
  import { parseExpression as parseExpression3 } from "@babel/parser";
5324
- import * as t50 from "@babel/types";
5577
+ import * as t51 from "@babel/types";
5325
5578
  var strCodeTypes = {
5326
- isIdentifier: isIdentifier29,
5579
+ isIdentifier: isIdentifier30,
5327
5580
  isSimpleExpression,
5328
- isStringLiteral: isStringLiteral13
5581
+ isStringLiteral: isStringLiteral14
5329
5582
  };
5330
5583
  function isSimpleExpression(code, excludeVar = false) {
5331
5584
  let node;
@@ -5334,38 +5587,38 @@ function isSimpleExpression(code, excludeVar = false) {
5334
5587
  } catch {
5335
5588
  return false;
5336
5589
  }
5337
- if (t50.isLiteral(node)) {
5590
+ if (t51.isLiteral(node)) {
5338
5591
  return true;
5339
5592
  }
5340
- if (!excludeVar && t50.isIdentifier(node)) {
5593
+ if (!excludeVar && t51.isIdentifier(node)) {
5341
5594
  return true;
5342
5595
  }
5343
- if (t50.isMemberExpression(node)) {
5344
- return isSimpleExpression(node.object) && t50.isIdentifier(node.property);
5596
+ if (t51.isMemberExpression(node)) {
5597
+ return isSimpleExpression(node.object) && t51.isIdentifier(node.property);
5345
5598
  }
5346
- if (t50.isObjectExpression(node) || t50.isArrayExpression(node)) {
5599
+ if (t51.isObjectExpression(node) || t51.isArrayExpression(node)) {
5347
5600
  return false;
5348
5601
  }
5349
- if (t50.isCallExpression(node) || t50.isAssignmentExpression(node)) {
5602
+ if (t51.isCallExpression(node) || t51.isAssignmentExpression(node)) {
5350
5603
  return false;
5351
5604
  }
5352
- if (t50.isBinaryExpression(node) || t50.isUnaryExpression(node)) {
5605
+ if (t51.isBinaryExpression(node) || t51.isUnaryExpression(node)) {
5353
5606
  return true;
5354
5607
  }
5355
5608
  return false;
5356
5609
  }
5357
- function isIdentifier29(code) {
5610
+ function isIdentifier30(code) {
5358
5611
  try {
5359
5612
  const node = parseExpression3(code);
5360
- return t50.isIdentifier(node);
5613
+ return t51.isIdentifier(node);
5361
5614
  } catch {
5362
5615
  return false;
5363
5616
  }
5364
5617
  }
5365
- function isStringLiteral13(code) {
5618
+ function isStringLiteral14(code) {
5366
5619
  try {
5367
5620
  const node = parseExpression3(code);
5368
- return t50.isStringLiteral(node);
5621
+ return t51.isStringLiteral(node);
5369
5622
  } catch {
5370
5623
  return false;
5371
5624
  }
@@ -5508,11 +5761,11 @@ function resolvePropAsBabelExp(ir, ctx) {
5508
5761
  const rule = ADAPTER_RULES.runtime;
5509
5762
  const setNameIdentifier = (target, valueName) => {
5510
5763
  target.content = valueName;
5511
- target.ast = t51.jsxIdentifier(valueName);
5764
+ target.ast = t52.jsxIdentifier(valueName);
5512
5765
  };
5513
- const setValueExpression = (target, content, isStringLiteral14) => {
5766
+ const setValueExpression = (target, content, isStringLiteral15) => {
5514
5767
  target.content = content;
5515
- target.ast = resolveStringExpr(content, ctx, isStringLiteral14);
5768
+ target.ast = resolveStringExpr(content, ctx, isStringLiteral15);
5516
5769
  };
5517
5770
  const createRuntimeCall = (fnName, args) => {
5518
5771
  const fnArgs = args.filter(Boolean).join(",");
@@ -5521,13 +5774,13 @@ function resolvePropAsBabelExp(ir, ctx) {
5521
5774
  const safeTypeAssertion = isTs ? valIsUndef ? "as never" : "" : "";
5522
5775
  return `${fnName}(${fnArgs}) ${safeTypeAssertion}`;
5523
5776
  };
5524
- const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral14) => {
5777
+ const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral15) => {
5525
5778
  if (setName && nameIdentifier) {
5526
5779
  setNameIdentifier(nameExp, nameIdentifier);
5527
5780
  }
5528
5781
  const dir = rule.dir;
5529
5782
  recordImport(ctx, dir.package, dir.target);
5530
- setValueExpression(value.babelExp, expression, isStringLiteral14);
5783
+ setValueExpression(value.babelExp, expression, isStringLiteral15);
5531
5784
  };
5532
5785
  if (ir.isKeyLessVBind) {
5533
5786
  const dirKeyless = rule.dirKeyless;
@@ -5948,12 +6201,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
5948
6201
  content = propsIR.value.content = parseStyleString(content);
5949
6202
  }
5950
6203
  if (isDynamic) {
5951
- const isStringLiteral14 = strCodeTypes.isStringLiteral(content);
5952
- if (isStringLiteral14) {
6204
+ const isStringLiteral15 = strCodeTypes.isStringLiteral(content);
6205
+ if (isStringLiteral15) {
5953
6206
  content = normalizeString(content);
5954
6207
  propsIR.value.content = content;
5955
6208
  }
5956
- propsIR.value.isStringLiteral = isStringLiteral14;
6209
+ propsIR.value.isStringLiteral = isStringLiteral15;
5957
6210
  }
5958
6211
  const existing = findSameProp(nodeIR.props, propsIR);
5959
6212
  if (existing) {
@@ -6258,7 +6511,7 @@ function applyValueModifiers(valueExp, modifiers) {
6258
6511
  }
6259
6512
 
6260
6513
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-on.ts
6261
- import * as t52 from "@babel/types";
6514
+ import * as t53 from "@babel/types";
6262
6515
  function resolveVOn(directive, ir, ctx, nodeIR) {
6263
6516
  const arg = directive.arg;
6264
6517
  const exp = directive.exp;
@@ -6316,10 +6569,10 @@ function resolveHandler(handlerContent, ctx, modifiers) {
6316
6569
  return handler;
6317
6570
  }
6318
6571
  function isConsoleCall(expr) {
6319
- return t52.isCallExpression(expr) && t52.isMemberExpression(expr.callee) && t52.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6572
+ return t53.isCallExpression(expr) && t53.isMemberExpression(expr.callee) && t53.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6320
6573
  }
6321
6574
  function isFnReference(expr) {
6322
- return t52.isIdentifier(expr) || t52.isMemberExpression(expr) || t52.isFunction(expr);
6575
+ return t53.isIdentifier(expr) || t53.isMemberExpression(expr) || t53.isFunction(expr);
6323
6576
  }
6324
6577
 
6325
6578
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
@@ -6672,7 +6925,7 @@ function transform(ast, ctx, options) {
6672
6925
  }
6673
6926
 
6674
6927
  // package.json
6675
- var version = "1.8.4";
6928
+ var version = "1.9.0";
6676
6929
  var bin = {
6677
6930
  vureact: "bin/vureact.js"
6678
6931
  };
@@ -7226,7 +7479,8 @@ var CompilationContext = class {
7226
7479
  refField: "expose"
7227
7480
  },
7228
7481
  declaredOptions: {},
7229
- source: ""
7482
+ source: "",
7483
+ __vureact_script_block_ir: void 0
7230
7484
  },
7231
7485
  styleData: {
7232
7486
  filePath: ""