@ncukondo/reference-manager 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{action-menu-DuKYYovJ.js → action-menu-DmRe0mqY.js} +2 -2
- package/dist/chunks/{action-menu-DuKYYovJ.js.map → action-menu-DmRe0mqY.js.map} +1 -1
- package/dist/chunks/{index-C8U-ofi3.js → index-HNDp6ifk.js} +3300 -289
- package/dist/chunks/index-HNDp6ifk.js.map +1 -0
- package/dist/chunks/{loader-B-qMK5su.js → loader-COOFA-HF.js} +44 -11
- package/dist/chunks/loader-COOFA-HF.js.map +1 -0
- package/dist/cli/commands/edit.d.ts +46 -0
- package/dist/cli/commands/edit.d.ts.map +1 -0
- package/dist/cli/commands/index.d.ts +2 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/helpers.d.ts +4 -1
- package/dist/cli/helpers.d.ts.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/schema.d.ts +42 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/features/edit/edit-session.d.ts +26 -0
- package/dist/features/edit/edit-session.d.ts.map +1 -0
- package/dist/features/edit/editor-resolver.d.ts +9 -0
- package/dist/features/edit/editor-resolver.d.ts.map +1 -0
- package/dist/features/edit/field-transformer.d.ts +25 -0
- package/dist/features/edit/field-transformer.d.ts.map +1 -0
- package/dist/features/edit/index.d.ts +35 -0
- package/dist/features/edit/index.d.ts.map +1 -0
- package/dist/features/edit/json-serializer.d.ts +12 -0
- package/dist/features/edit/json-serializer.d.ts.map +1 -0
- package/dist/features/edit/yaml-deserializer.d.ts +10 -0
- package/dist/features/edit/yaml-deserializer.d.ts.map +1 -0
- package/dist/features/edit/yaml-serializer.d.ts +7 -0
- package/dist/features/edit/yaml-serializer.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +3 -1
- package/dist/chunks/index-C8U-ofi3.js.map +0 -1
- package/dist/chunks/loader-B-qMK5su.js.map +0 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { ZodOptional as ZodOptional$2, z } from "zod";
|
|
3
3
|
import { p as pickDefined, q as sortOrderSchema, r as paginationOptionsSchema, L as Library, F as FileWatcher, u as sortFieldSchema, v as searchSortFieldSchema } from "./file-watcher-BhIAeC21.js";
|
|
4
|
+
import * as fs from "node:fs";
|
|
4
5
|
import { promises, existsSync, mkdtempSync, writeFileSync, readFileSync } from "node:fs";
|
|
5
6
|
import * as os from "node:os";
|
|
6
7
|
import { tmpdir } from "node:os";
|
|
7
8
|
import * as path from "node:path";
|
|
8
9
|
import { join, extname } from "node:path";
|
|
10
|
+
import { spawnSync, spawn } from "node:child_process";
|
|
9
11
|
import { mkdir, unlink, rename, copyFile, rm, readFile } from "node:fs/promises";
|
|
10
12
|
import { u as updateReference, B as BUILTIN_STYLES, s as startServerWithFileWatcher, g as getFulltextAttachmentTypes } from "./index-Az8CHxm3.js";
|
|
11
|
-
import { o as openWithSystemApp, l as loadConfig } from "./loader-
|
|
13
|
+
import { o as openWithSystemApp, l as loadConfig } from "./loader-COOFA-HF.js";
|
|
12
14
|
import "@citation-js/core";
|
|
13
15
|
import "@citation-js/plugin-csl";
|
|
14
16
|
import process$1, { stdin, stdout } from "node:process";
|
|
15
|
-
import { spawn } from "node:child_process";
|
|
16
17
|
import { serve } from "@hono/node-server";
|
|
17
18
|
const name = "@ncukondo/reference-manager";
|
|
18
|
-
const version$1 = "0.
|
|
19
|
+
const version$1 = "0.12.0";
|
|
19
20
|
const description$1 = "A local reference management tool using CSL-JSON as the single source of truth";
|
|
20
21
|
const packageJson = {
|
|
21
22
|
name,
|
|
@@ -258,8 +259,8 @@ async function validateOptions$2(options) {
|
|
|
258
259
|
throw new Error(`Invalid format '${options.format}'. Must be one of: text, html, rtf`);
|
|
259
260
|
}
|
|
260
261
|
if (options.cslFile) {
|
|
261
|
-
const
|
|
262
|
-
if (!
|
|
262
|
+
const fs2 = await import("node:fs");
|
|
263
|
+
if (!fs2.existsSync(options.cslFile)) {
|
|
263
264
|
throw new Error(`CSL file '${options.cslFile}' not found`);
|
|
264
265
|
}
|
|
265
266
|
}
|
|
@@ -308,6 +309,2978 @@ function getCiteExitCode(result) {
|
|
|
308
309
|
}
|
|
309
310
|
return 0;
|
|
310
311
|
}
|
|
312
|
+
function createTempFile(content, format2) {
|
|
313
|
+
const timestamp2 = Date.now();
|
|
314
|
+
const extension = format2 === "yaml" ? ".yaml" : ".json";
|
|
315
|
+
const fileName = `ref-edit-${timestamp2}${extension}`;
|
|
316
|
+
const filePath = path.join(os.tmpdir(), fileName);
|
|
317
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
318
|
+
return filePath;
|
|
319
|
+
}
|
|
320
|
+
function openEditor(editor, filePath) {
|
|
321
|
+
const result = spawnSync(editor, [filePath], {
|
|
322
|
+
stdio: "inherit",
|
|
323
|
+
shell: true
|
|
324
|
+
});
|
|
325
|
+
return result.status ?? 1;
|
|
326
|
+
}
|
|
327
|
+
function readTempFile(filePath) {
|
|
328
|
+
return fs.readFileSync(filePath, "utf-8");
|
|
329
|
+
}
|
|
330
|
+
function deleteTempFile(filePath) {
|
|
331
|
+
try {
|
|
332
|
+
fs.unlinkSync(filePath);
|
|
333
|
+
} catch {
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
function datePartsToIso(dateParts) {
|
|
337
|
+
if (!dateParts || dateParts.length === 0 || !dateParts[0]) {
|
|
338
|
+
return "";
|
|
339
|
+
}
|
|
340
|
+
const firstPart = dateParts[0];
|
|
341
|
+
const year = firstPart[0];
|
|
342
|
+
const month = firstPart[1];
|
|
343
|
+
const day = firstPart[2];
|
|
344
|
+
const parts = [String(year)];
|
|
345
|
+
if (month !== void 0) {
|
|
346
|
+
parts.push(String(month).padStart(2, "0"));
|
|
347
|
+
}
|
|
348
|
+
if (day !== void 0) {
|
|
349
|
+
parts.push(String(day).padStart(2, "0"));
|
|
350
|
+
}
|
|
351
|
+
return parts.join("-");
|
|
352
|
+
}
|
|
353
|
+
function isoToDateParts(isoDate) {
|
|
354
|
+
const parts = isoDate.split("-").map(Number);
|
|
355
|
+
return [parts];
|
|
356
|
+
}
|
|
357
|
+
function transformDateToEdit(date2) {
|
|
358
|
+
if (!date2 || !date2["date-parts"]) {
|
|
359
|
+
return void 0;
|
|
360
|
+
}
|
|
361
|
+
return datePartsToIso(date2["date-parts"]);
|
|
362
|
+
}
|
|
363
|
+
function transformDateFromEdit(isoDate) {
|
|
364
|
+
return {
|
|
365
|
+
"date-parts": isoToDateParts(isoDate)
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const PROTECTED_FIELDS$3 = ["uuid", "created_at", "timestamp", "fulltext"];
|
|
369
|
+
const ISO_DATE_REGEX$1 = /^\d{4}(-\d{2})?(-\d{2})?$/;
|
|
370
|
+
function extractProtectedFields(custom2) {
|
|
371
|
+
if (!custom2) return {};
|
|
372
|
+
const result = {};
|
|
373
|
+
if (custom2.uuid) result.uuid = custom2.uuid;
|
|
374
|
+
if (custom2.created_at) result.created_at = custom2.created_at;
|
|
375
|
+
if (custom2.timestamp) result.timestamp = custom2.timestamp;
|
|
376
|
+
if (custom2.fulltext) {
|
|
377
|
+
result.fulltext = custom2.fulltext;
|
|
378
|
+
}
|
|
379
|
+
return result;
|
|
380
|
+
}
|
|
381
|
+
function filterCustomFields$1(custom2) {
|
|
382
|
+
const filtered = {};
|
|
383
|
+
for (const [key, value] of Object.entries(custom2)) {
|
|
384
|
+
if (!PROTECTED_FIELDS$3.includes(key)) {
|
|
385
|
+
filtered[key] = value;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return Object.keys(filtered).length > 0 ? filtered : null;
|
|
389
|
+
}
|
|
390
|
+
function transformItemForJson(item) {
|
|
391
|
+
const result = {};
|
|
392
|
+
const protectedFields = extractProtectedFields(item.custom);
|
|
393
|
+
if (Object.keys(protectedFields).length > 0) {
|
|
394
|
+
result._protected = protectedFields;
|
|
395
|
+
}
|
|
396
|
+
for (const [key, value] of Object.entries(item)) {
|
|
397
|
+
if (key === "custom") {
|
|
398
|
+
const filtered = filterCustomFields$1(value);
|
|
399
|
+
if (filtered) {
|
|
400
|
+
result.custom = filtered;
|
|
401
|
+
}
|
|
402
|
+
} else if (key === "issued" || key === "accessed") {
|
|
403
|
+
const dateValue = value;
|
|
404
|
+
const isoDate = transformDateToEdit(dateValue);
|
|
405
|
+
if (isoDate) {
|
|
406
|
+
result[key] = isoDate;
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
result[key] = value;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
return result;
|
|
413
|
+
}
|
|
414
|
+
function serializeToJson(items2) {
|
|
415
|
+
const transformed = items2.map(transformItemForJson);
|
|
416
|
+
return JSON.stringify(transformed, null, 2);
|
|
417
|
+
}
|
|
418
|
+
function transformDateFields$1(item) {
|
|
419
|
+
const result = { ...item };
|
|
420
|
+
for (const dateField of ["issued", "accessed"]) {
|
|
421
|
+
const value = result[dateField];
|
|
422
|
+
if (typeof value === "string" && ISO_DATE_REGEX$1.test(value)) {
|
|
423
|
+
result[dateField] = transformDateFromEdit(value);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return result;
|
|
427
|
+
}
|
|
428
|
+
function deserializeFromJson(jsonContent) {
|
|
429
|
+
const parsed = JSON.parse(jsonContent);
|
|
430
|
+
if (!Array.isArray(parsed)) {
|
|
431
|
+
throw new Error("Expected JSON array");
|
|
432
|
+
}
|
|
433
|
+
return parsed.map((item) => {
|
|
434
|
+
const protectedData = item._protected;
|
|
435
|
+
const uuid2 = protectedData?.uuid;
|
|
436
|
+
const { _protected, ...rest } = item;
|
|
437
|
+
const transformed = transformDateFields$1(rest);
|
|
438
|
+
if (uuid2) {
|
|
439
|
+
transformed._extractedUuid = uuid2;
|
|
440
|
+
}
|
|
441
|
+
return transformed;
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
445
|
+
function isNothing(subject) {
|
|
446
|
+
return typeof subject === "undefined" || subject === null;
|
|
447
|
+
}
|
|
448
|
+
function isObject$1(subject) {
|
|
449
|
+
return typeof subject === "object" && subject !== null;
|
|
450
|
+
}
|
|
451
|
+
function toArray(sequence) {
|
|
452
|
+
if (Array.isArray(sequence)) return sequence;
|
|
453
|
+
else if (isNothing(sequence)) return [];
|
|
454
|
+
return [sequence];
|
|
455
|
+
}
|
|
456
|
+
function extend$1(target, source) {
|
|
457
|
+
var index, length, key, sourceKeys;
|
|
458
|
+
if (source) {
|
|
459
|
+
sourceKeys = Object.keys(source);
|
|
460
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
461
|
+
key = sourceKeys[index];
|
|
462
|
+
target[key] = source[key];
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return target;
|
|
466
|
+
}
|
|
467
|
+
function repeat(string2, count) {
|
|
468
|
+
var result = "", cycle;
|
|
469
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
470
|
+
result += string2;
|
|
471
|
+
}
|
|
472
|
+
return result;
|
|
473
|
+
}
|
|
474
|
+
function isNegativeZero(number2) {
|
|
475
|
+
return number2 === 0 && Number.NEGATIVE_INFINITY === 1 / number2;
|
|
476
|
+
}
|
|
477
|
+
var isNothing_1 = isNothing;
|
|
478
|
+
var isObject_1 = isObject$1;
|
|
479
|
+
var toArray_1 = toArray;
|
|
480
|
+
var repeat_1 = repeat;
|
|
481
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
482
|
+
var extend_1 = extend$1;
|
|
483
|
+
var common = {
|
|
484
|
+
isNothing: isNothing_1,
|
|
485
|
+
isObject: isObject_1,
|
|
486
|
+
toArray: toArray_1,
|
|
487
|
+
repeat: repeat_1,
|
|
488
|
+
isNegativeZero: isNegativeZero_1,
|
|
489
|
+
extend: extend_1
|
|
490
|
+
};
|
|
491
|
+
function formatError$1(exception2, compact) {
|
|
492
|
+
var where = "", message = exception2.reason || "(unknown reason)";
|
|
493
|
+
if (!exception2.mark) return message;
|
|
494
|
+
if (exception2.mark.name) {
|
|
495
|
+
where += 'in "' + exception2.mark.name + '" ';
|
|
496
|
+
}
|
|
497
|
+
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
498
|
+
if (!compact && exception2.mark.snippet) {
|
|
499
|
+
where += "\n\n" + exception2.mark.snippet;
|
|
500
|
+
}
|
|
501
|
+
return message + " " + where;
|
|
502
|
+
}
|
|
503
|
+
function YAMLException$1(reason, mark) {
|
|
504
|
+
Error.call(this);
|
|
505
|
+
this.name = "YAMLException";
|
|
506
|
+
this.reason = reason;
|
|
507
|
+
this.mark = mark;
|
|
508
|
+
this.message = formatError$1(this, false);
|
|
509
|
+
if (Error.captureStackTrace) {
|
|
510
|
+
Error.captureStackTrace(this, this.constructor);
|
|
511
|
+
} else {
|
|
512
|
+
this.stack = new Error().stack || "";
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
516
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
517
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
518
|
+
return this.name + ": " + formatError$1(this, compact);
|
|
519
|
+
};
|
|
520
|
+
var exception = YAMLException$1;
|
|
521
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
522
|
+
var head = "";
|
|
523
|
+
var tail = "";
|
|
524
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
525
|
+
if (position - lineStart > maxHalfLength) {
|
|
526
|
+
head = " ... ";
|
|
527
|
+
lineStart = position - maxHalfLength + head.length;
|
|
528
|
+
}
|
|
529
|
+
if (lineEnd - position > maxHalfLength) {
|
|
530
|
+
tail = " ...";
|
|
531
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
532
|
+
}
|
|
533
|
+
return {
|
|
534
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
535
|
+
pos: position - lineStart + head.length
|
|
536
|
+
// relative position
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function padStart(string2, max) {
|
|
540
|
+
return common.repeat(" ", max - string2.length) + string2;
|
|
541
|
+
}
|
|
542
|
+
function makeSnippet(mark, options) {
|
|
543
|
+
options = Object.create(options || null);
|
|
544
|
+
if (!mark.buffer) return null;
|
|
545
|
+
if (!options.maxLength) options.maxLength = 79;
|
|
546
|
+
if (typeof options.indent !== "number") options.indent = 1;
|
|
547
|
+
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
548
|
+
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
549
|
+
var re = /\r?\n|\r|\0/g;
|
|
550
|
+
var lineStarts = [0];
|
|
551
|
+
var lineEnds = [];
|
|
552
|
+
var match;
|
|
553
|
+
var foundLineNo = -1;
|
|
554
|
+
while (match = re.exec(mark.buffer)) {
|
|
555
|
+
lineEnds.push(match.index);
|
|
556
|
+
lineStarts.push(match.index + match[0].length);
|
|
557
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
558
|
+
foundLineNo = lineStarts.length - 2;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
562
|
+
var result = "", i, line;
|
|
563
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
564
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
565
|
+
for (i = 1; i <= options.linesBefore; i++) {
|
|
566
|
+
if (foundLineNo - i < 0) break;
|
|
567
|
+
line = getLine(
|
|
568
|
+
mark.buffer,
|
|
569
|
+
lineStarts[foundLineNo - i],
|
|
570
|
+
lineEnds[foundLineNo - i],
|
|
571
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
572
|
+
maxLineLength
|
|
573
|
+
);
|
|
574
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
575
|
+
}
|
|
576
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
577
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
578
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
579
|
+
for (i = 1; i <= options.linesAfter; i++) {
|
|
580
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
581
|
+
line = getLine(
|
|
582
|
+
mark.buffer,
|
|
583
|
+
lineStarts[foundLineNo + i],
|
|
584
|
+
lineEnds[foundLineNo + i],
|
|
585
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
586
|
+
maxLineLength
|
|
587
|
+
);
|
|
588
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
589
|
+
}
|
|
590
|
+
return result.replace(/\n$/, "");
|
|
591
|
+
}
|
|
592
|
+
var snippet = makeSnippet;
|
|
593
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
594
|
+
"kind",
|
|
595
|
+
"multi",
|
|
596
|
+
"resolve",
|
|
597
|
+
"construct",
|
|
598
|
+
"instanceOf",
|
|
599
|
+
"predicate",
|
|
600
|
+
"represent",
|
|
601
|
+
"representName",
|
|
602
|
+
"defaultStyle",
|
|
603
|
+
"styleAliases"
|
|
604
|
+
];
|
|
605
|
+
var YAML_NODE_KINDS = [
|
|
606
|
+
"scalar",
|
|
607
|
+
"sequence",
|
|
608
|
+
"mapping"
|
|
609
|
+
];
|
|
610
|
+
function compileStyleAliases(map2) {
|
|
611
|
+
var result = {};
|
|
612
|
+
if (map2 !== null) {
|
|
613
|
+
Object.keys(map2).forEach(function(style) {
|
|
614
|
+
map2[style].forEach(function(alias) {
|
|
615
|
+
result[String(alias)] = style;
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
return result;
|
|
620
|
+
}
|
|
621
|
+
function Type$1(tag, options) {
|
|
622
|
+
options = options || {};
|
|
623
|
+
Object.keys(options).forEach(function(name2) {
|
|
624
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name2) === -1) {
|
|
625
|
+
throw new exception('Unknown option "' + name2 + '" is met in definition of "' + tag + '" YAML type.');
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
this.options = options;
|
|
629
|
+
this.tag = tag;
|
|
630
|
+
this.kind = options["kind"] || null;
|
|
631
|
+
this.resolve = options["resolve"] || function() {
|
|
632
|
+
return true;
|
|
633
|
+
};
|
|
634
|
+
this.construct = options["construct"] || function(data) {
|
|
635
|
+
return data;
|
|
636
|
+
};
|
|
637
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
638
|
+
this.predicate = options["predicate"] || null;
|
|
639
|
+
this.represent = options["represent"] || null;
|
|
640
|
+
this.representName = options["representName"] || null;
|
|
641
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
642
|
+
this.multi = options["multi"] || false;
|
|
643
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
644
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
645
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
var type$2 = Type$1;
|
|
649
|
+
function compileList(schema2, name2) {
|
|
650
|
+
var result = [];
|
|
651
|
+
schema2[name2].forEach(function(currentType) {
|
|
652
|
+
var newIndex = result.length;
|
|
653
|
+
result.forEach(function(previousType, previousIndex) {
|
|
654
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
655
|
+
newIndex = previousIndex;
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
result[newIndex] = currentType;
|
|
659
|
+
});
|
|
660
|
+
return result;
|
|
661
|
+
}
|
|
662
|
+
function compileMap() {
|
|
663
|
+
var result = {
|
|
664
|
+
scalar: {},
|
|
665
|
+
sequence: {},
|
|
666
|
+
mapping: {},
|
|
667
|
+
fallback: {},
|
|
668
|
+
multi: {
|
|
669
|
+
scalar: [],
|
|
670
|
+
sequence: [],
|
|
671
|
+
mapping: [],
|
|
672
|
+
fallback: []
|
|
673
|
+
}
|
|
674
|
+
}, index, length;
|
|
675
|
+
function collectType(type2) {
|
|
676
|
+
if (type2.multi) {
|
|
677
|
+
result.multi[type2.kind].push(type2);
|
|
678
|
+
result.multi["fallback"].push(type2);
|
|
679
|
+
} else {
|
|
680
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
684
|
+
arguments[index].forEach(collectType);
|
|
685
|
+
}
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
function Schema$1(definition) {
|
|
689
|
+
return this.extend(definition);
|
|
690
|
+
}
|
|
691
|
+
Schema$1.prototype.extend = function extend(definition) {
|
|
692
|
+
var implicit = [];
|
|
693
|
+
var explicit = [];
|
|
694
|
+
if (definition instanceof type$2) {
|
|
695
|
+
explicit.push(definition);
|
|
696
|
+
} else if (Array.isArray(definition)) {
|
|
697
|
+
explicit = explicit.concat(definition);
|
|
698
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
699
|
+
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
700
|
+
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
701
|
+
} else {
|
|
702
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
703
|
+
}
|
|
704
|
+
implicit.forEach(function(type$12) {
|
|
705
|
+
if (!(type$12 instanceof type$2)) {
|
|
706
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
707
|
+
}
|
|
708
|
+
if (type$12.loadKind && type$12.loadKind !== "scalar") {
|
|
709
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
710
|
+
}
|
|
711
|
+
if (type$12.multi) {
|
|
712
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
explicit.forEach(function(type$12) {
|
|
716
|
+
if (!(type$12 instanceof type$2)) {
|
|
717
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
var result = Object.create(Schema$1.prototype);
|
|
721
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
722
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
723
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
724
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
725
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
726
|
+
return result;
|
|
727
|
+
};
|
|
728
|
+
var schema$3 = Schema$1;
|
|
729
|
+
var str = new type$2("tag:yaml.org,2002:str", {
|
|
730
|
+
kind: "scalar",
|
|
731
|
+
construct: function(data) {
|
|
732
|
+
return data !== null ? data : "";
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
var seq$1 = new type$2("tag:yaml.org,2002:seq", {
|
|
736
|
+
kind: "sequence",
|
|
737
|
+
construct: function(data) {
|
|
738
|
+
return data !== null ? data : [];
|
|
739
|
+
}
|
|
740
|
+
});
|
|
741
|
+
var map$1 = new type$2("tag:yaml.org,2002:map", {
|
|
742
|
+
kind: "mapping",
|
|
743
|
+
construct: function(data) {
|
|
744
|
+
return data !== null ? data : {};
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
var failsafe = new schema$3({
|
|
748
|
+
explicit: [
|
|
749
|
+
str,
|
|
750
|
+
seq$1,
|
|
751
|
+
map$1
|
|
752
|
+
]
|
|
753
|
+
});
|
|
754
|
+
function resolveYamlNull(data) {
|
|
755
|
+
if (data === null) return true;
|
|
756
|
+
var max = data.length;
|
|
757
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
758
|
+
}
|
|
759
|
+
function constructYamlNull() {
|
|
760
|
+
return null;
|
|
761
|
+
}
|
|
762
|
+
function isNull(object2) {
|
|
763
|
+
return object2 === null;
|
|
764
|
+
}
|
|
765
|
+
var _null$3 = new type$2("tag:yaml.org,2002:null", {
|
|
766
|
+
kind: "scalar",
|
|
767
|
+
resolve: resolveYamlNull,
|
|
768
|
+
construct: constructYamlNull,
|
|
769
|
+
predicate: isNull,
|
|
770
|
+
represent: {
|
|
771
|
+
canonical: function() {
|
|
772
|
+
return "~";
|
|
773
|
+
},
|
|
774
|
+
lowercase: function() {
|
|
775
|
+
return "null";
|
|
776
|
+
},
|
|
777
|
+
uppercase: function() {
|
|
778
|
+
return "NULL";
|
|
779
|
+
},
|
|
780
|
+
camelcase: function() {
|
|
781
|
+
return "Null";
|
|
782
|
+
},
|
|
783
|
+
empty: function() {
|
|
784
|
+
return "";
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
defaultStyle: "lowercase"
|
|
788
|
+
});
|
|
789
|
+
function resolveYamlBoolean(data) {
|
|
790
|
+
if (data === null) return false;
|
|
791
|
+
var max = data.length;
|
|
792
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
793
|
+
}
|
|
794
|
+
function constructYamlBoolean(data) {
|
|
795
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
796
|
+
}
|
|
797
|
+
function isBoolean(object2) {
|
|
798
|
+
return Object.prototype.toString.call(object2) === "[object Boolean]";
|
|
799
|
+
}
|
|
800
|
+
var bool = new type$2("tag:yaml.org,2002:bool", {
|
|
801
|
+
kind: "scalar",
|
|
802
|
+
resolve: resolveYamlBoolean,
|
|
803
|
+
construct: constructYamlBoolean,
|
|
804
|
+
predicate: isBoolean,
|
|
805
|
+
represent: {
|
|
806
|
+
lowercase: function(object2) {
|
|
807
|
+
return object2 ? "true" : "false";
|
|
808
|
+
},
|
|
809
|
+
uppercase: function(object2) {
|
|
810
|
+
return object2 ? "TRUE" : "FALSE";
|
|
811
|
+
},
|
|
812
|
+
camelcase: function(object2) {
|
|
813
|
+
return object2 ? "True" : "False";
|
|
814
|
+
}
|
|
815
|
+
},
|
|
816
|
+
defaultStyle: "lowercase"
|
|
817
|
+
});
|
|
818
|
+
function isHexCode(c) {
|
|
819
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
820
|
+
}
|
|
821
|
+
function isOctCode(c) {
|
|
822
|
+
return 48 <= c && c <= 55;
|
|
823
|
+
}
|
|
824
|
+
function isDecCode(c) {
|
|
825
|
+
return 48 <= c && c <= 57;
|
|
826
|
+
}
|
|
827
|
+
function resolveYamlInteger(data) {
|
|
828
|
+
if (data === null) return false;
|
|
829
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
830
|
+
if (!max) return false;
|
|
831
|
+
ch = data[index];
|
|
832
|
+
if (ch === "-" || ch === "+") {
|
|
833
|
+
ch = data[++index];
|
|
834
|
+
}
|
|
835
|
+
if (ch === "0") {
|
|
836
|
+
if (index + 1 === max) return true;
|
|
837
|
+
ch = data[++index];
|
|
838
|
+
if (ch === "b") {
|
|
839
|
+
index++;
|
|
840
|
+
for (; index < max; index++) {
|
|
841
|
+
ch = data[index];
|
|
842
|
+
if (ch === "_") continue;
|
|
843
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
844
|
+
hasDigits = true;
|
|
845
|
+
}
|
|
846
|
+
return hasDigits && ch !== "_";
|
|
847
|
+
}
|
|
848
|
+
if (ch === "x") {
|
|
849
|
+
index++;
|
|
850
|
+
for (; index < max; index++) {
|
|
851
|
+
ch = data[index];
|
|
852
|
+
if (ch === "_") continue;
|
|
853
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
854
|
+
hasDigits = true;
|
|
855
|
+
}
|
|
856
|
+
return hasDigits && ch !== "_";
|
|
857
|
+
}
|
|
858
|
+
if (ch === "o") {
|
|
859
|
+
index++;
|
|
860
|
+
for (; index < max; index++) {
|
|
861
|
+
ch = data[index];
|
|
862
|
+
if (ch === "_") continue;
|
|
863
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
864
|
+
hasDigits = true;
|
|
865
|
+
}
|
|
866
|
+
return hasDigits && ch !== "_";
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
if (ch === "_") return false;
|
|
870
|
+
for (; index < max; index++) {
|
|
871
|
+
ch = data[index];
|
|
872
|
+
if (ch === "_") continue;
|
|
873
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
hasDigits = true;
|
|
877
|
+
}
|
|
878
|
+
if (!hasDigits || ch === "_") return false;
|
|
879
|
+
return true;
|
|
880
|
+
}
|
|
881
|
+
function constructYamlInteger(data) {
|
|
882
|
+
var value = data, sign = 1, ch;
|
|
883
|
+
if (value.indexOf("_") !== -1) {
|
|
884
|
+
value = value.replace(/_/g, "");
|
|
885
|
+
}
|
|
886
|
+
ch = value[0];
|
|
887
|
+
if (ch === "-" || ch === "+") {
|
|
888
|
+
if (ch === "-") sign = -1;
|
|
889
|
+
value = value.slice(1);
|
|
890
|
+
ch = value[0];
|
|
891
|
+
}
|
|
892
|
+
if (value === "0") return 0;
|
|
893
|
+
if (ch === "0") {
|
|
894
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
895
|
+
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
896
|
+
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
897
|
+
}
|
|
898
|
+
return sign * parseInt(value, 10);
|
|
899
|
+
}
|
|
900
|
+
function isInteger(object2) {
|
|
901
|
+
return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 === 0 && !common.isNegativeZero(object2));
|
|
902
|
+
}
|
|
903
|
+
var int$3 = new type$2("tag:yaml.org,2002:int", {
|
|
904
|
+
kind: "scalar",
|
|
905
|
+
resolve: resolveYamlInteger,
|
|
906
|
+
construct: constructYamlInteger,
|
|
907
|
+
predicate: isInteger,
|
|
908
|
+
represent: {
|
|
909
|
+
binary: function(obj) {
|
|
910
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
911
|
+
},
|
|
912
|
+
octal: function(obj) {
|
|
913
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
914
|
+
},
|
|
915
|
+
decimal: function(obj) {
|
|
916
|
+
return obj.toString(10);
|
|
917
|
+
},
|
|
918
|
+
/* eslint-disable max-len */
|
|
919
|
+
hexadecimal: function(obj) {
|
|
920
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
921
|
+
}
|
|
922
|
+
},
|
|
923
|
+
defaultStyle: "decimal",
|
|
924
|
+
styleAliases: {
|
|
925
|
+
binary: [2, "bin"],
|
|
926
|
+
octal: [8, "oct"],
|
|
927
|
+
decimal: [10, "dec"],
|
|
928
|
+
hexadecimal: [16, "hex"]
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
932
|
+
// 2.5e4, 2.5 and integers
|
|
933
|
+
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
934
|
+
);
|
|
935
|
+
function resolveYamlFloat(data) {
|
|
936
|
+
if (data === null) return false;
|
|
937
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
938
|
+
// Probably should update regexp & check speed
|
|
939
|
+
data[data.length - 1] === "_") {
|
|
940
|
+
return false;
|
|
941
|
+
}
|
|
942
|
+
return true;
|
|
943
|
+
}
|
|
944
|
+
function constructYamlFloat(data) {
|
|
945
|
+
var value, sign;
|
|
946
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
947
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
948
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
949
|
+
value = value.slice(1);
|
|
950
|
+
}
|
|
951
|
+
if (value === ".inf") {
|
|
952
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
953
|
+
} else if (value === ".nan") {
|
|
954
|
+
return NaN;
|
|
955
|
+
}
|
|
956
|
+
return sign * parseFloat(value, 10);
|
|
957
|
+
}
|
|
958
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
959
|
+
function representYamlFloat(object2, style) {
|
|
960
|
+
var res;
|
|
961
|
+
if (isNaN(object2)) {
|
|
962
|
+
switch (style) {
|
|
963
|
+
case "lowercase":
|
|
964
|
+
return ".nan";
|
|
965
|
+
case "uppercase":
|
|
966
|
+
return ".NAN";
|
|
967
|
+
case "camelcase":
|
|
968
|
+
return ".NaN";
|
|
969
|
+
}
|
|
970
|
+
} else if (Number.POSITIVE_INFINITY === object2) {
|
|
971
|
+
switch (style) {
|
|
972
|
+
case "lowercase":
|
|
973
|
+
return ".inf";
|
|
974
|
+
case "uppercase":
|
|
975
|
+
return ".INF";
|
|
976
|
+
case "camelcase":
|
|
977
|
+
return ".Inf";
|
|
978
|
+
}
|
|
979
|
+
} else if (Number.NEGATIVE_INFINITY === object2) {
|
|
980
|
+
switch (style) {
|
|
981
|
+
case "lowercase":
|
|
982
|
+
return "-.inf";
|
|
983
|
+
case "uppercase":
|
|
984
|
+
return "-.INF";
|
|
985
|
+
case "camelcase":
|
|
986
|
+
return "-.Inf";
|
|
987
|
+
}
|
|
988
|
+
} else if (common.isNegativeZero(object2)) {
|
|
989
|
+
return "-0.0";
|
|
990
|
+
}
|
|
991
|
+
res = object2.toString(10);
|
|
992
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
993
|
+
}
|
|
994
|
+
function isFloat(object2) {
|
|
995
|
+
return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 !== 0 || common.isNegativeZero(object2));
|
|
996
|
+
}
|
|
997
|
+
var float$2 = new type$2("tag:yaml.org,2002:float", {
|
|
998
|
+
kind: "scalar",
|
|
999
|
+
resolve: resolveYamlFloat,
|
|
1000
|
+
construct: constructYamlFloat,
|
|
1001
|
+
predicate: isFloat,
|
|
1002
|
+
represent: representYamlFloat,
|
|
1003
|
+
defaultStyle: "lowercase"
|
|
1004
|
+
});
|
|
1005
|
+
var json = failsafe.extend({
|
|
1006
|
+
implicit: [
|
|
1007
|
+
_null$3,
|
|
1008
|
+
bool,
|
|
1009
|
+
int$3,
|
|
1010
|
+
float$2
|
|
1011
|
+
]
|
|
1012
|
+
});
|
|
1013
|
+
var core$2 = json;
|
|
1014
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
1015
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
1016
|
+
);
|
|
1017
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
1018
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
|
|
1019
|
+
);
|
|
1020
|
+
function resolveYamlTimestamp(data) {
|
|
1021
|
+
if (data === null) return false;
|
|
1022
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
1023
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
1024
|
+
return false;
|
|
1025
|
+
}
|
|
1026
|
+
function constructYamlTimestamp(data) {
|
|
1027
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date2;
|
|
1028
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
1029
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
1030
|
+
if (match === null) throw new Error("Date resolve error");
|
|
1031
|
+
year = +match[1];
|
|
1032
|
+
month = +match[2] - 1;
|
|
1033
|
+
day = +match[3];
|
|
1034
|
+
if (!match[4]) {
|
|
1035
|
+
return new Date(Date.UTC(year, month, day));
|
|
1036
|
+
}
|
|
1037
|
+
hour = +match[4];
|
|
1038
|
+
minute = +match[5];
|
|
1039
|
+
second = +match[6];
|
|
1040
|
+
if (match[7]) {
|
|
1041
|
+
fraction = match[7].slice(0, 3);
|
|
1042
|
+
while (fraction.length < 3) {
|
|
1043
|
+
fraction += "0";
|
|
1044
|
+
}
|
|
1045
|
+
fraction = +fraction;
|
|
1046
|
+
}
|
|
1047
|
+
if (match[9]) {
|
|
1048
|
+
tz_hour = +match[10];
|
|
1049
|
+
tz_minute = +(match[11] || 0);
|
|
1050
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
1051
|
+
if (match[9] === "-") delta = -delta;
|
|
1052
|
+
}
|
|
1053
|
+
date2 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
1054
|
+
if (delta) date2.setTime(date2.getTime() - delta);
|
|
1055
|
+
return date2;
|
|
1056
|
+
}
|
|
1057
|
+
function representYamlTimestamp(object2) {
|
|
1058
|
+
return object2.toISOString();
|
|
1059
|
+
}
|
|
1060
|
+
var timestamp$1 = new type$2("tag:yaml.org,2002:timestamp", {
|
|
1061
|
+
kind: "scalar",
|
|
1062
|
+
resolve: resolveYamlTimestamp,
|
|
1063
|
+
construct: constructYamlTimestamp,
|
|
1064
|
+
instanceOf: Date,
|
|
1065
|
+
represent: representYamlTimestamp
|
|
1066
|
+
});
|
|
1067
|
+
function resolveYamlMerge(data) {
|
|
1068
|
+
return data === "<<" || data === null;
|
|
1069
|
+
}
|
|
1070
|
+
var merge$2 = new type$2("tag:yaml.org,2002:merge", {
|
|
1071
|
+
kind: "scalar",
|
|
1072
|
+
resolve: resolveYamlMerge
|
|
1073
|
+
});
|
|
1074
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
1075
|
+
function resolveYamlBinary(data) {
|
|
1076
|
+
if (data === null) return false;
|
|
1077
|
+
var code2, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
1078
|
+
for (idx = 0; idx < max; idx++) {
|
|
1079
|
+
code2 = map2.indexOf(data.charAt(idx));
|
|
1080
|
+
if (code2 > 64) continue;
|
|
1081
|
+
if (code2 < 0) return false;
|
|
1082
|
+
bitlen += 6;
|
|
1083
|
+
}
|
|
1084
|
+
return bitlen % 8 === 0;
|
|
1085
|
+
}
|
|
1086
|
+
function constructYamlBinary(data) {
|
|
1087
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
1088
|
+
for (idx = 0; idx < max; idx++) {
|
|
1089
|
+
if (idx % 4 === 0 && idx) {
|
|
1090
|
+
result.push(bits >> 16 & 255);
|
|
1091
|
+
result.push(bits >> 8 & 255);
|
|
1092
|
+
result.push(bits & 255);
|
|
1093
|
+
}
|
|
1094
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
1095
|
+
}
|
|
1096
|
+
tailbits = max % 4 * 6;
|
|
1097
|
+
if (tailbits === 0) {
|
|
1098
|
+
result.push(bits >> 16 & 255);
|
|
1099
|
+
result.push(bits >> 8 & 255);
|
|
1100
|
+
result.push(bits & 255);
|
|
1101
|
+
} else if (tailbits === 18) {
|
|
1102
|
+
result.push(bits >> 10 & 255);
|
|
1103
|
+
result.push(bits >> 2 & 255);
|
|
1104
|
+
} else if (tailbits === 12) {
|
|
1105
|
+
result.push(bits >> 4 & 255);
|
|
1106
|
+
}
|
|
1107
|
+
return new Uint8Array(result);
|
|
1108
|
+
}
|
|
1109
|
+
function representYamlBinary(object2) {
|
|
1110
|
+
var result = "", bits = 0, idx, tail, max = object2.length, map2 = BASE64_MAP;
|
|
1111
|
+
for (idx = 0; idx < max; idx++) {
|
|
1112
|
+
if (idx % 3 === 0 && idx) {
|
|
1113
|
+
result += map2[bits >> 18 & 63];
|
|
1114
|
+
result += map2[bits >> 12 & 63];
|
|
1115
|
+
result += map2[bits >> 6 & 63];
|
|
1116
|
+
result += map2[bits & 63];
|
|
1117
|
+
}
|
|
1118
|
+
bits = (bits << 8) + object2[idx];
|
|
1119
|
+
}
|
|
1120
|
+
tail = max % 3;
|
|
1121
|
+
if (tail === 0) {
|
|
1122
|
+
result += map2[bits >> 18 & 63];
|
|
1123
|
+
result += map2[bits >> 12 & 63];
|
|
1124
|
+
result += map2[bits >> 6 & 63];
|
|
1125
|
+
result += map2[bits & 63];
|
|
1126
|
+
} else if (tail === 2) {
|
|
1127
|
+
result += map2[bits >> 10 & 63];
|
|
1128
|
+
result += map2[bits >> 4 & 63];
|
|
1129
|
+
result += map2[bits << 2 & 63];
|
|
1130
|
+
result += map2[64];
|
|
1131
|
+
} else if (tail === 1) {
|
|
1132
|
+
result += map2[bits >> 2 & 63];
|
|
1133
|
+
result += map2[bits << 4 & 63];
|
|
1134
|
+
result += map2[64];
|
|
1135
|
+
result += map2[64];
|
|
1136
|
+
}
|
|
1137
|
+
return result;
|
|
1138
|
+
}
|
|
1139
|
+
function isBinary(obj) {
|
|
1140
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
1141
|
+
}
|
|
1142
|
+
var binary$1 = new type$2("tag:yaml.org,2002:binary", {
|
|
1143
|
+
kind: "scalar",
|
|
1144
|
+
resolve: resolveYamlBinary,
|
|
1145
|
+
construct: constructYamlBinary,
|
|
1146
|
+
predicate: isBinary,
|
|
1147
|
+
represent: representYamlBinary
|
|
1148
|
+
});
|
|
1149
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1150
|
+
var _toString$2 = Object.prototype.toString;
|
|
1151
|
+
function resolveYamlOmap(data) {
|
|
1152
|
+
if (data === null) return true;
|
|
1153
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object2 = data;
|
|
1154
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
1155
|
+
pair = object2[index];
|
|
1156
|
+
pairHasKey = false;
|
|
1157
|
+
if (_toString$2.call(pair) !== "[object Object]") return false;
|
|
1158
|
+
for (pairKey in pair) {
|
|
1159
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
1160
|
+
if (!pairHasKey) pairHasKey = true;
|
|
1161
|
+
else return false;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
if (!pairHasKey) return false;
|
|
1165
|
+
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
1166
|
+
else return false;
|
|
1167
|
+
}
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
function constructYamlOmap(data) {
|
|
1171
|
+
return data !== null ? data : [];
|
|
1172
|
+
}
|
|
1173
|
+
var omap$1 = new type$2("tag:yaml.org,2002:omap", {
|
|
1174
|
+
kind: "sequence",
|
|
1175
|
+
resolve: resolveYamlOmap,
|
|
1176
|
+
construct: constructYamlOmap
|
|
1177
|
+
});
|
|
1178
|
+
var _toString$1 = Object.prototype.toString;
|
|
1179
|
+
function resolveYamlPairs(data) {
|
|
1180
|
+
if (data === null) return true;
|
|
1181
|
+
var index, length, pair, keys, result, object2 = data;
|
|
1182
|
+
result = new Array(object2.length);
|
|
1183
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
1184
|
+
pair = object2[index];
|
|
1185
|
+
if (_toString$1.call(pair) !== "[object Object]") return false;
|
|
1186
|
+
keys = Object.keys(pair);
|
|
1187
|
+
if (keys.length !== 1) return false;
|
|
1188
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1189
|
+
}
|
|
1190
|
+
return true;
|
|
1191
|
+
}
|
|
1192
|
+
function constructYamlPairs(data) {
|
|
1193
|
+
if (data === null) return [];
|
|
1194
|
+
var index, length, pair, keys, result, object2 = data;
|
|
1195
|
+
result = new Array(object2.length);
|
|
1196
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
1197
|
+
pair = object2[index];
|
|
1198
|
+
keys = Object.keys(pair);
|
|
1199
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1200
|
+
}
|
|
1201
|
+
return result;
|
|
1202
|
+
}
|
|
1203
|
+
var pairs$1 = new type$2("tag:yaml.org,2002:pairs", {
|
|
1204
|
+
kind: "sequence",
|
|
1205
|
+
resolve: resolveYamlPairs,
|
|
1206
|
+
construct: constructYamlPairs
|
|
1207
|
+
});
|
|
1208
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1209
|
+
function resolveYamlSet(data) {
|
|
1210
|
+
if (data === null) return true;
|
|
1211
|
+
var key, object2 = data;
|
|
1212
|
+
for (key in object2) {
|
|
1213
|
+
if (_hasOwnProperty$2.call(object2, key)) {
|
|
1214
|
+
if (object2[key] !== null) return false;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
return true;
|
|
1218
|
+
}
|
|
1219
|
+
function constructYamlSet(data) {
|
|
1220
|
+
return data !== null ? data : {};
|
|
1221
|
+
}
|
|
1222
|
+
var set$1 = new type$2("tag:yaml.org,2002:set", {
|
|
1223
|
+
kind: "mapping",
|
|
1224
|
+
resolve: resolveYamlSet,
|
|
1225
|
+
construct: constructYamlSet
|
|
1226
|
+
});
|
|
1227
|
+
var _default$1 = core$2.extend({
|
|
1228
|
+
implicit: [
|
|
1229
|
+
timestamp$1,
|
|
1230
|
+
merge$2
|
|
1231
|
+
],
|
|
1232
|
+
explicit: [
|
|
1233
|
+
binary$1,
|
|
1234
|
+
omap$1,
|
|
1235
|
+
pairs$1,
|
|
1236
|
+
set$1
|
|
1237
|
+
]
|
|
1238
|
+
});
|
|
1239
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1240
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1241
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1242
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1243
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1244
|
+
var CHOMPING_CLIP = 1;
|
|
1245
|
+
var CHOMPING_STRIP = 2;
|
|
1246
|
+
var CHOMPING_KEEP = 3;
|
|
1247
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1248
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1249
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1250
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1251
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1252
|
+
function _class(obj) {
|
|
1253
|
+
return Object.prototype.toString.call(obj);
|
|
1254
|
+
}
|
|
1255
|
+
function is_EOL(c) {
|
|
1256
|
+
return c === 10 || c === 13;
|
|
1257
|
+
}
|
|
1258
|
+
function is_WHITE_SPACE(c) {
|
|
1259
|
+
return c === 9 || c === 32;
|
|
1260
|
+
}
|
|
1261
|
+
function is_WS_OR_EOL(c) {
|
|
1262
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1263
|
+
}
|
|
1264
|
+
function is_FLOW_INDICATOR(c) {
|
|
1265
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1266
|
+
}
|
|
1267
|
+
function fromHexCode(c) {
|
|
1268
|
+
var lc;
|
|
1269
|
+
if (48 <= c && c <= 57) {
|
|
1270
|
+
return c - 48;
|
|
1271
|
+
}
|
|
1272
|
+
lc = c | 32;
|
|
1273
|
+
if (97 <= lc && lc <= 102) {
|
|
1274
|
+
return lc - 97 + 10;
|
|
1275
|
+
}
|
|
1276
|
+
return -1;
|
|
1277
|
+
}
|
|
1278
|
+
function escapedHexLen(c) {
|
|
1279
|
+
if (c === 120) {
|
|
1280
|
+
return 2;
|
|
1281
|
+
}
|
|
1282
|
+
if (c === 117) {
|
|
1283
|
+
return 4;
|
|
1284
|
+
}
|
|
1285
|
+
if (c === 85) {
|
|
1286
|
+
return 8;
|
|
1287
|
+
}
|
|
1288
|
+
return 0;
|
|
1289
|
+
}
|
|
1290
|
+
function fromDecimalCode(c) {
|
|
1291
|
+
if (48 <= c && c <= 57) {
|
|
1292
|
+
return c - 48;
|
|
1293
|
+
}
|
|
1294
|
+
return -1;
|
|
1295
|
+
}
|
|
1296
|
+
function simpleEscapeSequence(c) {
|
|
1297
|
+
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "
" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
1298
|
+
}
|
|
1299
|
+
function charFromCodepoint(c) {
|
|
1300
|
+
if (c <= 65535) {
|
|
1301
|
+
return String.fromCharCode(c);
|
|
1302
|
+
}
|
|
1303
|
+
return String.fromCharCode(
|
|
1304
|
+
(c - 65536 >> 10) + 55296,
|
|
1305
|
+
(c - 65536 & 1023) + 56320
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
function setProperty(object2, key, value) {
|
|
1309
|
+
if (key === "__proto__") {
|
|
1310
|
+
Object.defineProperty(object2, key, {
|
|
1311
|
+
configurable: true,
|
|
1312
|
+
enumerable: true,
|
|
1313
|
+
writable: true,
|
|
1314
|
+
value
|
|
1315
|
+
});
|
|
1316
|
+
} else {
|
|
1317
|
+
object2[key] = value;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
var simpleEscapeCheck = new Array(256);
|
|
1321
|
+
var simpleEscapeMap = new Array(256);
|
|
1322
|
+
for (var i = 0; i < 256; i++) {
|
|
1323
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1324
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1325
|
+
}
|
|
1326
|
+
function State$1(input, options) {
|
|
1327
|
+
this.input = input;
|
|
1328
|
+
this.filename = options["filename"] || null;
|
|
1329
|
+
this.schema = options["schema"] || _default$1;
|
|
1330
|
+
this.onWarning = options["onWarning"] || null;
|
|
1331
|
+
this.legacy = options["legacy"] || false;
|
|
1332
|
+
this.json = options["json"] || false;
|
|
1333
|
+
this.listener = options["listener"] || null;
|
|
1334
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1335
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1336
|
+
this.length = input.length;
|
|
1337
|
+
this.position = 0;
|
|
1338
|
+
this.line = 0;
|
|
1339
|
+
this.lineStart = 0;
|
|
1340
|
+
this.lineIndent = 0;
|
|
1341
|
+
this.firstTabInLine = -1;
|
|
1342
|
+
this.documents = [];
|
|
1343
|
+
}
|
|
1344
|
+
function generateError(state, message) {
|
|
1345
|
+
var mark = {
|
|
1346
|
+
name: state.filename,
|
|
1347
|
+
buffer: state.input.slice(0, -1),
|
|
1348
|
+
// omit trailing \0
|
|
1349
|
+
position: state.position,
|
|
1350
|
+
line: state.line,
|
|
1351
|
+
column: state.position - state.lineStart
|
|
1352
|
+
};
|
|
1353
|
+
mark.snippet = snippet(mark);
|
|
1354
|
+
return new exception(message, mark);
|
|
1355
|
+
}
|
|
1356
|
+
function throwError(state, message) {
|
|
1357
|
+
throw generateError(state, message);
|
|
1358
|
+
}
|
|
1359
|
+
function throwWarning(state, message) {
|
|
1360
|
+
if (state.onWarning) {
|
|
1361
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
var directiveHandlers = {
|
|
1365
|
+
YAML: function handleYamlDirective(state, name2, args) {
|
|
1366
|
+
var match, major, minor;
|
|
1367
|
+
if (state.version !== null) {
|
|
1368
|
+
throwError(state, "duplication of %YAML directive");
|
|
1369
|
+
}
|
|
1370
|
+
if (args.length !== 1) {
|
|
1371
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
1372
|
+
}
|
|
1373
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1374
|
+
if (match === null) {
|
|
1375
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
1376
|
+
}
|
|
1377
|
+
major = parseInt(match[1], 10);
|
|
1378
|
+
minor = parseInt(match[2], 10);
|
|
1379
|
+
if (major !== 1) {
|
|
1380
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
1381
|
+
}
|
|
1382
|
+
state.version = args[0];
|
|
1383
|
+
state.checkLineBreaks = minor < 2;
|
|
1384
|
+
if (minor !== 1 && minor !== 2) {
|
|
1385
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
1386
|
+
}
|
|
1387
|
+
},
|
|
1388
|
+
TAG: function handleTagDirective(state, name2, args) {
|
|
1389
|
+
var handle, prefix;
|
|
1390
|
+
if (args.length !== 2) {
|
|
1391
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1392
|
+
}
|
|
1393
|
+
handle = args[0];
|
|
1394
|
+
prefix = args[1];
|
|
1395
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1396
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1397
|
+
}
|
|
1398
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1399
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1400
|
+
}
|
|
1401
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1402
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1403
|
+
}
|
|
1404
|
+
try {
|
|
1405
|
+
prefix = decodeURIComponent(prefix);
|
|
1406
|
+
} catch (err) {
|
|
1407
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1408
|
+
}
|
|
1409
|
+
state.tagMap[handle] = prefix;
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1413
|
+
var _position, _length2, _character, _result;
|
|
1414
|
+
if (start < end) {
|
|
1415
|
+
_result = state.input.slice(start, end);
|
|
1416
|
+
if (checkJson) {
|
|
1417
|
+
for (_position = 0, _length2 = _result.length; _position < _length2; _position += 1) {
|
|
1418
|
+
_character = _result.charCodeAt(_position);
|
|
1419
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1420
|
+
throwError(state, "expected valid JSON character");
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1424
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1425
|
+
}
|
|
1426
|
+
state.result += _result;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1430
|
+
var sourceKeys, key, index, quantity;
|
|
1431
|
+
if (!common.isObject(source)) {
|
|
1432
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1433
|
+
}
|
|
1434
|
+
sourceKeys = Object.keys(source);
|
|
1435
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1436
|
+
key = sourceKeys[index];
|
|
1437
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1438
|
+
setProperty(destination, key, source[key]);
|
|
1439
|
+
overridableKeys[key] = true;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1444
|
+
var index, quantity;
|
|
1445
|
+
if (Array.isArray(keyNode)) {
|
|
1446
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1447
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1448
|
+
if (Array.isArray(keyNode[index])) {
|
|
1449
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1450
|
+
}
|
|
1451
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1452
|
+
keyNode[index] = "[object Object]";
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1457
|
+
keyNode = "[object Object]";
|
|
1458
|
+
}
|
|
1459
|
+
keyNode = String(keyNode);
|
|
1460
|
+
if (_result === null) {
|
|
1461
|
+
_result = {};
|
|
1462
|
+
}
|
|
1463
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1464
|
+
if (Array.isArray(valueNode)) {
|
|
1465
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1466
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1467
|
+
}
|
|
1468
|
+
} else {
|
|
1469
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1470
|
+
}
|
|
1471
|
+
} else {
|
|
1472
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1473
|
+
state.line = startLine || state.line;
|
|
1474
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1475
|
+
state.position = startPos || state.position;
|
|
1476
|
+
throwError(state, "duplicated mapping key");
|
|
1477
|
+
}
|
|
1478
|
+
setProperty(_result, keyNode, valueNode);
|
|
1479
|
+
delete overridableKeys[keyNode];
|
|
1480
|
+
}
|
|
1481
|
+
return _result;
|
|
1482
|
+
}
|
|
1483
|
+
function readLineBreak(state) {
|
|
1484
|
+
var ch;
|
|
1485
|
+
ch = state.input.charCodeAt(state.position);
|
|
1486
|
+
if (ch === 10) {
|
|
1487
|
+
state.position++;
|
|
1488
|
+
} else if (ch === 13) {
|
|
1489
|
+
state.position++;
|
|
1490
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1491
|
+
state.position++;
|
|
1492
|
+
}
|
|
1493
|
+
} else {
|
|
1494
|
+
throwError(state, "a line break is expected");
|
|
1495
|
+
}
|
|
1496
|
+
state.line += 1;
|
|
1497
|
+
state.lineStart = state.position;
|
|
1498
|
+
state.firstTabInLine = -1;
|
|
1499
|
+
}
|
|
1500
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1501
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1502
|
+
while (ch !== 0) {
|
|
1503
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1504
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1505
|
+
state.firstTabInLine = state.position;
|
|
1506
|
+
}
|
|
1507
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1508
|
+
}
|
|
1509
|
+
if (allowComments && ch === 35) {
|
|
1510
|
+
do {
|
|
1511
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1512
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1513
|
+
}
|
|
1514
|
+
if (is_EOL(ch)) {
|
|
1515
|
+
readLineBreak(state);
|
|
1516
|
+
ch = state.input.charCodeAt(state.position);
|
|
1517
|
+
lineBreaks++;
|
|
1518
|
+
state.lineIndent = 0;
|
|
1519
|
+
while (ch === 32) {
|
|
1520
|
+
state.lineIndent++;
|
|
1521
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1522
|
+
}
|
|
1523
|
+
} else {
|
|
1524
|
+
break;
|
|
1525
|
+
}
|
|
1526
|
+
}
|
|
1527
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1528
|
+
throwWarning(state, "deficient indentation");
|
|
1529
|
+
}
|
|
1530
|
+
return lineBreaks;
|
|
1531
|
+
}
|
|
1532
|
+
function testDocumentSeparator(state) {
|
|
1533
|
+
var _position = state.position, ch;
|
|
1534
|
+
ch = state.input.charCodeAt(_position);
|
|
1535
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1536
|
+
_position += 3;
|
|
1537
|
+
ch = state.input.charCodeAt(_position);
|
|
1538
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1539
|
+
return true;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
return false;
|
|
1543
|
+
}
|
|
1544
|
+
function writeFoldedLines(state, count) {
|
|
1545
|
+
if (count === 1) {
|
|
1546
|
+
state.result += " ";
|
|
1547
|
+
} else if (count > 1) {
|
|
1548
|
+
state.result += common.repeat("\n", count - 1);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1552
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1553
|
+
ch = state.input.charCodeAt(state.position);
|
|
1554
|
+
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
1555
|
+
return false;
|
|
1556
|
+
}
|
|
1557
|
+
if (ch === 63 || ch === 45) {
|
|
1558
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1559
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1560
|
+
return false;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
state.kind = "scalar";
|
|
1564
|
+
state.result = "";
|
|
1565
|
+
captureStart = captureEnd = state.position;
|
|
1566
|
+
hasPendingContent = false;
|
|
1567
|
+
while (ch !== 0) {
|
|
1568
|
+
if (ch === 58) {
|
|
1569
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1570
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1571
|
+
break;
|
|
1572
|
+
}
|
|
1573
|
+
} else if (ch === 35) {
|
|
1574
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1575
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1576
|
+
break;
|
|
1577
|
+
}
|
|
1578
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1579
|
+
break;
|
|
1580
|
+
} else if (is_EOL(ch)) {
|
|
1581
|
+
_line = state.line;
|
|
1582
|
+
_lineStart = state.lineStart;
|
|
1583
|
+
_lineIndent = state.lineIndent;
|
|
1584
|
+
skipSeparationSpace(state, false, -1);
|
|
1585
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1586
|
+
hasPendingContent = true;
|
|
1587
|
+
ch = state.input.charCodeAt(state.position);
|
|
1588
|
+
continue;
|
|
1589
|
+
} else {
|
|
1590
|
+
state.position = captureEnd;
|
|
1591
|
+
state.line = _line;
|
|
1592
|
+
state.lineStart = _lineStart;
|
|
1593
|
+
state.lineIndent = _lineIndent;
|
|
1594
|
+
break;
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
if (hasPendingContent) {
|
|
1598
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1599
|
+
writeFoldedLines(state, state.line - _line);
|
|
1600
|
+
captureStart = captureEnd = state.position;
|
|
1601
|
+
hasPendingContent = false;
|
|
1602
|
+
}
|
|
1603
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1604
|
+
captureEnd = state.position + 1;
|
|
1605
|
+
}
|
|
1606
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1607
|
+
}
|
|
1608
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1609
|
+
if (state.result) {
|
|
1610
|
+
return true;
|
|
1611
|
+
}
|
|
1612
|
+
state.kind = _kind;
|
|
1613
|
+
state.result = _result;
|
|
1614
|
+
return false;
|
|
1615
|
+
}
|
|
1616
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1617
|
+
var ch, captureStart, captureEnd;
|
|
1618
|
+
ch = state.input.charCodeAt(state.position);
|
|
1619
|
+
if (ch !== 39) {
|
|
1620
|
+
return false;
|
|
1621
|
+
}
|
|
1622
|
+
state.kind = "scalar";
|
|
1623
|
+
state.result = "";
|
|
1624
|
+
state.position++;
|
|
1625
|
+
captureStart = captureEnd = state.position;
|
|
1626
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1627
|
+
if (ch === 39) {
|
|
1628
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1629
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1630
|
+
if (ch === 39) {
|
|
1631
|
+
captureStart = state.position;
|
|
1632
|
+
state.position++;
|
|
1633
|
+
captureEnd = state.position;
|
|
1634
|
+
} else {
|
|
1635
|
+
return true;
|
|
1636
|
+
}
|
|
1637
|
+
} else if (is_EOL(ch)) {
|
|
1638
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1639
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1640
|
+
captureStart = captureEnd = state.position;
|
|
1641
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1642
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1643
|
+
} else {
|
|
1644
|
+
state.position++;
|
|
1645
|
+
captureEnd = state.position;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1649
|
+
}
|
|
1650
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1651
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1652
|
+
ch = state.input.charCodeAt(state.position);
|
|
1653
|
+
if (ch !== 34) {
|
|
1654
|
+
return false;
|
|
1655
|
+
}
|
|
1656
|
+
state.kind = "scalar";
|
|
1657
|
+
state.result = "";
|
|
1658
|
+
state.position++;
|
|
1659
|
+
captureStart = captureEnd = state.position;
|
|
1660
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1661
|
+
if (ch === 34) {
|
|
1662
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1663
|
+
state.position++;
|
|
1664
|
+
return true;
|
|
1665
|
+
} else if (ch === 92) {
|
|
1666
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1667
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1668
|
+
if (is_EOL(ch)) {
|
|
1669
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1670
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1671
|
+
state.result += simpleEscapeMap[ch];
|
|
1672
|
+
state.position++;
|
|
1673
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1674
|
+
hexLength = tmp;
|
|
1675
|
+
hexResult = 0;
|
|
1676
|
+
for (; hexLength > 0; hexLength--) {
|
|
1677
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1678
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1679
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1680
|
+
} else {
|
|
1681
|
+
throwError(state, "expected hexadecimal character");
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
state.result += charFromCodepoint(hexResult);
|
|
1685
|
+
state.position++;
|
|
1686
|
+
} else {
|
|
1687
|
+
throwError(state, "unknown escape sequence");
|
|
1688
|
+
}
|
|
1689
|
+
captureStart = captureEnd = state.position;
|
|
1690
|
+
} else if (is_EOL(ch)) {
|
|
1691
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1692
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1693
|
+
captureStart = captureEnd = state.position;
|
|
1694
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1695
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1696
|
+
} else {
|
|
1697
|
+
state.position++;
|
|
1698
|
+
captureEnd = state.position;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1702
|
+
}
|
|
1703
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1704
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair2, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1705
|
+
ch = state.input.charCodeAt(state.position);
|
|
1706
|
+
if (ch === 91) {
|
|
1707
|
+
terminator = 93;
|
|
1708
|
+
isMapping = false;
|
|
1709
|
+
_result = [];
|
|
1710
|
+
} else if (ch === 123) {
|
|
1711
|
+
terminator = 125;
|
|
1712
|
+
isMapping = true;
|
|
1713
|
+
_result = {};
|
|
1714
|
+
} else {
|
|
1715
|
+
return false;
|
|
1716
|
+
}
|
|
1717
|
+
if (state.anchor !== null) {
|
|
1718
|
+
state.anchorMap[state.anchor] = _result;
|
|
1719
|
+
}
|
|
1720
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1721
|
+
while (ch !== 0) {
|
|
1722
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1723
|
+
ch = state.input.charCodeAt(state.position);
|
|
1724
|
+
if (ch === terminator) {
|
|
1725
|
+
state.position++;
|
|
1726
|
+
state.tag = _tag;
|
|
1727
|
+
state.anchor = _anchor;
|
|
1728
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
1729
|
+
state.result = _result;
|
|
1730
|
+
return true;
|
|
1731
|
+
} else if (!readNext) {
|
|
1732
|
+
throwError(state, "missed comma between flow collection entries");
|
|
1733
|
+
} else if (ch === 44) {
|
|
1734
|
+
throwError(state, "expected the node content, but found ','");
|
|
1735
|
+
}
|
|
1736
|
+
keyTag = keyNode = valueNode = null;
|
|
1737
|
+
isPair2 = isExplicitPair = false;
|
|
1738
|
+
if (ch === 63) {
|
|
1739
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1740
|
+
if (is_WS_OR_EOL(following)) {
|
|
1741
|
+
isPair2 = isExplicitPair = true;
|
|
1742
|
+
state.position++;
|
|
1743
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1744
|
+
}
|
|
1745
|
+
}
|
|
1746
|
+
_line = state.line;
|
|
1747
|
+
_lineStart = state.lineStart;
|
|
1748
|
+
_pos = state.position;
|
|
1749
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1750
|
+
keyTag = state.tag;
|
|
1751
|
+
keyNode = state.result;
|
|
1752
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1753
|
+
ch = state.input.charCodeAt(state.position);
|
|
1754
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1755
|
+
isPair2 = true;
|
|
1756
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1757
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1758
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1759
|
+
valueNode = state.result;
|
|
1760
|
+
}
|
|
1761
|
+
if (isMapping) {
|
|
1762
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1763
|
+
} else if (isPair2) {
|
|
1764
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1765
|
+
} else {
|
|
1766
|
+
_result.push(keyNode);
|
|
1767
|
+
}
|
|
1768
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1769
|
+
ch = state.input.charCodeAt(state.position);
|
|
1770
|
+
if (ch === 44) {
|
|
1771
|
+
readNext = true;
|
|
1772
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1773
|
+
} else {
|
|
1774
|
+
readNext = false;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1778
|
+
}
|
|
1779
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1780
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1781
|
+
ch = state.input.charCodeAt(state.position);
|
|
1782
|
+
if (ch === 124) {
|
|
1783
|
+
folding = false;
|
|
1784
|
+
} else if (ch === 62) {
|
|
1785
|
+
folding = true;
|
|
1786
|
+
} else {
|
|
1787
|
+
return false;
|
|
1788
|
+
}
|
|
1789
|
+
state.kind = "scalar";
|
|
1790
|
+
state.result = "";
|
|
1791
|
+
while (ch !== 0) {
|
|
1792
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1793
|
+
if (ch === 43 || ch === 45) {
|
|
1794
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1795
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1796
|
+
} else {
|
|
1797
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
1798
|
+
}
|
|
1799
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1800
|
+
if (tmp === 0) {
|
|
1801
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1802
|
+
} else if (!detectedIndent) {
|
|
1803
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1804
|
+
detectedIndent = true;
|
|
1805
|
+
} else {
|
|
1806
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
1807
|
+
}
|
|
1808
|
+
} else {
|
|
1809
|
+
break;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1813
|
+
do {
|
|
1814
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1815
|
+
} while (is_WHITE_SPACE(ch));
|
|
1816
|
+
if (ch === 35) {
|
|
1817
|
+
do {
|
|
1818
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1819
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
while (ch !== 0) {
|
|
1823
|
+
readLineBreak(state);
|
|
1824
|
+
state.lineIndent = 0;
|
|
1825
|
+
ch = state.input.charCodeAt(state.position);
|
|
1826
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1827
|
+
state.lineIndent++;
|
|
1828
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1829
|
+
}
|
|
1830
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1831
|
+
textIndent = state.lineIndent;
|
|
1832
|
+
}
|
|
1833
|
+
if (is_EOL(ch)) {
|
|
1834
|
+
emptyLines++;
|
|
1835
|
+
continue;
|
|
1836
|
+
}
|
|
1837
|
+
if (state.lineIndent < textIndent) {
|
|
1838
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1839
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1840
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1841
|
+
if (didReadContent) {
|
|
1842
|
+
state.result += "\n";
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
break;
|
|
1846
|
+
}
|
|
1847
|
+
if (folding) {
|
|
1848
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1849
|
+
atMoreIndented = true;
|
|
1850
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1851
|
+
} else if (atMoreIndented) {
|
|
1852
|
+
atMoreIndented = false;
|
|
1853
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
1854
|
+
} else if (emptyLines === 0) {
|
|
1855
|
+
if (didReadContent) {
|
|
1856
|
+
state.result += " ";
|
|
1857
|
+
}
|
|
1858
|
+
} else {
|
|
1859
|
+
state.result += common.repeat("\n", emptyLines);
|
|
1860
|
+
}
|
|
1861
|
+
} else {
|
|
1862
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1863
|
+
}
|
|
1864
|
+
didReadContent = true;
|
|
1865
|
+
detectedIndent = true;
|
|
1866
|
+
emptyLines = 0;
|
|
1867
|
+
captureStart = state.position;
|
|
1868
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
1869
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1870
|
+
}
|
|
1871
|
+
captureSegment(state, captureStart, state.position, false);
|
|
1872
|
+
}
|
|
1873
|
+
return true;
|
|
1874
|
+
}
|
|
1875
|
+
function readBlockSequence(state, nodeIndent) {
|
|
1876
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1877
|
+
if (state.firstTabInLine !== -1) return false;
|
|
1878
|
+
if (state.anchor !== null) {
|
|
1879
|
+
state.anchorMap[state.anchor] = _result;
|
|
1880
|
+
}
|
|
1881
|
+
ch = state.input.charCodeAt(state.position);
|
|
1882
|
+
while (ch !== 0) {
|
|
1883
|
+
if (state.firstTabInLine !== -1) {
|
|
1884
|
+
state.position = state.firstTabInLine;
|
|
1885
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1886
|
+
}
|
|
1887
|
+
if (ch !== 45) {
|
|
1888
|
+
break;
|
|
1889
|
+
}
|
|
1890
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1891
|
+
if (!is_WS_OR_EOL(following)) {
|
|
1892
|
+
break;
|
|
1893
|
+
}
|
|
1894
|
+
detected = true;
|
|
1895
|
+
state.position++;
|
|
1896
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1897
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1898
|
+
_result.push(null);
|
|
1899
|
+
ch = state.input.charCodeAt(state.position);
|
|
1900
|
+
continue;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
_line = state.line;
|
|
1904
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1905
|
+
_result.push(state.result);
|
|
1906
|
+
skipSeparationSpace(state, true, -1);
|
|
1907
|
+
ch = state.input.charCodeAt(state.position);
|
|
1908
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1909
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
1910
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1911
|
+
break;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
if (detected) {
|
|
1915
|
+
state.tag = _tag;
|
|
1916
|
+
state.anchor = _anchor;
|
|
1917
|
+
state.kind = "sequence";
|
|
1918
|
+
state.result = _result;
|
|
1919
|
+
return true;
|
|
1920
|
+
}
|
|
1921
|
+
return false;
|
|
1922
|
+
}
|
|
1923
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1924
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1925
|
+
if (state.firstTabInLine !== -1) return false;
|
|
1926
|
+
if (state.anchor !== null) {
|
|
1927
|
+
state.anchorMap[state.anchor] = _result;
|
|
1928
|
+
}
|
|
1929
|
+
ch = state.input.charCodeAt(state.position);
|
|
1930
|
+
while (ch !== 0) {
|
|
1931
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1932
|
+
state.position = state.firstTabInLine;
|
|
1933
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1934
|
+
}
|
|
1935
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1936
|
+
_line = state.line;
|
|
1937
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1938
|
+
if (ch === 63) {
|
|
1939
|
+
if (atExplicitKey) {
|
|
1940
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1941
|
+
keyTag = keyNode = valueNode = null;
|
|
1942
|
+
}
|
|
1943
|
+
detected = true;
|
|
1944
|
+
atExplicitKey = true;
|
|
1945
|
+
allowCompact = true;
|
|
1946
|
+
} else if (atExplicitKey) {
|
|
1947
|
+
atExplicitKey = false;
|
|
1948
|
+
allowCompact = true;
|
|
1949
|
+
} else {
|
|
1950
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1951
|
+
}
|
|
1952
|
+
state.position += 1;
|
|
1953
|
+
ch = following;
|
|
1954
|
+
} else {
|
|
1955
|
+
_keyLine = state.line;
|
|
1956
|
+
_keyLineStart = state.lineStart;
|
|
1957
|
+
_keyPos = state.position;
|
|
1958
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1959
|
+
break;
|
|
1960
|
+
}
|
|
1961
|
+
if (state.line === _line) {
|
|
1962
|
+
ch = state.input.charCodeAt(state.position);
|
|
1963
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1964
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1965
|
+
}
|
|
1966
|
+
if (ch === 58) {
|
|
1967
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1968
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
1969
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1970
|
+
}
|
|
1971
|
+
if (atExplicitKey) {
|
|
1972
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1973
|
+
keyTag = keyNode = valueNode = null;
|
|
1974
|
+
}
|
|
1975
|
+
detected = true;
|
|
1976
|
+
atExplicitKey = false;
|
|
1977
|
+
allowCompact = false;
|
|
1978
|
+
keyTag = state.tag;
|
|
1979
|
+
keyNode = state.result;
|
|
1980
|
+
} else if (detected) {
|
|
1981
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1982
|
+
} else {
|
|
1983
|
+
state.tag = _tag;
|
|
1984
|
+
state.anchor = _anchor;
|
|
1985
|
+
return true;
|
|
1986
|
+
}
|
|
1987
|
+
} else if (detected) {
|
|
1988
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1989
|
+
} else {
|
|
1990
|
+
state.tag = _tag;
|
|
1991
|
+
state.anchor = _anchor;
|
|
1992
|
+
return true;
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1996
|
+
if (atExplicitKey) {
|
|
1997
|
+
_keyLine = state.line;
|
|
1998
|
+
_keyLineStart = state.lineStart;
|
|
1999
|
+
_keyPos = state.position;
|
|
2000
|
+
}
|
|
2001
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
2002
|
+
if (atExplicitKey) {
|
|
2003
|
+
keyNode = state.result;
|
|
2004
|
+
} else {
|
|
2005
|
+
valueNode = state.result;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
if (!atExplicitKey) {
|
|
2009
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
2010
|
+
keyTag = keyNode = valueNode = null;
|
|
2011
|
+
}
|
|
2012
|
+
skipSeparationSpace(state, true, -1);
|
|
2013
|
+
ch = state.input.charCodeAt(state.position);
|
|
2014
|
+
}
|
|
2015
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
2016
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
2017
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
2018
|
+
break;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
if (atExplicitKey) {
|
|
2022
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
2023
|
+
}
|
|
2024
|
+
if (detected) {
|
|
2025
|
+
state.tag = _tag;
|
|
2026
|
+
state.anchor = _anchor;
|
|
2027
|
+
state.kind = "mapping";
|
|
2028
|
+
state.result = _result;
|
|
2029
|
+
}
|
|
2030
|
+
return detected;
|
|
2031
|
+
}
|
|
2032
|
+
function readTagProperty(state) {
|
|
2033
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
2034
|
+
ch = state.input.charCodeAt(state.position);
|
|
2035
|
+
if (ch !== 33) return false;
|
|
2036
|
+
if (state.tag !== null) {
|
|
2037
|
+
throwError(state, "duplication of a tag property");
|
|
2038
|
+
}
|
|
2039
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2040
|
+
if (ch === 60) {
|
|
2041
|
+
isVerbatim = true;
|
|
2042
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2043
|
+
} else if (ch === 33) {
|
|
2044
|
+
isNamed = true;
|
|
2045
|
+
tagHandle = "!!";
|
|
2046
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2047
|
+
} else {
|
|
2048
|
+
tagHandle = "!";
|
|
2049
|
+
}
|
|
2050
|
+
_position = state.position;
|
|
2051
|
+
if (isVerbatim) {
|
|
2052
|
+
do {
|
|
2053
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2054
|
+
} while (ch !== 0 && ch !== 62);
|
|
2055
|
+
if (state.position < state.length) {
|
|
2056
|
+
tagName = state.input.slice(_position, state.position);
|
|
2057
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2058
|
+
} else {
|
|
2059
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2060
|
+
}
|
|
2061
|
+
} else {
|
|
2062
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2063
|
+
if (ch === 33) {
|
|
2064
|
+
if (!isNamed) {
|
|
2065
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2066
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2067
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
2068
|
+
}
|
|
2069
|
+
isNamed = true;
|
|
2070
|
+
_position = state.position + 1;
|
|
2071
|
+
} else {
|
|
2072
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2076
|
+
}
|
|
2077
|
+
tagName = state.input.slice(_position, state.position);
|
|
2078
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2079
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2083
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
2084
|
+
}
|
|
2085
|
+
try {
|
|
2086
|
+
tagName = decodeURIComponent(tagName);
|
|
2087
|
+
} catch (err) {
|
|
2088
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
2089
|
+
}
|
|
2090
|
+
if (isVerbatim) {
|
|
2091
|
+
state.tag = tagName;
|
|
2092
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
2093
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2094
|
+
} else if (tagHandle === "!") {
|
|
2095
|
+
state.tag = "!" + tagName;
|
|
2096
|
+
} else if (tagHandle === "!!") {
|
|
2097
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
2098
|
+
} else {
|
|
2099
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2100
|
+
}
|
|
2101
|
+
return true;
|
|
2102
|
+
}
|
|
2103
|
+
function readAnchorProperty(state) {
|
|
2104
|
+
var _position, ch;
|
|
2105
|
+
ch = state.input.charCodeAt(state.position);
|
|
2106
|
+
if (ch !== 38) return false;
|
|
2107
|
+
if (state.anchor !== null) {
|
|
2108
|
+
throwError(state, "duplication of an anchor property");
|
|
2109
|
+
}
|
|
2110
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2111
|
+
_position = state.position;
|
|
2112
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2113
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2114
|
+
}
|
|
2115
|
+
if (state.position === _position) {
|
|
2116
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
2117
|
+
}
|
|
2118
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
2119
|
+
return true;
|
|
2120
|
+
}
|
|
2121
|
+
function readAlias(state) {
|
|
2122
|
+
var _position, alias, ch;
|
|
2123
|
+
ch = state.input.charCodeAt(state.position);
|
|
2124
|
+
if (ch !== 42) return false;
|
|
2125
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2126
|
+
_position = state.position;
|
|
2127
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2128
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2129
|
+
}
|
|
2130
|
+
if (state.position === _position) {
|
|
2131
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
2132
|
+
}
|
|
2133
|
+
alias = state.input.slice(_position, state.position);
|
|
2134
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
2135
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2136
|
+
}
|
|
2137
|
+
state.result = state.anchorMap[alias];
|
|
2138
|
+
skipSeparationSpace(state, true, -1);
|
|
2139
|
+
return true;
|
|
2140
|
+
}
|
|
2141
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2142
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
2143
|
+
if (state.listener !== null) {
|
|
2144
|
+
state.listener("open", state);
|
|
2145
|
+
}
|
|
2146
|
+
state.tag = null;
|
|
2147
|
+
state.anchor = null;
|
|
2148
|
+
state.kind = null;
|
|
2149
|
+
state.result = null;
|
|
2150
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2151
|
+
if (allowToSeek) {
|
|
2152
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2153
|
+
atNewLine = true;
|
|
2154
|
+
if (state.lineIndent > parentIndent) {
|
|
2155
|
+
indentStatus = 1;
|
|
2156
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2157
|
+
indentStatus = 0;
|
|
2158
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2159
|
+
indentStatus = -1;
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
if (indentStatus === 1) {
|
|
2164
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2165
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2166
|
+
atNewLine = true;
|
|
2167
|
+
allowBlockCollections = allowBlockStyles;
|
|
2168
|
+
if (state.lineIndent > parentIndent) {
|
|
2169
|
+
indentStatus = 1;
|
|
2170
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2171
|
+
indentStatus = 0;
|
|
2172
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2173
|
+
indentStatus = -1;
|
|
2174
|
+
}
|
|
2175
|
+
} else {
|
|
2176
|
+
allowBlockCollections = false;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
if (allowBlockCollections) {
|
|
2181
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
2182
|
+
}
|
|
2183
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2184
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2185
|
+
flowIndent = parentIndent;
|
|
2186
|
+
} else {
|
|
2187
|
+
flowIndent = parentIndent + 1;
|
|
2188
|
+
}
|
|
2189
|
+
blockIndent = state.position - state.lineStart;
|
|
2190
|
+
if (indentStatus === 1) {
|
|
2191
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2192
|
+
hasContent = true;
|
|
2193
|
+
} else {
|
|
2194
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2195
|
+
hasContent = true;
|
|
2196
|
+
} else if (readAlias(state)) {
|
|
2197
|
+
hasContent = true;
|
|
2198
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
2199
|
+
throwError(state, "alias node should not have any properties");
|
|
2200
|
+
}
|
|
2201
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2202
|
+
hasContent = true;
|
|
2203
|
+
if (state.tag === null) {
|
|
2204
|
+
state.tag = "?";
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
if (state.anchor !== null) {
|
|
2208
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
} else if (indentStatus === 0) {
|
|
2212
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
if (state.tag === null) {
|
|
2216
|
+
if (state.anchor !== null) {
|
|
2217
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2218
|
+
}
|
|
2219
|
+
} else if (state.tag === "?") {
|
|
2220
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
2221
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2222
|
+
}
|
|
2223
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2224
|
+
type2 = state.implicitTypes[typeIndex];
|
|
2225
|
+
if (type2.resolve(state.result)) {
|
|
2226
|
+
state.result = type2.construct(state.result);
|
|
2227
|
+
state.tag = type2.tag;
|
|
2228
|
+
if (state.anchor !== null) {
|
|
2229
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2230
|
+
}
|
|
2231
|
+
break;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
} else if (state.tag !== "!") {
|
|
2235
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2236
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2237
|
+
} else {
|
|
2238
|
+
type2 = null;
|
|
2239
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
2240
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2241
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2242
|
+
type2 = typeList[typeIndex];
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
if (!type2) {
|
|
2248
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2249
|
+
}
|
|
2250
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
2251
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
2252
|
+
}
|
|
2253
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
2254
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2255
|
+
} else {
|
|
2256
|
+
state.result = type2.construct(state.result, state.tag);
|
|
2257
|
+
if (state.anchor !== null) {
|
|
2258
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2259
|
+
}
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
if (state.listener !== null) {
|
|
2263
|
+
state.listener("close", state);
|
|
2264
|
+
}
|
|
2265
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2266
|
+
}
|
|
2267
|
+
function readDocument(state) {
|
|
2268
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2269
|
+
state.version = null;
|
|
2270
|
+
state.checkLineBreaks = state.legacy;
|
|
2271
|
+
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
2272
|
+
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
2273
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2274
|
+
skipSeparationSpace(state, true, -1);
|
|
2275
|
+
ch = state.input.charCodeAt(state.position);
|
|
2276
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
2277
|
+
break;
|
|
2278
|
+
}
|
|
2279
|
+
hasDirectives = true;
|
|
2280
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2281
|
+
_position = state.position;
|
|
2282
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2283
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2284
|
+
}
|
|
2285
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2286
|
+
directiveArgs = [];
|
|
2287
|
+
if (directiveName.length < 1) {
|
|
2288
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
2289
|
+
}
|
|
2290
|
+
while (ch !== 0) {
|
|
2291
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2292
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2293
|
+
}
|
|
2294
|
+
if (ch === 35) {
|
|
2295
|
+
do {
|
|
2296
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2297
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
2298
|
+
break;
|
|
2299
|
+
}
|
|
2300
|
+
if (is_EOL(ch)) break;
|
|
2301
|
+
_position = state.position;
|
|
2302
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2303
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2304
|
+
}
|
|
2305
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2306
|
+
}
|
|
2307
|
+
if (ch !== 0) readLineBreak(state);
|
|
2308
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
2309
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2310
|
+
} else {
|
|
2311
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
skipSeparationSpace(state, true, -1);
|
|
2315
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2316
|
+
state.position += 3;
|
|
2317
|
+
skipSeparationSpace(state, true, -1);
|
|
2318
|
+
} else if (hasDirectives) {
|
|
2319
|
+
throwError(state, "directives end mark is expected");
|
|
2320
|
+
}
|
|
2321
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2322
|
+
skipSeparationSpace(state, true, -1);
|
|
2323
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2324
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2325
|
+
}
|
|
2326
|
+
state.documents.push(state.result);
|
|
2327
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2328
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
2329
|
+
state.position += 3;
|
|
2330
|
+
skipSeparationSpace(state, true, -1);
|
|
2331
|
+
}
|
|
2332
|
+
return;
|
|
2333
|
+
}
|
|
2334
|
+
if (state.position < state.length - 1) {
|
|
2335
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
2336
|
+
} else {
|
|
2337
|
+
return;
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
function loadDocuments(input, options) {
|
|
2341
|
+
input = String(input);
|
|
2342
|
+
options = options || {};
|
|
2343
|
+
if (input.length !== 0) {
|
|
2344
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2345
|
+
input += "\n";
|
|
2346
|
+
}
|
|
2347
|
+
if (input.charCodeAt(0) === 65279) {
|
|
2348
|
+
input = input.slice(1);
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
var state = new State$1(input, options);
|
|
2352
|
+
var nullpos = input.indexOf("\0");
|
|
2353
|
+
if (nullpos !== -1) {
|
|
2354
|
+
state.position = nullpos;
|
|
2355
|
+
throwError(state, "null byte is not allowed in input");
|
|
2356
|
+
}
|
|
2357
|
+
state.input += "\0";
|
|
2358
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
2359
|
+
state.lineIndent += 1;
|
|
2360
|
+
state.position += 1;
|
|
2361
|
+
}
|
|
2362
|
+
while (state.position < state.length - 1) {
|
|
2363
|
+
readDocument(state);
|
|
2364
|
+
}
|
|
2365
|
+
return state.documents;
|
|
2366
|
+
}
|
|
2367
|
+
function load$1(input, options) {
|
|
2368
|
+
var documents = loadDocuments(input, options);
|
|
2369
|
+
if (documents.length === 0) {
|
|
2370
|
+
return void 0;
|
|
2371
|
+
} else if (documents.length === 1) {
|
|
2372
|
+
return documents[0];
|
|
2373
|
+
}
|
|
2374
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
2375
|
+
}
|
|
2376
|
+
var load_1 = load$1;
|
|
2377
|
+
var loader = {
|
|
2378
|
+
load: load_1
|
|
2379
|
+
};
|
|
2380
|
+
var _toString = Object.prototype.toString;
|
|
2381
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2382
|
+
var CHAR_BOM = 65279;
|
|
2383
|
+
var CHAR_TAB = 9;
|
|
2384
|
+
var CHAR_LINE_FEED = 10;
|
|
2385
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2386
|
+
var CHAR_SPACE = 32;
|
|
2387
|
+
var CHAR_EXCLAMATION = 33;
|
|
2388
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2389
|
+
var CHAR_SHARP = 35;
|
|
2390
|
+
var CHAR_PERCENT = 37;
|
|
2391
|
+
var CHAR_AMPERSAND = 38;
|
|
2392
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2393
|
+
var CHAR_ASTERISK = 42;
|
|
2394
|
+
var CHAR_COMMA = 44;
|
|
2395
|
+
var CHAR_MINUS = 45;
|
|
2396
|
+
var CHAR_COLON = 58;
|
|
2397
|
+
var CHAR_EQUALS = 61;
|
|
2398
|
+
var CHAR_GREATER_THAN = 62;
|
|
2399
|
+
var CHAR_QUESTION = 63;
|
|
2400
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2401
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2402
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2403
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2404
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2405
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2406
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2407
|
+
var ESCAPE_SEQUENCES = {};
|
|
2408
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2409
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2410
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2411
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2412
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2413
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2414
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2415
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2416
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2417
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2418
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2419
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2420
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2421
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2422
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2423
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2424
|
+
"y",
|
|
2425
|
+
"Y",
|
|
2426
|
+
"yes",
|
|
2427
|
+
"Yes",
|
|
2428
|
+
"YES",
|
|
2429
|
+
"on",
|
|
2430
|
+
"On",
|
|
2431
|
+
"ON",
|
|
2432
|
+
"n",
|
|
2433
|
+
"N",
|
|
2434
|
+
"no",
|
|
2435
|
+
"No",
|
|
2436
|
+
"NO",
|
|
2437
|
+
"off",
|
|
2438
|
+
"Off",
|
|
2439
|
+
"OFF"
|
|
2440
|
+
];
|
|
2441
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2442
|
+
function compileStyleMap(schema2, map2) {
|
|
2443
|
+
var result, keys, index, length, tag, style, type2;
|
|
2444
|
+
if (map2 === null) return {};
|
|
2445
|
+
result = {};
|
|
2446
|
+
keys = Object.keys(map2);
|
|
2447
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2448
|
+
tag = keys[index];
|
|
2449
|
+
style = String(map2[tag]);
|
|
2450
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2451
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2452
|
+
}
|
|
2453
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2454
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2455
|
+
style = type2.styleAliases[style];
|
|
2456
|
+
}
|
|
2457
|
+
result[tag] = style;
|
|
2458
|
+
}
|
|
2459
|
+
return result;
|
|
2460
|
+
}
|
|
2461
|
+
function encodeHex(character) {
|
|
2462
|
+
var string2, handle, length;
|
|
2463
|
+
string2 = character.toString(16).toUpperCase();
|
|
2464
|
+
if (character <= 255) {
|
|
2465
|
+
handle = "x";
|
|
2466
|
+
length = 2;
|
|
2467
|
+
} else if (character <= 65535) {
|
|
2468
|
+
handle = "u";
|
|
2469
|
+
length = 4;
|
|
2470
|
+
} else if (character <= 4294967295) {
|
|
2471
|
+
handle = "U";
|
|
2472
|
+
length = 8;
|
|
2473
|
+
} else {
|
|
2474
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2475
|
+
}
|
|
2476
|
+
return "\\" + handle + common.repeat("0", length - string2.length) + string2;
|
|
2477
|
+
}
|
|
2478
|
+
var QUOTING_TYPE_SINGLE = 1, QUOTING_TYPE_DOUBLE = 2;
|
|
2479
|
+
function State(options) {
|
|
2480
|
+
this.schema = options["schema"] || _default$1;
|
|
2481
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2482
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2483
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2484
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2485
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2486
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2487
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2488
|
+
this.noRefs = options["noRefs"] || false;
|
|
2489
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2490
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2491
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2492
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
2493
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2494
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2495
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2496
|
+
this.tag = null;
|
|
2497
|
+
this.result = "";
|
|
2498
|
+
this.duplicates = [];
|
|
2499
|
+
this.usedDuplicates = null;
|
|
2500
|
+
}
|
|
2501
|
+
function indentString(string2, spaces) {
|
|
2502
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string2.length;
|
|
2503
|
+
while (position < length) {
|
|
2504
|
+
next = string2.indexOf("\n", position);
|
|
2505
|
+
if (next === -1) {
|
|
2506
|
+
line = string2.slice(position);
|
|
2507
|
+
position = length;
|
|
2508
|
+
} else {
|
|
2509
|
+
line = string2.slice(position, next + 1);
|
|
2510
|
+
position = next + 1;
|
|
2511
|
+
}
|
|
2512
|
+
if (line.length && line !== "\n") result += ind;
|
|
2513
|
+
result += line;
|
|
2514
|
+
}
|
|
2515
|
+
return result;
|
|
2516
|
+
}
|
|
2517
|
+
function generateNextLine(state, level) {
|
|
2518
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
2519
|
+
}
|
|
2520
|
+
function testImplicitResolving(state, str2) {
|
|
2521
|
+
var index, length, type2;
|
|
2522
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2523
|
+
type2 = state.implicitTypes[index];
|
|
2524
|
+
if (type2.resolve(str2)) {
|
|
2525
|
+
return true;
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
return false;
|
|
2529
|
+
}
|
|
2530
|
+
function isWhitespace(c) {
|
|
2531
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2532
|
+
}
|
|
2533
|
+
function isPrintable(c) {
|
|
2534
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2535
|
+
}
|
|
2536
|
+
function isNsCharOrWhitespace(c) {
|
|
2537
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2538
|
+
}
|
|
2539
|
+
function isPlainSafe(c, prev, inblock) {
|
|
2540
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2541
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2542
|
+
return (
|
|
2543
|
+
// ns-plain-safe
|
|
2544
|
+
(inblock ? (
|
|
2545
|
+
// c = flow-in
|
|
2546
|
+
cIsNsCharOrWhitespace
|
|
2547
|
+
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
2548
|
+
);
|
|
2549
|
+
}
|
|
2550
|
+
function isPlainSafeFirst(c) {
|
|
2551
|
+
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2552
|
+
}
|
|
2553
|
+
function isPlainSafeLast(c) {
|
|
2554
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2555
|
+
}
|
|
2556
|
+
function codePointAt(string2, pos) {
|
|
2557
|
+
var first = string2.charCodeAt(pos), second;
|
|
2558
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string2.length) {
|
|
2559
|
+
second = string2.charCodeAt(pos + 1);
|
|
2560
|
+
if (second >= 56320 && second <= 57343) {
|
|
2561
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
return first;
|
|
2565
|
+
}
|
|
2566
|
+
function needIndentIndicator(string2) {
|
|
2567
|
+
var leadingSpaceRe = /^\n* /;
|
|
2568
|
+
return leadingSpaceRe.test(string2);
|
|
2569
|
+
}
|
|
2570
|
+
var STYLE_PLAIN = 1, STYLE_SINGLE = 2, STYLE_LITERAL = 3, STYLE_FOLDED = 4, STYLE_DOUBLE = 5;
|
|
2571
|
+
function chooseScalarStyle(string2, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2572
|
+
var i;
|
|
2573
|
+
var char = 0;
|
|
2574
|
+
var prevChar = null;
|
|
2575
|
+
var hasLineBreak = false;
|
|
2576
|
+
var hasFoldableLine = false;
|
|
2577
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2578
|
+
var previousLineBreak = -1;
|
|
2579
|
+
var plain = isPlainSafeFirst(codePointAt(string2, 0)) && isPlainSafeLast(codePointAt(string2, string2.length - 1));
|
|
2580
|
+
if (singleLineOnly || forceQuotes) {
|
|
2581
|
+
for (i = 0; i < string2.length; char >= 65536 ? i += 2 : i++) {
|
|
2582
|
+
char = codePointAt(string2, i);
|
|
2583
|
+
if (!isPrintable(char)) {
|
|
2584
|
+
return STYLE_DOUBLE;
|
|
2585
|
+
}
|
|
2586
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2587
|
+
prevChar = char;
|
|
2588
|
+
}
|
|
2589
|
+
} else {
|
|
2590
|
+
for (i = 0; i < string2.length; char >= 65536 ? i += 2 : i++) {
|
|
2591
|
+
char = codePointAt(string2, i);
|
|
2592
|
+
if (char === CHAR_LINE_FEED) {
|
|
2593
|
+
hasLineBreak = true;
|
|
2594
|
+
if (shouldTrackWidth) {
|
|
2595
|
+
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2596
|
+
i - previousLineBreak - 1 > lineWidth && string2[previousLineBreak + 1] !== " ";
|
|
2597
|
+
previousLineBreak = i;
|
|
2598
|
+
}
|
|
2599
|
+
} else if (!isPrintable(char)) {
|
|
2600
|
+
return STYLE_DOUBLE;
|
|
2601
|
+
}
|
|
2602
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2603
|
+
prevChar = char;
|
|
2604
|
+
}
|
|
2605
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string2[previousLineBreak + 1] !== " ");
|
|
2606
|
+
}
|
|
2607
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2608
|
+
if (plain && !forceQuotes && !testAmbiguousType(string2)) {
|
|
2609
|
+
return STYLE_PLAIN;
|
|
2610
|
+
}
|
|
2611
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2612
|
+
}
|
|
2613
|
+
if (indentPerLevel > 9 && needIndentIndicator(string2)) {
|
|
2614
|
+
return STYLE_DOUBLE;
|
|
2615
|
+
}
|
|
2616
|
+
if (!forceQuotes) {
|
|
2617
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2618
|
+
}
|
|
2619
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2620
|
+
}
|
|
2621
|
+
function writeScalar(state, string2, level, iskey, inblock) {
|
|
2622
|
+
state.dump = (function() {
|
|
2623
|
+
if (string2.length === 0) {
|
|
2624
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2625
|
+
}
|
|
2626
|
+
if (!state.noCompatMode) {
|
|
2627
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string2) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string2)) {
|
|
2628
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string2 + '"' : "'" + string2 + "'";
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
var indent = state.indent * Math.max(1, level);
|
|
2632
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2633
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2634
|
+
function testAmbiguity(string3) {
|
|
2635
|
+
return testImplicitResolving(state, string3);
|
|
2636
|
+
}
|
|
2637
|
+
switch (chooseScalarStyle(
|
|
2638
|
+
string2,
|
|
2639
|
+
singleLineOnly,
|
|
2640
|
+
state.indent,
|
|
2641
|
+
lineWidth,
|
|
2642
|
+
testAmbiguity,
|
|
2643
|
+
state.quotingType,
|
|
2644
|
+
state.forceQuotes && !iskey,
|
|
2645
|
+
inblock
|
|
2646
|
+
)) {
|
|
2647
|
+
case STYLE_PLAIN:
|
|
2648
|
+
return string2;
|
|
2649
|
+
case STYLE_SINGLE:
|
|
2650
|
+
return "'" + string2.replace(/'/g, "''") + "'";
|
|
2651
|
+
case STYLE_LITERAL:
|
|
2652
|
+
return "|" + blockHeader(string2, state.indent) + dropEndingNewline(indentString(string2, indent));
|
|
2653
|
+
case STYLE_FOLDED:
|
|
2654
|
+
return ">" + blockHeader(string2, state.indent) + dropEndingNewline(indentString(foldString(string2, lineWidth), indent));
|
|
2655
|
+
case STYLE_DOUBLE:
|
|
2656
|
+
return '"' + escapeString(string2) + '"';
|
|
2657
|
+
default:
|
|
2658
|
+
throw new exception("impossible error: invalid scalar style");
|
|
2659
|
+
}
|
|
2660
|
+
})();
|
|
2661
|
+
}
|
|
2662
|
+
function blockHeader(string2, indentPerLevel) {
|
|
2663
|
+
var indentIndicator = needIndentIndicator(string2) ? String(indentPerLevel) : "";
|
|
2664
|
+
var clip = string2[string2.length - 1] === "\n";
|
|
2665
|
+
var keep = clip && (string2[string2.length - 2] === "\n" || string2 === "\n");
|
|
2666
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2667
|
+
return indentIndicator + chomp + "\n";
|
|
2668
|
+
}
|
|
2669
|
+
function dropEndingNewline(string2) {
|
|
2670
|
+
return string2[string2.length - 1] === "\n" ? string2.slice(0, -1) : string2;
|
|
2671
|
+
}
|
|
2672
|
+
function foldString(string2, width) {
|
|
2673
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
2674
|
+
var result = (function() {
|
|
2675
|
+
var nextLF = string2.indexOf("\n");
|
|
2676
|
+
nextLF = nextLF !== -1 ? nextLF : string2.length;
|
|
2677
|
+
lineRe.lastIndex = nextLF;
|
|
2678
|
+
return foldLine(string2.slice(0, nextLF), width);
|
|
2679
|
+
})();
|
|
2680
|
+
var prevMoreIndented = string2[0] === "\n" || string2[0] === " ";
|
|
2681
|
+
var moreIndented;
|
|
2682
|
+
var match;
|
|
2683
|
+
while (match = lineRe.exec(string2)) {
|
|
2684
|
+
var prefix = match[1], line = match[2];
|
|
2685
|
+
moreIndented = line[0] === " ";
|
|
2686
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2687
|
+
prevMoreIndented = moreIndented;
|
|
2688
|
+
}
|
|
2689
|
+
return result;
|
|
2690
|
+
}
|
|
2691
|
+
function foldLine(line, width) {
|
|
2692
|
+
if (line === "" || line[0] === " ") return line;
|
|
2693
|
+
var breakRe = / [^ ]/g;
|
|
2694
|
+
var match;
|
|
2695
|
+
var start = 0, end, curr = 0, next = 0;
|
|
2696
|
+
var result = "";
|
|
2697
|
+
while (match = breakRe.exec(line)) {
|
|
2698
|
+
next = match.index;
|
|
2699
|
+
if (next - start > width) {
|
|
2700
|
+
end = curr > start ? curr : next;
|
|
2701
|
+
result += "\n" + line.slice(start, end);
|
|
2702
|
+
start = end + 1;
|
|
2703
|
+
}
|
|
2704
|
+
curr = next;
|
|
2705
|
+
}
|
|
2706
|
+
result += "\n";
|
|
2707
|
+
if (line.length - start > width && curr > start) {
|
|
2708
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2709
|
+
} else {
|
|
2710
|
+
result += line.slice(start);
|
|
2711
|
+
}
|
|
2712
|
+
return result.slice(1);
|
|
2713
|
+
}
|
|
2714
|
+
function escapeString(string2) {
|
|
2715
|
+
var result = "";
|
|
2716
|
+
var char = 0;
|
|
2717
|
+
var escapeSeq;
|
|
2718
|
+
for (var i = 0; i < string2.length; char >= 65536 ? i += 2 : i++) {
|
|
2719
|
+
char = codePointAt(string2, i);
|
|
2720
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2721
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
2722
|
+
result += string2[i];
|
|
2723
|
+
if (char >= 65536) result += string2[i + 1];
|
|
2724
|
+
} else {
|
|
2725
|
+
result += escapeSeq || encodeHex(char);
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
return result;
|
|
2729
|
+
}
|
|
2730
|
+
function writeFlowSequence(state, level, object2) {
|
|
2731
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2732
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
2733
|
+
value = object2[index];
|
|
2734
|
+
if (state.replacer) {
|
|
2735
|
+
value = state.replacer.call(object2, String(index), value);
|
|
2736
|
+
}
|
|
2737
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2738
|
+
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
2739
|
+
_result += state.dump;
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
state.tag = _tag;
|
|
2743
|
+
state.dump = "[" + _result + "]";
|
|
2744
|
+
}
|
|
2745
|
+
function writeBlockSequence(state, level, object2, compact) {
|
|
2746
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2747
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
2748
|
+
value = object2[index];
|
|
2749
|
+
if (state.replacer) {
|
|
2750
|
+
value = state.replacer.call(object2, String(index), value);
|
|
2751
|
+
}
|
|
2752
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2753
|
+
if (!compact || _result !== "") {
|
|
2754
|
+
_result += generateNextLine(state, level);
|
|
2755
|
+
}
|
|
2756
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2757
|
+
_result += "-";
|
|
2758
|
+
} else {
|
|
2759
|
+
_result += "- ";
|
|
2760
|
+
}
|
|
2761
|
+
_result += state.dump;
|
|
2762
|
+
}
|
|
2763
|
+
}
|
|
2764
|
+
state.tag = _tag;
|
|
2765
|
+
state.dump = _result || "[]";
|
|
2766
|
+
}
|
|
2767
|
+
function writeFlowMapping(state, level, object2) {
|
|
2768
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, pairBuffer;
|
|
2769
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2770
|
+
pairBuffer = "";
|
|
2771
|
+
if (_result !== "") pairBuffer += ", ";
|
|
2772
|
+
if (state.condenseFlow) pairBuffer += '"';
|
|
2773
|
+
objectKey = objectKeyList[index];
|
|
2774
|
+
objectValue = object2[objectKey];
|
|
2775
|
+
if (state.replacer) {
|
|
2776
|
+
objectValue = state.replacer.call(object2, objectKey, objectValue);
|
|
2777
|
+
}
|
|
2778
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2779
|
+
continue;
|
|
2780
|
+
}
|
|
2781
|
+
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2782
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2783
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2784
|
+
continue;
|
|
2785
|
+
}
|
|
2786
|
+
pairBuffer += state.dump;
|
|
2787
|
+
_result += pairBuffer;
|
|
2788
|
+
}
|
|
2789
|
+
state.tag = _tag;
|
|
2790
|
+
state.dump = "{" + _result + "}";
|
|
2791
|
+
}
|
|
2792
|
+
function writeBlockMapping(state, level, object2, compact) {
|
|
2793
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2794
|
+
if (state.sortKeys === true) {
|
|
2795
|
+
objectKeyList.sort();
|
|
2796
|
+
} else if (typeof state.sortKeys === "function") {
|
|
2797
|
+
objectKeyList.sort(state.sortKeys);
|
|
2798
|
+
} else if (state.sortKeys) {
|
|
2799
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
2800
|
+
}
|
|
2801
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2802
|
+
pairBuffer = "";
|
|
2803
|
+
if (!compact || _result !== "") {
|
|
2804
|
+
pairBuffer += generateNextLine(state, level);
|
|
2805
|
+
}
|
|
2806
|
+
objectKey = objectKeyList[index];
|
|
2807
|
+
objectValue = object2[objectKey];
|
|
2808
|
+
if (state.replacer) {
|
|
2809
|
+
objectValue = state.replacer.call(object2, objectKey, objectValue);
|
|
2810
|
+
}
|
|
2811
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2812
|
+
continue;
|
|
2813
|
+
}
|
|
2814
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2815
|
+
if (explicitPair) {
|
|
2816
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2817
|
+
pairBuffer += "?";
|
|
2818
|
+
} else {
|
|
2819
|
+
pairBuffer += "? ";
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
pairBuffer += state.dump;
|
|
2823
|
+
if (explicitPair) {
|
|
2824
|
+
pairBuffer += generateNextLine(state, level);
|
|
2825
|
+
}
|
|
2826
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2827
|
+
continue;
|
|
2828
|
+
}
|
|
2829
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2830
|
+
pairBuffer += ":";
|
|
2831
|
+
} else {
|
|
2832
|
+
pairBuffer += ": ";
|
|
2833
|
+
}
|
|
2834
|
+
pairBuffer += state.dump;
|
|
2835
|
+
_result += pairBuffer;
|
|
2836
|
+
}
|
|
2837
|
+
state.tag = _tag;
|
|
2838
|
+
state.dump = _result || "{}";
|
|
2839
|
+
}
|
|
2840
|
+
function detectType$1(state, object2, explicit) {
|
|
2841
|
+
var _result, typeList, index, length, type2, style;
|
|
2842
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2843
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2844
|
+
type2 = typeList[index];
|
|
2845
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object2 === "object" && object2 instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object2))) {
|
|
2846
|
+
if (explicit) {
|
|
2847
|
+
if (type2.multi && type2.representName) {
|
|
2848
|
+
state.tag = type2.representName(object2);
|
|
2849
|
+
} else {
|
|
2850
|
+
state.tag = type2.tag;
|
|
2851
|
+
}
|
|
2852
|
+
} else {
|
|
2853
|
+
state.tag = "?";
|
|
2854
|
+
}
|
|
2855
|
+
if (type2.represent) {
|
|
2856
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2857
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2858
|
+
_result = type2.represent(object2, style);
|
|
2859
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2860
|
+
_result = type2.represent[style](object2, style);
|
|
2861
|
+
} else {
|
|
2862
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2863
|
+
}
|
|
2864
|
+
state.dump = _result;
|
|
2865
|
+
}
|
|
2866
|
+
return true;
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
return false;
|
|
2870
|
+
}
|
|
2871
|
+
function writeNode(state, level, object2, block, compact, iskey, isblockseq) {
|
|
2872
|
+
state.tag = null;
|
|
2873
|
+
state.dump = object2;
|
|
2874
|
+
if (!detectType$1(state, object2, false)) {
|
|
2875
|
+
detectType$1(state, object2, true);
|
|
2876
|
+
}
|
|
2877
|
+
var type2 = _toString.call(state.dump);
|
|
2878
|
+
var inblock = block;
|
|
2879
|
+
var tagStr;
|
|
2880
|
+
if (block) {
|
|
2881
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2882
|
+
}
|
|
2883
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2884
|
+
if (objectOrArray) {
|
|
2885
|
+
duplicateIndex = state.duplicates.indexOf(object2);
|
|
2886
|
+
duplicate = duplicateIndex !== -1;
|
|
2887
|
+
}
|
|
2888
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2889
|
+
compact = false;
|
|
2890
|
+
}
|
|
2891
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2892
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
2893
|
+
} else {
|
|
2894
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2895
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
2896
|
+
}
|
|
2897
|
+
if (type2 === "[object Object]") {
|
|
2898
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
2899
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
2900
|
+
if (duplicate) {
|
|
2901
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2902
|
+
}
|
|
2903
|
+
} else {
|
|
2904
|
+
writeFlowMapping(state, level, state.dump);
|
|
2905
|
+
if (duplicate) {
|
|
2906
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
} else if (type2 === "[object Array]") {
|
|
2910
|
+
if (block && state.dump.length !== 0) {
|
|
2911
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2912
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2913
|
+
} else {
|
|
2914
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
2915
|
+
}
|
|
2916
|
+
if (duplicate) {
|
|
2917
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2918
|
+
}
|
|
2919
|
+
} else {
|
|
2920
|
+
writeFlowSequence(state, level, state.dump);
|
|
2921
|
+
if (duplicate) {
|
|
2922
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
} else if (type2 === "[object String]") {
|
|
2926
|
+
if (state.tag !== "?") {
|
|
2927
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2928
|
+
}
|
|
2929
|
+
} else if (type2 === "[object Undefined]") {
|
|
2930
|
+
return false;
|
|
2931
|
+
} else {
|
|
2932
|
+
if (state.skipInvalid) return false;
|
|
2933
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2934
|
+
}
|
|
2935
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
2936
|
+
tagStr = encodeURI(
|
|
2937
|
+
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
2938
|
+
).replace(/!/g, "%21");
|
|
2939
|
+
if (state.tag[0] === "!") {
|
|
2940
|
+
tagStr = "!" + tagStr;
|
|
2941
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2942
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
2943
|
+
} else {
|
|
2944
|
+
tagStr = "!<" + tagStr + ">";
|
|
2945
|
+
}
|
|
2946
|
+
state.dump = tagStr + " " + state.dump;
|
|
2947
|
+
}
|
|
2948
|
+
}
|
|
2949
|
+
return true;
|
|
2950
|
+
}
|
|
2951
|
+
function getDuplicateReferences(object2, state) {
|
|
2952
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
2953
|
+
inspectNode(object2, objects, duplicatesIndexes);
|
|
2954
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2955
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2956
|
+
}
|
|
2957
|
+
state.usedDuplicates = new Array(length);
|
|
2958
|
+
}
|
|
2959
|
+
function inspectNode(object2, objects, duplicatesIndexes) {
|
|
2960
|
+
var objectKeyList, index, length;
|
|
2961
|
+
if (object2 !== null && typeof object2 === "object") {
|
|
2962
|
+
index = objects.indexOf(object2);
|
|
2963
|
+
if (index !== -1) {
|
|
2964
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2965
|
+
duplicatesIndexes.push(index);
|
|
2966
|
+
}
|
|
2967
|
+
} else {
|
|
2968
|
+
objects.push(object2);
|
|
2969
|
+
if (Array.isArray(object2)) {
|
|
2970
|
+
for (index = 0, length = object2.length; index < length; index += 1) {
|
|
2971
|
+
inspectNode(object2[index], objects, duplicatesIndexes);
|
|
2972
|
+
}
|
|
2973
|
+
} else {
|
|
2974
|
+
objectKeyList = Object.keys(object2);
|
|
2975
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2976
|
+
inspectNode(object2[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
function dump$1(input, options) {
|
|
2983
|
+
options = options || {};
|
|
2984
|
+
var state = new State(options);
|
|
2985
|
+
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2986
|
+
var value = input;
|
|
2987
|
+
if (state.replacer) {
|
|
2988
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
2989
|
+
}
|
|
2990
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
2991
|
+
return "";
|
|
2992
|
+
}
|
|
2993
|
+
var dump_1 = dump$1;
|
|
2994
|
+
var dumper = {
|
|
2995
|
+
dump: dump_1
|
|
2996
|
+
};
|
|
2997
|
+
var load = loader.load;
|
|
2998
|
+
var dump = dumper.dump;
|
|
2999
|
+
const UUID_COMMENT_REGEX = /^#\s*uuid:\s*(.+)$/m;
|
|
3000
|
+
const ISO_DATE_REGEX = /^\d{4}(-\d{2})?(-\d{2})?$/;
|
|
3001
|
+
function extractUuidFromComment(content) {
|
|
3002
|
+
const match = content.match(UUID_COMMENT_REGEX);
|
|
3003
|
+
return match?.[1]?.trim();
|
|
3004
|
+
}
|
|
3005
|
+
function transformDateFields(item) {
|
|
3006
|
+
const result = { ...item };
|
|
3007
|
+
for (const dateField of ["issued", "accessed"]) {
|
|
3008
|
+
const value = result[dateField];
|
|
3009
|
+
if (typeof value === "string" && ISO_DATE_REGEX.test(value)) {
|
|
3010
|
+
result[dateField] = transformDateFromEdit(value);
|
|
3011
|
+
}
|
|
3012
|
+
}
|
|
3013
|
+
return result;
|
|
3014
|
+
}
|
|
3015
|
+
function parseSection(section) {
|
|
3016
|
+
const uuid2 = extractUuidFromComment(section);
|
|
3017
|
+
const yamlOnly = section.split("\n").filter((line) => !line.startsWith("#")).join("\n").trim();
|
|
3018
|
+
if (!yamlOnly) {
|
|
3019
|
+
return [];
|
|
3020
|
+
}
|
|
3021
|
+
const parsed = load(yamlOnly);
|
|
3022
|
+
if (!Array.isArray(parsed)) {
|
|
3023
|
+
return [];
|
|
3024
|
+
}
|
|
3025
|
+
return parsed.map((item) => {
|
|
3026
|
+
const transformed = transformDateFields(item);
|
|
3027
|
+
if (uuid2) {
|
|
3028
|
+
transformed._extractedUuid = uuid2;
|
|
3029
|
+
}
|
|
3030
|
+
return transformed;
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
function deserializeFromYaml(yamlContent) {
|
|
3034
|
+
const sections = yamlContent.split(/^---$/m);
|
|
3035
|
+
const results = [];
|
|
3036
|
+
for (const section of sections) {
|
|
3037
|
+
const items2 = parseSection(section);
|
|
3038
|
+
results.push(...items2);
|
|
3039
|
+
}
|
|
3040
|
+
return results;
|
|
3041
|
+
}
|
|
3042
|
+
const PROTECTED_FIELDS$2 = ["uuid", "created_at", "timestamp", "fulltext"];
|
|
3043
|
+
function createProtectedComment(item) {
|
|
3044
|
+
const custom2 = item.custom;
|
|
3045
|
+
if (!custom2) {
|
|
3046
|
+
return "";
|
|
3047
|
+
}
|
|
3048
|
+
const lines = ["# === Protected Fields (do not edit) ==="];
|
|
3049
|
+
if (custom2.uuid) {
|
|
3050
|
+
lines.push(`# uuid: ${custom2.uuid}`);
|
|
3051
|
+
}
|
|
3052
|
+
if (custom2.created_at) {
|
|
3053
|
+
lines.push(`# created_at: ${custom2.created_at}`);
|
|
3054
|
+
}
|
|
3055
|
+
if (custom2.timestamp) {
|
|
3056
|
+
lines.push(`# timestamp: ${custom2.timestamp}`);
|
|
3057
|
+
}
|
|
3058
|
+
if (custom2.fulltext) {
|
|
3059
|
+
lines.push("# fulltext:");
|
|
3060
|
+
if (custom2.fulltext.pdf) {
|
|
3061
|
+
lines.push(`# pdf: ${custom2.fulltext.pdf}`);
|
|
3062
|
+
}
|
|
3063
|
+
if (custom2.fulltext.markdown) {
|
|
3064
|
+
lines.push(`# markdown: ${custom2.fulltext.markdown}`);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
lines.push("# ========================================");
|
|
3068
|
+
return lines.join("\n");
|
|
3069
|
+
}
|
|
3070
|
+
function filterCustomFields(customValue) {
|
|
3071
|
+
const filteredCustom = {};
|
|
3072
|
+
for (const [customKey, customVal] of Object.entries(customValue)) {
|
|
3073
|
+
if (!PROTECTED_FIELDS$2.includes(customKey)) {
|
|
3074
|
+
filteredCustom[customKey] = customVal;
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
return Object.keys(filteredCustom).length > 0 ? filteredCustom : null;
|
|
3078
|
+
}
|
|
3079
|
+
function transformItemForEdit(item) {
|
|
3080
|
+
const result = {};
|
|
3081
|
+
for (const [key, value] of Object.entries(item)) {
|
|
3082
|
+
if (key === "custom") {
|
|
3083
|
+
const filtered = filterCustomFields(value);
|
|
3084
|
+
if (filtered) {
|
|
3085
|
+
result.custom = filtered;
|
|
3086
|
+
}
|
|
3087
|
+
} else if (key === "issued" || key === "accessed") {
|
|
3088
|
+
const dateValue = value;
|
|
3089
|
+
const isoDate = transformDateToEdit(dateValue);
|
|
3090
|
+
if (isoDate) {
|
|
3091
|
+
result[key] = isoDate;
|
|
3092
|
+
}
|
|
3093
|
+
} else {
|
|
3094
|
+
result[key] = value;
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
return result;
|
|
3098
|
+
}
|
|
3099
|
+
function serializeToYaml(items2) {
|
|
3100
|
+
const sections = [];
|
|
3101
|
+
for (const item of items2) {
|
|
3102
|
+
const protectedComment = createProtectedComment(item);
|
|
3103
|
+
const editableItem = transformItemForEdit(item);
|
|
3104
|
+
const yamlContent = dump([editableItem], {
|
|
3105
|
+
lineWidth: -1,
|
|
3106
|
+
// Don't wrap lines
|
|
3107
|
+
quotingType: '"',
|
|
3108
|
+
forceQuotes: false
|
|
3109
|
+
});
|
|
3110
|
+
if (protectedComment) {
|
|
3111
|
+
sections.push(`${protectedComment}
|
|
3112
|
+
|
|
3113
|
+
${yamlContent}`);
|
|
3114
|
+
} else {
|
|
3115
|
+
sections.push(yamlContent);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
return sections.join("\n---\n\n");
|
|
3119
|
+
}
|
|
3120
|
+
function resolveEditor(platform) {
|
|
3121
|
+
const visual = process.env.VISUAL;
|
|
3122
|
+
if (visual && visual.trim() !== "") {
|
|
3123
|
+
return visual;
|
|
3124
|
+
}
|
|
3125
|
+
const editor = process.env.EDITOR;
|
|
3126
|
+
if (editor && editor.trim() !== "") {
|
|
3127
|
+
return editor;
|
|
3128
|
+
}
|
|
3129
|
+
const currentPlatform = process.platform;
|
|
3130
|
+
return currentPlatform === "win32" ? "notepad" : "vi";
|
|
3131
|
+
}
|
|
3132
|
+
function serialize(items2, format2) {
|
|
3133
|
+
return format2 === "yaml" ? serializeToYaml(items2) : serializeToJson(items2);
|
|
3134
|
+
}
|
|
3135
|
+
function deserialize(content, format2) {
|
|
3136
|
+
return format2 === "yaml" ? deserializeFromYaml(content) : deserializeFromJson(content);
|
|
3137
|
+
}
|
|
3138
|
+
async function executeEdit(items2, options) {
|
|
3139
|
+
const { format: format2, editor } = options;
|
|
3140
|
+
let tempFilePath;
|
|
3141
|
+
try {
|
|
3142
|
+
const serialized = serialize(items2, format2);
|
|
3143
|
+
tempFilePath = createTempFile(serialized, format2);
|
|
3144
|
+
const exitCode = openEditor(editor, tempFilePath);
|
|
3145
|
+
if (exitCode !== 0) {
|
|
3146
|
+
return {
|
|
3147
|
+
success: false,
|
|
3148
|
+
editedItems: [],
|
|
3149
|
+
error: `Editor exited with code ${exitCode}`
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
const editedContent = readTempFile(tempFilePath);
|
|
3153
|
+
const editedItems = deserialize(editedContent, format2);
|
|
3154
|
+
return {
|
|
3155
|
+
success: true,
|
|
3156
|
+
editedItems
|
|
3157
|
+
};
|
|
3158
|
+
} catch (error) {
|
|
3159
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
3160
|
+
return {
|
|
3161
|
+
success: false,
|
|
3162
|
+
editedItems: [],
|
|
3163
|
+
error: `Parse error: ${message}`
|
|
3164
|
+
};
|
|
3165
|
+
} finally {
|
|
3166
|
+
if (tempFilePath) {
|
|
3167
|
+
deleteTempFile(tempFilePath);
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
const PROTECTED_FIELDS$1 = /* @__PURE__ */ new Set(["uuid", "created_at", "timestamp", "fulltext"]);
|
|
3172
|
+
function mergeWithProtectedFields(original, edited) {
|
|
3173
|
+
const { _extractedUuid, ...rest } = edited;
|
|
3174
|
+
const result = { ...rest };
|
|
3175
|
+
const originalCustom = original.custom;
|
|
3176
|
+
const editedCustom = result.custom;
|
|
3177
|
+
if (originalCustom) {
|
|
3178
|
+
const mergedCustom = { ...editedCustom || {} };
|
|
3179
|
+
for (const field of PROTECTED_FIELDS$1) {
|
|
3180
|
+
if (field in originalCustom) {
|
|
3181
|
+
mergedCustom[field] = originalCustom[field];
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
result.custom = mergedCustom;
|
|
3185
|
+
}
|
|
3186
|
+
return result;
|
|
3187
|
+
}
|
|
3188
|
+
function getUuidFromItem(item) {
|
|
3189
|
+
return item.custom?.uuid;
|
|
3190
|
+
}
|
|
3191
|
+
async function resolveIdentifiers(identifiers, idType, context) {
|
|
3192
|
+
const items2 = [];
|
|
3193
|
+
const uuidToOriginal = /* @__PURE__ */ new Map();
|
|
3194
|
+
for (const identifier of identifiers) {
|
|
3195
|
+
const item = await context.library.find(identifier, { idType });
|
|
3196
|
+
if (!item) {
|
|
3197
|
+
return { items: [], uuidToOriginal, error: `Reference not found: ${identifier}` };
|
|
3198
|
+
}
|
|
3199
|
+
items2.push(item);
|
|
3200
|
+
const uuid2 = getUuidFromItem(item);
|
|
3201
|
+
if (uuid2) {
|
|
3202
|
+
uuidToOriginal.set(uuid2, item);
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
return { items: items2, uuidToOriginal };
|
|
3206
|
+
}
|
|
3207
|
+
async function updateEditedItem(editedItem, items2, uuidToOriginal, context) {
|
|
3208
|
+
const extractedUuid = editedItem._extractedUuid;
|
|
3209
|
+
const original = extractedUuid ? uuidToOriginal.get(extractedUuid) : void 0;
|
|
3210
|
+
if (original && extractedUuid) {
|
|
3211
|
+
const updates = mergeWithProtectedFields(original, editedItem);
|
|
3212
|
+
await context.library.update(extractedUuid, updates, { idType: "uuid" });
|
|
3213
|
+
return editedItem.id;
|
|
3214
|
+
}
|
|
3215
|
+
const matchedOriginal = items2.find((item) => item.id === editedItem.id);
|
|
3216
|
+
if (!matchedOriginal) {
|
|
3217
|
+
return void 0;
|
|
3218
|
+
}
|
|
3219
|
+
const matchedUuid = getUuidFromItem(matchedOriginal);
|
|
3220
|
+
if (matchedUuid) {
|
|
3221
|
+
const updates = mergeWithProtectedFields(matchedOriginal, editedItem);
|
|
3222
|
+
await context.library.update(matchedUuid, updates, { idType: "uuid" });
|
|
3223
|
+
return editedItem.id;
|
|
3224
|
+
}
|
|
3225
|
+
return void 0;
|
|
3226
|
+
}
|
|
3227
|
+
async function executeEditCommand(options, context) {
|
|
3228
|
+
const { identifiers, format: format2, useUuid = false, editor: customEditor } = options;
|
|
3229
|
+
const idType = useUuid ? "uuid" : "id";
|
|
3230
|
+
const resolved = await resolveIdentifiers(identifiers, idType, context);
|
|
3231
|
+
if (resolved.error) {
|
|
3232
|
+
return {
|
|
3233
|
+
success: false,
|
|
3234
|
+
updatedCount: 0,
|
|
3235
|
+
updatedIds: [],
|
|
3236
|
+
error: resolved.error
|
|
3237
|
+
};
|
|
3238
|
+
}
|
|
3239
|
+
const { items: items2, uuidToOriginal } = resolved;
|
|
3240
|
+
const editor = customEditor || resolveEditor();
|
|
3241
|
+
const editResult = await executeEdit(items2, { format: format2, editor });
|
|
3242
|
+
if (!editResult.success) {
|
|
3243
|
+
return {
|
|
3244
|
+
success: false,
|
|
3245
|
+
updatedCount: 0,
|
|
3246
|
+
updatedIds: [],
|
|
3247
|
+
error: editResult.error ?? "Edit failed"
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
const updatedIds = [];
|
|
3251
|
+
for (const editedItem of editResult.editedItems) {
|
|
3252
|
+
const updatedId = await updateEditedItem(editedItem, items2, uuidToOriginal, context);
|
|
3253
|
+
if (updatedId) {
|
|
3254
|
+
updatedIds.push(updatedId);
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
if (updatedIds.length > 0) {
|
|
3258
|
+
await context.library.save();
|
|
3259
|
+
}
|
|
3260
|
+
return {
|
|
3261
|
+
success: true,
|
|
3262
|
+
updatedCount: updatedIds.length,
|
|
3263
|
+
updatedIds
|
|
3264
|
+
};
|
|
3265
|
+
}
|
|
3266
|
+
function formatEditOutput(result) {
|
|
3267
|
+
if (result.aborted) {
|
|
3268
|
+
return "Edit aborted.";
|
|
3269
|
+
}
|
|
3270
|
+
if (!result.success) {
|
|
3271
|
+
return `Error: ${result.error || "Unknown error"}`;
|
|
3272
|
+
}
|
|
3273
|
+
const count = result.updatedCount;
|
|
3274
|
+
const refWord = count === 1 ? "reference" : "references";
|
|
3275
|
+
if (count === 0) {
|
|
3276
|
+
return "No references were updated.";
|
|
3277
|
+
}
|
|
3278
|
+
const lines = [`Updated ${count} ${refWord}:`];
|
|
3279
|
+
for (const id2 of result.updatedIds) {
|
|
3280
|
+
lines.push(` - ${id2}`);
|
|
3281
|
+
}
|
|
3282
|
+
return lines.join("\n");
|
|
3283
|
+
}
|
|
311
3284
|
const ALIAS = Symbol.for("yaml.alias");
|
|
312
3285
|
const DOC = Symbol.for("yaml.document");
|
|
313
3286
|
const MAP = Symbol.for("yaml.map");
|
|
@@ -1066,13 +4039,13 @@ class Collection extends NodeBase {
|
|
|
1066
4039
|
}
|
|
1067
4040
|
}
|
|
1068
4041
|
}
|
|
1069
|
-
const stringifyComment = (
|
|
4042
|
+
const stringifyComment = (str2) => str2.replace(/^(?!$)(?: $)?/gm, "#");
|
|
1070
4043
|
function indentComment(comment, indent) {
|
|
1071
4044
|
if (/^\n+$/.test(comment))
|
|
1072
4045
|
return comment.substring(1);
|
|
1073
4046
|
return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
|
|
1074
4047
|
}
|
|
1075
|
-
const lineComment = (
|
|
4048
|
+
const lineComment = (str2, indent, comment) => str2.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str2.endsWith(" ") ? "" : " ") + comment;
|
|
1076
4049
|
const FOLD_FLOW = "flow";
|
|
1077
4050
|
const FOLD_BLOCK = "block";
|
|
1078
4051
|
const FOLD_QUOTED = "quoted";
|
|
@@ -1203,16 +4176,16 @@ const getFoldOptions = (ctx, isBlock) => ({
|
|
|
1203
4176
|
lineWidth: ctx.options.lineWidth,
|
|
1204
4177
|
minContentWidth: ctx.options.minContentWidth
|
|
1205
4178
|
});
|
|
1206
|
-
const containsDocumentMarker = (
|
|
1207
|
-
function lineLengthOverLimit(
|
|
4179
|
+
const containsDocumentMarker = (str2) => /^(%|---|\.\.\.)/m.test(str2);
|
|
4180
|
+
function lineLengthOverLimit(str2, lineWidth, indentLength) {
|
|
1208
4181
|
if (!lineWidth || lineWidth < 0)
|
|
1209
4182
|
return false;
|
|
1210
4183
|
const limit2 = lineWidth - indentLength;
|
|
1211
|
-
const strLen =
|
|
4184
|
+
const strLen = str2.length;
|
|
1212
4185
|
if (strLen <= limit2)
|
|
1213
4186
|
return false;
|
|
1214
4187
|
for (let i = 0, start = 0; i < strLen; ++i) {
|
|
1215
|
-
if (
|
|
4188
|
+
if (str2[i] === "\n") {
|
|
1216
4189
|
if (i - start > limit2)
|
|
1217
4190
|
return true;
|
|
1218
4191
|
start = i + 1;
|
|
@@ -1223,74 +4196,74 @@ function lineLengthOverLimit(str, lineWidth, indentLength) {
|
|
|
1223
4196
|
return true;
|
|
1224
4197
|
}
|
|
1225
4198
|
function doubleQuotedString(value, ctx) {
|
|
1226
|
-
const
|
|
4199
|
+
const json2 = JSON.stringify(value);
|
|
1227
4200
|
if (ctx.options.doubleQuotedAsJSON)
|
|
1228
|
-
return
|
|
4201
|
+
return json2;
|
|
1229
4202
|
const { implicitKey } = ctx;
|
|
1230
4203
|
const minMultiLineLength = ctx.options.doubleQuotedMinMultiLineLength;
|
|
1231
4204
|
const indent = ctx.indent || (containsDocumentMarker(value) ? " " : "");
|
|
1232
|
-
let
|
|
4205
|
+
let str2 = "";
|
|
1233
4206
|
let start = 0;
|
|
1234
|
-
for (let i = 0, ch =
|
|
1235
|
-
if (ch === " " &&
|
|
1236
|
-
|
|
4207
|
+
for (let i = 0, ch = json2[i]; ch; ch = json2[++i]) {
|
|
4208
|
+
if (ch === " " && json2[i + 1] === "\\" && json2[i + 2] === "n") {
|
|
4209
|
+
str2 += json2.slice(start, i) + "\\ ";
|
|
1237
4210
|
i += 1;
|
|
1238
4211
|
start = i;
|
|
1239
4212
|
ch = "\\";
|
|
1240
4213
|
}
|
|
1241
4214
|
if (ch === "\\")
|
|
1242
|
-
switch (
|
|
4215
|
+
switch (json2[i + 1]) {
|
|
1243
4216
|
case "u":
|
|
1244
4217
|
{
|
|
1245
|
-
|
|
1246
|
-
const code2 =
|
|
4218
|
+
str2 += json2.slice(start, i);
|
|
4219
|
+
const code2 = json2.substr(i + 2, 4);
|
|
1247
4220
|
switch (code2) {
|
|
1248
4221
|
case "0000":
|
|
1249
|
-
|
|
4222
|
+
str2 += "\\0";
|
|
1250
4223
|
break;
|
|
1251
4224
|
case "0007":
|
|
1252
|
-
|
|
4225
|
+
str2 += "\\a";
|
|
1253
4226
|
break;
|
|
1254
4227
|
case "000b":
|
|
1255
|
-
|
|
4228
|
+
str2 += "\\v";
|
|
1256
4229
|
break;
|
|
1257
4230
|
case "001b":
|
|
1258
|
-
|
|
4231
|
+
str2 += "\\e";
|
|
1259
4232
|
break;
|
|
1260
4233
|
case "0085":
|
|
1261
|
-
|
|
4234
|
+
str2 += "\\N";
|
|
1262
4235
|
break;
|
|
1263
4236
|
case "00a0":
|
|
1264
|
-
|
|
4237
|
+
str2 += "\\_";
|
|
1265
4238
|
break;
|
|
1266
4239
|
case "2028":
|
|
1267
|
-
|
|
4240
|
+
str2 += "\\L";
|
|
1268
4241
|
break;
|
|
1269
4242
|
case "2029":
|
|
1270
|
-
|
|
4243
|
+
str2 += "\\P";
|
|
1271
4244
|
break;
|
|
1272
4245
|
default:
|
|
1273
4246
|
if (code2.substr(0, 2) === "00")
|
|
1274
|
-
|
|
4247
|
+
str2 += "\\x" + code2.substr(2);
|
|
1275
4248
|
else
|
|
1276
|
-
|
|
4249
|
+
str2 += json2.substr(i, 6);
|
|
1277
4250
|
}
|
|
1278
4251
|
i += 5;
|
|
1279
4252
|
start = i + 1;
|
|
1280
4253
|
}
|
|
1281
4254
|
break;
|
|
1282
4255
|
case "n":
|
|
1283
|
-
if (implicitKey ||
|
|
4256
|
+
if (implicitKey || json2[i + 2] === '"' || json2.length < minMultiLineLength) {
|
|
1284
4257
|
i += 1;
|
|
1285
4258
|
} else {
|
|
1286
|
-
|
|
1287
|
-
while (
|
|
1288
|
-
|
|
4259
|
+
str2 += json2.slice(start, i) + "\n\n";
|
|
4260
|
+
while (json2[i + 2] === "\\" && json2[i + 3] === "n" && json2[i + 4] !== '"') {
|
|
4261
|
+
str2 += "\n";
|
|
1289
4262
|
i += 2;
|
|
1290
4263
|
}
|
|
1291
|
-
|
|
1292
|
-
if (
|
|
1293
|
-
|
|
4264
|
+
str2 += indent;
|
|
4265
|
+
if (json2[i + 2] === " ")
|
|
4266
|
+
str2 += "\\";
|
|
1294
4267
|
i += 1;
|
|
1295
4268
|
start = i + 1;
|
|
1296
4269
|
}
|
|
@@ -1299,8 +4272,8 @@ function doubleQuotedString(value, ctx) {
|
|
|
1299
4272
|
i += 1;
|
|
1300
4273
|
}
|
|
1301
4274
|
}
|
|
1302
|
-
|
|
1303
|
-
return implicitKey ?
|
|
4275
|
+
str2 = start ? str2 + json2.slice(start) : json2;
|
|
4276
|
+
return implicitKey ? str2 : foldFlowLines(str2, indent, FOLD_QUOTED, getFoldOptions(ctx, false));
|
|
1304
4277
|
}
|
|
1305
4278
|
function singleQuotedString(value, ctx) {
|
|
1306
4279
|
if (ctx.options.singleQuote === false || ctx.implicitKey && value.includes("\n") || /[ \t]\n|\n[ \t]/.test(value))
|
|
@@ -1428,15 +4401,15 @@ function plainString(item, ctx, onComment, onChompKeep) {
|
|
|
1428
4401
|
return quotedString(value, ctx);
|
|
1429
4402
|
}
|
|
1430
4403
|
}
|
|
1431
|
-
const
|
|
4404
|
+
const str2 = value.replace(/\n+/g, `$&
|
|
1432
4405
|
${indent}`);
|
|
1433
4406
|
if (actualString) {
|
|
1434
|
-
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(
|
|
4407
|
+
const test = (tag) => tag.default && tag.tag !== "tag:yaml.org,2002:str" && tag.test?.test(str2);
|
|
1435
4408
|
const { compat, tags } = ctx.doc.schema;
|
|
1436
4409
|
if (tags.some(test) || compat?.some(test))
|
|
1437
4410
|
return quotedString(value, ctx);
|
|
1438
4411
|
}
|
|
1439
|
-
return implicitKey ?
|
|
4412
|
+
return implicitKey ? str2 : foldFlowLines(str2, indent, FOLD_FLOW, getFoldOptions(ctx, false));
|
|
1440
4413
|
}
|
|
1441
4414
|
function stringifyString(item, ctx, onComment, onChompKeep) {
|
|
1442
4415
|
const { implicitKey, inFlow } = ctx;
|
|
@@ -1575,11 +4548,11 @@ function stringify$1(item, ctx, onComment, onChompKeep) {
|
|
|
1575
4548
|
const props = stringifyProps(node, tagObj, ctx);
|
|
1576
4549
|
if (props.length > 0)
|
|
1577
4550
|
ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
|
|
1578
|
-
const
|
|
4551
|
+
const str2 = typeof tagObj.stringify === "function" ? tagObj.stringify(node, ctx, onComment, onChompKeep) : isScalar(node) ? stringifyString(node, ctx, onComment, onChompKeep) : node.toString(ctx, onComment, onChompKeep);
|
|
1579
4552
|
if (!props)
|
|
1580
|
-
return
|
|
1581
|
-
return isScalar(node) ||
|
|
1582
|
-
${ctx.indent}${
|
|
4553
|
+
return str2;
|
|
4554
|
+
return isScalar(node) || str2[0] === "{" || str2[0] === "[" ? `${props} ${str2}` : `${props}
|
|
4555
|
+
${ctx.indent}${str2}`;
|
|
1583
4556
|
}
|
|
1584
4557
|
function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
1585
4558
|
const { allNullValues, doc, indent, indentStep, options: { commentString, indentSeq, simpleKeys } } = ctx;
|
|
@@ -1601,8 +4574,8 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1601
4574
|
});
|
|
1602
4575
|
let keyCommentDone = false;
|
|
1603
4576
|
let chompKeep = false;
|
|
1604
|
-
let
|
|
1605
|
-
if (!explicitKey && !ctx.inFlow &&
|
|
4577
|
+
let str2 = stringify$1(key, ctx, () => keyCommentDone = true, () => chompKeep = true);
|
|
4578
|
+
if (!explicitKey && !ctx.inFlow && str2.length > 1024) {
|
|
1606
4579
|
if (simpleKeys)
|
|
1607
4580
|
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
1608
4581
|
explicitKey = true;
|
|
@@ -1611,27 +4584,27 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
1611
4584
|
if (allNullValues || value == null) {
|
|
1612
4585
|
if (keyCommentDone && onComment)
|
|
1613
4586
|
onComment();
|
|
1614
|
-
return
|
|
4587
|
+
return str2 === "" ? "?" : explicitKey ? `? ${str2}` : str2;
|
|
1615
4588
|
}
|
|
1616
4589
|
} else if (allNullValues && !simpleKeys || value == null && explicitKey) {
|
|
1617
|
-
|
|
4590
|
+
str2 = `? ${str2}`;
|
|
1618
4591
|
if (keyComment && !keyCommentDone) {
|
|
1619
|
-
|
|
4592
|
+
str2 += lineComment(str2, ctx.indent, commentString(keyComment));
|
|
1620
4593
|
} else if (chompKeep && onChompKeep)
|
|
1621
4594
|
onChompKeep();
|
|
1622
|
-
return
|
|
4595
|
+
return str2;
|
|
1623
4596
|
}
|
|
1624
4597
|
if (keyCommentDone)
|
|
1625
4598
|
keyComment = null;
|
|
1626
4599
|
if (explicitKey) {
|
|
1627
4600
|
if (keyComment)
|
|
1628
|
-
|
|
1629
|
-
|
|
4601
|
+
str2 += lineComment(str2, ctx.indent, commentString(keyComment));
|
|
4602
|
+
str2 = `? ${str2}
|
|
1630
4603
|
${indent}:`;
|
|
1631
4604
|
} else {
|
|
1632
|
-
|
|
4605
|
+
str2 = `${str2}:`;
|
|
1633
4606
|
if (keyComment)
|
|
1634
|
-
|
|
4607
|
+
str2 += lineComment(str2, ctx.indent, commentString(keyComment));
|
|
1635
4608
|
}
|
|
1636
4609
|
let vsb, vcb, valueComment;
|
|
1637
4610
|
if (isNode(value)) {
|
|
@@ -1647,7 +4620,7 @@ ${indent}:`;
|
|
|
1647
4620
|
}
|
|
1648
4621
|
ctx.implicitKey = false;
|
|
1649
4622
|
if (!explicitKey && !keyComment && isScalar(value))
|
|
1650
|
-
ctx.indentAtStart =
|
|
4623
|
+
ctx.indentAtStart = str2.length + 1;
|
|
1651
4624
|
chompKeep = false;
|
|
1652
4625
|
if (!indentSeq && indentStep.length >= 2 && !ctx.inFlow && !explicitKey && isSeq(value) && !value.flow && !value.tag && !value.anchor) {
|
|
1653
4626
|
ctx.indent = ctx.indent.substring(2);
|
|
@@ -1691,16 +4664,16 @@ ${ctx.indent}`;
|
|
|
1691
4664
|
} else if (valueStr === "" || valueStr[0] === "\n") {
|
|
1692
4665
|
ws = "";
|
|
1693
4666
|
}
|
|
1694
|
-
|
|
4667
|
+
str2 += ws + valueStr;
|
|
1695
4668
|
if (ctx.inFlow) {
|
|
1696
4669
|
if (valueCommentDone && onComment)
|
|
1697
4670
|
onComment();
|
|
1698
4671
|
} else if (valueComment && !valueCommentDone) {
|
|
1699
|
-
|
|
4672
|
+
str2 += lineComment(str2, ctx.indent, commentString(valueComment));
|
|
1700
4673
|
} else if (chompKeep && onChompKeep) {
|
|
1701
4674
|
onChompKeep();
|
|
1702
4675
|
}
|
|
1703
|
-
return
|
|
4676
|
+
return str2;
|
|
1704
4677
|
}
|
|
1705
4678
|
function warn(logLevel, warning) {
|
|
1706
4679
|
if (logLevel === "debug" || logLevel === "warn") {
|
|
@@ -1858,31 +4831,31 @@ function stringifyBlockCollection({ comment, items: items2 }, ctx, { blockItemPr
|
|
|
1858
4831
|
}
|
|
1859
4832
|
}
|
|
1860
4833
|
chompKeep = false;
|
|
1861
|
-
let
|
|
4834
|
+
let str3 = stringify$1(item, itemCtx, () => comment2 = null, () => chompKeep = true);
|
|
1862
4835
|
if (comment2)
|
|
1863
|
-
|
|
4836
|
+
str3 += lineComment(str3, itemIndent, commentString(comment2));
|
|
1864
4837
|
if (chompKeep && comment2)
|
|
1865
4838
|
chompKeep = false;
|
|
1866
|
-
lines.push(blockItemPrefix +
|
|
4839
|
+
lines.push(blockItemPrefix + str3);
|
|
1867
4840
|
}
|
|
1868
|
-
let
|
|
4841
|
+
let str2;
|
|
1869
4842
|
if (lines.length === 0) {
|
|
1870
|
-
|
|
4843
|
+
str2 = flowChars.start + flowChars.end;
|
|
1871
4844
|
} else {
|
|
1872
|
-
|
|
4845
|
+
str2 = lines[0];
|
|
1873
4846
|
for (let i = 1; i < lines.length; ++i) {
|
|
1874
4847
|
const line = lines[i];
|
|
1875
|
-
|
|
4848
|
+
str2 += line ? `
|
|
1876
4849
|
${indent}${line}` : "\n";
|
|
1877
4850
|
}
|
|
1878
4851
|
}
|
|
1879
4852
|
if (comment) {
|
|
1880
|
-
|
|
4853
|
+
str2 += "\n" + indentComment(commentString(comment), indent);
|
|
1881
4854
|
if (onComment)
|
|
1882
4855
|
onComment();
|
|
1883
4856
|
} else if (chompKeep && onChompKeep)
|
|
1884
4857
|
onChompKeep();
|
|
1885
|
-
return
|
|
4858
|
+
return str2;
|
|
1886
4859
|
}
|
|
1887
4860
|
function stringifyFlowCollection({ items: items2 }, ctx, { flowChars, itemIndent }) {
|
|
1888
4861
|
const { indent, indentStep, flowCollectionPadding: fcPadding, options: { commentString } } = ctx;
|
|
@@ -1925,14 +4898,14 @@ function stringifyFlowCollection({ items: items2 }, ctx, { flowChars, itemIndent
|
|
|
1925
4898
|
}
|
|
1926
4899
|
if (comment)
|
|
1927
4900
|
reqNewline = true;
|
|
1928
|
-
let
|
|
4901
|
+
let str2 = stringify$1(item, itemCtx, () => comment = null);
|
|
1929
4902
|
if (i < items2.length - 1)
|
|
1930
|
-
|
|
4903
|
+
str2 += ",";
|
|
1931
4904
|
if (comment)
|
|
1932
|
-
|
|
1933
|
-
if (!reqNewline && (lines.length > linesAtValue ||
|
|
4905
|
+
str2 += lineComment(str2, itemIndent, commentString(comment));
|
|
4906
|
+
if (!reqNewline && (lines.length > linesAtValue || str2.includes("\n")))
|
|
1934
4907
|
reqNewline = true;
|
|
1935
|
-
lines.push(
|
|
4908
|
+
lines.push(str2);
|
|
1936
4909
|
linesAtValue = lines.length;
|
|
1937
4910
|
}
|
|
1938
4911
|
const { start, end } = flowChars;
|
|
@@ -1944,11 +4917,11 @@ function stringifyFlowCollection({ items: items2 }, ctx, { flowChars, itemIndent
|
|
|
1944
4917
|
reqNewline = ctx.options.lineWidth > 0 && len > ctx.options.lineWidth;
|
|
1945
4918
|
}
|
|
1946
4919
|
if (reqNewline) {
|
|
1947
|
-
let
|
|
4920
|
+
let str2 = start;
|
|
1948
4921
|
for (const line of lines)
|
|
1949
|
-
|
|
4922
|
+
str2 += line ? `
|
|
1950
4923
|
${indentStep}${indent}${line}` : "\n";
|
|
1951
|
-
return `${
|
|
4924
|
+
return `${str2}
|
|
1952
4925
|
${indent}${end}`;
|
|
1953
4926
|
} else {
|
|
1954
4927
|
return `${start}${fcPadding}${lines.join(" ")}${fcPadding}${end}`;
|
|
@@ -2222,7 +5195,7 @@ const string$2 = {
|
|
|
2222
5195
|
identify: (value) => typeof value === "string",
|
|
2223
5196
|
default: true,
|
|
2224
5197
|
tag: "tag:yaml.org,2002:str",
|
|
2225
|
-
resolve: (
|
|
5198
|
+
resolve: (str2) => str2,
|
|
2226
5199
|
stringify(item, ctx, onComment, onChompKeep) {
|
|
2227
5200
|
ctx = Object.assign({ actualString: true }, ctx);
|
|
2228
5201
|
return stringifyString(item, ctx, onComment, onChompKeep);
|
|
@@ -2242,7 +5215,7 @@ const boolTag = {
|
|
|
2242
5215
|
default: true,
|
|
2243
5216
|
tag: "tag:yaml.org,2002:bool",
|
|
2244
5217
|
test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
|
|
2245
|
-
resolve: (
|
|
5218
|
+
resolve: (str2) => new Scalar(str2[0] === "t" || str2[0] === "T"),
|
|
2246
5219
|
stringify({ source, value }, ctx) {
|
|
2247
5220
|
if (source && boolTag.test.test(source)) {
|
|
2248
5221
|
const sv = source[0] === "t" || source[0] === "T";
|
|
@@ -2276,7 +5249,7 @@ const floatNaN$1 = {
|
|
|
2276
5249
|
default: true,
|
|
2277
5250
|
tag: "tag:yaml.org,2002:float",
|
|
2278
5251
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2279
|
-
resolve: (
|
|
5252
|
+
resolve: (str2) => str2.slice(-3).toLowerCase() === "nan" ? NaN : str2[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2280
5253
|
stringify: stringifyNumber
|
|
2281
5254
|
};
|
|
2282
5255
|
const floatExp$1 = {
|
|
@@ -2285,7 +5258,7 @@ const floatExp$1 = {
|
|
|
2285
5258
|
tag: "tag:yaml.org,2002:float",
|
|
2286
5259
|
format: "EXP",
|
|
2287
5260
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
|
|
2288
|
-
resolve: (
|
|
5261
|
+
resolve: (str2) => parseFloat(str2),
|
|
2289
5262
|
stringify(node) {
|
|
2290
5263
|
const num = Number(node.value);
|
|
2291
5264
|
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
|
|
@@ -2296,17 +5269,17 @@ const float$1 = {
|
|
|
2296
5269
|
default: true,
|
|
2297
5270
|
tag: "tag:yaml.org,2002:float",
|
|
2298
5271
|
test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
|
|
2299
|
-
resolve(
|
|
2300
|
-
const node = new Scalar(parseFloat(
|
|
2301
|
-
const dot =
|
|
2302
|
-
if (dot !== -1 &&
|
|
2303
|
-
node.minFractionDigits =
|
|
5272
|
+
resolve(str2) {
|
|
5273
|
+
const node = new Scalar(parseFloat(str2));
|
|
5274
|
+
const dot = str2.indexOf(".");
|
|
5275
|
+
if (dot !== -1 && str2[str2.length - 1] === "0")
|
|
5276
|
+
node.minFractionDigits = str2.length - dot - 1;
|
|
2304
5277
|
return node;
|
|
2305
5278
|
},
|
|
2306
5279
|
stringify: stringifyNumber
|
|
2307
5280
|
};
|
|
2308
5281
|
const intIdentify$2 = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2309
|
-
const intResolve$1 = (
|
|
5282
|
+
const intResolve$1 = (str2, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str2) : parseInt(str2.substring(offset), radix);
|
|
2310
5283
|
function intStringify$1(node, radix, prefix) {
|
|
2311
5284
|
const { value } = node;
|
|
2312
5285
|
if (intIdentify$2(value) && value >= 0)
|
|
@@ -2319,7 +5292,7 @@ const intOct$1 = {
|
|
|
2319
5292
|
tag: "tag:yaml.org,2002:int",
|
|
2320
5293
|
format: "OCT",
|
|
2321
5294
|
test: /^0o[0-7]+$/,
|
|
2322
|
-
resolve: (
|
|
5295
|
+
resolve: (str2, _onError, opt) => intResolve$1(str2, 2, 8, opt),
|
|
2323
5296
|
stringify: (node) => intStringify$1(node, 8, "0o")
|
|
2324
5297
|
};
|
|
2325
5298
|
const int$2 = {
|
|
@@ -2327,7 +5300,7 @@ const int$2 = {
|
|
|
2327
5300
|
default: true,
|
|
2328
5301
|
tag: "tag:yaml.org,2002:int",
|
|
2329
5302
|
test: /^[-+]?[0-9]+$/,
|
|
2330
|
-
resolve: (
|
|
5303
|
+
resolve: (str2, _onError, opt) => intResolve$1(str2, 0, 10, opt),
|
|
2331
5304
|
stringify: stringifyNumber
|
|
2332
5305
|
};
|
|
2333
5306
|
const intHex$1 = {
|
|
@@ -2336,7 +5309,7 @@ const intHex$1 = {
|
|
|
2336
5309
|
tag: "tag:yaml.org,2002:int",
|
|
2337
5310
|
format: "HEX",
|
|
2338
5311
|
test: /^0x[0-9a-fA-F]+$/,
|
|
2339
|
-
resolve: (
|
|
5312
|
+
resolve: (str2, _onError, opt) => intResolve$1(str2, 2, 16, opt),
|
|
2340
5313
|
stringify: (node) => intStringify$1(node, 16, "0x")
|
|
2341
5314
|
};
|
|
2342
5315
|
const schema$2 = [
|
|
@@ -2361,7 +5334,7 @@ const jsonScalars = [
|
|
|
2361
5334
|
identify: (value) => typeof value === "string",
|
|
2362
5335
|
default: true,
|
|
2363
5336
|
tag: "tag:yaml.org,2002:str",
|
|
2364
|
-
resolve: (
|
|
5337
|
+
resolve: (str2) => str2,
|
|
2365
5338
|
stringify: stringifyJSON
|
|
2366
5339
|
},
|
|
2367
5340
|
{
|
|
@@ -2378,7 +5351,7 @@ const jsonScalars = [
|
|
|
2378
5351
|
default: true,
|
|
2379
5352
|
tag: "tag:yaml.org,2002:bool",
|
|
2380
5353
|
test: /^true$|^false$/,
|
|
2381
|
-
resolve: (
|
|
5354
|
+
resolve: (str2) => str2 === "true",
|
|
2382
5355
|
stringify: stringifyJSON
|
|
2383
5356
|
},
|
|
2384
5357
|
{
|
|
@@ -2386,7 +5359,7 @@ const jsonScalars = [
|
|
|
2386
5359
|
default: true,
|
|
2387
5360
|
tag: "tag:yaml.org,2002:int",
|
|
2388
5361
|
test: /^-?(?:0|[1-9][0-9]*)$/,
|
|
2389
|
-
resolve: (
|
|
5362
|
+
resolve: (str2, _onError, { intAsBigInt }) => intAsBigInt ? BigInt(str2) : parseInt(str2, 10),
|
|
2390
5363
|
stringify: ({ value }) => intIdentify$1(value) ? value.toString() : JSON.stringify(value)
|
|
2391
5364
|
},
|
|
2392
5365
|
{
|
|
@@ -2394,7 +5367,7 @@ const jsonScalars = [
|
|
|
2394
5367
|
default: true,
|
|
2395
5368
|
tag: "tag:yaml.org,2002:float",
|
|
2396
5369
|
test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
|
|
2397
|
-
resolve: (
|
|
5370
|
+
resolve: (str2) => parseFloat(str2),
|
|
2398
5371
|
stringify: stringifyJSON
|
|
2399
5372
|
}
|
|
2400
5373
|
];
|
|
@@ -2402,9 +5375,9 @@ const jsonError = {
|
|
|
2402
5375
|
default: true,
|
|
2403
5376
|
tag: "",
|
|
2404
5377
|
test: /^/,
|
|
2405
|
-
resolve(
|
|
2406
|
-
onError(`Unresolved plain scalar ${JSON.stringify(
|
|
2407
|
-
return
|
|
5378
|
+
resolve(str2, onError) {
|
|
5379
|
+
onError(`Unresolved plain scalar ${JSON.stringify(str2)}`);
|
|
5380
|
+
return str2;
|
|
2408
5381
|
}
|
|
2409
5382
|
};
|
|
2410
5383
|
const schema$1 = [map, seq].concat(jsonScalars, jsonError);
|
|
@@ -2423,10 +5396,10 @@ const binary = {
|
|
|
2423
5396
|
*/
|
|
2424
5397
|
resolve(src, onError) {
|
|
2425
5398
|
if (typeof atob === "function") {
|
|
2426
|
-
const
|
|
2427
|
-
const buffer = new Uint8Array(
|
|
2428
|
-
for (let i = 0; i <
|
|
2429
|
-
buffer[i] =
|
|
5399
|
+
const str2 = atob(src.replace(/[\n\r]/g, ""));
|
|
5400
|
+
const buffer = new Uint8Array(str2.length);
|
|
5401
|
+
for (let i = 0; i < str2.length; ++i)
|
|
5402
|
+
buffer[i] = str2.charCodeAt(i);
|
|
2430
5403
|
return buffer;
|
|
2431
5404
|
} else {
|
|
2432
5405
|
onError("This environment does not support reading binary tags; either Buffer or atob is required");
|
|
@@ -2437,26 +5410,26 @@ const binary = {
|
|
|
2437
5410
|
if (!value)
|
|
2438
5411
|
return "";
|
|
2439
5412
|
const buf = value;
|
|
2440
|
-
let
|
|
5413
|
+
let str2;
|
|
2441
5414
|
if (typeof btoa === "function") {
|
|
2442
5415
|
let s = "";
|
|
2443
5416
|
for (let i = 0; i < buf.length; ++i)
|
|
2444
5417
|
s += String.fromCharCode(buf[i]);
|
|
2445
|
-
|
|
5418
|
+
str2 = btoa(s);
|
|
2446
5419
|
} else {
|
|
2447
5420
|
throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
|
|
2448
5421
|
}
|
|
2449
5422
|
type2 ?? (type2 = Scalar.BLOCK_LITERAL);
|
|
2450
5423
|
if (type2 !== Scalar.QUOTE_DOUBLE) {
|
|
2451
5424
|
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
2452
|
-
const n = Math.ceil(
|
|
5425
|
+
const n = Math.ceil(str2.length / lineWidth);
|
|
2453
5426
|
const lines = new Array(n);
|
|
2454
5427
|
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
|
2455
|
-
lines[i] =
|
|
5428
|
+
lines[i] = str2.substr(o, lineWidth);
|
|
2456
5429
|
}
|
|
2457
|
-
|
|
5430
|
+
str2 = lines.join(type2 === Scalar.BLOCK_LITERAL ? "\n" : " ");
|
|
2458
5431
|
}
|
|
2459
|
-
return stringifyString({ comment, type: type2, value:
|
|
5432
|
+
return stringifyString({ comment, type: type2, value: str2 }, ctx, onComment, onChompKeep);
|
|
2460
5433
|
}
|
|
2461
5434
|
};
|
|
2462
5435
|
function resolvePairs(seq2, onError) {
|
|
@@ -2614,7 +5587,7 @@ const floatNaN = {
|
|
|
2614
5587
|
default: true,
|
|
2615
5588
|
tag: "tag:yaml.org,2002:float",
|
|
2616
5589
|
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
2617
|
-
resolve: (
|
|
5590
|
+
resolve: (str2) => str2.slice(-3).toLowerCase() === "nan" ? NaN : str2[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
|
|
2618
5591
|
stringify: stringifyNumber
|
|
2619
5592
|
};
|
|
2620
5593
|
const floatExp = {
|
|
@@ -2623,7 +5596,7 @@ const floatExp = {
|
|
|
2623
5596
|
tag: "tag:yaml.org,2002:float",
|
|
2624
5597
|
format: "EXP",
|
|
2625
5598
|
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
2626
|
-
resolve: (
|
|
5599
|
+
resolve: (str2) => parseFloat(str2.replace(/_/g, "")),
|
|
2627
5600
|
stringify(node) {
|
|
2628
5601
|
const num = Number(node.value);
|
|
2629
5602
|
return isFinite(num) ? num.toExponential() : stringifyNumber(node);
|
|
@@ -2634,11 +5607,11 @@ const float = {
|
|
|
2634
5607
|
default: true,
|
|
2635
5608
|
tag: "tag:yaml.org,2002:float",
|
|
2636
5609
|
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
2637
|
-
resolve(
|
|
2638
|
-
const node = new Scalar(parseFloat(
|
|
2639
|
-
const dot =
|
|
5610
|
+
resolve(str2) {
|
|
5611
|
+
const node = new Scalar(parseFloat(str2.replace(/_/g, "")));
|
|
5612
|
+
const dot = str2.indexOf(".");
|
|
2640
5613
|
if (dot !== -1) {
|
|
2641
|
-
const f =
|
|
5614
|
+
const f = str2.substring(dot + 1).replace(/_/g, "");
|
|
2642
5615
|
if (f[f.length - 1] === "0")
|
|
2643
5616
|
node.minFractionDigits = f.length;
|
|
2644
5617
|
}
|
|
@@ -2647,34 +5620,34 @@ const float = {
|
|
|
2647
5620
|
stringify: stringifyNumber
|
|
2648
5621
|
};
|
|
2649
5622
|
const intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
|
|
2650
|
-
function intResolve(
|
|
2651
|
-
const sign =
|
|
5623
|
+
function intResolve(str2, offset, radix, { intAsBigInt }) {
|
|
5624
|
+
const sign = str2[0];
|
|
2652
5625
|
if (sign === "-" || sign === "+")
|
|
2653
5626
|
offset += 1;
|
|
2654
|
-
|
|
5627
|
+
str2 = str2.substring(offset).replace(/_/g, "");
|
|
2655
5628
|
if (intAsBigInt) {
|
|
2656
5629
|
switch (radix) {
|
|
2657
5630
|
case 2:
|
|
2658
|
-
|
|
5631
|
+
str2 = `0b${str2}`;
|
|
2659
5632
|
break;
|
|
2660
5633
|
case 8:
|
|
2661
|
-
|
|
5634
|
+
str2 = `0o${str2}`;
|
|
2662
5635
|
break;
|
|
2663
5636
|
case 16:
|
|
2664
|
-
|
|
5637
|
+
str2 = `0x${str2}`;
|
|
2665
5638
|
break;
|
|
2666
5639
|
}
|
|
2667
|
-
const n2 = BigInt(
|
|
5640
|
+
const n2 = BigInt(str2);
|
|
2668
5641
|
return sign === "-" ? BigInt(-1) * n2 : n2;
|
|
2669
5642
|
}
|
|
2670
|
-
const n = parseInt(
|
|
5643
|
+
const n = parseInt(str2, radix);
|
|
2671
5644
|
return sign === "-" ? -1 * n : n;
|
|
2672
5645
|
}
|
|
2673
5646
|
function intStringify(node, radix, prefix) {
|
|
2674
5647
|
const { value } = node;
|
|
2675
5648
|
if (intIdentify(value)) {
|
|
2676
|
-
const
|
|
2677
|
-
return value < 0 ? "-" + prefix +
|
|
5649
|
+
const str2 = value.toString(radix);
|
|
5650
|
+
return value < 0 ? "-" + prefix + str2.substr(1) : prefix + str2;
|
|
2678
5651
|
}
|
|
2679
5652
|
return stringifyNumber(node);
|
|
2680
5653
|
}
|
|
@@ -2684,7 +5657,7 @@ const intBin = {
|
|
|
2684
5657
|
tag: "tag:yaml.org,2002:int",
|
|
2685
5658
|
format: "BIN",
|
|
2686
5659
|
test: /^[-+]?0b[0-1_]+$/,
|
|
2687
|
-
resolve: (
|
|
5660
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 2, 2, opt),
|
|
2688
5661
|
stringify: (node) => intStringify(node, 2, "0b")
|
|
2689
5662
|
};
|
|
2690
5663
|
const intOct = {
|
|
@@ -2693,7 +5666,7 @@ const intOct = {
|
|
|
2693
5666
|
tag: "tag:yaml.org,2002:int",
|
|
2694
5667
|
format: "OCT",
|
|
2695
5668
|
test: /^[-+]?0[0-7_]+$/,
|
|
2696
|
-
resolve: (
|
|
5669
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 1, 8, opt),
|
|
2697
5670
|
stringify: (node) => intStringify(node, 8, "0")
|
|
2698
5671
|
};
|
|
2699
5672
|
const int$1 = {
|
|
@@ -2701,7 +5674,7 @@ const int$1 = {
|
|
|
2701
5674
|
default: true,
|
|
2702
5675
|
tag: "tag:yaml.org,2002:int",
|
|
2703
5676
|
test: /^[-+]?[0-9][0-9_]*$/,
|
|
2704
|
-
resolve: (
|
|
5677
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 0, 10, opt),
|
|
2705
5678
|
stringify: stringifyNumber
|
|
2706
5679
|
};
|
|
2707
5680
|
const intHex = {
|
|
@@ -2710,7 +5683,7 @@ const intHex = {
|
|
|
2710
5683
|
tag: "tag:yaml.org,2002:int",
|
|
2711
5684
|
format: "HEX",
|
|
2712
5685
|
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
2713
|
-
resolve: (
|
|
5686
|
+
resolve: (str2, _onError, opt) => intResolve(str2, 2, 16, opt),
|
|
2714
5687
|
stringify: (node) => intStringify(node, 16, "0x")
|
|
2715
5688
|
};
|
|
2716
5689
|
class YAMLSet extends YAMLMap {
|
|
@@ -2790,9 +5763,9 @@ const set = {
|
|
|
2790
5763
|
return map2;
|
|
2791
5764
|
}
|
|
2792
5765
|
};
|
|
2793
|
-
function parseSexagesimal(
|
|
2794
|
-
const sign =
|
|
2795
|
-
const parts = sign === "-" || sign === "+" ?
|
|
5766
|
+
function parseSexagesimal(str2, asBigInt) {
|
|
5767
|
+
const sign = str2[0];
|
|
5768
|
+
const parts = sign === "-" || sign === "+" ? str2.substring(1) : str2;
|
|
2796
5769
|
const num = (n) => asBigInt ? BigInt(n) : Number(n);
|
|
2797
5770
|
const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
|
|
2798
5771
|
return sign === "-" ? num(-1) * res : res;
|
|
@@ -2829,7 +5802,7 @@ const intTime = {
|
|
|
2829
5802
|
tag: "tag:yaml.org,2002:int",
|
|
2830
5803
|
format: "TIME",
|
|
2831
5804
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
|
|
2832
|
-
resolve: (
|
|
5805
|
+
resolve: (str2, _onError, { intAsBigInt }) => parseSexagesimal(str2, intAsBigInt),
|
|
2833
5806
|
stringify: stringifySexagesimal
|
|
2834
5807
|
};
|
|
2835
5808
|
const floatTime = {
|
|
@@ -2838,7 +5811,7 @@ const floatTime = {
|
|
|
2838
5811
|
tag: "tag:yaml.org,2002:float",
|
|
2839
5812
|
format: "TIME",
|
|
2840
5813
|
test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
|
|
2841
|
-
resolve: (
|
|
5814
|
+
resolve: (str2) => parseSexagesimal(str2, false),
|
|
2842
5815
|
stringify: stringifySexagesimal
|
|
2843
5816
|
};
|
|
2844
5817
|
const timestamp = {
|
|
@@ -2849,8 +5822,8 @@ const timestamp = {
|
|
|
2849
5822
|
// may be omitted altogether, resulting in a date format. In such a case, the time part is
|
|
2850
5823
|
// assumed to be 00:00:00Z (start of day, UTC).
|
|
2851
5824
|
test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
|
|
2852
|
-
resolve(
|
|
2853
|
-
const match =
|
|
5825
|
+
resolve(str2) {
|
|
5826
|
+
const match = str2.match(timestamp.test);
|
|
2854
5827
|
if (!match)
|
|
2855
5828
|
throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
|
|
2856
5829
|
const [, year, month, day, hour, minute, second] = match.map(Number);
|
|
@@ -3297,11 +6270,11 @@ class Document {
|
|
|
3297
6270
|
throw new Error(`With a null YAML version, the { schema: Schema } option is required`);
|
|
3298
6271
|
}
|
|
3299
6272
|
// json & jsonArg are only used from toJSON()
|
|
3300
|
-
toJS({ json, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
6273
|
+
toJS({ json: json2, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
3301
6274
|
const ctx = {
|
|
3302
6275
|
anchors: /* @__PURE__ */ new Map(),
|
|
3303
6276
|
doc: this,
|
|
3304
|
-
keep: !
|
|
6277
|
+
keep: !json2,
|
|
3305
6278
|
mapAsMap: mapAsMap === true,
|
|
3306
6279
|
mapKeyWarned: false,
|
|
3307
6280
|
maxAliasCount: typeof maxAliasCount === "number" ? maxAliasCount : 100
|
|
@@ -7920,8 +10893,8 @@ function mergeDefs(...defs) {
|
|
|
7920
10893
|
}
|
|
7921
10894
|
return Object.defineProperties({}, mergedDescriptors);
|
|
7922
10895
|
}
|
|
7923
|
-
function esc(
|
|
7924
|
-
return JSON.stringify(
|
|
10896
|
+
function esc(str2) {
|
|
10897
|
+
return JSON.stringify(str2);
|
|
7925
10898
|
}
|
|
7926
10899
|
function slugify(input) {
|
|
7927
10900
|
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -7967,8 +10940,8 @@ function shallowClone(o) {
|
|
|
7967
10940
|
return o;
|
|
7968
10941
|
}
|
|
7969
10942
|
const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
7970
|
-
function escapeRegex(
|
|
7971
|
-
return
|
|
10943
|
+
function escapeRegex(str2) {
|
|
10944
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7972
10945
|
}
|
|
7973
10946
|
function clone(inst, def, params) {
|
|
7974
10947
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -8044,7 +11017,7 @@ function omit(schema2, mask) {
|
|
|
8044
11017
|
});
|
|
8045
11018
|
return clone(schema2, def);
|
|
8046
11019
|
}
|
|
8047
|
-
function
|
|
11020
|
+
function extend2(schema2, shape) {
|
|
8048
11021
|
if (!isPlainObject$1(shape)) {
|
|
8049
11022
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
8050
11023
|
}
|
|
@@ -9441,13 +12414,13 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
9441
12414
|
}
|
|
9442
12415
|
return propValues;
|
|
9443
12416
|
});
|
|
9444
|
-
const isObject$
|
|
12417
|
+
const isObject$12 = isObject;
|
|
9445
12418
|
const catchall = def.catchall;
|
|
9446
12419
|
let value;
|
|
9447
12420
|
inst._zod.parse = (payload, ctx) => {
|
|
9448
12421
|
value ?? (value = _normalized.value);
|
|
9449
12422
|
const input = payload.value;
|
|
9450
|
-
if (!isObject$
|
|
12423
|
+
if (!isObject$12(input)) {
|
|
9451
12424
|
payload.issues.push({
|
|
9452
12425
|
expected: "object",
|
|
9453
12426
|
code: "invalid_type",
|
|
@@ -9521,7 +12494,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
9521
12494
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
9522
12495
|
};
|
|
9523
12496
|
let fastpass;
|
|
9524
|
-
const isObject$
|
|
12497
|
+
const isObject$12 = isObject;
|
|
9525
12498
|
const jit = !globalConfig.jitless;
|
|
9526
12499
|
const allowsEval$1 = allowsEval;
|
|
9527
12500
|
const fastEnabled = jit && allowsEval$1.value;
|
|
@@ -9530,7 +12503,7 @@ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def)
|
|
|
9530
12503
|
inst._zod.parse = (payload, ctx) => {
|
|
9531
12504
|
value ?? (value = _normalized.value);
|
|
9532
12505
|
const input = payload.value;
|
|
9533
|
-
if (!isObject$
|
|
12506
|
+
if (!isObject$12(input)) {
|
|
9534
12507
|
payload.issues.push({
|
|
9535
12508
|
expected: "object",
|
|
9536
12509
|
code: "invalid_type",
|
|
@@ -10715,24 +13688,24 @@ class JSONSchemaGenerator {
|
|
|
10715
13688
|
const _json = result.schema;
|
|
10716
13689
|
switch (def.type) {
|
|
10717
13690
|
case "string": {
|
|
10718
|
-
const
|
|
10719
|
-
|
|
13691
|
+
const json2 = _json;
|
|
13692
|
+
json2.type = "string";
|
|
10720
13693
|
const { minimum, maximum, format: format2, patterns, contentEncoding } = schema2._zod.bag;
|
|
10721
13694
|
if (typeof minimum === "number")
|
|
10722
|
-
|
|
13695
|
+
json2.minLength = minimum;
|
|
10723
13696
|
if (typeof maximum === "number")
|
|
10724
|
-
|
|
13697
|
+
json2.maxLength = maximum;
|
|
10725
13698
|
if (format2) {
|
|
10726
|
-
|
|
10727
|
-
if (
|
|
10728
|
-
delete
|
|
13699
|
+
json2.format = formatMap[format2] ?? format2;
|
|
13700
|
+
if (json2.format === "")
|
|
13701
|
+
delete json2.format;
|
|
10729
13702
|
}
|
|
10730
13703
|
if (contentEncoding)
|
|
10731
|
-
|
|
13704
|
+
json2.contentEncoding = contentEncoding;
|
|
10732
13705
|
if (patterns && patterns.size > 0) {
|
|
10733
13706
|
const regexes = [...patterns];
|
|
10734
13707
|
if (regexes.length === 1)
|
|
10735
|
-
|
|
13708
|
+
json2.pattern = regexes[0].source;
|
|
10736
13709
|
else if (regexes.length > 1) {
|
|
10737
13710
|
result.schema.allOf = [
|
|
10738
13711
|
...regexes.map((regex) => ({
|
|
@@ -10745,53 +13718,53 @@ class JSONSchemaGenerator {
|
|
|
10745
13718
|
break;
|
|
10746
13719
|
}
|
|
10747
13720
|
case "number": {
|
|
10748
|
-
const
|
|
13721
|
+
const json2 = _json;
|
|
10749
13722
|
const { minimum, maximum, format: format2, multipleOf: multipleOf2, exclusiveMaximum, exclusiveMinimum } = schema2._zod.bag;
|
|
10750
13723
|
if (typeof format2 === "string" && format2.includes("int"))
|
|
10751
|
-
|
|
13724
|
+
json2.type = "integer";
|
|
10752
13725
|
else
|
|
10753
|
-
|
|
13726
|
+
json2.type = "number";
|
|
10754
13727
|
if (typeof exclusiveMinimum === "number") {
|
|
10755
13728
|
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
10756
|
-
|
|
10757
|
-
|
|
13729
|
+
json2.minimum = exclusiveMinimum;
|
|
13730
|
+
json2.exclusiveMinimum = true;
|
|
10758
13731
|
} else {
|
|
10759
|
-
|
|
13732
|
+
json2.exclusiveMinimum = exclusiveMinimum;
|
|
10760
13733
|
}
|
|
10761
13734
|
}
|
|
10762
13735
|
if (typeof minimum === "number") {
|
|
10763
|
-
|
|
13736
|
+
json2.minimum = minimum;
|
|
10764
13737
|
if (typeof exclusiveMinimum === "number" && this.target !== "draft-4") {
|
|
10765
13738
|
if (exclusiveMinimum >= minimum)
|
|
10766
|
-
delete
|
|
13739
|
+
delete json2.minimum;
|
|
10767
13740
|
else
|
|
10768
|
-
delete
|
|
13741
|
+
delete json2.exclusiveMinimum;
|
|
10769
13742
|
}
|
|
10770
13743
|
}
|
|
10771
13744
|
if (typeof exclusiveMaximum === "number") {
|
|
10772
13745
|
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
10773
|
-
|
|
10774
|
-
|
|
13746
|
+
json2.maximum = exclusiveMaximum;
|
|
13747
|
+
json2.exclusiveMaximum = true;
|
|
10775
13748
|
} else {
|
|
10776
|
-
|
|
13749
|
+
json2.exclusiveMaximum = exclusiveMaximum;
|
|
10777
13750
|
}
|
|
10778
13751
|
}
|
|
10779
13752
|
if (typeof maximum === "number") {
|
|
10780
|
-
|
|
13753
|
+
json2.maximum = maximum;
|
|
10781
13754
|
if (typeof exclusiveMaximum === "number" && this.target !== "draft-4") {
|
|
10782
13755
|
if (exclusiveMaximum <= maximum)
|
|
10783
|
-
delete
|
|
13756
|
+
delete json2.maximum;
|
|
10784
13757
|
else
|
|
10785
|
-
delete
|
|
13758
|
+
delete json2.exclusiveMaximum;
|
|
10786
13759
|
}
|
|
10787
13760
|
}
|
|
10788
13761
|
if (typeof multipleOf2 === "number")
|
|
10789
|
-
|
|
13762
|
+
json2.multipleOf = multipleOf2;
|
|
10790
13763
|
break;
|
|
10791
13764
|
}
|
|
10792
13765
|
case "boolean": {
|
|
10793
|
-
const
|
|
10794
|
-
|
|
13766
|
+
const json2 = _json;
|
|
13767
|
+
json2.type = "boolean";
|
|
10795
13768
|
break;
|
|
10796
13769
|
}
|
|
10797
13770
|
case "bigint": {
|
|
@@ -10844,23 +13817,23 @@ class JSONSchemaGenerator {
|
|
|
10844
13817
|
break;
|
|
10845
13818
|
}
|
|
10846
13819
|
case "array": {
|
|
10847
|
-
const
|
|
13820
|
+
const json2 = _json;
|
|
10848
13821
|
const { minimum, maximum } = schema2._zod.bag;
|
|
10849
13822
|
if (typeof minimum === "number")
|
|
10850
|
-
|
|
13823
|
+
json2.minItems = minimum;
|
|
10851
13824
|
if (typeof maximum === "number")
|
|
10852
|
-
|
|
10853
|
-
|
|
10854
|
-
|
|
13825
|
+
json2.maxItems = maximum;
|
|
13826
|
+
json2.type = "array";
|
|
13827
|
+
json2.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
|
|
10855
13828
|
break;
|
|
10856
13829
|
}
|
|
10857
13830
|
case "object": {
|
|
10858
|
-
const
|
|
10859
|
-
|
|
10860
|
-
|
|
13831
|
+
const json2 = _json;
|
|
13832
|
+
json2.type = "object";
|
|
13833
|
+
json2.properties = {};
|
|
10861
13834
|
const shape = def.shape;
|
|
10862
13835
|
for (const key in shape) {
|
|
10863
|
-
|
|
13836
|
+
json2.properties[key] = this.process(shape[key], {
|
|
10864
13837
|
...params,
|
|
10865
13838
|
path: [...params.path, "properties", key]
|
|
10866
13839
|
});
|
|
@@ -10875,15 +13848,15 @@ class JSONSchemaGenerator {
|
|
|
10875
13848
|
}
|
|
10876
13849
|
}));
|
|
10877
13850
|
if (requiredKeys.size > 0) {
|
|
10878
|
-
|
|
13851
|
+
json2.required = Array.from(requiredKeys);
|
|
10879
13852
|
}
|
|
10880
13853
|
if (def.catchall?._zod.def.type === "never") {
|
|
10881
|
-
|
|
13854
|
+
json2.additionalProperties = false;
|
|
10882
13855
|
} else if (!def.catchall) {
|
|
10883
13856
|
if (this.io === "output")
|
|
10884
|
-
|
|
13857
|
+
json2.additionalProperties = false;
|
|
10885
13858
|
} else if (def.catchall) {
|
|
10886
|
-
|
|
13859
|
+
json2.additionalProperties = this.process(def.catchall, {
|
|
10887
13860
|
...params,
|
|
10888
13861
|
path: [...params.path, "additionalProperties"]
|
|
10889
13862
|
});
|
|
@@ -10891,21 +13864,21 @@ class JSONSchemaGenerator {
|
|
|
10891
13864
|
break;
|
|
10892
13865
|
}
|
|
10893
13866
|
case "union": {
|
|
10894
|
-
const
|
|
13867
|
+
const json2 = _json;
|
|
10895
13868
|
const isDiscriminated = def.discriminator !== void 0;
|
|
10896
13869
|
const options = def.options.map((x, i) => this.process(x, {
|
|
10897
13870
|
...params,
|
|
10898
13871
|
path: [...params.path, isDiscriminated ? "oneOf" : "anyOf", i]
|
|
10899
13872
|
}));
|
|
10900
13873
|
if (isDiscriminated) {
|
|
10901
|
-
|
|
13874
|
+
json2.oneOf = options;
|
|
10902
13875
|
} else {
|
|
10903
|
-
|
|
13876
|
+
json2.anyOf = options;
|
|
10904
13877
|
}
|
|
10905
13878
|
break;
|
|
10906
13879
|
}
|
|
10907
13880
|
case "intersection": {
|
|
10908
|
-
const
|
|
13881
|
+
const json2 = _json;
|
|
10909
13882
|
const a = this.process(def.left, {
|
|
10910
13883
|
...params,
|
|
10911
13884
|
path: [...params.path, "allOf", 0]
|
|
@@ -10919,12 +13892,12 @@ class JSONSchemaGenerator {
|
|
|
10919
13892
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
10920
13893
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
10921
13894
|
];
|
|
10922
|
-
|
|
13895
|
+
json2.allOf = allOf2;
|
|
10923
13896
|
break;
|
|
10924
13897
|
}
|
|
10925
13898
|
case "tuple": {
|
|
10926
|
-
const
|
|
10927
|
-
|
|
13899
|
+
const json2 = _json;
|
|
13900
|
+
json2.type = "array";
|
|
10928
13901
|
const prefixPath = this.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
10929
13902
|
const restPath = this.target === "draft-2020-12" ? "items" : this.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
10930
13903
|
const prefixItems2 = def.items.map((x, i) => this.process(x, {
|
|
@@ -10936,44 +13909,44 @@ class JSONSchemaGenerator {
|
|
|
10936
13909
|
path: [...params.path, restPath, ...this.target === "openapi-3.0" ? [def.items.length] : []]
|
|
10937
13910
|
}) : null;
|
|
10938
13911
|
if (this.target === "draft-2020-12") {
|
|
10939
|
-
|
|
13912
|
+
json2.prefixItems = prefixItems2;
|
|
10940
13913
|
if (rest) {
|
|
10941
|
-
|
|
13914
|
+
json2.items = rest;
|
|
10942
13915
|
}
|
|
10943
13916
|
} else if (this.target === "openapi-3.0") {
|
|
10944
|
-
|
|
13917
|
+
json2.items = {
|
|
10945
13918
|
anyOf: prefixItems2
|
|
10946
13919
|
};
|
|
10947
13920
|
if (rest) {
|
|
10948
|
-
|
|
13921
|
+
json2.items.anyOf.push(rest);
|
|
10949
13922
|
}
|
|
10950
|
-
|
|
13923
|
+
json2.minItems = prefixItems2.length;
|
|
10951
13924
|
if (!rest) {
|
|
10952
|
-
|
|
13925
|
+
json2.maxItems = prefixItems2.length;
|
|
10953
13926
|
}
|
|
10954
13927
|
} else {
|
|
10955
|
-
|
|
13928
|
+
json2.items = prefixItems2;
|
|
10956
13929
|
if (rest) {
|
|
10957
|
-
|
|
13930
|
+
json2.additionalItems = rest;
|
|
10958
13931
|
}
|
|
10959
13932
|
}
|
|
10960
13933
|
const { minimum, maximum } = schema2._zod.bag;
|
|
10961
13934
|
if (typeof minimum === "number")
|
|
10962
|
-
|
|
13935
|
+
json2.minItems = minimum;
|
|
10963
13936
|
if (typeof maximum === "number")
|
|
10964
|
-
|
|
13937
|
+
json2.maxItems = maximum;
|
|
10965
13938
|
break;
|
|
10966
13939
|
}
|
|
10967
13940
|
case "record": {
|
|
10968
|
-
const
|
|
10969
|
-
|
|
13941
|
+
const json2 = _json;
|
|
13942
|
+
json2.type = "object";
|
|
10970
13943
|
if (this.target === "draft-7" || this.target === "draft-2020-12") {
|
|
10971
|
-
|
|
13944
|
+
json2.propertyNames = this.process(def.keyType, {
|
|
10972
13945
|
...params,
|
|
10973
13946
|
path: [...params.path, "propertyNames"]
|
|
10974
13947
|
});
|
|
10975
13948
|
}
|
|
10976
|
-
|
|
13949
|
+
json2.additionalProperties = this.process(def.valueType, {
|
|
10977
13950
|
...params,
|
|
10978
13951
|
path: [...params.path, "additionalProperties"]
|
|
10979
13952
|
});
|
|
@@ -10992,17 +13965,17 @@ class JSONSchemaGenerator {
|
|
|
10992
13965
|
break;
|
|
10993
13966
|
}
|
|
10994
13967
|
case "enum": {
|
|
10995
|
-
const
|
|
13968
|
+
const json2 = _json;
|
|
10996
13969
|
const values = getEnumValues(def.entries);
|
|
10997
13970
|
if (values.every((v) => typeof v === "number"))
|
|
10998
|
-
|
|
13971
|
+
json2.type = "number";
|
|
10999
13972
|
if (values.every((v) => typeof v === "string"))
|
|
11000
|
-
|
|
11001
|
-
|
|
13973
|
+
json2.type = "string";
|
|
13974
|
+
json2.enum = values;
|
|
11002
13975
|
break;
|
|
11003
13976
|
}
|
|
11004
13977
|
case "literal": {
|
|
11005
|
-
const
|
|
13978
|
+
const json2 = _json;
|
|
11006
13979
|
const vals = [];
|
|
11007
13980
|
for (const val of def.values) {
|
|
11008
13981
|
if (val === void 0) {
|
|
@@ -11022,27 +13995,27 @@ class JSONSchemaGenerator {
|
|
|
11022
13995
|
if (vals.length === 0) ;
|
|
11023
13996
|
else if (vals.length === 1) {
|
|
11024
13997
|
const val = vals[0];
|
|
11025
|
-
|
|
13998
|
+
json2.type = val === null ? "null" : typeof val;
|
|
11026
13999
|
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
11027
|
-
|
|
14000
|
+
json2.enum = [val];
|
|
11028
14001
|
} else {
|
|
11029
|
-
|
|
14002
|
+
json2.const = val;
|
|
11030
14003
|
}
|
|
11031
14004
|
} else {
|
|
11032
14005
|
if (vals.every((v) => typeof v === "number"))
|
|
11033
|
-
|
|
14006
|
+
json2.type = "number";
|
|
11034
14007
|
if (vals.every((v) => typeof v === "string"))
|
|
11035
|
-
|
|
14008
|
+
json2.type = "string";
|
|
11036
14009
|
if (vals.every((v) => typeof v === "boolean"))
|
|
11037
|
-
|
|
14010
|
+
json2.type = "string";
|
|
11038
14011
|
if (vals.every((v) => v === null))
|
|
11039
|
-
|
|
11040
|
-
|
|
14012
|
+
json2.type = "null";
|
|
14013
|
+
json2.enum = vals;
|
|
11041
14014
|
}
|
|
11042
14015
|
break;
|
|
11043
14016
|
}
|
|
11044
14017
|
case "file": {
|
|
11045
|
-
const
|
|
14018
|
+
const json2 = _json;
|
|
11046
14019
|
const file = {
|
|
11047
14020
|
type: "string",
|
|
11048
14021
|
format: "binary",
|
|
@@ -11056,15 +14029,15 @@ class JSONSchemaGenerator {
|
|
|
11056
14029
|
if (mime) {
|
|
11057
14030
|
if (mime.length === 1) {
|
|
11058
14031
|
file.contentMediaType = mime[0];
|
|
11059
|
-
Object.assign(
|
|
14032
|
+
Object.assign(json2, file);
|
|
11060
14033
|
} else {
|
|
11061
|
-
|
|
14034
|
+
json2.anyOf = mime.map((m) => {
|
|
11062
14035
|
const mFile = { ...file, contentMediaType: m };
|
|
11063
14036
|
return mFile;
|
|
11064
14037
|
});
|
|
11065
14038
|
}
|
|
11066
14039
|
} else {
|
|
11067
|
-
Object.assign(
|
|
14040
|
+
Object.assign(json2, file);
|
|
11068
14041
|
}
|
|
11069
14042
|
break;
|
|
11070
14043
|
}
|
|
@@ -11090,8 +14063,8 @@ class JSONSchemaGenerator {
|
|
|
11090
14063
|
break;
|
|
11091
14064
|
}
|
|
11092
14065
|
case "success": {
|
|
11093
|
-
const
|
|
11094
|
-
|
|
14066
|
+
const json2 = _json;
|
|
14067
|
+
json2.type = "boolean";
|
|
11095
14068
|
break;
|
|
11096
14069
|
}
|
|
11097
14070
|
case "default": {
|
|
@@ -11126,12 +14099,12 @@ class JSONSchemaGenerator {
|
|
|
11126
14099
|
break;
|
|
11127
14100
|
}
|
|
11128
14101
|
case "template_literal": {
|
|
11129
|
-
const
|
|
14102
|
+
const json2 = _json;
|
|
11130
14103
|
const pattern2 = schema2._zod.pattern;
|
|
11131
14104
|
if (!pattern2)
|
|
11132
14105
|
throw new Error("Pattern not found in template literal");
|
|
11133
|
-
|
|
11134
|
-
|
|
14106
|
+
json2.type = "string";
|
|
14107
|
+
json2.pattern = pattern2.source;
|
|
11135
14108
|
break;
|
|
11136
14109
|
}
|
|
11137
14110
|
case "pipe": {
|
|
@@ -11990,7 +14963,7 @@ const ZodObject2 = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
11990
14963
|
inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
|
|
11991
14964
|
inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
|
|
11992
14965
|
inst.extend = (incoming) => {
|
|
11993
|
-
return
|
|
14966
|
+
return extend2(inst, incoming);
|
|
11994
14967
|
};
|
|
11995
14968
|
inst.safeExtend = (incoming) => {
|
|
11996
14969
|
return safeExtend(inst, incoming);
|
|
@@ -16058,7 +19031,7 @@ function requireCode$1() {
|
|
|
16058
19031
|
}
|
|
16059
19032
|
exports$1._ = _;
|
|
16060
19033
|
const plus = new _Code("+");
|
|
16061
|
-
function
|
|
19034
|
+
function str2(strs, ...args) {
|
|
16062
19035
|
const expr = [safeStringify(strs[0])];
|
|
16063
19036
|
let i = 0;
|
|
16064
19037
|
while (i < args.length) {
|
|
@@ -16069,7 +19042,7 @@ function requireCode$1() {
|
|
|
16069
19042
|
optimize(expr);
|
|
16070
19043
|
return new _Code(expr);
|
|
16071
19044
|
}
|
|
16072
|
-
exports$1.str =
|
|
19045
|
+
exports$1.str = str2;
|
|
16073
19046
|
function addCodeArg(code2, arg) {
|
|
16074
19047
|
if (arg instanceof _Code)
|
|
16075
19048
|
code2.push(...arg._items);
|
|
@@ -16112,7 +19085,7 @@ function requireCode$1() {
|
|
|
16112
19085
|
return;
|
|
16113
19086
|
}
|
|
16114
19087
|
function strConcat(c1, c2) {
|
|
16115
|
-
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 :
|
|
19088
|
+
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str2`${c1}${c2}`;
|
|
16116
19089
|
}
|
|
16117
19090
|
exports$1.strConcat = strConcat;
|
|
16118
19091
|
function interpolate(x) {
|
|
@@ -17078,22 +20051,22 @@ function requireUtil() {
|
|
|
17078
20051
|
return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword2)}`;
|
|
17079
20052
|
}
|
|
17080
20053
|
util.schemaRefOrVal = schemaRefOrVal;
|
|
17081
|
-
function unescapeFragment(
|
|
17082
|
-
return unescapeJsonPointer(decodeURIComponent(
|
|
20054
|
+
function unescapeFragment(str2) {
|
|
20055
|
+
return unescapeJsonPointer(decodeURIComponent(str2));
|
|
17083
20056
|
}
|
|
17084
20057
|
util.unescapeFragment = unescapeFragment;
|
|
17085
|
-
function escapeFragment(
|
|
17086
|
-
return encodeURIComponent(escapeJsonPointer(
|
|
20058
|
+
function escapeFragment(str2) {
|
|
20059
|
+
return encodeURIComponent(escapeJsonPointer(str2));
|
|
17087
20060
|
}
|
|
17088
20061
|
util.escapeFragment = escapeFragment;
|
|
17089
|
-
function escapeJsonPointer(
|
|
17090
|
-
if (typeof
|
|
17091
|
-
return `${
|
|
17092
|
-
return
|
|
20062
|
+
function escapeJsonPointer(str2) {
|
|
20063
|
+
if (typeof str2 == "number")
|
|
20064
|
+
return `${str2}`;
|
|
20065
|
+
return str2.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
17093
20066
|
}
|
|
17094
20067
|
util.escapeJsonPointer = escapeJsonPointer;
|
|
17095
|
-
function unescapeJsonPointer(
|
|
17096
|
-
return
|
|
20068
|
+
function unescapeJsonPointer(str2) {
|
|
20069
|
+
return str2.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
17097
20070
|
}
|
|
17098
20071
|
util.unescapeJsonPointer = unescapeJsonPointer;
|
|
17099
20072
|
function eachItem(xs, f) {
|
|
@@ -18119,8 +21092,8 @@ function requireJsonSchemaTraverse() {
|
|
|
18119
21092
|
post(schema2, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
18120
21093
|
}
|
|
18121
21094
|
}
|
|
18122
|
-
function escapeJsonPtr(
|
|
18123
|
-
return
|
|
21095
|
+
function escapeJsonPtr(str2) {
|
|
21096
|
+
return str2.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
18124
21097
|
}
|
|
18125
21098
|
return jsonSchemaTraverse.exports;
|
|
18126
21099
|
}
|
|
@@ -19175,10 +22148,10 @@ function requireUtils() {
|
|
|
19175
22148
|
return { host, isIPV6: false };
|
|
19176
22149
|
}
|
|
19177
22150
|
}
|
|
19178
|
-
function findToken(
|
|
22151
|
+
function findToken(str2, token) {
|
|
19179
22152
|
let ind = 0;
|
|
19180
|
-
for (let i = 0; i <
|
|
19181
|
-
if (
|
|
22153
|
+
for (let i = 0; i < str2.length; i++) {
|
|
22154
|
+
if (str2[i] === token) ind++;
|
|
19182
22155
|
}
|
|
19183
22156
|
return ind;
|
|
19184
22157
|
}
|
|
@@ -19534,10 +22507,10 @@ function requireFastUri() {
|
|
|
19534
22507
|
function normalize(uri2, options) {
|
|
19535
22508
|
if (typeof uri2 === "string") {
|
|
19536
22509
|
uri2 = /** @type {T} */
|
|
19537
|
-
|
|
22510
|
+
serialize2(parse2(uri2, options), options);
|
|
19538
22511
|
} else if (typeof uri2 === "object") {
|
|
19539
22512
|
uri2 = /** @type {T} */
|
|
19540
|
-
parse2(
|
|
22513
|
+
parse2(serialize2(uri2, options), options);
|
|
19541
22514
|
}
|
|
19542
22515
|
return uri2;
|
|
19543
22516
|
}
|
|
@@ -19545,13 +22518,13 @@ function requireFastUri() {
|
|
|
19545
22518
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
19546
22519
|
const resolved = resolveComponent(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
19547
22520
|
schemelessOptions.skipEscape = true;
|
|
19548
|
-
return
|
|
22521
|
+
return serialize2(resolved, schemelessOptions);
|
|
19549
22522
|
}
|
|
19550
22523
|
function resolveComponent(base, relative, options, skipNormalization) {
|
|
19551
22524
|
const target = {};
|
|
19552
22525
|
if (!skipNormalization) {
|
|
19553
|
-
base = parse2(
|
|
19554
|
-
relative = parse2(
|
|
22526
|
+
base = parse2(serialize2(base, options), options);
|
|
22527
|
+
relative = parse2(serialize2(relative, options), options);
|
|
19555
22528
|
}
|
|
19556
22529
|
options = options || {};
|
|
19557
22530
|
if (!options.tolerant && relative.scheme) {
|
|
@@ -19603,19 +22576,19 @@ function requireFastUri() {
|
|
|
19603
22576
|
function equal2(uriA, uriB, options) {
|
|
19604
22577
|
if (typeof uriA === "string") {
|
|
19605
22578
|
uriA = unescape(uriA);
|
|
19606
|
-
uriA =
|
|
22579
|
+
uriA = serialize2(normalizeComponentEncoding(parse2(uriA, options), true), { ...options, skipEscape: true });
|
|
19607
22580
|
} else if (typeof uriA === "object") {
|
|
19608
|
-
uriA =
|
|
22581
|
+
uriA = serialize2(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
|
|
19609
22582
|
}
|
|
19610
22583
|
if (typeof uriB === "string") {
|
|
19611
22584
|
uriB = unescape(uriB);
|
|
19612
|
-
uriB =
|
|
22585
|
+
uriB = serialize2(normalizeComponentEncoding(parse2(uriB, options), true), { ...options, skipEscape: true });
|
|
19613
22586
|
} else if (typeof uriB === "object") {
|
|
19614
|
-
uriB =
|
|
22587
|
+
uriB = serialize2(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
|
|
19615
22588
|
}
|
|
19616
22589
|
return uriA.toLowerCase() === uriB.toLowerCase();
|
|
19617
22590
|
}
|
|
19618
|
-
function
|
|
22591
|
+
function serialize2(cmpts, opts) {
|
|
19619
22592
|
const component = {
|
|
19620
22593
|
host: cmpts.host,
|
|
19621
22594
|
scheme: cmpts.scheme,
|
|
@@ -19771,7 +22744,7 @@ function requireFastUri() {
|
|
|
19771
22744
|
resolve: resolve2,
|
|
19772
22745
|
resolveComponent,
|
|
19773
22746
|
equal: equal2,
|
|
19774
|
-
serialize,
|
|
22747
|
+
serialize: serialize2,
|
|
19775
22748
|
parse: parse2
|
|
19776
22749
|
};
|
|
19777
22750
|
fastUri.exports = fastUri$1;
|
|
@@ -19829,7 +22802,7 @@ function requireCore$1() {
|
|
|
19829
22802
|
const util_1 = requireUtil();
|
|
19830
22803
|
const $dataRefSchema = require$$9;
|
|
19831
22804
|
const uri_1 = requireUri();
|
|
19832
|
-
const defaultRegExp = (
|
|
22805
|
+
const defaultRegExp = (str2, flags) => new RegExp(str2, flags);
|
|
19833
22806
|
defaultRegExp.code = "new RegExp";
|
|
19834
22807
|
const META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes"];
|
|
19835
22808
|
const EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -20628,16 +23601,16 @@ function requireUcs2length() {
|
|
|
20628
23601
|
if (hasRequiredUcs2length) return ucs2length;
|
|
20629
23602
|
hasRequiredUcs2length = 1;
|
|
20630
23603
|
Object.defineProperty(ucs2length, "__esModule", { value: true });
|
|
20631
|
-
function ucs2length$1(
|
|
20632
|
-
const len =
|
|
23604
|
+
function ucs2length$1(str2) {
|
|
23605
|
+
const len = str2.length;
|
|
20633
23606
|
let length = 0;
|
|
20634
23607
|
let pos = 0;
|
|
20635
23608
|
let value;
|
|
20636
23609
|
while (pos < len) {
|
|
20637
23610
|
length++;
|
|
20638
|
-
value =
|
|
23611
|
+
value = str2.charCodeAt(pos++);
|
|
20639
23612
|
if (value >= 55296 && value <= 56319 && pos < len) {
|
|
20640
|
-
value =
|
|
23613
|
+
value = str2.charCodeAt(pos);
|
|
20641
23614
|
if ((value & 64512) === 56320)
|
|
20642
23615
|
pos++;
|
|
20643
23616
|
}
|
|
@@ -22373,8 +25346,8 @@ function requireFormats() {
|
|
|
22373
25346
|
}
|
|
22374
25347
|
const DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
22375
25348
|
const DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
22376
|
-
function date2(
|
|
22377
|
-
const matches = DATE.exec(
|
|
25349
|
+
function date2(str2) {
|
|
25350
|
+
const matches = DATE.exec(str2);
|
|
22378
25351
|
if (!matches)
|
|
22379
25352
|
return false;
|
|
22380
25353
|
const year = +matches[1];
|
|
@@ -22393,8 +25366,8 @@ function requireFormats() {
|
|
|
22393
25366
|
}
|
|
22394
25367
|
const TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
|
|
22395
25368
|
function getTime(strictTimeZone) {
|
|
22396
|
-
return function time2(
|
|
22397
|
-
const matches = TIME.exec(
|
|
25369
|
+
return function time2(str2) {
|
|
25370
|
+
const matches = TIME.exec(str2);
|
|
22398
25371
|
if (!matches)
|
|
22399
25372
|
return false;
|
|
22400
25373
|
const hr = +matches[1];
|
|
@@ -22440,8 +25413,8 @@ function requireFormats() {
|
|
|
22440
25413
|
const DATE_TIME_SEPARATOR = /t|\s/i;
|
|
22441
25414
|
function getDateTime(strictTimeZone) {
|
|
22442
25415
|
const time2 = getTime(strictTimeZone);
|
|
22443
|
-
return function date_time(
|
|
22444
|
-
const dateTime =
|
|
25416
|
+
return function date_time(str2) {
|
|
25417
|
+
const dateTime = str2.split(DATE_TIME_SEPARATOR);
|
|
22445
25418
|
return dateTime.length === 2 && date2(dateTime[0]) && time2(dateTime[1]);
|
|
22446
25419
|
};
|
|
22447
25420
|
}
|
|
@@ -22466,13 +25439,13 @@ function requireFormats() {
|
|
|
22466
25439
|
}
|
|
22467
25440
|
const NOT_URI_FRAGMENT = /\/|:/;
|
|
22468
25441
|
const URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
22469
|
-
function uri2(
|
|
22470
|
-
return NOT_URI_FRAGMENT.test(
|
|
25442
|
+
function uri2(str2) {
|
|
25443
|
+
return NOT_URI_FRAGMENT.test(str2) && URI.test(str2);
|
|
22471
25444
|
}
|
|
22472
25445
|
const BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
|
|
22473
|
-
function byte(
|
|
25446
|
+
function byte(str2) {
|
|
22474
25447
|
BYTE.lastIndex = 0;
|
|
22475
|
-
return BYTE.test(
|
|
25448
|
+
return BYTE.test(str2);
|
|
22476
25449
|
}
|
|
22477
25450
|
const MIN_INT32 = -2147483648;
|
|
22478
25451
|
const MAX_INT32 = 2 ** 31 - 1;
|
|
@@ -22486,11 +25459,11 @@ function requireFormats() {
|
|
|
22486
25459
|
return true;
|
|
22487
25460
|
}
|
|
22488
25461
|
const Z_ANCHOR = /[^\\]\\Z/;
|
|
22489
|
-
function regex(
|
|
22490
|
-
if (Z_ANCHOR.test(
|
|
25462
|
+
function regex(str2) {
|
|
25463
|
+
if (Z_ANCHOR.test(str2))
|
|
22491
25464
|
return false;
|
|
22492
25465
|
try {
|
|
22493
|
-
new RegExp(
|
|
25466
|
+
new RegExp(str2);
|
|
22494
25467
|
return true;
|
|
22495
25468
|
} catch (e) {
|
|
22496
25469
|
return false;
|
|
@@ -22603,12 +25576,12 @@ function requireDist() {
|
|
|
22603
25576
|
throw new Error(`Unknown format "${name2}"`);
|
|
22604
25577
|
return f;
|
|
22605
25578
|
};
|
|
22606
|
-
function addFormats(ajv2, list,
|
|
25579
|
+
function addFormats(ajv2, list, fs2, exportName) {
|
|
22607
25580
|
var _a2;
|
|
22608
25581
|
var _b;
|
|
22609
25582
|
(_a2 = (_b = ajv2.opts.code).formats) !== null && _a2 !== void 0 ? _a2 : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
22610
25583
|
for (const f of list)
|
|
22611
|
-
ajv2.addFormat(f,
|
|
25584
|
+
ajv2.addFormat(f, fs2[f]);
|
|
22612
25585
|
}
|
|
22613
25586
|
module.exports = exports$1 = formatsPlugin;
|
|
22614
25587
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
@@ -23172,12 +26145,12 @@ class UriTemplate {
|
|
|
23172
26145
|
* A template expression is a sequence of characters enclosed in curly braces,
|
|
23173
26146
|
* like {foo} or {?bar}.
|
|
23174
26147
|
*/
|
|
23175
|
-
static isTemplate(
|
|
23176
|
-
return /\{[^}\s]+\}/.test(
|
|
26148
|
+
static isTemplate(str2) {
|
|
26149
|
+
return /\{[^}\s]+\}/.test(str2);
|
|
23177
26150
|
}
|
|
23178
|
-
static validateLength(
|
|
23179
|
-
if (
|
|
23180
|
-
throw new Error(`${context} exceeds maximum length of ${max} characters (got ${
|
|
26151
|
+
static validateLength(str2, max, context) {
|
|
26152
|
+
if (str2.length > max) {
|
|
26153
|
+
throw new Error(`${context} exceeds maximum length of ${max} characters (got ${str2.length})`);
|
|
23181
26154
|
}
|
|
23182
26155
|
}
|
|
23183
26156
|
get variableNames() {
|
|
@@ -23306,8 +26279,8 @@ class UriTemplate {
|
|
|
23306
26279
|
}
|
|
23307
26280
|
return result;
|
|
23308
26281
|
}
|
|
23309
|
-
escapeRegExp(
|
|
23310
|
-
return
|
|
26282
|
+
escapeRegExp(str2) {
|
|
26283
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
23311
26284
|
}
|
|
23312
26285
|
partToRegExp(part) {
|
|
23313
26286
|
const patterns = [];
|
|
@@ -24335,8 +27308,8 @@ class StdioServerTransport {
|
|
|
24335
27308
|
}
|
|
24336
27309
|
send(message) {
|
|
24337
27310
|
return new Promise((resolve2) => {
|
|
24338
|
-
const
|
|
24339
|
-
if (this._stdout.write(
|
|
27311
|
+
const json2 = serializeMessage(message);
|
|
27312
|
+
if (this._stdout.write(json2)) {
|
|
24340
27313
|
resolve2();
|
|
24341
27314
|
} else {
|
|
24342
27315
|
this._stdout.once("drain", resolve2);
|
|
@@ -25022,7 +27995,7 @@ async function executeInteractiveSearch(options, context, config2) {
|
|
|
25022
27995
|
validateInteractiveOptions(options);
|
|
25023
27996
|
const { checkTTY } = await import("./tty-CDBIQraQ.js");
|
|
25024
27997
|
const { runSearchPrompt } = await import("./search-prompt-RtHDJFgL.js");
|
|
25025
|
-
const { runActionMenu } = await import("./action-menu-
|
|
27998
|
+
const { runActionMenu } = await import("./action-menu-DmRe0mqY.js");
|
|
25026
27999
|
const { search } = await import("./file-watcher-BhIAeC21.js").then((n) => n.y);
|
|
25027
28000
|
const { tokenize } = await import("./file-watcher-BhIAeC21.js").then((n) => n.x);
|
|
25028
28001
|
checkTTY();
|
|
@@ -25817,6 +28790,9 @@ async function loadConfigWithOverrides(options) {
|
|
|
25817
28790
|
return { ...config2, ...overrides };
|
|
25818
28791
|
}
|
|
25819
28792
|
function isTTY() {
|
|
28793
|
+
if (process.env.REF_SKIP_TTY_CHECK === "1") {
|
|
28794
|
+
return true;
|
|
28795
|
+
}
|
|
25820
28796
|
return Boolean(stdin.isTTY && stdout.isTTY);
|
|
25821
28797
|
}
|
|
25822
28798
|
async function readConfirmation(prompt) {
|
|
@@ -25859,6 +28835,7 @@ function createProgram() {
|
|
|
25859
28835
|
registerAddCommand(program);
|
|
25860
28836
|
registerRemoveCommand(program);
|
|
25861
28837
|
registerUpdateCommand(program);
|
|
28838
|
+
registerEditCommand(program);
|
|
25862
28839
|
registerCiteCommand(program);
|
|
25863
28840
|
registerServerCommand(program);
|
|
25864
28841
|
registerFulltextCommand(program);
|
|
@@ -26214,6 +29191,40 @@ function registerUpdateCommand(program) {
|
|
|
26214
29191
|
await handleUpdateAction(identifier, file, options, program);
|
|
26215
29192
|
});
|
|
26216
29193
|
}
|
|
29194
|
+
async function handleEditAction(identifiers, options, program) {
|
|
29195
|
+
try {
|
|
29196
|
+
if (!isTTY()) {
|
|
29197
|
+
process.stderr.write("Error: Edit command requires a TTY\n");
|
|
29198
|
+
process.exit(1);
|
|
29199
|
+
}
|
|
29200
|
+
const globalOpts = program.opts();
|
|
29201
|
+
const config2 = await loadConfigWithOverrides({ ...globalOpts, ...options });
|
|
29202
|
+
const context = await createExecutionContext(config2, Library.load);
|
|
29203
|
+
const format2 = options.format ?? config2.cli.edit.defaultFormat;
|
|
29204
|
+
const result = await executeEditCommand(
|
|
29205
|
+
{
|
|
29206
|
+
identifiers,
|
|
29207
|
+
format: format2,
|
|
29208
|
+
...options.uuid && { useUuid: true },
|
|
29209
|
+
...options.editor && { editor: options.editor }
|
|
29210
|
+
},
|
|
29211
|
+
context
|
|
29212
|
+
);
|
|
29213
|
+
const output = formatEditOutput(result);
|
|
29214
|
+
process.stderr.write(`${output}
|
|
29215
|
+
`);
|
|
29216
|
+
process.exit(result.success ? 0 : 1);
|
|
29217
|
+
} catch (error) {
|
|
29218
|
+
process.stderr.write(`Error: ${error instanceof Error ? error.message : String(error)}
|
|
29219
|
+
`);
|
|
29220
|
+
process.exit(4);
|
|
29221
|
+
}
|
|
29222
|
+
}
|
|
29223
|
+
function registerEditCommand(program) {
|
|
29224
|
+
program.command("edit").description("Edit references interactively using an external editor").argument("<identifier...>", "Citation keys or UUIDs to edit").option("--uuid", "Interpret identifiers as UUIDs").option("-f, --format <format>", "Edit format: yaml (default), json").option("--editor <editor>", "Editor command (overrides $VISUAL/$EDITOR)").action(async (identifiers, options) => {
|
|
29225
|
+
await handleEditAction(identifiers, options, program);
|
|
29226
|
+
});
|
|
29227
|
+
}
|
|
26217
29228
|
async function handleCiteAction(identifiers, options, program) {
|
|
26218
29229
|
try {
|
|
26219
29230
|
const globalOpts = program.opts();
|
|
@@ -26520,4 +29531,4 @@ export {
|
|
|
26520
29531
|
formatBibtex as f,
|
|
26521
29532
|
main as m
|
|
26522
29533
|
};
|
|
26523
|
-
//# sourceMappingURL=index-
|
|
29534
|
+
//# sourceMappingURL=index-HNDp6ifk.js.map
|