@codingame/monaco-vscode-configuration-editing-default-extension 1.82.6 → 1.83.0-next.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.
@@ -7,6 +7,9 @@
7
7
  "use strict";
8
8
  __webpack_require__.r(__webpack_exports__);
9
9
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10
+ /* harmony export */ "ParseErrorCode": () => (/* binding */ ParseErrorCode),
11
+ /* harmony export */ "ScanError": () => (/* binding */ ScanError),
12
+ /* harmony export */ "SyntaxKind": () => (/* binding */ SyntaxKind),
10
13
  /* harmony export */ "applyEdits": () => (/* binding */ applyEdits),
11
14
  /* harmony export */ "createScanner": () => (/* binding */ createScanner),
12
15
  /* harmony export */ "findNodeAtLocation": () => (/* binding */ findNodeAtLocation),
@@ -39,84 +42,130 @@ __webpack_require__.r(__webpack_exports__);
39
42
  * Creates a JSON scanner on the given text.
40
43
  * If ignoreTrivia is set, whitespaces or comments are ignored.
41
44
  */
42
- var createScanner = _impl_scanner__WEBPACK_IMPORTED_MODULE_2__.createScanner;
45
+ const createScanner = _impl_scanner__WEBPACK_IMPORTED_MODULE_2__.createScanner;
46
+ var ScanError;
47
+ (function (ScanError) {
48
+ ScanError[ScanError["None"] = 0] = "None";
49
+ ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
50
+ ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
51
+ ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
52
+ ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
53
+ ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
54
+ ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
55
+ })(ScanError || (ScanError = {}));
56
+ var SyntaxKind;
57
+ (function (SyntaxKind) {
58
+ SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
59
+ SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
60
+ SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
61
+ SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
62
+ SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
63
+ SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
64
+ SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
65
+ SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
66
+ SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
67
+ SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
68
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
69
+ SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
70
+ SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
71
+ SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
72
+ SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
73
+ SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
74
+ SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
75
+ })(SyntaxKind || (SyntaxKind = {}));
43
76
  /**
44
77
  * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
45
78
  */
46
- var getLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getLocation;
79
+ const getLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getLocation;
47
80
  /**
48
81
  * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
49
82
  * Therefore, always check the errors list to find out if the input was valid.
50
83
  */
51
- var parse = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parse;
84
+ const parse = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parse;
52
85
  /**
53
86
  * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
54
87
  */
55
- var parseTree = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parseTree;
88
+ const parseTree = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.parseTree;
56
89
  /**
57
90
  * Finds the node at the given path in a JSON DOM.
58
91
  */
59
- var findNodeAtLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtLocation;
92
+ const findNodeAtLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtLocation;
60
93
  /**
61
94
  * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
62
95
  */
63
- var findNodeAtOffset = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtOffset;
96
+ const findNodeAtOffset = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.findNodeAtOffset;
64
97
  /**
65
98
  * Gets the JSON path of the given JSON DOM node
66
99
  */
67
- var getNodePath = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodePath;
100
+ const getNodePath = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodePath;
68
101
  /**
69
102
  * Evaluates the JavaScript object of the given JSON DOM node
70
103
  */
71
- var getNodeValue = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodeValue;
104
+ const getNodeValue = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.getNodeValue;
72
105
  /**
73
106
  * Parses the given text and invokes the visitor functions for each object, array and literal reached.
74
107
  */
75
- var visit = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.visit;
108
+ const visit = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.visit;
76
109
  /**
77
110
  * Takes JSON with JavaScript-style comments and remove
78
111
  * them. Optionally replaces every none-newline character
79
112
  * of comments with a replaceCharacter
80
113
  */
81
- var stripComments = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.stripComments;
114
+ const stripComments = _impl_parser__WEBPACK_IMPORTED_MODULE_3__.stripComments;
115
+ var ParseErrorCode;
116
+ (function (ParseErrorCode) {
117
+ ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
118
+ ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
119
+ ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
120
+ ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
121
+ ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
122
+ ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
123
+ ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
124
+ ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
125
+ ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
126
+ ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
127
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
128
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
129
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
130
+ ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
131
+ ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
132
+ ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
133
+ })(ParseErrorCode || (ParseErrorCode = {}));
82
134
  function printParseErrorCode(code) {
83
135
  switch (code) {
84
- case 1 /* InvalidSymbol */: return 'InvalidSymbol';
85
- case 2 /* InvalidNumberFormat */: return 'InvalidNumberFormat';
86
- case 3 /* PropertyNameExpected */: return 'PropertyNameExpected';
87
- case 4 /* ValueExpected */: return 'ValueExpected';
88
- case 5 /* ColonExpected */: return 'ColonExpected';
89
- case 6 /* CommaExpected */: return 'CommaExpected';
90
- case 7 /* CloseBraceExpected */: return 'CloseBraceExpected';
91
- case 8 /* CloseBracketExpected */: return 'CloseBracketExpected';
92
- case 9 /* EndOfFileExpected */: return 'EndOfFileExpected';
93
- case 10 /* InvalidCommentToken */: return 'InvalidCommentToken';
94
- case 11 /* UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
95
- case 12 /* UnexpectedEndOfString */: return 'UnexpectedEndOfString';
96
- case 13 /* UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
97
- case 14 /* InvalidUnicode */: return 'InvalidUnicode';
98
- case 15 /* InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
99
- case 16 /* InvalidCharacter */: return 'InvalidCharacter';
136
+ case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';
137
+ case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';
138
+ case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';
139
+ case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';
140
+ case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';
141
+ case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';
142
+ case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';
143
+ case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';
144
+ case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';
145
+ case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';
146
+ case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
147
+ case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';
148
+ case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
149
+ case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';
150
+ case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
151
+ case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';
100
152
  }
101
153
  return '<unknown ParseErrorCode>';
102
154
  }
103
155
  /**
104
- * Computes the edits needed to format a JSON document.
156
+ * Computes the edit operations needed to format a JSON document.
105
157
  *
106
158
  * @param documentText The input text
107
159
  * @param range The range to format or `undefined` to format the full content
108
160
  * @param options The formatting options
109
- * @returns A list of edit operations describing the formatting changes to the original document. Edits can be either inserts, replacements or
110
- * removals of text segments. All offsets refer to the original state of the document. No two edits must change or remove the same range of
111
- * text in the original document. However, multiple edits can have
112
- * the same offset, for example multiple inserts, or an insert followed by a remove or replace. The order in the array defines which edit is applied first.
113
- * To apply edits to an input, you can use `applyEdits`.
161
+ * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
162
+ * To apply the edit operations to the input, use {@linkcode applyEdits}.
114
163
  */
115
164
  function format(documentText, range, options) {
116
165
  return _impl_format__WEBPACK_IMPORTED_MODULE_0__.format(documentText, range, options);
117
166
  }
118
167
  /**
119
- * Computes the edits needed to modify a value in the JSON document.
168
+ * Computes the edit operations needed to modify a value in the JSON document.
120
169
  *
121
170
  * @param documentText The input text
122
171
  * @param path The path of the value to change. The path represents either to the document root, a property or an array item.
@@ -124,21 +173,37 @@ function format(documentText, range, options) {
124
173
  * @param value The new value for the specified property or item. If the value is undefined,
125
174
  * the property or item will be removed.
126
175
  * @param options Options
127
- * @returns A list of edit operations describing the formatting changes to the original document. Edits can be either inserts, replacements or
128
- * removals of text segments. All offsets refer to the original state of the document. No two edits must change or remove the same range of
129
- * text in the original document. However, multiple edits can have
130
- * the same offset, for example multiple inserts, or an insert followed by a remove or replace. The order in the array defines which edit is applied first.
131
- * To apply edits to an input, you can use `applyEdits`.
176
+ * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
177
+ * To apply the edit operations to the input, use {@linkcode applyEdits}.
132
178
  */
133
179
  function modify(text, path, value, options) {
134
- return _impl_edit__WEBPACK_IMPORTED_MODULE_1__.setProperty(text, path, value, options.formattingOptions, options.getInsertionIndex);
180
+ return _impl_edit__WEBPACK_IMPORTED_MODULE_1__.setProperty(text, path, value, options);
135
181
  }
136
182
  /**
137
- * Applies edits to a input string.
183
+ * Applies edits to an input string.
184
+ * @param text The input text
185
+ * @param edits Edit operations following the format described in {@linkcode EditResult}.
186
+ * @returns The text with the applied edits.
187
+ * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
138
188
  */
