@vue/compiler-core 3.4.0-alpha.2 → 3.4.0-alpha.4
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 +336 -51
- package/dist/compiler-core.cjs.prod.js +335 -48
- package/dist/compiler-core.d.ts +40 -18
- package/dist/compiler-core.esm-bundler.js +270 -33
- package/package.json +4 -4
|
@@ -96,6 +96,90 @@ function registerRuntimeHelpers(helpers) {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
const Namespaces = {
|
|
100
|
+
"HTML": 0,
|
|
101
|
+
"0": "HTML",
|
|
102
|
+
"SVG": 1,
|
|
103
|
+
"1": "SVG",
|
|
104
|
+
"MATH_ML": 2,
|
|
105
|
+
"2": "MATH_ML"
|
|
106
|
+
};
|
|
107
|
+
const NodeTypes = {
|
|
108
|
+
"ROOT": 0,
|
|
109
|
+
"0": "ROOT",
|
|
110
|
+
"ELEMENT": 1,
|
|
111
|
+
"1": "ELEMENT",
|
|
112
|
+
"TEXT": 2,
|
|
113
|
+
"2": "TEXT",
|
|
114
|
+
"COMMENT": 3,
|
|
115
|
+
"3": "COMMENT",
|
|
116
|
+
"SIMPLE_EXPRESSION": 4,
|
|
117
|
+
"4": "SIMPLE_EXPRESSION",
|
|
118
|
+
"INTERPOLATION": 5,
|
|
119
|
+
"5": "INTERPOLATION",
|
|
120
|
+
"ATTRIBUTE": 6,
|
|
121
|
+
"6": "ATTRIBUTE",
|
|
122
|
+
"DIRECTIVE": 7,
|
|
123
|
+
"7": "DIRECTIVE",
|
|
124
|
+
"COMPOUND_EXPRESSION": 8,
|
|
125
|
+
"8": "COMPOUND_EXPRESSION",
|
|
126
|
+
"IF": 9,
|
|
127
|
+
"9": "IF",
|
|
128
|
+
"IF_BRANCH": 10,
|
|
129
|
+
"10": "IF_BRANCH",
|
|
130
|
+
"FOR": 11,
|
|
131
|
+
"11": "FOR",
|
|
132
|
+
"TEXT_CALL": 12,
|
|
133
|
+
"12": "TEXT_CALL",
|
|
134
|
+
"VNODE_CALL": 13,
|
|
135
|
+
"13": "VNODE_CALL",
|
|
136
|
+
"JS_CALL_EXPRESSION": 14,
|
|
137
|
+
"14": "JS_CALL_EXPRESSION",
|
|
138
|
+
"JS_OBJECT_EXPRESSION": 15,
|
|
139
|
+
"15": "JS_OBJECT_EXPRESSION",
|
|
140
|
+
"JS_PROPERTY": 16,
|
|
141
|
+
"16": "JS_PROPERTY",
|
|
142
|
+
"JS_ARRAY_EXPRESSION": 17,
|
|
143
|
+
"17": "JS_ARRAY_EXPRESSION",
|
|
144
|
+
"JS_FUNCTION_EXPRESSION": 18,
|
|
145
|
+
"18": "JS_FUNCTION_EXPRESSION",
|
|
146
|
+
"JS_CONDITIONAL_EXPRESSION": 19,
|
|
147
|
+
"19": "JS_CONDITIONAL_EXPRESSION",
|
|
148
|
+
"JS_CACHE_EXPRESSION": 20,
|
|
149
|
+
"20": "JS_CACHE_EXPRESSION",
|
|
150
|
+
"JS_BLOCK_STATEMENT": 21,
|
|
151
|
+
"21": "JS_BLOCK_STATEMENT",
|
|
152
|
+
"JS_TEMPLATE_LITERAL": 22,
|
|
153
|
+
"22": "JS_TEMPLATE_LITERAL",
|
|
154
|
+
"JS_IF_STATEMENT": 23,
|
|
155
|
+
"23": "JS_IF_STATEMENT",
|
|
156
|
+
"JS_ASSIGNMENT_EXPRESSION": 24,
|
|
157
|
+
"24": "JS_ASSIGNMENT_EXPRESSION",
|
|
158
|
+
"JS_SEQUENCE_EXPRESSION": 25,
|
|
159
|
+
"25": "JS_SEQUENCE_EXPRESSION",
|
|
160
|
+
"JS_RETURN_STATEMENT": 26,
|
|
161
|
+
"26": "JS_RETURN_STATEMENT"
|
|
162
|
+
};
|
|
163
|
+
const ElementTypes = {
|
|
164
|
+
"ELEMENT": 0,
|
|
165
|
+
"0": "ELEMENT",
|
|
166
|
+
"COMPONENT": 1,
|
|
167
|
+
"1": "COMPONENT",
|
|
168
|
+
"SLOT": 2,
|
|
169
|
+
"2": "SLOT",
|
|
170
|
+
"TEMPLATE": 3,
|
|
171
|
+
"3": "TEMPLATE"
|
|
172
|
+
};
|
|
173
|
+
const ConstantTypes = {
|
|
174
|
+
"NOT_CONSTANT": 0,
|
|
175
|
+
"0": "NOT_CONSTANT",
|
|
176
|
+
"CAN_SKIP_PATCH": 1,
|
|
177
|
+
"1": "CAN_SKIP_PATCH",
|
|
178
|
+
"CAN_HOIST": 2,
|
|
179
|
+
"2": "CAN_HOIST",
|
|
180
|
+
"CAN_STRINGIFY": 3,
|
|
181
|
+
"3": "CAN_STRINGIFY"
|
|
182
|
+
};
|
|
99
183
|
const locStub = {
|
|
100
184
|
start: { line: 1, column: 1, offset: 0 },
|
|
101
185
|
end: { line: 1, column: 1, offset: 0 },
|
|
@@ -350,7 +434,9 @@ class Tokenizer {
|
|
|
350
434
|
this.inRCDATA = false;
|
|
351
435
|
/** For disabling RCDATA tags handling */
|
|
352
436
|
this.inXML = false;
|
|
353
|
-
/**
|
|
437
|
+
/** For disabling interpolation parsing in v-pre */
|
|
438
|
+
this.inVPre = false;
|
|
439
|
+
/** Record newline positions for fast line / column calculation */
|
|
354
440
|
this.newlines = [];
|
|
355
441
|
this.mode = 0;
|
|
356
442
|
this.delimiterOpen = defaultDelimitersOpen;
|
|
@@ -375,6 +461,7 @@ class Tokenizer {
|
|
|
375
461
|
this.sectionStart = 0;
|
|
376
462
|
this.index = 0;
|
|
377
463
|
this.baseState = 1;
|
|
464
|
+
this.inRCDATA = false;
|
|
378
465
|
this.currentSequence = void 0;
|
|
379
466
|
this.newlines.length = 0;
|
|
380
467
|
this.delimiterOpen = defaultDelimitersOpen;
|
|
@@ -415,7 +502,7 @@ class Tokenizer {
|
|
|
415
502
|
this.sectionStart = this.index;
|
|
416
503
|
} else if (c === 38) {
|
|
417
504
|
this.startEntity();
|
|
418
|
-
} else if (c === this.delimiterOpen[0]) {
|
|
505
|
+
} else if (!this.inVPre && c === this.delimiterOpen[0]) {
|
|
419
506
|
this.state = 2;
|
|
420
507
|
this.delimiterIndex = 0;
|
|
421
508
|
this.stateInterpolationOpen(c);
|
|
@@ -1151,6 +1238,16 @@ class Tokenizer {
|
|
|
1151
1238
|
}
|
|
1152
1239
|
}
|
|
1153
1240
|
|
|
1241
|
+
const CompilerDeprecationTypes = {
|
|
1242
|
+
"COMPILER_IS_ON_ELEMENT": "COMPILER_IS_ON_ELEMENT",
|
|
1243
|
+
"COMPILER_V_BIND_SYNC": "COMPILER_V_BIND_SYNC",
|
|
1244
|
+
"COMPILER_V_BIND_OBJECT_ORDER": "COMPILER_V_BIND_OBJECT_ORDER",
|
|
1245
|
+
"COMPILER_V_ON_NATIVE": "COMPILER_V_ON_NATIVE",
|
|
1246
|
+
"COMPILER_V_IF_V_FOR_PRECEDENCE": "COMPILER_V_IF_V_FOR_PRECEDENCE",
|
|
1247
|
+
"COMPILER_NATIVE_TEMPLATE": "COMPILER_NATIVE_TEMPLATE",
|
|
1248
|
+
"COMPILER_INLINE_TEMPLATE": "COMPILER_INLINE_TEMPLATE",
|
|
1249
|
+
"COMPILER_FILTERS": "COMPILER_FILTER"
|
|
1250
|
+
};
|
|
1154
1251
|
const deprecationData = {
|
|
1155
1252
|
["COMPILER_IS_ON_ELEMENT"]: {
|
|
1156
1253
|
message: `Platform-native elements with "is" prop will no longer be treated as components in Vue 3 unless the "is" value is explicitly prefixed with "vue:".`,
|
|
@@ -1228,6 +1325,114 @@ function createCompilerError(code, loc, messages, additionalMessage) {
|
|
|
1228
1325
|
error.loc = loc;
|
|
1229
1326
|
return error;
|
|
1230
1327
|
}
|
|
1328
|
+
const ErrorCodes = {
|
|
1329
|
+
"ABRUPT_CLOSING_OF_EMPTY_COMMENT": 0,
|
|
1330
|
+
"0": "ABRUPT_CLOSING_OF_EMPTY_COMMENT",
|
|
1331
|
+
"CDATA_IN_HTML_CONTENT": 1,
|
|
1332
|
+
"1": "CDATA_IN_HTML_CONTENT",
|
|
1333
|
+
"DUPLICATE_ATTRIBUTE": 2,
|
|
1334
|
+
"2": "DUPLICATE_ATTRIBUTE",
|
|
1335
|
+
"END_TAG_WITH_ATTRIBUTES": 3,
|
|
1336
|
+
"3": "END_TAG_WITH_ATTRIBUTES",
|
|
1337
|
+
"END_TAG_WITH_TRAILING_SOLIDUS": 4,
|
|
1338
|
+
"4": "END_TAG_WITH_TRAILING_SOLIDUS",
|
|
1339
|
+
"EOF_BEFORE_TAG_NAME": 5,
|
|
1340
|
+
"5": "EOF_BEFORE_TAG_NAME",
|
|
1341
|
+
"EOF_IN_CDATA": 6,
|
|
1342
|
+
"6": "EOF_IN_CDATA",
|
|
1343
|
+
"EOF_IN_COMMENT": 7,
|
|
1344
|
+
"7": "EOF_IN_COMMENT",
|
|
1345
|
+
"EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT": 8,
|
|
1346
|
+
"8": "EOF_IN_SCRIPT_HTML_COMMENT_LIKE_TEXT",
|
|
1347
|
+
"EOF_IN_TAG": 9,
|
|
1348
|
+
"9": "EOF_IN_TAG",
|
|
1349
|
+
"INCORRECTLY_CLOSED_COMMENT": 10,
|
|
1350
|
+
"10": "INCORRECTLY_CLOSED_COMMENT",
|
|
1351
|
+
"INCORRECTLY_OPENED_COMMENT": 11,
|
|
1352
|
+
"11": "INCORRECTLY_OPENED_COMMENT",
|
|
1353
|
+
"INVALID_FIRST_CHARACTER_OF_TAG_NAME": 12,
|
|
1354
|
+
"12": "INVALID_FIRST_CHARACTER_OF_TAG_NAME",
|
|
1355
|
+
"MISSING_ATTRIBUTE_VALUE": 13,
|
|
1356
|
+
"13": "MISSING_ATTRIBUTE_VALUE",
|
|
1357
|
+
"MISSING_END_TAG_NAME": 14,
|
|
1358
|
+
"14": "MISSING_END_TAG_NAME",
|
|
1359
|
+
"MISSING_WHITESPACE_BETWEEN_ATTRIBUTES": 15,
|
|
1360
|
+
"15": "MISSING_WHITESPACE_BETWEEN_ATTRIBUTES",
|
|
1361
|
+
"NESTED_COMMENT": 16,
|
|
1362
|
+
"16": "NESTED_COMMENT",
|
|
1363
|
+
"UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME": 17,
|
|
1364
|
+
"17": "UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME",
|
|
1365
|
+
"UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE": 18,
|
|
1366
|
+
"18": "UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE",
|
|
1367
|
+
"UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME": 19,
|
|
1368
|
+
"19": "UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME",
|
|
1369
|
+
"UNEXPECTED_NULL_CHARACTER": 20,
|
|
1370
|
+
"20": "UNEXPECTED_NULL_CHARACTER",
|
|
1371
|
+
"UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME": 21,
|
|
1372
|
+
"21": "UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME",
|
|
1373
|
+
"UNEXPECTED_SOLIDUS_IN_TAG": 22,
|
|
1374
|
+
"22": "UNEXPECTED_SOLIDUS_IN_TAG",
|
|
1375
|
+
"X_INVALID_END_TAG": 23,
|
|
1376
|
+
"23": "X_INVALID_END_TAG",
|
|
1377
|
+
"X_MISSING_END_TAG": 24,
|
|
1378
|
+
"24": "X_MISSING_END_TAG",
|
|
1379
|
+
"X_MISSING_INTERPOLATION_END": 25,
|
|
1380
|
+
"25": "X_MISSING_INTERPOLATION_END",
|
|
1381
|
+
"X_MISSING_DIRECTIVE_NAME": 26,
|
|
1382
|
+
"26": "X_MISSING_DIRECTIVE_NAME",
|
|
1383
|
+
"X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END": 27,
|
|
1384
|
+
"27": "X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END",
|
|
1385
|
+
"X_V_IF_NO_EXPRESSION": 28,
|
|
1386
|
+
"28": "X_V_IF_NO_EXPRESSION",
|
|
1387
|
+
"X_V_IF_SAME_KEY": 29,
|
|
1388
|
+
"29": "X_V_IF_SAME_KEY",
|
|
1389
|
+
"X_V_ELSE_NO_ADJACENT_IF": 30,
|
|
1390
|
+
"30": "X_V_ELSE_NO_ADJACENT_IF",
|
|
1391
|
+
"X_V_FOR_NO_EXPRESSION": 31,
|
|
1392
|
+
"31": "X_V_FOR_NO_EXPRESSION",
|
|
1393
|
+
"X_V_FOR_MALFORMED_EXPRESSION": 32,
|
|
1394
|
+
"32": "X_V_FOR_MALFORMED_EXPRESSION",
|
|
1395
|
+
"X_V_FOR_TEMPLATE_KEY_PLACEMENT": 33,
|
|
1396
|
+
"33": "X_V_FOR_TEMPLATE_KEY_PLACEMENT",
|
|
1397
|
+
"X_V_BIND_NO_EXPRESSION": 34,
|
|
1398
|
+
"34": "X_V_BIND_NO_EXPRESSION",
|
|
1399
|
+
"X_V_ON_NO_EXPRESSION": 35,
|
|
1400
|
+
"35": "X_V_ON_NO_EXPRESSION",
|
|
1401
|
+
"X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET": 36,
|
|
1402
|
+
"36": "X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET",
|
|
1403
|
+
"X_V_SLOT_MIXED_SLOT_USAGE": 37,
|
|
1404
|
+
"37": "X_V_SLOT_MIXED_SLOT_USAGE",
|
|
1405
|
+
"X_V_SLOT_DUPLICATE_SLOT_NAMES": 38,
|
|
1406
|
+
"38": "X_V_SLOT_DUPLICATE_SLOT_NAMES",
|
|
1407
|
+
"X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN": 39,
|
|
1408
|
+
"39": "X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN",
|
|
1409
|
+
"X_V_SLOT_MISPLACED": 40,
|
|
1410
|
+
"40": "X_V_SLOT_MISPLACED",
|
|
1411
|
+
"X_V_MODEL_NO_EXPRESSION": 41,
|
|
1412
|
+
"41": "X_V_MODEL_NO_EXPRESSION",
|
|
1413
|
+
"X_V_MODEL_MALFORMED_EXPRESSION": 42,
|
|
1414
|
+
"42": "X_V_MODEL_MALFORMED_EXPRESSION",
|
|
1415
|
+
"X_V_MODEL_ON_SCOPE_VARIABLE": 43,
|
|
1416
|
+
"43": "X_V_MODEL_ON_SCOPE_VARIABLE",
|
|
1417
|
+
"X_V_MODEL_ON_PROPS": 44,
|
|
1418
|
+
"44": "X_V_MODEL_ON_PROPS",
|
|
1419
|
+
"X_INVALID_EXPRESSION": 45,
|
|
1420
|
+
"45": "X_INVALID_EXPRESSION",
|
|
1421
|
+
"X_KEEP_ALIVE_INVALID_CHILDREN": 46,
|
|
1422
|
+
"46": "X_KEEP_ALIVE_INVALID_CHILDREN",
|
|
1423
|
+
"X_VNODE_HOOKS": 47,
|
|
1424
|
+
"47": "X_VNODE_HOOKS",
|
|
1425
|
+
"X_PREFIX_ID_NOT_SUPPORTED": 48,
|
|
1426
|
+
"48": "X_PREFIX_ID_NOT_SUPPORTED",
|
|
1427
|
+
"X_MODULE_MODE_NOT_SUPPORTED": 49,
|
|
1428
|
+
"49": "X_MODULE_MODE_NOT_SUPPORTED",
|
|
1429
|
+
"X_CACHE_HANDLER_NOT_SUPPORTED": 50,
|
|
1430
|
+
"50": "X_CACHE_HANDLER_NOT_SUPPORTED",
|
|
1431
|
+
"X_SCOPE_ID_NOT_SUPPORTED": 51,
|
|
1432
|
+
"51": "X_SCOPE_ID_NOT_SUPPORTED",
|
|
1433
|
+
"__EXTEND_POINT__": 52,
|
|
1434
|
+
"52": "__EXTEND_POINT__"
|
|
1435
|
+
};
|
|
1231
1436
|
const errorMessages = {
|
|
1232
1437
|
// parse errors
|
|
1233
1438
|
[0]: "Illegal comment.",
|
|
@@ -1280,16 +1485,14 @@ const errorMessages = {
|
|
|
1280
1485
|
Use a v-bind binding combined with a v-on listener that emits update:x event instead.`,
|
|
1281
1486
|
[45]: `Error parsing JavaScript expression: `,
|
|
1282
1487
|
[46]: `<KeepAlive> expects exactly one child component.`,
|
|
1488
|
+
[47]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
|
|
1283
1489
|
// generic errors
|
|
1284
|
-
[
|
|
1285
|
-
[
|
|
1286
|
-
[
|
|
1287
|
-
[
|
|
1288
|
-
// deprecations
|
|
1289
|
-
[51]: `@vnode-* hooks in templates are deprecated. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support will be removed in 3.4.`,
|
|
1290
|
-
[52]: `v-is="component-name" has been deprecated. Use is="vue:component-name" instead. v-is support will be removed in 3.4.`,
|
|
1490
|
+
[48]: `"prefixIdentifiers" option is not supported in this build of compiler.`,
|
|
1491
|
+
[49]: `ES module mode is not supported in this build of compiler.`,
|
|
1492
|
+
[50]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
|
|
1493
|
+
[51]: `"scopeId" option is only supported in module mode.`,
|
|
1291
1494
|
// just to fulfill types
|
|
1292
|
-
[
|
|
1495
|
+
[52]: ``
|
|
1293
1496
|
};
|
|
1294
1497
|
|
|
1295
1498
|
const isStaticExp = (p) => p.type === 4 && p.isStatic;
|
|
@@ -1609,7 +1812,8 @@ const defaultParserOptions = {
|
|
|
1609
1812
|
isCustomElement: shared.NO,
|
|
1610
1813
|
onError: defaultOnError,
|
|
1611
1814
|
onWarn: defaultOnWarn,
|
|
1612
|
-
comments: false
|
|
1815
|
+
comments: false,
|
|
1816
|
+
prefixIdentifiers: false
|
|
1613
1817
|
};
|
|
1614
1818
|
let currentOptions = defaultParserOptions;
|
|
1615
1819
|
let currentRoot = null;
|
|
@@ -1651,7 +1855,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
1651
1855
|
}
|
|
1652
1856
|
addNode({
|
|
1653
1857
|
type: 5,
|
|
1654
|
-
content:
|
|
1858
|
+
content: createExp(exp, false, getLoc(innerStart, innerEnd)),
|
|
1655
1859
|
loc: getLoc(start, end)
|
|
1656
1860
|
});
|
|
1657
1861
|
},
|
|
@@ -1744,7 +1948,7 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
1744
1948
|
loc: getLoc(start)
|
|
1745
1949
|
};
|
|
1746
1950
|
if (name === "pre") {
|
|
1747
|
-
inVPre = true;
|
|
1951
|
+
inVPre = tokenizer.inVPre = true;
|
|
1748
1952
|
currentVPreBoundary = currentOpenTag;
|
|
1749
1953
|
const props = currentOpenTag.props;
|
|
1750
1954
|
for (let i = 0; i < props.length; i++) {
|
|
@@ -1756,13 +1960,15 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
1756
1960
|
}
|
|
1757
1961
|
},
|
|
1758
1962
|
ondirarg(start, end) {
|
|
1963
|
+
if (start === end)
|
|
1964
|
+
return;
|
|
1759
1965
|
const arg = getSlice(start, end);
|
|
1760
1966
|
if (inVPre) {
|
|
1761
1967
|
currentProp.name += arg;
|
|
1762
1968
|
setLocEnd(currentProp.nameLoc, end);
|
|
1763
1969
|
} else {
|
|
1764
1970
|
const isStatic = arg[0] !== `[`;
|
|
1765
|
-
currentProp.arg =
|
|
1971
|
+
currentProp.arg = createExp(
|
|
1766
1972
|
isStatic ? arg : arg.slice(1, -1),
|
|
1767
1973
|
isStatic,
|
|
1768
1974
|
getLoc(start, end),
|
|
@@ -1829,10 +2035,22 @@ const tokenizer = new Tokenizer(stack, {
|
|
|
1829
2035
|
tokenizer.enterRCDATA(toCharCodes(`</template`), 0);
|
|
1830
2036
|
}
|
|
1831
2037
|
} else {
|
|
1832
|
-
|
|
2038
|
+
let expParseMode = 0 /* Normal */;
|
|
2039
|
+
{
|
|
2040
|
+
if (currentProp.name === "for") {
|
|
2041
|
+
expParseMode = 3 /* Skip */;
|
|
2042
|
+
} else if (currentProp.name === "slot") {
|
|
2043
|
+
expParseMode = 1 /* Params */;
|
|
2044
|
+
} else if (currentProp.name === "on" && currentAttrValue.includes(";")) {
|
|
2045
|
+
expParseMode = 2 /* Statements */;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
currentProp.exp = createExp(
|
|
1833
2049
|
currentAttrValue,
|
|
1834
2050
|
false,
|
|
1835
|
-
getLoc(currentAttrStartIndex, currentAttrEndIndex)
|
|
2051
|
+
getLoc(currentAttrStartIndex, currentAttrEndIndex),
|
|
2052
|
+
0,
|
|
2053
|
+
expParseMode
|
|
1836
2054
|
);
|
|
1837
2055
|
if (currentProp.name === "for") {
|
|
1838
2056
|
currentProp.forParseResult = parseForExpression(currentProp.exp);
|
|
@@ -1935,10 +2153,16 @@ function parseForExpression(input) {
|
|
|
1935
2153
|
if (!inMatch)
|
|
1936
2154
|
return;
|
|
1937
2155
|
const [, LHS, RHS] = inMatch;
|
|
1938
|
-
const createAliasExpression = (content, offset) => {
|
|
2156
|
+
const createAliasExpression = (content, offset, asParam = false) => {
|
|
1939
2157
|
const start = loc.start.offset + offset;
|
|
1940
2158
|
const end = start + content.length;
|
|
1941
|
-
return
|
|
2159
|
+
return createExp(
|
|
2160
|
+
content,
|
|
2161
|
+
false,
|
|
2162
|
+
getLoc(start, end),
|
|
2163
|
+
0,
|
|
2164
|
+
asParam ? 1 /* Params */ : 0 /* Normal */
|
|
2165
|
+
);
|
|
1942
2166
|
};
|
|
1943
2167
|
const result = {
|
|
1944
2168
|
source: createAliasExpression(RHS.trim(), exp.indexOf(RHS, LHS.length)),
|
|
@@ -1956,7 +2180,7 @@ function parseForExpression(input) {
|
|
|
1956
2180
|
let keyOffset;
|
|
1957
2181
|
if (keyContent) {
|
|
1958
2182
|
keyOffset = exp.indexOf(keyContent, trimmedOffset + valueContent.length);
|
|
1959
|
-
result.key = createAliasExpression(keyContent, keyOffset);
|
|
2183
|
+
result.key = createAliasExpression(keyContent, keyOffset, true);
|
|
1960
2184
|
}
|
|
1961
2185
|
if (iteratorMatch[2]) {
|
|
1962
2186
|
const indexContent = iteratorMatch[2].trim();
|
|
@@ -1966,13 +2190,14 @@ function parseForExpression(input) {
|
|
|
1966
2190
|
exp.indexOf(
|
|
1967
2191
|
indexContent,
|
|
1968
2192
|
result.key ? keyOffset + keyContent.length : trimmedOffset + valueContent.length
|
|
1969
|
-
)
|
|
2193
|
+
),
|
|
2194
|
+
true
|
|
1970
2195
|
);
|
|
1971
2196
|
}
|
|
1972
2197
|
}
|
|
1973
2198
|
}
|
|
1974
2199
|
if (valueContent) {
|
|
1975
|
-
result.value = createAliasExpression(valueContent, trimmedOffset);
|
|
2200
|
+
result.value = createAliasExpression(valueContent, trimmedOffset, true);
|
|
1976
2201
|
}
|
|
1977
2202
|
return result;
|
|
1978
2203
|
}
|
|
@@ -2043,7 +2268,7 @@ function onCloseTag(el, end, isImplied = false) {
|
|
|
2043
2268
|
inPre--;
|
|
2044
2269
|
}
|
|
2045
2270
|
if (currentVPreBoundary === el) {
|
|
2046
|
-
inVPre = false;
|
|
2271
|
+
inVPre = tokenizer.inVPre = false;
|
|
2047
2272
|
currentVPreBoundary = null;
|
|
2048
2273
|
}
|
|
2049
2274
|
if (tokenizer.inXML && (stack[0] ? stack[0].ns : currentOptions.ns) === 0) {
|
|
@@ -2248,8 +2473,36 @@ function dirToAttr(dir) {
|
|
|
2248
2473
|
}
|
|
2249
2474
|
return attr;
|
|
2250
2475
|
}
|
|
2251
|
-
function
|
|
2252
|
-
|
|
2476
|
+
function createExp(content, isStatic = false, loc, constType = 0, parseMode = 0 /* Normal */) {
|
|
2477
|
+
const exp = createSimpleExpression(content, isStatic, loc, constType);
|
|
2478
|
+
if (!isStatic && currentOptions.prefixIdentifiers && parseMode !== 3 /* Skip */ && content.trim()) {
|
|
2479
|
+
if (isSimpleIdentifier(content)) {
|
|
2480
|
+
exp.ast = null;
|
|
2481
|
+
return exp;
|
|
2482
|
+
}
|
|
2483
|
+
try {
|
|
2484
|
+
const plugins = currentOptions.expressionPlugins;
|
|
2485
|
+
const options = {
|
|
2486
|
+
plugins: plugins ? [...plugins, "typescript"] : ["typescript"]
|
|
2487
|
+
};
|
|
2488
|
+
if (parseMode === 2 /* Statements */) {
|
|
2489
|
+
exp.ast = parser.parse(` ${content} `, options).program;
|
|
2490
|
+
} else if (parseMode === 1 /* Params */) {
|
|
2491
|
+
exp.ast = parser.parseExpression(`(${content})=>{}`, options);
|
|
2492
|
+
} else {
|
|
2493
|
+
exp.ast = parser.parseExpression(`(${content})`, options);
|
|
2494
|
+
}
|
|
2495
|
+
} catch (e) {
|
|
2496
|
+
exp.ast = false;
|
|
2497
|
+
emitError(45, loc.start.offset, e.message);
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
return exp;
|
|
2501
|
+
}
|
|
2502
|
+
function emitError(code, index, message) {
|
|
2503
|
+
currentOptions.onError(
|
|
2504
|
+
createCompilerError(code, getLoc(index, index), void 0, message)
|
|
2505
|
+
);
|
|
2253
2506
|
}
|
|
2254
2507
|
function reset() {
|
|
2255
2508
|
tokenizer.reset();
|
|
@@ -2273,6 +2526,7 @@ function baseParse(input, options) {
|
|
|
2273
2526
|
}
|
|
2274
2527
|
}
|
|
2275
2528
|
tokenizer.mode = currentOptions.parseMode === "html" ? 1 : currentOptions.parseMode === "sfc" ? 2 : 0;
|
|
2529
|
+
tokenizer.inXML = currentOptions.ns === 1 || currentOptions.ns === 2;
|
|
2276
2530
|
const delimiters = options == null ? void 0 : options.delimiters;
|
|
2277
2531
|
if (delimiters) {
|
|
2278
2532
|
tokenizer.delimiterOpen = toCharCodes(delimiters[0]);
|
|
@@ -3601,7 +3855,7 @@ function genReturnStatement({ returns }, context) {
|
|
|
3601
3855
|
}
|
|
3602
3856
|
|
|
3603
3857
|
function walkIdentifiers(root, onIdentifier, includeAll = false, parentStack = [], knownIds = /* @__PURE__ */ Object.create(null)) {
|
|
3604
|
-
const rootExp = root.type === "Program"
|
|
3858
|
+
const rootExp = root.type === "Program" ? root.body[0].type === "ExpressionStatement" && root.body[0].expression : root;
|
|
3605
3859
|
estreeWalker.walk(root, {
|
|
3606
3860
|
enter(node, parent) {
|
|
3607
3861
|
parent && parentStack.push(parent);
|
|
@@ -3950,7 +4204,11 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3950
4204
|
};
|
|
3951
4205
|
const rawExp = node.content;
|
|
3952
4206
|
const bailConstant = constantBailRE.test(rawExp);
|
|
3953
|
-
|
|
4207
|
+
let ast = node.ast;
|
|
4208
|
+
if (ast === false) {
|
|
4209
|
+
return node;
|
|
4210
|
+
}
|
|
4211
|
+
if (ast === null || !ast && isSimpleIdentifier(rawExp)) {
|
|
3954
4212
|
const isScopeVarReference = context.identifiers[rawExp];
|
|
3955
4213
|
const isAllowedGlobal = shared.isGloballyAllowed(rawExp);
|
|
3956
4214
|
const isLiteral = isLiteralWhitelisted(rawExp);
|
|
@@ -3968,22 +4226,23 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
3968
4226
|
}
|
|
3969
4227
|
return node;
|
|
3970
4228
|
}
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
4229
|
+
if (!ast) {
|
|
4230
|
+
const source = asRawStatements ? ` ${rawExp} ` : `(${rawExp})${asParams ? `=>{}` : ``}`;
|
|
4231
|
+
try {
|
|
4232
|
+
ast = parser.parse(source, {
|
|
4233
|
+
plugins: context.expressionPlugins
|
|
4234
|
+
}).program;
|
|
4235
|
+
} catch (e) {
|
|
4236
|
+
context.onError(
|
|
4237
|
+
createCompilerError(
|
|
4238
|
+
45,
|
|
4239
|
+
node.loc,
|
|
4240
|
+
void 0,
|
|
4241
|
+
e.message
|
|
4242
|
+
)
|
|
4243
|
+
);
|
|
4244
|
+
return node;
|
|
4245
|
+
}
|
|
3987
4246
|
}
|
|
3988
4247
|
const ids = [];
|
|
3989
4248
|
const parentStack = [];
|
|
@@ -4026,15 +4285,15 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
4026
4285
|
if (leadingText.length || id.prefix) {
|
|
4027
4286
|
children.push(leadingText + (id.prefix || ``));
|
|
4028
4287
|
}
|
|
4029
|
-
const
|
|
4288
|
+
const source = rawExp.slice(start, end);
|
|
4030
4289
|
children.push(
|
|
4031
4290
|
createSimpleExpression(
|
|
4032
4291
|
id.name,
|
|
4033
4292
|
false,
|
|
4034
4293
|
{
|
|
4035
|
-
start: advancePositionWithClone(node.loc.start,
|
|
4036
|
-
end: advancePositionWithClone(node.loc.start,
|
|
4037
|
-
source
|
|
4294
|
+
start: advancePositionWithClone(node.loc.start, source, start),
|
|
4295
|
+
end: advancePositionWithClone(node.loc.start, source, end),
|
|
4296
|
+
source
|
|
4038
4297
|
},
|
|
4039
4298
|
id.isConstant ? 3 : 0
|
|
4040
4299
|
)
|
|
@@ -4046,6 +4305,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
|
|
|
4046
4305
|
let ret;
|
|
4047
4306
|
if (children.length) {
|
|
4048
4307
|
ret = createCompoundExpression(children, node.loc);
|
|
4308
|
+
ret.ast = ast;
|
|
4049
4309
|
} else {
|
|
4050
4310
|
ret = node;
|
|
4051
4311
|
ret.constType = bailConstant ? 0 : 3;
|
|
@@ -4981,6 +5241,10 @@ function resolveSetupReference(name, context) {
|
|
|
4981
5241
|
`${context.helperString(UNREF)}(${fromMaybeRef})`
|
|
4982
5242
|
) : `$setup[${JSON.stringify(fromMaybeRef)}]`;
|
|
4983
5243
|
}
|
|
5244
|
+
const fromProps = checkType("props");
|
|
5245
|
+
if (fromProps) {
|
|
5246
|
+
return `${context.helperString(UNREF)}(${context.inline ? "__props" : "$props"}[${JSON.stringify(fromProps)}])`;
|
|
5247
|
+
}
|
|
4984
5248
|
}
|
|
4985
5249
|
function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
|
|
4986
5250
|
const { tag, loc: elementLoc, children } = node;
|
|
@@ -5021,6 +5285,9 @@ function buildProps(node, context, props = node.props, isComponent, isDynamicCom
|
|
|
5021
5285
|
if (isEventHandler && shared.isReservedProp(name)) {
|
|
5022
5286
|
hasVnodeHook = true;
|
|
5023
5287
|
}
|
|
5288
|
+
if (isEventHandler && value.type === 14) {
|
|
5289
|
+
value = value.arguments[0];
|
|
5290
|
+
}
|
|
5024
5291
|
if (value.type === 20 || (value.type === 4 || value.type === 8) && getConstantType(value, context) > 0) {
|
|
5025
5292
|
return;
|
|
5026
5293
|
}
|
|
@@ -5993,10 +6260,10 @@ function baseCompile(source, options = {}) {
|
|
|
5993
6260
|
const isModuleMode = options.mode === "module";
|
|
5994
6261
|
const prefixIdentifiers = options.prefixIdentifiers === true || isModuleMode;
|
|
5995
6262
|
if (!prefixIdentifiers && options.cacheHandlers) {
|
|
5996
|
-
onError(createCompilerError(
|
|
6263
|
+
onError(createCompilerError(50));
|
|
5997
6264
|
}
|
|
5998
6265
|
if (options.scopeId && !isModuleMode) {
|
|
5999
|
-
onError(createCompilerError(
|
|
6266
|
+
onError(createCompilerError(51));
|
|
6000
6267
|
}
|
|
6001
6268
|
const ast = shared.isString(source) ? baseParse(source, options) : source;
|
|
6002
6269
|
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(prefixIdentifiers);
|
|
@@ -6031,10 +6298,24 @@ function baseCompile(source, options = {}) {
|
|
|
6031
6298
|
);
|
|
6032
6299
|
}
|
|
6033
6300
|
|
|
6301
|
+
const BindingTypes = {
|
|
6302
|
+
"DATA": "data",
|
|
6303
|
+
"PROPS": "props",
|
|
6304
|
+
"PROPS_ALIASED": "props-aliased",
|
|
6305
|
+
"SETUP_LET": "setup-let",
|
|
6306
|
+
"SETUP_CONST": "setup-const",
|
|
6307
|
+
"SETUP_REACTIVE_CONST": "setup-reactive-const",
|
|
6308
|
+
"SETUP_MAYBE_REF": "setup-maybe-ref",
|
|
6309
|
+
"SETUP_REF": "setup-ref",
|
|
6310
|
+
"OPTIONS": "options",
|
|
6311
|
+
"LITERAL_CONST": "literal-const"
|
|
6312
|
+
};
|
|
6313
|
+
|
|
6034
6314
|
const noopDirectiveTransform = () => ({ props: [] });
|
|
6035
6315
|
|
|
6036
6316
|
exports.generateCodeFrame = shared.generateCodeFrame;
|
|
6037
6317
|
exports.BASE_TRANSITION = BASE_TRANSITION;
|
|
6318
|
+
exports.BindingTypes = BindingTypes;
|
|
6038
6319
|
exports.CAMELIZE = CAMELIZE;
|
|
6039
6320
|
exports.CAPITALIZE = CAPITALIZE;
|
|
6040
6321
|
exports.CREATE_BLOCK = CREATE_BLOCK;
|
|
@@ -6045,6 +6326,10 @@ exports.CREATE_SLOTS = CREATE_SLOTS;
|
|
|
6045
6326
|
exports.CREATE_STATIC = CREATE_STATIC;
|
|
6046
6327
|
exports.CREATE_TEXT = CREATE_TEXT;
|
|
6047
6328
|
exports.CREATE_VNODE = CREATE_VNODE;
|
|
6329
|
+
exports.CompilerDeprecationTypes = CompilerDeprecationTypes;
|
|
6330
|
+
exports.ConstantTypes = ConstantTypes;
|
|
6331
|
+
exports.ElementTypes = ElementTypes;
|
|
6332
|
+
exports.ErrorCodes = ErrorCodes;
|
|
6048
6333
|
exports.FRAGMENT = FRAGMENT;
|
|
6049
6334
|
exports.GUARD_REACTIVE_PROPS = GUARD_REACTIVE_PROPS;
|
|
6050
6335
|
exports.IS_MEMO_SAME = IS_MEMO_SAME;
|
|
@@ -6054,6 +6339,8 @@ exports.MERGE_PROPS = MERGE_PROPS;
|
|
|
6054
6339
|
exports.NORMALIZE_CLASS = NORMALIZE_CLASS;
|
|
6055
6340
|
exports.NORMALIZE_PROPS = NORMALIZE_PROPS;
|
|
6056
6341
|
exports.NORMALIZE_STYLE = NORMALIZE_STYLE;
|
|
6342
|
+
exports.Namespaces = Namespaces;
|
|
6343
|
+
exports.NodeTypes = NodeTypes;
|
|
6057
6344
|
exports.OPEN_BLOCK = OPEN_BLOCK;
|
|
6058
6345
|
exports.POP_SCOPE_ID = POP_SCOPE_ID;
|
|
6059
6346
|
exports.PUSH_SCOPE_ID = PUSH_SCOPE_ID;
|