@vureact/compiler-core 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } 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.6.1
2
+ * @vureact/compiler-core v1.7.0
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 t16 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t40 = _interopRequireWildcard(_types); var t41 = _interopRequireWildcard(_types); var t42 = _interopRequireWildcard(_types); var t43 = _interopRequireWildcard(_types); var t44 = _interopRequireWildcard(_types); var t46 = _interopRequireWildcard(_types); var t45 = _interopRequireWildcard(_types); var t47 = _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 t16 = _interopRequireWildcard(_types); var t15 = _interopRequireWildcard(_types); var t18 = _interopRequireWildcard(_types); var t17 = _interopRequireWildcard(_types); var t19 = _interopRequireWildcard(_types); var t20 = _interopRequireWildcard(_types); var t21 = _interopRequireWildcard(_types); var t22 = _interopRequireWildcard(_types); var t23 = _interopRequireWildcard(_types); var t24 = _interopRequireWildcard(_types); var t25 = _interopRequireWildcard(_types); var t27 = _interopRequireWildcard(_types); var t26 = _interopRequireWildcard(_types); var t28 = _interopRequireWildcard(_types); var t36 = _interopRequireWildcard(_types); var t30 = _interopRequireWildcard(_types); var t29 = _interopRequireWildcard(_types); var t31 = _interopRequireWildcard(_types); var t34 = _interopRequireWildcard(_types); var t32 = _interopRequireWildcard(_types); var t33 = _interopRequireWildcard(_types); var t35 = _interopRequireWildcard(_types); var t37 = _interopRequireWildcard(_types); var t43 = _interopRequireWildcard(_types); var t42 = _interopRequireWildcard(_types); var t38 = _interopRequireWildcard(_types); var t39 = _interopRequireWildcard(_types); var t40 = _interopRequireWildcard(_types); var t41 = _interopRequireWildcard(_types); var t44 = _interopRequireWildcard(_types); var t45 = _interopRequireWildcard(_types); var t46 = _interopRequireWildcard(_types); var t47 = _interopRequireWildcard(_types); var t48 = _interopRequireWildcard(_types); var t50 = _interopRequireWildcard(_types); var t49 = _interopRequireWildcard(_types); var t51 = _interopRequireWildcard(_types);
28
28
 
29
29
  // src/consts/other.ts
30
30
  var PACKAGE_NAME = {
@@ -39,7 +39,7 @@ var RUNTIME_PACKAGES = {
39
39
  },
40
40
  runtime: {
41
41
  name: PACKAGE_NAME.runtime,
42
- version: "^1.0.1"
42
+ version: "^1.1.0"
43
43
  }
44
44
  };
45
45
  var STYLE_MODULE_NAME = "$style";
@@ -653,7 +653,7 @@ function resolveStringExpr(input, ctx, toStrLiteral = false) {
653
653
  const newContent = resolveSpecialExpression(input, ctx);
654
654
  try {
655
655
  return stringToExpr(newContent, scriptData.lang, filename);
656
- } catch (e) {
656
+ } catch (e2) {
657
657
  return t5.identifier(newContent);
658
658
  }
659
659
  }
@@ -809,7 +809,7 @@ function normalizePath(filePath) {
809
809
  if (fp.startsWith("file:")) {
810
810
  fp = _url.fileURLToPath.call(void 0, fp);
811
811
  }
812
- } catch (e2) {
812
+ } catch (e3) {
813
813
  }
814
814
  fp = fp.replace(/\\/g, "/").replace(/\/\/+/, "/");
815
815
  return fp;
@@ -1024,7 +1024,7 @@ function buildSlotCallbackParams(nodeIR, ctx) {
1024
1024
  return [];
1025
1025
  }
1026
1026
  return expression.params;
1027
- } catch (e3) {
1027
+ } catch (e4) {
1028
1028
  logger.warn(`Failed to parse slot params "${rawArg}". Falling back to no-arg slot function.`, {
1029
1029
  file: ctx.filename
1030
1030
  });
@@ -1058,7 +1058,7 @@ function buildStandardProp(nodeIR) {
1058
1058
  babelExp: { ast: keyAST },
1059
1059
  value: {
1060
1060
  content,
1061
- isStringLiteral: isStringLiteral13,
1061
+ isStringLiteral: isStringLiteral14,
1062
1062
  babelExp: { ast: valueAST }
1063
1063
  }
1064
1064
  } = nodeIR;
@@ -1067,7 +1067,7 @@ function buildStandardProp(nodeIR) {
1067
1067
  }
1068
1068
  let value;
1069
1069
  if (content !== "true") {
1070
- value = isStringLiteral13 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
1070
+ value = isStringLiteral14 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
1071
1071
  }
1072
1072
  return t9.jsxAttribute(keyAST, value);
1073
1073
  }
@@ -1159,7 +1159,7 @@ function buildCtxProviderNode(nodeIR, ctx, children) {
1159
1159
  if (!raw) return t11.stringLiteral("");
1160
1160
  try {
1161
1161
  return stringToExpr(raw, ctx.scriptData.lang, ctx.filename);
1162
- } catch (e4) {
1162
+ } catch (e5) {
1163
1163
  return t11.stringLiteral(raw);
1164
1164
  }
1165
1165
  };
@@ -2408,33 +2408,270 @@ function resolveContext(scriptSetup, ctx) {
2408
2408
  scriptSetup.content = content;
2409
2409
  }
2410
2410
 
2411
- // src/plugins/postcss.ts
2411
+ // src/plugins/postcss/index.ts
2412
2412
  var _postcss = require('postcss'); var _postcss2 = _interopRequireDefault(_postcss);
