@tinacms/app 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/appFiles/node_modules/.package-lock.json +23 -23
  2. package/appFiles/node_modules/@babel/generator/lib/generators/methods.js +3 -1
  3. package/appFiles/node_modules/@babel/generator/lib/generators/methods.js.map +1 -1
  4. package/appFiles/node_modules/@babel/generator/lib/index.js +11 -0
  5. package/appFiles/node_modules/@babel/generator/lib/index.js.map +1 -1
  6. package/appFiles/node_modules/@babel/generator/lib/printer.js +38 -21
  7. package/appFiles/node_modules/@babel/generator/lib/printer.js.map +1 -1
  8. package/appFiles/node_modules/@babel/generator/package.json +3 -3
  9. package/appFiles/node_modules/@babel/parser/lib/index.js +164 -98
  10. package/appFiles/node_modules/@babel/parser/lib/index.js.map +1 -1
  11. package/appFiles/node_modules/@babel/parser/package.json +2 -2
  12. package/appFiles/node_modules/@babel/parser/typings/babel-parser.d.ts +1 -1
  13. package/appFiles/node_modules/@babel/runtime/helpers/checkInRHS.js +6 -0
  14. package/appFiles/node_modules/@babel/runtime/helpers/createClass.js +2 -1
  15. package/appFiles/node_modules/@babel/runtime/helpers/defineProperty.js +2 -0
  16. package/appFiles/node_modules/@babel/runtime/helpers/esm/checkInRHS.js +5 -0
  17. package/appFiles/node_modules/@babel/runtime/helpers/esm/createClass.js +2 -1
  18. package/appFiles/node_modules/@babel/runtime/helpers/esm/defineProperty.js +2 -0
  19. package/appFiles/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +23 -18
  20. package/appFiles/node_modules/@babel/runtime/helpers/esm/iterableToArrayLimitLoose.js +8 -7
  21. package/appFiles/node_modules/@babel/runtime/helpers/esm/regeneratorRuntime.js +3 -8
  22. package/appFiles/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js +23 -18
  23. package/appFiles/node_modules/@babel/runtime/helpers/iterableToArrayLimitLoose.js +8 -7
  24. package/appFiles/node_modules/@babel/runtime/helpers/regeneratorRuntime.js +3 -8
  25. package/appFiles/node_modules/@babel/runtime/package.json +29 -20
  26. package/appFiles/node_modules/@babel/traverse/lib/path/context.js +3 -2
  27. package/appFiles/node_modules/@babel/traverse/lib/path/context.js.map +1 -1
  28. package/appFiles/node_modules/@babel/traverse/lib/path/conversion.js +8 -4
  29. package/appFiles/node_modules/@babel/traverse/lib/path/conversion.js.map +1 -1
  30. package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js +1 -0
  31. package/appFiles/node_modules/@babel/traverse/lib/path/inference/inferer-reference.js.map +1 -1
  32. package/appFiles/node_modules/@babel/traverse/lib/scope/index.js +1 -1
  33. package/appFiles/node_modules/@babel/traverse/lib/scope/index.js.map +1 -1
  34. package/appFiles/node_modules/@babel/traverse/package.json +4 -4
  35. package/appFiles/node_modules/@babel/types/lib/index.d.ts +64 -64
  36. package/appFiles/node_modules/@babel/types/package.json +3 -3
  37. package/appFiles/node_modules/regenerator-runtime/package.json +2 -2
  38. package/appFiles/node_modules/regenerator-runtime/runtime.js +18 -17
  39. package/appFiles/src/App.tsx +0 -12
  40. package/appFiles/src/fields/rich-text/monaco/mdx.js +0 -46
  41. package/appFiles/src/lib/machines/query-machine.ts +137 -2
  42. package/appFiles/src/preview.tsx +9 -15
  43. package/dist/index.js +7 -5
  44. package/package.json +3 -3
  45. package/appFiles/node_modules/@babel/parser/typings/babel-parser.source.d.ts +0 -151
