@vureact/compiler-core 1.4.0 → 1.5.1

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
- "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; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11;/**
2
- * @vureact/compiler-core v1.4.0
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; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;/**
2
+ * @vureact/compiler-core v1.5.1
3
3
  * (c) 2025-present Ruihong Zhong (Ryan John)
4
4
  * @license MIT
5
5
  */
@@ -24,7 +24,7 @@ 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 t11 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t10 = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t4 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t6 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types); var t7 = _interopRequireWildcard(_types); var t9 = _interopRequireWildcard(_types); var t8 = _interopRequireWildcard(_types); var t14 = _interopRequireWildcard(_types); var t12 = _interopRequireWildcard(_types); var t13 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t16 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t40 = _interopRequireWildcard(_types);
27
+ var _types = require('@babel/types'); var t11 = _interopRequireWildcard(_types); var t = _interopRequireWildcard(_types); var t10 = _interopRequireWildcard(_types); var t2 = _interopRequireWildcard(_types); var t4 = _interopRequireWildcard(_types); var t3 = _interopRequireWildcard(_types); var t6 = _interopRequireWildcard(_types); var t5 = _interopRequireWildcard(_types); var t7 = _interopRequireWildcard(_types); var t9 = _interopRequireWildcard(_types); var t8 = _interopRequireWildcard(_types); var t14 = _interopRequireWildcard(_types); var t12 = _interopRequireWildcard(_types); var t13 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t16 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t40 = _interopRequireWildcard(_types);
28
28
 
29
29
  // src/consts/other.ts
30
30
  var PACKAGE_NAME = {
@@ -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";
@@ -1385,7 +1385,12 @@ function generateComponent(ir, ctx, options) {
1385
1385
  quotes: "single"
1386
1386
  // 使用单引号
1387
1387
  },
1388
- minified: true,
1388
+ minified: false,
1389
+ // 不压缩输出内容
1390
+ retainLines: false,
1391
+ // 不保留行号
1392
+ retainFunctionParens: true,
1393
+ // 保留函数括号
1389
1394
  ...options
1390
1395
  });
1391
1396
  const result = {
@@ -1461,6 +1466,7 @@ function resolveScript(descriptor, ctx, pResult) {
1461
1466
  source: scriptBlock
1462
1467
  };
1463
1468
  const options = getBabelParseOptions(scriptBlock.lang, "script", ctx.filename);
1469
+ resolveCtxData(scriptBlock, ctx);
1464
1470
  if (descriptor.script) {
1465
1471
  const { code, ast, name } = extractSetupBodyToTopLevel(scriptBlock.content, options);
1466
1472
  if (ast) {
@@ -1480,12 +1486,21 @@ function resolveScript(descriptor, ctx, pResult) {
1480
1486
  logger.warn(msg, { file: ctx.filename });
1481
1487
  })]);
1482
1488
  }
1483
- const source = scriptBlock.content;
1484
- ctx.scriptData.source = source;
1485
- ctx.compName = extractCompName(source);
1486
- ctx.scriptData.lang = scriptBlock.lang || "js";
1487
1489
  pResult.script = result;
1488
1490
  }
