@vureact/compiler-core 1.1.0 → 1.2.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.1.0
2
+ * @vureact/compiler-core v1.1.1
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -26,93 +26,349 @@ function executePlugins(map, result, ctx) {
26
26
  // src/core/codegen/component/jsx/syntax-processor/postprocess/build-ctx-provider.ts
27
27
  import * as t10 from "@babel/types";
28
28
 
29
- // src/consts/adapters-map.ts
30
- var ADAPTER_COMPS = {
31
- KeepAlive: "KeepAlive",
32
- Suspense: "Suspense",
33
- Teleport: "Teleport",
34
- Component: "Component",
35
- Provider: "Provider",
36
- // 实际是 Vue 的 provide 方法,为了命名统一采用 Provide
37
- Transition: "Transition",
38
- TransitionGroup: "TransitionGroup"
39
- };
40
- var ADAPTER_UTILS_MAP = {
41
- dir: "dir",
42
- dirCls: "dir.cls",
43
- dirKeyless: "dir.keyless",
44
- dirOn: "dir.on",
45
- dirStyle: "dir.style",
46
- nextTick: "nextTick"
29
+ // src/consts/other.ts
30
+ var PACKAGE_NAME = {
31
+ react: "react",
32
+ runtime: "@vureact/runtime-core",
33
+ router: "@vureact/router"
47
34
  };
48
- var ADAPTER_ROUTER_COMPS = {
49
- RouterLink: "RouterLink",
50
- RouterView: "RouterView"
35
+ var STYLE_MODULE_NAME = "$style";
36
+ var MACRO_API_NAMES = {
37
+ props: "defineProps",
38
+ emits: "defineEmits",
39
+ slots: "defineSlots",
40
+ options: "defineOptions",
41
+ expose: "defineExpose"
51
42
  };
52
- var ADAPTER_HOOKS = {
53
- renameOnly: {
54
- pure: {
55
- useActived: "useActived",
56
- useDeactivated: "useDeactivated",
57
- onBeforeMount: "useBeforeMount",
58
- onBeforeUnMount: "useBeforeUnMount",
59
- onMounted: "useMounted",
60
- onUnmounted: "useUnmounted"
43
+ var DOLLAR_IDENTIFIERS = [
44
+ "$data",
45
+ "$props",
46
+ "$el",
47
+ "$options",
48
+ "$parent",
49
+ "$root",
50
+ "$slots",
51
+ "$refs",
52
+ "$attrs",
53
+ "$emit",
54
+ "$watch",
55
+ "$forceUpdate",
56
+ "$nextTick",
57
+ "$router",
58
+ "$route",
59
+ "$store",
60
+ "$pinia",
61
+ "$event"
62
+ ];
63
+ var VUE_PACKAGES = [
64
+ "vue",
65
+ "vite",
66
+ "pinia",
67
+ "nuxt",
68
+ // 不需要带到 React 项目中
69
+ "@vureact/compiler-core"
70
+ ];
71
+
72
+ // src/consts/adapters-map.ts
73
+ var ADAPTER_RULES = {
74
+ // =============== [React] ===============
75
+ react: {
76
+ // =============== Hooks ===============
77
+ useTemplateRef: {
78
+ target: "useRef",
79
+ package: PACKAGE_NAME.react,
80
+ type: "none"
61
81
  },
62
- effectful: {
63
- ref: "useVRef",
64
- reactive: "useReactive",
65
- computed: "useComputed",
66
- readonly: "useReadonly",
67
- toRef: "useToVRef",
68
- toRefs: "useToVRefs",
69
- toRaw: "useToRaw",
70
- inject: "useInject",
71
- watch: "useWatch",
72
- shallowRef: "useShallowRef",
73
- shallowReactive: "useShallowReactive",
74
- shallowReadonly: "useShallowReadonly",
75
- isRef: "isRef",
76
- isProxy: "isProxy",
77
- isReactive: "isReactive"
82
+ defineExpose: {
83
+ target: "useImperativeHandle",
84
+ package: PACKAGE_NAME.react,
85
+ type: "none"
78
86
  }
79
87
  },
80
- transform: {
81
- pure: {
82
- useTemplateRef: "useRef",
83
- watchEffect: {
84
- watchEffect: "useWatchEffect",
85
- watchPostEffect: "useWatchPostEffect",
86
- watchSyncEffect: "useWatchSyncEffect"
87
- },
88
- lifecycle: {
89
- onBeforeUpdate: "useBeforeUpdate",
90
- onUpdated: "useUpdated"
91
- }
88
+ // ============== [VuReact Runtime Core] ===============
89
+ runtime: {
90
+ // =============== Components ===============
91
+ KeepAlive: {
92
+ target: "KeepAlive",
93
+ package: PACKAGE_NAME.runtime,
94
+ type: "rename"
92
95
  },
93
- effectful: {}
94
- }
95
- };
96
- var ADAPTER_ROUTER_APIS = {
97
- renameOnly: {
98
- pure: {
99
- createRouter: "createRouter",
100
- onBeforeRouteLeave: "useBeforeRouteLeave",
101
- onBeforeRouteUpdate: "useBeforeRouteUpdate",
102
- onBeforeRouteEnter: "useBeforeRouteEnter"
96
+ Suspense: {
97
+ target: "Suspense",
98
+ package: PACKAGE_NAME.runtime,
99
+ type: "rename"
100
+ },
101
+ Teleport: {
102
+ target: "Teleport",
103
+ package: PACKAGE_NAME.runtime,
104
+ type: "rename"
105
+ },
106
+ Component: {
107
+ target: "Component",
108
+ package: PACKAGE_NAME.runtime,
109
+ type: "rename"
110
+ },
111
+ provide: {
112
+ target: "Provider",
113
+ package: PACKAGE_NAME.runtime,
114
+ type: "rename"
115
+ },
116
+ Transition: {
117
+ target: "Transition",
118
+ package: PACKAGE_NAME.runtime,
119
+ type: "rename"
120
+ },
121
+ TransitionGroup: {
122
+ target: "TransitionGroup",
123
+ package: PACKAGE_NAME.runtime,
124
+ type: "rename"
125
+ },
126
+ // =============== Hooks ===============
127
+ useActived: {
128
+ target: "useActived",
129
+ package: PACKAGE_NAME.runtime,
130
+ type: "rename"
131
+ },
132
+ useDeactivated: {
133
+ target: "useDeactivated",
134
+ package: PACKAGE_NAME.runtime,
135
+ type: "rename"
136
+ },
137
+ onBeforeMount: {
138
+ target: "useBeforeMount",
139
+ package: PACKAGE_NAME.runtime,
140
+ type: "rename"
141
+ },
142
+ onBeforeUnMount: {
143
+ target: "useBeforeUnMount",
144
+ package: PACKAGE_NAME.runtime,
145
+ type: "rename"
146
+ },
147
+ onMounted: {
148
+ target: "useMounted",
149
+ package: PACKAGE_NAME.runtime,
150
+ type: "rename"
151
+ },
152
+ onUnmounted: {
153
+ target: "useUnmounted",
154
+ package: PACKAGE_NAME.runtime,
155
+ type: "rename"
156
+ },
157
+ onBeforeUpdate: {
158
+ target: "useBeforeUpdate",
159
+ package: PACKAGE_NAME.runtime,
160
+ type: "analyzed-deps"
161
+ },
162
+ onUpdated: {
163
+ target: "useUpdated",
164
+ package: PACKAGE_NAME.runtime,
165
+ type: "analyzed-deps"
166
+ },
167
+ ref: {
168
+ target: "useVRef",
169
+ package: PACKAGE_NAME.runtime,
170
+ type: "rename",
171
+ isTrackable: true
172
+ },
173
+ reactive: {
174
+ target: "useReactive",
175
+ package: PACKAGE_NAME.runtime,
176
+ type: "rename",
177
+ isTrackable: true
178
+ },
179
+ computed: {
180
+ target: "useComputed",
181
+ package: PACKAGE_NAME.runtime,
182
+ type: "rename",
183
+ isTrackable: true
184
+ },
185
+ readonly: {
186
+ target: "useReadonly",
187
+ package: PACKAGE_NAME.runtime,
188
+ type: "rename",
189
+ isTrackable: true
190
+ },
191
+ toRef: {
192
+ target: "useToVRef",
193
+ package: PACKAGE_NAME.runtime,
194
+ type: "rename",
195
+ isTrackable: true
196
+ },
197
+ toRefs: {
198
+ target: "useToVRefs",
199
+ package: PACKAGE_NAME.runtime,
200
+ type: "rename",
201
+ isTrackable: true
202
+ },
203
+ toRaw: {
204
+ target: "useToRaw",
205
+ package: PACKAGE_NAME.runtime,
206
+ type: "rename"
207
+ },
208
+ inject: {
209
+ target: "useInject",
210
+ package: PACKAGE_NAME.runtime,
211
+ type: "rename",
212
+ isTrackable: true
213
+ },
214
+ shallowRef: {
215
+ target: "useShallowRef",
216
+ package: PACKAGE_NAME.runtime,
217
+ type: "rename",
218
+ isTrackable: true
219
+ },
220
+ shallowReactive: {
221
+ target: "useShallowReactive",
222
+ package: PACKAGE_NAME.runtime,
223
+ type: "rename",
224
+ isTrackable: true
225
+ },
226
+ shallowReadonly: {
227
+ target: "useShallowReadonly",
228
+ package: PACKAGE_NAME.runtime,
229
+ type: "rename",
230
+ isTrackable: true
231
+ },
232
+ isRef: {
233
+ target: "isRef",
234
+ package: PACKAGE_NAME.runtime,
235
+ type: "rename",
236
+ isTrackable: true
237
+ },
238
+ isProxy: {
239
+ target: "isProxy",
240
+ package: PACKAGE_NAME.runtime,
241
+ type: "rename",
242
+ isTrackable: true
243
+ },
244
+ isReactive: {
245
+ target: "isReactive",
246
+ package: PACKAGE_NAME.runtime,
247
+ type: "rename",
248
+ isTrackable: true
249
+ },
250
+ watch: {
251
+ target: "useWatch",
252
+ package: PACKAGE_NAME.runtime,
253
+ type: "rename"
254
+ },
255
+ watchEffect: {
256
+ target: "useWatchEffect",
257
+ package: PACKAGE_NAME.runtime,
258
+ type: "analyzed-deps"
259
+ },
260
+ watchPostEffect: {
261
+ target: "useWatchPostEffect",
262
+ package: PACKAGE_NAME.runtime,
263
+ type: "analyzed-deps"
264
+ },
265
+ watchSyncEffect: {
266
+ target: "useWatchSyncEffect",
267
+ package: PACKAGE_NAME.runtime,
268
+ type: "analyzed-deps"
269
+ },
270
+ // =============== Directive Utils ===============
271
+ dir: {
272
+ target: "dir",
273
+ package: PACKAGE_NAME.runtime,
274
+ type: "rename"
103
275
  },
104
- effectful: {
105
- useRoute: "useRoute",
106
- useRouter: "useRouter",
107
- useLink: "useLink"
276
+ dirCls: {
277
+ target: "dir.cls",
278
+ package: PACKAGE_NAME.runtime,
279
+ type: "rename"
280
+ },
281
+ dirKeyless: {
282
+ target: "dir.keyless",
283
+ package: PACKAGE_NAME.runtime,
284
+ type: "rename"
285
+ },
286
+ dirOn: {
287
+ target: "dir.On",
288
+ package: PACKAGE_NAME.runtime,
289
+ type: "rename"
290
+ },
291
+ dirStyle: {
292
+ target: "dir.style",
293
+ package: PACKAGE_NAME.runtime,
294
+ type: "rename"
295
+ },
296
+ nextTick: {
297
+ target: "nextTick",
298
+ package: PACKAGE_NAME.runtime,
299
+ type: "rename"
108
300
  }
109
301
  },
110
- transform: {
111
- pure: {},
112
- effectful: {}
302
+ // =================== [VuReact Router] ===================
303
+ router: {
304
+ // =============== Components ===============
305
+ RouterLink: {
306
+ target: "RouterLink",
307
+ package: PACKAGE_NAME.router,
308
+ type: "rename"
309
+ },
310
+ RouterView: {
311
+ target: "RouterView",
312
+ package: PACKAGE_NAME.router,
313
+ type: "rename"
314
+ },
315
+ createRouter: {
316
+ target: "createRouter",
317
+ package: PACKAGE_NAME.router,
318
+ type: "rename"
319
+ },
320
+ // =============== Hooks ===============
321
+ useRoute: {
322
+ target: "useRoute",
323
+ package: PACKAGE_NAME.router,
324
+ type: "rename",
325
+ isTrackable: true
326
+ },
327
+ useRouter: {
328
+ target: "useRouter",
329
+ package: PACKAGE_NAME.router,
330
+ type: "rename",
331
+ isTrackable: true
332
+ },
333
+ useLink: {
334
+ target: "useLink",
335
+ package: PACKAGE_NAME.router,
336
+ type: "rename",
337
+ isTrackable: true
338
+ },
339
+ onBeforeRouteLeave: {
340
+ target: "useBeforeRouteLeave",
341
+ package: PACKAGE_NAME.router,
342
+ type: "rename"
343
+ },
344
+ onBeforeRouteUpdate: {
345
+ target: "useBeforeRouteUpdate",
346
+ package: PACKAGE_NAME.router,
347
+ type: "rename"
348
+ },
349
+ onBeforeRouteEnter: {
350
+ target: "useBeforeRouteEnter",
351
+ package: PACKAGE_NAME.router,
352
+ type: "rename"
353
+ }
113
354
  }
114
355
  };
115
356
 
357
+ // src/consts/vue-api-map.ts
358
+ var VUE_API_MAP = {
359
+ ref: "ref",
360
+ provide: "provide",
361
+ watch: "watch",
362
+ watchEffect: "watchEffect",
363
+ watchPostEffect: "watchPostEffect",
364
+ watchSyncEffect: "watchSyncEffect",
365
+ useTemplateRef: "useTemplateRef",
366
+ defineAsyncComponent: "defineAsyncComponent",
367
+ DynamicComponent: "Component",
368
+ Transition: "Transition",
369
+ RouterLink: "RouterLink"
370
+ };
371
+
116
372
  // src/core/codegen/component/jsx/utils/jsx-element-utils.ts
117
373
  import * as t from "@babel/types";
118
374
  function createJsxElement(tag, props, children, selfClosing) {
@@ -705,7 +961,8 @@ function buildCtxProviderNode(nodeIR, ctx, children) {
705
961
  buildJsxExpressionNode(t10.identifier(value))
706
962
  );
707
963
  void ctx;
708
- return createJsxElement(ADAPTER_COMPS.Provider, [keyProp, valueProp], childNodes);
964
+ const adpater = ADAPTER_RULES.runtime[VUE_API_MAP.provide];
965
+ return createJsxElement(adpater.target, [keyProp, valueProp], childNodes);
709
966
  }
710
967
 
711
968
  // src/core/codegen/component/jsx/syntax-processor/postprocess/build-root-jsx.ts
@@ -783,9 +1040,11 @@ var REACT_API_MAP = {
783
1040
  lazy: "lazy",
784
1041
  memo: "memo",
785
1042
  useRef: "useRef",
786
- useCallback: "useCallback",
787
1043
  useMemo: "useMemo",
788
- ReactNode: "ReactNode"
1044
+ ReactNode: "ReactNode",
1045
+ forwardRef: "forwardRef",
1046
+ useCallback: "useCallback",
1047
+ useImperativeHandle: "useImperativeHandle"
789
1048
  };
790
1049
 
791
1050
  // src/utils/camelCase.ts
@@ -825,10 +1084,13 @@ function buildComponent(scriptIR, ctx, state) {
825
1084
  const hasProps = getHasProps(propsTSIface.propsTypes) || getHasProps(propsTSIface.emitTypes) || getHasProps(propsTSIface.slotTypes);
826
1085
  const shouldMemo = scriptIR !== null || hasProps;
827
1086
  const jsxStatement = t12.returnStatement(state.jsx || t12.nullLiteral());
828
- const component = !shouldMemo ? resolveComponent(jsxStatement, ctx) : resolveMemoComponent(scriptIR.statement.local, jsxStatement, ctx);
1087
+ const component = !shouldMemo ? resolvePureUIComponent(jsxStatement, ctx) : resolveMemoComponent(scriptIR.statement.local, jsxStatement, ctx);
829
1088
  state.component = component;
830
1089
  }
831
- function resolveComponent(jsxStmt, ctx) {
1090
+ function getHasProps(list) {
1091
+ return list.length > 0;
1092
+ }
1093
+ function resolvePureUIComponent(jsxStmt, ctx) {
832
1094
  return t12.variableDeclaration("const", [
833
1095
  t12.variableDeclarator(
834
1096
  resolveComponentName(ctx),
@@ -838,12 +1100,14 @@ function resolveComponent(jsxStmt, ctx) {
838
1100
  }
839
1101
  function resolveMemoComponent(local, jsxStmt, ctx) {
840
1102
  const name = resolveComponentName(ctx);
841
- const param = resolveParam(ctx);
842
- const component = t12.arrowFunctionExpression(
843
- !param ? [] : [param],
844
- t12.blockStatement(resolveStatements(local, jsxStmt))
845
- );
846
- const memoCall = t12.callExpression(t12.identifier(REACT_API_MAP.memo), [component]);
1103
+ const param = resolvePropsParam(ctx);
1104
+ const body = t12.blockStatement(resolveLocalStatements(local, jsxStmt));
1105
+ const component = resolveComponent(param, body, ctx);
1106
+ let compFn = component;
1107
+ if (ctx.scriptData.forwardRef.enabled) {
1108
+ compFn = resolveForwardRef(body, ctx);
1109
+ }
1110
+ const memoCall = t12.callExpression(t12.identifier(REACT_API_MAP.memo), [compFn]);
847
1111
  return t12.variableDeclaration("const", [t12.variableDeclarator(name, memoCall)]);
848
1112
  }
849
1113
  function resolveComponentName(ctx) {
@@ -860,7 +1124,52 @@ function resolveComponentName(ctx) {
860
1124
  }
861
1125
  return t12.identifier(name);
862
1126
  }
863
- function resolveParam(ctx) {
1127
+ function resolveLocalStatements(local, jsx) {
1128
+ const stmts = [jsx];
1129
+ if (!local) return stmts;
1130
+ if (typeof local === "object" && "program" in local) {
1131
+ const program3 = local.program;
1132
+ if (program3?.body?.length) {
1133
+ return [...program3.body, jsx];
1134
+ }
1135
+ }
1136
+ return stmts;
1137
+ }
1138
+ function resolveComponent(param, body, ctx) {
1139
+ const {
1140
+ scriptData: { forwardRef }
1141
+ } = ctx;
1142
+ if (forwardRef.enabled) {
1143
+ return resolveForwardRef(body, ctx);
1144
+ }
1145
+ const baseComponent = t12.arrowFunctionExpression(!param ? [] : [param], body);
1146
+ return baseComponent;
1147
+ }
1148
+ function resolveForwardRef(body, ctx) {
1149
+ const {
1150
+ propField,
1151
+ scriptData: { forwardRef, lang }
1152
+ } = ctx;
1153
+ const params = [t12.identifier(forwardRef.refField)];
1154
+ const propsId = resolvePropsParam(ctx);
1155
+ const callExpr = t12.callExpression(t12.identifier(REACT_API_MAP.forwardRef), [
1156
+ t12.arrowFunctionExpression(params, body)
1157
+ ]);
1158
+ if (lang.startsWith("ts")) {
1159
+ const types = [t12.tsAnyKeyword()];
1160
+ if (propsId) {
1161
+ const propsType = propsId?.typeAnnotation?.typeAnnotation;
1162
+ types.push(propsType || t12.tsAnyKeyword());
1163
+ }
1164
+ callExpr.typeParameters = t12.tsTypeParameterInstantiation(types);
1165
+ }
1166
+ if (propsId) {
1167
+ propsId.typeAnnotation = null;
1168
+ params.unshift(propsId);
1169
+ }
1170
+ return callExpr;
1171
+ }
1172
+ function resolvePropsParam(ctx) {
864
1173
  const { propField, scriptData } = ctx;
865
1174
  const { propsTSIface } = scriptData;
866
1175
  const propsIdentifier = t12.identifier(propField);
@@ -877,20 +1186,6 @@ function resolveParam(ctx) {
877
1186
  propsIdentifier.typeAnnotation = t12.tsTypeAnnotation(t12.tsTypeReference(typeIdentifier));
878
1187
  return propsIdentifier;
879
1188
  }
880
- function resolveStatements(local, jsx) {
881
- const stmts = [jsx];
882
- if (!local) return stmts;
883
- if (typeof local === "object" && "program" in local) {
884
- const program3 = local.program;
885
- if (program3?.body?.length) {
886
- return [...program3.body, jsx];
887
- }
888
- }
889
- return stmts;
890
- }
891
- function getHasProps(list) {
892
- return list.length > 0;
893
- }
894
1189
 
895
1190
  // src/core/codegen/component/script/syntax-processor/process/build-program-preamble.ts
896
1191
  function buildProgramPreamble(nodeIR, ctx, state) {
@@ -1234,11 +1529,6 @@ var HTML_TAG_TYPES = {
1234
1529
  frame: "HTMLFrameElement"
1235
1530
  };
1236
1531
 
1237
- // src/consts/vue-api-map.ts
1238
- var VUE_API_MAP = {
1239
- useTemplateRef: "useTemplateRef"
1240
- };
1241
-
1242
1532
  // src/consts/reactive-type-map.ts
1243
1533
  var REACTIVE_TYPE_MAP = {
1244
1534
  ref: "ref",
@@ -1294,7 +1584,7 @@ function collectReactiveBindings(node, ctx) {
1294
1584
  if (!reactiveStateApis.has(source)) return;
1295
1585
  const varName = node.id.name;
1296
1586
  const value = init.arguments[0];
1297
- if (source === "defineProps") {
1587
+ if (source === MACRO_API_NAMES.props) {
1298
1588
  ctx.propField = varName;
1299
1589
  }
1300
1590
  reactiveBindings[varName] = {
@@ -1311,55 +1601,13 @@ function collectRefBindings(node, ctx) {
1311
1601
  if (callee.name !== VUE_API_MAP.useTemplateRef) return;
1312
1602
  const idName = node.id.name;
1313
1603
  const tag = init.arguments[0]?.value;
1314
- refBindings[idName] = {
1604
+ refBindings.domRefs[idName] = {
1315
1605
  tag,
1316
1606
  htmlType: HTML_TAG_TYPES[tag] || "HTMLElement",
1317
1607
  name: idName
1318
1608
  };
1319
1609
  }
1320
1610
 
1321
- // src/consts/other.ts
1322
- var PACKAGE_NAME = {
1323
- react: "react",
1324
- runtime: "@vureact/runtime-core",
1325
- router: "@vureact/router"
1326
- };
1327
- var STYLE_MODULE_NAME = "$style";
1328
- var MACRO_API_NAMES = {
1329
- props: "defineProps",
1330
- emits: "defineEmits",
1331
- slots: "defineSlots",
1332
- options: "defineOptions"
1333
- };
1334
- var DOLLAR_IDENTIFIERS = [
1335
- "$data",
1336
- "$props",
1337
- "$el",
1338
- "$options",
1339
- "$parent",
1340
- "$root",
1341
- "$slots",
1342
- "$refs",
1343
- "$attrs",
1344
- "$emit",
1345
- "$watch",
1346
- "$forceUpdate",
1347
- "$nextTick",
1348
- "$router",
1349
- "$route",
1350
- "$store",
1351
- "$pinia",
1352
- "$event"
1353
- ];
1354
- var VUE_PACKAGES = [
1355
- "vue",
1356
- "vite",
1357
- "pinia",
1358
- "nuxt",
1359
- // 不需要带到 React 项目中
1360
- "@vureact/compiler-core"
1361
- ];
1362
-
1363
1611
  // src/plugins/postcss.ts
1364
1612
  import postcss from "postcss";
1365
1613
  function processScopedWithPostCss(input, hash) {
@@ -1411,6 +1659,7 @@ function resolveLessSass(source, options) {
1411
1659
  } else if (lang === "scss" || lang === "sass") {
1412
1660
  result.code = resolveSassSync(source, filename);
1413
1661
  }
1662
+ result.code = resolveImportExtensions(result.code);
1414
1663
  return result;
1415
1664
  }
1416
1665
  function resolveLessSync(source, filename) {
@@ -1462,6 +1711,12 @@ function resolveSassSync(source, filename) {
1462
1711
  const result = sass.compileString(source, options);
1463
1712
  return result.css;
1464
1713
  }
1714
+ function resolveImportExtensions(code) {
1715
+ if (code.includes(".less") || code.includes(".scss") || code.includes(".sass")) {
1716
+ return code.replaceAll(/\.(less|scss|sass)(?=['")])/g, ".css");
1717
+ }
1718
+ return code;
1719
+ }
1465
1720
 
1466
1721
  // src/core/parse/sfc/process/resolve-styles.ts
1467
1722
  function resolveStyles(descriptor, ctx, result) {
@@ -1991,66 +2246,13 @@ function collectLocalStatements(ctx, ast) {
1991
2246
  scriptIR.statement.local = ast;
1992
2247
  }
1993
2248
 
1994
- // src/core/transform/sfc/script/syntax-processor/process/resolve-template-ref.ts
2249
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
1995
2250
  import * as t20 from "@babel/types";
1996
- function resolveTemplateRef(ctx) {
1997
- if (ctx.inputType !== "sfc") return {};
2251
+ function resolveDefineAsyncComponent(ctx) {
1998
2252
  return {
1999
2253
  CallExpression(path7) {
2000
2254
  const { node } = path7;
2001
- if (!isCalleeNamed(node, VUE_API_MAP.useTemplateRef)) return;
2002
- addTypeParam(ctx, path7);
2003
- replaceValue(node);
2004
- replaceCallName(node, REACT_API_MAP.useRef);
2005
- recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
2006
- },
2007
- MemberExpression(path7) {
2008
- const { node } = path7;
2009
- if (node.computed || !t20.isIdentifier(node.property) || node.property.name !== "value") {
2010
- return;
2011
- }
2012
- const rootPath = findRootVariablePath(path7);
2013
- if (!rootPath?.node || !t20.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
2014
- return;
2015
- }
2016
- const rootId = findRootIdentifier(node);
2017
- if (!t20.isIdentifier(node.object) || node.object.name !== rootId?.name) {
2018
- return;
2019
- }
2020
- node.property.name = "current";
2021
- }
2022
- };
2023
- }
2024
- function replaceValue(node) {
2025
- const initVal = node.arguments[0];
2026
- const newVal = t20.identifier("null");
2027
- newVal.start = initVal?.start;
2028
- newVal.end = initVal?.end;
2029
- newVal.loc = initVal?.loc;
2030
- node.arguments[0] = newVal;
2031
- }
2032
- function addTypeParam(ctx, path7) {
2033
- const { templateData, scriptData } = ctx;
2034
- const { node, parent } = path7;
2035
- if (!scriptData.lang.startsWith("ts") && !t20.isVariableDeclarator(parent)) {
2036
- return;
2037
- }
2038
- const idName = parent.id.name;
2039
- const bindingMeta = templateData.refBindings[idName];
2040
- if (!node.typeParameters && bindingMeta) {
2041
- node.typeParameters = t20.tsTypeParameterInstantiation([
2042
- t20.tsTypeReference(t20.identifier(bindingMeta.htmlType))
2043
- ]);
2044
- }
2045
- }
2046
-
2047
- // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-async-component.ts
2048
- import * as t21 from "@babel/types";
2049
- function resolveAsyncComponent(ctx) {
2050
- return {
2051
- CallExpression(path7) {
2052
- const { node } = path7;
2053
- if (!isCalleeNamed(node, "defineAsyncComponent")) {
2255
+ if (!isCalleeNamed(node, VUE_API_MAP.defineAsyncComponent)) {
2054
2256
  return;
2055
2257
  }
2056
2258
  const [arg] = node.arguments;
@@ -2061,11 +2263,11 @@ function resolveAsyncComponent(ctx) {
2061
2263
  };
2062
2264
  }
2063
2265
  function checkIsUnsupported(ctx, arg) {
2064
- if (t21.isFunction(arg)) {
2266
+ if (t20.isFunction(arg)) {
2065
2267
  checkIsDynamicImport(ctx, arg);
2066
- } else if (t21.isObjectExpression(arg)) {
2268
+ } else if (t20.isObjectExpression(arg)) {
2067
2269
  const { value } = arg.properties.find(
2068
- (p) => t21.isObjectProperty(p) && t21.isIdentifier(p.key) && p.key.name === "loader"
2270
+ (p) => t20.isObjectProperty(p) && t20.isIdentifier(p.key) && p.key.name === "loader"
2069
2271
  );
2070
2272
  checkIsDynamicImport(ctx, value);
2071
2273
  if (arg.properties.length > 1) {
@@ -2076,7 +2278,7 @@ function checkIsUnsupported(ctx, arg) {
2076
2278
  function checkIsDynamicImport(ctx, node) {
2077
2279
  const { scriptData, filename } = ctx;
2078
2280
  const warnIsNotImport = (target) => {
2079
- if (!target || !t21.isImport(target)) {
2281
+ if (!target || !t20.isImport(target)) {
2080
2282
  logger.error(
2081
2283
  `Only ES module dynamic imports are supported. You must use and return import('...').`,
2082
2284
  {
@@ -2087,20 +2289,20 @@ function checkIsDynamicImport(ctx, node) {
2087
2289
  );
2088
2290
  }
2089
2291
  };
2090
- if (t21.isFunction(node)) {
2292
+ if (t20.isFunction(node)) {
2091
2293
  checkIsDynamicImport(ctx, node.body);
2092
2294
  return;
2093
2295
  }
2094
- if (t21.isBlockStatement(node)) {
2296
+ if (t20.isBlockStatement(node)) {
2095
2297
  const [returnSmt] = node.body;
2096
- if (t21.isReturnStatement(returnSmt)) {
2298
+ if (t20.isReturnStatement(returnSmt)) {
2097
2299
  warnIsNotImport(returnSmt.argument);
2098
2300
  }
2099
2301
  return;
2100
2302
  }
2101
- if (t21.isCallExpression(node)) {
2303
+ if (t20.isCallExpression(node)) {
2102
2304
  warnIsNotImport(node.callee);
2103
- if (t21.isStringLiteral(node.arguments[0])) {
2305
+ if (t20.isStringLiteral(node.arguments[0])) {
2104
2306
  replaceVueSuffix(ctx, node.arguments[0]);
2105
2307
  }
2106
2308
  return;
@@ -2148,61 +2350,64 @@ function pushToGlobalScope(path7, ctx) {
2148
2350
  scriptIR.statement.global.push(fullNode);
2149
2351
  }
2150
2352
 
2151
- // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-emit-calls.ts
2353
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
2152
2354
  import * as t22 from "@babel/types";
2153
- function resolveEmitCalls(ctx) {
2355
+
2356
+ // src/core/transform/sfc/script/shared/hook-creator.ts
2357
+ import * as t21 from "@babel/types";
2358
+ function createUseCallback(body, deps) {
2359
+ return t21.callExpression(t21.identifier(REACT_API_MAP.useCallback), [
2360
+ body,
2361
+ deps ?? t21.arrayExpression([])
2362
+ ]);
2363
+ }
2364
+ function createUseMemo(body, deps) {
2365
+ return t21.callExpression(t21.identifier(REACT_API_MAP.useMemo), [
2366
+ t21.arrowFunctionExpression([], body),
2367
+ deps ?? t21.arrayExpression([])
2368
+ ]);
2369
+ }
2370
+ function createUseImperativeHandle(refId, init) {
2371
+ return t21.callExpression(t21.identifier(REACT_API_MAP.useImperativeHandle), [refId, init]);
2372
+ }
2373
+
2374
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
2375
+ function resolveDefineExpose(ctx) {
2376
+ if (ctx.inputType !== "sfc") return {};
2154
2377
  return {
2155
2378
  CallExpression(path7) {
2156
2379
  const { node } = path7;
2157
- const { filename, templateData, scriptData } = ctx;
2158
- if (!t22.isIdentifier(node.callee)) return;
2159
- const { name } = node.callee;
2160
- const checkIfFromDefineEmits = () => {
2161
- let result = false;
2162
- const meta = templateData.reactiveBindings[name];
2163
- if (meta) {
2164
- result = meta.source === MACRO_API_NAMES.emits;
2165
- }
2166
- if (!result) {
2167
- const binding = path7.scope.getBinding(name);
2168
- if (binding) {
2169
- const parent = binding.path.node;
2170
- if (t22.isVariableDeclarator(parent) && t22.isCallExpression(parent.init) && t22.isIdentifier(parent.init.callee)) {
2171
- result = parent.init.callee.name === MACRO_API_NAMES.emits;
2172
- }
2173
- }
2174
- }
2175
- return result;
2176
- };
2177
- if (!checkIfFromDefineEmits()) return;
2178
- const [callee, ...args] = node.arguments;
2179
- const eventName = t22.isStringLiteral(callee) ? `on${capitalize(camelCase(callee.value))}` : void 0;
2180
- if (!eventName) {
2181
- logger.warn(`Expected String type but got ${callee?.type}, expression will be removed`, {
2182
- file: filename,
2183
- source: scriptData.source,
2184
- loc: callee?.loc
2185
- });
2380
+ const { filename, scriptData } = ctx;
2381
+ if (!isCalleeNamed(node, MACRO_API_NAMES.expose)) {
2382
+ return;
2383
+ }
2384
+ const [expose] = node.arguments;
2385
+ if (!expose) {
2186
2386
  path7.remove();
2187
2387
  return;
2188
2388
  }
2189
- const propCall = t22.callExpression(
2190
- t22.optionalMemberExpression(
2191
- t22.identifier(ctx.propField),
2192
- t22.identifier(eventName),
2193
- false,
2194
- true
2195
- ),
2196
- args
2197
- );
2198
- path7.replaceWith(propCall);
2389
+ const adapter = ADAPTER_RULES.react[MACRO_API_NAMES.expose];
2390
+ recordImport(ctx, adapter.package, REACT_API_MAP.forwardRef);
2391
+ recordImport(ctx, adapter.package, adapter.target);
2392
+ if (!t22.isObjectExpression(expose) && !t22.isFunction(expose)) {
2393
+ logger.warn("Non-deterministic object literal may cause unknown risks.", {
2394
+ file: filename,
2395
+ loc: expose.loc,
2396
+ source: scriptData.source
2397
+ });
2398
+ }
2399
+ const init = !t22.isFunction(expose) ? t22.arrowFunctionExpression([], expose) : expose;
2400
+ const { forwardRef } = scriptData;
2401
+ const newNode = createUseImperativeHandle(t22.identifier(forwardRef.refField), init);
2402
+ forwardRef.enabled = true;
2403
+ path7.replaceWith(newNode);
2199
2404
  }
2200
2405
  };
2201
2406
  }
2202
2407
 
2203
- // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-options.ts
2408
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-options.ts
2204
2409
  import * as t23 from "@babel/types";
2205
- function resolveOptions(ctx) {
2410
+ function resolveDefineOptions(ctx) {
2206
2411
  return {
2207
2412
  CallExpression(path7) {
2208
2413
  const { node } = path7;
@@ -2246,39 +2451,91 @@ function extractName(prop, ctx) {
2246
2451
  ctx.compName = prop.value.value;
2247
2452
  return;
2248
2453
  }
2249
- logger.error(`name must be a string type, but got ${prop.value.type}`, {
2250
- source: scriptData.source,
2251
- file: filename,
2252
- loc: prop.key?.loc
2253
- });
2254
- }
2454
+ logger.error(`name must be a string type, but got ${prop.value.type}`, {
2455
+ source: scriptData.source,
2456
+ file: filename,
2457
+ loc: prop.key?.loc
2458
+ });
2459
+ }
2460
+ }
2461
+
2462
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-emit-calls.ts
2463
+ import * as t24 from "@babel/types";
2464
+ function resolveEmitCalls(ctx) {
2465
+ return {
2466
+ CallExpression(path7) {
2467
+ const { node } = path7;
2468
+ const { filename, templateData, scriptData } = ctx;
2469
+ if (!t24.isIdentifier(node.callee)) return;
2470
+ const { name } = node.callee;
2471
+ const checkIfFromDefineEmits = () => {
2472
+ let result = false;
2473
+ const meta = templateData.reactiveBindings[name];
2474
+ if (meta) {
2475
+ result = meta.source === MACRO_API_NAMES.emits;
2476
+ }
2477
+ if (!result) {
2478
+ const binding = path7.scope.getBinding(name);
2479
+ if (binding) {
2480
+ const parent = binding.path.node;
2481
+ if (t24.isVariableDeclarator(parent) && t24.isCallExpression(parent.init) && t24.isIdentifier(parent.init.callee)) {
2482
+ result = parent.init.callee.name === MACRO_API_NAMES.emits;
2483
+ }
2484
+ }
2485
+ }
2486
+ return result;
2487
+ };
2488
+ if (!checkIfFromDefineEmits()) return;
2489
+ const [callee, ...args] = node.arguments;
2490
+ const eventName = t24.isStringLiteral(callee) ? `on${capitalize(camelCase(callee.value))}` : void 0;
2491
+ if (!eventName) {
2492
+ logger.warn(`Expected String type but got ${callee?.type}, expression will be removed`, {
2493
+ file: filename,
2494
+ source: scriptData.source,
2495
+ loc: callee?.loc
2496
+ });
2497
+ path7.remove();
2498
+ return;
2499
+ }
2500
+ const propCall = t24.callExpression(
2501
+ t24.optionalMemberExpression(
2502
+ t24.identifier(ctx.propField),
2503
+ t24.identifier(eventName),
2504
+ false,
2505
+ true
2506
+ ),
2507
+ args
2508
+ );
2509
+ path7.replaceWith(propCall);
2510
+ }
2511
+ };
2255
2512
  }
2256
2513
 
2257
2514
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/index.ts
2258
- import * as t28 from "@babel/types";
2515
+ import * as t29 from "@babel/types";
2259
2516
 
2260
2517
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-emits.ts
2261
- import * as t25 from "@babel/types";
2518
+ import * as t26 from "@babel/types";
2262
2519
 
2263
2520
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/shared.ts
2264
- import * as t24 from "@babel/types";
2521
+ import * as t25 from "@babel/types";
2265
2522
  function cloneCallableParams(params) {
2266
2523
  const cloneCallableParam = (param, index) => {
2267
- if (t24.isRestElement(param)) {
2524
+ if (t25.isRestElement(param)) {
2268
2525
  const arg = param.argument;
2269
- const name = t24.isIdentifier(arg) ? arg.name : `args${index}`;
2270
- const rest = t24.restElement(t24.identifier(name));
2271
- rest.typeAnnotation = param.typeAnnotation || (t24.isIdentifier(arg) ? arg.typeAnnotation : null) || t24.tsTypeAnnotation(t24.tsArrayType(t24.tsAnyKeyword()));
2526
+ const name = t25.isIdentifier(arg) ? arg.name : `args${index}`;
2527
+ const rest = t25.restElement(t25.identifier(name));
2528
+ rest.typeAnnotation = param.typeAnnotation || (t25.isIdentifier(arg) ? arg.typeAnnotation : null) || t25.tsTypeAnnotation(t25.tsArrayType(t25.tsAnyKeyword()));
2272
2529
  return rest;
2273
2530
  }
2274
- if (t24.isIdentifier(param)) {
2275
- const id = t24.identifier(param.name || `arg${index}`);
2531
+ if (t25.isIdentifier(param)) {
2532
+ const id = t25.identifier(param.name || `arg${index}`);
2276
2533
  id.optional = param.optional;
2277
- id.typeAnnotation = param.typeAnnotation || t24.tsTypeAnnotation(t24.tsAnyKeyword());
2534
+ id.typeAnnotation = param.typeAnnotation || t25.tsTypeAnnotation(t25.tsAnyKeyword());
2278
2535
  return id;
2279
2536
  }
2280
- const fallback = t24.identifier(`arg${index}`);
2281
- fallback.typeAnnotation = t24.tsTypeAnnotation(t24.tsAnyKeyword());
2537
+ const fallback = t25.identifier(`arg${index}`);
2538
+ fallback.typeAnnotation = t25.tsTypeAnnotation(t25.tsAnyKeyword());
2282
2539
  return fallback;
2283
2540
  };
2284
2541
  return params.map(cloneCallableParam);
@@ -2288,18 +2545,18 @@ function cloneCallableParams(params) {
2288
2545
  function resolveEmitsTopLevelTypes(ctx) {
2289
2546
  return {
2290
2547
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path7) {
2291
- if (!t25.isProgram(path7.parent)) return;
2548
+ if (!t26.isProgram(path7.parent)) return;
2292
2549
  const { node } = path7;
2293
- if (t25.isTSInterfaceDeclaration(node)) {
2294
- const typeLiteral = t25.tsTypeLiteral(node.body.body);
2550
+ if (t26.isTSInterfaceDeclaration(node)) {
2551
+ const typeLiteral = t26.tsTypeLiteral(node.body.body);
2295
2552
  if (!hasEmitsSignatureInType(typeLiteral)) return;
2296
2553
  const resolved = resolveTopLevelEmitType(typeLiteral);
2297
- if (resolved && t25.isTSTypeLiteral(resolved)) {
2554
+ if (resolved && t26.isTSTypeLiteral(resolved)) {
2298
2555
  node.body.body = resolved.members;
2299
2556
  }
2300
2557
  return;
2301
2558
  }
2302
- if (t25.isTSTypeAliasDeclaration(node)) {
2559
+ if (t26.isTSTypeAliasDeclaration(node)) {
2303
2560
  if (!hasEmitsSignatureInType(node.typeAnnotation)) return;
2304
2561
  const resolved = resolveTopLevelEmitType(node.typeAnnotation);
2305
2562
  if (resolved) {
@@ -2310,47 +2567,47 @@ function resolveEmitsTopLevelTypes(ctx) {
2310
2567
  };
2311
2568
  }
2312
2569
  function resolveTopLevelEmitType(tsType) {
2313
- if (t25.isTSParenthesizedType(tsType)) {
2570
+ if (t26.isTSParenthesizedType(tsType)) {
2314
2571
  return resolveTopLevelEmitType(tsType.typeAnnotation);
2315
2572
  }
2316
- if (t25.isTSTypeReference(tsType)) {
2573
+ if (t26.isTSTypeReference(tsType)) {
2317
2574
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
2318
2575
  return tsType;
2319
2576
  }
2320
2577
  const params = tsType.typeParameters.params.map((param) => resolveTopLevelEmitType(param)).filter(Boolean);
2321
- return t25.tsTypeReference(
2578
+ return t26.tsTypeReference(
2322
2579
  tsType.typeName,
2323
- t25.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
2580
+ t26.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
2324
2581
  );
2325
2582
  }
2326
- if (t25.isTSIntersectionType(tsType)) {
2583
+ if (t26.isTSIntersectionType(tsType)) {
2327
2584
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
2328
2585
  if (!types.length) return null;
2329
2586
  if (types.length === 1) return types[0];
2330
- return t25.tsIntersectionType(types);
2587
+ return t26.tsIntersectionType(types);
2331
2588
  }
2332
- if (t25.isTSUnionType(tsType)) {
2589
+ if (t26.isTSUnionType(tsType)) {
2333
2590
  const types = tsType.types.map(resolveTopLevelEmitType).filter(Boolean);
2334
2591
  if (!types.length) return null;
2335
2592
  if (types.length === 1) return types[0];
2336
- return t25.tsUnionType(types);
2593
+ return t26.tsUnionType(types);
2337
2594
  }
2338
- if (t25.isTSTypeLiteral(tsType)) {
2595
+ if (t26.isTSTypeLiteral(tsType)) {
2339
2596
  const members = [];
2340
2597
  for (const member of tsType.members) {
2341
- if (t25.isTSCallSignatureDeclaration(member)) {
2598
+ if (t26.isTSCallSignatureDeclaration(member)) {
2342
2599
  members.push(...resolveEmitPropsFromCallSignature(member));
2343
2600
  continue;
2344
2601
  }
2345
2602
  members.push(member);
2346
2603
  }
2347
2604
  if (!members.length) return null;
2348
- return t25.tsTypeLiteral(members);
2605
+ return t26.tsTypeLiteral(members);
2349
2606
  }
2350
- if (t25.isTSFunctionType(tsType)) {
2607
+ if (t26.isTSFunctionType(tsType)) {
2351
2608
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
2352
2609
  if (!props.length) return null;
2353
- return t25.tsTypeLiteral(props);
2610
+ return t26.tsTypeLiteral(props);
2354
2611
  }
2355
2612
  return tsType;
2356
2613
  }
@@ -2371,41 +2628,41 @@ function processInferredTypes(ctx, runtimeArg) {
2371
2628
  propsTSIface: { emitTypes }
2372
2629
  } = ctx.scriptData;
2373
2630
  const members = [];
2374
- if (t25.isArrayExpression(runtimeArg)) {
2631
+ if (t26.isArrayExpression(runtimeArg)) {
2375
2632
  for (const element of runtimeArg.elements) {
2376
- if (!element || !t25.isStringLiteral(element)) continue;
2633
+ if (!element || !t26.isStringLiteral(element)) continue;
2377
2634
  const handlerName = resolveEmitHandlerName(element.value);
2378
2635
  const key = buildKey(handlerName);
2379
- const fnType = t25.tsFunctionType(
2636
+ const fnType = t26.tsFunctionType(
2380
2637
  null,
2381
2638
  [createRestAnyParam("args")],
2382
- t25.tsTypeAnnotation(t25.tsAnyKeyword())
2639
+ t26.tsTypeAnnotation(t26.tsAnyKeyword())
2383
2640
  );
2384
- const prop = t25.tsPropertySignature(key, t25.tsTypeAnnotation(fnType));
2641
+ const prop = t26.tsPropertySignature(key, t26.tsTypeAnnotation(fnType));
2385
2642
  prop.optional = true;
2386
2643
  members.push(prop);
2387
2644
  }
2388
2645
  if (members.length) {
2389
- emitTypes.push(t25.tsTypeLiteral(members));
2646
+ emitTypes.push(t26.tsTypeLiteral(members));
2390
2647
  }
2391
2648
  return;
2392
2649
  }
2393
- if (t25.isObjectExpression(runtimeArg)) {
2650
+ if (t26.isObjectExpression(runtimeArg)) {
2394
2651
  for (const prop of runtimeArg.properties) {
2395
- if (!t25.isObjectProperty(prop)) continue;
2396
- if (t25.isSpreadElement(prop)) continue;
2652
+ if (!t26.isObjectProperty(prop)) continue;
2653
+ if (t26.isSpreadElement(prop)) continue;
2397
2654
  const rawName = resolvePropName(prop.key);
2398
2655
  if (!rawName) continue;
2399
2656
  const handlerName = resolveEmitHandlerName(rawName);
2400
2657
  const key = buildKey(handlerName);
2401
- const params = t25.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
2402
- const fnType = t25.tsFunctionType(null, params, t25.tsTypeAnnotation(t25.tsAnyKeyword()));
2403
- const propSig = t25.tsPropertySignature(key, t25.tsTypeAnnotation(fnType));
2658
+ const params = t26.isArrayExpression(prop.value) ? resolveRuntimeTupleParams(prop.value) : [createRestAnyParam("args")];
2659
+ const fnType = t26.tsFunctionType(null, params, t26.tsTypeAnnotation(t26.tsAnyKeyword()));
2660
+ const propSig = t26.tsPropertySignature(key, t26.tsTypeAnnotation(fnType));
2404
2661
  propSig.optional = true;
2405
2662
  members.push(propSig);
2406
2663
  }
2407
2664
  if (members.length) {
2408
- emitTypes.push(t25.tsTypeLiteral(members));
2665
+ emitTypes.push(t26.tsTypeLiteral(members));
2409
2666
  }
2410
2667
  }
2411
2668
  }
@@ -2426,129 +2683,129 @@ function resolveEmitHandlerName(rawName) {
2426
2683
  return `on${name}`;
2427
2684
  }
2428
2685
  function resolvePropName(key) {
2429
- if (t25.isIdentifier(key)) return key.name;
2430
- if (t25.isStringLiteral(key)) return key.value;
2431
- if (t25.isNumericLiteral(key)) return String(key.value);
2686
+ if (t26.isIdentifier(key)) return key.name;
2687
+ if (t26.isStringLiteral(key)) return key.value;
2688
+ if (t26.isNumericLiteral(key)) return String(key.value);
2432
2689
  return null;
2433
2690
  }
2434
2691
  function buildKey(name) {
2435
- return t25.isValidIdentifier(name) ? t25.identifier(name) : t25.stringLiteral(name);
2692
+ return t26.isValidIdentifier(name) ? t26.identifier(name) : t26.stringLiteral(name);
2436
2693
  }
2437
2694
  function createRestAnyParam(name) {
2438
- const id = t25.identifier(name);
2439
- const rest = t25.restElement(id);
2440
- rest.typeAnnotation = t25.tsTypeAnnotation(t25.tsArrayType(t25.tsAnyKeyword()));
2695
+ const id = t26.identifier(name);
2696
+ const rest = t26.restElement(id);
2697
+ rest.typeAnnotation = t26.tsTypeAnnotation(t26.tsArrayType(t26.tsAnyKeyword()));
2441
2698
  return rest;
2442
2699
  }
2443
2700
  function resolveRuntimeTupleParams(value) {
2444
2701
  const params = [];
2445
2702
  value.elements.forEach((element, index) => {
2446
2703
  if (!element) return;
2447
- if (t25.isSpreadElement(element)) {
2704
+ if (t26.isSpreadElement(element)) {
2448
2705
  params.push(createRestAnyParam(`args${index}`));
2449
2706
  return;
2450
2707
  }
2451
- if (t25.isIdentifier(element)) {
2452
- const id = t25.identifier(element.name);
2453
- id.typeAnnotation = element.typeAnnotation || t25.tsTypeAnnotation(t25.tsAnyKeyword());
2708
+ if (t26.isIdentifier(element)) {
2709
+ const id = t26.identifier(element.name);
2710
+ id.typeAnnotation = element.typeAnnotation || t26.tsTypeAnnotation(t26.tsAnyKeyword());
2454
2711
  params.push(id);
2455
2712
  return;
2456
2713
  }
2457
- if (t25.isTSAsExpression(element)) {
2458
- const id = t25.identifier(`arg${index}`);
2459
- id.typeAnnotation = t25.tsTypeAnnotation(element.typeAnnotation);
2714
+ if (t26.isTSAsExpression(element)) {
2715
+ const id = t26.identifier(`arg${index}`);
2716
+ id.typeAnnotation = t26.tsTypeAnnotation(element.typeAnnotation);
2460
2717
  params.push(id);
2461
2718
  return;
2462
2719
  }
2463
- const fallback = t25.identifier(`arg${index}`);
2464
- fallback.typeAnnotation = t25.tsTypeAnnotation(t25.tsAnyKeyword());
2720
+ const fallback = t26.identifier(`arg${index}`);
2721
+ fallback.typeAnnotation = t26.tsTypeAnnotation(t26.tsAnyKeyword());
2465
2722
  params.push(fallback);
2466
2723
  });
2467
2724
  return params;
2468
2725
  }
2469
2726
  function resolveExplicitEmitType(tsType) {
2470
- if (t25.isTSParenthesizedType(tsType)) {
2727
+ if (t26.isTSParenthesizedType(tsType)) {
2471
2728
  return resolveExplicitEmitType(tsType.typeAnnotation);
2472
2729
  }
2473
- if (t25.isTSTypeReference(tsType)) {
2730
+ if (t26.isTSTypeReference(tsType)) {
2474
2731
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
2475
2732
  return tsType;
2476
2733
  }
2477
2734
  const params = tsType.typeParameters.params.map((param) => resolveExplicitEmitType(param)).filter(Boolean);
2478
- return t25.tsTypeReference(
2735
+ return t26.tsTypeReference(
2479
2736
  tsType.typeName,
2480
- t25.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
2737
+ t26.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
2481
2738
  );
2482
2739
  }
2483
- if (t25.isTSIntersectionType(tsType)) {
2740
+ if (t26.isTSIntersectionType(tsType)) {
2484
2741
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
2485
2742
  if (!types.length) return null;
2486
2743
  if (types.length === 1) return types[0];
2487
- return t25.tsIntersectionType(types);
2744
+ return t26.tsIntersectionType(types);
2488
2745
  }
2489
- if (t25.isTSUnionType(tsType)) {
2746
+ if (t26.isTSUnionType(tsType)) {
2490
2747
  const types = tsType.types.map(resolveExplicitEmitType).filter(Boolean);
2491
2748
  if (!types.length) return null;
2492
2749
  if (types.length === 1) return types[0];
2493
- return t25.tsUnionType(types);
2750
+ return t26.tsUnionType(types);
2494
2751
  }
2495
- if (t25.isTSTypeLiteral(tsType)) {
2752
+ if (t26.isTSTypeLiteral(tsType)) {
2496
2753
  const members = [];
2497
2754
  for (const member of tsType.members) {
2498
- if (t25.isTSPropertySignature(member)) {
2755
+ if (t26.isTSPropertySignature(member)) {
2499
2756
  const prop = resolveEmitPropFromPropertySignature(member);
2500
2757
  if (prop) members.push(prop);
2501
2758
  continue;
2502
2759
  }
2503
- if (t25.isTSCallSignatureDeclaration(member)) {
2760
+ if (t26.isTSCallSignatureDeclaration(member)) {
2504
2761
  members.push(...resolveEmitPropsFromCallSignature(member));
2505
2762
  continue;
2506
2763
  }
2507
2764
  }
2508
2765
  if (!members.length) return null;
2509
- return t25.tsTypeLiteral(members);
2766
+ return t26.tsTypeLiteral(members);
2510
2767
  }
2511
- if (t25.isTSFunctionType(tsType)) {
2768
+ if (t26.isTSFunctionType(tsType)) {
2512
2769
  const props = resolveEmitPropsFromCallable(tsType.parameters, tsType.typeAnnotation);
2513
2770
  if (!props.length) return null;
2514
- return t25.tsTypeLiteral(props);
2771
+ return t26.tsTypeLiteral(props);
2515
2772
  }
2516
2773
  return tsType;
2517
2774
  }
2518
2775
  function hasEmitsSignatureInType(tsType) {
2519
- if (t25.isTSParenthesizedType(tsType)) {
2776
+ if (t26.isTSParenthesizedType(tsType)) {
2520
2777
  return hasEmitsSignatureInType(tsType.typeAnnotation);
2521
2778
  }
2522
- if (t25.isTSTypeReference(tsType)) {
2779
+ if (t26.isTSTypeReference(tsType)) {
2523
2780
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
2524
2781
  return false;
2525
2782
  }
2526
2783
  return tsType.typeParameters.params.some(hasEmitsSignatureInType);
2527
2784
  }
2528
- if (t25.isTSIntersectionType(tsType) || t25.isTSUnionType(tsType)) {
2785
+ if (t26.isTSIntersectionType(tsType) || t26.isTSUnionType(tsType)) {
2529
2786
  return tsType.types.some(hasEmitsSignatureInType);
2530
2787
  }
2531
- if (t25.isTSTypeLiteral(tsType)) {
2788
+ if (t26.isTSTypeLiteral(tsType)) {
2532
2789
  return tsType.members.some(hasEmitsSignatureInMember);
2533
2790
  }
2534
- if (t25.isTSFunctionType(tsType)) {
2791
+ if (t26.isTSFunctionType(tsType)) {
2535
2792
  return isEmitsCallable(tsType.parameters);
2536
2793
  }
2537
2794
  return false;
2538
2795
  }
2539
2796
  function hasEmitsSignatureInMember(member) {
2540
- if (t25.isTSCallSignatureDeclaration(member)) {
2797
+ if (t26.isTSCallSignatureDeclaration(member)) {
2541
2798
  return isEmitsCallable(member.parameters);
2542
2799
  }
2543
2800
  return false;
2544
2801
  }
2545
2802
  function isEmitsCallable(parameters) {
2546
2803
  const [eventParam] = parameters;
2547
- if (!eventParam || !t25.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
2804
+ if (!eventParam || !t26.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
2548
2805
  return false;
2549
2806
  }
2550
2807
  const { typeAnnotation } = eventParam;
2551
- if (t25.isNoop(typeAnnotation)) return false;
2808
+ if (t26.isNoop(typeAnnotation)) return false;
2552
2809
  return resolveEventNames(typeAnnotation.typeAnnotation).length > 0;
2553
2810
  }
2554
2811
  function resolveEmitPropFromPropertySignature(member) {
@@ -2558,19 +2815,19 @@ function resolveEmitPropFromPropertySignature(member) {
2558
2815
  const key = buildKey(handlerName);
2559
2816
  const typeAnnotation = member.typeAnnotation?.typeAnnotation;
2560
2817
  let params = [];
2561
- let returnType = t25.tsAnyKeyword();
2562
- if (typeAnnotation && t25.isTSFunctionType(typeAnnotation)) {
2818
+ let returnType = t26.tsAnyKeyword();
2819
+ if (typeAnnotation && t26.isTSFunctionType(typeAnnotation)) {
2563
2820
  params = cloneCallableParams(typeAnnotation.parameters);
2564
2821
  returnType = typeAnnotation.typeAnnotation?.typeAnnotation ?? returnType;
2565
- } else if (typeAnnotation && t25.isTSTupleType(typeAnnotation)) {
2822
+ } else if (typeAnnotation && t26.isTSTupleType(typeAnnotation)) {
2566
2823
  params = resolveTupleTypeParams(typeAnnotation);
2567
2824
  } else if (typeAnnotation) {
2568
- const id = t25.identifier("value");
2569
- id.typeAnnotation = t25.tsTypeAnnotation(typeAnnotation);
2825
+ const id = t26.identifier("value");
2826
+ id.typeAnnotation = t26.tsTypeAnnotation(typeAnnotation);
2570
2827
  params = [id];
2571
2828
  }
2572
- const fnType = t25.tsFunctionType(null, params, t25.tsTypeAnnotation(returnType));
2573
- const prop = t25.tsPropertySignature(key, t25.tsTypeAnnotation(fnType));
2829
+ const fnType = t26.tsFunctionType(null, params, t26.tsTypeAnnotation(returnType));
2830
+ const prop = t26.tsPropertySignature(key, t26.tsTypeAnnotation(fnType));
2574
2831
  prop.optional = !!member.optional;
2575
2832
  return prop;
2576
2833
  }
@@ -2579,32 +2836,32 @@ function resolveEmitPropsFromCallSignature(member) {
2579
2836
  }
2580
2837
  function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
2581
2838
  const [eventParam, ...restParams] = parameters;
2582
- if (!eventParam || !t25.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
2839
+ if (!eventParam || !t26.isIdentifier(eventParam) || !eventParam.typeAnnotation) {
2583
2840
  return [];
2584
2841
  }
2585
2842
  const { typeAnnotation: paramTypeAnnotation } = eventParam;
2586
- if (t25.isNoop(paramTypeAnnotation)) return [];
2843
+ if (t26.isNoop(paramTypeAnnotation)) return [];
2587
2844
  const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
2588
2845
  if (!eventNames.length) return [];
2589
- const returnType = typeAnnotation?.typeAnnotation ?? t25.tsAnyKeyword();
2846
+ const returnType = typeAnnotation?.typeAnnotation ?? t26.tsAnyKeyword();
2590
2847
  return eventNames.map((eventName) => {
2591
2848
  const handlerName = resolveEmitHandlerName(eventName);
2592
2849
  const key = buildKey(handlerName);
2593
2850
  const params = cloneCallableParams(restParams);
2594
- const fnType = t25.tsFunctionType(null, params, t25.tsTypeAnnotation(returnType));
2595
- const prop = t25.tsPropertySignature(key, t25.tsTypeAnnotation(fnType));
2851
+ const fnType = t26.tsFunctionType(null, params, t26.tsTypeAnnotation(returnType));
2852
+ const prop = t26.tsPropertySignature(key, t26.tsTypeAnnotation(fnType));
2596
2853
  prop.optional = true;
2597
2854
  return prop;
2598
2855
  });
2599
2856
  }
2600
2857
  function resolveEventNames(type) {
2601
- if (t25.isTSLiteralType(type) && t25.isStringLiteral(type.literal)) {
2858
+ if (t26.isTSLiteralType(type) && t26.isStringLiteral(type.literal)) {
2602
2859
  return [type.literal.value];
2603
2860
  }
2604
- if (t25.isTSUnionType(type)) {
2861
+ if (t26.isTSUnionType(type)) {
2605
2862
  return type.types.flatMap(resolveEventNames);
2606
2863
  }
2607
- if (t25.isTSParenthesizedType(type)) {
2864
+ if (t26.isTSParenthesizedType(type)) {
2608
2865
  return resolveEventNames(type.typeAnnotation);
2609
2866
  }
2610
2867
  return [];
@@ -2617,44 +2874,44 @@ function resolveTupleTypeParams(tuple) {
2617
2874
  return params;
2618
2875
  }
2619
2876
  function resolveTupleElementParam(element, index) {
2620
- const isNamedTuple = typeof t25.isTSNamedTupleMember === "function" && t25.isTSNamedTupleMember(element);
2877
+ const isNamedTuple = typeof t26.isTSNamedTupleMember === "function" && t26.isTSNamedTupleMember(element);
2621
2878
  if (isNamedTuple) {
2622
2879
  const tupleMember = element;
2623
2880
  const name = tupleMember.label?.name || `arg${index}`;
2624
2881
  let innerType = tupleMember.elementType;
2625
2882
  let optional = tupleMember.optional;
2626
- if (t25.isTSOptionalType(innerType)) {
2883
+ if (t26.isTSOptionalType(innerType)) {
2627
2884
  optional = true;
2628
2885
  innerType = innerType.typeAnnotation;
2629
2886
  }
2630
- if (t25.isTSRestType(innerType)) {
2631
- const rest = t25.restElement(t25.identifier(name));
2632
- rest.typeAnnotation = t25.tsTypeAnnotation(innerType.typeAnnotation);
2887
+ if (t26.isTSRestType(innerType)) {
2888
+ const rest = t26.restElement(t26.identifier(name));
2889
+ rest.typeAnnotation = t26.tsTypeAnnotation(innerType.typeAnnotation);
2633
2890
  return rest;
2634
2891
  }
2635
- const id2 = t25.identifier(name);
2892
+ const id2 = t26.identifier(name);
2636
2893
  id2.optional = optional;
2637
- id2.typeAnnotation = t25.tsTypeAnnotation(innerType);
2894
+ id2.typeAnnotation = t26.tsTypeAnnotation(innerType);
2638
2895
  return id2;
2639
2896
  }
2640
- if (t25.isTSRestType(element)) {
2641
- const rest = t25.restElement(t25.identifier(`args${index}`));
2642
- rest.typeAnnotation = t25.tsTypeAnnotation(element.typeAnnotation);
2897
+ if (t26.isTSRestType(element)) {
2898
+ const rest = t26.restElement(t26.identifier(`args${index}`));
2899
+ rest.typeAnnotation = t26.tsTypeAnnotation(element.typeAnnotation);
2643
2900
  return rest;
2644
2901
  }
2645
- if (t25.isTSOptionalType(element)) {
2646
- const id2 = t25.identifier(`arg${index}`);
2902
+ if (t26.isTSOptionalType(element)) {
2903
+ const id2 = t26.identifier(`arg${index}`);
2647
2904
  id2.optional = true;
2648
- id2.typeAnnotation = t25.tsTypeAnnotation(element.typeAnnotation);
2905
+ id2.typeAnnotation = t26.tsTypeAnnotation(element.typeAnnotation);
2649
2906
  return id2;
2650
2907
  }
2651
- const id = t25.identifier(`arg${index}`);
2652
- id.typeAnnotation = t25.tsTypeAnnotation(element);
2908
+ const id = t26.identifier(`arg${index}`);
2909
+ id.typeAnnotation = t26.tsTypeAnnotation(element);
2653
2910
  return id;
2654
2911
  }
2655
2912
 
2656
2913
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-props.ts
2657
- import * as t26 from "@babel/types";
2914
+ import * as t27 from "@babel/types";
2658
2915
  function resolveDefinePropsIface(path7, ctx) {
2659
2916
  const { node } = path7;
2660
2917
  const [runtimeArg] = node.arguments;
@@ -2674,38 +2931,38 @@ function processInferredTypes2(ctx, runtimeArg) {
2674
2931
  } = scriptData;
2675
2932
  if (!runtimeArg) return;
2676
2933
  const members = [];
2677
- if (t26.isArrayExpression(runtimeArg)) {
2934
+ if (t27.isArrayExpression(runtimeArg)) {
2678
2935
  for (const element of runtimeArg.elements) {
2679
- if (!element || !t26.isStringLiteral(element)) continue;
2680
- const key = t26.isValidIdentifier(element.value) ? t26.identifier(element.value) : t26.stringLiteral(element.value);
2681
- const prop = t26.tsPropertySignature(key, t26.tsTypeAnnotation(t26.tsAnyKeyword()));
2936
+ if (!element || !t27.isStringLiteral(element)) continue;
2937
+ const key = t27.isValidIdentifier(element.value) ? t27.identifier(element.value) : t27.stringLiteral(element.value);
2938
+ const prop = t27.tsPropertySignature(key, t27.tsTypeAnnotation(t27.tsAnyKeyword()));
2682
2939
  prop.optional = true;
2683
2940
  members.push(prop);
2684
2941
  }
2685
2942
  if (members.length) {
2686
- propsTypes.push(t26.tsTypeLiteral(members));
2943
+ propsTypes.push(t27.tsTypeLiteral(members));
2687
2944
  }
2688
2945
  return;
2689
2946
  }
2690
- if (t26.isObjectExpression(runtimeArg)) {
2947
+ if (t27.isObjectExpression(runtimeArg)) {
2691
2948
  for (const prop of runtimeArg.properties) {
2692
- if (!t26.isObjectProperty(prop)) continue;
2693
- if (t26.isSpreadElement(prop)) continue;
2949
+ if (!t27.isObjectProperty(prop)) continue;
2950
+ if (t27.isSpreadElement(prop)) continue;
2694
2951
  const key = prop.key;
2695
2952
  let propName = null;
2696
- if (t26.isIdentifier(key)) propName = key.name;
2697
- if (t26.isStringLiteral(key)) propName = key.value;
2698
- if (t26.isNumericLiteral(key)) propName = String(key.value);
2953
+ if (t27.isIdentifier(key)) propName = key.name;
2954
+ if (t27.isStringLiteral(key)) propName = key.value;
2955
+ if (t27.isNumericLiteral(key)) propName = String(key.value);
2699
2956
  if (!propName) continue;
2700
2957
  const { type, required } = resolveRuntimePropMeta(prop.value);
2701
- const tsType = type ?? t26.tsAnyKeyword();
2702
- const tsKey = t26.isValidIdentifier(propName) ? t26.identifier(propName) : t26.stringLiteral(propName);
2703
- const tsProp = t26.tsPropertySignature(tsKey, t26.tsTypeAnnotation(tsType));
2958
+ const tsType = type ?? t27.tsAnyKeyword();
2959
+ const tsKey = t27.isValidIdentifier(propName) ? t27.identifier(propName) : t27.stringLiteral(propName);
2960
+ const tsProp = t27.tsPropertySignature(tsKey, t27.tsTypeAnnotation(tsType));
2704
2961
  tsProp.optional = !required;
2705
2962
  members.push(tsProp);
2706
2963
  }
2707
2964
  if (members.length) {
2708
- propsTypes.push(t26.tsTypeLiteral(members));
2965
+ propsTypes.push(t27.tsTypeLiteral(members));
2709
2966
  }
2710
2967
  return;
2711
2968
  }
@@ -2719,42 +2976,42 @@ function processInferredTypes2(ctx, runtimeArg) {
2719
2976
  );
2720
2977
  }
2721
2978
  function resolveRuntimePropMeta(value) {
2722
- if (t26.isIdentifier(value)) {
2979
+ if (t27.isIdentifier(value)) {
2723
2980
  return {
2724
2981
  type: mapRuntimeTypeToTSType(value),
2725
2982
  required: false
2726
2983
  };
2727
2984
  }
2728
- if (t26.isArrayExpression(value)) {
2985
+ if (t27.isArrayExpression(value)) {
2729
2986
  return {
2730
2987
  type: resolveRuntimeUnionType(value),
2731
2988
  required: false
2732
2989
  };
2733
2990
  }
2734
- if (!t26.isObjectExpression(value)) {
2991
+ if (!t27.isObjectExpression(value)) {
2735
2992
  return { required: false };
2736
2993
  }
2737
2994
  let type;
2738
2995
  let required = false;
2739
2996
  for (const prop of value.properties) {
2740
- if (!t26.isObjectProperty(prop)) continue;
2741
- if (t26.isSpreadElement(prop)) continue;
2997
+ if (!t27.isObjectProperty(prop)) continue;
2998
+ if (t27.isSpreadElement(prop)) continue;
2742
2999
  const key = prop.key;
2743
- const propName = t26.isIdentifier(key) ? key.name : t26.isStringLiteral(key) ? key.value : null;
3000
+ const propName = t27.isIdentifier(key) ? key.name : t27.isStringLiteral(key) ? key.value : null;
2744
3001
  if (!propName) continue;
2745
3002
  if (propName === "type") {
2746
3003
  const valueNode = prop.value;
2747
- if (t26.isArrayExpression(valueNode)) {
3004
+ if (t27.isArrayExpression(valueNode)) {
2748
3005
  type = resolveRuntimeUnionType(valueNode);
2749
3006
  continue;
2750
3007
  }
2751
- if (t26.isIdentifier(valueNode)) {
3008
+ if (t27.isIdentifier(valueNode)) {
2752
3009
  type = mapRuntimeTypeToTSType(valueNode);
2753
3010
  continue;
2754
3011
  }
2755
3012
  }
2756
3013
  if (propName === "required") {
2757
- if (t26.isBooleanLiteral(prop.value)) {
3014
+ if (t27.isBooleanLiteral(prop.value)) {
2758
3015
  required = prop.value.value;
2759
3016
  }
2760
3017
  }
@@ -2764,58 +3021,58 @@ function resolveRuntimePropMeta(value) {
2764
3021
  function resolveRuntimeUnionType(value) {
2765
3022
  const types = [];
2766
3023
  for (const element of value.elements) {
2767
- if (!element || !t26.isIdentifier(element)) continue;
3024
+ if (!element || !t27.isIdentifier(element)) continue;
2768
3025
  const resolved = mapRuntimeTypeToTSType(element);
2769
3026
  if (resolved) types.push(resolved);
2770
3027
  }
2771
- if (!types.length) return t26.tsAnyKeyword();
3028
+ if (!types.length) return t27.tsAnyKeyword();
2772
3029
  if (types.length === 1) return types[0];
2773
- return t26.tsUnionType(types);
3030
+ return t27.tsUnionType(types);
2774
3031
  }
2775
3032
  function mapRuntimeTypeToTSType(value) {
2776
3033
  switch (value.name) {
2777
3034
  case "String":
2778
- return t26.tsStringKeyword();
3035
+ return t27.tsStringKeyword();
2779
3036
  case "Number":
2780
- return t26.tsNumberKeyword();
3037
+ return t27.tsNumberKeyword();
2781
3038
  case "Boolean":
2782
- return t26.tsBooleanKeyword();
3039
+ return t27.tsBooleanKeyword();
2783
3040
  case "Object":
2784
- return t26.tsTypeLiteral([]);
3041
+ return t27.tsTypeLiteral([]);
2785
3042
  case "Array":
2786
- return t26.tsArrayType(t26.tsAnyKeyword());
3043
+ return t27.tsArrayType(t27.tsAnyKeyword());
2787
3044
  case "Function":
2788
- return t26.tsFunctionType(null, [], t26.tsTypeAnnotation(t26.tsAnyKeyword()));
3045
+ return t27.tsFunctionType(null, [], t27.tsTypeAnnotation(t27.tsAnyKeyword()));
2789
3046
  case "Symbol":
2790
- return t26.tsSymbolKeyword();
3047
+ return t27.tsSymbolKeyword();
2791
3048
  case "BigInt":
2792
- return t26.tsBigIntKeyword();
3049
+ return t27.tsBigIntKeyword();
2793
3050
  default:
2794
- return t26.tsAnyKeyword();
3051
+ return t27.tsAnyKeyword();
2795
3052
  }
2796
3053
  }
2797
3054
 
2798
3055
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot.ts
2799
- import * as t27 from "@babel/types";
3056
+ import * as t28 from "@babel/types";
2800
3057
  var SLOT_DEFAULT_NAME = "default";
2801
3058
  var SLOT_CHILDREN_NAME = "children";
2802
3059
  var SLOT_FN_PARAM_NAME = "props";
2803
3060
  function resolveSlotsTopLevelTypes(ctx) {
2804
3061
  return {
2805
3062
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path7) {
2806
- if (!t27.isProgram(path7.parent)) return;
3063
+ if (!t28.isProgram(path7.parent)) return;
2807
3064
  const { node } = path7;
2808
- if (t27.isTSInterfaceDeclaration(node)) {
2809
- const typeLiteral = t27.tsTypeLiteral(node.body.body);
3065
+ if (t28.isTSInterfaceDeclaration(node)) {
3066
+ const typeLiteral = t28.tsTypeLiteral(node.body.body);
2810
3067
  if (!hasSlotsSignatureInType(typeLiteral)) return;
2811
3068
  const resolved = resolveSlotType(typeLiteral);
2812
- if (resolved && t27.isTSTypeLiteral(resolved)) {
3069
+ if (resolved && t28.isTSTypeLiteral(resolved)) {
2813
3070
  node.body.body = resolved.members;
2814
3071
  recordReactNode(ctx);
2815
3072
  }
2816
3073
  return;
2817
3074
  }
2818
- if (t27.isTSTypeAliasDeclaration(node)) {
3075
+ if (t28.isTSTypeAliasDeclaration(node)) {
2819
3076
  if (!hasSlotsSignatureInType(node.typeAnnotation)) return;
2820
3077
  const resolved = resolveSlotType(node.typeAnnotation);
2821
3078
  if (resolved) {
@@ -2860,7 +3117,7 @@ function resolveTemplateSlotIface(ctx) {
2860
3117
  }
2861
3118
  if (tsMembers.length) {
2862
3119
  recordReactNode(ctx);
2863
- slotTypes.push(t27.tsTypeLiteral(tsMembers));
3120
+ slotTypes.push(t28.tsTypeLiteral(tsMembers));
2864
3121
  }
2865
3122
  }
2866
3123
  function recordReactNode(ctx) {
@@ -2870,32 +3127,32 @@ function recordReactNode(ctx) {
2870
3127
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.ReactNode);
2871
3128
  }
2872
3129
  function resolveSlotType(tsType) {
2873
- if (t27.isTSParenthesizedType(tsType)) {
3130
+ if (t28.isTSParenthesizedType(tsType)) {
2874
3131
  return resolveSlotType(tsType.typeAnnotation);
2875
3132
  }
2876
- if (t27.isTSTypeReference(tsType)) {
3133
+ if (t28.isTSTypeReference(tsType)) {
2877
3134
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
2878
3135
  return tsType;
2879
3136
  }
2880
3137
  const params = tsType.typeParameters.params.map((param) => resolveSlotType(param)).filter(Boolean);
2881
- return t27.tsTypeReference(
3138
+ return t28.tsTypeReference(
2882
3139
  tsType.typeName,
2883
- t27.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
3140
+ t28.tsTypeParameterInstantiation(params.length ? params : tsType.typeParameters.params)
2884
3141
  );
2885
3142
  }
2886
- if (t27.isTSIntersectionType(tsType)) {
3143
+ if (t28.isTSIntersectionType(tsType)) {
2887
3144
  const types = tsType.types.map(resolveSlotType).filter(Boolean);
2888
3145
  if (!types.length) return null;
2889
3146
  if (types.length === 1) return types[0];
2890
- return t27.tsIntersectionType(types);
3147
+ return t28.tsIntersectionType(types);
2891
3148
  }
2892
- if (t27.isTSUnionType(tsType)) {
3149
+ if (t28.isTSUnionType(tsType)) {
2893
3150
  const types = tsType.types.map(resolveSlotType).filter(Boolean);
2894
3151
  if (!types.length) return null;
2895
3152
  if (types.length === 1) return types[0];
2896
- return t27.tsUnionType(types);
3153
+ return t28.tsUnionType(types);
2897
3154
  }
2898
- if (t27.isTSTypeLiteral(tsType)) {
3155
+ if (t28.isTSTypeLiteral(tsType)) {
2899
3156
  const members = [];
2900
3157
  for (const member of tsType.members) {
2901
3158
  const resolved = resolveSlotPropFromMember(member);
@@ -2906,56 +3163,56 @@ function resolveSlotType(tsType) {
2906
3163
  members.push(member);
2907
3164
  }
2908
3165
  if (!members.length) return null;
2909
- return t27.tsTypeLiteral(members);
3166
+ return t28.tsTypeLiteral(members);
2910
3167
  }
2911
- if (t27.isTSFunctionType(tsType)) {
3168
+ if (t28.isTSFunctionType(tsType)) {
2912
3169
  const props = buildSlotPropSignature(
2913
3170
  SLOT_DEFAULT_NAME,
2914
3171
  cloneCallableParams(tsType.parameters),
2915
3172
  false
2916
3173
  );
2917
- return t27.tsTypeLiteral([props]);
3174
+ return t28.tsTypeLiteral([props]);
2918
3175
  }
2919
3176
  return tsType;
2920
3177
  }
2921
3178
  function hasSlotsSignatureInType(tsType) {
2922
- if (t27.isTSParenthesizedType(tsType)) {
3179
+ if (t28.isTSParenthesizedType(tsType)) {
2923
3180
  return hasSlotsSignatureInType(tsType.typeAnnotation);
2924
3181
  }
2925
- if (t27.isTSTypeReference(tsType)) {
3182
+ if (t28.isTSTypeReference(tsType)) {
2926
3183
  if (!tsType.typeParameters || !tsType.typeParameters.params.length) {
2927
3184
  return false;
2928
3185
  }
2929
3186
  return tsType.typeParameters.params.some(hasSlotsSignatureInType);
2930
3187
  }
2931
- if (t27.isTSIntersectionType(tsType) || t27.isTSUnionType(tsType)) {
3188
+ if (t28.isTSIntersectionType(tsType) || t28.isTSUnionType(tsType)) {
2932
3189
  return tsType.types.some(hasSlotsSignatureInType);
2933
3190
  }
2934
- if (t27.isTSTypeLiteral(tsType)) {
3191
+ if (t28.isTSTypeLiteral(tsType)) {
2935
3192
  return tsType.members.some(hasSlotsSignatureInMember);
2936
3193
  }
2937
- if (t27.isTSFunctionType(tsType)) {
3194
+ if (t28.isTSFunctionType(tsType)) {
2938
3195
  return true;
2939
3196
  }
2940
3197
  return false;
2941
3198
  }
2942
3199
  function hasSlotsSignatureInMember(member) {
2943
- if (t27.isTSMethodSignature(member)) return true;
2944
- if (t27.isTSCallSignatureDeclaration(member)) return true;
2945
- if (t27.isTSPropertySignature(member)) {
3200
+ if (t28.isTSMethodSignature(member)) return true;
3201
+ if (t28.isTSCallSignatureDeclaration(member)) return true;
3202
+ if (t28.isTSPropertySignature(member)) {
2946
3203
  const typeAnnotation = member.typeAnnotation?.typeAnnotation;
2947
3204
  return !!(typeAnnotation && resolveCallableType(typeAnnotation));
2948
3205
  }
2949
3206
  return false;
2950
3207
  }
2951
3208
  function resolveSlotPropFromMember(member) {
2952
- if (t27.isTSMethodSignature(member)) {
3209
+ if (t28.isTSMethodSignature(member)) {
2953
3210
  const rawName = resolvePropName2(member.key);
2954
3211
  if (!rawName) return null;
2955
3212
  const params = cloneCallableParams(member.parameters);
2956
3213
  return buildSlotPropSignature(rawName, params, !!member.optional);
2957
3214
  }
2958
- if (t27.isTSPropertySignature(member)) {
3215
+ if (t28.isTSPropertySignature(member)) {
2959
3216
  const rawName = resolvePropName2(member.key);
2960
3217
  if (!rawName) return null;
2961
3218
  const typeAnnotation = member.typeAnnotation?.typeAnnotation;
@@ -2964,52 +3221,52 @@ function resolveSlotPropFromMember(member) {
2964
3221
  const params = cloneCallableParams(callable.parameters);
2965
3222
  return buildSlotPropSignature(rawName, params, !!member.optional);
2966
3223
  }
2967
- if (t27.isTSCallSignatureDeclaration(member)) {
3224
+ if (t28.isTSCallSignatureDeclaration(member)) {
2968
3225
  const params = cloneCallableParams(member.parameters);
2969
3226
  return buildSlotPropSignature(SLOT_DEFAULT_NAME, params, true);
2970
3227
  }
2971
3228
  return null;
2972
3229
  }
2973
3230
  function resolveCallableType(tsType) {
2974
- if (t27.isTSFunctionType(tsType)) return tsType;
2975
- if (t27.isTSParenthesizedType(tsType)) return resolveCallableType(tsType.typeAnnotation);
3231
+ if (t28.isTSFunctionType(tsType)) return tsType;
3232
+ if (t28.isTSParenthesizedType(tsType)) return resolveCallableType(tsType.typeAnnotation);
2976
3233
  return null;
2977
3234
  }
2978
3235
  function buildSlotPropSignature(rawName, params, optional) {
2979
3236
  const propName = rawName === SLOT_DEFAULT_NAME ? SLOT_CHILDREN_NAME : rawName;
2980
- const key = t27.isValidIdentifier(propName) ? t27.identifier(propName) : t27.stringLiteral(propName);
2981
- const reactNodeType = t27.tsTypeAnnotation(
2982
- t27.tsTypeReference(t27.identifier(REACT_API_MAP.ReactNode))
3237
+ const key = t28.isValidIdentifier(propName) ? t28.identifier(propName) : t28.stringLiteral(propName);
3238
+ const reactNodeType = t28.tsTypeAnnotation(
3239
+ t28.tsTypeReference(t28.identifier(REACT_API_MAP.ReactNode))
2983
3240
  );
2984
3241
  let typeAnnotation;
2985
3242
  if (rawName === SLOT_DEFAULT_NAME && params.length === 0 || params.length === 0) {
2986
3243
  typeAnnotation = reactNodeType;
2987
3244
  } else {
2988
- const fnType = t27.tsFunctionType(null, params, reactNodeType);
2989
- typeAnnotation = t27.tsTypeAnnotation(fnType);
3245
+ const fnType = t28.tsFunctionType(null, params, reactNodeType);
3246
+ typeAnnotation = t28.tsTypeAnnotation(fnType);
2990
3247
  }
2991
- const prop = t27.tsPropertySignature(key, typeAnnotation);
3248
+ const prop = t28.tsPropertySignature(key, typeAnnotation);
2992
3249
  prop.optional = optional;
2993
3250
  return prop;
2994
3251
  }
2995
3252
  function createSlotScopeParam(props, ctx) {
2996
- const paramId = t27.identifier(SLOT_FN_PARAM_NAME);
3253
+ const paramId = t28.identifier(SLOT_FN_PARAM_NAME);
2997
3254
  const propsSigns = [];
2998
3255
  const { reactiveBindings } = ctx.templateData;
2999
3256
  props.forEach(({ prop, tsType }) => {
3000
3257
  const foundBindingValue = reactiveBindings[prop]?.value;
3001
3258
  const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
3002
- const typeAnnotation = foundBindingTypes ? t27.tsTypeAnnotation(foundBindingTypes) : tsType;
3003
- const propSign = t27.tsPropertySignature(t27.identifier(prop), typeAnnotation);
3259
+ const typeAnnotation = foundBindingTypes ? t28.tsTypeAnnotation(foundBindingTypes) : tsType;
3260
+ const propSign = t28.tsPropertySignature(t28.identifier(prop), typeAnnotation);
3004
3261
  propsSigns.push(propSign);
3005
3262
  });
3006
- paramId.typeAnnotation = t27.tsTypeAnnotation(t27.tsTypeLiteral(propsSigns));
3263
+ paramId.typeAnnotation = t28.tsTypeAnnotation(t28.tsTypeLiteral(propsSigns));
3007
3264
  return paramId;
3008
3265
  }
3009
3266
  function resolvePropName2(key) {
3010
- if (t27.isIdentifier(key)) return key.name;
3011
- if (t27.isStringLiteral(key)) return key.value;
3012
- if (t27.isNumericLiteral(key)) return String(key.value);
3267
+ if (t28.isIdentifier(key)) return key.name;
3268
+ if (t28.isStringLiteral(key)) return key.value;
3269
+ if (t28.isNumericLiteral(key)) return String(key.value);
3013
3270
  return null;
3014
3271
  }
3015
3272
 
@@ -3061,65 +3318,17 @@ function resolveCompIProps(ctx, ast) {
3061
3318
  }
3062
3319
  const n = ctx.compName || "Comp";
3063
3320
  const ns = `I${camelCase(capitalize(n))}Props`;
3064
- const typeNode = t28.tsIntersectionType(tsTypes);
3065
- const typeAliasDecl = t28.tsTypeAliasDeclaration(t28.identifier(ns), null, typeNode);
3066
- const exportDecl = t28.exportNamedDeclaration(typeAliasDecl);
3321
+ const typeNode = t29.tsIntersectionType(tsTypes);
3322
+ const typeAliasDecl = t29.tsTypeAliasDeclaration(t29.identifier(ns), null, typeNode);
3323
+ const exportDecl = t29.exportNamedDeclaration(typeAliasDecl);
3067
3324
  propsTSIface.name = ns;
3068
3325
  const scriptIR = getScriptIR(ctx);
3069
3326
  scriptIR.exports.push(exportDecl);
3070
3327
  void ast;
3071
3328
  }
3072
3329
 
3073
- // src/core/transform/sfc/script/syntax-processor/process/lint-rules.ts
3074
- import * as t29 from "@babel/types";
3075
- function lintRules(ctx, ast) {
3076
- const inScriptFile = ctx.inputType !== "sfc";
3077
- return {
3078
- CallExpression(path7) {
3079
- const { node, parentPath } = path7;
3080
- if (!t29.isIdentifier(node.callee)) return;
3081
- const { name: callName } = node.callee;
3082
- const addLog = (t40) => {
3083
- logger.error(t40, {
3084
- file: ctx.filename,
3085
- source: ctx.scriptData.source,
3086
- loc: node.loc
3087
- });
3088
- };
3089
- const lintMacros = () => {
3090
- const macro = Object.values(MACRO_API_NAMES).find((v) => v === callName);
3091
- if (!macro) return;
3092
- if (inScriptFile) {
3093
- addLog(
3094
- `The ${macro} can only be used inside Vue SFC <script> blocks, not in separate script files.`
3095
- );
3096
- return;
3097
- }
3098
- if (!atComponentOrHookRoot(path7, ast.program)) {
3099
- addLog(
3100
- `The ${macro} must be defined at the top level of the component, not inside blocks or functions.`
3101
- );
3102
- return;
3103
- }
3104
- if (!parentPath.isVariableDeclarator()) {
3105
- addLog(
3106
- `The ${macro} macro must be assigned to a variable (e.g., const props = defineProps(...)).`
3107
- );
3108
- }
3109
- };
3110
- const lintHooks = () => {
3111
- if (!callName.startsWith("use")) return;
3112
- if (!atComponentOrHookRoot(path7, ast.program, inScriptFile)) {
3113
- addLog(
3114
- `The ${callName} hook must be called at the top level, not inside loops, conditions, or nested functions.`
3115
- );
3116
- }
3117
- };
3118
- lintMacros();
3119
- lintHooks();
3120
- }
3121
- };
3122
- }
3330
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
3331
+ import * as t31 from "@babel/types";
3123
3332
 
3124
3333
  // src/core/transform/sfc/script/shared/dependency-analyzer.ts
3125
3334
  import { traverse as traverse2 } from "@babel/core";
@@ -3369,19 +3578,48 @@ function getIsAnalyzed(node) {
3369
3578
  return getScriptNodeMeta(node)?.is_deps_analyzed;
3370
3579
  }
3371
3580
 
3372
- // src/core/transform/sfc/script/shared/hook-creator.ts
3373
- import * as t31 from "@babel/types";
3374
- function createUseCallback(body, deps) {
3375
- return t31.callExpression(t31.identifier(REACT_API_MAP.useCallback), [
3376
- body,
3377
- deps ?? t31.arrayExpression([])
3378
- ]);
3581
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
3582
+ function resolveAnalysisOnlyAdapter(ctx) {
3583
+ return {
3584
+ "CallExpression|Identifier"(path7) {
3585
+ const node = path7.node;
3586
+ const apiName = getApiName(node);
3587
+ const adapter = ADAPTER_RULES.runtime[apiName];
3588
+ if (!adapter || adapter.type !== "analyzed-deps") {
3589
+ return;
3590
+ }
3591
+ if (t31.isCallExpression(node)) {
3592
+ resolveCallNode(path7, adapter, ctx);
3593
+ } else {
3594
+ replaceIdName(node, adapter.target);
3595
+ }
3596
+ recordImport(ctx, adapter.package, adapter.target);
3597
+ }
3598
+ };
3379
3599
  }
3380
- function createUseMemo(body, deps) {
3381
- return t31.callExpression(t31.identifier(REACT_API_MAP.useMemo), [
3382
- t31.arrowFunctionExpression([], body),
3383
- deps ?? t31.arrayExpression([])
3384
- ]);
3600
+ function getApiName(node) {
3601
+ const isCallNode = t31.isCallExpression(node);
3602
+ let apiName = "";
3603
+ if (t31.isIdentifier(node)) {
3604
+ apiName = node.name;
3605
+ } else if (isCallNode && t31.isIdentifier(node.callee)) {
3606
+ apiName = node.callee.name;
3607
+ }
3608
+ return apiName;
3609
+ }
3610
+ function resolveCallNode(path7, adapter, ctx) {
3611
+ const { node } = path7;
3612
+ const { arguments: args } = node;
3613
+ if (!args.length) return;
3614
+ const fn = args[0];
3615
+ if (!t31.isArrowFunctionExpression(fn) && !t31.isFunctionExpression(fn)) {
3616
+ return;
3617
+ }
3618
+ const fnPath = path7.get("arguments")[0];
3619
+ const deps = analyzeDeps(fn, ctx, fnPath);
3620
+ args.push(deps);
3621
+ replaceCallName(node, adapter.target);
3622
+ recordImport(ctx, adapter.package, adapter.target);
3385
3623
  }
3386
3624
 
3387
3625
  // src/core/transform/sfc/script/syntax-processor/process/resolve-arrow-deps.ts
@@ -3455,8 +3693,78 @@ function isSkip(path7) {
3455
3693
  return (isCallback() || isMethod() || !isVariableDecl()) && !isReturnFunc();
3456
3694
  }
3457
3695
 
3458
- // src/core/transform/sfc/script/syntax-processor/process/resolve-expression-memo.ts
3696
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-element-ref.ts
3459
3697
  import * as t32 from "@babel/types";
3698
+ function resolveElementRef(ctx) {
3699
+ return {
3700
+ CallExpression(path7) {
3701
+ const {
3702
+ inputType,
3703
+ templateData: { refBindings }
3704
+ } = ctx;
3705
+ if (inputType !== "sfc") return;
3706
+ const { node } = path7;
3707
+ const isUseTemplateRef = isCalleeNamed(node, VUE_API_MAP.useTemplateRef);
3708
+ const isCompRefBindings = Object.keys(refBindings.componentRefs).length > 0 && isCalleeNamed(node, VUE_API_MAP.ref);
3709
+ const shouldProcess = isUseTemplateRef || isCompRefBindings;
3710
+ if (!shouldProcess) {
3711
+ return;
3712
+ }
3713
+ if (isCompRefBindings) {
3714
+ const varDeclaratorPath = getVariableDeclaratorPath(path7)?.node;
3715
+ if (!t32.isIdentifier(varDeclaratorPath?.id)) {
3716
+ return;
3717
+ }
3718
+ const varName = varDeclaratorPath.id.name;
3719
+ const compRef = refBindings.componentRefs[varName];
3720
+ if (!compRef) return;
3721
+ }
3722
+ node.arguments[0] = t32.identifier("null");
3723
+ resolveTypeParameters(ctx, path7);
3724
+ replaceCallName(node, REACT_API_MAP.useRef);
3725
+ recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
3726
+ },
3727
+ MemberExpression(path7) {
3728
+ resolveRefValueToCurrent(path7);
3729
+ }
3730
+ };
3731
+ }
3732
+ function resolveTypeParameters(ctx, path7) {
3733
+ const {
3734
+ templateData: { refBindings },
3735
+ scriptData
3736
+ } = ctx;
3737
+ const { node } = path7;
3738
+ const varDeclaratorNode = getVariableDeclaratorPath(path7)?.node;
3739
+ if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
3740
+ return;
3741
+ }
3742
+ const idName = varDeclaratorNode.id.name;
3743
+ const domBindingMeta = refBindings.domRefs[idName];
3744
+ const compBindingMeta = refBindings.componentRefs[idName];
3745
+ if (!node.typeParameters && (domBindingMeta || compBindingMeta)) {
3746
+ const type = compBindingMeta ? "any" : domBindingMeta.htmlType;
3747
+ node.typeParameters = t32.tsTypeParameterInstantiation([t32.tsTypeReference(t32.identifier(type))]);
3748
+ }
3749
+ }
3750
+ function resolveRefValueToCurrent(path7) {
3751
+ const { node } = path7;
3752
+ if (node.computed || !t32.isIdentifier(node.property) || node.property.name !== "value") {
3753
+ return;
3754
+ }
3755
+ const rootPath = findRootVariablePath(path7);
3756
+ if (!rootPath?.node || !t32.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
3757
+ return;
3758
+ }
3759
+ const rootId = findRootIdentifier(node);
3760
+ if (!t32.isIdentifier(node.object) || node.object.name !== rootId?.name) {
3761
+ return;
3762
+ }
3763
+ node.property.name = "current";
3764
+ }
3765
+
3766
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-expression-memo.ts
3767
+ import * as t33 from "@babel/types";
3460
3768
  function resolveExprMemo(ctx, ast) {
3461
3769
  const isScriptFile = ctx.inputType !== "sfc";
3462
3770
  return {
@@ -3468,7 +3776,7 @@ function resolveExprMemo(ctx, ast) {
3468
3776
  if (!atComponentOrHookRoot(path7, ast.program, isScriptFile)) {
3469
3777
  return false;
3470
3778
  }
3471
- if (t32.isCallExpression(init) && t32.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
3779
+ if (t33.isCallExpression(init) && t33.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
3472
3780
  return false;
3473
3781
  }
3474
3782
  return true;
@@ -3485,20 +3793,74 @@ function resolveExprMemo(ctx, ast) {
3485
3793
  };
3486
3794
  }
3487
3795
 
3796
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-lint-rules.ts
3797
+ import * as t34 from "@babel/types";
3798
+ function resolveLintRules(ctx, ast) {
3799
+ const inScriptFile = ctx.inputType !== "sfc";
3800
+ return {
3801
+ CallExpression(path7) {
3802
+ const { node, parentPath } = path7;
3803
+ if (!t34.isIdentifier(node.callee)) return;
3804
+ const { name: callName } = node.callee;
3805
+ const addLog = (t41) => {
3806
+ logger.error(t41, {
3807
+ file: ctx.filename,
3808
+ source: ctx.scriptData.source,
3809
+ loc: node.loc
3810
+ });
3811
+ };
3812
+ const lintMacros = () => {
3813
+ const macro = Object.values(MACRO_API_NAMES).find((v) => v === callName);
3814
+ if (!macro) return;
3815
+ if (inScriptFile) {
3816
+ addLog(
3817
+ `The ${macro} can only be used inside Vue SFC <script> blocks, not in separate script files.`
3818
+ );
3819
+ return;
3820
+ }
3821
+ if (!atComponentOrHookRoot(path7, ast.program)) {
3822
+ addLog(
3823
+ `The ${macro} must be defined at the top level of the component, not inside blocks or functions.`
3824
+ );
3825
+ return;
3826
+ }
3827
+ if (!parentPath.isVariableDeclarator()) {
3828
+ if (macro === MACRO_API_NAMES.props || macro === MACRO_API_NAMES.emits) {
3829
+ addLog(
3830
+ `The ${macro} macro must be assigned to a variable (e.g., const props = defineProps(...)).`
3831
+ );
3832
+ }
3833
+ }
3834
+ };
3835
+ const lintHooks = () => {
3836
+ if (!callName.startsWith("use")) return;
3837
+ if (!atComponentOrHookRoot(path7, ast.program, inScriptFile)) {
3838
+ addLog(
3839
+ `The ${callName} hook must be called at the top level, not inside loops, conditions, or nested functions.`
3840
+ );
3841
+ }
3842
+ };
3843
+ lintMacros();
3844
+ lintHooks();
3845
+ }
3846
+ };
3847
+ }
3848
+
3488
3849
  // src/core/transform/sfc/script/syntax-processor/process/resolve-provide.ts
3489
3850
  import { generate as generate3 } from "@babel/generator";
3490
- import * as t33 from "@babel/types";
3851
+ import * as t35 from "@babel/types";
3491
3852
  function resolveProvide(ctx) {
3492
3853
  if (ctx.inputType !== "sfc") return {};
3493
3854
  return {
3494
3855
  CallExpression(path7) {
3495
3856
  const { node } = path7;
3496
- if (!isCalleeNamed(node, "provide")) return;
3857
+ if (!isCalleeNamed(node, VUE_API_MAP.provide)) return;
3497
3858
  const { provide } = ctx.scriptData;
3498
3859
  const [key, value] = node.arguments;
3499
3860
  const target = findOrCreateCtxProvider(provide);
3861
+ const adapter = ADAPTER_RULES.runtime[VUE_API_MAP.provide];
3500
3862
  assignProviderValue(target, key, value);
3501
- recordImport(ctx, PACKAGE_NAME.runtime, ADAPTER_COMPS.Provider);
3863
+ recordImport(ctx, adapter.package, adapter.target);
3502
3864
  path7.parentPath.remove();
3503
3865
  }
3504
3866
  };
@@ -3516,13 +3878,13 @@ function findOrCreateCtxProvider(root) {
3516
3878
  function assignProviderValue(target, key, value) {
3517
3879
  const getRawExp = (exp) => {
3518
3880
  if (!exp) return "''";
3519
- if (t33.isStringLiteral(exp)) {
3881
+ if (t35.isStringLiteral(exp)) {
3520
3882
  return `'${exp.value}'`;
3521
3883
  }
3522
- if (t33.isNumericLiteral(exp)) {
3884
+ if (t35.isNumericLiteral(exp)) {
3523
3885
  return exp.value.toString();
3524
3886
  }
3525
- if (t33.isIdentifier(exp)) {
3887
+ if (t35.isIdentifier(exp)) {
3526
3888
  return exp.name;
3527
3889
  }
3528
3890
  try {
@@ -3537,165 +3899,70 @@ function assignProviderValue(target, key, value) {
3537
3899
  target.provide = {};
3538
3900
  }
3539
3901
 
3540
- // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-only-adapter.ts
3541
- import * as t34 from "@babel/types";
3542
- function resolveRenameOnlyAdapter(ctx) {
3543
- return {
3544
- "Identifier|CallExpression"(path7) {
3545
- resolveAdapterRules(PACKAGE_NAME.runtime, ADAPTER_HOOKS, path7, ctx);
3546
- resolveAdapterRules(PACKAGE_NAME.router, ADAPTER_ROUTER_APIS, path7, ctx);
3547
- }
3548
- };
3549
- }
3550
- function resolveAdapterRules(pkgName, rules, path7, ctx) {
3551
- const node = path7.node;
3552
- const isCallExpr = t34.isCallExpression(node);
3553
- let sourceName = "";
3554
- if (t34.isIdentifier(node)) {
3555
- sourceName = node.name;
3556
- } else if (isCallExpr && t34.isIdentifier(node.callee)) {
3557
- sourceName = node.callee.name;
3558
- }
3559
- const { pure, effectful } = rules.renameOnly;
3560
- const pureApi = pure[sourceName];
3561
- const effectfulApi = effectful[sourceName];
3562
- const adapter = pureApi || effectfulApi;
3563
- if (!adapter) return;
3564
- if (effectfulApi) {
3565
- const reactiveType = getReactiveType(sourceName);
3566
- const declaratorPath = getVariableDeclaratorPath(path7);
3567
- setScriptNodeMeta(declaratorPath?.node, {
3568
- is_reactive: true,
3569
- reactive_type: reactiveType
3570
- });
3571
- }
3572
- if (isCallExpr) {
3573
- replaceCallName(node, adapter);
3574
- } else {
3575
- replaceIdName(node, adapter);
3576
- }
3577
- recordImport(ctx, pkgName, adapter);
3578
- if (pkgName === PACKAGE_NAME.router && !ctx.route) {
3579
- ctx.route = true;
3580
- }
3581
- }
3582
-
3583
- // src/core/transform/sfc/script/syntax-processor/process/resolve-transform-adapter.ts
3584
- import * as t35 from "@babel/types";
3585
- function resolveTransformAdapter(ctx) {
3902
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-adapter.ts
3903
+ import * as t36 from "@babel/types";
3904
+ function resolveRenameAdapter(ctx) {
3586
3905
  return {
3587
- "Identifier|CallExpression"(path7) {
3588
- resolveTransformAdapterRules(PACKAGE_NAME.runtime, ADAPTER_HOOKS, path7, ctx);
3589
- resolveTransformAdapterRules(PACKAGE_NAME.router, ADAPTER_ROUTER_APIS, path7, ctx);
3906
+ "CallExpression|Identifier"(path7) {
3907
+ const node = path7.node;
3908
+ const isCallNode = t36.isCallExpression(node);
3909
+ let apiName = "";
3910
+ if (t36.isIdentifier(node)) {
3911
+ apiName = node.name;
3912
+ } else if (isCallNode && t36.isIdentifier(node.callee)) {
3913
+ apiName = node.callee.name;
3914
+ }
3915
+ const runtimeAdapter = ADAPTER_RULES.runtime[apiName];
3916
+ const routerAdapter = ADAPTER_RULES.router[apiName];
3917
+ const adapter = runtimeAdapter || routerAdapter;
3918
+ if (!adapter || adapter.type !== "rename") {
3919
+ return;
3920
+ }
3921
+ if (adapter.isTrackable) {
3922
+ const reactiveType = getReactiveType(apiName);
3923
+ const declaratorPath = getVariableDeclaratorPath(path7);
3924
+ setScriptNodeMeta(declaratorPath?.node, {
3925
+ is_reactive: true,
3926
+ reactive_type: reactiveType
3927
+ });
3928
+ }
3929
+ if (isCallNode) {
3930
+ replaceCallName(node, adapter.target);
3931
+ } else {
3932
+ replaceIdName(node, adapter.target);
3933
+ }
3934
+ if (adapter.package === PACKAGE_NAME.router && !ctx.route) {
3935
+ ctx.route = true;
3936
+ }
3937
+ recordImport(ctx, adapter.package, adapter.target);
3590
3938
  }
3591
3939
  };
3592
3940
  }
3593
- function resolveTransformAdapterRules(pkgName, rules, path7, ctx) {
3594
- const node = path7.node;
3595
- const isCallExpr = t35.isCallExpression(node);
3596
- let sourceName = "";
3597
- if (t35.isIdentifier(node)) {
3598
- sourceName = node.name;
3599
- } else if (isCallExpr && t35.isIdentifier(node.callee)) {
3600
- sourceName = node.callee.name;
3601
- }
3602
- const { pure, effectful } = rules.transform;
3603
- const watchEffectAdapter = findNestedAdapter(sourceName, pure.watchEffect);
3604
- if (watchEffectAdapter) {
3605
- if (isCallExpr) {
3606
- handleDependencyAnalysisAPI(
3607
- path7,
3608
- ctx,
3609
- watchEffectAdapter,
3610
- pkgName
3611
- );
3612
- } else {
3613
- replaceIdName(node, watchEffectAdapter);
3614
- recordImport(ctx, pkgName, watchEffectAdapter);
3615
- }
3616
- return;
3617
- }
3618
- const lifecycleAdapter = findNestedAdapter(sourceName, pure.lifecycle);
3619
- if (lifecycleAdapter) {
3620
- if (isCallExpr) {
3621
- handleDependencyAnalysisAPI(
3622
- path7,
3623
- ctx,
3624
- lifecycleAdapter,
3625
- pkgName
3626
- );
3627
- } else {
3628
- replaceIdName(node, lifecycleAdapter);
3629
- recordImport(ctx, pkgName, lifecycleAdapter);
3630
- }
3631
- return;
3632
- }
3633
- const pureApi = pure[sourceName];
3634
- if (pureApi) {
3635
- if (isCallExpr) {
3636
- replaceCallName(node, pureApi);
3637
- } else {
3638
- replaceIdName(node, pureApi);
3639
- }
3640
- recordImport(ctx, pkgName, pureApi);
3641
- return;
3642
- }
3643
- const effectfulApi = effectful[sourceName];
3644
- if (effectfulApi) {
3645
- if (isCallExpr) {
3646
- replaceCallName(node, effectfulApi);
3647
- } else {
3648
- replaceIdName(node, effectfulApi);
3649
- }
3650
- recordImport(ctx, pkgName, effectfulApi);
3651
- return;
3652
- }
3653
- }
3654
- function findNestedAdapter(sourceName, nestedMap) {
3655
- if (!nestedMap) return void 0;
3656
- if (typeof nestedMap === "string") {
3657
- return nestedMap;
3658
- }
3659
- return nestedMap[sourceName];
3660
- }
3661
- function handleDependencyAnalysisAPI(path7, ctx, adapter, pkgName) {
3662
- const { node } = path7;
3663
- const { arguments: args } = node;
3664
- if (args.length === 0) return;
3665
- const fn = args[0];
3666
- if (!t35.isArrowFunctionExpression(fn) && !t35.isFunctionExpression(fn)) {
3667
- return;
3668
- }
3669
- const fnPath = path7.get("arguments")[0];
3670
- const deps = analyzeDeps(fn, ctx, fnPath);
3671
- args.push(deps);
3672
- replaceCallName(node, adapter);
3673
- recordImport(ctx, pkgName, adapter);
3674
- }
3675
3941
 
3676
3942
  // src/core/transform/sfc/script/syntax-processor/index.ts
3677
3943
  function processVueSyntax2(ast, ctx) {
3678
3944
  vueSyntaxProcessor2(ast, ctx, {
3679
3945
  preprocess: {
3680
3946
  applyBabel: [
3681
- resolveOptions,
3947
+ resolvePropsIface,
3682
3948
  resolveEmitsTopLevelTypes,
3683
3949
  resolveSlotsTopLevelTypes,
3684
- resolvePropsIface,
3685
- resolveAsyncComponent,
3950
+ resolveDefineOptions,
3951
+ resolveDefineExpose,
3952
+ resolveDefineAsyncComponent,
3686
3953
  resolveEmitCalls
3687
3954
  ]
3688
3955
  },
3689
3956
  process: {
3690
3957
  applyBabel: [
3691
- resolveRenameOnlyAdapter,
3958
+ resolveElementRef,
3959
+ resolveRenameAdapter,
3692
3960
  resolveArrowFnDeps,
3693
3961
  resolveUnanalyzedArrow,
3694
- resolveTransformAdapter,
3695
- resolveTemplateRef,
3962
+ resolveAnalysisOnlyAdapter,
3696
3963
  resolveProvide,
3697
3964
  resolveExprMemo,
3698
- lintRules
3965
+ resolveLintRules
3699
3966
  ],
3700
3967
  excludeBabel: [resolveTemplateSlotIface, resolveCompIProps]
3701
3968
  },
@@ -3793,11 +4060,11 @@ function isRouterLinkBooleanCustomProp(prop) {
3793
4060
  }
3794
4061
 
3795
4062
  // src/core/transform/sfc/template/shared/prop-ir-utils.ts
3796
- import * as t38 from "@babel/types";
4063
+ import * as t39 from "@babel/types";
3797
4064
 
3798
4065
  // src/shared/string-code-types.ts
3799
4066
  import { parseExpression as parseExpression3 } from "@babel/parser";
3800
- import * as t36 from "@babel/types";
4067
+ import * as t37 from "@babel/types";
3801
4068
  var strCodeTypes = {
3802
4069
  isIdentifier: isIdentifier20,
3803
4070
  isSimpleExpression,
@@ -3810,22 +4077,22 @@ function isSimpleExpression(code, excludeVar = false) {
3810
4077
  } catch {
3811
4078
  return false;
3812
4079
  }
3813
- if (t36.isLiteral(node)) {
4080
+ if (t37.isLiteral(node)) {
3814
4081
  return true;
3815
4082
  }
3816
- if (!excludeVar && t36.isIdentifier(node)) {
4083
+ if (!excludeVar && t37.isIdentifier(node)) {
3817
4084
  return true;
3818
4085
  }
3819
- if (t36.isMemberExpression(node)) {
3820
- return isSimpleExpression(node.object) && t36.isIdentifier(node.property);
4086
+ if (t37.isMemberExpression(node)) {
4087
+ return isSimpleExpression(node.object) && t37.isIdentifier(node.property);
3821
4088
  }
3822
- if (t36.isObjectExpression(node) || t36.isArrayExpression(node)) {
4089
+ if (t37.isObjectExpression(node) || t37.isArrayExpression(node)) {
3823
4090
  return false;
3824
4091
  }
3825
- if (t36.isCallExpression(node) || t36.isAssignmentExpression(node)) {
4092
+ if (t37.isCallExpression(node) || t37.isAssignmentExpression(node)) {
3826
4093
  return false;
3827
4094
  }
3828
- if (t36.isBinaryExpression(node) || t36.isUnaryExpression(node)) {
4095
+ if (t37.isBinaryExpression(node) || t37.isUnaryExpression(node)) {
3829
4096
  return true;
3830
4097
  }
3831
4098
  return false;
@@ -3833,7 +4100,7 @@ function isSimpleExpression(code, excludeVar = false) {
3833
4100
  function isIdentifier20(code) {
3834
4101
  try {
3835
4102
  const node = parseExpression3(code);
3836
- return t36.isIdentifier(node);
4103
+ return t37.isIdentifier(node);
3837
4104
  } catch {
3838
4105
  return false;
3839
4106
  }
@@ -3841,14 +4108,14 @@ function isIdentifier20(code) {
3841
4108
  function isStringLiteral12(code) {
3842
4109
  try {
3843
4110
  const node = parseExpression3(code);
3844
- return t36.isStringLiteral(node) || t36.isTemplateLiteral(node);
4111
+ return t37.isStringLiteral(node) || t37.isTemplateLiteral(node);
3845
4112
  } catch {
3846
4113
  return false;
3847
4114
  }
3848
4115
  }
3849
4116
 
3850
4117
  // src/core/transform/sfc/template/shared/resolve-string-expression/index.ts
3851
- import * as t37 from "@babel/types";
4118
+ import * as t38 from "@babel/types";
3852
4119
 
3853
4120
  // src/core/transform/sfc/template/shared/resolve-string-expression/special-expressions.ts
3854
4121
  function resolveSpecialExpressions(input, ctx) {
@@ -3894,13 +4161,13 @@ function resolveRefVariable(input, ctx) {
3894
4161
 
3895
4162
  // src/core/transform/sfc/template/shared/resolve-string-expression/index.ts
3896
4163
  function resolveStringExpr(input, ctx, toStrLiteral = false) {
3897
- if (toStrLiteral) return t37.stringLiteral(input);
4164
+ if (toStrLiteral) return t38.stringLiteral(input);
3898
4165
  const { filename, scriptData } = ctx;
3899
4166
  const newContent = resolveSpecialExpressions(input, ctx);
3900
4167
  try {
3901
4168
  return stringToExpr(newContent, scriptData.lang, filename);
3902
4169
  } catch {
3903
- return t37.identifier(newContent);
4170
+ return t38.identifier(newContent);
3904
4171
  }
3905
4172
  }
3906
4173
 
@@ -4037,7 +4304,7 @@ function resolvePropAsBabelExp(ir, ctx) {
4037
4304
  const mergedItems = value.merge;
4038
4305
  const setNameIdentifier = (target, valueName) => {
4039
4306
  target.content = valueName;
4040
- target.ast = t38.jsxIdentifier(valueName);
4307
+ target.ast = t39.jsxIdentifier(valueName);
4041
4308
  };
4042
4309
  const setValueExpression = (target, content, isStringLiteral13) => {
4043
4310
  target.content = content;
@@ -4051,29 +4318,34 @@ function resolvePropAsBabelExp(ir, ctx) {
4051
4318
  if (setName && nameIdentifier) {
4052
4319
  setNameIdentifier(nameExp, nameIdentifier);
4053
4320
  }
4321
+ const dir = ADAPTER_RULES.runtime.dir;
4322
+ recordImport(ctx, dir.package, dir.target);
4054
4323
  setValueExpression(value.babelExp, expression, isStringLiteral13);
4055
- recordImport(ctx, PACKAGE_NAME.runtime, ADAPTER_UTILS_MAP.dir);
4056
4324
  };
4057
4325
  if (ir.isKeyLessVBind) {
4058
- const expression = createRuntimeCall(ADAPTER_UTILS_MAP.dirKeyless, [valueContent]);
4326
+ const dirKeyless = ADAPTER_RULES.runtime.dirKeyless;
4327
+ const expression = createRuntimeCall(dirKeyless.target, [valueContent]);
4059
4328
  applyRuntimeExpression(expression, false);
4060
4329
  return;
4061
4330
  }
4062
4331
  if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
4332
+ const dirCls = ADAPTER_RULES.runtime.dirCls;
4063
4333
  const arg = mergedItems?.join(",") || wrapSingleQuotes(valueContent);
4064
- const expression = createRuntimeCall(ADAPTER_UTILS_MAP.dirCls, [arg]);
4334
+ const expression = createRuntimeCall(dirCls.target, [arg]);
4065
4335
  applyRuntimeExpression(expression, true, name);
4066
4336
  return;
4067
4337
  }
4068
4338
  if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || mergedItems?.some((item) => !isSimpleStyle(item)))) {
4339
+ const dirStyle = ADAPTER_RULES.runtime.dirStyle;
4069
4340
  const arg = mergedItems?.join(",") || valueContent;
4070
- const expression = createRuntimeCall(ADAPTER_UTILS_MAP.dirStyle, [arg]);
4341
+ const expression = createRuntimeCall(dirStyle.target, [arg]);
4071
4342
  applyRuntimeExpression(expression, true, name);
4072
4343
  return;
4073
4344
  }
4074
4345
  if (ir.type === 3 /* EVENT */ && ir.modifiers?.length) {
4346
+ const dirOn = ADAPTER_RULES.runtime.dirOn;
4075
4347
  const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
4076
- const expression = createRuntimeCall(ADAPTER_UTILS_MAP.dirOn, [eventName, valueContent]);
4348
+ const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
4077
4349
  applyRuntimeExpression(expression, true, name);
4078
4350
  return;
4079
4351
  }
@@ -4126,12 +4398,12 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
4126
4398
  }
4127
4399
  const nodeIR = child;
4128
4400
  if (parentIR?.isBuiltIn) {
4129
- if (parentIR.tag == ADAPTER_COMPS.Transition) {
4401
+ if (parentIR.tag == VUE_API_MAP.Transition) {
4130
4402
  resolveTransitionRules(nodeIR, parentIR, ir, ctx);
4131
4403
  }
4132
4404
  }
4133
4405
  if (nodeIR.isRoute) {
4134
- if (nodeIR.tag === ADAPTER_ROUTER_COMPS.RouterLink) {
4406
+ if (nodeIR.tag === VUE_API_MAP.RouterLink) {
4135
4407
  resolveRouterLinkRules(nodeIR, ctx);
4136
4408
  }
4137
4409
  }
@@ -4338,7 +4610,7 @@ function resolveDynamicIsProp(node, ir, ctx, nodeIR) {
4338
4610
  }
4339
4611
  const propIR = createPropsIR("is", "is", content);
4340
4612
  resolvePropAsBabelExp(propIR, ctx);
4341
- nodeIR.tag = ADAPTER_COMPS.Component;
4613
+ nodeIR.tag = VUE_API_MAP.DynamicComponent;
4342
4614
  nodeIR.isComponent = true;
4343
4615
  nodeIR.props.push(propIR);
4344
4616
  recordImport(ctx, PACKAGE_NAME.runtime, nodeIR.tag);
@@ -4347,15 +4619,20 @@ function resolveDynamicIsProp(node, ir, ctx, nodeIR) {
4347
4619
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-ref-prop.ts
4348
4620
  import { NodeTypes as NodeTypes5 } from "@vue/compiler-core";
4349
4621
  function resolveRefProp(node, ctx, nodeIR) {
4350
- const { templateData } = ctx;
4622
+ const {
4623
+ templateData: { refBindings }
4624
+ } = ctx;
4351
4625
  let propIR;
4352
4626
  if (node.type === NodeTypes5.ATTRIBUTE) {
4353
- const tagName = node.value?.content;
4354
- const binding = Object.values(templateData.refBindings).find((r) => r.tag === tagName);
4355
- propIR = createPropsIR("ref", "ref", binding?.name || "null");
4627
+ const tag = node.value?.content;
4628
+ if (!tag) return;
4629
+ collectComponentRef(tag, ctx);
4630
+ const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
4631
+ const refVar = domRefBinding?.name || refBindings.componentRefs[tag]?.name;
4632
+ propIR = createPropsIR("ref", "ref", refVar || "null");
4356
4633
  } else {
4357
4634
  const exp = node.exp;
4358
- for (const name in templateData.refBindings) {
4635
+ for (const name in refBindings.domRefs) {
4359
4636
  const newName = `${name}.current`;
4360
4637
  const regex = new RegExp(`${name}(?!\\.current)`, "g");
4361
4638
  exp.content = exp.content.replace(regex, newName);
@@ -4365,6 +4642,22 @@ function resolveRefProp(node, ctx, nodeIR) {
4365
4642
  resolvePropAsBabelExp(propIR, ctx);
4366
4643
  nodeIR.props.push(propIR);
4367
4644
  }
4645
+ function collectComponentRef(tag, ctx) {
4646
+ if (tag in HTML_TAG_TYPES) {
4647
+ return;
4648
+ }
4649
+ const { refBindings, reactiveBindings } = ctx.templateData;
4650
+ refBindings.componentRefs[tag] = {
4651
+ tag,
4652
+ // 对应的标签名(随便填,不影响)
4653
+ htmlType: "",
4654
+ name: tag
4655
+ // 对应的变量名(随便填,不影响)
4656
+ };
4657
+ if (reactiveBindings[tag]) {
4658
+ delete reactiveBindings[tag];
4659
+ }
4660
+ }
4368
4661
 
4369
4662
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-dynamic-attribute-prop.ts
4370
4663
  function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
@@ -4631,7 +4924,7 @@ function getRootIdName(expr) {
4631
4924
  }
4632
4925
 
4633
4926
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-on.ts
4634
- import * as t39 from "@babel/types";
4927
+ import * as t40 from "@babel/types";
4635
4928
  function resolveVOn(node, _ir, ctx, nodeIR) {
4636
4929
  const arg = node.arg;
4637
4930
  const exp = node.exp;
@@ -4648,7 +4941,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
4648
4941
  originalVueEventName = `${arg.content}.${modifiers.join(".")}`;
4649
4942
  } else {
4650
4943
  const expr = stringToExpr(handler);
4651
- if (!t39.isFunctionExpression(expr) && !t39.isIdentifier(expr)) {
4944
+ if (!t40.isFunctionExpression(expr) && !t40.isIdentifier(expr)) {
4652
4945
  handler = `() => {${handler}}`;
4653
4946
  }
4654
4947
  }
@@ -4775,7 +5068,7 @@ function resolveDirectiveProp(node, ir, ctx, elementNode, nodeIR, siblingNodesIR
4775
5068
  return resolveVOn(node, ir, ctx, nodeIR);
4776
5069
  }
4777
5070
  if (isVSlot(rawName2)) {
4778
- if (nodeIR.tag === ADAPTER_ROUTER_COMPS.RouterLink) {
5071
+ if (nodeIR.tag === VUE_API_MAP.RouterLink) {
4779
5072
  resolveRouterLinkVSlotProp(node, nodeIR, ctx);
4780
5073
  }
4781
5074
  return true;
@@ -4849,14 +5142,16 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
4849
5142
  isSelfClosing: node.isSelfClosing,
4850
5143
  loc: node.loc
4851
5144
  });
4852
- if (tag in ADAPTER_COMPS) {
5145
+ const routerAdapter = ADAPTER_RULES.router[tag];
5146
+ const runtimeAdapter = ADAPTER_RULES.runtime[tag];
5147
+ if (runtimeAdapter) {
4853
5148
  nodeIR.isBuiltIn = true;
4854
- recordImport(ctx, PACKAGE_NAME.runtime, tag);
5149
+ recordImport(ctx, runtimeAdapter.package, runtimeAdapter.target);
4855
5150
  }
4856
- if (tag in ADAPTER_ROUTER_COMPS) {
5151
+ if (routerAdapter) {
4857
5152
  if (!ctx.route) ctx.route = true;
4858
5153
  nodeIR.isRoute = true;
4859
- recordImport(ctx, PACKAGE_NAME.router, tag);
5154
+ recordImport(ctx, routerAdapter?.package, routerAdapter.target);
4860
5155
  }
4861
5156
  resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
4862
5157
  return nodeIR;
@@ -5094,7 +5389,7 @@ function transform(ast, ctx, options) {
5094
5389
  }
5095
5390
 
5096
5391
  // package.json
5097
- var version = "1.1.0";
5392
+ var version = "1.1.1";
5098
5393
  var bin = {
5099
5394
  vureact: "./bin/vureact.js"
5100
5395
  };
@@ -5549,7 +5844,10 @@ var CompilationContext = class {
5549
5844
  propField: "$props",
5550
5845
  templateData: {
5551
5846
  slots: {},
5552
- refBindings: {},
5847
+ refBindings: {
5848
+ domRefs: {},
5849
+ componentRefs: {}
5850
+ },
5553
5851
  reactiveBindings: {}
5554
5852
  },
5555
5853
  scriptData: {
@@ -5566,6 +5864,10 @@ var CompilationContext = class {
5566
5864
  emitTypes: [],
5567
5865
  slotTypes: []
5568
5866
  },
5867
+ forwardRef: {
5868
+ enabled: false,
5869
+ refField: "expose"
5870
+ },
5569
5871
  source: ""
5570
5872
  },
5571
5873
  styleData: {