prettier 3.0.0-alpha.4 → 3.0.0-alpha.5

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 (50) hide show
  1. package/LICENSE +849 -415
  2. package/README.md +3 -3
  3. package/doc.d.ts +248 -0
  4. package/doc.js +274 -199
  5. package/doc.mjs +269 -194
  6. package/index.cjs +380 -201
  7. package/index.d.ts +903 -0
  8. package/index.mjs +7539 -5795
  9. package/internal/cli.mjs +2025 -3219
  10. package/internal/third-party.mjs +2948 -5593
  11. package/package.json +32 -1
  12. package/plugins/acorn-and-espree.d.ts +10 -0
  13. package/plugins/acorn-and-espree.js +12 -12
  14. package/plugins/acorn-and-espree.mjs +12 -12
  15. package/plugins/angular.d.ts +11 -0
  16. package/plugins/angular.js +2 -2
  17. package/plugins/angular.mjs +2 -2
  18. package/plugins/babel.d.ts +16 -0
  19. package/plugins/babel.js +13 -13
  20. package/plugins/babel.mjs +13 -13
  21. package/plugins/flow.d.ts +8 -0
  22. package/plugins/flow.js +20 -20
  23. package/plugins/flow.mjs +20 -20
  24. package/plugins/glimmer.d.ts +8 -0
  25. package/plugins/glimmer.js +18 -17
  26. package/plugins/glimmer.mjs +18 -17
  27. package/plugins/graphql.d.ts +8 -0
  28. package/plugins/graphql.js +7 -7
  29. package/plugins/graphql.mjs +7 -7
  30. package/plugins/html.d.ts +11 -0
  31. package/plugins/html.js +17 -28
  32. package/plugins/html.mjs +17 -28
  33. package/plugins/markdown.d.ts +10 -0
  34. package/plugins/markdown.js +28 -29
  35. package/plugins/markdown.mjs +28 -29
  36. package/plugins/meriyah.d.ts +8 -0
  37. package/plugins/meriyah.js +5 -6
  38. package/plugins/meriyah.mjs +5 -6
  39. package/plugins/postcss.d.ts +10 -0
  40. package/plugins/postcss.js +32 -43
  41. package/plugins/postcss.mjs +32 -43
  42. package/plugins/typescript.d.ts +8 -0
  43. package/plugins/typescript.js +18 -27
  44. package/plugins/typescript.mjs +18 -27
  45. package/plugins/yaml.d.ts +8 -0
  46. package/plugins/yaml.js +108 -108
  47. package/plugins/yaml.mjs +108 -108
  48. package/standalone.d.ts +33 -0
  49. package/standalone.js +74 -80
  50. package/standalone.mjs +74 -80
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;
54
+ }
55
+ });
56
+
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;
41
85
  }
42
86
  });
43
87
 
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) {
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) {
83
- return false;
84
- }
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;
98
- }
99
- });
100
-
101
- // src/utils/text/skip-trailing-comment.js
102
- function skipTrailingComment(text, index) {
103
- if (index === false) {
124
+ // src/utils/skip-trailing-comment.js
125
+ function skipTrailingComment(text, startIndex) {
126
+ if (startIndex === false) {
104
127
  return false;
105
128
  }
106
- if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
107
- return skipEverythingButNewLine(text, index);
129
+ if (text.charAt(startIndex) === "/" && text.charAt(startIndex + 1) === "/") {
130
+ return skipEverythingButNewLine(text, startIndex);
108
131
  }
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;
163
+ }
164
+ });
165
+
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;
171
200
  }
172
201
  });
173
202
 
