@xyd-js/plugin-docs 0.1.0-xyd.2 → 0.1.0-xyd.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/TODO.md +1 -0
- package/package.json +7 -17
- package/src/const.ts +7 -0
- package/src/declarations.d.ts +23 -0
- package/src/index.ts +305 -0
- package/src/pages/context.tsx +9 -0
- package/src/pages/layout.tsx +263 -0
- package/src/pages/metatags.ts +96 -0
- package/src/pages/page.tsx +363 -0
- package/src/presets/docs/index.ts +232 -0
- package/src/presets/docs/settings.ts +75 -0
- package/src/presets/graphql/index.ts +69 -0
- package/src/presets/openapi/index.ts +66 -0
- package/src/presets/sources/index.ts +74 -0
- package/src/presets/uniform/index.ts +751 -0
- package/src/types.ts +38 -0
- package/src/utils.ts +19 -0
- package/tsconfig.json +51 -0
- package/tsup.config.ts +74 -0
- package/dist/index.d.ts +0 -42
- package/dist/index.js +0 -4307
- package/dist/index.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,4307 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
|
|
33
|
-
// ../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js
|
|
34
|
-
var require_kind_of = __commonJS({
|
|
35
|
-
"../../node_modules/.pnpm/kind-of@6.0.3/node_modules/kind-of/index.js"(exports2, module2) {
|
|
36
|
-
var toString = Object.prototype.toString;
|
|
37
|
-
module2.exports = function kindOf(val) {
|
|
38
|
-
if (val === void 0) return "undefined";
|
|
39
|
-
if (val === null) return "null";
|
|
40
|
-
var type = typeof val;
|
|
41
|
-
if (type === "boolean") return "boolean";
|
|
42
|
-
if (type === "string") return "string";
|
|
43
|
-
if (type === "number") return "number";
|
|
44
|
-
if (type === "symbol") return "symbol";
|
|
45
|
-
if (type === "function") {
|
|
46
|
-
return isGeneratorFn(val) ? "generatorfunction" : "function";
|
|
47
|
-
}
|
|
48
|
-
if (isArray(val)) return "array";
|
|
49
|
-
if (isBuffer(val)) return "buffer";
|
|
50
|
-
if (isArguments(val)) return "arguments";
|
|
51
|
-
if (isDate(val)) return "date";
|
|
52
|
-
if (isError(val)) return "error";
|
|
53
|
-
if (isRegexp(val)) return "regexp";
|
|
54
|
-
switch (ctorName(val)) {
|
|
55
|
-
case "Symbol":
|
|
56
|
-
return "symbol";
|
|
57
|
-
case "Promise":
|
|
58
|
-
return "promise";
|
|
59
|
-
// Set, Map, WeakSet, WeakMap
|
|
60
|
-
case "WeakMap":
|
|
61
|
-
return "weakmap";
|
|
62
|
-
case "WeakSet":
|
|
63
|
-
return "weakset";
|
|
64
|
-
case "Map":
|
|
65
|
-
return "map";
|
|
66
|
-
case "Set":
|
|
67
|
-
return "set";
|
|
68
|
-
// 8-bit typed arrays
|
|
69
|
-
case "Int8Array":
|
|
70
|
-
return "int8array";
|
|
71
|
-
case "Uint8Array":
|
|
72
|
-
return "uint8array";
|
|
73
|
-
case "Uint8ClampedArray":
|
|
74
|
-
return "uint8clampedarray";
|
|
75
|
-
// 16-bit typed arrays
|
|
76
|
-
case "Int16Array":
|
|
77
|
-
return "int16array";
|
|
78
|
-
case "Uint16Array":
|
|
79
|
-
return "uint16array";
|
|
80
|
-
// 32-bit typed arrays
|
|
81
|
-
case "Int32Array":
|
|
82
|
-
return "int32array";
|
|
83
|
-
case "Uint32Array":
|
|
84
|
-
return "uint32array";
|
|
85
|
-
case "Float32Array":
|
|
86
|
-
return "float32array";
|
|
87
|
-
case "Float64Array":
|
|
88
|
-
return "float64array";
|
|
89
|
-
}
|
|
90
|
-
if (isGeneratorObj(val)) {
|
|
91
|
-
return "generator";
|
|
92
|
-
}
|
|
93
|
-
type = toString.call(val);
|
|
94
|
-
switch (type) {
|
|
95
|
-
case "[object Object]":
|
|
96
|
-
return "object";
|
|
97
|
-
// iterators
|
|
98
|
-
case "[object Map Iterator]":
|
|
99
|
-
return "mapiterator";
|
|
100
|
-
case "[object Set Iterator]":
|
|
101
|
-
return "setiterator";
|
|
102
|
-
case "[object String Iterator]":
|
|
103
|
-
return "stringiterator";
|
|
104
|
-
case "[object Array Iterator]":
|
|
105
|
-
return "arrayiterator";
|
|
106
|
-
}
|
|
107
|
-
return type.slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
108
|
-
};
|
|
109
|
-
function ctorName(val) {
|
|
110
|
-
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
111
|
-
}
|
|
112
|
-
function isArray(val) {
|
|
113
|
-
if (Array.isArray) return Array.isArray(val);
|
|
114
|
-
return val instanceof Array;
|
|
115
|
-
}
|
|
116
|
-
function isError(val) {
|
|
117
|
-
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
118
|
-
}
|
|
119
|
-
function isDate(val) {
|
|
120
|
-
if (val instanceof Date) return true;
|
|
121
|
-
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
122
|
-
}
|
|
123
|
-
function isRegexp(val) {
|
|
124
|
-
if (val instanceof RegExp) return true;
|
|
125
|
-
return typeof val.flags === "string" && typeof val.ignoreCase === "boolean" && typeof val.multiline === "boolean" && typeof val.global === "boolean";
|
|
126
|
-
}
|
|
127
|
-
function isGeneratorFn(name, val) {
|
|
128
|
-
return ctorName(name) === "GeneratorFunction";
|
|
129
|
-
}
|
|
130
|
-
function isGeneratorObj(val) {
|
|
131
|
-
return typeof val.throw === "function" && typeof val.return === "function" && typeof val.next === "function";
|
|
132
|
-
}
|
|
133
|
-
function isArguments(val) {
|
|
134
|
-
try {
|
|
135
|
-
if (typeof val.length === "number" && typeof val.callee === "function") {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
} catch (err) {
|
|
139
|
-
if (err.message.indexOf("callee") !== -1) {
|
|
140
|
-
return true;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
function isBuffer(val) {
|
|
146
|
-
if (val.constructor && typeof val.constructor.isBuffer === "function") {
|
|
147
|
-
return val.constructor.isBuffer(val);
|
|
148
|
-
}
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// ../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engine.js
|
|
155
|
-
var require_engine = __commonJS({
|
|
156
|
-
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engine.js"(exports2, module2) {
|
|
157
|
-
"use strict";
|
|
158
|
-
module2.exports = function(name, options2) {
|
|
159
|
-
let engine = options2.engines[name] || options2.engines[aliase(name)];
|
|
160
|
-
if (typeof engine === "undefined") {
|
|
161
|
-
throw new Error('gray-matter engine "' + name + '" is not registered');
|
|
162
|
-
}
|
|
163
|
-
if (typeof engine === "function") {
|
|
164
|
-
engine = { parse: engine };
|
|
165
|
-
}
|
|
166
|
-
return engine;
|
|
167
|
-
};
|
|
168
|
-
function aliase(name) {
|
|
169
|
-
switch (name.toLowerCase()) {
|
|
170
|
-
case "js":
|
|
171
|
-
case "javascript":
|
|
172
|
-
return "javascript";
|
|
173
|
-
case "coffee":
|
|
174
|
-
case "coffeescript":
|
|
175
|
-
case "cson":
|
|
176
|
-
return "coffee";
|
|
177
|
-
case "yaml":
|
|
178
|
-
case "yml":
|
|
179
|
-
return "yaml";
|
|
180
|
-
default: {
|
|
181
|
-
return name;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/common.js
|
|
189
|
-
var require_common = __commonJS({
|
|
190
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/common.js"(exports2, module2) {
|
|
191
|
-
"use strict";
|
|
192
|
-
function isNothing(subject) {
|
|
193
|
-
return typeof subject === "undefined" || subject === null;
|
|
194
|
-
}
|
|
195
|
-
function isObject(subject) {
|
|
196
|
-
return typeof subject === "object" && subject !== null;
|
|
197
|
-
}
|
|
198
|
-
function toArray(sequence) {
|
|
199
|
-
if (Array.isArray(sequence)) return sequence;
|
|
200
|
-
else if (isNothing(sequence)) return [];
|
|
201
|
-
return [sequence];
|
|
202
|
-
}
|
|
203
|
-
function extend(target, source) {
|
|
204
|
-
var index, length, key, sourceKeys;
|
|
205
|
-
if (source) {
|
|
206
|
-
sourceKeys = Object.keys(source);
|
|
207
|
-
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
208
|
-
key = sourceKeys[index];
|
|
209
|
-
target[key] = source[key];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
return target;
|
|
213
|
-
}
|
|
214
|
-
function repeat(string, count) {
|
|
215
|
-
var result = "", cycle;
|
|
216
|
-
for (cycle = 0; cycle < count; cycle += 1) {
|
|
217
|
-
result += string;
|
|
218
|
-
}
|
|
219
|
-
return result;
|
|
220
|
-
}
|
|
221
|
-
function isNegativeZero(number) {
|
|
222
|
-
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
223
|
-
}
|
|
224
|
-
module2.exports.isNothing = isNothing;
|
|
225
|
-
module2.exports.isObject = isObject;
|
|
226
|
-
module2.exports.toArray = toArray;
|
|
227
|
-
module2.exports.repeat = repeat;
|
|
228
|
-
module2.exports.isNegativeZero = isNegativeZero;
|
|
229
|
-
module2.exports.extend = extend;
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/exception.js
|
|
234
|
-
var require_exception = __commonJS({
|
|
235
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/exception.js"(exports2, module2) {
|
|
236
|
-
"use strict";
|
|
237
|
-
function YAMLException(reason, mark) {
|
|
238
|
-
Error.call(this);
|
|
239
|
-
this.name = "YAMLException";
|
|
240
|
-
this.reason = reason;
|
|
241
|
-
this.mark = mark;
|
|
242
|
-
this.message = (this.reason || "(unknown reason)") + (this.mark ? " " + this.mark.toString() : "");
|
|
243
|
-
if (Error.captureStackTrace) {
|
|
244
|
-
Error.captureStackTrace(this, this.constructor);
|
|
245
|
-
} else {
|
|
246
|
-
this.stack = new Error().stack || "";
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
YAMLException.prototype = Object.create(Error.prototype);
|
|
250
|
-
YAMLException.prototype.constructor = YAMLException;
|
|
251
|
-
YAMLException.prototype.toString = function toString(compact) {
|
|
252
|
-
var result = this.name + ": ";
|
|
253
|
-
result += this.reason || "(unknown reason)";
|
|
254
|
-
if (!compact && this.mark) {
|
|
255
|
-
result += " " + this.mark.toString();
|
|
256
|
-
}
|
|
257
|
-
return result;
|
|
258
|
-
};
|
|
259
|
-
module2.exports = YAMLException;
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/mark.js
|
|
264
|
-
var require_mark = __commonJS({
|
|
265
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/mark.js"(exports2, module2) {
|
|
266
|
-
"use strict";
|
|
267
|
-
var common = require_common();
|
|
268
|
-
function Mark(name, buffer, position, line, column) {
|
|
269
|
-
this.name = name;
|
|
270
|
-
this.buffer = buffer;
|
|
271
|
-
this.position = position;
|
|
272
|
-
this.line = line;
|
|
273
|
-
this.column = column;
|
|
274
|
-
}
|
|
275
|
-
Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
|
|
276
|
-
var head, start, tail, end, snippet;
|
|
277
|
-
if (!this.buffer) return null;
|
|
278
|
-
indent = indent || 4;
|
|
279
|
-
maxLength = maxLength || 75;
|
|
280
|
-
head = "";
|
|
281
|
-
start = this.position;
|
|
282
|
-
while (start > 0 && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(start - 1)) === -1) {
|
|
283
|
-
start -= 1;
|
|
284
|
-
if (this.position - start > maxLength / 2 - 1) {
|
|
285
|
-
head = " ... ";
|
|
286
|
-
start += 5;
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
tail = "";
|
|
291
|
-
end = this.position;
|
|
292
|
-
while (end < this.buffer.length && "\0\r\n\x85\u2028\u2029".indexOf(this.buffer.charAt(end)) === -1) {
|
|
293
|
-
end += 1;
|
|
294
|
-
if (end - this.position > maxLength / 2 - 1) {
|
|
295
|
-
tail = " ... ";
|
|
296
|
-
end -= 5;
|
|
297
|
-
break;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
snippet = this.buffer.slice(start, end);
|
|
301
|
-
return common.repeat(" ", indent) + head + snippet + tail + "\n" + common.repeat(" ", indent + this.position - start + head.length) + "^";
|
|
302
|
-
};
|
|
303
|
-
Mark.prototype.toString = function toString(compact) {
|
|
304
|
-
var snippet, where = "";
|
|
305
|
-
if (this.name) {
|
|
306
|
-
where += 'in "' + this.name + '" ';
|
|
307
|
-
}
|
|
308
|
-
where += "at line " + (this.line + 1) + ", column " + (this.column + 1);
|
|
309
|
-
if (!compact) {
|
|
310
|
-
snippet = this.getSnippet();
|
|
311
|
-
if (snippet) {
|
|
312
|
-
where += ":\n" + snippet;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
return where;
|
|
316
|
-
};
|
|
317
|
-
module2.exports = Mark;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type.js
|
|
322
|
-
var require_type = __commonJS({
|
|
323
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type.js"(exports2, module2) {
|
|
324
|
-
"use strict";
|
|
325
|
-
var YAMLException = require_exception();
|
|
326
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
327
|
-
"kind",
|
|
328
|
-
"resolve",
|
|
329
|
-
"construct",
|
|
330
|
-
"instanceOf",
|
|
331
|
-
"predicate",
|
|
332
|
-
"represent",
|
|
333
|
-
"defaultStyle",
|
|
334
|
-
"styleAliases"
|
|
335
|
-
];
|
|
336
|
-
var YAML_NODE_KINDS = [
|
|
337
|
-
"scalar",
|
|
338
|
-
"sequence",
|
|
339
|
-
"mapping"
|
|
340
|
-
];
|
|
341
|
-
function compileStyleAliases(map) {
|
|
342
|
-
var result = {};
|
|
343
|
-
if (map !== null) {
|
|
344
|
-
Object.keys(map).forEach(function(style) {
|
|
345
|
-
map[style].forEach(function(alias) {
|
|
346
|
-
result[String(alias)] = style;
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
function Type(tag, options2) {
|
|
353
|
-
options2 = options2 || {};
|
|
354
|
-
Object.keys(options2).forEach(function(name) {
|
|
355
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
356
|
-
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
357
|
-
}
|
|
358
|
-
});
|
|
359
|
-
this.tag = tag;
|
|
360
|
-
this.kind = options2["kind"] || null;
|
|
361
|
-
this.resolve = options2["resolve"] || function() {
|
|
362
|
-
return true;
|
|
363
|
-
};
|
|
364
|
-
this.construct = options2["construct"] || function(data) {
|
|
365
|
-
return data;
|
|
366
|
-
};
|
|
367
|
-
this.instanceOf = options2["instanceOf"] || null;
|
|
368
|
-
this.predicate = options2["predicate"] || null;
|
|
369
|
-
this.represent = options2["represent"] || null;
|
|
370
|
-
this.defaultStyle = options2["defaultStyle"] || null;
|
|
371
|
-
this.styleAliases = compileStyleAliases(options2["styleAliases"] || null);
|
|
372
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
373
|
-
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
module2.exports = Type;
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
|
|
380
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema.js
|
|
381
|
-
var require_schema = __commonJS({
|
|
382
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema.js"(exports2, module2) {
|
|
383
|
-
"use strict";
|
|
384
|
-
var common = require_common();
|
|
385
|
-
var YAMLException = require_exception();
|
|
386
|
-
var Type = require_type();
|
|
387
|
-
function compileList(schema, name, result) {
|
|
388
|
-
var exclude = [];
|
|
389
|
-
schema.include.forEach(function(includedSchema) {
|
|
390
|
-
result = compileList(includedSchema, name, result);
|
|
391
|
-
});
|
|
392
|
-
schema[name].forEach(function(currentType) {
|
|
393
|
-
result.forEach(function(previousType, previousIndex) {
|
|
394
|
-
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
|
|
395
|
-
exclude.push(previousIndex);
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
result.push(currentType);
|
|
399
|
-
});
|
|
400
|
-
return result.filter(function(type, index) {
|
|
401
|
-
return exclude.indexOf(index) === -1;
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
function compileMap() {
|
|
405
|
-
var result = {
|
|
406
|
-
scalar: {},
|
|
407
|
-
sequence: {},
|
|
408
|
-
mapping: {},
|
|
409
|
-
fallback: {}
|
|
410
|
-
}, index, length;
|
|
411
|
-
function collectType(type) {
|
|
412
|
-
result[type.kind][type.tag] = result["fallback"][type.tag] = type;
|
|
413
|
-
}
|
|
414
|
-
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
415
|
-
arguments[index].forEach(collectType);
|
|
416
|
-
}
|
|
417
|
-
return result;
|
|
418
|
-
}
|
|
419
|
-
function Schema(definition) {
|
|
420
|
-
this.include = definition.include || [];
|
|
421
|
-
this.implicit = definition.implicit || [];
|
|
422
|
-
this.explicit = definition.explicit || [];
|
|
423
|
-
this.implicit.forEach(function(type) {
|
|
424
|
-
if (type.loadKind && type.loadKind !== "scalar") {
|
|
425
|
-
throw new YAMLException("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
this.compiledImplicit = compileList(this, "implicit", []);
|
|
429
|
-
this.compiledExplicit = compileList(this, "explicit", []);
|
|
430
|
-
this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
|
|
431
|
-
}
|
|
432
|
-
Schema.DEFAULT = null;
|
|
433
|
-
Schema.create = function createSchema() {
|
|
434
|
-
var schemas, types;
|
|
435
|
-
switch (arguments.length) {
|
|
436
|
-
case 1:
|
|
437
|
-
schemas = Schema.DEFAULT;
|
|
438
|
-
types = arguments[0];
|
|
439
|
-
break;
|
|
440
|
-
case 2:
|
|
441
|
-
schemas = arguments[0];
|
|
442
|
-
types = arguments[1];
|
|
443
|
-
break;
|
|
444
|
-
default:
|
|
445
|
-
throw new YAMLException("Wrong number of arguments for Schema.create function");
|
|
446
|
-
}
|
|
447
|
-
schemas = common.toArray(schemas);
|
|
448
|
-
types = common.toArray(types);
|
|
449
|
-
if (!schemas.every(function(schema) {
|
|
450
|
-
return schema instanceof Schema;
|
|
451
|
-
})) {
|
|
452
|
-
throw new YAMLException("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");
|
|
453
|
-
}
|
|
454
|
-
if (!types.every(function(type) {
|
|
455
|
-
return type instanceof Type;
|
|
456
|
-
})) {
|
|
457
|
-
throw new YAMLException("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
458
|
-
}
|
|
459
|
-
return new Schema({
|
|
460
|
-
include: schemas,
|
|
461
|
-
explicit: types
|
|
462
|
-
});
|
|
463
|
-
};
|
|
464
|
-
module2.exports = Schema;
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
|
|
468
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/str.js
|
|
469
|
-
var require_str = __commonJS({
|
|
470
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/str.js"(exports2, module2) {
|
|
471
|
-
"use strict";
|
|
472
|
-
var Type = require_type();
|
|
473
|
-
module2.exports = new Type("tag:yaml.org,2002:str", {
|
|
474
|
-
kind: "scalar",
|
|
475
|
-
construct: function(data) {
|
|
476
|
-
return data !== null ? data : "";
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
|
|
482
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/seq.js
|
|
483
|
-
var require_seq = __commonJS({
|
|
484
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/seq.js"(exports2, module2) {
|
|
485
|
-
"use strict";
|
|
486
|
-
var Type = require_type();
|
|
487
|
-
module2.exports = new Type("tag:yaml.org,2002:seq", {
|
|
488
|
-
kind: "sequence",
|
|
489
|
-
construct: function(data) {
|
|
490
|
-
return data !== null ? data : [];
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/map.js
|
|
497
|
-
var require_map = __commonJS({
|
|
498
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/map.js"(exports2, module2) {
|
|
499
|
-
"use strict";
|
|
500
|
-
var Type = require_type();
|
|
501
|
-
module2.exports = new Type("tag:yaml.org,2002:map", {
|
|
502
|
-
kind: "mapping",
|
|
503
|
-
construct: function(data) {
|
|
504
|
-
return data !== null ? data : {};
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js
|
|
511
|
-
var require_failsafe = __commonJS({
|
|
512
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js"(exports2, module2) {
|
|
513
|
-
"use strict";
|
|
514
|
-
var Schema = require_schema();
|
|
515
|
-
module2.exports = new Schema({
|
|
516
|
-
explicit: [
|
|
517
|
-
require_str(),
|
|
518
|
-
require_seq(),
|
|
519
|
-
require_map()
|
|
520
|
-
]
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/null.js
|
|
526
|
-
var require_null = __commonJS({
|
|
527
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/null.js"(exports2, module2) {
|
|
528
|
-
"use strict";
|
|
529
|
-
var Type = require_type();
|
|
530
|
-
function resolveYamlNull(data) {
|
|
531
|
-
if (data === null) return true;
|
|
532
|
-
var max = data.length;
|
|
533
|
-
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
534
|
-
}
|
|
535
|
-
function constructYamlNull() {
|
|
536
|
-
return null;
|
|
537
|
-
}
|
|
538
|
-
function isNull(object) {
|
|
539
|
-
return object === null;
|
|
540
|
-
}
|
|
541
|
-
module2.exports = new Type("tag:yaml.org,2002:null", {
|
|
542
|
-
kind: "scalar",
|
|
543
|
-
resolve: resolveYamlNull,
|
|
544
|
-
construct: constructYamlNull,
|
|
545
|
-
predicate: isNull,
|
|
546
|
-
represent: {
|
|
547
|
-
canonical: function() {
|
|
548
|
-
return "~";
|
|
549
|
-
},
|
|
550
|
-
lowercase: function() {
|
|
551
|
-
return "null";
|
|
552
|
-
},
|
|
553
|
-
uppercase: function() {
|
|
554
|
-
return "NULL";
|
|
555
|
-
},
|
|
556
|
-
camelcase: function() {
|
|
557
|
-
return "Null";
|
|
558
|
-
}
|
|
559
|
-
},
|
|
560
|
-
defaultStyle: "lowercase"
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/bool.js
|
|
566
|
-
var require_bool = __commonJS({
|
|
567
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/bool.js"(exports2, module2) {
|
|
568
|
-
"use strict";
|
|
569
|
-
var Type = require_type();
|
|
570
|
-
function resolveYamlBoolean(data) {
|
|
571
|
-
if (data === null) return false;
|
|
572
|
-
var max = data.length;
|
|
573
|
-
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
574
|
-
}
|
|
575
|
-
function constructYamlBoolean(data) {
|
|
576
|
-
return data === "true" || data === "True" || data === "TRUE";
|
|
577
|
-
}
|
|
578
|
-
function isBoolean(object) {
|
|
579
|
-
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
580
|
-
}
|
|
581
|
-
module2.exports = new Type("tag:yaml.org,2002:bool", {
|
|
582
|
-
kind: "scalar",
|
|
583
|
-
resolve: resolveYamlBoolean,
|
|
584
|
-
construct: constructYamlBoolean,
|
|
585
|
-
predicate: isBoolean,
|
|
586
|
-
represent: {
|
|
587
|
-
lowercase: function(object) {
|
|
588
|
-
return object ? "true" : "false";
|
|
589
|
-
},
|
|
590
|
-
uppercase: function(object) {
|
|
591
|
-
return object ? "TRUE" : "FALSE";
|
|
592
|
-
},
|
|
593
|
-
camelcase: function(object) {
|
|
594
|
-
return object ? "True" : "False";
|
|
595
|
-
}
|
|
596
|
-
},
|
|
597
|
-
defaultStyle: "lowercase"
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/int.js
|
|
603
|
-
var require_int = __commonJS({
|
|
604
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/int.js"(exports2, module2) {
|
|
605
|
-
"use strict";
|
|
606
|
-
var common = require_common();
|
|
607
|
-
var Type = require_type();
|
|
608
|
-
function isHexCode(c) {
|
|
609
|
-
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
610
|
-
}
|
|
611
|
-
function isOctCode(c) {
|
|
612
|
-
return 48 <= c && c <= 55;
|
|
613
|
-
}
|
|
614
|
-
function isDecCode(c) {
|
|
615
|
-
return 48 <= c && c <= 57;
|
|
616
|
-
}
|
|
617
|
-
function resolveYamlInteger(data) {
|
|
618
|
-
if (data === null) return false;
|
|
619
|
-
var max = data.length, index = 0, hasDigits = false, ch;
|
|
620
|
-
if (!max) return false;
|
|
621
|
-
ch = data[index];
|
|
622
|
-
if (ch === "-" || ch === "+") {
|
|
623
|
-
ch = data[++index];
|
|
624
|
-
}
|
|
625
|
-
if (ch === "0") {
|
|
626
|
-
if (index + 1 === max) return true;
|
|
627
|
-
ch = data[++index];
|
|
628
|
-
if (ch === "b") {
|
|
629
|
-
index++;
|
|
630
|
-
for (; index < max; index++) {
|
|
631
|
-
ch = data[index];
|
|
632
|
-
if (ch === "_") continue;
|
|
633
|
-
if (ch !== "0" && ch !== "1") return false;
|
|
634
|
-
hasDigits = true;
|
|
635
|
-
}
|
|
636
|
-
return hasDigits && ch !== "_";
|
|
637
|
-
}
|
|
638
|
-
if (ch === "x") {
|
|
639
|
-
index++;
|
|
640
|
-
for (; index < max; index++) {
|
|
641
|
-
ch = data[index];
|
|
642
|
-
if (ch === "_") continue;
|
|
643
|
-
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
644
|
-
hasDigits = true;
|
|
645
|
-
}
|
|
646
|
-
return hasDigits && ch !== "_";
|
|
647
|
-
}
|
|
648
|
-
for (; index < max; index++) {
|
|
649
|
-
ch = data[index];
|
|
650
|
-
if (ch === "_") continue;
|
|
651
|
-
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
652
|
-
hasDigits = true;
|
|
653
|
-
}
|
|
654
|
-
return hasDigits && ch !== "_";
|
|
655
|
-
}
|
|
656
|
-
if (ch === "_") return false;
|
|
657
|
-
for (; index < max; index++) {
|
|
658
|
-
ch = data[index];
|
|
659
|
-
if (ch === "_") continue;
|
|
660
|
-
if (ch === ":") break;
|
|
661
|
-
if (!isDecCode(data.charCodeAt(index))) {
|
|
662
|
-
return false;
|
|
663
|
-
}
|
|
664
|
-
hasDigits = true;
|
|
665
|
-
}
|
|
666
|
-
if (!hasDigits || ch === "_") return false;
|
|
667
|
-
if (ch !== ":") return true;
|
|
668
|
-
return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
|
|
669
|
-
}
|
|
670
|
-
function constructYamlInteger(data) {
|
|
671
|
-
var value = data, sign = 1, ch, base, digits = [];
|
|
672
|
-
if (value.indexOf("_") !== -1) {
|
|
673
|
-
value = value.replace(/_/g, "");
|
|
674
|
-
}
|
|
675
|
-
ch = value[0];
|
|
676
|
-
if (ch === "-" || ch === "+") {
|
|
677
|
-
if (ch === "-") sign = -1;
|
|
678
|
-
value = value.slice(1);
|
|
679
|
-
ch = value[0];
|
|
680
|
-
}
|
|
681
|
-
if (value === "0") return 0;
|
|
682
|
-
if (ch === "0") {
|
|
683
|
-
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
684
|
-
if (value[1] === "x") return sign * parseInt(value, 16);
|
|
685
|
-
return sign * parseInt(value, 8);
|
|
686
|
-
}
|
|
687
|
-
if (value.indexOf(":") !== -1) {
|
|
688
|
-
value.split(":").forEach(function(v) {
|
|
689
|
-
digits.unshift(parseInt(v, 10));
|
|
690
|
-
});
|
|
691
|
-
value = 0;
|
|
692
|
-
base = 1;
|
|
693
|
-
digits.forEach(function(d) {
|
|
694
|
-
value += d * base;
|
|
695
|
-
base *= 60;
|
|
696
|
-
});
|
|
697
|
-
return sign * value;
|
|
698
|
-
}
|
|
699
|
-
return sign * parseInt(value, 10);
|
|
700
|
-
}
|
|
701
|
-
function isInteger(object) {
|
|
702
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
703
|
-
}
|
|
704
|
-
module2.exports = new Type("tag:yaml.org,2002:int", {
|
|
705
|
-
kind: "scalar",
|
|
706
|
-
resolve: resolveYamlInteger,
|
|
707
|
-
construct: constructYamlInteger,
|
|
708
|
-
predicate: isInteger,
|
|
709
|
-
represent: {
|
|
710
|
-
binary: function(obj) {
|
|
711
|
-
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
712
|
-
},
|
|
713
|
-
octal: function(obj) {
|
|
714
|
-
return obj >= 0 ? "0" + obj.toString(8) : "-0" + obj.toString(8).slice(1);
|
|
715
|
-
},
|
|
716
|
-
decimal: function(obj) {
|
|
717
|
-
return obj.toString(10);
|
|
718
|
-
},
|
|
719
|
-
/* eslint-disable max-len */
|
|
720
|
-
hexadecimal: function(obj) {
|
|
721
|
-
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
722
|
-
}
|
|
723
|
-
},
|
|
724
|
-
defaultStyle: "decimal",
|
|
725
|
-
styleAliases: {
|
|
726
|
-
binary: [2, "bin"],
|
|
727
|
-
octal: [8, "oct"],
|
|
728
|
-
decimal: [10, "dec"],
|
|
729
|
-
hexadecimal: [16, "hex"]
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/float.js
|
|
736
|
-
var require_float = __commonJS({
|
|
737
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/float.js"(exports2, module2) {
|
|
738
|
-
"use strict";
|
|
739
|
-
var common = require_common();
|
|
740
|
-
var Type = require_type();
|
|
741
|
-
var YAML_FLOAT_PATTERN = new RegExp(
|
|
742
|
-
// 2.5e4, 2.5 and integers
|
|
743
|
-
"^(?:[-+]?(?: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))$"
|
|
744
|
-
);
|
|
745
|
-
function resolveYamlFloat(data) {
|
|
746
|
-
if (data === null) return false;
|
|
747
|
-
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
748
|
-
// Probably should update regexp & check speed
|
|
749
|
-
data[data.length - 1] === "_") {
|
|
750
|
-
return false;
|
|
751
|
-
}
|
|
752
|
-
return true;
|
|
753
|
-
}
|
|
754
|
-
function constructYamlFloat(data) {
|
|
755
|
-
var value, sign, base, digits;
|
|
756
|
-
value = data.replace(/_/g, "").toLowerCase();
|
|
757
|
-
sign = value[0] === "-" ? -1 : 1;
|
|
758
|
-
digits = [];
|
|
759
|
-
if ("+-".indexOf(value[0]) >= 0) {
|
|
760
|
-
value = value.slice(1);
|
|
761
|
-
}
|
|
762
|
-
if (value === ".inf") {
|
|
763
|
-
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
764
|
-
} else if (value === ".nan") {
|
|
765
|
-
return NaN;
|
|
766
|
-
} else if (value.indexOf(":") >= 0) {
|
|
767
|
-
value.split(":").forEach(function(v) {
|
|
768
|
-
digits.unshift(parseFloat(v, 10));
|
|
769
|
-
});
|
|
770
|
-
value = 0;
|
|
771
|
-
base = 1;
|
|
772
|
-
digits.forEach(function(d) {
|
|
773
|
-
value += d * base;
|
|
774
|
-
base *= 60;
|
|
775
|
-
});
|
|
776
|
-
return sign * value;
|
|
777
|
-
}
|
|
778
|
-
return sign * parseFloat(value, 10);
|
|
779
|
-
}
|
|
780
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
781
|
-
function representYamlFloat(object, style) {
|
|
782
|
-
var res;
|
|
783
|
-
if (isNaN(object)) {
|
|
784
|
-
switch (style) {
|
|
785
|
-
case "lowercase":
|
|
786
|
-
return ".nan";
|
|
787
|
-
case "uppercase":
|
|
788
|
-
return ".NAN";
|
|
789
|
-
case "camelcase":
|
|
790
|
-
return ".NaN";
|
|
791
|
-
}
|
|
792
|
-
} else if (Number.POSITIVE_INFINITY === object) {
|
|
793
|
-
switch (style) {
|
|
794
|
-
case "lowercase":
|
|
795
|
-
return ".inf";
|
|
796
|
-
case "uppercase":
|
|
797
|
-
return ".INF";
|
|
798
|
-
case "camelcase":
|
|
799
|
-
return ".Inf";
|
|
800
|
-
}
|
|
801
|
-
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
802
|
-
switch (style) {
|
|
803
|
-
case "lowercase":
|
|
804
|
-
return "-.inf";
|
|
805
|
-
case "uppercase":
|
|
806
|
-
return "-.INF";
|
|
807
|
-
case "camelcase":
|
|
808
|
-
return "-.Inf";
|
|
809
|
-
}
|
|
810
|
-
} else if (common.isNegativeZero(object)) {
|
|
811
|
-
return "-0.0";
|
|
812
|
-
}
|
|
813
|
-
res = object.toString(10);
|
|
814
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
815
|
-
}
|
|
816
|
-
function isFloat(object) {
|
|
817
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
818
|
-
}
|
|
819
|
-
module2.exports = new Type("tag:yaml.org,2002:float", {
|
|
820
|
-
kind: "scalar",
|
|
821
|
-
resolve: resolveYamlFloat,
|
|
822
|
-
construct: constructYamlFloat,
|
|
823
|
-
predicate: isFloat,
|
|
824
|
-
represent: representYamlFloat,
|
|
825
|
-
defaultStyle: "lowercase"
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
|
|
830
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/json.js
|
|
831
|
-
var require_json = __commonJS({
|
|
832
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/json.js"(exports2, module2) {
|
|
833
|
-
"use strict";
|
|
834
|
-
var Schema = require_schema();
|
|
835
|
-
module2.exports = new Schema({
|
|
836
|
-
include: [
|
|
837
|
-
require_failsafe()
|
|
838
|
-
],
|
|
839
|
-
implicit: [
|
|
840
|
-
require_null(),
|
|
841
|
-
require_bool(),
|
|
842
|
-
require_int(),
|
|
843
|
-
require_float()
|
|
844
|
-
]
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/core.js
|
|
850
|
-
var require_core = __commonJS({
|
|
851
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/core.js"(exports2, module2) {
|
|
852
|
-
"use strict";
|
|
853
|
-
var Schema = require_schema();
|
|
854
|
-
module2.exports = new Schema({
|
|
855
|
-
include: [
|
|
856
|
-
require_json()
|
|
857
|
-
]
|
|
858
|
-
});
|
|
859
|
-
}
|
|
860
|
-
});
|
|
861
|
-
|
|
862
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/timestamp.js
|
|
863
|
-
var require_timestamp = __commonJS({
|
|
864
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/timestamp.js"(exports2, module2) {
|
|
865
|
-
"use strict";
|
|
866
|
-
var Type = require_type();
|
|
867
|
-
var YAML_DATE_REGEXP = new RegExp(
|
|
868
|
-
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
869
|
-
);
|
|
870
|
-
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
871
|
-
"^([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]))?))?$"
|
|
872
|
-
);
|
|
873
|
-
function resolveYamlTimestamp(data) {
|
|
874
|
-
if (data === null) return false;
|
|
875
|
-
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
876
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
|
-
function constructYamlTimestamp(data) {
|
|
880
|
-
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
881
|
-
match = YAML_DATE_REGEXP.exec(data);
|
|
882
|
-
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
883
|
-
if (match === null) throw new Error("Date resolve error");
|
|
884
|
-
year = +match[1];
|
|
885
|
-
month = +match[2] - 1;
|
|
886
|
-
day = +match[3];
|
|
887
|
-
if (!match[4]) {
|
|
888
|
-
return new Date(Date.UTC(year, month, day));
|
|
889
|
-
}
|
|
890
|
-
hour = +match[4];
|
|
891
|
-
minute = +match[5];
|
|
892
|
-
second = +match[6];
|
|
893
|
-
if (match[7]) {
|
|
894
|
-
fraction = match[7].slice(0, 3);
|
|
895
|
-
while (fraction.length < 3) {
|
|
896
|
-
fraction += "0";
|
|
897
|
-
}
|
|
898
|
-
fraction = +fraction;
|
|
899
|
-
}
|
|
900
|
-
if (match[9]) {
|
|
901
|
-
tz_hour = +match[10];
|
|
902
|
-
tz_minute = +(match[11] || 0);
|
|
903
|
-
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
904
|
-
if (match[9] === "-") delta = -delta;
|
|
905
|
-
}
|
|
906
|
-
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
907
|
-
if (delta) date.setTime(date.getTime() - delta);
|
|
908
|
-
return date;
|
|
909
|
-
}
|
|
910
|
-
function representYamlTimestamp(object) {
|
|
911
|
-
return object.toISOString();
|
|
912
|
-
}
|
|
913
|
-
module2.exports = new Type("tag:yaml.org,2002:timestamp", {
|
|
914
|
-
kind: "scalar",
|
|
915
|
-
resolve: resolveYamlTimestamp,
|
|
916
|
-
construct: constructYamlTimestamp,
|
|
917
|
-
instanceOf: Date,
|
|
918
|
-
represent: representYamlTimestamp
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
});
|
|
922
|
-
|
|
923
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/merge.js
|
|
924
|
-
var require_merge = __commonJS({
|
|
925
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/merge.js"(exports2, module2) {
|
|
926
|
-
"use strict";
|
|
927
|
-
var Type = require_type();
|
|
928
|
-
function resolveYamlMerge(data) {
|
|
929
|
-
return data === "<<" || data === null;
|
|
930
|
-
}
|
|
931
|
-
module2.exports = new Type("tag:yaml.org,2002:merge", {
|
|
932
|
-
kind: "scalar",
|
|
933
|
-
resolve: resolveYamlMerge
|
|
934
|
-
});
|
|
935
|
-
}
|
|
936
|
-
});
|
|
937
|
-
|
|
938
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/binary.js
|
|
939
|
-
var require_binary = __commonJS({
|
|
940
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/binary.js"(exports2, module2) {
|
|
941
|
-
"use strict";
|
|
942
|
-
var NodeBuffer;
|
|
943
|
-
try {
|
|
944
|
-
_require = __require;
|
|
945
|
-
NodeBuffer = _require("buffer").Buffer;
|
|
946
|
-
} catch (__) {
|
|
947
|
-
}
|
|
948
|
-
var _require;
|
|
949
|
-
var Type = require_type();
|
|
950
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
951
|
-
function resolveYamlBinary(data) {
|
|
952
|
-
if (data === null) return false;
|
|
953
|
-
var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
|
|
954
|
-
for (idx = 0; idx < max; idx++) {
|
|
955
|
-
code = map.indexOf(data.charAt(idx));
|
|
956
|
-
if (code > 64) continue;
|
|
957
|
-
if (code < 0) return false;
|
|
958
|
-
bitlen += 6;
|
|
959
|
-
}
|
|
960
|
-
return bitlen % 8 === 0;
|
|
961
|
-
}
|
|
962
|
-
function constructYamlBinary(data) {
|
|
963
|
-
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map = BASE64_MAP, bits = 0, result = [];
|
|
964
|
-
for (idx = 0; idx < max; idx++) {
|
|
965
|
-
if (idx % 4 === 0 && idx) {
|
|
966
|
-
result.push(bits >> 16 & 255);
|
|
967
|
-
result.push(bits >> 8 & 255);
|
|
968
|
-
result.push(bits & 255);
|
|
969
|
-
}
|
|
970
|
-
bits = bits << 6 | map.indexOf(input.charAt(idx));
|
|
971
|
-
}
|
|
972
|
-
tailbits = max % 4 * 6;
|
|
973
|
-
if (tailbits === 0) {
|
|
974
|
-
result.push(bits >> 16 & 255);
|
|
975
|
-
result.push(bits >> 8 & 255);
|
|
976
|
-
result.push(bits & 255);
|
|
977
|
-
} else if (tailbits === 18) {
|
|
978
|
-
result.push(bits >> 10 & 255);
|
|
979
|
-
result.push(bits >> 2 & 255);
|
|
980
|
-
} else if (tailbits === 12) {
|
|
981
|
-
result.push(bits >> 4 & 255);
|
|
982
|
-
}
|
|
983
|
-
if (NodeBuffer) {
|
|
984
|
-
return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
|
|
985
|
-
}
|
|
986
|
-
return result;
|
|
987
|
-
}
|
|
988
|
-
function representYamlBinary(object) {
|
|
989
|
-
var result = "", bits = 0, idx, tail, max = object.length, map = BASE64_MAP;
|
|
990
|
-
for (idx = 0; idx < max; idx++) {
|
|
991
|
-
if (idx % 3 === 0 && idx) {
|
|
992
|
-
result += map[bits >> 18 & 63];
|
|
993
|
-
result += map[bits >> 12 & 63];
|
|
994
|
-
result += map[bits >> 6 & 63];
|
|
995
|
-
result += map[bits & 63];
|
|
996
|
-
}
|
|
997
|
-
bits = (bits << 8) + object[idx];
|
|
998
|
-
}
|
|
999
|
-
tail = max % 3;
|
|
1000
|
-
if (tail === 0) {
|
|
1001
|
-
result += map[bits >> 18 & 63];
|
|
1002
|
-
result += map[bits >> 12 & 63];
|
|
1003
|
-
result += map[bits >> 6 & 63];
|
|
1004
|
-
result += map[bits & 63];
|
|
1005
|
-
} else if (tail === 2) {
|
|
1006
|
-
result += map[bits >> 10 & 63];
|
|
1007
|
-
result += map[bits >> 4 & 63];
|
|
1008
|
-
result += map[bits << 2 & 63];
|
|
1009
|
-
result += map[64];
|
|
1010
|
-
} else if (tail === 1) {
|
|
1011
|
-
result += map[bits >> 2 & 63];
|
|
1012
|
-
result += map[bits << 4 & 63];
|
|
1013
|
-
result += map[64];
|
|
1014
|
-
result += map[64];
|
|
1015
|
-
}
|
|
1016
|
-
return result;
|
|
1017
|
-
}
|
|
1018
|
-
function isBinary(object) {
|
|
1019
|
-
return NodeBuffer && NodeBuffer.isBuffer(object);
|
|
1020
|
-
}
|
|
1021
|
-
module2.exports = new Type("tag:yaml.org,2002:binary", {
|
|
1022
|
-
kind: "scalar",
|
|
1023
|
-
resolve: resolveYamlBinary,
|
|
1024
|
-
construct: constructYamlBinary,
|
|
1025
|
-
predicate: isBinary,
|
|
1026
|
-
represent: representYamlBinary
|
|
1027
|
-
});
|
|
1028
|
-
}
|
|
1029
|
-
});
|
|
1030
|
-
|
|
1031
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/omap.js
|
|
1032
|
-
var require_omap = __commonJS({
|
|
1033
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/omap.js"(exports2, module2) {
|
|
1034
|
-
"use strict";
|
|
1035
|
-
var Type = require_type();
|
|
1036
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1037
|
-
var _toString = Object.prototype.toString;
|
|
1038
|
-
function resolveYamlOmap(data) {
|
|
1039
|
-
if (data === null) return true;
|
|
1040
|
-
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
1041
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1042
|
-
pair = object[index];
|
|
1043
|
-
pairHasKey = false;
|
|
1044
|
-
if (_toString.call(pair) !== "[object Object]") return false;
|
|
1045
|
-
for (pairKey in pair) {
|
|
1046
|
-
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
1047
|
-
if (!pairHasKey) pairHasKey = true;
|
|
1048
|
-
else return false;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
if (!pairHasKey) return false;
|
|
1052
|
-
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
1053
|
-
else return false;
|
|
1054
|
-
}
|
|
1055
|
-
return true;
|
|
1056
|
-
}
|
|
1057
|
-
function constructYamlOmap(data) {
|
|
1058
|
-
return data !== null ? data : [];
|
|
1059
|
-
}
|
|
1060
|
-
module2.exports = new Type("tag:yaml.org,2002:omap", {
|
|
1061
|
-
kind: "sequence",
|
|
1062
|
-
resolve: resolveYamlOmap,
|
|
1063
|
-
construct: constructYamlOmap
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/pairs.js
|
|
1069
|
-
var require_pairs = __commonJS({
|
|
1070
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/pairs.js"(exports2, module2) {
|
|
1071
|
-
"use strict";
|
|
1072
|
-
var Type = require_type();
|
|
1073
|
-
var _toString = Object.prototype.toString;
|
|
1074
|
-
function resolveYamlPairs(data) {
|
|
1075
|
-
if (data === null) return true;
|
|
1076
|
-
var index, length, pair, keys, result, object = data;
|
|
1077
|
-
result = new Array(object.length);
|
|
1078
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1079
|
-
pair = object[index];
|
|
1080
|
-
if (_toString.call(pair) !== "[object Object]") return false;
|
|
1081
|
-
keys = Object.keys(pair);
|
|
1082
|
-
if (keys.length !== 1) return false;
|
|
1083
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1084
|
-
}
|
|
1085
|
-
return true;
|
|
1086
|
-
}
|
|
1087
|
-
function constructYamlPairs(data) {
|
|
1088
|
-
if (data === null) return [];
|
|
1089
|
-
var index, length, pair, keys, result, object = data;
|
|
1090
|
-
result = new Array(object.length);
|
|
1091
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1092
|
-
pair = object[index];
|
|
1093
|
-
keys = Object.keys(pair);
|
|
1094
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1095
|
-
}
|
|
1096
|
-
return result;
|
|
1097
|
-
}
|
|
1098
|
-
module2.exports = new Type("tag:yaml.org,2002:pairs", {
|
|
1099
|
-
kind: "sequence",
|
|
1100
|
-
resolve: resolveYamlPairs,
|
|
1101
|
-
construct: constructYamlPairs
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
|
-
});
|
|
1105
|
-
|
|
1106
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/set.js
|
|
1107
|
-
var require_set = __commonJS({
|
|
1108
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/set.js"(exports2, module2) {
|
|
1109
|
-
"use strict";
|
|
1110
|
-
var Type = require_type();
|
|
1111
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1112
|
-
function resolveYamlSet(data) {
|
|
1113
|
-
if (data === null) return true;
|
|
1114
|
-
var key, object = data;
|
|
1115
|
-
for (key in object) {
|
|
1116
|
-
if (_hasOwnProperty.call(object, key)) {
|
|
1117
|
-
if (object[key] !== null) return false;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
return true;
|
|
1121
|
-
}
|
|
1122
|
-
function constructYamlSet(data) {
|
|
1123
|
-
return data !== null ? data : {};
|
|
1124
|
-
}
|
|
1125
|
-
module2.exports = new Type("tag:yaml.org,2002:set", {
|
|
1126
|
-
kind: "mapping",
|
|
1127
|
-
resolve: resolveYamlSet,
|
|
1128
|
-
construct: constructYamlSet
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js
|
|
1134
|
-
var require_default_safe = __commonJS({
|
|
1135
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js"(exports2, module2) {
|
|
1136
|
-
"use strict";
|
|
1137
|
-
var Schema = require_schema();
|
|
1138
|
-
module2.exports = new Schema({
|
|
1139
|
-
include: [
|
|
1140
|
-
require_core()
|
|
1141
|
-
],
|
|
1142
|
-
implicit: [
|
|
1143
|
-
require_timestamp(),
|
|
1144
|
-
require_merge()
|
|
1145
|
-
],
|
|
1146
|
-
explicit: [
|
|
1147
|
-
require_binary(),
|
|
1148
|
-
require_omap(),
|
|
1149
|
-
require_pairs(),
|
|
1150
|
-
require_set()
|
|
1151
|
-
]
|
|
1152
|
-
});
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js
|
|
1157
|
-
var require_undefined = __commonJS({
|
|
1158
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js"(exports2, module2) {
|
|
1159
|
-
"use strict";
|
|
1160
|
-
var Type = require_type();
|
|
1161
|
-
function resolveJavascriptUndefined() {
|
|
1162
|
-
return true;
|
|
1163
|
-
}
|
|
1164
|
-
function constructJavascriptUndefined() {
|
|
1165
|
-
return void 0;
|
|
1166
|
-
}
|
|
1167
|
-
function representJavascriptUndefined() {
|
|
1168
|
-
return "";
|
|
1169
|
-
}
|
|
1170
|
-
function isUndefined(object) {
|
|
1171
|
-
return typeof object === "undefined";
|
|
1172
|
-
}
|
|
1173
|
-
module2.exports = new Type("tag:yaml.org,2002:js/undefined", {
|
|
1174
|
-
kind: "scalar",
|
|
1175
|
-
resolve: resolveJavascriptUndefined,
|
|
1176
|
-
construct: constructJavascriptUndefined,
|
|
1177
|
-
predicate: isUndefined,
|
|
1178
|
-
represent: representJavascriptUndefined
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
});
|
|
1182
|
-
|
|
1183
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js
|
|
1184
|
-
var require_regexp = __commonJS({
|
|
1185
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js"(exports2, module2) {
|
|
1186
|
-
"use strict";
|
|
1187
|
-
var Type = require_type();
|
|
1188
|
-
function resolveJavascriptRegExp(data) {
|
|
1189
|
-
if (data === null) return false;
|
|
1190
|
-
if (data.length === 0) return false;
|
|
1191
|
-
var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
|
|
1192
|
-
if (regexp[0] === "/") {
|
|
1193
|
-
if (tail) modifiers = tail[1];
|
|
1194
|
-
if (modifiers.length > 3) return false;
|
|
1195
|
-
if (regexp[regexp.length - modifiers.length - 1] !== "/") return false;
|
|
1196
|
-
}
|
|
1197
|
-
return true;
|
|
1198
|
-
}
|
|
1199
|
-
function constructJavascriptRegExp(data) {
|
|
1200
|
-
var regexp = data, tail = /\/([gim]*)$/.exec(data), modifiers = "";
|
|
1201
|
-
if (regexp[0] === "/") {
|
|
1202
|
-
if (tail) modifiers = tail[1];
|
|
1203
|
-
regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
|
|
1204
|
-
}
|
|
1205
|
-
return new RegExp(regexp, modifiers);
|
|
1206
|
-
}
|
|
1207
|
-
function representJavascriptRegExp(object) {
|
|
1208
|
-
var result = "/" + object.source + "/";
|
|
1209
|
-
if (object.global) result += "g";
|
|
1210
|
-
if (object.multiline) result += "m";
|
|
1211
|
-
if (object.ignoreCase) result += "i";
|
|
1212
|
-
return result;
|
|
1213
|
-
}
|
|
1214
|
-
function isRegExp(object) {
|
|
1215
|
-
return Object.prototype.toString.call(object) === "[object RegExp]";
|
|
1216
|
-
}
|
|
1217
|
-
module2.exports = new Type("tag:yaml.org,2002:js/regexp", {
|
|
1218
|
-
kind: "scalar",
|
|
1219
|
-
resolve: resolveJavascriptRegExp,
|
|
1220
|
-
construct: constructJavascriptRegExp,
|
|
1221
|
-
predicate: isRegExp,
|
|
1222
|
-
represent: representJavascriptRegExp
|
|
1223
|
-
});
|
|
1224
|
-
}
|
|
1225
|
-
});
|
|
1226
|
-
|
|
1227
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/function.js
|
|
1228
|
-
var require_function = __commonJS({
|
|
1229
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/type/js/function.js"(exports2, module2) {
|
|
1230
|
-
"use strict";
|
|
1231
|
-
var esprima;
|
|
1232
|
-
try {
|
|
1233
|
-
_require = __require;
|
|
1234
|
-
esprima = _require("esprima");
|
|
1235
|
-
} catch (_) {
|
|
1236
|
-
if (typeof window !== "undefined") esprima = window.esprima;
|
|
1237
|
-
}
|
|
1238
|
-
var _require;
|
|
1239
|
-
var Type = require_type();
|
|
1240
|
-
function resolveJavascriptFunction(data) {
|
|
1241
|
-
if (data === null) return false;
|
|
1242
|
-
try {
|
|
1243
|
-
var source = "(" + data + ")", ast = esprima.parse(source, { range: true });
|
|
1244
|
-
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") {
|
|
1245
|
-
return false;
|
|
1246
|
-
}
|
|
1247
|
-
return true;
|
|
1248
|
-
} catch (err) {
|
|
1249
|
-
return false;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
function constructJavascriptFunction(data) {
|
|
1253
|
-
var source = "(" + data + ")", ast = esprima.parse(source, { range: true }), params = [], body;
|
|
1254
|
-
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") {
|
|
1255
|
-
throw new Error("Failed to resolve function");
|
|
1256
|
-
}
|
|
1257
|
-
ast.body[0].expression.params.forEach(function(param) {
|
|
1258
|
-
params.push(param.name);
|
|
1259
|
-
});
|
|
1260
|
-
body = ast.body[0].expression.body.range;
|
|
1261
|
-
if (ast.body[0].expression.body.type === "BlockStatement") {
|
|
1262
|
-
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
|
1263
|
-
}
|
|
1264
|
-
return new Function(params, "return " + source.slice(body[0], body[1]));
|
|
1265
|
-
}
|
|
1266
|
-
function representJavascriptFunction(object) {
|
|
1267
|
-
return object.toString();
|
|
1268
|
-
}
|
|
1269
|
-
function isFunction(object) {
|
|
1270
|
-
return Object.prototype.toString.call(object) === "[object Function]";
|
|
1271
|
-
}
|
|
1272
|
-
module2.exports = new Type("tag:yaml.org,2002:js/function", {
|
|
1273
|
-
kind: "scalar",
|
|
1274
|
-
resolve: resolveJavascriptFunction,
|
|
1275
|
-
construct: constructJavascriptFunction,
|
|
1276
|
-
predicate: isFunction,
|
|
1277
|
-
represent: representJavascriptFunction
|
|
1278
|
-
});
|
|
1279
|
-
}
|
|
1280
|
-
});
|
|
1281
|
-
|
|
1282
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_full.js
|
|
1283
|
-
var require_default_full = __commonJS({
|
|
1284
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/schema/default_full.js"(exports2, module2) {
|
|
1285
|
-
"use strict";
|
|
1286
|
-
var Schema = require_schema();
|
|
1287
|
-
module2.exports = Schema.DEFAULT = new Schema({
|
|
1288
|
-
include: [
|
|
1289
|
-
require_default_safe()
|
|
1290
|
-
],
|
|
1291
|
-
explicit: [
|
|
1292
|
-
require_undefined(),
|
|
1293
|
-
require_regexp(),
|
|
1294
|
-
require_function()
|
|
1295
|
-
]
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
});
|
|
1299
|
-
|
|
1300
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/loader.js
|
|
1301
|
-
var require_loader = __commonJS({
|
|
1302
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/loader.js"(exports2, module2) {
|
|
1303
|
-
"use strict";
|
|
1304
|
-
var common = require_common();
|
|
1305
|
-
var YAMLException = require_exception();
|
|
1306
|
-
var Mark = require_mark();
|
|
1307
|
-
var DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
1308
|
-
var DEFAULT_FULL_SCHEMA = require_default_full();
|
|
1309
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
1310
|
-
var CONTEXT_FLOW_IN = 1;
|
|
1311
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
1312
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
1313
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
1314
|
-
var CHOMPING_CLIP = 1;
|
|
1315
|
-
var CHOMPING_STRIP = 2;
|
|
1316
|
-
var CHOMPING_KEEP = 3;
|
|
1317
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1318
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1319
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1320
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1321
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1322
|
-
function _class(obj) {
|
|
1323
|
-
return Object.prototype.toString.call(obj);
|
|
1324
|
-
}
|
|
1325
|
-
function is_EOL(c) {
|
|
1326
|
-
return c === 10 || c === 13;
|
|
1327
|
-
}
|
|
1328
|
-
function is_WHITE_SPACE(c) {
|
|
1329
|
-
return c === 9 || c === 32;
|
|
1330
|
-
}
|
|
1331
|
-
function is_WS_OR_EOL(c) {
|
|
1332
|
-
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1333
|
-
}
|
|
1334
|
-
function is_FLOW_INDICATOR(c) {
|
|
1335
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1336
|
-
}
|
|
1337
|
-
function fromHexCode(c) {
|
|
1338
|
-
var lc;
|
|
1339
|
-
if (48 <= c && c <= 57) {
|
|
1340
|
-
return c - 48;
|
|
1341
|
-
}
|
|
1342
|
-
lc = c | 32;
|
|
1343
|
-
if (97 <= lc && lc <= 102) {
|
|
1344
|
-
return lc - 97 + 10;
|
|
1345
|
-
}
|
|
1346
|
-
return -1;
|
|
1347
|
-
}
|
|
1348
|
-
function escapedHexLen(c) {
|
|
1349
|
-
if (c === 120) {
|
|
1350
|
-
return 2;
|
|
1351
|
-
}
|
|
1352
|
-
if (c === 117) {
|
|
1353
|
-
return 4;
|
|
1354
|
-
}
|
|
1355
|
-
if (c === 85) {
|
|
1356
|
-
return 8;
|
|
1357
|
-
}
|
|
1358
|
-
return 0;
|
|
1359
|
-
}
|
|
1360
|
-
function fromDecimalCode(c) {
|
|
1361
|
-
if (48 <= c && c <= 57) {
|
|
1362
|
-
return c - 48;
|
|
1363
|
-
}
|
|
1364
|
-
return -1;
|
|
1365
|
-
}
|
|
1366
|
-
function simpleEscapeSequence(c) {
|
|
1367
|
-
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
1368
|
-
}
|
|
1369
|
-
function charFromCodepoint(c) {
|
|
1370
|
-
if (c <= 65535) {
|
|
1371
|
-
return String.fromCharCode(c);
|
|
1372
|
-
}
|
|
1373
|
-
return String.fromCharCode(
|
|
1374
|
-
(c - 65536 >> 10) + 55296,
|
|
1375
|
-
(c - 65536 & 1023) + 56320
|
|
1376
|
-
);
|
|
1377
|
-
}
|
|
1378
|
-
var simpleEscapeCheck = new Array(256);
|
|
1379
|
-
var simpleEscapeMap = new Array(256);
|
|
1380
|
-
for (i = 0; i < 256; i++) {
|
|
1381
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1382
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1383
|
-
}
|
|
1384
|
-
var i;
|
|
1385
|
-
function State(input, options2) {
|
|
1386
|
-
this.input = input;
|
|
1387
|
-
this.filename = options2["filename"] || null;
|
|
1388
|
-
this.schema = options2["schema"] || DEFAULT_FULL_SCHEMA;
|
|
1389
|
-
this.onWarning = options2["onWarning"] || null;
|
|
1390
|
-
this.legacy = options2["legacy"] || false;
|
|
1391
|
-
this.json = options2["json"] || false;
|
|
1392
|
-
this.listener = options2["listener"] || null;
|
|
1393
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
1394
|
-
this.typeMap = this.schema.compiledTypeMap;
|
|
1395
|
-
this.length = input.length;
|
|
1396
|
-
this.position = 0;
|
|
1397
|
-
this.line = 0;
|
|
1398
|
-
this.lineStart = 0;
|
|
1399
|
-
this.lineIndent = 0;
|
|
1400
|
-
this.documents = [];
|
|
1401
|
-
}
|
|
1402
|
-
function generateError(state, message) {
|
|
1403
|
-
return new YAMLException(
|
|
1404
|
-
message,
|
|
1405
|
-
new Mark(state.filename, state.input, state.position, state.line, state.position - state.lineStart)
|
|
1406
|
-
);
|
|
1407
|
-
}
|
|
1408
|
-
function throwError(state, message) {
|
|
1409
|
-
throw generateError(state, message);
|
|
1410
|
-
}
|
|
1411
|
-
function throwWarning(state, message) {
|
|
1412
|
-
if (state.onWarning) {
|
|
1413
|
-
state.onWarning.call(null, generateError(state, message));
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
var directiveHandlers = {
|
|
1417
|
-
YAML: function handleYamlDirective(state, name, args) {
|
|
1418
|
-
var match, major, minor;
|
|
1419
|
-
if (state.version !== null) {
|
|
1420
|
-
throwError(state, "duplication of %YAML directive");
|
|
1421
|
-
}
|
|
1422
|
-
if (args.length !== 1) {
|
|
1423
|
-
throwError(state, "YAML directive accepts exactly one argument");
|
|
1424
|
-
}
|
|
1425
|
-
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1426
|
-
if (match === null) {
|
|
1427
|
-
throwError(state, "ill-formed argument of the YAML directive");
|
|
1428
|
-
}
|
|
1429
|
-
major = parseInt(match[1], 10);
|
|
1430
|
-
minor = parseInt(match[2], 10);
|
|
1431
|
-
if (major !== 1) {
|
|
1432
|
-
throwError(state, "unacceptable YAML version of the document");
|
|
1433
|
-
}
|
|
1434
|
-
state.version = args[0];
|
|
1435
|
-
state.checkLineBreaks = minor < 2;
|
|
1436
|
-
if (minor !== 1 && minor !== 2) {
|
|
1437
|
-
throwWarning(state, "unsupported YAML version of the document");
|
|
1438
|
-
}
|
|
1439
|
-
},
|
|
1440
|
-
TAG: function handleTagDirective(state, name, args) {
|
|
1441
|
-
var handle, prefix;
|
|
1442
|
-
if (args.length !== 2) {
|
|
1443
|
-
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1444
|
-
}
|
|
1445
|
-
handle = args[0];
|
|
1446
|
-
prefix = args[1];
|
|
1447
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1448
|
-
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1449
|
-
}
|
|
1450
|
-
if (_hasOwnProperty.call(state.tagMap, handle)) {
|
|
1451
|
-
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1452
|
-
}
|
|
1453
|
-
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1454
|
-
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1455
|
-
}
|
|
1456
|
-
state.tagMap[handle] = prefix;
|
|
1457
|
-
}
|
|
1458
|
-
};
|
|
1459
|
-
function captureSegment(state, start, end, checkJson) {
|
|
1460
|
-
var _position, _length, _character, _result;
|
|
1461
|
-
if (start < end) {
|
|
1462
|
-
_result = state.input.slice(start, end);
|
|
1463
|
-
if (checkJson) {
|
|
1464
|
-
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1465
|
-
_character = _result.charCodeAt(_position);
|
|
1466
|
-
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1467
|
-
throwError(state, "expected valid JSON character");
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1471
|
-
throwError(state, "the stream contains non-printable characters");
|
|
1472
|
-
}
|
|
1473
|
-
state.result += _result;
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1477
|
-
var sourceKeys, key, index, quantity;
|
|
1478
|
-
if (!common.isObject(source)) {
|
|
1479
|
-
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1480
|
-
}
|
|
1481
|
-
sourceKeys = Object.keys(source);
|
|
1482
|
-
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1483
|
-
key = sourceKeys[index];
|
|
1484
|
-
if (!_hasOwnProperty.call(destination, key)) {
|
|
1485
|
-
destination[key] = source[key];
|
|
1486
|
-
overridableKeys[key] = true;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
|
|
1491
|
-
var index, quantity;
|
|
1492
|
-
if (Array.isArray(keyNode)) {
|
|
1493
|
-
keyNode = Array.prototype.slice.call(keyNode);
|
|
1494
|
-
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1495
|
-
if (Array.isArray(keyNode[index])) {
|
|
1496
|
-
throwError(state, "nested arrays are not supported inside keys");
|
|
1497
|
-
}
|
|
1498
|
-
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1499
|
-
keyNode[index] = "[object Object]";
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1504
|
-
keyNode = "[object Object]";
|
|
1505
|
-
}
|
|
1506
|
-
keyNode = String(keyNode);
|
|
1507
|
-
if (_result === null) {
|
|
1508
|
-
_result = {};
|
|
1509
|
-
}
|
|
1510
|
-
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1511
|
-
if (Array.isArray(valueNode)) {
|
|
1512
|
-
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1513
|
-
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1514
|
-
}
|
|
1515
|
-
} else {
|
|
1516
|
-
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1517
|
-
}
|
|
1518
|
-
} else {
|
|
1519
|
-
if (!state.json && !_hasOwnProperty.call(overridableKeys, keyNode) && _hasOwnProperty.call(_result, keyNode)) {
|
|
1520
|
-
state.line = startLine || state.line;
|
|
1521
|
-
state.position = startPos || state.position;
|
|
1522
|
-
throwError(state, "duplicated mapping key");
|
|
1523
|
-
}
|
|
1524
|
-
_result[keyNode] = valueNode;
|
|
1525
|
-
delete overridableKeys[keyNode];
|
|
1526
|
-
}
|
|
1527
|
-
return _result;
|
|
1528
|
-
}
|
|
1529
|
-
function readLineBreak(state) {
|
|
1530
|
-
var ch;
|
|
1531
|
-
ch = state.input.charCodeAt(state.position);
|
|
1532
|
-
if (ch === 10) {
|
|
1533
|
-
state.position++;
|
|
1534
|
-
} else if (ch === 13) {
|
|
1535
|
-
state.position++;
|
|
1536
|
-
if (state.input.charCodeAt(state.position) === 10) {
|
|
1537
|
-
state.position++;
|
|
1538
|
-
}
|
|
1539
|
-
} else {
|
|
1540
|
-
throwError(state, "a line break is expected");
|
|
1541
|
-
}
|
|
1542
|
-
state.line += 1;
|
|
1543
|
-
state.lineStart = state.position;
|
|
1544
|
-
}
|
|
1545
|
-
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1546
|
-
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1547
|
-
while (ch !== 0) {
|
|
1548
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1549
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1550
|
-
}
|
|
1551
|
-
if (allowComments && ch === 35) {
|
|
1552
|
-
do {
|
|
1553
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1554
|
-
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1555
|
-
}
|
|
1556
|
-
if (is_EOL(ch)) {
|
|
1557
|
-
readLineBreak(state);
|
|
1558
|
-
ch = state.input.charCodeAt(state.position);
|
|
1559
|
-
lineBreaks++;
|
|
1560
|
-
state.lineIndent = 0;
|
|
1561
|
-
while (ch === 32) {
|
|
1562
|
-
state.lineIndent++;
|
|
1563
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1564
|
-
}
|
|
1565
|
-
} else {
|
|
1566
|
-
break;
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1570
|
-
throwWarning(state, "deficient indentation");
|
|
1571
|
-
}
|
|
1572
|
-
return lineBreaks;
|
|
1573
|
-
}
|
|
1574
|
-
function testDocumentSeparator(state) {
|
|
1575
|
-
var _position = state.position, ch;
|
|
1576
|
-
ch = state.input.charCodeAt(_position);
|
|
1577
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1578
|
-
_position += 3;
|
|
1579
|
-
ch = state.input.charCodeAt(_position);
|
|
1580
|
-
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1581
|
-
return true;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
return false;
|
|
1585
|
-
}
|
|
1586
|
-
function writeFoldedLines(state, count) {
|
|
1587
|
-
if (count === 1) {
|
|
1588
|
-
state.result += " ";
|
|
1589
|
-
} else if (count > 1) {
|
|
1590
|
-
state.result += common.repeat("\n", count - 1);
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1594
|
-
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1595
|
-
ch = state.input.charCodeAt(state.position);
|
|
1596
|
-
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) {
|
|
1597
|
-
return false;
|
|
1598
|
-
}
|
|
1599
|
-
if (ch === 63 || ch === 45) {
|
|
1600
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1601
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1602
|
-
return false;
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
state.kind = "scalar";
|
|
1606
|
-
state.result = "";
|
|
1607
|
-
captureStart = captureEnd = state.position;
|
|
1608
|
-
hasPendingContent = false;
|
|
1609
|
-
while (ch !== 0) {
|
|
1610
|
-
if (ch === 58) {
|
|
1611
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1612
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1613
|
-
break;
|
|
1614
|
-
}
|
|
1615
|
-
} else if (ch === 35) {
|
|
1616
|
-
preceding = state.input.charCodeAt(state.position - 1);
|
|
1617
|
-
if (is_WS_OR_EOL(preceding)) {
|
|
1618
|
-
break;
|
|
1619
|
-
}
|
|
1620
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1621
|
-
break;
|
|
1622
|
-
} else if (is_EOL(ch)) {
|
|
1623
|
-
_line = state.line;
|
|
1624
|
-
_lineStart = state.lineStart;
|
|
1625
|
-
_lineIndent = state.lineIndent;
|
|
1626
|
-
skipSeparationSpace(state, false, -1);
|
|
1627
|
-
if (state.lineIndent >= nodeIndent) {
|
|
1628
|
-
hasPendingContent = true;
|
|
1629
|
-
ch = state.input.charCodeAt(state.position);
|
|
1630
|
-
continue;
|
|
1631
|
-
} else {
|
|
1632
|
-
state.position = captureEnd;
|
|
1633
|
-
state.line = _line;
|
|
1634
|
-
state.lineStart = _lineStart;
|
|
1635
|
-
state.lineIndent = _lineIndent;
|
|
1636
|
-
break;
|
|
1637
|
-
}
|
|
1638
|
-
}
|
|
1639
|
-
if (hasPendingContent) {
|
|
1640
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1641
|
-
writeFoldedLines(state, state.line - _line);
|
|
1642
|
-
captureStart = captureEnd = state.position;
|
|
1643
|
-
hasPendingContent = false;
|
|
1644
|
-
}
|
|
1645
|
-
if (!is_WHITE_SPACE(ch)) {
|
|
1646
|
-
captureEnd = state.position + 1;
|
|
1647
|
-
}
|
|
1648
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1649
|
-
}
|
|
1650
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1651
|
-
if (state.result) {
|
|
1652
|
-
return true;
|
|
1653
|
-
}
|
|
1654
|
-
state.kind = _kind;
|
|
1655
|
-
state.result = _result;
|
|
1656
|
-
return false;
|
|
1657
|
-
}
|
|
1658
|
-
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1659
|
-
var ch, captureStart, captureEnd;
|
|
1660
|
-
ch = state.input.charCodeAt(state.position);
|
|
1661
|
-
if (ch !== 39) {
|
|
1662
|
-
return false;
|
|
1663
|
-
}
|
|
1664
|
-
state.kind = "scalar";
|
|
1665
|
-
state.result = "";
|
|
1666
|
-
state.position++;
|
|
1667
|
-
captureStart = captureEnd = state.position;
|
|
1668
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1669
|
-
if (ch === 39) {
|
|
1670
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1671
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1672
|
-
if (ch === 39) {
|
|
1673
|
-
captureStart = state.position;
|
|
1674
|
-
state.position++;
|
|
1675
|
-
captureEnd = state.position;
|
|
1676
|
-
} else {
|
|
1677
|
-
return true;
|
|
1678
|
-
}
|
|
1679
|
-
} else if (is_EOL(ch)) {
|
|
1680
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1681
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1682
|
-
captureStart = captureEnd = state.position;
|
|
1683
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1684
|
-
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1685
|
-
} else {
|
|
1686
|
-
state.position++;
|
|
1687
|
-
captureEnd = state.position;
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1691
|
-
}
|
|
1692
|
-
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1693
|
-
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1694
|
-
ch = state.input.charCodeAt(state.position);
|
|
1695
|
-
if (ch !== 34) {
|
|
1696
|
-
return false;
|
|
1697
|
-
}
|
|
1698
|
-
state.kind = "scalar";
|
|
1699
|
-
state.result = "";
|
|
1700
|
-
state.position++;
|
|
1701
|
-
captureStart = captureEnd = state.position;
|
|
1702
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1703
|
-
if (ch === 34) {
|
|
1704
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1705
|
-
state.position++;
|
|
1706
|
-
return true;
|
|
1707
|
-
} else if (ch === 92) {
|
|
1708
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1709
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1710
|
-
if (is_EOL(ch)) {
|
|
1711
|
-
skipSeparationSpace(state, false, nodeIndent);
|
|
1712
|
-
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1713
|
-
state.result += simpleEscapeMap[ch];
|
|
1714
|
-
state.position++;
|
|
1715
|
-
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1716
|
-
hexLength = tmp;
|
|
1717
|
-
hexResult = 0;
|
|
1718
|
-
for (; hexLength > 0; hexLength--) {
|
|
1719
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1720
|
-
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1721
|
-
hexResult = (hexResult << 4) + tmp;
|
|
1722
|
-
} else {
|
|
1723
|
-
throwError(state, "expected hexadecimal character");
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
state.result += charFromCodepoint(hexResult);
|
|
1727
|
-
state.position++;
|
|
1728
|
-
} else {
|
|
1729
|
-
throwError(state, "unknown escape sequence");
|
|
1730
|
-
}
|
|
1731
|
-
captureStart = captureEnd = state.position;
|
|
1732
|
-
} else if (is_EOL(ch)) {
|
|
1733
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1734
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1735
|
-
captureStart = captureEnd = state.position;
|
|
1736
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1737
|
-
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1738
|
-
} else {
|
|
1739
|
-
state.position++;
|
|
1740
|
-
captureEnd = state.position;
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1744
|
-
}
|
|
1745
|
-
function readFlowCollection(state, nodeIndent) {
|
|
1746
|
-
var readNext = true, _line, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = {}, keyNode, keyTag, valueNode, ch;
|
|
1747
|
-
ch = state.input.charCodeAt(state.position);
|
|
1748
|
-
if (ch === 91) {
|
|
1749
|
-
terminator = 93;
|
|
1750
|
-
isMapping = false;
|
|
1751
|
-
_result = [];
|
|
1752
|
-
} else if (ch === 123) {
|
|
1753
|
-
terminator = 125;
|
|
1754
|
-
isMapping = true;
|
|
1755
|
-
_result = {};
|
|
1756
|
-
} else {
|
|
1757
|
-
return false;
|
|
1758
|
-
}
|
|
1759
|
-
if (state.anchor !== null) {
|
|
1760
|
-
state.anchorMap[state.anchor] = _result;
|
|
1761
|
-
}
|
|
1762
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1763
|
-
while (ch !== 0) {
|
|
1764
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1765
|
-
ch = state.input.charCodeAt(state.position);
|
|
1766
|
-
if (ch === terminator) {
|
|
1767
|
-
state.position++;
|
|
1768
|
-
state.tag = _tag;
|
|
1769
|
-
state.anchor = _anchor;
|
|
1770
|
-
state.kind = isMapping ? "mapping" : "sequence";
|
|
1771
|
-
state.result = _result;
|
|
1772
|
-
return true;
|
|
1773
|
-
} else if (!readNext) {
|
|
1774
|
-
throwError(state, "missed comma between flow collection entries");
|
|
1775
|
-
}
|
|
1776
|
-
keyTag = keyNode = valueNode = null;
|
|
1777
|
-
isPair = isExplicitPair = false;
|
|
1778
|
-
if (ch === 63) {
|
|
1779
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1780
|
-
if (is_WS_OR_EOL(following)) {
|
|
1781
|
-
isPair = isExplicitPair = true;
|
|
1782
|
-
state.position++;
|
|
1783
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
_line = state.line;
|
|
1787
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1788
|
-
keyTag = state.tag;
|
|
1789
|
-
keyNode = state.result;
|
|
1790
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1791
|
-
ch = state.input.charCodeAt(state.position);
|
|
1792
|
-
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1793
|
-
isPair = true;
|
|
1794
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1795
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1796
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1797
|
-
valueNode = state.result;
|
|
1798
|
-
}
|
|
1799
|
-
if (isMapping) {
|
|
1800
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
|
|
1801
|
-
} else if (isPair) {
|
|
1802
|
-
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
|
|
1803
|
-
} else {
|
|
1804
|
-
_result.push(keyNode);
|
|
1805
|
-
}
|
|
1806
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1807
|
-
ch = state.input.charCodeAt(state.position);
|
|
1808
|
-
if (ch === 44) {
|
|
1809
|
-
readNext = true;
|
|
1810
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1811
|
-
} else {
|
|
1812
|
-
readNext = false;
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1816
|
-
}
|
|
1817
|
-
function readBlockScalar(state, nodeIndent) {
|
|
1818
|
-
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1819
|
-
ch = state.input.charCodeAt(state.position);
|
|
1820
|
-
if (ch === 124) {
|
|
1821
|
-
folding = false;
|
|
1822
|
-
} else if (ch === 62) {
|
|
1823
|
-
folding = true;
|
|
1824
|
-
} else {
|
|
1825
|
-
return false;
|
|
1826
|
-
}
|
|
1827
|
-
state.kind = "scalar";
|
|
1828
|
-
state.result = "";
|
|
1829
|
-
while (ch !== 0) {
|
|
1830
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1831
|
-
if (ch === 43 || ch === 45) {
|
|
1832
|
-
if (CHOMPING_CLIP === chomping) {
|
|
1833
|
-
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1834
|
-
} else {
|
|
1835
|
-
throwError(state, "repeat of a chomping mode identifier");
|
|
1836
|
-
}
|
|
1837
|
-
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1838
|
-
if (tmp === 0) {
|
|
1839
|
-
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1840
|
-
} else if (!detectedIndent) {
|
|
1841
|
-
textIndent = nodeIndent + tmp - 1;
|
|
1842
|
-
detectedIndent = true;
|
|
1843
|
-
} else {
|
|
1844
|
-
throwError(state, "repeat of an indentation width identifier");
|
|
1845
|
-
}
|
|
1846
|
-
} else {
|
|
1847
|
-
break;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1851
|
-
do {
|
|
1852
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1853
|
-
} while (is_WHITE_SPACE(ch));
|
|
1854
|
-
if (ch === 35) {
|
|
1855
|
-
do {
|
|
1856
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1857
|
-
} while (!is_EOL(ch) && ch !== 0);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
while (ch !== 0) {
|
|
1861
|
-
readLineBreak(state);
|
|
1862
|
-
state.lineIndent = 0;
|
|
1863
|
-
ch = state.input.charCodeAt(state.position);
|
|
1864
|
-
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1865
|
-
state.lineIndent++;
|
|
1866
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1867
|
-
}
|
|
1868
|
-
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1869
|
-
textIndent = state.lineIndent;
|
|
1870
|
-
}
|
|
1871
|
-
if (is_EOL(ch)) {
|
|
1872
|
-
emptyLines++;
|
|
1873
|
-
continue;
|
|
1874
|
-
}
|
|
1875
|
-
if (state.lineIndent < textIndent) {
|
|
1876
|
-
if (chomping === CHOMPING_KEEP) {
|
|
1877
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1878
|
-
} else if (chomping === CHOMPING_CLIP) {
|
|
1879
|
-
if (didReadContent) {
|
|
1880
|
-
state.result += "\n";
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
break;
|
|
1884
|
-
}
|
|
1885
|
-
if (folding) {
|
|
1886
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1887
|
-
atMoreIndented = true;
|
|
1888
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1889
|
-
} else if (atMoreIndented) {
|
|
1890
|
-
atMoreIndented = false;
|
|
1891
|
-
state.result += common.repeat("\n", emptyLines + 1);
|
|
1892
|
-
} else if (emptyLines === 0) {
|
|
1893
|
-
if (didReadContent) {
|
|
1894
|
-
state.result += " ";
|
|
1895
|
-
}
|
|
1896
|
-
} else {
|
|
1897
|
-
state.result += common.repeat("\n", emptyLines);
|
|
1898
|
-
}
|
|
1899
|
-
} else {
|
|
1900
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1901
|
-
}
|
|
1902
|
-
didReadContent = true;
|
|
1903
|
-
detectedIndent = true;
|
|
1904
|
-
emptyLines = 0;
|
|
1905
|
-
captureStart = state.position;
|
|
1906
|
-
while (!is_EOL(ch) && ch !== 0) {
|
|
1907
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1908
|
-
}
|
|
1909
|
-
captureSegment(state, captureStart, state.position, false);
|
|
1910
|
-
}
|
|
1911
|
-
return true;
|
|
1912
|
-
}
|
|
1913
|
-
function readBlockSequence(state, nodeIndent) {
|
|
1914
|
-
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1915
|
-
if (state.anchor !== null) {
|
|
1916
|
-
state.anchorMap[state.anchor] = _result;
|
|
1917
|
-
}
|
|
1918
|
-
ch = state.input.charCodeAt(state.position);
|
|
1919
|
-
while (ch !== 0) {
|
|
1920
|
-
if (ch !== 45) {
|
|
1921
|
-
break;
|
|
1922
|
-
}
|
|
1923
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1924
|
-
if (!is_WS_OR_EOL(following)) {
|
|
1925
|
-
break;
|
|
1926
|
-
}
|
|
1927
|
-
detected = true;
|
|
1928
|
-
state.position++;
|
|
1929
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1930
|
-
if (state.lineIndent <= nodeIndent) {
|
|
1931
|
-
_result.push(null);
|
|
1932
|
-
ch = state.input.charCodeAt(state.position);
|
|
1933
|
-
continue;
|
|
1934
|
-
}
|
|
1935
|
-
}
|
|
1936
|
-
_line = state.line;
|
|
1937
|
-
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1938
|
-
_result.push(state.result);
|
|
1939
|
-
skipSeparationSpace(state, true, -1);
|
|
1940
|
-
ch = state.input.charCodeAt(state.position);
|
|
1941
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1942
|
-
throwError(state, "bad indentation of a sequence entry");
|
|
1943
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1944
|
-
break;
|
|
1945
|
-
}
|
|
1946
|
-
}
|
|
1947
|
-
if (detected) {
|
|
1948
|
-
state.tag = _tag;
|
|
1949
|
-
state.anchor = _anchor;
|
|
1950
|
-
state.kind = "sequence";
|
|
1951
|
-
state.result = _result;
|
|
1952
|
-
return true;
|
|
1953
|
-
}
|
|
1954
|
-
return false;
|
|
1955
|
-
}
|
|
1956
|
-
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1957
|
-
var following, allowCompact, _line, _pos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = {}, keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1958
|
-
if (state.anchor !== null) {
|
|
1959
|
-
state.anchorMap[state.anchor] = _result;
|
|
1960
|
-
}
|
|
1961
|
-
ch = state.input.charCodeAt(state.position);
|
|
1962
|
-
while (ch !== 0) {
|
|
1963
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1964
|
-
_line = state.line;
|
|
1965
|
-
_pos = state.position;
|
|
1966
|
-
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1967
|
-
if (ch === 63) {
|
|
1968
|
-
if (atExplicitKey) {
|
|
1969
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
1970
|
-
keyTag = keyNode = valueNode = null;
|
|
1971
|
-
}
|
|
1972
|
-
detected = true;
|
|
1973
|
-
atExplicitKey = true;
|
|
1974
|
-
allowCompact = true;
|
|
1975
|
-
} else if (atExplicitKey) {
|
|
1976
|
-
atExplicitKey = false;
|
|
1977
|
-
allowCompact = true;
|
|
1978
|
-
} else {
|
|
1979
|
-
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1980
|
-
}
|
|
1981
|
-
state.position += 1;
|
|
1982
|
-
ch = following;
|
|
1983
|
-
} else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1984
|
-
if (state.line === _line) {
|
|
1985
|
-
ch = state.input.charCodeAt(state.position);
|
|
1986
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1987
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1988
|
-
}
|
|
1989
|
-
if (ch === 58) {
|
|
1990
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1991
|
-
if (!is_WS_OR_EOL(ch)) {
|
|
1992
|
-
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1993
|
-
}
|
|
1994
|
-
if (atExplicitKey) {
|
|
1995
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
1996
|
-
keyTag = keyNode = valueNode = null;
|
|
1997
|
-
}
|
|
1998
|
-
detected = true;
|
|
1999
|
-
atExplicitKey = false;
|
|
2000
|
-
allowCompact = false;
|
|
2001
|
-
keyTag = state.tag;
|
|
2002
|
-
keyNode = state.result;
|
|
2003
|
-
} else if (detected) {
|
|
2004
|
-
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
2005
|
-
} else {
|
|
2006
|
-
state.tag = _tag;
|
|
2007
|
-
state.anchor = _anchor;
|
|
2008
|
-
return true;
|
|
2009
|
-
}
|
|
2010
|
-
} else if (detected) {
|
|
2011
|
-
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
2012
|
-
} else {
|
|
2013
|
-
state.tag = _tag;
|
|
2014
|
-
state.anchor = _anchor;
|
|
2015
|
-
return true;
|
|
2016
|
-
}
|
|
2017
|
-
} else {
|
|
2018
|
-
break;
|
|
2019
|
-
}
|
|
2020
|
-
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
2021
|
-
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
2022
|
-
if (atExplicitKey) {
|
|
2023
|
-
keyNode = state.result;
|
|
2024
|
-
} else {
|
|
2025
|
-
valueNode = state.result;
|
|
2026
|
-
}
|
|
2027
|
-
}
|
|
2028
|
-
if (!atExplicitKey) {
|
|
2029
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
|
|
2030
|
-
keyTag = keyNode = valueNode = null;
|
|
2031
|
-
}
|
|
2032
|
-
skipSeparationSpace(state, true, -1);
|
|
2033
|
-
ch = state.input.charCodeAt(state.position);
|
|
2034
|
-
}
|
|
2035
|
-
if (state.lineIndent > nodeIndent && ch !== 0) {
|
|
2036
|
-
throwError(state, "bad indentation of a mapping entry");
|
|
2037
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
2038
|
-
break;
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
if (atExplicitKey) {
|
|
2042
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
|
|
2043
|
-
}
|
|
2044
|
-
if (detected) {
|
|
2045
|
-
state.tag = _tag;
|
|
2046
|
-
state.anchor = _anchor;
|
|
2047
|
-
state.kind = "mapping";
|
|
2048
|
-
state.result = _result;
|
|
2049
|
-
}
|
|
2050
|
-
return detected;
|
|
2051
|
-
}
|
|
2052
|
-
function readTagProperty(state) {
|
|
2053
|
-
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
2054
|
-
ch = state.input.charCodeAt(state.position);
|
|
2055
|
-
if (ch !== 33) return false;
|
|
2056
|
-
if (state.tag !== null) {
|
|
2057
|
-
throwError(state, "duplication of a tag property");
|
|
2058
|
-
}
|
|
2059
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2060
|
-
if (ch === 60) {
|
|
2061
|
-
isVerbatim = true;
|
|
2062
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2063
|
-
} else if (ch === 33) {
|
|
2064
|
-
isNamed = true;
|
|
2065
|
-
tagHandle = "!!";
|
|
2066
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2067
|
-
} else {
|
|
2068
|
-
tagHandle = "!";
|
|
2069
|
-
}
|
|
2070
|
-
_position = state.position;
|
|
2071
|
-
if (isVerbatim) {
|
|
2072
|
-
do {
|
|
2073
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2074
|
-
} while (ch !== 0 && ch !== 62);
|
|
2075
|
-
if (state.position < state.length) {
|
|
2076
|
-
tagName = state.input.slice(_position, state.position);
|
|
2077
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2078
|
-
} else {
|
|
2079
|
-
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2080
|
-
}
|
|
2081
|
-
} else {
|
|
2082
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2083
|
-
if (ch === 33) {
|
|
2084
|
-
if (!isNamed) {
|
|
2085
|
-
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2086
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2087
|
-
throwError(state, "named tag handle cannot contain such characters");
|
|
2088
|
-
}
|
|
2089
|
-
isNamed = true;
|
|
2090
|
-
_position = state.position + 1;
|
|
2091
|
-
} else {
|
|
2092
|
-
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2096
|
-
}
|
|
2097
|
-
tagName = state.input.slice(_position, state.position);
|
|
2098
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2099
|
-
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2103
|
-
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
2104
|
-
}
|
|
2105
|
-
if (isVerbatim) {
|
|
2106
|
-
state.tag = tagName;
|
|
2107
|
-
} else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
|
|
2108
|
-
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2109
|
-
} else if (tagHandle === "!") {
|
|
2110
|
-
state.tag = "!" + tagName;
|
|
2111
|
-
} else if (tagHandle === "!!") {
|
|
2112
|
-
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
2113
|
-
} else {
|
|
2114
|
-
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2115
|
-
}
|
|
2116
|
-
return true;
|
|
2117
|
-
}
|
|
2118
|
-
function readAnchorProperty(state) {
|
|
2119
|
-
var _position, ch;
|
|
2120
|
-
ch = state.input.charCodeAt(state.position);
|
|
2121
|
-
if (ch !== 38) return false;
|
|
2122
|
-
if (state.anchor !== null) {
|
|
2123
|
-
throwError(state, "duplication of an anchor property");
|
|
2124
|
-
}
|
|
2125
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2126
|
-
_position = state.position;
|
|
2127
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2128
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2129
|
-
}
|
|
2130
|
-
if (state.position === _position) {
|
|
2131
|
-
throwError(state, "name of an anchor node must contain at least one character");
|
|
2132
|
-
}
|
|
2133
|
-
state.anchor = state.input.slice(_position, state.position);
|
|
2134
|
-
return true;
|
|
2135
|
-
}
|
|
2136
|
-
function readAlias(state) {
|
|
2137
|
-
var _position, alias, ch;
|
|
2138
|
-
ch = state.input.charCodeAt(state.position);
|
|
2139
|
-
if (ch !== 42) return false;
|
|
2140
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2141
|
-
_position = state.position;
|
|
2142
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2143
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2144
|
-
}
|
|
2145
|
-
if (state.position === _position) {
|
|
2146
|
-
throwError(state, "name of an alias node must contain at least one character");
|
|
2147
|
-
}
|
|
2148
|
-
alias = state.input.slice(_position, state.position);
|
|
2149
|
-
if (!_hasOwnProperty.call(state.anchorMap, alias)) {
|
|
2150
|
-
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2151
|
-
}
|
|
2152
|
-
state.result = state.anchorMap[alias];
|
|
2153
|
-
skipSeparationSpace(state, true, -1);
|
|
2154
|
-
return true;
|
|
2155
|
-
}
|
|
2156
|
-
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2157
|
-
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, type, flowIndent, blockIndent;
|
|
2158
|
-
if (state.listener !== null) {
|
|
2159
|
-
state.listener("open", state);
|
|
2160
|
-
}
|
|
2161
|
-
state.tag = null;
|
|
2162
|
-
state.anchor = null;
|
|
2163
|
-
state.kind = null;
|
|
2164
|
-
state.result = null;
|
|
2165
|
-
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2166
|
-
if (allowToSeek) {
|
|
2167
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2168
|
-
atNewLine = true;
|
|
2169
|
-
if (state.lineIndent > parentIndent) {
|
|
2170
|
-
indentStatus = 1;
|
|
2171
|
-
} else if (state.lineIndent === parentIndent) {
|
|
2172
|
-
indentStatus = 0;
|
|
2173
|
-
} else if (state.lineIndent < parentIndent) {
|
|
2174
|
-
indentStatus = -1;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
if (indentStatus === 1) {
|
|
2179
|
-
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2180
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2181
|
-
atNewLine = true;
|
|
2182
|
-
allowBlockCollections = allowBlockStyles;
|
|
2183
|
-
if (state.lineIndent > parentIndent) {
|
|
2184
|
-
indentStatus = 1;
|
|
2185
|
-
} else if (state.lineIndent === parentIndent) {
|
|
2186
|
-
indentStatus = 0;
|
|
2187
|
-
} else if (state.lineIndent < parentIndent) {
|
|
2188
|
-
indentStatus = -1;
|
|
2189
|
-
}
|
|
2190
|
-
} else {
|
|
2191
|
-
allowBlockCollections = false;
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
}
|
|
2195
|
-
if (allowBlockCollections) {
|
|
2196
|
-
allowBlockCollections = atNewLine || allowCompact;
|
|
2197
|
-
}
|
|
2198
|
-
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2199
|
-
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2200
|
-
flowIndent = parentIndent;
|
|
2201
|
-
} else {
|
|
2202
|
-
flowIndent = parentIndent + 1;
|
|
2203
|
-
}
|
|
2204
|
-
blockIndent = state.position - state.lineStart;
|
|
2205
|
-
if (indentStatus === 1) {
|
|
2206
|
-
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2207
|
-
hasContent = true;
|
|
2208
|
-
} else {
|
|
2209
|
-
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2210
|
-
hasContent = true;
|
|
2211
|
-
} else if (readAlias(state)) {
|
|
2212
|
-
hasContent = true;
|
|
2213
|
-
if (state.tag !== null || state.anchor !== null) {
|
|
2214
|
-
throwError(state, "alias node should not have any properties");
|
|
2215
|
-
}
|
|
2216
|
-
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2217
|
-
hasContent = true;
|
|
2218
|
-
if (state.tag === null) {
|
|
2219
|
-
state.tag = "?";
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
|
-
if (state.anchor !== null) {
|
|
2223
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2224
|
-
}
|
|
2225
|
-
}
|
|
2226
|
-
} else if (indentStatus === 0) {
|
|
2227
|
-
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
if (state.tag !== null && state.tag !== "!") {
|
|
2231
|
-
if (state.tag === "?") {
|
|
2232
|
-
if (state.result !== null && state.kind !== "scalar") {
|
|
2233
|
-
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2234
|
-
}
|
|
2235
|
-
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2236
|
-
type = state.implicitTypes[typeIndex];
|
|
2237
|
-
if (type.resolve(state.result)) {
|
|
2238
|
-
state.result = type.construct(state.result);
|
|
2239
|
-
state.tag = type.tag;
|
|
2240
|
-
if (state.anchor !== null) {
|
|
2241
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2242
|
-
}
|
|
2243
|
-
break;
|
|
2244
|
-
}
|
|
2245
|
-
}
|
|
2246
|
-
} else if (_hasOwnProperty.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2247
|
-
type = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2248
|
-
if (state.result !== null && type.kind !== state.kind) {
|
|
2249
|
-
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
|
|
2250
|
-
}
|
|
2251
|
-
if (!type.resolve(state.result)) {
|
|
2252
|
-
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2253
|
-
} else {
|
|
2254
|
-
state.result = type.construct(state.result);
|
|
2255
|
-
if (state.anchor !== null) {
|
|
2256
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
} else {
|
|
2260
|
-
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
if (state.listener !== null) {
|
|
2264
|
-
state.listener("close", state);
|
|
2265
|
-
}
|
|
2266
|
-
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2267
|
-
}
|
|
2268
|
-
function readDocument(state) {
|
|
2269
|
-
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2270
|
-
state.version = null;
|
|
2271
|
-
state.checkLineBreaks = state.legacy;
|
|
2272
|
-
state.tagMap = {};
|
|
2273
|
-
state.anchorMap = {};
|
|
2274
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2275
|
-
skipSeparationSpace(state, true, -1);
|
|
2276
|
-
ch = state.input.charCodeAt(state.position);
|
|
2277
|
-
if (state.lineIndent > 0 || ch !== 37) {
|
|
2278
|
-
break;
|
|
2279
|
-
}
|
|
2280
|
-
hasDirectives = true;
|
|
2281
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2282
|
-
_position = state.position;
|
|
2283
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2284
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2285
|
-
}
|
|
2286
|
-
directiveName = state.input.slice(_position, state.position);
|
|
2287
|
-
directiveArgs = [];
|
|
2288
|
-
if (directiveName.length < 1) {
|
|
2289
|
-
throwError(state, "directive name must not be less than one character in length");
|
|
2290
|
-
}
|
|
2291
|
-
while (ch !== 0) {
|
|
2292
|
-
while (is_WHITE_SPACE(ch)) {
|
|
2293
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2294
|
-
}
|
|
2295
|
-
if (ch === 35) {
|
|
2296
|
-
do {
|
|
2297
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2298
|
-
} while (ch !== 0 && !is_EOL(ch));
|
|
2299
|
-
break;
|
|
2300
|
-
}
|
|
2301
|
-
if (is_EOL(ch)) break;
|
|
2302
|
-
_position = state.position;
|
|
2303
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2304
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2305
|
-
}
|
|
2306
|
-
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2307
|
-
}
|
|
2308
|
-
if (ch !== 0) readLineBreak(state);
|
|
2309
|
-
if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
|
|
2310
|
-
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2311
|
-
} else {
|
|
2312
|
-
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2313
|
-
}
|
|
2314
|
-
}
|
|
2315
|
-
skipSeparationSpace(state, true, -1);
|
|
2316
|
-
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2317
|
-
state.position += 3;
|
|
2318
|
-
skipSeparationSpace(state, true, -1);
|
|
2319
|
-
} else if (hasDirectives) {
|
|
2320
|
-
throwError(state, "directives end mark is expected");
|
|
2321
|
-
}
|
|
2322
|
-
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2323
|
-
skipSeparationSpace(state, true, -1);
|
|
2324
|
-
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2325
|
-
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2326
|
-
}
|
|
2327
|
-
state.documents.push(state.result);
|
|
2328
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2329
|
-
if (state.input.charCodeAt(state.position) === 46) {
|
|
2330
|
-
state.position += 3;
|
|
2331
|
-
skipSeparationSpace(state, true, -1);
|
|
2332
|
-
}
|
|
2333
|
-
return;
|
|
2334
|
-
}
|
|
2335
|
-
if (state.position < state.length - 1) {
|
|
2336
|
-
throwError(state, "end of the stream or a document separator is expected");
|
|
2337
|
-
} else {
|
|
2338
|
-
return;
|
|
2339
|
-
}
|
|
2340
|
-
}
|
|
2341
|
-
function loadDocuments(input, options2) {
|
|
2342
|
-
input = String(input);
|
|
2343
|
-
options2 = options2 || {};
|
|
2344
|
-
if (input.length !== 0) {
|
|
2345
|
-
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2346
|
-
input += "\n";
|
|
2347
|
-
}
|
|
2348
|
-
if (input.charCodeAt(0) === 65279) {
|
|
2349
|
-
input = input.slice(1);
|
|
2350
|
-
}
|
|
2351
|
-
}
|
|
2352
|
-
var state = new State(input, options2);
|
|
2353
|
-
var nullpos = input.indexOf("\0");
|
|
2354
|
-
if (nullpos !== -1) {
|
|
2355
|
-
state.position = nullpos;
|
|
2356
|
-
throwError(state, "null byte is not allowed in input");
|
|
2357
|
-
}
|
|
2358
|
-
state.input += "\0";
|
|
2359
|
-
while (state.input.charCodeAt(state.position) === 32) {
|
|
2360
|
-
state.lineIndent += 1;
|
|
2361
|
-
state.position += 1;
|
|
2362
|
-
}
|
|
2363
|
-
while (state.position < state.length - 1) {
|
|
2364
|
-
readDocument(state);
|
|
2365
|
-
}
|
|
2366
|
-
return state.documents;
|
|
2367
|
-
}
|
|
2368
|
-
function loadAll(input, iterator, options2) {
|
|
2369
|
-
if (iterator !== null && typeof iterator === "object" && typeof options2 === "undefined") {
|
|
2370
|
-
options2 = iterator;
|
|
2371
|
-
iterator = null;
|
|
2372
|
-
}
|
|
2373
|
-
var documents = loadDocuments(input, options2);
|
|
2374
|
-
if (typeof iterator !== "function") {
|
|
2375
|
-
return documents;
|
|
2376
|
-
}
|
|
2377
|
-
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
2378
|
-
iterator(documents[index]);
|
|
2379
|
-
}
|
|
2380
|
-
}
|
|
2381
|
-
function load(input, options2) {
|
|
2382
|
-
var documents = loadDocuments(input, options2);
|
|
2383
|
-
if (documents.length === 0) {
|
|
2384
|
-
return void 0;
|
|
2385
|
-
} else if (documents.length === 1) {
|
|
2386
|
-
return documents[0];
|
|
2387
|
-
}
|
|
2388
|
-
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2389
|
-
}
|
|
2390
|
-
function safeLoadAll(input, iterator, options2) {
|
|
2391
|
-
if (typeof iterator === "object" && iterator !== null && typeof options2 === "undefined") {
|
|
2392
|
-
options2 = iterator;
|
|
2393
|
-
iterator = null;
|
|
2394
|
-
}
|
|
2395
|
-
return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options2));
|
|
2396
|
-
}
|
|
2397
|
-
function safeLoad(input, options2) {
|
|
2398
|
-
return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options2));
|
|
2399
|
-
}
|
|
2400
|
-
module2.exports.loadAll = loadAll;
|
|
2401
|
-
module2.exports.load = load;
|
|
2402
|
-
module2.exports.safeLoadAll = safeLoadAll;
|
|
2403
|
-
module2.exports.safeLoad = safeLoad;
|
|
2404
|
-
}
|
|
2405
|
-
});
|
|
2406
|
-
|
|
2407
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/dumper.js
|
|
2408
|
-
var require_dumper = __commonJS({
|
|
2409
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml/dumper.js"(exports2, module2) {
|
|
2410
|
-
"use strict";
|
|
2411
|
-
var common = require_common();
|
|
2412
|
-
var YAMLException = require_exception();
|
|
2413
|
-
var DEFAULT_FULL_SCHEMA = require_default_full();
|
|
2414
|
-
var DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
2415
|
-
var _toString = Object.prototype.toString;
|
|
2416
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2417
|
-
var CHAR_TAB = 9;
|
|
2418
|
-
var CHAR_LINE_FEED = 10;
|
|
2419
|
-
var CHAR_CARRIAGE_RETURN = 13;
|
|
2420
|
-
var CHAR_SPACE = 32;
|
|
2421
|
-
var CHAR_EXCLAMATION = 33;
|
|
2422
|
-
var CHAR_DOUBLE_QUOTE = 34;
|
|
2423
|
-
var CHAR_SHARP = 35;
|
|
2424
|
-
var CHAR_PERCENT = 37;
|
|
2425
|
-
var CHAR_AMPERSAND = 38;
|
|
2426
|
-
var CHAR_SINGLE_QUOTE = 39;
|
|
2427
|
-
var CHAR_ASTERISK = 42;
|
|
2428
|
-
var CHAR_COMMA = 44;
|
|
2429
|
-
var CHAR_MINUS = 45;
|
|
2430
|
-
var CHAR_COLON = 58;
|
|
2431
|
-
var CHAR_EQUALS = 61;
|
|
2432
|
-
var CHAR_GREATER_THAN = 62;
|
|
2433
|
-
var CHAR_QUESTION = 63;
|
|
2434
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
2435
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2436
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2437
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
2438
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2439
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
2440
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2441
|
-
var ESCAPE_SEQUENCES = {};
|
|
2442
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2443
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2444
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2445
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2446
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2447
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2448
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2449
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2450
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2451
|
-
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2452
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2453
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2454
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2455
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2456
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2457
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2458
|
-
"y",
|
|
2459
|
-
"Y",
|
|
2460
|
-
"yes",
|
|
2461
|
-
"Yes",
|
|
2462
|
-
"YES",
|
|
2463
|
-
"on",
|
|
2464
|
-
"On",
|
|
2465
|
-
"ON",
|
|
2466
|
-
"n",
|
|
2467
|
-
"N",
|
|
2468
|
-
"no",
|
|
2469
|
-
"No",
|
|
2470
|
-
"NO",
|
|
2471
|
-
"off",
|
|
2472
|
-
"Off",
|
|
2473
|
-
"OFF"
|
|
2474
|
-
];
|
|
2475
|
-
function compileStyleMap(schema, map) {
|
|
2476
|
-
var result, keys, index, length, tag, style, type;
|
|
2477
|
-
if (map === null) return {};
|
|
2478
|
-
result = {};
|
|
2479
|
-
keys = Object.keys(map);
|
|
2480
|
-
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2481
|
-
tag = keys[index];
|
|
2482
|
-
style = String(map[tag]);
|
|
2483
|
-
if (tag.slice(0, 2) === "!!") {
|
|
2484
|
-
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2485
|
-
}
|
|
2486
|
-
type = schema.compiledTypeMap["fallback"][tag];
|
|
2487
|
-
if (type && _hasOwnProperty.call(type.styleAliases, style)) {
|
|
2488
|
-
style = type.styleAliases[style];
|
|
2489
|
-
}
|
|
2490
|
-
result[tag] = style;
|
|
2491
|
-
}
|
|
2492
|
-
return result;
|
|
2493
|
-
}
|
|
2494
|
-
function encodeHex(character) {
|
|
2495
|
-
var string, handle, length;
|
|
2496
|
-
string = character.toString(16).toUpperCase();
|
|
2497
|
-
if (character <= 255) {
|
|
2498
|
-
handle = "x";
|
|
2499
|
-
length = 2;
|
|
2500
|
-
} else if (character <= 65535) {
|
|
2501
|
-
handle = "u";
|
|
2502
|
-
length = 4;
|
|
2503
|
-
} else if (character <= 4294967295) {
|
|
2504
|
-
handle = "U";
|
|
2505
|
-
length = 8;
|
|
2506
|
-
} else {
|
|
2507
|
-
throw new YAMLException("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2508
|
-
}
|
|
2509
|
-
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2510
|
-
}
|
|
2511
|
-
function State(options2) {
|
|
2512
|
-
this.schema = options2["schema"] || DEFAULT_FULL_SCHEMA;
|
|
2513
|
-
this.indent = Math.max(1, options2["indent"] || 2);
|
|
2514
|
-
this.noArrayIndent = options2["noArrayIndent"] || false;
|
|
2515
|
-
this.skipInvalid = options2["skipInvalid"] || false;
|
|
2516
|
-
this.flowLevel = common.isNothing(options2["flowLevel"]) ? -1 : options2["flowLevel"];
|
|
2517
|
-
this.styleMap = compileStyleMap(this.schema, options2["styles"] || null);
|
|
2518
|
-
this.sortKeys = options2["sortKeys"] || false;
|
|
2519
|
-
this.lineWidth = options2["lineWidth"] || 80;
|
|
2520
|
-
this.noRefs = options2["noRefs"] || false;
|
|
2521
|
-
this.noCompatMode = options2["noCompatMode"] || false;
|
|
2522
|
-
this.condenseFlow = options2["condenseFlow"] || false;
|
|
2523
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
2524
|
-
this.explicitTypes = this.schema.compiledExplicit;
|
|
2525
|
-
this.tag = null;
|
|
2526
|
-
this.result = "";
|
|
2527
|
-
this.duplicates = [];
|
|
2528
|
-
this.usedDuplicates = null;
|
|
2529
|
-
}
|
|
2530
|
-
function indentString(string, spaces) {
|
|
2531
|
-
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2532
|
-
while (position < length) {
|
|
2533
|
-
next = string.indexOf("\n", position);
|
|
2534
|
-
if (next === -1) {
|
|
2535
|
-
line = string.slice(position);
|
|
2536
|
-
position = length;
|
|
2537
|
-
} else {
|
|
2538
|
-
line = string.slice(position, next + 1);
|
|
2539
|
-
position = next + 1;
|
|
2540
|
-
}
|
|
2541
|
-
if (line.length && line !== "\n") result += ind;
|
|
2542
|
-
result += line;
|
|
2543
|
-
}
|
|
2544
|
-
return result;
|
|
2545
|
-
}
|
|
2546
|
-
function generateNextLine(state, level) {
|
|
2547
|
-
return "\n" + common.repeat(" ", state.indent * level);
|
|
2548
|
-
}
|
|
2549
|
-
function testImplicitResolving(state, str2) {
|
|
2550
|
-
var index, length, type;
|
|
2551
|
-
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2552
|
-
type = state.implicitTypes[index];
|
|
2553
|
-
if (type.resolve(str2)) {
|
|
2554
|
-
return true;
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
return false;
|
|
2558
|
-
}
|
|
2559
|
-
function isWhitespace(c) {
|
|
2560
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2561
|
-
}
|
|
2562
|
-
function isPrintable(c) {
|
|
2563
|
-
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== 65279 || 65536 <= c && c <= 1114111;
|
|
2564
|
-
}
|
|
2565
|
-
function isNsChar(c) {
|
|
2566
|
-
return isPrintable(c) && !isWhitespace(c) && c !== 65279 && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2567
|
-
}
|
|
2568
|
-
function isPlainSafe(c, prev) {
|
|
2569
|
-
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));
|
|
2570
|
-
}
|
|
2571
|
-
function isPlainSafeFirst(c) {
|
|
2572
|
-
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;
|
|
2573
|
-
}
|
|
2574
|
-
function needIndentIndicator(string) {
|
|
2575
|
-
var leadingSpaceRe = /^\n* /;
|
|
2576
|
-
return leadingSpaceRe.test(string);
|
|
2577
|
-
}
|
|
2578
|
-
var STYLE_PLAIN = 1;
|
|
2579
|
-
var STYLE_SINGLE = 2;
|
|
2580
|
-
var STYLE_LITERAL = 3;
|
|
2581
|
-
var STYLE_FOLDED = 4;
|
|
2582
|
-
var STYLE_DOUBLE = 5;
|
|
2583
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
|
|
2584
|
-
var i;
|
|
2585
|
-
var char, prev_char;
|
|
2586
|
-
var hasLineBreak = false;
|
|
2587
|
-
var hasFoldableLine = false;
|
|
2588
|
-
var shouldTrackWidth = lineWidth !== -1;
|
|
2589
|
-
var previousLineBreak = -1;
|
|
2590
|
-
var plain = isPlainSafeFirst(string.charCodeAt(0)) && !isWhitespace(string.charCodeAt(string.length - 1));
|
|
2591
|
-
if (singleLineOnly) {
|
|
2592
|
-
for (i = 0; i < string.length; i++) {
|
|
2593
|
-
char = string.charCodeAt(i);
|
|
2594
|
-
if (!isPrintable(char)) {
|
|
2595
|
-
return STYLE_DOUBLE;
|
|
2596
|
-
}
|
|
2597
|
-
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
|
2598
|
-
plain = plain && isPlainSafe(char, prev_char);
|
|
2599
|
-
}
|
|
2600
|
-
} else {
|
|
2601
|
-
for (i = 0; i < string.length; i++) {
|
|
2602
|
-
char = string.charCodeAt(i);
|
|
2603
|
-
if (char === CHAR_LINE_FEED) {
|
|
2604
|
-
hasLineBreak = true;
|
|
2605
|
-
if (shouldTrackWidth) {
|
|
2606
|
-
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2607
|
-
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2608
|
-
previousLineBreak = i;
|
|
2609
|
-
}
|
|
2610
|
-
} else if (!isPrintable(char)) {
|
|
2611
|
-
return STYLE_DOUBLE;
|
|
2612
|
-
}
|
|
2613
|
-
prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
|
|
2614
|
-
plain = plain && isPlainSafe(char, prev_char);
|
|
2615
|
-
}
|
|
2616
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2617
|
-
}
|
|
2618
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2619
|
-
return plain && !testAmbiguousType(string) ? STYLE_PLAIN : STYLE_SINGLE;
|
|
2620
|
-
}
|
|
2621
|
-
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2622
|
-
return STYLE_DOUBLE;
|
|
2623
|
-
}
|
|
2624
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2625
|
-
}
|
|
2626
|
-
function writeScalar(state, string, level, iskey) {
|
|
2627
|
-
state.dump = function() {
|
|
2628
|
-
if (string.length === 0) {
|
|
2629
|
-
return "''";
|
|
2630
|
-
}
|
|
2631
|
-
if (!state.noCompatMode && DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
|
|
2632
|
-
return "'" + string + "'";
|
|
2633
|
-
}
|
|
2634
|
-
var indent = state.indent * Math.max(1, level);
|
|
2635
|
-
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2636
|
-
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2637
|
-
function testAmbiguity(string2) {
|
|
2638
|
-
return testImplicitResolving(state, string2);
|
|
2639
|
-
}
|
|
2640
|
-
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
|
|
2641
|
-
case STYLE_PLAIN:
|
|
2642
|
-
return string;
|
|
2643
|
-
case STYLE_SINGLE:
|
|
2644
|
-
return "'" + string.replace(/'/g, "''") + "'";
|
|
2645
|
-
case STYLE_LITERAL:
|
|
2646
|
-
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2647
|
-
case STYLE_FOLDED:
|
|
2648
|
-
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2649
|
-
case STYLE_DOUBLE:
|
|
2650
|
-
return '"' + escapeString(string, lineWidth) + '"';
|
|
2651
|
-
default:
|
|
2652
|
-
throw new YAMLException("impossible error: invalid scalar style");
|
|
2653
|
-
}
|
|
2654
|
-
}();
|
|
2655
|
-
}
|
|
2656
|
-
function blockHeader(string, indentPerLevel) {
|
|
2657
|
-
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2658
|
-
var clip = string[string.length - 1] === "\n";
|
|
2659
|
-
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
2660
|
-
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2661
|
-
return indentIndicator + chomp + "\n";
|
|
2662
|
-
}
|
|
2663
|
-
function dropEndingNewline(string) {
|
|
2664
|
-
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2665
|
-
}
|
|
2666
|
-
function foldString(string, width) {
|
|
2667
|
-
var lineRe = /(\n+)([^\n]*)/g;
|
|
2668
|
-
var result = function() {
|
|
2669
|
-
var nextLF = string.indexOf("\n");
|
|
2670
|
-
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2671
|
-
lineRe.lastIndex = nextLF;
|
|
2672
|
-
return foldLine(string.slice(0, nextLF), width);
|
|
2673
|
-
}();
|
|
2674
|
-
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2675
|
-
var moreIndented;
|
|
2676
|
-
var match;
|
|
2677
|
-
while (match = lineRe.exec(string)) {
|
|
2678
|
-
var prefix = match[1], line = match[2];
|
|
2679
|
-
moreIndented = line[0] === " ";
|
|
2680
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2681
|
-
prevMoreIndented = moreIndented;
|
|
2682
|
-
}
|
|
2683
|
-
return result;
|
|
2684
|
-
}
|
|
2685
|
-
function foldLine(line, width) {
|
|
2686
|
-
if (line === "" || line[0] === " ") return line;
|
|
2687
|
-
var breakRe = / [^ ]/g;
|
|
2688
|
-
var match;
|
|
2689
|
-
var start = 0, end, curr = 0, next = 0;
|
|
2690
|
-
var result = "";
|
|
2691
|
-
while (match = breakRe.exec(line)) {
|
|
2692
|
-
next = match.index;
|
|
2693
|
-
if (next - start > width) {
|
|
2694
|
-
end = curr > start ? curr : next;
|
|
2695
|
-
result += "\n" + line.slice(start, end);
|
|
2696
|
-
start = end + 1;
|
|
2697
|
-
}
|
|
2698
|
-
curr = next;
|
|
2699
|
-
}
|
|
2700
|
-
result += "\n";
|
|
2701
|
-
if (line.length - start > width && curr > start) {
|
|
2702
|
-
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2703
|
-
} else {
|
|
2704
|
-
result += line.slice(start);
|
|
2705
|
-
}
|
|
2706
|
-
return result.slice(1);
|
|
2707
|
-
}
|
|
2708
|
-
function escapeString(string) {
|
|
2709
|
-
var result = "";
|
|
2710
|
-
var char, nextChar;
|
|
2711
|
-
var escapeSeq;
|
|
2712
|
-
for (var i = 0; i < string.length; i++) {
|
|
2713
|
-
char = string.charCodeAt(i);
|
|
2714
|
-
if (char >= 55296 && char <= 56319) {
|
|
2715
|
-
nextChar = string.charCodeAt(i + 1);
|
|
2716
|
-
if (nextChar >= 56320 && nextChar <= 57343) {
|
|
2717
|
-
result += encodeHex((char - 55296) * 1024 + nextChar - 56320 + 65536);
|
|
2718
|
-
i++;
|
|
2719
|
-
continue;
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2723
|
-
result += !escapeSeq && isPrintable(char) ? string[i] : escapeSeq || encodeHex(char);
|
|
2724
|
-
}
|
|
2725
|
-
return result;
|
|
2726
|
-
}
|
|
2727
|
-
function writeFlowSequence(state, level, object) {
|
|
2728
|
-
var _result = "", _tag = state.tag, index, length;
|
|
2729
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2730
|
-
if (writeNode(state, level, object[index], false, false)) {
|
|
2731
|
-
if (index !== 0) _result += "," + (!state.condenseFlow ? " " : "");
|
|
2732
|
-
_result += state.dump;
|
|
2733
|
-
}
|
|
2734
|
-
}
|
|
2735
|
-
state.tag = _tag;
|
|
2736
|
-
state.dump = "[" + _result + "]";
|
|
2737
|
-
}
|
|
2738
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
2739
|
-
var _result = "", _tag = state.tag, index, length;
|
|
2740
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2741
|
-
if (writeNode(state, level + 1, object[index], true, true)) {
|
|
2742
|
-
if (!compact || index !== 0) {
|
|
2743
|
-
_result += generateNextLine(state, level);
|
|
2744
|
-
}
|
|
2745
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2746
|
-
_result += "-";
|
|
2747
|
-
} else {
|
|
2748
|
-
_result += "- ";
|
|
2749
|
-
}
|
|
2750
|
-
_result += state.dump;
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
state.tag = _tag;
|
|
2754
|
-
state.dump = _result || "[]";
|
|
2755
|
-
}
|
|
2756
|
-
function writeFlowMapping(state, level, object) {
|
|
2757
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2758
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2759
|
-
pairBuffer = "";
|
|
2760
|
-
if (index !== 0) pairBuffer += ", ";
|
|
2761
|
-
if (state.condenseFlow) pairBuffer += '"';
|
|
2762
|
-
objectKey = objectKeyList[index];
|
|
2763
|
-
objectValue = object[objectKey];
|
|
2764
|
-
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2765
|
-
continue;
|
|
2766
|
-
}
|
|
2767
|
-
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2768
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2769
|
-
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2770
|
-
continue;
|
|
2771
|
-
}
|
|
2772
|
-
pairBuffer += state.dump;
|
|
2773
|
-
_result += pairBuffer;
|
|
2774
|
-
}
|
|
2775
|
-
state.tag = _tag;
|
|
2776
|
-
state.dump = "{" + _result + "}";
|
|
2777
|
-
}
|
|
2778
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
2779
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2780
|
-
if (state.sortKeys === true) {
|
|
2781
|
-
objectKeyList.sort();
|
|
2782
|
-
} else if (typeof state.sortKeys === "function") {
|
|
2783
|
-
objectKeyList.sort(state.sortKeys);
|
|
2784
|
-
} else if (state.sortKeys) {
|
|
2785
|
-
throw new YAMLException("sortKeys must be a boolean or a function");
|
|
2786
|
-
}
|
|
2787
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2788
|
-
pairBuffer = "";
|
|
2789
|
-
if (!compact || index !== 0) {
|
|
2790
|
-
pairBuffer += generateNextLine(state, level);
|
|
2791
|
-
}
|
|
2792
|
-
objectKey = objectKeyList[index];
|
|
2793
|
-
objectValue = object[objectKey];
|
|
2794
|
-
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2795
|
-
continue;
|
|
2796
|
-
}
|
|
2797
|
-
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2798
|
-
if (explicitPair) {
|
|
2799
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2800
|
-
pairBuffer += "?";
|
|
2801
|
-
} else {
|
|
2802
|
-
pairBuffer += "? ";
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
pairBuffer += state.dump;
|
|
2806
|
-
if (explicitPair) {
|
|
2807
|
-
pairBuffer += generateNextLine(state, level);
|
|
2808
|
-
}
|
|
2809
|
-
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2810
|
-
continue;
|
|
2811
|
-
}
|
|
2812
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2813
|
-
pairBuffer += ":";
|
|
2814
|
-
} else {
|
|
2815
|
-
pairBuffer += ": ";
|
|
2816
|
-
}
|
|
2817
|
-
pairBuffer += state.dump;
|
|
2818
|
-
_result += pairBuffer;
|
|
2819
|
-
}
|
|
2820
|
-
state.tag = _tag;
|
|
2821
|
-
state.dump = _result || "{}";
|
|
2822
|
-
}
|
|
2823
|
-
function detectType(state, object, explicit) {
|
|
2824
|
-
var _result, typeList, index, length, type, style;
|
|
2825
|
-
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2826
|
-
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2827
|
-
type = typeList[index];
|
|
2828
|
-
if ((type.instanceOf || type.predicate) && (!type.instanceOf || typeof object === "object" && object instanceof type.instanceOf) && (!type.predicate || type.predicate(object))) {
|
|
2829
|
-
state.tag = explicit ? type.tag : "?";
|
|
2830
|
-
if (type.represent) {
|
|
2831
|
-
style = state.styleMap[type.tag] || type.defaultStyle;
|
|
2832
|
-
if (_toString.call(type.represent) === "[object Function]") {
|
|
2833
|
-
_result = type.represent(object, style);
|
|
2834
|
-
} else if (_hasOwnProperty.call(type.represent, style)) {
|
|
2835
|
-
_result = type.represent[style](object, style);
|
|
2836
|
-
} else {
|
|
2837
|
-
throw new YAMLException("!<" + type.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2838
|
-
}
|
|
2839
|
-
state.dump = _result;
|
|
2840
|
-
}
|
|
2841
|
-
return true;
|
|
2842
|
-
}
|
|
2843
|
-
}
|
|
2844
|
-
return false;
|
|
2845
|
-
}
|
|
2846
|
-
function writeNode(state, level, object, block, compact, iskey) {
|
|
2847
|
-
state.tag = null;
|
|
2848
|
-
state.dump = object;
|
|
2849
|
-
if (!detectType(state, object, false)) {
|
|
2850
|
-
detectType(state, object, true);
|
|
2851
|
-
}
|
|
2852
|
-
var type = _toString.call(state.dump);
|
|
2853
|
-
if (block) {
|
|
2854
|
-
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2855
|
-
}
|
|
2856
|
-
var objectOrArray = type === "[object Object]" || type === "[object Array]", duplicateIndex, duplicate;
|
|
2857
|
-
if (objectOrArray) {
|
|
2858
|
-
duplicateIndex = state.duplicates.indexOf(object);
|
|
2859
|
-
duplicate = duplicateIndex !== -1;
|
|
2860
|
-
}
|
|
2861
|
-
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2862
|
-
compact = false;
|
|
2863
|
-
}
|
|
2864
|
-
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2865
|
-
state.dump = "*ref_" + duplicateIndex;
|
|
2866
|
-
} else {
|
|
2867
|
-
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2868
|
-
state.usedDuplicates[duplicateIndex] = true;
|
|
2869
|
-
}
|
|
2870
|
-
if (type === "[object Object]") {
|
|
2871
|
-
if (block && Object.keys(state.dump).length !== 0) {
|
|
2872
|
-
writeBlockMapping(state, level, state.dump, compact);
|
|
2873
|
-
if (duplicate) {
|
|
2874
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2875
|
-
}
|
|
2876
|
-
} else {
|
|
2877
|
-
writeFlowMapping(state, level, state.dump);
|
|
2878
|
-
if (duplicate) {
|
|
2879
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
} else if (type === "[object Array]") {
|
|
2883
|
-
var arrayLevel = state.noArrayIndent && level > 0 ? level - 1 : level;
|
|
2884
|
-
if (block && state.dump.length !== 0) {
|
|
2885
|
-
writeBlockSequence(state, arrayLevel, state.dump, compact);
|
|
2886
|
-
if (duplicate) {
|
|
2887
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2888
|
-
}
|
|
2889
|
-
} else {
|
|
2890
|
-
writeFlowSequence(state, arrayLevel, state.dump);
|
|
2891
|
-
if (duplicate) {
|
|
2892
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
} else if (type === "[object String]") {
|
|
2896
|
-
if (state.tag !== "?") {
|
|
2897
|
-
writeScalar(state, state.dump, level, iskey);
|
|
2898
|
-
}
|
|
2899
|
-
} else {
|
|
2900
|
-
if (state.skipInvalid) return false;
|
|
2901
|
-
throw new YAMLException("unacceptable kind of an object to dump " + type);
|
|
2902
|
-
}
|
|
2903
|
-
if (state.tag !== null && state.tag !== "?") {
|
|
2904
|
-
state.dump = "!<" + state.tag + "> " + state.dump;
|
|
2905
|
-
}
|
|
2906
|
-
}
|
|
2907
|
-
return true;
|
|
2908
|
-
}
|
|
2909
|
-
function getDuplicateReferences(object, state) {
|
|
2910
|
-
var objects = [], duplicatesIndexes = [], index, length;
|
|
2911
|
-
inspectNode(object, objects, duplicatesIndexes);
|
|
2912
|
-
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2913
|
-
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2914
|
-
}
|
|
2915
|
-
state.usedDuplicates = new Array(length);
|
|
2916
|
-
}
|
|
2917
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2918
|
-
var objectKeyList, index, length;
|
|
2919
|
-
if (object !== null && typeof object === "object") {
|
|
2920
|
-
index = objects.indexOf(object);
|
|
2921
|
-
if (index !== -1) {
|
|
2922
|
-
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2923
|
-
duplicatesIndexes.push(index);
|
|
2924
|
-
}
|
|
2925
|
-
} else {
|
|
2926
|
-
objects.push(object);
|
|
2927
|
-
if (Array.isArray(object)) {
|
|
2928
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2929
|
-
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2930
|
-
}
|
|
2931
|
-
} else {
|
|
2932
|
-
objectKeyList = Object.keys(object);
|
|
2933
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2934
|
-
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
function dump(input, options2) {
|
|
2941
|
-
options2 = options2 || {};
|
|
2942
|
-
var state = new State(options2);
|
|
2943
|
-
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
2944
|
-
if (writeNode(state, 0, input, true, true)) return state.dump + "\n";
|
|
2945
|
-
return "";
|
|
2946
|
-
}
|
|
2947
|
-
function safeDump(input, options2) {
|
|
2948
|
-
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options2));
|
|
2949
|
-
}
|
|
2950
|
-
module2.exports.dump = dump;
|
|
2951
|
-
module2.exports.safeDump = safeDump;
|
|
2952
|
-
}
|
|
2953
|
-
});
|
|
2954
|
-
|
|
2955
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml.js
|
|
2956
|
-
var require_js_yaml = __commonJS({
|
|
2957
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/lib/js-yaml.js"(exports2, module2) {
|
|
2958
|
-
"use strict";
|
|
2959
|
-
var loader = require_loader();
|
|
2960
|
-
var dumper = require_dumper();
|
|
2961
|
-
function deprecated(name) {
|
|
2962
|
-
return function() {
|
|
2963
|
-
throw new Error("Function " + name + " is deprecated and cannot be used.");
|
|
2964
|
-
};
|
|
2965
|
-
}
|
|
2966
|
-
module2.exports.Type = require_type();
|
|
2967
|
-
module2.exports.Schema = require_schema();
|
|
2968
|
-
module2.exports.FAILSAFE_SCHEMA = require_failsafe();
|
|
2969
|
-
module2.exports.JSON_SCHEMA = require_json();
|
|
2970
|
-
module2.exports.CORE_SCHEMA = require_core();
|
|
2971
|
-
module2.exports.DEFAULT_SAFE_SCHEMA = require_default_safe();
|
|
2972
|
-
module2.exports.DEFAULT_FULL_SCHEMA = require_default_full();
|
|
2973
|
-
module2.exports.load = loader.load;
|
|
2974
|
-
module2.exports.loadAll = loader.loadAll;
|
|
2975
|
-
module2.exports.safeLoad = loader.safeLoad;
|
|
2976
|
-
module2.exports.safeLoadAll = loader.safeLoadAll;
|
|
2977
|
-
module2.exports.dump = dumper.dump;
|
|
2978
|
-
module2.exports.safeDump = dumper.safeDump;
|
|
2979
|
-
module2.exports.YAMLException = require_exception();
|
|
2980
|
-
module2.exports.MINIMAL_SCHEMA = require_failsafe();
|
|
2981
|
-
module2.exports.SAFE_SCHEMA = require_default_safe();
|
|
2982
|
-
module2.exports.DEFAULT_SCHEMA = require_default_full();
|
|
2983
|
-
module2.exports.scan = deprecated("scan");
|
|
2984
|
-
module2.exports.parse = deprecated("parse");
|
|
2985
|
-
module2.exports.compose = deprecated("compose");
|
|
2986
|
-
module2.exports.addConstructor = deprecated("addConstructor");
|
|
2987
|
-
}
|
|
2988
|
-
});
|
|
2989
|
-
|
|
2990
|
-
// ../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/index.js
|
|
2991
|
-
var require_js_yaml2 = __commonJS({
|
|
2992
|
-
"../../node_modules/.pnpm/js-yaml@3.14.1/node_modules/js-yaml/index.js"(exports2, module2) {
|
|
2993
|
-
"use strict";
|
|
2994
|
-
var yaml2 = require_js_yaml();
|
|
2995
|
-
module2.exports = yaml2;
|
|
2996
|
-
}
|
|
2997
|
-
});
|
|
2998
|
-
|
|
2999
|
-
// ../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engines.js
|
|
3000
|
-
var require_engines = __commonJS({
|
|
3001
|
-
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/engines.js"(exports, module) {
|
|
3002
|
-
"use strict";
|
|
3003
|
-
var yaml = require_js_yaml2();
|
|
3004
|
-
var engines = exports = module.exports;
|
|
3005
|
-
engines.yaml = {
|
|
3006
|
-
parse: yaml.safeLoad.bind(yaml),
|
|
3007
|
-
stringify: yaml.safeDump.bind(yaml)
|
|
3008
|
-
};
|
|
3009
|
-
engines.json = {
|
|
3010
|
-
parse: JSON.parse.bind(JSON),
|
|
3011
|
-
stringify: function(obj, options2) {
|
|
3012
|
-
const opts = Object.assign({ replacer: null, space: 2 }, options2);
|
|
3013
|
-
return JSON.stringify(obj, opts.replacer, opts.space);
|
|
3014
|
-
}
|
|
3015
|
-
};
|
|
3016
|
-
engines.javascript = {
|
|
3017
|
-
parse: function parse(str, options, wrap) {
|
|
3018
|
-
try {
|
|
3019
|
-
if (wrap !== false) {
|
|
3020
|
-
str = "(function() {\nreturn " + str.trim() + ";\n}());";
|
|
3021
|
-
}
|
|
3022
|
-
return eval(str) || {};
|
|
3023
|
-
} catch (err) {
|
|
3024
|
-
if (wrap !== false && /(unexpected|identifier)/i.test(err.message)) {
|
|
3025
|
-
return parse(str, options, false);
|
|
3026
|
-
}
|
|
3027
|
-
throw new SyntaxError(err);
|
|
3028
|
-
}
|
|
3029
|
-
},
|
|
3030
|
-
stringify: function() {
|
|
3031
|
-
throw new Error("stringifying JavaScript is not supported");
|
|
3032
|
-
}
|
|
3033
|
-
};
|
|
3034
|
-
}
|
|
3035
|
-
});
|
|
3036
|
-
|
|
3037
|
-
// ../../node_modules/.pnpm/strip-bom-string@1.0.0/node_modules/strip-bom-string/index.js
|
|
3038
|
-
var require_strip_bom_string = __commonJS({
|
|
3039
|
-
"../../node_modules/.pnpm/strip-bom-string@1.0.0/node_modules/strip-bom-string/index.js"(exports2, module2) {
|
|
3040
|
-
"use strict";
|
|
3041
|
-
module2.exports = function(str2) {
|
|
3042
|
-
if (typeof str2 === "string" && str2.charAt(0) === "\uFEFF") {
|
|
3043
|
-
return str2.slice(1);
|
|
3044
|
-
}
|
|
3045
|
-
return str2;
|
|
3046
|
-
};
|
|
3047
|
-
}
|
|
3048
|
-
});
|
|
3049
|
-
|
|
3050
|
-
// ../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/utils.js
|
|
3051
|
-
var require_utils = __commonJS({
|
|
3052
|
-
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/utils.js"(exports2) {
|
|
3053
|
-
"use strict";
|
|
3054
|
-
var stripBom = require_strip_bom_string();
|
|
3055
|
-
var typeOf = require_kind_of();
|
|
3056
|
-
exports2.define = function(obj, key, val) {
|
|
3057
|
-
Reflect.defineProperty(obj, key, {
|
|
3058
|
-
enumerable: false,
|
|
3059
|
-
configurable: true,
|
|
3060
|
-
writable: true,
|
|
3061
|
-
value: val
|
|
3062
|
-
});
|
|
3063
|
-
};
|
|
3064
|
-
exports2.isBuffer = function(val) {
|
|
3065
|
-
return typeOf(val) === "buffer";
|
|
3066
|
-
};
|
|
3067
|
-
exports2.isObject = function(val) {
|
|
3068
|
-
return typeOf(val) === "object";
|
|
3069
|
-
};
|
|
3070
|
-
exports2.toBuffer = function(input) {
|
|
3071
|
-
return typeof input === "string" ? Buffer.from(input) : input;
|
|
3072
|
-
};
|
|
3073
|
-
exports2.toString = function(input) {
|
|
3074
|
-
if (exports2.isBuffer(input)) return stripBom(String(input));
|
|
3075
|
-
if (typeof input !== "string") {
|
|
3076
|
-
throw new TypeError("expected input to be a string or buffer");
|
|
3077
|
-
}
|
|
3078
|
-
return stripBom(input);
|
|
3079
|
-
};
|
|
3080
|
-
exports2.arrayify = function(val) {
|
|
3081
|
-
return val ? Array.isArray(val) ? val : [val] : [];
|
|
3082
|
-
};
|
|
3083
|
-
exports2.startsWith = function(str2, substr, len) {
|
|
3084
|
-
if (typeof len !== "number") len = substr.length;
|
|
3085
|
-
return str2.slice(0, len) === substr;
|
|
3086
|
-
};
|
|
3087
|
-
}
|
|
3088
|
-
});
|
|
3089
|
-
|
|
3090
|
-
// ../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/defaults.js
|
|
3091
|
-
var require_defaults = __commonJS({
|
|
3092
|
-
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/defaults.js"(exports2, module2) {
|
|
3093
|
-
"use strict";
|
|
3094
|
-
var engines2 = require_engines();
|
|
3095
|
-
var utils = require_utils();
|
|
3096
|
-
module2.exports = function(options2) {
|
|
3097
|
-
const opts = Object.assign({}, options2);
|
|
3098
|
-
opts.delimiters = utils.arrayify(opts.delims || opts.delimiters || "---");
|
|
3099
|
-
if (opts.delimiters.length === 1) {
|
|
3100
|
-
opts.delimiters.push(opts.delimiters[0]);
|
|
3101
|
-
}
|
|
3102
|
-
opts.language = (opts.language || opts.lang || "yaml").toLowerCase();
|
|
3103
|
-
opts.engines = Object.assign({}, engines2, opts.parsers, opts.engines);
|
|
3104
|
-
return opts;
|
|
3105
|
-
};
|
|
3106
|
-
}
|
|
3107
|
-
});
|
|
3108
|
-
|
|
3109
|
-
// ../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/stringify.js
|
|
3110
|
-
var require_stringify = __commonJS({
|
|
3111
|
-
"../../node_modules/.pnpm/gray-matter@4.0.3/node_modules/gray-matter/lib/stringify.js"(exports2, module2) {
|
|
3112
|
-
"use strict";
|
|
3113
|
-
var typeOf = require_kind_of();
|
|
3114
|
-
var getEngine = require_engine();
|
|
3115
|
-
var defaults = require_defaults();
|
|
3116
|
-
module2.exports = function(file, data, options2) {
|
|
3117
|
-
if (data == null && options2 == null) {
|
|
3118
|
-
switch (typeOf(file)) {
|
|
3119
|
-
case "object":
|
|
3120
|
-
data = file.data;
|
|
3121
|
-
options2 = {};
|
|
3122
|
-
break;
|
|
3123
|
-
case "string":
|
|
3124
|
-
return file;
|
|
3125
|
-
default: {
|
|
3126
|
-
throw new TypeError("expected file to be a string or object");
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3130
|
-
const str2 = file.content;
|
|
3131
|
-
const opts = defaults(options2);
|
|
3132
|
-
if (data == null) {
|
|
3133
|
-
if (!opts.data) return file;
|
|
3134
|
-
data = opts.data;
|
|
3135
|
-
}
|
|
3136
|
-
const language = file.language || opts.language;
|
|
3137
|
-
const engine = getEngine(language, opts);
|
|
3138
|
-
if (typeof engine.stringify !== "function") {
|
|
3139
|
-
throw new TypeError('expected "' + language + '.stringify" to be a function');
|
|
3140
|
-
}
|
|
3141
|
-
data = Object.assign({}, file.data, data);
|
|
3142
|
-
const open = opts.delimiters[0];
|
|
3143
|
-
const close = opts.delimiters[1];
|
|
3144
|
-
const matter2 = engine.stringify(data, options2).trim();
|
|
3145
|
-
let buf = "";
|
|
3146
|
-
if (matter2 !== "{}") {
|
|
3147
|
-
buf = newline(open) + newline(matter2) + newline(close);
|
|
3148
|
-
}
|
|
3149
|
-
if (typeof file.excerpt === "string" && file.excerpt !== "") {
|
|
3150
|
-
if (str2.indexOf(file.excerpt.trim()) === -1) {
|
|
3151
|
-
buf += newline(file.excerpt) + newline(close);
|
|
3152
|
-
}
|
|
3153
|
-
}
|
|
3154
|
-
return buf + newline(str2);
|
|
3155
|
-
};
|
|
3156
|
-
function newline(str2) {
|
|
3157
|
-
return str2.slice(-1) !== "\n" ? str2 + "\n" : str2;
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
});
|
|
3161
|
-
|
|
3162
|
-
// src/index.ts
|
|
3163
|
-
import fs5 from "fs";
|
|
3164
|
-
|
|
3165
|
-
// src/presets/docs/index.ts
|
|
3166
|
-
import { promises as fs2 } from "fs";
|
|
3167
|
-
import path3 from "path";
|
|
3168
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
3169
|
-
import { createServer as createServer2 } from "vite";
|
|
3170
|
-
import { route } from "@react-router/dev/routes";
|
|
3171
|
-
|
|
3172
|
-
// src/presets/docs/settings.ts
|
|
3173
|
-
import fs from "fs/promises";
|
|
3174
|
-
import path from "path";
|
|
3175
|
-
import { createServer } from "vite";
|
|
3176
|
-
var extensions = ["tsx", "ts", "json"];
|
|
3177
|
-
async function readSettings() {
|
|
3178
|
-
const dirPath = process.cwd();
|
|
3179
|
-
const baseFileName = "docs";
|
|
3180
|
-
let settingsFilePath = "";
|
|
3181
|
-
let reactSettings = false;
|
|
3182
|
-
try {
|
|
3183
|
-
const files = await fs.readdir(dirPath);
|
|
3184
|
-
const settingsFile = files.find((file) => {
|
|
3185
|
-
const ext = path.extname(file).slice(1);
|
|
3186
|
-
return file.startsWith(baseFileName) && extensions.includes(ext);
|
|
3187
|
-
});
|
|
3188
|
-
if (settingsFile) {
|
|
3189
|
-
settingsFilePath = path.join(dirPath, settingsFile);
|
|
3190
|
-
reactSettings = path.extname(settingsFile) !== ".json";
|
|
3191
|
-
} else {
|
|
3192
|
-
console.error(`No settings file found.
|
|
3193
|
-
File must be named 'docs' with one of the following extensions: ${extensions.join(", ")}`);
|
|
3194
|
-
return null;
|
|
3195
|
-
}
|
|
3196
|
-
} catch (error) {
|
|
3197
|
-
console.error(error);
|
|
3198
|
-
return null;
|
|
3199
|
-
}
|
|
3200
|
-
if (reactSettings) {
|
|
3201
|
-
const settingsPreview = await createServer({
|
|
3202
|
-
optimizeDeps: {
|
|
3203
|
-
include: ["react/jsx-runtime"]
|
|
3204
|
-
}
|
|
3205
|
-
});
|
|
3206
|
-
const config = await settingsPreview.ssrLoadModule(settingsFilePath);
|
|
3207
|
-
return config.default;
|
|
3208
|
-
} else {
|
|
3209
|
-
const rawJsonSettings = await fs.readFile(settingsFilePath, "utf-8");
|
|
3210
|
-
try {
|
|
3211
|
-
let json = JSON.parse(rawJsonSettings);
|
|
3212
|
-
return json;
|
|
3213
|
-
} catch (e) {
|
|
3214
|
-
console.error(e);
|
|
3215
|
-
return null;
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
|
|
3220
|
-
// src/const.ts
|
|
3221
|
-
var THEME_CONFIG_FOLDER = ".docs/theme";
|
|
3222
|
-
var VIRTUAL_CONTENT_FOLDER = ".xyd/.cache/.content";
|
|
3223
|
-
var DEFAULT_THEME = "poetry";
|
|
3224
|
-
|
|
3225
|
-
// src/utils.ts
|
|
3226
|
-
import path2 from "path";
|
|
3227
|
-
import { fileURLToPath } from "url";
|
|
3228
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
3229
|
-
var __dirname = path2.dirname(__filename);
|
|
3230
|
-
var HOST_FOLDER_PATH = ".xyd/host";
|
|
3231
|
-
function getHostPath() {
|
|
3232
|
-
if (process.env.XYD_DEV_MODE) {
|
|
3233
|
-
return path2.join(__dirname, "../../../", HOST_FOLDER_PATH);
|
|
3234
|
-
}
|
|
3235
|
-
return path2.join(process.cwd(), HOST_FOLDER_PATH);
|
|
3236
|
-
}
|
|
3237
|
-
function getDocsPluginBasePath() {
|
|
3238
|
-
return path2.join(getHostPath(), "./plugins/xyd-plugin-docs");
|
|
3239
|
-
}
|
|
3240
|
-
|
|
3241
|
-
// src/presets/docs/index.ts
|
|
3242
|
-
async function loadModule(filePath) {
|
|
3243
|
-
const server = await createServer2({
|
|
3244
|
-
optimizeDeps: {
|
|
3245
|
-
include: ["react/jsx-runtime"]
|
|
3246
|
-
}
|
|
3247
|
-
});
|
|
3248
|
-
try {
|
|
3249
|
-
const module2 = await server.ssrLoadModule(filePath);
|
|
3250
|
-
return module2.default;
|
|
3251
|
-
} finally {
|
|
3252
|
-
await server.close();
|
|
3253
|
-
}
|
|
3254
|
-
}
|
|
3255
|
-
function preinstall() {
|
|
3256
|
-
return async function docsPluginInner(_, data) {
|
|
3257
|
-
const root = process.cwd();
|
|
3258
|
-
const settings = await readSettings();
|
|
3259
|
-
if (settings && !settings.theme) {
|
|
3260
|
-
settings.theme = {
|
|
3261
|
-
name: DEFAULT_THEME
|
|
3262
|
-
};
|
|
3263
|
-
}
|
|
3264
|
-
let themeRoutesExists = false;
|
|
3265
|
-
try {
|
|
3266
|
-
await fs2.access(path3.join(root, THEME_CONFIG_FOLDER, "./routes.ts"));
|
|
3267
|
-
themeRoutesExists = true;
|
|
3268
|
-
} catch (_2) {
|
|
3269
|
-
}
|
|
3270
|
-
if (themeRoutesExists) {
|
|
3271
|
-
const routeMod = await loadModule(path3.join(root, THEME_CONFIG_FOLDER, "./routes.ts"));
|
|
3272
|
-
const routes = routeMod((routePath, routeFile, routeOptions) => {
|
|
3273
|
-
return route(routePath, path3.join(root, THEME_CONFIG_FOLDER, routeFile), routeOptions);
|
|
3274
|
-
});
|
|
3275
|
-
data.routes.push(...routes);
|
|
3276
|
-
}
|
|
3277
|
-
return {
|
|
3278
|
-
settings
|
|
3279
|
-
};
|
|
3280
|
-
};
|
|
3281
|
-
}
|
|
3282
|
-
function vitePluginSettings() {
|
|
3283
|
-
return async function({ preinstall: preinstall3 }) {
|
|
3284
|
-
return {
|
|
3285
|
-
name: "virtual:xyd-settings",
|
|
3286
|
-
resolveId(id) {
|
|
3287
|
-
if (id === "virtual:xyd-settings") {
|
|
3288
|
-
return id + ".jsx";
|
|
3289
|
-
}
|
|
3290
|
-
return null;
|
|
3291
|
-
},
|
|
3292
|
-
async load(id) {
|
|
3293
|
-
if (id === "virtual:xyd-settings.jsx") {
|
|
3294
|
-
return `
|
|
3295
|
-
export default {
|
|
3296
|
-
get settings() {
|
|
3297
|
-
return globalThis.__xydSettings || ${typeof preinstall3.settings === "string" ? preinstall3.settings : JSON.stringify(preinstall3.settings)}
|
|
3298
|
-
}
|
|
3299
|
-
}
|
|
3300
|
-
`;
|
|
3301
|
-
}
|
|
3302
|
-
return null;
|
|
3303
|
-
}
|
|
3304
|
-
};
|
|
3305
|
-
};
|
|
3306
|
-
}
|
|
3307
|
-
function vitePluginThemeCSS() {
|
|
3308
|
-
return async function({
|
|
3309
|
-
preinstall: preinstall3
|
|
3310
|
-
}) {
|
|
3311
|
-
return {
|
|
3312
|
-
name: "virtual:xyd-theme/index.css",
|
|
3313
|
-
resolveId(source) {
|
|
3314
|
-
if (source === "virtual:xyd-theme/index.css") {
|
|
3315
|
-
const __filename2 = fileURLToPath2(import.meta.url);
|
|
3316
|
-
const __dirname2 = path3.dirname(__filename2);
|
|
3317
|
-
const themeName = preinstall3.settings.theme?.name || DEFAULT_THEME;
|
|
3318
|
-
let themePath = "";
|
|
3319
|
-
if (process.env.XYD_CLI) {
|
|
3320
|
-
themePath = path3.join(getHostPath(), `node_modules/@xyd-js/theme-${themeName}/dist`);
|
|
3321
|
-
} else {
|
|
3322
|
-
themePath = path3.join(path3.resolve(__dirname2, "../../"), `xyd-theme-${themeName}/dist`);
|
|
3323
|
-
}
|
|
3324
|
-
return path3.join(themePath, "index.css");
|
|
3325
|
-
}
|
|
3326
|
-
return null;
|
|
3327
|
-
}
|
|
3328
|
-
};
|
|
3329
|
-
};
|
|
3330
|
-
}
|
|
3331
|
-
function vitePluginThemeOverrideCSS() {
|
|
3332
|
-
return async function({ preinstall: preinstall3 }) {
|
|
3333
|
-
return {
|
|
3334
|
-
name: "virtual:xyd-theme-override-css",
|
|
3335
|
-
async resolveId(id) {
|
|
3336
|
-
if (id === "virtual:xyd-theme-override/index.css") {
|
|
3337
|
-
const root = process.cwd();
|
|
3338
|
-
const filePath = path3.join(root, THEME_CONFIG_FOLDER, "./index.css");
|
|
3339
|
-
try {
|
|
3340
|
-
await fs2.access(filePath);
|
|
3341
|
-
return filePath;
|
|
3342
|
-
} catch {
|
|
3343
|
-
return "virtual:xyd-theme-override/empty.css";
|
|
3344
|
-
}
|
|
3345
|
-
}
|
|
3346
|
-
return null;
|
|
3347
|
-
},
|
|
3348
|
-
async load(id) {
|
|
3349
|
-
if (id === "virtual:xyd-theme-override/empty.css") {
|
|
3350
|
-
return "";
|
|
3351
|
-
}
|
|
3352
|
-
return null;
|
|
3353
|
-
}
|
|
3354
|
-
};
|
|
3355
|
-
};
|
|
3356
|
-
}
|
|
3357
|
-
function vitePluginTheme() {
|
|
3358
|
-
return async function({
|
|
3359
|
-
preinstall: preinstall3
|
|
3360
|
-
}) {
|
|
3361
|
-
return {
|
|
3362
|
-
name: "virtual:xyd-theme",
|
|
3363
|
-
resolveId(id) {
|
|
3364
|
-
if (id === "virtual:xyd-theme") {
|
|
3365
|
-
return id;
|
|
3366
|
-
}
|
|
3367
|
-
return null;
|
|
3368
|
-
},
|
|
3369
|
-
async load(id) {
|
|
3370
|
-
if (id === "virtual:xyd-theme") {
|
|
3371
|
-
const __filename2 = fileURLToPath2(import.meta.url);
|
|
3372
|
-
const __dirname2 = path3.dirname(__filename2);
|
|
3373
|
-
const themeName = preinstall3.settings.theme?.name || DEFAULT_THEME;
|
|
3374
|
-
let themePath = "";
|
|
3375
|
-
if (process.env.XYD_CLI) {
|
|
3376
|
-
themePath = `@xyd-js/theme-${themeName}`;
|
|
3377
|
-
} else {
|
|
3378
|
-
themePath = path3.join(path3.resolve(__dirname2, "../../"), `xyd-theme-${themeName}/src`);
|
|
3379
|
-
}
|
|
3380
|
-
return `
|
|
3381
|
-
import Theme from '${themePath}';
|
|
3382
|
-
|
|
3383
|
-
export default Theme;
|
|
3384
|
-
`;
|
|
3385
|
-
}
|
|
3386
|
-
return null;
|
|
3387
|
-
}
|
|
3388
|
-
};
|
|
3389
|
-
};
|
|
3390
|
-
}
|
|
3391
|
-
function preset(settings, options2) {
|
|
3392
|
-
const basePath = getDocsPluginBasePath();
|
|
3393
|
-
return {
|
|
3394
|
-
preinstall: [
|
|
3395
|
-
preinstall
|
|
3396
|
-
],
|
|
3397
|
-
routes: [
|
|
3398
|
-
route("", path3.join(basePath, "src/pages/docs.tsx")),
|
|
3399
|
-
// TODO: custom routes
|
|
3400
|
-
route(options2.urlPrefix ? `${options2.urlPrefix}/*` : "*", path3.join(basePath, "src/pages/docs.tsx"), {
|
|
3401
|
-
id: "xyd-plugin-docs/docs"
|
|
3402
|
-
})
|
|
3403
|
-
],
|
|
3404
|
-
vitePlugins: [
|
|
3405
|
-
vitePluginSettings,
|
|
3406
|
-
vitePluginTheme,
|
|
3407
|
-
vitePluginThemeCSS,
|
|
3408
|
-
vitePluginThemeOverrideCSS
|
|
3409
|
-
],
|
|
3410
|
-
basePath
|
|
3411
|
-
};
|
|
3412
|
-
}
|
|
3413
|
-
var docsPreset = preset;
|
|
3414
|
-
|
|
3415
|
-
// src/presets/graphql/index.ts
|
|
3416
|
-
import { gqlSchemaToReferences } from "@xyd-js/gql";
|
|
3417
|
-
|
|
3418
|
-
// src/presets/uniform/index.ts
|
|
3419
|
-
var import_stringify = __toESM(require_stringify(), 1);
|
|
3420
|
-
import path4 from "path";
|
|
3421
|
-
import { promises as fs3 } from "fs";
|
|
3422
|
-
import { route as route2 } from "@react-router/dev/routes";
|
|
3423
|
-
import uniform, {
|
|
3424
|
-
pluginNavigation
|
|
3425
|
-
} from "@xyd-js/uniform";
|
|
3426
|
-
import { uniformPluginXDocsSidebar } from "@xyd-js/openapi";
|
|
3427
|
-
import { createRequire } from "module";
|
|
3428
|
-
var require2 = createRequire(import.meta.url);
|
|
3429
|
-
var matter = require2("gray-matter");
|
|
3430
|
-
async function ensureAndCleanupVirtualFolder() {
|
|
3431
|
-
try {
|
|
3432
|
-
await fs3.mkdir(VIRTUAL_CONTENT_FOLDER, { recursive: true });
|
|
3433
|
-
const entries = await fs3.readdir(VIRTUAL_CONTENT_FOLDER, { withFileTypes: true });
|
|
3434
|
-
for (const entry of entries) {
|
|
3435
|
-
const fullPath = path4.join(VIRTUAL_CONTENT_FOLDER, entry.name);
|
|
3436
|
-
if (entry.isDirectory()) {
|
|
3437
|
-
await fs3.rm(fullPath, { recursive: true, force: true });
|
|
3438
|
-
} else {
|
|
3439
|
-
await fs3.unlink(fullPath);
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
} catch (error) {
|
|
3443
|
-
console.error("Error managing virtual folder:", error);
|
|
3444
|
-
}
|
|
3445
|
-
}
|
|
3446
|
-
function flatPages(sidebar, groups, resp = []) {
|
|
3447
|
-
sidebar.map(async (side) => {
|
|
3448
|
-
if ("route" in side) {
|
|
3449
|
-
side?.pages.map((item) => {
|
|
3450
|
-
return flatPages([item], groups, resp);
|
|
3451
|
-
});
|
|
3452
|
-
return;
|
|
3453
|
-
}
|
|
3454
|
-
if (groups[side.group || ""]) {
|
|
3455
|
-
const link = groups[side.group || ""];
|
|
3456
|
-
resp.push(link);
|
|
3457
|
-
}
|
|
3458
|
-
side?.pages?.map(async (page) => {
|
|
3459
|
-
if (typeof page === "string") {
|
|
3460
|
-
resp.push(page);
|
|
3461
|
-
return;
|
|
3462
|
-
}
|
|
3463
|
-
if ("virtual" in page) {
|
|
3464
|
-
resp.push(page.virtual);
|
|
3465
|
-
return;
|
|
3466
|
-
}
|
|
3467
|
-
return flatPages([page], groups, resp);
|
|
3468
|
-
});
|
|
3469
|
-
});
|
|
3470
|
-
return resp;
|
|
3471
|
-
}
|
|
3472
|
-
function flatGroups(sidebar, resp = {}) {
|
|
3473
|
-
sidebar.map(async (side) => {
|
|
3474
|
-
if ("route" in side) {
|
|
3475
|
-
side?.pages.map((item) => {
|
|
3476
|
-
return flatGroups([item], resp);
|
|
3477
|
-
});
|
|
3478
|
-
return;
|
|
3479
|
-
}
|
|
3480
|
-
if (side.group) {
|
|
3481
|
-
if (resp[side.group]) {
|
|
3482
|
-
console.error("group already exists", side.group);
|
|
3483
|
-
}
|
|
3484
|
-
const first = side?.pages?.[0];
|
|
3485
|
-
if (first && typeof first === "string") {
|
|
3486
|
-
const chunks = first.split("/");
|
|
3487
|
-
chunks[chunks.length - 1] = side.group || "";
|
|
3488
|
-
const groupLink = chunks.join("/");
|
|
3489
|
-
resp[side.group] = groupLink;
|
|
3490
|
-
}
|
|
3491
|
-
}
|
|
3492
|
-
side?.pages?.map(async (page) => {
|
|
3493
|
-
if (typeof page === "string") {
|
|
3494
|
-
return;
|
|
3495
|
-
}
|
|
3496
|
-
if ("virtual" in page) {
|
|
3497
|
-
return;
|
|
3498
|
-
}
|
|
3499
|
-
return flatGroups([page], resp);
|
|
3500
|
-
});
|
|
3501
|
-
});
|
|
3502
|
-
return resp;
|
|
3503
|
-
}
|
|
3504
|
-
function uniformSidebarLevelMap(pages) {
|
|
3505
|
-
const out = {};
|
|
3506
|
-
let level = 0;
|
|
3507
|
-
function recursive(items) {
|
|
3508
|
-
for (const item of items) {
|
|
3509
|
-
out[item] = level++;
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3512
|
-
recursive(pages);
|
|
3513
|
-
return out;
|
|
3514
|
-
}
|
|
3515
|
-
async function readMarkdownFile(root, page) {
|
|
3516
|
-
try {
|
|
3517
|
-
return await fs3.readFile(path4.join(root, page + ".mdx"), "utf-8");
|
|
3518
|
-
} catch (e) {
|
|
3519
|
-
try {
|
|
3520
|
-
return await fs3.readFile(path4.join(root, page + ".md"), "utf-8");
|
|
3521
|
-
} catch (e2) {
|
|
3522
|
-
}
|
|
3523
|
-
}
|
|
3524
|
-
return "";
|
|
3525
|
-
}
|
|
3526
|
-
async function uniformResolver(settings, root, matchRoute, apiFile, uniformApiResolver, sidebar, options2, uniformType, disableFSWrite) {
|
|
3527
|
-
let urlPrefix = "";
|
|
3528
|
-
if (matchRoute && sidebar) {
|
|
3529
|
-
sidebar.forEach((sidebar2) => {
|
|
3530
|
-
if ("route" in sidebar2) {
|
|
3531
|
-
if (sidebar2.route === matchRoute) {
|
|
3532
|
-
if (urlPrefix) {
|
|
3533
|
-
throw new Error("multiple sidebars found for apiFile match");
|
|
3534
|
-
}
|
|
3535
|
-
urlPrefix = sidebar2.route;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
});
|
|
3539
|
-
}
|
|
3540
|
-
const resolvedApiFile = path4.relative(process.cwd(), path4.resolve(process.cwd(), apiFile));
|
|
3541
|
-
const uniformRefs = await uniformApiResolver(resolvedApiFile);
|
|
3542
|
-
const plugins = globalThis.__xydUserUniformVitePlugins || [];
|
|
3543
|
-
if (!urlPrefix && options2?.fileRouting?.[resolvedApiFile]) {
|
|
3544
|
-
matchRoute = options2.fileRouting[resolvedApiFile];
|
|
3545
|
-
}
|
|
3546
|
-
if (!urlPrefix && matchRoute) {
|
|
3547
|
-
sidebar?.push({
|
|
3548
|
-
route: matchRoute,
|
|
3549
|
-
pages: []
|
|
3550
|
-
});
|
|
3551
|
-
urlPrefix = matchRoute;
|
|
3552
|
-
}
|
|
3553
|
-
if (!urlPrefix && options2?.urlPrefix) {
|
|
3554
|
-
urlPrefix = options2.urlPrefix;
|
|
3555
|
-
}
|
|
3556
|
-
if (!urlPrefix) {
|
|
3557
|
-
throw new Error("(uniformResolver): urlPrefix not found");
|
|
3558
|
-
}
|
|
3559
|
-
if (uniformType === "openapi") {
|
|
3560
|
-
plugins.push(uniformPluginXDocsSidebar);
|
|
3561
|
-
}
|
|
3562
|
-
const uniformWithNavigation = uniform(uniformRefs, {
|
|
3563
|
-
plugins: [
|
|
3564
|
-
...plugins,
|
|
3565
|
-
pluginNavigation(settings, {
|
|
3566
|
-
urlPrefix
|
|
3567
|
-
})
|
|
3568
|
-
]
|
|
3569
|
-
});
|
|
3570
|
-
let pageLevels = {};
|
|
3571
|
-
const uniformData = {
|
|
3572
|
-
slugs: {},
|
|
3573
|
-
data: [],
|
|
3574
|
-
// TODO: fix any
|
|
3575
|
-
i: 0,
|
|
3576
|
-
set: (slug, content, options3 = {}) => {
|
|
3577
|
-
if (uniformData.slugs[slug]) {
|
|
3578
|
-
console.error("slug already exists", slug);
|
|
3579
|
-
}
|
|
3580
|
-
const level = pageLevels[slug];
|
|
3581
|
-
uniformData.data[level] = {
|
|
3582
|
-
slug,
|
|
3583
|
-
content,
|
|
3584
|
-
options: options3
|
|
3585
|
-
};
|
|
3586
|
-
}
|
|
3587
|
-
};
|
|
3588
|
-
const uniformSidebars = [];
|
|
3589
|
-
if (sidebar && matchRoute) {
|
|
3590
|
-
sidebar.forEach((sidebar2) => {
|
|
3591
|
-
if ("route" in sidebar2) {
|
|
3592
|
-
if (sidebar2.route === matchRoute) {
|
|
3593
|
-
uniformSidebars.push(sidebar2);
|
|
3594
|
-
}
|
|
3595
|
-
}
|
|
3596
|
-
});
|
|
3597
|
-
if (uniformSidebars.length > 1) {
|
|
3598
|
-
throw new Error("multiple sidebars found for uniform match");
|
|
3599
|
-
}
|
|
3600
|
-
}
|
|
3601
|
-
{
|
|
3602
|
-
const otherUniformPages = flatPages(uniformSidebars, {});
|
|
3603
|
-
const groups = flatGroups(uniformWithNavigation.out.sidebar);
|
|
3604
|
-
const flatUniformPages = [
|
|
3605
|
-
...otherUniformPages,
|
|
3606
|
-
...flatPages(
|
|
3607
|
-
uniformWithNavigation.out.sidebar,
|
|
3608
|
-
groups
|
|
3609
|
-
// TODO: we dont need groups - because it comes to structured page levels
|
|
3610
|
-
)
|
|
3611
|
-
];
|
|
3612
|
-
pageLevels = uniformSidebarLevelMap(flatUniformPages);
|
|
3613
|
-
{
|
|
3614
|
-
await Promise.all(otherUniformPages.map(async (page) => {
|
|
3615
|
-
const content = await readMarkdownFile(root, page);
|
|
3616
|
-
uniformData.set(page, content + "\n");
|
|
3617
|
-
}));
|
|
3618
|
-
await Promise.all(Object.keys(groups).map(async (group) => {
|
|
3619
|
-
try {
|
|
3620
|
-
const page = groups[group];
|
|
3621
|
-
const content = await readMarkdownFile(root, page);
|
|
3622
|
-
uniformData.set(page, content + "\n");
|
|
3623
|
-
} catch (e) {
|
|
3624
|
-
}
|
|
3625
|
-
}));
|
|
3626
|
-
}
|
|
3627
|
-
}
|
|
3628
|
-
{
|
|
3629
|
-
const routeFolder = path4.join(root, matchRoute);
|
|
3630
|
-
try {
|
|
3631
|
-
await fs3.access(routeFolder);
|
|
3632
|
-
} catch {
|
|
3633
|
-
await fs3.mkdir(routeFolder, { recursive: true });
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
let composedFileMap = {};
|
|
3637
|
-
if (!settings.engine?.uniform?.store) {
|
|
3638
|
-
composedFileMap = await composeFileMap(root, matchRoute);
|
|
3639
|
-
}
|
|
3640
|
-
const basePath = settings.engine?.uniform?.store ? root : path4.join(root, VIRTUAL_CONTENT_FOLDER);
|
|
3641
|
-
await Promise.all(
|
|
3642
|
-
uniformWithNavigation.references.map(async (ref) => {
|
|
3643
|
-
const byCanonical = path4.join(urlPrefix, ref.canonical);
|
|
3644
|
-
const mdPath = path4.join(basePath, byCanonical + ".md");
|
|
3645
|
-
const frontmatter = uniformWithNavigation.out.pageFrontMatter[byCanonical];
|
|
3646
|
-
if (!frontmatter) {
|
|
3647
|
-
console.error("frontmatter not found", byCanonical);
|
|
3648
|
-
return;
|
|
3649
|
-
}
|
|
3650
|
-
let meta = {
|
|
3651
|
-
title: frontmatter.title,
|
|
3652
|
-
layout: "wide"
|
|
3653
|
-
};
|
|
3654
|
-
const absoluteApiFile = path4.join(
|
|
3655
|
-
process.cwd(),
|
|
3656
|
-
apiFile
|
|
3657
|
-
);
|
|
3658
|
-
const resolvedApiFile2 = absoluteApiFile;
|
|
3659
|
-
let region = "";
|
|
3660
|
-
switch (uniformType) {
|
|
3661
|
-
case "graphql": {
|
|
3662
|
-
const ctx = ref.context;
|
|
3663
|
-
region = `${ctx.graphqlTypeShort}.${ctx?.graphqlName}`;
|
|
3664
|
-
meta.graphql = `${resolvedApiFile2}#${region}`;
|
|
3665
|
-
break;
|
|
3666
|
-
}
|
|
3667
|
-
case "openapi": {
|
|
3668
|
-
const ctx = ref.context;
|
|
3669
|
-
const method = (ctx?.method || "").toUpperCase();
|
|
3670
|
-
if (method && ctx?.path) {
|
|
3671
|
-
region = `${method} ${ctx?.path}`;
|
|
3672
|
-
} else if (ctx.componentSchema) {
|
|
3673
|
-
region = "/components/schemas/" + ctx.componentSchema;
|
|
3674
|
-
}
|
|
3675
|
-
meta.openapi = `${resolvedApiFile2}#${region}`;
|
|
3676
|
-
break;
|
|
3677
|
-
}
|
|
3678
|
-
}
|
|
3679
|
-
let composedContent = "";
|
|
3680
|
-
if (region && composedFileMap[region]) {
|
|
3681
|
-
const content2 = await fs3.readFile(composedFileMap[region], "utf-8");
|
|
3682
|
-
const resp = matter(content2);
|
|
3683
|
-
meta = {
|
|
3684
|
-
...meta,
|
|
3685
|
-
...composyingMetaProps(resp.data, "title", "description", "layout")
|
|
3686
|
-
};
|
|
3687
|
-
composedContent = resp.content;
|
|
3688
|
-
}
|
|
3689
|
-
const content = (0, import_stringify.default)({ content: composedContent }, meta);
|
|
3690
|
-
if (!disableFSWrite) {
|
|
3691
|
-
try {
|
|
3692
|
-
await fs3.access(path4.dirname(mdPath));
|
|
3693
|
-
} catch {
|
|
3694
|
-
await fs3.mkdir(path4.dirname(mdPath), { recursive: true });
|
|
3695
|
-
}
|
|
3696
|
-
await fs3.writeFile(mdPath, content);
|
|
3697
|
-
}
|
|
3698
|
-
})
|
|
3699
|
-
);
|
|
3700
|
-
if (!sidebar) {
|
|
3701
|
-
return {
|
|
3702
|
-
sidebar: [
|
|
3703
|
-
{
|
|
3704
|
-
route: matchRoute,
|
|
3705
|
-
pages: uniformWithNavigation.out.sidebar
|
|
3706
|
-
}
|
|
3707
|
-
],
|
|
3708
|
-
data: uniformData.data
|
|
3709
|
-
};
|
|
3710
|
-
}
|
|
3711
|
-
if (matchRoute) {
|
|
3712
|
-
uniformSidebars[0].pages.unshift(...uniformWithNavigation.out.sidebar);
|
|
3713
|
-
return {
|
|
3714
|
-
data: uniformData.data
|
|
3715
|
-
};
|
|
3716
|
-
}
|
|
3717
|
-
sidebar.unshift({
|
|
3718
|
-
route: matchRoute,
|
|
3719
|
-
pages: uniformWithNavigation.out.sidebar
|
|
3720
|
-
});
|
|
3721
|
-
return {
|
|
3722
|
-
data: uniformData.data,
|
|
3723
|
-
composedFileMap
|
|
3724
|
-
};
|
|
3725
|
-
}
|
|
3726
|
-
var allowedMetaProps = ["title", "description", "layout"];
|
|
3727
|
-
function composyingMetaProps(meta, ...props) {
|
|
3728
|
-
let newProps = {};
|
|
3729
|
-
props.forEach((prop) => {
|
|
3730
|
-
if (allowedMetaProps.includes(prop) && typeof meta[prop] === "string") {
|
|
3731
|
-
newProps[prop] = meta[prop];
|
|
3732
|
-
}
|
|
3733
|
-
});
|
|
3734
|
-
return newProps;
|
|
3735
|
-
}
|
|
3736
|
-
async function composeFileMap(basePath, matchRoute) {
|
|
3737
|
-
const routeMap = {};
|
|
3738
|
-
async function processDirectory(dirPath) {
|
|
3739
|
-
const entries = await fs3.readdir(dirPath, { withFileTypes: true });
|
|
3740
|
-
for (const entry of entries) {
|
|
3741
|
-
const fullPath = path4.join(dirPath, entry.name);
|
|
3742
|
-
if (entry.isDirectory()) {
|
|
3743
|
-
await processDirectory(fullPath);
|
|
3744
|
-
} else if (entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".mdx"))) {
|
|
3745
|
-
try {
|
|
3746
|
-
const content = await fs3.readFile(fullPath, "utf-8");
|
|
3747
|
-
const { data: frontmatter } = matter(content);
|
|
3748
|
-
if (frontmatter && frontmatter.openapi) {
|
|
3749
|
-
const route3 = frontmatter.openapi;
|
|
3750
|
-
routeMap[route3] = path4.join(matchRoute, entry.name);
|
|
3751
|
-
}
|
|
3752
|
-
} catch (error) {
|
|
3753
|
-
console.error(`Error processing file ${fullPath}:`, error);
|
|
3754
|
-
}
|
|
3755
|
-
}
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
await processDirectory(path4.join(basePath, matchRoute));
|
|
3759
|
-
return routeMap;
|
|
3760
|
-
}
|
|
3761
|
-
function preinstall2(id, uniformApiResolver, apiFile, uniformType, disableFSWrite, options2) {
|
|
3762
|
-
return function preinstallInner(innerOptions) {
|
|
3763
|
-
return async function uniformPluginInner(settings, data) {
|
|
3764
|
-
const root = process.cwd();
|
|
3765
|
-
if (!apiFile) {
|
|
3766
|
-
return;
|
|
3767
|
-
}
|
|
3768
|
-
const resp = [];
|
|
3769
|
-
if (typeof apiFile === "string") {
|
|
3770
|
-
const routeMatch = id;
|
|
3771
|
-
const resolved = await uniformResolver(
|
|
3772
|
-
settings,
|
|
3773
|
-
root,
|
|
3774
|
-
routeMatch,
|
|
3775
|
-
apiFile,
|
|
3776
|
-
uniformApiResolver,
|
|
3777
|
-
settings?.navigation?.sidebar,
|
|
3778
|
-
{
|
|
3779
|
-
...options2,
|
|
3780
|
-
...innerOptions
|
|
3781
|
-
},
|
|
3782
|
-
uniformType,
|
|
3783
|
-
disableFSWrite
|
|
3784
|
-
);
|
|
3785
|
-
if (resolved.sidebar) {
|
|
3786
|
-
settings.navigation = {
|
|
3787
|
-
...settings?.navigation,
|
|
3788
|
-
sidebar: !settings.navigation?.sidebar ? resolved.sidebar : [
|
|
3789
|
-
...resolved.sidebar,
|
|
3790
|
-
...!settings.navigation?.sidebar || []
|
|
3791
|
-
]
|
|
3792
|
-
};
|
|
3793
|
-
}
|
|
3794
|
-
resp.push({
|
|
3795
|
-
urlPrefix: routeMatch.startsWith("/") ? routeMatch : `/${routeMatch}`,
|
|
3796
|
-
data: resolved.data
|
|
3797
|
-
});
|
|
3798
|
-
} else {
|
|
3799
|
-
async function resolve(routeMatch, uniform2) {
|
|
3800
|
-
const resolved = await uniformResolver(
|
|
3801
|
-
settings,
|
|
3802
|
-
root,
|
|
3803
|
-
routeMatch,
|
|
3804
|
-
uniform2,
|
|
3805
|
-
uniformApiResolver,
|
|
3806
|
-
settings?.navigation?.sidebar,
|
|
3807
|
-
{
|
|
3808
|
-
...options2,
|
|
3809
|
-
...innerOptions
|
|
3810
|
-
},
|
|
3811
|
-
uniformType,
|
|
3812
|
-
disableFSWrite
|
|
3813
|
-
);
|
|
3814
|
-
if (resolved.sidebar) {
|
|
3815
|
-
settings.navigation = {
|
|
3816
|
-
...settings?.navigation,
|
|
3817
|
-
sidebar: !settings.navigation?.sidebar ? resolved.sidebar : [
|
|
3818
|
-
...resolved.sidebar,
|
|
3819
|
-
...!settings.navigation?.sidebar || []
|
|
3820
|
-
]
|
|
3821
|
-
};
|
|
3822
|
-
}
|
|
3823
|
-
resp.push({
|
|
3824
|
-
urlPrefix: routeMatch.startsWith("/") ? routeMatch : `/${routeMatch}`,
|
|
3825
|
-
data: resolved.data
|
|
3826
|
-
});
|
|
3827
|
-
}
|
|
3828
|
-
if (apiFile["source"]) {
|
|
3829
|
-
await resolve(apiFile["route"], apiFile["source"]);
|
|
3830
|
-
} else {
|
|
3831
|
-
for (const apiKey in apiFile) {
|
|
3832
|
-
const uniform2 = apiFile?.[apiKey]?.source || apiFile?.[apiKey] || "";
|
|
3833
|
-
const routeMatch = settings.api?.[id]?.[apiKey]?.route || "";
|
|
3834
|
-
if (!uniform2) {
|
|
3835
|
-
throw new Error(`uniform not found for ${apiKey}`);
|
|
3836
|
-
}
|
|
3837
|
-
await resolve(routeMatch, uniform2);
|
|
3838
|
-
}
|
|
3839
|
-
}
|
|
3840
|
-
}
|
|
3841
|
-
return resp;
|
|
3842
|
-
};
|
|
3843
|
-
};
|
|
3844
|
-
}
|
|
3845
|
-
function vitePluginUniformContent(pluginId) {
|
|
3846
|
-
return function vitePluginUniformContentInner() {
|
|
3847
|
-
return async function({
|
|
3848
|
-
preinstall: preinstall3
|
|
3849
|
-
}) {
|
|
3850
|
-
return {
|
|
3851
|
-
name: `virtual:xyd-plugin-docs/${pluginId}`,
|
|
3852
|
-
// TODO: unique name per plugin ?
|
|
3853
|
-
resolveId(id) {
|
|
3854
|
-
if (id == `virtual:xyd-plugin-docs/${pluginId}`) {
|
|
3855
|
-
return id;
|
|
3856
|
-
}
|
|
3857
|
-
},
|
|
3858
|
-
async load(id) {
|
|
3859
|
-
if (id === `virtual:xyd-plugin-docs/${pluginId}`) {
|
|
3860
|
-
if (!preinstall3.data) {
|
|
3861
|
-
return `export default ${JSON.stringify(preinstall3)}`;
|
|
3862
|
-
}
|
|
3863
|
-
return `export default ${JSON.stringify(preinstall3.data)}`;
|
|
3864
|
-
}
|
|
3865
|
-
}
|
|
3866
|
-
};
|
|
3867
|
-
};
|
|
3868
|
-
};
|
|
3869
|
-
}
|
|
3870
|
-
function uniformPreset(id, apiFile, sidebar, options2, uniformApiResolver, disableFSWrite) {
|
|
3871
|
-
return function(settings, uniformType) {
|
|
3872
|
-
const routeMatches = [];
|
|
3873
|
-
if (apiFile) {
|
|
3874
|
-
sidebar.forEach((sidebar2) => {
|
|
3875
|
-
if ("route" in sidebar2) {
|
|
3876
|
-
if (typeof apiFile === "string") {
|
|
3877
|
-
const routeMatch = id;
|
|
3878
|
-
if (sidebar2.route === routeMatch) {
|
|
3879
|
-
routeMatches.push(routeMatch);
|
|
3880
|
-
}
|
|
3881
|
-
return;
|
|
3882
|
-
}
|
|
3883
|
-
if (typeof apiFile === "object" && !Array.isArray(apiFile)) {
|
|
3884
|
-
for (const routeMatchKey in apiFile) {
|
|
3885
|
-
const routeMatch = settings?.api?.[id]?.[routeMatchKey]?.route || "";
|
|
3886
|
-
if (sidebar2.route === routeMatch) {
|
|
3887
|
-
routeMatches.push(routeMatch);
|
|
3888
|
-
}
|
|
3889
|
-
}
|
|
3890
|
-
}
|
|
3891
|
-
return;
|
|
3892
|
-
}
|
|
3893
|
-
});
|
|
3894
|
-
} else {
|
|
3895
|
-
if (!options2.urlPrefix) {
|
|
3896
|
-
throw new Error("(uniformPreset): urlPrefix not found");
|
|
3897
|
-
}
|
|
3898
|
-
routeMatches.push(`${options2.urlPrefix}/*`);
|
|
3899
|
-
}
|
|
3900
|
-
const basePath = path4.join(getHostPath(), "./plugins/xyd-plugin-docs");
|
|
3901
|
-
const pageTheme = "src/pages/docs.tsx";
|
|
3902
|
-
return {
|
|
3903
|
-
preinstall: [
|
|
3904
|
-
preinstall2(
|
|
3905
|
-
id,
|
|
3906
|
-
uniformApiResolver,
|
|
3907
|
-
apiFile,
|
|
3908
|
-
uniformType,
|
|
3909
|
-
disableFSWrite,
|
|
3910
|
-
options2
|
|
3911
|
-
)
|
|
3912
|
-
],
|
|
3913
|
-
routes: routeMatches.map(
|
|
3914
|
-
(routeMatch, i) => route2(
|
|
3915
|
-
`${routeMatch}/*`,
|
|
3916
|
-
path4.join(basePath, pageTheme),
|
|
3917
|
-
{
|
|
3918
|
-
id: `xyd-plugin-docs/${id}-${i}`
|
|
3919
|
-
}
|
|
3920
|
-
)
|
|
3921
|
-
),
|
|
3922
|
-
vitePlugins: [
|
|
3923
|
-
vitePluginUniformContent(id)
|
|
3924
|
-
]
|
|
3925
|
-
};
|
|
3926
|
-
};
|
|
3927
|
-
}
|
|
3928
|
-
var UniformPreset = class {
|
|
3929
|
-
constructor(presetId, apiFile, sidebar, disableFSWrite) {
|
|
3930
|
-
this.presetId = presetId;
|
|
3931
|
-
this.apiFile = apiFile;
|
|
3932
|
-
this.sidebar = sidebar;
|
|
3933
|
-
this.disableFSWrite = disableFSWrite;
|
|
3934
|
-
}
|
|
3935
|
-
_urlPrefix;
|
|
3936
|
-
_sourceTheme;
|
|
3937
|
-
_fileRouting = {};
|
|
3938
|
-
urlPrefix(urlPrefix) {
|
|
3939
|
-
this._urlPrefix = urlPrefix;
|
|
3940
|
-
return this;
|
|
3941
|
-
}
|
|
3942
|
-
sourceTheme(v) {
|
|
3943
|
-
this._sourceTheme = v;
|
|
3944
|
-
return this;
|
|
3945
|
-
}
|
|
3946
|
-
fileRouting(file, route3) {
|
|
3947
|
-
this._fileRouting[file] = route3;
|
|
3948
|
-
return this;
|
|
3949
|
-
}
|
|
3950
|
-
newUniformPreset() {
|
|
3951
|
-
return uniformPreset(
|
|
3952
|
-
this.presetId,
|
|
3953
|
-
this.apiFile,
|
|
3954
|
-
this.sidebar,
|
|
3955
|
-
{
|
|
3956
|
-
urlPrefix: this._urlPrefix,
|
|
3957
|
-
sourceTheme: this._sourceTheme,
|
|
3958
|
-
fileRouting: this._fileRouting
|
|
3959
|
-
},
|
|
3960
|
-
this.uniformRefResolver,
|
|
3961
|
-
this.disableFSWrite
|
|
3962
|
-
);
|
|
3963
|
-
}
|
|
3964
|
-
};
|
|
3965
|
-
|
|
3966
|
-
// src/presets/graphql/index.ts
|
|
3967
|
-
function preset2(settings, options2) {
|
|
3968
|
-
return GraphQLUniformPreset.new(settings, options2);
|
|
3969
|
-
}
|
|
3970
|
-
var graphqlPreset = preset2;
|
|
3971
|
-
var GraphQLUniformPreset = class _GraphQLUniformPreset extends UniformPreset {
|
|
3972
|
-
constructor(settings, options2) {
|
|
3973
|
-
super(
|
|
3974
|
-
"graphql",
|
|
3975
|
-
settings.api?.graphql || "",
|
|
3976
|
-
settings?.navigation?.sidebar || [],
|
|
3977
|
-
options2.disableFSWrite
|
|
3978
|
-
);
|
|
3979
|
-
this.uniformRefResolver = this.uniformRefResolver.bind(this);
|
|
3980
|
-
}
|
|
3981
|
-
static new(settings, options2) {
|
|
3982
|
-
return new _GraphQLUniformPreset(settings, {
|
|
3983
|
-
disableFSWrite: options2.disableFSWrite
|
|
3984
|
-
}).urlPrefix(options2.urlPrefix || "").newUniformPreset()(settings, "graphql");
|
|
3985
|
-
}
|
|
3986
|
-
async uniformRefResolver(filePath) {
|
|
3987
|
-
if (!filePath) {
|
|
3988
|
-
return [];
|
|
3989
|
-
}
|
|
3990
|
-
const resp = await gqlSchemaToReferences(filePath);
|
|
3991
|
-
if ("__UNSAFE_route" in resp && typeof resp.__UNSAFE_route === "function") {
|
|
3992
|
-
const route3 = resp.__UNSAFE_route();
|
|
3993
|
-
if (route3) {
|
|
3994
|
-
this.fileRouting(filePath, route3);
|
|
3995
|
-
}
|
|
3996
|
-
}
|
|
3997
|
-
return resp;
|
|
3998
|
-
}
|
|
3999
|
-
};
|
|
4000
|
-
|
|
4001
|
-
// src/presets/openapi/index.ts
|
|
4002
|
-
import { deferencedOpenAPI, oapSchemaToReferences, getXDocs } from "@xyd-js/openapi";
|
|
4003
|
-
function preset3(settings, options2) {
|
|
4004
|
-
return OpenAPIUniformPreset.new(settings, options2);
|
|
4005
|
-
}
|
|
4006
|
-
var openapiPreset = preset3;
|
|
4007
|
-
var OpenAPIUniformPreset = class _OpenAPIUniformPreset extends UniformPreset {
|
|
4008
|
-
constructor(settings, options2) {
|
|
4009
|
-
super(
|
|
4010
|
-
"openapi",
|
|
4011
|
-
settings.api?.openapi || "",
|
|
4012
|
-
settings?.navigation?.sidebar || [],
|
|
4013
|
-
options2.disableFSWrite
|
|
4014
|
-
);
|
|
4015
|
-
this.uniformRefResolver = this.uniformRefResolver.bind(this);
|
|
4016
|
-
}
|
|
4017
|
-
static new(settings, options2) {
|
|
4018
|
-
return new _OpenAPIUniformPreset(settings, {
|
|
4019
|
-
disableFSWrite: options2.disableFSWrite
|
|
4020
|
-
}).urlPrefix(options2.urlPrefix || "").newUniformPreset()(settings, "openapi");
|
|
4021
|
-
}
|
|
4022
|
-
async uniformRefResolver(filePath) {
|
|
4023
|
-
if (!filePath) {
|
|
4024
|
-
return [];
|
|
4025
|
-
}
|
|
4026
|
-
const schema = await deferencedOpenAPI(filePath);
|
|
4027
|
-
if (schema) {
|
|
4028
|
-
const xdocs = getXDocs(schema);
|
|
4029
|
-
if (xdocs?.route) {
|
|
4030
|
-
this.fileRouting(filePath, xdocs.route);
|
|
4031
|
-
}
|
|
4032
|
-
}
|
|
4033
|
-
return oapSchemaToReferences(schema);
|
|
4034
|
-
}
|
|
4035
|
-
};
|
|
4036
|
-
|
|
4037
|
-
// src/presets/sources/index.ts
|
|
4038
|
-
import path5 from "path";
|
|
4039
|
-
import fs4 from "fs/promises";
|
|
4040
|
-
import { sourcesToUniformV2 } from "@xyd-js/sources/ts";
|
|
4041
|
-
function preset4(settings, options2) {
|
|
4042
|
-
return SourceUniformPreset.new(settings, options2);
|
|
4043
|
-
}
|
|
4044
|
-
var sourcesPreset = preset4;
|
|
4045
|
-
var SourceUniformPreset = class _SourceUniformPreset extends UniformPreset {
|
|
4046
|
-
constructor(settings, options2) {
|
|
4047
|
-
super(
|
|
4048
|
-
"sources",
|
|
4049
|
-
settings.api?.sources || "",
|
|
4050
|
-
settings?.navigation?.sidebar || [],
|
|
4051
|
-
options2.disableFSWrite
|
|
4052
|
-
);
|
|
4053
|
-
}
|
|
4054
|
-
static new(settings, options2) {
|
|
4055
|
-
return new _SourceUniformPreset(settings, {
|
|
4056
|
-
disableFSWrite: options2.disableFSWrite
|
|
4057
|
-
}).urlPrefix(options2.urlPrefix || "").sourceTheme(true).newUniformPreset()(settings, "sources");
|
|
4058
|
-
}
|
|
4059
|
-
// TODO: options to specify only specific packages?
|
|
4060
|
-
async uniformRefResolver(filePath) {
|
|
4061
|
-
if (!filePath) {
|
|
4062
|
-
return [];
|
|
4063
|
-
}
|
|
4064
|
-
const packages = await fs4.readdir(filePath);
|
|
4065
|
-
const ref = await sourcesToUniformV2(
|
|
4066
|
-
filePath,
|
|
4067
|
-
packages.map((p) => path5.join(filePath, p))
|
|
4068
|
-
);
|
|
4069
|
-
if (!ref || !ref.references) {
|
|
4070
|
-
console.error("Failed to generate documentation.", filePath);
|
|
4071
|
-
return [];
|
|
4072
|
-
}
|
|
4073
|
-
return ref.references;
|
|
4074
|
-
}
|
|
4075
|
-
};
|
|
4076
|
-
|
|
4077
|
-
// src/index.ts
|
|
4078
|
-
async function pluginDocs(options2) {
|
|
4079
|
-
let settings = null;
|
|
4080
|
-
const vitePlugins = [];
|
|
4081
|
-
const routes = [];
|
|
4082
|
-
let basePath = "";
|
|
4083
|
-
{
|
|
4084
|
-
const options3 = {
|
|
4085
|
-
urlPrefix: ""
|
|
4086
|
-
// TODO: configurable
|
|
4087
|
-
};
|
|
4088
|
-
const docs = docsPreset(void 0, options3);
|
|
4089
|
-
docs.preinstall = docs.preinstall || [];
|
|
4090
|
-
let preinstallMerge = {};
|
|
4091
|
-
for (const preinstall3 of docs.preinstall) {
|
|
4092
|
-
const resp = await preinstall3()({}, {
|
|
4093
|
-
routes: docs.routes
|
|
4094
|
-
});
|
|
4095
|
-
if (resp && typeof resp === "object") {
|
|
4096
|
-
preinstallMerge = {
|
|
4097
|
-
...preinstallMerge,
|
|
4098
|
-
...resp
|
|
4099
|
-
};
|
|
4100
|
-
}
|
|
4101
|
-
}
|
|
4102
|
-
docs.vitePlugins = docs.vitePlugins || [];
|
|
4103
|
-
for (const vitePlugin of docs.vitePlugins) {
|
|
4104
|
-
const vitePlug = await vitePlugin()({
|
|
4105
|
-
preinstall: preinstallMerge
|
|
4106
|
-
});
|
|
4107
|
-
vitePlugins.push(vitePlug);
|
|
4108
|
-
}
|
|
4109
|
-
if ("settings" in preinstallMerge) {
|
|
4110
|
-
settings = preinstallMerge.settings;
|
|
4111
|
-
}
|
|
4112
|
-
docs.routes = docs.routes || [];
|
|
4113
|
-
routes.push(...docs.routes);
|
|
4114
|
-
basePath = docs.basePath;
|
|
4115
|
-
}
|
|
4116
|
-
if (!settings) {
|
|
4117
|
-
return null;
|
|
4118
|
-
}
|
|
4119
|
-
await ensureAndCleanupVirtualFolder();
|
|
4120
|
-
if (!options2?.disableAPIGeneration && settings?.api?.graphql) {
|
|
4121
|
-
const opt = {
|
|
4122
|
-
disableFSWrite: options2?.disableFSWrite
|
|
4123
|
-
};
|
|
4124
|
-
const gql = graphqlPreset(settings, opt);
|
|
4125
|
-
gql.preinstall = gql.preinstall || [];
|
|
4126
|
-
let preinstallMerge = {};
|
|
4127
|
-
for (const preinstall3 of gql.preinstall) {
|
|
4128
|
-
const resp = await preinstall3(opt)(settings, {
|
|
4129
|
-
routes: gql.routes
|
|
4130
|
-
});
|
|
4131
|
-
if (resp && typeof resp === "object") {
|
|
4132
|
-
preinstallMerge = {
|
|
4133
|
-
...preinstallMerge,
|
|
4134
|
-
...resp
|
|
4135
|
-
};
|
|
4136
|
-
}
|
|
4137
|
-
}
|
|
4138
|
-
gql.vitePlugins = gql.vitePlugins || [];
|
|
4139
|
-
for (const vitePlugin of gql.vitePlugins) {
|
|
4140
|
-
const vitePlug = await vitePlugin()({
|
|
4141
|
-
preinstall: preinstallMerge
|
|
4142
|
-
});
|
|
4143
|
-
vitePlugins.push(vitePlug);
|
|
4144
|
-
}
|
|
4145
|
-
gql.routes = gql.routes || [];
|
|
4146
|
-
routes.push(...gql.routes);
|
|
4147
|
-
}
|
|
4148
|
-
if (!options2?.disableAPIGeneration && settings?.api?.openapi) {
|
|
4149
|
-
const opt = {
|
|
4150
|
-
disableFSWrite: options2?.disableFSWrite
|
|
4151
|
-
};
|
|
4152
|
-
const oap = openapiPreset(settings, opt);
|
|
4153
|
-
oap.preinstall = oap.preinstall || [];
|
|
4154
|
-
let preinstallMerge = {};
|
|
4155
|
-
for (const preinstall3 of oap.preinstall) {
|
|
4156
|
-
const resp = await preinstall3(opt)(settings, {
|
|
4157
|
-
routes: oap.routes
|
|
4158
|
-
});
|
|
4159
|
-
if (resp && typeof resp === "object") {
|
|
4160
|
-
preinstallMerge = {
|
|
4161
|
-
...preinstallMerge,
|
|
4162
|
-
...resp
|
|
4163
|
-
};
|
|
4164
|
-
}
|
|
4165
|
-
}
|
|
4166
|
-
oap.vitePlugins = oap.vitePlugins || [];
|
|
4167
|
-
for (const vitePlugin of oap.vitePlugins) {
|
|
4168
|
-
const vitePlug = await vitePlugin()({
|
|
4169
|
-
preinstall: preinstallMerge
|
|
4170
|
-
});
|
|
4171
|
-
vitePlugins.push(vitePlug);
|
|
4172
|
-
}
|
|
4173
|
-
oap.routes = oap.routes || [];
|
|
4174
|
-
routes.push(...oap.routes);
|
|
4175
|
-
}
|
|
4176
|
-
if (!options2?.disableAPIGeneration && settings?.api?.sources) {
|
|
4177
|
-
const opt = {
|
|
4178
|
-
disableFSWrite: options2?.disableFSWrite
|
|
4179
|
-
};
|
|
4180
|
-
const src = sourcesPreset(settings, opt);
|
|
4181
|
-
src.preinstall = src.preinstall || [];
|
|
4182
|
-
let preinstallMerge = {};
|
|
4183
|
-
for (const preinstall3 of src.preinstall) {
|
|
4184
|
-
const resp = await preinstall3(opt)(settings, {
|
|
4185
|
-
routes: src.routes
|
|
4186
|
-
});
|
|
4187
|
-
if (resp && typeof resp === "object") {
|
|
4188
|
-
preinstallMerge = {
|
|
4189
|
-
...preinstallMerge,
|
|
4190
|
-
...resp
|
|
4191
|
-
};
|
|
4192
|
-
}
|
|
4193
|
-
}
|
|
4194
|
-
src.vitePlugins = src.vitePlugins || [];
|
|
4195
|
-
for (const vitePlugin of src.vitePlugins) {
|
|
4196
|
-
const vitePlug = await vitePlugin()({
|
|
4197
|
-
preinstall: preinstallMerge
|
|
4198
|
-
});
|
|
4199
|
-
vitePlugins.push(vitePlug);
|
|
4200
|
-
}
|
|
4201
|
-
src.routes = src.routes || [];
|
|
4202
|
-
routes.push(...src.routes);
|
|
4203
|
-
}
|
|
4204
|
-
let pagePathMapping = {};
|
|
4205
|
-
if (settings?.navigation) {
|
|
4206
|
-
pagePathMapping = mapNavigationToPagePathMapping(settings?.navigation);
|
|
4207
|
-
} else {
|
|
4208
|
-
console.warn("No navigation found in settings");
|
|
4209
|
-
}
|
|
4210
|
-
sortSidebarGroups(settings?.navigation?.sidebar || []);
|
|
4211
|
-
return {
|
|
4212
|
-
vitePlugins,
|
|
4213
|
-
settings,
|
|
4214
|
-
routes,
|
|
4215
|
-
basePath,
|
|
4216
|
-
pagePathMapping
|
|
4217
|
-
};
|
|
4218
|
-
}
|
|
4219
|
-
function sortSidebarGroups(sidebar) {
|
|
4220
|
-
for (const group of sidebar) {
|
|
4221
|
-
if (typeof group === "string") {
|
|
4222
|
-
continue;
|
|
4223
|
-
}
|
|
4224
|
-
if ("pages" in group && Array.isArray(group.pages)) {
|
|
4225
|
-
group.pages.sort((a, b) => {
|
|
4226
|
-
if (typeof a.sort === "number" && typeof b.sort === "number") {
|
|
4227
|
-
return a.sort - b.sort;
|
|
4228
|
-
}
|
|
4229
|
-
if (typeof a.sort === "number") {
|
|
4230
|
-
return -1;
|
|
4231
|
-
}
|
|
4232
|
-
if (typeof b.sort === "number") {
|
|
4233
|
-
return 1;
|
|
4234
|
-
}
|
|
4235
|
-
return 0;
|
|
4236
|
-
});
|
|
4237
|
-
}
|
|
4238
|
-
}
|
|
4239
|
-
}
|
|
4240
|
-
function mapNavigationToPagePathMapping(navigation) {
|
|
4241
|
-
const mapping = {};
|
|
4242
|
-
function getExistingFilePath(basePath) {
|
|
4243
|
-
const mdPath = `${basePath}.md`;
|
|
4244
|
-
const mdxPath = `${basePath}.mdx`;
|
|
4245
|
-
if (fs5.existsSync(mdPath)) {
|
|
4246
|
-
return mdPath;
|
|
4247
|
-
}
|
|
4248
|
-
if (fs5.existsSync(mdxPath)) {
|
|
4249
|
-
return mdxPath;
|
|
4250
|
-
}
|
|
4251
|
-
return null;
|
|
4252
|
-
}
|
|
4253
|
-
function processPages(pages) {
|
|
4254
|
-
for (const page of pages) {
|
|
4255
|
-
if (typeof page === "string") {
|
|
4256
|
-
const existingPath = getExistingFilePath(page);
|
|
4257
|
-
if (existingPath) {
|
|
4258
|
-
mapping[page] = existingPath;
|
|
4259
|
-
}
|
|
4260
|
-
} else if (typeof page === "object" && "virtual" in page) {
|
|
4261
|
-
const virtualPath = page.virtual;
|
|
4262
|
-
const pagePath = page.page;
|
|
4263
|
-
const existingPath = getExistingFilePath(virtualPath);
|
|
4264
|
-
if (existingPath) {
|
|
4265
|
-
mapping[pagePath] = existingPath;
|
|
4266
|
-
}
|
|
4267
|
-
} else if (typeof page === "object" && "pages" in page) {
|
|
4268
|
-
processPages(page.pages || []);
|
|
4269
|
-
}
|
|
4270
|
-
}
|
|
4271
|
-
}
|
|
4272
|
-
let sidebarFlatOnly = false;
|
|
4273
|
-
for (const sidebar of navigation.sidebar) {
|
|
4274
|
-
if (typeof sidebar === "string") {
|
|
4275
|
-
sidebarFlatOnly = true;
|
|
4276
|
-
break;
|
|
4277
|
-
} else if ("pages" in sidebar && "route" in sidebar) {
|
|
4278
|
-
for (const item of sidebar.pages) {
|
|
4279
|
-
if (item?.pages) {
|
|
4280
|
-
processPages(item.pages);
|
|
4281
|
-
}
|
|
4282
|
-
}
|
|
4283
|
-
} else if ("pages" in sidebar) {
|
|
4284
|
-
processPages(sidebar.pages || []);
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4287
|
-
if (sidebarFlatOnly) {
|
|
4288
|
-
const sidebar = navigation.sidebar;
|
|
4289
|
-
processPages(sidebar);
|
|
4290
|
-
}
|
|
4291
|
-
return mapping;
|
|
4292
|
-
}
|
|
4293
|
-
export {
|
|
4294
|
-
pluginDocs,
|
|
4295
|
-
readSettings
|
|
4296
|
-
};
|
|
4297
|
-
/*! Bundled license information:
|
|
4298
|
-
|
|
4299
|
-
strip-bom-string/index.js:
|
|
4300
|
-
(*!
|
|
4301
|
-
* strip-bom-string <https://github.com/jonschlinkert/strip-bom-string>
|
|
4302
|
-
*
|
|
4303
|
-
* Copyright (c) 2015, 2017, Jon Schlinkert.
|
|
4304
|
-
* Released under the MIT License.
|
|
4305
|
-
*)
|
|
4306
|
-
*/
|
|
4307
|
-
//# sourceMappingURL=index.js.map
|