@vue/compiler-core 3.3.0-alpha.1 → 3.3.0-alpha.11
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 +101 -83
- package/dist/compiler-core.cjs.prod.js +98 -80
- package/dist/compiler-core.d.ts +155 -151
- package/dist/compiler-core.esm-bundler.js +88 -75
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var shared = require('@vue/shared');
|
|
6
6
|
var parser = require('@babel/parser');
|
|
7
|
-
var
|
|
7
|
+
var sourceMapJs = require('source-map-js');
|
|
8
8
|
var estreeWalker = require('estree-walker');
|
|
9
9
|
|
|
10
10
|
function defaultOnError(error) {
|
|
@@ -341,6 +341,20 @@ function createReturnStatement(returns) {
|
|
|
341
341
|
loc: locStub
|
|
342
342
|
};
|
|
343
343
|
}
|
|
344
|
+
function getVNodeHelper(ssr, isComponent) {
|
|
345
|
+
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
346
|
+
}
|
|
347
|
+
function getVNodeBlockHelper(ssr, isComponent) {
|
|
348
|
+
return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
|
349
|
+
}
|
|
350
|
+
function convertToBlock(node, { helper, removeHelper, inSSR }) {
|
|
351
|
+
if (!node.isBlock) {
|
|
352
|
+
node.isBlock = true;
|
|
353
|
+
removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
|
354
|
+
helper(OPEN_BLOCK);
|
|
355
|
+
helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
344
358
|
|
|
345
359
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
346
360
|
const isBuiltInType = (tag, expected) => tag === expected || tag === shared.hyphenate(expected);
|
|
@@ -512,22 +526,16 @@ function hasDynamicKeyVBind(node) {
|
|
|
512
526
|
);
|
|
513
527
|
}
|
|
514
528
|
function isText$1(node) {
|
|
515
|
-
return node.type === 5 || node.type ===
|
|
529
|
+
return node.type === 5 || node.type === 2;
|
|
516
530
|
}
|
|
517
531
|
function isVSlot(p) {
|
|
518
532
|
return p.type === 7 && p.name === "slot";
|
|
519
533
|
}
|
|
520
534
|
function isTemplateNode(node) {
|
|
521
|
-
return node.type ===
|
|
535
|
+
return node.type === 1 && node.tagType === 3;
|
|
522
536
|
}
|
|
523
537
|
function isSlotOutlet(node) {
|
|
524
|
-
return node.type ===
|
|
525
|
-
}
|
|
526
|
-
function getVNodeHelper(ssr, isComponent) {
|
|
527
|
-
return ssr || isComponent ? CREATE_VNODE : CREATE_ELEMENT_VNODE;
|
|
528
|
-
}
|
|
529
|
-
function getVNodeBlockHelper(ssr, isComponent) {
|
|
530
|
-
return ssr || isComponent ? CREATE_BLOCK : CREATE_ELEMENT_BLOCK;
|
|
538
|
+
return node.type === 1 && node.tagType === 2;
|
|
531
539
|
}
|
|
532
540
|
const propsHelperSet = /* @__PURE__ */ new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS]);
|
|
533
541
|
function getUnnormalizedProps(props, callPath = []) {
|
|
@@ -620,7 +628,7 @@ function hasScopeRef(node, ids) {
|
|
|
620
628
|
return false;
|
|
621
629
|
}
|
|
622
630
|
switch (node.type) {
|
|
623
|
-
case
|
|
631
|
+
case 1:
|
|
624
632
|
for (let i = 0; i < node.props.length; i++) {
|
|
625
633
|
const p = node.props[i];
|
|
626
634
|
if (p.type === 7 && (hasScopeRef(p.arg, ids) || hasScopeRef(p.exp, ids))) {
|
|
@@ -647,8 +655,8 @@ function hasScopeRef(node, ids) {
|
|
|
647
655
|
case 5:
|
|
648
656
|
case 12:
|
|
649
657
|
return hasScopeRef(node.content, ids);
|
|
650
|
-
case
|
|
651
|
-
case
|
|
658
|
+
case 2:
|
|
659
|
+
case 3:
|
|
652
660
|
return false;
|
|
653
661
|
default:
|
|
654
662
|
return false;
|
|
@@ -661,14 +669,6 @@ function getMemoedVNodeCall(node) {
|
|
|
661
669
|
return node;
|
|
662
670
|
}
|
|
663
671
|
}
|
|
664
|
-
function makeBlock(node, { helper, removeHelper, inSSR }) {
|
|
665
|
-
if (!node.isBlock) {
|
|
666
|
-
node.isBlock = true;
|
|
667
|
-
removeHelper(getVNodeHelper(inSSR, node.isComponent));
|
|
668
|
-
helper(OPEN_BLOCK);
|
|
669
|
-
helper(getVNodeBlockHelper(inSSR, node.isComponent));
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
672
|
|
|
673
673
|
const deprecationData = {
|
|
674
674
|
["COMPILER_IS_ON_ELEMENT"]: {
|
|
@@ -871,12 +871,12 @@ function parseChildren(context, mode, ancestors) {
|
|
|
871
871
|
const shouldCondense = context.options.whitespace !== "preserve";
|
|
872
872
|
for (let i = 0; i < nodes.length; i++) {
|
|
873
873
|
const node = nodes[i];
|
|
874
|
-
if (node.type ===
|
|
874
|
+
if (node.type === 2) {
|
|
875
875
|
if (!context.inPre) {
|
|
876
876
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
|
877
877
|
const prev = nodes[i - 1];
|
|
878
878
|
const next = nodes[i + 1];
|
|
879
|
-
if (!prev || !next || shouldCondense && (prev.type ===
|
|
879
|
+
if (!prev || !next || shouldCondense && (prev.type === 3 && next.type === 3 || prev.type === 3 && next.type === 1 || prev.type === 1 && next.type === 3 || prev.type === 1 && next.type === 1 && /[\r\n]/.test(node.content))) {
|
|
880
880
|
removedWhitespace = true;
|
|
881
881
|
nodes[i] = null;
|
|
882
882
|
} else {
|
|
@@ -888,14 +888,14 @@ function parseChildren(context, mode, ancestors) {
|
|
|
888
888
|
} else {
|
|
889
889
|
node.content = node.content.replace(/\r\n/g, "\n");
|
|
890
890
|
}
|
|
891
|
-
} else if (node.type ===
|
|
891
|
+
} else if (node.type === 3 && !context.options.comments) {
|
|
892
892
|
removedWhitespace = true;
|
|
893
893
|
nodes[i] = null;
|
|
894
894
|
}
|
|
895
895
|
}
|
|
896
896
|
if (context.inPre && parent && context.options.isPreTag(parent.tag)) {
|
|
897
897
|
const first = nodes[0];
|
|
898
|
-
if (first && first.type ===
|
|
898
|
+
if (first && first.type === 2) {
|
|
899
899
|
first.content = first.content.replace(/^\r?\n/, "");
|
|
900
900
|
}
|
|
901
901
|
}
|
|
@@ -903,9 +903,9 @@ function parseChildren(context, mode, ancestors) {
|
|
|
903
903
|
return removedWhitespace ? nodes.filter(Boolean) : nodes;
|
|
904
904
|
}
|
|
905
905
|
function pushNode(nodes, node) {
|
|
906
|
-
if (node.type ===
|
|
906
|
+
if (node.type === 2) {
|
|
907
907
|
const prev = last(nodes);
|
|
908
|
-
if (prev && prev.type ===
|
|
908
|
+
if (prev && prev.type === 2 && prev.loc.end.offset === node.loc.start.offset) {
|
|
909
909
|
prev.content += node.content;
|
|
910
910
|
prev.loc.end = node.loc.end;
|
|
911
911
|
prev.loc.source += node.loc.source;
|
|
@@ -952,7 +952,7 @@ function parseComment(context) {
|
|
|
952
952
|
advanceBy(context, match.index + match[0].length - prevIndex + 1);
|
|
953
953
|
}
|
|
954
954
|
return {
|
|
955
|
-
type:
|
|
955
|
+
type: 3,
|
|
956
956
|
content,
|
|
957
957
|
loc: getSelection(context, start)
|
|
958
958
|
};
|
|
@@ -970,7 +970,7 @@ function parseBogusComment(context) {
|
|
|
970
970
|
advanceBy(context, closeIndex + 1);
|
|
971
971
|
}
|
|
972
972
|
return {
|
|
973
|
-
type:
|
|
973
|
+
type: 3,
|
|
974
974
|
content,
|
|
975
975
|
loc: getSelection(context, start)
|
|
976
976
|
};
|
|
@@ -1006,7 +1006,7 @@ function parseElement(context, ancestors) {
|
|
|
1006
1006
|
)) {
|
|
1007
1007
|
const loc = getSelection(context, element.loc.end);
|
|
1008
1008
|
inlineTemplateProp.value = {
|
|
1009
|
-
type:
|
|
1009
|
+
type: 2,
|
|
1010
1010
|
content: loc.source,
|
|
1011
1011
|
loc
|
|
1012
1012
|
};
|
|
@@ -1088,7 +1088,7 @@ function parseTag(context, type, parent) {
|
|
|
1088
1088
|
}
|
|
1089
1089
|
}
|
|
1090
1090
|
return {
|
|
1091
|
-
type:
|
|
1091
|
+
type: 1,
|
|
1092
1092
|
ns,
|
|
1093
1093
|
tag,
|
|
1094
1094
|
tagType,
|
|
@@ -1287,7 +1287,7 @@ function parseAttribute(context, nameSet) {
|
|
|
1287
1287
|
type: 6,
|
|
1288
1288
|
name,
|
|
1289
1289
|
value: value && {
|
|
1290
|
-
type:
|
|
1290
|
+
type: 2,
|
|
1291
1291
|
content: value.content,
|
|
1292
1292
|
loc: value.loc
|
|
1293
1293
|
},
|
|
@@ -1377,7 +1377,7 @@ function parseText(context, mode) {
|
|
|
1377
1377
|
const start = getCursor(context);
|
|
1378
1378
|
const content = parseTextData(context, endIndex, mode);
|
|
1379
1379
|
return {
|
|
1380
|
-
type:
|
|
1380
|
+
type: 2,
|
|
1381
1381
|
content,
|
|
1382
1382
|
loc: getSelection(context, start)
|
|
1383
1383
|
};
|
|
@@ -1486,7 +1486,7 @@ function hoistStatic(root, context) {
|
|
|
1486
1486
|
}
|
|
1487
1487
|
function isSingleElementRoot(root, child) {
|
|
1488
1488
|
const { children } = root;
|
|
1489
|
-
return children.length === 1 && child.type ===
|
|
1489
|
+
return children.length === 1 && child.type === 1 && !isSlotOutlet(child);
|
|
1490
1490
|
}
|
|
1491
1491
|
function walk(node, context, doNotHoistNode = false) {
|
|
1492
1492
|
const { children } = node;
|
|
@@ -1494,7 +1494,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1494
1494
|
let hoistedCount = 0;
|
|
1495
1495
|
for (let i = 0; i < children.length; i++) {
|
|
1496
1496
|
const child = children[i];
|
|
1497
|
-
if (child.type ===
|
|
1497
|
+
if (child.type === 1 && child.tagType === 0) {
|
|
1498
1498
|
const constantType = doNotHoistNode ? 0 : getConstantType(child, context);
|
|
1499
1499
|
if (constantType > 0) {
|
|
1500
1500
|
if (constantType >= 2) {
|
|
@@ -1519,7 +1519,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
}
|
|
1521
1521
|
}
|
|
1522
|
-
if (child.type ===
|
|
1522
|
+
if (child.type === 1) {
|
|
1523
1523
|
const isComponent = child.tagType === 1;
|
|
1524
1524
|
if (isComponent) {
|
|
1525
1525
|
context.scopes.vSlot++;
|
|
@@ -1543,7 +1543,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1543
1543
|
if (hoistedCount && context.transformHoist) {
|
|
1544
1544
|
context.transformHoist(children, context, node);
|
|
1545
1545
|
}
|
|
1546
|
-
if (hoistedCount && hoistedCount === originalCount && node.type ===
|
|
1546
|
+
if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && shared.isArray(node.codegenNode.children)) {
|
|
1547
1547
|
node.codegenNode.children = context.hoist(
|
|
1548
1548
|
createArrayExpression(node.codegenNode.children)
|
|
1549
1549
|
);
|
|
@@ -1552,7 +1552,7 @@ function walk(node, context, doNotHoistNode = false) {
|
|
|
1552
1552
|
function getConstantType(node, context) {
|
|
1553
1553
|
const { constantCache } = context;
|
|
1554
1554
|
switch (node.type) {
|
|
1555
|
-
case
|
|
1555
|
+
case 1:
|
|
1556
1556
|
if (node.tagType !== 0) {
|
|
1557
1557
|
return 0;
|
|
1558
1558
|
}
|
|
@@ -1624,8 +1624,8 @@ function getConstantType(node, context) {
|
|
|
1624
1624
|
constantCache.set(node, 0);
|
|
1625
1625
|
return 0;
|
|
1626
1626
|
}
|
|
1627
|
-
case
|
|
1628
|
-
case
|
|
1627
|
+
case 2:
|
|
1628
|
+
case 3:
|
|
1629
1629
|
return 3;
|
|
1630
1630
|
case 9:
|
|
1631
1631
|
case 11:
|
|
@@ -1904,7 +1904,7 @@ function createRootCodegen(root, context) {
|
|
|
1904
1904
|
if (isSingleElementRoot(root, child) && child.codegenNode) {
|
|
1905
1905
|
const codegenNode = child.codegenNode;
|
|
1906
1906
|
if (codegenNode.type === 13) {
|
|
1907
|
-
|
|
1907
|
+
convertToBlock(codegenNode, context);
|
|
1908
1908
|
}
|
|
1909
1909
|
root.codegenNode = codegenNode;
|
|
1910
1910
|
} else {
|
|
@@ -1963,7 +1963,7 @@ function traverseNode(node, context) {
|
|
|
1963
1963
|
}
|
|
1964
1964
|
}
|
|
1965
1965
|
switch (node.type) {
|
|
1966
|
-
case
|
|
1966
|
+
case 3:
|
|
1967
1967
|
if (!context.ssr) {
|
|
1968
1968
|
context.helper(CREATE_COMMENT);
|
|
1969
1969
|
}
|
|
@@ -1980,7 +1980,7 @@ function traverseNode(node, context) {
|
|
|
1980
1980
|
break;
|
|
1981
1981
|
case 10:
|
|
1982
1982
|
case 11:
|
|
1983
|
-
case
|
|
1983
|
+
case 1:
|
|
1984
1984
|
case 0:
|
|
1985
1985
|
traverseChildren(node, context);
|
|
1986
1986
|
break;
|
|
@@ -1994,7 +1994,7 @@ function traverseNode(node, context) {
|
|
|
1994
1994
|
function createStructuralDirectiveTransform(name, fn) {
|
|
1995
1995
|
const matches = shared.isString(name) ? (n) => n === name : (n) => name.test(n);
|
|
1996
1996
|
return (node, context) => {
|
|
1997
|
-
if (node.type ===
|
|
1997
|
+
if (node.type === 1) {
|
|
1998
1998
|
const { props } = node;
|
|
1999
1999
|
if (node.tagType === 3 && props.some(isVSlot)) {
|
|
2000
2000
|
return;
|
|
@@ -2020,7 +2020,7 @@ const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
|
|
|
2020
2020
|
function createCodegenContext(ast, {
|
|
2021
2021
|
mode = "function",
|
|
2022
2022
|
prefixIdentifiers = mode === "module",
|
|
2023
|
-
sourceMap
|
|
2023
|
+
sourceMap = false,
|
|
2024
2024
|
filename = `template.vue.html`,
|
|
2025
2025
|
scopeId = null,
|
|
2026
2026
|
optimizeImports = false,
|
|
@@ -2034,7 +2034,7 @@ function createCodegenContext(ast, {
|
|
|
2034
2034
|
const context = {
|
|
2035
2035
|
mode,
|
|
2036
2036
|
prefixIdentifiers,
|
|
2037
|
-
sourceMap
|
|
2037
|
+
sourceMap,
|
|
2038
2038
|
filename,
|
|
2039
2039
|
scopeId,
|
|
2040
2040
|
optimizeImports,
|
|
@@ -2106,8 +2106,8 @@ function createCodegenContext(ast, {
|
|
|
2106
2106
|
}
|
|
2107
2107
|
});
|
|
2108
2108
|
}
|
|
2109
|
-
if (sourceMap
|
|
2110
|
-
context.map = new
|
|
2109
|
+
if (sourceMap) {
|
|
2110
|
+
context.map = new sourceMapJs.SourceMapGenerator();
|
|
2111
2111
|
context.map.setSourceContent(filename, context.source);
|
|
2112
2112
|
}
|
|
2113
2113
|
return context;
|
|
@@ -2361,7 +2361,7 @@ function genImports(importsOptions, context) {
|
|
|
2361
2361
|
});
|
|
2362
2362
|
}
|
|
2363
2363
|
function isText(n) {
|
|
2364
|
-
return shared.isString(n) || n.type === 4 || n.type ===
|
|
2364
|
+
return shared.isString(n) || n.type === 4 || n.type === 2 || n.type === 5 || n.type === 8;
|
|
2365
2365
|
}
|
|
2366
2366
|
function genNodeListAsArray(nodes, context) {
|
|
2367
2367
|
const multilines = nodes.length > 3 || nodes.some((n) => shared.isArray(n) || !isText(n));
|
|
@@ -2402,12 +2402,12 @@ function genNode(node, context) {
|
|
|
2402
2402
|
return;
|
|
2403
2403
|
}
|
|
2404
2404
|
switch (node.type) {
|
|
2405
|
-
case
|
|
2405
|
+
case 1:
|
|
2406
2406
|
case 9:
|
|
2407
2407
|
case 11:
|
|
2408
2408
|
genNode(node.codegenNode, context);
|
|
2409
2409
|
break;
|
|
2410
|
-
case
|
|
2410
|
+
case 2:
|
|
2411
2411
|
genText(node, context);
|
|
2412
2412
|
break;
|
|
2413
2413
|
case 4:
|
|
@@ -2422,7 +2422,7 @@ function genNode(node, context) {
|
|
|
2422
2422
|
case 8:
|
|
2423
2423
|
genCompoundExpression(node, context);
|
|
2424
2424
|
break;
|
|
2425
|
-
case
|
|
2425
|
+
case 3:
|
|
2426
2426
|
genComment(node, context);
|
|
2427
2427
|
break;
|
|
2428
2428
|
case 13:
|
|
@@ -2756,7 +2756,7 @@ function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [
|
|
|
2756
2756
|
estreeWalker.walk(root, {
|
|
2757
2757
|
enter(node, parent) {
|
|
2758
2758
|
parent && parentStack.push(parent);
|
|
2759
|
-
if (parent && parent.type.startsWith("TS") &&
|
|
2759
|
+
if (parent && parent.type.startsWith("TS") && !TS_NODE_TYPES.includes(parent.type)) {
|
|
2760
2760
|
return this.skip();
|
|
2761
2761
|
}
|
|
2762
2762
|
if (node.type === "Identifier") {
|
|
@@ -2987,6 +2987,18 @@ function isReferenced(node, parent, grandparent) {
|
|
|
2987
2987
|
}
|
|
2988
2988
|
return true;
|
|
2989
2989
|
}
|
|
2990
|
+
const TS_NODE_TYPES = [
|
|
2991
|
+
"TSAsExpression",
|
|
2992
|
+
// foo as number
|
|
2993
|
+
"TSTypeAssertion",
|
|
2994
|
+
// (<number>foo)
|
|
2995
|
+
"TSNonNullExpression",
|
|
2996
|
+
// foo!
|
|
2997
|
+
"TSInstantiationExpression",
|
|
2998
|
+
// foo<string>
|
|
2999
|
+
"TSSatisfiesExpression"
|
|
3000
|
+
// foo satisfies T
|
|
3001
|
+
];
|
|
2990
3002
|
|
|
2991
3003
|
const isLiteralWhitelisted = /* @__PURE__ */ shared.makeMap("true,false,null,this");
|
|
2992
3004
|
const transformExpression = (node, context) => {
|
|
@@ -2995,7 +3007,7 @@ const transformExpression = (node, context) => {
|
|
|
2995
3007
|
node.content,
|
|
2996
3008
|
context
|
|
2997
3009
|
);
|
|
2998
|
-
} else if (node.type ===
|
|
3010
|
+
} else if (node.type === 1) {
|
|
2999
3011
|
for (let i = 0; i < node.props.length; i++) {
|
|
3000
3012
|
const dir = node.props[i];
|
|
3001
3013
|
if (dir.type === 7 && dir.name !== "for") {
|
|
@@ -3027,7 +3039,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3027
3039
|
const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
|
|
3028
3040
|
const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
|
|
3029
3041
|
const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
|
|
3030
|
-
if (type
|
|
3042
|
+
if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
|
|
3031
3043
|
return raw;
|
|
3032
3044
|
} else if (type === "setup-ref") {
|
|
3033
3045
|
return `${raw}.value`;
|
|
@@ -3071,6 +3083,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3071
3083
|
return `$setup.${raw}`;
|
|
3072
3084
|
} else if (type === "props-aliased") {
|
|
3073
3085
|
return `$props['${bindingMetadata.__propsAliases[raw]}']`;
|
|
3086
|
+
} else if (type === "literal-const") {
|
|
3087
|
+
return raw;
|
|
3074
3088
|
} else if (type) {
|
|
3075
3089
|
return `$${type}.${raw}`;
|
|
3076
3090
|
}
|
|
@@ -3084,7 +3098,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3084
3098
|
const isAllowedGlobal = shared.isGloballyWhitelisted(rawExp);
|
|
3085
3099
|
const isLiteral = isLiteralWhitelisted(rawExp);
|
|
3086
3100
|
if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
|
|
3087
|
-
if (bindingMetadata[node.content]
|
|
3101
|
+
if (isConst(bindingMetadata[node.content])) {
|
|
3088
3102
|
node.constType = 1;
|
|
3089
3103
|
}
|
|
3090
3104
|
node.content = rewriteIdentifier(rawExp);
|
|
@@ -3200,6 +3214,9 @@ function stringifyExpression(exp) {
|
|
|
3200
3214
|
return exp.children.map(stringifyExpression).join("");
|
|
3201
3215
|
}
|
|
3202
3216
|
}
|
|
3217
|
+
function isConst(type) {
|
|
3218
|
+
return type === "setup-const" || type === "literal-const";
|
|
3219
|
+
}
|
|
3203
3220
|
|
|
3204
3221
|
const transformIf = createStructuralDirectiveTransform(
|
|
3205
3222
|
/^(if|else|else-if)$/,
|
|
@@ -3260,11 +3277,11 @@ function processIf(node, dir, context, processCodegen) {
|
|
|
3260
3277
|
let i = siblings.indexOf(node);
|
|
3261
3278
|
while (i-- >= -1) {
|
|
3262
3279
|
const sibling = siblings[i];
|
|
3263
|
-
if (sibling && sibling.type ===
|
|
3280
|
+
if (sibling && sibling.type === 3) {
|
|
3264
3281
|
context.removeNode(sibling);
|
|
3265
3282
|
continue;
|
|
3266
3283
|
}
|
|
3267
|
-
if (sibling && sibling.type ===
|
|
3284
|
+
if (sibling && sibling.type === 2 && !sibling.content.trim().length) {
|
|
3268
3285
|
context.removeNode(sibling);
|
|
3269
3286
|
continue;
|
|
3270
3287
|
}
|
|
@@ -3346,7 +3363,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3346
3363
|
);
|
|
3347
3364
|
const { children } = branch;
|
|
3348
3365
|
const firstChild = children[0];
|
|
3349
|
-
const needFragmentWrapper = children.length !== 1 || firstChild.type !==
|
|
3366
|
+
const needFragmentWrapper = children.length !== 1 || firstChild.type !== 1;
|
|
3350
3367
|
if (needFragmentWrapper) {
|
|
3351
3368
|
if (children.length === 1 && firstChild.type === 11) {
|
|
3352
3369
|
const vnodeCall = firstChild.codegenNode;
|
|
@@ -3373,7 +3390,7 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
|
|
|
3373
3390
|
const ret = firstChild.codegenNode;
|
|
3374
3391
|
const vnodeCall = getMemoedVNodeCall(ret);
|
|
3375
3392
|
if (vnodeCall.type === 13) {
|
|
3376
|
-
|
|
3393
|
+
convertToBlock(vnodeCall, context);
|
|
3377
3394
|
}
|
|
3378
3395
|
injectProp(vnodeCall, keyProperty, context);
|
|
3379
3396
|
return ret;
|
|
@@ -3460,7 +3477,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3460
3477
|
const { children } = forNode;
|
|
3461
3478
|
if (isTemplate) {
|
|
3462
3479
|
node.children.some((c) => {
|
|
3463
|
-
if (c.type ===
|
|
3480
|
+
if (c.type === 1) {
|
|
3464
3481
|
const key = findProp(c, "key");
|
|
3465
3482
|
if (key) {
|
|
3466
3483
|
context.onError(
|
|
@@ -3474,7 +3491,7 @@ const transformFor = createStructuralDirectiveTransform(
|
|
|
3474
3491
|
}
|
|
3475
3492
|
});
|
|
3476
3493
|
}
|
|
3477
|
-
const needFragmentWrapper = children.length !== 1 || children[0].type !==
|
|
3494
|
+
const needFragmentWrapper = children.length !== 1 || children[0].type !== 1;
|
|
3478
3495
|
const slotOutlet = isSlotOutlet(node) ? node : isTemplate && node.children.length === 1 && isSlotOutlet(node.children[0]) ? node.children[0] : null;
|
|
3479
3496
|
if (slotOutlet) {
|
|
3480
3497
|
childBlock = slotOutlet.codegenNode;
|
|
@@ -3694,7 +3711,7 @@ function createParamsList(args) {
|
|
|
3694
3711
|
|
|
3695
3712
|
const defaultFallback = createSimpleExpression(`undefined`, false);
|
|
3696
3713
|
const trackSlotScopes = (node, context) => {
|
|
3697
|
-
if (node.type ===
|
|
3714
|
+
if (node.type === 1 && (node.tagType === 1 || node.tagType === 3)) {
|
|
3698
3715
|
const vSlot = findDir(node, "slot");
|
|
3699
3716
|
if (vSlot) {
|
|
3700
3717
|
const slotProps = vSlot.exp;
|
|
@@ -3770,7 +3787,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3770
3787
|
const slotElement = children[i];
|
|
3771
3788
|
let slotDir;
|
|
3772
3789
|
if (!isTemplateNode(slotElement) || !(slotDir = findDir(slotElement, "slot", true))) {
|
|
3773
|
-
if (slotElement.type !==
|
|
3790
|
+
if (slotElement.type !== 3) {
|
|
3774
3791
|
implicitDefaultChildren.push(slotElement);
|
|
3775
3792
|
}
|
|
3776
3793
|
continue;
|
|
@@ -3817,7 +3834,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
|
|
|
3817
3834
|
let prev;
|
|
3818
3835
|
while (j--) {
|
|
3819
3836
|
prev = children[j];
|
|
3820
|
-
if (prev.type !==
|
|
3837
|
+
if (prev.type !== 3) {
|
|
3821
3838
|
break;
|
|
3822
3839
|
}
|
|
3823
3840
|
}
|
|
@@ -3951,7 +3968,7 @@ function hasForwardedSlots(children) {
|
|
|
3951
3968
|
for (let i = 0; i < children.length; i++) {
|
|
3952
3969
|
const child = children[i];
|
|
3953
3970
|
switch (child.type) {
|
|
3954
|
-
case
|
|
3971
|
+
case 1:
|
|
3955
3972
|
if (child.tagType === 2 || hasForwardedSlots(child.children)) {
|
|
3956
3973
|
return true;
|
|
3957
3974
|
}
|
|
@@ -3970,16 +3987,16 @@ function hasForwardedSlots(children) {
|
|
|
3970
3987
|
return false;
|
|
3971
3988
|
}
|
|
3972
3989
|
function isNonWhitespaceContent(node) {
|
|
3973
|
-
if (node.type !==
|
|
3990
|
+
if (node.type !== 2 && node.type !== 12)
|
|
3974
3991
|
return true;
|
|
3975
|
-
return node.type ===
|
|
3992
|
+
return node.type === 2 ? !!node.content.trim() : isNonWhitespaceContent(node.content);
|
|
3976
3993
|
}
|
|
3977
3994
|
|
|
3978
3995
|
const directiveImportMap = /* @__PURE__ */ new WeakMap();
|
|
3979
3996
|
const transformElement = (node, context) => {
|
|
3980
3997
|
return function postTransformElement() {
|
|
3981
3998
|
node = context.currentNode;
|
|
3982
|
-
if (!(node.type ===
|
|
3999
|
+
if (!(node.type === 1 && (node.tagType === 0 || node.tagType === 1))) {
|
|
3983
4000
|
return;
|
|
3984
4001
|
}
|
|
3985
4002
|
const { tag, props } = node;
|
|
@@ -4041,7 +4058,7 @@ const transformElement = (node, context) => {
|
|
|
4041
4058
|
if (hasDynamicTextChild && getConstantType(child, context) === 0) {
|
|
4042
4059
|
patchFlag |= 1;
|
|
4043
4060
|
}
|
|
4044
|
-
if (hasDynamicTextChild || type ===
|
|
4061
|
+
if (hasDynamicTextChild || type === 2) {
|
|
4045
4062
|
vnodeChildren = child;
|
|
4046
4063
|
} else {
|
|
4047
4064
|
vnodeChildren = node.children;
|
|
@@ -4144,7 +4161,7 @@ function resolveSetupReference(name, context) {
|
|
|
4144
4161
|
return PascalName;
|
|
4145
4162
|
}
|
|
4146
4163
|
};
|
|
4147
|
-
const fromConst = checkType("setup-const") || checkType("setup-reactive-const");
|
|
4164
|
+
const fromConst = checkType("setup-const") || checkType("setup-reactive-const") || checkType("literal-const");
|
|
4148
4165
|
if (fromConst) {
|
|
4149
4166
|
return context.inline ? (
|
|
4150
4167
|
// in inline mode, const setup bindings (e.g. imports) can be used as-is
|
|
@@ -4787,7 +4804,7 @@ const injectPrefix = (arg, prefix) => {
|
|
|
4787
4804
|
};
|
|
4788
4805
|
|
|
4789
4806
|
const transformText = (node, context) => {
|
|
4790
|
-
if (node.type === 0 || node.type ===
|
|
4807
|
+
if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
|
|
4791
4808
|
return () => {
|
|
4792
4809
|
const children = node.children;
|
|
4793
4810
|
let currentContainer = void 0;
|
|
@@ -4819,7 +4836,7 @@ const transformText = (node, context) => {
|
|
|
4819
4836
|
// as-is since the runtime has dedicated fast path for this by directly
|
|
4820
4837
|
// setting textContent of the element.
|
|
4821
4838
|
// for component root it's always normalized anyway.
|
|
4822
|
-
children.length === 1 && (node.type === 0 || node.type ===
|
|
4839
|
+
children.length === 1 && (node.type === 0 || node.type === 1 && node.tagType === 0 && // #3756
|
|
4823
4840
|
// custom directives can potentially add DOM elements arbitrarily,
|
|
4824
4841
|
// we need to avoid setting textContent of the element at runtime
|
|
4825
4842
|
// to avoid accidentally overwriting the DOM elements added
|
|
@@ -4836,7 +4853,7 @@ const transformText = (node, context) => {
|
|
|
4836
4853
|
const child = children[i];
|
|
4837
4854
|
if (isText$1(child) || child.type === 8) {
|
|
4838
4855
|
const callArgs = [];
|
|
4839
|
-
if (child.type !==
|
|
4856
|
+
if (child.type !== 2 || child.content !== " ") {
|
|
4840
4857
|
callArgs.push(child);
|
|
4841
4858
|
}
|
|
4842
4859
|
if (!context.ssr && getConstantType(child, context) === 0) {
|
|
@@ -4861,8 +4878,8 @@ const transformText = (node, context) => {
|
|
|
4861
4878
|
|
|
4862
4879
|
const seen$1 = /* @__PURE__ */ new WeakSet();
|
|
4863
4880
|
const transformOnce = (node, context) => {
|
|
4864
|
-
if (node.type ===
|
|
4865
|
-
if (seen$1.has(node) || context.inVOnce) {
|
|
4881
|
+
if (node.type === 1 && findDir(node, "once", true)) {
|
|
4882
|
+
if (seen$1.has(node) || context.inVOnce || context.inSSR) {
|
|
4866
4883
|
return;
|
|
4867
4884
|
}
|
|
4868
4885
|
seen$1.add(node);
|
|
@@ -4974,7 +4991,7 @@ const transformFilter = (node, context) => {
|
|
|
4974
4991
|
if (node.type === 5) {
|
|
4975
4992
|
rewriteFilter(node.content, context);
|
|
4976
4993
|
}
|
|
4977
|
-
if (node.type ===
|
|
4994
|
+
if (node.type === 1) {
|
|
4978
4995
|
node.props.forEach((prop) => {
|
|
4979
4996
|
if (prop.type === 7 && prop.name !== "for" && prop.exp) {
|
|
4980
4997
|
rewriteFilter(prop.exp, context);
|
|
@@ -5110,7 +5127,7 @@ function wrapFilter(exp, filter, context) {
|
|
|
5110
5127
|
|
|
5111
5128
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
5112
5129
|
const transformMemo = (node, context) => {
|
|
5113
|
-
if (node.type ===
|
|
5130
|
+
if (node.type === 1) {
|
|
5114
5131
|
const dir = findDir(node, "memo");
|
|
5115
5132
|
if (!dir || seen.has(node)) {
|
|
5116
5133
|
return;
|
|
@@ -5120,7 +5137,7 @@ const transformMemo = (node, context) => {
|
|
|
5120
5137
|
const codegenNode = node.codegenNode || context.currentNode.codegenNode;
|
|
5121
5138
|
if (codegenNode && codegenNode.type === 13) {
|
|
5122
5139
|
if (node.tagType !== 1) {
|
|
5123
|
-
|
|
5140
|
+
convertToBlock(codegenNode, context);
|
|
5124
5141
|
}
|
|
5125
5142
|
node.codegenNode = createCallExpression(context.helper(WITH_MEMO), [
|
|
5126
5143
|
dir.exp,
|
|
@@ -5239,6 +5256,7 @@ exports.TELEPORT = TELEPORT;
|
|
|
5239
5256
|
exports.TO_DISPLAY_STRING = TO_DISPLAY_STRING;
|
|
5240
5257
|
exports.TO_HANDLERS = TO_HANDLERS;
|
|
5241
5258
|
exports.TO_HANDLER_KEY = TO_HANDLER_KEY;
|
|
5259
|
+
exports.TS_NODE_TYPES = TS_NODE_TYPES;
|
|
5242
5260
|
exports.UNREF = UNREF;
|
|
5243
5261
|
exports.WITH_CTX = WITH_CTX;
|
|
5244
5262
|
exports.WITH_DIRECTIVES = WITH_DIRECTIVES;
|
|
@@ -5252,6 +5270,7 @@ exports.buildDirectiveArgs = buildDirectiveArgs;
|
|
|
5252
5270
|
exports.buildProps = buildProps;
|
|
5253
5271
|
exports.buildSlots = buildSlots;
|
|
5254
5272
|
exports.checkCompatEnabled = checkCompatEnabled;
|
|
5273
|
+
exports.convertToBlock = convertToBlock;
|
|
5255
5274
|
exports.createArrayExpression = createArrayExpression;
|
|
5256
5275
|
exports.createAssignmentExpression = createAssignmentExpression;
|
|
5257
5276
|
exports.createBlockStatement = createBlockStatement;
|
|
@@ -5306,7 +5325,6 @@ exports.isTemplateNode = isTemplateNode;
|
|
|
5306
5325
|
exports.isText = isText$1;
|
|
5307
5326
|
exports.isVSlot = isVSlot;
|
|
5308
5327
|
exports.locStub = locStub;
|
|
5309
|
-
exports.makeBlock = makeBlock;
|
|
5310
5328
|
exports.noopDirectiveTransform = noopDirectiveTransform;
|
|
5311
5329
|
exports.processExpression = processExpression;
|
|
5312
5330
|
exports.processFor = processFor;
|