174
- // src/utils/is-non-empty-array.js
175
- var init_is_non_empty_array = __esm({
176
- "src/utils/is-non-empty-array.js"() {
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,58 +376,11 @@ var init_get_string_width = __esm({
279
376
  }
280
377
  });
281
378
 
282
- // src/common/util.js
283
- function hasNewline(text, index, opts = {}) {
284
- const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
285
- const idx2 = skip_newline_default(text, idx, opts);
286
- return idx !== idx2;
287
- }
288
- function hasNewlineInRange(text, start, end) {
289
- for (let i = start; i < end; ++i) {
290
- if (text.charAt(i) === "\n") {
291
- return true;
292
- }
293
- }
294
- return false;
295
- }
296
- function isPreviousLineEmpty(text, node, locStart) {
297
- let idx = locStart(node) - 1;
298
- idx = skipSpaces(text, idx, { backwards: true });
299
- idx = skip_newline_default(text, idx, { backwards: true });
300
- idx = skipSpaces(text, idx, { backwards: true });
301
- const idx2 = skip_newline_default(text, idx, { backwards: true });
302
- return idx !== idx2;
303
- }
304
- function isNextLineEmptyAfterIndex(text, index) {
305
- let oldIdx = null;
306
- let idx = index;
307
- while (idx !== oldIdx) {
308
- oldIdx = idx;
309
- idx = skipToLineEnd(text, idx);
310
- idx = skip_inline_comment_default(text, idx);
311
- idx = skipSpaces(text, idx);
312
- }
313
- idx = skip_trailing_comment_default(text, idx);
314
- idx = skip_newline_default(text, idx);
315
- return idx !== false && hasNewline(text, idx);
316
- }
317
- function isNextLineEmpty(text, node, locEnd) {
318
- return isNextLineEmptyAfterIndex(text, locEnd(node));
319
- }
320
- function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
321
- return get_next_non_space_non_comment_character_index_with_start_index_default(
322
- text,
323
- locEnd(node)
324
- );
325
- }
326
- function hasSpaces(text, index, opts = {}) {
327
- const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
328
- return idx !== index;
329
- }
330
- function getAlignmentSize(value, tabWidth, startIndex = 0) {
379
+ // src/utils/get-alignment-size.js
380
+ function getAlignmentSize(text, tabWidth, startIndex = 0) {
331
381
  let size = 0;
332
- for (let i = startIndex; i < value.length; ++i) {
333
- if (value[i] === " ") {
382
+ for (let i = startIndex; i < text.length; ++i) {
383
+ if (text[i] === " ") {
334
384
  size = size + tabWidth - size % tabWidth;
335
385
  } else {
336
386
  size++;
@@ -338,44 +388,141 @@ function getAlignmentSize(value, tabWidth, startIndex = 0) {
338
388
  }
339
389
  return size;
340
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
341
399
  function getIndentSize(value, tabWidth) {
342
400
  const lastNewlineIndex = value.lastIndexOf("\n");
343
401
  if (lastNewlineIndex === -1) {
344
402
  return 0;
345
403
  }
346
- return getAlignmentSize(
404
+ return get_alignment_size_default(
405
+ // All the leading whitespaces
347
406
  value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0],
348
407
  tabWidth
349
408
  );
350
409
  }
351
- 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) {
352
486
  const otherQuote = enclosingQuote === '"' ? "'" : '"';
353
487
  const regex = /\\(.)|(["'])/gs;
354
- const newContent = rawContent.replace(regex, (match, escaped, quote) => {
355
- if (escaped === otherQuote) {
356
- return escaped;
357
- }
358
- if (quote === enclosingQuote) {
359
- return "\\" + quote;
360
- }
361
- if (quote) {
362
- 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;
363
504
  }
364
- return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
365
- });
366
- return enclosingQuote + newContent + enclosingQuote;
367
- }
368
- function getMaxContinuousCount(str, target) {
369
- const results = str.match(
370
- new RegExp(`(${escapeStringRegexp(target)})+`, "g")
371
505
  );
372
- if (results === null) {
373
- 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;
374
513
  }
375
- return results.reduce(
376
- (maxCount, result) => Math.max(maxCount, result.length / target.length),
377
- 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 || ""
378
521
  );
522
+ if (nodeName.length > 20) {
523
+ nodeName = nodeName.slice(0, 19) + "\u2026";
524
+ }
525
+ return nodeType + (nodeName ? " " + nodeName : "");
379
526
  }
380
527
  function addCommentHelper(node, comment) {
381
528
  const comments = node.comments ?? (node.comments = []);
@@ -401,47 +548,30 @@ function addTrailingComment(node, comment) {
401
548
  comment.trailing = true;
402
549
  addCommentHelper(node, comment);
403
550
  }
404
- function describeNodeForDebugging(node) {
405
- const nodeType = node.type || node.kind || "(unknown type)";
406
- let nodeName = String(
407
- 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 || ""
408
- );
409
- if (nodeName.length > 20) {
410
- nodeName = nodeName.slice(0, 19) + "\u2026";
411
- }
412
- return nodeType + (nodeName ? " " + nodeName : "");
413
- }
414
- var init_util = __esm({
415
- "src/common/util.js"() {
416
- init_escape_string_regexp();
417
- init_skip();
418
- init_skip_inline_comment();
419
- init_skip_trailing_comment();
420
- init_skip_newline();
421
- init_get_next_non_space_non_comment_character_index_with_start_index();
422
- init_is_non_empty_array();
423
- init_get_string_width();
551
+ var init_utils = __esm({
552
+ "src/main/comments/utils.js"() {
424
553
  }
425
554
  });
426
555
 
427
- // src/common/util-shared.js
428
- var util_shared_exports = {};
429
- __export(util_shared_exports, {
556
+ // src/utils/public.js
557
+ var public_exports = {};
558
+ __export(public_exports, {
430
559
  addDanglingComment: () => addDanglingComment,
431
560
  addLeadingComment: () => addLeadingComment,
432
561
  addTrailingComment: () => addTrailingComment,
433
- getAlignmentSize: () => getAlignmentSize,
434
- getIndentSize: () => getIndentSize,
435
- getMaxContinuousCount: () => getMaxContinuousCount,
436
- 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,
437
567
  getStringWidth: () => get_string_width_default,
438
- hasNewline: () => hasNewline,
439
- hasNewlineInRange: () => hasNewlineInRange,
440
- hasSpaces: () => hasSpaces,
441
- isNextLineEmpty: () => isNextLineEmpty,
442
- isNextLineEmptyAfterIndex: () => isNextLineEmptyAfterIndex,
443
- isPreviousLineEmpty: () => isPreviousLineEmpty,
444
- makeString: () => makeString,
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,
445
575
  skip: () => skip,
446
576
  skipEverythingButNewLine: () => skipEverythingButNewLine,
447
577
  skipInlineComment: () => skip_inline_comment_default,
@@ -451,16 +581,65 @@ __export(util_shared_exports, {
451
581
  skipTrailingComment: () => skip_trailing_comment_default,
452
582
  skipWhitespace: () => skipWhitespace
453
583
  });
454
- var init_util_shared = __esm({
455
- "src/common/util-shared.js"() {
456
- 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();
457
636
  }
458
637
  });
459
638
 
460
639
  // src/main/version.evaluate.cjs
461
640
  var require_version_evaluate = __commonJS({
462
641
  "src/main/version.evaluate.cjs"(exports2, module2) {
463
- module2.exports = "3.0.0-alpha.4";
642
+ module2.exports = "3.0.0-alpha.5";
464
643
  }
465
644
  });
466
645
 
@@ -499,7 +678,7 @@ for (const name of debugApiFunctionNames) {
499
678
  }
500
679
  prettier.__debug = debugApis;
501
680
  if (true) {
502
- prettier.util = (init_util_shared(), __toCommonJS(util_shared_exports));
681
+ prettier.util = (init_public(), __toCommonJS(public_exports));
503
682
  prettier.doc = require("./doc.js");
504
683
  } else {
505
684
  Object.defineProperties(prettier, {