opencode-manifold 0.4.2 → 0.4.3
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/index.js +3025 -193
- package/package.json +6 -2
- package/src/templates/agents/clerk.md +22 -0
- package/src/templates/agents/debug.md +16 -0
- package/src/templates/agents/junior-dev.md +14 -0
- package/src/templates/agents/manifold.md +53 -27
- package/src/templates/agents/senior-dev.md +14 -0
- package/src/templates/agents/todo.md +159 -0
- package/src/templates/config/opencode.json +2 -21
- package/src/templates/manifold/schema.md +76 -6
- package/src/templates/skills/clerk-orchestration/SKILL.md +31 -0
- package/src/templates/skills/manifold-workflow/SKILL.md +80 -18
- package/src/templates/skills/wiki-ingest/SKILL.md +14 -4
- package/src/templates/skills/wiki-query/SKILL.md +3 -4
package/dist/index.js
CHANGED
|
@@ -55,15 +55,6 @@ async function mergeOpencodeConfig(projectDir) {
|
|
|
55
55
|
existing.agent.manifold = templateConfig.agent.manifold;
|
|
56
56
|
changed = true;
|
|
57
57
|
}
|
|
58
|
-
if (templateConfig.permission) {
|
|
59
|
-
for (const [key, value] of Object.entries(templateConfig.permission)) {
|
|
60
|
-
if (!existing.permission?.[key]) {
|
|
61
|
-
existing.permission = existing.permission || {};
|
|
62
|
-
existing.permission[key] = value;
|
|
63
|
-
changed = true;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
58
|
if (changed) {
|
|
68
59
|
await writeFile(configPath, JSON.stringify(existing, null, 2));
|
|
69
60
|
}
|
|
@@ -149,13 +140,13 @@ async function initProject(directory, client) {
|
|
|
149
140
|
// src/tools/dispatch-task.ts
|
|
150
141
|
import { tool } from "@opencode-ai/plugin";
|
|
151
142
|
import { readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
152
|
-
import { existsSync as
|
|
153
|
-
import { join as
|
|
143
|
+
import { existsSync as existsSync5 } from "fs";
|
|
144
|
+
import { join as join5 } from "path";
|
|
154
145
|
|
|
155
146
|
// src/state-machine.ts
|
|
156
147
|
import { readFile as readFile3, writeFile as writeFile3, readdir as readdir2 } from "fs/promises";
|
|
157
|
-
import { existsSync as
|
|
158
|
-
import { join as
|
|
148
|
+
import { existsSync as existsSync4 } from "fs";
|
|
149
|
+
import { join as join4 } from "path";
|
|
159
150
|
|
|
160
151
|
// src/session-spawner.ts
|
|
161
152
|
async function waitForSessionIdle(client, sessionId, timeoutMs) {
|
|
@@ -357,207 +348,3039 @@ async function retryWithBackoff(fn, options) {
|
|
|
357
348
|
}
|
|
358
349
|
|
|
359
350
|
// src/graph.ts
|
|
360
|
-
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
351
|
+
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
361
352
|
import { existsSync as existsSync2 } from "fs";
|
|
362
|
-
import { join as join2 } from "path";
|
|
363
|
-
|
|
364
|
-
|
|
353
|
+
import { join as join2, dirname as dirname2 } from "path";
|
|
354
|
+
|
|
355
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
356
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
357
|
+
function isNothing(subject) {
|
|
358
|
+
return typeof subject === "undefined" || subject === null;
|
|
365
359
|
}
|
|
366
|
-
function
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
if (trimmed === "## Calls") {
|
|
385
|
-
inSection = "calls";
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
if (trimmed === "## Depends On") {
|
|
389
|
-
inSection = "dependsOn";
|
|
390
|
-
continue;
|
|
391
|
-
}
|
|
392
|
-
if (trimmed === "## Tasks That Edited") {
|
|
393
|
-
inSection = "tasks";
|
|
394
|
-
continue;
|
|
395
|
-
}
|
|
396
|
-
if (trimmed.startsWith("- [[") && trimmed.endsWith("]]")) {
|
|
397
|
-
const ref = trimmed.slice(4, -2).trim();
|
|
398
|
-
if (inSection === "calls") {
|
|
399
|
-
entry.calls.push(ref);
|
|
400
|
-
} else if (inSection === "dependsOn") {
|
|
401
|
-
entry.dependsOn.push(ref);
|
|
402
|
-
} else if (inSection === "tasks") {
|
|
403
|
-
entry.tasksThatEdited.push(ref);
|
|
404
|
-
}
|
|
405
|
-
} else if (trimmed.startsWith("- `") && trimmed.endsWith("`")) {
|
|
406
|
-
const ref = trimmed.slice(3, -1).trim();
|
|
407
|
-
if (inSection === "calls" && !entry.calls.includes(ref)) {
|
|
408
|
-
entry.calls.push(ref);
|
|
409
|
-
} else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref)) {
|
|
410
|
-
entry.dependsOn.push(ref);
|
|
411
|
-
}
|
|
412
|
-
} else if (trimmed.startsWith("- ")) {
|
|
413
|
-
const ref = trimmed.slice(2).trim();
|
|
414
|
-
if (inSection === "calls" && !entry.calls.includes(ref)) {
|
|
415
|
-
entry.calls.push(ref);
|
|
416
|
-
} else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref)) {
|
|
417
|
-
entry.dependsOn.push(ref);
|
|
418
|
-
} else if (inSection === "tasks" && !entry.tasksThatEdited.includes(ref)) {
|
|
419
|
-
entry.tasksThatEdited.push(ref);
|
|
420
|
-
}
|
|
360
|
+
function isObject(subject) {
|
|
361
|
+
return typeof subject === "object" && subject !== null;
|
|
362
|
+
}
|
|
363
|
+
function toArray(sequence) {
|
|
364
|
+
if (Array.isArray(sequence))
|
|
365
|
+
return sequence;
|
|
366
|
+
else if (isNothing(sequence))
|
|
367
|
+
return [];
|
|
368
|
+
return [sequence];
|
|
369
|
+
}
|
|
370
|
+
function extend(target, source) {
|
|
371
|
+
var index, length, key, sourceKeys;
|
|
372
|
+
if (source) {
|
|
373
|
+
sourceKeys = Object.keys(source);
|
|
374
|
+
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
375
|
+
key = sourceKeys[index];
|
|
376
|
+
target[key] = source[key];
|
|
421
377
|
}
|
|
422
378
|
}
|
|
423
|
-
|
|
424
|
-
|
|
379
|
+
return target;
|
|
380
|
+
}
|
|
381
|
+
function repeat(string, count) {
|
|
382
|
+
var result = "", cycle;
|
|
383
|
+
for (cycle = 0;cycle < count; cycle += 1) {
|
|
384
|
+
result += string;
|
|
425
385
|
}
|
|
426
|
-
return
|
|
386
|
+
return result;
|
|
427
387
|
}
|
|
428
|
-
function
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
388
|
+
function isNegativeZero(number) {
|
|
389
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
390
|
+
}
|
|
391
|
+
var isNothing_1 = isNothing;
|
|
392
|
+
var isObject_1 = isObject;
|
|
393
|
+
var toArray_1 = toArray;
|
|
394
|
+
var repeat_1 = repeat;
|
|
395
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
396
|
+
var extend_1 = extend;
|
|
397
|
+
var common = {
|
|
398
|
+
isNothing: isNothing_1,
|
|
399
|
+
isObject: isObject_1,
|
|
400
|
+
toArray: toArray_1,
|
|
401
|
+
repeat: repeat_1,
|
|
402
|
+
isNegativeZero: isNegativeZero_1,
|
|
403
|
+
extend: extend_1
|
|
404
|
+
};
|
|
405
|
+
function formatError(exception, compact) {
|
|
406
|
+
var where = "", message = exception.reason || "(unknown reason)";
|
|
407
|
+
if (!exception.mark)
|
|
408
|
+
return message;
|
|
409
|
+
if (exception.mark.name) {
|
|
410
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
411
|
+
}
|
|
412
|
+
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
413
|
+
if (!compact && exception.mark.snippet) {
|
|
414
|
+
where += `
|
|
415
|
+
|
|
416
|
+
` + exception.mark.snippet;
|
|
417
|
+
}
|
|
418
|
+
return message + " " + where;
|
|
419
|
+
}
|
|
420
|
+
function YAMLException$1(reason, mark) {
|
|
421
|
+
Error.call(this);
|
|
422
|
+
this.name = "YAMLException";
|
|
423
|
+
this.reason = reason;
|
|
424
|
+
this.mark = mark;
|
|
425
|
+
this.message = formatError(this, false);
|
|
426
|
+
if (Error.captureStackTrace) {
|
|
427
|
+
Error.captureStackTrace(this, this.constructor);
|
|
428
|
+
} else {
|
|
429
|
+
this.stack = new Error().stack || "";
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
433
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
434
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
435
|
+
return this.name + ": " + formatError(this, compact);
|
|
436
|
+
};
|
|
437
|
+
var exception = YAMLException$1;
|
|
438
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
439
|
+
var head = "";
|
|
440
|
+
var tail = "";
|
|
441
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
442
|
+
if (position - lineStart > maxHalfLength) {
|
|
443
|
+
head = " ... ";
|
|
444
|
+
lineStart = position - maxHalfLength + head.length;
|
|
445
|
+
}
|
|
446
|
+
if (lineEnd - position > maxHalfLength) {
|
|
447
|
+
tail = " ...";
|
|
448
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
449
|
+
}
|
|
450
|
+
return {
|
|
451
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
452
|
+
pos: position - lineStart + head.length
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function padStart(string, max) {
|
|
456
|
+
return common.repeat(" ", max - string.length) + string;
|
|
457
|
+
}
|
|
458
|
+
function makeSnippet(mark, options) {
|
|
459
|
+
options = Object.create(options || null);
|
|
460
|
+
if (!mark.buffer)
|
|
461
|
+
return null;
|
|
462
|
+
if (!options.maxLength)
|
|
463
|
+
options.maxLength = 79;
|
|
464
|
+
if (typeof options.indent !== "number")
|
|
465
|
+
options.indent = 1;
|
|
466
|
+
if (typeof options.linesBefore !== "number")
|
|
467
|
+
options.linesBefore = 3;
|
|
468
|
+
if (typeof options.linesAfter !== "number")
|
|
469
|
+
options.linesAfter = 2;
|
|
470
|
+
var re = /\r?\n|\r|\0/g;
|
|
471
|
+
var lineStarts = [0];
|
|
472
|
+
var lineEnds = [];
|
|
473
|
+
var match;
|
|
474
|
+
var foundLineNo = -1;
|
|
475
|
+
while (match = re.exec(mark.buffer)) {
|
|
476
|
+
lineEnds.push(match.index);
|
|
477
|
+
lineStarts.push(match.index + match[0].length);
|
|
478
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
479
|
+
foundLineNo = lineStarts.length - 2;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (foundLineNo < 0)
|
|
483
|
+
foundLineNo = lineStarts.length - 1;
|
|
484
|
+
var result = "", i, line;
|
|
485
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
486
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
487
|
+
for (i = 1;i <= options.linesBefore; i++) {
|
|
488
|
+
if (foundLineNo - i < 0)
|
|
489
|
+
break;
|
|
490
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
491
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
492
|
+
` + result;
|
|
493
|
+
}
|
|
494
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
495
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
432
496
|
`;
|
|
433
|
-
|
|
434
|
-
` + entry.dependsOn.map((d) => `- ${d}`).join(`
|
|
435
|
-
`) : `## Depends On
|
|
497
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + `
|
|
436
498
|
`;
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
499
|
+
for (i = 1;i <= options.linesAfter; i++) {
|
|
500
|
+
if (foundLineNo + i >= lineEnds.length)
|
|
501
|
+
break;
|
|
502
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
503
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
440
504
|
`;
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
${callsSection}
|
|
444
|
-
|
|
445
|
-
${dependsSection}
|
|
446
|
-
|
|
447
|
-
${tasksSection}
|
|
448
|
-
`.trim();
|
|
505
|
+
}
|
|
506
|
+
return result.replace(/\n$/, "");
|
|
449
507
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
508
|
+
var snippet = makeSnippet;
|
|
509
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
510
|
+
"kind",
|
|
511
|
+
"multi",
|
|
512
|
+
"resolve",
|
|
513
|
+
"construct",
|
|
514
|
+
"instanceOf",
|
|
515
|
+
"predicate",
|
|
516
|
+
"represent",
|
|
517
|
+
"representName",
|
|
518
|
+
"defaultStyle",
|
|
519
|
+
"styleAliases"
|
|
520
|
+
];
|
|
521
|
+
var YAML_NODE_KINDS = [
|
|
522
|
+
"scalar",
|
|
523
|
+
"sequence",
|
|
524
|
+
"mapping"
|
|
525
|
+
];
|
|
526
|
+
function compileStyleAliases(map) {
|
|
527
|
+
var result = {};
|
|
528
|
+
if (map !== null) {
|
|
529
|
+
Object.keys(map).forEach(function(style) {
|
|
530
|
+
map[style].forEach(function(alias) {
|
|
531
|
+
result[String(alias)] = style;
|
|
532
|
+
});
|
|
533
|
+
});
|
|
455
534
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
535
|
+
return result;
|
|
536
|
+
}
|
|
537
|
+
function Type$1(tag, options) {
|
|
538
|
+
options = options || {};
|
|
539
|
+
Object.keys(options).forEach(function(name) {
|
|
540
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
541
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
this.options = options;
|
|
545
|
+
this.tag = tag;
|
|
546
|
+
this.kind = options["kind"] || null;
|
|
547
|
+
this.resolve = options["resolve"] || function() {
|
|
548
|
+
return true;
|
|
549
|
+
};
|
|
550
|
+
this.construct = options["construct"] || function(data) {
|
|
551
|
+
return data;
|
|
552
|
+
};
|
|
553
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
554
|
+
this.predicate = options["predicate"] || null;
|
|
555
|
+
this.represent = options["represent"] || null;
|
|
556
|
+
this.representName = options["representName"] || null;
|
|
557
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
558
|
+
this.multi = options["multi"] || false;
|
|
559
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
560
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
561
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
461
562
|
}
|
|
462
563
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
564
|
+
var type = Type$1;
|
|
565
|
+
function compileList(schema, name) {
|
|
566
|
+
var result = [];
|
|
567
|
+
schema[name].forEach(function(currentType) {
|
|
568
|
+
var newIndex = result.length;
|
|
569
|
+
result.forEach(function(previousType, previousIndex) {
|
|
570
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
571
|
+
newIndex = previousIndex;
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
result[newIndex] = currentType;
|
|
575
|
+
});
|
|
576
|
+
return result;
|
|
577
|
+
}
|
|
578
|
+
function compileMap() {
|
|
579
|
+
var result = {
|
|
580
|
+
scalar: {},
|
|
581
|
+
sequence: {},
|
|
582
|
+
mapping: {},
|
|
583
|
+
fallback: {},
|
|
584
|
+
multi: {
|
|
585
|
+
scalar: [],
|
|
586
|
+
sequence: [],
|
|
587
|
+
mapping: [],
|
|
588
|
+
fallback: []
|
|
589
|
+
}
|
|
590
|
+
}, index, length;
|
|
591
|
+
function collectType(type2) {
|
|
592
|
+
if (type2.multi) {
|
|
593
|
+
result.multi[type2.kind].push(type2);
|
|
594
|
+
result.multi["fallback"].push(type2);
|
|
595
|
+
} else {
|
|
596
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
600
|
+
arguments[index].forEach(collectType);
|
|
601
|
+
}
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
function Schema$1(definition) {
|
|
605
|
+
return this.extend(definition);
|
|
606
|
+
}
|
|
607
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
608
|
+
var implicit = [];
|
|
609
|
+
var explicit = [];
|
|
610
|
+
if (definition instanceof type) {
|
|
611
|
+
explicit.push(definition);
|
|
612
|
+
} else if (Array.isArray(definition)) {
|
|
613
|
+
explicit = explicit.concat(definition);
|
|
614
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
615
|
+
if (definition.implicit)
|
|
616
|
+
implicit = implicit.concat(definition.implicit);
|
|
617
|
+
if (definition.explicit)
|
|
618
|
+
explicit = explicit.concat(definition.explicit);
|
|
475
619
|
} else {
|
|
476
|
-
|
|
477
|
-
filePath,
|
|
478
|
-
calls: calls || [],
|
|
479
|
-
dependsOn: dependsOn || [],
|
|
480
|
-
tasksThatEdited: []
|
|
481
|
-
};
|
|
620
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
482
621
|
}
|
|
483
|
-
|
|
484
|
-
|
|
622
|
+
implicit.forEach(function(type$1) {
|
|
623
|
+
if (!(type$1 instanceof type)) {
|
|
624
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
625
|
+
}
|
|
626
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
627
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
628
|
+
}
|
|
629
|
+
if (type$1.multi) {
|
|
630
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
explicit.forEach(function(type$1) {
|
|
634
|
+
if (!(type$1 instanceof type)) {
|
|
635
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
var result = Object.create(Schema$1.prototype);
|
|
639
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
640
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
641
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
642
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
643
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
644
|
+
return result;
|
|
645
|
+
};
|
|
646
|
+
var schema = Schema$1;
|
|
647
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
648
|
+
kind: "scalar",
|
|
649
|
+
construct: function(data) {
|
|
650
|
+
return data !== null ? data : "";
|
|
485
651
|
}
|
|
486
|
-
|
|
487
|
-
|
|
652
|
+
});
|
|
653
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
654
|
+
kind: "sequence",
|
|
655
|
+
construct: function(data) {
|
|
656
|
+
return data !== null ? data : [];
|
|
488
657
|
}
|
|
489
|
-
|
|
490
|
-
|
|
658
|
+
});
|
|
659
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
660
|
+
kind: "mapping",
|
|
661
|
+
construct: function(data) {
|
|
662
|
+
return data !== null ? data : {};
|
|
491
663
|
}
|
|
492
|
-
|
|
493
|
-
|
|
664
|
+
});
|
|
665
|
+
var failsafe = new schema({
|
|
666
|
+
explicit: [
|
|
667
|
+
str,
|
|
668
|
+
seq,
|
|
669
|
+
map
|
|
670
|
+
]
|
|
671
|
+
});
|
|
672
|
+
function resolveYamlNull(data) {
|
|
673
|
+
if (data === null)
|
|
674
|
+
return true;
|
|
675
|
+
var max = data.length;
|
|
676
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
494
677
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
678
|
+
function constructYamlNull() {
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
681
|
+
function isNull(object) {
|
|
682
|
+
return object === null;
|
|
683
|
+
}
|
|
684
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
685
|
+
kind: "scalar",
|
|
686
|
+
resolve: resolveYamlNull,
|
|
687
|
+
construct: constructYamlNull,
|
|
688
|
+
predicate: isNull,
|
|
689
|
+
represent: {
|
|
690
|
+
canonical: function() {
|
|
691
|
+
return "~";
|
|
692
|
+
},
|
|
693
|
+
lowercase: function() {
|
|
694
|
+
return "null";
|
|
695
|
+
},
|
|
696
|
+
uppercase: function() {
|
|
697
|
+
return "NULL";
|
|
698
|
+
},
|
|
699
|
+
camelcase: function() {
|
|
700
|
+
return "Null";
|
|
701
|
+
},
|
|
702
|
+
empty: function() {
|
|
703
|
+
return "";
|
|
704
|
+
}
|
|
705
|
+
},
|
|
706
|
+
defaultStyle: "lowercase"
|
|
707
|
+
});
|
|
708
|
+
function resolveYamlBoolean(data) {
|
|
709
|
+
if (data === null)
|
|
710
|
+
return false;
|
|
711
|
+
var max = data.length;
|
|
712
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
713
|
+
}
|
|
714
|
+
function constructYamlBoolean(data) {
|
|
715
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
716
|
+
}
|
|
717
|
+
function isBoolean(object) {
|
|
718
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
719
|
+
}
|
|
720
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
721
|
+
kind: "scalar",
|
|
722
|
+
resolve: resolveYamlBoolean,
|
|
723
|
+
construct: constructYamlBoolean,
|
|
724
|
+
predicate: isBoolean,
|
|
725
|
+
represent: {
|
|
726
|
+
lowercase: function(object) {
|
|
727
|
+
return object ? "true" : "false";
|
|
728
|
+
},
|
|
729
|
+
uppercase: function(object) {
|
|
730
|
+
return object ? "TRUE" : "FALSE";
|
|
731
|
+
},
|
|
732
|
+
camelcase: function(object) {
|
|
733
|
+
return object ? "True" : "False";
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
defaultStyle: "lowercase"
|
|
737
|
+
});
|
|
738
|
+
function isHexCode(c) {
|
|
739
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
740
|
+
}
|
|
741
|
+
function isOctCode(c) {
|
|
742
|
+
return 48 <= c && c <= 55;
|
|
743
|
+
}
|
|
744
|
+
function isDecCode(c) {
|
|
745
|
+
return 48 <= c && c <= 57;
|
|
746
|
+
}
|
|
747
|
+
function resolveYamlInteger(data) {
|
|
748
|
+
if (data === null)
|
|
749
|
+
return false;
|
|
750
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
751
|
+
if (!max)
|
|
752
|
+
return false;
|
|
753
|
+
ch = data[index];
|
|
754
|
+
if (ch === "-" || ch === "+") {
|
|
755
|
+
ch = data[++index];
|
|
756
|
+
}
|
|
757
|
+
if (ch === "0") {
|
|
758
|
+
if (index + 1 === max)
|
|
759
|
+
return true;
|
|
760
|
+
ch = data[++index];
|
|
761
|
+
if (ch === "b") {
|
|
762
|
+
index++;
|
|
763
|
+
for (;index < max; index++) {
|
|
764
|
+
ch = data[index];
|
|
765
|
+
if (ch === "_")
|
|
766
|
+
continue;
|
|
767
|
+
if (ch !== "0" && ch !== "1")
|
|
768
|
+
return false;
|
|
769
|
+
hasDigits = true;
|
|
770
|
+
}
|
|
771
|
+
return hasDigits && ch !== "_";
|
|
772
|
+
}
|
|
773
|
+
if (ch === "x") {
|
|
774
|
+
index++;
|
|
775
|
+
for (;index < max; index++) {
|
|
776
|
+
ch = data[index];
|
|
777
|
+
if (ch === "_")
|
|
778
|
+
continue;
|
|
779
|
+
if (!isHexCode(data.charCodeAt(index)))
|
|
780
|
+
return false;
|
|
781
|
+
hasDigits = true;
|
|
782
|
+
}
|
|
783
|
+
return hasDigits && ch !== "_";
|
|
784
|
+
}
|
|
785
|
+
if (ch === "o") {
|
|
786
|
+
index++;
|
|
787
|
+
for (;index < max; index++) {
|
|
788
|
+
ch = data[index];
|
|
789
|
+
if (ch === "_")
|
|
790
|
+
continue;
|
|
791
|
+
if (!isOctCode(data.charCodeAt(index)))
|
|
792
|
+
return false;
|
|
793
|
+
hasDigits = true;
|
|
794
|
+
}
|
|
795
|
+
return hasDigits && ch !== "_";
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
if (ch === "_")
|
|
799
|
+
return false;
|
|
800
|
+
for (;index < max; index++) {
|
|
801
|
+
ch = data[index];
|
|
802
|
+
if (ch === "_")
|
|
803
|
+
continue;
|
|
804
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
805
|
+
return false;
|
|
501
806
|
}
|
|
807
|
+
hasDigits = true;
|
|
502
808
|
}
|
|
809
|
+
if (!hasDigits || ch === "_")
|
|
810
|
+
return false;
|
|
811
|
+
return true;
|
|
503
812
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
if (existsSync3(statePath)) {
|
|
509
|
-
const content = await readFile3(statePath, "utf-8");
|
|
510
|
-
return JSON.parse(content);
|
|
813
|
+
function constructYamlInteger(data) {
|
|
814
|
+
var value = data, sign = 1, ch;
|
|
815
|
+
if (value.indexOf("_") !== -1) {
|
|
816
|
+
value = value.replace(/_/g, "");
|
|
511
817
|
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
818
|
+
ch = value[0];
|
|
819
|
+
if (ch === "-" || ch === "+") {
|
|
820
|
+
if (ch === "-")
|
|
821
|
+
sign = -1;
|
|
822
|
+
value = value.slice(1);
|
|
823
|
+
ch = value[0];
|
|
824
|
+
}
|
|
825
|
+
if (value === "0")
|
|
826
|
+
return 0;
|
|
827
|
+
if (ch === "0") {
|
|
828
|
+
if (value[1] === "b")
|
|
829
|
+
return sign * parseInt(value.slice(2), 2);
|
|
830
|
+
if (value[1] === "x")
|
|
831
|
+
return sign * parseInt(value.slice(2), 16);
|
|
832
|
+
if (value[1] === "o")
|
|
833
|
+
return sign * parseInt(value.slice(2), 8);
|
|
834
|
+
}
|
|
835
|
+
return sign * parseInt(value, 10);
|
|
523
836
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
await writeFile3(statePath, JSON.stringify(state, null, 2));
|
|
837
|
+
function isInteger(object) {
|
|
838
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
527
839
|
}
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
840
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
841
|
+
kind: "scalar",
|
|
842
|
+
resolve: resolveYamlInteger,
|
|
843
|
+
construct: constructYamlInteger,
|
|
844
|
+
predicate: isInteger,
|
|
845
|
+
represent: {
|
|
846
|
+
binary: function(obj) {
|
|
847
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
848
|
+
},
|
|
849
|
+
octal: function(obj) {
|
|
850
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
851
|
+
},
|
|
852
|
+
decimal: function(obj) {
|
|
853
|
+
return obj.toString(10);
|
|
854
|
+
},
|
|
855
|
+
hexadecimal: function(obj) {
|
|
856
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
857
|
+
}
|
|
858
|
+
},
|
|
859
|
+
defaultStyle: "decimal",
|
|
860
|
+
styleAliases: {
|
|
861
|
+
binary: [2, "bin"],
|
|
862
|
+
octal: [8, "oct"],
|
|
863
|
+
decimal: [10, "dec"],
|
|
864
|
+
hexadecimal: [16, "hex"]
|
|
531
865
|
}
|
|
532
|
-
|
|
533
|
-
$
|
|
534
|
-
|
|
535
|
-
|
|
866
|
+
});
|
|
867
|
+
var YAML_FLOAT_PATTERN = new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?" + "|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?" + "|[-+]?\\.(?:inf|Inf|INF)" + "|\\.(?:nan|NaN|NAN))$");
|
|
868
|
+
function resolveYamlFloat(data) {
|
|
869
|
+
if (data === null)
|
|
870
|
+
return false;
|
|
871
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
return true;
|
|
536
875
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
876
|
+
function constructYamlFloat(data) {
|
|
877
|
+
var value, sign;
|
|
878
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
879
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
880
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
881
|
+
value = value.slice(1);
|
|
541
882
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
const tasks = await Promise.all(recentFiles.map(async (filename) => {
|
|
547
|
-
const content = await readFile3(join3(tasksDir, filename), "utf-8");
|
|
548
|
-
return { filename, content };
|
|
549
|
-
}));
|
|
550
|
-
return tasks;
|
|
551
|
-
} catch {
|
|
552
|
-
return [];
|
|
883
|
+
if (value === ".inf") {
|
|
884
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
885
|
+
} else if (value === ".nan") {
|
|
886
|
+
return NaN;
|
|
553
887
|
}
|
|
888
|
+
return sign * parseFloat(value, 10);
|
|
554
889
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
890
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
891
|
+
function representYamlFloat(object, style) {
|
|
892
|
+
var res;
|
|
893
|
+
if (isNaN(object)) {
|
|
894
|
+
switch (style) {
|
|
895
|
+
case "lowercase":
|
|
896
|
+
return ".nan";
|
|
897
|
+
case "uppercase":
|
|
898
|
+
return ".NAN";
|
|
899
|
+
case "camelcase":
|
|
900
|
+
return ".NaN";
|
|
901
|
+
}
|
|
902
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
903
|
+
switch (style) {
|
|
904
|
+
case "lowercase":
|
|
905
|
+
return ".inf";
|
|
906
|
+
case "uppercase":
|
|
907
|
+
return ".INF";
|
|
908
|
+
case "camelcase":
|
|
909
|
+
return ".Inf";
|
|
910
|
+
}
|
|
911
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
912
|
+
switch (style) {
|
|
913
|
+
case "lowercase":
|
|
914
|
+
return "-.inf";
|
|
915
|
+
case "uppercase":
|
|
916
|
+
return "-.INF";
|
|
917
|
+
case "camelcase":
|
|
918
|
+
return "-.Inf";
|
|
919
|
+
}
|
|
920
|
+
} else if (common.isNegativeZero(object)) {
|
|
921
|
+
return "-0.0";
|
|
922
|
+
}
|
|
923
|
+
res = object.toString(10);
|
|
924
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
925
|
+
}
|
|
926
|
+
function isFloat(object) {
|
|
927
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
928
|
+
}
|
|
929
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
930
|
+
kind: "scalar",
|
|
931
|
+
resolve: resolveYamlFloat,
|
|
932
|
+
construct: constructYamlFloat,
|
|
933
|
+
predicate: isFloat,
|
|
934
|
+
represent: representYamlFloat,
|
|
935
|
+
defaultStyle: "lowercase"
|
|
936
|
+
});
|
|
937
|
+
var json = failsafe.extend({
|
|
938
|
+
implicit: [
|
|
939
|
+
_null,
|
|
940
|
+
bool,
|
|
941
|
+
int,
|
|
942
|
+
float
|
|
943
|
+
]
|
|
944
|
+
});
|
|
945
|
+
var core = json;
|
|
946
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
947
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp("^([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]))?))?$");
|
|
948
|
+
function resolveYamlTimestamp(data) {
|
|
949
|
+
if (data === null)
|
|
950
|
+
return false;
|
|
951
|
+
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
952
|
+
return true;
|
|
953
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
954
|
+
return true;
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
function constructYamlTimestamp(data) {
|
|
958
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
959
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
960
|
+
if (match === null)
|
|
961
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
962
|
+
if (match === null)
|
|
963
|
+
throw new Error("Date resolve error");
|
|
964
|
+
year = +match[1];
|
|
965
|
+
month = +match[2] - 1;
|
|
966
|
+
day = +match[3];
|
|
967
|
+
if (!match[4]) {
|
|
968
|
+
return new Date(Date.UTC(year, month, day));
|
|
969
|
+
}
|
|
970
|
+
hour = +match[4];
|
|
971
|
+
minute = +match[5];
|
|
972
|
+
second = +match[6];
|
|
973
|
+
if (match[7]) {
|
|
974
|
+
fraction = match[7].slice(0, 3);
|
|
975
|
+
while (fraction.length < 3) {
|
|
976
|
+
fraction += "0";
|
|
977
|
+
}
|
|
978
|
+
fraction = +fraction;
|
|
979
|
+
}
|
|
980
|
+
if (match[9]) {
|
|
981
|
+
tz_hour = +match[10];
|
|
982
|
+
tz_minute = +(match[11] || 0);
|
|
983
|
+
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
984
|
+
if (match[9] === "-")
|
|
985
|
+
delta = -delta;
|
|
986
|
+
}
|
|
987
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
988
|
+
if (delta)
|
|
989
|
+
date.setTime(date.getTime() - delta);
|
|
990
|
+
return date;
|
|
991
|
+
}
|
|
992
|
+
function representYamlTimestamp(object) {
|
|
993
|
+
return object.toISOString();
|
|
994
|
+
}
|
|
995
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
996
|
+
kind: "scalar",
|
|
997
|
+
resolve: resolveYamlTimestamp,
|
|
998
|
+
construct: constructYamlTimestamp,
|
|
999
|
+
instanceOf: Date,
|
|
1000
|
+
represent: representYamlTimestamp
|
|
1001
|
+
});
|
|
1002
|
+
function resolveYamlMerge(data) {
|
|
1003
|
+
return data === "<<" || data === null;
|
|
1004
|
+
}
|
|
1005
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
1006
|
+
kind: "scalar",
|
|
1007
|
+
resolve: resolveYamlMerge
|
|
1008
|
+
});
|
|
1009
|
+
var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
1010
|
+
\r`;
|
|
1011
|
+
function resolveYamlBinary(data) {
|
|
1012
|
+
if (data === null)
|
|
1013
|
+
return false;
|
|
1014
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
1015
|
+
for (idx = 0;idx < max; idx++) {
|
|
1016
|
+
code = map2.indexOf(data.charAt(idx));
|
|
1017
|
+
if (code > 64)
|
|
1018
|
+
continue;
|
|
1019
|
+
if (code < 0)
|
|
1020
|
+
return false;
|
|
1021
|
+
bitlen += 6;
|
|
1022
|
+
}
|
|
1023
|
+
return bitlen % 8 === 0;
|
|
1024
|
+
}
|
|
1025
|
+
function constructYamlBinary(data) {
|
|
1026
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
1027
|
+
for (idx = 0;idx < max; idx++) {
|
|
1028
|
+
if (idx % 4 === 0 && idx) {
|
|
1029
|
+
result.push(bits >> 16 & 255);
|
|
1030
|
+
result.push(bits >> 8 & 255);
|
|
1031
|
+
result.push(bits & 255);
|
|
1032
|
+
}
|
|
1033
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
1034
|
+
}
|
|
1035
|
+
tailbits = max % 4 * 6;
|
|
1036
|
+
if (tailbits === 0) {
|
|
1037
|
+
result.push(bits >> 16 & 255);
|
|
1038
|
+
result.push(bits >> 8 & 255);
|
|
1039
|
+
result.push(bits & 255);
|
|
1040
|
+
} else if (tailbits === 18) {
|
|
1041
|
+
result.push(bits >> 10 & 255);
|
|
1042
|
+
result.push(bits >> 2 & 255);
|
|
1043
|
+
} else if (tailbits === 12) {
|
|
1044
|
+
result.push(bits >> 4 & 255);
|
|
1045
|
+
}
|
|
1046
|
+
return new Uint8Array(result);
|
|
1047
|
+
}
|
|
1048
|
+
function representYamlBinary(object) {
|
|
1049
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
1050
|
+
for (idx = 0;idx < max; idx++) {
|
|
1051
|
+
if (idx % 3 === 0 && idx) {
|
|
1052
|
+
result += map2[bits >> 18 & 63];
|
|
1053
|
+
result += map2[bits >> 12 & 63];
|
|
1054
|
+
result += map2[bits >> 6 & 63];
|
|
1055
|
+
result += map2[bits & 63];
|
|
1056
|
+
}
|
|
1057
|
+
bits = (bits << 8) + object[idx];
|
|
1058
|
+
}
|
|
1059
|
+
tail = max % 3;
|
|
1060
|
+
if (tail === 0) {
|
|
1061
|
+
result += map2[bits >> 18 & 63];
|
|
1062
|
+
result += map2[bits >> 12 & 63];
|
|
1063
|
+
result += map2[bits >> 6 & 63];
|
|
1064
|
+
result += map2[bits & 63];
|
|
1065
|
+
} else if (tail === 2) {
|
|
1066
|
+
result += map2[bits >> 10 & 63];
|
|
1067
|
+
result += map2[bits >> 4 & 63];
|
|
1068
|
+
result += map2[bits << 2 & 63];
|
|
1069
|
+
result += map2[64];
|
|
1070
|
+
} else if (tail === 1) {
|
|
1071
|
+
result += map2[bits >> 2 & 63];
|
|
1072
|
+
result += map2[bits << 4 & 63];
|
|
1073
|
+
result += map2[64];
|
|
1074
|
+
result += map2[64];
|
|
1075
|
+
}
|
|
1076
|
+
return result;
|
|
1077
|
+
}
|
|
1078
|
+
function isBinary(obj) {
|
|
1079
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
1080
|
+
}
|
|
1081
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
1082
|
+
kind: "scalar",
|
|
1083
|
+
resolve: resolveYamlBinary,
|
|
1084
|
+
construct: constructYamlBinary,
|
|
1085
|
+
predicate: isBinary,
|
|
1086
|
+
represent: representYamlBinary
|
|
1087
|
+
});
|
|
1088
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1089
|
+
var _toString$2 = Object.prototype.toString;
|
|
1090
|
+
function resolveYamlOmap(data) {
|
|
1091
|
+
if (data === null)
|
|
1092
|
+
return true;
|
|
1093
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
1094
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1095
|
+
pair = object[index];
|
|
1096
|
+
pairHasKey = false;
|
|
1097
|
+
if (_toString$2.call(pair) !== "[object Object]")
|
|
1098
|
+
return false;
|
|
1099
|
+
for (pairKey in pair) {
|
|
1100
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
1101
|
+
if (!pairHasKey)
|
|
1102
|
+
pairHasKey = true;
|
|
1103
|
+
else
|
|
1104
|
+
return false;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
if (!pairHasKey)
|
|
1108
|
+
return false;
|
|
1109
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
1110
|
+
objectKeys.push(pairKey);
|
|
1111
|
+
else
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
function constructYamlOmap(data) {
|
|
1117
|
+
return data !== null ? data : [];
|
|
1118
|
+
}
|
|
1119
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
1120
|
+
kind: "sequence",
|
|
1121
|
+
resolve: resolveYamlOmap,
|
|
1122
|
+
construct: constructYamlOmap
|
|
1123
|
+
});
|
|
1124
|
+
var _toString$1 = Object.prototype.toString;
|
|
1125
|
+
function resolveYamlPairs(data) {
|
|
1126
|
+
if (data === null)
|
|
1127
|
+
return true;
|
|
1128
|
+
var index, length, pair, keys, result, object = data;
|
|
1129
|
+
result = new Array(object.length);
|
|
1130
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1131
|
+
pair = object[index];
|
|
1132
|
+
if (_toString$1.call(pair) !== "[object Object]")
|
|
1133
|
+
return false;
|
|
1134
|
+
keys = Object.keys(pair);
|
|
1135
|
+
if (keys.length !== 1)
|
|
1136
|
+
return false;
|
|
1137
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1138
|
+
}
|
|
1139
|
+
return true;
|
|
1140
|
+
}
|
|
1141
|
+
function constructYamlPairs(data) {
|
|
1142
|
+
if (data === null)
|
|
1143
|
+
return [];
|
|
1144
|
+
var index, length, pair, keys, result, object = data;
|
|
1145
|
+
result = new Array(object.length);
|
|
1146
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1147
|
+
pair = object[index];
|
|
1148
|
+
keys = Object.keys(pair);
|
|
1149
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
1150
|
+
}
|
|
1151
|
+
return result;
|
|
1152
|
+
}
|
|
1153
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
1154
|
+
kind: "sequence",
|
|
1155
|
+
resolve: resolveYamlPairs,
|
|
1156
|
+
construct: constructYamlPairs
|
|
1157
|
+
});
|
|
1158
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1159
|
+
function resolveYamlSet(data) {
|
|
1160
|
+
if (data === null)
|
|
1161
|
+
return true;
|
|
1162
|
+
var key, object = data;
|
|
1163
|
+
for (key in object) {
|
|
1164
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
1165
|
+
if (object[key] !== null)
|
|
1166
|
+
return false;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
return true;
|
|
1170
|
+
}
|
|
1171
|
+
function constructYamlSet(data) {
|
|
1172
|
+
return data !== null ? data : {};
|
|
1173
|
+
}
|
|
1174
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
1175
|
+
kind: "mapping",
|
|
1176
|
+
resolve: resolveYamlSet,
|
|
1177
|
+
construct: constructYamlSet
|
|
1178
|
+
});
|
|
1179
|
+
var _default = core.extend({
|
|
1180
|
+
implicit: [
|
|
1181
|
+
timestamp,
|
|
1182
|
+
merge
|
|
1183
|
+
],
|
|
1184
|
+
explicit: [
|
|
1185
|
+
binary,
|
|
1186
|
+
omap,
|
|
1187
|
+
pairs,
|
|
1188
|
+
set
|
|
1189
|
+
]
|
|
1190
|
+
});
|
|
1191
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1192
|
+
var CONTEXT_FLOW_IN = 1;
|
|
1193
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
1194
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
1195
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
1196
|
+
var CHOMPING_CLIP = 1;
|
|
1197
|
+
var CHOMPING_STRIP = 2;
|
|
1198
|
+
var CHOMPING_KEEP = 3;
|
|
1199
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1200
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1201
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1202
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1203
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1204
|
+
function _class(obj) {
|
|
1205
|
+
return Object.prototype.toString.call(obj);
|
|
1206
|
+
}
|
|
1207
|
+
function is_EOL(c) {
|
|
1208
|
+
return c === 10 || c === 13;
|
|
1209
|
+
}
|
|
1210
|
+
function is_WHITE_SPACE(c) {
|
|
1211
|
+
return c === 9 || c === 32;
|
|
1212
|
+
}
|
|
1213
|
+
function is_WS_OR_EOL(c) {
|
|
1214
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1215
|
+
}
|
|
1216
|
+
function is_FLOW_INDICATOR(c) {
|
|
1217
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1218
|
+
}
|
|
1219
|
+
function fromHexCode(c) {
|
|
1220
|
+
var lc;
|
|
1221
|
+
if (48 <= c && c <= 57) {
|
|
1222
|
+
return c - 48;
|
|
1223
|
+
}
|
|
1224
|
+
lc = c | 32;
|
|
1225
|
+
if (97 <= lc && lc <= 102) {
|
|
1226
|
+
return lc - 97 + 10;
|
|
1227
|
+
}
|
|
1228
|
+
return -1;
|
|
1229
|
+
}
|
|
1230
|
+
function escapedHexLen(c) {
|
|
1231
|
+
if (c === 120) {
|
|
1232
|
+
return 2;
|
|
1233
|
+
}
|
|
1234
|
+
if (c === 117) {
|
|
1235
|
+
return 4;
|
|
1236
|
+
}
|
|
1237
|
+
if (c === 85) {
|
|
1238
|
+
return 8;
|
|
1239
|
+
}
|
|
1240
|
+
return 0;
|
|
1241
|
+
}
|
|
1242
|
+
function fromDecimalCode(c) {
|
|
1243
|
+
if (48 <= c && c <= 57) {
|
|
1244
|
+
return c - 48;
|
|
1245
|
+
}
|
|
1246
|
+
return -1;
|
|
1247
|
+
}
|
|
1248
|
+
function simpleEscapeSequence(c) {
|
|
1249
|
+
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
1250
|
+
` : 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" : "";
|
|
1251
|
+
}
|
|
1252
|
+
function charFromCodepoint(c) {
|
|
1253
|
+
if (c <= 65535) {
|
|
1254
|
+
return String.fromCharCode(c);
|
|
1255
|
+
}
|
|
1256
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1257
|
+
}
|
|
1258
|
+
function setProperty(object, key, value) {
|
|
1259
|
+
if (key === "__proto__") {
|
|
1260
|
+
Object.defineProperty(object, key, {
|
|
1261
|
+
configurable: true,
|
|
1262
|
+
enumerable: true,
|
|
1263
|
+
writable: true,
|
|
1264
|
+
value
|
|
1265
|
+
});
|
|
1266
|
+
} else {
|
|
1267
|
+
object[key] = value;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
var simpleEscapeCheck = new Array(256);
|
|
1271
|
+
var simpleEscapeMap = new Array(256);
|
|
1272
|
+
for (i = 0;i < 256; i++) {
|
|
1273
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1274
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1275
|
+
}
|
|
1276
|
+
var i;
|
|
1277
|
+
function State$1(input, options) {
|
|
1278
|
+
this.input = input;
|
|
1279
|
+
this.filename = options["filename"] || null;
|
|
1280
|
+
this.schema = options["schema"] || _default;
|
|
1281
|
+
this.onWarning = options["onWarning"] || null;
|
|
1282
|
+
this.legacy = options["legacy"] || false;
|
|
1283
|
+
this.json = options["json"] || false;
|
|
1284
|
+
this.listener = options["listener"] || null;
|
|
1285
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
1286
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
1287
|
+
this.length = input.length;
|
|
1288
|
+
this.position = 0;
|
|
1289
|
+
this.line = 0;
|
|
1290
|
+
this.lineStart = 0;
|
|
1291
|
+
this.lineIndent = 0;
|
|
1292
|
+
this.firstTabInLine = -1;
|
|
1293
|
+
this.documents = [];
|
|
1294
|
+
}
|
|
1295
|
+
function generateError(state, message) {
|
|
1296
|
+
var mark = {
|
|
1297
|
+
name: state.filename,
|
|
1298
|
+
buffer: state.input.slice(0, -1),
|
|
1299
|
+
position: state.position,
|
|
1300
|
+
line: state.line,
|
|
1301
|
+
column: state.position - state.lineStart
|
|
1302
|
+
};
|
|
1303
|
+
mark.snippet = snippet(mark);
|
|
1304
|
+
return new exception(message, mark);
|
|
1305
|
+
}
|
|
1306
|
+
function throwError(state, message) {
|
|
1307
|
+
throw generateError(state, message);
|
|
1308
|
+
}
|
|
1309
|
+
function throwWarning(state, message) {
|
|
1310
|
+
if (state.onWarning) {
|
|
1311
|
+
state.onWarning.call(null, generateError(state, message));
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
var directiveHandlers = {
|
|
1315
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
1316
|
+
var match, major, minor;
|
|
1317
|
+
if (state.version !== null) {
|
|
1318
|
+
throwError(state, "duplication of %YAML directive");
|
|
1319
|
+
}
|
|
1320
|
+
if (args.length !== 1) {
|
|
1321
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
1322
|
+
}
|
|
1323
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1324
|
+
if (match === null) {
|
|
1325
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
1326
|
+
}
|
|
1327
|
+
major = parseInt(match[1], 10);
|
|
1328
|
+
minor = parseInt(match[2], 10);
|
|
1329
|
+
if (major !== 1) {
|
|
1330
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
1331
|
+
}
|
|
1332
|
+
state.version = args[0];
|
|
1333
|
+
state.checkLineBreaks = minor < 2;
|
|
1334
|
+
if (minor !== 1 && minor !== 2) {
|
|
1335
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
1336
|
+
}
|
|
1337
|
+
},
|
|
1338
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
1339
|
+
var handle, prefix;
|
|
1340
|
+
if (args.length !== 2) {
|
|
1341
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1342
|
+
}
|
|
1343
|
+
handle = args[0];
|
|
1344
|
+
prefix = args[1];
|
|
1345
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1346
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1347
|
+
}
|
|
1348
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1349
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1350
|
+
}
|
|
1351
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1352
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1353
|
+
}
|
|
1354
|
+
try {
|
|
1355
|
+
prefix = decodeURIComponent(prefix);
|
|
1356
|
+
} catch (err) {
|
|
1357
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1358
|
+
}
|
|
1359
|
+
state.tagMap[handle] = prefix;
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1362
|
+
function captureSegment(state, start, end, checkJson) {
|
|
1363
|
+
var _position, _length, _character, _result;
|
|
1364
|
+
if (start < end) {
|
|
1365
|
+
_result = state.input.slice(start, end);
|
|
1366
|
+
if (checkJson) {
|
|
1367
|
+
for (_position = 0, _length = _result.length;_position < _length; _position += 1) {
|
|
1368
|
+
_character = _result.charCodeAt(_position);
|
|
1369
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1370
|
+
throwError(state, "expected valid JSON character");
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1374
|
+
throwError(state, "the stream contains non-printable characters");
|
|
1375
|
+
}
|
|
1376
|
+
state.result += _result;
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1380
|
+
var sourceKeys, key, index, quantity;
|
|
1381
|
+
if (!common.isObject(source)) {
|
|
1382
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1383
|
+
}
|
|
1384
|
+
sourceKeys = Object.keys(source);
|
|
1385
|
+
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
1386
|
+
key = sourceKeys[index];
|
|
1387
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1388
|
+
setProperty(destination, key, source[key]);
|
|
1389
|
+
overridableKeys[key] = true;
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1394
|
+
var index, quantity;
|
|
1395
|
+
if (Array.isArray(keyNode)) {
|
|
1396
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
1397
|
+
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
1398
|
+
if (Array.isArray(keyNode[index])) {
|
|
1399
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
1400
|
+
}
|
|
1401
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1402
|
+
keyNode[index] = "[object Object]";
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1407
|
+
keyNode = "[object Object]";
|
|
1408
|
+
}
|
|
1409
|
+
keyNode = String(keyNode);
|
|
1410
|
+
if (_result === null) {
|
|
1411
|
+
_result = {};
|
|
1412
|
+
}
|
|
1413
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1414
|
+
if (Array.isArray(valueNode)) {
|
|
1415
|
+
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
1416
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1417
|
+
}
|
|
1418
|
+
} else {
|
|
1419
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1420
|
+
}
|
|
1421
|
+
} else {
|
|
1422
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1423
|
+
state.line = startLine || state.line;
|
|
1424
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
1425
|
+
state.position = startPos || state.position;
|
|
1426
|
+
throwError(state, "duplicated mapping key");
|
|
1427
|
+
}
|
|
1428
|
+
setProperty(_result, keyNode, valueNode);
|
|
1429
|
+
delete overridableKeys[keyNode];
|
|
1430
|
+
}
|
|
1431
|
+
return _result;
|
|
1432
|
+
}
|
|
1433
|
+
function readLineBreak(state) {
|
|
1434
|
+
var ch;
|
|
1435
|
+
ch = state.input.charCodeAt(state.position);
|
|
1436
|
+
if (ch === 10) {
|
|
1437
|
+
state.position++;
|
|
1438
|
+
} else if (ch === 13) {
|
|
1439
|
+
state.position++;
|
|
1440
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
1441
|
+
state.position++;
|
|
1442
|
+
}
|
|
1443
|
+
} else {
|
|
1444
|
+
throwError(state, "a line break is expected");
|
|
1445
|
+
}
|
|
1446
|
+
state.line += 1;
|
|
1447
|
+
state.lineStart = state.position;
|
|
1448
|
+
state.firstTabInLine = -1;
|
|
1449
|
+
}
|
|
1450
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1451
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1452
|
+
while (ch !== 0) {
|
|
1453
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1454
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1455
|
+
state.firstTabInLine = state.position;
|
|
1456
|
+
}
|
|
1457
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1458
|
+
}
|
|
1459
|
+
if (allowComments && ch === 35) {
|
|
1460
|
+
do {
|
|
1461
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1462
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1463
|
+
}
|
|
1464
|
+
if (is_EOL(ch)) {
|
|
1465
|
+
readLineBreak(state);
|
|
1466
|
+
ch = state.input.charCodeAt(state.position);
|
|
1467
|
+
lineBreaks++;
|
|
1468
|
+
state.lineIndent = 0;
|
|
1469
|
+
while (ch === 32) {
|
|
1470
|
+
state.lineIndent++;
|
|
1471
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1472
|
+
}
|
|
1473
|
+
} else {
|
|
1474
|
+
break;
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1478
|
+
throwWarning(state, "deficient indentation");
|
|
1479
|
+
}
|
|
1480
|
+
return lineBreaks;
|
|
1481
|
+
}
|
|
1482
|
+
function testDocumentSeparator(state) {
|
|
1483
|
+
var _position = state.position, ch;
|
|
1484
|
+
ch = state.input.charCodeAt(_position);
|
|
1485
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1486
|
+
_position += 3;
|
|
1487
|
+
ch = state.input.charCodeAt(_position);
|
|
1488
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1489
|
+
return true;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
return false;
|
|
1493
|
+
}
|
|
1494
|
+
function writeFoldedLines(state, count) {
|
|
1495
|
+
if (count === 1) {
|
|
1496
|
+
state.result += " ";
|
|
1497
|
+
} else if (count > 1) {
|
|
1498
|
+
state.result += common.repeat(`
|
|
1499
|
+
`, count - 1);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1503
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1504
|
+
ch = state.input.charCodeAt(state.position);
|
|
1505
|
+
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) {
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
if (ch === 63 || ch === 45) {
|
|
1509
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1510
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1511
|
+
return false;
|
|
1512
|
+
}
|
|
1513
|
+
}
|
|
1514
|
+
state.kind = "scalar";
|
|
1515
|
+
state.result = "";
|
|
1516
|
+
captureStart = captureEnd = state.position;
|
|
1517
|
+
hasPendingContent = false;
|
|
1518
|
+
while (ch !== 0) {
|
|
1519
|
+
if (ch === 58) {
|
|
1520
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1521
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1522
|
+
break;
|
|
1523
|
+
}
|
|
1524
|
+
} else if (ch === 35) {
|
|
1525
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
1526
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1529
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1530
|
+
break;
|
|
1531
|
+
} else if (is_EOL(ch)) {
|
|
1532
|
+
_line = state.line;
|
|
1533
|
+
_lineStart = state.lineStart;
|
|
1534
|
+
_lineIndent = state.lineIndent;
|
|
1535
|
+
skipSeparationSpace(state, false, -1);
|
|
1536
|
+
if (state.lineIndent >= nodeIndent) {
|
|
1537
|
+
hasPendingContent = true;
|
|
1538
|
+
ch = state.input.charCodeAt(state.position);
|
|
1539
|
+
continue;
|
|
1540
|
+
} else {
|
|
1541
|
+
state.position = captureEnd;
|
|
1542
|
+
state.line = _line;
|
|
1543
|
+
state.lineStart = _lineStart;
|
|
1544
|
+
state.lineIndent = _lineIndent;
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
if (hasPendingContent) {
|
|
1549
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1550
|
+
writeFoldedLines(state, state.line - _line);
|
|
1551
|
+
captureStart = captureEnd = state.position;
|
|
1552
|
+
hasPendingContent = false;
|
|
1553
|
+
}
|
|
1554
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
1555
|
+
captureEnd = state.position + 1;
|
|
1556
|
+
}
|
|
1557
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1558
|
+
}
|
|
1559
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
1560
|
+
if (state.result) {
|
|
1561
|
+
return true;
|
|
1562
|
+
}
|
|
1563
|
+
state.kind = _kind;
|
|
1564
|
+
state.result = _result;
|
|
1565
|
+
return false;
|
|
1566
|
+
}
|
|
1567
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1568
|
+
var ch, captureStart, captureEnd;
|
|
1569
|
+
ch = state.input.charCodeAt(state.position);
|
|
1570
|
+
if (ch !== 39) {
|
|
1571
|
+
return false;
|
|
1572
|
+
}
|
|
1573
|
+
state.kind = "scalar";
|
|
1574
|
+
state.result = "";
|
|
1575
|
+
state.position++;
|
|
1576
|
+
captureStart = captureEnd = state.position;
|
|
1577
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1578
|
+
if (ch === 39) {
|
|
1579
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1580
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1581
|
+
if (ch === 39) {
|
|
1582
|
+
captureStart = state.position;
|
|
1583
|
+
state.position++;
|
|
1584
|
+
captureEnd = state.position;
|
|
1585
|
+
} else {
|
|
1586
|
+
return true;
|
|
1587
|
+
}
|
|
1588
|
+
} else if (is_EOL(ch)) {
|
|
1589
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1590
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1591
|
+
captureStart = captureEnd = state.position;
|
|
1592
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1593
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1594
|
+
} else {
|
|
1595
|
+
state.position++;
|
|
1596
|
+
captureEnd = state.position;
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1600
|
+
}
|
|
1601
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1602
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1603
|
+
ch = state.input.charCodeAt(state.position);
|
|
1604
|
+
if (ch !== 34) {
|
|
1605
|
+
return false;
|
|
1606
|
+
}
|
|
1607
|
+
state.kind = "scalar";
|
|
1608
|
+
state.result = "";
|
|
1609
|
+
state.position++;
|
|
1610
|
+
captureStart = captureEnd = state.position;
|
|
1611
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1612
|
+
if (ch === 34) {
|
|
1613
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1614
|
+
state.position++;
|
|
1615
|
+
return true;
|
|
1616
|
+
} else if (ch === 92) {
|
|
1617
|
+
captureSegment(state, captureStart, state.position, true);
|
|
1618
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1619
|
+
if (is_EOL(ch)) {
|
|
1620
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
1621
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1622
|
+
state.result += simpleEscapeMap[ch];
|
|
1623
|
+
state.position++;
|
|
1624
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1625
|
+
hexLength = tmp;
|
|
1626
|
+
hexResult = 0;
|
|
1627
|
+
for (;hexLength > 0; hexLength--) {
|
|
1628
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1629
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1630
|
+
hexResult = (hexResult << 4) + tmp;
|
|
1631
|
+
} else {
|
|
1632
|
+
throwError(state, "expected hexadecimal character");
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
state.result += charFromCodepoint(hexResult);
|
|
1636
|
+
state.position++;
|
|
1637
|
+
} else {
|
|
1638
|
+
throwError(state, "unknown escape sequence");
|
|
1639
|
+
}
|
|
1640
|
+
captureStart = captureEnd = state.position;
|
|
1641
|
+
} else if (is_EOL(ch)) {
|
|
1642
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
1643
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1644
|
+
captureStart = captureEnd = state.position;
|
|
1645
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1646
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1647
|
+
} else {
|
|
1648
|
+
state.position++;
|
|
1649
|
+
captureEnd = state.position;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1653
|
+
}
|
|
1654
|
+
function readFlowCollection(state, nodeIndent) {
|
|
1655
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1656
|
+
ch = state.input.charCodeAt(state.position);
|
|
1657
|
+
if (ch === 91) {
|
|
1658
|
+
terminator = 93;
|
|
1659
|
+
isMapping = false;
|
|
1660
|
+
_result = [];
|
|
1661
|
+
} else if (ch === 123) {
|
|
1662
|
+
terminator = 125;
|
|
1663
|
+
isMapping = true;
|
|
1664
|
+
_result = {};
|
|
1665
|
+
} else {
|
|
1666
|
+
return false;
|
|
1667
|
+
}
|
|
1668
|
+
if (state.anchor !== null) {
|
|
1669
|
+
state.anchorMap[state.anchor] = _result;
|
|
1670
|
+
}
|
|
1671
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1672
|
+
while (ch !== 0) {
|
|
1673
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1674
|
+
ch = state.input.charCodeAt(state.position);
|
|
1675
|
+
if (ch === terminator) {
|
|
1676
|
+
state.position++;
|
|
1677
|
+
state.tag = _tag;
|
|
1678
|
+
state.anchor = _anchor;
|
|
1679
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
1680
|
+
state.result = _result;
|
|
1681
|
+
return true;
|
|
1682
|
+
} else if (!readNext) {
|
|
1683
|
+
throwError(state, "missed comma between flow collection entries");
|
|
1684
|
+
} else if (ch === 44) {
|
|
1685
|
+
throwError(state, "expected the node content, but found ','");
|
|
1686
|
+
}
|
|
1687
|
+
keyTag = keyNode = valueNode = null;
|
|
1688
|
+
isPair = isExplicitPair = false;
|
|
1689
|
+
if (ch === 63) {
|
|
1690
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1691
|
+
if (is_WS_OR_EOL(following)) {
|
|
1692
|
+
isPair = isExplicitPair = true;
|
|
1693
|
+
state.position++;
|
|
1694
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
_line = state.line;
|
|
1698
|
+
_lineStart = state.lineStart;
|
|
1699
|
+
_pos = state.position;
|
|
1700
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1701
|
+
keyTag = state.tag;
|
|
1702
|
+
keyNode = state.result;
|
|
1703
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1704
|
+
ch = state.input.charCodeAt(state.position);
|
|
1705
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1706
|
+
isPair = true;
|
|
1707
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1708
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1709
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1710
|
+
valueNode = state.result;
|
|
1711
|
+
}
|
|
1712
|
+
if (isMapping) {
|
|
1713
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1714
|
+
} else if (isPair) {
|
|
1715
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1716
|
+
} else {
|
|
1717
|
+
_result.push(keyNode);
|
|
1718
|
+
}
|
|
1719
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
1720
|
+
ch = state.input.charCodeAt(state.position);
|
|
1721
|
+
if (ch === 44) {
|
|
1722
|
+
readNext = true;
|
|
1723
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1724
|
+
} else {
|
|
1725
|
+
readNext = false;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1729
|
+
}
|
|
1730
|
+
function readBlockScalar(state, nodeIndent) {
|
|
1731
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1732
|
+
ch = state.input.charCodeAt(state.position);
|
|
1733
|
+
if (ch === 124) {
|
|
1734
|
+
folding = false;
|
|
1735
|
+
} else if (ch === 62) {
|
|
1736
|
+
folding = true;
|
|
1737
|
+
} else {
|
|
1738
|
+
return false;
|
|
1739
|
+
}
|
|
1740
|
+
state.kind = "scalar";
|
|
1741
|
+
state.result = "";
|
|
1742
|
+
while (ch !== 0) {
|
|
1743
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1744
|
+
if (ch === 43 || ch === 45) {
|
|
1745
|
+
if (CHOMPING_CLIP === chomping) {
|
|
1746
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1747
|
+
} else {
|
|
1748
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
1749
|
+
}
|
|
1750
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1751
|
+
if (tmp === 0) {
|
|
1752
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1753
|
+
} else if (!detectedIndent) {
|
|
1754
|
+
textIndent = nodeIndent + tmp - 1;
|
|
1755
|
+
detectedIndent = true;
|
|
1756
|
+
} else {
|
|
1757
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
1758
|
+
}
|
|
1759
|
+
} else {
|
|
1760
|
+
break;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1764
|
+
do {
|
|
1765
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1766
|
+
} while (is_WHITE_SPACE(ch));
|
|
1767
|
+
if (ch === 35) {
|
|
1768
|
+
do {
|
|
1769
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1770
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
while (ch !== 0) {
|
|
1774
|
+
readLineBreak(state);
|
|
1775
|
+
state.lineIndent = 0;
|
|
1776
|
+
ch = state.input.charCodeAt(state.position);
|
|
1777
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1778
|
+
state.lineIndent++;
|
|
1779
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1780
|
+
}
|
|
1781
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1782
|
+
textIndent = state.lineIndent;
|
|
1783
|
+
}
|
|
1784
|
+
if (is_EOL(ch)) {
|
|
1785
|
+
emptyLines++;
|
|
1786
|
+
continue;
|
|
1787
|
+
}
|
|
1788
|
+
if (state.lineIndent < textIndent) {
|
|
1789
|
+
if (chomping === CHOMPING_KEEP) {
|
|
1790
|
+
state.result += common.repeat(`
|
|
1791
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1792
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
1793
|
+
if (didReadContent) {
|
|
1794
|
+
state.result += `
|
|
1795
|
+
`;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
break;
|
|
1799
|
+
}
|
|
1800
|
+
if (folding) {
|
|
1801
|
+
if (is_WHITE_SPACE(ch)) {
|
|
1802
|
+
atMoreIndented = true;
|
|
1803
|
+
state.result += common.repeat(`
|
|
1804
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1805
|
+
} else if (atMoreIndented) {
|
|
1806
|
+
atMoreIndented = false;
|
|
1807
|
+
state.result += common.repeat(`
|
|
1808
|
+
`, emptyLines + 1);
|
|
1809
|
+
} else if (emptyLines === 0) {
|
|
1810
|
+
if (didReadContent) {
|
|
1811
|
+
state.result += " ";
|
|
1812
|
+
}
|
|
1813
|
+
} else {
|
|
1814
|
+
state.result += common.repeat(`
|
|
1815
|
+
`, emptyLines);
|
|
1816
|
+
}
|
|
1817
|
+
} else {
|
|
1818
|
+
state.result += common.repeat(`
|
|
1819
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1820
|
+
}
|
|
1821
|
+
didReadContent = true;
|
|
1822
|
+
detectedIndent = true;
|
|
1823
|
+
emptyLines = 0;
|
|
1824
|
+
captureStart = state.position;
|
|
1825
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
1826
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1827
|
+
}
|
|
1828
|
+
captureSegment(state, captureStart, state.position, false);
|
|
1829
|
+
}
|
|
1830
|
+
return true;
|
|
1831
|
+
}
|
|
1832
|
+
function readBlockSequence(state, nodeIndent) {
|
|
1833
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1834
|
+
if (state.firstTabInLine !== -1)
|
|
1835
|
+
return false;
|
|
1836
|
+
if (state.anchor !== null) {
|
|
1837
|
+
state.anchorMap[state.anchor] = _result;
|
|
1838
|
+
}
|
|
1839
|
+
ch = state.input.charCodeAt(state.position);
|
|
1840
|
+
while (ch !== 0) {
|
|
1841
|
+
if (state.firstTabInLine !== -1) {
|
|
1842
|
+
state.position = state.firstTabInLine;
|
|
1843
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1844
|
+
}
|
|
1845
|
+
if (ch !== 45) {
|
|
1846
|
+
break;
|
|
1847
|
+
}
|
|
1848
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1849
|
+
if (!is_WS_OR_EOL(following)) {
|
|
1850
|
+
break;
|
|
1851
|
+
}
|
|
1852
|
+
detected = true;
|
|
1853
|
+
state.position++;
|
|
1854
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
1855
|
+
if (state.lineIndent <= nodeIndent) {
|
|
1856
|
+
_result.push(null);
|
|
1857
|
+
ch = state.input.charCodeAt(state.position);
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
_line = state.line;
|
|
1862
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1863
|
+
_result.push(state.result);
|
|
1864
|
+
skipSeparationSpace(state, true, -1);
|
|
1865
|
+
ch = state.input.charCodeAt(state.position);
|
|
1866
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1867
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
1868
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1869
|
+
break;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
if (detected) {
|
|
1873
|
+
state.tag = _tag;
|
|
1874
|
+
state.anchor = _anchor;
|
|
1875
|
+
state.kind = "sequence";
|
|
1876
|
+
state.result = _result;
|
|
1877
|
+
return true;
|
|
1878
|
+
}
|
|
1879
|
+
return false;
|
|
1880
|
+
}
|
|
1881
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1882
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1883
|
+
if (state.firstTabInLine !== -1)
|
|
1884
|
+
return false;
|
|
1885
|
+
if (state.anchor !== null) {
|
|
1886
|
+
state.anchorMap[state.anchor] = _result;
|
|
1887
|
+
}
|
|
1888
|
+
ch = state.input.charCodeAt(state.position);
|
|
1889
|
+
while (ch !== 0) {
|
|
1890
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1891
|
+
state.position = state.firstTabInLine;
|
|
1892
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
1893
|
+
}
|
|
1894
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
1895
|
+
_line = state.line;
|
|
1896
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1897
|
+
if (ch === 63) {
|
|
1898
|
+
if (atExplicitKey) {
|
|
1899
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1900
|
+
keyTag = keyNode = valueNode = null;
|
|
1901
|
+
}
|
|
1902
|
+
detected = true;
|
|
1903
|
+
atExplicitKey = true;
|
|
1904
|
+
allowCompact = true;
|
|
1905
|
+
} else if (atExplicitKey) {
|
|
1906
|
+
atExplicitKey = false;
|
|
1907
|
+
allowCompact = true;
|
|
1908
|
+
} else {
|
|
1909
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1910
|
+
}
|
|
1911
|
+
state.position += 1;
|
|
1912
|
+
ch = following;
|
|
1913
|
+
} else {
|
|
1914
|
+
_keyLine = state.line;
|
|
1915
|
+
_keyLineStart = state.lineStart;
|
|
1916
|
+
_keyPos = state.position;
|
|
1917
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1918
|
+
break;
|
|
1919
|
+
}
|
|
1920
|
+
if (state.line === _line) {
|
|
1921
|
+
ch = state.input.charCodeAt(state.position);
|
|
1922
|
+
while (is_WHITE_SPACE(ch)) {
|
|
1923
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1924
|
+
}
|
|
1925
|
+
if (ch === 58) {
|
|
1926
|
+
ch = state.input.charCodeAt(++state.position);
|
|
1927
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
1928
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1929
|
+
}
|
|
1930
|
+
if (atExplicitKey) {
|
|
1931
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1932
|
+
keyTag = keyNode = valueNode = null;
|
|
1933
|
+
}
|
|
1934
|
+
detected = true;
|
|
1935
|
+
atExplicitKey = false;
|
|
1936
|
+
allowCompact = false;
|
|
1937
|
+
keyTag = state.tag;
|
|
1938
|
+
keyNode = state.result;
|
|
1939
|
+
} else if (detected) {
|
|
1940
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1941
|
+
} else {
|
|
1942
|
+
state.tag = _tag;
|
|
1943
|
+
state.anchor = _anchor;
|
|
1944
|
+
return true;
|
|
1945
|
+
}
|
|
1946
|
+
} else if (detected) {
|
|
1947
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1948
|
+
} else {
|
|
1949
|
+
state.tag = _tag;
|
|
1950
|
+
state.anchor = _anchor;
|
|
1951
|
+
return true;
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1955
|
+
if (atExplicitKey) {
|
|
1956
|
+
_keyLine = state.line;
|
|
1957
|
+
_keyLineStart = state.lineStart;
|
|
1958
|
+
_keyPos = state.position;
|
|
1959
|
+
}
|
|
1960
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1961
|
+
if (atExplicitKey) {
|
|
1962
|
+
keyNode = state.result;
|
|
1963
|
+
} else {
|
|
1964
|
+
valueNode = state.result;
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
if (!atExplicitKey) {
|
|
1968
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1969
|
+
keyTag = keyNode = valueNode = null;
|
|
1970
|
+
}
|
|
1971
|
+
skipSeparationSpace(state, true, -1);
|
|
1972
|
+
ch = state.input.charCodeAt(state.position);
|
|
1973
|
+
}
|
|
1974
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1975
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
1976
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
1977
|
+
break;
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
1980
|
+
if (atExplicitKey) {
|
|
1981
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1982
|
+
}
|
|
1983
|
+
if (detected) {
|
|
1984
|
+
state.tag = _tag;
|
|
1985
|
+
state.anchor = _anchor;
|
|
1986
|
+
state.kind = "mapping";
|
|
1987
|
+
state.result = _result;
|
|
1988
|
+
}
|
|
1989
|
+
return detected;
|
|
1990
|
+
}
|
|
1991
|
+
function readTagProperty(state) {
|
|
1992
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1993
|
+
ch = state.input.charCodeAt(state.position);
|
|
1994
|
+
if (ch !== 33)
|
|
1995
|
+
return false;
|
|
1996
|
+
if (state.tag !== null) {
|
|
1997
|
+
throwError(state, "duplication of a tag property");
|
|
1998
|
+
}
|
|
1999
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2000
|
+
if (ch === 60) {
|
|
2001
|
+
isVerbatim = true;
|
|
2002
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2003
|
+
} else if (ch === 33) {
|
|
2004
|
+
isNamed = true;
|
|
2005
|
+
tagHandle = "!!";
|
|
2006
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2007
|
+
} else {
|
|
2008
|
+
tagHandle = "!";
|
|
2009
|
+
}
|
|
2010
|
+
_position = state.position;
|
|
2011
|
+
if (isVerbatim) {
|
|
2012
|
+
do {
|
|
2013
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2014
|
+
} while (ch !== 0 && ch !== 62);
|
|
2015
|
+
if (state.position < state.length) {
|
|
2016
|
+
tagName = state.input.slice(_position, state.position);
|
|
2017
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2018
|
+
} else {
|
|
2019
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2020
|
+
}
|
|
2021
|
+
} else {
|
|
2022
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2023
|
+
if (ch === 33) {
|
|
2024
|
+
if (!isNamed) {
|
|
2025
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2026
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2027
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
2028
|
+
}
|
|
2029
|
+
isNamed = true;
|
|
2030
|
+
_position = state.position + 1;
|
|
2031
|
+
} else {
|
|
2032
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2036
|
+
}
|
|
2037
|
+
tagName = state.input.slice(_position, state.position);
|
|
2038
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2039
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2043
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
2044
|
+
}
|
|
2045
|
+
try {
|
|
2046
|
+
tagName = decodeURIComponent(tagName);
|
|
2047
|
+
} catch (err) {
|
|
2048
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
2049
|
+
}
|
|
2050
|
+
if (isVerbatim) {
|
|
2051
|
+
state.tag = tagName;
|
|
2052
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
2053
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2054
|
+
} else if (tagHandle === "!") {
|
|
2055
|
+
state.tag = "!" + tagName;
|
|
2056
|
+
} else if (tagHandle === "!!") {
|
|
2057
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
2058
|
+
} else {
|
|
2059
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2060
|
+
}
|
|
2061
|
+
return true;
|
|
2062
|
+
}
|
|
2063
|
+
function readAnchorProperty(state) {
|
|
2064
|
+
var _position, ch;
|
|
2065
|
+
ch = state.input.charCodeAt(state.position);
|
|
2066
|
+
if (ch !== 38)
|
|
2067
|
+
return false;
|
|
2068
|
+
if (state.anchor !== null) {
|
|
2069
|
+
throwError(state, "duplication of an anchor property");
|
|
2070
|
+
}
|
|
2071
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2072
|
+
_position = state.position;
|
|
2073
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2074
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2075
|
+
}
|
|
2076
|
+
if (state.position === _position) {
|
|
2077
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
2078
|
+
}
|
|
2079
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
2080
|
+
return true;
|
|
2081
|
+
}
|
|
2082
|
+
function readAlias(state) {
|
|
2083
|
+
var _position, alias, ch;
|
|
2084
|
+
ch = state.input.charCodeAt(state.position);
|
|
2085
|
+
if (ch !== 42)
|
|
2086
|
+
return false;
|
|
2087
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2088
|
+
_position = state.position;
|
|
2089
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2090
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2091
|
+
}
|
|
2092
|
+
if (state.position === _position) {
|
|
2093
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
2094
|
+
}
|
|
2095
|
+
alias = state.input.slice(_position, state.position);
|
|
2096
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
2097
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2098
|
+
}
|
|
2099
|
+
state.result = state.anchorMap[alias];
|
|
2100
|
+
skipSeparationSpace(state, true, -1);
|
|
2101
|
+
return true;
|
|
2102
|
+
}
|
|
2103
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2104
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
2105
|
+
if (state.listener !== null) {
|
|
2106
|
+
state.listener("open", state);
|
|
2107
|
+
}
|
|
2108
|
+
state.tag = null;
|
|
2109
|
+
state.anchor = null;
|
|
2110
|
+
state.kind = null;
|
|
2111
|
+
state.result = null;
|
|
2112
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2113
|
+
if (allowToSeek) {
|
|
2114
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2115
|
+
atNewLine = true;
|
|
2116
|
+
if (state.lineIndent > parentIndent) {
|
|
2117
|
+
indentStatus = 1;
|
|
2118
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2119
|
+
indentStatus = 0;
|
|
2120
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2121
|
+
indentStatus = -1;
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
if (indentStatus === 1) {
|
|
2126
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2127
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
2128
|
+
atNewLine = true;
|
|
2129
|
+
allowBlockCollections = allowBlockStyles;
|
|
2130
|
+
if (state.lineIndent > parentIndent) {
|
|
2131
|
+
indentStatus = 1;
|
|
2132
|
+
} else if (state.lineIndent === parentIndent) {
|
|
2133
|
+
indentStatus = 0;
|
|
2134
|
+
} else if (state.lineIndent < parentIndent) {
|
|
2135
|
+
indentStatus = -1;
|
|
2136
|
+
}
|
|
2137
|
+
} else {
|
|
2138
|
+
allowBlockCollections = false;
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
if (allowBlockCollections) {
|
|
2143
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
2144
|
+
}
|
|
2145
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2146
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2147
|
+
flowIndent = parentIndent;
|
|
2148
|
+
} else {
|
|
2149
|
+
flowIndent = parentIndent + 1;
|
|
2150
|
+
}
|
|
2151
|
+
blockIndent = state.position - state.lineStart;
|
|
2152
|
+
if (indentStatus === 1) {
|
|
2153
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2154
|
+
hasContent = true;
|
|
2155
|
+
} else {
|
|
2156
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2157
|
+
hasContent = true;
|
|
2158
|
+
} else if (readAlias(state)) {
|
|
2159
|
+
hasContent = true;
|
|
2160
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
2161
|
+
throwError(state, "alias node should not have any properties");
|
|
2162
|
+
}
|
|
2163
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2164
|
+
hasContent = true;
|
|
2165
|
+
if (state.tag === null) {
|
|
2166
|
+
state.tag = "?";
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
if (state.anchor !== null) {
|
|
2170
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
} else if (indentStatus === 0) {
|
|
2174
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (state.tag === null) {
|
|
2178
|
+
if (state.anchor !== null) {
|
|
2179
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2180
|
+
}
|
|
2181
|
+
} else if (state.tag === "?") {
|
|
2182
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
2183
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2184
|
+
}
|
|
2185
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
2186
|
+
type2 = state.implicitTypes[typeIndex];
|
|
2187
|
+
if (type2.resolve(state.result)) {
|
|
2188
|
+
state.result = type2.construct(state.result);
|
|
2189
|
+
state.tag = type2.tag;
|
|
2190
|
+
if (state.anchor !== null) {
|
|
2191
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2192
|
+
}
|
|
2193
|
+
break;
|
|
2194
|
+
}
|
|
2195
|
+
}
|
|
2196
|
+
} else if (state.tag !== "!") {
|
|
2197
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2198
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2199
|
+
} else {
|
|
2200
|
+
type2 = null;
|
|
2201
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
2202
|
+
for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
2203
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2204
|
+
type2 = typeList[typeIndex];
|
|
2205
|
+
break;
|
|
2206
|
+
}
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
if (!type2) {
|
|
2210
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2211
|
+
}
|
|
2212
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
2213
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
2214
|
+
}
|
|
2215
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
2216
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2217
|
+
} else {
|
|
2218
|
+
state.result = type2.construct(state.result, state.tag);
|
|
2219
|
+
if (state.anchor !== null) {
|
|
2220
|
+
state.anchorMap[state.anchor] = state.result;
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
if (state.listener !== null) {
|
|
2225
|
+
state.listener("close", state);
|
|
2226
|
+
}
|
|
2227
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2228
|
+
}
|
|
2229
|
+
function readDocument(state) {
|
|
2230
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2231
|
+
state.version = null;
|
|
2232
|
+
state.checkLineBreaks = state.legacy;
|
|
2233
|
+
state.tagMap = Object.create(null);
|
|
2234
|
+
state.anchorMap = Object.create(null);
|
|
2235
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2236
|
+
skipSeparationSpace(state, true, -1);
|
|
2237
|
+
ch = state.input.charCodeAt(state.position);
|
|
2238
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
2239
|
+
break;
|
|
2240
|
+
}
|
|
2241
|
+
hasDirectives = true;
|
|
2242
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2243
|
+
_position = state.position;
|
|
2244
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2245
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2246
|
+
}
|
|
2247
|
+
directiveName = state.input.slice(_position, state.position);
|
|
2248
|
+
directiveArgs = [];
|
|
2249
|
+
if (directiveName.length < 1) {
|
|
2250
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
2251
|
+
}
|
|
2252
|
+
while (ch !== 0) {
|
|
2253
|
+
while (is_WHITE_SPACE(ch)) {
|
|
2254
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2255
|
+
}
|
|
2256
|
+
if (ch === 35) {
|
|
2257
|
+
do {
|
|
2258
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2259
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
2260
|
+
break;
|
|
2261
|
+
}
|
|
2262
|
+
if (is_EOL(ch))
|
|
2263
|
+
break;
|
|
2264
|
+
_position = state.position;
|
|
2265
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2266
|
+
ch = state.input.charCodeAt(++state.position);
|
|
2267
|
+
}
|
|
2268
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2269
|
+
}
|
|
2270
|
+
if (ch !== 0)
|
|
2271
|
+
readLineBreak(state);
|
|
2272
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
2273
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2274
|
+
} else {
|
|
2275
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
skipSeparationSpace(state, true, -1);
|
|
2279
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2280
|
+
state.position += 3;
|
|
2281
|
+
skipSeparationSpace(state, true, -1);
|
|
2282
|
+
} else if (hasDirectives) {
|
|
2283
|
+
throwError(state, "directives end mark is expected");
|
|
2284
|
+
}
|
|
2285
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2286
|
+
skipSeparationSpace(state, true, -1);
|
|
2287
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2288
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2289
|
+
}
|
|
2290
|
+
state.documents.push(state.result);
|
|
2291
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2292
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
2293
|
+
state.position += 3;
|
|
2294
|
+
skipSeparationSpace(state, true, -1);
|
|
2295
|
+
}
|
|
2296
|
+
return;
|
|
2297
|
+
}
|
|
2298
|
+
if (state.position < state.length - 1) {
|
|
2299
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
2300
|
+
} else {
|
|
2301
|
+
return;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
function loadDocuments(input, options) {
|
|
2305
|
+
input = String(input);
|
|
2306
|
+
options = options || {};
|
|
2307
|
+
if (input.length !== 0) {
|
|
2308
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2309
|
+
input += `
|
|
2310
|
+
`;
|
|
2311
|
+
}
|
|
2312
|
+
if (input.charCodeAt(0) === 65279) {
|
|
2313
|
+
input = input.slice(1);
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
var state = new State$1(input, options);
|
|
2317
|
+
var nullpos = input.indexOf("\x00");
|
|
2318
|
+
if (nullpos !== -1) {
|
|
2319
|
+
state.position = nullpos;
|
|
2320
|
+
throwError(state, "null byte is not allowed in input");
|
|
2321
|
+
}
|
|
2322
|
+
state.input += "\x00";
|
|
2323
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
2324
|
+
state.lineIndent += 1;
|
|
2325
|
+
state.position += 1;
|
|
2326
|
+
}
|
|
2327
|
+
while (state.position < state.length - 1) {
|
|
2328
|
+
readDocument(state);
|
|
2329
|
+
}
|
|
2330
|
+
return state.documents;
|
|
2331
|
+
}
|
|
2332
|
+
function loadAll$1(input, iterator, options) {
|
|
2333
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2334
|
+
options = iterator;
|
|
2335
|
+
iterator = null;
|
|
2336
|
+
}
|
|
2337
|
+
var documents = loadDocuments(input, options);
|
|
2338
|
+
if (typeof iterator !== "function") {
|
|
2339
|
+
return documents;
|
|
2340
|
+
}
|
|
2341
|
+
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
2342
|
+
iterator(documents[index]);
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
function load$1(input, options) {
|
|
2346
|
+
var documents = loadDocuments(input, options);
|
|
2347
|
+
if (documents.length === 0) {
|
|
2348
|
+
return;
|
|
2349
|
+
} else if (documents.length === 1) {
|
|
2350
|
+
return documents[0];
|
|
2351
|
+
}
|
|
2352
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
2353
|
+
}
|
|
2354
|
+
var loadAll_1 = loadAll$1;
|
|
2355
|
+
var load_1 = load$1;
|
|
2356
|
+
var loader = {
|
|
2357
|
+
loadAll: loadAll_1,
|
|
2358
|
+
load: load_1
|
|
2359
|
+
};
|
|
2360
|
+
var _toString = Object.prototype.toString;
|
|
2361
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2362
|
+
var CHAR_BOM = 65279;
|
|
2363
|
+
var CHAR_TAB = 9;
|
|
2364
|
+
var CHAR_LINE_FEED = 10;
|
|
2365
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
2366
|
+
var CHAR_SPACE = 32;
|
|
2367
|
+
var CHAR_EXCLAMATION = 33;
|
|
2368
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
2369
|
+
var CHAR_SHARP = 35;
|
|
2370
|
+
var CHAR_PERCENT = 37;
|
|
2371
|
+
var CHAR_AMPERSAND = 38;
|
|
2372
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
2373
|
+
var CHAR_ASTERISK = 42;
|
|
2374
|
+
var CHAR_COMMA = 44;
|
|
2375
|
+
var CHAR_MINUS = 45;
|
|
2376
|
+
var CHAR_COLON = 58;
|
|
2377
|
+
var CHAR_EQUALS = 61;
|
|
2378
|
+
var CHAR_GREATER_THAN = 62;
|
|
2379
|
+
var CHAR_QUESTION = 63;
|
|
2380
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
2381
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2382
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2383
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
2384
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2385
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
2386
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2387
|
+
var ESCAPE_SEQUENCES = {};
|
|
2388
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2389
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2390
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2391
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2392
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2393
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2394
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2395
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2396
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2397
|
+
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
2398
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2399
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2400
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2401
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2402
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2403
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2404
|
+
"y",
|
|
2405
|
+
"Y",
|
|
2406
|
+
"yes",
|
|
2407
|
+
"Yes",
|
|
2408
|
+
"YES",
|
|
2409
|
+
"on",
|
|
2410
|
+
"On",
|
|
2411
|
+
"ON",
|
|
2412
|
+
"n",
|
|
2413
|
+
"N",
|
|
2414
|
+
"no",
|
|
2415
|
+
"No",
|
|
2416
|
+
"NO",
|
|
2417
|
+
"off",
|
|
2418
|
+
"Off",
|
|
2419
|
+
"OFF"
|
|
2420
|
+
];
|
|
2421
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2422
|
+
function compileStyleMap(schema2, map2) {
|
|
2423
|
+
var result, keys, index, length, tag, style, type2;
|
|
2424
|
+
if (map2 === null)
|
|
2425
|
+
return {};
|
|
2426
|
+
result = {};
|
|
2427
|
+
keys = Object.keys(map2);
|
|
2428
|
+
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
2429
|
+
tag = keys[index];
|
|
2430
|
+
style = String(map2[tag]);
|
|
2431
|
+
if (tag.slice(0, 2) === "!!") {
|
|
2432
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2433
|
+
}
|
|
2434
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2435
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2436
|
+
style = type2.styleAliases[style];
|
|
2437
|
+
}
|
|
2438
|
+
result[tag] = style;
|
|
2439
|
+
}
|
|
2440
|
+
return result;
|
|
2441
|
+
}
|
|
2442
|
+
function encodeHex(character) {
|
|
2443
|
+
var string, handle, length;
|
|
2444
|
+
string = character.toString(16).toUpperCase();
|
|
2445
|
+
if (character <= 255) {
|
|
2446
|
+
handle = "x";
|
|
2447
|
+
length = 2;
|
|
2448
|
+
} else if (character <= 65535) {
|
|
2449
|
+
handle = "u";
|
|
2450
|
+
length = 4;
|
|
2451
|
+
} else if (character <= 4294967295) {
|
|
2452
|
+
handle = "U";
|
|
2453
|
+
length = 8;
|
|
2454
|
+
} else {
|
|
2455
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2456
|
+
}
|
|
2457
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2458
|
+
}
|
|
2459
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
2460
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
2461
|
+
function State(options) {
|
|
2462
|
+
this.schema = options["schema"] || _default;
|
|
2463
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
2464
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2465
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
2466
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2467
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2468
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
2469
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
2470
|
+
this.noRefs = options["noRefs"] || false;
|
|
2471
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
2472
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
2473
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2474
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
2475
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2476
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
2477
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
2478
|
+
this.tag = null;
|
|
2479
|
+
this.result = "";
|
|
2480
|
+
this.duplicates = [];
|
|
2481
|
+
this.usedDuplicates = null;
|
|
2482
|
+
}
|
|
2483
|
+
function indentString(string, spaces) {
|
|
2484
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2485
|
+
while (position < length) {
|
|
2486
|
+
next = string.indexOf(`
|
|
2487
|
+
`, position);
|
|
2488
|
+
if (next === -1) {
|
|
2489
|
+
line = string.slice(position);
|
|
2490
|
+
position = length;
|
|
2491
|
+
} else {
|
|
2492
|
+
line = string.slice(position, next + 1);
|
|
2493
|
+
position = next + 1;
|
|
2494
|
+
}
|
|
2495
|
+
if (line.length && line !== `
|
|
2496
|
+
`)
|
|
2497
|
+
result += ind;
|
|
2498
|
+
result += line;
|
|
2499
|
+
}
|
|
2500
|
+
return result;
|
|
2501
|
+
}
|
|
2502
|
+
function generateNextLine(state, level) {
|
|
2503
|
+
return `
|
|
2504
|
+
` + common.repeat(" ", state.indent * level);
|
|
2505
|
+
}
|
|
2506
|
+
function testImplicitResolving(state, str2) {
|
|
2507
|
+
var index, length, type2;
|
|
2508
|
+
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
2509
|
+
type2 = state.implicitTypes[index];
|
|
2510
|
+
if (type2.resolve(str2)) {
|
|
2511
|
+
return true;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
return false;
|
|
2515
|
+
}
|
|
2516
|
+
function isWhitespace(c) {
|
|
2517
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2518
|
+
}
|
|
2519
|
+
function isPrintable(c) {
|
|
2520
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2521
|
+
}
|
|
2522
|
+
function isNsCharOrWhitespace(c) {
|
|
2523
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2524
|
+
}
|
|
2525
|
+
function isPlainSafe(c, prev, inblock) {
|
|
2526
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2527
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2528
|
+
return (inblock ? cIsNsCharOrWhitespace : 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;
|
|
2529
|
+
}
|
|
2530
|
+
function isPlainSafeFirst(c) {
|
|
2531
|
+
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;
|
|
2532
|
+
}
|
|
2533
|
+
function isPlainSafeLast(c) {
|
|
2534
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2535
|
+
}
|
|
2536
|
+
function codePointAt(string, pos) {
|
|
2537
|
+
var first = string.charCodeAt(pos), second;
|
|
2538
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2539
|
+
second = string.charCodeAt(pos + 1);
|
|
2540
|
+
if (second >= 56320 && second <= 57343) {
|
|
2541
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
return first;
|
|
2545
|
+
}
|
|
2546
|
+
function needIndentIndicator(string) {
|
|
2547
|
+
var leadingSpaceRe = /^\n* /;
|
|
2548
|
+
return leadingSpaceRe.test(string);
|
|
2549
|
+
}
|
|
2550
|
+
var STYLE_PLAIN = 1;
|
|
2551
|
+
var STYLE_SINGLE = 2;
|
|
2552
|
+
var STYLE_LITERAL = 3;
|
|
2553
|
+
var STYLE_FOLDED = 4;
|
|
2554
|
+
var STYLE_DOUBLE = 5;
|
|
2555
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2556
|
+
var i2;
|
|
2557
|
+
var char = 0;
|
|
2558
|
+
var prevChar = null;
|
|
2559
|
+
var hasLineBreak = false;
|
|
2560
|
+
var hasFoldableLine = false;
|
|
2561
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
2562
|
+
var previousLineBreak = -1;
|
|
2563
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2564
|
+
if (singleLineOnly || forceQuotes) {
|
|
2565
|
+
for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2566
|
+
char = codePointAt(string, i2);
|
|
2567
|
+
if (!isPrintable(char)) {
|
|
2568
|
+
return STYLE_DOUBLE;
|
|
2569
|
+
}
|
|
2570
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2571
|
+
prevChar = char;
|
|
2572
|
+
}
|
|
2573
|
+
} else {
|
|
2574
|
+
for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2575
|
+
char = codePointAt(string, i2);
|
|
2576
|
+
if (char === CHAR_LINE_FEED) {
|
|
2577
|
+
hasLineBreak = true;
|
|
2578
|
+
if (shouldTrackWidth) {
|
|
2579
|
+
hasFoldableLine = hasFoldableLine || i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2580
|
+
previousLineBreak = i2;
|
|
2581
|
+
}
|
|
2582
|
+
} else if (!isPrintable(char)) {
|
|
2583
|
+
return STYLE_DOUBLE;
|
|
2584
|
+
}
|
|
2585
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2586
|
+
prevChar = char;
|
|
2587
|
+
}
|
|
2588
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2589
|
+
}
|
|
2590
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
2591
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2592
|
+
return STYLE_PLAIN;
|
|
2593
|
+
}
|
|
2594
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2595
|
+
}
|
|
2596
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2597
|
+
return STYLE_DOUBLE;
|
|
2598
|
+
}
|
|
2599
|
+
if (!forceQuotes) {
|
|
2600
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2601
|
+
}
|
|
2602
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2603
|
+
}
|
|
2604
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
2605
|
+
state.dump = function() {
|
|
2606
|
+
if (string.length === 0) {
|
|
2607
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2608
|
+
}
|
|
2609
|
+
if (!state.noCompatMode) {
|
|
2610
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2611
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
var indent = state.indent * Math.max(1, level);
|
|
2615
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2616
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2617
|
+
function testAmbiguity(string2) {
|
|
2618
|
+
return testImplicitResolving(state, string2);
|
|
2619
|
+
}
|
|
2620
|
+
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
2621
|
+
case STYLE_PLAIN:
|
|
2622
|
+
return string;
|
|
2623
|
+
case STYLE_SINGLE:
|
|
2624
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
2625
|
+
case STYLE_LITERAL:
|
|
2626
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2627
|
+
case STYLE_FOLDED:
|
|
2628
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2629
|
+
case STYLE_DOUBLE:
|
|
2630
|
+
return '"' + escapeString(string) + '"';
|
|
2631
|
+
default:
|
|
2632
|
+
throw new exception("impossible error: invalid scalar style");
|
|
2633
|
+
}
|
|
2634
|
+
}();
|
|
2635
|
+
}
|
|
2636
|
+
function blockHeader(string, indentPerLevel) {
|
|
2637
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2638
|
+
var clip = string[string.length - 1] === `
|
|
2639
|
+
`;
|
|
2640
|
+
var keep = clip && (string[string.length - 2] === `
|
|
2641
|
+
` || string === `
|
|
2642
|
+
`);
|
|
2643
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2644
|
+
return indentIndicator + chomp + `
|
|
2645
|
+
`;
|
|
2646
|
+
}
|
|
2647
|
+
function dropEndingNewline(string) {
|
|
2648
|
+
return string[string.length - 1] === `
|
|
2649
|
+
` ? string.slice(0, -1) : string;
|
|
2650
|
+
}
|
|
2651
|
+
function foldString(string, width) {
|
|
2652
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
2653
|
+
var result = function() {
|
|
2654
|
+
var nextLF = string.indexOf(`
|
|
2655
|
+
`);
|
|
2656
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2657
|
+
lineRe.lastIndex = nextLF;
|
|
2658
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
2659
|
+
}();
|
|
2660
|
+
var prevMoreIndented = string[0] === `
|
|
2661
|
+
` || string[0] === " ";
|
|
2662
|
+
var moreIndented;
|
|
2663
|
+
var match;
|
|
2664
|
+
while (match = lineRe.exec(string)) {
|
|
2665
|
+
var prefix = match[1], line = match[2];
|
|
2666
|
+
moreIndented = line[0] === " ";
|
|
2667
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
2668
|
+
` : "") + foldLine(line, width);
|
|
2669
|
+
prevMoreIndented = moreIndented;
|
|
2670
|
+
}
|
|
2671
|
+
return result;
|
|
2672
|
+
}
|
|
2673
|
+
function foldLine(line, width) {
|
|
2674
|
+
if (line === "" || line[0] === " ")
|
|
2675
|
+
return line;
|
|
2676
|
+
var breakRe = / [^ ]/g;
|
|
2677
|
+
var match;
|
|
2678
|
+
var start = 0, end, curr = 0, next = 0;
|
|
2679
|
+
var result = "";
|
|
2680
|
+
while (match = breakRe.exec(line)) {
|
|
2681
|
+
next = match.index;
|
|
2682
|
+
if (next - start > width) {
|
|
2683
|
+
end = curr > start ? curr : next;
|
|
2684
|
+
result += `
|
|
2685
|
+
` + line.slice(start, end);
|
|
2686
|
+
start = end + 1;
|
|
2687
|
+
}
|
|
2688
|
+
curr = next;
|
|
2689
|
+
}
|
|
2690
|
+
result += `
|
|
2691
|
+
`;
|
|
2692
|
+
if (line.length - start > width && curr > start) {
|
|
2693
|
+
result += line.slice(start, curr) + `
|
|
2694
|
+
` + line.slice(curr + 1);
|
|
2695
|
+
} else {
|
|
2696
|
+
result += line.slice(start);
|
|
2697
|
+
}
|
|
2698
|
+
return result.slice(1);
|
|
2699
|
+
}
|
|
2700
|
+
function escapeString(string) {
|
|
2701
|
+
var result = "";
|
|
2702
|
+
var char = 0;
|
|
2703
|
+
var escapeSeq;
|
|
2704
|
+
for (var i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
2705
|
+
char = codePointAt(string, i2);
|
|
2706
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2707
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
2708
|
+
result += string[i2];
|
|
2709
|
+
if (char >= 65536)
|
|
2710
|
+
result += string[i2 + 1];
|
|
2711
|
+
} else {
|
|
2712
|
+
result += escapeSeq || encodeHex(char);
|
|
2713
|
+
}
|
|
2714
|
+
}
|
|
2715
|
+
return result;
|
|
2716
|
+
}
|
|
2717
|
+
function writeFlowSequence(state, level, object) {
|
|
2718
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2719
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2720
|
+
value = object[index];
|
|
2721
|
+
if (state.replacer) {
|
|
2722
|
+
value = state.replacer.call(object, String(index), value);
|
|
2723
|
+
}
|
|
2724
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2725
|
+
if (_result !== "")
|
|
2726
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
2727
|
+
_result += state.dump;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
state.tag = _tag;
|
|
2731
|
+
state.dump = "[" + _result + "]";
|
|
2732
|
+
}
|
|
2733
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
2734
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
2735
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2736
|
+
value = object[index];
|
|
2737
|
+
if (state.replacer) {
|
|
2738
|
+
value = state.replacer.call(object, String(index), value);
|
|
2739
|
+
}
|
|
2740
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2741
|
+
if (!compact || _result !== "") {
|
|
2742
|
+
_result += generateNextLine(state, level);
|
|
2743
|
+
}
|
|
2744
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2745
|
+
_result += "-";
|
|
2746
|
+
} else {
|
|
2747
|
+
_result += "- ";
|
|
2748
|
+
}
|
|
2749
|
+
_result += state.dump;
|
|
2750
|
+
}
|
|
2751
|
+
}
|
|
2752
|
+
state.tag = _tag;
|
|
2753
|
+
state.dump = _result || "[]";
|
|
2754
|
+
}
|
|
2755
|
+
function writeFlowMapping(state, level, object) {
|
|
2756
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2757
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2758
|
+
pairBuffer = "";
|
|
2759
|
+
if (_result !== "")
|
|
2760
|
+
pairBuffer += ", ";
|
|
2761
|
+
if (state.condenseFlow)
|
|
2762
|
+
pairBuffer += '"';
|
|
2763
|
+
objectKey = objectKeyList[index];
|
|
2764
|
+
objectValue = object[objectKey];
|
|
2765
|
+
if (state.replacer) {
|
|
2766
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2767
|
+
}
|
|
2768
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2769
|
+
continue;
|
|
2770
|
+
}
|
|
2771
|
+
if (state.dump.length > 1024)
|
|
2772
|
+
pairBuffer += "? ";
|
|
2773
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2774
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2775
|
+
continue;
|
|
2776
|
+
}
|
|
2777
|
+
pairBuffer += state.dump;
|
|
2778
|
+
_result += pairBuffer;
|
|
2779
|
+
}
|
|
2780
|
+
state.tag = _tag;
|
|
2781
|
+
state.dump = "{" + _result + "}";
|
|
2782
|
+
}
|
|
2783
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
2784
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2785
|
+
if (state.sortKeys === true) {
|
|
2786
|
+
objectKeyList.sort();
|
|
2787
|
+
} else if (typeof state.sortKeys === "function") {
|
|
2788
|
+
objectKeyList.sort(state.sortKeys);
|
|
2789
|
+
} else if (state.sortKeys) {
|
|
2790
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
2791
|
+
}
|
|
2792
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2793
|
+
pairBuffer = "";
|
|
2794
|
+
if (!compact || _result !== "") {
|
|
2795
|
+
pairBuffer += generateNextLine(state, level);
|
|
2796
|
+
}
|
|
2797
|
+
objectKey = objectKeyList[index];
|
|
2798
|
+
objectValue = object[objectKey];
|
|
2799
|
+
if (state.replacer) {
|
|
2800
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2801
|
+
}
|
|
2802
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2803
|
+
continue;
|
|
2804
|
+
}
|
|
2805
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2806
|
+
if (explicitPair) {
|
|
2807
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2808
|
+
pairBuffer += "?";
|
|
2809
|
+
} else {
|
|
2810
|
+
pairBuffer += "? ";
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
pairBuffer += state.dump;
|
|
2814
|
+
if (explicitPair) {
|
|
2815
|
+
pairBuffer += generateNextLine(state, level);
|
|
2816
|
+
}
|
|
2817
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2818
|
+
continue;
|
|
2819
|
+
}
|
|
2820
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2821
|
+
pairBuffer += ":";
|
|
2822
|
+
} else {
|
|
2823
|
+
pairBuffer += ": ";
|
|
2824
|
+
}
|
|
2825
|
+
pairBuffer += state.dump;
|
|
2826
|
+
_result += pairBuffer;
|
|
2827
|
+
}
|
|
2828
|
+
state.tag = _tag;
|
|
2829
|
+
state.dump = _result || "{}";
|
|
2830
|
+
}
|
|
2831
|
+
function detectType(state, object, explicit) {
|
|
2832
|
+
var _result, typeList, index, length, type2, style;
|
|
2833
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2834
|
+
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
2835
|
+
type2 = typeList[index];
|
|
2836
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
2837
|
+
if (explicit) {
|
|
2838
|
+
if (type2.multi && type2.representName) {
|
|
2839
|
+
state.tag = type2.representName(object);
|
|
2840
|
+
} else {
|
|
2841
|
+
state.tag = type2.tag;
|
|
2842
|
+
}
|
|
2843
|
+
} else {
|
|
2844
|
+
state.tag = "?";
|
|
2845
|
+
}
|
|
2846
|
+
if (type2.represent) {
|
|
2847
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2848
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2849
|
+
_result = type2.represent(object, style);
|
|
2850
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2851
|
+
_result = type2.represent[style](object, style);
|
|
2852
|
+
} else {
|
|
2853
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2854
|
+
}
|
|
2855
|
+
state.dump = _result;
|
|
2856
|
+
}
|
|
2857
|
+
return true;
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
return false;
|
|
2861
|
+
}
|
|
2862
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2863
|
+
state.tag = null;
|
|
2864
|
+
state.dump = object;
|
|
2865
|
+
if (!detectType(state, object, false)) {
|
|
2866
|
+
detectType(state, object, true);
|
|
2867
|
+
}
|
|
2868
|
+
var type2 = _toString.call(state.dump);
|
|
2869
|
+
var inblock = block;
|
|
2870
|
+
var tagStr;
|
|
2871
|
+
if (block) {
|
|
2872
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2873
|
+
}
|
|
2874
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2875
|
+
if (objectOrArray) {
|
|
2876
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
2877
|
+
duplicate = duplicateIndex !== -1;
|
|
2878
|
+
}
|
|
2879
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2880
|
+
compact = false;
|
|
2881
|
+
}
|
|
2882
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2883
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
2884
|
+
} else {
|
|
2885
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2886
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
2887
|
+
}
|
|
2888
|
+
if (type2 === "[object Object]") {
|
|
2889
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
2890
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
2891
|
+
if (duplicate) {
|
|
2892
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2893
|
+
}
|
|
2894
|
+
} else {
|
|
2895
|
+
writeFlowMapping(state, level, state.dump);
|
|
2896
|
+
if (duplicate) {
|
|
2897
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
} else if (type2 === "[object Array]") {
|
|
2901
|
+
if (block && state.dump.length !== 0) {
|
|
2902
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2903
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2904
|
+
} else {
|
|
2905
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
2906
|
+
}
|
|
2907
|
+
if (duplicate) {
|
|
2908
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2909
|
+
}
|
|
2910
|
+
} else {
|
|
2911
|
+
writeFlowSequence(state, level, state.dump);
|
|
2912
|
+
if (duplicate) {
|
|
2913
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
} else if (type2 === "[object String]") {
|
|
2917
|
+
if (state.tag !== "?") {
|
|
2918
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2919
|
+
}
|
|
2920
|
+
} else if (type2 === "[object Undefined]") {
|
|
2921
|
+
return false;
|
|
2922
|
+
} else {
|
|
2923
|
+
if (state.skipInvalid)
|
|
2924
|
+
return false;
|
|
2925
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2926
|
+
}
|
|
2927
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
2928
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
2929
|
+
if (state.tag[0] === "!") {
|
|
2930
|
+
tagStr = "!" + tagStr;
|
|
2931
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2932
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
2933
|
+
} else {
|
|
2934
|
+
tagStr = "!<" + tagStr + ">";
|
|
2935
|
+
}
|
|
2936
|
+
state.dump = tagStr + " " + state.dump;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
return true;
|
|
2940
|
+
}
|
|
2941
|
+
function getDuplicateReferences(object, state) {
|
|
2942
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
2943
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
2944
|
+
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
2945
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2946
|
+
}
|
|
2947
|
+
state.usedDuplicates = new Array(length);
|
|
2948
|
+
}
|
|
2949
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2950
|
+
var objectKeyList, index, length;
|
|
2951
|
+
if (object !== null && typeof object === "object") {
|
|
2952
|
+
index = objects.indexOf(object);
|
|
2953
|
+
if (index !== -1) {
|
|
2954
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2955
|
+
duplicatesIndexes.push(index);
|
|
2956
|
+
}
|
|
2957
|
+
} else {
|
|
2958
|
+
objects.push(object);
|
|
2959
|
+
if (Array.isArray(object)) {
|
|
2960
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2961
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2962
|
+
}
|
|
2963
|
+
} else {
|
|
2964
|
+
objectKeyList = Object.keys(object);
|
|
2965
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2966
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
function dump$1(input, options) {
|
|
2973
|
+
options = options || {};
|
|
2974
|
+
var state = new State(options);
|
|
2975
|
+
if (!state.noRefs)
|
|
2976
|
+
getDuplicateReferences(input, state);
|
|
2977
|
+
var value = input;
|
|
2978
|
+
if (state.replacer) {
|
|
2979
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
2980
|
+
}
|
|
2981
|
+
if (writeNode(state, 0, value, true, true))
|
|
2982
|
+
return state.dump + `
|
|
2983
|
+
`;
|
|
2984
|
+
return "";
|
|
2985
|
+
}
|
|
2986
|
+
var dump_1 = dump$1;
|
|
2987
|
+
var dumper = {
|
|
2988
|
+
dump: dump_1
|
|
2989
|
+
};
|
|
2990
|
+
function renamed(from, to) {
|
|
2991
|
+
return function() {
|
|
2992
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
|
|
2993
|
+
};
|
|
2994
|
+
}
|
|
2995
|
+
var Type = type;
|
|
2996
|
+
var Schema = schema;
|
|
2997
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
2998
|
+
var JSON_SCHEMA = json;
|
|
2999
|
+
var CORE_SCHEMA = core;
|
|
3000
|
+
var DEFAULT_SCHEMA = _default;
|
|
3001
|
+
var load = loader.load;
|
|
3002
|
+
var loadAll = loader.loadAll;
|
|
3003
|
+
var dump = dumper.dump;
|
|
3004
|
+
var YAMLException = exception;
|
|
3005
|
+
var types = {
|
|
3006
|
+
binary,
|
|
3007
|
+
float,
|
|
3008
|
+
map,
|
|
3009
|
+
null: _null,
|
|
3010
|
+
pairs,
|
|
3011
|
+
set,
|
|
3012
|
+
timestamp,
|
|
3013
|
+
bool,
|
|
3014
|
+
int,
|
|
3015
|
+
merge,
|
|
3016
|
+
omap,
|
|
3017
|
+
seq,
|
|
3018
|
+
str
|
|
3019
|
+
};
|
|
3020
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
3021
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
3022
|
+
var safeDump = renamed("safeDump", "dump");
|
|
3023
|
+
var jsYaml = {
|
|
3024
|
+
Type,
|
|
3025
|
+
Schema,
|
|
3026
|
+
FAILSAFE_SCHEMA,
|
|
3027
|
+
JSON_SCHEMA,
|
|
3028
|
+
CORE_SCHEMA,
|
|
3029
|
+
DEFAULT_SCHEMA,
|
|
3030
|
+
load,
|
|
3031
|
+
loadAll,
|
|
3032
|
+
dump,
|
|
3033
|
+
YAMLException,
|
|
3034
|
+
types,
|
|
3035
|
+
safeLoad,
|
|
3036
|
+
safeLoadAll,
|
|
3037
|
+
safeDump
|
|
3038
|
+
};
|
|
3039
|
+
|
|
3040
|
+
// src/graph.ts
|
|
3041
|
+
var ENCODE_MAP = { "/": "__SL__", ".": "__DT__" };
|
|
3042
|
+
var ENCODE_RE = /[/.]/g;
|
|
3043
|
+
function pathToGraphFilename(filePath) {
|
|
3044
|
+
return filePath.replace(ENCODE_RE, (ch) => ENCODE_MAP[ch]) + ".md";
|
|
3045
|
+
}
|
|
3046
|
+
function parseGraphContent(content) {
|
|
3047
|
+
const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
3048
|
+
if (fmMatch) {
|
|
3049
|
+
try {
|
|
3050
|
+
const fm = jsYaml.load(fmMatch[1]);
|
|
3051
|
+
if (fm && fm.filePath) {
|
|
3052
|
+
return {
|
|
3053
|
+
filePath: fm.filePath,
|
|
3054
|
+
calls: fm.calls || [],
|
|
3055
|
+
dependsOn: fm.dependsOn || [],
|
|
3056
|
+
tasksThatEdited: fm.tasksThatEdited || []
|
|
3057
|
+
};
|
|
3058
|
+
}
|
|
3059
|
+
} catch {}
|
|
3060
|
+
}
|
|
3061
|
+
return parseLegacyContent(content);
|
|
3062
|
+
}
|
|
3063
|
+
function parseLegacyContent(content) {
|
|
3064
|
+
const lines = content.split(`
|
|
3065
|
+
`);
|
|
3066
|
+
const entry = {
|
|
3067
|
+
filePath: "",
|
|
3068
|
+
calls: [],
|
|
3069
|
+
dependsOn: [],
|
|
3070
|
+
tasksThatEdited: []
|
|
3071
|
+
};
|
|
3072
|
+
let inSection = null;
|
|
3073
|
+
for (const line of lines) {
|
|
3074
|
+
const trimmed = line.trim();
|
|
3075
|
+
if (trimmed.startsWith("# ") && !entry.filePath) {
|
|
3076
|
+
entry.filePath = trimmed.substring(2).trim();
|
|
3077
|
+
continue;
|
|
3078
|
+
}
|
|
3079
|
+
if (trimmed === "## Calls") {
|
|
3080
|
+
inSection = "calls";
|
|
3081
|
+
continue;
|
|
3082
|
+
}
|
|
3083
|
+
if (trimmed === "## Depends On") {
|
|
3084
|
+
inSection = "dependsOn";
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3087
|
+
if (trimmed === "## Tasks That Edited") {
|
|
3088
|
+
inSection = "tasks";
|
|
3089
|
+
continue;
|
|
3090
|
+
}
|
|
3091
|
+
if (trimmed.startsWith("- [[") && trimmed.endsWith("]]")) {
|
|
3092
|
+
const ref = trimmed.slice(4, -2).trim();
|
|
3093
|
+
if (inSection === "calls")
|
|
3094
|
+
entry.calls.push(ref);
|
|
3095
|
+
else if (inSection === "dependsOn")
|
|
3096
|
+
entry.dependsOn.push(ref);
|
|
3097
|
+
else if (inSection === "tasks")
|
|
3098
|
+
entry.tasksThatEdited.push(ref);
|
|
3099
|
+
} else if (trimmed.startsWith("- `") && trimmed.endsWith("`")) {
|
|
3100
|
+
const ref = trimmed.slice(3, -1).trim();
|
|
3101
|
+
if (inSection === "calls" && !entry.calls.includes(ref))
|
|
3102
|
+
entry.calls.push(ref);
|
|
3103
|
+
else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref))
|
|
3104
|
+
entry.dependsOn.push(ref);
|
|
3105
|
+
} else if (trimmed.startsWith("- ")) {
|
|
3106
|
+
const ref = trimmed.slice(2).trim();
|
|
3107
|
+
if (inSection === "calls" && !entry.calls.includes(ref))
|
|
3108
|
+
entry.calls.push(ref);
|
|
3109
|
+
else if (inSection === "dependsOn" && !entry.dependsOn.includes(ref))
|
|
3110
|
+
entry.dependsOn.push(ref);
|
|
3111
|
+
else if (inSection === "tasks" && !entry.tasksThatEdited.includes(ref))
|
|
3112
|
+
entry.tasksThatEdited.push(ref);
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
return entry.filePath ? entry : null;
|
|
3116
|
+
}
|
|
3117
|
+
function formatGraphContent(entry) {
|
|
3118
|
+
const fm = {
|
|
3119
|
+
filePath: entry.filePath,
|
|
3120
|
+
calls: entry.calls,
|
|
3121
|
+
dependsOn: entry.dependsOn,
|
|
3122
|
+
tasksThatEdited: entry.tasksThatEdited
|
|
3123
|
+
};
|
|
3124
|
+
const fmYaml = jsYaml.dump(fm, { lineWidth: -1, quotingType: "'", forceQuotes: false });
|
|
3125
|
+
const callsSection = entry.calls.length > 0 ? `## Calls
|
|
3126
|
+
` + entry.calls.map((c) => `- ${c}`).join(`
|
|
3127
|
+
`) : `## Calls
|
|
3128
|
+
`;
|
|
3129
|
+
const dependsSection = entry.dependsOn.length > 0 ? `## Depends On
|
|
3130
|
+
` + entry.dependsOn.map((d) => `- ${d}`).join(`
|
|
3131
|
+
`) : `## Depends On
|
|
3132
|
+
`;
|
|
3133
|
+
const tasksSection = entry.tasksThatEdited.length > 0 ? `## Tasks That Edited
|
|
3134
|
+
` + entry.tasksThatEdited.map((t) => `- [[${t}]]`).join(`
|
|
3135
|
+
`) : `## Tasks That Edited
|
|
3136
|
+
`;
|
|
3137
|
+
return `---
|
|
3138
|
+
${fmYaml.trim()}
|
|
3139
|
+
---
|
|
3140
|
+
|
|
3141
|
+
${callsSection}
|
|
3142
|
+
|
|
3143
|
+
${dependsSection}
|
|
3144
|
+
|
|
3145
|
+
${tasksSection}
|
|
3146
|
+
`.trim();
|
|
3147
|
+
}
|
|
3148
|
+
async function readGraphFile(directory, filePath) {
|
|
3149
|
+
const filename = pathToGraphFilename(filePath);
|
|
3150
|
+
const graphPath = join2(directory, "Manifold", "graph", filename);
|
|
3151
|
+
if (!existsSync2(graphPath)) {
|
|
3152
|
+
return null;
|
|
3153
|
+
}
|
|
3154
|
+
try {
|
|
3155
|
+
const content = await readFile2(graphPath, "utf-8");
|
|
3156
|
+
return parseGraphContent(content);
|
|
3157
|
+
} catch {
|
|
3158
|
+
return null;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
async function updateGraphFile(directory, filePath, taskId, calls, dependsOn) {
|
|
3162
|
+
const filename = pathToGraphFilename(filePath);
|
|
3163
|
+
const graphPath = join2(directory, "Manifold", "graph", filename);
|
|
3164
|
+
let entry;
|
|
3165
|
+
if (existsSync2(graphPath)) {
|
|
3166
|
+
const existing = await readGraphFile(directory, filePath);
|
|
3167
|
+
entry = existing || {
|
|
3168
|
+
filePath,
|
|
3169
|
+
calls: [],
|
|
3170
|
+
dependsOn: [],
|
|
3171
|
+
tasksThatEdited: []
|
|
3172
|
+
};
|
|
3173
|
+
} else {
|
|
3174
|
+
entry = {
|
|
3175
|
+
filePath,
|
|
3176
|
+
calls: calls || [],
|
|
3177
|
+
dependsOn: dependsOn || [],
|
|
3178
|
+
tasksThatEdited: []
|
|
3179
|
+
};
|
|
3180
|
+
}
|
|
3181
|
+
if (calls) {
|
|
3182
|
+
entry.calls = [...new Set([...entry.calls, ...calls])];
|
|
3183
|
+
}
|
|
3184
|
+
if (dependsOn) {
|
|
3185
|
+
entry.dependsOn = [...new Set([...entry.dependsOn, ...dependsOn])];
|
|
3186
|
+
}
|
|
3187
|
+
if (!entry.tasksThatEdited.includes(taskId)) {
|
|
3188
|
+
entry.tasksThatEdited.push(taskId);
|
|
3189
|
+
}
|
|
3190
|
+
const graphDir = dirname2(graphPath);
|
|
3191
|
+
if (!existsSync2(graphDir)) {
|
|
3192
|
+
await mkdir2(graphDir, { recursive: true });
|
|
3193
|
+
}
|
|
3194
|
+
const content = formatGraphContent(entry);
|
|
3195
|
+
await writeFile2(graphPath, content, "utf-8");
|
|
3196
|
+
}
|
|
3197
|
+
async function updateGraphFilesForTask(directory, taskId, files) {
|
|
3198
|
+
for (const file of files) {
|
|
3199
|
+
try {
|
|
3200
|
+
await updateGraphFile(directory, file, taskId);
|
|
3201
|
+
} catch (error) {
|
|
3202
|
+
console.error(`Failed to update graph for ${file}:`, error);
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
}
|
|
3206
|
+
async function replaceGraphCalls(directory, filePath, calls, dependsOn) {
|
|
3207
|
+
const filename = pathToGraphFilename(filePath);
|
|
3208
|
+
const graphPath = join2(directory, "Manifold", "graph", filename);
|
|
3209
|
+
let entry;
|
|
3210
|
+
if (existsSync2(graphPath)) {
|
|
3211
|
+
const existing = await readGraphFile(directory, filePath);
|
|
3212
|
+
entry = existing || {
|
|
3213
|
+
filePath,
|
|
3214
|
+
calls: [],
|
|
3215
|
+
dependsOn: [],
|
|
3216
|
+
tasksThatEdited: []
|
|
3217
|
+
};
|
|
3218
|
+
} else {
|
|
3219
|
+
entry = {
|
|
3220
|
+
filePath,
|
|
3221
|
+
calls: [],
|
|
3222
|
+
dependsOn: [],
|
|
3223
|
+
tasksThatEdited: []
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
entry.calls = [...new Set(calls)];
|
|
3227
|
+
entry.dependsOn = [...new Set(dependsOn)];
|
|
3228
|
+
const graphDir = dirname2(graphPath);
|
|
3229
|
+
if (!existsSync2(graphDir)) {
|
|
3230
|
+
await mkdir2(graphDir, { recursive: true });
|
|
3231
|
+
}
|
|
3232
|
+
const content = formatGraphContent(entry);
|
|
3233
|
+
await writeFile2(graphPath, content, "utf-8");
|
|
3234
|
+
}
|
|
3235
|
+
|
|
3236
|
+
// src/graph-sync.ts
|
|
3237
|
+
import Database from "better-sqlite3";
|
|
3238
|
+
import { existsSync as existsSync3 } from "fs";
|
|
3239
|
+
import { join as join3 } from "path";
|
|
3240
|
+
function openIndexDb(projectRoot) {
|
|
3241
|
+
const dbPath = join3(projectRoot, ".opencode", "index", "codebase.db");
|
|
3242
|
+
if (!existsSync3(dbPath)) {
|
|
3243
|
+
return null;
|
|
3244
|
+
}
|
|
3245
|
+
try {
|
|
3246
|
+
const db = new Database(dbPath, { readonly: true });
|
|
3247
|
+
db.pragma("journal_mode = WAL");
|
|
3248
|
+
return db;
|
|
3249
|
+
} catch {
|
|
3250
|
+
return null;
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
function getFileCallEdges(db, filePath, branch) {
|
|
3254
|
+
const calls = new Set;
|
|
3255
|
+
const dependsOn = new Set;
|
|
3256
|
+
const outEdges = db.prepare(`
|
|
3257
|
+
SELECT s_to.file_path AS target_file
|
|
3258
|
+
FROM call_edges ce
|
|
3259
|
+
INNER JOIN symbols s_from ON ce.from_symbol_id = s_from.id
|
|
3260
|
+
INNER JOIN branch_symbols bs ON s_from.id = bs.symbol_id AND bs.branch = ?
|
|
3261
|
+
LEFT JOIN symbols s_to ON ce.to_symbol_id = s_to.id
|
|
3262
|
+
WHERE s_from.file_path = ?
|
|
3263
|
+
AND ce.is_resolved = 1
|
|
3264
|
+
AND s_to.file_path IS NOT NULL
|
|
3265
|
+
AND s_to.file_path != ?
|
|
3266
|
+
`).all(branch, filePath, filePath);
|
|
3267
|
+
for (const row of outEdges) {
|
|
3268
|
+
if (row.target_file) {
|
|
3269
|
+
calls.add(row.target_file);
|
|
3270
|
+
dependsOn.add(row.target_file);
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
const unresolvedEdges = db.prepare(`
|
|
3274
|
+
SELECT DISTINCT ce.target_name
|
|
3275
|
+
FROM call_edges ce
|
|
3276
|
+
INNER JOIN symbols s_from ON ce.from_symbol_id = s_from.id
|
|
3277
|
+
INNER JOIN branch_symbols bs ON s_from.id = bs.symbol_id AND bs.branch = ?
|
|
3278
|
+
WHERE s_from.file_path = ?
|
|
3279
|
+
AND ce.is_resolved = 0
|
|
3280
|
+
`).all(branch, filePath);
|
|
3281
|
+
const symbolByName = db.prepare(`
|
|
3282
|
+
SELECT DISTINCT s.file_path
|
|
3283
|
+
FROM symbols s
|
|
3284
|
+
INNER JOIN branch_symbols bs ON s.id = bs.symbol_id AND bs.branch = ?
|
|
3285
|
+
WHERE s.name = ?
|
|
3286
|
+
AND s.file_path != ?
|
|
3287
|
+
`);
|
|
3288
|
+
for (const row of unresolvedEdges) {
|
|
3289
|
+
const candidates = symbolByName.all(branch, row.target_name, filePath);
|
|
3290
|
+
if (candidates.length === 1) {
|
|
3291
|
+
calls.add(candidates[0].file_path);
|
|
3292
|
+
dependsOn.add(candidates[0].file_path);
|
|
3293
|
+
}
|
|
3294
|
+
}
|
|
3295
|
+
return {
|
|
3296
|
+
calls: [...calls].sort(),
|
|
3297
|
+
dependsOn: [...dependsOn].sort()
|
|
3298
|
+
};
|
|
3299
|
+
}
|
|
3300
|
+
function getCurrentBranch(db) {
|
|
3301
|
+
const row = db.prepare("SELECT value FROM metadata WHERE key = 'current_branch'").get();
|
|
3302
|
+
return row?.value || "main";
|
|
3303
|
+
}
|
|
3304
|
+
async function syncGraphFilesFromIndex(projectRoot, files) {
|
|
3305
|
+
const db = openIndexDb(projectRoot);
|
|
3306
|
+
if (!db) {
|
|
3307
|
+
return { synced: 0, skipped: files.length };
|
|
3308
|
+
}
|
|
3309
|
+
try {
|
|
3310
|
+
const branch = getCurrentBranch(db);
|
|
3311
|
+
let synced = 0;
|
|
3312
|
+
let skipped = 0;
|
|
3313
|
+
for (const filePath of files) {
|
|
3314
|
+
try {
|
|
3315
|
+
const edges = getFileCallEdges(db, filePath, branch);
|
|
3316
|
+
await replaceGraphCalls(projectRoot, filePath, edges.calls, edges.dependsOn);
|
|
3317
|
+
synced++;
|
|
3318
|
+
} catch {
|
|
3319
|
+
skipped++;
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
return { synced, skipped };
|
|
3323
|
+
} finally {
|
|
3324
|
+
db.close();
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
// src/state-machine.ts
|
|
3329
|
+
async function readState(directory) {
|
|
3330
|
+
const statePath = join4(directory, "Manifold", "state.json");
|
|
3331
|
+
if (existsSync4(statePath)) {
|
|
3332
|
+
const content = await readFile3(statePath, "utf-8");
|
|
3333
|
+
return JSON.parse(content);
|
|
3334
|
+
}
|
|
3335
|
+
return {
|
|
3336
|
+
current_task: null,
|
|
3337
|
+
state: "idle",
|
|
3338
|
+
loop_count: 0,
|
|
3339
|
+
clerk_retry_count: 0,
|
|
3340
|
+
scoped_prompt: null,
|
|
3341
|
+
senior_output: null,
|
|
3342
|
+
junior_response: null,
|
|
3343
|
+
debug_suggestion: null,
|
|
3344
|
+
loop_history: []
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
async function writeState(directory, state) {
|
|
3348
|
+
const statePath = join4(directory, "Manifold", "state.json");
|
|
3349
|
+
await writeFile3(statePath, JSON.stringify(state, null, 2));
|
|
3350
|
+
}
|
|
3351
|
+
function buildLoopHistory(state) {
|
|
3352
|
+
if (state.loop_history.length === 0) {
|
|
3353
|
+
return "No previous loops.";
|
|
3354
|
+
}
|
|
3355
|
+
return state.loop_history.map((entry, i2) => `### Loop ${i2 + 1}
|
|
3356
|
+
${entry}`).join(`
|
|
3357
|
+
|
|
3358
|
+
`);
|
|
3359
|
+
}
|
|
3360
|
+
async function readRecentTaskLogs(directory, count) {
|
|
3361
|
+
const tasksDir = join4(directory, "Manifold", "tasks");
|
|
3362
|
+
if (!existsSync4(tasksDir)) {
|
|
3363
|
+
return [];
|
|
3364
|
+
}
|
|
3365
|
+
try {
|
|
3366
|
+
const files = await readdir2(tasksDir);
|
|
3367
|
+
const mdFiles = files.filter((f) => f.endsWith(".md")).sort();
|
|
3368
|
+
const recentFiles = mdFiles.slice(-count);
|
|
3369
|
+
const tasks = await Promise.all(recentFiles.map(async (filename) => {
|
|
3370
|
+
const content = await readFile3(join4(tasksDir, filename), "utf-8");
|
|
3371
|
+
return { filename, content };
|
|
3372
|
+
}));
|
|
3373
|
+
return tasks;
|
|
3374
|
+
} catch {
|
|
3375
|
+
return [];
|
|
3376
|
+
}
|
|
3377
|
+
}
|
|
3378
|
+
async function runClerkLoggingPhase(client, task, state, settings, directory) {
|
|
3379
|
+
state.state = "clerk_logging";
|
|
3380
|
+
await writeState(directory, state);
|
|
3381
|
+
await client.app.log({
|
|
3382
|
+
body: {
|
|
3383
|
+
service: "opencode-manifold",
|
|
561
3384
|
level: "info",
|
|
562
3385
|
message: "State: clerk_logging - Spawning Clerk for wiki logging"
|
|
563
3386
|
}
|
|
@@ -601,11 +3424,12 @@ Please perform the following logging actions:
|
|
|
601
3424
|
\`## [${date}] ${taskId} | ${task.description} | COMPLETED | ${state.loop_count} loops\`
|
|
602
3425
|
|
|
603
3426
|
4. Update graph files for each touched file:
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
3427
|
+
- Read the implementation and identify all files that were created or modified
|
|
3428
|
+
- For each file, create or update \`Manifold/graph/<graph-name>.md\`
|
|
3429
|
+
- Add the task ID to the "Tasks That Edited" section
|
|
3430
|
+
- Do NOT populate "Calls" or "Depends On" sections — those are synced automatically from the codebase index
|
|
3431
|
+
- Graph filename format: replace \`/\` with \`__SL__\` and \`.\` with \`__DT__\`, append \`.md\`
|
|
3432
|
+
- Example: \`src/middleware/auth.ts\` → \`src__SL__middleware__SL__auth__DT__ts.md\`
|
|
609
3433
|
|
|
610
3434
|
Extract the list of files touched from the Senior's implementation and include it in your response.`;
|
|
611
3435
|
const clerkLoggingResult = await retryWithBackoff(() => spawnClerkSession(client, clerkLoggingPrompt, "clerk", settings.timeout), {
|
|
@@ -648,6 +3472,14 @@ Extract the list of files touched from the Senior's implementation and include i
|
|
|
648
3472
|
message: `Graph files updated successfully`
|
|
649
3473
|
}
|
|
650
3474
|
});
|
|
3475
|
+
const syncResult = await syncGraphFilesFromIndex(directory, filesChanged);
|
|
3476
|
+
await client.app.log({
|
|
3477
|
+
body: {
|
|
3478
|
+
service: "opencode-manifold",
|
|
3479
|
+
level: "info",
|
|
3480
|
+
message: `Graph sync from codebase-index: ${syncResult.synced} synced, ${syncResult.skipped} skipped`
|
|
3481
|
+
}
|
|
3482
|
+
});
|
|
651
3483
|
} catch (error) {
|
|
652
3484
|
await client.app.log({
|
|
653
3485
|
body: {
|
|
@@ -1243,8 +4075,8 @@ function setPluginContext(client) {
|
|
|
1243
4075
|
pluginClient = client;
|
|
1244
4076
|
}
|
|
1245
4077
|
async function readSettings(directory) {
|
|
1246
|
-
const settingsPath =
|
|
1247
|
-
if (
|
|
4078
|
+
const settingsPath = join5(directory, "Manifold", "settings.json");
|
|
4079
|
+
if (existsSync5(settingsPath)) {
|
|
1248
4080
|
const content = await readFile4(settingsPath, "utf-8");
|
|
1249
4081
|
return JSON.parse(content);
|
|
1250
4082
|
}
|
|
@@ -1259,9 +4091,9 @@ async function readSettings(directory) {
|
|
|
1259
4091
|
};
|
|
1260
4092
|
}
|
|
1261
4093
|
async function updatePlansRegistry(directory, planFile) {
|
|
1262
|
-
const plansPath =
|
|
4094
|
+
const plansPath = join5(directory, "Manifold", "plans.json");
|
|
1263
4095
|
let plans = {};
|
|
1264
|
-
if (
|
|
4096
|
+
if (existsSync5(plansPath)) {
|
|
1265
4097
|
const content = await readFile4(plansPath, "utf-8");
|
|
1266
4098
|
plans = JSON.parse(content);
|
|
1267
4099
|
}
|