prettier 2.1.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/doc.js CHANGED
@@ -29,7 +29,7 @@
29
29
  */
30
30
 
31
31
 
32
- function indent(contents) {
32
+ function indent$1(contents) {
33
33
 
34
34
  return {
35
35
  type: "indent",
@@ -37,18 +37,18 @@
37
37
  };
38
38
  }
39
39
  /**
40
- * @param {number | string} n
40
+ * @param {number | string} widthOrString
41
41
  * @param {Doc} contents
42
42
  * @returns Doc
43
43
  */
44
44
 
45
45
 
46
- function align(n, contents) {
46
+ function align(widthOrString, contents) {
47
47
 
48
48
  return {
49
49
  type: "align",
50
50
  contents,
51
- n
51
+ n: widthOrString
52
52
  };
53
53
  }
54
54
  /**
@@ -58,14 +58,13 @@
58
58
  */
59
59
 
60
60
 
61
- function group(contents, opts) {
62
- opts = opts || {};
61
+ function group(contents, opts = {}) {
63
62
 
64
63
  return {
65
64
  type: "group",
66
65
  id: opts.id,
67
66
  contents,
68
- break: !!opts.shouldBreak,
67
+ break: Boolean(opts.shouldBreak),
69
68
  expandedStates: opts.expandedStates
70
69
  };
71
70
  }
@@ -76,7 +75,7 @@
76
75
 
77
76
 
78
77
  function dedentToRoot(contents) {
79
- return align(-Infinity, contents);
78
+ return align(Number.NEGATIVE_INFINITY, contents);
80
79
  }
81
80
  /**
82
81
  * @param {Doc} contents
@@ -117,7 +116,7 @@
117
116
  */
118
117
 
119
118
 
120
- function fill(parts) {
119
+ function fill$1(parts) {
121
120
 
122
121
  return {
123
122
  type: "fill",
@@ -132,8 +131,7 @@
132
131
  */
133
132
 
134
133
 
135
- function ifBreak(breakContents, flatContents, opts) {
136
- opts = opts || {};
134
+ function ifBreak(breakContents, flatContents, opts = {}) {
137
135
 
138
136
  return {
139
137
  type: "if-break",
@@ -142,6 +140,22 @@
142
140
  groupId: opts.groupId
143
141
  };
144
142
  }
143
+ /**
144
+ * Optimized version of `ifBreak(indent(doc), doc, { groupId: ... })`
145
+ * @param {Doc} contents
146
+ * @param {{ groupId: symbol, negate?: boolean }} opts
147
+ * @returns Doc
148
+ */
149
+
150
+
151
+ function indentIfBreak(contents, opts) {
152
+ return {
153
+ type: "indent-if-break",
154
+ contents,
155
+ groupId: opts.groupId,
156
+ negate: opts.negate
157
+ };
158
+ }
145
159
  /**
146
160
  * @param {Doc} contents
147
161
  * @returns Doc
@@ -162,26 +176,30 @@
162
176
  const breakParent = {
163
177
  type: "break-parent"
164
178
  };
165
- const trim = {
179
+ const trim$1 = {
166
180
  type: "trim"
167
181
  };
182
+ const hardlineWithoutBreakParent = {
183
+ type: "line",
184
+ hard: true
185
+ };
186
+ const literallineWithoutBreakParent = {
187
+ type: "line",
188
+ hard: true,
189
+ literal: true
190
+ };
168
191
  const line = {
169
192
  type: "line"
170
193
  };
171
194
  const softline = {
172
195
  type: "line",
173
196
  soft: true
174
- };
175
- const hardline = concat([{
176
- type: "line",
177
- hard: true
178
- }, breakParent]);
179
- const literalline = concat([{
180
- type: "line",
181
- hard: true,
182
- literal: true
183
- }, breakParent]);
184
- const cursor = {
197
+ }; // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
198
+
199
+ const hardline = concat([hardlineWithoutBreakParent, breakParent]); // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
200
+
201
+ const literalline$1 = concat([literallineWithoutBreakParent, breakParent]);
202
+ const cursor$1 = {
185
203
  type: "cursor",
186
204
  placeholder: Symbol("cursor")
187
205
  };
@@ -200,7 +218,8 @@
200
218
  }
201
219
 
202
220
  res.push(arr[i]);
203
- }
221
+ } // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
222
+
204
223
 
205
224
  return concat(res);
206
225
  }
@@ -217,41 +236,53 @@
217
236
  if (size > 0) {
218
237
  // Use indent to add tabs for all the levels of tabs we need
219
238
  for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
220
- aligned = indent(aligned);
239
+ aligned = indent$1(aligned);
221
240
  } // Use align for all the spaces that are needed
222
241
 
223
242
 
224
243
  aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
225
244
  // indentation, so we use -Infinity to reset the indentation to 0
226
245
 
227
- aligned = align(-Infinity, aligned);
246
+ aligned = align(Number.NEGATIVE_INFINITY, aligned);
228
247
  }
229
248
 
230
249
  return aligned;
231
250
  }
232
251
 
252
+ function label(label, contents) {
253
+ return {
254
+ type: "label",
255
+ label,
256
+ contents
257
+ };
258
+ }
259
+
233
260
  var docBuilders = {
234
261
  concat,
235
262
  join,
236
263
  line,
237
264
  softline,
238
265
  hardline,
239
- literalline,
266
+ literalline: literalline$1,
240
267
  group,
241
268
  conditionalGroup,
242
- fill,
269
+ fill: fill$1,
243
270
  lineSuffix,
244
271
  lineSuffixBoundary,
245
- cursor,
272
+ cursor: cursor$1,
246
273
  breakParent,
247
274
  ifBreak,
248
- trim,
249
- indent,
275
+ trim: trim$1,
276
+ indent: indent$1,
277
+ indentIfBreak,
250
278
  align,
251
279
  addAlignmentToDoc,
252
280
  markAsRoot,
253
281
  dedentToRoot,
254
- dedent
282
+ dedent,
283
+ hardlineWithoutBreakParent,
284
+ literallineWithoutBreakParent,
285
+ label
255
286
  };
256
287
 
257
288
  var ansiRegex = ({
@@ -295,22 +326,26 @@
295
326
  };
296
327
 
297
328
  var isFullwidthCodePoint_1 = isFullwidthCodePoint;
298
- var _default = isFullwidthCodePoint;
299
- isFullwidthCodePoint_1.default = _default;
329
+ var _default$1 = isFullwidthCodePoint;
330
+ isFullwidthCodePoint_1.default = _default$1;
300
331
 
301
- var emojiRegex = function emojiRegex() {
332
+ var emojiRegex = function () {
302
333
  // https://mths.be/emoji
303
334
  return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
304
335
  };
305
336
 
306
337
  const stringWidth = string => {
307
- string = string.replace(emojiRegex(), ' ');
308
-
309
338
  if (typeof string !== 'string' || string.length === 0) {
310
339
  return 0;
311
340
  }
312
341
 
313
342
  string = stripAnsi(string);
343
+
344
+ if (string.length === 0) {
345
+ return 0;
346
+ }
347
+
348
+ string = string.replace(emojiRegex(), ' ');
314
349
  let width = 0;
315
350
 
316
351
  for (let i = 0; i < string.length; i++) {
@@ -338,8 +373,8 @@
338
373
 
339
374
  var stringWidth_1 = stringWidth; // TODO: remove this in the next major version
340
375
 
341
- var _default$1 = stringWidth;
342
- stringWidth_1.default = _default$1;
376
+ var _default = stringWidth;
377
+ stringWidth_1.default = _default;
343
378
 
344
379
  var escapeStringRegexp = string => {
345
380
  if (typeof string !== 'string') {
@@ -351,7 +386,9 @@
351
386
  return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
352
387
  };
353
388
 
354
- var getLast = arr => arr[arr.length - 1];
389
+ const getLast$1 = arr => arr[arr.length - 1];
390
+
391
+ var getLast_1 = getLast$1;
355
392
 
356
393
  function _objectWithoutPropertiesLoose(source, excluded) {
357
394
  if (source == null) return {};
@@ -380,165 +417,179 @@
380
417
  }));
381
418
  }
382
419
 
383
- var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
420
+ /**
421
+ * The inverse of `_.toPairs`; this method returns an object composed
422
+ * from key-value `pairs`.
423
+ *
424
+ * @static
425
+ * @memberOf _
426
+ * @since 4.0.0
427
+ * @category Array
428
+ * @param {Array} pairs The key-value pairs.
429
+ * @returns {Object} Returns the new object.
430
+ * @example
431
+ *
432
+ * _.fromPairs([['a', 1], ['b', 2]]);
433
+ * // => { 'a': 1, 'b': 2 }
434
+ */
435
+ function fromPairs(pairs) {
436
+ var index = -1,
437
+ length = pairs == null ? 0 : pairs.length,
438
+ result = {};
439
+
440
+ while (++index < length) {
441
+ var pair = pairs[index];
442
+ result[pair[0]] = pair[1];
443
+ }
444
+
445
+ return result;
446
+ }
447
+
448
+ var fromPairs_1 = fromPairs;
449
+
450
+ var global = (typeof global !== "undefined" ? global :
451
+ typeof self !== "undefined" ? self :
452
+ typeof window !== "undefined" ? window : {});
384
453
 
454
+ // shim for using process in browser
385
455
  // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
386
456
 
387
457
  function defaultSetTimout() {
388
- throw new Error('setTimeout has not been defined');
458
+ throw new Error('setTimeout has not been defined');
389
459
  }
390
-
391
- function defaultClearTimeout() {
392
- throw new Error('clearTimeout has not been defined');
460
+ function defaultClearTimeout () {
461
+ throw new Error('clearTimeout has not been defined');
393
462
  }
394
-
395
463
  var cachedSetTimeout = defaultSetTimout;
396
464
  var cachedClearTimeout = defaultClearTimeout;
397
-
398
- if (typeof global$1.setTimeout === 'function') {
399
- cachedSetTimeout = setTimeout;
465
+ if (typeof global.setTimeout === 'function') {
466
+ cachedSetTimeout = setTimeout;
400
467
  }
401
-
402
- if (typeof global$1.clearTimeout === 'function') {
403
- cachedClearTimeout = clearTimeout;
468
+ if (typeof global.clearTimeout === 'function') {
469
+ cachedClearTimeout = clearTimeout;
404
470
  }
405
471
 
406
472
  function runTimeout(fun) {
407
- if (cachedSetTimeout === setTimeout) {
408
- //normal enviroments in sane situations
409
- return setTimeout(fun, 0);
410
- } // if setTimeout wasn't available but was latter defined
411
-
412
-
413
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
414
- cachedSetTimeout = setTimeout;
415
- return setTimeout(fun, 0);
416
- }
417
-
418
- try {
419
- // when when somebody has screwed with setTimeout but no I.E. maddness
420
- return cachedSetTimeout(fun, 0);
421
- } catch (e) {
473
+ if (cachedSetTimeout === setTimeout) {
474
+ //normal enviroments in sane situations
475
+ return setTimeout(fun, 0);
476
+ }
477
+ // if setTimeout wasn't available but was latter defined
478
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
479
+ cachedSetTimeout = setTimeout;
480
+ return setTimeout(fun, 0);
481
+ }
422
482
  try {
423
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
424
- return cachedSetTimeout.call(null, fun, 0);
425
- } catch (e) {
426
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
427
- return cachedSetTimeout.call(this, fun, 0);
483
+ // when when somebody has screwed with setTimeout but no I.E. maddness
484
+ return cachedSetTimeout(fun, 0);
485
+ } catch(e){
486
+ try {
487
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
488
+ return cachedSetTimeout.call(null, fun, 0);
489
+ } catch(e){
490
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
491
+ return cachedSetTimeout.call(this, fun, 0);
492
+ }
428
493
  }
429
- }
430
- }
431
494
 
495
+
496
+ }
432
497
  function runClearTimeout(marker) {
433
- if (cachedClearTimeout === clearTimeout) {
434
- //normal enviroments in sane situations
435
- return clearTimeout(marker);
436
- } // if clearTimeout wasn't available but was latter defined
498
+ if (cachedClearTimeout === clearTimeout) {
499
+ //normal enviroments in sane situations
500
+ return clearTimeout(marker);
501
+ }
502
+ // if clearTimeout wasn't available but was latter defined
503
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
504
+ cachedClearTimeout = clearTimeout;
505
+ return clearTimeout(marker);
506
+ }
507
+ try {
508
+ // when when somebody has screwed with setTimeout but no I.E. maddness
509
+ return cachedClearTimeout(marker);
510
+ } catch (e){
511
+ try {
512
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
513
+ return cachedClearTimeout.call(null, marker);
514
+ } catch (e){
515
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
516
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
517
+ return cachedClearTimeout.call(this, marker);
518
+ }
519
+ }
437
520
 
438
521
 
439
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
440
- cachedClearTimeout = clearTimeout;
441
- return clearTimeout(marker);
442
- }
443
522
 
444
- try {
445
- // when when somebody has screwed with setTimeout but no I.E. maddness
446
- return cachedClearTimeout(marker);
447
- } catch (e) {
448
- try {
449
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
450
- return cachedClearTimeout.call(null, marker);
451
- } catch (e) {
452
- // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
453
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
454
- return cachedClearTimeout.call(this, marker);
455
- }
456
- }
457
523
  }
458
-
459
524
  var queue = [];
460
525
  var draining = false;
461
526
  var currentQueue;
462
527
  var queueIndex = -1;
463
528
 
464
529
  function cleanUpNextTick() {
465
- if (!draining || !currentQueue) {
466
- return;
467
- }
468
-
469
- draining = false;
470
-
471
- if (currentQueue.length) {
472
- queue = currentQueue.concat(queue);
473
- } else {
474
- queueIndex = -1;
475
- }
476
-
477
- if (queue.length) {
478
- drainQueue();
479
- }
530
+ if (!draining || !currentQueue) {
531
+ return;
532
+ }
533
+ draining = false;
534
+ if (currentQueue.length) {
535
+ queue = currentQueue.concat(queue);
536
+ } else {
537
+ queueIndex = -1;
538
+ }
539
+ if (queue.length) {
540
+ drainQueue();
541
+ }
480
542
  }
481
543
 
482
544
  function drainQueue() {
483
- if (draining) {
484
- return;
485
- }
486
-
487
- var timeout = runTimeout(cleanUpNextTick);
488
- draining = true;
489
- var len = queue.length;
490
-
491
- while (len) {
492
- currentQueue = queue;
493
- queue = [];
494
-
495
- while (++queueIndex < len) {
496
- if (currentQueue) {
497
- currentQueue[queueIndex].run();
498
- }
545
+ if (draining) {
546
+ return;
547
+ }
548
+ var timeout = runTimeout(cleanUpNextTick);
549
+ draining = true;
550
+
551
+ var len = queue.length;
552
+ while(len) {
553
+ currentQueue = queue;
554
+ queue = [];
555
+ while (++queueIndex < len) {
556
+ if (currentQueue) {
557
+ currentQueue[queueIndex].run();
558
+ }
559
+ }
560
+ queueIndex = -1;
561
+ len = queue.length;
499
562
  }
500
-
501
- queueIndex = -1;
502
- len = queue.length;
503
- }
504
-
505
- currentQueue = null;
506
- draining = false;
507
- runClearTimeout(timeout);
563
+ currentQueue = null;
564
+ draining = false;
565
+ runClearTimeout(timeout);
508
566
  }
509
-
510
567
  function nextTick(fun) {
511
- var args = new Array(arguments.length - 1);
512
-
513
- if (arguments.length > 1) {
514
- for (var i = 1; i < arguments.length; i++) {
515
- args[i - 1] = arguments[i];
568
+ var args = new Array(arguments.length - 1);
569
+ if (arguments.length > 1) {
570
+ for (var i = 1; i < arguments.length; i++) {
571
+ args[i - 1] = arguments[i];
572
+ }
516
573
  }
517
- }
518
-
519
- queue.push(new Item(fun, args));
520
-
521
- if (queue.length === 1 && !draining) {
522
- runTimeout(drainQueue);
523
- }
524
- } // v8 likes predictible objects
525
-
574
+ queue.push(new Item(fun, args));
575
+ if (queue.length === 1 && !draining) {
576
+ runTimeout(drainQueue);
577
+ }
578
+ }
579
+ // v8 likes predictible objects
526
580
  function Item(fun, array) {
527
- this.fun = fun;
528
- this.array = array;
581
+ this.fun = fun;
582
+ this.array = array;
529
583
  }
530
-
531
584
  Item.prototype.run = function () {
532
- this.fun.apply(null, this.array);
585
+ this.fun.apply(null, this.array);
533
586
  };
534
-
535
587
  var title = 'browser';
536
588
  var platform = 'browser';
537
- var browser = true;
589
+ var browser$1 = true;
538
590
  var env = {};
539
591
  var argv = [];
540
- var version = ''; // empty string to avoid regexp issues
541
-
592
+ var version$1 = ''; // empty string to avoid regexp issues
542
593
  var versions = {};
543
594
  var release = {};
544
595
  var config = {};
@@ -552,57 +603,57 @@
552
603
  var removeListener = noop;
553
604
  var removeAllListeners = noop;
554
605
  var emit = noop;
606
+
555
607
  function binding(name) {
556
- throw new Error('process.binding is not supported');
557
- }
558
- function cwd() {
559
- return '/';
560
- }
561
- function chdir(dir) {
562
- throw new Error('process.chdir is not supported');
608
+ throw new Error('process.binding is not supported');
563
609
  }
564
- function umask() {
565
- return 0;
566
- } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
567
610
 
568
- var performance = global$1.performance || {};
569
-
570
- var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
571
- return new Date().getTime();
572
- }; // generate timestamp or delta
573
- // see http://nodejs.org/api/process.html#process_process_hrtime
611
+ function cwd () { return '/' }
612
+ function chdir (dir) {
613
+ throw new Error('process.chdir is not supported');
614
+ }function umask() { return 0; }
574
615
 
616
+ // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
617
+ var performance = global.performance || {};
618
+ var performanceNow =
619
+ performance.now ||
620
+ performance.mozNow ||
621
+ performance.msNow ||
622
+ performance.oNow ||
623
+ performance.webkitNow ||
624
+ function(){ return (new Date()).getTime() };
575
625
 
576
- function hrtime(previousTimestamp) {
577
- var clocktime = performanceNow.call(performance) * 1e-3;
626
+ // generate timestamp or delta
627
+ // see http://nodejs.org/api/process.html#process_process_hrtime
628
+ function hrtime(previousTimestamp){
629
+ var clocktime = performanceNow.call(performance)*1e-3;
578
630
  var seconds = Math.floor(clocktime);
579
- var nanoseconds = Math.floor(clocktime % 1 * 1e9);
580
-
631
+ var nanoseconds = Math.floor((clocktime%1)*1e9);
581
632
  if (previousTimestamp) {
582
633
  seconds = seconds - previousTimestamp[0];
583
634
  nanoseconds = nanoseconds - previousTimestamp[1];
584
-
585
- if (nanoseconds < 0) {
635
+ if (nanoseconds<0) {
586
636
  seconds--;
587
637
  nanoseconds += 1e9;
588
638
  }
589
639
  }
590
-
591
- return [seconds, nanoseconds];
640
+ return [seconds,nanoseconds]
592
641
  }
642
+
593
643
  var startTime = new Date();
594
644
  function uptime() {
595
645
  var currentTime = new Date();
596
646
  var dif = currentTime - startTime;
597
647
  return dif / 1000;
598
648
  }
599
- var process = {
649
+
650
+ var browser$1$1 = {
600
651
  nextTick: nextTick,
601
652
  title: title,
602
- browser: browser,
653
+ browser: browser$1,
603
654
  env: env,
604
655
  argv: argv,
605
- version: version,
656
+ version: version$1,
606
657
  versions: versions,
607
658
  on: on,
608
659
  addListener: addListener,
@@ -622,41 +673,28 @@
622
673
  uptime: uptime
623
674
  };
624
675
 
625
- const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
676
+ const debug = typeof browser$1$1 === 'object' && browser$1$1.env && browser$1$1.env.NODE_DEBUG && /\bsemver\b/i.test(browser$1$1.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
626
677
  var debug_1 = debug;
627
678
 
628
679
  // Note: this is the semver.org version of the spec that it implements
629
680
  // Not necessarily the package version of this code.
630
681
  const SEMVER_SPEC_VERSION = '2.0.0';
631
- const MAX_LENGTH = 256;
632
- const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
682
+ const MAX_LENGTH$1 = 256;
683
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
633
684
  /* istanbul ignore next */
634
685
  9007199254740991; // Max safe segment length for coercion.
635
686
 
636
687
  const MAX_SAFE_COMPONENT_LENGTH = 16;
637
688
  var constants = {
638
689
  SEMVER_SPEC_VERSION,
639
- MAX_LENGTH,
640
- MAX_SAFE_INTEGER,
690
+ MAX_LENGTH: MAX_LENGTH$1,
691
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
641
692
  MAX_SAFE_COMPONENT_LENGTH
642
693
  };
643
694
 
644
- function createCommonjsModule(fn, basedir, module) {
645
- return module = {
646
- path: basedir,
647
- exports: {},
648
- require: function (path, base) {
649
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
650
- }
651
- }, fn(module, module.exports), module.exports;
652
- }
653
-
654
- function getCjsExportFromNamespace (n) {
655
- return n && n['default'] || n;
656
- }
657
-
658
- function commonjsRequire () {
659
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
695
+ function createCommonjsModule(fn) {
696
+ var module = { exports: {} };
697
+ return fn(module, module.exports), module.exports;
660
698
  }
661
699
 
662
700
  var re_1 = createCommonjsModule(function (module, exports) {
@@ -770,9 +808,22 @@
770
808
  createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
771
809
  });
772
810
 
811
+ // parse out just the options we care about so we always get a consistent
812
+ // obj with keys in a consistent order.
813
+ const opts = ['includePrerelease', 'loose', 'rtl'];
814
+
815
+ const parseOptions = options => !options ? {} : typeof options !== 'object' ? {
816
+ loose: true
817
+ } : opts.filter(k => options[k]).reduce((options, k) => {
818
+ options[k] = true;
819
+ return options;
820
+ }, {});
821
+
822
+ var parseOptions_1 = parseOptions;
823
+
773
824
  const numeric = /^[0-9]+$/;
774
825
 
775
- const compareIdentifiers = (a, b) => {
826
+ const compareIdentifiers$1 = (a, b) => {
776
827
  const anum = numeric.test(a);
777
828
  const bnum = numeric.test(b);
778
829
 
@@ -784,33 +835,28 @@
784
835
  return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
785
836
  };
786
837
 
787
- const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
838
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
788
839
 
789
840
  var identifiers = {
790
- compareIdentifiers,
841
+ compareIdentifiers: compareIdentifiers$1,
791
842
  rcompareIdentifiers
792
843
  };
793
844
 
794
845
  const {
795
- MAX_LENGTH: MAX_LENGTH$1,
796
- MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1
846
+ MAX_LENGTH,
847
+ MAX_SAFE_INTEGER
797
848
  } = constants;
798
849
  const {
799
850
  re,
800
851
  t
801
852
  } = re_1;
802
853
  const {
803
- compareIdentifiers: compareIdentifiers$1
854
+ compareIdentifiers
804
855
  } = identifiers;
805
856
 
806
857
  class SemVer {
807
858
  constructor(version, options) {
808
- if (!options || typeof options !== 'object') {
809
- options = {
810
- loose: !!options,
811
- includePrerelease: false
812
- };
813
- }
859
+ options = parseOptions_1(options);
814
860
 
815
861
  if (version instanceof SemVer) {
816
862
  if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
@@ -822,8 +868,8 @@
822
868
  throw new TypeError("Invalid Version: ".concat(version));
823
869
  }
824
870
 
825
- if (version.length > MAX_LENGTH$1) {
826
- throw new TypeError("version is longer than ".concat(MAX_LENGTH$1, " characters"));
871
+ if (version.length > MAX_LENGTH) {
872
+ throw new TypeError("version is longer than ".concat(MAX_LENGTH, " characters"));
827
873
  }
828
874
 
829
875
  debug_1('SemVer', version, options);
@@ -844,15 +890,15 @@
844
890
  this.minor = +m[2];
845
891
  this.patch = +m[3];
846
892
 
847
- if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) {
893
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
848
894
  throw new TypeError('Invalid major version');
849
895
  }
850
896
 
851
- if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) {
897
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
852
898
  throw new TypeError('Invalid minor version');
853
899
  }
854
900
 
855
- if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) {
901
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
856
902
  throw new TypeError('Invalid patch version');
857
903
  } // numberify any prerelease numeric ids
858
904
 
@@ -864,7 +910,7 @@
864
910
  if (/^[0-9]+$/.test(id)) {
865
911
  const num = +id;
866
912
 
867
- if (num >= 0 && num < MAX_SAFE_INTEGER$1) {
913
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
868
914
  return num;
869
915
  }
870
916
  }
@@ -914,7 +960,7 @@
914
960
  other = new SemVer(other, this.options);
915
961
  }
916
962
 
917
- return compareIdentifiers$1(this.major, other.major) || compareIdentifiers$1(this.minor, other.minor) || compareIdentifiers$1(this.patch, other.patch);
963
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
918
964
  }
919
965
 
920
966
  comparePre(other) {
@@ -947,7 +993,7 @@
947
993
  } else if (a === b) {
948
994
  continue;
949
995
  } else {
950
- return compareIdentifiers$1(a, b);
996
+ return compareIdentifiers(a, b);
951
997
  }
952
998
  } while (++i);
953
999
  }
@@ -973,7 +1019,7 @@
973
1019
  } else if (a === b) {
974
1020
  continue;
975
1021
  } else {
976
- return compareIdentifiers$1(a, b);
1022
+ return compareIdentifiers(a, b);
977
1023
  }
978
1024
  } while (++i);
979
1025
  } // preminor will bump the version up to the next minor release, and immediately
@@ -1101,9 +1147,9 @@
1101
1147
 
1102
1148
  }
1103
1149
 
1104
- var semver = SemVer;
1150
+ var semver$1 = SemVer;
1105
1151
 
1106
- const compare = (a, b, loose) => new semver(a, loose).compare(new semver(b, loose));
1152
+ const compare = (a, b, loose) => new semver$1(a, loose).compare(new semver$1(b, loose));
1107
1153
 
1108
1154
  var compare_1 = compare;
1109
1155
 
@@ -1120,7 +1166,7 @@
1120
1166
  }, value));