139
189
  function applyEdits(text, edits) {
140
- for (var i = edits.length - 1; i >= 0; i--) {
141
- text = _impl_edit__WEBPACK_IMPORTED_MODULE_1__.applyEdit(text, edits[i]);
190
+ let sortedEdits = edits.slice(0).sort((a, b) => {
191
+ const diff = a.offset - b.offset;
192
+ if (diff === 0) {
193
+ return a.length - b.length;
194
+ }
195
+ return diff;
196
+ });
197
+ let lastModifiedOffset = text.length;
198
+ for (let i = sortedEdits.length - 1; i >= 0; i--) {
199
+ let e = sortedEdits[i];
200
+ if (e.offset + e.length <= lastModifiedOffset) {
201
+ text = _impl_edit__WEBPACK_IMPORTED_MODULE_1__.applyEdit(text, e);
202
+ }
203
+ else {
204
+ throw new Error('Overlapping edit');
205
+ }
206
+ lastModifiedOffset = e.offset;
142
207
  }
143
208
  return text;
144
209
  }
@@ -162,11 +227,11 @@ __webpack_require__.r(__webpack_exports__);
162
227
 
163
228
 
164
229
  function format(documentText, range, options) {
165
- var initialIndentLevel;
166
- var formatText;
167
- var formatTextStart;
168
- var rangeStart;
169
- var rangeEnd;
230
+ let initialIndentLevel;
231
+ let formatText;
232
+ let formatTextStart;
233
+ let rangeStart;
234
+ let rangeEnd;
170
235
  if (range) {
171
236
  rangeStart = range.offset;
172
237
  rangeEnd = rangeStart + range.length;
@@ -174,7 +239,7 @@ function format(documentText, range, options) {
174
239
  while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
175
240
  formatTextStart--;
176
241
  }
177
- var endOffset = rangeEnd;
242
+ let endOffset = rangeEnd;
178
243
  while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
179
244
  endOffset++;
180
245
  }
@@ -188,136 +253,193 @@ function format(documentText, range, options) {
188
253
  rangeStart = 0;
189
254
  rangeEnd = documentText.length;
190
255
  }
191
- var eol = getEOL(options, documentText);
192
- var lineBreak = false;
193
- var indentLevel = 0;
194
- var indentValue;
256
+ const eol = getEOL(options, documentText);
257
+ let numberLineBreaks = 0;
258
+ let indentLevel = 0;
259
+ let indentValue;
195
260
  if (options.insertSpaces) {
196
261
  indentValue = repeat(' ', options.tabSize || 4);
197
262
  }
198
263
  else {
199
264
  indentValue = '\t';
200
265
  }
201
- var scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(formatText, false);
202
- var hasError = false;
203
- function newLineAndIndent() {
204
- return eol + repeat(indentValue, initialIndentLevel + indentLevel);
266
+ let scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(formatText, false);
267
+ let hasError = false;
268
+ function newLinesAndIndent() {
269
+ if (numberLineBreaks > 1) {
270
+ return repeat(eol, numberLineBreaks) + repeat(indentValue, initialIndentLevel + indentLevel);
271
+ }
272
+ else {
273
+ return eol + repeat(indentValue, initialIndentLevel + indentLevel);
274
+ }
205
275
  }
206
276
  function scanNext() {
207
- var token = scanner.scan();
208
- lineBreak = false;
209
- while (token === 15 /* Trivia */ || token === 14 /* LineBreakTrivia */) {
210
- lineBreak = lineBreak || (token === 14 /* LineBreakTrivia */);
277
+ let token = scanner.scan();
278
+ numberLineBreaks = 0;
279
+ while (token === 15 /* SyntaxKind.Trivia */ || token === 14 /* SyntaxKind.LineBreakTrivia */) {
280
+ if (token === 14 /* SyntaxKind.LineBreakTrivia */ && options.keepLines) {
281
+ numberLineBreaks += 1;
282
+ }
283
+ else if (token === 14 /* SyntaxKind.LineBreakTrivia */) {
284
+ numberLineBreaks = 1;
285
+ }
211
286
  token = scanner.scan();
212
287
  }
213
- hasError = token === 16 /* Unknown */ || scanner.getTokenError() !== 0 /* None */;
288
+ hasError = token === 16 /* SyntaxKind.Unknown */ || scanner.getTokenError() !== 0 /* ScanError.None */;
214
289
  return token;
215
290
  }
216
- var editOperations = [];
291
+ const editOperations = [];
217
292
  function addEdit(text, startOffset, endOffset) {
218
- if (!hasError && startOffset < rangeEnd && endOffset > rangeStart && documentText.substring(startOffset, endOffset) !== text) {
293
+ if (!hasError && (!range || (startOffset < rangeEnd && endOffset > rangeStart)) && documentText.substring(startOffset, endOffset) !== text) {
219
294
  editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
220
295
  }
221
296
  }
222
- var firstToken = scanNext();
223
- if (firstToken !== 17 /* EOF */) {
224
- var firstTokenStart = scanner.getTokenOffset() + formatTextStart;
225
- var initialIndent = repeat(indentValue, initialIndentLevel);
297
+ let firstToken = scanNext();
298
+ if (options.keepLines && numberLineBreaks > 0) {
299
+ addEdit(repeat(eol, numberLineBreaks), 0, 0);
300
+ }
301
+ if (firstToken !== 17 /* SyntaxKind.EOF */) {
302
+ let firstTokenStart = scanner.getTokenOffset() + formatTextStart;
303
+ let initialIndent = repeat(indentValue, initialIndentLevel);
226
304
  addEdit(initialIndent, formatTextStart, firstTokenStart);
227
305
  }
228
- while (firstToken !== 17 /* EOF */) {
229
- var firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
230
- var secondToken = scanNext();
231
- var replaceContent = '';
232
- while (!lineBreak && (secondToken === 12 /* LineCommentTrivia */ || secondToken === 13 /* BlockCommentTrivia */)) {
233
- // comments on the same line: keep them on the same line, but ignore them otherwise
234
- var commentTokenStart = scanner.getTokenOffset() + formatTextStart;
306
+ while (firstToken !== 17 /* SyntaxKind.EOF */) {
307
+ let firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
308
+ let secondToken = scanNext();
309
+ let replaceContent = '';
310
+ let needsLineBreak = false;
311
+ while (numberLineBreaks === 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
312
+ let commentTokenStart = scanner.getTokenOffset() + formatTextStart;
235
313
  addEdit(' ', firstTokenEnd, commentTokenStart);
236
314
  firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
237
- replaceContent = secondToken === 12 /* LineCommentTrivia */ ? newLineAndIndent() : '';
315
+ needsLineBreak = secondToken === 12 /* SyntaxKind.LineCommentTrivia */;
316
+ replaceContent = needsLineBreak ? newLinesAndIndent() : '';
238
317
  secondToken = scanNext();
239
318
  }
240
- if (secondToken === 2 /* CloseBraceToken */) {
241
- if (firstToken !== 1 /* OpenBraceToken */) {
319
+ if (secondToken === 2 /* SyntaxKind.CloseBraceToken */) {
320
+ if (firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
242
321
  indentLevel--;
243
- replaceContent = newLineAndIndent();
322
+ }
323
+ ;
324
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 1 /* SyntaxKind.OpenBraceToken */) {
325
+ replaceContent = newLinesAndIndent();
326
+ }
327
+ else if (options.keepLines) {
328
+ replaceContent = ' ';
244
329
  }
245
330
  }
246
- else if (secondToken === 4 /* CloseBracketToken */) {
247
- if (firstToken !== 3 /* OpenBracketToken */) {
331
+ else if (secondToken === 4 /* SyntaxKind.CloseBracketToken */) {
332
+ if (firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
248
333
  indentLevel--;
249
- replaceContent = newLineAndIndent();
334
+ }
335
+ ;
336
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines && firstToken !== 3 /* SyntaxKind.OpenBracketToken */) {
337
+ replaceContent = newLinesAndIndent();
338
+ }
339
+ else if (options.keepLines) {
340
+ replaceContent = ' ';
250
341
  }
251
342
  }
252
343
  else {
253
344
  switch (firstToken) {
254
- case 3 /* OpenBracketToken */:
255
- case 1 /* OpenBraceToken */:
345
+ case 3 /* SyntaxKind.OpenBracketToken */:
346
+ case 1 /* SyntaxKind.OpenBraceToken */:
256
347
  indentLevel++;
257
- replaceContent = newLineAndIndent();
258
- break;
259
- case 5 /* CommaToken */:
260
- case 12 /* LineCommentTrivia */:
261
- replaceContent = newLineAndIndent();
348
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
349
+ replaceContent = newLinesAndIndent();
350
+ }
351
+ else {
352
+ replaceContent = ' ';
353
+ }
262
354
  break;
263
- case 13 /* BlockCommentTrivia */:
264
- if (lineBreak) {
265
- replaceContent = newLineAndIndent();
355
+ case 5 /* SyntaxKind.CommaToken */:
356
+ if (options.keepLines && numberLineBreaks > 0 || !options.keepLines) {
357
+ replaceContent = newLinesAndIndent();
266
358
  }
267
359
  else {
268
- // symbol following comment on the same line: keep on same line, separate with ' '
269
360
  replaceContent = ' ';
270
361
  }
271
362
  break;
272
- case 6 /* ColonToken */:
273
- replaceContent = ' ';
363
+ case 12 /* SyntaxKind.LineCommentTrivia */:
364
+ replaceContent = newLinesAndIndent();
274
365
  break;
275
- case 10 /* StringLiteral */:
276
- if (secondToken === 6 /* ColonToken */) {
277
- replaceContent = '';
278
- break;
366
+ case 13 /* SyntaxKind.BlockCommentTrivia */:
367
+ if (numberLineBreaks > 0) {
368
+ replaceContent = newLinesAndIndent();
279
369
  }
280
- // fall through
281
- case 7 /* NullKeyword */:
282
- case 8 /* TrueKeyword */:
283
- case 9 /* FalseKeyword */:
284
- case 11 /* NumericLiteral */:
285
- case 2 /* CloseBraceToken */:
286
- case 4 /* CloseBracketToken */:
287
- if (secondToken === 12 /* LineCommentTrivia */ || secondToken === 13 /* BlockCommentTrivia */) {
370
+ else if (!needsLineBreak) {
288
371
  replaceContent = ' ';
289
372
  }
290
- else if (secondToken !== 5 /* CommaToken */ && secondToken !== 17 /* EOF */) {
291
- hasError = true;
373
+ break;
374
+ case 6 /* SyntaxKind.ColonToken */:
375
+ if (options.keepLines && numberLineBreaks > 0) {
376
+ replaceContent = newLinesAndIndent();
377
+ }
378
+ else if (!needsLineBreak) {
379
+ replaceContent = ' ';
292
380
  }
293
381
  break;
294
- case 16 /* Unknown */:
382
+ case 10 /* SyntaxKind.StringLiteral */:
383
+ if (options.keepLines && numberLineBreaks > 0) {
384
+ replaceContent = newLinesAndIndent();
385
+ }
386
+ else if (secondToken === 6 /* SyntaxKind.ColonToken */ && !needsLineBreak) {
387
+ replaceContent = '';
388
+ }
389
+ break;
390
+ case 7 /* SyntaxKind.NullKeyword */:
391
+ case 8 /* SyntaxKind.TrueKeyword */:
392
+ case 9 /* SyntaxKind.FalseKeyword */:
393
+ case 11 /* SyntaxKind.NumericLiteral */:
394
+ case 2 /* SyntaxKind.CloseBraceToken */:
395
+ case 4 /* SyntaxKind.CloseBracketToken */:
396
+ if (options.keepLines && numberLineBreaks > 0) {
397
+ replaceContent = newLinesAndIndent();
398
+ }
399
+ else {
400
+ if ((secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */) && !needsLineBreak) {
401
+ replaceContent = ' ';
402
+ }
403
+ else if (secondToken !== 5 /* SyntaxKind.CommaToken */ && secondToken !== 17 /* SyntaxKind.EOF */) {
404
+ hasError = true;
405
+ }
406
+ }
407
+ break;
408
+ case 16 /* SyntaxKind.Unknown */:
295
409
  hasError = true;
296
410
  break;
297
411
  }
298
- if (lineBreak && (secondToken === 12 /* LineCommentTrivia */ || secondToken === 13 /* BlockCommentTrivia */)) {
299
- replaceContent = newLineAndIndent();
412
+ if (numberLineBreaks > 0 && (secondToken === 12 /* SyntaxKind.LineCommentTrivia */ || secondToken === 13 /* SyntaxKind.BlockCommentTrivia */)) {
413
+ replaceContent = newLinesAndIndent();
414
+ }
415
+ }
416
+ if (secondToken === 17 /* SyntaxKind.EOF */) {
417
+ if (options.keepLines && numberLineBreaks > 0) {
418
+ replaceContent = newLinesAndIndent();
419
+ }
420
+ else {
421
+ replaceContent = options.insertFinalNewline ? eol : '';
300
422
  }
301
423
  }
302
- var secondTokenStart = scanner.getTokenOffset() + formatTextStart;
424
+ const secondTokenStart = scanner.getTokenOffset() + formatTextStart;
303
425
  addEdit(replaceContent, firstTokenEnd, secondTokenStart);
304
426
  firstToken = secondToken;
305
427
  }
306
428
  return editOperations;
307
429
  }
308
430
  function repeat(s, count) {
309
- var result = '';
310
- for (var i = 0; i < count; i++) {
431
+ let result = '';
432
+ for (let i = 0; i < count; i++) {
311
433
  result += s;
312
434
  }
313
435
  return result;
314
436
  }
315
437
  function computeIndentLevel(content, options) {
316
- var i = 0;
317
- var nChars = 0;
318
- var tabSize = options.tabSize || 4;
438
+ let i = 0;
439
+ let nChars = 0;
440
+ const tabSize = options.tabSize || 4;
319
441
  while (i < content.length) {
320
- var ch = content.charAt(i);
442
+ let ch = content.charAt(i);
321
443
  if (ch === ' ') {
322
444
  nChars++;
323
445
  }
@@ -332,8 +454,8 @@ function computeIndentLevel(content, options) {
332
454
  return Math.floor(nChars / tabSize);
333
455
  }
334
456
  function getEOL(options, text) {
335
- for (var i = 0; i < text.length; i++) {
336
- var ch = text.charAt(i);
457
+ for (let i = 0; i < text.length; i++) {
458
+ const ch = text.charAt(i);
337
459
  if (ch === '\r') {
338
460
  if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
339
461
  return '\r\n';
@@ -369,23 +491,22 @@ __webpack_require__.r(__webpack_exports__);
369
491
  * Creates a JSON scanner on the given text.
370
492
  * If ignoreTrivia is set, whitespaces or comments are ignored.
371
493
  */
372
- function createScanner(text, ignoreTrivia) {
373
- if (ignoreTrivia === void 0) { ignoreTrivia = false; }
374
- var len = text.length;
375
- var pos = 0, value = '', tokenOffset = 0, token = 16 /* Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* None */;
494
+ function createScanner(text, ignoreTrivia = false) {
495
+ const len = text.length;
496
+ let pos = 0, value = '', tokenOffset = 0, token = 16 /* SyntaxKind.Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* ScanError.None */;
376
497
  function scanHexDigits(count, exact) {
377
- var digits = 0;
378
- var value = 0;
498
+ let digits = 0;
499
+ let value = 0;
379
500
  while (digits < count || !exact) {
380
- var ch = text.charCodeAt(pos);
381
- if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) {
382
- value = value * 16 + ch - 48 /* _0 */;
501
+ let ch = text.charCodeAt(pos);
502
+ if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) {
503
+ value = value * 16 + ch - 48 /* CharacterCodes._0 */;
383
504
  }
384
- else if (ch >= 65 /* A */ && ch <= 70 /* F */) {
385
- value = value * 16 + ch - 65 /* A */ + 10;
505
+ else if (ch >= 65 /* CharacterCodes.A */ && ch <= 70 /* CharacterCodes.F */) {
506
+ value = value * 16 + ch - 65 /* CharacterCodes.A */ + 10;
386
507
  }
387
- else if (ch >= 97 /* a */ && ch <= 102 /* f */) {
388
- value = value * 16 + ch - 97 /* a */ + 10;
508
+ else if (ch >= 97 /* CharacterCodes.a */ && ch <= 102 /* CharacterCodes.f */) {
509
+ value = value * 16 + ch - 97 /* CharacterCodes.a */ + 10;
389
510
  }
390
511
  else {
391
512
  break;
@@ -402,12 +523,12 @@ function createScanner(text, ignoreTrivia) {
402
523
  pos = newPosition;
403
524
  value = '';
404
525
  tokenOffset = 0;
405
- token = 16 /* Unknown */;
406
- scanError = 0 /* None */;
526
+ token = 16 /* SyntaxKind.Unknown */;
527
+ scanError = 0 /* ScanError.None */;
407
528
  }
408
529
  function scanNumber() {
409
- var start = pos;
410
- if (text.charCodeAt(pos) === 48 /* _0 */) {
530
+ let start = pos;
531
+ if (text.charCodeAt(pos) === 48 /* CharacterCodes._0 */) {
411
532
  pos++;
412
533
  }
413
534
  else {
@@ -416,7 +537,7 @@ function createScanner(text, ignoreTrivia) {
416
537
  pos++;
417
538
  }
418
539
  }
419
- if (pos < text.length && text.charCodeAt(pos) === 46 /* dot */) {
540
+ if (pos < text.length && text.charCodeAt(pos) === 46 /* CharacterCodes.dot */) {
420
541
  pos++;
421
542
  if (pos < text.length && isDigit(text.charCodeAt(pos))) {
422
543
  pos++;
@@ -425,14 +546,14 @@ function createScanner(text, ignoreTrivia) {
425
546
  }
426
547
  }
427
548
  else {
428
- scanError = 3 /* UnexpectedEndOfNumber */;
549
+ scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
429
550
  return text.substring(start, pos);
430
551
  }
431
552
  }
432
- var end = pos;
433
- if (pos < text.length && (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */)) {
553
+ let end = pos;
554
+ if (pos < text.length && (text.charCodeAt(pos) === 69 /* CharacterCodes.E */ || text.charCodeAt(pos) === 101 /* CharacterCodes.e */)) {
434
555
  pos++;
435
- if (pos < text.length && text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) {
556
+ if (pos < text.length && text.charCodeAt(pos) === 43 /* CharacterCodes.plus */ || text.charCodeAt(pos) === 45 /* CharacterCodes.minus */) {
436
557
  pos++;
437
558
  }
438
559
  if (pos < text.length && isDigit(text.charCodeAt(pos))) {
@@ -443,69 +564,69 @@ function createScanner(text, ignoreTrivia) {
443
564
  end = pos;
444
565
  }
445
566
  else {
446
- scanError = 3 /* UnexpectedEndOfNumber */;
567
+ scanError = 3 /* ScanError.UnexpectedEndOfNumber */;
447
568
  }
448
569
  }
449
570
  return text.substring(start, end);
450
571
  }
451
572
  function scanString() {
452
- var result = '', start = pos;
573
+ let result = '', start = pos;
453
574
  while (true) {
454
575
  if (pos >= len) {
455
576
  result += text.substring(start, pos);
456
- scanError = 2 /* UnexpectedEndOfString */;
577
+ scanError = 2 /* ScanError.UnexpectedEndOfString */;
457
578
  break;
458
579
  }
459
- var ch = text.charCodeAt(pos);
460
- if (ch === 34 /* doubleQuote */) {
580
+ const ch = text.charCodeAt(pos);
581
+ if (ch === 34 /* CharacterCodes.doubleQuote */) {
461
582
  result += text.substring(start, pos);
462
583
  pos++;
463
584
  break;
464
585
  }
465
- if (ch === 92 /* backslash */) {
586
+ if (ch === 92 /* CharacterCodes.backslash */) {
466
587
  result += text.substring(start, pos);
467
588
  pos++;
468
589
  if (pos >= len) {
469
- scanError = 2 /* UnexpectedEndOfString */;
590
+ scanError = 2 /* ScanError.UnexpectedEndOfString */;
470
591
  break;
471
592
  }
472
- var ch2 = text.charCodeAt(pos++);
593
+ const ch2 = text.charCodeAt(pos++);
473
594
  switch (ch2) {
474
- case 34 /* doubleQuote */:
595
+ case 34 /* CharacterCodes.doubleQuote */:
475
596
  result += '\"';
476
597
  break;
477
- case 92 /* backslash */:
598
+ case 92 /* CharacterCodes.backslash */:
478
599
  result += '\\';
479
600
  break;
480
- case 47 /* slash */:
601
+ case 47 /* CharacterCodes.slash */:
481
602
  result += '/';
482
603
  break;
483
- case 98 /* b */:
604
+ case 98 /* CharacterCodes.b */:
484
605
  result += '\b';
485
606
  break;
486
- case 102 /* f */:
607
+ case 102 /* CharacterCodes.f */:
487
608
  result += '\f';
488
609
  break;
489
- case 110 /* n */:
610
+ case 110 /* CharacterCodes.n */:
490
611
  result += '\n';
491
612
  break;
492
- case 114 /* r */:
613
+ case 114 /* CharacterCodes.r */:
493
614
  result += '\r';
494
615
  break;
495
- case 116 /* t */:
616
+ case 116 /* CharacterCodes.t */:
496
617
  result += '\t';
497
618
  break;
498
- case 117 /* u */:
499
- var ch3 = scanHexDigits(4, true);
619
+ case 117 /* CharacterCodes.u */:
620
+ const ch3 = scanHexDigits(4, true);
500
621
  if (ch3 >= 0) {
501
622
  result += String.fromCharCode(ch3);
502
623
  }
503
624
  else {
504
- scanError = 4 /* InvalidUnicode */;
625
+ scanError = 4 /* ScanError.InvalidUnicode */;
505
626
  }
506
627
  break;
507
628
  default:
508
- scanError = 5 /* InvalidEscapeCharacter */;
629
+ scanError = 5 /* ScanError.InvalidEscapeCharacter */;
509
630
  }
510
631
  start = pos;
511
632
  continue;
@@ -513,11 +634,11 @@ function createScanner(text, ignoreTrivia) {
513
634
  if (ch >= 0 && ch <= 0x1f) {
514
635
  if (isLineBreak(ch)) {
515
636
  result += text.substring(start, pos);
516
- scanError = 2 /* UnexpectedEndOfString */;
637
+ scanError = 2 /* ScanError.UnexpectedEndOfString */;
517
638
  break;
518
639
  }
519
640
  else {
520
- scanError = 6 /* InvalidCharacter */;
641
+ scanError = 6 /* ScanError.InvalidCharacter */;
521
642
  // mark as error but continue with string
522
643
  }
523
644
  }
@@ -527,16 +648,16 @@ function createScanner(text, ignoreTrivia) {
527
648
  }
528
649
  function scanNext() {
529
650
  value = '';
530
- scanError = 0 /* None */;
651
+ scanError = 0 /* ScanError.None */;
531
652
  tokenOffset = pos;
532
653
  lineStartOffset = lineNumber;
533
654
  prevTokenLineStartOffset = tokenLineStartOffset;
534
655
  if (pos >= len) {
535
656
  // at the end
536
657
  tokenOffset = len;
537
- return token = 17 /* EOF */;
658
+ return token = 17 /* SyntaxKind.EOF */;
538
659
  }
539
- var code = text.charCodeAt(pos);
660
+ let code = text.charCodeAt(pos);
540
661
  // trivia: whitespace
541
662
  if (isWhiteSpace(code)) {
542
663
  do {
@@ -544,50 +665,50 @@ function createScanner(text, ignoreTrivia) {
544
665
  value += String.fromCharCode(code);
545
666
  code = text.charCodeAt(pos);
546
667
  } while (isWhiteSpace(code));
547
- return token = 15 /* Trivia */;
668
+ return token = 15 /* SyntaxKind.Trivia */;
548
669
  }
549
670
  // trivia: newlines
550
671
  if (isLineBreak(code)) {
551
672
  pos++;
552
673
  value += String.fromCharCode(code);
553
- if (code === 13 /* carriageReturn */ && text.charCodeAt(pos) === 10 /* lineFeed */) {
674
+ if (code === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
554
675
  pos++;
555
676
  value += '\n';
556
677
  }
557
678
  lineNumber++;
558
679
  tokenLineStartOffset = pos;
559
- return token = 14 /* LineBreakTrivia */;
680
+ return token = 14 /* SyntaxKind.LineBreakTrivia */;
560
681
  }
561
682
  switch (code) {
562
683
  // tokens: []{}:,
563
- case 123 /* openBrace */:
684
+ case 123 /* CharacterCodes.openBrace */:
564
685
  pos++;
565
- return token = 1 /* OpenBraceToken */;
566
- case 125 /* closeBrace */:
686
+ return token = 1 /* SyntaxKind.OpenBraceToken */;
687
+ case 125 /* CharacterCodes.closeBrace */:
567
688
  pos++;
568
- return token = 2 /* CloseBraceToken */;
569
- case 91 /* openBracket */:
689
+ return token = 2 /* SyntaxKind.CloseBraceToken */;
690
+ case 91 /* CharacterCodes.openBracket */:
570
691
  pos++;
571
- return token = 3 /* OpenBracketToken */;
572
- case 93 /* closeBracket */:
692
+ return token = 3 /* SyntaxKind.OpenBracketToken */;
693
+ case 93 /* CharacterCodes.closeBracket */:
573
694
  pos++;
574
- return token = 4 /* CloseBracketToken */;
575
- case 58 /* colon */:
695
+ return token = 4 /* SyntaxKind.CloseBracketToken */;
696
+ case 58 /* CharacterCodes.colon */:
576
697
  pos++;
577
- return token = 6 /* ColonToken */;
578
- case 44 /* comma */:
698
+ return token = 6 /* SyntaxKind.ColonToken */;
699
+ case 44 /* CharacterCodes.comma */:
579
700
  pos++;
580
- return token = 5 /* CommaToken */;
701
+ return token = 5 /* SyntaxKind.CommaToken */;
581
702
  // strings
582
- case 34 /* doubleQuote */:
703
+ case 34 /* CharacterCodes.doubleQuote */:
583
704
  pos++;
584
705
  value = scanString();
585
- return token = 10 /* StringLiteral */;
706
+ return token = 10 /* SyntaxKind.StringLiteral */;
586
707
  // comments
587
- case 47 /* slash */:
588
- var start = pos - 1;
708
+ case 47 /* CharacterCodes.slash */:
709
+ const start = pos - 1;
589
710
  // Single-line comment
590
- if (text.charCodeAt(pos + 1) === 47 /* slash */) {
711
+ if (text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
591
712
  pos += 2;
592
713
  while (pos < len) {
593
714
  if (isLineBreak(text.charCodeAt(pos))) {
@@ -596,23 +717,23 @@ function createScanner(text, ignoreTrivia) {
596
717
  pos++;
597
718
  }
598
719
  value = text.substring(start, pos);
599
- return token = 12 /* LineCommentTrivia */;
720
+ return token = 12 /* SyntaxKind.LineCommentTrivia */;
600
721
  }
601
722
  // Multi-line comment
602
- if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
723
+ if (text.charCodeAt(pos + 1) === 42 /* CharacterCodes.asterisk */) {
603
724
  pos += 2;
604
- var safeLength = len - 1; // For lookahead.
605
- var commentClosed = false;
725
+ const safeLength = len - 1; // For lookahead.
726
+ let commentClosed = false;
606
727
  while (pos < safeLength) {
607
- var ch = text.charCodeAt(pos);
608
- if (ch === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
728
+ const ch = text.charCodeAt(pos);
729
+ if (ch === 42 /* CharacterCodes.asterisk */ && text.charCodeAt(pos + 1) === 47 /* CharacterCodes.slash */) {
609
730
  pos += 2;
610
731
  commentClosed = true;
611
732
  break;
612
733
  }
613
734
  pos++;
614
735
  if (isLineBreak(ch)) {
615
- if (ch === 13 /* carriageReturn */ && text.charCodeAt(pos) === 10 /* lineFeed */) {
736
+ if (ch === 13 /* CharacterCodes.carriageReturn */ && text.charCodeAt(pos) === 10 /* CharacterCodes.lineFeed */) {
616
737
  pos++;
617
738
  }
618
739
  lineNumber++;
@@ -621,37 +742,37 @@ function createScanner(text, ignoreTrivia) {
621
742
  }
622
743
  if (!commentClosed) {
623
744
  pos++;
624
- scanError = 1 /* UnexpectedEndOfComment */;
745
+ scanError = 1 /* ScanError.UnexpectedEndOfComment */;
625
746
  }
626
747
  value = text.substring(start, pos);
627
- return token = 13 /* BlockCommentTrivia */;
748
+ return token = 13 /* SyntaxKind.BlockCommentTrivia */;
628
749
  }
629
750
  // just a single slash
630
751
  value += String.fromCharCode(code);
631
752
  pos++;
632
- return token = 16 /* Unknown */;
753
+ return token = 16 /* SyntaxKind.Unknown */;
633
754
  // numbers
634
- case 45 /* minus */:
755
+ case 45 /* CharacterCodes.minus */:
635
756
  value += String.fromCharCode(code);
636
757
  pos++;
637
758
  if (pos === len || !isDigit(text.charCodeAt(pos))) {
638
- return token = 16 /* Unknown */;
759
+ return token = 16 /* SyntaxKind.Unknown */;
639
760
  }
640
761
  // found a minus, followed by a number so
641
762
  // we fall through to proceed with scanning
642
763
  // numbers
643
- case 48 /* _0 */:
644
- case 49 /* _1 */:
645
- case 50 /* _2 */:
646
- case 51 /* _3 */:
647
- case 52 /* _4 */:
648
- case 53 /* _5 */:
649
- case 54 /* _6 */:
650
- case 55 /* _7 */:
651
- case 56 /* _8 */:
652
- case 57 /* _9 */:
764
+ case 48 /* CharacterCodes._0 */:
765
+ case 49 /* CharacterCodes._1 */:
766
+ case 50 /* CharacterCodes._2 */:
767
+ case 51 /* CharacterCodes._3 */:
768
+ case 52 /* CharacterCodes._4 */:
769
+ case 53 /* CharacterCodes._5 */:
770
+ case 54 /* CharacterCodes._6 */:
771
+ case 55 /* CharacterCodes._7 */:
772
+ case 56 /* CharacterCodes._8 */:
773
+ case 57 /* CharacterCodes._9 */:
653
774
  value += scanNumber();
654
- return token = 11 /* NumericLiteral */;
775
+ return token = 11 /* SyntaxKind.NumericLiteral */;
655
776
  // literals and unknown symbols
656
777
  default:
657
778
  // is a literal? Read the full word.
@@ -663,16 +784,16 @@ function createScanner(text, ignoreTrivia) {
663
784
  value = text.substring(tokenOffset, pos);
664
785
  // keywords: true, false, null
665
786
  switch (value) {
666
- case 'true': return token = 8 /* TrueKeyword */;
667
- case 'false': return token = 9 /* FalseKeyword */;
668
- case 'null': return token = 7 /* NullKeyword */;
787
+ case 'true': return token = 8 /* SyntaxKind.TrueKeyword */;
788
+ case 'false': return token = 9 /* SyntaxKind.FalseKeyword */;
789
+ case 'null': return token = 7 /* SyntaxKind.NullKeyword */;
669
790
  }
670
- return token = 16 /* Unknown */;
791
+ return token = 16 /* SyntaxKind.Unknown */;
671
792
  }
672
793
  // some
673
794
  value += String.fromCharCode(code);
674
795
  pos++;
675
- return token = 16 /* Unknown */;
796
+ return token = 16 /* SyntaxKind.Unknown */;
676
797
  }
677
798
  }
678
799
  function isUnknownContentCharacter(code) {
@@ -680,49 +801,130 @@ function createScanner(text, ignoreTrivia) {
680
801
  return false;
681
802
  }
682
803
  switch (code) {
683
- case 125 /* closeBrace */:
684
- case 93 /* closeBracket */:
685
- case 123 /* openBrace */:
686
- case 91 /* openBracket */:
687
- case 34 /* doubleQuote */:
688
- case 58 /* colon */:
689
- case 44 /* comma */:
690
- case 47 /* slash */:
804
+ case 125 /* CharacterCodes.closeBrace */:
805
+ case 93 /* CharacterCodes.closeBracket */:
806
+ case 123 /* CharacterCodes.openBrace */:
807
+ case 91 /* CharacterCodes.openBracket */:
808
+ case 34 /* CharacterCodes.doubleQuote */:
809
+ case 58 /* CharacterCodes.colon */:
810
+ case 44 /* CharacterCodes.comma */:
811
+ case 47 /* CharacterCodes.slash */:
691
812
  return false;
692
813
  }
693
814
  return true;
694
815
  }
695
816
  function scanNextNonTrivia() {
696
- var result;
817
+ let result;
697
818
  do {
698
819
  result = scanNext();
699
- } while (result >= 12 /* LineCommentTrivia */ && result <= 15 /* Trivia */);
820
+ } while (result >= 12 /* SyntaxKind.LineCommentTrivia */ && result <= 15 /* SyntaxKind.Trivia */);
700
821
  return result;
701
822
  }
702
823
  return {
703
824
  setPosition: setPosition,
704
- getPosition: function () { return pos; },
825
+ getPosition: () => pos,
705
826
  scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
706
- getToken: function () { return token; },
707
- getTokenValue: function () { return value; },
708
- getTokenOffset: function () { return tokenOffset; },
709
- getTokenLength: function () { return pos - tokenOffset; },
710
- getTokenStartLine: function () { return lineStartOffset; },
711
- getTokenStartCharacter: function () { return tokenOffset - prevTokenLineStartOffset; },
712
- getTokenError: function () { return scanError; },
827
+ getToken: () => token,
828
+ getTokenValue: () => value,
829
+ getTokenOffset: () => tokenOffset,
830
+ getTokenLength: () => pos - tokenOffset,
831
+ getTokenStartLine: () => lineStartOffset,
832
+ getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
833
+ getTokenError: () => scanError,
713
834
  };
714
835
  }
715
836
  function isWhiteSpace(ch) {
716
- return ch === 32 /* space */ || ch === 9 /* tab */ || ch === 11 /* verticalTab */ || ch === 12 /* formFeed */ ||
717
- ch === 160 /* nonBreakingSpace */ || ch === 5760 /* ogham */ || ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ ||
718
- ch === 8239 /* narrowNoBreakSpace */ || ch === 8287 /* mathematicalSpace */ || ch === 12288 /* ideographicSpace */ || ch === 65279 /* byteOrderMark */;
837
+ return ch === 32 /* CharacterCodes.space */ || ch === 9 /* CharacterCodes.tab */;
719
838
  }
720
839
  function isLineBreak(ch) {
721
- return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */;
840
+ return ch === 10 /* CharacterCodes.lineFeed */ || ch === 13 /* CharacterCodes.carriageReturn */;
722
841
  }
723
842
  function isDigit(ch) {
724
- return ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
843
+ return ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */;
725
844
  }
845
+ var CharacterCodes;
846
+ (function (CharacterCodes) {
847
+ CharacterCodes[CharacterCodes["lineFeed"] = 10] = "lineFeed";
848
+ CharacterCodes[CharacterCodes["carriageReturn"] = 13] = "carriageReturn";
849
+ CharacterCodes[CharacterCodes["space"] = 32] = "space";
850
+ CharacterCodes[CharacterCodes["_0"] = 48] = "_0";
851
+ CharacterCodes[CharacterCodes["_1"] = 49] = "_1";
852
+ CharacterCodes[CharacterCodes["_2"] = 50] = "_2";
853
+ CharacterCodes[CharacterCodes["_3"] = 51] = "_3";
854
+ CharacterCodes[CharacterCodes["_4"] = 52] = "_4";
855
+ CharacterCodes[CharacterCodes["_5"] = 53] = "_5";
856
+ CharacterCodes[CharacterCodes["_6"] = 54] = "_6";
857
+ CharacterCodes[CharacterCodes["_7"] = 55] = "_7";
858
+ CharacterCodes[CharacterCodes["_8"] = 56] = "_8";
859
+ CharacterCodes[CharacterCodes["_9"] = 57] = "_9";
860
+ CharacterCodes[CharacterCodes["a"] = 97] = "a";
861
+ CharacterCodes[CharacterCodes["b"] = 98] = "b";
862
+ CharacterCodes[CharacterCodes["c"] = 99] = "c";
863
+ CharacterCodes[CharacterCodes["d"] = 100] = "d";
864
+ CharacterCodes[CharacterCodes["e"] = 101] = "e";
865
+ CharacterCodes[CharacterCodes["f"] = 102] = "f";
866
+ CharacterCodes[CharacterCodes["g"] = 103] = "g";
867
+ CharacterCodes[CharacterCodes["h"] = 104] = "h";
868
+ CharacterCodes[CharacterCodes["i"] = 105] = "i";
869
+ CharacterCodes[CharacterCodes["j"] = 106] = "j";
870
+ CharacterCodes[CharacterCodes["k"] = 107] = "k";
871
+ CharacterCodes[CharacterCodes["l"] = 108] = "l";
872
+ CharacterCodes[CharacterCodes["m"] = 109] = "m";
873
+ CharacterCodes[CharacterCodes["n"] = 110] = "n";
874
+ CharacterCodes[CharacterCodes["o"] = 111] = "o";
875
+ CharacterCodes[CharacterCodes["p"] = 112] = "p";
876
+ CharacterCodes[CharacterCodes["q"] = 113] = "q";
877
+ CharacterCodes[CharacterCodes["r"] = 114] = "r";
878
+ CharacterCodes[CharacterCodes["s"] = 115] = "s";
879
+ CharacterCodes[CharacterCodes["t"] = 116] = "t";
880
+ CharacterCodes[CharacterCodes["u"] = 117] = "u";
881
+ CharacterCodes[CharacterCodes["v"] = 118] = "v";
882
+ CharacterCodes[CharacterCodes["w"] = 119] = "w";
883
+ CharacterCodes[CharacterCodes["x"] = 120] = "x";
884
+ CharacterCodes[CharacterCodes["y"] = 121] = "y";
885
+ CharacterCodes[CharacterCodes["z"] = 122] = "z";
886
+ CharacterCodes[CharacterCodes["A"] = 65] = "A";
887
+ CharacterCodes[CharacterCodes["B"] = 66] = "B";
888
+ CharacterCodes[CharacterCodes["C"] = 67] = "C";
889
+ CharacterCodes[CharacterCodes["D"] = 68] = "D";
890
+ CharacterCodes[CharacterCodes["E"] = 69] = "E";
891
+ CharacterCodes[CharacterCodes["F"] = 70] = "F";
892
+ CharacterCodes[CharacterCodes["G"] = 71] = "G";
893
+ CharacterCodes[CharacterCodes["H"] = 72] = "H";
894
+ CharacterCodes[CharacterCodes["I"] = 73] = "I";
895
+ CharacterCodes[CharacterCodes["J"] = 74] = "J";
896
+ CharacterCodes[CharacterCodes["K"] = 75] = "K";
897
+ CharacterCodes[CharacterCodes["L"] = 76] = "L";
898
+ CharacterCodes[CharacterCodes["M"] = 77] = "M";
899
+ CharacterCodes[CharacterCodes["N"] = 78] = "N";
900
+ CharacterCodes[CharacterCodes["O"] = 79] = "O";
901
+ CharacterCodes[CharacterCodes["P"] = 80] = "P";
902
+ CharacterCodes[CharacterCodes["Q"] = 81] = "Q";
903
+ CharacterCodes[CharacterCodes["R"] = 82] = "R";
904
+ CharacterCodes[CharacterCodes["S"] = 83] = "S";
905
+ CharacterCodes[CharacterCodes["T"] = 84] = "T";
906
+ CharacterCodes[CharacterCodes["U"] = 85] = "U";
907
+ CharacterCodes[CharacterCodes["V"] = 86] = "V";
908
+ CharacterCodes[CharacterCodes["W"] = 87] = "W";
909
+ CharacterCodes[CharacterCodes["X"] = 88] = "X";
910
+ CharacterCodes[CharacterCodes["Y"] = 89] = "Y";
911
+ CharacterCodes[CharacterCodes["Z"] = 90] = "Z";
912
+ CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk";
913
+ CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash";
914
+ CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace";
915
+ CharacterCodes[CharacterCodes["closeBracket"] = 93] = "closeBracket";
916
+ CharacterCodes[CharacterCodes["colon"] = 58] = "colon";
917
+ CharacterCodes[CharacterCodes["comma"] = 44] = "comma";
918
+ CharacterCodes[CharacterCodes["dot"] = 46] = "dot";
919
+ CharacterCodes[CharacterCodes["doubleQuote"] = 34] = "doubleQuote";
920
+ CharacterCodes[CharacterCodes["minus"] = 45] = "minus";
921
+ CharacterCodes[CharacterCodes["openBrace"] = 123] = "openBrace";
922
+ CharacterCodes[CharacterCodes["openBracket"] = 91] = "openBracket";
923
+ CharacterCodes[CharacterCodes["plus"] = 43] = "plus";
924
+ CharacterCodes[CharacterCodes["slash"] = 47] = "slash";
925
+ CharacterCodes[CharacterCodes["formFeed"] = 12] = "formFeed";
926
+ CharacterCodes[CharacterCodes["tab"] = 9] = "tab";
927
+ })(CharacterCodes || (CharacterCodes = {}));
726
928
 
727
929
 
728
930
  /***/ }),
@@ -746,22 +948,21 @@ __webpack_require__.r(__webpack_exports__);
746
948
 
747
949
 
748
950
 
749
- function removeProperty(text, path, formattingOptions) {
750
- return setProperty(text, path, void 0, formattingOptions);
951
+ function removeProperty(text, path, options) {
952
+ return setProperty(text, path, void 0, options);
751
953
  }
752
- function setProperty(text, originalPath, value, formattingOptions, getInsertionIndex) {
753
- var _a;
754
- var path = originalPath.slice();
755
- var errors = [];
756
- var root = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.parseTree)(text, errors);
757
- var parent = void 0;
758
- var lastSegment = void 0;
954
+ function setProperty(text, originalPath, value, options) {
955
+ const path = originalPath.slice();
956
+ const errors = [];
957
+ const root = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.parseTree)(text, errors);
958
+ let parent = void 0;
959
+ let lastSegment = void 0;
759
960
  while (path.length > 0) {
760
961
  lastSegment = path.pop();
761
962
  parent = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(root, path);
762
963
  if (parent === void 0 && value !== void 0) {
763
964
  if (typeof lastSegment === 'string') {
764
- value = (_a = {}, _a[lastSegment] = value, _a);
965
+ value = { [lastSegment]: value };
765
966
  }
766
967
  else {
767
968
  value = [value];
@@ -776,47 +977,47 @@ function setProperty(text, originalPath, value, formattingOptions, getInsertionI
776
977
  if (value === void 0) { // delete
777
978
  throw new Error('Can not delete in empty document');
778
979
  }
779
- return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, formattingOptions);
980
+ return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, options);
780
981
  }
781
982
  else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
782
- var existing = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(parent, [lastSegment]);
983
+ const existing = (0,_parser__WEBPACK_IMPORTED_MODULE_1__.findNodeAtLocation)(parent, [lastSegment]);
783
984
  if (existing !== void 0) {
784
985
  if (value === void 0) { // delete
785
986
  if (!existing.parent) {
786
987
  throw new Error('Malformed AST');
787
988
  }
788
- var propertyIndex = parent.children.indexOf(existing.parent);
789
- var removeBegin = void 0;
790
- var removeEnd = existing.parent.offset + existing.parent.length;
989
+ const propertyIndex = parent.children.indexOf(existing.parent);
990
+ let removeBegin;
991
+ let removeEnd = existing.parent.offset + existing.parent.length;
791
992
  if (propertyIndex > 0) {
792
993
  // remove the comma of the previous node
793
- var previous = parent.children[propertyIndex - 1];
994
+ let previous = parent.children[propertyIndex - 1];
794
995
  removeBegin = previous.offset + previous.length;
795
996
  }
796
997
  else {
797
998
  removeBegin = parent.offset + 1;
798
999
  if (parent.children.length > 1) {
799
1000
  // remove the comma of the next node
800
- var next = parent.children[1];
1001
+ let next = parent.children[1];
801
1002
  removeEnd = next.offset;
802
1003
  }
803
1004
  }
804
- return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, formattingOptions);
1005
+ return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, options);
805
1006
  }
806
1007
  else {
807
1008
  // set value of existing property
808
- return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, formattingOptions);
1009
+ return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, options);
809
1010
  }
810
1011
  }
811
1012
  else {
812
1013
  if (value === void 0) { // delete
813
1014
  return []; // property does not exist, nothing to do
814
1015
  }
815
- var newProperty = JSON.stringify(lastSegment) + ": " + JSON.stringify(value);
816
- var index = getInsertionIndex ? getInsertionIndex(parent.children.map(function (p) { return p.children[0].value; })) : parent.children.length;
817
- var edit = void 0;
1016
+ const newProperty = `${JSON.stringify(lastSegment)}: ${JSON.stringify(value)}`;
1017
+ const index = options.getInsertionIndex ? options.getInsertionIndex(parent.children.map(p => p.children[0].value)) : parent.children.length;
1018
+ let edit;
818
1019
  if (index > 0) {
819
- var previous = parent.children[index - 1];
1020
+ let previous = parent.children[index - 1];
820
1021
  edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
821
1022
  }
822
1023
  else if (parent.children.length === 0) {
@@ -825,61 +1026,79 @@ function setProperty(text, originalPath, value, formattingOptions, getInsertionI
825
1026
  else {
826
1027
  edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
827
1028
  }
828
- return withFormatting(text, edit, formattingOptions);
1029
+ return withFormatting(text, edit, options);
829
1030
  }
830
1031
  }
831
1032
  else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
832
- var insertIndex = lastSegment;
1033
+ const insertIndex = lastSegment;
833
1034
  if (insertIndex === -1) {
834
1035
  // Insert
835
- var newProperty = "" + JSON.stringify(value);
836
- var edit = void 0;
1036
+ const newProperty = `${JSON.stringify(value)}`;
1037
+ let edit;
837
1038
  if (parent.children.length === 0) {
838
1039
  edit = { offset: parent.offset + 1, length: 0, content: newProperty };
839
1040
  }
840
1041
  else {
841
- var previous = parent.children[parent.children.length - 1];
1042
+ const previous = parent.children[parent.children.length - 1];
842
1043
  edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
843
1044
  }
844
- return withFormatting(text, edit, formattingOptions);
845
- }
846
- else {
847
- if (value === void 0 && parent.children.length >= 0) {
848
- //Removal
849
- var removalIndex = lastSegment;
850
- var toRemove = parent.children[removalIndex];
851
- var edit = void 0;
852
- if (parent.children.length === 1) {
853
- // only item
854
- edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
855
- }
856
- else if (parent.children.length - 1 === removalIndex) {
857
- // last item
858
- var previous = parent.children[removalIndex - 1];
859
- var offset = previous.offset + previous.length;
860
- var parentEndOffset = parent.offset + parent.length;
861
- edit = { offset: offset, length: parentEndOffset - 2 - offset, content: '' };
862
- }
863
- else {
864
- edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
865
- }
866
- return withFormatting(text, edit, formattingOptions);
1045
+ return withFormatting(text, edit, options);
1046
+ }
1047
+ else if (value === void 0 && parent.children.length >= 0) {
1048
+ // Removal
1049
+ const removalIndex = lastSegment;
1050
+ const toRemove = parent.children[removalIndex];
1051
+ let edit;
1052
+ if (parent.children.length === 1) {
1053
+ // only item
1054
+ edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
1055
+ }
1056
+ else if (parent.children.length - 1 === removalIndex) {
1057
+ // last item
1058
+ let previous = parent.children[removalIndex - 1];
1059
+ let offset = previous.offset + previous.length;
1060
+ let parentEndOffset = parent.offset + parent.length;
1061
+ edit = { offset, length: parentEndOffset - 2 - offset, content: '' };
867
1062
  }
868
1063
  else {
869
- throw new Error('Array modification not supported yet');
1064
+ edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
1065
+ }
1066
+ return withFormatting(text, edit, options);
1067
+ }
1068
+ else if (value !== void 0) {
1069
+ let edit;
1070
+ const newProperty = `${JSON.stringify(value)}`;
1071
+ if (!options.isArrayInsertion && parent.children.length > lastSegment) {
1072
+ const toModify = parent.children[lastSegment];
1073
+ edit = { offset: toModify.offset, length: toModify.length, content: newProperty };
1074
+ }
1075
+ else if (parent.children.length === 0 || lastSegment === 0) {
1076
+ edit = { offset: parent.offset + 1, length: 0, content: parent.children.length === 0 ? newProperty : newProperty + ',' };
1077
+ }
1078
+ else {
1079
+ const index = lastSegment > parent.children.length ? parent.children.length : lastSegment;
1080
+ const previous = parent.children[index - 1];
1081
+ edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
870
1082
  }
1083
+ return withFormatting(text, edit, options);
1084
+ }
1085
+ else {
1086
+ throw new Error(`Can not ${value === void 0 ? 'remove' : (options.isArrayInsertion ? 'insert' : 'modify')} Array index ${insertIndex} as length is not sufficient`);
871
1087
  }
872
1088
  }
873
1089
  else {
874
- throw new Error("Can not add " + (typeof lastSegment !== 'number' ? 'index' : 'property') + " to parent of type " + parent.type);
1090
+ throw new Error(`Can not add ${typeof lastSegment !== 'number' ? 'index' : 'property'} to parent of type ${parent.type}`);
875
1091
  }
876
1092
  }
877
- function withFormatting(text, edit, formattingOptions) {
1093
+ function withFormatting(text, edit, options) {
1094
+ if (!options.formattingOptions) {
1095
+ return [edit];
1096
+ }
878
1097
  // apply the edit
879
- var newText = applyEdit(text, edit);
1098
+ let newText = applyEdit(text, edit);
880
1099
  // format the new text
881
- var begin = edit.offset;
882
- var end = edit.offset + edit.content.length;
1100
+ let begin = edit.offset;
1101
+ let end = edit.offset + edit.content.length;
883
1102
  if (edit.length === 0 || edit.content.length === 0) { // insert or remove
884
1103
  while (begin > 0 && !(0,_format__WEBPACK_IMPORTED_MODULE_0__.isEOL)(newText, begin - 1)) {
885
1104
  begin--;
@@ -888,17 +1107,17 @@ function withFormatting(text, edit, formattingOptions) {
888
1107
  end++;
889
1108
  }
890
1109
  }
891
- var edits = (0,_format__WEBPACK_IMPORTED_MODULE_0__.format)(newText, { offset: begin, length: end - begin }, formattingOptions);
1110
+ const edits = (0,_format__WEBPACK_IMPORTED_MODULE_0__.format)(newText, { offset: begin, length: end - begin }, { ...options.formattingOptions, keepLines: false });
892
1111
  // apply the formatting edits and track the begin and end offsets of the changes
893
- for (var i = edits.length - 1; i >= 0; i--) {
894
- var edit_1 = edits[i];
895
- newText = applyEdit(newText, edit_1);
896
- begin = Math.min(begin, edit_1.offset);
897
- end = Math.max(end, edit_1.offset + edit_1.length);
898
- end += edit_1.content.length - edit_1.length;
1112
+ for (let i = edits.length - 1; i >= 0; i--) {
1113
+ const edit = edits[i];
1114
+ newText = applyEdit(newText, edit);
1115
+ begin = Math.min(begin, edit.offset);
1116
+ end = Math.max(end, edit.offset + edit.length);
1117
+ end += edit.content.length - edit.length;
899
1118
  }
900
1119
  // create a single edit with all changes
901
- var editLength = text.length - (newText.length - end) - begin;
1120
+ const editLength = text.length - (newText.length - end) - begin;
902
1121
  return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
903
1122
  }
904
1123
  function applyEdit(text, edit) {
@@ -945,17 +1164,17 @@ var ParseOptions;
945
1164
  * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
946
1165
  */
947
1166
  function getLocation(text, position) {
948
- var segments = []; // strings or numbers
949
- var earlyReturnException = new Object();
950
- var previousNode = undefined;
951
- var previousNodeInst = {
1167
+ const segments = []; // strings or numbers
1168
+ const earlyReturnException = new Object();
1169
+ let previousNode = undefined;
1170
+ const previousNodeInst = {
952
1171
  value: {},
953
1172
  offset: 0,
954
1173
  length: 0,
955
1174
  type: 'object',
956
1175
  parent: undefined
957
1176
  };
958
- var isAtPropertyKey = false;
1177
+ let isAtPropertyKey = false;
959
1178
  function setPreviousNode(value, offset, length, type) {
960
1179
  previousNodeInst.value = value;
961
1180
  previousNodeInst.offset = offset;
@@ -966,7 +1185,7 @@ function getLocation(text, position) {
966
1185
  }
967
1186
  try {
968
1187
  visit(text, {
969
- onObjectBegin: function (offset, length) {
1188
+ onObjectBegin: (offset, length) => {
970
1189
  if (position <= offset) {
971
1190
  throw earlyReturnException;
972
1191
  }
@@ -974,7 +1193,7 @@ function getLocation(text, position) {
974
1193
  isAtPropertyKey = position > offset;
975
1194
  segments.push(''); // push a placeholder (will be replaced)
976
1195
  },
977
- onObjectProperty: function (name, offset, length) {
1196
+ onObjectProperty: (name, offset, length) => {
978
1197
  if (position < offset) {
979
1198
  throw earlyReturnException;
980
1199
  }
@@ -984,28 +1203,28 @@ function getLocation(text, position) {
984
1203
  throw earlyReturnException;
985
1204
  }
986
1205
  },
987
- onObjectEnd: function (offset, length) {
1206
+ onObjectEnd: (offset, length) => {
988
1207
  if (position <= offset) {
989
1208
  throw earlyReturnException;
990
1209
  }
991
1210
  previousNode = undefined;
992
1211
  segments.pop();
993
1212
  },
994
- onArrayBegin: function (offset, length) {
1213
+ onArrayBegin: (offset, length) => {
995
1214
  if (position <= offset) {
996
1215
  throw earlyReturnException;
997
1216
  }
998
1217
  previousNode = undefined;
999
1218
  segments.push(0);
1000
1219
  },
1001
- onArrayEnd: function (offset, length) {
1220
+ onArrayEnd: (offset, length) => {
1002
1221
  if (position <= offset) {
1003
1222
  throw earlyReturnException;
1004
1223
  }
1005
1224
  previousNode = undefined;
1006
1225
  segments.pop();
1007
1226
  },
1008
- onLiteralValue: function (value, offset, length) {
1227
+ onLiteralValue: (value, offset, length) => {
1009
1228
  if (position < offset) {
1010
1229
  throw earlyReturnException;
1011
1230
  }
@@ -1014,7 +1233,7 @@ function getLocation(text, position) {
1014
1233
  throw earlyReturnException;
1015
1234
  }
1016
1235
  },
1017
- onSeparator: function (sep, offset, length) {
1236
+ onSeparator: (sep, offset, length) => {
1018
1237
  if (position <= offset) {
1019
1238
  throw earlyReturnException;
1020
1239
  }
@@ -1024,7 +1243,7 @@ function getLocation(text, position) {
1024
1243
  previousNode = undefined;
1025
1244
  }
1026
1245
  else if (sep === ',') {
1027
- var last = segments[segments.length - 1];
1246
+ const last = segments[segments.length - 1];
1028
1247
  if (typeof last === 'number') {
1029
1248
  segments[segments.length - 1] = last + 1;
1030
1249
  }
@@ -1044,11 +1263,11 @@ function getLocation(text, position) {
1044
1263
  }
1045
1264
  return {
1046
1265
  path: segments,
1047
- previousNode: previousNode,
1048
- isAtPropertyKey: isAtPropertyKey,
1049
- matches: function (pattern) {
1050
- var k = 0;
1051
- for (var i = 0; k < pattern.length && i < segments.length; i++) {
1266
+ previousNode,
1267
+ isAtPropertyKey,
1268
+ matches: (pattern) => {
1269
+ let k = 0;
1270
+ for (let i = 0; k < pattern.length && i < segments.length; i++) {
1052
1271
  if (pattern[k] === segments[i] || pattern[k] === '*') {
1053
1272
  k++;
1054
1273
  }
@@ -1064,12 +1283,10 @@ function getLocation(text, position) {
1064
1283
  * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
1065
1284
  * Therefore always check the errors list to find out if the input was valid.
1066
1285
  */
1067
- function parse(text, errors, options) {
1068
- if (errors === void 0) { errors = []; }
1069
- if (options === void 0) { options = ParseOptions.DEFAULT; }
1070
- var currentProperty = null;
1071
- var currentParent = [];
1072
- var previousParents = [];
1286
+ function parse(text, errors = [], options = ParseOptions.DEFAULT) {
1287
+ let currentProperty = null;
1288
+ let currentParent = [];
1289
+ const previousParents = [];
1073
1290
  function onValue(value) {
1074
1291
  if (Array.isArray(currentParent)) {
1075
1292
  currentParent.push(value);
@@ -1078,33 +1295,33 @@ function parse(text, errors, options) {
1078
1295
  currentParent[currentProperty] = value;
1079
1296
  }
1080
1297
  }
1081
- var visitor = {
1082
- onObjectBegin: function () {
1083
- var object = {};
1298
+ const visitor = {
1299
+ onObjectBegin: () => {
1300
+ const object = {};
1084
1301
  onValue(object);
1085
1302
  previousParents.push(currentParent);
1086
1303
  currentParent = object;
1087
1304
  currentProperty = null;
1088
1305
  },
1089
- onObjectProperty: function (name) {
1306
+ onObjectProperty: (name) => {
1090
1307
  currentProperty = name;
1091
1308
  },
1092
- onObjectEnd: function () {
1309
+ onObjectEnd: () => {
1093
1310
  currentParent = previousParents.pop();
1094
1311
  },
1095
- onArrayBegin: function () {
1096
- var array = [];
1312
+ onArrayBegin: () => {
1313
+ const array = [];
1097
1314
  onValue(array);
1098
1315
  previousParents.push(currentParent);
1099
1316
  currentParent = array;
1100
1317
  currentProperty = null;
1101
1318
  },
1102
- onArrayEnd: function () {
1319
+ onArrayEnd: () => {
1103
1320
  currentParent = previousParents.pop();
1104
1321
  },
1105
1322
  onLiteralValue: onValue,
1106
- onError: function (error, offset, length) {
1107
- errors.push({ error: error, offset: offset, length: length });
1323
+ onError: (error, offset, length) => {
1324
+ errors.push({ error, offset, length });
1108
1325
  }
1109
1326
  };
1110
1327
  visit(text, visitor, options);
@@ -1113,10 +1330,8 @@ function parse(text, errors, options) {
1113
1330
  /**
1114
1331
  * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
1115
1332
  */
1116
- function parseTree(text, errors, options) {
1117
- if (errors === void 0) { errors = []; }
1118
- if (options === void 0) { options = ParseOptions.DEFAULT; }
1119
- var currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
1333
+ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
1334
+ let currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: undefined }; // artificial root
1120
1335
  function ensurePropertyComplete(endOffset) {
1121
1336
  if (currentParent.type === 'property') {
1122
1337
  currentParent.length = endOffset - currentParent.offset;
@@ -1127,33 +1342,33 @@ function parseTree(text, errors, options) {
1127
1342
  currentParent.children.push(valueNode);
1128
1343
  return valueNode;
1129
1344
  }
1130
- var visitor = {
1131
- onObjectBegin: function (offset) {
1132
- currentParent = onValue({ type: 'object', offset: offset, length: -1, parent: currentParent, children: [] });
1345
+ const visitor = {
1346
+ onObjectBegin: (offset) => {
1347
+ currentParent = onValue({ type: 'object', offset, length: -1, parent: currentParent, children: [] });
1133
1348
  },
1134
- onObjectProperty: function (name, offset, length) {
1135
- currentParent = onValue({ type: 'property', offset: offset, length: -1, parent: currentParent, children: [] });
1136
- currentParent.children.push({ type: 'string', value: name, offset: offset, length: length, parent: currentParent });
1349
+ onObjectProperty: (name, offset, length) => {
1350
+ currentParent = onValue({ type: 'property', offset, length: -1, parent: currentParent, children: [] });
1351
+ currentParent.children.push({ type: 'string', value: name, offset, length, parent: currentParent });
1137
1352
  },
1138
- onObjectEnd: function (offset, length) {
1353
+ onObjectEnd: (offset, length) => {
1139
1354
  ensurePropertyComplete(offset + length); // in case of a missing value for a property: make sure property is complete
1140
1355
  currentParent.length = offset + length - currentParent.offset;
1141
1356
  currentParent = currentParent.parent;
1142
1357
  ensurePropertyComplete(offset + length);
1143
1358
  },
1144
- onArrayBegin: function (offset, length) {
1145
- currentParent = onValue({ type: 'array', offset: offset, length: -1, parent: currentParent, children: [] });
1359
+ onArrayBegin: (offset, length) => {
1360
+ currentParent = onValue({ type: 'array', offset, length: -1, parent: currentParent, children: [] });
1146
1361
  },
1147
- onArrayEnd: function (offset, length) {
1362
+ onArrayEnd: (offset, length) => {
1148
1363
  currentParent.length = offset + length - currentParent.offset;
1149
1364
  currentParent = currentParent.parent;
1150
1365
  ensurePropertyComplete(offset + length);
1151
1366
  },
1152
- onLiteralValue: function (value, offset, length) {
1153
- onValue({ type: getNodeType(value), offset: offset, length: length, parent: currentParent, value: value });
1367
+ onLiteralValue: (value, offset, length) => {
1368
+ onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
1154
1369
  ensurePropertyComplete(offset + length);
1155
1370
  },
1156
- onSeparator: function (sep, offset, length) {
1371
+ onSeparator: (sep, offset, length) => {
1157
1372
  if (currentParent.type === 'property') {
1158
1373
  if (sep === ':') {
1159
1374
  currentParent.colonOffset = offset;
@@ -1163,12 +1378,12 @@ function parseTree(text, errors, options) {
1163
1378
  }
1164
1379
  }
1165
1380
  },
1166
- onError: function (error, offset, length) {
1167
- errors.push({ error: error, offset: offset, length: length });
1381
+ onError: (error, offset, length) => {
1382
+ errors.push({ error, offset, length });
1168
1383
  }
1169
1384
  };
1170
1385
  visit(text, visitor, options);
1171
- var result = currentParent.children[0];
1386
+ const result = currentParent.children[0];
1172
1387
  if (result) {
1173
1388
  delete result.parent;
1174
1389
  }
@@ -1181,17 +1396,15 @@ function findNodeAtLocation(root, path) {
1181
1396
  if (!root) {
1182
1397
  return undefined;
1183
1398
  }
1184
- var node = root;
1185
- for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
1186
- var segment = path_1[_i];
1399
+ let node = root;
1400
+ for (let segment of path) {
1187
1401
  if (typeof segment === 'string') {
1188
1402
  if (node.type !== 'object' || !Array.isArray(node.children)) {
1189
1403
  return undefined;
1190
1404
  }
1191
- var found = false;
1192
- for (var _a = 0, _b = node.children; _a < _b.length; _a++) {
1193
- var propertyNode = _b[_a];
1194
- if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment) {
1405
+ let found = false;
1406
+ for (const propertyNode of node.children) {
1407
+ if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
1195
1408
  node = propertyNode.children[1];
1196
1409
  found = true;
1197
1410
  break;
@@ -1202,7 +1415,7 @@ function findNodeAtLocation(root, path) {
1202
1415
  }
1203
1416
  }
1204
1417
  else {
1205
- var index = segment;
1418
+ const index = segment;
1206
1419
  if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
1207
1420
  return undefined;
1208
1421
  }
@@ -1218,13 +1431,13 @@ function getNodePath(node) {
1218
1431
  if (!node.parent || !node.parent.children) {
1219
1432
  return [];
1220
1433
  }
1221
- var path = getNodePath(node.parent);
1434
+ const path = getNodePath(node.parent);
1222
1435
  if (node.parent.type === 'property') {
1223
- var key = node.parent.children[0].value;
1436
+ const key = node.parent.children[0].value;
1224
1437
  path.push(key);
1225
1438
  }
1226
1439
  else if (node.parent.type === 'array') {
1227
- var index = node.parent.children.indexOf(node);
1440
+ const index = node.parent.children.indexOf(node);
1228
1441
  if (index !== -1) {
1229
1442
  path.push(index);
1230
1443
  }
@@ -1239,10 +1452,9 @@ function getNodeValue(node) {
1239
1452
  case 'array':
1240
1453
  return node.children.map(getNodeValue);
1241
1454
  case 'object':
1242
- var obj = Object.create(null);
1243
- for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
1244
- var prop = _a[_i];
1245
- var valueNode = prop.children[1];
1455
+ const obj = Object.create(null);
1456
+ for (let prop of node.children) {
1457
+ const valueNode = prop.children[1];
1246
1458
  if (valueNode) {
1247
1459
  obj[prop.children[0].value] = getNodeValue(valueNode);
1248
1460
  }
@@ -1257,20 +1469,18 @@ function getNodeValue(node) {
1257
1469
  return undefined;
1258
1470
  }
1259
1471
  }
1260
- function contains(node, offset, includeRightBound) {
1261
- if (includeRightBound === void 0) { includeRightBound = false; }
1472
+ function contains(node, offset, includeRightBound = false) {
1262
1473
  return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));
1263
1474
  }
1264
1475
  /**
1265
1476
  * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
1266
1477
  */
1267
- function findNodeAtOffset(node, offset, includeRightBound) {
1268
- if (includeRightBound === void 0) { includeRightBound = false; }
1478
+ function findNodeAtOffset(node, offset, includeRightBound = false) {
1269
1479
  if (contains(node, offset, includeRightBound)) {
1270
- var children = node.children;
1480
+ const children = node.children;
1271
1481
  if (Array.isArray(children)) {
1272
- for (var i = 0; i < children.length && children[i].offset <= offset; i++) {
1273
- var item = findNodeAtOffset(children[i], offset, includeRightBound);
1482
+ for (let i = 0; i < children.length && children[i].offset <= offset; i++) {
1483
+ const item = findNodeAtOffset(children[i], offset, includeRightBound);
1274
1484
  if (item) {
1275
1485
  return item;
1276
1486
  }
@@ -1283,71 +1493,77 @@ function findNodeAtOffset(node, offset, includeRightBound) {
1283
1493
  /**
1284
1494
  * Parses the given text and invokes the visitor functions for each object, array and literal reached.
1285
1495
  */
1286
- function visit(text, visitor, options) {
1287
- if (options === void 0) { options = ParseOptions.DEFAULT; }
1288
- var _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text, false);
1496
+ function visit(text, visitor, options = ParseOptions.DEFAULT) {
1497
+ const _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text, false);
1498
+ // Important: Only pass copies of this to visitor functions to prevent accidental modification, and
1499
+ // to not affect visitor functions which stored a reference to a previous JSONPath
1500
+ const _jsonPath = [];
1289
1501
  function toNoArgVisit(visitFunction) {
1290
- return visitFunction ? function () { return visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()); } : function () { return true; };
1502
+ return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
1503
+ }
1504
+ function toNoArgVisitWithPath(visitFunction) {
1505
+ return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
1291
1506
  }
1292
1507
  function toOneArgVisit(visitFunction) {
1293
- return visitFunction ? function (arg) { return visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()); } : function () { return true; };
1508
+ return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
1509
+ }
1510
+ function toOneArgVisitWithPath(visitFunction) {
1511
+ return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
1294
1512
  }
1295
- var onObjectBegin = toNoArgVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisit(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisit(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisit(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
1296
- var disallowComments = options && options.disallowComments;
1297
- var allowTrailingComma = options && options.allowTrailingComma;
1513
+ const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
1514
+ const disallowComments = options && options.disallowComments;
1515
+ const allowTrailingComma = options && options.allowTrailingComma;
1298
1516
  function scanNext() {
1299
1517
  while (true) {
1300
- var token = _scanner.scan();
1518
+ const token = _scanner.scan();
1301
1519
  switch (_scanner.getTokenError()) {
1302
- case 4 /* InvalidUnicode */:
1303
- handleError(14 /* InvalidUnicode */);
1520
+ case 4 /* ScanError.InvalidUnicode */:
1521
+ handleError(14 /* ParseErrorCode.InvalidUnicode */);
1304
1522
  break;
1305
- case 5 /* InvalidEscapeCharacter */:
1306
- handleError(15 /* InvalidEscapeCharacter */);
1523
+ case 5 /* ScanError.InvalidEscapeCharacter */:
1524
+ handleError(15 /* ParseErrorCode.InvalidEscapeCharacter */);
1307
1525
  break;
1308
- case 3 /* UnexpectedEndOfNumber */:
1309
- handleError(13 /* UnexpectedEndOfNumber */);
1526
+ case 3 /* ScanError.UnexpectedEndOfNumber */:
1527
+ handleError(13 /* ParseErrorCode.UnexpectedEndOfNumber */);
1310
1528
  break;
1311
- case 1 /* UnexpectedEndOfComment */:
1529
+ case 1 /* ScanError.UnexpectedEndOfComment */:
1312
1530
  if (!disallowComments) {
1313
- handleError(11 /* UnexpectedEndOfComment */);
1531
+ handleError(11 /* ParseErrorCode.UnexpectedEndOfComment */);
1314
1532
  }
1315
1533
  break;
1316
- case 2 /* UnexpectedEndOfString */:
1317
- handleError(12 /* UnexpectedEndOfString */);
1534
+ case 2 /* ScanError.UnexpectedEndOfString */:
1535
+ handleError(12 /* ParseErrorCode.UnexpectedEndOfString */);
1318
1536
  break;
1319
- case 6 /* InvalidCharacter */:
1320
- handleError(16 /* InvalidCharacter */);
1537
+ case 6 /* ScanError.InvalidCharacter */:
1538
+ handleError(16 /* ParseErrorCode.InvalidCharacter */);
1321
1539
  break;
1322
1540
  }
1323
1541
  switch (token) {
1324
- case 12 /* LineCommentTrivia */:
1325
- case 13 /* BlockCommentTrivia */:
1542
+ case 12 /* SyntaxKind.LineCommentTrivia */:
1543
+ case 13 /* SyntaxKind.BlockCommentTrivia */:
1326
1544
  if (disallowComments) {
1327
- handleError(10 /* InvalidCommentToken */);
1545
+ handleError(10 /* ParseErrorCode.InvalidCommentToken */);
1328
1546
  }
1329
1547
  else {
1330
1548
  onComment();
1331
1549
  }
1332
1550
  break;
1333
- case 16 /* Unknown */:
1334
- handleError(1 /* InvalidSymbol */);
1551
+ case 16 /* SyntaxKind.Unknown */:
1552
+ handleError(1 /* ParseErrorCode.InvalidSymbol */);
1335
1553
  break;
1336
- case 15 /* Trivia */:
1337
- case 14 /* LineBreakTrivia */:
1554
+ case 15 /* SyntaxKind.Trivia */:
1555
+ case 14 /* SyntaxKind.LineBreakTrivia */:
1338
1556
  break;
1339
1557
  default:
1340
1558
  return token;
1341
1559
  }
1342
1560
  }
1343
1561
  }
1344
- function handleError(error, skipUntilAfter, skipUntil) {
1345
- if (skipUntilAfter === void 0) { skipUntilAfter = []; }
1346
- if (skipUntil === void 0) { skipUntil = []; }
1562
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
1347
1563
  onError(error);
1348
1564
  if (skipUntilAfter.length + skipUntil.length > 0) {
1349
- var token = _scanner.getToken();
1350
- while (token !== 17 /* EOF */) {
1565
+ let token = _scanner.getToken();
1566
+ while (token !== 17 /* SyntaxKind.EOF */) {
1351
1567
  if (skipUntilAfter.indexOf(token) !== -1) {
1352
1568
  scanNext();
1353
1569
  break;
@@ -1360,39 +1576,36 @@ function visit(text, visitor, options) {
1360
1576
  }
1361
1577
  }
1362
1578
  function parseString(isValue) {
1363
- var value = _scanner.getTokenValue();
1579
+ const value = _scanner.getTokenValue();
1364
1580
  if (isValue) {
1365
1581
  onLiteralValue(value);
1366
1582
  }
1367
1583
  else {
1368
1584
  onObjectProperty(value);
1585
+ // add property name afterwards
1586
+ _jsonPath.push(value);
1369
1587
  }
1370
1588
  scanNext();
1371
1589
  return true;
1372
1590
  }
1373
1591
  function parseLiteral() {
1374
1592
  switch (_scanner.getToken()) {
1375
- case 11 /* NumericLiteral */:
1376
- var value = 0;
1377
- try {
1378
- value = JSON.parse(_scanner.getTokenValue());
1379
- if (typeof value !== 'number') {
1380
- handleError(2 /* InvalidNumberFormat */);
1381
- value = 0;
1382
- }
1383
- }
1384
- catch (e) {
1385
- handleError(2 /* InvalidNumberFormat */);
1593
+ case 11 /* SyntaxKind.NumericLiteral */:
1594
+ const tokenValue = _scanner.getTokenValue();
1595
+ let value = Number(tokenValue);
1596
+ if (isNaN(value)) {
1597
+ handleError(2 /* ParseErrorCode.InvalidNumberFormat */);
1598
+ value = 0;
1386
1599
  }
1387
1600
  onLiteralValue(value);
1388
1601
  break;
1389
- case 7 /* NullKeyword */:
1602
+ case 7 /* SyntaxKind.NullKeyword */:
1390
1603
  onLiteralValue(null);
1391
1604
  break;
1392
- case 8 /* TrueKeyword */:
1605
+ case 8 /* SyntaxKind.TrueKeyword */:
1393
1606
  onLiteralValue(true);
1394
1607
  break;
1395
- case 9 /* FalseKeyword */:
1608
+ case 9 /* SyntaxKind.FalseKeyword */:
1396
1609
  onLiteralValue(false);
1397
1610
  break;
1398
1611
  default:
@@ -1402,49 +1615,50 @@ function visit(text, visitor, options) {
1402
1615
  return true;
1403
1616
  }
1404
1617
  function parseProperty() {
1405
- if (_scanner.getToken() !== 10 /* StringLiteral */) {
1406
- handleError(3 /* PropertyNameExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
1618
+ if (_scanner.getToken() !== 10 /* SyntaxKind.StringLiteral */) {
1619
+ handleError(3 /* ParseErrorCode.PropertyNameExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1407
1620
  return false;
1408
1621
  }
1409
1622
  parseString(false);
1410
- if (_scanner.getToken() === 6 /* ColonToken */) {
1623
+ if (_scanner.getToken() === 6 /* SyntaxKind.ColonToken */) {
1411
1624
  onSeparator(':');
1412
1625
  scanNext(); // consume colon
1413
1626
  if (!parseValue()) {
1414
- handleError(4 /* ValueExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
1627
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1415
1628
  }
1416
1629
  }
1417
1630
  else {
1418
- handleError(5 /* ColonExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
1631
+ handleError(5 /* ParseErrorCode.ColonExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1419
1632
  }
1633
+ _jsonPath.pop(); // remove processed property name
1420
1634
  return true;
1421
1635
  }
1422
1636
  function parseObject() {
1423
1637
  onObjectBegin();
1424
1638
  scanNext(); // consume open brace
1425
- var needsComma = false;
1426
- while (_scanner.getToken() !== 2 /* CloseBraceToken */ && _scanner.getToken() !== 17 /* EOF */) {
1427
- if (_scanner.getToken() === 5 /* CommaToken */) {
1639
+ let needsComma = false;
1640
+ while (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
1641
+ if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
1428
1642
  if (!needsComma) {
1429
- handleError(4 /* ValueExpected */, [], []);
1643
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1430
1644
  }
1431
1645
  onSeparator(',');
1432
1646
  scanNext(); // consume comma
1433
- if (_scanner.getToken() === 2 /* CloseBraceToken */ && allowTrailingComma) {
1647
+ if (_scanner.getToken() === 2 /* SyntaxKind.CloseBraceToken */ && allowTrailingComma) {
1434
1648
  break;
1435
1649
  }
1436
1650
  }
1437
1651
  else if (needsComma) {
1438
- handleError(6 /* CommaExpected */, [], []);
1652
+ handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
1439
1653
  }
1440
1654
  if (!parseProperty()) {
1441
- handleError(4 /* ValueExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
1655
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], [2 /* SyntaxKind.CloseBraceToken */, 5 /* SyntaxKind.CommaToken */]);
1442
1656
  }
1443
1657
  needsComma = true;
1444
1658
  }
1445
1659
  onObjectEnd();
1446
- if (_scanner.getToken() !== 2 /* CloseBraceToken */) {
1447
- handleError(7 /* CloseBraceExpected */, [2 /* CloseBraceToken */], []);
1660
+ if (_scanner.getToken() !== 2 /* SyntaxKind.CloseBraceToken */) {
1661
+ handleError(7 /* ParseErrorCode.CloseBraceExpected */, [2 /* SyntaxKind.CloseBraceToken */], []);
1448
1662
  }
1449
1663
  else {
1450
1664
  scanNext(); // consume close brace
@@ -1454,29 +1668,40 @@ function visit(text, visitor, options) {
1454
1668
  function parseArray() {
1455
1669
  onArrayBegin();
1456
1670
  scanNext(); // consume open bracket
1457
- var needsComma = false;
1458
- while (_scanner.getToken() !== 4 /* CloseBracketToken */ && _scanner.getToken() !== 17 /* EOF */) {
1459
- if (_scanner.getToken() === 5 /* CommaToken */) {
1671
+ let isFirstElement = true;
1672
+ let needsComma = false;
1673
+ while (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */ && _scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
1674
+ if (_scanner.getToken() === 5 /* SyntaxKind.CommaToken */) {
1460
1675
  if (!needsComma) {
1461
- handleError(4 /* ValueExpected */, [], []);
1676
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1462
1677
  }
1463
1678
  onSeparator(',');
1464
1679
  scanNext(); // consume comma
1465
- if (_scanner.getToken() === 4 /* CloseBracketToken */ && allowTrailingComma) {
1680
+ if (_scanner.getToken() === 4 /* SyntaxKind.CloseBracketToken */ && allowTrailingComma) {
1466
1681
  break;
1467
1682
  }
1468
1683
  }
1469
1684
  else if (needsComma) {
1470
- handleError(6 /* CommaExpected */, [], []);
1685
+ handleError(6 /* ParseErrorCode.CommaExpected */, [], []);
1686
+ }
1687
+ if (isFirstElement) {
1688
+ _jsonPath.push(0);
1689
+ isFirstElement = false;
1690
+ }
1691
+ else {
1692
+ _jsonPath[_jsonPath.length - 1]++;
1471
1693
  }
1472
1694
  if (!parseValue()) {
1473
- handleError(4 /* ValueExpected */, [], [4 /* CloseBracketToken */, 5 /* CommaToken */]);
1695
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], [4 /* SyntaxKind.CloseBracketToken */, 5 /* SyntaxKind.CommaToken */]);
1474
1696
  }
1475
1697
  needsComma = true;
1476
1698
  }
1477
1699
  onArrayEnd();
1478
- if (_scanner.getToken() !== 4 /* CloseBracketToken */) {
1479
- handleError(8 /* CloseBracketExpected */, [4 /* CloseBracketToken */], []);
1700
+ if (!isFirstElement) {
1701
+ _jsonPath.pop(); // remove array index
1702
+ }
1703
+ if (_scanner.getToken() !== 4 /* SyntaxKind.CloseBracketToken */) {
1704
+ handleError(8 /* ParseErrorCode.CloseBracketExpected */, [4 /* SyntaxKind.CloseBracketToken */], []);
1480
1705
  }
1481
1706
  else {
1482
1707
  scanNext(); // consume close bracket
@@ -1485,30 +1710,30 @@ function visit(text, visitor, options) {
1485
1710
  }
1486
1711
  function parseValue() {
1487
1712
  switch (_scanner.getToken()) {
1488
- case 3 /* OpenBracketToken */:
1713
+ case 3 /* SyntaxKind.OpenBracketToken */:
1489
1714
  return parseArray();
1490
- case 1 /* OpenBraceToken */:
1715
+ case 1 /* SyntaxKind.OpenBraceToken */:
1491
1716
  return parseObject();
1492
- case 10 /* StringLiteral */:
1717
+ case 10 /* SyntaxKind.StringLiteral */:
1493
1718
  return parseString(true);
1494
1719
  default:
1495
1720
  return parseLiteral();
1496
1721
  }
1497
1722
  }
1498
1723
  scanNext();
1499
- if (_scanner.getToken() === 17 /* EOF */) {
1724
+ if (_scanner.getToken() === 17 /* SyntaxKind.EOF */) {
1500
1725
  if (options.allowEmptyContent) {
1501
1726
  return true;
1502
1727
  }
1503
- handleError(4 /* ValueExpected */, [], []);
1728
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1504
1729
  return false;
1505
1730
  }
1506
1731
  if (!parseValue()) {
1507
- handleError(4 /* ValueExpected */, [], []);
1732
+ handleError(4 /* ParseErrorCode.ValueExpected */, [], []);
1508
1733
  return false;
1509
1734
  }
1510
- if (_scanner.getToken() !== 17 /* EOF */) {
1511
- handleError(9 /* EndOfFileExpected */, [], []);
1735
+ if (_scanner.getToken() !== 17 /* SyntaxKind.EOF */) {
1736
+ handleError(9 /* ParseErrorCode.EndOfFileExpected */, [], []);
1512
1737
  }
1513
1738
  return true;
1514
1739
  }
@@ -1518,14 +1743,14 @@ function visit(text, visitor, options) {
1518
1743
  * of comments with a replaceCharacter
1519
1744
  */
1520
1745
  function stripComments(text, replaceCh) {
1521
- var _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text), parts = [], kind, offset = 0, pos;
1746
+ let _scanner = (0,_scanner__WEBPACK_IMPORTED_MODULE_0__.createScanner)(text), parts = [], kind, offset = 0, pos;
1522
1747
  do {
1523
1748
  pos = _scanner.getPosition();
1524
1749
  kind = _scanner.scan();
1525
1750
  switch (kind) {
1526
- case 12 /* LineCommentTrivia */:
1527
- case 13 /* BlockCommentTrivia */:
1528
- case 17 /* EOF */:
1751
+ case 12 /* SyntaxKind.LineCommentTrivia */:
1752
+ case 13 /* SyntaxKind.BlockCommentTrivia */:
1753
+ case 17 /* SyntaxKind.EOF */:
1529
1754
  if (offset !== pos) {
1530
1755
  parts.push(text.substring(offset, pos));
1531
1756
  }
@@ -1535,7 +1760,7 @@ function stripComments(text, replaceCh) {
1535
1760
  offset = _scanner.getPosition();
1536
1761
  break;
1537
1762
  }
1538
- } while (kind !== 17 /* EOF */);
1763
+ } while (kind !== 17 /* SyntaxKind.EOF */);
1539
1764
  return parts.join('');
1540
1765
  }
1541
1766
  function getNodeType(value) {
@@ -2602,137 +2827,137 @@ __webpack_require__.r(__webpack_exports__);
2602
2827
  /* harmony import */ var _octokit_request__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
2603
2828
  /* harmony import */ var _octokit_graphql__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(27);
2604
2829
  /* harmony import */ var _octokit_auth_token__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(28);
2830
+ // pkg/dist-src/index.js
2605
2831
 
2606
2832
 
2607
2833
 
2608
2834
 
2609
2835
 
2610
2836
 
2611
- const VERSION = "4.1.0";
2837
+ // pkg/dist-src/version.js
2838
+ var VERSION = "4.2.4";
2612
2839
 
2613
- class Octokit {
2614
- constructor(options = {}) {
2615
- const hook = new before_after_hook__WEBPACK_IMPORTED_MODULE_0__.Collection();
2616
- const requestDefaults = {
2617
- baseUrl: _octokit_request__WEBPACK_IMPORTED_MODULE_1__.request.endpoint.DEFAULTS.baseUrl,
2618
- headers: {},
2619
- request: Object.assign({}, options.request, {
2620
- // @ts-ignore internal usage only, no need to type
2621
- hook: hook.bind(null, "request"),
2622
- }),
2623
- mediaType: {
2624
- previews: [],
2625
- format: "",
2626
- },
2627
- };
2628
- // prepend default user agent with `options.userAgent` if set
2629
- requestDefaults.headers["user-agent"] = [
2630
- options.userAgent,
2631
- `octokit-core.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_2__.getUserAgent)()}`,
2632
- ]
2633
- .filter(Boolean)
2634
- .join(" ");
2635
- if (options.baseUrl) {
2636
- requestDefaults.baseUrl = options.baseUrl;
2637
- }
2638
- if (options.previews) {
2639
- requestDefaults.mediaType.previews = options.previews;
2640
- }
2641
- if (options.timeZone) {
2642
- requestDefaults.headers["time-zone"] = options.timeZone;
2643
- }
2644
- this.request = _octokit_request__WEBPACK_IMPORTED_MODULE_1__.request.defaults(requestDefaults);
2645
- this.graphql = (0,_octokit_graphql__WEBPACK_IMPORTED_MODULE_3__.withCustomRequest)(this.request).defaults(requestDefaults);
2646
- this.log = Object.assign({
2647
- debug: () => { },
2648
- info: () => { },
2649
- warn: console.warn.bind(console),
2650
- error: console.error.bind(console),
2651
- }, options.log);
2652
- this.hook = hook;
2653
- // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
2654
- // is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.
2655
- // (2) If only `options.auth` is set, use the default token authentication strategy.
2656
- // (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
2657
- // TODO: type `options.auth` based on `options.authStrategy`.
2658
- if (!options.authStrategy) {
2659
- if (!options.auth) {
2660
- // (1)
2661
- this.auth = async () => ({
2662
- type: "unauthenticated",
2663
- });
2664
- }
2665
- else {
2666
- // (2)
2667
- const auth = (0,_octokit_auth_token__WEBPACK_IMPORTED_MODULE_4__.createTokenAuth)(options.auth);
2668
- // @ts-ignore ¯\_(ツ)_/¯
2669
- hook.wrap("request", auth.hook);
2670
- this.auth = auth;
2671
- }
2840
+ // pkg/dist-src/index.js
2841
+ var Octokit = class {
2842
+ static defaults(defaults) {
2843
+ const OctokitWithDefaults = class extends this {
2844
+ constructor(...args) {
2845
+ const options = args[0] || {};
2846
+ if (typeof defaults === "function") {
2847
+ super(defaults(options));
2848
+ return;
2672
2849
  }
2673
- else {
2674
- const { authStrategy, ...otherOptions } = options;
2675
- const auth = authStrategy(Object.assign({
2676
- request: this.request,
2677
- log: this.log,
2678
- // we pass the current octokit instance as well as its constructor options
2679
- // to allow for authentication strategies that return a new octokit instance
2680
- // that shares the same internal state as the current one. The original
2681
- // requirement for this was the "event-octokit" authentication strategy
2682
- // of https://github.com/probot/octokit-auth-probot.
2683
- octokit: this,
2684
- octokitOptions: otherOptions,
2685
- }, options.auth));
2686
- // @ts-ignore ¯\_(ツ)_/¯
2687
- hook.wrap("request", auth.hook);
2688
- this.auth = auth;
2689
- }
2690
- // apply plugins
2691
- // https://stackoverflow.com/a/16345172
2692
- const classConstructor = this.constructor;
2693
- classConstructor.plugins.forEach((plugin) => {
2694
- Object.assign(this, plugin(this, options));
2850
+ super(
2851
+ Object.assign(
2852
+ {},
2853
+ defaults,
2854
+ options,
2855
+ options.userAgent && defaults.userAgent ? {
2856
+ userAgent: `${options.userAgent} ${defaults.userAgent}`
2857
+ } : null
2858
+ )
2859
+ );
2860
+ }
2861
+ };
2862
+ return OctokitWithDefaults;
2863
+ }
2864
+ /**
2865
+ * Attach a plugin (or many) to your Octokit instance.
2866
+ *
2867
+ * @example
2868
+ * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
2869
+ */
2870
+ static plugin(...newPlugins) {
2871
+ var _a;
2872
+ const currentPlugins = this.plugins;
2873
+ const NewOctokit = (_a = class extends this {
2874
+ }, _a.plugins = currentPlugins.concat(
2875
+ newPlugins.filter((plugin) => !currentPlugins.includes(plugin))
2876
+ ), _a);
2877
+ return NewOctokit;
2878
+ }
2879
+ constructor(options = {}) {
2880
+ const hook = new before_after_hook__WEBPACK_IMPORTED_MODULE_0__.Collection();
2881
+ const requestDefaults = {
2882
+ baseUrl: _octokit_request__WEBPACK_IMPORTED_MODULE_1__.request.endpoint.DEFAULTS.baseUrl,
2883
+ headers: {},
2884
+ request: Object.assign({}, options.request, {
2885
+ // @ts-ignore internal usage only, no need to type
2886
+ hook: hook.bind(null, "request")
2887
+ }),
2888
+ mediaType: {
2889
+ previews: [],
2890
+ format: ""
2891
+ }
2892
+ };
2893
+ requestDefaults.headers["user-agent"] = [
2894
+ options.userAgent,
2895
+ `octokit-core.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_2__.getUserAgent)()}`
2896
+ ].filter(Boolean).join(" ");
2897
+ if (options.baseUrl) {
2898
+ requestDefaults.baseUrl = options.baseUrl;
2899
+ }
2900
+ if (options.previews) {
2901
+ requestDefaults.mediaType.previews = options.previews;
2902
+ }
2903
+ if (options.timeZone) {
2904
+ requestDefaults.headers["time-zone"] = options.timeZone;
2905
+ }
2906
+ this.request = _octokit_request__WEBPACK_IMPORTED_MODULE_1__.request.defaults(requestDefaults);
2907
+ this.graphql = (0,_octokit_graphql__WEBPACK_IMPORTED_MODULE_3__.withCustomRequest)(this.request).defaults(requestDefaults);
2908
+ this.log = Object.assign(
2909
+ {
2910
+ debug: () => {
2911
+ },
2912
+ info: () => {
2913
+ },
2914
+ warn: console.warn.bind(console),
2915
+ error: console.error.bind(console)
2916
+ },
2917
+ options.log
2918
+ );
2919
+ this.hook = hook;
2920
+ if (!options.authStrategy) {
2921
+ if (!options.auth) {
2922
+ this.auth = async () => ({
2923
+ type: "unauthenticated"
2695
2924
  });
2696
- }
2697
- static defaults(defaults) {
2698
- const OctokitWithDefaults = class extends this {
2699
- constructor(...args) {
2700
- const options = args[0] || {};
2701
- if (typeof defaults === "function") {
2702
- super(defaults(options));
2703
- return;
2704
- }
2705
- super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent
2706
- ? {
2707
- userAgent: `${options.userAgent} ${defaults.userAgent}`,
2708
- }
2709
- : null));
2710
- }
2711
- };
2712
- return OctokitWithDefaults;
2713
- }
2714
- /**
2715
- * Attach a plugin (or many) to your Octokit instance.
2716
- *
2717
- * @example
2718
- * const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
2719
- */
2720
- static plugin(...newPlugins) {
2721
- var _a;
2722
- const currentPlugins = this.plugins;
2723
- const NewOctokit = (_a = class extends this {
2724
- },
2725
- _a.plugins = currentPlugins.concat(newPlugins.filter((plugin) => !currentPlugins.includes(plugin))),
2726
- _a);
2727
- return NewOctokit;
2728
- }
2729
- }
2925
+ } else {
2926
+ const auth = (0,_octokit_auth_token__WEBPACK_IMPORTED_MODULE_4__.createTokenAuth)(options.auth);
2927
+ hook.wrap("request", auth.hook);
2928
+ this.auth = auth;
2929
+ }
2930
+ } else {
2931
+ const { authStrategy, ...otherOptions } = options;
2932
+ const auth = authStrategy(
2933
+ Object.assign(
2934
+ {
2935
+ request: this.request,
2936
+ log: this.log,
2937
+ // we pass the current octokit instance as well as its constructor options
2938
+ // to allow for authentication strategies that return a new octokit instance
2939
+ // that shares the same internal state as the current one. The original
2940
+ // requirement for this was the "event-octokit" authentication strategy
2941
+ // of https://github.com/probot/octokit-auth-probot.
2942
+ octokit: this,
2943
+ octokitOptions: otherOptions
2944
+ },
2945
+ options.auth
2946
+ )
2947
+ );
2948
+ hook.wrap("request", auth.hook);
2949
+ this.auth = auth;
2950
+ }
2951
+ const classConstructor = this.constructor;
2952
+ classConstructor.plugins.forEach((plugin) => {
2953
+ Object.assign(this, plugin(this, options));
2954
+ });
2955
+ }
2956
+ };
2730
2957
  Octokit.VERSION = VERSION;
2731
2958
  Octokit.plugins = [];
2732
2959
 
2733
2960
 
2734
- //# sourceMappingURL=index.js.map
2735
-
2736
2961
 
2737
2962
  /***/ }),
2738
2963
  /* 14 */
@@ -2926,169 +3151,177 @@ __webpack_require__.r(__webpack_exports__);
2926
3151
  /* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(20);
2927
3152
  /* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_1__);
2928
3153
  /* harmony import */ var _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(21);
3154
+ // pkg/dist-src/index.js
3155
+
2929
3156
 
2930
3157
 
3158
+ // pkg/dist-src/version.js
3159
+ var VERSION = "6.2.8";
2931
3160
 
3161
+ // pkg/dist-src/fetch-wrapper.js
2932
3162
 
2933
3163
 
2934
3164
 
2935
- const VERSION = "6.2.2";
2936
3165
 
3166
+ // pkg/dist-src/get-buffer-response.js
2937
3167
  function getBufferResponse(response) {
2938
- return response.arrayBuffer();
3168
+ return response.arrayBuffer();
2939
3169
  }
2940
3170
 
3171
+ // pkg/dist-src/fetch-wrapper.js
2941
3172
  function fetchWrapper(requestOptions) {
2942
- const log = requestOptions.request && requestOptions.request.log
2943
- ? requestOptions.request.log
2944
- : console;
2945
- if ((0,is_plain_object__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(requestOptions.body) ||
2946
- Array.isArray(requestOptions.body)) {
2947
- requestOptions.body = JSON.stringify(requestOptions.body);
2948
- }
2949
- let headers = {};
2950
- let status;
2951
- let url;
2952
- const fetch = (requestOptions.request && requestOptions.request.fetch) ||
2953
- globalThis.fetch ||
2954
- /* istanbul ignore next */ (node_fetch__WEBPACK_IMPORTED_MODULE_1___default());
2955
- return fetch(requestOptions.url, Object.assign({
3173
+ const log = requestOptions.request && requestOptions.request.log ? requestOptions.request.log : console;
3174
+ if ((0,is_plain_object__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(requestOptions.body) || Array.isArray(requestOptions.body)) {
3175
+ requestOptions.body = JSON.stringify(requestOptions.body);
3176
+ }
3177
+ let headers = {};
3178
+ let status;
3179
+ let url;
3180
+ const fetch = requestOptions.request && requestOptions.request.fetch || globalThis.fetch || /* istanbul ignore next */
3181
+ (node_fetch__WEBPACK_IMPORTED_MODULE_1___default());
3182
+ return fetch(
3183
+ requestOptions.url,
3184
+ Object.assign(
3185
+ {
2956
3186
  method: requestOptions.method,
2957
3187
  body: requestOptions.body,
2958
3188
  headers: requestOptions.headers,
2959
3189
  redirect: requestOptions.redirect,
2960
- },
2961
- // `requestOptions.request.agent` type is incompatible
2962
- // see https://github.com/octokit/types.ts/pull/264
2963
- requestOptions.request))
2964
- .then(async (response) => {
2965
- url = response.url;
2966
- status = response.status;
2967
- for (const keyAndValue of response.headers) {
2968
- headers[keyAndValue[0]] = keyAndValue[1];
2969
- }
2970
- if ("deprecation" in headers) {
2971
- const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/);
2972
- const deprecationLink = matches && matches.pop();
2973
- log.warn(`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`);
2974
- }
2975
- if (status === 204 || status === 205) {
2976
- return;
2977
- }
2978
- // GitHub API returns 200 for HEAD requests
2979
- if (requestOptions.method === "HEAD") {
2980
- if (status < 400) {
2981
- return;
2982
- }
2983
- throw new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError(response.statusText, status, {
2984
- response: {
2985
- url,
2986
- status,
2987
- headers,
2988
- data: undefined,
2989
- },
2990
- request: requestOptions,
2991
- });
2992
- }
2993
- if (status === 304) {
2994
- throw new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError("Not modified", status, {
2995
- response: {
2996
- url,
2997
- status,
2998
- headers,
2999
- data: await getResponseData(response),
3000
- },
3001
- request: requestOptions,
3002
- });
3003
- }
3004
- if (status >= 400) {
3005
- const data = await getResponseData(response);
3006
- const error = new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError(toErrorMessage(data), status, {
3007
- response: {
3008
- url,
3009
- status,
3010
- headers,
3011
- data,
3012
- },
3013
- request: requestOptions,
3014
- });
3015
- throw error;
3016
- }
3017
- return getResponseData(response);
3018
- })
3019
- .then((data) => {
3020
- return {
3021
- status,
3022
- url,
3023
- headers,
3024
- data,
3025
- };
3026
- })
3027
- .catch((error) => {
3028
- if (error instanceof _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError)
3029
- throw error;
3030
- else if (error.name === "AbortError")
3031
- throw error;
3032
- throw new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError(error.message, 500, {
3033
- request: requestOptions,
3034
- });
3190
+ // duplex must be set if request.body is ReadableStream or Async Iterables.
3191
+ // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex.
3192
+ ...requestOptions.body && { duplex: "half" }
3193
+ },
3194
+ // `requestOptions.request.agent` type is incompatible
3195
+ // see https://github.com/octokit/types.ts/pull/264
3196
+ requestOptions.request
3197
+ )
3198
+ ).then(async (response) => {
3199
+ url = response.url;
3200
+ status = response.status;
3201
+ for (const keyAndValue of response.headers) {
3202
+ headers[keyAndValue[0]] = keyAndValue[1];
3203
+ }
3204
+ if ("deprecation" in headers) {
3205
+ const matches = headers.link && headers.link.match(/<([^>]+)>; rel="deprecation"/);
3206
+ const deprecationLink = matches && matches.pop();
3207
+ log.warn(
3208
+ `[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${headers.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`
3209
+ );
3210
+ }
3211
+ if (status === 204 || status === 205) {
3212
+ return;
3213
+ }
3214
+ if (requestOptions.method === "HEAD") {
3215
+ if (status < 400) {
3216
+ return;
3217
+ }
3218
+ throw new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError(response.statusText, status, {
3219
+ response: {
3220
+ url,
3221
+ status,
3222
+ headers,
3223
+ data: void 0
3224
+ },
3225
+ request: requestOptions
3226
+ });
3227
+ }
3228
+ if (status === 304) {
3229
+ throw new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError("Not modified", status, {
3230
+ response: {
3231
+ url,
3232
+ status,
3233
+ headers,
3234
+ data: await getResponseData(response)
3235
+ },
3236
+ request: requestOptions
3237
+ });
3238
+ }
3239
+ if (status >= 400) {
3240
+ const data = await getResponseData(response);
3241
+ const error = new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError(toErrorMessage(data), status, {
3242
+ response: {
3243
+ url,
3244
+ status,
3245
+ headers,
3246
+ data
3247
+ },
3248
+ request: requestOptions
3249
+ });
3250
+ throw error;
3251
+ }
3252
+ return getResponseData(response);
3253
+ }).then((data) => {
3254
+ return {
3255
+ status,
3256
+ url,
3257
+ headers,
3258
+ data
3259
+ };
3260
+ }).catch((error) => {
3261
+ if (error instanceof _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError)
3262
+ throw error;
3263
+ else if (error.name === "AbortError")
3264
+ throw error;
3265
+ throw new _octokit_request_error__WEBPACK_IMPORTED_MODULE_2__.RequestError(error.message, 500, {
3266
+ request: requestOptions
3035
3267
  });
3268
+ });
3036
3269
  }
3037
3270
  async function getResponseData(response) {
3038
- const contentType = response.headers.get("content-type");
3039
- if (/application\/json/.test(contentType)) {
3040
- return response.json();
3041
- }
3042
- if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
3043
- return response.text();
3044
- }
3045
- return getBufferResponse(response);
3271
+ const contentType = response.headers.get("content-type");
3272
+ if (/application\/json/.test(contentType)) {
3273
+ return response.json();
3274
+ }
3275
+ if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
3276
+ return response.text();
3277
+ }
3278
+ return getBufferResponse(response);
3046
3279
  }
3047
3280
  function toErrorMessage(data) {
3048
- if (typeof data === "string")
3049
- return data;
3050
- // istanbul ignore else - just in case
3051
- if ("message" in data) {
3052
- if (Array.isArray(data.errors)) {
3053
- return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`;
3054
- }
3055
- return data.message;
3281
+ if (typeof data === "string")
3282
+ return data;
3283
+ if ("message" in data) {
3284
+ if (Array.isArray(data.errors)) {
3285
+ return `${data.message}: ${data.errors.map(JSON.stringify).join(", ")}`;
3056
3286
  }
3057
- // istanbul ignore next - just in case
3058
- return `Unknown error: ${JSON.stringify(data)}`;
3287
+ return data.message;
3288
+ }
3289
+ return `Unknown error: ${JSON.stringify(data)}`;
3059
3290
  }
3060
3291
 
3292
+ // pkg/dist-src/with-defaults.js
3061
3293
  function withDefaults(oldEndpoint, newDefaults) {
3062
- const endpoint = oldEndpoint.defaults(newDefaults);
3063
- const newApi = function (route, parameters) {
3064
- const endpointOptions = endpoint.merge(route, parameters);
3065
- if (!endpointOptions.request || !endpointOptions.request.hook) {
3066
- return fetchWrapper(endpoint.parse(endpointOptions));
3067
- }
3068
- const request = (route, parameters) => {
3069
- return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));
3070
- };
3071
- Object.assign(request, {
3072
- endpoint,
3073
- defaults: withDefaults.bind(null, endpoint),
3074
- });
3075
- return endpointOptions.request.hook(request, endpointOptions);
3294
+ const endpoint2 = oldEndpoint.defaults(newDefaults);
3295
+ const newApi = function(route, parameters) {
3296
+ const endpointOptions = endpoint2.merge(route, parameters);
3297
+ if (!endpointOptions.request || !endpointOptions.request.hook) {
3298
+ return fetchWrapper(endpoint2.parse(endpointOptions));
3299
+ }
3300
+ const request2 = (route2, parameters2) => {
3301
+ return fetchWrapper(
3302
+ endpoint2.parse(endpoint2.merge(route2, parameters2))
3303
+ );
3076
3304
  };
3077
- return Object.assign(newApi, {
3078
- endpoint,
3079
- defaults: withDefaults.bind(null, endpoint),
3305
+ Object.assign(request2, {
3306
+ endpoint: endpoint2,
3307
+ defaults: withDefaults.bind(null, endpoint2)
3080
3308
  });
3309
+ return endpointOptions.request.hook(request2, endpointOptions);
3310
+ };
3311
+ return Object.assign(newApi, {
3312
+ endpoint: endpoint2,
3313
+ defaults: withDefaults.bind(null, endpoint2)
3314
+ });
3081
3315
  }
3082
3316
 
3083
- const request = withDefaults(_octokit_endpoint__WEBPACK_IMPORTED_MODULE_3__.endpoint, {
3084
- headers: {
3085
- "user-agent": `octokit-request.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_4__.getUserAgent)()}`,
3086
- },
3317
+ // pkg/dist-src/index.js
3318
+ var request = withDefaults(_octokit_endpoint__WEBPACK_IMPORTED_MODULE_3__.endpoint, {
3319
+ headers: {
3320
+ "user-agent": `octokit-request.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_4__.getUserAgent)()}`
3321
+ }
3087
3322
  });
3088
3323
 
3089
3324
 
3090
- //# sourceMappingURL=index.js.map
3091
-
3092
3325
 
3093
3326
  /***/ }),
3094
3327
  /* 19 */
@@ -3159,7 +3392,7 @@ module.exports = exports = globalObject.fetch;
3159
3392
 
3160
3393
  // Needed for TypeScript and Webpack.
3161
3394
  if (globalObject.fetch) {
3162
- exports["default"] = globalObject.fetch.bind(__webpack_require__.g);
3395
+ exports["default"] = globalObject.fetch.bind(globalObject);
3163
3396
  }
3164
3397
 
3165
3398
  exports.Headers = globalObject.Headers;
@@ -3365,384 +3598,332 @@ __webpack_require__.r(__webpack_exports__);
3365
3598
  /* harmony export */ });
3366
3599
  /* harmony import */ var is_plain_object__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
3367
3600
  /* harmony import */ var universal_user_agent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(26);
3368
-
3369
-
3370
-
3601
+ // pkg/dist-src/util/lowercase-keys.js
3371
3602
  function lowercaseKeys(object) {
3372
- if (!object) {
3373
- return {};
3374
- }
3375
- return Object.keys(object).reduce((newObj, key) => {
3376
- newObj[key.toLowerCase()] = object[key];
3377
- return newObj;
3378
- }, {});
3603
+ if (!object) {
3604
+ return {};
3605
+ }
3606
+ return Object.keys(object).reduce((newObj, key) => {
3607
+ newObj[key.toLowerCase()] = object[key];
3608
+ return newObj;
3609
+ }, {});
3379
3610
  }
3380
3611
 
3612
+ // pkg/dist-src/util/merge-deep.js
3613
+
3381
3614
  function mergeDeep(defaults, options) {
3382
- const result = Object.assign({}, defaults);
3383
- Object.keys(options).forEach((key) => {
3384
- if ((0,is_plain_object__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(options[key])) {
3385
- if (!(key in defaults))
3386
- Object.assign(result, { [key]: options[key] });
3387
- else
3388
- result[key] = mergeDeep(defaults[key], options[key]);
3389
- }
3390
- else {
3391
- Object.assign(result, { [key]: options[key] });
3392
- }
3393
- });
3394
- return result;
3615
+ const result = Object.assign({}, defaults);
3616
+ Object.keys(options).forEach((key) => {
3617
+ if ((0,is_plain_object__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(options[key])) {
3618
+ if (!(key in defaults))
3619
+ Object.assign(result, { [key]: options[key] });
3620
+ else
3621
+ result[key] = mergeDeep(defaults[key], options[key]);
3622
+ } else {
3623
+ Object.assign(result, { [key]: options[key] });
3624
+ }
3625
+ });
3626
+ return result;
3395
3627
  }
3396
3628
 
3629
+ // pkg/dist-src/util/remove-undefined-properties.js
3397
3630
  function removeUndefinedProperties(obj) {
3398
- for (const key in obj) {
3399
- if (obj[key] === undefined) {
3400
- delete obj[key];
3401
- }
3631
+ for (const key in obj) {
3632
+ if (obj[key] === void 0) {
3633
+ delete obj[key];
3402
3634
  }
3403
- return obj;
3635
+ }
3636
+ return obj;
3404
3637
  }
3405
3638
 
3639
+ // pkg/dist-src/merge.js
3406
3640
  function merge(defaults, route, options) {
3407
- if (typeof route === "string") {
3408
- let [method, url] = route.split(" ");
3409
- options = Object.assign(url ? { method, url } : { url: method }, options);
3410
- }
3411
- else {
3412
- options = Object.assign({}, route);
3413
- }
3414
- // lowercase header names before merging with defaults to avoid duplicates
3415
- options.headers = lowercaseKeys(options.headers);
3416
- // remove properties with undefined values before merging
3417
- removeUndefinedProperties(options);
3418
- removeUndefinedProperties(options.headers);
3419
- const mergedOptions = mergeDeep(defaults || {}, options);
3420
- // mediaType.previews arrays are merged, instead of overwritten
3421
- if (defaults && defaults.mediaType.previews.length) {
3422
- mergedOptions.mediaType.previews = defaults.mediaType.previews
3423
- .filter((preview) => !mergedOptions.mediaType.previews.includes(preview))
3424
- .concat(mergedOptions.mediaType.previews);
3425
- }
3426
- mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, ""));
3427
- return mergedOptions;
3641
+ if (typeof route === "string") {
3642
+ let [method, url] = route.split(" ");
3643
+ options = Object.assign(url ? { method, url } : { url: method }, options);
3644
+ } else {
3645
+ options = Object.assign({}, route);
3646
+ }
3647
+ options.headers = lowercaseKeys(options.headers);
3648
+ removeUndefinedProperties(options);
3649
+ removeUndefinedProperties(options.headers);
3650
+ const mergedOptions = mergeDeep(defaults || {}, options);
3651
+ if (defaults && defaults.mediaType.previews.length) {
3652
+ mergedOptions.mediaType.previews = defaults.mediaType.previews.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);
3653
+ }
3654
+ mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(
3655
+ (preview) => preview.replace(/-preview/, "")
3656
+ );
3657
+ return mergedOptions;
3428
3658
  }
3429
3659
 
3660
+ // pkg/dist-src/util/add-query-parameters.js
3430
3661
  function addQueryParameters(url, parameters) {
3431
- const separator = /\?/.test(url) ? "&" : "?";
3432
- const names = Object.keys(parameters);
3433
- if (names.length === 0) {
3434
- return url;
3435
- }
3436
- return (url +
3437
- separator +
3438
- names
3439
- .map((name) => {
3440
- if (name === "q") {
3441
- return ("q=" + parameters.q.split("+").map(encodeURIComponent).join("+"));
3442
- }
3443
- return `${name}=${encodeURIComponent(parameters[name])}`;
3444
- })
3445
- .join("&"));
3662
+ const separator = /\?/.test(url) ? "&" : "?";
3663
+ const names = Object.keys(parameters);
3664
+ if (names.length === 0) {
3665
+ return url;
3666
+ }
3667
+ return url + separator + names.map((name) => {
3668
+ if (name === "q") {
3669
+ return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
3670
+ }
3671
+ return `${name}=${encodeURIComponent(parameters[name])}`;
3672
+ }).join("&");
3446
3673
  }
3447
3674
 
3448
- const urlVariableRegex = /\{[^}]+\}/g;
3675
+ // pkg/dist-src/util/extract-url-variable-names.js
3676
+ var urlVariableRegex = /\{[^}]+\}/g;
3449
3677
  function removeNonChars(variableName) {
3450
- return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
3678
+ return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
3451
3679
  }
3452
3680
  function extractUrlVariableNames(url) {
3453
- const matches = url.match(urlVariableRegex);
3454
- if (!matches) {
3455
- return [];
3456
- }
3457
- return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
3681
+ const matches = url.match(urlVariableRegex);
3682
+ if (!matches) {
3683
+ return [];
3684
+ }
3685
+ return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
3458
3686
  }
3459
3687
 
3688
+ // pkg/dist-src/util/omit.js
3460
3689
  function omit(object, keysToOmit) {
3461
- return Object.keys(object)
3462
- .filter((option) => !keysToOmit.includes(option))
3463
- .reduce((obj, key) => {
3464
- obj[key] = object[key];
3465
- return obj;
3466
- }, {});
3690
+ return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => {
3691
+ obj[key] = object[key];
3692
+ return obj;
3693
+ }, {});
3467
3694
  }
3468
3695
 
3469
- // Based on https://github.com/bramstein/url-template, licensed under BSD
3470
- // TODO: create separate package.
3471
- //
3472
- // Copyright (c) 2012-2014, Bram Stein
3473
- // All rights reserved.
3474
- // Redistribution and use in source and binary forms, with or without
3475
- // modification, are permitted provided that the following conditions
3476
- // are met:
3477
- // 1. Redistributions of source code must retain the above copyright
3478
- // notice, this list of conditions and the following disclaimer.
3479
- // 2. Redistributions in binary form must reproduce the above copyright
3480
- // notice, this list of conditions and the following disclaimer in the
3481
- // documentation and/or other materials provided with the distribution.
3482
- // 3. The name of the author may not be used to endorse or promote products
3483
- // derived from this software without specific prior written permission.
3484
- // THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
3485
- // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
3486
- // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
3487
- // EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
3488
- // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
3489
- // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3490
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
3491
- // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
3492
- // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
3493
- // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3494
- /* istanbul ignore file */
3696
+ // pkg/dist-src/util/url-template.js
3495
3697
  function encodeReserved(str) {
3496
- return str
3497
- .split(/(%[0-9A-Fa-f]{2})/g)
3498
- .map(function (part) {
3499
- if (!/%[0-9A-Fa-f]/.test(part)) {
3500
- part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
3501
- }
3502
- return part;
3503
- })
3504
- .join("");
3698
+ return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) {
3699
+ if (!/%[0-9A-Fa-f]/.test(part)) {
3700
+ part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
3701
+ }
3702
+ return part;
3703
+ }).join("");
3505
3704
  }
3506
3705
  function encodeUnreserved(str) {
3507
- return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
3508
- return "%" + c.charCodeAt(0).toString(16).toUpperCase();
3509
- });
3706
+ return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
3707
+ return "%" + c.charCodeAt(0).toString(16).toUpperCase();
3708
+ });
3510
3709
  }
3511
3710
  function encodeValue(operator, value, key) {
3512
- value =
3513
- operator === "+" || operator === "#"
3514
- ? encodeReserved(value)
3515
- : encodeUnreserved(value);
3516
- if (key) {
3517
- return encodeUnreserved(key) + "=" + value;
3518
- }
3519
- else {
3520
- return value;
3521
- }
3711
+ value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
3712
+ if (key) {
3713
+ return encodeUnreserved(key) + "=" + value;
3714
+ } else {
3715
+ return value;
3716
+ }
3522
3717
  }
3523
3718
  function isDefined(value) {
3524
- return value !== undefined && value !== null;
3719
+ return value !== void 0 && value !== null;
3525
3720
  }
3526
3721
  function isKeyOperator(operator) {
3527
- return operator === ";" || operator === "&" || operator === "?";
3722
+ return operator === ";" || operator === "&" || operator === "?";
3528
3723
  }
3529
3724
  function getValues(context, operator, key, modifier) {
3530
- var value = context[key], result = [];
3531
- if (isDefined(value) && value !== "") {
3532
- if (typeof value === "string" ||
3533
- typeof value === "number" ||
3534
- typeof value === "boolean") {
3535
- value = value.toString();
3536
- if (modifier && modifier !== "*") {
3537
- value = value.substring(0, parseInt(modifier, 10));
3538
- }
3539
- result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
3540
- }
3541
- else {
3542
- if (modifier === "*") {
3543
- if (Array.isArray(value)) {
3544
- value.filter(isDefined).forEach(function (value) {
3545
- result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
3546
- });
3547
- }
3548
- else {
3549
- Object.keys(value).forEach(function (k) {
3550
- if (isDefined(value[k])) {
3551
- result.push(encodeValue(operator, value[k], k));
3552
- }
3553
- });
3554
- }
3555
- }
3556
- else {
3557
- const tmp = [];
3558
- if (Array.isArray(value)) {
3559
- value.filter(isDefined).forEach(function (value) {
3560
- tmp.push(encodeValue(operator, value));
3561
- });
3562
- }
3563
- else {
3564
- Object.keys(value).forEach(function (k) {
3565
- if (isDefined(value[k])) {
3566
- tmp.push(encodeUnreserved(k));
3567
- tmp.push(encodeValue(operator, value[k].toString()));
3568
- }
3569
- });
3570
- }
3571
- if (isKeyOperator(operator)) {
3572
- result.push(encodeUnreserved(key) + "=" + tmp.join(","));
3573
- }
3574
- else if (tmp.length !== 0) {
3575
- result.push(tmp.join(","));
3576
- }
3725
+ var value = context[key], result = [];
3726
+ if (isDefined(value) && value !== "") {
3727
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
3728
+ value = value.toString();
3729
+ if (modifier && modifier !== "*") {
3730
+ value = value.substring(0, parseInt(modifier, 10));
3731
+ }
3732
+ result.push(
3733
+ encodeValue(operator, value, isKeyOperator(operator) ? key : "")
3734
+ );
3735
+ } else {
3736
+ if (modifier === "*") {
3737
+ if (Array.isArray(value)) {
3738
+ value.filter(isDefined).forEach(function(value2) {
3739
+ result.push(
3740
+ encodeValue(operator, value2, isKeyOperator(operator) ? key : "")
3741
+ );
3742
+ });
3743
+ } else {
3744
+ Object.keys(value).forEach(function(k) {
3745
+ if (isDefined(value[k])) {
3746
+ result.push(encodeValue(operator, value[k], k));
3577
3747
  }
3748
+ });
3578
3749
  }
3579
- }
3580
- else {
3581
- if (operator === ";") {
3582
- if (isDefined(value)) {
3583
- result.push(encodeUnreserved(key));
3750
+ } else {
3751
+ const tmp = [];
3752
+ if (Array.isArray(value)) {
3753
+ value.filter(isDefined).forEach(function(value2) {
3754
+ tmp.push(encodeValue(operator, value2));
3755
+ });
3756
+ } else {
3757
+ Object.keys(value).forEach(function(k) {
3758
+ if (isDefined(value[k])) {
3759
+ tmp.push(encodeUnreserved(k));
3760
+ tmp.push(encodeValue(operator, value[k].toString()));
3584
3761
  }
3762
+ });
3585
3763
  }
3586
- else if (value === "" && (operator === "&" || operator === "?")) {
3587
- result.push(encodeUnreserved(key) + "=");
3588
- }
3589
- else if (value === "") {
3590
- result.push("");
3764
+ if (isKeyOperator(operator)) {
3765
+ result.push(encodeUnreserved(key) + "=" + tmp.join(","));
3766
+ } else if (tmp.length !== 0) {
3767
+ result.push(tmp.join(","));
3591
3768
  }
3769
+ }
3592
3770
  }
3593
- return result;
3771
+ } else {
3772
+ if (operator === ";") {
3773
+ if (isDefined(value)) {
3774
+ result.push(encodeUnreserved(key));
3775
+ }
3776
+ } else if (value === "" && (operator === "&" || operator === "?")) {
3777
+ result.push(encodeUnreserved(key) + "=");
3778
+ } else if (value === "") {
3779
+ result.push("");
3780
+ }
3781
+ }
3782
+ return result;
3594
3783
  }
3595
3784
  function parseUrl(template) {
3596
- return {
3597
- expand: expand.bind(null, template),
3598
- };
3785
+ return {
3786
+ expand: expand.bind(null, template)
3787
+ };
3599
3788
  }
3600
3789
  function expand(template, context) {
3601
- var operators = ["+", "#", ".", "/", ";", "?", "&"];
3602
- return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
3603
- if (expression) {
3604
- let operator = "";
3605
- const values = [];
3606
- if (operators.indexOf(expression.charAt(0)) !== -1) {
3607
- operator = expression.charAt(0);
3608
- expression = expression.substr(1);
3609
- }
3610
- expression.split(/,/g).forEach(function (variable) {
3611
- var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
3612
- values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
3613
- });
3614
- if (operator && operator !== "+") {
3615
- var separator = ",";
3616
- if (operator === "?") {
3617
- separator = "&";
3618
- }
3619
- else if (operator !== "#") {
3620
- separator = operator;
3621
- }
3622
- return (values.length !== 0 ? operator : "") + values.join(separator);
3623
- }
3624
- else {
3625
- return values.join(",");
3626
- }
3627
- }
3628
- else {
3629
- return encodeReserved(literal);
3790
+ var operators = ["+", "#", ".", "/", ";", "?", "&"];
3791
+ return template.replace(
3792
+ /\{([^\{\}]+)\}|([^\{\}]+)/g,
3793
+ function(_, expression, literal) {
3794
+ if (expression) {
3795
+ let operator = "";
3796
+ const values = [];
3797
+ if (operators.indexOf(expression.charAt(0)) !== -1) {
3798
+ operator = expression.charAt(0);
3799
+ expression = expression.substr(1);
3800
+ }
3801
+ expression.split(/,/g).forEach(function(variable) {
3802
+ var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
3803
+ values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
3804
+ });
3805
+ if (operator && operator !== "+") {
3806
+ var separator = ",";
3807
+ if (operator === "?") {
3808
+ separator = "&";
3809
+ } else if (operator !== "#") {
3810
+ separator = operator;
3811
+ }
3812
+ return (values.length !== 0 ? operator : "") + values.join(separator);
3813
+ } else {
3814
+ return values.join(",");
3630
3815
  }
3631
- });
3816
+ } else {
3817
+ return encodeReserved(literal);
3818
+ }
3819
+ }
3820
+ );
3632
3821
  }
3633
3822
 
3823
+ // pkg/dist-src/parse.js
3634
3824
  function parse(options) {
3635
- // https://fetch.spec.whatwg.org/#methods
3636
- let method = options.method.toUpperCase();
3637
- // replace :varname with {varname} to make it RFC 6570 compatible
3638
- let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
3639
- let headers = Object.assign({}, options.headers);
3640
- let body;
3641
- let parameters = omit(options, [
3642
- "method",
3643
- "baseUrl",
3644
- "url",
3645
- "headers",
3646
- "request",
3647
- "mediaType",
3648
- ]);
3649
- // extract variable names from URL to calculate remaining variables later
3650
- const urlVariableNames = extractUrlVariableNames(url);
3651
- url = parseUrl(url).expand(parameters);
3652
- if (!/^http/.test(url)) {
3653
- url = options.baseUrl + url;
3654
- }
3655
- const omittedParameters = Object.keys(options)
3656
- .filter((option) => urlVariableNames.includes(option))
3657
- .concat("baseUrl");
3658
- const remainingParameters = omit(parameters, omittedParameters);
3659
- const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
3660
- if (!isBinaryRequest) {
3661
- if (options.mediaType.format) {
3662
- // e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw
3663
- headers.accept = headers.accept
3664
- .split(/,/)
3665
- .map((preview) => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`))
3666
- .join(",");
3667
- }
3668
- if (options.mediaType.previews.length) {
3669
- const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
3670
- headers.accept = previewsFromAcceptHeader
3671
- .concat(options.mediaType.previews)
3672
- .map((preview) => {
3673
- const format = options.mediaType.format
3674
- ? `.${options.mediaType.format}`
3675
- : "+json";
3676
- return `application/vnd.github.${preview}-preview${format}`;
3677
- })
3678
- .join(",");
3679
- }
3680
- }
3681
- // for GET/HEAD requests, set URL query parameters from remaining parameters
3682
- // for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters
3683
- if (["GET", "HEAD"].includes(method)) {
3684
- url = addQueryParameters(url, remainingParameters);
3685
- }
3686
- else {
3687
- if ("data" in remainingParameters) {
3688
- body = remainingParameters.data;
3689
- }
3690
- else {
3691
- if (Object.keys(remainingParameters).length) {
3692
- body = remainingParameters;
3693
- }
3694
- }
3695
- }
3696
- // default content-type for JSON if body is set
3697
- if (!headers["content-type"] && typeof body !== "undefined") {
3698
- headers["content-type"] = "application/json; charset=utf-8";
3825
+ let method = options.method.toUpperCase();
3826
+ let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
3827
+ let headers = Object.assign({}, options.headers);
3828
+ let body;
3829
+ let parameters = omit(options, [
3830
+ "method",
3831
+ "baseUrl",
3832
+ "url",
3833
+ "headers",
3834
+ "request",
3835
+ "mediaType"
3836
+ ]);
3837
+ const urlVariableNames = extractUrlVariableNames(url);
3838
+ url = parseUrl(url).expand(parameters);
3839
+ if (!/^http/.test(url)) {
3840
+ url = options.baseUrl + url;
3841
+ }
3842
+ const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl");
3843
+ const remainingParameters = omit(parameters, omittedParameters);
3844
+ const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
3845
+ if (!isBinaryRequest) {
3846
+ if (options.mediaType.format) {
3847
+ headers.accept = headers.accept.split(/,/).map(
3848
+ (preview) => preview.replace(
3849
+ /application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/,
3850
+ `application/vnd$1$2.${options.mediaType.format}`
3851
+ )
3852
+ ).join(",");
3853
+ }
3854
+ if (options.mediaType.previews.length) {
3855
+ const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
3856
+ headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => {
3857
+ const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
3858
+ return `application/vnd.github.${preview}-preview${format}`;
3859
+ }).join(",");
3699
3860
  }
3700
- // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
3701
- // fetch does not allow to set `content-length` header, but we can set body to an empty string
3702
- if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
3703
- body = "";
3861
+ }
3862
+ if (["GET", "HEAD"].includes(method)) {
3863
+ url = addQueryParameters(url, remainingParameters);
3864
+ } else {
3865
+ if ("data" in remainingParameters) {
3866
+ body = remainingParameters.data;
3867
+ } else {
3868
+ if (Object.keys(remainingParameters).length) {
3869
+ body = remainingParameters;
3870
+ }
3704
3871
  }
3705
- // Only return body/request keys if present
3706
- return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null);
3872
+ }
3873
+ if (!headers["content-type"] && typeof body !== "undefined") {
3874
+ headers["content-type"] = "application/json; charset=utf-8";
3875
+ }
3876
+ if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
3877
+ body = "";
3878
+ }
3879
+ return Object.assign(
3880
+ { method, url, headers },
3881
+ typeof body !== "undefined" ? { body } : null,
3882
+ options.request ? { request: options.request } : null
3883
+ );
3707
3884
  }
3708
3885
 
3886
+ // pkg/dist-src/endpoint-with-defaults.js
3709
3887
  function endpointWithDefaults(defaults, route, options) {
3710
- return parse(merge(defaults, route, options));
3888
+ return parse(merge(defaults, route, options));
3711
3889
  }
3712
3890
 
3891
+ // pkg/dist-src/with-defaults.js
3713
3892
  function withDefaults(oldDefaults, newDefaults) {
3714
- const DEFAULTS = merge(oldDefaults, newDefaults);
3715
- const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
3716
- return Object.assign(endpoint, {
3717
- DEFAULTS,
3718
- defaults: withDefaults.bind(null, DEFAULTS),
3719
- merge: merge.bind(null, DEFAULTS),
3720
- parse,
3721
- });
3893
+ const DEFAULTS2 = merge(oldDefaults, newDefaults);
3894
+ const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2);
3895
+ return Object.assign(endpoint2, {
3896
+ DEFAULTS: DEFAULTS2,
3897
+ defaults: withDefaults.bind(null, DEFAULTS2),
3898
+ merge: merge.bind(null, DEFAULTS2),
3899
+ parse
3900
+ });
3722
3901
  }
3723
3902
 
3724
- const VERSION = "7.0.3";
3725
-
3726
- const userAgent = `octokit-endpoint.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_1__.getUserAgent)()}`;
3727
- // DEFAULTS has all properties set that EndpointOptions has, except url.
3728
- // So we use RequestParameters and add method as additional required property.
3729
- const DEFAULTS = {
3730
- method: "GET",
3731
- baseUrl: "https://api.github.com",
3732
- headers: {
3733
- accept: "application/vnd.github.v3+json",
3734
- "user-agent": userAgent,
3735
- },
3736
- mediaType: {
3737
- format: "",
3738
- previews: [],
3739
- },
3740
- };
3903
+ // pkg/dist-src/defaults.js
3741
3904
 
3742
- const endpoint = withDefaults(null, DEFAULTS);
3743
3905
 
3906
+ // pkg/dist-src/version.js
3907
+ var VERSION = "7.0.6";
3908
+
3909
+ // pkg/dist-src/defaults.js
3910
+ var userAgent = `octokit-endpoint.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_1__.getUserAgent)()}`;
3911
+ var DEFAULTS = {
3912
+ method: "GET",
3913
+ baseUrl: "https://api.github.com",
3914
+ headers: {
3915
+ accept: "application/vnd.github.v3+json",
3916
+ "user-agent": userAgent
3917
+ },
3918
+ mediaType: {
3919
+ format: "",
3920
+ previews: []
3921
+ }
3922
+ };
3923
+
3924
+ // pkg/dist-src/index.js
3925
+ var endpoint = withDefaults(null, DEFAULTS);
3744
3926
 
3745
- //# sourceMappingURL=index.js.map
3746
3927
 
3747
3928
 
3748
3929
  /***/ }),
@@ -3776,118 +3957,127 @@ function getUserAgent() {
3776
3957
  __webpack_require__.r(__webpack_exports__);
3777
3958
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3778
3959
  /* harmony export */ "GraphqlResponseError": () => (/* binding */ GraphqlResponseError),
3779
- /* harmony export */ "graphql": () => (/* binding */ graphql$1),
3960
+ /* harmony export */ "graphql": () => (/* binding */ graphql2),
3780
3961
  /* harmony export */ "withCustomRequest": () => (/* binding */ withCustomRequest)
3781
3962
  /* harmony export */ });
3782
3963
  /* harmony import */ var _octokit_request__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(18);
3783
3964
  /* harmony import */ var universal_user_agent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(26);
3965
+ // pkg/dist-src/index.js
3784
3966
 
3785
3967
 
3786
3968
 
3787
- const VERSION = "5.0.4";
3969
+ // pkg/dist-src/version.js
3970
+ var VERSION = "5.0.6";
3788
3971
 
3972
+ // pkg/dist-src/error.js
3789
3973
  function _buildMessageForResponseErrors(data) {
3790
- return (`Request failed due to following response errors:\n` +
3791
- data.errors.map((e) => ` - ${e.message}`).join("\n"));
3974
+ return `Request failed due to following response errors:
3975
+ ` + data.errors.map((e) => ` - ${e.message}`).join("\n");
3792
3976
  }
3793
- class GraphqlResponseError extends Error {
3794
- constructor(request, headers, response) {
3795
- super(_buildMessageForResponseErrors(response));
3796
- this.request = request;
3797
- this.headers = headers;
3798
- this.response = response;
3799
- this.name = "GraphqlResponseError";
3800
- // Expose the errors and response data in their shorthand properties.
3801
- this.errors = response.errors;
3802
- this.data = response.data;
3803
- // Maintains proper stack trace (only available on V8)
3804
- /* istanbul ignore next */
3805
- if (Error.captureStackTrace) {
3806
- Error.captureStackTrace(this, this.constructor);
3807
- }
3977
+ var GraphqlResponseError = class extends Error {
3978
+ constructor(request2, headers, response) {
3979
+ super(_buildMessageForResponseErrors(response));
3980
+ this.request = request2;
3981
+ this.headers = headers;
3982
+ this.response = response;
3983
+ this.name = "GraphqlResponseError";
3984
+ this.errors = response.errors;
3985
+ this.data = response.data;
3986
+ if (Error.captureStackTrace) {
3987
+ Error.captureStackTrace(this, this.constructor);
3808
3988
  }
3809
- }
3989
+ }
3990
+ };
3810
3991
 
3811
- const NON_VARIABLE_OPTIONS = [
3812
- "method",
3813
- "baseUrl",
3814
- "url",
3815
- "headers",
3816
- "request",
3817
- "query",
3818
- "mediaType",
3992
+ // pkg/dist-src/graphql.js
3993
+ var NON_VARIABLE_OPTIONS = [
3994
+ "method",
3995
+ "baseUrl",
3996
+ "url",
3997
+ "headers",
3998
+ "request",
3999
+ "query",
4000
+ "mediaType"
3819
4001
  ];
3820
- const FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
3821
- const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
3822
- function graphql(request, query, options) {
3823
- if (options) {
3824
- if (typeof query === "string" && "query" in options) {
3825
- return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
3826
- }
3827
- for (const key in options) {
3828
- if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
3829
- continue;
3830
- return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
3831
- }
4002
+ var FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
4003
+ var GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
4004
+ function graphql(request2, query, options) {
4005
+ if (options) {
4006
+ if (typeof query === "string" && "query" in options) {
4007
+ return Promise.reject(
4008
+ new Error(`[@octokit/graphql] "query" cannot be used as variable name`)
4009
+ );
4010
+ }
4011
+ for (const key in options) {
4012
+ if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
4013
+ continue;
4014
+ return Promise.reject(
4015
+ new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`)
4016
+ );
3832
4017
  }
3833
- const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
3834
- const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
3835
- if (NON_VARIABLE_OPTIONS.includes(key)) {
3836
- result[key] = parsedOptions[key];
3837
- return result;
3838
- }
3839
- if (!result.variables) {
3840
- result.variables = {};
3841
- }
3842
- result.variables[key] = parsedOptions[key];
3843
- return result;
3844
- }, {});
3845
- // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
3846
- // https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
3847
- const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
3848
- if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
3849
- requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
3850
- }
3851
- return request(requestOptions).then((response) => {
3852
- if (response.data.errors) {
3853
- const headers = {};
3854
- for (const key of Object.keys(response.headers)) {
3855
- headers[key] = response.headers[key];
3856
- }
3857
- throw new GraphqlResponseError(requestOptions, headers, response.data);
3858
- }
3859
- return response.data.data;
3860
- });
4018
+ }
4019
+ const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
4020
+ const requestOptions = Object.keys(
4021
+ parsedOptions
4022
+ ).reduce((result, key) => {
4023
+ if (NON_VARIABLE_OPTIONS.includes(key)) {
4024
+ result[key] = parsedOptions[key];
4025
+ return result;
4026
+ }
4027
+ if (!result.variables) {
4028
+ result.variables = {};
4029
+ }
4030
+ result.variables[key] = parsedOptions[key];
4031
+ return result;
4032
+ }, {});
4033
+ const baseUrl = parsedOptions.baseUrl || request2.endpoint.DEFAULTS.baseUrl;
4034
+ if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
4035
+ requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
4036
+ }
4037
+ return request2(requestOptions).then((response) => {
4038
+ if (response.data.errors) {
4039
+ const headers = {};
4040
+ for (const key of Object.keys(response.headers)) {
4041
+ headers[key] = response.headers[key];
4042
+ }
4043
+ throw new GraphqlResponseError(
4044
+ requestOptions,
4045
+ headers,
4046
+ response.data
4047
+ );
4048
+ }
4049
+ return response.data.data;
4050
+ });
3861
4051
  }
3862
4052
 
3863
- function withDefaults(request, newDefaults) {
3864
- const newRequest = request.defaults(newDefaults);
3865
- const newApi = (query, options) => {
3866
- return graphql(newRequest, query, options);
3867
- };
3868
- return Object.assign(newApi, {
3869
- defaults: withDefaults.bind(null, newRequest),
3870
- endpoint: newRequest.endpoint,
3871
- });
4053
+ // pkg/dist-src/with-defaults.js
4054
+ function withDefaults(request2, newDefaults) {
4055
+ const newRequest = request2.defaults(newDefaults);
4056
+ const newApi = (query, options) => {
4057
+ return graphql(newRequest, query, options);
4058
+ };
4059
+ return Object.assign(newApi, {
4060
+ defaults: withDefaults.bind(null, newRequest),
4061
+ endpoint: newRequest.endpoint
4062
+ });
3872
4063
  }
3873
4064
 
3874
- const graphql$1 = withDefaults(_octokit_request__WEBPACK_IMPORTED_MODULE_0__.request, {
3875
- headers: {
3876
- "user-agent": `octokit-graphql.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_1__.getUserAgent)()}`,
3877
- },
3878
- method: "POST",
3879
- url: "/graphql",
4065
+ // pkg/dist-src/index.js
4066
+ var graphql2 = withDefaults(_octokit_request__WEBPACK_IMPORTED_MODULE_0__.request, {
4067
+ headers: {
4068
+ "user-agent": `octokit-graphql.js/${VERSION} ${(0,universal_user_agent__WEBPACK_IMPORTED_MODULE_1__.getUserAgent)()}`
4069
+ },
4070
+ method: "POST",
4071
+ url: "/graphql"
3880
4072
  });
3881
4073
  function withCustomRequest(customRequest) {
3882
- return withDefaults(customRequest, {
3883
- method: "POST",
3884
- url: "/graphql",
3885
- });
4074
+ return withDefaults(customRequest, {
4075
+ method: "POST",
4076
+ url: "/graphql"
4077
+ });
3886
4078
  }
3887
4079
 
3888
4080
 
3889
- //# sourceMappingURL=index.js.map
3890
-
3891
4081
 
3892
4082
  /***/ }),
3893
4083
  /* 28 */
@@ -3898,62 +4088,57 @@ __webpack_require__.r(__webpack_exports__);
3898
4088
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3899
4089
  /* harmony export */ "createTokenAuth": () => (/* binding */ createTokenAuth)
3900
4090
  /* harmony export */ });
3901
- const REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
3902
- const REGEX_IS_INSTALLATION = /^ghs_/;
3903
- const REGEX_IS_USER_TO_SERVER = /^ghu_/;
4091
+ // pkg/dist-src/auth.js
4092
+ var REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
4093
+ var REGEX_IS_INSTALLATION = /^ghs_/;
4094
+ var REGEX_IS_USER_TO_SERVER = /^ghu_/;
3904
4095
  async function auth(token) {
3905
- const isApp = token.split(/\./).length === 3;
3906
- const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) ||
3907
- REGEX_IS_INSTALLATION.test(token);
3908
- const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
3909
- const tokenType = isApp
3910
- ? "app"
3911
- : isInstallation
3912
- ? "installation"
3913
- : isUserToServer
3914
- ? "user-to-server"
3915
- : "oauth";
3916
- return {
3917
- type: "token",
3918
- token: token,
3919
- tokenType,
3920
- };
4096
+ const isApp = token.split(/\./).length === 3;
4097
+ const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
4098
+ const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
4099
+ const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
4100
+ return {
4101
+ type: "token",
4102
+ token,
4103
+ tokenType
4104
+ };
3921
4105
  }
3922
4106
 
3923
- /**
3924
- * Prefix token for usage in the Authorization header
3925
- *
3926
- * @param token OAuth token or JSON Web Token
3927
- */
4107
+ // pkg/dist-src/with-authorization-prefix.js
3928
4108
  function withAuthorizationPrefix(token) {
3929
- if (token.split(/\./).length === 3) {
3930
- return `bearer ${token}`;
3931
- }
3932
- return `token ${token}`;
4109
+ if (token.split(/\./).length === 3) {
4110
+ return `bearer ${token}`;
4111
+ }
4112
+ return `token ${token}`;
3933
4113
  }
3934
4114
 
4115
+ // pkg/dist-src/hook.js
3935
4116
  async function hook(token, request, route, parameters) {
3936
- const endpoint = request.endpoint.merge(route, parameters);
3937
- endpoint.headers.authorization = withAuthorizationPrefix(token);
3938
- return request(endpoint);
4117
+ const endpoint = request.endpoint.merge(
4118
+ route,
4119
+ parameters
4120
+ );
4121
+ endpoint.headers.authorization = withAuthorizationPrefix(token);
4122
+ return request(endpoint);
3939
4123
  }
3940
4124
 
3941
- const createTokenAuth = function createTokenAuth(token) {
3942
- if (!token) {
3943
- throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
3944
- }
3945
- if (typeof token !== "string") {
3946
- throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
3947
- }
3948
- token = token.replace(/^(token|bearer) +/i, "");
3949
- return Object.assign(auth.bind(null, token), {
3950
- hook: hook.bind(null, token),
3951
- });
4125
+ // pkg/dist-src/index.js
4126
+ var createTokenAuth = function createTokenAuth2(token) {
4127
+ if (!token) {
4128
+ throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
4129
+ }
4130
+ if (typeof token !== "string") {
4131
+ throw new Error(
4132
+ "[@octokit/auth-token] Token passed to createTokenAuth is not a string"
4133
+ );
4134
+ }
4135
+ token = token.replace(/^(token|bearer) +/i, "");
4136
+ return Object.assign(auth.bind(null, token), {
4137
+ hook: hook.bind(null, token)
4138
+ });
3952
4139
  };
3953
4140
 
3954
4141
 
3955
- //# sourceMappingURL=index.js.map
3956
-
3957
4142
 
3958
4143
  /***/ }),
3959
4144
  /* 29 */
@@ -5744,7 +5929,7 @@ const Endpoints = {
5744
5929
  },
5745
5930
  };
5746
5931
 
5747
- const VERSION = "6.7.0";
5932
+ const VERSION = "6.8.1";
5748
5933
 
5749
5934
  function endpointsToMethods(octokit, endpointsMap) {
5750
5935
  const newMethods = {};