1491
+ function resolveCtxData(scriptBlock, ctx) {
1492
+ let { content, lang } = scriptBlock;
1493
+ const resolveVRComment = (source) => {
1494
+ const regx = /\/\/\s*@vr-name:\s*(\w+)/;
1495
+ const nameMatch = source.match(regx);
1496
+ content = content.replace(regx, "");
1497
+ return _optionalChain([nameMatch, 'optionalAccess', _45 => _45[1], 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()]) || "";
1498
+ };
1499
+ ctx.compName = resolveVRComment(content);
1500
+ ctx.scriptData.source = content;
1501
+ ctx.scriptData.lang = lang || "js";
1502
+ scriptBlock.content = content;
1503
+ }
1489
1504
  function extractSetupBodyToTopLevel(content, options) {
1490
1505
  let name = "";
1491
1506
  try {
@@ -1549,10 +1564,6 @@ function extractSetupBodyToTopLevel(content, options) {
1549
1564
  return { name, code: content };
1550
1565
  }
1551
1566
  }
1552
- function extractCompName(source) {
1553
- const nameMatch = source.match(/@vr-name:\s*(\w+)/);
1554
- return _optionalChain([nameMatch, 'optionalAccess', _45 => _45[1], 'optionalAccess', _46 => _46.trim, 'call', _47 => _47()]) || "";
1555
- }
1556
1567
 
1557
1568
  // src/core/parse/sfc/process/resolve-script-meta.ts
1558
1569
  var _core = require('@babel/core');
@@ -1827,12 +1838,6 @@ function resolveStyles(descriptor, ctx, result) {
1827
1838
  { file: filename }
1828
1839
  );
1829
1840
  }
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
1841
  const { code, fileExt } = resolveLessSass(content, {
1837
1842
  lang,
1838
1843
  filename,
@@ -1942,184 +1947,11 @@ function parse(source, ctx, options) {
1942
1947
  // src/core/transform/sfc/script/syntax-processor/index.ts
1943
1948
 
1944
1949
 
1945
- // src/core/transform/sfc/script/syntax-processor/postprocess/insert-css-import.ts
1946
-
1947
- function insertCSSImport(ctx) {
1948
- const { inputType } = ctx;
1949
- if (inputType !== "sfc") return;
1950
- const { filePath, moduleName } = ctx.styleData;
1951
- if (!filePath) return;
1952
- const scriptIR = getScriptIR(ctx);
1953
- const filename = normalizePath(filePath).split("/").pop();
1954
- const importPath = `./${filename}`;
1955
- const importDecl = t17.importDeclaration(
1956
- !moduleName ? [] : [t17.importDefaultSpecifier(t17.identifier(moduleName))],
1957
- t17.stringLiteral(importPath)
1958
- );
1959
- scriptIR.imports.push(importDecl);
1960
- }
1961
-
1962
- // src/core/transform/sfc/script/syntax-processor/postprocess/insert-required-imports.ts
1963
-
1964
-
1965
- // src/core/transform/shared.ts
1966
- function recordImport(ctx, pkg, name, onDemand = true) {
1967
- const { imports } = ctx;
1968
- if (isTypeOnlyImport(name)) {
1969
- name = `type ${name}`;
1970
- }
1971
- if (imports.has(pkg)) {
1972
- const list = imports.get(pkg);
1973
- const foundItem = list.find((item) => item.name === name);
1974
- if (!foundItem) {
1975
- list.push({ name, onDemand });
1976
- }
1977
- return;
1978
- }
1979
- imports.set(pkg, [{ name, onDemand }]);
1980
- }
1981
- function isTypeOnlyImport(name) {
1982
- const arr = [REACT_API_MAP.ReactNode];
1983
- return arr.includes(name);
1984
- }
1985
-
1986
- // src/core/transform/sfc/script/shared/replace-vue-suffix.ts
1987
- function replaceVueSuffix(ctx, node) {
1988
- if (!node.value.endsWith(".vue")) return;
1989
- const jsxFile = node.value.replace(/.vue$/, "");
1990
- node.value = jsxFile;
1991
- node.extra = { rawValue: jsxFile, raw: jsxFile };
1992
- }
1993
-
1994
- // src/core/transform/sfc/script/syntax-processor/postprocess/insert-required-imports.ts
1995
- function insertRequiredImports(ctx) {
1996
- const processedModules = /* @__PURE__ */ new Set();
1997
- let hasProcessedImports = false;
1998
- recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
1999
- function resolveRequiredImport(path9) {
2000
- 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) {
2005
- path9.remove();
2006
- return;
2007
- }
2008
- processedModules.add(moduleName);
2009
- if (!hasProcessedImports) {
2010
- const required = createRequiredImports(ctx);
2011
- if (isVueLike) {
2012
- path9.replaceWithMultiple(required);
2013
- } else if (moduleName === PACKAGE_NAME.react) {
2014
- path9.insertAfter(required);
2015
- } else {
2016
- path9.insertBefore(required);
2017
- }
2018
- hasProcessedImports = true;
2019
- }
2020
- if (isVueLike && !path9.removed) {
2021
- path9.remove();
2022
- return;
2023
- }
2024
- replaceVueSuffix(ctx, node.source);
2025
- }
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
- return {
2038
- // 增加 Program.exit 兜底注入 required imports(处理无 ImportDeclaration 的 SFC)
2039
- Program: {
2040
- exit(path9) {
2041
- if (hasProcessedImports) return;
2042
- const required = createRequiredImports(ctx);
2043
- path9.unshiftContainer("body", required);
2044
- hasProcessedImports = true;
2045
- }
2046
- },
2047
- ImportDeclaration(path9) {
2048
- resolveRequiredImport(path9);
2049
- resolveStyleFileExt(path9);
2050
- }
2051
- };
2052
- }
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();
2067
- const ctxImportItems = ctx.imports.get(moduleName);
2068
- if (!_optionalChain([ctxImportItems, 'optionalAccess', _58 => _58.length])) {
2069
- return;
2070
- }
2071
- const currentImports = /* @__PURE__ */ new Set();
2072
- for (const spec of currentNode.specifiers) {
2073
- if (t18.isImportSpecifier(spec) && t18.isIdentifier(spec.imported)) {
2074
- currentImports.add(spec.imported.name);
2075
- }
2076
- if (t18.isImportDefaultSpecifier(spec) && t18.isIdentifier(spec.local)) {
2077
- currentImports.add(spec.local.name);
2078
- }
2079
- }
2080
- for (const item of ctxImportItems) {
2081
- if (currentImports.has(item.name)) return;
2082
- const local = t18.identifier(item.name);
2083
- const newNode = !item.onDemand ? t18.importDefaultSpecifier(local) : t18.importSpecifier(local, local);
2084
- currentNode.specifiers.push(newNode);
2085
- }
2086
- ctx.imports.delete(moduleName);
2087
- }
2088
- function createRequiredImports(ctx) {
2089
- const result = [];
2090
- const importMap = {};
2091
- ctx.imports.forEach((items, moduleName) => {
2092
- const specifier = [];
2093
- for (const item of items) {
2094
- const local = t18.identifier(item.name);
2095
- if (!item.onDemand) {
2096
- specifier.push(t18.importDefaultSpecifier(local));
2097
- } else {
2098
- specifier.push(t18.importSpecifier(local, local));
2099
- }
2100
- }
2101
- importMap[moduleName] = specifier;
2102
- });
2103
- for (const name in importMap) {
2104
- const specifiers = importMap[name];
2105
- const importDecl = t18.importDeclaration(specifiers, t18.stringLiteral(name));
2106
- if (name === PACKAGE_NAME.react) {
2107
- result.unshift(importDecl);
2108
- } else {
2109
- result.push(importDecl);
2110
- }
2111
- }
2112
- return result;
2113
- }
2114
-
2115
- // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-static-hoisting.ts
2116
-
2117
-
2118
1950
  // src/core/transform/sfc/script/shared/babel-utils.ts
2119
1951
 
2120
1952
  function findRootVariablePath(path9) {
2121
1953
  const rootId = findRootIdentifier(path9.node);
2122
- if (!_optionalChain([rootId, 'optionalAccess', _59 => _59.name])) return null;
1954
+ if (!_optionalChain([rootId, 'optionalAccess', _58 => _58.name])) return null;
2123
1955
  const binding = path9.scope.getBinding(rootId.name);
2124
1956
  if (!binding) return null;
2125
1957
  const rootPath = getVariableDeclaratorPath(binding.path);
@@ -2127,10 +1959,10 @@ function findRootVariablePath(path9) {
2127
1959
  }
2128
1960
  function findRootIdentifier(node) {
2129
1961
  let current = node.object;
2130
- while (t19.isMemberExpression(current) || t19.isOptionalMemberExpression(current)) {
1962
+ while (t17.isMemberExpression(current) || t17.isOptionalMemberExpression(current)) {
2131
1963
  current = current.object;
2132
1964
  }
2133
- return t19.isIdentifier(current) ? current : null;
1965
+ return t17.isIdentifier(current) ? current : null;
2134
1966
  }
2135
1967
  function getVariableDeclaratorPath(path9) {
2136
1968
  if (path9.isVariableDeclarator()) {
@@ -2214,14 +2046,14 @@ function isPropertyName(path9) {
2214
2046
  }
2215
2047
  function replaceCallName(callExp, identifierName) {
2216
2048
  const { callee } = callExp;
2217
- if (!t19.isIdentifier(callee)) return;
2049
+ if (!t17.isIdentifier(callee)) return;
2218
2050
  callee.name = identifierName;
2219
2051
  if (callee.loc) {
2220
2052
  callee.loc.identifierName = identifierName;
2221
2053
  }
2222
2054
  }
2223
2055
  function replaceIdName(id, newName) {
2224
- if (!t19.isIdentifier(id)) return;
2056
+ if (!t17.isIdentifier(id)) return;
2225
2057
  id.name = newName;
2226
2058
  if (id.loc) {
2227
2059
  id.loc.identifierName = newName;
@@ -2231,69 +2063,110 @@ function stringValueToTSType(ctx, input, tsTypeAnnotation7) {
2231
2063
  const { filename, scriptData } = ctx;
2232
2064
  const exp = stringToExpr(input, scriptData.lang, filename);
2233
2065
  const ts = expressionToTSType(exp);
2234
- return tsTypeAnnotation7 ? t19.tsTypeAnnotation(ts) : ts;
2066
+ return tsTypeAnnotation7 ? t17.tsTypeAnnotation(ts) : ts;
2235
2067
  }
2236
2068
  function expressionToTSType(exp) {
2237
- if (t19.isStringLiteral(exp)) return t19.tsStringKeyword();
2238
- if (t19.isNumericLiteral(exp)) return t19.tsNumberKeyword();
2239
- if (t19.isBooleanLiteral(exp)) return t19.tsBooleanKeyword();
2240
- if (t19.isArrayExpression(exp)) return t19.tsArrayType(t19.tsAnyKeyword());
2241
- if (t19.isObjectExpression(exp)) {
2069
+ if (t17.isStringLiteral(exp)) return t17.tsStringKeyword();
2070
+ if (t17.isNumericLiteral(exp)) return t17.tsNumberKeyword();
2071
+ if (t17.isBooleanLiteral(exp)) return t17.tsBooleanKeyword();
2072
+ if (t17.isArrayExpression(exp)) return t17.tsArrayType(t17.tsAnyKeyword());
2073
+ if (t17.isObjectExpression(exp)) {
2242
2074
  const members = [];
2243
2075
  for (const p of exp.properties) {
2244
- if (!t19.isObjectProperty(p)) continue;
2076
+ if (!t17.isObjectProperty(p)) continue;
2245
2077
  let key;
2246
- if (t19.isIdentifier(p.key)) key = p.key.name;
2247
- else if (t19.isStringLiteral(p.key)) key = p.key.value;
2078
+ if (t17.isIdentifier(p.key)) key = p.key.name;
2079
+ else if (t17.isStringLiteral(p.key)) key = p.key.value;
2248
2080
  if (!key) continue;
2249
- if (t19.isExpression(p.value)) {
2081
+ if (t17.isExpression(p.value)) {
2250
2082
  members.push(
2251
- t19.tsPropertySignature(t19.identifier(key), t19.tsTypeAnnotation(expressionToTSType(p.value)))
2083
+ t17.tsPropertySignature(t17.identifier(key), t17.tsTypeAnnotation(expressionToTSType(p.value)))
2252
2084
  );
2253
2085
  } else {
2254
2086
  members.push(
2255
- t19.tsPropertySignature(t19.identifier(key), t19.tsTypeAnnotation(t19.tsAnyKeyword()))
2087
+ t17.tsPropertySignature(t17.identifier(key), t17.tsTypeAnnotation(t17.tsAnyKeyword()))
2256
2088
  );
2257
2089
  }
2258
2090
  }
2259
- return t19.tsTypeLiteral(members);
2091
+ return t17.tsTypeLiteral(members);
2260
2092
  }
2261
- if (t19.isArrowFunctionExpression(exp) || t19.isFunctionExpression(exp)) {
2093
+ if (t17.isArrowFunctionExpression(exp) || t17.isFunctionExpression(exp)) {
2262
2094
  const params = exp.params.map((p, i) => {
2263
- const id = t19.isIdentifier(p) ? t19.identifier(p.name) : t19.identifier(`arg${i}`);
2264
- id.typeAnnotation = t19.tsTypeAnnotation(t19.tsAnyKeyword());
2095
+ const id = t17.isIdentifier(p) ? t17.identifier(p.name) : t17.identifier(`arg${i}`);
2096
+ id.typeAnnotation = t17.tsTypeAnnotation(t17.tsAnyKeyword());
2265
2097
  return id;
2266
2098
  });
2267
- let returnType = t19.tsAnyKeyword();
2268
- if (t19.isBlockStatement(exp.body)) {
2099
+ let returnType = t17.tsAnyKeyword();
2100
+ if (t17.isBlockStatement(exp.body)) {
2269
2101
  for (const stmt of exp.body.body) {
2270
- if (t19.isReturnStatement(stmt) && stmt.argument) {
2271
- if (t19.isExpression(stmt.argument)) {
2102
+ if (t17.isReturnStatement(stmt) && stmt.argument) {
2103
+ if (t17.isExpression(stmt.argument)) {
2272
2104
  returnType = expressionToTSType(stmt.argument);
2273
2105
  break;
2274
2106
  }
2275
2107
  }
2276
2108
  }
2277
- } else if (t19.isExpression(exp.body)) {
2109
+ } else if (t17.isExpression(exp.body)) {
2278
2110
  returnType = expressionToTSType(exp.body);
2279
2111
  }
2280
- return t19.tsFunctionType(null, params, t19.tsTypeAnnotation(returnType));
2112
+ return t17.tsFunctionType(null, params, t17.tsTypeAnnotation(returnType));
2281
2113
  }
2282
- return t19.tsAnyKeyword();
2114
+ return t17.tsAnyKeyword();
2283
2115
  }
2284
2116
  function isCalleeNamed(node, name) {
2285
- if (!t19.isIdentifier(node.callee)) {
2117
+ if (!t17.isIdentifier(node.callee)) {
2286
2118
  return false;
2287
2119
  }
2288
2120
  return node.callee.name === name;
2289
2121
  }
2290
2122
  function isSimpleLiteral(node) {
2291
2123
  if (!node) return false;
2292
- if (t19.isStringLiteral(node) || t19.isNumericLiteral(node) || t19.isBooleanLiteral(node) || t19.isNullLiteral(node) || t19.isRegExpLiteral(node) || t19.isBigIntLiteral(node) || t19.isDecimalLiteral(node)) {
2124
+ if (t17.isStringLiteral(node) || t17.isNumericLiteral(node) || t17.isBooleanLiteral(node) || t17.isNullLiteral(node) || t17.isRegExpLiteral(node) || t17.isBigIntLiteral(node) || t17.isDecimalLiteral(node)) {
2293
2125
  return true;
2294
2126
  }
2295
2127
  return false;
2296
2128
  }
2129
+ function forkNode(node, deep = true) {
2130
+ const newNode = t17.cloneNode(node, deep);
2131
+ newNode.leadingComments = node.leadingComments;
2132
+ newNode.innerComments = node.innerComments;
2133
+ newNode.trailingComments = null;
2134
+ cleanNodeLoc(node);
2135
+ cleanNodeComments(node);
2136
+ return newNode;
2137
+ }
2138
+ function cleanNodeLoc(node) {
2139
+ node.start = null;
2140
+ node.end = null;
2141
+ node.loc = null;
2142
+ }
2143
+ function cleanNodeComments(node) {
2144
+ node.leadingComments = null;
2145
+ node.innerComments = null;
2146
+ node.trailingComments = null;
2147
+ }
2148
+
2149
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-global-type-chunk.ts
2150
+ function resolveGlobalTypeChunks(path9, ir) {
2151
+ if (!_optionalChain([path9, 'access', _59 => _59.parentPath, 'optionalAccess', _60 => _60.isProgram, 'call', _61 => _61()])) {
2152
+ return;
2153
+ }
2154
+ const forked = forkNode(path9.node);
2155
+ ir.tsTypes.push(forked);
2156
+ path9.remove();
2157
+ }
2158
+
2159
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-module-chunk.ts
2160
+
2161
+ function resolveModuleChunks(path9, ir) {
2162
+ const forked = forkNode(path9.node);
2163
+ if (t18.isImportDeclaration(forked)) {
2164
+ ir.imports.push(forked);
2165
+ } else if (t18.isExportDeclaration(forked)) {
2166
+ ir.exports.push(forked);
2167
+ }
2168
+ path9.remove();
2169
+ }
2297
2170
 
2298
2171
  // src/core/transform/sfc/script/shared/metadata-utils.ts
2299
2172
  var META_KEY = "__vureact_metadata";
@@ -2311,43 +2184,289 @@ function setScriptNodeMeta(node, opts) {
2311
2184
  node[META_KEY] = opts;
2312
2185
  }
2313
2186
 
2314
- // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-static-hoisting.ts
2315
- function resolveStaticHoisting(ctx) {
2187
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-static-const-chunk.ts
2188
+ function resolveStaticConstChunks(path9, ir) {
2189
+ const { node, parentPath } = path9;
2190
+ const parent = parentPath.node;
2191
+ if (!isVariableDeclTopLevel(path9) || !parentPath.isVariableDeclaration() || parent.kind !== "const" || !isSimpleLiteral(node.init) || getScriptNodeMeta(node)) {
2192
+ return;
2193
+ }
2194
+ const forked = forkNode(parent);
2195
+ ir.statement.global.push(forked);
2196
+ parentPath.remove();
2197
+ }
2198
+
2199
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/index.ts
2200
+ function resolveASTChunks(ctx, ast) {
2316
2201
  const scriptIR = getScriptIR(ctx);
2317
2202
  if (ctx.inputType !== "sfc") {
2318
2203
  return {};
2319
2204
  }
2205
+ scriptIR.statement.local = ast;
2320
2206
  return {
2207
+ // 提取 import/export
2321
2208
  "ImportDeclaration|ExportDeclaration"(path9) {
2322
- if (t20.isImportDeclaration(path9.node)) {
2323
- scriptIR.imports.push(path9.node);
2324
- } else if (t20.isExportDeclaration(path9.node)) {
2325
- scriptIR.exports.push(path9.node);
2326
- }
2327
- path9.remove();
2209
+ resolveModuleChunks(path9, scriptIR);
2328
2210
  },
2211
+ // 提取全局类型声明
2329
2212
  "TSInterfaceDeclaration|TSTypeAliasDeclaration|TSEnumDeclaration|TSModuleDeclaration|TSModuleDeclaration"(path9) {
2330
- if (t20.isProgram(path9.parent)) {
2331
- scriptIR.tsTypes.push(path9.node);
2332
- path9.remove();
2333
- }
2213
+ resolveGlobalTypeChunks(path9, scriptIR);
2334
2214
  },
2215
+ // 提升顶层常量声明
2335
2216
  VariableDeclarator(path9) {
2217
+ resolveStaticConstChunks(path9, scriptIR);
2218
+ }
2219
+ };
2220
+ }
2221
+
2222
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/index.ts
2223
+
2224
+
2225
+ // src/core/transform/shared.ts
2226
+ function recordImport(ctx, pkg, name, onDemand = true) {
2227
+ const { imports } = ctx;
2228
+ if (isTypeOnlyImport(name)) {
2229
+ name = `type ${name}`;
2230
+ }
2231
+ if (imports.has(pkg)) {
2232
+ const list = imports.get(pkg);
2233
+ const foundItem = list.find((item) => item.name === name);
2234
+ if (!foundItem) {
2235
+ list.push({ name, onDemand });
2236
+ }
2237
+ return;
2238
+ }
2239
+ imports.set(pkg, [{ name, onDemand }]);
2240
+ }
2241
+ function isTypeOnlyImport(name) {
2242
+ const arr = [REACT_API_MAP.ReactNode];
2243
+ return arr.includes(name);
2244
+ }
2245
+
2246
+ // src/core/transform/sfc/script/shared/replace-vue-suffix.ts
2247
+ function replaceVueSuffix(node) {
2248
+ if (!node.value.endsWith(".vue")) return;
2249
+ const replaced = node.value.replace(/.vue$/, "");
2250
+ node.value = replaced;
2251
+ node.extra = {
2252
+ rawValue: replaced,
2253
+ // fix: 当 minified: true 的情况下,输出内容丢失引号
2254
+ raw: `'${replaced}'`
2255
+ };
2256
+ }
2257
+
2258
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/import-strategies.ts
2259
+ var VueRouterStrategy = class {
2260
+ matches(moduleName) {
2261
+ return moduleName === "vue-router" || moduleName.startsWith("vue-router/");
2262
+ }
2263
+ process() {
2264
+ return {
2265
+ shouldReplaceSource: true,
2266
+ newSource: PACKAGE_NAME.router,
2267
+ shouldRemove: false,
2268
+ shouldInjectRuntimeImports: false
2269
+ };
2270
+ }
2271
+ };
2272
+ var VueEcosystemStrategy = class {
2273
+ matches(moduleName) {
2274
+ if (moduleName.startsWith(".") || moduleName.startsWith("/") || moduleName.startsWith("file:")) {
2275
+ return false;
2276
+ }
2277
+ if (moduleName === "vue-router" || moduleName.startsWith("vue-router/")) {
2278
+ return false;
2279
+ }
2280
+ if (moduleName.startsWith("@vue/")) {
2281
+ return true;
2282
+ }
2283
+ for (const pkg of VUE_PACKAGES) {
2284
+ if (moduleName === pkg || moduleName.startsWith(`${pkg}/`)) {
2285
+ return true;
2286
+ }
2287
+ }
2288
+ return false;
2289
+ }
2290
+ process() {
2291
+ return {
2292
+ shouldReplaceSource: false,
2293
+ shouldRemove: true,
2294
+ shouldInjectRuntimeImports: true
2295
+ };
2296
+ }
2297
+ };
2298
+ var StyleFileStrategy = (_class3 = class {constructor() { _class3.prototype.__init5.call(this); }
2299
+ __init5() {this.regExp = /\.(less|sass|scss)$/i}
2300
+ matches(moduleName) {
2301
+ return this.regExp.test(moduleName);
2302
+ }
2303
+ process(path9, ctx) {
2304
+ if (!ctx.preprocessStyles) {
2305
+ return {};
2306
+ }
2307
+ const importSource = path9.node.source.value;
2308
+ if (typeof importSource !== "string") {
2309
+ return {};
2310
+ }
2311
+ return {
2312
+ shouldReplaceSource: true,
2313
+ newSource: importSource.replace(this.regExp, ".css"),
2314
+ shouldRemove: false,
2315
+ shouldInjectRuntimeImports: false
2316
+ };
2317
+ }
2318
+ }, _class3);
2319
+
2320
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/import-strategy-manager.ts
2321
+ var ImportStrategyManager = (_class4 = class {
2322
+ __init6() {this.strategies = []}
2323
+ constructor() {;_class4.prototype.__init6.call(this);
2324
+ this.strategies.push(new VueRouterStrategy());
2325
+ this.strategies.push(new VueEcosystemStrategy());
2326
+ this.strategies.push(new StyleFileStrategy());
2327
+ }
2328
+ /** 添加自定义策略 */
2329
+ addStrategy(strategy) {
2330
+ this.strategies.push(strategy);
2331
+ }
2332
+ /** 查找匹配的策略 */
2333
+ findStrategy(moduleName) {
2334
+ for (const strategy of this.strategies) {
2335
+ if (strategy.matches(moduleName)) {
2336
+ return strategy;
2337
+ }
2338
+ }
2339
+ return null;
2340
+ }
2341
+ }, _class4);
2342
+
2343
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-runtime-imports/index.ts
2344
+ function resolveRuntimeImports(ctx) {
2345
+ if (ctx.inputType === "sfc") {
2346
+ recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.memo);
2347
+ }
2348
+ const strategyManager = new ImportStrategyManager();
2349
+ const processedModules = /* @__PURE__ */ new Set();
2350
+ let hasImports = false;
2351
+ return {
2352
+ ImportDeclaration(path9) {
2336
2353
  const { node } = path9;
2337
- if (!isVariableDeclTopLevel(path9) || !isSimpleLiteral(node.init) || getScriptNodeMeta(node)) {
2354
+ const originalModuleName = node.source.value.toLowerCase();
2355
+ const strategy = strategyManager.findStrategy(originalModuleName);
2356
+ let strategyResult = null;
2357
+ if (strategy) {
2358
+ strategyResult = strategy.process(path9, ctx, originalModuleName);
2359
+ if (strategyResult.shouldReplaceSource && strategyResult.newSource) {
2360
+ node.source.value = strategyResult.newSource;
2361
+ }
2362
+ if (strategyResult.shouldRemove && !path9.removed) {
2363
+ path9.remove();
2364
+ return;
2365
+ }
2366
+ }
2367
+ replaceVueSuffix(node.source);
2368
+ const finalModuleName = node.source.value.toLowerCase();
2369
+ if (processedModules.has(finalModuleName) && !path9.removed) {
2370
+ path9.remove();
2338
2371
  return;
2339
2372
  }
2340
- const declarationPath = path9.findParent((p) => p.isVariableDeclaration());
2341
- if (!declarationPath) return;
2342
- scriptIR.statement.global.push(declarationPath.node);
2343
- declarationPath.remove();
2373
+ processedModules.add(finalModuleName);
2374
+ mergeImports(node, ctx, finalModuleName);
2375
+ if (!hasImports) {
2376
+ const importNodes = createImportNodes(ctx);
2377
+ if (importNodes.length) {
2378
+ if (_optionalChain([strategyResult, 'optionalAccess', _62 => _62.shouldInjectRuntimeImports])) {
2379
+ path9.insertAfter(importNodes);
2380
+ } else if (finalModuleName === PACKAGE_NAME.react) {
2381
+ path9.insertAfter(importNodes);
2382
+ } else {
2383
+ forkLeadingComments(importNodes[0], node);
2384
+ path9.insertBefore(importNodes);
2385
+ }
2386
+ }
2387
+ hasImports = true;
2388
+ }
2389
+ },
2390
+ // 兜底:无 ImportDeclaration 的文件也要能注入必需依赖。
2391
+ Program: {
2392
+ exit(path9) {
2393
+ if (hasImports) return;
2394
+ hasImports = true;
2395
+ const { node } = path9;
2396
+ const importNodes = createImportNodes(ctx);
2397
+ if (!importNodes.length) return;
2398
+ forkLeadingComments(importNodes[0], node);
2399
+ path9.unshiftContainer("body", importNodes);
2400
+ }
2344
2401
  }
2345
2402
  };
2346
2403
  }
2347
- function collectLocalStatements(ctx, ast) {
2404
+ function mergeImports(currentNode, ctx, moduleName) {
2405
+ const ctxImportItems = ctx.imports.get(moduleName);
2406
+ if (!_optionalChain([ctxImportItems, 'optionalAccess', _63 => _63.length])) {
2407
+ return;
2408
+ }
2409
+ const currentImports = /* @__PURE__ */ new Set();
2410
+ for (const spec of currentNode.specifiers) {
2411
+ if (t19.isImportSpecifier(spec) && t19.isIdentifier(spec.imported)) {
2412
+ currentImports.add(spec.imported.name);
2413
+ }
2414
+ if (t19.isImportDefaultSpecifier(spec) && t19.isIdentifier(spec.local)) {
2415
+ currentImports.add(spec.local.name);
2416
+ }
2417
+ }
2418
+ for (const item of ctxImportItems) {
2419
+ if (currentImports.has(item.name)) {
2420
+ continue;
2421
+ }
2422
+ const local = t19.identifier(item.name);
2423
+ const newNode = !item.onDemand ? t19.importDefaultSpecifier(local) : t19.importSpecifier(local, local);
2424
+ currentNode.specifiers.push(newNode);
2425
+ }
2426
+ ctx.imports.delete(moduleName);
2427
+ }
2428
+ function createImportNodes(ctx) {
2429
+ const result = [];
2430
+ const importDeclarations = Array.from(ctx.imports).map(([moduleName, items]) => {
2431
+ const specifiers = items.map((item) => {
2432
+ const local = t19.identifier(item.name);
2433
+ return item.onDemand ? t19.importSpecifier(local, local) : t19.importDefaultSpecifier(local);
2434
+ });
2435
+ return t19.importDeclaration(specifiers, t19.stringLiteral(moduleName));
2436
+ });
2437
+ for (const decl of importDeclarations) {
2438
+ const name = decl.source.value;
2439
+ if (name === PACKAGE_NAME.react) {
2440
+ result.unshift(decl);
2441
+ } else {
2442
+ result.push(decl);
2443
+ }
2444
+ }
2445
+ return result;
2446
+ }
2447
+ function forkLeadingComments(target, source) {
2448
+ const { leadingComments } = source;
2449
+ if (!_optionalChain([leadingComments, 'optionalAccess', _64 => _64.length])) {
2450
+ return;
2451
+ }
2452
+ const newComments = [...leadingComments];
2453
+ source.leadingComments = null;
2454
+ target.leadingComments = newComments;
2455
+ }
2456
+
2457
+ // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-sfc-css-import.ts
2458
+
2459
+ function resolveSfcCssImport(ctx) {
2348
2460
  if (ctx.inputType !== "sfc") return;
2349
2461
  const scriptIR = getScriptIR(ctx);
2350
- scriptIR.statement.local = ast;
2462
+ const { filePath, moduleName } = ctx.styleData;
2463
+ if (!filePath) return;
2464
+ const styleFilename = normalizePath(filePath).split("/").pop();
2465
+ const importDecl = t20.importDeclaration(
2466
+ !moduleName ? [] : [t20.importDefaultSpecifier(t20.identifier(moduleName))],
2467
+ t20.stringLiteral(`./${styleFilename}`)
2468
+ );
2469
+ scriptIR.imports.push(importDecl);
2351
2470
  }
2352
2471
 
2353
2472
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-async-component.ts
@@ -2388,7 +2507,7 @@ function checkIsDynamicImport(ctx, node) {
2388
2507
  {
2389
2508
  source: scriptData.source,
2390
2509
  file: filename,
2391
- loc: _optionalChain([target, 'optionalAccess', _60 => _60.loc]) || {}
2510
+ loc: _optionalChain([target, 'optionalAccess', _65 => _65.loc]) || {}
2392
2511
  }
2393
2512
  );
2394
2513
  }
@@ -2407,7 +2526,7 @@ function checkIsDynamicImport(ctx, node) {
2407
2526
  if (t21.isCallExpression(node)) {
2408
2527
  warnIsNotImport(node.callee);
2409
2528
  if (t21.isStringLiteral(node.arguments[0])) {
2410
- replaceVueSuffix(ctx, node.arguments[0]);
2529
+ replaceVueSuffix(node.arguments[0]);
2411
2530
  }
2412
2531
  return;
2413
2532
  }
@@ -2440,7 +2559,7 @@ function pushToGlobalScope(path9, ctx) {
2440
2559
  declarationPath = declarationPath.parentPath;
2441
2560
  }
2442
2561
  let fullNode;
2443
- if (_optionalChain([declarationPath, 'optionalAccess', _61 => _61.isVariableDeclaration, 'call', _62 => _62()])) {
2562
+ if (_optionalChain([declarationPath, 'optionalAccess', _66 => _66.isVariableDeclaration, 'call', _67 => _67()])) {
2444
2563
  fullNode = declarationPath.node;
2445
2564
  declarationPath.remove();
2446
2565
  } else if (path9.parentPath.isVariableDeclarator()) {
@@ -2524,7 +2643,7 @@ function resolveDefineOptions(ctx) {
2524
2643
  logger.warn("defineOptions was found, but no options were provided.", {
2525
2644
  source: scriptData.source,
2526
2645
  file: filename,
2527
- loc: _optionalChain([node, 'optionalAccess', _63 => _63.loc])
2646
+ loc: _optionalChain([node, 'optionalAccess', _68 => _68.loc])
2528
2647
  });
2529
2648
  path9.remove();
2530
2649
  return;
@@ -2533,7 +2652,7 @@ function resolveDefineOptions(ctx) {
2533
2652
  logger.warn("Argument for defineOptions must be an object expression.", {
2534
2653
  source: scriptData.source,
2535
2654
  file: filename,
2536
- loc: _optionalChain([options, 'optionalAccess', _64 => _64.loc])
2655
+ loc: _optionalChain([options, 'optionalAccess', _69 => _69.loc])
2537
2656
  });
2538
2657
  } else {
2539
2658
  for (const prop of options.properties) {
@@ -2558,7 +2677,7 @@ function extractName(prop, ctx) {
2558
2677
  logger.error(`name must be a string type, but got ${prop.value.type}`, {
2559
2678
  source: scriptData.source,
2560
2679
  file: filename,
2561
- loc: _optionalChain([prop, 'access', _65 => _65.key, 'optionalAccess', _66 => _66.loc])
2680
+ loc: _optionalChain([prop, 'access', _70 => _70.key, 'optionalAccess', _71 => _71.loc])
2562
2681
  });
2563
2682
  }
2564
2683
  }
@@ -2601,10 +2720,10 @@ function resolveEmitCalls(ctx) {
2601
2720
  const [callee, ...args] = node.arguments;
2602
2721
  const eventName = t25.isStringLiteral(callee) ? formatEmitEventName(callee.value) : void 0;
2603
2722
  if (!eventName) {
2604
- logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess', _67 => _67.type])}, expression will be removed`, {
2723
+ logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess', _72 => _72.type])}, expression will be removed`, {
2605
2724
  file: filename,
2606
2725
  source: scriptData.source,
2607
- loc: _optionalChain([callee, 'optionalAccess', _68 => _68.loc])
2726
+ loc: _optionalChain([callee, 'optionalAccess', _73 => _73.loc])
2608
2727
  });
2609
2728
  path9.remove();
2610
2729
  return;
@@ -2727,8 +2846,8 @@ function resolveTopLevelEmitType(tsType) {
2727
2846
  function resolveDefineEmitsIface(path9, ctx) {
2728
2847
  const { node } = path9;
2729
2848
  const [runtimeArg] = node.arguments;
2730
- const tsParams = _optionalChain([node, 'access', _69 => _69.typeParameters, 'optionalAccess', _70 => _70.params]);
2731
- if (_optionalChain([tsParams, 'optionalAccess', _71 => _71.length])) {
2849
+ const tsParams = _optionalChain([node, 'access', _74 => _74.typeParameters, 'optionalAccess', _75 => _75.params]);
2850
+ if (_optionalChain([tsParams, 'optionalAccess', _76 => _76.length])) {
2732
2851
  processExplicitType(ctx, tsParams);
2733
2852
  return;
2734
2853
  }
@@ -2926,12 +3045,12 @@ function resolveEmitPropFromPropertySignature(member) {
2926
3045
  if (!rawName) return null;
2927
3046
  const handlerName = resolveEmitHandlerName(rawName);
2928
3047
  const key = buildKey(handlerName);
2929
- const typeAnnotation = _optionalChain([member, 'access', _72 => _72.typeAnnotation, 'optionalAccess', _73 => _73.typeAnnotation]);
3048
+ const typeAnnotation = _optionalChain([member, 'access', _77 => _77.typeAnnotation, 'optionalAccess', _78 => _78.typeAnnotation]);
2930
3049
  let params = [];
2931
3050
  let returnType = t27.tsAnyKeyword();
2932
3051
  if (typeAnnotation && t27.isTSFunctionType(typeAnnotation)) {
2933
3052
  params = cloneCallableParams(typeAnnotation.parameters);
2934
- returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _74 => _74.typeAnnotation, 'optionalAccess', _75 => _75.typeAnnotation]), () => ( returnType));
3053
+ returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _79 => _79.typeAnnotation, 'optionalAccess', _80 => _80.typeAnnotation]), () => ( returnType));
2935
3054
  } else if (typeAnnotation && t27.isTSTupleType(typeAnnotation)) {
2936
3055
  params = resolveTupleTypeParams(typeAnnotation);
2937
3056
  } else if (typeAnnotation) {
@@ -2956,7 +3075,7 @@ function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
2956
3075
  if (t27.isNoop(paramTypeAnnotation)) return [];
2957
3076
  const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
2958
3077
  if (!eventNames.length) return [];
2959
- const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _76 => _76.typeAnnotation]), () => ( t27.tsAnyKeyword()));
3078
+ const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _81 => _81.typeAnnotation]), () => ( t27.tsAnyKeyword()));
2960
3079
  return eventNames.map((eventName) => {
2961
3080
  const handlerName = resolveEmitHandlerName(eventName);
2962
3081
  const key = buildKey(handlerName);
@@ -2990,7 +3109,7 @@ function resolveTupleElementParam(element, index) {
2990
3109
  const isNamedTuple = typeof t27.isTSNamedTupleMember === "function" && t27.isTSNamedTupleMember(element);
2991
3110
  if (isNamedTuple) {
2992
3111
  const tupleMember = element;
2993
- const name = _optionalChain([tupleMember, 'access', _77 => _77.label, 'optionalAccess', _78 => _78.name]) || `arg${index}`;
3112
+ const name = _optionalChain([tupleMember, 'access', _82 => _82.label, 'optionalAccess', _83 => _83.name]) || `arg${index}`;
2994
3113
  let innerType = tupleMember.elementType;
2995
3114
  let optional = tupleMember.optional;
2996
3115
  if (t27.isTSOptionalType(innerType)) {
@@ -3028,8 +3147,8 @@ function resolveTupleElementParam(element, index) {
3028
3147
  function resolveDefinePropsIface(path9, ctx) {
3029
3148
  const { node } = path9;
3030
3149
  const [runtimeArg] = node.arguments;
3031
- const tsParams = _optionalChain([node, 'access', _79 => _79.typeParameters, 'optionalAccess', _80 => _80.params]);
3032
- if (_optionalChain([tsParams, 'optionalAccess', _81 => _81.length])) {
3150
+ const tsParams = _optionalChain([node, 'access', _84 => _84.typeParameters, 'optionalAccess', _85 => _85.params]);
3151
+ if (_optionalChain([tsParams, 'optionalAccess', _86 => _86.length])) {
3033
3152
  const { propsTSIface } = ctx.scriptData;
3034
3153
  propsTSIface.propsTypes = tsParams;
3035
3154
  return;
@@ -3084,7 +3203,7 @@ function processInferredTypes2(ctx, runtimeArg) {
3084
3203
  {
3085
3204
  source,
3086
3205
  file: filename,
3087
- loc: _optionalChain([runtimeArg, 'optionalAccess', _82 => _82.loc])
3206
+ loc: _optionalChain([runtimeArg, 'optionalAccess', _87 => _87.loc])
3088
3207
  }
3089
3208
  );
3090
3209
  }
@@ -3171,6 +3290,9 @@ var SLOT_DEFAULT_NAME = "default";
3171
3290
  var SLOT_CHILDREN_NAME = "children";
3172
3291
  var SLOT_FN_PARAM_NAME = "props";
3173
3292
  function resolveSlotsTopLevelTypes(ctx) {
3293
+ if (ctx.inputType !== "sfc") {
3294
+ return {};
3295
+ }
3174
3296
  return {
3175
3297
  "TSInterfaceDeclaration|TSTypeAliasDeclaration"(path9) {
3176
3298
  if (!t29.isProgram(path9.parent)) return;
@@ -3198,8 +3320,8 @@ function resolveSlotsTopLevelTypes(ctx) {
3198
3320
  }
3199
3321
  function resolveDefineSlotsIface(path9, ctx) {
3200
3322
  const { node } = path9;
3201
- const tsParams = _optionalChain([node, 'access', _83 => _83.typeParameters, 'optionalAccess', _84 => _84.params]);
3202
- if (!_optionalChain([tsParams, 'optionalAccess', _85 => _85.length])) return;
3323
+ const tsParams = _optionalChain([node, 'access', _88 => _88.typeParameters, 'optionalAccess', _89 => _89.params]);
3324
+ if (!_optionalChain([tsParams, 'optionalAccess', _90 => _90.length])) return;
3203
3325
  const {
3204
3326
  propsTSIface: { slotTypes }
3205
3327
  } = ctx.scriptData;
@@ -3313,7 +3435,7 @@ function hasSlotsSignatureInMember(member) {
3313
3435
  if (t29.isTSMethodSignature(member)) return true;
3314
3436
  if (t29.isTSCallSignatureDeclaration(member)) return true;
3315
3437
  if (t29.isTSPropertySignature(member)) {
3316
- const typeAnnotation = _optionalChain([member, 'access', _86 => _86.typeAnnotation, 'optionalAccess', _87 => _87.typeAnnotation]);
3438
+ const typeAnnotation = _optionalChain([member, 'access', _91 => _91.typeAnnotation, 'optionalAccess', _92 => _92.typeAnnotation]);
3317
3439
  return !!(typeAnnotation && resolveCallableType(typeAnnotation));
3318
3440
  }
3319
3441
  return false;
@@ -3328,7 +3450,7 @@ function resolveSlotPropFromMember(member) {
3328
3450
  if (t29.isTSPropertySignature(member)) {
3329
3451
  const rawName = resolvePropName2(member.key);
3330
3452
  if (!rawName) return null;
3331
- const typeAnnotation = _optionalChain([member, 'access', _88 => _88.typeAnnotation, 'optionalAccess', _89 => _89.typeAnnotation]);
3453
+ const typeAnnotation = _optionalChain([member, 'access', _93 => _93.typeAnnotation, 'optionalAccess', _94 => _94.typeAnnotation]);
3332
3454
  const callable = typeAnnotation ? resolveCallableType(typeAnnotation) : null;
3333
3455
  if (!callable) return null;
3334
3456
  const params = cloneCallableParams(callable.parameters);
@@ -3367,7 +3489,7 @@ function createSlotScopeParam(props, ctx) {
3367
3489
  const propsSigns = [];
3368
3490
  const { reactiveBindings } = ctx.templateData;
3369
3491
  props.forEach(({ prop, tsType }) => {
3370
- const foundBindingValue = _optionalChain([reactiveBindings, 'access', _90 => _90[prop], 'optionalAccess', _91 => _91.value]);
3492
+ const foundBindingValue = _optionalChain([reactiveBindings, 'access', _95 => _95[prop], 'optionalAccess', _96 => _96.value]);
3371
3493
  const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
3372
3494
  const typeAnnotation = foundBindingTypes ? t29.tsTypeAnnotation(foundBindingTypes) : tsType;
3373
3495
  const key = t29.isValidIdentifier(prop) ? t29.identifier(prop) : t29.stringLiteral(prop);
@@ -3612,11 +3734,11 @@ function analyzeDeps(node, ctx, parentPath) {
3612
3734
  const bindingPath = binding.path;
3613
3735
  const declaratorPath = getVariableDeclaratorPath(bindingPath);
3614
3736
  const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
3615
- const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _92 => _92.node, 'access', _93 => _93.init]);
3737
+ const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _97 => _97.node, 'access', _98 => _98.init]);
3616
3738
  const isReactiveApiCallVarBinding = !!declaratorPath && t31.isCallExpression(nodeInit) && t31.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
3617
3739
  const isHookCallVarBinding = !!declaratorPath && t31.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
3618
3740
  const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t31.isArrowFunctionExpression(nodeInit) || t31.isFunctionExpression(nodeInit));
3619
- const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess', _94 => _94.node])) || isReactiveBinding(bindingPath.node));
3741
+ const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess', _99 => _99.node])) || isReactiveBinding(bindingPath.node));
3620
3742
  return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
3621
3743
  }
3622
3744
  function isHookLikeCallee(callee) {
@@ -3723,7 +3845,7 @@ function isNestedMemberObject(path9) {
3723
3845
  }
3724
3846
  function isReactiveBinding(node) {
3725
3847
  if (!node) return false;
3726
- return !!_optionalChain([getScriptNodeMeta, 'call', _95 => _95(node), 'optionalAccess', _96 => _96.is_reactive]);
3848
+ return !!_optionalChain([getScriptNodeMeta, 'call', _100 => _100(node), 'optionalAccess', _101 => _101.is_reactive]);
3727
3849
  }
3728
3850
 
3729
3851
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
@@ -3736,6 +3858,9 @@ function resolveAnalysisOnlyAdapter(ctx) {
3736
3858
  if (!adapter || adapter.type !== "analyzed-deps") {
3737
3859
  return;
3738
3860
  }
3861
+ if (!isVueApiReference(path9, apiName)) {
3862
+ return;
3863
+ }
3739
3864
  if (t32.isCallExpression(node)) {
3740
3865
  resolveCallNode(path9, adapter, ctx);
3741
3866
  } else {
@@ -3769,6 +3894,41 @@ function resolveCallNode(path9, adapter, ctx) {
3769
3894
  replaceCallName(node, adapter.target);
3770
3895
  recordImport(ctx, adapter.package, adapter.target);
3771
3896
  }
3897
+ function isVueApiReference(path9, apiName) {
3898
+ if (path9.isIdentifier()) {
3899
+ if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
3900
+ return false;
3901
+ }
3902
+ if (!path9.isReferencedIdentifier()) {
3903
+ return false;
3904
+ }
3905
+ }
3906
+ if (path9.isCallExpression()) {
3907
+ const callee = path9.get("callee");
3908
+ if (!callee.isIdentifier()) return false;
3909
+ return isVueImportBinding(callee.scope.getBinding(apiName));
3910
+ }
3911
+ return isVueImportBinding(path9.scope.getBinding(apiName));
3912
+ }
3913
+ function isVueImportBinding(binding) {
3914
+ if (!binding) return false;
3915
+ const bindingPath = binding.path;
3916
+ if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
3917
+ return false;
3918
+ }
3919
+ const parent = _optionalChain([bindingPath, 'access', _102 => _102.parentPath, 'optionalAccess', _103 => _103.node]);
3920
+ if (!parent || !t32.isImportDeclaration(parent)) {
3921
+ return false;
3922
+ }
3923
+ const source = parent.source.value.toLowerCase();
3924
+ if (source.startsWith("@vue/")) {
3925
+ return true;
3926
+ }
3927
+ if (source === "vue-router" || source.startsWith("vue-router/")) {
3928
+ return true;
3929
+ }
3930
+ return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
3931
+ }
3772
3932
 
3773
3933
  // src/core/transform/sfc/script/syntax-processor/process/resolve-arrow-deps.ts
3774
3934
  function resolveArrowFnDeps(ctx, ast) {
@@ -3783,7 +3943,7 @@ function resolveArrowFnDeps(ctx, ast) {
3783
3943
  const newNode = createUseCallback(node, deps);
3784
3944
  const declaratorPath = getVariableDeclaratorPath(path9);
3785
3945
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
3786
- setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _97 => _97.node]), { is_reactive: true, reactive_type: "indirect" });
3946
+ setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _104 => _104.node]), { is_reactive: true, reactive_type: "indirect" });
3787
3947
  path9.replaceWith(newNode);
3788
3948
  }
3789
3949
  };
@@ -3842,8 +4002,8 @@ function resolveElementRef(ctx) {
3842
4002
  return;
3843
4003
  }
3844
4004
  if (isCompRefBindings) {
3845
- const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _98 => _98(path9), 'optionalAccess', _99 => _99.node]);
3846
- if (!t33.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _100 => _100.id]))) {
4005
+ const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _105 => _105(path9), 'optionalAccess', _106 => _106.node]);
4006
+ if (!t33.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _107 => _107.id]))) {
3847
4007
  return;
3848
4008
  }
3849
4009
  const varName = varDeclaratorPath.id.name;
@@ -3866,7 +4026,7 @@ function resolveTypeParameters(ctx, path9) {
3866
4026
  scriptData
3867
4027
  } = ctx;
3868
4028
  const { node } = path9;
3869
- const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _101 => _101(path9), 'optionalAccess', _102 => _102.node]);
4029
+ const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _108 => _108(path9), 'optionalAccess', _109 => _109.node]);
3870
4030
  if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
3871
4031
  return;
3872
4032
  }
@@ -3884,11 +4044,11 @@ function resolveRefValueToCurrent(path9) {
3884
4044
  return;
3885
4045
  }
3886
4046
  const rootPath = findRootVariablePath(path9);
3887
- if (!_optionalChain([rootPath, 'optionalAccess', _103 => _103.node]) || !t33.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4047
+ if (!_optionalChain([rootPath, 'optionalAccess', _110 => _110.node]) || !t33.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
3888
4048
  return;
3889
4049
  }
3890
4050
  const rootId = findRootIdentifier(node);
3891
- if (!t33.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _104 => _104.name])) {
4051
+ if (!t33.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _111 => _111.name])) {
3892
4052
  return;
3893
4053
  }
3894
4054
  node.property.name = "current";
@@ -3989,7 +4149,7 @@ function resolveProvide(ctx) {
3989
4149
  return {
3990
4150
  CallExpression(path9) {
3991
4151
  const { node } = path9;
3992
- const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _105 => _105.runtime, 'access', _106 => _106[VUE_API_MAP.provide], 'optionalAccess', _107 => _107.target]);
4152
+ const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _112 => _112.runtime, 'access', _113 => _113[VUE_API_MAP.provide], 'optionalAccess', _114 => _114.target]);
3993
4153
  const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
3994
4154
  if (!isProvideCall) return;
3995
4155
  const { provide } = ctx.scriptData;
@@ -4007,7 +4167,7 @@ function findOrCreateCtxProvider(root) {
4007
4167
  return root;
4008
4168
  }
4009
4169
  let cur = root.provide;
4010
- while (_optionalChain([cur, 'optionalAccess', _108 => _108.isOccupied])) {
4170
+ while (_optionalChain([cur, 'optionalAccess', _115 => _115.isOccupied])) {
4011
4171
  cur = _nullishCoalesce(cur.provide, () => ( {}));
4012
4172
  }
4013
4173
  return cur || (root.provide = {});
@@ -4049,16 +4209,22 @@ function resolveRenameAdapter(ctx) {
4049
4209
  } else if (isCallNode && t37.isIdentifier(node.callee)) {
4050
4210
  apiName = node.callee.name;
4051
4211
  }
4212
+ if (!apiName) {
4213
+ return;
4214
+ }
4052
4215
  const runtimeAdapter = ADAPTER_RULES.runtime[apiName];
4053
4216
  const routerAdapter = ADAPTER_RULES.router[apiName];
4054
4217
  const adapter = runtimeAdapter || routerAdapter;
4055
4218
  if (!adapter || adapter.type !== "rename") {
4056
4219
  return;
4057
4220
  }
4221
+ if (!isVueApiReference2(path9, apiName)) {
4222
+ return;
4223
+ }
4058
4224
  if (adapter.isTrackable) {
4059
4225
  const reactiveType = getReactiveType(apiName);
4060
4226
  const declaratorPath = getVariableDeclaratorPath(path9);
4061
- setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _109 => _109.node]), {
4227
+ setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _116 => _116.node]), {
4062
4228
  is_reactive: true,
4063
4229
  reactive_type: reactiveType
4064
4230
  });
@@ -4075,6 +4241,41 @@ function resolveRenameAdapter(ctx) {
4075
4241
  }
4076
4242
  };
4077
4243
  }
4244
+ function isVueApiReference2(path9, apiName) {
4245
+ if (path9.isIdentifier()) {
4246
+ if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
4247
+ return false;
4248
+ }
4249
+ if (!path9.isReferencedIdentifier()) {
4250
+ return false;
4251
+ }
4252
+ }
4253
+ if (path9.isCallExpression()) {
4254
+ const callee = path9.get("callee");
4255
+ if (!callee.isIdentifier()) return false;
4256
+ return isVueImportBinding2(callee.scope.getBinding(apiName));
4257
+ }
4258
+ return isVueImportBinding2(path9.scope.getBinding(apiName));
4259
+ }
4260
+ function isVueImportBinding2(binding) {
4261
+ if (!binding) return false;
4262
+ const bindingPath = binding.path;
4263
+ if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
4264
+ return false;
4265
+ }
4266
+ const parent = _optionalChain([bindingPath, 'access', _117 => _117.parentPath, 'optionalAccess', _118 => _118.node]);
4267
+ if (!parent || !t37.isImportDeclaration(parent)) {
4268
+ return false;
4269
+ }
4270
+ const source = parent.source.value.toLowerCase();
4271
+ if (source.startsWith("@vue/")) {
4272
+ return true;
4273
+ }
4274
+ if (source === "vue-router" || source.startsWith("vue-router/")) {
4275
+ return true;
4276
+ }
4277
+ return VUE_PACKAGES.some((name) => source === name || source.startsWith(`${name}/`));
4278
+ }
4078
4279
 