2413
+
2414
+ // src/plugins/postcss/deep.ts
2415
+ var _postcssselectorparser = require('postcss-selector-parser'); var _postcssselectorparser2 = _interopRequireDefault(_postcssselectorparser);
2416
+
2417
+ // src/plugins/postcss/standard.ts
2418
+
2419
+
2420
+ // src/plugins/postcss/utils.ts
2421
+ function findFirstPseudoIndex(nodes, start, end) {
2422
+ for (let i = start; i <= end; i++) {
2423
+ if (_optionalChain([nodes, 'access', _72 => _72[i], 'optionalAccess', _73 => _73.type]) === "pseudo") {
2424
+ return i;
2425
+ }
2426
+ }
2427
+ return end + 1;
2428
+ }
2429
+ function hasScopeAttribute(nodes, start, end, scopeId) {
2430
+ if (start > end) {
2431
+ return false;
2432
+ }
2433
+ for (let i = start; i <= end; i++) {
2434
+ const node = nodes[i];
2435
+ if (_optionalChain([node, 'optionalAccess', _74 => _74.type]) === "attribute" && node.attribute === scopeId) {
2436
+ return true;
2437
+ }
2438
+ }
2439
+ return false;
2440
+ }
2441
+ function hasNestingSelector(nodes, start, end) {
2442
+ if (start > end) {
2443
+ return false;
2444
+ }
2445
+ for (let i = start; i <= end; i++) {
2446
+ if (_optionalChain([nodes, 'access', _75 => _75[i], 'optionalAccess', _76 => _76.type]) === "nesting") {
2447
+ return true;
2448
+ }
2449
+ }
2450
+ return false;
2451
+ }
2452
+ function findScopeTargetIndex(nodes, start, end) {
2453
+ if (start > end) {
2454
+ return -1;
2455
+ }
2456
+ let candidate = -1;
2457
+ let nestingFallback = -1;
2458
+ for (let i = start; i <= end; i++) {
2459
+ const node = nodes[i];
2460
+ if (_optionalChain([node, 'optionalAccess', _77 => _77.type]) === "nesting") {
2461
+ nestingFallback = i;
2462
+ continue;
2463
+ }
2464
+ if (_optionalChain([node, 'optionalAccess', _78 => _78.type]) === "tag" || _optionalChain([node, 'optionalAccess', _79 => _79.type]) === "class" || _optionalChain([node, 'optionalAccess', _80 => _80.type]) === "id") {
2465
+ candidate = i;
2466
+ }
2467
+ }
2468
+ return candidate === -1 ? nestingFallback : candidate;
2469
+ }
2470
+ function isRuleIgnored(rule) {
2471
+ return rule.parent != null && rule.parent.type === "atrule" && _optionalChain([rule, 'access', _81 => _81.parent, 'optionalAccess', _82 => _82.name]) === "keyframes";
2472
+ }
2473
+ function isNestedInRule(rule) {
2474
+ let current = rule.parent;
2475
+ while (current) {
2476
+ if (current.type === "rule") {
2477
+ return true;
2478
+ }
2479
+ current = current.parent;
2480
+ }
2481
+ return false;
2482
+ }
2483
+
2484
+ // src/plugins/postcss/standard.ts
2485
+ function resolveStandard(s, scopeId) {
2486
+ try {
2487
+ return _postcssselectorparser2.default.call(void 0, (selectors) => {
2488
+ selectors.each((selector) => {
2489
+ const compoundEnd = selector.nodes.length - 1;
2490
+ if (compoundEnd < 0) {
2491
+ return;
2492
+ }
2493
+ let compoundStart = 0;
2494
+ for (let i = compoundEnd; i >= 0; i--) {
2495
+ if (_optionalChain([selector, 'access', _83 => _83.nodes, 'access', _84 => _84[i], 'optionalAccess', _85 => _85.type]) === "combinator") {
2496
+ compoundStart = i + 1;
2497
+ break;
2498
+ }
2499
+ }
2500
+ const firstPseudoIndex = findFirstPseudoIndex(selector.nodes, compoundStart, compoundEnd);
2501
+ if (hasNestingSelector(selector.nodes, compoundStart, firstPseudoIndex - 1)) {
2502
+ return;
2503
+ }
2504
+ if (hasScopeAttribute(selector.nodes, compoundStart, firstPseudoIndex - 1, scopeId)) {
2505
+ return;
2506
+ }
2507
+ const insertTargetIndex = findScopeTargetIndex(
2508
+ selector.nodes,
2509
+ compoundStart,
2510
+ firstPseudoIndex - 1
2511
+ );
2512
+ if (insertTargetIndex === -1) {
2513
+ return;
2514
+ }
2515
+ selector.insertAfter(
2516
+ selector.nodes[insertTargetIndex],
2517
+ _postcssselectorparser2.default.attribute({
2518
+ attribute: scopeId,
2519
+ raws: {},
2520
+ value: void 0
2521
+ // 不加 = 值,等同于 [data-css-xxx]
2522
+ })
2523
+ );
2524
+ });
2525
+ }).processSync(s);
2526
+ } catch (e) {
2527
+ console.warn(e);
2528
+ return `${s}[${scopeId}]`;
2529
+ }
2530
+ }
2531
+
2532
+ // src/plugins/postcss/deep.ts
2533
+ function resolveDeep(s, scopeId, nestedInRule) {
2534
+ try {
2535
+ const root = _postcssselectorparser2.default.call(void 0, ).astSync(s);
2536
+ const resolvedSelectors = [];
2537
+ root.nodes.forEach((selector) => {
2538
+ const resolved = resolveSingleSelectorWithDeep(selector, scopeId, nestedInRule);
2539
+ resolvedSelectors.push(...resolved);
2540
+ });
2541
+ return resolvedSelectors.join(", ");
2542
+ } catch (e) {
2543
+ console.warn(e);
2544
+ return s.replace(/:deep\((.*)\)/g, "$1");
2545
+ }
2546
+ }
2547
+ function resolveSingleSelectorWithDeep(selector, scopeId, nestedInRule) {
2548
+ const deepIndex = findTopLevelDeepIndex(selector.nodes);
2549
+ if (deepIndex === -1) {
2550
+ return [resolveStandard(selector.toString(), scopeId)];
2551
+ }
2552
+ const deepNode = selector.nodes[deepIndex];
2553
+ if (_optionalChain([deepNode, 'optionalAccess', _86 => _86.type]) !== "pseudo") {
2554
+ return [resolveStandard(selector.toString(), scopeId)];
2555
+ }
2556
+ const leftRaw = selector.nodes.slice(0, deepIndex).map((node) => node.toString()).join("");
2557
+ const rightRaw = selector.nodes.slice(deepIndex + 1).map((node) => node.toString()).join("");
2558
+ const leftScoped = scopeDeepLeftSide(leftRaw, scopeId, nestedInRule);
2559
+ const deepInnerSelectors = _optionalChain([deepNode, 'access', _87 => _87.nodes, 'optionalAccess', _88 => _88.length]) ? deepNode.nodes : [];
2560
+ if (!deepInnerSelectors.length) {
2561
+ return [leftScoped + rightRaw];
2562
+ }
2563
+ const results = [];
2564
+ for (const innerSelector of deepInnerSelectors) {
2565
+ const combined = joinDeepParts(leftScoped, innerSelector.toString().trim(), rightRaw);
2566
+ if (combined.includes(":deep(")) {
2567
+ results.push(resolveDeep(combined, scopeId, nestedInRule));
2568
+ continue;
2569
+ }
2570
+ results.push(combined);
2571
+ }
2572
+ return results;
2573
+ }
2574
+ function findTopLevelDeepIndex(nodes) {
2575
+ for (let i = 0; i < nodes.length; i++) {
2576
+ const node = nodes[i];
2577
+ if (_optionalChain([node, 'optionalAccess', _89 => _89.type]) === "pseudo" && (node.value === ":deep" || node.value === "::v-deep")) {
2578
+ return i;
2579
+ }
2580
+ }
2581
+ return -1;
2582
+ }
2583
+ function scopeDeepLeftSide(leftRaw, scopeId, nestedInRule) {
2584
+ if (!leftRaw.trim()) {
2585
+ return nestedInRule ? "&" : `[${scopeId}]`;
2586
+ }
2587
+ try {
2588
+ const root = _postcssselectorparser2.default.call(void 0, ).astSync(leftRaw);
2589
+ root.each((selector) => {
2590
+ injectScopeToRightMostCompound(selector, scopeId);
2591
+ });
2592
+ return root.toString();
2593
+ } catch (e) {
2594
+ console.warn(e);
2595
+ return resolveStandard(leftRaw, scopeId);
2596
+ }
2597
+ }
2598
+ function injectScopeToRightMostCompound(selector, scopeId) {
2599
+ const nodes = selector.nodes;
2600
+ if (!nodes.length) {
2601
+ return;
2602
+ }
2603
+ let compoundEnd = nodes.length - 1;
2604
+ while (compoundEnd >= 0 && _optionalChain([nodes, 'access', _90 => _90[compoundEnd], 'optionalAccess', _91 => _91.type]) === "combinator") {
2605
+ compoundEnd--;
2606
+ }
2607
+ if (compoundEnd < 0) {
2608
+ return;
2609
+ }
2610
+ let compoundStart = 0;
2611
+ for (let i = compoundEnd; i >= 0; i--) {
2612
+ if (_optionalChain([nodes, 'access', _92 => _92[i], 'optionalAccess', _93 => _93.type]) === "combinator") {
2613
+ compoundStart = i + 1;
2614
+ break;
2615
+ }
2616
+ }
2617
+ const firstPseudoIndex = findFirstPseudoIndex(nodes, compoundStart, compoundEnd);
2618
+ if (hasScopeAttribute(nodes, compoundStart, firstPseudoIndex - 1, scopeId)) {
2619
+ return;
2620
+ }
2621
+ const insertTargetIndex = findScopeTargetIndex(nodes, compoundStart, firstPseudoIndex - 1);
2622
+ if (insertTargetIndex === -1) {
2623
+ return;
2624
+ }
2625
+ const insertTarget = nodes[insertTargetIndex];
2626
+ insertTarget.spaces = {
2627
+ ...insertTarget.spaces,
2628
+ after: ""
2629
+ };
2630
+ selector.insertAfter(
2631
+ insertTarget,
2632
+ _postcssselectorparser2.default.attribute({
2633
+ attribute: scopeId,
2634
+ raws: {},
2635
+ value: void 0
2636
+ })
2637
+ );
2638
+ }
2639
+ function joinDeepParts(leftScoped, innerRaw, rightRaw) {
2640
+ if (!leftScoped) {
2641
+ return `${innerRaw}${rightRaw}`;
2642
+ }
2643
+ const needsGap = !/\s$/.test(leftScoped);
2644
+ const gap = needsGap ? " " : "";
2645
+ return `${leftScoped}${gap}${innerRaw}${rightRaw}`;
2646
+ }
2647
+
2648
+ // src/plugins/postcss/selector.ts
2649
+ function resolveSelector(s, scopeId, options) {
2650
+ if (s.includes(":global(")) {
2651
+ return s.replace(/:global\(([^)]+)\)/g, (_, inner) => inner);
2652
+ }
2653
+ if (s.includes(":deep(")) {
2654
+ return resolveDeep(s, scopeId, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _94 => _94.nestedInRule]), () => ( false)));
2655
+ }
2656
+ if (s.includes(":slotted(")) {
2657
+ return s.replace(/:slotted\((.*)\)/, "$1");
2658
+ }
2659
+ return resolveStandard(s, scopeId);
2660
+ }
2661
+
2662
+ // src/plugins/postcss/index.ts
2413
2663
  function processScopedWithPostCss(input, hash) {
2414
2664
  const scopeId = `data-css-${hash}`;
2415
2665
  const result = _postcss2.default.call(void 0, [
2416
2666
  {
2417
- postcssPlugin: "postcss-scoped-simple",
2667
+ postcssPlugin: "postcss-scoped-vureact",
2418
2668
  Rule(rule) {
2419
- if (rule.parent && rule.parent.type === "atrule" && rule.parent.name === "keyframes") {
2669
+ if (isRuleIgnored(rule)) {
2420
2670
  return;
2421
2671
  }
2422
- rule.selectors = rule.selectors.map((selector) => {
2423
- if (selector.includes(":global(")) {
2424
- return selector.replace(/:global\((.*)\)/, "$1");
2425
- }
2426
- if (selector.includes(":deep(")) {
2427
- return selector.replace(/:deep\((.*)\)/, "$1");
2428
- }
2429
- const pseudoElementRegex = /(::[a-zA-Z-]+)$/;
2430
- const match = selector.match(pseudoElementRegex);
2431
- if (match) {
2432
- const base = selector.replace(pseudoElementRegex, "");
2433
- const pseudo = match[1];
2434
- return `${base}[${scopeId}]${pseudo}`;
2435
- }
2436
- return `${selector}[${scopeId}]`;
2437
- });
2672
+ rule.selectors = rule.selectors.map(
2673
+ (selector) => resolveSelector(selector, scopeId, { nestedInRule: isNestedInRule(rule) })
2674
+ );
2438
2675
  }
2439
2676
  }
2440
2677
  ]).process(input);
@@ -2568,7 +2805,7 @@ function resolveStyles(descriptor, ctx, result) {
2568
2805
  var _compilercore = require('@vue/compiler-core');
2569
2806
  function resolveTemplate(descriptor, _, result) {
2570
2807
  const block = descriptor.template;
2571
- if (!_optionalChain([block, 'optionalAccess', _72 => _72.content])) return null;
2808
+ if (!_optionalChain([block, 'optionalAccess', _95 => _95.content])) return null;
2572
2809
  result.template = {
2573
2810
  ast: _compilercore.baseParse.call(void 0, block.content),
2574
2811
  source: block
@@ -2585,7 +2822,7 @@ function processVueSyntax(descriptor, ctx, result) {
2585
2822
  }
2586
2823
  function vueSyntaxProcessor(descriptor, ctx, result, options) {
2587
2824
  const run = (p, type) => {
2588
- _optionalChain([p, 'optionalAccess', _73 => _73.forEach, 'call', _74 => _74((handler) => {
2825
+ _optionalChain([p, 'optionalAccess', _96 => _96.forEach, 'call', _97 => _97((handler) => {
2589
2826
  if (type === "post") {
2590
2827
  handler(result, ctx);
2591
2828
  return;
@@ -2609,7 +2846,7 @@ function parseSFC(source, ctx, options) {
2609
2846
  };
2610
2847
  collectErrs(descriptor, errors);
2611
2848
  processVueSyntax(descriptor, ctx, result);
2612
- executePlugins(_optionalChain([options, 'optionalAccess', _75 => _75.plugins]), result, ctx);
2849
+ executePlugins(_optionalChain([options, 'optionalAccess', _98 => _98.plugins]), result, ctx);
2613
2850
  return result;
2614
2851
  }
2615
2852
  function collectErrs(descriptor, errors) {
@@ -2617,7 +2854,7 @@ function collectErrs(descriptor, errors) {
2617
2854
  logger.error(err.message, {
2618
2855
  source: descriptor.source,
2619
2856
  file: descriptor.filename,
2620
- loc: _optionalChain([err, 'optionalAccess', _76 => _76.loc])
2857
+ loc: _optionalChain([err, 'optionalAccess', _99 => _99.loc])
2621
2858
  });
2622
2859
  }
2623
2860
  if (descriptor.cssVars.length) {
@@ -2641,7 +2878,7 @@ function parse(source, ctx, options) {
2641
2878
 
2642
2879
  // src/core/transform/sfc/script/syntax-processor/postprocess/resolve-ast-chunks/resolve-global-type-chunk.ts
2643
2880
  function resolveGlobalTypeChunks(path9, ir) {
2644
- if (!_optionalChain([path9, 'access', _77 => _77.parentPath, 'optionalAccess', _78 => _78.isProgram, 'call', _79 => _79()])) {
2881
+ if (!_optionalChain([path9, 'access', _100 => _100.parentPath, 'optionalAccess', _101 => _101.isProgram, 'call', _102 => _102()])) {
2645
2882
  return;
2646
2883
  }
2647
2884
  const forked = forkNode(path9.node);
@@ -2868,7 +3105,7 @@ function resolveRuntimeImports(ctx) {
2868
3105
  if (!hasImports) {
2869
3106
  const importNodes = createImportNodes(ctx);
2870
3107
  if (importNodes.length) {
2871
- if (_optionalChain([strategyResult, 'optionalAccess', _80 => _80.shouldInjectRuntimeImports])) {
3108
+ if (_optionalChain([strategyResult, 'optionalAccess', _103 => _103.shouldInjectRuntimeImports])) {
2872
3109
  path9.insertAfter(importNodes);
2873
3110
  } else if (finalModuleName === PACKAGE_NAME.react) {
2874
3111
  path9.insertAfter(importNodes);
@@ -2896,7 +3133,7 @@ function resolveRuntimeImports(ctx) {
2896
3133
  }
2897
3134
  function mergeImports(currentNode, ctx, moduleName) {
2898
3135
  const ctxImportItems = ctx.imports.get(moduleName);
2899
- if (!_optionalChain([ctxImportItems, 'optionalAccess', _81 => _81.length])) {
3136
+ if (!_optionalChain([ctxImportItems, 'optionalAccess', _104 => _104.length])) {
2900
3137
  return;
2901
3138
  }
2902
3139
  const currentImports = /* @__PURE__ */ new Set();
@@ -2946,7 +3183,7 @@ function forkProgramTopLeadingComments(target, program3) {
2946
3183
  }
2947
3184
  function forkFilePreambleLeadingComments(target, source) {
2948
3185
  const { leadingComments } = source;
2949
- if (!_optionalChain([leadingComments, 'optionalAccess', _82 => _82.length])) {
3186
+ if (!_optionalChain([leadingComments, 'optionalAccess', _105 => _105.length])) {
2950
3187
  return;
2951
3188
  }
2952
3189
  const commentsToMove = [];
@@ -3118,30 +3355,32 @@ function resolveEmitCalls(ctx) {
3118
3355
  };
3119
3356
  if (!checkIfFromDefineEmits()) return;
3120
3357
  const [callee, ...args] = node.arguments;
3121
- const eventName = t28.isStringLiteral(callee) ? formatEmitEventName(callee.value) : void 0;
3122
- if (!eventName) {
3123
- logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess', _83 => _83.type])}, expression will be removed`, {
3124
- file: filename,
3125
- source: scriptData.source,
3126
- loc: _optionalChain([callee, 'optionalAccess', _84 => _84.loc])
3127
- });
3128
- path9.remove();
3129
- return;
3358
+ let propCall;
3359
+ if (t28.isStringLiteral(callee)) {
3360
+ const eventName = formatEmitEventName(callee.value);
3361
+ propCall = createPropCall(ctx.propField, t28.identifier(eventName), args);
3362
+ } else {
3363
+ propCall = createPropCall(ctx.propField, callee, args, true);
3364
+ logger.error(
3365
+ `Non-string event name cannot be converted to React onXxx style. The emit call will not work as expected.`,
3366
+ {
3367
+ file: filename,
3368
+ source: scriptData.source,
3369
+ loc: _optionalChain([callee, 'optionalAccess', _106 => _106.loc])
3370
+ }
3371
+ );
3130
3372
  }
3131
- const propCall = t28.optionalCallExpression(
3132
- t28.optionalMemberExpression(
3133
- t28.identifier(ctx.propField),
3134
- t28.identifier(eventName),
3135
- false,
3136
- true
3137
- ),
3138
- args,
3139
- true
3140
- );
3141
3373
  replaceNode(path9, propCall, node);
3142
3374
  }
3143
3375
  };
3144
3376
  }
3377
+ function createPropCall(rootName, callee, args, computed = false) {
3378
+ return t28.optionalCallExpression(
3379
+ t28.memberExpression(t28.identifier(rootName), callee, computed),
3380
+ args,
3381
+ true
3382
+ );
3383
+ }
3145
3384
 
3146
3385
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/index.ts
3147
3386
 
@@ -3246,8 +3485,8 @@ function resolveTopLevelEmitType(tsType) {
3246
3485
  function resolveDefineEmitsIface(path9, ctx) {
3247
3486
  const { node } = path9;
3248
3487
  const [runtimeArg] = node.arguments;
3249
- const tsParams = _optionalChain([node, 'access', _85 => _85.typeParameters, 'optionalAccess', _86 => _86.params]);
3250
- if (_optionalChain([tsParams, 'optionalAccess', _87 => _87.length])) {
3488
+ const tsParams = _optionalChain([node, 'access', _107 => _107.typeParameters, 'optionalAccess', _108 => _108.params]);
3489
+ if (_optionalChain([tsParams, 'optionalAccess', _109 => _109.length])) {
3251
3490
  processExplicitType(ctx, tsParams);
3252
3491
  return;
3253
3492
  }
@@ -3445,12 +3684,12 @@ function resolveEmitPropFromPropertySignature(member) {
3445
3684
  if (!rawName) return null;
3446
3685
  const handlerName = resolveEmitHandlerName(rawName);
3447
3686
  const key = buildKey(handlerName);
3448
- const typeAnnotation = _optionalChain([member, 'access', _88 => _88.typeAnnotation, 'optionalAccess', _89 => _89.typeAnnotation]);
3687
+ const typeAnnotation = _optionalChain([member, 'access', _110 => _110.typeAnnotation, 'optionalAccess', _111 => _111.typeAnnotation]);
3449
3688
  let params = [];
3450
3689
  let returnType = t30.tsAnyKeyword();
3451
3690
  if (typeAnnotation && t30.isTSFunctionType(typeAnnotation)) {
3452
3691
  params = cloneCallableParams(typeAnnotation.parameters);
3453
- returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _90 => _90.typeAnnotation, 'optionalAccess', _91 => _91.typeAnnotation]), () => ( returnType));
3692
+ returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _112 => _112.typeAnnotation, 'optionalAccess', _113 => _113.typeAnnotation]), () => ( returnType));
3454
3693
  } else if (typeAnnotation && t30.isTSTupleType(typeAnnotation)) {
3455
3694
  params = resolveTupleTypeParams(typeAnnotation);
3456
3695
  } else if (typeAnnotation) {
@@ -3475,7 +3714,7 @@ function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
3475
3714
  if (t30.isNoop(paramTypeAnnotation)) return [];
3476
3715
  const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
3477
3716
  if (!eventNames.length) return [];
3478
- const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _92 => _92.typeAnnotation]), () => ( t30.tsAnyKeyword()));
3717
+ const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _114 => _114.typeAnnotation]), () => ( t30.tsAnyKeyword()));
3479
3718
  return eventNames.map((eventName) => {
3480
3719
  const handlerName = resolveEmitHandlerName(eventName);
3481
3720
  const key = buildKey(handlerName);
@@ -3509,7 +3748,7 @@ function resolveTupleElementParam(element, index) {
3509
3748
  const isNamedTuple = typeof t30.isTSNamedTupleMember === "function" && t30.isTSNamedTupleMember(element);
3510
3749
  if (isNamedTuple) {
3511
3750
  const tupleMember = element;
3512
- const name = _optionalChain([tupleMember, 'access', _93 => _93.label, 'optionalAccess', _94 => _94.name]) || `arg${index}`;
3751
+ const name = _optionalChain([tupleMember, 'access', _115 => _115.label, 'optionalAccess', _116 => _116.name]) || `arg${index}`;
3513
3752
  let innerType = tupleMember.elementType;
3514
3753
  let optional = tupleMember.optional;
3515
3754
  if (t30.isTSOptionalType(innerType)) {
@@ -3547,8 +3786,8 @@ function resolveTupleElementParam(element, index) {
3547
3786
  function resolveDefinePropsIface(path9, ctx) {
3548
3787
  const { node } = path9;
3549
3788
  const [runtimeArg] = node.arguments;
3550
- const tsParams = _optionalChain([node, 'access', _95 => _95.typeParameters, 'optionalAccess', _96 => _96.params]);
3551
- if (_optionalChain([tsParams, 'optionalAccess', _97 => _97.length])) {
3789
+ const tsParams = _optionalChain([node, 'access', _117 => _117.typeParameters, 'optionalAccess', _118 => _118.params]);
3790
+ if (_optionalChain([tsParams, 'optionalAccess', _119 => _119.length])) {
3552
3791
  const { propsTSIface } = ctx.scriptData;
3553
3792
  propsTSIface.propsTypes = tsParams;
3554
3793
  return;
@@ -3603,7 +3842,7 @@ function processInferredTypes2(ctx, runtimeArg) {
3603
3842
  {
3604
3843
  source,
3605
3844
  file: filename,
3606
- loc: _optionalChain([runtimeArg, 'optionalAccess', _98 => _98.loc])
3845
+ loc: _optionalChain([runtimeArg, 'optionalAccess', _120 => _120.loc])
3607
3846
  }
3608
3847
  );
3609
3848
  }
@@ -3714,7 +3953,7 @@ function createSlotScopeParam(props, ctx) {
3714
3953
  const propsSigns = [];
3715
3954
  const { reactiveBindings } = ctx.templateData;
3716
3955
  props.forEach(({ prop, tsType }) => {
3717
- const foundBindingValue = _optionalChain([reactiveBindings, 'access', _99 => _99[prop], 'optionalAccess', _100 => _100.value]);
3956
+ const foundBindingValue = _optionalChain([reactiveBindings, 'access', _121 => _121[prop], 'optionalAccess', _122 => _122.value]);
3718
3957
  const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
3719
3958
  const typeAnnotation = foundBindingTypes ? t32.tsTypeAnnotation(foundBindingTypes) : tsType;
3720
3959
  const key = t32.isValidIdentifier(prop) ? t32.identifier(prop) : t32.stringLiteral(prop);
@@ -3746,7 +3985,7 @@ function collectLocalTypeDeclarations(path9) {
3746
3985
  declarations.set(statement.id.name, {
3747
3986
  type: t33.tsTypeLiteral(statement.body.body),
3748
3987
  // 将接口体转换为类型字面量
3749
- hasTypeParameters: !!_optionalChain([statement, 'access', _101 => _101.typeParameters, 'optionalAccess', _102 => _102.params, 'access', _103 => _103.length])
3988
+ hasTypeParameters: !!_optionalChain([statement, 'access', _123 => _123.typeParameters, 'optionalAccess', _124 => _124.params, 'access', _125 => _125.length])
3750
3989
  // 检查是否有泛型参数
3751
3990
  });
3752
3991
  continue;
@@ -3755,7 +3994,7 @@ function collectLocalTypeDeclarations(path9) {
3755
3994
  declarations.set(statement.id.name, {
3756
3995
  type: statement.typeAnnotation,
3757
3996
  // 直接使用类型注解
3758
- hasTypeParameters: !!_optionalChain([statement, 'access', _104 => _104.typeParameters, 'optionalAccess', _105 => _105.params, 'access', _106 => _106.length])
3997
+ hasTypeParameters: !!_optionalChain([statement, 'access', _126 => _126.typeParameters, 'optionalAccess', _127 => _127.params, 'access', _128 => _128.length])
3759
3998
  // 检查是否有泛型参数
3760
3999
  });
3761
4000
  continue;
@@ -3766,14 +4005,14 @@ function collectLocalTypeDeclarations(path9) {
3766
4005
  declarations.set(declaration.id.name, {
3767
4006
  type: t33.tsTypeLiteral(declaration.body.body),
3768
4007
  // 将接口体转换为类型字面量
3769
- hasTypeParameters: !!_optionalChain([declaration, 'access', _107 => _107.typeParameters, 'optionalAccess', _108 => _108.params, 'access', _109 => _109.length])
4008
+ hasTypeParameters: !!_optionalChain([declaration, 'access', _129 => _129.typeParameters, 'optionalAccess', _130 => _130.params, 'access', _131 => _131.length])
3770
4009
  // 检查是否有泛型参数
3771
4010
  });
3772
4011
  } else if (t33.isTSTypeAliasDeclaration(declaration)) {
3773
4012
  declarations.set(declaration.id.name, {
3774
4013
  type: declaration.typeAnnotation,
3775
4014
  // 直接使用类型注解
3776
- hasTypeParameters: !!_optionalChain([declaration, 'access', _110 => _110.typeParameters, 'optionalAccess', _111 => _111.params, 'access', _112 => _112.length])
4015
+ hasTypeParameters: !!_optionalChain([declaration, 'access', _132 => _132.typeParameters, 'optionalAccess', _133 => _133.params, 'access', _134 => _134.length])
3777
4016
  // 检查是否有泛型参数
3778
4017
  });
3779
4018
  }
@@ -3811,7 +4050,7 @@ function resolveSlotType(tsType, options) {
3811
4050
  }
3812
4051
  if (t34.isTSTypeReference(tsType)) {
3813
4052
  let shouldRecordReactNode = false;
3814
- if (_optionalChain([tsType, 'access', _113 => _113.typeParameters, 'optionalAccess', _114 => _114.params, 'access', _115 => _115.length])) {
4053
+ if (_optionalChain([tsType, 'access', _135 => _135.typeParameters, 'optionalAccess', _136 => _136.params, 'access', _137 => _137.length])) {
3815
4054
  const params = [];
3816
4055
  for (const param of tsType.typeParameters.params) {
3817
4056
  const resolved2 = resolveSlotType(param, options);
@@ -3975,7 +4214,7 @@ function resolveSlotPropFromMember(member) {
3975
4214
  shouldRecordReactNode: false
3976
4215
  };
3977
4216
  }
3978
- const typeAnnotation = _optionalChain([member, 'access', _116 => _116.typeAnnotation, 'optionalAccess', _117 => _117.typeAnnotation]);
4217
+ const typeAnnotation = _optionalChain([member, 'access', _138 => _138.typeAnnotation, 'optionalAccess', _139 => _139.typeAnnotation]);
3979
4218
  const callable = typeAnnotation ? resolveCallableType(typeAnnotation) : null;
3980
4219
  if (!callable) {
3981
4220
  return {
@@ -4007,8 +4246,8 @@ function resolveSlotPropFromMember(member) {
4007
4246
  // src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/define-slots.ts
4008
4247
  function resolveDefineSlotsIface(path9, ctx) {
4009
4248
  const { node } = path9;
4010
- const tsParams = _optionalChain([node, 'access', _118 => _118.typeParameters, 'optionalAccess', _119 => _119.params]);
4011
- if (!_optionalChain([tsParams, 'optionalAccess', _120 => _120.length])) return;
4249
+ const tsParams = _optionalChain([node, 'access', _140 => _140.typeParameters, 'optionalAccess', _141 => _141.params]);
4250
+ if (!_optionalChain([tsParams, 'optionalAccess', _142 => _142.length])) return;
4012
4251
  const {
4013
4252
  propsTSIface: { slotTypes }
4014
4253
  } = ctx.scriptData;
@@ -4156,18 +4395,247 @@ function createPropsTypeAssertion(propsIdentifier, typeAnnotation) {
4156
4395
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
4157
4396
 
4158
4397
 
4159
- // src/core/transform/sfc/script/shared/dependency-analyzer.ts
4398
+ // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4399
+
4400
+
4401
+
4402
+ // src/core/transform/sfc/script/shared/dependency-analyzer/binding-utils.ts
4403
+ function isBindingDeclaredInsideBoundary(binding, boundary) {
4404
+ let current = binding.path;
4405
+ while (current) {
4406
+ if (current.node === boundary) {
4407
+ return true;
4408
+ }
4409
+ current = current.parentPath;
4410
+ }
4411
+ return false;
4412
+ }
4413
+ function isReactiveBinding(node) {
4414
+ if (!node) return false;
4415
+ return !!_optionalChain([getScriptNodeMeta, 'call', _143 => _143(node), 'optionalAccess', _144 => _144.is_reactive]);
4416
+ }
4417
+
4418
+ // src/core/transform/sfc/script/shared/dependency-analyzer/dep-checker.ts
4419
+
4420
+ function isEligibleBindingSource(binding) {
4421
+ if (binding.kind === "param") {
4422
+ return false;
4423
+ }
4424
+ const reactiveStateApis = getReactiveStateApis();
4425
+ const bindingPath = binding.path;
4426
+ const declaratorPath = getVariableDeclaratorPath(bindingPath);
4427
+ const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
4428
+ const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _145 => _145.node, 'access', _146 => _146.init]);
4429
+ const isReactiveApiCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && t38.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4430
+ const isHookCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4431
+ const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t38.isArrowFunctionExpression(nodeInit) || t38.isFunctionExpression(nodeInit));
4432
+ const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess', _147 => _147.node])) || isReactiveBinding(bindingPath.node));
4433
+ return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
4434
+ }
4435
+ function isReactValidDependencyExpr(node) {
4436
+ if (t38.isIdentifier(node)) {
4437
+ return true;
4438
+ }
4439
+ if (t38.isMemberExpression(node) || t38.isOptionalMemberExpression(node)) {
4440
+ return isStaticMemberChain(node);
4441
+ }
4442
+ return false;
4443
+ }
4444
+ function isStaticMemberChain(node) {
4445
+ let current = node;
4446
+ while (t38.isMemberExpression(current) || t38.isOptionalMemberExpression(current)) {
4447
+ if (!current.computed && !t38.isIdentifier(current.property)) {
4448
+ return false;
4449
+ }
4450
+ if (current.computed && !t38.isStringLiteral(current.property) && !t38.isNumericLiteral(current.property)) {
4451
+ return false;
4452
+ }
4453
+ current = current.object;
4454
+ }
4455
+ return t38.isIdentifier(current);
4456
+ }
4457
+ function isHookLikeCallee(callee) {
4458
+ if (t38.isIdentifier(callee)) {
4459
+ return callee.name.startsWith("use");
4460
+ }
4461
+ if (t38.isMemberExpression(callee) && !callee.computed && t38.isIdentifier(callee.property)) {
4462
+ return callee.property.name.startsWith("use");
4463
+ }
4464
+ return false;
4465
+ }
4466
+
4467
+ // src/core/transform/sfc/script/shared/dependency-analyzer/dep-key.ts
4468
+
4469
+ function getDependencyKey(exp) {
4470
+ if (t39.isIdentifier(exp)) {
4471
+ return exp.name;
4472
+ }
4473
+ if (t39.isMemberExpression(exp) || t39.isOptionalMemberExpression(exp)) {
4474
+ const objectKey = getDependencyKey(exp.object);
4475
+ const opt = exp.optional ? "?" : "";
4476
+ if (!exp.computed && t39.isIdentifier(exp.property)) {
4477
+ return `${objectKey}${opt}.${exp.property.name}`;
4478
+ }
4479
+ if (t39.isStringLiteral(exp.property) || t39.isNumericLiteral(exp.property)) {
4480
+ return `${objectKey}${opt}[${JSON.stringify(exp.property.value)}]`;
4481
+ }
4482
+ return `${objectKey}${opt}[*]`;
4483
+ }
4484
+ return exp.type;
4485
+ }
4160
4486
 
4487
+ // src/core/transform/sfc/script/shared/dependency-analyzer/dep-normalizer.ts
4161
4488
 
4489
+ function normalizeDependencyExpr(path9, rootName, ctx) {
4490
+ if (t40.isIdentifier(path9.node)) {
4491
+ return t40.identifier(path9.node.name);
4492
+ }
4493
+ if (t40.isMemberExpression(path9.node) || t40.isOptionalMemberExpression(path9.node)) {
4494
+ if (rootName === ctx.propField) {
4495
+ const safePropsExp = ensureOptionalForMemberChain(path9.node);
4496
+ if (isReactValidDependencyExpr(safePropsExp)) {
4497
+ return t40.cloneNode(safePropsExp, true);
4498
+ }
4499
+ return t40.identifier(rootName);
4500
+ }
4501
+ const normalizedExp = normalizeMemberForCallSite(path9, path9.node);
4502
+ const safeExp = t40.isMemberExpression(normalizedExp) || t40.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4503
+ if (isReactValidDependencyExpr(safeExp)) {
4504
+ return t40.cloneNode(safeExp, true);
4505
+ }
4506
+ return t40.identifier(rootName);
4507
+ }
4508
+ return null;
4509
+ }
4510
+ function normalizeSourcedDependency(exp) {
4511
+ if (t40.isIdentifier(exp)) {
4512
+ return t40.identifier(exp.name);
4513
+ }
4514
+ if (t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp)) {
4515
+ const root = findRootIdentifier(exp);
4516
+ if (!root) return null;
4517
+ const safeExp = t40.isMemberExpression(exp) || t40.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4518
+ if (isReactValidDependencyExpr(safeExp)) {
4519
+ return t40.cloneNode(safeExp, true);
4520
+ }
4521
+ return t40.identifier(root.name);
4522
+ }
4523
+ return null;
4524
+ }
4525
+ function normalizeMemberForCallSite(path9, node) {
4526
+ const parent = path9.parentPath;
4527
+ const isDirectCallee = !!parent && (parent.isCallExpression() && parent.node.callee === node || parent.isOptionalCallExpression() && parent.node.callee === node);
4528
+ if (!isDirectCallee) {
4529
+ return node;
4530
+ }
4531
+ if (!t40.isExpression(node.object)) {
4532
+ return node;
4533
+ }
4534
+ return node.object;
4535
+ }
4536
+ function ensureOptionalForMemberChain(node) {
4537
+ if (!hasTrailingMemberAccess(node)) {
4538
+ return node;
4539
+ }
4540
+ if (t40.isOptionalMemberExpression(node) && node.optional) {
4541
+ return node;
4542
+ }
4543
+ const object = t40.cloneNode(node.object, true);
4544
+ const property = t40.cloneNode(node.property, true);
4545
+ return t40.optionalMemberExpression(object, property, node.computed, true);
4546
+ }
4547
+ function hasTrailingMemberAccess(node) {
4548
+ return t40.isMemberExpression(node.object) || t40.isOptionalMemberExpression(node.object);
4549
+ }
4550
+
4551
+ // src/core/transform/sfc/script/shared/dependency-analyzer/shared-utils.ts
4162
4552
  var TRACE_MAX_DEPTH = 20;
4553
+ function isNestedMemberObject(path9) {
4554
+ const parent = path9.parentPath;
4555
+ if (!parent) return false;
4556
+ if (parent.isMemberExpression() || parent.isOptionalMemberExpression()) {
4557
+ return parent.node.object === path9.node;
4558
+ }
4559
+ return false;
4560
+ }
4561
+
4562
+ // src/core/transform/sfc/script/shared/dependency-analyzer/trace-utils.ts
4563
+
4564
+ function traceBindingSource(binding, seen, depth) {
4565
+ if (depth <= 0) return null;
4566
+ const declaratorPath = getVariableDeclaratorPath(binding.path);
4567
+ if (!declaratorPath || !declaratorPath.node.init) return null;
4568
+ if (seen.has(declaratorPath.node)) return null;
4569
+ seen.add(declaratorPath.node);
4570
+ const { init } = declaratorPath.node;
4571
+ return isExpressionSourcedFromEligibleBinding(init, declaratorPath.scope, seen, depth - 1);
4572
+ }
4573
+ function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4574
+ if (depth <= 0) return null;
4575
+ if (t41.isIdentifier(exp)) {
4576
+ const sourceBinding = scope.getBinding(exp.name);
4577
+ if (!sourceBinding) return null;
4578
+ if (isEligibleBindingSource(sourceBinding)) {
4579
+ return exp;
4580
+ }
4581
+ return traceBindingSource(sourceBinding, seen, depth - 1);
4582
+ }
4583
+ if (t41.isMemberExpression(exp) || t41.isOptionalMemberExpression(exp)) {
4584
+ const root = findRootIdentifier(exp);
4585
+ if (!root) return null;
4586
+ const sourceBinding = scope.getBinding(root.name);
4587
+ if (!sourceBinding) return null;
4588
+ if (isEligibleBindingSource(sourceBinding)) {
4589
+ return t41.cloneNode(exp);
4590
+ }
4591
+ const sourcedRoot = traceBindingSource(sourceBinding, seen, depth - 1);
4592
+ if (sourcedRoot) {
4593
+ const rebuilt = rebuildMemberWithNewRoot(exp, sourcedRoot);
4594
+ if (rebuilt) {
4595
+ return rebuilt;
4596
+ }
4597
+ return t41.cloneNode(sourcedRoot, true);
4598
+ }
4599
+ }
4600
+ return null;
4601
+ }
4602
+ function rebuildMemberWithNewRoot(node, nextRoot) {
4603
+ const replacedObject = (() => {
4604
+ if (t41.isIdentifier(node.object)) {
4605
+ return t41.cloneNode(nextRoot, true);
4606
+ }
4607
+ if (t41.isMemberExpression(node.object) || t41.isOptionalMemberExpression(node.object)) {
4608
+ return rebuildMemberWithNewRoot(node.object, nextRoot);
4609
+ }
4610
+ return null;
4611
+ })();
4612
+ if (!replacedObject) {
4613
+ return null;
4614
+ }
4615
+ const property = t41.cloneNode(node.property, true);
4616
+ if (t41.isMemberExpression(node)) {
4617
+ return t41.memberExpression(
4618
+ replacedObject,
4619
+ property,
4620
+ node.computed
4621
+ );
4622
+ }
4623
+ return t41.optionalMemberExpression(
4624
+ replacedObject,
4625
+ property,
4626
+ node.computed,
4627
+ node.optional
4628
+ );
4629
+ }
4630
+
4631
+ // src/core/transform/sfc/script/shared/dependency-analyzer/index.ts
4163
4632
  function analyzeDeps(node, ctx, parentPath) {
4164
4633
  if (!parentPath) {
4165
- return t38.arrayExpression([]);
4634
+ return t42.arrayExpression([]);
4166
4635
  }
4167
- const isFnExpr = t38.isArrowFunctionExpression(node) || t38.isFunctionExpression(node);
4636
+ const isFnExpr = t42.isArrowFunctionExpression(node) || t42.isFunctionExpression(node);
4168
4637
  const analyzeTarget = isFnExpr ? node.body : node;
4169
4638
  const bindingLocalBoundary = isFnExpr ? node : analyzeTarget;
4170
- const reactiveStateApis = getReactiveStateApis();
4171
4639
  const deps = /* @__PURE__ */ new Map();
4172
4640
  const processedIdentifiers = /* @__PURE__ */ new WeakSet();
4173
4641
  function addDependency(exp) {
@@ -4175,13 +4643,13 @@ function analyzeDeps(node, ctx, parentPath) {
4175
4643
  }
4176
4644
  const analyzeTargetPath = parentPath && parentPath.node === analyzeTarget ? parentPath : null;
4177
4645
  if (analyzeTargetPath) {
4178
- if (t38.isMemberExpression(analyzeTarget) || t38.isOptionalMemberExpression(analyzeTarget)) {
4646
+ if (t42.isMemberExpression(analyzeTarget) || t42.isOptionalMemberExpression(analyzeTarget)) {
4179
4647
  const rootId = findRootIdentifier(analyzeTarget);
4180
4648
  if (rootId) {
4181
4649
  tryAddDependency(analyzeTargetPath, rootId.name, analyzeTargetPath.scope);
4182
4650
  processedIdentifiers.add(rootId);
4183
4651
  }
4184
- } else if (t38.isIdentifier(analyzeTarget)) {
4652
+ } else if (t42.isIdentifier(analyzeTarget)) {
4185
4653
  tryAddDependency(analyzeTargetPath, analyzeTarget.name, analyzeTargetPath.scope);
4186
4654
  }
4187
4655
  }
@@ -4207,17 +4675,19 @@ function analyzeDeps(node, ctx, parentPath) {
4207
4675
  parentPath.scope
4208
4676
  );
4209
4677
  function tryAddDependency(depPath, rootName, scope) {
4210
- const normalized = normalizeDependencyExpr(depPath, rootName);
4678
+ const normalized = normalizeDependencyExpr(depPath, rootName, ctx);
4211
4679
  if (!normalized) return;
4212
- const binding = scope.getBinding(rootName);
4213
- if (!binding) return;
4214
- const isLocalBinding = isBindingDeclaredInsideBoundary(binding, bindingLocalBoundary);
4215
4680
  if (rootName === ctx.propField) {
4216
- if (!isLocalBinding) {
4681
+ const propsBinding = scope.getBinding(rootName);
4682
+ const isLocalPropsBinding = !!propsBinding && isBindingDeclaredInsideBoundary(propsBinding, bindingLocalBoundary);
4683
+ if (!isLocalPropsBinding) {
4217
4684
  addDependency(normalized);
4218
4685
  }
4219
4686
  return;
4220
4687
  }
4688
+ const binding = scope.getBinding(rootName);
4689
+ if (!binding) return;
4690
+ const isLocalBinding = isBindingDeclaredInsideBoundary(binding, bindingLocalBoundary);
4221
4691
  const directEligible = !isLocalBinding && isEligibleBindingSource(binding);
4222
4692
  if (directEligible) {
4223
4693
  addDependency(normalized);
@@ -4231,211 +4701,7 @@ function analyzeDeps(node, ctx, parentPath) {
4231
4701
  }
4232
4702
  }
4233
4703
  }
4234
- function normalizeDependencyExpr(path9, rootName) {
4235
- if (t38.isIdentifier(path9.node)) {
4236
- return t38.identifier(path9.node.name);
4237
- }
4238
- if (t38.isMemberExpression(path9.node) || t38.isOptionalMemberExpression(path9.node)) {
4239
- const normalizedExp = normalizeMemberForCallSite(path9, path9.node);
4240
- const safeExp = t38.isMemberExpression(normalizedExp) || t38.isOptionalMemberExpression(normalizedExp) ? ensureOptionalForMemberChain(normalizedExp) : normalizedExp;
4241
- if (isReactValidDependencyExpr(safeExp)) {
4242
- return t38.cloneNode(safeExp, true);
4243
- }
4244
- return t38.identifier(rootName);
4245
- }
4246
- return null;
4247
- }
4248
- function normalizeSourcedDependency(exp) {
4249
- if (t38.isIdentifier(exp)) {
4250
- return t38.identifier(exp.name);
4251
- }
4252
- if (t38.isMemberExpression(exp) || t38.isOptionalMemberExpression(exp)) {
4253
- const root = findRootIdentifier(exp);
4254
- if (!root) return null;
4255
- const safeExp = t38.isMemberExpression(exp) || t38.isOptionalMemberExpression(exp) ? ensureOptionalForMemberChain(exp) : exp;
4256
- if (isReactValidDependencyExpr(safeExp)) {
4257
- return t38.cloneNode(safeExp, true);
4258
- }
4259
- return t38.identifier(root.name);
4260
- }
4261
- return null;
4262
- }
4263
- function isReactValidDependencyExpr(node2) {
4264
- if (t38.isIdentifier(node2)) {
4265
- return true;
4266
- }
4267
- if (t38.isMemberExpression(node2) || t38.isOptionalMemberExpression(node2)) {
4268
- return isStaticMemberChain(node2);
4269
- }
4270
- return false;
4271
- }
4272
- function isStaticMemberChain(node2) {
4273
- let current = node2;
4274
- while (t38.isMemberExpression(current) || t38.isOptionalMemberExpression(current)) {
4275
- if (!current.computed && !t38.isIdentifier(current.property)) {
4276
- return false;
4277
- }
4278
- if (current.computed && !t38.isStringLiteral(current.property) && !t38.isNumericLiteral(current.property)) {
4279
- return false;
4280
- }
4281
- current = current.object;
4282
- }
4283
- return t38.isIdentifier(current);
4284
- }
4285
- function isBindingDeclaredInsideBoundary(binding, boundary) {
4286
- let current = binding.path;
4287
- while (current) {
4288
- if (current.node === boundary) {
4289
- return true;
4290
- }
4291
- current = current.parentPath;
4292
- }
4293
- return false;
4294
- }
4295
- function normalizeMemberForCallSite(path9, node2) {
4296
- const parent = path9.parentPath;
4297
- const isDirectCallee = !!parent && (parent.isCallExpression() && parent.node.callee === node2 || parent.isOptionalCallExpression() && parent.node.callee === node2);
4298
- if (!isDirectCallee) {
4299
- return node2;
4300
- }
4301
- if (!t38.isExpression(node2.object)) {
4302
- return node2;
4303
- }
4304
- return node2.object;
4305
- }
4306
- function ensureOptionalForMemberChain(node2) {
4307
- if (!hasTrailingMemberAccess(node2)) {
4308
- return node2;
4309
- }
4310
- if (t38.isOptionalMemberExpression(node2) && node2.optional) {
4311
- return node2;
4312
- }
4313
- const object = t38.cloneNode(node2.object, true);
4314
- const property = t38.cloneNode(node2.property, true);
4315
- return t38.optionalMemberExpression(object, property, node2.computed, true);
4316
- }
4317
- function hasTrailingMemberAccess(node2) {
4318
- return t38.isMemberExpression(node2.object) || t38.isOptionalMemberExpression(node2.object);
4319
- }
4320
- function isEligibleBindingSource(binding) {
4321
- if (binding.kind === "param") {
4322
- return false;
4323
- }
4324
- const bindingPath = binding.path;
4325
- const declaratorPath = getVariableDeclaratorPath(bindingPath);
4326
- const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
4327
- const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _121 => _121.node, 'access', _122 => _122.init]);
4328
- const isReactiveApiCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && t38.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
4329
- const isHookCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
4330
- const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t38.isArrowFunctionExpression(nodeInit) || t38.isFunctionExpression(nodeInit));
4331
- const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess', _123 => _123.node])) || isReactiveBinding(bindingPath.node));
4332
- return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
4333
- }
4334
- function isHookLikeCallee(callee) {
4335
- if (t38.isIdentifier(callee)) {
4336
- return callee.name.startsWith("use");
4337
- }
4338
- if (t38.isMemberExpression(callee) && !callee.computed && t38.isIdentifier(callee.property)) {
4339
- return callee.property.name.startsWith("use");
4340
- }
4341
- return false;
4342
- }
4343
- function traceBindingSource(binding, seen, depth) {
4344
- if (depth <= 0) return null;
4345
- const declaratorPath = getVariableDeclaratorPath(binding.path);
4346
- if (!declaratorPath || !declaratorPath.node.init) return null;
4347
- if (seen.has(declaratorPath.node)) return null;
4348
- seen.add(declaratorPath.node);
4349
- const { init } = declaratorPath.node;
4350
- return isExpressionSourcedFromEligibleBinding(init, declaratorPath.scope, seen, depth - 1);
4351
- }
4352
- function isExpressionSourcedFromEligibleBinding(exp, scope, seen, depth) {
4353
- if (depth <= 0) return null;
4354
- if (t38.isIdentifier(exp)) {
4355
- const sourceBinding = scope.getBinding(exp.name);
4356
- if (!sourceBinding) return null;
4357
- if (isEligibleBindingSource(sourceBinding)) {
4358
- return exp;
4359
- }
4360
- return traceBindingSource(sourceBinding, seen, depth - 1);
4361
- }
4362
- if (t38.isMemberExpression(exp) || t38.isOptionalMemberExpression(exp)) {
4363
- const root = findRootIdentifier(exp);
4364
- if (!root) return null;
4365
- const sourceBinding = scope.getBinding(root.name);
4366
- if (!sourceBinding) return null;
4367
- if (isEligibleBindingSource(sourceBinding)) {
4368
- return t38.cloneNode(exp);
4369
- }
4370
- const sourcedRoot = traceBindingSource(sourceBinding, seen, depth - 1);
4371
- if (sourcedRoot) {
4372
- const rebuilt = rebuildMemberWithNewRoot(exp, sourcedRoot);
4373
- if (rebuilt) {
4374
- return rebuilt;
4375
- }
4376
- return t38.cloneNode(sourcedRoot, true);
4377
- }
4378
- }
4379
- return null;
4380
- }
4381
- function rebuildMemberWithNewRoot(node2, nextRoot) {
4382
- const replacedObject = (() => {
4383
- if (t38.isIdentifier(node2.object)) {
4384
- return t38.cloneNode(nextRoot, true);
4385
- }
4386
- if (t38.isMemberExpression(node2.object) || t38.isOptionalMemberExpression(node2.object)) {
4387
- return rebuildMemberWithNewRoot(node2.object, nextRoot);
4388
- }
4389
- return null;
4390
- })();
4391
- if (!replacedObject) {
4392
- return null;
4393
- }
4394
- const property = t38.cloneNode(node2.property, true);
4395
- if (t38.isMemberExpression(node2)) {
4396
- return t38.memberExpression(
4397
- replacedObject,
4398
- property,
4399
- node2.computed
4400
- );
4401
- }
4402
- return t38.optionalMemberExpression(
4403
- replacedObject,
4404
- property,
4405
- node2.computed,
4406
- node2.optional
4407
- );
4408
- }
4409
- return t38.arrayExpression(Array.from(deps.values()));
4410
- }
4411
- function getDependencyKey(exp) {
4412
- if (t38.isIdentifier(exp)) {
4413
- return exp.name;
4414
- }
4415
- if (t38.isMemberExpression(exp) || t38.isOptionalMemberExpression(exp)) {
4416
- const objectKey = getDependencyKey(exp.object);
4417
- const opt = exp.optional ? "?" : "";
4418
- if (!exp.computed && t38.isIdentifier(exp.property)) {
4419
- return `${objectKey}${opt}.${exp.property.name}`;
4420
- }
4421
- if (t38.isStringLiteral(exp.property) || t38.isNumericLiteral(exp.property)) {
4422
- return `${objectKey}${opt}[${JSON.stringify(exp.property.value)}]`;
4423
- }
4424
- return `${objectKey}${opt}[*]`;
4425
- }
4426
- return exp.type;
4427
- }
4428
- function isNestedMemberObject(path9) {
4429
- const parent = path9.parentPath;
4430
- if (!parent) return false;
4431
- if (parent.isMemberExpression() || parent.isOptionalMemberExpression()) {
4432
- return parent.node.object === path9.node;
4433
- }
4434
- return false;
4435
- }
4436
- function isReactiveBinding(node) {
4437
- if (!node) return false;
4438
- return !!_optionalChain([getScriptNodeMeta, 'call', _124 => _124(node), 'optionalAccess', _125 => _125.is_reactive]);
4704
+ return t42.arrayExpression(Array.from(deps.values()));
4439
4705
  }
4440
4706
 
4441
4707
  // src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
@@ -4451,7 +4717,7 @@ function resolveAnalysisOnlyAdapter(ctx) {
4451
4717
  if (!isVueApiReference(path9, apiName)) {
4452
4718
  return;
4453
4719
  }
4454
- if (t39.isCallExpression(node)) {
4720
+ if (t43.isCallExpression(node)) {
4455
4721
  resolveCallNode(path9, adapter, ctx);
4456
4722
  } else {
4457
4723
  replaceIdName(node, adapter.target);
@@ -4461,11 +4727,11 @@ function resolveAnalysisOnlyAdapter(ctx) {
4461
4727
  };
4462
4728
  }
4463
4729
  function getApiName(node) {
4464
- const isCallNode = t39.isCallExpression(node);
4730
+ const isCallNode = t43.isCallExpression(node);
4465
4731
  let apiName = "";
4466
- if (t39.isIdentifier(node)) {
4732
+ if (t43.isIdentifier(node)) {
4467
4733
  apiName = node.name;
4468
- } else if (isCallNode && t39.isIdentifier(node.callee)) {
4734
+ } else if (isCallNode && t43.isIdentifier(node.callee)) {
4469
4735
  apiName = node.callee.name;
4470
4736
  }
4471
4737
  return apiName;
@@ -4475,7 +4741,7 @@ function resolveCallNode(path9, adapter, ctx) {
4475
4741
  const { arguments: args } = node;
4476
4742
  if (!args.length) return;
4477
4743
  const fn = args[0];
4478
- if (!t39.isArrowFunctionExpression(fn) && !t39.isFunctionExpression(fn)) {
4744
+ if (!t43.isArrowFunctionExpression(fn) && !t43.isFunctionExpression(fn)) {
4479
4745
  return;
4480
4746
  }
4481
4747
  const fnPath = path9.get("arguments")[0];
@@ -4506,8 +4772,8 @@ function isVueImportBinding(binding) {
4506
4772
  if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
4507
4773
  return false;
4508
4774
  }
4509
- const parent = _optionalChain([bindingPath, 'access', _126 => _126.parentPath, 'optionalAccess', _127 => _127.node]);
4510
- if (!parent || !t39.isImportDeclaration(parent)) {
4775
+ const parent = _optionalChain([bindingPath, 'access', _148 => _148.parentPath, 'optionalAccess', _149 => _149.node]);
4776
+ if (!parent || !t43.isImportDeclaration(parent)) {
4511
4777
  return false;
4512
4778
  }
4513
4779
  const source = parent.source.value.toLowerCase();
@@ -4533,7 +4799,7 @@ function resolveArrowFnDeps(ctx, ast) {
4533
4799
  const newNode = createUseCallback(node, deps);
4534
4800
  const declaratorPath = getVariableDeclaratorPath(path9);
4535
4801
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
4536
- setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _128 => _128.node]), { is_reactive: true, reactive_type: "indirect" });
4802
+ setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _150 => _150.node]), { is_reactive: true, reactive_type: "indirect" });
4537
4803
  replaceNode(path9, newNode, node);
4538
4804
  }
4539
4805
  };
@@ -4592,15 +4858,15 @@ function resolveElementRef(ctx) {
4592
4858
  return;
4593
4859
  }
4594
4860
  if (isCompRefBindings) {
4595
- const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _129 => _129(path9), 'optionalAccess', _130 => _130.node]);
4596
- if (!t40.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _131 => _131.id]))) {
4861
+ const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _151 => _151(path9), 'optionalAccess', _152 => _152.node]);
4862
+ if (!t44.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _153 => _153.id]))) {
4597
4863
  return;
4598
4864
  }
4599
4865
  const varName = varDeclaratorPath.id.name;
4600
4866
  const compRef = refBindings.componentRefs[varName];
4601
4867
  if (!compRef) return;
4602
4868
  }
4603
- node.arguments[0] = t40.identifier("null");
4869
+ node.arguments[0] = t44.identifier("null");
4604
4870
  resolveTypeParameters(ctx, path9);
4605
4871
  replaceCallName(node, REACT_API_MAP.useRef);
4606
4872
  recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useRef);
@@ -4616,7 +4882,7 @@ function resolveTypeParameters(ctx, path9) {
4616
4882
  scriptData
4617
4883
  } = ctx;
4618
4884
  const { node } = path9;
4619
- const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _132 => _132(path9), 'optionalAccess', _133 => _133.node]);
4885
+ const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _154 => _154(path9), 'optionalAccess', _155 => _155.node]);
4620
4886
  if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
4621
4887
  return;
4622
4888
  }
@@ -4625,20 +4891,20 @@ function resolveTypeParameters(ctx, path9) {
4625
4891
  const compBindingMeta = refBindings.componentRefs[idName];
4626
4892
  if (!node.typeParameters && (domBindingMeta || compBindingMeta)) {
4627
4893
  const type = compBindingMeta ? "any" : domBindingMeta.htmlType;
4628
- node.typeParameters = t40.tsTypeParameterInstantiation([t40.tsTypeReference(t40.identifier(type))]);
4894
+ node.typeParameters = t44.tsTypeParameterInstantiation([t44.tsTypeReference(t44.identifier(type))]);
4629
4895
  }
4630
4896
  }
4631
4897
  function resolveRefValueToCurrent(path9) {
4632
4898
  const { node } = path9;
4633
- if (node.computed || !t40.isIdentifier(node.property) || node.property.name !== "value") {
4899
+ if (node.computed || !t44.isIdentifier(node.property) || node.property.name !== "value") {
4634
4900
  return;
4635
4901
  }
4636
4902
  const rootPath = findRootVariablePath(path9);
4637
- if (!_optionalChain([rootPath, 'optionalAccess', _134 => _134.node]) || !t40.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4903
+ if (!_optionalChain([rootPath, 'optionalAccess', _156 => _156.node]) || !t44.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
4638
4904
  return;
4639
4905
  }
4640
4906
  const rootId = findRootIdentifier(node);
4641
- if (!t40.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _135 => _135.name])) {
4907
+ if (!t44.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _157 => _157.name])) {
4642
4908
  return;
4643
4909
  }
4644
4910
  node.property.name = "current";
@@ -4657,11 +4923,11 @@ function resolveExprMemo(ctx, ast) {
4657
4923
  if (!atComponentOrHookRoot(path9, ast.program, isScriptFile)) {
4658
4924
  return false;
4659
4925
  }
4660
- if (!t41.isVariableDeclaration(path9.parent) || path9.parent.kind !== "const") {
4926
+ if (!t45.isVariableDeclaration(path9.parent) || path9.parent.kind !== "const") {
4661
4927
  return false;
4662
4928
  }
4663
- if (t41.isFunction(init)) return false;
4664
- if (t41.isCallExpression(init) && t41.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
4929
+ if (t45.isFunction(init)) return false;
4930
+ if (t45.isCallExpression(init) && t45.isIdentifier(init.callee) && init.callee.name.startsWith("use")) {
4665
4931
  return false;
4666
4932
  }
4667
4933
  return true;
@@ -4674,6 +4940,7 @@ function resolveExprMemo(ctx, ast) {
4674
4940
  const useMemoCall = createUseMemo(initPath.node, deps);
4675
4941
  initPath.replaceWith(useMemoCall);
4676
4942
  setScriptNodeMeta(node, { is_reactive: true, reactive_type: "indirect" });
4943
+ recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useMemo);
4677
4944
  }
4678
4945
  };
4679
4946
  }
@@ -4685,10 +4952,10 @@ function resolveLintRules(ctx, ast) {
4685
4952
  return {
4686
4953
  CallExpression(path9) {
4687
4954
  const { node, parentPath } = path9;
4688
- if (!t42.isIdentifier(node.callee)) return;
4955
+ if (!t46.isIdentifier(node.callee)) return;
4689
4956
  const { name: callName } = node.callee;
4690
- const addLog = (t48) => {
4691
- logger.error(t48, {
4957
+ const addLog = (t52) => {
4958
+ logger.error(t52, {
4692
4959
  file: ctx.filename,
4693
4960
  source: ctx.scriptData.source,
4694
4961
  loc: node.loc
@@ -4739,7 +5006,7 @@ function resolveProvide(ctx) {
4739
5006
  return {
4740
5007
  CallExpression(path9) {
4741
5008
  const { node } = path9;
4742
- const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _136 => _136.runtime, 'access', _137 => _137[VUE_API_MAP.provide], 'optionalAccess', _138 => _138.target]);
5009
+ const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _158 => _158.runtime, 'access', _159 => _159[VUE_API_MAP.provide], 'optionalAccess', _160 => _160.target]);
4743
5010
  const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
4744
5011
  if (!isProvideCall) return;
4745
5012
  const { provide } = ctx.scriptData;
@@ -4757,7 +5024,7 @@ function findOrCreateCtxProvider(root) {
4757
5024
  return root;
4758
5025
  }
4759
5026
  let cur = root.provide;
4760
- while (_optionalChain([cur, 'optionalAccess', _139 => _139.isOccupied])) {
5027
+ while (_optionalChain([cur, 'optionalAccess', _161 => _161.isOccupied])) {
4761
5028
  cur = _nullishCoalesce(cur.provide, () => ( {}));
4762
5029
  }
4763
5030
  return cur || (root.provide = {});
@@ -4765,18 +5032,18 @@ function findOrCreateCtxProvider(root) {
4765
5032
  function assignProviderValue(target, key, value) {
4766
5033
  const getRawExp = (exp) => {
4767
5034
  if (!exp) return "''";
4768
- if (t43.isStringLiteral(exp)) {
5035
+ if (t47.isStringLiteral(exp)) {
4769
5036
  return JSON.stringify(exp.value);
4770
5037
  }
4771
- if (t43.isNumericLiteral(exp)) {
5038
+ if (t47.isNumericLiteral(exp)) {
4772
5039
  return exp.value.toString();
4773
5040
  }
4774
- if (t43.isIdentifier(exp)) {
5041
+ if (t47.isIdentifier(exp)) {
4775
5042
  return exp.name;
4776
5043
  }
4777
5044
  try {
4778
5045
  return _generator.generate.call(void 0, exp).code;
4779
- } catch (e5) {
5046
+ } catch (e6) {
4780
5047
  return "null";
4781
5048
  }
4782
5049
  };
@@ -4792,11 +5059,11 @@ function resolveRenameAdapter(ctx) {
4792
5059
  return {
4793
5060
  "CallExpression|Identifier"(path9) {
4794
5061
  const node = path9.node;
4795
- const isCallNode = t44.isCallExpression(node);
5062
+ const isCallNode = t48.isCallExpression(node);
4796
5063
  let apiName = "";
4797
- if (t44.isIdentifier(node)) {
5064
+ if (t48.isIdentifier(node)) {
4798
5065
  apiName = node.name;
4799
- } else if (isCallNode && t44.isIdentifier(node.callee)) {
5066
+ } else if (isCallNode && t48.isIdentifier(node.callee)) {
4800
5067
  apiName = node.callee.name;
4801
5068
  }
4802
5069
  if (!apiName) {
@@ -4814,7 +5081,7 @@ function resolveRenameAdapter(ctx) {
4814
5081
  if (adapter.isTrackable) {
4815
5082
  const reactiveType = getReactiveType(apiName);
4816
5083
  const declaratorPath = getVariableDeclaratorPath(path9);
4817
- setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _140 => _140.node]), {
5084
+ setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _162 => _162.node]), {
4818
5085
  is_reactive: true,
4819
5086
  reactive_type: reactiveType
4820
5087
  });
@@ -4857,8 +5124,8 @@ function isVueImportBinding2(binding) {
4857
5124
  if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
4858
5125
  return false;
4859
5126
  }
4860
- const parent = _optionalChain([bindingPath, 'access', _141 => _141.parentPath, 'optionalAccess', _142 => _142.node]);
4861
- if (!parent || !t44.isImportDeclaration(parent)) {
5127
+ const parent = _optionalChain([bindingPath, 'access', _163 => _163.parentPath, 'optionalAccess', _164 => _164.node]);
5128
+ if (!parent || !t48.isImportDeclaration(parent)) {
4862
5129
  return false;
4863
5130
  }
4864
5131
  const source = parent.source.value.toLowerCase();
@@ -4909,12 +5176,12 @@ function processVueSyntax2(ast, ctx) {
4909
5176
  }
4910
5177
  function vueSyntaxProcessor2(ast, ctx, options) {
4911
5178
  const runExcludeThenApply = (cfg) => {
4912
- _optionalChain([cfg, 'access', _143 => _143.excludeBabel, 'optionalAccess', _144 => _144.forEach, 'call', _145 => _145((fn) => fn(ctx, ast))]);
4913
- _optionalChain([cfg, 'access', _146 => _146.applyBabel, 'optionalAccess', _147 => _147.forEach, 'call', _148 => _148((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
5179
+ _optionalChain([cfg, 'access', _165 => _165.excludeBabel, 'optionalAccess', _166 => _166.forEach, 'call', _167 => _167((fn) => fn(ctx, ast))]);
5180
+ _optionalChain([cfg, 'access', _168 => _168.applyBabel, 'optionalAccess', _169 => _169.forEach, 'call', _170 => _170((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
4914
5181
  };
4915
5182
  const runApplyThenExclude = (cfg) => {
4916
- _optionalChain([cfg, 'access', _149 => _149.applyBabel, 'optionalAccess', _150 => _150.forEach, 'call', _151 => _151((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
4917
- _optionalChain([cfg, 'access', _152 => _152.excludeBabel, 'optionalAccess', _153 => _153.forEach, 'call', _154 => _154((fn) => fn(ctx, ast))]);
5183
+ _optionalChain([cfg, 'access', _171 => _171.applyBabel, 'optionalAccess', _172 => _172.forEach, 'call', _173 => _173((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
5184
+ _optionalChain([cfg, 'access', _174 => _174.excludeBabel, 'optionalAccess', _175 => _175.forEach, 'call', _176 => _176((fn) => fn(ctx, ast))]);
4918
5185
  };
4919
5186
  runExcludeThenApply(options.preprocess);
4920
5187
  runExcludeThenApply(options.process);
@@ -5001,50 +5268,50 @@ function isRouterLinkBooleanCustomProp(prop) {
5001
5268
 
5002
5269
 
5003
5270
  var strCodeTypes = {
5004
- isIdentifier: isIdentifier24,
5271
+ isIdentifier: isIdentifier28,
5005
5272
  isSimpleExpression,
5006
- isStringLiteral: isStringLiteral12
5273
+ isStringLiteral: isStringLiteral13
5007
5274
  };
5008
5275
  function isSimpleExpression(code, excludeVar = false) {
5009
5276
  let node;
5010
5277
  try {
5011
5278
  node = _parser.parseExpression.call(void 0, code);
5012
- } catch (e6) {
5279
+ } catch (e7) {
5013
5280
  return false;
5014
5281
  }
5015
- if (t45.isLiteral(node)) {
5282
+ if (t49.isLiteral(node)) {
5016
5283
  return true;
5017
5284
  }
5018
- if (!excludeVar && t45.isIdentifier(node)) {
5285
+ if (!excludeVar && t49.isIdentifier(node)) {
5019
5286
  return true;
5020
5287
  }
5021
- if (t45.isMemberExpression(node)) {
5022
- return isSimpleExpression(node.object) && t45.isIdentifier(node.property);
5288
+ if (t49.isMemberExpression(node)) {
5289
+ return isSimpleExpression(node.object) && t49.isIdentifier(node.property);
5023
5290
  }
5024
- if (t45.isObjectExpression(node) || t45.isArrayExpression(node)) {
5291
+ if (t49.isObjectExpression(node) || t49.isArrayExpression(node)) {
5025
5292
  return false;
5026
5293
  }
5027
- if (t45.isCallExpression(node) || t45.isAssignmentExpression(node)) {
5294
+ if (t49.isCallExpression(node) || t49.isAssignmentExpression(node)) {
5028
5295
  return false;
5029
5296
  }
5030
- if (t45.isBinaryExpression(node) || t45.isUnaryExpression(node)) {
5297
+ if (t49.isBinaryExpression(node) || t49.isUnaryExpression(node)) {
5031
5298
  return true;
5032
5299
  }
5033
5300
  return false;
5034
5301
  }
5035
- function isIdentifier24(code) {
5302
+ function isIdentifier28(code) {
5036
5303
  try {
5037
5304
  const node = _parser.parseExpression.call(void 0, code);
5038
- return t45.isIdentifier(node);
5039
- } catch (e7) {
5305
+ return t49.isIdentifier(node);
5306
+ } catch (e8) {
5040
5307
  return false;
5041
5308
  }
5042
5309
  }
5043
- function isStringLiteral12(code) {
5310
+ function isStringLiteral13(code) {
5044
5311
  try {
5045
5312
  const node = _parser.parseExpression.call(void 0, code);
5046
- return t45.isStringLiteral(node);
5047
- } catch (e8) {
5313
+ return t49.isStringLiteral(node);
5314
+ } catch (e9) {
5048
5315
  return false;
5049
5316
  }
5050
5317
  }
@@ -5153,12 +5420,12 @@ function wrapSingleQuotes(content, condition) {
5153
5420
  return condition || strCodeTypes.isStringLiteral(content) ? `'${content}'` : content;
5154
5421
  }
5155
5422
  function checkPropIsDynamicKey(ctx, node) {
5156
- const isKeyStatic = _optionalChain([node, 'access', _155 => _155.arg, 'optionalAccess', _156 => _156.isStatic]);
5423
+ const isKeyStatic = _optionalChain([node, 'access', _177 => _177.arg, 'optionalAccess', _178 => _178.isStatic]);
5157
5424
  const { source, filename } = ctx;
5158
5425
  if (node.rawName === "v-bind" && !node.name) {
5159
5426
  logger.warn("Keyless v-bind will overwrite all previously declared props at runtime.", {
5160
5427
  source,
5161
- loc: _optionalChain([node, 'access', _157 => _157.arg, 'optionalAccess', _158 => _158.loc]),
5428
+ loc: _optionalChain([node, 'access', _179 => _179.arg, 'optionalAccess', _180 => _180.loc]),
5162
5429
  file: filename
5163
5430
  });
5164
5431
  return;
@@ -5166,7 +5433,7 @@ function checkPropIsDynamicKey(ctx, node) {
5166
5433
  if (isKeyStatic === false) {
5167
5434
  logger.warn("Avoid using dynamic slot names, as they generate complex JSX prop expressions.", {
5168
5435
  source,
5169
- loc: _optionalChain([node, 'access', _159 => _159.arg, 'optionalAccess', _160 => _160.loc]),
5436
+ loc: _optionalChain([node, 'access', _181 => _181.arg, 'optionalAccess', _182 => _182.loc]),
5170
5437
  file: filename
5171
5438
  });
5172
5439
  }
@@ -5185,23 +5452,23 @@ function resolvePropAsBabelExp(ir, ctx) {
5185
5452
  const mergedItems = value.merge;
5186
5453
  const setNameIdentifier = (target, valueName) => {
5187
5454
  target.content = valueName;
5188
- target.ast = t46.jsxIdentifier(valueName);
5455
+ target.ast = t50.jsxIdentifier(valueName);
5189
5456
  };
5190
- const setValueExpression = (target, content, isStringLiteral13) => {
5457
+ const setValueExpression = (target, content, isStringLiteral14) => {
5191
5458
  target.content = content;
5192
- target.ast = resolveStringExpr(content, ctx, isStringLiteral13);
5459
+ target.ast = resolveStringExpr(content, ctx, isStringLiteral14);
5193
5460
  };
5194
5461
  const createRuntimeCall = (fnName, args) => {
5195
5462
  const fnArgs = args.filter(Boolean).join(",");
5196
5463
  return `${fnName}(${fnArgs})`;
5197
5464
  };
5198
- const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral13) => {
5465
+ const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral14) => {
5199
5466
  if (setName && nameIdentifier) {
5200
5467
  setNameIdentifier(nameExp, nameIdentifier);
5201
5468
  }
5202
5469
  const dir = ADAPTER_RULES.runtime.dir;
5203
5470
  recordImport(ctx, dir.package, dir.target);
5204
- setValueExpression(value.babelExp, expression, isStringLiteral13);
5471
+ setValueExpression(value.babelExp, expression, isStringLiteral14);
5205
5472
  };
5206
5473
  if (ir.isKeyLessVBind) {
5207
5474
  const dirKeyless = ADAPTER_RULES.runtime.dirKeyless;
@@ -5211,19 +5478,19 @@ function resolvePropAsBabelExp(ir, ctx) {
5211
5478
  }
5212
5479
  if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
5213
5480
  const dirCls = ADAPTER_RULES.runtime.dirCls;
5214
- const arg = _optionalChain([mergedItems, 'optionalAccess', _161 => _161.join, 'call', _162 => _162(",")]) || wrapSingleQuotes(valueContent);
5481
+ const arg = _optionalChain([mergedItems, 'optionalAccess', _183 => _183.join, 'call', _184 => _184(",")]) || wrapSingleQuotes(valueContent);
5215
5482
  const expression = createRuntimeCall(dirCls.target, [arg]);
5216
5483
  applyRuntimeExpression(expression, true, name);
5217
5484
  return;
5218
5485
  }
5219
- if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _163 => _163.some, 'call', _164 => _164((item) => !isSimpleStyle(item))]))) {
5486
+ if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _185 => _185.some, 'call', _186 => _186((item) => !isSimpleStyle(item))]))) {
5220
5487
  const dirStyle = ADAPTER_RULES.runtime.dirStyle;
5221
- const arg = _optionalChain([mergedItems, 'optionalAccess', _165 => _165.join, 'call', _166 => _166(",")]) || valueContent;
5488
+ const arg = _optionalChain([mergedItems, 'optionalAccess', _187 => _187.join, 'call', _188 => _188(",")]) || valueContent;
5222
5489
  const expression = createRuntimeCall(dirStyle.target, [arg]);
5223
5490
  applyRuntimeExpression(expression, true, name);
5224
5491
  return;
5225
5492
  }
5226
- if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _167 => _167.modifiers, 'optionalAccess', _168 => _168.length])) {
5493
+ if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _189 => _189.modifiers, 'optionalAccess', _190 => _190.length])) {
5227
5494
  const dirOn = ADAPTER_RULES.runtime.dirOn;
5228
5495
  const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
5229
5496
  const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
@@ -5278,7 +5545,7 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
5278
5545
  continue;
5279
5546
  }
5280
5547
  const nodeIR = child;
5281
- if (_optionalChain([parentIR, 'optionalAccess', _169 => _169.isBuiltIn])) {
5548
+ if (_optionalChain([parentIR, 'optionalAccess', _191 => _191.isBuiltIn])) {
5282
5549
  if (parentIR.tag == VUE_API_MAP.Transition) {
5283
5550
  resolveTransitionRules(nodeIR, parentIR, ir, ctx);
5284
5551
  }
@@ -5319,7 +5586,7 @@ function walkElementNodes(node, onElement) {
5319
5586
  }
5320
5587
  function resolveDefaultStyleModuleName(node) {
5321
5588
  const { exp } = node;
5322
- if (_optionalChain([exp, 'optionalAccess', _170 => _170.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
5589
+ if (_optionalChain([exp, 'optionalAccess', _192 => _192.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
5323
5590
  return;
5324
5591
  }
5325
5592
  if (exp.content.includes("$style")) {
@@ -5356,26 +5623,16 @@ function injectStyleScopeAttribute(node, ctx) {
5356
5623
  return;
5357
5624
  }
5358
5625
  let hasScopeId = false;
5359
- let hasClassOrId = false;
5360
5626
  for (const prop of node.props) {
5361
- if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
5362
- if (prop.name === scopeId) {
5363
- hasScopeId = true;
5364
- break;
5365
- }
5366
- if (getHasClassOrId(prop.name)) {
5367
- hasClassOrId = true;
5368
- break;
5369
- }
5627
+ if (prop.type !== _compilercore.NodeTypes.ATTRIBUTE) {
5628
+ continue;
5370
5629
  }
5371
- if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access', _171 => _171.arg, 'optionalAccess', _172 => _172.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
5372
- if (getHasClassOrId(prop.arg.content)) {
5373
- hasClassOrId = true;
5374
- break;
5375
- }
5630
+ if (prop.name === scopeId) {
5631
+ hasScopeId = true;
5632
+ break;
5376
5633
  }
5377
5634
  }
5378
- if (hasScopeId || !hasClassOrId) return;
5635
+ if (hasScopeId) return;
5379
5636
  const attr = {
5380
5637
  type: _compilercore.NodeTypes.ATTRIBUTE,
5381
5638
  name: scopeId,
@@ -5385,9 +5642,6 @@ function injectStyleScopeAttribute(node, ctx) {
5385
5642
  };
5386
5643
  node.props.push(attr);
5387
5644
  }
5388
- function getHasClassOrId(ns) {
5389
- return isClassAttr(ns) || ns === "id";
5390
- }
5391
5645
 
5392
5646
  // src/core/transform/sfc/template/shared/prop-merge-utils.ts
5393
5647
  function mergePropsIR(ctx, oldAttr, newAttr) {
@@ -5428,7 +5682,7 @@ function mergeStyleProps(oldAttr, newAttr) {
5428
5682
  const oldStyle = oldAttr.value.content;
5429
5683
  const newStyle = parseStyleString(newAttr.value.content);
5430
5684
  let merged = oldAttr.value.merge;
5431
- if (!_optionalChain([merged, 'optionalAccess', _173 => _173.length])) {
5685
+ if (!_optionalChain([merged, 'optionalAccess', _193 => _193.length])) {
5432
5686
  merged = oldAttr.value.merge = [oldStyle, newStyle];
5433
5687
  } else {
5434
5688
  merged.push(newStyle);
@@ -5458,7 +5712,7 @@ function warnUnsupportedVueDollarVar(ctx, node) {
5458
5712
  const { source, filename } = ctx;
5459
5713
  let value = "";
5460
5714
  let loc;
5461
- if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _174 => _174.exp, 'optionalAccess', _175 => _175.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
5715
+ if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _194 => _194.exp, 'optionalAccess', _195 => _195.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
5462
5716
  value = node.exp.content;
5463
5717
  loc = node.exp.loc;
5464
5718
  } else if (node.type === _compilercore.NodeTypes.INTERPOLATION && node.content.type === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
@@ -5512,11 +5766,11 @@ function resolveRefProp(prop, ctx, nodeIR) {
5512
5766
  } = ctx;
5513
5767
  let propIR;
5514
5768
  if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
5515
- const tag = _optionalChain([prop, 'access', _176 => _176.value, 'optionalAccess', _177 => _177.content]);
5769
+ const tag = _optionalChain([prop, 'access', _196 => _196.value, 'optionalAccess', _197 => _197.content]);
5516
5770
  if (!tag) return;
5517
5771
  collectComponentRef(tag, ctx);
5518
5772
  const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
5519
- const refVar = _optionalChain([domRefBinding, 'optionalAccess', _178 => _178.name]) || _optionalChain([refBindings, 'access', _179 => _179.componentRefs, 'access', _180 => _180[tag], 'optionalAccess', _181 => _181.name]);
5773
+ const refVar = _optionalChain([domRefBinding, 'optionalAccess', _198 => _198.name]) || _optionalChain([refBindings, 'access', _199 => _199.componentRefs, 'access', _200 => _200[tag], 'optionalAccess', _201 => _201.name]);
5520
5774
  propIR = createPropsIR("ref", "ref", refVar || "null");
5521
5775
  } else {
5522
5776
  const exp = prop.exp;
@@ -5552,14 +5806,30 @@ function collectComponentRef(tag, ctx) {
5552
5806
 
5553
5807
 
5554
5808
 
5555
- function resolveTemplateNodeKey(vueNode, keyContent) {
5556
- const firstNode = vueNode.children[0];
5557
- if (!firstNode) return;
5558
- const hasKeyProp = firstNode.props.some(
5809
+
5810
+ function resolveTemplateNodeKey(templNode, keyContent, ctx) {
5811
+ const { filename, source } = ctx;
5812
+ const { children, loc } = templNode;
5813
+ if (children.length > 1) {
5814
+ logger.warn(
5815
+ "Expected <template> with `:key` to have a single parent element; otherwise, the key cannot be transferred to the first child.",
5816
+ {
5817
+ file: filename,
5818
+ source,
5819
+ loc
5820
+ }
5821
+ );
5822
+ return;
5823
+ }
5824
+ const [firstChild] = children;
5825
+ if (_optionalChain([firstChild, 'optionalAccess', _202 => _202.type]) !== _compilercore.NodeTypes.ELEMENT || firstChild.tagType === _compilercore.ElementTypes.TEMPLATE || firstChild.tagType === _compilercore.ElementTypes.SLOT) {
5826
+ return;
5827
+ }
5828
+ const hasKeyProp = firstChild.props.some(
5559
5829
  (p) => p.type === _compilercore.NodeTypes.DIRECTIVE && p.name === "key"
5560
5830
  );
5561
5831
  if (hasKeyProp) return;
5562
- firstNode.props.push(createSimpleVueBind("key", keyContent));
5832
+ firstChild.props.push(createSimpleVueBind("key", keyContent));
5563
5833
  }
5564
5834
  function createSimpleVueBind(name, value) {
5565
5835
  return {
@@ -5589,8 +5859,8 @@ function createSimpleVueBind(name, value) {
5589
5859
  function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
5590
5860
  const arg = directive.arg;
5591
5861
  const exp = directive.exp;
5592
- const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _182 => _182.content]), () => ( ""));
5593
- const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _183 => _183.content]), () => ( "true"));
5862
+ const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _203 => _203.content]), () => ( ""));
5863
+ const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _204 => _204.content]), () => ( "true"));
5594
5864
  warnUnsupportedVueDollarVar(ctx, directive);
5595
5865
  if (name === "is") {
5596
5866
  resolveDynamicIsProp(directive, ir, ctx, nodeIR);
@@ -5601,11 +5871,11 @@ function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
5601
5871
  return;
5602
5872
  }
5603
5873
  if (vueNode.tag === "template" && name === "key") {
5604
- resolveTemplateNodeKey(vueNode, content);
5874
+ resolveTemplateNodeKey(vueNode, content, ctx);
5605
5875
  return;
5606
5876
  }
5607
5877
  const propIR = createPropsIR(directive.rawName, name, content);
5608
- propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _184 => _184.isStatic]), () => ( true));
5878
+ propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _205 => _205.isStatic]), () => ( true));
5609
5879
  checkPropIsDynamicKey(ctx, directive);
5610
5880
  resolvePropertyIR(propIR, ir, ctx, nodeIR, true);
5611
5881
  }
@@ -5619,12 +5889,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
5619
5889
  content = propsIR.value.content = parseStyleString(content);
5620
5890
  }
5621
5891
  if (isDynamic) {
5622
- const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
5623
- if (isStringLiteral13) {
5892
+ const isStringLiteral14 = strCodeTypes.isStringLiteral(content);
5893
+ if (isStringLiteral14) {
5624
5894
  content = normalizeString(content);
5625
5895
  propsIR.value.content = content;
5626
5896
  }
5627
- propsIR.value.isStringLiteral = isStringLiteral13;
5897
+ propsIR.value.isStringLiteral = isStringLiteral14;
5628
5898
  }
5629
5899
  const existing = findSameProp(nodeIR.props, propsIR);
5630
5900
  if (existing) {
@@ -5644,7 +5914,7 @@ function normalizeString(s) {
5644
5914
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
5645
5915
  function resolveAttributeProp(attribute, ir, ctx, nodeIR) {
5646
5916
  const name = attribute.name;
5647
- const content = _nullishCoalesce(_optionalChain([attribute, 'access', _185 => _185.value, 'optionalAccess', _186 => _186.content]), () => ( "true"));
5917
+ const content = _nullishCoalesce(_optionalChain([attribute, 'access', _206 => _206.value, 'optionalAccess', _207 => _207.content]), () => ( "true"));
5648
5918
  if (name === "is") {
5649
5919
  resolveStaticIsProp(content, ir, ctx, nodeIR);
5650
5920
  return;
@@ -5739,10 +6009,10 @@ function resolveRouterLinkVSlotProp(directive, nodeIR, ctx) {
5739
6009
  type: 2 /* SLOT */,
5740
6010
  name: "customRender",
5741
6011
  rawName: _nullishCoalesce(directive.rawName, () => ( "v-slot")),
5742
- isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _187 => _187.isStatic]), () => ( true)),
6012
+ isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _208 => _208.isStatic]), () => ( true)),
5743
6013
  isScoped: true,
5744
6014
  callback: {
5745
- arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _188 => _188.content, 'optionalAccess', _189 => _189.trim, 'call', _190 => _190()]), () => ( "")),
6015
+ arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _209 => _209.content, 'optionalAccess', _210 => _210.trim, 'call', _211 => _211()]), () => ( "")),
5746
6016
  exp: []
5747
6017
  }
5748
6018
  };
@@ -5758,10 +6028,10 @@ function resolveVFor(directive, ir, ctx, nodeIR) {
5758
6028
  };
5759
6029
  }
5760
6030
  function resolveForResult(forParseResult) {
5761
- const source = _optionalChain([forParseResult, 'access', _191 => _191.source, 'optionalAccess', _192 => _192.content]);
5762
- const value = _optionalChain([forParseResult, 'access', _193 => _193.value, 'optionalAccess', _194 => _194.content]);
5763
- const index = _optionalChain([forParseResult, 'access', _195 => _195.index, 'optionalAccess', _196 => _196.content]);
5764
- const key = _optionalChain([forParseResult, 'access', _197 => _197.key, 'optionalAccess', _198 => _198.content]);
6031
+ const source = _optionalChain([forParseResult, 'access', _212 => _212.source, 'optionalAccess', _213 => _213.content]);
6032
+ const value = _optionalChain([forParseResult, 'access', _214 => _214.value, 'optionalAccess', _215 => _215.content]);
6033
+ const index = _optionalChain([forParseResult, 'access', _216 => _216.index, 'optionalAccess', _217 => _217.content]);
6034
+ const key = _optionalChain([forParseResult, 'access', _218 => _218.key, 'optionalAccess', _219 => _219.content]);
5765
6035
  return {
5766
6036
  source,
5767
6037
  value,
@@ -5781,7 +6051,7 @@ function resolveVHtml(directive, ir, ctx, nodeIR) {
5781
6051
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
5782
6052
  function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
5783
6053
  const name = directive.name === "else-if" ? "elseIf" : directive.name;
5784
- const value = _nullishCoalesce(_optionalChain([directive, 'access', _199 => _199.exp, 'optionalAccess', _200 => _200.content]), () => ( "true"));
6054
+ const value = _nullishCoalesce(_optionalChain([directive, 'access', _220 => _220.exp, 'optionalAccess', _221 => _221.content]), () => ( "true"));
5785
6055
  const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
5786
6056
  const isElseBranch = name === "else" || name === "elseIf";
5787
6057
  let hasError = false;
@@ -5820,7 +6090,7 @@ function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
5820
6090
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
5821
6091
  function resolveVMemo(directive, _ir, ctx, nodeIR) {
5822
6092
  const exp = directive.exp;
5823
- let value = _optionalChain([exp, 'optionalAccess', _201 => _201.content]);
6093
+ let value = _optionalChain([exp, 'optionalAccess', _222 => _222.content]);
5824
6094
  if (value !== void 0) {
5825
6095
  if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
5826
6096
  const { source, filename } = ctx;
@@ -5860,14 +6130,14 @@ function resolveVModel(directive, ir, ctx, vueNode, nodeIR) {
5860
6130
  const getterName = exp.content;
5861
6131
  const isComponent = vueNode.tagType === _compilercore.ElementTypes.COMPONENT;
5862
6132
  const inputType = resolveHtmlInput(vueNode, isComponent);
5863
- const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _202 => _202.content]), () => ( resolveModelPropName(inputType, isComponent)));
6133
+ const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _223 => _223.content]), () => ( resolveModelPropName(inputType, isComponent)));
5864
6134
  let valuePropIR;
5865
6135
  let eventPropIR;
5866
6136
  if (isComponent) {
5867
6137
  valuePropIR = createPropsIR("v-model", propName, getterName);
5868
6138
  const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
5869
6139
  const eventVueName = `update:${propName}`;
5870
- const isTS = _optionalChain([ctx, 'access', _203 => _203.scriptData, 'optionalAccess', _204 => _204.lang, 'optionalAccess', _205 => _205.startsWith, 'call', _206 => _206("ts")]);
6140
+ const isTS = _optionalChain([ctx, 'access', _224 => _224.scriptData, 'optionalAccess', _225 => _225.lang, 'optionalAccess', _226 => _226.startsWith, 'call', _227 => _227("ts")]);
5871
6141
  const valueArg = isTS ? "value: any" : "value";
5872
6142
  const processedValue = applyValueModifiers("value", modifiers);
5873
6143
  const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
@@ -5905,7 +6175,7 @@ function getRadioValue(vueNode) {
5905
6175
  const valueAttr = vueNode.props.find(
5906
6176
  (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
5907
6177
  );
5908
- if (!_optionalChain([valueAttr, 'optionalAccess', _207 => _207.value, 'optionalAccess', _208 => _208.content])) return '""';
6178
+ if (!_optionalChain([valueAttr, 'optionalAccess', _228 => _228.value, 'optionalAccess', _229 => _229.content])) return '""';
5909
6179
  const content = valueAttr.value.content;
5910
6180
  return /^['"]/.test(content) ? content : `"${content}"`;
5911
6181
  }
@@ -5915,7 +6185,7 @@ function resolveHtmlInput(node, isComponent) {
5915
6185
  const typeProp = node.props.find(
5916
6186
  (prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
5917
6187
  );
5918
- return _optionalChain([typeProp, 'optionalAccess', _209 => _209.value, 'optionalAccess', _210 => _210.content, 'optionalAccess', _211 => _211.toLowerCase, 'call', _212 => _212()]);
6188
+ return _optionalChain([typeProp, 'optionalAccess', _230 => _230.value, 'optionalAccess', _231 => _231.content, 'optionalAccess', _232 => _232.toLowerCase, 'call', _233 => _233()]);
5919
6189
  }
5920
6190
  function applyValueModifiers(valueExp, modifiers) {
5921
6191
  let result = valueExp;
@@ -5934,22 +6204,10 @@ function resolveVOn(directive, ir, ctx, nodeIR) {
5934
6204
  const arg = directive.arg;
5935
6205
  const exp = directive.exp;
5936
6206
  const modifiers = directive.modifiers.map((item) => item.content);
5937
- const captureIndex = modifiers.findIndex((modifier) => modifier === "capture");
5938
- let eventName = normalizeVOnEventName(arg.content);
5939
- let handler = resolveSpecialExpression(exp.content.trim(), ctx);
5940
- if (captureIndex > -1) {
5941
- eventName = modifiers[captureIndex] ? `${eventName}Capture` : eventName;
5942
- modifiers.splice(captureIndex, 1);
5943
- }
5944
- let originalVueEventName = "";
5945
- if (modifiers.length) {
5946
- originalVueEventName = `${arg.content}.${modifiers.join(".")}`;
5947
- } else {
5948
- const expr = stringToExpr(handler);
5949
- if (!t47.isFunctionExpression(expr) && !t47.isArrowFunctionExpression(expr) && !t47.isIdentifier(expr)) {
5950
- handler = `() => {${handler}}`;
5951
- }
5952
- }
6207
+ const captureIndex = resolveCaptureModifier(modifiers);
6208
+ const eventName = resolveEventName(arg.content, captureIndex);
6209
+ const handler = resolveHandler(exp.content.trim(), ctx, modifiers);
6210
+ const originalVueEventName = modifiers.length ? `${arg.content}.${modifiers.join(".")}` : "";
5953
6211
  const eventIR = createPropsIR(directive.rawName, eventName, handler);
5954
6212
  eventIR.type = 3 /* EVENT */;
5955
6213
  eventIR.isStatic = arg.isStatic;
@@ -5964,11 +6222,45 @@ function resolveVOn(directive, ir, ctx, nodeIR) {
5964
6222
  }
5965
6223
  nodeIR.props.push(eventIR);
5966
6224
  }
6225
+ function resolveCaptureModifier(modifiers) {
6226
+ const captureIndex = modifiers.findIndex((modifier) => modifier === "capture");
6227
+ if (captureIndex > -1) {
6228
+ modifiers.splice(captureIndex, 1);
6229
+ }
6230
+ return captureIndex;
6231
+ }
6232
+ function resolveEventName(rawEventName, captureIndex) {
6233
+ let eventName = normalizeVOnEventName(rawEventName);
6234
+ if (captureIndex > -1) {
6235
+ eventName = `${eventName}Capture`;
6236
+ }
6237
+ return eventName;
6238
+ }
5967
6239
  function normalizeVOnEventName(rawEventName) {
5968
6240
  const segments = rawEventName.split(/[:-]/g).map((segment) => segment.trim()).filter(Boolean);
5969
6241
  const normalized = segments.map((segment) => capitalize(camelCase(segment))).join("");
5970
6242
  return `on${normalized}`;
5971
6243
  }
6244
+ function resolveHandler(handlerContent, ctx, modifiers) {
6245
+ let handler = resolveSpecialExpression(handlerContent, ctx);
6246
+ if (modifiers.length) {
6247
+ return handler;
6248
+ }
6249
+ const expr = stringToExpr(handler);
6250
+ if (isConsoleCall(expr)) {
6251
+ return "() => {}";
6252
+ }
6253
+ if (!isFnReference(expr)) {
6254
+ handler = `() => {${handler}}`;
6255
+ }
6256
+ return handler;
6257
+ }
6258
+ function isConsoleCall(expr) {
6259
+ return t51.isCallExpression(expr) && t51.isMemberExpression(expr.callee) && t51.isIdentifier(expr.callee.object) && expr.callee.object.name === "console";
6260
+ }
6261
+ function isFnReference(expr) {
6262
+ return t51.isIdentifier(expr) || t51.isMemberExpression(expr) || t51.isFunction(expr);
6263
+ }
5972
6264
 
5973
6265
  // src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
5974
6266
  function resolveVShow(directive, ir, ctx, nodeIR) {
@@ -6000,7 +6292,7 @@ function resolveVSlotProp(directive, ir, ctx) {
6000
6292
  const name = !arg || arg.content === "default" ? "children" : arg.content;
6001
6293
  const content = !isScoped ? [] : void 0;
6002
6294
  const callback = isScoped ? {
6003
- arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _213 => _213.content, 'optionalAccess', _214 => _214.trim, 'call', _215 => _215()]), () => ( "")),
6295
+ arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _234 => _234.content, 'optionalAccess', _235 => _235.trim, 'call', _236 => _236()]), () => ( "")),
6004
6296
  exp: []
6005
6297
  } : void 0;
6006
6298
  checkPropIsDynamicKey(ctx, directive);
@@ -6008,7 +6300,7 @@ function resolveVSlotProp(directive, ir, ctx) {
6008
6300
  type: 2 /* SLOT */,
6009
6301
  name,
6010
6302
  rawName: _nullishCoalesce(directive.rawName, () => ( "default")),
6011
- isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _216 => _216.isStatic]), () => ( true)),
6303
+ isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _237 => _237.isStatic]), () => ( true)),
6012
6304
  isScoped,
6013
6305
  content,
6014
6306
  callback
@@ -6071,7 +6363,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
6071
6363
  if (routerAdapter) {
6072
6364
  if (!ctx.route) ctx.route = true;
6073
6365
  nodeIR.isRoute = true;
6074
- recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _217 => _217.package]), routerAdapter.target);
6366
+ recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _238 => _238.package]), routerAdapter.target);
6075
6367
  }
6076
6368
  resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
6077
6369
  return nodeIR;
@@ -6218,7 +6510,7 @@ function resolveSlotProps(node, ctx) {
6218
6510
  for (const prop of node.props) {
6219
6511
  if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
6220
6512
  const attr = prop.name;
6221
- const value = _optionalChain([prop, 'access', _218 => _218.value, 'optionalAccess', _219 => _219.content, 'access', _220 => _220.trim, 'call', _221 => _221()]);
6513
+ const value = _optionalChain([prop, 'access', _239 => _239.value, 'optionalAccess', _240 => _240.content, 'access', _241 => _241.trim, 'call', _242 => _242()]);
6222
6514
  if (attr === "name" && value) {
6223
6515
  result.name = camelCase(value);
6224
6516
  } else {
@@ -6308,19 +6600,19 @@ function resolveTemplate2(root, ctx) {
6308
6600
  // src/core/transform/sfc/index.ts
6309
6601
  function transform(ast, ctx, options) {
6310
6602
  const { template, script, style } = ast;
6311
- const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _222 => _222.ast]), ctx);
6312
- const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _223 => _223.ast]), ctx);
6603
+ const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _243 => _243.ast]), ctx);
6604
+ const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _244 => _244.ast]), ctx);
6313
6605
  const result = {
6314
6606
  template: templateIR,
6315
6607
  script: scriptIR,
6316
- style: _optionalChain([style, 'optionalAccess', _224 => _224.source, 'optionalAccess', _225 => _225.content])
6608
+ style: _optionalChain([style, 'optionalAccess', _245 => _245.source, 'optionalAccess', _246 => _246.content])
6317
6609
  };
6318
- executePlugins(_optionalChain([options, 'optionalAccess', _226 => _226.plugins]), result, ctx);
6610
+ executePlugins(_optionalChain([options, 'optionalAccess', _247 => _247.plugins]), result, ctx);
6319
6611
  return result;
6320
6612
  }
6321
6613
 
6322
6614
  // package.json
6323
- var version = "1.6.1";
6615
+ var version = "1.7.0";
6324
6616
  var bin = {
6325
6617
  vureact: "./bin/vureact.js"
6326
6618
  };
@@ -6353,7 +6645,7 @@ async function formatWithPrettier(code, lang, opts) {
6353
6645
  ...opts,
6354
6646
  parser
6355
6647
  });
6356
- } catch (e9) {
6648
+ } catch (e10) {
6357
6649
  logger.info("Prettier is unavailable; the built-in simple formatter is used.");
6358
6650
  return simpleFormat(code);
6359
6651
  }
@@ -6403,7 +6695,7 @@ var FileLockManager = class _FileLockManager {
6403
6695
  if (content.trim()) {
6404
6696
  try {
6405
6697
  current = JSON.parse(content);
6406
- } catch (e10) {
6698
+ } catch (e11) {
6407
6699
  current = content;
6408
6700
  }
6409
6701
  }
@@ -6436,7 +6728,7 @@ var FileLockManager = class _FileLockManager {
6436
6728
  await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
6437
6729
  try {
6438
6730
  await _fs2.default.promises.access(filePath);
6439
- } catch (e11) {
6731
+ } catch (e12) {
6440
6732
  await this.writeFile(filePath, "");
6441
6733
  }
6442
6734
  const release = await _properlockfile2.default.lock(filePath, {
@@ -6461,7 +6753,7 @@ var FileLockManager = class _FileLockManager {
6461
6753
  const { stale = 1e4, realpath = true, lockfilePath } = options;
6462
6754
  try {
6463
6755
  return await _properlockfile2.default.check(filePath, { stale, realpath, lockfilePath });
6464
- } catch (e12) {
6756
+ } catch (e13) {
6465
6757
  return false;
6466
6758
  }
6467
6759
  }
@@ -6483,7 +6775,7 @@ var FileLockManager = class _FileLockManager {
6483
6775
  lockfilePath
6484
6776
  });
6485
6777
  return release;
6486
- } catch (e13) {
6778
+ } catch (e14) {
6487
6779
  return null;
6488
6780
  }
6489
6781
  }
@@ -6496,7 +6788,7 @@ var FileLockManager = class _FileLockManager {
6496
6788
  const { realpath = true, lockfilePath } = options;
6497
6789
  try {
6498
6790
  await _properlockfile2.default.unlock(filePath, { realpath, lockfilePath });
6499
- } catch (e14) {
6791
+ } catch (e15) {
6500
6792
  }
6501
6793
  }
6502
6794
  async writeFile(filePath, content) {
@@ -6514,7 +6806,7 @@ var Helper = (_class5 = class {
6514
6806
  __init8() {this.outDir = "react-app"}
6515
6807
  constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
6516
6808
  this.compilerOpts = opts;
6517
- if (_optionalChain([opts, 'access', _227 => _227.output, 'optionalAccess', _228 => _228.workspace])) {
6809
+ if (_optionalChain([opts, 'access', _248 => _248.output, 'optionalAccess', _249 => _249.workspace])) {
6518
6810
  this.workspaceDir = opts.output.workspace;
6519
6811
  }
6520
6812
  const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
@@ -6551,7 +6843,7 @@ var Helper = (_class5 = class {
6551
6843
  }
6552
6844
  getOutDirName() {
6553
6845
  const { output } = this.compilerOpts;
6554
- return _optionalChain([output, 'optionalAccess', _229 => _229.outDir]) || this.outDir;
6846
+ return _optionalChain([output, 'optionalAccess', _250 => _250.outDir]) || this.outDir;
6555
6847
  }
6556
6848
  getWorkspaceDir() {
6557
6849
  return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
@@ -6565,7 +6857,7 @@ var Helper = (_class5 = class {
6565
6857
  }
6566
6858
  getIgnoreAssets() {
6567
6859
  const { output } = this.compilerOpts;
6568
- if (_optionalChain([output, 'optionalAccess', _230 => _230.ignoreAssets])) {
6860
+ if (_optionalChain([output, 'optionalAccess', _251 => _251.ignoreAssets])) {
6569
6861
  return new Set(output.ignoreAssets.map(normalizePath));
6570
6862
  }
6571
6863
  return /* @__PURE__ */ new Set([
@@ -6648,12 +6940,12 @@ var Helper = (_class5 = class {
6648
6940
  */
6649
6941
  async formatCode({ code, fileInfo }) {
6650
6942
  const { format } = this.compilerOpts;
6651
- if (!_optionalChain([format, 'optionalAccess', _231 => _231.enabled])) return code;
6652
- if (_optionalChain([format, 'optionalAccess', _232 => _232.formatter]) === "builtin") {
6943
+ if (!_optionalChain([format, 'optionalAccess', _252 => _252.enabled])) return code;
6944
+ if (_optionalChain([format, 'optionalAccess', _253 => _253.formatter]) === "builtin") {
6653
6945
  return simpleFormat(code);
6654
6946
  }
6655
- const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _233 => _233.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _234 => _234.script])));
6656
- return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _235 => _235.prettierOptions]));
6947
+ const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _254 => _254.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _255 => _255.script])));
6948
+ return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _256 => _256.prettierOptions]));
6657
6949
  }
6658
6950
  /**
6659
6951
  * 通用的缓存校验工具函数
@@ -6687,7 +6979,7 @@ var Helper = (_class5 = class {
6687
6979
  * @param options.lock - 是否启用文件锁(默认false)
6688
6980
  */
6689
6981
  async writeFileWithDir(filePath, content, options) {
6690
- if (_optionalChain([options, 'optionalAccess', _236 => _236.lock])) {
6982
+ if (_optionalChain([options, 'optionalAccess', _257 => _257.lock])) {
6691
6983
  await fileLock.updateFile(filePath, async () => content, options);
6692
6984
  } else {
6693
6985
  await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
@@ -6697,7 +6989,7 @@ var Helper = (_class5 = class {
6697
6989
  async rmFile(filePath) {
6698
6990
  try {
6699
6991
  await _fs2.default.promises.rm(filePath, { recursive: true, force: true });
6700
- } catch (e15) {
6992
+ } catch (e16) {
6701
6993
  }
6702
6994
  }
6703
6995
  async loadCache(key) {
@@ -6714,7 +7006,7 @@ var Helper = (_class5 = class {
6714
7006
  target: data[key] || [],
6715
7007
  source: data
6716
7008
  };
6717
- } catch (e16) {
7009
+ } catch (e17) {
6718
7010
  return defaultData;
6719
7011
  }
6720
7012
  }
@@ -6812,7 +7104,7 @@ var Helper = (_class5 = class {
6812
7104
  * 获取需要排除编译的文件
6813
7105
  */
6814
7106
  getExcludes() {
6815
- if (!_optionalChain([this, 'access', _237 => _237.compilerOpts, 'access', _238 => _238.exclude, 'optionalAccess', _239 => _239.length])) {
7107
+ if (!_optionalChain([this, 'access', _258 => _258.compilerOpts, 'access', _259 => _259.exclude, 'optionalAccess', _260 => _260.length])) {
6816
7108
  return PathFilter.withDefaults();
6817
7109
  }
6818
7110
  return this.compilerOpts.exclude;
@@ -6910,7 +7202,7 @@ function parseOnlyStyle(source, ctx, options) {
6910
7202
  ast: void 0
6911
7203
  }
6912
7204
  };
6913
- executePlugins(_optionalChain([options, 'optionalAccess', _240 => _240.plugins]), result, ctx);
7205
+ executePlugins(_optionalChain([options, 'optionalAccess', _261 => _261.plugins]), result, ctx);
6914
7206
  return result;
6915
7207
  }
6916
7208
 
@@ -6934,7 +7226,7 @@ var CompilationContext = (_class6 = class {constructor() { _class6.prototype.__i
6934
7226
  }
6935
7227
  create() {
6936
7228
  return {
6937
- fileId: "",
7229
+ fileId: Date.now().toString(),
6938
7230
  source: "",
6939
7231
  filename: "",
6940
7232
  imports: /* @__PURE__ */ new Map(),
@@ -7044,16 +7336,16 @@ var BaseCompiler = (_class7 = class extends Helper {
7044
7336
  });
7045
7337
  const genOptions = this.prepareGenerateOptions(filename);
7046
7338
  const resolveSFCAndScriptFile = () => {
7047
- const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _241 => _241.parser]) });
7048
- const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _242 => _242.transformer]) });
7339
+ const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _262 => _262.parser]) });
7340
+ const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _263 => _263.transformer]) });
7049
7341
  const gen = generate(ir, ctx.data, {
7050
7342
  ...genOptions,
7051
- plugins: _optionalChain([plugins, 'optionalAccess', _243 => _243.codegen])
7343
+ plugins: _optionalChain([plugins, 'optionalAccess', _264 => _264.codegen])
7052
7344
  });
7053
7345
  return this.resolveMainResult(ir, gen, ctx.data);
7054
7346
  };
7055
7347
  const resolveStyleFile = () => {
7056
- const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _244 => _244.parser]) });
7348
+ const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _265 => _265.parser]) });
7057
7349
  return this.resolveStyleResult(result, ctx.data);
7058
7350
  };
7059
7351
  try {
@@ -7092,9 +7384,9 @@ var BaseCompiler = (_class7 = class extends Helper {
7092
7384
  lang
7093
7385
  },
7094
7386
  css: {
7095
- file: _optionalChain([styleData, 'optionalAccess', _245 => _245.filePath]),
7096
- hash: _optionalChain([styleData, 'optionalAccess', _246 => _246.scopeId]),
7097
- code: _optionalChain([ir, 'optionalAccess', _247 => _247.style])
7387
+ file: _optionalChain([styleData, 'optionalAccess', _266 => _266.filePath]),
7388
+ hash: _optionalChain([styleData, 'optionalAccess', _267 => _267.scopeId]),
7389
+ code: _optionalChain([ir, 'optionalAccess', _268 => _268.style])
7098
7390
  }
7099
7391
  },
7100
7392
  ...base
@@ -7164,7 +7456,7 @@ var AssetManager = (_class8 = class {
7164
7456
  const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
7165
7457
  const filename = _path2.default.basename(p).toLowerCase();
7166
7458
  const ext = _path2.default.extname(p).toLowerCase();
7167
- if (!_optionalChain([options, 'access', _248 => _248.output, 'optionalAccess', _249 => _249.ignoreAssets])) {
7459
+ if (!_optionalChain([options, 'access', _269 => _269.output, 'optionalAccess', _270 => _270.ignoreAssets])) {
7168
7460
  const shouldExclude = Array.from(exclusions).some((pattern) => {
7169
7461
  if (pattern.endsWith(".")) {
7170
7462
  return filename.startsWith(pattern);
@@ -7261,12 +7553,12 @@ var CacheManager = (_class9 = class {
7261
7553
  const meta = { ...unit };
7262
7554
  delete meta.source;
7263
7555
  if (key === "sfc" /* SFC */) {
7264
- _optionalChainDelete([meta, 'access', _250 => _250.output, 'optionalAccess', _251 => _251.jsx, 'access', _252 => delete _252.code]);
7265
- _optionalChainDelete([meta, 'access', _253 => _253.output, 'optionalAccess', _254 => _254.css, 'access', _255 => delete _255.code]);
7556
+ _optionalChainDelete([meta, 'access', _271 => _271.output, 'optionalAccess', _272 => _272.jsx, 'access', _273 => delete _273.code]);
7557
+ _optionalChainDelete([meta, 'access', _274 => _274.output, 'optionalAccess', _275 => _275.css, 'access', _276 => delete _276.code]);
7266
7558
  } else if (key === "script" /* SCRIPT */) {
7267
- _optionalChainDelete([meta, 'access', _256 => _256.output, 'optionalAccess', _257 => _257.script, 'access', _258 => delete _258.code]);
7559
+ _optionalChainDelete([meta, 'access', _277 => _277.output, 'optionalAccess', _278 => _278.script, 'access', _279 => delete _279.code]);
7268
7560
  } else if (key === "style" /* STYLE */) {
7269
- _optionalChainDelete([meta, 'access', _259 => _259.output, 'optionalAccess', _260 => _260.style, 'access', _261 => delete _261.code]);
7561
+ _optionalChainDelete([meta, 'access', _280 => _280.output, 'optionalAccess', _281 => _281.style, 'access', _282 => delete _282.code]);
7270
7562
  }
7271
7563
  if (!this.pendingUpdates.has(key)) {
7272
7564
  this.pendingUpdates.set(key, []);
@@ -7336,7 +7628,7 @@ var CleanupManager = class {
7336
7628
  meta = m;
7337
7629
  const { jsx, css } = meta.output;
7338
7630
  await this.fileCompiler.removeOutputFile(jsx.file);
7339
- if (_optionalChain([css, 'optionalAccess', _262 => _262.file])) {
7631
+ if (_optionalChain([css, 'optionalAccess', _283 => _283.file])) {
7340
7632
  await this.fileCompiler.removeOutputFile(css.file);
7341
7633
  }
7342
7634
  break;
@@ -7397,7 +7689,7 @@ var CompilationUnitProcessor = class {
7397
7689
  const isScriptFile = key === "script" /* SCRIPT */;
7398
7690
  const isStyleFile = key === "style" /* STYLE */;
7399
7691
  if (isSFC || isScriptFile) {
7400
- unit.hasRoute = _optionalChain([result, 'optionalAccess', _263 => _263.hasRoute]);
7692
+ unit.hasRoute = _optionalChain([result, 'optionalAccess', _284 => _284.hasRoute]);
7401
7693
  }
7402
7694
  const resolveFileInfo = () => {
7403
7695
  if (isSFC) {
@@ -7417,7 +7709,7 @@ var CompilationUnitProcessor = class {
7417
7709
  const { script } = result.fileInfo;
7418
7710
  unit.output = {
7419
7711
  script: {
7420
- file: _optionalChain([script, 'optionalAccess', _264 => _264.file]),
7712
+ file: _optionalChain([script, 'optionalAccess', _285 => _285.file]),
7421
7713
  code
7422
7714
  }
7423
7715
  };
@@ -7494,7 +7786,7 @@ var FileProcessor = (_class10 = class {
7494
7786
  const absPath = this.fileCompiler.getAbsPath(filePath);
7495
7787
  const fileMeta = await this.fileCompiler.getFileMeta(absPath);
7496
7788
  const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
7497
- const record = _optionalChain([cache, 'optionalAccess', _265 => _265.target, 'access', _266 => _266.find, 'call', _267 => _267((c) => c.file === absPath)]);
7789
+ const record = _optionalChain([cache, 'optionalAccess', _286 => _286.target, 'access', _287 => _287.find, 'call', _288 => _288((c) => c.file === absPath)]);
7498
7790
  const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
7499
7791
  fileMeta,
7500
7792
  record,
@@ -7516,10 +7808,10 @@ var FileProcessor = (_class10 = class {
7516
7808
  hash: hash || this.fileCompiler.genHash(source)
7517
7809
  };
7518
7810
  const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
7519
- if (_optionalChain([processed, 'optionalAccess', _268 => _268.output])) {
7811
+ if (_optionalChain([processed, 'optionalAccess', _289 => _289.output])) {
7520
7812
  await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
7521
7813
  if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
7522
- if (_optionalChain([processed, 'optionalAccess', _269 => _269.hasRoute])) {
7814
+ if (_optionalChain([processed, 'optionalAccess', _290 => _290.hasRoute])) {
7523
7815
  await this.addRouterToPackageJson();
7524
7816
  await this.updateEntryWithRouterProvider();
7525
7817
  }
@@ -7533,13 +7825,13 @@ var FileProcessor = (_class10 = class {
7533
7825
  */
7534
7826
  async addRouterToPackageJson() {
7535
7827
  const { output } = this.fileCompiler.options;
7536
- if (_optionalChain([output, 'optionalAccess', _270 => _270.bootstrapVite]) === false) {
7828
+ if (_optionalChain([output, 'optionalAccess', _291 => _291.bootstrapVite]) === false) {
7537
7829
  return;
7538
7830
  }
7539
7831
  const { router } = RUNTIME_PACKAGES;
7540
7832
  const filePath = this.fileCompiler.getOutputPkgPath();
7541
7833
  const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
7542
- if (_optionalChain([packageJson, 'optionalAccess', _271 => _271.dependencies, 'optionalAccess', _272 => _272[router.name]])) {
7834
+ if (_optionalChain([packageJson, 'optionalAccess', _292 => _292.dependencies, 'optionalAccess', _293 => _293[router.name]])) {
7543
7835
  return;
7544
7836
  }
7545
7837
  if (!packageJson.dependencies) {
@@ -7558,14 +7850,14 @@ var FileProcessor = (_class10 = class {
7558
7850
  const { exclude, output, router } = this.fileCompiler.options;
7559
7851
  const inputPath = this.fileCompiler.getInputPath();
7560
7852
  const outputPath = this.fileCompiler.getOuputPath(true);
7561
- if (_optionalChain([output, 'optionalAccess', _273 => _273.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _274 => _274.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _275 => _275.configFile])) {
7853
+ if (_optionalChain([output, 'optionalAccess', _294 => _294.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _295 => _295.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _296 => _296.configFile])) {
7562
7854
  return;
7563
7855
  }
7564
7856
  const getMainFile = async (filename) => {
7565
7857
  const filePath = _path2.default.resolve(outputPath, filename);
7566
7858
  try {
7567
7859
  return { filePath, content: await _fs2.default.promises.readFile(filePath, "utf-8") };
7568
- } catch (e17) {
7860
+ } catch (e18) {
7569
7861
  return;
7570
7862
  }
7571
7863
  };
@@ -7579,7 +7871,7 @@ var FileProcessor = (_class10 = class {
7579
7871
  const prepareRouterEntry = () => {
7580
7872
  const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
7581
7873
  let content = fileData.content;
7582
- if (_optionalChain([exclude, 'optionalAccess', _276 => _276.includes, 'call', _277 => _277(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _278 => _278.includes, 'call', _279 => _279(importPath)])) {
7874
+ if (_optionalChain([exclude, 'optionalAccess', _297 => _297.includes, 'call', _298 => _298(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _299 => _299.includes, 'call', _300 => _300(importPath)])) {
7583
7875
  return content;
7584
7876
  }
7585
7877
  const routerModule = "RouterInstance";
@@ -7725,7 +8017,7 @@ var ViteBootstrapper = (_class12 = class {
7725
8017
  const { output } = this.options;
7726
8018
  const workspaceDir = this.fileCompiler.getWorkspaceDir();
7727
8019
  await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
7728
- if (_optionalChain([output, 'optionalAccess', _280 => _280.bootstrapVite]) === false) {
8020
+ if (_optionalChain([output, 'optionalAccess', _301 => _301.bootstrapVite]) === false) {
7729
8021
  return false;
7730
8022
  }
7731
8023
  if (this.isSingleFile()) {
@@ -7775,7 +8067,7 @@ var ViteBootstrapper = (_class12 = class {
7775
8067
  const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
7776
8068
  newPkg.dependencies = newDeps;
7777
8069
  newPkg.devDependencies = newDevDeps;
7778
- newPkg = _optionalChain([output, 'optionalAccess', _281 => _281.packageJson, 'optionalCall', _282 => _282(newPkg)]) || newPkg;
8070
+ newPkg = _optionalChain([output, 'optionalAccess', _302 => _302.packageJson, 'optionalCall', _303 => _303(newPkg)]) || newPkg;
7779
8071
  await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
7780
8072
  this.spinner.succeed("Standard Vite React environment initialized");
7781
8073
  return true;
@@ -7786,12 +8078,12 @@ var ViteBootstrapper = (_class12 = class {
7786
8078
  async resolveViteCreateApp() {
7787
8079
  const { output } = this.options;
7788
8080
  const { viteVersion, template: tmpl } = this.defaultConfig;
7789
- const bootstrapVite = _optionalChain([output, 'optionalAccess', _283 => _283.bootstrapVite]);
8081
+ const bootstrapVite = _optionalChain([output, 'optionalAccess', _304 => _304.bootstrapVite]);
7790
8082
  const outDirName = this.fileCompiler.getOutDirName();
7791
8083
  const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
7792
- const viteVer = _optionalChain([configObject, 'optionalAccess', _284 => _284.vite]) || viteVersion;
7793
- const reactVer = _optionalChain([configObject, 'optionalAccess', _285 => _285.react]);
7794
- const template = _optionalChain([configObject, 'optionalAccess', _286 => _286.template]) || tmpl;
8084
+ const viteVer = _optionalChain([configObject, 'optionalAccess', _305 => _305.vite]) || viteVersion;
8085
+ const reactVer = _optionalChain([configObject, 'optionalAccess', _306 => _306.react]);
8086
+ const template = _optionalChain([configObject, 'optionalAccess', _307 => _307.template]) || tmpl;
7795
8087
  const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
7796
8088
  _child_process.execSync.call(void 0, cmd, {
7797
8089
  cwd: this.fileCompiler.getWorkspaceDir(),
@@ -7895,7 +8187,7 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
7895
8187
  const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
7896
8188
  const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
7897
8189
  const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
7898
- await _optionalChain([this, 'access', _287 => _287.options, 'access', _288 => _288.onSuccess, 'optionalCall', _289 => _289()]);
8190
+ await _optionalChain([this, 'access', _308 => _308.options, 'access', _309 => _309.onSuccess, 'optionalCall', _310 => _310()]);
7899
8191
  const endTime = calcElapsedTime(startTime);
7900
8192
  this.printCoreLogs();
7901
8193
  this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);