prettier 3.0.0-alpha.1 → 3.0.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +910 -759
  2. package/README.md +3 -3
  3. package/bin/prettier.cjs +0 -0
  4. package/doc.d.ts +240 -0
  5. package/doc.js +351 -479
  6. package/doc.mjs +342 -474
  7. package/index.cjs +400 -230
  8. package/index.d.ts +919 -0
  9. package/index.mjs +18129 -32123
  10. package/internal/cli.mjs +4374 -10823
  11. package/internal/internal.mjs +6437 -0
  12. package/package.json +55 -13
  13. package/plugins/acorn.d.ts +6 -0
  14. package/plugins/acorn.js +13 -0
  15. package/plugins/acorn.mjs +13 -0
  16. package/plugins/angular.d.ts +8 -0
  17. package/plugins/angular.js +2 -2
  18. package/plugins/angular.mjs +2 -2
  19. package/plugins/babel.d.ts +17 -0
  20. package/plugins/babel.js +12 -12
  21. package/plugins/babel.mjs +12 -12
  22. package/plugins/estree.d.ts +0 -0
  23. package/plugins/estree.js +35 -0
  24. package/plugins/estree.mjs +35 -0
  25. package/plugins/flow.d.ts +5 -0
  26. package/plugins/flow.js +20 -20
  27. package/plugins/flow.mjs +20 -20
  28. package/plugins/glimmer.d.ts +5 -0
  29. package/plugins/glimmer.js +23 -18
  30. package/plugins/glimmer.mjs +23 -18
  31. package/plugins/graphql.d.ts +5 -0
  32. package/plugins/graphql.js +16 -7
  33. package/plugins/graphql.mjs +16 -7
  34. package/plugins/html.d.ts +8 -0
  35. package/plugins/html.js +19 -29
  36. package/plugins/html.mjs +19 -29
  37. package/plugins/markdown.d.ts +7 -0
  38. package/plugins/markdown.js +52 -32
  39. package/plugins/markdown.mjs +52 -32
  40. package/plugins/meriyah.d.ts +5 -0
  41. package/plugins/meriyah.js +5 -6
  42. package/plugins/meriyah.mjs +5 -6
  43. package/plugins/postcss.d.ts +7 -0
  44. package/plugins/postcss.js +45 -43
  45. package/plugins/postcss.mjs +45 -43
  46. package/plugins/typescript.d.ts +5 -0
  47. package/plugins/typescript.js +24 -239
  48. package/plugins/typescript.mjs +24 -239
  49. package/plugins/yaml.d.ts +5 -0
  50. package/plugins/yaml.js +146 -133
  51. package/plugins/yaml.mjs +146 -133
  52. package/standalone.d.ts +33 -0
  53. package/standalone.js +35 -105
  54. package/standalone.mjs +35 -105
  55. package/internal/third-party.mjs +0 -9071
  56. package/plugins/acorn-and-espree.js +0 -13
  57. package/plugins/acorn-and-espree.mjs +0 -13
package/index.cjs CHANGED
@@ -24,39 +24,83 @@ var __copyProps = (to, from, except, desc) => {
24
24
  return to;
25
25
  };
26
26
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
31
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
32
  mod
29
33
  ));
30
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
35
 
32
- // node_modules/escape-string-regexp/index.js
33
- function escapeStringRegexp(string) {
34
- if (typeof string !== "string") {
35
- throw new TypeError("Expected a string");
36
+ // src/utils/skip-inline-comment.js
37
+ function skipInlineComment(text, startIndex) {
38
+ if (startIndex === false) {
39
+ return false;
36
40
  }
37
- return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
41
+ if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "*") {
42
+ for (let i = startIndex + 2; i < text.length; ++i) {
43
+ if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
44
+ return i + 2;
45
+ }
46
+ }
47
+ }
48
+ return startIndex;
38
49
  }