4079
4280
  // src/core/transform/sfc/script/syntax-processor/index.ts
4080
4281
  function processVueSyntax2(ast, ctx) {
@@ -4106,19 +4307,19 @@ function processVueSyntax2(ast, ctx) {
4106
4307
  excludeBabel: [resolveTemplateSlotIface, resolveCompIProps]
4107
4308
  },
4108
4309
  postprocess: {
4109
- applyBabel: [insertRequiredImports, resolveStaticHoisting],
4110
- excludeBabel: [insertCSSImport, collectLocalStatements]
4310
+ applyBabel: [resolveRuntimeImports, resolveASTChunks],
4311
+ excludeBabel: [resolveSfcCssImport]
4111
4312
  }
4112
4313
  });
4113
4314
  }
4114
4315
  function vueSyntaxProcessor2(ast, ctx, options) {
4115
4316
  const runExcludeThenApply = (cfg) => {
4116
- _optionalChain([cfg, 'access', _110 => _110.excludeBabel, 'optionalAccess', _111 => _111.forEach, 'call', _112 => _112((fn) => fn(ctx, ast))]);
4117
- _optionalChain([cfg, 'access', _113 => _113.applyBabel, 'optionalAccess', _114 => _114.forEach, 'call', _115 => _115((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
4317
+ _optionalChain([cfg, 'access', _119 => _119.excludeBabel, 'optionalAccess', _120 => _120.forEach, 'call', _121 => _121((fn) => fn(ctx, ast))]);
4318
+ _optionalChain([cfg, 'access', _122 => _122.applyBabel, 'optionalAccess', _123 => _123.forEach, 'call', _124 => _124((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
4118
4319
  };
4119
4320
  const runApplyThenExclude = (cfg) => {
4120
- _optionalChain([cfg, 'access', _116 => _116.applyBabel, 'optionalAccess', _117 => _117.forEach, 'call', _118 => _118((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
4121
- _optionalChain([cfg, 'access', _119 => _119.excludeBabel, 'optionalAccess', _120 => _120.forEach, 'call', _121 => _121((fn) => fn(ctx, ast))]);
4321
+ _optionalChain([cfg, 'access', _125 => _125.applyBabel, 'optionalAccess', _126 => _126.forEach, 'call', _127 => _127((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
4322
+ _optionalChain([cfg, 'access', _128 => _128.excludeBabel, 'optionalAccess', _129 => _129.forEach, 'call', _130 => _130((fn) => fn(ctx, ast))]);
4122
4323
  };
4123
4324
  runExcludeThenApply(options.preprocess);
4124
4325
  runExcludeThenApply(options.process);
@@ -4247,7 +4448,7 @@ function isIdentifier20(code) {
4247
4448
  function isStringLiteral12(code) {
4248
4449
  try {
4249
4450
  const node = _parser.parseExpression.call(void 0, code);
4250
- return t38.isStringLiteral(node) || t38.isTemplateLiteral(node);
4451
+ return t38.isStringLiteral(node);
4251
4452
  } catch (e9) {
4252
4453
  return false;
4253
4454
  }
@@ -4320,7 +4521,10 @@ function normalizePropName(rawName, name) {
4320
4521
  case "for":
4321
4522
  return "htmlFor";
4322
4523
  default:
4323
- return whitelist.test(name) ? name : camelCase(name);
4524
+ if (!isVBind(rawName) && whitelist.test(name)) {
4525
+ return name;
4526
+ }
4527
+ return camelCase(name);
4324
4528
  }
4325
4529
  }
4326
4530
  function isVOn(name) {
@@ -4336,7 +4540,7 @@ function isVModel(name) {
4336
4540
  return /^v-model/.test(_nullishCoalesce(name, () => ( "")));
4337
4541
  }
4338
4542
  function isClassAttr(name) {
4339
- return /^(class|:class|v-bind:class|className)$/.test(_nullishCoalesce(name, () => ( "")));
4543
+ return /^(class|:class|v-bind:class|className|class-name)$/.test(_nullishCoalesce(name, () => ( "")));
4340
4544
  }
4341
4545
  function isStyleAttr(name) {
4342
4546
  return /^(style|:style|v-bind:style)$/.test(_nullishCoalesce(name, () => ( "")));
@@ -4354,12 +4558,12 @@ function wrapSingleQuotes(content, condition) {
4354
4558
  return condition || strCodeTypes.isStringLiteral(content) ? `'${content}'` : content;
4355
4559
  }
4356
4560
  function checkPropIsDynamicKey(ctx, node) {
4357
- const isKeyStatic = _optionalChain([node, 'access', _122 => _122.arg, 'optionalAccess', _123 => _123.isStatic]);
4561
+ const isKeyStatic = _optionalChain([node, 'access', _131 => _131.arg, 'optionalAccess', _132 => _132.isStatic]);
4358
4562
  const { source, filename } = ctx;
4359
4563
  if (node.rawName === "v-bind" && !node.name) {
4360
4564
  logger.warn("Keyless v-bind will overwrite all previously declared props at runtime.", {
4361
4565
  source,
4362
- loc: _optionalChain([node, 'access', _124 => _124.arg, 'optionalAccess', _125 => _125.loc]),
4566
+ loc: _optionalChain([node, 'access', _133 => _133.arg, 'optionalAccess', _134 => _134.loc]),
4363
4567
  file: filename
4364
4568
  });
4365
4569
  return;
@@ -4367,7 +4571,7 @@ function checkPropIsDynamicKey(ctx, node) {
4367
4571
  if (isKeyStatic === false) {
4368
4572
  logger.warn("Avoid using dynamic slot names, as they generate complex JSX prop expressions.", {
4369
4573
  source,
4370
- loc: _optionalChain([node, 'access', _126 => _126.arg, 'optionalAccess', _127 => _127.loc]),
4574
+ loc: _optionalChain([node, 'access', _135 => _135.arg, 'optionalAccess', _136 => _136.loc]),
4371
4575
  file: filename
4372
4576
  });
4373
4577
  }
@@ -4412,19 +4616,19 @@ function resolvePropAsBabelExp(ir, ctx) {
4412
4616
  }
4413
4617
  if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
4414
4618
  const dirCls = ADAPTER_RULES.runtime.dirCls;
4415
- const arg = _optionalChain([mergedItems, 'optionalAccess', _128 => _128.join, 'call', _129 => _129(",")]) || wrapSingleQuotes(valueContent);
4619
+ const arg = _optionalChain([mergedItems, 'optionalAccess', _137 => _137.join, 'call', _138 => _138(",")]) || wrapSingleQuotes(valueContent);
4416
4620
  const expression = createRuntimeCall(dirCls.target, [arg]);
4417
4621
  applyRuntimeExpression(expression, true, name);
4418
4622
  return;
4419
4623
  }
4420
- if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _130 => _130.some, 'call', _131 => _131((item) => !isSimpleStyle(item))]))) {
4624
+ if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _139 => _139.some, 'call', _140 => _140((item) => !isSimpleStyle(item))]))) {
4421
4625
  const dirStyle = ADAPTER_RULES.runtime.dirStyle;
4422
- const arg = _optionalChain([mergedItems, 'optionalAccess', _132 => _132.join, 'call', _133 => _133(",")]) || valueContent;
4626
+ const arg = _optionalChain([mergedItems, 'optionalAccess', _141 => _141.join, 'call', _142 => _142(",")]) || valueContent;
4423
4627
  const expression = createRuntimeCall(dirStyle.target, [arg]);
4424
4628
  applyRuntimeExpression(expression, true, name);
4425
4629
  return;
4426
4630
  }
4427
- if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _134 => _134.modifiers, 'optionalAccess', _135 => _135.length])) {
4631
+ if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _143 => _143.modifiers, 'optionalAccess', _144 => _144.length])) {
4428
4632
  const dirOn = ADAPTER_RULES.runtime.dirOn;
4429
4633
  const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
4430
4634
  const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
@@ -4479,7 +4683,7 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
4479
4683
  continue;
4480
4684
  }
4481
4685
  const nodeIR = child;
4482
- if (_optionalChain([parentIR, 'optionalAccess', _136 => _136.isBuiltIn])) {
4686
+ if (_optionalChain([parentIR, 'optionalAccess', _145 => _145.isBuiltIn])) {
4483
4687
  if (parentIR.tag == VUE_API_MAP.Transition) {
4484
4688
  resolveTransitionRules(nodeIR, parentIR, ir, ctx);
4485
4689
  }
@@ -4520,7 +4724,7 @@ function walkElementNodes(node, onElement) {
4520
4724
  }
4521
4725
  function resolveDefaultStyleModuleName(node) {
4522
4726
  const { exp } = node;
4523
- if (_optionalChain([exp, 'optionalAccess', _137 => _137.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4727
+ if (_optionalChain([exp, 'optionalAccess', _146 => _146.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4524
4728
  return;
4525
4729
  }
4526
4730
  if (exp.content.includes("$style")) {
@@ -4534,7 +4738,6 @@ function resolveDefaultStyleModuleName(node) {
4534
4738
 
4535
4739
 
4536
4740
 
4537
-
4538
4741
  function resolveStyleScopeAttribute(node, _ir, ctx) {
4539
4742
  if (!ctx.styleData.scopeId) {
4540
4743
  return;
@@ -4554,21 +4757,30 @@ function walkElementNodes2(node, onElement) {
4554
4757
  }
4555
4758
  function injectStyleScopeAttribute(node, ctx) {
4556
4759
  const { scopeId } = ctx.styleData;
4557
- if (!scopeId || isComponentElement(node) || _compilercore.isSlotOutlet.call(void 0, node) || _compilercore.isTemplateNode.call(void 0, node)) {
4760
+ if (!scopeId || _compilercore.isSlotOutlet.call(void 0, node) || _compilercore.isTemplateNode.call(void 0, node)) {
4558
4761
  return;
4559
4762
  }
4560
- const hasDynamicIs = node.props.some((prop) => {
4561
- if (prop.type !== _compilercore.NodeTypes.DIRECTIVE || _optionalChain([prop, 'access', _138 => _138.arg, 'optionalAccess', _139 => _139.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4562
- return false;
4763
+ let hasScopeId = false;
4764
+ let hasClassOrId = false;
4765
+ for (const prop of node.props) {
4766
+ if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
4767
+ if (prop.name === scopeId) {
4768
+ hasScopeId = true;
4769
+ break;
4770
+ }
4771
+ if (getHasClassOrId(prop.name)) {
4772
+ hasClassOrId = true;
4773
+ break;
4774
+ }
4775
+ }
4776
+ if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access', _147 => _147.arg, 'optionalAccess', _148 => _148.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4777
+ if (getHasClassOrId(prop.arg.content)) {
4778
+ hasClassOrId = true;
4779
+ break;
4780
+ }
4563
4781
  }
4564
- return prop.arg.content === "is";
4565
- });
4566
- const hasScopeId = node.props.some(
4567
- (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === scopeId
4568
- );
4569
- if (hasDynamicIs || hasScopeId) {
4570
- return;
4571
4782
  }
4783
+ if (hasScopeId || !hasClassOrId) return;
4572
4784
  const attr = {
4573
4785
  type: _compilercore.NodeTypes.ATTRIBUTE,
4574
4786
  name: scopeId,
@@ -4578,11 +4790,8 @@ function injectStyleScopeAttribute(node, ctx) {
4578
4790
  };
4579
4791
  node.props.push(attr);
4580
4792
  }
4581
- function isComponentElement(node) {
4582
- if (node.tagType !== _compilercore.ElementTypes.COMPONENT) {
4583
- return camelCase(node.tag) !== node.tag;
4584
- }
4585
- return node.tagType === _compilercore.ElementTypes.COMPONENT;
4793
+ function getHasClassOrId(ns) {
4794
+ return isClassAttr(ns) || ns === "id";
4586
4795
  }
4587
4796
 
4588
4797
  // src/core/transform/sfc/template/shared/prop-merge-utils.ts
@@ -4624,7 +4833,7 @@ function mergeStyleProps(oldAttr, newAttr) {
4624
4833
  const oldStyle = oldAttr.value.content;
4625
4834
  const newStyle = parseStyleString(newAttr.value.content);
4626
4835
  let merged = oldAttr.value.merge;
4627
- if (!_optionalChain([merged, 'optionalAccess', _140 => _140.length])) {
4836
+ if (!_optionalChain([merged, 'optionalAccess', _149 => _149.length])) {
4628
4837
  merged = oldAttr.value.merge = [oldStyle, newStyle];
4629
4838
  } else {
4630
4839
  merged.push(newStyle);
@@ -4654,7 +4863,7 @@ function warnUnsupportedVueDollarVar(ctx, node) {
4654
4863
  const { source, filename } = ctx;
4655
4864
  let value = "";
4656
4865
  let loc;
4657
- if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _141 => _141.exp, 'optionalAccess', _142 => _142.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4866
+ if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _150 => _150.exp, 'optionalAccess', _151 => _151.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
4658
4867
  value = node.exp.content;
4659
4868
  loc = node.exp.loc;
4660
4869
  } else if (node.type === _compilercore.NodeTypes.INTERPOLATION && node.content.type === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
@@ -4708,11 +4917,11 @@ function resolveRefProp(node, ctx, nodeIR) {
4708
4917
  } = ctx;
4709
4918
  let propIR;
4710
4919
  if (node.type === _compilercore.NodeTypes.ATTRIBUTE) {
4711
- const tag = _optionalChain([node, 'access', _143 => _143.value, 'optionalAccess', _144 => _144.content]);
4920
+ const tag = _optionalChain([node, 'access', _152 => _152.value, 'optionalAccess', _153 => _153.content]);
4712
4921
  if (!tag) return;
4713
4922
  collectComponentRef(tag, ctx);
4714
4923
  const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
4715
- const refVar = _optionalChain([domRefBinding, 'optionalAccess', _145 => _145.name]) || _optionalChain([refBindings, 'access', _146 => _146.componentRefs, 'access', _147 => _147[tag], 'optionalAccess', _148 => _148.name]);
4924
+ const refVar = _optionalChain([domRefBinding, 'optionalAccess', _154 => _154.name]) || _optionalChain([refBindings, 'access', _155 => _155.componentRefs, 'access', _156 => _156[tag], 'optionalAccess', _157 => _157.name]);
4716
4925
  propIR = createPropsIR("ref", "ref", refVar || "null");
4717
4926
  } else {
4718
4927
  const exp = node.exp;
@@ -4747,8 +4956,8 @@ function collectComponentRef(tag, ctx) {
4747
4956
  function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
4748
4957
  const arg = node.arg;
4749
4958
  const exp = node.exp;
4750
- const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _149 => _149.content]), () => ( ""));
4751
- const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _150 => _150.content]), () => ( "true"));
4959
+ const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _158 => _158.content]), () => ( ""));
4960
+ const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _159 => _159.content]), () => ( "true"));
4752
4961
  warnUnsupportedVueDollarVar(ctx, node);
4753
4962
  if (name === "is") {
4754
4963
  resolveDynamicIsProp(node, ir, ctx, nodeIR);
@@ -4759,7 +4968,7 @@ function resolveDynamicAttributeProp(node, ir, ctx, nodeIR) {
4759
4968
  return;
4760
4969
  }
4761
4970
  const dynamicPropIR = createPropsIR(node.rawName, name, content);
4762
- dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _151 => _151.isStatic]), () => ( true));
4971
+ dynamicPropIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _160 => _160.isStatic]), () => ( true));
4763
4972
  checkPropIsDynamicKey(ctx, node);
4764
4973
  resolvePropertyIR(dynamicPropIR, ir, ctx, nodeIR, true);
4765
4974
  }
@@ -4773,7 +4982,12 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
4773
4982
  content = node.value.content = parseStyleString(content);
4774
4983
  }
4775
4984
  if (isDynamic) {
4776
- node.value.isStringLiteral = strCodeTypes.isStringLiteral(content);
4985
+ const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
4986
+ if (isStringLiteral13) {
4987
+ content = normalizeString(content);
4988
+ node.value.content = content;
4989
+ }
4990
+ node.value.isStringLiteral = isStringLiteral13;
4777
4991
  }
4778
4992
  const existing = findSameProp(nodeIR.props, node);
4779
4993
  if (existing) {
@@ -4783,11 +4997,17 @@ function resolvePropertyIR(node, ir, ctx, nodeIR, isDynamic = false) {
4783
4997
  }
4784
4998
  resolvePropAsBabelExp(_nullishCoalesce(existing, () => ( node)), ctx);
4785
4999
  }
5000
+ function normalizeString(s) {
5001
+ if (s.startsWith("'") && s.endsWith("'")) {
5002
+ return s.slice(1, -1);
5003
+ }
5004
+ return s;
5005
+ }
4786
5006
 
4787
5007
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
4788
5008
  function resolveAttributeProp(node, ir, ctx, nodeIR) {
4789
5009
  const name = node.name;
4790
- const content = _nullishCoalesce(_optionalChain([node, 'access', _152 => _152.value, 'optionalAccess', _153 => _153.content]), () => ( "true"));
5010
+ const content = _nullishCoalesce(_optionalChain([node, 'access', _161 => _161.value, 'optionalAccess', _162 => _162.content]), () => ( "true"));
4791
5011
  if (name === "is") {
4792
5012
  resolveStaticIsProp(content, ir, ctx, nodeIR);
4793
5013
  return;
@@ -4811,10 +5031,10 @@ function resolveRouterLinkVSlotProp(node, nodeIR, ctx) {
4811
5031
  type: 2 /* SLOT */,
4812
5032
  name: "customRender",
4813
5033
  rawName: _nullishCoalesce(node.rawName, () => ( "v-slot")),
4814
- isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _154 => _154.isStatic]), () => ( true)),
5034
+ isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _163 => _163.isStatic]), () => ( true)),
4815
5035
  isScoped: true,
4816
5036
  callback: {
4817
- arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _155 => _155.content, 'optionalAccess', _156 => _156.trim, 'call', _157 => _157()]), () => ( "")),
5037
+ arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _164 => _164.content, 'optionalAccess', _165 => _165.trim, 'call', _166 => _166()]), () => ( "")),
4818
5038
  exp: []
4819
5039
  }
4820
5040
  };
@@ -4830,10 +5050,10 @@ function resolveVFor(node, _ir, _ctx, nodeIR) {
4830
5050
  };
4831
5051
  }
4832
5052
  function resolveForResult(forParseResult) {
4833
- const source = _optionalChain([forParseResult, 'access', _158 => _158.source, 'optionalAccess', _159 => _159.content]);
4834
- const value = _optionalChain([forParseResult, 'access', _160 => _160.value, 'optionalAccess', _161 => _161.content]);
4835
- const index = _optionalChain([forParseResult, 'access', _162 => _162.index, 'optionalAccess', _163 => _163.content]);
4836
- const key = _optionalChain([forParseResult, 'access', _164 => _164.key, 'optionalAccess', _165 => _165.content]);
5053
+ const source = _optionalChain([forParseResult, 'access', _167 => _167.source, 'optionalAccess', _168 => _168.content]);
5054
+ const value = _optionalChain([forParseResult, 'access', _169 => _169.value, 'optionalAccess', _170 => _170.content]);
5055
+ const index = _optionalChain([forParseResult, 'access', _171 => _171.index, 'optionalAccess', _172 => _172.content]);
5056
+ const key = _optionalChain([forParseResult, 'access', _173 => _173.key, 'optionalAccess', _174 => _174.content]);
4837
5057
  return {
4838
5058
  source,
4839
5059
  value,
@@ -4853,7 +5073,7 @@ function resolveVHtml(node, ir, ctx, nodeIR) {
4853
5073
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
4854
5074
  function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
4855
5075
  const name = node.name === "else-if" ? "elseIf" : node.name;
4856
- const value = _nullishCoalesce(_optionalChain([node, 'access', _166 => _166.exp, 'optionalAccess', _167 => _167.content]), () => ( "true"));
5076
+ const value = _nullishCoalesce(_optionalChain([node, 'access', _175 => _175.exp, 'optionalAccess', _176 => _176.content]), () => ( "true"));
4857
5077
  const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
4858
5078
  const isElseBranch = name === "else" || name === "elseIf";
4859
5079
  let hasError = false;
@@ -4892,7 +5112,7 @@ function resolveVIf(node, _ir, ctx, nodeIR, siblingNodesIR) {
4892
5112
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
4893
5113
  function resolveVMemo(node, _ir, ctx, nodeIR) {
4894
5114
  const exp = node.exp;
4895
- let value = _optionalChain([exp, 'optionalAccess', _168 => _168.content]);
5115
+ let value = _optionalChain([exp, 'optionalAccess', _177 => _177.content]);
4896
5116
  if (value !== void 0) {
4897
5117
  if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
4898
5118
  const { source, filename } = ctx;
@@ -4932,14 +5152,14 @@ function resolveVModel(node, _ir, ctx, elementNode, nodeIR) {
4932
5152
  const getterName = exp.content;
4933
5153
  const isComponent = elementNode.tagType === _compilercore.ElementTypes.COMPONENT;
4934
5154
  const inputType = resolveHtmlInput(elementNode, isComponent);
4935
- const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _169 => _169.content]), () => ( resolveModelPropName(inputType, isComponent)));
5155
+ const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _178 => _178.content]), () => ( resolveModelPropName(inputType, isComponent)));
4936
5156
  let valuePropIR;
4937
5157
  let eventPropIR;
4938
5158
  if (isComponent) {
4939
5159
  valuePropIR = createPropsIR("v-model", propName, getterName);
4940
5160
  const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
4941
5161
  const eventVueName = `update:${propName}`;
4942
- const isTS = _optionalChain([ctx, 'access', _170 => _170.scriptData, 'optionalAccess', _171 => _171.lang, 'optionalAccess', _172 => _172.startsWith, 'call', _173 => _173("ts")]);
5162
+ const isTS = _optionalChain([ctx, 'access', _179 => _179.scriptData, 'optionalAccess', _180 => _180.lang, 'optionalAccess', _181 => _181.startsWith, 'call', _182 => _182("ts")]);
4943
5163
  const valueArg = isTS ? "value: any" : "value";
4944
5164
  const processedValue = applyValueModifiers("value", modifiers);
4945
5165
  const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
@@ -4977,7 +5197,7 @@ function getRadioValue(elementNode) {
4977
5197
  const valueAttr = elementNode.props.find(
4978
5198
  (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
4979
5199
  );
4980
- if (!_optionalChain([valueAttr, 'optionalAccess', _174 => _174.value, 'optionalAccess', _175 => _175.content])) return '""';
5200
+ if (!_optionalChain([valueAttr, 'optionalAccess', _183 => _183.value, 'optionalAccess', _184 => _184.content])) return '""';
4981
5201
  const content = valueAttr.value.content;
4982
5202
  return /^['"]/.test(content) ? content : `"${content}"`;
4983
5203
  }
@@ -4987,7 +5207,7 @@ function resolveHtmlInput(node, isComponent) {
4987
5207
  const typeProp = node.props.find(
4988
5208
  (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
4989
5209
  );
4990
- return _optionalChain([typeProp, 'optionalAccess', _176 => _176.value, 'optionalAccess', _177 => _177.content, 'optionalAccess', _178 => _178.toLowerCase, 'call', _179 => _179()]);
5210
+ return _optionalChain([typeProp, 'optionalAccess', _185 => _185.value, 'optionalAccess', _186 => _186.content, 'optionalAccess', _187 => _187.toLowerCase, 'call', _188 => _188()]);
4991
5211
  }
4992
5212
  function applyValueModifiers(valueExp, modifiers) {
4993
5213
  let result = valueExp;
@@ -5007,7 +5227,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
5007
5227
  const exp = node.exp;
5008
5228
  const modifiers = node.modifiers.map((item) => item.content);
5009
5229
  const captureIndex = modifiers.findIndex((modifier) => modifier === "capture");
5010
- let eventName = `on${camelCase(capitalize(arg.content))}`;
5230
+ let eventName = normalizeVOnEventName(arg.content);
5011
5231
  let handler = resolveSpecialExpressions(exp.content.trim(), ctx);
5012
5232
  if (captureIndex > -1) {
5013
5233
  eventName = modifiers[captureIndex] ? `${eventName}Capture` : eventName;
@@ -5018,7 +5238,7 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
5018
5238
  originalVueEventName = `${arg.content}.${modifiers.join(".")}`;
5019
5239
  } else {
5020
5240
  const expr = stringToExpr(handler);
5021
- if (!t40.isFunctionExpression(expr) && !t40.isIdentifier(expr)) {
5241
+ if (!t40.isFunctionExpression(expr) && !t40.isArrowFunctionExpression(expr) && !t40.isIdentifier(expr)) {
5022
5242
  handler = `() => {${handler}}`;
5023
5243
  }
5024
5244
  }
@@ -5036,6 +5256,11 @@ function resolveVOn(node, _ir, ctx, nodeIR) {
5036
5256
  }
5037
5257
  nodeIR.props.push(eventIR);
5038
5258
  }
5259
+ function normalizeVOnEventName(rawEventName) {
5260
+ const segments = rawEventName.split(/[:-]/g).map((segment) => segment.trim()).filter(Boolean);
5261
+ const normalized = segments.map((segment) => capitalize(camelCase(segment))).join("");
5262
+ return `on${normalized}`;
5263
+ }
5039
5264
 
5040
5265
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
5041
5266
  function resolveVShow(node, _ir, ctx, nodeIR) {
@@ -5186,7 +5411,7 @@ function resolveVSlotProp(node, _ir, ctx) {
5186
5411
  const name = !arg || arg.content === "default" ? "children" : arg.content;
5187
5412
  const content = !isScoped ? [] : void 0;
5188
5413
  const callback = isScoped ? {
5189
- arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _180 => _180.content, 'optionalAccess', _181 => _181.trim, 'call', _182 => _182()]), () => ( "")),
5414
+ arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _189 => _189.content, 'optionalAccess', _190 => _190.trim, 'call', _191 => _191()]), () => ( "")),
5190
5415
  exp: []
5191
5416
  } : void 0;
5192
5417
  checkPropIsDynamicKey(ctx, node);
@@ -5194,7 +5419,7 @@ function resolveVSlotProp(node, _ir, ctx) {
5194
5419
  type: 2 /* SLOT */,
5195
5420
  name,
5196
5421
  rawName: _nullishCoalesce(node.rawName, () => ( "default")),
5197
- isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _183 => _183.isStatic]), () => ( true)),
5422
+ isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _192 => _192.isStatic]), () => ( true)),
5198
5423
  isScoped,
5199
5424
  content,
5200
5425
  callback
@@ -5228,7 +5453,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
5228
5453
  if (routerAdapter) {
5229
5454
  if (!ctx.route) ctx.route = true;
5230
5455
  nodeIR.isRoute = true;
5231
- recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _184 => _184.package]), routerAdapter.target);
5456
+ recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _193 => _193.package]), routerAdapter.target);
5232
5457
  }
