prettier 3.0.0-alpha.6 → 3.0.0-alpha.8-for-vscode
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/LICENSE +17 -17
- package/bin/prettier.cjs +0 -0
- package/doc.d.ts +2 -10
- package/doc.js +55 -246
- package/doc.mjs +51 -246
- package/index.cjs +1 -1
- package/index.d.ts +26 -8
- package/index.mjs +5920 -20834
- package/internal/cli.mjs +486 -478
- package/internal/{third-party.mjs → internal.mjs} +19 -14
- package/package.json +39 -28
- package/plugins/acorn.d.ts +6 -0
- package/plugins/acorn.js +13 -0
- package/plugins/acorn.mjs +13 -0
- package/plugins/angular.d.ts +5 -9
- package/plugins/angular.js +2 -2
- package/plugins/angular.mjs +2 -2
- package/plugins/babel.d.ts +14 -14
- package/plugins/babel.js +11 -11
- package/plugins/babel.mjs +11 -11
- package/plugins/estree.d.ts +0 -0
- package/plugins/estree.js +35 -0
- package/plugins/estree.mjs +35 -0
- package/plugins/flow.d.ts +2 -6
- package/plugins/flow.js +20 -20
- package/plugins/flow.mjs +20 -20
- package/plugins/glimmer.d.ts +2 -6
- package/plugins/glimmer.js +22 -17
- package/plugins/glimmer.mjs +22 -17
- package/plugins/graphql.d.ts +2 -6
- package/plugins/graphql.js +16 -7
- package/plugins/graphql.mjs +16 -7
- package/plugins/html.d.ts +5 -9
- package/plugins/html.js +19 -17
- package/plugins/html.mjs +19 -17
- package/plugins/markdown.d.ts +4 -8
- package/plugins/markdown.js +54 -33
- package/plugins/markdown.mjs +54 -33
- package/plugins/meriyah.d.ts +2 -6
- package/plugins/meriyah.js +5 -5
- package/plugins/meriyah.mjs +5 -5
- package/plugins/postcss.d.ts +4 -8
- package/plugins/postcss.js +45 -32
- package/plugins/postcss.mjs +45 -32
- package/plugins/typescript.d.ts +2 -6
- package/plugins/typescript.js +24 -20
- package/plugins/typescript.mjs +24 -20
- package/plugins/yaml.d.ts +2 -6
- package/plugins/yaml.js +130 -117
- package/plugins/yaml.mjs +130 -117
- package/standalone.js +27 -90
- package/standalone.mjs +27 -90
- package/plugins/acorn-and-espree.d.ts +0 -10
- package/plugins/acorn-and-espree.js +0 -13
- package/plugins/acorn-and-espree.mjs +0 -13
package/LICENSE
CHANGED
|
@@ -17,7 +17,7 @@ MIT, ISC, BSD-2-Clause, BSD-3-Clause, 0BSD, Apache-2.0
|
|
|
17
17
|
|
|
18
18
|
## Bundled dependencies
|
|
19
19
|
|
|
20
|
-
### @angular/compiler@v15.2.
|
|
20
|
+
### @angular/compiler@v15.2.8
|
|
21
21
|
|
|
22
22
|
> Angular - the compiler library
|
|
23
23
|
|
|
@@ -27,7 +27,7 @@ Author: angular
|
|
|
27
27
|
|
|
28
28
|
----------------------------------------
|
|
29
29
|
|
|
30
|
-
### @babel/code-frame@v7.
|
|
30
|
+
### @babel/code-frame@v7.21.4
|
|
31
31
|
|
|
32
32
|
> Generate errors that contain a code frame that point to source locations.
|
|
33
33
|
|
|
@@ -128,7 +128,7 @@ Author: The Babel Team (https://babel.dev/team)
|
|
|
128
128
|
|
|
129
129
|
----------------------------------------
|
|
130
130
|
|
|
131
|
-
### @babel/parser@v7.21.
|
|
131
|
+
### @babel/parser@v7.21.4
|
|
132
132
|
|
|
133
133
|
> A JavaScript parser
|
|
134
134
|
|
|
@@ -187,7 +187,7 @@ License: MIT
|
|
|
187
187
|
|
|
188
188
|
----------------------------------------
|
|
189
189
|
|
|
190
|
-
### @glimmer/syntax@v0.84.
|
|
190
|
+
### @glimmer/syntax@v0.84.3
|
|
191
191
|
|
|
192
192
|
License: MIT
|
|
193
193
|
|
|
@@ -213,7 +213,7 @@ License: MIT
|
|
|
213
213
|
|
|
214
214
|
----------------------------------------
|
|
215
215
|
|
|
216
|
-
### @glimmer/util@v0.84.
|
|
216
|
+
### @glimmer/util@v0.84.3
|
|
217
217
|
|
|
218
218
|
> Common utilities used in Glimmer
|
|
219
219
|
|
|
@@ -397,7 +397,7 @@ Author: fisker Cheung <lionkay@gmail.com>
|
|
|
397
397
|
|
|
398
398
|
----------------------------------------
|
|
399
399
|
|
|
400
|
-
### @prettier/parse-srcset@
|
|
400
|
+
### @prettier/parse-srcset@v3.0.0
|
|
401
401
|
|
|
402
402
|
> A spec-conformant JavaScript parser for the HTML5 srcset attribute
|
|
403
403
|
|
|
@@ -429,7 +429,7 @@ Author: Alex Bell <alex@bellandwhistle.net>
|
|
|
429
429
|
|
|
430
430
|
----------------------------------------
|
|
431
431
|
|
|
432
|
-
### @typescript-eslint/types@v5.
|
|
432
|
+
### @typescript-eslint/types@v5.58.0
|
|
433
433
|
|
|
434
434
|
> Types for the TypeScript-ESTree AST spec
|
|
435
435
|
|
|
@@ -460,7 +460,7 @@ Repository: <https://github.com/typescript-eslint/typescript-eslint.git>
|
|
|
460
460
|
|
|
461
461
|
----------------------------------------
|
|
462
462
|
|
|
463
|
-
### @typescript-eslint/typescript-estree@v5.
|
|
463
|
+
### @typescript-eslint/typescript-estree@v5.58.0
|
|
464
464
|
|
|
465
465
|
> A parser that converts TypeScript source code into an ESTree compatible form
|
|
466
466
|
|
|
@@ -558,7 +558,7 @@ Repository: <https://github.com/acornjs/acorn-jsx>
|
|
|
558
558
|
|
|
559
559
|
----------------------------------------
|
|
560
560
|
|
|
561
|
-
### angular-estree-parser@v6.
|
|
561
|
+
### angular-estree-parser@v6.2.0
|
|
562
562
|
|
|
563
563
|
> A parser that converts Angular source code into an ESTree-compatible form
|
|
564
564
|
|
|
@@ -1385,7 +1385,7 @@ Contributors:
|
|
|
1385
1385
|
|
|
1386
1386
|
----------------------------------------
|
|
1387
1387
|
|
|
1388
|
-
### editorconfig-to-prettier@
|
|
1388
|
+
### editorconfig-to-prettier@v1.0.0
|
|
1389
1389
|
|
|
1390
1390
|
> Converts an `editorconfig`-parsed object to a `prettier` configuration
|
|
1391
1391
|
|
|
@@ -1508,7 +1508,7 @@ Author: Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
|
1508
1508
|
|
|
1509
1509
|
----------------------------------------
|
|
1510
1510
|
|
|
1511
|
-
### espree@v9.
|
|
1511
|
+
### espree@v9.5.1
|
|
1512
1512
|
|
|
1513
1513
|
> An Esprima-compatible JavaScript parser built on Acorn
|
|
1514
1514
|
|
|
@@ -1904,7 +1904,7 @@ Contributors:
|
|
|
1904
1904
|
|
|
1905
1905
|
----------------------------------------
|
|
1906
1906
|
|
|
1907
|
-
### flow-parser@v0.
|
|
1907
|
+
### flow-parser@v0.204.0
|
|
1908
1908
|
|
|
1909
1909
|
> JavaScript parser written in OCaml. Produces ESTree AST
|
|
1910
1910
|
|
|
@@ -2150,7 +2150,7 @@ Author: Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
|
2150
2150
|
|
|
2151
2151
|
----------------------------------------
|
|
2152
2152
|
|
|
2153
|
-
### import-meta-resolve@v2.2.
|
|
2153
|
+
### import-meta-resolve@v2.2.2
|
|
2154
2154
|
|
|
2155
2155
|
> Resolve things like Node.js — ponyfill for `import.meta.resolve`
|
|
2156
2156
|
|
|
@@ -3164,7 +3164,7 @@ Repository: <git@github.com:teambition/merge2.git>
|
|
|
3164
3164
|
|
|
3165
3165
|
----------------------------------------
|
|
3166
3166
|
|
|
3167
|
-
### meriyah@v4.3.
|
|
3167
|
+
### meriyah@v4.3.5
|
|
3168
3168
|
|
|
3169
3169
|
> A 100% compliant, self-hosted javascript parser with high focus on both performance and stability
|
|
3170
3170
|
|
|
@@ -3339,7 +3339,7 @@ Author: Yoan Arnaudov <jonidev@gmail.com>
|
|
|
3339
3339
|
|
|
3340
3340
|
----------------------------------------
|
|
3341
3341
|
|
|
3342
|
-
### nanoid@v3.3.
|
|
3342
|
+
### nanoid@v3.3.6
|
|
3343
3343
|
|
|
3344
3344
|
> A tiny (116 bytes), secure URL-friendly unique string ID generator
|
|
3345
3345
|
|
|
@@ -3695,7 +3695,7 @@ Author: typicode
|
|
|
3695
3695
|
|
|
3696
3696
|
----------------------------------------
|
|
3697
3697
|
|
|
3698
|
-
### postcss@v8.4.
|
|
3698
|
+
### postcss@v8.4.23
|
|
3699
3699
|
|
|
3700
3700
|
> Tool for transforming styles with JS plugins
|
|
3701
3701
|
|
|
@@ -4544,7 +4544,7 @@ Author: Klaus Meinhardt
|
|
|
4544
4544
|
|
|
4545
4545
|
----------------------------------------
|
|
4546
4546
|
|
|
4547
|
-
### typescript@
|
|
4547
|
+
### typescript@v5.0.4
|
|
4548
4548
|
|
|
4549
4549
|
> TypeScript is a language for application scale JavaScript development
|
|
4550
4550
|
|
package/bin/prettier.cjs
CHANGED
|
File without changes
|
package/doc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// https://github.com/prettier/prettier/blob/next/src/document/
|
|
1
|
+
// https://github.com/prettier/prettier/blob/next/src/document/public.js
|
|
2
2
|
export namespace builders {
|
|
3
3
|
type DocCommand =
|
|
4
4
|
| Align
|
|
@@ -183,10 +183,6 @@ export namespace builders {
|
|
|
183
183
|
const cursor: Cursor;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
export namespace debug {
|
|
187
|
-
function printDocToDebug(doc: builders.Doc): string;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
186
|
export namespace printer {
|
|
191
187
|
function printDocToString(
|
|
192
188
|
doc: builders.Doc,
|
|
@@ -211,14 +207,13 @@ export namespace printer {
|
|
|
211
207
|
* Indent lines with tabs instead of spaces
|
|
212
208
|
* @default false
|
|
213
209
|
*/
|
|
214
|
-
useTabs
|
|
210
|
+
useTabs?: boolean;
|
|
215
211
|
parentParser?: string | undefined;
|
|
216
212
|
__embeddedInHtml?: boolean | undefined;
|
|
217
213
|
}
|
|
218
214
|
}
|
|
219
215
|
|
|
220
216
|
export namespace utils {
|
|
221
|
-
function getDocParts(doc: builders.Doc): builders.Doc;
|
|
222
217
|
function willBreak(doc: builders.Doc): boolean;
|
|
223
218
|
function traverseDoc(
|
|
224
219
|
doc: builders.Doc,
|
|
@@ -235,14 +230,11 @@ export namespace utils {
|
|
|
235
230
|
doc: builders.Doc,
|
|
236
231
|
callback: (doc: builders.Doc) => T
|
|
237
232
|
): T;
|
|
238
|
-
function propagateBreaks(doc: builders.Doc): void;
|
|
239
233
|
function removeLines(doc: builders.Doc): builders.Doc;
|
|
240
234
|
function stripTrailingHardline(doc: builders.Doc): builders.Doc;
|
|
241
|
-
function cleanDoc(doc: builders.Doc): builders.Doc;
|
|
242
235
|
function replaceEndOfLine(
|
|
243
236
|
doc: builders.Doc,
|
|
244
237
|
replacement?: builders.Doc
|
|
245
238
|
): builders.Doc;
|
|
246
239
|
function canBreak(doc: builders.Doc): boolean;
|
|
247
|
-
function getDocType(doc: builders.Doc): string;
|
|
248
240
|
}
|
package/doc.js
CHANGED
|
@@ -62,43 +62,12 @@
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
// src/document/
|
|
66
|
-
var
|
|
67
|
-
__export(
|
|
68
|
-
builders: () =>
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
utils: () => utils_exports
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// src/document/builders.js
|
|
75
|
-
var builders_exports = {};
|
|
76
|
-
__export(builders_exports, {
|
|
77
|
-
addAlignmentToDoc: () => addAlignmentToDoc,
|
|
78
|
-
align: () => align,
|
|
79
|
-
breakParent: () => breakParent,
|
|
80
|
-
concat: () => concat,
|
|
81
|
-
conditionalGroup: () => conditionalGroup,
|
|
82
|
-
cursor: () => cursor,
|
|
83
|
-
dedent: () => dedent,
|
|
84
|
-
dedentToRoot: () => dedentToRoot,
|
|
85
|
-
fill: () => fill,
|
|
86
|
-
group: () => group,
|
|
87
|
-
hardline: () => hardline,
|
|
88
|
-
hardlineWithoutBreakParent: () => hardlineWithoutBreakParent,
|
|
89
|
-
ifBreak: () => ifBreak,
|
|
90
|
-
indent: () => indent,
|
|
91
|
-
indentIfBreak: () => indentIfBreak,
|
|
92
|
-
join: () => join,
|
|
93
|
-
label: () => label,
|
|
94
|
-
line: () => line,
|
|
95
|
-
lineSuffix: () => lineSuffix,
|
|
96
|
-
lineSuffixBoundary: () => lineSuffixBoundary,
|
|
97
|
-
literalline: () => literalline,
|
|
98
|
-
literallineWithoutBreakParent: () => literallineWithoutBreakParent,
|
|
99
|
-
markAsRoot: () => markAsRoot,
|
|
100
|
-
softline: () => softline,
|
|
101
|
-
trim: () => trim
|
|
65
|
+
// src/document/public.js
|
|
66
|
+
var public_exports = {};
|
|
67
|
+
__export(public_exports, {
|
|
68
|
+
builders: () => builders,
|
|
69
|
+
printer: () => printer,
|
|
70
|
+
utils: () => utils
|
|
102
71
|
});
|
|
103
72
|
|
|
104
73
|
// src/document/constants.js
|
|
@@ -375,20 +344,16 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
375
344
|
assertDoc(contents);
|
|
376
345
|
return label2 ? { type: DOC_TYPE_LABEL, label: label2, contents } : contents;
|
|
377
346
|
}
|
|
378
|
-
var concat = (parts) => parts;
|
|
379
|
-
|
|
380
|
-
// src/document/printer.js
|
|
381
|
-
var printer_exports = {};
|
|
382
|
-
__export(printer_exports, {
|
|
383
|
-
printDocToString: () => printDocToString
|
|
384
|
-
});
|
|
385
347
|
|
|
386
348
|
// scripts/build/shims/at.js
|
|
387
349
|
var at = (isOptionalObject, object, index) => {
|
|
388
350
|
if (isOptionalObject && (object === void 0 || object === null)) {
|
|
389
351
|
return;
|
|
390
352
|
}
|
|
391
|
-
|
|
353
|
+
if (Array.isArray(object) || typeof object === "string") {
|
|
354
|
+
return object[index < 0 ? object.length + index : index];
|
|
355
|
+
}
|
|
356
|
+
return object.at(index);
|
|
392
357
|
};
|
|
393
358
|
var at_default = at;
|
|
394
359
|
|
|
@@ -501,23 +466,6 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
501
466
|
var get_string_width_default = getStringWidth;
|
|
502
467
|
|
|
503
468
|
// src/document/utils.js
|
|
504
|
-
var utils_exports = {};
|
|
505
|
-
__export(utils_exports, {
|
|
506
|
-
canBreak: () => canBreak,
|
|
507
|
-
cleanDoc: () => cleanDoc,
|
|
508
|
-
findInDoc: () => findInDoc,
|
|
509
|
-
getDocParts: () => getDocParts,
|
|
510
|
-
getDocType: () => get_doc_type_default,
|
|
511
|
-
mapDoc: () => mapDoc,
|
|
512
|
-
normalizeDoc: () => normalizeDoc,
|
|
513
|
-
normalizeParts: () => normalizeParts,
|
|
514
|
-
propagateBreaks: () => propagateBreaks,
|
|
515
|
-
removeLines: () => removeLines,
|
|
516
|
-
replaceEndOfLine: () => replaceEndOfLine,
|
|
517
|
-
stripTrailingHardline: () => stripTrailingHardline,
|
|
518
|
-
traverseDoc: () => traverse_doc_default,
|
|
519
|
-
willBreak: () => willBreak
|
|
520
|
-
});
|
|
521
469
|
var getDocParts = (doc) => {
|
|
522
470
|
if (Array.isArray(doc)) {
|
|
523
471
|
return doc;
|
|
@@ -821,45 +769,6 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
821
769
|
function cleanDoc(doc) {
|
|
822
770
|
return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
|
|
823
771
|
}
|
|
824
|
-
function normalizeParts(parts) {
|
|
825
|
-
const newParts = [];
|
|
826
|
-
const restParts = parts.filter(Boolean);
|
|
827
|
-
while (restParts.length > 0) {
|
|
828
|
-
const part = restParts.shift();
|
|
829
|
-
if (!part) {
|
|
830
|
-
continue;
|
|
831
|
-
}
|
|
832
|
-
if (Array.isArray(part)) {
|
|
833
|
-
restParts.unshift(...part);
|
|
834
|
-
continue;
|
|
835
|
-
}
|
|
836
|
-
if (newParts.length > 0 && typeof at_default(
|
|
837
|
-
/* isOptionalObject*/
|
|
838
|
-
false,
|
|
839
|
-
newParts,
|
|
840
|
-
-1
|
|
841
|
-
) === "string" && typeof part === "string") {
|
|
842
|
-
newParts[newParts.length - 1] += part;
|
|
843
|
-
continue;
|
|
844
|
-
}
|
|
845
|
-
newParts.push(part);
|
|
846
|
-
}
|
|
847
|
-
return newParts;
|
|
848
|
-
}
|
|
849
|
-
function normalizeDoc(doc) {
|
|
850
|
-
return mapDoc(doc, (currentDoc) => {
|
|
851
|
-
if (Array.isArray(currentDoc)) {
|
|
852
|
-
return normalizeParts(currentDoc);
|
|
853
|
-
}
|
|
854
|
-
if (!currentDoc.parts) {
|
|
855
|
-
return currentDoc;
|
|
856
|
-
}
|
|
857
|
-
return {
|
|
858
|
-
...currentDoc,
|
|
859
|
-
parts: normalizeParts(currentDoc.parts)
|
|
860
|
-
};
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
772
|
function replaceEndOfLine(doc, replacement = literalline) {
|
|
864
773
|
return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ? join(replacement, currentDoc.split("\n")) : currentDoc);
|
|
865
774
|
}
|
|
@@ -1013,6 +922,9 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
1013
922
|
return trimCount;
|
|
1014
923
|
}
|
|
1015
924
|
function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat) {
|
|
925
|
+
if (width === Number.POSITIVE_INFINITY) {
|
|
926
|
+
return true;
|
|
927
|
+
}
|
|
1016
928
|
let restIdx = restCommands.length;
|
|
1017
929
|
const cmds = [next];
|
|
1018
930
|
const out = [];
|
|
@@ -1119,6 +1031,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
1119
1031
|
let shouldRemeasure = false;
|
|
1120
1032
|
const lineSuffix2 = [];
|
|
1121
1033
|
let printedCursorCount = 0;
|
|
1034
|
+
propagateBreaks(doc);
|
|
1122
1035
|
while (cmds.length > 0) {
|
|
1123
1036
|
const {
|
|
1124
1037
|
ind,
|
|
@@ -1434,149 +1347,45 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
|
|
1434
1347
|
};
|
|
1435
1348
|
}
|
|
1436
1349
|
|
|
1437
|
-
// src/document/
|
|
1438
|
-
var
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
if (doc.contents) {
|
|
1479
|
-
return { ...doc, contents: flattenDoc(doc.contents) };
|
|
1480
|
-
}
|
|
1481
|
-
return doc;
|
|
1482
|
-
}
|
|
1483
|
-
function printDocToDebug(doc) {
|
|
1484
|
-
const printedSymbols = /* @__PURE__ */ Object.create(null);
|
|
1485
|
-
const usedKeysForSymbols = /* @__PURE__ */ new Set();
|
|
1486
|
-
return printDoc(flattenDoc(doc));
|
|
1487
|
-
function printDoc(doc2, index, parentParts) {
|
|
1488
|
-
var _a, _b;
|
|
1489
|
-
if (typeof doc2 === "string") {
|
|
1490
|
-
return JSON.stringify(doc2);
|
|
1491
|
-
}
|
|
1492
|
-
if (Array.isArray(doc2)) {
|
|
1493
|
-
const printed = doc2.map(printDoc).filter(Boolean);
|
|
1494
|
-
return printed.length === 1 ? printed[0] : `[${printed.join(", ")}]`;
|
|
1495
|
-
}
|
|
1496
|
-
if (doc2.type === DOC_TYPE_LINE) {
|
|
1497
|
-
const withBreakParent = ((_a = parentParts == null ? void 0 : parentParts[index + 1]) == null ? void 0 : _a.type) === DOC_TYPE_BREAK_PARENT;
|
|
1498
|
-
if (doc2.literal) {
|
|
1499
|
-
return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
|
|
1500
|
-
}
|
|
1501
|
-
if (doc2.hard) {
|
|
1502
|
-
return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
|
|
1503
|
-
}
|
|
1504
|
-
if (doc2.soft) {
|
|
1505
|
-
return "softline";
|
|
1506
|
-
}
|
|
1507
|
-
return "line";
|
|
1508
|
-
}
|
|
1509
|
-
if (doc2.type === DOC_TYPE_BREAK_PARENT) {
|
|
1510
|
-
const afterHardline = ((_b = parentParts == null ? void 0 : parentParts[index - 1]) == null ? void 0 : _b.type) === DOC_TYPE_LINE && parentParts[index - 1].hard;
|
|
1511
|
-
return afterHardline ? void 0 : "breakParent";
|
|
1512
|
-
}
|
|
1513
|
-
if (doc2.type === DOC_TYPE_TRIM) {
|
|
1514
|
-
return "trim";
|
|
1515
|
-
}
|
|
1516
|
-
if (doc2.type === DOC_TYPE_INDENT) {
|
|
1517
|
-
return "indent(" + printDoc(doc2.contents) + ")";
|
|
1518
|
-
}
|
|
1519
|
-
if (doc2.type === DOC_TYPE_ALIGN) {
|
|
1520
|
-
return doc2.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc2.contents) + ")" : doc2.n < 0 ? "dedent(" + printDoc(doc2.contents) + ")" : doc2.n.type === "root" ? "markAsRoot(" + printDoc(doc2.contents) + ")" : "align(" + JSON.stringify(doc2.n) + ", " + printDoc(doc2.contents) + ")";
|
|
1521
|
-
}
|
|
1522
|
-
if (doc2.type === DOC_TYPE_IF_BREAK) {
|
|
1523
|
-
return "ifBreak(" + printDoc(doc2.breakContents) + (doc2.flatContents ? ", " + printDoc(doc2.flatContents) : "") + (doc2.groupId ? (!doc2.flatContents ? ', ""' : "") + `, { groupId: ${printGroupId(doc2.groupId)} }` : "") + ")";
|
|
1524
|
-
}
|
|
1525
|
-
if (doc2.type === DOC_TYPE_INDENT_IF_BREAK) {
|
|
1526
|
-
const optionsParts = [];
|
|
1527
|
-
if (doc2.negate) {
|
|
1528
|
-
optionsParts.push("negate: true");
|
|
1529
|
-
}
|
|
1530
|
-
if (doc2.groupId) {
|
|
1531
|
-
optionsParts.push(`groupId: ${printGroupId(doc2.groupId)}`);
|
|
1532
|
-
}
|
|
1533
|
-
const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
|
|
1534
|
-
return `indentIfBreak(${printDoc(doc2.contents)}${options})`;
|
|
1535
|
-
}
|
|
1536
|
-
if (doc2.type === DOC_TYPE_GROUP) {
|
|
1537
|
-
const optionsParts = [];
|
|
1538
|
-
if (doc2.break && doc2.break !== "propagated") {
|
|
1539
|
-
optionsParts.push("shouldBreak: true");
|
|
1540
|
-
}
|
|
1541
|
-
if (doc2.id) {
|
|
1542
|
-
optionsParts.push(`id: ${printGroupId(doc2.id)}`);
|
|
1543
|
-
}
|
|
1544
|
-
const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
|
|
1545
|
-
if (doc2.expandedStates) {
|
|
1546
|
-
return `conditionalGroup([${doc2.expandedStates.map((part) => printDoc(part)).join(",")}]${options})`;
|
|
1547
|
-
}
|
|
1548
|
-
return `group(${printDoc(doc2.contents)}${options})`;
|
|
1549
|
-
}
|
|
1550
|
-
if (doc2.type === DOC_TYPE_FILL) {
|
|
1551
|
-
return `fill([${doc2.parts.map((part) => printDoc(part)).join(", ")}])`;
|
|
1552
|
-
}
|
|
1553
|
-
if (doc2.type === DOC_TYPE_LINE_SUFFIX) {
|
|
1554
|
-
return "lineSuffix(" + printDoc(doc2.contents) + ")";
|
|
1555
|
-
}
|
|
1556
|
-
if (doc2.type === DOC_TYPE_LINE_SUFFIX_BOUNDARY) {
|
|
1557
|
-
return "lineSuffixBoundary";
|
|
1558
|
-
}
|
|
1559
|
-
if (doc2.type === DOC_TYPE_LABEL) {
|
|
1560
|
-
return `label(${JSON.stringify(doc2.label)}, ${printDoc(doc2.contents)})`;
|
|
1561
|
-
}
|
|
1562
|
-
throw new Error("Unknown doc type " + doc2.type);
|
|
1563
|
-
}
|
|
1564
|
-
function printGroupId(id) {
|
|
1565
|
-
if (typeof id !== "symbol") {
|
|
1566
|
-
return JSON.stringify(String(id));
|
|
1567
|
-
}
|
|
1568
|
-
if (id in printedSymbols) {
|
|
1569
|
-
return printedSymbols[id];
|
|
1570
|
-
}
|
|
1571
|
-
const prefix = id.description || "symbol";
|
|
1572
|
-
for (let counter = 0; ; counter++) {
|
|
1573
|
-
const key = prefix + (counter > 0 ? ` #${counter}` : "");
|
|
1574
|
-
if (!usedKeysForSymbols.has(key)) {
|
|
1575
|
-
usedKeysForSymbols.add(key);
|
|
1576
|
-
return printedSymbols[id] = `Symbol.for(${JSON.stringify(key)})`;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
return __toCommonJS(document_exports);
|
|
1350
|
+
// src/document/public.js
|
|
1351
|
+
var builders = {
|
|
1352
|
+
join,
|
|
1353
|
+
line,
|
|
1354
|
+
softline,
|
|
1355
|
+
hardline,
|
|
1356
|
+
literalline,
|
|
1357
|
+
group,
|
|
1358
|
+
conditionalGroup,
|
|
1359
|
+
fill,
|
|
1360
|
+
lineSuffix,
|
|
1361
|
+
lineSuffixBoundary,
|
|
1362
|
+
cursor,
|
|
1363
|
+
breakParent,
|
|
1364
|
+
ifBreak,
|
|
1365
|
+
trim,
|
|
1366
|
+
indent,
|
|
1367
|
+
indentIfBreak,
|
|
1368
|
+
align,
|
|
1369
|
+
addAlignmentToDoc,
|
|
1370
|
+
markAsRoot,
|
|
1371
|
+
dedentToRoot,
|
|
1372
|
+
dedent,
|
|
1373
|
+
hardlineWithoutBreakParent,
|
|
1374
|
+
literallineWithoutBreakParent,
|
|
1375
|
+
label,
|
|
1376
|
+
// TODO: Remove this in v4
|
|
1377
|
+
concat: (parts) => parts
|
|
1378
|
+
};
|
|
1379
|
+
var printer = { printDocToString };
|
|
1380
|
+
var utils = {
|
|
1381
|
+
willBreak,
|
|
1382
|
+
traverseDoc: traverse_doc_default,
|
|
1383
|
+
findInDoc,
|
|
1384
|
+
mapDoc,
|
|
1385
|
+
removeLines,
|
|
1386
|
+
stripTrailingHardline,
|
|
1387
|
+
replaceEndOfLine,
|
|
1388
|
+
canBreak
|
|
1389
|
+
};
|
|
1390
|
+
return __toCommonJS(public_exports);
|
|
1582
1391
|
});
|