dorian 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +15 -0
- data/.github/workflows/ci.yml +38 -0
- data/.gitignore +30 -0
- data/.node-version +1 -0
- data/.prettierignore +2 -0
- data/.rubocop.yml +129 -0
- data/.ruby-version +1 -0
- data/.tool-versions +3 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +186 -0
- data/LICENSE +19 -0
- data/README.md +24 -0
- data/VERSION +1 -1
- data/bin/bundle +123 -0
- data/bin/bundle-audit +31 -0
- data/bin/bundler-audit +31 -0
- data/bin/rspec +31 -0
- data/bin/rubocop +31 -0
- data/dorian.gemspec +35 -0
- data/lib/dorian/bin.rb +739 -81
- data/package-lock.json +39 -0
- data/package.json +11 -0
- data/samples/books.json +33 -0
- data/samples/books.jsonl +3 -0
- data/samples/config.yml +27 -0
- data/samples/config_2.yml +22 -0
- data/samples/maths.js +1 -0
- data/samples/numbers.raw +10 -0
- data/samples/people.csv +6 -0
- data/samples/people.yml +28 -0
- data/samples/query.sql +7 -0
- data/samples/user.json +31 -0
- data/spec/dorian_spec.rb +276 -0
- data/spec/spec_helper.rb +3 -0
- data/vendor/groovy-beautify/LICENSE.MD +21 -0
- data/vendor/groovy-beautify/README.md +65 -0
- data/vendor/groovy-beautify/dist/__tests__/index.test.d.ts +1 -0
- data/vendor/groovy-beautify/dist/cjs/index.js +573 -0
- data/vendor/groovy-beautify/dist/cjs/package.json +3 -0
- data/vendor/groovy-beautify/dist/es/index.js +682 -0
- data/vendor/groovy-beautify/dist/es/package.json +3 -0
- data/vendor/groovy-beautify/dist/formatter/FormatRule.d.ts +14 -0
- data/vendor/groovy-beautify/dist/formatter/Formatter.d.ts +11 -0
- data/vendor/groovy-beautify/dist/formatter/GroovyFormatRules.d.ts +3 -0
- data/vendor/groovy-beautify/dist/formatter/__tests__/formatter.test.d.ts +1 -0
- data/vendor/groovy-beautify/dist/index.d.ts +5 -0
- data/vendor/groovy-beautify/dist/parser/GroovyParseRules.d.ts +3 -0
- data/vendor/groovy-beautify/dist/parser/ParseRule.d.ts +23 -0
- data/vendor/groovy-beautify/dist/parser/Parser.d.ts +29 -0
- data/vendor/groovy-beautify/dist/parser/__tests__/parser.test.d.ts +1 -0
- data/vendor/groovy-beautify/dist/parser/types.d.ts +6 -0
- data/vendor/groovy-beautify/dist/utils/text.d.ts +4 -0
- data/vendor/groovy-beautify/package.json +55 -0
- data/vendor/prettier/LICENSE +4379 -0
- data/vendor/prettier/README.md +109 -0
- data/vendor/prettier/bin/prettier.cjs +71 -0
- data/vendor/prettier/doc.d.ts +243 -0
- data/vendor/prettier/doc.js +1545 -0
- data/vendor/prettier/doc.mjs +1503 -0
- data/vendor/prettier/index.cjs +825 -0
- data/vendor/prettier/index.d.ts +941 -0
- data/vendor/prettier/index.mjs +25899 -0
- data/vendor/prettier/internal/cli.mjs +4366 -0
- data/vendor/prettier/package.json +198 -0
- data/vendor/prettier/plugins/acorn.d.ts +6 -0
- data/vendor/prettier/plugins/acorn.js +6618 -0
- data/vendor/prettier/plugins/acorn.mjs +6456 -0
- data/vendor/prettier/plugins/angular.d.ts +8 -0
- data/vendor/prettier/plugins/angular.js +2435 -0
- data/vendor/prettier/plugins/angular.mjs +2375 -0
- data/vendor/prettier/plugins/babel.d.ts +18 -0
- data/vendor/prettier/plugins/babel.js +14271 -0
- data/vendor/prettier/plugins/babel.mjs +13986 -0
- data/vendor/prettier/plugins/estree.d.ts +1 -0
- data/vendor/prettier/plugins/estree.js +9487 -0
- data/vendor/prettier/plugins/estree.mjs +9279 -0
- data/vendor/prettier/plugins/flow.d.ts +5 -0
- data/vendor/prettier/plugins/flow.js +51477 -0
- data/vendor/prettier/plugins/flow.mjs +51219 -0
- data/vendor/prettier/plugins/glimmer.d.ts +5 -0
- data/vendor/prettier/plugins/glimmer.js +8534 -0
- data/vendor/prettier/plugins/glimmer.mjs +8421 -0
- data/vendor/prettier/plugins/graphql.d.ts +5 -0
- data/vendor/prettier/plugins/graphql.js +2421 -0
- data/vendor/prettier/plugins/graphql.mjs +2347 -0
- data/vendor/prettier/plugins/html.d.ts +8 -0
- data/vendor/prettier/plugins/html.js +8182 -0
- data/vendor/prettier/plugins/html.mjs +8077 -0
- data/vendor/prettier/plugins/markdown.d.ts +7 -0
- data/vendor/prettier/plugins/markdown.js +9068 -0
- data/vendor/prettier/plugins/markdown.mjs +8977 -0
- data/vendor/prettier/plugins/meriyah.d.ts +5 -0
- data/vendor/prettier/plugins/meriyah.js +5953 -0
- data/vendor/prettier/plugins/meriyah.mjs +5800 -0
- data/vendor/prettier/plugins/postcss.d.ts +7 -0
- data/vendor/prettier/plugins/postcss.js +9244 -0
- data/vendor/prettier/plugins/postcss.mjs +9046 -0
- data/vendor/prettier/plugins/typescript.d.ts +5 -0
- data/vendor/prettier/plugins/typescript.js +38058 -0
- data/vendor/prettier/plugins/typescript.mjs +37732 -0
- data/vendor/prettier/plugins/yaml.d.ts +5 -0
- data/vendor/prettier/plugins/yaml.js +7425 -0
- data/vendor/prettier/plugins/yaml.mjs +7329 -0
- data/vendor/prettier/standalone.d.ts +33 -0
- data/vendor/prettier/standalone.js +3984 -0
- data/vendor/prettier/standalone.mjs +3938 -0
- data/vendor/sql-formatter.js +18762 -0
- metadata +205 -2
@@ -0,0 +1,1545 @@
|
|
1
|
+
(function (factory) {
|
2
|
+
function interopModuleDefault() {
|
3
|
+
var module = factory();
|
4
|
+
return module.default || module;
|
5
|
+
}
|
6
|
+
|
7
|
+
if (typeof exports === "object" && typeof module === "object") {
|
8
|
+
module.exports = interopModuleDefault();
|
9
|
+
} else if (typeof define === "function" && define.amd) {
|
10
|
+
define(interopModuleDefault);
|
11
|
+
} else {
|
12
|
+
var root =
|
13
|
+
typeof globalThis !== "undefined"
|
14
|
+
? globalThis
|
15
|
+
: typeof global !== "undefined"
|
16
|
+
? global
|
17
|
+
: typeof self !== "undefined"
|
18
|
+
? self
|
19
|
+
: this || {};
|
20
|
+
root.doc = interopModuleDefault();
|
21
|
+
}
|
22
|
+
})(function () {
|
23
|
+
"use strict";
|
24
|
+
var __defProp = Object.defineProperty;
|
25
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
26
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
27
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
28
|
+
var __export = (target, all) => {
|
29
|
+
for (var name in all)
|
30
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
31
|
+
};
|
32
|
+
var __copyProps = (to, from, except, desc) => {
|
33
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
34
|
+
for (let key of __getOwnPropNames(from))
|
35
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
36
|
+
__defProp(to, key, {
|
37
|
+
get: () => from[key],
|
38
|
+
enumerable:
|
39
|
+
!(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
40
|
+
});
|
41
|
+
}
|
42
|
+
return to;
|
43
|
+
};
|
44
|
+
var __toCommonJS = (mod) =>
|
45
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
46
|
+
|
47
|
+
// src/document/public.js
|
48
|
+
var public_exports = {};
|
49
|
+
__export(public_exports, {
|
50
|
+
builders: () => builders,
|
51
|
+
printer: () => printer,
|
52
|
+
utils: () => utils,
|
53
|
+
});
|
54
|
+
|
55
|
+
// src/document/constants.js
|
56
|
+
var DOC_TYPE_STRING = "string";
|
57
|
+
var DOC_TYPE_ARRAY = "array";
|
58
|
+
var DOC_TYPE_CURSOR = "cursor";
|
59
|
+
var DOC_TYPE_INDENT = "indent";
|
60
|
+
var DOC_TYPE_ALIGN = "align";
|
61
|
+
var DOC_TYPE_TRIM = "trim";
|
62
|
+
var DOC_TYPE_GROUP = "group";
|
63
|
+
var DOC_TYPE_FILL = "fill";
|
64
|
+
var DOC_TYPE_IF_BREAK = "if-break";
|
65
|
+
var DOC_TYPE_INDENT_IF_BREAK = "indent-if-break";
|
66
|
+
var DOC_TYPE_LINE_SUFFIX = "line-suffix";
|
67
|
+
var DOC_TYPE_LINE_SUFFIX_BOUNDARY = "line-suffix-boundary";
|
68
|
+
var DOC_TYPE_LINE = "line";
|
69
|
+
var DOC_TYPE_LABEL = "label";
|
70
|
+
var DOC_TYPE_BREAK_PARENT = "break-parent";
|
71
|
+
var VALID_OBJECT_DOC_TYPES = /* @__PURE__ */ new Set([
|
72
|
+
DOC_TYPE_CURSOR,
|
73
|
+
DOC_TYPE_INDENT,
|
74
|
+
DOC_TYPE_ALIGN,
|
75
|
+
DOC_TYPE_TRIM,
|
76
|
+
DOC_TYPE_GROUP,
|
77
|
+
DOC_TYPE_FILL,
|
78
|
+
DOC_TYPE_IF_BREAK,
|
79
|
+
DOC_TYPE_INDENT_IF_BREAK,
|
80
|
+
DOC_TYPE_LINE_SUFFIX,
|
81
|
+
DOC_TYPE_LINE_SUFFIX_BOUNDARY,
|
82
|
+
DOC_TYPE_LINE,
|
83
|
+
DOC_TYPE_LABEL,
|
84
|
+
DOC_TYPE_BREAK_PARENT,
|
85
|
+
]);
|
86
|
+
|
87
|
+
// src/document/utils/get-doc-type.js
|
88
|
+
function getDocType(doc) {
|
89
|
+
if (typeof doc === "string") {
|
90
|
+
return DOC_TYPE_STRING;
|
91
|
+
}
|
92
|
+
if (Array.isArray(doc)) {
|
93
|
+
return DOC_TYPE_ARRAY;
|
94
|
+
}
|
95
|
+
if (!doc) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
const { type } = doc;
|
99
|
+
if (VALID_OBJECT_DOC_TYPES.has(type)) {
|
100
|
+
return type;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
var get_doc_type_default = getDocType;
|
104
|
+
|
105
|
+
// src/document/invalid-doc-error.js
|
106
|
+
var disjunctionListFormat = (list) =>
|
107
|
+
new Intl.ListFormat("en-US", { type: "disjunction" }).format(list);
|
108
|
+
function getDocErrorMessage(doc) {
|
109
|
+
const type = doc === null ? "null" : typeof doc;
|
110
|
+
if (type !== "string" && type !== "object") {
|
111
|
+
return `Unexpected doc '${type}',
|
112
|
+
Expected it to be 'string' or 'object'.`;
|
113
|
+
}
|
114
|
+
if (get_doc_type_default(doc)) {
|
115
|
+
throw new Error("doc is valid.");
|
116
|
+
}
|
117
|
+
const objectType = Object.prototype.toString.call(doc);
|
118
|
+
if (objectType !== "[object Object]") {
|
119
|
+
return `Unexpected doc '${objectType}'.`;
|
120
|
+
}
|
121
|
+
const EXPECTED_TYPE_VALUES = disjunctionListFormat(
|
122
|
+
[...VALID_OBJECT_DOC_TYPES].map((type2) => `'${type2}'`),
|
123
|
+
);
|
124
|
+
return `Unexpected doc.type '${doc.type}'.
|
125
|
+
Expected it to be ${EXPECTED_TYPE_VALUES}.`;
|
126
|
+
}
|
127
|
+
var InvalidDocError = class extends Error {
|
128
|
+
name = "InvalidDocError";
|
129
|
+
constructor(doc) {
|
130
|
+
super(getDocErrorMessage(doc));
|
131
|
+
this.doc = doc;
|
132
|
+
}
|
133
|
+
};
|
134
|
+
var invalid_doc_error_default = InvalidDocError;
|
135
|
+
|
136
|
+
// src/document/utils/traverse-doc.js
|
137
|
+
var traverseDocOnExitStackMarker = {};
|
138
|
+
function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
|
139
|
+
const docsStack = [doc];
|
140
|
+
while (docsStack.length > 0) {
|
141
|
+
const doc2 = docsStack.pop();
|
142
|
+
if (doc2 === traverseDocOnExitStackMarker) {
|
143
|
+
onExit(docsStack.pop());
|
144
|
+
continue;
|
145
|
+
}
|
146
|
+
if (onExit) {
|
147
|
+
docsStack.push(doc2, traverseDocOnExitStackMarker);
|
148
|
+
}
|
149
|
+
const docType = get_doc_type_default(doc2);
|
150
|
+
if (!docType) {
|
151
|
+
throw new invalid_doc_error_default(doc2);
|
152
|
+
}
|
153
|
+
if ((onEnter == null ? void 0 : onEnter(doc2)) === false) {
|
154
|
+
continue;
|
155
|
+
}
|
156
|
+
switch (docType) {
|
157
|
+
case DOC_TYPE_ARRAY:
|
158
|
+
case DOC_TYPE_FILL: {
|
159
|
+
const parts = docType === DOC_TYPE_ARRAY ? doc2 : doc2.parts;
|
160
|
+
for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
|
161
|
+
docsStack.push(parts[i]);
|
162
|
+
}
|
163
|
+
break;
|
164
|
+
}
|
165
|
+
case DOC_TYPE_IF_BREAK:
|
166
|
+
docsStack.push(doc2.flatContents, doc2.breakContents);
|
167
|
+
break;
|
168
|
+
case DOC_TYPE_GROUP:
|
169
|
+
if (shouldTraverseConditionalGroups && doc2.expandedStates) {
|
170
|
+
for (let ic = doc2.expandedStates.length, i = ic - 1; i >= 0; --i) {
|
171
|
+
docsStack.push(doc2.expandedStates[i]);
|
172
|
+
}
|
173
|
+
} else {
|
174
|
+
docsStack.push(doc2.contents);
|
175
|
+
}
|
176
|
+
break;
|
177
|
+
case DOC_TYPE_ALIGN:
|
178
|
+
case DOC_TYPE_INDENT:
|
179
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
180
|
+
case DOC_TYPE_LABEL:
|
181
|
+
case DOC_TYPE_LINE_SUFFIX:
|
182
|
+
docsStack.push(doc2.contents);
|
183
|
+
break;
|
184
|
+
case DOC_TYPE_STRING:
|
185
|
+
case DOC_TYPE_CURSOR:
|
186
|
+
case DOC_TYPE_TRIM:
|
187
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
188
|
+
case DOC_TYPE_LINE:
|
189
|
+
case DOC_TYPE_BREAK_PARENT:
|
190
|
+
break;
|
191
|
+
default:
|
192
|
+
throw new invalid_doc_error_default(doc2);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
var traverse_doc_default = traverseDoc;
|
197
|
+
|
198
|
+
// src/document/utils/assert-doc.js
|
199
|
+
var noop = () => {};
|
200
|
+
var assertDoc = true
|
201
|
+
? noop
|
202
|
+
: function (doc) {
|
203
|
+
traverse_doc_default(doc, (doc2) => {
|
204
|
+
if (checked.has(doc2)) {
|
205
|
+
return false;
|
206
|
+
}
|
207
|
+
if (typeof doc2 !== "string") {
|
208
|
+
checked.add(doc2);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
};
|
212
|
+
var assertDocArray = true
|
213
|
+
? noop
|
214
|
+
: function (docs, optional = false) {
|
215
|
+
if (optional && !docs) {
|
216
|
+
return;
|
217
|
+
}
|
218
|
+
if (!Array.isArray(docs)) {
|
219
|
+
throw new TypeError("Unexpected doc array.");
|
220
|
+
}
|
221
|
+
for (const doc of docs) {
|
222
|
+
assertDoc(doc);
|
223
|
+
}
|
224
|
+
};
|
225
|
+
|
226
|
+
// src/document/builders.js
|
227
|
+
function indent(contents) {
|
228
|
+
assertDoc(contents);
|
229
|
+
return { type: DOC_TYPE_INDENT, contents };
|
230
|
+
}
|
231
|
+
function align(widthOrString, contents) {
|
232
|
+
assertDoc(contents);
|
233
|
+
return { type: DOC_TYPE_ALIGN, contents, n: widthOrString };
|
234
|
+
}
|
235
|
+
function group(contents, opts = {}) {
|
236
|
+
assertDoc(contents);
|
237
|
+
assertDocArray(
|
238
|
+
opts.expandedStates,
|
239
|
+
/* optional */
|
240
|
+
true,
|
241
|
+
);
|
242
|
+
return {
|
243
|
+
type: DOC_TYPE_GROUP,
|
244
|
+
id: opts.id,
|
245
|
+
contents,
|
246
|
+
break: Boolean(opts.shouldBreak),
|
247
|
+
expandedStates: opts.expandedStates,
|
248
|
+
};
|
249
|
+
}
|
250
|
+
function dedentToRoot(contents) {
|
251
|
+
return align(Number.NEGATIVE_INFINITY, contents);
|
252
|
+
}
|
253
|
+
function markAsRoot(contents) {
|
254
|
+
return align({ type: "root" }, contents);
|
255
|
+
}
|
256
|
+
function dedent(contents) {
|
257
|
+
return align(-1, contents);
|
258
|
+
}
|
259
|
+
function conditionalGroup(states, opts) {
|
260
|
+
return group(states[0], { ...opts, expandedStates: states });
|
261
|
+
}
|
262
|
+
function fill(parts) {
|
263
|
+
assertDocArray(parts);
|
264
|
+
return { type: DOC_TYPE_FILL, parts };
|
265
|
+
}
|
266
|
+
function ifBreak(breakContents, flatContents = "", opts = {}) {
|
267
|
+
assertDoc(breakContents);
|
268
|
+
if (flatContents !== "") {
|
269
|
+
assertDoc(flatContents);
|
270
|
+
}
|
271
|
+
return {
|
272
|
+
type: DOC_TYPE_IF_BREAK,
|
273
|
+
breakContents,
|
274
|
+
flatContents,
|
275
|
+
groupId: opts.groupId,
|
276
|
+
};
|
277
|
+
}
|
278
|
+
function indentIfBreak(contents, opts) {
|
279
|
+
assertDoc(contents);
|
280
|
+
return {
|
281
|
+
type: DOC_TYPE_INDENT_IF_BREAK,
|
282
|
+
contents,
|
283
|
+
groupId: opts.groupId,
|
284
|
+
negate: opts.negate,
|
285
|
+
};
|
286
|
+
}
|
287
|
+
function lineSuffix(contents) {
|
288
|
+
assertDoc(contents);
|
289
|
+
return { type: DOC_TYPE_LINE_SUFFIX, contents };
|
290
|
+
}
|
291
|
+
var lineSuffixBoundary = { type: DOC_TYPE_LINE_SUFFIX_BOUNDARY };
|
292
|
+
var breakParent = { type: DOC_TYPE_BREAK_PARENT };
|
293
|
+
var trim = { type: DOC_TYPE_TRIM };
|
294
|
+
var hardlineWithoutBreakParent = { type: DOC_TYPE_LINE, hard: true };
|
295
|
+
var literallineWithoutBreakParent = {
|
296
|
+
type: DOC_TYPE_LINE,
|
297
|
+
hard: true,
|
298
|
+
literal: true,
|
299
|
+
};
|
300
|
+
var line = { type: DOC_TYPE_LINE };
|
301
|
+
var softline = { type: DOC_TYPE_LINE, soft: true };
|
302
|
+
var hardline = [hardlineWithoutBreakParent, breakParent];
|
303
|
+
var literalline = [literallineWithoutBreakParent, breakParent];
|
304
|
+
var cursor = { type: DOC_TYPE_CURSOR };
|
305
|
+
function join(separator, docs) {
|
306
|
+
assertDoc(separator);
|
307
|
+
assertDocArray(docs);
|
308
|
+
const parts = [];
|
309
|
+
for (let i = 0; i < docs.length; i++) {
|
310
|
+
if (i !== 0) {
|
311
|
+
parts.push(separator);
|
312
|
+
}
|
313
|
+
parts.push(docs[i]);
|
314
|
+
}
|
315
|
+
return parts;
|
316
|
+
}
|
317
|
+
function addAlignmentToDoc(doc, size, tabWidth) {
|
318
|
+
assertDoc(doc);
|
319
|
+
let aligned = doc;
|
320
|
+
if (size > 0) {
|
321
|
+
for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
|
322
|
+
aligned = indent(aligned);
|
323
|
+
}
|
324
|
+
aligned = align(size % tabWidth, aligned);
|
325
|
+
aligned = align(Number.NEGATIVE_INFINITY, aligned);
|
326
|
+
}
|
327
|
+
return aligned;
|
328
|
+
}
|
329
|
+
function label(label2, contents) {
|
330
|
+
assertDoc(contents);
|
331
|
+
return label2
|
332
|
+
? { type: DOC_TYPE_LABEL, label: label2, contents }
|
333
|
+
: contents;
|
334
|
+
}
|
335
|
+
|
336
|
+
// scripts/build/shims/at.js
|
337
|
+
var at = (isOptionalObject, object, index) => {
|
338
|
+
if (isOptionalObject && (object === void 0 || object === null)) {
|
339
|
+
return;
|
340
|
+
}
|
341
|
+
if (Array.isArray(object) || typeof object === "string") {
|
342
|
+
return object[index < 0 ? object.length + index : index];
|
343
|
+
}
|
344
|
+
return object.at(index);
|
345
|
+
};
|
346
|
+
var at_default = at;
|
347
|
+
|
348
|
+
// scripts/build/shims/string-replace-all.js
|
349
|
+
var stringReplaceAll = (isOptionalObject, original, pattern, replacement) => {
|
350
|
+
if (isOptionalObject && (original === void 0 || original === null)) {
|
351
|
+
return;
|
352
|
+
}
|
353
|
+
if (original.replaceAll) {
|
354
|
+
return original.replaceAll(pattern, replacement);
|
355
|
+
}
|
356
|
+
if (pattern.global) {
|
357
|
+
return original.replace(pattern, replacement);
|
358
|
+
}
|
359
|
+
return original.split(pattern).join(replacement);
|
360
|
+
};
|
361
|
+
var string_replace_all_default = stringReplaceAll;
|
362
|
+
|
363
|
+
// src/common/end-of-line.js
|
364
|
+
function convertEndOfLineToChars(value) {
|
365
|
+
switch (value) {
|
366
|
+
case "cr":
|
367
|
+
return "\r";
|
368
|
+
case "crlf":
|
369
|
+
return "\r\n";
|
370
|
+
default:
|
371
|
+
return "\n";
|
372
|
+
}
|
373
|
+
}
|
374
|
+
|
375
|
+
// node_modules/emoji-regex/index.mjs
|
376
|
+
var emoji_regex_default = () => {
|
377
|
+
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\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]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\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])?|[\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-\uDF43\uDF45-\uDF4A\uDF4C-\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]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\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(?:[\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\uDEB5](?:\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-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\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])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\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;
|
378
|
+
};
|
379
|
+
|
380
|
+
// node_modules/get-east-asian-width/lookup.js
|
381
|
+
function isFullWidth(x) {
|
382
|
+
return (
|
383
|
+
x === 12288 || (x >= 65281 && x <= 65376) || (x >= 65504 && x <= 65510)
|
384
|
+
);
|
385
|
+
}
|
386
|
+
function isWide(x) {
|
387
|
+
return (
|
388
|
+
(x >= 4352 && x <= 4447) ||
|
389
|
+
x === 8986 ||
|
390
|
+
x === 8987 ||
|
391
|
+
x === 9001 ||
|
392
|
+
x === 9002 ||
|
393
|
+
(x >= 9193 && x <= 9196) ||
|
394
|
+
x === 9200 ||
|
395
|
+
x === 9203 ||
|
396
|
+
x === 9725 ||
|
397
|
+
x === 9726 ||
|
398
|
+
x === 9748 ||
|
399
|
+
x === 9749 ||
|
400
|
+
(x >= 9800 && x <= 9811) ||
|
401
|
+
x === 9855 ||
|
402
|
+
x === 9875 ||
|
403
|
+
x === 9889 ||
|
404
|
+
x === 9898 ||
|
405
|
+
x === 9899 ||
|
406
|
+
x === 9917 ||
|
407
|
+
x === 9918 ||
|
408
|
+
x === 9924 ||
|
409
|
+
x === 9925 ||
|
410
|
+
x === 9934 ||
|
411
|
+
x === 9940 ||
|
412
|
+
x === 9962 ||
|
413
|
+
x === 9970 ||
|
414
|
+
x === 9971 ||
|
415
|
+
x === 9973 ||
|
416
|
+
x === 9978 ||
|
417
|
+
x === 9981 ||
|
418
|
+
x === 9989 ||
|
419
|
+
x === 9994 ||
|
420
|
+
x === 9995 ||
|
421
|
+
x === 10024 ||
|
422
|
+
x === 10060 ||
|
423
|
+
x === 10062 ||
|
424
|
+
(x >= 10067 && x <= 10069) ||
|
425
|
+
x === 10071 ||
|
426
|
+
(x >= 10133 && x <= 10135) ||
|
427
|
+
x === 10160 ||
|
428
|
+
x === 10175 ||
|
429
|
+
x === 11035 ||
|
430
|
+
x === 11036 ||
|
431
|
+
x === 11088 ||
|
432
|
+
x === 11093 ||
|
433
|
+
(x >= 11904 && x <= 11929) ||
|
434
|
+
(x >= 11931 && x <= 12019) ||
|
435
|
+
(x >= 12032 && x <= 12245) ||
|
436
|
+
(x >= 12272 && x <= 12287) ||
|
437
|
+
(x >= 12289 && x <= 12350) ||
|
438
|
+
(x >= 12353 && x <= 12438) ||
|
439
|
+
(x >= 12441 && x <= 12543) ||
|
440
|
+
(x >= 12549 && x <= 12591) ||
|
441
|
+
(x >= 12593 && x <= 12686) ||
|
442
|
+
(x >= 12688 && x <= 12771) ||
|
443
|
+
(x >= 12783 && x <= 12830) ||
|
444
|
+
(x >= 12832 && x <= 12871) ||
|
445
|
+
(x >= 12880 && x <= 19903) ||
|
446
|
+
(x >= 19968 && x <= 42124) ||
|
447
|
+
(x >= 42128 && x <= 42182) ||
|
448
|
+
(x >= 43360 && x <= 43388) ||
|
449
|
+
(x >= 44032 && x <= 55203) ||
|
450
|
+
(x >= 63744 && x <= 64255) ||
|
451
|
+
(x >= 65040 && x <= 65049) ||
|
452
|
+
(x >= 65072 && x <= 65106) ||
|
453
|
+
(x >= 65108 && x <= 65126) ||
|
454
|
+
(x >= 65128 && x <= 65131) ||
|
455
|
+
(x >= 94176 && x <= 94180) ||
|
456
|
+
x === 94192 ||
|
457
|
+
x === 94193 ||
|
458
|
+
(x >= 94208 && x <= 100343) ||
|
459
|
+
(x >= 100352 && x <= 101589) ||
|
460
|
+
(x >= 101632 && x <= 101640) ||
|
461
|
+
(x >= 110576 && x <= 110579) ||
|
462
|
+
(x >= 110581 && x <= 110587) ||
|
463
|
+
x === 110589 ||
|
464
|
+
x === 110590 ||
|
465
|
+
(x >= 110592 && x <= 110882) ||
|
466
|
+
x === 110898 ||
|
467
|
+
(x >= 110928 && x <= 110930) ||
|
468
|
+
x === 110933 ||
|
469
|
+
(x >= 110948 && x <= 110951) ||
|
470
|
+
(x >= 110960 && x <= 111355) ||
|
471
|
+
x === 126980 ||
|
472
|
+
x === 127183 ||
|
473
|
+
x === 127374 ||
|
474
|
+
(x >= 127377 && x <= 127386) ||
|
475
|
+
(x >= 127488 && x <= 127490) ||
|
476
|
+
(x >= 127504 && x <= 127547) ||
|
477
|
+
(x >= 127552 && x <= 127560) ||
|
478
|
+
x === 127568 ||
|
479
|
+
x === 127569 ||
|
480
|
+
(x >= 127584 && x <= 127589) ||
|
481
|
+
(x >= 127744 && x <= 127776) ||
|
482
|
+
(x >= 127789 && x <= 127797) ||
|
483
|
+
(x >= 127799 && x <= 127868) ||
|
484
|
+
(x >= 127870 && x <= 127891) ||
|
485
|
+
(x >= 127904 && x <= 127946) ||
|
486
|
+
(x >= 127951 && x <= 127955) ||
|
487
|
+
(x >= 127968 && x <= 127984) ||
|
488
|
+
x === 127988 ||
|
489
|
+
(x >= 127992 && x <= 128062) ||
|
490
|
+
x === 128064 ||
|
491
|
+
(x >= 128066 && x <= 128252) ||
|
492
|
+
(x >= 128255 && x <= 128317) ||
|
493
|
+
(x >= 128331 && x <= 128334) ||
|
494
|
+
(x >= 128336 && x <= 128359) ||
|
495
|
+
x === 128378 ||
|
496
|
+
x === 128405 ||
|
497
|
+
x === 128406 ||
|
498
|
+
x === 128420 ||
|
499
|
+
(x >= 128507 && x <= 128591) ||
|
500
|
+
(x >= 128640 && x <= 128709) ||
|
501
|
+
x === 128716 ||
|
502
|
+
(x >= 128720 && x <= 128722) ||
|
503
|
+
(x >= 128725 && x <= 128727) ||
|
504
|
+
(x >= 128732 && x <= 128735) ||
|
505
|
+
x === 128747 ||
|
506
|
+
x === 128748 ||
|
507
|
+
(x >= 128756 && x <= 128764) ||
|
508
|
+
(x >= 128992 && x <= 129003) ||
|
509
|
+
x === 129008 ||
|
510
|
+
(x >= 129292 && x <= 129338) ||
|
511
|
+
(x >= 129340 && x <= 129349) ||
|
512
|
+
(x >= 129351 && x <= 129535) ||
|
513
|
+
(x >= 129648 && x <= 129660) ||
|
514
|
+
(x >= 129664 && x <= 129672) ||
|
515
|
+
(x >= 129680 && x <= 129725) ||
|
516
|
+
(x >= 129727 && x <= 129733) ||
|
517
|
+
(x >= 129742 && x <= 129755) ||
|
518
|
+
(x >= 129760 && x <= 129768) ||
|
519
|
+
(x >= 129776 && x <= 129784) ||
|
520
|
+
(x >= 131072 && x <= 196605) ||
|
521
|
+
(x >= 196608 && x <= 262141)
|
522
|
+
);
|
523
|
+
}
|
524
|
+
|
525
|
+
// node_modules/get-east-asian-width/index.js
|
526
|
+
var _isNarrowWidth = (codePoint) =>
|
527
|
+
!(isFullWidth(codePoint) || isWide(codePoint));
|
528
|
+
|
529
|
+
// src/utils/get-string-width.js
|
530
|
+
var notAsciiRegex = /[^\x20-\x7F]/u;
|
531
|
+
function getStringWidth(text) {
|
532
|
+
if (!text) {
|
533
|
+
return 0;
|
534
|
+
}
|
535
|
+
if (!notAsciiRegex.test(text)) {
|
536
|
+
return text.length;
|
537
|
+
}
|
538
|
+
text = text.replace(emoji_regex_default(), " ");
|
539
|
+
let width = 0;
|
540
|
+
for (const character of text) {
|
541
|
+
const codePoint = character.codePointAt(0);
|
542
|
+
if (codePoint <= 31 || (codePoint >= 127 && codePoint <= 159)) {
|
543
|
+
continue;
|
544
|
+
}
|
545
|
+
if (codePoint >= 768 && codePoint <= 879) {
|
546
|
+
continue;
|
547
|
+
}
|
548
|
+
width += _isNarrowWidth(codePoint) ? 1 : 2;
|
549
|
+
}
|
550
|
+
return width;
|
551
|
+
}
|
552
|
+
var get_string_width_default = getStringWidth;
|
553
|
+
|
554
|
+
// src/document/utils.js
|
555
|
+
function mapDoc(doc, cb) {
|
556
|
+
if (typeof doc === "string") {
|
557
|
+
return cb(doc);
|
558
|
+
}
|
559
|
+
const mapped = /* @__PURE__ */ new Map();
|
560
|
+
return rec(doc);
|
561
|
+
function rec(doc2) {
|
562
|
+
if (mapped.has(doc2)) {
|
563
|
+
return mapped.get(doc2);
|
564
|
+
}
|
565
|
+
const result = process2(doc2);
|
566
|
+
mapped.set(doc2, result);
|
567
|
+
return result;
|
568
|
+
}
|
569
|
+
function process2(doc2) {
|
570
|
+
switch (get_doc_type_default(doc2)) {
|
571
|
+
case DOC_TYPE_ARRAY:
|
572
|
+
return cb(doc2.map(rec));
|
573
|
+
case DOC_TYPE_FILL:
|
574
|
+
return cb({
|
575
|
+
...doc2,
|
576
|
+
parts: doc2.parts.map(rec),
|
577
|
+
});
|
578
|
+
case DOC_TYPE_IF_BREAK:
|
579
|
+
return cb({
|
580
|
+
...doc2,
|
581
|
+
breakContents: rec(doc2.breakContents),
|
582
|
+
flatContents: rec(doc2.flatContents),
|
583
|
+
});
|
584
|
+
case DOC_TYPE_GROUP: {
|
585
|
+
let { expandedStates, contents } = doc2;
|
586
|
+
if (expandedStates) {
|
587
|
+
expandedStates = expandedStates.map(rec);
|
588
|
+
contents = expandedStates[0];
|
589
|
+
} else {
|
590
|
+
contents = rec(contents);
|
591
|
+
}
|
592
|
+
return cb({
|
593
|
+
...doc2,
|
594
|
+
contents,
|
595
|
+
expandedStates,
|
596
|
+
});
|
597
|
+
}
|
598
|
+
case DOC_TYPE_ALIGN:
|
599
|
+
case DOC_TYPE_INDENT:
|
600
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
601
|
+
case DOC_TYPE_LABEL:
|
602
|
+
case DOC_TYPE_LINE_SUFFIX:
|
603
|
+
return cb({
|
604
|
+
...doc2,
|
605
|
+
contents: rec(doc2.contents),
|
606
|
+
});
|
607
|
+
case DOC_TYPE_STRING:
|
608
|
+
case DOC_TYPE_CURSOR:
|
609
|
+
case DOC_TYPE_TRIM:
|
610
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
611
|
+
case DOC_TYPE_LINE:
|
612
|
+
case DOC_TYPE_BREAK_PARENT:
|
613
|
+
return cb(doc2);
|
614
|
+
default:
|
615
|
+
throw new invalid_doc_error_default(doc2);
|
616
|
+
}
|
617
|
+
}
|
618
|
+
}
|
619
|
+
function findInDoc(doc, fn, defaultValue) {
|
620
|
+
let result = defaultValue;
|
621
|
+
let shouldSkipFurtherProcessing = false;
|
622
|
+
function findInDocOnEnterFn(doc2) {
|
623
|
+
if (shouldSkipFurtherProcessing) {
|
624
|
+
return false;
|
625
|
+
}
|
626
|
+
const maybeResult = fn(doc2);
|
627
|
+
if (maybeResult !== void 0) {
|
628
|
+
shouldSkipFurtherProcessing = true;
|
629
|
+
result = maybeResult;
|
630
|
+
}
|
631
|
+
}
|
632
|
+
traverse_doc_default(doc, findInDocOnEnterFn);
|
633
|
+
return result;
|
634
|
+
}
|
635
|
+
function willBreakFn(doc) {
|
636
|
+
if (doc.type === DOC_TYPE_GROUP && doc.break) {
|
637
|
+
return true;
|
638
|
+
}
|
639
|
+
if (doc.type === DOC_TYPE_LINE && doc.hard) {
|
640
|
+
return true;
|
641
|
+
}
|
642
|
+
if (doc.type === DOC_TYPE_BREAK_PARENT) {
|
643
|
+
return true;
|
644
|
+
}
|
645
|
+
}
|
646
|
+
function willBreak(doc) {
|
647
|
+
return findInDoc(doc, willBreakFn, false);
|
648
|
+
}
|
649
|
+
function breakParentGroup(groupStack) {
|
650
|
+
if (groupStack.length > 0) {
|
651
|
+
const parentGroup = at_default(
|
652
|
+
/* isOptionalObject */
|
653
|
+
false,
|
654
|
+
groupStack,
|
655
|
+
-1,
|
656
|
+
);
|
657
|
+
if (!parentGroup.expandedStates && !parentGroup.break) {
|
658
|
+
parentGroup.break = "propagated";
|
659
|
+
}
|
660
|
+
}
|
661
|
+
return null;
|
662
|
+
}
|
663
|
+
function propagateBreaks(doc) {
|
664
|
+
const alreadyVisitedSet = /* @__PURE__ */ new Set();
|
665
|
+
const groupStack = [];
|
666
|
+
function propagateBreaksOnEnterFn(doc2) {
|
667
|
+
if (doc2.type === DOC_TYPE_BREAK_PARENT) {
|
668
|
+
breakParentGroup(groupStack);
|
669
|
+
}
|
670
|
+
if (doc2.type === DOC_TYPE_GROUP) {
|
671
|
+
groupStack.push(doc2);
|
672
|
+
if (alreadyVisitedSet.has(doc2)) {
|
673
|
+
return false;
|
674
|
+
}
|
675
|
+
alreadyVisitedSet.add(doc2);
|
676
|
+
}
|
677
|
+
}
|
678
|
+
function propagateBreaksOnExitFn(doc2) {
|
679
|
+
if (doc2.type === DOC_TYPE_GROUP) {
|
680
|
+
const group2 = groupStack.pop();
|
681
|
+
if (group2.break) {
|
682
|
+
breakParentGroup(groupStack);
|
683
|
+
}
|
684
|
+
}
|
685
|
+
}
|
686
|
+
traverse_doc_default(
|
687
|
+
doc,
|
688
|
+
propagateBreaksOnEnterFn,
|
689
|
+
propagateBreaksOnExitFn,
|
690
|
+
/* shouldTraverseConditionalGroups */
|
691
|
+
true,
|
692
|
+
);
|
693
|
+
}
|
694
|
+
function removeLinesFn(doc) {
|
695
|
+
if (doc.type === DOC_TYPE_LINE && !doc.hard) {
|
696
|
+
return doc.soft ? "" : " ";
|
697
|
+
}
|
698
|
+
if (doc.type === DOC_TYPE_IF_BREAK) {
|
699
|
+
return doc.flatContents;
|
700
|
+
}
|
701
|
+
return doc;
|
702
|
+
}
|
703
|
+
function removeLines(doc) {
|
704
|
+
return mapDoc(doc, removeLinesFn);
|
705
|
+
}
|
706
|
+
function stripTrailingHardlineFromParts(parts) {
|
707
|
+
parts = [...parts];
|
708
|
+
while (
|
709
|
+
parts.length >= 2 &&
|
710
|
+
at_default(
|
711
|
+
/* isOptionalObject */
|
712
|
+
false,
|
713
|
+
parts,
|
714
|
+
-2,
|
715
|
+
).type === DOC_TYPE_LINE &&
|
716
|
+
at_default(
|
717
|
+
/* isOptionalObject */
|
718
|
+
false,
|
719
|
+
parts,
|
720
|
+
-1,
|
721
|
+
).type === DOC_TYPE_BREAK_PARENT
|
722
|
+
) {
|
723
|
+
parts.length -= 2;
|
724
|
+
}
|
725
|
+
if (parts.length > 0) {
|
726
|
+
const lastPart = stripTrailingHardlineFromDoc(
|
727
|
+
at_default(
|
728
|
+
/* isOptionalObject */
|
729
|
+
false,
|
730
|
+
parts,
|
731
|
+
-1,
|
732
|
+
),
|
733
|
+
);
|
734
|
+
parts[parts.length - 1] = lastPart;
|
735
|
+
}
|
736
|
+
return parts;
|
737
|
+
}
|
738
|
+
function stripTrailingHardlineFromDoc(doc) {
|
739
|
+
switch (get_doc_type_default(doc)) {
|
740
|
+
case DOC_TYPE_INDENT:
|
741
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
742
|
+
case DOC_TYPE_GROUP:
|
743
|
+
case DOC_TYPE_LINE_SUFFIX:
|
744
|
+
case DOC_TYPE_LABEL: {
|
745
|
+
const contents = stripTrailingHardlineFromDoc(doc.contents);
|
746
|
+
return {
|
747
|
+
...doc,
|
748
|
+
contents,
|
749
|
+
};
|
750
|
+
}
|
751
|
+
case DOC_TYPE_IF_BREAK:
|
752
|
+
return {
|
753
|
+
...doc,
|
754
|
+
breakContents: stripTrailingHardlineFromDoc(doc.breakContents),
|
755
|
+
flatContents: stripTrailingHardlineFromDoc(doc.flatContents),
|
756
|
+
};
|
757
|
+
case DOC_TYPE_FILL:
|
758
|
+
return {
|
759
|
+
...doc,
|
760
|
+
parts: stripTrailingHardlineFromParts(doc.parts),
|
761
|
+
};
|
762
|
+
case DOC_TYPE_ARRAY:
|
763
|
+
return stripTrailingHardlineFromParts(doc);
|
764
|
+
case DOC_TYPE_STRING:
|
765
|
+
return doc.replace(/[\n\r]*$/u, "");
|
766
|
+
case DOC_TYPE_ALIGN:
|
767
|
+
case DOC_TYPE_CURSOR:
|
768
|
+
case DOC_TYPE_TRIM:
|
769
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
770
|
+
case DOC_TYPE_LINE:
|
771
|
+
case DOC_TYPE_BREAK_PARENT:
|
772
|
+
break;
|
773
|
+
default:
|
774
|
+
throw new invalid_doc_error_default(doc);
|
775
|
+
}
|
776
|
+
return doc;
|
777
|
+
}
|
778
|
+
function stripTrailingHardline(doc) {
|
779
|
+
return stripTrailingHardlineFromDoc(cleanDoc(doc));
|
780
|
+
}
|
781
|
+
function cleanDocFn(doc) {
|
782
|
+
switch (get_doc_type_default(doc)) {
|
783
|
+
case DOC_TYPE_FILL:
|
784
|
+
if (doc.parts.every((part) => part === "")) {
|
785
|
+
return "";
|
786
|
+
}
|
787
|
+
break;
|
788
|
+
case DOC_TYPE_GROUP:
|
789
|
+
if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
|
790
|
+
return "";
|
791
|
+
}
|
792
|
+
if (
|
793
|
+
doc.contents.type === DOC_TYPE_GROUP &&
|
794
|
+
doc.contents.id === doc.id &&
|
795
|
+
doc.contents.break === doc.break &&
|
796
|
+
doc.contents.expandedStates === doc.expandedStates
|
797
|
+
) {
|
798
|
+
return doc.contents;
|
799
|
+
}
|
800
|
+
break;
|
801
|
+
case DOC_TYPE_ALIGN:
|
802
|
+
case DOC_TYPE_INDENT:
|
803
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
804
|
+
case DOC_TYPE_LINE_SUFFIX:
|
805
|
+
if (!doc.contents) {
|
806
|
+
return "";
|
807
|
+
}
|
808
|
+
break;
|
809
|
+
case DOC_TYPE_IF_BREAK:
|
810
|
+
if (!doc.flatContents && !doc.breakContents) {
|
811
|
+
return "";
|
812
|
+
}
|
813
|
+
break;
|
814
|
+
case DOC_TYPE_ARRAY: {
|
815
|
+
const parts = [];
|
816
|
+
for (const part of doc) {
|
817
|
+
if (!part) {
|
818
|
+
continue;
|
819
|
+
}
|
820
|
+
const [currentPart, ...restParts] = Array.isArray(part)
|
821
|
+
? part
|
822
|
+
: [part];
|
823
|
+
if (
|
824
|
+
typeof currentPart === "string" &&
|
825
|
+
typeof at_default(
|
826
|
+
/* isOptionalObject */
|
827
|
+
false,
|
828
|
+
parts,
|
829
|
+
-1,
|
830
|
+
) === "string"
|
831
|
+
) {
|
832
|
+
parts[parts.length - 1] += currentPart;
|
833
|
+
} else {
|
834
|
+
parts.push(currentPart);
|
835
|
+
}
|
836
|
+
parts.push(...restParts);
|
837
|
+
}
|
838
|
+
if (parts.length === 0) {
|
839
|
+
return "";
|
840
|
+
}
|
841
|
+
if (parts.length === 1) {
|
842
|
+
return parts[0];
|
843
|
+
}
|
844
|
+
return parts;
|
845
|
+
}
|
846
|
+
case DOC_TYPE_STRING:
|
847
|
+
case DOC_TYPE_CURSOR:
|
848
|
+
case DOC_TYPE_TRIM:
|
849
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
850
|
+
case DOC_TYPE_LINE:
|
851
|
+
case DOC_TYPE_LABEL:
|
852
|
+
case DOC_TYPE_BREAK_PARENT:
|
853
|
+
break;
|
854
|
+
default:
|
855
|
+
throw new invalid_doc_error_default(doc);
|
856
|
+
}
|
857
|
+
return doc;
|
858
|
+
}
|
859
|
+
function cleanDoc(doc) {
|
860
|
+
return mapDoc(doc, (currentDoc) => cleanDocFn(currentDoc));
|
861
|
+
}
|
862
|
+
function replaceEndOfLine(doc, replacement = literalline) {
|
863
|
+
return mapDoc(doc, (currentDoc) =>
|
864
|
+
typeof currentDoc === "string"
|
865
|
+
? join(replacement, currentDoc.split("\n"))
|
866
|
+
: currentDoc,
|
867
|
+
);
|
868
|
+
}
|
869
|
+
function canBreakFn(doc) {
|
870
|
+
if (doc.type === DOC_TYPE_LINE) {
|
871
|
+
return true;
|
872
|
+
}
|
873
|
+
}
|
874
|
+
function canBreak(doc) {
|
875
|
+
return findInDoc(doc, canBreakFn, false);
|
876
|
+
}
|
877
|
+
|
878
|
+
// src/document/printer.js
|
879
|
+
var MODE_BREAK = Symbol("MODE_BREAK");
|
880
|
+
var MODE_FLAT = Symbol("MODE_FLAT");
|
881
|
+
var CURSOR_PLACEHOLDER = Symbol("cursor");
|
882
|
+
function rootIndent() {
|
883
|
+
return {
|
884
|
+
value: "",
|
885
|
+
length: 0,
|
886
|
+
queue: [],
|
887
|
+
};
|
888
|
+
}
|
889
|
+
function makeIndent(ind, options) {
|
890
|
+
return generateInd(
|
891
|
+
ind,
|
892
|
+
{
|
893
|
+
type: "indent",
|
894
|
+
},
|
895
|
+
options,
|
896
|
+
);
|
897
|
+
}
|
898
|
+
function makeAlign(indent2, widthOrDoc, options) {
|
899
|
+
if (widthOrDoc === Number.NEGATIVE_INFINITY) {
|
900
|
+
return indent2.root || rootIndent();
|
901
|
+
}
|
902
|
+
if (widthOrDoc < 0) {
|
903
|
+
return generateInd(
|
904
|
+
indent2,
|
905
|
+
{
|
906
|
+
type: "dedent",
|
907
|
+
},
|
908
|
+
options,
|
909
|
+
);
|
910
|
+
}
|
911
|
+
if (!widthOrDoc) {
|
912
|
+
return indent2;
|
913
|
+
}
|
914
|
+
if (widthOrDoc.type === "root") {
|
915
|
+
return {
|
916
|
+
...indent2,
|
917
|
+
root: indent2,
|
918
|
+
};
|
919
|
+
}
|
920
|
+
const alignType =
|
921
|
+
typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
|
922
|
+
return generateInd(
|
923
|
+
indent2,
|
924
|
+
{
|
925
|
+
type: alignType,
|
926
|
+
n: widthOrDoc,
|
927
|
+
},
|
928
|
+
options,
|
929
|
+
);
|
930
|
+
}
|
931
|
+
function generateInd(ind, newPart, options) {
|
932
|
+
const queue =
|
933
|
+
newPart.type === "dedent"
|
934
|
+
? ind.queue.slice(0, -1)
|
935
|
+
: [...ind.queue, newPart];
|
936
|
+
let value = "";
|
937
|
+
let length = 0;
|
938
|
+
let lastTabs = 0;
|
939
|
+
let lastSpaces = 0;
|
940
|
+
for (const part of queue) {
|
941
|
+
switch (part.type) {
|
942
|
+
case "indent":
|
943
|
+
flush();
|
944
|
+
if (options.useTabs) {
|
945
|
+
addTabs(1);
|
946
|
+
} else {
|
947
|
+
addSpaces(options.tabWidth);
|
948
|
+
}
|
949
|
+
break;
|
950
|
+
case "stringAlign":
|
951
|
+
flush();
|
952
|
+
value += part.n;
|
953
|
+
length += part.n.length;
|
954
|
+
break;
|
955
|
+
case "numberAlign":
|
956
|
+
lastTabs += 1;
|
957
|
+
lastSpaces += part.n;
|
958
|
+
break;
|
959
|
+
default:
|
960
|
+
throw new Error(`Unexpected type '${part.type}'`);
|
961
|
+
}
|
962
|
+
}
|
963
|
+
flushSpaces();
|
964
|
+
return {
|
965
|
+
...ind,
|
966
|
+
value,
|
967
|
+
length,
|
968
|
+
queue,
|
969
|
+
};
|
970
|
+
function addTabs(count) {
|
971
|
+
value += " ".repeat(count);
|
972
|
+
length += options.tabWidth * count;
|
973
|
+
}
|
974
|
+
function addSpaces(count) {
|
975
|
+
value += " ".repeat(count);
|
976
|
+
length += count;
|
977
|
+
}
|
978
|
+
function flush() {
|
979
|
+
if (options.useTabs) {
|
980
|
+
flushTabs();
|
981
|
+
} else {
|
982
|
+
flushSpaces();
|
983
|
+
}
|
984
|
+
}
|
985
|
+
function flushTabs() {
|
986
|
+
if (lastTabs > 0) {
|
987
|
+
addTabs(lastTabs);
|
988
|
+
}
|
989
|
+
resetLast();
|
990
|
+
}
|
991
|
+
function flushSpaces() {
|
992
|
+
if (lastSpaces > 0) {
|
993
|
+
addSpaces(lastSpaces);
|
994
|
+
}
|
995
|
+
resetLast();
|
996
|
+
}
|
997
|
+
function resetLast() {
|
998
|
+
lastTabs = 0;
|
999
|
+
lastSpaces = 0;
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
function trim2(out) {
|
1003
|
+
let trimCount = 0;
|
1004
|
+
let cursorCount = 0;
|
1005
|
+
let outIndex = out.length;
|
1006
|
+
outer: while (outIndex--) {
|
1007
|
+
const last = out[outIndex];
|
1008
|
+
if (last === CURSOR_PLACEHOLDER) {
|
1009
|
+
cursorCount++;
|
1010
|
+
continue;
|
1011
|
+
}
|
1012
|
+
if (false) {
|
1013
|
+
throw new Error(`Unexpected value in trim: '${typeof last}'`);
|
1014
|
+
}
|
1015
|
+
for (let charIndex = last.length - 1; charIndex >= 0; charIndex--) {
|
1016
|
+
const char = last[charIndex];
|
1017
|
+
if (char === " " || char === " ") {
|
1018
|
+
trimCount++;
|
1019
|
+
} else {
|
1020
|
+
out[outIndex] = last.slice(0, charIndex + 1);
|
1021
|
+
break outer;
|
1022
|
+
}
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
if (trimCount > 0 || cursorCount > 0) {
|
1026
|
+
out.length = outIndex + 1;
|
1027
|
+
while (cursorCount-- > 0) {
|
1028
|
+
out.push(CURSOR_PLACEHOLDER);
|
1029
|
+
}
|
1030
|
+
}
|
1031
|
+
return trimCount;
|
1032
|
+
}
|
1033
|
+
function fits(
|
1034
|
+
next,
|
1035
|
+
restCommands,
|
1036
|
+
width,
|
1037
|
+
hasLineSuffix,
|
1038
|
+
groupModeMap,
|
1039
|
+
mustBeFlat,
|
1040
|
+
) {
|
1041
|
+
if (width === Number.POSITIVE_INFINITY) {
|
1042
|
+
return true;
|
1043
|
+
}
|
1044
|
+
let restIdx = restCommands.length;
|
1045
|
+
const cmds = [next];
|
1046
|
+
const out = [];
|
1047
|
+
while (width >= 0) {
|
1048
|
+
if (cmds.length === 0) {
|
1049
|
+
if (restIdx === 0) {
|
1050
|
+
return true;
|
1051
|
+
}
|
1052
|
+
cmds.push(restCommands[--restIdx]);
|
1053
|
+
continue;
|
1054
|
+
}
|
1055
|
+
const { mode, doc } = cmds.pop();
|
1056
|
+
const docType = get_doc_type_default(doc);
|
1057
|
+
switch (docType) {
|
1058
|
+
case DOC_TYPE_STRING:
|
1059
|
+
out.push(doc);
|
1060
|
+
width -= get_string_width_default(doc);
|
1061
|
+
break;
|
1062
|
+
case DOC_TYPE_ARRAY:
|
1063
|
+
case DOC_TYPE_FILL: {
|
1064
|
+
const parts = docType === DOC_TYPE_ARRAY ? doc : doc.parts;
|
1065
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
1066
|
+
cmds.push({
|
1067
|
+
mode,
|
1068
|
+
doc: parts[i],
|
1069
|
+
});
|
1070
|
+
}
|
1071
|
+
break;
|
1072
|
+
}
|
1073
|
+
case DOC_TYPE_INDENT:
|
1074
|
+
case DOC_TYPE_ALIGN:
|
1075
|
+
case DOC_TYPE_INDENT_IF_BREAK:
|
1076
|
+
case DOC_TYPE_LABEL:
|
1077
|
+
cmds.push({
|
1078
|
+
mode,
|
1079
|
+
doc: doc.contents,
|
1080
|
+
});
|
1081
|
+
break;
|
1082
|
+
case DOC_TYPE_TRIM:
|
1083
|
+
width += trim2(out);
|
1084
|
+
break;
|
1085
|
+
case DOC_TYPE_GROUP: {
|
1086
|
+
if (mustBeFlat && doc.break) {
|
1087
|
+
return false;
|
1088
|
+
}
|
1089
|
+
const groupMode = doc.break ? MODE_BREAK : mode;
|
1090
|
+
const contents =
|
1091
|
+
doc.expandedStates && groupMode === MODE_BREAK
|
1092
|
+
? at_default(
|
1093
|
+
/* isOptionalObject */
|
1094
|
+
false,
|
1095
|
+
doc.expandedStates,
|
1096
|
+
-1,
|
1097
|
+
)
|
1098
|
+
: doc.contents;
|
1099
|
+
cmds.push({
|
1100
|
+
mode: groupMode,
|
1101
|
+
doc: contents,
|
1102
|
+
});
|
1103
|
+
break;
|
1104
|
+
}
|
1105
|
+
case DOC_TYPE_IF_BREAK: {
|
1106
|
+
const groupMode = doc.groupId
|
1107
|
+
? groupModeMap[doc.groupId] || MODE_FLAT
|
1108
|
+
: mode;
|
1109
|
+
const contents =
|
1110
|
+
groupMode === MODE_BREAK ? doc.breakContents : doc.flatContents;
|
1111
|
+
if (contents) {
|
1112
|
+
cmds.push({
|
1113
|
+
mode,
|
1114
|
+
doc: contents,
|
1115
|
+
});
|
1116
|
+
}
|
1117
|
+
break;
|
1118
|
+
}
|
1119
|
+
case DOC_TYPE_LINE:
|
1120
|
+
if (mode === MODE_BREAK || doc.hard) {
|
1121
|
+
return true;
|
1122
|
+
}
|
1123
|
+
if (!doc.soft) {
|
1124
|
+
out.push(" ");
|
1125
|
+
width--;
|
1126
|
+
}
|
1127
|
+
break;
|
1128
|
+
case DOC_TYPE_LINE_SUFFIX:
|
1129
|
+
hasLineSuffix = true;
|
1130
|
+
break;
|
1131
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
1132
|
+
if (hasLineSuffix) {
|
1133
|
+
return false;
|
1134
|
+
}
|
1135
|
+
break;
|
1136
|
+
}
|
1137
|
+
}
|
1138
|
+
return false;
|
1139
|
+
}
|
1140
|
+
function printDocToString(doc, options) {
|
1141
|
+
const groupModeMap = {};
|
1142
|
+
const width = options.printWidth;
|
1143
|
+
const newLine = convertEndOfLineToChars(options.endOfLine);
|
1144
|
+
let pos = 0;
|
1145
|
+
const cmds = [
|
1146
|
+
{
|
1147
|
+
ind: rootIndent(),
|
1148
|
+
mode: MODE_BREAK,
|
1149
|
+
doc,
|
1150
|
+
},
|
1151
|
+
];
|
1152
|
+
const out = [];
|
1153
|
+
let shouldRemeasure = false;
|
1154
|
+
const lineSuffix2 = [];
|
1155
|
+
let printedCursorCount = 0;
|
1156
|
+
propagateBreaks(doc);
|
1157
|
+
while (cmds.length > 0) {
|
1158
|
+
const { ind, mode, doc: doc2 } = cmds.pop();
|
1159
|
+
switch (get_doc_type_default(doc2)) {
|
1160
|
+
case DOC_TYPE_STRING: {
|
1161
|
+
const formatted =
|
1162
|
+
newLine !== "\n"
|
1163
|
+
? string_replace_all_default(
|
1164
|
+
/* isOptionalObject */
|
1165
|
+
false,
|
1166
|
+
doc2,
|
1167
|
+
"\n",
|
1168
|
+
newLine,
|
1169
|
+
)
|
1170
|
+
: doc2;
|
1171
|
+
out.push(formatted);
|
1172
|
+
if (cmds.length > 0) {
|
1173
|
+
pos += get_string_width_default(formatted);
|
1174
|
+
}
|
1175
|
+
break;
|
1176
|
+
}
|
1177
|
+
case DOC_TYPE_ARRAY:
|
1178
|
+
for (let i = doc2.length - 1; i >= 0; i--) {
|
1179
|
+
cmds.push({
|
1180
|
+
ind,
|
1181
|
+
mode,
|
1182
|
+
doc: doc2[i],
|
1183
|
+
});
|
1184
|
+
}
|
1185
|
+
break;
|
1186
|
+
case DOC_TYPE_CURSOR:
|
1187
|
+
if (printedCursorCount >= 2) {
|
1188
|
+
throw new Error("There are too many 'cursor' in doc.");
|
1189
|
+
}
|
1190
|
+
out.push(CURSOR_PLACEHOLDER);
|
1191
|
+
printedCursorCount++;
|
1192
|
+
break;
|
1193
|
+
case DOC_TYPE_INDENT:
|
1194
|
+
cmds.push({
|
1195
|
+
ind: makeIndent(ind, options),
|
1196
|
+
mode,
|
1197
|
+
doc: doc2.contents,
|
1198
|
+
});
|
1199
|
+
break;
|
1200
|
+
case DOC_TYPE_ALIGN:
|
1201
|
+
cmds.push({
|
1202
|
+
ind: makeAlign(ind, doc2.n, options),
|
1203
|
+
mode,
|
1204
|
+
doc: doc2.contents,
|
1205
|
+
});
|
1206
|
+
break;
|
1207
|
+
case DOC_TYPE_TRIM:
|
1208
|
+
pos -= trim2(out);
|
1209
|
+
break;
|
1210
|
+
case DOC_TYPE_GROUP:
|
1211
|
+
switch (mode) {
|
1212
|
+
case MODE_FLAT:
|
1213
|
+
if (!shouldRemeasure) {
|
1214
|
+
cmds.push({
|
1215
|
+
ind,
|
1216
|
+
mode: doc2.break ? MODE_BREAK : MODE_FLAT,
|
1217
|
+
doc: doc2.contents,
|
1218
|
+
});
|
1219
|
+
break;
|
1220
|
+
}
|
1221
|
+
case MODE_BREAK: {
|
1222
|
+
shouldRemeasure = false;
|
1223
|
+
const next = {
|
1224
|
+
ind,
|
1225
|
+
mode: MODE_FLAT,
|
1226
|
+
doc: doc2.contents,
|
1227
|
+
};
|
1228
|
+
const rem = width - pos;
|
1229
|
+
const hasLineSuffix = lineSuffix2.length > 0;
|
1230
|
+
if (
|
1231
|
+
!doc2.break &&
|
1232
|
+
fits(next, cmds, rem, hasLineSuffix, groupModeMap)
|
1233
|
+
) {
|
1234
|
+
cmds.push(next);
|
1235
|
+
} else {
|
1236
|
+
if (doc2.expandedStates) {
|
1237
|
+
const mostExpanded = at_default(
|
1238
|
+
/* isOptionalObject */
|
1239
|
+
false,
|
1240
|
+
doc2.expandedStates,
|
1241
|
+
-1,
|
1242
|
+
);
|
1243
|
+
if (doc2.break) {
|
1244
|
+
cmds.push({
|
1245
|
+
ind,
|
1246
|
+
mode: MODE_BREAK,
|
1247
|
+
doc: mostExpanded,
|
1248
|
+
});
|
1249
|
+
break;
|
1250
|
+
} else {
|
1251
|
+
for (let i = 1; i < doc2.expandedStates.length + 1; i++) {
|
1252
|
+
if (i >= doc2.expandedStates.length) {
|
1253
|
+
cmds.push({
|
1254
|
+
ind,
|
1255
|
+
mode: MODE_BREAK,
|
1256
|
+
doc: mostExpanded,
|
1257
|
+
});
|
1258
|
+
break;
|
1259
|
+
} else {
|
1260
|
+
const state = doc2.expandedStates[i];
|
1261
|
+
const cmd = {
|
1262
|
+
ind,
|
1263
|
+
mode: MODE_FLAT,
|
1264
|
+
doc: state,
|
1265
|
+
};
|
1266
|
+
if (fits(cmd, cmds, rem, hasLineSuffix, groupModeMap)) {
|
1267
|
+
cmds.push(cmd);
|
1268
|
+
break;
|
1269
|
+
}
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
}
|
1273
|
+
} else {
|
1274
|
+
cmds.push({
|
1275
|
+
ind,
|
1276
|
+
mode: MODE_BREAK,
|
1277
|
+
doc: doc2.contents,
|
1278
|
+
});
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
break;
|
1282
|
+
}
|
1283
|
+
}
|
1284
|
+
if (doc2.id) {
|
1285
|
+
groupModeMap[doc2.id] = at_default(
|
1286
|
+
/* isOptionalObject */
|
1287
|
+
false,
|
1288
|
+
cmds,
|
1289
|
+
-1,
|
1290
|
+
).mode;
|
1291
|
+
}
|
1292
|
+
break;
|
1293
|
+
case DOC_TYPE_FILL: {
|
1294
|
+
const rem = width - pos;
|
1295
|
+
const { parts } = doc2;
|
1296
|
+
if (parts.length === 0) {
|
1297
|
+
break;
|
1298
|
+
}
|
1299
|
+
const [content, whitespace] = parts;
|
1300
|
+
const contentFlatCmd = {
|
1301
|
+
ind,
|
1302
|
+
mode: MODE_FLAT,
|
1303
|
+
doc: content,
|
1304
|
+
};
|
1305
|
+
const contentBreakCmd = {
|
1306
|
+
ind,
|
1307
|
+
mode: MODE_BREAK,
|
1308
|
+
doc: content,
|
1309
|
+
};
|
1310
|
+
const contentFits = fits(
|
1311
|
+
contentFlatCmd,
|
1312
|
+
[],
|
1313
|
+
rem,
|
1314
|
+
lineSuffix2.length > 0,
|
1315
|
+
groupModeMap,
|
1316
|
+
true,
|
1317
|
+
);
|
1318
|
+
if (parts.length === 1) {
|
1319
|
+
if (contentFits) {
|
1320
|
+
cmds.push(contentFlatCmd);
|
1321
|
+
} else {
|
1322
|
+
cmds.push(contentBreakCmd);
|
1323
|
+
}
|
1324
|
+
break;
|
1325
|
+
}
|
1326
|
+
const whitespaceFlatCmd = {
|
1327
|
+
ind,
|
1328
|
+
mode: MODE_FLAT,
|
1329
|
+
doc: whitespace,
|
1330
|
+
};
|
1331
|
+
const whitespaceBreakCmd = {
|
1332
|
+
ind,
|
1333
|
+
mode: MODE_BREAK,
|
1334
|
+
doc: whitespace,
|
1335
|
+
};
|
1336
|
+
if (parts.length === 2) {
|
1337
|
+
if (contentFits) {
|
1338
|
+
cmds.push(whitespaceFlatCmd, contentFlatCmd);
|
1339
|
+
} else {
|
1340
|
+
cmds.push(whitespaceBreakCmd, contentBreakCmd);
|
1341
|
+
}
|
1342
|
+
break;
|
1343
|
+
}
|
1344
|
+
parts.splice(0, 2);
|
1345
|
+
const remainingCmd = {
|
1346
|
+
ind,
|
1347
|
+
mode,
|
1348
|
+
doc: fill(parts),
|
1349
|
+
};
|
1350
|
+
const secondContent = parts[0];
|
1351
|
+
const firstAndSecondContentFlatCmd = {
|
1352
|
+
ind,
|
1353
|
+
mode: MODE_FLAT,
|
1354
|
+
doc: [content, whitespace, secondContent],
|
1355
|
+
};
|
1356
|
+
const firstAndSecondContentFits = fits(
|
1357
|
+
firstAndSecondContentFlatCmd,
|
1358
|
+
[],
|
1359
|
+
rem,
|
1360
|
+
lineSuffix2.length > 0,
|
1361
|
+
groupModeMap,
|
1362
|
+
true,
|
1363
|
+
);
|
1364
|
+
if (firstAndSecondContentFits) {
|
1365
|
+
cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
|
1366
|
+
} else if (contentFits) {
|
1367
|
+
cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
|
1368
|
+
} else {
|
1369
|
+
cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
|
1370
|
+
}
|
1371
|
+
break;
|
1372
|
+
}
|
1373
|
+
case DOC_TYPE_IF_BREAK:
|
1374
|
+
case DOC_TYPE_INDENT_IF_BREAK: {
|
1375
|
+
const groupMode = doc2.groupId ? groupModeMap[doc2.groupId] : mode;
|
1376
|
+
if (groupMode === MODE_BREAK) {
|
1377
|
+
const breakContents =
|
1378
|
+
doc2.type === DOC_TYPE_IF_BREAK
|
1379
|
+
? doc2.breakContents
|
1380
|
+
: doc2.negate
|
1381
|
+
? doc2.contents
|
1382
|
+
: indent(doc2.contents);
|
1383
|
+
if (breakContents) {
|
1384
|
+
cmds.push({
|
1385
|
+
ind,
|
1386
|
+
mode,
|
1387
|
+
doc: breakContents,
|
1388
|
+
});
|
1389
|
+
}
|
1390
|
+
}
|
1391
|
+
if (groupMode === MODE_FLAT) {
|
1392
|
+
const flatContents =
|
1393
|
+
doc2.type === DOC_TYPE_IF_BREAK
|
1394
|
+
? doc2.flatContents
|
1395
|
+
: doc2.negate
|
1396
|
+
? indent(doc2.contents)
|
1397
|
+
: doc2.contents;
|
1398
|
+
if (flatContents) {
|
1399
|
+
cmds.push({
|
1400
|
+
ind,
|
1401
|
+
mode,
|
1402
|
+
doc: flatContents,
|
1403
|
+
});
|
1404
|
+
}
|
1405
|
+
}
|
1406
|
+
break;
|
1407
|
+
}
|
1408
|
+
case DOC_TYPE_LINE_SUFFIX:
|
1409
|
+
lineSuffix2.push({
|
1410
|
+
ind,
|
1411
|
+
mode,
|
1412
|
+
doc: doc2.contents,
|
1413
|
+
});
|
1414
|
+
break;
|
1415
|
+
case DOC_TYPE_LINE_SUFFIX_BOUNDARY:
|
1416
|
+
if (lineSuffix2.length > 0) {
|
1417
|
+
cmds.push({
|
1418
|
+
ind,
|
1419
|
+
mode,
|
1420
|
+
doc: hardlineWithoutBreakParent,
|
1421
|
+
});
|
1422
|
+
}
|
1423
|
+
break;
|
1424
|
+
case DOC_TYPE_LINE:
|
1425
|
+
switch (mode) {
|
1426
|
+
case MODE_FLAT:
|
1427
|
+
if (!doc2.hard) {
|
1428
|
+
if (!doc2.soft) {
|
1429
|
+
out.push(" ");
|
1430
|
+
pos += 1;
|
1431
|
+
}
|
1432
|
+
break;
|
1433
|
+
} else {
|
1434
|
+
shouldRemeasure = true;
|
1435
|
+
}
|
1436
|
+
case MODE_BREAK:
|
1437
|
+
if (lineSuffix2.length > 0) {
|
1438
|
+
cmds.push(
|
1439
|
+
{
|
1440
|
+
ind,
|
1441
|
+
mode,
|
1442
|
+
doc: doc2,
|
1443
|
+
},
|
1444
|
+
...lineSuffix2.reverse(),
|
1445
|
+
);
|
1446
|
+
lineSuffix2.length = 0;
|
1447
|
+
break;
|
1448
|
+
}
|
1449
|
+
if (doc2.literal) {
|
1450
|
+
if (ind.root) {
|
1451
|
+
out.push(newLine, ind.root.value);
|
1452
|
+
pos = ind.root.length;
|
1453
|
+
} else {
|
1454
|
+
out.push(newLine);
|
1455
|
+
pos = 0;
|
1456
|
+
}
|
1457
|
+
} else {
|
1458
|
+
pos -= trim2(out);
|
1459
|
+
out.push(newLine + ind.value);
|
1460
|
+
pos = ind.length;
|
1461
|
+
}
|
1462
|
+
break;
|
1463
|
+
}
|
1464
|
+
break;
|
1465
|
+
case DOC_TYPE_LABEL:
|
1466
|
+
cmds.push({
|
1467
|
+
ind,
|
1468
|
+
mode,
|
1469
|
+
doc: doc2.contents,
|
1470
|
+
});
|
1471
|
+
break;
|
1472
|
+
case DOC_TYPE_BREAK_PARENT:
|
1473
|
+
break;
|
1474
|
+
default:
|
1475
|
+
throw new invalid_doc_error_default(doc2);
|
1476
|
+
}
|
1477
|
+
if (cmds.length === 0 && lineSuffix2.length > 0) {
|
1478
|
+
cmds.push(...lineSuffix2.reverse());
|
1479
|
+
lineSuffix2.length = 0;
|
1480
|
+
}
|
1481
|
+
}
|
1482
|
+
const cursorPlaceholderIndex = out.indexOf(CURSOR_PLACEHOLDER);
|
1483
|
+
if (cursorPlaceholderIndex !== -1) {
|
1484
|
+
const otherCursorPlaceholderIndex = out.indexOf(
|
1485
|
+
CURSOR_PLACEHOLDER,
|
1486
|
+
cursorPlaceholderIndex + 1,
|
1487
|
+
);
|
1488
|
+
const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
|
1489
|
+
const aroundCursor = out
|
1490
|
+
.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex)
|
1491
|
+
.join("");
|
1492
|
+
const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
|
1493
|
+
return {
|
1494
|
+
formatted: beforeCursor + aroundCursor + afterCursor,
|
1495
|
+
cursorNodeStart: beforeCursor.length,
|
1496
|
+
cursorNodeText: aroundCursor,
|
1497
|
+
};
|
1498
|
+
}
|
1499
|
+
return {
|
1500
|
+
formatted: out.join(""),
|
1501
|
+
};
|
1502
|
+
}
|
1503
|
+
|
1504
|
+
// src/document/public.js
|
1505
|
+
var builders = {
|
1506
|
+
join,
|
1507
|
+
line,
|
1508
|
+
softline,
|
1509
|
+
hardline,
|
1510
|
+
literalline,
|
1511
|
+
group,
|
1512
|
+
conditionalGroup,
|
1513
|
+
fill,
|
1514
|
+
lineSuffix,
|
1515
|
+
lineSuffixBoundary,
|
1516
|
+
cursor,
|
1517
|
+
breakParent,
|
1518
|
+
ifBreak,
|
1519
|
+
trim,
|
1520
|
+
indent,
|
1521
|
+
indentIfBreak,
|
1522
|
+
align,
|
1523
|
+
addAlignmentToDoc,
|
1524
|
+
markAsRoot,
|
1525
|
+
dedentToRoot,
|
1526
|
+
dedent,
|
1527
|
+
hardlineWithoutBreakParent,
|
1528
|
+
literallineWithoutBreakParent,
|
1529
|
+
label,
|
1530
|
+
// TODO: Remove this in v4
|
1531
|
+
concat: (parts) => parts,
|
1532
|
+
};
|
1533
|
+
var printer = { printDocToString };
|
1534
|
+
var utils = {
|
1535
|
+
willBreak,
|
1536
|
+
traverseDoc: traverse_doc_default,
|
1537
|
+
findInDoc,
|
1538
|
+
mapDoc,
|
1539
|
+
removeLines,
|
1540
|
+
stripTrailingHardline,
|
1541
|
+
replaceEndOfLine,
|
1542
|
+
canBreak,
|
1543
|
+
};
|
1544
|
+
return __toCommonJS(public_exports);
|
1545
|
+
});
|