@@ -455,6 +455,7 @@ var estree = (superClass => class ESTreeParserMixin extends superClass {
455
455
  regex = new RegExp(pattern, flags);
456
456
  } catch (e) {
457
457
  }
458
+
458
459
  const node = this.estreeParseLiteral(regex);
459
460
  node.regex = {
460
461
  pattern,
@@ -5293,7 +5294,7 @@ var flow = (superClass => class FlowParserMixin extends superClass {
5293
5294
  return super.parseFunctionBodyAndFinish(node, type, isMethod);
5294
5295
  }
5295
5296
 
5296
- parseStatement(context, topLevel) {
5297
+ parseStatementLike(flags) {
5297
5298
  if (this.state.strict && this.isContextual(127)) {
5298
5299
  const lookahead = this.lookahead();
5299
5300
  if (tokenIsKeywordOrIdentifier(lookahead.type)) {
@@ -5306,7 +5307,7 @@ var flow = (superClass => class FlowParserMixin extends superClass {
5306
5307
  this.next();
5307
5308
  return this.flowParseEnumDeclaration(node);
5308
5309
  }
5309
- const stmt = super.parseStatement(context, topLevel);
5310
+ const stmt = super.parseStatementLike(flags);
5310
5311
  if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
5311
5312
  this.flowPragma = null;
5312
5313
  }
@@ -8729,7 +8730,7 @@ var typescript = (superClass => class TypeScriptParserMixin extends superClass {
8729
8730
  return this.tsInAmbientContext(() => {
8730
8731
  if (starttype === 68) {
8731
8732
  nany.declare = true;
8732
- return super.parseFunctionStatement(nany, false, true);
8733
+ return super.parseFunctionStatement(nany, false, false);
8733
8734
  }
8734
8735
  if (starttype === 80) {
8735
8736
  nany.declare = true;
@@ -9204,7 +9205,7 @@ var typescript = (superClass => class TypeScriptParserMixin extends superClass {
9204
9205
  }
9205
9206
  return declaration;
9206
9207
  }
9207
- parseStatementContent(context, topLevel, decorators) {
9208
+ parseStatementContent(flags, decorators) {
9208
9209
  if (this.match(75) && this.isLookaheadContextual("enum")) {
9209
9210
  const node = this.startNode();
9210
9211
  this.expect(75);
@@ -9219,7 +9220,7 @@ var typescript = (superClass => class TypeScriptParserMixin extends superClass {
9219
9220
  const result = this.tsParseInterfaceDeclaration(this.startNode());
9220
9221
  if (result) return result;
9221
9222
  }
9222
- return super.parseStatementContent(context, topLevel, decorators);
9223
+ return super.parseStatementContent(flags, decorators);
9223
9224
  }
9224
9225
  parseAccessModifier() {
9225
9226
  return this.tsParseModifier(["public", "protected", "private"]);
@@ -10048,11 +10049,10 @@ var placeholders = (superClass => class PlaceholdersParserMixin extends superCla
10048
10049
  }
10049
10050
  }
10050
10051
 
10051
- hasFollowingIdentifier(context) {
10052
- if (super.hasFollowingIdentifier(context)) {
10052
+ chStartsBindingIdentifier(ch, pos) {
10053
+ if (super.chStartsBindingIdentifier(ch, pos)) {
10053
10054
  return true;
10054
10055
  }
10055
- if (context) return false;
10056
10056
 
10057
10057
  const nextToken = this.lookahead();
10058
10058
  if (nextToken.type === 142) {
@@ -10073,7 +10073,7 @@ var placeholders = (superClass => class PlaceholdersParserMixin extends superCla
10073
10073
  const stmt = node;
10074
10074
  stmt.label = this.finishPlaceholder(expr, "Identifier");
10075
10075
  this.next();
10076
- stmt.body = super.parseStatement("label");
10076
+ stmt.body = super.parseStatementOrFunctionDeclaration(false);
10077
10077
  return this.finishNode(stmt, "LabeledStatement");
10078
10078
  }
10079
10079
  this.semicolon();
@@ -11547,7 +11547,7 @@ class ExpressionParser extends LValParser {
11547
11547
  if (type === 68) {
11548
11548
  this.resetPreviousNodeTrailingComments(id);
11549
11549
  this.next();
11550
- return this.parseFunction(this.startNodeAtNode(id), undefined, true);
11550
+ return this.parseAsyncFunctionExpression(this.startNodeAtNode(id));
11551
11551
  } else if (tokenIsIdentifier(type)) {
11552
11552
  if (this.lookaheadCharCode() === 61) {
11553
11553
  return this.parseAsyncArrowUnaryFunction(this.startNodeAtNode(id));
@@ -12213,12 +12213,12 @@ class ExpressionParser extends LValParser {
12213
12213
  initFunction(node, isAsync) {
12214
12214
  node.id = null;
12215
12215
  node.generator = false;
12216
- node.async = !!isAsync;
12216
+ node.async = isAsync;
12217
12217
  }
12218
12218
 
12219
12219
  parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
12220
12220
  this.initFunction(node, isAsync);
12221
- node.generator = !!isGenerator;
12221
+ node.generator = isGenerator;
12222
12222
  const allowModifiers = isConstructor;
12223
12223
  this.scope.enter(SCOPE_FUNCTION | SCOPE_SUPER | (inClassScope ? SCOPE_CLASS : 0) | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
12224
12224
  this.prodParam.enter(functionFlags(isAsync, node.generator));
@@ -12702,10 +12702,20 @@ const loopLabel = {
12702
12702
  switchLabel = {
12703
12703
  kind: "switch"
12704
12704
  };
12705
- const FUNC_NO_FLAGS = 0b000,
12706
- FUNC_STATEMENT = 0b001,
12707
- FUNC_HANGING_STATEMENT = 0b010,
12708
- FUNC_NULLABLE_ID = 0b100;
12705
+ var ParseFunctionFlag = {
12706
+ Expression: 0,
12707
+ Declaration: 1,
12708
+ HangingDeclaration: 2,
12709
+ NullableId: 4,
12710
+ Async: 8
12711
+ };
12712
+ var ParseStatementFlag = {
12713
+ StatementOnly: 0,
12714
+ AllowImportExport: 1,
12715
+ AllowDeclaration: 2,
12716
+ AllowFunctionDeclaration: 4,
12717
+ AllowLabeledFunction: 8
12718
+ };
12709
12719
  const loneSurrogate = /[\uD800-\uDFFF]/u;
12710
12720
  const keywordRelationalOperator = /in(?:stanceof)?/y;
12711
12721
 
@@ -12872,23 +12882,15 @@ class StatementParser extends ExpressionParser {
12872
12882
  this.next();
12873
12883
  return this.finishNode(node, "InterpreterDirective");
12874
12884
  }
12875
- isLet(context) {
12885
+ isLet() {
12876
12886
  if (!this.isContextual(99)) {
12877
12887
  return false;
12878
12888
  }
12879
- return this.hasFollowingIdentifier(context);
12889
+ return this.hasFollowingBindingAtom();
12880
12890
  }
12881
-
12882
- hasFollowingIdentifier(context) {
12883
- const next = this.nextTokenStart();
12884
- const nextCh = this.codePointAtPos(next);
12885
- if (nextCh === 92 || nextCh === 91) {
12886
- return true;
12887
- }
12888
- if (context) return false;
12889
- if (nextCh === 123) return true;
12890
- if (isIdentifierStart(nextCh)) {
12891
- keywordRelationalOperator.lastIndex = next;
12891
+ chStartsBindingIdentifier(ch, pos) {
12892
+ if (isIdentifierStart(ch)) {
12893
+ keywordRelationalOperator.lastIndex = pos;
12892
12894
  if (keywordRelationalOperator.test(this.input)) {
12893
12895
  const endCh = this.codePointAtPos(keywordRelationalOperator.lastIndex);
12894
12896
  if (!isIdentifierChar(endCh) && endCh !== 92) {
@@ -12896,8 +12898,26 @@ class StatementParser extends ExpressionParser {
12896
12898
  }
12897
12899
  }
12898
12900
  return true;
12901
+ } else if (ch === 92) {
12902
+ return true;
12903
+ } else {
12904
+ return false;
12899
12905
  }
12900
- return false;
12906
+ }
12907
+ chStartsBindingPattern(ch) {
12908
+ return ch === 91 || ch === 123;
12909
+ }
12910
+
12911
+ hasFollowingBindingAtom() {
12912
+ const next = this.nextTokenStart();
12913
+ const nextCh = this.codePointAtPos(next);
12914
+ return this.chStartsBindingPattern(nextCh) || this.chStartsBindingIdentifier(nextCh, next);
12915
+ }
12916
+
12917
+ hasFollowingBindingIdentifier() {
12918
+ const next = this.nextTokenStart();
12919
+ const nextCh = this.codePointAtPos(next);
12920
+ return this.chStartsBindingIdentifier(nextCh, next);
12901
12921
  }
12902
12922
  startsUsingForOf() {
12903
12923
  const lookahead = this.lookahead();
@@ -12909,16 +12929,34 @@ class StatementParser extends ExpressionParser {
12909
12929
  }
12910
12930
  }
12911
12931
 
12912
- parseStatement(context, topLevel) {
12932
+ parseModuleItem() {
12933
+ return this.parseStatementLike(ParseStatementFlag.AllowImportExport | ParseStatementFlag.AllowDeclaration | ParseStatementFlag.AllowFunctionDeclaration | ParseStatementFlag.AllowLabeledFunction);
12934
+ }
12935
+
12936
+ parseStatementListItem() {
12937
+ return this.parseStatementLike(ParseStatementFlag.AllowDeclaration | ParseStatementFlag.AllowFunctionDeclaration | ParseStatementFlag.AllowLabeledFunction);
12938
+ }
12939
+ parseStatementOrFunctionDeclaration(disallowLabeledFunction) {
12940
+ return this.parseStatementLike(ParseStatementFlag.AllowFunctionDeclaration | (disallowLabeledFunction ? 0 : ParseStatementFlag.AllowLabeledFunction));
12941
+ }
12942
+
12943
+ parseStatement() {
12944
+ return this.parseStatementLike(ParseStatementFlag.StatementOnly);
12945
+ }
12946
+
12947
+ parseStatementLike(flags) {
12913
12948
  let decorators = null;
12914
12949
  if (this.match(26)) {
12915
12950
  decorators = this.parseDecorators(true);
12916
12951
  }
12917
- return this.parseStatementContent(context, topLevel, decorators);
12952
+ return this.parseStatementContent(flags, decorators);
12918
12953
  }
12919
- parseStatementContent(context, topLevel, decorators) {
12954
+ parseStatementContent(flags, decorators) {
12920
12955
  const starttype = this.state.type;
12921
12956
  const node = this.startNode();
12957
+ const allowDeclaration = !!(flags & ParseStatementFlag.AllowDeclaration);
12958
+ const allowFunctionDeclaration = !!(flags & ParseStatementFlag.AllowFunctionDeclaration);
12959
+ const topLevel = flags & ParseStatementFlag.AllowImportExport;
12922
12960
 
12923
12961
  switch (starttype) {
12924
12962
  case 60:
@@ -12928,25 +12966,25 @@ class StatementParser extends ExpressionParser {
12928
12966
  case 64:
12929
12967
  return this.parseDebuggerStatement(node);
12930
12968
  case 90:
12931
- return this.parseDoStatement(node);
12969
+ return this.parseDoWhileStatement(node);
12932
12970
  case 91:
12933
12971
  return this.parseForStatement(node);
12934
12972
  case 68:
12935
12973
  if (this.lookaheadCharCode() === 46) break;
12936
- if (context) {
12974
+ if (!allowDeclaration) {
12937
12975
  if (this.state.strict) {
12938
12976
  this.raise(Errors.StrictFunction, {
12939
12977
  at: this.state.startLoc
12940
12978
  });
12941
- } else if (context !== "if" && context !== "label") {
12979
+ } else if (!allowFunctionDeclaration) {
12942
12980
  this.raise(Errors.SloppyFunction, {
12943
12981
  at: this.state.startLoc
12944
12982
  });
12945
12983
  }
12946
12984
  }
12947
- return this.parseFunctionStatement(node, false, !context);
12985
+ return this.parseFunctionStatement(node, false, !allowDeclaration && allowFunctionDeclaration);
12948
12986
  case 80:
12949
- if (context) this.unexpected();
12987
+ if (!allowDeclaration) this.unexpected();
12950
12988
  return this.parseClass(this.maybeTakeDecorators(decorators, node), true);
12951
12989
  case 69:
12952
12990
  return this.parseIfStatement(node);
@@ -12959,30 +12997,45 @@ class StatementParser extends ExpressionParser {
12959
12997
  case 73:
12960
12998
  return this.parseTryStatement(node);
12961
12999
  case 105:
12962
- if (this.hasFollowingLineBreak()) {
13000
+ if (this.hasFollowingLineBreak() || this.state.containsEsc || !this.hasFollowingBindingIdentifier()) {
12963
13001
  break;
12964
13002
  }
12965
- case 99:
12966
- if (this.state.containsEsc || !this.hasFollowingIdentifier(context)) {
12967
- break;
13003
+ this.expectPlugin("explicitResourceManagement");
13004
+ if (!this.scope.inModule && this.scope.inTopLevel) {
13005
+ this.raise(Errors.UnexpectedUsingDeclaration, {
13006
+ at: this.state.startLoc
13007
+ });
13008
+ } else if (!allowDeclaration) {
13009
+ this.raise(Errors.UnexpectedLexicalDeclaration, {
13010
+ at: this.state.startLoc
13011
+ });
12968
13012
  }
12969
- case 75:
12970
- case 74:
13013
+ return this.parseVarStatement(node, "using");
13014
+ case 99:
12971
13015
  {
12972
- const kind = this.state.value;
12973
- if (kind === "using") {
12974
- this.expectPlugin("explicitResourceManagement");
12975
- if (!this.scope.inModule && this.scope.inTopLevel) {
12976
- this.raise(Errors.UnexpectedUsingDeclaration, {
12977
- at: this.state.startLoc
12978
- });
13016
+ if (this.state.containsEsc) {
13017
+ break;
13018
+ }
13019
+ const next = this.nextTokenStart();
13020
+ const nextCh = this.codePointAtPos(next);
13021
+ if (nextCh !== 91) {
13022
+ if (!allowDeclaration && this.hasFollowingLineBreak()) break;
13023
+ if (!this.chStartsBindingIdentifier(nextCh, next) && nextCh !== 123) {
13024
+ break;
12979
13025
  }
12980
13026
  }
12981
- if (context && kind !== "var") {
13027
+ }
13028
+ case 75:
13029
+ {
13030
+ if (!allowDeclaration) {
12982
13031
  this.raise(Errors.UnexpectedLexicalDeclaration, {
12983
13032
  at: this.state.startLoc
12984
13033
  });
12985
13034
  }
13035
+ }
13036
+ case 74:
13037
+ {
13038
+ const kind = this.state.value;
12986
13039
  return this.parseVarStatement(node, kind);
12987
13040
  }
12988
13041
  case 92:
@@ -13028,13 +13081,13 @@ class StatementParser extends ExpressionParser {
13028
13081
  default:
13029
13082
  {
13030
13083
  if (this.isAsyncFunction()) {
13031
- if (context) {
13084
+ if (!allowDeclaration) {
13032
13085
  this.raise(Errors.AsyncFunctionInSingleStatementContext, {
13033
13086
  at: this.state.startLoc
13034
13087
  });
13035
13088
  }
13036
13089
  this.next();
13037
- return this.parseFunctionStatement(node, true, !context);
13090
+ return this.parseFunctionStatement(node, true, !allowDeclaration && allowFunctionDeclaration);
13038
13091
  }
13039
13092
  }
13040
13093
  }
@@ -13043,7 +13096,7 @@ class StatementParser extends ExpressionParser {
13043
13096
  const expr = this.parseExpression();
13044
13097
  if (tokenIsIdentifier(starttype) && expr.type === "Identifier" && this.eat(14)) {
13045
13098
  return this.parseLabeledStatement(node, maybeName,
13046
- expr, context);
13099
+ expr, flags);
13047
13100
  } else {
13048
13101
  return this.parseExpressionStatement(node, expr, decorators);
13049
13102
  }
@@ -13182,13 +13235,14 @@ class StatementParser extends ExpressionParser {
13182
13235
  this.expect(11);
13183
13236
  return val;
13184
13237
  }
13185
- parseDoStatement(node) {
13238
+
13239
+ parseDoWhileStatement(node) {
13186
13240
  this.next();
13187
13241
  this.state.labels.push(loopLabel);
13188
13242
 
13189
13243
  node.body =
13190
13244
  this.withSmartMixTopicForbiddingContext(() =>
13191
- this.parseStatement("do"));
13245
+ this.parseStatement());
13192
13246
  this.state.labels.pop();
13193
13247
  this.expect(92);
13194
13248
  node.test = this.parseHeaderExpression();
@@ -13213,7 +13267,7 @@ class StatementParser extends ExpressionParser {
13213
13267
  }
13214
13268
  const startsWithLet = this.isContextual(99);
13215
13269
  const startsWithUsing = this.isContextual(105) && !this.hasFollowingLineBreak();
13216
- const isLetOrUsing = startsWithLet && this.hasFollowingIdentifier() || startsWithUsing && this.hasFollowingIdentifier() && this.startsUsingForOf();
13270
+ const isLetOrUsing = startsWithLet && this.hasFollowingBindingAtom() || startsWithUsing && this.hasFollowingBindingIdentifier() && this.startsUsingForOf();
13217
13271
  if (this.match(74) || this.match(75) || isLetOrUsing) {
13218
13272
  const initNode = this.startNode();
13219
13273
  const kind = this.state.value;
@@ -13271,15 +13325,18 @@ class StatementParser extends ExpressionParser {
13271
13325
  }
13272
13326
  return this.parseFor(node, init);
13273
13327
  }
13274
- parseFunctionStatement(node, isAsync, declarationPosition) {
13328
+
13329
+ parseFunctionStatement(node, isAsync, isHangingDeclaration) {
13275
13330
  this.next();
13276
- return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), isAsync);
13331
+ return this.parseFunction(node, ParseFunctionFlag.Declaration | (isHangingDeclaration ? ParseFunctionFlag.HangingDeclaration : 0) | (isAsync ? ParseFunctionFlag.Async : 0));
13277
13332
  }
13333
+
13278
13334
  parseIfStatement(node) {
13279
13335
  this.next();
13280
13336
  node.test = this.parseHeaderExpression();
13281
- node.consequent = this.parseStatement("if");
13282
- node.alternate = this.eat(66) ? this.parseStatement("if") : null;
13337
+ node.consequent = this.parseStatementOrFunctionDeclaration(
13338
+ true);
13339
+ node.alternate = this.eat(66) ? this.parseStatementOrFunctionDeclaration(true) : null;
13283
13340
  return this.finishNode(node, "IfStatement");
13284
13341
  }
13285
13342
  parseReturnStatement(node) {
@@ -13298,6 +13355,7 @@ class StatementParser extends ExpressionParser {
13298
13355
  }
13299
13356
  return this.finishNode(node, "ReturnStatement");
13300
13357
  }
13358
+
13301
13359
  parseSwitchStatement(node) {
13302
13360
  this.next();
13303
13361
  node.discriminant = this.parseHeaderExpression();
@@ -13328,7 +13386,7 @@ class StatementParser extends ExpressionParser {
13328
13386
  this.expect(14);
13329
13387
  } else {
13330
13388
  if (cur) {
13331
- cur.consequent.push(this.parseStatement(null));
13389
+ cur.consequent.push(this.parseStatementListItem());
13332
13390
  } else {
13333
13391
  this.unexpected();
13334
13392
  }
@@ -13394,12 +13452,14 @@ class StatementParser extends ExpressionParser {
13394
13452
  }
13395
13453
  return this.finishNode(node, "TryStatement");
13396
13454
  }
13455
+
13397
13456
  parseVarStatement(node, kind, allowMissingInitializer = false) {
13398
13457
  this.next();
13399
13458
  this.parseVar(node, false, kind, allowMissingInitializer);
13400
13459
  this.semicolon();
13401
13460
  return this.finishNode(node, "VariableDeclaration");
13402
13461
  }
13462
+
13403
13463
  parseWhileStatement(node) {
13404
13464
  this.next();
13405
13465
  node.test = this.parseHeaderExpression();
@@ -13407,7 +13467,7 @@ class StatementParser extends ExpressionParser {
13407
13467
 
13408
13468
  node.body =
13409
13469
  this.withSmartMixTopicForbiddingContext(() =>
13410
- this.parseStatement("while"));
13470
+ this.parseStatement());
13411
13471
  this.state.labels.pop();
13412
13472
  return this.finishNode(node, "WhileStatement");
13413
13473
  }
@@ -13422,14 +13482,15 @@ class StatementParser extends ExpressionParser {
13422
13482
 
13423
13483
  node.body =
13424
13484
  this.withSmartMixTopicForbiddingContext(() =>
13425
- this.parseStatement("with"));
13485
+ this.parseStatement());
13426
13486
  return this.finishNode(node, "WithStatement");
13427
13487
  }
13428
13488
  parseEmptyStatement(node) {
13429
13489
  this.next();
13430
13490
  return this.finishNode(node, "EmptyStatement");
13431
13491
  }
13432
- parseLabeledStatement(node, maybeName, expr, context) {
13492
+
13493
+ parseLabeledStatement(node, maybeName, expr, flags) {
13433
13494
  for (const label of this.state.labels) {
13434
13495
  if (label.name === maybeName) {
13435
13496
  this.raise(Errors.LabelRedeclaration, {
@@ -13453,7 +13514,7 @@ class StatementParser extends ExpressionParser {
13453
13514
  kind: kind,
13454
13515
  statementStart: this.state.start
13455
13516
  });
13456
- node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
13517
+ node.body = flags & ParseStatementFlag.AllowLabeledFunction ? this.parseStatementOrFunctionDeclaration(false) : this.parseStatement();
13457
13518
  this.state.labels.pop();
13458
13519
  node.label = expr;
13459
13520
  return this.finishNode(node, "LabeledStatement");
@@ -13494,7 +13555,7 @@ class StatementParser extends ExpressionParser {
13494
13555
  let hasStrictModeDirective = false;
13495
13556
  let parsedNonDirective = false;
13496
13557
  while (!this.match(end)) {
13497
- const stmt = this.parseStatement(null, topLevel);
13558
+ const stmt = topLevel ? this.parseModuleItem() : this.parseStatementListItem();
13498
13559
  if (directives && !parsedNonDirective) {
13499
13560
  if (this.isValidDirective(stmt)) {
13500
13561
  const directive = this.stmtToDirective(stmt);
@@ -13529,7 +13590,7 @@ class StatementParser extends ExpressionParser {
13529
13590
 
13530
13591
  node.body =
13531
13592
  this.withSmartMixTopicForbiddingContext(() =>
13532
- this.parseStatement("for"));
13593
+ this.parseStatement());
13533
13594
  this.scope.exit();
13534
13595
  this.state.labels.pop();
13535
13596
  return this.finishNode(node, "ForStatement");
@@ -13563,7 +13624,7 @@ class StatementParser extends ExpressionParser {
13563
13624
 
13564
13625
  node.body =
13565
13626
  this.withSmartMixTopicForbiddingContext(() =>
13566
- this.parseStatement("for"));
13627
+ this.parseStatement());
13567
13628
  this.scope.exit();
13568
13629
  this.state.labels.pop();
13569
13630
  return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
@@ -13596,11 +13657,6 @@ class StatementParser extends ExpressionParser {
13596
13657
  }
13597
13658
  parseVarId(decl, kind) {
13598
13659
  const id = this.parseBindingAtom();
13599
- if (kind === "using" && id.type !== "Identifier") {
13600
- this.raise(Errors.UsingDeclarationHasBindingPattern, {
13601
- at: id
13602
- });
13603
- }
13604
13660
  this.checkLVal(id, {
13605
13661
  in: {
13606
13662
  type: "VariableDeclarator"
@@ -13610,35 +13666,43 @@ class StatementParser extends ExpressionParser {
13610
13666
  decl.id = id;
13611
13667
  }
13612
13668
 
13613
- parseFunction(node, statement = FUNC_NO_FLAGS, isAsync = false) {
13614
- const isStatement = statement & FUNC_STATEMENT;
13615
- const isHangingStatement = statement & FUNC_HANGING_STATEMENT;
13616
- const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID);
13669
+ parseAsyncFunctionExpression(node) {
13670
+ return this.parseFunction(node, ParseFunctionFlag.Async);
13671
+ }
13672
+
13673
+ parseFunction(node, flags = ParseFunctionFlag.Expression) {
13674
+ const hangingDeclaration = flags & ParseFunctionFlag.HangingDeclaration;
13675
+ const isDeclaration = !!(flags & ParseFunctionFlag.Declaration);
13676
+ const requireId = isDeclaration && !(flags & ParseFunctionFlag.NullableId);
13677
+ const isAsync = !!(flags & ParseFunctionFlag.Async);
13617
13678
  this.initFunction(node, isAsync);
13618
- if (this.match(55) && isHangingStatement) {
13619
- this.raise(Errors.GeneratorInSingleStatementContext, {
13620
- at: this.state.startLoc
13621
- });
13679
+ if (this.match(55)) {
13680
+ if (hangingDeclaration) {
13681
+ this.raise(Errors.GeneratorInSingleStatementContext, {
13682
+ at: this.state.startLoc
13683
+ });
13684
+ }
13685
+ this.next();
13686
+ node.generator = true;
13622
13687
  }
13623
- node.generator = this.eat(55);
13624
- if (isStatement) {
13688
+ if (isDeclaration) {
13625
13689
  node.id = this.parseFunctionId(requireId);
13626
13690
  }
13627
13691
  const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
13628
13692
  this.state.maybeInArrowParameters = false;
13629
13693
  this.scope.enter(SCOPE_FUNCTION);
13630
13694
  this.prodParam.enter(functionFlags(isAsync, node.generator));
13631
- if (!isStatement) {
13695
+ if (!isDeclaration) {
13632
13696
  node.id = this.parseFunctionId();
13633
13697
  }
13634
13698
  this.parseFunctionParams(node, false);
13635
13699
 
13636
13700
  this.withSmartMixTopicForbiddingContext(() => {
13637
- this.parseFunctionBodyAndFinish(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
13701
+ this.parseFunctionBodyAndFinish(node, isDeclaration ? "FunctionDeclaration" : "FunctionExpression");
13638
13702
  });
13639
13703
  this.prodParam.exit();
13640
13704
  this.scope.exit();
13641
- if (isStatement && !isHangingStatement) {
13705
+ if (isDeclaration && !hangingDeclaration) {
13642
13706
  this.registerFunctionStatementId(node);
13643
13707
  }
13644
13708
  this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
@@ -14144,13 +14208,13 @@ class StatementParser extends ExpressionParser {
14144
14208
  }
14145
14209
  parseExportDefaultExpression() {
14146
14210
  const expr = this.startNode();
14147
- const isAsync = this.isAsyncFunction();
14148
- if (this.match(68) || isAsync) {
14211
+ if (this.match(68)) {
14149
14212
  this.next();
14150
- if (isAsync) {
14151
- this.next();
14152
- }
14153
- return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
14213
+ return this.parseFunction(expr, ParseFunctionFlag.Declaration | ParseFunctionFlag.NullableId);
14214
+ } else if (this.isAsyncFunction()) {
14215
+ this.next();
14216
+ this.next();
14217
+ return this.parseFunction(expr, ParseFunctionFlag.Declaration | ParseFunctionFlag.NullableId | ParseFunctionFlag.Async);
14154
14218
  }
14155
14219
  if (this.match(80)) {
14156
14220
  return this.parseClass(expr, true, true);
@@ -14172,13 +14236,14 @@ class StatementParser extends ExpressionParser {
14172
14236
  this.semicolon();
14173
14237
  return res;
14174
14238
  }
14239
+
14175
14240
  parseExportDeclaration(
14176
14241
  node) {
14177
14242
  if (this.match(80)) {
14178
14243
  const node = this.parseClass(this.startNode(), true, false);
14179
14244
  return node;
14180
14245
  }
14181
- return this.parseStatement(null);
14246
+ return this.parseStatementListItem();
14182
14247
  }
14183
14248
  isExportDefaultSpecifier() {
14184
14249
  const {
@@ -14431,8 +14496,9 @@ class StatementParser extends ExpressionParser {
14431
14496
  let isImportReflection = false;
14432
14497
  if (this.isContextual(125)) {
14433
14498
  const lookahead = this.lookahead();
14434
- if (tokenIsIdentifier(lookahead.type)) {
14435
- if (lookahead.type !== 97) {
14499
+ const nextType = lookahead.type;
14500
+ if (tokenIsIdentifier(nextType)) {
14501
+ if (nextType !== 97) {
14436
14502
  isImportReflection = true;
14437
14503
  } else {
14438
14504
  const nextNextTokenFirstChar = this.input.charCodeAt(this.nextTokenStartSince(lookahead.end));
@@ -14440,7 +14506,7 @@ class StatementParser extends ExpressionParser {
14440
14506
  isImportReflection = true;
14441
14507
  }
14442
14508
  }
14443
- } else {
14509
+ } else if (nextType !== 12) {
14444
14510
  isImportReflection = true;
14445
14511
  }
14446
14512
  }