@vureact/compiler-core 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12; var _class13;/**
|
|
2
|
-
* @vureact/compiler-core v1.6.
|
|
2
|
+
* @vureact/compiler-core v1.6.2
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -39,7 +39,7 @@ var RUNTIME_PACKAGES = {
|
|
|
39
39
|
},
|
|
40
40
|
runtime: {
|
|
41
41
|
name: PACKAGE_NAME.runtime,
|
|
42
|
-
version: "^1.0
|
|
42
|
+
version: "^1.1.0"
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
var STYLE_MODULE_NAME = "$style";
|
|
@@ -324,6 +324,11 @@ var ADAPTER_RULES = {
|
|
|
324
324
|
target: "nextTick",
|
|
325
325
|
package: PACKAGE_NAME.runtime,
|
|
326
326
|
type: "rename"
|
|
327
|
+
},
|
|
328
|
+
defineAsyncComponent: {
|
|
329
|
+
target: "defineAsyncComponent",
|
|
330
|
+
package: PACKAGE_NAME.runtime,
|
|
331
|
+
type: "rename"
|
|
327
332
|
}
|
|
328
333
|
},
|
|
329
334
|
// =================== [VuReact Router] ===================
|
|
@@ -1053,7 +1058,7 @@ function buildStandardProp(nodeIR) {
|
|
|
1053
1058
|
babelExp: { ast: keyAST },
|
|
1054
1059
|
value: {
|
|
1055
1060
|
content,
|
|
1056
|
-
isStringLiteral:
|
|
1061
|
+
isStringLiteral: isStringLiteral13,
|
|
1057
1062
|
babelExp: { ast: valueAST }
|
|
1058
1063
|
}
|
|
1059
1064
|
} = nodeIR;
|
|
@@ -1062,7 +1067,7 @@ function buildStandardProp(nodeIR) {
|
|
|
1062
1067
|
}
|
|
1063
1068
|
let value;
|
|
1064
1069
|
if (content !== "true") {
|
|
1065
|
-
value =
|
|
1070
|
+
value = isStringLiteral13 ? t9.stringLiteral(content) : buildJsxExpressionNode(valueAST);
|
|
1066
1071
|
}
|
|
1067
1072
|
return t9.jsxAttribute(keyAST, value);
|
|
1068
1073
|
}
|
|
@@ -2991,98 +2996,22 @@ function resolveDefineAsyncComponent(ctx) {
|
|
|
2991
2996
|
return;
|
|
2992
2997
|
}
|
|
2993
2998
|
const [arg] = node.arguments;
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
function checkIsUnsupported(ctx, arg) {
|
|
3001
|
-
if (t25.isFunction(arg)) {
|
|
3002
|
-
checkIsDynamicImport(ctx, arg);
|
|
3003
|
-
} else if (t25.isObjectExpression(arg)) {
|
|
3004
|
-
const { value } = arg.properties.find(
|
|
3005
|
-
(p) => t25.isObjectProperty(p) && t25.isIdentifier(p.key) && p.key.name === "loader"
|
|
3006
|
-
);
|
|
3007
|
-
checkIsDynamicImport(ctx, value);
|
|
3008
|
-
if (arg.properties.length > 1) {
|
|
3009
|
-
warnMultipleOptionsUsed(ctx, arg);
|
|
3010
|
-
}
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
function checkIsDynamicImport(ctx, node) {
|
|
3014
|
-
const { scriptData, filename } = ctx;
|
|
3015
|
-
const warnIsNotImport = (target) => {
|
|
3016
|
-
if (!target || !t25.isImport(target)) {
|
|
3017
|
-
logger.error(
|
|
3018
|
-
`Only ES module dynamic imports are supported. You must use and return import('...').`,
|
|
3019
|
-
{
|
|
3020
|
-
source: scriptData.source,
|
|
3021
|
-
file: filename,
|
|
3022
|
-
loc: _optionalChain([target, 'optionalAccess', _83 => _83.loc]) || {}
|
|
2999
|
+
if (!t25.isObjectExpression(arg)) {
|
|
3000
|
+
return;
|
|
3001
|
+
}
|
|
3002
|
+
for (const prop of arg.properties) {
|
|
3003
|
+
if (!t25.isObjectProperty(prop) || !t25.isIdentifier(prop.key) || prop.key.name !== "hydrate") {
|
|
3004
|
+
continue;
|
|
3023
3005
|
}
|
|
3024
|
-
|
|
3006
|
+
logger.warn('Unsupported option "hydrate"', {
|
|
3007
|
+
file: ctx.filename,
|
|
3008
|
+
source: ctx.scriptData.source,
|
|
3009
|
+
loc: prop.key.loc
|
|
3010
|
+
});
|
|
3011
|
+
break;
|
|
3012
|
+
}
|
|
3025
3013
|
}
|
|
3026
3014
|
};
|
|
3027
|
-
if (t25.isFunction(node)) {
|
|
3028
|
-
checkIsDynamicImport(ctx, node.body);
|
|
3029
|
-
return;
|
|
3030
|
-
}
|
|
3031
|
-
if (t25.isBlockStatement(node)) {
|
|
3032
|
-
const [returnSmt] = node.body;
|
|
3033
|
-
if (t25.isReturnStatement(returnSmt)) {
|
|
3034
|
-
warnIsNotImport(returnSmt.argument);
|
|
3035
|
-
}
|
|
3036
|
-
return;
|
|
3037
|
-
}
|
|
3038
|
-
if (t25.isCallExpression(node)) {
|
|
3039
|
-
warnIsNotImport(node.callee);
|
|
3040
|
-
if (t25.isStringLiteral(node.arguments[0])) {
|
|
3041
|
-
replaceVueSuffix(node.arguments[0]);
|
|
3042
|
-
}
|
|
3043
|
-
return;
|
|
3044
|
-
}
|
|
3045
|
-
warnIsNotImport(node);
|
|
3046
|
-
}
|
|
3047
|
-
function warnMultipleOptionsUsed(ctx, node) {
|
|
3048
|
-
const { scriptData, filename } = ctx;
|
|
3049
|
-
logger.warn(
|
|
3050
|
-
"Only the loader option is supported. Other options may be implemented manually based on your needs.",
|
|
3051
|
-
{
|
|
3052
|
-
source: scriptData.source,
|
|
3053
|
-
file: filename,
|
|
3054
|
-
loc: node.loc
|
|
3055
|
-
}
|
|
3056
|
-
);
|
|
3057
|
-
}
|
|
3058
|
-
function pushToGlobalScope(path9, ctx) {
|
|
3059
|
-
const { node } = path9;
|
|
3060
|
-
const callee = node.callee;
|
|
3061
|
-
callee.name = REACT_API_MAP.lazy;
|
|
3062
|
-
callee.loc.identifierName = REACT_API_MAP.lazy;
|
|
3063
|
-
if (node.typeParameters) {
|
|
3064
|
-
node.typeParameters = void 0;
|
|
3065
|
-
}
|
|
3066
|
-
let declarationPath = path9.parentPath;
|
|
3067
|
-
while (declarationPath) {
|
|
3068
|
-
if (declarationPath.isVariableDeclaration()) {
|
|
3069
|
-
break;
|
|
3070
|
-
}
|
|
3071
|
-
declarationPath = declarationPath.parentPath;
|
|
3072
|
-
}
|
|
3073
|
-
let fullNode;
|
|
3074
|
-
if (_optionalChain([declarationPath, 'optionalAccess', _84 => _84.isVariableDeclaration, 'call', _85 => _85()])) {
|
|
3075
|
-
fullNode = declarationPath.node;
|
|
3076
|
-
declarationPath.remove();
|
|
3077
|
-
} else if (path9.parentPath.isVariableDeclarator()) {
|
|
3078
|
-
fullNode = path9.parent;
|
|
3079
|
-
path9.parentPath.remove();
|
|
3080
|
-
} else {
|
|
3081
|
-
fullNode = path9.node;
|
|
3082
|
-
path9.remove();
|
|
3083
|
-
}
|
|
3084
|
-
const scriptIR = getScriptIR(ctx);
|
|
3085
|
-
scriptIR.statement.global.push(fullNode);
|
|
3086
3015
|
}
|
|
3087
3016
|
|
|
3088
3017
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-define-expose.ts
|
|
@@ -3191,10 +3120,10 @@ function resolveEmitCalls(ctx) {
|
|
|
3191
3120
|
const [callee, ...args] = node.arguments;
|
|
3192
3121
|
const eventName = t28.isStringLiteral(callee) ? formatEmitEventName(callee.value) : void 0;
|
|
3193
3122
|
if (!eventName) {
|
|
3194
|
-
logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess',
|
|
3123
|
+
logger.warn(`Expected String type but got ${_optionalChain([callee, 'optionalAccess', _83 => _83.type])}, expression will be removed`, {
|
|
3195
3124
|
file: filename,
|
|
3196
3125
|
source: scriptData.source,
|
|
3197
|
-
loc: _optionalChain([callee, 'optionalAccess',
|
|
3126
|
+
loc: _optionalChain([callee, 'optionalAccess', _84 => _84.loc])
|
|
3198
3127
|
});
|
|
3199
3128
|
path9.remove();
|
|
3200
3129
|
return;
|
|
@@ -3317,8 +3246,8 @@ function resolveTopLevelEmitType(tsType) {
|
|
|
3317
3246
|
function resolveDefineEmitsIface(path9, ctx) {
|
|
3318
3247
|
const { node } = path9;
|
|
3319
3248
|
const [runtimeArg] = node.arguments;
|
|
3320
|
-
const tsParams = _optionalChain([node, 'access',
|
|
3321
|
-
if (_optionalChain([tsParams, 'optionalAccess',
|
|
3249
|
+
const tsParams = _optionalChain([node, 'access', _85 => _85.typeParameters, 'optionalAccess', _86 => _86.params]);
|
|
3250
|
+
if (_optionalChain([tsParams, 'optionalAccess', _87 => _87.length])) {
|
|
3322
3251
|
processExplicitType(ctx, tsParams);
|
|
3323
3252
|
return;
|
|
3324
3253
|
}
|
|
@@ -3516,12 +3445,12 @@ function resolveEmitPropFromPropertySignature(member) {
|
|
|
3516
3445
|
if (!rawName) return null;
|
|
3517
3446
|
const handlerName = resolveEmitHandlerName(rawName);
|
|
3518
3447
|
const key = buildKey(handlerName);
|
|
3519
|
-
const typeAnnotation = _optionalChain([member, 'access',
|
|
3448
|
+
const typeAnnotation = _optionalChain([member, 'access', _88 => _88.typeAnnotation, 'optionalAccess', _89 => _89.typeAnnotation]);
|
|
3520
3449
|
let params = [];
|
|
3521
3450
|
let returnType = t30.tsAnyKeyword();
|
|
3522
3451
|
if (typeAnnotation && t30.isTSFunctionType(typeAnnotation)) {
|
|
3523
3452
|
params = cloneCallableParams(typeAnnotation.parameters);
|
|
3524
|
-
returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access',
|
|
3453
|
+
returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'access', _90 => _90.typeAnnotation, 'optionalAccess', _91 => _91.typeAnnotation]), () => ( returnType));
|
|
3525
3454
|
} else if (typeAnnotation && t30.isTSTupleType(typeAnnotation)) {
|
|
3526
3455
|
params = resolveTupleTypeParams(typeAnnotation);
|
|
3527
3456
|
} else if (typeAnnotation) {
|
|
@@ -3546,7 +3475,7 @@ function resolveEmitPropsFromCallable(parameters, typeAnnotation) {
|
|
|
3546
3475
|
if (t30.isNoop(paramTypeAnnotation)) return [];
|
|
3547
3476
|
const eventNames = resolveEventNames(paramTypeAnnotation.typeAnnotation);
|
|
3548
3477
|
if (!eventNames.length) return [];
|
|
3549
|
-
const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess',
|
|
3478
|
+
const returnType = _nullishCoalesce(_optionalChain([typeAnnotation, 'optionalAccess', _92 => _92.typeAnnotation]), () => ( t30.tsAnyKeyword()));
|
|
3550
3479
|
return eventNames.map((eventName) => {
|
|
3551
3480
|
const handlerName = resolveEmitHandlerName(eventName);
|
|
3552
3481
|
const key = buildKey(handlerName);
|
|
@@ -3580,7 +3509,7 @@ function resolveTupleElementParam(element, index) {
|
|
|
3580
3509
|
const isNamedTuple = typeof t30.isTSNamedTupleMember === "function" && t30.isTSNamedTupleMember(element);
|
|
3581
3510
|
if (isNamedTuple) {
|
|
3582
3511
|
const tupleMember = element;
|
|
3583
|
-
const name = _optionalChain([tupleMember, 'access',
|
|
3512
|
+
const name = _optionalChain([tupleMember, 'access', _93 => _93.label, 'optionalAccess', _94 => _94.name]) || `arg${index}`;
|
|
3584
3513
|
let innerType = tupleMember.elementType;
|
|
3585
3514
|
let optional = tupleMember.optional;
|
|
3586
3515
|
if (t30.isTSOptionalType(innerType)) {
|
|
@@ -3618,8 +3547,8 @@ function resolveTupleElementParam(element, index) {
|
|
|
3618
3547
|
function resolveDefinePropsIface(path9, ctx) {
|
|
3619
3548
|
const { node } = path9;
|
|
3620
3549
|
const [runtimeArg] = node.arguments;
|
|
3621
|
-
const tsParams = _optionalChain([node, 'access',
|
|
3622
|
-
if (_optionalChain([tsParams, 'optionalAccess',
|
|
3550
|
+
const tsParams = _optionalChain([node, 'access', _95 => _95.typeParameters, 'optionalAccess', _96 => _96.params]);
|
|
3551
|
+
if (_optionalChain([tsParams, 'optionalAccess', _97 => _97.length])) {
|
|
3623
3552
|
const { propsTSIface } = ctx.scriptData;
|
|
3624
3553
|
propsTSIface.propsTypes = tsParams;
|
|
3625
3554
|
return;
|
|
@@ -3674,7 +3603,7 @@ function processInferredTypes2(ctx, runtimeArg) {
|
|
|
3674
3603
|
{
|
|
3675
3604
|
source,
|
|
3676
3605
|
file: filename,
|
|
3677
|
-
loc: _optionalChain([runtimeArg, 'optionalAccess',
|
|
3606
|
+
loc: _optionalChain([runtimeArg, 'optionalAccess', _98 => _98.loc])
|
|
3678
3607
|
}
|
|
3679
3608
|
);
|
|
3680
3609
|
}
|
|
@@ -3785,7 +3714,7 @@ function createSlotScopeParam(props, ctx) {
|
|
|
3785
3714
|
const propsSigns = [];
|
|
3786
3715
|
const { reactiveBindings } = ctx.templateData;
|
|
3787
3716
|
props.forEach(({ prop, tsType }) => {
|
|
3788
|
-
const foundBindingValue = _optionalChain([reactiveBindings, 'access',
|
|
3717
|
+
const foundBindingValue = _optionalChain([reactiveBindings, 'access', _99 => _99[prop], 'optionalAccess', _100 => _100.value]);
|
|
3789
3718
|
const foundBindingTypes = foundBindingValue ? expressionToTSType(foundBindingValue) : null;
|
|
3790
3719
|
const typeAnnotation = foundBindingTypes ? t32.tsTypeAnnotation(foundBindingTypes) : tsType;
|
|
3791
3720
|
const key = t32.isValidIdentifier(prop) ? t32.identifier(prop) : t32.stringLiteral(prop);
|
|
@@ -3817,7 +3746,7 @@ function collectLocalTypeDeclarations(path9) {
|
|
|
3817
3746
|
declarations.set(statement.id.name, {
|
|
3818
3747
|
type: t33.tsTypeLiteral(statement.body.body),
|
|
3819
3748
|
// 将接口体转换为类型字面量
|
|
3820
|
-
hasTypeParameters: !!_optionalChain([statement, 'access',
|
|
3749
|
+
hasTypeParameters: !!_optionalChain([statement, 'access', _101 => _101.typeParameters, 'optionalAccess', _102 => _102.params, 'access', _103 => _103.length])
|
|
3821
3750
|
// 检查是否有泛型参数
|
|
3822
3751
|
});
|
|
3823
3752
|
continue;
|
|
@@ -3826,7 +3755,7 @@ function collectLocalTypeDeclarations(path9) {
|
|
|
3826
3755
|
declarations.set(statement.id.name, {
|
|
3827
3756
|
type: statement.typeAnnotation,
|
|
3828
3757
|
// 直接使用类型注解
|
|
3829
|
-
hasTypeParameters: !!_optionalChain([statement, 'access',
|
|
3758
|
+
hasTypeParameters: !!_optionalChain([statement, 'access', _104 => _104.typeParameters, 'optionalAccess', _105 => _105.params, 'access', _106 => _106.length])
|
|
3830
3759
|
// 检查是否有泛型参数
|
|
3831
3760
|
});
|
|
3832
3761
|
continue;
|
|
@@ -3837,14 +3766,14 @@ function collectLocalTypeDeclarations(path9) {
|
|
|
3837
3766
|
declarations.set(declaration.id.name, {
|
|
3838
3767
|
type: t33.tsTypeLiteral(declaration.body.body),
|
|
3839
3768
|
// 将接口体转换为类型字面量
|
|
3840
|
-
hasTypeParameters: !!_optionalChain([declaration, 'access',
|
|
3769
|
+
hasTypeParameters: !!_optionalChain([declaration, 'access', _107 => _107.typeParameters, 'optionalAccess', _108 => _108.params, 'access', _109 => _109.length])
|
|
3841
3770
|
// 检查是否有泛型参数
|
|
3842
3771
|
});
|
|
3843
3772
|
} else if (t33.isTSTypeAliasDeclaration(declaration)) {
|
|
3844
3773
|
declarations.set(declaration.id.name, {
|
|
3845
3774
|
type: declaration.typeAnnotation,
|
|
3846
3775
|
// 直接使用类型注解
|
|
3847
|
-
hasTypeParameters: !!_optionalChain([declaration, 'access',
|
|
3776
|
+
hasTypeParameters: !!_optionalChain([declaration, 'access', _110 => _110.typeParameters, 'optionalAccess', _111 => _111.params, 'access', _112 => _112.length])
|
|
3848
3777
|
// 检查是否有泛型参数
|
|
3849
3778
|
});
|
|
3850
3779
|
}
|
|
@@ -3882,7 +3811,7 @@ function resolveSlotType(tsType, options) {
|
|
|
3882
3811
|
}
|
|
3883
3812
|
if (t34.isTSTypeReference(tsType)) {
|
|
3884
3813
|
let shouldRecordReactNode = false;
|
|
3885
|
-
if (_optionalChain([tsType, 'access',
|
|
3814
|
+
if (_optionalChain([tsType, 'access', _113 => _113.typeParameters, 'optionalAccess', _114 => _114.params, 'access', _115 => _115.length])) {
|
|
3886
3815
|
const params = [];
|
|
3887
3816
|
for (const param of tsType.typeParameters.params) {
|
|
3888
3817
|
const resolved2 = resolveSlotType(param, options);
|
|
@@ -4046,7 +3975,7 @@ function resolveSlotPropFromMember(member) {
|
|
|
4046
3975
|
shouldRecordReactNode: false
|
|
4047
3976
|
};
|
|
4048
3977
|
}
|
|
4049
|
-
const typeAnnotation = _optionalChain([member, 'access',
|
|
3978
|
+
const typeAnnotation = _optionalChain([member, 'access', _116 => _116.typeAnnotation, 'optionalAccess', _117 => _117.typeAnnotation]);
|
|
4050
3979
|
const callable = typeAnnotation ? resolveCallableType(typeAnnotation) : null;
|
|
4051
3980
|
if (!callable) {
|
|
4052
3981
|
return {
|
|
@@ -4078,8 +4007,8 @@ function resolveSlotPropFromMember(member) {
|
|
|
4078
4007
|
// src/core/transform/sfc/script/syntax-processor/preprocess/resolve-props-interface/resolve-slot/define-slots.ts
|
|
4079
4008
|
function resolveDefineSlotsIface(path9, ctx) {
|
|
4080
4009
|
const { node } = path9;
|
|
4081
|
-
const tsParams = _optionalChain([node, 'access',
|
|
4082
|
-
if (!_optionalChain([tsParams, 'optionalAccess',
|
|
4010
|
+
const tsParams = _optionalChain([node, 'access', _118 => _118.typeParameters, 'optionalAccess', _119 => _119.params]);
|
|
4011
|
+
if (!_optionalChain([tsParams, 'optionalAccess', _120 => _120.length])) return;
|
|
4083
4012
|
const {
|
|
4084
4013
|
propsTSIface: { slotTypes }
|
|
4085
4014
|
} = ctx.scriptData;
|
|
@@ -4395,11 +4324,11 @@ function analyzeDeps(node, ctx, parentPath) {
|
|
|
4395
4324
|
const bindingPath = binding.path;
|
|
4396
4325
|
const declaratorPath = getVariableDeclaratorPath(bindingPath);
|
|
4397
4326
|
const isReactiveVarBinding = !!declaratorPath && isReactiveBinding(declaratorPath.node);
|
|
4398
|
-
const nodeInit = _optionalChain([declaratorPath, 'optionalAccess',
|
|
4327
|
+
const nodeInit = _optionalChain([declaratorPath, 'optionalAccess', _121 => _121.node, 'access', _122 => _122.init]);
|
|
4399
4328
|
const isReactiveApiCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && t38.isIdentifier(nodeInit.callee) && reactiveStateApis.has(nodeInit.callee.name);
|
|
4400
4329
|
const isHookCallVarBinding = !!declaratorPath && t38.isCallExpression(nodeInit) && isHookLikeCallee(nodeInit.callee);
|
|
4401
4330
|
const isFunctionBinding = bindingPath.isFunctionDeclaration() || !!declaratorPath && !!nodeInit && (t38.isArrowFunctionExpression(nodeInit) || t38.isFunctionExpression(nodeInit));
|
|
4402
|
-
const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess',
|
|
4331
|
+
const isReactiveFunctionBinding = isFunctionBinding && (isReactiveBinding(_optionalChain([declaratorPath, 'optionalAccess', _123 => _123.node])) || isReactiveBinding(bindingPath.node));
|
|
4403
4332
|
return isReactiveVarBinding || isReactiveApiCallVarBinding || isHookCallVarBinding || isReactiveFunctionBinding;
|
|
4404
4333
|
}
|
|
4405
4334
|
function isHookLikeCallee(callee) {
|
|
@@ -4506,7 +4435,7 @@ function isNestedMemberObject(path9) {
|
|
|
4506
4435
|
}
|
|
4507
4436
|
function isReactiveBinding(node) {
|
|
4508
4437
|
if (!node) return false;
|
|
4509
|
-
return !!_optionalChain([getScriptNodeMeta, 'call',
|
|
4438
|
+
return !!_optionalChain([getScriptNodeMeta, 'call', _124 => _124(node), 'optionalAccess', _125 => _125.is_reactive]);
|
|
4510
4439
|
}
|
|
4511
4440
|
|
|
4512
4441
|
// src/core/transform/sfc/script/syntax-processor/process/resolve-analysis-only-adapter.ts
|
|
@@ -4577,7 +4506,7 @@ function isVueImportBinding(binding) {
|
|
|
4577
4506
|
if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
|
|
4578
4507
|
return false;
|
|
4579
4508
|
}
|
|
4580
|
-
const parent = _optionalChain([bindingPath, 'access',
|
|
4509
|
+
const parent = _optionalChain([bindingPath, 'access', _126 => _126.parentPath, 'optionalAccess', _127 => _127.node]);
|
|
4581
4510
|
if (!parent || !t39.isImportDeclaration(parent)) {
|
|
4582
4511
|
return false;
|
|
4583
4512
|
}
|
|
@@ -4604,7 +4533,7 @@ function resolveArrowFnDeps(ctx, ast) {
|
|
|
4604
4533
|
const newNode = createUseCallback(node, deps);
|
|
4605
4534
|
const declaratorPath = getVariableDeclaratorPath(path9);
|
|
4606
4535
|
recordImport(ctx, PACKAGE_NAME.react, REACT_API_MAP.useCallback);
|
|
4607
|
-
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess',
|
|
4536
|
+
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _128 => _128.node]), { is_reactive: true, reactive_type: "indirect" });
|
|
4608
4537
|
replaceNode(path9, newNode, node);
|
|
4609
4538
|
}
|
|
4610
4539
|
};
|
|
@@ -4663,8 +4592,8 @@ function resolveElementRef(ctx) {
|
|
|
4663
4592
|
return;
|
|
4664
4593
|
}
|
|
4665
4594
|
if (isCompRefBindings) {
|
|
4666
|
-
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call',
|
|
4667
|
-
if (!t40.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess',
|
|
4595
|
+
const varDeclaratorPath = _optionalChain([getVariableDeclaratorPath, 'call', _129 => _129(path9), 'optionalAccess', _130 => _130.node]);
|
|
4596
|
+
if (!t40.isIdentifier(_optionalChain([varDeclaratorPath, 'optionalAccess', _131 => _131.id]))) {
|
|
4668
4597
|
return;
|
|
4669
4598
|
}
|
|
4670
4599
|
const varName = varDeclaratorPath.id.name;
|
|
@@ -4687,7 +4616,7 @@ function resolveTypeParameters(ctx, path9) {
|
|
|
4687
4616
|
scriptData
|
|
4688
4617
|
} = ctx;
|
|
4689
4618
|
const { node } = path9;
|
|
4690
|
-
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call',
|
|
4619
|
+
const varDeclaratorNode = _optionalChain([getVariableDeclaratorPath, 'call', _132 => _132(path9), 'optionalAccess', _133 => _133.node]);
|
|
4691
4620
|
if (!scriptData.lang.startsWith("ts") || !varDeclaratorNode) {
|
|
4692
4621
|
return;
|
|
4693
4622
|
}
|
|
@@ -4705,11 +4634,11 @@ function resolveRefValueToCurrent(path9) {
|
|
|
4705
4634
|
return;
|
|
4706
4635
|
}
|
|
4707
4636
|
const rootPath = findRootVariablePath(path9);
|
|
4708
|
-
if (!_optionalChain([rootPath, 'optionalAccess',
|
|
4637
|
+
if (!_optionalChain([rootPath, 'optionalAccess', _134 => _134.node]) || !t40.isCallExpression(rootPath.node.init) || !isCalleeNamed(rootPath.node.init, REACT_API_MAP.useRef)) {
|
|
4709
4638
|
return;
|
|
4710
4639
|
}
|
|
4711
4640
|
const rootId = findRootIdentifier(node);
|
|
4712
|
-
if (!t40.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess',
|
|
4641
|
+
if (!t40.isIdentifier(node.object) || node.object.name !== _optionalChain([rootId, 'optionalAccess', _135 => _135.name])) {
|
|
4713
4642
|
return;
|
|
4714
4643
|
}
|
|
4715
4644
|
node.property.name = "current";
|
|
@@ -4810,7 +4739,7 @@ function resolveProvide(ctx) {
|
|
|
4810
4739
|
return {
|
|
4811
4740
|
CallExpression(path9) {
|
|
4812
4741
|
const { node } = path9;
|
|
4813
|
-
const providerTarget = _optionalChain([ADAPTER_RULES, 'access',
|
|
4742
|
+
const providerTarget = _optionalChain([ADAPTER_RULES, 'access', _136 => _136.runtime, 'access', _137 => _137[VUE_API_MAP.provide], 'optionalAccess', _138 => _138.target]);
|
|
4814
4743
|
const isProvideCall = isCalleeNamed(node, VUE_API_MAP.provide) || providerTarget && isCalleeNamed(node, providerTarget);
|
|
4815
4744
|
if (!isProvideCall) return;
|
|
4816
4745
|
const { provide } = ctx.scriptData;
|
|
@@ -4828,7 +4757,7 @@ function findOrCreateCtxProvider(root) {
|
|
|
4828
4757
|
return root;
|
|
4829
4758
|
}
|
|
4830
4759
|
let cur = root.provide;
|
|
4831
|
-
while (_optionalChain([cur, 'optionalAccess',
|
|
4760
|
+
while (_optionalChain([cur, 'optionalAccess', _139 => _139.isOccupied])) {
|
|
4832
4761
|
cur = _nullishCoalesce(cur.provide, () => ( {}));
|
|
4833
4762
|
}
|
|
4834
4763
|
return cur || (root.provide = {});
|
|
@@ -4885,7 +4814,7 @@ function resolveRenameAdapter(ctx) {
|
|
|
4885
4814
|
if (adapter.isTrackable) {
|
|
4886
4815
|
const reactiveType = getReactiveType(apiName);
|
|
4887
4816
|
const declaratorPath = getVariableDeclaratorPath(path9);
|
|
4888
|
-
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess',
|
|
4817
|
+
setScriptNodeMeta(_optionalChain([declaratorPath, 'optionalAccess', _140 => _140.node]), {
|
|
4889
4818
|
is_reactive: true,
|
|
4890
4819
|
reactive_type: reactiveType
|
|
4891
4820
|
});
|
|
@@ -4903,6 +4832,10 @@ function resolveRenameAdapter(ctx) {
|
|
|
4903
4832
|
};
|
|
4904
4833
|
}
|
|
4905
4834
|
function isVueApiReference2(path9, apiName) {
|
|
4835
|
+
const whitelist = [VUE_API_MAP.defineAsyncComponent];
|
|
4836
|
+
if (whitelist.includes(apiName)) {
|
|
4837
|
+
return true;
|
|
4838
|
+
}
|
|
4906
4839
|
if (path9.isIdentifier()) {
|
|
4907
4840
|
if (path9.parentPath.isCallExpression() && path9.parentPath.node.callee === path9.node) {
|
|
4908
4841
|
return false;
|
|
@@ -4924,7 +4857,7 @@ function isVueImportBinding2(binding) {
|
|
|
4924
4857
|
if (!bindingPath.isImportSpecifier() && !bindingPath.isImportDefaultSpecifier() && !bindingPath.isImportNamespaceSpecifier()) {
|
|
4925
4858
|
return false;
|
|
4926
4859
|
}
|
|
4927
|
-
const parent = _optionalChain([bindingPath, 'access',
|
|
4860
|
+
const parent = _optionalChain([bindingPath, 'access', _141 => _141.parentPath, 'optionalAccess', _142 => _142.node]);
|
|
4928
4861
|
if (!parent || !t44.isImportDeclaration(parent)) {
|
|
4929
4862
|
return false;
|
|
4930
4863
|
}
|
|
@@ -4976,12 +4909,12 @@ function processVueSyntax2(ast, ctx) {
|
|
|
4976
4909
|
}
|
|
4977
4910
|
function vueSyntaxProcessor2(ast, ctx, options) {
|
|
4978
4911
|
const runExcludeThenApply = (cfg) => {
|
|
4979
|
-
_optionalChain([cfg, 'access',
|
|
4980
|
-
_optionalChain([cfg, 'access',
|
|
4912
|
+
_optionalChain([cfg, 'access', _143 => _143.excludeBabel, 'optionalAccess', _144 => _144.forEach, 'call', _145 => _145((fn) => fn(ctx, ast))]);
|
|
4913
|
+
_optionalChain([cfg, 'access', _146 => _146.applyBabel, 'optionalAccess', _147 => _147.forEach, 'call', _148 => _148((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
|
|
4981
4914
|
};
|
|
4982
4915
|
const runApplyThenExclude = (cfg) => {
|
|
4983
|
-
_optionalChain([cfg, 'access',
|
|
4984
|
-
_optionalChain([cfg, 'access',
|
|
4916
|
+
_optionalChain([cfg, 'access', _149 => _149.applyBabel, 'optionalAccess', _150 => _150.forEach, 'call', _151 => _151((fn) => _core.traverse.call(void 0, ast, fn(ctx, ast)))]);
|
|
4917
|
+
_optionalChain([cfg, 'access', _152 => _152.excludeBabel, 'optionalAccess', _153 => _153.forEach, 'call', _154 => _154((fn) => fn(ctx, ast))]);
|
|
4985
4918
|
};
|
|
4986
4919
|
runExcludeThenApply(options.preprocess);
|
|
4987
4920
|
runExcludeThenApply(options.process);
|
|
@@ -5070,7 +5003,7 @@ function isRouterLinkBooleanCustomProp(prop) {
|
|
|
5070
5003
|
var strCodeTypes = {
|
|
5071
5004
|
isIdentifier: isIdentifier24,
|
|
5072
5005
|
isSimpleExpression,
|
|
5073
|
-
isStringLiteral:
|
|
5006
|
+
isStringLiteral: isStringLiteral12
|
|
5074
5007
|
};
|
|
5075
5008
|
function isSimpleExpression(code, excludeVar = false) {
|
|
5076
5009
|
let node;
|
|
@@ -5107,7 +5040,7 @@ function isIdentifier24(code) {
|
|
|
5107
5040
|
return false;
|
|
5108
5041
|
}
|
|
5109
5042
|
}
|
|
5110
|
-
function
|
|
5043
|
+
function isStringLiteral12(code) {
|
|
5111
5044
|
try {
|
|
5112
5045
|
const node = _parser.parseExpression.call(void 0, code);
|
|
5113
5046
|
return t45.isStringLiteral(node);
|
|
@@ -5220,12 +5153,12 @@ function wrapSingleQuotes(content, condition) {
|
|
|
5220
5153
|
return condition || strCodeTypes.isStringLiteral(content) ? `'${content}'` : content;
|
|
5221
5154
|
}
|
|
5222
5155
|
function checkPropIsDynamicKey(ctx, node) {
|
|
5223
|
-
const isKeyStatic = _optionalChain([node, 'access',
|
|
5156
|
+
const isKeyStatic = _optionalChain([node, 'access', _155 => _155.arg, 'optionalAccess', _156 => _156.isStatic]);
|
|
5224
5157
|
const { source, filename } = ctx;
|
|
5225
5158
|
if (node.rawName === "v-bind" && !node.name) {
|
|
5226
5159
|
logger.warn("Keyless v-bind will overwrite all previously declared props at runtime.", {
|
|
5227
5160
|
source,
|
|
5228
|
-
loc: _optionalChain([node, 'access',
|
|
5161
|
+
loc: _optionalChain([node, 'access', _157 => _157.arg, 'optionalAccess', _158 => _158.loc]),
|
|
5229
5162
|
file: filename
|
|
5230
5163
|
});
|
|
5231
5164
|
return;
|
|
@@ -5233,7 +5166,7 @@ function checkPropIsDynamicKey(ctx, node) {
|
|
|
5233
5166
|
if (isKeyStatic === false) {
|
|
5234
5167
|
logger.warn("Avoid using dynamic slot names, as they generate complex JSX prop expressions.", {
|
|
5235
5168
|
source,
|
|
5236
|
-
loc: _optionalChain([node, 'access',
|
|
5169
|
+
loc: _optionalChain([node, 'access', _159 => _159.arg, 'optionalAccess', _160 => _160.loc]),
|
|
5237
5170
|
file: filename
|
|
5238
5171
|
});
|
|
5239
5172
|
}
|
|
@@ -5254,21 +5187,21 @@ function resolvePropAsBabelExp(ir, ctx) {
|
|
|
5254
5187
|
target.content = valueName;
|
|
5255
5188
|
target.ast = t46.jsxIdentifier(valueName);
|
|
5256
5189
|
};
|
|
5257
|
-
const setValueExpression = (target, content,
|
|
5190
|
+
const setValueExpression = (target, content, isStringLiteral13) => {
|
|
5258
5191
|
target.content = content;
|
|
5259
|
-
target.ast = resolveStringExpr(content, ctx,
|
|
5192
|
+
target.ast = resolveStringExpr(content, ctx, isStringLiteral13);
|
|
5260
5193
|
};
|
|
5261
5194
|
const createRuntimeCall = (fnName, args) => {
|
|
5262
5195
|
const fnArgs = args.filter(Boolean).join(",");
|
|
5263
5196
|
return `${fnName}(${fnArgs})`;
|
|
5264
5197
|
};
|
|
5265
|
-
const applyRuntimeExpression = (expression, setName = false, nameIdentifier,
|
|
5198
|
+
const applyRuntimeExpression = (expression, setName = false, nameIdentifier, isStringLiteral13) => {
|
|
5266
5199
|
if (setName && nameIdentifier) {
|
|
5267
5200
|
setNameIdentifier(nameExp, nameIdentifier);
|
|
5268
5201
|
}
|
|
5269
5202
|
const dir = ADAPTER_RULES.runtime.dir;
|
|
5270
5203
|
recordImport(ctx, dir.package, dir.target);
|
|
5271
|
-
setValueExpression(value.babelExp, expression,
|
|
5204
|
+
setValueExpression(value.babelExp, expression, isStringLiteral13);
|
|
5272
5205
|
};
|
|
5273
5206
|
if (ir.isKeyLessVBind) {
|
|
5274
5207
|
const dirKeyless = ADAPTER_RULES.runtime.dirKeyless;
|
|
@@ -5278,19 +5211,19 @@ function resolvePropAsBabelExp(ir, ctx) {
|
|
|
5278
5211
|
}
|
|
5279
5212
|
if (isClassAttr(name) && !value.isStringLiteral && !valueContent.startsWith(STYLE_MODULE_NAME)) {
|
|
5280
5213
|
const dirCls = ADAPTER_RULES.runtime.dirCls;
|
|
5281
|
-
const arg = _optionalChain([mergedItems, 'optionalAccess',
|
|
5214
|
+
const arg = _optionalChain([mergedItems, 'optionalAccess', _161 => _161.join, 'call', _162 => _162(",")]) || wrapSingleQuotes(valueContent);
|
|
5282
5215
|
const expression = createRuntimeCall(dirCls.target, [arg]);
|
|
5283
5216
|
applyRuntimeExpression(expression, true, name);
|
|
5284
5217
|
return;
|
|
5285
5218
|
}
|
|
5286
|
-
if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess',
|
|
5219
|
+
if (isStyleAttr(name) && (!isSimpleStyle(valueContent) || _optionalChain([mergedItems, 'optionalAccess', _163 => _163.some, 'call', _164 => _164((item) => !isSimpleStyle(item))]))) {
|
|
5287
5220
|
const dirStyle = ADAPTER_RULES.runtime.dirStyle;
|
|
5288
|
-
const arg = _optionalChain([mergedItems, 'optionalAccess',
|
|
5221
|
+
const arg = _optionalChain([mergedItems, 'optionalAccess', _165 => _165.join, 'call', _166 => _166(",")]) || valueContent;
|
|
5289
5222
|
const expression = createRuntimeCall(dirStyle.target, [arg]);
|
|
5290
5223
|
applyRuntimeExpression(expression, true, name);
|
|
5291
5224
|
return;
|
|
5292
5225
|
}
|
|
5293
|
-
if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access',
|
|
5226
|
+
if (ir.type === 3 /* EVENT */ && _optionalChain([ir, 'access', _167 => _167.modifiers, 'optionalAccess', _168 => _168.length])) {
|
|
5294
5227
|
const dirOn = ADAPTER_RULES.runtime.dirOn;
|
|
5295
5228
|
const eventName = wrapSingleQuotes(ir.__vOnEvName || name, ir.isStatic);
|
|
5296
5229
|
const expression = createRuntimeCall(dirOn.target, [eventName, valueContent]);
|
|
@@ -5345,7 +5278,7 @@ function resolveElementChildrenRules(children, ctx, parentIR, ir) {
|
|
|
5345
5278
|
continue;
|
|
5346
5279
|
}
|
|
5347
5280
|
const nodeIR = child;
|
|
5348
|
-
if (_optionalChain([parentIR, 'optionalAccess',
|
|
5281
|
+
if (_optionalChain([parentIR, 'optionalAccess', _169 => _169.isBuiltIn])) {
|
|
5349
5282
|
if (parentIR.tag == VUE_API_MAP.Transition) {
|
|
5350
5283
|
resolveTransitionRules(nodeIR, parentIR, ir, ctx);
|
|
5351
5284
|
}
|
|
@@ -5386,7 +5319,7 @@ function walkElementNodes(node, onElement) {
|
|
|
5386
5319
|
}
|
|
5387
5320
|
function resolveDefaultStyleModuleName(node) {
|
|
5388
5321
|
const { exp } = node;
|
|
5389
|
-
if (_optionalChain([exp, 'optionalAccess',
|
|
5322
|
+
if (_optionalChain([exp, 'optionalAccess', _170 => _170.type]) !== _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
5390
5323
|
return;
|
|
5391
5324
|
}
|
|
5392
5325
|
if (exp.content.includes("$style")) {
|
|
@@ -5435,7 +5368,7 @@ function injectStyleScopeAttribute(node, ctx) {
|
|
|
5435
5368
|
break;
|
|
5436
5369
|
}
|
|
5437
5370
|
}
|
|
5438
|
-
if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access',
|
|
5371
|
+
if (prop.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([prop, 'access', _171 => _171.arg, 'optionalAccess', _172 => _172.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
5439
5372
|
if (getHasClassOrId(prop.arg.content)) {
|
|
5440
5373
|
hasClassOrId = true;
|
|
5441
5374
|
break;
|
|
@@ -5495,7 +5428,7 @@ function mergeStyleProps(oldAttr, newAttr) {
|
|
|
5495
5428
|
const oldStyle = oldAttr.value.content;
|
|
5496
5429
|
const newStyle = parseStyleString(newAttr.value.content);
|
|
5497
5430
|
let merged = oldAttr.value.merge;
|
|
5498
|
-
if (!_optionalChain([merged, 'optionalAccess',
|
|
5431
|
+
if (!_optionalChain([merged, 'optionalAccess', _173 => _173.length])) {
|
|
5499
5432
|
merged = oldAttr.value.merge = [oldStyle, newStyle];
|
|
5500
5433
|
} else {
|
|
5501
5434
|
merged.push(newStyle);
|
|
@@ -5525,7 +5458,7 @@ function warnUnsupportedVueDollarVar(ctx, node) {
|
|
|
5525
5458
|
const { source, filename } = ctx;
|
|
5526
5459
|
let value = "";
|
|
5527
5460
|
let loc;
|
|
5528
|
-
if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access',
|
|
5461
|
+
if (node.type === _compilercore.NodeTypes.DIRECTIVE && _optionalChain([node, 'access', _174 => _174.exp, 'optionalAccess', _175 => _175.type]) === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
5529
5462
|
value = node.exp.content;
|
|
5530
5463
|
loc = node.exp.loc;
|
|
5531
5464
|
} else if (node.type === _compilercore.NodeTypes.INTERPOLATION && node.content.type === _compilercore.NodeTypes.SIMPLE_EXPRESSION) {
|
|
@@ -5579,11 +5512,11 @@ function resolveRefProp(prop, ctx, nodeIR) {
|
|
|
5579
5512
|
} = ctx;
|
|
5580
5513
|
let propIR;
|
|
5581
5514
|
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
5582
|
-
const tag = _optionalChain([prop, 'access',
|
|
5515
|
+
const tag = _optionalChain([prop, 'access', _176 => _176.value, 'optionalAccess', _177 => _177.content]);
|
|
5583
5516
|
if (!tag) return;
|
|
5584
5517
|
collectComponentRef(tag, ctx);
|
|
5585
5518
|
const domRefBinding = Object.values(refBindings.domRefs).find((r) => r.tag === tag);
|
|
5586
|
-
const refVar = _optionalChain([domRefBinding, 'optionalAccess',
|
|
5519
|
+
const refVar = _optionalChain([domRefBinding, 'optionalAccess', _178 => _178.name]) || _optionalChain([refBindings, 'access', _179 => _179.componentRefs, 'access', _180 => _180[tag], 'optionalAccess', _181 => _181.name]);
|
|
5587
5520
|
propIR = createPropsIR("ref", "ref", refVar || "null");
|
|
5588
5521
|
} else {
|
|
5589
5522
|
const exp = prop.exp;
|
|
@@ -5619,14 +5552,30 @@ function collectComponentRef(tag, ctx) {
|
|
|
5619
5552
|
|
|
5620
5553
|
|
|
5621
5554
|
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
const
|
|
5555
|
+
|
|
5556
|
+
function resolveTemplateNodeKey(templNode, keyContent, ctx) {
|
|
5557
|
+
const { filename, source } = ctx;
|
|
5558
|
+
const { children, loc } = templNode;
|
|
5559
|
+
if (children.length > 1) {
|
|
5560
|
+
logger.warn(
|
|
5561
|
+
"Expected <template> with `:key` to have a single parent element; otherwise, the key cannot be transferred to the first child.",
|
|
5562
|
+
{
|
|
5563
|
+
file: filename,
|
|
5564
|
+
source,
|
|
5565
|
+
loc
|
|
5566
|
+
}
|
|
5567
|
+
);
|
|
5568
|
+
return;
|
|
5569
|
+
}
|
|
5570
|
+
const [firstChild] = children;
|
|
5571
|
+
if (_optionalChain([firstChild, 'optionalAccess', _182 => _182.type]) !== _compilercore.NodeTypes.ELEMENT || firstChild.tagType === _compilercore.ElementTypes.TEMPLATE || firstChild.tagType === _compilercore.ElementTypes.SLOT) {
|
|
5572
|
+
return;
|
|
5573
|
+
}
|
|
5574
|
+
const hasKeyProp = firstChild.props.some(
|
|
5626
5575
|
(p) => p.type === _compilercore.NodeTypes.DIRECTIVE && p.name === "key"
|
|
5627
5576
|
);
|
|
5628
5577
|
if (hasKeyProp) return;
|
|
5629
|
-
|
|
5578
|
+
firstChild.props.push(createSimpleVueBind("key", keyContent));
|
|
5630
5579
|
}
|
|
5631
5580
|
function createSimpleVueBind(name, value) {
|
|
5632
5581
|
return {
|
|
@@ -5656,8 +5605,8 @@ function createSimpleVueBind(name, value) {
|
|
|
5656
5605
|
function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
|
|
5657
5606
|
const arg = directive.arg;
|
|
5658
5607
|
const exp = directive.exp;
|
|
5659
|
-
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5660
|
-
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5608
|
+
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _183 => _183.content]), () => ( ""));
|
|
5609
|
+
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _184 => _184.content]), () => ( "true"));
|
|
5661
5610
|
warnUnsupportedVueDollarVar(ctx, directive);
|
|
5662
5611
|
if (name === "is") {
|
|
5663
5612
|
resolveDynamicIsProp(directive, ir, ctx, nodeIR);
|
|
@@ -5668,11 +5617,11 @@ function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
|
|
|
5668
5617
|
return;
|
|
5669
5618
|
}
|
|
5670
5619
|
if (vueNode.tag === "template" && name === "key") {
|
|
5671
|
-
resolveTemplateNodeKey(vueNode, content);
|
|
5620
|
+
resolveTemplateNodeKey(vueNode, content, ctx);
|
|
5672
5621
|
return;
|
|
5673
5622
|
}
|
|
5674
5623
|
const propIR = createPropsIR(directive.rawName, name, content);
|
|
5675
|
-
propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5624
|
+
propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _185 => _185.isStatic]), () => ( true));
|
|
5676
5625
|
checkPropIsDynamicKey(ctx, directive);
|
|
5677
5626
|
resolvePropertyIR(propIR, ir, ctx, nodeIR, true);
|
|
5678
5627
|
}
|
|
@@ -5686,12 +5635,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
|
|
|
5686
5635
|
content = propsIR.value.content = parseStyleString(content);
|
|
5687
5636
|
}
|
|
5688
5637
|
if (isDynamic) {
|
|
5689
|
-
const
|
|
5690
|
-
if (
|
|
5638
|
+
const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
|
|
5639
|
+
if (isStringLiteral13) {
|
|
5691
5640
|
content = normalizeString(content);
|
|
5692
5641
|
propsIR.value.content = content;
|
|
5693
5642
|
}
|
|
5694
|
-
propsIR.value.isStringLiteral =
|
|
5643
|
+
propsIR.value.isStringLiteral = isStringLiteral13;
|
|
5695
5644
|
}
|
|
5696
5645
|
const existing = findSameProp(nodeIR.props, propsIR);
|
|
5697
5646
|
if (existing) {
|
|
@@ -5711,7 +5660,7 @@ function normalizeString(s) {
|
|
|
5711
5660
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
|
|
5712
5661
|
function resolveAttributeProp(attribute, ir, ctx, nodeIR) {
|
|
5713
5662
|
const name = attribute.name;
|
|
5714
|
-
const content = _nullishCoalesce(_optionalChain([attribute, 'access',
|
|
5663
|
+
const content = _nullishCoalesce(_optionalChain([attribute, 'access', _186 => _186.value, 'optionalAccess', _187 => _187.content]), () => ( "true"));
|
|
5715
5664
|
if (name === "is") {
|
|
5716
5665
|
resolveStaticIsProp(content, ir, ctx, nodeIR);
|
|
5717
5666
|
return;
|
|
@@ -5806,10 +5755,10 @@ function resolveRouterLinkVSlotProp(directive, nodeIR, ctx) {
|
|
|
5806
5755
|
type: 2 /* SLOT */,
|
|
5807
5756
|
name: "customRender",
|
|
5808
5757
|
rawName: _nullishCoalesce(directive.rawName, () => ( "v-slot")),
|
|
5809
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5758
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _188 => _188.isStatic]), () => ( true)),
|
|
5810
5759
|
isScoped: true,
|
|
5811
5760
|
callback: {
|
|
5812
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5761
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _189 => _189.content, 'optionalAccess', _190 => _190.trim, 'call', _191 => _191()]), () => ( "")),
|
|
5813
5762
|
exp: []
|
|
5814
5763
|
}
|
|
5815
5764
|
};
|
|
@@ -5825,10 +5774,10 @@ function resolveVFor(directive, ir, ctx, nodeIR) {
|
|
|
5825
5774
|
};
|
|
5826
5775
|
}
|
|
5827
5776
|
function resolveForResult(forParseResult) {
|
|
5828
|
-
const source = _optionalChain([forParseResult, 'access',
|
|
5829
|
-
const value = _optionalChain([forParseResult, 'access',
|
|
5830
|
-
const index = _optionalChain([forParseResult, 'access',
|
|
5831
|
-
const key = _optionalChain([forParseResult, 'access',
|
|
5777
|
+
const source = _optionalChain([forParseResult, 'access', _192 => _192.source, 'optionalAccess', _193 => _193.content]);
|
|
5778
|
+
const value = _optionalChain([forParseResult, 'access', _194 => _194.value, 'optionalAccess', _195 => _195.content]);
|
|
5779
|
+
const index = _optionalChain([forParseResult, 'access', _196 => _196.index, 'optionalAccess', _197 => _197.content]);
|
|
5780
|
+
const key = _optionalChain([forParseResult, 'access', _198 => _198.key, 'optionalAccess', _199 => _199.content]);
|
|
5832
5781
|
return {
|
|
5833
5782
|
source,
|
|
5834
5783
|
value,
|
|
@@ -5848,7 +5797,7 @@ function resolveVHtml(directive, ir, ctx, nodeIR) {
|
|
|
5848
5797
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
|
|
5849
5798
|
function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
|
|
5850
5799
|
const name = directive.name === "else-if" ? "elseIf" : directive.name;
|
|
5851
|
-
const value = _nullishCoalesce(_optionalChain([directive, 'access',
|
|
5800
|
+
const value = _nullishCoalesce(_optionalChain([directive, 'access', _200 => _200.exp, 'optionalAccess', _201 => _201.content]), () => ( "true"));
|
|
5852
5801
|
const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
|
|
5853
5802
|
const isElseBranch = name === "else" || name === "elseIf";
|
|
5854
5803
|
let hasError = false;
|
|
@@ -5887,7 +5836,7 @@ function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
|
|
|
5887
5836
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
|
|
5888
5837
|
function resolveVMemo(directive, _ir, ctx, nodeIR) {
|
|
5889
5838
|
const exp = directive.exp;
|
|
5890
|
-
let value = _optionalChain([exp, 'optionalAccess',
|
|
5839
|
+
let value = _optionalChain([exp, 'optionalAccess', _202 => _202.content]);
|
|
5891
5840
|
if (value !== void 0) {
|
|
5892
5841
|
if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
|
|
5893
5842
|
const { source, filename } = ctx;
|
|
@@ -5927,14 +5876,14 @@ function resolveVModel(directive, ir, ctx, vueNode, nodeIR) {
|
|
|
5927
5876
|
const getterName = exp.content;
|
|
5928
5877
|
const isComponent = vueNode.tagType === _compilercore.ElementTypes.COMPONENT;
|
|
5929
5878
|
const inputType = resolveHtmlInput(vueNode, isComponent);
|
|
5930
|
-
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5879
|
+
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _203 => _203.content]), () => ( resolveModelPropName(inputType, isComponent)));
|
|
5931
5880
|
let valuePropIR;
|
|
5932
5881
|
let eventPropIR;
|
|
5933
5882
|
if (isComponent) {
|
|
5934
5883
|
valuePropIR = createPropsIR("v-model", propName, getterName);
|
|
5935
5884
|
const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
|
|
5936
5885
|
const eventVueName = `update:${propName}`;
|
|
5937
|
-
const isTS = _optionalChain([ctx, 'access',
|
|
5886
|
+
const isTS = _optionalChain([ctx, 'access', _204 => _204.scriptData, 'optionalAccess', _205 => _205.lang, 'optionalAccess', _206 => _206.startsWith, 'call', _207 => _207("ts")]);
|
|
5938
5887
|
const valueArg = isTS ? "value: any" : "value";
|
|
5939
5888
|
const processedValue = applyValueModifiers("value", modifiers);
|
|
5940
5889
|
const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
|
|
@@ -5972,7 +5921,7 @@ function getRadioValue(vueNode) {
|
|
|
5972
5921
|
const valueAttr = vueNode.props.find(
|
|
5973
5922
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
|
|
5974
5923
|
);
|
|
5975
|
-
if (!_optionalChain([valueAttr, 'optionalAccess',
|
|
5924
|
+
if (!_optionalChain([valueAttr, 'optionalAccess', _208 => _208.value, 'optionalAccess', _209 => _209.content])) return '""';
|
|
5976
5925
|
const content = valueAttr.value.content;
|
|
5977
5926
|
return /^['"]/.test(content) ? content : `"${content}"`;
|
|
5978
5927
|
}
|
|
@@ -5982,7 +5931,7 @@ function resolveHtmlInput(node, isComponent) {
|
|
|
5982
5931
|
const typeProp = node.props.find(
|
|
5983
5932
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
|
|
5984
5933
|
);
|
|
5985
|
-
return _optionalChain([typeProp, 'optionalAccess',
|
|
5934
|
+
return _optionalChain([typeProp, 'optionalAccess', _210 => _210.value, 'optionalAccess', _211 => _211.content, 'optionalAccess', _212 => _212.toLowerCase, 'call', _213 => _213()]);
|
|
5986
5935
|
}
|
|
5987
5936
|
function applyValueModifiers(valueExp, modifiers) {
|
|
5988
5937
|
let result = valueExp;
|
|
@@ -6067,7 +6016,7 @@ function resolveVSlotProp(directive, ir, ctx) {
|
|
|
6067
6016
|
const name = !arg || arg.content === "default" ? "children" : arg.content;
|
|
6068
6017
|
const content = !isScoped ? [] : void 0;
|
|
6069
6018
|
const callback = isScoped ? {
|
|
6070
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
6019
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _214 => _214.content, 'optionalAccess', _215 => _215.trim, 'call', _216 => _216()]), () => ( "")),
|
|
6071
6020
|
exp: []
|
|
6072
6021
|
} : void 0;
|
|
6073
6022
|
checkPropIsDynamicKey(ctx, directive);
|
|
@@ -6075,7 +6024,7 @@ function resolveVSlotProp(directive, ir, ctx) {
|
|
|
6075
6024
|
type: 2 /* SLOT */,
|
|
6076
6025
|
name,
|
|
6077
6026
|
rawName: _nullishCoalesce(directive.rawName, () => ( "default")),
|
|
6078
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
6027
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _217 => _217.isStatic]), () => ( true)),
|
|
6079
6028
|
isScoped,
|
|
6080
6029
|
content,
|
|
6081
6030
|
callback
|
|
@@ -6138,7 +6087,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
|
|
|
6138
6087
|
if (routerAdapter) {
|
|
6139
6088
|
if (!ctx.route) ctx.route = true;
|
|
6140
6089
|
nodeIR.isRoute = true;
|
|
6141
|
-
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess',
|
|
6090
|
+
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _218 => _218.package]), routerAdapter.target);
|
|
6142
6091
|
}
|
|
6143
6092
|
resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
|
|
6144
6093
|
return nodeIR;
|
|
@@ -6285,7 +6234,7 @@ function resolveSlotProps(node, ctx) {
|
|
|
6285
6234
|
for (const prop of node.props) {
|
|
6286
6235
|
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
6287
6236
|
const attr = prop.name;
|
|
6288
|
-
const value = _optionalChain([prop, 'access',
|
|
6237
|
+
const value = _optionalChain([prop, 'access', _219 => _219.value, 'optionalAccess', _220 => _220.content, 'access', _221 => _221.trim, 'call', _222 => _222()]);
|
|
6289
6238
|
if (attr === "name" && value) {
|
|
6290
6239
|
result.name = camelCase(value);
|
|
6291
6240
|
} else {
|
|
@@ -6375,19 +6324,19 @@ function resolveTemplate2(root, ctx) {
|
|
|
6375
6324
|
// src/core/transform/sfc/index.ts
|
|
6376
6325
|
function transform(ast, ctx, options) {
|
|
6377
6326
|
const { template, script, style } = ast;
|
|
6378
|
-
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess',
|
|
6379
|
-
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess',
|
|
6327
|
+
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _223 => _223.ast]), ctx);
|
|
6328
|
+
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _224 => _224.ast]), ctx);
|
|
6380
6329
|
const result = {
|
|
6381
6330
|
template: templateIR,
|
|
6382
6331
|
script: scriptIR,
|
|
6383
|
-
style: _optionalChain([style, 'optionalAccess',
|
|
6332
|
+
style: _optionalChain([style, 'optionalAccess', _225 => _225.source, 'optionalAccess', _226 => _226.content])
|
|
6384
6333
|
};
|
|
6385
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6334
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _227 => _227.plugins]), result, ctx);
|
|
6386
6335
|
return result;
|
|
6387
6336
|
}
|
|
6388
6337
|
|
|
6389
6338
|
// package.json
|
|
6390
|
-
var version = "1.6.
|
|
6339
|
+
var version = "1.6.2";
|
|
6391
6340
|
var bin = {
|
|
6392
6341
|
vureact: "./bin/vureact.js"
|
|
6393
6342
|
};
|
|
@@ -6581,7 +6530,7 @@ var Helper = (_class5 = class {
|
|
|
6581
6530
|
__init8() {this.outDir = "react-app"}
|
|
6582
6531
|
constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
|
|
6583
6532
|
this.compilerOpts = opts;
|
|
6584
|
-
if (_optionalChain([opts, 'access',
|
|
6533
|
+
if (_optionalChain([opts, 'access', _228 => _228.output, 'optionalAccess', _229 => _229.workspace])) {
|
|
6585
6534
|
this.workspaceDir = opts.output.workspace;
|
|
6586
6535
|
}
|
|
6587
6536
|
const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
|
|
@@ -6618,7 +6567,7 @@ var Helper = (_class5 = class {
|
|
|
6618
6567
|
}
|
|
6619
6568
|
getOutDirName() {
|
|
6620
6569
|
const { output } = this.compilerOpts;
|
|
6621
|
-
return _optionalChain([output, 'optionalAccess',
|
|
6570
|
+
return _optionalChain([output, 'optionalAccess', _230 => _230.outDir]) || this.outDir;
|
|
6622
6571
|
}
|
|
6623
6572
|
getWorkspaceDir() {
|
|
6624
6573
|
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
|
|
@@ -6632,7 +6581,7 @@ var Helper = (_class5 = class {
|
|
|
6632
6581
|
}
|
|
6633
6582
|
getIgnoreAssets() {
|
|
6634
6583
|
const { output } = this.compilerOpts;
|
|
6635
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6584
|
+
if (_optionalChain([output, 'optionalAccess', _231 => _231.ignoreAssets])) {
|
|
6636
6585
|
return new Set(output.ignoreAssets.map(normalizePath));
|
|
6637
6586
|
}
|
|
6638
6587
|
return /* @__PURE__ */ new Set([
|
|
@@ -6715,12 +6664,12 @@ var Helper = (_class5 = class {
|
|
|
6715
6664
|
*/
|
|
6716
6665
|
async formatCode({ code, fileInfo }) {
|
|
6717
6666
|
const { format } = this.compilerOpts;
|
|
6718
|
-
if (!_optionalChain([format, 'optionalAccess',
|
|
6719
|
-
if (_optionalChain([format, 'optionalAccess',
|
|
6667
|
+
if (!_optionalChain([format, 'optionalAccess', _232 => _232.enabled])) return code;
|
|
6668
|
+
if (_optionalChain([format, 'optionalAccess', _233 => _233.formatter]) === "builtin") {
|
|
6720
6669
|
return simpleFormat(code);
|
|
6721
6670
|
}
|
|
6722
|
-
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess',
|
|
6723
|
-
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess',
|
|
6671
|
+
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _234 => _234.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _235 => _235.script])));
|
|
6672
|
+
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _236 => _236.prettierOptions]));
|
|
6724
6673
|
}
|
|
6725
6674
|
/**
|
|
6726
6675
|
* 通用的缓存校验工具函数
|
|
@@ -6754,7 +6703,7 @@ var Helper = (_class5 = class {
|
|
|
6754
6703
|
* @param options.lock - 是否启用文件锁(默认false)
|
|
6755
6704
|
*/
|
|
6756
6705
|
async writeFileWithDir(filePath, content, options) {
|
|
6757
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6706
|
+
if (_optionalChain([options, 'optionalAccess', _237 => _237.lock])) {
|
|
6758
6707
|
await fileLock.updateFile(filePath, async () => content, options);
|
|
6759
6708
|
} else {
|
|
6760
6709
|
await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
@@ -6879,7 +6828,7 @@ var Helper = (_class5 = class {
|
|
|
6879
6828
|
* 获取需要排除编译的文件
|
|
6880
6829
|
*/
|
|
6881
6830
|
getExcludes() {
|
|
6882
|
-
if (!_optionalChain([this, 'access',
|
|
6831
|
+
if (!_optionalChain([this, 'access', _238 => _238.compilerOpts, 'access', _239 => _239.exclude, 'optionalAccess', _240 => _240.length])) {
|
|
6883
6832
|
return PathFilter.withDefaults();
|
|
6884
6833
|
}
|
|
6885
6834
|
return this.compilerOpts.exclude;
|
|
@@ -6977,7 +6926,7 @@ function parseOnlyStyle(source, ctx, options) {
|
|
|
6977
6926
|
ast: void 0
|
|
6978
6927
|
}
|
|
6979
6928
|
};
|
|
6980
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6929
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _241 => _241.plugins]), result, ctx);
|
|
6981
6930
|
return result;
|
|
6982
6931
|
}
|
|
6983
6932
|
|
|
@@ -7111,16 +7060,16 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7111
7060
|
});
|
|
7112
7061
|
const genOptions = this.prepareGenerateOptions(filename);
|
|
7113
7062
|
const resolveSFCAndScriptFile = () => {
|
|
7114
|
-
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7115
|
-
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7063
|
+
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _242 => _242.parser]) });
|
|
7064
|
+
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _243 => _243.transformer]) });
|
|
7116
7065
|
const gen = generate(ir, ctx.data, {
|
|
7117
7066
|
...genOptions,
|
|
7118
|
-
plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7067
|
+
plugins: _optionalChain([plugins, 'optionalAccess', _244 => _244.codegen])
|
|
7119
7068
|
});
|
|
7120
7069
|
return this.resolveMainResult(ir, gen, ctx.data);
|
|
7121
7070
|
};
|
|
7122
7071
|
const resolveStyleFile = () => {
|
|
7123
|
-
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7072
|
+
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _245 => _245.parser]) });
|
|
7124
7073
|
return this.resolveStyleResult(result, ctx.data);
|
|
7125
7074
|
};
|
|
7126
7075
|
try {
|
|
@@ -7159,9 +7108,9 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7159
7108
|
lang
|
|
7160
7109
|
},
|
|
7161
7110
|
css: {
|
|
7162
|
-
file: _optionalChain([styleData, 'optionalAccess',
|
|
7163
|
-
hash: _optionalChain([styleData, 'optionalAccess',
|
|
7164
|
-
code: _optionalChain([ir, 'optionalAccess',
|
|
7111
|
+
file: _optionalChain([styleData, 'optionalAccess', _246 => _246.filePath]),
|
|
7112
|
+
hash: _optionalChain([styleData, 'optionalAccess', _247 => _247.scopeId]),
|
|
7113
|
+
code: _optionalChain([ir, 'optionalAccess', _248 => _248.style])
|
|
7165
7114
|
}
|
|
7166
7115
|
},
|
|
7167
7116
|
...base
|
|
@@ -7231,7 +7180,7 @@ var AssetManager = (_class8 = class {
|
|
|
7231
7180
|
const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
|
|
7232
7181
|
const filename = _path2.default.basename(p).toLowerCase();
|
|
7233
7182
|
const ext = _path2.default.extname(p).toLowerCase();
|
|
7234
|
-
if (!_optionalChain([options, 'access',
|
|
7183
|
+
if (!_optionalChain([options, 'access', _249 => _249.output, 'optionalAccess', _250 => _250.ignoreAssets])) {
|
|
7235
7184
|
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
7236
7185
|
if (pattern.endsWith(".")) {
|
|
7237
7186
|
return filename.startsWith(pattern);
|
|
@@ -7328,12 +7277,12 @@ var CacheManager = (_class9 = class {
|
|
|
7328
7277
|
const meta = { ...unit };
|
|
7329
7278
|
delete meta.source;
|
|
7330
7279
|
if (key === "sfc" /* SFC */) {
|
|
7331
|
-
_optionalChainDelete([meta, 'access',
|
|
7332
|
-
_optionalChainDelete([meta, 'access',
|
|
7280
|
+
_optionalChainDelete([meta, 'access', _251 => _251.output, 'optionalAccess', _252 => _252.jsx, 'access', _253 => delete _253.code]);
|
|
7281
|
+
_optionalChainDelete([meta, 'access', _254 => _254.output, 'optionalAccess', _255 => _255.css, 'access', _256 => delete _256.code]);
|
|
7333
7282
|
} else if (key === "script" /* SCRIPT */) {
|
|
7334
|
-
_optionalChainDelete([meta, 'access',
|
|
7283
|
+
_optionalChainDelete([meta, 'access', _257 => _257.output, 'optionalAccess', _258 => _258.script, 'access', _259 => delete _259.code]);
|
|
7335
7284
|
} else if (key === "style" /* STYLE */) {
|
|
7336
|
-
_optionalChainDelete([meta, 'access',
|
|
7285
|
+
_optionalChainDelete([meta, 'access', _260 => _260.output, 'optionalAccess', _261 => _261.style, 'access', _262 => delete _262.code]);
|
|
7337
7286
|
}
|
|
7338
7287
|
if (!this.pendingUpdates.has(key)) {
|
|
7339
7288
|
this.pendingUpdates.set(key, []);
|
|
@@ -7403,7 +7352,7 @@ var CleanupManager = class {
|
|
|
7403
7352
|
meta = m;
|
|
7404
7353
|
const { jsx, css } = meta.output;
|
|
7405
7354
|
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
7406
|
-
if (_optionalChain([css, 'optionalAccess',
|
|
7355
|
+
if (_optionalChain([css, 'optionalAccess', _263 => _263.file])) {
|
|
7407
7356
|
await this.fileCompiler.removeOutputFile(css.file);
|
|
7408
7357
|
}
|
|
7409
7358
|
break;
|
|
@@ -7464,7 +7413,7 @@ var CompilationUnitProcessor = class {
|
|
|
7464
7413
|
const isScriptFile = key === "script" /* SCRIPT */;
|
|
7465
7414
|
const isStyleFile = key === "style" /* STYLE */;
|
|
7466
7415
|
if (isSFC || isScriptFile) {
|
|
7467
|
-
unit.hasRoute = _optionalChain([result, 'optionalAccess',
|
|
7416
|
+
unit.hasRoute = _optionalChain([result, 'optionalAccess', _264 => _264.hasRoute]);
|
|
7468
7417
|
}
|
|
7469
7418
|
const resolveFileInfo = () => {
|
|
7470
7419
|
if (isSFC) {
|
|
@@ -7484,7 +7433,7 @@ var CompilationUnitProcessor = class {
|
|
|
7484
7433
|
const { script } = result.fileInfo;
|
|
7485
7434
|
unit.output = {
|
|
7486
7435
|
script: {
|
|
7487
|
-
file: _optionalChain([script, 'optionalAccess',
|
|
7436
|
+
file: _optionalChain([script, 'optionalAccess', _265 => _265.file]),
|
|
7488
7437
|
code
|
|
7489
7438
|
}
|
|
7490
7439
|
};
|
|
@@ -7561,7 +7510,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7561
7510
|
const absPath = this.fileCompiler.getAbsPath(filePath);
|
|
7562
7511
|
const fileMeta = await this.fileCompiler.getFileMeta(absPath);
|
|
7563
7512
|
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
|
|
7564
|
-
const record = _optionalChain([cache, 'optionalAccess',
|
|
7513
|
+
const record = _optionalChain([cache, 'optionalAccess', _266 => _266.target, 'access', _267 => _267.find, 'call', _268 => _268((c) => c.file === absPath)]);
|
|
7565
7514
|
const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
|
|
7566
7515
|
fileMeta,
|
|
7567
7516
|
record,
|
|
@@ -7583,10 +7532,10 @@ var FileProcessor = (_class10 = class {
|
|
|
7583
7532
|
hash: hash || this.fileCompiler.genHash(source)
|
|
7584
7533
|
};
|
|
7585
7534
|
const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
|
|
7586
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7535
|
+
if (_optionalChain([processed, 'optionalAccess', _269 => _269.output])) {
|
|
7587
7536
|
await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
|
|
7588
7537
|
if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
|
|
7589
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7538
|
+
if (_optionalChain([processed, 'optionalAccess', _270 => _270.hasRoute])) {
|
|
7590
7539
|
await this.addRouterToPackageJson();
|
|
7591
7540
|
await this.updateEntryWithRouterProvider();
|
|
7592
7541
|
}
|
|
@@ -7600,13 +7549,13 @@ var FileProcessor = (_class10 = class {
|
|
|
7600
7549
|
*/
|
|
7601
7550
|
async addRouterToPackageJson() {
|
|
7602
7551
|
const { output } = this.fileCompiler.options;
|
|
7603
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7552
|
+
if (_optionalChain([output, 'optionalAccess', _271 => _271.bootstrapVite]) === false) {
|
|
7604
7553
|
return;
|
|
7605
7554
|
}
|
|
7606
7555
|
const { router } = RUNTIME_PACKAGES;
|
|
7607
7556
|
const filePath = this.fileCompiler.getOutputPkgPath();
|
|
7608
7557
|
const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
|
|
7609
|
-
if (_optionalChain([packageJson, 'optionalAccess',
|
|
7558
|
+
if (_optionalChain([packageJson, 'optionalAccess', _272 => _272.dependencies, 'optionalAccess', _273 => _273[router.name]])) {
|
|
7610
7559
|
return;
|
|
7611
7560
|
}
|
|
7612
7561
|
if (!packageJson.dependencies) {
|
|
@@ -7625,7 +7574,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7625
7574
|
const { exclude, output, router } = this.fileCompiler.options;
|
|
7626
7575
|
const inputPath = this.fileCompiler.getInputPath();
|
|
7627
7576
|
const outputPath = this.fileCompiler.getOuputPath(true);
|
|
7628
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7577
|
+
if (_optionalChain([output, 'optionalAccess', _274 => _274.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _275 => _275.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _276 => _276.configFile])) {
|
|
7629
7578
|
return;
|
|
7630
7579
|
}
|
|
7631
7580
|
const getMainFile = async (filename) => {
|
|
@@ -7646,7 +7595,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7646
7595
|
const prepareRouterEntry = () => {
|
|
7647
7596
|
const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
|
|
7648
7597
|
let content = fileData.content;
|
|
7649
|
-
if (_optionalChain([exclude, 'optionalAccess',
|
|
7598
|
+
if (_optionalChain([exclude, 'optionalAccess', _277 => _277.includes, 'call', _278 => _278(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _279 => _279.includes, 'call', _280 => _280(importPath)])) {
|
|
7650
7599
|
return content;
|
|
7651
7600
|
}
|
|
7652
7601
|
const routerModule = "RouterInstance";
|
|
@@ -7792,7 +7741,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7792
7741
|
const { output } = this.options;
|
|
7793
7742
|
const workspaceDir = this.fileCompiler.getWorkspaceDir();
|
|
7794
7743
|
await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
|
|
7795
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7744
|
+
if (_optionalChain([output, 'optionalAccess', _281 => _281.bootstrapVite]) === false) {
|
|
7796
7745
|
return false;
|
|
7797
7746
|
}
|
|
7798
7747
|
if (this.isSingleFile()) {
|
|
@@ -7842,7 +7791,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7842
7791
|
const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
|
|
7843
7792
|
newPkg.dependencies = newDeps;
|
|
7844
7793
|
newPkg.devDependencies = newDevDeps;
|
|
7845
|
-
newPkg = _optionalChain([output, 'optionalAccess',
|
|
7794
|
+
newPkg = _optionalChain([output, 'optionalAccess', _282 => _282.packageJson, 'optionalCall', _283 => _283(newPkg)]) || newPkg;
|
|
7846
7795
|
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
|
|
7847
7796
|
this.spinner.succeed("Standard Vite React environment initialized");
|
|
7848
7797
|
return true;
|
|
@@ -7853,12 +7802,12 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7853
7802
|
async resolveViteCreateApp() {
|
|
7854
7803
|
const { output } = this.options;
|
|
7855
7804
|
const { viteVersion, template: tmpl } = this.defaultConfig;
|
|
7856
|
-
const bootstrapVite = _optionalChain([output, 'optionalAccess',
|
|
7805
|
+
const bootstrapVite = _optionalChain([output, 'optionalAccess', _284 => _284.bootstrapVite]);
|
|
7857
7806
|
const outDirName = this.fileCompiler.getOutDirName();
|
|
7858
7807
|
const configObject = typeof bootstrapVite === "object" ? bootstrapVite : null;
|
|
7859
|
-
const viteVer = _optionalChain([configObject, 'optionalAccess',
|
|
7860
|
-
const reactVer = _optionalChain([configObject, 'optionalAccess',
|
|
7861
|
-
const template = _optionalChain([configObject, 'optionalAccess',
|
|
7808
|
+
const viteVer = _optionalChain([configObject, 'optionalAccess', _285 => _285.vite]) || viteVersion;
|
|
7809
|
+
const reactVer = _optionalChain([configObject, 'optionalAccess', _286 => _286.react]);
|
|
7810
|
+
const template = _optionalChain([configObject, 'optionalAccess', _287 => _287.template]) || tmpl;
|
|
7862
7811
|
const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
|
|
7863
7812
|
_child_process.execSync.call(void 0, cmd, {
|
|
7864
7813
|
cwd: this.fileCompiler.getWorkspaceDir(),
|
|
@@ -7962,7 +7911,7 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
|
7962
7911
|
const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
|
|
7963
7912
|
const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
|
|
7964
7913
|
const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
|
|
7965
|
-
await _optionalChain([this, 'access',
|
|
7914
|
+
await _optionalChain([this, 'access', _288 => _288.options, 'access', _289 => _289.onSuccess, 'optionalCall', _290 => _290()]);
|
|
7966
7915
|
const endTime = calcElapsedTime(startTime);
|
|
7967
7916
|
this.printCoreLogs();
|
|
7968
7917
|
this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
|