claude-threads 1.8.3 → 1.9.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/CHANGELOG.md +35 -0
- package/README.md +1 -1
- package/dist/index.js +768 -566
- package/dist/mcp/permission-server.js +2967 -263
- package/package.json +1 -1
|
@@ -15279,8 +15279,8 @@ var require_buffer_util = __commonJS((exports, module) => {
|
|
|
15279
15279
|
return list[0];
|
|
15280
15280
|
const target = Buffer.allocUnsafe(totalLength);
|
|
15281
15281
|
let offset = 0;
|
|
15282
|
-
for (let
|
|
15283
|
-
const buf = list[
|
|
15282
|
+
for (let i2 = 0;i2 < list.length; i2++) {
|
|
15283
|
+
const buf = list[i2];
|
|
15284
15284
|
target.set(buf, offset);
|
|
15285
15285
|
offset += buf.length;
|
|
15286
15286
|
}
|
|
@@ -15290,13 +15290,13 @@ var require_buffer_util = __commonJS((exports, module) => {
|
|
|
15290
15290
|
return target;
|
|
15291
15291
|
}
|
|
15292
15292
|
function _mask(source, mask, output, offset, length) {
|
|
15293
|
-
for (let
|
|
15294
|
-
output[offset +
|
|
15293
|
+
for (let i2 = 0;i2 < length; i2++) {
|
|
15294
|
+
output[offset + i2] = source[i2] ^ mask[i2 & 3];
|
|
15295
15295
|
}
|
|
15296
15296
|
}
|
|
15297
15297
|
function _unmask(buffer, mask) {
|
|
15298
|
-
for (let
|
|
15299
|
-
buffer[
|
|
15298
|
+
for (let i2 = 0;i2 < buffer.length; i2++) {
|
|
15299
|
+
buffer[i2] ^= mask[i2 & 3];
|
|
15300
15300
|
}
|
|
15301
15301
|
}
|
|
15302
15302
|
function toArrayBuffer(buf) {
|
|
@@ -15781,25 +15781,25 @@ var require_validation3 = __commonJS((exports, module) => {
|
|
|
15781
15781
|
}
|
|
15782
15782
|
function _isValidUTF8(buf) {
|
|
15783
15783
|
const len = buf.length;
|
|
15784
|
-
let
|
|
15785
|
-
while (
|
|
15786
|
-
if ((buf[
|
|
15787
|
-
|
|
15788
|
-
} else if ((buf[
|
|
15789
|
-
if (
|
|
15784
|
+
let i2 = 0;
|
|
15785
|
+
while (i2 < len) {
|
|
15786
|
+
if ((buf[i2] & 128) === 0) {
|
|
15787
|
+
i2++;
|
|
15788
|
+
} else if ((buf[i2] & 224) === 192) {
|
|
15789
|
+
if (i2 + 1 === len || (buf[i2 + 1] & 192) !== 128 || (buf[i2] & 254) === 192) {
|
|
15790
15790
|
return false;
|
|
15791
15791
|
}
|
|
15792
|
-
|
|
15793
|
-
} else if ((buf[
|
|
15794
|
-
if (
|
|
15792
|
+
i2 += 2;
|
|
15793
|
+
} else if ((buf[i2] & 240) === 224) {
|
|
15794
|
+
if (i2 + 2 >= len || (buf[i2 + 1] & 192) !== 128 || (buf[i2 + 2] & 192) !== 128 || buf[i2] === 224 && (buf[i2 + 1] & 224) === 128 || buf[i2] === 237 && (buf[i2 + 1] & 224) === 160) {
|
|
15795
15795
|
return false;
|
|
15796
15796
|
}
|
|
15797
|
-
|
|
15798
|
-
} else if ((buf[
|
|
15799
|
-
if (
|
|
15797
|
+
i2 += 3;
|
|
15798
|
+
} else if ((buf[i2] & 248) === 240) {
|
|
15799
|
+
if (i2 + 3 >= len || (buf[i2 + 1] & 192) !== 128 || (buf[i2 + 2] & 192) !== 128 || (buf[i2 + 3] & 192) !== 128 || buf[i2] === 240 && (buf[i2 + 1] & 240) === 128 || buf[i2] === 244 && buf[i2 + 1] > 143 || buf[i2] > 244) {
|
|
15800
15800
|
return false;
|
|
15801
15801
|
}
|
|
15802
|
-
|
|
15802
|
+
i2 += 4;
|
|
15803
15803
|
} else {
|
|
15804
15804
|
return false;
|
|
15805
15805
|
}
|
|
@@ -16245,7 +16245,7 @@ var require_sender = __commonJS((exports, module) => {
|
|
|
16245
16245
|
}
|
|
16246
16246
|
static frame(data, options2) {
|
|
16247
16247
|
let mask;
|
|
16248
|
-
let
|
|
16248
|
+
let merge4 = false;
|
|
16249
16249
|
let offset = 2;
|
|
16250
16250
|
let skipMasking = false;
|
|
16251
16251
|
if (options2.mask) {
|
|
@@ -16278,7 +16278,7 @@ var require_sender = __commonJS((exports, module) => {
|
|
|
16278
16278
|
}
|
|
16279
16279
|
} else {
|
|
16280
16280
|
dataLength = data.length;
|
|
16281
|
-
|
|
16281
|
+
merge4 = options2.mask && options2.readOnly && !skipMasking;
|
|
16282
16282
|
}
|
|
16283
16283
|
let payloadLength = dataLength;
|
|
16284
16284
|
if (dataLength >= 65536) {
|
|
@@ -16288,7 +16288,7 @@ var require_sender = __commonJS((exports, module) => {
|
|
|
16288
16288
|
offset += 2;
|
|
16289
16289
|
payloadLength = 126;
|
|
16290
16290
|
}
|
|
16291
|
-
const target = Buffer.allocUnsafe(
|
|
16291
|
+
const target = Buffer.allocUnsafe(merge4 ? dataLength + offset : offset);
|
|
16292
16292
|
target[0] = options2.fin ? options2.opcode | 128 : options2.opcode;
|
|
16293
16293
|
if (options2.rsv1)
|
|
16294
16294
|
target[0] |= 64;
|
|
@@ -16308,7 +16308,7 @@ var require_sender = __commonJS((exports, module) => {
|
|
|
16308
16308
|
target[offset - 1] = mask[3];
|
|
16309
16309
|
if (skipMasking)
|
|
16310
16310
|
return [target, data];
|
|
16311
|
-
if (
|
|
16311
|
+
if (merge4) {
|
|
16312
16312
|
applyMask(data, mask, target, offset, dataLength);
|
|
16313
16313
|
return [target];
|
|
16314
16314
|
}
|
|
@@ -16551,8 +16551,8 @@ var require_sender = __commonJS((exports, module) => {
|
|
|
16551
16551
|
function callCallbacks(sender, err, cb) {
|
|
16552
16552
|
if (typeof cb === "function")
|
|
16553
16553
|
cb(err);
|
|
16554
|
-
for (let
|
|
16555
|
-
const params = sender._queue[
|
|
16554
|
+
for (let i2 = 0;i2 < sender._queue.length; i2++) {
|
|
16555
|
+
const params = sender._queue[i2];
|
|
16556
16556
|
const callback = params[params.length - 1];
|
|
16557
16557
|
if (typeof callback === "function")
|
|
16558
16558
|
callback(err);
|
|
@@ -16577,9 +16577,9 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16577
16577
|
var kWasClean = Symbol("kWasClean");
|
|
16578
16578
|
|
|
16579
16579
|
class Event {
|
|
16580
|
-
constructor(
|
|
16580
|
+
constructor(type2) {
|
|
16581
16581
|
this[kTarget] = null;
|
|
16582
|
-
this[kType] =
|
|
16582
|
+
this[kType] = type2;
|
|
16583
16583
|
}
|
|
16584
16584
|
get target() {
|
|
16585
16585
|
return this[kTarget];
|
|
@@ -16592,8 +16592,8 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16592
16592
|
Object.defineProperty(Event.prototype, "type", { enumerable: true });
|
|
16593
16593
|
|
|
16594
16594
|
class CloseEvent extends Event {
|
|
16595
|
-
constructor(
|
|
16596
|
-
super(
|
|
16595
|
+
constructor(type2, options2 = {}) {
|
|
16596
|
+
super(type2);
|
|
16597
16597
|
this[kCode] = options2.code === undefined ? 0 : options2.code;
|
|
16598
16598
|
this[kReason] = options2.reason === undefined ? "" : options2.reason;
|
|
16599
16599
|
this[kWasClean] = options2.wasClean === undefined ? false : options2.wasClean;
|
|
@@ -16613,8 +16613,8 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16613
16613
|
Object.defineProperty(CloseEvent.prototype, "wasClean", { enumerable: true });
|
|
16614
16614
|
|
|
16615
16615
|
class ErrorEvent extends Event {
|
|
16616
|
-
constructor(
|
|
16617
|
-
super(
|
|
16616
|
+
constructor(type2, options2 = {}) {
|
|
16617
|
+
super(type2);
|
|
16618
16618
|
this[kError] = options2.error === undefined ? null : options2.error;
|
|
16619
16619
|
this[kMessage] = options2.message === undefined ? "" : options2.message;
|
|
16620
16620
|
}
|
|
@@ -16629,8 +16629,8 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16629
16629
|
Object.defineProperty(ErrorEvent.prototype, "message", { enumerable: true });
|
|
16630
16630
|
|
|
16631
16631
|
class MessageEvent extends Event {
|
|
16632
|
-
constructor(
|
|
16633
|
-
super(
|
|
16632
|
+
constructor(type2, options2 = {}) {
|
|
16633
|
+
super(type2);
|
|
16634
16634
|
this[kData] = options2.data === undefined ? null : options2.data;
|
|
16635
16635
|
}
|
|
16636
16636
|
get data() {
|
|
@@ -16639,22 +16639,22 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16639
16639
|
}
|
|
16640
16640
|
Object.defineProperty(MessageEvent.prototype, "data", { enumerable: true });
|
|
16641
16641
|
var EventTarget = {
|
|
16642
|
-
addEventListener(
|
|
16643
|
-
for (const listener of this.listeners(
|
|
16642
|
+
addEventListener(type2, handler2, options2 = {}) {
|
|
16643
|
+
for (const listener of this.listeners(type2)) {
|
|
16644
16644
|
if (!options2[kForOnEventAttribute] && listener[kListener] === handler2 && !listener[kForOnEventAttribute]) {
|
|
16645
16645
|
return;
|
|
16646
16646
|
}
|
|
16647
16647
|
}
|
|
16648
16648
|
let wrapper;
|
|
16649
|
-
if (
|
|
16650
|
-
wrapper = function onMessage(data,
|
|
16649
|
+
if (type2 === "message") {
|
|
16650
|
+
wrapper = function onMessage(data, isBinary2) {
|
|
16651
16651
|
const event = new MessageEvent("message", {
|
|
16652
|
-
data:
|
|
16652
|
+
data: isBinary2 ? data : data.toString()
|
|
16653
16653
|
});
|
|
16654
16654
|
event[kTarget] = this;
|
|
16655
16655
|
callListener(handler2, this, event);
|
|
16656
16656
|
};
|
|
16657
|
-
} else if (
|
|
16657
|
+
} else if (type2 === "close") {
|
|
16658
16658
|
wrapper = function onClose(code, message) {
|
|
16659
16659
|
const event = new CloseEvent("close", {
|
|
16660
16660
|
code,
|
|
@@ -16664,7 +16664,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16664
16664
|
event[kTarget] = this;
|
|
16665
16665
|
callListener(handler2, this, event);
|
|
16666
16666
|
};
|
|
16667
|
-
} else if (
|
|
16667
|
+
} else if (type2 === "error") {
|
|
16668
16668
|
wrapper = function onError(error49) {
|
|
16669
16669
|
const event = new ErrorEvent("error", {
|
|
16670
16670
|
error: error49,
|
|
@@ -16673,7 +16673,7 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16673
16673
|
event[kTarget] = this;
|
|
16674
16674
|
callListener(handler2, this, event);
|
|
16675
16675
|
};
|
|
16676
|
-
} else if (
|
|
16676
|
+
} else if (type2 === "open") {
|
|
16677
16677
|
wrapper = function onOpen() {
|
|
16678
16678
|
const event = new Event("open");
|
|
16679
16679
|
event[kTarget] = this;
|
|
@@ -16685,15 +16685,15 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
16685
16685
|
wrapper[kForOnEventAttribute] = !!options2[kForOnEventAttribute];
|
|
16686
16686
|
wrapper[kListener] = handler2;
|
|
16687
16687
|
if (options2.once) {
|
|
16688
|
-
this.once(
|
|
16688
|
+
this.once(type2, wrapper);
|
|
16689
16689
|
} else {
|
|
16690
|
-
this.on(
|
|
16690
|
+
this.on(type2, wrapper);
|
|
16691
16691
|
}
|
|
16692
16692
|
},
|
|
16693
|
-
removeEventListener(
|
|
16694
|
-
for (const listener of this.listeners(
|
|
16693
|
+
removeEventListener(type2, handler2) {
|
|
16694
|
+
for (const listener of this.listeners(type2)) {
|
|
16695
16695
|
if (listener[kListener] === handler2 && !listener[kForOnEventAttribute]) {
|
|
16696
|
-
this.removeListener(
|
|
16696
|
+
this.removeListener(type2, listener);
|
|
16697
16697
|
break;
|
|
16698
16698
|
}
|
|
16699
16699
|
}
|
|
@@ -16735,22 +16735,22 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
16735
16735
|
let start = -1;
|
|
16736
16736
|
let code = -1;
|
|
16737
16737
|
let end = -1;
|
|
16738
|
-
let
|
|
16739
|
-
for (;
|
|
16740
|
-
code = header.charCodeAt(
|
|
16738
|
+
let i2 = 0;
|
|
16739
|
+
for (;i2 < header.length; i2++) {
|
|
16740
|
+
code = header.charCodeAt(i2);
|
|
16741
16741
|
if (extensionName === undefined) {
|
|
16742
16742
|
if (end === -1 && tokenChars[code] === 1) {
|
|
16743
16743
|
if (start === -1)
|
|
16744
|
-
start =
|
|
16745
|
-
} else if (
|
|
16744
|
+
start = i2;
|
|
16745
|
+
} else if (i2 !== 0 && (code === 32 || code === 9)) {
|
|
16746
16746
|
if (end === -1 && start !== -1)
|
|
16747
|
-
end =
|
|
16747
|
+
end = i2;
|
|
16748
16748
|
} else if (code === 59 || code === 44) {
|
|
16749
16749
|
if (start === -1) {
|
|
16750
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16750
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16751
16751
|
}
|
|
16752
16752
|
if (end === -1)
|
|
16753
|
-
end =
|
|
16753
|
+
end = i2;
|
|
16754
16754
|
const name = header.slice(start, end);
|
|
16755
16755
|
if (code === 44) {
|
|
16756
16756
|
push(offers, name, params);
|
|
@@ -16760,21 +16760,21 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
16760
16760
|
}
|
|
16761
16761
|
start = end = -1;
|
|
16762
16762
|
} else {
|
|
16763
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16763
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16764
16764
|
}
|
|
16765
16765
|
} else if (paramName === undefined) {
|
|
16766
16766
|
if (end === -1 && tokenChars[code] === 1) {
|
|
16767
16767
|
if (start === -1)
|
|
16768
|
-
start =
|
|
16768
|
+
start = i2;
|
|
16769
16769
|
} else if (code === 32 || code === 9) {
|
|
16770
16770
|
if (end === -1 && start !== -1)
|
|
16771
|
-
end =
|
|
16771
|
+
end = i2;
|
|
16772
16772
|
} else if (code === 59 || code === 44) {
|
|
16773
16773
|
if (start === -1) {
|
|
16774
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16774
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16775
16775
|
}
|
|
16776
16776
|
if (end === -1)
|
|
16777
|
-
end =
|
|
16777
|
+
end = i2;
|
|
16778
16778
|
push(params, header.slice(start, end), true);
|
|
16779
16779
|
if (code === 44) {
|
|
16780
16780
|
push(offers, extensionName, params);
|
|
@@ -16783,47 +16783,47 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
16783
16783
|
}
|
|
16784
16784
|
start = end = -1;
|
|
16785
16785
|
} else if (code === 61 && start !== -1 && end === -1) {
|
|
16786
|
-
paramName = header.slice(start,
|
|
16786
|
+
paramName = header.slice(start, i2);
|
|
16787
16787
|
start = end = -1;
|
|
16788
16788
|
} else {
|
|
16789
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16789
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16790
16790
|
}
|
|
16791
16791
|
} else {
|
|
16792
16792
|
if (isEscaping) {
|
|
16793
16793
|
if (tokenChars[code] !== 1) {
|
|
16794
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16794
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16795
16795
|
}
|
|
16796
16796
|
if (start === -1)
|
|
16797
|
-
start =
|
|
16797
|
+
start = i2;
|
|
16798
16798
|
else if (!mustUnescape)
|
|
16799
16799
|
mustUnescape = true;
|
|
16800
16800
|
isEscaping = false;
|
|
16801
16801
|
} else if (inQuotes) {
|
|
16802
16802
|
if (tokenChars[code] === 1) {
|
|
16803
16803
|
if (start === -1)
|
|
16804
|
-
start =
|
|
16804
|
+
start = i2;
|
|
16805
16805
|
} else if (code === 34 && start !== -1) {
|
|
16806
16806
|
inQuotes = false;
|
|
16807
|
-
end =
|
|
16807
|
+
end = i2;
|
|
16808
16808
|
} else if (code === 92) {
|
|
16809
16809
|
isEscaping = true;
|
|
16810
16810
|
} else {
|
|
16811
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16811
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16812
16812
|
}
|
|
16813
|
-
} else if (code === 34 && header.charCodeAt(
|
|
16813
|
+
} else if (code === 34 && header.charCodeAt(i2 - 1) === 61) {
|
|
16814
16814
|
inQuotes = true;
|
|
16815
16815
|
} else if (end === -1 && tokenChars[code] === 1) {
|
|
16816
16816
|
if (start === -1)
|
|
16817
|
-
start =
|
|
16817
|
+
start = i2;
|
|
16818
16818
|
} else if (start !== -1 && (code === 32 || code === 9)) {
|
|
16819
16819
|
if (end === -1)
|
|
16820
|
-
end =
|
|
16820
|
+
end = i2;
|
|
16821
16821
|
} else if (code === 59 || code === 44) {
|
|
16822
16822
|
if (start === -1) {
|
|
16823
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16823
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16824
16824
|
}
|
|
16825
16825
|
if (end === -1)
|
|
16826
|
-
end =
|
|
16826
|
+
end = i2;
|
|
16827
16827
|
let value = header.slice(start, end);
|
|
16828
16828
|
if (mustUnescape) {
|
|
16829
16829
|
value = value.replace(/\\/g, "");
|
|
@@ -16838,7 +16838,7 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
16838
16838
|
paramName = undefined;
|
|
16839
16839
|
start = end = -1;
|
|
16840
16840
|
} else {
|
|
16841
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
16841
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
16842
16842
|
}
|
|
16843
16843
|
}
|
|
16844
16844
|
}
|
|
@@ -16846,7 +16846,7 @@ var require_extension = __commonJS((exports, module) => {
|
|
|
16846
16846
|
throw new SyntaxError("Unexpected end of input");
|
|
16847
16847
|
}
|
|
16848
16848
|
if (end === -1)
|
|
16849
|
-
end =
|
|
16849
|
+
end = i2;
|
|
16850
16850
|
const token = header.slice(start, end);
|
|
16851
16851
|
if (extensionName === undefined) {
|
|
16852
16852
|
push(offers, token, params);
|
|
@@ -16955,12 +16955,12 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
16955
16955
|
get binaryType() {
|
|
16956
16956
|
return this._binaryType;
|
|
16957
16957
|
}
|
|
16958
|
-
set binaryType(
|
|
16959
|
-
if (!BINARY_TYPES.includes(
|
|
16958
|
+
set binaryType(type2) {
|
|
16959
|
+
if (!BINARY_TYPES.includes(type2))
|
|
16960
16960
|
return;
|
|
16961
|
-
this._binaryType =
|
|
16961
|
+
this._binaryType = type2;
|
|
16962
16962
|
if (this._receiver)
|
|
16963
|
-
this._receiver._binaryType =
|
|
16963
|
+
this._receiver._binaryType = type2;
|
|
16964
16964
|
}
|
|
16965
16965
|
get bufferedAmount() {
|
|
16966
16966
|
if (!this._socket)
|
|
@@ -17565,8 +17565,8 @@ var require_websocket = __commonJS((exports, module) => {
|
|
|
17565
17565
|
function receiverOnFinish() {
|
|
17566
17566
|
this[kWebSocket].emitClose();
|
|
17567
17567
|
}
|
|
17568
|
-
function receiverOnMessage(data,
|
|
17569
|
-
this[kWebSocket].emit("message", data,
|
|
17568
|
+
function receiverOnMessage(data, isBinary2) {
|
|
17569
|
+
this[kWebSocket].emit("message", data, isBinary2);
|
|
17570
17570
|
}
|
|
17571
17571
|
function receiverOnPing(data) {
|
|
17572
17572
|
const websocket = this[kWebSocket];
|
|
@@ -17667,8 +17667,8 @@ var require_stream = __commonJS((exports, module) => {
|
|
|
17667
17667
|
objectMode: false,
|
|
17668
17668
|
writableObjectMode: false
|
|
17669
17669
|
});
|
|
17670
|
-
ws.on("message", function message(msg,
|
|
17671
|
-
const data = !
|
|
17670
|
+
ws.on("message", function message(msg, isBinary2) {
|
|
17671
|
+
const data = !isBinary2 && duplex._readableState.objectMode ? msg.toString() : msg;
|
|
17672
17672
|
if (!duplex.push(data))
|
|
17673
17673
|
ws.pause();
|
|
17674
17674
|
});
|
|
@@ -17749,21 +17749,21 @@ var require_subprotocol = __commonJS((exports, module) => {
|
|
|
17749
17749
|
const protocols = new Set;
|
|
17750
17750
|
let start = -1;
|
|
17751
17751
|
let end = -1;
|
|
17752
|
-
let
|
|
17753
|
-
for (
|
|
17754
|
-
const code = header.charCodeAt(
|
|
17752
|
+
let i2 = 0;
|
|
17753
|
+
for (i2;i2 < header.length; i2++) {
|
|
17754
|
+
const code = header.charCodeAt(i2);
|
|
17755
17755
|
if (end === -1 && tokenChars[code] === 1) {
|
|
17756
17756
|
if (start === -1)
|
|
17757
|
-
start =
|
|
17758
|
-
} else if (
|
|
17757
|
+
start = i2;
|
|
17758
|
+
} else if (i2 !== 0 && (code === 32 || code === 9)) {
|
|
17759
17759
|
if (end === -1 && start !== -1)
|
|
17760
|
-
end =
|
|
17760
|
+
end = i2;
|
|
17761
17761
|
} else if (code === 44) {
|
|
17762
17762
|
if (start === -1) {
|
|
17763
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
17763
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
17764
17764
|
}
|
|
17765
17765
|
if (end === -1)
|
|
17766
|
-
end =
|
|
17766
|
+
end = i2;
|
|
17767
17767
|
const protocol2 = header.slice(start, end);
|
|
17768
17768
|
if (protocols.has(protocol2)) {
|
|
17769
17769
|
throw new SyntaxError(`The "${protocol2}" subprotocol is duplicated`);
|
|
@@ -17771,13 +17771,13 @@ var require_subprotocol = __commonJS((exports, module) => {
|
|
|
17771
17771
|
protocols.add(protocol2);
|
|
17772
17772
|
start = end = -1;
|
|
17773
17773
|
} else {
|
|
17774
|
-
throw new SyntaxError(`Unexpected character at index ${
|
|
17774
|
+
throw new SyntaxError(`Unexpected character at index ${i2}`);
|
|
17775
17775
|
}
|
|
17776
17776
|
}
|
|
17777
17777
|
if (start === -1 || end !== -1) {
|
|
17778
17778
|
throw new SyntaxError("Unexpected end of input");
|
|
17779
17779
|
}
|
|
17780
|
-
const protocol = header.slice(start,
|
|
17780
|
+
const protocol = header.slice(start, i2);
|
|
17781
17781
|
if (protocols.has(protocol)) {
|
|
17782
17782
|
throw new SyntaxError(`The "${protocol}" subprotocol is duplicated`);
|
|
17783
17783
|
}
|
|
@@ -18046,12 +18046,12 @@ var require_websocket_server = __commonJS((exports, module) => {
|
|
|
18046
18046
|
}
|
|
18047
18047
|
}
|
|
18048
18048
|
module.exports = WebSocketServer;
|
|
18049
|
-
function addListeners(server,
|
|
18050
|
-
for (const event of Object.keys(
|
|
18051
|
-
server.on(event,
|
|
18049
|
+
function addListeners(server, map4) {
|
|
18050
|
+
for (const event of Object.keys(map4))
|
|
18051
|
+
server.on(event, map4[event]);
|
|
18052
18052
|
return function removeListeners() {
|
|
18053
|
-
for (const event of Object.keys(
|
|
18054
|
-
server.removeListener(event,
|
|
18053
|
+
for (const event of Object.keys(map4)) {
|
|
18054
|
+
server.removeListener(event, map4[event]);
|
|
18055
18055
|
}
|
|
18056
18056
|
};
|
|
18057
18057
|
}
|
|
@@ -50665,6 +50665,18 @@ class ContentExecutor extends BaseExecutor {
|
|
|
50665
50665
|
}
|
|
50666
50666
|
this.state = this.getInitialState();
|
|
50667
50667
|
}
|
|
50668
|
+
async tryUpdatePost(ctx, postId, content, logTag, successDetails, failureDetails, onSuccess, onFailure) {
|
|
50669
|
+
try {
|
|
50670
|
+
await ctx.platform.updatePost(postId, content);
|
|
50671
|
+
onSuccess();
|
|
50672
|
+
ctx.threadLogger?.logExecutor("content", "update", postId, successDetails, logTag);
|
|
50673
|
+
} catch (err) {
|
|
50674
|
+
ctx.logger.debug(`Update failed (${logTag}): ${err}`);
|
|
50675
|
+
const resolvedFailureDetails = typeof failureDetails === "function" ? failureDetails(err) : failureDetails;
|
|
50676
|
+
ctx.threadLogger?.logExecutor("content", "error", postId, resolvedFailureDetails, logTag);
|
|
50677
|
+
onFailure();
|
|
50678
|
+
}
|
|
50679
|
+
}
|
|
50668
50680
|
closeCurrentPost(ctx) {
|
|
50669
50681
|
const oldPostId = this.state.currentPostId;
|
|
50670
50682
|
const contentLength = this.state.currentPostContent.length;
|
|
@@ -50763,23 +50775,13 @@ class ContentExecutor extends BaseExecutor {
|
|
|
50763
50775
|
await this.createNewPost(ctx, content, pendingAtFlushStart);
|
|
50764
50776
|
return;
|
|
50765
50777
|
}
|
|
50766
|
-
|
|
50767
|
-
await ctx.platform.updatePost(postId, combinedContent2);
|
|
50778
|
+
await this.tryUpdatePost(ctx, postId, combinedContent2, "flush", { newContentLength: content.length, combinedLength: combinedContent2.length }, (err) => ({ failedOp: "updatePost", error: String(err) }), () => {
|
|
50768
50779
|
this.state.currentPostContent = combinedContent2;
|
|
50769
50780
|
this.clearFlushedContent(pendingAtFlushStart);
|
|
50770
|
-
|
|
50771
|
-
newContentLength: content.length,
|
|
50772
|
-
combinedLength: combinedContent2.length
|
|
50773
|
-
}, "flush");
|
|
50774
|
-
} catch (err) {
|
|
50775
|
-
ctx.logger.debug(`Update failed, will create new post on next flush: ${err}`);
|
|
50776
|
-
ctx.threadLogger?.logExecutor("content", "error", postId, {
|
|
50777
|
-
failedOp: "updatePost",
|
|
50778
|
-
error: String(err)
|
|
50779
|
-
}, "flush");
|
|
50781
|
+
}, () => {
|
|
50780
50782
|
this.state.currentPostId = null;
|
|
50781
50783
|
this.state.currentPostContent = "";
|
|
50782
|
-
}
|
|
50784
|
+
});
|
|
50783
50785
|
} else {
|
|
50784
50786
|
const chunks = splitContentForHeight(content, ctx.contentBreaker);
|
|
50785
50787
|
ctx.threadLogger?.logExecutor("content", "create_start", "none", {
|
|
@@ -50840,21 +50842,13 @@ class ContentExecutor extends BaseExecutor {
|
|
|
50840
50842
|
breakPoint = bestBreakPoint;
|
|
50841
50843
|
} else {
|
|
50842
50844
|
if (this.state.currentPostId) {
|
|
50843
|
-
|
|
50844
|
-
|
|
50845
|
+
const postId = this.state.currentPostId;
|
|
50846
|
+
await this.tryUpdatePost(ctx, postId, content, "handleSplit", { reason: "soft_break_no_breakpoint", contentLength: content.length }, { reason: "soft_break_no_breakpoint_failed" }, () => {
|
|
50845
50847
|
this.state.currentPostContent = content;
|
|
50846
50848
|
this.clearFlushedContent(pendingAtFlushStart);
|
|
50847
|
-
|
|
50848
|
-
reason: "soft_break_no_breakpoint",
|
|
50849
|
-
contentLength: content.length
|
|
50850
|
-
}, "handleSplit");
|
|
50851
|
-
} catch {
|
|
50852
|
-
ctx.logger.debug("Update failed (no breakpoint), will create new post on next flush");
|
|
50853
|
-
ctx.threadLogger?.logExecutor("content", "error", this.state.currentPostId, {
|
|
50854
|
-
reason: "soft_break_no_breakpoint_failed"
|
|
50855
|
-
}, "handleSplit");
|
|
50849
|
+
}, () => {
|
|
50856
50850
|
this.state.currentPostId = null;
|
|
50857
|
-
}
|
|
50851
|
+
});
|
|
50858
50852
|
}
|
|
50859
50853
|
return;
|
|
50860
50854
|
}
|
|
@@ -50862,22 +50856,14 @@ class ContentExecutor extends BaseExecutor {
|
|
|
50862
50856
|
if (codeBlockOpenPosition !== undefined) {
|
|
50863
50857
|
if (codeBlockOpenPosition === 0) {
|
|
50864
50858
|
if (this.state.currentPostId) {
|
|
50865
|
-
|
|
50866
|
-
|
|
50859
|
+
const postId = this.state.currentPostId;
|
|
50860
|
+
await this.tryUpdatePost(ctx, postId, content, "handleSplit", { reason: "code_block_at_start", contentLength: content.length }, { reason: "code_block_at_start_failed" }, () => {
|
|
50867
50861
|
this.state.currentPostContent = content;
|
|
50868
50862
|
this.clearFlushedContent(pendingAtFlushStart);
|
|
50869
|
-
|
|
50870
|
-
reason: "code_block_at_start",
|
|
50871
|
-
contentLength: content.length
|
|
50872
|
-
}, "handleSplit");
|
|
50873
|
-
} catch {
|
|
50874
|
-
ctx.logger.debug("Update failed (code block at start)");
|
|
50875
|
-
ctx.threadLogger?.logExecutor("content", "error", this.state.currentPostId, {
|
|
50876
|
-
reason: "code_block_at_start_failed"
|
|
50877
|
-
}, "handleSplit");
|
|
50863
|
+
}, () => {
|
|
50878
50864
|
this.state.currentPostId = null;
|
|
50879
50865
|
this.state.currentPostContent = "";
|
|
50880
|
-
}
|
|
50866
|
+
});
|
|
50881
50867
|
}
|
|
50882
50868
|
return;
|
|
50883
50869
|
}
|
|
@@ -50887,22 +50873,14 @@ class ContentExecutor extends BaseExecutor {
|
|
|
50887
50873
|
breakPoint = breakBeforeCodeBlock;
|
|
50888
50874
|
} else {
|
|
50889
50875
|
if (this.state.currentPostId) {
|
|
50890
|
-
|
|
50891
|
-
|
|
50876
|
+
const postId = this.state.currentPostId;
|
|
50877
|
+
await this.tryUpdatePost(ctx, postId, content, "handleSplit", { reason: "no_break_before_code_block", contentLength: content.length }, { reason: "no_break_before_code_block_failed" }, () => {
|
|
50892
50878
|
this.state.currentPostContent = content;
|
|
50893
50879
|
this.clearFlushedContent(pendingAtFlushStart);
|
|
50894
|
-
|
|
50895
|
-
reason: "no_break_before_code_block",
|
|
50896
|
-
contentLength: content.length
|
|
50897
|
-
}, "handleSplit");
|
|
50898
|
-
} catch {
|
|
50899
|
-
ctx.logger.debug("Update failed (no break before code block)");
|
|
50900
|
-
ctx.threadLogger?.logExecutor("content", "error", this.state.currentPostId, {
|
|
50901
|
-
reason: "no_break_before_code_block_failed"
|
|
50902
|
-
}, "handleSplit");
|
|
50880
|
+
}, () => {
|
|
50903
50881
|
this.state.currentPostId = null;
|
|
50904
50882
|
this.state.currentPostContent = "";
|
|
50905
|
-
}
|
|
50883
|
+
});
|
|
50906
50884
|
}
|
|
50907
50885
|
return;
|
|
50908
50886
|
}
|
|
@@ -50910,19 +50888,8 @@ class ContentExecutor extends BaseExecutor {
|
|
|
50910
50888
|
const firstPart = content.substring(0, breakPoint).trim();
|
|
50911
50889
|
const remainder = content.substring(breakPoint).trim();
|
|
50912
50890
|
if (this.state.currentPostId) {
|
|
50913
|
-
|
|
50914
|
-
|
|
50915
|
-
ctx.threadLogger?.logExecutor("content", "update", this.state.currentPostId, {
|
|
50916
|
-
reason: "split_first_part",
|
|
50917
|
-
firstPartLength: firstPart.length,
|
|
50918
|
-
remainderLength: remainder.length
|
|
50919
|
-
}, "handleSplit");
|
|
50920
|
-
} catch {
|
|
50921
|
-
ctx.logger.debug("Update failed during split, continuing with new post");
|
|
50922
|
-
ctx.threadLogger?.logExecutor("content", "error", this.state.currentPostId, {
|
|
50923
|
-
reason: "split_first_part_failed"
|
|
50924
|
-
}, "handleSplit");
|
|
50925
|
-
}
|
|
50891
|
+
const postId = this.state.currentPostId;
|
|
50892
|
+
await this.tryUpdatePost(ctx, postId, firstPart, "handleSplit", { reason: "split_first_part", firstPartLength: firstPart.length, remainderLength: remainder.length }, { reason: "split_first_part_failed" }, () => {}, () => {});
|
|
50926
50893
|
}
|
|
50927
50894
|
this.state.currentPostId = null;
|
|
50928
50895
|
this.state.currentPostContent = "";
|
|
@@ -52440,7 +52407,8 @@ class MessageManager {
|
|
|
52440
52407
|
emitSessionUpdateCallback;
|
|
52441
52408
|
toolStartTimes = new Map;
|
|
52442
52409
|
flushTimer = null;
|
|
52443
|
-
static
|
|
52410
|
+
static DEFAULT_FLUSH_DELAY_MS = 500;
|
|
52411
|
+
flushDelayMs;
|
|
52444
52412
|
events;
|
|
52445
52413
|
constructor(options2) {
|
|
52446
52414
|
this.session = options2.session;
|
|
@@ -52455,6 +52423,7 @@ class MessageManager {
|
|
|
52455
52423
|
this.buildMessageContentCallback = options2.buildMessageContent;
|
|
52456
52424
|
this.startTypingCallback = options2.startTyping;
|
|
52457
52425
|
this.emitSessionUpdateCallback = options2.emitSessionUpdate;
|
|
52426
|
+
this.flushDelayMs = options2.flushDelayMs ?? MessageManager.DEFAULT_FLUSH_DELAY_MS;
|
|
52458
52427
|
this.events = createMessageManagerEvents();
|
|
52459
52428
|
this.contentBreaker = new DefaultContentBreaker;
|
|
52460
52429
|
this.contentExecutor = new ContentExecutor({
|
|
@@ -52601,7 +52570,7 @@ class MessageManager {
|
|
|
52601
52570
|
this.flushTimer = null;
|
|
52602
52571
|
const flushOp = createFlushOp(this.sessionId, "soft_threshold");
|
|
52603
52572
|
await this.contentExecutor.executeFlush(flushOp, ctx);
|
|
52604
|
-
},
|
|
52573
|
+
}, this.flushDelayMs);
|
|
52605
52574
|
}
|
|
52606
52575
|
cancelScheduledFlush() {
|
|
52607
52576
|
if (this.flushTimer) {
|
|
@@ -52911,6 +52880,2660 @@ class MessageManager {
|
|
|
52911
52880
|
this.reset();
|
|
52912
52881
|
}
|
|
52913
52882
|
}
|
|
52883
|
+
// src/config/index.ts
|
|
52884
|
+
import { resolve as resolve2, dirname as dirname2 } from "path";
|
|
52885
|
+
import { homedir } from "os";
|
|
52886
|
+
|
|
52887
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
52888
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
52889
|
+
function isNothing(subject) {
|
|
52890
|
+
return typeof subject === "undefined" || subject === null;
|
|
52891
|
+
}
|
|
52892
|
+
function isObject3(subject) {
|
|
52893
|
+
return typeof subject === "object" && subject !== null;
|
|
52894
|
+
}
|
|
52895
|
+
function toArray(sequence) {
|
|
52896
|
+
if (Array.isArray(sequence))
|
|
52897
|
+
return sequence;
|
|
52898
|
+
else if (isNothing(sequence))
|
|
52899
|
+
return [];
|
|
52900
|
+
return [sequence];
|
|
52901
|
+
}
|
|
52902
|
+
function extend3(target, source) {
|
|
52903
|
+
var index, length, key, sourceKeys;
|
|
52904
|
+
if (source) {
|
|
52905
|
+
sourceKeys = Object.keys(source);
|
|
52906
|
+
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
52907
|
+
key = sourceKeys[index];
|
|
52908
|
+
target[key] = source[key];
|
|
52909
|
+
}
|
|
52910
|
+
}
|
|
52911
|
+
return target;
|
|
52912
|
+
}
|
|
52913
|
+
function repeat(string7, count) {
|
|
52914
|
+
var result = "", cycle;
|
|
52915
|
+
for (cycle = 0;cycle < count; cycle += 1) {
|
|
52916
|
+
result += string7;
|
|
52917
|
+
}
|
|
52918
|
+
return result;
|
|
52919
|
+
}
|
|
52920
|
+
function isNegativeZero(number7) {
|
|
52921
|
+
return number7 === 0 && Number.NEGATIVE_INFINITY === 1 / number7;
|
|
52922
|
+
}
|
|
52923
|
+
var isNothing_1 = isNothing;
|
|
52924
|
+
var isObject_1 = isObject3;
|
|
52925
|
+
var toArray_1 = toArray;
|
|
52926
|
+
var repeat_1 = repeat;
|
|
52927
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
52928
|
+
var extend_1 = extend3;
|
|
52929
|
+
var common = {
|
|
52930
|
+
isNothing: isNothing_1,
|
|
52931
|
+
isObject: isObject_1,
|
|
52932
|
+
toArray: toArray_1,
|
|
52933
|
+
repeat: repeat_1,
|
|
52934
|
+
isNegativeZero: isNegativeZero_1,
|
|
52935
|
+
extend: extend_1
|
|
52936
|
+
};
|
|
52937
|
+
function formatError3(exception, compact) {
|
|
52938
|
+
var where = "", message = exception.reason || "(unknown reason)";
|
|
52939
|
+
if (!exception.mark)
|
|
52940
|
+
return message;
|
|
52941
|
+
if (exception.mark.name) {
|
|
52942
|
+
where += 'in "' + exception.mark.name + '" ';
|
|
52943
|
+
}
|
|
52944
|
+
where += "(" + (exception.mark.line + 1) + ":" + (exception.mark.column + 1) + ")";
|
|
52945
|
+
if (!compact && exception.mark.snippet) {
|
|
52946
|
+
where += `
|
|
52947
|
+
|
|
52948
|
+
` + exception.mark.snippet;
|
|
52949
|
+
}
|
|
52950
|
+
return message + " " + where;
|
|
52951
|
+
}
|
|
52952
|
+
function YAMLException$1(reason, mark) {
|
|
52953
|
+
Error.call(this);
|
|
52954
|
+
this.name = "YAMLException";
|
|
52955
|
+
this.reason = reason;
|
|
52956
|
+
this.mark = mark;
|
|
52957
|
+
this.message = formatError3(this, false);
|
|
52958
|
+
if (Error.captureStackTrace) {
|
|
52959
|
+
Error.captureStackTrace(this, this.constructor);
|
|
52960
|
+
} else {
|
|
52961
|
+
this.stack = new Error().stack || "";
|
|
52962
|
+
}
|
|
52963
|
+
}
|
|
52964
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
52965
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
52966
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
52967
|
+
return this.name + ": " + formatError3(this, compact);
|
|
52968
|
+
};
|
|
52969
|
+
var exception = YAMLException$1;
|
|
52970
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
52971
|
+
var head = "";
|
|
52972
|
+
var tail = "";
|
|
52973
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
52974
|
+
if (position - lineStart > maxHalfLength) {
|
|
52975
|
+
head = " ... ";
|
|
52976
|
+
lineStart = position - maxHalfLength + head.length;
|
|
52977
|
+
}
|
|
52978
|
+
if (lineEnd - position > maxHalfLength) {
|
|
52979
|
+
tail = " ...";
|
|
52980
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
52981
|
+
}
|
|
52982
|
+
return {
|
|
52983
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
52984
|
+
pos: position - lineStart + head.length
|
|
52985
|
+
};
|
|
52986
|
+
}
|
|
52987
|
+
function padStart(string7, max) {
|
|
52988
|
+
return common.repeat(" ", max - string7.length) + string7;
|
|
52989
|
+
}
|
|
52990
|
+
function makeSnippet(mark, options2) {
|
|
52991
|
+
options2 = Object.create(options2 || null);
|
|
52992
|
+
if (!mark.buffer)
|
|
52993
|
+
return null;
|
|
52994
|
+
if (!options2.maxLength)
|
|
52995
|
+
options2.maxLength = 79;
|
|
52996
|
+
if (typeof options2.indent !== "number")
|
|
52997
|
+
options2.indent = 1;
|
|
52998
|
+
if (typeof options2.linesBefore !== "number")
|
|
52999
|
+
options2.linesBefore = 3;
|
|
53000
|
+
if (typeof options2.linesAfter !== "number")
|
|
53001
|
+
options2.linesAfter = 2;
|
|
53002
|
+
var re = /\r?\n|\r|\0/g;
|
|
53003
|
+
var lineStarts = [0];
|
|
53004
|
+
var lineEnds = [];
|
|
53005
|
+
var match;
|
|
53006
|
+
var foundLineNo = -1;
|
|
53007
|
+
while (match = re.exec(mark.buffer)) {
|
|
53008
|
+
lineEnds.push(match.index);
|
|
53009
|
+
lineStarts.push(match.index + match[0].length);
|
|
53010
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
53011
|
+
foundLineNo = lineStarts.length - 2;
|
|
53012
|
+
}
|
|
53013
|
+
}
|
|
53014
|
+
if (foundLineNo < 0)
|
|
53015
|
+
foundLineNo = lineStarts.length - 1;
|
|
53016
|
+
var result = "", i, line;
|
|
53017
|
+
var lineNoLength = Math.min(mark.line + options2.linesAfter, lineEnds.length).toString().length;
|
|
53018
|
+
var maxLineLength = options2.maxLength - (options2.indent + lineNoLength + 3);
|
|
53019
|
+
for (i = 1;i <= options2.linesBefore; i++) {
|
|
53020
|
+
if (foundLineNo - i < 0)
|
|
53021
|
+
break;
|
|
53022
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
53023
|
+
result = common.repeat(" ", options2.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
53024
|
+
` + result;
|
|
53025
|
+
}
|
|
53026
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
53027
|
+
result += common.repeat(" ", options2.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
53028
|
+
`;
|
|
53029
|
+
result += common.repeat("-", options2.indent + lineNoLength + 3 + line.pos) + "^" + `
|
|
53030
|
+
`;
|
|
53031
|
+
for (i = 1;i <= options2.linesAfter; i++) {
|
|
53032
|
+
if (foundLineNo + i >= lineEnds.length)
|
|
53033
|
+
break;
|
|
53034
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
53035
|
+
result += common.repeat(" ", options2.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
53036
|
+
`;
|
|
53037
|
+
}
|
|
53038
|
+
return result.replace(/\n$/, "");
|
|
53039
|
+
}
|
|
53040
|
+
var snippet = makeSnippet;
|
|
53041
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
53042
|
+
"kind",
|
|
53043
|
+
"multi",
|
|
53044
|
+
"resolve",
|
|
53045
|
+
"construct",
|
|
53046
|
+
"instanceOf",
|
|
53047
|
+
"predicate",
|
|
53048
|
+
"represent",
|
|
53049
|
+
"representName",
|
|
53050
|
+
"defaultStyle",
|
|
53051
|
+
"styleAliases"
|
|
53052
|
+
];
|
|
53053
|
+
var YAML_NODE_KINDS = [
|
|
53054
|
+
"scalar",
|
|
53055
|
+
"sequence",
|
|
53056
|
+
"mapping"
|
|
53057
|
+
];
|
|
53058
|
+
function compileStyleAliases(map3) {
|
|
53059
|
+
var result = {};
|
|
53060
|
+
if (map3 !== null) {
|
|
53061
|
+
Object.keys(map3).forEach(function(style) {
|
|
53062
|
+
map3[style].forEach(function(alias) {
|
|
53063
|
+
result[String(alias)] = style;
|
|
53064
|
+
});
|
|
53065
|
+
});
|
|
53066
|
+
}
|
|
53067
|
+
return result;
|
|
53068
|
+
}
|
|
53069
|
+
function Type$1(tag, options2) {
|
|
53070
|
+
options2 = options2 || {};
|
|
53071
|
+
Object.keys(options2).forEach(function(name) {
|
|
53072
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
53073
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
53074
|
+
}
|
|
53075
|
+
});
|
|
53076
|
+
this.options = options2;
|
|
53077
|
+
this.tag = tag;
|
|
53078
|
+
this.kind = options2["kind"] || null;
|
|
53079
|
+
this.resolve = options2["resolve"] || function() {
|
|
53080
|
+
return true;
|
|
53081
|
+
};
|
|
53082
|
+
this.construct = options2["construct"] || function(data) {
|
|
53083
|
+
return data;
|
|
53084
|
+
};
|
|
53085
|
+
this.instanceOf = options2["instanceOf"] || null;
|
|
53086
|
+
this.predicate = options2["predicate"] || null;
|
|
53087
|
+
this.represent = options2["represent"] || null;
|
|
53088
|
+
this.representName = options2["representName"] || null;
|
|
53089
|
+
this.defaultStyle = options2["defaultStyle"] || null;
|
|
53090
|
+
this.multi = options2["multi"] || false;
|
|
53091
|
+
this.styleAliases = compileStyleAliases(options2["styleAliases"] || null);
|
|
53092
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
53093
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
53094
|
+
}
|
|
53095
|
+
}
|
|
53096
|
+
var type = Type$1;
|
|
53097
|
+
function compileList(schema, name) {
|
|
53098
|
+
var result = [];
|
|
53099
|
+
schema[name].forEach(function(currentType) {
|
|
53100
|
+
var newIndex = result.length;
|
|
53101
|
+
result.forEach(function(previousType, previousIndex) {
|
|
53102
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
53103
|
+
newIndex = previousIndex;
|
|
53104
|
+
}
|
|
53105
|
+
});
|
|
53106
|
+
result[newIndex] = currentType;
|
|
53107
|
+
});
|
|
53108
|
+
return result;
|
|
53109
|
+
}
|
|
53110
|
+
function compileMap() {
|
|
53111
|
+
var result = {
|
|
53112
|
+
scalar: {},
|
|
53113
|
+
sequence: {},
|
|
53114
|
+
mapping: {},
|
|
53115
|
+
fallback: {},
|
|
53116
|
+
multi: {
|
|
53117
|
+
scalar: [],
|
|
53118
|
+
sequence: [],
|
|
53119
|
+
mapping: [],
|
|
53120
|
+
fallback: []
|
|
53121
|
+
}
|
|
53122
|
+
}, index, length;
|
|
53123
|
+
function collectType(type2) {
|
|
53124
|
+
if (type2.multi) {
|
|
53125
|
+
result.multi[type2.kind].push(type2);
|
|
53126
|
+
result.multi["fallback"].push(type2);
|
|
53127
|
+
} else {
|
|
53128
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
53129
|
+
}
|
|
53130
|
+
}
|
|
53131
|
+
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
53132
|
+
arguments[index].forEach(collectType);
|
|
53133
|
+
}
|
|
53134
|
+
return result;
|
|
53135
|
+
}
|
|
53136
|
+
function Schema$1(definition) {
|
|
53137
|
+
return this.extend(definition);
|
|
53138
|
+
}
|
|
53139
|
+
Schema$1.prototype.extend = function extend4(definition) {
|
|
53140
|
+
var implicit = [];
|
|
53141
|
+
var explicit = [];
|
|
53142
|
+
if (definition instanceof type) {
|
|
53143
|
+
explicit.push(definition);
|
|
53144
|
+
} else if (Array.isArray(definition)) {
|
|
53145
|
+
explicit = explicit.concat(definition);
|
|
53146
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
53147
|
+
if (definition.implicit)
|
|
53148
|
+
implicit = implicit.concat(definition.implicit);
|
|
53149
|
+
if (definition.explicit)
|
|
53150
|
+
explicit = explicit.concat(definition.explicit);
|
|
53151
|
+
} else {
|
|
53152
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
53153
|
+
}
|
|
53154
|
+
implicit.forEach(function(type$1) {
|
|
53155
|
+
if (!(type$1 instanceof type)) {
|
|
53156
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
53157
|
+
}
|
|
53158
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
53159
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
53160
|
+
}
|
|
53161
|
+
if (type$1.multi) {
|
|
53162
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
53163
|
+
}
|
|
53164
|
+
});
|
|
53165
|
+
explicit.forEach(function(type$1) {
|
|
53166
|
+
if (!(type$1 instanceof type)) {
|
|
53167
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
53168
|
+
}
|
|
53169
|
+
});
|
|
53170
|
+
var result = Object.create(Schema$1.prototype);
|
|
53171
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
53172
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
53173
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
53174
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
53175
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
53176
|
+
return result;
|
|
53177
|
+
};
|
|
53178
|
+
var schema = Schema$1;
|
|
53179
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
53180
|
+
kind: "scalar",
|
|
53181
|
+
construct: function(data) {
|
|
53182
|
+
return data !== null ? data : "";
|
|
53183
|
+
}
|
|
53184
|
+
});
|
|
53185
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
53186
|
+
kind: "sequence",
|
|
53187
|
+
construct: function(data) {
|
|
53188
|
+
return data !== null ? data : [];
|
|
53189
|
+
}
|
|
53190
|
+
});
|
|
53191
|
+
var map3 = new type("tag:yaml.org,2002:map", {
|
|
53192
|
+
kind: "mapping",
|
|
53193
|
+
construct: function(data) {
|
|
53194
|
+
return data !== null ? data : {};
|
|
53195
|
+
}
|
|
53196
|
+
});
|
|
53197
|
+
var failsafe = new schema({
|
|
53198
|
+
explicit: [
|
|
53199
|
+
str,
|
|
53200
|
+
seq,
|
|
53201
|
+
map3
|
|
53202
|
+
]
|
|
53203
|
+
});
|
|
53204
|
+
function resolveYamlNull(data) {
|
|
53205
|
+
if (data === null)
|
|
53206
|
+
return true;
|
|
53207
|
+
var max = data.length;
|
|
53208
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
53209
|
+
}
|
|
53210
|
+
function constructYamlNull() {
|
|
53211
|
+
return null;
|
|
53212
|
+
}
|
|
53213
|
+
function isNull(object5) {
|
|
53214
|
+
return object5 === null;
|
|
53215
|
+
}
|
|
53216
|
+
var _null7 = new type("tag:yaml.org,2002:null", {
|
|
53217
|
+
kind: "scalar",
|
|
53218
|
+
resolve: resolveYamlNull,
|
|
53219
|
+
construct: constructYamlNull,
|
|
53220
|
+
predicate: isNull,
|
|
53221
|
+
represent: {
|
|
53222
|
+
canonical: function() {
|
|
53223
|
+
return "~";
|
|
53224
|
+
},
|
|
53225
|
+
lowercase: function() {
|
|
53226
|
+
return "null";
|
|
53227
|
+
},
|
|
53228
|
+
uppercase: function() {
|
|
53229
|
+
return "NULL";
|
|
53230
|
+
},
|
|
53231
|
+
camelcase: function() {
|
|
53232
|
+
return "Null";
|
|
53233
|
+
},
|
|
53234
|
+
empty: function() {
|
|
53235
|
+
return "";
|
|
53236
|
+
}
|
|
53237
|
+
},
|
|
53238
|
+
defaultStyle: "lowercase"
|
|
53239
|
+
});
|
|
53240
|
+
function resolveYamlBoolean(data) {
|
|
53241
|
+
if (data === null)
|
|
53242
|
+
return false;
|
|
53243
|
+
var max = data.length;
|
|
53244
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
53245
|
+
}
|
|
53246
|
+
function constructYamlBoolean(data) {
|
|
53247
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
53248
|
+
}
|
|
53249
|
+
function isBoolean(object5) {
|
|
53250
|
+
return Object.prototype.toString.call(object5) === "[object Boolean]";
|
|
53251
|
+
}
|
|
53252
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
53253
|
+
kind: "scalar",
|
|
53254
|
+
resolve: resolveYamlBoolean,
|
|
53255
|
+
construct: constructYamlBoolean,
|
|
53256
|
+
predicate: isBoolean,
|
|
53257
|
+
represent: {
|
|
53258
|
+
lowercase: function(object5) {
|
|
53259
|
+
return object5 ? "true" : "false";
|
|
53260
|
+
},
|
|
53261
|
+
uppercase: function(object5) {
|
|
53262
|
+
return object5 ? "TRUE" : "FALSE";
|
|
53263
|
+
},
|
|
53264
|
+
camelcase: function(object5) {
|
|
53265
|
+
return object5 ? "True" : "False";
|
|
53266
|
+
}
|
|
53267
|
+
},
|
|
53268
|
+
defaultStyle: "lowercase"
|
|
53269
|
+
});
|
|
53270
|
+
function isHexCode(c) {
|
|
53271
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
53272
|
+
}
|
|
53273
|
+
function isOctCode(c) {
|
|
53274
|
+
return 48 <= c && c <= 55;
|
|
53275
|
+
}
|
|
53276
|
+
function isDecCode(c) {
|
|
53277
|
+
return 48 <= c && c <= 57;
|
|
53278
|
+
}
|
|
53279
|
+
function resolveYamlInteger(data) {
|
|
53280
|
+
if (data === null)
|
|
53281
|
+
return false;
|
|
53282
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
53283
|
+
if (!max)
|
|
53284
|
+
return false;
|
|
53285
|
+
ch = data[index];
|
|
53286
|
+
if (ch === "-" || ch === "+") {
|
|
53287
|
+
ch = data[++index];
|
|
53288
|
+
}
|
|
53289
|
+
if (ch === "0") {
|
|
53290
|
+
if (index + 1 === max)
|
|
53291
|
+
return true;
|
|
53292
|
+
ch = data[++index];
|
|
53293
|
+
if (ch === "b") {
|
|
53294
|
+
index++;
|
|
53295
|
+
for (;index < max; index++) {
|
|
53296
|
+
ch = data[index];
|
|
53297
|
+
if (ch === "_")
|
|
53298
|
+
continue;
|
|
53299
|
+
if (ch !== "0" && ch !== "1")
|
|
53300
|
+
return false;
|
|
53301
|
+
hasDigits = true;
|
|
53302
|
+
}
|
|
53303
|
+
return hasDigits && ch !== "_";
|
|
53304
|
+
}
|
|
53305
|
+
if (ch === "x") {
|
|
53306
|
+
index++;
|
|
53307
|
+
for (;index < max; index++) {
|
|
53308
|
+
ch = data[index];
|
|
53309
|
+
if (ch === "_")
|
|
53310
|
+
continue;
|
|
53311
|
+
if (!isHexCode(data.charCodeAt(index)))
|
|
53312
|
+
return false;
|
|
53313
|
+
hasDigits = true;
|
|
53314
|
+
}
|
|
53315
|
+
return hasDigits && ch !== "_";
|
|
53316
|
+
}
|
|
53317
|
+
if (ch === "o") {
|
|
53318
|
+
index++;
|
|
53319
|
+
for (;index < max; index++) {
|
|
53320
|
+
ch = data[index];
|
|
53321
|
+
if (ch === "_")
|
|
53322
|
+
continue;
|
|
53323
|
+
if (!isOctCode(data.charCodeAt(index)))
|
|
53324
|
+
return false;
|
|
53325
|
+
hasDigits = true;
|
|
53326
|
+
}
|
|
53327
|
+
return hasDigits && ch !== "_";
|
|
53328
|
+
}
|
|
53329
|
+
}
|
|
53330
|
+
if (ch === "_")
|
|
53331
|
+
return false;
|
|
53332
|
+
for (;index < max; index++) {
|
|
53333
|
+
ch = data[index];
|
|
53334
|
+
if (ch === "_")
|
|
53335
|
+
continue;
|
|
53336
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
53337
|
+
return false;
|
|
53338
|
+
}
|
|
53339
|
+
hasDigits = true;
|
|
53340
|
+
}
|
|
53341
|
+
if (!hasDigits || ch === "_")
|
|
53342
|
+
return false;
|
|
53343
|
+
return true;
|
|
53344
|
+
}
|
|
53345
|
+
function constructYamlInteger(data) {
|
|
53346
|
+
var value = data, sign = 1, ch;
|
|
53347
|
+
if (value.indexOf("_") !== -1) {
|
|
53348
|
+
value = value.replace(/_/g, "");
|
|
53349
|
+
}
|
|
53350
|
+
ch = value[0];
|
|
53351
|
+
if (ch === "-" || ch === "+") {
|
|
53352
|
+
if (ch === "-")
|
|
53353
|
+
sign = -1;
|
|
53354
|
+
value = value.slice(1);
|
|
53355
|
+
ch = value[0];
|
|
53356
|
+
}
|
|
53357
|
+
if (value === "0")
|
|
53358
|
+
return 0;
|
|
53359
|
+
if (ch === "0") {
|
|
53360
|
+
if (value[1] === "b")
|
|
53361
|
+
return sign * parseInt(value.slice(2), 2);
|
|
53362
|
+
if (value[1] === "x")
|
|
53363
|
+
return sign * parseInt(value.slice(2), 16);
|
|
53364
|
+
if (value[1] === "o")
|
|
53365
|
+
return sign * parseInt(value.slice(2), 8);
|
|
53366
|
+
}
|
|
53367
|
+
return sign * parseInt(value, 10);
|
|
53368
|
+
}
|
|
53369
|
+
function isInteger(object5) {
|
|
53370
|
+
return Object.prototype.toString.call(object5) === "[object Number]" && (object5 % 1 === 0 && !common.isNegativeZero(object5));
|
|
53371
|
+
}
|
|
53372
|
+
var int3 = new type("tag:yaml.org,2002:int", {
|
|
53373
|
+
kind: "scalar",
|
|
53374
|
+
resolve: resolveYamlInteger,
|
|
53375
|
+
construct: constructYamlInteger,
|
|
53376
|
+
predicate: isInteger,
|
|
53377
|
+
represent: {
|
|
53378
|
+
binary: function(obj) {
|
|
53379
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
53380
|
+
},
|
|
53381
|
+
octal: function(obj) {
|
|
53382
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
53383
|
+
},
|
|
53384
|
+
decimal: function(obj) {
|
|
53385
|
+
return obj.toString(10);
|
|
53386
|
+
},
|
|
53387
|
+
hexadecimal: function(obj) {
|
|
53388
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
53389
|
+
}
|
|
53390
|
+
},
|
|
53391
|
+
defaultStyle: "decimal",
|
|
53392
|
+
styleAliases: {
|
|
53393
|
+
binary: [2, "bin"],
|
|
53394
|
+
octal: [8, "oct"],
|
|
53395
|
+
decimal: [10, "dec"],
|
|
53396
|
+
hexadecimal: [16, "hex"]
|
|
53397
|
+
}
|
|
53398
|
+
});
|
|
53399
|
+
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))$");
|
|
53400
|
+
function resolveYamlFloat(data) {
|
|
53401
|
+
if (data === null)
|
|
53402
|
+
return false;
|
|
53403
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
53404
|
+
return false;
|
|
53405
|
+
}
|
|
53406
|
+
return true;
|
|
53407
|
+
}
|
|
53408
|
+
function constructYamlFloat(data) {
|
|
53409
|
+
var value, sign;
|
|
53410
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
53411
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
53412
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
53413
|
+
value = value.slice(1);
|
|
53414
|
+
}
|
|
53415
|
+
if (value === ".inf") {
|
|
53416
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
53417
|
+
} else if (value === ".nan") {
|
|
53418
|
+
return NaN;
|
|
53419
|
+
}
|
|
53420
|
+
return sign * parseFloat(value, 10);
|
|
53421
|
+
}
|
|
53422
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
53423
|
+
function representYamlFloat(object5, style) {
|
|
53424
|
+
var res;
|
|
53425
|
+
if (isNaN(object5)) {
|
|
53426
|
+
switch (style) {
|
|
53427
|
+
case "lowercase":
|
|
53428
|
+
return ".nan";
|
|
53429
|
+
case "uppercase":
|
|
53430
|
+
return ".NAN";
|
|
53431
|
+
case "camelcase":
|
|
53432
|
+
return ".NaN";
|
|
53433
|
+
}
|
|
53434
|
+
} else if (Number.POSITIVE_INFINITY === object5) {
|
|
53435
|
+
switch (style) {
|
|
53436
|
+
case "lowercase":
|
|
53437
|
+
return ".inf";
|
|
53438
|
+
case "uppercase":
|
|
53439
|
+
return ".INF";
|
|
53440
|
+
case "camelcase":
|
|
53441
|
+
return ".Inf";
|
|
53442
|
+
}
|
|
53443
|
+
} else if (Number.NEGATIVE_INFINITY === object5) {
|
|
53444
|
+
switch (style) {
|
|
53445
|
+
case "lowercase":
|
|
53446
|
+
return "-.inf";
|
|
53447
|
+
case "uppercase":
|
|
53448
|
+
return "-.INF";
|
|
53449
|
+
case "camelcase":
|
|
53450
|
+
return "-.Inf";
|
|
53451
|
+
}
|
|
53452
|
+
} else if (common.isNegativeZero(object5)) {
|
|
53453
|
+
return "-0.0";
|
|
53454
|
+
}
|
|
53455
|
+
res = object5.toString(10);
|
|
53456
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
53457
|
+
}
|
|
53458
|
+
function isFloat(object5) {
|
|
53459
|
+
return Object.prototype.toString.call(object5) === "[object Number]" && (object5 % 1 !== 0 || common.isNegativeZero(object5));
|
|
53460
|
+
}
|
|
53461
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
53462
|
+
kind: "scalar",
|
|
53463
|
+
resolve: resolveYamlFloat,
|
|
53464
|
+
construct: constructYamlFloat,
|
|
53465
|
+
predicate: isFloat,
|
|
53466
|
+
represent: representYamlFloat,
|
|
53467
|
+
defaultStyle: "lowercase"
|
|
53468
|
+
});
|
|
53469
|
+
var json2 = failsafe.extend({
|
|
53470
|
+
implicit: [
|
|
53471
|
+
_null7,
|
|
53472
|
+
bool,
|
|
53473
|
+
int3,
|
|
53474
|
+
float
|
|
53475
|
+
]
|
|
53476
|
+
});
|
|
53477
|
+
var core3 = json2;
|
|
53478
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
53479
|
+
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]))?))?$");
|
|
53480
|
+
function resolveYamlTimestamp(data) {
|
|
53481
|
+
if (data === null)
|
|
53482
|
+
return false;
|
|
53483
|
+
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
53484
|
+
return true;
|
|
53485
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
53486
|
+
return true;
|
|
53487
|
+
return false;
|
|
53488
|
+
}
|
|
53489
|
+
function constructYamlTimestamp(data) {
|
|
53490
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date8;
|
|
53491
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
53492
|
+
if (match === null)
|
|
53493
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
53494
|
+
if (match === null)
|
|
53495
|
+
throw new Error("Date resolve error");
|
|
53496
|
+
year = +match[1];
|
|
53497
|
+
month = +match[2] - 1;
|
|
53498
|
+
day = +match[3];
|
|
53499
|
+
if (!match[4]) {
|
|
53500
|
+
return new Date(Date.UTC(year, month, day));
|
|
53501
|
+
}
|
|
53502
|
+
hour = +match[4];
|
|
53503
|
+
minute = +match[5];
|
|
53504
|
+
second = +match[6];
|
|
53505
|
+
if (match[7]) {
|
|
53506
|
+
fraction = match[7].slice(0, 3);
|
|
53507
|
+
while (fraction.length < 3) {
|
|
53508
|
+
fraction += "0";
|
|
53509
|
+
}
|
|
53510
|
+
fraction = +fraction;
|
|
53511
|
+
}
|
|
53512
|
+
if (match[9]) {
|
|
53513
|
+
tz_hour = +match[10];
|
|
53514
|
+
tz_minute = +(match[11] || 0);
|
|
53515
|
+
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
53516
|
+
if (match[9] === "-")
|
|
53517
|
+
delta = -delta;
|
|
53518
|
+
}
|
|
53519
|
+
date8 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
53520
|
+
if (delta)
|
|
53521
|
+
date8.setTime(date8.getTime() - delta);
|
|
53522
|
+
return date8;
|
|
53523
|
+
}
|
|
53524
|
+
function representYamlTimestamp(object5) {
|
|
53525
|
+
return object5.toISOString();
|
|
53526
|
+
}
|
|
53527
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
53528
|
+
kind: "scalar",
|
|
53529
|
+
resolve: resolveYamlTimestamp,
|
|
53530
|
+
construct: constructYamlTimestamp,
|
|
53531
|
+
instanceOf: Date,
|
|
53532
|
+
represent: representYamlTimestamp
|
|
53533
|
+
});
|
|
53534
|
+
function resolveYamlMerge(data) {
|
|
53535
|
+
return data === "<<" || data === null;
|
|
53536
|
+
}
|
|
53537
|
+
var merge3 = new type("tag:yaml.org,2002:merge", {
|
|
53538
|
+
kind: "scalar",
|
|
53539
|
+
resolve: resolveYamlMerge
|
|
53540
|
+
});
|
|
53541
|
+
var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
53542
|
+
\r`;
|
|
53543
|
+
function resolveYamlBinary(data) {
|
|
53544
|
+
if (data === null)
|
|
53545
|
+
return false;
|
|
53546
|
+
var code, idx, bitlen = 0, max = data.length, map4 = BASE64_MAP;
|
|
53547
|
+
for (idx = 0;idx < max; idx++) {
|
|
53548
|
+
code = map4.indexOf(data.charAt(idx));
|
|
53549
|
+
if (code > 64)
|
|
53550
|
+
continue;
|
|
53551
|
+
if (code < 0)
|
|
53552
|
+
return false;
|
|
53553
|
+
bitlen += 6;
|
|
53554
|
+
}
|
|
53555
|
+
return bitlen % 8 === 0;
|
|
53556
|
+
}
|
|
53557
|
+
function constructYamlBinary(data) {
|
|
53558
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map4 = BASE64_MAP, bits = 0, result = [];
|
|
53559
|
+
for (idx = 0;idx < max; idx++) {
|
|
53560
|
+
if (idx % 4 === 0 && idx) {
|
|
53561
|
+
result.push(bits >> 16 & 255);
|
|
53562
|
+
result.push(bits >> 8 & 255);
|
|
53563
|
+
result.push(bits & 255);
|
|
53564
|
+
}
|
|
53565
|
+
bits = bits << 6 | map4.indexOf(input.charAt(idx));
|
|
53566
|
+
}
|
|
53567
|
+
tailbits = max % 4 * 6;
|
|
53568
|
+
if (tailbits === 0) {
|
|
53569
|
+
result.push(bits >> 16 & 255);
|
|
53570
|
+
result.push(bits >> 8 & 255);
|
|
53571
|
+
result.push(bits & 255);
|
|
53572
|
+
} else if (tailbits === 18) {
|
|
53573
|
+
result.push(bits >> 10 & 255);
|
|
53574
|
+
result.push(bits >> 2 & 255);
|
|
53575
|
+
} else if (tailbits === 12) {
|
|
53576
|
+
result.push(bits >> 4 & 255);
|
|
53577
|
+
}
|
|
53578
|
+
return new Uint8Array(result);
|
|
53579
|
+
}
|
|
53580
|
+
function representYamlBinary(object5) {
|
|
53581
|
+
var result = "", bits = 0, idx, tail, max = object5.length, map4 = BASE64_MAP;
|
|
53582
|
+
for (idx = 0;idx < max; idx++) {
|
|
53583
|
+
if (idx % 3 === 0 && idx) {
|
|
53584
|
+
result += map4[bits >> 18 & 63];
|
|
53585
|
+
result += map4[bits >> 12 & 63];
|
|
53586
|
+
result += map4[bits >> 6 & 63];
|
|
53587
|
+
result += map4[bits & 63];
|
|
53588
|
+
}
|
|
53589
|
+
bits = (bits << 8) + object5[idx];
|
|
53590
|
+
}
|
|
53591
|
+
tail = max % 3;
|
|
53592
|
+
if (tail === 0) {
|
|
53593
|
+
result += map4[bits >> 18 & 63];
|
|
53594
|
+
result += map4[bits >> 12 & 63];
|
|
53595
|
+
result += map4[bits >> 6 & 63];
|
|
53596
|
+
result += map4[bits & 63];
|
|
53597
|
+
} else if (tail === 2) {
|
|
53598
|
+
result += map4[bits >> 10 & 63];
|
|
53599
|
+
result += map4[bits >> 4 & 63];
|
|
53600
|
+
result += map4[bits << 2 & 63];
|
|
53601
|
+
result += map4[64];
|
|
53602
|
+
} else if (tail === 1) {
|
|
53603
|
+
result += map4[bits >> 2 & 63];
|
|
53604
|
+
result += map4[bits << 4 & 63];
|
|
53605
|
+
result += map4[64];
|
|
53606
|
+
result += map4[64];
|
|
53607
|
+
}
|
|
53608
|
+
return result;
|
|
53609
|
+
}
|
|
53610
|
+
function isBinary(obj) {
|
|
53611
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
53612
|
+
}
|
|
53613
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
53614
|
+
kind: "scalar",
|
|
53615
|
+
resolve: resolveYamlBinary,
|
|
53616
|
+
construct: constructYamlBinary,
|
|
53617
|
+
predicate: isBinary,
|
|
53618
|
+
represent: representYamlBinary
|
|
53619
|
+
});
|
|
53620
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
53621
|
+
var _toString$2 = Object.prototype.toString;
|
|
53622
|
+
function resolveYamlOmap(data) {
|
|
53623
|
+
if (data === null)
|
|
53624
|
+
return true;
|
|
53625
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object5 = data;
|
|
53626
|
+
for (index = 0, length = object5.length;index < length; index += 1) {
|
|
53627
|
+
pair = object5[index];
|
|
53628
|
+
pairHasKey = false;
|
|
53629
|
+
if (_toString$2.call(pair) !== "[object Object]")
|
|
53630
|
+
return false;
|
|
53631
|
+
for (pairKey in pair) {
|
|
53632
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
53633
|
+
if (!pairHasKey)
|
|
53634
|
+
pairHasKey = true;
|
|
53635
|
+
else
|
|
53636
|
+
return false;
|
|
53637
|
+
}
|
|
53638
|
+
}
|
|
53639
|
+
if (!pairHasKey)
|
|
53640
|
+
return false;
|
|
53641
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
53642
|
+
objectKeys.push(pairKey);
|
|
53643
|
+
else
|
|
53644
|
+
return false;
|
|
53645
|
+
}
|
|
53646
|
+
return true;
|
|
53647
|
+
}
|
|
53648
|
+
function constructYamlOmap(data) {
|
|
53649
|
+
return data !== null ? data : [];
|
|
53650
|
+
}
|
|
53651
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
53652
|
+
kind: "sequence",
|
|
53653
|
+
resolve: resolveYamlOmap,
|
|
53654
|
+
construct: constructYamlOmap
|
|
53655
|
+
});
|
|
53656
|
+
var _toString$1 = Object.prototype.toString;
|
|
53657
|
+
function resolveYamlPairs(data) {
|
|
53658
|
+
if (data === null)
|
|
53659
|
+
return true;
|
|
53660
|
+
var index, length, pair, keys, result, object5 = data;
|
|
53661
|
+
result = new Array(object5.length);
|
|
53662
|
+
for (index = 0, length = object5.length;index < length; index += 1) {
|
|
53663
|
+
pair = object5[index];
|
|
53664
|
+
if (_toString$1.call(pair) !== "[object Object]")
|
|
53665
|
+
return false;
|
|
53666
|
+
keys = Object.keys(pair);
|
|
53667
|
+
if (keys.length !== 1)
|
|
53668
|
+
return false;
|
|
53669
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
53670
|
+
}
|
|
53671
|
+
return true;
|
|
53672
|
+
}
|
|
53673
|
+
function constructYamlPairs(data) {
|
|
53674
|
+
if (data === null)
|
|
53675
|
+
return [];
|
|
53676
|
+
var index, length, pair, keys, result, object5 = data;
|
|
53677
|
+
result = new Array(object5.length);
|
|
53678
|
+
for (index = 0, length = object5.length;index < length; index += 1) {
|
|
53679
|
+
pair = object5[index];
|
|
53680
|
+
keys = Object.keys(pair);
|
|
53681
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
53682
|
+
}
|
|
53683
|
+
return result;
|
|
53684
|
+
}
|
|
53685
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
53686
|
+
kind: "sequence",
|
|
53687
|
+
resolve: resolveYamlPairs,
|
|
53688
|
+
construct: constructYamlPairs
|
|
53689
|
+
});
|
|
53690
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
53691
|
+
function resolveYamlSet(data) {
|
|
53692
|
+
if (data === null)
|
|
53693
|
+
return true;
|
|
53694
|
+
var key, object5 = data;
|
|
53695
|
+
for (key in object5) {
|
|
53696
|
+
if (_hasOwnProperty$2.call(object5, key)) {
|
|
53697
|
+
if (object5[key] !== null)
|
|
53698
|
+
return false;
|
|
53699
|
+
}
|
|
53700
|
+
}
|
|
53701
|
+
return true;
|
|
53702
|
+
}
|
|
53703
|
+
function constructYamlSet(data) {
|
|
53704
|
+
return data !== null ? data : {};
|
|
53705
|
+
}
|
|
53706
|
+
var set3 = new type("tag:yaml.org,2002:set", {
|
|
53707
|
+
kind: "mapping",
|
|
53708
|
+
resolve: resolveYamlSet,
|
|
53709
|
+
construct: constructYamlSet
|
|
53710
|
+
});
|
|
53711
|
+
var _default4 = core3.extend({
|
|
53712
|
+
implicit: [
|
|
53713
|
+
timestamp,
|
|
53714
|
+
merge3
|
|
53715
|
+
],
|
|
53716
|
+
explicit: [
|
|
53717
|
+
binary,
|
|
53718
|
+
omap,
|
|
53719
|
+
pairs,
|
|
53720
|
+
set3
|
|
53721
|
+
]
|
|
53722
|
+
});
|
|
53723
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
53724
|
+
var CONTEXT_FLOW_IN = 1;
|
|
53725
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
53726
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
53727
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
53728
|
+
var CHOMPING_CLIP = 1;
|
|
53729
|
+
var CHOMPING_STRIP = 2;
|
|
53730
|
+
var CHOMPING_KEEP = 3;
|
|
53731
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
53732
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
53733
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
53734
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
53735
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
53736
|
+
function _class(obj) {
|
|
53737
|
+
return Object.prototype.toString.call(obj);
|
|
53738
|
+
}
|
|
53739
|
+
function is_EOL(c) {
|
|
53740
|
+
return c === 10 || c === 13;
|
|
53741
|
+
}
|
|
53742
|
+
function is_WHITE_SPACE(c) {
|
|
53743
|
+
return c === 9 || c === 32;
|
|
53744
|
+
}
|
|
53745
|
+
function is_WS_OR_EOL(c) {
|
|
53746
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
53747
|
+
}
|
|
53748
|
+
function is_FLOW_INDICATOR(c) {
|
|
53749
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
53750
|
+
}
|
|
53751
|
+
function fromHexCode(c) {
|
|
53752
|
+
var lc;
|
|
53753
|
+
if (48 <= c && c <= 57) {
|
|
53754
|
+
return c - 48;
|
|
53755
|
+
}
|
|
53756
|
+
lc = c | 32;
|
|
53757
|
+
if (97 <= lc && lc <= 102) {
|
|
53758
|
+
return lc - 97 + 10;
|
|
53759
|
+
}
|
|
53760
|
+
return -1;
|
|
53761
|
+
}
|
|
53762
|
+
function escapedHexLen(c) {
|
|
53763
|
+
if (c === 120) {
|
|
53764
|
+
return 2;
|
|
53765
|
+
}
|
|
53766
|
+
if (c === 117) {
|
|
53767
|
+
return 4;
|
|
53768
|
+
}
|
|
53769
|
+
if (c === 85) {
|
|
53770
|
+
return 8;
|
|
53771
|
+
}
|
|
53772
|
+
return 0;
|
|
53773
|
+
}
|
|
53774
|
+
function fromDecimalCode(c) {
|
|
53775
|
+
if (48 <= c && c <= 57) {
|
|
53776
|
+
return c - 48;
|
|
53777
|
+
}
|
|
53778
|
+
return -1;
|
|
53779
|
+
}
|
|
53780
|
+
function simpleEscapeSequence(c) {
|
|
53781
|
+
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
53782
|
+
` : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "
" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
53783
|
+
}
|
|
53784
|
+
function charFromCodepoint(c) {
|
|
53785
|
+
if (c <= 65535) {
|
|
53786
|
+
return String.fromCharCode(c);
|
|
53787
|
+
}
|
|
53788
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
53789
|
+
}
|
|
53790
|
+
function setProperty(object5, key, value) {
|
|
53791
|
+
if (key === "__proto__") {
|
|
53792
|
+
Object.defineProperty(object5, key, {
|
|
53793
|
+
configurable: true,
|
|
53794
|
+
enumerable: true,
|
|
53795
|
+
writable: true,
|
|
53796
|
+
value
|
|
53797
|
+
});
|
|
53798
|
+
} else {
|
|
53799
|
+
object5[key] = value;
|
|
53800
|
+
}
|
|
53801
|
+
}
|
|
53802
|
+
var simpleEscapeCheck = new Array(256);
|
|
53803
|
+
var simpleEscapeMap = new Array(256);
|
|
53804
|
+
for (i = 0;i < 256; i++) {
|
|
53805
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
53806
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
53807
|
+
}
|
|
53808
|
+
var i;
|
|
53809
|
+
function State$1(input, options2) {
|
|
53810
|
+
this.input = input;
|
|
53811
|
+
this.filename = options2["filename"] || null;
|
|
53812
|
+
this.schema = options2["schema"] || _default4;
|
|
53813
|
+
this.onWarning = options2["onWarning"] || null;
|
|
53814
|
+
this.legacy = options2["legacy"] || false;
|
|
53815
|
+
this.json = options2["json"] || false;
|
|
53816
|
+
this.listener = options2["listener"] || null;
|
|
53817
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
53818
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
53819
|
+
this.length = input.length;
|
|
53820
|
+
this.position = 0;
|
|
53821
|
+
this.line = 0;
|
|
53822
|
+
this.lineStart = 0;
|
|
53823
|
+
this.lineIndent = 0;
|
|
53824
|
+
this.firstTabInLine = -1;
|
|
53825
|
+
this.documents = [];
|
|
53826
|
+
}
|
|
53827
|
+
function generateError(state, message) {
|
|
53828
|
+
var mark = {
|
|
53829
|
+
name: state.filename,
|
|
53830
|
+
buffer: state.input.slice(0, -1),
|
|
53831
|
+
position: state.position,
|
|
53832
|
+
line: state.line,
|
|
53833
|
+
column: state.position - state.lineStart
|
|
53834
|
+
};
|
|
53835
|
+
mark.snippet = snippet(mark);
|
|
53836
|
+
return new exception(message, mark);
|
|
53837
|
+
}
|
|
53838
|
+
function throwError(state, message) {
|
|
53839
|
+
throw generateError(state, message);
|
|
53840
|
+
}
|
|
53841
|
+
function throwWarning(state, message) {
|
|
53842
|
+
if (state.onWarning) {
|
|
53843
|
+
state.onWarning.call(null, generateError(state, message));
|
|
53844
|
+
}
|
|
53845
|
+
}
|
|
53846
|
+
var directiveHandlers = {
|
|
53847
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
53848
|
+
var match, major, minor;
|
|
53849
|
+
if (state.version !== null) {
|
|
53850
|
+
throwError(state, "duplication of %YAML directive");
|
|
53851
|
+
}
|
|
53852
|
+
if (args.length !== 1) {
|
|
53853
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
53854
|
+
}
|
|
53855
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
53856
|
+
if (match === null) {
|
|
53857
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
53858
|
+
}
|
|
53859
|
+
major = parseInt(match[1], 10);
|
|
53860
|
+
minor = parseInt(match[2], 10);
|
|
53861
|
+
if (major !== 1) {
|
|
53862
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
53863
|
+
}
|
|
53864
|
+
state.version = args[0];
|
|
53865
|
+
state.checkLineBreaks = minor < 2;
|
|
53866
|
+
if (minor !== 1 && minor !== 2) {
|
|
53867
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
53868
|
+
}
|
|
53869
|
+
},
|
|
53870
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
53871
|
+
var handle, prefix;
|
|
53872
|
+
if (args.length !== 2) {
|
|
53873
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
53874
|
+
}
|
|
53875
|
+
handle = args[0];
|
|
53876
|
+
prefix = args[1];
|
|
53877
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
53878
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
53879
|
+
}
|
|
53880
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
53881
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
53882
|
+
}
|
|
53883
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
53884
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
53885
|
+
}
|
|
53886
|
+
try {
|
|
53887
|
+
prefix = decodeURIComponent(prefix);
|
|
53888
|
+
} catch (err) {
|
|
53889
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
53890
|
+
}
|
|
53891
|
+
state.tagMap[handle] = prefix;
|
|
53892
|
+
}
|
|
53893
|
+
};
|
|
53894
|
+
function captureSegment(state, start, end, checkJson) {
|
|
53895
|
+
var _position, _length3, _character, _result;
|
|
53896
|
+
if (start < end) {
|
|
53897
|
+
_result = state.input.slice(start, end);
|
|
53898
|
+
if (checkJson) {
|
|
53899
|
+
for (_position = 0, _length3 = _result.length;_position < _length3; _position += 1) {
|
|
53900
|
+
_character = _result.charCodeAt(_position);
|
|
53901
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
53902
|
+
throwError(state, "expected valid JSON character");
|
|
53903
|
+
}
|
|
53904
|
+
}
|
|
53905
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
53906
|
+
throwError(state, "the stream contains non-printable characters");
|
|
53907
|
+
}
|
|
53908
|
+
state.result += _result;
|
|
53909
|
+
}
|
|
53910
|
+
}
|
|
53911
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
53912
|
+
var sourceKeys, key, index, quantity;
|
|
53913
|
+
if (!common.isObject(source)) {
|
|
53914
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
53915
|
+
}
|
|
53916
|
+
sourceKeys = Object.keys(source);
|
|
53917
|
+
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
53918
|
+
key = sourceKeys[index];
|
|
53919
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
53920
|
+
setProperty(destination, key, source[key]);
|
|
53921
|
+
overridableKeys[key] = true;
|
|
53922
|
+
}
|
|
53923
|
+
}
|
|
53924
|
+
}
|
|
53925
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
53926
|
+
var index, quantity;
|
|
53927
|
+
if (Array.isArray(keyNode)) {
|
|
53928
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
53929
|
+
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
53930
|
+
if (Array.isArray(keyNode[index])) {
|
|
53931
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
53932
|
+
}
|
|
53933
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
53934
|
+
keyNode[index] = "[object Object]";
|
|
53935
|
+
}
|
|
53936
|
+
}
|
|
53937
|
+
}
|
|
53938
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
53939
|
+
keyNode = "[object Object]";
|
|
53940
|
+
}
|
|
53941
|
+
keyNode = String(keyNode);
|
|
53942
|
+
if (_result === null) {
|
|
53943
|
+
_result = {};
|
|
53944
|
+
}
|
|
53945
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
53946
|
+
if (Array.isArray(valueNode)) {
|
|
53947
|
+
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
53948
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
53949
|
+
}
|
|
53950
|
+
} else {
|
|
53951
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
53952
|
+
}
|
|
53953
|
+
} else {
|
|
53954
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
53955
|
+
state.line = startLine || state.line;
|
|
53956
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
53957
|
+
state.position = startPos || state.position;
|
|
53958
|
+
throwError(state, "duplicated mapping key");
|
|
53959
|
+
}
|
|
53960
|
+
setProperty(_result, keyNode, valueNode);
|
|
53961
|
+
delete overridableKeys[keyNode];
|
|
53962
|
+
}
|
|
53963
|
+
return _result;
|
|
53964
|
+
}
|
|
53965
|
+
function readLineBreak(state) {
|
|
53966
|
+
var ch;
|
|
53967
|
+
ch = state.input.charCodeAt(state.position);
|
|
53968
|
+
if (ch === 10) {
|
|
53969
|
+
state.position++;
|
|
53970
|
+
} else if (ch === 13) {
|
|
53971
|
+
state.position++;
|
|
53972
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
53973
|
+
state.position++;
|
|
53974
|
+
}
|
|
53975
|
+
} else {
|
|
53976
|
+
throwError(state, "a line break is expected");
|
|
53977
|
+
}
|
|
53978
|
+
state.line += 1;
|
|
53979
|
+
state.lineStart = state.position;
|
|
53980
|
+
state.firstTabInLine = -1;
|
|
53981
|
+
}
|
|
53982
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
53983
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
53984
|
+
while (ch !== 0) {
|
|
53985
|
+
while (is_WHITE_SPACE(ch)) {
|
|
53986
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
53987
|
+
state.firstTabInLine = state.position;
|
|
53988
|
+
}
|
|
53989
|
+
ch = state.input.charCodeAt(++state.position);
|
|
53990
|
+
}
|
|
53991
|
+
if (allowComments && ch === 35) {
|
|
53992
|
+
do {
|
|
53993
|
+
ch = state.input.charCodeAt(++state.position);
|
|
53994
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
53995
|
+
}
|
|
53996
|
+
if (is_EOL(ch)) {
|
|
53997
|
+
readLineBreak(state);
|
|
53998
|
+
ch = state.input.charCodeAt(state.position);
|
|
53999
|
+
lineBreaks++;
|
|
54000
|
+
state.lineIndent = 0;
|
|
54001
|
+
while (ch === 32) {
|
|
54002
|
+
state.lineIndent++;
|
|
54003
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54004
|
+
}
|
|
54005
|
+
} else {
|
|
54006
|
+
break;
|
|
54007
|
+
}
|
|
54008
|
+
}
|
|
54009
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
54010
|
+
throwWarning(state, "deficient indentation");
|
|
54011
|
+
}
|
|
54012
|
+
return lineBreaks;
|
|
54013
|
+
}
|
|
54014
|
+
function testDocumentSeparator(state) {
|
|
54015
|
+
var _position = state.position, ch;
|
|
54016
|
+
ch = state.input.charCodeAt(_position);
|
|
54017
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
54018
|
+
_position += 3;
|
|
54019
|
+
ch = state.input.charCodeAt(_position);
|
|
54020
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
54021
|
+
return true;
|
|
54022
|
+
}
|
|
54023
|
+
}
|
|
54024
|
+
return false;
|
|
54025
|
+
}
|
|
54026
|
+
function writeFoldedLines(state, count) {
|
|
54027
|
+
if (count === 1) {
|
|
54028
|
+
state.result += " ";
|
|
54029
|
+
} else if (count > 1) {
|
|
54030
|
+
state.result += common.repeat(`
|
|
54031
|
+
`, count - 1);
|
|
54032
|
+
}
|
|
54033
|
+
}
|
|
54034
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
54035
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
54036
|
+
ch = state.input.charCodeAt(state.position);
|
|
54037
|
+
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) {
|
|
54038
|
+
return false;
|
|
54039
|
+
}
|
|
54040
|
+
if (ch === 63 || ch === 45) {
|
|
54041
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
54042
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
54043
|
+
return false;
|
|
54044
|
+
}
|
|
54045
|
+
}
|
|
54046
|
+
state.kind = "scalar";
|
|
54047
|
+
state.result = "";
|
|
54048
|
+
captureStart = captureEnd = state.position;
|
|
54049
|
+
hasPendingContent = false;
|
|
54050
|
+
while (ch !== 0) {
|
|
54051
|
+
if (ch === 58) {
|
|
54052
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
54053
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
54054
|
+
break;
|
|
54055
|
+
}
|
|
54056
|
+
} else if (ch === 35) {
|
|
54057
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
54058
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
54059
|
+
break;
|
|
54060
|
+
}
|
|
54061
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
54062
|
+
break;
|
|
54063
|
+
} else if (is_EOL(ch)) {
|
|
54064
|
+
_line = state.line;
|
|
54065
|
+
_lineStart = state.lineStart;
|
|
54066
|
+
_lineIndent = state.lineIndent;
|
|
54067
|
+
skipSeparationSpace(state, false, -1);
|
|
54068
|
+
if (state.lineIndent >= nodeIndent) {
|
|
54069
|
+
hasPendingContent = true;
|
|
54070
|
+
ch = state.input.charCodeAt(state.position);
|
|
54071
|
+
continue;
|
|
54072
|
+
} else {
|
|
54073
|
+
state.position = captureEnd;
|
|
54074
|
+
state.line = _line;
|
|
54075
|
+
state.lineStart = _lineStart;
|
|
54076
|
+
state.lineIndent = _lineIndent;
|
|
54077
|
+
break;
|
|
54078
|
+
}
|
|
54079
|
+
}
|
|
54080
|
+
if (hasPendingContent) {
|
|
54081
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
54082
|
+
writeFoldedLines(state, state.line - _line);
|
|
54083
|
+
captureStart = captureEnd = state.position;
|
|
54084
|
+
hasPendingContent = false;
|
|
54085
|
+
}
|
|
54086
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
54087
|
+
captureEnd = state.position + 1;
|
|
54088
|
+
}
|
|
54089
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54090
|
+
}
|
|
54091
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
54092
|
+
if (state.result) {
|
|
54093
|
+
return true;
|
|
54094
|
+
}
|
|
54095
|
+
state.kind = _kind;
|
|
54096
|
+
state.result = _result;
|
|
54097
|
+
return false;
|
|
54098
|
+
}
|
|
54099
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
54100
|
+
var ch, captureStart, captureEnd;
|
|
54101
|
+
ch = state.input.charCodeAt(state.position);
|
|
54102
|
+
if (ch !== 39) {
|
|
54103
|
+
return false;
|
|
54104
|
+
}
|
|
54105
|
+
state.kind = "scalar";
|
|
54106
|
+
state.result = "";
|
|
54107
|
+
state.position++;
|
|
54108
|
+
captureStart = captureEnd = state.position;
|
|
54109
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
54110
|
+
if (ch === 39) {
|
|
54111
|
+
captureSegment(state, captureStart, state.position, true);
|
|
54112
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54113
|
+
if (ch === 39) {
|
|
54114
|
+
captureStart = state.position;
|
|
54115
|
+
state.position++;
|
|
54116
|
+
captureEnd = state.position;
|
|
54117
|
+
} else {
|
|
54118
|
+
return true;
|
|
54119
|
+
}
|
|
54120
|
+
} else if (is_EOL(ch)) {
|
|
54121
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
54122
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
54123
|
+
captureStart = captureEnd = state.position;
|
|
54124
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
54125
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
54126
|
+
} else {
|
|
54127
|
+
state.position++;
|
|
54128
|
+
captureEnd = state.position;
|
|
54129
|
+
}
|
|
54130
|
+
}
|
|
54131
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
54132
|
+
}
|
|
54133
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
54134
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
54135
|
+
ch = state.input.charCodeAt(state.position);
|
|
54136
|
+
if (ch !== 34) {
|
|
54137
|
+
return false;
|
|
54138
|
+
}
|
|
54139
|
+
state.kind = "scalar";
|
|
54140
|
+
state.result = "";
|
|
54141
|
+
state.position++;
|
|
54142
|
+
captureStart = captureEnd = state.position;
|
|
54143
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
54144
|
+
if (ch === 34) {
|
|
54145
|
+
captureSegment(state, captureStart, state.position, true);
|
|
54146
|
+
state.position++;
|
|
54147
|
+
return true;
|
|
54148
|
+
} else if (ch === 92) {
|
|
54149
|
+
captureSegment(state, captureStart, state.position, true);
|
|
54150
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54151
|
+
if (is_EOL(ch)) {
|
|
54152
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
54153
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
54154
|
+
state.result += simpleEscapeMap[ch];
|
|
54155
|
+
state.position++;
|
|
54156
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
54157
|
+
hexLength = tmp;
|
|
54158
|
+
hexResult = 0;
|
|
54159
|
+
for (;hexLength > 0; hexLength--) {
|
|
54160
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54161
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
54162
|
+
hexResult = (hexResult << 4) + tmp;
|
|
54163
|
+
} else {
|
|
54164
|
+
throwError(state, "expected hexadecimal character");
|
|
54165
|
+
}
|
|
54166
|
+
}
|
|
54167
|
+
state.result += charFromCodepoint(hexResult);
|
|
54168
|
+
state.position++;
|
|
54169
|
+
} else {
|
|
54170
|
+
throwError(state, "unknown escape sequence");
|
|
54171
|
+
}
|
|
54172
|
+
captureStart = captureEnd = state.position;
|
|
54173
|
+
} else if (is_EOL(ch)) {
|
|
54174
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
54175
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
54176
|
+
captureStart = captureEnd = state.position;
|
|
54177
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
54178
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
54179
|
+
} else {
|
|
54180
|
+
state.position++;
|
|
54181
|
+
captureEnd = state.position;
|
|
54182
|
+
}
|
|
54183
|
+
}
|
|
54184
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
54185
|
+
}
|
|
54186
|
+
function readFlowCollection(state, nodeIndent) {
|
|
54187
|
+
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;
|
|
54188
|
+
ch = state.input.charCodeAt(state.position);
|
|
54189
|
+
if (ch === 91) {
|
|
54190
|
+
terminator = 93;
|
|
54191
|
+
isMapping = false;
|
|
54192
|
+
_result = [];
|
|
54193
|
+
} else if (ch === 123) {
|
|
54194
|
+
terminator = 125;
|
|
54195
|
+
isMapping = true;
|
|
54196
|
+
_result = {};
|
|
54197
|
+
} else {
|
|
54198
|
+
return false;
|
|
54199
|
+
}
|
|
54200
|
+
if (state.anchor !== null) {
|
|
54201
|
+
state.anchorMap[state.anchor] = _result;
|
|
54202
|
+
}
|
|
54203
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54204
|
+
while (ch !== 0) {
|
|
54205
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
54206
|
+
ch = state.input.charCodeAt(state.position);
|
|
54207
|
+
if (ch === terminator) {
|
|
54208
|
+
state.position++;
|
|
54209
|
+
state.tag = _tag;
|
|
54210
|
+
state.anchor = _anchor;
|
|
54211
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
54212
|
+
state.result = _result;
|
|
54213
|
+
return true;
|
|
54214
|
+
} else if (!readNext) {
|
|
54215
|
+
throwError(state, "missed comma between flow collection entries");
|
|
54216
|
+
} else if (ch === 44) {
|
|
54217
|
+
throwError(state, "expected the node content, but found ','");
|
|
54218
|
+
}
|
|
54219
|
+
keyTag = keyNode = valueNode = null;
|
|
54220
|
+
isPair = isExplicitPair = false;
|
|
54221
|
+
if (ch === 63) {
|
|
54222
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
54223
|
+
if (is_WS_OR_EOL(following)) {
|
|
54224
|
+
isPair = isExplicitPair = true;
|
|
54225
|
+
state.position++;
|
|
54226
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
54227
|
+
}
|
|
54228
|
+
}
|
|
54229
|
+
_line = state.line;
|
|
54230
|
+
_lineStart = state.lineStart;
|
|
54231
|
+
_pos = state.position;
|
|
54232
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
54233
|
+
keyTag = state.tag;
|
|
54234
|
+
keyNode = state.result;
|
|
54235
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
54236
|
+
ch = state.input.charCodeAt(state.position);
|
|
54237
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
54238
|
+
isPair = true;
|
|
54239
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54240
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
54241
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
54242
|
+
valueNode = state.result;
|
|
54243
|
+
}
|
|
54244
|
+
if (isMapping) {
|
|
54245
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
54246
|
+
} else if (isPair) {
|
|
54247
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
54248
|
+
} else {
|
|
54249
|
+
_result.push(keyNode);
|
|
54250
|
+
}
|
|
54251
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
54252
|
+
ch = state.input.charCodeAt(state.position);
|
|
54253
|
+
if (ch === 44) {
|
|
54254
|
+
readNext = true;
|
|
54255
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54256
|
+
} else {
|
|
54257
|
+
readNext = false;
|
|
54258
|
+
}
|
|
54259
|
+
}
|
|
54260
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
54261
|
+
}
|
|
54262
|
+
function readBlockScalar(state, nodeIndent) {
|
|
54263
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
54264
|
+
ch = state.input.charCodeAt(state.position);
|
|
54265
|
+
if (ch === 124) {
|
|
54266
|
+
folding = false;
|
|
54267
|
+
} else if (ch === 62) {
|
|
54268
|
+
folding = true;
|
|
54269
|
+
} else {
|
|
54270
|
+
return false;
|
|
54271
|
+
}
|
|
54272
|
+
state.kind = "scalar";
|
|
54273
|
+
state.result = "";
|
|
54274
|
+
while (ch !== 0) {
|
|
54275
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54276
|
+
if (ch === 43 || ch === 45) {
|
|
54277
|
+
if (CHOMPING_CLIP === chomping) {
|
|
54278
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
54279
|
+
} else {
|
|
54280
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
54281
|
+
}
|
|
54282
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
54283
|
+
if (tmp === 0) {
|
|
54284
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
54285
|
+
} else if (!detectedIndent) {
|
|
54286
|
+
textIndent = nodeIndent + tmp - 1;
|
|
54287
|
+
detectedIndent = true;
|
|
54288
|
+
} else {
|
|
54289
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
54290
|
+
}
|
|
54291
|
+
} else {
|
|
54292
|
+
break;
|
|
54293
|
+
}
|
|
54294
|
+
}
|
|
54295
|
+
if (is_WHITE_SPACE(ch)) {
|
|
54296
|
+
do {
|
|
54297
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54298
|
+
} while (is_WHITE_SPACE(ch));
|
|
54299
|
+
if (ch === 35) {
|
|
54300
|
+
do {
|
|
54301
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54302
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
54303
|
+
}
|
|
54304
|
+
}
|
|
54305
|
+
while (ch !== 0) {
|
|
54306
|
+
readLineBreak(state);
|
|
54307
|
+
state.lineIndent = 0;
|
|
54308
|
+
ch = state.input.charCodeAt(state.position);
|
|
54309
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
54310
|
+
state.lineIndent++;
|
|
54311
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54312
|
+
}
|
|
54313
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
54314
|
+
textIndent = state.lineIndent;
|
|
54315
|
+
}
|
|
54316
|
+
if (is_EOL(ch)) {
|
|
54317
|
+
emptyLines++;
|
|
54318
|
+
continue;
|
|
54319
|
+
}
|
|
54320
|
+
if (state.lineIndent < textIndent) {
|
|
54321
|
+
if (chomping === CHOMPING_KEEP) {
|
|
54322
|
+
state.result += common.repeat(`
|
|
54323
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
54324
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
54325
|
+
if (didReadContent) {
|
|
54326
|
+
state.result += `
|
|
54327
|
+
`;
|
|
54328
|
+
}
|
|
54329
|
+
}
|
|
54330
|
+
break;
|
|
54331
|
+
}
|
|
54332
|
+
if (folding) {
|
|
54333
|
+
if (is_WHITE_SPACE(ch)) {
|
|
54334
|
+
atMoreIndented = true;
|
|
54335
|
+
state.result += common.repeat(`
|
|
54336
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
54337
|
+
} else if (atMoreIndented) {
|
|
54338
|
+
atMoreIndented = false;
|
|
54339
|
+
state.result += common.repeat(`
|
|
54340
|
+
`, emptyLines + 1);
|
|
54341
|
+
} else if (emptyLines === 0) {
|
|
54342
|
+
if (didReadContent) {
|
|
54343
|
+
state.result += " ";
|
|
54344
|
+
}
|
|
54345
|
+
} else {
|
|
54346
|
+
state.result += common.repeat(`
|
|
54347
|
+
`, emptyLines);
|
|
54348
|
+
}
|
|
54349
|
+
} else {
|
|
54350
|
+
state.result += common.repeat(`
|
|
54351
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
54352
|
+
}
|
|
54353
|
+
didReadContent = true;
|
|
54354
|
+
detectedIndent = true;
|
|
54355
|
+
emptyLines = 0;
|
|
54356
|
+
captureStart = state.position;
|
|
54357
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
54358
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54359
|
+
}
|
|
54360
|
+
captureSegment(state, captureStart, state.position, false);
|
|
54361
|
+
}
|
|
54362
|
+
return true;
|
|
54363
|
+
}
|
|
54364
|
+
function readBlockSequence(state, nodeIndent) {
|
|
54365
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
54366
|
+
if (state.firstTabInLine !== -1)
|
|
54367
|
+
return false;
|
|
54368
|
+
if (state.anchor !== null) {
|
|
54369
|
+
state.anchorMap[state.anchor] = _result;
|
|
54370
|
+
}
|
|
54371
|
+
ch = state.input.charCodeAt(state.position);
|
|
54372
|
+
while (ch !== 0) {
|
|
54373
|
+
if (state.firstTabInLine !== -1) {
|
|
54374
|
+
state.position = state.firstTabInLine;
|
|
54375
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
54376
|
+
}
|
|
54377
|
+
if (ch !== 45) {
|
|
54378
|
+
break;
|
|
54379
|
+
}
|
|
54380
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
54381
|
+
if (!is_WS_OR_EOL(following)) {
|
|
54382
|
+
break;
|
|
54383
|
+
}
|
|
54384
|
+
detected = true;
|
|
54385
|
+
state.position++;
|
|
54386
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
54387
|
+
if (state.lineIndent <= nodeIndent) {
|
|
54388
|
+
_result.push(null);
|
|
54389
|
+
ch = state.input.charCodeAt(state.position);
|
|
54390
|
+
continue;
|
|
54391
|
+
}
|
|
54392
|
+
}
|
|
54393
|
+
_line = state.line;
|
|
54394
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
54395
|
+
_result.push(state.result);
|
|
54396
|
+
skipSeparationSpace(state, true, -1);
|
|
54397
|
+
ch = state.input.charCodeAt(state.position);
|
|
54398
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
54399
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
54400
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
54401
|
+
break;
|
|
54402
|
+
}
|
|
54403
|
+
}
|
|
54404
|
+
if (detected) {
|
|
54405
|
+
state.tag = _tag;
|
|
54406
|
+
state.anchor = _anchor;
|
|
54407
|
+
state.kind = "sequence";
|
|
54408
|
+
state.result = _result;
|
|
54409
|
+
return true;
|
|
54410
|
+
}
|
|
54411
|
+
return false;
|
|
54412
|
+
}
|
|
54413
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
54414
|
+
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;
|
|
54415
|
+
if (state.firstTabInLine !== -1)
|
|
54416
|
+
return false;
|
|
54417
|
+
if (state.anchor !== null) {
|
|
54418
|
+
state.anchorMap[state.anchor] = _result;
|
|
54419
|
+
}
|
|
54420
|
+
ch = state.input.charCodeAt(state.position);
|
|
54421
|
+
while (ch !== 0) {
|
|
54422
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
54423
|
+
state.position = state.firstTabInLine;
|
|
54424
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
54425
|
+
}
|
|
54426
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
54427
|
+
_line = state.line;
|
|
54428
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
54429
|
+
if (ch === 63) {
|
|
54430
|
+
if (atExplicitKey) {
|
|
54431
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
54432
|
+
keyTag = keyNode = valueNode = null;
|
|
54433
|
+
}
|
|
54434
|
+
detected = true;
|
|
54435
|
+
atExplicitKey = true;
|
|
54436
|
+
allowCompact = true;
|
|
54437
|
+
} else if (atExplicitKey) {
|
|
54438
|
+
atExplicitKey = false;
|
|
54439
|
+
allowCompact = true;
|
|
54440
|
+
} else {
|
|
54441
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
54442
|
+
}
|
|
54443
|
+
state.position += 1;
|
|
54444
|
+
ch = following;
|
|
54445
|
+
} else {
|
|
54446
|
+
_keyLine = state.line;
|
|
54447
|
+
_keyLineStart = state.lineStart;
|
|
54448
|
+
_keyPos = state.position;
|
|
54449
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
54450
|
+
break;
|
|
54451
|
+
}
|
|
54452
|
+
if (state.line === _line) {
|
|
54453
|
+
ch = state.input.charCodeAt(state.position);
|
|
54454
|
+
while (is_WHITE_SPACE(ch)) {
|
|
54455
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54456
|
+
}
|
|
54457
|
+
if (ch === 58) {
|
|
54458
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54459
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
54460
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
54461
|
+
}
|
|
54462
|
+
if (atExplicitKey) {
|
|
54463
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
54464
|
+
keyTag = keyNode = valueNode = null;
|
|
54465
|
+
}
|
|
54466
|
+
detected = true;
|
|
54467
|
+
atExplicitKey = false;
|
|
54468
|
+
allowCompact = false;
|
|
54469
|
+
keyTag = state.tag;
|
|
54470
|
+
keyNode = state.result;
|
|
54471
|
+
} else if (detected) {
|
|
54472
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
54473
|
+
} else {
|
|
54474
|
+
state.tag = _tag;
|
|
54475
|
+
state.anchor = _anchor;
|
|
54476
|
+
return true;
|
|
54477
|
+
}
|
|
54478
|
+
} else if (detected) {
|
|
54479
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
54480
|
+
} else {
|
|
54481
|
+
state.tag = _tag;
|
|
54482
|
+
state.anchor = _anchor;
|
|
54483
|
+
return true;
|
|
54484
|
+
}
|
|
54485
|
+
}
|
|
54486
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
54487
|
+
if (atExplicitKey) {
|
|
54488
|
+
_keyLine = state.line;
|
|
54489
|
+
_keyLineStart = state.lineStart;
|
|
54490
|
+
_keyPos = state.position;
|
|
54491
|
+
}
|
|
54492
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
54493
|
+
if (atExplicitKey) {
|
|
54494
|
+
keyNode = state.result;
|
|
54495
|
+
} else {
|
|
54496
|
+
valueNode = state.result;
|
|
54497
|
+
}
|
|
54498
|
+
}
|
|
54499
|
+
if (!atExplicitKey) {
|
|
54500
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
54501
|
+
keyTag = keyNode = valueNode = null;
|
|
54502
|
+
}
|
|
54503
|
+
skipSeparationSpace(state, true, -1);
|
|
54504
|
+
ch = state.input.charCodeAt(state.position);
|
|
54505
|
+
}
|
|
54506
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
54507
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
54508
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
54509
|
+
break;
|
|
54510
|
+
}
|
|
54511
|
+
}
|
|
54512
|
+
if (atExplicitKey) {
|
|
54513
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
54514
|
+
}
|
|
54515
|
+
if (detected) {
|
|
54516
|
+
state.tag = _tag;
|
|
54517
|
+
state.anchor = _anchor;
|
|
54518
|
+
state.kind = "mapping";
|
|
54519
|
+
state.result = _result;
|
|
54520
|
+
}
|
|
54521
|
+
return detected;
|
|
54522
|
+
}
|
|
54523
|
+
function readTagProperty(state) {
|
|
54524
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
54525
|
+
ch = state.input.charCodeAt(state.position);
|
|
54526
|
+
if (ch !== 33)
|
|
54527
|
+
return false;
|
|
54528
|
+
if (state.tag !== null) {
|
|
54529
|
+
throwError(state, "duplication of a tag property");
|
|
54530
|
+
}
|
|
54531
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54532
|
+
if (ch === 60) {
|
|
54533
|
+
isVerbatim = true;
|
|
54534
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54535
|
+
} else if (ch === 33) {
|
|
54536
|
+
isNamed = true;
|
|
54537
|
+
tagHandle = "!!";
|
|
54538
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54539
|
+
} else {
|
|
54540
|
+
tagHandle = "!";
|
|
54541
|
+
}
|
|
54542
|
+
_position = state.position;
|
|
54543
|
+
if (isVerbatim) {
|
|
54544
|
+
do {
|
|
54545
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54546
|
+
} while (ch !== 0 && ch !== 62);
|
|
54547
|
+
if (state.position < state.length) {
|
|
54548
|
+
tagName = state.input.slice(_position, state.position);
|
|
54549
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54550
|
+
} else {
|
|
54551
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
54552
|
+
}
|
|
54553
|
+
} else {
|
|
54554
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
54555
|
+
if (ch === 33) {
|
|
54556
|
+
if (!isNamed) {
|
|
54557
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
54558
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
54559
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
54560
|
+
}
|
|
54561
|
+
isNamed = true;
|
|
54562
|
+
_position = state.position + 1;
|
|
54563
|
+
} else {
|
|
54564
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
54565
|
+
}
|
|
54566
|
+
}
|
|
54567
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54568
|
+
}
|
|
54569
|
+
tagName = state.input.slice(_position, state.position);
|
|
54570
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
54571
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
54572
|
+
}
|
|
54573
|
+
}
|
|
54574
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
54575
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
54576
|
+
}
|
|
54577
|
+
try {
|
|
54578
|
+
tagName = decodeURIComponent(tagName);
|
|
54579
|
+
} catch (err) {
|
|
54580
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
54581
|
+
}
|
|
54582
|
+
if (isVerbatim) {
|
|
54583
|
+
state.tag = tagName;
|
|
54584
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
54585
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
54586
|
+
} else if (tagHandle === "!") {
|
|
54587
|
+
state.tag = "!" + tagName;
|
|
54588
|
+
} else if (tagHandle === "!!") {
|
|
54589
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
54590
|
+
} else {
|
|
54591
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
54592
|
+
}
|
|
54593
|
+
return true;
|
|
54594
|
+
}
|
|
54595
|
+
function readAnchorProperty(state) {
|
|
54596
|
+
var _position, ch;
|
|
54597
|
+
ch = state.input.charCodeAt(state.position);
|
|
54598
|
+
if (ch !== 38)
|
|
54599
|
+
return false;
|
|
54600
|
+
if (state.anchor !== null) {
|
|
54601
|
+
throwError(state, "duplication of an anchor property");
|
|
54602
|
+
}
|
|
54603
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54604
|
+
_position = state.position;
|
|
54605
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
54606
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54607
|
+
}
|
|
54608
|
+
if (state.position === _position) {
|
|
54609
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
54610
|
+
}
|
|
54611
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
54612
|
+
return true;
|
|
54613
|
+
}
|
|
54614
|
+
function readAlias(state) {
|
|
54615
|
+
var _position, alias, ch;
|
|
54616
|
+
ch = state.input.charCodeAt(state.position);
|
|
54617
|
+
if (ch !== 42)
|
|
54618
|
+
return false;
|
|
54619
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54620
|
+
_position = state.position;
|
|
54621
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
54622
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54623
|
+
}
|
|
54624
|
+
if (state.position === _position) {
|
|
54625
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
54626
|
+
}
|
|
54627
|
+
alias = state.input.slice(_position, state.position);
|
|
54628
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
54629
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
54630
|
+
}
|
|
54631
|
+
state.result = state.anchorMap[alias];
|
|
54632
|
+
skipSeparationSpace(state, true, -1);
|
|
54633
|
+
return true;
|
|
54634
|
+
}
|
|
54635
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
54636
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
54637
|
+
if (state.listener !== null) {
|
|
54638
|
+
state.listener("open", state);
|
|
54639
|
+
}
|
|
54640
|
+
state.tag = null;
|
|
54641
|
+
state.anchor = null;
|
|
54642
|
+
state.kind = null;
|
|
54643
|
+
state.result = null;
|
|
54644
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
54645
|
+
if (allowToSeek) {
|
|
54646
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
54647
|
+
atNewLine = true;
|
|
54648
|
+
if (state.lineIndent > parentIndent) {
|
|
54649
|
+
indentStatus = 1;
|
|
54650
|
+
} else if (state.lineIndent === parentIndent) {
|
|
54651
|
+
indentStatus = 0;
|
|
54652
|
+
} else if (state.lineIndent < parentIndent) {
|
|
54653
|
+
indentStatus = -1;
|
|
54654
|
+
}
|
|
54655
|
+
}
|
|
54656
|
+
}
|
|
54657
|
+
if (indentStatus === 1) {
|
|
54658
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
54659
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
54660
|
+
atNewLine = true;
|
|
54661
|
+
allowBlockCollections = allowBlockStyles;
|
|
54662
|
+
if (state.lineIndent > parentIndent) {
|
|
54663
|
+
indentStatus = 1;
|
|
54664
|
+
} else if (state.lineIndent === parentIndent) {
|
|
54665
|
+
indentStatus = 0;
|
|
54666
|
+
} else if (state.lineIndent < parentIndent) {
|
|
54667
|
+
indentStatus = -1;
|
|
54668
|
+
}
|
|
54669
|
+
} else {
|
|
54670
|
+
allowBlockCollections = false;
|
|
54671
|
+
}
|
|
54672
|
+
}
|
|
54673
|
+
}
|
|
54674
|
+
if (allowBlockCollections) {
|
|
54675
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
54676
|
+
}
|
|
54677
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
54678
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
54679
|
+
flowIndent = parentIndent;
|
|
54680
|
+
} else {
|
|
54681
|
+
flowIndent = parentIndent + 1;
|
|
54682
|
+
}
|
|
54683
|
+
blockIndent = state.position - state.lineStart;
|
|
54684
|
+
if (indentStatus === 1) {
|
|
54685
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
54686
|
+
hasContent = true;
|
|
54687
|
+
} else {
|
|
54688
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
54689
|
+
hasContent = true;
|
|
54690
|
+
} else if (readAlias(state)) {
|
|
54691
|
+
hasContent = true;
|
|
54692
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
54693
|
+
throwError(state, "alias node should not have any properties");
|
|
54694
|
+
}
|
|
54695
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
54696
|
+
hasContent = true;
|
|
54697
|
+
if (state.tag === null) {
|
|
54698
|
+
state.tag = "?";
|
|
54699
|
+
}
|
|
54700
|
+
}
|
|
54701
|
+
if (state.anchor !== null) {
|
|
54702
|
+
state.anchorMap[state.anchor] = state.result;
|
|
54703
|
+
}
|
|
54704
|
+
}
|
|
54705
|
+
} else if (indentStatus === 0) {
|
|
54706
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
54707
|
+
}
|
|
54708
|
+
}
|
|
54709
|
+
if (state.tag === null) {
|
|
54710
|
+
if (state.anchor !== null) {
|
|
54711
|
+
state.anchorMap[state.anchor] = state.result;
|
|
54712
|
+
}
|
|
54713
|
+
} else if (state.tag === "?") {
|
|
54714
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
54715
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
54716
|
+
}
|
|
54717
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
54718
|
+
type2 = state.implicitTypes[typeIndex];
|
|
54719
|
+
if (type2.resolve(state.result)) {
|
|
54720
|
+
state.result = type2.construct(state.result);
|
|
54721
|
+
state.tag = type2.tag;
|
|
54722
|
+
if (state.anchor !== null) {
|
|
54723
|
+
state.anchorMap[state.anchor] = state.result;
|
|
54724
|
+
}
|
|
54725
|
+
break;
|
|
54726
|
+
}
|
|
54727
|
+
}
|
|
54728
|
+
} else if (state.tag !== "!") {
|
|
54729
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
54730
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
54731
|
+
} else {
|
|
54732
|
+
type2 = null;
|
|
54733
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
54734
|
+
for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
54735
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
54736
|
+
type2 = typeList[typeIndex];
|
|
54737
|
+
break;
|
|
54738
|
+
}
|
|
54739
|
+
}
|
|
54740
|
+
}
|
|
54741
|
+
if (!type2) {
|
|
54742
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
54743
|
+
}
|
|
54744
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
54745
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
54746
|
+
}
|
|
54747
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
54748
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
54749
|
+
} else {
|
|
54750
|
+
state.result = type2.construct(state.result, state.tag);
|
|
54751
|
+
if (state.anchor !== null) {
|
|
54752
|
+
state.anchorMap[state.anchor] = state.result;
|
|
54753
|
+
}
|
|
54754
|
+
}
|
|
54755
|
+
}
|
|
54756
|
+
if (state.listener !== null) {
|
|
54757
|
+
state.listener("close", state);
|
|
54758
|
+
}
|
|
54759
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
54760
|
+
}
|
|
54761
|
+
function readDocument(state) {
|
|
54762
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
54763
|
+
state.version = null;
|
|
54764
|
+
state.checkLineBreaks = state.legacy;
|
|
54765
|
+
state.tagMap = Object.create(null);
|
|
54766
|
+
state.anchorMap = Object.create(null);
|
|
54767
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
54768
|
+
skipSeparationSpace(state, true, -1);
|
|
54769
|
+
ch = state.input.charCodeAt(state.position);
|
|
54770
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
54771
|
+
break;
|
|
54772
|
+
}
|
|
54773
|
+
hasDirectives = true;
|
|
54774
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54775
|
+
_position = state.position;
|
|
54776
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
54777
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54778
|
+
}
|
|
54779
|
+
directiveName = state.input.slice(_position, state.position);
|
|
54780
|
+
directiveArgs = [];
|
|
54781
|
+
if (directiveName.length < 1) {
|
|
54782
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
54783
|
+
}
|
|
54784
|
+
while (ch !== 0) {
|
|
54785
|
+
while (is_WHITE_SPACE(ch)) {
|
|
54786
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54787
|
+
}
|
|
54788
|
+
if (ch === 35) {
|
|
54789
|
+
do {
|
|
54790
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54791
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
54792
|
+
break;
|
|
54793
|
+
}
|
|
54794
|
+
if (is_EOL(ch))
|
|
54795
|
+
break;
|
|
54796
|
+
_position = state.position;
|
|
54797
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
54798
|
+
ch = state.input.charCodeAt(++state.position);
|
|
54799
|
+
}
|
|
54800
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
54801
|
+
}
|
|
54802
|
+
if (ch !== 0)
|
|
54803
|
+
readLineBreak(state);
|
|
54804
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
54805
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
54806
|
+
} else {
|
|
54807
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
54808
|
+
}
|
|
54809
|
+
}
|
|
54810
|
+
skipSeparationSpace(state, true, -1);
|
|
54811
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
54812
|
+
state.position += 3;
|
|
54813
|
+
skipSeparationSpace(state, true, -1);
|
|
54814
|
+
} else if (hasDirectives) {
|
|
54815
|
+
throwError(state, "directives end mark is expected");
|
|
54816
|
+
}
|
|
54817
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
54818
|
+
skipSeparationSpace(state, true, -1);
|
|
54819
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
54820
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
54821
|
+
}
|
|
54822
|
+
state.documents.push(state.result);
|
|
54823
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
54824
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
54825
|
+
state.position += 3;
|
|
54826
|
+
skipSeparationSpace(state, true, -1);
|
|
54827
|
+
}
|
|
54828
|
+
return;
|
|
54829
|
+
}
|
|
54830
|
+
if (state.position < state.length - 1) {
|
|
54831
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
54832
|
+
} else {
|
|
54833
|
+
return;
|
|
54834
|
+
}
|
|
54835
|
+
}
|
|
54836
|
+
function loadDocuments(input, options2) {
|
|
54837
|
+
input = String(input);
|
|
54838
|
+
options2 = options2 || {};
|
|
54839
|
+
if (input.length !== 0) {
|
|
54840
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
54841
|
+
input += `
|
|
54842
|
+
`;
|
|
54843
|
+
}
|
|
54844
|
+
if (input.charCodeAt(0) === 65279) {
|
|
54845
|
+
input = input.slice(1);
|
|
54846
|
+
}
|
|
54847
|
+
}
|
|
54848
|
+
var state = new State$1(input, options2);
|
|
54849
|
+
var nullpos = input.indexOf("\x00");
|
|
54850
|
+
if (nullpos !== -1) {
|
|
54851
|
+
state.position = nullpos;
|
|
54852
|
+
throwError(state, "null byte is not allowed in input");
|
|
54853
|
+
}
|
|
54854
|
+
state.input += "\x00";
|
|
54855
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
54856
|
+
state.lineIndent += 1;
|
|
54857
|
+
state.position += 1;
|
|
54858
|
+
}
|
|
54859
|
+
while (state.position < state.length - 1) {
|
|
54860
|
+
readDocument(state);
|
|
54861
|
+
}
|
|
54862
|
+
return state.documents;
|
|
54863
|
+
}
|
|
54864
|
+
function loadAll$1(input, iterator, options2) {
|
|
54865
|
+
if (iterator !== null && typeof iterator === "object" && typeof options2 === "undefined") {
|
|
54866
|
+
options2 = iterator;
|
|
54867
|
+
iterator = null;
|
|
54868
|
+
}
|
|
54869
|
+
var documents = loadDocuments(input, options2);
|
|
54870
|
+
if (typeof iterator !== "function") {
|
|
54871
|
+
return documents;
|
|
54872
|
+
}
|
|
54873
|
+
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
54874
|
+
iterator(documents[index]);
|
|
54875
|
+
}
|
|
54876
|
+
}
|
|
54877
|
+
function load$1(input, options2) {
|
|
54878
|
+
var documents = loadDocuments(input, options2);
|
|
54879
|
+
if (documents.length === 0) {
|
|
54880
|
+
return;
|
|
54881
|
+
} else if (documents.length === 1) {
|
|
54882
|
+
return documents[0];
|
|
54883
|
+
}
|
|
54884
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
54885
|
+
}
|
|
54886
|
+
var loadAll_1 = loadAll$1;
|
|
54887
|
+
var load_1 = load$1;
|
|
54888
|
+
var loader = {
|
|
54889
|
+
loadAll: loadAll_1,
|
|
54890
|
+
load: load_1
|
|
54891
|
+
};
|
|
54892
|
+
var _toString = Object.prototype.toString;
|
|
54893
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
54894
|
+
var CHAR_BOM = 65279;
|
|
54895
|
+
var CHAR_TAB = 9;
|
|
54896
|
+
var CHAR_LINE_FEED = 10;
|
|
54897
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
54898
|
+
var CHAR_SPACE = 32;
|
|
54899
|
+
var CHAR_EXCLAMATION = 33;
|
|
54900
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
54901
|
+
var CHAR_SHARP = 35;
|
|
54902
|
+
var CHAR_PERCENT = 37;
|
|
54903
|
+
var CHAR_AMPERSAND = 38;
|
|
54904
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
54905
|
+
var CHAR_ASTERISK = 42;
|
|
54906
|
+
var CHAR_COMMA = 44;
|
|
54907
|
+
var CHAR_MINUS = 45;
|
|
54908
|
+
var CHAR_COLON = 58;
|
|
54909
|
+
var CHAR_EQUALS = 61;
|
|
54910
|
+
var CHAR_GREATER_THAN = 62;
|
|
54911
|
+
var CHAR_QUESTION = 63;
|
|
54912
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
54913
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
54914
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
54915
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
54916
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
54917
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
54918
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
54919
|
+
var ESCAPE_SEQUENCES = {};
|
|
54920
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
54921
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
54922
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
54923
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
54924
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
54925
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
54926
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
54927
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
54928
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
54929
|
+
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
54930
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
54931
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
54932
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
54933
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
54934
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
54935
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
54936
|
+
"y",
|
|
54937
|
+
"Y",
|
|
54938
|
+
"yes",
|
|
54939
|
+
"Yes",
|
|
54940
|
+
"YES",
|
|
54941
|
+
"on",
|
|
54942
|
+
"On",
|
|
54943
|
+
"ON",
|
|
54944
|
+
"n",
|
|
54945
|
+
"N",
|
|
54946
|
+
"no",
|
|
54947
|
+
"No",
|
|
54948
|
+
"NO",
|
|
54949
|
+
"off",
|
|
54950
|
+
"Off",
|
|
54951
|
+
"OFF"
|
|
54952
|
+
];
|
|
54953
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
54954
|
+
function compileStyleMap(schema2, map4) {
|
|
54955
|
+
var result, keys, index, length, tag, style, type2;
|
|
54956
|
+
if (map4 === null)
|
|
54957
|
+
return {};
|
|
54958
|
+
result = {};
|
|
54959
|
+
keys = Object.keys(map4);
|
|
54960
|
+
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
54961
|
+
tag = keys[index];
|
|
54962
|
+
style = String(map4[tag]);
|
|
54963
|
+
if (tag.slice(0, 2) === "!!") {
|
|
54964
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
54965
|
+
}
|
|
54966
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
54967
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
54968
|
+
style = type2.styleAliases[style];
|
|
54969
|
+
}
|
|
54970
|
+
result[tag] = style;
|
|
54971
|
+
}
|
|
54972
|
+
return result;
|
|
54973
|
+
}
|
|
54974
|
+
function encodeHex(character) {
|
|
54975
|
+
var string7, handle, length;
|
|
54976
|
+
string7 = character.toString(16).toUpperCase();
|
|
54977
|
+
if (character <= 255) {
|
|
54978
|
+
handle = "x";
|
|
54979
|
+
length = 2;
|
|
54980
|
+
} else if (character <= 65535) {
|
|
54981
|
+
handle = "u";
|
|
54982
|
+
length = 4;
|
|
54983
|
+
} else if (character <= 4294967295) {
|
|
54984
|
+
handle = "U";
|
|
54985
|
+
length = 8;
|
|
54986
|
+
} else {
|
|
54987
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
54988
|
+
}
|
|
54989
|
+
return "\\" + handle + common.repeat("0", length - string7.length) + string7;
|
|
54990
|
+
}
|
|
54991
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
54992
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
54993
|
+
function State(options2) {
|
|
54994
|
+
this.schema = options2["schema"] || _default4;
|
|
54995
|
+
this.indent = Math.max(1, options2["indent"] || 2);
|
|
54996
|
+
this.noArrayIndent = options2["noArrayIndent"] || false;
|
|
54997
|
+
this.skipInvalid = options2["skipInvalid"] || false;
|
|
54998
|
+
this.flowLevel = common.isNothing(options2["flowLevel"]) ? -1 : options2["flowLevel"];
|
|
54999
|
+
this.styleMap = compileStyleMap(this.schema, options2["styles"] || null);
|
|
55000
|
+
this.sortKeys = options2["sortKeys"] || false;
|
|
55001
|
+
this.lineWidth = options2["lineWidth"] || 80;
|
|
55002
|
+
this.noRefs = options2["noRefs"] || false;
|
|
55003
|
+
this.noCompatMode = options2["noCompatMode"] || false;
|
|
55004
|
+
this.condenseFlow = options2["condenseFlow"] || false;
|
|
55005
|
+
this.quotingType = options2["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
55006
|
+
this.forceQuotes = options2["forceQuotes"] || false;
|
|
55007
|
+
this.replacer = typeof options2["replacer"] === "function" ? options2["replacer"] : null;
|
|
55008
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
55009
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
55010
|
+
this.tag = null;
|
|
55011
|
+
this.result = "";
|
|
55012
|
+
this.duplicates = [];
|
|
55013
|
+
this.usedDuplicates = null;
|
|
55014
|
+
}
|
|
55015
|
+
function indentString(string7, spaces) {
|
|
55016
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string7.length;
|
|
55017
|
+
while (position < length) {
|
|
55018
|
+
next = string7.indexOf(`
|
|
55019
|
+
`, position);
|
|
55020
|
+
if (next === -1) {
|
|
55021
|
+
line = string7.slice(position);
|
|
55022
|
+
position = length;
|
|
55023
|
+
} else {
|
|
55024
|
+
line = string7.slice(position, next + 1);
|
|
55025
|
+
position = next + 1;
|
|
55026
|
+
}
|
|
55027
|
+
if (line.length && line !== `
|
|
55028
|
+
`)
|
|
55029
|
+
result += ind;
|
|
55030
|
+
result += line;
|
|
55031
|
+
}
|
|
55032
|
+
return result;
|
|
55033
|
+
}
|
|
55034
|
+
function generateNextLine(state, level) {
|
|
55035
|
+
return `
|
|
55036
|
+
` + common.repeat(" ", state.indent * level);
|
|
55037
|
+
}
|
|
55038
|
+
function testImplicitResolving(state, str2) {
|
|
55039
|
+
var index, length, type2;
|
|
55040
|
+
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
55041
|
+
type2 = state.implicitTypes[index];
|
|
55042
|
+
if (type2.resolve(str2)) {
|
|
55043
|
+
return true;
|
|
55044
|
+
}
|
|
55045
|
+
}
|
|
55046
|
+
return false;
|
|
55047
|
+
}
|
|
55048
|
+
function isWhitespace(c) {
|
|
55049
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
55050
|
+
}
|
|
55051
|
+
function isPrintable(c) {
|
|
55052
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
55053
|
+
}
|
|
55054
|
+
function isNsCharOrWhitespace(c) {
|
|
55055
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
55056
|
+
}
|
|
55057
|
+
function isPlainSafe(c, prev, inblock) {
|
|
55058
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
55059
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
55060
|
+
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;
|
|
55061
|
+
}
|
|
55062
|
+
function isPlainSafeFirst(c) {
|
|
55063
|
+
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;
|
|
55064
|
+
}
|
|
55065
|
+
function isPlainSafeLast(c) {
|
|
55066
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
55067
|
+
}
|
|
55068
|
+
function codePointAt(string7, pos) {
|
|
55069
|
+
var first = string7.charCodeAt(pos), second;
|
|
55070
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string7.length) {
|
|
55071
|
+
second = string7.charCodeAt(pos + 1);
|
|
55072
|
+
if (second >= 56320 && second <= 57343) {
|
|
55073
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
55074
|
+
}
|
|
55075
|
+
}
|
|
55076
|
+
return first;
|
|
55077
|
+
}
|
|
55078
|
+
function needIndentIndicator(string7) {
|
|
55079
|
+
var leadingSpaceRe = /^\n* /;
|
|
55080
|
+
return leadingSpaceRe.test(string7);
|
|
55081
|
+
}
|
|
55082
|
+
var STYLE_PLAIN = 1;
|
|
55083
|
+
var STYLE_SINGLE = 2;
|
|
55084
|
+
var STYLE_LITERAL = 3;
|
|
55085
|
+
var STYLE_FOLDED = 4;
|
|
55086
|
+
var STYLE_DOUBLE = 5;
|
|
55087
|
+
function chooseScalarStyle(string7, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
55088
|
+
var i2;
|
|
55089
|
+
var char = 0;
|
|
55090
|
+
var prevChar = null;
|
|
55091
|
+
var hasLineBreak = false;
|
|
55092
|
+
var hasFoldableLine = false;
|
|
55093
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
55094
|
+
var previousLineBreak = -1;
|
|
55095
|
+
var plain = isPlainSafeFirst(codePointAt(string7, 0)) && isPlainSafeLast(codePointAt(string7, string7.length - 1));
|
|
55096
|
+
if (singleLineOnly || forceQuotes) {
|
|
55097
|
+
for (i2 = 0;i2 < string7.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
55098
|
+
char = codePointAt(string7, i2);
|
|
55099
|
+
if (!isPrintable(char)) {
|
|
55100
|
+
return STYLE_DOUBLE;
|
|
55101
|
+
}
|
|
55102
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
55103
|
+
prevChar = char;
|
|
55104
|
+
}
|
|
55105
|
+
} else {
|
|
55106
|
+
for (i2 = 0;i2 < string7.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
55107
|
+
char = codePointAt(string7, i2);
|
|
55108
|
+
if (char === CHAR_LINE_FEED) {
|
|
55109
|
+
hasLineBreak = true;
|
|
55110
|
+
if (shouldTrackWidth) {
|
|
55111
|
+
hasFoldableLine = hasFoldableLine || i2 - previousLineBreak - 1 > lineWidth && string7[previousLineBreak + 1] !== " ";
|
|
55112
|
+
previousLineBreak = i2;
|
|
55113
|
+
}
|
|
55114
|
+
} else if (!isPrintable(char)) {
|
|
55115
|
+
return STYLE_DOUBLE;
|
|
55116
|
+
}
|
|
55117
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
55118
|
+
prevChar = char;
|
|
55119
|
+
}
|
|
55120
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i2 - previousLineBreak - 1 > lineWidth && string7[previousLineBreak + 1] !== " ");
|
|
55121
|
+
}
|
|
55122
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
55123
|
+
if (plain && !forceQuotes && !testAmbiguousType(string7)) {
|
|
55124
|
+
return STYLE_PLAIN;
|
|
55125
|
+
}
|
|
55126
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
55127
|
+
}
|
|
55128
|
+
if (indentPerLevel > 9 && needIndentIndicator(string7)) {
|
|
55129
|
+
return STYLE_DOUBLE;
|
|
55130
|
+
}
|
|
55131
|
+
if (!forceQuotes) {
|
|
55132
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
55133
|
+
}
|
|
55134
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
55135
|
+
}
|
|
55136
|
+
function writeScalar(state, string7, level, iskey, inblock) {
|
|
55137
|
+
state.dump = function() {
|
|
55138
|
+
if (string7.length === 0) {
|
|
55139
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
55140
|
+
}
|
|
55141
|
+
if (!state.noCompatMode) {
|
|
55142
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string7) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string7)) {
|
|
55143
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string7 + '"' : "'" + string7 + "'";
|
|
55144
|
+
}
|
|
55145
|
+
}
|
|
55146
|
+
var indent = state.indent * Math.max(1, level);
|
|
55147
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
55148
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
55149
|
+
function testAmbiguity(string8) {
|
|
55150
|
+
return testImplicitResolving(state, string8);
|
|
55151
|
+
}
|
|
55152
|
+
switch (chooseScalarStyle(string7, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
55153
|
+
case STYLE_PLAIN:
|
|
55154
|
+
return string7;
|
|
55155
|
+
case STYLE_SINGLE:
|
|
55156
|
+
return "'" + string7.replace(/'/g, "''") + "'";
|
|
55157
|
+
case STYLE_LITERAL:
|
|
55158
|
+
return "|" + blockHeader(string7, state.indent) + dropEndingNewline(indentString(string7, indent));
|
|
55159
|
+
case STYLE_FOLDED:
|
|
55160
|
+
return ">" + blockHeader(string7, state.indent) + dropEndingNewline(indentString(foldString(string7, lineWidth), indent));
|
|
55161
|
+
case STYLE_DOUBLE:
|
|
55162
|
+
return '"' + escapeString(string7) + '"';
|
|
55163
|
+
default:
|
|
55164
|
+
throw new exception("impossible error: invalid scalar style");
|
|
55165
|
+
}
|
|
55166
|
+
}();
|
|
55167
|
+
}
|
|
55168
|
+
function blockHeader(string7, indentPerLevel) {
|
|
55169
|
+
var indentIndicator = needIndentIndicator(string7) ? String(indentPerLevel) : "";
|
|
55170
|
+
var clip = string7[string7.length - 1] === `
|
|
55171
|
+
`;
|
|
55172
|
+
var keep = clip && (string7[string7.length - 2] === `
|
|
55173
|
+
` || string7 === `
|
|
55174
|
+
`);
|
|
55175
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
55176
|
+
return indentIndicator + chomp + `
|
|
55177
|
+
`;
|
|
55178
|
+
}
|
|
55179
|
+
function dropEndingNewline(string7) {
|
|
55180
|
+
return string7[string7.length - 1] === `
|
|
55181
|
+
` ? string7.slice(0, -1) : string7;
|
|
55182
|
+
}
|
|
55183
|
+
function foldString(string7, width) {
|
|
55184
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
55185
|
+
var result = function() {
|
|
55186
|
+
var nextLF = string7.indexOf(`
|
|
55187
|
+
`);
|
|
55188
|
+
nextLF = nextLF !== -1 ? nextLF : string7.length;
|
|
55189
|
+
lineRe.lastIndex = nextLF;
|
|
55190
|
+
return foldLine(string7.slice(0, nextLF), width);
|
|
55191
|
+
}();
|
|
55192
|
+
var prevMoreIndented = string7[0] === `
|
|
55193
|
+
` || string7[0] === " ";
|
|
55194
|
+
var moreIndented;
|
|
55195
|
+
var match;
|
|
55196
|
+
while (match = lineRe.exec(string7)) {
|
|
55197
|
+
var prefix = match[1], line = match[2];
|
|
55198
|
+
moreIndented = line[0] === " ";
|
|
55199
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
55200
|
+
` : "") + foldLine(line, width);
|
|
55201
|
+
prevMoreIndented = moreIndented;
|
|
55202
|
+
}
|
|
55203
|
+
return result;
|
|
55204
|
+
}
|
|
55205
|
+
function foldLine(line, width) {
|
|
55206
|
+
if (line === "" || line[0] === " ")
|
|
55207
|
+
return line;
|
|
55208
|
+
var breakRe = / [^ ]/g;
|
|
55209
|
+
var match;
|
|
55210
|
+
var start = 0, end, curr = 0, next = 0;
|
|
55211
|
+
var result = "";
|
|
55212
|
+
while (match = breakRe.exec(line)) {
|
|
55213
|
+
next = match.index;
|
|
55214
|
+
if (next - start > width) {
|
|
55215
|
+
end = curr > start ? curr : next;
|
|
55216
|
+
result += `
|
|
55217
|
+
` + line.slice(start, end);
|
|
55218
|
+
start = end + 1;
|
|
55219
|
+
}
|
|
55220
|
+
curr = next;
|
|
55221
|
+
}
|
|
55222
|
+
result += `
|
|
55223
|
+
`;
|
|
55224
|
+
if (line.length - start > width && curr > start) {
|
|
55225
|
+
result += line.slice(start, curr) + `
|
|
55226
|
+
` + line.slice(curr + 1);
|
|
55227
|
+
} else {
|
|
55228
|
+
result += line.slice(start);
|
|
55229
|
+
}
|
|
55230
|
+
return result.slice(1);
|
|
55231
|
+
}
|
|
55232
|
+
function escapeString(string7) {
|
|
55233
|
+
var result = "";
|
|
55234
|
+
var char = 0;
|
|
55235
|
+
var escapeSeq;
|
|
55236
|
+
for (var i2 = 0;i2 < string7.length; char >= 65536 ? i2 += 2 : i2++) {
|
|
55237
|
+
char = codePointAt(string7, i2);
|
|
55238
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
55239
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
55240
|
+
result += string7[i2];
|
|
55241
|
+
if (char >= 65536)
|
|
55242
|
+
result += string7[i2 + 1];
|
|
55243
|
+
} else {
|
|
55244
|
+
result += escapeSeq || encodeHex(char);
|
|
55245
|
+
}
|
|
55246
|
+
}
|
|
55247
|
+
return result;
|
|
55248
|
+
}
|
|
55249
|
+
function writeFlowSequence(state, level, object5) {
|
|
55250
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
55251
|
+
for (index = 0, length = object5.length;index < length; index += 1) {
|
|
55252
|
+
value = object5[index];
|
|
55253
|
+
if (state.replacer) {
|
|
55254
|
+
value = state.replacer.call(object5, String(index), value);
|
|
55255
|
+
}
|
|
55256
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
55257
|
+
if (_result !== "")
|
|
55258
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
55259
|
+
_result += state.dump;
|
|
55260
|
+
}
|
|
55261
|
+
}
|
|
55262
|
+
state.tag = _tag;
|
|
55263
|
+
state.dump = "[" + _result + "]";
|
|
55264
|
+
}
|
|
55265
|
+
function writeBlockSequence(state, level, object5, compact) {
|
|
55266
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
55267
|
+
for (index = 0, length = object5.length;index < length; index += 1) {
|
|
55268
|
+
value = object5[index];
|
|
55269
|
+
if (state.replacer) {
|
|
55270
|
+
value = state.replacer.call(object5, String(index), value);
|
|
55271
|
+
}
|
|
55272
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
55273
|
+
if (!compact || _result !== "") {
|
|
55274
|
+
_result += generateNextLine(state, level);
|
|
55275
|
+
}
|
|
55276
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
55277
|
+
_result += "-";
|
|
55278
|
+
} else {
|
|
55279
|
+
_result += "- ";
|
|
55280
|
+
}
|
|
55281
|
+
_result += state.dump;
|
|
55282
|
+
}
|
|
55283
|
+
}
|
|
55284
|
+
state.tag = _tag;
|
|
55285
|
+
state.dump = _result || "[]";
|
|
55286
|
+
}
|
|
55287
|
+
function writeFlowMapping(state, level, object5) {
|
|
55288
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object5), index, length, objectKey, objectValue, pairBuffer;
|
|
55289
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
55290
|
+
pairBuffer = "";
|
|
55291
|
+
if (_result !== "")
|
|
55292
|
+
pairBuffer += ", ";
|
|
55293
|
+
if (state.condenseFlow)
|
|
55294
|
+
pairBuffer += '"';
|
|
55295
|
+
objectKey = objectKeyList[index];
|
|
55296
|
+
objectValue = object5[objectKey];
|
|
55297
|
+
if (state.replacer) {
|
|
55298
|
+
objectValue = state.replacer.call(object5, objectKey, objectValue);
|
|
55299
|
+
}
|
|
55300
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
55301
|
+
continue;
|
|
55302
|
+
}
|
|
55303
|
+
if (state.dump.length > 1024)
|
|
55304
|
+
pairBuffer += "? ";
|
|
55305
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
55306
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
55307
|
+
continue;
|
|
55308
|
+
}
|
|
55309
|
+
pairBuffer += state.dump;
|
|
55310
|
+
_result += pairBuffer;
|
|
55311
|
+
}
|
|
55312
|
+
state.tag = _tag;
|
|
55313
|
+
state.dump = "{" + _result + "}";
|
|
55314
|
+
}
|
|
55315
|
+
function writeBlockMapping(state, level, object5, compact) {
|
|
55316
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object5), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
55317
|
+
if (state.sortKeys === true) {
|
|
55318
|
+
objectKeyList.sort();
|
|
55319
|
+
} else if (typeof state.sortKeys === "function") {
|
|
55320
|
+
objectKeyList.sort(state.sortKeys);
|
|
55321
|
+
} else if (state.sortKeys) {
|
|
55322
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
55323
|
+
}
|
|
55324
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
55325
|
+
pairBuffer = "";
|
|
55326
|
+
if (!compact || _result !== "") {
|
|
55327
|
+
pairBuffer += generateNextLine(state, level);
|
|
55328
|
+
}
|
|
55329
|
+
objectKey = objectKeyList[index];
|
|
55330
|
+
objectValue = object5[objectKey];
|
|
55331
|
+
if (state.replacer) {
|
|
55332
|
+
objectValue = state.replacer.call(object5, objectKey, objectValue);
|
|
55333
|
+
}
|
|
55334
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
55335
|
+
continue;
|
|
55336
|
+
}
|
|
55337
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
55338
|
+
if (explicitPair) {
|
|
55339
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
55340
|
+
pairBuffer += "?";
|
|
55341
|
+
} else {
|
|
55342
|
+
pairBuffer += "? ";
|
|
55343
|
+
}
|
|
55344
|
+
}
|
|
55345
|
+
pairBuffer += state.dump;
|
|
55346
|
+
if (explicitPair) {
|
|
55347
|
+
pairBuffer += generateNextLine(state, level);
|
|
55348
|
+
}
|
|
55349
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
55350
|
+
continue;
|
|
55351
|
+
}
|
|
55352
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
55353
|
+
pairBuffer += ":";
|
|
55354
|
+
} else {
|
|
55355
|
+
pairBuffer += ": ";
|
|
55356
|
+
}
|
|
55357
|
+
pairBuffer += state.dump;
|
|
55358
|
+
_result += pairBuffer;
|
|
55359
|
+
}
|
|
55360
|
+
state.tag = _tag;
|
|
55361
|
+
state.dump = _result || "{}";
|
|
55362
|
+
}
|
|
55363
|
+
function detectType(state, object5, explicit) {
|
|
55364
|
+
var _result, typeList, index, length, type2, style;
|
|
55365
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
55366
|
+
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
55367
|
+
type2 = typeList[index];
|
|
55368
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object5 === "object" && object5 instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object5))) {
|
|
55369
|
+
if (explicit) {
|
|
55370
|
+
if (type2.multi && type2.representName) {
|
|
55371
|
+
state.tag = type2.representName(object5);
|
|
55372
|
+
} else {
|
|
55373
|
+
state.tag = type2.tag;
|
|
55374
|
+
}
|
|
55375
|
+
} else {
|
|
55376
|
+
state.tag = "?";
|
|
55377
|
+
}
|
|
55378
|
+
if (type2.represent) {
|
|
55379
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
55380
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
55381
|
+
_result = type2.represent(object5, style);
|
|
55382
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
55383
|
+
_result = type2.represent[style](object5, style);
|
|
55384
|
+
} else {
|
|
55385
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
55386
|
+
}
|
|
55387
|
+
state.dump = _result;
|
|
55388
|
+
}
|
|
55389
|
+
return true;
|
|
55390
|
+
}
|
|
55391
|
+
}
|
|
55392
|
+
return false;
|
|
55393
|
+
}
|
|
55394
|
+
function writeNode(state, level, object5, block, compact, iskey, isblockseq) {
|
|
55395
|
+
state.tag = null;
|
|
55396
|
+
state.dump = object5;
|
|
55397
|
+
if (!detectType(state, object5, false)) {
|
|
55398
|
+
detectType(state, object5, true);
|
|
55399
|
+
}
|
|
55400
|
+
var type2 = _toString.call(state.dump);
|
|
55401
|
+
var inblock = block;
|
|
55402
|
+
var tagStr;
|
|
55403
|
+
if (block) {
|
|
55404
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
55405
|
+
}
|
|
55406
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
55407
|
+
if (objectOrArray) {
|
|
55408
|
+
duplicateIndex = state.duplicates.indexOf(object5);
|
|
55409
|
+
duplicate = duplicateIndex !== -1;
|
|
55410
|
+
}
|
|
55411
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
55412
|
+
compact = false;
|
|
55413
|
+
}
|
|
55414
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
55415
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
55416
|
+
} else {
|
|
55417
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
55418
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
55419
|
+
}
|
|
55420
|
+
if (type2 === "[object Object]") {
|
|
55421
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
55422
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
55423
|
+
if (duplicate) {
|
|
55424
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
55425
|
+
}
|
|
55426
|
+
} else {
|
|
55427
|
+
writeFlowMapping(state, level, state.dump);
|
|
55428
|
+
if (duplicate) {
|
|
55429
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
55430
|
+
}
|
|
55431
|
+
}
|
|
55432
|
+
} else if (type2 === "[object Array]") {
|
|
55433
|
+
if (block && state.dump.length !== 0) {
|
|
55434
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
55435
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
55436
|
+
} else {
|
|
55437
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
55438
|
+
}
|
|
55439
|
+
if (duplicate) {
|
|
55440
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
55441
|
+
}
|
|
55442
|
+
} else {
|
|
55443
|
+
writeFlowSequence(state, level, state.dump);
|
|
55444
|
+
if (duplicate) {
|
|
55445
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
55446
|
+
}
|
|
55447
|
+
}
|
|
55448
|
+
} else if (type2 === "[object String]") {
|
|
55449
|
+
if (state.tag !== "?") {
|
|
55450
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
55451
|
+
}
|
|
55452
|
+
} else if (type2 === "[object Undefined]") {
|
|
55453
|
+
return false;
|
|
55454
|
+
} else {
|
|
55455
|
+
if (state.skipInvalid)
|
|
55456
|
+
return false;
|
|
55457
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
55458
|
+
}
|
|
55459
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
55460
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
55461
|
+
if (state.tag[0] === "!") {
|
|
55462
|
+
tagStr = "!" + tagStr;
|
|
55463
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
55464
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
55465
|
+
} else {
|
|
55466
|
+
tagStr = "!<" + tagStr + ">";
|
|
55467
|
+
}
|
|
55468
|
+
state.dump = tagStr + " " + state.dump;
|
|
55469
|
+
}
|
|
55470
|
+
}
|
|
55471
|
+
return true;
|
|
55472
|
+
}
|
|
55473
|
+
function getDuplicateReferences(object5, state) {
|
|
55474
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
55475
|
+
inspectNode(object5, objects, duplicatesIndexes);
|
|
55476
|
+
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
55477
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
55478
|
+
}
|
|
55479
|
+
state.usedDuplicates = new Array(length);
|
|
55480
|
+
}
|
|
55481
|
+
function inspectNode(object5, objects, duplicatesIndexes) {
|
|
55482
|
+
var objectKeyList, index, length;
|
|
55483
|
+
if (object5 !== null && typeof object5 === "object") {
|
|
55484
|
+
index = objects.indexOf(object5);
|
|
55485
|
+
if (index !== -1) {
|
|
55486
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
55487
|
+
duplicatesIndexes.push(index);
|
|
55488
|
+
}
|
|
55489
|
+
} else {
|
|
55490
|
+
objects.push(object5);
|
|
55491
|
+
if (Array.isArray(object5)) {
|
|
55492
|
+
for (index = 0, length = object5.length;index < length; index += 1) {
|
|
55493
|
+
inspectNode(object5[index], objects, duplicatesIndexes);
|
|
55494
|
+
}
|
|
55495
|
+
} else {
|
|
55496
|
+
objectKeyList = Object.keys(object5);
|
|
55497
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
55498
|
+
inspectNode(object5[objectKeyList[index]], objects, duplicatesIndexes);
|
|
55499
|
+
}
|
|
55500
|
+
}
|
|
55501
|
+
}
|
|
55502
|
+
}
|
|
55503
|
+
}
|
|
55504
|
+
function dump$1(input, options2) {
|
|
55505
|
+
options2 = options2 || {};
|
|
55506
|
+
var state = new State(options2);
|
|
55507
|
+
if (!state.noRefs)
|
|
55508
|
+
getDuplicateReferences(input, state);
|
|
55509
|
+
var value = input;
|
|
55510
|
+
if (state.replacer) {
|
|
55511
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
55512
|
+
}
|
|
55513
|
+
if (writeNode(state, 0, value, true, true))
|
|
55514
|
+
return state.dump + `
|
|
55515
|
+
`;
|
|
55516
|
+
return "";
|
|
55517
|
+
}
|
|
55518
|
+
var dump_1 = dump$1;
|
|
55519
|
+
var dumper = {
|
|
55520
|
+
dump: dump_1
|
|
55521
|
+
};
|
|
55522
|
+
function renamed(from, to) {
|
|
55523
|
+
return function() {
|
|
55524
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
|
|
55525
|
+
};
|
|
55526
|
+
}
|
|
55527
|
+
var load = loader.load;
|
|
55528
|
+
var loadAll = loader.loadAll;
|
|
55529
|
+
var dump = dumper.dump;
|
|
55530
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
55531
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
55532
|
+
var safeDump = renamed("safeDump", "dump");
|
|
55533
|
+
|
|
55534
|
+
// src/config/index.ts
|
|
55535
|
+
var CONFIG_PATH = resolve2(homedir(), ".config", "claude-threads", "config.yaml");
|
|
55536
|
+
|
|
52914
55537
|
// src/utils/battery.ts
|
|
52915
55538
|
import { exec } from "child_process";
|
|
52916
55539
|
import { promisify } from "util";
|
|
@@ -52918,13 +55541,13 @@ var execAsync = promisify(exec);
|
|
|
52918
55541
|
|
|
52919
55542
|
// src/changelog.ts
|
|
52920
55543
|
import { readFileSync as readFileSync2, existsSync as existsSync3 } from "fs";
|
|
52921
|
-
import { dirname as
|
|
55544
|
+
import { dirname as dirname3, resolve as resolve3 } from "path";
|
|
52922
55545
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
52923
|
-
var __dirname3 =
|
|
55546
|
+
var __dirname3 = dirname3(fileURLToPath2(import.meta.url));
|
|
52924
55547
|
function getReleaseNotes(version3) {
|
|
52925
55548
|
const possiblePaths = [
|
|
52926
|
-
|
|
52927
|
-
|
|
55549
|
+
resolve3(__dirname3, "..", "CHANGELOG.md"),
|
|
55550
|
+
resolve3(__dirname3, "..", "..", "CHANGELOG.md")
|
|
52928
55551
|
];
|
|
52929
55552
|
let changelogPath = null;
|
|
52930
55553
|
for (const p of possiblePaths) {
|
|
@@ -53310,8 +55933,8 @@ class Redactor {
|
|
|
53310
55933
|
this.anonymizationMap.clear();
|
|
53311
55934
|
this.anonymizationCounters.clear();
|
|
53312
55935
|
}
|
|
53313
|
-
const redactString = (
|
|
53314
|
-
return this._redactString(
|
|
55936
|
+
const redactString = (str2) => {
|
|
55937
|
+
return this._redactString(str2, false);
|
|
53315
55938
|
};
|
|
53316
55939
|
const processValue = (value) => {
|
|
53317
55940
|
if (typeof value === "string") {
|
|
@@ -53439,10 +56062,10 @@ class Redactor {
|
|
|
53439
56062
|
}
|
|
53440
56063
|
|
|
53441
56064
|
// src/persistence/thread-logger.ts
|
|
53442
|
-
import { homedir } from "os";
|
|
53443
|
-
import { join as join2, dirname as
|
|
56065
|
+
import { homedir as homedir2 } from "os";
|
|
56066
|
+
import { join as join2, dirname as dirname4 } from "path";
|
|
53444
56067
|
var log6 = createLogger("thread-log");
|
|
53445
|
-
var LOGS_BASE_DIR = join2(
|
|
56068
|
+
var LOGS_BASE_DIR = join2(homedir2(), ".claude-threads", "logs");
|
|
53446
56069
|
|
|
53447
56070
|
// src/operations/bug-report/handler.ts
|
|
53448
56071
|
var piiRedactor = new Redactor({ aggressive: true });
|
|
@@ -53477,9 +56100,9 @@ function crossSpawn(command, args, options2) {
|
|
|
53477
56100
|
|
|
53478
56101
|
// src/claude/cli.ts
|
|
53479
56102
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
53480
|
-
import { resolve as
|
|
56103
|
+
import { resolve as resolve4, dirname as dirname5 } from "path";
|
|
53481
56104
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
53482
|
-
import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync } from "fs";
|
|
56105
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, watchFile, unwatchFile, unlinkSync, statSync, readdirSync, writeFileSync } from "fs";
|
|
53483
56106
|
import { tmpdir } from "os";
|
|
53484
56107
|
import { join as join3 } from "path";
|
|
53485
56108
|
|
|
@@ -53593,6 +56216,64 @@ function isErrorResultEvent(event) {
|
|
|
53593
56216
|
return true;
|
|
53594
56217
|
return false;
|
|
53595
56218
|
}
|
|
56219
|
+
function materializeMcpConfig(config3, sessionId, opts = {}) {
|
|
56220
|
+
if (opts.inline ?? process.env.CLAUDE_THREADS_MCP_CONFIG_INLINE === "1") {
|
|
56221
|
+
return { mode: "inline", value: JSON.stringify(config3) };
|
|
56222
|
+
}
|
|
56223
|
+
const dir = opts.tmpDirOverride ?? tmpdir();
|
|
56224
|
+
const path = join3(dir, `claude-threads-mcp-${sessionId ?? process.pid}-${Date.now()}.json`);
|
|
56225
|
+
writeFileSync(path, JSON.stringify(config3), { mode: 384 });
|
|
56226
|
+
return { mode: "file", path };
|
|
56227
|
+
}
|
|
56228
|
+
function buildPermissionArgs(opts) {
|
|
56229
|
+
const args = [];
|
|
56230
|
+
if (opts.permissionMode === "bypass") {
|
|
56231
|
+
args.push("--dangerously-skip-permissions");
|
|
56232
|
+
return { args, tempFile: null };
|
|
56233
|
+
}
|
|
56234
|
+
if (!opts.platformConfig) {
|
|
56235
|
+
throw new Error(`platformConfig is required when permissionMode is '${opts.permissionMode}'`);
|
|
56236
|
+
}
|
|
56237
|
+
const mcpEnv = {
|
|
56238
|
+
PLATFORM_TYPE: opts.platformConfig.type,
|
|
56239
|
+
PLATFORM_URL: opts.platformConfig.url,
|
|
56240
|
+
PLATFORM_TOKEN: opts.platformConfig.token,
|
|
56241
|
+
PLATFORM_CHANNEL_ID: opts.platformConfig.channelId,
|
|
56242
|
+
PLATFORM_THREAD_ID: opts.threadId || "",
|
|
56243
|
+
ALLOWED_USERS: opts.platformConfig.allowedUsers.join(","),
|
|
56244
|
+
DEBUG: opts.debug ? "1" : "",
|
|
56245
|
+
PERMISSION_TIMEOUT_MS: String(opts.permissionTimeoutMs)
|
|
56246
|
+
};
|
|
56247
|
+
if (opts.platformConfig.appToken) {
|
|
56248
|
+
mcpEnv.PLATFORM_APP_TOKEN = opts.platformConfig.appToken;
|
|
56249
|
+
}
|
|
56250
|
+
const mcpConfig = {
|
|
56251
|
+
mcpServers: {
|
|
56252
|
+
"claude-threads-permissions": {
|
|
56253
|
+
type: "stdio",
|
|
56254
|
+
command: "node",
|
|
56255
|
+
args: [opts.mcpServerPath],
|
|
56256
|
+
env: mcpEnv
|
|
56257
|
+
}
|
|
56258
|
+
}
|
|
56259
|
+
};
|
|
56260
|
+
const materialized = materializeMcpConfig(mcpConfig, opts.sessionId, { inline: opts.inline });
|
|
56261
|
+
let tempFile = null;
|
|
56262
|
+
if (materialized.mode === "file") {
|
|
56263
|
+
tempFile = materialized.path;
|
|
56264
|
+
args.push("--mcp-config", materialized.path);
|
|
56265
|
+
} else {
|
|
56266
|
+
args.push("--mcp-config", materialized.value);
|
|
56267
|
+
}
|
|
56268
|
+
args.push("--permission-prompt-tool", "mcp__claude-threads-permissions__permission_prompt");
|
|
56269
|
+
if (opts.permissionMode === "auto") {
|
|
56270
|
+
args.push("--permission-mode", "auto");
|
|
56271
|
+
}
|
|
56272
|
+
return { args, tempFile };
|
|
56273
|
+
}
|
|
56274
|
+
var STDERR_PER_INSTANCE_CAP = 10240;
|
|
56275
|
+
var STDERR_AGGREGATE_SOFT_CAP = 10 * 1024 * 1024;
|
|
56276
|
+
var totalStderrBytes = 0;
|
|
53596
56277
|
|
|
53597
56278
|
class ClaudeCli extends EventEmitter2 {
|
|
53598
56279
|
process = null;
|
|
@@ -53602,6 +56283,7 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53602
56283
|
statusFilePath = null;
|
|
53603
56284
|
lastStatusData = null;
|
|
53604
56285
|
stderrBuffer = "";
|
|
56286
|
+
mcpConfigTempFile = null;
|
|
53605
56287
|
lastEmittedRateLimitDeadline = 0;
|
|
53606
56288
|
log;
|
|
53607
56289
|
constructor(options2) {
|
|
@@ -53653,6 +56335,7 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53653
56335
|
start() {
|
|
53654
56336
|
if (this.process)
|
|
53655
56337
|
throw new Error("Already running");
|
|
56338
|
+
totalStderrBytes -= this.stderrBuffer.length;
|
|
53656
56339
|
this.stderrBuffer = "";
|
|
53657
56340
|
this.lastEmittedRateLimitDeadline = 0;
|
|
53658
56341
|
cleanupBrowserBridgeSockets();
|
|
@@ -53671,40 +56354,18 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53671
56354
|
args.push("--session-id", this.options.sessionId);
|
|
53672
56355
|
}
|
|
53673
56356
|
}
|
|
53674
|
-
|
|
53675
|
-
|
|
53676
|
-
|
|
53677
|
-
|
|
53678
|
-
|
|
53679
|
-
|
|
53680
|
-
|
|
53681
|
-
|
|
53682
|
-
|
|
53683
|
-
|
|
53684
|
-
|
|
53685
|
-
|
|
53686
|
-
PLATFORM_CHANNEL_ID: platformConfig.channelId,
|
|
53687
|
-
PLATFORM_THREAD_ID: this.options.threadId || "",
|
|
53688
|
-
ALLOWED_USERS: platformConfig.allowedUsers.join(","),
|
|
53689
|
-
DEBUG: this.debug ? "1" : "",
|
|
53690
|
-
PERMISSION_TIMEOUT_MS: String(this.options.permissionTimeoutMs ?? 120000)
|
|
53691
|
-
};
|
|
53692
|
-
if (platformConfig.appToken) {
|
|
53693
|
-
mcpEnv.PLATFORM_APP_TOKEN = platformConfig.appToken;
|
|
53694
|
-
}
|
|
53695
|
-
const mcpConfig = {
|
|
53696
|
-
mcpServers: {
|
|
53697
|
-
"claude-threads-permissions": {
|
|
53698
|
-
type: "stdio",
|
|
53699
|
-
command: "node",
|
|
53700
|
-
args: [mcpServerPath],
|
|
53701
|
-
env: mcpEnv
|
|
53702
|
-
}
|
|
53703
|
-
}
|
|
53704
|
-
};
|
|
53705
|
-
args.push("--mcp-config", JSON.stringify(mcpConfig));
|
|
53706
|
-
args.push("--permission-prompt-tool", "mcp__claude-threads-permissions__permission_prompt");
|
|
53707
|
-
}
|
|
56357
|
+
const permissionMode = this.options.permissionMode ?? "default";
|
|
56358
|
+
const permResult = buildPermissionArgs({
|
|
56359
|
+
permissionMode,
|
|
56360
|
+
mcpServerPath: this.getMcpServerPath(),
|
|
56361
|
+
platformConfig: this.options.platformConfig,
|
|
56362
|
+
threadId: this.options.threadId,
|
|
56363
|
+
sessionId: this.options.sessionId,
|
|
56364
|
+
permissionTimeoutMs: this.options.permissionTimeoutMs ?? 120000,
|
|
56365
|
+
debug: this.debug
|
|
56366
|
+
});
|
|
56367
|
+
args.push(...permResult.args);
|
|
56368
|
+
this.mcpConfigTempFile = permResult.tempFile;
|
|
53708
56369
|
if (this.options.chrome) {
|
|
53709
56370
|
args.push("--chrome");
|
|
53710
56371
|
}
|
|
@@ -53739,10 +56400,13 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53739
56400
|
});
|
|
53740
56401
|
this.process.stderr?.on("data", (chunk) => {
|
|
53741
56402
|
const text = chunk.toString();
|
|
56403
|
+
const before = this.stderrBuffer.length;
|
|
53742
56404
|
this.stderrBuffer += text;
|
|
53743
|
-
|
|
53744
|
-
|
|
56405
|
+
const cap = totalStderrBytes > STDERR_AGGREGATE_SOFT_CAP ? 1024 : STDERR_PER_INSTANCE_CAP;
|
|
56406
|
+
if (this.stderrBuffer.length > cap) {
|
|
56407
|
+
this.stderrBuffer = this.stderrBuffer.slice(-cap);
|
|
53745
56408
|
}
|
|
56409
|
+
totalStderrBytes += this.stderrBuffer.length - before;
|
|
53746
56410
|
this.log.debug(`stderr: ${text.trim()}`);
|
|
53747
56411
|
if (process.env.INTEGRATION_TEST === "1") {
|
|
53748
56412
|
process.stderr.write(text);
|
|
@@ -53757,6 +56421,14 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53757
56421
|
this.log.debug(`Exited ${code}`);
|
|
53758
56422
|
this.process = null;
|
|
53759
56423
|
this.buffer = "";
|
|
56424
|
+
totalStderrBytes -= this.stderrBuffer.length;
|
|
56425
|
+
if (this.mcpConfigTempFile) {
|
|
56426
|
+
const path = this.mcpConfigTempFile;
|
|
56427
|
+
this.mcpConfigTempFile = null;
|
|
56428
|
+
try {
|
|
56429
|
+
unlinkSync(path);
|
|
56430
|
+
} catch {}
|
|
56431
|
+
}
|
|
53760
56432
|
this.emit("exit", code);
|
|
53761
56433
|
});
|
|
53762
56434
|
}
|
|
@@ -53862,7 +56534,7 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53862
56534
|
const pid = proc.pid;
|
|
53863
56535
|
this.process = null;
|
|
53864
56536
|
this.log.debug(`Killing Claude process (pid=${pid})`);
|
|
53865
|
-
return new Promise((
|
|
56537
|
+
return new Promise((resolve5) => {
|
|
53866
56538
|
this.log.debug("Sending first SIGINT");
|
|
53867
56539
|
proc.kill("SIGINT");
|
|
53868
56540
|
const secondSigint = setTimeout(() => {
|
|
@@ -53881,7 +56553,7 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53881
56553
|
this.log.debug(`Claude process exited (code=${code})`);
|
|
53882
56554
|
clearTimeout(secondSigint);
|
|
53883
56555
|
clearTimeout(forceKillTimeout);
|
|
53884
|
-
|
|
56556
|
+
resolve5();
|
|
53885
56557
|
});
|
|
53886
56558
|
});
|
|
53887
56559
|
}
|
|
@@ -53899,21 +56571,21 @@ class ClaudeCli extends EventEmitter2 {
|
|
|
53899
56571
|
}
|
|
53900
56572
|
getMcpServerPath() {
|
|
53901
56573
|
const __filename2 = fileURLToPath3(import.meta.url);
|
|
53902
|
-
const __dirname4 =
|
|
53903
|
-
const bundledPath =
|
|
56574
|
+
const __dirname4 = dirname5(__filename2);
|
|
56575
|
+
const bundledPath = resolve4(__dirname4, "mcp", "permission-server.js");
|
|
53904
56576
|
if (existsSync4(bundledPath)) {
|
|
53905
56577
|
return bundledPath;
|
|
53906
56578
|
}
|
|
53907
|
-
return
|
|
56579
|
+
return resolve4(__dirname4, "..", "mcp", "permission-server.js");
|
|
53908
56580
|
}
|
|
53909
56581
|
getStatusLineWriterPath() {
|
|
53910
56582
|
const __filename2 = fileURLToPath3(import.meta.url);
|
|
53911
|
-
const __dirname4 =
|
|
53912
|
-
const bundledPath =
|
|
56583
|
+
const __dirname4 = dirname5(__filename2);
|
|
56584
|
+
const bundledPath = resolve4(__dirname4, "statusline", "writer.js");
|
|
53913
56585
|
if (existsSync4(bundledPath)) {
|
|
53914
56586
|
return bundledPath;
|
|
53915
56587
|
}
|
|
53916
|
-
return
|
|
56588
|
+
return resolve4(__dirname4, "..", "statusline", "writer.js");
|
|
53917
56589
|
}
|
|
53918
56590
|
}
|
|
53919
56591
|
|
|
@@ -54002,8 +56674,8 @@ var COMMAND_REGISTRY = [
|
|
|
54002
56674
|
},
|
|
54003
56675
|
{
|
|
54004
56676
|
command: "permissions",
|
|
54005
|
-
description: "
|
|
54006
|
-
args: "
|
|
56677
|
+
description: "Set permission mode (default prompts; auto lets Claude classify; bypass skips all)",
|
|
56678
|
+
args: "default / auto / bypass",
|
|
54007
56679
|
category: "settings",
|
|
54008
56680
|
audience: "user",
|
|
54009
56681
|
claudeNotes: "User decisions, not yours",
|
|
@@ -54238,22 +56910,39 @@ var handleCd = async (ctx, args) => {
|
|
|
54238
56910
|
await ctx.sessionManager.changeDirectory(ctx.threadId, args, ctx.username);
|
|
54239
56911
|
return { handled: true };
|
|
54240
56912
|
};
|
|
56913
|
+
function parsePermissionMode(arg) {
|
|
56914
|
+
switch (arg?.toLowerCase()) {
|
|
56915
|
+
case "default":
|
|
56916
|
+
case "interactive":
|
|
56917
|
+
return "default";
|
|
56918
|
+
case "auto":
|
|
56919
|
+
return "auto";
|
|
56920
|
+
case "bypass":
|
|
56921
|
+
case "skip":
|
|
56922
|
+
return "bypass";
|
|
56923
|
+
default:
|
|
56924
|
+
return null;
|
|
56925
|
+
}
|
|
56926
|
+
}
|
|
54241
56927
|
var handlePermissions = async (ctx, args) => {
|
|
54242
|
-
const mode = args
|
|
56928
|
+
const mode = parsePermissionMode(args);
|
|
54243
56929
|
if (ctx.commandContext === "first-message") {
|
|
54244
|
-
if (mode
|
|
56930
|
+
if (mode) {
|
|
54245
56931
|
return {
|
|
54246
|
-
sessionOptions: {
|
|
56932
|
+
sessionOptions: {
|
|
56933
|
+
permissionMode: mode,
|
|
56934
|
+
forceInteractivePermissions: mode === "default"
|
|
56935
|
+
},
|
|
54247
56936
|
continueProcessing: true
|
|
54248
56937
|
};
|
|
54249
56938
|
}
|
|
54250
56939
|
return { handled: false };
|
|
54251
56940
|
}
|
|
54252
|
-
if (mode
|
|
54253
|
-
await ctx.
|
|
54254
|
-
|
|
54255
|
-
await ctx.client.createPost(`⚠️ Cannot upgrade to auto permissions - can only downgrade to interactive`, ctx.threadId);
|
|
56941
|
+
if (!mode) {
|
|
56942
|
+
await ctx.client.createPost(`⚠️ Unknown permission mode. Usage: \`!permissions default|auto|bypass\` (aliases: \`interactive\`, \`skip\`).`, ctx.threadId);
|
|
56943
|
+
return { handled: true };
|
|
54256
56944
|
}
|
|
56945
|
+
await ctx.sessionManager.setSessionPermissionMode(ctx.threadId, ctx.username, mode);
|
|
54257
56946
|
return { handled: true };
|
|
54258
56947
|
};
|
|
54259
56948
|
var handleWorktree = async (ctx, args) => {
|
|
@@ -54487,10 +57176,10 @@ init_emoji();
|
|
|
54487
57176
|
|
|
54488
57177
|
// src/git/worktree.ts
|
|
54489
57178
|
import * as path from "path";
|
|
54490
|
-
import { homedir as
|
|
57179
|
+
import { homedir as homedir3 } from "os";
|
|
54491
57180
|
var log9 = createLogger("git-wt");
|
|
54492
|
-
var WORKTREES_DIR = path.join(
|
|
54493
|
-
var METADATA_STORE_PATH = path.join(
|
|
57181
|
+
var WORKTREES_DIR = path.join(homedir3(), ".claude-threads", "worktrees");
|
|
57182
|
+
var METADATA_STORE_PATH = path.join(homedir3(), ".claude-threads", "worktree-metadata.json");
|
|
54494
57183
|
|
|
54495
57184
|
// src/operations/post-helpers/index.ts
|
|
54496
57185
|
var log10 = createLogger("helpers");
|
|
@@ -54616,11 +57305,11 @@ ${code}
|
|
|
54616
57305
|
}
|
|
54617
57306
|
}
|
|
54618
57307
|
|
|
54619
|
-
// src/mattermost/api.ts
|
|
54620
|
-
var
|
|
57308
|
+
// src/platform/mattermost/permission-api.ts
|
|
57309
|
+
var apiLog = createLogger("mm-api");
|
|
54621
57310
|
async function mattermostApi(config3, method, path2, body) {
|
|
54622
57311
|
const url2 = `${config3.url}/api/v4${path2}`;
|
|
54623
|
-
|
|
57312
|
+
apiLog.debug(`API ${method} ${path2}`);
|
|
54624
57313
|
const response = await fetch(url2, {
|
|
54625
57314
|
method,
|
|
54626
57315
|
headers: {
|
|
@@ -54631,10 +57320,10 @@ async function mattermostApi(config3, method, path2, body) {
|
|
|
54631
57320
|
});
|
|
54632
57321
|
if (!response.ok) {
|
|
54633
57322
|
const text = await response.text();
|
|
54634
|
-
|
|
57323
|
+
apiLog.warn(`API ${method} ${path2} failed: ${response.status} ${text.substring(0, 100)}`);
|
|
54635
57324
|
throw new Error(`Mattermost API error ${response.status}: ${text}`);
|
|
54636
57325
|
}
|
|
54637
|
-
|
|
57326
|
+
apiLog.debug(`API ${method} ${path2} → ${response.status}`);
|
|
54638
57327
|
return response.json();
|
|
54639
57328
|
}
|
|
54640
57329
|
async function getMe(config3) {
|
|
@@ -54644,7 +57333,7 @@ async function getUser(config3, userId) {
|
|
|
54644
57333
|
try {
|
|
54645
57334
|
return await mattermostApi(config3, "GET", `/users/${userId}`);
|
|
54646
57335
|
} catch (err) {
|
|
54647
|
-
|
|
57336
|
+
apiLog.debug(`Failed to get user ${userId}: ${err}`);
|
|
54648
57337
|
return null;
|
|
54649
57338
|
}
|
|
54650
57339
|
}
|
|
@@ -54655,7 +57344,7 @@ async function createPost(config3, channelId, message, rootId) {
|
|
|
54655
57344
|
root_id: rootId
|
|
54656
57345
|
});
|
|
54657
57346
|
}
|
|
54658
|
-
async function
|
|
57347
|
+
async function updatePostRaw(config3, postId, message) {
|
|
54659
57348
|
return mattermostApi(config3, "PUT", `/posts/${postId}`, {
|
|
54660
57349
|
id: postId,
|
|
54661
57350
|
message
|
|
@@ -54668,24 +57357,23 @@ async function addReaction(config3, postId, userId, emojiName) {
|
|
|
54668
57357
|
emoji_name: emojiName
|
|
54669
57358
|
});
|
|
54670
57359
|
}
|
|
54671
|
-
function
|
|
57360
|
+
function isUserInAllowList(username, allowList) {
|
|
54672
57361
|
if (allowList.length === 0)
|
|
54673
57362
|
return true;
|
|
54674
57363
|
return allowList.includes(username);
|
|
54675
57364
|
}
|
|
54676
|
-
async function
|
|
57365
|
+
async function createInteractivePostInternal(config3, channelId, message, reactions, rootId, botUserId) {
|
|
54677
57366
|
const post2 = await createPost(config3, channelId, message, rootId);
|
|
54678
57367
|
for (const emoji4 of reactions) {
|
|
54679
57368
|
try {
|
|
54680
57369
|
await addReaction(config3, post2.id, botUserId, emoji4);
|
|
54681
57370
|
} catch (err) {
|
|
54682
|
-
|
|
57371
|
+
apiLog.warn(`Failed to add reaction ${emoji4}: ${err}`);
|
|
54683
57372
|
}
|
|
54684
57373
|
}
|
|
54685
57374
|
return post2;
|
|
54686
57375
|
}
|
|
54687
57376
|
|
|
54688
|
-
// src/platform/mattermost/permission-api.ts
|
|
54689
57377
|
class MattermostPermissionApi {
|
|
54690
57378
|
apiConfig;
|
|
54691
57379
|
config;
|
|
@@ -54726,21 +57414,21 @@ class MattermostPermissionApi {
|
|
|
54726
57414
|
}
|
|
54727
57415
|
}
|
|
54728
57416
|
isUserAllowed(username) {
|
|
54729
|
-
return
|
|
57417
|
+
return isUserInAllowList(username, this.config.allowedUsers);
|
|
54730
57418
|
}
|
|
54731
57419
|
async createInteractivePost(message, reactions, threadId) {
|
|
54732
57420
|
mcpLogger.debug(`Creating interactive post with ${reactions.length} reaction options`);
|
|
54733
57421
|
const botUserId = await this.getBotUserId();
|
|
54734
|
-
const post2 = await
|
|
57422
|
+
const post2 = await createInteractivePostInternal(this.apiConfig, this.config.channelId, message, reactions, threadId, botUserId);
|
|
54735
57423
|
mcpLogger.debug(`Created post ${formatShortId(post2.id)}`);
|
|
54736
57424
|
return { id: post2.id };
|
|
54737
57425
|
}
|
|
54738
57426
|
async updatePost(postId, message) {
|
|
54739
57427
|
mcpLogger.debug(`Updating post ${postId.substring(0, 8)}`);
|
|
54740
|
-
await
|
|
57428
|
+
await updatePostRaw(this.apiConfig, postId, message);
|
|
54741
57429
|
}
|
|
54742
57430
|
async waitForReaction(postId, botUserId, timeoutMs) {
|
|
54743
|
-
return new Promise((
|
|
57431
|
+
return new Promise((resolve5) => {
|
|
54744
57432
|
const wsUrl = this.config.url.replace(/^http/, "ws") + "/api/v4/websocket";
|
|
54745
57433
|
mcpLogger.debug(`Connecting to WebSocket: ${wsUrl}`);
|
|
54746
57434
|
const ws = new WS(wsUrl);
|
|
@@ -54755,7 +57443,7 @@ class MattermostPermissionApi {
|
|
|
54755
57443
|
mcpLogger.debug(`Reaction wait timed out after ${timeoutMs}ms`);
|
|
54756
57444
|
resolved = true;
|
|
54757
57445
|
cleanup();
|
|
54758
|
-
|
|
57446
|
+
resolve5(null);
|
|
54759
57447
|
}
|
|
54760
57448
|
}, timeoutMs);
|
|
54761
57449
|
ws.onopen = () => {
|
|
@@ -54783,7 +57471,7 @@ class MattermostPermissionApi {
|
|
|
54783
57471
|
resolved = true;
|
|
54784
57472
|
clearTimeout(timeout);
|
|
54785
57473
|
cleanup();
|
|
54786
|
-
|
|
57474
|
+
resolve5({
|
|
54787
57475
|
postId: reaction.post_id,
|
|
54788
57476
|
userId: reaction.user_id,
|
|
54789
57477
|
emojiName: reaction.emoji_name
|
|
@@ -54798,7 +57486,7 @@ class MattermostPermissionApi {
|
|
|
54798
57486
|
if (!resolved) {
|
|
54799
57487
|
resolved = true;
|
|
54800
57488
|
clearTimeout(timeout);
|
|
54801
|
-
|
|
57489
|
+
resolve5(null);
|
|
54802
57490
|
}
|
|
54803
57491
|
};
|
|
54804
57492
|
ws.onclose = () => {
|
|
@@ -54806,7 +57494,7 @@ class MattermostPermissionApi {
|
|
|
54806
57494
|
if (!resolved) {
|
|
54807
57495
|
resolved = true;
|
|
54808
57496
|
clearTimeout(timeout);
|
|
54809
|
-
|
|
57497
|
+
resolve5(null);
|
|
54810
57498
|
}
|
|
54811
57499
|
};
|
|
54812
57500
|
});
|
|
@@ -54867,8 +57555,8 @@ ${code}
|
|
|
54867
57555
|
formatTable(headers, rows) {
|
|
54868
57556
|
const lines = [];
|
|
54869
57557
|
for (const row of rows) {
|
|
54870
|
-
const items = row.map((cell,
|
|
54871
|
-
const header = headers[
|
|
57558
|
+
const items = row.map((cell, i2) => {
|
|
57559
|
+
const header = headers[i2];
|
|
54872
57560
|
return header ? `*${header}:* ${cell}` : cell;
|
|
54873
57561
|
});
|
|
54874
57562
|
lines.push(items.join(" · "));
|
|
@@ -54986,7 +57674,7 @@ class SlackPermissionApi {
|
|
|
54986
57674
|
});
|
|
54987
57675
|
}
|
|
54988
57676
|
async waitForReaction(postId, botUserId, timeoutMs) {
|
|
54989
|
-
return new Promise((
|
|
57677
|
+
return new Promise((resolve5) => {
|
|
54990
57678
|
let resolved = false;
|
|
54991
57679
|
let ws = null;
|
|
54992
57680
|
const cleanup = () => {
|
|
@@ -54999,7 +57687,7 @@ class SlackPermissionApi {
|
|
|
54999
57687
|
mcpLogger.debug(`Reaction wait timed out after ${timeoutMs}ms`);
|
|
55000
57688
|
resolved = true;
|
|
55001
57689
|
cleanup();
|
|
55002
|
-
|
|
57690
|
+
resolve5(null);
|
|
55003
57691
|
}
|
|
55004
57692
|
}, timeoutMs);
|
|
55005
57693
|
this.getSocketModeUrl().then((wsUrl) => {
|
|
@@ -55037,7 +57725,7 @@ class SlackPermissionApi {
|
|
|
55037
57725
|
resolved = true;
|
|
55038
57726
|
clearTimeout(timeout);
|
|
55039
57727
|
cleanup();
|
|
55040
|
-
|
|
57728
|
+
resolve5({
|
|
55041
57729
|
postId: item.ts,
|
|
55042
57730
|
userId,
|
|
55043
57731
|
emojiName
|
|
@@ -55053,7 +57741,7 @@ class SlackPermissionApi {
|
|
|
55053
57741
|
resolved = true;
|
|
55054
57742
|
clearTimeout(timeout);
|
|
55055
57743
|
cleanup();
|
|
55056
|
-
|
|
57744
|
+
resolve5(null);
|
|
55057
57745
|
}
|
|
55058
57746
|
}
|
|
55059
57747
|
} catch (err) {
|
|
@@ -55066,7 +57754,7 @@ class SlackPermissionApi {
|
|
|
55066
57754
|
resolved = true;
|
|
55067
57755
|
clearTimeout(timeout);
|
|
55068
57756
|
cleanup();
|
|
55069
|
-
|
|
57757
|
+
resolve5(null);
|
|
55070
57758
|
}
|
|
55071
57759
|
};
|
|
55072
57760
|
ws.onclose = () => {
|
|
@@ -55074,7 +57762,7 @@ class SlackPermissionApi {
|
|
|
55074
57762
|
if (!resolved) {
|
|
55075
57763
|
resolved = true;
|
|
55076
57764
|
clearTimeout(timeout);
|
|
55077
|
-
|
|
57765
|
+
resolve5(null);
|
|
55078
57766
|
}
|
|
55079
57767
|
};
|
|
55080
57768
|
}).catch((err) => {
|
|
@@ -55082,7 +57770,7 @@ class SlackPermissionApi {
|
|
|
55082
57770
|
if (!resolved) {
|
|
55083
57771
|
resolved = true;
|
|
55084
57772
|
clearTimeout(timeout);
|
|
55085
|
-
|
|
57773
|
+
resolve5(null);
|
|
55086
57774
|
}
|
|
55087
57775
|
});
|
|
55088
57776
|
});
|
|
@@ -55143,18 +57831,19 @@ function getApi() {
|
|
|
55143
57831
|
return permissionApi;
|
|
55144
57832
|
}
|
|
55145
57833
|
var allowAllSession = false;
|
|
55146
|
-
async function
|
|
57834
|
+
async function handlePermissionWith(toolName, toolInput, cfg) {
|
|
55147
57835
|
mcpLogger.debug(`handlePermission called for ${toolName}`);
|
|
55148
|
-
if (
|
|
57836
|
+
if (cfg.getAllowAll()) {
|
|
55149
57837
|
mcpLogger.debug(`Auto-allowing ${toolName} (allow all active)`);
|
|
55150
57838
|
return { behavior: "allow", updatedInput: toolInput };
|
|
55151
57839
|
}
|
|
55152
|
-
if (!
|
|
57840
|
+
if (!cfg.platformConfigured) {
|
|
55153
57841
|
mcpLogger.error("Missing platform config");
|
|
55154
57842
|
return { behavior: "deny", message: "Permission service not configured" };
|
|
55155
57843
|
}
|
|
57844
|
+
const now = cfg.now ?? Date.now;
|
|
55156
57845
|
try {
|
|
55157
|
-
const api3 =
|
|
57846
|
+
const api3 = cfg.api;
|
|
55158
57847
|
const formatter = api3.getFormatter();
|
|
55159
57848
|
const toolInfo = formatToolForPermission(toolName, toolInput, formatter);
|
|
55160
57849
|
const message = `⚠️ ${formatter.formatBold("Permission requested")}
|
|
@@ -55163,12 +57852,12 @@ ${toolInfo}
|
|
|
55163
57852
|
|
|
55164
57853
|
` + `\uD83D\uDC4D Allow | ✅ Allow all | \uD83D\uDC4E Deny`;
|
|
55165
57854
|
const botUserId = await api3.getBotUserId();
|
|
55166
|
-
const post2 = await api3.createInteractivePost(message, [APPROVAL_EMOJIS[0], ALLOW_ALL_EMOJIS[0], DENIAL_EMOJIS[0]],
|
|
55167
|
-
const startTime =
|
|
57855
|
+
const post2 = await api3.createInteractivePost(message, [APPROVAL_EMOJIS[0], ALLOW_ALL_EMOJIS[0], DENIAL_EMOJIS[0]], cfg.threadId);
|
|
57856
|
+
const startTime = now();
|
|
55168
57857
|
let reaction;
|
|
55169
57858
|
let username = null;
|
|
55170
57859
|
while (true) {
|
|
55171
|
-
const remainingTime =
|
|
57860
|
+
const remainingTime = cfg.timeoutMs - (now() - startTime);
|
|
55172
57861
|
if (remainingTime <= 0) {
|
|
55173
57862
|
await api3.updatePost(post2.id, `⏱️ ${formatter.formatBold("Timed out")} - permission denied
|
|
55174
57863
|
|
|
@@ -55199,7 +57888,7 @@ ${toolInfo}`);
|
|
|
55199
57888
|
mcpLogger.info(`Allowed: ${toolName}`);
|
|
55200
57889
|
return { behavior: "allow", updatedInput: toolInput };
|
|
55201
57890
|
} else if (isAllowAllEmoji(emoji4)) {
|
|
55202
|
-
|
|
57891
|
+
cfg.setAllowAll(true);
|
|
55203
57892
|
await api3.updatePost(post2.id, `✅ ${formatter.formatBold("Allowed all")} by ${formatter.formatUserMention(username)}
|
|
55204
57893
|
|
|
55205
57894
|
${toolInfo}`);
|
|
@@ -55217,6 +57906,18 @@ ${toolInfo}`);
|
|
|
55217
57906
|
return { behavior: "deny", message: String(error49) };
|
|
55218
57907
|
}
|
|
55219
57908
|
}
|
|
57909
|
+
async function handlePermission(toolName, toolInput) {
|
|
57910
|
+
return handlePermissionWith(toolName, toolInput, {
|
|
57911
|
+
api: getApi(),
|
|
57912
|
+
threadId: PLATFORM_THREAD_ID || undefined,
|
|
57913
|
+
timeoutMs: PERMISSION_TIMEOUT_MS,
|
|
57914
|
+
platformConfigured: Boolean(PLATFORM_URL && PLATFORM_TOKEN && PLATFORM_CHANNEL_ID),
|
|
57915
|
+
getAllowAll: () => allowAllSession,
|
|
57916
|
+
setAllowAll: (v) => {
|
|
57917
|
+
allowAllSession = v;
|
|
57918
|
+
}
|
|
57919
|
+
});
|
|
57920
|
+
}
|
|
55220
57921
|
var permissionInputSchema = {
|
|
55221
57922
|
tool_name: exports_external.string().describe("Name of the tool requesting permission"),
|
|
55222
57923
|
input: exports_external.record(exports_external.string(), exports_external.unknown()).describe("Tool input parameters")
|
|
@@ -55240,3 +57941,6 @@ main().catch((err) => {
|
|
|
55240
57941
|
mcpLogger.error(`Fatal: ${err}`);
|
|
55241
57942
|
process.exit(1);
|
|
55242
57943
|
});
|
|
57944
|
+
export {
|
|
57945
|
+
handlePermissionWith
|
|
57946
|
+
};
|