1121
1167
 
1122
1168
  var name = "prettier";
1123
- var version$1 = "2.1.1";
1169
+ var version = "2.3.0";
1124
1170
  var description = "Prettier is an opinionated code formatter";
1125
1171
  var bin = "./bin/prettier.js";
1126
1172
  var repository = "prettier/prettier";
@@ -1128,7 +1174,7 @@
1128
1174
  var author = "James Long";
1129
1175
  var license = "MIT";
1130
1176
  var main = "./index.js";
1131
- var browser$1 = "./standalone.js";
1177
+ var browser = "./standalone.js";
1132
1178
  var unpkg = "./standalone.js";
1133
1179
  var engines = {
1134
1180
  node: ">=10.13.0"
@@ -1140,48 +1186,50 @@
1140
1186
  "bin"
1141
1187
  ];
1142
1188
  var dependencies = {
1143
- "@angular/compiler": "10.0.12",
1144
- "@babel/code-frame": "7.10.4",
1145
- "@babel/parser": "7.11.2",
1146
- "@glimmer/syntax": "0.59.0",
1189
+ "@angular/compiler": "11.2.13",
1190
+ "@babel/code-frame": "7.12.13",
1191
+ "@babel/parser": "7.14.1",
1192
+ "@glimmer/syntax": "0.79.0",
1147
1193
  "@iarna/toml": "2.2.5",
1148
- "@typescript-eslint/typescript-estree": "3.10.0",
1149
- "angular-estree-parser": "2.2.0",
1150
- "angular-html-parser": "1.7.1",
1151
- camelcase: "6.0.0",
1152
- chalk: "4.1.0",
1153
- "ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
1154
- "cjk-regex": "2.0.0",
1194
+ "@typescript-eslint/typescript-estree": "4.22.0",
1195
+ "angular-estree-parser": "2.3.0",
1196
+ "angular-html-parser": "1.8.0",
1197
+ camelcase: "6.2.0",
1198
+ chalk: "4.1.1",
1199
+ "ci-info": "3.1.1",
1200
+ "cjk-regex": "2.0.1",
1155
1201
  cosmiconfig: "7.0.0",
1156
1202
  dashify: "2.0.0",
1157
- diff: "4.0.2",
1203
+ diff: "5.0.0",
1158
1204
  editorconfig: "0.15.3",
1159
- "editorconfig-to-prettier": "0.1.1",
1205
+ "editorconfig-to-prettier": "0.2.0",
1160
1206
  "escape-string-regexp": "4.0.0",
1207
+ espree: "7.3.1",
1161
1208
  esutils: "2.0.3",
1162
- "fast-glob": "3.2.4",
1209
+ "fast-glob": "3.2.5",
1163
1210
  "fast-json-stable-stringify": "2.1.0",
1164
1211
  "find-parent-dir": "0.3.0",
1165
- "flow-parser": "0.132.0",
1166
- "get-stream": "6.0.0",
1167
- globby: "11.0.1",
1168
- graphql: "15.3.0",
1169
- "html-element-attributes": "2.2.1",
1212
+ "flow-parser": "0.150.1",
1213
+ "get-stdin": "8.0.0",
1214
+ globby: "11.0.3",
1215
+ graphql: "15.5.0",
1216
+ "html-element-attributes": "2.3.0",
1170
1217
  "html-styles": "1.0.0",
1171
1218
  "html-tag-names": "1.1.5",
1172
1219
  "html-void-elements": "1.0.5",
1173
1220
  ignore: "4.0.6",
1174
1221
  "jest-docblock": "26.0.0",
1175
- json5: "2.1.3",
1222
+ json5: "2.2.0",
1176
1223
  leven: "3.1.0",
1177
1224
  "lines-and-columns": "1.1.6",
1178
- "linguist-languages": "7.10.0",
1179
- lodash: "4.17.20",
1180
- mem: "6.1.0",
1225
+ "linguist-languages": "7.14.0",
1226
+ lodash: "4.17.21",
1227
+ mem: "8.1.1",
1228
+ meriyah: "4.1.5",
1181
1229
  minimatch: "3.0.4",
1182
1230
  minimist: "1.2.5",
1183
- "n-readlines": "1.0.0",
1184
- outdent: "0.7.1",
1231
+ "n-readlines": "1.0.1",
1232
+ outdent: "0.8.0",
1185
1233
  "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
1186
1234
  "please-upgrade-node": "3.2.0",
1187
1235
  "postcss-less": "3.1.4",
@@ -1191,62 +1239,65 @@
1191
1239
  "postcss-values-parser": "2.0.1",
1192
1240
  "regexp-util": "1.2.2",
1193
1241
  "remark-footnotes": "2.0.0",
1194
- "remark-math": "1.0.6",
1242
+ "remark-math": "3.0.1",
1195
1243
  "remark-parse": "8.0.3",
1196
- resolve: "1.17.0",
1197
- semver: "7.3.2",
1198
- "string-width": "4.2.0",
1199
- typescript: "4.0.2",
1244
+ resolve: "1.20.0",
1245
+ semver: "7.3.5",
1246
+ "string-width": "4.2.2",
1247
+ "strip-ansi": "6.0.0",
1248
+ typescript: "4.2.4",
1200
1249
  "unicode-regex": "3.0.0",
1201
- unified: "9.2.0",
1250
+ unified: "9.2.1",
1202
1251
  vnopts: "1.0.2",
1203
- "yaml-unist-parser": "1.3.0"
1252
+ wcwidth: "1.0.1",
1253
+ "yaml-unist-parser": "1.3.1"
1204
1254
  };
