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