@maz-ui/mcp 5.2.0-beta.0 → 5.3.0
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/README.md +4 -2
- package/dist/chunks/files.mjs +28 -9
- package/dist/chunks/index.mjs +6588 -6170
- package/dist/chunks/theme.mjs +885 -426
- package/dist/cli.mjs +3 -9
- package/dist/index.d.mts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.mjs +5 -8
- package/dist/shared/{mcp.Ccxm-Aoc.mjs → mcp.ByQS-5Nc.mjs} +94 -31
- package/dist/shared/{mcp.D3_Fk0U3.mjs → mcp.CXId5vdl.mjs} +444 -3179
- package/docs/agents/claude-rule.md +13 -46
- package/docs/components/maz-alert.md +1 -1
- package/docs/components/maz-bottom-sheet.md +1 -1
- package/docs/components/maz-btn.md +3 -3
- package/docs/components/maz-card.md +1 -1
- package/docs/components/maz-container.md +2 -2
- package/docs/components/maz-dropdown.md +1 -1
- package/docs/components/maz-dropzone.md +1 -1
- package/docs/components/maz-icon.md +2 -2
- package/docs/components/maz-input.md +2 -2
- package/docs/components/maz-link.md +2 -2
- package/docs/components/maz-select-country.md +1 -1
- package/docs/components/maz-sidebar-menu-button.md +1 -1
- package/docs/components/maz-sidebar-menu-sub.md +1 -1
- package/docs/components/maz-sidebar.md +2 -2
- package/docs/ecosystem/node/index.md +1 -1
- package/docs/ecosystem/node/setup-agents.md +38 -1
- package/docs/ecosystem/nuxt.md +3 -3
- package/docs/guide/ai-agents.md +5 -4
- package/docs/guide/migration-v5.md +2 -2
- package/docs/manifest.json +1 -1
- package/package.json +15 -15
- package/dist/chunks/prompt.mjs +0 -280
package/dist/chunks/theme.mjs
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, statSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { a as globSync } from '../shared/mcp.
|
|
4
|
+
import { a as globSync } from '../shared/mcp.ByQS-5Nc.mjs';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'path';
|
|
7
7
|
import 'url';
|
|
8
8
|
import 'module';
|
|
9
|
-
import '../shared/mcp.
|
|
9
|
+
import '../shared/mcp.CXId5vdl.mjs';
|
|
10
10
|
import 'node:buffer';
|
|
11
11
|
import 'node:util';
|
|
12
|
-
import 'node:process';
|
|
13
|
-
import 'tty';
|
|
14
|
-
import 'node:tty';
|
|
15
|
-
import 'node:crypto';
|
|
16
12
|
import 'node:url';
|
|
13
|
+
import 'node:crypto';
|
|
14
|
+
import 'node:process';
|
|
17
15
|
|
|
18
16
|
class Position {
|
|
19
17
|
constructor(line, col, index) {
|
|
@@ -108,6 +106,7 @@ const StandardErrors = {
|
|
|
108
106
|
DecoratorSemicolon: "Decorators must not be followed by a semicolon.",
|
|
109
107
|
DecoratorStaticBlock: "Decorators can't be used with a static block.",
|
|
110
108
|
DeferImportRequiresNamespace: 'Only `import defer * as x from "./module"` is valid.',
|
|
109
|
+
DeferExportInvalidAll: '`export defer * from "./module"` is invalid. Explicitly list the re-exported names.',
|
|
111
110
|
DeletePrivateField: "Deleting a private field is not allowed.",
|
|
112
111
|
DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
|
|
113
112
|
DuplicateConstructor: "Duplicate constructor in the same class.",
|
|
@@ -124,6 +123,11 @@ const StandardErrors = {
|
|
|
124
123
|
exportName
|
|
125
124
|
}) => `A string literal cannot be used as an exported binding without \`from\`.\n- Did you mean \`export { '${localName}' as '${exportName}' } from 'some-module'\`?`,
|
|
126
125
|
ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'.",
|
|
126
|
+
FilteredNamespaceDuplicateName: ({
|
|
127
|
+
name
|
|
128
|
+
}) => `Duplicate name '${name}' in filtered namespace.`,
|
|
129
|
+
FilteredNamespaceRename: "Names in a filtered namespace cannot be renamed using `as`.",
|
|
130
|
+
FilteredNamespaceTypeModifier: "Names in a filtered namespace cannot have a type modifier.",
|
|
127
131
|
ForInOfLoopInitializer: ({
|
|
128
132
|
type
|
|
129
133
|
}) => `'${type === "ForInStatement" ? "for-in" : "for-of"}' loop variable declaration may not have an initializer.`,
|
|
@@ -140,14 +144,17 @@ const StandardErrors = {
|
|
|
140
144
|
importName
|
|
141
145
|
}) => `A string literal cannot be used as an imported binding.\n- Did you mean \`import { "${importName}" as foo }\`?`,
|
|
142
146
|
ImportCallArity: ({
|
|
143
|
-
phase
|
|
144
|
-
|
|
147
|
+
phase,
|
|
148
|
+
sync
|
|
149
|
+
}) => `\`import${phase ? `.${phase}` : sync ? ".sync" : ""}()\` requires exactly one or two arguments.`,
|
|
145
150
|
ImportCallNotNewExpression: ({
|
|
146
|
-
phase
|
|
147
|
-
|
|
151
|
+
phase,
|
|
152
|
+
sync
|
|
153
|
+
}) => `Cannot use new with import${phase ? `.${phase}` : sync ? ".sync" : ""}().`,
|
|
148
154
|
ImportCallSpreadArgument: ({
|
|
149
|
-
phase
|
|
150
|
-
|
|
155
|
+
phase,
|
|
156
|
+
sync
|
|
157
|
+
}) => `\`...\` is not allowed in \`import${phase ? `.${phase}` : sync ? ".sync" : ""}()\`.`,
|
|
151
158
|
IncompatibleRegExpUVFlags: "The 'u' and 'v' regular expression flags cannot be enabled at the same time.",
|
|
152
159
|
InvalidBigIntLiteral: "Invalid BigIntLiteral.",
|
|
153
160
|
InvalidCodePoint: "Code point out of bounds.",
|
|
@@ -173,7 +180,6 @@ const StandardErrors = {
|
|
|
173
180
|
InvalidLhsOptionalChaining: ({
|
|
174
181
|
ancestor
|
|
175
182
|
}) => `Invalid optional chaining in the left-hand side of ${toNodeDescription(ancestor)}.`,
|
|
176
|
-
InvalidNumber: "Invalid number.",
|
|
177
183
|
InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'.",
|
|
178
184
|
InvalidOrUnexpectedToken: ({
|
|
179
185
|
unexpected
|
|
@@ -473,12 +479,14 @@ function getOptions(opts) {
|
|
|
473
479
|
return options;
|
|
474
480
|
}
|
|
475
481
|
function toESTreeLocation(node) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
+
if (node.loc) {
|
|
483
|
+
const {
|
|
484
|
+
start,
|
|
485
|
+
end
|
|
486
|
+
} = node.loc;
|
|
487
|
+
node.loc.start = new Position(start.line, start.column);
|
|
488
|
+
node.loc.end = new Position(end.line, end.column);
|
|
489
|
+
}
|
|
482
490
|
return node;
|
|
483
491
|
}
|
|
484
492
|
const estree = superClass => class ESTreeParserMixin extends superClass {
|
|
@@ -754,7 +762,7 @@ const estree = superClass => class ESTreeParserMixin extends superClass {
|
|
|
754
762
|
node.exported = null;
|
|
755
763
|
break;
|
|
756
764
|
case "ExportNamedDeclaration":
|
|
757
|
-
if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
|
|
765
|
+
if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier" && !node.specifiers[0].exportsFilter) {
|
|
758
766
|
this.castNodeTo(node, "ExportAllDeclaration");
|
|
759
767
|
node.exported = node.specifiers[0].exported;
|
|
760
768
|
delete node.specifiers;
|
|
@@ -1189,6 +1197,12 @@ const tt = {
|
|
|
1189
1197
|
_static: createKeywordLike("static", {
|
|
1190
1198
|
startsExpr
|
|
1191
1199
|
}),
|
|
1200
|
+
_struct: createKeywordLike("struct", {
|
|
1201
|
+
startsExpr
|
|
1202
|
+
}),
|
|
1203
|
+
_sync: createKeywordLike("sync", {
|
|
1204
|
+
startsExpr
|
|
1205
|
+
}),
|
|
1192
1206
|
_using: createKeywordLike("using", {
|
|
1193
1207
|
startsExpr
|
|
1194
1208
|
}),
|
|
@@ -1296,16 +1310,16 @@ const tt = {
|
|
|
1296
1310
|
jsxTagEnd: createToken("jsxTagEnd")
|
|
1297
1311
|
};
|
|
1298
1312
|
function tokenIsIdentifier(token) {
|
|
1299
|
-
return token >= 89 && token <=
|
|
1313
|
+
return token >= 89 && token <= 132;
|
|
1300
1314
|
}
|
|
1301
1315
|
function tokenKeywordOrIdentifierIsKeyword(token) {
|
|
1302
1316
|
return token <= 88;
|
|
1303
1317
|
}
|
|
1304
1318
|
function tokenIsKeywordOrIdentifier(token) {
|
|
1305
|
-
return token >= 54 && token <=
|
|
1319
|
+
return token >= 54 && token <= 132;
|
|
1306
1320
|
}
|
|
1307
1321
|
function tokenIsLiteralPropertyName(token) {
|
|
1308
|
-
return token >= 54 && token <=
|
|
1322
|
+
return token >= 54 && token <= 135;
|
|
1309
1323
|
}
|
|
1310
1324
|
function tokenComesBeforeExpression(token) {
|
|
1311
1325
|
return tokenBeforeExprs[token];
|
|
@@ -1317,7 +1331,7 @@ function tokenIsAssignment(token) {
|
|
|
1317
1331
|
return token >= 25 && token <= 29;
|
|
1318
1332
|
}
|
|
1319
1333
|
function tokenIsFlowInterfaceOrTypeOrOpaque(token) {
|
|
1320
|
-
return token >=
|
|
1334
|
+
return token >= 128 && token <= 130;
|
|
1321
1335
|
}
|
|
1322
1336
|
function tokenIsLoop(token) {
|
|
1323
1337
|
return token >= 86 && token <= 88;
|
|
@@ -1335,10 +1349,10 @@ function tokenIsPrefix(token) {
|
|
|
1335
1349
|
return tokenPrefixes[token];
|
|
1336
1350
|
}
|
|
1337
1351
|
function tokenIsTSTypeOperator(token) {
|
|
1338
|
-
return token >=
|
|
1352
|
+
return token >= 120 && token <= 122;
|
|
1339
1353
|
}
|
|
1340
1354
|
function tokenIsTSDeclarationStart(token) {
|
|
1341
|
-
return token >=
|
|
1355
|
+
return token >= 123 && token <= 129;
|
|
1342
1356
|
}
|
|
1343
1357
|
function tokenLabelName(token) {
|
|
1344
1358
|
return tokenLabels[token];
|
|
@@ -1748,7 +1762,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1748
1762
|
return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
|
|
1749
1763
|
}
|
|
1750
1764
|
finishToken(type, val) {
|
|
1751
|
-
if (type !==
|
|
1765
|
+
if (type !== 133 && type !== 9 && type !== 24) {
|
|
1752
1766
|
if (this.flowPragma === undefined) {
|
|
1753
1767
|
this.flowPragma = null;
|
|
1754
1768
|
}
|
|
@@ -1780,7 +1794,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1780
1794
|
const node = this.startNode();
|
|
1781
1795
|
const moduloLoc = this.state.startLoc;
|
|
1782
1796
|
this.next();
|
|
1783
|
-
this.expectContextual(
|
|
1797
|
+
this.expectContextual(109);
|
|
1784
1798
|
if (this.state.lastTokStartLoc.index > moduloLoc.index + 1) {
|
|
1785
1799
|
this.raise(FlowErrors.UnexpectedSpaceBetweenModuloChecks, moduloLoc);
|
|
1786
1800
|
}
|
|
@@ -1846,7 +1860,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1846
1860
|
return this.flowParseDeclareFunction(node);
|
|
1847
1861
|
} else if (this.match(70)) {
|
|
1848
1862
|
return this.flowParseDeclareVariable(node);
|
|
1849
|
-
} else if (this.eatContextual(
|
|
1863
|
+
} else if (this.eatContextual(126)) {
|
|
1850
1864
|
if (this.match(12)) {
|
|
1851
1865
|
return this.flowParseDeclareModuleExports(node);
|
|
1852
1866
|
} else {
|
|
@@ -1855,11 +1869,11 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1855
1869
|
}
|
|
1856
1870
|
return this.flowParseDeclareModule(node);
|
|
1857
1871
|
}
|
|
1858
|
-
} else if (this.isContextual(
|
|
1872
|
+
} else if (this.isContextual(129)) {
|
|
1859
1873
|
return this.flowParseDeclareTypeAlias(node);
|
|
1860
|
-
} else if (this.isContextual(
|
|
1874
|
+
} else if (this.isContextual(130)) {
|
|
1861
1875
|
return this.flowParseDeclareOpaqueType(node);
|
|
1862
|
-
} else if (this.isContextual(
|
|
1876
|
+
} else if (this.isContextual(128)) {
|
|
1863
1877
|
return this.flowParseDeclareInterface(node);
|
|
1864
1878
|
} else if (this.match(78)) {
|
|
1865
1879
|
return this.flowParseDeclareExportDeclaration(node, insideModule);
|
|
@@ -1875,7 +1889,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1875
1889
|
}
|
|
1876
1890
|
flowParseDeclareModule(node) {
|
|
1877
1891
|
this.scope.enter(0);
|
|
1878
|
-
if (this.match(
|
|
1892
|
+
if (this.match(133)) {
|
|
1879
1893
|
node.id = super.parseExprAtom();
|
|
1880
1894
|
} else {
|
|
1881
1895
|
node.id = this.parseIdentifier();
|
|
@@ -1887,12 +1901,12 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1887
1901
|
const bodyNode = this.startNode();
|
|
1888
1902
|
if (this.match(79)) {
|
|
1889
1903
|
this.next();
|
|
1890
|
-
if (!this.isContextual(
|
|
1904
|
+
if (!this.isContextual(129) && !this.match(83)) {
|
|
1891
1905
|
this.raise(FlowErrors.InvalidNonTypeImportInDeclareModule, this.state.lastTokStartLoc);
|
|
1892
1906
|
}
|
|
1893
1907
|
body.push(super.parseImport(bodyNode));
|
|
1894
1908
|
} else {
|
|
1895
|
-
this.expectContextual(
|
|
1909
|
+
this.expectContextual(124, FlowErrors.UnsupportedStatementInDeclareModule);
|
|
1896
1910
|
body.push(this.flowParseDeclare(bodyNode, true));
|
|
1897
1911
|
}
|
|
1898
1912
|
}
|
|
@@ -1933,18 +1947,18 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1933
1947
|
node.default = true;
|
|
1934
1948
|
return this.finishNode(node, "DeclareExportDeclaration");
|
|
1935
1949
|
} else {
|
|
1936
|
-
if (this.match(71) || this.isLet() || (this.isContextual(
|
|
1950
|
+
if (this.match(71) || this.isLet() || (this.isContextual(129) || this.isContextual(128)) && !insideModule) {
|
|
1937
1951
|
const label = this.state.value;
|
|
1938
1952
|
throw this.raise(FlowErrors.UnsupportedDeclareExportKind, this.state.startLoc, {
|
|
1939
1953
|
unsupportedExportKind: label,
|
|
1940
1954
|
suggestion: exportSuggestions[label]
|
|
1941
1955
|
});
|
|
1942
1956
|
}
|
|
1943
|
-
if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(
|
|
1957
|
+
if (this.match(70) || this.match(64) || this.match(76) || this.isContextual(130)) {
|
|
1944
1958
|
node.declaration = this.flowParseDeclare(this.startNode());
|
|
1945
1959
|
node.default = false;
|
|
1946
1960
|
return this.finishNode(node, "DeclareExportDeclaration");
|
|
1947
|
-
} else if (this.match(51) || this.match(2) || this.isContextual(
|
|
1961
|
+
} else if (this.match(51) || this.match(2) || this.isContextual(128) || this.isContextual(129) || this.isContextual(130)) {
|
|
1948
1962
|
const result = this.parseExport(node, null);
|
|
1949
1963
|
if (result.type === "ExportNamedDeclaration") {
|
|
1950
1964
|
result.default = false;
|
|
@@ -1959,7 +1973,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1959
1973
|
}
|
|
1960
1974
|
flowParseDeclareModuleExports(node) {
|
|
1961
1975
|
this.next();
|
|
1962
|
-
this.expectContextual(
|
|
1976
|
+
this.expectContextual(110);
|
|
1963
1977
|
node.typeAnnotation = this.flowParseTypeAnnotation();
|
|
1964
1978
|
this.semicolon();
|
|
1965
1979
|
return this.finishNode(node, "DeclareModuleExports");
|
|
@@ -1996,12 +2010,12 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
1996
2010
|
if (isClass) {
|
|
1997
2011
|
const implemented = [];
|
|
1998
2012
|
const mixins = [];
|
|
1999
|
-
if (this.eatContextual(
|
|
2013
|
+
if (this.eatContextual(116)) {
|
|
2000
2014
|
do {
|
|
2001
2015
|
mixins.push(this.flowParseInterfaceExtends());
|
|
2002
2016
|
} while (this.eat(8));
|
|
2003
2017
|
}
|
|
2004
|
-
if (this.eatContextual(
|
|
2018
|
+
if (this.eatContextual(112)) {
|
|
2005
2019
|
do {
|
|
2006
2020
|
implemented.push(this.flowParseClassImplements());
|
|
2007
2021
|
} while (this.eat(8));
|
|
@@ -2064,7 +2078,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2064
2078
|
return this.finishNode(node, "TypeAlias");
|
|
2065
2079
|
}
|
|
2066
2080
|
flowParseOpaqueType(node, declare) {
|
|
2067
|
-
this.expectContextual(
|
|
2081
|
+
this.expectContextual(129);
|
|
2068
2082
|
node.id = this.flowParseRestrictedIdentifier(true, true);
|
|
2069
2083
|
this.scope.declareName(node.id.name, 8201, node.id.start);
|
|
2070
2084
|
if (this.match(43)) {
|
|
@@ -2113,7 +2127,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2113
2127
|
const node = this.startNode();
|
|
2114
2128
|
node.params = [];
|
|
2115
2129
|
this.state.inType = true;
|
|
2116
|
-
if (this.match(43) || this.match(
|
|
2130
|
+
if (this.match(43) || this.match(141)) {
|
|
2117
2131
|
this.next();
|
|
2118
2132
|
} else {
|
|
2119
2133
|
this.unexpected();
|
|
@@ -2193,7 +2207,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2193
2207
|
}
|
|
2194
2208
|
flowParseInterfaceType() {
|
|
2195
2209
|
const node = this.startNode();
|
|
2196
|
-
this.expectContextual(
|
|
2210
|
+
this.expectContextual(128);
|
|
2197
2211
|
node.extends = [];
|
|
2198
2212
|
if (this.eat(77)) {
|
|
2199
2213
|
do {
|
|
@@ -2210,7 +2224,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2210
2224
|
return this.finishNode(node, "InterfaceTypeAnnotation");
|
|
2211
2225
|
}
|
|
2212
2226
|
flowParseObjectPropertyKey() {
|
|
2213
|
-
return this.match(
|
|
2227
|
+
return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
|
|
2214
2228
|
}
|
|
2215
2229
|
flowParseObjectTypeIndexer(node, isStatic, variance) {
|
|
2216
2230
|
node.static = isStatic;
|
|
@@ -2311,7 +2325,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2311
2325
|
let protoStartLoc = null;
|
|
2312
2326
|
let inexactStartLoc = null;
|
|
2313
2327
|
const node = this.startNode();
|
|
2314
|
-
if (allowProto && this.isContextual(
|
|
2328
|
+
if (allowProto && this.isContextual(117)) {
|
|
2315
2329
|
const lookahead = this.lookahead();
|
|
2316
2330
|
if (lookahead.type !== 10 && lookahead.type !== 13) {
|
|
2317
2331
|
this.next();
|
|
@@ -2653,7 +2667,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2653
2667
|
node.typeParameters = null;
|
|
2654
2668
|
return this.finishNode(node, "FunctionTypeAnnotation");
|
|
2655
2669
|
}
|
|
2656
|
-
case
|
|
2670
|
+
case 133:
|
|
2657
2671
|
return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
|
|
2658
2672
|
case 81:
|
|
2659
2673
|
case 82:
|
|
@@ -2663,18 +2677,18 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2663
2677
|
case 49:
|
|
2664
2678
|
if (this.state.value === "-") {
|
|
2665
2679
|
this.next();
|
|
2666
|
-
if (this.match(
|
|
2680
|
+
if (this.match(134)) {
|
|
2667
2681
|
return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
|
|
2668
2682
|
}
|
|
2669
|
-
if (this.match(
|
|
2683
|
+
if (this.match(135)) {
|
|
2670
2684
|
return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
|
|
2671
2685
|
}
|
|
2672
2686
|
throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
|
|
2673
2687
|
}
|
|
2674
2688
|
throw this.unexpected();
|
|
2675
|
-
case
|
|
2689
|
+
case 134:
|
|
2676
2690
|
return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
|
|
2677
|
-
case
|
|
2691
|
+
case 135:
|
|
2678
2692
|
return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
|
|
2679
2693
|
case 84:
|
|
2680
2694
|
this.next();
|
|
@@ -2696,7 +2710,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2696
2710
|
this.next();
|
|
2697
2711
|
return super.createIdentifier(node, label);
|
|
2698
2712
|
} else if (tokenIsIdentifier(this.state.type)) {
|
|
2699
|
-
if (this.isContextual(
|
|
2713
|
+
if (this.isContextual(128)) {
|
|
2700
2714
|
return this.flowParseInterfaceType();
|
|
2701
2715
|
}
|
|
2702
2716
|
return this.flowIdentToTypeAnnotation(startLoc, node, this.parseIdentifier());
|
|
@@ -2781,7 +2795,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2781
2795
|
return type;
|
|
2782
2796
|
}
|
|
2783
2797
|
flowParseTypeOrImplicitInstantiation() {
|
|
2784
|
-
if (this.state.type ===
|
|
2798
|
+
if (this.state.type === 131 && this.state.value === "_") {
|
|
2785
2799
|
const startLoc = this.state.startLoc;
|
|
2786
2800
|
const node = this.parseIdentifier();
|
|
2787
2801
|
return this.flowParseGenericType(startLoc, node);
|
|
@@ -2841,14 +2855,14 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2841
2855
|
return super.parseFunctionBodyAndFinish(node, type, isMethod);
|
|
2842
2856
|
}
|
|
2843
2857
|
parseStatementLike(flags) {
|
|
2844
|
-
if (this.state.strict && this.isContextual(
|
|
2858
|
+
if (this.state.strict && this.isContextual(128)) {
|
|
2845
2859
|
const lookahead = this.lookahead();
|
|
2846
2860
|
if (tokenIsKeywordOrIdentifier(lookahead.type)) {
|
|
2847
2861
|
const node = this.startNode();
|
|
2848
2862
|
this.next();
|
|
2849
2863
|
return this.flowParseInterface(node);
|
|
2850
2864
|
}
|
|
2851
|
-
} else if (this.isContextual(
|
|
2865
|
+
} else if (this.isContextual(125)) {
|
|
2852
2866
|
const node = this.startNode();
|
|
2853
2867
|
this.next();
|
|
2854
2868
|
return this.flowParseEnumDeclaration(node);
|
|
@@ -2881,7 +2895,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2881
2895
|
const {
|
|
2882
2896
|
type
|
|
2883
2897
|
} = this.state;
|
|
2884
|
-
if (type ===
|
|
2898
|
+
if (type === 125 || tokenIsFlowInterfaceOrTypeOrOpaque(type)) {
|
|
2885
2899
|
return !this.state.containsEsc;
|
|
2886
2900
|
}
|
|
2887
2901
|
return super.shouldParseExportDeclaration();
|
|
@@ -2890,13 +2904,13 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
2890
2904
|
const {
|
|
2891
2905
|
type
|
|
2892
2906
|
} = this.state;
|
|
2893
|
-
if (type ===
|
|
2907
|
+
if (type === 125 || tokenIsFlowInterfaceOrTypeOrOpaque(type)) {
|
|
2894
2908
|
return this.state.containsEsc;
|
|
2895
2909
|
}
|
|
2896
2910
|
return super.isExportDefaultSpecifier();
|
|
2897
2911
|
}
|
|
2898
2912
|
parseExportDefaultExpression() {
|
|
2899
|
-
if (this.isContextual(
|
|
2913
|
+
if (this.isContextual(125)) {
|
|
2900
2914
|
const node = this.startNode();
|
|
2901
2915
|
this.next();
|
|
2902
2916
|
return this.flowParseEnumDeclaration(node);
|
|
@@ -3030,7 +3044,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3030
3044
|
super.assertModuleNodeAllowed(node);
|
|
3031
3045
|
}
|
|
3032
3046
|
parseExportDeclaration(node) {
|
|
3033
|
-
if (this.isContextual(
|
|
3047
|
+
if (this.isContextual(129)) {
|
|
3034
3048
|
node.exportKind = "type";
|
|
3035
3049
|
const declarationNode = this.startNode();
|
|
3036
3050
|
this.next();
|
|
@@ -3041,17 +3055,17 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3041
3055
|
} else {
|
|
3042
3056
|
return this.flowParseTypeAlias(declarationNode);
|
|
3043
3057
|
}
|
|
3044
|
-
} else if (this.isContextual(
|
|
3058
|
+
} else if (this.isContextual(130)) {
|
|
3045
3059
|
node.exportKind = "type";
|
|
3046
3060
|
const declarationNode = this.startNode();
|
|
3047
3061
|
this.next();
|
|
3048
3062
|
return this.flowParseOpaqueType(declarationNode, false);
|
|
3049
|
-
} else if (this.isContextual(
|
|
3063
|
+
} else if (this.isContextual(128)) {
|
|
3050
3064
|
node.exportKind = "type";
|
|
3051
3065
|
const declarationNode = this.startNode();
|
|
3052
3066
|
this.next();
|
|
3053
3067
|
return this.flowParseInterface(declarationNode);
|
|
3054
|
-
} else if (this.isContextual(
|
|
3068
|
+
} else if (this.isContextual(125)) {
|
|
3055
3069
|
node.exportKind = "value";
|
|
3056
3070
|
const declarationNode = this.startNode();
|
|
3057
3071
|
this.next();
|
|
@@ -3062,7 +3076,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3062
3076
|
}
|
|
3063
3077
|
eatExportStar(node) {
|
|
3064
3078
|
if (super.eatExportStar(node)) return true;
|
|
3065
|
-
if (this.isContextual(
|
|
3079
|
+
if (this.isContextual(129) && this.lookahead().type === 51) {
|
|
3066
3080
|
node.exportKind = "type";
|
|
3067
3081
|
this.next();
|
|
3068
3082
|
this.next();
|
|
@@ -3080,8 +3094,16 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3080
3094
|
}
|
|
3081
3095
|
return hasNamespace;
|
|
3082
3096
|
}
|
|
3097
|
+
maybeParseExportNamedSpecifiers(node) {
|
|
3098
|
+
if (!super.maybeParseExportNamedSpecifiers(node)) return false;
|
|
3099
|
+
const specifier = node.specifiers[node.specifiers.length - 1];
|
|
3100
|
+
if (node.exportKind === "type" && specifier?.type === "ExportNamespaceSpecifier") {
|
|
3101
|
+
this.unexpected(specifier.start);
|
|
3102
|
+
}
|
|
3103
|
+
return true;
|
|
3104
|
+
}
|
|
3083
3105
|
parseClassId(node, isStatement, optionalId) {
|
|
3084
|
-
if ((!isStatement || optionalId) && this.isContextual(
|
|
3106
|
+
if ((!isStatement || optionalId) && this.isContextual(112)) {
|
|
3085
3107
|
node.id = null;
|
|
3086
3108
|
return;
|
|
3087
3109
|
}
|
|
@@ -3094,7 +3116,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3094
3116
|
const {
|
|
3095
3117
|
startLoc
|
|
3096
3118
|
} = this.state;
|
|
3097
|
-
if (this.isContextual(
|
|
3119
|
+
if (this.isContextual(124)) {
|
|
3098
3120
|
if (super.parseClassMemberFromModifier(classBody, member)) {
|
|
3099
3121
|
return;
|
|
3100
3122
|
}
|
|
@@ -3120,7 +3142,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3120
3142
|
identifierName: fullWord
|
|
3121
3143
|
});
|
|
3122
3144
|
}
|
|
3123
|
-
this.finishToken(
|
|
3145
|
+
this.finishToken(131, fullWord);
|
|
3124
3146
|
}
|
|
3125
3147
|
getTokenFromCode(code) {
|
|
3126
3148
|
const next = this.input.charCodeAt(this.state.pos + 1);
|
|
@@ -3247,7 +3269,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3247
3269
|
if (node.superClass && (this.match(43) || this.match(47))) {
|
|
3248
3270
|
node.superTypeArguments = this.flowParseTypeParameterInstantiationInExpression();
|
|
3249
3271
|
}
|
|
3250
|
-
if (this.eatContextual(
|
|
3272
|
+
if (this.eatContextual(112)) {
|
|
3251
3273
|
const implemented = node.implements = [];
|
|
3252
3274
|
do {
|
|
3253
3275
|
implemented.push(this.flowParseClassImplements());
|
|
@@ -3319,7 +3341,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3319
3341
|
}
|
|
3320
3342
|
isPotentialImportPhase(isExport) {
|
|
3321
3343
|
if (super.isPotentialImportPhase(isExport)) return true;
|
|
3322
|
-
if (this.isContextual(
|
|
3344
|
+
if (this.isContextual(129)) {
|
|
3323
3345
|
if (!isExport) return true;
|
|
3324
3346
|
const ch = this.lookaheadCharCode();
|
|
3325
3347
|
return ch === 123 || ch === 42;
|
|
@@ -3338,7 +3360,14 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3338
3360
|
node.importKind = phase === "type" || phase === "typeof" ? phase : "value";
|
|
3339
3361
|
}
|
|
3340
3362
|
}
|
|
3341
|
-
|
|
3363
|
+
parseNamedOrFilteredImportSpecifiers(node) {
|
|
3364
|
+
super.parseNamedOrFilteredImportSpecifiers(node);
|
|
3365
|
+
const specifier = node.specifiers[node.specifiers.length - 1];
|
|
3366
|
+
if (hasTypeImportKind(node) && specifier?.type === "ImportNamespaceSpecifier") {
|
|
3367
|
+
this.unexpected(specifier.start);
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) {
|
|
3342
3371
|
const firstIdent = specifier.imported;
|
|
3343
3372
|
let specifierTypeKind = null;
|
|
3344
3373
|
if (firstIdent.type === "Identifier") {
|
|
@@ -3348,7 +3377,6 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3348
3377
|
specifierTypeKind = "typeof";
|
|
3349
3378
|
}
|
|
3350
3379
|
}
|
|
3351
|
-
let isBinding = false;
|
|
3352
3380
|
if (this.isContextual(90) && !this.isLookaheadContextual("as")) {
|
|
3353
3381
|
const as_ident = this.parseIdentifier(true);
|
|
3354
3382
|
if (specifierTypeKind !== null && !tokenIsKeywordOrIdentifier(this.state.type)) {
|
|
@@ -3365,32 +3393,30 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3365
3393
|
specifier.imported = this.parseIdentifier(true);
|
|
3366
3394
|
specifier.importKind = specifierTypeKind;
|
|
3367
3395
|
} else {
|
|
3368
|
-
if (importedIsString) {
|
|
3369
|
-
throw this.raise(Errors.ImportBindingIsString, specifier, {
|
|
3370
|
-
importName: firstIdent.value
|
|
3371
|
-
});
|
|
3372
|
-
}
|
|
3373
3396
|
specifier.imported = firstIdent;
|
|
3374
3397
|
specifier.importKind = null;
|
|
3375
3398
|
}
|
|
3376
3399
|
if (this.eatContextual(90)) {
|
|
3377
3400
|
specifier.local = this.parseIdentifier();
|
|
3378
3401
|
} else {
|
|
3379
|
-
isBinding = true;
|
|
3380
3402
|
specifier.local = this.cloneIdentifier(specifier.imported);
|
|
3381
3403
|
}
|
|
3382
3404
|
}
|
|
3405
|
+
return this.finishNode(specifier, "ImportSpecifier");
|
|
3406
|
+
}
|
|
3407
|
+
checkImportSpecifier(specifier, isInTypeOnlyImport) {
|
|
3383
3408
|
const specifierIsTypeImport = hasTypeImportKind(specifier);
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3409
|
+
const isTypeImport = isInTypeOnlyImport || specifierIsTypeImport;
|
|
3410
|
+
if (isTypeImport) {
|
|
3411
|
+
if (isInTypeOnlyImport && specifierIsTypeImport) {
|
|
3412
|
+
this.raise(FlowErrors.ImportTypeShorthandOnlyInPureImport, specifier);
|
|
3413
|
+
}
|
|
3414
|
+
const {
|
|
3415
|
+
local
|
|
3416
|
+
} = specifier;
|
|
3417
|
+
this.checkReservedType(local.name, local.start, true);
|
|
3392
3418
|
}
|
|
3393
|
-
|
|
3419
|
+
super.checkImportSpecifier(specifier, isInTypeOnlyImport, 8201, !isTypeImport);
|
|
3394
3420
|
}
|
|
3395
3421
|
parseBindingAtom() {
|
|
3396
3422
|
switch (this.state.type) {
|
|
@@ -3429,7 +3455,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3429
3455
|
parseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
3430
3456
|
let state = null;
|
|
3431
3457
|
let jsx;
|
|
3432
|
-
if (this.hasPlugin("jsx") && (this.match(
|
|
3458
|
+
if (this.hasPlugin("jsx") && (this.match(141) || this.match(43))) {
|
|
3433
3459
|
state = this.state.clone();
|
|
3434
3460
|
jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, isParenItem), state);
|
|
3435
3461
|
if (!jsx.error) return jsx.node;
|
|
@@ -3680,7 +3706,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3680
3706
|
const startLoc = this.state.startLoc;
|
|
3681
3707
|
const endOfInit = () => this.match(8) || this.match(4);
|
|
3682
3708
|
switch (this.state.type) {
|
|
3683
|
-
case
|
|
3709
|
+
case 134:
|
|
3684
3710
|
{
|
|
3685
3711
|
const literal = this.parseNumericLiteral(this.state.value);
|
|
3686
3712
|
if (endOfInit()) {
|
|
@@ -3692,7 +3718,7 @@ const flow = superClass => class FlowParserMixin extends superClass {
|
|
|
3692
3718
|
}
|
|
3693
3719
|
break;
|
|
3694
3720
|
}
|
|
3695
|
-
case
|
|
3721
|
+
case 133:
|
|
3696
3722
|
{
|
|
3697
3723
|
const literal = this.parseStringLiteral(this.state.value);
|
|
3698
3724
|
if (endOfInit()) {
|
|
@@ -4372,14 +4398,14 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4372
4398
|
if (this.state.pos === this.state.start) {
|
|
4373
4399
|
if (ch === 60 && this.state.canStartJSXElement) {
|
|
4374
4400
|
++this.state.pos;
|
|
4375
|
-
this.finishToken(
|
|
4401
|
+
this.finishToken(141);
|
|
4376
4402
|
} else {
|
|
4377
4403
|
super.getTokenFromCode(ch);
|
|
4378
4404
|
}
|
|
4379
4405
|
return;
|
|
4380
4406
|
}
|
|
4381
4407
|
out += this.input.slice(chunkStart, this.state.pos);
|
|
4382
|
-
this.finishToken(
|
|
4408
|
+
this.finishToken(140, out);
|
|
4383
4409
|
return;
|
|
4384
4410
|
case 38:
|
|
4385
4411
|
out += this.input.slice(chunkStart, this.state.pos);
|
|
@@ -4439,7 +4465,7 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4439
4465
|
}
|
|
4440
4466
|
}
|
|
4441
4467
|
out += this.input.slice(chunkStart, this.state.pos++);
|
|
4442
|
-
this.finishToken(
|
|
4468
|
+
this.finishToken(133, out);
|
|
4443
4469
|
}
|
|
4444
4470
|
jsxReadEntity() {
|
|
4445
4471
|
const startPos = ++this.state.pos;
|
|
@@ -4479,11 +4505,11 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4479
4505
|
do {
|
|
4480
4506
|
ch = this.input.charCodeAt(++this.state.pos);
|
|
4481
4507
|
} while (isIdentifierChar(ch) || ch === 45);
|
|
4482
|
-
this.finishToken(
|
|
4508
|
+
this.finishToken(139, this.input.slice(start, this.state.pos));
|
|
4483
4509
|
}
|
|
4484
4510
|
jsxParseIdentifier() {
|
|
4485
4511
|
const node = this.startNode();
|
|
4486
|
-
if (this.match(
|
|
4512
|
+
if (this.match(139)) {
|
|
4487
4513
|
node.name = this.state.value;
|
|
4488
4514
|
} else if (tokenIsKeyword(this.state.type)) {
|
|
4489
4515
|
node.name = tokenLabelName(this.state.type);
|
|
@@ -4528,8 +4554,8 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4528
4554
|
this.raise(JsxErrors.AttributeIsEmpty, node);
|
|
4529
4555
|
}
|
|
4530
4556
|
return node;
|
|
4531
|
-
case
|
|
4532
|
-
case
|
|
4557
|
+
case 141:
|
|
4558
|
+
case 133:
|
|
4533
4559
|
return this.parseExprAtom();
|
|
4534
4560
|
default:
|
|
4535
4561
|
throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
|
|
@@ -4580,7 +4606,7 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4580
4606
|
return this.finishNode(node, "JSXAttribute");
|
|
4581
4607
|
}
|
|
4582
4608
|
jsxParseOpeningElementAt(startLoc) {
|
|
4583
|
-
if (this.eat(
|
|
4609
|
+
if (this.eat(142)) {
|
|
4584
4610
|
const node = this.startNodeAt(startLoc);
|
|
4585
4611
|
return this.finishNode(node, "JSXOpeningFragment");
|
|
4586
4612
|
}
|
|
@@ -4590,22 +4616,22 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4590
4616
|
}
|
|
4591
4617
|
jsxParseOpeningElementAfterName(node) {
|
|
4592
4618
|
const attributes = [];
|
|
4593
|
-
while (!this.match(52) && !this.match(
|
|
4619
|
+
while (!this.match(52) && !this.match(142)) {
|
|
4594
4620
|
attributes.push(this.jsxParseAttribute());
|
|
4595
4621
|
}
|
|
4596
4622
|
node.attributes = attributes;
|
|
4597
4623
|
node.selfClosing = this.eat(52);
|
|
4598
|
-
this.expect(
|
|
4624
|
+
this.expect(142);
|
|
4599
4625
|
return this.finishNode(node, "JSXOpeningElement");
|
|
4600
4626
|
}
|
|
4601
4627
|
jsxParseClosingElementAt(startLoc) {
|
|
4602
|
-
if (this.eat(
|
|
4628
|
+
if (this.eat(142)) {
|
|
4603
4629
|
const node = this.startNodeAt(startLoc);
|
|
4604
4630
|
return this.finishNode(node, "JSXClosingFragment");
|
|
4605
4631
|
}
|
|
4606
4632
|
const node = this.startNodeAt(startLoc);
|
|
4607
4633
|
node.name = this.jsxParseElementName();
|
|
4608
|
-
this.expect(
|
|
4634
|
+
this.expect(142);
|
|
4609
4635
|
return this.finishNode(node, "JSXClosingElement");
|
|
4610
4636
|
}
|
|
4611
4637
|
jsxParseElementAt(startLoc) {
|
|
@@ -4616,17 +4642,16 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4616
4642
|
if (!openingElement.selfClosing) {
|
|
4617
4643
|
contents: for (;;) {
|
|
4618
4644
|
switch (this.state.type) {
|
|
4619
|
-
case
|
|
4645
|
+
case 141:
|
|
4620
4646
|
startLoc = this.state.startLoc;
|
|
4621
4647
|
this.next();
|
|
4622
4648
|
if (this.eat(52)) {
|
|
4623
|
-
this.setLoc(startLoc);
|
|
4624
4649
|
closingElement = this.jsxParseClosingElementAt(startLoc);
|
|
4625
4650
|
break contents;
|
|
4626
4651
|
}
|
|
4627
4652
|
children.push(this.jsxParseElementAt(startLoc));
|
|
4628
4653
|
break;
|
|
4629
|
-
case
|
|
4654
|
+
case 140:
|
|
4630
4655
|
children.push(this.parseLiteral(this.state.value, "JSXText"));
|
|
4631
4656
|
break;
|
|
4632
4657
|
case 2:
|
|
@@ -4684,10 +4709,10 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4684
4709
|
context[context.length - 1] = newContext;
|
|
4685
4710
|
}
|
|
4686
4711
|
parseExprAtom(refExpressionErrors) {
|
|
4687
|
-
if (this.match(
|
|
4712
|
+
if (this.match(141)) {
|
|
4688
4713
|
return this.jsxParseElement();
|
|
4689
4714
|
} else if (this.match(43) && this.input.charCodeAt(this.state.pos) !== 33) {
|
|
4690
|
-
this.replaceToken(
|
|
4715
|
+
this.replaceToken(141);
|
|
4691
4716
|
return this.jsxParseElement();
|
|
4692
4717
|
} else {
|
|
4693
4718
|
return super.parseExprAtom(refExpressionErrors);
|
|
@@ -4710,7 +4735,7 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4710
4735
|
}
|
|
4711
4736
|
if (code === 62) {
|
|
4712
4737
|
++this.state.pos;
|
|
4713
|
-
this.finishToken(
|
|
4738
|
+
this.finishToken(142);
|
|
4714
4739
|
return;
|
|
4715
4740
|
}
|
|
4716
4741
|
if ((code === 34 || code === 39) && context === types.j_oTag) {
|
|
@@ -4720,7 +4745,7 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4720
4745
|
}
|
|
4721
4746
|
if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
|
|
4722
4747
|
++this.state.pos;
|
|
4723
|
-
this.finishToken(
|
|
4748
|
+
this.finishToken(141);
|
|
4724
4749
|
return;
|
|
4725
4750
|
}
|
|
4726
4751
|
super.getTokenFromCode(code);
|
|
@@ -4730,12 +4755,12 @@ const jsx = superClass => class JSXParserMixin extends superClass {
|
|
|
4730
4755
|
context,
|
|
4731
4756
|
type
|
|
4732
4757
|
} = this.state;
|
|
4733
|
-
if (type === 52 && prevType ===
|
|
4758
|
+
if (type === 52 && prevType === 141) {
|
|
4734
4759
|
context.splice(-2, 2, types.j_cTag);
|
|
4735
4760
|
this.state.canStartJSXElement = false;
|
|
4736
|
-
} else if (type ===
|
|
4761
|
+
} else if (type === 141) {
|
|
4737
4762
|
context.push(types.j_oTag);
|
|
4738
|
-
} else if (type ===
|
|
4763
|
+
} else if (type === 142) {
|
|
4739
4764
|
const out = context[context.length - 1];
|
|
4740
4765
|
if (out === types.j_oTag && prevType === 52 || out === types.j_cTag) {
|
|
4741
4766
|
context.pop();
|
|
@@ -5009,6 +5034,10 @@ class CommentsParser extends BaseParser {
|
|
|
5009
5034
|
case "ImportDeclaration":
|
|
5010
5035
|
adjustInnerComments(node, node.specifiers, commentWS);
|
|
5011
5036
|
break;
|
|
5037
|
+
case "ImportNamespaceSpecifier":
|
|
5038
|
+
case "ExportNamespaceSpecifier":
|
|
5039
|
+
adjustInnerComments(node, node.exportsFilter ?? [], commentWS);
|
|
5040
|
+
break;
|
|
5012
5041
|
case "TSEnumBody":
|
|
5013
5042
|
adjustInnerComments(node, node.members, commentWS);
|
|
5014
5043
|
break;
|
|
@@ -5047,6 +5076,12 @@ class CommentsParser extends BaseParser {
|
|
|
5047
5076
|
commentWS.leadingNode = null;
|
|
5048
5077
|
}
|
|
5049
5078
|
}
|
|
5079
|
+
replaceNodeInPendingComments(oldNode, newNode) {
|
|
5080
|
+
for (const commentWS of this.state.commentStack) {
|
|
5081
|
+
if (commentWS.leadingNode === oldNode) commentWS.leadingNode = newNode;
|
|
5082
|
+
if (commentWS.trailingNode === oldNode) commentWS.trailingNode = newNode;
|
|
5083
|
+
}
|
|
5084
|
+
}
|
|
5050
5085
|
takeSurroundingComments(node, start, end) {
|
|
5051
5086
|
const {
|
|
5052
5087
|
commentStack
|
|
@@ -5162,7 +5197,7 @@ class State {
|
|
|
5162
5197
|
commentsLen = 0;
|
|
5163
5198
|
commentStack = [];
|
|
5164
5199
|
pos = 0;
|
|
5165
|
-
type =
|
|
5200
|
+
type = 138;
|
|
5166
5201
|
value = null;
|
|
5167
5202
|
start = 0;
|
|
5168
5203
|
end = 0;
|
|
@@ -5581,6 +5616,7 @@ class Tokenizer extends CommentsParser {
|
|
|
5581
5616
|
end: state.end,
|
|
5582
5617
|
context: [this.curContext()],
|
|
5583
5618
|
inType: state.inType,
|
|
5619
|
+
strict: state.strict,
|
|
5584
5620
|
startLoc: state.startLoc,
|
|
5585
5621
|
lastTokEndLoc: state.lastTokEndLoc,
|
|
5586
5622
|
curLine: state.curLine,
|
|
@@ -5647,7 +5683,7 @@ class Tokenizer extends CommentsParser {
|
|
|
5647
5683
|
this.state.start = this.state.pos;
|
|
5648
5684
|
if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
|
|
5649
5685
|
if (this.state.pos >= this.length) {
|
|
5650
|
-
this.finishToken(
|
|
5686
|
+
this.finishToken(138);
|
|
5651
5687
|
return;
|
|
5652
5688
|
}
|
|
5653
5689
|
this.getTokenFromCode(this.codePointAtPos(this.state.pos));
|
|
@@ -5823,10 +5859,10 @@ class Tokenizer extends CommentsParser {
|
|
|
5823
5859
|
}
|
|
5824
5860
|
if (isIdentifierStart(next)) {
|
|
5825
5861
|
++this.state.pos;
|
|
5826
|
-
this.finishToken(
|
|
5862
|
+
this.finishToken(137, this.readWord1(next));
|
|
5827
5863
|
} else if (next === 92) {
|
|
5828
5864
|
++this.state.pos;
|
|
5829
|
-
this.finishToken(
|
|
5865
|
+
this.finishToken(137, this.readWord1());
|
|
5830
5866
|
} else {
|
|
5831
5867
|
this.finishOp(23, 1);
|
|
5832
5868
|
}
|
|
@@ -6206,7 +6242,7 @@ class Tokenizer extends CommentsParser {
|
|
|
6206
6242
|
mods += char;
|
|
6207
6243
|
}
|
|
6208
6244
|
this.state.pos = pos;
|
|
6209
|
-
this.finishToken(
|
|
6245
|
+
this.finishToken(136, {
|
|
6210
6246
|
pattern: content,
|
|
6211
6247
|
flags: mods
|
|
6212
6248
|
});
|
|
@@ -6219,41 +6255,63 @@ class Tokenizer extends CommentsParser {
|
|
|
6219
6255
|
this.state.pos = pos;
|
|
6220
6256
|
return n;
|
|
6221
6257
|
}
|
|
6258
|
+
readLiteralInt(radix) {
|
|
6259
|
+
let pos = this.state.pos;
|
|
6260
|
+
let val = 0;
|
|
6261
|
+
let code;
|
|
6262
|
+
for (;;) {
|
|
6263
|
+
code = this.input.charCodeAt(pos);
|
|
6264
|
+
let digit;
|
|
6265
|
+
if (code >= 48 && code <= 57) {
|
|
6266
|
+
digit = code - 48;
|
|
6267
|
+
} else {
|
|
6268
|
+
digit = (code | 0x20) - 97;
|
|
6269
|
+
if (digit < 0 || digit > 5) break;
|
|
6270
|
+
digit += 10;
|
|
6271
|
+
}
|
|
6272
|
+
if (digit >= radix) break;
|
|
6273
|
+
val = val * radix + digit;
|
|
6274
|
+
++pos;
|
|
6275
|
+
}
|
|
6276
|
+
if (code === 95 || code >= 48 && code <= 57) {
|
|
6277
|
+
return this.readInt(radix);
|
|
6278
|
+
}
|
|
6279
|
+
if (pos === this.state.pos) return null;
|
|
6280
|
+
this.state.pos = pos;
|
|
6281
|
+
return val;
|
|
6282
|
+
}
|
|
6222
6283
|
readRadixNumber(radix) {
|
|
6223
6284
|
const start = this.state.pos;
|
|
6224
6285
|
const startLoc = this.state.curPosition();
|
|
6225
|
-
let isBigInt = false;
|
|
6226
6286
|
this.state.pos += 2;
|
|
6227
|
-
|
|
6287
|
+
let val = this.readLiteralInt(radix);
|
|
6288
|
+
const end = this.state.pos;
|
|
6228
6289
|
if (val == null) {
|
|
6229
6290
|
this.raise(Errors.InvalidDigit, createPositionWithColumnOffset(startLoc, 2), {
|
|
6230
6291
|
radix
|
|
6231
6292
|
});
|
|
6232
6293
|
}
|
|
6233
|
-
const
|
|
6234
|
-
if (
|
|
6235
|
-
++this.state.pos;
|
|
6236
|
-
isBigInt = true;
|
|
6237
|
-
}
|
|
6294
|
+
const isBigInt = this.input.charCodeAt(this.state.pos) === 110;
|
|
6295
|
+
if (isBigInt) ++this.state.pos;
|
|
6238
6296
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
|
|
6239
6297
|
throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
|
|
6240
6298
|
}
|
|
6241
|
-
if (isBigInt) {
|
|
6242
|
-
const str = this.input.slice(start,
|
|
6243
|
-
|
|
6244
|
-
|
|
6299
|
+
if (isBigInt || val !== null && val > Number.MAX_SAFE_INTEGER) {
|
|
6300
|
+
const str = this.input.slice(start, end).replaceAll("_", "");
|
|
6301
|
+
if (isBigInt) {
|
|
6302
|
+
this.finishToken(135, str);
|
|
6303
|
+
return;
|
|
6304
|
+
}
|
|
6305
|
+
val = Number(radix !== 16 && this.optionFlags & 4096 ? str.replace(radix === 2 ? /[2-9]/g : /[89]/g, "0") : str);
|
|
6245
6306
|
}
|
|
6246
|
-
this.finishToken(
|
|
6307
|
+
this.finishToken(134, val);
|
|
6247
6308
|
}
|
|
6248
6309
|
readNumber(startsWithDot) {
|
|
6249
6310
|
const start = this.state.pos;
|
|
6250
6311
|
const startLoc = this.state.curPosition();
|
|
6251
6312
|
let isFloat = false;
|
|
6252
|
-
let isBigInt = false;
|
|
6253
6313
|
let isOctal = false;
|
|
6254
|
-
|
|
6255
|
-
this.raise(Errors.InvalidNumber, this.state.curPosition());
|
|
6256
|
-
}
|
|
6314
|
+
const integerValue = startsWithDot ? 0 : this.readLiteralInt(10);
|
|
6257
6315
|
const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
|
|
6258
6316
|
if (hasLeadingZero) {
|
|
6259
6317
|
const integer = this.input.slice(start, this.state.pos);
|
|
@@ -6264,12 +6322,12 @@ class Tokenizer extends CommentsParser {
|
|
|
6264
6322
|
this.raise(Errors.ZeroDigitNumericSeparator, createPositionWithColumnOffset(startLoc, underscorePos));
|
|
6265
6323
|
}
|
|
6266
6324
|
}
|
|
6267
|
-
isOctal =
|
|
6325
|
+
isOctal = !/[89]/.test(integer);
|
|
6268
6326
|
}
|
|
6269
6327
|
let next = this.input.charCodeAt(this.state.pos);
|
|
6270
6328
|
if (next === 46 && !isOctal) {
|
|
6271
6329
|
++this.state.pos;
|
|
6272
|
-
this.
|
|
6330
|
+
this.readLiteralInt(10);
|
|
6273
6331
|
isFloat = true;
|
|
6274
6332
|
next = this.input.charCodeAt(this.state.pos);
|
|
6275
6333
|
}
|
|
@@ -6278,29 +6336,34 @@ class Tokenizer extends CommentsParser {
|
|
|
6278
6336
|
if (next === 43 || next === 45) {
|
|
6279
6337
|
++this.state.pos;
|
|
6280
6338
|
}
|
|
6281
|
-
if (this.
|
|
6339
|
+
if (this.readLiteralInt(10) === null) {
|
|
6282
6340
|
this.raise(Errors.InvalidOrMissingExponent, startLoc);
|
|
6283
6341
|
}
|
|
6284
6342
|
isFloat = true;
|
|
6285
6343
|
next = this.input.charCodeAt(this.state.pos);
|
|
6286
6344
|
}
|
|
6287
|
-
const
|
|
6288
|
-
|
|
6345
|
+
const end = this.state.pos;
|
|
6346
|
+
const isBigInt = next === 110;
|
|
6347
|
+
if (isBigInt) {
|
|
6289
6348
|
if (isFloat || hasLeadingZero) {
|
|
6290
6349
|
this.raise(Errors.InvalidBigIntLiteral, startLoc);
|
|
6291
6350
|
}
|
|
6292
6351
|
++this.state.pos;
|
|
6293
|
-
isBigInt = true;
|
|
6294
6352
|
}
|
|
6295
6353
|
if (isIdentifierStart(this.codePointAtPos(this.state.pos))) {
|
|
6296
6354
|
throw this.raise(Errors.NumberIdentifier, this.state.curPosition());
|
|
6297
6355
|
}
|
|
6356
|
+
if (!isFloat && !isBigInt && !hasLeadingZero && integerValue <= Number.MAX_SAFE_INTEGER) {
|
|
6357
|
+
this.finishToken(134, integerValue);
|
|
6358
|
+
return;
|
|
6359
|
+
}
|
|
6360
|
+
const str = this.input.slice(start, end).replaceAll("_", "");
|
|
6298
6361
|
if (isBigInt) {
|
|
6299
|
-
this.finishToken(
|
|
6362
|
+
this.finishToken(135, str);
|
|
6300
6363
|
return;
|
|
6301
6364
|
}
|
|
6302
6365
|
const val = isOctal ? parseInt(str, 8) : parseFloat(str);
|
|
6303
|
-
this.finishToken(
|
|
6366
|
+
this.finishToken(134, val);
|
|
6304
6367
|
}
|
|
6305
6368
|
readCodePoint(throwOnInvalid) {
|
|
6306
6369
|
const {
|
|
@@ -6320,7 +6383,7 @@ class Tokenizer extends CommentsParser {
|
|
|
6320
6383
|
this.state.pos = pos + 1;
|
|
6321
6384
|
this.state.lineStart = lineStart;
|
|
6322
6385
|
this.state.curLine = curLine;
|
|
6323
|
-
this.finishToken(
|
|
6386
|
+
this.finishToken(133, str);
|
|
6324
6387
|
}
|
|
6325
6388
|
readTemplateContinuation() {
|
|
6326
6389
|
if (!this.match(4)) {
|
|
@@ -6352,6 +6415,7 @@ class Tokenizer extends CommentsParser {
|
|
|
6352
6415
|
}
|
|
6353
6416
|
}
|
|
6354
6417
|
recordStrictModeErrors(toParseError, at) {
|
|
6418
|
+
if (this.isLookahead) return;
|
|
6355
6419
|
const index = at.index;
|
|
6356
6420
|
if (this.state.strict && !this.state.strictErrors.has(index)) {
|
|
6357
6421
|
this.raise(toParseError, at);
|
|
@@ -6402,7 +6466,7 @@ class Tokenizer extends CommentsParser {
|
|
|
6402
6466
|
if (type !== undefined) {
|
|
6403
6467
|
this.finishToken(type, tokenLabelName(type));
|
|
6404
6468
|
} else {
|
|
6405
|
-
this.finishToken(
|
|
6469
|
+
this.finishToken(131, word);
|
|
6406
6470
|
}
|
|
6407
6471
|
}
|
|
6408
6472
|
checkKeywordEscapes() {
|
|
@@ -6577,6 +6641,9 @@ class ExpressionScope {
|
|
|
6577
6641
|
isCertainlyParameterDeclaration() {
|
|
6578
6642
|
return this.type === 3;
|
|
6579
6643
|
}
|
|
6644
|
+
isInitializer() {
|
|
6645
|
+
return this.type === 4;
|
|
6646
|
+
}
|
|
6580
6647
|
}
|
|
6581
6648
|
class ArrowHeadParsingScope extends ExpressionScope {
|
|
6582
6649
|
declarationErrors = new Map();
|
|
@@ -6605,6 +6672,10 @@ class ExpressionScopeHandler {
|
|
|
6605
6672
|
exit() {
|
|
6606
6673
|
this.stack.pop();
|
|
6607
6674
|
}
|
|
6675
|
+
canBeInParameters() {
|
|
6676
|
+
const scope = this.stack[this.stack.length - 1];
|
|
6677
|
+
return scope.canBeArrowParameterDeclaration() || scope.isCertainlyParameterDeclaration();
|
|
6678
|
+
}
|
|
6608
6679
|
recordParameterInitializerError(toParseError, loc) {
|
|
6609
6680
|
const {
|
|
6610
6681
|
stack
|
|
@@ -6614,7 +6685,7 @@ class ExpressionScopeHandler {
|
|
|
6614
6685
|
while (!scope.isCertainlyParameterDeclaration()) {
|
|
6615
6686
|
if (scope.canBeArrowParameterDeclaration()) {
|
|
6616
6687
|
scope.recordDeclarationError(toParseError, loc);
|
|
6617
|
-
} else {
|
|
6688
|
+
} else if (!scope.isInitializer()) {
|
|
6618
6689
|
return;
|
|
6619
6690
|
}
|
|
6620
6691
|
scope = stack[--i];
|
|
@@ -6639,13 +6710,15 @@ class ExpressionScopeHandler {
|
|
|
6639
6710
|
const {
|
|
6640
6711
|
stack
|
|
6641
6712
|
} = this;
|
|
6642
|
-
let i = stack.length - 1
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
|
|
6713
|
+
for (let i = stack.length - 1;; i--) {
|
|
6714
|
+
const scope = stack[i];
|
|
6715
|
+
if (scope.canBeArrowParameterDeclaration()) {
|
|
6716
|
+
if (scope.type === 2) {
|
|
6717
|
+
scope.recordDeclarationError(Errors.AwaitBindingIdentifier, at);
|
|
6718
|
+
}
|
|
6719
|
+
} else if (!scope.isInitializer()) {
|
|
6720
|
+
return;
|
|
6647
6721
|
}
|
|
6648
|
-
scope = stack[--i];
|
|
6649
6722
|
}
|
|
6650
6723
|
}
|
|
6651
6724
|
validateAsPattern() {
|
|
@@ -6656,27 +6729,26 @@ class ExpressionScopeHandler {
|
|
|
6656
6729
|
if (!currentScope.canBeArrowParameterDeclaration()) return;
|
|
6657
6730
|
currentScope.iterateErrors((toParseError, key) => {
|
|
6658
6731
|
this.parser.raise(toParseError, key);
|
|
6659
|
-
let i = stack.length - 2
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
scope
|
|
6732
|
+
for (let i = stack.length - 2;; i--) {
|
|
6733
|
+
const scope = stack[i];
|
|
6734
|
+
if (scope.canBeArrowParameterDeclaration()) {
|
|
6735
|
+
scope.clearDeclarationError(key);
|
|
6736
|
+
} else if (!scope.isInitializer()) {
|
|
6737
|
+
break;
|
|
6738
|
+
}
|
|
6664
6739
|
}
|
|
6665
6740
|
});
|
|
6666
6741
|
}
|
|
6667
6742
|
}
|
|
6668
|
-
function newParameterDeclarationScope() {
|
|
6669
|
-
return new ExpressionScope(3);
|
|
6670
|
-
}
|
|
6671
6743
|
function newArrowHeadScope() {
|
|
6672
6744
|
return new ArrowHeadParsingScope(1);
|
|
6673
6745
|
}
|
|
6674
6746
|
function newAsyncArrowScope() {
|
|
6675
6747
|
return new ArrowHeadParsingScope(2);
|
|
6676
6748
|
}
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6749
|
+
const sharedExpressionScope = new ExpressionScope();
|
|
6750
|
+
const parameterDeclarationScope = new ExpressionScope(3);
|
|
6751
|
+
const initializerScope = new ExpressionScope(4);
|
|
6680
6752
|
class ProductionParameterHandler {
|
|
6681
6753
|
stacks = [];
|
|
6682
6754
|
enter(flags) {
|
|
@@ -6732,7 +6804,7 @@ class UtilParser extends Tokenizer {
|
|
|
6732
6804
|
isUnparsedContextual(nameStart, name) {
|
|
6733
6805
|
if (this.input.startsWith(name, nameStart)) {
|
|
6734
6806
|
const nextCh = this.input.charCodeAt(nameStart + name.length);
|
|
6735
|
-
return !(isIdentifierChar(nextCh) || (nextCh & 0xfc00) === 0xd800);
|
|
6807
|
+
return !(isIdentifierChar(nextCh) || nextCh === 92 || (nextCh & 0xfc00) === 0xd800);
|
|
6736
6808
|
}
|
|
6737
6809
|
return false;
|
|
6738
6810
|
}
|
|
@@ -6756,7 +6828,7 @@ class UtilParser extends Tokenizer {
|
|
|
6756
6828
|
}
|
|
6757
6829
|
}
|
|
6758
6830
|
canInsertSemicolon() {
|
|
6759
|
-
return this.match(
|
|
6831
|
+
return this.match(138) || this.match(4) || this.hasPrecedingLineBreak();
|
|
6760
6832
|
}
|
|
6761
6833
|
hasPrecedingLineBreak() {
|
|
6762
6834
|
return hasNewLine(this.input, this.offsetToSourcePos(this.state.lastTokEndLoc.index), this.state.start);
|
|
@@ -6776,10 +6848,28 @@ class UtilParser extends Tokenizer {
|
|
|
6776
6848
|
this.unexpected(loc, type);
|
|
6777
6849
|
}
|
|
6778
6850
|
}
|
|
6851
|
+
snapshotScopeStacks() {
|
|
6852
|
+
return {
|
|
6853
|
+
scopeDepth: this.scope.scopeStack.length,
|
|
6854
|
+
prodParamDepth: this.prodParam.stacks.length,
|
|
6855
|
+
classScopeDepth: this.classScope.stack.length,
|
|
6856
|
+
expressionScopeDepth: this.expressionScope.stack.length
|
|
6857
|
+
};
|
|
6858
|
+
}
|
|
6859
|
+
restoreScopeStacks(snapshot) {
|
|
6860
|
+
const {
|
|
6861
|
+
scope
|
|
6862
|
+
} = this;
|
|
6863
|
+
while (scope.scopeStack.length > snapshot.scopeDepth) scope.exit();
|
|
6864
|
+
this.prodParam.stacks.length = snapshot.prodParamDepth;
|
|
6865
|
+
this.classScope.stack.length = snapshot.classScopeDepth;
|
|
6866
|
+
this.expressionScope.stack.length = snapshot.expressionScopeDepth;
|
|
6867
|
+
}
|
|
6779
6868
|
tryParse(fn, oldState = this.state.clone()) {
|
|
6780
6869
|
const abortSignal = {
|
|
6781
6870
|
node: null
|
|
6782
6871
|
};
|
|
6872
|
+
const scopeStacksSnapshot = this.snapshotScopeStacks();
|
|
6783
6873
|
try {
|
|
6784
6874
|
const node = fn((node = null) => {
|
|
6785
6875
|
abortSignal.node = node;
|
|
@@ -6807,6 +6897,7 @@ class UtilParser extends Tokenizer {
|
|
|
6807
6897
|
} catch (error) {
|
|
6808
6898
|
const failState = this.state;
|
|
6809
6899
|
this.state = oldState;
|
|
6900
|
+
this.restoreScopeStacks(scopeStacksSnapshot);
|
|
6810
6901
|
if (error instanceof SyntaxError) {
|
|
6811
6902
|
return {
|
|
6812
6903
|
node: null,
|
|
@@ -6957,13 +7048,10 @@ class NodeUtils extends UtilParser {
|
|
|
6957
7048
|
return loc;
|
|
6958
7049
|
}
|
|
6959
7050
|
startNode() {
|
|
6960
|
-
|
|
6961
|
-
startLoc
|
|
6962
|
-
} = this.state;
|
|
6963
|
-
this.setLoc(startLoc);
|
|
6964
|
-
return this.startNodeAt(startLoc);
|
|
7051
|
+
return this.startNodeAt(this.state.startLoc);
|
|
6965
7052
|
}
|
|
6966
7053
|
startNodeAt(loc) {
|
|
7054
|
+
this.setLoc(loc);
|
|
6967
7055
|
const {
|
|
6968
7056
|
optionFlags,
|
|
6969
7057
|
filename
|
|
@@ -7099,6 +7187,20 @@ const unwrapParenthesizedExpression = node => {
|
|
|
7099
7187
|
return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
|
|
7100
7188
|
};
|
|
7101
7189
|
class LValParser extends NodeUtils {
|
|
7190
|
+
raiseOnce(toParseError, node) {
|
|
7191
|
+
const {
|
|
7192
|
+
errors
|
|
7193
|
+
} = this.state;
|
|
7194
|
+
const length = errors.length;
|
|
7195
|
+
const error = this.raise(toParseError, node);
|
|
7196
|
+
if (errors.length === length) return;
|
|
7197
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
7198
|
+
if (errors[i].pos === error.pos && errors[i].reasonCode === error.reasonCode) {
|
|
7199
|
+
errors.pop();
|
|
7200
|
+
return;
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7102
7204
|
toAssignable(node, isLHS = false) {
|
|
7103
7205
|
let parenthesized = undefined;
|
|
7104
7206
|
if (node.type === "ParenthesizedExpression" || node.extra?.parenthesized) {
|
|
@@ -7107,10 +7209,10 @@ class LValParser extends NodeUtils {
|
|
|
7107
7209
|
if (parenthesized.type === "Identifier") {
|
|
7108
7210
|
this.expressionScope.recordArrowParameterBindingError(Errors.InvalidParenthesizedAssignment, node);
|
|
7109
7211
|
} else if (parenthesized.type !== "CallExpression" && parenthesized.type !== "MemberExpression" && !this.isOptionalMemberExpression(parenthesized)) {
|
|
7110
|
-
this.
|
|
7212
|
+
this.raiseOnce(Errors.InvalidParenthesizedAssignment, node);
|
|
7111
7213
|
}
|
|
7112
7214
|
} else {
|
|
7113
|
-
this.
|
|
7215
|
+
this.raiseOnce(Errors.InvalidParenthesizedAssignment, node);
|
|
7114
7216
|
}
|
|
7115
7217
|
}
|
|
7116
7218
|
switch (node.type) {
|
|
@@ -7336,7 +7438,7 @@ class LValParser extends NodeUtils {
|
|
|
7336
7438
|
return this.parseBindingRestProperty(this.startNode());
|
|
7337
7439
|
}
|
|
7338
7440
|
const prop = this.startNode();
|
|
7339
|
-
if (type ===
|
|
7441
|
+
if (type === 137) {
|
|
7340
7442
|
this.expectPlugin("destructuringPrivate", startLoc);
|
|
7341
7443
|
this.classScope.usePrivateName(this.state.value, startLoc);
|
|
7342
7444
|
prop.key = this.parsePrivateName();
|
|
@@ -7543,11 +7645,11 @@ class ExpressionParser extends LValParser {
|
|
|
7543
7645
|
getExpression() {
|
|
7544
7646
|
this.enterInitialScopes();
|
|
7545
7647
|
this.nextToken();
|
|
7546
|
-
if (this.match(
|
|
7648
|
+
if (this.match(138)) {
|
|
7547
7649
|
throw this.raise(Errors.ParseExpressionEmptyInput, this.state.startLoc);
|
|
7548
7650
|
}
|
|
7549
7651
|
const expr = this.parseExpression();
|
|
7550
|
-
if (!this.match(
|
|
7652
|
+
if (!this.match(138)) {
|
|
7551
7653
|
throw this.raise(Errors.ParseExpressionExpectsEOF, this.state.startLoc, {
|
|
7552
7654
|
unexpected: this.input.codePointAt(this.state.start)
|
|
7553
7655
|
});
|
|
@@ -7591,7 +7693,7 @@ class ExpressionParser extends LValParser {
|
|
|
7591
7693
|
}
|
|
7592
7694
|
parseMaybeAssign(refExpressionErrors, isParenItem) {
|
|
7593
7695
|
const startLoc = this.state.startLoc;
|
|
7594
|
-
const isYield = this.isContextual(
|
|
7696
|
+
const isYield = this.isContextual(107);
|
|
7595
7697
|
if (isYield) {
|
|
7596
7698
|
if (this.prodParam.hasYield) {
|
|
7597
7699
|
this.next();
|
|
@@ -7603,11 +7705,16 @@ class ExpressionParser extends LValParser {
|
|
|
7603
7705
|
}
|
|
7604
7706
|
}
|
|
7605
7707
|
let ownExpressionErrors;
|
|
7708
|
+
let inInitializerScope = false;
|
|
7606
7709
|
if (refExpressionErrors) {
|
|
7607
7710
|
ownExpressionErrors = false;
|
|
7608
7711
|
} else {
|
|
7609
7712
|
refExpressionErrors = new ExpressionErrors();
|
|
7610
7713
|
ownExpressionErrors = true;
|
|
7714
|
+
if (this.expressionScope.canBeInParameters()) {
|
|
7715
|
+
this.expressionScope.enter(initializerScope);
|
|
7716
|
+
inInitializerScope = true;
|
|
7717
|
+
}
|
|
7611
7718
|
}
|
|
7612
7719
|
this.state.canStartArrow = true;
|
|
7613
7720
|
let left = this.parseMaybeConditional(refExpressionErrors);
|
|
@@ -7640,10 +7747,12 @@ class ExpressionParser extends LValParser {
|
|
|
7640
7747
|
}
|
|
7641
7748
|
this.next();
|
|
7642
7749
|
node.right = this.parseMaybeAssign();
|
|
7750
|
+
if (inInitializerScope) this.expressionScope.exit();
|
|
7643
7751
|
this.checkLVal(left, this.finishNode(node, "AssignmentExpression"), undefined, undefined, undefined, undefined, operator === "||=" || operator === "&&=" || operator === "??=");
|
|
7644
7752
|
return node;
|
|
7645
7753
|
} else if (ownExpressionErrors) {
|
|
7646
7754
|
this.checkExpressionErrors(refExpressionErrors, true);
|
|
7755
|
+
if (inInitializerScope) this.expressionScope.exit();
|
|
7647
7756
|
}
|
|
7648
7757
|
if (isYield) {
|
|
7649
7758
|
const {
|
|
@@ -7677,7 +7786,7 @@ class ExpressionParser extends LValParser {
|
|
|
7677
7786
|
return expr;
|
|
7678
7787
|
}
|
|
7679
7788
|
parseMaybeUnaryOrPrivate(refExpressionErrors) {
|
|
7680
|
-
return this.match(
|
|
7789
|
+
return this.match(137) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
|
|
7681
7790
|
}
|
|
7682
7791
|
parseExprOps(refExpressionErrors) {
|
|
7683
7792
|
const startLoc = this.state.startLoc;
|
|
@@ -7846,7 +7955,6 @@ class ExpressionParser extends LValParser {
|
|
|
7846
7955
|
}
|
|
7847
7956
|
parseExprSubscripts(refExpressionErrors) {
|
|
7848
7957
|
const startLoc = this.state.startLoc;
|
|
7849
|
-
this.setLoc(startLoc);
|
|
7850
7958
|
if (refExpressionErrors != null && (this.match(2) || this.match(0))) {
|
|
7851
7959
|
const atomExpressionErrors = new ExpressionErrors();
|
|
7852
7960
|
const expr = this.parseExprAtom(atomExpressionErrors);
|
|
@@ -7922,7 +8030,7 @@ class ExpressionParser extends LValParser {
|
|
|
7922
8030
|
if (computed) {
|
|
7923
8031
|
node.property = this.parseExpression();
|
|
7924
8032
|
this.expect(1);
|
|
7925
|
-
} else if (this.match(
|
|
8033
|
+
} else if (this.match(137)) {
|
|
7926
8034
|
if (base.type === "Super") {
|
|
7927
8035
|
this.raise(Errors.SuperPrivateField, startLoc);
|
|
7928
8036
|
}
|
|
@@ -8073,7 +8181,7 @@ class ExpressionParser extends LValParser {
|
|
|
8073
8181
|
node = this.startNode();
|
|
8074
8182
|
this.next();
|
|
8075
8183
|
if (this.match(12)) {
|
|
8076
|
-
return this.
|
|
8184
|
+
return this.parseImportMetaPropertyOrPhaseCallOrSyncCall(node);
|
|
8077
8185
|
}
|
|
8078
8186
|
if (this.match(6)) {
|
|
8079
8187
|
if (this.optionFlags & 1024) {
|
|
@@ -8099,11 +8207,11 @@ class ExpressionParser extends LValParser {
|
|
|
8099
8207
|
this.readRegexp();
|
|
8100
8208
|
return this.parseRegExpLiteral(this.state.value);
|
|
8101
8209
|
}
|
|
8102
|
-
case
|
|
8210
|
+
case 134:
|
|
8103
8211
|
return this.parseNumericLiteral(this.state.value);
|
|
8104
|
-
case
|
|
8212
|
+
case 135:
|
|
8105
8213
|
return this.parseBigIntLiteral(this.state.value);
|
|
8106
|
-
case
|
|
8214
|
+
case 133:
|
|
8107
8215
|
return this.parseStringLiteral(this.state.value);
|
|
8108
8216
|
case 80:
|
|
8109
8217
|
return this.parseNullLiteral();
|
|
@@ -8148,7 +8256,7 @@ class ExpressionParser extends LValParser {
|
|
|
8148
8256
|
throw this.raise(Errors.UnsupportedBind, callee);
|
|
8149
8257
|
}
|
|
8150
8258
|
}
|
|
8151
|
-
case
|
|
8259
|
+
case 137:
|
|
8152
8260
|
{
|
|
8153
8261
|
this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
|
|
8154
8262
|
identifierName: this.state.value
|
|
@@ -8182,13 +8290,13 @@ class ExpressionParser extends LValParser {
|
|
|
8182
8290
|
{
|
|
8183
8291
|
const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
|
|
8184
8292
|
if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
|
|
8185
|
-
|
|
8293
|
+
this.expectOnePlugin(["jsx", "flow", "typescript"]);
|
|
8186
8294
|
}
|
|
8187
8295
|
throw this.unexpected();
|
|
8188
8296
|
}
|
|
8189
8297
|
default:
|
|
8190
8298
|
if (tokenIsIdentifier(type)) {
|
|
8191
|
-
if (this.isContextual(
|
|
8299
|
+
if (this.isContextual(126) && this.lookaheadInLineCharCode() === 123) {
|
|
8192
8300
|
return this.parseModuleExpression();
|
|
8193
8301
|
}
|
|
8194
8302
|
const {
|
|
@@ -8346,7 +8454,7 @@ class ExpressionParser extends LValParser {
|
|
|
8346
8454
|
}
|
|
8347
8455
|
return this.finishNode(node, "MetaProperty");
|
|
8348
8456
|
}
|
|
8349
|
-
|
|
8457
|
+
parseImportMetaPropertyOrPhaseCallOrSyncCall(node) {
|
|
8350
8458
|
this.next();
|
|
8351
8459
|
if (this.isContextual(102) || this.isContextual(94)) {
|
|
8352
8460
|
const isSource = this.isContextual(102);
|
|
@@ -8354,6 +8462,11 @@ class ExpressionParser extends LValParser {
|
|
|
8354
8462
|
this.next();
|
|
8355
8463
|
node.phase = isSource ? "source" : "defer";
|
|
8356
8464
|
return this.parseImportCall(node);
|
|
8465
|
+
} else if (this.isContextual(105)) {
|
|
8466
|
+
this.expectPlugin("importSync");
|
|
8467
|
+
this.next();
|
|
8468
|
+
node.sync = true;
|
|
8469
|
+
return this.parseImportCall(node);
|
|
8357
8470
|
} else {
|
|
8358
8471
|
const id = this.createIdentifierAt(this.startNodeAtNode(node), "import", this.state.lastTokStartLoc);
|
|
8359
8472
|
if (this.isContextual(98)) {
|
|
@@ -8745,16 +8858,16 @@ class ExpressionParser extends LValParser {
|
|
|
8745
8858
|
key = this.parseIdentifier(true);
|
|
8746
8859
|
} else {
|
|
8747
8860
|
switch (type) {
|
|
8748
|
-
case
|
|
8861
|
+
case 134:
|
|
8749
8862
|
key = this.parseNumericLiteral(value);
|
|
8750
8863
|
break;
|
|
8751
|
-
case
|
|
8864
|
+
case 133:
|
|
8752
8865
|
key = this.parseStringLiteral(value);
|
|
8753
8866
|
break;
|
|
8754
|
-
case
|
|
8867
|
+
case 135:
|
|
8755
8868
|
key = this.parseBigIntLiteral(value);
|
|
8756
8869
|
break;
|
|
8757
|
-
case
|
|
8870
|
+
case 137:
|
|
8758
8871
|
{
|
|
8759
8872
|
const privateKeyLoc = this.state.startLoc;
|
|
8760
8873
|
if (refExpressionErrors != null) {
|
|
@@ -8772,7 +8885,7 @@ class ExpressionParser extends LValParser {
|
|
|
8772
8885
|
}
|
|
8773
8886
|
}
|
|
8774
8887
|
prop.key = key;
|
|
8775
|
-
if (type !==
|
|
8888
|
+
if (type !== 137) {
|
|
8776
8889
|
prop.computed = false;
|
|
8777
8890
|
}
|
|
8778
8891
|
}
|
|
@@ -8829,7 +8942,7 @@ class ExpressionParser extends LValParser {
|
|
|
8829
8942
|
}
|
|
8830
8943
|
parseFunctionBody(node, allowExpression, isMethod = false) {
|
|
8831
8944
|
const isExpression = allowExpression && !this.match(2);
|
|
8832
|
-
this.expressionScope.enter(
|
|
8945
|
+
this.expressionScope.enter(sharedExpressionScope);
|
|
8833
8946
|
if (isExpression) {
|
|
8834
8947
|
node.body = this.parseMaybeAssign();
|
|
8835
8948
|
this.checkParams(node, false, allowExpression, false);
|
|
@@ -8950,7 +9063,7 @@ class ExpressionParser extends LValParser {
|
|
|
8950
9063
|
const tokenIsKeyword = tokenKeywordOrIdentifierIsKeyword(type);
|
|
8951
9064
|
if (liberal) {
|
|
8952
9065
|
if (tokenIsKeyword) {
|
|
8953
|
-
this.replaceToken(
|
|
9066
|
+
this.replaceToken(131);
|
|
8954
9067
|
}
|
|
8955
9068
|
} else {
|
|
8956
9069
|
this.checkReservedWord(name, this.sourceToOffsetPos(start), tokenIsKeyword, false);
|
|
@@ -9008,7 +9121,6 @@ class ExpressionParser extends LValParser {
|
|
|
9008
9121
|
}
|
|
9009
9122
|
parseAwait(startLoc, soloAwait) {
|
|
9010
9123
|
const startIndex = startLoc.index;
|
|
9011
|
-
this.setLoc(startLoc);
|
|
9012
9124
|
const node = this.startNodeAt(startLoc);
|
|
9013
9125
|
this.expressionScope.recordParameterInitializerError(Errors.AwaitExpressionFormalParameter, startIndex);
|
|
9014
9126
|
if (this.eat(51)) {
|
|
@@ -9032,10 +9144,9 @@ class ExpressionParser extends LValParser {
|
|
|
9032
9144
|
const {
|
|
9033
9145
|
type
|
|
9034
9146
|
} = this.state;
|
|
9035
|
-
return type === 49 || type === 6 || type === 0 || tokenIsTemplate(type) || type === 99 && !this.state.containsEsc || type ===
|
|
9147
|
+
return type === 49 || type === 6 || type === 0 || tokenIsTemplate(type) || type === 99 && !this.state.containsEsc || type === 136 || type === 52 || this.hasPlugin("v8intrinsic") && type === 50;
|
|
9036
9148
|
}
|
|
9037
9149
|
parseYield(startLoc) {
|
|
9038
|
-
this.setLoc(startLoc);
|
|
9039
9150
|
const node = this.startNodeAt(startLoc);
|
|
9040
9151
|
this.expressionScope.recordParameterInitializerError(Errors.YieldInParameter, startLoc.index);
|
|
9041
9152
|
let delegating = false;
|
|
@@ -9044,7 +9155,7 @@ class ExpressionParser extends LValParser {
|
|
|
9044
9155
|
delegating = this.eat(51);
|
|
9045
9156
|
switch (this.state.type) {
|
|
9046
9157
|
case 9:
|
|
9047
|
-
case
|
|
9158
|
+
case 138:
|
|
9048
9159
|
case 4:
|
|
9049
9160
|
case 7:
|
|
9050
9161
|
case 1:
|
|
@@ -9052,6 +9163,8 @@ class ExpressionParser extends LValParser {
|
|
|
9052
9163
|
case 10:
|
|
9053
9164
|
case 8:
|
|
9054
9165
|
if (!delegating) break;
|
|
9166
|
+
case 54:
|
|
9167
|
+
if (this.options.annexB && !delegating) break;
|
|
9055
9168
|
default:
|
|
9056
9169
|
argument = this.parseMaybeAssign();
|
|
9057
9170
|
}
|
|
@@ -9191,6 +9304,7 @@ const loopLabel = {
|
|
|
9191
9304
|
};
|
|
9192
9305
|
const loneSurrogate = /[\uD800-\uDFFF]/u;
|
|
9193
9306
|
const keywordRelationalOperator = /in(?:stanceof)?/y;
|
|
9307
|
+
const keywordLikeWord = /[a-z]{2,10}/y;
|
|
9194
9308
|
function createExportedTokens(tokens) {
|
|
9195
9309
|
for (let i = 0; i < tokens.length; i++) {
|
|
9196
9310
|
const token = tokens[i];
|
|
@@ -9205,7 +9319,7 @@ function createExportedTokens(tokens) {
|
|
|
9205
9319
|
}
|
|
9206
9320
|
class StatementParser extends ExpressionParser {
|
|
9207
9321
|
parseTopLevel(file, program) {
|
|
9208
|
-
file.program = this.parseProgram(program,
|
|
9322
|
+
file.program = this.parseProgram(program, 138, this.options.sourceType === "module" ? "module" : "script");
|
|
9209
9323
|
file.comments = this.comments;
|
|
9210
9324
|
if (this.optionFlags & 512) {
|
|
9211
9325
|
file.tokens = createExportedTokens(this.tokens);
|
|
@@ -9227,7 +9341,7 @@ class StatementParser extends ExpressionParser {
|
|
|
9227
9341
|
this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait);
|
|
9228
9342
|
}
|
|
9229
9343
|
let finishedProgram;
|
|
9230
|
-
if (end ===
|
|
9344
|
+
if (end === 138) {
|
|
9231
9345
|
finishedProgram = this.finishNode(program, "Program");
|
|
9232
9346
|
} else {
|
|
9233
9347
|
finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
|
|
@@ -9263,13 +9377,13 @@ class StatementParser extends ExpressionParser {
|
|
|
9263
9377
|
return this.hasFollowingBindingAtom();
|
|
9264
9378
|
}
|
|
9265
9379
|
isUsing() {
|
|
9266
|
-
if (!this.isContextual(
|
|
9380
|
+
if (!this.isContextual(106)) {
|
|
9267
9381
|
return false;
|
|
9268
9382
|
}
|
|
9269
9383
|
return this.nextTokenIsIdentifierOnSameLine();
|
|
9270
9384
|
}
|
|
9271
9385
|
isForUsing() {
|
|
9272
|
-
if (!this.isContextual(
|
|
9386
|
+
if (!this.isContextual(106)) {
|
|
9273
9387
|
return false;
|
|
9274
9388
|
}
|
|
9275
9389
|
const next = this.nextTokenInLineStart();
|
|
@@ -9320,6 +9434,22 @@ class StatementParser extends ExpressionParser {
|
|
|
9320
9434
|
return false;
|
|
9321
9435
|
}
|
|
9322
9436
|
}
|
|
9437
|
+
isReservedWordOnNewLineAfterLet(pos) {
|
|
9438
|
+
if (!hasNewLine(this.input, this.state.end, pos)) {
|
|
9439
|
+
return false;
|
|
9440
|
+
}
|
|
9441
|
+
keywordLikeWord.lastIndex = pos;
|
|
9442
|
+
if (!keywordLikeWord.test(this.input)) {
|
|
9443
|
+
return false;
|
|
9444
|
+
}
|
|
9445
|
+
const end = keywordLikeWord.lastIndex;
|
|
9446
|
+
const endCh = this.codePointAtPos(end);
|
|
9447
|
+
if (isIdentifierChar(endCh) || endCh === 92) {
|
|
9448
|
+
return false;
|
|
9449
|
+
}
|
|
9450
|
+
const word = this.input.slice(pos, end);
|
|
9451
|
+
return isKeyword(word) || isReservedWord(word, false);
|
|
9452
|
+
}
|
|
9323
9453
|
chStartsBindingPattern(ch) {
|
|
9324
9454
|
return ch === 91 || ch === 123;
|
|
9325
9455
|
}
|
|
@@ -9388,6 +9518,13 @@ class StatementParser extends ExpressionParser {
|
|
|
9388
9518
|
case 76:
|
|
9389
9519
|
if (!allowDeclaration) this.unexpected();
|
|
9390
9520
|
return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
|
|
9521
|
+
case 104:
|
|
9522
|
+
if (!this.state.containsEsc && this.nextTokenIsIdentifierOnSameLine()) {
|
|
9523
|
+
this.expectPlugin("structs");
|
|
9524
|
+
if (!allowDeclaration) this.unexpected();
|
|
9525
|
+
return this.parseStructDeclaration(node, false);
|
|
9526
|
+
}
|
|
9527
|
+
break;
|
|
9391
9528
|
case 65:
|
|
9392
9529
|
return this.parseIfStatement(node);
|
|
9393
9530
|
case 66:
|
|
@@ -9411,7 +9548,7 @@ class StatementParser extends ExpressionParser {
|
|
|
9411
9548
|
return this.parseVarStatement(node, "await using");
|
|
9412
9549
|
}
|
|
9413
9550
|
break;
|
|
9414
|
-
case
|
|
9551
|
+
case 106:
|
|
9415
9552
|
if (this.state.containsEsc || !this.hasInLineFollowingBindingIdentifierOrBrace()) {
|
|
9416
9553
|
break;
|
|
9417
9554
|
}
|
|
@@ -9433,6 +9570,7 @@ class StatementParser extends ExpressionParser {
|
|
|
9433
9570
|
if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
|
|
9434
9571
|
break;
|
|
9435
9572
|
}
|
|
9573
|
+
if (this.isReservedWordOnNewLineAfterLet(next)) break;
|
|
9436
9574
|
}
|
|
9437
9575
|
}
|
|
9438
9576
|
case 71:
|
|
@@ -9558,7 +9696,7 @@ class StatementParser extends ExpressionParser {
|
|
|
9558
9696
|
while (this.eat(12)) {
|
|
9559
9697
|
const node = this.startNodeAt(startLoc);
|
|
9560
9698
|
node.object = expr;
|
|
9561
|
-
if (this.match(
|
|
9699
|
+
if (this.match(137)) {
|
|
9562
9700
|
this.classScope.usePrivateName(this.state.value, this.state.startLoc);
|
|
9563
9701
|
node.property = this.parsePrivateName();
|
|
9564
9702
|
} else {
|
|
@@ -10034,7 +10172,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10034
10172
|
this.scope.enter(514);
|
|
10035
10173
|
this.prodParam.enter(functionFlags(isAsync, node.generator));
|
|
10036
10174
|
if (!isDeclaration && tokenIsIdentifier(this.state.type)) {
|
|
10037
|
-
this.expressionScope.enter(
|
|
10175
|
+
this.expressionScope.enter(sharedExpressionScope);
|
|
10038
10176
|
node.id = this.parseFunctionId();
|
|
10039
10177
|
this.expressionScope.exit();
|
|
10040
10178
|
}
|
|
@@ -10052,7 +10190,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10052
10190
|
}
|
|
10053
10191
|
parseFunctionParams(node, isConstructor) {
|
|
10054
10192
|
this.expect(6);
|
|
10055
|
-
this.expressionScope.enter(
|
|
10193
|
+
this.expressionScope.enter(parameterDeclarationScope);
|
|
10056
10194
|
node.params = this.parseBindingList(7, 41, 2 | (isConstructor ? 4 : 0));
|
|
10057
10195
|
this.expressionScope.exit();
|
|
10058
10196
|
}
|
|
@@ -10164,7 +10302,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10164
10302
|
this.parsePropertyNamePrefixOperator(member);
|
|
10165
10303
|
if (this.eat(51)) {
|
|
10166
10304
|
method.kind = "method";
|
|
10167
|
-
const isPrivateName = this.match(
|
|
10305
|
+
const isPrivateName = this.match(137);
|
|
10168
10306
|
this.parseClassElementName(method);
|
|
10169
10307
|
this.parsePostMemberNameModifiers(method);
|
|
10170
10308
|
if (isPrivateName) {
|
|
@@ -10219,7 +10357,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10219
10357
|
this.unexpected(maybeQuestionTokenStartLoc);
|
|
10220
10358
|
}
|
|
10221
10359
|
method.kind = "method";
|
|
10222
|
-
const isPrivate = this.match(
|
|
10360
|
+
const isPrivate = this.match(137);
|
|
10223
10361
|
this.parseClassElementName(method);
|
|
10224
10362
|
this.parsePostMemberNameModifiers(publicMember);
|
|
10225
10363
|
if (isPrivate) {
|
|
@@ -10233,7 +10371,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10233
10371
|
} else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(51) && this.isLineTerminator())) {
|
|
10234
10372
|
this.resetPreviousNodeTrailingComments(key);
|
|
10235
10373
|
method.kind = maybeContextualKw;
|
|
10236
|
-
const isPrivate = this.match(
|
|
10374
|
+
const isPrivate = this.match(137);
|
|
10237
10375
|
this.parseClassElementName(publicMethod);
|
|
10238
10376
|
if (isPrivate) {
|
|
10239
10377
|
this.pushClassPrivateMethod(classBody, privateMethod, false, false);
|
|
@@ -10247,7 +10385,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10247
10385
|
} else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
|
|
10248
10386
|
this.expectPlugin("decoratorAutoAccessors");
|
|
10249
10387
|
this.resetPreviousNodeTrailingComments(key);
|
|
10250
|
-
const isPrivate = this.match(
|
|
10388
|
+
const isPrivate = this.match(137);
|
|
10251
10389
|
this.parseClassElementName(publicProp);
|
|
10252
10390
|
this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
|
|
10253
10391
|
} else if (this.isLineTerminator()) {
|
|
@@ -10265,10 +10403,10 @@ class StatementParser extends ExpressionParser {
|
|
|
10265
10403
|
type,
|
|
10266
10404
|
value
|
|
10267
10405
|
} = this.state;
|
|
10268
|
-
if ((type ===
|
|
10406
|
+
if ((type === 131 || type === 133) && member.static && value === "prototype") {
|
|
10269
10407
|
this.raise(Errors.StaticPrototype, this.state.startLoc);
|
|
10270
10408
|
}
|
|
10271
|
-
if (type ===
|
|
10409
|
+
if (type === 137) {
|
|
10272
10410
|
if (value === "constructor") {
|
|
10273
10411
|
this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
|
|
10274
10412
|
}
|
|
@@ -10345,7 +10483,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10345
10483
|
}
|
|
10346
10484
|
parseInitializer(node) {
|
|
10347
10485
|
this.scope.enter(576 | 16);
|
|
10348
|
-
this.expressionScope.enter(
|
|
10486
|
+
this.expressionScope.enter(sharedExpressionScope);
|
|
10349
10487
|
this.prodParam.enter(0);
|
|
10350
10488
|
node.value = this.eat(25) ? this.parseMaybeAssignAllowIn() : null;
|
|
10351
10489
|
this.expressionScope.exit();
|
|
@@ -10375,6 +10513,36 @@ class StatementParser extends ExpressionParser {
|
|
|
10375
10513
|
node.superClass = null;
|
|
10376
10514
|
}
|
|
10377
10515
|
}
|
|
10516
|
+
parseStructDeclaration(node, optionalId) {
|
|
10517
|
+
this.next();
|
|
10518
|
+
const oldStrict = this.state.strict;
|
|
10519
|
+
this.state.strict = true;
|
|
10520
|
+
this.parseClassId(node, true, optionalId);
|
|
10521
|
+
this.parseClassSuper(node);
|
|
10522
|
+
node.body = this.parseStructBody(!!node.superClass, oldStrict);
|
|
10523
|
+
return this.finishNode(node, "StructDeclaration");
|
|
10524
|
+
}
|
|
10525
|
+
parseStructBody(hadSuperClass, oldStrict) {
|
|
10526
|
+
this.classScope.enter();
|
|
10527
|
+
const state = {
|
|
10528
|
+
hadConstructor: false,
|
|
10529
|
+
hadSuperClass
|
|
10530
|
+
};
|
|
10531
|
+
const structBody = this.startNode();
|
|
10532
|
+
structBody.body = [];
|
|
10533
|
+
this.expect(2);
|
|
10534
|
+
while (!this.match(4)) {
|
|
10535
|
+
if (this.eat(9)) {
|
|
10536
|
+
continue;
|
|
10537
|
+
}
|
|
10538
|
+
const member = this.startNode();
|
|
10539
|
+
this.parseClassMember(structBody, member, state);
|
|
10540
|
+
}
|
|
10541
|
+
this.state.strict = oldStrict;
|
|
10542
|
+
this.next();
|
|
10543
|
+
this.classScope.exit();
|
|
10544
|
+
return this.finishNode(structBody, "StructBody");
|
|
10545
|
+
}
|
|
10378
10546
|
parseExport(node, decorators) {
|
|
10379
10547
|
const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, true);
|
|
10380
10548
|
const hasDefault = this.maybeParseExportDefaultSpecifier(node, maybeDefaultIdentifier);
|
|
@@ -10382,17 +10550,20 @@ class StatementParser extends ExpressionParser {
|
|
|
10382
10550
|
const hasStar = parseAfterDefault && this.eatExportStar(node);
|
|
10383
10551
|
const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
|
|
10384
10552
|
const parseAfterNamespace = parseAfterDefault && !hasNamespace;
|
|
10385
|
-
const isFromRequired = hasDefault || hasStar;
|
|
10386
10553
|
if (hasStar && !hasNamespace) {
|
|
10387
10554
|
if (hasDefault) this.unexpected();
|
|
10388
10555
|
if (decorators) {
|
|
10389
10556
|
throw this.raise(Errors.UnsupportedDecoratorExport, node);
|
|
10390
10557
|
}
|
|
10558
|
+
if (node.phase === "defer") {
|
|
10559
|
+
this.raise(Errors.DeferExportInvalidAll, node);
|
|
10560
|
+
}
|
|
10391
10561
|
this.parseExportFrom(node, true);
|
|
10392
10562
|
this.sawUnambiguousESM = true;
|
|
10393
10563
|
return this.finishNode(node, "ExportAllDeclaration");
|
|
10394
10564
|
}
|
|
10395
10565
|
const hasSpecifiers = parseAfterNamespace && this.maybeParseExportNamedSpecifiers(node);
|
|
10566
|
+
const isFromRequired = hasDefault || hasStar || node.phase === "defer" || hasSpecifiers && node.specifiers[0]?.type === "ExportNamespaceSpecifier";
|
|
10396
10567
|
if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers) {
|
|
10397
10568
|
this.unexpected(null, 2);
|
|
10398
10569
|
}
|
|
@@ -10414,6 +10585,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10414
10585
|
} else if (decorators) {
|
|
10415
10586
|
throw this.raise(Errors.UnsupportedDecoratorExport, node);
|
|
10416
10587
|
}
|
|
10588
|
+
if (this.hasPlugin("deferredReexports")) node2.phase ??= null;
|
|
10417
10589
|
this.sawUnambiguousESM = true;
|
|
10418
10590
|
return this.finishNode(node2, "ExportNamedDeclaration");
|
|
10419
10591
|
}
|
|
@@ -10467,7 +10639,19 @@ class StatementParser extends ExpressionParser {
|
|
|
10467
10639
|
const node2 = node;
|
|
10468
10640
|
if (!node2.specifiers) node2.specifiers = [];
|
|
10469
10641
|
const isTypeExport = node2.exportKind === "type";
|
|
10470
|
-
|
|
10642
|
+
const startLoc = this.state.startLoc;
|
|
10643
|
+
this.setLoc(startLoc);
|
|
10644
|
+
const specifiers = this.parseExportSpecifiers(isTypeExport);
|
|
10645
|
+
if (this.isContextual(90) && !this.hasPrecedingLineBreak()) {
|
|
10646
|
+
this.expectPlugin("namespaceImportFilter");
|
|
10647
|
+
const specifier = this.startNodeAt(startLoc);
|
|
10648
|
+
specifier.exportsFilter = this.toNamespaceExportsFilter(specifiers);
|
|
10649
|
+
this.next();
|
|
10650
|
+
specifier.exported = this.parseModuleExportName();
|
|
10651
|
+
node2.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
|
|
10652
|
+
} else {
|
|
10653
|
+
node2.specifiers.push(...specifiers);
|
|
10654
|
+
}
|
|
10471
10655
|
node2.source = null;
|
|
10472
10656
|
node2.attributes = [];
|
|
10473
10657
|
node2.declaration = null;
|
|
@@ -10503,10 +10687,18 @@ class StatementParser extends ExpressionParser {
|
|
|
10503
10687
|
if (this.match(76)) {
|
|
10504
10688
|
return this.parseClass(expr, true, true);
|
|
10505
10689
|
}
|
|
10690
|
+
if (this.isContextual(104)) {
|
|
10691
|
+
const next = this.nextTokenInLineStart();
|
|
10692
|
+
const nextCh = this.codePointAtPos(next);
|
|
10693
|
+
if (nextCh === 123 || this.chStartsBindingIdentifier(nextCh, next)) {
|
|
10694
|
+
this.expectPlugin("structs");
|
|
10695
|
+
return this.parseStructDeclaration(expr, true);
|
|
10696
|
+
}
|
|
10697
|
+
}
|
|
10506
10698
|
if (this.match(22)) {
|
|
10507
10699
|
return this.parseClass(this.maybeTakeDecorators(this.parseDecorators(false), this.startNode()), true, true);
|
|
10508
10700
|
}
|
|
10509
|
-
if (this.match(71) || this.match(70) || this.isLet() || this.isUsing() || this.isAwaitUsing()) {
|
|
10701
|
+
if (this.match(71) || this.match(70) || this.isLet() && !this.isReservedWordOnNewLineAfterLet(this.nextTokenStart()) || this.isUsing() || this.isAwaitUsing()) {
|
|
10510
10702
|
throw this.raise(Errors.UnsupportedDefaultExport, this.state.startLoc);
|
|
10511
10703
|
}
|
|
10512
10704
|
const res = this.parseMaybeAssignAllowIn();
|
|
@@ -10518,6 +10710,14 @@ class StatementParser extends ExpressionParser {
|
|
|
10518
10710
|
const node = this.parseClass(this.startNode(), true, false);
|
|
10519
10711
|
return node;
|
|
10520
10712
|
}
|
|
10713
|
+
if (this.isContextual(104) && this.nextTokenIsIdentifierOnSameLine()) {
|
|
10714
|
+
this.expectPlugin("structs");
|
|
10715
|
+
const node = this.parseStructDeclaration(this.startNode(), false);
|
|
10716
|
+
return node;
|
|
10717
|
+
}
|
|
10718
|
+
if (this.isContextual(97)) {
|
|
10719
|
+
return this.parseVarStatement(this.startNode(), "let");
|
|
10720
|
+
}
|
|
10521
10721
|
return this.parseStatementListItem();
|
|
10522
10722
|
}
|
|
10523
10723
|
isExportDefaultSpecifier() {
|
|
@@ -10528,11 +10728,13 @@ class StatementParser extends ExpressionParser {
|
|
|
10528
10728
|
if (type === 92 && !this.state.containsEsc || type === 97) {
|
|
10529
10729
|
return false;
|
|
10530
10730
|
}
|
|
10531
|
-
if ((type ===
|
|
10731
|
+
if ((type === 129 || type === 128 || type === 104) && !this.state.containsEsc) {
|
|
10532
10732
|
const next = this.nextTokenStart();
|
|
10533
10733
|
const nextChar = this.input.charCodeAt(next);
|
|
10534
|
-
if (nextChar === 123 || this.chStartsBindingIdentifier(nextChar, next) && !this.
|
|
10535
|
-
|
|
10734
|
+
if (nextChar === 123 || this.chStartsBindingIdentifier(nextChar, next) && !this.isUnparsedContextual(next, "from")) {
|
|
10735
|
+
if (type !== 104) {
|
|
10736
|
+
this.expectOnePlugin(["flow", "typescript"]);
|
|
10737
|
+
}
|
|
10536
10738
|
return false;
|
|
10537
10739
|
}
|
|
10538
10740
|
}
|
|
@@ -10577,7 +10779,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10577
10779
|
this.raise(Errors.UsingDeclarationExport, this.state.startLoc);
|
|
10578
10780
|
return true;
|
|
10579
10781
|
}
|
|
10580
|
-
return type === 70 || type === 71 || type === 64 || type === 76 || this.isLet() || this.isAsyncFunction();
|
|
10782
|
+
return type === 70 || type === 71 || type === 64 || type === 76 || this.isLet() || this.isAsyncFunction() || this.isContextual(104) && this.nextTokenIsIdentifierOnSameLine();
|
|
10581
10783
|
}
|
|
10582
10784
|
checkNamedExport(node, isFrom) {
|
|
10583
10785
|
if (node.specifiers?.length) {
|
|
@@ -10604,7 +10806,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10604
10806
|
}
|
|
10605
10807
|
} else if (node.declaration) {
|
|
10606
10808
|
const decl = node.declaration;
|
|
10607
|
-
if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration") {
|
|
10809
|
+
if (decl.type === "FunctionDeclaration" || decl.type === "ClassDeclaration" || decl.type === "StructDeclaration") {
|
|
10608
10810
|
const {
|
|
10609
10811
|
id
|
|
10610
10812
|
} = decl;
|
|
@@ -10661,8 +10863,8 @@ class StatementParser extends ExpressionParser {
|
|
|
10661
10863
|
this.expect(8);
|
|
10662
10864
|
if (this.eat(4)) break;
|
|
10663
10865
|
}
|
|
10664
|
-
const isMaybeTypeOnly = this.isContextual(
|
|
10665
|
-
const isString = this.match(
|
|
10866
|
+
const isMaybeTypeOnly = this.isContextual(129);
|
|
10867
|
+
const isString = this.match(133);
|
|
10666
10868
|
const node = this.startNode();
|
|
10667
10869
|
node.local = this.parseModuleExportName();
|
|
10668
10870
|
nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
|
|
@@ -10680,7 +10882,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10680
10882
|
return this.finishNode(node, "ExportSpecifier");
|
|
10681
10883
|
}
|
|
10682
10884
|
parseModuleExportName() {
|
|
10683
|
-
if (this.match(
|
|
10885
|
+
if (this.match(133)) {
|
|
10684
10886
|
const result = this.parseStringLiteral(this.state.value);
|
|
10685
10887
|
const surrogate = loneSurrogate.exec(result.value);
|
|
10686
10888
|
if (surrogate) {
|
|
@@ -10692,27 +10894,80 @@ class StatementParser extends ExpressionParser {
|
|
|
10692
10894
|
}
|
|
10693
10895
|
return this.parseIdentifier(true);
|
|
10694
10896
|
}
|
|
10897
|
+
toNamespaceExportsFilter(specifiers) {
|
|
10898
|
+
const seen = new Set();
|
|
10899
|
+
return specifiers.map(specifier => {
|
|
10900
|
+
let name, alias, kind;
|
|
10901
|
+
if (specifier.type === "ImportSpecifier") {
|
|
10902
|
+
({
|
|
10903
|
+
imported: name,
|
|
10904
|
+
local: alias,
|
|
10905
|
+
importKind: kind
|
|
10906
|
+
} = specifier);
|
|
10907
|
+
} else {
|
|
10908
|
+
({
|
|
10909
|
+
local: name,
|
|
10910
|
+
exported: alias,
|
|
10911
|
+
exportKind: kind
|
|
10912
|
+
} = specifier);
|
|
10913
|
+
}
|
|
10914
|
+
const nameString = name.type === "Identifier" ? name.name : this.isStringModuleExportName(name) ? name.value : null;
|
|
10915
|
+
if (nameString !== null) {
|
|
10916
|
+
if (seen.has(nameString)) {
|
|
10917
|
+
this.raise(Errors.FilteredNamespaceDuplicateName, name, {
|
|
10918
|
+
name: nameString
|
|
10919
|
+
});
|
|
10920
|
+
}
|
|
10921
|
+
seen.add(nameString);
|
|
10922
|
+
}
|
|
10923
|
+
let invalid = false;
|
|
10924
|
+
if (alias.start !== name.start) {
|
|
10925
|
+
this.raise(Errors.FilteredNamespaceRename, alias);
|
|
10926
|
+
invalid = true;
|
|
10927
|
+
}
|
|
10928
|
+
if (kind === "type" || kind === "typeof") {
|
|
10929
|
+
this.raise(Errors.FilteredNamespaceTypeModifier, specifier);
|
|
10930
|
+
invalid = true;
|
|
10931
|
+
}
|
|
10932
|
+
if (invalid) {
|
|
10933
|
+
return specifier;
|
|
10934
|
+
}
|
|
10935
|
+
this.replaceNodeInPendingComments(specifier, name);
|
|
10936
|
+
return name;
|
|
10937
|
+
});
|
|
10938
|
+
}
|
|
10695
10939
|
checkImportPhase(node) {
|
|
10940
|
+
if (node.phase == null) {
|
|
10941
|
+
return;
|
|
10942
|
+
}
|
|
10696
10943
|
const {
|
|
10697
10944
|
specifiers
|
|
10698
10945
|
} = node;
|
|
10699
10946
|
const singleBindingType = specifiers.length === 1 ? specifiers[0].type : null;
|
|
10700
10947
|
if (node.phase === "source") {
|
|
10701
10948
|
if (singleBindingType !== "ImportDefaultSpecifier") {
|
|
10702
|
-
this.raise(Errors.SourcePhaseImportRequiresDefault,
|
|
10949
|
+
this.raise(Errors.SourcePhaseImportRequiresDefault, node);
|
|
10703
10950
|
}
|
|
10704
10951
|
} else if (node.phase === "defer") {
|
|
10705
10952
|
if (singleBindingType !== "ImportNamespaceSpecifier") {
|
|
10706
|
-
this.raise(Errors.DeferImportRequiresNamespace,
|
|
10953
|
+
this.raise(Errors.DeferImportRequiresNamespace, node);
|
|
10707
10954
|
}
|
|
10708
10955
|
}
|
|
10709
10956
|
}
|
|
10710
10957
|
isPotentialImportPhase(isExport) {
|
|
10711
|
-
if (isExport)
|
|
10958
|
+
if (isExport) {
|
|
10959
|
+
if (!this.isContextual(94)) return false;
|
|
10960
|
+
const ch = this.lookaheadCharCode();
|
|
10961
|
+
return ch === 123 || ch === 42;
|
|
10962
|
+
}
|
|
10712
10963
|
return this.isContextual(102) || this.isContextual(94);
|
|
10713
10964
|
}
|
|
10714
10965
|
applyImportPhase(node, isExport, phase, loc) {
|
|
10715
10966
|
if (isExport) {
|
|
10967
|
+
if (phase === "defer") {
|
|
10968
|
+
this.expectPlugin("deferredReexports", loc);
|
|
10969
|
+
node.phase = "defer";
|
|
10970
|
+
}
|
|
10716
10971
|
return;
|
|
10717
10972
|
}
|
|
10718
10973
|
if (phase === "source") {
|
|
@@ -10751,7 +11006,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10751
11006
|
return tokenIsIdentifier(type) ? type !== 95 || this.lookaheadCharCode() === 102 : type !== 8;
|
|
10752
11007
|
}
|
|
10753
11008
|
parseImport(node) {
|
|
10754
|
-
if (this.match(
|
|
11009
|
+
if (this.match(133)) {
|
|
10755
11010
|
return this.parseImportSourceAndAttributes(node);
|
|
10756
11011
|
}
|
|
10757
11012
|
return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
|
|
@@ -10761,7 +11016,7 @@ class StatementParser extends ExpressionParser {
|
|
|
10761
11016
|
const hasDefault = this.maybeParseDefaultImportSpecifier(node, maybeDefaultIdentifier);
|
|
10762
11017
|
const parseNext = !hasDefault || this.eat(8);
|
|
10763
11018
|
const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
|
|
10764
|
-
if (parseNext && !hasStar) this.
|
|
11019
|
+
if (parseNext && !hasStar) this.parseNamedOrFilteredImportSpecifiers(node);
|
|
10765
11020
|
this.expectContextual(95);
|
|
10766
11021
|
return this.parseImportSourceAndAttributes(node);
|
|
10767
11022
|
}
|
|
@@ -10775,17 +11030,17 @@ class StatementParser extends ExpressionParser {
|
|
|
10775
11030
|
return this.finishNode(node, "ImportDeclaration");
|
|
10776
11031
|
}
|
|
10777
11032
|
parseImportSource() {
|
|
10778
|
-
if (!this.match(
|
|
11033
|
+
if (!this.match(133)) this.unexpected();
|
|
10779
11034
|
return this.parseExprAtom();
|
|
10780
11035
|
}
|
|
10781
11036
|
parseImportSpecifierLocal(node, specifier, type) {
|
|
10782
11037
|
specifier.local = this.parseIdentifier();
|
|
10783
11038
|
node.specifiers.push(this.finishImportSpecifier(specifier, type));
|
|
10784
11039
|
}
|
|
10785
|
-
finishImportSpecifier(specifier, type
|
|
11040
|
+
finishImportSpecifier(specifier, type) {
|
|
10786
11041
|
this.checkLVal(specifier.local, {
|
|
10787
11042
|
type
|
|
10788
|
-
},
|
|
11043
|
+
}, 8201);
|
|
10789
11044
|
return this.finishNode(specifier, type);
|
|
10790
11045
|
}
|
|
10791
11046
|
parseImportAttributes() {
|
|
@@ -10804,13 +11059,13 @@ class StatementParser extends ExpressionParser {
|
|
|
10804
11059
|
});
|
|
10805
11060
|
}
|
|
10806
11061
|
attrNames.add(keyName);
|
|
10807
|
-
if (this.match(
|
|
11062
|
+
if (this.match(133)) {
|
|
10808
11063
|
node.key = this.parseStringLiteral(keyName);
|
|
10809
11064
|
} else {
|
|
10810
11065
|
node.key = this.parseIdentifier(true);
|
|
10811
11066
|
}
|
|
10812
11067
|
this.expect(10);
|
|
10813
|
-
if (!this.match(
|
|
11068
|
+
if (!this.match(133)) {
|
|
10814
11069
|
throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
|
|
10815
11070
|
}
|
|
10816
11071
|
node.value = this.parseStringLiteral(this.state.value);
|
|
@@ -10854,6 +11109,24 @@ class StatementParser extends ExpressionParser {
|
|
|
10854
11109
|
}
|
|
10855
11110
|
return false;
|
|
10856
11111
|
}
|
|
11112
|
+
parseNamedOrFilteredImportSpecifiers(node) {
|
|
11113
|
+
const startLoc = this.state.startLoc;
|
|
11114
|
+
this.setLoc(startLoc);
|
|
11115
|
+
const specifiersStart = node.specifiers.length;
|
|
11116
|
+
this.parseNamedImportSpecifiers(node);
|
|
11117
|
+
if (this.isContextual(90)) {
|
|
11118
|
+
this.expectPlugin("namespaceImportFilter");
|
|
11119
|
+
const specifier = this.startNodeAt(startLoc);
|
|
11120
|
+
specifier.exportsFilter = this.toNamespaceExportsFilter(node.specifiers.splice(specifiersStart));
|
|
11121
|
+
this.next();
|
|
11122
|
+
this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier");
|
|
11123
|
+
return;
|
|
11124
|
+
}
|
|
11125
|
+
const isInTypeOnlyImport = node.importKind === "type" || node.importKind === "typeof";
|
|
11126
|
+
for (let i = specifiersStart; i < node.specifiers.length; i++) {
|
|
11127
|
+
this.checkImportSpecifier(node.specifiers[i], isInTypeOnlyImport);
|
|
11128
|
+
}
|
|
11129
|
+
}
|
|
10857
11130
|
parseNamedImportSpecifiers(node) {
|
|
10858
11131
|
let first = true;
|
|
10859
11132
|
this.expect(2);
|
|
@@ -10868,31 +11141,40 @@ class StatementParser extends ExpressionParser {
|
|
|
10868
11141
|
if (this.eat(4)) break;
|
|
10869
11142
|
}
|
|
10870
11143
|
const specifier = this.startNode();
|
|
10871
|
-
const importedIsString = this.match(
|
|
10872
|
-
const isMaybeTypeOnly = this.isContextual(
|
|
11144
|
+
const importedIsString = this.match(133);
|
|
11145
|
+
const isMaybeTypeOnly = this.isContextual(129);
|
|
10873
11146
|
specifier.imported = this.parseModuleExportName();
|
|
10874
|
-
const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly
|
|
11147
|
+
const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly);
|
|
10875
11148
|
node.specifiers.push(importSpecifier);
|
|
10876
11149
|
}
|
|
10877
11150
|
}
|
|
10878
|
-
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly
|
|
11151
|
+
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) {
|
|
10879
11152
|
if (this.eatContextual(90)) {
|
|
10880
11153
|
specifier.local = this.parseIdentifier();
|
|
10881
11154
|
} else {
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
10888
|
-
|
|
10889
|
-
|
|
10890
|
-
|
|
10891
|
-
|
|
10892
|
-
|
|
10893
|
-
|
|
11155
|
+
specifier.local ??= this.cloneIdentifier(specifier.imported);
|
|
11156
|
+
}
|
|
11157
|
+
return this.finishNode(specifier, "ImportSpecifier");
|
|
11158
|
+
}
|
|
11159
|
+
checkImportSpecifier(specifier, isInTypeOnlyImport, bindingType = 8201, checkReservedWord = true) {
|
|
11160
|
+
const {
|
|
11161
|
+
imported,
|
|
11162
|
+
local
|
|
11163
|
+
} = specifier;
|
|
11164
|
+
if (this.isStringModuleExportName(local)) {
|
|
11165
|
+
throw this.raise(Errors.ImportBindingIsString, specifier, {
|
|
11166
|
+
importName: imported.value
|
|
11167
|
+
});
|
|
10894
11168
|
}
|
|
10895
|
-
|
|
11169
|
+
if (checkReservedWord && local.start === imported.start) {
|
|
11170
|
+
this.checkReservedWord(local.name, local.start, true, true);
|
|
11171
|
+
}
|
|
11172
|
+
this.checkLVal(local, {
|
|
11173
|
+
type: "ImportSpecifier"
|
|
11174
|
+
}, bindingType);
|
|
11175
|
+
}
|
|
11176
|
+
isStringModuleExportName(node) {
|
|
11177
|
+
return node.type === "StringLiteral" || node.type === "Literal";
|
|
10896
11178
|
}
|
|
10897
11179
|
isThisParam(param) {
|
|
10898
11180
|
return param.type === "Identifier" && param.name === "this";
|
|
@@ -11070,6 +11352,17 @@ function tsIsEntityName(node) {
|
|
|
11070
11352
|
return false;
|
|
11071
11353
|
}
|
|
11072
11354
|
}
|
|
11355
|
+
function tsIsTypeCast(node) {
|
|
11356
|
+
switch (node.type) {
|
|
11357
|
+
case "TSAsExpression":
|
|
11358
|
+
case "TSSatisfiesExpression":
|
|
11359
|
+
case "TSNonNullExpression":
|
|
11360
|
+
case "TSTypeAssertion":
|
|
11361
|
+
return true;
|
|
11362
|
+
default:
|
|
11363
|
+
return false;
|
|
11364
|
+
}
|
|
11365
|
+
}
|
|
11073
11366
|
const ClassMemberModifiers = buildModifiersMap(["declare", "private", "public", "protected", "override", "abstract", "readonly", "static"], ["in", "out"]);
|
|
11074
11367
|
const IndexSignatureModifiers = buildModifiersMap(["readonly"], ["declare", "abstract", "private", "protected", "public", "static", "override"]);
|
|
11075
11368
|
const BindingElementModifiers = buildModifiersMap(["public", "private", "protected", "override", "readonly"]);
|
|
@@ -11082,7 +11375,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11082
11375
|
return tokenIsIdentifier(this.state.type);
|
|
11083
11376
|
}
|
|
11084
11377
|
tsTokenCanFollowModifier() {
|
|
11085
|
-
return this.match(0) || this.match(2) || this.match(51) || this.match(17) || this.match(
|
|
11378
|
+
return this.match(0) || this.match(2) || this.match(51) || this.match(17) || this.match(137) || this.isLiteralPropertyName();
|
|
11086
11379
|
}
|
|
11087
11380
|
tsNextTokenOnSameLineAndCanFollowModifier() {
|
|
11088
11381
|
this.next();
|
|
@@ -11259,7 +11552,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11259
11552
|
const node = this.startNode();
|
|
11260
11553
|
this.expect(79);
|
|
11261
11554
|
this.expect(6);
|
|
11262
|
-
if (!this.match(
|
|
11555
|
+
if (!this.match(133)) {
|
|
11263
11556
|
this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
|
|
11264
11557
|
node.source = this.tsParseNonConditionalType();
|
|
11265
11558
|
} else {
|
|
@@ -11304,7 +11597,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11304
11597
|
this.expect(2);
|
|
11305
11598
|
while (!this.match(4)) {
|
|
11306
11599
|
const type = this.state.type;
|
|
11307
|
-
if (tokenIsIdentifier(type) || type ===
|
|
11600
|
+
if (tokenIsIdentifier(type) || type === 133) {
|
|
11308
11601
|
properties.push(super.parsePropertyDefinition(null));
|
|
11309
11602
|
} else {
|
|
11310
11603
|
this.unexpected();
|
|
@@ -11388,7 +11681,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11388
11681
|
}
|
|
11389
11682
|
tsParseTypeParameters(parseModifiers) {
|
|
11390
11683
|
const node = this.startNode();
|
|
11391
|
-
if (this.match(43) || this.match(
|
|
11684
|
+
if (this.match(43) || this.match(141)) {
|
|
11392
11685
|
this.next();
|
|
11393
11686
|
} else {
|
|
11394
11687
|
this.unexpected();
|
|
@@ -11559,9 +11852,9 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11559
11852
|
tsIsStartOfMappedType() {
|
|
11560
11853
|
this.next();
|
|
11561
11854
|
if (this.eat(49)) {
|
|
11562
|
-
return this.isContextual(
|
|
11855
|
+
return this.isContextual(121);
|
|
11563
11856
|
}
|
|
11564
|
-
if (this.isContextual(
|
|
11857
|
+
if (this.isContextual(121)) {
|
|
11565
11858
|
this.next();
|
|
11566
11859
|
}
|
|
11567
11860
|
if (!this.match(0)) {
|
|
@@ -11580,8 +11873,8 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11580
11873
|
if (this.match(49)) {
|
|
11581
11874
|
node.readonly = this.state.value;
|
|
11582
11875
|
this.next();
|
|
11583
|
-
this.expectContextual(
|
|
11584
|
-
} else if (this.eatContextual(
|
|
11876
|
+
this.expectContextual(121);
|
|
11877
|
+
} else if (this.eatContextual(121)) {
|
|
11585
11878
|
node.readonly = true;
|
|
11586
11879
|
}
|
|
11587
11880
|
this.expect(0);
|
|
@@ -11705,9 +11998,9 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11705
11998
|
tsParseLiteralTypeNode() {
|
|
11706
11999
|
const node = this.startNode();
|
|
11707
12000
|
switch (this.state.type) {
|
|
11708
|
-
case
|
|
12001
|
+
case 134:
|
|
12002
|
+
case 135:
|
|
11709
12003
|
case 133:
|
|
11710
|
-
case 131:
|
|
11711
12004
|
case 81:
|
|
11712
12005
|
case 82:
|
|
11713
12006
|
node.literal = super.parseExprAtom();
|
|
@@ -11747,7 +12040,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11747
12040
|
}
|
|
11748
12041
|
tsParseThisTypeOrThisTypePredicate() {
|
|
11749
12042
|
const thisKeyword = this.tsParseThisTypeNode();
|
|
11750
|
-
if (this.isContextual(
|
|
12043
|
+
if (this.isContextual(115) && !this.hasPrecedingLineBreak()) {
|
|
11751
12044
|
return this.tsParseThisTypePredicate(thisKeyword);
|
|
11752
12045
|
} else {
|
|
11753
12046
|
return thisKeyword;
|
|
@@ -11755,9 +12048,9 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11755
12048
|
}
|
|
11756
12049
|
tsParseNonArrayType() {
|
|
11757
12050
|
switch (this.state.type) {
|
|
11758
|
-
case 131:
|
|
11759
|
-
case 132:
|
|
11760
12051
|
case 133:
|
|
12052
|
+
case 134:
|
|
12053
|
+
case 135:
|
|
11761
12054
|
case 81:
|
|
11762
12055
|
case 82:
|
|
11763
12056
|
return this.tsParseLiteralTypeNode();
|
|
@@ -11765,7 +12058,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11765
12058
|
if (this.state.value === "-") {
|
|
11766
12059
|
const node = this.startNode();
|
|
11767
12060
|
const nextToken = this.lookahead();
|
|
11768
|
-
if (nextToken.type !==
|
|
12061
|
+
if (nextToken.type !== 134 && nextToken.type !== 135) {
|
|
11769
12062
|
this.unexpected();
|
|
11770
12063
|
}
|
|
11771
12064
|
node.literal = this.parseMaybeUnary();
|
|
@@ -11857,7 +12150,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11857
12150
|
}
|
|
11858
12151
|
tsParseInferType() {
|
|
11859
12152
|
const node = this.startNode();
|
|
11860
|
-
this.expectContextual(
|
|
12153
|
+
this.expectContextual(114);
|
|
11861
12154
|
const typeParameter = this.startNode();
|
|
11862
12155
|
typeParameter.name = this.tsParseTypeParameterName();
|
|
11863
12156
|
typeParameter.constraint = this.tsTryParse(() => this.tsParseConstraintForInferType());
|
|
@@ -11874,7 +12167,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11874
12167
|
}
|
|
11875
12168
|
tsParseTypeOperatorOrHigher() {
|
|
11876
12169
|
const isTypeOperator = tokenIsTSTypeOperator(this.state.type) && !this.state.containsEsc;
|
|
11877
|
-
return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(
|
|
12170
|
+
return isTypeOperator ? this.tsParseTypeOperator() : this.isContextual(114) ? this.tsParseInferType() : this.tsInAllowConditionalTypesContext(() => this.tsParseArrayTypeOrHigher());
|
|
11878
12171
|
}
|
|
11879
12172
|
tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
|
|
11880
12173
|
const node = this.startNode();
|
|
@@ -11906,28 +12199,23 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
11906
12199
|
this.next();
|
|
11907
12200
|
return true;
|
|
11908
12201
|
}
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
} = this.state;
|
|
11913
|
-
const previousErrorCount = errors.length;
|
|
11914
|
-
try {
|
|
11915
|
-
this.parseObjectLike(4, true);
|
|
11916
|
-
return errors.length === previousErrorCount;
|
|
11917
|
-
} catch {
|
|
11918
|
-
return false;
|
|
11919
|
-
}
|
|
11920
|
-
}
|
|
11921
|
-
if (this.match(0)) {
|
|
11922
|
-
this.next();
|
|
12202
|
+
const isObjectPattern = this.match(2);
|
|
12203
|
+
if (isObjectPattern || this.match(0)) {
|
|
12204
|
+
if (!isObjectPattern) this.next();
|
|
11923
12205
|
const {
|
|
11924
12206
|
errors
|
|
11925
12207
|
} = this.state;
|
|
11926
12208
|
const previousErrorCount = errors.length;
|
|
12209
|
+
const scopeStacksSnapshot = this.snapshotScopeStacks();
|
|
11927
12210
|
try {
|
|
11928
|
-
|
|
12211
|
+
if (isObjectPattern) {
|
|
12212
|
+
this.parseObjectLike(4, true);
|
|
12213
|
+
} else {
|
|
12214
|
+
super.parseBindingList(1, 93, 1);
|
|
12215
|
+
}
|
|
11929
12216
|
return errors.length === previousErrorCount;
|
|
11930
12217
|
} catch {
|
|
12218
|
+
this.restoreScopeStacks(scopeStacksSnapshot);
|
|
11931
12219
|
return false;
|
|
11932
12220
|
}
|
|
11933
12221
|
}
|
|
@@ -12005,13 +12293,13 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12005
12293
|
}
|
|
12006
12294
|
tsParseTypePredicatePrefix() {
|
|
12007
12295
|
const id = this.parseIdentifier();
|
|
12008
|
-
if (this.isContextual(
|
|
12296
|
+
if (this.isContextual(115) && !this.hasPrecedingLineBreak()) {
|
|
12009
12297
|
this.next();
|
|
12010
12298
|
return id;
|
|
12011
12299
|
}
|
|
12012
12300
|
}
|
|
12013
12301
|
tsParseTypePredicateAsserts() {
|
|
12014
|
-
if (this.state.type !==
|
|
12302
|
+
if (this.state.type !== 108) {
|
|
12015
12303
|
return false;
|
|
12016
12304
|
}
|
|
12017
12305
|
const containsEsc = this.state.containsEsc;
|
|
@@ -12049,7 +12337,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12049
12337
|
return this.finishNode(node, "TSConditionalType");
|
|
12050
12338
|
}
|
|
12051
12339
|
isAbstractConstructorSignature() {
|
|
12052
|
-
return this.isContextual(
|
|
12340
|
+
return this.isContextual(123) && this.isLookaheadContextual("new");
|
|
12053
12341
|
}
|
|
12054
12342
|
tsParseNonConditionalType() {
|
|
12055
12343
|
if (this.tsIsStartOfFunctionType()) {
|
|
@@ -12106,7 +12394,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12106
12394
|
}
|
|
12107
12395
|
tsParseInterfaceDeclaration(node, properties = {}) {
|
|
12108
12396
|
if (this.hasFollowingLineBreak()) return null;
|
|
12109
|
-
this.expectContextual(
|
|
12397
|
+
this.expectContextual(128);
|
|
12110
12398
|
if (properties.declare) node.declare = true;
|
|
12111
12399
|
if (tokenIsIdentifier(this.state.type)) {
|
|
12112
12400
|
node.id = this.parseIdentifier();
|
|
@@ -12130,7 +12418,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12130
12418
|
node.typeAnnotation = this.tsInType(() => {
|
|
12131
12419
|
node.typeParameters = this.tsTryParseTypeParameters(this.tsParseInOutModifiers);
|
|
12132
12420
|
this.expect(25);
|
|
12133
|
-
if (this.isContextual(
|
|
12421
|
+
if (this.isContextual(113) && this.lookaheadCharCode() !== 46) {
|
|
12134
12422
|
const node = this.startNode();
|
|
12135
12423
|
this.next();
|
|
12136
12424
|
return this.finishNode(node, "TSIntrinsicKeyword");
|
|
@@ -12199,7 +12487,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12199
12487
|
}
|
|
12200
12488
|
tsParseEnumMember() {
|
|
12201
12489
|
const node = this.startNode();
|
|
12202
|
-
node.id = this.match(
|
|
12490
|
+
node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
|
|
12203
12491
|
if (this.eat(25)) {
|
|
12204
12492
|
node.initializer = super.parseMaybeAssignAllowIn();
|
|
12205
12493
|
}
|
|
@@ -12208,7 +12496,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12208
12496
|
tsParseEnumDeclaration(node, properties = {}) {
|
|
12209
12497
|
if (properties.const) node.const = true;
|
|
12210
12498
|
if (properties.declare) node.declare = true;
|
|
12211
|
-
this.expectContextual(
|
|
12499
|
+
this.expectContextual(125);
|
|
12212
12500
|
node.id = this.parseIdentifier();
|
|
12213
12501
|
this.checkIdentifier(node.id, node.const ? 8971 : 8459);
|
|
12214
12502
|
node.body = this.tsParseEnumBody();
|
|
@@ -12246,7 +12534,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12246
12534
|
return this.finishNode(node, "TSModuleDeclaration");
|
|
12247
12535
|
}
|
|
12248
12536
|
tsParseAmbientExternalModuleDeclaration(node) {
|
|
12249
|
-
const isGlobal = this.isContextual(
|
|
12537
|
+
const isGlobal = this.isContextual(111);
|
|
12250
12538
|
if (isGlobal) {
|
|
12251
12539
|
node.kind = "global";
|
|
12252
12540
|
node.id = this.parseIdentifier();
|
|
@@ -12256,7 +12544,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12256
12544
|
type,
|
|
12257
12545
|
value
|
|
12258
12546
|
} = this.state;
|
|
12259
|
-
if (type ===
|
|
12547
|
+
if (type === 133) {
|
|
12260
12548
|
node.id = super.parseStringLiteral(value);
|
|
12261
12549
|
} else if (tokenIsIdentifier(type)) {
|
|
12262
12550
|
this.raise(TSErrors.InlineModuleDeclarationMustUseString, this.state.startLoc);
|
|
@@ -12296,16 +12584,16 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12296
12584
|
return this.finishNode(node, "TSImportEqualsDeclaration");
|
|
12297
12585
|
}
|
|
12298
12586
|
tsIsExternalModuleReference() {
|
|
12299
|
-
return this.isContextual(
|
|
12587
|
+
return this.isContextual(118) && this.lookaheadCharCode() === 40;
|
|
12300
12588
|
}
|
|
12301
12589
|
tsParseModuleReference() {
|
|
12302
12590
|
return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(0);
|
|
12303
12591
|
}
|
|
12304
12592
|
tsParseExternalModuleReference() {
|
|
12305
12593
|
const node = this.startNode();
|
|
12306
|
-
this.expectContextual(
|
|
12594
|
+
this.expectContextual(118);
|
|
12307
12595
|
this.expect(6);
|
|
12308
|
-
if (!this.match(
|
|
12596
|
+
if (!this.match(133)) {
|
|
12309
12597
|
this.unexpected();
|
|
12310
12598
|
}
|
|
12311
12599
|
node.expression = super.parseExprAtom();
|
|
@@ -12346,11 +12634,11 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12346
12634
|
case 76:
|
|
12347
12635
|
node.declare = true;
|
|
12348
12636
|
return this.parseClass(node, true, false);
|
|
12349
|
-
case
|
|
12637
|
+
case 125:
|
|
12350
12638
|
return this.tsParseEnumDeclaration(node, {
|
|
12351
12639
|
declare: true
|
|
12352
12640
|
});
|
|
12353
|
-
case
|
|
12641
|
+
case 111:
|
|
12354
12642
|
return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
12355
12643
|
case 97:
|
|
12356
12644
|
if (this.state.containsEsc) {
|
|
@@ -12367,7 +12655,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12367
12655
|
const: true,
|
|
12368
12656
|
declare: true
|
|
12369
12657
|
});
|
|
12370
|
-
case
|
|
12658
|
+
case 106:
|
|
12371
12659
|
if (this.isUsing()) {
|
|
12372
12660
|
this.raise(TSErrors.InvalidModifierOnUsingDeclaration, this.state.startLoc, "declare");
|
|
12373
12661
|
node.declare = true;
|
|
@@ -12382,7 +12670,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12382
12670
|
return this.parseVarStatement(node, "await using", true);
|
|
12383
12671
|
}
|
|
12384
12672
|
break;
|
|
12385
|
-
case
|
|
12673
|
+
case 128:
|
|
12386
12674
|
{
|
|
12387
12675
|
const result = this.tsParseInterfaceDeclaration(node, {
|
|
12388
12676
|
declare: true
|
|
@@ -12401,23 +12689,23 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12401
12689
|
}
|
|
12402
12690
|
tsParseDeclaration(node, type, next, decorators) {
|
|
12403
12691
|
switch (type) {
|
|
12404
|
-
case
|
|
12692
|
+
case 123:
|
|
12405
12693
|
if (this.tsCheckLineTerminator(next) && (this.match(76) || tokenIsIdentifier(this.state.type))) {
|
|
12406
12694
|
return this.tsParseAbstractDeclaration(node, decorators);
|
|
12407
12695
|
}
|
|
12408
12696
|
break;
|
|
12409
|
-
case
|
|
12697
|
+
case 126:
|
|
12410
12698
|
if (this.tsCheckLineTerminator(next)) {
|
|
12411
12699
|
return this.tsParseAmbientExternalModuleDeclaration(node);
|
|
12412
12700
|
}
|
|
12413
12701
|
break;
|
|
12414
|
-
case
|
|
12702
|
+
case 127:
|
|
12415
12703
|
if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
|
|
12416
12704
|
node.kind = "namespace";
|
|
12417
12705
|
return this.tsParseNamespaceDeclaration(node);
|
|
12418
12706
|
}
|
|
12419
12707
|
break;
|
|
12420
|
-
case
|
|
12708
|
+
case 129:
|
|
12421
12709
|
if (this.tsCheckLineTerminator(next) && tokenIsIdentifier(this.state.type)) {
|
|
12422
12710
|
return this.tsParseTypeAliasDeclaration(node);
|
|
12423
12711
|
}
|
|
@@ -12490,8 +12778,6 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12490
12778
|
const pp = startLoc ? this.startNodeAt(startLoc) : this.startNodeAtNode(decorators[0]);
|
|
12491
12779
|
if (decorators.length) {
|
|
12492
12780
|
pp.decorators = decorators;
|
|
12493
|
-
} else {
|
|
12494
|
-
this.setLoc(startLoc);
|
|
12495
12781
|
}
|
|
12496
12782
|
if (accessibility) pp.accessibility = accessibility;
|
|
12497
12783
|
if (readonly) pp.readonly = readonly;
|
|
@@ -12628,7 +12914,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12628
12914
|
return this.finishCallExpression(node, state.optionalChainMember);
|
|
12629
12915
|
}
|
|
12630
12916
|
const tokenType = this.state.type;
|
|
12631
|
-
if (tokenType === 44 || tokenType === 48 || tokenType !== 6 && tokenType !== 90 && tokenType !==
|
|
12917
|
+
if (tokenType === 44 || tokenType === 48 || tokenType !== 6 && tokenType !== 90 && tokenType !== 119 && tokenCanStartExpression(tokenType) && !this.hasPrecedingLineBreak()) {
|
|
12632
12918
|
return;
|
|
12633
12919
|
}
|
|
12634
12920
|
const node = this.startNodeAt(startLoc);
|
|
@@ -12665,7 +12951,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12665
12951
|
}
|
|
12666
12952
|
parseExprOp(left, leftStartLoc, minPrec) {
|
|
12667
12953
|
let isSatisfies;
|
|
12668
|
-
if (tokenOperatorPrecedence(54) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(90) || (isSatisfies = this.isContextual(
|
|
12954
|
+
if (tokenOperatorPrecedence(54) > minPrec && !this.hasPrecedingLineBreak() && (this.isContextual(90) || (isSatisfies = this.isContextual(119)))) {
|
|
12669
12955
|
const node = this.startNodeAt(leftStartLoc);
|
|
12670
12956
|
node.expression = left;
|
|
12671
12957
|
node.typeAnnotation = this.tsInType(() => {
|
|
@@ -12694,7 +12980,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12694
12980
|
checkDuplicateExports() {}
|
|
12695
12981
|
isPotentialImportPhase(isExport) {
|
|
12696
12982
|
if (super.isPotentialImportPhase(isExport)) return true;
|
|
12697
|
-
if (this.isContextual(
|
|
12983
|
+
if (this.isContextual(129)) {
|
|
12698
12984
|
const ch = this.lookaheadCharCode();
|
|
12699
12985
|
return isExport ? ch === 123 || ch === 42 : ch !== 61;
|
|
12700
12986
|
}
|
|
@@ -12709,7 +12995,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12709
12995
|
}
|
|
12710
12996
|
}
|
|
12711
12997
|
parseImport(node) {
|
|
12712
|
-
if (this.match(
|
|
12998
|
+
if (this.match(133)) {
|
|
12713
12999
|
node.importKind = "value";
|
|
12714
13000
|
if (this.scope.inTSNamespace) {
|
|
12715
13001
|
this.raise(TSErrors.ImportInTSNamespace, node);
|
|
@@ -12724,7 +13010,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12724
13010
|
this.raise(TSErrors.ImportInTSNamespace, node);
|
|
12725
13011
|
}
|
|
12726
13012
|
return result;
|
|
12727
|
-
} else if (this.isContextual(
|
|
13013
|
+
} else if (this.isContextual(129)) {
|
|
12728
13014
|
const maybeDefaultIdentifier = this.parseMaybeImportPhase(node, false);
|
|
12729
13015
|
if (this.lookaheadCharCode() === 61) {
|
|
12730
13016
|
if (this.scope.inTSNamespace) {
|
|
@@ -12749,7 +13035,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12749
13035
|
const nodeImportEquals = this.startNode();
|
|
12750
13036
|
this.next();
|
|
12751
13037
|
let maybeDefaultIdentifier = null;
|
|
12752
|
-
if (this.isContextual(
|
|
13038
|
+
if (this.isContextual(129) && this.isPotentialImportPhase(false)) {
|
|
12753
13039
|
maybeDefaultIdentifier = this.parseMaybeImportPhase(nodeImportEquals, false);
|
|
12754
13040
|
} else {
|
|
12755
13041
|
nodeImportEquals.importKind = "value";
|
|
@@ -12772,7 +13058,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12772
13058
|
return this.finishNode(assign, "TSExportAssignment");
|
|
12773
13059
|
} else if (this.eatContextual(90)) {
|
|
12774
13060
|
const decl = node;
|
|
12775
|
-
this.expectContextual(
|
|
13061
|
+
this.expectContextual(127);
|
|
12776
13062
|
decl.id = this.parseIdentifier();
|
|
12777
13063
|
this.checkIdentifier(decl.id, 8201);
|
|
12778
13064
|
this.semicolon();
|
|
@@ -12789,7 +13075,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12789
13075
|
}
|
|
12790
13076
|
}
|
|
12791
13077
|
isAbstractClass() {
|
|
12792
|
-
return this.isContextual(
|
|
13078
|
+
return this.isContextual(123) && this.isLookaheadContextual("class");
|
|
12793
13079
|
}
|
|
12794
13080
|
parseExportDefaultExpression() {
|
|
12795
13081
|
if (this.isAbstractClass()) {
|
|
@@ -12798,7 +13084,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12798
13084
|
cls.abstract = true;
|
|
12799
13085
|
return this.parseClass(cls, true, true);
|
|
12800
13086
|
}
|
|
12801
|
-
if (this.match(
|
|
13087
|
+
if (this.match(128)) {
|
|
12802
13088
|
const result = this.tsParseInterfaceDeclaration(this.startNode());
|
|
12803
13089
|
if (result) return result;
|
|
12804
13090
|
}
|
|
@@ -12851,30 +13137,30 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12851
13137
|
}
|
|
12852
13138
|
break;
|
|
12853
13139
|
}
|
|
12854
|
-
case
|
|
12855
|
-
case
|
|
13140
|
+
case 123:
|
|
13141
|
+
case 124:
|
|
12856
13142
|
{
|
|
12857
13143
|
if (this.nextTokenIsIdentifierAndNotTSRelationalOperatorOnSameLine()) {
|
|
12858
13144
|
const token = this.state.type;
|
|
12859
13145
|
const node = this.startNode();
|
|
12860
13146
|
this.next();
|
|
12861
|
-
const declaration = token ===
|
|
13147
|
+
const declaration = token === 124 ? this.tsTryParseDeclare(node) : this.tsParseAbstractDeclaration(node, decorators);
|
|
12862
13148
|
if (declaration) {
|
|
12863
|
-
if (token ===
|
|
13149
|
+
if (token === 124) {
|
|
12864
13150
|
declaration.declare = true;
|
|
12865
13151
|
}
|
|
12866
13152
|
return declaration;
|
|
12867
13153
|
} else {
|
|
12868
|
-
node.expression = this.createIdentifier(this.startNodeAtNode(node), token ===
|
|
13154
|
+
node.expression = this.createIdentifier(this.startNodeAtNode(node), token === 124 ? "declare" : "abstract");
|
|
12869
13155
|
this.semicolon(false);
|
|
12870
13156
|
return this.finishNode(node, "ExpressionStatement");
|
|
12871
13157
|
}
|
|
12872
13158
|
}
|
|
12873
13159
|
break;
|
|
12874
13160
|
}
|
|
12875
|
-
case
|
|
13161
|
+
case 125:
|
|
12876
13162
|
return this.tsParseEnumDeclaration(this.startNode());
|
|
12877
|
-
case
|
|
13163
|
+
case 111:
|
|
12878
13164
|
{
|
|
12879
13165
|
const nextCh = this.lookaheadCharCode();
|
|
12880
13166
|
if (nextCh === 123) {
|
|
@@ -12883,7 +13169,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12883
13169
|
}
|
|
12884
13170
|
break;
|
|
12885
13171
|
}
|
|
12886
|
-
case
|
|
13172
|
+
case 128:
|
|
12887
13173
|
{
|
|
12888
13174
|
const result = this.tsParseInterfaceDeclaration(this.startNode());
|
|
12889
13175
|
if (result) {
|
|
@@ -12894,30 +13180,30 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
12894
13180
|
}
|
|
12895
13181
|
break;
|
|
12896
13182
|
}
|
|
12897
|
-
case
|
|
13183
|
+
case 126:
|
|
12898
13184
|
{
|
|
12899
13185
|
if (this.nextTokenIsStringLiteralOnSameLine()) {
|
|
12900
13186
|
const node = this.startNode();
|
|
12901
13187
|
this.next();
|
|
12902
|
-
return this.tsParseDeclaration(node,
|
|
13188
|
+
return this.tsParseDeclaration(node, 126, false, decorators);
|
|
12903
13189
|
} else if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
12904
13190
|
this.raise(TSErrors.InlineModuleDeclarationMustUseString, this.state.startLoc);
|
|
12905
13191
|
const node = this.startNode();
|
|
12906
13192
|
this.next();
|
|
12907
|
-
return this.tsParseDeclaration(node,
|
|
13193
|
+
return this.tsParseDeclaration(node, 127, false, decorators);
|
|
12908
13194
|
}
|
|
12909
13195
|
break;
|
|
12910
13196
|
}
|
|
12911
|
-
case
|
|
13197
|
+
case 127:
|
|
12912
13198
|
{
|
|
12913
13199
|
if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
12914
13200
|
const node = this.startNode();
|
|
12915
13201
|
this.next();
|
|
12916
|
-
return this.tsParseDeclaration(node,
|
|
13202
|
+
return this.tsParseDeclaration(node, 127, false, decorators);
|
|
12917
13203
|
}
|
|
12918
13204
|
break;
|
|
12919
13205
|
}
|
|
12920
|
-
case
|
|
13206
|
+
case 129:
|
|
12921
13207
|
{
|
|
12922
13208
|
if (this.nextTokenIsIdentifierOnSameLine()) {
|
|
12923
13209
|
const node = this.startNode();
|
|
@@ -13057,12 +13343,12 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13057
13343
|
return node;
|
|
13058
13344
|
}
|
|
13059
13345
|
parseExportDeclaration(node) {
|
|
13060
|
-
if (!this.state.isAmbientContext && this.isContextual(
|
|
13346
|
+
if (!this.state.isAmbientContext && this.isContextual(124)) {
|
|
13061
13347
|
return this.tsInAmbientContext(() => this.parseExportDeclaration(node));
|
|
13062
13348
|
}
|
|
13063
13349
|
const startLoc = this.state.startLoc;
|
|
13064
|
-
const isDeclare = this.eatContextual(
|
|
13065
|
-
if (isDeclare && (this.isContextual(
|
|
13350
|
+
const isDeclare = this.eatContextual(124);
|
|
13351
|
+
if (isDeclare && (this.isContextual(124) || !this.shouldParseExportDeclaration())) {
|
|
13066
13352
|
throw this.raise(TSErrors.ExpectedAmbientAfterExportDeclare, this.state.startLoc);
|
|
13067
13353
|
}
|
|
13068
13354
|
const isIdentifier = tokenIsIdentifier(this.state.type);
|
|
@@ -13078,7 +13364,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13078
13364
|
return declaration;
|
|
13079
13365
|
}
|
|
13080
13366
|
parseClassId(node, isStatement, optionalId, bindingType) {
|
|
13081
|
-
if ((!isStatement || optionalId) && this.isContextual(
|
|
13367
|
+
if ((!isStatement || optionalId) && this.isContextual(112)) {
|
|
13082
13368
|
node.id = null;
|
|
13083
13369
|
return;
|
|
13084
13370
|
}
|
|
@@ -13182,7 +13468,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13182
13468
|
node.superTypeArguments = this.tsParseTypeArgumentsInExpression();
|
|
13183
13469
|
}
|
|
13184
13470
|
}
|
|
13185
|
-
if (this.eatContextual(
|
|
13471
|
+
if (this.eatContextual(112)) {
|
|
13186
13472
|
node.implements = this.tsParseHeritageClause("implements");
|
|
13187
13473
|
}
|
|
13188
13474
|
}
|
|
@@ -13217,7 +13503,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13217
13503
|
let state;
|
|
13218
13504
|
let jsx;
|
|
13219
13505
|
let typeCast;
|
|
13220
|
-
if (this.hasPlugin("jsx") && (this.match(
|
|
13506
|
+
if (this.hasPlugin("jsx") && (this.match(141) || this.match(43))) {
|
|
13221
13507
|
state = this.state.clone();
|
|
13222
13508
|
jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, isParenItem), state);
|
|
13223
13509
|
if (!jsx.error) return jsx.node;
|
|
@@ -13324,21 +13610,19 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13324
13610
|
}
|
|
13325
13611
|
}
|
|
13326
13612
|
toAssignable(node, isLHS = false) {
|
|
13613
|
+
if (tsIsTypeCast(node)) {
|
|
13614
|
+
if (isLHS) {
|
|
13615
|
+
this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
|
|
13616
|
+
} else {
|
|
13617
|
+
this.raiseOnce(TSErrors.UnexpectedTypeCastInParameter, node);
|
|
13618
|
+
}
|
|
13619
|
+
this.toAssignable(node.expression, isLHS);
|
|
13620
|
+
return;
|
|
13621
|
+
}
|
|
13327
13622
|
switch (node.type) {
|
|
13328
13623
|
case "ParenthesizedExpression":
|
|
13329
13624
|
this.toAssignableParenthesizedExpression(node, isLHS);
|
|
13330
13625
|
break;
|
|
13331
|
-
case "TSAsExpression":
|
|
13332
|
-
case "TSSatisfiesExpression":
|
|
13333
|
-
case "TSNonNullExpression":
|
|
13334
|
-
case "TSTypeAssertion":
|
|
13335
|
-
if (isLHS) {
|
|
13336
|
-
this.expressionScope.recordArrowParameterBindingError(TSErrors.UnexpectedTypeCastInParameter, node);
|
|
13337
|
-
} else {
|
|
13338
|
-
this.raise(TSErrors.UnexpectedTypeCastInParameter, node);
|
|
13339
|
-
}
|
|
13340
|
-
this.toAssignable(node.expression, isLHS);
|
|
13341
|
-
break;
|
|
13342
13626
|
case "AssignmentExpression":
|
|
13343
13627
|
if (!isLHS && node.left.type === "TSTypeCastExpression") {
|
|
13344
13628
|
node.left = this.typeCastToParameter(node.left);
|
|
@@ -13348,28 +13632,17 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13348
13632
|
}
|
|
13349
13633
|
}
|
|
13350
13634
|
toAssignableParenthesizedExpression(node, isLHS) {
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13355
|
-
case "TSTypeAssertion":
|
|
13356
|
-
case "ParenthesizedExpression":
|
|
13357
|
-
this.toAssignable(node.expression, isLHS);
|
|
13358
|
-
break;
|
|
13359
|
-
default:
|
|
13360
|
-
super.toAssignable(node, isLHS);
|
|
13635
|
+
if (tsIsTypeCast(node.expression) || node.expression.type === "ParenthesizedExpression") {
|
|
13636
|
+
this.toAssignable(node.expression, isLHS);
|
|
13637
|
+
} else {
|
|
13638
|
+
super.toAssignable(node, isLHS);
|
|
13361
13639
|
}
|
|
13362
13640
|
}
|
|
13363
13641
|
checkToRestConversion(node, allowPattern) {
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
case "TSNonNullExpression":
|
|
13369
|
-
this.checkToRestConversion(node.expression, false);
|
|
13370
|
-
break;
|
|
13371
|
-
default:
|
|
13372
|
-
super.checkToRestConversion(node, allowPattern);
|
|
13642
|
+
if (tsIsTypeCast(node)) {
|
|
13643
|
+
this.checkToRestConversion(node.expression, false);
|
|
13644
|
+
} else {
|
|
13645
|
+
super.checkToRestConversion(node, allowPattern);
|
|
13373
13646
|
}
|
|
13374
13647
|
}
|
|
13375
13648
|
isValidLVal(type, disallowCallExpression, isUnparenthesizedInAssign, binding) {
|
|
@@ -13549,7 +13822,7 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13549
13822
|
if (this.match(76)) {
|
|
13550
13823
|
node.abstract = true;
|
|
13551
13824
|
return this.maybeTakeDecorators(decorators, this.parseClass(node, true, false));
|
|
13552
|
-
} else if (this.isContextual(
|
|
13825
|
+
} else if (this.isContextual(128)) {
|
|
13553
13826
|
if (!this.hasFollowingLineBreak()) {
|
|
13554
13827
|
node.abstract = true;
|
|
13555
13828
|
this.raise(TSErrors.NonClassMethodPropertyHasAbstractModifier, node);
|
|
@@ -13602,15 +13875,22 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13602
13875
|
node.exportKind = "value";
|
|
13603
13876
|
return super.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly);
|
|
13604
13877
|
}
|
|
13605
|
-
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly
|
|
13878
|
+
parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly) {
|
|
13606
13879
|
if (!importedIsString && isMaybeTypeOnly) {
|
|
13607
|
-
this.parseTypeOnlyImportSpecifier(specifier
|
|
13880
|
+
this.parseTypeOnlyImportSpecifier(specifier);
|
|
13608
13881
|
return this.finishNode(specifier, "ImportSpecifier");
|
|
13609
13882
|
}
|
|
13610
13883
|
specifier.importKind = "value";
|
|
13611
|
-
return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly
|
|
13884
|
+
return super.parseImportSpecifier(specifier, importedIsString, isInTypeOnlyImport, isMaybeTypeOnly);
|
|
13885
|
+
}
|
|
13886
|
+
checkImportSpecifier(specifier, isInTypeOnlyImport) {
|
|
13887
|
+
const hasTypeSpecifier = specifier.importKind === "type";
|
|
13888
|
+
if (hasTypeSpecifier && isInTypeOnlyImport) {
|
|
13889
|
+
this.raise(TSErrors.TypeModifierIsUsedInTypeImports, specifier);
|
|
13890
|
+
}
|
|
13891
|
+
super.checkImportSpecifier(specifier, isInTypeOnlyImport, hasTypeSpecifier || isInTypeOnlyImport ? 4098 : 4096);
|
|
13612
13892
|
}
|
|
13613
|
-
parseTypeOnlyImportSpecifier(node
|
|
13893
|
+
parseTypeOnlyImportSpecifier(node) {
|
|
13614
13894
|
let leftOfAs = node.imported;
|
|
13615
13895
|
let hasTypeSpecifier = false;
|
|
13616
13896
|
if (this.isContextual(90)) {
|
|
@@ -13633,16 +13913,10 @@ const typescript = superClass => class TypeScriptParserMixin extends superClass
|
|
|
13633
13913
|
} else if (tokenIsKeywordOrIdentifier(this.state.type)) {
|
|
13634
13914
|
hasTypeSpecifier = true;
|
|
13635
13915
|
leftOfAs = this.parseIdentifier(true);
|
|
13636
|
-
if (!this.isContextual(90)) {
|
|
13637
|
-
this.checkReservedWord(leftOfAs.name, leftOfAs.start, true, true);
|
|
13638
|
-
}
|
|
13639
|
-
}
|
|
13640
|
-
if (hasTypeSpecifier && isInTypeOnly) {
|
|
13641
|
-
this.raise(TSErrors.TypeModifierIsUsedInTypeImports, node.imported);
|
|
13642
13916
|
}
|
|
13643
13917
|
node.imported = leftOfAs;
|
|
13644
13918
|
node.importKind = hasTypeSpecifier ? "type" : "value";
|
|
13645
|
-
|
|
13919
|
+
node.local ??= this.eatContextual(90) ? this.parseIdentifier() : this.cloneIdentifier(node.imported);
|
|
13646
13920
|
}
|
|
13647
13921
|
parseTypeOnlyExportSpecifier(node, isInTypeOnly) {
|
|
13648
13922
|
const local = node.local;
|
|
@@ -13896,13 +14170,13 @@ const PlaceholderErrorTemplates = {
|
|
|
13896
14170
|
const PlaceholderErrors = ParseErrorEnum`placeholders`(PlaceholderErrorTemplates);
|
|
13897
14171
|
const placeholders = superClass => class PlaceholdersParserMixin extends superClass {
|
|
13898
14172
|
parsePlaceholder(expectedNode) {
|
|
13899
|
-
if (this.match(
|
|
14173
|
+
if (this.match(132)) {
|
|
13900
14174
|
const node = this.startNode();
|
|
13901
14175
|
this.next();
|
|
13902
14176
|
this.assertNoSpace();
|
|
13903
14177
|
node.name = super.parseIdentifier(true);
|
|
13904
14178
|
this.assertNoSpace();
|
|
13905
|
-
this.expect(
|
|
14179
|
+
this.expect(132);
|
|
13906
14180
|
return this.finishPlaceholder(node, expectedNode);
|
|
13907
14181
|
}
|
|
13908
14182
|
}
|
|
@@ -13916,7 +14190,7 @@ const placeholders = superClass => class PlaceholdersParserMixin extends superCl
|
|
|
13916
14190
|
}
|
|
13917
14191
|
getTokenFromCode(code) {
|
|
13918
14192
|
if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
|
|
13919
|
-
this.finishOp(
|
|
14193
|
+
this.finishOp(132, 2);
|
|
13920
14194
|
} else {
|
|
13921
14195
|
super.getTokenFromCode(code);
|
|
13922
14196
|
}
|
|
@@ -14000,7 +14274,7 @@ const placeholders = superClass => class PlaceholdersParserMixin extends superCl
|
|
|
14000
14274
|
const oldStrict = this.state.strict;
|
|
14001
14275
|
const placeholder = this.parsePlaceholder("Identifier");
|
|
14002
14276
|
if (placeholder) {
|
|
14003
|
-
if (this.match(77) || this.match(
|
|
14277
|
+
if (this.match(77) || this.match(132) || this.match(2)) {
|
|
14004
14278
|
node.id = placeholder;
|
|
14005
14279
|
} else if (optionalId || !isStatement) {
|
|
14006
14280
|
node.id = null;
|
|
@@ -14036,7 +14310,7 @@ const placeholders = superClass => class PlaceholdersParserMixin extends superCl
|
|
|
14036
14310
|
if (this.match(61)) {
|
|
14037
14311
|
const next = this.nextTokenStart();
|
|
14038
14312
|
if (this.isUnparsedContextual(next, "from")) {
|
|
14039
|
-
if (this.input.startsWith(tokenLabelName(
|
|
14313
|
+
if (this.input.startsWith(tokenLabelName(132), this.hasPlugin("exportDefaultFrom") ? this.nextTokenStartSince(next + 4) : this.nextTokenInLineStartSince(next + 4))) {
|
|
14040
14314
|
return true;
|
|
14041
14315
|
}
|
|
14042
14316
|
}
|
|
@@ -14064,7 +14338,7 @@ const placeholders = superClass => class PlaceholdersParserMixin extends superCl
|
|
|
14064
14338
|
node.specifiers.push(this.finishNode(specifier, "ImportDefaultSpecifier"));
|
|
14065
14339
|
if (this.eat(8)) {
|
|
14066
14340
|
const hasStarImport = this.maybeParseStarImportSpecifier(node);
|
|
14067
|
-
if (!hasStarImport) this.
|
|
14341
|
+
if (!hasStarImport) this.parseNamedOrFilteredImportSpecifiers(node);
|
|
14068
14342
|
}
|
|
14069
14343
|
this.expectContextual(95);
|
|
14070
14344
|
node.source = this.parseImportSource();
|
|
@@ -14087,6 +14361,7 @@ const v8intrinsic = superClass => class V8IntrinsicMixin extends superClass {
|
|
|
14087
14361
|
const node = this.startNode();
|
|
14088
14362
|
this.next();
|
|
14089
14363
|
if (tokenIsIdentifier(this.state.type)) {
|
|
14364
|
+
this.setLoc(this.state.startLoc);
|
|
14090
14365
|
const name = this.parseIdentifierName();
|
|
14091
14366
|
const identifier = this.createIdentifier(node, name);
|
|
14092
14367
|
this.castNodeTo(identifier, "V8IntrinsicIdentifier");
|
|
@@ -14166,6 +14441,9 @@ function validatePlugins(pluginsMap) {
|
|
|
14166
14441
|
if (pluginsMap.has("importReflection")) {
|
|
14167
14442
|
throw new Error("The 'importReflection' plugin has been removed in Babel 8. Use 'sourcePhaseImports' instead, and " + "replace 'import module' with 'import source' in your code.");
|
|
14168
14443
|
}
|
|
14444
|
+
if (pluginsMap.has("deferredReexports") && !pluginsMap.has("deferredImportEvaluation")) {
|
|
14445
|
+
throw new Error("The 'deferredReexports' plugin requires 'deferredImportEvaluation'.");
|
|
14446
|
+
}
|
|
14169
14447
|
}
|
|
14170
14448
|
const mixinPlugins = {
|
|
14171
14449
|
estree,
|
|
@@ -14357,7 +14635,12 @@ function literalValue(node, source) {
|
|
|
14357
14635
|
case "ObjectExpression":
|
|
14358
14636
|
return Object.fromEntries(expression.properties.flatMap((property) => {
|
|
14359
14637
|
const key = keyOf(property);
|
|
14360
|
-
return key && property.type === "ObjectProperty" ? [
|
|
14638
|
+
return key && property.type === "ObjectProperty" ? [
|
|
14639
|
+
[
|
|
14640
|
+
key,
|
|
14641
|
+
literalValue(property.value, source)
|
|
14642
|
+
]
|
|
14643
|
+
] : [];
|
|
14361
14644
|
}));
|
|
14362
14645
|
default:
|
|
14363
14646
|
return `<expr: ${sourceOf(expression, source)}>`;
|
|
@@ -14384,7 +14667,11 @@ function findPresetCalls(node, found, name) {
|
|
|
14384
14667
|
function readPresets(file, source) {
|
|
14385
14668
|
let program;
|
|
14386
14669
|
try {
|
|
14387
|
-
program = parse(source, {
|
|
14670
|
+
program = parse(source, {
|
|
14671
|
+
sourceType: "module",
|
|
14672
|
+
plugins: ["typescript"],
|
|
14673
|
+
errorRecovery: true
|
|
14674
|
+
}).program;
|
|
14388
14675
|
} catch {
|
|
14389
14676
|
return [];
|
|
14390
14677
|
}
|
|
@@ -14397,19 +14684,24 @@ function readPresets(file, source) {
|
|
|
14397
14684
|
const options = literalValue(argument, source);
|
|
14398
14685
|
const base = options.base;
|
|
14399
14686
|
const overrides = options.overrides;
|
|
14400
|
-
return [
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14687
|
+
return [
|
|
14688
|
+
{
|
|
14689
|
+
file,
|
|
14690
|
+
exportName: name,
|
|
14691
|
+
base: typeof base === "string" ? base.replace(/^<expr: (.*)>$/, "$1") : void 0,
|
|
14692
|
+
overrides: overrides && typeof overrides === "object" && !Array.isArray(overrides) ? overrides : {}
|
|
14693
|
+
}
|
|
14694
|
+
];
|
|
14406
14695
|
});
|
|
14407
14696
|
}
|
|
14408
14697
|
|
|
14409
14698
|
const BLOCK_AT_RULES = /^@(?:utility|keyframes|custom-variant)\s/;
|
|
14410
14699
|
function blankComments(css, comments) {
|
|
14411
14700
|
return css.replaceAll(/\/\*([\s\S]*?)\*\//g, (match, text, index) => {
|
|
14412
|
-
comments.push({
|
|
14701
|
+
comments.push({
|
|
14702
|
+
end: index + match.length,
|
|
14703
|
+
text: text.replaceAll(/\s*\n\s*\*?\s*/g, " ").trim()
|
|
14704
|
+
});
|
|
14413
14705
|
return match.replaceAll(/[^\n]/g, " ");
|
|
14414
14706
|
});
|
|
14415
14707
|
}
|
|
@@ -14462,44 +14754,149 @@ function parseCss(source) {
|
|
|
14462
14754
|
flush(index);
|
|
14463
14755
|
start = index + 1;
|
|
14464
14756
|
} else if (char === "{") {
|
|
14465
|
-
stack.push({
|
|
14757
|
+
stack.push({
|
|
14758
|
+
prelude: css.slice(start, index).trim().replaceAll(/\s+/g, " "),
|
|
14759
|
+
open: index
|
|
14760
|
+
});
|
|
14466
14761
|
start = index + 1;
|
|
14467
14762
|
} else if (char === "}") {
|
|
14468
14763
|
flush(index);
|
|
14469
14764
|
start = index + 1;
|
|
14470
14765
|
const block = stack.pop();
|
|
14471
|
-
if (block && BLOCK_AT_RULES.test(block.prelude))
|
|
14472
|
-
result.blocks.push({
|
|
14766
|
+
if (block && BLOCK_AT_RULES.test(block.prelude)) {
|
|
14767
|
+
result.blocks.push({
|
|
14768
|
+
prelude: block.prelude,
|
|
14769
|
+
body: css.slice(block.open + 1, index).trim().replaceAll(/\s+/g, " ")
|
|
14770
|
+
});
|
|
14771
|
+
}
|
|
14473
14772
|
}
|
|
14474
14773
|
}
|
|
14475
14774
|
return result;
|
|
14476
14775
|
}
|
|
14477
14776
|
const NAMESPACES = [
|
|
14478
|
-
{
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
{
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
{
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
{
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14777
|
+
{
|
|
14778
|
+
prefix: "--color-",
|
|
14779
|
+
topic: "colors",
|
|
14780
|
+
usage: (name) => `bg-${name} text-${name} border-${name}...`
|
|
14781
|
+
},
|
|
14782
|
+
{
|
|
14783
|
+
prefix: "--font-weight-",
|
|
14784
|
+
topic: "typography",
|
|
14785
|
+
usage: (name) => `font-${name}`
|
|
14786
|
+
},
|
|
14787
|
+
{
|
|
14788
|
+
prefix: "--font-",
|
|
14789
|
+
topic: "typography",
|
|
14790
|
+
usage: (name) => `font-${name}`
|
|
14791
|
+
},
|
|
14792
|
+
{
|
|
14793
|
+
prefix: "--text-shadow-",
|
|
14794
|
+
topic: "shadows",
|
|
14795
|
+
usage: (name) => `text-shadow-${name}`
|
|
14796
|
+
},
|
|
14797
|
+
{
|
|
14798
|
+
prefix: "--text-",
|
|
14799
|
+
topic: "typography",
|
|
14800
|
+
usage: (name) => `text-${name}`
|
|
14801
|
+
},
|
|
14802
|
+
{
|
|
14803
|
+
prefix: "--tracking-",
|
|
14804
|
+
topic: "typography",
|
|
14805
|
+
usage: (name) => `tracking-${name}`
|
|
14806
|
+
},
|
|
14807
|
+
{
|
|
14808
|
+
prefix: "--leading-",
|
|
14809
|
+
topic: "typography",
|
|
14810
|
+
usage: (name) => `leading-${name}`
|
|
14811
|
+
},
|
|
14812
|
+
{
|
|
14813
|
+
prefix: "--animate-",
|
|
14814
|
+
topic: "typography",
|
|
14815
|
+
usage: (name) => `animate-${name}`
|
|
14816
|
+
},
|
|
14817
|
+
{
|
|
14818
|
+
prefix: "--ease-",
|
|
14819
|
+
topic: "typography",
|
|
14820
|
+
usage: (name) => `ease-${name}`
|
|
14821
|
+
},
|
|
14822
|
+
{
|
|
14823
|
+
prefix: "--duration-",
|
|
14824
|
+
topic: "typography",
|
|
14825
|
+
usage: (name) => `duration-(--duration-${name})`
|
|
14826
|
+
},
|
|
14827
|
+
{
|
|
14828
|
+
prefix: "--radius-",
|
|
14829
|
+
topic: "radius",
|
|
14830
|
+
usage: (name) => `rounded-${name}`
|
|
14831
|
+
},
|
|
14832
|
+
{
|
|
14833
|
+
prefix: "--inset-shadow-",
|
|
14834
|
+
topic: "shadows",
|
|
14835
|
+
usage: (name) => `inset-shadow-${name}`
|
|
14836
|
+
},
|
|
14837
|
+
{
|
|
14838
|
+
prefix: "--drop-shadow-",
|
|
14839
|
+
topic: "shadows",
|
|
14840
|
+
usage: (name) => `drop-shadow-${name}`
|
|
14841
|
+
},
|
|
14842
|
+
{
|
|
14843
|
+
prefix: "--shadow-",
|
|
14844
|
+
topic: "shadows",
|
|
14845
|
+
usage: (name) => `shadow-${name}`
|
|
14846
|
+
},
|
|
14847
|
+
{
|
|
14848
|
+
prefix: "--spacing-",
|
|
14849
|
+
topic: "spacing",
|
|
14850
|
+
usage: (name) => `p-${name} gap-${name} w-${name}...`
|
|
14851
|
+
},
|
|
14852
|
+
{
|
|
14853
|
+
prefix: "--breakpoint-",
|
|
14854
|
+
topic: "breakpoints",
|
|
14855
|
+
usage: (name) => `${name}:`
|
|
14856
|
+
},
|
|
14857
|
+
{
|
|
14858
|
+
prefix: "--container-",
|
|
14859
|
+
topic: "layout",
|
|
14860
|
+
usage: (name) => `max-w-${name} @${name}:`
|
|
14861
|
+
},
|
|
14862
|
+
{
|
|
14863
|
+
prefix: "--aspect-",
|
|
14864
|
+
topic: "layout",
|
|
14865
|
+
usage: (name) => `aspect-${name}`
|
|
14866
|
+
},
|
|
14867
|
+
{
|
|
14868
|
+
prefix: "--z-",
|
|
14869
|
+
topic: "z-index",
|
|
14870
|
+
usage: (name) => `z-${name}`
|
|
14871
|
+
}
|
|
14497
14872
|
];
|
|
14498
14873
|
function tokenOf(variable, value, { inline = false, comment } = {}) {
|
|
14499
|
-
if (variable === "--spacing")
|
|
14500
|
-
return {
|
|
14874
|
+
if (variable === "--spacing") {
|
|
14875
|
+
return {
|
|
14876
|
+
variable,
|
|
14877
|
+
value,
|
|
14878
|
+
topic: "spacing",
|
|
14879
|
+
usage: "p-4 gap-2 w-8... (base step)",
|
|
14880
|
+
inline,
|
|
14881
|
+
comment
|
|
14882
|
+
};
|
|
14883
|
+
}
|
|
14501
14884
|
const namespace = NAMESPACES.find((entry) => variable.startsWith(entry.prefix));
|
|
14502
|
-
return namespace ? {
|
|
14885
|
+
return namespace ? {
|
|
14886
|
+
variable,
|
|
14887
|
+
value,
|
|
14888
|
+
topic: namespace.topic,
|
|
14889
|
+
usage: namespace.usage(variable.slice(namespace.prefix.length)),
|
|
14890
|
+
inline,
|
|
14891
|
+
comment
|
|
14892
|
+
} : {
|
|
14893
|
+
variable,
|
|
14894
|
+
value,
|
|
14895
|
+
topic: "css-variables",
|
|
14896
|
+
usage: `var(${variable})`,
|
|
14897
|
+
inline,
|
|
14898
|
+
comment
|
|
14899
|
+
};
|
|
14503
14900
|
}
|
|
14504
14901
|
function importPath(statement) {
|
|
14505
14902
|
return /^@import\s+(?:url\()?\s*["']([^"']+)["']/.exec(statement)?.[1];
|
|
@@ -14509,7 +14906,16 @@ function themeContext(context) {
|
|
|
14509
14906
|
}
|
|
14510
14907
|
function readStylesheet(file, source) {
|
|
14511
14908
|
const { declarations, statements, blocks } = parseCss(source);
|
|
14512
|
-
const stylesheet = {
|
|
14909
|
+
const stylesheet = {
|
|
14910
|
+
file,
|
|
14911
|
+
imports: [],
|
|
14912
|
+
tokens: [],
|
|
14913
|
+
resets: [],
|
|
14914
|
+
variants: [],
|
|
14915
|
+
utilities: [],
|
|
14916
|
+
keyframes: [],
|
|
14917
|
+
mazVariables: []
|
|
14918
|
+
};
|
|
14513
14919
|
for (const statement of statements) {
|
|
14514
14920
|
const path = importPath(statement);
|
|
14515
14921
|
const variant = /^@custom-variant ([\w-]+) (.+)$/.exec(statement);
|
|
@@ -14530,12 +14936,20 @@ function readStylesheet(file, source) {
|
|
|
14530
14936
|
for (const { property, value, context, comment } of declarations) {
|
|
14531
14937
|
const theme = themeContext(context);
|
|
14532
14938
|
if (theme && property.startsWith("--")) {
|
|
14533
|
-
if (value === "initial")
|
|
14939
|
+
if (value === "initial") {
|
|
14534
14940
|
stylesheet.resets.push(property);
|
|
14535
|
-
else if (!/^--[\w-]+--/.test(property))
|
|
14536
|
-
stylesheet.tokens.push(tokenOf(property, value, {
|
|
14941
|
+
} else if (!/^--[\w-]+--/.test(property)) {
|
|
14942
|
+
stylesheet.tokens.push(tokenOf(property, value, {
|
|
14943
|
+
inline: /\binline\b/.test(theme),
|
|
14944
|
+
comment
|
|
14945
|
+
}));
|
|
14946
|
+
}
|
|
14537
14947
|
} else if (!theme && property.startsWith("--maz-")) {
|
|
14538
|
-
stylesheet.mazVariables.push({
|
|
14948
|
+
stylesheet.mazVariables.push({
|
|
14949
|
+
variable: property,
|
|
14950
|
+
value,
|
|
14951
|
+
selector: context.filter((prelude) => !prelude.startsWith("@layer")).join(" ")
|
|
14952
|
+
});
|
|
14539
14953
|
}
|
|
14540
14954
|
}
|
|
14541
14955
|
return stylesheet;
|
|
@@ -14556,11 +14970,30 @@ const IGNORED = [
|
|
|
14556
14970
|
"**/*.{spec,test}.*"
|
|
14557
14971
|
];
|
|
14558
14972
|
const MAX_FILE_SIZE = 3e5;
|
|
14559
|
-
const PATTERNS = [
|
|
14973
|
+
const PATTERNS = [
|
|
14974
|
+
"*.css",
|
|
14975
|
+
"*.ts",
|
|
14976
|
+
"*.mts",
|
|
14977
|
+
"*.cts",
|
|
14978
|
+
"*.js",
|
|
14979
|
+
"*.mjs"
|
|
14980
|
+
];
|
|
14560
14981
|
const IGNORED_PATH = /(?:^|\/)(?:node_modules|dist|build|coverage|public|fixtures|__tests__|\.[^/]+)\/|\.min\.css$|\.d\.ts$|\.(?:spec|test)\.\w+$/;
|
|
14561
14982
|
function projectFiles(rootDir) {
|
|
14562
14983
|
try {
|
|
14563
|
-
return execFileSync("git", [
|
|
14984
|
+
return execFileSync("git", [
|
|
14985
|
+
"ls-files",
|
|
14986
|
+
"--cached",
|
|
14987
|
+
"--others",
|
|
14988
|
+
"--exclude-standard",
|
|
14989
|
+
"--",
|
|
14990
|
+
...PATTERNS
|
|
14991
|
+
], {
|
|
14992
|
+
cwd: rootDir,
|
|
14993
|
+
encoding: "utf8",
|
|
14994
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
14995
|
+
maxBuffer: 64 * 1024 * 1024
|
|
14996
|
+
}).split("\n").filter((file) => file && !IGNORED_PATH.test(file));
|
|
14564
14997
|
} catch {
|
|
14565
14998
|
return globSync(PATTERNS.map((pattern) => `**/${pattern}`), { cwd: rootDir, ignore: IGNORED, deep: 8 }).filter((file) => !IGNORED_PATH.test(file));
|
|
14566
14999
|
}
|
|
@@ -14642,7 +15075,12 @@ function presetColors(preset) {
|
|
|
14642
15075
|
const colors = asRecord(preset.overrides.colors);
|
|
14643
15076
|
const light = asRecord(colors.light);
|
|
14644
15077
|
const dark = asRecord(colors.dark);
|
|
14645
|
-
const names = [
|
|
15078
|
+
const names = [
|
|
15079
|
+
.../* @__PURE__ */ new Set([
|
|
15080
|
+
...Object.keys(light),
|
|
15081
|
+
...Object.keys(dark)
|
|
15082
|
+
])
|
|
15083
|
+
];
|
|
14646
15084
|
if (names.length === 0)
|
|
14647
15085
|
return [];
|
|
14648
15086
|
return [
|
|
@@ -14666,8 +15104,11 @@ function presetScales(preset, wanted) {
|
|
|
14666
15104
|
function flatten(value, path) {
|
|
14667
15105
|
const record = asRecord(value);
|
|
14668
15106
|
const keys = Object.keys(record);
|
|
14669
|
-
if (keys.length === 0 || keys.every((key) => key === "light" || key === "dark"))
|
|
14670
|
-
return [
|
|
15107
|
+
if (keys.length === 0 || keys.every((key) => key === "light" || key === "dark")) {
|
|
15108
|
+
return [
|
|
15109
|
+
[path, value]
|
|
15110
|
+
];
|
|
15111
|
+
}
|
|
14671
15112
|
return keys.flatMap((key) => flatten(record[key], path ? `${path}.${key}` : key));
|
|
14672
15113
|
}
|
|
14673
15114
|
function presetComponents(preset) {
|
|
@@ -14731,10 +15172,24 @@ function renderStylesheet(stylesheet, mazUi, wanted, animated) {
|
|
|
14731
15172
|
}
|
|
14732
15173
|
if (stylesheet.resets.length > 0 && wanted("colors"))
|
|
14733
15174
|
sections.push(`Reset namespaces: ${stylesheet.resets.map((reset) => code(reset)).join(", ")}: the default Tailwind tokens of these namespaces do not exist.`);
|
|
14734
|
-
if (stylesheet.variants.length > 0 && (wanted("variants") || wanted("breakpoints")))
|
|
14735
|
-
sections.push([
|
|
14736
|
-
|
|
14737
|
-
|
|
15175
|
+
if (stylesheet.variants.length > 0 && (wanted("variants") || wanted("breakpoints"))) {
|
|
15176
|
+
sections.push([
|
|
15177
|
+
"#### Custom variants",
|
|
15178
|
+
"",
|
|
15179
|
+
"| Variant | Definition |",
|
|
15180
|
+
"| --- | --- |",
|
|
15181
|
+
...stylesheet.variants.map((variant) => `| \`${variant.name}:\` | ${code(shorten(variant.definition))} |`)
|
|
15182
|
+
].join("\n"));
|
|
15183
|
+
}
|
|
15184
|
+
if (stylesheet.utilities.length > 0 && wanted("utilities")) {
|
|
15185
|
+
sections.push([
|
|
15186
|
+
"#### Custom utilities",
|
|
15187
|
+
"",
|
|
15188
|
+
"| Class | CSS |",
|
|
15189
|
+
"| --- | --- |",
|
|
15190
|
+
...stylesheet.utilities.map((utility) => `| \`${utility.name}\` | ${code(shorten(utility.css))} |`)
|
|
15191
|
+
].join("\n"));
|
|
15192
|
+
}
|
|
14738
15193
|
const keyframes = stylesheet.keyframes.filter((name) => !animated.has(name));
|
|
14739
15194
|
if (keyframes.length > 0 && wanted("typography"))
|
|
14740
15195
|
sections.push(`Keyframes without \`animate-*\` token: ${keyframes.map((name) => code(name)).join(", ")}. Use them in CSS or add a \`--animate-<name>\` token to the \`@theme\` to get a class.`);
|
|
@@ -14754,7 +15209,11 @@ function renderStylesheetSection(stylesheet, mazUi, topics, animated) {
|
|
|
14754
15209
|
if (topics?.length && sections.length === 0)
|
|
14755
15210
|
return void 0;
|
|
14756
15211
|
const imports = stylesheet.imports.length > 0 ? [`Imports: ${stylesheet.imports.map((path) => code(path)).join(", ")}`] : [];
|
|
14757
|
-
return [
|
|
15212
|
+
return [
|
|
15213
|
+
`### Tailwind \`${stylesheet.file}\``,
|
|
15214
|
+
...imports,
|
|
15215
|
+
...sections
|
|
15216
|
+
].join("\n\n");
|
|
14758
15217
|
}
|
|
14759
15218
|
function stylesheetProblems(stylesheet) {
|
|
14760
15219
|
if (!stylesheet.imports.includes("tailwindcss"))
|