1205
1255
  var devDependencies = {
1206
- "@babel/core": "7.11.4",
1207
- "@babel/preset-env": "7.11.0",
1208
- "@babel/types": "7.11.0",
1209
- "@glimmer/reference": "0.59.0",
1210
- "@rollup/plugin-alias": "3.1.1",
1211
- "@rollup/plugin-babel": "5.2.0",
1212
- "@rollup/plugin-commonjs": "14.0.0",
1256
+ "@babel/core": "7.14.0",
1257
+ "@babel/preset-env": "7.14.1",
1258
+ "@babel/types": "7.14.1",
1259
+ "@glimmer/reference": "0.79.0",
1260
+ "@rollup/plugin-alias": "3.1.2",
1261
+ "@rollup/plugin-babel": "5.3.0",
1262
+ "@rollup/plugin-commonjs": "18.1.0",
1213
1263
  "@rollup/plugin-json": "4.1.0",
1214
- "@rollup/plugin-node-resolve": "9.0.0",
1215
- "@rollup/plugin-replace": "2.3.3",
1216
- "@types/estree": "0.0.45",
1217
- "@types/node": "14.6.0",
1218
- "@typescript-eslint/types": "3.10.0",
1219
- "babel-loader": "8.1.0",
1264
+ "@rollup/plugin-node-resolve": "13.0.0",
1265
+ "@rollup/plugin-replace": "2.4.2",
1266
+ "@types/estree": "0.0.47",
1267
+ "@types/node": "15.0.1",
1268
+ "babel-jest": "26.6.3",
1269
+ "babel-loader": "8.2.2",
1220
1270
  benchmark: "2.1.4",
1221
- "builtin-modules": "3.1.0",
1222
- "cross-env": "7.0.2",
1223
- cspell: "4.1.0",
1224
- eslint: "7.7.0",
1225
- "eslint-config-prettier": "6.11.0",
1271
+ "builtin-modules": "3.2.0",
1272
+ "cross-env": "7.0.3",
1273
+ cspell: "4.2.8",
1274
+ eslint: "7.26.0",
1275
+ "eslint-config-prettier": "8.3.0",
1226
1276
  "eslint-formatter-friendly": "7.0.0",
1227
- "eslint-plugin-import": "2.22.0",
1228
- "eslint-plugin-jest": "23.20.0",
1229
- "eslint-plugin-prettier-internal-rules": "file:scripts/tools/eslint-plugin-prettier-internal-rules",
1230
- "eslint-plugin-react": "7.20.6",
1231
- "eslint-plugin-unicorn": "21.0.0",
1232
- execa: "4.0.3",
1233
- jest: "26.4.2",
1277
+ "eslint-plugin-import": "2.22.1",
1278
+ "eslint-plugin-jest": "24.3.6",
1279
+ "eslint-plugin-prettier-internal-rules": "link:scripts/tools/eslint-plugin-prettier-internal-rules",
1280
+ "eslint-plugin-react": "7.23.2",
1281
+ "eslint-plugin-unicorn": "31.0.0",
1282
+ execa: "5.0.0",
1283
+ jest: "26.6.3",
1234
1284
  "jest-snapshot-serializer-ansi": "1.0.0",
1235
- "jest-snapshot-serializer-raw": "1.1.0",
1236
- "jest-watch-typeahead": "0.6.0",
1285
+ "jest-snapshot-serializer-raw": "1.2.0",
1286
+ "jest-watch-typeahead": "0.6.3",
1237
1287
  "npm-run-all": "4.1.5",
1238
- prettier: "2.1.0",
1288
+ "path-browserify": "1.0.1",
1289
+ prettier: "2.2.1",
1290
+ "pretty-bytes": "5.6.0",
1239
1291
  rimraf: "3.0.2",
1240
- rollup: "2.26.5",
1241
- "rollup-plugin-node-globals": "1.4.0",
1242
- "rollup-plugin-terser": "7.0.0",
1292
+ rollup: "2.47.0",
1293
+ "rollup-plugin-polyfill-node": "0.6.2",
1294
+ "rollup-plugin-terser": "7.0.2",
1243
1295
  shelljs: "0.8.4",
1244
1296
  "snapshot-diff": "0.8.1",
1245
- "strip-ansi": "6.0.0",
1246
- "synchronous-promise": "2.0.13",
1247
- tempy: "0.6.0",
1248
- "terser-webpack-plugin": "4.1.0",
1249
- webpack: "4.44.1"
1297
+ "synchronous-promise": "2.0.15",
1298
+ tempy: "1.0.1",
1299
+ "terser-webpack-plugin": "5.1.1",
1300
+ webpack: "5.36.2"
1250
1301
  };
1251
1302
  var scripts = {
1252
1303
  prepublishOnly: "echo \"Error: must publish from dist/\" && exit 1",
@@ -1255,7 +1306,7 @@
1255
1306
  "test:dev-package": "cross-env INSTALL_PACKAGE=1 jest",
1256
1307
  "test:dist": "cross-env NODE_ENV=production jest",
1257
1308
  "test:dist-standalone": "cross-env NODE_ENV=production TEST_STANDALONE=1 jest",
1258
- "test:integration": "jest tests_integration",
1309
+ "test:integration": "jest tests/integration",
1259
1310
  "perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
1260
1311
  "perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
1261
1312
  "perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
@@ -1264,18 +1315,18 @@
1264
1315
  "lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
1265
1316
  "lint:changelog": "node ./scripts/lint-changelog.js",
1266
1317
  "lint:prettier": "prettier . \"!test*\" --check",
1267
- "lint:dist": "eslint --no-eslintrc --no-ignore --env=es6,browser --parser-options=ecmaVersion:2016 \"dist/!(bin-prettier|index|third-party).js\"",
1318
+ "lint:dist": "eslint --no-eslintrc --no-ignore --no-inline-config --env=es6,browser --parser-options=ecmaVersion:2018 \"dist/!(bin-prettier|index|third-party).js\"",
1268
1319
  "lint:spellcheck": "cspell \"**/*\" \".github/**/*\"",
1269
1320
  "lint:deps": "node ./scripts/check-deps.js",
1270
1321
  fix: "run-s fix:eslint fix:prettier",
1271
1322
  "fix:eslint": "yarn lint:eslint --fix",
1272
1323
  "fix:prettier": "yarn lint:prettier --write",
1273
- build: "node ./scripts/build/build.js",
1324
+ build: "node --max-old-space-size=3072 ./scripts/build/build.js",
1274
1325
  "build-docs": "node ./scripts/build-docs.js"
1275
1326
  };