5233
5458
  resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
5234
5459
  return nodeIR;
@@ -5364,7 +5589,7 @@ function resolveSlotProps(node, ctx) {
5364
5589
  for (const prop of node.props) {
5365
5590
  if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
5366
5591
  const attr = prop.name;
5367
- const value = _optionalChain([prop, 'access', _185 => _185.value, 'optionalAccess', _186 => _186.content, 'access', _187 => _187.trim, 'call', _188 => _188()]);
5592
+ const value = _optionalChain([prop, 'access', _194 => _194.value, 'optionalAccess', _195 => _195.content, 'access', _196 => _196.trim, 'call', _197 => _197()]);
5368
5593
  if (attr === "name" && value) {
5369
5594
  result.name = camelCase(value);
5370
5595
  } else {
@@ -5454,19 +5679,19 @@ function resolveTemplate2(root, ctx) {
5454
5679
  // src/core/transform/sfc/index.ts
5455
5680
  function transform(ast, ctx, options) {
5456
5681
  const { template, script, style } = ast;
5457
- const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _189 => _189.ast]), ctx);
5458
- const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _190 => _190.ast]), ctx);
5682
+ const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _198 => _198.ast]), ctx);
5683
+ const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _199 => _199.ast]), ctx);
5459
5684
  const result = {
5460
5685
  template: templateIR,
5461
5686
  script: scriptIR,
5462
- style: _optionalChain([style, 'optionalAccess', _191 => _191.source, 'optionalAccess', _192 => _192.content])
5687
+ style: _optionalChain([style, 'optionalAccess', _200 => _200.source, 'optionalAccess', _201 => _201.content])
5463
5688
  };
