conversationalist 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +227 -58
- package/dist/adapters/anthropic/index.d.ts +11 -6
- package/dist/adapters/anthropic/index.d.ts.map +1 -1
- package/dist/adapters/anthropic/index.js +16 -3
- package/dist/adapters/anthropic/index.js.map +5 -4
- package/dist/adapters/gemini/index.d.ts +2 -2
- package/dist/adapters/gemini/index.d.ts.map +1 -1
- package/dist/adapters/gemini/index.js +52 -9
- package/dist/adapters/gemini/index.js.map +5 -4
- package/dist/adapters/openai/index.d.ts +32 -5
- package/dist/adapters/openai/index.d.ts.map +1 -1
- package/dist/adapters/openai/index.js +30 -8
- package/dist/adapters/openai/index.js.map +5 -4
- package/dist/context.d.ts.map +1 -1
- package/dist/conversation/append.d.ts +4 -4
- package/dist/conversation/append.d.ts.map +1 -1
- package/dist/conversation/create.d.ts +2 -3
- package/dist/conversation/create.d.ts.map +1 -1
- package/dist/conversation/index.d.ts +2 -2
- package/dist/conversation/index.d.ts.map +1 -1
- package/dist/conversation/modify.d.ts.map +1 -1
- package/dist/conversation/query.d.ts +9 -5
- package/dist/conversation/query.d.ts.map +1 -1
- package/dist/conversation/serialization.d.ts +21 -5
- package/dist/conversation/serialization.d.ts.map +1 -1
- package/dist/conversation/system-messages.d.ts +3 -3
- package/dist/conversation/system-messages.d.ts.map +1 -1
- package/dist/conversation/transform.d.ts.map +1 -1
- package/dist/conversation.d.ts +84 -14
- package/dist/conversation.d.ts.map +1 -1
- package/dist/export/index.d.ts +7 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/export/index.js +3762 -0
- package/dist/export/index.js.map +62 -0
- package/dist/history.d.ts +102 -24
- package/dist/history.d.ts.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +440 -3982
- package/dist/index.js.map +15 -57
- package/dist/markdown/index.d.ts +15 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +4969 -0
- package/dist/markdown/index.js.map +69 -0
- package/dist/message.d.ts +1 -1
- package/dist/message.d.ts.map +1 -1
- package/dist/multi-modal.d.ts +3 -0
- package/dist/multi-modal.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +59 -0
- package/dist/plugins/index.js.map +10 -0
- package/dist/plugins/pii-redaction.d.ts +10 -1
- package/dist/plugins/pii-redaction.d.ts.map +1 -1
- package/dist/redaction/index.d.ts +2 -0
- package/dist/redaction/index.d.ts.map +1 -0
- package/dist/redaction/index.js +59 -0
- package/dist/redaction/index.js.map +10 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +114 -0
- package/dist/schemas/index.js.map +10 -0
- package/dist/schemas.d.ts +325 -15
- package/dist/schemas.d.ts.map +1 -1
- package/dist/sort/index.d.ts +2 -0
- package/dist/sort/index.d.ts.map +1 -0
- package/dist/sort/index.js +32 -0
- package/dist/sort/index.js.map +10 -0
- package/dist/streaming.d.ts +3 -3
- package/dist/streaming.d.ts.map +1 -1
- package/dist/types.d.ts +107 -37
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/deterministic.d.ts +37 -0
- package/dist/utilities/deterministic.d.ts.map +1 -0
- package/dist/utilities/index.d.ts +3 -3
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/line-endings.d.ts +5 -0
- package/dist/utilities/line-endings.d.ts.map +1 -0
- package/dist/utilities/markdown.d.ts +47 -21
- package/dist/utilities/markdown.d.ts.map +1 -1
- package/dist/utilities/message-store.d.ts +6 -0
- package/dist/utilities/message-store.d.ts.map +1 -0
- package/dist/utilities/message.d.ts +9 -3
- package/dist/utilities/message.d.ts.map +1 -1
- package/dist/utilities/tool-calls.d.ts +4 -4
- package/dist/utilities/tool-calls.d.ts.map +1 -1
- package/dist/utilities/tool-results.d.ts +10 -0
- package/dist/utilities/tool-results.d.ts.map +1 -0
- package/dist/utilities/transient.d.ts +47 -0
- package/dist/utilities/transient.d.ts.map +1 -0
- package/dist/utilities.d.ts +6 -4
- package/dist/utilities.d.ts.map +1 -1
- package/dist/versioning/index.d.ts +3 -0
- package/dist/versioning/index.d.ts.map +1 -0
- package/dist/versioning/index.js +58 -0
- package/dist/versioning/index.js.map +11 -0
- package/dist/with-conversation.d.ts +8 -8
- package/dist/with-conversation.d.ts.map +1 -1
- package/package.json +26 -1
package/dist/index.js
CHANGED
|
@@ -1,3496 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
-
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
-
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
-
for (let key of __getOwnPropNames(mod))
|
|
11
|
-
if (!__hasOwnProp.call(to, key))
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: () => mod[key],
|
|
14
|
-
enumerable: true
|
|
15
|
-
});
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
|
-
|
|
21
|
-
// node_modules/kind-of/index.js
|
|
22
|
-
var require_kind_of = __commonJS((exports, module) => {
|
|
23
|
-
var toString = Object.prototype.toString;
|
|
24
|
-
module.exports = function kindOf(val) {
|
|
25
|
-
if (val === undefined)
|
|
26
|
-
return "undefined";
|
|
27
|
-
if (val === null)
|
|
28
|
-
return "null";
|
|
29
|
-
var type = typeof val;
|
|
30
|
-
if (type === "boolean")
|
|
31
|
-
return "boolean";
|
|
32
|
-
if (type === "string")
|
|
33
|
-
return "string";
|
|
34
|
-
if (type === "number")
|
|
35
|
-
return "number";
|
|
36
|
-
if (type === "symbol")
|
|
37
|
-
return "symbol";
|
|
38
|
-
if (type === "function") {
|
|
39
|
-
return isGeneratorFn(val) ? "generatorfunction" : "function";
|
|
40
|
-
}
|
|
41
|
-
if (isArray(val))
|
|
42
|
-
return "array";
|
|
43
|
-
if (isBuffer(val))
|
|
44
|
-
return "buffer";
|
|
45
|
-
if (isArguments(val))
|
|
46
|
-
return "arguments";
|
|
47
|
-
if (isDate(val))
|
|
48
|
-
return "date";
|
|
49
|
-
if (isError(val))
|
|
50
|
-
return "error";
|
|
51
|
-
if (isRegexp(val))
|
|
52
|
-
return "regexp";
|
|
53
|
-
switch (ctorName(val)) {
|
|
54
|
-
case "Symbol":
|
|
55
|
-
return "symbol";
|
|
56
|
-
case "Promise":
|
|
57
|
-
return "promise";
|
|
58
|
-
case "WeakMap":
|
|
59
|
-
return "weakmap";
|
|
60
|
-
case "WeakSet":
|
|
61
|
-
return "weakset";
|
|
62
|
-
case "Map":
|
|
63
|
-
return "map";
|
|
64
|
-
case "Set":
|
|
65
|
-
return "set";
|
|
66
|
-
case "Int8Array":
|
|
67
|
-
return "int8array";
|
|
68
|
-
case "Uint8Array":
|
|
69
|
-
return "uint8array";
|
|
70
|
-
case "Uint8ClampedArray":
|
|
71
|
-
return "uint8clampedarray";
|
|
72
|
-
case "Int16Array":
|
|
73
|
-
return "int16array";
|
|
74
|
-
case "Uint16Array":
|
|
75
|
-
return "uint16array";
|
|
76
|
-
case "Int32Array":
|
|
77
|
-
return "int32array";
|
|
78
|
-
case "Uint32Array":
|
|
79
|
-
return "uint32array";
|
|
80
|
-
case "Float32Array":
|
|
81
|
-
return "float32array";
|
|
82
|
-
case "Float64Array":
|
|
83
|
-
return "float64array";
|
|
84
|
-
}
|
|
85
|
-
if (isGeneratorObj(val)) {
|
|
86
|
-
return "generator";
|
|
87
|
-
}
|
|
88
|
-
type = toString.call(val);
|
|
89
|
-
switch (type) {
|
|
90
|
-
case "[object Object]":
|
|
91
|
-
return "object";
|
|
92
|
-
case "[object Map Iterator]":
|
|
93
|
-
return "mapiterator";
|
|
94
|
-
case "[object Set Iterator]":
|
|
95
|
-
return "setiterator";
|
|
96
|
-
case "[object String Iterator]":
|
|
97
|
-
return "stringiterator";
|
|
98
|
-
case "[object Array Iterator]":
|
|
99
|
-
return "arrayiterator";
|
|
100
|
-
}
|
|
101
|
-
return type.slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
102
|
-
};
|
|
103
|
-
function ctorName(val) {
|
|
104
|
-
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
105
|
-
}
|
|
106
|
-
function isArray(val) {
|
|
107
|
-
if (Array.isArray)
|
|
108
|
-
return Array.isArray(val);
|
|
109
|
-
return val instanceof Array;
|
|
110
|
-
}
|
|
111
|
-
function isError(val) {
|
|
112
|
-
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
113
|
-
}
|
|
114
|
-
function isDate(val) {
|
|
115
|
-
if (val instanceof Date)
|
|
116
|
-
return true;
|
|
117
|
-
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
118
|
-
}
|
|
119
|
-
function isRegexp(val) {
|
|
120
|
-
if (val instanceof RegExp)
|
|
121
|
-
return true;
|
|
122
|
-
return typeof val.flags === "string" && typeof val.ignoreCase === "boolean" && typeof val.multiline === "boolean" && typeof val.global === "boolean";
|
|
123
|
-
}
|
|
124
|
-
function isGeneratorFn(name, val) {
|
|
125
|
-
return ctorName(name) === "GeneratorFunction";
|
|
126
|
-
}
|
|
127
|
-
function isGeneratorObj(val) {
|
|
128
|
-
return typeof val.throw === "function" && typeof val.return === "function" && typeof val.next === "function";
|
|
129
|
-
}
|
|
130
|
-
function isArguments(val) {
|
|
131
|
-
try {
|
|
132
|
-
if (typeof val.length === "number" && typeof val.callee === "function") {
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
} catch (err) {
|
|
136
|
-
if (err.message.indexOf("callee") !== -1) {
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
}
|
|
142
|
-
function isBuffer(val) {
|
|
143
|
-
if (val.constructor && typeof val.constructor.isBuffer === "function") {
|
|
144
|
-
return val.constructor.isBuffer(val);
|
|
145
|
-
}
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// node_modules/is-extendable/index.js
|
|
151
|
-
var require_is_extendable = __commonJS((exports, module) => {
|
|
152
|
-
/*!
|
|
153
|
-
* is-extendable <https://github.com/jonschlinkert/is-extendable>
|
|
154
|
-
*
|
|
155
|
-
* Copyright (c) 2015, Jon Schlinkert.
|
|
156
|
-
* Licensed under the MIT License.
|
|
157
|
-
*/
|
|
158
|
-
module.exports = function isExtendable(val) {
|
|
159
|
-
return typeof val !== "undefined" && val !== null && (typeof val === "object" || typeof val === "function");
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
// node_modules/extend-shallow/index.js
|
|
164
|
-
var require_extend_shallow = __commonJS((exports, module) => {
|
|
165
|
-
var isObject = require_is_extendable();
|
|
166
|
-
module.exports = function extend(o) {
|
|
167
|
-
if (!isObject(o)) {
|
|
168
|
-
o = {};
|
|
169
|
-
}
|
|
170
|
-
var len = arguments.length;
|
|
171
|
-
for (var i = 1;i < len; i++) {
|
|
172
|
-
var obj = arguments[i];
|
|
173
|
-
if (isObject(obj)) {
|
|
174
|
-
assign(o, obj);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return o;
|
|
178
|
-
};
|
|
179
|
-
function assign(a, b) {
|
|
180
|
-
for (var key in b) {
|
|
181
|
-
if (hasOwn(b, key)) {
|
|
182
|
-
a[key] = b[key];
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function hasOwn(obj, key) {
|
|
187
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// node_modules/section-matter/index.js
|
|
192
|
-
var require_section_matter = __commonJS((exports, module) => {
|
|
193
|
-
var typeOf = require_kind_of();
|
|
194
|
-
var extend = require_extend_shallow();
|
|
195
|
-
module.exports = function(input, options2) {
|
|
196
|
-
if (typeof options2 === "function") {
|
|
197
|
-
options2 = { parse: options2 };
|
|
198
|
-
}
|
|
199
|
-
var file = toObject(input);
|
|
200
|
-
var defaults = { section_delimiter: "---", parse: identity };
|
|
201
|
-
var opts = extend({}, defaults, options2);
|
|
202
|
-
var delim = opts.section_delimiter;
|
|
203
|
-
var lines = file.content.split(/\r?\n/);
|
|
204
|
-
var sections = null;
|
|
205
|
-
var section = createSection();
|
|
206
|
-
var content = [];
|
|
207
|
-
var stack = [];
|
|
208
|
-
function initSections(val) {
|
|
209
|
-
file.content = val;
|
|
210
|
-
sections = [];
|
|
211
|
-
content = [];
|
|
212
|
-
}
|
|
213
|
-
function closeSection(val) {
|
|
214
|
-
if (stack.length) {
|
|
215
|
-
section.key = getKey(stack[0], delim);
|
|
216
|
-
section.content = val;
|
|
217
|
-
opts.parse(section, sections);
|
|
218
|
-
sections.push(section);
|
|
219
|
-
section = createSection();
|
|
220
|
-
content = [];
|
|
221
|
-
stack = [];
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
for (var i = 0;i < lines.length; i++) {
|
|
225
|
-
var line = lines[i];
|
|
226
|
-
var len = stack.length;
|
|
227
|
-
var ln = line.trim();
|
|
228
|
-
if (isDelimiter(ln, delim)) {
|
|
229
|
-
if (ln.length === 3 && i !== 0) {
|
|
230
|
-
if (len === 0 || len === 2) {
|
|
231
|
-
content.push(line);
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
stack.push(ln);
|
|
235
|
-
section.data = content.join(`
|
|
236
|
-
`);
|
|
237
|
-
content = [];
|
|
238
|
-
continue;
|
|
239
|
-
}
|
|
240
|
-
if (sections === null) {
|
|
241
|
-
initSections(content.join(`
|
|
242
|
-
`));
|
|
243
|
-
}
|
|
244
|
-
if (len === 2) {
|
|
245
|
-
closeSection(content.join(`
|
|
246
|
-
`));
|
|
247
|
-
}
|
|
248
|
-
stack.push(ln);
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
content.push(line);
|
|
252
|
-
}
|
|
253
|
-
if (sections === null) {
|
|
254
|
-
initSections(content.join(`
|
|
255
|
-
`));
|
|
256
|
-
} else {
|
|
257
|
-
closeSection(content.join(`
|
|
258
|
-
`));
|
|
259
|
-
}
|
|
260
|
-
file.sections = sections;
|
|
261
|
-
return file;
|
|
262
|
-
};
|
|
263
|
-
function isDelimiter(line, delim) {
|
|
264
|
-
if (line.slice(0, delim.length) !== delim) {
|
|
265
|
-
return false;
|
|
266
|
-
}
|
|
267
|
-
if (line.charAt(delim.length + 1) === delim.slice(-1)) {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
function toObject(input) {
|
|
273
|
-
if (typeOf(input) !== "object") {
|
|
274
|
-
input = { content: input };
|
|
275
|
-
}
|
|
276
|
-
if (typeof input.content !== "string" && !isBuffer(input.content)) {
|
|
277
|
-
throw new TypeError("expected a buffer or string");
|
|
278
|
-
}
|
|
279
|
-
input.content = input.content.toString();
|
|
280
|
-
input.sections = [];
|
|
281
|
-
return input;
|
|
282
|
-
}
|
|
283
|
-
function getKey(val, delim) {
|
|
284
|
-
return val ? val.slice(delim.length).trim() : "";
|
|
285
|
-
}
|
|
286
|
-
function createSection() {
|
|
287
|
-
return { key: "", data: "", content: "" };
|
|
288
|
-
}
|
|
289
|
-
function identity(val) {
|
|
290
|
-
return val;
|
|
291
|
-
}
|
|
292
|
-
function isBuffer(val) {
|
|
293
|
-
if (val && val.constructor && typeof val.constructor.isBuffer === "function") {
|
|
294
|
-
return val.constructor.isBuffer(val);
|
|
295
|
-
}
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/common.js
|
|
301
|
-
var require_common = __commonJS((exports, module) => {
|
|
302
|
-
function isNothing(subject) {
|
|
303
|
-
return typeof subject === "undefined" || subject === null;
|
|
304
|
-
}
|
|
305
|
-
function isObject(subject) {
|
|
306
|
-
return typeof subject === "object" && subject !== null;
|
|
307
|
-
}
|
|
308
|
-
function toArray(sequence) {
|
|
309
|
-
if (Array.isArray(sequence))
|
|
310
|
-
return sequence;
|
|
311
|
-
else if (isNothing(sequence))
|
|
312
|
-
return [];
|
|
313
|
-
return [sequence];
|
|
314
|
-
}
|
|
315
|
-
function extend(target, source) {
|
|
316
|
-
var index, length, key, sourceKeys;
|
|
317
|
-
if (source) {
|
|
318
|
-
sourceKeys = Object.keys(source);
|
|
319
|
-
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
320
|
-
key = sourceKeys[index];
|
|
321
|
-
target[key] = source[key];
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
return target;
|
|
325
|
-
}
|
|
326
|
-
function repeat(string, count) {
|
|
327
|
-
var result = "", cycle;
|
|
328
|
-
for (cycle = 0;cycle < count; cycle += 1) {
|
|
329
|
-
result += string;
|
|
330
|
-
}
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
function isNegativeZero(number) {
|
|
334
|
-
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
335
|
-
}
|
|
336
|
-
exports.isNothing = isNothing;
|
|
337
|
-
exports.isObject = isObject;
|
|
338
|
-
exports.toArray = toArray;
|
|
339
|
-
exports.repeat = repeat;
|
|
340
|
-
exports.isNegativeZero = isNegativeZero;
|
|
341
|
-
exports.extend = extend;
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/exception.js
|
|
345
|
-
var require_exception = __commonJS((exports, module) => {
|
|
346
|
-
function YAMLException(reason, mark) {
|
|
347
|
-
Error.call(this);
|
|
348
|
-
this.name = "YAMLException";
|
|
349
|
-
this.reason = reason;
|
|
350
|
-
this.mark = mark;
|
|
351
|
-
this.message = (this.reason || "(unknown reason)") + (this.mark ? " " + this.mark.toString() : "");
|
|
352
|
-
if (Error.captureStackTrace) {
|
|
353
|
-
Error.captureStackTrace(this, this.constructor);
|
|
354
|
-
} else {
|
|
355
|
-
this.stack = new Error().stack || "";
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
YAMLException.prototype = Object.create(Error.prototype);
|
|
359
|
-
YAMLException.prototype.constructor = YAMLException;
|
|
360
|
-
YAMLException.prototype.toString = function toString(compact) {
|
|
361
|
-
var result = this.name + ": ";
|
|
362
|
-
result += this.reason || "(unknown reason)";
|
|
363
|
-
if (!compact && this.mark) {
|
|
364
|
-
result += " " + this.mark.toString();
|
|
365
|
-
}
|
|
366
|
-
return result;
|
|
367
|
-
};
|
|
368
|
-
module.exports = YAMLException;
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/mark.js
|
|
372
|
-
var require_mark = __commonJS((exports, module) => {
|
|
373
|
-
var common = require_common();
|
|
374
|
-
function Mark(name, buffer, position, line, column) {
|
|
375
|
-
this.name = name;
|
|
376
|
-
this.buffer = buffer;
|
|
377
|
-
this.position = position;
|
|
378
|
-
this.line = line;
|
|
379
|
-
this.column = column;
|
|
380
|
-
}
|
|
381
|
-
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
|
382
|
-
var head, start, tail, end, snippet;
|
|
383
|
-
if (!this.buffer)
|
|
384
|
-
return null;
|
|
385
|
-
indent = indent || 4;
|
|
386
|
-
maxLength = maxLength || 75;
|
|
387
|
-
head = "";
|
|
388
|
-
start = this.position;
|
|
389
|
-
while (start > 0 && `\x00\r
|
|
390
|
-
\u2028\u2029`.indexOf(this.buffer.charAt(start - 1)) === -1) {
|
|
391
|
-
start -= 1;
|
|
392
|
-
if (this.position - start > maxLength / 2 - 1) {
|
|
393
|
-
head = " ... ";
|
|
394
|
-
start += 5;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
tail = "";
|
|
399
|
-
end = this.position;
|
|
400
|
-
while (end < this.buffer.length && `\x00\r
|
|
401
|
-
\u2028\u2029`.indexOf(this.buffer.charAt(end)) === -1) {
|
|
402
|
-
end += 1;
|
|
403
|
-
if (end - this.position > maxLength / 2 - 1) {
|
|
404
|
-
tail = " ... ";
|
|
405
|
-
end -= 5;
|
|
406
|
-
break;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
snippet = this.buffer.slice(start, end);
|
|
410
|
-
return common.repeat(" ", indent) + head + snippet + tail + `
|
|
411
|
-
` + common.repeat(" ", indent + this.position - start + head.length) + "^";
|
|
412
|
-
};
|
|
413
|
-
Mark.prototype.toString = function toString(compact) {
|
|
414
|
-
var snippet, where = "";
|
|
415
|
-
if (this.name) {
|
|
416
|
-
where += 'in "' + this.name + '" ';
|
|
417
|
-
}
|
|
418
|
-
where += "at line " + (this.line + 1) + ", column " + (this.column + 1);
|
|
419
|
-
if (!compact) {
|
|
420
|
-
snippet = this.getSnippet();
|
|
421
|
-
if (snippet) {
|
|
422
|
-
where += `:
|
|
423
|
-
` + snippet;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
return where;
|
|
427
|
-
};
|
|
428
|
-
module.exports = Mark;
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type.js
|
|
432
|
-
var require_type = __commonJS((exports, module) => {
|
|
433
|
-
var YAMLException = require_exception();
|
|
434
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
435
|
-
"kind",
|
|
436
|
-
"resolve",
|
|
437
|
-
"construct",
|
|
438
|
-
"instanceOf",
|
|
439
|
-
"predicate",
|
|
440
|
-
"represent",
|
|
441
|
-
"defaultStyle",
|
|
442
|
-
"styleAliases"
|
|
443
|
-
];
|
|
444
|
-
var YAML_NODE_KINDS = [
|
|
445
|
-
"scalar",
|
|
446
|
-
"sequence",
|
|
447
|
-
"mapping"
|
|
448
|
-
];
|
|
449
|
-
function compileStyleAliases(map) {
|
|
450
|
-
var result = {};
|
|
451
|
-
if (map !== null) {
|
|
452
|
-
Object.keys(map).forEach(function(style) {
|
|
453
|
-
map[style].forEach(function(alias) {
|
|
454
|
-
result[String(alias)] = style;
|
|
455
|
-
});
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
return result;
|
|
459
|
-
}
|
|
460
|
-
function Type(tag, options2) {
|
|
461
|
-
options2 = options2 || {};
|
|
462
|
-
Object.keys(options2).forEach(function(name) {
|
|
463
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
464
|
-
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
this.tag = tag;
|
|
468
|
-
this.kind = options2["kind"] || null;
|
|
469
|
-
this.resolve = options2["resolve"] || function() {
|
|
470
|
-
return true;
|
|
471
|
-
};
|
|
472
|
-
this.construct = options2["construct"] || function(data) {
|
|
473
|
-
return data;
|
|
474
|
-
};
|
|
475
|
-
this.instanceOf = options2["instanceOf"] || null;
|
|
476
|
-
this.predicate = options2["predicate"] || null;
|
|
477
|
-
this.represent = options2["represent"] || null;
|
|
478
|
-
this.defaultStyle = options2["defaultStyle"] || null;
|
|
479
|
-
this.styleAliases = compileStyleAliases(options2["styleAliases"] || null);
|
|
480
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
481
|
-
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
module.exports = Type;
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema.js
|
|
488
|
-
var require_schema = __commonJS((exports, module) => {
|
|
489
|
-
var common = require_common();
|
|
490
|
-
var YAMLException = require_exception();
|
|
491
|
-
var Type = require_type();
|
|
492
|
-
function compileList(schema, name, result) {
|
|
493
|
-
var exclude = [];
|
|
494
|
-
schema.include.forEach(function(includedSchema) {
|
|
495
|
-
result = compileList(includedSchema, name, result);
|
|
496
|
-
});
|
|
497
|
-
schema[name].forEach(function(currentType) {
|
|
498
|
-
result.forEach(function(previousType, previousIndex) {
|
|
499
|
-
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
|
|
500
|
-
exclude.push(previousIndex);
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
result.push(currentType);
|
|
504
|
-
});
|
|
505
|
-
return result.filter(function(type, index) {
|
|
506
|
-
return exclude.indexOf(index) === -1;
|
|
507
|
-
});
|
|
508
|
-
}
|
|
509
|
-
function compileMap() {
|
|
510
|
-
var result = {
|
|
511
|
-
scalar: {},
|
|
512
|
-
sequence: {},
|
|
513
|
-
mapping: {},
|
|
514
|
-
fallback: {}
|
|
515
|
-
}, index, length;
|
|
516
|
-
function collectType(type) {
|
|
517
|
-
result[type.kind][type.tag] = result["fallback"][type.tag] = type;
|
|
518
|
-
}
|
|
519
|
-
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
520
|
-
arguments[index].forEach(collectType);
|
|
521
|
-
}
|
|
522
|
-
return result;
|
|
523
|
-
}
|
|
524
|
-
function Schema(definition) {
|
|
525
|
-
this.include = definition.include || [];
|
|
526
|
-
this.implicit = definition.implicit || [];
|
|
527
|
-
this.explicit = definition.explicit || [];
|
|
528
|
-
this.implicit.forEach(function(type) {
|
|
529
|
-
if (type.loadKind && type.loadKind !== "scalar") {
|
|
530
|
-
throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
531
|
-
}
|
|
532
|
-
});
|
|
533
|
-
this.compiledImplicit = compileList(this, "implicit", []);
|
|
534
|
-
this.compiledExplicit = compileList(this, "explicit", []);
|
|
535
|
-
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
|
536
|
-
}
|
|
537
|
-
Schema.DEFAULT = null;
|
|
538
|
-
Schema.create = function createSchema() {
|
|
539
|
-
var schemas, types;
|
|
540
|
-
switch (arguments.length) {
|
|
541
|
-
case 1:
|
|
542
|
-
schemas = Schema.DEFAULT;
|
|
543
|
-
types = arguments[0];
|
|
544
|
-
break;
|
|
545
|
-
case 2:
|
|
546
|
-
schemas = arguments[0];
|
|
547
|
-
types = arguments[1];
|
|
548
|
-
break;
|
|
549
|
-
default:
|
|
550
|
-
throw new YAMLException("Wrong number of arguments for Schema.create function");
|
|
551
|
-
}
|
|
552
|
-
schemas = common.toArray(schemas);
|
|
553
|
-
types = common.toArray(types);
|
|
554
|
-
if (!schemas.every(function(schema) {
|
|
555
|
-
return schema instanceof Schema;
|
|
556
|
-
})) {
|
|
557
|
-
throw new YAMLException("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");
|
|
558
|
-
}
|
|
559
|
-
if (!types.every(function(type) {
|
|
560
|
-
return type instanceof Type;
|
|
561
|
-
})) {
|
|
562
|
-
throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
563
|
-
}
|
|
564
|
-
return new Schema({
|
|
565
|
-
include: schemas,
|
|
566
|
-
explicit: types
|
|
567
|
-
});
|
|
568
|
-
};
|
|
569
|
-
module.exports = Schema;
|
|
570
|
-
});
|
|
571
|
-
|
|
572
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/str.js
|
|
573
|
-
var require_str = __commonJS((exports, module) => {
|
|
574
|
-
var Type = require_type();
|
|
575
|
-
module.exports = new Type("tag:yaml.org,2002:str", {
|
|
576
|
-
kind: "scalar",
|
|
577
|
-
construct: function(data) {
|
|
578
|
-
return data !== null ? data : "";
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
});
|
|
582
|
-
|
|
583
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/seq.js
|
|
584
|
-
var require_seq = __commonJS((exports, module) => {
|
|
585
|
-
var Type = require_type();
|
|
586
|
-
module.exports = new Type("tag:yaml.org,2002:seq", {
|
|
587
|
-
kind: "sequence",
|
|
588
|
-
construct: function(data) {
|
|
589
|
-
return data !== null ? data : [];
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/map.js
|
|
595
|
-
var require_map = __commonJS((exports, module) => {
|
|
596
|
-
var Type = require_type();
|
|
597
|
-
module.exports = new Type("tag:yaml.org,2002:map", {
|
|
598
|
-
kind: "mapping",
|
|
599
|
-
construct: function(data) {
|
|
600
|
-
return data !== null ? data : {};
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
|
|
606
|
-
var require_failsafe = __commonJS((exports, module) => {
|
|
607
|
-
var Schema = require_schema();
|
|
608
|
-
module.exports = new Schema({
|
|
609
|
-
explicit: [
|
|
610
|
-
require_str(),
|
|
611
|
-
require_seq(),
|
|
612
|
-
require_map()
|
|
613
|
-
]
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/null.js
|
|
618
|
-
var require_null = __commonJS((exports, module) => {
|
|
619
|
-
var Type = require_type();
|
|
620
|
-
function resolveYamlNull(data) {
|
|
621
|
-
if (data === null)
|
|
622
|
-
return true;
|
|
623
|
-
var max = data.length;
|
|
624
|
-
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
625
|
-
}
|
|
626
|
-
function constructYamlNull() {
|
|
627
|
-
return null;
|
|
628
|
-
}
|
|
629
|
-
function isNull(object) {
|
|
630
|
-
return object === null;
|
|
631
|
-
}
|
|
632
|
-
module.exports = new Type("tag:yaml.org,2002:null", {
|
|
633
|
-
kind: "scalar",
|
|
634
|
-
resolve: resolveYamlNull,
|
|
635
|
-
construct: constructYamlNull,
|
|
636
|
-
predicate: isNull,
|
|
637
|
-
represent: {
|
|
638
|
-
canonical: function() {
|
|
639
|
-
return "~";
|
|
640
|
-
},
|
|
641
|
-
lowercase: function() {
|
|
642
|
-
return "null";
|
|
643
|
-
},
|
|
644
|
-
uppercase: function() {
|
|
645
|
-
return "NULL";
|
|
646
|
-
},
|
|
647
|
-
camelcase: function() {
|
|
648
|
-
return "Null";
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
defaultStyle: "lowercase"
|
|
652
|
-
});
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/bool.js
|
|
656
|
-
var require_bool = __commonJS((exports, module) => {
|
|
657
|
-
var Type = require_type();
|
|
658
|
-
function resolveYamlBoolean(data) {
|
|
659
|
-
if (data === null)
|
|
660
|
-
return false;
|
|
661
|
-
var max = data.length;
|
|
662
|
-
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
663
|
-
}
|
|
664
|
-
function constructYamlBoolean(data) {
|
|
665
|
-
return data === "true" || data === "True" || data === "TRUE";
|
|
666
|
-
}
|
|
667
|
-
function isBoolean(object) {
|
|
668
|
-
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
669
|
-
}
|
|
670
|
-
module.exports = new Type("tag:yaml.org,2002:bool", {
|
|
671
|
-
kind: "scalar",
|
|
672
|
-
resolve: resolveYamlBoolean,
|
|
673
|
-
construct: constructYamlBoolean,
|
|
674
|
-
predicate: isBoolean,
|
|
675
|
-
represent: {
|
|
676
|
-
lowercase: function(object) {
|
|
677
|
-
return object ? "true" : "false";
|
|
678
|
-
},
|
|
679
|
-
uppercase: function(object) {
|
|
680
|
-
return object ? "TRUE" : "FALSE";
|
|
681
|
-
},
|
|
682
|
-
camelcase: function(object) {
|
|
683
|
-
return object ? "True" : "False";
|
|
684
|
-
}
|
|
685
|
-
},
|
|
686
|
-
defaultStyle: "lowercase"
|
|
687
|
-
});
|
|
688
|
-
});
|
|
689
|
-
|
|
690
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/int.js
|
|
691
|
-
var require_int = __commonJS((exports, module) => {
|
|
692
|
-
var common = require_common();
|
|
693
|
-
var Type = require_type();
|
|
694
|
-
function isHexCode(c) {
|
|
695
|
-
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
696
|
-
}
|
|
697
|
-
function isOctCode(c) {
|
|
698
|
-
return 48 <= c && c <= 55;
|
|
699
|
-
}
|
|
700
|
-
function isDecCode(c) {
|
|
701
|
-
return 48 <= c && c <= 57;
|
|
702
|
-
}
|
|
703
|
-
function resolveYamlInteger(data) {
|
|
704
|
-
if (data === null)
|
|
705
|
-
return false;
|
|
706
|
-
var max = data.length, index = 0, hasDigits = false, ch;
|
|
707
|
-
if (!max)
|
|
708
|
-
return false;
|
|
709
|
-
ch = data[index];
|
|
710
|
-
if (ch === "-" || ch === "+") {
|
|
711
|
-
ch = data[++index];
|
|
712
|
-
}
|
|
713
|
-
if (ch === "0") {
|
|
714
|
-
if (index + 1 === max)
|
|
715
|
-
return true;
|
|
716
|
-
ch = data[++index];
|
|
717
|
-
if (ch === "b") {
|
|
718
|
-
index++;
|
|
719
|
-
for (;index < max; index++) {
|
|
720
|
-
ch = data[index];
|
|
721
|
-
if (ch === "_")
|
|
722
|
-
continue;
|
|
723
|
-
if (ch !== "0" && ch !== "1")
|
|
724
|
-
return false;
|
|
725
|
-
hasDigits = true;
|
|
726
|
-
}
|
|
727
|
-
return hasDigits && ch !== "_";
|
|
728
|
-
}
|
|
729
|
-
if (ch === "x") {
|
|
730
|
-
index++;
|
|
731
|
-
for (;index < max; index++) {
|
|
732
|
-
ch = data[index];
|
|
733
|
-
if (ch === "_")
|
|
734
|
-
continue;
|
|
735
|
-
if (!isHexCode(data.charCodeAt(index)))
|
|
736
|
-
return false;
|
|
737
|
-
hasDigits = true;
|
|
738
|
-
}
|
|
739
|
-
return hasDigits && ch !== "_";
|
|
740
|
-
}
|
|
741
|
-
for (;index < max; index++) {
|
|
742
|
-
ch = data[index];
|
|
743
|
-
if (ch === "_")
|
|
744
|
-
continue;
|
|
745
|
-
if (!isOctCode(data.charCodeAt(index)))
|
|
746
|
-
return false;
|
|
747
|
-
hasDigits = true;
|
|
748
|
-
}
|
|
749
|
-
return hasDigits && ch !== "_";
|
|
750
|
-
}
|
|
751
|
-
if (ch === "_")
|
|
752
|
-
return false;
|
|
753
|
-
for (;index < max; index++) {
|
|
754
|
-
ch = data[index];
|
|
755
|
-
if (ch === "_")
|
|
756
|
-
continue;
|
|
757
|
-
if (ch === ":")
|
|
758
|
-
break;
|
|
759
|
-
if (!isDecCode(data.charCodeAt(index))) {
|
|
760
|
-
return false;
|
|
761
|
-
}
|
|
762
|
-
hasDigits = true;
|
|
763
|
-
}
|
|
764
|
-
if (!hasDigits || ch === "_")
|
|
765
|
-
return false;
|
|
766
|
-
if (ch !== ":")
|
|
767
|
-
return true;
|
|
768
|
-
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
|
769
|
-
}
|
|
770
|
-
function constructYamlInteger(data) {
|
|
771
|
-
var value = data, sign = 1, ch, base, digits = [];
|
|
772
|
-
if (value.indexOf("_") !== -1) {
|
|
773
|
-
value = value.replace(/_/g, "");
|
|
774
|
-
}
|
|
775
|
-
ch = value[0];
|
|
776
|
-
if (ch === "-" || ch === "+") {
|
|
777
|
-
if (ch === "-")
|
|
778
|
-
sign = -1;
|
|
779
|
-
value = value.slice(1);
|
|
780
|
-
ch = value[0];
|
|
781
|
-
}
|
|
782
|
-
if (value === "0")
|
|
783
|
-
return 0;
|
|
784
|
-
if (ch === "0") {
|
|
785
|
-
if (value[1] === "b")
|
|
786
|
-
return sign * parseInt(value.slice(2), 2);
|
|
787
|
-
if (value[1] === "x")
|
|
788
|
-
return sign * parseInt(value, 16);
|
|
789
|
-
return sign * parseInt(value, 8);
|
|
790
|
-
}
|
|
791
|
-
if (value.indexOf(":") !== -1) {
|
|
792
|
-
value.split(":").forEach(function(v) {
|
|
793
|
-
digits.unshift(parseInt(v, 10));
|
|
794
|
-
});
|
|
795
|
-
value = 0;
|
|
796
|
-
base = 1;
|
|
797
|
-
digits.forEach(function(d) {
|
|
798
|
-
value += d * base;
|
|
799
|
-
base *= 60;
|
|
800
|
-
});
|
|
801
|
-
return sign * value;
|
|
802
|
-
}
|
|
803
|
-
return sign * parseInt(value, 10);
|
|
804
|
-
}
|
|
805
|
-
function isInteger(object) {
|
|
806
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
807
|
-
}
|
|
808
|
-
module.exports = new Type("tag:yaml.org,2002:int", {
|
|
809
|
-
kind: "scalar",
|
|
810
|
-
resolve: resolveYamlInteger,
|
|
811
|
-
construct: constructYamlInteger,
|
|
812
|
-
predicate: isInteger,
|
|
813
|
-
represent: {
|
|
814
|
-
binary: function(obj) {
|
|
815
|
-
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
816
|
-
},
|
|
817
|
-
octal: function(obj) {
|
|
818
|
-
return obj >= 0 ? "0" + obj.toString(8) : "-0" + obj.toString(8).slice(1);
|
|
819
|
-
},
|
|
820
|
-
decimal: function(obj) {
|
|
821
|
-
return obj.toString(10);
|
|
822
|
-
},
|
|
823
|
-
hexadecimal: function(obj) {
|
|
824
|
-
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
825
|
-
}
|
|
826
|
-
},
|
|
827
|
-
defaultStyle: "decimal",
|
|
828
|
-
styleAliases: {
|
|
829
|
-
binary: [2, "bin"],
|
|
830
|
-
octal: [8, "oct"],
|
|
831
|
-
decimal: [10, "dec"],
|
|
832
|
-
hexadecimal: [16, "hex"]
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
});
|
|
836
|
-
|
|
837
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/float.js
|
|
838
|
-
var require_float = __commonJS((exports, module) => {
|
|
839
|
-
var common = require_common();
|
|
840
|
-
var Type = require_type();
|
|
841
|
-
var YAML_FLOAT_PATTERN = new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?" + "|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?" + "|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*" + "|[-+]?\\.(?:inf|Inf|INF)" + "|\\.(?:nan|NaN|NAN))$");
|
|
842
|
-
function resolveYamlFloat(data) {
|
|
843
|
-
if (data === null)
|
|
844
|
-
return false;
|
|
845
|
-
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
846
|
-
return false;
|
|
847
|
-
}
|
|
848
|
-
return true;
|
|
849
|
-
}
|
|
850
|
-
function constructYamlFloat(data) {
|
|
851
|
-
var value, sign, base, digits;
|
|
852
|
-
value = data.replace(/_/g, "").toLowerCase();
|
|
853
|
-
sign = value[0] === "-" ? -1 : 1;
|
|
854
|
-
digits = [];
|
|
855
|
-
if ("+-".indexOf(value[0]) >= 0) {
|
|
856
|
-
value = value.slice(1);
|
|
857
|
-
}
|
|
858
|
-
if (value === ".inf") {
|
|
859
|
-
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
860
|
-
} else if (value === ".nan") {
|
|
861
|
-
return NaN;
|
|
862
|
-
} else if (value.indexOf(":") >= 0) {
|
|
863
|
-
value.split(":").forEach(function(v) {
|
|
864
|
-
digits.unshift(parseFloat(v, 10));
|
|
865
|
-
});
|
|
866
|
-
value = 0;
|
|
867
|
-
base = 1;
|
|
868
|
-
digits.forEach(function(d) {
|
|
869
|
-
value += d * base;
|
|
870
|
-
base *= 60;
|
|
871
|
-
});
|
|
872
|
-
return sign * value;
|
|
873
|
-
}
|
|
874
|
-
return sign * parseFloat(value, 10);
|
|
875
|
-
}
|
|
876
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
877
|
-
function representYamlFloat(object, style) {
|
|
878
|
-
var res;
|
|
879
|
-
if (isNaN(object)) {
|
|
880
|
-
switch (style) {
|
|
881
|
-
case "lowercase":
|
|
882
|
-
return ".nan";
|
|
883
|
-
case "uppercase":
|
|
884
|
-
return ".NAN";
|
|
885
|
-
case "camelcase":
|
|
886
|
-
return ".NaN";
|
|
887
|
-
}
|
|
888
|
-
} else if (Number.POSITIVE_INFINITY === object) {
|
|
889
|
-
switch (style) {
|
|
890
|
-
case "lowercase":
|
|
891
|
-
return ".inf";
|
|
892
|
-
case "uppercase":
|
|
893
|
-
return ".INF";
|
|
894
|
-
case "camelcase":
|
|
895
|
-
return ".Inf";
|
|
896
|
-
}
|
|
897
|
-
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
898
|
-
switch (style) {
|
|
899
|
-
case "lowercase":
|
|
900
|
-
return "-.inf";
|
|
901
|
-
case "uppercase":
|
|
902
|
-
return "-.INF";
|
|
903
|
-
case "camelcase":
|
|
904
|
-
return "-.Inf";
|
|
905
|
-
}
|
|
906
|
-
} else if (common.isNegativeZero(object)) {
|
|
907
|
-
return "-0.0";
|
|
908
|
-
}
|
|
909
|
-
res = object.toString(10);
|
|
910
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
911
|
-
}
|
|
912
|
-
function isFloat(object) {
|
|
913
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
914
|
-
}
|
|
915
|
-
module.exports = new Type("tag:yaml.org,2002:float", {
|
|
916
|
-
kind: "scalar",
|
|
917
|
-
resolve: resolveYamlFloat,
|
|
918
|
-
construct: constructYamlFloat,
|
|
919
|
-
predicate: isFloat,
|
|
920
|
-
represent: representYamlFloat,
|
|
921
|
-
defaultStyle: "lowercase"
|
|
922
|
-
});
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/json.js
|
|
926
|
-
var require_json = __commonJS((exports, module) => {
|
|
927
|
-
var Schema = require_schema();
|
|
928
|
-
module.exports = new Schema({
|
|
929
|
-
include: [
|
|
930
|
-
require_failsafe()
|
|
931
|
-
],
|
|
932
|
-
implicit: [
|
|
933
|
-
require_null(),
|
|
934
|
-
require_bool(),
|
|
935
|
-
require_int(),
|
|
936
|
-
require_float()
|
|
937
|
-
]
|
|
938
|
-
});
|
|
939
|
-
});
|
|
940
|
-
|
|
941
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/core.js
|
|
942
|
-
var require_core = __commonJS((exports, module) => {
|
|
943
|
-
var Schema = require_schema();
|
|
944
|
-
module.exports = new Schema({
|
|
945
|
-
include: [
|
|
946
|
-
require_json()
|
|
947
|
-
]
|
|
948
|
-
});
|
|
949
|
-
});
|
|
950
|
-
|
|
951
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
|
|
952
|
-
var require_timestamp = __commonJS((exports, module) => {
|
|
953
|
-
var Type = require_type();
|
|
954
|
-
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
955
|
-
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]))?))?$");
|
|
956
|
-
function resolveYamlTimestamp(data) {
|
|
957
|
-
if (data === null)
|
|
958
|
-
return false;
|
|
959
|
-
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
960
|
-
return true;
|
|
961
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
962
|
-
return true;
|
|
963
|
-
return false;
|
|
964
|
-
}
|
|
965
|
-
function constructYamlTimestamp(data) {
|
|
966
|
-
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
967
|
-
match = YAML_DATE_REGEXP.exec(data);
|
|
968
|
-
if (match === null)
|
|
969
|
-
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
970
|
-
if (match === null)
|
|
971
|
-
throw new Error("Date resolve error");
|
|
972
|
-
year = +match[1];
|
|
973
|
-
month = +match[2] - 1;
|
|
974
|
-
day = +match[3];
|
|
975
|
-
if (!match[4]) {
|
|
976
|
-
return new Date(Date.UTC(year, month, day));
|
|
977
|
-
}
|
|
978
|
-
hour = +match[4];
|
|
979
|
-
minute = +match[5];
|
|
980
|
-
second = +match[6];
|
|
981
|
-
if (match[7]) {
|
|
982
|
-
fraction = match[7].slice(0, 3);
|
|
983
|
-
while (fraction.length < 3) {
|
|
984
|
-
fraction += "0";
|
|
985
|
-
}
|
|
986
|
-
fraction = +fraction;
|
|
987
|
-
}
|
|
988
|
-
if (match[9]) {
|
|
989
|
-
tz_hour = +match[10];
|
|
990
|
-
tz_minute = +(match[11] || 0);
|
|
991
|
-
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
992
|
-
if (match[9] === "-")
|
|
993
|
-
delta = -delta;
|
|
994
|
-
}
|
|
995
|
-
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
996
|
-
if (delta)
|
|
997
|
-
date.setTime(date.getTime() - delta);
|
|
998
|
-
return date;
|
|
999
|
-
}
|
|
1000
|
-
function representYamlTimestamp(object) {
|
|
1001
|
-
return object.toISOString();
|
|
1002
|
-
}
|
|
1003
|
-
module.exports = new Type("tag:yaml.org,2002:timestamp", {
|
|
1004
|
-
kind: "scalar",
|
|
1005
|
-
resolve: resolveYamlTimestamp,
|
|
1006
|
-
construct: constructYamlTimestamp,
|
|
1007
|
-
instanceOf: Date,
|
|
1008
|
-
represent: representYamlTimestamp
|
|
1009
|
-
});
|
|
1010
|
-
});
|
|
1011
|
-
|
|
1012
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/merge.js
|
|
1013
|
-
var require_merge = __commonJS((exports, module) => {
|
|
1014
|
-
var Type = require_type();
|
|
1015
|
-
function resolveYamlMerge(data) {
|
|
1016
|
-
return data === "<<" || data === null;
|
|
1017
|
-
}
|
|
1018
|
-
module.exports = new Type("tag:yaml.org,2002:merge", {
|
|
1019
|
-
kind: "scalar",
|
|
1020
|
-
resolve: resolveYamlMerge
|
|
1021
|
-
});
|
|
1022
|
-
});
|
|
1023
|
-
|
|
1024
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/binary.js
|
|
1025
|
-
var require_binary = __commonJS((exports, module) => {
|
|
1026
|
-
var NodeBuffer;
|
|
1027
|
-
try {
|
|
1028
|
-
_require = __require;
|
|
1029
|
-
NodeBuffer = _require("buffer").Buffer;
|
|
1030
|
-
} catch (__) {}
|
|
1031
|
-
var _require;
|
|
1032
|
-
var Type = require_type();
|
|
1033
|
-
var BASE64_MAP = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
1034
|
-
\r`;
|
|
1035
|
-
function resolveYamlBinary(data) {
|
|
1036
|
-
if (data === null)
|
|
1037
|
-
return false;
|
|
1038
|
-
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
|
1039
|
-
for (idx = 0;idx < max; idx++) {
|
|
1040
|
-
code = map.indexOf(data.charAt(idx));
|
|
1041
|
-
if (code > 64)
|
|
1042
|
-
continue;
|
|
1043
|
-
if (code < 0)
|
|
1044
|
-
return false;
|
|
1045
|
-
bitlen += 6;
|
|
1046
|
-
}
|
|
1047
|
-
return bitlen % 8 === 0;
|
|
1048
|
-
}
|
|
1049
|
-
function constructYamlBinary(data) {
|
|
1050
|
-
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map = BASE64_MAP, bits = 0, result = [];
|
|
1051
|
-
for (idx = 0;idx < max; idx++) {
|
|
1052
|
-
if (idx % 4 === 0 && idx) {
|
|
1053
|
-
result.push(bits >> 16 & 255);
|
|
1054
|
-
result.push(bits >> 8 & 255);
|
|
1055
|
-
result.push(bits & 255);
|
|
1056
|
-
}
|
|
1057
|
-
bits = bits << 6 | map.indexOf(input.charAt(idx));
|
|
1058
|
-
}
|
|
1059
|
-
tailbits = max % 4 * 6;
|
|
1060
|
-
if (tailbits === 0) {
|
|
1061
|
-
result.push(bits >> 16 & 255);
|
|
1062
|
-
result.push(bits >> 8 & 255);
|
|
1063
|
-
result.push(bits & 255);
|
|
1064
|
-
} else if (tailbits === 18) {
|
|
1065
|
-
result.push(bits >> 10 & 255);
|
|
1066
|
-
result.push(bits >> 2 & 255);
|
|
1067
|
-
} else if (tailbits === 12) {
|
|
1068
|
-
result.push(bits >> 4 & 255);
|
|
1069
|
-
}
|
|
1070
|
-
if (NodeBuffer) {
|
|
1071
|
-
return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
|
|
1072
|
-
}
|
|
1073
|
-
return result;
|
|
1074
|
-
}
|
|
1075
|
-
function representYamlBinary(object) {
|
|
1076
|
-
var result = "", bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
|
|
1077
|
-
for (idx = 0;idx < max; idx++) {
|
|
1078
|
-
if (idx % 3 === 0 && idx) {
|
|
1079
|
-
result += map[bits >> 18 & 63];
|
|
1080
|
-
result += map[bits >> 12 & 63];
|
|
1081
|
-
result += map[bits >> 6 & 63];
|
|
1082
|
-
result += map[bits & 63];
|
|
1083
|
-
}
|
|
1084
|
-
bits = (bits << 8) + object[idx];
|
|
1085
|
-
}
|
|
1086
|
-
tail = max % 3;
|
|
1087
|
-
if (tail === 0) {
|
|
1088
|
-
result += map[bits >> 18 & 63];
|
|
1089
|
-
result += map[bits >> 12 & 63];
|
|
1090
|
-
result += map[bits >> 6 & 63];
|
|
1091
|
-
result += map[bits & 63];
|
|
1092
|
-
} else if (tail === 2) {
|
|
1093
|
-
result += map[bits >> 10 & 63];
|
|
1094
|
-
result += map[bits >> 4 & 63];
|
|
1095
|
-
result += map[bits << 2 & 63];
|
|
1096
|
-
result += map[64];
|
|
1097
|
-
} else if (tail === 1) {
|
|
1098
|
-
result += map[bits >> 2 & 63];
|
|
1099
|
-
result += map[bits << 4 & 63];
|
|
1100
|
-
result += map[64];
|
|
1101
|
-
result += map[64];
|
|
1102
|
-
}
|
|
1103
|
-
return result;
|
|
1104
|
-
}
|
|
1105
|
-
function isBinary(object) {
|
|
1106
|
-
return NodeBuffer && NodeBuffer.isBuffer(object);
|
|
1107
|
-
}
|
|
1108
|
-
module.exports = new Type("tag:yaml.org,2002:binary", {
|
|
1109
|
-
kind: "scalar",
|
|
1110
|
-
resolve: resolveYamlBinary,
|
|
1111
|
-
construct: constructYamlBinary,
|
|
1112
|
-
predicate: isBinary,
|
|
1113
|
-
represent: representYamlBinary
|
|
1114
|
-
});
|
|
1115
|
-
});
|
|
1116
|
-
|
|
1117
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/omap.js
|
|
1118
|
-
var require_omap = __commonJS((exports, module) => {
|
|
1119
|
-
var Type = require_type();
|
|
1120
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1121
|
-
var _toString = Object.prototype.toString;
|
|
1122
|
-
function resolveYamlOmap(data) {
|
|
1123
|
-
if (data === null)
|
|
1124
|
-
return true;
|
|
1125
|
-
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
1126
|
-
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1127
|
-
pair = object[index];
|
|
1128
|
-
pairHasKey = false;
|
|
1129
|
-
if (_toString.call(pair) !== "[object Object]")
|
|
1130
|
-
return false;
|
|
1131
|
-
for (pairKey in pair) {
|
|
1132
|
-
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
1133
|
-
if (!pairHasKey)
|
|
1134
|
-
pairHasKey = true;
|
|
1135
|
-
else
|
|
1136
|
-
return false;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
if (!pairHasKey)
|
|
1140
|
-
return false;
|
|
1141
|
-
if (objectKeys.indexOf(pairKey) === -1)
|
|
1142
|
-
objectKeys.push(pairKey);
|
|
1143
|
-
else
|
|
1144
|
-
return false;
|
|
1145
|
-
}
|
|
1146
|
-
return true;
|
|
1147
|
-
}
|
|
1148
|
-
function constructYamlOmap(data) {
|
|
1149
|
-
return data !== null ? data : [];
|
|
1150
|
-
}
|
|
1151
|
-
module.exports = new Type("tag:yaml.org,2002:omap", {
|
|
1152
|
-
kind: "sequence",
|
|
1153
|
-
resolve: resolveYamlOmap,
|
|
1154
|
-
construct: constructYamlOmap
|
|
1155
|
-
});
|
|
1156
|
-
});
|
|
1157
|
-
|
|
1158
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/pairs.js
|
|
1159
|
-
var require_pairs = __commonJS((exports, module) => {
|
|
1160
|
-
var Type = require_type();
|
|
1161
|
-
var _toString = Object.prototype.toString;
|
|
1162
|
-
function resolveYamlPairs(data) {
|
|
1163
|
-
if (data === null)
|
|
1164
|
-
return true;
|
|
1165
|
-
var index, length, pair, keys, result, object = data;
|
|
1166
|
-
result = new Array(object.length);
|
|
1167
|
-
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1168
|
-
pair = object[index];
|
|
1169
|
-
if (_toString.call(pair) !== "[object Object]")
|
|
1170
|
-
return false;
|
|
1171
|
-
keys = Object.keys(pair);
|
|
1172
|
-
if (keys.length !== 1)
|
|
1173
|
-
return false;
|
|
1174
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1175
|
-
}
|
|
1176
|
-
return true;
|
|
1177
|
-
}
|
|
1178
|
-
function constructYamlPairs(data) {
|
|
1179
|
-
if (data === null)
|
|
1180
|
-
return [];
|
|
1181
|
-
var index, length, pair, keys, result, object = data;
|
|
1182
|
-
result = new Array(object.length);
|
|
1183
|
-
for (index = 0, length = object.length;index < length; index += 1) {
|
|
1184
|
-
pair = object[index];
|
|
1185
|
-
keys = Object.keys(pair);
|
|
1186
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1187
|
-
}
|
|
1188
|
-
return result;
|
|
1189
|
-
}
|
|
1190
|
-
module.exports = new Type("tag:yaml.org,2002:pairs", {
|
|
1191
|
-
kind: "sequence",
|
|
1192
|
-
resolve: resolveYamlPairs,
|
|
1193
|
-
construct: constructYamlPairs
|
|
1194
|
-
});
|
|
1195
|
-
});
|
|
1196
|
-
|
|
1197
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/set.js
|
|
1198
|
-
var require_set = __commonJS((exports, module) => {
|
|
1199
|
-
var Type = require_type();
|
|
1200
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1201
|
-
function resolveYamlSet(data) {
|
|
1202
|
-
if (data === null)
|
|
1203
|
-
return true;
|
|
1204
|
-
var key, object = data;
|
|
1205
|
-
for (key in object) {
|
|
1206
|
-
if (_hasOwnProperty.call(object, key)) {
|
|
1207
|
-
if (object[key] !== null)
|
|
1208
|
-
return false;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
return true;
|
|
1212
|
-
}
|
|
1213
|
-
function constructYamlSet(data) {
|
|
1214
|
-
return data !== null ? data : {};
|
|
1215
|
-
}
|
|
1216
|
-
module.exports = new Type("tag:yaml.org,2002:set", {
|
|
1217
|
-
kind: "mapping",
|
|
1218
|
-
resolve: resolveYamlSet,
|
|
1219
|
-
construct: constructYamlSet
|
|
1220
|
-
});
|
|
1221
|
-
});
|
|
1222
|
-
|
|
1223
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
|
|
1224
|
-
var require_default_safe = __commonJS((exports, module) => {
|
|
1225
|
-
var Schema = require_schema();
|
|
1226
|
-
module.exports = new Schema({
|
|
1227
|
-
include: [
|
|
1228
|
-
require_core()
|
|
1229
|
-
],
|
|
1230
|
-
implicit: [
|
|
1231
|
-
require_timestamp(),
|
|
1232
|
-
require_merge()
|
|
1233
|
-
],
|
|
1234
|
-
explicit: [
|
|
1235
|
-
require_binary(),
|
|
1236
|
-
require_omap(),
|
|
1237
|
-
require_pairs(),
|
|
1238
|
-
require_set()
|
|
1239
|
-
]
|
|
1240
|
-
});
|
|
1241
|
-
});
|
|
1242
|
-
|
|
1243
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
|
|
1244
|
-
var require_undefined = __commonJS((exports, module) => {
|
|
1245
|
-
var Type = require_type();
|
|
1246
|
-
function resolveJavascriptUndefined() {
|
|
1247
|
-
return true;
|
|
1248
|
-
}
|
|
1249
|
-
function constructJavascriptUndefined() {
|
|
1250
|
-
return;
|
|
1251
|
-
}
|
|
1252
|
-
function representJavascriptUndefined() {
|
|
1253
|
-
return "";
|
|
1254
|
-
}
|
|
1255
|
-
function isUndefined(object) {
|
|
1256
|
-
return typeof object === "undefined";
|
|
1257
|
-
}
|
|
1258
|
-
module.exports = new Type("tag:yaml.org,2002:js/undefined", {
|
|
1259
|
-
kind: "scalar",
|
|
1260
|
-
resolve: resolveJavascriptUndefined,
|
|
1261
|
-
construct: constructJavascriptUndefined,
|
|
1262
|
-
predicate: isUndefined,
|
|
1263
|
-
represent: representJavascriptUndefined
|
|
1264
|
-
});
|
|
1265
|
-
});
|
|
1266
|
-
|
|
1267
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
|
|
1268
|
-
var require_regexp = __commonJS((exports, module) => {
|
|
1269
|
-
var Type = require_type();
|
|
1270
|
-
function resolveJavascriptRegExp(data) {
|
|
1271
|
-
if (data === null)
|
|
1272
|
-
return false;
|
|
1273
|
-
if (data.length === 0)
|
|
1274
|
-
return false;
|
|
1275
|
-
var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
|
|
1276
|
-
if (regexp[0] === "/") {
|
|
1277
|
-
if (tail)
|
|
1278
|
-
modifiers = tail[1];
|
|
1279
|
-
if (modifiers.length > 3)
|
|
1280
|
-
return false;
|
|
1281
|
-
if (regexp[regexp.length - modifiers.length - 1] !== "/")
|
|
1282
|
-
return false;
|
|
1283
|
-
}
|
|
1284
|
-
return true;
|
|
1285
|
-
}
|
|
1286
|
-
function constructJavascriptRegExp(data) {
|
|
1287
|
-
var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
|
|
1288
|
-
if (regexp[0] === "/") {
|
|
1289
|
-
if (tail)
|
|
1290
|
-
modifiers = tail[1];
|
|
1291
|
-
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
|
1292
|
-
}
|
|
1293
|
-
return new RegExp(regexp, modifiers);
|
|
1294
|
-
}
|
|
1295
|
-
function representJavascriptRegExp(object) {
|
|
1296
|
-
var result = "/" + object.source + "/";
|
|
1297
|
-
if (object.global)
|
|
1298
|
-
result += "g";
|
|
1299
|
-
if (object.multiline)
|
|
1300
|
-
result += "m";
|
|
1301
|
-
if (object.ignoreCase)
|
|
1302
|
-
result += "i";
|
|
1303
|
-
return result;
|
|
1304
|
-
}
|
|
1305
|
-
function isRegExp(object) {
|
|
1306
|
-
return Object.prototype.toString.call(object) === "[object RegExp]";
|
|
1307
|
-
}
|
|
1308
|
-
module.exports = new Type("tag:yaml.org,2002:js/regexp", {
|
|
1309
|
-
kind: "scalar",
|
|
1310
|
-
resolve: resolveJavascriptRegExp,
|
|
1311
|
-
construct: constructJavascriptRegExp,
|
|
1312
|
-
predicate: isRegExp,
|
|
1313
|
-
represent: representJavascriptRegExp
|
|
1314
|
-
});
|
|
1315
|
-
});
|
|
1316
|
-
|
|
1317
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
|
1318
|
-
var require_function = __commonJS((exports, module) => {
|
|
1319
|
-
var esprima;
|
|
1320
|
-
try {
|
|
1321
|
-
_require = __require;
|
|
1322
|
-
esprima = _require("esprima");
|
|
1323
|
-
} catch (_) {
|
|
1324
|
-
if (typeof window !== "undefined")
|
|
1325
|
-
esprima = window.esprima;
|
|
1326
|
-
}
|
|
1327
|
-
var _require;
|
|
1328
|
-
var Type = require_type();
|
|
1329
|
-
function resolveJavascriptFunction(data) {
|
|
1330
|
-
if (data === null)
|
|
1331
|
-
return false;
|
|
1332
|
-
try {
|
|
1333
|
-
var source = "(" + data + ")", ast = esprima.parse(source, { range: true });
|
|
1334
|
-
if (ast.type !== "Program" || ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement" || ast.body[0].expression.type !== "ArrowFunctionExpression" && ast.body[0].expression.type !== "FunctionExpression") {
|
|
1335
|
-
return false;
|
|
1336
|
-
}
|
|
1337
|
-
return true;
|
|
1338
|
-
} catch (err) {
|
|
1339
|
-
return false;
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
function constructJavascriptFunction(data) {
|
|
1343
|
-
var source = "(" + data + ")", ast = esprima.parse(source, { range: true }), params = [], body;
|
|
1344
|
-
if (ast.type !== "Program" || ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement" || ast.body[0].expression.type !== "ArrowFunctionExpression" && ast.body[0].expression.type !== "FunctionExpression") {
|
|
1345
|
-
throw new Error("Failed to resolve function");
|
|
1346
|
-
}
|
|
1347
|
-
ast.body[0].expression.params.forEach(function(param) {
|
|
1348
|
-
params.push(param.name);
|
|
1349
|
-
});
|
|
1350
|
-
body = ast.body[0].expression.body.range;
|
|
1351
|
-
if (ast.body[0].expression.body.type === "BlockStatement") {
|
|
1352
|
-
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
|
1353
|
-
}
|
|
1354
|
-
return new Function(params, "return " + source.slice(body[0], body[1]));
|
|
1355
|
-
}
|
|
1356
|
-
function representJavascriptFunction(object) {
|
|
1357
|
-
return object.toString();
|
|
1358
|
-
}
|
|
1359
|
-
function isFunction(object) {
|
|
1360
|
-
return Object.prototype.toString.call(object) === "[object Function]";
|
|
1361
|
-
}
|
|
1362
|
-
module.exports = new Type("tag:yaml.org,2002:js/function", {
|
|
1363
|
-
kind: "scalar",
|
|
1364
|
-
resolve: resolveJavascriptFunction,
|
|
1365
|
-
construct: constructJavascriptFunction,
|
|
1366
|
-
predicate: isFunction,
|
|
1367
|
-
represent: representJavascriptFunction
|
|
1368
|
-
});
|
|
1369
|
-
});
|
|
1370
|
-
|
|
1371
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
|
|
1372
|
-
var require_default_full = __commonJS((exports, module) => {
|
|
1373
|
-
var Schema = require_schema();
|
|
1374
|
-
module.exports = Schema.DEFAULT = new Schema({
|
|
1375
|
-
include: [
|
|
1376
|
-
require_default_safe()
|
|
1377
|
-
],
|
|
1378
|
-
explicit: [
|
|
1379
|
-
require_undefined(),
|
|
1380
|
-
require_regexp(),
|
|
1381
|
-
require_function()
|
|
1382
|
-
]
|
|
1383
|
-
});
|
|
1384
|
-
});
|
|
1385
|
-
|
|
1386
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/loader.js
|
|
1387
|
-
var require_loader = __commonJS((exports, module) => {
|
|
1388
|
-
var common = require_common();
|
|
1389
|
-
var YAMLException = require_exception();
|
|
1390
|
-
var Mark = require_mark();
|
|
1391
|
-
var DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
1392
|
-
var DEFAULT_FULL_SCHEMA = require_default_full();
|
|
1393
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1394
|
-
var CONTEXT_FLOW_IN = 1;
|
|
1395
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
1396
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
1397
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
1398
|
-
var CHOMPING_CLIP = 1;
|
|
1399
|
-
var CHOMPING_STRIP = 2;
|
|
1400
|
-
var CHOMPING_KEEP = 3;
|
|
1401
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1402
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1403
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1404
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1405
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1406
|
-
function _class(obj) {
|
|
1407
|
-
return Object.prototype.toString.call(obj);
|
|
1408
|
-
}
|
|
1409
|
-
function is_EOL(c) {
|
|
1410
|
-
return c === 10 || c === 13;
|
|
1411
|
-
}
|
|
1412
|
-
function is_WHITE_SPACE(c) {
|
|
1413
|
-
return c === 9 || c === 32;
|
|
1414
|
-
}
|
|
1415
|
-
function is_WS_OR_EOL(c) {
|
|
1416
|
-
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1417
|
-
}
|
|
1418
|
-
function is_FLOW_INDICATOR(c) {
|
|
1419
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1420
|
-
}
|
|
1421
|
-
function fromHexCode(c) {
|
|
1422
|
-
var lc;
|
|
1423
|
-
if (48 <= c && c <= 57) {
|
|
1424
|
-
return c - 48;
|
|
1425
|
-
}
|
|
1426
|
-
lc = c | 32;
|
|
1427
|
-
if (97 <= lc && lc <= 102) {
|
|
1428
|
-
return lc - 97 + 10;
|
|
1429
|
-
}
|
|
1430
|
-
return -1;
|
|
1431
|
-
}
|
|
1432
|
-
function escapedHexLen(c) {
|
|
1433
|
-
if (c === 120) {
|
|
1434
|
-
return 2;
|
|
1435
|
-
}
|
|
1436
|
-
if (c === 117) {
|
|
1437
|
-
return 4;
|
|
1438
|
-
}
|
|
1439
|
-
if (c === 85) {
|
|
1440
|
-
return 8;
|
|
1441
|
-
}
|
|
1442
|
-
return 0;
|
|
1443
|
-
}
|
|
1444
|
-
function fromDecimalCode(c) {
|
|
1445
|
-
if (48 <= c && c <= 57) {
|
|
1446
|
-
return c - 48;
|
|
1447
|
-
}
|
|
1448
|
-
return -1;
|
|
1449
|
-
}
|
|
1450
|
-
function simpleEscapeSequence(c) {
|
|
1451
|
-
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
1452
|
-
` : 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" : "";
|
|
1453
|
-
}
|
|
1454
|
-
function charFromCodepoint(c) {
|
|
1455
|
-
if (c <= 65535) {
|
|
1456
|
-
return String.fromCharCode(c);
|
|
1457
|
-
}
|
|
1458
|
-
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
1459
|
-
}
|
|
1460
|
-
function setProperty(object, key, value) {
|
|
1461
|
-
if (key === "__proto__") {
|
|
1462
|
-
Object.defineProperty(object, key, {
|
|
1463
|
-
configurable: true,
|
|
1464
|
-
enumerable: true,
|
|
1465
|
-
writable: true,
|
|
1466
|
-
value
|
|
1467
|
-
});
|
|
1468
|
-
} else {
|
|
1469
|
-
object[key] = value;
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
var simpleEscapeCheck = new Array(256);
|
|
1473
|
-
var simpleEscapeMap = new Array(256);
|
|
1474
|
-
for (i = 0;i < 256; i++) {
|
|
1475
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1476
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1477
|
-
}
|
|
1478
|
-
var i;
|
|
1479
|
-
function State(input, options2) {
|
|
1480
|
-
this.input = input;
|
|
1481
|
-
this.filename = options2["filename"] || null;
|
|
1482
|
-
this.schema = options2["schema"] || DEFAULT_FULL_SCHEMA;
|
|
1483
|
-
this.onWarning = options2["onWarning"] || null;
|
|
1484
|
-
this.legacy = options2["legacy"] || false;
|
|
1485
|
-
this.json = options2["json"] || false;
|
|
1486
|
-
this.listener = options2["listener"] || null;
|
|
1487
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
1488
|
-
this.typeMap = this.schema.compiledTypeMap;
|
|
1489
|
-
this.length = input.length;
|
|
1490
|
-
this.position = 0;
|
|
1491
|
-
this.line = 0;
|
|
1492
|
-
this.lineStart = 0;
|
|
1493
|
-
this.lineIndent = 0;
|
|
1494
|
-
this.documents = [];
|
|
1495
|
-
}
|
|
1496
|
-
function generateError(state, message) {
|
|
1497
|
-
return new YAMLException(message, new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart));
|
|
1498
|
-
}
|
|
1499
|
-
function throwError(state, message) {
|
|
1500
|
-
throw generateError(state, message);
|
|
1501
|
-
}
|
|
1502
|
-
function throwWarning(state, message) {
|
|
1503
|
-
if (state.onWarning) {
|
|
1504
|
-
state.onWarning.call(null, generateError(state, message));
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
var directiveHandlers = {
|
|
1508
|
-
YAML: function handleYamlDirective(state, name, args) {
|
|
1509
|
-
var match, major, minor;
|
|
1510
|
-
if (state.version !== null) {
|
|
1511
|
-
throwError(state, "duplication of %YAML directive");
|
|
1512
|
-
}
|
|
1513
|
-
if (args.length !== 1) {
|
|
1514
|
-
throwError(state, "YAML directive accepts exactly one argument");
|
|
1515
|
-
}
|
|
1516
|
-
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1517
|
-
if (match === null) {
|
|
1518
|
-
throwError(state, "ill-formed argument of the YAML directive");
|
|
1519
|
-
}
|
|
1520
|
-
major = parseInt(match[1], 10);
|
|
1521
|
-
minor = parseInt(match[2], 10);
|
|
1522
|
-
if (major !== 1) {
|
|
1523
|
-
throwError(state, "unacceptable YAML version of the document");
|
|
1524
|
-
}
|
|
1525
|
-
state.version = args[0];
|
|
1526
|
-
state.checkLineBreaks = minor < 2;
|
|
1527
|
-
if (minor !== 1 && minor !== 2) {
|
|
1528
|
-
throwWarning(state, "unsupported YAML version of the document");
|
|
1529
|
-
}
|
|
1530
|
-
},
|
|
1531
|
-
TAG: function handleTagDirective(state, name, args) {
|
|
1532
|
-
var handle, prefix;
|
|
1533
|
-
if (args.length !== 2) {
|
|
1534
|
-
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1535
|
-
}
|
|
1536
|
-
handle = args[0];
|
|
1537
|
-
prefix = args[1];
|
|
1538
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1539
|
-
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1540
|
-
}
|
|
1541
|
-
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
1542
|
-
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1543
|
-
}
|
|
1544
|
-
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1545
|
-
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1546
|
-
}
|
|
1547
|
-
state.tagMap[handle] = prefix;
|
|
1548
|
-
}
|
|
1549
|
-
};
|
|
1550
|
-
function captureSegment(state, start, end, checkJson) {
|
|
1551
|
-
var _position, _length, _character, _result;
|
|
1552
|
-
if (start < end) {
|
|
1553
|
-
_result = state.input.slice(start, end);
|
|
1554
|
-
if (checkJson) {
|
|
1555
|
-
for (_position = 0, _length = _result.length;_position < _length; _position += 1) {
|
|
1556
|
-
_character = _result.charCodeAt(_position);
|
|
1557
|
-
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1558
|
-
throwError(state, "expected valid JSON character");
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1562
|
-
throwError(state, "the stream contains non-printable characters");
|
|
1563
|
-
}
|
|
1564
|
-
state.result += _result;
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1568
|
-
var sourceKeys, key, index, quantity;
|
|
1569
|
-
if (!common.isObject(source)) {
|
|
1570
|
-
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1571
|
-
}
|
|
1572
|
-
sourceKeys = Object.keys(source);
|
|
1573
|
-
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
1574
|
-
key = sourceKeys[index];
|
|
1575
|
-
if (!_hasOwnProperty.call(destination, key)) {
|
|
1576
|
-
setProperty(destination, key, source[key]);
|
|
1577
|
-
overridableKeys[key] = true;
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
|
|
1582
|
-
var index, quantity;
|
|
1583
|
-
if (Array.isArray(keyNode)) {
|
|
1584
|
-
keyNode = Array.prototype.slice.call(keyNode);
|
|
1585
|
-
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
1586
|
-
if (Array.isArray(keyNode[index])) {
|
|
1587
|
-
throwError(state, "nested arrays are not supported inside keys");
|
|
1588
|
-
}
|
|
1589
|
-
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1590
|
-
keyNode[index] = "[object Object]";
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1595
|
-
keyNode = "[object Object]";
|
|
1596
|
-
}
|
|
1597
|
-
keyNode = String(keyNode);
|
|
1598
|
-
if (_result === null) {
|
|
1599
|
-
_result = {};
|
|
1600
|
-
}
|
|
1601
|
-
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1602
|
-
if (Array.isArray(valueNode)) {
|
|
1603
|
-
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
1604
|
-
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1605
|
-
}
|
|
1606
|
-
} else {
|
|
1607
|
-
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1608
|
-
}
|
|
1609
|
-
} else {
|
|
1610
|
-
if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
|
|
1611
|
-
state.line = startLine || state.line;
|
|
1612
|
-
state.position = startPos || state.position;
|
|
1613
|
-
throwError(state, "duplicated mapping key");
|
|
1614
|
-
}
|
|
1615
|
-
setProperty(_result, keyNode, valueNode);
|
|
1616
|
-
delete overridableKeys[keyNode];
|
|
1617
|
-
}
|
|
1618
|
-
return _result;
|
|
1619
|
-
}
|
|
1620
|
-
function readLineBreak(state) {
|
|
1621
|
-
var ch;
|
|
1622
|
-
ch = state.input.charCodeAt(state.position);
|
|
1623
|
-
if (ch === 10) {
|
|
1624
|
-
state.position++;
|
|
1625
|
-
} else if (ch === 13) {
|
|
1626
|
-
state.position++;
|
|
1627
|
-
if (state.input.charCodeAt(state.position) === 10) {
|
|
1628
|
-
state.position++;
|
|
1629
|
-
}
|
|
1630
|
-
} else {
|
|
1631
|
-
throwError(state, "a line break is expected");
|
|
1632
|
-
}
|
|
1633
|
-
state.line += 1;
|
|
1634
|
-
state.lineStart = state.position;
|
|
1635
|
-
}
|
|
1636
|
-
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1637
|
-
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1638
|
-
while (ch !== 0) {
|
|
1639
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1640
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1641
|
-
}
|
|
1642
|
-
if (allowComments && ch === 35) {
|
|
1643
|
-
do {
|
|
1644
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1645
|
-
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1646
|
-
}
|
|
1647
|
-
if (is_EOL(ch)) {
|
|
1648
|
-
readLineBreak(state);
|
|
1649
|
-
ch = state.input.charCodeAt(state.position);
|
|
1650
|
-
lineBreaks++;
|
|
1651
|
-
state.lineIndent = 0;
|
|
1652
|
-
while (ch === 32) {
|
|
1653
|
-
state.lineIndent++;
|
|
1654
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1655
|
-
}
|
|
1656
|
-
} else {
|
|
1657
|
-
break;
|
|
1658
|
-
}
|
|
1659
|
-
}
|
|
1660
|
-
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1661
|
-
throwWarning(state, "deficient indentation");
|
|
1662
|
-
}
|
|
1663
|
-
return lineBreaks;
|
|
1664
|
-
}
|
|
1665
|
-
function testDocumentSeparator(state) {
|
|
1666
|
-
var _position = state.position, ch;
|
|
1667
|
-
ch = state.input.charCodeAt(_position);
|
|
1668
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1669
|
-
_position += 3;
|
|
1670
|
-
ch = state.input.charCodeAt(_position);
|
|
1671
|
-
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1672
|
-
return true;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
return false;
|
|
1676
|
-
}
|
|
1677
|
-
function writeFoldedLines(state, count) {
|
|
1678
|
-
if (count === 1) {
|
|
1679
|
-
state.result += " ";
|
|
1680
|
-
} else if (count > 1) {
|
|
1681
|
-
state.result += common.repeat(`
|
|
1682
|
-
`, count - 1);
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1686
|
-
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1687
|
-
ch = state.input.charCodeAt(state.position);
|
|
1688
|
-
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) {
|
|
1689
|
-
return false;
|
|
1690
|
-
}
|
|
1691
|
-
if (ch === 63 || ch === 45) {
|
|
1692
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1693
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1694
|
-
return false;
|
|
1695
|
-
}
|
|
1696
|
-
}
|
|
1697
|
-
state.kind = "scalar";
|
|
1698
|
-
state.result = "";
|
|
1699
|
-
captureStart = captureEnd = state.position;
|
|
1700
|
-
hasPendingContent = false;
|
|
1701
|
-
while (ch !== 0) {
|
|
1702
|
-
if (ch === 58) {
|
|
1703
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1704
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1705
|
-
break;
|
|
1706
|
-
}
|
|
1707
|
-
} else if (ch === 35) {
|
|
1708
|
-
preceding = state.input.charCodeAt(state.position - 1);
|
|
1709
|
-
if (is_WS_OR_EOL(preceding)) {
|
|
1710
|
-
break;
|
|
1711
|
-
}
|
|
1712
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1713
|
-
break;
|
|
1714
|
-
} else if (is_EOL(ch)) {
|
|
1715
|
-
_line = state.line;
|
|
1716
|
-
_lineStart = state.lineStart;
|
|
1717
|
-
_lineIndent = state.lineIndent;
|
|
1718
|
-
skipSeparationSpace(state, false, -1);
|
|
1719
|
-
if (state.lineIndent >= nodeIndent) {
|
|
1720
|
-
hasPendingContent = true;
|
|
1721
|
-
ch = state.input.charCodeAt(state.position);
|
|
1722
|
-
continue;
|
|
1723
|
-
} else {
|
|
1724
|
-
state.position = captureEnd;
|
|
1725
|
-
state.line = _line;
|
|
1726
|
-
state.lineStart = _lineStart;
|
|
1727
|
-
state.lineIndent = _lineIndent;
|
|
1728
|
-
break;
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
if (hasPendingContent) {
|
|
1732
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1733
|
-
writeFoldedLines(state, state.line - _line);
|
|
1734
|
-
captureStart = captureEnd = state.position;
|
|
1735
|
-
hasPendingContent = false;
|
|
1736
|
-
}
|
|
1737
|
-
if (!is_WHITE_SPACE(ch)) {
|
|
1738
|
-
captureEnd = state.position + 1;
|
|
1739
|
-
}
|
|
1740
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1741
|
-
}
|
|
1742
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1743
|
-
if (state.result) {
|
|
1744
|
-
return true;
|
|
1745
|
-
}
|
|
1746
|
-
state.kind = _kind;
|
|
1747
|
-
state.result = _result;
|
|
1748
|
-
return false;
|
|
1749
|
-
}
|
|
1750
|
-
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1751
|
-
var ch, captureStart, captureEnd;
|
|
1752
|
-
ch = state.input.charCodeAt(state.position);
|
|
1753
|
-
if (ch !== 39) {
|
|
1754
|
-
return false;
|
|
1755
|
-
}
|
|
1756
|
-
state.kind = "scalar";
|
|
1757
|
-
state.result = "";
|
|
1758
|
-
state.position++;
|
|
1759
|
-
captureStart = captureEnd = state.position;
|
|
1760
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1761
|
-
if (ch === 39) {
|
|
1762
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1763
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1764
|
-
if (ch === 39) {
|
|
1765
|
-
captureStart = state.position;
|
|
1766
|
-
state.position++;
|
|
1767
|
-
captureEnd = state.position;
|
|
1768
|
-
} else {
|
|
1769
|
-
return true;
|
|
1770
|
-
}
|
|
1771
|
-
} else if (is_EOL(ch)) {
|
|
1772
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1773
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1774
|
-
captureStart = captureEnd = state.position;
|
|
1775
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1776
|
-
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1777
|
-
} else {
|
|
1778
|
-
state.position++;
|
|
1779
|
-
captureEnd = state.position;
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1783
|
-
}
|
|
1784
|
-
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1785
|
-
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1786
|
-
ch = state.input.charCodeAt(state.position);
|
|
1787
|
-
if (ch !== 34) {
|
|
1788
|
-
return false;
|
|
1789
|
-
}
|
|
1790
|
-
state.kind = "scalar";
|
|
1791
|
-
state.result = "";
|
|
1792
|
-
state.position++;
|
|
1793
|
-
captureStart = captureEnd = state.position;
|
|
1794
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1795
|
-
if (ch === 34) {
|
|
1796
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1797
|
-
state.position++;
|
|
1798
|
-
return true;
|
|
1799
|
-
} else if (ch === 92) {
|
|
1800
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1801
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1802
|
-
if (is_EOL(ch)) {
|
|
1803
|
-
skipSeparationSpace(state, false, nodeIndent);
|
|
1804
|
-
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1805
|
-
state.result += simpleEscapeMap[ch];
|
|
1806
|
-
state.position++;
|
|
1807
|
-
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1808
|
-
hexLength = tmp;
|
|
1809
|
-
hexResult = 0;
|
|
1810
|
-
for (;hexLength > 0; hexLength--) {
|
|
1811
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1812
|
-
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1813
|
-
hexResult = (hexResult << 4) + tmp;
|
|
1814
|
-
} else {
|
|
1815
|
-
throwError(state, "expected hexadecimal character");
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
state.result += charFromCodepoint(hexResult);
|
|
1819
|
-
state.position++;
|
|
1820
|
-
} else {
|
|
1821
|
-
throwError(state, "unknown escape sequence");
|
|
1822
|
-
}
|
|
1823
|
-
captureStart = captureEnd = state.position;
|
|
1824
|
-
} else if (is_EOL(ch)) {
|
|
1825
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1826
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1827
|
-
captureStart = captureEnd = state.position;
|
|
1828
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1829
|
-
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1830
|
-
} else {
|
|
1831
|
-
state.position++;
|
|
1832
|
-
captureEnd = state.position;
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1836
|
-
}
|
|
1837
|
-
function readFlowCollection(state, nodeIndent) {
|
|
1838
|
-
var readNext = true, _line, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = {}, keyNode, keyTag, valueNode, ch;
|
|
1839
|
-
ch = state.input.charCodeAt(state.position);
|
|
1840
|
-
if (ch === 91) {
|
|
1841
|
-
terminator = 93;
|
|
1842
|
-
isMapping = false;
|
|
1843
|
-
_result = [];
|
|
1844
|
-
} else if (ch === 123) {
|
|
1845
|
-
terminator = 125;
|
|
1846
|
-
isMapping = true;
|
|
1847
|
-
_result = {};
|
|
1848
|
-
} else {
|
|
1849
|
-
return false;
|
|
1850
|
-
}
|
|
1851
|
-
if (state.anchor !== null) {
|
|
1852
|
-
state.anchorMap[state.anchor] = _result;
|
|
1853
|
-
}
|
|
1854
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1855
|
-
while (ch !== 0) {
|
|
1856
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1857
|
-
ch = state.input.charCodeAt(state.position);
|
|
1858
|
-
if (ch === terminator) {
|
|
1859
|
-
state.position++;
|
|
1860
|
-
state.tag = _tag;
|
|
1861
|
-
state.anchor = _anchor;
|
|
1862
|
-
state.kind = isMapping ? "mapping" : "sequence";
|
|
1863
|
-
state.result = _result;
|
|
1864
|
-
return true;
|
|
1865
|
-
} else if (!readNext) {
|
|
1866
|
-
throwError(state, "missed comma between flow collection entries");
|
|
1867
|
-
}
|
|
1868
|
-
keyTag = keyNode = valueNode = null;
|
|
1869
|
-
isPair = isExplicitPair = false;
|
|
1870
|
-
if (ch === 63) {
|
|
1871
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1872
|
-
if (is_WS_OR_EOL(following)) {
|
|
1873
|
-
isPair = isExplicitPair = true;
|
|
1874
|
-
state.position++;
|
|
1875
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
_line = state.line;
|
|
1879
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1880
|
-
keyTag = state.tag;
|
|
1881
|
-
keyNode = state.result;
|
|
1882
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1883
|
-
ch = state.input.charCodeAt(state.position);
|
|
1884
|
-
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1885
|
-
isPair = true;
|
|
1886
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1887
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1888
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1889
|
-
valueNode = state.result;
|
|
1890
|
-
}
|
|
1891
|
-
if (isMapping) {
|
|
1892
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
|
|
1893
|
-
} else if (isPair) {
|
|
1894
|
-
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
|
|
1895
|
-
} else {
|
|
1896
|
-
_result.push(keyNode);
|
|
1897
|
-
}
|
|
1898
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1899
|
-
ch = state.input.charCodeAt(state.position);
|
|
1900
|
-
if (ch === 44) {
|
|
1901
|
-
readNext = true;
|
|
1902
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1903
|
-
} else {
|
|
1904
|
-
readNext = false;
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1908
|
-
}
|
|
1909
|
-
function readBlockScalar(state, nodeIndent) {
|
|
1910
|
-
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1911
|
-
ch = state.input.charCodeAt(state.position);
|
|
1912
|
-
if (ch === 124) {
|
|
1913
|
-
folding = false;
|
|
1914
|
-
} else if (ch === 62) {
|
|
1915
|
-
folding = true;
|
|
1916
|
-
} else {
|
|
1917
|
-
return false;
|
|
1918
|
-
}
|
|
1919
|
-
state.kind = "scalar";
|
|
1920
|
-
state.result = "";
|
|
1921
|
-
while (ch !== 0) {
|
|
1922
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1923
|
-
if (ch === 43 || ch === 45) {
|
|
1924
|
-
if (CHOMPING_CLIP === chomping) {
|
|
1925
|
-
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1926
|
-
} else {
|
|
1927
|
-
throwError(state, "repeat of a chomping mode identifier");
|
|
1928
|
-
}
|
|
1929
|
-
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1930
|
-
if (tmp === 0) {
|
|
1931
|
-
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1932
|
-
} else if (!detectedIndent) {
|
|
1933
|
-
textIndent = nodeIndent + tmp - 1;
|
|
1934
|
-
detectedIndent = true;
|
|
1935
|
-
} else {
|
|
1936
|
-
throwError(state, "repeat of an indentation width identifier");
|
|
1937
|
-
}
|
|
1938
|
-
} else {
|
|
1939
|
-
break;
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1943
|
-
do {
|
|
1944
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1945
|
-
} while (is_WHITE_SPACE(ch));
|
|
1946
|
-
if (ch === 35) {
|
|
1947
|
-
do {
|
|
1948
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1949
|
-
} while (!is_EOL(ch) && ch !== 0);
|
|
1950
|
-
}
|
|
1951
|
-
}
|
|
1952
|
-
while (ch !== 0) {
|
|
1953
|
-
readLineBreak(state);
|
|
1954
|
-
state.lineIndent = 0;
|
|
1955
|
-
ch = state.input.charCodeAt(state.position);
|
|
1956
|
-
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1957
|
-
state.lineIndent++;
|
|
1958
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1959
|
-
}
|
|
1960
|
-
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1961
|
-
textIndent = state.lineIndent;
|
|
1962
|
-
}
|
|
1963
|
-
if (is_EOL(ch)) {
|
|
1964
|
-
emptyLines++;
|
|
1965
|
-
continue;
|
|
1966
|
-
}
|
|
1967
|
-
if (state.lineIndent < textIndent) {
|
|
1968
|
-
if (chomping === CHOMPING_KEEP) {
|
|
1969
|
-
state.result += common.repeat(`
|
|
1970
|
-
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1971
|
-
} else if (chomping === CHOMPING_CLIP) {
|
|
1972
|
-
if (didReadContent) {
|
|
1973
|
-
state.result += `
|
|
1974
|
-
`;
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
break;
|
|
1978
|
-
}
|
|
1979
|
-
if (folding) {
|
|
1980
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1981
|
-
atMoreIndented = true;
|
|
1982
|
-
state.result += common.repeat(`
|
|
1983
|
-
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1984
|
-
} else if (atMoreIndented) {
|
|
1985
|
-
atMoreIndented = false;
|
|
1986
|
-
state.result += common.repeat(`
|
|
1987
|
-
`, emptyLines + 1);
|
|
1988
|
-
} else if (emptyLines === 0) {
|
|
1989
|
-
if (didReadContent) {
|
|
1990
|
-
state.result += " ";
|
|
1991
|
-
}
|
|
1992
|
-
} else {
|
|
1993
|
-
state.result += common.repeat(`
|
|
1994
|
-
`, emptyLines);
|
|
1995
|
-
}
|
|
1996
|
-
} else {
|
|
1997
|
-
state.result += common.repeat(`
|
|
1998
|
-
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
1999
|
-
}
|
|
2000
|
-
didReadContent = true;
|
|
2001
|
-
detectedIndent = true;
|
|
2002
|
-
emptyLines = 0;
|
|
2003
|
-
captureStart = state.position;
|
|
2004
|
-
while (!is_EOL(ch) && ch !== 0) {
|
|
2005
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2006
|
-
}
|
|
2007
|
-
captureSegment(state, captureStart, state.position, false);
|
|
2008
|
-
}
|
|
2009
|
-
return true;
|
|
2010
|
-
}
|
|
2011
|
-
function readBlockSequence(state, nodeIndent) {
|
|
2012
|
-
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
2013
|
-
if (state.anchor !== null) {
|
|
2014
|
-
state.anchorMap[state.anchor] = _result;
|
|
2015
|
-
}
|
|
2016
|
-
ch = state.input.charCodeAt(state.position);
|
|
2017
|
-
while (ch !== 0) {
|
|
2018
|
-
if (ch !== 45) {
|
|
2019
|
-
break;
|
|
2020
|
-
}
|
|
2021
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
2022
|
-
if (!is_WS_OR_EOL(following)) {
|
|
2023
|
-
break;
|
|
2024
|
-
}
|
|
2025
|
-
detected = true;
|
|
2026
|
-
state.position++;
|
|
2027
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2028
|
-
if (state.lineIndent <= nodeIndent) {
|
|
2029
|
-
_result.push(null);
|
|
2030
|
-
ch = state.input.charCodeAt(state.position);
|
|
2031
|
-
continue;
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
_line = state.line;
|
|
2035
|
-
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
2036
|
-
_result.push(state.result);
|
|
2037
|
-
skipSeparationSpace(state, true, -1);
|
|
2038
|
-
ch = state.input.charCodeAt(state.position);
|
|
2039
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
2040
|
-
throwError(state, "bad indentation of a sequence entry");
|
|
2041
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
2042
|
-
break;
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
if (detected) {
|
|
2046
|
-
state.tag = _tag;
|
|
2047
|
-
state.anchor = _anchor;
|
|
2048
|
-
state.kind = "sequence";
|
|
2049
|
-
state.result = _result;
|
|
2050
|
-
return true;
|
|
2051
|
-
}
|
|
2052
|
-
return false;
|
|
2053
|
-
}
|
|
2054
|
-
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
2055
|
-
var following, allowCompact, _line, _pos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = {}, keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
2056
|
-
if (state.anchor !== null) {
|
|
2057
|
-
state.anchorMap[state.anchor] = _result;
|
|
2058
|
-
}
|
|
2059
|
-
ch = state.input.charCodeAt(state.position);
|
|
2060
|
-
while (ch !== 0) {
|
|
2061
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
2062
|
-
_line = state.line;
|
|
2063
|
-
_pos = state.position;
|
|
2064
|
-
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
2065
|
-
if (ch === 63) {
|
|
2066
|
-
if (atExplicitKey) {
|
|
2067
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
2068
|
-
keyTag = keyNode = valueNode = null;
|
|
2069
|
-
}
|
|
2070
|
-
detected = true;
|
|
2071
|
-
atExplicitKey = true;
|
|
2072
|
-
allowCompact = true;
|
|
2073
|
-
} else if (atExplicitKey) {
|
|
2074
|
-
atExplicitKey = false;
|
|
2075
|
-
allowCompact = true;
|
|
2076
|
-
} else {
|
|
2077
|
-
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
2078
|
-
}
|
|
2079
|
-
state.position += 1;
|
|
2080
|
-
ch = following;
|
|
2081
|
-
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
2082
|
-
if (state.line === _line) {
|
|
2083
|
-
ch = state.input.charCodeAt(state.position);
|
|
2084
|
-
while (is_WHITE_SPACE(ch)) {
|
|
2085
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2086
|
-
}
|
|
2087
|
-
if (ch === 58) {
|
|
2088
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2089
|
-
if (!is_WS_OR_EOL(ch)) {
|
|
2090
|
-
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2091
|
-
}
|
|
2092
|
-
if (atExplicitKey) {
|
|
2093
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
2094
|
-
keyTag = keyNode = valueNode = null;
|
|
2095
|
-
}
|
|
2096
|
-
detected = true;
|
|
2097
|
-
atExplicitKey = false;
|
|
2098
|
-
allowCompact = false;
|
|
2099
|
-
keyTag = state.tag;
|
|
2100
|
-
keyNode = state.result;
|
|
2101
|
-
} else if (detected) {
|
|
2102
|
-
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
2103
|
-
} else {
|
|
2104
|
-
state.tag = _tag;
|
|
2105
|
-
state.anchor = _anchor;
|
|
2106
|
-
return true;
|
|
2107
|
-
}
|
|
2108
|
-
} else if (detected) {
|
|
2109
|
-
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
2110
|
-
} else {
|
|
2111
|
-
state.tag = _tag;
|
|
2112
|
-
state.anchor = _anchor;
|
|
2113
|
-
return true;
|
|
2114
|
-
}
|
|
2115
|
-
} else {
|
|
2116
|
-
break;
|
|
2117
|
-
}
|
|
2118
|
-
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
2119
|
-
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
2120
|
-
if (atExplicitKey) {
|
|
2121
|
-
keyNode = state.result;
|
|
2122
|
-
} else {
|
|
2123
|
-
valueNode = state.result;
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2126
|
-
if (!atExplicitKey) {
|
|
2127
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
|
|
2128
|
-
keyTag = keyNode = valueNode = null;
|
|
2129
|
-
}
|
|
2130
|
-
skipSeparationSpace(state, true, -1);
|
|
2131
|
-
ch = state.input.charCodeAt(state.position);
|
|
2132
|
-
}
|
|
2133
|
-
if (state.lineIndent > nodeIndent && ch !== 0) {
|
|
2134
|
-
throwError(state, "bad indentation of a mapping entry");
|
|
2135
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
2136
|
-
break;
|
|
2137
|
-
}
|
|
2138
|
-
}
|
|
2139
|
-
if (atExplicitKey) {
|
|
2140
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
2141
|
-
}
|
|
2142
|
-
if (detected) {
|
|
2143
|
-
state.tag = _tag;
|
|
2144
|
-
state.anchor = _anchor;
|
|
2145
|
-
state.kind = "mapping";
|
|
2146
|
-
state.result = _result;
|
|
2147
|
-
}
|
|
2148
|
-
return detected;
|
|
2149
|
-
}
|
|
2150
|
-
function readTagProperty(state) {
|
|
2151
|
-
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
2152
|
-
ch = state.input.charCodeAt(state.position);
|
|
2153
|
-
if (ch !== 33)
|
|
2154
|
-
return false;
|
|
2155
|
-
if (state.tag !== null) {
|
|
2156
|
-
throwError(state, "duplication of a tag property");
|
|
2157
|
-
}
|
|
2158
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2159
|
-
if (ch === 60) {
|
|
2160
|
-
isVerbatim = true;
|
|
2161
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2162
|
-
} else if (ch === 33) {
|
|
2163
|
-
isNamed = true;
|
|
2164
|
-
tagHandle = "!!";
|
|
2165
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2166
|
-
} else {
|
|
2167
|
-
tagHandle = "!";
|
|
2168
|
-
}
|
|
2169
|
-
_position = state.position;
|
|
2170
|
-
if (isVerbatim) {
|
|
2171
|
-
do {
|
|
2172
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2173
|
-
} while (ch !== 0 && ch !== 62);
|
|
2174
|
-
if (state.position < state.length) {
|
|
2175
|
-
tagName = state.input.slice(_position, state.position);
|
|
2176
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2177
|
-
} else {
|
|
2178
|
-
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2179
|
-
}
|
|
2180
|
-
} else {
|
|
2181
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2182
|
-
if (ch === 33) {
|
|
2183
|
-
if (!isNamed) {
|
|
2184
|
-
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2185
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2186
|
-
throwError(state, "named tag handle cannot contain such characters");
|
|
2187
|
-
}
|
|
2188
|
-
isNamed = true;
|
|
2189
|
-
_position = state.position + 1;
|
|
2190
|
-
} else {
|
|
2191
|
-
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2195
|
-
}
|
|
2196
|
-
tagName = state.input.slice(_position, state.position);
|
|
2197
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2198
|
-
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2202
|
-
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
2203
|
-
}
|
|
2204
|
-
if (isVerbatim) {
|
|
2205
|
-
state.tag = tagName;
|
|
2206
|
-
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
2207
|
-
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2208
|
-
} else if (tagHandle === "!") {
|
|
2209
|
-
state.tag = "!" + tagName;
|
|
2210
|
-
} else if (tagHandle === "!!") {
|
|
2211
|
-
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
2212
|
-
} else {
|
|
2213
|
-
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2214
|
-
}
|
|
2215
|
-
return true;
|
|
2216
|
-
}
|
|
2217
|
-
function readAnchorProperty(state) {
|
|
2218
|
-
var _position, ch;
|
|
2219
|
-
ch = state.input.charCodeAt(state.position);
|
|
2220
|
-
if (ch !== 38)
|
|
2221
|
-
return false;
|
|
2222
|
-
if (state.anchor !== null) {
|
|
2223
|
-
throwError(state, "duplication of an anchor property");
|
|
2224
|
-
}
|
|
2225
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2226
|
-
_position = state.position;
|
|
2227
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2228
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2229
|
-
}
|
|
2230
|
-
if (state.position === _position) {
|
|
2231
|
-
throwError(state, "name of an anchor node must contain at least one character");
|
|
2232
|
-
}
|
|
2233
|
-
state.anchor = state.input.slice(_position, state.position);
|
|
2234
|
-
return true;
|
|
2235
|
-
}
|
|
2236
|
-
function readAlias(state) {
|
|
2237
|
-
var _position, alias, ch;
|
|
2238
|
-
ch = state.input.charCodeAt(state.position);
|
|
2239
|
-
if (ch !== 42)
|
|
2240
|
-
return false;
|
|
2241
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2242
|
-
_position = state.position;
|
|
2243
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2244
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2245
|
-
}
|
|
2246
|
-
if (state.position === _position) {
|
|
2247
|
-
throwError(state, "name of an alias node must contain at least one character");
|
|
2248
|
-
}
|
|
2249
|
-
alias = state.input.slice(_position, state.position);
|
|
2250
|
-
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
|
2251
|
-
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2252
|
-
}
|
|
2253
|
-
state.result = state.anchorMap[alias];
|
|
2254
|
-
skipSeparationSpace(state, true, -1);
|
|
2255
|
-
return true;
|
|
2256
|
-
}
|
|
2257
|
-
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2258
|
-
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, type, flowIndent, blockIndent;
|
|
2259
|
-
if (state.listener !== null) {
|
|
2260
|
-
state.listener("open", state);
|
|
2261
|
-
}
|
|
2262
|
-
state.tag = null;
|
|
2263
|
-
state.anchor = null;
|
|
2264
|
-
state.kind = null;
|
|
2265
|
-
state.result = null;
|
|
2266
|
-
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2267
|
-
if (allowToSeek) {
|
|
2268
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2269
|
-
atNewLine = true;
|
|
2270
|
-
if (state.lineIndent > parentIndent) {
|
|
2271
|
-
indentStatus = 1;
|
|
2272
|
-
} else if (state.lineIndent === parentIndent) {
|
|
2273
|
-
indentStatus = 0;
|
|
2274
|
-
} else if (state.lineIndent < parentIndent) {
|
|
2275
|
-
indentStatus = -1;
|
|
2276
|
-
}
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
if (indentStatus === 1) {
|
|
2280
|
-
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2281
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2282
|
-
atNewLine = true;
|
|
2283
|
-
allowBlockCollections = allowBlockStyles;
|
|
2284
|
-
if (state.lineIndent > parentIndent) {
|
|
2285
|
-
indentStatus = 1;
|
|
2286
|
-
} else if (state.lineIndent === parentIndent) {
|
|
2287
|
-
indentStatus = 0;
|
|
2288
|
-
} else if (state.lineIndent < parentIndent) {
|
|
2289
|
-
indentStatus = -1;
|
|
2290
|
-
}
|
|
2291
|
-
} else {
|
|
2292
|
-
allowBlockCollections = false;
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
if (allowBlockCollections) {
|
|
2297
|
-
allowBlockCollections = atNewLine || allowCompact;
|
|
2298
|
-
}
|
|
2299
|
-
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2300
|
-
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2301
|
-
flowIndent = parentIndent;
|
|
2302
|
-
} else {
|
|
2303
|
-
flowIndent = parentIndent + 1;
|
|
2304
|
-
}
|
|
2305
|
-
blockIndent = state.position - state.lineStart;
|
|
2306
|
-
if (indentStatus === 1) {
|
|
2307
|
-
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2308
|
-
hasContent = true;
|
|
2309
|
-
} else {
|
|
2310
|
-
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2311
|
-
hasContent = true;
|
|
2312
|
-
} else if (readAlias(state)) {
|
|
2313
|
-
hasContent = true;
|
|
2314
|
-
if (state.tag !== null || state.anchor !== null) {
|
|
2315
|
-
throwError(state, "alias node should not have any properties");
|
|
2316
|
-
}
|
|
2317
|
-
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2318
|
-
hasContent = true;
|
|
2319
|
-
if (state.tag === null) {
|
|
2320
|
-
state.tag = "?";
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
if (state.anchor !== null) {
|
|
2324
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
} else if (indentStatus === 0) {
|
|
2328
|
-
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
if (state.tag !== null && state.tag !== "!") {
|
|
2332
|
-
if (state.tag === "?") {
|
|
2333
|
-
if (state.result !== null && state.kind !== "scalar") {
|
|
2334
|
-
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2335
|
-
}
|
|
2336
|
-
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
2337
|
-
type = state.implicitTypes[typeIndex];
|
|
2338
|
-
if (type.resolve(state.result)) {
|
|
2339
|
-
state.result = type.construct(state.result);
|
|
2340
|
-
state.tag = type.tag;
|
|
2341
|
-
if (state.anchor !== null) {
|
|
2342
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2343
|
-
}
|
|
2344
|
-
break;
|
|
2345
|
-
}
|
|
2346
|
-
}
|
|
2347
|
-
} else if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2348
|
-
type = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2349
|
-
if (state.result !== null && type.kind !== state.kind) {
|
|
2350
|
-
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
2351
|
-
}
|
|
2352
|
-
if (!type.resolve(state.result)) {
|
|
2353
|
-
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2354
|
-
} else {
|
|
2355
|
-
state.result = type.construct(state.result);
|
|
2356
|
-
if (state.anchor !== null) {
|
|
2357
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
} else {
|
|
2361
|
-
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
if (state.listener !== null) {
|
|
2365
|
-
state.listener("close", state);
|
|
2366
|
-
}
|
|
2367
|
-
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2368
|
-
}
|
|
2369
|
-
function readDocument(state) {
|
|
2370
|
-
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2371
|
-
state.version = null;
|
|
2372
|
-
state.checkLineBreaks = state.legacy;
|
|
2373
|
-
state.tagMap = {};
|
|
2374
|
-
state.anchorMap = {};
|
|
2375
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2376
|
-
skipSeparationSpace(state, true, -1);
|
|
2377
|
-
ch = state.input.charCodeAt(state.position);
|
|
2378
|
-
if (state.lineIndent > 0 || ch !== 37) {
|
|
2379
|
-
break;
|
|
2380
|
-
}
|
|
2381
|
-
hasDirectives = true;
|
|
2382
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2383
|
-
_position = state.position;
|
|
2384
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2385
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2386
|
-
}
|
|
2387
|
-
directiveName = state.input.slice(_position, state.position);
|
|
2388
|
-
directiveArgs = [];
|
|
2389
|
-
if (directiveName.length < 1) {
|
|
2390
|
-
throwError(state, "directive name must not be less than one character in length");
|
|
2391
|
-
}
|
|
2392
|
-
while (ch !== 0) {
|
|
2393
|
-
while (is_WHITE_SPACE(ch)) {
|
|
2394
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2395
|
-
}
|
|
2396
|
-
if (ch === 35) {
|
|
2397
|
-
do {
|
|
2398
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2399
|
-
} while (ch !== 0 && !is_EOL(ch));
|
|
2400
|
-
break;
|
|
2401
|
-
}
|
|
2402
|
-
if (is_EOL(ch))
|
|
2403
|
-
break;
|
|
2404
|
-
_position = state.position;
|
|
2405
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2406
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2407
|
-
}
|
|
2408
|
-
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2409
|
-
}
|
|
2410
|
-
if (ch !== 0)
|
|
2411
|
-
readLineBreak(state);
|
|
2412
|
-
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
2413
|
-
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2414
|
-
} else {
|
|
2415
|
-
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2416
|
-
}
|
|
2417
|
-
}
|
|
2418
|
-
skipSeparationSpace(state, true, -1);
|
|
2419
|
-
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2420
|
-
state.position += 3;
|
|
2421
|
-
skipSeparationSpace(state, true, -1);
|
|
2422
|
-
} else if (hasDirectives) {
|
|
2423
|
-
throwError(state, "directives end mark is expected");
|
|
2424
|
-
}
|
|
2425
|
-
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2426
|
-
skipSeparationSpace(state, true, -1);
|
|
2427
|
-
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2428
|
-
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2429
|
-
}
|
|
2430
|
-
state.documents.push(state.result);
|
|
2431
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2432
|
-
if (state.input.charCodeAt(state.position) === 46) {
|
|
2433
|
-
state.position += 3;
|
|
2434
|
-
skipSeparationSpace(state, true, -1);
|
|
2435
|
-
}
|
|
2436
|
-
return;
|
|
2437
|
-
}
|
|
2438
|
-
if (state.position < state.length - 1) {
|
|
2439
|
-
throwError(state, "end of the stream or a document separator is expected");
|
|
2440
|
-
} else {
|
|
2441
|
-
return;
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
function loadDocuments(input, options2) {
|
|
2445
|
-
input = String(input);
|
|
2446
|
-
options2 = options2 || {};
|
|
2447
|
-
if (input.length !== 0) {
|
|
2448
|
-
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2449
|
-
input += `
|
|
2450
|
-
`;
|
|
2451
|
-
}
|
|
2452
|
-
if (input.charCodeAt(0) === 65279) {
|
|
2453
|
-
input = input.slice(1);
|
|
2454
|
-
}
|
|
2455
|
-
}
|
|
2456
|
-
var state = new State(input, options2);
|
|
2457
|
-
var nullpos = input.indexOf("\x00");
|
|
2458
|
-
if (nullpos !== -1) {
|
|
2459
|
-
state.position = nullpos;
|
|
2460
|
-
throwError(state, "null byte is not allowed in input");
|
|
2461
|
-
}
|
|
2462
|
-
state.input += "\x00";
|
|
2463
|
-
while (state.input.charCodeAt(state.position) === 32) {
|
|
2464
|
-
state.lineIndent += 1;
|
|
2465
|
-
state.position += 1;
|
|
2466
|
-
}
|
|
2467
|
-
while (state.position < state.length - 1) {
|
|
2468
|
-
readDocument(state);
|
|
2469
|
-
}
|
|
2470
|
-
return state.documents;
|
|
2471
|
-
}
|
|
2472
|
-
function loadAll(input, iterator, options2) {
|
|
2473
|
-
if (iterator !== null && typeof iterator === "object" && typeof options2 === "undefined") {
|
|
2474
|
-
options2 = iterator;
|
|
2475
|
-
iterator = null;
|
|
2476
|
-
}
|
|
2477
|
-
var documents = loadDocuments(input, options2);
|
|
2478
|
-
if (typeof iterator !== "function") {
|
|
2479
|
-
return documents;
|
|
2480
|
-
}
|
|
2481
|
-
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
2482
|
-
iterator(documents[index]);
|
|
2483
|
-
}
|
|
2484
|
-
}
|
|
2485
|
-
function load(input, options2) {
|
|
2486
|
-
var documents = loadDocuments(input, options2);
|
|
2487
|
-
if (documents.length === 0) {
|
|
2488
|
-
return;
|
|
2489
|
-
} else if (documents.length === 1) {
|
|
2490
|
-
return documents[0];
|
|
2491
|
-
}
|
|
2492
|
-
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2493
|
-
}
|
|
2494
|
-
function safeLoadAll(input, iterator, options2) {
|
|
2495
|
-
if (typeof iterator === "object" && iterator !== null && typeof options2 === "undefined") {
|
|
2496
|
-
options2 = iterator;
|
|
2497
|
-
iterator = null;
|
|
2498
|
-
}
|
|
2499
|
-
return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options2));
|
|
2500
|
-
}
|
|
2501
|
-
function safeLoad(input, options2) {
|
|
2502
|
-
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options2));
|
|
2503
|
-
}
|
|
2504
|
-
exports.loadAll = loadAll;
|
|
2505
|
-
exports.load = load;
|
|
2506
|
-
exports.safeLoadAll = safeLoadAll;
|
|
2507
|
-
exports.safeLoad = safeLoad;
|
|
2508
|
-
});
|
|
2509
|
-
|
|
2510
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml/dumper.js
|
|
2511
|
-
var require_dumper = __commonJS((exports, module) => {
|
|
2512
|
-
var common = require_common();
|
|
2513
|
-
var YAMLException = require_exception();
|
|
2514
|
-
var DEFAULT_FULL_SCHEMA = require_default_full();
|
|
2515
|
-
var DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
2516
|
-
var _toString = Object.prototype.toString;
|
|
2517
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2518
|
-
var CHAR_TAB = 9;
|
|
2519
|
-
var CHAR_LINE_FEED = 10;
|
|
2520
|
-
var CHAR_CARRIAGE_RETURN = 13;
|
|
2521
|
-
var CHAR_SPACE = 32;
|
|
2522
|
-
var CHAR_EXCLAMATION = 33;
|
|
2523
|
-
var CHAR_DOUBLE_QUOTE = 34;
|
|
2524
|
-
var CHAR_SHARP = 35;
|
|
2525
|
-
var CHAR_PERCENT = 37;
|
|
2526
|
-
var CHAR_AMPERSAND = 38;
|
|
2527
|
-
var CHAR_SINGLE_QUOTE = 39;
|
|
2528
|
-
var CHAR_ASTERISK = 42;
|
|
2529
|
-
var CHAR_COMMA = 44;
|
|
2530
|
-
var CHAR_MINUS = 45;
|
|
2531
|
-
var CHAR_COLON = 58;
|
|
2532
|
-
var CHAR_EQUALS = 61;
|
|
2533
|
-
var CHAR_GREATER_THAN = 62;
|
|
2534
|
-
var CHAR_QUESTION = 63;
|
|
2535
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
2536
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2537
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2538
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
2539
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2540
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
2541
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2542
|
-
var ESCAPE_SEQUENCES = {};
|
|
2543
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2544
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2545
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2546
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2547
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2548
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2549
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2550
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2551
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2552
|
-
ESCAPE_SEQUENCES[34] = "\\\"";
|
|
2553
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2554
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2555
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2556
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2557
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2558
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2559
|
-
"y",
|
|
2560
|
-
"Y",
|
|
2561
|
-
"yes",
|
|
2562
|
-
"Yes",
|
|
2563
|
-
"YES",
|
|
2564
|
-
"on",
|
|
2565
|
-
"On",
|
|
2566
|
-
"ON",
|
|
2567
|
-
"n",
|
|
2568
|
-
"N",
|
|
2569
|
-
"no",
|
|
2570
|
-
"No",
|
|
2571
|
-
"NO",
|
|
2572
|
-
"off",
|
|
2573
|
-
"Off",
|
|
2574
|
-
"OFF"
|
|
2575
|
-
];
|
|
2576
|
-
function compileStyleMap(schema, map) {
|
|
2577
|
-
var result, keys, index, length, tag, style, type;
|
|
2578
|
-
if (map === null)
|
|
2579
|
-
return {};
|
|
2580
|
-
result = {};
|
|
2581
|
-
keys = Object.keys(map);
|
|
2582
|
-
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
2583
|
-
tag = keys[index];
|
|
2584
|
-
style = String(map[tag]);
|
|
2585
|
-
if (tag.slice(0, 2) === "!!") {
|
|
2586
|
-
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2587
|
-
}
|
|
2588
|
-
type = schema.compiledTypeMap["fallback"][tag];
|
|
2589
|
-
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
2590
|
-
style = type.styleAliases[style];
|
|
2591
|
-
}
|
|
2592
|
-
result[tag] = style;
|
|
2593
|
-
}
|
|
2594
|
-
return result;
|
|
2595
|
-
}
|
|
2596
|
-
function encodeHex(character) {
|
|
2597
|
-
var string, handle, length;
|
|
2598
|
-
string = character.toString(16).toUpperCase();
|
|
2599
|
-
if (character <= 255) {
|
|
2600
|
-
handle = "x";
|
|
2601
|
-
length = 2;
|
|
2602
|
-
} else if (character <= 65535) {
|
|
2603
|
-
handle = "u";
|
|
2604
|
-
length = 4;
|
|
2605
|
-
} else if (character <= 4294967295) {
|
|
2606
|
-
handle = "U";
|
|
2607
|
-
length = 8;
|
|
2608
|
-
} else {
|
|
2609
|
-
throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2610
|
-
}
|
|
2611
|
-
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2612
|
-
}
|
|
2613
|
-
function State(options2) {
|
|
2614
|
-
this.schema = options2["schema"] || DEFAULT_FULL_SCHEMA;
|
|
2615
|
-
this.indent = Math.max(1, options2["indent"] || 2);
|
|
2616
|
-
this.noArrayIndent = options2["noArrayIndent"] || false;
|
|
2617
|
-
this.skipInvalid = options2["skipInvalid"] || false;
|
|
2618
|
-
this.flowLevel = common.isNothing(options2["flowLevel"]) ? -1 : options2["flowLevel"];
|
|
2619
|
-
this.styleMap = compileStyleMap(this.schema, options2["styles"] || null);
|
|
2620
|
-
this.sortKeys = options2["sortKeys"] || false;
|
|
2621
|
-
this.lineWidth = options2["lineWidth"] || 80;
|
|
2622
|
-
this.noRefs = options2["noRefs"] || false;
|
|
2623
|
-
this.noCompatMode = options2["noCompatMode"] || false;
|
|
2624
|
-
this.condenseFlow = options2["condenseFlow"] || false;
|
|
2625
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
2626
|
-
this.explicitTypes = this.schema.compiledExplicit;
|
|
2627
|
-
this.tag = null;
|
|
2628
|
-
this.result = "";
|
|
2629
|
-
this.duplicates = [];
|
|
2630
|
-
this.usedDuplicates = null;
|
|
2631
|
-
}
|
|
2632
|
-
function indentString(string, spaces) {
|
|
2633
|
-
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2634
|
-
while (position < length) {
|
|
2635
|
-
next = string.indexOf(`
|
|
2636
|
-
`, position);
|
|
2637
|
-
if (next === -1) {
|
|
2638
|
-
line = string.slice(position);
|
|
2639
|
-
position = length;
|
|
2640
|
-
} else {
|
|
2641
|
-
line = string.slice(position, next + 1);
|
|
2642
|
-
position = next + 1;
|
|
2643
|
-
}
|
|
2644
|
-
if (line.length && line !== `
|
|
2645
|
-
`)
|
|
2646
|
-
result += ind;
|
|
2647
|
-
result += line;
|
|
2648
|
-
}
|
|
2649
|
-
return result;
|
|
2650
|
-
}
|
|
2651
|
-
function generateNextLine(state, level) {
|
|
2652
|
-
return `
|
|
2653
|
-
` + common.repeat(" ", state.indent * level);
|
|
2654
|
-
}
|
|
2655
|
-
function testImplicitResolving(state, str2) {
|
|
2656
|
-
var index, length, type;
|
|
2657
|
-
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
2658
|
-
type = state.implicitTypes[index];
|
|
2659
|
-
if (type.resolve(str2)) {
|
|
2660
|
-
return true;
|
|
2661
|
-
}
|
|
2662
|
-
}
|
|
2663
|
-
return false;
|
|
2664
|
-
}
|
|
2665
|
-
function isWhitespace(c) {
|
|
2666
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2667
|
-
}
|
|
2668
|
-
function isPrintable(c) {
|
|
2669
|
-
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== 65279 || 65536 <= c && c <= 1114111;
|
|
2670
|
-
}
|
|
2671
|
-
function isNsChar(c) {
|
|
2672
|
-
return isPrintable(c) && !isWhitespace(c) && c !== 65279 && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2673
|
-
}
|
|
2674
|
-
function isPlainSafe(c, prev) {
|
|
2675
|
-
return isPrintable(c) && c !== 65279 && 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_COLON && (c !== CHAR_SHARP || prev && isNsChar(prev));
|
|
2676
|
-
}
|
|
2677
|
-
function isPlainSafeFirst(c) {
|
|
2678
|
-
return isPrintable(c) && c !== 65279 && !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;
|
|
2679
|
-
}
|
|
2680
|
-
function needIndentIndicator(string) {
|
|
2681
|
-
var leadingSpaceRe = /^\n* /;
|
|
2682
|
-
return leadingSpaceRe.test(string);
|
|
2683
|
-
}
|
|
2684
|
-
var STYLE_PLAIN = 1;
|
|
2685
|
-
var STYLE_SINGLE = 2;
|
|
2686
|
-
var STYLE_LITERAL = 3;
|
|
2687
|
-
var STYLE_FOLDED = 4;
|
|
2688
|
-
var STYLE_DOUBLE = 5;
|
|
2689
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
|
2690
|
-
var i;
|
|
2691
|
-
var char, prev_char;
|
|
2692
|
-
var hasLineBreak = false;
|
|
2693
|
-
var hasFoldableLine = false;
|
|
2694
|
-
var shouldTrackWidth = lineWidth !== -1;
|
|
2695
|
-
var previousLineBreak = -1;
|
|
2696
|
-
var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
|
|
2697
|
-
if (singleLineOnly) {
|
|
2698
|
-
for (i = 0;i < string.length; i++) {
|
|
2699
|
-
char = string.charCodeAt(i);
|
|
2700
|
-
if (!isPrintable(char)) {
|
|
2701
|
-
return STYLE_DOUBLE;
|
|
2702
|
-
}
|
|
2703
|
-
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
|
2704
|
-
plain = plain && isPlainSafe(char, prev_char);
|
|
2705
|
-
}
|
|
2706
|
-
} else {
|
|
2707
|
-
for (i = 0;i < string.length; i++) {
|
|
2708
|
-
char = string.charCodeAt(i);
|
|
2709
|
-
if (char === CHAR_LINE_FEED) {
|
|
2710
|
-
hasLineBreak = true;
|
|
2711
|
-
if (shouldTrackWidth) {
|
|
2712
|
-
hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2713
|
-
previousLineBreak = i;
|
|
2714
|
-
}
|
|
2715
|
-
} else if (!isPrintable(char)) {
|
|
2716
|
-
return STYLE_DOUBLE;
|
|
2717
|
-
}
|
|
2718
|
-
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
|
2719
|
-
plain = plain && isPlainSafe(char, prev_char);
|
|
2720
|
-
}
|
|
2721
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2722
|
-
}
|
|
2723
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2724
|
-
return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
|
|
2725
|
-
}
|
|
2726
|
-
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2727
|
-
return STYLE_DOUBLE;
|
|
2728
|
-
}
|
|
2729
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2730
|
-
}
|
|
2731
|
-
function writeScalar(state, string, level, iskey) {
|
|
2732
|
-
state.dump = function() {
|
|
2733
|
-
if (string.length === 0) {
|
|
2734
|
-
return "''";
|
|
2735
|
-
}
|
|
2736
|
-
if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
|
|
2737
|
-
return "'" + string + "'";
|
|
2738
|
-
}
|
|
2739
|
-
var indent = state.indent * Math.max(1, level);
|
|
2740
|
-
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2741
|
-
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2742
|
-
function testAmbiguity(string2) {
|
|
2743
|
-
return testImplicitResolving(state, string2);
|
|
2744
|
-
}
|
|
2745
|
-
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
|
|
2746
|
-
case STYLE_PLAIN:
|
|
2747
|
-
return string;
|
|
2748
|
-
case STYLE_SINGLE:
|
|
2749
|
-
return "'" + string.replace(/'/g, "''") + "'";
|
|
2750
|
-
case STYLE_LITERAL:
|
|
2751
|
-
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2752
|
-
case STYLE_FOLDED:
|
|
2753
|
-
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2754
|
-
case STYLE_DOUBLE:
|
|
2755
|
-
return '"' + escapeString(string, lineWidth) + '"';
|
|
2756
|
-
default:
|
|
2757
|
-
throw new YAMLException("impossible error: invalid scalar style");
|
|
2758
|
-
}
|
|
2759
|
-
}();
|
|
2760
|
-
}
|
|
2761
|
-
function blockHeader(string, indentPerLevel) {
|
|
2762
|
-
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2763
|
-
var clip = string[string.length - 1] === `
|
|
2764
|
-
`;
|
|
2765
|
-
var keep = clip && (string[string.length - 2] === `
|
|
2766
|
-
` || string === `
|
|
2767
|
-
`);
|
|
2768
|
-
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2769
|
-
return indentIndicator + chomp + `
|
|
2770
|
-
`;
|
|
2771
|
-
}
|
|
2772
|
-
function dropEndingNewline(string) {
|
|
2773
|
-
return string[string.length - 1] === `
|
|
2774
|
-
` ? string.slice(0, -1) : string;
|
|
2775
|
-
}
|
|
2776
|
-
function foldString(string, width) {
|
|
2777
|
-
var lineRe = /(\n+)([^\n]*)/g;
|
|
2778
|
-
var result = function() {
|
|
2779
|
-
var nextLF = string.indexOf(`
|
|
2780
|
-
`);
|
|
2781
|
-
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2782
|
-
lineRe.lastIndex = nextLF;
|
|
2783
|
-
return foldLine(string.slice(0, nextLF), width);
|
|
2784
|
-
}();
|
|
2785
|
-
var prevMoreIndented = string[0] === `
|
|
2786
|
-
` || string[0] === " ";
|
|
2787
|
-
var moreIndented;
|
|
2788
|
-
var match;
|
|
2789
|
-
while (match = lineRe.exec(string)) {
|
|
2790
|
-
var prefix = match[1], line = match[2];
|
|
2791
|
-
moreIndented = line[0] === " ";
|
|
2792
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
2793
|
-
` : "") + foldLine(line, width);
|
|
2794
|
-
prevMoreIndented = moreIndented;
|
|
2795
|
-
}
|
|
2796
|
-
return result;
|
|
2797
|
-
}
|
|
2798
|
-
function foldLine(line, width) {
|
|
2799
|
-
if (line === "" || line[0] === " ")
|
|
2800
|
-
return line;
|
|
2801
|
-
var breakRe = / [^ ]/g;
|
|
2802
|
-
var match;
|
|
2803
|
-
var start = 0, end, curr = 0, next = 0;
|
|
2804
|
-
var result = "";
|
|
2805
|
-
while (match = breakRe.exec(line)) {
|
|
2806
|
-
next = match.index;
|
|
2807
|
-
if (next - start > width) {
|
|
2808
|
-
end = curr > start ? curr : next;
|
|
2809
|
-
result += `
|
|
2810
|
-
` + line.slice(start, end);
|
|
2811
|
-
start = end + 1;
|
|
2812
|
-
}
|
|
2813
|
-
curr = next;
|
|
2814
|
-
}
|
|
2815
|
-
result += `
|
|
2816
|
-
`;
|
|
2817
|
-
if (line.length - start > width && curr > start) {
|
|
2818
|
-
result += line.slice(start, curr) + `
|
|
2819
|
-
` + line.slice(curr + 1);
|
|
2820
|
-
} else {
|
|
2821
|
-
result += line.slice(start);
|
|
2822
|
-
}
|
|
2823
|
-
return result.slice(1);
|
|
2824
|
-
}
|
|
2825
|
-
function escapeString(string) {
|
|
2826
|
-
var result = "";
|
|
2827
|
-
var char, nextChar;
|
|
2828
|
-
var escapeSeq;
|
|
2829
|
-
for (var i = 0;i < string.length; i++) {
|
|
2830
|
-
char = string.charCodeAt(i);
|
|
2831
|
-
if (char >= 55296 && char <= 56319) {
|
|
2832
|
-
nextChar = string.charCodeAt(i + 1);
|
|
2833
|
-
if (nextChar >= 56320 && nextChar <= 57343) {
|
|
2834
|
-
result += encodeHex((char - 55296) * 1024 + nextChar - 56320 + 65536);
|
|
2835
|
-
i++;
|
|
2836
|
-
continue;
|
|
2837
|
-
}
|
|
2838
|
-
}
|
|
2839
|
-
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2840
|
-
result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
|
|
2841
|
-
}
|
|
2842
|
-
return result;
|
|
2843
|
-
}
|
|
2844
|
-
function writeFlowSequence(state, level, object) {
|
|
2845
|
-
var _result = "", _tag = state.tag, index, length;
|
|
2846
|
-
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2847
|
-
if (writeNode(state, level, object[index], false, false)) {
|
|
2848
|
-
if (index !== 0)
|
|
2849
|
-
_result += "," + (!state.condenseFlow ? " " : "");
|
|
2850
|
-
_result += state.dump;
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
state.tag = _tag;
|
|
2854
|
-
state.dump = "[" + _result + "]";
|
|
2855
|
-
}
|
|
2856
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
2857
|
-
var _result = "", _tag = state.tag, index, length;
|
|
2858
|
-
for (index = 0, length = object.length;index < length; index += 1) {
|
|
2859
|
-
if (writeNode(state, level + 1, object[index], true, true)) {
|
|
2860
|
-
if (!compact || index !== 0) {
|
|
2861
|
-
_result += generateNextLine(state, level);
|
|
2862
|
-
}
|
|
2863
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2864
|
-
_result += "-";
|
|
2865
|
-
} else {
|
|
2866
|
-
_result += "- ";
|
|
2867
|
-
}
|
|
2868
|
-
_result += state.dump;
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
state.tag = _tag;
|
|
2872
|
-
state.dump = _result || "[]";
|
|
2873
|
-
}
|
|
2874
|
-
function writeFlowMapping(state, level, object) {
|
|
2875
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2876
|
-
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2877
|
-
pairBuffer = "";
|
|
2878
|
-
if (index !== 0)
|
|
2879
|
-
pairBuffer += ", ";
|
|
2880
|
-
if (state.condenseFlow)
|
|
2881
|
-
pairBuffer += '"';
|
|
2882
|
-
objectKey = objectKeyList[index];
|
|
2883
|
-
objectValue = object[objectKey];
|
|
2884
|
-
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2885
|
-
continue;
|
|
2886
|
-
}
|
|
2887
|
-
if (state.dump.length > 1024)
|
|
2888
|
-
pairBuffer += "? ";
|
|
2889
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2890
|
-
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2891
|
-
continue;
|
|
2892
|
-
}
|
|
2893
|
-
pairBuffer += state.dump;
|
|
2894
|
-
_result += pairBuffer;
|
|
2895
|
-
}
|
|
2896
|
-
state.tag = _tag;
|
|
2897
|
-
state.dump = "{" + _result + "}";
|
|
2898
|
-
}
|
|
2899
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
2900
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2901
|
-
if (state.sortKeys === true) {
|
|
2902
|
-
objectKeyList.sort();
|
|
2903
|
-
} else if (typeof state.sortKeys === "function") {
|
|
2904
|
-
objectKeyList.sort(state.sortKeys);
|
|
2905
|
-
} else if (state.sortKeys) {
|
|
2906
|
-
throw new YAMLException("sortKeys must be a boolean or a function");
|
|
2907
|
-
}
|
|
2908
|
-
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
2909
|
-
pairBuffer = "";
|
|
2910
|
-
if (!compact || index !== 0) {
|
|
2911
|
-
pairBuffer += generateNextLine(state, level);
|
|
2912
|
-
}
|
|
2913
|
-
objectKey = objectKeyList[index];
|
|
2914
|
-
objectValue = object[objectKey];
|
|
2915
|
-
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2916
|
-
continue;
|
|
2917
|
-
}
|
|
2918
|
-
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2919
|
-
if (explicitPair) {
|
|
2920
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2921
|
-
pairBuffer += "?";
|
|
2922
|
-
} else {
|
|
2923
|
-
pairBuffer += "? ";
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
pairBuffer += state.dump;
|
|
2927
|
-
if (explicitPair) {
|
|
2928
|
-
pairBuffer += generateNextLine(state, level);
|
|
2929
|
-
}
|
|
2930
|
-
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2931
|
-
continue;
|
|
2932
|
-
}
|
|
2933
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2934
|
-
pairBuffer += ":";
|
|
2935
|
-
} else {
|
|
2936
|
-
pairBuffer += ": ";
|
|
2937
|
-
}
|
|
2938
|
-
pairBuffer += state.dump;
|
|
2939
|
-
_result += pairBuffer;
|
|
2940
|
-
}
|
|
2941
|
-
state.tag = _tag;
|
|
2942
|
-
state.dump = _result || "{}";
|
|
2943
|
-
}
|
|
2944
|
-
function detectType(state, object, explicit) {
|
|
2945
|
-
var _result, typeList, index, length, type, style;
|
|
2946
|
-
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2947
|
-
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
2948
|
-
type = typeList[index];
|
|
2949
|
-
if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
|
|
2950
|
-
state.tag = explicit ? type.tag : "?";
|
|
2951
|
-
if (type.represent) {
|
|
2952
|
-
style = state.styleMap[type.tag] || type.defaultStyle;
|
|
2953
|
-
if (_toString.call(type.represent) === "[object Function]") {
|
|
2954
|
-
_result = type.represent(object, style);
|
|
2955
|
-
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
2956
|
-
_result = type.represent[style](object, style);
|
|
2957
|
-
} else {
|
|
2958
|
-
throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2959
|
-
}
|
|
2960
|
-
state.dump = _result;
|
|
2961
|
-
}
|
|
2962
|
-
return true;
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
|
-
return false;
|
|
2966
|
-
}
|
|
2967
|
-
function writeNode(state, level, object, block, compact, iskey) {
|
|
2968
|
-
state.tag = null;
|
|
2969
|
-
state.dump = object;
|
|
2970
|
-
if (!detectType(state, object, false)) {
|
|
2971
|
-
detectType(state, object, true);
|
|
2972
|
-
}
|
|
2973
|
-
var type = _toString.call(state.dump);
|
|
2974
|
-
if (block) {
|
|
2975
|
-
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2976
|
-
}
|
|
2977
|
-
var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
|
|
2978
|
-
if (objectOrArray) {
|
|
2979
|
-
duplicateIndex = state.duplicates.indexOf(object);
|
|
2980
|
-
duplicate = duplicateIndex !== -1;
|
|
2981
|
-
}
|
|
2982
|
-
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2983
|
-
compact = false;
|
|
2984
|
-
}
|
|
2985
|
-
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2986
|
-
state.dump = "*ref_" + duplicateIndex;
|
|
2987
|
-
} else {
|
|
2988
|
-
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2989
|
-
state.usedDuplicates[duplicateIndex] = true;
|
|
2990
|
-
}
|
|
2991
|
-
if (type === "[object Object]") {
|
|
2992
|
-
if (block && Object.keys(state.dump).length !== 0) {
|
|
2993
|
-
writeBlockMapping(state, level, state.dump, compact);
|
|
2994
|
-
if (duplicate) {
|
|
2995
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2996
|
-
}
|
|
2997
|
-
} else {
|
|
2998
|
-
writeFlowMapping(state, level, state.dump);
|
|
2999
|
-
if (duplicate) {
|
|
3000
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
} else if (type === "[object Array]") {
|
|
3004
|
-
var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
|
|
3005
|
-
if (block && state.dump.length !== 0) {
|
|
3006
|
-
writeBlockSequence(state, arrayLevel, state.dump, compact);
|
|
3007
|
-
if (duplicate) {
|
|
3008
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
3009
|
-
}
|
|
3010
|
-
} else {
|
|
3011
|
-
writeFlowSequence(state, arrayLevel, state.dump);
|
|
3012
|
-
if (duplicate) {
|
|
3013
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
3014
|
-
}
|
|
3015
|
-
}
|
|
3016
|
-
} else if (type === "[object String]") {
|
|
3017
|
-
if (state.tag !== "?") {
|
|
3018
|
-
writeScalar(state, state.dump, level, iskey);
|
|
3019
|
-
}
|
|
3020
|
-
} else {
|
|
3021
|
-
if (state.skipInvalid)
|
|
3022
|
-
return false;
|
|
3023
|
-
throw new YAMLException("unacceptable kind of an object to dump " + type);
|
|
3024
|
-
}
|
|
3025
|
-
if (state.tag !== null && state.tag !== "?") {
|
|
3026
|
-
state.dump = "!<" + state.tag + "> " + state.dump;
|
|
3027
|
-
}
|
|
3028
|
-
}
|
|
3029
|
-
return true;
|
|
3030
|
-
}
|
|
3031
|
-
function getDuplicateReferences(object, state) {
|
|
3032
|
-
var objects = [], duplicatesIndexes = [], index, length;
|
|
3033
|
-
inspectNode(object, objects, duplicatesIndexes);
|
|
3034
|
-
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
3035
|
-
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
3036
|
-
}
|
|
3037
|
-
state.usedDuplicates = new Array(length);
|
|
3038
|
-
}
|
|
3039
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
3040
|
-
var objectKeyList, index, length;
|
|
3041
|
-
if (object !== null && typeof object === "object") {
|
|
3042
|
-
index = objects.indexOf(object);
|
|
3043
|
-
if (index !== -1) {
|
|
3044
|
-
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
3045
|
-
duplicatesIndexes.push(index);
|
|
3046
|
-
}
|
|
3047
|
-
} else {
|
|
3048
|
-
objects.push(object);
|
|
3049
|
-
if (Array.isArray(object)) {
|
|
3050
|
-
for (index = 0, length = object.length;index < length; index += 1) {
|
|
3051
|
-
inspectNode(object[index], objects, duplicatesIndexes);
|
|
3052
|
-
}
|
|
3053
|
-
} else {
|
|
3054
|
-
objectKeyList = Object.keys(object);
|
|
3055
|
-
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
3056
|
-
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
}
|
|
3060
|
-
}
|
|
3061
|
-
}
|
|
3062
|
-
function dump(input, options2) {
|
|
3063
|
-
options2 = options2 || {};
|
|
3064
|
-
var state = new State(options2);
|
|
3065
|
-
if (!state.noRefs)
|
|
3066
|
-
getDuplicateReferences(input, state);
|
|
3067
|
-
if (writeNode(state, 0, input, true, true))
|
|
3068
|
-
return state.dump + `
|
|
3069
|
-
`;
|
|
3070
|
-
return "";
|
|
3071
|
-
}
|
|
3072
|
-
function safeDump(input, options2) {
|
|
3073
|
-
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options2));
|
|
3074
|
-
}
|
|
3075
|
-
exports.dump = dump;
|
|
3076
|
-
exports.safeDump = safeDump;
|
|
3077
|
-
});
|
|
3078
|
-
|
|
3079
|
-
// node_modules/gray-matter/node_modules/js-yaml/lib/js-yaml.js
|
|
3080
|
-
var require_js_yaml = __commonJS((exports, module) => {
|
|
3081
|
-
var loader = require_loader();
|
|
3082
|
-
var dumper = require_dumper();
|
|
3083
|
-
function deprecated(name) {
|
|
3084
|
-
return function() {
|
|
3085
|
-
throw new Error("Function " + name + " is deprecated and cannot be used.");
|
|
3086
|
-
};
|
|
3087
|
-
}
|
|
3088
|
-
exports.Type = require_type();
|
|
3089
|
-
exports.Schema = require_schema();
|
|
3090
|
-
exports.FAILSAFE_SCHEMA = require_failsafe();
|
|
3091
|
-
exports.JSON_SCHEMA = require_json();
|
|
3092
|
-
exports.CORE_SCHEMA = require_core();
|
|
3093
|
-
exports.DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
3094
|
-
exports.DEFAULT_FULL_SCHEMA = require_default_full();
|
|
3095
|
-
exports.load = loader.load;
|
|
3096
|
-
exports.loadAll = loader.loadAll;
|
|
3097
|
-
exports.safeLoad = loader.safeLoad;
|
|
3098
|
-
exports.safeLoadAll = loader.safeLoadAll;
|
|
3099
|
-
exports.dump = dumper.dump;
|
|
3100
|
-
exports.safeDump = dumper.safeDump;
|
|
3101
|
-
exports.YAMLException = require_exception();
|
|
3102
|
-
exports.MINIMAL_SCHEMA = require_failsafe();
|
|
3103
|
-
exports.SAFE_SCHEMA = require_default_safe();
|
|
3104
|
-
exports.DEFAULT_SCHEMA = require_default_full();
|
|
3105
|
-
exports.scan = deprecated("scan");
|
|
3106
|
-
exports.parse = deprecated("parse");
|
|
3107
|
-
exports.compose = deprecated("compose");
|
|
3108
|
-
exports.addConstructor = deprecated("addConstructor");
|
|
3109
|
-
});
|
|
3110
|
-
|
|
3111
|
-
// node_modules/gray-matter/node_modules/js-yaml/index.js
|
|
3112
|
-
var require_js_yaml2 = __commonJS((exports, module) => {
|
|
3113
|
-
var yaml = require_js_yaml();
|
|
3114
|
-
module.exports = yaml;
|
|
3115
|
-
});
|
|
3116
|
-
|
|
3117
|
-
// node_modules/gray-matter/lib/engines.js
|
|
3118
|
-
var require_engines = __commonJS((exports, module) => {
|
|
3119
|
-
var yaml = require_js_yaml2();
|
|
3120
|
-
var engines = exports = module.exports;
|
|
3121
|
-
engines.yaml = {
|
|
3122
|
-
parse: yaml.safeLoad.bind(yaml),
|
|
3123
|
-
stringify: yaml.safeDump.bind(yaml)
|
|
3124
|
-
};
|
|
3125
|
-
engines.json = {
|
|
3126
|
-
parse: JSON.parse.bind(JSON),
|
|
3127
|
-
stringify: function(obj, options2) {
|
|
3128
|
-
const opts = Object.assign({ replacer: null, space: 2 }, options2);
|
|
3129
|
-
return JSON.stringify(obj, opts.replacer, opts.space);
|
|
3130
|
-
}
|
|
3131
|
-
};
|
|
3132
|
-
engines.javascript = {
|
|
3133
|
-
parse: function parse(str, options, wrap) {
|
|
3134
|
-
try {
|
|
3135
|
-
if (wrap !== false) {
|
|
3136
|
-
str = `(function() {
|
|
3137
|
-
return ` + str.trim() + `;
|
|
3138
|
-
}());`;
|
|
3139
|
-
}
|
|
3140
|
-
return eval(str) || {};
|
|
3141
|
-
} catch (err) {
|
|
3142
|
-
if (wrap !== false && /(unexpected|identifier)/i.test(err.message)) {
|
|
3143
|
-
return parse(str, options, false);
|
|
3144
|
-
}
|
|
3145
|
-
throw new SyntaxError(err);
|
|
3146
|
-
}
|
|
3147
|
-
},
|
|
3148
|
-
stringify: function() {
|
|
3149
|
-
throw new Error("stringifying JavaScript is not supported");
|
|
3150
|
-
}
|
|
3151
|
-
};
|
|
3152
|
-
});
|
|
3153
|
-
|
|
3154
|
-
// node_modules/strip-bom-string/index.js
|
|
3155
|
-
var require_strip_bom_string = __commonJS((exports, module) => {
|
|
3156
|
-
/*!
|
|
3157
|
-
* strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
|
|
3158
|
-
*
|
|
3159
|
-
* Copyright (c) 2015, 2017, Jon Schlinkert.
|
|
3160
|
-
* Released under the MIT License.
|
|
3161
|
-
*/
|
|
3162
|
-
module.exports = function(str2) {
|
|
3163
|
-
if (typeof str2 === "string" && str2.charAt(0) === "\uFEFF") {
|
|
3164
|
-
return str2.slice(1);
|
|
3165
|
-
}
|
|
3166
|
-
return str2;
|
|
3167
|
-
};
|
|
3168
|
-
});
|
|
3169
|
-
|
|
3170
|
-
// node_modules/gray-matter/lib/utils.js
|
|
3171
|
-
var require_utils = __commonJS((exports) => {
|
|
3172
|
-
var stripBom = require_strip_bom_string();
|
|
3173
|
-
var typeOf = require_kind_of();
|
|
3174
|
-
exports.define = function(obj, key, val) {
|
|
3175
|
-
Reflect.defineProperty(obj, key, {
|
|
3176
|
-
enumerable: false,
|
|
3177
|
-
configurable: true,
|
|
3178
|
-
writable: true,
|
|
3179
|
-
value: val
|
|
3180
|
-
});
|
|
3181
|
-
};
|
|
3182
|
-
exports.isBuffer = function(val) {
|
|
3183
|
-
return typeOf(val) === "buffer";
|
|
3184
|
-
};
|
|
3185
|
-
exports.isObject = function(val) {
|
|
3186
|
-
return typeOf(val) === "object";
|
|
3187
|
-
};
|
|
3188
|
-
exports.toBuffer = function(input) {
|
|
3189
|
-
return typeof input === "string" ? Buffer.from(input) : input;
|
|
3190
|
-
};
|
|
3191
|
-
exports.toString = function(input) {
|
|
3192
|
-
if (exports.isBuffer(input))
|
|
3193
|
-
return stripBom(String(input));
|
|
3194
|
-
if (typeof input !== "string") {
|
|
3195
|
-
throw new TypeError("expected input to be a string or buffer");
|
|
3196
|
-
}
|
|
3197
|
-
return stripBom(input);
|
|
3198
|
-
};
|
|
3199
|
-
exports.arrayify = function(val) {
|
|
3200
|
-
return val ? Array.isArray(val) ? val : [val] : [];
|
|
3201
|
-
};
|
|
3202
|
-
exports.startsWith = function(str2, substr, len) {
|
|
3203
|
-
if (typeof len !== "number")
|
|
3204
|
-
len = substr.length;
|
|
3205
|
-
return str2.slice(0, len) === substr;
|
|
3206
|
-
};
|
|
3207
|
-
});
|
|
3208
|
-
|
|
3209
|
-
// node_modules/gray-matter/lib/defaults.js
|
|
3210
|
-
var require_defaults = __commonJS((exports, module) => {
|
|
3211
|
-
var engines = require_engines();
|
|
3212
|
-
var utils = require_utils();
|
|
3213
|
-
module.exports = function(options2) {
|
|
3214
|
-
const opts = Object.assign({}, options2);
|
|
3215
|
-
opts.delimiters = utils.arrayify(opts.delims || opts.delimiters || "---");
|
|
3216
|
-
if (opts.delimiters.length === 1) {
|
|
3217
|
-
opts.delimiters.push(opts.delimiters[0]);
|
|
3218
|
-
}
|
|
3219
|
-
opts.language = (opts.language || opts.lang || "yaml").toLowerCase();
|
|
3220
|
-
opts.engines = Object.assign({}, engines, opts.parsers, opts.engines);
|
|
3221
|
-
return opts;
|
|
3222
|
-
};
|
|
3223
|
-
});
|
|
3224
|
-
|
|
3225
|
-
// node_modules/gray-matter/lib/engine.js
|
|
3226
|
-
var require_engine = __commonJS((exports, module) => {
|
|
3227
|
-
module.exports = function(name, options2) {
|
|
3228
|
-
let engine = options2.engines[name] || options2.engines[aliase(name)];
|
|
3229
|
-
if (typeof engine === "undefined") {
|
|
3230
|
-
throw new Error('gray-matter engine "' + name + '" is not registered');
|
|
3231
|
-
}
|
|
3232
|
-
if (typeof engine === "function") {
|
|
3233
|
-
engine = { parse: engine };
|
|
3234
|
-
}
|
|
3235
|
-
return engine;
|
|
3236
|
-
};
|
|
3237
|
-
function aliase(name) {
|
|
3238
|
-
switch (name.toLowerCase()) {
|
|
3239
|
-
case "js":
|
|
3240
|
-
case "javascript":
|
|
3241
|
-
return "javascript";
|
|
3242
|
-
case "coffee":
|
|
3243
|
-
case "coffeescript":
|
|
3244
|
-
case "cson":
|
|
3245
|
-
return "coffee";
|
|
3246
|
-
case "yaml":
|
|
3247
|
-
case "yml":
|
|
3248
|
-
return "yaml";
|
|
3249
|
-
default: {
|
|
3250
|
-
return name;
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
});
|
|
3255
|
-
|
|
3256
|
-
// node_modules/gray-matter/lib/stringify.js
|
|
3257
|
-
var require_stringify = __commonJS((exports, module) => {
|
|
3258
|
-
var typeOf = require_kind_of();
|
|
3259
|
-
var getEngine = require_engine();
|
|
3260
|
-
var defaults = require_defaults();
|
|
3261
|
-
module.exports = function(file, data, options2) {
|
|
3262
|
-
if (data == null && options2 == null) {
|
|
3263
|
-
switch (typeOf(file)) {
|
|
3264
|
-
case "object":
|
|
3265
|
-
data = file.data;
|
|
3266
|
-
options2 = {};
|
|
3267
|
-
break;
|
|
3268
|
-
case "string":
|
|
3269
|
-
return file;
|
|
3270
|
-
default: {
|
|
3271
|
-
throw new TypeError("expected file to be a string or object");
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
const str2 = file.content;
|
|
3276
|
-
const opts = defaults(options2);
|
|
3277
|
-
if (data == null) {
|
|
3278
|
-
if (!opts.data)
|
|
3279
|
-
return file;
|
|
3280
|
-
data = opts.data;
|
|
3281
|
-
}
|
|
3282
|
-
const language = file.language || opts.language;
|
|
3283
|
-
const engine = getEngine(language, opts);
|
|
3284
|
-
if (typeof engine.stringify !== "function") {
|
|
3285
|
-
throw new TypeError('expected "' + language + '.stringify" to be a function');
|
|
3286
|
-
}
|
|
3287
|
-
data = Object.assign({}, file.data, data);
|
|
3288
|
-
const open = opts.delimiters[0];
|
|
3289
|
-
const close = opts.delimiters[1];
|
|
3290
|
-
const matter = engine.stringify(data, options2).trim();
|
|
3291
|
-
let buf = "";
|
|
3292
|
-
if (matter !== "{}") {
|
|
3293
|
-
buf = newline(open) + newline(matter) + newline(close);
|
|
3294
|
-
}
|
|
3295
|
-
if (typeof file.excerpt === "string" && file.excerpt !== "") {
|
|
3296
|
-
if (str2.indexOf(file.excerpt.trim()) === -1) {
|
|
3297
|
-
buf += newline(file.excerpt) + newline(close);
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
return buf + newline(str2);
|
|
3301
|
-
};
|
|
3302
|
-
function newline(str2) {
|
|
3303
|
-
return str2.slice(-1) !== `
|
|
3304
|
-
` ? str2 + `
|
|
3305
|
-
` : str2;
|
|
3306
|
-
}
|
|
3307
|
-
});
|
|
3308
|
-
|
|
3309
|
-
// node_modules/gray-matter/lib/excerpt.js
|
|
3310
|
-
var require_excerpt = __commonJS((exports, module) => {
|
|
3311
|
-
var defaults = require_defaults();
|
|
3312
|
-
module.exports = function(file, options2) {
|
|
3313
|
-
const opts = defaults(options2);
|
|
3314
|
-
if (file.data == null) {
|
|
3315
|
-
file.data = {};
|
|
3316
|
-
}
|
|
3317
|
-
if (typeof opts.excerpt === "function") {
|
|
3318
|
-
return opts.excerpt(file, opts);
|
|
3319
|
-
}
|
|
3320
|
-
const sep = file.data.excerpt_separator || opts.excerpt_separator;
|
|
3321
|
-
if (sep == null && (opts.excerpt === false || opts.excerpt == null)) {
|
|
3322
|
-
return file;
|
|
3323
|
-
}
|
|
3324
|
-
const delimiter = typeof opts.excerpt === "string" ? opts.excerpt : sep || opts.delimiters[0];
|
|
3325
|
-
const idx = file.content.indexOf(delimiter);
|
|
3326
|
-
if (idx !== -1) {
|
|
3327
|
-
file.excerpt = file.content.slice(0, idx);
|
|
3328
|
-
}
|
|
3329
|
-
return file;
|
|
3330
|
-
};
|
|
3331
|
-
});
|
|
3332
|
-
|
|
3333
|
-
// node_modules/gray-matter/lib/to-file.js
|
|
3334
|
-
var require_to_file = __commonJS((exports, module) => {
|
|
3335
|
-
var typeOf = require_kind_of();
|
|
3336
|
-
var stringify = require_stringify();
|
|
3337
|
-
var utils = require_utils();
|
|
3338
|
-
module.exports = function(file) {
|
|
3339
|
-
if (typeOf(file) !== "object") {
|
|
3340
|
-
file = { content: file };
|
|
3341
|
-
}
|
|
3342
|
-
if (typeOf(file.data) !== "object") {
|
|
3343
|
-
file.data = {};
|
|
3344
|
-
}
|
|
3345
|
-
if (file.contents && file.content == null) {
|
|
3346
|
-
file.content = file.contents;
|
|
3347
|
-
}
|
|
3348
|
-
utils.define(file, "orig", utils.toBuffer(file.content));
|
|
3349
|
-
utils.define(file, "language", file.language || "");
|
|
3350
|
-
utils.define(file, "matter", file.matter || "");
|
|
3351
|
-
utils.define(file, "stringify", function(data, options2) {
|
|
3352
|
-
if (options2 && options2.language) {
|
|
3353
|
-
file.language = options2.language;
|
|
3354
|
-
}
|
|
3355
|
-
return stringify(file, data, options2);
|
|
3356
|
-
});
|
|
3357
|
-
file.content = utils.toString(file.content);
|
|
3358
|
-
file.isEmpty = false;
|
|
3359
|
-
file.excerpt = "";
|
|
3360
|
-
return file;
|
|
3361
|
-
};
|
|
3362
|
-
});
|
|
3363
|
-
|
|
3364
|
-
// node_modules/gray-matter/lib/parse.js
|
|
3365
|
-
var require_parse = __commonJS((exports, module) => {
|
|
3366
|
-
var getEngine = require_engine();
|
|
3367
|
-
var defaults = require_defaults();
|
|
3368
|
-
module.exports = function(language, str2, options2) {
|
|
3369
|
-
const opts = defaults(options2);
|
|
3370
|
-
const engine = getEngine(language, opts);
|
|
3371
|
-
if (typeof engine.parse !== "function") {
|
|
3372
|
-
throw new TypeError('expected "' + language + '.parse" to be a function');
|
|
3373
|
-
}
|
|
3374
|
-
return engine.parse(str2, opts);
|
|
3375
|
-
};
|
|
3376
|
-
});
|
|
3377
|
-
|
|
3378
|
-
// node_modules/gray-matter/index.js
|
|
3379
|
-
var require_gray_matter = __commonJS((exports, module) => {
|
|
3380
|
-
var fs = __require("fs");
|
|
3381
|
-
var sections = require_section_matter();
|
|
3382
|
-
var defaults = require_defaults();
|
|
3383
|
-
var stringify = require_stringify();
|
|
3384
|
-
var excerpt = require_excerpt();
|
|
3385
|
-
var engines = require_engines();
|
|
3386
|
-
var toFile = require_to_file();
|
|
3387
|
-
var parse2 = require_parse();
|
|
3388
|
-
var utils = require_utils();
|
|
3389
|
-
function matter(input, options2) {
|
|
3390
|
-
if (input === "") {
|
|
3391
|
-
return { data: {}, content: input, excerpt: "", orig: input };
|
|
3392
|
-
}
|
|
3393
|
-
let file = toFile(input);
|
|
3394
|
-
const cached = matter.cache[file.content];
|
|
3395
|
-
if (!options2) {
|
|
3396
|
-
if (cached) {
|
|
3397
|
-
file = Object.assign({}, cached);
|
|
3398
|
-
file.orig = cached.orig;
|
|
3399
|
-
return file;
|
|
3400
|
-
}
|
|
3401
|
-
matter.cache[file.content] = file;
|
|
3402
|
-
}
|
|
3403
|
-
return parseMatter(file, options2);
|
|
3404
|
-
}
|
|
3405
|
-
function parseMatter(file, options2) {
|
|
3406
|
-
const opts = defaults(options2);
|
|
3407
|
-
const open = opts.delimiters[0];
|
|
3408
|
-
const close = `
|
|
3409
|
-
` + opts.delimiters[1];
|
|
3410
|
-
let str2 = file.content;
|
|
3411
|
-
if (opts.language) {
|
|
3412
|
-
file.language = opts.language;
|
|
3413
|
-
}
|
|
3414
|
-
const openLen = open.length;
|
|
3415
|
-
if (!utils.startsWith(str2, open, openLen)) {
|
|
3416
|
-
excerpt(file, opts);
|
|
3417
|
-
return file;
|
|
3418
|
-
}
|
|
3419
|
-
if (str2.charAt(openLen) === open.slice(-1)) {
|
|
3420
|
-
return file;
|
|
3421
|
-
}
|
|
3422
|
-
str2 = str2.slice(openLen);
|
|
3423
|
-
const len = str2.length;
|
|
3424
|
-
const language = matter.language(str2, opts);
|
|
3425
|
-
if (language.name) {
|
|
3426
|
-
file.language = language.name;
|
|
3427
|
-
str2 = str2.slice(language.raw.length);
|
|
3428
|
-
}
|
|
3429
|
-
let closeIndex = str2.indexOf(close);
|
|
3430
|
-
if (closeIndex === -1) {
|
|
3431
|
-
closeIndex = len;
|
|
3432
|
-
}
|
|
3433
|
-
file.matter = str2.slice(0, closeIndex);
|
|
3434
|
-
const block = file.matter.replace(/^\s*#[^\n]+/gm, "").trim();
|
|
3435
|
-
if (block === "") {
|
|
3436
|
-
file.isEmpty = true;
|
|
3437
|
-
file.empty = file.content;
|
|
3438
|
-
file.data = {};
|
|
3439
|
-
} else {
|
|
3440
|
-
file.data = parse2(file.language, file.matter, opts);
|
|
3441
|
-
}
|
|
3442
|
-
if (closeIndex === len) {
|
|
3443
|
-
file.content = "";
|
|
3444
|
-
} else {
|
|
3445
|
-
file.content = str2.slice(closeIndex + close.length);
|
|
3446
|
-
if (file.content[0] === "\r") {
|
|
3447
|
-
file.content = file.content.slice(1);
|
|
3448
|
-
}
|
|
3449
|
-
if (file.content[0] === `
|
|
3450
|
-
`) {
|
|
3451
|
-
file.content = file.content.slice(1);
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3454
|
-
excerpt(file, opts);
|
|
3455
|
-
if (opts.sections === true || typeof opts.section === "function") {
|
|
3456
|
-
sections(file, opts.section);
|
|
3457
|
-
}
|
|
3458
|
-
return file;
|
|
3459
|
-
}
|
|
3460
|
-
matter.engines = engines;
|
|
3461
|
-
matter.stringify = function(file, data, options2) {
|
|
3462
|
-
if (typeof file === "string")
|
|
3463
|
-
file = matter(file, options2);
|
|
3464
|
-
return stringify(file, data, options2);
|
|
3465
|
-
};
|
|
3466
|
-
matter.read = function(filepath, options2) {
|
|
3467
|
-
const str2 = fs.readFileSync(filepath, "utf8");
|
|
3468
|
-
const file = matter(str2, options2);
|
|
3469
|
-
file.path = filepath;
|
|
3470
|
-
return file;
|
|
3471
|
-
};
|
|
3472
|
-
matter.test = function(str2, options2) {
|
|
3473
|
-
return utils.startsWith(str2, defaults(options2).delimiters[0]);
|
|
3474
|
-
};
|
|
3475
|
-
matter.language = function(str2, options2) {
|
|
3476
|
-
const opts = defaults(options2);
|
|
3477
|
-
const open = opts.delimiters[0];
|
|
3478
|
-
if (matter.test(str2)) {
|
|
3479
|
-
str2 = str2.slice(open.length);
|
|
3480
|
-
}
|
|
3481
|
-
const language = str2.slice(0, str2.search(/\r?\n/));
|
|
3482
|
-
return {
|
|
3483
|
-
raw: language,
|
|
3484
|
-
name: language ? language.trim() : ""
|
|
3485
|
-
};
|
|
3486
|
-
};
|
|
3487
|
-
matter.cache = {};
|
|
3488
|
-
matter.clearCache = function() {
|
|
3489
|
-
matter.cache = {};
|
|
3490
|
-
};
|
|
3491
|
-
module.exports = matter;
|
|
3492
|
-
});
|
|
3493
|
-
|
|
3494
1
|
// src/multi-modal.ts
|
|
3495
2
|
function copyMultiModalContent(item) {
|
|
3496
3
|
if (item.type === "text") {
|
|
@@ -3516,15 +23,36 @@ function copyContent(content) {
|
|
|
3516
23
|
}
|
|
3517
24
|
// src/schemas.ts
|
|
3518
25
|
import { z } from "zod";
|
|
26
|
+
function toMultiModalContent(value) {
|
|
27
|
+
const result = { type: value.type };
|
|
28
|
+
if (value.text !== undefined)
|
|
29
|
+
result.text = value.text;
|
|
30
|
+
if (value.url !== undefined)
|
|
31
|
+
result.url = value.url;
|
|
32
|
+
if (value.mimeType !== undefined)
|
|
33
|
+
result.mimeType = value.mimeType;
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
var jsonValueSchema = z.lazy(() => z.union([
|
|
37
|
+
z.string(),
|
|
38
|
+
z.number(),
|
|
39
|
+
z.boolean(),
|
|
40
|
+
z.null(),
|
|
41
|
+
z.array(jsonValueSchema),
|
|
42
|
+
z.record(z.string(), jsonValueSchema)
|
|
43
|
+
]));
|
|
3519
44
|
var multiModalContentSchema = z.discriminatedUnion("type", [
|
|
3520
|
-
z.object({
|
|
45
|
+
z.object({
|
|
46
|
+
type: z.literal("text"),
|
|
47
|
+
text: z.string()
|
|
48
|
+
}),
|
|
3521
49
|
z.object({
|
|
3522
50
|
type: z.literal("image"),
|
|
3523
51
|
url: z.string().url(),
|
|
3524
52
|
mimeType: z.string().optional(),
|
|
3525
53
|
text: z.string().optional()
|
|
3526
54
|
})
|
|
3527
|
-
]);
|
|
55
|
+
]).transform(toMultiModalContent);
|
|
3528
56
|
var messageRoleSchema = z.enum([
|
|
3529
57
|
"user",
|
|
3530
58
|
"assistant",
|
|
@@ -3537,12 +65,16 @@ var messageRoleSchema = z.enum([
|
|
|
3537
65
|
var toolCallSchema = z.object({
|
|
3538
66
|
id: z.string(),
|
|
3539
67
|
name: z.string(),
|
|
3540
|
-
arguments:
|
|
68
|
+
arguments: jsonValueSchema
|
|
3541
69
|
});
|
|
3542
70
|
var toolResultSchema = z.object({
|
|
3543
71
|
callId: z.string(),
|
|
3544
72
|
outcome: z.enum(["success", "error"]),
|
|
3545
|
-
content:
|
|
73
|
+
content: jsonValueSchema,
|
|
74
|
+
toolCallId: z.string().optional(),
|
|
75
|
+
toolName: z.string().optional(),
|
|
76
|
+
result: jsonValueSchema.optional(),
|
|
77
|
+
error: z.string().optional()
|
|
3546
78
|
});
|
|
3547
79
|
var tokenUsageSchema = z.object({
|
|
3548
80
|
prompt: z.number().int().min(0),
|
|
@@ -3552,7 +84,7 @@ var tokenUsageSchema = z.object({
|
|
|
3552
84
|
var messageInputSchema = z.object({
|
|
3553
85
|
role: messageRoleSchema,
|
|
3554
86
|
content: z.union([z.string(), z.array(multiModalContentSchema)]),
|
|
3555
|
-
metadata: z.record(z.string(),
|
|
87
|
+
metadata: z.record(z.string(), jsonValueSchema).optional(),
|
|
3556
88
|
hidden: z.boolean().optional(),
|
|
3557
89
|
toolCall: toolCallSchema.optional(),
|
|
3558
90
|
toolResult: toolResultSchema.optional(),
|
|
@@ -3565,25 +97,26 @@ var messageJSONSchema = z.object({
|
|
|
3565
97
|
content: z.union([z.string(), z.array(multiModalContentSchema)]),
|
|
3566
98
|
position: z.number().int().min(0),
|
|
3567
99
|
createdAt: z.string(),
|
|
3568
|
-
metadata: z.record(z.string(),
|
|
100
|
+
metadata: z.record(z.string(), jsonValueSchema),
|
|
3569
101
|
hidden: z.boolean(),
|
|
3570
102
|
toolCall: toolCallSchema.optional(),
|
|
3571
103
|
toolResult: toolResultSchema.optional(),
|
|
3572
104
|
tokenUsage: tokenUsageSchema.optional(),
|
|
3573
105
|
goalCompleted: z.boolean().optional()
|
|
3574
|
-
}).
|
|
106
|
+
}).loose();
|
|
3575
107
|
var conversationStatusSchema = z.enum([
|
|
3576
108
|
"active",
|
|
3577
109
|
"archived",
|
|
3578
110
|
"deleted"
|
|
3579
111
|
]);
|
|
3580
112
|
var conversationShape = {
|
|
113
|
+
schemaVersion: z.number().int().min(1),
|
|
3581
114
|
id: z.string(),
|
|
3582
115
|
title: z.string().optional(),
|
|
3583
116
|
status: conversationStatusSchema,
|
|
3584
|
-
metadata: z.record(z.string(),
|
|
3585
|
-
|
|
3586
|
-
messages: z.
|
|
117
|
+
metadata: z.record(z.string(), jsonValueSchema),
|
|
118
|
+
ids: z.array(z.string()),
|
|
119
|
+
messages: z.record(z.string(), messageJSONSchema),
|
|
3587
120
|
createdAt: z.string(),
|
|
3588
121
|
updatedAt: z.string()
|
|
3589
122
|
};
|
|
@@ -3601,9 +134,6 @@ function normalizeContent(content) {
|
|
|
3601
134
|
return content;
|
|
3602
135
|
return Array.isArray(content) ? content : [content];
|
|
3603
136
|
}
|
|
3604
|
-
// src/utilities/markdown.ts
|
|
3605
|
-
var import_gray_matter = __toESM(require_gray_matter(), 1);
|
|
3606
|
-
|
|
3607
137
|
// src/utilities/type-helpers.ts
|
|
3608
138
|
function toReadonly(value) {
|
|
3609
139
|
return value;
|
|
@@ -3611,7 +141,7 @@ function toReadonly(value) {
|
|
|
3611
141
|
|
|
3612
142
|
// src/utilities/message.ts
|
|
3613
143
|
function createMessage(props) {
|
|
3614
|
-
const content =
|
|
144
|
+
const content = typeof props.content === "string" ? props.content : toReadonly(props.content.map((part) => part));
|
|
3615
145
|
const message = {
|
|
3616
146
|
id: props.id,
|
|
3617
147
|
role: props.role,
|
|
@@ -3622,9 +152,15 @@ function createMessage(props) {
|
|
|
3622
152
|
hidden: props.hidden,
|
|
3623
153
|
toolCall: props.toolCall ? toReadonly({ ...props.toolCall }) : undefined,
|
|
3624
154
|
toolResult: props.toolResult ? toReadonly({ ...props.toolResult }) : undefined,
|
|
3625
|
-
tokenUsage: props.tokenUsage ? toReadonly({ ...props.tokenUsage }) : undefined
|
|
3626
|
-
goalCompleted: props.goalCompleted
|
|
155
|
+
tokenUsage: props.tokenUsage ? toReadonly({ ...props.tokenUsage }) : undefined
|
|
3627
156
|
};
|
|
157
|
+
if (isAssistantMessage(props)) {
|
|
158
|
+
return toReadonly({
|
|
159
|
+
...message,
|
|
160
|
+
role: "assistant",
|
|
161
|
+
goalCompleted: props.goalCompleted
|
|
162
|
+
});
|
|
163
|
+
}
|
|
3628
164
|
return toReadonly(message);
|
|
3629
165
|
}
|
|
3630
166
|
function messageParts(message) {
|
|
@@ -3643,238 +179,21 @@ function messageText(message, joiner = `
|
|
|
3643
179
|
function messageHasImages(message) {
|
|
3644
180
|
return messageParts(message).some((p) => p.type === "image");
|
|
3645
181
|
}
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
var ROLE_DISPLAY_NAMES = {
|
|
3649
|
-
user: "User",
|
|
3650
|
-
assistant: "Assistant",
|
|
3651
|
-
system: "System",
|
|
3652
|
-
developer: "Developer",
|
|
3653
|
-
"tool-use": "Tool Use",
|
|
3654
|
-
"tool-result": "Tool Result",
|
|
3655
|
-
snapshot: "Snapshot"
|
|
3656
|
-
};
|
|
3657
|
-
var DISPLAY_NAME_TO_ROLE = {
|
|
3658
|
-
User: "user",
|
|
3659
|
-
Assistant: "assistant",
|
|
3660
|
-
System: "system",
|
|
3661
|
-
Developer: "developer",
|
|
3662
|
-
"Tool Use": "tool-use",
|
|
3663
|
-
"Tool Result": "tool-result",
|
|
3664
|
-
Snapshot: "snapshot"
|
|
3665
|
-
};
|
|
3666
|
-
function formatMessageContent(message) {
|
|
3667
|
-
if (typeof message.content === "string")
|
|
3668
|
-
return message.content;
|
|
3669
|
-
const parts = messageParts(message);
|
|
3670
|
-
const lines = [];
|
|
3671
|
-
for (const part of parts) {
|
|
3672
|
-
if (part.type === "text" && part.text) {
|
|
3673
|
-
lines.push(part.text);
|
|
3674
|
-
} else if (part.type === "image") {
|
|
3675
|
-
const imageUrl = part.url;
|
|
3676
|
-
const altText = part.text ?? "image";
|
|
3677
|
-
lines.push(``);
|
|
3678
|
-
}
|
|
3679
|
-
}
|
|
3680
|
-
return lines.join(`
|
|
3681
|
-
|
|
3682
|
-
`);
|
|
3683
|
-
}
|
|
3684
|
-
function toMarkdown(conversation, options2 = {}) {
|
|
3685
|
-
const { includeMetadata = false } = options2;
|
|
3686
|
-
if (includeMetadata) {
|
|
3687
|
-
return toMarkdownWithMetadata(conversation);
|
|
3688
|
-
}
|
|
3689
|
-
return toMarkdownSimple(conversation);
|
|
3690
|
-
}
|
|
3691
|
-
function toMarkdownSimple(conversation) {
|
|
3692
|
-
const sections = [];
|
|
3693
|
-
for (const message of conversation.messages) {
|
|
3694
|
-
const roleName = ROLE_DISPLAY_NAMES[message.role];
|
|
3695
|
-
const header = `### ${roleName}`;
|
|
3696
|
-
const content = formatMessageContent(message);
|
|
3697
|
-
sections.push(`${header}
|
|
3698
|
-
|
|
3699
|
-
${content}`);
|
|
3700
|
-
}
|
|
3701
|
-
return sections.join(`
|
|
3702
|
-
|
|
3703
|
-
`);
|
|
3704
|
-
}
|
|
3705
|
-
function toMarkdownWithMetadata(conversation) {
|
|
3706
|
-
const messagesMetadata = {};
|
|
3707
|
-
for (const message of conversation.messages) {
|
|
3708
|
-
const messageMeta = {
|
|
3709
|
-
position: message.position,
|
|
3710
|
-
createdAt: message.createdAt,
|
|
3711
|
-
metadata: { ...message.metadata },
|
|
3712
|
-
hidden: message.hidden
|
|
3713
|
-
};
|
|
3714
|
-
if (Array.isArray(message.content)) {
|
|
3715
|
-
messageMeta.content = copyContent(message.content);
|
|
3716
|
-
}
|
|
3717
|
-
if (message.toolCall) {
|
|
3718
|
-
messageMeta.toolCall = { ...message.toolCall };
|
|
3719
|
-
}
|
|
3720
|
-
if (message.toolResult) {
|
|
3721
|
-
messageMeta.toolResult = { ...message.toolResult };
|
|
3722
|
-
}
|
|
3723
|
-
if (message.tokenUsage) {
|
|
3724
|
-
messageMeta.tokenUsage = { ...message.tokenUsage };
|
|
3725
|
-
}
|
|
3726
|
-
if (message.goalCompleted !== undefined) {
|
|
3727
|
-
messageMeta.goalCompleted = message.goalCompleted;
|
|
3728
|
-
}
|
|
3729
|
-
messagesMetadata[message.id] = messageMeta;
|
|
3730
|
-
}
|
|
3731
|
-
const frontmatterData = {
|
|
3732
|
-
id: conversation.id,
|
|
3733
|
-
status: conversation.status,
|
|
3734
|
-
metadata: { ...conversation.metadata },
|
|
3735
|
-
tags: [...conversation.tags],
|
|
3736
|
-
createdAt: conversation.createdAt,
|
|
3737
|
-
updatedAt: conversation.updatedAt,
|
|
3738
|
-
messages: messagesMetadata
|
|
3739
|
-
};
|
|
3740
|
-
if (conversation.title !== undefined) {
|
|
3741
|
-
frontmatterData.title = conversation.title;
|
|
3742
|
-
}
|
|
3743
|
-
const messageSections = [];
|
|
3744
|
-
for (const message of conversation.messages) {
|
|
3745
|
-
const roleName = ROLE_DISPLAY_NAMES[message.role];
|
|
3746
|
-
const header = `### ${roleName} (${message.id})`;
|
|
3747
|
-
const content = formatMessageContent(message);
|
|
3748
|
-
messageSections.push(`${header}
|
|
3749
|
-
|
|
3750
|
-
${content}`);
|
|
3751
|
-
}
|
|
3752
|
-
const body = messageSections.join(`
|
|
3753
|
-
|
|
3754
|
-
`);
|
|
3755
|
-
return import_gray_matter.default.stringify(body, frontmatterData);
|
|
3756
|
-
}
|
|
3757
|
-
|
|
3758
|
-
class MarkdownParseError extends Error {
|
|
3759
|
-
constructor(message) {
|
|
3760
|
-
super(message);
|
|
3761
|
-
this.name = "MarkdownParseError";
|
|
3762
|
-
}
|
|
3763
|
-
}
|
|
3764
|
-
function generateId() {
|
|
3765
|
-
return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
3766
|
-
}
|
|
3767
|
-
function fromMarkdown(markdown) {
|
|
3768
|
-
const trimmed = markdown.trim();
|
|
3769
|
-
const hasFrontmatter = trimmed.startsWith("---");
|
|
3770
|
-
if (hasFrontmatter) {
|
|
3771
|
-
return parseMarkdownWithMetadata(trimmed);
|
|
3772
|
-
}
|
|
3773
|
-
return parseMarkdownSimple(trimmed);
|
|
3774
|
-
}
|
|
3775
|
-
function parseMarkdownWithMetadata(trimmed) {
|
|
3776
|
-
let parsed;
|
|
3777
|
-
try {
|
|
3778
|
-
parsed = import_gray_matter.default(trimmed);
|
|
3779
|
-
} catch {
|
|
3780
|
-
throw new MarkdownParseError("Invalid frontmatter: failed to parse YAML");
|
|
3781
|
-
}
|
|
3782
|
-
const frontmatter = parsed.data;
|
|
3783
|
-
const body = parsed.content.trim();
|
|
3784
|
-
if (!frontmatter.id) {
|
|
3785
|
-
throw new MarkdownParseError('Invalid frontmatter: missing required field "id"');
|
|
3786
|
-
}
|
|
3787
|
-
const messages = [];
|
|
3788
|
-
const messagePattern = /^### ([\w\s]+) \(([^)]+)\)\n\n([\s\S]*?)(?=\n\n### |\n*$)/gm;
|
|
3789
|
-
let match;
|
|
3790
|
-
while ((match = messagePattern.exec(body)) !== null) {
|
|
3791
|
-
const [, roleDisplay, messageId, contentBody] = match;
|
|
3792
|
-
const role = DISPLAY_NAME_TO_ROLE[roleDisplay];
|
|
3793
|
-
if (!role) {
|
|
3794
|
-
throw new MarkdownParseError(`Unknown role: ${roleDisplay}`);
|
|
3795
|
-
}
|
|
3796
|
-
const messageMeta = frontmatter.messages?.[messageId];
|
|
3797
|
-
if (!messageMeta) {
|
|
3798
|
-
throw new MarkdownParseError(`Missing metadata for message: ${messageId}`);
|
|
3799
|
-
}
|
|
3800
|
-
let content;
|
|
3801
|
-
if (messageMeta.content) {
|
|
3802
|
-
content = toReadonly([...messageMeta.content]);
|
|
3803
|
-
} else {
|
|
3804
|
-
content = contentBody?.trim() ?? "";
|
|
3805
|
-
}
|
|
3806
|
-
const message = {
|
|
3807
|
-
id: messageId,
|
|
3808
|
-
role,
|
|
3809
|
-
content,
|
|
3810
|
-
position: messageMeta.position,
|
|
3811
|
-
createdAt: messageMeta.createdAt,
|
|
3812
|
-
metadata: toReadonly({ ...messageMeta.metadata }),
|
|
3813
|
-
hidden: messageMeta.hidden,
|
|
3814
|
-
toolCall: messageMeta.toolCall ? toReadonly({ ...messageMeta.toolCall }) : undefined,
|
|
3815
|
-
toolResult: messageMeta.toolResult ? toReadonly({ ...messageMeta.toolResult }) : undefined,
|
|
3816
|
-
tokenUsage: messageMeta.tokenUsage ? toReadonly({ ...messageMeta.tokenUsage }) : undefined,
|
|
3817
|
-
goalCompleted: messageMeta.goalCompleted
|
|
3818
|
-
};
|
|
3819
|
-
messages.push(toReadonly(message));
|
|
3820
|
-
}
|
|
3821
|
-
const conversation = {
|
|
3822
|
-
id: frontmatter.id,
|
|
3823
|
-
title: frontmatter.title,
|
|
3824
|
-
status: frontmatter.status ?? "active",
|
|
3825
|
-
metadata: toReadonly({ ...frontmatter.metadata }),
|
|
3826
|
-
tags: toReadonly([...frontmatter.tags ?? []]),
|
|
3827
|
-
messages: toReadonly(messages),
|
|
3828
|
-
createdAt: frontmatter.createdAt,
|
|
3829
|
-
updatedAt: frontmatter.updatedAt
|
|
3830
|
-
};
|
|
3831
|
-
return toReadonly(conversation);
|
|
3832
|
-
}
|
|
3833
|
-
function parseMarkdownSimple(body) {
|
|
3834
|
-
const now = new Date().toISOString();
|
|
3835
|
-
const messages = [];
|
|
3836
|
-
const messagePattern = /^### ([^\n]+)\n\n([\s\S]*?)(?=\n\n### |\n*$)/gm;
|
|
3837
|
-
let match;
|
|
3838
|
-
let position = 0;
|
|
3839
|
-
while ((match = messagePattern.exec(body)) !== null) {
|
|
3840
|
-
const [, roleDisplay, contentBody] = match;
|
|
3841
|
-
const role = DISPLAY_NAME_TO_ROLE[roleDisplay];
|
|
3842
|
-
if (!role) {
|
|
3843
|
-
throw new MarkdownParseError(`Unknown role: ${roleDisplay}`);
|
|
3844
|
-
}
|
|
3845
|
-
const message = {
|
|
3846
|
-
id: generateId(),
|
|
3847
|
-
role,
|
|
3848
|
-
content: contentBody?.trim() ?? "",
|
|
3849
|
-
position,
|
|
3850
|
-
createdAt: now,
|
|
3851
|
-
metadata: toReadonly({}),
|
|
3852
|
-
hidden: false
|
|
3853
|
-
};
|
|
3854
|
-
messages.push(toReadonly(message));
|
|
3855
|
-
position++;
|
|
3856
|
-
}
|
|
3857
|
-
const conversation = {
|
|
3858
|
-
id: generateId(),
|
|
3859
|
-
status: "active",
|
|
3860
|
-
metadata: toReadonly({}),
|
|
3861
|
-
tags: toReadonly([]),
|
|
3862
|
-
messages: toReadonly(messages),
|
|
3863
|
-
createdAt: now,
|
|
3864
|
-
updatedAt: now
|
|
3865
|
-
};
|
|
3866
|
-
return toReadonly(conversation);
|
|
182
|
+
function isAssistantMessage(message) {
|
|
183
|
+
return message.role === "assistant";
|
|
3867
184
|
}
|
|
3868
185
|
// src/utilities/tool-calls.ts
|
|
3869
186
|
function pairToolCallsWithResults(messages) {
|
|
187
|
+
const isMessageArray = (value) => Array.isArray(value);
|
|
188
|
+
const ordered = isMessageArray(messages) ? messages : Object.values(messages).sort((a, b) => a.position - b.position);
|
|
3870
189
|
const pairs = [];
|
|
3871
190
|
const resultsMap = new Map;
|
|
3872
|
-
for (const msg of
|
|
191
|
+
for (const msg of ordered) {
|
|
3873
192
|
if (msg.toolResult) {
|
|
3874
193
|
resultsMap.set(msg.toolResult.callId, msg.toolResult);
|
|
3875
194
|
}
|
|
3876
195
|
}
|
|
3877
|
-
for (const msg of
|
|
196
|
+
for (const msg of ordered) {
|
|
3878
197
|
if (msg.toolCall) {
|
|
3879
198
|
pairs.push({
|
|
3880
199
|
call: msg.toolCall,
|
|
@@ -3884,6 +203,74 @@ function pairToolCallsWithResults(messages) {
|
|
|
3884
203
|
}
|
|
3885
204
|
return pairs;
|
|
3886
205
|
}
|
|
206
|
+
// src/utilities/message-store.ts
|
|
207
|
+
function getOrderedMessages(conversation) {
|
|
208
|
+
const ordered = [];
|
|
209
|
+
for (const id of conversation.ids) {
|
|
210
|
+
const message = conversation.messages[id];
|
|
211
|
+
if (message) {
|
|
212
|
+
ordered.push(message);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return ordered;
|
|
216
|
+
}
|
|
217
|
+
function toIdRecord(items) {
|
|
218
|
+
const record = {};
|
|
219
|
+
for (const item of items) {
|
|
220
|
+
record[item.id] = item;
|
|
221
|
+
}
|
|
222
|
+
return record;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// src/utilities/transient.ts
|
|
226
|
+
function isTransientKey(key) {
|
|
227
|
+
return key.startsWith("_");
|
|
228
|
+
}
|
|
229
|
+
function stripTransientFromRecord(metadata) {
|
|
230
|
+
const result = {};
|
|
231
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
232
|
+
if (!isTransientKey(key)) {
|
|
233
|
+
result[key] = value;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return result;
|
|
237
|
+
}
|
|
238
|
+
function stripTransientMetadata(conversation) {
|
|
239
|
+
const strippedMessages = getOrderedMessages(conversation).map((message) => {
|
|
240
|
+
const baseMessage = {
|
|
241
|
+
id: message.id,
|
|
242
|
+
role: message.role,
|
|
243
|
+
content: message.content,
|
|
244
|
+
position: message.position,
|
|
245
|
+
createdAt: message.createdAt,
|
|
246
|
+
metadata: toReadonly(stripTransientFromRecord({ ...message.metadata })),
|
|
247
|
+
hidden: message.hidden,
|
|
248
|
+
toolCall: message.toolCall,
|
|
249
|
+
toolResult: message.toolResult,
|
|
250
|
+
tokenUsage: message.tokenUsage
|
|
251
|
+
};
|
|
252
|
+
if (isAssistantMessage(message)) {
|
|
253
|
+
const assistantMessage = {
|
|
254
|
+
...baseMessage,
|
|
255
|
+
role: "assistant",
|
|
256
|
+
goalCompleted: message.goalCompleted
|
|
257
|
+
};
|
|
258
|
+
return toReadonly(assistantMessage);
|
|
259
|
+
}
|
|
260
|
+
return toReadonly(baseMessage);
|
|
261
|
+
});
|
|
262
|
+
return toReadonly({
|
|
263
|
+
schemaVersion: conversation.schemaVersion,
|
|
264
|
+
id: conversation.id,
|
|
265
|
+
title: conversation.title,
|
|
266
|
+
status: conversation.status,
|
|
267
|
+
metadata: toReadonly(stripTransientFromRecord({ ...conversation.metadata })),
|
|
268
|
+
ids: strippedMessages.map((message) => message.id),
|
|
269
|
+
messages: toIdRecord(strippedMessages),
|
|
270
|
+
createdAt: conversation.createdAt,
|
|
271
|
+
updatedAt: conversation.updatedAt
|
|
272
|
+
});
|
|
273
|
+
}
|
|
3887
274
|
// src/environment.ts
|
|
3888
275
|
function simpleTokenEstimator(message) {
|
|
3889
276
|
const text = messageText(message);
|
|
@@ -3920,12 +307,12 @@ class ConversationalistError extends Error {
|
|
|
3920
307
|
code;
|
|
3921
308
|
context;
|
|
3922
309
|
cause;
|
|
3923
|
-
constructor(code, message,
|
|
310
|
+
constructor(code, message, options) {
|
|
3924
311
|
super(message);
|
|
3925
312
|
this.name = "ConversationalistError";
|
|
3926
313
|
this.code = code;
|
|
3927
|
-
this.context =
|
|
3928
|
-
this.cause =
|
|
314
|
+
this.context = options?.context;
|
|
315
|
+
this.cause = options?.cause;
|
|
3929
316
|
if (Error.captureStackTrace) {
|
|
3930
317
|
Error.captureStackTrace(this, ConversationalistError);
|
|
3931
318
|
}
|
|
@@ -3969,6 +356,9 @@ function createValidationError(message, context, cause) {
|
|
|
3969
356
|
return new ConversationalistError("error:validation", message, { context, cause });
|
|
3970
357
|
}
|
|
3971
358
|
|
|
359
|
+
// src/types.ts
|
|
360
|
+
var CURRENT_SCHEMA_VERSION = 3;
|
|
361
|
+
|
|
3972
362
|
// src/conversation.ts
|
|
3973
363
|
var buildToolUseIndex = (messages) => messages.reduce((index, message) => {
|
|
3974
364
|
if (message.role === "tool-use" && message.toolCall) {
|
|
@@ -3999,16 +389,17 @@ function partitionAppendArgs(args) {
|
|
|
3999
389
|
}
|
|
4000
390
|
return { inputs: args };
|
|
4001
391
|
}
|
|
4002
|
-
function createConversation(
|
|
392
|
+
function createConversation(options, environment) {
|
|
4003
393
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4004
394
|
const now = resolvedEnvironment.now();
|
|
4005
395
|
const conv = {
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
396
|
+
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
397
|
+
id: options?.id ?? resolvedEnvironment.randomId(),
|
|
398
|
+
title: options?.title,
|
|
399
|
+
status: options?.status ?? "active",
|
|
400
|
+
metadata: { ...options?.metadata ?? {} },
|
|
401
|
+
ids: [],
|
|
402
|
+
messages: {},
|
|
4012
403
|
createdAt: now,
|
|
4013
404
|
updatedAt: now
|
|
4014
405
|
};
|
|
@@ -4018,15 +409,15 @@ function appendMessages(conversation, ...args) {
|
|
|
4018
409
|
const { inputs, environment } = partitionAppendArgs(args);
|
|
4019
410
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4020
411
|
const now = resolvedEnvironment.now();
|
|
4021
|
-
const startPosition = conversation.
|
|
4022
|
-
const initialToolUses = buildToolUseIndex(conversation
|
|
412
|
+
const startPosition = conversation.ids.length;
|
|
413
|
+
const initialToolUses = buildToolUseIndex(getOrderedMessages(conversation));
|
|
4023
414
|
const { messages } = inputs.reduce((state, input, index) => {
|
|
4024
415
|
const processedInput = resolvedEnvironment.plugins.reduce((acc, plugin) => plugin(acc), input);
|
|
4025
416
|
if (processedInput.role === "tool-result" && processedInput.toolResult) {
|
|
4026
417
|
assertToolReference(state.toolUses, processedInput.toolResult.callId);
|
|
4027
418
|
}
|
|
4028
419
|
const normalizedContent = normalizeContent(processedInput.content);
|
|
4029
|
-
const
|
|
420
|
+
const baseMessage = {
|
|
4030
421
|
id: resolvedEnvironment.randomId(),
|
|
4031
422
|
role: processedInput.role,
|
|
4032
423
|
content: normalizedContent,
|
|
@@ -4036,18 +427,30 @@ function appendMessages(conversation, ...args) {
|
|
|
4036
427
|
hidden: processedInput.hidden ?? false,
|
|
4037
428
|
toolCall: processedInput.toolCall,
|
|
4038
429
|
toolResult: processedInput.toolResult,
|
|
4039
|
-
tokenUsage: processedInput.tokenUsage
|
|
4040
|
-
|
|
4041
|
-
|
|
430
|
+
tokenUsage: processedInput.tokenUsage
|
|
431
|
+
};
|
|
432
|
+
let message;
|
|
433
|
+
if (processedInput.role === "assistant") {
|
|
434
|
+
const assistantMessage = {
|
|
435
|
+
...baseMessage,
|
|
436
|
+
role: "assistant",
|
|
437
|
+
goalCompleted: processedInput.goalCompleted
|
|
438
|
+
};
|
|
439
|
+
message = createMessage(assistantMessage);
|
|
440
|
+
} else {
|
|
441
|
+
message = createMessage(baseMessage);
|
|
442
|
+
}
|
|
4042
443
|
const toolUses = processedInput.role === "tool-use" && processedInput.toolCall ? registerToolUse(state.toolUses, processedInput.toolCall) : state.toolUses;
|
|
4043
444
|
return {
|
|
4044
445
|
toolUses,
|
|
4045
446
|
messages: [...state.messages, message]
|
|
4046
447
|
};
|
|
4047
448
|
}, { toolUses: initialToolUses, messages: [] });
|
|
449
|
+
const messageIds = messages.map((message) => message.id);
|
|
4048
450
|
const next = {
|
|
4049
451
|
...conversation,
|
|
4050
|
-
|
|
452
|
+
ids: [...conversation.ids, ...messageIds],
|
|
453
|
+
messages: { ...conversation.messages, ...toIdRecord(messages) },
|
|
4051
454
|
updatedAt: now
|
|
4052
455
|
};
|
|
4053
456
|
return toReadonly(next);
|
|
@@ -4061,21 +464,27 @@ function appendAssistantMessage(conversation, content, metadata, environment) {
|
|
|
4061
464
|
function appendSystemMessage(conversation, content, metadata, environment) {
|
|
4062
465
|
return environment ? appendMessages(conversation, { role: "system", content, metadata }, environment) : appendMessages(conversation, { role: "system", content, metadata });
|
|
4063
466
|
}
|
|
4064
|
-
function
|
|
4065
|
-
const includeHidden =
|
|
4066
|
-
|
|
467
|
+
function getMessages(conversation, options) {
|
|
468
|
+
const includeHidden = options?.includeHidden ?? false;
|
|
469
|
+
const ordered = getOrderedMessages(conversation);
|
|
470
|
+
return includeHidden ? ordered : ordered.filter((m) => !m.hidden);
|
|
4067
471
|
}
|
|
4068
472
|
function getMessageAtPosition(conversation, position) {
|
|
4069
|
-
|
|
473
|
+
const id = conversation.ids[position];
|
|
474
|
+
return id ? conversation.messages[id] : undefined;
|
|
4070
475
|
}
|
|
4071
|
-
function
|
|
4072
|
-
return conversation.
|
|
476
|
+
function getMessageIds(conversation) {
|
|
477
|
+
return [...conversation.ids];
|
|
478
|
+
}
|
|
479
|
+
function getMessageById(conversation, id) {
|
|
480
|
+
return conversation.messages[id];
|
|
4073
481
|
}
|
|
4074
482
|
function searchConversationMessages(conversation, predicate) {
|
|
4075
|
-
return conversation.
|
|
483
|
+
return getOrderedMessages(conversation).filter(predicate);
|
|
4076
484
|
}
|
|
4077
|
-
function
|
|
4078
|
-
const
|
|
485
|
+
function getStatistics(conversation) {
|
|
486
|
+
const ordered = getOrderedMessages(conversation);
|
|
487
|
+
const stats = ordered.reduce((acc, message) => {
|
|
4079
488
|
const byRole = {
|
|
4080
489
|
...acc.byRole,
|
|
4081
490
|
[message.role]: (acc.byRole[message.role] ?? 0) + 1
|
|
@@ -4086,16 +495,16 @@ function computeConversationStatistics(conversation) {
|
|
|
4086
495
|
withImages: acc.withImages + (messageHasImages(message) ? 1 : 0)
|
|
4087
496
|
};
|
|
4088
497
|
}, { byRole: {}, hidden: 0, withImages: 0 });
|
|
4089
|
-
return { total:
|
|
498
|
+
return { total: ordered.length, ...stats };
|
|
4090
499
|
}
|
|
4091
500
|
function hasSystemMessage(conversation) {
|
|
4092
|
-
return conversation.
|
|
501
|
+
return getOrderedMessages(conversation).some((m) => m.role === "system");
|
|
4093
502
|
}
|
|
4094
503
|
function getFirstSystemMessage(conversation) {
|
|
4095
|
-
return conversation.
|
|
504
|
+
return getOrderedMessages(conversation).find((m) => m.role === "system");
|
|
4096
505
|
}
|
|
4097
506
|
function getSystemMessages(conversation) {
|
|
4098
|
-
return conversation.
|
|
507
|
+
return getOrderedMessages(conversation).filter((m) => m.role === "system");
|
|
4099
508
|
}
|
|
4100
509
|
function prependSystemMessage(conversation, content, metadata, environment) {
|
|
4101
510
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
@@ -4112,7 +521,8 @@ function prependSystemMessage(conversation, content, metadata, environment) {
|
|
|
4112
521
|
toolResult: undefined,
|
|
4113
522
|
tokenUsage: undefined
|
|
4114
523
|
});
|
|
4115
|
-
const
|
|
524
|
+
const ordered = getOrderedMessages(conversation);
|
|
525
|
+
const renumberedMessages = ordered.map((message) => createMessage({
|
|
4116
526
|
id: message.id,
|
|
4117
527
|
role: message.role,
|
|
4118
528
|
content: copyContent(message.content),
|
|
@@ -4126,18 +536,20 @@ function prependSystemMessage(conversation, content, metadata, environment) {
|
|
|
4126
536
|
}));
|
|
4127
537
|
return toReadonly({
|
|
4128
538
|
...conversation,
|
|
4129
|
-
|
|
539
|
+
ids: [newMessage.id, ...ordered.map((message) => message.id)],
|
|
540
|
+
messages: toIdRecord([newMessage, ...renumberedMessages]),
|
|
4130
541
|
updatedAt: now
|
|
4131
542
|
});
|
|
4132
543
|
}
|
|
4133
544
|
function replaceSystemMessage(conversation, content, metadata, environment) {
|
|
4134
545
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4135
546
|
const now = resolvedEnvironment.now();
|
|
4136
|
-
const
|
|
547
|
+
const ordered = getOrderedMessages(conversation);
|
|
548
|
+
const firstSystemIndex = ordered.findIndex((m) => m.role === "system");
|
|
4137
549
|
if (firstSystemIndex === -1) {
|
|
4138
550
|
return prependSystemMessage(conversation, content, metadata, resolvedEnvironment);
|
|
4139
551
|
}
|
|
4140
|
-
const original =
|
|
552
|
+
const original = ordered[firstSystemIndex];
|
|
4141
553
|
const replaced = createMessage({
|
|
4142
554
|
id: original.id,
|
|
4143
555
|
role: "system",
|
|
@@ -4150,12 +562,17 @@ function replaceSystemMessage(conversation, content, metadata, environment) {
|
|
|
4150
562
|
toolResult: undefined,
|
|
4151
563
|
tokenUsage: undefined
|
|
4152
564
|
});
|
|
4153
|
-
const
|
|
4154
|
-
|
|
565
|
+
const next = {
|
|
566
|
+
...conversation,
|
|
567
|
+
ids: [...conversation.ids],
|
|
568
|
+
messages: { ...conversation.messages, [replaced.id]: replaced },
|
|
569
|
+
updatedAt: now
|
|
570
|
+
};
|
|
4155
571
|
return toReadonly(next);
|
|
4156
572
|
}
|
|
4157
573
|
function collapseSystemMessages(conversation, environment) {
|
|
4158
|
-
const
|
|
574
|
+
const ordered = getOrderedMessages(conversation);
|
|
575
|
+
const systemMessages = ordered.filter((m) => m.role === "system");
|
|
4159
576
|
if (systemMessages.length <= 1) {
|
|
4160
577
|
return conversation;
|
|
4161
578
|
}
|
|
@@ -4190,7 +607,7 @@ function collapseSystemMessages(conversation, environment) {
|
|
|
4190
607
|
nextIds.add(message.id);
|
|
4191
608
|
return nextIds;
|
|
4192
609
|
}, new Set);
|
|
4193
|
-
const messages =
|
|
610
|
+
const messages = ordered.filter((m) => !systemIdsToRemove.has(m.id)).map((m) => m.id === firstSystemMsg.id ? collapsed : m);
|
|
4194
611
|
const renumbered = messages.map((message, index) => {
|
|
4195
612
|
if (message.position === index)
|
|
4196
613
|
return message;
|
|
@@ -4209,16 +626,21 @@ function collapseSystemMessages(conversation, environment) {
|
|
|
4209
626
|
});
|
|
4210
627
|
const next = {
|
|
4211
628
|
...conversation,
|
|
4212
|
-
|
|
629
|
+
ids: renumbered.map((message) => message.id),
|
|
630
|
+
messages: toIdRecord(renumbered),
|
|
4213
631
|
updatedAt: now
|
|
4214
632
|
};
|
|
4215
633
|
return toReadonly(next);
|
|
4216
634
|
}
|
|
4217
635
|
function redactMessageAtPosition(conversation, position, placeholder = "[REDACTED]", environment) {
|
|
4218
|
-
if (position < 0 || position >= conversation.
|
|
4219
|
-
throw createInvalidPositionError(conversation.
|
|
636
|
+
if (position < 0 || position >= conversation.ids.length) {
|
|
637
|
+
throw createInvalidPositionError(conversation.ids.length - 1, position);
|
|
638
|
+
}
|
|
639
|
+
const id = conversation.ids[position];
|
|
640
|
+
const original = id ? conversation.messages[id] : undefined;
|
|
641
|
+
if (!original) {
|
|
642
|
+
throw createInvalidPositionError(conversation.ids.length - 1, position);
|
|
4220
643
|
}
|
|
4221
|
-
const original = conversation.messages[position];
|
|
4222
644
|
const redacted = createMessage({
|
|
4223
645
|
id: original.id,
|
|
4224
646
|
role: original.role,
|
|
@@ -4233,40 +655,77 @@ function redactMessageAtPosition(conversation, position, placeholder = "[REDACTE
|
|
|
4233
655
|
});
|
|
4234
656
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4235
657
|
const now = resolvedEnvironment.now();
|
|
4236
|
-
const
|
|
4237
|
-
|
|
658
|
+
const next = {
|
|
659
|
+
...conversation,
|
|
660
|
+
ids: [...conversation.ids],
|
|
661
|
+
messages: { ...conversation.messages, [redacted.id]: redacted },
|
|
662
|
+
updatedAt: now
|
|
663
|
+
};
|
|
4238
664
|
return toReadonly(next);
|
|
4239
665
|
}
|
|
4240
|
-
function
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
666
|
+
function migrateConversation(json) {
|
|
667
|
+
if (typeof json !== "object" || json === null || Array.isArray(json)) {
|
|
668
|
+
return {
|
|
669
|
+
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
670
|
+
id: "",
|
|
671
|
+
status: "active",
|
|
672
|
+
metadata: {},
|
|
673
|
+
ids: [],
|
|
674
|
+
messages: {},
|
|
675
|
+
createdAt: new Date().toISOString(),
|
|
676
|
+
updatedAt: new Date().toISOString()
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const data = json;
|
|
680
|
+
const rawMessages = data.messages;
|
|
681
|
+
let messages = {};
|
|
682
|
+
let ids = [];
|
|
683
|
+
const rawIds = data.ids;
|
|
684
|
+
const isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
685
|
+
if (Array.isArray(rawMessages)) {
|
|
686
|
+
const rawMessageArray = rawMessages;
|
|
687
|
+
ids = rawMessageArray.map((message) => message.id);
|
|
688
|
+
messages = Object.fromEntries(rawMessageArray.map((message) => [message.id, message]));
|
|
689
|
+
} else if (rawMessages && typeof rawMessages === "object") {
|
|
690
|
+
messages = { ...rawMessages };
|
|
691
|
+
if (isStringArray(rawIds) && rawIds.length > 0) {
|
|
692
|
+
ids = [...rawIds];
|
|
693
|
+
} else {
|
|
694
|
+
ids = Object.values(messages).sort((a, b) => a.position - b.position).map((message) => message.id);
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
if (ids.length > 0) {
|
|
698
|
+
ids = ids.filter((id) => (id in messages));
|
|
699
|
+
const missing = Object.keys(messages).filter((id) => !ids.includes(id));
|
|
700
|
+
if (missing.length > 0) {
|
|
701
|
+
const sortedMissing = missing.sort((a, b) => (messages[a]?.position ?? 0) - (messages[b]?.position ?? 0));
|
|
702
|
+
ids = [...ids, ...sortedMissing];
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
if (!("schemaVersion" in json)) {
|
|
706
|
+
return {
|
|
707
|
+
...data,
|
|
708
|
+
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
709
|
+
ids,
|
|
710
|
+
messages
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
return { ...data, ids, messages };
|
|
4263
714
|
}
|
|
4264
715
|
function deserializeConversation(json) {
|
|
716
|
+
const migrated = migrateConversation(json);
|
|
4265
717
|
try {
|
|
4266
|
-
|
|
718
|
+
const orderedMessages = migrated.ids.map((id, index) => {
|
|
719
|
+
const message = migrated.messages[id];
|
|
720
|
+
if (!message) {
|
|
721
|
+
throw createSerializationError(`missing message for id ${id}`);
|
|
722
|
+
}
|
|
4267
723
|
if (message.position !== index) {
|
|
4268
724
|
throw createInvalidPositionError(index, message.position);
|
|
4269
725
|
}
|
|
726
|
+
return message;
|
|
727
|
+
});
|
|
728
|
+
orderedMessages.reduce((state, message) => {
|
|
4270
729
|
if (message.role === "tool-use" && message.toolCall) {
|
|
4271
730
|
return {
|
|
4272
731
|
toolUses: registerToolUse(state.toolUses, message.toolCall)
|
|
@@ -4277,16 +736,17 @@ function deserializeConversation(json) {
|
|
|
4277
736
|
}
|
|
4278
737
|
return state;
|
|
4279
738
|
}, { toolUses: new Map });
|
|
4280
|
-
const
|
|
739
|
+
const messageInstances = orderedMessages.map((m) => createMessage(m));
|
|
4281
740
|
const conv = {
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
741
|
+
schemaVersion: migrated.schemaVersion,
|
|
742
|
+
id: migrated.id,
|
|
743
|
+
title: migrated.title,
|
|
744
|
+
status: migrated.status,
|
|
745
|
+
metadata: { ...migrated.metadata },
|
|
746
|
+
ids: orderedMessages.map((message) => message.id),
|
|
747
|
+
messages: toIdRecord(messageInstances),
|
|
748
|
+
createdAt: migrated.createdAt,
|
|
749
|
+
updatedAt: migrated.updatedAt
|
|
4290
750
|
};
|
|
4291
751
|
return toReadonly(conv);
|
|
4292
752
|
} catch (error) {
|
|
@@ -4304,7 +764,7 @@ function toChatMessages(conversation) {
|
|
|
4304
764
|
snapshot: "system"
|
|
4305
765
|
};
|
|
4306
766
|
const result = [];
|
|
4307
|
-
for (const message of conversation
|
|
767
|
+
for (const message of getOrderedMessages(conversation)) {
|
|
4308
768
|
if (message.hidden)
|
|
4309
769
|
continue;
|
|
4310
770
|
const externalRole = roleMap[message.role];
|
|
@@ -4316,6 +776,29 @@ function toChatMessages(conversation) {
|
|
|
4316
776
|
return result;
|
|
4317
777
|
}
|
|
4318
778
|
// src/context.ts
|
|
779
|
+
var cloneMessageWithPosition = (message, position, content) => {
|
|
780
|
+
const baseMessage = {
|
|
781
|
+
id: message.id,
|
|
782
|
+
role: message.role,
|
|
783
|
+
content,
|
|
784
|
+
position,
|
|
785
|
+
createdAt: message.createdAt,
|
|
786
|
+
metadata: { ...message.metadata },
|
|
787
|
+
hidden: message.hidden,
|
|
788
|
+
toolCall: message.toolCall ? { ...message.toolCall } : undefined,
|
|
789
|
+
toolResult: message.toolResult ? { ...message.toolResult } : undefined,
|
|
790
|
+
tokenUsage: message.tokenUsage ? { ...message.tokenUsage } : undefined
|
|
791
|
+
};
|
|
792
|
+
if (isAssistantMessage(message)) {
|
|
793
|
+
const assistantMessage = {
|
|
794
|
+
...baseMessage,
|
|
795
|
+
role: "assistant",
|
|
796
|
+
goalCompleted: message.goalCompleted
|
|
797
|
+
};
|
|
798
|
+
return createMessage(assistantMessage);
|
|
799
|
+
}
|
|
800
|
+
return createMessage(baseMessage);
|
|
801
|
+
};
|
|
4319
802
|
function estimateConversationTokens(conversation, estimateTokens, environment) {
|
|
4320
803
|
let estimator = estimateTokens;
|
|
4321
804
|
let env = environment;
|
|
@@ -4325,13 +808,13 @@ function estimateConversationTokens(conversation, estimateTokens, environment) {
|
|
|
4325
808
|
}
|
|
4326
809
|
const resolvedEnvironment = resolveConversationEnvironment(env);
|
|
4327
810
|
const finalEstimator = typeof estimator === "function" ? estimator : resolvedEnvironment.estimateTokens;
|
|
4328
|
-
return conversation.
|
|
811
|
+
return getOrderedMessages(conversation).reduce((total, message) => total + finalEstimator(message), 0);
|
|
4329
812
|
}
|
|
4330
813
|
function truncateToTokenLimit(conversation, maxTokens, optionsOrEstimator, environment) {
|
|
4331
|
-
let
|
|
814
|
+
let options = {};
|
|
4332
815
|
let env = environment;
|
|
4333
816
|
if (typeof optionsOrEstimator === "function") {
|
|
4334
|
-
|
|
817
|
+
options = { estimateTokens: optionsOrEstimator };
|
|
4335
818
|
} else if (optionsOrEstimator) {
|
|
4336
819
|
if (!environment && isConversationEnvironmentParameter(optionsOrEstimator)) {
|
|
4337
820
|
const candidate = optionsOrEstimator;
|
|
@@ -4339,23 +822,24 @@ function truncateToTokenLimit(conversation, maxTokens, optionsOrEstimator, envir
|
|
|
4339
822
|
if (hasEnvFields) {
|
|
4340
823
|
env = optionsOrEstimator;
|
|
4341
824
|
} else {
|
|
4342
|
-
|
|
825
|
+
options = optionsOrEstimator;
|
|
4343
826
|
}
|
|
4344
827
|
} else {
|
|
4345
|
-
|
|
828
|
+
options = optionsOrEstimator;
|
|
4346
829
|
}
|
|
4347
830
|
}
|
|
4348
831
|
const resolvedEnvironment = resolveConversationEnvironment(env);
|
|
4349
|
-
const estimator =
|
|
4350
|
-
const preserveSystem =
|
|
4351
|
-
const preserveLastN =
|
|
832
|
+
const estimator = options.estimateTokens ?? resolvedEnvironment.estimateTokens;
|
|
833
|
+
const preserveSystem = options.preserveSystemMessages ?? true;
|
|
834
|
+
const preserveLastN = options.preserveLastN ?? 0;
|
|
4352
835
|
const currentTokens = estimateConversationTokens(conversation, estimator, resolvedEnvironment);
|
|
4353
836
|
if (currentTokens <= maxTokens) {
|
|
4354
837
|
return conversation;
|
|
4355
838
|
}
|
|
4356
839
|
const now = resolvedEnvironment.now();
|
|
4357
|
-
const
|
|
4358
|
-
const
|
|
840
|
+
const orderedMessages = getOrderedMessages(conversation);
|
|
841
|
+
const systemMessages = preserveSystem ? orderedMessages.filter((m) => m.role === "system") : [];
|
|
842
|
+
const nonSystemMessages = orderedMessages.filter((m) => m.role !== "system");
|
|
4359
843
|
const protectedMessages = preserveLastN > 0 ? nonSystemMessages.slice(-preserveLastN) : [];
|
|
4360
844
|
const removableMessages = preserveLastN > 0 ? nonSystemMessages.slice(0, -preserveLastN) : nonSystemMessages;
|
|
4361
845
|
const systemTokens = systemMessages.reduce((sum, m) => sum + estimator(m), 0);
|
|
@@ -4363,22 +847,11 @@ function truncateToTokenLimit(conversation, maxTokens, optionsOrEstimator, envir
|
|
|
4363
847
|
const availableTokens = maxTokens - systemTokens - protectedTokens;
|
|
4364
848
|
if (availableTokens <= 0) {
|
|
4365
849
|
const allMessages2 = [...systemMessages, ...protectedMessages];
|
|
4366
|
-
const renumbered2 = allMessages2.map((message, index) =>
|
|
4367
|
-
id: message.id,
|
|
4368
|
-
role: message.role,
|
|
4369
|
-
content: copyContent(message.content),
|
|
4370
|
-
position: index,
|
|
4371
|
-
createdAt: message.createdAt,
|
|
4372
|
-
metadata: { ...message.metadata },
|
|
4373
|
-
hidden: message.hidden,
|
|
4374
|
-
toolCall: message.toolCall ? { ...message.toolCall } : undefined,
|
|
4375
|
-
toolResult: message.toolResult ? { ...message.toolResult } : undefined,
|
|
4376
|
-
tokenUsage: message.tokenUsage ? { ...message.tokenUsage } : undefined,
|
|
4377
|
-
goalCompleted: message.goalCompleted
|
|
4378
|
-
}));
|
|
850
|
+
const renumbered2 = allMessages2.map((message, index) => cloneMessageWithPosition(message, index, copyContent(message.content)));
|
|
4379
851
|
return toReadonly({
|
|
4380
852
|
...conversation,
|
|
4381
|
-
|
|
853
|
+
ids: renumbered2.map((message) => message.id),
|
|
854
|
+
messages: toIdRecord(renumbered2),
|
|
4382
855
|
updatedAt: now
|
|
4383
856
|
});
|
|
4384
857
|
}
|
|
@@ -4396,29 +869,18 @@ function truncateToTokenLimit(conversation, maxTokens, optionsOrEstimator, envir
|
|
|
4396
869
|
}
|
|
4397
870
|
const allMessages = [...systemMessages, ...keptRemovable, ...protectedMessages];
|
|
4398
871
|
allMessages.sort((a, b) => a.position - b.position);
|
|
4399
|
-
const renumbered = allMessages.map((message, index) =>
|
|
4400
|
-
id: message.id,
|
|
4401
|
-
role: message.role,
|
|
4402
|
-
content: copyContent(message.content),
|
|
4403
|
-
position: index,
|
|
4404
|
-
createdAt: message.createdAt,
|
|
4405
|
-
metadata: { ...message.metadata },
|
|
4406
|
-
hidden: message.hidden,
|
|
4407
|
-
toolCall: message.toolCall ? { ...message.toolCall } : undefined,
|
|
4408
|
-
toolResult: message.toolResult ? { ...message.toolResult } : undefined,
|
|
4409
|
-
tokenUsage: message.tokenUsage ? { ...message.tokenUsage } : undefined,
|
|
4410
|
-
goalCompleted: message.goalCompleted
|
|
4411
|
-
}));
|
|
872
|
+
const renumbered = allMessages.map((message, index) => cloneMessageWithPosition(message, index, copyContent(message.content)));
|
|
4412
873
|
return toReadonly({
|
|
4413
874
|
...conversation,
|
|
4414
|
-
|
|
875
|
+
ids: renumbered.map((message) => message.id),
|
|
876
|
+
messages: toIdRecord(renumbered),
|
|
4415
877
|
updatedAt: now
|
|
4416
878
|
});
|
|
4417
879
|
}
|
|
4418
|
-
function getRecentMessages(conversation, count,
|
|
4419
|
-
const includeHidden =
|
|
4420
|
-
const includeSystem =
|
|
4421
|
-
const filtered = conversation.
|
|
880
|
+
function getRecentMessages(conversation, count, options) {
|
|
881
|
+
const includeHidden = options?.includeHidden ?? false;
|
|
882
|
+
const includeSystem = options?.includeSystem ?? false;
|
|
883
|
+
const filtered = getOrderedMessages(conversation).filter((m) => {
|
|
4422
884
|
if (!includeHidden && m.hidden)
|
|
4423
885
|
return false;
|
|
4424
886
|
if (!includeSystem && m.role === "system")
|
|
@@ -4427,40 +889,53 @@ function getRecentMessages(conversation, count, options2) {
|
|
|
4427
889
|
});
|
|
4428
890
|
return filtered.slice(-count);
|
|
4429
891
|
}
|
|
4430
|
-
function truncateFromPosition(conversation, position,
|
|
4431
|
-
const preserveSystem =
|
|
892
|
+
function truncateFromPosition(conversation, position, options, environment) {
|
|
893
|
+
const preserveSystem = options?.preserveSystemMessages ?? true;
|
|
4432
894
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4433
895
|
const now = resolvedEnvironment.now();
|
|
4434
|
-
const
|
|
4435
|
-
const
|
|
896
|
+
const ordered = getOrderedMessages(conversation);
|
|
897
|
+
const systemMessages = preserveSystem ? ordered.filter((m) => m.role === "system" && m.position < position) : [];
|
|
898
|
+
const keptMessages = ordered.filter((m) => m.position >= position);
|
|
4436
899
|
const allMessages = [...systemMessages, ...keptMessages];
|
|
4437
|
-
const renumbered = allMessages.map((message, index) =>
|
|
4438
|
-
id: message.id,
|
|
4439
|
-
role: message.role,
|
|
4440
|
-
content: copyContent(message.content),
|
|
4441
|
-
position: index,
|
|
4442
|
-
createdAt: message.createdAt,
|
|
4443
|
-
metadata: { ...message.metadata },
|
|
4444
|
-
hidden: message.hidden,
|
|
4445
|
-
toolCall: message.toolCall ? { ...message.toolCall } : undefined,
|
|
4446
|
-
toolResult: message.toolResult ? { ...message.toolResult } : undefined,
|
|
4447
|
-
tokenUsage: message.tokenUsage ? { ...message.tokenUsage } : undefined,
|
|
4448
|
-
goalCompleted: message.goalCompleted
|
|
4449
|
-
}));
|
|
900
|
+
const renumbered = allMessages.map((message, index) => cloneMessageWithPosition(message, index, copyContent(message.content)));
|
|
4450
901
|
return toReadonly({
|
|
4451
902
|
...conversation,
|
|
4452
|
-
|
|
903
|
+
ids: renumbered.map((message) => message.id),
|
|
904
|
+
messages: toIdRecord(renumbered),
|
|
4453
905
|
updatedAt: now
|
|
4454
906
|
});
|
|
4455
907
|
}
|
|
4456
908
|
|
|
4457
909
|
// src/streaming.ts
|
|
4458
910
|
var STREAMING_KEY = "__streaming";
|
|
911
|
+
var cloneMessage = (original, overrides = {}) => {
|
|
912
|
+
const baseMessage = {
|
|
913
|
+
id: original.id,
|
|
914
|
+
role: original.role,
|
|
915
|
+
content: overrides.content ?? (typeof original.content === "string" ? original.content : [...original.content]),
|
|
916
|
+
position: overrides.position ?? original.position,
|
|
917
|
+
createdAt: original.createdAt,
|
|
918
|
+
metadata: overrides.metadata ?? { ...original.metadata },
|
|
919
|
+
hidden: original.hidden,
|
|
920
|
+
toolCall: original.toolCall ? { ...original.toolCall } : undefined,
|
|
921
|
+
toolResult: original.toolResult ? { ...original.toolResult } : undefined,
|
|
922
|
+
tokenUsage: overrides.tokenUsage
|
|
923
|
+
};
|
|
924
|
+
if (isAssistantMessage(original)) {
|
|
925
|
+
const assistantMessage = {
|
|
926
|
+
...baseMessage,
|
|
927
|
+
role: "assistant",
|
|
928
|
+
goalCompleted: original.goalCompleted
|
|
929
|
+
};
|
|
930
|
+
return createMessage(assistantMessage);
|
|
931
|
+
}
|
|
932
|
+
return createMessage(baseMessage);
|
|
933
|
+
};
|
|
4459
934
|
function isStreamingMessage(message) {
|
|
4460
935
|
return message.metadata[STREAMING_KEY] === true;
|
|
4461
936
|
}
|
|
4462
937
|
function getStreamingMessage(conversation) {
|
|
4463
|
-
return conversation.
|
|
938
|
+
return getOrderedMessages(conversation).find(isStreamingMessage);
|
|
4464
939
|
}
|
|
4465
940
|
function appendStreamingMessage(conversation, role, metadata, environment) {
|
|
4466
941
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
@@ -4470,7 +945,7 @@ function appendStreamingMessage(conversation, role, metadata, environment) {
|
|
|
4470
945
|
id: messageId,
|
|
4471
946
|
role,
|
|
4472
947
|
content: "",
|
|
4473
|
-
position: conversation.
|
|
948
|
+
position: conversation.ids.length,
|
|
4474
949
|
createdAt: now,
|
|
4475
950
|
metadata: { ...metadata ?? {}, [STREAMING_KEY]: true },
|
|
4476
951
|
hidden: false,
|
|
@@ -4480,7 +955,8 @@ function appendStreamingMessage(conversation, role, metadata, environment) {
|
|
|
4480
955
|
});
|
|
4481
956
|
const updatedConversation = toReadonly({
|
|
4482
957
|
...conversation,
|
|
4483
|
-
|
|
958
|
+
ids: [...conversation.ids, messageId],
|
|
959
|
+
messages: { ...conversation.messages, [messageId]: newMessage },
|
|
4484
960
|
updatedAt: now
|
|
4485
961
|
});
|
|
4486
962
|
return { conversation: updatedConversation, messageId };
|
|
@@ -4488,84 +964,69 @@ function appendStreamingMessage(conversation, role, metadata, environment) {
|
|
|
4488
964
|
function updateStreamingMessage(conversation, messageId, content, environment) {
|
|
4489
965
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4490
966
|
const now = resolvedEnvironment.now();
|
|
4491
|
-
const
|
|
4492
|
-
if (
|
|
967
|
+
const original = conversation.messages[messageId];
|
|
968
|
+
if (!original) {
|
|
4493
969
|
return conversation;
|
|
4494
970
|
}
|
|
4495
|
-
const
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
metadata: { ...original.metadata },
|
|
4503
|
-
hidden: original.hidden,
|
|
4504
|
-
toolCall: original.toolCall ? { ...original.toolCall } : undefined,
|
|
4505
|
-
toolResult: original.toolResult ? { ...original.toolResult } : undefined,
|
|
4506
|
-
tokenUsage: original.tokenUsage ? { ...original.tokenUsage } : undefined,
|
|
4507
|
-
goalCompleted: original.goalCompleted
|
|
4508
|
-
});
|
|
4509
|
-
const messages = conversation.messages.map((m, i) => i === messageIndex ? updated : m);
|
|
971
|
+
const overrides = {
|
|
972
|
+
content: typeof content === "string" ? content : [...content]
|
|
973
|
+
};
|
|
974
|
+
if (original.tokenUsage) {
|
|
975
|
+
overrides.tokenUsage = { ...original.tokenUsage };
|
|
976
|
+
}
|
|
977
|
+
const updated = cloneMessage(original, overrides);
|
|
4510
978
|
return toReadonly({
|
|
4511
979
|
...conversation,
|
|
4512
|
-
|
|
980
|
+
ids: [...conversation.ids],
|
|
981
|
+
messages: { ...conversation.messages, [updated.id]: updated },
|
|
4513
982
|
updatedAt: now
|
|
4514
983
|
});
|
|
4515
984
|
}
|
|
4516
|
-
function finalizeStreamingMessage(conversation, messageId,
|
|
985
|
+
function finalizeStreamingMessage(conversation, messageId, options, environment) {
|
|
4517
986
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4518
987
|
const now = resolvedEnvironment.now();
|
|
4519
|
-
const
|
|
4520
|
-
if (
|
|
988
|
+
const original = conversation.messages[messageId];
|
|
989
|
+
if (!original) {
|
|
4521
990
|
return conversation;
|
|
4522
991
|
}
|
|
4523
|
-
const original = conversation.messages[messageIndex];
|
|
4524
992
|
const { [STREAMING_KEY]: _, ...restMetadata } = original.metadata;
|
|
4525
|
-
const finalMetadata = {
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
tokenUsage: options2?.tokenUsage ? { ...options2.tokenUsage } : undefined,
|
|
4537
|
-
goalCompleted: original.goalCompleted
|
|
4538
|
-
});
|
|
4539
|
-
const messages = conversation.messages.map((m, i) => i === messageIndex ? updated : m);
|
|
993
|
+
const finalMetadata = {
|
|
994
|
+
...restMetadata,
|
|
995
|
+
...options?.metadata ?? {}
|
|
996
|
+
};
|
|
997
|
+
const finalizeOverrides = {
|
|
998
|
+
metadata: finalMetadata
|
|
999
|
+
};
|
|
1000
|
+
if (options?.tokenUsage) {
|
|
1001
|
+
finalizeOverrides.tokenUsage = { ...options.tokenUsage };
|
|
1002
|
+
}
|
|
1003
|
+
const updated = cloneMessage(original, finalizeOverrides);
|
|
4540
1004
|
return toReadonly({
|
|
4541
1005
|
...conversation,
|
|
4542
|
-
|
|
1006
|
+
ids: [...conversation.ids],
|
|
1007
|
+
messages: { ...conversation.messages, [updated.id]: updated },
|
|
4543
1008
|
updatedAt: now
|
|
4544
1009
|
});
|
|
4545
1010
|
}
|
|
4546
1011
|
function cancelStreamingMessage(conversation, messageId, environment) {
|
|
4547
1012
|
const resolvedEnvironment = resolveConversationEnvironment(environment);
|
|
4548
1013
|
const now = resolvedEnvironment.now();
|
|
4549
|
-
|
|
4550
|
-
if (messageIndex === -1) {
|
|
1014
|
+
if (!conversation.messages[messageId]) {
|
|
4551
1015
|
return conversation;
|
|
4552
1016
|
}
|
|
4553
|
-
const messages = conversation.
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
toolResult: message.toolResult ? { ...message.toolResult } : undefined,
|
|
4563
|
-
tokenUsage: message.tokenUsage ? { ...message.tokenUsage } : undefined,
|
|
4564
|
-
goalCompleted: message.goalCompleted
|
|
4565
|
-
}));
|
|
1017
|
+
const messages = getOrderedMessages(conversation).filter((m) => m.id !== messageId).map((message, index) => message.position === index ? message : (() => {
|
|
1018
|
+
const overrides = {
|
|
1019
|
+
position: index
|
|
1020
|
+
};
|
|
1021
|
+
if (message.tokenUsage) {
|
|
1022
|
+
overrides.tokenUsage = { ...message.tokenUsage };
|
|
1023
|
+
}
|
|
1024
|
+
return cloneMessage(message, overrides);
|
|
1025
|
+
})());
|
|
4566
1026
|
return toReadonly({
|
|
4567
1027
|
...conversation,
|
|
4568
|
-
messages,
|
|
1028
|
+
ids: messages.map((message) => message.id),
|
|
1029
|
+
messages: toIdRecord(messages),
|
|
4569
1030
|
updatedAt: now
|
|
4570
1031
|
});
|
|
4571
1032
|
}
|
|
@@ -4618,20 +1079,20 @@ function createDraft(initial) {
|
|
|
4618
1079
|
current = updateStreamingMessage(current, messageId, content);
|
|
4619
1080
|
return draft;
|
|
4620
1081
|
},
|
|
4621
|
-
finalizeStreamingMessage: (messageId,
|
|
4622
|
-
current = finalizeStreamingMessage(current, messageId,
|
|
1082
|
+
finalizeStreamingMessage: (messageId, options) => {
|
|
1083
|
+
current = finalizeStreamingMessage(current, messageId, options);
|
|
4623
1084
|
return draft;
|
|
4624
1085
|
},
|
|
4625
1086
|
cancelStreamingMessage: (messageId) => {
|
|
4626
1087
|
current = cancelStreamingMessage(current, messageId);
|
|
4627
1088
|
return draft;
|
|
4628
1089
|
},
|
|
4629
|
-
truncateFromPosition: (position,
|
|
4630
|
-
current = truncateFromPosition(current, position,
|
|
1090
|
+
truncateFromPosition: (position, options) => {
|
|
1091
|
+
current = truncateFromPosition(current, position, options);
|
|
4631
1092
|
return draft;
|
|
4632
1093
|
},
|
|
4633
|
-
truncateToTokenLimit: (maxTokens,
|
|
4634
|
-
current = truncateToTokenLimit(current, maxTokens,
|
|
1094
|
+
truncateToTokenLimit: (maxTokens, options) => {
|
|
1095
|
+
current = truncateToTokenLimit(current, maxTokens, options);
|
|
4635
1096
|
return draft;
|
|
4636
1097
|
}
|
|
4637
1098
|
};
|
|
@@ -4675,11 +1136,11 @@ class ConversationHistory extends EventTarget {
|
|
|
4675
1136
|
this.dispatchEvent(new ConversationHistoryEvent("change", detail));
|
|
4676
1137
|
this.dispatchEvent(new ConversationHistoryEvent(type, detail));
|
|
4677
1138
|
}
|
|
4678
|
-
addEventListener(type, callback,
|
|
1139
|
+
addEventListener(type, callback, options) {
|
|
4679
1140
|
if (!callback)
|
|
4680
1141
|
return;
|
|
4681
|
-
super.addEventListener(type, callback,
|
|
4682
|
-
const unsubscribe = () => this.removeEventListener(type, callback,
|
|
1142
|
+
super.addEventListener(type, callback, options);
|
|
1143
|
+
const unsubscribe = () => this.removeEventListener(type, callback, options);
|
|
4683
1144
|
return unsubscribe;
|
|
4684
1145
|
}
|
|
4685
1146
|
subscribe(run) {
|
|
@@ -4698,6 +1159,9 @@ class ConversationHistory extends EventTarget {
|
|
|
4698
1159
|
get current() {
|
|
4699
1160
|
return this.currentNode.conversation;
|
|
4700
1161
|
}
|
|
1162
|
+
get ids() {
|
|
1163
|
+
return getMessageIds(this.current);
|
|
1164
|
+
}
|
|
4701
1165
|
get canUndo() {
|
|
4702
1166
|
return this.currentNode.parent !== null;
|
|
4703
1167
|
}
|
|
@@ -4765,20 +1229,26 @@ class ConversationHistory extends EventTarget {
|
|
|
4765
1229
|
}
|
|
4766
1230
|
return path;
|
|
4767
1231
|
}
|
|
4768
|
-
getMessages(
|
|
4769
|
-
return
|
|
1232
|
+
getMessages(options) {
|
|
1233
|
+
return getMessages(this.current, options);
|
|
4770
1234
|
}
|
|
4771
1235
|
getMessageAtPosition(position) {
|
|
4772
1236
|
return getMessageAtPosition(this.current, position);
|
|
4773
1237
|
}
|
|
4774
|
-
|
|
4775
|
-
return
|
|
1238
|
+
getMessageIds() {
|
|
1239
|
+
return getMessageIds(this.current);
|
|
1240
|
+
}
|
|
1241
|
+
getMessageById(id) {
|
|
1242
|
+
return getMessageById(this.current, id);
|
|
1243
|
+
}
|
|
1244
|
+
get(id) {
|
|
1245
|
+
return getMessageById(this.current, id);
|
|
4776
1246
|
}
|
|
4777
1247
|
searchMessages(predicate) {
|
|
4778
1248
|
return searchConversationMessages(this.current, predicate);
|
|
4779
1249
|
}
|
|
4780
1250
|
getStatistics() {
|
|
4781
|
-
return
|
|
1251
|
+
return getStatistics(this.current);
|
|
4782
1252
|
}
|
|
4783
1253
|
hasSystemMessage() {
|
|
4784
1254
|
return hasSystemMessage(this.current);
|
|
@@ -4789,20 +1259,14 @@ class ConversationHistory extends EventTarget {
|
|
|
4789
1259
|
getSystemMessages() {
|
|
4790
1260
|
return getSystemMessages(this.current);
|
|
4791
1261
|
}
|
|
4792
|
-
serialize() {
|
|
4793
|
-
return serializeConversation(this.current);
|
|
4794
|
-
}
|
|
4795
1262
|
toChatMessages() {
|
|
4796
1263
|
return toChatMessages(this.current);
|
|
4797
1264
|
}
|
|
4798
|
-
toMarkdown(options2) {
|
|
4799
|
-
return toMarkdown(this.current, options2);
|
|
4800
|
-
}
|
|
4801
1265
|
estimateTokens(estimator) {
|
|
4802
1266
|
return estimateConversationTokens(this.current, estimator, this.env);
|
|
4803
1267
|
}
|
|
4804
|
-
getRecentMessages(count,
|
|
4805
|
-
return getRecentMessages(this.current, count,
|
|
1268
|
+
getRecentMessages(count, options) {
|
|
1269
|
+
return getRecentMessages(this.current, count, options);
|
|
4806
1270
|
}
|
|
4807
1271
|
getStreamingMessage() {
|
|
4808
1272
|
return getStreamingMessage(this.current);
|
|
@@ -4831,11 +1295,11 @@ class ConversationHistory extends EventTarget {
|
|
|
4831
1295
|
redactMessageAtPosition(position, placeholder) {
|
|
4832
1296
|
this.push(redactMessageAtPosition(this.current, position, placeholder, this.env));
|
|
4833
1297
|
}
|
|
4834
|
-
truncateFromPosition(position,
|
|
4835
|
-
this.push(truncateFromPosition(this.current, position,
|
|
1298
|
+
truncateFromPosition(position, options) {
|
|
1299
|
+
this.push(truncateFromPosition(this.current, position, options, this.env));
|
|
4836
1300
|
}
|
|
4837
|
-
truncateToTokenLimit(maxTokens,
|
|
4838
|
-
this.push(truncateToTokenLimit(this.current, maxTokens,
|
|
1301
|
+
truncateToTokenLimit(maxTokens, options) {
|
|
1302
|
+
this.push(truncateToTokenLimit(this.current, maxTokens, options, this.env));
|
|
4839
1303
|
}
|
|
4840
1304
|
appendStreamingMessage(role, metadata) {
|
|
4841
1305
|
const { conversation, messageId } = appendStreamingMessage(this.current, role, metadata, this.env);
|
|
@@ -4845,13 +1309,13 @@ class ConversationHistory extends EventTarget {
|
|
|
4845
1309
|
updateStreamingMessage(messageId, content) {
|
|
4846
1310
|
this.push(updateStreamingMessage(this.current, messageId, content, this.env));
|
|
4847
1311
|
}
|
|
4848
|
-
finalizeStreamingMessage(messageId,
|
|
4849
|
-
this.push(finalizeStreamingMessage(this.current, messageId,
|
|
1312
|
+
finalizeStreamingMessage(messageId, options) {
|
|
1313
|
+
this.push(finalizeStreamingMessage(this.current, messageId, options, this.env));
|
|
4850
1314
|
}
|
|
4851
1315
|
cancelStreamingMessage(messageId) {
|
|
4852
1316
|
this.push(cancelStreamingMessage(this.current, messageId, this.env));
|
|
4853
1317
|
}
|
|
4854
|
-
|
|
1318
|
+
snapshot() {
|
|
4855
1319
|
const getPath = (node) => {
|
|
4856
1320
|
const path = [];
|
|
4857
1321
|
let curr = node;
|
|
@@ -4862,7 +1326,7 @@ class ConversationHistory extends EventTarget {
|
|
|
4862
1326
|
return path;
|
|
4863
1327
|
};
|
|
4864
1328
|
const serializeNode = (node) => ({
|
|
4865
|
-
conversation:
|
|
1329
|
+
conversation: node.conversation,
|
|
4866
1330
|
children: node.children.map(serializeNode)
|
|
4867
1331
|
});
|
|
4868
1332
|
let root = this.currentNode;
|
|
@@ -4900,12 +1364,15 @@ class ConversationHistory extends EventTarget {
|
|
|
4900
1364
|
h.currentNode = current;
|
|
4901
1365
|
return history;
|
|
4902
1366
|
}
|
|
4903
|
-
static fromMarkdown(markdown, environment) {
|
|
4904
|
-
const conversation = fromMarkdown(markdown);
|
|
4905
|
-
return new ConversationHistory(conversation, environment);
|
|
4906
|
-
}
|
|
4907
1367
|
bind(fn) {
|
|
4908
|
-
return
|
|
1368
|
+
return (...args) => {
|
|
1369
|
+
const boundFn = fn;
|
|
1370
|
+
const result = boundFn(this.current, ...args, this.env);
|
|
1371
|
+
if (isConversation(result)) {
|
|
1372
|
+
this.push(result);
|
|
1373
|
+
}
|
|
1374
|
+
return result;
|
|
1375
|
+
};
|
|
4909
1376
|
}
|
|
4910
1377
|
[Symbol.dispose]() {
|
|
4911
1378
|
let root = this.currentNode;
|
|
@@ -4925,18 +1392,8 @@ class ConversationHistory extends EventTarget {
|
|
|
4925
1392
|
clearNode(root);
|
|
4926
1393
|
}
|
|
4927
1394
|
}
|
|
4928
|
-
function bindToConversationHistory(history, fn) {
|
|
4929
|
-
return (...args) => {
|
|
4930
|
-
const boundFn = fn;
|
|
4931
|
-
const result = boundFn(history.current, ...args, history.env);
|
|
4932
|
-
if (isConversation(result)) {
|
|
4933
|
-
history.push(result);
|
|
4934
|
-
}
|
|
4935
|
-
return result;
|
|
4936
|
-
};
|
|
4937
|
-
}
|
|
4938
1395
|
function isConversation(value) {
|
|
4939
|
-
return value !== null && typeof value === "object" && typeof value.id === "string" && typeof value.status === "string" && value.metadata !== null && typeof value.metadata === "object" && Array.isArray(value.
|
|
1396
|
+
return value !== null && typeof value === "object" && typeof value.schemaVersion === "number" && typeof value.id === "string" && typeof value.status === "string" && value.metadata !== null && typeof value.metadata === "object" && Array.isArray(value.ids) && typeof value.messages === "object" && value.messages !== null && !Array.isArray(value.messages) && typeof value.createdAt === "string" && typeof value.updatedAt === "string";
|
|
4940
1397
|
}
|
|
4941
1398
|
export {
|
|
4942
1399
|
withEnvironment,
|
|
@@ -4948,10 +1405,10 @@ export {
|
|
|
4948
1405
|
toolCallSchema,
|
|
4949
1406
|
tokenUsageSchema,
|
|
4950
1407
|
toMultiModalArray,
|
|
4951
|
-
toMarkdown,
|
|
4952
1408
|
toChatMessages,
|
|
1409
|
+
stripTransientMetadata,
|
|
1410
|
+
stripTransientFromRecord,
|
|
4953
1411
|
simpleTokenEstimator,
|
|
4954
|
-
serializeConversation,
|
|
4955
1412
|
searchConversationMessages,
|
|
4956
1413
|
replaceSystemMessage,
|
|
4957
1414
|
redactMessageAtPosition,
|
|
@@ -4963,16 +1420,20 @@ export {
|
|
|
4963
1420
|
messageRoleSchema,
|
|
4964
1421
|
messageJSONSchema,
|
|
4965
1422
|
messageInputSchema,
|
|
1423
|
+
jsonValueSchema,
|
|
1424
|
+
isTransientKey,
|
|
4966
1425
|
isStreamingMessage,
|
|
1426
|
+
isAssistantMessage,
|
|
4967
1427
|
hasSystemMessage,
|
|
4968
1428
|
getSystemMessages,
|
|
4969
1429
|
getStreamingMessage,
|
|
1430
|
+
getStatistics,
|
|
4970
1431
|
getRecentMessages,
|
|
4971
|
-
|
|
1432
|
+
getMessages,
|
|
1433
|
+
getMessageIds,
|
|
1434
|
+
getMessageById,
|
|
4972
1435
|
getMessageAtPosition,
|
|
4973
1436
|
getFirstSystemMessage,
|
|
4974
|
-
getConversationMessages,
|
|
4975
|
-
fromMarkdown,
|
|
4976
1437
|
finalizeStreamingMessage,
|
|
4977
1438
|
estimateConversationTokens,
|
|
4978
1439
|
deserializeConversation,
|
|
@@ -4990,18 +1451,15 @@ export {
|
|
|
4990
1451
|
copyContent,
|
|
4991
1452
|
conversationShape,
|
|
4992
1453
|
conversationSchema,
|
|
4993
|
-
computeConversationStatistics,
|
|
4994
1454
|
collapseSystemMessages,
|
|
4995
1455
|
cancelStreamingMessage,
|
|
4996
|
-
bindToConversationHistory,
|
|
4997
1456
|
appendUserMessage,
|
|
4998
1457
|
appendSystemMessage,
|
|
4999
1458
|
appendStreamingMessage,
|
|
5000
1459
|
appendMessages,
|
|
5001
1460
|
appendAssistantMessage,
|
|
5002
|
-
MarkdownParseError,
|
|
5003
1461
|
ConversationalistError,
|
|
5004
1462
|
ConversationHistory
|
|
5005
1463
|
};
|
|
5006
1464
|
|
|
5007
|
-
//# debugId=
|
|
1465
|
+
//# debugId=77EDEC984ED3373C64756E2164756E21
|