1276
- var _package = {
1327
+ var require$$3 = {
1277
1328
  name: name,
1278
- version: version$1,
1329
+ version: version,
1279
1330
  description: description,
1280
1331
  bin: bin,
1281
1332
  repository: repository,
@@ -1283,7 +1334,7 @@
1283
1334
  author: author,
1284
1335
  license: license,
1285
1336
  main: main,
1286
- browser: browser$1,
1337
+ browser: browser,
1287
1338
  unpkg: unpkg,
1288
1339
  engines: engines,
1289
1340
  files: files,
@@ -1292,32 +1343,12 @@
1292
1343
  scripts: scripts
1293
1344
  };
1294
1345
 
1295
- var _package$1 = /*#__PURE__*/Object.freeze({
1296
- __proto__: null,
1297
- name: name,
1298
- version: version$1,
1299
- description: description,
1300
- bin: bin,
1301
- repository: repository,
1302
- homepage: homepage,
1303
- author: author,
1304
- license: license,
1305
- main: main,
1306
- browser: browser$1,
1307
- unpkg: unpkg,
1308
- engines: engines,
1309
- files: files,
1310
- dependencies: dependencies,
1311
- devDependencies: devDependencies,
1312
- scripts: scripts,
1313
- 'default': _package
1314
- });
1315
-
1316
1346
  var lib = createCommonjsModule(function (module, exports) {
1317
1347
 
1318
1348
  Object.defineProperty(exports, "__esModule", {
1319
1349
  value: true
1320
- }); // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
1350
+ });
1351
+ exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
1321
1352
 
1322
1353
  function noop() {
1323
1354
  var args = [];
@@ -1328,7 +1359,7 @@
1328
1359
  }
1329
1360
 
1330
1361
  function createWeakMap() {
1331
- if (typeof WeakMap !== 'undefined') {
1362
+ if (typeof WeakMap !== "undefined") {
1332
1363
  return new WeakMap();
1333
1364
  } else {
1334
1365
  return fakeSetOrMap();
@@ -1345,7 +1376,7 @@
1345
1376
  delete: noop,
1346
1377
  get: noop,
1347
1378
  set: noop,
1348
- has: function has(k) {
1379
+ has: function (k) {
1349
1380
  return false;
1350
1381
  }
1351
1382
  };
@@ -1354,7 +1385,7 @@
1354
1385
 
1355
1386
  var hop = Object.prototype.hasOwnProperty;
1356
1387
 
1357
- var has = function has(obj, prop) {
1388
+ var has = function (obj, prop) {
1358
1389
  return hop.call(obj, prop);
1359
1390
  }; // Copy all own enumerable properties from source to target
1360
1391
 
@@ -1386,7 +1417,7 @@
1386
1417
  }
1387
1418
 
1388
1419
  var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
1389
- var reMatchIndent = new RegExp(reSource, 'g');
1420
+ var reMatchIndent = new RegExp(reSource, "g");
1390
1421
 
1391
1422
  if (firstInterpolatedValueSetsIndentationLevel) {
1392
1423
  strings = strings.slice(1);
@@ -1395,19 +1426,19 @@
1395
1426
  var newline = options.newline,
1396
1427
  trimLeadingNewline = options.trimLeadingNewline,
1397
1428
  trimTrailingNewline = options.trimTrailingNewline;
1398
- var normalizeNewlines = typeof newline === 'string';
1429
+ var normalizeNewlines = typeof newline === "string";
1399
1430
  var l = strings.length;
1400
1431
  var outdentedStrings = strings.map(function (v, i) {
1401
1432
  // Remove leading indentation from all lines
1402
- v = v.replace(reMatchIndent, '$1'); // Trim a leading newline from the first string
1433
+ v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
1403
1434
 
1404
1435
  if (i === 0 && trimLeadingNewline) {
1405
- v = v.replace(reLeadingNewline, '');
1436
+ v = v.replace(reLeadingNewline, "");
1406
1437
  } // Trim a trailing newline from the last string
1407
1438
 
1408
1439
 
1409
1440
  if (i === l - 1 && trimTrailingNewline) {
1410
- v = v.replace(reTrailingNewline, '');
1441
+ v = v.replace(reTrailingNewline, "");
1411
1442
  } // Normalize newlines
1412
1443
 
1413
1444
 
@@ -1423,7 +1454,7 @@
1423
1454
  }
1424
1455
 
1425
1456
  function concatStringsAndValues(strings, values) {
1426
- var ret = '';
1457
+ var ret = "";
1427
1458
 
1428
1459
  for (var i = 0, l = strings.length; i < l; i++) {
1429
1460
  ret += strings[i];
@@ -1437,7 +1468,7 @@
1437
1468
  }
1438
1469
 
1439
1470
  function isTemplateStringsArray(v) {
1440
- return has(v, 'raw') && has(v, 'length');
1471
+ return has(v, "raw") && has(v, "length");
1441
1472
  }
1442
1473
  /**
1443
1474
  * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
@@ -1451,9 +1482,9 @@
1451
1482
  /** Cache of pre-processed template literal arrays */
1452
1483
  var arrayAutoIndentCache = createWeakMap();
1453
1484
  /**
1454
- * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
1455
- * before interpolated values are injected.
1456
- */
1485
+ * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
1486
+ * before interpolated values are injected.
1487
+ */
1457
1488
 
1458
1489
  var arrayFirstInterpSetsIndentCache = createWeakMap();
1459
1490
 
@@ -1496,7 +1527,7 @@
1496
1527
  }
1497
1528
 
1498
1529
  var fullOutdent = extend(outdent, {
1499
- string: function string(str) {
1530
+ string: function (str) {
1500
1531
  return _outdentArray([str], false, options)[0];
1501
1532
  }
1502
1533
  });
@@ -1517,7 +1548,7 @@
1517
1548
  // so we fail gracefully.
1518
1549
  try {
1519
1550
  module.exports = defaultOutdent;
1520
- Object.defineProperty(defaultOutdent, '__esModule', {
1551
+ Object.defineProperty(defaultOutdent, "__esModule", {
1521
1552
  value: true
1522
1553
  });
1523
1554
  defaultOutdent.default = defaultOutdent;
@@ -1526,65 +1557,7 @@
1526
1557
  }
1527
1558
  });
1528
1559
 
1529
- function _templateObject6() {
1530
- const data = _taggedTemplateLiteral(["\n Require either '@prettier' or '@format' to be present in the file's first docblock comment\n in order for it to be formatted.\n "]);
1531
-
1532
- _templateObject6 = function _templateObject6() {
1533
- return data;
1534
- };
1535
-
1536
- return data;
1537
- }
1538
-
1539
- function _templateObject5() {
1540
- const data = _taggedTemplateLiteral(["\n Format code starting at a given character offset.\n The range will extend backwards to the start of the first line containing the selected statement.\n This option cannot be used with --cursor-offset.\n "]);
1541
-
1542
- _templateObject5 = function _templateObject5() {
1543
- return data;
1544
- };
1545
-
1546
- return data;
1547
- }
1548
-
1549
- function _templateObject4() {
1550
- const data = _taggedTemplateLiteral(["\n Format code ending at a given character offset (exclusive).\n The range will extend forwards to the end of the selected statement.\n This option cannot be used with --cursor-offset.\n "]);
1551
-
1552
- _templateObject4 = function _templateObject4() {
1553
- return data;
1554
- };
1555
-
1556
- return data;
1557
- }
1558
-
1559
- function _templateObject3() {
1560
- const data = _taggedTemplateLiteral(["\n Custom directory that contains prettier plugins in node_modules subdirectory.\n Overrides default behavior when plugins are searched relatively to the location of Prettier.\n Multiple values are accepted.\n "]);
1561
-
1562
- _templateObject3 = function _templateObject3() {
1563
- return data;
1564
- };
1565
-
1566
- return data;
1567
- }
1568
-
1569
- function _templateObject2() {
1570
- const data = _taggedTemplateLiteral(["\n Maintain existing\n (mixed values within one file are normalised by looking at what's used after the first line)\n "]);
1571
-
1572
- _templateObject2 = function _templateObject2() {
1573
- return data;
1574
- };
1575
-
1576
- return data;
1577
- }
1578
-
1579
- function _templateObject() {
1580
- const data = _taggedTemplateLiteral(["\n Print (to stderr) where a cursor at the given position would move to after formatting.\n This option cannot be used with --range-start and --range-end.\n "]);
1581
-
1582
- _templateObject = function _templateObject() {
1583
- return data;
1584
- };
1585
-
1586
- return data;
1587
- }
1560
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
1588
1561
 
1589
1562
  const {
1590
1563
  outdent
@@ -1643,10 +1616,10 @@
1643
1616
  default: -1,
1644
1617
  range: {
1645
1618
  start: -1,
1646
- end: Infinity,
1619
+ end: Number.POSITIVE_INFINITY,
1647
1620
  step: 1
1648
1621
  },
1649
- description: outdent(_templateObject()),
1622
+ description: outdent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n Print (to stderr) where a cursor at the given position would move to after formatting.\n This option cannot be used with --range-start and --range-end.\n "]))),
1650
1623
  cliCategory: CATEGORY_EDITOR
1651
1624
  },
1652
1625
  endOfLine: {
@@ -1672,7 +1645,7 @@
1672
1645
  description: "Carriage Return character only (\\r), used very rarely"
1673
1646
  }, {
1674
1647
  value: "auto",
1675
- description: outdent(_templateObject2())
1648
+ description: outdent(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n Maintain existing\n (mixed values within one file are normalised by looking at what's used after the first line)\n "])))
1676
1649
  }]
1677
1650
  },
1678
1651
  filepath: {
@@ -1724,6 +1697,14 @@
1724
1697
  value: "typescript",
1725
1698
  since: "1.4.0",
1726
1699
  description: "TypeScript"
1700
+ }, {
1701
+ value: "espree",
1702
+ since: "2.2.0",
1703
+ description: "JavaScript"
1704
+ }, {
1705
+ value: "meriyah",
1706
+ since: "2.2.0",
1707
+ description: "JavaScript"
1727
1708
  }, {
1728
1709
  value: "css",
1729
1710
  since: "1.7.1",
@@ -1770,8 +1751,8 @@
1770
1751
  description: "YAML"
1771
1752
  }, {
1772
1753
  value: "glimmer",
1773
- since: null,
1774
- description: "Handlebars"
1754
+ since: "2.3.0",
1755
+ description: "Ember / Handlebars"
1775
1756
  }, {
1776
1757
  value: "html",
1777
1758
  since: "1.15.0",
@@ -1807,7 +1788,7 @@
1807
1788
  value: []
1808
1789
  }],
1809
1790
  category: CATEGORY_GLOBAL,
1810
- description: outdent(_templateObject3()),
1791
+ description: outdent(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n Custom directory that contains prettier plugins in node_modules subdirectory.\n Overrides default behavior when plugins are searched relatively to the location of Prettier.\n Multiple values are accepted.\n "]))),
1811
1792
  exception: value => typeof value === "string" || typeof value === "object",
1812
1793
  cliName: "plugin-search-dir",
1813
1794
  cliCategory: CATEGORY_CONFIG
@@ -1820,7 +1801,7 @@
1820
1801
  description: "The line length where Prettier will try wrap.",
1821
1802
  range: {
1822
1803
  start: 0,
1823
- end: Infinity,
1804
+ end: Number.POSITIVE_INFINITY,
1824
1805
  step: 1
1825
1806
  }
1826
1807
  },
@@ -1828,13 +1809,13 @@
1828
1809
  since: "1.4.0",
1829
1810
  category: CATEGORY_SPECIAL,
1830
1811
  type: "int",
1831
- default: Infinity,
1812
+ default: Number.POSITIVE_INFINITY,
1832
1813
  range: {
1833
1814
  start: 0,
1834
- end: Infinity,
1815
+ end: Number.POSITIVE_INFINITY,
1835
1816
  step: 1
1836
1817
  },
1837
- description: outdent(_templateObject4()),
1818
+ description: outdent(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n Format code ending at a given character offset (exclusive).\n The range will extend forwards to the end of the selected statement.\n This option cannot be used with --cursor-offset.\n "]))),
1838
1819
  cliCategory: CATEGORY_EDITOR
1839
1820
  },
1840
1821
  rangeStart: {
@@ -1844,10 +1825,10 @@
1844
1825
  default: 0,
1845
1826
  range: {
1846
1827
  start: 0,
1847
- end: Infinity,
1828
+ end: Number.POSITIVE_INFINITY,
1848
1829
  step: 1
1849
1830
  },
1850
- description: outdent(_templateObject5()),
1831
+ description: outdent(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n Format code starting at a given character offset.\n The range will extend backwards to the start of the first line containing the selected statement.\n This option cannot be used with --cursor-offset.\n "]))),
1851
1832
  cliCategory: CATEGORY_EDITOR
1852
1833
  },
1853
1834
  requirePragma: {
@@ -1855,7 +1836,7 @@
1855
1836
  category: CATEGORY_SPECIAL,
1856
1837
  type: "boolean",
1857
1838
  default: false,
1858
- description: outdent(_templateObject6()),
1839
+ description: outdent(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n Require either '@prettier' or '@format' to be present in the file's first docblock comment\n in order for it to be formatted.\n "]))),
1859
1840
  cliCategory: CATEGORY_OTHER
1860
1841
  },
1861
1842
  tabWidth: {
@@ -1865,7 +1846,7 @@
1865
1846
  description: "Number of spaces per indentation level.",
1866
1847
  range: {
1867
1848
  start: 0,
1868
- end: Infinity,
1849
+ end: Number.POSITIVE_INFINITY,
1869
1850
  step: 1
1870
1851
  }
1871
1852
  },
@@ -1894,7 +1875,7 @@
1894
1875
  }]
1895
1876
  }
1896
1877
  };
1897
- var coreOptions = {
1878
+ var coreOptions$1 = {
1898
1879
  CATEGORY_CONFIG,
1899
1880
  CATEGORY_EDITOR,
1900
1881
  CATEGORY_FORMAT,
@@ -1905,15 +1886,13 @@
1905
1886
  options
1906
1887
  };
1907
1888
 
1908
- var require$$3 = getCjsExportFromNamespace(_package$1);
1909
-
1910
- const semver$1 = {
1889
+ const semver = {
1911
1890
  compare: compare_1,
1912
1891
  lt: lt_1,
1913
1892
  gte: gte_1
1914
1893
  };
1915
1894
  const currentVersion = require$$3.version;
1916
- const coreOptions$1 = coreOptions.options;
1895
+ const coreOptions = coreOptions$1.options;
1917
1896
  /**
1918
1897
  * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
1919
1898
  * of this function created by `withPlugins`. Don't pass them here directly.
@@ -1925,7 +1904,7 @@
1925
1904
  * @param {boolean=} param0.showInternal
1926
1905
  */
1927
1906
 
1928
- function getSupportInfo({
1907
+ function getSupportInfo$1({
1929
1908
  plugins = [],
1930
1909
  showUnreleased = false,
1931
1910
  showDeprecated = false,
@@ -1934,14 +1913,14 @@
1934
1913
  // pre-release version is smaller than the normal version in semver,
1935
1914
  // we need to treat it as the normal one so as to test new features.
1936
1915
  const version = currentVersion.split("-", 1)[0];
1937
- const languages = plugins.reduce((all, plugin) => all.concat(plugin.languages || []), []).filter(filterSince);
1916
+ const languages = plugins.reduce((all, plugin) => [...all, ...(plugin.languages || [])], []).filter(filterSince);
1938
1917
  const options = arrayify(Object.assign({}, ...plugins.map(({
1939
1918
  options
1940
- }) => options), coreOptions$1), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
1919
+ }) => options), coreOptions), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
1941
1920
  option = Object.assign({}, option);
1942
1921
 
1943
1922
  if (Array.isArray(option.default)) {
1944
- option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$1.compare(info2.since, info1.since))[0].value;
1923
+ option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver.compare(info2.since, info1.since))[0].value;
1945
1924
  }
1946
1925
 
1947
1926
  if (Array.isArray(option.choices)) {
@@ -1952,10 +1931,7 @@
1952
1931
  }
1953
1932
  }
1954
1933
 
1955
- const pluginDefaults = plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).reduce((reduced, plugin) => {
1956
- reduced[plugin.name] = plugin.defaultOptions[option.name];
1957
- return reduced;
1958
- }, {});
1934
+ const pluginDefaults = fromPairs_1(plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).map(plugin => [plugin.name, plugin.defaultOptions[option.name]]));
1959
1935
  return Object.assign({}, option, {
1960
1936
  pluginDefaults
1961
1937
  });
@@ -1966,11 +1942,11 @@
1966
1942
  };
1967
1943
 
1968
1944
  function filterSince(object) {
1969
- return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since);
1945
+ return showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
1970
1946
  }
1971
1947
 
1972
1948
  function filterDeprecated(object) {
1973
- return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated);
1949
+ return showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
1974
1950
  }
1975
1951
 
1976
1952
  function mapInternal(object) {
@@ -2010,9 +1986,12 @@
2010
1986
  }
2011
1987
 
2012
1988
  var support = {
2013
- getSupportInfo
1989
+ getSupportInfo: getSupportInfo$1
2014
1990
  };
2015
1991
 
1992
+ const {
1993
+ getSupportInfo
1994
+ } = support;
2016
1995
  const notAsciiRegex = /[^\x20-\x7F]/;
2017
1996
 
2018
1997
  const getPenultimate = arr => arr[arr.length - 2];
@@ -2183,8 +2162,7 @@
2183
2162
  */
2184
2163
 
2185
2164
 
