prettier 3.2.2 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -2
- data/README.md +23 -59
- data/lib/prettier.rb +7 -5
- data/node_modules/prettier/LICENSE +5205 -0
- data/node_modules/prettier/README.md +109 -0
- data/node_modules/prettier/{bin-prettier.js → bin/prettier.cjs} +10 -5
- data/node_modules/prettier/doc.d.ts +240 -0
- data/node_modules/prettier/doc.js +1257 -1309
- data/node_modules/prettier/doc.mjs +1312 -0
- data/node_modules/prettier/index.cjs +655 -0
- data/node_modules/prettier/index.d.ts +915 -0
- data/node_modules/prettier/index.mjs +21845 -0
- data/node_modules/prettier/internal/cli.mjs +6978 -0
- data/node_modules/prettier/internal/internal.mjs +6531 -0
- data/node_modules/prettier/package.json +179 -6
- data/node_modules/prettier/plugins/acorn.d.ts +6 -0
- data/node_modules/prettier/plugins/acorn.js +13 -0
- data/node_modules/prettier/plugins/acorn.mjs +13 -0
- data/node_modules/prettier/plugins/angular.d.ts +8 -0
- data/node_modules/prettier/plugins/angular.js +2 -0
- data/node_modules/prettier/plugins/angular.mjs +2 -0
- data/node_modules/prettier/plugins/babel.d.ts +17 -0
- data/node_modules/prettier/plugins/babel.js +16 -0
- data/node_modules/prettier/plugins/babel.mjs +16 -0
- data/node_modules/prettier/plugins/estree.d.ts +0 -0
- data/node_modules/prettier/plugins/estree.js +35 -0
- data/node_modules/prettier/plugins/estree.mjs +35 -0
- data/node_modules/prettier/plugins/flow.d.ts +5 -0
- data/node_modules/prettier/plugins/flow.js +21 -0
- data/node_modules/prettier/plugins/flow.mjs +21 -0
- data/node_modules/prettier/plugins/glimmer.d.ts +5 -0
- data/node_modules/prettier/plugins/glimmer.js +30 -0
- data/node_modules/prettier/plugins/glimmer.mjs +30 -0
- data/node_modules/prettier/plugins/graphql.d.ts +5 -0
- data/node_modules/prettier/plugins/graphql.js +29 -0
- data/node_modules/prettier/plugins/graphql.mjs +29 -0
- data/node_modules/prettier/plugins/html.d.ts +8 -0
- data/node_modules/prettier/plugins/html.js +19 -0
- data/node_modules/prettier/plugins/html.mjs +19 -0
- data/node_modules/prettier/plugins/markdown.d.ts +7 -0
- data/node_modules/prettier/plugins/markdown.js +59 -0
- data/node_modules/prettier/plugins/markdown.mjs +59 -0
- data/node_modules/prettier/plugins/meriyah.d.ts +5 -0
- data/node_modules/prettier/plugins/meriyah.js +5 -0
- data/node_modules/prettier/plugins/meriyah.mjs +5 -0
- data/node_modules/prettier/plugins/postcss.d.ts +7 -0
- data/node_modules/prettier/plugins/postcss.js +52 -0
- data/node_modules/prettier/plugins/postcss.mjs +52 -0
- data/node_modules/prettier/plugins/typescript.d.ts +5 -0
- data/node_modules/prettier/plugins/typescript.js +27 -0
- data/node_modules/prettier/plugins/typescript.mjs +27 -0
- data/node_modules/prettier/plugins/yaml.d.ts +5 -0
- data/node_modules/prettier/plugins/yaml.js +161 -0
- data/node_modules/prettier/plugins/yaml.mjs +161 -0
- data/node_modules/prettier/standalone.d.ts +33 -0
- data/node_modules/prettier/standalone.js +34 -0
- data/node_modules/prettier/standalone.mjs +34 -0
- data/package.json +15 -10
- data/src/plugin.js +210 -14
- data/src/server.rb +50 -87
- metadata +60 -28
- data/CONTRIBUTING.md +0 -185
- data/node_modules/prettier/cli.js +0 -15085
- data/node_modules/prettier/index.js +0 -37282
- data/node_modules/prettier/parser-angular.js +0 -2
- data/node_modules/prettier/parser-babel.js +0 -27
- data/node_modules/prettier/parser-espree.js +0 -26
- data/node_modules/prettier/parser-flow.js +0 -35
- data/node_modules/prettier/parser-glimmer.js +0 -27
- data/node_modules/prettier/parser-graphql.js +0 -15
- data/node_modules/prettier/parser-html.js +0 -36
- data/node_modules/prettier/parser-markdown.js +0 -76
- data/node_modules/prettier/parser-meriyah.js +0 -19
- data/node_modules/prettier/parser-postcss.js +0 -76
- data/node_modules/prettier/parser-typescript.js +0 -280
- data/node_modules/prettier/parser-yaml.js +0 -150
- data/node_modules/prettier/third-party.js +0 -8978
- data/src/getInfo.js +0 -23
- data/src/netcat.js +0 -13
- data/src/parseSync.js +0 -236
@@ -0,0 +1,1312 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __export = (target, all) => {
|
3
|
+
for (var name in all)
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
5
|
+
};
|
6
|
+
|
7
|
+
// src/document/public.js
|
8
|
+
var public_exports = {};
|
9
|
+
__export(public_exports, {
|
10
|
+
builders: () => builders,
|
11
|
+
printer: () => printer,
|
12
|
+
utils: () => utils
|
13
|
+
});
|
14
|
+
|
15
|
+
// src/document/constants.js
|
16
|
+
var DOC_TYPE_STRING = "string";
|
17
|
+
var DOC_TYPE_ARRAY = "array";
|
18
|
+
var DOC_TYPE_CURSOR = "cursor";
|
19
|
+
var DOC_TYPE_INDENT = "indent";
|
20
|
+
var DOC_TYPE_ALIGN = "align";
|
21
|
+
var DOC_TYPE_TRIM = "trim";
|
22
|
+
var DOC_TYPE_GROUP = "group";
|
23
|
+
var DOC_TYPE_FILL = "fill";
|
24
|
+
var DOC_TYPE_IF_BREAK = "if-break";
|
25
|
+
var DOC_TYPE_INDENT_IF_BREAK = "indent-if-break";
|
26
|
+
var DOC_TYPE_LINE_SUFFIX = "line-suffix";
|
27
|
+
var DOC_TYPE_LINE_SUFFIX_BOUNDARY = "line-suffix-boundary";
|
28
|
+
var DOC_TYPE_LINE = "line";
|
29
|
+
var DOC_TYPE_LABEL = "label";
|
30
|
+
var DOC_TYPE_BREAK_PARENT = "break-parent";
|
31
|
+
var VALID_OBJECT_DOC_TYPES = /* @__PURE__ */ new Set([
|
32
|
+
DOC_TYPE_CURSOR,
|
33
|
+
DOC_TYPE_INDENT,
|
34
|
+
DOC_TYPE_ALIGN,
|
35
|
+
DOC_TYPE_TRIM,
|
36
|
+
DOC_TYPE_GROUP,
|
37
|
+
DOC_TYPE_FILL,
|
38
|
+
DOC_TYPE_IF_BREAK,
|
39
|
+
DOC_TYPE_INDENT_IF_BREAK,
|
40
|
+
DOC_TYPE_LINE_SUFFIX,
|
41
|
+
DOC_TYPE_LINE_SUFFIX_BOUNDARY,
|
42
|
+
DOC_TYPE_LINE,
|
43
|
+
DOC_TYPE_LABEL,
|
44
|
+
DOC_TYPE_BREAK_PARENT
|
45
|
+
]);
|
46
|
+
|
47
|
+
// src/document/utils/get-doc-type.js
|
48
|
+
function getDocType(doc) {
|
49
|
+
if (typeof doc === "string") {
|
50
|
+
return DOC_TYPE_STRING;
|
51
|
+
}
|
52
|
+
if (Array.isArray(doc)) {
|
53
|
+
return DOC_TYPE_ARRAY;
|
54
|
+
}
|
55
|
+
if (!doc) {
|
56
|
+
return;
|
57
|
+
}
|
58
|
+
const { type } = doc;
|
59
|
+
if (VALID_OBJECT_DOC_TYPES.has(type)) {
|
60
|
+
return type;
|
61
|
+
}
|
62
|
+
}
|
63
|
+
var get_doc_type_default = getDocType;
|
64
|
+
|
65
|
+
// src/document/invalid-doc-error.js
|
66
|
+
var disjunctionListFormat = (list) => new Intl.ListFormat("en-US", { type: "disjunction" }).format(list);
|
67
|
+
function getDocErrorMessage(doc) {
|
68
|
+
const type = doc === null ? "null" : typeof doc;
|
69
|
+
if (type !== "string" && type !== "object") {
|
70
|
+
return `Unexpected doc '${type}',
|
71
|
+
Expected it to be 'string' or 'object'.`;
|
72
|
+
}
|
73
|
+
if (get_doc_type_default(doc)) {
|
74
|
+
throw new Error("doc is valid.");
|
75
|
+
}
|
76
|
+
const objectType = Object.prototype.toString.call(doc);
|
77
|
+
if (objectType !== "[object Object]") {
|
78
|
+
return `Unexpected doc '${objectType}'.`;
|
79
|
+
}
|
80
|
+
const EXPECTED_TYPE_VALUES = disjunctionListFormat(
|
81
|
+
[...VALID_OBJECT_DOC_TYPES].map((type2) => `'${type2}'`)
|
82
|
+
);
|
83
|
+
return `Unexpected doc.type '${doc.type}'.
|
84
|
+
Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
85
|
+
}
|
86
|
+
var InvalidDocError = class extends Error {
|
87
|
+
name = "InvalidDocError";
|
88
|
+
constructor(doc) {
|
89
|
+
super(getDocErrorMessage(doc));
|
90
|
+
this.doc = doc;
|
91
|
+
}
|
92
|
+
};
|
93
|
+
var invalid_doc_error_default = InvalidDocError;
|
94
|
+
|
95
|
+
// src/document/utils/traverse-doc.js
|
96
|
+
var traverseDocOnExitStackMarker = {};
|
97
|
+
function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
|
98
|
+
const docsStack = [doc];
|
99
|
+
while (docsStack.length > 0) {
|
100
|
+
const doc2 = docsStack.pop();
|
101
|
+
if (doc2 === traverseDocOnExitStackMarker) {
|
102
|
+
onExit(docsStack.pop());
|
103
|
+
continue;
|
104
|
+
}
|
105
|
+
if (onExit) {
|
106
|
+
docsStack.push(doc2, traverseDocOnExitStackMarker);
|
107
|
+
}
|
108
|
+
const docType = get_doc_type_default(doc2);
|
109
|
+
if (!docType) {
|
110
|
+
throw new invalid_doc_error_default(doc2);
|
111
|
+
}
|
112
|
+
if ((onEnter == null ? void 0 : onEnter(doc2)) === false) {
|
113
|
+
continue;
|
114
|
+
}
|
115
|
+
switch (docType) {
|
116
|
+
case DOC_TYPE_ARRAY:
|
117
|
+
case DOC_TYPE_FILL: {
|
118
|
+
const parts = docType === DOC_TYPE_ARRAY ? doc2 : doc2.parts;
|
119
|
+
for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
|
120
|
+
docsStack.push(parts[i]);
|
121
|
+
}
|
122
|
+
break;
|
123
|
+
}
|
124
|
+
case DOC_TYPE_IF_BREAK:
|
125
|
+
docsStack.push(doc2.flatContents, doc2.breakContents);
|
126
|
+
break;
|
127
|
+
case DOC_TYPE_GROUP:
|
128
|
+
if (shouldTraverseConditionalGroups && doc2.expandedStates) {
|
129
|
+
for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
|
130
|
+
docsStack.push(doc2.expandedStates[i]);
|
131
|
+
}
|
132
|
+
} else {
|
133
|
+
docsStack.push(doc2.contents);
|
134
|
+
}
|
135
|
+
break;
|
136
|
+
case DOC_TYPE_ALIGN:
|
137
|
+
case DOC_TYPE_INDENT:
|
138
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
139
|
+
case DOC_TYPE_LABEL:
|
140
|
+
case DOC_TYPE_LINE_SUFFIX:
|
141
|
+
docsStack.push(doc2.contents);
|
142
|
+
break;
|
143
|
+
case DOC_TYPE_STRING:
|
144
|
+
case DOC_TYPE_CURSOR:
|
145
|
+
case DOC_TYPE_TRIM:
|
146
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
147
|
+
case DOC_TYPE_LINE:
|
148
|
+
case DOC_TYPE_BREAK_PARENT:
|
149
|
+
break;
|
150
|
+
default:
|
151
|
+
throw new invalid_doc_error_default(doc2);
|
152
|
+
}
|
153
|
+
}
|
154
|
+
}
|
155
|
+
var traverse_doc_default = traverseDoc;
|
156
|
+
|
157
|
+
// src/document/utils/assert-doc.js
|
158
|
+
var noop = () => {
|
159
|
+
};
|
160
|
+
var assertDoc = true ? noop : function(doc) {
|
161
|
+
traverse_doc_default(doc, (doc2) => {
|
162
|
+
if (checked.has(doc2)) {
|
163
|
+
return false;
|
164
|
+
}
|
165
|
+
if (typeof doc2 !== "string") {
|
166
|
+
checked.add(doc2);
|
167
|
+
}
|
168
|
+
});
|
169
|
+
};
|
170
|
+
var assertDocArray = true ? noop : function(docs, optional = false) {
|
171
|
+
if (optional && !docs) {
|
172
|
+
return;
|
173
|
+
}
|
174
|
+
if (!Array.isArray(docs)) {
|
175
|
+
throw new TypeError("Unexpected doc array.");
|
176
|
+
}
|
177
|
+
for (const doc of docs) {
|
178
|
+
assertDoc(doc);
|
179
|
+
}
|
180
|
+
};
|
181
|
+
|
182
|
+
// src/document/builders.js
|
183
|
+
function indent(contents) {
|
184
|
+
assertDoc(contents);
|
185
|
+
return { type: DOC_TYPE_INDENT, contents };
|
186
|
+
}
|
187
|
+
function align(widthOrString, contents) {
|
188
|
+
assertDoc(contents);
|
189
|
+
return { type: DOC_TYPE_ALIGN, contents, n: widthOrString };
|
190
|
+
}
|
191
|
+
function group(contents, opts = {}) {
|
192
|
+
assertDoc(contents);
|
193
|
+
assertDocArray(
|
194
|
+
opts.expandedStates,
|
195
|
+
/* optional */
|
196
|
+
true
|
197
|
+
);
|
198
|
+
return {
|
199
|
+
type: DOC_TYPE_GROUP,
|
200
|
+
id: opts.id,
|
201
|
+
contents,
|
202
|
+
break: Boolean(opts.shouldBreak),
|
203
|
+
expandedStates: opts.expandedStates
|
204
|
+
};
|
205
|
+
}
|
206
|
+
function dedentToRoot(contents) {
|
207
|
+
return align(Number.NEGATIVE_INFINITY, contents);
|
208
|
+
}
|
209
|
+
function markAsRoot(contents) {
|
210
|
+
return align({ type: "root" }, contents);
|
211
|
+
}
|
212
|
+
function dedent(contents) {
|
213
|
+
return align(-1, contents);
|
214
|
+
}
|
215
|
+
function conditionalGroup(states, opts) {
|
216
|
+
return group(states[0], { ...opts, expandedStates: states });
|
217
|
+
}
|
218
|
+
function fill(parts) {
|
219
|
+
assertDocArray(parts);
|
220
|
+
return { type: DOC_TYPE_FILL, parts };
|
221
|
+
}
|
222
|
+
function ifBreak(breakContents, flatContents = "", opts = {}) {
|
223
|
+
assertDoc(breakContents);
|
224
|
+
if (flatContents !== "") {
|
225
|
+
assertDoc(flatContents);
|
226
|
+
}
|
227
|
+
return {
|
228
|
+
type: DOC_TYPE_IF_BREAK,
|
229
|
+
breakContents,
|
230
|
+
flatContents,
|
231
|
+
groupId: opts.groupId
|
232
|
+
};
|
233
|
+
}
|
234
|
+
function indentIfBreak(contents, opts) {
|
235
|
+
assertDoc(contents);
|
236
|
+
return {
|
237
|
+
type: DOC_TYPE_INDENT_IF_BREAK,
|
238
|
+
contents,
|
239
|
+
groupId: opts.groupId,
|
240
|
+
negate: opts.negate
|
241
|
+
};
|
242
|
+
}
|
243
|
+
function lineSuffix(contents) {
|
244
|
+
assertDoc(contents);
|
245
|
+
return { type: DOC_TYPE_LINE_SUFFIX, contents };
|
246
|
+
}
|
247
|
+
var lineSuffixBoundary = { type: DOC_TYPE_LINE_SUFFIX_BOUNDARY };
|
248
|
+
var breakParent = { type: DOC_TYPE_BREAK_PARENT };
|
249
|
+
var trim = { type: DOC_TYPE_TRIM };
|
250
|
+
var hardlineWithoutBreakParent = { type: DOC_TYPE_LINE, hard: true };
|
251
|
+
var literallineWithoutBreakParent = {
|
252
|
+
type: DOC_TYPE_LINE,
|
253
|
+
hard: true,
|
254
|
+
literal: true
|
255
|
+
};
|
256
|
+
var line = { type: DOC_TYPE_LINE };
|
257
|
+
var softline = { type: DOC_TYPE_LINE, soft: true };
|
258
|
+
var hardline = [hardlineWithoutBreakParent, breakParent];
|
259
|
+
var literalline = [literallineWithoutBreakParent, breakParent];
|
260
|
+
var cursor = { type: DOC_TYPE_CURSOR };
|
261
|
+
function join(separator, docs) {
|
262
|
+
assertDoc(separator);
|
263
|
+
assertDocArray(docs);
|
264
|
+
const parts = [];
|
265
|
+
for (let i = 0; i < docs.length; i++) {
|
266
|
+
if (i !== 0) {
|
267
|
+
parts.push(separator);
|
268
|
+
}
|
269
|
+
parts.push(docs[i]);
|
270
|
+
}
|
271
|
+
return parts;
|
272
|
+
}
|
273
|
+
function addAlignmentToDoc(doc, size, tabWidth) {
|
274
|
+
assertDoc(doc);
|
275
|
+
let aligned = doc;
|
276
|
+
if (size > 0) {
|
277
|
+
for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
|
278
|
+
aligned = indent(aligned);
|
279
|
+
}
|
280
|
+
aligned = align(size % tabWidth, aligned);
|
281
|
+
aligned = align(Number.NEGATIVE_INFINITY, aligned);
|
282
|
+
}
|
283
|
+
return aligned;
|
284
|
+
}
|
285
|
+
function label(label2, contents) {
|
286
|
+
assertDoc(contents);
|
287
|
+
return label2 ? { type: DOC_TYPE_LABEL, label: label2, contents } : contents;
|
288
|
+
}
|
289
|
+
|
290
|
+
// scripts/build/shims/at.js
|
291
|
+
var at = (isOptionalObject, object, index) => {
|
292
|
+
if (isOptionalObject && (object === void 0 || object === null)) {
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
if (Array.isArray(object) || typeof object === "string") {
|
296
|
+
return object[index < 0 ? object.length + index : index];
|
297
|
+
}
|
298
|
+
return object.at(index);
|
299
|
+
};
|
300
|
+
var at_default = at;
|
301
|
+
|
302
|
+
// scripts/build/shims/string-replace-all.js
|
303
|
+
var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
|
304
|
+
if (isOptionalObject && (original === void 0 || original === null)) {
|
305
|
+
return;
|
306
|
+
}
|
307
|
+
if (original.replaceAll) {
|
308
|
+
return original.replaceAll(pattern, replacement);
|
309
|
+
}
|
310
|
+
if (pattern.global) {
|
311
|
+
return original.replace(pattern, replacement);
|
312
|
+
}
|
313
|
+
return original.split(pattern).join(replacement);
|
314
|
+
};
|
315
|
+
var string_replace_all_default = stringReplaceAll;
|
316
|
+
|
317
|
+
// src/common/end-of-line.js
|
318
|
+
function convertEndOfLineToChars(value) {
|
319
|
+
switch (value) {
|
320
|
+
case "cr":
|
321
|
+
return "\r";
|
322
|
+
case "crlf":
|
323
|
+
return "\r\n";
|
324
|
+
default:
|
325
|
+
return "\n";
|
326
|
+
}
|
327
|
+
}
|
328
|
+
|
329
|
+
// node_modules/emoji-regex/index.mjs
|
330
|
+
var emoji_regex_default = () => {
|
331
|
+
return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC08\uDC26](?:\u200D\u2B1B)?|[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
|
332
|
+
};
|
333
|
+
|
334
|
+
// node_modules/eastasianwidth/eastasianwidth.js
|
335
|
+
var eastasianwidth_default = {
|
336
|
+
eastAsianWidth(character) {
|
337
|
+
var x = character.charCodeAt(0);
|
338
|
+
var y = character.length == 2 ? character.charCodeAt(1) : 0;
|
339
|
+
var codePoint = x;
|
340
|
+
if (55296 <= x && x <= 56319 && 56320 <= y && y <= 57343) {
|
341
|
+
x &= 1023;
|
342
|
+
y &= 1023;
|
343
|
+
codePoint = x << 10 | y;
|
344
|
+
codePoint += 65536;
|
345
|
+
}
|
346
|
+
if (12288 == codePoint || 65281 <= codePoint && codePoint <= 65376 || 65504 <= codePoint && codePoint <= 65510) {
|
347
|
+
return "F";
|
348
|
+
}
|
349
|
+
if (4352 <= codePoint && codePoint <= 4447 || 4515 <= codePoint && codePoint <= 4519 || 4602 <= codePoint && codePoint <= 4607 || 9001 <= codePoint && codePoint <= 9002 || 11904 <= codePoint && codePoint <= 11929 || 11931 <= codePoint && codePoint <= 12019 || 12032 <= codePoint && codePoint <= 12245 || 12272 <= codePoint && codePoint <= 12283 || 12289 <= codePoint && codePoint <= 12350 || 12353 <= codePoint && codePoint <= 12438 || 12441 <= codePoint && codePoint <= 12543 || 12549 <= codePoint && codePoint <= 12589 || 12593 <= codePoint && codePoint <= 12686 || 12688 <= codePoint && codePoint <= 12730 || 12736 <= codePoint && codePoint <= 12771 || 12784 <= codePoint && codePoint <= 12830 || 12832 <= codePoint && codePoint <= 12871 || 12880 <= codePoint && codePoint <= 13054 || 13056 <= codePoint && codePoint <= 19903 || 19968 <= codePoint && codePoint <= 42124 || 42128 <= codePoint && codePoint <= 42182 || 43360 <= codePoint && codePoint <= 43388 || 44032 <= codePoint && codePoint <= 55203 || 55216 <= codePoint && codePoint <= 55238 || 55243 <= codePoint && codePoint <= 55291 || 63744 <= codePoint && codePoint <= 64255 || 65040 <= codePoint && codePoint <= 65049 || 65072 <= codePoint && codePoint <= 65106 || 65108 <= codePoint && codePoint <= 65126 || 65128 <= codePoint && codePoint <= 65131 || 110592 <= codePoint && codePoint <= 110593 || 127488 <= codePoint && codePoint <= 127490 || 127504 <= codePoint && codePoint <= 127546 || 127552 <= codePoint && codePoint <= 127560 || 127568 <= codePoint && codePoint <= 127569 || 131072 <= codePoint && codePoint <= 194367 || 177984 <= codePoint && codePoint <= 196605 || 196608 <= codePoint && codePoint <= 262141) {
|
350
|
+
return "W";
|
351
|
+
}
|
352
|
+
return "N";
|
353
|
+
}
|
354
|
+
};
|
355
|
+
|
356
|
+
// src/utils/get-string-width.js
|
357
|
+
var notAsciiRegex = /[^\x20-\x7F]/;
|
358
|
+
function getStringWidth(text) {
|
359
|
+
if (!text) {
|
360
|
+
return 0;
|
361
|
+
}
|
362
|
+
if (!notAsciiRegex.test(text)) {
|
363
|
+
return text.length;
|
364
|
+
}
|
365
|
+
text = text.replace(emoji_regex_default(), " ");
|
366
|
+
let width = 0;
|
367
|
+
for (const character of text) {
|
368
|
+
const codePoint = character.codePointAt(0);
|
369
|
+
if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) {
|
370
|
+
continue;
|
371
|
+
}
|
372
|
+
if (codePoint >= 768 && codePoint <= 879) {
|
373
|
+
continue;
|
374
|
+
}
|
375
|
+
const code = eastasianwidth_default.eastAsianWidth(character);
|
376
|
+
width += code === "F" || code === "W" ? 2 : 1;
|
377
|
+
}
|
378
|
+
return width;
|
379
|
+
}
|
380
|
+
var get_string_width_default = getStringWidth;
|
381
|
+
|
382
|
+
// src/document/utils.js
|
383
|
+
var getDocParts = (doc) => {
|
384
|
+
if (Array.isArray(doc)) {
|
385
|
+
return doc;
|
386
|
+
}
|
387
|
+
if (doc.type !== DOC_TYPE_FILL) {
|
388
|
+
throw new Error(`Expect doc to be 'array' or '${DOC_TYPE_FILL}'.`);
|
389
|
+
}
|
390
|
+
return doc.parts;
|
391
|
+
};
|
392
|
+
function mapDoc(doc, cb) {
|
393
|
+
if (typeof doc === "string") {
|
394
|
+
return cb(doc);
|
395
|
+
}
|
396
|
+
const mapped = /* @__PURE__ */ new Map();
|
397
|
+
return rec(doc);
|
398
|
+
function rec(doc2) {
|
399
|
+
if (mapped.has(doc2)) {
|
400
|
+
return mapped.get(doc2);
|
401
|
+
}
|
402
|
+
const result = process2(doc2);
|
403
|
+
mapped.set(doc2, result);
|
404
|
+
return result;
|
405
|
+
}
|
406
|
+
function process2(doc2) {
|
407
|
+
switch (get_doc_type_default(doc2)) {
|
408
|
+
case DOC_TYPE_ARRAY:
|
409
|
+
return cb(doc2.map(rec));
|
410
|
+
case DOC_TYPE_FILL:
|
411
|
+
return cb({
|
412
|
+
...doc2,
|
413
|
+
parts: doc2.parts.map(rec)
|
414
|
+
});
|
415
|
+
case DOC_TYPE_IF_BREAK:
|
416
|
+
return cb({
|
417
|
+
...doc2,
|
418
|
+
breakContents: rec(doc2.breakContents),
|
419
|
+
flatContents: rec(doc2.flatContents)
|
420
|
+
});
|
421
|
+
case DOC_TYPE_GROUP: {
|
422
|
+
let {
|
423
|
+
expandedStates,
|
424
|
+
contents
|
425
|
+
} = doc2;
|
426
|
+
if (expandedStates) {
|
427
|
+
expandedStates = expandedStates.map(rec);
|
428
|
+
contents = expandedStates[0];
|
429
|
+
} else {
|
430
|
+
contents = rec(contents);
|
431
|
+
}
|
432
|
+
return cb({
|
433
|
+
...doc2,
|
434
|
+
contents,
|
435
|
+
expandedStates
|
436
|
+
});
|
437
|
+
}
|
438
|
+
case DOC_TYPE_ALIGN:
|
439
|
+
case DOC_TYPE_INDENT:
|
440
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
441
|
+
case DOC_TYPE_LABEL:
|
442
|
+
case DOC_TYPE_LINE_SUFFIX:
|
443
|
+
return cb({
|
444
|
+
...doc2,
|
445
|
+
contents: rec(doc2.contents)
|
446
|
+
});
|
447
|
+
case DOC_TYPE_STRING:
|
448
|
+
case DOC_TYPE_CURSOR:
|
449
|
+
case DOC_TYPE_TRIM:
|
450
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
451
|
+
case DOC_TYPE_LINE:
|
452
|
+
case DOC_TYPE_BREAK_PARENT:
|
453
|
+
return cb(doc2);
|
454
|
+
default:
|
455
|
+
throw new invalid_doc_error_default(doc2);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
}
|
459
|
+
function findInDoc(doc, fn, defaultValue) {
|
460
|
+
let result = defaultValue;
|
461
|
+
let shouldSkipFurtherProcessing = false;
|
462
|
+
function findInDocOnEnterFn(doc2) {
|
463
|
+
if (shouldSkipFurtherProcessing) {
|
464
|
+
return false;
|
465
|
+
}
|
466
|
+
const maybeResult = fn(doc2);
|
467
|
+
if (maybeResult !== void 0) {
|
468
|
+
shouldSkipFurtherProcessing = true;
|
469
|
+
result = maybeResult;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
traverse_doc_default(doc, findInDocOnEnterFn);
|
473
|
+
return result;
|
474
|
+
}
|
475
|
+
function willBreakFn(doc) {
|
476
|
+
if (doc.type === DOC_TYPE_GROUP && doc.break) {
|
477
|
+
return true;
|
478
|
+
}
|
479
|
+
if (doc.type === DOC_TYPE_LINE && doc.hard) {
|
480
|
+
return true;
|
481
|
+
}
|
482
|
+
if (doc.type === DOC_TYPE_BREAK_PARENT) {
|
483
|
+
return true;
|
484
|
+
}
|
485
|
+
}
|
486
|
+
function willBreak(doc) {
|
487
|
+
return findInDoc(doc, willBreakFn, false);
|
488
|
+
}
|
489
|
+
function breakParentGroup(groupStack) {
|
490
|
+
if (groupStack.length > 0) {
|
491
|
+
const parentGroup = at_default(
|
492
|
+
/* isOptionalObject*/
|
493
|
+
false,
|
494
|
+
groupStack,
|
495
|
+
-1
|
496
|
+
);
|
497
|
+
if (!parentGroup.expandedStates && !parentGroup.break) {
|
498
|
+
parentGroup.break = "propagated";
|
499
|
+
}
|
500
|
+
}
|
501
|
+
return null;
|
502
|
+
}
|
503
|
+
function propagateBreaks(doc) {
|
504
|
+
const alreadyVisitedSet = /* @__PURE__ */ new Set();
|
505
|
+
const groupStack = [];
|
506
|
+
function propagateBreaksOnEnterFn(doc2) {
|
507
|
+
if (doc2.type === DOC_TYPE_BREAK_PARENT) {
|
508
|
+
breakParentGroup(groupStack);
|
509
|
+
}
|
510
|
+
if (doc2.type === DOC_TYPE_GROUP) {
|
511
|
+
groupStack.push(doc2);
|
512
|
+
if (alreadyVisitedSet.has(doc2)) {
|
513
|
+
return false;
|
514
|
+
}
|
515
|
+
alreadyVisitedSet.add(doc2);
|
516
|
+
}
|
517
|
+
}
|
518
|
+
function propagateBreaksOnExitFn(doc2) {
|
519
|
+
if (doc2.type === DOC_TYPE_GROUP) {
|
520
|
+
const group2 = groupStack.pop();
|
521
|
+
if (group2.break) {
|
522
|
+
breakParentGroup(groupStack);
|
523
|
+
}
|
524
|
+
}
|
525
|
+
}
|
526
|
+
traverse_doc_default(
|
527
|
+
doc,
|
528
|
+
propagateBreaksOnEnterFn,
|
529
|
+
propagateBreaksOnExitFn,
|
530
|
+
/* shouldTraverseConditionalGroups */
|
531
|
+
true
|
532
|
+
);
|
533
|
+
}
|
534
|
+
function removeLinesFn(doc) {
|
535
|
+
if (doc.type === DOC_TYPE_LINE && !doc.hard) {
|
536
|
+
return doc.soft ? "" : " ";
|
537
|
+
}
|
538
|
+
if (doc.type === DOC_TYPE_IF_BREAK) {
|
539
|
+
return doc.flatContents;
|
540
|
+
}
|
541
|
+
return doc;
|
542
|
+
}
|
543
|
+
function removeLines(doc) {
|
544
|
+
return mapDoc(doc, removeLinesFn);
|
545
|
+
}
|
546
|
+
function stripTrailingHardlineFromParts(parts) {
|
547
|
+
parts = [...parts];
|
548
|
+
while (parts.length >= 2 && at_default(
|
549
|
+
/* isOptionalObject*/
|
550
|
+
false,
|
551
|
+
parts,
|
552
|
+
-2
|
553
|
+
).type === DOC_TYPE_LINE && at_default(
|
554
|
+
/* isOptionalObject*/
|
555
|
+
false,
|
556
|
+
parts,
|
557
|
+
-1
|
558
|
+
).type === DOC_TYPE_BREAK_PARENT) {
|
559
|
+
parts.length -= 2;
|
560
|
+
}
|
561
|
+
if (parts.length > 0) {
|
562
|
+
const lastPart = stripTrailingHardlineFromDoc(at_default(
|
563
|
+
/* isOptionalObject*/
|
564
|
+
false,
|
565
|
+
parts,
|
566
|
+
-1
|
567
|
+
));
|
568
|
+
parts[parts.length - 1] = lastPart;
|
569
|
+
}
|
570
|
+
return parts;
|
571
|
+
}
|
572
|
+
function stripTrailingHardlineFromDoc(doc) {
|
573
|
+
switch (get_doc_type_default(doc)) {
|
574
|
+
case DOC_TYPE_ALIGN:
|
575
|
+
case DOC_TYPE_INDENT:
|
576
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
577
|
+
case DOC_TYPE_GROUP:
|
578
|
+
case DOC_TYPE_LINE_SUFFIX:
|
579
|
+
case DOC_TYPE_LABEL: {
|
580
|
+
const contents = stripTrailingHardlineFromDoc(doc.contents);
|
581
|
+
return {
|
582
|
+
...doc,
|
583
|
+
contents
|
584
|
+
};
|
585
|
+
}
|
586
|
+
case DOC_TYPE_IF_BREAK:
|
587
|
+
return {
|
588
|
+
...doc,
|
589
|
+
breakContents: stripTrailingHardlineFromDoc(doc.breakContents),
|
590
|
+
flatContents: stripTrailingHardlineFromDoc(doc.flatContents)
|
591
|
+
};
|
592
|
+
case DOC_TYPE_FILL:
|
593
|
+
return {
|
594
|
+
...doc,
|
595
|
+
parts: stripTrailingHardlineFromParts(doc.parts)
|
596
|
+
};
|
597
|
+
case DOC_TYPE_ARRAY:
|
598
|
+
return stripTrailingHardlineFromParts(doc);
|
599
|
+
case DOC_TYPE_STRING:
|
600
|
+
return doc.replace(/[\n\r]*$/, "");
|
601
|
+
case DOC_TYPE_CURSOR:
|
602
|
+
case DOC_TYPE_TRIM:
|
603
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
604
|
+
case DOC_TYPE_LINE:
|
605
|
+
case DOC_TYPE_BREAK_PARENT:
|
606
|
+
break;
|
607
|
+
default:
|
608
|
+
throw new invalid_doc_error_default(doc);
|
609
|
+
}
|
610
|
+
return doc;
|
611
|
+
}
|
612
|
+
function stripTrailingHardline(doc) {
|
613
|
+
return stripTrailingHardlineFromDoc(cleanDoc(doc));
|
614
|
+
}
|
615
|
+
function cleanDocFn(doc) {
|
616
|
+
switch (get_doc_type_default(doc)) {
|
617
|
+
case DOC_TYPE_FILL:
|
618
|
+
if (doc.parts.every((part) => part === "")) {
|
619
|
+
return "";
|
620
|
+
}
|
621
|
+
break;
|
622
|
+
case DOC_TYPE_GROUP:
|
623
|
+
if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
|
624
|
+
return "";
|
625
|
+
}
|
626
|
+
if (doc.contents.type === DOC_TYPE_GROUP && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
|
627
|
+
return doc.contents;
|
628
|
+
}
|
629
|
+
break;
|
630
|
+
case DOC_TYPE_ALIGN:
|
631
|
+
case DOC_TYPE_INDENT:
|
632
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
633
|
+
case DOC_TYPE_LINE_SUFFIX:
|
634
|
+
if (!doc.contents) {
|
635
|
+
return "";
|
636
|
+
}
|
637
|
+
break;
|
638
|
+
case DOC_TYPE_IF_BREAK:
|
639
|
+
if (!doc.flatContents && !doc.breakContents) {
|
640
|
+
return "";
|
641
|
+
}
|
642
|
+
break;
|
643
|
+
case DOC_TYPE_ARRAY: {
|
644
|
+
const parts = [];
|
645
|
+
for (const part of doc) {
|
646
|
+
if (!part) {
|
647
|
+
continue;
|
648
|
+
}
|
649
|
+
const [currentPart, ...restParts] = Array.isArray(part) ? part : [part];
|
650
|
+
if (typeof currentPart === "string" && typeof at_default(
|
651
|
+
/* isOptionalObject*/
|
652
|
+
false,
|
653
|
+
parts,
|
654
|
+
-1
|
655
|
+
) === "string") {
|
656
|
+
parts[parts.length - 1] += currentPart;
|
657
|
+
} else {
|
658
|
+
parts.push(currentPart);
|
659
|
+
}
|
660
|
+
parts.push(...restParts);
|
661
|
+
}
|
662
|
+
if (parts.length === 0) {
|
663
|
+
return "";
|
664
|
+
}
|
665
|
+
if (parts.length === 1) {
|
666
|
+
return parts[0];
|
667
|
+
}
|
668
|
+
return parts;
|
669
|
+
}
|
670
|
+
case DOC_TYPE_STRING:
|
671
|
+
case DOC_TYPE_CURSOR:
|
672
|
+
case DOC_TYPE_TRIM:
|
673
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
674
|
+
case DOC_TYPE_LINE:
|
675
|
+
case DOC_TYPE_LABEL:
|
676
|
+
case DOC_TYPE_BREAK_PARENT:
|
677
|
+
break;
|
678
|
+
default:
|
679
|
+
throw new invalid_doc_error_default(doc);
|
680
|
+
}
|
681
|
+
return doc;
|
682
|
+
}
|
683
|
+
function cleanDoc(doc) {
|
684
|
+
return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
|
685
|
+
}
|
686
|
+
function replaceEndOfLine(doc, replacement = literalline) {
|
687
|
+
return mapDoc(doc, (currentDoc) => typeof currentDoc === "string" ? join(replacement, currentDoc.split("\n")) : currentDoc);
|
688
|
+
}
|
689
|
+
function canBreakFn(doc) {
|
690
|
+
if (doc.type === DOC_TYPE_LINE) {
|
691
|
+
return true;
|
692
|
+
}
|
693
|
+
}
|
694
|
+
function canBreak(doc) {
|
695
|
+
return findInDoc(doc, canBreakFn, false);
|
696
|
+
}
|
697
|
+
|
698
|
+
// src/document/printer.js
|
699
|
+
var MODE_BREAK = Symbol("MODE_BREAK");
|
700
|
+
var MODE_FLAT = Symbol("MODE_FLAT");
|
701
|
+
var CURSOR_PLACEHOLDER = Symbol("cursor");
|
702
|
+
function rootIndent() {
|
703
|
+
return {
|
704
|
+
value: "",
|
705
|
+
length: 0,
|
706
|
+
queue: []
|
707
|
+
};
|
708
|
+
}
|
709
|
+
function makeIndent(ind, options) {
|
710
|
+
return generateInd(ind, {
|
711
|
+
type: "indent"
|
712
|
+
}, options);
|
713
|
+
}
|
714
|
+
function makeAlign(indent2, widthOrDoc, options) {
|
715
|
+
if (widthOrDoc === Number.NEGATIVE_INFINITY) {
|
716
|
+
return indent2.root || rootIndent();
|
717
|
+
}
|
718
|
+
if (widthOrDoc < 0) {
|
719
|
+
return generateInd(indent2, {
|
720
|
+
type: "dedent"
|
721
|
+
}, options);
|
722
|
+
}
|
723
|
+
if (!widthOrDoc) {
|
724
|
+
return indent2;
|
725
|
+
}
|
726
|
+
if (widthOrDoc.type === "root") {
|
727
|
+
return {
|
728
|
+
...indent2,
|
729
|
+
root: indent2
|
730
|
+
};
|
731
|
+
}
|
732
|
+
const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
|
733
|
+
return generateInd(indent2, {
|
734
|
+
type: alignType,
|
735
|
+
n: widthOrDoc
|
736
|
+
}, options);
|
737
|
+
}
|
738
|
+
function generateInd(ind, newPart, options) {
|
739
|
+
const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
|
740
|
+
let value = "";
|
741
|
+
let length = 0;
|
742
|
+
let lastTabs = 0;
|
743
|
+
let lastSpaces = 0;
|
744
|
+
for (const part of queue) {
|
745
|
+
switch (part.type) {
|
746
|
+
case "indent":
|
747
|
+
flush();
|
748
|
+
if (options.useTabs) {
|
749
|
+
addTabs(1);
|
750
|
+
} else {
|
751
|
+
addSpaces(options.tabWidth);
|
752
|
+
}
|
753
|
+
break;
|
754
|
+
case "stringAlign":
|
755
|
+
flush();
|
756
|
+
value += part.n;
|
757
|
+
length += part.n.length;
|
758
|
+
break;
|
759
|
+
case "numberAlign":
|
760
|
+
lastTabs += 1;
|
761
|
+
lastSpaces += part.n;
|
762
|
+
break;
|
763
|
+
default:
|
764
|
+
throw new Error(`Unexpected type '${part.type}'`);
|
765
|
+
}
|
766
|
+
}
|
767
|
+
flushSpaces();
|
768
|
+
return {
|
769
|
+
...ind,
|
770
|
+
value,
|
771
|
+
length,
|
772
|
+
queue
|
773
|
+
};
|
774
|
+
function addTabs(count) {
|
775
|
+
value += " ".repeat(count);
|
776
|
+
length += options.tabWidth * count;
|
777
|
+
}
|
778
|
+
function addSpaces(count) {
|
779
|
+
value += " ".repeat(count);
|
780
|
+
length += count;
|
781
|
+
}
|
782
|
+
function flush() {
|
783
|
+
if (options.useTabs) {
|
784
|
+
flushTabs();
|
785
|
+
} else {
|
786
|
+
flushSpaces();
|
787
|
+
}
|
788
|
+
}
|
789
|
+
function flushTabs() {
|
790
|
+
if (lastTabs > 0) {
|
791
|
+
addTabs(lastTabs);
|
792
|
+
}
|
793
|
+
resetLast();
|
794
|
+
}
|
795
|
+
function flushSpaces() {
|
796
|
+
if (lastSpaces > 0) {
|
797
|
+
addSpaces(lastSpaces);
|
798
|
+
}
|
799
|
+
resetLast();
|
800
|
+
}
|
801
|
+
function resetLast() {
|
802
|
+
lastTabs = 0;
|
803
|
+
lastSpaces = 0;
|
804
|
+
}
|
805
|
+
}
|
806
|
+
function trim2(out) {
|
807
|
+
let trimCount = 0;
|
808
|
+
let cursorCount = 0;
|
809
|
+
let outIndex = out.length;
|
810
|
+
outer:
|
811
|
+
while (outIndex--) {
|
812
|
+
const last = out[outIndex];
|
813
|
+
if (last === CURSOR_PLACEHOLDER) {
|
814
|
+
cursorCount++;
|
815
|
+
continue;
|
816
|
+
}
|
817
|
+
if (false) {
|
818
|
+
throw new Error(`Unexpected value in trim: '${typeof last}'`);
|
819
|
+
}
|
820
|
+
for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
|
821
|
+
const char = last[charIndex];
|
822
|
+
if (char === " " || char === " ") {
|
823
|
+
trimCount++;
|
824
|
+
} else {
|
825
|
+
out[outIndex] = last.slice(0, charIndex + 1);
|
826
|
+
break outer;
|
827
|
+
}
|
828
|
+
}
|
829
|
+
}
|
830
|
+
if (trimCount > 0 || cursorCount > 0) {
|
831
|
+
out.length = outIndex + 1;
|
832
|
+
while (cursorCount-- > 0) {
|
833
|
+
out.push(CURSOR_PLACEHOLDER);
|
834
|
+
}
|
835
|
+
}
|
836
|
+
return trimCount;
|
837
|
+
}
|
838
|
+
function fits(next, restCommands, width, hasLineSuffix, groupModeMap, mustBeFlat) {
|
839
|
+
if (width === Number.POSITIVE_INFINITY) {
|
840
|
+
return true;
|
841
|
+
}
|
842
|
+
let restIdx = restCommands.length;
|
843
|
+
const cmds = [next];
|
844
|
+
const out = [];
|
845
|
+
while (width >= 0) {
|
846
|
+
if (cmds.length === 0) {
|
847
|
+
if (restIdx === 0) {
|
848
|
+
return true;
|
849
|
+
}
|
850
|
+
cmds.push(restCommands[--restIdx]);
|
851
|
+
continue;
|
852
|
+
}
|
853
|
+
const {
|
854
|
+
mode,
|
855
|
+
doc
|
856
|
+
} = cmds.pop();
|
857
|
+
switch (get_doc_type_default(doc)) {
|
858
|
+
case DOC_TYPE_STRING:
|
859
|
+
out.push(doc);
|
860
|
+
width -= get_string_width_default(doc);
|
861
|
+
break;
|
862
|
+
case DOC_TYPE_ARRAY:
|
863
|
+
case DOC_TYPE_FILL: {
|
864
|
+
const parts = getDocParts(doc);
|
865
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
866
|
+
cmds.push({
|
867
|
+
mode,
|
868
|
+
doc: parts[i]
|
869
|
+
});
|
870
|
+
}
|
871
|
+
break;
|
872
|
+
}
|
873
|
+
case DOC_TYPE_INDENT:
|
874
|
+
case DOC_TYPE_ALIGN:
|
875
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
876
|
+
case DOC_TYPE_LABEL:
|
877
|
+
cmds.push({
|
878
|
+
mode,
|
879
|
+
doc: doc.contents
|
880
|
+
});
|
881
|
+
break;
|
882
|
+
case DOC_TYPE_TRIM:
|
883
|
+
width += trim2(out);
|
884
|
+
break;
|
885
|
+
case DOC_TYPE_GROUP: {
|
886
|
+
if (mustBeFlat && doc.break) {
|
887
|
+
return false;
|
888
|
+
}
|
889
|
+
const groupMode = doc.break ? MODE_BREAK : mode;
|
890
|
+
const contents = doc.expandedStates && groupMode === MODE_BREAK ? at_default(
|
891
|
+
/* isOptionalObject*/
|
892
|
+
false,
|
893
|
+
doc.expandedStates,
|
894
|
+
-1
|
895
|
+
) : doc.contents;
|
896
|
+
cmds.push({
|
897
|
+
mode: groupMode,
|
898
|
+
doc: contents
|
899
|
+
});
|
900
|
+
break;
|
901
|
+
}
|
902
|
+
case DOC_TYPE_IF_BREAK: {
|
903
|
+
const groupMode = doc.groupId ? groupModeMap[doc.groupId] || MODE_FLAT : mode;
|
904
|
+
const contents = groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
|
905
|
+
if (contents) {
|
906
|
+
cmds.push({
|
907
|
+
mode,
|
908
|
+
doc: contents
|
909
|
+
});
|
910
|
+
}
|
911
|
+
break;
|
912
|
+
}
|
913
|
+
case DOC_TYPE_LINE:
|
914
|
+
if (mode === MODE_BREAK || doc.hard) {
|
915
|
+
return true;
|
916
|
+
}
|
917
|
+
if (!doc.soft) {
|
918
|
+
out.push(" ");
|
919
|
+
width--;
|
920
|
+
}
|
921
|
+
break;
|
922
|
+
case DOC_TYPE_LINE_SUFFIX:
|
923
|
+
hasLineSuffix = true;
|
924
|
+
break;
|
925
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
926
|
+
if (hasLineSuffix) {
|
927
|
+
return false;
|
928
|
+
}
|
929
|
+
break;
|
930
|
+
}
|
931
|
+
}
|
932
|
+
return false;
|
933
|
+
}
|
934
|
+
function printDocToString(doc, options) {
|
935
|
+
const groupModeMap = {};
|
936
|
+
const width = options.printWidth;
|
937
|
+
const newLine = convertEndOfLineToChars(options.endOfLine);
|
938
|
+
let pos = 0;
|
939
|
+
const cmds = [{
|
940
|
+
ind: rootIndent(),
|
941
|
+
mode: MODE_BREAK,
|
942
|
+
doc
|
943
|
+
}];
|
944
|
+
const out = [];
|
945
|
+
let shouldRemeasure = false;
|
946
|
+
const lineSuffix2 = [];
|
947
|
+
let printedCursorCount = 0;
|
948
|
+
propagateBreaks(doc);
|
949
|
+
while (cmds.length > 0) {
|
950
|
+
const {
|
951
|
+
ind,
|
952
|
+
mode,
|
953
|
+
doc: doc2
|
954
|
+
} = cmds.pop();
|
955
|
+
switch (get_doc_type_default(doc2)) {
|
956
|
+
case DOC_TYPE_STRING: {
|
957
|
+
const formatted = newLine !== "\n" ? string_replace_all_default(
|
958
|
+
/* isOptionalObject*/
|
959
|
+
false,
|
960
|
+
doc2,
|
961
|
+
"\n",
|
962
|
+
newLine
|
963
|
+
) : doc2;
|
964
|
+
out.push(formatted);
|
965
|
+
if (cmds.length > 0) {
|
966
|
+
pos += get_string_width_default(formatted);
|
967
|
+
}
|
968
|
+
break;
|
969
|
+
}
|
970
|
+
case DOC_TYPE_ARRAY:
|
971
|
+
for (let i = doc2.length - 1; i >= 0; i--) {
|
972
|
+
cmds.push({
|
973
|
+
ind,
|
974
|
+
mode,
|
975
|
+
doc: doc2[i]
|
976
|
+
});
|
977
|
+
}
|
978
|
+
break;
|
979
|
+
case DOC_TYPE_CURSOR:
|
980
|
+
if (printedCursorCount >= 2) {
|
981
|
+
throw new Error("There are too many 'cursor' in doc.");
|
982
|
+
}
|
983
|
+
out.push(CURSOR_PLACEHOLDER);
|
984
|
+
printedCursorCount++;
|
985
|
+
break;
|
986
|
+
case DOC_TYPE_INDENT:
|
987
|
+
cmds.push({
|
988
|
+
ind: makeIndent(ind, options),
|
989
|
+
mode,
|
990
|
+
doc: doc2.contents
|
991
|
+
});
|
992
|
+
break;
|
993
|
+
case DOC_TYPE_ALIGN:
|
994
|
+
cmds.push({
|
995
|
+
ind: makeAlign(ind, doc2.n, options),
|
996
|
+
mode,
|
997
|
+
doc: doc2.contents
|
998
|
+
});
|
999
|
+
break;
|
1000
|
+
case DOC_TYPE_TRIM:
|
1001
|
+
pos -= trim2(out);
|
1002
|
+
break;
|
1003
|
+
case DOC_TYPE_GROUP:
|
1004
|
+
switch (mode) {
|
1005
|
+
case MODE_FLAT:
|
1006
|
+
if (!shouldRemeasure) {
|
1007
|
+
cmds.push({
|
1008
|
+
ind,
|
1009
|
+
mode: doc2.break ? MODE_BREAK : MODE_FLAT,
|
1010
|
+
doc: doc2.contents
|
1011
|
+
});
|
1012
|
+
break;
|
1013
|
+
}
|
1014
|
+
case MODE_BREAK: {
|
1015
|
+
shouldRemeasure = false;
|
1016
|
+
const next = {
|
1017
|
+
ind,
|
1018
|
+
mode: MODE_FLAT,
|
1019
|
+
doc: doc2.contents
|
1020
|
+
};
|
1021
|
+
const rem = width - pos;
|
1022
|
+
const hasLineSuffix = lineSuffix2.length > 0;
|
1023
|
+
if (!doc2.break && fits(next, cmds, rem, hasLineSuffix, groupModeMap)) {
|
1024
|
+
cmds.push(next);
|
1025
|
+
} else {
|
1026
|
+
if (doc2.expandedStates) {
|
1027
|
+
const mostExpanded = at_default(
|
1028
|
+
/* isOptionalObject*/
|
1029
|
+
false,
|
1030
|
+
doc2.expandedStates,
|
1031
|
+
-1
|
1032
|
+
);
|
1033
|
+
if (doc2.break) {
|
1034
|
+
cmds.push({
|
1035
|
+
ind,
|
1036
|
+
mode: MODE_BREAK,
|
1037
|
+
doc: mostExpanded
|
1038
|
+
});
|
1039
|
+
break;
|
1040
|
+
} else {
|
1041
|
+
for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
|
1042
|
+
if (i >= doc2.expandedStates.length) {
|
1043
|
+
cmds.push({
|
1044
|
+
ind,
|
1045
|
+
mode: MODE_BREAK,
|
1046
|
+
doc: mostExpanded
|
1047
|
+
});
|
1048
|
+
break;
|
1049
|
+
} else {
|
1050
|
+
const state = doc2.expandedStates[i];
|
1051
|
+
const cmd = {
|
1052
|
+
ind,
|
1053
|
+
mode: MODE_FLAT,
|
1054
|
+
doc: state
|
1055
|
+
};
|
1056
|
+
if (fits(cmd, cmds, rem, hasLineSuffix, groupModeMap)) {
|
1057
|
+
cmds.push(cmd);
|
1058
|
+
break;
|
1059
|
+
}
|
1060
|
+
}
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
} else {
|
1064
|
+
cmds.push({
|
1065
|
+
ind,
|
1066
|
+
mode: MODE_BREAK,
|
1067
|
+
doc: doc2.contents
|
1068
|
+
});
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
break;
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
if (doc2.id) {
|
1075
|
+
groupModeMap[doc2.id] = at_default(
|
1076
|
+
/* isOptionalObject*/
|
1077
|
+
false,
|
1078
|
+
cmds,
|
1079
|
+
-1
|
1080
|
+
).mode;
|
1081
|
+
}
|
1082
|
+
break;
|
1083
|
+
case DOC_TYPE_FILL: {
|
1084
|
+
const rem = width - pos;
|
1085
|
+
const {
|
1086
|
+
parts
|
1087
|
+
} = doc2;
|
1088
|
+
if (parts.length === 0) {
|
1089
|
+
break;
|
1090
|
+
}
|
1091
|
+
const [content, whitespace] = parts;
|
1092
|
+
const contentFlatCmd = {
|
1093
|
+
ind,
|
1094
|
+
mode: MODE_FLAT,
|
1095
|
+
doc: content
|
1096
|
+
};
|
1097
|
+
const contentBreakCmd = {
|
1098
|
+
ind,
|
1099
|
+
mode: MODE_BREAK,
|
1100
|
+
doc: content
|
1101
|
+
};
|
1102
|
+
const contentFits = fits(contentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
|
1103
|
+
if (parts.length === 1) {
|
1104
|
+
if (contentFits) {
|
1105
|
+
cmds.push(contentFlatCmd);
|
1106
|
+
} else {
|
1107
|
+
cmds.push(contentBreakCmd);
|
1108
|
+
}
|
1109
|
+
break;
|
1110
|
+
}
|
1111
|
+
const whitespaceFlatCmd = {
|
1112
|
+
ind,
|
1113
|
+
mode: MODE_FLAT,
|
1114
|
+
doc: whitespace
|
1115
|
+
};
|
1116
|
+
const whitespaceBreakCmd = {
|
1117
|
+
ind,
|
1118
|
+
mode: MODE_BREAK,
|
1119
|
+
doc: whitespace
|
1120
|
+
};
|
1121
|
+
if (parts.length === 2) {
|
1122
|
+
if (contentFits) {
|
1123
|
+
cmds.push(whitespaceFlatCmd, contentFlatCmd);
|
1124
|
+
} else {
|
1125
|
+
cmds.push(whitespaceBreakCmd, contentBreakCmd);
|
1126
|
+
}
|
1127
|
+
break;
|
1128
|
+
}
|
1129
|
+
parts.splice(0, 2);
|
1130
|
+
const remainingCmd = {
|
1131
|
+
ind,
|
1132
|
+
mode,
|
1133
|
+
doc: fill(parts)
|
1134
|
+
};
|
1135
|
+
const secondContent = parts[0];
|
1136
|
+
const firstAndSecondContentFlatCmd = {
|
1137
|
+
ind,
|
1138
|
+
mode: MODE_FLAT,
|
1139
|
+
doc: [content, whitespace, secondContent]
|
1140
|
+
};
|
1141
|
+
const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, lineSuffix2.length > 0, groupModeMap, true);
|
1142
|
+
if (firstAndSecondContentFits) {
|
1143
|
+
cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
|
1144
|
+
} else if (contentFits) {
|
1145
|
+
cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
|
1146
|
+
} else {
|
1147
|
+
cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
|
1148
|
+
}
|
1149
|
+
break;
|
1150
|
+
}
|
1151
|
+
case DOC_TYPE_IF_BREAK:
|
1152
|
+
case DOC_TYPE_INDENT_IF_BREAK: {
|
1153
|
+
const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
|
1154
|
+
if (groupMode === MODE_BREAK) {
|
1155
|
+
const breakContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.breakContents : doc2.negate ? doc2.contents : indent(doc2.contents);
|
1156
|
+
if (breakContents) {
|
1157
|
+
cmds.push({
|
1158
|
+
ind,
|
1159
|
+
mode,
|
1160
|
+
doc: breakContents
|
1161
|
+
});
|
1162
|
+
}
|
1163
|
+
}
|
1164
|
+
if (groupMode === MODE_FLAT) {
|
1165
|
+
const flatContents = doc2.type === DOC_TYPE_IF_BREAK ? doc2.flatContents : doc2.negate ? indent(doc2.contents) : doc2.contents;
|
1166
|
+
if (flatContents) {
|
1167
|
+
cmds.push({
|
1168
|
+
ind,
|
1169
|
+
mode,
|
1170
|
+
doc: flatContents
|
1171
|
+
});
|
1172
|
+
}
|
1173
|
+
}
|
1174
|
+
break;
|
1175
|
+
}
|
1176
|
+
case DOC_TYPE_LINE_SUFFIX:
|
1177
|
+
lineSuffix2.push({
|
1178
|
+
ind,
|
1179
|
+
mode,
|
1180
|
+
doc: doc2.contents
|
1181
|
+
});
|
1182
|
+
break;
|
1183
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
1184
|
+
if (lineSuffix2.length > 0) {
|
1185
|
+
cmds.push({
|
1186
|
+
ind,
|
1187
|
+
mode,
|
1188
|
+
doc: hardlineWithoutBreakParent
|
1189
|
+
});
|
1190
|
+
}
|
1191
|
+
break;
|
1192
|
+
case DOC_TYPE_LINE:
|
1193
|
+
switch (mode) {
|
1194
|
+
case MODE_FLAT:
|
1195
|
+
if (!doc2.hard) {
|
1196
|
+
if (!doc2.soft) {
|
1197
|
+
out.push(" ");
|
1198
|
+
pos += 1;
|
1199
|
+
}
|
1200
|
+
break;
|
1201
|
+
} else {
|
1202
|
+
shouldRemeasure = true;
|
1203
|
+
}
|
1204
|
+
case MODE_BREAK:
|
1205
|
+
if (lineSuffix2.length > 0) {
|
1206
|
+
cmds.push({
|
1207
|
+
ind,
|
1208
|
+
mode,
|
1209
|
+
doc: doc2
|
1210
|
+
}, ...lineSuffix2.reverse());
|
1211
|
+
lineSuffix2.length = 0;
|
1212
|
+
break;
|
1213
|
+
}
|
1214
|
+
if (doc2.literal) {
|
1215
|
+
if (ind.root) {
|
1216
|
+
out.push(newLine, ind.root.value);
|
1217
|
+
pos = ind.root.length;
|
1218
|
+
} else {
|
1219
|
+
out.push(newLine);
|
1220
|
+
pos = 0;
|
1221
|
+
}
|
1222
|
+
} else {
|
1223
|
+
pos -= trim2(out);
|
1224
|
+
out.push(newLine + ind.value);
|
1225
|
+
pos = ind.length;
|
1226
|
+
}
|
1227
|
+
break;
|
1228
|
+
}
|
1229
|
+
break;
|
1230
|
+
case DOC_TYPE_LABEL:
|
1231
|
+
cmds.push({
|
1232
|
+
ind,
|
1233
|
+
mode,
|
1234
|
+
doc: doc2.contents
|
1235
|
+
});
|
1236
|
+
break;
|
1237
|
+
case DOC_TYPE_BREAK_PARENT:
|
1238
|
+
break;
|
1239
|
+
default:
|
1240
|
+
throw new invalid_doc_error_default(doc2);
|
1241
|
+
}
|
1242
|
+
if (cmds.length === 0 && lineSuffix2.length > 0) {
|
1243
|
+
cmds.push(...lineSuffix2.reverse());
|
1244
|
+
lineSuffix2.length = 0;
|
1245
|
+
}
|
1246
|
+
}
|
1247
|
+
const cursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER);
|
1248
|
+
if (cursorPlaceholderIndex !== -1) {
|
1249
|
+
const otherCursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER, cursorPlaceholderIndex + 1);
|
1250
|
+
const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
|
1251
|
+
const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
|
1252
|
+
const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
|
1253
|
+
return {
|
1254
|
+
formatted: beforeCursor + aroundCursor + afterCursor,
|
1255
|
+
cursorNodeStart: beforeCursor.length,
|
1256
|
+
cursorNodeText: aroundCursor
|
1257
|
+
};
|
1258
|
+
}
|
1259
|
+
return {
|
1260
|
+
formatted: out.join("")
|
1261
|
+
};
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
// src/document/public.js
|
1265
|
+
var builders = {
|
1266
|
+
join,
|
1267
|
+
line,
|
1268
|
+
softline,
|
1269
|
+
hardline,
|
1270
|
+
literalline,
|
1271
|
+
group,
|
1272
|
+
conditionalGroup,
|
1273
|
+
fill,
|
1274
|
+
lineSuffix,
|
1275
|
+
lineSuffixBoundary,
|
1276
|
+
cursor,
|
1277
|
+
breakParent,
|
1278
|
+
ifBreak,
|
1279
|
+
trim,
|
1280
|
+
indent,
|
1281
|
+
indentIfBreak,
|
1282
|
+
align,
|
1283
|
+
addAlignmentToDoc,
|
1284
|
+
markAsRoot,
|
1285
|
+
dedentToRoot,
|
1286
|
+
dedent,
|
1287
|
+
hardlineWithoutBreakParent,
|
1288
|
+
literallineWithoutBreakParent,
|
1289
|
+
label,
|
1290
|
+
// TODO: Remove this in v4
|
1291
|
+
concat: (parts) => parts
|
1292
|
+
};
|
1293
|
+
var printer = { printDocToString };
|
1294
|
+
var utils = {
|
1295
|
+
willBreak,
|
1296
|
+
traverseDoc: traverse_doc_default,
|
1297
|
+
findInDoc,
|
1298
|
+
mapDoc,
|
1299
|
+
removeLines,
|
1300
|
+
stripTrailingHardline,
|
1301
|
+
replaceEndOfLine,
|
1302
|
+
canBreak
|
1303
|
+
};
|
1304
|
+
|
1305
|
+
// with-default-export:src/document/public.js
|
1306
|
+
var public_default = public_exports;
|
1307
|
+
export {
|
1308
|
+
builders,
|
1309
|
+
public_default as default,
|
1310
|
+
printer,
|
1311
|
+
utils
|
1312
|
+
};
|