opencode-plugin-search 0.0.1 → 0.0.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/README.md +52 -13
- package/dist/index.js +2801 -41
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -12329,8 +12329,2695 @@ function tool(input) {
|
|
|
12329
12329
|
return input;
|
|
12330
12330
|
}
|
|
12331
12331
|
tool.schema = exports_external;
|
|
12332
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
12333
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
12334
|
+
function isNothing(subject) {
|
|
12335
|
+
return typeof subject === "undefined" || subject === null;
|
|
12336
|
+
}
|
|
12337
|
+
function isObject2(subject) {
|
|
12338
|
+
return typeof subject === "object" && subject !== null;
|
|
12339
|
+
}
|
|
12340
|
+
function toArray(sequence) {
|
|
12341
|
+
if (Array.isArray(sequence))
|
|
12342
|
+
return sequence;
|
|
12343
|
+
else if (isNothing(sequence))
|
|
12344
|
+
return [];
|
|
12345
|
+
return [sequence];
|
|
12346
|
+
}
|
|
12347
|
+
function extend2(target, source) {
|
|
12348
|
+
var index, length, key, sourceKeys;
|
|
12349
|
+
if (source) {
|
|
12350
|
+
sourceKeys = Object.keys(source);
|
|
12351
|
+
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
12352
|
+
key = sourceKeys[index];
|
|
12353
|
+
target[key] = source[key];
|
|
12354
|
+
}
|
|
12355
|
+
}
|
|
12356
|
+
return target;
|
|
12357
|
+
}
|
|
12358
|
+
function repeat(string4, count) {
|
|
12359
|
+
var result = "", cycle;
|
|
12360
|
+
for (cycle = 0;cycle < count; cycle += 1) {
|
|
12361
|
+
result += string4;
|
|
12362
|
+
}
|
|
12363
|
+
return result;
|
|
12364
|
+
}
|
|
12365
|
+
function isNegativeZero(number4) {
|
|
12366
|
+
return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
|
|
12367
|
+
}
|
|
12368
|
+
var isNothing_1 = isNothing;
|
|
12369
|
+
var isObject_1 = isObject2;
|
|
12370
|
+
var toArray_1 = toArray;
|
|
12371
|
+
var repeat_1 = repeat;
|
|
12372
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
12373
|
+
var extend_1 = extend2;
|
|
12374
|
+
var common = {
|
|
12375
|
+
isNothing: isNothing_1,
|
|
12376
|
+
isObject: isObject_1,
|
|
12377
|
+
toArray: toArray_1,
|
|
12378
|
+
repeat: repeat_1,
|
|
12379
|
+
isNegativeZero: isNegativeZero_1,
|
|
12380
|
+
extend: extend_1
|
|
12381
|
+
};
|
|
12382
|
+
function formatError2(exception, compact) {
|
|
12383
|
+
var where = "", message = exception.reason || "(unknown reason)";
|
|
12384
|
+
if (!exception.mark)
|
|
12385
|
+
return message;
|
|
12386
|
+
if (exception.mark.name) {
|
|
12387
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
12388
|
+
}
|
|
12389
|
+
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
12390
|
+
if (!compact && exception.mark.snippet) {
|
|
12391
|
+
where += `
|
|
12392
|
+
|
|
12393
|
+
` + exception.mark.snippet;
|
|
12394
|
+
}
|
|
12395
|
+
return message + " " + where;
|
|
12396
|
+
}
|
|
12397
|
+
function YAMLException$1(reason, mark) {
|
|
12398
|
+
Error.call(this);
|
|
12399
|
+
this.name = "YAMLException";
|
|
12400
|
+
this.reason = reason;
|
|
12401
|
+
this.mark = mark;
|
|
12402
|
+
this.message = formatError2(this, false);
|
|
12403
|
+
if (Error.captureStackTrace) {
|
|
12404
|
+
Error.captureStackTrace(this, this.constructor);
|
|
12405
|
+
} else {
|
|
12406
|
+
this.stack = new Error().stack || "";
|
|
12407
|
+
}
|
|
12408
|
+
}
|
|
12409
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
12410
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
12411
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
12412
|
+
return this.name + ": " + formatError2(this, compact);
|
|
12413
|
+
};
|
|
12414
|
+
var exception = YAMLException$1;
|
|
12415
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
12416
|
+
var head = "";
|
|
12417
|
+
var tail = "";
|
|
12418
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
12419
|
+
if (position - lineStart > maxHalfLength) {
|
|
12420
|
+
head = " ... ";
|
|
12421
|
+
lineStart = position - maxHalfLength + head.length;
|
|
12422
|
+
}
|
|
12423
|
+
if (lineEnd - position > maxHalfLength) {
|
|
12424
|
+
tail = " ...";
|
|
12425
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
12426
|
+
}
|
|
12427
|
+
return {
|
|
12428
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
12429
|
+
pos: position - lineStart + head.length
|
|
12430
|
+
};
|
|
12431
|
+
}
|
|
12432
|
+
function padStart(string4, max) {
|
|
12433
|
+
return common.repeat(" ", max - string4.length) + string4;
|
|
12434
|
+
}
|
|
12435
|
+
function makeSnippet(mark, options) {
|
|
12436
|
+
options = Object.create(options || null);
|
|
12437
|
+
if (!mark.buffer)
|
|
12438
|
+
return null;
|
|
12439
|
+
if (!options.maxLength)
|
|
12440
|
+
options.maxLength = 79;
|
|
12441
|
+
if (typeof options.indent !== "number")
|
|
12442
|
+
options.indent = 1;
|
|
12443
|
+
if (typeof options.linesBefore !== "number")
|
|
12444
|
+
options.linesBefore = 3;
|
|
12445
|
+
if (typeof options.linesAfter !== "number")
|
|
12446
|
+
options.linesAfter = 2;
|
|
12447
|
+
var re = /\r?\n|\r|\0/g;
|
|
12448
|
+
var lineStarts = [0];
|
|
12449
|
+
var lineEnds = [];
|
|
12450
|
+
var match;
|
|
12451
|
+
var foundLineNo = -1;
|
|
12452
|
+
while (match = re.exec(mark.buffer)) {
|
|
12453
|
+
lineEnds.push(match.index);
|
|
12454
|
+
lineStarts.push(match.index + match[0].length);
|
|
12455
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
12456
|
+
foundLineNo = lineStarts.length - 2;
|
|
12457
|
+
}
|
|
12458
|
+
}
|
|
12459
|
+
if (foundLineNo < 0)
|
|
12460
|
+
foundLineNo = lineStarts.length - 1;
|
|
12461
|
+
var result = "", i, line;
|
|
12462
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
12463
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
12464
|
+
for (i = 1;i <= options.linesBefore; i++) {
|
|
12465
|
+
if (foundLineNo - i < 0)
|
|
12466
|
+
break;
|
|
12467
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
12468
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
12469
|
+
` + result;
|
|
12470
|
+
}
|
|
12471
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
12472
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
12473
|
+
`;
|
|
12474
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + `
|
|
12475
|
+
`;
|
|
12476
|
+
for (i = 1;i <= options.linesAfter; i++) {
|
|
12477
|
+
if (foundLineNo + i >= lineEnds.length)
|
|
12478
|
+
break;
|
|
12479
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
12480
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
12481
|
+
`;
|
|
12482
|
+
}
|
|
12483
|
+
return result.replace(/\n$/, "");
|
|
12484
|
+
}
|
|
12485
|
+
var snippet = makeSnippet;
|
|
12486
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
12487
|
+
"kind",
|
|
12488
|
+
"multi",
|
|
12489
|
+
"resolve",
|
|
12490
|
+
"construct",
|
|
12491
|
+
"instanceOf",
|
|
12492
|
+
"predicate",
|
|
12493
|
+
"represent",
|
|
12494
|
+
"representName",
|
|
12495
|
+
"defaultStyle",
|
|
12496
|
+
"styleAliases"
|
|
12497
|
+
];
|
|
12498
|
+
var YAML_NODE_KINDS = [
|
|
12499
|
+
"scalar",
|
|
12500
|
+
"sequence",
|
|
12501
|
+
"mapping"
|
|
12502
|
+
];
|
|
12503
|
+
function compileStyleAliases(map2) {
|
|
12504
|
+
var result = {};
|
|
12505
|
+
if (map2 !== null) {
|
|
12506
|
+
Object.keys(map2).forEach(function(style) {
|
|
12507
|
+
map2[style].forEach(function(alias) {
|
|
12508
|
+
result[String(alias)] = style;
|
|
12509
|
+
});
|
|
12510
|
+
});
|
|
12511
|
+
}
|
|
12512
|
+
return result;
|
|
12513
|
+
}
|
|
12514
|
+
function Type$1(tag, options) {
|
|
12515
|
+
options = options || {};
|
|
12516
|
+
Object.keys(options).forEach(function(name) {
|
|
12517
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
12518
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
12519
|
+
}
|
|
12520
|
+
});
|
|
12521
|
+
this.options = options;
|
|
12522
|
+
this.tag = tag;
|
|
12523
|
+
this.kind = options["kind"] || null;
|
|
12524
|
+
this.resolve = options["resolve"] || function() {
|
|
12525
|
+
return true;
|
|
12526
|
+
};
|
|
12527
|
+
this.construct = options["construct"] || function(data) {
|
|
12528
|
+
return data;
|
|
12529
|
+
};
|
|
12530
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
12531
|
+
this.predicate = options["predicate"] || null;
|
|
12532
|
+
this.represent = options["represent"] || null;
|
|
12533
|
+
this.representName = options["representName"] || null;
|
|
12534
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
12535
|
+
this.multi = options["multi"] || false;
|
|
12536
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
12537
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
12538
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
12539
|
+
}
|
|
12540
|
+
}
|
|
12541
|
+
var type = Type$1;
|
|
12542
|
+
function compileList(schema, name) {
|
|
12543
|
+
var result = [];
|
|
12544
|
+
schema[name].forEach(function(currentType) {
|
|
12545
|
+
var newIndex = result.length;
|
|
12546
|
+
result.forEach(function(previousType, previousIndex) {
|
|
12547
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
12548
|
+
newIndex = previousIndex;
|
|
12549
|
+
}
|
|
12550
|
+
});
|
|
12551
|
+
result[newIndex] = currentType;
|
|
12552
|
+
});
|
|
12553
|
+
return result;
|
|
12554
|
+
}
|
|
12555
|
+
function compileMap() {
|
|
12556
|
+
var result = {
|
|
12557
|
+
scalar: {},
|
|
12558
|
+
sequence: {},
|
|
12559
|
+
mapping: {},
|
|
12560
|
+
fallback: {},
|
|
12561
|
+
multi: {
|
|
12562
|
+
scalar: [],
|
|
12563
|
+
sequence: [],
|
|
12564
|
+
mapping: [],
|
|
12565
|
+
fallback: []
|
|
12566
|
+
}
|
|
12567
|
+
}, index, length;
|
|
12568
|
+
function collectType(type2) {
|
|
12569
|
+
if (type2.multi) {
|
|
12570
|
+
result.multi[type2.kind].push(type2);
|
|
12571
|
+
result.multi["fallback"].push(type2);
|
|
12572
|
+
} else {
|
|
12573
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
12574
|
+
}
|
|
12575
|
+
}
|
|
12576
|
+
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
12577
|
+
arguments[index].forEach(collectType);
|
|
12578
|
+
}
|
|
12579
|
+
return result;
|
|
12580
|
+
}
|
|
12581
|
+
function Schema$1(definition) {
|
|
12582
|
+
return this.extend(definition);
|
|
12583
|
+
}
|
|
12584
|
+
Schema$1.prototype.extend = function extend3(definition) {
|
|
12585
|
+
var implicit = [];
|
|
12586
|
+
var explicit = [];
|
|
12587
|
+
if (definition instanceof type) {
|
|
12588
|
+
explicit.push(definition);
|
|
12589
|
+
} else if (Array.isArray(definition)) {
|
|
12590
|
+
explicit = explicit.concat(definition);
|
|
12591
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
12592
|
+
if (definition.implicit)
|
|
12593
|
+
implicit = implicit.concat(definition.implicit);
|
|
12594
|
+
if (definition.explicit)
|
|
12595
|
+
explicit = explicit.concat(definition.explicit);
|
|
12596
|
+
} else {
|
|
12597
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
12598
|
+
}
|
|
12599
|
+
implicit.forEach(function(type$1) {
|
|
12600
|
+
if (!(type$1 instanceof type)) {
|
|
12601
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
12602
|
+
}
|
|
12603
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
12604
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
12605
|
+
}
|
|
12606
|
+
if (type$1.multi) {
|
|
12607
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
12608
|
+
}
|
|
12609
|
+
});
|
|
12610
|
+
explicit.forEach(function(type$1) {
|
|
12611
|
+
if (!(type$1 instanceof type)) {
|
|
12612
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
12613
|
+
}
|
|
12614
|
+
});
|
|
12615
|
+
var result = Object.create(Schema$1.prototype);
|
|
12616
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
12617
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
12618
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
12619
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
12620
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
12621
|
+
return result;
|
|
12622
|
+
};
|
|
12623
|
+
var schema = Schema$1;
|
|
12624
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
12625
|
+
kind: "scalar",
|
|
12626
|
+
construct: function(data) {
|
|
12627
|
+
return data !== null ? data : "";
|
|
12628
|
+
}
|
|
12629
|
+
});
|
|
12630
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
12631
|
+
kind: "sequence",
|
|
12632
|
+
construct: function(data) {
|
|
12633
|
+
return data !== null ? data : [];
|
|
12634
|
+
}
|
|
12635
|
+
});
|
|
12636
|
+
var map2 = new type("tag:yaml.org,2002:map", {
|
|
12637
|
+
kind: "mapping",
|
|
12638
|
+
construct: function(data) {
|
|
12639
|
+
return data !== null ? data : {};
|
|
12640
|
+
}
|
|
12641
|
+
});
|
|
12642
|
+
var failsafe = new schema({
|
|
12643
|
+
explicit: [
|
|
12644
|
+
str,
|
|
12645
|
+
seq,
|
|
12646
|
+
map2
|
|
12647
|
+
]
|
|
12648
|
+
});
|
|
12649
|
+
function resolveYamlNull(data) {
|
|
12650
|
+
if (data === null)
|
|
12651
|
+
return true;
|
|
12652
|
+
var max = data.length;
|
|
12653
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
12654
|
+
}
|
|
12655
|
+
function constructYamlNull() {
|
|
12656
|
+
return null;
|
|
12657
|
+
}
|
|
12658
|
+
function isNull(object2) {
|
|
12659
|
+
return object2 === null;
|
|
12660
|
+
}
|
|
12661
|
+
var _null4 = new type("tag:yaml.org,2002:null", {
|
|
12662
|
+
kind: "scalar",
|
|
12663
|
+
resolve: resolveYamlNull,
|
|
12664
|
+
construct: constructYamlNull,
|
|
12665
|
+
predicate: isNull,
|
|
12666
|
+
represent: {
|
|
12667
|
+
canonical: function() {
|
|
12668
|
+
return "~";
|
|
12669
|
+
},
|
|
12670
|
+
lowercase: function() {
|
|
12671
|
+
return "null";
|
|
12672
|
+
},
|
|
12673
|
+
uppercase: function() {
|
|
12674
|
+
return "NULL";
|
|
12675
|
+
},
|
|
12676
|
+
camelcase: function() {
|
|
12677
|
+
return "Null";
|
|
12678
|
+
},
|
|
12679
|
+
empty: function() {
|
|
12680
|
+
return "";
|
|
12681
|
+
}
|
|
12682
|
+
},
|
|
12683
|
+
defaultStyle: "lowercase"
|
|
12684
|
+
});
|
|
12685
|
+
function resolveYamlBoolean(data) {
|
|
12686
|
+
if (data === null)
|
|
12687
|
+
return false;
|
|
12688
|
+
var max = data.length;
|
|
12689
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
12690
|
+
}
|
|
12691
|
+
function constructYamlBoolean(data) {
|
|
12692
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
12693
|
+
}
|
|
12694
|
+
function isBoolean(object2) {
|
|
12695
|
+
return Object.prototype.toString.call(object2) === "[object Boolean]";
|
|
12696
|
+
}
|
|
12697
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
12698
|
+
kind: "scalar",
|
|
12699
|
+
resolve: resolveYamlBoolean,
|
|
12700
|
+
construct: constructYamlBoolean,
|
|
12701
|
+
predicate: isBoolean,
|
|
12702
|
+
represent: {
|
|
12703
|
+
lowercase: function(object2) {
|
|
12704
|
+
return object2 ? "true" : "false";
|
|
12705
|
+
},
|
|
12706
|
+
uppercase: function(object2) {
|
|
12707
|
+
return object2 ? "TRUE" : "FALSE";
|
|
12708
|
+
},
|
|
12709
|
+
camelcase: function(object2) {
|
|
12710
|
+
return object2 ? "True" : "False";
|
|
12711
|
+
}
|
|
12712
|
+
},
|
|
12713
|
+
defaultStyle: "lowercase"
|
|
12714
|
+
});
|
|
12715
|
+
function isHexCode(c) {
|
|
12716
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
12717
|
+
}
|
|
12718
|
+
function isOctCode(c) {
|
|
12719
|
+
return 48 <= c && c <= 55;
|
|
12720
|
+
}
|
|
12721
|
+
function isDecCode(c) {
|
|
12722
|
+
return 48 <= c && c <= 57;
|
|
12723
|
+
}
|
|
12724
|
+
function resolveYamlInteger(data) {
|
|
12725
|
+
if (data === null)
|
|
12726
|
+
return false;
|
|
12727
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
12728
|
+
if (!max)
|
|
12729
|
+
return false;
|
|
12730
|
+
ch = data[index];
|
|
12731
|
+
if (ch === "-" || ch === "+") {
|
|
12732
|
+
ch = data[++index];
|
|
12733
|
+
}
|
|
12734
|
+
if (ch === "0") {
|
|
12735
|
+
if (index + 1 === max)
|
|
12736
|
+
return true;
|
|
12737
|
+
ch = data[++index];
|
|
12738
|
+
if (ch === "b") {
|
|
12739
|
+
index++;
|
|
12740
|
+
for (;index < max; index++) {
|
|
12741
|
+
ch = data[index];
|
|
12742
|
+
if (ch === "_")
|
|
12743
|
+
continue;
|
|
12744
|
+
if (ch !== "0" && ch !== "1")
|
|
12745
|
+
return false;
|
|
12746
|
+
hasDigits = true;
|
|
12747
|
+
}
|
|
12748
|
+
return hasDigits && ch !== "_";
|
|
12749
|
+
}
|
|
12750
|
+
if (ch === "x") {
|
|
12751
|
+
index++;
|
|
12752
|
+
for (;index < max; index++) {
|
|
12753
|
+
ch = data[index];
|
|
12754
|
+
if (ch === "_")
|
|
12755
|
+
continue;
|
|
12756
|
+
if (!isHexCode(data.charCodeAt(index)))
|
|
12757
|
+
return false;
|
|
12758
|
+
hasDigits = true;
|
|
12759
|
+
}
|
|
12760
|
+
return hasDigits && ch !== "_";
|
|
12761
|
+
}
|
|
12762
|
+
if (ch === "o") {
|
|
12763
|
+
index++;
|
|
12764
|
+
for (;index < max; index++) {
|
|
12765
|
+
ch = data[index];
|
|
12766
|
+
if (ch === "_")
|
|
12767
|
+
continue;
|
|
12768
|
+
if (!isOctCode(data.charCodeAt(index)))
|
|
12769
|
+
return false;
|
|
12770
|
+
hasDigits = true;
|
|
12771
|
+
}
|
|
12772
|
+
return hasDigits && ch !== "_";
|
|
12773
|
+
}
|
|
12774
|
+
}
|
|
12775
|
+
if (ch === "_")
|
|
12776
|
+
return false;
|
|
12777
|
+
for (;index < max; index++) {
|
|
12778
|
+
ch = data[index];
|
|
12779
|
+
if (ch === "_")
|
|
12780
|
+
continue;
|
|
12781
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
12782
|
+
return false;
|
|
12783
|
+
}
|
|
12784
|
+
hasDigits = true;
|
|
12785
|
+
}
|
|
12786
|
+
if (!hasDigits || ch === "_")
|
|
12787
|
+
return false;
|
|
12788
|
+
return true;
|
|
12789
|
+
}
|
|
12790
|
+
function constructYamlInteger(data) {
|
|
12791
|
+
var value = data, sign = 1, ch;
|
|
12792
|
+
if (value.indexOf("_") !== -1) {
|
|
12793
|
+
value = value.replace(/_/g, "");
|
|
12794
|
+
}
|
|
12795
|
+
ch = value[0];
|
|
12796
|
+
if (ch === "-" || ch === "+") {
|
|
12797
|
+
if (ch === "-")
|
|
12798
|
+
sign = -1;
|
|
12799
|
+
value = value.slice(1);
|
|
12800
|
+
ch = value[0];
|
|
12801
|
+
}
|
|
12802
|
+
if (value === "0")
|
|
12803
|
+
return 0;
|
|
12804
|
+
if (ch === "0") {
|
|
12805
|
+
if (value[1] === "b")
|
|
12806
|
+
return sign * parseInt(value.slice(2), 2);
|
|
12807
|
+
if (value[1] === "x")
|
|
12808
|
+
return sign * parseInt(value.slice(2), 16);
|
|
12809
|
+
if (value[1] === "o")
|
|
12810
|
+
return sign * parseInt(value.slice(2), 8);
|
|
12811
|
+
}
|
|
12812
|
+
return sign * parseInt(value, 10);
|
|
12813
|
+
}
|
|
12814
|
+
function isInteger(object2) {
|
|
12815
|
+
return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 === 0 && !common.isNegativeZero(object2));
|
|
12816
|
+
}
|
|
12817
|
+
var int2 = new type("tag:yaml.org,2002:int", {
|
|
12818
|
+
kind: "scalar",
|
|
12819
|
+
resolve: resolveYamlInteger,
|
|
12820
|
+
construct: constructYamlInteger,
|
|
12821
|
+
predicate: isInteger,
|
|
12822
|
+
represent: {
|
|
12823
|
+
binary: function(obj) {
|
|
12824
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
12825
|
+
},
|
|
12826
|
+
octal: function(obj) {
|
|
12827
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
12828
|
+
},
|
|
12829
|
+
decimal: function(obj) {
|
|
12830
|
+
return obj.toString(10);
|
|
12831
|
+
},
|
|
12832
|
+
hexadecimal: function(obj) {
|
|
12833
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
12834
|
+
}
|
|
12835
|
+
},
|
|
12836
|
+
defaultStyle: "decimal",
|
|
12837
|
+
styleAliases: {
|
|
12838
|
+
binary: [2, "bin"],
|
|
12839
|
+
octal: [8, "oct"],
|
|
12840
|
+
decimal: [10, "dec"],
|
|
12841
|
+
hexadecimal: [16, "hex"]
|
|
12842
|
+
}
|
|
12843
|
+
});
|
|
12844
|
+
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))$");
|
|
12845
|
+
function resolveYamlFloat(data) {
|
|
12846
|
+
if (data === null)
|
|
12847
|
+
return false;
|
|
12848
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
12849
|
+
return false;
|
|
12850
|
+
}
|
|
12851
|
+
return true;
|
|
12852
|
+
}
|
|
12853
|
+
function constructYamlFloat(data) {
|
|
12854
|
+
var value, sign;
|
|
12855
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
12856
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
12857
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
12858
|
+
value = value.slice(1);
|
|
12859
|
+
}
|
|
12860
|
+
if (value === ".inf") {
|
|
12861
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
12862
|
+
} else if (value === ".nan") {
|
|
12863
|
+
return NaN;
|
|
12864
|
+
}
|
|
12865
|
+
return sign * parseFloat(value, 10);
|
|
12866
|
+
}
|
|
12867
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
12868
|
+
function representYamlFloat(object2, style) {
|
|
12869
|
+
var res;
|
|
12870
|
+
if (isNaN(object2)) {
|
|
12871
|
+
switch (style) {
|
|
12872
|
+
case "lowercase":
|
|
12873
|
+
return ".nan";
|
|
12874
|
+
case "uppercase":
|
|
12875
|
+
return ".NAN";
|
|
12876
|
+
case "camelcase":
|
|
12877
|
+
return ".NaN";
|
|
12878
|
+
}
|
|
12879
|
+
} else if (Number.POSITIVE_INFINITY === object2) {
|
|
12880
|
+
switch (style) {
|
|
12881
|
+
case "lowercase":
|
|
12882
|
+
return ".inf";
|
|
12883
|
+
case "uppercase":
|
|
12884
|
+
return ".INF";
|
|
12885
|
+
case "camelcase":
|
|
12886
|
+
return ".Inf";
|
|
12887
|
+
}
|
|
12888
|
+
} else if (Number.NEGATIVE_INFINITY === object2) {
|
|
12889
|
+
switch (style) {
|
|
12890
|
+
case "lowercase":
|
|
12891
|
+
return "-.inf";
|
|
12892
|
+
case "uppercase":
|
|
12893
|
+
return "-.INF";
|
|
12894
|
+
case "camelcase":
|
|
12895
|
+
return "-.Inf";
|
|
12896
|
+
}
|
|
12897
|
+
} else if (common.isNegativeZero(object2)) {
|
|
12898
|
+
return "-0.0";
|
|
12899
|
+
}
|
|
12900
|
+
res = object2.toString(10);
|
|
12901
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
12902
|
+
}
|
|
12903
|
+
function isFloat(object2) {
|
|
12904
|
+
return Object.prototype.toString.call(object2) === "[object Number]" && (object2 % 1 !== 0 || common.isNegativeZero(object2));
|
|
12905
|
+
}
|
|
12906
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
12907
|
+
kind: "scalar",
|
|
12908
|
+
resolve: resolveYamlFloat,
|
|
12909
|
+
construct: constructYamlFloat,
|
|
12910
|
+
predicate: isFloat,
|
|
12911
|
+
represent: representYamlFloat,
|
|
12912
|
+
defaultStyle: "lowercase"
|
|
12913
|
+
});
|
|
12914
|
+
var json2 = failsafe.extend({
|
|
12915
|
+
implicit: [
|
|
12916
|
+
_null4,
|
|
12917
|
+
bool,
|
|
12918
|
+
int2,
|
|
12919
|
+
float
|
|
12920
|
+
]
|
|
12921
|
+
});
|
|
12922
|
+
var core2 = json2;
|
|
12923
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
12924
|
+
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]))?))?$");
|
|
12925
|
+
function resolveYamlTimestamp(data) {
|
|
12926
|
+
if (data === null)
|
|
12927
|
+
return false;
|
|
12928
|
+
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
12929
|
+
return true;
|
|
12930
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
12931
|
+
return true;
|
|
12932
|
+
return false;
|
|
12933
|
+
}
|
|
12934
|
+
function constructYamlTimestamp(data) {
|
|
12935
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date5;
|
|
12936
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
12937
|
+
if (match === null)
|
|
12938
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
12939
|
+
if (match === null)
|
|
12940
|
+
throw new Error("Date resolve error");
|
|
12941
|
+
year = +match[1];
|
|
12942
|
+
month = +match[2] - 1;
|
|
12943
|
+
day = +match[3];
|
|
12944
|
+
if (!match[4]) {
|
|
12945
|
+
return new Date(Date.UTC(year, month, day));
|
|
12946
|
+
}
|
|
12947
|
+
hour = +match[4];
|
|
12948
|
+
minute = +match[5];
|
|
12949
|
+
second = +match[6];
|
|
12950
|
+
if (match[7]) {
|
|
12951
|
+
fraction = match[7].slice(0, 3);
|
|
12952
|
+
while (fraction.length < 3) {
|
|
12953
|
+
fraction += "0";
|
|
12954
|
+
}
|
|
12955
|
+
fraction = +fraction;
|
|
12956
|
+
}
|
|
12957
|
+
if (match[9]) {
|
|
12958
|
+
tz_hour = +match[10];
|
|
12959
|
+
tz_minute = +(match[11] || 0);
|
|
12960
|
+
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
12961
|
+
if (match[9] === "-")
|
|
12962
|
+
delta = -delta;
|
|
12963
|
+
}
|
|
12964
|
+
date5 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
12965
|
+
if (delta)
|
|
12966
|
+
date5.setTime(date5.getTime() - delta);
|
|
12967
|
+
return date5;
|
|
12968
|
+
}
|
|
12969
|
+
function representYamlTimestamp(object2) {
|
|
12970
|
+
return object2.toISOString();
|
|
12971
|
+
}
|
|
12972
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
12973
|
+
kind: "scalar",
|
|
12974
|
+
resolve: resolveYamlTimestamp,
|
|
12975
|
+
construct: constructYamlTimestamp,
|
|
12976
|
+
instanceOf: Date,
|
|
12977
|
+
represent: representYamlTimestamp
|
|
12978
|
+
});
|
|
12979
|
+
function resolveYamlMerge(data) {
|
|
12980
|
+
return data === "<<" || data === null;
|
|
12981
|
+
}
|
|
12982
|
+
var merge2 = new type("tag:yaml.org,2002:merge", {
|
|
12983
|
+
kind: "scalar",
|
|
12984
|
+
resolve: resolveYamlMerge
|
|
12985
|
+
});
|
|
12986
|
+
var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
12987
|
+
\r`;
|
|
12988
|
+
function resolveYamlBinary(data) {
|
|
12989
|
+
if (data === null)
|
|
12990
|
+
return false;
|
|
12991
|
+
var code, idx, bitlen = 0, max = data.length, map3 = BASE64_MAP;
|
|
12992
|
+
for (idx = 0;idx < max; idx++) {
|
|
12993
|
+
code = map3.indexOf(data.charAt(idx));
|
|
12994
|
+
if (code > 64)
|
|
12995
|
+
continue;
|
|
12996
|
+
if (code < 0)
|
|
12997
|
+
return false;
|
|
12998
|
+
bitlen += 6;
|
|
12999
|
+
}
|
|
13000
|
+
return bitlen % 8 === 0;
|
|
13001
|
+
}
|
|
13002
|
+
function constructYamlBinary(data) {
|
|
13003
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map3 = BASE64_MAP, bits = 0, result = [];
|
|
13004
|
+
for (idx = 0;idx < max; idx++) {
|
|
13005
|
+
if (idx % 4 === 0 && idx) {
|
|
13006
|
+
result.push(bits >> 16 & 255);
|
|
13007
|
+
result.push(bits >> 8 & 255);
|
|
13008
|
+
result.push(bits & 255);
|
|
13009
|
+
}
|
|
13010
|
+
bits = bits << 6 | map3.indexOf(input.charAt(idx));
|
|
13011
|
+
}
|
|
13012
|
+
tailbits = max % 4 * 6;
|
|
13013
|
+
if (tailbits === 0) {
|
|
13014
|
+
result.push(bits >> 16 & 255);
|
|
13015
|
+
result.push(bits >> 8 & 255);
|
|
13016
|
+
result.push(bits & 255);
|
|
13017
|
+
} else if (tailbits === 18) {
|
|
13018
|
+
result.push(bits >> 10 & 255);
|
|
13019
|
+
result.push(bits >> 2 & 255);
|
|
13020
|
+
} else if (tailbits === 12) {
|
|
13021
|
+
result.push(bits >> 4 & 255);
|
|
13022
|
+
}
|
|
13023
|
+
return new Uint8Array(result);
|
|
13024
|
+
}
|
|
13025
|
+
function representYamlBinary(object2) {
|
|
13026
|
+
var result = "", bits = 0, idx, tail, max = object2.length, map3 = BASE64_MAP;
|
|
13027
|
+
for (idx = 0;idx < max; idx++) {
|
|
13028
|
+
if (idx % 3 === 0 && idx) {
|
|
13029
|
+
result += map3[bits >> 18 & 63];
|
|
13030
|
+
result += map3[bits >> 12 & 63];
|
|
13031
|
+
result += map3[bits >> 6 & 63];
|
|
13032
|
+
result += map3[bits & 63];
|
|
13033
|
+
}
|
|
13034
|
+
bits = (bits << 8) + object2[idx];
|
|
13035
|
+
}
|
|
13036
|
+
tail = max % 3;
|
|
13037
|
+
if (tail === 0) {
|
|
13038
|
+
result += map3[bits >> 18 & 63];
|
|
13039
|
+
result += map3[bits >> 12 & 63];
|
|
13040
|
+
result += map3[bits >> 6 & 63];
|
|
13041
|
+
result += map3[bits & 63];
|
|
13042
|
+
} else if (tail === 2) {
|
|
13043
|
+
result += map3[bits >> 10 & 63];
|
|
13044
|
+
result += map3[bits >> 4 & 63];
|
|
13045
|
+
result += map3[bits << 2 & 63];
|
|
13046
|
+
result += map3[64];
|
|
13047
|
+
} else if (tail === 1) {
|
|
13048
|
+
result += map3[bits >> 2 & 63];
|
|
13049
|
+
result += map3[bits << 4 & 63];
|
|
13050
|
+
result += map3[64];
|
|
13051
|
+
result += map3[64];
|
|
13052
|
+
}
|
|
13053
|
+
return result;
|
|
13054
|
+
}
|
|
13055
|
+
function isBinary(obj) {
|
|
13056
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
13057
|
+
}
|
|
13058
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
13059
|
+
kind: "scalar",
|
|
13060
|
+
resolve: resolveYamlBinary,
|
|
13061
|
+
construct: constructYamlBinary,
|
|
13062
|
+
predicate: isBinary,
|
|
13063
|
+
represent: representYamlBinary
|
|
13064
|
+
});
|
|
13065
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
13066
|
+
var _toString$2 = Object.prototype.toString;
|
|
13067
|
+
function resolveYamlOmap(data) {
|
|
13068
|
+
if (data === null)
|
|
13069
|
+
return true;
|
|
13070
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object2 = data;
|
|
13071
|
+
for (index = 0, length = object2.length;index < length; index += 1) {
|
|
13072
|
+
pair = object2[index];
|
|
13073
|
+
pairHasKey = false;
|
|
13074
|
+
if (_toString$2.call(pair) !== "[object Object]")
|
|
13075
|
+
return false;
|
|
13076
|
+
for (pairKey in pair) {
|
|
13077
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
13078
|
+
if (!pairHasKey)
|
|
13079
|
+
pairHasKey = true;
|
|
13080
|
+
else
|
|
13081
|
+
return false;
|
|
13082
|
+
}
|
|
13083
|
+
}
|
|
13084
|
+
if (!pairHasKey)
|
|
13085
|
+
return false;
|
|
13086
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
13087
|
+
objectKeys.push(pairKey);
|
|
13088
|
+
else
|
|
13089
|
+
return false;
|
|
13090
|
+
}
|
|
13091
|
+
return true;
|
|
13092
|
+
}
|
|
13093
|
+
function constructYamlOmap(data) {
|
|
13094
|
+
return data !== null ? data : [];
|
|
13095
|
+
}
|
|
13096
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
13097
|
+
kind: "sequence",
|
|
13098
|
+
resolve: resolveYamlOmap,
|
|
13099
|
+
construct: constructYamlOmap
|
|
13100
|
+
});
|
|
13101
|
+
var _toString$1 = Object.prototype.toString;
|
|
13102
|
+
function resolveYamlPairs(data) {
|
|
13103
|
+
if (data === null)
|
|
13104
|
+
return true;
|
|
13105
|
+
var index, length, pair, keys, result, object2 = data;
|
|
13106
|
+
result = new Array(object2.length);
|
|
13107
|
+
for (index = 0, length = object2.length;index < length; index += 1) {
|
|
13108
|
+
pair = object2[index];
|
|
13109
|
+
if (_toString$1.call(pair) !== "[object Object]")
|
|
13110
|
+
return false;
|
|
13111
|
+
keys = Object.keys(pair);
|
|
13112
|
+
if (keys.length !== 1)
|
|
13113
|
+
return false;
|
|
13114
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
13115
|
+
}
|
|
13116
|
+
return true;
|
|
13117
|
+
}
|
|
13118
|
+
function constructYamlPairs(data) {
|
|
13119
|
+
if (data === null)
|
|
13120
|
+
return [];
|
|
13121
|
+
var index, length, pair, keys, result, object2 = data;
|
|
13122
|
+
result = new Array(object2.length);
|
|
13123
|
+
for (index = 0, length = object2.length;index < length; index += 1) {
|
|
13124
|
+
pair = object2[index];
|
|
13125
|
+
keys = Object.keys(pair);
|
|
13126
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
13127
|
+
}
|
|
13128
|
+
return result;
|
|
13129
|
+
}
|
|
13130
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
13131
|
+
kind: "sequence",
|
|
13132
|
+
resolve: resolveYamlPairs,
|
|
13133
|
+
construct: constructYamlPairs
|
|
13134
|
+
});
|
|
13135
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
13136
|
+
function resolveYamlSet(data) {
|
|
13137
|
+
if (data === null)
|
|
13138
|
+
return true;
|
|
13139
|
+
var key, object2 = data;
|
|
13140
|
+
for (key in object2) {
|
|
13141
|
+
if (_hasOwnProperty$2.call(object2, key)) {
|
|
13142
|
+
if (object2[key] !== null)
|
|
13143
|
+
return false;
|
|
13144
|
+
}
|
|
13145
|
+
}
|
|
13146
|
+
return true;
|
|
13147
|
+
}
|
|
13148
|
+
function constructYamlSet(data) {
|
|
13149
|
+
return data !== null ? data : {};
|
|
13150
|
+
}
|
|
13151
|
+
var set2 = new type("tag:yaml.org,2002:set", {
|
|
13152
|
+
kind: "mapping",
|
|
13153
|
+
resolve: resolveYamlSet,
|
|
13154
|
+
construct: constructYamlSet
|
|
13155
|
+
});
|
|
13156
|
+
var _default3 = core2.extend({
|
|
13157
|
+
implicit: [
|
|
13158
|
+
timestamp,
|
|
13159
|
+
merge2
|
|
13160
|
+
],
|
|
13161
|
+
explicit: [
|
|
13162
|
+
binary,
|
|
13163
|
+
omap,
|
|
13164
|
+
pairs,
|
|
13165
|
+
set2
|
|
13166
|
+
]
|
|
13167
|
+
});
|
|
13168
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
13169
|
+
var CONTEXT_FLOW_IN = 1;
|
|
13170
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
13171
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
13172
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
13173
|
+
var CHOMPING_CLIP = 1;
|
|
13174
|
+
var CHOMPING_STRIP = 2;
|
|
13175
|
+
var CHOMPING_KEEP = 3;
|
|
13176
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
13177
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
13178
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
13179
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
13180
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
13181
|
+
function _class(obj) {
|
|
13182
|
+
return Object.prototype.toString.call(obj);
|
|
13183
|
+
}
|
|
13184
|
+
function is_EOL(c) {
|
|
13185
|
+
return c === 10 || c === 13;
|
|
13186
|
+
}
|
|
13187
|
+
function is_WHITE_SPACE(c) {
|
|
13188
|
+
return c === 9 || c === 32;
|
|
13189
|
+
}
|
|
13190
|
+
function is_WS_OR_EOL(c) {
|
|
13191
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
13192
|
+
}
|
|
13193
|
+
function is_FLOW_INDICATOR(c) {
|
|
13194
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
13195
|
+
}
|
|
13196
|
+
function fromHexCode(c) {
|
|
13197
|
+
var lc;
|
|
13198
|
+
if (48 <= c && c <= 57) {
|
|
13199
|
+
return c - 48;
|
|
13200
|
+
}
|
|
13201
|
+
lc = c | 32;
|
|
13202
|
+
if (97 <= lc && lc <= 102) {
|
|
13203
|
+
return lc - 97 + 10;
|
|
13204
|
+
}
|
|
13205
|
+
return -1;
|
|
13206
|
+
}
|
|
13207
|
+
function escapedHexLen(c) {
|
|
13208
|
+
if (c === 120) {
|
|
13209
|
+
return 2;
|
|
13210
|
+
}
|
|
13211
|
+
if (c === 117) {
|
|
13212
|
+
return 4;
|
|
13213
|
+
}
|
|
13214
|
+
if (c === 85) {
|
|
13215
|
+
return 8;
|
|
13216
|
+
}
|
|
13217
|
+
return 0;
|
|
13218
|
+
}
|
|
13219
|
+
function fromDecimalCode(c) {
|
|
13220
|
+
if (48 <= c && c <= 57) {
|
|
13221
|
+
return c - 48;
|
|
13222
|
+
}
|
|
13223
|
+
return -1;
|
|
13224
|
+
}
|
|
13225
|
+
function simpleEscapeSequence(c) {
|
|
13226
|
+
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
13227
|
+
` : 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" : "";
|
|
13228
|
+
}
|
|
13229
|
+
function charFromCodepoint(c) {
|
|
13230
|
+
if (c <= 65535) {
|
|
13231
|
+
return String.fromCharCode(c);
|
|
13232
|
+
}
|
|
13233
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
13234
|
+
}
|
|
13235
|
+
function setProperty(object2, key, value) {
|
|
13236
|
+
if (key === "__proto__") {
|
|
13237
|
+
Object.defineProperty(object2, key, {
|
|
13238
|
+
configurable: true,
|
|
13239
|
+
enumerable: true,
|
|
13240
|
+
writable: true,
|
|
13241
|
+
value
|
|
13242
|
+
});
|
|
13243
|
+
} else {
|
|
13244
|
+
object2[key] = value;
|
|
13245
|
+
}
|
|
13246
|
+
}
|
|
13247
|
+
var simpleEscapeCheck = new Array(256);
|
|
13248
|
+
var simpleEscapeMap = new Array(256);
|
|
13249
|
+
for (i = 0;i < 256; i++) {
|
|
13250
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
13251
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
13252
|
+
}
|
|
13253
|
+
var i;
|
|
13254
|
+
function State$1(input, options) {
|
|
13255
|
+
this.input = input;
|
|
13256
|
+
this.filename = options["filename"] || null;
|
|
13257
|
+
this.schema = options["schema"] || _default3;
|
|
13258
|
+
this.onWarning = options["onWarning"] || null;
|
|
13259
|
+
this.legacy = options["legacy"] || false;
|
|
13260
|
+
this.json = options["json"] || false;
|
|
13261
|
+
this.listener = options["listener"] || null;
|
|
13262
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
13263
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
13264
|
+
this.length = input.length;
|
|
13265
|
+
this.position = 0;
|
|
13266
|
+
this.line = 0;
|
|
13267
|
+
this.lineStart = 0;
|
|
13268
|
+
this.lineIndent = 0;
|
|
13269
|
+
this.firstTabInLine = -1;
|
|
13270
|
+
this.documents = [];
|
|
13271
|
+
}
|
|
13272
|
+
function generateError(state, message) {
|
|
13273
|
+
var mark = {
|
|
13274
|
+
name: state.filename,
|
|
13275
|
+
buffer: state.input.slice(0, -1),
|
|
13276
|
+
position: state.position,
|
|
13277
|
+
line: state.line,
|
|
13278
|
+
column: state.position - state.lineStart
|
|
13279
|
+
};
|
|
13280
|
+
mark.snippet = snippet(mark);
|
|
13281
|
+
return new exception(message, mark);
|
|
13282
|
+
}
|
|
13283
|
+
function throwError(state, message) {
|
|
13284
|
+
throw generateError(state, message);
|
|
13285
|
+
}
|
|
13286
|
+
function throwWarning(state, message) {
|
|
13287
|
+
if (state.onWarning) {
|
|
13288
|
+
state.onWarning.call(null, generateError(state, message));
|
|
13289
|
+
}
|
|
13290
|
+
}
|
|
13291
|
+
var directiveHandlers = {
|
|
13292
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
13293
|
+
var match, major, minor;
|
|
13294
|
+
if (state.version !== null) {
|
|
13295
|
+
throwError(state, "duplication of %YAML directive");
|
|
13296
|
+
}
|
|
13297
|
+
if (args.length !== 1) {
|
|
13298
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
13299
|
+
}
|
|
13300
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
13301
|
+
if (match === null) {
|
|
13302
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
13303
|
+
}
|
|
13304
|
+
major = parseInt(match[1], 10);
|
|
13305
|
+
minor = parseInt(match[2], 10);
|
|
13306
|
+
if (major !== 1) {
|
|
13307
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
13308
|
+
}
|
|
13309
|
+
state.version = args[0];
|
|
13310
|
+
state.checkLineBreaks = minor < 2;
|
|
13311
|
+
if (minor !== 1 && minor !== 2) {
|
|
13312
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
13313
|
+
}
|
|
13314
|
+
},
|
|
13315
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
13316
|
+
var handle, prefix;
|
|
13317
|
+
if (args.length !== 2) {
|
|
13318
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
13319
|
+
}
|
|
13320
|
+
handle = args[0];
|
|
13321
|
+
prefix = args[1];
|
|
13322
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
13323
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
13324
|
+
}
|
|
13325
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
13326
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
13327
|
+
}
|
|
13328
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
13329
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
13330
|
+
}
|
|
13331
|
+
try {
|
|
13332
|
+
prefix = decodeURIComponent(prefix);
|
|
13333
|
+
} catch (err) {
|
|
13334
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
13335
|
+
}
|
|
13336
|
+
state.tagMap[handle] = prefix;
|
|
13337
|
+
}
|
|
13338
|
+
};
|
|
13339
|
+
function captureSegment(state, start, end, checkJson) {
|
|
13340
|
+
var _position, _length2, _character, _result;
|
|
13341
|
+
if (start < end) {
|
|
13342
|
+
_result = state.input.slice(start, end);
|
|
13343
|
+
if (checkJson) {
|
|
13344
|
+
for (_position = 0, _length2 = _result.length;_position < _length2; _position += 1) {
|
|
13345
|
+
_character = _result.charCodeAt(_position);
|
|
13346
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
13347
|
+
throwError(state, "expected valid JSON character");
|
|
13348
|
+
}
|
|
13349
|
+
}
|
|
13350
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
13351
|
+
throwError(state, "the stream contains non-printable characters");
|
|
13352
|
+
}
|
|
13353
|
+
state.result += _result;
|
|
13354
|
+
}
|
|
13355
|
+
}
|
|
13356
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
13357
|
+
var sourceKeys, key, index, quantity;
|
|
13358
|
+
if (!common.isObject(source)) {
|
|
13359
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
13360
|
+
}
|
|
13361
|
+
sourceKeys = Object.keys(source);
|
|
13362
|
+
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
13363
|
+
key = sourceKeys[index];
|
|
13364
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
13365
|
+
setProperty(destination, key, source[key]);
|
|
13366
|
+
overridableKeys[key] = true;
|
|
13367
|
+
}
|
|
13368
|
+
}
|
|
13369
|
+
}
|
|
13370
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
13371
|
+
var index, quantity;
|
|
13372
|
+
if (Array.isArray(keyNode)) {
|
|
13373
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
13374
|
+
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
13375
|
+
if (Array.isArray(keyNode[index])) {
|
|
13376
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
13377
|
+
}
|
|
13378
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
13379
|
+
keyNode[index] = "[object Object]";
|
|
13380
|
+
}
|
|
13381
|
+
}
|
|
13382
|
+
}
|
|
13383
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
13384
|
+
keyNode = "[object Object]";
|
|
13385
|
+
}
|
|
13386
|
+
keyNode = String(keyNode);
|
|
13387
|
+
if (_result === null) {
|
|
13388
|
+
_result = {};
|
|
13389
|
+
}
|
|
13390
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
13391
|
+
if (Array.isArray(valueNode)) {
|
|
13392
|
+
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
13393
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
13394
|
+
}
|
|
13395
|
+
} else {
|
|
13396
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
13397
|
+
}
|
|
13398
|
+
} else {
|
|
13399
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
13400
|
+
state.line = startLine || state.line;
|
|
13401
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
13402
|
+
state.position = startPos || state.position;
|
|
13403
|
+
throwError(state, "duplicated mapping key");
|
|
13404
|
+
}
|
|
13405
|
+
setProperty(_result, keyNode, valueNode);
|
|
13406
|
+
delete overridableKeys[keyNode];
|
|
13407
|
+
}
|
|
13408
|
+
return _result;
|
|
13409
|
+
}
|
|
13410
|
+
function readLineBreak(state) {
|
|
13411
|
+
var ch;
|
|
13412
|
+
ch = state.input.charCodeAt(state.position);
|
|
13413
|
+
if (ch === 10) {
|
|
13414
|
+
state.position++;
|
|
13415
|
+
} else if (ch === 13) {
|
|
13416
|
+
state.position++;
|
|
13417
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
13418
|
+
state.position++;
|
|
13419
|
+
}
|
|
13420
|
+
} else {
|
|
13421
|
+
throwError(state, "a line break is expected");
|
|
13422
|
+
}
|
|
13423
|
+
state.line += 1;
|
|
13424
|
+
state.lineStart = state.position;
|
|
13425
|
+
state.firstTabInLine = -1;
|
|
13426
|
+
}
|
|
13427
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
13428
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
13429
|
+
while (ch !== 0) {
|
|
13430
|
+
while (is_WHITE_SPACE(ch)) {
|
|
13431
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
13432
|
+
state.firstTabInLine = state.position;
|
|
13433
|
+
}
|
|
13434
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13435
|
+
}
|
|
13436
|
+
if (allowComments && ch === 35) {
|
|
13437
|
+
do {
|
|
13438
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13439
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
13440
|
+
}
|
|
13441
|
+
if (is_EOL(ch)) {
|
|
13442
|
+
readLineBreak(state);
|
|
13443
|
+
ch = state.input.charCodeAt(state.position);
|
|
13444
|
+
lineBreaks++;
|
|
13445
|
+
state.lineIndent = 0;
|
|
13446
|
+
while (ch === 32) {
|
|
13447
|
+
state.lineIndent++;
|
|
13448
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13449
|
+
}
|
|
13450
|
+
} else {
|
|
13451
|
+
break;
|
|
13452
|
+
}
|
|
13453
|
+
}
|
|
13454
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
13455
|
+
throwWarning(state, "deficient indentation");
|
|
13456
|
+
}
|
|
13457
|
+
return lineBreaks;
|
|
13458
|
+
}
|
|
13459
|
+
function testDocumentSeparator(state) {
|
|
13460
|
+
var _position = state.position, ch;
|
|
13461
|
+
ch = state.input.charCodeAt(_position);
|
|
13462
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
13463
|
+
_position += 3;
|
|
13464
|
+
ch = state.input.charCodeAt(_position);
|
|
13465
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
13466
|
+
return true;
|
|
13467
|
+
}
|
|
13468
|
+
}
|
|
13469
|
+
return false;
|
|
13470
|
+
}
|
|
13471
|
+
function writeFoldedLines(state, count) {
|
|
13472
|
+
if (count === 1) {
|
|
13473
|
+
state.result += " ";
|
|
13474
|
+
} else if (count > 1) {
|
|
13475
|
+
state.result += common.repeat(`
|
|
13476
|
+
`, count - 1);
|
|
13477
|
+
}
|
|
13478
|
+
}
|
|
13479
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
13480
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
13481
|
+
ch = state.input.charCodeAt(state.position);
|
|
13482
|
+
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) {
|
|
13483
|
+
return false;
|
|
13484
|
+
}
|
|
13485
|
+
if (ch === 63 || ch === 45) {
|
|
13486
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13487
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
13488
|
+
return false;
|
|
13489
|
+
}
|
|
13490
|
+
}
|
|
13491
|
+
state.kind = "scalar";
|
|
13492
|
+
state.result = "";
|
|
13493
|
+
captureStart = captureEnd = state.position;
|
|
13494
|
+
hasPendingContent = false;
|
|
13495
|
+
while (ch !== 0) {
|
|
13496
|
+
if (ch === 58) {
|
|
13497
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13498
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
13499
|
+
break;
|
|
13500
|
+
}
|
|
13501
|
+
} else if (ch === 35) {
|
|
13502
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
13503
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
13504
|
+
break;
|
|
13505
|
+
}
|
|
13506
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
13507
|
+
break;
|
|
13508
|
+
} else if (is_EOL(ch)) {
|
|
13509
|
+
_line = state.line;
|
|
13510
|
+
_lineStart = state.lineStart;
|
|
13511
|
+
_lineIndent = state.lineIndent;
|
|
13512
|
+
skipSeparationSpace(state, false, -1);
|
|
13513
|
+
if (state.lineIndent >= nodeIndent) {
|
|
13514
|
+
hasPendingContent = true;
|
|
13515
|
+
ch = state.input.charCodeAt(state.position);
|
|
13516
|
+
continue;
|
|
13517
|
+
} else {
|
|
13518
|
+
state.position = captureEnd;
|
|
13519
|
+
state.line = _line;
|
|
13520
|
+
state.lineStart = _lineStart;
|
|
13521
|
+
state.lineIndent = _lineIndent;
|
|
13522
|
+
break;
|
|
13523
|
+
}
|
|
13524
|
+
}
|
|
13525
|
+
if (hasPendingContent) {
|
|
13526
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
13527
|
+
writeFoldedLines(state, state.line - _line);
|
|
13528
|
+
captureStart = captureEnd = state.position;
|
|
13529
|
+
hasPendingContent = false;
|
|
13530
|
+
}
|
|
13531
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
13532
|
+
captureEnd = state.position + 1;
|
|
13533
|
+
}
|
|
13534
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13535
|
+
}
|
|
13536
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
13537
|
+
if (state.result) {
|
|
13538
|
+
return true;
|
|
13539
|
+
}
|
|
13540
|
+
state.kind = _kind;
|
|
13541
|
+
state.result = _result;
|
|
13542
|
+
return false;
|
|
13543
|
+
}
|
|
13544
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
13545
|
+
var ch, captureStart, captureEnd;
|
|
13546
|
+
ch = state.input.charCodeAt(state.position);
|
|
13547
|
+
if (ch !== 39) {
|
|
13548
|
+
return false;
|
|
13549
|
+
}
|
|
13550
|
+
state.kind = "scalar";
|
|
13551
|
+
state.result = "";
|
|
13552
|
+
state.position++;
|
|
13553
|
+
captureStart = captureEnd = state.position;
|
|
13554
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
13555
|
+
if (ch === 39) {
|
|
13556
|
+
captureSegment(state, captureStart, state.position, true);
|
|
13557
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13558
|
+
if (ch === 39) {
|
|
13559
|
+
captureStart = state.position;
|
|
13560
|
+
state.position++;
|
|
13561
|
+
captureEnd = state.position;
|
|
13562
|
+
} else {
|
|
13563
|
+
return true;
|
|
13564
|
+
}
|
|
13565
|
+
} else if (is_EOL(ch)) {
|
|
13566
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
13567
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
13568
|
+
captureStart = captureEnd = state.position;
|
|
13569
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
13570
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
13571
|
+
} else {
|
|
13572
|
+
state.position++;
|
|
13573
|
+
captureEnd = state.position;
|
|
13574
|
+
}
|
|
13575
|
+
}
|
|
13576
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
13577
|
+
}
|
|
13578
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
13579
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
13580
|
+
ch = state.input.charCodeAt(state.position);
|
|
13581
|
+
if (ch !== 34) {
|
|
13582
|
+
return false;
|
|
13583
|
+
}
|
|
13584
|
+
state.kind = "scalar";
|
|
13585
|
+
state.result = "";
|
|
13586
|
+
state.position++;
|
|
13587
|
+
captureStart = captureEnd = state.position;
|
|
13588
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
13589
|
+
if (ch === 34) {
|
|
13590
|
+
captureSegment(state, captureStart, state.position, true);
|
|
13591
|
+
state.position++;
|
|
13592
|
+
return true;
|
|
13593
|
+
} else if (ch === 92) {
|
|
13594
|
+
captureSegment(state, captureStart, state.position, true);
|
|
13595
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13596
|
+
if (is_EOL(ch)) {
|
|
13597
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
13598
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
13599
|
+
state.result += simpleEscapeMap[ch];
|
|
13600
|
+
state.position++;
|
|
13601
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
13602
|
+
hexLength = tmp;
|
|
13603
|
+
hexResult = 0;
|
|
13604
|
+
for (;hexLength > 0; hexLength--) {
|
|
13605
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13606
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
13607
|
+
hexResult = (hexResult << 4) + tmp;
|
|
13608
|
+
} else {
|
|
13609
|
+
throwError(state, "expected hexadecimal character");
|
|
13610
|
+
}
|
|
13611
|
+
}
|
|
13612
|
+
state.result += charFromCodepoint(hexResult);
|
|
13613
|
+
state.position++;
|
|
13614
|
+
} else {
|
|
13615
|
+
throwError(state, "unknown escape sequence");
|
|
13616
|
+
}
|
|
13617
|
+
captureStart = captureEnd = state.position;
|
|
13618
|
+
} else if (is_EOL(ch)) {
|
|
13619
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
13620
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
13621
|
+
captureStart = captureEnd = state.position;
|
|
13622
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
13623
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
13624
|
+
} else {
|
|
13625
|
+
state.position++;
|
|
13626
|
+
captureEnd = state.position;
|
|
13627
|
+
}
|
|
13628
|
+
}
|
|
13629
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
13630
|
+
}
|
|
13631
|
+
function readFlowCollection(state, nodeIndent) {
|
|
13632
|
+
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;
|
|
13633
|
+
ch = state.input.charCodeAt(state.position);
|
|
13634
|
+
if (ch === 91) {
|
|
13635
|
+
terminator = 93;
|
|
13636
|
+
isMapping = false;
|
|
13637
|
+
_result = [];
|
|
13638
|
+
} else if (ch === 123) {
|
|
13639
|
+
terminator = 125;
|
|
13640
|
+
isMapping = true;
|
|
13641
|
+
_result = {};
|
|
13642
|
+
} else {
|
|
13643
|
+
return false;
|
|
13644
|
+
}
|
|
13645
|
+
if (state.anchor !== null) {
|
|
13646
|
+
state.anchorMap[state.anchor] = _result;
|
|
13647
|
+
}
|
|
13648
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13649
|
+
while (ch !== 0) {
|
|
13650
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
13651
|
+
ch = state.input.charCodeAt(state.position);
|
|
13652
|
+
if (ch === terminator) {
|
|
13653
|
+
state.position++;
|
|
13654
|
+
state.tag = _tag;
|
|
13655
|
+
state.anchor = _anchor;
|
|
13656
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
13657
|
+
state.result = _result;
|
|
13658
|
+
return true;
|
|
13659
|
+
} else if (!readNext) {
|
|
13660
|
+
throwError(state, "missed comma between flow collection entries");
|
|
13661
|
+
} else if (ch === 44) {
|
|
13662
|
+
throwError(state, "expected the node content, but found ','");
|
|
13663
|
+
}
|
|
13664
|
+
keyTag = keyNode = valueNode = null;
|
|
13665
|
+
isPair = isExplicitPair = false;
|
|
13666
|
+
if (ch === 63) {
|
|
13667
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13668
|
+
if (is_WS_OR_EOL(following)) {
|
|
13669
|
+
isPair = isExplicitPair = true;
|
|
13670
|
+
state.position++;
|
|
13671
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
13672
|
+
}
|
|
13673
|
+
}
|
|
13674
|
+
_line = state.line;
|
|
13675
|
+
_lineStart = state.lineStart;
|
|
13676
|
+
_pos = state.position;
|
|
13677
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
13678
|
+
keyTag = state.tag;
|
|
13679
|
+
keyNode = state.result;
|
|
13680
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
13681
|
+
ch = state.input.charCodeAt(state.position);
|
|
13682
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
13683
|
+
isPair = true;
|
|
13684
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13685
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
13686
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
13687
|
+
valueNode = state.result;
|
|
13688
|
+
}
|
|
13689
|
+
if (isMapping) {
|
|
13690
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
13691
|
+
} else if (isPair) {
|
|
13692
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
13693
|
+
} else {
|
|
13694
|
+
_result.push(keyNode);
|
|
13695
|
+
}
|
|
13696
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
13697
|
+
ch = state.input.charCodeAt(state.position);
|
|
13698
|
+
if (ch === 44) {
|
|
13699
|
+
readNext = true;
|
|
13700
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13701
|
+
} else {
|
|
13702
|
+
readNext = false;
|
|
13703
|
+
}
|
|
13704
|
+
}
|
|
13705
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
13706
|
+
}
|
|
13707
|
+
function readBlockScalar(state, nodeIndent) {
|
|
13708
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
13709
|
+
ch = state.input.charCodeAt(state.position);
|
|
13710
|
+
if (ch === 124) {
|
|
13711
|
+
folding = false;
|
|
13712
|
+
} else if (ch === 62) {
|
|
13713
|
+
folding = true;
|
|
13714
|
+
} else {
|
|
13715
|
+
return false;
|
|
13716
|
+
}
|
|
13717
|
+
state.kind = "scalar";
|
|
13718
|
+
state.result = "";
|
|
13719
|
+
while (ch !== 0) {
|
|
13720
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13721
|
+
if (ch === 43 || ch === 45) {
|
|
13722
|
+
if (CHOMPING_CLIP === chomping) {
|
|
13723
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
13724
|
+
} else {
|
|
13725
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
13726
|
+
}
|
|
13727
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
13728
|
+
if (tmp === 0) {
|
|
13729
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
13730
|
+
} else if (!detectedIndent) {
|
|
13731
|
+
textIndent = nodeIndent + tmp - 1;
|
|
13732
|
+
detectedIndent = true;
|
|
13733
|
+
} else {
|
|
13734
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
13735
|
+
}
|
|
13736
|
+
} else {
|
|
13737
|
+
break;
|
|
13738
|
+
}
|
|
13739
|
+
}
|
|
13740
|
+
if (is_WHITE_SPACE(ch)) {
|
|
13741
|
+
do {
|
|
13742
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13743
|
+
} while (is_WHITE_SPACE(ch));
|
|
13744
|
+
if (ch === 35) {
|
|
13745
|
+
do {
|
|
13746
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13747
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
13748
|
+
}
|
|
13749
|
+
}
|
|
13750
|
+
while (ch !== 0) {
|
|
13751
|
+
readLineBreak(state);
|
|
13752
|
+
state.lineIndent = 0;
|
|
13753
|
+
ch = state.input.charCodeAt(state.position);
|
|
13754
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
13755
|
+
state.lineIndent++;
|
|
13756
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13757
|
+
}
|
|
13758
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
13759
|
+
textIndent = state.lineIndent;
|
|
13760
|
+
}
|
|
13761
|
+
if (is_EOL(ch)) {
|
|
13762
|
+
emptyLines++;
|
|
13763
|
+
continue;
|
|
13764
|
+
}
|
|
13765
|
+
if (state.lineIndent < textIndent) {
|
|
13766
|
+
if (chomping === CHOMPING_KEEP) {
|
|
13767
|
+
state.result += common.repeat(`
|
|
13768
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
13769
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
13770
|
+
if (didReadContent) {
|
|
13771
|
+
state.result += `
|
|
13772
|
+
`;
|
|
13773
|
+
}
|
|
13774
|
+
}
|
|
13775
|
+
break;
|
|
13776
|
+
}
|
|
13777
|
+
if (folding) {
|
|
13778
|
+
if (is_WHITE_SPACE(ch)) {
|
|
13779
|
+
atMoreIndented = true;
|
|
13780
|
+
state.result += common.repeat(`
|
|
13781
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
13782
|
+
} else if (atMoreIndented) {
|
|
13783
|
+
atMoreIndented = false;
|
|
13784
|
+
state.result += common.repeat(`
|
|
13785
|
+
`, emptyLines + 1);
|
|
13786
|
+
} else if (emptyLines === 0) {
|
|
13787
|
+
if (didReadContent) {
|
|
13788
|
+
state.result += " ";
|
|
13789
|
+
}
|
|
13790
|
+
} else {
|
|
13791
|
+
state.result += common.repeat(`
|
|
13792
|
+
`, emptyLines);
|
|
13793
|
+
}
|
|
13794
|
+
} else {
|
|
13795
|
+
state.result += common.repeat(`
|
|
13796
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
13797
|
+
}
|
|
13798
|
+
didReadContent = true;
|
|
13799
|
+
detectedIndent = true;
|
|
13800
|
+
emptyLines = 0;
|
|
13801
|
+
captureStart = state.position;
|
|
13802
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
13803
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13804
|
+
}
|
|
13805
|
+
captureSegment(state, captureStart, state.position, false);
|
|
13806
|
+
}
|
|
13807
|
+
return true;
|
|
13808
|
+
}
|
|
13809
|
+
function readBlockSequence(state, nodeIndent) {
|
|
13810
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
13811
|
+
if (state.firstTabInLine !== -1)
|
|
13812
|
+
return false;
|
|
13813
|
+
if (state.anchor !== null) {
|
|
13814
|
+
state.anchorMap[state.anchor] = _result;
|
|
13815
|
+
}
|
|
13816
|
+
ch = state.input.charCodeAt(state.position);
|
|
13817
|
+
while (ch !== 0) {
|
|
13818
|
+
if (state.firstTabInLine !== -1) {
|
|
13819
|
+
state.position = state.firstTabInLine;
|
|
13820
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
13821
|
+
}
|
|
13822
|
+
if (ch !== 45) {
|
|
13823
|
+
break;
|
|
13824
|
+
}
|
|
13825
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13826
|
+
if (!is_WS_OR_EOL(following)) {
|
|
13827
|
+
break;
|
|
13828
|
+
}
|
|
13829
|
+
detected = true;
|
|
13830
|
+
state.position++;
|
|
13831
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
13832
|
+
if (state.lineIndent <= nodeIndent) {
|
|
13833
|
+
_result.push(null);
|
|
13834
|
+
ch = state.input.charCodeAt(state.position);
|
|
13835
|
+
continue;
|
|
13836
|
+
}
|
|
13837
|
+
}
|
|
13838
|
+
_line = state.line;
|
|
13839
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
13840
|
+
_result.push(state.result);
|
|
13841
|
+
skipSeparationSpace(state, true, -1);
|
|
13842
|
+
ch = state.input.charCodeAt(state.position);
|
|
13843
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
13844
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
13845
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
13846
|
+
break;
|
|
13847
|
+
}
|
|
13848
|
+
}
|
|
13849
|
+
if (detected) {
|
|
13850
|
+
state.tag = _tag;
|
|
13851
|
+
state.anchor = _anchor;
|
|
13852
|
+
state.kind = "sequence";
|
|
13853
|
+
state.result = _result;
|
|
13854
|
+
return true;
|
|
13855
|
+
}
|
|
13856
|
+
return false;
|
|
13857
|
+
}
|
|
13858
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
13859
|
+
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;
|
|
13860
|
+
if (state.firstTabInLine !== -1)
|
|
13861
|
+
return false;
|
|
13862
|
+
if (state.anchor !== null) {
|
|
13863
|
+
state.anchorMap[state.anchor] = _result;
|
|
13864
|
+
}
|
|
13865
|
+
ch = state.input.charCodeAt(state.position);
|
|
13866
|
+
while (ch !== 0) {
|
|
13867
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
13868
|
+
state.position = state.firstTabInLine;
|
|
13869
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
13870
|
+
}
|
|
13871
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13872
|
+
_line = state.line;
|
|
13873
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
13874
|
+
if (ch === 63) {
|
|
13875
|
+
if (atExplicitKey) {
|
|
13876
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
13877
|
+
keyTag = keyNode = valueNode = null;
|
|
13878
|
+
}
|
|
13879
|
+
detected = true;
|
|
13880
|
+
atExplicitKey = true;
|
|
13881
|
+
allowCompact = true;
|
|
13882
|
+
} else if (atExplicitKey) {
|
|
13883
|
+
atExplicitKey = false;
|
|
13884
|
+
allowCompact = true;
|
|
13885
|
+
} else {
|
|
13886
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
13887
|
+
}
|
|
13888
|
+
state.position += 1;
|
|
13889
|
+
ch = following;
|
|
13890
|
+
} else {
|
|
13891
|
+
_keyLine = state.line;
|
|
13892
|
+
_keyLineStart = state.lineStart;
|
|
13893
|
+
_keyPos = state.position;
|
|
13894
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
13895
|
+
break;
|
|
13896
|
+
}
|
|
13897
|
+
if (state.line === _line) {
|
|
13898
|
+
ch = state.input.charCodeAt(state.position);
|
|
13899
|
+
while (is_WHITE_SPACE(ch)) {
|
|
13900
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13901
|
+
}
|
|
13902
|
+
if (ch === 58) {
|
|
13903
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13904
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
13905
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
13906
|
+
}
|
|
13907
|
+
if (atExplicitKey) {
|
|
13908
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
13909
|
+
keyTag = keyNode = valueNode = null;
|
|
13910
|
+
}
|
|
13911
|
+
detected = true;
|
|
13912
|
+
atExplicitKey = false;
|
|
13913
|
+
allowCompact = false;
|
|
13914
|
+
keyTag = state.tag;
|
|
13915
|
+
keyNode = state.result;
|
|
13916
|
+
} else if (detected) {
|
|
13917
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
13918
|
+
} else {
|
|
13919
|
+
state.tag = _tag;
|
|
13920
|
+
state.anchor = _anchor;
|
|
13921
|
+
return true;
|
|
13922
|
+
}
|
|
13923
|
+
} else if (detected) {
|
|
13924
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
13925
|
+
} else {
|
|
13926
|
+
state.tag = _tag;
|
|
13927
|
+
state.anchor = _anchor;
|
|
13928
|
+
return true;
|
|
13929
|
+
}
|
|
13930
|
+
}
|
|
13931
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
13932
|
+
if (atExplicitKey) {
|
|
13933
|
+
_keyLine = state.line;
|
|
13934
|
+
_keyLineStart = state.lineStart;
|
|
13935
|
+
_keyPos = state.position;
|
|
13936
|
+
}
|
|
13937
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
13938
|
+
if (atExplicitKey) {
|
|
13939
|
+
keyNode = state.result;
|
|
13940
|
+
} else {
|
|
13941
|
+
valueNode = state.result;
|
|
13942
|
+
}
|
|
13943
|
+
}
|
|
13944
|
+
if (!atExplicitKey) {
|
|
13945
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
13946
|
+
keyTag = keyNode = valueNode = null;
|
|
13947
|
+
}
|
|
13948
|
+
skipSeparationSpace(state, true, -1);
|
|
13949
|
+
ch = state.input.charCodeAt(state.position);
|
|
13950
|
+
}
|
|
13951
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
13952
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
13953
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
13954
|
+
break;
|
|
13955
|
+
}
|
|
13956
|
+
}
|
|
13957
|
+
if (atExplicitKey) {
|
|
13958
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
13959
|
+
}
|
|
13960
|
+
if (detected) {
|
|
13961
|
+
state.tag = _tag;
|
|
13962
|
+
state.anchor = _anchor;
|
|
13963
|
+
state.kind = "mapping";
|
|
13964
|
+
state.result = _result;
|
|
13965
|
+
}
|
|
13966
|
+
return detected;
|
|
13967
|
+
}
|
|
13968
|
+
function readTagProperty(state) {
|
|
13969
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
13970
|
+
ch = state.input.charCodeAt(state.position);
|
|
13971
|
+
if (ch !== 33)
|
|
13972
|
+
return false;
|
|
13973
|
+
if (state.tag !== null) {
|
|
13974
|
+
throwError(state, "duplication of a tag property");
|
|
13975
|
+
}
|
|
13976
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13977
|
+
if (ch === 60) {
|
|
13978
|
+
isVerbatim = true;
|
|
13979
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13980
|
+
} else if (ch === 33) {
|
|
13981
|
+
isNamed = true;
|
|
13982
|
+
tagHandle = "!!";
|
|
13983
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13984
|
+
} else {
|
|
13985
|
+
tagHandle = "!";
|
|
13986
|
+
}
|
|
13987
|
+
_position = state.position;
|
|
13988
|
+
if (isVerbatim) {
|
|
13989
|
+
do {
|
|
13990
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13991
|
+
} while (ch !== 0 && ch !== 62);
|
|
13992
|
+
if (state.position < state.length) {
|
|
13993
|
+
tagName = state.input.slice(_position, state.position);
|
|
13994
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13995
|
+
} else {
|
|
13996
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
13997
|
+
}
|
|
13998
|
+
} else {
|
|
13999
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
14000
|
+
if (ch === 33) {
|
|
14001
|
+
if (!isNamed) {
|
|
14002
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
14003
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
14004
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
14005
|
+
}
|
|
14006
|
+
isNamed = true;
|
|
14007
|
+
_position = state.position + 1;
|
|
14008
|
+
} else {
|
|
14009
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
14010
|
+
}
|
|
14011
|
+
}
|
|
14012
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14013
|
+
}
|
|
14014
|
+
tagName = state.input.slice(_position, state.position);
|
|
14015
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
14016
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
14017
|
+
}
|
|
14018
|
+
}
|
|
14019
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
14020
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
14021
|
+
}
|
|
14022
|
+
try {
|
|
14023
|
+
tagName = decodeURIComponent(tagName);
|
|
14024
|
+
} catch (err) {
|
|
14025
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
14026
|
+
}
|
|
14027
|
+
if (isVerbatim) {
|
|
14028
|
+
state.tag = tagName;
|
|
14029
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
14030
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
14031
|
+
} else if (tagHandle === "!") {
|
|
14032
|
+
state.tag = "!" + tagName;
|
|
14033
|
+
} else if (tagHandle === "!!") {
|
|
14034
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
14035
|
+
} else {
|
|
14036
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
14037
|
+
}
|
|
14038
|
+
return true;
|
|
14039
|
+
}
|
|
14040
|
+
function readAnchorProperty(state) {
|
|
14041
|
+
var _position, ch;
|
|
14042
|
+
ch = state.input.charCodeAt(state.position);
|
|
14043
|
+
if (ch !== 38)
|
|
14044
|
+
return false;
|
|
14045
|
+
if (state.anchor !== null) {
|
|
14046
|
+
throwError(state, "duplication of an anchor property");
|
|
14047
|
+
}
|
|
14048
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14049
|
+
_position = state.position;
|
|
14050
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
14051
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14052
|
+
}
|
|
14053
|
+
if (state.position === _position) {
|
|
14054
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
14055
|
+
}
|
|
14056
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
14057
|
+
return true;
|
|
14058
|
+
}
|
|
14059
|
+
function readAlias(state) {
|
|
14060
|
+
var _position, alias, ch;
|
|
14061
|
+
ch = state.input.charCodeAt(state.position);
|
|
14062
|
+
if (ch !== 42)
|
|
14063
|
+
return false;
|
|
14064
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14065
|
+
_position = state.position;
|
|
14066
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
14067
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14068
|
+
}
|
|
14069
|
+
if (state.position === _position) {
|
|
14070
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
14071
|
+
}
|
|
14072
|
+
alias = state.input.slice(_position, state.position);
|
|
14073
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
14074
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
14075
|
+
}
|
|
14076
|
+
state.result = state.anchorMap[alias];
|
|
14077
|
+
skipSeparationSpace(state, true, -1);
|
|
14078
|
+
return true;
|
|
14079
|
+
}
|
|
14080
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
14081
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
14082
|
+
if (state.listener !== null) {
|
|
14083
|
+
state.listener("open", state);
|
|
14084
|
+
}
|
|
14085
|
+
state.tag = null;
|
|
14086
|
+
state.anchor = null;
|
|
14087
|
+
state.kind = null;
|
|
14088
|
+
state.result = null;
|
|
14089
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
14090
|
+
if (allowToSeek) {
|
|
14091
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
14092
|
+
atNewLine = true;
|
|
14093
|
+
if (state.lineIndent > parentIndent) {
|
|
14094
|
+
indentStatus = 1;
|
|
14095
|
+
} else if (state.lineIndent === parentIndent) {
|
|
14096
|
+
indentStatus = 0;
|
|
14097
|
+
} else if (state.lineIndent < parentIndent) {
|
|
14098
|
+
indentStatus = -1;
|
|
14099
|
+
}
|
|
14100
|
+
}
|
|
14101
|
+
}
|
|
14102
|
+
if (indentStatus === 1) {
|
|
14103
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
14104
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
14105
|
+
atNewLine = true;
|
|
14106
|
+
allowBlockCollections = allowBlockStyles;
|
|
14107
|
+
if (state.lineIndent > parentIndent) {
|
|
14108
|
+
indentStatus = 1;
|
|
14109
|
+
} else if (state.lineIndent === parentIndent) {
|
|
14110
|
+
indentStatus = 0;
|
|
14111
|
+
} else if (state.lineIndent < parentIndent) {
|
|
14112
|
+
indentStatus = -1;
|
|
14113
|
+
}
|
|
14114
|
+
} else {
|
|
14115
|
+
allowBlockCollections = false;
|
|
14116
|
+
}
|
|
14117
|
+
}
|
|
14118
|
+
}
|
|
14119
|
+
if (allowBlockCollections) {
|
|
14120
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
14121
|
+
}
|
|
14122
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
14123
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
14124
|
+
flowIndent = parentIndent;
|
|
14125
|
+
} else {
|
|
14126
|
+
flowIndent = parentIndent + 1;
|
|
14127
|
+
}
|
|
14128
|
+
blockIndent = state.position - state.lineStart;
|
|
14129
|
+
if (indentStatus === 1) {
|
|
14130
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
14131
|
+
hasContent = true;
|
|
14132
|
+
} else {
|
|
14133
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
14134
|
+
hasContent = true;
|
|
14135
|
+
} else if (readAlias(state)) {
|
|
14136
|
+
hasContent = true;
|
|
14137
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
14138
|
+
throwError(state, "alias node should not have any properties");
|
|
14139
|
+
}
|
|
14140
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
14141
|
+
hasContent = true;
|
|
14142
|
+
if (state.tag === null) {
|
|
14143
|
+
state.tag = "?";
|
|
14144
|
+
}
|
|
14145
|
+
}
|
|
14146
|
+
if (state.anchor !== null) {
|
|
14147
|
+
state.anchorMap[state.anchor] = state.result;
|
|
14148
|
+
}
|
|
14149
|
+
}
|
|
14150
|
+
} else if (indentStatus === 0) {
|
|
14151
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
14152
|
+
}
|
|
14153
|
+
}
|
|
14154
|
+
if (state.tag === null) {
|
|
14155
|
+
if (state.anchor !== null) {
|
|
14156
|
+
state.anchorMap[state.anchor] = state.result;
|
|
14157
|
+
}
|
|
14158
|
+
} else if (state.tag === "?") {
|
|
14159
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
14160
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
14161
|
+
}
|
|
14162
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
14163
|
+
type2 = state.implicitTypes[typeIndex];
|
|
14164
|
+
if (type2.resolve(state.result)) {
|
|
14165
|
+
state.result = type2.construct(state.result);
|
|
14166
|
+
state.tag = type2.tag;
|
|
14167
|
+
if (state.anchor !== null) {
|
|
14168
|
+
state.anchorMap[state.anchor] = state.result;
|
|
14169
|
+
}
|
|
14170
|
+
break;
|
|
14171
|
+
}
|
|
14172
|
+
}
|
|
14173
|
+
} else if (state.tag !== "!") {
|
|
14174
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
14175
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
14176
|
+
} else {
|
|
14177
|
+
type2 = null;
|
|
14178
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
14179
|
+
for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
14180
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
14181
|
+
type2 = typeList[typeIndex];
|
|
14182
|
+
break;
|
|
14183
|
+
}
|
|
14184
|
+
}
|
|
14185
|
+
}
|
|
14186
|
+
if (!type2) {
|
|
14187
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
14188
|
+
}
|
|
14189
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
14190
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
14191
|
+
}
|
|
14192
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
14193
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
14194
|
+
} else {
|
|
14195
|
+
state.result = type2.construct(state.result, state.tag);
|
|
14196
|
+
if (state.anchor !== null) {
|
|
14197
|
+
state.anchorMap[state.anchor] = state.result;
|
|
14198
|
+
}
|
|
14199
|
+
}
|
|
14200
|
+
}
|
|
14201
|
+
if (state.listener !== null) {
|
|
14202
|
+
state.listener("close", state);
|
|
14203
|
+
}
|
|
14204
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
14205
|
+
}
|
|
14206
|
+
function readDocument(state) {
|
|
14207
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
14208
|
+
state.version = null;
|
|
14209
|
+
state.checkLineBreaks = state.legacy;
|
|
14210
|
+
state.tagMap = Object.create(null);
|
|
14211
|
+
state.anchorMap = Object.create(null);
|
|
14212
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
14213
|
+
skipSeparationSpace(state, true, -1);
|
|
14214
|
+
ch = state.input.charCodeAt(state.position);
|
|
14215
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
14216
|
+
break;
|
|
14217
|
+
}
|
|
14218
|
+
hasDirectives = true;
|
|
14219
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14220
|
+
_position = state.position;
|
|
14221
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
14222
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14223
|
+
}
|
|
14224
|
+
directiveName = state.input.slice(_position, state.position);
|
|
14225
|
+
directiveArgs = [];
|
|
14226
|
+
if (directiveName.length < 1) {
|
|
14227
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
14228
|
+
}
|
|
14229
|
+
while (ch !== 0) {
|
|
14230
|
+
while (is_WHITE_SPACE(ch)) {
|
|
14231
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14232
|
+
}
|
|
14233
|
+
if (ch === 35) {
|
|
14234
|
+
do {
|
|
14235
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14236
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
14237
|
+
break;
|
|
14238
|
+
}
|
|
14239
|
+
if (is_EOL(ch))
|
|
14240
|
+
break;
|
|
14241
|
+
_position = state.position;
|
|
14242
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
14243
|
+
ch = state.input.charCodeAt(++state.position);
|
|
14244
|
+
}
|
|
14245
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
14246
|
+
}
|
|
14247
|
+
if (ch !== 0)
|
|
14248
|
+
readLineBreak(state);
|
|
14249
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
14250
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
14251
|
+
} else {
|
|
14252
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
14253
|
+
}
|
|
14254
|
+
}
|
|
14255
|
+
skipSeparationSpace(state, true, -1);
|
|
14256
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
14257
|
+
state.position += 3;
|
|
14258
|
+
skipSeparationSpace(state, true, -1);
|
|
14259
|
+
} else if (hasDirectives) {
|
|
14260
|
+
throwError(state, "directives end mark is expected");
|
|
14261
|
+
}
|
|
14262
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
14263
|
+
skipSeparationSpace(state, true, -1);
|
|
14264
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
14265
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
14266
|
+
}
|
|
14267
|
+
state.documents.push(state.result);
|
|
14268
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
14269
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
14270
|
+
state.position += 3;
|
|
14271
|
+
skipSeparationSpace(state, true, -1);
|
|
14272
|
+
}
|
|
14273
|
+
return;
|
|
14274
|
+
}
|
|
14275
|
+
if (state.position < state.length - 1) {
|
|
14276
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
14277
|
+
} else {
|
|
14278
|
+
return;
|
|
14279
|
+
}
|
|
14280
|
+
}
|
|
14281
|
+
function loadDocuments(input, options) {
|
|
14282
|
+
input = String(input);
|
|
14283
|
+
options = options || {};
|
|
14284
|
+
if (input.length !== 0) {
|
|
14285
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
14286
|
+
input += `
|
|
14287
|
+
`;
|
|
14288
|
+
}
|
|
14289
|
+
if (input.charCodeAt(0) === 65279) {
|
|
14290
|
+
input = input.slice(1);
|
|
14291
|
+
}
|
|
14292
|
+
}
|
|
14293
|
+
var state = new State$1(input, options);
|
|
14294
|
+
var nullpos = input.indexOf("\x00");
|
|
14295
|
+
if (nullpos !== -1) {
|
|
14296
|
+
state.position = nullpos;
|
|
14297
|
+
throwError(state, "null byte is not allowed in input");
|
|
14298
|
+
}
|
|
14299
|
+
state.input += "\x00";
|
|
14300
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
14301
|
+
state.lineIndent += 1;
|
|
14302
|
+
state.position += 1;
|
|
14303
|
+
}
|
|
14304
|
+
while (state.position < state.length - 1) {
|
|
14305
|
+
readDocument(state);
|
|
14306
|
+
}
|
|
14307
|
+
return state.documents;
|
|
14308
|
+
}
|
|
14309
|
+
function loadAll$1(input, iterator, options) {
|
|
14310
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
14311
|
+
options = iterator;
|
|
14312
|
+
iterator = null;
|
|
14313
|
+
}
|
|
14314
|
+
var documents = loadDocuments(input, options);
|
|
14315
|
+
if (typeof iterator !== "function") {
|
|
14316
|
+
return documents;
|
|
14317
|
+
}
|
|
14318
|
+
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
14319
|
+
iterator(documents[index]);
|
|
14320
|
+
}
|
|
14321
|
+
}
|
|
14322
|
+
function load$1(input, options) {
|
|
14323
|
+
var documents = loadDocuments(input, options);
|
|
14324
|
+
if (documents.length === 0) {
|
|
14325
|
+
return;
|
|
14326
|
+
} else if (documents.length === 1) {
|
|
14327
|
+
return documents[0];
|
|
14328
|
+
}
|
|
14329
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
14330
|
+
}
|
|
14331
|
+
var loadAll_1 = loadAll$1;
|
|
14332
|
+
var load_1 = load$1;
|
|
14333
|
+
var loader = {
|
|
14334
|
+
loadAll: loadAll_1,
|
|
14335
|
+
load: load_1
|
|
14336
|
+
};
|
|
14337
|
+
var _toString = Object.prototype.toString;
|
|
14338
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
14339
|
+
var CHAR_BOM = 65279;
|
|
14340
|
+
var CHAR_TAB = 9;
|
|
14341
|
+
var CHAR_LINE_FEED = 10;
|
|
14342
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
14343
|
+
var CHAR_SPACE = 32;
|
|
14344
|
+
var CHAR_EXCLAMATION = 33;
|
|
14345
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
14346
|
+
var CHAR_SHARP = 35;
|
|
14347
|
+
var CHAR_PERCENT = 37;
|
|
14348
|
+
var CHAR_AMPERSAND = 38;
|
|
14349
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
14350
|
+
var CHAR_ASTERISK = 42;
|
|
14351
|
+
var CHAR_COMMA = 44;
|
|
14352
|
+
var CHAR_MINUS = 45;
|
|
14353
|
+
var CHAR_COLON = 58;
|
|
14354
|
+
var CHAR_EQUALS = 61;
|
|
14355
|
+
var CHAR_GREATER_THAN = 62;
|
|
14356
|
+
var CHAR_QUESTION = 63;
|
|
14357
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
14358
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
14359
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
14360
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
14361
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
14362
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
14363
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
14364
|
+
var ESCAPE_SEQUENCES = {};
|
|
14365
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
14366
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
14367
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
14368
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
14369
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
14370
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
14371
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
14372
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
14373
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
14374
|
+
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
14375
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
14376
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
14377
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
14378
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
14379
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
14380
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
14381
|
+
"y",
|
|
14382
|
+
"Y",
|
|
14383
|
+
"yes",
|
|
14384
|
+
"Yes",
|
|
14385
|
+
"YES",
|
|
14386
|
+
"on",
|
|
14387
|
+
"On",
|
|
14388
|
+
"ON",
|
|
14389
|
+
"n",
|
|
14390
|
+
"N",
|
|
14391
|
+
"no",
|
|
14392
|
+
"No",
|
|
14393
|
+
"NO",
|
|
14394
|
+
"off",
|
|
14395
|
+
"Off",
|
|
14396
|
+
"OFF"
|
|
14397
|
+
];
|
|
14398
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
14399
|
+
function compileStyleMap(schema2, map3) {
|
|
14400
|
+
var result, keys, index, length, tag, style, type2;
|
|
14401
|
+
if (map3 === null)
|
|
14402
|
+
return {};
|
|
14403
|
+
result = {};
|
|
14404
|
+
keys = Object.keys(map3);
|
|
14405
|
+
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
14406
|
+
tag = keys[index];
|
|
14407
|
+
style = String(map3[tag]);
|
|
14408
|
+
if (tag.slice(0, 2) === "!!") {
|
|
14409
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
14410
|
+
}
|
|
14411
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
14412
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
14413
|
+
style = type2.styleAliases[style];
|
|
14414
|
+
}
|
|
14415
|
+
result[tag] = style;
|
|
14416
|
+
}
|
|
14417
|
+
return result;
|
|
14418
|
+
}
|
|
14419
|
+
function encodeHex(character) {
|
|
14420
|
+
var string4, handle, length;
|
|
14421
|
+
string4 = character.toString(16).toUpperCase();
|
|
14422
|
+
if (character <= 255) {
|
|
14423
|
+
handle = "x";
|
|
14424
|
+
length = 2;
|
|
14425
|
+
} else if (character <= 65535) {
|
|
14426
|
+
handle = "u";
|
|
14427
|
+
length = 4;
|
|
14428
|
+
} else if (character <= 4294967295) {
|
|
14429
|
+
handle = "U";
|
|
14430
|
+
length = 8;
|
|
14431
|
+
} else {
|
|
14432
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
14433
|
+
}
|
|
14434
|
+
return "\\" + handle + common.repeat("0", length - string4.length) + string4;
|
|
14435
|
+
}
|
|
14436
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
14437
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
14438
|
+
function State(options) {
|
|
14439
|
+
this.schema = options["schema"] || _default3;
|
|
14440
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
14441
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
14442
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
14443
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
14444
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
14445
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
14446
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
14447
|
+
this.noRefs = options["noRefs"] || false;
|
|
14448
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
14449
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
14450
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
14451
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
14452
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
14453
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
14454
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
14455
|
+
this.tag = null;
|
|
14456
|
+
this.result = "";
|
|
14457
|
+
this.duplicates = [];
|
|
14458
|
+
this.usedDuplicates = null;
|
|
14459
|
+
}
|
|
14460
|
+
function indentString(string4, spaces) {
|
|
14461
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string4.length;
|
|
14462
|
+
while (position < length) {
|
|
14463
|
+
next = string4.indexOf(`
|
|
14464
|
+
`, position);
|
|
14465
|
+
if (next === -1) {
|
|
14466
|
+
line = string4.slice(position);
|
|
14467
|
+
position = length;
|
|
14468
|
+
} else {
|
|
14469
|
+
line = string4.slice(position, next + 1);
|
|
14470
|
+
position = next + 1;
|
|
14471
|
+
}
|
|
14472
|
+
if (line.length && line !== `
|
|
14473
|
+
`)
|
|
14474
|
+
result += ind;
|
|
14475
|
+
result += line;
|
|
14476
|
+
}
|
|
14477
|
+
return result;
|
|
14478
|
+
}
|
|
14479
|
+
function generateNextLine(state, level) {
|
|
14480
|
+
return `
|
|
14481
|
+
` + common.repeat(" ", state.indent * level);
|
|
14482
|
+
}
|
|
14483
|
+
function testImplicitResolving(state, str2) {
|
|
14484
|
+
var index, length, type2;
|
|
14485
|
+
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
14486
|
+
type2 = state.implicitTypes[index];
|
|
14487
|
+
if (type2.resolve(str2)) {
|
|
14488
|
+
return true;
|
|
14489
|
+
}
|
|
14490
|
+
}
|
|
14491
|
+
return false;
|
|
14492
|
+
}
|
|
14493
|
+
function isWhitespace(c) {
|
|
14494
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
14495
|
+
}
|
|
14496
|
+
function isPrintable(c) {
|
|
14497
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
14498
|
+
}
|
|
14499
|
+
function isNsCharOrWhitespace(c) {
|
|
14500
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
14501
|
+
}
|
|
14502
|
+
function isPlainSafe(c, prev, inblock) {
|
|
14503
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
14504
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
14505
|
+
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;
|
|
14506
|
+
}
|
|
14507
|
+
function isPlainSafeFirst(c) {
|
|
14508
|
+
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;
|
|
14509
|
+
}
|
|
14510
|
+
function isPlainSafeLast(c) {
|
|
14511
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
14512
|
+
}
|
|
14513
|
+
function codePointAt(string4, pos) {
|
|
14514
|
+
var first = string4.charCodeAt(pos), second;
|
|
14515
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string4.length) {
|
|
14516
|
+
second = string4.charCodeAt(pos + 1);
|
|
14517
|
+
if (second >= 56320 && second <= 57343) {
|
|
14518
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
14519
|
+
}
|
|
14520
|
+
}
|
|
14521
|
+
return first;
|
|
14522
|
+
}
|
|
14523
|
+
function needIndentIndicator(string4) {
|
|
14524
|
+
var leadingSpaceRe = /^\n* /;
|
|
14525
|
+
return leadingSpaceRe.test(string4);
|
|
14526
|
+
}
|
|
14527
|
+
var STYLE_PLAIN = 1;
|
|
14528
|
+
var STYLE_SINGLE = 2;
|
|
14529
|
+
var STYLE_LITERAL = 3;
|
|
14530
|
+
var STYLE_FOLDED = 4;
|
|
14531
|
+
var STYLE_DOUBLE = 5;
|
|
14532
|
+
function chooseScalarStyle(string4, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
14533
|
+
var i2;
|
|
14534
|
+
var char = 0;
|
|
14535
|
+
var prevChar = null;
|
|
14536
|
+
var hasLineBreak = false;
|
|
14537
|
+
var hasFoldableLine = false;
|
|
14538
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
14539
|
+
var previousLineBreak = -1;
|
|
14540
|
+
var plain = isPlainSafeFirst(codePointAt(string4, 0)) && isPlainSafeLast(codePointAt(string4, string4.length - 1));
|
|
14541
|
+
if (singleLineOnly || forceQuotes) {
|
|
14542
|
+
for (i2 = 0;i2 < string4.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
14543
|
+
char = codePointAt(string4, i2);
|
|
14544
|
+
if (!isPrintable(char)) {
|
|
14545
|
+
return STYLE_DOUBLE;
|
|
14546
|
+
}
|
|
14547
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
14548
|
+
prevChar = char;
|
|
14549
|
+
}
|
|
14550
|
+
} else {
|
|
14551
|
+
for (i2 = 0;i2 < string4.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
14552
|
+
char = codePointAt(string4, i2);
|
|
14553
|
+
if (char === CHAR_LINE_FEED) {
|
|
14554
|
+
hasLineBreak = true;
|
|
14555
|
+
if (shouldTrackWidth) {
|
|
14556
|
+
hasFoldableLine = hasFoldableLine || i2 - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ";
|
|
14557
|
+
previousLineBreak = i2;
|
|
14558
|
+
}
|
|
14559
|
+
} else if (!isPrintable(char)) {
|
|
14560
|
+
return STYLE_DOUBLE;
|
|
14561
|
+
}
|
|
14562
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
14563
|
+
prevChar = char;
|
|
14564
|
+
}
|
|
14565
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ");
|
|
14566
|
+
}
|
|
14567
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
14568
|
+
if (plain && !forceQuotes && !testAmbiguousType(string4)) {
|
|
14569
|
+
return STYLE_PLAIN;
|
|
14570
|
+
}
|
|
14571
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
14572
|
+
}
|
|
14573
|
+
if (indentPerLevel > 9 && needIndentIndicator(string4)) {
|
|
14574
|
+
return STYLE_DOUBLE;
|
|
14575
|
+
}
|
|
14576
|
+
if (!forceQuotes) {
|
|
14577
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
14578
|
+
}
|
|
14579
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
14580
|
+
}
|
|
14581
|
+
function writeScalar(state, string4, level, iskey, inblock) {
|
|
14582
|
+
state.dump = function() {
|
|
14583
|
+
if (string4.length === 0) {
|
|
14584
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
14585
|
+
}
|
|
14586
|
+
if (!state.noCompatMode) {
|
|
14587
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string4) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string4)) {
|
|
14588
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string4 + '"' : "'" + string4 + "'";
|
|
14589
|
+
}
|
|
14590
|
+
}
|
|
14591
|
+
var indent = state.indent * Math.max(1, level);
|
|
14592
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
14593
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
14594
|
+
function testAmbiguity(string5) {
|
|
14595
|
+
return testImplicitResolving(state, string5);
|
|
14596
|
+
}
|
|
14597
|
+
switch (chooseScalarStyle(string4, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
14598
|
+
case STYLE_PLAIN:
|
|
14599
|
+
return string4;
|
|
14600
|
+
case STYLE_SINGLE:
|
|
14601
|
+
return "'" + string4.replace(/'/g, "''") + "'";
|
|
14602
|
+
case STYLE_LITERAL:
|
|
14603
|
+
return "|" + blockHeader(string4, state.indent) + dropEndingNewline(indentString(string4, indent));
|
|
14604
|
+
case STYLE_FOLDED:
|
|
14605
|
+
return ">" + blockHeader(string4, state.indent) + dropEndingNewline(indentString(foldString(string4, lineWidth), indent));
|
|
14606
|
+
case STYLE_DOUBLE:
|
|
14607
|
+
return '"' + escapeString(string4) + '"';
|
|
14608
|
+
default:
|
|
14609
|
+
throw new exception("impossible error: invalid scalar style");
|
|
14610
|
+
}
|
|
14611
|
+
}();
|
|
14612
|
+
}
|
|
14613
|
+
function blockHeader(string4, indentPerLevel) {
|
|
14614
|
+
var indentIndicator = needIndentIndicator(string4) ? String(indentPerLevel) : "";
|
|
14615
|
+
var clip = string4[string4.length - 1] === `
|
|
14616
|
+
`;
|
|
14617
|
+
var keep = clip && (string4[string4.length - 2] === `
|
|
14618
|
+
` || string4 === `
|
|
14619
|
+
`);
|
|
14620
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
14621
|
+
return indentIndicator + chomp + `
|
|
14622
|
+
`;
|
|
14623
|
+
}
|
|
14624
|
+
function dropEndingNewline(string4) {
|
|
14625
|
+
return string4[string4.length - 1] === `
|
|
14626
|
+
` ? string4.slice(0, -1) : string4;
|
|
14627
|
+
}
|
|
14628
|
+
function foldString(string4, width) {
|
|
14629
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
14630
|
+
var result = function() {
|
|
14631
|
+
var nextLF = string4.indexOf(`
|
|
14632
|
+
`);
|
|
14633
|
+
nextLF = nextLF !== -1 ? nextLF : string4.length;
|
|
14634
|
+
lineRe.lastIndex = nextLF;
|
|
14635
|
+
return foldLine(string4.slice(0, nextLF), width);
|
|
14636
|
+
}();
|
|
14637
|
+
var prevMoreIndented = string4[0] === `
|
|
14638
|
+
` || string4[0] === " ";
|
|
14639
|
+
var moreIndented;
|
|
14640
|
+
var match;
|
|
14641
|
+
while (match = lineRe.exec(string4)) {
|
|
14642
|
+
var prefix = match[1], line = match[2];
|
|
14643
|
+
moreIndented = line[0] === " ";
|
|
14644
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
14645
|
+
` : "") + foldLine(line, width);
|
|
14646
|
+
prevMoreIndented = moreIndented;
|
|
14647
|
+
}
|
|
14648
|
+
return result;
|
|
14649
|
+
}
|
|
14650
|
+
function foldLine(line, width) {
|
|
14651
|
+
if (line === "" || line[0] === " ")
|
|
14652
|
+
return line;
|
|
14653
|
+
var breakRe = / [^ ]/g;
|
|
14654
|
+
var match;
|
|
14655
|
+
var start = 0, end, curr = 0, next = 0;
|
|
14656
|
+
var result = "";
|
|
14657
|
+
while (match = breakRe.exec(line)) {
|
|
14658
|
+
next = match.index;
|
|
14659
|
+
if (next - start > width) {
|
|
14660
|
+
end = curr > start ? curr : next;
|
|
14661
|
+
result += `
|
|
14662
|
+
` + line.slice(start, end);
|
|
14663
|
+
start = end + 1;
|
|
14664
|
+
}
|
|
14665
|
+
curr = next;
|
|
14666
|
+
}
|
|
14667
|
+
result += `
|
|
14668
|
+
`;
|
|
14669
|
+
if (line.length - start > width && curr > start) {
|
|
14670
|
+
result += line.slice(start, curr) + `
|
|
14671
|
+
` + line.slice(curr + 1);
|
|
14672
|
+
} else {
|
|
14673
|
+
result += line.slice(start);
|
|
14674
|
+
}
|
|
14675
|
+
return result.slice(1);
|
|
14676
|
+
}
|
|
14677
|
+
function escapeString(string4) {
|
|
14678
|
+
var result = "";
|
|
14679
|
+
var char = 0;
|
|
14680
|
+
var escapeSeq;
|
|
14681
|
+
for (var i2 = 0;i2 < string4.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
14682
|
+
char = codePointAt(string4, i2);
|
|
14683
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
14684
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
14685
|
+
result += string4[i2];
|
|
14686
|
+
if (char >= 65536)
|
|
14687
|
+
result += string4[i2 + 1];
|
|
14688
|
+
} else {
|
|
14689
|
+
result += escapeSeq || encodeHex(char);
|
|
14690
|
+
}
|
|
14691
|
+
}
|
|
14692
|
+
return result;
|
|
14693
|
+
}
|
|
14694
|
+
function writeFlowSequence(state, level, object2) {
|
|
14695
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
14696
|
+
for (index = 0, length = object2.length;index < length; index += 1) {
|
|
14697
|
+
value = object2[index];
|
|
14698
|
+
if (state.replacer) {
|
|
14699
|
+
value = state.replacer.call(object2, String(index), value);
|
|
14700
|
+
}
|
|
14701
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
14702
|
+
if (_result !== "")
|
|
14703
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
14704
|
+
_result += state.dump;
|
|
14705
|
+
}
|
|
14706
|
+
}
|
|
14707
|
+
state.tag = _tag;
|
|
14708
|
+
state.dump = "[" + _result + "]";
|
|
14709
|
+
}
|
|
14710
|
+
function writeBlockSequence(state, level, object2, compact) {
|
|
14711
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
14712
|
+
for (index = 0, length = object2.length;index < length; index += 1) {
|
|
14713
|
+
value = object2[index];
|
|
14714
|
+
if (state.replacer) {
|
|
14715
|
+
value = state.replacer.call(object2, String(index), value);
|
|
14716
|
+
}
|
|
14717
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
14718
|
+
if (!compact || _result !== "") {
|
|
14719
|
+
_result += generateNextLine(state, level);
|
|
14720
|
+
}
|
|
14721
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
14722
|
+
_result += "-";
|
|
14723
|
+
} else {
|
|
14724
|
+
_result += "- ";
|
|
14725
|
+
}
|
|
14726
|
+
_result += state.dump;
|
|
14727
|
+
}
|
|
14728
|
+
}
|
|
14729
|
+
state.tag = _tag;
|
|
14730
|
+
state.dump = _result || "[]";
|
|
14731
|
+
}
|
|
14732
|
+
function writeFlowMapping(state, level, object2) {
|
|
14733
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, pairBuffer;
|
|
14734
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
14735
|
+
pairBuffer = "";
|
|
14736
|
+
if (_result !== "")
|
|
14737
|
+
pairBuffer += ", ";
|
|
14738
|
+
if (state.condenseFlow)
|
|
14739
|
+
pairBuffer += '"';
|
|
14740
|
+
objectKey = objectKeyList[index];
|
|
14741
|
+
objectValue = object2[objectKey];
|
|
14742
|
+
if (state.replacer) {
|
|
14743
|
+
objectValue = state.replacer.call(object2, objectKey, objectValue);
|
|
14744
|
+
}
|
|
14745
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
14746
|
+
continue;
|
|
14747
|
+
}
|
|
14748
|
+
if (state.dump.length > 1024)
|
|
14749
|
+
pairBuffer += "? ";
|
|
14750
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
14751
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
14752
|
+
continue;
|
|
14753
|
+
}
|
|
14754
|
+
pairBuffer += state.dump;
|
|
14755
|
+
_result += pairBuffer;
|
|
14756
|
+
}
|
|
14757
|
+
state.tag = _tag;
|
|
14758
|
+
state.dump = "{" + _result + "}";
|
|
14759
|
+
}
|
|
14760
|
+
function writeBlockMapping(state, level, object2, compact) {
|
|
14761
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object2), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
14762
|
+
if (state.sortKeys === true) {
|
|
14763
|
+
objectKeyList.sort();
|
|
14764
|
+
} else if (typeof state.sortKeys === "function") {
|
|
14765
|
+
objectKeyList.sort(state.sortKeys);
|
|
14766
|
+
} else if (state.sortKeys) {
|
|
14767
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
14768
|
+
}
|
|
14769
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
14770
|
+
pairBuffer = "";
|
|
14771
|
+
if (!compact || _result !== "") {
|
|
14772
|
+
pairBuffer += generateNextLine(state, level);
|
|
14773
|
+
}
|
|
14774
|
+
objectKey = objectKeyList[index];
|
|
14775
|
+
objectValue = object2[objectKey];
|
|
14776
|
+
if (state.replacer) {
|
|
14777
|
+
objectValue = state.replacer.call(object2, objectKey, objectValue);
|
|
14778
|
+
}
|
|
14779
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
14780
|
+
continue;
|
|
14781
|
+
}
|
|
14782
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
14783
|
+
if (explicitPair) {
|
|
14784
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
14785
|
+
pairBuffer += "?";
|
|
14786
|
+
} else {
|
|
14787
|
+
pairBuffer += "? ";
|
|
14788
|
+
}
|
|
14789
|
+
}
|
|
14790
|
+
pairBuffer += state.dump;
|
|
14791
|
+
if (explicitPair) {
|
|
14792
|
+
pairBuffer += generateNextLine(state, level);
|
|
14793
|
+
}
|
|
14794
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
14795
|
+
continue;
|
|
14796
|
+
}
|
|
14797
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
14798
|
+
pairBuffer += ":";
|
|
14799
|
+
} else {
|
|
14800
|
+
pairBuffer += ": ";
|
|
14801
|
+
}
|
|
14802
|
+
pairBuffer += state.dump;
|
|
14803
|
+
_result += pairBuffer;
|
|
14804
|
+
}
|
|
14805
|
+
state.tag = _tag;
|
|
14806
|
+
state.dump = _result || "{}";
|
|
14807
|
+
}
|
|
14808
|
+
function detectType(state, object2, explicit) {
|
|
14809
|
+
var _result, typeList, index, length, type2, style;
|
|
14810
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
14811
|
+
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
14812
|
+
type2 = typeList[index];
|
|
14813
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object2 === "object" && object2 instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object2))) {
|
|
14814
|
+
if (explicit) {
|
|
14815
|
+
if (type2.multi && type2.representName) {
|
|
14816
|
+
state.tag = type2.representName(object2);
|
|
14817
|
+
} else {
|
|
14818
|
+
state.tag = type2.tag;
|
|
14819
|
+
}
|
|
14820
|
+
} else {
|
|
14821
|
+
state.tag = "?";
|
|
14822
|
+
}
|
|
14823
|
+
if (type2.represent) {
|
|
14824
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
14825
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
14826
|
+
_result = type2.represent(object2, style);
|
|
14827
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
14828
|
+
_result = type2.represent[style](object2, style);
|
|
14829
|
+
} else {
|
|
14830
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
14831
|
+
}
|
|
14832
|
+
state.dump = _result;
|
|
14833
|
+
}
|
|
14834
|
+
return true;
|
|
14835
|
+
}
|
|
14836
|
+
}
|
|
14837
|
+
return false;
|
|
14838
|
+
}
|
|
14839
|
+
function writeNode(state, level, object2, block, compact, iskey, isblockseq) {
|
|
14840
|
+
state.tag = null;
|
|
14841
|
+
state.dump = object2;
|
|
14842
|
+
if (!detectType(state, object2, false)) {
|
|
14843
|
+
detectType(state, object2, true);
|
|
14844
|
+
}
|
|
14845
|
+
var type2 = _toString.call(state.dump);
|
|
14846
|
+
var inblock = block;
|
|
14847
|
+
var tagStr;
|
|
14848
|
+
if (block) {
|
|
14849
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
14850
|
+
}
|
|
14851
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
14852
|
+
if (objectOrArray) {
|
|
14853
|
+
duplicateIndex = state.duplicates.indexOf(object2);
|
|
14854
|
+
duplicate = duplicateIndex !== -1;
|
|
14855
|
+
}
|
|
14856
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
14857
|
+
compact = false;
|
|
14858
|
+
}
|
|
14859
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
14860
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
14861
|
+
} else {
|
|
14862
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
14863
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
14864
|
+
}
|
|
14865
|
+
if (type2 === "[object Object]") {
|
|
14866
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
14867
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
14868
|
+
if (duplicate) {
|
|
14869
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
14870
|
+
}
|
|
14871
|
+
} else {
|
|
14872
|
+
writeFlowMapping(state, level, state.dump);
|
|
14873
|
+
if (duplicate) {
|
|
14874
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
14875
|
+
}
|
|
14876
|
+
}
|
|
14877
|
+
} else if (type2 === "[object Array]") {
|
|
14878
|
+
if (block && state.dump.length !== 0) {
|
|
14879
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
14880
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
14881
|
+
} else {
|
|
14882
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
14883
|
+
}
|
|
14884
|
+
if (duplicate) {
|
|
14885
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
14886
|
+
}
|
|
14887
|
+
} else {
|
|
14888
|
+
writeFlowSequence(state, level, state.dump);
|
|
14889
|
+
if (duplicate) {
|
|
14890
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
14891
|
+
}
|
|
14892
|
+
}
|
|
14893
|
+
} else if (type2 === "[object String]") {
|
|
14894
|
+
if (state.tag !== "?") {
|
|
14895
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
14896
|
+
}
|
|
14897
|
+
} else if (type2 === "[object Undefined]") {
|
|
14898
|
+
return false;
|
|
14899
|
+
} else {
|
|
14900
|
+
if (state.skipInvalid)
|
|
14901
|
+
return false;
|
|
14902
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
14903
|
+
}
|
|
14904
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
14905
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
14906
|
+
if (state.tag[0] === "!") {
|
|
14907
|
+
tagStr = "!" + tagStr;
|
|
14908
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
14909
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
14910
|
+
} else {
|
|
14911
|
+
tagStr = "!<" + tagStr + ">";
|
|
14912
|
+
}
|
|
14913
|
+
state.dump = tagStr + " " + state.dump;
|
|
14914
|
+
}
|
|
14915
|
+
}
|
|
14916
|
+
return true;
|
|
14917
|
+
}
|
|
14918
|
+
function getDuplicateReferences(object2, state) {
|
|
14919
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
14920
|
+
inspectNode(object2, objects, duplicatesIndexes);
|
|
14921
|
+
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
14922
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
14923
|
+
}
|
|
14924
|
+
state.usedDuplicates = new Array(length);
|
|
14925
|
+
}
|
|
14926
|
+
function inspectNode(object2, objects, duplicatesIndexes) {
|
|
14927
|
+
var objectKeyList, index, length;
|
|
14928
|
+
if (object2 !== null && typeof object2 === "object") {
|
|
14929
|
+
index = objects.indexOf(object2);
|
|
14930
|
+
if (index !== -1) {
|
|
14931
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
14932
|
+
duplicatesIndexes.push(index);
|
|
14933
|
+
}
|
|
14934
|
+
} else {
|
|
14935
|
+
objects.push(object2);
|
|
14936
|
+
if (Array.isArray(object2)) {
|
|
14937
|
+
for (index = 0, length = object2.length;index < length; index += 1) {
|
|
14938
|
+
inspectNode(object2[index], objects, duplicatesIndexes);
|
|
14939
|
+
}
|
|
14940
|
+
} else {
|
|
14941
|
+
objectKeyList = Object.keys(object2);
|
|
14942
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
14943
|
+
inspectNode(object2[objectKeyList[index]], objects, duplicatesIndexes);
|
|
14944
|
+
}
|
|
14945
|
+
}
|
|
14946
|
+
}
|
|
14947
|
+
}
|
|
14948
|
+
}
|
|
14949
|
+
function dump$1(input, options) {
|
|
14950
|
+
options = options || {};
|
|
14951
|
+
var state = new State(options);
|
|
14952
|
+
if (!state.noRefs)
|
|
14953
|
+
getDuplicateReferences(input, state);
|
|
14954
|
+
var value = input;
|
|
14955
|
+
if (state.replacer) {
|
|
14956
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
14957
|
+
}
|
|
14958
|
+
if (writeNode(state, 0, value, true, true))
|
|
14959
|
+
return state.dump + `
|
|
14960
|
+
`;
|
|
14961
|
+
return "";
|
|
14962
|
+
}
|
|
14963
|
+
var dump_1 = dump$1;
|
|
14964
|
+
var dumper = {
|
|
14965
|
+
dump: dump_1
|
|
14966
|
+
};
|
|
14967
|
+
function renamed(from, to) {
|
|
14968
|
+
return function() {
|
|
14969
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
|
|
14970
|
+
};
|
|
14971
|
+
}
|
|
14972
|
+
var Type = type;
|
|
14973
|
+
var Schema = schema;
|
|
14974
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
14975
|
+
var JSON_SCHEMA = json2;
|
|
14976
|
+
var CORE_SCHEMA = core2;
|
|
14977
|
+
var DEFAULT_SCHEMA = _default3;
|
|
14978
|
+
var load = loader.load;
|
|
14979
|
+
var loadAll = loader.loadAll;
|
|
14980
|
+
var dump = dumper.dump;
|
|
14981
|
+
var YAMLException = exception;
|
|
14982
|
+
var types = {
|
|
14983
|
+
binary,
|
|
14984
|
+
float,
|
|
14985
|
+
map: map2,
|
|
14986
|
+
null: _null4,
|
|
14987
|
+
pairs,
|
|
14988
|
+
set: set2,
|
|
14989
|
+
timestamp,
|
|
14990
|
+
bool,
|
|
14991
|
+
int: int2,
|
|
14992
|
+
merge: merge2,
|
|
14993
|
+
omap,
|
|
14994
|
+
seq,
|
|
14995
|
+
str
|
|
14996
|
+
};
|
|
14997
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
14998
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
14999
|
+
var safeDump = renamed("safeDump", "dump");
|
|
15000
|
+
var jsYaml = {
|
|
15001
|
+
Type,
|
|
15002
|
+
Schema,
|
|
15003
|
+
FAILSAFE_SCHEMA,
|
|
15004
|
+
JSON_SCHEMA,
|
|
15005
|
+
CORE_SCHEMA,
|
|
15006
|
+
DEFAULT_SCHEMA,
|
|
15007
|
+
load,
|
|
15008
|
+
loadAll,
|
|
15009
|
+
dump,
|
|
15010
|
+
YAMLException,
|
|
15011
|
+
types,
|
|
15012
|
+
safeLoad,
|
|
15013
|
+
safeLoadAll,
|
|
15014
|
+
safeDump
|
|
15015
|
+
};
|
|
15016
|
+
|
|
12332
15017
|
// src/utils.ts
|
|
12333
15018
|
import { spawn } from "node:child_process";
|
|
15019
|
+
import { existsSync } from "node:fs";
|
|
15020
|
+
import { join } from "node:path";
|
|
12334
15021
|
async function runAstGrep({ args, input, directory }) {
|
|
12335
15022
|
const fullArgs = ["ast-grep", ...args];
|
|
12336
15023
|
const [cmd, ...cmdArgs] = fullArgs;
|
|
@@ -12381,8 +15068,14 @@ ${matchText}`);
|
|
|
12381
15068
|
function getConfigPath(directory) {
|
|
12382
15069
|
if (!directory)
|
|
12383
15070
|
return;
|
|
12384
|
-
const
|
|
12385
|
-
|
|
15071
|
+
const extensions = [".yml", ".yaml"];
|
|
15072
|
+
for (const ext of extensions) {
|
|
15073
|
+
const configPath = join(directory, `sgconfig${ext}`);
|
|
15074
|
+
if (existsSync(configPath)) {
|
|
15075
|
+
return configPath;
|
|
15076
|
+
}
|
|
15077
|
+
}
|
|
15078
|
+
return;
|
|
12386
15079
|
}
|
|
12387
15080
|
async function executeAstGrep(command, args, options) {
|
|
12388
15081
|
const allArgs = [];
|
|
@@ -12421,6 +15114,39 @@ async function executeAstGrep(command, args, options) {
|
|
|
12421
15114
|
}
|
|
12422
15115
|
|
|
12423
15116
|
// src/tools.ts
|
|
15117
|
+
var patternSchema = tool.schema.union([
|
|
15118
|
+
tool.schema.string(),
|
|
15119
|
+
tool.schema.object({
|
|
15120
|
+
context: tool.schema.string(),
|
|
15121
|
+
selector: tool.schema.string(),
|
|
15122
|
+
strictness: tool.schema.enum(["cst", "smart", "ast", "relaxed", "signature"]).optional()
|
|
15123
|
+
})
|
|
15124
|
+
]);
|
|
15125
|
+
var ruleObjectSchema = tool.schema.lazy(() => tool.schema.object({
|
|
15126
|
+
pattern: patternSchema.optional(),
|
|
15127
|
+
kind: tool.schema.string().optional(),
|
|
15128
|
+
regex: tool.schema.string().optional(),
|
|
15129
|
+
inside: ruleObjectSchema.optional(),
|
|
15130
|
+
has: ruleObjectSchema.optional(),
|
|
15131
|
+
follows: ruleObjectSchema.optional(),
|
|
15132
|
+
precedes: ruleObjectSchema.optional(),
|
|
15133
|
+
all: tool.schema.array(ruleObjectSchema).optional(),
|
|
15134
|
+
any: tool.schema.array(ruleObjectSchema).optional(),
|
|
15135
|
+
not: ruleObjectSchema.optional(),
|
|
15136
|
+
matches: tool.schema.string().optional(),
|
|
15137
|
+
stopBy: tool.schema.union([tool.schema.enum(["neighbor", "end"]), ruleObjectSchema]).optional(),
|
|
15138
|
+
field: tool.schema.string().optional()
|
|
15139
|
+
}).passthrough().refine((obj) => Object.keys(obj).length > 0, {
|
|
15140
|
+
message: "Rule object must have at least one property (e.g., pattern, kind, has, inside)"
|
|
15141
|
+
}));
|
|
15142
|
+
var ruleSchema = tool.schema.object({
|
|
15143
|
+
id: tool.schema.string(),
|
|
15144
|
+
language: tool.schema.string(),
|
|
15145
|
+
rule: ruleObjectSchema,
|
|
15146
|
+
message: tool.schema.string().optional(),
|
|
15147
|
+
severity: tool.schema.enum(["error", "warning", "info", "hint"]).optional(),
|
|
15148
|
+
fix: tool.schema.string().optional()
|
|
15149
|
+
});
|
|
12424
15150
|
function createFindTool(directory) {
|
|
12425
15151
|
return tool({
|
|
12426
15152
|
description: "Find code in the project using a simple AST pattern.",
|
|
@@ -12430,7 +15156,7 @@ function createFindTool(directory) {
|
|
|
12430
15156
|
max_results: tool.schema.number().int().positive().optional(),
|
|
12431
15157
|
output_format: tool.schema.enum(["text", "json"]).optional()
|
|
12432
15158
|
},
|
|
12433
|
-
async execute(args) {
|
|
15159
|
+
async execute(args, _context) {
|
|
12434
15160
|
const { pattern, language, max_results, output_format = "text" } = args;
|
|
12435
15161
|
const cmdArgs = ["--pattern", pattern];
|
|
12436
15162
|
if (language) {
|
|
@@ -12465,37 +15191,54 @@ ${textOutput}`;
|
|
|
12465
15191
|
}
|
|
12466
15192
|
function createFindByRuleTool(directory) {
|
|
12467
15193
|
return tool({
|
|
12468
|
-
description: "Find code using a
|
|
15194
|
+
description: "Find code using a structured AST rule for advanced structural queries.",
|
|
12469
15195
|
args: {
|
|
12470
|
-
|
|
15196
|
+
rule: ruleSchema,
|
|
12471
15197
|
max_results: tool.schema.number().int().positive().optional(),
|
|
12472
15198
|
output_format: tool.schema.enum(["text", "json"]).optional()
|
|
12473
15199
|
},
|
|
12474
|
-
async execute(args) {
|
|
12475
|
-
const {
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
limitedMatches = matches
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
header
|
|
12495
|
-
|
|
12496
|
-
|
|
15200
|
+
async execute(args, _context) {
|
|
15201
|
+
const { rule, max_results, output_format = "text" } = args;
|
|
15202
|
+
try {
|
|
15203
|
+
const yamlString = jsYaml.dump(rule);
|
|
15204
|
+
const cmdArgs = ["--inline-rules", yamlString, "--json", "."];
|
|
15205
|
+
const { matches } = await executeAstGrep("scan", cmdArgs, {
|
|
15206
|
+
directory
|
|
15207
|
+
});
|
|
15208
|
+
const totalMatches = matches.length;
|
|
15209
|
+
let limitedMatches = matches;
|
|
15210
|
+
if (max_results && totalMatches > max_results) {
|
|
15211
|
+
limitedMatches = matches.slice(0, max_results);
|
|
15212
|
+
}
|
|
15213
|
+
if (output_format === "json") {
|
|
15214
|
+
return JSON.stringify(limitedMatches, null, 2);
|
|
15215
|
+
}
|
|
15216
|
+
if (limitedMatches.length === 0) {
|
|
15217
|
+
return "No matches found";
|
|
15218
|
+
}
|
|
15219
|
+
const textOutput = formatMatchesAsText(limitedMatches);
|
|
15220
|
+
let header = `Found ${limitedMatches.length} matches`;
|
|
15221
|
+
if (max_results && totalMatches > max_results) {
|
|
15222
|
+
header += ` (showing first ${max_results} of ${totalMatches})`;
|
|
15223
|
+
}
|
|
15224
|
+
return `${header}:
|
|
12497
15225
|
|
|
12498
15226
|
${textOutput}`;
|
|
15227
|
+
} catch (error45) {
|
|
15228
|
+
if (error45 instanceof Error && error45.message.includes("Cannot parse rule")) {
|
|
15229
|
+
return `Invalid rule structure: ${error45.message}
|
|
15230
|
+
|
|
15231
|
+
Rule must include id, language, and rule fields. The rule field must be an object with at least one property (pattern, kind, has, inside, etc.). Example:
|
|
15232
|
+
${JSON.stringify({
|
|
15233
|
+
id: "example-rule",
|
|
15234
|
+
language: "javascript",
|
|
15235
|
+
rule: {
|
|
15236
|
+
pattern: "console.log($ARG)"
|
|
15237
|
+
}
|
|
15238
|
+
}, null, 2)}`;
|
|
15239
|
+
}
|
|
15240
|
+
throw error45;
|
|
15241
|
+
}
|
|
12499
15242
|
}
|
|
12500
15243
|
});
|
|
12501
15244
|
}
|
|
@@ -12507,7 +15250,7 @@ function createDumpSyntaxTool() {
|
|
|
12507
15250
|
language: tool.schema.string(),
|
|
12508
15251
|
format: tool.schema.enum(["cst", "ast", "pattern"]).optional()
|
|
12509
15252
|
},
|
|
12510
|
-
async execute(args) {
|
|
15253
|
+
async execute(args, _context) {
|
|
12511
15254
|
const { code, language, format = "cst" } = args;
|
|
12512
15255
|
const cmdArgs = ["--pattern", code, "--lang", language, `--debug-query=${format}`];
|
|
12513
15256
|
const { stderr } = await executeAstGrep("run", cmdArgs, {});
|
|
@@ -12517,22 +15260,39 @@ function createDumpSyntaxTool() {
|
|
|
12517
15260
|
}
|
|
12518
15261
|
function createTestRuleTool(directory) {
|
|
12519
15262
|
return tool({
|
|
12520
|
-
description: "Test a
|
|
15263
|
+
description: "Test a structured AST rule against a code snippet to verify matches.",
|
|
12521
15264
|
args: {
|
|
12522
15265
|
code: tool.schema.string(),
|
|
12523
|
-
|
|
15266
|
+
rule: ruleSchema
|
|
12524
15267
|
},
|
|
12525
|
-
async execute(args) {
|
|
12526
|
-
const { code,
|
|
12527
|
-
|
|
12528
|
-
|
|
12529
|
-
|
|
12530
|
-
|
|
12531
|
-
|
|
12532
|
-
|
|
12533
|
-
|
|
15268
|
+
async execute(args, _context) {
|
|
15269
|
+
const { code, rule } = args;
|
|
15270
|
+
try {
|
|
15271
|
+
const yamlString = jsYaml.dump(rule);
|
|
15272
|
+
const cmdArgs = ["--inline-rules", yamlString, "--json", "--stdin"];
|
|
15273
|
+
const { matches } = await executeAstGrep("scan", cmdArgs, {
|
|
15274
|
+
input: code,
|
|
15275
|
+
directory
|
|
15276
|
+
});
|
|
15277
|
+
if (matches.length === 0) {
|
|
15278
|
+
return "No matches found for the given code and rule. Try adding `stopBy: end` to your inside/has rule.";
|
|
15279
|
+
}
|
|
15280
|
+
return JSON.stringify(matches, null, 2);
|
|
15281
|
+
} catch (error45) {
|
|
15282
|
+
if (error45 instanceof Error && error45.message.includes("Cannot parse rule")) {
|
|
15283
|
+
return `Invalid rule structure: ${error45.message}
|
|
15284
|
+
|
|
15285
|
+
Rule must include id, language, and rule fields. The rule field must be an object with at least one property (pattern, kind, has, inside, etc.). Example:
|
|
15286
|
+
${JSON.stringify({
|
|
15287
|
+
id: "test-rule",
|
|
15288
|
+
language: "javascript",
|
|
15289
|
+
rule: {
|
|
15290
|
+
pattern: "console.log($ARG)"
|
|
15291
|
+
}
|
|
15292
|
+
}, null, 2)}`;
|
|
15293
|
+
}
|
|
15294
|
+
throw error45;
|
|
12534
15295
|
}
|
|
12535
|
-
return JSON.stringify(matches, null, 2);
|
|
12536
15296
|
}
|
|
12537
15297
|
});
|
|
12538
15298
|
}
|