setupin 2.4.3 → 2.5.0-beta.1

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.
@@ -1266,6 +1266,9 @@
1266
1266
  name: createToken("name", {
1267
1267
  startsExpr
1268
1268
  }),
1269
+ placeholder: createToken("%%", {
1270
+ startsExpr: true
1271
+ }),
1269
1272
  string: createToken("string", {
1270
1273
  startsExpr
1271
1274
  }),
@@ -1292,22 +1295,19 @@
1292
1295
  jsxTagStart: createToken("jsxTagStart", {
1293
1296
  startsExpr: true
1294
1297
  }),
1295
- jsxTagEnd: createToken("jsxTagEnd"),
1296
- placeholder: createToken("%%", {
1297
- startsExpr: true
1298
- })
1298
+ jsxTagEnd: createToken("jsxTagEnd")
1299
1299
  };
1300
1300
  function tokenIsIdentifier(token) {
1301
- return token >= 93 && token <= 132;
1301
+ return token >= 93 && token <= 133;
1302
1302
  }
1303
1303
  function tokenKeywordOrIdentifierIsKeyword(token) {
1304
1304
  return token <= 92;
1305
1305
  }
1306
1306
  function tokenIsKeywordOrIdentifier(token) {
1307
- return token >= 58 && token <= 132;
1307
+ return token >= 58 && token <= 133;
1308
1308
  }
1309
1309
  function tokenIsLiteralPropertyName(token) {
1310
- return token >= 58 && token <= 136;
1310
+ return token >= 58 && token <= 137;
1311
1311
  }
1312
1312
  function tokenComesBeforeExpression(token) {
1313
1313
  return tokenBeforeExprs[token];
@@ -1371,7 +1371,7 @@
1371
1371
  context.push(types.template);
1372
1372
  }
1373
1373
  };
1374
- tokenTypes[142].updateContext = context => {
1374
+ tokenTypes[143].updateContext = context => {
1375
1375
  context.push(types.j_expr, types.j_oTag);
1376
1376
  };
1377
1377
  }
@@ -1922,7 +1922,7 @@
1922
1922
  this.commentsLen = 0;
1923
1923
  this.commentStack = [];
1924
1924
  this.pos = 0;
1925
- this.type = 139;
1925
+ this.type = 140;
1926
1926
  this.value = null;
1927
1927
  this.start = 0;
1928
1928
  this.end = 0;
@@ -2025,8 +2025,7 @@
2025
2025
  if (v) this.flags |= 4096;else this.flags &= -4097;
2026
2026
  }
2027
2027
  curPosition() {
2028
- const index = this.startIndex + this.pos;
2029
- return new Position(this.curLine, index - this.lineStart, index);
2028
+ return new Position(this.curLine, this.pos - this.lineStart, this.pos + this.startIndex);
2030
2029
  }
2031
2030
  clone() {
2032
2031
  const state = new State();
@@ -2349,10 +2348,11 @@
2349
2348
  const VALID_REGEX_FLAGS = new Set([103, 109, 115, 105, 121, 117, 100, 118]);
2350
2349
  class Token {
2351
2350
  constructor(state) {
2351
+ const startIndex = state.startIndex || 0;
2352
2352
  this.type = state.type;
2353
2353
  this.value = state.value;
2354
- this.start = state.start;
2355
- this.end = state.end;
2354
+ this.start = startIndex + state.start;
2355
+ this.end = startIndex + state.end;
2356
2356
  this.loc = new SourceLocation(state.startLoc, state.endLoc);
2357
2357
  }
2358
2358
  }
@@ -2493,7 +2493,7 @@
2493
2493
  this.state.start = this.state.pos;
2494
2494
  if (!this.isLookahead) this.state.startLoc = this.state.curPosition();
2495
2495
  if (this.state.pos >= this.length) {
2496
- this.finishToken(139);
2496
+ this.finishToken(140);
2497
2497
  return;
2498
2498
  }
2499
2499
  this.getTokenFromCode(this.codePointAtPos(this.state.pos));
@@ -2516,8 +2516,8 @@
2516
2516
  const comment = {
2517
2517
  type: "CommentBlock",
2518
2518
  value: this.input.slice(start + 2, end),
2519
- start,
2520
- end: end + commentEnd.length,
2519
+ start: this.sourceToOffsetPos(start),
2520
+ end: this.sourceToOffsetPos(end + commentEnd.length),
2521
2521
  loc: new SourceLocation(startLoc, this.state.curPosition())
2522
2522
  };
2523
2523
  if (this.options.tokens) this.pushToken(comment);
@@ -2539,8 +2539,8 @@
2539
2539
  const comment = {
2540
2540
  type: "CommentLine",
2541
2541
  value,
2542
- start,
2543
- end,
2542
+ start: this.sourceToOffsetPos(start),
2543
+ end: this.sourceToOffsetPos(end),
2544
2544
  loc: new SourceLocation(startLoc, this.state.curPosition())
2545
2545
  };
2546
2546
  if (this.options.tokens) this.pushToken(comment);
@@ -2671,10 +2671,10 @@
2671
2671
  }
2672
2672
  } else if (isIdentifierStart(next)) {
2673
2673
  ++this.state.pos;
2674
- this.finishToken(138, this.readWord1(next));
2674
+ this.finishToken(139, this.readWord1(next));
2675
2675
  } else if (next === 92) {
2676
2676
  ++this.state.pos;
2677
- this.finishToken(138, this.readWord1());
2677
+ this.finishToken(139, this.readWord1());
2678
2678
  } else {
2679
2679
  this.finishOp(27, 1);
2680
2680
  }