5464
- executePlugins(_optionalChain([options, 'optionalAccess', _193 => _193.plugins]), result, ctx);
5689
+ executePlugins(_optionalChain([options, 'optionalAccess', _202 => _202.plugins]), result, ctx);
5465
5690
  return result;
5466
5691
  }
5467
5692
 
5468
5693
  // package.json
5469
- var version = "1.4.0";
5694
+ var version = "1.5.1";
5470
5695
  var bin = {
5471
5696
  vureact: "./bin/vureact.js"
5472
5697
  };
@@ -5653,14 +5878,14 @@ var FileLockManager = class _FileLockManager {
5653
5878
  var fileLock = FileLockManager.getInstance();
5654
5879
 
5655
5880
  // src/compiler/shared/helper.ts
5656
- var Helper = (_class3 = class {
5881
+ var Helper = (_class5 = class {
5657
5882
 
5658
5883
 
5659
- __init5() {this.workspaceDir = ".vureact"}
5660
- __init6() {this.outDir = "react-app"}
5661
- constructor(opts) {;_class3.prototype.__init5.call(this);_class3.prototype.__init6.call(this);
5884
+ __init7() {this.workspaceDir = ".vureact"}
5885
+ __init8() {this.outDir = "react-app"}
5886
+ constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
5662
5887
  this.compilerOpts = opts;
5663
- if (_optionalChain([opts, 'access', _194 => _194.output, 'optionalAccess', _195 => _195.workspace])) {
5888
+ if (_optionalChain([opts, 'access', _203 => _203.output, 'optionalAccess', _204 => _204.workspace])) {
5664
5889
  this.workspaceDir = opts.output.workspace;
5665
5890
  }
5666
5891
  const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
@@ -5697,7 +5922,7 @@ var Helper = (_class3 = class {
5697
5922
  }
5698
5923
  getOutDirName() {
5699
5924
  const { output } = this.compilerOpts;
5700
- return _optionalChain([output, 'optionalAccess', _196 => _196.outDir]) || this.outDir;
5925
+ return _optionalChain([output, 'optionalAccess', _205 => _205.outDir]) || this.outDir;
5701
5926
  }
5702
5927
  getWorkspaceDir() {
5703
5928
  return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
@@ -5711,7 +5936,7 @@ var Helper = (_class3 = class {
5711
5936
  }
5712
5937
  getIgnoreAssets() {
5713
5938
  const { output } = this.compilerOpts;
5714
- if (_optionalChain([output, 'optionalAccess', _197 => _197.ignoreAssets])) {
5939
+ if (_optionalChain([output, 'optionalAccess', _206 => _206.ignoreAssets])) {
5715
5940
  return new Set(output.ignoreAssets.map(normalizePath));
5716
5941
  }
5717
5942
  return /* @__PURE__ */ new Set([
@@ -5794,12 +6019,12 @@ var Helper = (_class3 = class {
5794
6019
  */
5795
6020
  async formatCode({ code, fileInfo }) {
5796
6021
  const { format } = this.compilerOpts;
5797
- if (!_optionalChain([format, 'optionalAccess', _198 => _198.enabled])) return code;
5798
- if (_optionalChain([format, 'optionalAccess', _199 => _199.formatter]) === "builtin") {
6022
+ if (!_optionalChain([format, 'optionalAccess', _207 => _207.enabled])) return code;
6023
+ if (_optionalChain([format, 'optionalAccess', _208 => _208.formatter]) === "builtin") {
5799
6024
  return simpleFormat(code);
5800
6025
  }
5801
- const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _200 => _200.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _201 => _201.script])));
5802
- return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _202 => _202.prettierOptions]));
6026
+ const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _209 => _209.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _210 => _210.script])));
6027
+ return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _211 => _211.prettierOptions]));
5803
6028
  }
5804
6029
  /**
5805
6030
  * 通用的缓存校验工具函数
@@ -5833,7 +6058,7 @@ var Helper = (_class3 = class {
5833
6058
  * @param options.lock - 是否启用文件锁(默认false)
5834
6059
  */
5835
6060
  async writeFileWithDir(filePath, content, options) {
5836
- if (_optionalChain([options, 'optionalAccess', _203 => _203.lock])) {
6061
+ if (_optionalChain([options, 'optionalAccess', _212 => _212.lock])) {
5837
6062
  await fileLock.updateFile(filePath, async () => content, options);
5838
6063
  } else {
5839
6064
  await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
@@ -5958,7 +6183,7 @@ var Helper = (_class3 = class {
5958
6183
  * 获取需要排除编译的文件
5959
6184
  */
5960
6185
  getExcludes() {
5961
- if (!_optionalChain([this, 'access', _204 => _204.compilerOpts, 'access', _205 => _205.exclude, 'optionalAccess', _206 => _206.length])) {
6186
+ if (!_optionalChain([this, 'access', _213 => _213.compilerOpts, 'access', _214 => _214.exclude, 'optionalAccess', _215 => _215.length])) {
5962
6187
  return PathFilter.withDefaults();
5963
6188
  }
5964
6189
  return this.compilerOpts.exclude;
@@ -6025,7 +6250,7 @@ var Helper = (_class3 = class {
6025
6250
  }
6026
6251
  return normalizePath(relativePath2);
6027
6252
  }
6028
- }, _class3);
6253
+ }, _class5);
6029
6254
 
6030
6255
  // src/core/parse/style-only.ts
6031
6256
  function parseOnlyStyle(source, ctx, options) {
@@ -6056,7 +6281,7 @@ function parseOnlyStyle(source, ctx, options) {
6056
6281
  ast: void 0
6057
6282
  }
6058
6283
  };
6059
- executePlugins(_optionalChain([options, 'optionalAccess', _207 => _207.plugins]), result, ctx);
6284
+ executePlugins(_optionalChain([options, 'optionalAccess', _216 => _216.plugins]), result, ctx);
6060
6285
  return result;
6061
6286
  }
6062
6287
 
@@ -6067,8 +6292,8 @@ function parseOnlyStyle(source, ctx, options) {
6067
6292
  function createCompilationCtx() {
6068
6293
  return new CompilationContext();
6069
6294
  }
6070
- var CompilationContext = (_class4 = class {constructor() { _class4.prototype.__init7.call(this); }
6071
- __init7() {this.context = {}}
6295
+ var CompilationContext = (_class6 = class {constructor() { _class6.prototype.__init9.call(this); }
6296
+ __init9() {this.context = {}}
6072
6297
  get data() {
6073
6298
  return this.context;
6074
6299
  }
@@ -6121,7 +6346,7 @@ var CompilationContext = (_class4 = class {constructor() { _class4.prototype.__i
6121
6346
  }
6122
6347
  };
6123
6348
  }
6124
- }, _class4);
6349
+ }, _class6);
6125
6350
 
6126
6351
  // src/compiler/context/adapter.ts
6127
6352
  var CompilationAdapter = class _CompilationAdapter {
@@ -6168,12 +6393,12 @@ var CompilationAdapter = class _CompilationAdapter {
6168
6393
  };
6169
6394
 
6170
6395
  // src/compiler/shared/base-compiler.ts
6171
- var BaseCompiler = (_class5 = class extends Helper {
6172
- __init8() {this.version = exports.version = version}
6396
+ var BaseCompiler = (_class7 = class extends Helper {
6397
+ __init10() {this.version = exports.version = version}
6173
6398
 
6174
- __init9() {this.createContext = CompilationAdapter.createContext}
6399
+ __init11() {this.createContext = CompilationAdapter.createContext}
6175
6400
  constructor(options = {}) {
6176
- super(options);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);;
6401
+ super(options);_class7.prototype.__init10.call(this);_class7.prototype.__init11.call(this);;
6177
6402
  this.options = options;
6178
6403
  }
6179
6404
  /** 编译 Vue 源代码为 React 代码 */
@@ -6188,16 +6413,16 @@ var BaseCompiler = (_class5 = class extends Helper {
6188
6413
  });
6189
6414
  const genOptions = this.prepareGenerateOptions(filename);
6190
6415
  const resolveSFCAndScriptFile = () => {
6191
- const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _208 => _208.parser]) });
6192
- const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _209 => _209.transformer]) });
6416
+ const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _217 => _217.parser]) });
6417
+ const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _218 => _218.transformer]) });
6193
6418
  const gen = generate(ir, ctx.data, {
6194
6419
  ...genOptions,
6195
- plugins: _optionalChain([plugins, 'optionalAccess', _210 => _210.codegen])
6420
+ plugins: _optionalChain([plugins, 'optionalAccess', _219 => _219.codegen])
6196
6421
  });