39
- var init_escape_string_regexp = __esm({
40
- "node_modules/escape-string-regexp/index.js"() {
50
+ var skip_inline_comment_default;
51
+ var init_skip_inline_comment = __esm({
52
+ "src/utils/skip-inline-comment.js"() {
53
+ skip_inline_comment_default = skipInlineComment;
41
54
  }
42
55
  });
43
56
 
44
- // src/utils/text/skip.js
45
- function skip(chars) {
46
- return (text, index, opts) => {
47
- const backwards = opts && opts.backwards;
48
- if (index === false) {
57
+ // src/utils/skip-newline.js
58
+ function skipNewline(text, startIndex, options) {
59
+ const backwards = Boolean(options == null ? void 0 : options.backwards);
60
+ if (startIndex === false) {
61
+ return false;
62
+ }
63
+ const character = text.charAt(startIndex);
64
+ if (backwards) {
65
+ if (text.charAt(startIndex - 1) === "\r" && character === "\n") {
66
+ return startIndex - 2;
67
+ }
68
+ if (character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029") {
69
+ return startIndex - 1;
70
+ }
71
+ } else {
72
+ if (character === "\r" && text.charAt(startIndex + 1) === "\n") {
73
+ return startIndex + 2;
74
+ }
75
+ if (character === "\n" || character === "\r" || character === "\u2028" || character === "\u2029") {
76
+ return startIndex + 1;
77
+ }
78
+ }
79
+ return startIndex;
80
+ }
81
+ var skip_newline_default;
82
+ var init_skip_newline = __esm({
83
+ "src/utils/skip-newline.js"() {
84
+ skip_newline_default = skipNewline;
85
+ }
86
+ });
87
+
88
+ // src/utils/skip.js
89
+ function skip(characters) {
90
+ return (text, startIndex, options) => {
91
+ const backwards = Boolean(options == null ? void 0 : options.backwards);
92
+ if (startIndex === false) {
49
93
  return false;
50
94
  }
51
95
  const { length } = text;
52
- let cursor = index;
96
+ let cursor = startIndex;
53
97
  while (cursor >= 0 && cursor < length) {
54
- const c = text.charAt(cursor);
55
- if (chars instanceof RegExp) {
56
- if (!chars.test(c)) {
98
+ const character = text.charAt(cursor);
99
+ if (characters instanceof RegExp) {
100
+ if (!characters.test(character)) {
57
101
  return cursor;
58
102
  }
59
- } else if (!chars.includes(c)) {
103
+ } else if (!characters.includes(character)) {
60
104
  return cursor;
61
105
  }
62
106
  backwards ? cursor-- : cursor++;
@@ -69,7 +113,7 @@ function skip(chars) {
69
113
  }
70
114
  var skipWhitespace, skipSpaces, skipToLineEnd, skipEverythingButNewLine;
71
115
  var init_skip = __esm({
72
- "src/utils/text/skip.js"() {
116
+ "src/utils/skip.js"() {
73
117
  skipWhitespace = skip(/\s/);
74
118
  skipSpaces = skip(" ");
75
119
  skipToLineEnd = skip(",; ");
@@ -77,80 +121,28 @@ var init_skip = __esm({
77
121
  }
78
122
  });
79
123
 
80
- // src/utils/text/skip-inline-comment.js
81
- function skipInlineComment(text, index) {
82
- if (index === false) {
124
+ // src/utils/skip-trailing-comment.js
125
+ function skipTrailingComment(text, startIndex) {
126
+ if (startIndex === false) {
83
127
  return false;
84
128
  }
85
- if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
86
- for (let i = index + 2; i < text.length; ++i) {
87
- if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
88
- return i + 2;
89
- }
90
- }
91
- }
92
- return index;
93
- }
94
- var skip_inline_comment_default;
95
- var init_skip_inline_comment = __esm({
96
- "src/utils/text/skip-inline-comment.js"() {
97
- skip_inline_comment_default = skipInlineComment;
129
+ if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "/") {
130
+ return skipEverythingButNewLine(text, startIndex);
98
131
  }
99
- });
100
-
101
- // src/utils/text/skip-trailing-comment.js
102
- function skipTrailingComment(text, index) {
103
- if (index === false) {
104
- return false;
105
- }
106
- if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
107
- return skipEverythingButNewLine(text, index);
108
- }
109
- return index;
132
+ return startIndex;
110
133
  }
111
134
  var skip_trailing_comment_default;
112
135
  var init_skip_trailing_comment = __esm({
113
- "src/utils/text/skip-trailing-comment.js"() {
136
+ "src/utils/skip-trailing-comment.js"() {
114
137
  init_skip();
115
138
  skip_trailing_comment_default = skipTrailingComment;
116
139
  }
117
140
  });
118
141
 
119
- // src/utils/text/skip-newline.js
120
- function skipNewline(text, index, opts) {
121
- const backwards = opts && opts.backwards;
122
- if (index === false) {
123
- return false;
124
- }
125
- const atIndex = text.charAt(index);
126
- if (backwards) {
127
- if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
128
- return index - 2;
129
- }
130
- if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
131
- return index - 1;
132
- }
133
- } else {
134
- if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
135
- return index + 2;
136
- }
137
- if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
138
- return index + 1;
139
- }
140
- }
141
- return index;
142
- }
143
- var skip_newline_default;
144
- var init_skip_newline = __esm({
145
- "src/utils/text/skip-newline.js"() {
146
- skip_newline_default = skipNewline;
147
- }
148
- });
149
-
150
- // src/utils/text/get-next-non-space-non-comment-character-index-with-start-index.js
151
- function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
142
+ // src/utils/get-next-non-space-non-comment-character-index.js
143
+ function getNextNonSpaceNonCommentCharacterIndex(text, startIndex) {
152
144
  let oldIdx = null;
153
- let nextIdx = idx;
145
+ let nextIdx = startIndex;
154
146
  while (nextIdx !== oldIdx) {
155
147
  oldIdx = nextIdx;
156
148
  nextIdx = skipSpaces(text, nextIdx);
@@ -160,20 +152,110 @@ function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
160
152
  }
161
153
  return nextIdx;
162
154
  }
163
- var get_next_non_space_non_comment_character_index_with_start_index_default;
164
- var init_get_next_non_space_non_comment_character_index_with_start_index = __esm({
165
- "src/utils/text/get-next-non-space-non-comment-character-index-with-start-index.js"() {
155
+ var get_next_non_space_non_comment_character_index_default;
156
+ var init_get_next_non_space_non_comment_character_index = __esm({
157
+ "src/utils/get-next-non-space-non-comment-character-index.js"() {
166
158
  init_skip_inline_comment();
167
159
  init_skip_newline();
168
160
  init_skip_trailing_comment();
169
161
  init_skip();
170
- get_next_non_space_non_comment_character_index_with_start_index_default = getNextNonSpaceNonCommentCharacterIndexWithStartIndex;
162
+ get_next_non_space_non_comment_character_index_default = getNextNonSpaceNonCommentCharacterIndex;
171
163
  }
172
164
  });
173
165
 
174
- // src/utils/is-non-empty-array.js
175
- var init_is_non_empty_array = __esm({
176
- "src/utils/is-non-empty-array.js"() {
166
+ // src/utils/is-previous-line-empty.js
167
+ function isPreviousLineEmpty(text, startIndex) {
168
+ let idx = startIndex - 1;
169
+ idx = skipSpaces(text, idx, { backwards: true });
170
+ idx = skip_newline_default(text, idx, { backwards: true });
171
+ idx = skipSpaces(text, idx, { backwards: true });
172
+ const idx2 = skip_newline_default(text, idx, { backwards: true });
173
+ return idx !== idx2;
174
+ }
175
+ var is_previous_line_empty_default;
176
+ var init_is_previous_line_empty = __esm({
177
+ "src/utils/is-previous-line-empty.js"() {
178
+ init_skip_newline();
179
+ init_skip();
180
+ is_previous_line_empty_default = isPreviousLineEmpty;
181
+ }
182
+ });
183
+
184
+ // src/utils/has-newline.js
185
+ function hasNewline(text, startIndex, options = {}) {
186
+ const idx = skipSpaces(
187
+ text,
188
+ options.backwards ? startIndex - 1 : startIndex,
189
+ options
190
+ );
191
+ const idx2 = skip_newline_default(text, idx, options);
192
+ return idx !== idx2;
193
+ }
194
+ var has_newline_default;
195
+ var init_has_newline = __esm({
196
+ "src/utils/has-newline.js"() {
197
+ init_skip();
198
+ init_skip_newline();
199
+ has_newline_default = hasNewline;
200
+ }
201
+ });
202
+
203
+ // src/utils/is-next-line-empty.js
204
+ function isNextLineEmpty(text, startIndex) {
205
+ let oldIdx = null;
206
+ let idx = startIndex;
207
+ while (idx !== oldIdx) {
208
+ oldIdx = idx;
209
+ idx = skipToLineEnd(text, idx);
210
+ idx = skip_inline_comment_default(text, idx);
211
+ idx = skipSpaces(text, idx);
212
+ }
213
+ idx = skip_trailing_comment_default(text, idx);
214
+ idx = skip_newline_default(text, idx);
215
+ return idx !== false && has_newline_default(text, idx);
216
+ }
217
+ var is_next_line_empty_default;
218
+ var init_is_next_line_empty = __esm({
219
+ "src/utils/is-next-line-empty.js"() {
220
+ init_skip_newline();
221
+ init_skip();
222
+ init_skip_inline_comment();
223
+ init_skip_trailing_comment();
224
+ init_has_newline();
225
+ is_next_line_empty_default = isNextLineEmpty;
226
+ }
227
+ });
228
+
229
+ // node_modules/escape-string-regexp/index.js
230
+ function escapeStringRegexp(string) {
231
+ if (typeof string !== "string") {
232
+ throw new TypeError("Expected a string");
233
+ }
234
+ return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
235
+ }
236
+ var init_escape_string_regexp = __esm({
237
+ "node_modules/escape-string-regexp/index.js"() {
238
+ }
239
+ });
240
+
241
+ // src/utils/get-max-continuous-count.js
242
+ function getMaxContinuousCount(text, searchString) {
243
+ const results = text.match(
244
+ new RegExp(`(${escapeStringRegexp(searchString)})+`, "g")
245
+ );
246
+ if (results === null) {
247
+ return 0;
248
+ }
249
+ return results.reduce(
250
+ (maxCount, result) => Math.max(maxCount, result.length / searchString.length),
251
+ 0
252
+ );
253
+ }
254
+ var get_max_continuous_count_default;
255
+ var init_get_max_continuous_count = __esm({
256
+ "src/utils/get-max-continuous-count.js"() {
257
+ init_escape_string_regexp();
258
+ get_max_continuous_count_default = getMaxContinuousCount;
177
259
  }
178
260
  });
179
261
 
@@ -208,7 +290,22 @@ function isFullwidthCodePoint(codePoint) {
208
290
  if (!Number.isInteger(codePoint)) {
209
291
  return false;
210
292
  }
211
- return codePoint >= 4352 && (codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || 12880 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65131 || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 262141);
293
+ return codePoint >= 4352 && (codePoint <= 4447 || // Hangul Jamo
294
+ codePoint === 9001 || // LEFT-POINTING ANGLE BRACKET
295
+ codePoint === 9002 || // RIGHT-POINTING ANGLE BRACKET
296
+ // CJK Radicals Supplement .. Enclosed CJK Letters and Months
297
+ 11904 <= codePoint && codePoint <= 12871 && codePoint !== 12351 || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
298
+ 12880 <= codePoint && codePoint <= 19903 || // CJK Unified Ideographs .. Yi Radicals
299
+ 19968 <= codePoint && codePoint <= 42182 || // Hangul Jamo Extended-A
300
+ 43360 <= codePoint && codePoint <= 43388 || // Hangul Syllables
301
+ 44032 <= codePoint && codePoint <= 55203 || // CJK Compatibility Ideographs
302
+ 63744 <= codePoint && codePoint <= 64255 || // Vertical Forms
303
+ 65040 <= codePoint && codePoint <= 65049 || // CJK Compatibility Forms .. Small Form Variants
304
+ 65072 <= codePoint && codePoint <= 65131 || // Halfwidth and Fullwidth Forms
305
+ 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510 || // Kana Supplement
306
+ 110592 <= codePoint && codePoint <= 110593 || // Enclosed Ideographic Supplement
307
+ 127488 <= codePoint && codePoint <= 127569 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
308
+ 131072 <= codePoint && codePoint <= 262141);
212
309
  }
213
310
  var init_is_fullwidth_code_point = __esm({
214
311
  "node_modules/string-width/node_modules/is-fullwidth-code-point/index.js"() {
@@ -279,83 +376,11 @@ var init_get_string_width = __esm({
279
376
  }
280
377
  });
281
378
 
282
- // src/common/util.js
283
- function skip2(chars) {
284
- return (text, index, opts) => {
285
- const backwards = opts && opts.backwards;
286
- if (index === false) {
287
- return false;
288
- }
289
- const { length } = text;
290
- let cursor = index;
291
- while (cursor >= 0 && cursor < length) {
292
- const c = text.charAt(cursor);
293
- if (chars instanceof RegExp) {
294
- if (!chars.test(c)) {
295
- return cursor;
296
- }
297
- } else if (!chars.includes(c)) {
298
- return cursor;
299
- }
300
- backwards ? cursor-- : cursor++;
301
- }
302
- if (cursor === -1 || cursor === length) {
303
- return cursor;
304
- }
305
- return false;
306
- };
307
- }
308
- function hasNewline(text, index, opts = {}) {
309
- const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
310
- const idx2 = skip_newline_default(text, idx, opts);
311
- return idx !== idx2;
312
- }
313
- function hasNewlineInRange(text, start, end) {
314
- for (let i = start; i < end; ++i) {
315
- if (text.charAt(i) === "\n") {
316
- return true;
317
- }
318
- }
319
- return false;
320
- }
321
- function isPreviousLineEmpty(text, node, locStart) {
322
- let idx = locStart(node) - 1;
323
- idx = skipSpaces(text, idx, { backwards: true });
324
- idx = skip_newline_default(text, idx, { backwards: true });
325
- idx = skipSpaces(text, idx, { backwards: true });
326
- const idx2 = skip_newline_default(text, idx, { backwards: true });
327
- return idx !== idx2;
328
- }
329
- function isNextLineEmptyAfterIndex(text, index) {
330
- let oldIdx = null;
331
- let idx = index;
332
- while (idx !== oldIdx) {
333
- oldIdx = idx;
334
- idx = skipToLineEnd(text, idx);
335
- idx = skip_inline_comment_default(text, idx);
336
- idx = skipSpaces(text, idx);
337
- }
338
- idx = skip_trailing_comment_default(text, idx);
339
- idx = skip_newline_default(text, idx);
340
- return idx !== false && hasNewline(text, idx);
341
- }
342
- function isNextLineEmpty(text, node, locEnd) {
343
- return isNextLineEmptyAfterIndex(text, locEnd(node));
344
- }
345
- function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
346
- return get_next_non_space_non_comment_character_index_with_start_index_default(
347
- text,
348
- locEnd(node)
349
- );
350
- }
351
- function hasSpaces(text, index, opts = {}) {
352
- const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
353
- return idx !== index;
354
- }
355
- function getAlignmentSize(value, tabWidth, startIndex = 0) {
379
+ // src/utils/get-alignment-size.js
380
+ function getAlignmentSize(text, tabWidth, startIndex = 0) {
356
381
  let size = 0;
357
- for (let i = startIndex; i < value.length; ++i) {
358
- if (value[i] === " ") {
382
+ for (let i = startIndex; i < text.length; ++i) {
383
+ if (text[i] === " ") {
359
384
  size = size + tabWidth - size % tabWidth;
360
385
  } else {
361
386
  size++;
@@ -363,44 +388,141 @@ function getAlignmentSize(value, tabWidth, startIndex = 0) {
363
388
  }
364
389
  return size;
365
390
  }
391
+ var get_alignment_size_default;
392
+ var init_get_alignment_size = __esm({
393
+ "src/utils/get-alignment-size.js"() {
394
+ get_alignment_size_default = getAlignmentSize;
395
+ }
396
+ });
397
+
398
+ // src/utils/get-indent-size.js
366
399
  function getIndentSize(value, tabWidth) {
367
400
  const lastNewlineIndex = value.lastIndexOf("\n");
368
401
  if (lastNewlineIndex === -1) {
369
402
  return 0;
370
403
  }
371
- return getAlignmentSize(
404
+ return get_alignment_size_default(
405
+ // All the leading whitespaces
372
406
  value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
373
407
  tabWidth
374
408
  );
375
409
  }
376
- function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
410
+ var get_indent_size_default;
411
+ var init_get_indent_size = __esm({
412
+ "src/utils/get-indent-size.js"() {
413
+ init_get_alignment_size();
414
+ get_indent_size_default = getIndentSize;
415
+ }
416
+ });
417
+
418
+ // src/utils/has-newline-in-range.js
419
+ function hasNewlineInRange(text, startIndex, endIndex) {
420
+ for (let i = startIndex; i < endIndex; ++i) {
421
+ if (text.charAt(i) === "\n") {
422
+ return true;
423
+ }
424
+ }
425
+ return false;
426
+ }
427
+ var has_newline_in_range_default;
428
+ var init_has_newline_in_range = __esm({
429
+ "src/utils/has-newline-in-range.js"() {
430
+ has_newline_in_range_default = hasNewlineInRange;
431
+ }
432
+ });
433
+
434
+ // src/utils/has-spaces.js
435
+ function hasSpaces(text, startIndex, options = {}) {
436
+ const idx = skipSpaces(
437
+ text,
438
+ options.backwards ? startIndex - 1 : startIndex,
439
+ options
440
+ );
441
+ return idx !== startIndex;
442
+ }
443
+ var has_spaces_default;
444
+ var init_has_spaces = __esm({
445
+ "src/utils/has-spaces.js"() {
446
+ init_skip();
447
+ has_spaces_default = hasSpaces;
448
+ }
449
+ });
450
+
451
+ // src/utils/get-next-non-space-non-comment-character.js
452
+ function getNextNonSpaceNonCommentCharacter(text, startIndex) {
453
+ const index = get_next_non_space_non_comment_character_index_default(text, startIndex);
454
+ return index === false ? "" : text.charAt(index);
455
+ }
456
+ var get_next_non_space_non_comment_character_default;
457
+ var init_get_next_non_space_non_comment_character = __esm({
458
+ "src/utils/get-next-non-space-non-comment-character.js"() {
459
+ init_get_next_non_space_non_comment_character_index();
460
+ get_next_non_space_non_comment_character_default = getNextNonSpaceNonCommentCharacter;
461
+ }
462
+ });
463
+
464
+ // scripts/build/shims/string-replace-all.js
465
+ var stringReplaceAll, string_replace_all_default;
466
+ var init_string_replace_all = __esm({
467
+ "scripts/build/shims/string-replace-all.js"() {
468
+ stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
469
+ if (isOptionalObject && (original === void 0 || original === null)) {
470
+ return;
471
+ }
472
+ if (original.replaceAll) {
473
+ return original.replaceAll(pattern, replacement);
474
+ }
475
+ if (pattern.global) {
476
+ return original.replace(pattern, replacement);
477
+ }
478
+ return original.split(pattern).join(replacement);
479
+ };
480
+ string_replace_all_default = stringReplaceAll;
481
+ }
482
+ });
483
+
484
+ // src/utils/make-string.js
485
+ function makeString(rawText, enclosingQuote, unescapeUnnecessaryEscapes) {
377
486
  const otherQuote = enclosingQuote === '"' ? "'" : '"';
378
487
  const regex = /\\(.)|(["'])/gs;
379
- const newContent = rawContent.replace(regex, (match, escaped, quote) => {
380
- if (escaped === otherQuote) {
381
- return escaped;
382
- }
383
- if (quote === enclosingQuote) {
384
- return "\\" + quote;
385
- }
386
- if (quote) {
387
- return quote;
488
+ const raw = string_replace_all_default(
489
+ /* isOptionalObject*/
490
+ false,
491
+ rawText,
492
+ regex,
493
+ (match, escaped, quote) => {
494
+ if (escaped === otherQuote) {
495
+ return escaped;
496
+ }
497
+ if (quote === enclosingQuote) {
498
+ return "\\" + quote;
499
+ }
500
+ if (quote) {
501
+ return quote;
502
+ }
503
+ return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
388
504
  }
389
- return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
390
- });
391
- return enclosingQuote + newContent + enclosingQuote;
392
- }
393
- function getMaxContinuousCount(str, target) {
394
- const results = str.match(
395
- new RegExp(`(${escapeStringRegexp(target)})+`, "g")
396
505
  );
397
- if (results === null) {
398
- return 0;
506
+ return enclosingQuote + raw + enclosingQuote;
507
+ }
508
+ var make_string_default;
509
+ var init_make_string = __esm({
510
+ "src/utils/make-string.js"() {
511
+ init_string_replace_all();
512
+ make_string_default = makeString;
399
513
  }
400
- return results.reduce(
401
- (maxCount, result) => Math.max(maxCount, result.length / target.length),
402
- 0
514
+ });
515
+
516
+ // src/main/comments/utils.js
517
+ function describeNodeForDebugging(node) {
518
+ const nodeType = node.type || node.kind || "(unknown type)";
519
+ let nodeName = String(
520
+ 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 || ""
403
521
  );
522
+ if (nodeName.length > 20) {
523
+ nodeName = nodeName.slice(0, 19) + "\u2026";
524
+ }
525
+ return nodeType + (nodeName ? " " + nodeName : "");
404
526
  }
405
527
  function addCommentHelper(node, comment) {
406
528
  const comments = node.comments ?? (node.comments = []);
@@ -426,48 +548,31 @@ function addTrailingComment(node, comment) {
426
548
  comment.trailing = true;
427
549
  addCommentHelper(node, comment);
428
550
  }
429
- function describeNodeForDebugging(node) {
430
- const nodeType = node.type || node.kind || "(unknown type)";
431
- let nodeName = String(
432
- 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 || ""
433
- );
434
- if (nodeName.length > 20) {
435
- nodeName = nodeName.slice(0, 19) + "\u2026";
436
- }
437
- return nodeType + (nodeName ? " " + nodeName : "");
438
- }
439
- var init_util = __esm({
440
- "src/common/util.js"() {
441
- init_escape_string_regexp();
442
- init_skip();
443
- init_skip_inline_comment();
444
- init_skip_trailing_comment();
445
- init_skip_newline();
446
- init_get_next_non_space_non_comment_character_index_with_start_index();
447
- init_is_non_empty_array();
448
- init_get_string_width();
551
+ var init_utils = __esm({
552
+ "src/main/comments/utils.js"() {
449
553
  }
450
554
  });
451
555
 
452
- // src/common/util-shared.js
453
- var util_shared_exports = {};
454
- __export(util_shared_exports, {
556
+ // src/utils/public.js
557
+ var public_exports = {};
558
+ __export(public_exports, {
455
559
  addDanglingComment: () => addDanglingComment,
456
560
  addLeadingComment: () => addLeadingComment,
457
561
  addTrailingComment: () => addTrailingComment,
458
- getAlignmentSize: () => getAlignmentSize,
459
- getIndentSize: () => getIndentSize,
460
- getMaxContinuousCount: () => getMaxContinuousCount,
461
- getNextNonSpaceNonCommentCharacterIndex: () => getNextNonSpaceNonCommentCharacterIndex,
562
+ getAlignmentSize: () => get_alignment_size_default,
563
+ getIndentSize: () => get_indent_size_default,
564
+ getMaxContinuousCount: () => get_max_continuous_count_default,
565
+ getNextNonSpaceNonCommentCharacter: () => get_next_non_space_non_comment_character_default,
566
+ getNextNonSpaceNonCommentCharacterIndex: () => getNextNonSpaceNonCommentCharacterIndex2,
462
567
  getStringWidth: () => get_string_width_default,
463
- hasNewline: () => hasNewline,
464
- hasNewlineInRange: () => hasNewlineInRange,
465
- hasSpaces: () => hasSpaces,
466
- isNextLineEmpty: () => isNextLineEmpty,
467
- isNextLineEmptyAfterIndex: () => isNextLineEmptyAfterIndex,
468
- isPreviousLineEmpty: () => isPreviousLineEmpty,
469
- makeString: () => makeString,
470
- skip: () => skip2,
568
+ hasNewline: () => has_newline_default,
569
+ hasNewlineInRange: () => has_newline_in_range_default,
570
+ hasSpaces: () => has_spaces_default,
571
+ isNextLineEmpty: () => isNextLineEmpty2,
572
+ isNextLineEmptyAfterIndex: () => is_next_line_empty_default,
573
+ isPreviousLineEmpty: () => isPreviousLineEmpty2,
574
+ makeString: () => make_string_default,
575
+ skip: () => skip,
471
576
  skipEverythingButNewLine: () => skipEverythingButNewLine,
472
577
  skipInlineComment: () => skip_inline_comment_default,
473
578
  skipNewline: () => skip_newline_default,
@@ -476,16 +581,65 @@ __export(util_shared_exports, {
476
581
  skipTrailingComment: () => skip_trailing_comment_default,
477
582
  skipWhitespace: () => skipWhitespace
478
583
  });
479
- var init_util_shared = __esm({
480
- "src/common/util-shared.js"() {
481
- init_util();
584
+ function legacyGetNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
585
+ return get_next_non_space_non_comment_character_index_default(
586
+ text,
587
+ locEnd(node)
588
+ );
589
+ }
590
+ function getNextNonSpaceNonCommentCharacterIndex2(text, startIndex) {
591
+ return arguments.length === 2 || typeof startIndex === "number" ? get_next_non_space_non_comment_character_index_default(text, startIndex) : (
592
+ // @ts-expect-error -- expected
593
+ // eslint-disable-next-line prefer-rest-params
594
+ legacyGetNextNonSpaceNonCommentCharacterIndex(...arguments)
595
+ );
596
+ }
597
+ function legacyIsPreviousLineEmpty(text, node, locStart) {
598
+ return is_previous_line_empty_default(text, locStart(node));
599
+ }
600
+ function isPreviousLineEmpty2(text, startIndex) {
601
+ return arguments.length === 2 || typeof startIndex === "number" ? is_previous_line_empty_default(text, startIndex) : (
602
+ // @ts-expect-error -- expected
603
+ // eslint-disable-next-line prefer-rest-params
604
+ legacyIsPreviousLineEmpty(...arguments)
605
+ );
606
+ }
607
+ function legacyIsNextLineEmpty(text, node, locEnd) {
608
+ return is_next_line_empty_default(text, locEnd(node));
609
+ }
610
+ function isNextLineEmpty2(text, startIndex) {
611
+ return arguments.length === 2 || typeof startIndex === "number" ? is_next_line_empty_default(text, startIndex) : (
612
+ // @ts-expect-error -- expected
613
+ // eslint-disable-next-line prefer-rest-params
614
+ legacyIsNextLineEmpty(...arguments)
615
+ );
616
+ }
617
+ var init_public = __esm({
618
+ "src/utils/public.js"() {
619
+ init_get_next_non_space_non_comment_character_index();
620
+ init_is_previous_line_empty();
621
+ init_is_next_line_empty();
622
+ init_get_max_continuous_count();
623
+ init_get_string_width();
624
+ init_get_alignment_size();
625
+ init_get_indent_size();
626
+ init_skip_newline();
627
+ init_skip_inline_comment();
628
+ init_skip_trailing_comment();
629
+ init_has_newline();
630
+ init_has_newline_in_range();
631
+ init_has_spaces();
632
+ init_get_next_non_space_non_comment_character();
633
+ init_make_string();
634
+ init_skip();
635
+ init_utils();
482
636
  }
483
637
  });
484
638
 
485
639
  // src/main/version.evaluate.cjs
486
640
  var require_version_evaluate = __commonJS({
487
641
  "src/main/version.evaluate.cjs"(exports2, module2) {
488
- module2.exports = "3.0.0-alpha.1";
642
+ module2.exports = "3.0.0-alpha.11";
489
643
  }
490
644
  });
491
645
 
@@ -503,13 +657,29 @@ var functionNames = [
503
657
  ];
504
658
  var prettier = /* @__PURE__ */ Object.create(null);
505
659
  for (const name of functionNames) {
506
- prettier[name] = function(...args) {
507
- return prettierPromise.then((prettier2) => prettier2[name](...args));
660
+ prettier[name] = async (...args) => {
661
+ const prettier2 = await prettierPromise;
662
+ return prettier2[name](...args);
663
+ };
664
+ }
665
+ var debugApiFunctionNames = [
666
+ "parse",
667
+ "formatAST",
668
+ "formatDoc",
669
+ "printToDoc",
670
+ "printDocToString"
671
+ ];
672
+ var debugApis = /* @__PURE__ */ Object.create(null);
673
+ for (const name of debugApiFunctionNames) {
674
+ debugApis[name] = async (...args) => {
675
+ const prettier2 = await prettierPromise;
676
+ return prettier2.__debug[name](...args);
508
677
  };
509
678
  }
679
+ prettier.__debug = debugApis;
510
680
  if (true) {
511
- prettier.util = (init_util_shared(), __toCommonJS(util_shared_exports));
512
- prettier.doc = require("./doc.mjs");
681
+ prettier.util = (init_public(), __toCommonJS(public_exports));
682
+ prettier.doc = require("./doc.js");
513
683
  } else {
514
684
  Object.defineProperties(prettier, {
515
685
  util: {