@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
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10;/**
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
  */
@@ -24,95 +24,351 @@ function executePlugins(map, result, ctx) {
24
24
  }
25
25
 
26
26
  // src/core/codegen/component/jsx/syntax-processor/postprocess/build-ctx-provider.ts
27
- var _types = require('@babel/types'); var t10 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t9 = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t4 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types); var t6 = _interopRequireWildcard(_types); var t8 = _interopRequireWildcard(_types); var t7 = _interopRequireWildcard(_types); var t13 = _interopRequireWildcard(_types); var t11 = _interopRequireWildcard(_types); var t12 = _interopRequireWildcard(_types); var t14 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t16 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types);
27
+ var _types = require('@babel/types'); var t10 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t9 = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t4 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types); var t6 = _interopRequireWildcard(_types); var t8 = _interopRequireWildcard(_types); var t7 = _interopRequireWildcard(_types); var t13 = _interopRequireWildcard(_types); var t11 = _interopRequireWildcard(_types); var t12 = _interopRequireWildcard(_types); var t14 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t16 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t40 = _interopRequireWildcard(_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"
103
264
  },
104
- effectful: {
105
- useRoute: "useRoute",
106
- useRouter: "useRouter",
107
- useLink: "useLink"
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"
275
+ },
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
 
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 (_optionalChain([program3, 'optionalAccess', _28 => _28.body, 'optionalAccess', _29 => _29.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 = _optionalChain([propsId, 'optionalAccess', _30 => _30.typeAnnotation, 'optionalAccess', _31 => _31.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,24 +1186,10 @@ 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 (_optionalChain([program3, 'optionalAccess', _28 => _28.body, 'optionalAccess', _29 => _29.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) {
897
- const statements = [_optionalChain([nodeIR, 'optionalAccess', _30 => _30.imports]), _optionalChain([nodeIR, 'optionalAccess', _31 => _31.tsTypes]), _optionalChain([nodeIR, 'optionalAccess', _32 => _32.exports]), _optionalChain([nodeIR, 'optionalAccess', _33 => _33.statement, 'access', _34 => _34.global])].flat().filter(Boolean);
1192
+ const statements = [_optionalChain([nodeIR, 'optionalAccess', _32 => _32.imports]), _optionalChain([nodeIR, 'optionalAccess', _33 => _33.tsTypes]), _optionalChain([nodeIR, 'optionalAccess', _34 => _34.exports]), _optionalChain([nodeIR, 'optionalAccess', _35 => _35.statement, 'access', _36 => _36.global])].flat().filter(Boolean);
898
1193
  state.preambleStatements = statements;
899
1194
  void ctx;
900
1195
  }
@@ -949,7 +1244,7 @@ function generateComponent(ir, ctx, options) {
949
1244
  code,
950
1245
  source: ctx.source
951
1246
  };
952
- executePlugins(_optionalChain([options, 'optionalAccess', _35 => _35.plugins]), result, ctx);
1247
+ executePlugins(_optionalChain([options, 'optionalAccess', _37 => _37.plugins]), result, ctx);
953
1248
  return result;
954
1249
  }
955
1250
 
@@ -963,7 +1258,7 @@ function generateOnlyScript(ir, ctx, options) {
963
1258
  code,
964
1259
  source: ctx.source
965
1260
  };
966
- executePlugins(_optionalChain([options, 'optionalAccess', _36 => _36.plugins]), result, ctx);
1261
+ executePlugins(_optionalChain([options, 'optionalAccess', _38 => _38.plugins]), result, ctx);
967
1262
  return result;
968
1263
  }
969
1264
 
@@ -1048,7 +1343,7 @@ function parseOnlyScript(source, ctx, options) {
1048
1343
  };
1049
1344
  ctx.scriptData.lang = lang;
1050
1345
  ctx.scriptData.source = source;
1051
- executePlugins(_optionalChain([options, 'optionalAccess', _37 => _37.plugins]), result, ctx);
1346
+ executePlugins(_optionalChain([options, 'optionalAccess', _39 => _39.plugins]), result, ctx);
1052
1347
  return result;
1053
1348
  }
1054
1349
 
@@ -1083,8 +1378,8 @@ function resolveScript(descriptor, ctx, pResult) {
1083
1378
  } else {
1084
1379
  result.ast = _parser.parse.call(void 0, result.source.content, options);
1085
1380
  }
1086
- if (_optionalChain([scriptBlock, 'optionalAccess', _38 => _38.warnings])) {
1087
- _optionalChain([scriptBlock, 'optionalAccess', _39 => _39.warnings, 'access', _40 => _40.forEach, 'call', _41 => _41((msg) => {
1381
+ if (_optionalChain([scriptBlock, 'optionalAccess', _40 => _40.warnings])) {
1382
+ _optionalChain([scriptBlock, 'optionalAccess', _41 => _41.warnings, 'access', _42 => _42.forEach, 'call', _43 => _43((msg) => {
1088
1383
  logger.warn(msg, { file: ctx.filename });
1089
1384
  })]);
1090
1385
  }
@@ -1159,7 +1454,7 @@ function extractSetupBodyToTopLevel(content, options) {
1159
1454
  }
1160
1455
  function extractCompName(source) {
1161
1456
  const nameMatch = source.match(/@vr-name:\s*(\w+)/);
1162
- return _optionalChain([nameMatch, 'optionalAccess', _42 => _42[1], 'optionalAccess', _43 => _43.trim, 'call', _44 => _44()]) || "";
1457
+ return _optionalChain([nameMatch, 'optionalAccess', _44 => _44[1], 'optionalAccess', _45 => _45.trim, 'call', _46 => _46()]) || "";
1163
1458
  }
1164
1459
 
1165
1460
  // src/core/parse/sfc/process/resolve-script-meta.ts
@@ -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",
@@ -1270,7 +1560,7 @@ function getReactiveStateApis() {
1270
1560
 
1271
1561
  // src/core/parse/sfc/process/resolve-script-meta.ts
1272
1562
  function resolveScriptMeta(result, ctx) {
1273
- const scriptAST = _optionalChain([result, 'access', _45 => _45.script, 'optionalAccess', _46 => _46.ast]);
1563
+ const scriptAST = _optionalChain([result, 'access', _47 => _47.script, 'optionalAccess', _48 => _48.ast]);
1274
1564
  if (!scriptAST) return;
1275
1565
  _core.traverse.call(void 0, scriptAST, {
1276
1566
  VariableDeclarator(path7) {
@@ -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] = {
@@ -1310,56 +1600,14 @@ function collectRefBindings(node, ctx) {
1310
1600
  const callee = init.callee;
1311
1601
  if (callee.name !== VUE_API_MAP.useTemplateRef) return;
1312
1602
  const idName = node.id.name;
1313
- const tag = _optionalChain([init, 'access', _47 => _47.arguments, 'access', _48 => _48[0], 'optionalAccess', _49 => _49.value]);
1314
- refBindings[idName] = {
1603
+ const tag = _optionalChain([init, 'access', _49 => _49.arguments, 'access', _50 => _50[0], 'optionalAccess', _51 => _51.value]);
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
  var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_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) {
@@ -1519,7 +1774,7 @@ function resolveStyles(descriptor, ctx, result) {
1519
1774
  var _compilercore = require('@vue/compiler-core');
1520
1775
  function resolveTemplate(descriptor, _, result) {
1521
1776
  const block = descriptor.template;
1522
- if (!_optionalChain([block, 'optionalAccess', _50 => _50.content])) return null;
1777
+ if (!_optionalChain([block, 'optionalAccess', _52 => _52.content])) return null;
1523
1778
  result.template = {
1524
1779
  ast: _compilercore.baseParse.call(void 0, block.content),
1525
1780
  source: block
@@ -1536,7 +1791,7 @@ function processVueSyntax(descriptor, ctx, result) {
1536
1791
  }
1537
1792
  function vueSyntaxProcessor(descriptor, ctx, result, options) {
1538
1793
  const run = (p, type) => {
1539
- _optionalChain([p, 'optionalAccess', _51 => _51.forEach, 'call', _52 => _52((handler) => {
1794
+ _optionalChain([p, 'optionalAccess', _53 => _53.forEach, 'call', _54 => _54((handler) => {
1540
1795
  if (type === "post") {
1541
1796
  handler(result, ctx);
1542
1797
  return;
@@ -1560,7 +1815,7 @@ function parseSFC(source, ctx, options) {
1560
1815
  };
1561
1816
  collectErrs(descriptor, errors);
1562
1817
  processVueSyntax(descriptor, ctx, result);
1563
- executePlugins(_optionalChain([options, 'optionalAccess', _53 => _53.plugins]), result, ctx);
1818
+ executePlugins(_optionalChain([options, 'optionalAccess', _55 => _55.plugins]), result, ctx);
1564
1819
  return result;
1565
1820
  }
1566
1821
  function collectErrs(descriptor, errors) {
@@ -1568,7 +1823,7 @@ function collectErrs(descriptor, errors) {
1568
1823
  logger.error(err.message, {
1569
1824
  source: descriptor.source,
1570
1825
  file: descriptor.filename,
1571
- loc: _optionalChain([err, 'optionalAccess', _54 => _54.loc])
1826
+ loc: _optionalChain([err, 'optionalAccess', _56 => _56.loc])
1572
1827
  });
1573
1828
  }
1574
1829
  if (descriptor.cssVars.length) {
@@ -1706,7 +1961,7 @@ function isVueEcosystemPackage(moduleName) {
1706
1961
  function mergeImports(currentNode, ctx) {
1707
1962
  const moduleName = currentNode.source.value.toLowerCase();
1708
1963
  const ctxImportItems = ctx.imports.get(moduleName);
1709
- if (!_optionalChain([ctxImportItems, 'optionalAccess', _55 => _55.length])) {
1964
+ if (!_optionalChain([ctxImportItems, 'optionalAccess', _57 => _57.length])) {
1710
1965
  return;
1711
1966
  }
1712
1967
  const currentImports = /* @__PURE__ */ new Set();
@@ -1760,7 +2015,7 @@ function createRequiredImports(ctx) {
1760
2015
 
1761
2016
  function findRootVariablePath(path7) {
1762
2017
  const rootId = findRootIdentifier(path7.node);
1763
- if (!_optionalChain([rootId, 'optionalAccess', _56 => _56.name])) return null;
2018
+ if (!_optionalChain([rootId, 'optionalAccess', _58 => _58.name])) return null;
1764
2019
  const binding = path7.scope.getBinding(rootId.name);
1765
2020
  if (!binding) return null;
1766
2021
  const rootPath = getVariableDeclaratorPath(binding.path);
@@ -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
 
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 (!_optionalChain([rootPath, 'optionalAccess', _57 => _57.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 !== _optionalChain([rootId, 'optionalAccess', _58 => _58.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 = _optionalChain([initVal, 'optionalAccess', _59 => _59.start]);
2028
- newVal.end = _optionalChain([initVal, 'optionalAccess', _60 => _60.end]);
2029
- newVal.loc = _optionalChain([initVal, 'optionalAccess', _61 => _61.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
-
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,31 +2278,31 @@ 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
  {
2083
2285
  source: scriptData.source,
2084
2286
  file: filename,
2085
- loc: _optionalChain([target, 'optionalAccess', _62 => _62.loc]) || {}
2287
+ loc: _optionalChain([target, 'optionalAccess', _59 => _59.loc]) || {}
2086
2288
  }
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;
@@ -2134,7 +2336,7 @@ function pushToGlobalScope(path7, ctx) {
2134
2336
  declarationPath = declarationPath.parentPath;
2135
2337
  }
2136
2338
  let fullNode;
2137
- if (_optionalChain([declarationPath, 'optionalAccess', _63 => _63.isVariableDeclaration, 'call', _64 => _64()])) {
2339
+ if (_optionalChain([declarationPath, 'optionalAccess', _60 => _60.isVariableDeclaration, 'call', _61 => _61()])) {
2138
2340
  fullNode = declarationPath.node;
2139
2341
  declarationPath.remove();
2140
2342
  } else if (path7.parentPath.isVariableDeclarator()) {
@@ -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
 
2153
- function resolveEmitCalls(ctx) {
2355
+
2356
+ // src/core/transform/sfc/script/shared/hook-creator.ts
2357
+
2358
+ function createUseCallback(body, deps) {
2359
+ return t21.callExpression(t21.identifier(REACT_API_MAP.useCallback), [
2360
+ body,
2361
+ _nullishCoalesce(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
+ _nullishCoalesce(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 ${_optionalChain([callee, 'optionalAccess', _65 => _65.type])}, expression will be removed`, {
2182
- file: filename,
2183
- source: scriptData.source,
2184
- loc: _optionalChain([callee, 'optionalAccess', _66 => _66.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
 
2205
- function resolveOptions(ctx) {
2410
+ function resolveDefineOptions(ctx) {
2206
2411
  return {
2207
2412
  CallExpression(path7) {
2208
2413
  const { node } = path7;
@@ -2215,7 +2420,7 @@ function resolveOptions(ctx) {
2215
2420
  logger.warn("defineOptions was found, but no options were provided.", {
2216
2421
  source: scriptData.source,
2217
2422
  file: filename,
2218
- loc: _optionalChain([node, 'optionalAccess', _67 => _67.loc])
2423
+ loc: _optionalChain([node, 'optionalAccess', _62 => _62.loc])
2219
2424
  });
2220
2425
  path7.remove();
2221
2426
  return;
@@ -2224,35 +2429,87 @@ function resolveOptions(ctx) {
2224
2429
  logger.warn("Argument for defineOptions must be an object expression.", {
2225
2430
  source: scriptData.source,
2226
2431
  file: filename,
2227
- loc: _optionalChain([options, 'optionalAccess', _68 => _68.loc])
2432
+ loc: _optionalChain([options, 'optionalAccess', _63 => _63.loc])
2228
2433
  });
2229
2434
  } else {
2230
2435
  for (const prop of options.properties) {
2231
2436
  if (!t23.isObjectProperty(prop) || !t23.isIdentifier(prop.key)) {
2232
2437
  continue;
2233
2438
  }
2234
- extractName(prop, ctx);
2439
+ extractName(prop, ctx);
2440
+ }
2441
+ }
2442
+ path7.remove();
2443
+ }
2444
+ };
2445
+ }
2446
+ function extractName(prop, ctx) {
2447
+ if (ctx.compName) return;
2448
+ const { filename, scriptData } = ctx;
2449
+ if (!prop.computed && prop.key.name === "name") {
2450
+ if (t23.isStringLiteral(prop.value)) {
2451
+ ctx.compName = prop.value.value;
2452
+ return;
2453
+ }
2454
+ logger.error(`name must be a string type, but got ${prop.value.type}`, {
2455
+ source: scriptData.source,
2456
+ file: filename,
2457
+ loc: _optionalChain([prop, 'access', _64 => _64.key, 'optionalAccess', _65 => _65.loc])
2458
+ });
2459
+ }
2460
+ }
2461
+
2462
+ // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-emit-calls.ts
2463
+
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
+ }
2235
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 ${_optionalChain([callee, 'optionalAccess', _66 => _66.type])}, expression will be removed`, {
2493
+ file: filename,
2494
+ source: scriptData.source,
2495
+ loc: _optionalChain([callee, 'optionalAccess', _67 => _67.loc])
2496
+ });
2497
+ path7.remove();
2498
+ return;
2236
2499
  }
2237
- path7.remove();
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);
2238
2510
  }
2239
2511
  };
2240
2512
  }
2241
- function extractName(prop, ctx) {
2242
- if (ctx.compName) return;
2243
- const { filename, scriptData } = ctx;
2244
- if (!prop.computed && prop.key.name === "name") {
2245
- if (t23.isStringLiteral(prop.value)) {
2246
- ctx.compName = prop.value.value;
2247
- return;
2248
- }
2249
- logger.error(`name must be a string type, but got ${prop.value.type}`, {
2250
- source: scriptData.source,
2251
- file: filename,
2252
- loc: _optionalChain([prop, 'access', _69 => _69.key, 'optionalAccess', _70 => _70.loc])
2253
- });
2254
- }
2255
- }
2256
2513
 
2257
2514
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/index.ts
2258
2515
 
@@ -2264,21 +2521,21 @@ function extractName(prop, ctx) {
2264
2521
 
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,55 +2567,55 @@ 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
  }
2357
2614
  function resolveDefineEmitsIface(path7, ctx) {
2358
2615
  const { node } = path7;
2359
2616
  const [runtimeArg] = node.arguments;
2360
- const tsParams = _optionalChain([node, 'access', _71 => _71.typeParameters, 'optionalAccess', _72 => _72.params]);
2361
- if (_optionalChain([tsParams, 'optionalAccess', _73 => _73.length])) {
2617
+ const tsParams = _optionalChain([node, 'access', _68 => _68.typeParameters, 'optionalAccess', _69 => _69.params]);
2618
+ if (_optionalChain([tsParams, 'optionalAccess', _70 => _70.length])) {
2362
2619
  processExplicitType(ctx, tsParams);
2363
2620
  return;
2364
2621
  }
@@ -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) {
@@ -2556,21 +2813,21 @@ function resolveEmitPropFromPropertySignature(member) {
2556
2813
  if (!rawName) return null;
2557
2814
  const handlerName = resolveEmitHandlerName(rawName);
2558
2815
  const key = buildKey(handlerName);
2559
- const typeAnnotation = _optionalChain([member, 'access', _74 => _74.typeAnnotation, 'optionalAccess', _75 => _75.typeAnnotation]);
2816
+ const typeAnnotation = _optionalChain([member, 'access', _71 => _71.typeAnnotation, 'optionalAccess', _72 => _72.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
- returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _76 => _76.typeAnnotation, 'optionalAccess', _77 => _77.typeAnnotation]), () => ( returnType));
2565
- } else if (typeAnnotation && t25.isTSTupleType(typeAnnotation)) {
2821
+ returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _73 => _73.typeAnnotation, 'optionalAccess', _74 => _74.typeAnnotation]), () => ( returnType));
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 = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _78 => _78.typeAnnotation]), () => ( t25.tsAnyKeyword()));
2846
+ const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _75 => _75.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,39 +2874,39 @@ 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
- const name = _optionalChain([tupleMember, 'access', _79 => _79.label, 'optionalAccess', _80 => _80.name]) || `arg${index}`;
2880
+ const name = _optionalChain([tupleMember, 'access', _76 => _76.label, 'optionalAccess', _77 => _77.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
 
@@ -2658,8 +2915,8 @@ function resolveTupleElementParam(element, index) {
2658
2915
  function resolveDefinePropsIface(path7, ctx) {
2659
2916
  const { node } = path7;
2660
2917
  const [runtimeArg] = node.arguments;
2661
- const tsParams = _optionalChain([node, 'access', _81 => _81.typeParameters, 'optionalAccess', _82 => _82.params]);
2662
- if (_optionalChain([tsParams, 'optionalAccess', _83 => _83.length])) {
2918
+ const tsParams = _optionalChain([node, 'access', _78 => _78.typeParameters, 'optionalAccess', _79 => _79.params]);
2919
+ if (_optionalChain([tsParams, 'optionalAccess', _80 => _80.length])) {
2663
2920
  const { propsTSIface } = ctx.scriptData;
2664
2921
  propsTSIface.propsTypes = tsParams;
2665
2922
  return;
@@ -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 = _nullishCoalesce(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 = _nullishCoalesce(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
  }
@@ -2714,47 +2971,47 @@ function processInferredTypes2(ctx, runtimeArg) {
2714
2971
  {
2715
2972
  source,
2716
2973
  file: filename,
2717
- loc: _optionalChain([runtimeArg, 'optionalAccess', _84 => _84.loc])
2974
+ loc: _optionalChain([runtimeArg, 'optionalAccess', _81 => _81.loc])
2718
2975
  }
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,34 +3021,34 @@ 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
 
@@ -2803,19 +3060,19 @@ 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) {
@@ -2828,8 +3085,8 @@ function resolveSlotsTopLevelTypes(ctx) {
2828
3085
  }
2829
3086
  function resolveDefineSlotsIface(path7, ctx) {
2830
3087
  const { node } = path7;
2831
- const tsParams = _optionalChain([node, 'access', _85 => _85.typeParameters, 'optionalAccess', _86 => _86.params]);
2832
- if (!_optionalChain([tsParams, 'optionalAccess', _87 => _87.length])) return;
3088
+ const tsParams = _optionalChain([node, 'access', _82 => _82.typeParameters, 'optionalAccess', _83 => _83.params]);
3089
+ if (!_optionalChain([tsParams, 'optionalAccess', _84 => _84.length])) return;
2833
3090
  const {
2834
3091
  propsTSIface: { slotTypes }
2835
3092
  } = ctx.scriptData;
@@ -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,110 +3163,110 @@ 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)) {
2946
- const typeAnnotation = _optionalChain([member, 'access', _88 => _88.typeAnnotation, 'optionalAccess', _89 => _89.typeAnnotation]);
3200
+ if (t28.isTSMethodSignature(member)) return true;
3201
+ if (t28.isTSCallSignatureDeclaration(member)) return true;
3202
+ if (t28.isTSPropertySignature(member)) {
3203
+ const typeAnnotation = _optionalChain([member, 'access', _85 => _85.typeAnnotation, 'optionalAccess', _86 => _86.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
- const typeAnnotation = _optionalChain([member, 'access', _90 => _90.typeAnnotation, 'optionalAccess', _91 => _91.typeAnnotation]);
3218
+ const typeAnnotation = _optionalChain([member, 'access', _87 => _87.typeAnnotation, 'optionalAccess', _88 => _88.typeAnnotation]);
2962
3219
  const callable = typeAnnotation ? resolveCallableType(typeAnnotation) : null;
2963
3220
  if (!callable) return null;
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
- const foundBindingValue = _optionalChain([reactiveBindings, 'access', _92 => _92[prop], 'optionalAccess', _93 => _93.value]);
3257
+ const foundBindingValue = _optionalChain([reactiveBindings, 'access', _89 => _89[prop], 'optionalAccess', _90 => _90.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
3330
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
3074
3331
 
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
- }
3123
3332
 
3124
3333
  // src/core/transform/sfc/script/shared/dependency-analyzer.ts
3125
3334
 
@@ -3245,7 +3454,7 @@ function analyzeDeps(node, ctx, parentPath) {
3245
3454
  const declaratorPath = getVariableDeclaratorPath(bindingPath);
3246
3455
  const isImportBinding = bindingPath.isImportSpecifier() || bindingPath.isImportDefaultSpecifier() || bindingPath.isImportNamespaceSpecifier();
3247
3456
  const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
3248
- const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _94 => _94.node, 'access', _95 => _95.init]);
3457
+ const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _91 => _91.node, 'access', _92 => _92.init]);
3249
3458
  const isReactiveApiCallVarBinding = !!declaratorPath && t30.isCallExpression(nodeInit) && t30.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
3250
3459
  const isHookCallVarBinding = !!declaratorPath && t30.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
3251
3460
  const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t30.isArrowFunctionExpression(nodeInit) || t30.isFunctionExpression(nodeInit));
@@ -3358,7 +3567,7 @@ function isNestedMemberObject(path7) {
3358
3567
  }
3359
3568
  function isReactiveBinding(node) {
3360
3569
  if (!node) return false;
3361
- return !!_optionalChain([getScriptNodeMeta, 'call', _96 => _96(node), 'optionalAccess', _97 => _97.is_reactive]);
3570
+ return !!_optionalChain([getScriptNodeMeta, 'call', _93 => _93(node), 'optionalAccess', _94 => _94.is_reactive]);
3362
3571
  }
3363
3572
  function markAsAnalyzed(node, flag = true) {
3364
3573
  const analyzed = getIsAnalyzed(node);
@@ -3366,22 +3575,51 @@ function markAsAnalyzed(node, flag = true) {
3366
3575
  setScriptNodeMeta(node, { is_deps_analyzed: flag });
3367
3576
  }
3368
3577
  function getIsAnalyzed(node) {
3369
- return _optionalChain([getScriptNodeMeta, 'call', _98 => _98(node), 'optionalAccess', _99 => _99.is_deps_analyzed]);
3578
+ return _optionalChain([getScriptNodeMeta, 'call', _95 => _95(node), 'optionalAccess', _96 => _96.is_deps_analyzed]);
3370
3579
  }
3371
3580
 
3372
- // src/core/transform/sfc/script/shared/hook-creator.ts
3373
-
3374
- function createUseCallback(body, deps) {
3375
- return t31.callExpression(t31.identifier(REACT_API_MAP.useCallback), [
3376
- body,
3377
- _nullishCoalesce(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
- _nullishCoalesce(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
@@ -3398,7 +3636,7 @@ function resolveArrowFnDeps(ctx, ast) {
3398
3636
  const declaratorPath = getVariableDeclaratorPath(path7);
3399
3637
  markAsAnalyzed(newNode.arguments[0]);
3400
3638
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
3401
- setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _100 => _100.node]), { is_reactive: true, reactive_type: "indirect" });
3639
+ setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _97 => _97.node]), { is_reactive: true, reactive_type: "indirect" });
3402
3640
  path7.replaceWith(newNode);
3403
3641
  }
3404
3642
  };
@@ -3411,7 +3649,7 @@ function resolveUnanalyzedArrow(ctx) {
3411
3649
  if (typeof analyzed === "undefined" || analyzed) return;
3412
3650
  const newNode = createUseCallback(node);
3413
3651
  const declaratorPath = getVariableDeclaratorPath(path7);
3414
- if (_optionalChain([declaratorPath, 'optionalAccess', _101 => _101.node])) {
3652
+ if (_optionalChain([declaratorPath, 'optionalAccess', _98 => _98.node])) {
3415
3653
  setScriptNodeMeta(declaratorPath.node, { is_reactive: true, reactive_type: "indirect" });
3416
3654
  }
3417
3655
  markAsAnalyzed(newNode.arguments[0]);
@@ -3455,6 +3693,76 @@ function isSkip(path7) {
3455
3693
  return (isCallback() || isMethod() || !isVariableDecl()) && !isReturnFunc();
3456
3694
  }
3457
3695
 
3696
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-element-ref.ts
3697
+
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 = _optionalChain([getVariableDeclaratorPath, 'call', _99 => _99(path7), 'optionalAccess', _100 => _100.node]);
3715
+ if (!t32.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _101 => _101.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 = _optionalChain([getVariableDeclaratorPath, 'call', _102 => _102(path7), 'optionalAccess', _103 => _103.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 (!_optionalChain([rootPath, 'optionalAccess', _104 => _104.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 !== _optionalChain([rootId, 'optionalAccess', _105 => _105.name])) {
3761
+ return;
3762
+ }
3763
+ node.property.name = "current";
3764
+ }
3765
+
3458
3766
  // src/core/transform/sfc/script/syntax-processor/process/resolve-expression-memo.ts
3459
3767
 
3460
3768
  function resolveExprMemo(ctx, ast) {
@@ -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,6 +3793,59 @@ function resolveExprMemo(ctx, ast) {
3485
3793
  };
3486
3794
  }
3487
3795
 
3796
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-lint-rules.ts
3797
+
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
 
3490
3851
 
@@ -3493,12 +3854,13 @@ function resolveProvide(ctx) {
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
  };
@@ -3508,7 +3870,7 @@ function findOrCreateCtxProvider(root) {
3508
3870
  return root;
3509
3871
  }
3510
3872
  let cur = root.provide;
3511
- while (_optionalChain([cur, 'optionalAccess', _102 => _102.isOccupied])) {
3873
+ while (_optionalChain([cur, 'optionalAccess', _106 => _106.isOccupied])) {
3512
3874
  cur = _nullishCoalesce(cur.provide, () => ( {}));
3513
3875
  }
3514
3876
  return cur || (root.provide = {});
@@ -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
-
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(_optionalChain([declaratorPath, 'optionalAccess', _103 => _103.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
3902
+ // src/core/transform/sfc/script/syntax-processor/process/resolve-rename-adapter.ts
3584
3903
 
3585
- function resolveTransformAdapter(ctx) {
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(_optionalChain([declaratorPath, 'optionalAccess', _107 => _107.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
  },
@@ -3707,12 +3974,12 @@ function processVueSyntax2(ast, ctx) {
3707
3974
  }
3708
3975
  function vueSyntaxProcessor2(ast, ctx, options) {
3709
3976
  const runExcludeThenApply = (cfg) => {
3710
- _optionalChain([cfg, 'access', _104 => _104.excludeBabel, 'optionalAccess', _105 => _105.forEach, 'call', _106 => _106((fn) => fn(ctx, ast))]);
3711
- _optionalChain([cfg, 'access', _107 => _107.applyBabel, 'optionalAccess', _108 => _108.forEach, 'call', _109 => _109((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
3977
+ _optionalChain([cfg, 'access', _108 => _108.excludeBabel, 'optionalAccess', _109 => _109.forEach, 'call', _110 => _110((fn) => fn(ctx, ast))]);
3978
+ _optionalChain([cfg, 'access', _111 => _111.applyBabel, 'optionalAccess', _112 => _112.forEach, 'call', _113 => _113((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
3712
3979
  };
3713
3980
  const runApplyThenExclude = (cfg) => {
3714
- _optionalChain([cfg, 'access', _110 => _110.applyBabel, 'optionalAccess', _111 => _111.forEach, 'call', _112 => _112((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
3715
- _optionalChain([cfg, 'access', _113 => _113.excludeBabel, 'optionalAccess', _114 => _114.forEach, 'call', _115 => _115((fn) => fn(ctx, ast))]);
3981
+ _optionalChain([cfg, 'access', _114 => _114.applyBabel, 'optionalAccess', _115 => _115.forEach, 'call', _116 => _116((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
3982
+ _optionalChain([cfg, 'access', _117 => _117.excludeBabel, 'optionalAccess', _118 => _118.forEach, 'call', _119 => _119((fn) => fn(ctx, ast))]);
3716
3983
  };
3717
3984
  runExcludeThenApply(options.preprocess);
3718
3985
  runExcludeThenApply(options.process);
@@ -3810,22 +4077,22 @@ function isSimpleExpression(code, excludeVar = false) {
3810
4077
  } catch (e5) {
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 = _parser.parseExpression.call(void 0, code);
3836
- return t36.isIdentifier(node);
4103
+ return t37.isIdentifier(node);
3837
4104
  } catch (e6) {
3838
4105
  return false;
3839
4106
  }
@@ -3841,7 +4108,7 @@ function isIdentifier20(code) {
3841
4108
  function isStringLiteral12(code) {
3842
4109
  try {
3843
4110
  const node = _parser.parseExpression.call(void 0, code);
3844
- return t36.isStringLiteral(node) || t36.isTemplateLiteral(node);
4111
+ return t37.isStringLiteral(node) || t37.isTemplateLiteral(node);
3845
4112
  } catch (e7) {
3846
4113
  return false;
3847
4114
  }
@@ -3886,7 +4153,7 @@ function resolveRefVariable(input, ctx) {
3886
4153
  };
3887
4154
  for (const name in reactiveBindings) {
3888
4155
  const binding = reactiveBindings[name];
3889
- if (_optionalChain([binding, 'optionalAccess', _116 => _116.reactiveType]) !== "ref") continue;
4156
+ if (_optionalChain([binding, 'optionalAccess', _120 => _120.reactiveType]) !== "ref") continue;
3890
4157
  input = addValueProperty(input, name);
3891
4158
  }
3892
4159
  return input;
@@ -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 (e8) {
3903
- return t37.identifier(newContent);
4170
+ return t38.identifier(newContent);
3904
4171
  }
3905
4172
  }
3906
4173
 
@@ -4005,12 +4272,12 @@ function wrapSingleQuotes(content, condition) {
4005
4272
  return condition || strCodeTypes.isStringLiteral(content) ? `'${content}'` : content;
4006
4273
  }
4007
4274
  function checkPropIsDynamicKey(ctx, node) {
4008
- const isKeyStatic = _optionalChain([node, 'access', _117 => _117.arg, 'optionalAccess', _118 => _118.isStatic]);
4275
+ const isKeyStatic = _optionalChain([node, 'access', _121 => _121.arg, 'optionalAccess', _122 => _122.isStatic]);
4009
4276
  const { source, filename } = ctx;
4010
4277
  if (node.rawName === "v-bind" && !node.name) {
4011
4278
  logger.warn("Keyless v-bind will overwrite all previously declared props at runtime.", {
4012
4279
  source,
4013
- loc: _optionalChain([node, 'access', _119 => _119.arg, 'optionalAccess', _120 => _120.loc]),
4280
+ loc: _optionalChain([node, 'access', _123 => _123.arg, 'optionalAccess', _124 => _124.loc]),
4014
4281
  file: filename
4015
4282
  });
4016
4283
  return;
@@ -4018,7 +4285,7 @@ function checkPropIsDynamicKey(ctx, node) {
4018
4285
  if (isKeyStatic === false) {
4019
4286
  logger.warn("Avoid using dynamic slot names, as they generate complex JSX prop expressions.", {
4020
4287
  source,
4021
- loc: _optionalChain([node, 'access', _121 => _121.arg, 'optionalAccess', _122 => _122.loc]),
4288
+ loc: _optionalChain([node, 'access', _125 => _125.arg, 'optionalAccess', _126 => _126.loc]),
4022
4289
  file: filename
4023
4290
  });
4024
4291
  }
@@ -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)) {
4063
- const arg = _optionalChain([mergedItems, 'optionalAccess', _123 => _123.join, 'call', _124 => _124(",")]) || wrapSingleQuotes(valueContent);
4064
- const expression = createRuntimeCall(ADAPTER_UTILS_MAP.dirCls, [arg]);
4332
+ const dirCls = ADAPTER_RULES.runtime.dirCls;
4333
+ const arg = _optionalChain([mergedItems, 'optionalAccess', _127 => _127.join, 'call', _128 => _128(",")]) || wrapSingleQuotes(valueContent);
4334
+ const expression = createRuntimeCall(dirCls.target, [arg]);
4065
4335
  applyRuntimeExpression(expression, true, name);
4066
4336
  return;
4067
4337
  }
4068
- if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _125 => _125.some, 'call', _126 => _126((item) => !isSimpleStyle(item))]))) {
4069
- const arg = _optionalChain([mergedItems, 'optionalAccess', _127 => _127.join, 'call', _128 => _128(",")]) || valueContent;
4070
- const expression = createRuntimeCall(ADAPTER_UTILS_MAP.dirStyle, [arg]);
4338
+ if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _129 => _129.some, 'call', _130 => _130((item) => !isSimpleStyle(item))]))) {
4339
+ const dirStyle = ADAPTER_RULES.runtime.dirStyle;
4340
+ const arg = _optionalChain([mergedItems, 'optionalAccess', _131 => _131.join, 'call', _132 => _132(",")]) || valueContent;
4341
+ const expression = createRuntimeCall(dirStyle.target, [arg]);
4071
4342
  applyRuntimeExpression(expression, true, name);
4072
4343
  return;
4073
4344
  }
4074
- if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _129 => _129.modifiers, 'optionalAccess', _130 => _130.length])) {
4345
+ if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _133 => _133.modifiers, 'optionalAccess', _134 => _134.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
  }
@@ -4125,13 +4397,13 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
4125
4397
  continue;
4126
4398
  }
4127
4399
  const nodeIR = child;
4128
- if (_optionalChain([parentIR, 'optionalAccess', _131 => _131.isBuiltIn])) {
4129
- if (parentIR.tag == ADAPTER_COMPS.Transition) {
4400
+ if (_optionalChain([parentIR, 'optionalAccess', _135 => _135.isBuiltIn])) {
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
  }
@@ -4166,7 +4438,7 @@ function walkElementNodes(node, onElement) {
4166
4438
  }
4167
4439
  function resolveDefaultStyleModuleName(node) {
4168
4440
  const { exp } = node;
4169
- if (_optionalChain([exp, 'optionalAccess', _132 => _132.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4441
+ if (_optionalChain([exp, 'optionalAccess', _136 => _136.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4170
4442
  return;
4171
4443
  }
4172
4444
  if (exp.content.includes("$style")) {
@@ -4202,7 +4474,7 @@ function injectStyleScopeAttribute(node, ctx) {
4202
4474
  return;
4203
4475
  }
4204
4476
  const hasDynamicIs = node.props.some((prop) => {
4205
- if (prop.type !== _compilercore.NodeTypes.DIRECTIVE || _optionalChain([prop, 'access', _133 => _133.arg, 'optionalAccess', _134 => _134.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4477
+ if (prop.type !== _compilercore.NodeTypes.DIRECTIVE || _optionalChain([prop, 'access', _137 => _137.arg, 'optionalAccess', _138 => _138.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4206
4478
  return false;
4207
4479
  }
4208
4480
  return prop.arg.content === "is";
@@ -4268,7 +4540,7 @@ function mergeStyleProps(oldAttr, newAttr) {
4268
4540
  const oldStyle = oldAttr.value.content;
4269
4541
  const newStyle = parseStyleString(newAttr.value.content);
4270
4542
  let merged = oldAttr.value.merge;
4271
- if (!_optionalChain([merged, 'optionalAccess', _135 => _135.length])) {
4543
+ if (!_optionalChain([merged, 'optionalAccess', _139 => _139.length])) {
4272
4544
  merged = oldAttr.value.merge = [oldStyle, newStyle];
4273
4545
  } else {
4274
4546
  merged.push(newStyle);
@@ -4298,7 +4570,7 @@ function warnUnsupportedVueDollarVar(ctx, node) {
4298
4570
  const { source, filename } = ctx;
4299
4571
  let value = "";
4300
4572
  let loc;
4301
- if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _136 => _136.exp, 'optionalAccess', _137 => _137.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4573
+ if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _140 => _140.exp, 'optionalAccess', _141 => _141.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4302
4574
  value = node.exp.content;
4303
4575
  loc = node.exp.loc;
4304
4576
  } else if (node.type === _compilercore.NodeTypes.INTERPOLATION && node.content.type === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
@@ -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
 
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 === _compilercore.NodeTypes.ATTRIBUTE) {
4353
- const tagName = _optionalChain([node, 'access', _138 => _138.value, 'optionalAccess', _139 => _139.content]);
4354
- const binding = Object.values(templateData.refBindings).find((r) => r.tag === tagName);
4355
- propIR = createPropsIR("ref", "ref", _optionalChain([binding, 'optionalAccess', _140 => _140.name]) || "null");
4627
+ const tag = _optionalChain([node, 'access', _142 => _142.value, 'optionalAccess', _143 => _143.content]);
4628
+ if (!tag) return;
4629
+ collectComponentRef(tag, ctx);
4630
+ const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
4631
+ const refVar = _optionalChain([domRefBinding, 'optionalAccess', _144 => _144.name]) || _optionalChain([refBindings, 'access', _145 => _145.componentRefs, 'access', _146 => _146[tag], 'optionalAccess', _147 => _147.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,13 +4642,29 @@ 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) {
4371
4664
  const arg = node.arg;
4372
4665
  const exp = node.exp;
4373
- const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _141 => _141.content]), () => ( ""));
4374
- const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _142 => _142.content]), () => ( "true"));
4666
+ const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _148 => _148.content]), () => ( ""));
4667
+ const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _149 => _149.content]), () => ( "true"));
4375
4668
  warnUnsupportedVueDollarVar(ctx, node);
4376
4669
  if (name === "is") {
4377
4670
  resolveDynamicIsProp(node, ir, ctx, nodeIR);
@@ -4382,7 +4675,7 @@ function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
4382
4675
  return;
4383
4676
  }
4384
4677
  const dynamicPropIR = createPropsIR(node.rawName, name, content);
4385
- dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _143 => _143.isStatic]), () => ( true));
4678
+ dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _150 => _150.isStatic]), () => ( true));
4386
4679
  checkPropIsDynamicKey(ctx, node);
4387
4680
  resolvePropertyIR(dynamicPropIR, ir, ctx, nodeIR, true);
4388
4681
  }
@@ -4410,7 +4703,7 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
4410
4703
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
4411
4704
  function resolveAttributeProp(node, ir, ctx, nodeIR) {
4412
4705
  const name = node.name;
4413
- const content = _nullishCoalesce(_optionalChain([node, 'access', _144 => _144.value, 'optionalAccess', _145 => _145.content]), () => ( "true"));
4706
+ const content = _nullishCoalesce(_optionalChain([node, 'access', _151 => _151.value, 'optionalAccess', _152 => _152.content]), () => ( "true"));
4414
4707
  if (name === "is") {
4415
4708
  resolveStaticIsProp(content, ir, ctx, nodeIR);
4416
4709
  return;
@@ -4434,10 +4727,10 @@ function resolveRouterLinkVSlotProp(node, nodeIR, ctx) {
4434
4727
  type: 2 /* SLOT */,
4435
4728
  name: "customRender",
4436
4729
  rawName: _nullishCoalesce(node.rawName, () => ( "v-slot")),
4437
- isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _146 => _146.isStatic]), () => ( true)),
4730
+ isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _153 => _153.isStatic]), () => ( true)),
4438
4731
  isScoped: true,
4439
4732
  callback: {
4440
- arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _147 => _147.content, 'optionalAccess', _148 => _148.trim, 'call', _149 => _149()]), () => ( "")),
4733
+ arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _154 => _154.content, 'optionalAccess', _155 => _155.trim, 'call', _156 => _156()]), () => ( "")),
4441
4734
  exp: []
4442
4735
  }
4443
4736
  };
@@ -4453,10 +4746,10 @@ function resolveVFor(node, _ir, _ctx, nodeIR) {
4453
4746
  };
4454
4747
  }
4455
4748
  function resolveForResult(forParseResult) {
4456
- const source = _optionalChain([forParseResult, 'access', _150 => _150.source, 'optionalAccess', _151 => _151.content]);
4457
- const value = _optionalChain([forParseResult, 'access', _152 => _152.value, 'optionalAccess', _153 => _153.content]);
4458
- const index = _optionalChain([forParseResult, 'access', _154 => _154.index, 'optionalAccess', _155 => _155.content]);
4459
- const key = _optionalChain([forParseResult, 'access', _156 => _156.key, 'optionalAccess', _157 => _157.content]);
4749
+ const source = _optionalChain([forParseResult, 'access', _157 => _157.source, 'optionalAccess', _158 => _158.content]);
4750
+ const value = _optionalChain([forParseResult, 'access', _159 => _159.value, 'optionalAccess', _160 => _160.content]);
4751
+ const index = _optionalChain([forParseResult, 'access', _161 => _161.index, 'optionalAccess', _162 => _162.content]);
4752
+ const key = _optionalChain([forParseResult, 'access', _163 => _163.key, 'optionalAccess', _164 => _164.content]);
4460
4753
  return {
4461
4754
  source,
4462
4755
  value,
@@ -4476,7 +4769,7 @@ function resolveVHtml(node, ir, ctx, nodeIR) {
4476
4769
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
4477
4770
  function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
4478
4771
  const name = node.name === "else-if" ? "elseIf" : node.name;
4479
- const value = _nullishCoalesce(_optionalChain([node, 'access', _158 => _158.exp, 'optionalAccess', _159 => _159.content]), () => ( "true"));
4772
+ const value = _nullishCoalesce(_optionalChain([node, 'access', _165 => _165.exp, 'optionalAccess', _166 => _166.content]), () => ( "true"));
4480
4773
  const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
4481
4774
  const isElseBranch = name === "else" || name === "elseIf";
4482
4775
  let hasError = false;
@@ -4515,7 +4808,7 @@ function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
4515
4808
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
4516
4809
  function resolveVMemo(node, _ir, ctx, nodeIR) {
4517
4810
  const exp = node.exp;
4518
- let value = _optionalChain([exp, 'optionalAccess', _160 => _160.content]);
4811
+ let value = _optionalChain([exp, 'optionalAccess', _167 => _167.content]);
4519
4812
  if (value !== void 0) {
4520
4813
  if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
4521
4814
  const { source, filename } = ctx;
@@ -4555,7 +4848,7 @@ function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
4555
4848
  const getterName = exp.content;
4556
4849
  const isComponent = elementNode.tagType === _compilercore.ElementTypes.COMPONENT;
4557
4850
  const inputType = resolveHtmlInput(elementNode, isComponent);
4558
- const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _161 => _161.content]), () => ( resolveModelPropName(inputType, isComponent)));
4851
+ const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _168 => _168.content]), () => ( resolveModelPropName(inputType, isComponent)));
4559
4852
  let valuePropIR;
4560
4853
  let eventPropIR;
4561
4854
  if (isComponent) {
@@ -4563,7 +4856,7 @@ function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
4563
4856
  const getterNamespace = getRootIdName(getterName);
4564
4857
  const eventReactName = `onUpdate${capitalize(getterNamespace)}`;
4565
4858
  const eventVueName = `update:${getterNamespace}`;
4566
- const isTS = _optionalChain([ctx, 'access', _162 => _162.scriptData, 'optionalAccess', _163 => _163.lang, 'optionalAccess', _164 => _164.startsWith, 'call', _165 => _165("ts")]);
4859
+ const isTS = _optionalChain([ctx, 'access', _169 => _169.scriptData, 'optionalAccess', _170 => _170.lang, 'optionalAccess', _171 => _171.startsWith, 'call', _172 => _172("ts")]);
4567
4860
  const valueArg = isTS ? "value: any" : "value";
4568
4861
  const processedValue = applyValueModifiers("value", modifiers);
4569
4862
  const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
@@ -4601,7 +4894,7 @@ function getRadioValue(elementNode) {
4601
4894
  const valueAttr = elementNode.props.find(
4602
4895
  (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
4603
4896
  );
4604
- if (!_optionalChain([valueAttr, 'optionalAccess', _166 => _166.value, 'optionalAccess', _167 => _167.content])) return '""';
4897
+ if (!_optionalChain([valueAttr, 'optionalAccess', _173 => _173.value, 'optionalAccess', _174 => _174.content])) return '""';
4605
4898
  const content = valueAttr.value.content;
4606
4899
  return /^['"]/.test(content) ? content : `"${content}"`;
4607
4900
  }
@@ -4611,7 +4904,7 @@ function resolveHtmlInput(node, isComponent) {
4611
4904
  const typeProp = node.props.find(
4612
4905
  (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
4613
4906
  );
4614
- return _optionalChain([typeProp, 'optionalAccess', _168 => _168.value, 'optionalAccess', _169 => _169.content, 'optionalAccess', _170 => _170.toLowerCase, 'call', _171 => _171()]);
4907
+ return _optionalChain([typeProp, 'optionalAccess', _175 => _175.value, 'optionalAccess', _176 => _176.content, 'optionalAccess', _177 => _177.toLowerCase, 'call', _178 => _178()]);
4615
4908
  }
4616
4909
  function applyValueModifiers(valueExp, modifiers) {
4617
4910
  let result = valueExp;
@@ -4627,7 +4920,7 @@ function getRootIdName(expr) {
4627
4920
  if (typeof expr !== "string") return;
4628
4921
  const pattern = /^([a-zA-Z_$][a-zA-Z0-9_$]*)(?:[\.\?\.\[\(].*)?$/;
4629
4922
  const match = pattern.exec(expr.trim());
4630
- return _optionalChain([match, 'optionalAccess', _172 => _172[1]]);
4923
+ return _optionalChain([match, 'optionalAccess', _179 => _179[1]]);
4631
4924
  }
4632
4925
 
4633
4926
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-on.ts
@@ -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;
@@ -4816,7 +5109,7 @@ function resolveVSlotProp(node, _ir, ctx) {
4816
5109
  const name = !arg || arg.content === "default" ? "children" : arg.content;
4817
5110
  const content = !isScoped ? [] : void 0;
4818
5111
  const callback = isScoped ? {
4819
- arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _173 => _173.content, 'optionalAccess', _174 => _174.trim, 'call', _175 => _175()]), () => ( "")),
5112
+ arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _180 => _180.content, 'optionalAccess', _181 => _181.trim, 'call', _182 => _182()]), () => ( "")),
4820
5113
  exp: []
4821
5114
  } : void 0;
4822
5115
  checkPropIsDynamicKey(ctx, node);
@@ -4824,7 +5117,7 @@ function resolveVSlotProp(node, _ir, ctx) {
4824
5117
  type: 2 /* SLOT */,
4825
5118
  name,
4826
5119
  rawName: _nullishCoalesce(node.rawName, () => ( "default")),
4827
- isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _176 => _176.isStatic]), () => ( true)),
5120
+ isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _183 => _183.isStatic]), () => ( true)),
4828
5121
  isScoped,
4829
5122
  content,
4830
5123
  callback
@@ -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, _optionalChain([routerAdapter, 'optionalAccess', _184 => _184.package]), routerAdapter.target);
4860
5155
  }
4861
5156
  resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
4862
5157
  return nodeIR;
@@ -4992,7 +5287,7 @@ function resolveSlotProps(node, ctx) {
4992
5287
  for (const prop of node.props) {
4993
5288
  if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
4994
5289
  const attr = prop.name;
4995
- const value = _optionalChain([prop, 'access', _177 => _177.value, 'optionalAccess', _178 => _178.content, 'access', _179 => _179.trim, 'call', _180 => _180()]);
5290
+ const value = _optionalChain([prop, 'access', _185 => _185.value, 'optionalAccess', _186 => _186.content, 'access', _187 => _187.trim, 'call', _188 => _188()]);
4996
5291
  if (attr === "name" && value) {
4997
5292
  result.name = camelCase(value);
4998
5293
  } else {
@@ -5082,19 +5377,19 @@ function resolveTemplate2(root, ctx) {
5082
5377
  // src/core/transform/sfc/index.ts
5083
5378
  function transform(ast, ctx, options) {
5084
5379
  const { template, script, style } = ast;
5085
- const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _181 => _181.ast]), ctx);
5086
- const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _182 => _182.ast]), ctx);
5380
+ const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _189 => _189.ast]), ctx);
5381
+ const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _190 => _190.ast]), ctx);
5087
5382
  const result = {
5088
5383
  template: templateIR,
5089
5384
  script: scriptIR,
5090
- style: _optionalChain([style, 'optionalAccess', _183 => _183.source, 'optionalAccess', _184 => _184.content])
5385
+ style: _optionalChain([style, 'optionalAccess', _191 => _191.source, 'optionalAccess', _192 => _192.content])
5091
5386
  };
5092
- executePlugins(_optionalChain([options, 'optionalAccess', _185 => _185.plugins]), result, ctx);
5387
+ executePlugins(_optionalChain([options, 'optionalAccess', _193 => _193.plugins]), result, ctx);
5093
5388
  return result;
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
  };
@@ -5152,7 +5447,7 @@ var Helper = (_class3 = class {
5152
5447
  __init6() {this.outDir = "react-app"}
5153
5448
  constructor(opts) {;_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);
5154
5449
  this.compilerOpts = opts;
5155
- if (_optionalChain([opts, 'access', _186 => _186.output, 'optionalAccess', _187 => _187.workspace])) {
5450
+ if (_optionalChain([opts, 'access', _194 => _194.output, 'optionalAccess', _195 => _195.workspace])) {
5156
5451
  this.workspaceDir = opts.output.workspace;
5157
5452
  }
5158
5453
  const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
@@ -5187,7 +5482,7 @@ var Helper = (_class3 = class {
5187
5482
  }
5188
5483
  getOutDirName() {
5189
5484
  const { output } = this.compilerOpts;
5190
- return _optionalChain([output, 'optionalAccess', _188 => _188.outDir]) || this.outDir;
5485
+ return _optionalChain([output, 'optionalAccess', _196 => _196.outDir]) || this.outDir;
5191
5486
  }
5192
5487
  getWorkspaceDir() {
5193
5488
  return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
@@ -5201,7 +5496,7 @@ var Helper = (_class3 = class {
5201
5496
  }
5202
5497
  getIgnoreAssets() {
5203
5498
  const { output } = this.compilerOpts;
5204
- if (_optionalChain([output, 'optionalAccess', _189 => _189.ignoreAssets])) {
5499
+ if (_optionalChain([output, 'optionalAccess', _197 => _197.ignoreAssets])) {
5205
5500
  return new Set(output.ignoreAssets.map(normalizePath));
5206
5501
  }
5207
5502
  return /* @__PURE__ */ new Set([
@@ -5282,12 +5577,12 @@ var Helper = (_class3 = class {
5282
5577
  */
5283
5578
  async formatCode({ code, fileInfo }) {
5284
5579
  const { format } = this.compilerOpts;
5285
- if (!_optionalChain([format, 'optionalAccess', _190 => _190.enabled])) return code;
5286
- if (_optionalChain([format, 'optionalAccess', _191 => _191.formatter]) === "builtin") {
5580
+ if (!_optionalChain([format, 'optionalAccess', _198 => _198.enabled])) return code;
5581
+ if (_optionalChain([format, 'optionalAccess', _199 => _199.formatter]) === "builtin") {
5287
5582
  return simpleFormat(code);
5288
5583
  }
5289
- const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _192 => _192.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _193 => _193.script])));
5290
- return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _194 => _194.prettierOptions]));
5584
+ const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _200 => _200.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _201 => _201.script])));
5585
+ return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _202 => _202.prettierOptions]));
5291
5586
  }
5292
5587
  /**
5293
5588
  * 通用的缓存校验工具函数
@@ -5420,7 +5715,7 @@ var Helper = (_class3 = class {
5420
5715
  }
5421
5716
  resolveViteCreateApp() {
5422
5717
  const { output } = this.compilerOpts;
5423
- const config = _optionalChain([output, 'optionalAccess', _195 => _195.bootstrapVite]);
5718
+ const config = _optionalChain([output, 'optionalAccess', _203 => _203.bootstrapVite]);
5424
5719
  const template = typeof config === "object" ? config.template : "react-ts";
5425
5720
  const outDirName = this.getOutDirName();
5426
5721
  const cmd = `npm create vite@latest ${outDirName} -- --template ${template}`;
@@ -5434,7 +5729,7 @@ var Helper = (_class3 = class {
5434
5729
  * 获取需要排除编译的文件
5435
5730
  */
5436
5731
  getExcludes() {
5437
- if (!_optionalChain([this, 'access', _196 => _196.compilerOpts, 'access', _197 => _197.exclude, 'optionalAccess', _198 => _198.length])) {
5732
+ if (!_optionalChain([this, 'access', _204 => _204.compilerOpts, 'access', _205 => _205.exclude, 'optionalAccess', _206 => _206.length])) {
5438
5733
  return PathFilter.withDefaults();
5439
5734
  }
5440
5735
  return this.compilerOpts.exclude;
@@ -5515,7 +5810,7 @@ function parseOnlyStyle(source, ctx, options) {
5515
5810
  ast: void 0
5516
5811
  }
5517
5812
  };
5518
- executePlugins(_optionalChain([options, 'optionalAccess', _199 => _199.plugins]), result, ctx);
5813
+ executePlugins(_optionalChain([options, 'optionalAccess', _207 => _207.plugins]), result, ctx);
5519
5814
  return result;
5520
5815
  }
5521
5816
 
@@ -5549,7 +5844,10 @@ var CompilationContext = (_class4 = class {constructor() { _class4.prototype.__i
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 = (_class4 = class {constructor() { _class4.prototype.__i
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: {
@@ -5694,16 +5996,16 @@ var BaseCompiler = (_class5 = class extends Helper {
5694
5996
  });
5695
5997
  const genOptions = this.prepareGenerateOptions(filename);
5696
5998
  const resolveSFCAndScriptFile = () => {
5697
- const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _200 => _200.parser]) });
5698
- const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _201 => _201.transformer]) });
5999
+ const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _208 => _208.parser]) });
6000
+ const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _209 => _209.transformer]) });
5699
6001
  const gen = generate(ir, ctx.data, {
5700
6002
  ...genOptions,
5701
- plugins: _optionalChain([plugins, 'optionalAccess', _202 => _202.codegen])
6003
+ plugins: _optionalChain([plugins, 'optionalAccess', _210 => _210.codegen])
5702
6004
  });
5703
6005
  return this.resolveMainResult(ir, gen, ctx.data);
5704
6006
  };
5705
6007
  const resolveStyleFile = () => {
5706
- const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _203 => _203.parser]) });
6008
+ const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _211 => _211.parser]) });
5707
6009
  return this.resolveStyleResult(result, ctx.data);
5708
6010
  };
5709
6011
  try {
@@ -5830,9 +6132,9 @@ var BaseCompiler = (_class5 = class extends Helper {
5830
6132
  lang
5831
6133
  },
5832
6134
  css: {
5833
- file: _optionalChain([styleData, 'optionalAccess', _204 => _204.filePath]),
5834
- hash: _optionalChain([styleData, 'optionalAccess', _205 => _205.scopeId]),
5835
- code: _optionalChain([ir, 'optionalAccess', _206 => _206.style])
6135
+ file: _optionalChain([styleData, 'optionalAccess', _212 => _212.filePath]),
6136
+ hash: _optionalChain([styleData, 'optionalAccess', _213 => _213.scopeId]),
6137
+ code: _optionalChain([ir, 'optionalAccess', _214 => _214.style])
5836
6138
  }
5837
6139
  },
5838
6140
  ...base
@@ -5906,7 +6208,7 @@ var AssetManager = (_class6 = class {
5906
6208
  const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
5907
6209
  const filename = _path2.default.basename(p).toLowerCase();
5908
6210
  const ext = _path2.default.extname(p).toLowerCase();
5909
- if (!_optionalChain([this, 'access', _207 => _207.fileCompiler, 'access', _208 => _208.options, 'access', _209 => _209.output, 'optionalAccess', _210 => _210.ignoreAssets])) {
6211
+ if (!_optionalChain([this, 'access', _215 => _215.fileCompiler, 'access', _216 => _216.options, 'access', _217 => _217.output, 'optionalAccess', _218 => _218.ignoreAssets])) {
5910
6212
  const shouldExclude = Array.from(exclusions).some((pattern) => {
5911
6213
  if (pattern.endsWith(".")) {
5912
6214
  return filename.startsWith(pattern);
@@ -6043,10 +6345,10 @@ var CleanupManager = class {
6043
6345
  const removeFn = async (m) => {
6044
6346
  if (key === "sfc" /* SFC */) {
6045
6347
  const meta = m;
6046
- if (!_optionalChain([meta, 'optionalAccess', _211 => _211.output])) return;
6348
+ if (!_optionalChain([meta, 'optionalAccess', _219 => _219.output])) return;
6047
6349
  const { jsx, css } = meta.output;
6048
6350
  await this.fileCompiler.removeOutputFile(jsx.file);
6049
- if (_optionalChain([css, 'optionalAccess', _212 => _212.file])) {
6351
+ if (_optionalChain([css, 'optionalAccess', _220 => _220.file])) {
6050
6352
  await this.fileCompiler.removeOutputFile(css.file);
6051
6353
  }
6052
6354
  } else if (key === "script" /* SCRIPT */ || key === "copied" /* ASSET */) {
@@ -6090,7 +6392,7 @@ var CompilationUnitProcessor = class {
6090
6392
  const isScriptFile = key === "script" /* SCRIPT */;
6091
6393
  const isStyleFile = key === "style" /* STYLE */;
6092
6394
  if (isSFC || isScriptFile) {
6093
- unit.hasRoute = _optionalChain([result, 'optionalAccess', _213 => _213.hasRoute]);
6395
+ unit.hasRoute = _optionalChain([result, 'optionalAccess', _221 => _221.hasRoute]);
6094
6396
  }
6095
6397
  const resolveFileInfo = () => {
6096
6398
  if (isSFC) {
@@ -6110,7 +6412,7 @@ var CompilationUnitProcessor = class {
6110
6412
  const { script } = result.fileInfo;
6111
6413
  unit.output = {
6112
6414
  script: {
6113
- file: _optionalChain([script, 'optionalAccess', _214 => _214.file]),
6415
+ file: _optionalChain([script, 'optionalAccess', _222 => _222.file]),
6114
6416
  code
6115
6417
  }
6116
6418
  };
@@ -6190,7 +6492,7 @@ var FileProcessor = (_class7 = class {
6190
6492
  const absPath = this.fileCompiler.getAbsPath(filePath);
6191
6493
  const fileMeta = await this.fileCompiler.getFileMeta(absPath);
6192
6494
  const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
6193
- const record = _optionalChain([cache, 'optionalAccess', _215 => _215.target, 'access', _216 => _216.find, 'call', _217 => _217((c) => c.file === absPath)]);
6495
+ const record = _optionalChain([cache, 'optionalAccess', _223 => _223.target, 'access', _224 => _224.find, 'call', _225 => _225((c) => c.file === absPath)]);
6194
6496
  const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
6195
6497
  fileMeta,
6196
6498
  record,
@@ -6209,10 +6511,10 @@ var FileProcessor = (_class7 = class {
6209
6511
  hash: hash || this.fileCompiler.genHash(source)
6210
6512
  };
6211
6513
  const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
6212
- if (_optionalChain([processed, 'optionalAccess', _218 => _218.output])) {
6514
+ if (_optionalChain([processed, 'optionalAccess', _226 => _226.output])) {
6213
6515
  await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
6214
6516
  if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
6215
- if (_optionalChain([processed, 'optionalAccess', _219 => _219.hasRoute])) {
6517
+ if (_optionalChain([processed, 'optionalAccess', _227 => _227.hasRoute])) {
6216
6518
  await this.injectVuReactRouteDep();
6217
6519
  }
6218
6520
  }
@@ -6402,7 +6704,7 @@ var ViteBootstrapper = (_class9 = class {
6402
6704
  */
6403
6705
  resolveViteCreateApp() {
6404
6706
  const { output } = this.options;
6405
- const config = _optionalChain([output, 'optionalAccess', _220 => _220.bootstrapVite]);
6707
+ const config = _optionalChain([output, 'optionalAccess', _228 => _228.bootstrapVite]);
6406
6708
  const template = typeof config === "object" ? config.template : "react-ts";
6407
6709
  const outDirName = this.fileCompiler.getOutDirName();
6408
6710
  const cmd = `npm create vite@latest ${outDirName} -- --template ${template}`;
@@ -6490,7 +6792,7 @@ var FileCompiler = (_class10 = class extends BaseCompiler {
6490
6792
  this.spinner.start("Copying assets...");
6491
6793
  const assetCount = await this.assetManager.runAssetPipeline();
6492
6794
  this.spinner.stop();
6493
- await _optionalChain([this, 'access', _221 => _221.options, 'access', _222 => _222.onSuccess, 'optionalCall', _223 => _223()]);
6795
+ await _optionalChain([this, 'access', _229 => _229.options, 'access', _230 => _230.onSuccess, 'optionalCall', _231 => _231()]);
6494
6796
  const endTime = calcElapsedTime(startTime);
6495
6797
  this.printCoreLogs();
6496
6798
  this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);