@vureact/compiler-core 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
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.1
|
|
3
3
|
* (c) 2025-present Ruihong Zhong (Ryan John)
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -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;
|
|
@@ -5656,8 +5589,8 @@ function createSimpleVueBind(name, value) {
|
|
|
5656
5589
|
function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
|
|
5657
5590
|
const arg = directive.arg;
|
|
5658
5591
|
const exp = directive.exp;
|
|
5659
|
-
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5660
|
-
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5592
|
+
const name = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _182 => _182.content]), () => ( ""));
|
|
5593
|
+
const content = _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _183 => _183.content]), () => ( "true"));
|
|
5661
5594
|
warnUnsupportedVueDollarVar(ctx, directive);
|
|
5662
5595
|
if (name === "is") {
|
|
5663
5596
|
resolveDynamicIsProp(directive, ir, ctx, nodeIR);
|
|
@@ -5672,7 +5605,7 @@ function resolveDynamicAttributeProp(directive, ir, ctx, vueNode, nodeIR) {
|
|
|
5672
5605
|
return;
|
|
5673
5606
|
}
|
|
5674
5607
|
const propIR = createPropsIR(directive.rawName, name, content);
|
|
5675
|
-
propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5608
|
+
propIR.isStatic = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _184 => _184.isStatic]), () => ( true));
|
|
5676
5609
|
checkPropIsDynamicKey(ctx, directive);
|
|
5677
5610
|
resolvePropertyIR(propIR, ir, ctx, nodeIR, true);
|
|
5678
5611
|
}
|
|
@@ -5686,12 +5619,12 @@ function resolvePropertyIR(propsIR, ir, ctx, nodeIR, isDynamic = false) {
|
|
|
5686
5619
|
content = propsIR.value.content = parseStyleString(content);
|
|
5687
5620
|
}
|
|
5688
5621
|
if (isDynamic) {
|
|
5689
|
-
const
|
|
5690
|
-
if (
|
|
5622
|
+
const isStringLiteral13 = strCodeTypes.isStringLiteral(content);
|
|
5623
|
+
if (isStringLiteral13) {
|
|
5691
5624
|
content = normalizeString(content);
|
|
5692
5625
|
propsIR.value.content = content;
|
|
5693
5626
|
}
|
|
5694
|
-
propsIR.value.isStringLiteral =
|
|
5627
|
+
propsIR.value.isStringLiteral = isStringLiteral13;
|
|
5695
5628
|
}
|
|
5696
5629
|
const existing = findSameProp(nodeIR.props, propsIR);
|
|
5697
5630
|
if (existing) {
|
|
@@ -5711,7 +5644,7 @@ function normalizeString(s) {
|
|
|
5711
5644
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-attribute-prop.ts
|
|
5712
5645
|
function resolveAttributeProp(attribute, ir, ctx, nodeIR) {
|
|
5713
5646
|
const name = attribute.name;
|
|
5714
|
-
const content = _nullishCoalesce(_optionalChain([attribute, 'access',
|
|
5647
|
+
const content = _nullishCoalesce(_optionalChain([attribute, 'access', _185 => _185.value, 'optionalAccess', _186 => _186.content]), () => ( "true"));
|
|
5715
5648
|
if (name === "is") {
|
|
5716
5649
|
resolveStaticIsProp(content, ir, ctx, nodeIR);
|
|
5717
5650
|
return;
|
|
@@ -5806,10 +5739,10 @@ function resolveRouterLinkVSlotProp(directive, nodeIR, ctx) {
|
|
|
5806
5739
|
type: 2 /* SLOT */,
|
|
5807
5740
|
name: "customRender",
|
|
5808
5741
|
rawName: _nullishCoalesce(directive.rawName, () => ( "v-slot")),
|
|
5809
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5742
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _187 => _187.isStatic]), () => ( true)),
|
|
5810
5743
|
isScoped: true,
|
|
5811
5744
|
callback: {
|
|
5812
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
5745
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _188 => _188.content, 'optionalAccess', _189 => _189.trim, 'call', _190 => _190()]), () => ( "")),
|
|
5813
5746
|
exp: []
|
|
5814
5747
|
}
|
|
5815
5748
|
};
|
|
@@ -5825,10 +5758,10 @@ function resolveVFor(directive, ir, ctx, nodeIR) {
|
|
|
5825
5758
|
};
|
|
5826
5759
|
}
|
|
5827
5760
|
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',
|
|
5761
|
+
const source = _optionalChain([forParseResult, 'access', _191 => _191.source, 'optionalAccess', _192 => _192.content]);
|
|
5762
|
+
const value = _optionalChain([forParseResult, 'access', _193 => _193.value, 'optionalAccess', _194 => _194.content]);
|
|
5763
|
+
const index = _optionalChain([forParseResult, 'access', _195 => _195.index, 'optionalAccess', _196 => _196.content]);
|
|
5764
|
+
const key = _optionalChain([forParseResult, 'access', _197 => _197.key, 'optionalAccess', _198 => _198.content]);
|
|
5832
5765
|
return {
|
|
5833
5766
|
source,
|
|
5834
5767
|
value,
|
|
@@ -5848,7 +5781,7 @@ function resolveVHtml(directive, ir, ctx, nodeIR) {
|
|
|
5848
5781
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-if.ts
|
|
5849
5782
|
function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
|
|
5850
5783
|
const name = directive.name === "else-if" ? "elseIf" : directive.name;
|
|
5851
|
-
const value = _nullishCoalesce(_optionalChain([directive, 'access',
|
|
5784
|
+
const value = _nullishCoalesce(_optionalChain([directive, 'access', _199 => _199.exp, 'optionalAccess', _200 => _200.content]), () => ( "true"));
|
|
5852
5785
|
const prevNode = siblingNodesIR[siblingNodesIR.length - 1];
|
|
5853
5786
|
const isElseBranch = name === "else" || name === "elseIf";
|
|
5854
5787
|
let hasError = false;
|
|
@@ -5887,7 +5820,7 @@ function resolveVIf(directive, ir, ctx, nodeIR, siblingNodesIR) {
|
|
|
5887
5820
|
// src/core/transform/sfc/template/syntax-processor/process/props/resolve-v-memo.ts
|
|
5888
5821
|
function resolveVMemo(directive, _ir, ctx, nodeIR) {
|
|
5889
5822
|
const exp = directive.exp;
|
|
5890
|
-
let value = _optionalChain([exp, 'optionalAccess',
|
|
5823
|
+
let value = _optionalChain([exp, 'optionalAccess', _201 => _201.content]);
|
|
5891
5824
|
if (value !== void 0) {
|
|
5892
5825
|
if (!value.trim() || !value.startsWith("[") && !value.endsWith("]")) {
|
|
5893
5826
|
const { source, filename } = ctx;
|
|
@@ -5927,14 +5860,14 @@ function resolveVModel(directive, ir, ctx, vueNode, nodeIR) {
|
|
|
5927
5860
|
const getterName = exp.content;
|
|
5928
5861
|
const isComponent = vueNode.tagType === _compilercore.ElementTypes.COMPONENT;
|
|
5929
5862
|
const inputType = resolveHtmlInput(vueNode, isComponent);
|
|
5930
|
-
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
5863
|
+
const propName = _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _202 => _202.content]), () => ( resolveModelPropName(inputType, isComponent)));
|
|
5931
5864
|
let valuePropIR;
|
|
5932
5865
|
let eventPropIR;
|
|
5933
5866
|
if (isComponent) {
|
|
5934
5867
|
valuePropIR = createPropsIR("v-model", propName, getterName);
|
|
5935
5868
|
const eventReactName = `onUpdate${capitalize(camelCase(propName))}`;
|
|
5936
5869
|
const eventVueName = `update:${propName}`;
|
|
5937
|
-
const isTS = _optionalChain([ctx, 'access',
|
|
5870
|
+
const isTS = _optionalChain([ctx, 'access', _203 => _203.scriptData, 'optionalAccess', _204 => _204.lang, 'optionalAccess', _205 => _205.startsWith, 'call', _206 => _206("ts")]);
|
|
5938
5871
|
const valueArg = isTS ? "value: any" : "value";
|
|
5939
5872
|
const processedValue = applyValueModifiers("value", modifiers);
|
|
5940
5873
|
const handlerBody = `(${valueArg}) => { ${getterName} = ${processedValue} }`;
|
|
@@ -5972,7 +5905,7 @@ function getRadioValue(vueNode) {
|
|
|
5972
5905
|
const valueAttr = vueNode.props.find(
|
|
5973
5906
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "value"
|
|
5974
5907
|
);
|
|
5975
|
-
if (!_optionalChain([valueAttr, 'optionalAccess',
|
|
5908
|
+
if (!_optionalChain([valueAttr, 'optionalAccess', _207 => _207.value, 'optionalAccess', _208 => _208.content])) return '""';
|
|
5976
5909
|
const content = valueAttr.value.content;
|
|
5977
5910
|
return /^['"]/.test(content) ? content : `"${content}"`;
|
|
5978
5911
|
}
|
|
@@ -5982,7 +5915,7 @@ function resolveHtmlInput(node, isComponent) {
|
|
|
5982
5915
|
const typeProp = node.props.find(
|
|
5983
5916
|
(prop) => prop.type === _compilercore.NodeTypes.ATTRIBUTE && prop.name === "type"
|
|
5984
5917
|
);
|
|
5985
|
-
return _optionalChain([typeProp, 'optionalAccess',
|
|
5918
|
+
return _optionalChain([typeProp, 'optionalAccess', _209 => _209.value, 'optionalAccess', _210 => _210.content, 'optionalAccess', _211 => _211.toLowerCase, 'call', _212 => _212()]);
|
|
5986
5919
|
}
|
|
5987
5920
|
function applyValueModifiers(valueExp, modifiers) {
|
|
5988
5921
|
let result = valueExp;
|
|
@@ -6067,7 +6000,7 @@ function resolveVSlotProp(directive, ir, ctx) {
|
|
|
6067
6000
|
const name = !arg || arg.content === "default" ? "children" : arg.content;
|
|
6068
6001
|
const content = !isScoped ? [] : void 0;
|
|
6069
6002
|
const callback = isScoped ? {
|
|
6070
|
-
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess',
|
|
6003
|
+
arg: _nullishCoalesce(_optionalChain([exp, 'optionalAccess', _213 => _213.content, 'optionalAccess', _214 => _214.trim, 'call', _215 => _215()]), () => ( "")),
|
|
6071
6004
|
exp: []
|
|
6072
6005
|
} : void 0;
|
|
6073
6006
|
checkPropIsDynamicKey(ctx, directive);
|
|
@@ -6075,7 +6008,7 @@ function resolveVSlotProp(directive, ir, ctx) {
|
|
|
6075
6008
|
type: 2 /* SLOT */,
|
|
6076
6009
|
name,
|
|
6077
6010
|
rawName: _nullishCoalesce(directive.rawName, () => ( "default")),
|
|
6078
|
-
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess',
|
|
6011
|
+
isStatic: _nullishCoalesce(_optionalChain([arg, 'optionalAccess', _216 => _216.isStatic]), () => ( true)),
|
|
6079
6012
|
isScoped,
|
|
6080
6013
|
content,
|
|
6081
6014
|
callback
|
|
@@ -6138,7 +6071,7 @@ function resolveElementNode(node, ir, ctx, siblingNodesIR) {
|
|
|
6138
6071
|
if (routerAdapter) {
|
|
6139
6072
|
if (!ctx.route) ctx.route = true;
|
|
6140
6073
|
nodeIR.isRoute = true;
|
|
6141
|
-
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess',
|
|
6074
|
+
recordImport(ctx, _optionalChain([routerAdapter, 'optionalAccess', _217 => _217.package]), routerAdapter.target);
|
|
6142
6075
|
}
|
|
6143
6076
|
resolveProps(node, ir, ctx, nodeIR, siblingNodesIR);
|
|
6144
6077
|
return nodeIR;
|
|
@@ -6285,7 +6218,7 @@ function resolveSlotProps(node, ctx) {
|
|
|
6285
6218
|
for (const prop of node.props) {
|
|
6286
6219
|
if (prop.type === _compilercore.NodeTypes.ATTRIBUTE) {
|
|
6287
6220
|
const attr = prop.name;
|
|
6288
|
-
const value = _optionalChain([prop, 'access',
|
|
6221
|
+
const value = _optionalChain([prop, 'access', _218 => _218.value, 'optionalAccess', _219 => _219.content, 'access', _220 => _220.trim, 'call', _221 => _221()]);
|
|
6289
6222
|
if (attr === "name" && value) {
|
|
6290
6223
|
result.name = camelCase(value);
|
|
6291
6224
|
} else {
|
|
@@ -6375,19 +6308,19 @@ function resolveTemplate2(root, ctx) {
|
|
|
6375
6308
|
// src/core/transform/sfc/index.ts
|
|
6376
6309
|
function transform(ast, ctx, options) {
|
|
6377
6310
|
const { template, script, style } = ast;
|
|
6378
|
-
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess',
|
|
6379
|
-
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess',
|
|
6311
|
+
const templateIR = resolveTemplate2(_optionalChain([template, 'optionalAccess', _222 => _222.ast]), ctx);
|
|
6312
|
+
const scriptIR = resolveScript2(_optionalChain([script, 'optionalAccess', _223 => _223.ast]), ctx);
|
|
6380
6313
|
const result = {
|
|
6381
6314
|
template: templateIR,
|
|
6382
6315
|
script: scriptIR,
|
|
6383
|
-
style: _optionalChain([style, 'optionalAccess',
|
|
6316
|
+
style: _optionalChain([style, 'optionalAccess', _224 => _224.source, 'optionalAccess', _225 => _225.content])
|
|
6384
6317
|
};
|
|
6385
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6318
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _226 => _226.plugins]), result, ctx);
|
|
6386
6319
|
return result;
|
|
6387
6320
|
}
|
|
6388
6321
|
|
|
6389
6322
|
// package.json
|
|
6390
|
-
var version = "1.6.
|
|
6323
|
+
var version = "1.6.1";
|
|
6391
6324
|
var bin = {
|
|
6392
6325
|
vureact: "./bin/vureact.js"
|
|
6393
6326
|
};
|
|
@@ -6581,7 +6514,7 @@ var Helper = (_class5 = class {
|
|
|
6581
6514
|
__init8() {this.outDir = "react-app"}
|
|
6582
6515
|
constructor(opts) {;_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);
|
|
6583
6516
|
this.compilerOpts = opts;
|
|
6584
|
-
if (_optionalChain([opts, 'access',
|
|
6517
|
+
if (_optionalChain([opts, 'access', _227 => _227.output, 'optionalAccess', _228 => _228.workspace])) {
|
|
6585
6518
|
this.workspaceDir = opts.output.workspace;
|
|
6586
6519
|
}
|
|
6587
6520
|
const excludePatterns = PathFilter.withDefaults(opts.exclude || []);
|
|
@@ -6618,7 +6551,7 @@ var Helper = (_class5 = class {
|
|
|
6618
6551
|
}
|
|
6619
6552
|
getOutDirName() {
|
|
6620
6553
|
const { output } = this.compilerOpts;
|
|
6621
|
-
return _optionalChain([output, 'optionalAccess',
|
|
6554
|
+
return _optionalChain([output, 'optionalAccess', _229 => _229.outDir]) || this.outDir;
|
|
6622
6555
|
}
|
|
6623
6556
|
getWorkspaceDir() {
|
|
6624
6557
|
return _path2.default.resolve(this.getProjectRoot(), this.workspaceDir);
|
|
@@ -6632,7 +6565,7 @@ var Helper = (_class5 = class {
|
|
|
6632
6565
|
}
|
|
6633
6566
|
getIgnoreAssets() {
|
|
6634
6567
|
const { output } = this.compilerOpts;
|
|
6635
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
6568
|
+
if (_optionalChain([output, 'optionalAccess', _230 => _230.ignoreAssets])) {
|
|
6636
6569
|
return new Set(output.ignoreAssets.map(normalizePath));
|
|
6637
6570
|
}
|
|
6638
6571
|
return /* @__PURE__ */ new Set([
|
|
@@ -6715,12 +6648,12 @@ var Helper = (_class5 = class {
|
|
|
6715
6648
|
*/
|
|
6716
6649
|
async formatCode({ code, fileInfo }) {
|
|
6717
6650
|
const { format } = this.compilerOpts;
|
|
6718
|
-
if (!_optionalChain([format, 'optionalAccess',
|
|
6719
|
-
if (_optionalChain([format, 'optionalAccess',
|
|
6651
|
+
if (!_optionalChain([format, 'optionalAccess', _231 => _231.enabled])) return code;
|
|
6652
|
+
if (_optionalChain([format, 'optionalAccess', _232 => _232.formatter]) === "builtin") {
|
|
6720
6653
|
return simpleFormat(code);
|
|
6721
6654
|
}
|
|
6722
|
-
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess',
|
|
6723
|
-
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess',
|
|
6655
|
+
const { lang } = _nullishCoalesce(_optionalChain([fileInfo, 'optionalAccess', _233 => _233.jsx]), () => ( _optionalChain([fileInfo, 'optionalAccess', _234 => _234.script])));
|
|
6656
|
+
return await formatWithPrettier(code, lang, _optionalChain([format, 'optionalAccess', _235 => _235.prettierOptions]));
|
|
6724
6657
|
}
|
|
6725
6658
|
/**
|
|
6726
6659
|
* 通用的缓存校验工具函数
|
|
@@ -6754,7 +6687,7 @@ var Helper = (_class5 = class {
|
|
|
6754
6687
|
* @param options.lock - 是否启用文件锁(默认false)
|
|
6755
6688
|
*/
|
|
6756
6689
|
async writeFileWithDir(filePath, content, options) {
|
|
6757
|
-
if (_optionalChain([options, 'optionalAccess',
|
|
6690
|
+
if (_optionalChain([options, 'optionalAccess', _236 => _236.lock])) {
|
|
6758
6691
|
await fileLock.updateFile(filePath, async () => content, options);
|
|
6759
6692
|
} else {
|
|
6760
6693
|
await _fs2.default.promises.mkdir(_path2.default.dirname(filePath), { recursive: true });
|
|
@@ -6879,7 +6812,7 @@ var Helper = (_class5 = class {
|
|
|
6879
6812
|
* 获取需要排除编译的文件
|
|
6880
6813
|
*/
|
|
6881
6814
|
getExcludes() {
|
|
6882
|
-
if (!_optionalChain([this, 'access',
|
|
6815
|
+
if (!_optionalChain([this, 'access', _237 => _237.compilerOpts, 'access', _238 => _238.exclude, 'optionalAccess', _239 => _239.length])) {
|
|
6883
6816
|
return PathFilter.withDefaults();
|
|
6884
6817
|
}
|
|
6885
6818
|
return this.compilerOpts.exclude;
|
|
@@ -6977,7 +6910,7 @@ function parseOnlyStyle(source, ctx, options) {
|
|
|
6977
6910
|
ast: void 0
|
|
6978
6911
|
}
|
|
6979
6912
|
};
|
|
6980
|
-
executePlugins(_optionalChain([options, 'optionalAccess',
|
|
6913
|
+
executePlugins(_optionalChain([options, 'optionalAccess', _240 => _240.plugins]), result, ctx);
|
|
6981
6914
|
return result;
|
|
6982
6915
|
}
|
|
6983
6916
|
|
|
@@ -7111,16 +7044,16 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7111
7044
|
});
|
|
7112
7045
|
const genOptions = this.prepareGenerateOptions(filename);
|
|
7113
7046
|
const resolveSFCAndScriptFile = () => {
|
|
7114
|
-
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7115
|
-
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7047
|
+
const ast = parse(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _241 => _241.parser]) });
|
|
7048
|
+
const ir = transform(ast, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _242 => _242.transformer]) });
|
|
7116
7049
|
const gen = generate(ir, ctx.data, {
|
|
7117
7050
|
...genOptions,
|
|
7118
|
-
plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7051
|
+
plugins: _optionalChain([plugins, 'optionalAccess', _243 => _243.codegen])
|
|
7119
7052
|
});
|
|
7120
7053
|
return this.resolveMainResult(ir, gen, ctx.data);
|
|
7121
7054
|
};
|
|
7122
7055
|
const resolveStyleFile = () => {
|
|
7123
|
-
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess',
|
|
7056
|
+
const result = parseOnlyStyle(source, ctx.data, { plugins: _optionalChain([plugins, 'optionalAccess', _244 => _244.parser]) });
|
|
7124
7057
|
return this.resolveStyleResult(result, ctx.data);
|
|
7125
7058
|
};
|
|
7126
7059
|
try {
|
|
@@ -7159,9 +7092,9 @@ var BaseCompiler = (_class7 = class extends Helper {
|
|
|
7159
7092
|
lang
|
|
7160
7093
|
},
|
|
7161
7094
|
css: {
|
|
7162
|
-
file: _optionalChain([styleData, 'optionalAccess',
|
|
7163
|
-
hash: _optionalChain([styleData, 'optionalAccess',
|
|
7164
|
-
code: _optionalChain([ir, 'optionalAccess',
|
|
7095
|
+
file: _optionalChain([styleData, 'optionalAccess', _245 => _245.filePath]),
|
|
7096
|
+
hash: _optionalChain([styleData, 'optionalAccess', _246 => _246.scopeId]),
|
|
7097
|
+
code: _optionalChain([ir, 'optionalAccess', _247 => _247.style])
|
|
7165
7098
|
}
|
|
7166
7099
|
},
|
|
7167
7100
|
...base
|
|
@@ -7231,7 +7164,7 @@ var AssetManager = (_class8 = class {
|
|
|
7231
7164
|
const relativeToRoot = normalizePath(this.fileCompiler.relativePath(p));
|
|
7232
7165
|
const filename = _path2.default.basename(p).toLowerCase();
|
|
7233
7166
|
const ext = _path2.default.extname(p).toLowerCase();
|
|
7234
|
-
if (!_optionalChain([options, 'access',
|
|
7167
|
+
if (!_optionalChain([options, 'access', _248 => _248.output, 'optionalAccess', _249 => _249.ignoreAssets])) {
|
|
7235
7168
|
const shouldExclude = Array.from(exclusions).some((pattern) => {
|
|
7236
7169
|
if (pattern.endsWith(".")) {
|
|
7237
7170
|
return filename.startsWith(pattern);
|
|
@@ -7328,12 +7261,12 @@ var CacheManager = (_class9 = class {
|
|
|
7328
7261
|
const meta = { ...unit };
|
|
7329
7262
|
delete meta.source;
|
|
7330
7263
|
if (key === "sfc" /* SFC */) {
|
|
7331
|
-
_optionalChainDelete([meta, 'access',
|
|
7332
|
-
_optionalChainDelete([meta, 'access',
|
|
7264
|
+
_optionalChainDelete([meta, 'access', _250 => _250.output, 'optionalAccess', _251 => _251.jsx, 'access', _252 => delete _252.code]);
|
|
7265
|
+
_optionalChainDelete([meta, 'access', _253 => _253.output, 'optionalAccess', _254 => _254.css, 'access', _255 => delete _255.code]);
|
|
7333
7266
|
} else if (key === "script" /* SCRIPT */) {
|
|
7334
|
-
_optionalChainDelete([meta, 'access',
|
|
7267
|
+
_optionalChainDelete([meta, 'access', _256 => _256.output, 'optionalAccess', _257 => _257.script, 'access', _258 => delete _258.code]);
|
|
7335
7268
|
} else if (key === "style" /* STYLE */) {
|
|
7336
|
-
_optionalChainDelete([meta, 'access',
|
|
7269
|
+
_optionalChainDelete([meta, 'access', _259 => _259.output, 'optionalAccess', _260 => _260.style, 'access', _261 => delete _261.code]);
|
|
7337
7270
|
}
|
|
7338
7271
|
if (!this.pendingUpdates.has(key)) {
|
|
7339
7272
|
this.pendingUpdates.set(key, []);
|
|
@@ -7403,7 +7336,7 @@ var CleanupManager = class {
|
|
|
7403
7336
|
meta = m;
|
|
7404
7337
|
const { jsx, css } = meta.output;
|
|
7405
7338
|
await this.fileCompiler.removeOutputFile(jsx.file);
|
|
7406
|
-
if (_optionalChain([css, 'optionalAccess',
|
|
7339
|
+
if (_optionalChain([css, 'optionalAccess', _262 => _262.file])) {
|
|
7407
7340
|
await this.fileCompiler.removeOutputFile(css.file);
|
|
7408
7341
|
}
|
|
7409
7342
|
break;
|
|
@@ -7464,7 +7397,7 @@ var CompilationUnitProcessor = class {
|
|
|
7464
7397
|
const isScriptFile = key === "script" /* SCRIPT */;
|
|
7465
7398
|
const isStyleFile = key === "style" /* STYLE */;
|
|
7466
7399
|
if (isSFC || isScriptFile) {
|
|
7467
|
-
unit.hasRoute = _optionalChain([result, 'optionalAccess',
|
|
7400
|
+
unit.hasRoute = _optionalChain([result, 'optionalAccess', _263 => _263.hasRoute]);
|
|
7468
7401
|
}
|
|
7469
7402
|
const resolveFileInfo = () => {
|
|
7470
7403
|
if (isSFC) {
|
|
@@ -7484,7 +7417,7 @@ var CompilationUnitProcessor = class {
|
|
|
7484
7417
|
const { script } = result.fileInfo;
|
|
7485
7418
|
unit.output = {
|
|
7486
7419
|
script: {
|
|
7487
|
-
file: _optionalChain([script, 'optionalAccess',
|
|
7420
|
+
file: _optionalChain([script, 'optionalAccess', _264 => _264.file]),
|
|
7488
7421
|
code
|
|
7489
7422
|
}
|
|
7490
7423
|
};
|
|
@@ -7561,7 +7494,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7561
7494
|
const absPath = this.fileCompiler.getAbsPath(filePath);
|
|
7562
7495
|
const fileMeta = await this.fileCompiler.getFileMeta(absPath);
|
|
7563
7496
|
const cache = (this.fileCompiler.getIsCache() ? existingCache : void 0) || await this.fileCompiler.loadCache(key);
|
|
7564
|
-
const record = _optionalChain([cache, 'optionalAccess',
|
|
7497
|
+
const record = _optionalChain([cache, 'optionalAccess', _265 => _265.target, 'access', _266 => _266.find, 'call', _267 => _267((c) => c.file === absPath)]);
|
|
7565
7498
|
const { shouldCompile, hash } = await this.fileCompiler.checkCacheStatus(
|
|
7566
7499
|
fileMeta,
|
|
7567
7500
|
record,
|
|
@@ -7583,10 +7516,10 @@ var FileProcessor = (_class10 = class {
|
|
|
7583
7516
|
hash: hash || this.fileCompiler.genHash(source)
|
|
7584
7517
|
};
|
|
7585
7518
|
const processed = await this.compilationUnitProcessor.resolve(initUnit, key);
|
|
7586
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7519
|
+
if (_optionalChain([processed, 'optionalAccess', _268 => _268.output])) {
|
|
7587
7520
|
await this.compilationUnitProcessor.saveCompiledFiles(processed, key);
|
|
7588
7521
|
if (key === "sfc" /* SFC */ || key === "script" /* SCRIPT */) {
|
|
7589
|
-
if (_optionalChain([processed, 'optionalAccess',
|
|
7522
|
+
if (_optionalChain([processed, 'optionalAccess', _269 => _269.hasRoute])) {
|
|
7590
7523
|
await this.addRouterToPackageJson();
|
|
7591
7524
|
await this.updateEntryWithRouterProvider();
|
|
7592
7525
|
}
|
|
@@ -7600,13 +7533,13 @@ var FileProcessor = (_class10 = class {
|
|
|
7600
7533
|
*/
|
|
7601
7534
|
async addRouterToPackageJson() {
|
|
7602
7535
|
const { output } = this.fileCompiler.options;
|
|
7603
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7536
|
+
if (_optionalChain([output, 'optionalAccess', _270 => _270.bootstrapVite]) === false) {
|
|
7604
7537
|
return;
|
|
7605
7538
|
}
|
|
7606
7539
|
const { router } = RUNTIME_PACKAGES;
|
|
7607
7540
|
const filePath = this.fileCompiler.getOutputPkgPath();
|
|
7608
7541
|
const packageJson = await this.fileCompiler.resolvePackageFile(filePath);
|
|
7609
|
-
if (_optionalChain([packageJson, 'optionalAccess',
|
|
7542
|
+
if (_optionalChain([packageJson, 'optionalAccess', _271 => _271.dependencies, 'optionalAccess', _272 => _272[router.name]])) {
|
|
7610
7543
|
return;
|
|
7611
7544
|
}
|
|
7612
7545
|
if (!packageJson.dependencies) {
|
|
@@ -7625,7 +7558,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7625
7558
|
const { exclude, output, router } = this.fileCompiler.options;
|
|
7626
7559
|
const inputPath = this.fileCompiler.getInputPath();
|
|
7627
7560
|
const outputPath = this.fileCompiler.getOuputPath(true);
|
|
7628
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7561
|
+
if (_optionalChain([output, 'optionalAccess', _273 => _273.bootstrapVite]) === false || _optionalChain([router, 'optionalAccess', _274 => _274.autoUpdateEntry]) === false || !_optionalChain([router, 'optionalAccess', _275 => _275.configFile])) {
|
|
7629
7562
|
return;
|
|
7630
7563
|
}
|
|
7631
7564
|
const getMainFile = async (filename) => {
|
|
@@ -7646,7 +7579,7 @@ var FileProcessor = (_class10 = class {
|
|
|
7646
7579
|
const prepareRouterEntry = () => {
|
|
7647
7580
|
const importPath = this.fileCompiler.resolveRelativePath(inputPath, router.configFile);
|
|
7648
7581
|
let content = fileData.content;
|
|
7649
|
-
if (_optionalChain([exclude, 'optionalAccess',
|
|
7582
|
+
if (_optionalChain([exclude, 'optionalAccess', _276 => _276.includes, 'call', _277 => _277(router.configFile)]) || _optionalChain([exclude, 'optionalAccess', _278 => _278.includes, 'call', _279 => _279(importPath)])) {
|
|
7650
7583
|
return content;
|
|
7651
7584
|
}
|
|
7652
7585
|
const routerModule = "RouterInstance";
|
|
@@ -7792,7 +7725,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7792
7725
|
const { output } = this.options;
|
|
7793
7726
|
const workspaceDir = this.fileCompiler.getWorkspaceDir();
|
|
7794
7727
|
await _fs2.default.promises.mkdir(workspaceDir, { recursive: true });
|
|
7795
|
-
if (_optionalChain([output, 'optionalAccess',
|
|
7728
|
+
if (_optionalChain([output, 'optionalAccess', _280 => _280.bootstrapVite]) === false) {
|
|
7796
7729
|
return false;
|
|
7797
7730
|
}
|
|
7798
7731
|
if (this.isSingleFile()) {
|
|
@@ -7842,7 +7775,7 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7842
7775
|
const newDevDeps = resolveDeps(sourcePkg.devDependencies, newPkg.devDependencies, true);
|
|
7843
7776
|
newPkg.dependencies = newDeps;
|
|
7844
7777
|
newPkg.devDependencies = newDevDeps;
|
|
7845
|
-
newPkg = _optionalChain([output, 'optionalAccess',
|
|
7778
|
+
newPkg = _optionalChain([output, 'optionalAccess', _281 => _281.packageJson, 'optionalCall', _282 => _282(newPkg)]) || newPkg;
|
|
7846
7779
|
await this.fileCompiler.writeFileWithDir(outputPkgPath, JSON.stringify(newPkg, null, 2));
|
|
7847
7780
|
this.spinner.succeed("Standard Vite React environment initialized");
|
|
7848
7781
|
return true;
|
|
@@ -7853,12 +7786,12 @@ var ViteBootstrapper = (_class12 = class {
|
|
|
7853
7786
|
async resolveViteCreateApp() {
|
|
7854
7787
|
const { output } = this.options;
|
|
7855
7788
|
const { viteVersion, template: tmpl } = this.defaultConfig;
|
|
7856
|
-
const bootstrapVite = _optionalChain([output, 'optionalAccess',
|
|
7789
|
+
const bootstrapVite = _optionalChain([output, 'optionalAccess', _283 => _283.bootstrapVite]);
|
|
7857
7790
|
const outDirName = this.fileCompiler.getOutDirName();
|
|
7858
7791
|
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',
|
|
7792
|
+
const viteVer = _optionalChain([configObject, 'optionalAccess', _284 => _284.vite]) || viteVersion;
|
|
7793
|
+
const reactVer = _optionalChain([configObject, 'optionalAccess', _285 => _285.react]);
|
|
7794
|
+
const template = _optionalChain([configObject, 'optionalAccess', _286 => _286.template]) || tmpl;
|
|
7862
7795
|
const cmd = `npm create vite${viteVer} ${outDirName} -- --template ${template}`;
|
|
7863
7796
|
_child_process.execSync.call(void 0, cmd, {
|
|
7864
7797
|
cwd: this.fileCompiler.getWorkspaceDir(),
|
|
@@ -7962,7 +7895,7 @@ var FileCompiler = (_class13 = class extends BaseCompiler {
|
|
|
7962
7895
|
const scriptCount = await this.runPipelineWithSpinner("script" /* SCRIPT */);
|
|
7963
7896
|
const styleCount = await this.runPipelineWithSpinner("style" /* STYLE */);
|
|
7964
7897
|
const assetCount = await this.runPipelineWithSpinner("copied" /* ASSET */);
|
|
7965
|
-
await _optionalChain([this, 'access',
|
|
7898
|
+
await _optionalChain([this, 'access', _287 => _287.options, 'access', _288 => _288.onSuccess, 'optionalCall', _289 => _289()]);
|
|
7966
7899
|
const endTime = calcElapsedTime(startTime);
|
|
7967
7900
|
this.printCoreLogs();
|
|
7968
7901
|
this.showCompileStats(endTime, sfcCount, scriptCount, styleCount, assetCount);
|