@vureact/compiler-core 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vureact/compiler-core v1.4.0
2
+ * @vureact/compiler-core v1.5.0
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -35,11 +35,11 @@ var PACKAGE_NAME = {
35
35
  var RUNTIME_PACKAGES = {
36
36
  router: {
37
37
  name: PACKAGE_NAME.router,
38
- version: "^1.0.0"
38
+ version: "^2.0.1"
39
39
  },
40
40
  runtime: {
41
41
  name: PACKAGE_NAME.runtime,
42
- version: "^1.0.0"
42
+ version: "^1.0.1"
43
43
  }
44
44
  };
45
45
  var STYLE_MODULE_NAME = "$style";
@@ -1827,12 +1827,6 @@ function resolveStyles(descriptor, ctx, result) {
1827
1827
  { file: filename }
1828
1828
  );
1829
1829
  }
1830
- if (content.includes("@import")) {
1831
- logger.warn(
1832
- "Detected @import in scoped style. Imported styles remain global. Consider inlining them to preserve scoping.",
1833
- { file: filename }
1834
- );
1835
- }
1836
1830
  const { code, fileExt } = resolveLessSass(content, {
1837
1831
  lang,
1838
1832
  filename,
@@ -1959,7 +1953,7 @@ function insertCSSImport(ctx) {
1959
1953
  scriptIR.imports.push(importDecl);
1960
1954
  }
1961
1955
 
1962
- // src/core/transform/sfc/script/syntax-processor/postprocess/insert-required-imports.ts
1956
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/index.ts
1963
1957
  import * as t18 from "@babel/types";
1964
1958
 
1965
1959
  // src/core/transform/shared.ts
@@ -1991,51 +1985,147 @@ function replaceVueSuffix(ctx, node) {
1991
1985
  node.extra = { rawValue: jsxFile, raw: jsxFile };
1992
1986
  }
1993
1987
 
1994
- // src/core/transform/sfc/script/syntax-processor/postprocess/insert-required-imports.ts
1995
- function insertRequiredImports(ctx) {
1988
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/import-strategies.ts
1989
+ var VueRouterStrategy = class {
1990
+ matches(moduleName) {
1991
+ return moduleName === "vue-router" || moduleName.startsWith("vue-router/");
1992
+ }
1993
+ process() {
1994
+ return {
1995
+ shouldReplaceSource: true,
1996
+ newSource: PACKAGE_NAME.router,
1997
+ shouldRemove: false,
1998
+ shouldInjectRuntimeImports: false
1999
+ };
2000
+ }
2001
+ };
2002
+ var VueEcosystemStrategy = class {
2003
+ matches(moduleName) {
2004
+ if (moduleName.startsWith(".") || moduleName.startsWith("/") || moduleName.startsWith("file:")) {
2005
+ return false;
2006
+ }
2007
+ if (moduleName === "vue-router" || moduleName.startsWith("vue-router/")) {
2008
+ return false;
2009
+ }
2010
+ if (moduleName.startsWith("@vue/")) {
2011
+ return true;
2012
+ }
2013
+ for (const pkg of VUE_PACKAGES) {
2014
+ if (moduleName === pkg || moduleName.startsWith(`${pkg}/`)) {
2015
+ return true;
2016
+ }
2017
+ }
2018
+ return false;
2019
+ }
2020
+ process() {
2021
+ return {
2022
+ shouldReplaceSource: false,
2023
+ shouldRemove: true,
2024
+ shouldInjectRuntimeImports: true
2025
+ };
2026
+ }
2027
+ };
2028
+ var StyleFileStrategy = class {
2029
+ regExp = /\.(less|sass|scss)$/i;
2030
+ matches(moduleName) {
2031
+ return this.regExp.test(moduleName);
2032
+ }
2033
+ process(path9, ctx) {
2034
+ if (!ctx.preprocessStyles) {
2035
+ return {};
2036
+ }
2037
+ const importSource = path9.node.source.value;
2038
+ if (typeof importSource !== "string") {
2039
+ return {};
2040
+ }
2041
+ return {
2042
+ shouldReplaceSource: true,
2043
+ newSource: importSource.replace(this.regExp, ".css"),
2044
+ shouldRemove: false,
2045
+ shouldInjectRuntimeImports: false
2046
+ };
2047
+ }
2048
+ };
2049
+
2050
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/import-strategy-manager.ts
2051
+ var ImportStrategyManager = class {
2052
+ strategies = [];
2053
+ constructor() {
2054
+ this.strategies.push(new VueRouterStrategy());
2055
+ this.strategies.push(new VueEcosystemStrategy());
2056
+ this.strategies.push(new StyleFileStrategy());
2057
+ }
2058
+ /** 添加自定义策略 */
2059
+ addStrategy(strategy) {
2060
+ this.strategies.push(strategy);
2061
+ }
2062
+ /** 查找匹配的策略 */
2063
+ findStrategy(moduleName) {
2064
+ for (const strategy of this.strategies) {
2065
+ if (strategy.matches(moduleName)) {
2066
+ return strategy;
2067
+ }
2068
+ }
2069
+ return null;
2070
+ }
2071
+ };
2072
+
2073
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-required-imports/index.ts
2074
+ function resolveRequiredImports(ctx) {
1996
2075
  const processedModules = /* @__PURE__ */ new Set();
1997
2076
  let hasProcessedImports = false;
1998
- recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
2077
+ const strategyManager = new ImportStrategyManager();
2078
+ if (ctx.inputType === "sfc") {
2079
+ recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
2080
+ }
1999
2081
  function resolveRequiredImport(path9) {
2000
2082
  const { node } = path9;
2001
- const moduleName = node.source.value.toLowerCase();
2002
- const isVueLike = isVueEcosystemPackage(moduleName);
2003
- mergeImports(node, ctx);
2004
- if (processedModules.has(moduleName) && !path9.removed) {
2083
+ const originalModuleName = node.source.value.toLowerCase();
2084
+ const strategy = strategyManager.findStrategy(originalModuleName);
2085
+ if (strategy) {
2086
+ const result = strategy.process(path9, ctx, originalModuleName);
2087
+ if (result.shouldReplaceSource && result.newSource) {
2088
+ node.source.value = result.newSource;
2089
+ }
2090
+ }
2091
+ const normalizedModuleName = node.source.value.toLowerCase();
2092
+ mergeImports(node, ctx, normalizedModuleName);
2093
+ if (processedModules.has(normalizedModuleName) && !path9.removed) {
2005
2094
  path9.remove();
2006
2095
  return;
2007
2096
  }
2008
- processedModules.add(moduleName);
2097
+ processedModules.add(normalizedModuleName);
2009
2098
  if (!hasProcessedImports) {
2010
2099
  const required = createRequiredImports(ctx);
2011
- if (isVueLike) {
2012
- path9.replaceWithMultiple(required);
2013
- } else if (moduleName === PACKAGE_NAME.react) {
2014
- path9.insertAfter(required);
2100
+ if (strategy) {
2101
+ const result = strategy.process(path9, ctx, originalModuleName);
2102
+ if (result.shouldRemove) {
2103
+ path9.replaceWithMultiple(required);
2104
+ } else if (normalizedModuleName === PACKAGE_NAME.react) {
2105
+ path9.insertAfter(required);
2106
+ } else {
2107
+ path9.insertBefore(required);
2108
+ }
2015
2109
  } else {
2016
- path9.insertBefore(required);
2110
+ if (normalizedModuleName === PACKAGE_NAME.react) {
2111
+ path9.insertAfter(required);
2112
+ } else {
2113
+ path9.insertBefore(required);
2114
+ }
2017
2115
  }
2018
2116
  hasProcessedImports = true;
2019
2117
  }
2020
- if (isVueLike && !path9.removed) {
2021
- path9.remove();
2022
- return;
2118
+ if (strategy) {
2119
+ const result = strategy.process(path9, ctx, originalModuleName);
2120
+ if (result.shouldRemove && !path9.removed) {
2121
+ path9.remove();
2122
+ return;
2123
+ }
2023
2124
  }
2024
2125
  replaceVueSuffix(ctx, node.source);
2025
2126
  }
2026
- function resolveStyleFileExt(path9) {
2027
- if (!ctx.preprocessStyles) return;
2028
- const { node } = path9;
2029
- if (!node || !node.source || !node.source.value) return;
2030
- const importSource = node.source.value;
2031
- if (typeof importSource !== "string") return;
2032
- const styleExtRegex = /\.(less|sass|scss)$/i;
2033
- if (!styleExtRegex.test(importSource)) return;
2034
- const newSource = importSource.replace(styleExtRegex, ".css");
2035
- node.source.value = newSource;
2036
- }
2037
2127
  return {
2038
- // 增加 Program.exit 兜底注入 required imports(处理无 ImportDeclaration 的 SFC)
2128
+ // 兜底:无 ImportDeclaration 的文件也要能注入必需依赖。
2039
2129
  Program: {
2040
2130
  exit(path9) {
2041
2131
  if (hasProcessedImports) return;
@@ -2046,24 +2136,10 @@ function insertRequiredImports(ctx) {
2046
2136
  },
2047
2137
  ImportDeclaration(path9) {
2048
2138
  resolveRequiredImport(path9);
2049
- resolveStyleFileExt(path9);
2050
2139
  }
2051
2140
  };
2052
2141
  }
2053
- function isVueEcosystemPackage(moduleName) {
2054
- if (moduleName.startsWith(".") || moduleName.startsWith("/") || moduleName.startsWith("file:")) {
2055
- return false;
2056
- }
2057
- if (moduleName.startsWith("@vue/")) {
2058
- return true;
2059
- }
2060
- if (moduleName === "vue-router" || moduleName.startsWith("vue-router/")) {
2061
- return true;
2062
- }
2063
- return VUE_PACKAGES.some((name) => moduleName === name || moduleName.startsWith(`${name}/`));
2064
- }
2065
- function mergeImports(currentNode, ctx) {
2066
- const moduleName = currentNode.source.value.toLowerCase();
2142
+ function mergeImports(currentNode, ctx, moduleName) {
2067
2143
  const ctxImportItems = ctx.imports.get(moduleName);
2068
2144
  if (!ctxImportItems?.length) {
2069
2145
  return;
@@ -2078,7 +2154,9 @@ function mergeImports(currentNode, ctx) {
2078
2154
  }
2079
2155
  }
2080
2156
  for (const item of ctxImportItems) {
2081
- if (currentImports.has(item.name)) return;
2157
+ if (currentImports.has(item.name)) {
2158
+ continue;
2159
+ }
2082
2160
  const local = t18.identifier(item.name);
2083
2161
  const newNode = !item.onDemand ? t18.importDefaultSpecifier(local) : t18.importSpecifier(local, local);
2084
2162
  currentNode.specifiers.push(newNode);
@@ -3171,6 +3249,9 @@ var SLOT_DEFAULT_NAME = "default";
3171
3249
  var SLOT_CHILDREN_NAME = "children";
3172
3250
  var SLOT_FN_PARAM_NAME = "props";
3173
3251
  function resolveSlotsTopLevelTypes(ctx) {
3252
+ if (ctx.inputType !== "sfc") {
3253
+ return {};
3254
+ }
3174
3255
  return {
3175
3256
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path9) {
3176
3257
  if (!t29.isProgram(path9.parent)) return;
@@ -3736,6 +3817,9 @@ function resolveAnalysisOnlyAdapter(ctx) {
3736
3817
  if (!adapter || adapter.type !== "analyzed-deps") {
3737
3818
  return;
3738
3819
  }
3820
+ if (!isVueApiReference(path9, apiName)) {
3821
+ return;
3822
+ }
3739
3823
  if (t32.isCallExpression(node)) {
3740
3824
  resolveCallNode(path9, adapter, ctx);
3741
3825
  } else {
@@ -3769,6 +3853,41 @@ function resolveCallNode(path9, adapter, ctx) {
3769
3853
  replaceCallName(node, adapter.target);
3770
3854
  recordImport(ctx, adapter.package, adapter.target);
3771
3855
  }
3856
+ function isVueApiReference(path9, apiName) {
3857
+ if (path9.isIdentifier()) {
3858
+ if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
3859
+ return false;
3860
+ }
3861
+ if (!path9.isReferencedIdentifier()) {
3862
+ return false;
3863
+ }
3864
+ }
3865
+ if (path9.isCallExpression()) {
3866
+ const callee = path9.get("callee");
3867
+ if (!callee.isIdentifier()) return false;
3868
+ return isVueImportBinding(callee.scope.getBinding(apiName));
3869
+ }
3870
+ return isVueImportBinding(path9.scope.getBinding(apiName));
3871
+ }
3872
+ function isVueImportBinding(binding) {
3873
+ if (!binding) return false;
3874
+ const bindingPath = binding.path;
3875
+ if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
3876
+ return false;
3877
+ }
3878
+ const parent = bindingPath.parentPath?.node;
3879
+ if (!parent || !t32.isImportDeclaration(parent)) {
3880
+ return false;
3881
+ }
3882
+ const source = parent.source.value.toLowerCase();
3883
+ if (source.startsWith("@vue/")) {
3884
+ return true;
3885
+ }
3886
+ if (source === "vue-router" || source.startsWith("vue-router/")) {
3887
+ return true;
3888
+ }
3889
+ return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
3890
+ }
3772
3891
 
3773
3892
  // src/core/transform/sfc/script/syntax-processor/process/resolve-arrow-deps.ts
3774
3893
  function resolveArrowFnDeps(ctx, ast) {
@@ -4049,12 +4168,18 @@ function resolveRenameAdapter(ctx) {
4049
4168
  } else if (isCallNode && t37.isIdentifier(node.callee)) {
4050
4169
  apiName = node.callee.name;
4051
4170
  }
4171
+ if (!apiName) {
4172
+ return;
4173
+ }
4052
4174
  const runtimeAdapter = ADAPTER_RULES.runtime[apiName];
4053
4175
  const routerAdapter = ADAPTER_RULES.router[apiName];
4054
4176
  const adapter = runtimeAdapter || routerAdapter;
4055
4177
  if (!adapter || adapter.type !== "rename") {
4056
4178
  return;
4057
4179
  }
4180
+ if (!isVueApiReference2(path9, apiName)) {
4181
+ return;
4182
+ }
4058
4183
  if (adapter.isTrackable) {
4059
4184
  const reactiveType = getReactiveType(apiName);
4060
4185
  const declaratorPath = getVariableDeclaratorPath(path9);
@@ -4075,6 +4200,41 @@ function resolveRenameAdapter(ctx) {
4075
4200
  }
4076
4201
  };
4077
4202
  }
4203
+ function isVueApiReference2(path9, apiName) {
4204
+ if (path9.isIdentifier()) {
4205
+ if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
4206
+ return false;
4207
+ }
4208
+ if (!path9.isReferencedIdentifier()) {
4209
+ return false;
4210
+ }
4211
+ }
4212
+ if (path9.isCallExpression()) {
4213
+ const callee = path9.get("callee");
4214
+ if (!callee.isIdentifier()) return false;
4215
+ return isVueImportBinding2(callee.scope.getBinding(apiName));
4216
+ }
4217
+ return isVueImportBinding2(path9.scope.getBinding(apiName));
4218
+ }
4219
+ function isVueImportBinding2(binding) {
4220
+ if (!binding) return false;
4221
+ const bindingPath = binding.path;
4222
+ if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
4223
+ return false;
4224
+ }
4225
+ const parent = bindingPath.parentPath?.node;
4226
+ if (!parent || !t37.isImportDeclaration(parent)) {
4227
+ return false;
4228
+ }
4229
+ const source = parent.source.value.toLowerCase();
4230
+ if (source.startsWith("@vue/")) {
4231
+ return true;
4232
+ }
4233
+ if (source === "vue-router" || source.startsWith("vue-router/")) {
4234
+ return true;
4235
+ }
4236
+ return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
4237
+ }
4078
4238
 
4079
4239
  // src/core/transform/sfc/script/syntax-processor/index.ts
4080
4240
  function processVueSyntax2(ast, ctx) {
@@ -4106,7 +4266,7 @@ function processVueSyntax2(ast, ctx) {
4106
4266
  excludeBabel: [resolveTemplateSlotIface, resolveCompIProps]
4107
4267
  },
4108
4268
  postprocess: {
4109
- applyBabel: [insertRequiredImports, resolveStaticHoisting],
4269
+ applyBabel: [resolveRequiredImports, resolveStaticHoisting],
4110
4270
  excludeBabel: [insertCSSImport, collectLocalStatements]
4111
4271
  }
4112
4272
  });
@@ -4247,7 +4407,7 @@ function isIdentifier20(code) {
4247
4407
  function isStringLiteral12(code) {
4248
4408
  try {
4249
4409
  const node = parseExpression3(code);
4250
- return t38.isStringLiteral(node) || t38.isTemplateLiteral(node);
4410
+ return t38.isStringLiteral(node);
4251
4411
  } catch {
4252
4412
  return false;
4253
4413
  }
@@ -4320,7 +4480,10 @@ function normalizePropName(rawName, name) {
4320
4480
  case "for":
4321
4481
  return "htmlFor";
4322
4482
  default:
4323
- return whitelist.test(name) ? name : camelCase(name);
4483
+ if (!isVBind(rawName) && whitelist.test(name)) {
4484
+ return name;
4485
+ }
4486
+ return camelCase(name);
4324
4487
  }
4325
4488
  }
4326
4489
  function isVOn(name) {
@@ -4336,7 +4499,7 @@ function isVModel(name) {
4336
4499
  return /^v-model/.test(name ?? "");
4337
4500
  }
4338
4501
  function isClassAttr(name) {
4339
- return /^(class|:class|v-bind:class|className)$/.test(name ?? "");
4502
+ return /^(class|:class|v-bind:class|className|class-name)$/.test(name ?? "");
4340
4503
  }
4341
4504
  function isStyleAttr(name) {
4342
4505
  return /^(style|:style|v-bind:style)$/.test(name ?? "");
@@ -4530,7 +4693,6 @@ function resolveDefaultStyleModuleName(node) {
4530
4693
 
4531
4694
  // src/core/transform/sfc/template/syntax-processor/preprocess/resolve-style-scope-attribute.ts
4532
4695
  import {
4533
- ElementTypes,
4534
4696
  isSlotOutlet,
4535
4697
  isTemplateNode,
4536
4698
  NodeTypes as NodeTypes3
@@ -4554,21 +4716,30 @@ function walkElementNodes2(node, onElement) {
4554
4716
  }
4555
4717
  function injectStyleScopeAttribute(node, ctx) {
4556
4718
  const { scopeId } = ctx.styleData;
4557
- if (!scopeId || isComponentElement(node) || isSlotOutlet(node) || isTemplateNode(node)) {
4719
+ if (!scopeId || isSlotOutlet(node) || isTemplateNode(node)) {
4558
4720
  return;
4559
4721
  }
4560
- const hasDynamicIs = node.props.some((prop) => {
4561
- if (prop.type !== NodeTypes3.DIRECTIVE || prop.arg?.type !== NodeTypes3.SIMPLE_EXPRESSION) {
4562
- return false;
4722
+ let hasScopeId = false;
4723
+ let hasClassOrId = false;
4724
+ for (const prop of node.props) {
4725
+ if (prop.type === NodeTypes3.ATTRIBUTE) {
4726
+ if (prop.name === scopeId) {
4727
+ hasScopeId = true;
4728
+ break;
4729
+ }
4730
+ if (getHasClassOrId(prop.name)) {
4731
+ hasClassOrId = true;
4732
+ break;
4733
+ }
4734
+ }
4735
+ if (prop.type === NodeTypes3.DIRECTIVE && prop.arg?.type === NodeTypes3.SIMPLE_EXPRESSION) {
4736
+ if (getHasClassOrId(prop.arg.content)) {
4737
+ hasClassOrId = true;
4738
+ break;
4739
+ }
4563
4740
  }
4564
- return prop.arg.content === "is";
4565
- });
4566
- const hasScopeId = node.props.some(
4567
- (prop) => prop.type === NodeTypes3.ATTRIBUTE && prop.name === scopeId
4568
- );
4569
- if (hasDynamicIs || hasScopeId) {
4570
- return;
4571
4741
  }
4742
+ if (hasScopeId || !hasClassOrId) return;
4572
4743
  const attr = {
4573
4744
  type: NodeTypes3.ATTRIBUTE,
4574
4745
  name: scopeId,
@@ -4578,11 +4749,8 @@ function injectStyleScopeAttribute(node, ctx) {
4578
4749
  };
4579
4750
  node.props.push(attr);
4580
4751
  }
4581
- function isComponentElement(node) {
4582
- if (node.tagType !== ElementTypes.COMPONENT) {
4583
- return camelCase(node.tag) !== node.tag;
4584
- }
4585
- return node.tagType === ElementTypes.COMPONENT;
4752
+ function getHasClassOrId(ns) {
4753
+ return isClassAttr(ns) || ns === "id";
4586
4754
  }
4587
4755
 
4588
4756
  // src/core/transform/sfc/template/shared/prop-merge-utils.ts
@@ -4773,7 +4941,12 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
4773
4941
  content = node.value.content = parseStyleString(content);
4774
4942
  }
4775
4943
  if (isDynamic) {
4776
- node.value.isStringLiteral = strCodeTypes.isStringLiteral(content);
4944
+ const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
4945
+ if (isStringLiteral13) {
4946
+ content = normalizeString(content);
4947
+ node.value.content = content;
4948
+ }
4949
+ node.value.isStringLiteral = isStringLiteral13;
4777
4950
  }
4778
4951
  const existing = findSameProp(nodeIR.props, node);
4779
4952
  if (existing) {
@@ -4783,6 +4956,12 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
4783
4956
  }
4784
4957
  resolvePropAsBabelExp(existing ?? node, ctx);
4785
4958
  }
4959
+ function normalizeString(s) {
4960
+ if (s.startsWith("'") && s.endsWith("'")) {
4961
+ return s.slice(1, -1);
4962
+ }
4963
+ return s;
4964
+ }
4786
4965
 
4787
4966
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
4788
4967
  function resolveAttributeProp(node, ir, ctx, nodeIR) {
@@ -4922,7 +5101,7 @@ function resolveVMemo(node, _ir, ctx, nodeIR) {
4922
5101
 
4923
5102
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-model.ts
4924
5103
  import {
4925
- ElementTypes as ElementTypes2,
5104
+ ElementTypes,
4926
5105
  NodeTypes as NodeTypes6
4927
5106
  } from "@vue/compiler-core";
4928
5107
  function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
@@ -4930,7 +5109,7 @@ function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
4930
5109
  const exp = node.exp;
4931
5110
  const modifiers = node.modifiers.map((item) => item.content);
4932
5111
  const getterName = exp.content;
4933
- const isComponent = elementNode.tagType === ElementTypes2.COMPONENT;
5112
+ const isComponent = elementNode.tagType === ElementTypes.COMPONENT;
4934
5113
  const inputType = resolveHtmlInput(elementNode, isComponent);
4935
5114
  const propName = arg?.content ?? resolveModelPropName(inputType, isComponent);
4936
5115
  let valuePropIR;
@@ -5007,7 +5186,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
5007
5186
  const exp = node.exp;
5008
5187
  const modifiers = node.modifiers.map((item) => item.content);
5009
5188
  const captureIndex = modifiers.findIndex((modifier) => modifier === "capture");
5010
- let eventName = `on${camelCase(capitalize(arg.content))}`;
5189
+ let eventName = normalizeVOnEventName(arg.content);
5011
5190
  let handler = resolveSpecialExpressions(exp.content.trim(), ctx);
5012
5191
  if (captureIndex > -1) {
5013
5192
  eventName = modifiers[captureIndex] ? `${eventName}Capture` : eventName;
@@ -5018,7 +5197,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
5018
5197
  originalVueEventName = `${arg.content}.${modifiers.join(".")}`;
5019
5198
  } else {
5020
5199
  const expr = stringToExpr(handler);
5021
- if (!t40.isFunctionExpression(expr) && !t40.isIdentifier(expr)) {
5200
+ if (!t40.isFunctionExpression(expr) && !t40.isArrowFunctionExpression(expr) && !t40.isIdentifier(expr)) {
5022
5201
  handler = `() => {${handler}}`;
5023
5202
  }
5024
5203
  }
@@ -5036,6 +5215,11 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
5036
5215
  }
5037
5216
  nodeIR.props.push(eventIR);
5038
5217
  }
5218
+ function normalizeVOnEventName(rawEventName) {
5219
+ const segments = rawEventName.split(/[:-]/g).map((segment) => segment.trim()).filter(Boolean);
5220
+ const normalized = segments.map((segment) => capitalize(camelCase(segment))).join("");
5221
+ return `on${normalized}`;
5222
+ }
5039
5223
 
5040
5224
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
5041
5225
  function resolveVShow(node, _ir, ctx, nodeIR) {
@@ -5209,7 +5393,7 @@ function resolveCommentNode(node, _ir, ctx, childrenIR) {
5209
5393
  }
5210
5394
 
5211
5395
  // src/core/transform/sfc/template/syntax-processor/process/resolve-element-node.ts
5212
- import { ElementTypes as ElementTypes3 } from "@vue/compiler-core";
5396
+ import { ElementTypes as ElementTypes2 } from "@vue/compiler-core";
5213
5397
  function resolveElementNode(node, ir, ctx, siblingNodesIR) {
5214
5398
  const isComponent = getIsComponent(node);
5215
5399
  const tag = isComponent ? capitalize(camelCase(node.tag)) : node.tag;
@@ -5244,10 +5428,10 @@ function createElementNodeIR(options) {
5244
5428
  };
5245
5429
  }
5246
5430
  function getIsComponent(node) {
5247
- if (node.tagType !== ElementTypes3.COMPONENT) {
5431
+ if (node.tagType !== ElementTypes2.COMPONENT) {
5248
5432
  return camelCase(node.tag) !== node.tag;
5249
5433
  }
5250
- return node.tagType === ElementTypes3.COMPONENT;
5434
+ return node.tagType === ElementTypes2.COMPONENT;
5251
5435
  }
5252
5436
 
5253
5437
  // src/core/transform/sfc/template/syntax-processor/process/resolve-interpolation-node.ts
@@ -5466,7 +5650,7 @@ function transform(ast, ctx, options) {
5466
5650
  }
5467
5651
 
5468
5652
  // package.json
5469
- var version = "1.4.0";
5653
+ var version = "1.5.0";
5470
5654
  var bin = {
5471
5655
  vureact: "./bin/vureact.js"
5472
5656
  };
@@ -6874,31 +7058,31 @@ var ViteBootstrapper = class {
6874
7058
  * 利用 Vite 官方脚手架创建标准 React 环境
6875
7059
  */
6876
7060
  async bootstrapIfNeeded() {
6877
- const { bootstrapVite } = this.options.output || {};
7061
+ const { output } = this.options;
6878
7062
  const workspaceDir = this.fileCompiler.getWorkspaceDir();
6879
7063
  await fs5.promises.mkdir(workspaceDir, { recursive: true });
6880
- if (bootstrapVite === false) {
7064
+ if (output?.bootstrapVite === false) {
6881
7065
  return false;
6882
7066
  }
6883
7067
  if (this.isSingleFile()) {
6884
7068
  console.info("Skipping Vite initialization for single file compilation");
6885
- return false;
7069
+ return;
6886
7070
  }
6887
7071
  const outputPkgPath = this.fileCompiler.getOutputPkgPath();
6888
7072
  if (fs5.existsSync(outputPkgPath)) {
6889
- return false;
7073
+ return;
6890
7074
  }
6891
- this.spinner.start("Bootstrapping Vite React environment...");
6892
7075
  try {
7076
+ this.spinner.start("Bootstrapping Vite React environment...");
6893
7077
  await this.resolveViteCreateApp();
6894
7078
  } catch (err) {
6895
- this.spinner.stop();
6896
7079
  console.error(
6897
7080
  kleur7.red("\u2716"),
6898
- "Failed to bootstrap Vite environment. Please check npm/network.",
7081
+ "Failed to bootstrap Vite environment. Please check npm/network.\n",
6899
7082
  err
6900
7083
  );
6901
- return false;
7084
+ this.spinner.stop();
7085
+ return;
6902
7086
  }
6903
7087
  const removeVuePackages = (deps) => {
6904
7088
  for (const name in deps) {
@@ -6920,15 +7104,15 @@ var ViteBootstrapper = class {
6920
7104
  }
6921
7105
  return deps;
6922
7106
  };
6923
- const rootPkgPath = this.fileCompiler.getRootPkgPath();
6924
- const rootPkg = await this.fileCompiler.resolvePackageFile(rootPkgPath);
6925
- const vitePkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
6926
- const newDeps = resolveDeps(rootPkg.dependencies, vitePkg.dependencies);
6927
- const newDevDeps = resolveDeps(rootPkg.devDependencies, vitePkg.devDependencies, true);
6928
- vitePkg.dependencies = newDeps;
6929
- vitePkg.devDependencies = newDevDeps;
6930
- const newVitePkg = JSON.stringify(vitePkg, null, 2);
6931
- await this.fileCompiler.writeFileWithDir(outputPkgPath, newVitePkg);
7107
+ const sourcePkgPath = this.fileCompiler.getRootPkgPath();
7108
+ const sourcePkg = await this.fileCompiler.resolvePackageFile(sourcePkgPath);
7109
+ let newPkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
7110
+ const newDeps = resolveDeps(sourcePkg.dependencies, newPkg.dependencies);
7111
+ const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
7112
+ newPkg.dependencies = newDeps;
7113
+ newPkg.devDependencies = newDevDeps;
7114
+ newPkg = output?.packageJson?.(newPkg) || newPkg;
7115
+ await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
6932
7116
  this.spinner.succeed("Standard Vite React environment initialized");
6933
7117
  return true;
6934
7118
  }
@@ -6960,15 +7144,15 @@ var ViteBootstrapper = class {
6960
7144
  */
6961
7145
  async resolveReactVersion(ver) {
6962
7146
  const outputPkgPath = this.fileCompiler.getOutputPkgPath();
6963
- const vitePkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
6964
- const typesVer = `^${ver.split(".")[0].replace(/@|\^/, "")}.0.0`;
6965
- vitePkg.dependencies.react = ver;
6966
- vitePkg.dependencies["react-dom"] = ver;
6967
- vitePkg.devDependencies["@types/react"] = typesVer;
6968
- vitePkg.devDependencies["@types/react-dom"] = typesVer;
6969
- await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(vitePkg, null, 2), {
6970
- lock: true
6971
- });
7147
+ const curPkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
7148
+ const mainVer = Number(ver.split(".")[0]);
7149
+ const typeVer = !isNaN(mainVer) ? `^${mainVer.toString().replace(/@|\^|~|>=|>|/, "")}.0.0` : "^19.0.0";
7150
+ curPkg.dependencies.react = ver;
7151
+ curPkg.dependencies["react-dom"] = ver;
7152
+ curPkg.devDependencies["@types/react"] = typeVer;
7153
+ curPkg.devDependencies["@types/react-dom"] = typeVer;
7154
+ await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(curPkg, null, 2));
7155
+ return curPkg;
6972
7156
  }
6973
7157
  };
6974
7158
 
@@ -7056,7 +7240,9 @@ var FileCompiler = class extends BaseCompiler {
7056
7240
  await rmWorkspace();
7057
7241
  console.error(kleur8.red("\u2716"), `Build failed in ${endTime}`);
7058
7242
  console.error(error);
7243
+ process.exit(-1);
7059
7244
  } finally {
7245
+ this.spinner.stop();
7060
7246
  this.resetSkippedCount();
7061
7247
  }
7062
7248
  }