6197
6422
  return this.resolveMainResult(ir, gen, ctx.data);
6198
6423
  };
6199
6424
  const resolveStyleFile = () => {
6200
- const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _211 => _211.parser]) });
6425
+ const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _220 => _220.parser]) });
6201
6426
  return this.resolveStyleResult(result, ctx.data);
6202
6427
  };
6203
6428
  try {
@@ -6214,18 +6439,10 @@ var BaseCompiler = (_class5 = class extends Helper {
6214
6439
  }
6215
6440
  prepareGenerateOptions(filename) {
6216
6441
  const userOptions = this.options.generate || {};
6217
- const mergedOptions = {
6218
- jsescOption: {
6219
- minimal: true,
6220
- quotes: "single"
6221
- },
6222
- minified: true,
6223
- ...userOptions
6224
- };
6225
- if (mergedOptions.sourceMaps && filename) {
6226
- mergedOptions.sourceFileName = mergedOptions.sourceFileName || filename;
6442
+ if (userOptions.sourceMaps && filename) {
6443
+ userOptions.sourceFileName = userOptions.sourceFileName || filename;
6227
6444
  }
6228
- return mergedOptions;
6445
+ return userOptions;
6229
6446
  }
6230
6447
  resolveMainResult(ir, gen, ctxData) {
6231
6448
  const { fileId, filename, scriptData, styleData, inputType } = ctxData;
@@ -6244,9 +6461,9 @@ var BaseCompiler = (_class5 = class extends Helper {
6244
6461
  lang
6245
6462
  },
6246
6463
  css: {
6247
- file: _optionalChain([styleData, 'optionalAccess', _212 => _212.filePath]),
6248
- hash: _optionalChain([styleData, 'optionalAccess', _213 => _213.scopeId]),
6249
- code: _optionalChain([ir, 'optionalAccess', _214 => _214.style])
6464
+ file: _optionalChain([styleData, 'optionalAccess', _221 => _221.filePath]),
6465
+ hash: _optionalChain([styleData, 'optionalAccess', _222 => _222.scopeId]),
6466
+ code: _optionalChain([ir, 'optionalAccess', _223 => _223.style])
6250
6467
  }
6251
6468
  },
6252
6469
  ...base
@@ -6272,7 +6489,7 @@ var BaseCompiler = (_class5 = class extends Helper {
6272
6489
  code: content
6273
6490
  };
6274
6491
  }
6275
- }, _class5);
6492
+ }, _class7);
6276
6493
 
