oh-my-opencode 2.10.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +10 -0
- package/README.ko.md +10 -0
- package/README.md +30 -0
- package/README.zh-cn.md +10 -0
- package/dist/cli/index.js +3048 -360
- package/dist/config/schema.d.ts +165 -165
- package/dist/features/claude-code-command-loader/types.d.ts +19 -0
- package/dist/features/claude-code-mcp-loader/loader.d.ts +1 -0
- package/dist/features/claude-code-mcp-loader/loader.test.d.ts +1 -0
- package/dist/hooks/anthropic-context-window-limit-recovery/storage.test.d.ts +1 -0
- package/dist/hooks/anthropic-context-window-limit-recovery/types.d.ts +1 -1
- package/dist/hooks/auto-update-checker/constants.d.ts +4 -0
- package/dist/hooks/rules-injector/constants.d.ts +2 -0
- package/dist/hooks/rules-injector/finder.d.ts +1 -13
- package/dist/hooks/rules-injector/finder.test.d.ts +1 -0
- package/dist/hooks/rules-injector/parser.test.d.ts +1 -0
- package/dist/hooks/rules-injector/types.d.ts +13 -0
- package/dist/index.js +16980 -16606
- package/dist/plugin-config.d.ts +4 -0
- package/dist/plugin-handlers/config-handler.d.ts +10 -0
- package/dist/plugin-handlers/index.d.ts +1 -0
- package/dist/plugin-state.d.ts +6 -0
- package/dist/shared/frontmatter.d.ts +2 -2
- package/dist/shared/frontmatter.test.d.ts +1 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2657,7 +2657,7 @@ var require_napi = __commonJS((exports, module) => {
|
|
|
2657
2657
|
var require_package = __commonJS((exports, module) => {
|
|
2658
2658
|
module.exports = {
|
|
2659
2659
|
name: "oh-my-opencode",
|
|
2660
|
-
version: "2.
|
|
2660
|
+
version: "2.10.0",
|
|
2661
2661
|
description: "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
|
|
2662
2662
|
main: "dist/index.js",
|
|
2663
2663
|
types: "dist/index.d.ts",
|
|
@@ -3341,6 +3341,2653 @@ var import_picocolors2 = __toESM(require_picocolors(), 1);
|
|
|
3341
3341
|
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync, statSync } from "fs";
|
|
3342
3342
|
import { homedir } from "os";
|
|
3343
3343
|
import { join as join2 } from "path";
|
|
3344
|
+
|
|
3345
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
3346
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
3347
|
+
function isNothing(subject) {
|
|
3348
|
+
return typeof subject === "undefined" || subject === null;
|
|
3349
|
+
}
|
|
3350
|
+
function isObject(subject) {
|
|
3351
|
+
return typeof subject === "object" && subject !== null;
|
|
3352
|
+
}
|
|
3353
|
+
function toArray(sequence) {
|
|
3354
|
+
if (Array.isArray(sequence))
|
|
3355
|
+
return sequence;
|
|
3356
|
+
else if (isNothing(sequence))
|
|
3357
|
+
return [];
|
|
3358
|
+
return [sequence];
|
|
3359
|
+
}
|
|
3360
|
+
function extend(target, source) {
|
|
3361
|
+
var index, length, key, sourceKeys;
|
|
3362
|
+
if (source) {
|
|
3363
|
+
sourceKeys = Object.keys(source);
|
|
3364
|
+
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
3365
|
+
key = sourceKeys[index];
|
|
3366
|
+
target[key] = source[key];
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
return target;
|
|
3370
|
+
}
|
|
3371
|
+
function repeat(string, count) {
|
|
3372
|
+
var result = "", cycle;
|
|
3373
|
+
for (cycle = 0;cycle < count; cycle += 1) {
|
|
3374
|
+
result += string;
|
|
3375
|
+
}
|
|
3376
|
+
return result;
|
|
3377
|
+
}
|
|
3378
|
+
function isNegativeZero(number) {
|
|
3379
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
3380
|
+
}
|
|
3381
|
+
var isNothing_1 = isNothing;
|
|
3382
|
+
var isObject_1 = isObject;
|
|
3383
|
+
var toArray_1 = toArray;
|
|
3384
|
+
var repeat_1 = repeat;
|
|
3385
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
3386
|
+
var extend_1 = extend;
|
|
3387
|
+
var common = {
|
|
3388
|
+
isNothing: isNothing_1,
|
|
3389
|
+
isObject: isObject_1,
|
|
3390
|
+
toArray: toArray_1,
|
|
3391
|
+
repeat: repeat_1,
|
|
3392
|
+
isNegativeZero: isNegativeZero_1,
|
|
3393
|
+
extend: extend_1
|
|
3394
|
+
};
|
|
3395
|
+
function formatError(exception, compact) {
|
|
3396
|
+
var where = "", message = exception.reason || "(unknown reason)";
|
|
3397
|
+
if (!exception.mark)
|
|
3398
|
+
return message;
|
|
3399
|
+
if (exception.mark.name) {
|
|
3400
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
3401
|
+
}
|
|
3402
|
+
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
3403
|
+
if (!compact && exception.mark.snippet) {
|
|
3404
|
+
where += `
|
|
3405
|
+
|
|
3406
|
+
` + exception.mark.snippet;
|
|
3407
|
+
}
|
|
3408
|
+
return message + " " + where;
|
|
3409
|
+
}
|
|
3410
|
+
function YAMLException$1(reason, mark) {
|
|
3411
|
+
Error.call(this);
|
|
3412
|
+
this.name = "YAMLException";
|
|
3413
|
+
this.reason = reason;
|
|
3414
|
+
this.mark = mark;
|
|
3415
|
+
this.message = formatError(this, false);
|
|
3416
|
+
if (Error.captureStackTrace) {
|
|
3417
|
+
Error.captureStackTrace(this, this.constructor);
|
|
3418
|
+
} else {
|
|
3419
|
+
this.stack = new Error().stack || "";
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
3423
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
3424
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
3425
|
+
return this.name + ": " + formatError(this, compact);
|
|
3426
|
+
};
|
|
3427
|
+
var exception = YAMLException$1;
|
|
3428
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
3429
|
+
var head = "";
|
|
3430
|
+
var tail = "";
|
|
3431
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
3432
|
+
if (position - lineStart > maxHalfLength) {
|
|
3433
|
+
head = " ... ";
|
|
3434
|
+
lineStart = position - maxHalfLength + head.length;
|
|
3435
|
+
}
|
|
3436
|
+
if (lineEnd - position > maxHalfLength) {
|
|
3437
|
+
tail = " ...";
|
|
3438
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
3439
|
+
}
|
|
3440
|
+
return {
|
|
3441
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
3442
|
+
pos: position - lineStart + head.length
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
function padStart(string, max) {
|
|
3446
|
+
return common.repeat(" ", max - string.length) + string;
|
|
3447
|
+
}
|
|
3448
|
+
function makeSnippet(mark, options) {
|
|
3449
|
+
options = Object.create(options || null);
|
|
3450
|
+
if (!mark.buffer)
|
|
3451
|
+
return null;
|
|
3452
|
+
if (!options.maxLength)
|
|
3453
|
+
options.maxLength = 79;
|
|
3454
|
+
if (typeof options.indent !== "number")
|
|
3455
|
+
options.indent = 1;
|
|
3456
|
+
if (typeof options.linesBefore !== "number")
|
|
3457
|
+
options.linesBefore = 3;
|
|
3458
|
+
if (typeof options.linesAfter !== "number")
|
|
3459
|
+
options.linesAfter = 2;
|
|
3460
|
+
var re = /\r?\n|\r|\0/g;
|
|
3461
|
+
var lineStarts = [0];
|
|
3462
|
+
var lineEnds = [];
|
|
3463
|
+
var match;
|
|
3464
|
+
var foundLineNo = -1;
|
|
3465
|
+
while (match = re.exec(mark.buffer)) {
|
|
3466
|
+
lineEnds.push(match.index);
|
|
3467
|
+
lineStarts.push(match.index + match[0].length);
|
|
3468
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
3469
|
+
foundLineNo = lineStarts.length - 2;
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
3472
|
+
if (foundLineNo < 0)
|
|
3473
|
+
foundLineNo = lineStarts.length - 1;
|
|
3474
|
+
var result = "", i, line;
|
|
3475
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
3476
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
3477
|
+
for (i = 1;i <= options.linesBefore; i++) {
|
|
3478
|
+
if (foundLineNo - i < 0)
|
|
3479
|
+
break;
|
|
3480
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
3481
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
3482
|
+
` + result;
|
|
3483
|
+
}
|
|
3484
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
3485
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
3486
|
+
`;
|
|
3487
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + `
|
|
3488
|
+
`;
|
|
3489
|
+
for (i = 1;i <= options.linesAfter; i++) {
|
|
3490
|
+
if (foundLineNo + i >= lineEnds.length)
|
|
3491
|
+
break;
|
|
3492
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
3493
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
3494
|
+
`;
|
|
3495
|
+
}
|
|
3496
|
+
return result.replace(/\n$/, "");
|
|
3497
|
+
}
|
|
3498
|
+
var snippet = makeSnippet;
|
|
3499
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
3500
|
+
"kind",
|
|
3501
|
+
"multi",
|
|
3502
|
+
"resolve",
|
|
3503
|
+
"construct",
|
|
3504
|
+
"instanceOf",
|
|
3505
|
+
"predicate",
|
|
3506
|
+
"represent",
|
|
3507
|
+
"representName",
|
|
3508
|
+
"defaultStyle",
|
|
3509
|
+
"styleAliases"
|
|
3510
|
+
];
|
|
3511
|
+
var YAML_NODE_KINDS = [
|
|
3512
|
+
"scalar",
|
|
3513
|
+
"sequence",
|
|
3514
|
+
"mapping"
|
|
3515
|
+
];
|
|
3516
|
+
function compileStyleAliases(map) {
|
|
3517
|
+
var result = {};
|
|
3518
|
+
if (map !== null) {
|
|
3519
|
+
Object.keys(map).forEach(function(style) {
|
|
3520
|
+
map[style].forEach(function(alias) {
|
|
3521
|
+
result[String(alias)] = style;
|
|
3522
|
+
});
|
|
3523
|
+
});
|
|
3524
|
+
}
|
|
3525
|
+
return result;
|
|
3526
|
+
}
|
|
3527
|
+
function Type$1(tag, options) {
|
|
3528
|
+
options = options || {};
|
|
3529
|
+
Object.keys(options).forEach(function(name) {
|
|
3530
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
3531
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
3532
|
+
}
|
|
3533
|
+
});
|
|
3534
|
+
this.options = options;
|
|
3535
|
+
this.tag = tag;
|
|
3536
|
+
this.kind = options["kind"] || null;
|
|
3537
|
+
this.resolve = options["resolve"] || function() {
|
|
3538
|
+
return true;
|
|
3539
|
+
};
|
|
3540
|
+
this.construct = options["construct"] || function(data) {
|
|
3541
|
+
return data;
|
|
3542
|
+
};
|
|
3543
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
3544
|
+
this.predicate = options["predicate"] || null;
|
|
3545
|
+
this.represent = options["represent"] || null;
|
|
3546
|
+
this.representName = options["representName"] || null;
|
|
3547
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
3548
|
+
this.multi = options["multi"] || false;
|
|
3549
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
3550
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
3551
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
var type = Type$1;
|
|
3555
|
+
function compileList(schema, name) {
|
|
3556
|
+
var result = [];
|
|
3557
|
+
schema[name].forEach(function(currentType) {
|
|
3558
|
+
var newIndex = result.length;
|
|
3559
|
+
result.forEach(function(previousType, previousIndex) {
|
|
3560
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
3561
|
+
newIndex = previousIndex;
|
|
3562
|
+
}
|
|
3563
|
+
});
|
|
3564
|
+
result[newIndex] = currentType;
|
|
3565
|
+
});
|
|
3566
|
+
return result;
|
|
3567
|
+
}
|
|
3568
|
+
function compileMap() {
|
|
3569
|
+
var result = {
|
|
3570
|
+
scalar: {},
|
|
3571
|
+
sequence: {},
|
|
3572
|
+
mapping: {},
|
|
3573
|
+
fallback: {},
|
|
3574
|
+
multi: {
|
|
3575
|
+
scalar: [],
|
|
3576
|
+
sequence: [],
|
|
3577
|
+
mapping: [],
|
|
3578
|
+
fallback: []
|
|
3579
|
+
}
|
|
3580
|
+
}, index, length;
|
|
3581
|
+
function collectType(type2) {
|
|
3582
|
+
if (type2.multi) {
|
|
3583
|
+
result.multi[type2.kind].push(type2);
|
|
3584
|
+
result.multi["fallback"].push(type2);
|
|
3585
|
+
} else {
|
|
3586
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
3590
|
+
arguments[index].forEach(collectType);
|
|
3591
|
+
}
|
|
3592
|
+
return result;
|
|
3593
|
+
}
|
|
3594
|
+
function Schema$1(definition) {
|
|
3595
|
+
return this.extend(definition);
|
|
3596
|
+
}
|
|
3597
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
3598
|
+
var implicit = [];
|
|
3599
|
+
var explicit = [];
|
|
3600
|
+
if (definition instanceof type) {
|
|
3601
|
+
explicit.push(definition);
|
|
3602
|
+
} else if (Array.isArray(definition)) {
|
|
3603
|
+
explicit = explicit.concat(definition);
|
|
3604
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
3605
|
+
if (definition.implicit)
|
|
3606
|
+
implicit = implicit.concat(definition.implicit);
|
|
3607
|
+
if (definition.explicit)
|
|
3608
|
+
explicit = explicit.concat(definition.explicit);
|
|
3609
|
+
} else {
|
|
3610
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
3611
|
+
}
|
|
3612
|
+
implicit.forEach(function(type$1) {
|
|
3613
|
+
if (!(type$1 instanceof type)) {
|
|
3614
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
3615
|
+
}
|
|
3616
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
3617
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
3618
|
+
}
|
|
3619
|
+
if (type$1.multi) {
|
|
3620
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
3621
|
+
}
|
|
3622
|
+
});
|
|
3623
|
+
explicit.forEach(function(type$1) {
|
|
3624
|
+
if (!(type$1 instanceof type)) {
|
|
3625
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
3626
|
+
}
|
|
3627
|
+
});
|
|
3628
|
+
var result = Object.create(Schema$1.prototype);
|
|
3629
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
3630
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
3631
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
3632
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
3633
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
3634
|
+
return result;
|
|
3635
|
+
};
|
|
3636
|
+
var schema = Schema$1;
|
|
3637
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
3638
|
+
kind: "scalar",
|
|
3639
|
+
construct: function(data) {
|
|
3640
|
+
return data !== null ? data : "";
|
|
3641
|
+
}
|
|
3642
|
+
});
|
|
3643
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
3644
|
+
kind: "sequence",
|
|
3645
|
+
construct: function(data) {
|
|
3646
|
+
return data !== null ? data : [];
|
|
3647
|
+
}
|
|
3648
|
+
});
|
|
3649
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
3650
|
+
kind: "mapping",
|
|
3651
|
+
construct: function(data) {
|
|
3652
|
+
return data !== null ? data : {};
|
|
3653
|
+
}
|
|
3654
|
+
});
|
|
3655
|
+
var failsafe = new schema({
|
|
3656
|
+
explicit: [
|
|
3657
|
+
str,
|
|
3658
|
+
seq,
|
|
3659
|
+
map
|
|
3660
|
+
]
|
|
3661
|
+
});
|
|
3662
|
+
function resolveYamlNull(data) {
|
|
3663
|
+
if (data === null)
|
|
3664
|
+
return true;
|
|
3665
|
+
var max = data.length;
|
|
3666
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
3667
|
+
}
|
|
3668
|
+
function constructYamlNull() {
|
|
3669
|
+
return null;
|
|
3670
|
+
}
|
|
3671
|
+
function isNull(object) {
|
|
3672
|
+
return object === null;
|
|
3673
|
+
}
|
|
3674
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
3675
|
+
kind: "scalar",
|
|
3676
|
+
resolve: resolveYamlNull,
|
|
3677
|
+
construct: constructYamlNull,
|
|
3678
|
+
predicate: isNull,
|
|
3679
|
+
represent: {
|
|
3680
|
+
canonical: function() {
|
|
3681
|
+
return "~";
|
|
3682
|
+
},
|
|
3683
|
+
lowercase: function() {
|
|
3684
|
+
return "null";
|
|
3685
|
+
},
|
|
3686
|
+
uppercase: function() {
|
|
3687
|
+
return "NULL";
|
|
3688
|
+
},
|
|
3689
|
+
camelcase: function() {
|
|
3690
|
+
return "Null";
|
|
3691
|
+
},
|
|
3692
|
+
empty: function() {
|
|
3693
|
+
return "";
|
|
3694
|
+
}
|
|
3695
|
+
},
|
|
3696
|
+
defaultStyle: "lowercase"
|
|
3697
|
+
});
|
|
3698
|
+
function resolveYamlBoolean(data) {
|
|
3699
|
+
if (data === null)
|
|
3700
|
+
return false;
|
|
3701
|
+
var max = data.length;
|
|
3702
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
3703
|
+
}
|
|
3704
|
+
function constructYamlBoolean(data) {
|
|
3705
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
3706
|
+
}
|
|
3707
|
+
function isBoolean(object) {
|
|
3708
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
3709
|
+
}
|
|
3710
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
3711
|
+
kind: "scalar",
|
|
3712
|
+
resolve: resolveYamlBoolean,
|
|
3713
|
+
construct: constructYamlBoolean,
|
|
3714
|
+
predicate: isBoolean,
|
|
3715
|
+
represent: {
|
|
3716
|
+
lowercase: function(object) {
|
|
3717
|
+
return object ? "true" : "false";
|
|
3718
|
+
},
|
|
3719
|
+
uppercase: function(object) {
|
|
3720
|
+
return object ? "TRUE" : "FALSE";
|
|
3721
|
+
},
|
|
3722
|
+
camelcase: function(object) {
|
|
3723
|
+
return object ? "True" : "False";
|
|
3724
|
+
}
|
|
3725
|
+
},
|
|
3726
|
+
defaultStyle: "lowercase"
|
|
3727
|
+
});
|
|
3728
|
+
function isHexCode(c) {
|
|
3729
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
3730
|
+
}
|
|
3731
|
+
function isOctCode(c) {
|
|
3732
|
+
return 48 <= c && c <= 55;
|
|
3733
|
+
}
|
|
3734
|
+
function isDecCode(c) {
|
|
3735
|
+
return 48 <= c && c <= 57;
|
|
3736
|
+
}
|
|
3737
|
+
function resolveYamlInteger(data) {
|
|
3738
|
+
if (data === null)
|
|
3739
|
+
return false;
|
|
3740
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
3741
|
+
if (!max)
|
|
3742
|
+
return false;
|
|
3743
|
+
ch = data[index];
|
|
3744
|
+
if (ch === "-" || ch === "+") {
|
|
3745
|
+
ch = data[++index];
|
|
3746
|
+
}
|
|
3747
|
+
if (ch === "0") {
|
|
3748
|
+
if (index + 1 === max)
|
|
3749
|
+
return true;
|
|
3750
|
+
ch = data[++index];
|
|
3751
|
+
if (ch === "b") {
|
|
3752
|
+
index++;
|
|
3753
|
+
for (;index < max; index++) {
|
|
3754
|
+
ch = data[index];
|
|
3755
|
+
if (ch === "_")
|
|
3756
|
+
continue;
|
|
3757
|
+
if (ch !== "0" && ch !== "1")
|
|
3758
|
+
return false;
|
|
3759
|
+
hasDigits = true;
|
|
3760
|
+
}
|
|
3761
|
+
return hasDigits && ch !== "_";
|
|
3762
|
+
}
|
|
3763
|
+
if (ch === "x") {
|
|
3764
|
+
index++;
|
|
3765
|
+
for (;index < max; index++) {
|
|
3766
|
+
ch = data[index];
|
|
3767
|
+
if (ch === "_")
|
|
3768
|
+
continue;
|
|
3769
|
+
if (!isHexCode(data.charCodeAt(index)))
|
|
3770
|
+
return false;
|
|
3771
|
+
hasDigits = true;
|
|
3772
|
+
}
|
|
3773
|
+
return hasDigits && ch !== "_";
|
|
3774
|
+
}
|
|
3775
|
+
if (ch === "o") {
|
|
3776
|
+
index++;
|
|
3777
|
+
for (;index < max; index++) {
|
|
3778
|
+
ch = data[index];
|
|
3779
|
+
if (ch === "_")
|
|
3780
|
+
continue;
|
|
3781
|
+
if (!isOctCode(data.charCodeAt(index)))
|
|
3782
|
+
return false;
|
|
3783
|
+
hasDigits = true;
|
|
3784
|
+
}
|
|
3785
|
+
return hasDigits && ch !== "_";
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
if (ch === "_")
|
|
3789
|
+
return false;
|
|
3790
|
+
for (;index < max; index++) {
|
|
3791
|
+
ch = data[index];
|
|
3792
|
+
if (ch === "_")
|
|
3793
|
+
continue;
|
|
3794
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
3795
|
+
return false;
|
|
3796
|
+
}
|
|
3797
|
+
hasDigits = true;
|
|
3798
|
+
}
|
|
3799
|
+
if (!hasDigits || ch === "_")
|
|
3800
|
+
return false;
|
|
3801
|
+
return true;
|
|
3802
|
+
}
|
|
3803
|
+
function constructYamlInteger(data) {
|
|
3804
|
+
var value = data, sign = 1, ch;
|
|
3805
|
+
if (value.indexOf("_") !== -1) {
|
|
3806
|
+
value = value.replace(/_/g, "");
|
|
3807
|
+
}
|
|
3808
|
+
ch = value[0];
|
|
3809
|
+
if (ch === "-" || ch === "+") {
|
|
3810
|
+
if (ch === "-")
|
|
3811
|
+
sign = -1;
|
|
3812
|
+
value = value.slice(1);
|
|
3813
|
+
ch = value[0];
|
|
3814
|
+
}
|
|
3815
|
+
if (value === "0")
|
|
3816
|
+
return 0;
|
|
3817
|
+
if (ch === "0") {
|
|
3818
|
+
if (value[1] === "b")
|
|
3819
|
+
return sign * parseInt(value.slice(2), 2);
|
|
3820
|
+
if (value[1] === "x")
|
|
3821
|
+
return sign * parseInt(value.slice(2), 16);
|
|
3822
|
+
if (value[1] === "o")
|
|
3823
|
+
return sign * parseInt(value.slice(2), 8);
|
|
3824
|
+
}
|
|
3825
|
+
return sign * parseInt(value, 10);
|
|
3826
|
+
}
|
|
3827
|
+
function isInteger(object) {
|
|
3828
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
3829
|
+
}
|
|
3830
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
3831
|
+
kind: "scalar",
|
|
3832
|
+
resolve: resolveYamlInteger,
|
|
3833
|
+
construct: constructYamlInteger,
|
|
3834
|
+
predicate: isInteger,
|
|
3835
|
+
represent: {
|
|
3836
|
+
binary: function(obj) {
|
|
3837
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
3838
|
+
},
|
|
3839
|
+
octal: function(obj) {
|
|
3840
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
3841
|
+
},
|
|
3842
|
+
decimal: function(obj) {
|
|
3843
|
+
return obj.toString(10);
|
|
3844
|
+
},
|
|
3845
|
+
hexadecimal: function(obj) {
|
|
3846
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
3847
|
+
}
|
|
3848
|
+
},
|
|
3849
|
+
defaultStyle: "decimal",
|
|
3850
|
+
styleAliases: {
|
|
3851
|
+
binary: [2, "bin"],
|
|
3852
|
+
octal: [8, "oct"],
|
|
3853
|
+
decimal: [10, "dec"],
|
|
3854
|
+
hexadecimal: [16, "hex"]
|
|
3855
|
+
}
|
|
3856
|
+
});
|
|
3857
|
+
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))$");
|
|
3858
|
+
function resolveYamlFloat(data) {
|
|
3859
|
+
if (data === null)
|
|
3860
|
+
return false;
|
|
3861
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
3862
|
+
return false;
|
|
3863
|
+
}
|
|
3864
|
+
return true;
|
|
3865
|
+
}
|
|
3866
|
+
function constructYamlFloat(data) {
|
|
3867
|
+
var value, sign;
|
|
3868
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
3869
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
3870
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
3871
|
+
value = value.slice(1);
|
|
3872
|
+
}
|
|
3873
|
+
if (value === ".inf") {
|
|
3874
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
3875
|
+
} else if (value === ".nan") {
|
|
3876
|
+
return NaN;
|
|
3877
|
+
}
|
|
3878
|
+
return sign * parseFloat(value, 10);
|
|
3879
|
+
}
|
|
3880
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
3881
|
+
function representYamlFloat(object, style) {
|
|
3882
|
+
var res;
|
|
3883
|
+
if (isNaN(object)) {
|
|
3884
|
+
switch (style) {
|
|
3885
|
+
case "lowercase":
|
|
3886
|
+
return ".nan";
|
|
3887
|
+
case "uppercase":
|
|
3888
|
+
return ".NAN";
|
|
3889
|
+
case "camelcase":
|
|
3890
|
+
return ".NaN";
|
|
3891
|
+
}
|
|
3892
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
3893
|
+
switch (style) {
|
|
3894
|
+
case "lowercase":
|
|
3895
|
+
return ".inf";
|
|
3896
|
+
case "uppercase":
|
|
3897
|
+
return ".INF";
|
|
3898
|
+
case "camelcase":
|
|
3899
|
+
return ".Inf";
|
|
3900
|
+
}
|
|
3901
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
3902
|
+
switch (style) {
|
|
3903
|
+
case "lowercase":
|
|
3904
|
+
return "-.inf";
|
|
3905
|
+
case "uppercase":
|
|
3906
|
+
return "-.INF";
|
|
3907
|
+
case "camelcase":
|
|
3908
|
+
return "-.Inf";
|
|
3909
|
+
}
|
|
3910
|
+
} else if (common.isNegativeZero(object)) {
|
|
3911
|
+
return "-0.0";
|
|
3912
|
+
}
|
|
3913
|
+
res = object.toString(10);
|
|
3914
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
3915
|
+
}
|
|
3916
|
+
function isFloat(object) {
|
|
3917
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
3918
|
+
}
|
|
3919
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
3920
|
+
kind: "scalar",
|
|
3921
|
+
resolve: resolveYamlFloat,
|
|
3922
|
+
construct: constructYamlFloat,
|
|
3923
|
+
predicate: isFloat,
|
|
3924
|
+
represent: representYamlFloat,
|
|
3925
|
+
defaultStyle: "lowercase"
|
|
3926
|
+
});
|
|
3927
|
+
var json = failsafe.extend({
|
|
3928
|
+
implicit: [
|
|
3929
|
+
_null,
|
|
3930
|
+
bool,
|
|
3931
|
+
int,
|
|
3932
|
+
float
|
|
3933
|
+
]
|
|
3934
|
+
});
|
|
3935
|
+
var core = json;
|
|
3936
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
3937
|
+
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]))?))?$");
|
|
3938
|
+
function resolveYamlTimestamp(data) {
|
|
3939
|
+
if (data === null)
|
|
3940
|
+
return false;
|
|
3941
|
+
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
3942
|
+
return true;
|
|
3943
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
3944
|
+
return true;
|
|
3945
|
+
return false;
|
|
3946
|
+
}
|
|
3947
|
+
function constructYamlTimestamp(data) {
|
|
3948
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
3949
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
3950
|
+
if (match === null)
|
|
3951
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
3952
|
+
if (match === null)
|
|
3953
|
+
throw new Error("Date resolve error");
|
|
3954
|
+
year = +match[1];
|
|
3955
|
+
month = +match[2] - 1;
|
|
3956
|
+
day = +match[3];
|
|
3957
|
+
if (!match[4]) {
|
|
3958
|
+
return new Date(Date.UTC(year, month, day));
|
|
3959
|
+
}
|
|
3960
|
+
hour = +match[4];
|
|
3961
|
+
minute = +match[5];
|
|
3962
|
+
second = +match[6];
|
|
3963
|
+
if (match[7]) {
|
|
3964
|
+
fraction = match[7].slice(0, 3);
|
|
3965
|
+
while (fraction.length < 3) {
|
|
3966
|
+
fraction += "0";
|
|
3967
|
+
}
|
|
3968
|
+
fraction = +fraction;
|
|
3969
|
+
}
|
|
3970
|
+
if (match[9]) {
|
|
3971
|
+
tz_hour = +match[10];
|
|
3972
|
+
tz_minute = +(match[11] || 0);
|
|
3973
|
+
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
3974
|
+
if (match[9] === "-")
|
|
3975
|
+
delta = -delta;
|
|
3976
|
+
}
|
|
3977
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
3978
|
+
if (delta)
|
|
3979
|
+
date.setTime(date.getTime() - delta);
|
|
3980
|
+
return date;
|
|
3981
|
+
}
|
|
3982
|
+
function representYamlTimestamp(object) {
|
|
3983
|
+
return object.toISOString();
|
|
3984
|
+
}
|
|
3985
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
3986
|
+
kind: "scalar",
|
|
3987
|
+
resolve: resolveYamlTimestamp,
|
|
3988
|
+
construct: constructYamlTimestamp,
|
|
3989
|
+
instanceOf: Date,
|
|
3990
|
+
represent: representYamlTimestamp
|
|
3991
|
+
});
|
|
3992
|
+
function resolveYamlMerge(data) {
|
|
3993
|
+
return data === "<<" || data === null;
|
|
3994
|
+
}
|
|
3995
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
3996
|
+
kind: "scalar",
|
|
3997
|
+
resolve: resolveYamlMerge
|
|
3998
|
+
});
|
|
3999
|
+
var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
4000
|
+
\r`;
|
|
4001
|
+
function resolveYamlBinary(data) {
|
|
4002
|
+
if (data === null)
|
|
4003
|
+
return false;
|
|
4004
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
4005
|
+
for (idx = 0;idx < max; idx++) {
|
|
4006
|
+
code = map2.indexOf(data.charAt(idx));
|
|
4007
|
+
if (code > 64)
|
|
4008
|
+
continue;
|
|
4009
|
+
if (code < 0)
|
|
4010
|
+
return false;
|
|
4011
|
+
bitlen += 6;
|
|
4012
|
+
}
|
|
4013
|
+
return bitlen % 8 === 0;
|
|
4014
|
+
}
|
|
4015
|
+
function constructYamlBinary(data) {
|
|
4016
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
4017
|
+
for (idx = 0;idx < max; idx++) {
|
|
4018
|
+
if (idx % 4 === 0 && idx) {
|
|
4019
|
+
result.push(bits >> 16 & 255);
|
|
4020
|
+
result.push(bits >> 8 & 255);
|
|
4021
|
+
result.push(bits & 255);
|
|
4022
|
+
}
|
|
4023
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
4024
|
+
}
|
|
4025
|
+
tailbits = max % 4 * 6;
|
|
4026
|
+
if (tailbits === 0) {
|
|
4027
|
+
result.push(bits >> 16 & 255);
|
|
4028
|
+
result.push(bits >> 8 & 255);
|
|
4029
|
+
result.push(bits & 255);
|
|
4030
|
+
} else if (tailbits === 18) {
|
|
4031
|
+
result.push(bits >> 10 & 255);
|
|
4032
|
+
result.push(bits >> 2 & 255);
|
|
4033
|
+
} else if (tailbits === 12) {
|
|
4034
|
+
result.push(bits >> 4 & 255);
|
|
4035
|
+
}
|
|
4036
|
+
return new Uint8Array(result);
|
|
4037
|
+
}
|
|
4038
|
+
function representYamlBinary(object) {
|
|
4039
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
4040
|
+
for (idx = 0;idx < max; idx++) {
|
|
4041
|
+
if (idx % 3 === 0 && idx) {
|
|
4042
|
+
result += map2[bits >> 18 & 63];
|
|
4043
|
+
result += map2[bits >> 12 & 63];
|
|
4044
|
+
result += map2[bits >> 6 & 63];
|
|
4045
|
+
result += map2[bits & 63];
|
|
4046
|
+
}
|
|
4047
|
+
bits = (bits << 8) + object[idx];
|
|
4048
|
+
}
|
|
4049
|
+
tail = max % 3;
|
|
4050
|
+
if (tail === 0) {
|
|
4051
|
+
result += map2[bits >> 18 & 63];
|
|
4052
|
+
result += map2[bits >> 12 & 63];
|
|
4053
|
+
result += map2[bits >> 6 & 63];
|
|
4054
|
+
result += map2[bits & 63];
|
|
4055
|
+
} else if (tail === 2) {
|
|
4056
|
+
result += map2[bits >> 10 & 63];
|
|
4057
|
+
result += map2[bits >> 4 & 63];
|
|
4058
|
+
result += map2[bits << 2 & 63];
|
|
4059
|
+
result += map2[64];
|
|
4060
|
+
} else if (tail === 1) {
|
|
4061
|
+
result += map2[bits >> 2 & 63];
|
|
4062
|
+
result += map2[bits << 4 & 63];
|
|
4063
|
+
result += map2[64];
|
|
4064
|
+
result += map2[64];
|
|
4065
|
+
}
|
|
4066
|
+
return result;
|
|
4067
|
+
}
|
|
4068
|
+
function isBinary(obj) {
|
|
4069
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
4070
|
+
}
|
|
4071
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
4072
|
+
kind: "scalar",
|
|
4073
|
+
resolve: resolveYamlBinary,
|
|
4074
|
+
construct: constructYamlBinary,
|
|
4075
|
+
predicate: isBinary,
|
|
4076
|
+
represent: representYamlBinary
|
|
4077
|
+
});
|
|
4078
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
4079
|
+
var _toString$2 = Object.prototype.toString;
|
|
4080
|
+
function resolveYamlOmap(data) {
|
|
4081
|
+
if (data === null)
|
|
4082
|
+
return true;
|
|
4083
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
4084
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
4085
|
+
pair = object[index];
|
|
4086
|
+
pairHasKey = false;
|
|
4087
|
+
if (_toString$2.call(pair) !== "[object Object]")
|
|
4088
|
+
return false;
|
|
4089
|
+
for (pairKey in pair) {
|
|
4090
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
4091
|
+
if (!pairHasKey)
|
|
4092
|
+
pairHasKey = true;
|
|
4093
|
+
else
|
|
4094
|
+
return false;
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
if (!pairHasKey)
|
|
4098
|
+
return false;
|
|
4099
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
4100
|
+
objectKeys.push(pairKey);
|
|
4101
|
+
else
|
|
4102
|
+
return false;
|
|
4103
|
+
}
|
|
4104
|
+
return true;
|
|
4105
|
+
}
|
|
4106
|
+
function constructYamlOmap(data) {
|
|
4107
|
+
return data !== null ? data : [];
|
|
4108
|
+
}
|
|
4109
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
4110
|
+
kind: "sequence",
|
|
4111
|
+
resolve: resolveYamlOmap,
|
|
4112
|
+
construct: constructYamlOmap
|
|
4113
|
+
});
|
|
4114
|
+
var _toString$1 = Object.prototype.toString;
|
|
4115
|
+
function resolveYamlPairs(data) {
|
|
4116
|
+
if (data === null)
|
|
4117
|
+
return true;
|
|
4118
|
+
var index, length, pair, keys, result, object = data;
|
|
4119
|
+
result = new Array(object.length);
|
|
4120
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
4121
|
+
pair = object[index];
|
|
4122
|
+
if (_toString$1.call(pair) !== "[object Object]")
|
|
4123
|
+
return false;
|
|
4124
|
+
keys = Object.keys(pair);
|
|
4125
|
+
if (keys.length !== 1)
|
|
4126
|
+
return false;
|
|
4127
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
4128
|
+
}
|
|
4129
|
+
return true;
|
|
4130
|
+
}
|
|
4131
|
+
function constructYamlPairs(data) {
|
|
4132
|
+
if (data === null)
|
|
4133
|
+
return [];
|
|
4134
|
+
var index, length, pair, keys, result, object = data;
|
|
4135
|
+
result = new Array(object.length);
|
|
4136
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
4137
|
+
pair = object[index];
|
|
4138
|
+
keys = Object.keys(pair);
|
|
4139
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
4140
|
+
}
|
|
4141
|
+
return result;
|
|
4142
|
+
}
|
|
4143
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
4144
|
+
kind: "sequence",
|
|
4145
|
+
resolve: resolveYamlPairs,
|
|
4146
|
+
construct: constructYamlPairs
|
|
4147
|
+
});
|
|
4148
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
4149
|
+
function resolveYamlSet(data) {
|
|
4150
|
+
if (data === null)
|
|
4151
|
+
return true;
|
|
4152
|
+
var key, object = data;
|
|
4153
|
+
for (key in object) {
|
|
4154
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
4155
|
+
if (object[key] !== null)
|
|
4156
|
+
return false;
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
return true;
|
|
4160
|
+
}
|
|
4161
|
+
function constructYamlSet(data) {
|
|
4162
|
+
return data !== null ? data : {};
|
|
4163
|
+
}
|
|
4164
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
4165
|
+
kind: "mapping",
|
|
4166
|
+
resolve: resolveYamlSet,
|
|
4167
|
+
construct: constructYamlSet
|
|
4168
|
+
});
|
|
4169
|
+
var _default = core.extend({
|
|
4170
|
+
implicit: [
|
|
4171
|
+
timestamp,
|
|
4172
|
+
merge
|
|
4173
|
+
],
|
|
4174
|
+
explicit: [
|
|
4175
|
+
binary,
|
|
4176
|
+
omap,
|
|
4177
|
+
pairs,
|
|
4178
|
+
set
|
|
4179
|
+
]
|
|
4180
|
+
});
|
|
4181
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
4182
|
+
var CONTEXT_FLOW_IN = 1;
|
|
4183
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
4184
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
4185
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
4186
|
+
var CHOMPING_CLIP = 1;
|
|
4187
|
+
var CHOMPING_STRIP = 2;
|
|
4188
|
+
var CHOMPING_KEEP = 3;
|
|
4189
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
4190
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
4191
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
4192
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
4193
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
4194
|
+
function _class(obj) {
|
|
4195
|
+
return Object.prototype.toString.call(obj);
|
|
4196
|
+
}
|
|
4197
|
+
function is_EOL(c) {
|
|
4198
|
+
return c === 10 || c === 13;
|
|
4199
|
+
}
|
|
4200
|
+
function is_WHITE_SPACE(c) {
|
|
4201
|
+
return c === 9 || c === 32;
|
|
4202
|
+
}
|
|
4203
|
+
function is_WS_OR_EOL(c) {
|
|
4204
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
4205
|
+
}
|
|
4206
|
+
function is_FLOW_INDICATOR(c) {
|
|
4207
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
4208
|
+
}
|
|
4209
|
+
function fromHexCode(c) {
|
|
4210
|
+
var lc;
|
|
4211
|
+
if (48 <= c && c <= 57) {
|
|
4212
|
+
return c - 48;
|
|
4213
|
+
}
|
|
4214
|
+
lc = c | 32;
|
|
4215
|
+
if (97 <= lc && lc <= 102) {
|
|
4216
|
+
return lc - 97 + 10;
|
|
4217
|
+
}
|
|
4218
|
+
return -1;
|
|
4219
|
+
}
|
|
4220
|
+
function escapedHexLen(c) {
|
|
4221
|
+
if (c === 120) {
|
|
4222
|
+
return 2;
|
|
4223
|
+
}
|
|
4224
|
+
if (c === 117) {
|
|
4225
|
+
return 4;
|
|
4226
|
+
}
|
|
4227
|
+
if (c === 85) {
|
|
4228
|
+
return 8;
|
|
4229
|
+
}
|
|
4230
|
+
return 0;
|
|
4231
|
+
}
|
|
4232
|
+
function fromDecimalCode(c) {
|
|
4233
|
+
if (48 <= c && c <= 57) {
|
|
4234
|
+
return c - 48;
|
|
4235
|
+
}
|
|
4236
|
+
return -1;
|
|
4237
|
+
}
|
|
4238
|
+
function simpleEscapeSequence(c) {
|
|
4239
|
+
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
4240
|
+
` : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
4241
|
+
}
|
|
4242
|
+
function charFromCodepoint(c) {
|
|
4243
|
+
if (c <= 65535) {
|
|
4244
|
+
return String.fromCharCode(c);
|
|
4245
|
+
}
|
|
4246
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
4247
|
+
}
|
|
4248
|
+
function setProperty(object, key, value) {
|
|
4249
|
+
if (key === "__proto__") {
|
|
4250
|
+
Object.defineProperty(object, key, {
|
|
4251
|
+
configurable: true,
|
|
4252
|
+
enumerable: true,
|
|
4253
|
+
writable: true,
|
|
4254
|
+
value
|
|
4255
|
+
});
|
|
4256
|
+
} else {
|
|
4257
|
+
object[key] = value;
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
var simpleEscapeCheck = new Array(256);
|
|
4261
|
+
var simpleEscapeMap = new Array(256);
|
|
4262
|
+
for (i = 0;i < 256; i++) {
|
|
4263
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
4264
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
4265
|
+
}
|
|
4266
|
+
var i;
|
|
4267
|
+
function State$1(input, options) {
|
|
4268
|
+
this.input = input;
|
|
4269
|
+
this.filename = options["filename"] || null;
|
|
4270
|
+
this.schema = options["schema"] || _default;
|
|
4271
|
+
this.onWarning = options["onWarning"] || null;
|
|
4272
|
+
this.legacy = options["legacy"] || false;
|
|
4273
|
+
this.json = options["json"] || false;
|
|
4274
|
+
this.listener = options["listener"] || null;
|
|
4275
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
4276
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
4277
|
+
this.length = input.length;
|
|
4278
|
+
this.position = 0;
|
|
4279
|
+
this.line = 0;
|
|
4280
|
+
this.lineStart = 0;
|
|
4281
|
+
this.lineIndent = 0;
|
|
4282
|
+
this.firstTabInLine = -1;
|
|
4283
|
+
this.documents = [];
|
|
4284
|
+
}
|
|
4285
|
+
function generateError(state, message) {
|
|
4286
|
+
var mark = {
|
|
4287
|
+
name: state.filename,
|
|
4288
|
+
buffer: state.input.slice(0, -1),
|
|
4289
|
+
position: state.position,
|
|
4290
|
+
line: state.line,
|
|
4291
|
+
column: state.position - state.lineStart
|
|
4292
|
+
};
|
|
4293
|
+
mark.snippet = snippet(mark);
|
|
4294
|
+
return new exception(message, mark);
|
|
4295
|
+
}
|
|
4296
|
+
function throwError(state, message) {
|
|
4297
|
+
throw generateError(state, message);
|
|
4298
|
+
}
|
|
4299
|
+
function throwWarning(state, message) {
|
|
4300
|
+
if (state.onWarning) {
|
|
4301
|
+
state.onWarning.call(null, generateError(state, message));
|
|
4302
|
+
}
|
|
4303
|
+
}
|
|
4304
|
+
var directiveHandlers = {
|
|
4305
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
4306
|
+
var match, major, minor;
|
|
4307
|
+
if (state.version !== null) {
|
|
4308
|
+
throwError(state, "duplication of %YAML directive");
|
|
4309
|
+
}
|
|
4310
|
+
if (args.length !== 1) {
|
|
4311
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
4312
|
+
}
|
|
4313
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
4314
|
+
if (match === null) {
|
|
4315
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
4316
|
+
}
|
|
4317
|
+
major = parseInt(match[1], 10);
|
|
4318
|
+
minor = parseInt(match[2], 10);
|
|
4319
|
+
if (major !== 1) {
|
|
4320
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
4321
|
+
}
|
|
4322
|
+
state.version = args[0];
|
|
4323
|
+
state.checkLineBreaks = minor < 2;
|
|
4324
|
+
if (minor !== 1 && minor !== 2) {
|
|
4325
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
4326
|
+
}
|
|
4327
|
+
},
|
|
4328
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
4329
|
+
var handle, prefix;
|
|
4330
|
+
if (args.length !== 2) {
|
|
4331
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
4332
|
+
}
|
|
4333
|
+
handle = args[0];
|
|
4334
|
+
prefix = args[1];
|
|
4335
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
4336
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
4337
|
+
}
|
|
4338
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
4339
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
4340
|
+
}
|
|
4341
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
4342
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
4343
|
+
}
|
|
4344
|
+
try {
|
|
4345
|
+
prefix = decodeURIComponent(prefix);
|
|
4346
|
+
} catch (err) {
|
|
4347
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
4348
|
+
}
|
|
4349
|
+
state.tagMap[handle] = prefix;
|
|
4350
|
+
}
|
|
4351
|
+
};
|
|
4352
|
+
function captureSegment(state, start, end, checkJson) {
|
|
4353
|
+
var _position, _length, _character, _result;
|
|
4354
|
+
if (start < end) {
|
|
4355
|
+
_result = state.input.slice(start, end);
|
|
4356
|
+
if (checkJson) {
|
|
4357
|
+
for (_position = 0, _length = _result.length;_position < _length; _position += 1) {
|
|
4358
|
+
_character = _result.charCodeAt(_position);
|
|
4359
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
4360
|
+
throwError(state, "expected valid JSON character");
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
4364
|
+
throwError(state, "the stream contains non-printable characters");
|
|
4365
|
+
}
|
|
4366
|
+
state.result += _result;
|
|
4367
|
+
}
|
|
4368
|
+
}
|
|
4369
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
4370
|
+
var sourceKeys, key, index, quantity;
|
|
4371
|
+
if (!common.isObject(source)) {
|
|
4372
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
4373
|
+
}
|
|
4374
|
+
sourceKeys = Object.keys(source);
|
|
4375
|
+
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
4376
|
+
key = sourceKeys[index];
|
|
4377
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
4378
|
+
setProperty(destination, key, source[key]);
|
|
4379
|
+
overridableKeys[key] = true;
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
}
|
|
4383
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
4384
|
+
var index, quantity;
|
|
4385
|
+
if (Array.isArray(keyNode)) {
|
|
4386
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
4387
|
+
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
4388
|
+
if (Array.isArray(keyNode[index])) {
|
|
4389
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
4390
|
+
}
|
|
4391
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
4392
|
+
keyNode[index] = "[object Object]";
|
|
4393
|
+
}
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
4397
|
+
keyNode = "[object Object]";
|
|
4398
|
+
}
|
|
4399
|
+
keyNode = String(keyNode);
|
|
4400
|
+
if (_result === null) {
|
|
4401
|
+
_result = {};
|
|
4402
|
+
}
|
|
4403
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
4404
|
+
if (Array.isArray(valueNode)) {
|
|
4405
|
+
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
4406
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
4407
|
+
}
|
|
4408
|
+
} else {
|
|
4409
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
4410
|
+
}
|
|
4411
|
+
} else {
|
|
4412
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
4413
|
+
state.line = startLine || state.line;
|
|
4414
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
4415
|
+
state.position = startPos || state.position;
|
|
4416
|
+
throwError(state, "duplicated mapping key");
|
|
4417
|
+
}
|
|
4418
|
+
setProperty(_result, keyNode, valueNode);
|
|
4419
|
+
delete overridableKeys[keyNode];
|
|
4420
|
+
}
|
|
4421
|
+
return _result;
|
|
4422
|
+
}
|
|
4423
|
+
function readLineBreak(state) {
|
|
4424
|
+
var ch;
|
|
4425
|
+
ch = state.input.charCodeAt(state.position);
|
|
4426
|
+
if (ch === 10) {
|
|
4427
|
+
state.position++;
|
|
4428
|
+
} else if (ch === 13) {
|
|
4429
|
+
state.position++;
|
|
4430
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
4431
|
+
state.position++;
|
|
4432
|
+
}
|
|
4433
|
+
} else {
|
|
4434
|
+
throwError(state, "a line break is expected");
|
|
4435
|
+
}
|
|
4436
|
+
state.line += 1;
|
|
4437
|
+
state.lineStart = state.position;
|
|
4438
|
+
state.firstTabInLine = -1;
|
|
4439
|
+
}
|
|
4440
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
4441
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
4442
|
+
while (ch !== 0) {
|
|
4443
|
+
while (is_WHITE_SPACE(ch)) {
|
|
4444
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
4445
|
+
state.firstTabInLine = state.position;
|
|
4446
|
+
}
|
|
4447
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4448
|
+
}
|
|
4449
|
+
if (allowComments && ch === 35) {
|
|
4450
|
+
do {
|
|
4451
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4452
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
4453
|
+
}
|
|
4454
|
+
if (is_EOL(ch)) {
|
|
4455
|
+
readLineBreak(state);
|
|
4456
|
+
ch = state.input.charCodeAt(state.position);
|
|
4457
|
+
lineBreaks++;
|
|
4458
|
+
state.lineIndent = 0;
|
|
4459
|
+
while (ch === 32) {
|
|
4460
|
+
state.lineIndent++;
|
|
4461
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4462
|
+
}
|
|
4463
|
+
} else {
|
|
4464
|
+
break;
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
4468
|
+
throwWarning(state, "deficient indentation");
|
|
4469
|
+
}
|
|
4470
|
+
return lineBreaks;
|
|
4471
|
+
}
|
|
4472
|
+
function testDocumentSeparator(state) {
|
|
4473
|
+
var _position = state.position, ch;
|
|
4474
|
+
ch = state.input.charCodeAt(_position);
|
|
4475
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
4476
|
+
_position += 3;
|
|
4477
|
+
ch = state.input.charCodeAt(_position);
|
|
4478
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
4479
|
+
return true;
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
return false;
|
|
4483
|
+
}
|
|
4484
|
+
function writeFoldedLines(state, count) {
|
|
4485
|
+
if (count === 1) {
|
|
4486
|
+
state.result += " ";
|
|
4487
|
+
} else if (count > 1) {
|
|
4488
|
+
state.result += common.repeat(`
|
|
4489
|
+
`, count - 1);
|
|
4490
|
+
}
|
|
4491
|
+
}
|
|
4492
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
4493
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
4494
|
+
ch = state.input.charCodeAt(state.position);
|
|
4495
|
+
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) {
|
|
4496
|
+
return false;
|
|
4497
|
+
}
|
|
4498
|
+
if (ch === 63 || ch === 45) {
|
|
4499
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
4500
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
4501
|
+
return false;
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
state.kind = "scalar";
|
|
4505
|
+
state.result = "";
|
|
4506
|
+
captureStart = captureEnd = state.position;
|
|
4507
|
+
hasPendingContent = false;
|
|
4508
|
+
while (ch !== 0) {
|
|
4509
|
+
if (ch === 58) {
|
|
4510
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
4511
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
4512
|
+
break;
|
|
4513
|
+
}
|
|
4514
|
+
} else if (ch === 35) {
|
|
4515
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
4516
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
4517
|
+
break;
|
|
4518
|
+
}
|
|
4519
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
4520
|
+
break;
|
|
4521
|
+
} else if (is_EOL(ch)) {
|
|
4522
|
+
_line = state.line;
|
|
4523
|
+
_lineStart = state.lineStart;
|
|
4524
|
+
_lineIndent = state.lineIndent;
|
|
4525
|
+
skipSeparationSpace(state, false, -1);
|
|
4526
|
+
if (state.lineIndent >= nodeIndent) {
|
|
4527
|
+
hasPendingContent = true;
|
|
4528
|
+
ch = state.input.charCodeAt(state.position);
|
|
4529
|
+
continue;
|
|
4530
|
+
} else {
|
|
4531
|
+
state.position = captureEnd;
|
|
4532
|
+
state.line = _line;
|
|
4533
|
+
state.lineStart = _lineStart;
|
|
4534
|
+
state.lineIndent = _lineIndent;
|
|
4535
|
+
break;
|
|
4536
|
+
}
|
|
4537
|
+
}
|
|
4538
|
+
if (hasPendingContent) {
|
|
4539
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
4540
|
+
writeFoldedLines(state, state.line - _line);
|
|
4541
|
+
captureStart = captureEnd = state.position;
|
|
4542
|
+
hasPendingContent = false;
|
|
4543
|
+
}
|
|
4544
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
4545
|
+
captureEnd = state.position + 1;
|
|
4546
|
+
}
|
|
4547
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4548
|
+
}
|
|
4549
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
4550
|
+
if (state.result) {
|
|
4551
|
+
return true;
|
|
4552
|
+
}
|
|
4553
|
+
state.kind = _kind;
|
|
4554
|
+
state.result = _result;
|
|
4555
|
+
return false;
|
|
4556
|
+
}
|
|
4557
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
4558
|
+
var ch, captureStart, captureEnd;
|
|
4559
|
+
ch = state.input.charCodeAt(state.position);
|
|
4560
|
+
if (ch !== 39) {
|
|
4561
|
+
return false;
|
|
4562
|
+
}
|
|
4563
|
+
state.kind = "scalar";
|
|
4564
|
+
state.result = "";
|
|
4565
|
+
state.position++;
|
|
4566
|
+
captureStart = captureEnd = state.position;
|
|
4567
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
4568
|
+
if (ch === 39) {
|
|
4569
|
+
captureSegment(state, captureStart, state.position, true);
|
|
4570
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4571
|
+
if (ch === 39) {
|
|
4572
|
+
captureStart = state.position;
|
|
4573
|
+
state.position++;
|
|
4574
|
+
captureEnd = state.position;
|
|
4575
|
+
} else {
|
|
4576
|
+
return true;
|
|
4577
|
+
}
|
|
4578
|
+
} else if (is_EOL(ch)) {
|
|
4579
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
4580
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
4581
|
+
captureStart = captureEnd = state.position;
|
|
4582
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
4583
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
4584
|
+
} else {
|
|
4585
|
+
state.position++;
|
|
4586
|
+
captureEnd = state.position;
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
4590
|
+
}
|
|
4591
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
4592
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
4593
|
+
ch = state.input.charCodeAt(state.position);
|
|
4594
|
+
if (ch !== 34) {
|
|
4595
|
+
return false;
|
|
4596
|
+
}
|
|
4597
|
+
state.kind = "scalar";
|
|
4598
|
+
state.result = "";
|
|
4599
|
+
state.position++;
|
|
4600
|
+
captureStart = captureEnd = state.position;
|
|
4601
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
4602
|
+
if (ch === 34) {
|
|
4603
|
+
captureSegment(state, captureStart, state.position, true);
|
|
4604
|
+
state.position++;
|
|
4605
|
+
return true;
|
|
4606
|
+
} else if (ch === 92) {
|
|
4607
|
+
captureSegment(state, captureStart, state.position, true);
|
|
4608
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4609
|
+
if (is_EOL(ch)) {
|
|
4610
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
4611
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
4612
|
+
state.result += simpleEscapeMap[ch];
|
|
4613
|
+
state.position++;
|
|
4614
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
4615
|
+
hexLength = tmp;
|
|
4616
|
+
hexResult = 0;
|
|
4617
|
+
for (;hexLength > 0; hexLength--) {
|
|
4618
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4619
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
4620
|
+
hexResult = (hexResult << 4) + tmp;
|
|
4621
|
+
} else {
|
|
4622
|
+
throwError(state, "expected hexadecimal character");
|
|
4623
|
+
}
|
|
4624
|
+
}
|
|
4625
|
+
state.result += charFromCodepoint(hexResult);
|
|
4626
|
+
state.position++;
|
|
4627
|
+
} else {
|
|
4628
|
+
throwError(state, "unknown escape sequence");
|
|
4629
|
+
}
|
|
4630
|
+
captureStart = captureEnd = state.position;
|
|
4631
|
+
} else if (is_EOL(ch)) {
|
|
4632
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
4633
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
4634
|
+
captureStart = captureEnd = state.position;
|
|
4635
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
4636
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
4637
|
+
} else {
|
|
4638
|
+
state.position++;
|
|
4639
|
+
captureEnd = state.position;
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
4643
|
+
}
|
|
4644
|
+
function readFlowCollection(state, nodeIndent) {
|
|
4645
|
+
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;
|
|
4646
|
+
ch = state.input.charCodeAt(state.position);
|
|
4647
|
+
if (ch === 91) {
|
|
4648
|
+
terminator = 93;
|
|
4649
|
+
isMapping = false;
|
|
4650
|
+
_result = [];
|
|
4651
|
+
} else if (ch === 123) {
|
|
4652
|
+
terminator = 125;
|
|
4653
|
+
isMapping = true;
|
|
4654
|
+
_result = {};
|
|
4655
|
+
} else {
|
|
4656
|
+
return false;
|
|
4657
|
+
}
|
|
4658
|
+
if (state.anchor !== null) {
|
|
4659
|
+
state.anchorMap[state.anchor] = _result;
|
|
4660
|
+
}
|
|
4661
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4662
|
+
while (ch !== 0) {
|
|
4663
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
4664
|
+
ch = state.input.charCodeAt(state.position);
|
|
4665
|
+
if (ch === terminator) {
|
|
4666
|
+
state.position++;
|
|
4667
|
+
state.tag = _tag;
|
|
4668
|
+
state.anchor = _anchor;
|
|
4669
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
4670
|
+
state.result = _result;
|
|
4671
|
+
return true;
|
|
4672
|
+
} else if (!readNext) {
|
|
4673
|
+
throwError(state, "missed comma between flow collection entries");
|
|
4674
|
+
} else if (ch === 44) {
|
|
4675
|
+
throwError(state, "expected the node content, but found ','");
|
|
4676
|
+
}
|
|
4677
|
+
keyTag = keyNode = valueNode = null;
|
|
4678
|
+
isPair = isExplicitPair = false;
|
|
4679
|
+
if (ch === 63) {
|
|
4680
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
4681
|
+
if (is_WS_OR_EOL(following)) {
|
|
4682
|
+
isPair = isExplicitPair = true;
|
|
4683
|
+
state.position++;
|
|
4684
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
4685
|
+
}
|
|
4686
|
+
}
|
|
4687
|
+
_line = state.line;
|
|
4688
|
+
_lineStart = state.lineStart;
|
|
4689
|
+
_pos = state.position;
|
|
4690
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
4691
|
+
keyTag = state.tag;
|
|
4692
|
+
keyNode = state.result;
|
|
4693
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
4694
|
+
ch = state.input.charCodeAt(state.position);
|
|
4695
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
4696
|
+
isPair = true;
|
|
4697
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4698
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
4699
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
4700
|
+
valueNode = state.result;
|
|
4701
|
+
}
|
|
4702
|
+
if (isMapping) {
|
|
4703
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
4704
|
+
} else if (isPair) {
|
|
4705
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
4706
|
+
} else {
|
|
4707
|
+
_result.push(keyNode);
|
|
4708
|
+
}
|
|
4709
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
4710
|
+
ch = state.input.charCodeAt(state.position);
|
|
4711
|
+
if (ch === 44) {
|
|
4712
|
+
readNext = true;
|
|
4713
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4714
|
+
} else {
|
|
4715
|
+
readNext = false;
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
4719
|
+
}
|
|
4720
|
+
function readBlockScalar(state, nodeIndent) {
|
|
4721
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
4722
|
+
ch = state.input.charCodeAt(state.position);
|
|
4723
|
+
if (ch === 124) {
|
|
4724
|
+
folding = false;
|
|
4725
|
+
} else if (ch === 62) {
|
|
4726
|
+
folding = true;
|
|
4727
|
+
} else {
|
|
4728
|
+
return false;
|
|
4729
|
+
}
|
|
4730
|
+
state.kind = "scalar";
|
|
4731
|
+
state.result = "";
|
|
4732
|
+
while (ch !== 0) {
|
|
4733
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4734
|
+
if (ch === 43 || ch === 45) {
|
|
4735
|
+
if (CHOMPING_CLIP === chomping) {
|
|
4736
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
4737
|
+
} else {
|
|
4738
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
4739
|
+
}
|
|
4740
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
4741
|
+
if (tmp === 0) {
|
|
4742
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
4743
|
+
} else if (!detectedIndent) {
|
|
4744
|
+
textIndent = nodeIndent + tmp - 1;
|
|
4745
|
+
detectedIndent = true;
|
|
4746
|
+
} else {
|
|
4747
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
4748
|
+
}
|
|
4749
|
+
} else {
|
|
4750
|
+
break;
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
if (is_WHITE_SPACE(ch)) {
|
|
4754
|
+
do {
|
|
4755
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4756
|
+
} while (is_WHITE_SPACE(ch));
|
|
4757
|
+
if (ch === 35) {
|
|
4758
|
+
do {
|
|
4759
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4760
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
4761
|
+
}
|
|
4762
|
+
}
|
|
4763
|
+
while (ch !== 0) {
|
|
4764
|
+
readLineBreak(state);
|
|
4765
|
+
state.lineIndent = 0;
|
|
4766
|
+
ch = state.input.charCodeAt(state.position);
|
|
4767
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
4768
|
+
state.lineIndent++;
|
|
4769
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4770
|
+
}
|
|
4771
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
4772
|
+
textIndent = state.lineIndent;
|
|
4773
|
+
}
|
|
4774
|
+
if (is_EOL(ch)) {
|
|
4775
|
+
emptyLines++;
|
|
4776
|
+
continue;
|
|
4777
|
+
}
|
|
4778
|
+
if (state.lineIndent < textIndent) {
|
|
4779
|
+
if (chomping === CHOMPING_KEEP) {
|
|
4780
|
+
state.result += common.repeat(`
|
|
4781
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
4782
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
4783
|
+
if (didReadContent) {
|
|
4784
|
+
state.result += `
|
|
4785
|
+
`;
|
|
4786
|
+
}
|
|
4787
|
+
}
|
|
4788
|
+
break;
|
|
4789
|
+
}
|
|
4790
|
+
if (folding) {
|
|
4791
|
+
if (is_WHITE_SPACE(ch)) {
|
|
4792
|
+
atMoreIndented = true;
|
|
4793
|
+
state.result += common.repeat(`
|
|
4794
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
4795
|
+
} else if (atMoreIndented) {
|
|
4796
|
+
atMoreIndented = false;
|
|
4797
|
+
state.result += common.repeat(`
|
|
4798
|
+
`, emptyLines + 1);
|
|
4799
|
+
} else if (emptyLines === 0) {
|
|
4800
|
+
if (didReadContent) {
|
|
4801
|
+
state.result += " ";
|
|
4802
|
+
}
|
|
4803
|
+
} else {
|
|
4804
|
+
state.result += common.repeat(`
|
|
4805
|
+
`, emptyLines);
|
|
4806
|
+
}
|
|
4807
|
+
} else {
|
|
4808
|
+
state.result += common.repeat(`
|
|
4809
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
4810
|
+
}
|
|
4811
|
+
didReadContent = true;
|
|
4812
|
+
detectedIndent = true;
|
|
4813
|
+
emptyLines = 0;
|
|
4814
|
+
captureStart = state.position;
|
|
4815
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
4816
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4817
|
+
}
|
|
4818
|
+
captureSegment(state, captureStart, state.position, false);
|
|
4819
|
+
}
|
|
4820
|
+
return true;
|
|
4821
|
+
}
|
|
4822
|
+
function readBlockSequence(state, nodeIndent) {
|
|
4823
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
4824
|
+
if (state.firstTabInLine !== -1)
|
|
4825
|
+
return false;
|
|
4826
|
+
if (state.anchor !== null) {
|
|
4827
|
+
state.anchorMap[state.anchor] = _result;
|
|
4828
|
+
}
|
|
4829
|
+
ch = state.input.charCodeAt(state.position);
|
|
4830
|
+
while (ch !== 0) {
|
|
4831
|
+
if (state.firstTabInLine !== -1) {
|
|
4832
|
+
state.position = state.firstTabInLine;
|
|
4833
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
4834
|
+
}
|
|
4835
|
+
if (ch !== 45) {
|
|
4836
|
+
break;
|
|
4837
|
+
}
|
|
4838
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
4839
|
+
if (!is_WS_OR_EOL(following)) {
|
|
4840
|
+
break;
|
|
4841
|
+
}
|
|
4842
|
+
detected = true;
|
|
4843
|
+
state.position++;
|
|
4844
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
4845
|
+
if (state.lineIndent <= nodeIndent) {
|
|
4846
|
+
_result.push(null);
|
|
4847
|
+
ch = state.input.charCodeAt(state.position);
|
|
4848
|
+
continue;
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
_line = state.line;
|
|
4852
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
4853
|
+
_result.push(state.result);
|
|
4854
|
+
skipSeparationSpace(state, true, -1);
|
|
4855
|
+
ch = state.input.charCodeAt(state.position);
|
|
4856
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
4857
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
4858
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
4859
|
+
break;
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
if (detected) {
|
|
4863
|
+
state.tag = _tag;
|
|
4864
|
+
state.anchor = _anchor;
|
|
4865
|
+
state.kind = "sequence";
|
|
4866
|
+
state.result = _result;
|
|
4867
|
+
return true;
|
|
4868
|
+
}
|
|
4869
|
+
return false;
|
|
4870
|
+
}
|
|
4871
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
4872
|
+
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;
|
|
4873
|
+
if (state.firstTabInLine !== -1)
|
|
4874
|
+
return false;
|
|
4875
|
+
if (state.anchor !== null) {
|
|
4876
|
+
state.anchorMap[state.anchor] = _result;
|
|
4877
|
+
}
|
|
4878
|
+
ch = state.input.charCodeAt(state.position);
|
|
4879
|
+
while (ch !== 0) {
|
|
4880
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
4881
|
+
state.position = state.firstTabInLine;
|
|
4882
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
4883
|
+
}
|
|
4884
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
4885
|
+
_line = state.line;
|
|
4886
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
4887
|
+
if (ch === 63) {
|
|
4888
|
+
if (atExplicitKey) {
|
|
4889
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
4890
|
+
keyTag = keyNode = valueNode = null;
|
|
4891
|
+
}
|
|
4892
|
+
detected = true;
|
|
4893
|
+
atExplicitKey = true;
|
|
4894
|
+
allowCompact = true;
|
|
4895
|
+
} else if (atExplicitKey) {
|
|
4896
|
+
atExplicitKey = false;
|
|
4897
|
+
allowCompact = true;
|
|
4898
|
+
} else {
|
|
4899
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
4900
|
+
}
|
|
4901
|
+
state.position += 1;
|
|
4902
|
+
ch = following;
|
|
4903
|
+
} else {
|
|
4904
|
+
_keyLine = state.line;
|
|
4905
|
+
_keyLineStart = state.lineStart;
|
|
4906
|
+
_keyPos = state.position;
|
|
4907
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
4908
|
+
break;
|
|
4909
|
+
}
|
|
4910
|
+
if (state.line === _line) {
|
|
4911
|
+
ch = state.input.charCodeAt(state.position);
|
|
4912
|
+
while (is_WHITE_SPACE(ch)) {
|
|
4913
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4914
|
+
}
|
|
4915
|
+
if (ch === 58) {
|
|
4916
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4917
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
4918
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
4919
|
+
}
|
|
4920
|
+
if (atExplicitKey) {
|
|
4921
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
4922
|
+
keyTag = keyNode = valueNode = null;
|
|
4923
|
+
}
|
|
4924
|
+
detected = true;
|
|
4925
|
+
atExplicitKey = false;
|
|
4926
|
+
allowCompact = false;
|
|
4927
|
+
keyTag = state.tag;
|
|
4928
|
+
keyNode = state.result;
|
|
4929
|
+
} else if (detected) {
|
|
4930
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
4931
|
+
} else {
|
|
4932
|
+
state.tag = _tag;
|
|
4933
|
+
state.anchor = _anchor;
|
|
4934
|
+
return true;
|
|
4935
|
+
}
|
|
4936
|
+
} else if (detected) {
|
|
4937
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
4938
|
+
} else {
|
|
4939
|
+
state.tag = _tag;
|
|
4940
|
+
state.anchor = _anchor;
|
|
4941
|
+
return true;
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
4945
|
+
if (atExplicitKey) {
|
|
4946
|
+
_keyLine = state.line;
|
|
4947
|
+
_keyLineStart = state.lineStart;
|
|
4948
|
+
_keyPos = state.position;
|
|
4949
|
+
}
|
|
4950
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
4951
|
+
if (atExplicitKey) {
|
|
4952
|
+
keyNode = state.result;
|
|
4953
|
+
} else {
|
|
4954
|
+
valueNode = state.result;
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
if (!atExplicitKey) {
|
|
4958
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
4959
|
+
keyTag = keyNode = valueNode = null;
|
|
4960
|
+
}
|
|
4961
|
+
skipSeparationSpace(state, true, -1);
|
|
4962
|
+
ch = state.input.charCodeAt(state.position);
|
|
4963
|
+
}
|
|
4964
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
4965
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
4966
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
4967
|
+
break;
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4970
|
+
if (atExplicitKey) {
|
|
4971
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
4972
|
+
}
|
|
4973
|
+
if (detected) {
|
|
4974
|
+
state.tag = _tag;
|
|
4975
|
+
state.anchor = _anchor;
|
|
4976
|
+
state.kind = "mapping";
|
|
4977
|
+
state.result = _result;
|
|
4978
|
+
}
|
|
4979
|
+
return detected;
|
|
4980
|
+
}
|
|
4981
|
+
function readTagProperty(state) {
|
|
4982
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
4983
|
+
ch = state.input.charCodeAt(state.position);
|
|
4984
|
+
if (ch !== 33)
|
|
4985
|
+
return false;
|
|
4986
|
+
if (state.tag !== null) {
|
|
4987
|
+
throwError(state, "duplication of a tag property");
|
|
4988
|
+
}
|
|
4989
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4990
|
+
if (ch === 60) {
|
|
4991
|
+
isVerbatim = true;
|
|
4992
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4993
|
+
} else if (ch === 33) {
|
|
4994
|
+
isNamed = true;
|
|
4995
|
+
tagHandle = "!!";
|
|
4996
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4997
|
+
} else {
|
|
4998
|
+
tagHandle = "!";
|
|
4999
|
+
}
|
|
5000
|
+
_position = state.position;
|
|
5001
|
+
if (isVerbatim) {
|
|
5002
|
+
do {
|
|
5003
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5004
|
+
} while (ch !== 0 && ch !== 62);
|
|
5005
|
+
if (state.position < state.length) {
|
|
5006
|
+
tagName = state.input.slice(_position, state.position);
|
|
5007
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5008
|
+
} else {
|
|
5009
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
5010
|
+
}
|
|
5011
|
+
} else {
|
|
5012
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
5013
|
+
if (ch === 33) {
|
|
5014
|
+
if (!isNamed) {
|
|
5015
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
5016
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
5017
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
5018
|
+
}
|
|
5019
|
+
isNamed = true;
|
|
5020
|
+
_position = state.position + 1;
|
|
5021
|
+
} else {
|
|
5022
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
5025
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5026
|
+
}
|
|
5027
|
+
tagName = state.input.slice(_position, state.position);
|
|
5028
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
5029
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
5030
|
+
}
|
|
5031
|
+
}
|
|
5032
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
5033
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
5034
|
+
}
|
|
5035
|
+
try {
|
|
5036
|
+
tagName = decodeURIComponent(tagName);
|
|
5037
|
+
} catch (err) {
|
|
5038
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
5039
|
+
}
|
|
5040
|
+
if (isVerbatim) {
|
|
5041
|
+
state.tag = tagName;
|
|
5042
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
5043
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
5044
|
+
} else if (tagHandle === "!") {
|
|
5045
|
+
state.tag = "!" + tagName;
|
|
5046
|
+
} else if (tagHandle === "!!") {
|
|
5047
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
5048
|
+
} else {
|
|
5049
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
5050
|
+
}
|
|
5051
|
+
return true;
|
|
5052
|
+
}
|
|
5053
|
+
function readAnchorProperty(state) {
|
|
5054
|
+
var _position, ch;
|
|
5055
|
+
ch = state.input.charCodeAt(state.position);
|
|
5056
|
+
if (ch !== 38)
|
|
5057
|
+
return false;
|
|
5058
|
+
if (state.anchor !== null) {
|
|
5059
|
+
throwError(state, "duplication of an anchor property");
|
|
5060
|
+
}
|
|
5061
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5062
|
+
_position = state.position;
|
|
5063
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
5064
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5065
|
+
}
|
|
5066
|
+
if (state.position === _position) {
|
|
5067
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
5068
|
+
}
|
|
5069
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
5070
|
+
return true;
|
|
5071
|
+
}
|
|
5072
|
+
function readAlias(state) {
|
|
5073
|
+
var _position, alias, ch;
|
|
5074
|
+
ch = state.input.charCodeAt(state.position);
|
|
5075
|
+
if (ch !== 42)
|
|
5076
|
+
return false;
|
|
5077
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5078
|
+
_position = state.position;
|
|
5079
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
5080
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5081
|
+
}
|
|
5082
|
+
if (state.position === _position) {
|
|
5083
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
5084
|
+
}
|
|
5085
|
+
alias = state.input.slice(_position, state.position);
|
|
5086
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
5087
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
5088
|
+
}
|
|
5089
|
+
state.result = state.anchorMap[alias];
|
|
5090
|
+
skipSeparationSpace(state, true, -1);
|
|
5091
|
+
return true;
|
|
5092
|
+
}
|
|
5093
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
5094
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
5095
|
+
if (state.listener !== null) {
|
|
5096
|
+
state.listener("open", state);
|
|
5097
|
+
}
|
|
5098
|
+
state.tag = null;
|
|
5099
|
+
state.anchor = null;
|
|
5100
|
+
state.kind = null;
|
|
5101
|
+
state.result = null;
|
|
5102
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
5103
|
+
if (allowToSeek) {
|
|
5104
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
5105
|
+
atNewLine = true;
|
|
5106
|
+
if (state.lineIndent > parentIndent) {
|
|
5107
|
+
indentStatus = 1;
|
|
5108
|
+
} else if (state.lineIndent === parentIndent) {
|
|
5109
|
+
indentStatus = 0;
|
|
5110
|
+
} else if (state.lineIndent < parentIndent) {
|
|
5111
|
+
indentStatus = -1;
|
|
5112
|
+
}
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
if (indentStatus === 1) {
|
|
5116
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
5117
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
5118
|
+
atNewLine = true;
|
|
5119
|
+
allowBlockCollections = allowBlockStyles;
|
|
5120
|
+
if (state.lineIndent > parentIndent) {
|
|
5121
|
+
indentStatus = 1;
|
|
5122
|
+
} else if (state.lineIndent === parentIndent) {
|
|
5123
|
+
indentStatus = 0;
|
|
5124
|
+
} else if (state.lineIndent < parentIndent) {
|
|
5125
|
+
indentStatus = -1;
|
|
5126
|
+
}
|
|
5127
|
+
} else {
|
|
5128
|
+
allowBlockCollections = false;
|
|
5129
|
+
}
|
|
5130
|
+
}
|
|
5131
|
+
}
|
|
5132
|
+
if (allowBlockCollections) {
|
|
5133
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
5134
|
+
}
|
|
5135
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
5136
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
5137
|
+
flowIndent = parentIndent;
|
|
5138
|
+
} else {
|
|
5139
|
+
flowIndent = parentIndent + 1;
|
|
5140
|
+
}
|
|
5141
|
+
blockIndent = state.position - state.lineStart;
|
|
5142
|
+
if (indentStatus === 1) {
|
|
5143
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
5144
|
+
hasContent = true;
|
|
5145
|
+
} else {
|
|
5146
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
5147
|
+
hasContent = true;
|
|
5148
|
+
} else if (readAlias(state)) {
|
|
5149
|
+
hasContent = true;
|
|
5150
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
5151
|
+
throwError(state, "alias node should not have any properties");
|
|
5152
|
+
}
|
|
5153
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
5154
|
+
hasContent = true;
|
|
5155
|
+
if (state.tag === null) {
|
|
5156
|
+
state.tag = "?";
|
|
5157
|
+
}
|
|
5158
|
+
}
|
|
5159
|
+
if (state.anchor !== null) {
|
|
5160
|
+
state.anchorMap[state.anchor] = state.result;
|
|
5161
|
+
}
|
|
5162
|
+
}
|
|
5163
|
+
} else if (indentStatus === 0) {
|
|
5164
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
5165
|
+
}
|
|
5166
|
+
}
|
|
5167
|
+
if (state.tag === null) {
|
|
5168
|
+
if (state.anchor !== null) {
|
|
5169
|
+
state.anchorMap[state.anchor] = state.result;
|
|
5170
|
+
}
|
|
5171
|
+
} else if (state.tag === "?") {
|
|
5172
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
5173
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
5174
|
+
}
|
|
5175
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
5176
|
+
type2 = state.implicitTypes[typeIndex];
|
|
5177
|
+
if (type2.resolve(state.result)) {
|
|
5178
|
+
state.result = type2.construct(state.result);
|
|
5179
|
+
state.tag = type2.tag;
|
|
5180
|
+
if (state.anchor !== null) {
|
|
5181
|
+
state.anchorMap[state.anchor] = state.result;
|
|
5182
|
+
}
|
|
5183
|
+
break;
|
|
5184
|
+
}
|
|
5185
|
+
}
|
|
5186
|
+
} else if (state.tag !== "!") {
|
|
5187
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
5188
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
5189
|
+
} else {
|
|
5190
|
+
type2 = null;
|
|
5191
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
5192
|
+
for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
5193
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
5194
|
+
type2 = typeList[typeIndex];
|
|
5195
|
+
break;
|
|
5196
|
+
}
|
|
5197
|
+
}
|
|
5198
|
+
}
|
|
5199
|
+
if (!type2) {
|
|
5200
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
5201
|
+
}
|
|
5202
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
5203
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
5204
|
+
}
|
|
5205
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
5206
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
5207
|
+
} else {
|
|
5208
|
+
state.result = type2.construct(state.result, state.tag);
|
|
5209
|
+
if (state.anchor !== null) {
|
|
5210
|
+
state.anchorMap[state.anchor] = state.result;
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
}
|
|
5214
|
+
if (state.listener !== null) {
|
|
5215
|
+
state.listener("close", state);
|
|
5216
|
+
}
|
|
5217
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
5218
|
+
}
|
|
5219
|
+
function readDocument(state) {
|
|
5220
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
5221
|
+
state.version = null;
|
|
5222
|
+
state.checkLineBreaks = state.legacy;
|
|
5223
|
+
state.tagMap = Object.create(null);
|
|
5224
|
+
state.anchorMap = Object.create(null);
|
|
5225
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
5226
|
+
skipSeparationSpace(state, true, -1);
|
|
5227
|
+
ch = state.input.charCodeAt(state.position);
|
|
5228
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
5229
|
+
break;
|
|
5230
|
+
}
|
|
5231
|
+
hasDirectives = true;
|
|
5232
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5233
|
+
_position = state.position;
|
|
5234
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
5235
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5236
|
+
}
|
|
5237
|
+
directiveName = state.input.slice(_position, state.position);
|
|
5238
|
+
directiveArgs = [];
|
|
5239
|
+
if (directiveName.length < 1) {
|
|
5240
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
5241
|
+
}
|
|
5242
|
+
while (ch !== 0) {
|
|
5243
|
+
while (is_WHITE_SPACE(ch)) {
|
|
5244
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5245
|
+
}
|
|
5246
|
+
if (ch === 35) {
|
|
5247
|
+
do {
|
|
5248
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5249
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
5250
|
+
break;
|
|
5251
|
+
}
|
|
5252
|
+
if (is_EOL(ch))
|
|
5253
|
+
break;
|
|
5254
|
+
_position = state.position;
|
|
5255
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
5256
|
+
ch = state.input.charCodeAt(++state.position);
|
|
5257
|
+
}
|
|
5258
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
5259
|
+
}
|
|
5260
|
+
if (ch !== 0)
|
|
5261
|
+
readLineBreak(state);
|
|
5262
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
5263
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
5264
|
+
} else {
|
|
5265
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
5266
|
+
}
|
|
5267
|
+
}
|
|
5268
|
+
skipSeparationSpace(state, true, -1);
|
|
5269
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
5270
|
+
state.position += 3;
|
|
5271
|
+
skipSeparationSpace(state, true, -1);
|
|
5272
|
+
} else if (hasDirectives) {
|
|
5273
|
+
throwError(state, "directives end mark is expected");
|
|
5274
|
+
}
|
|
5275
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
5276
|
+
skipSeparationSpace(state, true, -1);
|
|
5277
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
5278
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
5279
|
+
}
|
|
5280
|
+
state.documents.push(state.result);
|
|
5281
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
5282
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
5283
|
+
state.position += 3;
|
|
5284
|
+
skipSeparationSpace(state, true, -1);
|
|
5285
|
+
}
|
|
5286
|
+
return;
|
|
5287
|
+
}
|
|
5288
|
+
if (state.position < state.length - 1) {
|
|
5289
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
5290
|
+
} else {
|
|
5291
|
+
return;
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
function loadDocuments(input, options) {
|
|
5295
|
+
input = String(input);
|
|
5296
|
+
options = options || {};
|
|
5297
|
+
if (input.length !== 0) {
|
|
5298
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
5299
|
+
input += `
|
|
5300
|
+
`;
|
|
5301
|
+
}
|
|
5302
|
+
if (input.charCodeAt(0) === 65279) {
|
|
5303
|
+
input = input.slice(1);
|
|
5304
|
+
}
|
|
5305
|
+
}
|
|
5306
|
+
var state = new State$1(input, options);
|
|
5307
|
+
var nullpos = input.indexOf("\x00");
|
|
5308
|
+
if (nullpos !== -1) {
|
|
5309
|
+
state.position = nullpos;
|
|
5310
|
+
throwError(state, "null byte is not allowed in input");
|
|
5311
|
+
}
|
|
5312
|
+
state.input += "\x00";
|
|
5313
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
5314
|
+
state.lineIndent += 1;
|
|
5315
|
+
state.position += 1;
|
|
5316
|
+
}
|
|
5317
|
+
while (state.position < state.length - 1) {
|
|
5318
|
+
readDocument(state);
|
|
5319
|
+
}
|
|
5320
|
+
return state.documents;
|
|
5321
|
+
}
|
|
5322
|
+
function loadAll$1(input, iterator, options) {
|
|
5323
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
5324
|
+
options = iterator;
|
|
5325
|
+
iterator = null;
|
|
5326
|
+
}
|
|
5327
|
+
var documents = loadDocuments(input, options);
|
|
5328
|
+
if (typeof iterator !== "function") {
|
|
5329
|
+
return documents;
|
|
5330
|
+
}
|
|
5331
|
+
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
5332
|
+
iterator(documents[index]);
|
|
5333
|
+
}
|
|
5334
|
+
}
|
|
5335
|
+
function load$1(input, options) {
|
|
5336
|
+
var documents = loadDocuments(input, options);
|
|
5337
|
+
if (documents.length === 0) {
|
|
5338
|
+
return;
|
|
5339
|
+
} else if (documents.length === 1) {
|
|
5340
|
+
return documents[0];
|
|
5341
|
+
}
|
|
5342
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
5343
|
+
}
|
|
5344
|
+
var loadAll_1 = loadAll$1;
|
|
5345
|
+
var load_1 = load$1;
|
|
5346
|
+
var loader = {
|
|
5347
|
+
loadAll: loadAll_1,
|
|
5348
|
+
load: load_1
|
|
5349
|
+
};
|
|
5350
|
+
var _toString = Object.prototype.toString;
|
|
5351
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
5352
|
+
var CHAR_BOM = 65279;
|
|
5353
|
+
var CHAR_TAB = 9;
|
|
5354
|
+
var CHAR_LINE_FEED = 10;
|
|
5355
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
5356
|
+
var CHAR_SPACE = 32;
|
|
5357
|
+
var CHAR_EXCLAMATION = 33;
|
|
5358
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
5359
|
+
var CHAR_SHARP = 35;
|
|
5360
|
+
var CHAR_PERCENT = 37;
|
|
5361
|
+
var CHAR_AMPERSAND = 38;
|
|
5362
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
5363
|
+
var CHAR_ASTERISK = 42;
|
|
5364
|
+
var CHAR_COMMA = 44;
|
|
5365
|
+
var CHAR_MINUS = 45;
|
|
5366
|
+
var CHAR_COLON = 58;
|
|
5367
|
+
var CHAR_EQUALS = 61;
|
|
5368
|
+
var CHAR_GREATER_THAN = 62;
|
|
5369
|
+
var CHAR_QUESTION = 63;
|
|
5370
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
5371
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
5372
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
5373
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
5374
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
5375
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
5376
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
5377
|
+
var ESCAPE_SEQUENCES = {};
|
|
5378
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
5379
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
5380
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
5381
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
5382
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
5383
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
5384
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
5385
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
5386
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
5387
|
+
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
5388
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
5389
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
5390
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
5391
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
5392
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
5393
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
5394
|
+
"y",
|
|
5395
|
+
"Y",
|
|
5396
|
+
"yes",
|
|
5397
|
+
"Yes",
|
|
5398
|
+
"YES",
|
|
5399
|
+
"on",
|
|
5400
|
+
"On",
|
|
5401
|
+
"ON",
|
|
5402
|
+
"n",
|
|
5403
|
+
"N",
|
|
5404
|
+
"no",
|
|
5405
|
+
"No",
|
|
5406
|
+
"NO",
|
|
5407
|
+
"off",
|
|
5408
|
+
"Off",
|
|
5409
|
+
"OFF"
|
|
5410
|
+
];
|
|
5411
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
5412
|
+
function compileStyleMap(schema2, map2) {
|
|
5413
|
+
var result, keys, index, length, tag, style, type2;
|
|
5414
|
+
if (map2 === null)
|
|
5415
|
+
return {};
|
|
5416
|
+
result = {};
|
|
5417
|
+
keys = Object.keys(map2);
|
|
5418
|
+
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
5419
|
+
tag = keys[index];
|
|
5420
|
+
style = String(map2[tag]);
|
|
5421
|
+
if (tag.slice(0, 2) === "!!") {
|
|
5422
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
5423
|
+
}
|
|
5424
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
5425
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
5426
|
+
style = type2.styleAliases[style];
|
|
5427
|
+
}
|
|
5428
|
+
result[tag] = style;
|
|
5429
|
+
}
|
|
5430
|
+
return result;
|
|
5431
|
+
}
|
|
5432
|
+
function encodeHex(character) {
|
|
5433
|
+
var string, handle, length;
|
|
5434
|
+
string = character.toString(16).toUpperCase();
|
|
5435
|
+
if (character <= 255) {
|
|
5436
|
+
handle = "x";
|
|
5437
|
+
length = 2;
|
|
5438
|
+
} else if (character <= 65535) {
|
|
5439
|
+
handle = "u";
|
|
5440
|
+
length = 4;
|
|
5441
|
+
} else if (character <= 4294967295) {
|
|
5442
|
+
handle = "U";
|
|
5443
|
+
length = 8;
|
|
5444
|
+
} else {
|
|
5445
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
5446
|
+
}
|
|
5447
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
5448
|
+
}
|
|
5449
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
5450
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
5451
|
+
function State(options) {
|
|
5452
|
+
this.schema = options["schema"] || _default;
|
|
5453
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
5454
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
5455
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
5456
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
5457
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
5458
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
5459
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
5460
|
+
this.noRefs = options["noRefs"] || false;
|
|
5461
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
5462
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
5463
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
5464
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
5465
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
5466
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
5467
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
5468
|
+
this.tag = null;
|
|
5469
|
+
this.result = "";
|
|
5470
|
+
this.duplicates = [];
|
|
5471
|
+
this.usedDuplicates = null;
|
|
5472
|
+
}
|
|
5473
|
+
function indentString(string, spaces) {
|
|
5474
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
5475
|
+
while (position < length) {
|
|
5476
|
+
next = string.indexOf(`
|
|
5477
|
+
`, position);
|
|
5478
|
+
if (next === -1) {
|
|
5479
|
+
line = string.slice(position);
|
|
5480
|
+
position = length;
|
|
5481
|
+
} else {
|
|
5482
|
+
line = string.slice(position, next + 1);
|
|
5483
|
+
position = next + 1;
|
|
5484
|
+
}
|
|
5485
|
+
if (line.length && line !== `
|
|
5486
|
+
`)
|
|
5487
|
+
result += ind;
|
|
5488
|
+
result += line;
|
|
5489
|
+
}
|
|
5490
|
+
return result;
|
|
5491
|
+
}
|
|
5492
|
+
function generateNextLine(state, level) {
|
|
5493
|
+
return `
|
|
5494
|
+
` + common.repeat(" ", state.indent * level);
|
|
5495
|
+
}
|
|
5496
|
+
function testImplicitResolving(state, str2) {
|
|
5497
|
+
var index, length, type2;
|
|
5498
|
+
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
5499
|
+
type2 = state.implicitTypes[index];
|
|
5500
|
+
if (type2.resolve(str2)) {
|
|
5501
|
+
return true;
|
|
5502
|
+
}
|
|
5503
|
+
}
|
|
5504
|
+
return false;
|
|
5505
|
+
}
|
|
5506
|
+
function isWhitespace(c) {
|
|
5507
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
5508
|
+
}
|
|
5509
|
+
function isPrintable(c) {
|
|
5510
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
5511
|
+
}
|
|
5512
|
+
function isNsCharOrWhitespace(c) {
|
|
5513
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
5514
|
+
}
|
|
5515
|
+
function isPlainSafe(c, prev, inblock) {
|
|
5516
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
5517
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
5518
|
+
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;
|
|
5519
|
+
}
|
|
5520
|
+
function isPlainSafeFirst(c) {
|
|
5521
|
+
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;
|
|
5522
|
+
}
|
|
5523
|
+
function isPlainSafeLast(c) {
|
|
5524
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
5525
|
+
}
|
|
5526
|
+
function codePointAt(string, pos) {
|
|
5527
|
+
var first = string.charCodeAt(pos), second;
|
|
5528
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
5529
|
+
second = string.charCodeAt(pos + 1);
|
|
5530
|
+
if (second >= 56320 && second <= 57343) {
|
|
5531
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
5532
|
+
}
|
|
5533
|
+
}
|
|
5534
|
+
return first;
|
|
5535
|
+
}
|
|
5536
|
+
function needIndentIndicator(string) {
|
|
5537
|
+
var leadingSpaceRe = /^\n* /;
|
|
5538
|
+
return leadingSpaceRe.test(string);
|
|
5539
|
+
}
|
|
5540
|
+
var STYLE_PLAIN = 1;
|
|
5541
|
+
var STYLE_SINGLE = 2;
|
|
5542
|
+
var STYLE_LITERAL = 3;
|
|
5543
|
+
var STYLE_FOLDED = 4;
|
|
5544
|
+
var STYLE_DOUBLE = 5;
|
|
5545
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
5546
|
+
var i2;
|
|
5547
|
+
var char = 0;
|
|
5548
|
+
var prevChar = null;
|
|
5549
|
+
var hasLineBreak = false;
|
|
5550
|
+
var hasFoldableLine = false;
|
|
5551
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
5552
|
+
var previousLineBreak = -1;
|
|
5553
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
5554
|
+
if (singleLineOnly || forceQuotes) {
|
|
5555
|
+
for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
5556
|
+
char = codePointAt(string, i2);
|
|
5557
|
+
if (!isPrintable(char)) {
|
|
5558
|
+
return STYLE_DOUBLE;
|
|
5559
|
+
}
|
|
5560
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
5561
|
+
prevChar = char;
|
|
5562
|
+
}
|
|
5563
|
+
} else {
|
|
5564
|
+
for (i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
5565
|
+
char = codePointAt(string, i2);
|
|
5566
|
+
if (char === CHAR_LINE_FEED) {
|
|
5567
|
+
hasLineBreak = true;
|
|
5568
|
+
if (shouldTrackWidth) {
|
|
5569
|
+
hasFoldableLine = hasFoldableLine || i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
5570
|
+
previousLineBreak = i2;
|
|
5571
|
+
}
|
|
5572
|
+
} else if (!isPrintable(char)) {
|
|
5573
|
+
return STYLE_DOUBLE;
|
|
5574
|
+
}
|
|
5575
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
5576
|
+
prevChar = char;
|
|
5577
|
+
}
|
|
5578
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
5579
|
+
}
|
|
5580
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
5581
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
5582
|
+
return STYLE_PLAIN;
|
|
5583
|
+
}
|
|
5584
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
5585
|
+
}
|
|
5586
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
5587
|
+
return STYLE_DOUBLE;
|
|
5588
|
+
}
|
|
5589
|
+
if (!forceQuotes) {
|
|
5590
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
5591
|
+
}
|
|
5592
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
5593
|
+
}
|
|
5594
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
5595
|
+
state.dump = function() {
|
|
5596
|
+
if (string.length === 0) {
|
|
5597
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
5598
|
+
}
|
|
5599
|
+
if (!state.noCompatMode) {
|
|
5600
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
5601
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
5602
|
+
}
|
|
5603
|
+
}
|
|
5604
|
+
var indent = state.indent * Math.max(1, level);
|
|
5605
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
5606
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
5607
|
+
function testAmbiguity(string2) {
|
|
5608
|
+
return testImplicitResolving(state, string2);
|
|
5609
|
+
}
|
|
5610
|
+
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
5611
|
+
case STYLE_PLAIN:
|
|
5612
|
+
return string;
|
|
5613
|
+
case STYLE_SINGLE:
|
|
5614
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
5615
|
+
case STYLE_LITERAL:
|
|
5616
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
5617
|
+
case STYLE_FOLDED:
|
|
5618
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
5619
|
+
case STYLE_DOUBLE:
|
|
5620
|
+
return '"' + escapeString(string) + '"';
|
|
5621
|
+
default:
|
|
5622
|
+
throw new exception("impossible error: invalid scalar style");
|
|
5623
|
+
}
|
|
5624
|
+
}();
|
|
5625
|
+
}
|
|
5626
|
+
function blockHeader(string, indentPerLevel) {
|
|
5627
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
5628
|
+
var clip = string[string.length - 1] === `
|
|
5629
|
+
`;
|
|
5630
|
+
var keep = clip && (string[string.length - 2] === `
|
|
5631
|
+
` || string === `
|
|
5632
|
+
`);
|
|
5633
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
5634
|
+
return indentIndicator + chomp + `
|
|
5635
|
+
`;
|
|
5636
|
+
}
|
|
5637
|
+
function dropEndingNewline(string) {
|
|
5638
|
+
return string[string.length - 1] === `
|
|
5639
|
+
` ? string.slice(0, -1) : string;
|
|
5640
|
+
}
|
|
5641
|
+
function foldString(string, width) {
|
|
5642
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
5643
|
+
var result = function() {
|
|
5644
|
+
var nextLF = string.indexOf(`
|
|
5645
|
+
`);
|
|
5646
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
5647
|
+
lineRe.lastIndex = nextLF;
|
|
5648
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
5649
|
+
}();
|
|
5650
|
+
var prevMoreIndented = string[0] === `
|
|
5651
|
+
` || string[0] === " ";
|
|
5652
|
+
var moreIndented;
|
|
5653
|
+
var match;
|
|
5654
|
+
while (match = lineRe.exec(string)) {
|
|
5655
|
+
var prefix = match[1], line = match[2];
|
|
5656
|
+
moreIndented = line[0] === " ";
|
|
5657
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
5658
|
+
` : "") + foldLine(line, width);
|
|
5659
|
+
prevMoreIndented = moreIndented;
|
|
5660
|
+
}
|
|
5661
|
+
return result;
|
|
5662
|
+
}
|
|
5663
|
+
function foldLine(line, width) {
|
|
5664
|
+
if (line === "" || line[0] === " ")
|
|
5665
|
+
return line;
|
|
5666
|
+
var breakRe = / [^ ]/g;
|
|
5667
|
+
var match;
|
|
5668
|
+
var start = 0, end, curr = 0, next = 0;
|
|
5669
|
+
var result = "";
|
|
5670
|
+
while (match = breakRe.exec(line)) {
|
|
5671
|
+
next = match.index;
|
|
5672
|
+
if (next - start > width) {
|
|
5673
|
+
end = curr > start ? curr : next;
|
|
5674
|
+
result += `
|
|
5675
|
+
` + line.slice(start, end);
|
|
5676
|
+
start = end + 1;
|
|
5677
|
+
}
|
|
5678
|
+
curr = next;
|
|
5679
|
+
}
|
|
5680
|
+
result += `
|
|
5681
|
+
`;
|
|
5682
|
+
if (line.length - start > width && curr > start) {
|
|
5683
|
+
result += line.slice(start, curr) + `
|
|
5684
|
+
` + line.slice(curr + 1);
|
|
5685
|
+
} else {
|
|
5686
|
+
result += line.slice(start);
|
|
5687
|
+
}
|
|
5688
|
+
return result.slice(1);
|
|
5689
|
+
}
|
|
5690
|
+
function escapeString(string) {
|
|
5691
|
+
var result = "";
|
|
5692
|
+
var char = 0;
|
|
5693
|
+
var escapeSeq;
|
|
5694
|
+
for (var i2 = 0;i2 < string.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
5695
|
+
char = codePointAt(string, i2);
|
|
5696
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
5697
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
5698
|
+
result += string[i2];
|
|
5699
|
+
if (char >= 65536)
|
|
5700
|
+
result += string[i2 + 1];
|
|
5701
|
+
} else {
|
|
5702
|
+
result += escapeSeq || encodeHex(char);
|
|
5703
|
+
}
|
|
5704
|
+
}
|
|
5705
|
+
return result;
|
|
5706
|
+
}
|
|
5707
|
+
function writeFlowSequence(state, level, object) {
|
|
5708
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
5709
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
5710
|
+
value = object[index];
|
|
5711
|
+
if (state.replacer) {
|
|
5712
|
+
value = state.replacer.call(object, String(index), value);
|
|
5713
|
+
}
|
|
5714
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
5715
|
+
if (_result !== "")
|
|
5716
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
5717
|
+
_result += state.dump;
|
|
5718
|
+
}
|
|
5719
|
+
}
|
|
5720
|
+
state.tag = _tag;
|
|
5721
|
+
state.dump = "[" + _result + "]";
|
|
5722
|
+
}
|
|
5723
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
5724
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
5725
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
5726
|
+
value = object[index];
|
|
5727
|
+
if (state.replacer) {
|
|
5728
|
+
value = state.replacer.call(object, String(index), value);
|
|
5729
|
+
}
|
|
5730
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
5731
|
+
if (!compact || _result !== "") {
|
|
5732
|
+
_result += generateNextLine(state, level);
|
|
5733
|
+
}
|
|
5734
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
5735
|
+
_result += "-";
|
|
5736
|
+
} else {
|
|
5737
|
+
_result += "- ";
|
|
5738
|
+
}
|
|
5739
|
+
_result += state.dump;
|
|
5740
|
+
}
|
|
5741
|
+
}
|
|
5742
|
+
state.tag = _tag;
|
|
5743
|
+
state.dump = _result || "[]";
|
|
5744
|
+
}
|
|
5745
|
+
function writeFlowMapping(state, level, object) {
|
|
5746
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
5747
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
5748
|
+
pairBuffer = "";
|
|
5749
|
+
if (_result !== "")
|
|
5750
|
+
pairBuffer += ", ";
|
|
5751
|
+
if (state.condenseFlow)
|
|
5752
|
+
pairBuffer += '"';
|
|
5753
|
+
objectKey = objectKeyList[index];
|
|
5754
|
+
objectValue = object[objectKey];
|
|
5755
|
+
if (state.replacer) {
|
|
5756
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
5757
|
+
}
|
|
5758
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
5759
|
+
continue;
|
|
5760
|
+
}
|
|
5761
|
+
if (state.dump.length > 1024)
|
|
5762
|
+
pairBuffer += "? ";
|
|
5763
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
5764
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
5765
|
+
continue;
|
|
5766
|
+
}
|
|
5767
|
+
pairBuffer += state.dump;
|
|
5768
|
+
_result += pairBuffer;
|
|
5769
|
+
}
|
|
5770
|
+
state.tag = _tag;
|
|
5771
|
+
state.dump = "{" + _result + "}";
|
|
5772
|
+
}
|
|
5773
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
5774
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
5775
|
+
if (state.sortKeys === true) {
|
|
5776
|
+
objectKeyList.sort();
|
|
5777
|
+
} else if (typeof state.sortKeys === "function") {
|
|
5778
|
+
objectKeyList.sort(state.sortKeys);
|
|
5779
|
+
} else if (state.sortKeys) {
|
|
5780
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
5781
|
+
}
|
|
5782
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
5783
|
+
pairBuffer = "";
|
|
5784
|
+
if (!compact || _result !== "") {
|
|
5785
|
+
pairBuffer += generateNextLine(state, level);
|
|
5786
|
+
}
|
|
5787
|
+
objectKey = objectKeyList[index];
|
|
5788
|
+
objectValue = object[objectKey];
|
|
5789
|
+
if (state.replacer) {
|
|
5790
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
5791
|
+
}
|
|
5792
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
5793
|
+
continue;
|
|
5794
|
+
}
|
|
5795
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
5796
|
+
if (explicitPair) {
|
|
5797
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
5798
|
+
pairBuffer += "?";
|
|
5799
|
+
} else {
|
|
5800
|
+
pairBuffer += "? ";
|
|
5801
|
+
}
|
|
5802
|
+
}
|
|
5803
|
+
pairBuffer += state.dump;
|
|
5804
|
+
if (explicitPair) {
|
|
5805
|
+
pairBuffer += generateNextLine(state, level);
|
|
5806
|
+
}
|
|
5807
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
5808
|
+
continue;
|
|
5809
|
+
}
|
|
5810
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
5811
|
+
pairBuffer += ":";
|
|
5812
|
+
} else {
|
|
5813
|
+
pairBuffer += ": ";
|
|
5814
|
+
}
|
|
5815
|
+
pairBuffer += state.dump;
|
|
5816
|
+
_result += pairBuffer;
|
|
5817
|
+
}
|
|
5818
|
+
state.tag = _tag;
|
|
5819
|
+
state.dump = _result || "{}";
|
|
5820
|
+
}
|
|
5821
|
+
function detectType(state, object, explicit) {
|
|
5822
|
+
var _result, typeList, index, length, type2, style;
|
|
5823
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
5824
|
+
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
5825
|
+
type2 = typeList[index];
|
|
5826
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
5827
|
+
if (explicit) {
|
|
5828
|
+
if (type2.multi && type2.representName) {
|
|
5829
|
+
state.tag = type2.representName(object);
|
|
5830
|
+
} else {
|
|
5831
|
+
state.tag = type2.tag;
|
|
5832
|
+
}
|
|
5833
|
+
} else {
|
|
5834
|
+
state.tag = "?";
|
|
5835
|
+
}
|
|
5836
|
+
if (type2.represent) {
|
|
5837
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
5838
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
5839
|
+
_result = type2.represent(object, style);
|
|
5840
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
5841
|
+
_result = type2.represent[style](object, style);
|
|
5842
|
+
} else {
|
|
5843
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
5844
|
+
}
|
|
5845
|
+
state.dump = _result;
|
|
5846
|
+
}
|
|
5847
|
+
return true;
|
|
5848
|
+
}
|
|
5849
|
+
}
|
|
5850
|
+
return false;
|
|
5851
|
+
}
|
|
5852
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
5853
|
+
state.tag = null;
|
|
5854
|
+
state.dump = object;
|
|
5855
|
+
if (!detectType(state, object, false)) {
|
|
5856
|
+
detectType(state, object, true);
|
|
5857
|
+
}
|
|
5858
|
+
var type2 = _toString.call(state.dump);
|
|
5859
|
+
var inblock = block;
|
|
5860
|
+
var tagStr;
|
|
5861
|
+
if (block) {
|
|
5862
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
5863
|
+
}
|
|
5864
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
5865
|
+
if (objectOrArray) {
|
|
5866
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
5867
|
+
duplicate = duplicateIndex !== -1;
|
|
5868
|
+
}
|
|
5869
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
5870
|
+
compact = false;
|
|
5871
|
+
}
|
|
5872
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
5873
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
5874
|
+
} else {
|
|
5875
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
5876
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
5877
|
+
}
|
|
5878
|
+
if (type2 === "[object Object]") {
|
|
5879
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
5880
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
5881
|
+
if (duplicate) {
|
|
5882
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
5883
|
+
}
|
|
5884
|
+
} else {
|
|
5885
|
+
writeFlowMapping(state, level, state.dump);
|
|
5886
|
+
if (duplicate) {
|
|
5887
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
5888
|
+
}
|
|
5889
|
+
}
|
|
5890
|
+
} else if (type2 === "[object Array]") {
|
|
5891
|
+
if (block && state.dump.length !== 0) {
|
|
5892
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
5893
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
5894
|
+
} else {
|
|
5895
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
5896
|
+
}
|
|
5897
|
+
if (duplicate) {
|
|
5898
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
5899
|
+
}
|
|
5900
|
+
} else {
|
|
5901
|
+
writeFlowSequence(state, level, state.dump);
|
|
5902
|
+
if (duplicate) {
|
|
5903
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
5904
|
+
}
|
|
5905
|
+
}
|
|
5906
|
+
} else if (type2 === "[object String]") {
|
|
5907
|
+
if (state.tag !== "?") {
|
|
5908
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
5909
|
+
}
|
|
5910
|
+
} else if (type2 === "[object Undefined]") {
|
|
5911
|
+
return false;
|
|
5912
|
+
} else {
|
|
5913
|
+
if (state.skipInvalid)
|
|
5914
|
+
return false;
|
|
5915
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
5916
|
+
}
|
|
5917
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
5918
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
5919
|
+
if (state.tag[0] === "!") {
|
|
5920
|
+
tagStr = "!" + tagStr;
|
|
5921
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
5922
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
5923
|
+
} else {
|
|
5924
|
+
tagStr = "!<" + tagStr + ">";
|
|
5925
|
+
}
|
|
5926
|
+
state.dump = tagStr + " " + state.dump;
|
|
5927
|
+
}
|
|
5928
|
+
}
|
|
5929
|
+
return true;
|
|
5930
|
+
}
|
|
5931
|
+
function getDuplicateReferences(object, state) {
|
|
5932
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
5933
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
5934
|
+
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
5935
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
5936
|
+
}
|
|
5937
|
+
state.usedDuplicates = new Array(length);
|
|
5938
|
+
}
|
|
5939
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
5940
|
+
var objectKeyList, index, length;
|
|
5941
|
+
if (object !== null && typeof object === "object") {
|
|
5942
|
+
index = objects.indexOf(object);
|
|
5943
|
+
if (index !== -1) {
|
|
5944
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
5945
|
+
duplicatesIndexes.push(index);
|
|
5946
|
+
}
|
|
5947
|
+
} else {
|
|
5948
|
+
objects.push(object);
|
|
5949
|
+
if (Array.isArray(object)) {
|
|
5950
|
+
for (index = 0, length = object.length;index < length; index += 1) {
|
|
5951
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
5952
|
+
}
|
|
5953
|
+
} else {
|
|
5954
|
+
objectKeyList = Object.keys(object);
|
|
5955
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
5956
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
5957
|
+
}
|
|
5958
|
+
}
|
|
5959
|
+
}
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
5962
|
+
function dump$1(input, options) {
|
|
5963
|
+
options = options || {};
|
|
5964
|
+
var state = new State(options);
|
|
5965
|
+
if (!state.noRefs)
|
|
5966
|
+
getDuplicateReferences(input, state);
|
|
5967
|
+
var value = input;
|
|
5968
|
+
if (state.replacer) {
|
|
5969
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
5970
|
+
}
|
|
5971
|
+
if (writeNode(state, 0, value, true, true))
|
|
5972
|
+
return state.dump + `
|
|
5973
|
+
`;
|
|
5974
|
+
return "";
|
|
5975
|
+
}
|
|
5976
|
+
var dump_1 = dump$1;
|
|
5977
|
+
var dumper = {
|
|
5978
|
+
dump: dump_1
|
|
5979
|
+
};
|
|
5980
|
+
function renamed(from, to) {
|
|
5981
|
+
return function() {
|
|
5982
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
|
|
5983
|
+
};
|
|
5984
|
+
}
|
|
5985
|
+
var load = loader.load;
|
|
5986
|
+
var loadAll = loader.loadAll;
|
|
5987
|
+
var dump = dumper.dump;
|
|
5988
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
5989
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
5990
|
+
var safeDump = renamed("safeDump", "dump");
|
|
3344
5991
|
// src/shared/command-executor.ts
|
|
3345
5992
|
import { exec } from "child_process";
|
|
3346
5993
|
import { promisify } from "util";
|
|
@@ -3352,8 +5999,8 @@ import * as path from "path";
|
|
|
3352
5999
|
var logFile = path.join(os.tmpdir(), "oh-my-opencode.log");
|
|
3353
6000
|
function log(message, data) {
|
|
3354
6001
|
try {
|
|
3355
|
-
const
|
|
3356
|
-
const logEntry = `[${
|
|
6002
|
+
const timestamp2 = new Date().toISOString();
|
|
6003
|
+
const logEntry = `[${timestamp2}] ${message} ${data ? JSON.stringify(data) : ""}
|
|
3357
6004
|
`;
|
|
3358
6005
|
fs.appendFileSync(logFile, logEntry);
|
|
3359
6006
|
} catch {}
|
|
@@ -4464,16 +7111,16 @@ function writeOmoConfig(installConfig) {
|
|
|
4464
7111
|
}
|
|
4465
7112
|
}
|
|
4466
7113
|
async function findOpenCodeBinaryWithVersion() {
|
|
4467
|
-
for (const
|
|
7114
|
+
for (const binary2 of OPENCODE_BINARIES) {
|
|
4468
7115
|
try {
|
|
4469
|
-
const proc = Bun.spawn([
|
|
7116
|
+
const proc = Bun.spawn([binary2, "--version"], {
|
|
4470
7117
|
stdout: "pipe",
|
|
4471
7118
|
stderr: "pipe"
|
|
4472
7119
|
});
|
|
4473
7120
|
const output = await new Response(proc.stdout).text();
|
|
4474
7121
|
await proc.exited;
|
|
4475
7122
|
if (proc.exitCode === 0) {
|
|
4476
|
-
return { binary, version: output.trim() };
|
|
7123
|
+
return { binary: binary2, version: output.trim() };
|
|
4477
7124
|
}
|
|
4478
7125
|
} catch {
|
|
4479
7126
|
continue;
|
|
@@ -5018,6 +7665,12 @@ async function runNonTuiInstall(args) {
|
|
|
5018
7665
|
console.log(`${SYMBOLS.star} ${import_picocolors2.default.bold(import_picocolors2.default.green(isUpdate ? "Configuration updated!" : "Installation complete!"))}`);
|
|
5019
7666
|
console.log(` Run ${import_picocolors2.default.cyan("opencode")} to start!`);
|
|
5020
7667
|
console.log();
|
|
7668
|
+
printBox(`${import_picocolors2.default.bold("Pro Tip:")} Include ${import_picocolors2.default.cyan("ultrawork")} (or ${import_picocolors2.default.cyan("ulw")}) in your prompt.
|
|
7669
|
+
` + `All features work like magic\u2014parallel agents, background tasks,
|
|
7670
|
+
` + `deep exploration, and relentless execution until completion.`, "\uD83E\uDE84 The Magic Word");
|
|
7671
|
+
console.log(`${SYMBOLS.star} ${import_picocolors2.default.yellow("If you found this helpful, consider starring the repo!")}`);
|
|
7672
|
+
console.log(` ${import_picocolors2.default.dim("gh repo star code-yeongyu/oh-my-opencode")}`);
|
|
7673
|
+
console.log();
|
|
5021
7674
|
console.log(import_picocolors2.default.dim("oMoMoMoMo... Enjoy!"));
|
|
5022
7675
|
console.log();
|
|
5023
7676
|
return 0;
|
|
@@ -5119,6 +7772,11 @@ async function install(args) {
|
|
|
5119
7772
|
}
|
|
5120
7773
|
M2.success(import_picocolors2.default.bold(isUpdate ? "Configuration updated!" : "Installation complete!"));
|
|
5121
7774
|
M2.message(`Run ${import_picocolors2.default.cyan("opencode")} to start!`);
|
|
7775
|
+
Me(`Include ${import_picocolors2.default.cyan("ultrawork")} (or ${import_picocolors2.default.cyan("ulw")}) in your prompt.
|
|
7776
|
+
` + `All features work like magic\u2014parallel agents, background tasks,
|
|
7777
|
+
` + `deep exploration, and relentless execution until completion.`, "\uD83E\uDE84 The Magic Word");
|
|
7778
|
+
M2.message(`${import_picocolors2.default.yellow("\u2605")} If you found this helpful, consider starring the repo!`);
|
|
7779
|
+
M2.message(` ${import_picocolors2.default.dim("gh repo star code-yeongyu/oh-my-opencode")}`);
|
|
5122
7780
|
Se(import_picocolors2.default.green("oMoMoMoMo... Enjoy!"));
|
|
5123
7781
|
return 0;
|
|
5124
7782
|
}
|
|
@@ -5483,7 +8141,7 @@ var getParseAs = (contentType) => {
|
|
|
5483
8141
|
if (cleanContent === "multipart/form-data") {
|
|
5484
8142
|
return "formData";
|
|
5485
8143
|
}
|
|
5486
|
-
if (["application/", "audio/", "image/", "video/"].some((
|
|
8144
|
+
if (["application/", "audio/", "image/", "video/"].some((type2) => cleanContent.startsWith(type2))) {
|
|
5487
8145
|
return "blob";
|
|
5488
8146
|
}
|
|
5489
8147
|
if (cleanContent.startsWith("text/")) {
|
|
@@ -6918,13 +9576,14 @@ All tasks completed.`));
|
|
|
6918
9576
|
}
|
|
6919
9577
|
}
|
|
6920
9578
|
// src/hooks/auto-update-checker/checker.ts
|
|
6921
|
-
import * as
|
|
9579
|
+
import * as fs3 from "fs";
|
|
6922
9580
|
import * as path3 from "path";
|
|
6923
9581
|
import { fileURLToPath } from "url";
|
|
6924
9582
|
|
|
6925
9583
|
// src/hooks/auto-update-checker/constants.ts
|
|
6926
9584
|
import * as path2 from "path";
|
|
6927
9585
|
import * as os2 from "os";
|
|
9586
|
+
import * as fs2 from "fs";
|
|
6928
9587
|
var PACKAGE_NAME = "oh-my-opencode";
|
|
6929
9588
|
var NPM_REGISTRY_URL = `https://registry.npmjs.org/-/package/${PACKAGE_NAME}/dist-tags`;
|
|
6930
9589
|
var NPM_FETCH_TIMEOUT = 5000;
|
|
@@ -6939,35 +9598,64 @@ var VERSION_FILE = path2.join(CACHE_DIR, "version");
|
|
|
6939
9598
|
var INSTALLED_PACKAGE_JSON = path2.join(CACHE_DIR, "node_modules", PACKAGE_NAME, "package.json");
|
|
6940
9599
|
function getUserConfigDir() {
|
|
6941
9600
|
if (process.platform === "win32") {
|
|
6942
|
-
|
|
9601
|
+
const crossPlatformDir = path2.join(os2.homedir(), ".config");
|
|
9602
|
+
const appdataDir = process.env.APPDATA ?? path2.join(os2.homedir(), "AppData", "Roaming");
|
|
9603
|
+
const crossPlatformConfig = path2.join(crossPlatformDir, "opencode", "opencode.json");
|
|
9604
|
+
const crossPlatformConfigJsonc = path2.join(crossPlatformDir, "opencode", "opencode.jsonc");
|
|
9605
|
+
if (fs2.existsSync(crossPlatformConfig) || fs2.existsSync(crossPlatformConfigJsonc)) {
|
|
9606
|
+
return crossPlatformDir;
|
|
9607
|
+
}
|
|
9608
|
+
return appdataDir;
|
|
6943
9609
|
}
|
|
6944
9610
|
return process.env.XDG_CONFIG_HOME ?? path2.join(os2.homedir(), ".config");
|
|
6945
9611
|
}
|
|
9612
|
+
function getWindowsAppdataDir() {
|
|
9613
|
+
if (process.platform !== "win32")
|
|
9614
|
+
return null;
|
|
9615
|
+
return process.env.APPDATA ?? path2.join(os2.homedir(), "AppData", "Roaming");
|
|
9616
|
+
}
|
|
6946
9617
|
var USER_CONFIG_DIR = getUserConfigDir();
|
|
6947
9618
|
var USER_OPENCODE_CONFIG = path2.join(USER_CONFIG_DIR, "opencode", "opencode.json");
|
|
6948
9619
|
var USER_OPENCODE_CONFIG_JSONC = path2.join(USER_CONFIG_DIR, "opencode", "opencode.jsonc");
|
|
6949
9620
|
|
|
6950
9621
|
// src/hooks/auto-update-checker/checker.ts
|
|
9622
|
+
import * as os3 from "os";
|
|
6951
9623
|
function isLocalDevMode(directory) {
|
|
6952
9624
|
return getLocalDevPath(directory) !== null;
|
|
6953
9625
|
}
|
|
6954
|
-
function stripJsonComments(
|
|
6955
|
-
return
|
|
9626
|
+
function stripJsonComments(json2) {
|
|
9627
|
+
return json2.replace(/\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g, (m2, g2) => g2 ? "" : m2).replace(/,(\s*[}\]])/g, "$1");
|
|
6956
9628
|
}
|
|
6957
9629
|
function getConfigPaths(directory) {
|
|
6958
|
-
|
|
9630
|
+
const paths = [
|
|
6959
9631
|
path3.join(directory, ".opencode", "opencode.json"),
|
|
6960
9632
|
path3.join(directory, ".opencode", "opencode.jsonc"),
|
|
6961
9633
|
USER_OPENCODE_CONFIG,
|
|
6962
9634
|
USER_OPENCODE_CONFIG_JSONC
|
|
6963
9635
|
];
|
|
9636
|
+
if (process.platform === "win32") {
|
|
9637
|
+
const crossPlatformDir = path3.join(os3.homedir(), ".config");
|
|
9638
|
+
const appdataDir = getWindowsAppdataDir();
|
|
9639
|
+
if (appdataDir) {
|
|
9640
|
+
const alternateDir = USER_CONFIG_DIR === crossPlatformDir ? appdataDir : crossPlatformDir;
|
|
9641
|
+
const alternateConfig = path3.join(alternateDir, "opencode", "opencode.json");
|
|
9642
|
+
const alternateConfigJsonc = path3.join(alternateDir, "opencode", "opencode.jsonc");
|
|
9643
|
+
if (!paths.includes(alternateConfig)) {
|
|
9644
|
+
paths.push(alternateConfig);
|
|
9645
|
+
}
|
|
9646
|
+
if (!paths.includes(alternateConfigJsonc)) {
|
|
9647
|
+
paths.push(alternateConfigJsonc);
|
|
9648
|
+
}
|
|
9649
|
+
}
|
|
9650
|
+
}
|
|
9651
|
+
return paths;
|
|
6964
9652
|
}
|
|
6965
9653
|
function getLocalDevPath(directory) {
|
|
6966
9654
|
for (const configPath of getConfigPaths(directory)) {
|
|
6967
9655
|
try {
|
|
6968
|
-
if (!
|
|
9656
|
+
if (!fs3.existsSync(configPath))
|
|
6969
9657
|
continue;
|
|
6970
|
-
const content =
|
|
9658
|
+
const content = fs3.readFileSync(configPath, "utf-8");
|
|
6971
9659
|
const config = JSON.parse(stripJsonComments(content));
|
|
6972
9660
|
const plugins = config.plugin ?? [];
|
|
6973
9661
|
for (const entry of plugins) {
|
|
@@ -6987,13 +9675,13 @@ function getLocalDevPath(directory) {
|
|
|
6987
9675
|
}
|
|
6988
9676
|
function findPackageJsonUp(startPath) {
|
|
6989
9677
|
try {
|
|
6990
|
-
const stat =
|
|
9678
|
+
const stat = fs3.statSync(startPath);
|
|
6991
9679
|
let dir = stat.isDirectory() ? startPath : path3.dirname(startPath);
|
|
6992
|
-
for (let
|
|
9680
|
+
for (let i2 = 0;i2 < 10; i2++) {
|
|
6993
9681
|
const pkgPath = path3.join(dir, "package.json");
|
|
6994
|
-
if (
|
|
9682
|
+
if (fs3.existsSync(pkgPath)) {
|
|
6995
9683
|
try {
|
|
6996
|
-
const content =
|
|
9684
|
+
const content = fs3.readFileSync(pkgPath, "utf-8");
|
|
6997
9685
|
const pkg = JSON.parse(content);
|
|
6998
9686
|
if (pkg.name === PACKAGE_NAME)
|
|
6999
9687
|
return pkgPath;
|
|
@@ -7010,9 +9698,9 @@ function findPackageJsonUp(startPath) {
|
|
|
7010
9698
|
function findPluginEntry(directory) {
|
|
7011
9699
|
for (const configPath of getConfigPaths(directory)) {
|
|
7012
9700
|
try {
|
|
7013
|
-
if (!
|
|
9701
|
+
if (!fs3.existsSync(configPath))
|
|
7014
9702
|
continue;
|
|
7015
|
-
const content =
|
|
9703
|
+
const content = fs3.readFileSync(configPath, "utf-8");
|
|
7016
9704
|
const config = JSON.parse(stripJsonComments(content));
|
|
7017
9705
|
const plugins = config.plugin ?? [];
|
|
7018
9706
|
for (const entry of plugins) {
|
|
@@ -7033,8 +9721,8 @@ function findPluginEntry(directory) {
|
|
|
7033
9721
|
}
|
|
7034
9722
|
function getCachedVersion() {
|
|
7035
9723
|
try {
|
|
7036
|
-
if (
|
|
7037
|
-
const content =
|
|
9724
|
+
if (fs3.existsSync(INSTALLED_PACKAGE_JSON)) {
|
|
9725
|
+
const content = fs3.readFileSync(INSTALLED_PACKAGE_JSON, "utf-8");
|
|
7038
9726
|
const pkg = JSON.parse(content);
|
|
7039
9727
|
if (pkg.version)
|
|
7040
9728
|
return pkg.version;
|
|
@@ -7044,7 +9732,7 @@ function getCachedVersion() {
|
|
|
7044
9732
|
const currentDir = path3.dirname(fileURLToPath(import.meta.url));
|
|
7045
9733
|
const pkgPath = findPackageJsonUp(currentDir);
|
|
7046
9734
|
if (pkgPath) {
|
|
7047
|
-
const content =
|
|
9735
|
+
const content = fs3.readFileSync(pkgPath, "utf-8");
|
|
7048
9736
|
const pkg = JSON.parse(content);
|
|
7049
9737
|
if (pkg.version)
|
|
7050
9738
|
return pkg.version;
|
|
@@ -7285,13 +9973,13 @@ var OPENCODE_BINARIES2 = ["opencode", "opencode-desktop"];
|
|
|
7285
9973
|
|
|
7286
9974
|
// src/cli/doctor/checks/opencode.ts
|
|
7287
9975
|
async function findOpenCodeBinary() {
|
|
7288
|
-
for (const
|
|
9976
|
+
for (const binary2 of OPENCODE_BINARIES2) {
|
|
7289
9977
|
try {
|
|
7290
|
-
const proc = Bun.spawn(["which",
|
|
9978
|
+
const proc = Bun.spawn(["which", binary2], { stdout: "pipe", stderr: "pipe" });
|
|
7291
9979
|
const output = await new Response(proc.stdout).text();
|
|
7292
9980
|
await proc.exited;
|
|
7293
9981
|
if (proc.exitCode === 0) {
|
|
7294
|
-
return { binary, path: output.trim() };
|
|
9982
|
+
return { binary: binary2, path: output.trim() };
|
|
7295
9983
|
}
|
|
7296
9984
|
} catch {
|
|
7297
9985
|
continue;
|
|
@@ -7299,9 +9987,9 @@ async function findOpenCodeBinary() {
|
|
|
7299
9987
|
}
|
|
7300
9988
|
return null;
|
|
7301
9989
|
}
|
|
7302
|
-
async function getOpenCodeVersion2(
|
|
9990
|
+
async function getOpenCodeVersion2(binary2) {
|
|
7303
9991
|
try {
|
|
7304
|
-
const proc = Bun.spawn([
|
|
9992
|
+
const proc = Bun.spawn([binary2, "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
7305
9993
|
const output = await new Response(proc.stdout).text();
|
|
7306
9994
|
await proc.exited;
|
|
7307
9995
|
if (proc.exitCode === 0) {
|
|
@@ -7319,9 +10007,9 @@ function compareVersions(current, minimum) {
|
|
|
7319
10007
|
};
|
|
7320
10008
|
const curr = parseVersion(current);
|
|
7321
10009
|
const min = parseVersion(minimum);
|
|
7322
|
-
for (let
|
|
7323
|
-
const c = curr[
|
|
7324
|
-
const m2 = min[
|
|
10010
|
+
for (let i2 = 0;i2 < Math.max(curr.length, min.length); i2++) {
|
|
10011
|
+
const c = curr[i2] ?? 0;
|
|
10012
|
+
const m2 = min[i2] ?? 0;
|
|
7325
10013
|
if (c > m2)
|
|
7326
10014
|
return true;
|
|
7327
10015
|
if (c < m2)
|
|
@@ -7390,17 +10078,17 @@ function getOpenCodeCheckDefinition() {
|
|
|
7390
10078
|
}
|
|
7391
10079
|
|
|
7392
10080
|
// src/cli/doctor/checks/plugin.ts
|
|
7393
|
-
import { existsSync as
|
|
7394
|
-
import { homedir as
|
|
10081
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
10082
|
+
import { homedir as homedir4 } from "os";
|
|
7395
10083
|
import { join as join5 } from "path";
|
|
7396
|
-
var OPENCODE_CONFIG_DIR2 = join5(
|
|
10084
|
+
var OPENCODE_CONFIG_DIR2 = join5(homedir4(), ".config", "opencode");
|
|
7397
10085
|
var OPENCODE_JSON2 = join5(OPENCODE_CONFIG_DIR2, "opencode.json");
|
|
7398
10086
|
var OPENCODE_JSONC2 = join5(OPENCODE_CONFIG_DIR2, "opencode.jsonc");
|
|
7399
10087
|
function detectConfigPath() {
|
|
7400
|
-
if (
|
|
10088
|
+
if (existsSync5(OPENCODE_JSONC2)) {
|
|
7401
10089
|
return { path: OPENCODE_JSONC2, format: "jsonc" };
|
|
7402
10090
|
}
|
|
7403
|
-
if (
|
|
10091
|
+
if (existsSync5(OPENCODE_JSON2)) {
|
|
7404
10092
|
return { path: OPENCODE_JSON2, format: "json" };
|
|
7405
10093
|
}
|
|
7406
10094
|
return null;
|
|
@@ -7500,8 +10188,8 @@ function getPluginCheckDefinition() {
|
|
|
7500
10188
|
}
|
|
7501
10189
|
|
|
7502
10190
|
// src/cli/doctor/checks/config.ts
|
|
7503
|
-
import { existsSync as
|
|
7504
|
-
import { homedir as
|
|
10191
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
10192
|
+
import { homedir as homedir5 } from "os";
|
|
7505
10193
|
import { join as join6 } from "path";
|
|
7506
10194
|
|
|
7507
10195
|
// node_modules/zod/v4/classic/external.js
|
|
@@ -7540,7 +10228,7 @@ __export(exports_external, {
|
|
|
7540
10228
|
startsWith: () => _startsWith,
|
|
7541
10229
|
size: () => _size,
|
|
7542
10230
|
setErrorMap: () => setErrorMap,
|
|
7543
|
-
set: () =>
|
|
10231
|
+
set: () => set2,
|
|
7544
10232
|
safeParseAsync: () => safeParseAsync2,
|
|
7545
10233
|
safeParse: () => safeParse2,
|
|
7546
10234
|
safeEncodeAsync: () => safeEncodeAsync2,
|
|
@@ -7569,7 +10257,7 @@ __export(exports_external, {
|
|
|
7569
10257
|
number: () => number2,
|
|
7570
10258
|
nullish: () => nullish2,
|
|
7571
10259
|
nullable: () => nullable,
|
|
7572
|
-
null: () =>
|
|
10260
|
+
null: () => _null4,
|
|
7573
10261
|
normalize: () => _normalize,
|
|
7574
10262
|
nonpositive: () => _nonpositive,
|
|
7575
10263
|
nonoptional: () => nonoptional,
|
|
@@ -7585,7 +10273,7 @@ __export(exports_external, {
|
|
|
7585
10273
|
mime: () => _mime,
|
|
7586
10274
|
maxSize: () => _maxSize,
|
|
7587
10275
|
maxLength: () => _maxLength,
|
|
7588
|
-
map: () =>
|
|
10276
|
+
map: () => map2,
|
|
7589
10277
|
lte: () => _lte,
|
|
7590
10278
|
lt: () => _lt,
|
|
7591
10279
|
lowercase: () => _lowercase,
|
|
@@ -7597,14 +10285,14 @@ __export(exports_external, {
|
|
|
7597
10285
|
ksuid: () => ksuid2,
|
|
7598
10286
|
keyof: () => keyof,
|
|
7599
10287
|
jwt: () => jwt,
|
|
7600
|
-
json: () =>
|
|
10288
|
+
json: () => json2,
|
|
7601
10289
|
iso: () => exports_iso,
|
|
7602
10290
|
ipv6: () => ipv62,
|
|
7603
10291
|
ipv4: () => ipv42,
|
|
7604
10292
|
intersection: () => intersection,
|
|
7605
10293
|
int64: () => int64,
|
|
7606
10294
|
int32: () => int32,
|
|
7607
|
-
int: () =>
|
|
10295
|
+
int: () => int2,
|
|
7608
10296
|
instanceof: () => _instanceof,
|
|
7609
10297
|
includes: () => _includes,
|
|
7610
10298
|
httpUrl: () => httpUrl,
|
|
@@ -7617,7 +10305,7 @@ __export(exports_external, {
|
|
|
7617
10305
|
globalRegistry: () => globalRegistry,
|
|
7618
10306
|
getErrorMap: () => getErrorMap,
|
|
7619
10307
|
function: () => _function,
|
|
7620
|
-
formatError: () =>
|
|
10308
|
+
formatError: () => formatError2,
|
|
7621
10309
|
float64: () => float64,
|
|
7622
10310
|
float32: () => float32,
|
|
7623
10311
|
flattenError: () => flattenError,
|
|
@@ -7652,7 +10340,7 @@ __export(exports_external, {
|
|
|
7652
10340
|
array: () => array,
|
|
7653
10341
|
any: () => any,
|
|
7654
10342
|
_function: () => _function,
|
|
7655
|
-
_default: () =>
|
|
10343
|
+
_default: () => _default3,
|
|
7656
10344
|
_ZodString: () => _ZodString,
|
|
7657
10345
|
ZodXID: () => ZodXID,
|
|
7658
10346
|
ZodVoid: () => ZodVoid,
|
|
@@ -7759,7 +10447,7 @@ __export(exports_core2, {
|
|
|
7759
10447
|
isValidBase64: () => isValidBase64,
|
|
7760
10448
|
globalRegistry: () => globalRegistry,
|
|
7761
10449
|
globalConfig: () => globalConfig,
|
|
7762
|
-
formatError: () =>
|
|
10450
|
+
formatError: () => formatError2,
|
|
7763
10451
|
flattenError: () => flattenError,
|
|
7764
10452
|
encodeAsync: () => encodeAsync,
|
|
7765
10453
|
encode: () => encode,
|
|
@@ -7816,7 +10504,7 @@ __export(exports_core2, {
|
|
|
7816
10504
|
_optional: () => _optional,
|
|
7817
10505
|
_number: () => _number,
|
|
7818
10506
|
_nullable: () => _nullable,
|
|
7819
|
-
_null: () =>
|
|
10507
|
+
_null: () => _null3,
|
|
7820
10508
|
_normalize: () => _normalize,
|
|
7821
10509
|
_nonpositive: () => _nonpositive,
|
|
7822
10510
|
_nonoptional: () => _nonoptional,
|
|
@@ -7868,7 +10556,7 @@ __export(exports_core2, {
|
|
|
7868
10556
|
_email: () => _email,
|
|
7869
10557
|
_e164: () => _e164,
|
|
7870
10558
|
_discriminatedUnion: () => _discriminatedUnion,
|
|
7871
|
-
_default: () =>
|
|
10559
|
+
_default: () => _default2,
|
|
7872
10560
|
_decodeAsync: () => _decodeAsync,
|
|
7873
10561
|
_decode: () => _decode,
|
|
7874
10562
|
_date: () => _date,
|
|
@@ -8090,12 +10778,12 @@ __export(exports_util, {
|
|
|
8090
10778
|
nullish: () => nullish,
|
|
8091
10779
|
normalizeParams: () => normalizeParams,
|
|
8092
10780
|
mergeDefs: () => mergeDefs,
|
|
8093
|
-
merge: () =>
|
|
10781
|
+
merge: () => merge2,
|
|
8094
10782
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
8095
10783
|
joinValues: () => joinValues,
|
|
8096
10784
|
issue: () => issue,
|
|
8097
10785
|
isPlainObject: () => isPlainObject2,
|
|
8098
|
-
isObject: () =>
|
|
10786
|
+
isObject: () => isObject2,
|
|
8099
10787
|
hexToUint8Array: () => hexToUint8Array,
|
|
8100
10788
|
getSizableOrigin: () => getSizableOrigin,
|
|
8101
10789
|
getParsedType: () => getParsedType,
|
|
@@ -8104,7 +10792,7 @@ __export(exports_util, {
|
|
|
8104
10792
|
getElementAtPath: () => getElementAtPath,
|
|
8105
10793
|
floatSafeRemainder: () => floatSafeRemainder,
|
|
8106
10794
|
finalizeIssue: () => finalizeIssue,
|
|
8107
|
-
extend: () =>
|
|
10795
|
+
extend: () => extend3,
|
|
8108
10796
|
escapeRegex: () => escapeRegex,
|
|
8109
10797
|
esc: () => esc,
|
|
8110
10798
|
defineLazy: () => defineLazy,
|
|
@@ -8154,10 +10842,10 @@ function jsonStringifyReplacer(_3, value) {
|
|
|
8154
10842
|
return value;
|
|
8155
10843
|
}
|
|
8156
10844
|
function cached(getter) {
|
|
8157
|
-
const
|
|
10845
|
+
const set2 = false;
|
|
8158
10846
|
return {
|
|
8159
10847
|
get value() {
|
|
8160
|
-
if (!
|
|
10848
|
+
if (!set2) {
|
|
8161
10849
|
const value = getter();
|
|
8162
10850
|
Object.defineProperty(this, "value", { value });
|
|
8163
10851
|
return value;
|
|
@@ -8230,8 +10918,8 @@ function mergeDefs(...defs) {
|
|
|
8230
10918
|
}
|
|
8231
10919
|
return Object.defineProperties({}, mergedDescriptors);
|
|
8232
10920
|
}
|
|
8233
|
-
function cloneDef(
|
|
8234
|
-
return mergeDefs(
|
|
10921
|
+
function cloneDef(schema2) {
|
|
10922
|
+
return mergeDefs(schema2._zod.def);
|
|
8235
10923
|
}
|
|
8236
10924
|
function getElementAtPath(obj, path4) {
|
|
8237
10925
|
if (!path4)
|
|
@@ -8243,25 +10931,25 @@ function promiseAllObject(promisesObj) {
|
|
|
8243
10931
|
const promises = keys.map((key) => promisesObj[key]);
|
|
8244
10932
|
return Promise.all(promises).then((results) => {
|
|
8245
10933
|
const resolvedObj = {};
|
|
8246
|
-
for (let
|
|
8247
|
-
resolvedObj[keys[
|
|
10934
|
+
for (let i2 = 0;i2 < keys.length; i2++) {
|
|
10935
|
+
resolvedObj[keys[i2]] = results[i2];
|
|
8248
10936
|
}
|
|
8249
10937
|
return resolvedObj;
|
|
8250
10938
|
});
|
|
8251
10939
|
}
|
|
8252
10940
|
function randomString(length = 10) {
|
|
8253
10941
|
const chars = "abcdefghijklmnopqrstuvwxyz";
|
|
8254
|
-
let
|
|
8255
|
-
for (let
|
|
8256
|
-
|
|
10942
|
+
let str2 = "";
|
|
10943
|
+
for (let i2 = 0;i2 < length; i2++) {
|
|
10944
|
+
str2 += chars[Math.floor(Math.random() * chars.length)];
|
|
8257
10945
|
}
|
|
8258
|
-
return
|
|
10946
|
+
return str2;
|
|
8259
10947
|
}
|
|
8260
|
-
function esc(
|
|
8261
|
-
return JSON.stringify(
|
|
10948
|
+
function esc(str2) {
|
|
10949
|
+
return JSON.stringify(str2);
|
|
8262
10950
|
}
|
|
8263
10951
|
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
8264
|
-
function
|
|
10952
|
+
function isObject2(data) {
|
|
8265
10953
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
8266
10954
|
}
|
|
8267
10955
|
var allowsEval = cached(() => {
|
|
@@ -8277,13 +10965,13 @@ var allowsEval = cached(() => {
|
|
|
8277
10965
|
}
|
|
8278
10966
|
});
|
|
8279
10967
|
function isPlainObject2(o2) {
|
|
8280
|
-
if (
|
|
10968
|
+
if (isObject2(o2) === false)
|
|
8281
10969
|
return false;
|
|
8282
10970
|
const ctor = o2.constructor;
|
|
8283
10971
|
if (ctor === undefined)
|
|
8284
10972
|
return true;
|
|
8285
10973
|
const prot = ctor.prototype;
|
|
8286
|
-
if (
|
|
10974
|
+
if (isObject2(prot) === false)
|
|
8287
10975
|
return false;
|
|
8288
10976
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
8289
10977
|
return false;
|
|
@@ -8352,8 +11040,8 @@ var getParsedType = (data) => {
|
|
|
8352
11040
|
};
|
|
8353
11041
|
var propertyKeyTypes = new Set(["string", "number", "symbol"]);
|
|
8354
11042
|
var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
|
|
8355
|
-
function escapeRegex(
|
|
8356
|
-
return
|
|
11043
|
+
function escapeRegex(str2) {
|
|
11044
|
+
return str2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8357
11045
|
}
|
|
8358
11046
|
function clone(inst, def, params) {
|
|
8359
11047
|
const cl = new inst._zod.constr(def ?? inst._zod.def);
|
|
@@ -8433,9 +11121,9 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
8433
11121
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
8434
11122
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
8435
11123
|
};
|
|
8436
|
-
function pick(
|
|
8437
|
-
const currDef =
|
|
8438
|
-
const def = mergeDefs(
|
|
11124
|
+
function pick(schema2, mask) {
|
|
11125
|
+
const currDef = schema2._zod.def;
|
|
11126
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
8439
11127
|
get shape() {
|
|
8440
11128
|
const newShape = {};
|
|
8441
11129
|
for (const key in mask) {
|
|
@@ -8451,13 +11139,13 @@ function pick(schema, mask) {
|
|
|
8451
11139
|
},
|
|
8452
11140
|
checks: []
|
|
8453
11141
|
});
|
|
8454
|
-
return clone(
|
|
11142
|
+
return clone(schema2, def);
|
|
8455
11143
|
}
|
|
8456
|
-
function omit(
|
|
8457
|
-
const currDef =
|
|
8458
|
-
const def = mergeDefs(
|
|
11144
|
+
function omit(schema2, mask) {
|
|
11145
|
+
const currDef = schema2._zod.def;
|
|
11146
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
8459
11147
|
get shape() {
|
|
8460
|
-
const newShape = { ...
|
|
11148
|
+
const newShape = { ...schema2._zod.def.shape };
|
|
8461
11149
|
for (const key in mask) {
|
|
8462
11150
|
if (!(key in currDef.shape)) {
|
|
8463
11151
|
throw new Error(`Unrecognized key: "${key}"`);
|
|
@@ -8471,43 +11159,43 @@ function omit(schema, mask) {
|
|
|
8471
11159
|
},
|
|
8472
11160
|
checks: []
|
|
8473
11161
|
});
|
|
8474
|
-
return clone(
|
|
11162
|
+
return clone(schema2, def);
|
|
8475
11163
|
}
|
|
8476
|
-
function
|
|
11164
|
+
function extend3(schema2, shape) {
|
|
8477
11165
|
if (!isPlainObject2(shape)) {
|
|
8478
11166
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
8479
11167
|
}
|
|
8480
|
-
const checks =
|
|
11168
|
+
const checks = schema2._zod.def.checks;
|
|
8481
11169
|
const hasChecks = checks && checks.length > 0;
|
|
8482
11170
|
if (hasChecks) {
|
|
8483
11171
|
throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
|
|
8484
11172
|
}
|
|
8485
|
-
const def = mergeDefs(
|
|
11173
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
8486
11174
|
get shape() {
|
|
8487
|
-
const _shape = { ...
|
|
11175
|
+
const _shape = { ...schema2._zod.def.shape, ...shape };
|
|
8488
11176
|
assignProp(this, "shape", _shape);
|
|
8489
11177
|
return _shape;
|
|
8490
11178
|
},
|
|
8491
11179
|
checks: []
|
|
8492
11180
|
});
|
|
8493
|
-
return clone(
|
|
11181
|
+
return clone(schema2, def);
|
|
8494
11182
|
}
|
|
8495
|
-
function safeExtend(
|
|
11183
|
+
function safeExtend(schema2, shape) {
|
|
8496
11184
|
if (!isPlainObject2(shape)) {
|
|
8497
11185
|
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
8498
11186
|
}
|
|
8499
11187
|
const def = {
|
|
8500
|
-
...
|
|
11188
|
+
...schema2._zod.def,
|
|
8501
11189
|
get shape() {
|
|
8502
|
-
const _shape = { ...
|
|
11190
|
+
const _shape = { ...schema2._zod.def.shape, ...shape };
|
|
8503
11191
|
assignProp(this, "shape", _shape);
|
|
8504
11192
|
return _shape;
|
|
8505
11193
|
},
|
|
8506
|
-
checks:
|
|
11194
|
+
checks: schema2._zod.def.checks
|
|
8507
11195
|
};
|
|
8508
|
-
return clone(
|
|
11196
|
+
return clone(schema2, def);
|
|
8509
11197
|
}
|
|
8510
|
-
function
|
|
11198
|
+
function merge2(a, b3) {
|
|
8511
11199
|
const def = mergeDefs(a._zod.def, {
|
|
8512
11200
|
get shape() {
|
|
8513
11201
|
const _shape = { ...a._zod.def.shape, ...b3._zod.def.shape };
|
|
@@ -8521,10 +11209,10 @@ function merge(a, b3) {
|
|
|
8521
11209
|
});
|
|
8522
11210
|
return clone(a, def);
|
|
8523
11211
|
}
|
|
8524
|
-
function partial(Class,
|
|
8525
|
-
const def = mergeDefs(
|
|
11212
|
+
function partial(Class, schema2, mask) {
|
|
11213
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
8526
11214
|
get shape() {
|
|
8527
|
-
const oldShape =
|
|
11215
|
+
const oldShape = schema2._zod.def.shape;
|
|
8528
11216
|
const shape = { ...oldShape };
|
|
8529
11217
|
if (mask) {
|
|
8530
11218
|
for (const key in mask) {
|
|
@@ -8551,12 +11239,12 @@ function partial(Class, schema, mask) {
|
|
|
8551
11239
|
},
|
|
8552
11240
|
checks: []
|
|
8553
11241
|
});
|
|
8554
|
-
return clone(
|
|
11242
|
+
return clone(schema2, def);
|
|
8555
11243
|
}
|
|
8556
|
-
function required(Class,
|
|
8557
|
-
const def = mergeDefs(
|
|
11244
|
+
function required(Class, schema2, mask) {
|
|
11245
|
+
const def = mergeDefs(schema2._zod.def, {
|
|
8558
11246
|
get shape() {
|
|
8559
|
-
const oldShape =
|
|
11247
|
+
const oldShape = schema2._zod.def.shape;
|
|
8560
11248
|
const shape = { ...oldShape };
|
|
8561
11249
|
if (mask) {
|
|
8562
11250
|
for (const key in mask) {
|
|
@@ -8583,13 +11271,13 @@ function required(Class, schema, mask) {
|
|
|
8583
11271
|
},
|
|
8584
11272
|
checks: []
|
|
8585
11273
|
});
|
|
8586
|
-
return clone(
|
|
11274
|
+
return clone(schema2, def);
|
|
8587
11275
|
}
|
|
8588
11276
|
function aborted(x2, startIndex = 0) {
|
|
8589
11277
|
if (x2.aborted === true)
|
|
8590
11278
|
return true;
|
|
8591
|
-
for (let
|
|
8592
|
-
if (x2.issues[
|
|
11279
|
+
for (let i2 = startIndex;i2 < x2.issues.length; i2++) {
|
|
11280
|
+
if (x2.issues[i2]?.continue !== true) {
|
|
8593
11281
|
return true;
|
|
8594
11282
|
}
|
|
8595
11283
|
}
|
|
@@ -8655,15 +11343,15 @@ function cleanEnum(obj) {
|
|
|
8655
11343
|
function base64ToUint8Array(base64) {
|
|
8656
11344
|
const binaryString = atob(base64);
|
|
8657
11345
|
const bytes = new Uint8Array(binaryString.length);
|
|
8658
|
-
for (let
|
|
8659
|
-
bytes[
|
|
11346
|
+
for (let i2 = 0;i2 < binaryString.length; i2++) {
|
|
11347
|
+
bytes[i2] = binaryString.charCodeAt(i2);
|
|
8660
11348
|
}
|
|
8661
11349
|
return bytes;
|
|
8662
11350
|
}
|
|
8663
11351
|
function uint8ArrayToBase64(bytes) {
|
|
8664
11352
|
let binaryString = "";
|
|
8665
|
-
for (let
|
|
8666
|
-
binaryString += String.fromCharCode(bytes[
|
|
11353
|
+
for (let i2 = 0;i2 < bytes.length; i2++) {
|
|
11354
|
+
binaryString += String.fromCharCode(bytes[i2]);
|
|
8667
11355
|
}
|
|
8668
11356
|
return btoa(binaryString);
|
|
8669
11357
|
}
|
|
@@ -8681,8 +11369,8 @@ function hexToUint8Array(hex) {
|
|
|
8681
11369
|
throw new Error("Invalid hex string length");
|
|
8682
11370
|
}
|
|
8683
11371
|
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
8684
|
-
for (let
|
|
8685
|
-
bytes[
|
|
11372
|
+
for (let i2 = 0;i2 < cleanHex.length; i2 += 2) {
|
|
11373
|
+
bytes[i2 / 2] = Number.parseInt(cleanHex.slice(i2, i2 + 2), 16);
|
|
8686
11374
|
}
|
|
8687
11375
|
return bytes;
|
|
8688
11376
|
}
|
|
@@ -8726,7 +11414,7 @@ function flattenError(error, mapper = (issue2) => issue2.message) {
|
|
|
8726
11414
|
}
|
|
8727
11415
|
return { formErrors, fieldErrors };
|
|
8728
11416
|
}
|
|
8729
|
-
function
|
|
11417
|
+
function formatError2(error, _mapper) {
|
|
8730
11418
|
const mapper = _mapper || function(issue2) {
|
|
8731
11419
|
return issue2.message;
|
|
8732
11420
|
};
|
|
@@ -8743,10 +11431,10 @@ function formatError(error, _mapper) {
|
|
|
8743
11431
|
fieldErrors._errors.push(mapper(issue2));
|
|
8744
11432
|
} else {
|
|
8745
11433
|
let curr = fieldErrors;
|
|
8746
|
-
let
|
|
8747
|
-
while (
|
|
8748
|
-
const el = issue2.path[
|
|
8749
|
-
const terminal =
|
|
11434
|
+
let i2 = 0;
|
|
11435
|
+
while (i2 < issue2.path.length) {
|
|
11436
|
+
const el = issue2.path[i2];
|
|
11437
|
+
const terminal = i2 === issue2.path.length - 1;
|
|
8750
11438
|
if (!terminal) {
|
|
8751
11439
|
curr[el] = curr[el] || { _errors: [] };
|
|
8752
11440
|
} else {
|
|
@@ -8754,7 +11442,7 @@ function formatError(error, _mapper) {
|
|
|
8754
11442
|
curr[el]._errors.push(mapper(issue2));
|
|
8755
11443
|
}
|
|
8756
11444
|
curr = curr[el];
|
|
8757
|
-
|
|
11445
|
+
i2++;
|
|
8758
11446
|
}
|
|
8759
11447
|
}
|
|
8760
11448
|
}
|
|
@@ -8783,10 +11471,10 @@ function treeifyError(error, _mapper) {
|
|
|
8783
11471
|
continue;
|
|
8784
11472
|
}
|
|
8785
11473
|
let curr = result;
|
|
8786
|
-
let
|
|
8787
|
-
while (
|
|
8788
|
-
const el = fullpath[
|
|
8789
|
-
const terminal =
|
|
11474
|
+
let i2 = 0;
|
|
11475
|
+
while (i2 < fullpath.length) {
|
|
11476
|
+
const el = fullpath[i2];
|
|
11477
|
+
const terminal = i2 === fullpath.length - 1;
|
|
8790
11478
|
if (typeof el === "string") {
|
|
8791
11479
|
curr.properties ?? (curr.properties = {});
|
|
8792
11480
|
(_a = curr.properties)[el] ?? (_a[el] = { errors: [] });
|
|
@@ -8799,7 +11487,7 @@ function treeifyError(error, _mapper) {
|
|
|
8799
11487
|
if (terminal) {
|
|
8800
11488
|
curr.errors.push(mapper(issue2));
|
|
8801
11489
|
}
|
|
8802
|
-
|
|
11490
|
+
i2++;
|
|
8803
11491
|
}
|
|
8804
11492
|
}
|
|
8805
11493
|
}
|
|
@@ -8838,9 +11526,9 @@ function prettifyError(error) {
|
|
|
8838
11526
|
}
|
|
8839
11527
|
|
|
8840
11528
|
// node_modules/zod/v4/core/parse.js
|
|
8841
|
-
var _parse = (_Err) => (
|
|
11529
|
+
var _parse = (_Err) => (schema2, value, _ctx, _params) => {
|
|
8842
11530
|
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
|
|
8843
|
-
const result =
|
|
11531
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
8844
11532
|
if (result instanceof Promise) {
|
|
8845
11533
|
throw new $ZodAsyncError;
|
|
8846
11534
|
}
|
|
@@ -8852,9 +11540,9 @@ var _parse = (_Err) => (schema, value, _ctx, _params) => {
|
|
|
8852
11540
|
return result.value;
|
|
8853
11541
|
};
|
|
8854
11542
|
var parse3 = /* @__PURE__ */ _parse($ZodRealError);
|
|
8855
|
-
var _parseAsync = (_Err) => async (
|
|
11543
|
+
var _parseAsync = (_Err) => async (schema2, value, _ctx, params) => {
|
|
8856
11544
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
8857
|
-
let result =
|
|
11545
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
8858
11546
|
if (result instanceof Promise)
|
|
8859
11547
|
result = await result;
|
|
8860
11548
|
if (result.issues.length) {
|
|
@@ -8865,9 +11553,9 @@ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
|
|
|
8865
11553
|
return result.value;
|
|
8866
11554
|
};
|
|
8867
11555
|
var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError);
|
|
8868
|
-
var _safeParse = (_Err) => (
|
|
11556
|
+
var _safeParse = (_Err) => (schema2, value, _ctx) => {
|
|
8869
11557
|
const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
|
|
8870
|
-
const result =
|
|
11558
|
+
const result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
8871
11559
|
if (result instanceof Promise) {
|
|
8872
11560
|
throw new $ZodAsyncError;
|
|
8873
11561
|
}
|
|
@@ -8877,9 +11565,9 @@ var _safeParse = (_Err) => (schema, value, _ctx) => {
|
|
|
8877
11565
|
} : { success: true, data: result.value };
|
|
8878
11566
|
};
|
|
8879
11567
|
var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
|
|
8880
|
-
var _safeParseAsync = (_Err) => async (
|
|
11568
|
+
var _safeParseAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
8881
11569
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
8882
|
-
let result =
|
|
11570
|
+
let result = schema2._zod.run({ value, issues: [] }, ctx);
|
|
8883
11571
|
if (result instanceof Promise)
|
|
8884
11572
|
result = await result;
|
|
8885
11573
|
return result.issues.length ? {
|
|
@@ -8888,40 +11576,40 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
8888
11576
|
} : { success: true, data: result.value };
|
|
8889
11577
|
};
|
|
8890
11578
|
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
8891
|
-
var _encode = (_Err) => (
|
|
11579
|
+
var _encode = (_Err) => (schema2, value, _ctx) => {
|
|
8892
11580
|
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
8893
|
-
return _parse(_Err)(
|
|
11581
|
+
return _parse(_Err)(schema2, value, ctx);
|
|
8894
11582
|
};
|
|
8895
11583
|
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
8896
|
-
var _decode = (_Err) => (
|
|
8897
|
-
return _parse(_Err)(
|
|
11584
|
+
var _decode = (_Err) => (schema2, value, _ctx) => {
|
|
11585
|
+
return _parse(_Err)(schema2, value, _ctx);
|
|
8898
11586
|
};
|
|
8899
11587
|
var decode = /* @__PURE__ */ _decode($ZodRealError);
|
|
8900
|
-
var _encodeAsync = (_Err) => async (
|
|
11588
|
+
var _encodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
8901
11589
|
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
8902
|
-
return _parseAsync(_Err)(
|
|
11590
|
+
return _parseAsync(_Err)(schema2, value, ctx);
|
|
8903
11591
|
};
|
|
8904
11592
|
var encodeAsync = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
8905
|
-
var _decodeAsync = (_Err) => async (
|
|
8906
|
-
return _parseAsync(_Err)(
|
|
11593
|
+
var _decodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
11594
|
+
return _parseAsync(_Err)(schema2, value, _ctx);
|
|
8907
11595
|
};
|
|
8908
11596
|
var decodeAsync = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
8909
|
-
var _safeEncode = (_Err) => (
|
|
11597
|
+
var _safeEncode = (_Err) => (schema2, value, _ctx) => {
|
|
8910
11598
|
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
8911
|
-
return _safeParse(_Err)(
|
|
11599
|
+
return _safeParse(_Err)(schema2, value, ctx);
|
|
8912
11600
|
};
|
|
8913
11601
|
var safeEncode = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
8914
|
-
var _safeDecode = (_Err) => (
|
|
8915
|
-
return _safeParse(_Err)(
|
|
11602
|
+
var _safeDecode = (_Err) => (schema2, value, _ctx) => {
|
|
11603
|
+
return _safeParse(_Err)(schema2, value, _ctx);
|
|
8916
11604
|
};
|
|
8917
11605
|
var safeDecode = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
8918
|
-
var _safeEncodeAsync = (_Err) => async (
|
|
11606
|
+
var _safeEncodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
8919
11607
|
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
8920
|
-
return _safeParseAsync(_Err)(
|
|
11608
|
+
return _safeParseAsync(_Err)(schema2, value, ctx);
|
|
8921
11609
|
};
|
|
8922
11610
|
var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
8923
|
-
var _safeDecodeAsync = (_Err) => async (
|
|
8924
|
-
return _safeParseAsync(_Err)(
|
|
11611
|
+
var _safeDecodeAsync = (_Err) => async (schema2, value, _ctx) => {
|
|
11612
|
+
return _safeParseAsync(_Err)(schema2, value, _ctx);
|
|
8925
11613
|
};
|
|
8926
11614
|
var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
8927
11615
|
// node_modules/zod/v4/core/regexes.js
|
|
@@ -8952,7 +11640,7 @@ __export(exports_regexes, {
|
|
|
8952
11640
|
sha1_base64: () => sha1_base64,
|
|
8953
11641
|
rfc5322Email: () => rfc5322Email,
|
|
8954
11642
|
number: () => number,
|
|
8955
|
-
null: () =>
|
|
11643
|
+
null: () => _null2,
|
|
8956
11644
|
nanoid: () => nanoid,
|
|
8957
11645
|
md5_hex: () => md5_hex,
|
|
8958
11646
|
md5_base64url: () => md5_base64url,
|
|
@@ -9049,7 +11737,7 @@ var bigint = /^-?\d+n?$/;
|
|
|
9049
11737
|
var integer = /^-?\d+$/;
|
|
9050
11738
|
var number = /^-?\d+(?:\.\d+)?/;
|
|
9051
11739
|
var boolean = /^(?:true|false)$/i;
|
|
9052
|
-
var
|
|
11740
|
+
var _null2 = /^null$/i;
|
|
9053
11741
|
var _undefined = /^undefined$/i;
|
|
9054
11742
|
var lowercase = /^[^A-Z]*$/;
|
|
9055
11743
|
var uppercase = /^[^a-z]*$/;
|
|
@@ -10192,7 +12880,7 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
|
|
|
10192
12880
|
});
|
|
10193
12881
|
var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
|
|
10194
12882
|
$ZodType.init(inst, def);
|
|
10195
|
-
inst._zod.pattern =
|
|
12883
|
+
inst._zod.pattern = _null2;
|
|
10196
12884
|
inst._zod.values = new Set([null]);
|
|
10197
12885
|
inst._zod.parse = (payload, _ctx) => {
|
|
10198
12886
|
const input = payload.value;
|
|
@@ -10286,16 +12974,16 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
10286
12974
|
}
|
|
10287
12975
|
payload.value = Array(input.length);
|
|
10288
12976
|
const proms = [];
|
|
10289
|
-
for (let
|
|
10290
|
-
const item = input[
|
|
12977
|
+
for (let i2 = 0;i2 < input.length; i2++) {
|
|
12978
|
+
const item = input[i2];
|
|
10291
12979
|
const result = def.element._zod.run({
|
|
10292
12980
|
value: item,
|
|
10293
12981
|
issues: []
|
|
10294
12982
|
}, ctx);
|
|
10295
12983
|
if (result instanceof Promise) {
|
|
10296
|
-
proms.push(result.then((result2) => handleArrayResult(result2, payload,
|
|
12984
|
+
proms.push(result.then((result2) => handleArrayResult(result2, payload, i2)));
|
|
10297
12985
|
} else {
|
|
10298
|
-
handleArrayResult(result, payload,
|
|
12986
|
+
handleArrayResult(result, payload, i2);
|
|
10299
12987
|
}
|
|
10300
12988
|
}
|
|
10301
12989
|
if (proms.length) {
|
|
@@ -10381,13 +13069,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
10381
13069
|
}
|
|
10382
13070
|
return propValues;
|
|
10383
13071
|
});
|
|
10384
|
-
const
|
|
13072
|
+
const isObject3 = isObject2;
|
|
10385
13073
|
const catchall = def.catchall;
|
|
10386
13074
|
let value;
|
|
10387
13075
|
inst._zod.parse = (payload, ctx) => {
|
|
10388
13076
|
value ?? (value = _normalized.value);
|
|
10389
13077
|
const input = payload.value;
|
|
10390
|
-
if (!
|
|
13078
|
+
if (!isObject3(input)) {
|
|
10391
13079
|
payload.issues.push({
|
|
10392
13080
|
expected: "object",
|
|
10393
13081
|
code: "invalid_type",
|
|
@@ -10461,7 +13149,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
10461
13149
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
10462
13150
|
};
|
|
10463
13151
|
let fastpass;
|
|
10464
|
-
const
|
|
13152
|
+
const isObject3 = isObject2;
|
|
10465
13153
|
const jit = !globalConfig.jitless;
|
|
10466
13154
|
const allowsEval2 = allowsEval;
|
|
10467
13155
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -10470,7 +13158,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
10470
13158
|
inst._zod.parse = (payload, ctx) => {
|
|
10471
13159
|
value ?? (value = _normalized.value);
|
|
10472
13160
|
const input = payload.value;
|
|
10473
|
-
if (!
|
|
13161
|
+
if (!isObject3(input)) {
|
|
10474
13162
|
payload.issues.push({
|
|
10475
13163
|
expected: "object",
|
|
10476
13164
|
code: "invalid_type",
|
|
@@ -10577,23 +13265,23 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
10577
13265
|
});
|
|
10578
13266
|
const disc = cached(() => {
|
|
10579
13267
|
const opts = def.options;
|
|
10580
|
-
const
|
|
13268
|
+
const map2 = new Map;
|
|
10581
13269
|
for (const o2 of opts) {
|
|
10582
13270
|
const values = o2._zod.propValues?.[def.discriminator];
|
|
10583
13271
|
if (!values || values.size === 0)
|
|
10584
13272
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o2)}"`);
|
|
10585
13273
|
for (const v of values) {
|
|
10586
|
-
if (
|
|
13274
|
+
if (map2.has(v)) {
|
|
10587
13275
|
throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
10588
13276
|
}
|
|
10589
|
-
|
|
13277
|
+
map2.set(v, o2);
|
|
10590
13278
|
}
|
|
10591
13279
|
}
|
|
10592
|
-
return
|
|
13280
|
+
return map2;
|
|
10593
13281
|
});
|
|
10594
13282
|
inst._zod.parse = (payload, ctx) => {
|
|
10595
13283
|
const input = payload.value;
|
|
10596
|
-
if (!
|
|
13284
|
+
if (!isObject2(input)) {
|
|
10597
13285
|
payload.issues.push({
|
|
10598
13286
|
code: "invalid_type",
|
|
10599
13287
|
expected: "object",
|
|
@@ -10726,35 +13414,35 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
|
|
|
10726
13414
|
return payload;
|
|
10727
13415
|
}
|
|
10728
13416
|
}
|
|
10729
|
-
let
|
|
13417
|
+
let i2 = -1;
|
|
10730
13418
|
for (const item of items) {
|
|
10731
|
-
|
|
10732
|
-
if (
|
|
10733
|
-
if (
|
|
13419
|
+
i2++;
|
|
13420
|
+
if (i2 >= input.length) {
|
|
13421
|
+
if (i2 >= optStart)
|
|
10734
13422
|
continue;
|
|
10735
13423
|
}
|
|
10736
13424
|
const result = item._zod.run({
|
|
10737
|
-
value: input[
|
|
13425
|
+
value: input[i2],
|
|
10738
13426
|
issues: []
|
|
10739
13427
|
}, ctx);
|
|
10740
13428
|
if (result instanceof Promise) {
|
|
10741
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
13429
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i2)));
|
|
10742
13430
|
} else {
|
|
10743
|
-
handleTupleResult(result, payload,
|
|
13431
|
+
handleTupleResult(result, payload, i2);
|
|
10744
13432
|
}
|
|
10745
13433
|
}
|
|
10746
13434
|
if (def.rest) {
|
|
10747
13435
|
const rest = input.slice(items.length);
|
|
10748
13436
|
for (const el of rest) {
|
|
10749
|
-
|
|
13437
|
+
i2++;
|
|
10750
13438
|
const result = def.rest._zod.run({
|
|
10751
13439
|
value: el,
|
|
10752
13440
|
issues: []
|
|
10753
13441
|
}, ctx);
|
|
10754
13442
|
if (result instanceof Promise) {
|
|
10755
|
-
proms.push(result.then((result2) => handleTupleResult(result2, payload,
|
|
13443
|
+
proms.push(result.then((result2) => handleTupleResult(result2, payload, i2)));
|
|
10756
13444
|
} else {
|
|
10757
|
-
handleTupleResult(result, payload,
|
|
13445
|
+
handleTupleResult(result, payload, i2);
|
|
10758
13446
|
}
|
|
10759
13447
|
}
|
|
10760
13448
|
}
|
|
@@ -12203,8 +14891,8 @@ var error6 = () => {
|
|
|
12203
14891
|
function getSizing(origin) {
|
|
12204
14892
|
return Sizable[origin] ?? null;
|
|
12205
14893
|
}
|
|
12206
|
-
function getTypeName(
|
|
12207
|
-
return TypeNames[
|
|
14894
|
+
function getTypeName(type2) {
|
|
14895
|
+
return TypeNames[type2] ?? type2;
|
|
12208
14896
|
}
|
|
12209
14897
|
const parsedType = (data) => {
|
|
12210
14898
|
const t = typeof data;
|
|
@@ -12700,8 +15388,8 @@ var error10 = () => {
|
|
|
12700
15388
|
function getSizing(origin) {
|
|
12701
15389
|
return Sizable[origin] ?? null;
|
|
12702
15390
|
}
|
|
12703
|
-
function getTypeName(
|
|
12704
|
-
return TypeNames[
|
|
15391
|
+
function getTypeName(type2) {
|
|
15392
|
+
return TypeNames[type2] ?? type2;
|
|
12705
15393
|
}
|
|
12706
15394
|
const parsedType3 = (data) => {
|
|
12707
15395
|
const t = typeof data;
|
|
@@ -16977,14 +19665,14 @@ class $ZodRegistry {
|
|
|
16977
19665
|
this._map = new WeakMap;
|
|
16978
19666
|
this._idmap = new Map;
|
|
16979
19667
|
}
|
|
16980
|
-
add(
|
|
19668
|
+
add(schema2, ..._meta) {
|
|
16981
19669
|
const meta = _meta[0];
|
|
16982
|
-
this._map.set(
|
|
19670
|
+
this._map.set(schema2, meta);
|
|
16983
19671
|
if (meta && typeof meta === "object" && "id" in meta) {
|
|
16984
19672
|
if (this._idmap.has(meta.id)) {
|
|
16985
19673
|
throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
16986
19674
|
}
|
|
16987
|
-
this._idmap.set(meta.id,
|
|
19675
|
+
this._idmap.set(meta.id, schema2);
|
|
16988
19676
|
}
|
|
16989
19677
|
return this;
|
|
16990
19678
|
}
|
|
@@ -16993,26 +19681,26 @@ class $ZodRegistry {
|
|
|
16993
19681
|
this._idmap = new Map;
|
|
16994
19682
|
return this;
|
|
16995
19683
|
}
|
|
16996
|
-
remove(
|
|
16997
|
-
const meta = this._map.get(
|
|
19684
|
+
remove(schema2) {
|
|
19685
|
+
const meta = this._map.get(schema2);
|
|
16998
19686
|
if (meta && typeof meta === "object" && "id" in meta) {
|
|
16999
19687
|
this._idmap.delete(meta.id);
|
|
17000
19688
|
}
|
|
17001
|
-
this._map.delete(
|
|
19689
|
+
this._map.delete(schema2);
|
|
17002
19690
|
return this;
|
|
17003
19691
|
}
|
|
17004
|
-
get(
|
|
17005
|
-
const p2 =
|
|
19692
|
+
get(schema2) {
|
|
19693
|
+
const p2 = schema2._zod.parent;
|
|
17006
19694
|
if (p2) {
|
|
17007
19695
|
const pm = { ...this.get(p2) ?? {} };
|
|
17008
19696
|
delete pm.id;
|
|
17009
|
-
const f = { ...pm, ...this._map.get(
|
|
19697
|
+
const f = { ...pm, ...this._map.get(schema2) };
|
|
17010
19698
|
return Object.keys(f).length ? f : undefined;
|
|
17011
19699
|
}
|
|
17012
|
-
return this._map.get(
|
|
19700
|
+
return this._map.get(schema2);
|
|
17013
19701
|
}
|
|
17014
|
-
has(
|
|
17015
|
-
return this._map.has(
|
|
19702
|
+
has(schema2) {
|
|
19703
|
+
return this._map.has(schema2);
|
|
17016
19704
|
}
|
|
17017
19705
|
}
|
|
17018
19706
|
function registry() {
|
|
@@ -17393,7 +20081,7 @@ function _undefined2(Class2, params) {
|
|
|
17393
20081
|
...normalizeParams(params)
|
|
17394
20082
|
});
|
|
17395
20083
|
}
|
|
17396
|
-
function
|
|
20084
|
+
function _null3(Class2, params) {
|
|
17397
20085
|
return new Class2({
|
|
17398
20086
|
type: "null",
|
|
17399
20087
|
...normalizeParams(params)
|
|
@@ -17580,11 +20268,11 @@ function _endsWith(suffix, params) {
|
|
|
17580
20268
|
suffix
|
|
17581
20269
|
});
|
|
17582
20270
|
}
|
|
17583
|
-
function _property(property,
|
|
20271
|
+
function _property(property, schema2, params) {
|
|
17584
20272
|
return new $ZodCheckProperty({
|
|
17585
20273
|
check: "property",
|
|
17586
20274
|
property,
|
|
17587
|
-
schema,
|
|
20275
|
+
schema: schema2,
|
|
17588
20276
|
...normalizeParams(params)
|
|
17589
20277
|
});
|
|
17590
20278
|
}
|
|
@@ -17722,7 +20410,7 @@ function _nullable(Class2, innerType) {
|
|
|
17722
20410
|
innerType
|
|
17723
20411
|
});
|
|
17724
20412
|
}
|
|
17725
|
-
function
|
|
20413
|
+
function _default2(Class2, innerType, defaultValue) {
|
|
17726
20414
|
return new Class2({
|
|
17727
20415
|
type: "default",
|
|
17728
20416
|
innerType,
|
|
@@ -17786,22 +20474,22 @@ function _promise(Class2, innerType) {
|
|
|
17786
20474
|
function _custom(Class2, fn, _params) {
|
|
17787
20475
|
const norm = normalizeParams(_params);
|
|
17788
20476
|
norm.abort ?? (norm.abort = true);
|
|
17789
|
-
const
|
|
20477
|
+
const schema2 = new Class2({
|
|
17790
20478
|
type: "custom",
|
|
17791
20479
|
check: "custom",
|
|
17792
20480
|
fn,
|
|
17793
20481
|
...norm
|
|
17794
20482
|
});
|
|
17795
|
-
return
|
|
20483
|
+
return schema2;
|
|
17796
20484
|
}
|
|
17797
20485
|
function _refine(Class2, fn, _params) {
|
|
17798
|
-
const
|
|
20486
|
+
const schema2 = new Class2({
|
|
17799
20487
|
type: "custom",
|
|
17800
20488
|
check: "custom",
|
|
17801
20489
|
fn,
|
|
17802
20490
|
...normalizeParams(_params)
|
|
17803
20491
|
});
|
|
17804
|
-
return
|
|
20492
|
+
return schema2;
|
|
17805
20493
|
}
|
|
17806
20494
|
function _superRefine(fn) {
|
|
17807
20495
|
const ch = _check((payload) => {
|
|
@@ -17908,9 +20596,9 @@ class JSONSchemaGenerator {
|
|
|
17908
20596
|
this.io = params?.io ?? "output";
|
|
17909
20597
|
this.seen = new Map;
|
|
17910
20598
|
}
|
|
17911
|
-
process(
|
|
20599
|
+
process(schema2, _params = { path: [], schemaPath: [] }) {
|
|
17912
20600
|
var _a;
|
|
17913
|
-
const def =
|
|
20601
|
+
const def = schema2._zod.def;
|
|
17914
20602
|
const formatMap = {
|
|
17915
20603
|
guid: "uuid",
|
|
17916
20604
|
url: "uri",
|
|
@@ -17918,27 +20606,27 @@ class JSONSchemaGenerator {
|
|
|
17918
20606
|
json_string: "json-string",
|
|
17919
20607
|
regex: ""
|
|
17920
20608
|
};
|
|
17921
|
-
const seen = this.seen.get(
|
|
20609
|
+
const seen = this.seen.get(schema2);
|
|
17922
20610
|
if (seen) {
|
|
17923
20611
|
seen.count++;
|
|
17924
|
-
const isCycle = _params.schemaPath.includes(
|
|
20612
|
+
const isCycle = _params.schemaPath.includes(schema2);
|
|
17925
20613
|
if (isCycle) {
|
|
17926
20614
|
seen.cycle = _params.path;
|
|
17927
20615
|
}
|
|
17928
20616
|
return seen.schema;
|
|
17929
20617
|
}
|
|
17930
20618
|
const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
|
|
17931
|
-
this.seen.set(
|
|
17932
|
-
const overrideSchema =
|
|
20619
|
+
this.seen.set(schema2, result);
|
|
20620
|
+
const overrideSchema = schema2._zod.toJSONSchema?.();
|
|
17933
20621
|
if (overrideSchema) {
|
|
17934
20622
|
result.schema = overrideSchema;
|
|
17935
20623
|
} else {
|
|
17936
20624
|
const params = {
|
|
17937
20625
|
..._params,
|
|
17938
|
-
schemaPath: [..._params.schemaPath,
|
|
20626
|
+
schemaPath: [..._params.schemaPath, schema2],
|
|
17939
20627
|
path: _params.path
|
|
17940
20628
|
};
|
|
17941
|
-
const parent =
|
|
20629
|
+
const parent = schema2._zod.parent;
|
|
17942
20630
|
if (parent) {
|
|
17943
20631
|
result.ref = parent;
|
|
17944
20632
|
this.process(parent, params);
|
|
@@ -17947,24 +20635,24 @@ class JSONSchemaGenerator {
|
|
|
17947
20635
|
const _json = result.schema;
|
|
17948
20636
|
switch (def.type) {
|
|
17949
20637
|
case "string": {
|
|
17950
|
-
const
|
|
17951
|
-
|
|
17952
|
-
const { minimum, maximum, format: format2, patterns, contentEncoding } =
|
|
20638
|
+
const json2 = _json;
|
|
20639
|
+
json2.type = "string";
|
|
20640
|
+
const { minimum, maximum, format: format2, patterns, contentEncoding } = schema2._zod.bag;
|
|
17953
20641
|
if (typeof minimum === "number")
|
|
17954
|
-
|
|
20642
|
+
json2.minLength = minimum;
|
|
17955
20643
|
if (typeof maximum === "number")
|
|
17956
|
-
|
|
20644
|
+
json2.maxLength = maximum;
|
|
17957
20645
|
if (format2) {
|
|
17958
|
-
|
|
17959
|
-
if (
|
|
17960
|
-
delete
|
|
20646
|
+
json2.format = formatMap[format2] ?? format2;
|
|
20647
|
+
if (json2.format === "")
|
|
20648
|
+
delete json2.format;
|
|
17961
20649
|
}
|
|
17962
20650
|
if (contentEncoding)
|
|
17963
|
-
|
|
20651
|
+
json2.contentEncoding = contentEncoding;
|
|
17964
20652
|
if (patterns && patterns.size > 0) {
|
|
17965
20653
|
const regexes = [...patterns];
|
|
17966
20654
|
if (regexes.length === 1)
|
|
17967
|
-
|
|
20655
|
+
json2.pattern = regexes[0].source;
|
|
17968
20656
|
else if (regexes.length > 1) {
|
|
17969
20657
|
result.schema.allOf = [
|
|
17970
20658
|
...regexes.map((regex) => ({
|
|
@@ -17977,53 +20665,53 @@ class JSONSchemaGenerator {
|
|
|
17977
20665
|
break;
|
|
17978
20666
|
}
|
|
17979
20667
|
case "number": {
|
|
17980
|
-
const
|
|
17981
|
-
const { minimum, maximum, format: format2, multipleOf, exclusiveMaximum, exclusiveMinimum } =
|
|
20668
|
+
const json2 = _json;
|
|
20669
|
+
const { minimum, maximum, format: format2, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema2._zod.bag;
|
|
17982
20670
|
if (typeof format2 === "string" && format2.includes("int"))
|
|
17983
|
-
|
|
20671
|
+
json2.type = "integer";
|
|
17984
20672
|
else
|
|
17985
|
-
|
|
20673
|
+
json2.type = "number";
|
|
17986
20674
|
if (typeof exclusiveMinimum === "number") {
|
|
17987
20675
|
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
17988
|
-
|
|
17989
|
-
|
|
20676
|
+
json2.minimum = exclusiveMinimum;
|
|
20677
|
+
json2.exclusiveMinimum = true;
|
|
17990
20678
|
} else {
|
|
17991
|
-
|
|
20679
|
+
json2.exclusiveMinimum = exclusiveMinimum;
|
|
17992
20680
|
}
|
|
17993
20681
|
}
|
|
17994
20682
|
if (typeof minimum === "number") {
|
|
17995
|
-
|
|
20683
|
+
json2.minimum = minimum;
|
|
17996
20684
|
if (typeof exclusiveMinimum === "number" && this.target !== "draft-4") {
|
|
17997
20685
|
if (exclusiveMinimum >= minimum)
|
|
17998
|
-
delete
|
|
20686
|
+
delete json2.minimum;
|
|
17999
20687
|
else
|
|
18000
|
-
delete
|
|
20688
|
+
delete json2.exclusiveMinimum;
|
|
18001
20689
|
}
|
|
18002
20690
|
}
|
|
18003
20691
|
if (typeof exclusiveMaximum === "number") {
|
|
18004
20692
|
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
18005
|
-
|
|
18006
|
-
|
|
20693
|
+
json2.maximum = exclusiveMaximum;
|
|
20694
|
+
json2.exclusiveMaximum = true;
|
|
18007
20695
|
} else {
|
|
18008
|
-
|
|
20696
|
+
json2.exclusiveMaximum = exclusiveMaximum;
|
|
18009
20697
|
}
|
|
18010
20698
|
}
|
|
18011
20699
|
if (typeof maximum === "number") {
|
|
18012
|
-
|
|
20700
|
+
json2.maximum = maximum;
|
|
18013
20701
|
if (typeof exclusiveMaximum === "number" && this.target !== "draft-4") {
|
|
18014
20702
|
if (exclusiveMaximum <= maximum)
|
|
18015
|
-
delete
|
|
20703
|
+
delete json2.maximum;
|
|
18016
20704
|
else
|
|
18017
|
-
delete
|
|
20705
|
+
delete json2.exclusiveMaximum;
|
|
18018
20706
|
}
|
|
18019
20707
|
}
|
|
18020
20708
|
if (typeof multipleOf === "number")
|
|
18021
|
-
|
|
20709
|
+
json2.multipleOf = multipleOf;
|
|
18022
20710
|
break;
|
|
18023
20711
|
}
|
|
18024
20712
|
case "boolean": {
|
|
18025
|
-
const
|
|
18026
|
-
|
|
20713
|
+
const json2 = _json;
|
|
20714
|
+
json2.type = "boolean";
|
|
18027
20715
|
break;
|
|
18028
20716
|
}
|
|
18029
20717
|
case "bigint": {
|
|
@@ -18076,23 +20764,23 @@ class JSONSchemaGenerator {
|
|
|
18076
20764
|
break;
|
|
18077
20765
|
}
|
|
18078
20766
|
case "array": {
|
|
18079
|
-
const
|
|
18080
|
-
const { minimum, maximum } =
|
|
20767
|
+
const json2 = _json;
|
|
20768
|
+
const { minimum, maximum } = schema2._zod.bag;
|
|
18081
20769
|
if (typeof minimum === "number")
|
|
18082
|
-
|
|
20770
|
+
json2.minItems = minimum;
|
|
18083
20771
|
if (typeof maximum === "number")
|
|
18084
|
-
|
|
18085
|
-
|
|
18086
|
-
|
|
20772
|
+
json2.maxItems = maximum;
|
|
20773
|
+
json2.type = "array";
|
|
20774
|
+
json2.items = this.process(def.element, { ...params, path: [...params.path, "items"] });
|
|
18087
20775
|
break;
|
|
18088
20776
|
}
|
|
18089
20777
|
case "object": {
|
|
18090
|
-
const
|
|
18091
|
-
|
|
18092
|
-
|
|
20778
|
+
const json2 = _json;
|
|
20779
|
+
json2.type = "object";
|
|
20780
|
+
json2.properties = {};
|
|
18093
20781
|
const shape = def.shape;
|
|
18094
20782
|
for (const key in shape) {
|
|
18095
|
-
|
|
20783
|
+
json2.properties[key] = this.process(shape[key], {
|
|
18096
20784
|
...params,
|
|
18097
20785
|
path: [...params.path, "properties", key]
|
|
18098
20786
|
});
|
|
@@ -18107,15 +20795,15 @@ class JSONSchemaGenerator {
|
|
|
18107
20795
|
}
|
|
18108
20796
|
}));
|
|
18109
20797
|
if (requiredKeys.size > 0) {
|
|
18110
|
-
|
|
20798
|
+
json2.required = Array.from(requiredKeys);
|
|
18111
20799
|
}
|
|
18112
20800
|
if (def.catchall?._zod.def.type === "never") {
|
|
18113
|
-
|
|
20801
|
+
json2.additionalProperties = false;
|
|
18114
20802
|
} else if (!def.catchall) {
|
|
18115
20803
|
if (this.io === "output")
|
|
18116
|
-
|
|
20804
|
+
json2.additionalProperties = false;
|
|
18117
20805
|
} else if (def.catchall) {
|
|
18118
|
-
|
|
20806
|
+
json2.additionalProperties = this.process(def.catchall, {
|
|
18119
20807
|
...params,
|
|
18120
20808
|
path: [...params.path, "additionalProperties"]
|
|
18121
20809
|
});
|
|
@@ -18123,16 +20811,16 @@ class JSONSchemaGenerator {
|
|
|
18123
20811
|
break;
|
|
18124
20812
|
}
|
|
18125
20813
|
case "union": {
|
|
18126
|
-
const
|
|
18127
|
-
const options = def.options.map((x2,
|
|
20814
|
+
const json2 = _json;
|
|
20815
|
+
const options = def.options.map((x2, i2) => this.process(x2, {
|
|
18128
20816
|
...params,
|
|
18129
|
-
path: [...params.path, "anyOf",
|
|
20817
|
+
path: [...params.path, "anyOf", i2]
|
|
18130
20818
|
}));
|
|
18131
|
-
|
|
20819
|
+
json2.anyOf = options;
|
|
18132
20820
|
break;
|
|
18133
20821
|
}
|
|
18134
20822
|
case "intersection": {
|
|
18135
|
-
const
|
|
20823
|
+
const json2 = _json;
|
|
18136
20824
|
const a = this.process(def.left, {
|
|
18137
20825
|
...params,
|
|
18138
20826
|
path: [...params.path, "allOf", 0]
|
|
@@ -18146,61 +20834,61 @@ class JSONSchemaGenerator {
|
|
|
18146
20834
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
18147
20835
|
...isSimpleIntersection(b3) ? b3.allOf : [b3]
|
|
18148
20836
|
];
|
|
18149
|
-
|
|
20837
|
+
json2.allOf = allOf;
|
|
18150
20838
|
break;
|
|
18151
20839
|
}
|
|
18152
20840
|
case "tuple": {
|
|
18153
|
-
const
|
|
18154
|
-
|
|
20841
|
+
const json2 = _json;
|
|
20842
|
+
json2.type = "array";
|
|
18155
20843
|
const prefixPath = this.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
18156
20844
|
const restPath = this.target === "draft-2020-12" ? "items" : this.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
18157
|
-
const prefixItems = def.items.map((x2,
|
|
20845
|
+
const prefixItems = def.items.map((x2, i2) => this.process(x2, {
|
|
18158
20846
|
...params,
|
|
18159
|
-
path: [...params.path, prefixPath,
|
|
20847
|
+
path: [...params.path, prefixPath, i2]
|
|
18160
20848
|
}));
|
|
18161
20849
|
const rest = def.rest ? this.process(def.rest, {
|
|
18162
20850
|
...params,
|
|
18163
20851
|
path: [...params.path, restPath, ...this.target === "openapi-3.0" ? [def.items.length] : []]
|
|
18164
20852
|
}) : null;
|
|
18165
20853
|
if (this.target === "draft-2020-12") {
|
|
18166
|
-
|
|
20854
|
+
json2.prefixItems = prefixItems;
|
|
18167
20855
|
if (rest) {
|
|
18168
|
-
|
|
20856
|
+
json2.items = rest;
|
|
18169
20857
|
}
|
|
18170
20858
|
} else if (this.target === "openapi-3.0") {
|
|
18171
|
-
|
|
20859
|
+
json2.items = {
|
|
18172
20860
|
anyOf: prefixItems
|
|
18173
20861
|
};
|
|
18174
20862
|
if (rest) {
|
|
18175
|
-
|
|
20863
|
+
json2.items.anyOf.push(rest);
|
|
18176
20864
|
}
|
|
18177
|
-
|
|
20865
|
+
json2.minItems = prefixItems.length;
|
|
18178
20866
|
if (!rest) {
|
|
18179
|
-
|
|
20867
|
+
json2.maxItems = prefixItems.length;
|
|
18180
20868
|
}
|
|
18181
20869
|
} else {
|
|
18182
|
-
|
|
20870
|
+
json2.items = prefixItems;
|
|
18183
20871
|
if (rest) {
|
|
18184
|
-
|
|
20872
|
+
json2.additionalItems = rest;
|
|
18185
20873
|
}
|
|
18186
20874
|
}
|
|
18187
|
-
const { minimum, maximum } =
|
|
20875
|
+
const { minimum, maximum } = schema2._zod.bag;
|
|
18188
20876
|
if (typeof minimum === "number")
|
|
18189
|
-
|
|
20877
|
+
json2.minItems = minimum;
|
|
18190
20878
|
if (typeof maximum === "number")
|
|
18191
|
-
|
|
20879
|
+
json2.maxItems = maximum;
|
|
18192
20880
|
break;
|
|
18193
20881
|
}
|
|
18194
20882
|
case "record": {
|
|
18195
|
-
const
|
|
18196
|
-
|
|
20883
|
+
const json2 = _json;
|
|
20884
|
+
json2.type = "object";
|
|
18197
20885
|
if (this.target === "draft-7" || this.target === "draft-2020-12") {
|
|
18198
|
-
|
|
20886
|
+
json2.propertyNames = this.process(def.keyType, {
|
|
18199
20887
|
...params,
|
|
18200
20888
|
path: [...params.path, "propertyNames"]
|
|
18201
20889
|
});
|
|
18202
20890
|
}
|
|
18203
|
-
|
|
20891
|
+
json2.additionalProperties = this.process(def.valueType, {
|
|
18204
20892
|
...params,
|
|
18205
20893
|
path: [...params.path, "additionalProperties"]
|
|
18206
20894
|
});
|
|
@@ -18219,17 +20907,17 @@ class JSONSchemaGenerator {
|
|
|
18219
20907
|
break;
|
|
18220
20908
|
}
|
|
18221
20909
|
case "enum": {
|
|
18222
|
-
const
|
|
20910
|
+
const json2 = _json;
|
|
18223
20911
|
const values = getEnumValues(def.entries);
|
|
18224
20912
|
if (values.every((v) => typeof v === "number"))
|
|
18225
|
-
|
|
20913
|
+
json2.type = "number";
|
|
18226
20914
|
if (values.every((v) => typeof v === "string"))
|
|
18227
|
-
|
|
18228
|
-
|
|
20915
|
+
json2.type = "string";
|
|
20916
|
+
json2.enum = values;
|
|
18229
20917
|
break;
|
|
18230
20918
|
}
|
|
18231
20919
|
case "literal": {
|
|
18232
|
-
const
|
|
20920
|
+
const json2 = _json;
|
|
18233
20921
|
const vals = [];
|
|
18234
20922
|
for (const val of def.values) {
|
|
18235
20923
|
if (val === undefined) {
|
|
@@ -18248,33 +20936,33 @@ class JSONSchemaGenerator {
|
|
|
18248
20936
|
}
|
|
18249
20937
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
18250
20938
|
const val = vals[0];
|
|
18251
|
-
|
|
20939
|
+
json2.type = val === null ? "null" : typeof val;
|
|
18252
20940
|
if (this.target === "draft-4" || this.target === "openapi-3.0") {
|
|
18253
|
-
|
|
20941
|
+
json2.enum = [val];
|
|
18254
20942
|
} else {
|
|
18255
|
-
|
|
20943
|
+
json2.const = val;
|
|
18256
20944
|
}
|
|
18257
20945
|
} else {
|
|
18258
20946
|
if (vals.every((v) => typeof v === "number"))
|
|
18259
|
-
|
|
20947
|
+
json2.type = "number";
|
|
18260
20948
|
if (vals.every((v) => typeof v === "string"))
|
|
18261
|
-
|
|
20949
|
+
json2.type = "string";
|
|
18262
20950
|
if (vals.every((v) => typeof v === "boolean"))
|
|
18263
|
-
|
|
20951
|
+
json2.type = "string";
|
|
18264
20952
|
if (vals.every((v) => v === null))
|
|
18265
|
-
|
|
18266
|
-
|
|
20953
|
+
json2.type = "null";
|
|
20954
|
+
json2.enum = vals;
|
|
18267
20955
|
}
|
|
18268
20956
|
break;
|
|
18269
20957
|
}
|
|
18270
20958
|
case "file": {
|
|
18271
|
-
const
|
|
20959
|
+
const json2 = _json;
|
|
18272
20960
|
const file = {
|
|
18273
20961
|
type: "string",
|
|
18274
20962
|
format: "binary",
|
|
18275
20963
|
contentEncoding: "binary"
|
|
18276
20964
|
};
|
|
18277
|
-
const { minimum, maximum, mime } =
|
|
20965
|
+
const { minimum, maximum, mime } = schema2._zod.bag;
|
|
18278
20966
|
if (minimum !== undefined)
|
|
18279
20967
|
file.minLength = minimum;
|
|
18280
20968
|
if (maximum !== undefined)
|
|
@@ -18282,15 +20970,15 @@ class JSONSchemaGenerator {
|
|
|
18282
20970
|
if (mime) {
|
|
18283
20971
|
if (mime.length === 1) {
|
|
18284
20972
|
file.contentMediaType = mime[0];
|
|
18285
|
-
Object.assign(
|
|
20973
|
+
Object.assign(json2, file);
|
|
18286
20974
|
} else {
|
|
18287
|
-
|
|
20975
|
+
json2.anyOf = mime.map((m2) => {
|
|
18288
20976
|
const mFile = { ...file, contentMediaType: m2 };
|
|
18289
20977
|
return mFile;
|
|
18290
20978
|
});
|
|
18291
20979
|
}
|
|
18292
20980
|
} else {
|
|
18293
|
-
Object.assign(
|
|
20981
|
+
Object.assign(json2, file);
|
|
18294
20982
|
}
|
|
18295
20983
|
break;
|
|
18296
20984
|
}
|
|
@@ -18316,8 +21004,8 @@ class JSONSchemaGenerator {
|
|
|
18316
21004
|
break;
|
|
18317
21005
|
}
|
|
18318
21006
|
case "success": {
|
|
18319
|
-
const
|
|
18320
|
-
|
|
21007
|
+
const json2 = _json;
|
|
21008
|
+
json2.type = "boolean";
|
|
18321
21009
|
break;
|
|
18322
21010
|
}
|
|
18323
21011
|
case "default": {
|
|
@@ -18352,12 +21040,12 @@ class JSONSchemaGenerator {
|
|
|
18352
21040
|
break;
|
|
18353
21041
|
}
|
|
18354
21042
|
case "template_literal": {
|
|
18355
|
-
const
|
|
18356
|
-
const pattern =
|
|
21043
|
+
const json2 = _json;
|
|
21044
|
+
const pattern = schema2._zod.pattern;
|
|
18357
21045
|
if (!pattern)
|
|
18358
21046
|
throw new Error("Pattern not found in template literal");
|
|
18359
|
-
|
|
18360
|
-
|
|
21047
|
+
json2.type = "string";
|
|
21048
|
+
json2.pattern = pattern.source;
|
|
18361
21049
|
break;
|
|
18362
21050
|
}
|
|
18363
21051
|
case "pipe": {
|
|
@@ -18383,7 +21071,7 @@ class JSONSchemaGenerator {
|
|
|
18383
21071
|
break;
|
|
18384
21072
|
}
|
|
18385
21073
|
case "lazy": {
|
|
18386
|
-
const innerType =
|
|
21074
|
+
const innerType = schema2._zod.innerType;
|
|
18387
21075
|
this.process(innerType, params);
|
|
18388
21076
|
result.ref = innerType;
|
|
18389
21077
|
break;
|
|
@@ -18404,26 +21092,26 @@ class JSONSchemaGenerator {
|
|
|
18404
21092
|
}
|
|
18405
21093
|
}
|
|
18406
21094
|
}
|
|
18407
|
-
const meta = this.metadataRegistry.get(
|
|
21095
|
+
const meta = this.metadataRegistry.get(schema2);
|
|
18408
21096
|
if (meta)
|
|
18409
21097
|
Object.assign(result.schema, meta);
|
|
18410
|
-
if (this.io === "input" && isTransforming(
|
|
21098
|
+
if (this.io === "input" && isTransforming(schema2)) {
|
|
18411
21099
|
delete result.schema.examples;
|
|
18412
21100
|
delete result.schema.default;
|
|
18413
21101
|
}
|
|
18414
21102
|
if (this.io === "input" && result.schema._prefault)
|
|
18415
21103
|
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
18416
21104
|
delete result.schema._prefault;
|
|
18417
|
-
const _result = this.seen.get(
|
|
21105
|
+
const _result = this.seen.get(schema2);
|
|
18418
21106
|
return _result.schema;
|
|
18419
21107
|
}
|
|
18420
|
-
emit(
|
|
21108
|
+
emit(schema2, _params) {
|
|
18421
21109
|
const params = {
|
|
18422
21110
|
cycles: _params?.cycles ?? "ref",
|
|
18423
21111
|
reused: _params?.reused ?? "inline",
|
|
18424
21112
|
external: _params?.external ?? undefined
|
|
18425
21113
|
};
|
|
18426
|
-
const root = this.seen.get(
|
|
21114
|
+
const root = this.seen.get(schema2);
|
|
18427
21115
|
if (!root)
|
|
18428
21116
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
18429
21117
|
const makeURI = (entry) => {
|
|
@@ -18455,11 +21143,11 @@ class JSONSchemaGenerator {
|
|
|
18455
21143
|
seen.def = { ...seen.schema };
|
|
18456
21144
|
if (defId)
|
|
18457
21145
|
seen.defId = defId;
|
|
18458
|
-
const
|
|
18459
|
-
for (const key in
|
|
18460
|
-
delete
|
|
21146
|
+
const schema3 = seen.schema;
|
|
21147
|
+
for (const key in schema3) {
|
|
21148
|
+
delete schema3[key];
|
|
18461
21149
|
}
|
|
18462
|
-
|
|
21150
|
+
schema3.$ref = ref;
|
|
18463
21151
|
};
|
|
18464
21152
|
if (params.cycles === "throw") {
|
|
18465
21153
|
for (const entry of this.seen.entries()) {
|
|
@@ -18471,13 +21159,13 @@ class JSONSchemaGenerator {
|
|
|
18471
21159
|
}
|
|
18472
21160
|
for (const entry of this.seen.entries()) {
|
|
18473
21161
|
const seen = entry[1];
|
|
18474
|
-
if (
|
|
21162
|
+
if (schema2 === entry[0]) {
|
|
18475
21163
|
extractToDef(entry);
|
|
18476
21164
|
continue;
|
|
18477
21165
|
}
|
|
18478
21166
|
if (params.external) {
|
|
18479
21167
|
const ext = params.external.registry.get(entry[0])?.id;
|
|
18480
|
-
if (
|
|
21168
|
+
if (schema2 !== entry[0] && ext) {
|
|
18481
21169
|
extractToDef(entry);
|
|
18482
21170
|
continue;
|
|
18483
21171
|
}
|
|
@@ -18500,8 +21188,8 @@ class JSONSchemaGenerator {
|
|
|
18500
21188
|
}
|
|
18501
21189
|
const flattenRef = (zodSchema, params2) => {
|
|
18502
21190
|
const seen = this.seen.get(zodSchema);
|
|
18503
|
-
const
|
|
18504
|
-
const _cached = { ...
|
|
21191
|
+
const schema3 = seen.def ?? seen.schema;
|
|
21192
|
+
const _cached = { ...schema3 };
|
|
18505
21193
|
if (seen.ref === null) {
|
|
18506
21194
|
return;
|
|
18507
21195
|
}
|
|
@@ -18511,17 +21199,17 @@ class JSONSchemaGenerator {
|
|
|
18511
21199
|
flattenRef(ref, params2);
|
|
18512
21200
|
const refSchema = this.seen.get(ref).schema;
|
|
18513
21201
|
if (refSchema.$ref && (params2.target === "draft-7" || params2.target === "draft-4" || params2.target === "openapi-3.0")) {
|
|
18514
|
-
|
|
18515
|
-
|
|
21202
|
+
schema3.allOf = schema3.allOf ?? [];
|
|
21203
|
+
schema3.allOf.push(refSchema);
|
|
18516
21204
|
} else {
|
|
18517
|
-
Object.assign(
|
|
18518
|
-
Object.assign(
|
|
21205
|
+
Object.assign(schema3, refSchema);
|
|
21206
|
+
Object.assign(schema3, _cached);
|
|
18519
21207
|
}
|
|
18520
21208
|
}
|
|
18521
21209
|
if (!seen.isParent)
|
|
18522
21210
|
this.override({
|
|
18523
21211
|
zodSchema,
|
|
18524
|
-
jsonSchema:
|
|
21212
|
+
jsonSchema: schema3,
|
|
18525
21213
|
path: seen.path ?? []
|
|
18526
21214
|
});
|
|
18527
21215
|
};
|
|
@@ -18539,7 +21227,7 @@ class JSONSchemaGenerator {
|
|
|
18539
21227
|
console.warn(`Invalid target: ${this.target}`);
|
|
18540
21228
|
}
|
|
18541
21229
|
if (params.external?.uri) {
|
|
18542
|
-
const id = params.external.registry.get(
|
|
21230
|
+
const id = params.external.registry.get(schema2)?.id;
|
|
18543
21231
|
if (!id)
|
|
18544
21232
|
throw new Error("Schema is missing an `id` property");
|
|
18545
21233
|
result.$id = params.external.uri(id);
|
|
@@ -18573,8 +21261,8 @@ function toJSONSchema(input, _params) {
|
|
|
18573
21261
|
const gen2 = new JSONSchemaGenerator(_params);
|
|
18574
21262
|
const defs = {};
|
|
18575
21263
|
for (const entry of input._idmap.entries()) {
|
|
18576
|
-
const [_3,
|
|
18577
|
-
gen2.process(
|
|
21264
|
+
const [_3, schema2] = entry;
|
|
21265
|
+
gen2.process(schema2);
|
|
18578
21266
|
}
|
|
18579
21267
|
const schemas = {};
|
|
18580
21268
|
const external = {
|
|
@@ -18583,8 +21271,8 @@ function toJSONSchema(input, _params) {
|
|
|
18583
21271
|
defs
|
|
18584
21272
|
};
|
|
18585
21273
|
for (const entry of input._idmap.entries()) {
|
|
18586
|
-
const [key,
|
|
18587
|
-
schemas[key] = gen2.emit(
|
|
21274
|
+
const [key, schema2] = entry;
|
|
21275
|
+
schemas[key] = gen2.emit(schema2, {
|
|
18588
21276
|
..._params,
|
|
18589
21277
|
external
|
|
18590
21278
|
});
|
|
@@ -18606,8 +21294,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
18606
21294
|
if (ctx.seen.has(_schema))
|
|
18607
21295
|
return false;
|
|
18608
21296
|
ctx.seen.add(_schema);
|
|
18609
|
-
const
|
|
18610
|
-
const def =
|
|
21297
|
+
const schema2 = _schema;
|
|
21298
|
+
const def = schema2._zod.def;
|
|
18611
21299
|
switch (def.type) {
|
|
18612
21300
|
case "string":
|
|
18613
21301
|
case "number":
|
|
@@ -18750,7 +21438,7 @@ var initializer2 = (inst, issues) => {
|
|
|
18750
21438
|
inst.name = "ZodError";
|
|
18751
21439
|
Object.defineProperties(inst, {
|
|
18752
21440
|
format: {
|
|
18753
|
-
value: (mapper) =>
|
|
21441
|
+
value: (mapper) => formatError2(inst, mapper)
|
|
18754
21442
|
},
|
|
18755
21443
|
flatten: {
|
|
18756
21444
|
value: (mapper) => flattenError(inst, mapper)
|
|
@@ -18838,7 +21526,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
18838
21526
|
inst.or = (arg) => union([inst, arg]);
|
|
18839
21527
|
inst.and = (arg) => intersection(inst, arg);
|
|
18840
21528
|
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
18841
|
-
inst.default = (def2) =>
|
|
21529
|
+
inst.default = (def2) => _default3(inst, def2);
|
|
18842
21530
|
inst.prefault = (def2) => prefault(inst, def2);
|
|
18843
21531
|
inst.catch = (params) => _catch2(inst, params);
|
|
18844
21532
|
inst.pipe = (target) => pipe(inst, target);
|
|
@@ -19105,8 +21793,8 @@ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
|
19105
21793
|
inst.lt = (value, params) => inst.check(_lt(value, params));
|
|
19106
21794
|
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
19107
21795
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
19108
|
-
inst.int = (params) => inst.check(
|
|
19109
|
-
inst.safe = (params) => inst.check(
|
|
21796
|
+
inst.int = (params) => inst.check(int2(params));
|
|
21797
|
+
inst.safe = (params) => inst.check(int2(params));
|
|
19110
21798
|
inst.positive = (params) => inst.check(_gt(0, params));
|
|
19111
21799
|
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
19112
21800
|
inst.negative = (params) => inst.check(_lt(0, params));
|
|
@@ -19128,7 +21816,7 @@ var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def
|
|
|
19128
21816
|
$ZodNumberFormat.init(inst, def);
|
|
19129
21817
|
ZodNumber.init(inst, def);
|
|
19130
21818
|
});
|
|
19131
|
-
function
|
|
21819
|
+
function int2(params) {
|
|
19132
21820
|
return _int(ZodNumberFormat, params);
|
|
19133
21821
|
}
|
|
19134
21822
|
function float32(params) {
|
|
@@ -19202,8 +21890,8 @@ var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
|
19202
21890
|
$ZodNull.init(inst, def);
|
|
19203
21891
|
ZodType.init(inst, def);
|
|
19204
21892
|
});
|
|
19205
|
-
function
|
|
19206
|
-
return
|
|
21893
|
+
function _null4(params) {
|
|
21894
|
+
return _null3(ZodNull, params);
|
|
19207
21895
|
}
|
|
19208
21896
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
19209
21897
|
$ZodAny.init(inst, def);
|
|
@@ -19258,8 +21946,8 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
19258
21946
|
function array(element, params) {
|
|
19259
21947
|
return _array(ZodArray, element, params);
|
|
19260
21948
|
}
|
|
19261
|
-
function keyof(
|
|
19262
|
-
const shape =
|
|
21949
|
+
function keyof(schema2) {
|
|
21950
|
+
const shape = schema2._zod.def.shape;
|
|
19263
21951
|
return _enum2(Object.keys(shape));
|
|
19264
21952
|
}
|
|
19265
21953
|
var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
@@ -19401,7 +22089,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
19401
22089
|
inst.keyType = def.keyType;
|
|
19402
22090
|
inst.valueType = def.valueType;
|
|
19403
22091
|
});
|
|
19404
|
-
function
|
|
22092
|
+
function map2(keyType, valueType, params) {
|
|
19405
22093
|
return new ZodMap({
|
|
19406
22094
|
type: "map",
|
|
19407
22095
|
keyType,
|
|
@@ -19417,7 +22105,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
|
19417
22105
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
19418
22106
|
inst.size = (...args) => inst.check(_size(...args));
|
|
19419
22107
|
});
|
|
19420
|
-
function
|
|
22108
|
+
function set2(valueType, params) {
|
|
19421
22109
|
return new ZodSet({
|
|
19422
22110
|
type: "set",
|
|
19423
22111
|
valueType,
|
|
@@ -19574,7 +22262,7 @@ var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
|
19574
22262
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
19575
22263
|
inst.removeDefault = inst.unwrap;
|
|
19576
22264
|
});
|
|
19577
|
-
function
|
|
22265
|
+
function _default3(innerType, defaultValue) {
|
|
19578
22266
|
return new ZodDefault({
|
|
19579
22267
|
type: "default",
|
|
19580
22268
|
innerType,
|
|
@@ -19759,14 +22447,14 @@ var stringbool = (...args) => _stringbool({
|
|
|
19759
22447
|
Boolean: ZodBoolean,
|
|
19760
22448
|
String: ZodString
|
|
19761
22449
|
}, ...args);
|
|
19762
|
-
function
|
|
22450
|
+
function json2(params) {
|
|
19763
22451
|
const jsonSchema = lazy(() => {
|
|
19764
|
-
return union([string2(params), number2(), boolean2(),
|
|
22452
|
+
return union([string2(params), number2(), boolean2(), _null4(), array(jsonSchema), record(string2(), jsonSchema)]);
|
|
19765
22453
|
});
|
|
19766
22454
|
return jsonSchema;
|
|
19767
22455
|
}
|
|
19768
|
-
function preprocess(fn,
|
|
19769
|
-
return pipe(transform(fn),
|
|
22456
|
+
function preprocess(fn, schema2) {
|
|
22457
|
+
return pipe(transform(fn), schema2);
|
|
19770
22458
|
}
|
|
19771
22459
|
// node_modules/zod/v4/classic/compat.js
|
|
19772
22460
|
var ZodIssueCode = {
|
|
@@ -19782,9 +22470,9 @@ var ZodIssueCode = {
|
|
|
19782
22470
|
invalid_value: "invalid_value",
|
|
19783
22471
|
custom: "custom"
|
|
19784
22472
|
};
|
|
19785
|
-
function setErrorMap(
|
|
22473
|
+
function setErrorMap(map3) {
|
|
19786
22474
|
config({
|
|
19787
|
-
customError:
|
|
22475
|
+
customError: map3
|
|
19788
22476
|
});
|
|
19789
22477
|
}
|
|
19790
22478
|
function getErrorMap() {
|
|
@@ -20033,7 +22721,7 @@ var OhMyOpenCodeConfigSchema = exports_external.object({
|
|
|
20033
22721
|
ralph_loop: RalphLoopConfigSchema.optional()
|
|
20034
22722
|
});
|
|
20035
22723
|
// src/cli/doctor/checks/config.ts
|
|
20036
|
-
var USER_CONFIG_DIR2 = join6(
|
|
22724
|
+
var USER_CONFIG_DIR2 = join6(homedir5(), ".config", "opencode");
|
|
20037
22725
|
var USER_CONFIG_BASE = join6(USER_CONFIG_DIR2, `${PACKAGE_NAME2}`);
|
|
20038
22726
|
var PROJECT_CONFIG_BASE = join6(process.cwd(), ".opencode", PACKAGE_NAME2);
|
|
20039
22727
|
function findConfigPath() {
|
|
@@ -20053,7 +22741,7 @@ function validateConfig(configPath) {
|
|
|
20053
22741
|
const rawConfig = parseJsonc(content);
|
|
20054
22742
|
const result = OhMyOpenCodeConfigSchema.safeParse(rawConfig);
|
|
20055
22743
|
if (!result.success) {
|
|
20056
|
-
const errors3 = result.error.issues.map((
|
|
22744
|
+
const errors3 = result.error.issues.map((i2) => `${i2.path.join(".")}: ${i2.message}`);
|
|
20057
22745
|
return { valid: false, errors: errors3 };
|
|
20058
22746
|
}
|
|
20059
22747
|
return { valid: true, errors: [] };
|
|
@@ -20075,7 +22763,7 @@ function getConfigInfo() {
|
|
|
20075
22763
|
errors: []
|
|
20076
22764
|
};
|
|
20077
22765
|
}
|
|
20078
|
-
if (!
|
|
22766
|
+
if (!existsSync6(configPath.path)) {
|
|
20079
22767
|
return {
|
|
20080
22768
|
exists: false,
|
|
20081
22769
|
path: configPath.path,
|
|
@@ -20132,10 +22820,10 @@ function getConfigCheckDefinition() {
|
|
|
20132
22820
|
}
|
|
20133
22821
|
|
|
20134
22822
|
// src/cli/doctor/checks/auth.ts
|
|
20135
|
-
import { existsSync as
|
|
20136
|
-
import { homedir as
|
|
22823
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
|
|
22824
|
+
import { homedir as homedir6 } from "os";
|
|
20137
22825
|
import { join as join7 } from "path";
|
|
20138
|
-
var OPENCODE_CONFIG_DIR3 = join7(
|
|
22826
|
+
var OPENCODE_CONFIG_DIR3 = join7(homedir6(), ".config", "opencode");
|
|
20139
22827
|
var OPENCODE_JSON3 = join7(OPENCODE_CONFIG_DIR3, "opencode.json");
|
|
20140
22828
|
var OPENCODE_JSONC3 = join7(OPENCODE_CONFIG_DIR3, "opencode.jsonc");
|
|
20141
22829
|
var AUTH_PLUGINS = {
|
|
@@ -20144,8 +22832,8 @@ var AUTH_PLUGINS = {
|
|
|
20144
22832
|
google: { plugin: "opencode-antigravity-auth", name: "Google (Gemini)" }
|
|
20145
22833
|
};
|
|
20146
22834
|
function getOpenCodeConfig() {
|
|
20147
|
-
const configPath =
|
|
20148
|
-
if (!
|
|
22835
|
+
const configPath = existsSync7(OPENCODE_JSONC3) ? OPENCODE_JSONC3 : OPENCODE_JSON3;
|
|
22836
|
+
if (!existsSync7(configPath))
|
|
20149
22837
|
return null;
|
|
20150
22838
|
try {
|
|
20151
22839
|
const content = readFileSync6(configPath, "utf-8");
|
|
@@ -20231,9 +22919,9 @@ function getAuthCheckDefinitions() {
|
|
|
20231
22919
|
}
|
|
20232
22920
|
|
|
20233
22921
|
// src/cli/doctor/checks/dependencies.ts
|
|
20234
|
-
async function checkBinaryExists(
|
|
22922
|
+
async function checkBinaryExists(binary2) {
|
|
20235
22923
|
try {
|
|
20236
|
-
const proc = Bun.spawn(["which",
|
|
22924
|
+
const proc = Bun.spawn(["which", binary2], { stdout: "pipe", stderr: "pipe" });
|
|
20237
22925
|
const output = await new Response(proc.stdout).text();
|
|
20238
22926
|
await proc.exited;
|
|
20239
22927
|
if (proc.exitCode === 0) {
|
|
@@ -20242,9 +22930,9 @@ async function checkBinaryExists(binary) {
|
|
|
20242
22930
|
} catch {}
|
|
20243
22931
|
return { exists: false, path: null };
|
|
20244
22932
|
}
|
|
20245
|
-
async function getBinaryVersion(
|
|
22933
|
+
async function getBinaryVersion(binary2) {
|
|
20246
22934
|
try {
|
|
20247
|
-
const proc = Bun.spawn([
|
|
22935
|
+
const proc = Bun.spawn([binary2, "--version"], { stdout: "pipe", stderr: "pipe" });
|
|
20248
22936
|
const output = await new Response(proc.stdout).text();
|
|
20249
22937
|
await proc.exited;
|
|
20250
22938
|
if (proc.exitCode === 0) {
|
|
@@ -20257,8 +22945,8 @@ async function getBinaryVersion(binary) {
|
|
|
20257
22945
|
async function checkAstGrepCli() {
|
|
20258
22946
|
const binaryCheck = await checkBinaryExists("sg");
|
|
20259
22947
|
const altBinaryCheck = !binaryCheck.exists ? await checkBinaryExists("ast-grep") : null;
|
|
20260
|
-
const
|
|
20261
|
-
if (!
|
|
22948
|
+
const binary2 = binaryCheck.exists ? binaryCheck : altBinaryCheck;
|
|
22949
|
+
if (!binary2 || !binary2.exists) {
|
|
20262
22950
|
return {
|
|
20263
22951
|
name: "AST-Grep CLI",
|
|
20264
22952
|
required: false,
|
|
@@ -20268,13 +22956,13 @@ async function checkAstGrepCli() {
|
|
|
20268
22956
|
installHint: "Install: npm install -g @ast-grep/cli"
|
|
20269
22957
|
};
|
|
20270
22958
|
}
|
|
20271
|
-
const version2 = await getBinaryVersion(
|
|
22959
|
+
const version2 = await getBinaryVersion(binary2.path);
|
|
20272
22960
|
return {
|
|
20273
22961
|
name: "AST-Grep CLI",
|
|
20274
22962
|
required: false,
|
|
20275
22963
|
installed: true,
|
|
20276
22964
|
version: version2,
|
|
20277
|
-
path:
|
|
22965
|
+
path: binary2.path
|
|
20278
22966
|
};
|
|
20279
22967
|
}
|
|
20280
22968
|
function checkAstGrepNapi() {
|
|
@@ -20374,9 +23062,9 @@ function getDependencyCheckDefinitions() {
|
|
|
20374
23062
|
}
|
|
20375
23063
|
|
|
20376
23064
|
// src/cli/doctor/checks/gh.ts
|
|
20377
|
-
async function checkBinaryExists2(
|
|
23065
|
+
async function checkBinaryExists2(binary2) {
|
|
20378
23066
|
try {
|
|
20379
|
-
const proc = Bun.spawn(["which",
|
|
23067
|
+
const proc = Bun.spawn(["which", binary2], { stdout: "pipe", stderr: "pipe" });
|
|
20380
23068
|
const output = await new Response(proc.stdout).text();
|
|
20381
23069
|
await proc.exited;
|
|
20382
23070
|
if (proc.exitCode === 0) {
|
|
@@ -20513,9 +23201,9 @@ var DEFAULT_LSP_SERVERS = [
|
|
|
20513
23201
|
{ id: "rust-analyzer", binary: "rust-analyzer", extensions: [".rs"] },
|
|
20514
23202
|
{ id: "gopls", binary: "gopls", extensions: [".go"] }
|
|
20515
23203
|
];
|
|
20516
|
-
async function checkBinaryExists3(
|
|
23204
|
+
async function checkBinaryExists3(binary2) {
|
|
20517
23205
|
try {
|
|
20518
|
-
const proc = Bun.spawn(["which",
|
|
23206
|
+
const proc = Bun.spawn(["which", binary2], { stdout: "pipe", stderr: "pipe" });
|
|
20519
23207
|
await proc.exited;
|
|
20520
23208
|
return proc.exitCode === 0;
|
|
20521
23209
|
} catch {
|
|
@@ -20577,19 +23265,19 @@ function getLspCheckDefinition() {
|
|
|
20577
23265
|
}
|
|
20578
23266
|
|
|
20579
23267
|
// src/cli/doctor/checks/mcp.ts
|
|
20580
|
-
import { existsSync as
|
|
20581
|
-
import { homedir as
|
|
23268
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7 } from "fs";
|
|
23269
|
+
import { homedir as homedir7 } from "os";
|
|
20582
23270
|
import { join as join8 } from "path";
|
|
20583
23271
|
var BUILTIN_MCP_SERVERS = ["context7", "websearch_exa", "grep_app"];
|
|
20584
23272
|
var MCP_CONFIG_PATHS = [
|
|
20585
|
-
join8(
|
|
23273
|
+
join8(homedir7(), ".claude", ".mcp.json"),
|
|
20586
23274
|
join8(process.cwd(), ".mcp.json"),
|
|
20587
23275
|
join8(process.cwd(), ".claude", ".mcp.json")
|
|
20588
23276
|
];
|
|
20589
23277
|
function loadUserMcpConfig() {
|
|
20590
23278
|
const servers = {};
|
|
20591
23279
|
for (const configPath of MCP_CONFIG_PATHS) {
|
|
20592
|
-
if (!
|
|
23280
|
+
if (!existsSync8(configPath))
|
|
20593
23281
|
continue;
|
|
20594
23282
|
try {
|
|
20595
23283
|
const content = readFileSync7(configPath, "utf-8");
|
|
@@ -20689,9 +23377,9 @@ function compareVersions2(current, latest) {
|
|
|
20689
23377
|
};
|
|
20690
23378
|
const curr = parseVersion(current);
|
|
20691
23379
|
const lat = parseVersion(latest);
|
|
20692
|
-
for (let
|
|
20693
|
-
const c = curr[
|
|
20694
|
-
const l2 = lat[
|
|
23380
|
+
for (let i2 = 0;i2 < Math.max(curr.length, lat.length); i2++) {
|
|
23381
|
+
const c = curr[i2] ?? 0;
|
|
23382
|
+
const l2 = lat[i2] ?? 0;
|
|
20695
23383
|
if (c < l2)
|
|
20696
23384
|
return false;
|
|
20697
23385
|
if (c > l2)
|