2186
- function hasNewline(text, index, opts) {
2187
- opts = opts || {};
2165
+ function hasNewline(text, index, opts = {}) {
2188
2166
  const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
2189
2167
  const idx2 = skipNewline(text, idx, opts);
2190
2168
  return idx !== idx2;
@@ -2330,8 +2308,7 @@
2330
2308
  */
2331
2309
 
2332
2310
 
2333
- function hasSpaces(text, index, opts) {
2334
- opts = opts || {};
2311
+ function hasSpaces(text, index, opts = {}) {
2335
2312
  const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
2336
2313
  return idx !== index;
2337
2314
  }
@@ -2343,8 +2320,7 @@
2343
2320
  */
2344
2321
 
2345
2322
 
2346
- function getAlignmentSize(value, tabWidth, startIndex) {
2347
- startIndex = startIndex || 0;
2323
+ function getAlignmentSize(value, tabWidth, startIndex = 0) {
2348
2324
  let size = 0;
2349
2325
 
2350
2326
  for (let i = startIndex; i < value.length; ++i) {
@@ -2421,33 +2397,18 @@
2421
2397
  return result;
2422
2398
  }
2423
2399
 
2424
- function printString(raw, options, isDirectiveLiteral) {
2400
+ function printString(raw, options) {
2425
2401
  // `rawContent` is the string exactly like it appeared in the input source
2426
2402
  // code, without its enclosing quotes.
2427
- const rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
2428
- // the quotes on a DirectiveLiteral.
2429
-
2430
- const canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
2403
+ const rawContent = raw.slice(1, -1);
2431
2404
  /** @type {Quote} */
2432
2405
 
2433
- const enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't
2434
- // change the escape sequences they use.
2435
- // See https://github.com/prettier/prettier/issues/1555
2436
- // and https://tc39.github.io/ecma262/#directive-prologue
2437
-
2438
- if (isDirectiveLiteral) {
2439
- if (canChangeDirectiveQuotes) {
2440
- return enclosingQuote + rawContent + enclosingQuote;
2441
- }
2442
-
2443
- return raw;
2444
- } // It might sound unnecessary to use `makeString` even if the string already
2406
+ const enclosingQuote = options.parser === "json" || options.parser === "json5" && options.quoteProps === "preserve" && !options.singleQuote ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // It might sound unnecessary to use `makeString` even if the string already
2445
2407
  // is enclosed with `enclosingQuote`, but it isn't. The string could contain
2446
2408
  // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
2447
2409
  // sure that we consistently output the minimum amount of escaped quotes.
2448
2410
 
2449
-
2450
- return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml));
2411
+ return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.__embeddedInHtml));
2451
2412
  }
2452
2413
  /**
2453
2414
  * @param {string} rawContent
@@ -2547,7 +2508,7 @@
2547
2508
  */
2548
2509
 
2549
2510
 
2550
- function getStringWidth(text) {
2511
+ function getStringWidth$1(text) {
2551
2512
  if (!text) {
2552
2513
  return 0;
2553
2514
  } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
@@ -2560,31 +2521,11 @@
2560
2521
  return stringWidth_1(text);
2561
2522
  }
2562
2523
 
2563
- function hasIgnoreComment(path) {
2564
- const node = path.getValue();
2565
- return hasNodeIgnoreComment(node);
2566
- }
2567
-
2568
- function hasNodeIgnoreComment(node) {
2569
- return node && (node.comments && node.comments.length > 0 && node.comments.some(comment => isNodeIgnoreComment(comment) && !comment.unignore) || node.prettierIgnore);
2570
- }
2571
-
2572
- function isNodeIgnoreComment(comment) {
2573
- return comment.value.trim() === "prettier-ignore";
2574
- }
2575
-
2576
2524
  function addCommentHelper(node, comment) {
2577
2525
  const comments = node.comments || (node.comments = []);
2578
2526
  comments.push(comment);
2579
- comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
2580
- // We already "print" it via the raw text, we don't need to re-print it as a
2581
- // comment
2582
-
2583
- /* istanbul ignore next */
2584
-
2585
- if (node.type === "JSXText") {
2586
- comment.printed = true;
2587
- }
2527
+ comment.printed = false;
2528
+ comment.nodeDescription = describeNodeForDebugging(node);
2588
2529
  }
2589
2530
 
2590
2531
  function addLeadingComment(node, comment) {
@@ -2608,32 +2549,13 @@
2608
2549
  comment.leading = false;
2609
2550
  comment.trailing = true;
2610
2551
  addCommentHelper(node, comment);
2611
- } // Not using
2612
-
2613
- /* istanbul ignore next */
2614
-
2615
-
2616
- function isWithinParentArrayProperty(path, propertyName) {
2617
- const node = path.getValue();
2618
- const parent = path.getParentNode();
2619
-
2620
- if (parent == null) {
2621
- return false;
2622
- }
2623
-
2624
- if (!Array.isArray(parent[propertyName])) {
2625
- return false;
2626
- }
2627
-
2628
- const key = path.getName();
2629
- return parent[propertyName][key] === node;
2630
2552
  }
2631
2553
 
2632
2554
  function replaceEndOfLineWith(text, replacement) {
2633
2555
  const parts = [];
2634
2556
 
2635
2557
  for (const part of text.split("\n")) {
2636
- if (parts.length !== 0) {
2558
+ if (parts.length > 0) {
2637
2559
  parts.push(replacement);
2638
2560
  }
2639
2561
 
@@ -2643,17 +2565,20 @@
2643
2565
  return parts;
2644
2566
  }
2645
2567
 
2646
- function getParserName(lang, options) {
2647
- const supportInfo = support.getSupportInfo({
2568
+ function inferParserByLanguage(language, options) {
2569
+ const {
2570
+ languages
2571
+ } = getSupportInfo({
2648
2572
  plugins: options.plugins
2649
2573
  });
2650
- const language = supportInfo.languages.find(language => language.name.toLowerCase() === lang || language.aliases && language.aliases.includes(lang) || language.extensions && language.extensions.some(ext => ext === ".".concat(lang)));
2651
-
2652
- if (language) {
2653
- return language.parsers[0];
2654
- }
2655
-
2656
- return null;
2574
+ const matched = languages.find(({
2575
+ name
2576
+ }) => name.toLowerCase() === language) || languages.find(({
2577
+ aliases
2578
+ }) => Array.isArray(aliases) && aliases.includes(language)) || languages.find(({
2579
+ extensions
2580
+ }) => Array.isArray(extensions) && extensions.includes(".".concat(language)));
2581
+ return matched && matched.parsers[0];
2657
2582
  }
2658
2583
 
2659
2584
  function isFrontMatterNode(node) {
@@ -2674,14 +2599,45 @@
2674
2599
  return text.slice(0, index);
2675
2600
  }
2676
2601
 
2602
+ function isNonEmptyArray(object) {
2603
+ return Array.isArray(object) && object.length > 0;
2604
+ }
2605
+ /**
2606
+ * @param {string} description
2607
+ * @returns {(node: any) => symbol}
2608
+ */
2609
+
2610
+
2611
+ function createGroupIdMapper(description) {
2612
+ const groupIds = new WeakMap();
2613
+ return function (node) {
2614
+ if (!groupIds.has(node)) {
2615
+ groupIds.set(node, Symbol(description));
2616
+ }
2617
+
2618
+ return groupIds.get(node);
2619
+ };
2620
+ }
2621
+
2622
+ function describeNodeForDebugging(node) {
2623
+ const nodeType = node.type || node.kind || "(unknown type)";
2624
+ let nodeName = String(node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || "");
2625
+
2626
+ if (nodeName.length > 20) {
2627
+ nodeName = nodeName.slice(0, 19) + "…";
2628
+ }
2629
+
2630
+ return nodeType + (nodeName ? " " + nodeName : "");
2631
+ }
2632
+
2677
2633
  var util = {
2634
+ inferParserByLanguage,
2678
2635
  replaceEndOfLineWith,
2679
- getStringWidth,
2636
+ getStringWidth: getStringWidth$1,
2680
2637
  getMaxContinuousCount,
2681
2638
  getMinNotPresentContinuousCount,
2682
- getParserName,
2683
2639
  getPenultimate,
2684
- getLast,
2640
+ getLast: getLast_1,
2685
2641
  getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
2686
2642
  getNextNonSpaceNonCommentCharacterIndex,
2687
2643
  getNextNonSpaceNonCommentCharacter,
@@ -2704,16 +2660,14 @@
2704
2660
  getPreferredQuote,
2705
2661
  printString,
2706
2662
  printNumber,
2707
- hasIgnoreComment,
2708
- hasNodeIgnoreComment,
2709
- isNodeIgnoreComment,
2710
2663
  makeString,
2711
2664
  addLeadingComment,
2712
2665
  addDanglingComment,
2713
2666
  addTrailingComment,
2714
- isWithinParentArrayProperty,
2715
2667
  isFrontMatterNode,
2716
- getShebang
2668
+ getShebang,
2669
+ isNonEmptyArray,
2670
+ createGroupIdMapper
2717
2671
  };
2718
2672
 
2719
2673
  function guessEndOfLine(text) {
@@ -2726,7 +2680,7 @@
2726
2680
  return "lf";
2727
2681
  }
2728
2682
 
2729
- function convertEndOfLineToChars(value) {
2683
+ function convertEndOfLineToChars$1(value) {
2730
2684
  switch (value) {
2731
2685
  case "cr":
2732
2686
  return "\r";
@@ -2763,72 +2717,521 @@
2763
2717
 
2764
2718
  var endOfLine = {
2765
2719
  guessEndOfLine,
2766
- convertEndOfLineToChars,
2720
+ convertEndOfLineToChars: convertEndOfLineToChars$1,
2767
2721
  countEndOfLineChars,
2768
2722
  normalizeEndOfLine
2769
2723
  };
2770
2724
 
2771
2725
  const {
2772
- getStringWidth: getStringWidth$1
2773
- } = util;
2774
- const {
2775
- convertEndOfLineToChars: convertEndOfLineToChars$1
2776
- } = endOfLine;
2777
- const {
2778
- concat: concat$1,
2779
- fill: fill$1,
2780
- cursor: cursor$1
2726
+ literalline
2781
2727
  } = docBuilders;
2782
- /** @type {Record<symbol, typeof MODE_BREAK | typeof MODE_FLAT>} */
2783
2728
 
2784
- let groupModeMap;
2785
- const MODE_BREAK = 1;
2786
- const MODE_FLAT = 2;
2729
+ const isConcat$2 = doc => Array.isArray(doc) || doc && doc.type === "concat";
2787
2730
 
2788
- function rootIndent() {
2789
- return {
2790
- value: "",
2791
- length: 0,
2792
- queue: []
2793
- };
2794
- }
2731
+ const getDocParts$2 = doc => {
2732
+ if (Array.isArray(doc)) {
2733
+ return doc;
2734
+ }
2735
+ /* istanbul ignore next */
2795
2736
 
2796
- function makeIndent(ind, options) {
2797
- return generateInd(ind, {
2798
- type: "indent"
2737
+
2738
+ if (doc.type !== "concat" && doc.type !== "fill") {
2739
+ throw new Error("Expect doc type to be `concat` or `fill`.");
2740
+ }
2741
+
2742
+ return doc.parts;
2743
+ }; // Using a unique object to compare by reference.
2744
+
2745
+
2746
+ const traverseDocOnExitStackMarker = {};
2747
+
2748
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
2749
+ const docsStack = [doc];
2750
+
2751
+ while (docsStack.length > 0) {
2752
+ const doc = docsStack.pop();
2753
+
2754
+ if (doc === traverseDocOnExitStackMarker) {
2755
+ onExit(docsStack.pop());
2756
+ continue;
2757
+ }
2758
+
2759
+ if (onExit) {
2760
+ docsStack.push(doc, traverseDocOnExitStackMarker);
2761
+ }
2762
+
2763
+ if ( // Should Recurse
2764
+ !onEnter || onEnter(doc) !== false) {
2765
+ // When there are multiple parts to process,
2766
+ // the parts need to be pushed onto the stack in reverse order,
2767
+ // so that they are processed in the original order
2768
+ // when the stack is popped.
2769
+ if (isConcat$2(doc) || doc.type === "fill") {
2770
+ const parts = getDocParts$2(doc);
2771
+
2772
+ for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
2773
+ docsStack.push(parts[i]);
2774
+ }
2775
+ } else if (doc.type === "if-break") {
2776
+ if (doc.flatContents) {
2777
+ docsStack.push(doc.flatContents);
2778
+ }
2779
+
2780
+ if (doc.breakContents) {
2781
+ docsStack.push(doc.breakContents);
2782
+ }
2783
+ } else if (doc.type === "group" && doc.expandedStates) {
2784
+ if (shouldTraverseConditionalGroups) {
2785
+ for (let ic = doc.expandedStates.length, i = ic - 1; i >= 0; --i) {
2786
+ docsStack.push(doc.expandedStates[i]);
2787
+ }
2788
+ } else {
2789
+ docsStack.push(doc.contents);
2790
+ }
2791
+ } else if (doc.contents) {
2792
+ docsStack.push(doc.contents);
2793
+ }
2794
+ }
2795
+ }
2796
+ }
2797
+
2798
+ function mapDoc(doc, cb) {
2799
+ // Within a doc tree, the same subtrees can be found multiple times.
2800
+ // E.g., often this happens in conditional groups.
2801
+ // As an optimization (those subtrees can be huge) and to maintain the
2802
+ // reference structure of the tree, the mapping results are cached in
2803
+ // a map and reused.
2804
+ const mapped = new Map();
2805
+ return rec(doc);
2806
+
2807
+ function rec(doc) {
2808
+ if (mapped.has(doc)) {
2809
+ return mapped.get(doc);
2810
+ }
2811
+
2812
+ const result = process(doc);
2813
+ mapped.set(doc, result);
2814
+ return result;
2815
+ }
2816
+
2817
+ function process(doc) {
2818
+ if (Array.isArray(doc)) {
2819
+ return cb(doc.map(rec));
2820
+ }
2821
+
2822
+ if (doc.type === "concat" || doc.type === "fill") {
2823
+ const parts = doc.parts.map(rec);
2824
+ return cb(Object.assign({}, doc, {
2825
+ parts
2826
+ }));
2827
+ }
2828
+
2829
+ if (doc.type === "if-break") {
2830
+ const breakContents = doc.breakContents && rec(doc.breakContents);
2831
+ const flatContents = doc.flatContents && rec(doc.flatContents);
2832
+ return cb(Object.assign({}, doc, {
2833
+ breakContents,
2834
+ flatContents
2835
+ }));
2836
+ }
2837
+
2838
+ if (doc.type === "group" && doc.expandedStates) {
2839
+ const expandedStates = doc.expandedStates.map(rec);
2840
+ const contents = expandedStates[0];
2841
+ return cb(Object.assign({}, doc, {
2842
+ contents,
2843
+ expandedStates
2844
+ }));
2845
+ }
2846
+
2847
+ if (doc.contents) {
2848
+ const contents = rec(doc.contents);
2849
+ return cb(Object.assign({}, doc, {
2850
+ contents
2851
+ }));
2852
+ }
2853
+
2854
+ return cb(doc);
2855
+ }
2856
+ }
2857
+
2858
+ function findInDoc(doc, fn, defaultValue) {
2859
+ let result = defaultValue;
2860
+ let hasStopped = false;
2861
+
2862
+ function findInDocOnEnterFn(doc) {
2863
+ const maybeResult = fn(doc);
2864
+
2865
+ if (maybeResult !== undefined) {
2866
+ hasStopped = true;
2867
+ result = maybeResult;
2868
+ }
2869
+
2870
+ if (hasStopped) {
2871
+ return false;
2872
+ }
2873
+ }
2874
+
2875
+ traverseDoc(doc, findInDocOnEnterFn);
2876
+ return result;
2877
+ }
2878
+
2879
+ function willBreakFn(doc) {
2880
+ if (doc.type === "group" && doc.break) {
2881
+ return true;
2882
+ }
2883
+
2884
+ if (doc.type === "line" && doc.hard) {
2885
+ return true;
2886
+ }
2887
+
2888
+ if (doc.type === "break-parent") {
2889
+ return true;
2890
+ }
2891
+ }
2892
+
2893
+ function willBreak(doc) {
2894
+ return findInDoc(doc, willBreakFn, false);
2895
+ }
2896
+
2897
+ function breakParentGroup(groupStack) {
2898
+ if (groupStack.length > 0) {
2899
+ const parentGroup = getLast_1(groupStack); // Breaks are not propagated through conditional groups because
2900
+ // the user is expected to manually handle what breaks.
2901
+
2902
+ if (!parentGroup.expandedStates && !parentGroup.break) {
2903
+ // An alternative truthy value allows to distinguish propagated group breaks
2904
+ // and not to print them as `group(..., { break: true })` in `--debug-print-doc`.
2905
+ parentGroup.break = "propagated";
2906
+ }
2907
+ }
2908
+
2909
+ return null;
2910
+ }
2911
+
2912
+ function propagateBreaks(doc) {
2913
+ const alreadyVisitedSet = new Set();
2914
+ const groupStack = [];
2915
+
2916
+ function propagateBreaksOnEnterFn(doc) {
2917
+ if (doc.type === "break-parent") {
2918
+ breakParentGroup(groupStack);
2919
+ }
2920
+
2921
+ if (doc.type === "group") {
2922
+ groupStack.push(doc);
2923
+
2924
+ if (alreadyVisitedSet.has(doc)) {
2925
+ return false;
2926
+ }
2927
+
2928
+ alreadyVisitedSet.add(doc);
2929
+ }
2930
+ }
2931
+
2932
+ function propagateBreaksOnExitFn(doc) {
2933
+ if (doc.type === "group") {
2934
+ const group = groupStack.pop();
2935
+
2936
+ if (group.break) {
2937
+ breakParentGroup(groupStack);
2938
+ }
2939
+ }
2940
+ }
2941
+
2942
+ traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
2943
+ /* shouldTraverseConditionalGroups */
2944
+ true);
2945
+ }
2946
+
2947
+ function removeLinesFn(doc) {
2948
+ // Force this doc into flat mode by statically converting all
2949
+ // lines into spaces (or soft lines into nothing). Hard lines
2950
+ // should still output because there's too great of a chance
2951
+ // of breaking existing assumptions otherwise.
2952
+ if (doc.type === "line" && !doc.hard) {
2953
+ return doc.soft ? "" : " ";
2954
+ }
2955
+
2956
+ if (doc.type === "if-break") {
2957
+ return doc.flatContents || "";
2958
+ }
2959
+
2960
+ return doc;
2961
+ }
2962
+
2963
+ function removeLines(doc) {
2964
+ return mapDoc(doc, removeLinesFn);
2965
+ }
2966
+
2967
+ const isHardline = (doc, nextDoc) => doc && doc.type === "line" && doc.hard && nextDoc && nextDoc.type === "break-parent";
2968
+
2969
+ function stripDocTrailingHardlineFromDoc(doc) {
2970
+ if (!doc) {
2971
+ return doc;
2972
+ }
2973
+
2974
+ if (isConcat$2(doc) || doc.type === "fill") {
2975
+ const parts = getDocParts$2(doc);
2976
+
2977
+ while (parts.length > 1 && isHardline(...parts.slice(-2))) {
2978
+ parts.length -= 2;
2979
+ }
2980
+
2981
+ if (parts.length > 0) {
2982
+ const lastPart = stripDocTrailingHardlineFromDoc(getLast_1(parts));
2983
+ parts[parts.length - 1] = lastPart;
2984
+ }
2985
+
2986
+ return Array.isArray(doc) ? parts : Object.assign({}, doc, {
2987
+ parts
2988
+ });
2989
+ }
2990
+
2991
+ switch (doc.type) {
2992
+ case "align":
2993
+ case "indent":
2994
+ case "indent-if-break":
2995
+ case "group":
2996
+ case "line-suffix":
2997
+ case "label":
2998
+ {
2999
+ const contents = stripDocTrailingHardlineFromDoc(doc.contents);
3000
+ return Object.assign({}, doc, {
3001
+ contents
3002
+ });
3003
+ }
3004
+
3005
+ case "if-break":
3006
+ {
3007
+ const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
3008
+ const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
3009
+ return Object.assign({}, doc, {
3010
+ breakContents,
3011
+ flatContents
3012
+ });
3013
+ }
3014
+ }
3015
+
3016
+ return doc;
3017
+ }
3018
+
3019
+ function stripTrailingHardline(doc) {
3020
+ // HACK remove ending hardline, original PR: #1984
3021
+ return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
3022
+ }
3023
+
3024
+ function cleanDocFn(doc) {
3025
+ switch (doc.type) {
3026
+ case "fill":
3027
+ if (doc.parts.length === 0 || doc.parts.every(part => part === "")) {
3028
+ return "";
3029
+ }
3030
+
3031
+ break;
3032
+
3033
+ case "group":
3034
+ if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
3035
+ return "";
3036
+ } // Remove nested only group
3037
+
3038
+
3039
+ if (doc.contents.type === "group" && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
3040
+ return doc.contents;
3041
+ }
3042
+
3043
+ break;
3044
+
3045
+ case "align":
3046
+ case "indent":
3047
+ case "indent-if-break":
3048
+ case "line-suffix":
3049
+ if (!doc.contents) {
3050
+ return "";
3051
+ }
3052
+
3053
+ break;
3054
+
3055
+ case "if-break":
3056
+ if (!doc.flatContents && !doc.breakContents) {
3057
+ return "";
3058
+ }
3059
+
3060
+ break;
3061
+ }
3062
+
3063
+ if (!isConcat$2(doc)) {
3064
+ return doc;
3065
+ }
3066
+
3067
+ const parts = [];
3068
+
3069
+ for (const part of getDocParts$2(doc)) {
3070
+ if (!part) {
3071
+ continue;
3072
+ }
3073
+
3074
+ const [currentPart, ...restParts] = isConcat$2(part) ? getDocParts$2(part) : [part];
3075
+
3076
+ if (typeof currentPart === "string" && typeof getLast_1(parts) === "string") {
3077
+ parts[parts.length - 1] += currentPart;
3078
+ } else {
3079
+ parts.push(currentPart);
3080
+ }
3081
+
3082
+ parts.push(...restParts);
3083
+ }
3084
+
3085
+ if (parts.length === 0) {
3086
+ return "";
3087
+ }
3088
+
3089
+ if (parts.length === 1) {
3090
+ return parts[0];
3091
+ }
3092
+
3093
+ return Array.isArray(doc) ? parts : Object.assign({}, doc, {
3094
+ parts
3095
+ });
3096
+ } // A safer version of `normalizeDoc`
3097
+ // - `normalizeDoc` concat strings and flat "concat" in `fill`, while `cleanDoc` don't
3098
+ // - On `concat` object, `normalizeDoc` always return object with `parts`, `cleanDoc` may return strings
3099
+ // - `cleanDoc` also remove nested `group`s and empty `fill`/`align`/`indent`/`line-suffix`/`if-break` if possible
3100
+
3101
+
3102
+ function cleanDoc(doc) {
3103
+ return mapDoc(doc, currentDoc => cleanDocFn(currentDoc));
3104
+ }
3105
+
3106
+ function normalizeParts(parts) {
3107
+ const newParts = [];
3108
+ const restParts = parts.filter(Boolean);
3109
+
3110
+ while (restParts.length > 0) {
3111
+ const part = restParts.shift();
3112
+
3113
+ if (!part) {
3114
+ continue;
3115
+ }
3116
+
3117
+ if (isConcat$2(part)) {
3118
+ restParts.unshift(...getDocParts$2(part));
3119
+ continue;
3120
+ }
3121
+
3122
+ if (newParts.length > 0 && typeof getLast_1(newParts) === "string" && typeof part === "string") {
3123
+ newParts[newParts.length - 1] += part;
3124
+ continue;
3125
+ }
3126
+
3127
+ newParts.push(part);
3128
+ }
3129
+
3130
+ return newParts;
3131
+ }
3132
+
3133
+ function normalizeDoc(doc) {
3134
+ return mapDoc(doc, currentDoc => {
3135
+ if (Array.isArray(currentDoc)) {
3136
+ return normalizeParts(currentDoc);
3137
+ }
3138
+
3139
+ if (!currentDoc.parts) {
3140
+ return currentDoc;
3141
+ }
3142
+
3143
+ return Object.assign({}, currentDoc, {
3144
+ parts: normalizeParts(currentDoc.parts)
3145
+ });
3146
+ });
3147
+ }
3148
+
3149
+ function replaceNewlinesWithLiterallines(doc) {
3150
+ return mapDoc(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline) : currentDoc);
3151
+ }
3152
+
3153
+ var docUtils = {
3154
+ isConcat: isConcat$2,
3155
+ getDocParts: getDocParts$2,
3156
+ willBreak,
3157
+ traverseDoc,
3158
+ findInDoc,
3159
+ mapDoc,
3160
+ propagateBreaks,
3161
+ removeLines,
3162
+ stripTrailingHardline,
3163
+ normalizeParts,
3164
+ normalizeDoc,
3165
+ cleanDoc,
3166
+ replaceNewlinesWithLiterallines
3167
+ };
3168
+
3169
+ const {
3170
+ getStringWidth,
3171
+ getLast
3172
+ } = util;
3173
+ const {
3174
+ convertEndOfLineToChars
3175
+ } = endOfLine;
3176
+ const {
3177
+ fill,
3178
+ cursor,
3179
+ indent
3180
+ } = docBuilders;
3181
+ const {
3182
+ isConcat: isConcat$1,
3183
+ getDocParts: getDocParts$1
3184
+ } = docUtils;
3185
+ /** @type {Record<symbol, typeof MODE_BREAK | typeof MODE_FLAT>} */
3186
+
3187
+ let groupModeMap;
3188
+ const MODE_BREAK = 1;
3189
+ const MODE_FLAT = 2;
3190
+
3191
+ function rootIndent() {
3192
+ return {
3193
+ value: "",
3194
+ length: 0,
3195
+ queue: []
3196
+ };
3197
+ }
3198
+
3199
+ function makeIndent(ind, options) {
3200
+ return generateInd(ind, {
3201
+ type: "indent"
2799
3202
  }, options);
2800
3203
  }
2801
3204
 
2802
- function makeAlign(indent, n, options) {
2803
- if (n === -Infinity) {
3205
+ function makeAlign(indent, widthOrDoc, options) {
3206
+ if (widthOrDoc === Number.NEGATIVE_INFINITY) {
2804
3207
  return indent.root || rootIndent();
2805
3208
  }
2806
3209
 
2807
- if (n < 0) {
3210
+ if (widthOrDoc < 0) {
2808
3211
  return generateInd(indent, {
2809
3212
  type: "dedent"
2810
3213
  }, options);
2811
3214
  }
2812
3215
 
2813
- if (!n) {
3216
+ if (!widthOrDoc) {
2814
3217
  return indent;
2815
3218
  }
2816
3219
 
2817
- if (n.type === "root") {
3220
+ if (widthOrDoc.type === "root") {
2818
3221
  return Object.assign({}, indent, {
2819
3222
  root: indent
2820
3223
  });
2821
3224
  }
2822
3225
 
2823
- const alignType = typeof n === "string" ? "stringAlign" : "numberAlign";
3226
+ const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
2824
3227
  return generateInd(indent, {
2825
3228
  type: alignType,
2826
- n
3229
+ n: widthOrDoc
2827
3230
  }, options);
2828
3231
  }
2829
3232
 
2830
3233
  function generateInd(ind, newPart, options) {
2831
- const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
3234
+ const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
2832
3235
  let value = "";
2833
3236
  let length = 0;
2834
3237
  let lastTabs = 0;
@@ -2912,27 +3315,27 @@
2912
3315
  }
2913
3316
  }
2914
3317
 
2915
- function trim$1(out) {
3318
+ function trim(out) {
2916
3319
  if (out.length === 0) {
2917
3320
  return 0;
2918
3321
  }
2919
3322
 
2920
3323
  let trimCount = 0; // Trim whitespace at the end of line
2921
3324
 
2922
- while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[\t ]*$/)) {
3325
+ while (out.length > 0 && typeof getLast(out) === "string" && /^[\t ]*$/.test(getLast(out))) {
2923
3326
  trimCount += out.pop().length;
2924
3327
  }
2925
3328
 
2926
- if (out.length && typeof out[out.length - 1] === "string") {
2927
- const trimmed = out[out.length - 1].replace(/[\t ]*$/, "");
2928
- trimCount += out[out.length - 1].length - trimmed.length;
3329
+ if (out.length > 0 && typeof getLast(out) === "string") {
3330
+ const trimmed = getLast(out).replace(/[\t ]*$/, "");
3331
+ trimCount += getLast(out).length - trimmed.length;
2929
3332
  out[out.length - 1] = trimmed;
2930
3333
  }
2931
3334
 
2932
3335
  return trimCount;
2933
3336
  }
2934
3337
 
2935
- function fits(next, restCommands, width, options, mustBeFlat) {
3338
+ function fits(next, restCommands, width, options, hasLineSuffix, mustBeFlat) {
2936
3339
  let restIdx = restCommands.length;
2937
3340
  const cmds = [next]; // `out` is only used for width counting because `trim` requires to look
2938
3341
  // backwards for space characters.
@@ -2954,16 +3357,15 @@
2954
3357
 
2955
3358
  if (typeof doc === "string") {
2956
3359
  out.push(doc);
2957
- width -= getStringWidth$1(doc);
3360
+ width -= getStringWidth(doc);
3361
+ } else if (isConcat$1(doc)) {
3362
+ const parts = getDocParts$1(doc);
3363
+
3364
+ for (let i = parts.length - 1; i >= 0; i--) {
3365
+ cmds.push([ind, mode, parts[i]]);
3366
+ }
2958
3367
  } else {
2959
3368
  switch (doc.type) {
2960
- case "concat":
2961
- for (let i = doc.parts.length - 1; i >= 0; i--) {
2962
- cmds.push([ind, mode, doc.parts[i]]);
2963
- }
2964
-
2965
- break;
2966
-
2967
3369
  case "indent":
2968
3370
  cmds.push([makeIndent(ind, options), mode, doc.contents]);
2969
3371
  break;
@@ -2973,21 +3375,25 @@
2973
3375
  break;
2974
3376
 
2975
3377
  case "trim":
2976
- width += trim$1(out);
3378
+ width += trim(out);
2977
3379
  break;
2978
3380
 
2979
3381
  case "group":
2980
- if (mustBeFlat && doc.break) {
2981
- return false;
2982
- }
3382
+ {
3383
+ if (mustBeFlat && doc.break) {
3384
+ return false;
3385
+ }
2983
3386
 
2984
- cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
3387
+ const groupMode = doc.break ? MODE_BREAK : mode;
3388
+ cmds.push([ind, groupMode, // The most expanded state takes up the least space on the current line.
3389
+ doc.expandedStates && groupMode === MODE_BREAK ? getLast(doc.expandedStates) : doc.contents]);
2985
3390
 
2986
- if (doc.id) {
2987
- groupModeMap[doc.id] = cmds[cmds.length - 1][1];
2988
- }
3391
+ if (doc.id) {
3392
+ groupModeMap[doc.id] = groupMode;
3393
+ }
2989
3394
 
2990
- break;
3395
+ break;
3396
+ }
2991
3397
 
2992
3398
  case "fill":
2993
3399
  for (let i = doc.parts.length - 1; i >= 0; i--) {
@@ -2997,18 +3403,23 @@
2997
3403
  break;
2998
3404
 
2999
3405
  case "if-break":
3406
+ case "indent-if-break":
3000
3407
  {
3001
3408
  const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
3002
3409
 
3003
3410
  if (groupMode === MODE_BREAK) {
3004
- if (doc.breakContents) {
3005
- cmds.push([ind, mode, doc.breakContents]);
3411
+ const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
3412
+
3413
+ if (breakContents) {
3414
+ cmds.push([ind, mode, breakContents]);
3006
3415
  }
3007
3416
  }
3008
3417
 
3009
3418
  if (groupMode === MODE_FLAT) {
3010
- if (doc.flatContents) {
3011
- cmds.push([ind, mode, doc.flatContents]);
3419
+ const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
3420
+
3421
+ if (flatContents) {
3422
+ cmds.push([ind, mode, flatContents]);
3012
3423
  }
3013
3424
  }
3014
3425
 
@@ -3035,6 +3446,21 @@
3035
3446
  }
3036
3447
 
3037
3448
  break;
3449
+
3450
+ case "line-suffix":
3451
+ hasLineSuffix = true;
3452
+ break;
3453
+
3454
+ case "line-suffix-boundary":
3455
+ if (hasLineSuffix) {
3456
+ return false;
3457
+ }
3458
+
3459
+ break;
3460
+
3461
+ case "label":
3462
+ cmds.push([ind, mode, doc.contents]);
3463
+ break;
3038
3464
  }
3039
3465
  }
3040
3466
  }
@@ -3045,7 +3471,7 @@
3045
3471
  function printDocToString(doc, options) {
3046
3472
  groupModeMap = {};
3047
3473
  const width = options.printWidth;
3048
- const newLine = convertEndOfLineToChars$1(options.endOfLine);
3474
+ const newLine = convertEndOfLineToChars(options.endOfLine);
3049
3475
  let pos = 0; // cmds is basically a stack. We've turned a recursive call into a
3050
3476
  // while loop which is much faster. The while loop below adds new
3051
3477
  // cmds to the array instead of recursively calling `print`.
@@ -3055,24 +3481,23 @@
3055
3481
  let shouldRemeasure = false;
3056
3482
  let lineSuffix = [];
3057
3483
 
3058
- while (cmds.length !== 0) {
3484
+ while (cmds.length > 0) {
3059
3485
  const [ind, mode, doc] = cmds.pop();
3060
3486
 
3061
3487
  if (typeof doc === "string") {
3062
- const formatted = newLine !== "\n" && doc.includes("\n") ? doc.replace(/\n/g, newLine) : doc;
3488
+ const formatted = newLine !== "\n" ? doc.replace(/\n/g, newLine) : doc;
3063
3489
  out.push(formatted);
3064
- pos += getStringWidth$1(formatted);
3490
+ pos += getStringWidth(formatted);
3491
+ } else if (isConcat$1(doc)) {
3492
+ const parts = getDocParts$1(doc);
3493
+
3494
+ for (let i = parts.length - 1; i >= 0; i--) {
3495
+ cmds.push([ind, mode, parts[i]]);
3496
+ }
3065
3497
  } else {
3066
3498
  switch (doc.type) {
3067
3499
  case "cursor":
3068
- out.push(cursor$1.placeholder);
3069
- break;
3070
-
3071
- case "concat":
3072
- for (let i = doc.parts.length - 1; i >= 0; i--) {
3073
- cmds.push([ind, mode, doc.parts[i]]);
3074
- }
3075
-
3500
+ out.push(cursor.placeholder);
3076
3501
  break;
3077
3502
 
3078
3503
  case "indent":
@@ -3084,7 +3509,7 @@
3084
3509
  break;
3085
3510
 
3086
3511
  case "trim":
3087
- pos -= trim$1(out);
3512
+ pos -= trim(out);
3088
3513
  break;
3089
3514
 
3090
3515
  case "group":
@@ -3102,8 +3527,9 @@
3102
3527
  shouldRemeasure = false;
3103
3528
  const next = [ind, MODE_FLAT, doc.contents];
3104
3529
  const rem = width - pos;
3530
+ const hasLineSuffix = lineSuffix.length > 0;
3105
3531
 
3106
- if (!doc.break && fits(next, cmds, rem, options)) {
3532
+ if (!doc.break && fits(next, cmds, rem, options, hasLineSuffix)) {
3107
3533
  cmds.push(next);
3108
3534
  } else {
3109
3535
  // Expanded states are a rare case where a document
@@ -3114,7 +3540,7 @@
3114
3540
  // group has these, we need to manually go through
3115
3541
  // these states and find the first one that fits.
3116
3542
  if (doc.expandedStates) {
3117
- const mostExpanded = doc.expandedStates[doc.expandedStates.length - 1];
3543
+ const mostExpanded = getLast(doc.expandedStates);
3118
3544
 
3119
3545
  if (doc.break) {
3120
3546
  cmds.push([ind, MODE_BREAK, mostExpanded]);
@@ -3128,7 +3554,7 @@
3128
3554
  const state = doc.expandedStates[i];
3129
3555
  const cmd = [ind, MODE_FLAT, state];
3130
3556
 
3131
- if (fits(cmd, cmds, rem, options)) {
3557
+ if (fits(cmd, cmds, rem, options, hasLineSuffix)) {
3132
3558
  cmds.push(cmd);
3133
3559
  break;
3134
3560
  }
@@ -3145,7 +3571,7 @@
3145
3571
  }
3146
3572
 
3147
3573
  if (doc.id) {
3148
- groupModeMap[doc.id] = cmds[cmds.length - 1][1];
3574
+ groupModeMap[doc.id] = getLast(cmds)[1];
3149
3575
  }
3150
3576
 
3151
3577
  break;
@@ -3184,7 +3610,7 @@
3184
3610
  const [content, whitespace] = parts;
3185
3611
  const contentFlatCmd = [ind, MODE_FLAT, content];
3186
3612
  const contentBreakCmd = [ind, MODE_BREAK, content];
3187
- const contentFits = fits(contentFlatCmd, [], rem, options, true);
3613
+ const contentFits = fits(contentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
3188
3614
 
3189
3615
  if (parts.length === 1) {
3190
3616
  if (contentFits) {
@@ -3201,11 +3627,9 @@
3201
3627
 
3202
3628
  if (parts.length === 2) {
3203
3629
  if (contentFits) {
3204
- cmds.push(whitespaceFlatCmd);
3205
- cmds.push(contentFlatCmd);
3630
+ cmds.push(whitespaceFlatCmd, contentFlatCmd);
3206
3631
  } else {
3207
- cmds.push(whitespaceBreakCmd);
3208
- cmds.push(contentBreakCmd);
3632
+ cmds.push(whitespaceBreakCmd, contentBreakCmd);
3209
3633
  }
3210
3634
 
3211
3635
  break;
@@ -3217,41 +3641,40 @@
3217
3641
 
3218
3642
 
3219
3643
  parts.splice(0, 2);
3220
- const remainingCmd = [ind, mode, fill$1(parts)];
3644
+ const remainingCmd = [ind, mode, fill(parts)];
3221
3645
  const secondContent = parts[0];
3222
- const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$1([content, whitespace, secondContent])];
3223
- const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, true);
3646
+ const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content, whitespace, secondContent]];
3647
+ const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
3224
3648
 
3225
3649
  if (firstAndSecondContentFits) {
3226
- cmds.push(remainingCmd);
3227
- cmds.push(whitespaceFlatCmd);
3228
- cmds.push(contentFlatCmd);
3650
+ cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
3229
3651
  } else if (contentFits) {
3230
- cmds.push(remainingCmd);
3231
- cmds.push(whitespaceBreakCmd);
3232
- cmds.push(contentFlatCmd);
3652
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
3233
3653
  } else {
3234
- cmds.push(remainingCmd);
3235
- cmds.push(whitespaceBreakCmd);
3236
- cmds.push(contentBreakCmd);
3654
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
3237
3655
  }
3238
3656
 
3239
3657
  break;
3240
3658
  }
3241
3659
 
3242
3660
  case "if-break":
3661
+ case "indent-if-break":
3243
3662
  {
3244
3663
  const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
3245
3664
 
3246
3665
  if (groupMode === MODE_BREAK) {
3247
- if (doc.breakContents) {
3248
- cmds.push([ind, mode, doc.breakContents]);
3666
+ const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
3667
+
3668
+ if (breakContents) {
3669
+ cmds.push([ind, mode, breakContents]);
3249
3670
  }
3250
3671
  }
3251
3672
 
3252
3673
  if (groupMode === MODE_FLAT) {
3253
- if (doc.flatContents) {
3254
- cmds.push([ind, mode, doc.flatContents]);
3674
+ const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
3675
+
3676
+ if (flatContents) {
3677
+ cmds.push([ind, mode, flatContents]);
3255
3678
  }
3256
3679
  }
3257
3680
 
@@ -3279,477 +3702,281 @@
3279
3702
  if (!doc.soft) {
3280
3703
  out.push(" ");
3281
3704
  pos += 1;
3282
- }
3283
-
3284
- break;
3285
- } else {
3286
- // This line was forced into the output even if we
3287
- // were in flattened mode, so we need to tell the next
3288
- // group that no matter what, it needs to remeasure
3289
- // because the previous measurement didn't accurately
3290
- // capture the entire expression (this is necessary
3291
- // for nested groups)
3292
- shouldRemeasure = true;
3293
- }
3294
-
3295
- // fallthrough
3296
-
3297
- case MODE_BREAK:
3298
- if (lineSuffix.length) {
3299
- cmds.push([ind, mode, doc]);
3300
- cmds.push(...lineSuffix.reverse());
3301
- lineSuffix = [];
3302
- break;
3303
- }
3304
-
3305
- if (doc.literal) {
3306
- if (ind.root) {
3307
- out.push(newLine, ind.root.value);
3308
- pos = ind.root.length;
3309
- } else {
3310
- out.push(newLine);
3311
- pos = 0;
3312
- }
3313
- } else {
3314
- pos -= trim$1(out);
3315
- out.push(newLine + ind.value);
3316
- pos = ind.length;
3317
- }
3318
-
3319
- break;
3320
- }
3321
-
3322
- break;
3323
- }
3324
- }
3325
- }
3326
-
3327
- const cursorPlaceholderIndex = out.indexOf(cursor$1.placeholder);
3328
-
3329
- if (cursorPlaceholderIndex !== -1) {
3330
- const otherCursorPlaceholderIndex = out.indexOf(cursor$1.placeholder, cursorPlaceholderIndex + 1);
3331
- const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
3332
- const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
3333
- const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
3334
- return {
3335
- formatted: beforeCursor + aroundCursor + afterCursor,
3336
- cursorNodeStart: beforeCursor.length,
3337
- cursorNodeText: aroundCursor
3338
- };
3339
- }
3340
-
3341
- return {
3342
- formatted: out.join("")
3343
- };
3344
- }
3345
-
3346
- var docPrinter = {
3347
- printDocToString
3348
- };
3349
-
3350
- const traverseDocOnExitStackMarker = {};
3351
-
3352
- function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
3353
- const docsStack = [doc];
3354
-
3355
- while (docsStack.length !== 0) {
3356
- const doc = docsStack.pop();
3357
-
3358
- if (doc === traverseDocOnExitStackMarker) {
3359
- onExit(docsStack.pop());
3360
- continue;
3361
- }
3362
-
3363
- if (onExit) {
3364
- docsStack.push(doc, traverseDocOnExitStackMarker);
3365
- }
3366
-
3367
- if ( // Should Recurse
3368
- !onEnter || onEnter(doc) !== false) {
3369
- // When there are multiple parts to process,
3370
- // the parts need to be pushed onto the stack in reverse order,
3371
- // so that they are processed in the original order
3372
- // when the stack is popped.
3373
- if (doc.type === "concat" || doc.type === "fill") {
3374
- for (let ic = doc.parts.length, i = ic - 1; i >= 0; --i) {
3375
- docsStack.push(doc.parts[i]);
3376
- }
3377
- } else if (doc.type === "if-break") {
3378
- if (doc.flatContents) {
3379
- docsStack.push(doc.flatContents);
3380
- }
3381
-
3382
- if (doc.breakContents) {
3383
- docsStack.push(doc.breakContents);
3384
- }
3385
- } else if (doc.type === "group" && doc.expandedStates) {
3386
- if (shouldTraverseConditionalGroups) {
3387
- for (let ic = doc.expandedStates.length, i = ic - 1; i >= 0; --i) {
3388
- docsStack.push(doc.expandedStates[i]);
3389
- }
3390
- } else {
3391
- docsStack.push(doc.contents);
3392
- }
3393
- } else if (doc.contents) {
3394
- docsStack.push(doc.contents);
3395
- }
3396
- }
3397
- }
3398
- }
3399
-
3400
- function mapDoc(doc, cb) {
3401
- if (doc.type === "concat" || doc.type === "fill") {
3402
- const parts = doc.parts.map(part => mapDoc(part, cb));
3403
- return cb(Object.assign({}, doc, {
3404
- parts
3405
- }));
3406
- } else if (doc.type === "if-break") {
3407
- const breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
3408
- const flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
3409
- return cb(Object.assign({}, doc, {
3410
- breakContents,
3411
- flatContents
3412
- }));
3413
- } else if (doc.contents) {
3414
- const contents = mapDoc(doc.contents, cb);
3415
- return cb(Object.assign({}, doc, {
3416
- contents
3417
- }));
3418
- }
3419
-
3420
- return cb(doc);
3421
- }
3422
-
3423
- function findInDoc(doc, fn, defaultValue) {
3424
- let result = defaultValue;
3425
- let hasStopped = false;
3705
+ }
3426
3706
 
3427
- function findInDocOnEnterFn(doc) {
3428
- const maybeResult = fn(doc);
3707
+ break;
3708
+ } else {
3709
+ // This line was forced into the output even if we
3710
+ // were in flattened mode, so we need to tell the next
3711
+ // group that no matter what, it needs to remeasure
3712
+ // because the previous measurement didn't accurately
3713
+ // capture the entire expression (this is necessary
3714
+ // for nested groups)
3715
+ shouldRemeasure = true;
3716
+ }
3429
3717
 
3430
- if (maybeResult !== undefined) {
3431
- hasStopped = true;
3432
- result = maybeResult;
3433
- }
3718
+ // fallthrough
3434
3719
 
3435
- if (hasStopped) {
3436
- return false;
3437
- }
3438
- }
3720
+ case MODE_BREAK:
3721
+ if (lineSuffix.length > 0) {
3722
+ cmds.push([ind, mode, doc], ...lineSuffix.reverse());
3723
+ lineSuffix = [];
3724
+ break;
3725
+ }
3439
3726
 
3440
- traverseDoc(doc, findInDocOnEnterFn);
3441
- return result;
3442
- }
3727
+ if (doc.literal) {
3728
+ if (ind.root) {
3729
+ out.push(newLine, ind.root.value);
3730
+ pos = ind.root.length;
3731
+ } else {
3732
+ out.push(newLine);
3733
+ pos = 0;
3734
+ }
3735
+ } else {
3736
+ pos -= trim(out);
3737
+ out.push(newLine + ind.value);
3738
+ pos = ind.length;
3739
+ }
3443
3740
 
3444
- function isEmpty(n) {
3445
- return typeof n === "string" && n.length === 0;
3446
- }
3741
+ break;
3742
+ }
3447
3743
 
3448
- function isLineNextFn(doc) {
3449
- if (typeof doc === "string") {
3450
- return false;
3451
- }
3744
+ break;
3452
3745
 
3453
- if (doc.type === "line") {
3454
- return true;
3455
- }
3456
- }
3746
+ case "label":
3747
+ cmds.push([ind, mode, doc.contents]);
3748
+ break;
3749
+ }
3750
+ } // Flush remaining line-suffix contents at the end of the document, in case
3751
+ // there is no new line after the line-suffix.
3457
3752
 
3458
- function isLineNext(doc) {
3459
- return findInDoc(doc, isLineNextFn, false);
3460
- }
3461
3753
 
3462
- function willBreakFn(doc) {
3463
- if (doc.type === "group" && doc.break) {
3464
- return true;
3754
+ if (cmds.length === 0 && lineSuffix.length > 0) {
3755
+ cmds.push(...lineSuffix.reverse());
3756
+ lineSuffix = [];
3757
+ }
3465
3758
  }
3466
3759
 
3467
- if (doc.type === "line" && doc.hard) {
3468
- return true;
3469
- }
3760
+ const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
3470
3761
 
3471
- if (doc.type === "break-parent") {
3472
- return true;
3762
+ if (cursorPlaceholderIndex !== -1) {
3763
+ const otherCursorPlaceholderIndex = out.indexOf(cursor.placeholder, cursorPlaceholderIndex + 1);
3764
+ const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
3765
+ const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
3766
+ const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
3767
+ return {
3768
+ formatted: beforeCursor + aroundCursor + afterCursor,
3769
+ cursorNodeStart: beforeCursor.length,
3770
+ cursorNodeText: aroundCursor
3771
+ };
3473
3772
  }
3474
- }
3475
3773
 
3476
- function willBreak(doc) {
3477
- return findInDoc(doc, willBreakFn, false);
3774
+ return {
3775
+ formatted: out.join("")
3776
+ };
3478
3777
  }
3479
3778
 
3480
- function breakParentGroup(groupStack) {
3481
- if (groupStack.length > 0) {
3482
- const parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
3483
- // the user is expected to manually handle what breaks.
3484
-
3485
- if (!parentGroup.expandedStates) {
3486
- parentGroup.break = true;
3487
- }
3488
- }
3779
+ var docPrinter = {
3780
+ printDocToString
3781
+ };
3489
3782
 
3490
- return null;
3491
- }
3783
+ const {
3784
+ isConcat,
3785
+ getDocParts
3786
+ } = docUtils;
3492
3787
 
3493
- function propagateBreaks(doc) {
3494
- const alreadyVisitedSet = new Set();
3495
- const groupStack = [];
3788
+ function flattenDoc(doc) {
3789
+ if (!doc) {
3790
+ return "";
3791
+ }
3496
3792
 
3497
- function propagateBreaksOnEnterFn(doc) {
3498
- if (doc.type === "break-parent") {
3499
- breakParentGroup(groupStack);
3500
- }
3793
+ if (isConcat(doc)) {
3794
+ const res = [];
3501
3795
 
3502
- if (doc.type === "group") {
3503
- groupStack.push(doc);
3796
+ for (const part of getDocParts(doc)) {
3797
+ if (isConcat(part)) {
3798
+ res.push(...flattenDoc(part).parts);
3799
+ } else {
3800
+ const flattened = flattenDoc(part);
3504
3801
 
3505
- if (alreadyVisitedSet.has(doc)) {
3506
- return false;
3802
+ if (flattened !== "") {
3803
+ res.push(flattened);
3804
+ }
3507
3805
  }
3508
-
3509
- alreadyVisitedSet.add(doc);
3510
3806
  }
3807
+
3808
+ return {
3809
+ type: "concat",
3810
+ parts: res
3811
+ };
3511
3812
  }
3512
3813
 
3513
- function propagateBreaksOnExitFn(doc) {
3514
- if (doc.type === "group") {
3515
- const group = groupStack.pop();
3814
+ if (doc.type === "if-break") {
3815
+ return Object.assign({}, doc, {
3816
+ breakContents: flattenDoc(doc.breakContents),
3817
+ flatContents: flattenDoc(doc.flatContents)
3818
+ });
3819
+ }
3516
3820
 
3517
- if (group.break) {
3518
- breakParentGroup(groupStack);
3519
- }
3520
- }
3821
+ if (doc.type === "group") {
3822
+ return Object.assign({}, doc, {
3823
+ contents: flattenDoc(doc.contents),
3824
+ expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
3825
+ });
3521
3826
  }
3522
3827
 
3523
- traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
3524
- /* shouldTraverseConditionalGroups */
3525
- true);
3526
- }
3828
+ if (doc.type === "fill") {
3829
+ return {
3830
+ type: "fill",
3831
+ parts: doc.parts.map(flattenDoc)
3832
+ };
3833
+ }
3527
3834
 
3528
- function removeLinesFn(doc) {
3529
- // Force this doc into flat mode by statically converting all
3530
- // lines into spaces (or soft lines into nothing). Hard lines
3531
- // should still output because there's too great of a chance
3532
- // of breaking existing assumptions otherwise.
3533
- if (doc.type === "line" && !doc.hard) {
3534
- return doc.soft ? "" : " ";
3535
- } else if (doc.type === "if-break") {
3536
- return doc.flatContents || "";
3835
+ if (doc.contents) {
3836
+ return Object.assign({}, doc, {
3837
+ contents: flattenDoc(doc.contents)
3838
+ });
3537
3839
  }
3538
3840
 
3539
3841
  return doc;
3540
3842
  }
3541
3843
 
3542
- function removeLines(doc) {
3543
- return mapDoc(doc, removeLinesFn);
3544
- }
3844
+ function printDocToDebug(doc) {
3845
+ /** @type Record<symbol, string> */
3846
+ const printedSymbols = Object.create(null);
3847
+ /** @type Set<string> */
3545
3848
 
3546
- function getInnerParts(doc) {
3547
- let {
3548
- parts
3549
- } = doc;
3550
- let lastPart; // Avoid a falsy element like ""
3849
+ const usedKeysForSymbols = new Set();
3850
+ return printDoc(flattenDoc(doc));
3551
3851
 
3552
- for (let i = doc.parts.length; i > 0 && !lastPart; i--) {
3553
- lastPart = parts[i - 1];
3554
- }
3852
+ function printDoc(doc, index, parentParts) {
3853
+ if (typeof doc === "string") {
3854
+ return JSON.stringify(doc);
3855
+ }
3555
3856
 
3556
- if (lastPart.type === "group") {
3557
- parts = lastPart.contents.parts;
3558
- }
3857
+ if (isConcat(doc)) {
3858
+ const printed = getDocParts(doc).map(printDoc).filter(Boolean);
3859
+ return printed.length === 1 ? printed[0] : "[".concat(printed.join(", "), "]");
3860
+ }
3559
3861
 
3560
- return parts;
3561
- }
3862
+ if (doc.type === "line") {
3863
+ const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === "break-parent";
3562
3864
 
3563
- function stripTrailingHardline(doc, withInnerParts = false) {
3564
- // HACK remove ending hardline, original PR: #1984
3565
- if (doc.type === "concat" && doc.parts.length !== 0) {
3566
- const parts = withInnerParts ? getInnerParts(doc) : doc.parts;
3567
- const lastPart = parts[parts.length - 1];
3568
-
3569
- if (lastPart.type === "concat") {
3570
- if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
3571
- return {
3572
- type: "concat",
3573
- parts: parts.slice(0, -1)
3574
- };
3865
+ if (doc.literal) {
3866
+ return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
3575
3867
  }
3576
3868
 
3577
- return {
3578
- type: "concat",
3579
- parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
3580
- };
3581
- }
3582
- }
3583
-
3584
- return doc;
3585
- }
3586
-
3587
- function normalizeParts(parts) {
3588
- const newParts = [];
3589
- const restParts = parts.filter(Boolean);
3869
+ if (doc.hard) {
3870
+ return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
3871
+ }
3590
3872
 
3591
- while (restParts.length !== 0) {
3592
- const part = restParts.shift();
3873
+ if (doc.soft) {
3874
+ return "softline";
3875
+ }
3593
3876
 
3594
- if (!part) {
3595
- continue;
3877
+ return "line";
3596
3878
  }
3597
3879
 
3598
- if (part.type === "concat") {
3599
- restParts.unshift(...part.parts);
3600
- continue;
3880
+ if (doc.type === "break-parent") {
3881
+ const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === "line" && parentParts[index - 1].hard;
3882
+ return afterHardline ? undefined : "breakParent";
3601
3883
  }
3602
3884
 
3603
- if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
3604
- newParts[newParts.length - 1] += part;
3605
- continue;
3885
+ if (doc.type === "trim") {
3886
+ return "trim";
3606
3887
  }
3607
3888
 
3608
- newParts.push(part);
3609
- }
3889
+ if (doc.type === "indent") {
3890
+ return "indent(" + printDoc(doc.contents) + ")";
3891
+ }
3610
3892
 
3611
- return newParts;
3612
- }
3893
+ if (doc.type === "align") {
3894
+ return doc.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
3895
+ }
3613
3896
 
3614
- function normalizeDoc(doc) {
3615
- return mapDoc(doc, currentDoc => {
3616
- if (!currentDoc.parts) {
3617
- return currentDoc;
3897
+ if (doc.type === "if-break") {
3898
+ return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + (doc.groupId ? (!doc.flatContents ? ', ""' : "") + ", { groupId: ".concat(printGroupId(doc.groupId), " }") : "") + ")";
3618
3899
  }
3619
3900
 
3620
- return Object.assign({}, currentDoc, {
3621
- parts: normalizeParts(currentDoc.parts)
3622
- });
3623
- });
3624
- }
3901
+ if (doc.type === "indent-if-break") {
3902
+ const optionsParts = [];
3625
3903
 
3626
- var docUtils = {
3627
- isEmpty,
3628
- willBreak,
3629
- isLineNext,
3630
- traverseDoc,
3631
- findInDoc,
3632
- mapDoc,
3633
- propagateBreaks,
3634
- removeLines,
3635
- stripTrailingHardline,
3636
- normalizeParts,
3637
- normalizeDoc
3638
- };
3904
+ if (doc.negate) {
3905
+ optionsParts.push("negate: true");
3906
+ }
3639
3907
 
3640
- function flattenDoc(doc) {
3641
- if (doc.type === "concat") {
3642
- const res = [];
3908
+ if (doc.groupId) {
3909
+ optionsParts.push("groupId: ".concat(printGroupId(doc.groupId)));
3910
+ }
3643
3911
 
3644
- for (let i = 0; i < doc.parts.length; ++i) {
3645
- const doc2 = doc.parts[i];
3912
+ const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
3913
+ return "indentIfBreak(".concat(printDoc(doc.contents)).concat(options, ")");
3914
+ }
3646
3915
 
3647
- if (typeof doc2 !== "string" && doc2.type === "concat") {
3648
- res.push(...flattenDoc(doc2).parts);
3649
- } else {
3650
- const flattened = flattenDoc(doc2);
3916
+ if (doc.type === "group") {
3917
+ const optionsParts = [];
3651
3918
 
3652
- if (flattened !== "") {
3653
- res.push(flattened);
3654
- }
3919
+ if (doc.break && doc.break !== "propagated") {
3920
+ optionsParts.push("shouldBreak: true");
3655
3921
  }
3656
- }
3657
3922
 
3658
- return Object.assign({}, doc, {
3659
- parts: res
3660
- });
3661
- } else if (doc.type === "if-break") {
3662
- return Object.assign({}, doc, {
3663
- breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
3664
- flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
3665
- });
3666
- } else if (doc.type === "group") {
3667
- return Object.assign({}, doc, {
3668
- contents: flattenDoc(doc.contents),
3669
- expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
3670
- });
3671
- } else if (doc.contents) {
3672
- return Object.assign({}, doc, {
3673
- contents: flattenDoc(doc.contents)
3674
- });
3675
- }
3923
+ if (doc.id) {
3924
+ optionsParts.push("id: ".concat(printGroupId(doc.id)));
3925
+ }
3676
3926
 
3677
- return doc;
3678
- }
3927
+ const options = optionsParts.length > 0 ? ", { ".concat(optionsParts.join(", "), " }") : "";
3679
3928
 
3680
- function printDoc(doc) {
3681
- if (typeof doc === "string") {
3682
- return JSON.stringify(doc);
3683
- }
3929
+ if (doc.expandedStates) {
3930
+ return "conditionalGroup([".concat(doc.expandedStates.map(part => printDoc(part)).join(","), "]").concat(options, ")");
3931
+ }
3684
3932
 
3685
- if (doc.type === "line") {
3686
- if (doc.literal) {
3687
- return "literalline";
3933
+ return "group(".concat(printDoc(doc.contents)).concat(options, ")");
3688
3934
  }
3689
3935
 
3690
- if (doc.hard) {
3691
- return "hardline";
3936
+ if (doc.type === "fill") {
3937
+ return "fill([".concat(doc.parts.map(part => printDoc(part)).join(", "), "])");
3692
3938
  }
3693
3939
 
3694
- if (doc.soft) {
3695
- return "softline";
3940
+ if (doc.type === "line-suffix") {
3941
+ return "lineSuffix(" + printDoc(doc.contents) + ")";
3696
3942
  }
3697
3943
 
3698
- return "line";
3699
- }
3700
-
3701
- if (doc.type === "break-parent") {
3702
- return "breakParent";
3703
- }
3704
-
3705
- if (doc.type === "trim") {
3706
- return "trim";
3707
- }
3708
-
3709
- if (doc.type === "concat") {
3710
- return "[" + doc.parts.map(printDoc).join(", ") + "]";
3711
- }
3712
-
3713
- if (doc.type === "indent") {
3714
- return "indent(" + printDoc(doc.contents) + ")";
3715
- }
3944
+ if (doc.type === "line-suffix-boundary") {
3945
+ return "lineSuffixBoundary";
3946
+ }
3716
3947
 
3717
- if (doc.type === "align") {
3718
- return doc.n === -Infinity ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
3719
- }
3948
+ if (doc.type === "label") {
3949
+ return "label(".concat(JSON.stringify(doc.label), ", ").concat(printDoc(doc.contents), ")");
3950
+ }
3720
3951
 
3721
- if (doc.type === "if-break") {
3722
- return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
3952
+ throw new Error("Unknown doc type " + doc.type);
3723
3953
  }
3724
3954
 
3725
- if (doc.type === "group") {
3726
- if (doc.expandedStates) {
3727
- return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
3955
+ function printGroupId(id) {
3956
+ if (typeof id !== "symbol") {
3957
+ return JSON.stringify(String(id));
3728
3958
  }
3729
3959
 
3730
- return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
3731
- }
3960
+ if (id in printedSymbols) {
3961
+ return printedSymbols[id];
3962
+ } // TODO: use Symbol.prototype.description instead of slice once Node 10 is dropped
3732
3963
 
3733
- if (doc.type === "fill") {
3734
- return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
3735
- }
3736
3964
 
3737
- if (doc.type === "line-suffix") {
3738
- return "lineSuffix(" + printDoc(doc.contents) + ")";
3739
- }
3965
+ const prefix = String(id).slice(7, -1) || "symbol";
3740
3966
 
3741
- if (doc.type === "line-suffix-boundary") {
3742
- return "lineSuffixBoundary";
3743
- }
3967
+ for (let counter = 0;; counter++) {
3968
+ const key = prefix + (counter > 0 ? " #".concat(counter) : "");
3744
3969
 
3745
- throw new Error("Unknown doc type " + doc.type);
3970
+ if (!usedKeysForSymbols.has(key)) {
3971
+ usedKeysForSymbols.add(key);
3972
+ return printedSymbols[id] = "Symbol.for(".concat(JSON.stringify(key), ")");
3973
+ }
3974
+ }
3975
+ }
3746
3976
  }
3747
3977
 
3748
3978
  var docDebug = {
3749
- printDocToDebug(doc) {
3750
- return printDoc(flattenDoc(doc));
3751
- }
3752
-
3979
+ printDocToDebug
3753
3980
  };
3754
3981
 
3755
3982
  /**