6277
6494
  // src/utils/calc-elapsed-time.ts
6278
6495
  function calcElapsedTime(start) {
@@ -6295,14 +6512,14 @@ var _ora = require('ora'); var _ora2 = _interopRequireDefault(_ora);
6295
6512
  // src/compiler/shared/file-compiler/asset-manager.ts
6296
6513
 
6297
6514
 
6298
- var AssetManager = (_class6 = class {
6299
- constructor(fileCompiler, cleanupManager) {;_class6.prototype.__init10.call(this);_class6.prototype.__init11.call(this);
6515
+ var AssetManager = (_class8 = class {
6516
+ constructor(fileCompiler, cleanupManager) {;_class8.prototype.__init12.call(this);_class8.prototype.__init13.call(this);
6300
6517
  this.fileCompiler = fileCompiler;
6301
6518
  this.cleanupManager = cleanupManager;
6302
6519
  }
6303
6520
  // 需要经过管线编译处理的文件类型
6304
- __init10() {this.pipelineFiles = [".js", ".ts", ".less", ".scss", ".sass"]}
6305
- __init11() {this.skippedCount = 0}
6521
+ __init12() {this.pipelineFiles = [".js", ".ts", ".less", ".scss", ".sass"]}
6522
+ __init13() {this.skippedCount = 0}
6306
6523
  /**
6307
6524
  * 运行资源文件处理管线
6308
6525
  */
@@ -6316,7 +6533,7 @@ var AssetManager = (_class6 = class {
6316
6533
  const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
6317
6534
  const filename = _path2.default.basename(p).toLowerCase();
6318
6535
  const ext = _path2.default.extname(p).toLowerCase();
6319
- if (!_optionalChain([options, 'access', _215 => _215.output, 'optionalAccess', _216 => _216.ignoreAssets])) {
6536
+ if (!_optionalChain([options, 'access', _224 => _224.output, 'optionalAccess', _225 => _225.ignoreAssets])) {
6320
6537
  const shouldExclude = Array.from(exclusions).some((pattern) => {
6321
6538
  if (pattern.endsWith(".")) {
6322
6539
  return filename.startsWith(pattern);
@@ -6397,14 +6614,14 @@ var AssetManager = (_class6 = class {
6397
6614
  resetSkippedCount() {
6398
6615
  this.skippedCount = 0;
6399
6616
  }
6400
- }, _class6);
6617
+ }, _class8);
6401
6618
 
6402
6619
  // src/compiler/shared/file-compiler/cache-manager.ts
6403
- var CacheManager = (_class7 = class {
6404
- constructor(fileCompiler) {;_class7.prototype.__init12.call(this);
6620
+ var CacheManager = (_class9 = class {
6621
+ constructor(fileCompiler) {;_class9.prototype.__init14.call(this);
6405
6622
  this.fileCompiler = fileCompiler;
6406
6623
  }
6407
- __init12() {this.pendingUpdates = /* @__PURE__ */ new Map()}
6624
+ __init14() {this.pendingUpdates = /* @__PURE__ */ new Map()}
6408
6625
  /**
6409
6626
  * 批量更新缓存记录
6410
6627
  */
@@ -6413,12 +6630,12 @@ var CacheManager = (_class7 = class {
6413
6630
  const meta = { ...unit };
6414
6631
  delete meta.source;
6415
6632
  if (key === "sfc" /* SFC */) {
6416
- _optionalChainDelete([meta, 'access', _217 => _217.output, 'optionalAccess', _218 => _218.jsx, 'access', _219 => delete _219.code]);
6417
- _optionalChainDelete([meta, 'access', _220 => _220.output, 'optionalAccess', _221 => _221.css, 'access', _222 => delete _222.code]);
6633
+ _optionalChainDelete([meta, 'access', _226 => _226.output, 'optionalAccess', _227 => _227.jsx, 'access', _228 => delete _228.code]);
6634
+ _optionalChainDelete([meta, 'access', _229 => _229.output, 'optionalAccess', _230 => _230.css, 'access', _231 => delete _231.code]);
6418
6635
  } else if (key === "script" /* SCRIPT */) {
6419
- _optionalChainDelete([meta, 'access', _223 => _223.output, 'optionalAccess', _224 => _224.script, 'access', _225 => delete _225.code]);
6636
+ _optionalChainDelete([meta, 'access', _232 => _232.output, 'optionalAccess', _233 => _233.script, 'access', _234 => delete _234.code]);
6420
6637
  } else if (key === "style" /* STYLE */) {
6421
- _optionalChainDelete([meta, 'access', _226 => _226.output, 'optionalAccess', _227 => _227.style, 'access', _228 => delete _228.code]);
6638
+ _optionalChainDelete([meta, 'access', _235 => _235.output, 'optionalAccess', _236 => _236.style, 'access', _237 => delete _237.code]);
6422
6639
  }
6423
6640
  if (!this.pendingUpdates.has(key)) {
6424
6641
  this.pendingUpdates.set(key, []);
@@ -6452,7 +6669,7 @@ var CacheManager = (_class7 = class {
6452
6669
  cache.target.push(newData);
6453
6670
  }
6454
6671
  }
6455
- }, _class7);
6672
+ }, _class9);
6456
6673
 
6457
6674
  // src/compiler/shared/file-compiler/cleanup-manager.ts
6458
6675
 
@@ -6488,7 +6705,7 @@ var CleanupManager = class {
6488
6705
  meta = m;
6489
6706
  const { jsx, css } = meta.output;
6490
6707
  await this.fileCompiler.removeOutputFile(jsx.file);
6491
- if (_optionalChain([css, 'optionalAccess', _229 => _229.file])) {
6708
+ if (_optionalChain([css, 'optionalAccess', _238 => _238.file])) {
6492
6709
  await this.fileCompiler.removeOutputFile(css.file);
6493
6710
  }
6494
6711
  break;
@@ -6549,7 +6766,7 @@ var CompilationUnitProcessor = class {
6549
6766
  const isScriptFile = key === "script" /* SCRIPT */;
6550
6767
  const isStyleFile = key === "style" /* STYLE */;
6551
6768
  if (isSFC || isScriptFile) {
6552
- unit.hasRoute = _optionalChain([result, 'optionalAccess', _230 => _230.hasRoute]);
6769
+ unit.hasRoute = _optionalChain([result, 'optionalAccess', _239 => _239.hasRoute]);
6553
6770
  }
6554
6771
  const resolveFileInfo = () => {
6555
6772
  if (isSFC) {
@@ -6569,7 +6786,7 @@ var CompilationUnitProcessor = class {
6569
6786
  const { script } = result.fileInfo;
6570
6787
  unit.output = {
6571
6788
  script: {
6572
- file: _optionalChain([script, 'optionalAccess', _231 => _231.file]),
6789
+ file: _optionalChain([script, 'optionalAccess', _240 => _240.file]),
6573
6790
  code
6574
6791
  }
6575
6792
  };
@@ -6617,13 +6834,13 @@ var CompilationUnitProcessor = class {
6617
6834
 
6618
6835
 
6619
6836
 
6620
- var FileProcessor = (_class8 = class {
6621
- constructor(fileCompiler, compilationUnitProcessor, cacheManager) {;_class8.prototype.__init13.call(this);
6837
+ var FileProcessor = (_class10 = class {
6838
+ constructor(fileCompiler, compilationUnitProcessor, cacheManager) {;_class10.prototype.__init15.call(this);
6622
6839
  this.fileCompiler = fileCompiler;
6623
6840
  this.compilationUnitProcessor = compilationUnitProcessor;
6624
6841
  this.cacheManager = cacheManager;
6625
6842
  }
6626
- __init13() {this.skippedCount = 0}
6843
+ __init15() {this.skippedCount = 0}
6627
6844
  /**
6628
6845
  * Process a single Vue file (this method is called directly in CLI Watch mode)
6629
6846
  */
@@ -6646,7 +6863,7 @@ var FileProcessor = (_class8 = class {
6646
6863
  const absPath = this.fileCompiler.getAbsPath(filePath);
6647
6864
  const fileMeta = await this.fileCompiler.getFileMeta(absPath);
6648
6865
  const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
6649
- const record = _optionalChain([cache, 'optionalAccess', _232 => _232.target, 'access', _233 => _233.find, 'call', _234 => _234((c) => c.file === absPath)]);
6866
+ const record = _optionalChain([cache, 'optionalAccess', _241 => _241.target, 'access', _242 => _242.find, 'call', _243 => _243((c) => c.file === absPath)]);
6650
6867
  const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
6651
6868
  fileMeta,
6652
6869
  record,
@@ -6668,10 +6885,10 @@ var FileProcessor = (_class8 = class {
6668
6885
  hash: hash || this.fileCompiler.genHash(source)
6669
6886
  };
6670
6887
  const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
6671
- if (_optionalChain([processed, 'optionalAccess', _235 => _235.output])) {
6888
+ if (_optionalChain([processed, 'optionalAccess', _244 => _244.output])) {
6672
6889
  await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
6673
6890
  if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
6674
- if (_optionalChain([processed, 'optionalAccess', _236 => _236.hasRoute])) {
6891
+ if (_optionalChain([processed, 'optionalAccess', _245 => _245.hasRoute])) {
6675
6892
  await this.addRouterToPackageJson();
6676
6893
  await this.updateEntryWithRouterProvider();
6677
6894
  }
@@ -6685,13 +6902,13 @@ var FileProcessor = (_class8 = class {
6685
6902
  */
6686
6903
  async addRouterToPackageJson() {
6687
6904
  const { output } = this.fileCompiler.options;
6688
- if (_optionalChain([output, 'optionalAccess', _237 => _237.bootstrapVite]) === false) {
6905
+ if (_optionalChain([output, 'optionalAccess', _246 => _246.bootstrapVite]) === false) {
6689
6906
  return;
6690
6907
  }
6691
6908
  const { router } = RUNTIME_PACKAGES;
6692
6909
  const filePath = this.fileCompiler.getOutputPkgPath();
6693
6910
  const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
6694
- if (_optionalChain([packageJson, 'optionalAccess', _238 => _238.dependencies, 'optionalAccess', _239 => _239[router.name]])) {
6911
+ if (_optionalChain([packageJson, 'optionalAccess', _247 => _247.dependencies, 'optionalAccess', _248 => _248[router.name]])) {
6695
6912
  return;
6696
6913
  }
6697
6914
  if (!packageJson.dependencies) {
@@ -6710,7 +6927,7 @@ var FileProcessor = (_class8 = class {
6710
6927
  const { exclude, output, router } = this.fileCompiler.options;
6711
6928
  const inputPath = this.fileCompiler.getInputPath();
6712
6929
  const outputPath = this.fileCompiler.getOuputPath(true);
6713
- if (_optionalChain([output, 'optionalAccess', _240 => _240.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _241 => _241.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _242 => _242.configFile])) {
6930
+ if (_optionalChain([output, 'optionalAccess', _249 => _249.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _250 => _250.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _251 => _251.configFile])) {
6714
6931
  return;
6715
6932
  }
6716
6933
  const getMainFile = async (filename) => {
@@ -6731,7 +6948,7 @@ var FileProcessor = (_class8 = class {
6731
6948
  const prepareRouterEntry = () => {
6732
6949
  const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
6733
6950
  let content = fileData.content;
6734
- if (_optionalChain([exclude, 'optionalAccess', _243 => _243.includes, 'call', _244 => _244(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _245 => _245.includes, 'call', _246 => _246(importPath)])) {
6951
+ if (_optionalChain([exclude, 'optionalAccess', _252 => _252.includes, 'call', _253 => _253(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _254 => _254.includes, 'call', _255 => _255(importPath)])) {
6735
6952
  return content;
6736
6953
  }
6737
6954
  const routerModule = "RouterInstance";
@@ -6770,17 +6987,17 @@ ${routerImport}`);
6770
6987
  resetSkippedCount() {
6771
6988
  this.skippedCount = 0;
6772
6989
  }
6773
- }, _class8);
6990
+ }, _class10);
6774
6991
 
6775
6992
  // src/compiler/shared/file-compiler/pipeline-manager.ts
6776
6993
 
6777
- var PipelineManager = (_class9 = class {
6778
- constructor(fileCompiler, fileProcessor) {;_class9.prototype.__init14.call(this);
6994
+ var PipelineManager = (_class11 = class {
6995
+ constructor(fileCompiler, fileProcessor) {;_class11.prototype.__init16.call(this);
6779
6996
  this.fileCompiler = fileCompiler;
6780
6997
  this.fileProcessor = fileProcessor;
6781
6998
  this.cleanupManager = new CleanupManager(fileCompiler);
6782
6999
  }
6783
- __init14() {this.skippedCount = 0}
7000
+ __init16() {this.skippedCount = 0}
6784
7001
 
6785
7002
  /**
6786
7003
  * 运行 SFC 编译管线
@@ -6842,20 +7059,20 @@ var PipelineManager = (_class9 = class {
6842
7059
  resetSkippedCount() {
6843
7060
  this.skippedCount = 0;
6844
7061
  }
6845
- }, _class9);
7062
+ }, _class11);
6846
7063
 
6847
7064
  // src/compiler/shared/file-compiler/vite-bootstrapper.ts
6848
7065
  var _child_process = require('child_process');
6849
7066
 
6850
7067
 
6851
7068
 
6852
- var ViteBootstrapper = (_class10 = class {
6853
- constructor(fileCompiler, options) {;_class10.prototype.__init15.call(this);_class10.prototype.__init16.call(this);
7069
+ var ViteBootstrapper = (_class12 = class {
7070
+ constructor(fileCompiler, options) {;_class12.prototype.__init17.call(this);_class12.prototype.__init18.call(this);
6854
7071
  this.fileCompiler = fileCompiler;
6855
7072
  this.options = options;
6856
7073
  }
6857
- __init15() {this.spinner = _ora2.default.call(void 0, )}
6858
- __init16() {this.defaultConfig = {
7074
+ __init17() {this.spinner = _ora2.default.call(void 0, )}
7075
+ __init18() {this.defaultConfig = {
6859
7076
  template: "react-ts",
6860
7077
  viteVersion: "@latest"
6861
7078
  }}
@@ -6874,31 +7091,31 @@ var ViteBootstrapper = (_class10 = class {
6874
7091
  * 利用 Vite 官方脚手架创建标准 React 环境
6875
7092
  */
6876
7093
  async bootstrapIfNeeded() {
6877
- const { bootstrapVite } = this.options.output || {};
7094
+ const { output } = this.options;
6878
7095
  const workspaceDir = this.fileCompiler.getWorkspaceDir();
6879
7096
  await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
6880
- if (bootstrapVite === false) {
7097
+ if (_optionalChain([output, 'optionalAccess', _256 => _256.bootstrapVite]) === false) {
6881
7098
  return false;
6882
7099
  }
6883
7100
  if (this.isSingleFile()) {
6884
7101
  console.info("Skipping Vite initialization for single file compilation");
6885
- return false;
7102
+ return;
6886
7103
  }
6887
7104
  const outputPkgPath = this.fileCompiler.getOutputPkgPath();
6888
7105
  if (_fs2.default.existsSync(outputPkgPath)) {
6889
- return false;
7106
+ return;
6890
7107
  }
6891
- this.spinner.start("Bootstrapping Vite React environment...");
6892
7108
  try {
7109
+ this.spinner.start("Bootstrapping Vite React environment...");
6893
7110
  await this.resolveViteCreateApp();
6894
7111
  } catch (err) {
6895
- this.spinner.stop();
6896
7112
  console.error(
6897
7113
  _kleur2.default.red("\u2716"),
6898
- "Failed to bootstrap Vite environment. Please check npm/network.",
7114
+ "Failed to bootstrap Vite environment. Please check npm/network.\n",
6899
7115
  err
6900
7116
  );
6901
- return false;
7117
+ this.spinner.stop();
7118
+ return;
6902
7119
  }
6903
7120
  const removeVuePackages = (deps) => {
6904
7121
  for (const name in deps) {
@@ -6920,15 +7137,15 @@ var ViteBootstrapper = (_class10 = class {
6920
7137
  }
6921
7138
  return deps;
6922
7139
  };
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);
7140
+ const sourcePkgPath = this.fileCompiler.getRootPkgPath();
7141
+ const sourcePkg = await this.fileCompiler.resolvePackageFile(sourcePkgPath);
7142
+ let newPkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
7143
+ const newDeps = resolveDeps(sourcePkg.dependencies, newPkg.dependencies);
7144
+ const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
7145
+ newPkg.dependencies = newDeps;
7146
+ newPkg.devDependencies = newDevDeps;
7147
+ newPkg = _optionalChain([output, 'optionalAccess', _257 => _257.packageJson, 'optionalCall', _258 => _258(newPkg)]) || newPkg;
7148
+ await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
6932
7149
  this.spinner.succeed("Standard Vite React environment initialized");
6933
7150
  return true;
6934
7151
  }
@@ -6938,12 +7155,12 @@ var ViteBootstrapper = (_class10 = class {
6938
7155
  async resolveViteCreateApp() {
6939
7156
  const { output } = this.options;
6940
7157
  const { viteVersion, template: tmpl } = this.defaultConfig;
6941
- const bootstrapVite = _optionalChain([output, 'optionalAccess', _247 => _247.bootstrapVite]);
7158
+ const bootstrapVite = _optionalChain([output, 'optionalAccess', _259 => _259.bootstrapVite]);
6942
7159
  const outDirName = this.fileCompiler.getOutDirName();
6943
7160
  const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
6944
- const viteVer = _optionalChain([configObject, 'optionalAccess', _248 => _248.vite]) || viteVersion;
6945
- const reactVer = _optionalChain([configObject, 'optionalAccess', _249 => _249.react]);
6946
- const template = _optionalChain([configObject, 'optionalAccess', _250 => _250.template]) || tmpl;
7161
+ const viteVer = _optionalChain([configObject, 'optionalAccess', _260 => _260.vite]) || viteVersion;
7162
+ const reactVer = _optionalChain([configObject, 'optionalAccess', _261 => _261.react]);
7163
+ const template = _optionalChain([configObject, 'optionalAccess', _262 => _262.template]) || tmpl;
6947
7164
  const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
6948
7165
  _child_process.execSync.call(void 0, cmd, {
6949
7166
  cwd: this.fileCompiler.getWorkspaceDir(),
@@ -6960,17 +7177,17 @@ var ViteBootstrapper = (_class10 = class {
6960
7177
  */
6961
7178
  async resolveReactVersion(ver) {
6962
7179
  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
- });
6972
- }
6973
- }, _class10);
7180
+ const curPkg = await this.fileCompiler.resolvePackageFile(outputPkgPath);
7181
+ const mainVer = Number(ver.split(".")[0]);
7182
+ const typeVer = !isNaN(mainVer) ? `^${mainVer.toString().replace(/@|\^|~|>=|>|/, "")}.0.0` : "^19.0.0";
7183
+ curPkg.dependencies.react = ver;
7184
+ curPkg.dependencies["react-dom"] = ver;
7185
+ curPkg.devDependencies["@types/react"] = typeVer;
7186
+ curPkg.devDependencies["@types/react-dom"] = typeVer;
7187
+ await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(curPkg, null, 2));
7188
+ return curPkg;
7189
+ }
7190
+ }, _class12);
6974
7191
 
6975
7192
  // src/compiler/shared/file-compiler/setup-manager.ts
6976
7193
  var SetupManager = class {
@@ -7024,11 +7241,11 @@ var SetupManager = class {
7024
7241
  };
7025
7242
 
7026
7243
  // src/compiler/shared/file-compiler/index.ts
7027
- var FileCompiler = (_class11 = class extends BaseCompiler {
7244
+ var FileCompiler = (_class13 = class extends BaseCompiler {
7028
7245
 
7029
- __init17() {this.spinner = _ora2.default.call(void 0, )}
7246
+ __init19() {this.spinner = _ora2.default.call(void 0, )}
7030
7247
  constructor(options = {}) {
7031
- super(options);_class11.prototype.__init17.call(this);;
7248
+ super(options);_class13.prototype.__init19.call(this);;
7032
7249
  new SetupManager(() => this);
7033
7250
  }
7034
7251
  /** 执行完整的编译流程 */
@@ -7047,7 +7264,7 @@ var FileCompiler = (_class11 = class extends BaseCompiler {
7047
7264
  const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
7048
7265
  const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
7049
7266
  const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
7050
- await _optionalChain([this, 'access', _251 => _251.options, 'access', _252 => _252.onSuccess, 'optionalCall', _253 => _253()]);
7267
+ await _optionalChain([this, 'access', _263 => _263.options, 'access', _264 => _264.onSuccess, 'optionalCall', _265 => _265()]);
7051
7268
  const endTime = calcElapsedTime(startTime);
7052
7269
  this.printCoreLogs();
7053
7270
  this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
@@ -7056,7 +7273,9 @@ var FileCompiler = (_class11 = class extends BaseCompiler {
7056
7273
  await rmWorkspace();
7057
7274
  console.error(_kleur2.default.red("\u2716"), `Build failed in ${endTime}`);
7058
7275
  console.error(error);
7276
+ process.exit(-1);
7059
7277
  } finally {
7278
+ this.spinner.stop();
7060
7279
  this.resetSkippedCount();
7061
7280
  }
7062
7281
  }
@@ -7155,7 +7374,7 @@ var FileCompiler = (_class11 = class extends BaseCompiler {
7155
7374
  this.manager.pipelineManager.resetSkippedCount();
7156
7375
  this.manager.assetManager.resetSkippedCount();
7157
7376
  }
7158
- }, _class11);
7377
+ }, _class13);
7159
7378
 
7160
7379
  // src/compiler/shared/define-config.ts
7161
7380
  function defineConfig(config) {