@vue/compiler-core 3.5.17 → 3.6.0-alpha.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.
- package/dist/compiler-core.cjs.js +107 -33
- package/dist/compiler-core.cjs.prod.js +107 -33
- package/dist/compiler-core.d.ts +38 -15
- package/dist/compiler-core.esm-bundler.js +93 -25
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.
|
|
2
|
+
* @vue/compiler-core v3.6.0-alpha.2
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1735,7 +1735,7 @@ function markScopeIdentifier(node, child, knownIds) {
|
|
|
1735
1735
|
const isFunctionType = (node) => {
|
|
1736
1736
|
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
1737
1737
|
};
|
|
1738
|
-
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1738
|
+
const isStaticProperty = (node) => !!node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1739
1739
|
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
1740
1740
|
function isReferenced(node, parent, grandparent) {
|
|
1741
1741
|
switch (parent.type) {
|
|
@@ -1894,6 +1894,59 @@ function unwrapTSNode(node) {
|
|
|
1894
1894
|
return node;
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
|
+
function isStaticNode(node) {
|
|
1898
|
+
node = unwrapTSNode(node);
|
|
1899
|
+
switch (node.type) {
|
|
1900
|
+
case "UnaryExpression":
|
|
1901
|
+
return isStaticNode(node.argument);
|
|
1902
|
+
case "LogicalExpression":
|
|
1903
|
+
// 1 > 2
|
|
1904
|
+
case "BinaryExpression":
|
|
1905
|
+
return isStaticNode(node.left) && isStaticNode(node.right);
|
|
1906
|
+
case "ConditionalExpression": {
|
|
1907
|
+
return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
|
|
1908
|
+
}
|
|
1909
|
+
case "SequenceExpression":
|
|
1910
|
+
// (1, 2)
|
|
1911
|
+
case "TemplateLiteral":
|
|
1912
|
+
return node.expressions.every((expr) => isStaticNode(expr));
|
|
1913
|
+
case "ParenthesizedExpression":
|
|
1914
|
+
return isStaticNode(node.expression);
|
|
1915
|
+
case "StringLiteral":
|
|
1916
|
+
case "NumericLiteral":
|
|
1917
|
+
case "BooleanLiteral":
|
|
1918
|
+
case "NullLiteral":
|
|
1919
|
+
case "BigIntLiteral":
|
|
1920
|
+
return true;
|
|
1921
|
+
}
|
|
1922
|
+
return false;
|
|
1923
|
+
}
|
|
1924
|
+
function isConstantNode(node, bindings) {
|
|
1925
|
+
if (isStaticNode(node)) return true;
|
|
1926
|
+
node = unwrapTSNode(node);
|
|
1927
|
+
switch (node.type) {
|
|
1928
|
+
case "Identifier":
|
|
1929
|
+
const type = bindings[node.name];
|
|
1930
|
+
return type === "literal-const";
|
|
1931
|
+
case "RegExpLiteral":
|
|
1932
|
+
return true;
|
|
1933
|
+
case "ObjectExpression":
|
|
1934
|
+
return node.properties.every((prop) => {
|
|
1935
|
+
if (prop.type === "ObjectMethod") return false;
|
|
1936
|
+
if (prop.type === "SpreadElement")
|
|
1937
|
+
return isConstantNode(prop.argument, bindings);
|
|
1938
|
+
return (!prop.computed || isConstantNode(prop.key, bindings)) && isConstantNode(prop.value, bindings);
|
|
1939
|
+
});
|
|
1940
|
+
case "ArrayExpression":
|
|
1941
|
+
return node.elements.every((element) => {
|
|
1942
|
+
if (element === null) return true;
|
|
1943
|
+
if (element.type === "SpreadElement")
|
|
1944
|
+
return isConstantNode(element.argument, bindings);
|
|
1945
|
+
return isConstantNode(element, bindings);
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
return false;
|
|
1949
|
+
}
|
|
1897
1950
|
|
|
1898
1951
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
1899
1952
|
function isCoreComponent(tag) {
|
|
@@ -3289,6 +3342,10 @@ function getNodeProps(node) {
|
|
|
3289
3342
|
}
|
|
3290
3343
|
}
|
|
3291
3344
|
|
|
3345
|
+
function getSelfName(filename) {
|
|
3346
|
+
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
3347
|
+
return nameMatch ? shared.capitalize(shared.camelize(nameMatch[1])) : null;
|
|
3348
|
+
}
|
|
3292
3349
|
function createTransformContext(root, {
|
|
3293
3350
|
filename = "",
|
|
3294
3351
|
prefixIdentifiers = false,
|
|
@@ -3313,11 +3370,10 @@ function createTransformContext(root, {
|
|
|
3313
3370
|
onWarn = defaultOnWarn,
|
|
3314
3371
|
compatConfig
|
|
3315
3372
|
}) {
|
|
3316
|
-
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
3317
3373
|
const context = {
|
|
3318
3374
|
// options
|
|
3319
3375
|
filename,
|
|
3320
|
-
selfName:
|
|
3376
|
+
selfName: getSelfName(filename),
|
|
3321
3377
|
prefixIdentifiers,
|
|
3322
3378
|
hoistStatic,
|
|
3323
3379
|
hmr,
|
|
@@ -3616,6 +3672,16 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
3616
3672
|
|
|
3617
3673
|
const PURE_ANNOTATION = `/*@__PURE__*/`;
|
|
3618
3674
|
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
3675
|
+
const NewlineType = {
|
|
3676
|
+
"Start": 0,
|
|
3677
|
+
"0": "Start",
|
|
3678
|
+
"End": -1,
|
|
3679
|
+
"-1": "End",
|
|
3680
|
+
"None": -2,
|
|
3681
|
+
"-2": "None",
|
|
3682
|
+
"Unknown": -3,
|
|
3683
|
+
"-3": "Unknown"
|
|
3684
|
+
};
|
|
3619
3685
|
function createCodegenContext(ast, {
|
|
3620
3686
|
mode = "function",
|
|
3621
3687
|
prefixIdentifiers = mode === "module",
|
|
@@ -3654,7 +3720,7 @@ function createCodegenContext(ast, {
|
|
|
3654
3720
|
helper(key) {
|
|
3655
3721
|
return `_${helperNameMap[key]}`;
|
|
3656
3722
|
},
|
|
3657
|
-
push(code, newlineIndex = -2
|
|
3723
|
+
push(code, newlineIndex = -2, node) {
|
|
3658
3724
|
context.code += code;
|
|
3659
3725
|
if (context.map) {
|
|
3660
3726
|
if (node) {
|
|
@@ -3669,14 +3735,14 @@ function createCodegenContext(ast, {
|
|
|
3669
3735
|
addMapping(node.loc.start, name);
|
|
3670
3736
|
}
|
|
3671
3737
|
}
|
|
3672
|
-
if (newlineIndex === -3
|
|
3738
|
+
if (newlineIndex === -3) {
|
|
3673
3739
|
advancePositionWithMutation(context, code);
|
|
3674
3740
|
} else {
|
|
3675
3741
|
context.offset += code.length;
|
|
3676
|
-
if (newlineIndex === -2
|
|
3742
|
+
if (newlineIndex === -2) {
|
|
3677
3743
|
context.column += code.length;
|
|
3678
3744
|
} else {
|
|
3679
|
-
if (newlineIndex === -1
|
|
3745
|
+
if (newlineIndex === -1) {
|
|
3680
3746
|
newlineIndex = code.length - 1;
|
|
3681
3747
|
}
|
|
3682
3748
|
context.line++;
|
|
@@ -3703,7 +3769,7 @@ function createCodegenContext(ast, {
|
|
|
3703
3769
|
}
|
|
3704
3770
|
};
|
|
3705
3771
|
function newline(n) {
|
|
3706
|
-
context.push("\n" + ` `.repeat(n), 0
|
|
3772
|
+
context.push("\n" + ` `.repeat(n), 0);
|
|
3707
3773
|
}
|
|
3708
3774
|
function addMapping(loc, name = null) {
|
|
3709
3775
|
const { _names, _mappings } = context.map;
|
|
@@ -3768,7 +3834,7 @@ function generate(ast, options = {}) {
|
|
|
3768
3834
|
push(
|
|
3769
3835
|
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3770
3836
|
`,
|
|
3771
|
-
-1
|
|
3837
|
+
-1
|
|
3772
3838
|
);
|
|
3773
3839
|
newline();
|
|
3774
3840
|
}
|
|
@@ -3798,7 +3864,7 @@ function generate(ast, options = {}) {
|
|
|
3798
3864
|
}
|
|
3799
3865
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
3800
3866
|
push(`
|
|
3801
|
-
`, 0
|
|
3867
|
+
`, 0);
|
|
3802
3868
|
newline();
|
|
3803
3869
|
}
|
|
3804
3870
|
if (!ssr) {
|
|
@@ -3819,7 +3885,8 @@ function generate(ast, options = {}) {
|
|
|
3819
3885
|
ast,
|
|
3820
3886
|
code: context.code,
|
|
3821
3887
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
3822
|
-
map: context.map ? context.map.toJSON() : void 0
|
|
3888
|
+
map: context.map ? context.map.toJSON() : void 0,
|
|
3889
|
+
helpers: ast.helpers
|
|
3823
3890
|
};
|
|
3824
3891
|
}
|
|
3825
3892
|
function genFunctionPreamble(ast, context) {
|
|
@@ -3839,11 +3906,11 @@ function genFunctionPreamble(ast, context) {
|
|
|
3839
3906
|
push(
|
|
3840
3907
|
`const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
|
|
3841
3908
|
`,
|
|
3842
|
-
-1
|
|
3909
|
+
-1
|
|
3843
3910
|
);
|
|
3844
3911
|
} else {
|
|
3845
3912
|
push(`const _Vue = ${VueBinding}
|
|
3846
|
-
`, -1
|
|
3913
|
+
`, -1);
|
|
3847
3914
|
if (ast.hoists.length) {
|
|
3848
3915
|
const staticHelpers = [
|
|
3849
3916
|
CREATE_VNODE,
|
|
@@ -3853,7 +3920,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
3853
3920
|
CREATE_STATIC
|
|
3854
3921
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
3855
3922
|
push(`const { ${staticHelpers} } = _Vue
|
|
3856
|
-
`, -1
|
|
3923
|
+
`, -1);
|
|
3857
3924
|
}
|
|
3858
3925
|
}
|
|
3859
3926
|
}
|
|
@@ -3861,7 +3928,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
3861
3928
|
push(
|
|
3862
3929
|
`const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
|
|
3863
3930
|
`,
|
|
3864
|
-
-1
|
|
3931
|
+
-1
|
|
3865
3932
|
);
|
|
3866
3933
|
}
|
|
3867
3934
|
genHoists(ast.hoists, context);
|
|
@@ -3882,20 +3949,20 @@ function genModulePreamble(ast, context, genScopeId, inline) {
|
|
|
3882
3949
|
push(
|
|
3883
3950
|
`import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
|
|
3884
3951
|
`,
|
|
3885
|
-
-1
|
|
3952
|
+
-1
|
|
3886
3953
|
);
|
|
3887
3954
|
push(
|
|
3888
3955
|
`
|
|
3889
3956
|
// Binding optimization for webpack code-split
|
|
3890
3957
|
const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
|
|
3891
3958
|
`,
|
|
3892
|
-
-1
|
|
3959
|
+
-1
|
|
3893
3960
|
);
|
|
3894
3961
|
} else {
|
|
3895
3962
|
push(
|
|
3896
3963
|
`import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
|
|
3897
3964
|
`,
|
|
3898
|
-
-1
|
|
3965
|
+
-1
|
|
3899
3966
|
);
|
|
3900
3967
|
}
|
|
3901
3968
|
}
|
|
@@ -3903,7 +3970,7 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
|
|
|
3903
3970
|
push(
|
|
3904
3971
|
`import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
|
|
3905
3972
|
`,
|
|
3906
|
-
-1
|
|
3973
|
+
-1
|
|
3907
3974
|
);
|
|
3908
3975
|
}
|
|
3909
3976
|
if (ast.imports.length) {
|
|
@@ -3978,7 +4045,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3978
4045
|
for (let i = 0; i < nodes.length; i++) {
|
|
3979
4046
|
const node = nodes[i];
|
|
3980
4047
|
if (shared.isString(node)) {
|
|
3981
|
-
push(node, -3
|
|
4048
|
+
push(node, -3);
|
|
3982
4049
|
} else if (shared.isArray(node)) {
|
|
3983
4050
|
genNodeListAsArray(node, context);
|
|
3984
4051
|
} else {
|
|
@@ -3996,7 +4063,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3996
4063
|
}
|
|
3997
4064
|
function genNode(node, context) {
|
|
3998
4065
|
if (shared.isString(node)) {
|
|
3999
|
-
context.push(node, -3
|
|
4066
|
+
context.push(node, -3);
|
|
4000
4067
|
return;
|
|
4001
4068
|
}
|
|
4002
4069
|
if (shared.isSymbol(node)) {
|
|
@@ -4083,13 +4150,13 @@ function genNode(node, context) {
|
|
|
4083
4150
|
}
|
|
4084
4151
|
}
|
|
4085
4152
|
function genText(node, context) {
|
|
4086
|
-
context.push(JSON.stringify(node.content), -3
|
|
4153
|
+
context.push(JSON.stringify(node.content), -3, node);
|
|
4087
4154
|
}
|
|
4088
4155
|
function genExpression(node, context) {
|
|
4089
4156
|
const { content, isStatic } = node;
|
|
4090
4157
|
context.push(
|
|
4091
4158
|
isStatic ? JSON.stringify(content) : content,
|
|
4092
|
-
-3
|
|
4159
|
+
-3,
|
|
4093
4160
|
node
|
|
4094
4161
|
);
|
|
4095
4162
|
}
|
|
@@ -4104,7 +4171,7 @@ function genCompoundExpression(node, context) {
|
|
|
4104
4171
|
for (let i = 0; i < node.children.length; i++) {
|
|
4105
4172
|
const child = node.children[i];
|
|
4106
4173
|
if (shared.isString(child)) {
|
|
4107
|
-
context.push(child, -3
|
|
4174
|
+
context.push(child, -3);
|
|
4108
4175
|
} else {
|
|
4109
4176
|
genNode(child, context);
|
|
4110
4177
|
}
|
|
@@ -4118,9 +4185,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
4118
4185
|
push(`]`);
|
|
4119
4186
|
} else if (node.isStatic) {
|
|
4120
4187
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
4121
|
-
push(text, -2
|
|
4188
|
+
push(text, -2, node);
|
|
4122
4189
|
} else {
|
|
4123
|
-
push(`[${node.content}]`, -3
|
|
4190
|
+
push(`[${node.content}]`, -3, node);
|
|
4124
4191
|
}
|
|
4125
4192
|
}
|
|
4126
4193
|
function genComment(node, context) {
|
|
@@ -4130,7 +4197,7 @@ function genComment(node, context) {
|
|
|
4130
4197
|
}
|
|
4131
4198
|
push(
|
|
4132
4199
|
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
4133
|
-
-3
|
|
4200
|
+
-3,
|
|
4134
4201
|
node
|
|
4135
4202
|
);
|
|
4136
4203
|
}
|
|
@@ -4168,7 +4235,7 @@ function genVNodeCall(node, context) {
|
|
|
4168
4235
|
push(PURE_ANNOTATION);
|
|
4169
4236
|
}
|
|
4170
4237
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
4171
|
-
push(helper(callHelper) + `(`, -2
|
|
4238
|
+
push(helper(callHelper) + `(`, -2, node);
|
|
4172
4239
|
genNodeList(
|
|
4173
4240
|
genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
|
|
4174
4241
|
context
|
|
@@ -4196,7 +4263,7 @@ function genCallExpression(node, context) {
|
|
|
4196
4263
|
if (pure) {
|
|
4197
4264
|
push(PURE_ANNOTATION);
|
|
4198
4265
|
}
|
|
4199
|
-
push(callee + `(`, -2
|
|
4266
|
+
push(callee + `(`, -2, node);
|
|
4200
4267
|
genNodeList(node.arguments, context);
|
|
4201
4268
|
push(`)`);
|
|
4202
4269
|
}
|
|
@@ -4204,7 +4271,7 @@ function genObjectExpression(node, context) {
|
|
|
4204
4271
|
const { push, indent, deindent, newline } = context;
|
|
4205
4272
|
const { properties } = node;
|
|
4206
4273
|
if (!properties.length) {
|
|
4207
|
-
push(`{}`, -2
|
|
4274
|
+
push(`{}`, -2, node);
|
|
4208
4275
|
return;
|
|
4209
4276
|
}
|
|
4210
4277
|
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
@@ -4232,7 +4299,7 @@ function genFunctionExpression(node, context) {
|
|
|
4232
4299
|
if (isSlot) {
|
|
4233
4300
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
4234
4301
|
}
|
|
4235
|
-
push(`(`, -2
|
|
4302
|
+
push(`(`, -2, node);
|
|
4236
4303
|
if (shared.isArray(params)) {
|
|
4237
4304
|
genNodeList(params, context);
|
|
4238
4305
|
} else if (params) {
|
|
@@ -4339,7 +4406,7 @@ function genTemplateLiteral(node, context) {
|
|
|
4339
4406
|
for (let i = 0; i < l; i++) {
|
|
4340
4407
|
const e = node.elements[i];
|
|
4341
4408
|
if (shared.isString(e)) {
|
|
4342
|
-
push(e.replace(/(`|\$|\\)/g, "\\$1"), -3
|
|
4409
|
+
push(e.replace(/(`|\$|\\)/g, "\\$1"), -3);
|
|
4343
4410
|
} else {
|
|
4344
4411
|
push("${");
|
|
4345
4412
|
if (multilines) indent();
|
|
@@ -6714,6 +6781,7 @@ exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
|
|
|
6714
6781
|
exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
|
|
6715
6782
|
exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
|
|
6716
6783
|
exports.Namespaces = Namespaces;
|
|
6784
|
+
exports.NewlineType = NewlineType;
|
|
6717
6785
|
exports.NodeTypes = NodeTypes;
|
|
6718
6786
|
exports.OPEN_BLOCK = OPEN_BLOCK;
|
|
6719
6787
|
exports.POP_SCOPE_ID = POP_SCOPE_ID;
|
|
@@ -6767,6 +6835,8 @@ exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform;
|
|
|
6767
6835
|
exports.createTemplateLiteral = createTemplateLiteral;
|
|
6768
6836
|
exports.createTransformContext = createTransformContext;
|
|
6769
6837
|
exports.createVNodeCall = createVNodeCall;
|
|
6838
|
+
exports.defaultOnError = defaultOnError;
|
|
6839
|
+
exports.defaultOnWarn = defaultOnWarn;
|
|
6770
6840
|
exports.errorMessages = errorMessages;
|
|
6771
6841
|
exports.extractIdentifiers = extractIdentifiers;
|
|
6772
6842
|
exports.findDir = findDir;
|
|
@@ -6776,12 +6846,14 @@ exports.generate = generate;
|
|
|
6776
6846
|
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
6777
6847
|
exports.getConstantType = getConstantType;
|
|
6778
6848
|
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
6849
|
+
exports.getSelfName = getSelfName;
|
|
6779
6850
|
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
|
6780
6851
|
exports.getVNodeHelper = getVNodeHelper;
|
|
6781
6852
|
exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
|
|
6782
6853
|
exports.hasScopeRef = hasScopeRef;
|
|
6783
6854
|
exports.helperNameMap = helperNameMap;
|
|
6784
6855
|
exports.injectProp = injectProp;
|
|
6856
|
+
exports.isConstantNode = isConstantNode;
|
|
6785
6857
|
exports.isCoreComponent = isCoreComponent;
|
|
6786
6858
|
exports.isFnExpression = isFnExpression;
|
|
6787
6859
|
exports.isFnExpressionBrowser = isFnExpressionBrowser;
|
|
@@ -6789,6 +6861,7 @@ exports.isFnExpressionNode = isFnExpressionNode;
|
|
|
6789
6861
|
exports.isFunctionType = isFunctionType;
|
|
6790
6862
|
exports.isInDestructureAssignment = isInDestructureAssignment;
|
|
6791
6863
|
exports.isInNewExpression = isInNewExpression;
|
|
6864
|
+
exports.isLiteralWhitelisted = isLiteralWhitelisted;
|
|
6792
6865
|
exports.isMemberExpression = isMemberExpression;
|
|
6793
6866
|
exports.isMemberExpressionBrowser = isMemberExpressionBrowser;
|
|
6794
6867
|
exports.isMemberExpressionNode = isMemberExpressionNode;
|
|
@@ -6797,6 +6870,7 @@ exports.isSimpleIdentifier = isSimpleIdentifier;
|
|
|
6797
6870
|
exports.isSlotOutlet = isSlotOutlet;
|
|
6798
6871
|
exports.isStaticArgOf = isStaticArgOf;
|
|
6799
6872
|
exports.isStaticExp = isStaticExp;
|
|
6873
|
+
exports.isStaticNode = isStaticNode;
|
|
6800
6874
|
exports.isStaticProperty = isStaticProperty;
|
|
6801
6875
|
exports.isStaticPropertyKey = isStaticPropertyKey;
|
|
6802
6876
|
exports.isTemplateNode = isTemplateNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.
|
|
2
|
+
* @vue/compiler-core v3.6.0-alpha.2
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
@@ -1731,7 +1731,7 @@ function markScopeIdentifier(node, child, knownIds) {
|
|
|
1731
1731
|
const isFunctionType = (node) => {
|
|
1732
1732
|
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
1733
1733
|
};
|
|
1734
|
-
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1734
|
+
const isStaticProperty = (node) => !!node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1735
1735
|
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
1736
1736
|
function isReferenced(node, parent, grandparent) {
|
|
1737
1737
|
switch (parent.type) {
|
|
@@ -1890,6 +1890,59 @@ function unwrapTSNode(node) {
|
|
|
1890
1890
|
return node;
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
|
+
function isStaticNode(node) {
|
|
1894
|
+
node = unwrapTSNode(node);
|
|
1895
|
+
switch (node.type) {
|
|
1896
|
+
case "UnaryExpression":
|
|
1897
|
+
return isStaticNode(node.argument);
|
|
1898
|
+
case "LogicalExpression":
|
|
1899
|
+
// 1 > 2
|
|
1900
|
+
case "BinaryExpression":
|
|
1901
|
+
return isStaticNode(node.left) && isStaticNode(node.right);
|
|
1902
|
+
case "ConditionalExpression": {
|
|
1903
|
+
return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
|
|
1904
|
+
}
|
|
1905
|
+
case "SequenceExpression":
|
|
1906
|
+
// (1, 2)
|
|
1907
|
+
case "TemplateLiteral":
|
|
1908
|
+
return node.expressions.every((expr) => isStaticNode(expr));
|
|
1909
|
+
case "ParenthesizedExpression":
|
|
1910
|
+
return isStaticNode(node.expression);
|
|
1911
|
+
case "StringLiteral":
|
|
1912
|
+
case "NumericLiteral":
|
|
1913
|
+
case "BooleanLiteral":
|
|
1914
|
+
case "NullLiteral":
|
|
1915
|
+
case "BigIntLiteral":
|
|
1916
|
+
return true;
|
|
1917
|
+
}
|
|
1918
|
+
return false;
|
|
1919
|
+
}
|
|
1920
|
+
function isConstantNode(node, bindings) {
|
|
1921
|
+
if (isStaticNode(node)) return true;
|
|
1922
|
+
node = unwrapTSNode(node);
|
|
1923
|
+
switch (node.type) {
|
|
1924
|
+
case "Identifier":
|
|
1925
|
+
const type = bindings[node.name];
|
|
1926
|
+
return type === "literal-const";
|
|
1927
|
+
case "RegExpLiteral":
|
|
1928
|
+
return true;
|
|
1929
|
+
case "ObjectExpression":
|
|
1930
|
+
return node.properties.every((prop) => {
|
|
1931
|
+
if (prop.type === "ObjectMethod") return false;
|
|
1932
|
+
if (prop.type === "SpreadElement")
|
|
1933
|
+
return isConstantNode(prop.argument, bindings);
|
|
1934
|
+
return (!prop.computed || isConstantNode(prop.key, bindings)) && isConstantNode(prop.value, bindings);
|
|
1935
|
+
});
|
|
1936
|
+
case "ArrayExpression":
|
|
1937
|
+
return node.elements.every((element) => {
|
|
1938
|
+
if (element === null) return true;
|
|
1939
|
+
if (element.type === "SpreadElement")
|
|
1940
|
+
return isConstantNode(element.argument, bindings);
|
|
1941
|
+
return isConstantNode(element, bindings);
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
return false;
|
|
1945
|
+
}
|
|
1893
1946
|
|
|
1894
1947
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
1895
1948
|
function isCoreComponent(tag) {
|
|
@@ -3248,6 +3301,10 @@ function getNodeProps(node) {
|
|
|
3248
3301
|
}
|
|
3249
3302
|
}
|
|
3250
3303
|
|
|
3304
|
+
function getSelfName(filename) {
|
|
3305
|
+
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
3306
|
+
return nameMatch ? shared.capitalize(shared.camelize(nameMatch[1])) : null;
|
|
3307
|
+
}
|
|
3251
3308
|
function createTransformContext(root, {
|
|
3252
3309
|
filename = "",
|
|
3253
3310
|
prefixIdentifiers = false,
|
|
@@ -3272,11 +3329,10 @@ function createTransformContext(root, {
|
|
|
3272
3329
|
onWarn = defaultOnWarn,
|
|
3273
3330
|
compatConfig
|
|
3274
3331
|
}) {
|
|
3275
|
-
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
3276
3332
|
const context = {
|
|
3277
3333
|
// options
|
|
3278
3334
|
filename,
|
|
3279
|
-
selfName:
|
|
3335
|
+
selfName: getSelfName(filename),
|
|
3280
3336
|
prefixIdentifiers,
|
|
3281
3337
|
hoistStatic,
|
|
3282
3338
|
hmr,
|
|
@@ -3558,6 +3614,16 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
3558
3614
|
|
|
3559
3615
|
const PURE_ANNOTATION = `/*@__PURE__*/`;
|
|
3560
3616
|
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
3617
|
+
const NewlineType = {
|
|
3618
|
+
"Start": 0,
|
|
3619
|
+
"0": "Start",
|
|
3620
|
+
"End": -1,
|
|
3621
|
+
"-1": "End",
|
|
3622
|
+
"None": -2,
|
|
3623
|
+
"-2": "None",
|
|
3624
|
+
"Unknown": -3,
|
|
3625
|
+
"-3": "Unknown"
|
|
3626
|
+
};
|
|
3561
3627
|
function createCodegenContext(ast, {
|
|
3562
3628
|
mode = "function",
|
|
3563
3629
|
prefixIdentifiers = mode === "module",
|
|
@@ -3596,7 +3662,7 @@ function createCodegenContext(ast, {
|
|
|
3596
3662
|
helper(key) {
|
|
3597
3663
|
return `_${helperNameMap[key]}`;
|
|
3598
3664
|
},
|
|
3599
|
-
push(code, newlineIndex = -2
|
|
3665
|
+
push(code, newlineIndex = -2, node) {
|
|
3600
3666
|
context.code += code;
|
|
3601
3667
|
if (context.map) {
|
|
3602
3668
|
if (node) {
|
|
@@ -3611,14 +3677,14 @@ function createCodegenContext(ast, {
|
|
|
3611
3677
|
addMapping(node.loc.start, name);
|
|
3612
3678
|
}
|
|
3613
3679
|
}
|
|
3614
|
-
if (newlineIndex === -3
|
|
3680
|
+
if (newlineIndex === -3) {
|
|
3615
3681
|
advancePositionWithMutation(context, code);
|
|
3616
3682
|
} else {
|
|
3617
3683
|
context.offset += code.length;
|
|
3618
|
-
if (newlineIndex === -2
|
|
3684
|
+
if (newlineIndex === -2) {
|
|
3619
3685
|
context.column += code.length;
|
|
3620
3686
|
} else {
|
|
3621
|
-
if (newlineIndex === -1
|
|
3687
|
+
if (newlineIndex === -1) {
|
|
3622
3688
|
newlineIndex = code.length - 1;
|
|
3623
3689
|
}
|
|
3624
3690
|
context.line++;
|
|
@@ -3645,7 +3711,7 @@ function createCodegenContext(ast, {
|
|
|
3645
3711
|
}
|
|
3646
3712
|
};
|
|
3647
3713
|
function newline(n) {
|
|
3648
|
-
context.push("\n" + ` `.repeat(n), 0
|
|
3714
|
+
context.push("\n" + ` `.repeat(n), 0);
|
|
3649
3715
|
}
|
|
3650
3716
|
function addMapping(loc, name = null) {
|
|
3651
3717
|
const { _names, _mappings } = context.map;
|
|
@@ -3710,7 +3776,7 @@ function generate(ast, options = {}) {
|
|
|
3710
3776
|
push(
|
|
3711
3777
|
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3712
3778
|
`,
|
|
3713
|
-
-1
|
|
3779
|
+
-1
|
|
3714
3780
|
);
|
|
3715
3781
|
newline();
|
|
3716
3782
|
}
|
|
@@ -3740,7 +3806,7 @@ function generate(ast, options = {}) {
|
|
|
3740
3806
|
}
|
|
3741
3807
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
3742
3808
|
push(`
|
|
3743
|
-
`, 0
|
|
3809
|
+
`, 0);
|
|
3744
3810
|
newline();
|
|
3745
3811
|
}
|
|
3746
3812
|
if (!ssr) {
|
|
@@ -3761,7 +3827,8 @@ function generate(ast, options = {}) {
|
|
|
3761
3827
|
ast,
|
|
3762
3828
|
code: context.code,
|
|
3763
3829
|
preamble: isSetupInlined ? preambleContext.code : ``,
|
|
3764
|
-
map: context.map ? context.map.toJSON() : void 0
|
|
3830
|
+
map: context.map ? context.map.toJSON() : void 0,
|
|
3831
|
+
helpers: ast.helpers
|
|
3765
3832
|
};
|
|
3766
3833
|
}
|
|
3767
3834
|
function genFunctionPreamble(ast, context) {
|
|
@@ -3781,11 +3848,11 @@ function genFunctionPreamble(ast, context) {
|
|
|
3781
3848
|
push(
|
|
3782
3849
|
`const { ${helpers.map(aliasHelper).join(", ")} } = ${VueBinding}
|
|
3783
3850
|
`,
|
|
3784
|
-
-1
|
|
3851
|
+
-1
|
|
3785
3852
|
);
|
|
3786
3853
|
} else {
|
|
3787
3854
|
push(`const _Vue = ${VueBinding}
|
|
3788
|
-
`, -1
|
|
3855
|
+
`, -1);
|
|
3789
3856
|
if (ast.hoists.length) {
|
|
3790
3857
|
const staticHelpers = [
|
|
3791
3858
|
CREATE_VNODE,
|
|
@@ -3795,7 +3862,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
3795
3862
|
CREATE_STATIC
|
|
3796
3863
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
3797
3864
|
push(`const { ${staticHelpers} } = _Vue
|
|
3798
|
-
`, -1
|
|
3865
|
+
`, -1);
|
|
3799
3866
|
}
|
|
3800
3867
|
}
|
|
3801
3868
|
}
|
|
@@ -3803,7 +3870,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
3803
3870
|
push(
|
|
3804
3871
|
`const { ${ast.ssrHelpers.map(aliasHelper).join(", ")} } = require("${ssrRuntimeModuleName}")
|
|
3805
3872
|
`,
|
|
3806
|
-
-1
|
|
3873
|
+
-1
|
|
3807
3874
|
);
|
|
3808
3875
|
}
|
|
3809
3876
|
genHoists(ast.hoists, context);
|
|
@@ -3824,20 +3891,20 @@ function genModulePreamble(ast, context, genScopeId, inline) {
|
|
|
3824
3891
|
push(
|
|
3825
3892
|
`import { ${helpers.map((s) => helperNameMap[s]).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
|
|
3826
3893
|
`,
|
|
3827
|
-
-1
|
|
3894
|
+
-1
|
|
3828
3895
|
);
|
|
3829
3896
|
push(
|
|
3830
3897
|
`
|
|
3831
3898
|
// Binding optimization for webpack code-split
|
|
3832
3899
|
const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(", ")}
|
|
3833
3900
|
`,
|
|
3834
|
-
-1
|
|
3901
|
+
-1
|
|
3835
3902
|
);
|
|
3836
3903
|
} else {
|
|
3837
3904
|
push(
|
|
3838
3905
|
`import { ${helpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from ${JSON.stringify(runtimeModuleName)}
|
|
3839
3906
|
`,
|
|
3840
|
-
-1
|
|
3907
|
+
-1
|
|
3841
3908
|
);
|
|
3842
3909
|
}
|
|
3843
3910
|
}
|
|
@@ -3845,7 +3912,7 @@ const ${helpers.map((s) => `_${helperNameMap[s]} = ${helperNameMap[s]}`).join(",
|
|
|
3845
3912
|
push(
|
|
3846
3913
|
`import { ${ast.ssrHelpers.map((s) => `${helperNameMap[s]} as _${helperNameMap[s]}`).join(", ")} } from "${ssrRuntimeModuleName}"
|
|
3847
3914
|
`,
|
|
3848
|
-
-1
|
|
3915
|
+
-1
|
|
3849
3916
|
);
|
|
3850
3917
|
}
|
|
3851
3918
|
if (ast.imports.length) {
|
|
@@ -3920,7 +3987,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3920
3987
|
for (let i = 0; i < nodes.length; i++) {
|
|
3921
3988
|
const node = nodes[i];
|
|
3922
3989
|
if (shared.isString(node)) {
|
|
3923
|
-
push(node, -3
|
|
3990
|
+
push(node, -3);
|
|
3924
3991
|
} else if (shared.isArray(node)) {
|
|
3925
3992
|
genNodeListAsArray(node, context);
|
|
3926
3993
|
} else {
|
|
@@ -3938,7 +4005,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3938
4005
|
}
|
|
3939
4006
|
function genNode(node, context) {
|
|
3940
4007
|
if (shared.isString(node)) {
|
|
3941
|
-
context.push(node, -3
|
|
4008
|
+
context.push(node, -3);
|
|
3942
4009
|
return;
|
|
3943
4010
|
}
|
|
3944
4011
|
if (shared.isSymbol(node)) {
|
|
@@ -4012,13 +4079,13 @@ function genNode(node, context) {
|
|
|
4012
4079
|
}
|
|
4013
4080
|
}
|
|
4014
4081
|
function genText(node, context) {
|
|
4015
|
-
context.push(JSON.stringify(node.content), -3
|
|
4082
|
+
context.push(JSON.stringify(node.content), -3, node);
|
|
4016
4083
|
}
|
|
4017
4084
|
function genExpression(node, context) {
|
|
4018
4085
|
const { content, isStatic } = node;
|
|
4019
4086
|
context.push(
|
|
4020
4087
|
isStatic ? JSON.stringify(content) : content,
|
|
4021
|
-
-3
|
|
4088
|
+
-3,
|
|
4022
4089
|
node
|
|
4023
4090
|
);
|
|
4024
4091
|
}
|
|
@@ -4033,7 +4100,7 @@ function genCompoundExpression(node, context) {
|
|
|
4033
4100
|
for (let i = 0; i < node.children.length; i++) {
|
|
4034
4101
|
const child = node.children[i];
|
|
4035
4102
|
if (shared.isString(child)) {
|
|
4036
|
-
context.push(child, -3
|
|
4103
|
+
context.push(child, -3);
|
|
4037
4104
|
} else {
|
|
4038
4105
|
genNode(child, context);
|
|
4039
4106
|
}
|
|
@@ -4047,9 +4114,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
4047
4114
|
push(`]`);
|
|
4048
4115
|
} else if (node.isStatic) {
|
|
4049
4116
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
4050
|
-
push(text, -2
|
|
4117
|
+
push(text, -2, node);
|
|
4051
4118
|
} else {
|
|
4052
|
-
push(`[${node.content}]`, -3
|
|
4119
|
+
push(`[${node.content}]`, -3, node);
|
|
4053
4120
|
}
|
|
4054
4121
|
}
|
|
4055
4122
|
function genComment(node, context) {
|
|
@@ -4059,7 +4126,7 @@ function genComment(node, context) {
|
|
|
4059
4126
|
}
|
|
4060
4127
|
push(
|
|
4061
4128
|
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
4062
|
-
-3
|
|
4129
|
+
-3,
|
|
4063
4130
|
node
|
|
4064
4131
|
);
|
|
4065
4132
|
}
|
|
@@ -4092,7 +4159,7 @@ function genVNodeCall(node, context) {
|
|
|
4092
4159
|
push(PURE_ANNOTATION);
|
|
4093
4160
|
}
|
|
4094
4161
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
4095
|
-
push(helper(callHelper) + `(`, -2
|
|
4162
|
+
push(helper(callHelper) + `(`, -2, node);
|
|
4096
4163
|
genNodeList(
|
|
4097
4164
|
genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
|
|
4098
4165
|
context
|
|
@@ -4120,7 +4187,7 @@ function genCallExpression(node, context) {
|
|
|
4120
4187
|
if (pure) {
|
|
4121
4188
|
push(PURE_ANNOTATION);
|
|
4122
4189
|
}
|
|
4123
|
-
push(callee + `(`, -2
|
|
4190
|
+
push(callee + `(`, -2, node);
|
|
4124
4191
|
genNodeList(node.arguments, context);
|
|
4125
4192
|
push(`)`);
|
|
4126
4193
|
}
|
|
@@ -4128,7 +4195,7 @@ function genObjectExpression(node, context) {
|
|
|
4128
4195
|
const { push, indent, deindent, newline } = context;
|
|
4129
4196
|
const { properties } = node;
|
|
4130
4197
|
if (!properties.length) {
|
|
4131
|
-
push(`{}`, -2
|
|
4198
|
+
push(`{}`, -2, node);
|
|
4132
4199
|
return;
|
|
4133
4200
|
}
|
|
4134
4201
|
const multilines = properties.length > 1 || properties.some((p) => p.value.type !== 4);
|
|
@@ -4156,7 +4223,7 @@ function genFunctionExpression(node, context) {
|
|
|
4156
4223
|
if (isSlot) {
|
|
4157
4224
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
4158
4225
|
}
|
|
4159
|
-
push(`(`, -2
|
|
4226
|
+
push(`(`, -2, node);
|
|
4160
4227
|
if (shared.isArray(params)) {
|
|
4161
4228
|
genNodeList(params, context);
|
|
4162
4229
|
} else if (params) {
|
|
@@ -4263,7 +4330,7 @@ function genTemplateLiteral(node, context) {
|
|
|
4263
4330
|
for (let i = 0; i < l; i++) {
|
|
4264
4331
|
const e = node.elements[i];
|
|
4265
4332
|
if (shared.isString(e)) {
|
|
4266
|
-
push(e.replace(/(`|\$|\\)/g, "\\$1"), -3
|
|
4333
|
+
push(e.replace(/(`|\$|\\)/g, "\\$1"), -3);
|
|
4267
4334
|
} else {
|
|
4268
4335
|
push("${");
|
|
4269
4336
|
if (multilines) indent();
|
|
@@ -6591,6 +6658,7 @@ exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
|
|
|
6591
6658
|
exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
|
|
6592
6659
|
exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
|
|
6593
6660
|
exports.Namespaces = Namespaces;
|
|
6661
|
+
exports.NewlineType = NewlineType;
|
|
6594
6662
|
exports.NodeTypes = NodeTypes;
|
|
6595
6663
|
exports.OPEN_BLOCK = OPEN_BLOCK;
|
|
6596
6664
|
exports.POP_SCOPE_ID = POP_SCOPE_ID;
|
|
@@ -6644,6 +6712,8 @@ exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform;
|
|
|
6644
6712
|
exports.createTemplateLiteral = createTemplateLiteral;
|
|
6645
6713
|
exports.createTransformContext = createTransformContext;
|
|
6646
6714
|
exports.createVNodeCall = createVNodeCall;
|
|
6715
|
+
exports.defaultOnError = defaultOnError;
|
|
6716
|
+
exports.defaultOnWarn = defaultOnWarn;
|
|
6647
6717
|
exports.errorMessages = errorMessages;
|
|
6648
6718
|
exports.extractIdentifiers = extractIdentifiers;
|
|
6649
6719
|
exports.findDir = findDir;
|
|
@@ -6653,12 +6723,14 @@ exports.generate = generate;
|
|
|
6653
6723
|
exports.getBaseTransformPreset = getBaseTransformPreset;
|
|
6654
6724
|
exports.getConstantType = getConstantType;
|
|
6655
6725
|
exports.getMemoedVNodeCall = getMemoedVNodeCall;
|
|
6726
|
+
exports.getSelfName = getSelfName;
|
|
6656
6727
|
exports.getVNodeBlockHelper = getVNodeBlockHelper;
|
|
6657
6728
|
exports.getVNodeHelper = getVNodeHelper;
|
|
6658
6729
|
exports.hasDynamicKeyVBind = hasDynamicKeyVBind;
|
|
6659
6730
|
exports.hasScopeRef = hasScopeRef;
|
|
6660
6731
|
exports.helperNameMap = helperNameMap;
|
|
6661
6732
|
exports.injectProp = injectProp;
|
|
6733
|
+
exports.isConstantNode = isConstantNode;
|
|
6662
6734
|
exports.isCoreComponent = isCoreComponent;
|
|
6663
6735
|
exports.isFnExpression = isFnExpression;
|
|
6664
6736
|
exports.isFnExpressionBrowser = isFnExpressionBrowser;
|
|
@@ -6666,6 +6738,7 @@ exports.isFnExpressionNode = isFnExpressionNode;
|
|
|
6666
6738
|
exports.isFunctionType = isFunctionType;
|
|
6667
6739
|
exports.isInDestructureAssignment = isInDestructureAssignment;
|
|
6668
6740
|
exports.isInNewExpression = isInNewExpression;
|
|
6741
|
+
exports.isLiteralWhitelisted = isLiteralWhitelisted;
|
|
6669
6742
|
exports.isMemberExpression = isMemberExpression;
|
|
6670
6743
|
exports.isMemberExpressionBrowser = isMemberExpressionBrowser;
|
|
6671
6744
|
exports.isMemberExpressionNode = isMemberExpressionNode;
|
|
@@ -6674,6 +6747,7 @@ exports.isSimpleIdentifier = isSimpleIdentifier;
|
|
|
6674
6747
|
exports.isSlotOutlet = isSlotOutlet;
|
|
6675
6748
|
exports.isStaticArgOf = isStaticArgOf;
|
|
6676
6749
|
exports.isStaticExp = isStaticExp;
|
|
6750
|
+
exports.isStaticNode = isStaticNode;
|
|
6677
6751
|
exports.isStaticProperty = isStaticProperty;
|
|
6678
6752
|
exports.isStaticPropertyKey = isStaticPropertyKey;
|
|
6679
6753
|
exports.isTemplateNode = isTemplateNode;
|
package/dist/compiler-core.d.ts
CHANGED
|
@@ -59,7 +59,7 @@ export declare function baseParse(input: string, options?: ParserOptions): RootN
|
|
|
59
59
|
type CompilerCompatConfig = Partial<Record<CompilerDeprecationTypes, boolean | 'suppress-warning'>> & {
|
|
60
60
|
MODE?: 2 | 3;
|
|
61
61
|
};
|
|
62
|
-
interface CompilerCompatOptions {
|
|
62
|
+
export interface CompilerCompatOptions {
|
|
63
63
|
compatConfig?: CompilerCompatConfig;
|
|
64
64
|
}
|
|
65
65
|
export declare enum CompilerDeprecationTypes {
|
|
@@ -124,6 +124,7 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
|
|
|
124
124
|
constantCache: WeakMap<TemplateChildNode, ConstantTypes>;
|
|
125
125
|
filters?: Set<string>;
|
|
126
126
|
}
|
|
127
|
+
export declare function getSelfName(filename: string): string | null;
|
|
127
128
|
export declare function createTransformContext(root: RootNode, { filename, prefixIdentifiers, hoistStatic, hmr, cacheHandlers, nodeTransforms, directiveTransforms, transformHoist, isBuiltInComponent, isCustomElement, expressionPlugins, scopeId, slotted, ssr, inSSR, ssrCssVars, bindingMetadata, inline, isTS, onError, onWarn, compatConfig, }: TransformOptions): TransformContext;
|
|
128
129
|
export declare function transform(root: RootNode, options: TransformOptions): void;
|
|
129
130
|
export declare function traverseNode(node: RootNode | TemplateChildNode, context: TransformContext): void;
|
|
@@ -196,6 +197,7 @@ export interface Position {
|
|
|
196
197
|
line: number;
|
|
197
198
|
column: number;
|
|
198
199
|
}
|
|
200
|
+
export type AllNode = ParentNode | ExpressionNode | TemplateChildNode | AttributeNode | DirectiveNode;
|
|
199
201
|
export type ParentNode = RootNode | ElementNode | IfBranchNode | ForNode;
|
|
200
202
|
export type ExpressionNode = SimpleExpressionNode | CompoundExpressionNode;
|
|
201
203
|
export type TemplateChildNode = ElementNode | InterpolationNode | CompoundExpressionNode | TextNode | CommentNode | IfNode | IfBranchNode | ForNode | TextCallNode;
|
|
@@ -565,6 +567,8 @@ export interface CompilerError extends SyntaxError {
|
|
|
565
567
|
export interface CoreCompilerError extends CompilerError {
|
|
566
568
|
code: ErrorCodes;
|
|
567
569
|
}
|
|
570
|
+
export declare function defaultOnError(error: CompilerError): never;
|
|
571
|
+
export declare function defaultOnWarn(msg: CompilerError): void;
|
|
568
572
|
type InferCompilerError<T> = T extends ErrorCodes ? CoreCompilerError : CompilerError;
|
|
569
573
|
export declare function createCompilerError<T extends number>(code: T, loc?: SourceLocation, messages?: {
|
|
570
574
|
[code: number]: string;
|
|
@@ -772,6 +776,12 @@ interface SharedTransformCodegenOptions {
|
|
|
772
776
|
* @default mode === 'module'
|
|
773
777
|
*/
|
|
774
778
|
prefixIdentifiers?: boolean;
|
|
779
|
+
/**
|
|
780
|
+
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
|
781
|
+
* parse expressions in bindings and interpolations.
|
|
782
|
+
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
|
783
|
+
*/
|
|
784
|
+
expressionPlugins?: ParserPlugin[];
|
|
775
785
|
/**
|
|
776
786
|
* Control whether generate SSR-optimized render functions instead.
|
|
777
787
|
* The resulting function must be attached to the component via the
|
|
@@ -866,12 +876,6 @@ export interface TransformOptions extends SharedTransformCodegenOptions, ErrorHa
|
|
|
866
876
|
* @default false
|
|
867
877
|
*/
|
|
868
878
|
cacheHandlers?: boolean;
|
|
869
|
-
/**
|
|
870
|
-
* A list of parser plugins to enable for `@babel/parser`, which is used to
|
|
871
|
-
* parse expressions in bindings and interpolations.
|
|
872
|
-
* https://babeljs.io/docs/en/next/babel-parser#plugins
|
|
873
|
-
*/
|
|
874
|
-
expressionPlugins?: ParserPlugin[];
|
|
875
879
|
/**
|
|
876
880
|
* SFC scoped styles ID
|
|
877
881
|
*/
|
|
@@ -976,13 +980,28 @@ interface MappingItem {
|
|
|
976
980
|
name: string | null;
|
|
977
981
|
}
|
|
978
982
|
type CodegenNode = TemplateChildNode | JSChildNode | SSRCodegenNode;
|
|
979
|
-
export interface
|
|
983
|
+
export interface BaseCodegenResult {
|
|
980
984
|
code: string;
|
|
981
985
|
preamble: string;
|
|
982
|
-
ast:
|
|
986
|
+
ast: unknown;
|
|
983
987
|
map?: RawSourceMap;
|
|
988
|
+
helpers?: Set<string> | Set<symbol>;
|
|
989
|
+
}
|
|
990
|
+
export interface CodegenResult extends BaseCodegenResult {
|
|
991
|
+
ast: RootNode;
|
|
992
|
+
helpers: Set<symbol>;
|
|
984
993
|
}
|
|
985
|
-
export
|
|
994
|
+
export declare enum NewlineType {
|
|
995
|
+
/** Start with `\n` */
|
|
996
|
+
Start = 0,
|
|
997
|
+
/** Ends with `\n` */
|
|
998
|
+
End = -1,
|
|
999
|
+
/** No `\n` included */
|
|
1000
|
+
None = -2,
|
|
1001
|
+
/** Don't know, calc it */
|
|
1002
|
+
Unknown = -3
|
|
1003
|
+
}
|
|
1004
|
+
export interface CodegenContext extends Omit<Required<CodegenOptions>, 'bindingMetadata' | 'inline' | 'vaporRuntimeModuleName' | 'expressionPlugins'> {
|
|
986
1005
|
source: string;
|
|
987
1006
|
code: string;
|
|
988
1007
|
line: number;
|
|
@@ -1018,14 +1037,15 @@ export declare const isSimpleIdentifier: (name: string) => boolean;
|
|
|
1018
1037
|
* expressions and false positives are invalid expressions in the first place.
|
|
1019
1038
|
*/
|
|
1020
1039
|
export declare const isMemberExpressionBrowser: (exp: ExpressionNode) => boolean;
|
|
1021
|
-
export declare const isMemberExpressionNode: (exp: ExpressionNode, context: TransformContext) => boolean;
|
|
1022
|
-
export declare const isMemberExpression: (exp: ExpressionNode, context: TransformContext) => boolean;
|
|
1040
|
+
export declare const isMemberExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext, 'expressionPlugins'>) => boolean;
|
|
1041
|
+
export declare const isMemberExpression: (exp: ExpressionNode, context: Pick<TransformContext, 'expressionPlugins'>) => boolean;
|
|
1023
1042
|
export declare const isFnExpressionBrowser: (exp: ExpressionNode) => boolean;
|
|
1024
|
-
export declare const isFnExpressionNode: (exp: ExpressionNode, context: TransformContext) => boolean;
|
|
1025
|
-
export declare const isFnExpression: (exp: ExpressionNode, context: TransformContext) => boolean;
|
|
1043
|
+
export declare const isFnExpressionNode: (exp: ExpressionNode, context: Pick<TransformContext, 'expressionPlugins'>) => boolean;
|
|
1044
|
+
export declare const isFnExpression: (exp: ExpressionNode, context: Pick<TransformContext, 'expressionPlugins'>) => boolean;
|
|
1026
1045
|
export declare function advancePositionWithClone(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
1027
1046
|
export declare function advancePositionWithMutation(pos: Position, source: string, numberOfCharacters?: number): Position;
|
|
1028
1047
|
export declare function assert(condition: boolean, msg?: string): void;
|
|
1048
|
+
/** find directive */
|
|
1029
1049
|
export declare function findDir(node: ElementNode, name: string | RegExp, allowEmpty?: boolean): DirectiveNode | undefined;
|
|
1030
1050
|
export declare function findProp(node: ElementNode, name: string, dynamicOnly?: boolean, allowEmpty?: boolean): ElementNode['props'][0] | undefined;
|
|
1031
1051
|
export declare function isStaticArgOf(arg: DirectiveNode['arg'], name: string): boolean;
|
|
@@ -1051,10 +1071,12 @@ export declare function walkFunctionParams(node: Function, onIdent: (id: Identif
|
|
|
1051
1071
|
export declare function walkBlockDeclarations(block: BlockStatement$1 | Program, onIdent: (node: Identifier) => void): void;
|
|
1052
1072
|
export declare function extractIdentifiers(param: Node$1, nodes?: Identifier[]): Identifier[];
|
|
1053
1073
|
export declare const isFunctionType: (node: Node$1) => node is Function;
|
|
1054
|
-
export declare const isStaticProperty: (node
|
|
1074
|
+
export declare const isStaticProperty: (node?: Node$1) => node is ObjectProperty;
|
|
1055
1075
|
export declare const isStaticPropertyKey: (node: Node$1, parent: Node$1) => boolean;
|
|
1056
1076
|
export declare const TS_NODE_TYPES: string[];
|
|
1057
1077
|
export declare function unwrapTSNode(node: Node$1): Node$1;
|
|
1078
|
+
export declare function isStaticNode(node: Node$1): boolean;
|
|
1079
|
+
export declare function isConstantNode(node: Node$1, bindings: BindingMetadata): boolean;
|
|
1058
1080
|
|
|
1059
1081
|
export declare const transformModel: DirectiveTransform;
|
|
1060
1082
|
|
|
@@ -1069,6 +1091,7 @@ export declare function processIf(node: ElementNode, dir: DirectiveNode, context
|
|
|
1069
1091
|
export declare function processFor(node: ElementNode, dir: DirectiveNode, context: TransformContext, processCodegen?: (forNode: ForNode) => (() => void) | undefined): (() => void) | undefined;
|
|
1070
1092
|
export declare function createForLoopParams({ value, key, index }: ForParseResult, memoArgs?: ExpressionNode[]): ExpressionNode[];
|
|
1071
1093
|
|
|
1094
|
+
export declare const isLiteralWhitelisted: (key: string) => boolean;
|
|
1072
1095
|
export declare const transformExpression: NodeTransform;
|
|
1073
1096
|
export declare function processExpression(node: SimpleExpressionNode, context: TransformContext, asParams?: boolean, asRawStatements?: boolean, localVars?: Record<string, number>): ExpressionNode;
|
|
1074
1097
|
export declare function stringifyExpression(exp: ExpressionNode | string): string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @vue/compiler-core v3.
|
|
2
|
+
* @vue/compiler-core v3.6.0-alpha.2
|
|
3
3
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
4
4
|
* @license MIT
|
|
5
5
|
**/
|
|
6
|
-
import { isString, NOOP, isObject, extend, NO, isSymbol, isArray, capitalize, camelize,
|
|
6
|
+
import { isString, NOOP, isObject, extend, NO, isSymbol, isArray, EMPTY_OBJ, capitalize, camelize, PatchFlagNames, makeMap, slotFlagsText, isOn, isBuiltInDirective, isReservedProp, toHandlerKey } from '@vue/shared';
|
|
7
7
|
export { generateCodeFrame } from '@vue/shared';
|
|
8
8
|
|
|
9
9
|
const FRAGMENT = Symbol(!!(process.env.NODE_ENV !== "production") ? `Fragment` : ``);
|
|
@@ -1581,7 +1581,7 @@ function extractIdentifiers(param, nodes = []) {
|
|
|
1581
1581
|
const isFunctionType = (node) => {
|
|
1582
1582
|
return /Function(?:Expression|Declaration)$|Method$/.test(node.type);
|
|
1583
1583
|
};
|
|
1584
|
-
const isStaticProperty = (node) => node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1584
|
+
const isStaticProperty = (node) => !!node && (node.type === "ObjectProperty" || node.type === "ObjectMethod") && !node.computed;
|
|
1585
1585
|
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
|
1586
1586
|
const TS_NODE_TYPES = [
|
|
1587
1587
|
"TSAsExpression",
|
|
@@ -1602,6 +1602,59 @@ function unwrapTSNode(node) {
|
|
|
1602
1602
|
return node;
|
|
1603
1603
|
}
|
|
1604
1604
|
}
|
|
1605
|
+
function isStaticNode(node) {
|
|
1606
|
+
node = unwrapTSNode(node);
|
|
1607
|
+
switch (node.type) {
|
|
1608
|
+
case "UnaryExpression":
|
|
1609
|
+
return isStaticNode(node.argument);
|
|
1610
|
+
case "LogicalExpression":
|
|
1611
|
+
// 1 > 2
|
|
1612
|
+
case "BinaryExpression":
|
|
1613
|
+
return isStaticNode(node.left) && isStaticNode(node.right);
|
|
1614
|
+
case "ConditionalExpression": {
|
|
1615
|
+
return isStaticNode(node.test) && isStaticNode(node.consequent) && isStaticNode(node.alternate);
|
|
1616
|
+
}
|
|
1617
|
+
case "SequenceExpression":
|
|
1618
|
+
// (1, 2)
|
|
1619
|
+
case "TemplateLiteral":
|
|
1620
|
+
return node.expressions.every((expr) => isStaticNode(expr));
|
|
1621
|
+
case "ParenthesizedExpression":
|
|
1622
|
+
return isStaticNode(node.expression);
|
|
1623
|
+
case "StringLiteral":
|
|
1624
|
+
case "NumericLiteral":
|
|
1625
|
+
case "BooleanLiteral":
|
|
1626
|
+
case "NullLiteral":
|
|
1627
|
+
case "BigIntLiteral":
|
|
1628
|
+
return true;
|
|
1629
|
+
}
|
|
1630
|
+
return false;
|
|
1631
|
+
}
|
|
1632
|
+
function isConstantNode(node, bindings) {
|
|
1633
|
+
if (isStaticNode(node)) return true;
|
|
1634
|
+
node = unwrapTSNode(node);
|
|
1635
|
+
switch (node.type) {
|
|
1636
|
+
case "Identifier":
|
|
1637
|
+
const type = bindings[node.name];
|
|
1638
|
+
return type === "literal-const";
|
|
1639
|
+
case "RegExpLiteral":
|
|
1640
|
+
return true;
|
|
1641
|
+
case "ObjectExpression":
|
|
1642
|
+
return node.properties.every((prop) => {
|
|
1643
|
+
if (prop.type === "ObjectMethod") return false;
|
|
1644
|
+
if (prop.type === "SpreadElement")
|
|
1645
|
+
return isConstantNode(prop.argument, bindings);
|
|
1646
|
+
return (!prop.computed || isConstantNode(prop.key, bindings)) && isConstantNode(prop.value, bindings);
|
|
1647
|
+
});
|
|
1648
|
+
case "ArrayExpression":
|
|
1649
|
+
return node.elements.every((element) => {
|
|
1650
|
+
if (element === null) return true;
|
|
1651
|
+
if (element.type === "SpreadElement")
|
|
1652
|
+
return isConstantNode(element.argument, bindings);
|
|
1653
|
+
return isConstantNode(element, bindings);
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
return false;
|
|
1657
|
+
}
|
|
1605
1658
|
|
|
1606
1659
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
1607
1660
|
function isCoreComponent(tag) {
|
|
@@ -2954,6 +3007,10 @@ function getNodeProps(node) {
|
|
|
2954
3007
|
}
|
|
2955
3008
|
}
|
|
2956
3009
|
|
|
3010
|
+
function getSelfName(filename) {
|
|
3011
|
+
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
3012
|
+
return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
|
|
3013
|
+
}
|
|
2957
3014
|
function createTransformContext(root, {
|
|
2958
3015
|
filename = "",
|
|
2959
3016
|
prefixIdentifiers = false,
|
|
@@ -2978,11 +3035,10 @@ function createTransformContext(root, {
|
|
|
2978
3035
|
onWarn = defaultOnWarn,
|
|
2979
3036
|
compatConfig
|
|
2980
3037
|
}) {
|
|
2981
|
-
const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
|
|
2982
3038
|
const context = {
|
|
2983
3039
|
// options
|
|
2984
3040
|
filename,
|
|
2985
|
-
selfName:
|
|
3041
|
+
selfName: getSelfName(filename),
|
|
2986
3042
|
prefixIdentifiers,
|
|
2987
3043
|
hoistStatic,
|
|
2988
3044
|
hmr,
|
|
@@ -3253,6 +3309,16 @@ function createStructuralDirectiveTransform(name, fn) {
|
|
|
3253
3309
|
|
|
3254
3310
|
const PURE_ANNOTATION = `/*@__PURE__*/`;
|
|
3255
3311
|
const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
3312
|
+
const NewlineType = {
|
|
3313
|
+
"Start": 0,
|
|
3314
|
+
"0": "Start",
|
|
3315
|
+
"End": -1,
|
|
3316
|
+
"-1": "End",
|
|
3317
|
+
"None": -2,
|
|
3318
|
+
"-2": "None",
|
|
3319
|
+
"Unknown": -3,
|
|
3320
|
+
"-3": "Unknown"
|
|
3321
|
+
};
|
|
3256
3322
|
function createCodegenContext(ast, {
|
|
3257
3323
|
mode = "function",
|
|
3258
3324
|
prefixIdentifiers = mode === "module",
|
|
@@ -3291,7 +3357,7 @@ function createCodegenContext(ast, {
|
|
|
3291
3357
|
helper(key) {
|
|
3292
3358
|
return `_${helperNameMap[key]}`;
|
|
3293
3359
|
},
|
|
3294
|
-
push(code, newlineIndex = -2
|
|
3360
|
+
push(code, newlineIndex = -2, node) {
|
|
3295
3361
|
context.code += code;
|
|
3296
3362
|
},
|
|
3297
3363
|
indent() {
|
|
@@ -3309,7 +3375,7 @@ function createCodegenContext(ast, {
|
|
|
3309
3375
|
}
|
|
3310
3376
|
};
|
|
3311
3377
|
function newline(n) {
|
|
3312
|
-
context.push("\n" + ` `.repeat(n), 0
|
|
3378
|
+
context.push("\n" + ` `.repeat(n), 0);
|
|
3313
3379
|
}
|
|
3314
3380
|
return context;
|
|
3315
3381
|
}
|
|
@@ -3347,7 +3413,7 @@ function generate(ast, options = {}) {
|
|
|
3347
3413
|
push(
|
|
3348
3414
|
`const { ${helpers.map(aliasHelper).join(", ")} } = _Vue
|
|
3349
3415
|
`,
|
|
3350
|
-
-1
|
|
3416
|
+
-1
|
|
3351
3417
|
);
|
|
3352
3418
|
newline();
|
|
3353
3419
|
}
|
|
@@ -3377,7 +3443,7 @@ function generate(ast, options = {}) {
|
|
|
3377
3443
|
}
|
|
3378
3444
|
if (ast.components.length || ast.directives.length || ast.temps) {
|
|
3379
3445
|
push(`
|
|
3380
|
-
`, 0
|
|
3446
|
+
`, 0);
|
|
3381
3447
|
newline();
|
|
3382
3448
|
}
|
|
3383
3449
|
if (!ssr) {
|
|
@@ -3398,7 +3464,8 @@ function generate(ast, options = {}) {
|
|
|
3398
3464
|
ast,
|
|
3399
3465
|
code: context.code,
|
|
3400
3466
|
preamble: ``,
|
|
3401
|
-
map: context.map ? context.map.toJSON() : void 0
|
|
3467
|
+
map: context.map ? context.map.toJSON() : void 0,
|
|
3468
|
+
helpers: ast.helpers
|
|
3402
3469
|
};
|
|
3403
3470
|
}
|
|
3404
3471
|
function genFunctionPreamble(ast, context) {
|
|
@@ -3416,7 +3483,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
3416
3483
|
if (helpers.length > 0) {
|
|
3417
3484
|
{
|
|
3418
3485
|
push(`const _Vue = ${VueBinding}
|
|
3419
|
-
`, -1
|
|
3486
|
+
`, -1);
|
|
3420
3487
|
if (ast.hoists.length) {
|
|
3421
3488
|
const staticHelpers = [
|
|
3422
3489
|
CREATE_VNODE,
|
|
@@ -3426,7 +3493,7 @@ function genFunctionPreamble(ast, context) {
|
|
|
3426
3493
|
CREATE_STATIC
|
|
3427
3494
|
].filter((helper) => helpers.includes(helper)).map(aliasHelper).join(", ");
|
|
3428
3495
|
push(`const { ${staticHelpers} } = _Vue
|
|
3429
|
-
`, -1
|
|
3496
|
+
`, -1);
|
|
3430
3497
|
}
|
|
3431
3498
|
}
|
|
3432
3499
|
}
|
|
@@ -3485,7 +3552,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3485
3552
|
for (let i = 0; i < nodes.length; i++) {
|
|
3486
3553
|
const node = nodes[i];
|
|
3487
3554
|
if (isString(node)) {
|
|
3488
|
-
push(node, -3
|
|
3555
|
+
push(node, -3);
|
|
3489
3556
|
} else if (isArray(node)) {
|
|
3490
3557
|
genNodeListAsArray(node, context);
|
|
3491
3558
|
} else {
|
|
@@ -3503,7 +3570,7 @@ function genNodeList(nodes, context, multilines = false, comma = true) {
|
|
|
3503
3570
|
}
|
|
3504
3571
|
function genNode(node, context) {
|
|
3505
3572
|
if (isString(node)) {
|
|
3506
|
-
context.push(node, -3
|
|
3573
|
+
context.push(node, -3);
|
|
3507
3574
|
return;
|
|
3508
3575
|
}
|
|
3509
3576
|
if (isSymbol(node)) {
|
|
@@ -3585,13 +3652,13 @@ function genNode(node, context) {
|
|
|
3585
3652
|
}
|
|
3586
3653
|
}
|
|
3587
3654
|
function genText(node, context) {
|
|
3588
|
-
context.push(JSON.stringify(node.content), -3
|
|
3655
|
+
context.push(JSON.stringify(node.content), -3, node);
|
|
3589
3656
|
}
|
|
3590
3657
|
function genExpression(node, context) {
|
|
3591
3658
|
const { content, isStatic } = node;
|
|
3592
3659
|
context.push(
|
|
3593
3660
|
isStatic ? JSON.stringify(content) : content,
|
|
3594
|
-
-3
|
|
3661
|
+
-3,
|
|
3595
3662
|
node
|
|
3596
3663
|
);
|
|
3597
3664
|
}
|
|
@@ -3606,7 +3673,7 @@ function genCompoundExpression(node, context) {
|
|
|
3606
3673
|
for (let i = 0; i < node.children.length; i++) {
|
|
3607
3674
|
const child = node.children[i];
|
|
3608
3675
|
if (isString(child)) {
|
|
3609
|
-
context.push(child, -3
|
|
3676
|
+
context.push(child, -3);
|
|
3610
3677
|
} else {
|
|
3611
3678
|
genNode(child, context);
|
|
3612
3679
|
}
|
|
@@ -3620,9 +3687,9 @@ function genExpressionAsPropertyKey(node, context) {
|
|
|
3620
3687
|
push(`]`);
|
|
3621
3688
|
} else if (node.isStatic) {
|
|
3622
3689
|
const text = isSimpleIdentifier(node.content) ? node.content : JSON.stringify(node.content);
|
|
3623
|
-
push(text, -2
|
|
3690
|
+
push(text, -2, node);
|
|
3624
3691
|
} else {
|
|
3625
|
-
push(`[${node.content}]`, -3
|
|
3692
|
+
push(`[${node.content}]`, -3, node);
|
|
3626
3693
|
}
|
|
3627
3694
|
}
|
|
3628
3695
|
function genComment(node, context) {
|
|
@@ -3632,7 +3699,7 @@ function genComment(node, context) {
|
|
|
3632
3699
|
}
|
|
3633
3700
|
push(
|
|
3634
3701
|
`${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
|
|
3635
|
-
-3
|
|
3702
|
+
-3,
|
|
3636
3703
|
node
|
|
3637
3704
|
);
|
|
3638
3705
|
}
|
|
@@ -3672,7 +3739,7 @@ function genVNodeCall(node, context) {
|
|
|
3672
3739
|
push(PURE_ANNOTATION);
|
|
3673
3740
|
}
|
|
3674
3741
|
const callHelper = isBlock ? getVNodeBlockHelper(context.inSSR, isComponent) : getVNodeHelper(context.inSSR, isComponent);
|
|
3675
|
-
push(helper(callHelper) + `(`, -2
|
|
3742
|
+
push(helper(callHelper) + `(`, -2, node);
|
|
3676
3743
|
genNodeList(
|
|
3677
3744
|
genNullableArgs([tag, props, children, patchFlagString, dynamicProps]),
|
|
3678
3745
|
context
|
|
@@ -3700,7 +3767,7 @@ function genCallExpression(node, context) {
|
|
|
3700
3767
|
if (pure) {
|
|
3701
3768
|
push(PURE_ANNOTATION);
|
|
3702
3769
|
}
|
|
3703
|
-
push(callee + `(`, -2
|
|
3770
|
+
push(callee + `(`, -2, node);
|
|
3704
3771
|
genNodeList(node.arguments, context);
|
|
3705
3772
|
push(`)`);
|
|
3706
3773
|
}
|
|
@@ -3708,7 +3775,7 @@ function genObjectExpression(node, context) {
|
|
|
3708
3775
|
const { push, indent, deindent, newline } = context;
|
|
3709
3776
|
const { properties } = node;
|
|
3710
3777
|
if (!properties.length) {
|
|
3711
|
-
push(`{}`, -2
|
|
3778
|
+
push(`{}`, -2, node);
|
|
3712
3779
|
return;
|
|
3713
3780
|
}
|
|
3714
3781
|
const multilines = properties.length > 1 || !!(process.env.NODE_ENV !== "production") && properties.some((p) => p.value.type !== 4);
|
|
@@ -3736,7 +3803,7 @@ function genFunctionExpression(node, context) {
|
|
|
3736
3803
|
if (isSlot) {
|
|
3737
3804
|
push(`_${helperNameMap[WITH_CTX]}(`);
|
|
3738
3805
|
}
|
|
3739
|
-
push(`(`, -2
|
|
3806
|
+
push(`(`, -2, node);
|
|
3740
3807
|
if (isArray(params)) {
|
|
3741
3808
|
genNodeList(params, context);
|
|
3742
3809
|
} else if (params) {
|
|
@@ -3866,6 +3933,7 @@ function validateBrowserExpression(node, context, asParams = false, asRawStateme
|
|
|
3866
3933
|
}
|
|
3867
3934
|
}
|
|
3868
3935
|
|
|
3936
|
+
const isLiteralWhitelisted = /* @__PURE__ */ makeMap("true,false,null,this");
|
|
3869
3937
|
const transformExpression = (node, context) => {
|
|
3870
3938
|
if (node.type === 5) {
|
|
3871
3939
|
node.content = processExpression(
|
|
@@ -5799,4 +5867,4 @@ const BindingTypes = {
|
|
|
5799
5867
|
|
|
5800
5868
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
5801
5869
|
|
|
5802
|
-
export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
|
5870
|
+
export { BASE_TRANSITION, BindingTypes, CAMELIZE, CAPITALIZE, CREATE_BLOCK, CREATE_COMMENT, CREATE_ELEMENT_BLOCK, CREATE_ELEMENT_VNODE, CREATE_SLOTS, CREATE_STATIC, CREATE_TEXT, CREATE_VNODE, CompilerDeprecationTypes, ConstantTypes, ElementTypes, ErrorCodes, FRAGMENT, GUARD_REACTIVE_PROPS, IS_MEMO_SAME, IS_REF, KEEP_ALIVE, MERGE_PROPS, NORMALIZE_CLASS, NORMALIZE_PROPS, NORMALIZE_STYLE, Namespaces, NewlineType, NodeTypes, OPEN_BLOCK, POP_SCOPE_ID, PUSH_SCOPE_ID, RENDER_LIST, RENDER_SLOT, RESOLVE_COMPONENT, RESOLVE_DIRECTIVE, RESOLVE_DYNAMIC_COMPONENT, RESOLVE_FILTER, SET_BLOCK_TRACKING, SUSPENSE, TELEPORT, TO_DISPLAY_STRING, TO_HANDLERS, TO_HANDLER_KEY, TS_NODE_TYPES, UNREF, WITH_CTX, WITH_DIRECTIVES, WITH_MEMO, advancePositionWithClone, advancePositionWithMutation, assert, baseCompile, baseParse, buildDirectiveArgs, buildProps, buildSlots, checkCompatEnabled, convertToBlock, createArrayExpression, createAssignmentExpression, createBlockStatement, createCacheExpression, createCallExpression, createCompilerError, createCompoundExpression, createConditionalExpression, createForLoopParams, createFunctionExpression, createIfStatement, createInterpolation, createObjectExpression, createObjectProperty, createReturnStatement, createRoot, createSequenceExpression, createSimpleExpression, createStructuralDirectiveTransform, createTemplateLiteral, createTransformContext, createVNodeCall, defaultOnError, defaultOnWarn, errorMessages, extractIdentifiers, findDir, findProp, forAliasRE, generate, getBaseTransformPreset, getConstantType, getMemoedVNodeCall, getSelfName, getVNodeBlockHelper, getVNodeHelper, hasDynamicKeyVBind, hasScopeRef, helperNameMap, injectProp, isConstantNode, isCoreComponent, isFnExpression, isFnExpressionBrowser, isFnExpressionNode, isFunctionType, isInDestructureAssignment, isInNewExpression, isLiteralWhitelisted, isMemberExpression, isMemberExpressionBrowser, isMemberExpressionNode, isReferencedIdentifier, isSimpleIdentifier, isSlotOutlet, isStaticArgOf, isStaticExp, isStaticNode, isStaticProperty, isStaticPropertyKey, isTemplateNode, isText$1 as isText, isVSlot, locStub, noopDirectiveTransform, processExpression, processFor, processIf, processSlotOutlet, registerRuntimeHelpers, resolveComponentType, stringifyExpression, toValidAssetId, trackSlotScopes, trackVForSlotScopes, transform, transformBind, transformElement, transformExpression, transformModel, transformOn, traverseNode, unwrapTSNode, walkBlockDeclarations, walkFunctionParams, walkIdentifiers, warnDeprecation };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/compiler-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0-alpha.2",
|
|
4
4
|
"description": "@vue/compiler-core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "dist/compiler-core.esm-bundler.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"entities": "^4.5.0",
|
|
51
51
|
"estree-walker": "^2.0.2",
|
|
52
52
|
"source-map-js": "^1.2.1",
|
|
53
|
-
"@vue/shared": "3.
|
|
53
|
+
"@vue/shared": "3.6.0-alpha.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@babel/types": "^7.27.6"
|