@@ -3086,7 +3086,7 @@
3086
3086
  mods += char;
3087
3087
  }
3088
3088
  this.state.pos = pos;
3089
- this.finishToken(137, {
3089
+ this.finishToken(138, {
3090
3090
  pattern: content,
3091
3091
  flags: mods
3092
3092
  });
@@ -3122,10 +3122,10 @@
3122
3122
  }
3123
3123
  if (isBigInt) {
3124
3124
  const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
3125
- this.finishToken(135, str);
3125
+ this.finishToken(136, str);
3126
3126
  return;
3127
3127
  }
3128
- this.finishToken(134, val);
3128
+ this.finishToken(135, val);
3129
3129
  }
3130
3130
  readNumber(startsWithDot) {
3131
3131
  const start = this.state.pos;
@@ -3188,15 +3188,15 @@
3188
3188
  }
3189
3189
  const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
3190
3190
  if (isBigInt) {
3191
- this.finishToken(135, str);
3191
+ this.finishToken(136, str);
3192
3192
  return;
3193
3193
  }
3194
3194
  if (isDecimal) {
3195
- this.finishToken(136, str);
3195
+ this.finishToken(137, str);
3196
3196
  return;
3197
3197
  }
3198
3198
  const val = isOctal ? parseInt(str, 8) : parseFloat(str);
3199
- this.finishToken(134, val);
3199
+ this.finishToken(135, val);
3200
3200
  }
3201
3201
  readCodePoint(throwOnInvalid) {
3202
3202
  const {
@@ -3216,7 +3216,7 @@
3216
3216
  this.state.pos = pos + 1;
3217
3217
  this.state.lineStart = lineStart;
3218
3218
  this.state.curLine = curLine;
3219
- this.finishToken(133, str);
3219
+ this.finishToken(134, str);
3220
3220
  }
3221
3221
  readTemplateContinuation() {
3222
3222
  if (!this.match(8)) {
@@ -3238,7 +3238,7 @@
3238
3238
  this.state.lineStart = lineStart;
3239
3239
  this.state.curLine = curLine;
3240
3240
  if (firstInvalidLoc) {
3241
- this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, firstInvalidLoc.pos);
3241
+ this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, this.sourceToOffsetPos(firstInvalidLoc.pos));
3242
3242
  }
3243
3243
  if (this.input.codePointAt(pos) === 96) {
3244
3244
  this.finishToken(24, firstInvalidLoc ? null : opening + str + "`");
@@ -3626,7 +3626,7 @@
3626
3626
  }
3627
3627
  }
3628
3628
  canInsertSemicolon() {
3629
- return this.match(139) || this.match(8) || this.hasPrecedingLineBreak();
3629
+ return this.match(140) || this.match(8) || this.hasPrecedingLineBreak();
3630
3630
  }
3631
3631
  hasPrecedingLineBreak() {
3632
3632
  return hasNewLine(this.input, this.offsetToSourcePos(this.state.lastTokEndLoc.index), this.state.start);
@@ -4031,7 +4031,7 @@
4031
4031
  return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
4032
4032
  }
