@vureact/compiler-core 1.6.2 → 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.
- package/README.en.md +20 -235
- package/README.md +21 -236
- package/lib/{chunk-FLZ5AUPG.js → chunk-Q36XF5TP.js} +749 -473
- package/lib/{chunk-SRBJ5B5X.esm.js → chunk-Q7HZAZHD.esm.js} +625 -349
- package/lib/cli.esm.js +2 -2
- package/lib/cli.js +10 -10
- package/lib/compiler-core.esm.js +2 -2
- package/lib/compiler-core.js +3 -3
- package/package.json +2 -1
|
@@ -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.
|
|
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
|
|
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 = {
|
|
@@ -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 (
|
|
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 (
|
|
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 (
|
|
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:
|
|
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 =
|
|
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 (
|
|
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-
|
|
2667
|
+
postcssPlugin: "postcss-scoped-vureact",
|
|
2418
2668
|
Rule(rule) {
|
|
2419
|
-
if (rule
|
|
2669
|
+
if (isRuleIgnored(rule)) {
|
|
2420
2670
|
return;
|
|
2421
2671
|
}
|
|
2422
|
-
rule.selectors = rule.selectors.map(
|
|
2423
|
-
|
|
2424
|
-
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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
|
-
|
|
3122
|
-
if (
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
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',
|
|
3250
|
-
if (_optionalChain([tsParams, 'optionalAccess',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
3551
|
-
if (_optionalChain([tsParams, 'optionalAccess',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
4011
|
-
if (!_optionalChain([tsParams, 'optionalAccess',
|
|
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
|
|
4634
|
+
return t42.arrayExpression([]);
|
|
4166
4635
|
}
|
|
4167
|
-
const isFnExpr =
|
|
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 (
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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 =
|
|
4730
|
+
const isCallNode = t43.isCallExpression(node);
|
|
4465
4731
|
let apiName = "";
|
|
4466
|
-
if (
|
|
4732
|
+
if (t43.isIdentifier(node)) {
|
|
4467
4733
|
apiName = node.name;
|
|
4468
|
-
} else if (isCallNode &&
|
|
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 (!
|
|
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',
|
|
4510
|
-
if (!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',
|
|
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',
|
|
4596
|
-
if (!
|
|
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] =
|
|
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',
|
|
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 =
|
|
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 || !
|
|
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',
|
|
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 (!
|
|
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 (!
|
|
4926
|
+
if (!t45.isVariableDeclaration(path9.parent) || path9.parent.kind !== "const") {
|
|
4661
4927
|
return false;
|
|
4662
4928
|
}
|
|
4663
|
-
if (
|
|
4664
|
-
if (
|
|
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 (!
|
|
4955
|
+
if (!t46.isIdentifier(node.callee)) return;
|
|
4689
4956
|
const { name: callName } = node.callee;
|
|
4690
|
-
const addLog = (
|
|
4691
|
-
logger.error(
|
|
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',
|
|
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',
|
|
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 (
|
|
5035
|
+
if (t47.isStringLiteral(exp)) {
|
|
4769
5036
|
return JSON.stringify(exp.value);
|
|
4770
5037
|
}
|
|
4771
|
-
if (
|
|
5038
|
+
if (t47.isNumericLiteral(exp)) {
|
|
4772
5039
|
return exp.value.toString();
|
|
4773
5040
|
}
|
|
4774
|
-
if (
|
|
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 (
|
|
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 =
|
|
5062
|
+
const isCallNode = t48.isCallExpression(node);
|
|
4796
5063
|
let apiName = "";
|
|
4797
|
-
if (
|
|
5064
|
+
if (t48.isIdentifier(node)) {
|
|
4798
5065
|
apiName = node.name;
|
|
4799
|
-
} else if (isCallNode &&
|
|
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',
|
|
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',
|
|
4861
|
-
if (!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',
|
|
4913
|
-
_optionalChain([cfg, 'access',
|
|
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',
|
|
4917
|
-
_optionalChain([cfg, 'access',
|
|
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:
|
|
5271
|
+
isIdentifier: isIdentifier28,
|
|
5005
5272
|
isSimpleExpression,
|
|
5006
|
-
isStringLiteral:
|
|
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 (
|
|
5279
|
+
} catch (e7) {
|
|
5013
5280
|
return false;
|
|
5014
5281
|
}
|
|
5015
|
-
if (
|
|
5282
|
+
if (t49.isLiteral(node)) {
|
|
5016
5283
|
return true;
|
|
5017
5284
|
}
|
|
5018
|
-
if (!excludeVar &&
|
|
5285
|
+
if (!excludeVar && t49.isIdentifier(node)) {
|
|
5019
5286
|
return true;
|
|
5020
5287
|
}
|
|
5021
|
-
if (
|
|
5022
|
-
return isSimpleExpression(node.object) &&
|
|
5288
|
+
if (t49.isMemberExpression(node)) {
|
|
5289
|
+
return isSimpleExpression(node.object) && t49.isIdentifier(node.property);
|
|
5023
5290
|
}
|
|
5024
|
-
if (
|
|
5291
|
+
if (t49.isObjectExpression(node) || t49.isArrayExpression(node)) {
|
|
5025
5292
|
return false;
|
|
5026
5293
|
}
|
|
5027
|
-
if (
|
|
5294
|
+
if (t49.isCallExpression(node) || t49.isAssignmentExpression(node)) {
|
|
5028
5295
|
return false;
|
|
5029
5296
|
}
|
|
5030
|
-
if (
|
|
5297
|
+
if (t49.isBinaryExpression(node) || t49.isUnaryExpression(node)) {
|
|
5031
5298
|
return true;
|
|
5032
5299
|
}
|
|
5033
5300
|
return false;
|
|
5034
5301
|
}
|
|
5035
|
-
function
|
|
5302
|
+
function isIdentifier28(code) {
|
|
5036
5303
|
try {
|
|
5037
5304
|
const node = _parser.parseExpression.call(void 0, code);
|
|
5038
|
-
return
|
|
5039
|
-
} catch (
|
|
5305
|
+
return t49.isIdentifier(node);
|
|
5306
|
+
} catch (e8) {
|
|
5040
5307
|
return false;
|
|
5041
5308
|
}
|
|
5042
5309
|
}
|
|
5043
|
-
function
|
|
5310
|
+
function isStringLiteral13(code) {
|
|
5044
5311
|
try {
|
|
5045
5312
|
const node = _parser.parseExpression.call(void 0, code);
|
|
5046
|
-
return
|
|
5047
|
-
} catch (
|
|
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',
|
|
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',
|
|
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',
|
|
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 =
|
|
5455
|
+
target.ast = t50.jsxIdentifier(valueName);
|
|
5189
5456
|
};
|
|
5190
|
-
const setValueExpression = (target, content,
|
|
5457
|
+
const setValueExpression = (target, content, isStringLiteral14) => {
|
|
5191
5458
|
target.content = content;
|
|
5192
|
-
target.ast = resolveStringExpr(content, ctx,
|
|
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,
|
|
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,
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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
|
|
5362
|
-
|
|
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.
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
break;
|
|
5375
|
-
}
|
|
5630
|
+
if (prop.name === scopeId) {
|
|
5631
|
+
hasScopeId = true;
|
|
5632
|
+
break;
|
|
5376
5633
|
}
|
|
5377
5634
|
}
|
|
5378
|
-
if (hasScopeId
|
|
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',
|
|
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',
|
|
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',
|
|
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',
|
|
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;
|
|
@@ -5568,7 +5822,7 @@ function resolveTemplateNodeKey(templNode, keyContent, ctx) {
|
|
|
5568
5822
|
return;
|
|
5569
5823
|
}
|
|
5570
5824
|
const [firstChild] = children;
|
|
5571
|
-
if (_optionalChain([firstChild, 'optionalAccess',
|
|
5825
|
+
if (_optionalChain([firstChild, 'optionalAccess', _202 => _202.type]) !== _compilercore.NodeTypes.ELEMENT || firstChild.tagType === _compilercore.ElementTypes.TEMPLATE || firstChild.tagType === _compilercore.ElementTypes.SLOT) {
|
|
5572
5826
|
return;
|
|
5573
5827
|
}
|
|
5574
5828
|
const hasKeyProp = firstChild.props.some(
|
|
@@ -5605,8 +5859,8 @@ function createSimpleVueBind(name, value) {
|
|
|
5605
5859
|
function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
|
|
5606
5860
|
const arg = directive.arg;
|
|
5607
5861
|
const exp = directive.exp;
|
|
5608
|
-
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5609
|
-
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5862
|
+
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _203 => _203.content]), () => ( ""));
|
|
5863
|
+
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _204 => _204.content]), () => ( "true"));
|
|
5610
5864
|
warnUnsupportedVueDollarVar(ctx, directive);
|
|
5611
5865
|
if (name === "is") {
|
|
5612
5866
|
resolveDynamicIsProp(directive, ir, ctx, nodeIR);
|
|
@@ -5621,7 +5875,7 @@ function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
|
|
|
5621
5875
|
return;
|
|
5622
5876
|
}
|
|
5623
5877
|
const propIR = createPropsIR(directive.rawName, name, content);
|
|
5624
|
-
propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5878
|
+
propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _205 => _205.isStatic]), () => ( true));
|
|
5625
5879
|
checkPropIsDynamicKey(ctx, directive);
|
|
5626
5880
|
resolvePropertyIR(propIR, ir, ctx, nodeIR, true);
|
|
5627
5881
|
}
|
|
@@ -5635,12 +5889,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
|
|
|
5635
5889
|
content = propsIR.value.content = parseStyleString(content);
|
|
5636
5890
|
}
|
|
5637
5891
|
if (isDynamic) {
|
|
5638
|
-
const
|
|
5639
|
-
if (
|
|
5892
|
+
const isStringLiteral14 = strCodeTypes.isStringLiteral(content);
|
|
5893
|
+
if (isStringLiteral14) {
|
|
5640
5894
|
content = normalizeString(content);
|
|
5641
5895
|
propsIR.value.content = content;
|
|
5642
5896
|
}
|
|
5643
|
-
propsIR.value.isStringLiteral =
|
|
5897
|
+
propsIR.value.isStringLiteral = isStringLiteral14;
|
|
5644
5898
|
}
|
|
5645
5899
|
const existing = findSameProp(nodeIR.props, propsIR);
|
|
5646
5900
|
if (existing) {
|
|
@@ -5660,7 +5914,7 @@ function normalizeString(s) {
|
|
|
5660
5914
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
|
|
5661
5915
|
function resolveAttributeProp(attribute, ir, ctx, nodeIR) {
|
|
5662
5916
|
const name = attribute.name;
|
|
5663
|
-
const content = _nullishCoalesce(_optionalChain([attribute, 'access',
|
|
5917
|
+
const content = _nullishCoalesce(_optionalChain([attribute, 'access', _206 => _206.value, 'optionalAccess', _207 => _207.content]), () => ( "true"));
|
|
5664
5918
|
if (name === "is") {
|
|
5665
5919
|
resolveStaticIsProp(content, ir, ctx, nodeIR);
|
|
5666
5920
|
return;
|
|
@@ -5755,10 +6009,10 @@ function resolveRouterLinkVSlotProp(directive, nodeIR, ctx) {
|
|
|
5755
6009
|
type: 2 /* SLOT */,
|
|
5756
6010
|
name: "customRender",
|
|
5757
6011
|
rawName: _nullishCoalesce(directive.rawName, () => ( "v-slot")),
|
|
5758
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
6012
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _208 => _208.isStatic]), () => ( true)),
|
|
5759
6013
|
isScoped: true,
|
|
5760
6014
|
callback: {
|
|
5761
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
6015
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _209 => _209.content, 'optionalAccess', _210 => _210.trim, 'call', _211 => _211()]), () => ( "")),
|
|
5762
6016
|
exp: []
|
|
5763
6017
|
}
|
|
5764
6018
|
};
|
|
@@ -5774,10 +6028,10 @@ function resolveVFor(directive, ir, ctx, nodeIR) {
|
|
|
5774
6028
|
};
|
|
5775
6029
|
}
|
|
5776
6030
|
function resolveForResult(forParseResult) {
|
|
5777
|
-
const source = _optionalChain([forParseResult, 'access',
|
|
5778
|
-
const value = _optionalChain([forParseResult, 'access',
|
|
5779
|
-
const index = _optionalChain([forParseResult, 'access',
|
|
5780
|
-
const key = _optionalChain([forParseResult, 'access',
|
|
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]);
|
|
5781
6035
|
return {
|
|
5782
6036
|
source,
|
|
5783
6037
|
value,
|
|
@@ -5797,7 +6051,7 @@ function resolveVHtml(directive, ir, ctx, nodeIR) {
|
|
|
5797
6051
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
|
|
5798
6052
|
function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
|
|
5799
6053
|
const name = directive.name === "else-if" ? "elseIf" : directive.name;
|
|
5800
|
-
const value = _nullishCoalesce(_optionalChain([directive, 'access',
|
|
6054
|
+
const value = _nullishCoalesce(_optionalChain([directive, 'access', _220 => _220.exp, 'optionalAccess', _221 => _221.content]), () => ( "true"));
|
|
5801
6055
|
const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
|
|
5802
6056
|
const isElseBranch = name === "else" || name === "elseIf";
|
|
5803
6057
|
let hasError = false;
|
|
@@ -5836,7 +6090,7 @@ function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
|
|
|
5836
6090
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
|
|
5837
6091
|
function resolveVMemo(directive, _ir, ctx, nodeIR) {
|
|
5838
6092
|
const exp = directive.exp;
|
|
5839
|
-
let value = _optionalChain([exp, 'optionalAccess',
|
|
6093
|
+
let value = _optionalChain([exp, 'optionalAccess', _222 => _222.content]);
|
|
5840
6094
|
if (value !== void 0) {
|
|
5841
6095
|
if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
|
|
5842
6096
|
const { source, filename } = ctx;
|
|
@@ -5876,14 +6130,14 @@ function resolveVModel(directive, ir, ctx, vueNode, nodeIR) {
|
|
|
5876
6130
|
const getterName = exp.content;
|
|
5877
6131
|
const isComponent = vueNode.tagType === _compilercore.ElementTypes.COMPONENT;
|
|
5878
6132
|
const inputType = resolveHtmlInput(vueNode, isComponent);
|
|
5879
|
-
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
6133
|
+
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _223 => _223.content]), () => ( resolveModelPropName(inputType, isComponent)));
|
|
5880
6134
|
let valuePropIR;
|
|
5881
6135
|
let eventPropIR;
|
|
5882
6136
|
if (isComponent) {
|
|
5883
6137
|
valuePropIR = createPropsIR("v-model", propName, getterName);
|
|
5884
6138
|
const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
|
|
5885
6139
|
const eventVueName = `update:${propName}`;
|
|
5886
|
-
const isTS = _optionalChain([ctx, 'access',
|
|
6140
|
+
const isTS = _optionalChain([ctx, 'access', _224 => _224.scriptData, 'optionalAccess', _225 => _225.lang, 'optionalAccess', _226 => _226.startsWith, 'call', _227 => _227("ts")]);
|
|
5887
6141
|
const valueArg = isTS ? "value: any" : "value";
|
|
5888
6142
|
const processedValue = applyValueModifiers("value", modifiers);
|
|
5889
6143
|
const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
|
|
@@ -5921,7 +6175,7 @@ function getRadioValue(vueNode) {
|
|
|
5921
6175
|
const valueAttr = vueNode.props.find(
|
|
5922
6176
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
|
|
5923
6177
|
);
|
|
5924
|
-
if (!_optionalChain([valueAttr, 'optionalAccess',
|
|
6178
|
+
if (!_optionalChain([valueAttr, 'optionalAccess', _228 => _228.value, 'optionalAccess', _229 => _229.content])) return '""';
|
|
5925
6179
|
const content = valueAttr.value.content;
|
|
5926
6180
|
return /^['"]/.test(content) ? content : `"${content}"`;
|
|
5927
6181
|
}
|
|
@@ -5931,7 +6185,7 @@ function resolveHtmlInput(node, isComponent) {
|
|
|
5931
6185
|
const typeProp = node.props.find(
|
|
5932
6186
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
|
|
5933
6187
|
);
|
|
5934
|
-
return _optionalChain([typeProp, 'optionalAccess',
|
|
6188
|
+
return _optionalChain([typeProp, 'optionalAccess', _230 => _230.value, 'optionalAccess', _231 => _231.content, 'optionalAccess', _232 => _232.toLowerCase, 'call', _233 => _233()]);
|
|
5935
6189
|
}
|
|
5936
6190
|
function applyValueModifiers(valueExp, modifiers) {
|
|
5937
6191
|
let result = valueExp;
|
|
@@ -5950,22 +6204,10 @@ function resolveVOn(directive, ir, ctx, nodeIR) {
|
|
|
5950
6204
|
const arg = directive.arg;
|
|
5951
6205
|
const exp = directive.exp;
|
|
5952
6206
|
const modifiers = directive.modifiers.map((item) => item.content);
|
|
5953
|
-
const captureIndex = modifiers
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
eventName = modifiers[captureIndex] ? `${eventName}Capture` : eventName;
|
|
5958
|
-
modifiers.splice(captureIndex, 1);
|
|
5959
|
-
}
|
|
5960
|
-
let originalVueEventName = "";
|
|
5961
|
-
if (modifiers.length) {
|
|
5962
|
-
originalVueEventName = `${arg.content}.${modifiers.join(".")}`;
|
|
5963
|
-
} else {
|
|
5964
|
-
const expr = stringToExpr(handler);
|
|
5965
|
-
if (!t47.isFunctionExpression(expr) && !t47.isArrowFunctionExpression(expr) && !t47.isIdentifier(expr)) {
|
|
5966
|
-
handler = `() => {${handler}}`;
|
|
5967
|
-
}
|
|
5968
|
-
}
|
|
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(".")}` : "";
|
|
5969
6211
|
const eventIR = createPropsIR(directive.rawName, eventName, handler);
|
|
5970
6212
|
eventIR.type = 3 /* EVENT */;
|
|
5971
6213
|
eventIR.isStatic = arg.isStatic;
|
|
@@ -5980,11 +6222,45 @@ function resolveVOn(directive, ir, ctx, nodeIR) {
|
|
|
5980
6222
|
}
|
|
5981
6223
|
nodeIR.props.push(eventIR);
|
|
5982
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
|
+
}
|
|
5983
6239
|
function normalizeVOnEventName(rawEventName) {
|
|
5984
6240
|
const segments = rawEventName.split(/[:-]/g).map((segment) => segment.trim()).filter(Boolean);
|
|
5985
6241
|
const normalized = segments.map((segment) => capitalize(camelCase(segment))).join("");
|
|
5986
6242
|
return `on${normalized}`;
|
|
5987
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
|
+
}
|
|
5988
6264
|
|
|
5989
6265
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-show.ts
|
|
5990
6266
|
function resolveVShow(directive, ir, ctx, nodeIR) {
|
|
@@ -6016,7 +6292,7 @@ function resolveVSlotProp(directive, ir, ctx) {
|
|
|
6016
6292
|
const name = !arg || arg.content === "default" ? "children" : arg.content;
|
|
6017
6293
|
const content = !isScoped ? [] : void 0;
|
|
6018
6294
|
const callback = isScoped ? {
|
|
6019
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
6295
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _234 => _234.content, 'optionalAccess', _235 => _235.trim, 'call', _236 => _236()]), () => ( "")),
|
|
6020
6296
|
exp: []
|
|
6021
6297
|
} : void 0;
|
|
6022
6298
|
checkPropIsDynamicKey(ctx, directive);
|
|
@@ -6024,7 +6300,7 @@ function resolveVSlotProp(directive, ir, ctx) {
|
|
|
6024
6300
|
type: 2 /* SLOT */,
|
|
6025
6301
|
name,
|
|
6026
6302
|
rawName: _nullishCoalesce(directive.rawName, () => ( "default")),
|
|
6027
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
6303
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _237 => _237.isStatic]), () => ( true)),
|
|
6028
6304
|
isScoped,
|
|
6029
6305
|
content,
|
|
6030
6306
|
callback
|
|
@@ -6087,7 +6363,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
|
|
|
6087
6363
|
if (routerAdapter) {
|
|
6088
6364
|
if (!ctx.route) ctx.route = true;
|
|
6089
6365
|
nodeIR.isRoute = true;
|
|
6090
|
-
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess',
|
|
6366
|
+
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _238 => _238.package]), routerAdapter.target);
|
|
6091
6367
|
}
|
|
6092
6368
|
resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
|
|
6093
6369
|
return nodeIR;
|
|
@@ -6234,7 +6510,7 @@ function resolveSlotProps(node, ctx) {
|
|
|
6234
6510
|
for (const prop of node.props) {
|
|
6235
6511
|
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
6236
6512
|
const attr = prop.name;
|
|
6237
|
-
const value = _optionalChain([prop, 'access',
|
|
6513
|
+
const value = _optionalChain([prop, 'access', _239 => _239.value, 'optionalAccess', _240 => _240.content, 'access', _241 => _241.trim, 'call', _242 => _242()]);
|
|
6238
6514
|
if (attr === "name" && value) {
|
|
6239
6515
|
result.name = camelCase(value);
|
|
6240
6516
|
} else {
|
|
@@ -6324,19 +6600,19 @@ function resolveTemplate2(root, ctx) {
|
|
|
6324
6600
|
// src/core/transform/sfc/index.ts
|
|
6325
6601
|
function transform(ast, ctx, options) {
|
|
6326
6602
|
const { template, script, style } = ast;
|
|
6327
|
-
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess',
|
|
6328
|
-
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess',
|
|
6603
|
+
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _243 => _243.ast]), ctx);
|
|
6604
|
+
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _244 => _244.ast]), ctx);
|
|
6329
6605
|
const result = {
|
|
6330
6606
|
template: templateIR,
|
|
6331
6607
|
script: scriptIR,
|
|
6332
|
-
style: _optionalChain([style, 'optionalAccess',
|
|
6608
|
+
style: _optionalChain([style, 'optionalAccess', _245 => _245.source, 'optionalAccess', _246 => _246.content])
|
|
6333
6609
|
};
|
|
6334
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6610
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _247 => _247.plugins]), result, ctx);
|
|
6335
6611
|
return result;
|
|
6336
6612
|
}
|
|
6337
6613
|
|
|
6338
6614
|
// package.json
|
|
6339
|
-
var version = "1.
|
|
6615
|
+
var version = "1.7.0";
|
|
6340
6616
|
var bin = {
|
|
6341
6617
|
vureact: "./bin/vureact.js"
|
|
6342
6618
|
};
|
|
@@ -6369,7 +6645,7 @@ async function formatWithPrettier(code, lang, opts) {
|
|
|
6369
6645
|
...opts,
|
|
6370
6646
|
parser
|
|
6371
6647
|
});
|
|
6372
|
-
} catch (
|
|
6648
|
+
} catch (e10) {
|
|
6373
6649
|
logger.info("Prettier is unavailable; the built-in simple formatter is used.");
|
|
6374
6650
|
return simpleFormat(code);
|
|
6375
6651
|
}
|
|
@@ -6419,7 +6695,7 @@ var FileLockManager = class _FileLockManager {
|
|
|
6419
6695
|
if (content.trim()) {
|
|
6420
6696
|
try {
|
|
6421
6697
|
current = JSON.parse(content);
|
|
6422
|
-
} catch (
|
|
6698
|
+
} catch (e11) {
|
|
6423
6699
|
current = content;
|
|
6424
6700
|
}
|
|
6425
6701
|
}
|
|
@@ -6452,7 +6728,7 @@ var FileLockManager = class _FileLockManager {
|
|
|
6452
6728
|
await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
6453
6729
|
try {
|
|
6454
6730
|
await _fs2.default.promises.access(filePath);
|
|
6455
|
-
} catch (
|
|
6731
|
+
} catch (e12) {
|
|
6456
6732
|
await this.writeFile(filePath, "");
|
|
6457
6733
|
}
|
|
6458
6734
|
const release = await _properlockfile2.default.lock(filePath, {
|
|
@@ -6477,7 +6753,7 @@ var FileLockManager = class _FileLockManager {
|
|
|
6477
6753
|
const { stale = 1e4, realpath = true, lockfilePath } = options;
|
|
6478
6754
|
try {
|
|
6479
6755
|
return await _properlockfile2.default.check(filePath, { stale, realpath, lockfilePath });
|
|
6480
|
-
} catch (
|
|
6756
|
+
} catch (e13) {
|
|
6481
6757
|
return false;
|
|
6482
6758
|
}
|
|
6483
6759
|
}
|
|
@@ -6499,7 +6775,7 @@ var FileLockManager = class _FileLockManager {
|
|
|
6499
6775
|
lockfilePath
|
|
6500
6776
|
});
|
|
6501
6777
|
return release;
|
|
6502
|
-
} catch (
|
|
6778
|
+
} catch (e14) {
|
|
6503
6779
|
return null;
|
|
6504
6780
|
}
|
|
6505
6781
|
}
|
|
@@ -6512,7 +6788,7 @@ var FileLockManager = class _FileLockManager {
|
|
|
6512
6788
|
const { realpath = true, lockfilePath } = options;
|
|
6513
6789
|
try {
|
|
6514
6790
|
await _properlockfile2.default.unlock(filePath, { realpath, lockfilePath });
|
|
6515
|
-
} catch (
|
|
6791
|
+
} catch (e15) {
|
|
6516
6792
|
}
|
|
6517
6793
|
}
|
|
6518
6794
|
async writeFile(filePath, content) {
|
|
@@ -6530,7 +6806,7 @@ var Helper = (_class5 = class {
|
|
|
6530
6806
|
__init8() {this.outDir = "react-app"}
|
|
6531
6807
|
constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
|
|
6532
6808
|
this.compilerOpts = opts;
|
|
6533
|
-
if (_optionalChain([opts, 'access',
|
|
6809
|
+
if (_optionalChain([opts, 'access', _248 => _248.output, 'optionalAccess', _249 => _249.workspace])) {
|
|
6534
6810
|
this.workspaceDir = opts.output.workspace;
|
|
6535
6811
|
}
|
|
6536
6812
|
const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
|
|
@@ -6567,7 +6843,7 @@ var Helper = (_class5 = class {
|
|
|
6567
6843
|
}
|
|
6568
6844
|
getOutDirName() {
|
|
6569
6845
|
const { output } = this.compilerOpts;
|
|
6570
|
-
return _optionalChain([output, 'optionalAccess',
|
|
6846
|
+
return _optionalChain([output, 'optionalAccess', _250 => _250.outDir]) || this.outDir;
|
|
6571
6847
|
}
|
|
6572
6848
|
getWorkspaceDir() {
|
|
6573
6849
|
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
|
|
@@ -6581,7 +6857,7 @@ var Helper = (_class5 = class {
|
|
|
6581
6857
|
}
|
|
6582
6858
|
getIgnoreAssets() {
|
|
6583
6859
|
const { output } = this.compilerOpts;
|
|
6584
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6860
|
+
if (_optionalChain([output, 'optionalAccess', _251 => _251.ignoreAssets])) {
|
|
6585
6861
|
return new Set(output.ignoreAssets.map(normalizePath));
|
|
6586
6862
|
}
|
|
6587
6863
|
return /* @__PURE__ */ new Set([
|
|
@@ -6664,12 +6940,12 @@ var Helper = (_class5 = class {
|
|
|
6664
6940
|
*/
|
|
6665
6941
|
async formatCode({ code, fileInfo }) {
|
|
6666
6942
|
const { format } = this.compilerOpts;
|
|
6667
|
-
if (!_optionalChain([format, 'optionalAccess',
|
|
6668
|
-
if (_optionalChain([format, 'optionalAccess',
|
|
6943
|
+
if (!_optionalChain([format, 'optionalAccess', _252 => _252.enabled])) return code;
|
|
6944
|
+
if (_optionalChain([format, 'optionalAccess', _253 => _253.formatter]) === "builtin") {
|
|
6669
6945
|
return simpleFormat(code);
|
|
6670
6946
|
}
|
|
6671
|
-
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess',
|
|
6672
|
-
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess',
|
|
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]));
|
|
6673
6949
|
}
|
|
6674
6950
|
/**
|
|
6675
6951
|
* 通用的缓存校验工具函数
|
|
@@ -6703,7 +6979,7 @@ var Helper = (_class5 = class {
|
|
|
6703
6979
|
* @param options.lock - 是否启用文件锁(默认false)
|
|
6704
6980
|
*/
|
|
6705
6981
|
async writeFileWithDir(filePath, content, options) {
|
|
6706
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6982
|
+
if (_optionalChain([options, 'optionalAccess', _257 => _257.lock])) {
|
|
6707
6983
|
await fileLock.updateFile(filePath, async () => content, options);
|
|
6708
6984
|
} else {
|
|
6709
6985
|
await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
@@ -6713,7 +6989,7 @@ var Helper = (_class5 = class {
|
|
|
6713
6989
|
async rmFile(filePath) {
|
|
6714
6990
|
try {
|
|
6715
6991
|
await _fs2.default.promises.rm(filePath, { recursive: true, force: true });
|
|
6716
|
-
} catch (
|
|
6992
|
+
} catch (e16) {
|
|
6717
6993
|
}
|
|
6718
6994
|
}
|
|
6719
6995
|
async loadCache(key) {
|
|
@@ -6730,7 +7006,7 @@ var Helper = (_class5 = class {
|
|
|
6730
7006
|
target: data[key] || [],
|
|
6731
7007
|
source: data
|
|
6732
7008
|
};
|
|
6733
|
-
} catch (
|
|
7009
|
+
} catch (e17) {
|
|
6734
7010
|
return defaultData;
|
|
6735
7011
|
}
|
|
6736
7012
|
}
|
|
@@ -6828,7 +7104,7 @@ var Helper = (_class5 = class {
|
|
|
6828
7104
|
* 获取需要排除编译的文件
|
|
6829
7105
|
*/
|
|
6830
7106
|
getExcludes() {
|
|
6831
|
-
if (!_optionalChain([this, 'access',
|
|
7107
|
+
if (!_optionalChain([this, 'access', _258 => _258.compilerOpts, 'access', _259 => _259.exclude, 'optionalAccess', _260 => _260.length])) {
|
|
6832
7108
|
return PathFilter.withDefaults();
|
|
6833
7109
|
}
|
|
6834
7110
|
return this.compilerOpts.exclude;
|
|
@@ -6926,7 +7202,7 @@ function parseOnlyStyle(source, ctx, options) {
|
|
|
6926
7202
|
ast: void 0
|
|
6927
7203
|
}
|
|
6928
7204
|
};
|
|
6929
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
7205
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _261 => _261.plugins]), result, ctx);
|
|
6930
7206
|
return result;
|
|
6931
7207
|
}
|
|
6932
7208
|
|
|
@@ -6950,7 +7226,7 @@ var CompilationContext = (_class6 = class {constructor() { _class6.prototype.__i
|
|
|
6950
7226
|
}
|
|
6951
7227
|
create() {
|
|
6952
7228
|
return {
|
|
6953
|
-
fileId:
|
|
7229
|
+
fileId: Date.now().toString(),
|
|
6954
7230
|
source: "",
|
|
6955
7231
|
filename: "",
|
|
6956
7232
|
imports: /* @__PURE__ */ new Map(),
|
|
@@ -7060,16 +7336,16 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7060
7336
|
});
|
|
7061
7337
|
const genOptions = this.prepareGenerateOptions(filename);
|
|
7062
7338
|
const resolveSFCAndScriptFile = () => {
|
|
7063
|
-
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7064
|
-
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
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]) });
|
|
7065
7341
|
const gen = generate(ir, ctx.data, {
|
|
7066
7342
|
...genOptions,
|
|
7067
|
-
plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7343
|
+
plugins: _optionalChain([plugins, 'optionalAccess', _264 => _264.codegen])
|
|
7068
7344
|
});
|
|
7069
7345
|
return this.resolveMainResult(ir, gen, ctx.data);
|
|
7070
7346
|
};
|
|
7071
7347
|
const resolveStyleFile = () => {
|
|
7072
|
-
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7348
|
+
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _265 => _265.parser]) });
|
|
7073
7349
|
return this.resolveStyleResult(result, ctx.data);
|
|
7074
7350
|
};
|
|
7075
7351
|
try {
|
|
@@ -7108,9 +7384,9 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7108
7384
|
lang
|
|
7109
7385
|
},
|
|
7110
7386
|
css: {
|
|
7111
|
-
file: _optionalChain([styleData, 'optionalAccess',
|
|
7112
|
-
hash: _optionalChain([styleData, 'optionalAccess',
|
|
7113
|
-
code: _optionalChain([ir, 'optionalAccess',
|
|
7387
|
+
file: _optionalChain([styleData, 'optionalAccess', _266 => _266.filePath]),
|
|
7388
|
+
hash: _optionalChain([styleData, 'optionalAccess', _267 => _267.scopeId]),
|
|
7389
|
+
code: _optionalChain([ir, 'optionalAccess', _268 => _268.style])
|
|
7114
7390
|
}
|
|
7115
7391
|
},
|
|
7116
7392
|
...base
|
|
@@ -7180,7 +7456,7 @@ var AssetManager = (_class8 = class {
|
|
|
7180
7456
|
const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
|
|
7181
7457
|
const filename = _path2.default.basename(p).toLowerCase();
|
|
7182
7458
|
const ext = _path2.default.extname(p).toLowerCase();
|
|
7183
|
-
if (!_optionalChain([options, 'access',
|
|
7459
|
+
if (!_optionalChain([options, 'access', _269 => _269.output, 'optionalAccess', _270 => _270.ignoreAssets])) {
|
|
7184
7460
|
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
7185
7461
|
if (pattern.endsWith(".")) {
|
|
7186
7462
|
return filename.startsWith(pattern);
|
|
@@ -7277,12 +7553,12 @@ var CacheManager = (_class9 = class {
|
|
|
7277
7553
|
const meta = { ...unit };
|
|
7278
7554
|
delete meta.source;
|
|
7279
7555
|
if (key === "sfc" /* SFC */) {
|
|
7280
|
-
_optionalChainDelete([meta, 'access',
|
|
7281
|
-
_optionalChainDelete([meta, 'access',
|
|
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]);
|
|
7282
7558
|
} else if (key === "script" /* SCRIPT */) {
|
|
7283
|
-
_optionalChainDelete([meta, 'access',
|
|
7559
|
+
_optionalChainDelete([meta, 'access', _277 => _277.output, 'optionalAccess', _278 => _278.script, 'access', _279 => delete _279.code]);
|
|
7284
7560
|
} else if (key === "style" /* STYLE */) {
|
|
7285
|
-
_optionalChainDelete([meta, 'access',
|
|
7561
|
+
_optionalChainDelete([meta, 'access', _280 => _280.output, 'optionalAccess', _281 => _281.style, 'access', _282 => delete _282.code]);
|
|
7286
7562
|
}
|
|
7287
7563
|
if (!this.pendingUpdates.has(key)) {
|
|
7288
7564
|
this.pendingUpdates.set(key, []);
|
|
@@ -7352,7 +7628,7 @@ var CleanupManager = class {
|
|
|
7352
7628
|
meta = m;
|
|
7353
7629
|
const { jsx, css } = meta.output;
|
|
7354
7630
|
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
7355
|
-
if (_optionalChain([css, 'optionalAccess',
|
|
7631
|
+
if (_optionalChain([css, 'optionalAccess', _283 => _283.file])) {
|
|
7356
7632
|
await this.fileCompiler.removeOutputFile(css.file);
|
|
7357
7633
|
}
|
|
7358
7634
|
break;
|
|
@@ -7413,7 +7689,7 @@ var CompilationUnitProcessor = class {
|
|
|
7413
7689
|
const isScriptFile = key === "script" /* SCRIPT */;
|
|
7414
7690
|
const isStyleFile = key === "style" /* STYLE */;
|
|
7415
7691
|
if (isSFC || isScriptFile) {
|
|
7416
|
-
unit.hasRoute = _optionalChain([result, 'optionalAccess',
|
|
7692
|
+
unit.hasRoute = _optionalChain([result, 'optionalAccess', _284 => _284.hasRoute]);
|
|
7417
7693
|
}
|
|
7418
7694
|
const resolveFileInfo = () => {
|
|
7419
7695
|
if (isSFC) {
|
|
@@ -7433,7 +7709,7 @@ var CompilationUnitProcessor = class {
|
|
|
7433
7709
|
const { script } = result.fileInfo;
|
|
7434
7710
|
unit.output = {
|
|
7435
7711
|
script: {
|
|
7436
|
-
file: _optionalChain([script, 'optionalAccess',
|
|
7712
|
+
file: _optionalChain([script, 'optionalAccess', _285 => _285.file]),
|
|
7437
7713
|
code
|
|
7438
7714
|
}
|
|
7439
7715
|
};
|
|
@@ -7510,7 +7786,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7510
7786
|
const absPath = this.fileCompiler.getAbsPath(filePath);
|
|
7511
7787
|
const fileMeta = await this.fileCompiler.getFileMeta(absPath);
|
|
7512
7788
|
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
|
|
7513
|
-
const record = _optionalChain([cache, 'optionalAccess',
|
|
7789
|
+
const record = _optionalChain([cache, 'optionalAccess', _286 => _286.target, 'access', _287 => _287.find, 'call', _288 => _288((c) => c.file === absPath)]);
|
|
7514
7790
|
const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
|
|
7515
7791
|
fileMeta,
|
|
7516
7792
|
record,
|
|
@@ -7532,10 +7808,10 @@ var FileProcessor = (_class10 = class {
|
|
|
7532
7808
|
hash: hash || this.fileCompiler.genHash(source)
|
|
7533
7809
|
};
|
|
7534
7810
|
const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
|
|
7535
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7811
|
+
if (_optionalChain([processed, 'optionalAccess', _289 => _289.output])) {
|
|
7536
7812
|
await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
|
|
7537
7813
|
if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
|
|
7538
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7814
|
+
if (_optionalChain([processed, 'optionalAccess', _290 => _290.hasRoute])) {
|
|
7539
7815
|
await this.addRouterToPackageJson();
|
|
7540
7816
|
await this.updateEntryWithRouterProvider();
|
|
7541
7817
|
}
|
|
@@ -7549,13 +7825,13 @@ var FileProcessor = (_class10 = class {
|
|
|
7549
7825
|
*/
|
|
7550
7826
|
async addRouterToPackageJson() {
|
|
7551
7827
|
const { output } = this.fileCompiler.options;
|
|
7552
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7828
|
+
if (_optionalChain([output, 'optionalAccess', _291 => _291.bootstrapVite]) === false) {
|
|
7553
7829
|
return;
|
|
7554
7830
|
}
|
|
7555
7831
|
const { router } = RUNTIME_PACKAGES;
|
|
7556
7832
|
const filePath = this.fileCompiler.getOutputPkgPath();
|
|
7557
7833
|
const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
|
|
7558
|
-
if (_optionalChain([packageJson, 'optionalAccess',
|
|
7834
|
+
if (_optionalChain([packageJson, 'optionalAccess', _292 => _292.dependencies, 'optionalAccess', _293 => _293[router.name]])) {
|
|
7559
7835
|
return;
|
|
7560
7836
|
}
|
|
7561
7837
|
if (!packageJson.dependencies) {
|
|
@@ -7574,14 +7850,14 @@ var FileProcessor = (_class10 = class {
|
|
|
7574
7850
|
const { exclude, output, router } = this.fileCompiler.options;
|
|
7575
7851
|
const inputPath = this.fileCompiler.getInputPath();
|
|
7576
7852
|
const outputPath = this.fileCompiler.getOuputPath(true);
|
|
7577
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7853
|
+
if (_optionalChain([output, 'optionalAccess', _294 => _294.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _295 => _295.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _296 => _296.configFile])) {
|
|
7578
7854
|
return;
|
|
7579
7855
|
}
|
|
7580
7856
|
const getMainFile = async (filename) => {
|
|
7581
7857
|
const filePath = _path2.default.resolve(outputPath, filename);
|
|
7582
7858
|
try {
|
|
7583
7859
|
return { filePath, content: await _fs2.default.promises.readFile(filePath, "utf-8") };
|
|
7584
|
-
} catch (
|
|
7860
|
+
} catch (e18) {
|
|
7585
7861
|
return;
|
|
7586
7862
|
}
|
|
7587
7863
|
};
|
|
@@ -7595,7 +7871,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7595
7871
|
const prepareRouterEntry = () => {
|
|
7596
7872
|
const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
|
|
7597
7873
|
let content = fileData.content;
|
|
7598
|
-
if (_optionalChain([exclude, 'optionalAccess',
|
|
7874
|
+
if (_optionalChain([exclude, 'optionalAccess', _297 => _297.includes, 'call', _298 => _298(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _299 => _299.includes, 'call', _300 => _300(importPath)])) {
|
|
7599
7875
|
return content;
|
|
7600
7876
|
}
|
|
7601
7877
|
const routerModule = "RouterInstance";
|
|
@@ -7741,7 +8017,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7741
8017
|
const { output } = this.options;
|
|
7742
8018
|
const workspaceDir = this.fileCompiler.getWorkspaceDir();
|
|
7743
8019
|
await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
|
|
7744
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
8020
|
+
if (_optionalChain([output, 'optionalAccess', _301 => _301.bootstrapVite]) === false) {
|
|
7745
8021
|
return false;
|
|
7746
8022
|
}
|
|
7747
8023
|
if (this.isSingleFile()) {
|
|
@@ -7791,7 +8067,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7791
8067
|
const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
|
|
7792
8068
|
newPkg.dependencies = newDeps;
|
|
7793
8069
|
newPkg.devDependencies = newDevDeps;
|
|
7794
|
-
newPkg = _optionalChain([output, 'optionalAccess',
|
|
8070
|
+
newPkg = _optionalChain([output, 'optionalAccess', _302 => _302.packageJson, 'optionalCall', _303 => _303(newPkg)]) || newPkg;
|
|
7795
8071
|
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
|
|
7796
8072
|
this.spinner.succeed("Standard Vite React environment initialized");
|
|
7797
8073
|
return true;
|
|
@@ -7802,12 +8078,12 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7802
8078
|
async resolveViteCreateApp() {
|
|
7803
8079
|
const { output } = this.options;
|
|
7804
8080
|
const { viteVersion, template: tmpl } = this.defaultConfig;
|
|
7805
|
-
const bootstrapVite = _optionalChain([output, 'optionalAccess',
|
|
8081
|
+
const bootstrapVite = _optionalChain([output, 'optionalAccess', _304 => _304.bootstrapVite]);
|
|
7806
8082
|
const outDirName = this.fileCompiler.getOutDirName();
|
|
7807
8083
|
const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
|
|
7808
|
-
const viteVer = _optionalChain([configObject, 'optionalAccess',
|
|
7809
|
-
const reactVer = _optionalChain([configObject, 'optionalAccess',
|
|
7810
|
-
const template = _optionalChain([configObject, 'optionalAccess',
|
|
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;
|
|
7811
8087
|
const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
|
|
7812
8088
|
_child_process.execSync.call(void 0, cmd, {
|
|
7813
8089
|
cwd: this.fileCompiler.getWorkspaceDir(),
|
|
@@ -7911,7 +8187,7 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
|
7911
8187
|
const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
|
|
7912
8188
|
const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
|
|
7913
8189
|
const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
|
|
7914
|
-
await _optionalChain([this, 'access',
|
|
8190
|
+
await _optionalChain([this, 'access', _308 => _308.options, 'access', _309 => _309.onSuccess, 'optionalCall', _310 => _310()]);
|
|
7915
8191
|
const endTime = calcElapsedTime(startTime);
|
|
7916
8192
|
this.printCoreLogs();
|
|
7917
8193
|
this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
|