4033
4033
  finishToken(type, val) {
4034
- if (type !== 133 && type !== 13 && type !== 28) {
4034
+ if (type !== 134 && type !== 13 && type !== 28) {
4035
4035
  if (this.flowPragma === undefined) {
4036
4036
  this.flowPragma = null;
4037
4037
  }
@@ -4159,7 +4159,7 @@
4159
4159
  }
4160
4160
  flowParseDeclareModule(node) {
4161
4161
  this.scope.enter(0);
4162
- if (this.match(133)) {
4162
+ if (this.match(134)) {
4163
4163
  node.id = super.parseExprAtom();
4164
4164
  } else {
4165
4165
  node.id = this.parseIdentifier();
@@ -4386,7 +4386,7 @@
4386
4386
  const node = this.startNode();
4387
4387
  node.params = [];
4388
4388
  this.state.inType = true;
4389
- if (this.match(47) || this.match(142)) {
4389
+ if (this.match(47) || this.match(143)) {
4390
4390
  this.next();
4391
4391
  } else {
4392
4392
  this.unexpected();
@@ -4460,7 +4460,7 @@
4460
4460
  return this.finishNode(node, "InterfaceTypeAnnotation");
4461
4461
  }
4462
4462
  flowParseObjectPropertyKey() {
4463
- return this.match(134) || this.match(133) ? super.parseExprAtom() : this.parseIdentifier(true);
4463
+ return this.match(135) || this.match(134) ? super.parseExprAtom() : this.parseIdentifier(true);
4464
4464
  }
4465
4465
  flowParseObjectTypeIndexer(node, isStatic, variance) {
4466
4466
  node.static = isStatic;
@@ -4904,7 +4904,7 @@
4904
4904
  node.typeParameters = null;
4905
4905
  return this.finishNode(node, "FunctionTypeAnnotation");
4906
4906
  }
4907
- case 133:
4907
+ case 134:
4908
4908
  return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
4909
4909
  case 85:
4910
4910
  case 86:
@@ -4914,19 +4914,19 @@
4914
4914
  case 53:
4915
4915
  if (this.state.value === "-") {
4916
4916
  this.next();
4917
- if (this.match(134)) {
4917
+ if (this.match(135)) {
4918
4918
  return this.parseLiteralAtNode(-this.state.value, "NumberLiteralTypeAnnotation", node);
4919
4919
  }
4920
- if (this.match(135)) {
4920
+ if (this.match(136)) {
4921
4921
  return this.parseLiteralAtNode(-this.state.value, "BigIntLiteralTypeAnnotation", node);
4922
4922
  }
4923
4923
  throw this.raise(FlowErrors.UnexpectedSubtractionOperand, this.state.startLoc);
4924
4924
  }
4925
4925
  this.unexpected();
4926
4926
  return;
4927
- case 134:
4928
- return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
4929
4927
  case 135:
4928
+ return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
4929
+ case 136:
4930
4930
  return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
4931
4931
  case 88:
4932
4932
  this.next();
@@ -5679,7 +5679,7 @@
5679
5679
  var _jsx;
5680
5680
  let state = null;
5681
5681
  let jsx;
5682
- if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
5682
+ if (this.hasPlugin("jsx") && (this.match(143) || this.match(47))) {
5683
5683
  state = this.state.clone();
5684
5684
  jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
5685
5685
  if (!jsx.error) return jsx.node;
@@ -5938,7 +5938,7 @@
5938
5938
  const startLoc = this.state.startLoc;
5939
5939
  const endOfInit = () => this.match(12) || this.match(8);
5940
5940
  switch (this.state.type) {
5941
- case 134:
5941
+ case 135:
5942
5942
  {
5943
5943
  const literal = this.parseNumericLiteral(this.state.value);
5944
5944
  if (endOfInit()) {
@@ -5953,7 +5953,7 @@
5953
5953
  loc: startLoc
5954
5954
  };
5955
5955
  }
5956
- case 133:
5956
+ case 134:
5957
5957
  {
5958
5958
  const literal = this.parseStringLiteral(this.state.value);
5959
5959
  if (endOfInit()) {
@@ -6558,14 +6558,14 @@
6558
6558
  if (this.state.pos === this.state.start) {
6559
6559
  if (ch === 60 && this.state.canStartJSXElement) {
6560
6560
  ++this.state.pos;
6561
- this.finishToken(142);
6561
+ this.finishToken(143);
6562
6562
  } else {
6563
6563
  super.getTokenFromCode(ch);
6564
6564
  }
6565
6565
  return;
6566
6566
  }
6567
6567
  out += this.input.slice(chunkStart, this.state.pos);
6568
- this.finishToken(141, out);
6568
+ this.finishToken(142, out);
6569
6569
  return;
6570
6570
  case 38:
6571
6571
  out += this.input.slice(chunkStart, this.state.pos);
@@ -6621,7 +6621,7 @@
6621
6621
  }
6622
6622
  }
6623
6623
  out += this.input.slice(chunkStart, this.state.pos++);
6624
- this.finishToken(133, out);
6624
+ this.finishToken(134, out);
6625
6625
  }
6626
6626
  jsxReadEntity() {
6627
6627
  const startPos = ++this.state.pos;
@@ -6661,11 +6661,11 @@
6661
6661
  do {
6662
6662
  ch = this.input.charCodeAt(++this.state.pos);
6663
6663
  } while (isIdentifierChar(ch) || ch === 45);
6664
- this.finishToken(140, this.input.slice(start, this.state.pos));
6664
+ this.finishToken(141, this.input.slice(start, this.state.pos));
6665
6665
  }
6666
6666
  jsxParseIdentifier() {
6667
6667
  const node = this.startNode();
6668
- if (this.match(140)) {
6668
+ if (this.match(141)) {
6669
6669
  node.name = this.state.value;
6670
6670
  } else if (tokenIsKeyword(this.state.type)) {
6671
6671
  node.name = tokenLabelName(this.state.type);
@@ -6710,8 +6710,8 @@
6710
6710
  this.raise(JsxErrors.AttributeIsEmpty, node);
6711
6711
  }
6712
6712
  return node;
6713
- case 142:
6714
- case 133:
6713
+ case 143:
6714
+ case 134:
6715
6715
  return this.parseExprAtom();
6716
6716
  default:
6717
6717
  throw this.raise(JsxErrors.UnsupportedJsxValue, this.state.startLoc);
@@ -6759,7 +6759,7 @@
6759
6759
  }
6760
6760
  jsxParseOpeningElementAt(startLoc) {
6761
6761
  const node = this.startNodeAt(startLoc);
6762
- if (this.eat(143)) {
6762
+ if (this.eat(144)) {
6763
6763
  return this.finishNode(node, "JSXOpeningFragment");
6764
6764
  }
6765
6765
  node.name = this.jsxParseElementName();
@@ -6767,21 +6767,21 @@
6767
6767
  }
6768
6768
  jsxParseOpeningElementAfterName(node) {
6769
6769
  const attributes = [];
6770
- while (!this.match(56) && !this.match(143)) {
6770
+ while (!this.match(56) && !this.match(144)) {
6771
6771
  attributes.push(this.jsxParseAttribute());
6772
6772
  }
6773
6773
  node.attributes = attributes;
6774
6774
  node.selfClosing = this.eat(56);
6775
- this.expect(143);
6775
+ this.expect(144);
6776
6776
  return this.finishNode(node, "JSXOpeningElement");
6777
6777
  }
6778
6778
  jsxParseClosingElementAt(startLoc) {
6779
6779
  const node = this.startNodeAt(startLoc);
6780
- if (this.eat(143)) {
6780
+ if (this.eat(144)) {
6781
6781
  return this.finishNode(node, "JSXClosingFragment");
6782
6782
  }
6783
6783
  node.name = this.jsxParseElementName();
6784
- this.expect(143);
6784
+ this.expect(144);
6785
6785
  return this.finishNode(node, "JSXClosingElement");
6786
6786
  }
6787
6787
  jsxParseElementAt(startLoc) {
@@ -6792,7 +6792,7 @@
6792
6792
  if (!openingElement.selfClosing) {
6793
6793
  contents: for (;;) {
6794
6794
  switch (this.state.type) {
6795
- case 142:
6795
+ case 143:
6796
6796
  startLoc = this.state.startLoc;
6797
6797
  this.next();
6798
6798
  if (this.eat(56)) {
@@ -6801,7 +6801,7 @@
6801
6801
  }
6802
6802
  children.push(this.jsxParseElementAt(startLoc));
6803
6803
  break;
6804
- case 141:
6804
+ case 142:
6805
6805
  children.push(this.parseLiteral(this.state.value, "JSXText"));
6806
6806
  break;
6807
6807
  case 5:
@@ -6859,10 +6859,10 @@
6859
6859
  context[context.length - 1] = newContext;
6860
6860
  }
6861
6861
  parseExprAtom(refExpressionErrors) {
6862
- if (this.match(142)) {
6862
+ if (this.match(143)) {
6863
6863
  return this.jsxParseElement();
6864
6864
  } else if (this.match(47) && this.input.charCodeAt(this.state.pos) !== 33) {
6865
- this.replaceToken(142);
6865
+ this.replaceToken(143);
6866
6866
  return this.jsxParseElement();
6867
6867
  } else {
6868
6868
  return super.parseExprAtom(refExpressionErrors);
@@ -6885,7 +6885,7 @@
6885
6885
  }
6886
6886
  if (code === 62) {
6887
6887
  ++this.state.pos;
6888
- this.finishToken(143);
6888
+ this.finishToken(144);
6889
6889
  return;
6890
6890
  }
6891
6891
  if ((code === 34 || code === 39) && context === types.j_oTag) {
@@ -6895,7 +6895,7 @@
6895
6895
  }
6896
6896
  if (code === 60 && this.state.canStartJSXElement && this.input.charCodeAt(this.state.pos + 1) !== 33) {
6897
6897
  ++this.state.pos;
6898
- this.finishToken(142);
6898
+ this.finishToken(143);
6899
6899
  return;
6900
6900
  }
6901
6901
  super.getTokenFromCode(code);
@@ -6905,12 +6905,12 @@
6905
6905
  context,
6906
6906
  type
6907
6907
  } = this.state;
6908
- if (type === 56 && prevType === 142) {
6908
+ if (type === 56 && prevType === 143) {
6909
6909
  context.splice(-2, 2, types.j_cTag);
6910
6910
  this.state.canStartJSXElement = false;
6911
- } else if (type === 142) {
6912
- context.push(types.j_oTag);
6913
6911
  } else if (type === 143) {
6912
+ context.push(types.j_oTag);
6913
+ } else if (type === 144) {
6914
6914
  const out = context[context.length - 1];
6915
6915
  if (out === types.j_oTag && prevType === 56 || out === types.j_cTag) {
6916
6916
  context.pop();
@@ -7267,7 +7267,7 @@
7267
7267
  return this.parseBindingRestProperty(this.startNode());
7268
7268
  }
7269
7269
  const prop = this.startNode();
7270
- if (type === 138) {
7270
+ if (type === 139) {
7271
7271
  this.expectPlugin("destructuringPrivate", startLoc);
7272
7272
  this.classScope.usePrivateName(this.state.value, startLoc);
7273
7273
  prop.key = this.parsePrivateName();
@@ -7591,7 +7591,7 @@
7591
7591
  return tokenIsIdentifier(this.state.type);
7592
7592
  }
7593
7593
  tsTokenCanFollowModifier() {
7594
- return this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(138) || this.isLiteralPropertyName();
7594
+ return this.match(0) || this.match(5) || this.match(55) || this.match(21) || this.match(139) || this.isLiteralPropertyName();
7595
7595
  }
7596
7596
  tsNextTokenOnSameLineAndCanFollowModifier() {
7597
7597
  this.next();
@@ -7762,7 +7762,7 @@
7762
7762
  const node = this.startNode();
7763
7763
  this.expect(83);
7764
7764
  this.expect(10);
7765
- if (!this.match(133)) {
7765
+ if (!this.match(134)) {
7766
7766
  this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc);
7767
7767
  }
7768
7768
  node.argument = super.parseExprAtom();
@@ -7840,7 +7840,7 @@
7840
7840
  }
7841
7841
  tsParseTypeParameters(parseModifiers) {
7842
7842
  const node = this.startNode();
7843
- if (this.match(47) || this.match(142)) {
7843
+ if (this.match(47) || this.match(143)) {
7844
7844
  this.next();
7845
7845
  } else {
7846
7846
  this.unexpected();
@@ -8164,9 +8164,9 @@
8164
8164
  tsParseLiteralTypeNode() {
8165
8165
  const node = this.startNode();
8166
8166
  switch (this.state.type) {
8167
- case 134:
8168
8167
  case 135:
8169
- case 133:
8168
+ case 136:
8169
+ case 134:
8170
8170
  case 85:
8171
8171
  case 86:
8172
8172
  node.literal = super.parseExprAtom();
@@ -8195,9 +8195,9 @@
8195
8195
  }
8196
8196
  tsParseNonArrayType() {
8197
8197
  switch (this.state.type) {
8198
- case 133:
8199
8198
  case 134:
8200
8199
  case 135:
8200
+ case 136:
8201
8201
  case 85:
8202
8202
  case 86:
8203
8203
  return this.tsParseLiteralTypeNode();
@@ -8205,7 +8205,7 @@
8205
8205
  if (this.state.value === "-") {
8206
8206
  const node = this.startNode();
8207
8207
  const nextToken = this.lookahead();
8208
- if (nextToken.type !== 134 && nextToken.type !== 135) {
8208
+ if (nextToken.type !== 135 && nextToken.type !== 136) {
8209
8209
  this.unexpected();
8210
8210
  }
8211
8211
  node.literal = this.parseMaybeUnary();
@@ -8611,7 +8611,7 @@
8611
8611
  }
8612
8612
  tsParseEnumMember() {
8613
8613
  const node = this.startNode();
8614
- node.id = this.match(133) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
8614
+ node.id = this.match(134) ? super.parseStringLiteral(this.state.value) : this.parseIdentifier(true);
8615
8615
  if (this.eat(29)) {
8616
8616
  node.initializer = super.parseMaybeAssignAllowIn();
8617
8617
  }
@@ -8659,7 +8659,7 @@
8659
8659
  node.kind = "global";
8660
8660
  node.global = true;
8661
8661
  node.id = this.parseIdentifier();
8662
- } else if (this.match(133)) {
8662
+ } else if (this.match(134)) {
8663
8663
  node.kind = "module";
8664
8664
  node.id = super.parseStringLiteral(this.state.value);
8665
8665
  } else {
@@ -8699,7 +8699,7 @@
8699
8699
  const node = this.startNode();
8700
8700
  this.expectContextual(119);
8701
8701
  this.expect(10);
8702
- if (!this.match(133)) {
8702
+ if (!this.match(134)) {
8703
8703
  this.unexpected();
8704
8704
  }
8705
8705
  node.expression = super.parseExprAtom();
@@ -8816,7 +8816,7 @@
8816
8816
  break;
8817
8817
  case "module":
8818
8818
  if (this.tsCheckLineTerminator(next)) {
8819
- if (this.match(133)) {
8819
+ if (this.match(134)) {
8820
8820
  return this.tsParseAmbientExternalModuleDeclaration(node);
8821
8821
  } else if (tokenIsIdentifier(this.state.type)) {
8822
8822
  node.kind = "module";
@@ -9110,7 +9110,7 @@
9110
9110
  }
9111
9111
  }
9112
9112
  parseImport(node) {
9113
- if (this.match(133)) {
9113
+ if (this.match(134)) {
9114
9114
  node.importKind = "value";
9115
9115
  return super.parseImport(node);
9116
9116
  }
@@ -9472,7 +9472,7 @@
9472
9472
  let state;
9473
9473
  let jsx;
9474
9474
  let typeCast;
9475
- if (this.hasPlugin("jsx") && (this.match(142) || this.match(47))) {
9475
+ if (this.hasPlugin("jsx") && (this.match(143) || this.match(47))) {
9476
9476
  state = this.state.clone();
9477
9477
  jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse), state);
9478
9478
  if (!jsx.error) return jsx.node;
@@ -9980,13 +9980,13 @@
9980
9980
  });
9981
9981
  var placeholders = superClass => class PlaceholdersParserMixin extends superClass {
9982
9982
  parsePlaceholder(expectedNode) {
9983
- if (this.match(144)) {
9983
+ if (this.match(133)) {
9984
9984
  const node = this.startNode();
9985
9985
  this.next();
9986
9986
  this.assertNoSpace();
9987
9987
  node.name = super.parseIdentifier(true);
9988
9988
  this.assertNoSpace();
9989
- this.expect(144);
9989
+ this.expect(133);
9990
9990
  return this.finishPlaceholder(node, expectedNode);
9991
9991
  }
9992
9992
  }
@@ -10000,7 +10000,7 @@
10000
10000
  }
10001
10001
  getTokenFromCode(code) {
10002
10002
  if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
10003
- this.finishOp(144, 2);
10003
+ this.finishOp(133, 2);
10004
10004
  } else {
10005
10005
  super.getTokenFromCode(code);
10006
10006
  }
@@ -10034,7 +10034,7 @@
10034
10034
  return true;
10035
10035
  }
10036
10036
  const nextToken = this.lookahead();
10037
- if (nextToken.type === 144) {
10037
+ if (nextToken.type === 133) {
10038
10038
  return true;
10039
10039
  }
10040
10040
  return false;
@@ -10072,7 +10072,7 @@
10072
10072
  const oldStrict = this.state.strict;
10073
10073
  const placeholder = this.parsePlaceholder("Identifier");
10074
10074
  if (placeholder) {
10075
- if (this.match(81) || this.match(144) || this.match(5)) {
10075
+ if (this.match(81) || this.match(133) || this.match(5)) {
10076
10076
  node.id = placeholder;
10077
10077
  } else if (optionalId || !isStatement) {
10078
10078
  node.id = null;
@@ -10108,7 +10108,7 @@
10108
10108
  if (this.match(65)) {
10109
10109
  const next = this.nextTokenStart();
10110
10110
  if (this.isUnparsedContextual(next, "from")) {
10111
- if (this.input.startsWith(tokenLabelName(144), this.nextTokenStartSince(next + 4))) {
10111
+ if (this.input.startsWith(tokenLabelName(133), this.nextTokenStartSince(next + 4))) {
10112
10112
  return true;
10113
10113
  }
10114
10114
  }
@@ -10361,7 +10361,7 @@
10361
10361
  this.enterInitialScopes();
10362
10362
  this.nextToken();
10363
10363
  const expr = this.parseExpression();
10364
- if (!this.match(139)) {
10364
+ if (!this.match(140)) {
10365
10365
  this.unexpected();
10366
10366
  }
10367
10367
  this.finalizeRemainingComments();
@@ -10481,7 +10481,7 @@
10481
10481
  return expr;
10482
10482
  }
10483
10483
  parseMaybeUnaryOrPrivate(refExpressionErrors) {
10484
- return this.match(138) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
10484
+ return this.match(139) ? this.parsePrivateName() : this.parseMaybeUnary(refExpressionErrors);
10485
10485
  }
10486
10486
  parseExprOps(refExpressionErrors) {
10487
10487
  const startLoc = this.state.startLoc;
@@ -10720,7 +10720,7 @@
10720
10720
  if (computed) {
10721
10721
  node.property = this.parseExpression();
10722
10722
  this.expect(3);
10723
- } else if (this.match(138)) {
10723
+ } else if (this.match(139)) {
10724
10724
  if (base.type === "Super") {
10725
10725
  this.raise(Errors.SuperPrivateField, startLoc);
10726
10726
  }
@@ -10895,11 +10895,11 @@
10895
10895
  this.readRegexp();
10896
10896
  return this.parseRegExpLiteral(this.state.value);
10897
10897
  }
10898
- case 134:
10899
- return this.parseNumericLiteral(this.state.value);
10900
10898
  case 135:
10899
+ return this.parseNumericLiteral(this.state.value);
10900
+ case 136:
10901
10901
  return this.parseBigIntLiteral(this.state.value);
10902
- case 133:
10902
+ case 134:
10903
10903
  return this.parseStringLiteral(this.state.value);
10904
10904
  case 84:
10905
10905
  return this.parseNullLiteral();
@@ -10953,7 +10953,7 @@
10953
10953
  throw this.raise(Errors.UnsupportedBind, callee);
10954
10954
  }
10955
10955
  }
10956
- case 138:
10956
+ case 139:
10957
10957
  {
10958
10958
  this.raise(Errors.PrivateInExpectedIn, this.state.startLoc, {
10959
10959
  identifierName: this.state.value
@@ -10995,7 +10995,7 @@
10995
10995
  break;
10996
10996
  }
10997
10997
  default:
10998
- if (type === 136) {
10998
+ if (type === 137) {
10999
10999
  return this.parseDecimalLiteral(this.state.value);
11000
11000
  }
11001
11001
  if (tokenIsIdentifier(type)) {
@@ -11578,16 +11578,16 @@
11578
11578
  key = this.parseIdentifier(true);
11579
11579
  } else {
11580
11580
  switch (type) {
11581
- case 134:
11581
+ case 135:
11582
11582
  key = this.parseNumericLiteral(value);
11583
11583
  break;
11584
- case 133:
11584
+ case 134:
11585
11585
  key = this.parseStringLiteral(value);
11586
11586
  break;
11587
- case 135:
11587
+ case 136:
11588
11588
  key = this.parseBigIntLiteral(value);
11589
11589
  break;
11590
- case 138:
11590
+ case 139:
11591
11591
  {
11592
11592
  const privateKeyLoc = this.state.startLoc;
11593
11593
  if (refExpressionErrors != null) {
@@ -11601,7 +11601,7 @@
11601
11601
  break;
11602
11602
  }
11603
11603
  default:
11604
- if (type === 136) {
11604
+ if (type === 137) {
11605
11605
  key = this.parseDecimalLiteral(value);
11606
11606
  break;
11607
11607
  }
@@ -11609,7 +11609,7 @@
11609
11609
  }
11610
11610
  }
11611
11611
  prop.key = key;
11612
- if (type !== 138) {
11612
+ if (type !== 139) {
11613
11613
  prop.computed = false;
11614
11614
  }
11615
11615
  }
@@ -11863,7 +11863,7 @@
11863
11863
  const {
11864
11864
  type
11865
11865
  } = this.state;
11866
- return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 137 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
11866
+ return type === 53 || type === 10 || type === 0 || tokenIsTemplate(type) || type === 102 && !this.state.containsEsc || type === 138 || type === 56 || this.hasPlugin("v8intrinsic") && type === 54;
11867
11867
  }
11868
11868
  parseYield() {
11869
11869
  const node = this.startNode();
@@ -11875,7 +11875,7 @@
11875
11875
  delegating = this.eat(55);
11876
11876
  switch (this.state.type) {
11877
11877
  case 13:
11878
- case 139:
11878
+ case 140:
11879
11879
  case 8:
11880
11880
  case 11:
11881
11881
  case 3:
@@ -12059,7 +12059,7 @@
12059
12059
  };
12060
12060
  const loneSurrogate = /[\uD800-\uDFFF]/u;
12061
12061
  const keywordRelationalOperator = /in(?:stanceof)?/y;
12062
- function babel7CompatTokens(tokens, input) {
12062
+ function babel7CompatTokens(tokens, input, startIndex) {
12063
12063
  for (let i = 0; i < tokens.length; i++) {
12064
12064
  const token = tokens[i];
12065
12065
  const {
@@ -12067,7 +12067,7 @@
12067
12067
  } = token;
12068
12068
  if (typeof type === "number") {
12069
12069
  {
12070
- if (type === 138) {
12070
+ if (type === 139) {
12071
12071
  const {
12072
12072
  loc,
12073
12073
  start,
@@ -12104,7 +12104,7 @@
12104
12104
  const backquoteEnd = start + 1;
12105
12105
  const backquoteEndLoc = createPositionWithColumnOffset(loc.start, 1);
12106
12106
  let startToken;
12107
- if (input.charCodeAt(start) === 96) {
12107
+ if (input.charCodeAt(start - startIndex) === 96) {
12108
12108
  startToken = new Token({
12109
12109
  type: getExportedToken(22),
12110
12110
  value: "`",
@@ -12171,11 +12171,11 @@
12171
12171
  file.program = this.parseProgram(program);
12172
12172
  file.comments = this.comments;
12173
12173
  if (this.options.tokens) {
12174
- file.tokens = babel7CompatTokens(this.tokens, this.input);
12174
+ file.tokens = babel7CompatTokens(this.tokens, this.input, this.startIndex);
12175
12175
  }
12176
12176
  return this.finishNode(file, "File");
12177
12177
  }
12178
- parseProgram(program, end = 139, sourceType = this.options.sourceType) {
12178
+ parseProgram(program, end = 140, sourceType = this.options.sourceType) {
12179
12179
  program.sourceType = sourceType;
12180
12180
  program.interpreter = this.parseInterpreterDirective();
12181
12181
  this.parseBlockBody(program, true, true, end);
@@ -12190,7 +12190,7 @@
12190
12190
  this.addExtra(program, "topLevelAwait", this.state.hasTopLevelAwait);
12191
12191
  }
12192
12192
  let finishedProgram;
12193
- if (end === 139) {
12193
+ if (end === 140) {
12194
12194
  finishedProgram = this.finishNode(program, "Program");
12195
12195
  } else {
12196
12196
  finishedProgram = this.finishNodeAt(program, "Program", createPositionWithColumnOffset(this.state.startLoc, -1));
@@ -12511,7 +12511,7 @@
12511
12511
  while (this.eat(16)) {
12512
12512
  const node = this.startNodeAt(startLoc);
12513
12513
  node.object = expr;
12514
- if (this.match(138)) {
12514
+ if (this.match(139)) {
12515
12515
  this.classScope.usePrivateName(this.state.value, this.state.startLoc);
12516
12516
  node.property = this.parsePrivateName();
12517
12517
  } else {
@@ -13114,7 +13114,7 @@
13114
13114
  this.parsePropertyNamePrefixOperator(member);
13115
13115
  if (this.eat(55)) {
13116
13116
  method.kind = "method";
13117
- const isPrivateName = this.match(138);
13117
+ const isPrivateName = this.match(139);
13118
13118
  this.parseClassElementName(method);
13119
13119
  if (isPrivateName) {
13120
13120
  this.pushClassPrivateMethod(classBody, privateMethod, true, false);
@@ -13165,7 +13165,7 @@
13165
13165
  this.unexpected(maybeQuestionTokenStartLoc);
13166
13166
  }
13167
13167
  method.kind = "method";
13168
- const isPrivate = this.match(138);
13168
+ const isPrivate = this.match(139);
13169
13169
  this.parseClassElementName(method);
13170
13170
  this.parsePostMemberNameModifiers(publicMember);
13171
13171
  if (isPrivate) {
@@ -13179,7 +13179,7 @@
13179
13179
  } else if ((maybeContextualKw === "get" || maybeContextualKw === "set") && !(this.match(55) && this.isLineTerminator())) {
13180
13180
  this.resetPreviousNodeTrailingComments(key);
13181
13181
  method.kind = maybeContextualKw;
13182
- const isPrivate = this.match(138);
13182
+ const isPrivate = this.match(139);
13183
13183
  this.parseClassElementName(publicMethod);
13184
13184
  if (isPrivate) {
13185
13185
  this.pushClassPrivateMethod(classBody, privateMethod, false, false);
@@ -13193,7 +13193,7 @@
13193
13193
  } else if (maybeContextualKw === "accessor" && !this.isLineTerminator()) {
13194
13194
  this.expectPlugin("decoratorAutoAccessors");
13195
13195
  this.resetPreviousNodeTrailingComments(key);
13196
- const isPrivate = this.match(138);
13196
+ const isPrivate = this.match(139);
13197
13197
  this.parseClassElementName(publicProp);
13198
13198
  this.pushClassAccessorProperty(classBody, accessorProp, isPrivate);
13199
13199
  } else if (this.isLineTerminator()) {
@@ -13211,10 +13211,10 @@
13211
13211
  type,
13212
13212
  value
13213
13213
  } = this.state;
13214
- if ((type === 132 || type === 133) && member.static && value === "prototype") {
13214
+ if ((type === 132 || type === 134) && member.static && value === "prototype") {
13215
13215
  this.raise(Errors.StaticPrototype, this.state.startLoc);
13216
13216
  }
13217
- if (type === 138) {
13217
+ if (type === 139) {
13218
13218
  if (value === "constructor") {
13219
13219
  this.raise(Errors.ConstructorClassPrivateField, this.state.startLoc);
13220
13220
  }
@@ -13625,7 +13625,7 @@
13625
13625
  if (this.eat(8)) break;
13626
13626
  }
13627
13627
  const isMaybeTypeOnly = this.isContextual(130);
13628
- const isString = this.match(133);
13628
+ const isString = this.match(134);
13629
13629
  const node = this.startNode();
13630
13630
  node.local = this.parseModuleExportName();
13631
13631
  nodes.push(this.parseExportSpecifier(node, isString, isInTypeExport, isMaybeTypeOnly));
@@ -13643,7 +13643,7 @@
13643
13643
  return this.finishNode(node, "ExportSpecifier");
13644
13644
  }
13645
13645
  parseModuleExportName() {
13646
- if (this.match(133)) {
13646
+ if (this.match(134)) {
13647
13647
  const result = this.parseStringLiteral(this.state.value);
13648
13648
  const surrogate = loneSurrogate.exec(result.value);
13649
13649
  if (surrogate) {
@@ -13762,7 +13762,7 @@
13762
13762
  return tokenIsIdentifier(type) ? type !== 98 || this.lookaheadCharCode() === 102 : type !== 12;
13763
13763
  }
13764
13764
  parseImport(node) {
13765
- if (this.match(133)) {
13765
+ if (this.match(134)) {
13766
13766
  return this.parseImportSourceAndAttributes(node);
13767
13767
  }
13768
13768
  return this.parseImportSpecifiersAndAfter(node, this.parseMaybeImportPhase(node, false));
@@ -13787,7 +13787,7 @@
13787
13787
  return this.finishNode(node, "ImportDeclaration");
13788
13788
  }
13789
13789
  parseImportSource() {
13790
- if (!this.match(133)) this.unexpected();
13790
+ if (!this.match(134)) this.unexpected();
13791
13791
  return this.parseExprAtom();
13792
13792
  }
13793
13793
  parseImportSpecifierLocal(node, specifier, type) {
@@ -13816,13 +13816,13 @@
13816
13816
  });
13817
13817
  }
13818
13818
  attrNames.add(keyName);
13819
- if (this.match(133)) {
13819
+ if (this.match(134)) {
13820
13820
  node.key = this.parseStringLiteral(keyName);
13821
13821
  } else {
13822
13822
  node.key = this.parseIdentifier(true);
13823
13823
  }
13824
13824
  this.expect(14);
13825
- if (!this.match(133)) {
13825
+ if (!this.match(134)) {
13826
13826
  throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
13827
13827
  }
13828
13828
  node.value = this.parseStringLiteral(this.state.value);
@@ -13847,7 +13847,7 @@
13847
13847
  }
13848
13848
  attributes.add(node.key.name);
13849
13849
  this.expect(14);
13850
- if (!this.match(133)) {
13850
+ if (!this.match(134)) {
13851
13851
  throw this.raise(Errors.ModuleAttributeInvalidValue, this.state.startLoc);
13852
13852
  }
13853
13853
  node.value = this.parseStringLiteral(this.state.value);
@@ -13927,7 +13927,7 @@
13927
13927
  if (this.eat(8)) break;
13928
13928
  }
13929
13929
  const specifier = this.startNode();
13930
- const importedIsString = this.match(133);
13930
+ const importedIsString = this.match(134);
13931
13931
  const isMaybeTypeOnly = this.isContextual(130);
13932
13932
  specifier.imported = this.parseModuleExportName();
13933
13933
  const importSpecifier = this.parseImportSpecifier(specifier, importedIsString, node.importKind === "type" || node.importKind === "typeof", isMaybeTypeOnly, undefined);
@@ -14135,11 +14135,9 @@
14135
14135
  const { extractImport, getGlobalVars, isAsyncModule } = ast(scriptContent);
14136
14136
  return {
14137
14137
  scriptEl,
14138
- context: {
14139
- retNames: getGlobalVars(),
14140
- isAsync: isAsyncModule(),
14141
- ...extractImport()
14142
- }
14138
+ retNames: getGlobalVars(),
14139
+ isAsync: isAsyncModule(),
14140
+ ...extractImport()
14143
14141
  };
14144
14142
  }
14145
14143
 
@@ -14159,8 +14157,8 @@
14159
14157
  function createBehavior(tag) {
14160
14158
  const { str, parse, logType: { lose, excess }, beNoHere } = tag;
14161
14159
  return {
14162
- lose: () => lose(`not found ${str} in top level for document`),
14163
- excess: () => excess(`only one ${str} is allowed in top level for document`),
14160
+ lose: () => false,
14161
+ excess: () => false,
14164
14162
  beNoHere: (node) => node.innerHTML = beNoHere,
14165
14163
  parse
14166
14164
  };
@@ -14404,19 +14402,18 @@
14404
14402
  function generate(templateCode, context) {
14405
14403
  document.body.innerHTML = templateCode;
14406
14404
  const demandRex = new RegExp(`\\b${Object.keys(window.Vue = Vue).join("\\b|\\b")}\\b`, "g");
14407
- const { importsCode, setupCode, retNames, isAsync } = context;
14405
+ const { scriptEl, importsCode, setupCode, retNames, isAsync } = context;
14408
14406
  const async = isAsync ? "async" : "";
14409
- const appComp = `{template:document.body.innerHTML, ${async} setup() {${setupCode}return {${retNames}}}}`;
14407
+ const appComp = `{template:document.body.innerHTML,${async} setup(){${setupCode}return{${retNames}}}}`;
14410
14408
  const suspenseComp = `{components:{c:${appComp}},template:'<Suspense><c/></Suspense>'}`;
14411
14409
  const createApp = `createApp(${isAsync ? suspenseComp : appComp}).mount(document.body);`;
14412
- const autoImport = `const { createApp,${[...new Set(setupCode.match(demandRex))]} } = Vue;`;
14413
- return importsCode + autoImport + createApp;
14410
+ const autoImport = `const {createApp,${[...new Set(setupCode.match(demandRex))]}}=Vue;`;
14411
+ scriptEl.innerHTML = importsCode + autoImport + createApp;
14414
14412
  }
14415
14413
 
14416
14414
  (async () => {
14417
14415
  const discovery = await discover(onPrior, onAfter);
14418
- const { scriptEl, context } = discovery[tagScript.str].parsed;
14419
- scriptEl.innerHTML = generate(discovery[tagTemplate.str].parsed, context);
14416
+ generate(discovery[tagTemplate.str].parsed, discovery[tagScript.str].parsed);
14420
14417
  })();
14421
14418
 
14422
14419
  })();