@caiquecamargo/vite-plugin-netlify-cms 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/index.cjs.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1245 -0
- package/dist/src/plugin.d.ts +38 -0
- package/dist/src/types.d.ts +321 -0
- package/package.json +55 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1245 @@
|
|
|
1
|
+
import "fs/promises";
|
|
2
|
+
import { fileURLToPath as Ne } from "url";
|
|
3
|
+
const Ae = {}, oe = Symbol.for("yaml.alias"), ke = Symbol.for("yaml.document"), D = Symbol.for("yaml.map"), ye = Symbol.for("yaml.pair"), le = Symbol.for("yaml.scalar"), q = Symbol.for("yaml.seq"), k = Symbol.for("yaml.node.type"), W = (t) => !!t && typeof t == "object" && t[k] === oe, fe = (t) => !!t && typeof t == "object" && t[k] === ke, we = (t) => !!t && typeof t == "object" && t[k] === D, j = (t) => !!t && typeof t == "object" && t[k] === ye, L = (t) => !!t && typeof t == "object" && t[k] === le, ce = (t) => !!t && typeof t == "object" && t[k] === q;
|
|
4
|
+
function A(t) {
|
|
5
|
+
if (t && typeof t == "object")
|
|
6
|
+
switch (t[k]) {
|
|
7
|
+
case D:
|
|
8
|
+
case q:
|
|
9
|
+
return !0;
|
|
10
|
+
}
|
|
11
|
+
return !1;
|
|
12
|
+
}
|
|
13
|
+
function N(t) {
|
|
14
|
+
if (t && typeof t == "object")
|
|
15
|
+
switch (t[k]) {
|
|
16
|
+
case oe:
|
|
17
|
+
case D:
|
|
18
|
+
case le:
|
|
19
|
+
case q:
|
|
20
|
+
return !0;
|
|
21
|
+
}
|
|
22
|
+
return !1;
|
|
23
|
+
}
|
|
24
|
+
const Ce = (t) => (L(t) || A(t)) && !!t.anchor;
|
|
25
|
+
class ae {
|
|
26
|
+
constructor(e) {
|
|
27
|
+
Object.defineProperty(this, k, { value: e });
|
|
28
|
+
}
|
|
29
|
+
/** Create a copy of this node. */
|
|
30
|
+
clone() {
|
|
31
|
+
const e = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
32
|
+
return this.range && (e.range = this.range.slice()), e;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const B = Symbol("break visit"), Me = Symbol("skip children"), Q = Symbol("remove node");
|
|
36
|
+
function V(t, e) {
|
|
37
|
+
const n = Pe(e);
|
|
38
|
+
fe(t) ? J(null, t.contents, n, Object.freeze([t])) === Q && (t.contents = null) : J(null, t, n, Object.freeze([]));
|
|
39
|
+
}
|
|
40
|
+
V.BREAK = B;
|
|
41
|
+
V.SKIP = Me;
|
|
42
|
+
V.REMOVE = Q;
|
|
43
|
+
function J(t, e, n, s) {
|
|
44
|
+
const i = Ie(t, e, n, s);
|
|
45
|
+
if (N(i) || j(i))
|
|
46
|
+
return Be(t, s, i), J(t, i, n, s);
|
|
47
|
+
if (typeof i != "symbol") {
|
|
48
|
+
if (A(e)) {
|
|
49
|
+
s = Object.freeze(s.concat(e));
|
|
50
|
+
for (let r = 0; r < e.items.length; ++r) {
|
|
51
|
+
const o = J(r, e.items[r], n, s);
|
|
52
|
+
if (typeof o == "number")
|
|
53
|
+
r = o - 1;
|
|
54
|
+
else {
|
|
55
|
+
if (o === B)
|
|
56
|
+
return B;
|
|
57
|
+
o === Q && (e.items.splice(r, 1), r -= 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
} else if (j(e)) {
|
|
61
|
+
s = Object.freeze(s.concat(e));
|
|
62
|
+
const r = J("key", e.key, n, s);
|
|
63
|
+
if (r === B)
|
|
64
|
+
return B;
|
|
65
|
+
r === Q && (e.key = null);
|
|
66
|
+
const o = J("value", e.value, n, s);
|
|
67
|
+
if (o === B)
|
|
68
|
+
return B;
|
|
69
|
+
o === Q && (e.value = null);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return i;
|
|
73
|
+
}
|
|
74
|
+
function Pe(t) {
|
|
75
|
+
return typeof t == "object" && (t.Collection || t.Node || t.Value) ? Object.assign({
|
|
76
|
+
Alias: t.Node,
|
|
77
|
+
Map: t.Node,
|
|
78
|
+
Scalar: t.Node,
|
|
79
|
+
Seq: t.Node
|
|
80
|
+
}, t.Value && {
|
|
81
|
+
Map: t.Value,
|
|
82
|
+
Scalar: t.Value,
|
|
83
|
+
Seq: t.Value
|
|
84
|
+
}, t.Collection && {
|
|
85
|
+
Map: t.Collection,
|
|
86
|
+
Seq: t.Collection
|
|
87
|
+
}, t) : t;
|
|
88
|
+
}
|
|
89
|
+
function Ie(t, e, n, s) {
|
|
90
|
+
if (typeof n == "function")
|
|
91
|
+
return n(t, e, s);
|
|
92
|
+
if (we(e))
|
|
93
|
+
return n.Map?.(t, e, s);
|
|
94
|
+
if (ce(e))
|
|
95
|
+
return n.Seq?.(t, e, s);
|
|
96
|
+
if (j(e))
|
|
97
|
+
return n.Pair?.(t, e, s);
|
|
98
|
+
if (L(e))
|
|
99
|
+
return n.Scalar?.(t, e, s);
|
|
100
|
+
if (W(e))
|
|
101
|
+
return n.Alias?.(t, e, s);
|
|
102
|
+
}
|
|
103
|
+
function Be(t, e, n) {
|
|
104
|
+
const s = e[e.length - 1];
|
|
105
|
+
if (A(s))
|
|
106
|
+
s.items[t] = n;
|
|
107
|
+
else if (j(s))
|
|
108
|
+
t === "key" ? s.key = n : s.value = n;
|
|
109
|
+
else if (fe(s))
|
|
110
|
+
s.contents = n;
|
|
111
|
+
else {
|
|
112
|
+
const i = W(s) ? "alias" : "scalar";
|
|
113
|
+
throw new Error(`Cannot replace node with ${i} parent`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function Se(t) {
|
|
117
|
+
if (/[\x00-\x19\s,[\]{}]/.test(t)) {
|
|
118
|
+
const n = `Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;
|
|
119
|
+
throw new Error(n);
|
|
120
|
+
}
|
|
121
|
+
return !0;
|
|
122
|
+
}
|
|
123
|
+
class Fe extends ae {
|
|
124
|
+
constructor(e) {
|
|
125
|
+
super(oe), this.source = e, Object.defineProperty(this, "tag", {
|
|
126
|
+
set() {
|
|
127
|
+
throw new Error("Alias nodes cannot have tags");
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Resolve the value of this alias within `doc`, finding the last
|
|
133
|
+
* instance of the `source` anchor before this node.
|
|
134
|
+
*/
|
|
135
|
+
resolve(e) {
|
|
136
|
+
let n;
|
|
137
|
+
return V(e, {
|
|
138
|
+
Node: (s, i) => {
|
|
139
|
+
if (i === this)
|
|
140
|
+
return V.BREAK;
|
|
141
|
+
i.anchor === this.source && (n = i);
|
|
142
|
+
}
|
|
143
|
+
}), n;
|
|
144
|
+
}
|
|
145
|
+
toJSON(e, n) {
|
|
146
|
+
if (!n)
|
|
147
|
+
return { source: this.source };
|
|
148
|
+
const { anchors: s, doc: i, maxAliasCount: r } = n, o = this.resolve(i);
|
|
149
|
+
if (!o) {
|
|
150
|
+
const l = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
151
|
+
throw new ReferenceError(l);
|
|
152
|
+
}
|
|
153
|
+
const f = s.get(o);
|
|
154
|
+
if (!f || f.res === void 0) {
|
|
155
|
+
const l = "This should not happen: Alias anchor was not resolved?";
|
|
156
|
+
throw new ReferenceError(l);
|
|
157
|
+
}
|
|
158
|
+
if (r >= 0 && (f.count += 1, f.aliasCount === 0 && (f.aliasCount = z(i, o, s)), f.count * f.aliasCount > r)) {
|
|
159
|
+
const l = "Excessive alias count indicates a resource exhaustion attack";
|
|
160
|
+
throw new ReferenceError(l);
|
|
161
|
+
}
|
|
162
|
+
return f.res;
|
|
163
|
+
}
|
|
164
|
+
toString(e, n, s) {
|
|
165
|
+
const i = `*${this.source}`;
|
|
166
|
+
if (e) {
|
|
167
|
+
if (Se(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
|
|
168
|
+
const r = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
169
|
+
throw new Error(r);
|
|
170
|
+
}
|
|
171
|
+
if (e.implicitKey)
|
|
172
|
+
return `${i} `;
|
|
173
|
+
}
|
|
174
|
+
return i;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
function z(t, e, n) {
|
|
178
|
+
if (W(e)) {
|
|
179
|
+
const s = e.resolve(t), i = n && s && n.get(s);
|
|
180
|
+
return i ? i.count * i.aliasCount : 0;
|
|
181
|
+
} else if (A(e)) {
|
|
182
|
+
let s = 0;
|
|
183
|
+
for (const i of e.items) {
|
|
184
|
+
const r = z(t, i, n);
|
|
185
|
+
r > s && (s = r);
|
|
186
|
+
}
|
|
187
|
+
return s;
|
|
188
|
+
} else if (j(e)) {
|
|
189
|
+
const s = z(t, e.key, n), i = z(t, e.value, n);
|
|
190
|
+
return Math.max(s, i);
|
|
191
|
+
}
|
|
192
|
+
return 1;
|
|
193
|
+
}
|
|
194
|
+
function C(t, e, n) {
|
|
195
|
+
if (Array.isArray(t))
|
|
196
|
+
return t.map((s, i) => C(s, String(i), n));
|
|
197
|
+
if (t && typeof t.toJSON == "function") {
|
|
198
|
+
if (!n || !Ce(t))
|
|
199
|
+
return t.toJSON(e, n);
|
|
200
|
+
const s = { aliasCount: 0, count: 1, res: void 0 };
|
|
201
|
+
n.anchors.set(t, s), n.onCreate = (r) => {
|
|
202
|
+
s.res = r, delete n.onCreate;
|
|
203
|
+
};
|
|
204
|
+
const i = t.toJSON(e, n);
|
|
205
|
+
return n.onCreate && n.onCreate(i), i;
|
|
206
|
+
}
|
|
207
|
+
return typeof t == "bigint" && !n?.keep ? Number(t) : t;
|
|
208
|
+
}
|
|
209
|
+
const Oe = (t) => !t || typeof t != "function" && typeof t != "object";
|
|
210
|
+
class E extends ae {
|
|
211
|
+
constructor(e) {
|
|
212
|
+
super(le), this.value = e;
|
|
213
|
+
}
|
|
214
|
+
toJSON(e, n) {
|
|
215
|
+
return n?.keep ? this.value : C(this.value, e, n);
|
|
216
|
+
}
|
|
217
|
+
toString() {
|
|
218
|
+
return String(this.value);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
E.BLOCK_FOLDED = "BLOCK_FOLDED";
|
|
222
|
+
E.BLOCK_LITERAL = "BLOCK_LITERAL";
|
|
223
|
+
E.PLAIN = "PLAIN";
|
|
224
|
+
E.QUOTE_DOUBLE = "QUOTE_DOUBLE";
|
|
225
|
+
E.QUOTE_SINGLE = "QUOTE_SINGLE";
|
|
226
|
+
const Te = "tag:yaml.org,2002:";
|
|
227
|
+
function De(t, e, n) {
|
|
228
|
+
if (e) {
|
|
229
|
+
const s = n.filter((r) => r.tag === e), i = s.find((r) => !r.format) ?? s[0];
|
|
230
|
+
if (!i)
|
|
231
|
+
throw new Error(`Tag ${e} not found`);
|
|
232
|
+
return i;
|
|
233
|
+
}
|
|
234
|
+
return n.find((s) => s.identify?.(t) && !s.format);
|
|
235
|
+
}
|
|
236
|
+
function _e(t, e, n) {
|
|
237
|
+
if (fe(t) && (t = t.contents), N(t))
|
|
238
|
+
return t;
|
|
239
|
+
if (j(t)) {
|
|
240
|
+
const d = n.schema[D].createNode?.(n.schema, null, n);
|
|
241
|
+
return d.items.push(t), d;
|
|
242
|
+
}
|
|
243
|
+
(t instanceof String || t instanceof Number || t instanceof Boolean || typeof BigInt < "u" && t instanceof BigInt) && (t = t.valueOf());
|
|
244
|
+
const { aliasDuplicateObjects: s, onAnchor: i, onTagObj: r, schema: o, sourceObjects: f } = n;
|
|
245
|
+
let l;
|
|
246
|
+
if (s && t && typeof t == "object") {
|
|
247
|
+
if (l = f.get(t), l)
|
|
248
|
+
return l.anchor || (l.anchor = i(t)), new Fe(l.anchor);
|
|
249
|
+
l = { anchor: null, node: null }, f.set(t, l);
|
|
250
|
+
}
|
|
251
|
+
e?.startsWith("!!") && (e = Te + e.slice(2));
|
|
252
|
+
let u = De(t, e, o.tags);
|
|
253
|
+
if (!u) {
|
|
254
|
+
if (t && typeof t.toJSON == "function" && (t = t.toJSON()), !t || typeof t != "object") {
|
|
255
|
+
const d = new E(t);
|
|
256
|
+
return l && (l.node = d), d;
|
|
257
|
+
}
|
|
258
|
+
u = t instanceof Map ? o[D] : Symbol.iterator in Object(t) ? o[q] : o[D];
|
|
259
|
+
}
|
|
260
|
+
r && (r(u), delete n.onTagObj);
|
|
261
|
+
const b = u?.createNode ? u.createNode(n.schema, t, n) : new E(t);
|
|
262
|
+
return e && (b.tag = e), l && (l.node = b), b;
|
|
263
|
+
}
|
|
264
|
+
function pe(t, e, n) {
|
|
265
|
+
let s = n;
|
|
266
|
+
for (let i = e.length - 1; i >= 0; --i) {
|
|
267
|
+
const r = e[i];
|
|
268
|
+
if (typeof r == "number" && Number.isInteger(r) && r >= 0) {
|
|
269
|
+
const o = [];
|
|
270
|
+
o[r] = s, s = o;
|
|
271
|
+
} else
|
|
272
|
+
s = /* @__PURE__ */ new Map([[r, s]]);
|
|
273
|
+
}
|
|
274
|
+
return _e(s, void 0, {
|
|
275
|
+
aliasDuplicateObjects: !1,
|
|
276
|
+
keepUndefined: !1,
|
|
277
|
+
onAnchor: () => {
|
|
278
|
+
throw new Error("This should not happen, please report a bug.");
|
|
279
|
+
},
|
|
280
|
+
schema: t,
|
|
281
|
+
sourceObjects: /* @__PURE__ */ new Map()
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
const Je = (t) => t == null || typeof t == "object" && !!t[Symbol.iterator]().next().done;
|
|
285
|
+
class v extends ae {
|
|
286
|
+
constructor(e, n) {
|
|
287
|
+
super(e), Object.defineProperty(this, "schema", {
|
|
288
|
+
value: n,
|
|
289
|
+
configurable: !0,
|
|
290
|
+
enumerable: !1,
|
|
291
|
+
writable: !0
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Create a copy of this collection.
|
|
296
|
+
*
|
|
297
|
+
* @param schema - If defined, overwrites the original's schema
|
|
298
|
+
*/
|
|
299
|
+
clone(e) {
|
|
300
|
+
const n = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
301
|
+
return e && (n.schema = e), n.items = n.items.map((s) => N(s) || j(s) ? s.clone(e) : s), this.range && (n.range = this.range.slice()), n;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
305
|
+
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
306
|
+
* that already exists in the map.
|
|
307
|
+
*/
|
|
308
|
+
addIn(e, n) {
|
|
309
|
+
if (Je(e))
|
|
310
|
+
this.add(n);
|
|
311
|
+
else {
|
|
312
|
+
const [s, ...i] = e, r = this.get(s, !0);
|
|
313
|
+
if (A(r))
|
|
314
|
+
r.addIn(i, n);
|
|
315
|
+
else if (r === void 0 && this.schema)
|
|
316
|
+
this.set(s, pe(this.schema, i, n));
|
|
317
|
+
else
|
|
318
|
+
throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Removes a value from the collection.
|
|
323
|
+
* @returns `true` if the item was found and removed.
|
|
324
|
+
*/
|
|
325
|
+
deleteIn(e) {
|
|
326
|
+
const [n, ...s] = e;
|
|
327
|
+
if (s.length === 0)
|
|
328
|
+
return this.delete(n);
|
|
329
|
+
const i = this.get(n, !0);
|
|
330
|
+
if (A(i))
|
|
331
|
+
return i.deleteIn(s);
|
|
332
|
+
throw new Error(`Expected YAML collection at ${n}. Remaining path: ${s}`);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
336
|
+
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
337
|
+
* `true` (collections are always returned intact).
|
|
338
|
+
*/
|
|
339
|
+
getIn(e, n) {
|
|
340
|
+
const [s, ...i] = e, r = this.get(s, !0);
|
|
341
|
+
return i.length === 0 ? !n && L(r) ? r.value : r : A(r) ? r.getIn(i, n) : void 0;
|
|
342
|
+
}
|
|
343
|
+
hasAllNullValues(e) {
|
|
344
|
+
return this.items.every((n) => {
|
|
345
|
+
if (!j(n))
|
|
346
|
+
return !1;
|
|
347
|
+
const s = n.value;
|
|
348
|
+
return s == null || e && L(s) && s.value == null && !s.commentBefore && !s.comment && !s.tag;
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Checks if the collection includes a value with the key `key`.
|
|
353
|
+
*/
|
|
354
|
+
hasIn(e) {
|
|
355
|
+
const [n, ...s] = e;
|
|
356
|
+
if (s.length === 0)
|
|
357
|
+
return this.has(n);
|
|
358
|
+
const i = this.get(n, !0);
|
|
359
|
+
return A(i) ? i.hasIn(s) : !1;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
363
|
+
* boolean to add/remove the item from the set.
|
|
364
|
+
*/
|
|
365
|
+
setIn(e, n) {
|
|
366
|
+
const [s, ...i] = e;
|
|
367
|
+
if (i.length === 0)
|
|
368
|
+
this.set(s, n);
|
|
369
|
+
else {
|
|
370
|
+
const r = this.get(s, !0);
|
|
371
|
+
if (A(r))
|
|
372
|
+
r.setIn(i, n);
|
|
373
|
+
else if (r === void 0 && this.schema)
|
|
374
|
+
this.set(s, pe(this.schema, i, n));
|
|
375
|
+
else
|
|
376
|
+
throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
v.maxFlowStringSingleLineLength = 60;
|
|
381
|
+
const Ke = (t) => t.replace(/^(?!$)(?: $)?/gm, "#");
|
|
382
|
+
function U(t, e) {
|
|
383
|
+
return /^\n+$/.test(t) ? t.substring(1) : e ? t.replace(/^(?! *$)/gm, e) : t;
|
|
384
|
+
}
|
|
385
|
+
const F = (t, e, n) => t.endsWith(`
|
|
386
|
+
`) ? U(n, e) : n.includes(`
|
|
387
|
+
`) ? `
|
|
388
|
+
` + U(n, e) : (t.endsWith(" ") ? "" : " ") + n, $e = "flow", ie = "block", G = "quoted";
|
|
389
|
+
function x(t, e, n = "flow", { indentAtStart: s, lineWidth: i = 80, minContentWidth: r = 20, onFold: o, onOverflow: f } = {}) {
|
|
390
|
+
if (!i || i < 0)
|
|
391
|
+
return t;
|
|
392
|
+
const l = Math.max(1 + r, 1 + i - e.length);
|
|
393
|
+
if (t.length <= l)
|
|
394
|
+
return t;
|
|
395
|
+
const u = [], b = {};
|
|
396
|
+
let d = i - e.length;
|
|
397
|
+
typeof s == "number" && (s > i - Math.max(2, r) ? u.push(0) : d = i - s);
|
|
398
|
+
let g, c, m = !1, a = -1, h = -1, S = -1;
|
|
399
|
+
n === ie && (a = me(t, a), a !== -1 && (d = a + l));
|
|
400
|
+
for (let y; y = t[a += 1]; ) {
|
|
401
|
+
if (n === G && y === "\\") {
|
|
402
|
+
switch (h = a, t[a + 1]) {
|
|
403
|
+
case "x":
|
|
404
|
+
a += 3;
|
|
405
|
+
break;
|
|
406
|
+
case "u":
|
|
407
|
+
a += 5;
|
|
408
|
+
break;
|
|
409
|
+
case "U":
|
|
410
|
+
a += 9;
|
|
411
|
+
break;
|
|
412
|
+
default:
|
|
413
|
+
a += 1;
|
|
414
|
+
}
|
|
415
|
+
S = a;
|
|
416
|
+
}
|
|
417
|
+
if (y === `
|
|
418
|
+
`)
|
|
419
|
+
n === ie && (a = me(t, a)), d = a + l, g = void 0;
|
|
420
|
+
else {
|
|
421
|
+
if (y === " " && c && c !== " " && c !== `
|
|
422
|
+
` && c !== " ") {
|
|
423
|
+
const w = t[a + 1];
|
|
424
|
+
w && w !== " " && w !== `
|
|
425
|
+
` && w !== " " && (g = a);
|
|
426
|
+
}
|
|
427
|
+
if (a >= d)
|
|
428
|
+
if (g)
|
|
429
|
+
u.push(g), d = g + l, g = void 0;
|
|
430
|
+
else if (n === G) {
|
|
431
|
+
for (; c === " " || c === " "; )
|
|
432
|
+
c = y, y = t[a += 1], m = !0;
|
|
433
|
+
const w = a > S + 1 ? a - 2 : h - 1;
|
|
434
|
+
if (b[w])
|
|
435
|
+
return t;
|
|
436
|
+
u.push(w), b[w] = !0, d = w + l, g = void 0;
|
|
437
|
+
} else
|
|
438
|
+
m = !0;
|
|
439
|
+
}
|
|
440
|
+
c = y;
|
|
441
|
+
}
|
|
442
|
+
if (m && f && f(), u.length === 0)
|
|
443
|
+
return t;
|
|
444
|
+
o && o();
|
|
445
|
+
let p = t.slice(0, u[0]);
|
|
446
|
+
for (let y = 0; y < u.length; ++y) {
|
|
447
|
+
const w = u[y], O = u[y + 1] || t.length;
|
|
448
|
+
w === 0 ? p = `
|
|
449
|
+
${e}${t.slice(0, O)}` : (n === G && b[w] && (p += `${t[w]}\\`), p += `
|
|
450
|
+
${e}${t.slice(w + 1, O)}`);
|
|
451
|
+
}
|
|
452
|
+
return p;
|
|
453
|
+
}
|
|
454
|
+
function me(t, e) {
|
|
455
|
+
let n = t[e + 1];
|
|
456
|
+
for (; n === " " || n === " "; ) {
|
|
457
|
+
do
|
|
458
|
+
n = t[e += 1];
|
|
459
|
+
while (n && n !== `
|
|
460
|
+
`);
|
|
461
|
+
n = t[e + 1];
|
|
462
|
+
}
|
|
463
|
+
return e;
|
|
464
|
+
}
|
|
465
|
+
const ee = (t) => ({
|
|
466
|
+
indentAtStart: t.indentAtStart,
|
|
467
|
+
lineWidth: t.options.lineWidth,
|
|
468
|
+
minContentWidth: t.options.minContentWidth
|
|
469
|
+
}), te = (t) => /^(%|---|\.\.\.)/m.test(t);
|
|
470
|
+
function We(t, e, n) {
|
|
471
|
+
if (!e || e < 0)
|
|
472
|
+
return !1;
|
|
473
|
+
const s = e - n, i = t.length;
|
|
474
|
+
if (i <= s)
|
|
475
|
+
return !1;
|
|
476
|
+
for (let r = 0, o = 0; r < i; ++r)
|
|
477
|
+
if (t[r] === `
|
|
478
|
+
`) {
|
|
479
|
+
if (r - o > s)
|
|
480
|
+
return !0;
|
|
481
|
+
if (o = r + 1, i - o <= s)
|
|
482
|
+
return !1;
|
|
483
|
+
}
|
|
484
|
+
return !0;
|
|
485
|
+
}
|
|
486
|
+
function R(t, e) {
|
|
487
|
+
const n = JSON.stringify(t);
|
|
488
|
+
if (e.options.doubleQuotedAsJSON)
|
|
489
|
+
return n;
|
|
490
|
+
const { implicitKey: s } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (te(t) ? " " : "");
|
|
491
|
+
let o = "", f = 0;
|
|
492
|
+
for (let l = 0, u = n[l]; u; u = n[++l])
|
|
493
|
+
if (u === " " && n[l + 1] === "\\" && n[l + 2] === "n" && (o += n.slice(f, l) + "\\ ", l += 1, f = l, u = "\\"), u === "\\")
|
|
494
|
+
switch (n[l + 1]) {
|
|
495
|
+
case "u":
|
|
496
|
+
{
|
|
497
|
+
o += n.slice(f, l);
|
|
498
|
+
const b = n.substr(l + 2, 4);
|
|
499
|
+
switch (b) {
|
|
500
|
+
case "0000":
|
|
501
|
+
o += "\\0";
|
|
502
|
+
break;
|
|
503
|
+
case "0007":
|
|
504
|
+
o += "\\a";
|
|
505
|
+
break;
|
|
506
|
+
case "000b":
|
|
507
|
+
o += "\\v";
|
|
508
|
+
break;
|
|
509
|
+
case "001b":
|
|
510
|
+
o += "\\e";
|
|
511
|
+
break;
|
|
512
|
+
case "0085":
|
|
513
|
+
o += "\\N";
|
|
514
|
+
break;
|
|
515
|
+
case "00a0":
|
|
516
|
+
o += "\\_";
|
|
517
|
+
break;
|
|
518
|
+
case "2028":
|
|
519
|
+
o += "\\L";
|
|
520
|
+
break;
|
|
521
|
+
case "2029":
|
|
522
|
+
o += "\\P";
|
|
523
|
+
break;
|
|
524
|
+
default:
|
|
525
|
+
b.substr(0, 2) === "00" ? o += "\\x" + b.substr(2) : o += n.substr(l, 6);
|
|
526
|
+
}
|
|
527
|
+
l += 5, f = l + 1;
|
|
528
|
+
}
|
|
529
|
+
break;
|
|
530
|
+
case "n":
|
|
531
|
+
if (s || n[l + 2] === '"' || n.length < i)
|
|
532
|
+
l += 1;
|
|
533
|
+
else {
|
|
534
|
+
for (o += n.slice(f, l) + `
|
|
535
|
+
|
|
536
|
+
`; n[l + 2] === "\\" && n[l + 3] === "n" && n[l + 4] !== '"'; )
|
|
537
|
+
o += `
|
|
538
|
+
`, l += 2;
|
|
539
|
+
o += r, n[l + 2] === " " && (o += "\\"), l += 1, f = l + 1;
|
|
540
|
+
}
|
|
541
|
+
break;
|
|
542
|
+
default:
|
|
543
|
+
l += 1;
|
|
544
|
+
}
|
|
545
|
+
return o = f ? o + n.slice(f) : n, s ? o : x(o, r, G, ee(e));
|
|
546
|
+
}
|
|
547
|
+
function re(t, e) {
|
|
548
|
+
if (e.options.singleQuote === !1 || e.implicitKey && t.includes(`
|
|
549
|
+
`) || /[ \t]\n|\n[ \t]/.test(t))
|
|
550
|
+
return R(t, e);
|
|
551
|
+
const n = e.indent || (te(t) ? " " : ""), s = "'" + t.replace(/'/g, "''").replace(/\n+/g, `$&
|
|
552
|
+
${n}`) + "'";
|
|
553
|
+
return e.implicitKey ? s : x(s, n, $e, ee(e));
|
|
554
|
+
}
|
|
555
|
+
function K(t, e) {
|
|
556
|
+
const { singleQuote: n } = e.options;
|
|
557
|
+
let s;
|
|
558
|
+
if (n === !1)
|
|
559
|
+
s = R;
|
|
560
|
+
else {
|
|
561
|
+
const i = t.includes('"'), r = t.includes("'");
|
|
562
|
+
i && !r ? s = re : r && !i ? s = R : s = n ? re : R;
|
|
563
|
+
}
|
|
564
|
+
return s(t, e);
|
|
565
|
+
}
|
|
566
|
+
function H({ comment: t, type: e, value: n }, s, i, r) {
|
|
567
|
+
const { blockQuote: o, commentString: f, lineWidth: l } = s.options;
|
|
568
|
+
if (!o || /\n[\t ]+$/.test(n) || /^\s*$/.test(n))
|
|
569
|
+
return K(n, s);
|
|
570
|
+
const u = s.indent || (s.forceBlockIndent || te(n) ? " " : ""), b = o === "literal" ? !0 : o === "folded" || e === E.BLOCK_FOLDED ? !1 : e === E.BLOCK_LITERAL ? !0 : !We(n, l, u.length);
|
|
571
|
+
if (!n)
|
|
572
|
+
return b ? `|
|
|
573
|
+
` : `>
|
|
574
|
+
`;
|
|
575
|
+
let d, g;
|
|
576
|
+
for (g = n.length; g > 0; --g) {
|
|
577
|
+
const $ = n[g - 1];
|
|
578
|
+
if ($ !== `
|
|
579
|
+
` && $ !== " " && $ !== " ")
|
|
580
|
+
break;
|
|
581
|
+
}
|
|
582
|
+
let c = n.substring(g);
|
|
583
|
+
const m = c.indexOf(`
|
|
584
|
+
`);
|
|
585
|
+
m === -1 ? d = "-" : n === c || m !== c.length - 1 ? (d = "+", r && r()) : d = "", c && (n = n.slice(0, -c.length), c[c.length - 1] === `
|
|
586
|
+
` && (c = c.slice(0, -1)), c = c.replace(/\n+(?!\n|$)/g, `$&${u}`));
|
|
587
|
+
let a = !1, h, S = -1;
|
|
588
|
+
for (h = 0; h < n.length; ++h) {
|
|
589
|
+
const $ = n[h];
|
|
590
|
+
if ($ === " ")
|
|
591
|
+
a = !0;
|
|
592
|
+
else if ($ === `
|
|
593
|
+
`)
|
|
594
|
+
S = h;
|
|
595
|
+
else
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
let p = n.substring(0, S < h ? S + 1 : h);
|
|
599
|
+
p && (n = n.substring(p.length), p = p.replace(/\n+/g, `$&${u}`));
|
|
600
|
+
let w = (b ? "|" : ">") + (a ? u ? "2" : "1" : "") + d;
|
|
601
|
+
if (t && (w += " " + f(t.replace(/ ?[\r\n]+/g, " ")), i && i()), b)
|
|
602
|
+
return n = n.replace(/\n+/g, `$&${u}`), `${w}
|
|
603
|
+
${u}${p}${n}${c}`;
|
|
604
|
+
n = n.replace(/\n+/g, `
|
|
605
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${u}`);
|
|
606
|
+
const O = x(`${p}${n}${c}`, u, ie, ee(s));
|
|
607
|
+
return `${w}
|
|
608
|
+
${u}${O}`;
|
|
609
|
+
}
|
|
610
|
+
function Qe(t, e, n, s) {
|
|
611
|
+
const { type: i, value: r } = t, { actualString: o, implicitKey: f, indent: l, indentStep: u, inFlow: b } = e;
|
|
612
|
+
if (f && /[\n[\]{},]/.test(r) || b && /[[\]{},]/.test(r))
|
|
613
|
+
return K(r, e);
|
|
614
|
+
if (!r || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))
|
|
615
|
+
return f || b || !r.includes(`
|
|
616
|
+
`) ? K(r, e) : H(t, e, n, s);
|
|
617
|
+
if (!f && !b && i !== E.PLAIN && r.includes(`
|
|
618
|
+
`))
|
|
619
|
+
return H(t, e, n, s);
|
|
620
|
+
if (te(r)) {
|
|
621
|
+
if (l === "")
|
|
622
|
+
return e.forceBlockIndent = !0, H(t, e, n, s);
|
|
623
|
+
if (f && l === u)
|
|
624
|
+
return K(r, e);
|
|
625
|
+
}
|
|
626
|
+
const d = r.replace(/\n+/g, `$&
|
|
627
|
+
${l}`);
|
|
628
|
+
if (o) {
|
|
629
|
+
const g = (a) => a.default && a.tag !== "tag:yaml.org,2002:str" && a.test?.test(d), { compat: c, tags: m } = e.doc.schema;
|
|
630
|
+
if (m.some(g) || c?.some(g))
|
|
631
|
+
return K(r, e);
|
|
632
|
+
}
|
|
633
|
+
return f ? d : x(d, l, $e, ee(e));
|
|
634
|
+
}
|
|
635
|
+
function Re(t, e, n, s) {
|
|
636
|
+
const { implicitKey: i, inFlow: r } = e, o = typeof t.value == "string" ? t : Object.assign({}, t, { value: String(t.value) });
|
|
637
|
+
let { type: f } = t;
|
|
638
|
+
f !== E.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (f = E.QUOTE_DOUBLE);
|
|
639
|
+
const l = (b) => {
|
|
640
|
+
switch (b) {
|
|
641
|
+
case E.BLOCK_FOLDED:
|
|
642
|
+
case E.BLOCK_LITERAL:
|
|
643
|
+
return i || r ? K(o.value, e) : H(o, e, n, s);
|
|
644
|
+
case E.QUOTE_DOUBLE:
|
|
645
|
+
return R(o.value, e);
|
|
646
|
+
case E.QUOTE_SINGLE:
|
|
647
|
+
return re(o.value, e);
|
|
648
|
+
case E.PLAIN:
|
|
649
|
+
return Qe(o, e, n, s);
|
|
650
|
+
default:
|
|
651
|
+
return null;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
let u = l(f);
|
|
655
|
+
if (u === null) {
|
|
656
|
+
const { defaultKeyType: b, defaultStringType: d } = e.options, g = i && b || d;
|
|
657
|
+
if (u = l(g), u === null)
|
|
658
|
+
throw new Error(`Unsupported default string type ${g}`);
|
|
659
|
+
}
|
|
660
|
+
return u;
|
|
661
|
+
}
|
|
662
|
+
function Ve(t, e) {
|
|
663
|
+
const n = Object.assign({
|
|
664
|
+
blockQuote: !0,
|
|
665
|
+
commentString: Ke,
|
|
666
|
+
defaultKeyType: null,
|
|
667
|
+
defaultStringType: "PLAIN",
|
|
668
|
+
directives: null,
|
|
669
|
+
doubleQuotedAsJSON: !1,
|
|
670
|
+
doubleQuotedMinMultiLineLength: 40,
|
|
671
|
+
falseStr: "false",
|
|
672
|
+
flowCollectionPadding: !0,
|
|
673
|
+
indentSeq: !0,
|
|
674
|
+
lineWidth: 80,
|
|
675
|
+
minContentWidth: 20,
|
|
676
|
+
nullStr: "null",
|
|
677
|
+
simpleKeys: !1,
|
|
678
|
+
singleQuote: null,
|
|
679
|
+
trueStr: "true",
|
|
680
|
+
verifyAliasOrder: !0
|
|
681
|
+
}, t.schema.toStringOptions, e);
|
|
682
|
+
let s;
|
|
683
|
+
switch (n.collectionStyle) {
|
|
684
|
+
case "block":
|
|
685
|
+
s = !1;
|
|
686
|
+
break;
|
|
687
|
+
case "flow":
|
|
688
|
+
s = !0;
|
|
689
|
+
break;
|
|
690
|
+
default:
|
|
691
|
+
s = null;
|
|
692
|
+
}
|
|
693
|
+
return {
|
|
694
|
+
anchors: /* @__PURE__ */ new Set(),
|
|
695
|
+
doc: t,
|
|
696
|
+
flowCollectionPadding: n.flowCollectionPadding ? " " : "",
|
|
697
|
+
indent: "",
|
|
698
|
+
indentStep: typeof n.indent == "number" ? " ".repeat(n.indent) : " ",
|
|
699
|
+
inFlow: s,
|
|
700
|
+
options: n
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
function Ue(t, e) {
|
|
704
|
+
if (e.tag) {
|
|
705
|
+
const i = t.filter((r) => r.tag === e.tag);
|
|
706
|
+
if (i.length > 0)
|
|
707
|
+
return i.find((r) => r.format === e.format) ?? i[0];
|
|
708
|
+
}
|
|
709
|
+
let n, s;
|
|
710
|
+
if (L(e)) {
|
|
711
|
+
s = e.value;
|
|
712
|
+
const i = t.filter((r) => r.identify?.(s));
|
|
713
|
+
n = i.find((r) => r.format === e.format) ?? i.find((r) => !r.format);
|
|
714
|
+
} else
|
|
715
|
+
s = e, n = t.find((i) => i.nodeClass && s instanceof i.nodeClass);
|
|
716
|
+
if (!n) {
|
|
717
|
+
const i = s?.constructor?.name ?? typeof s;
|
|
718
|
+
throw new Error(`Tag not resolved for ${i} value`);
|
|
719
|
+
}
|
|
720
|
+
return n;
|
|
721
|
+
}
|
|
722
|
+
function qe(t, e, { anchors: n, doc: s }) {
|
|
723
|
+
if (!s.directives)
|
|
724
|
+
return "";
|
|
725
|
+
const i = [], r = (L(t) || A(t)) && t.anchor;
|
|
726
|
+
r && Se(r) && (n.add(r), i.push(`&${r}`));
|
|
727
|
+
const o = t.tag ? t.tag : e.default ? null : e.tag;
|
|
728
|
+
return o && i.push(s.directives.tagString(o)), i.join(" ");
|
|
729
|
+
}
|
|
730
|
+
function X(t, e, n, s) {
|
|
731
|
+
if (j(t))
|
|
732
|
+
return t.toString(e, n, s);
|
|
733
|
+
if (W(t)) {
|
|
734
|
+
if (e.doc.directives)
|
|
735
|
+
return t.toString(e);
|
|
736
|
+
if (e.resolvedAliases?.has(t))
|
|
737
|
+
throw new TypeError("Cannot stringify circular structure without alias nodes");
|
|
738
|
+
e.resolvedAliases ? e.resolvedAliases.add(t) : e.resolvedAliases = /* @__PURE__ */ new Set([t]), t = t.resolve(e.doc);
|
|
739
|
+
}
|
|
740
|
+
let i;
|
|
741
|
+
const r = N(t) ? t : e.doc.createNode(t, { onTagObj: (l) => i = l });
|
|
742
|
+
i || (i = Ue(e.doc.schema.tags, r));
|
|
743
|
+
const o = qe(r, i, e);
|
|
744
|
+
o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1);
|
|
745
|
+
const f = typeof i.stringify == "function" ? i.stringify(r, e, n, s) : L(r) ? Re(r, e, n, s) : r.toString(e, n, s);
|
|
746
|
+
return o ? L(r) || f[0] === "{" || f[0] === "[" ? `${o} ${f}` : `${o}
|
|
747
|
+
${e.indent}${f}` : f;
|
|
748
|
+
}
|
|
749
|
+
function Ye({ key: t, value: e }, n, s, i) {
|
|
750
|
+
const { allNullValues: r, doc: o, indent: f, indentStep: l, options: { commentString: u, indentSeq: b, simpleKeys: d } } = n;
|
|
751
|
+
let g = N(t) && t.comment || null;
|
|
752
|
+
if (d) {
|
|
753
|
+
if (g)
|
|
754
|
+
throw new Error("With simple keys, key nodes cannot have comments");
|
|
755
|
+
if (A(t)) {
|
|
756
|
+
const P = "With simple keys, collection cannot be used as a key value";
|
|
757
|
+
throw new Error(P);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
let c = !d && (!t || g && e == null && !n.inFlow || A(t) || (L(t) ? t.type === E.BLOCK_FOLDED || t.type === E.BLOCK_LITERAL : typeof t == "object"));
|
|
761
|
+
n = Object.assign({}, n, {
|
|
762
|
+
allNullValues: !1,
|
|
763
|
+
implicitKey: !c && (d || !r),
|
|
764
|
+
indent: f + l
|
|
765
|
+
});
|
|
766
|
+
let m = !1, a = !1, h = X(t, n, () => m = !0, () => a = !0);
|
|
767
|
+
if (!c && !n.inFlow && h.length > 1024) {
|
|
768
|
+
if (d)
|
|
769
|
+
throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
|
|
770
|
+
c = !0;
|
|
771
|
+
}
|
|
772
|
+
if (n.inFlow) {
|
|
773
|
+
if (r || e == null)
|
|
774
|
+
return m && s && s(), h === "" ? "?" : c ? `? ${h}` : h;
|
|
775
|
+
} else if (r && !d || e == null && c)
|
|
776
|
+
return h = `? ${h}`, g && !m ? h += F(h, n.indent, u(g)) : a && i && i(), h;
|
|
777
|
+
m && (g = null), c ? (g && (h += F(h, n.indent, u(g))), h = `? ${h}
|
|
778
|
+
${f}:`) : (h = `${h}:`, g && (h += F(h, n.indent, u(g))));
|
|
779
|
+
let S, p, y;
|
|
780
|
+
N(e) ? (S = !!e.spaceBefore, p = e.commentBefore, y = e.comment) : (S = !1, p = null, y = null, e && typeof e == "object" && (e = o.createNode(e))), n.implicitKey = !1, !c && !g && L(e) && (n.indentAtStart = h.length + 1), a = !1, !b && l.length >= 2 && !n.inFlow && !c && ce(e) && !e.flow && !e.tag && !e.anchor && (n.indent = n.indent.substring(2));
|
|
781
|
+
let w = !1;
|
|
782
|
+
const O = X(e, n, () => w = !0, () => a = !0);
|
|
783
|
+
let $ = " ";
|
|
784
|
+
if (g || S || p) {
|
|
785
|
+
if ($ = S ? `
|
|
786
|
+
` : "", p) {
|
|
787
|
+
const P = u(p);
|
|
788
|
+
$ += `
|
|
789
|
+
${U(P, n.indent)}`;
|
|
790
|
+
}
|
|
791
|
+
O === "" && !n.inFlow ? $ === `
|
|
792
|
+
` && ($ = `
|
|
793
|
+
|
|
794
|
+
`) : $ += `
|
|
795
|
+
${n.indent}`;
|
|
796
|
+
} else if (!c && A(e)) {
|
|
797
|
+
const P = O[0], ne = O.indexOf(`
|
|
798
|
+
`), ge = ne !== -1, je = n.inFlow ?? e.flow ?? e.items.length === 0;
|
|
799
|
+
if (ge || !je) {
|
|
800
|
+
let he = !1;
|
|
801
|
+
if (ge && (P === "&" || P === "!")) {
|
|
802
|
+
let I = O.indexOf(" ");
|
|
803
|
+
P === "&" && I !== -1 && I < ne && O[I + 1] === "!" && (I = O.indexOf(" ", I + 1)), (I === -1 || ne < I) && (he = !0);
|
|
804
|
+
}
|
|
805
|
+
he || ($ = `
|
|
806
|
+
${n.indent}`);
|
|
807
|
+
}
|
|
808
|
+
} else
|
|
809
|
+
(O === "" || O[0] === `
|
|
810
|
+
`) && ($ = "");
|
|
811
|
+
return h += $ + O, n.inFlow ? w && s && s() : y && !w ? h += F(h, n.indent, u(y)) : a && i && i(), h;
|
|
812
|
+
}
|
|
813
|
+
function ze(t, e) {
|
|
814
|
+
(t === "debug" || t === "warn") && (typeof process < "u" && process.emitWarning ? process.emitWarning(e) : console.warn(e));
|
|
815
|
+
}
|
|
816
|
+
const be = "<<";
|
|
817
|
+
function Ee(t, e, { key: n, value: s }) {
|
|
818
|
+
if (t?.doc.schema.merge && Ge(n))
|
|
819
|
+
if (s = W(s) ? s.resolve(t.doc) : s, ce(s))
|
|
820
|
+
for (const i of s.items)
|
|
821
|
+
se(t, e, i);
|
|
822
|
+
else if (Array.isArray(s))
|
|
823
|
+
for (const i of s)
|
|
824
|
+
se(t, e, i);
|
|
825
|
+
else
|
|
826
|
+
se(t, e, s);
|
|
827
|
+
else {
|
|
828
|
+
const i = C(n, "", t);
|
|
829
|
+
if (e instanceof Map)
|
|
830
|
+
e.set(i, C(s, i, t));
|
|
831
|
+
else if (e instanceof Set)
|
|
832
|
+
e.add(i);
|
|
833
|
+
else {
|
|
834
|
+
const r = He(n, i, t), o = C(s, r, t);
|
|
835
|
+
r in e ? Object.defineProperty(e, r, {
|
|
836
|
+
value: o,
|
|
837
|
+
writable: !0,
|
|
838
|
+
enumerable: !0,
|
|
839
|
+
configurable: !0
|
|
840
|
+
}) : e[r] = o;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return e;
|
|
844
|
+
}
|
|
845
|
+
const Ge = (t) => t === be || L(t) && t.value === be && (!t.type || t.type === E.PLAIN);
|
|
846
|
+
function se(t, e, n) {
|
|
847
|
+
const s = t && W(n) ? n.resolve(t.doc) : n;
|
|
848
|
+
if (!we(s))
|
|
849
|
+
throw new Error("Merge sources must be maps or map aliases");
|
|
850
|
+
const i = s.toJSON(null, t, Map);
|
|
851
|
+
for (const [r, o] of i)
|
|
852
|
+
e instanceof Map ? e.has(r) || e.set(r, o) : e instanceof Set ? e.add(r) : Object.prototype.hasOwnProperty.call(e, r) || Object.defineProperty(e, r, {
|
|
853
|
+
value: o,
|
|
854
|
+
writable: !0,
|
|
855
|
+
enumerable: !0,
|
|
856
|
+
configurable: !0
|
|
857
|
+
});
|
|
858
|
+
return e;
|
|
859
|
+
}
|
|
860
|
+
function He(t, e, n) {
|
|
861
|
+
if (e === null)
|
|
862
|
+
return "";
|
|
863
|
+
if (typeof e != "object")
|
|
864
|
+
return String(e);
|
|
865
|
+
if (N(t) && n && n.doc) {
|
|
866
|
+
const s = Ve(n.doc, {});
|
|
867
|
+
s.anchors = /* @__PURE__ */ new Set();
|
|
868
|
+
for (const r of n.anchors.keys())
|
|
869
|
+
s.anchors.add(r.anchor);
|
|
870
|
+
s.inFlow = !0, s.inStringifyKey = !0;
|
|
871
|
+
const i = t.toString(s);
|
|
872
|
+
if (!n.mapKeyWarned) {
|
|
873
|
+
let r = JSON.stringify(i);
|
|
874
|
+
r.length > 40 && (r = r.substring(0, 36) + '..."'), ze(n.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`), n.mapKeyWarned = !0;
|
|
875
|
+
}
|
|
876
|
+
return i;
|
|
877
|
+
}
|
|
878
|
+
return JSON.stringify(e);
|
|
879
|
+
}
|
|
880
|
+
class M {
|
|
881
|
+
constructor(e, n = null) {
|
|
882
|
+
Object.defineProperty(this, k, { value: ye }), this.key = e, this.value = n;
|
|
883
|
+
}
|
|
884
|
+
clone(e) {
|
|
885
|
+
let { key: n, value: s } = this;
|
|
886
|
+
return N(n) && (n = n.clone(e)), N(s) && (s = s.clone(e)), new M(n, s);
|
|
887
|
+
}
|
|
888
|
+
toJSON(e, n) {
|
|
889
|
+
const s = n?.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
890
|
+
return Ee(n, s, this);
|
|
891
|
+
}
|
|
892
|
+
toString(e, n, s) {
|
|
893
|
+
return e?.doc ? Ye(this, e, n, s) : JSON.stringify(this);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
function Le(t, e, n) {
|
|
897
|
+
return (e.inFlow ?? t.flow ? Ze : Xe)(t, e, n);
|
|
898
|
+
}
|
|
899
|
+
function Xe({ comment: t, items: e }, n, { blockItemPrefix: s, flowChars: i, itemIndent: r, onChompKeep: o, onComment: f }) {
|
|
900
|
+
const { indent: l, options: { commentString: u } } = n, b = Object.assign({}, n, { indent: r, type: null });
|
|
901
|
+
let d = !1;
|
|
902
|
+
const g = [];
|
|
903
|
+
for (let m = 0; m < e.length; ++m) {
|
|
904
|
+
const a = e[m];
|
|
905
|
+
let h = null;
|
|
906
|
+
if (N(a))
|
|
907
|
+
!d && a.spaceBefore && g.push(""), Z(n, g, a.commentBefore, d), a.comment && (h = a.comment);
|
|
908
|
+
else if (j(a)) {
|
|
909
|
+
const p = N(a.key) ? a.key : null;
|
|
910
|
+
p && (!d && p.spaceBefore && g.push(""), Z(n, g, p.commentBefore, d));
|
|
911
|
+
}
|
|
912
|
+
d = !1;
|
|
913
|
+
let S = X(a, b, () => h = null, () => d = !0);
|
|
914
|
+
h && (S += F(S, r, u(h))), d && h && (d = !1), g.push(s + S);
|
|
915
|
+
}
|
|
916
|
+
let c;
|
|
917
|
+
if (g.length === 0)
|
|
918
|
+
c = i.start + i.end;
|
|
919
|
+
else {
|
|
920
|
+
c = g[0];
|
|
921
|
+
for (let m = 1; m < g.length; ++m) {
|
|
922
|
+
const a = g[m];
|
|
923
|
+
c += a ? `
|
|
924
|
+
${l}${a}` : `
|
|
925
|
+
`;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
return t ? (c += `
|
|
929
|
+
` + U(u(t), l), f && f()) : d && o && o(), c;
|
|
930
|
+
}
|
|
931
|
+
function Ze({ comment: t, items: e }, n, { flowChars: s, itemIndent: i, onComment: r }) {
|
|
932
|
+
const { indent: o, indentStep: f, flowCollectionPadding: l, options: { commentString: u } } = n;
|
|
933
|
+
i += f;
|
|
934
|
+
const b = Object.assign({}, n, {
|
|
935
|
+
indent: i,
|
|
936
|
+
inFlow: !0,
|
|
937
|
+
type: null
|
|
938
|
+
});
|
|
939
|
+
let d = !1, g = 0;
|
|
940
|
+
const c = [];
|
|
941
|
+
for (let S = 0; S < e.length; ++S) {
|
|
942
|
+
const p = e[S];
|
|
943
|
+
let y = null;
|
|
944
|
+
if (N(p))
|
|
945
|
+
p.spaceBefore && c.push(""), Z(n, c, p.commentBefore, !1), p.comment && (y = p.comment);
|
|
946
|
+
else if (j(p)) {
|
|
947
|
+
const O = N(p.key) ? p.key : null;
|
|
948
|
+
O && (O.spaceBefore && c.push(""), Z(n, c, O.commentBefore, !1), O.comment && (d = !0));
|
|
949
|
+
const $ = N(p.value) ? p.value : null;
|
|
950
|
+
$ ? ($.comment && (y = $.comment), $.commentBefore && (d = !0)) : p.value == null && O && O.comment && (y = O.comment);
|
|
951
|
+
}
|
|
952
|
+
y && (d = !0);
|
|
953
|
+
let w = X(p, b, () => y = null);
|
|
954
|
+
S < e.length - 1 && (w += ","), y && (w += F(w, i, u(y))), !d && (c.length > g || w.includes(`
|
|
955
|
+
`)) && (d = !0), c.push(w), g = c.length;
|
|
956
|
+
}
|
|
957
|
+
let m;
|
|
958
|
+
const { start: a, end: h } = s;
|
|
959
|
+
if (c.length === 0)
|
|
960
|
+
m = a + h;
|
|
961
|
+
else if (d || (d = c.reduce((p, y) => p + y.length + 2, 2) > v.maxFlowStringSingleLineLength), d) {
|
|
962
|
+
m = a;
|
|
963
|
+
for (const S of c)
|
|
964
|
+
m += S ? `
|
|
965
|
+
${f}${o}${S}` : `
|
|
966
|
+
`;
|
|
967
|
+
m += `
|
|
968
|
+
${o}${h}`;
|
|
969
|
+
} else
|
|
970
|
+
m = `${a}${l}${c.join(" ")}${l}${h}`;
|
|
971
|
+
return t && (m += F(m, u(t), o), r && r()), m;
|
|
972
|
+
}
|
|
973
|
+
function Z({ indent: t, options: { commentString: e } }, n, s, i) {
|
|
974
|
+
if (s && i && (s = s.replace(/^\n+/, "")), s) {
|
|
975
|
+
const r = U(e(s), t);
|
|
976
|
+
n.push(r.trimStart());
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
function T(t, e) {
|
|
980
|
+
const n = L(e) ? e.value : e;
|
|
981
|
+
for (const s of t)
|
|
982
|
+
if (j(s) && (s.key === e || s.key === n || L(s.key) && s.key.value === n))
|
|
983
|
+
return s;
|
|
984
|
+
}
|
|
985
|
+
class _ extends v {
|
|
986
|
+
static get tagName() {
|
|
987
|
+
return "tag:yaml.org,2002:map";
|
|
988
|
+
}
|
|
989
|
+
constructor(e) {
|
|
990
|
+
super(D, e), this.items = [];
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Adds a value to the collection.
|
|
994
|
+
*
|
|
995
|
+
* @param overwrite - If not set `true`, using a key that is already in the
|
|
996
|
+
* collection will throw. Otherwise, overwrites the previous value.
|
|
997
|
+
*/
|
|
998
|
+
add(e, n) {
|
|
999
|
+
let s;
|
|
1000
|
+
j(e) ? s = e : !e || typeof e != "object" || !("key" in e) ? s = new M(e, e?.value) : s = new M(e.key, e.value);
|
|
1001
|
+
const i = T(this.items, s.key), r = this.schema?.sortMapEntries;
|
|
1002
|
+
if (i) {
|
|
1003
|
+
if (!n)
|
|
1004
|
+
throw new Error(`Key ${s.key} already set`);
|
|
1005
|
+
L(i.value) && Oe(s.value) ? i.value.value = s.value : i.value = s.value;
|
|
1006
|
+
} else if (r) {
|
|
1007
|
+
const o = this.items.findIndex((f) => r(s, f) < 0);
|
|
1008
|
+
o === -1 ? this.items.push(s) : this.items.splice(o, 0, s);
|
|
1009
|
+
} else
|
|
1010
|
+
this.items.push(s);
|
|
1011
|
+
}
|
|
1012
|
+
delete(e) {
|
|
1013
|
+
const n = T(this.items, e);
|
|
1014
|
+
return n ? this.items.splice(this.items.indexOf(n), 1).length > 0 : !1;
|
|
1015
|
+
}
|
|
1016
|
+
get(e, n) {
|
|
1017
|
+
const i = T(this.items, e)?.value;
|
|
1018
|
+
return (!n && L(i) ? i.value : i) ?? void 0;
|
|
1019
|
+
}
|
|
1020
|
+
has(e) {
|
|
1021
|
+
return !!T(this.items, e);
|
|
1022
|
+
}
|
|
1023
|
+
set(e, n) {
|
|
1024
|
+
this.add(new M(e, n), !0);
|
|
1025
|
+
}
|
|
1026
|
+
/**
|
|
1027
|
+
* @param ctx - Conversion context, originally set in Document#toJS()
|
|
1028
|
+
* @param {Class} Type - If set, forces the returned collection type
|
|
1029
|
+
* @returns Instance of Type, Map, or Object
|
|
1030
|
+
*/
|
|
1031
|
+
toJSON(e, n, s) {
|
|
1032
|
+
const i = s ? new s() : n?.mapAsMap ? /* @__PURE__ */ new Map() : {};
|
|
1033
|
+
n?.onCreate && n.onCreate(i);
|
|
1034
|
+
for (const r of this.items)
|
|
1035
|
+
Ee(n, i, r);
|
|
1036
|
+
return i;
|
|
1037
|
+
}
|
|
1038
|
+
toString(e, n, s) {
|
|
1039
|
+
if (!e)
|
|
1040
|
+
return JSON.stringify(this);
|
|
1041
|
+
for (const i of this.items)
|
|
1042
|
+
if (!j(i))
|
|
1043
|
+
throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);
|
|
1044
|
+
return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })), Le(this, e, {
|
|
1045
|
+
blockItemPrefix: "",
|
|
1046
|
+
flowChars: { start: "{", end: "}" },
|
|
1047
|
+
itemIndent: e.indent || "",
|
|
1048
|
+
onChompKeep: s,
|
|
1049
|
+
onComment: n
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
class ve extends v {
|
|
1054
|
+
static get tagName() {
|
|
1055
|
+
return "tag:yaml.org,2002:seq";
|
|
1056
|
+
}
|
|
1057
|
+
constructor(e) {
|
|
1058
|
+
super(q, e), this.items = [];
|
|
1059
|
+
}
|
|
1060
|
+
add(e) {
|
|
1061
|
+
this.items.push(e);
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Removes a value from the collection.
|
|
1065
|
+
*
|
|
1066
|
+
* `key` must contain a representation of an integer for this to succeed.
|
|
1067
|
+
* It may be wrapped in a `Scalar`.
|
|
1068
|
+
*
|
|
1069
|
+
* @returns `true` if the item was found and removed.
|
|
1070
|
+
*/
|
|
1071
|
+
delete(e) {
|
|
1072
|
+
const n = Y(e);
|
|
1073
|
+
return typeof n != "number" ? !1 : this.items.splice(n, 1).length > 0;
|
|
1074
|
+
}
|
|
1075
|
+
get(e, n) {
|
|
1076
|
+
const s = Y(e);
|
|
1077
|
+
if (typeof s != "number")
|
|
1078
|
+
return;
|
|
1079
|
+
const i = this.items[s];
|
|
1080
|
+
return !n && L(i) ? i.value : i;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Checks if the collection includes a value with the key `key`.
|
|
1084
|
+
*
|
|
1085
|
+
* `key` must contain a representation of an integer for this to succeed.
|
|
1086
|
+
* It may be wrapped in a `Scalar`.
|
|
1087
|
+
*/
|
|
1088
|
+
has(e) {
|
|
1089
|
+
const n = Y(e);
|
|
1090
|
+
return typeof n == "number" && n < this.items.length;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
1094
|
+
* boolean to add/remove the item from the set.
|
|
1095
|
+
*
|
|
1096
|
+
* If `key` does not contain a representation of an integer, this will throw.
|
|
1097
|
+
* It may be wrapped in a `Scalar`.
|
|
1098
|
+
*/
|
|
1099
|
+
set(e, n) {
|
|
1100
|
+
const s = Y(e);
|
|
1101
|
+
if (typeof s != "number")
|
|
1102
|
+
throw new Error(`Expected a valid index, not ${e}.`);
|
|
1103
|
+
const i = this.items[s];
|
|
1104
|
+
L(i) && Oe(n) ? i.value = n : this.items[s] = n;
|
|
1105
|
+
}
|
|
1106
|
+
toJSON(e, n) {
|
|
1107
|
+
const s = [];
|
|
1108
|
+
n?.onCreate && n.onCreate(s);
|
|
1109
|
+
let i = 0;
|
|
1110
|
+
for (const r of this.items)
|
|
1111
|
+
s.push(C(r, String(i++), n));
|
|
1112
|
+
return s;
|
|
1113
|
+
}
|
|
1114
|
+
toString(e, n, s) {
|
|
1115
|
+
return e ? Le(this, e, {
|
|
1116
|
+
blockItemPrefix: "- ",
|
|
1117
|
+
flowChars: { start: "[", end: "]" },
|
|
1118
|
+
itemIndent: (e.indent || "") + " ",
|
|
1119
|
+
onChompKeep: s,
|
|
1120
|
+
onComment: n
|
|
1121
|
+
}) : JSON.stringify(this);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
function Y(t) {
|
|
1125
|
+
let e = L(t) ? t.value : t;
|
|
1126
|
+
return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null;
|
|
1127
|
+
}
|
|
1128
|
+
class ue extends ve {
|
|
1129
|
+
constructor() {
|
|
1130
|
+
super(), this.add = _.prototype.add.bind(this), this.delete = _.prototype.delete.bind(this), this.get = _.prototype.get.bind(this), this.has = _.prototype.has.bind(this), this.set = _.prototype.set.bind(this), this.tag = ue.tag;
|
|
1131
|
+
}
|
|
1132
|
+
/**
|
|
1133
|
+
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
1134
|
+
* but TypeScript won't allow widening the signature of a child method.
|
|
1135
|
+
*/
|
|
1136
|
+
toJSON(e, n) {
|
|
1137
|
+
if (!n)
|
|
1138
|
+
return super.toJSON(e);
|
|
1139
|
+
const s = /* @__PURE__ */ new Map();
|
|
1140
|
+
n?.onCreate && n.onCreate(s);
|
|
1141
|
+
for (const i of this.items) {
|
|
1142
|
+
let r, o;
|
|
1143
|
+
if (j(i) ? (r = C(i.key, "", n), o = C(i.value, r, n)) : r = C(i, "", n), s.has(r))
|
|
1144
|
+
throw new Error("Ordered maps must not include duplicate keys");
|
|
1145
|
+
s.set(r, o);
|
|
1146
|
+
}
|
|
1147
|
+
return s;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
ue.tag = "tag:yaml.org,2002:omap";
|
|
1151
|
+
class de extends _ {
|
|
1152
|
+
constructor(e) {
|
|
1153
|
+
super(e), this.tag = de.tag;
|
|
1154
|
+
}
|
|
1155
|
+
add(e) {
|
|
1156
|
+
let n;
|
|
1157
|
+
j(e) ? n = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? n = new M(e.key, null) : n = new M(e, null), T(this.items, n.key) || this.items.push(n);
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* If `keepPair` is `true`, returns the Pair matching `key`.
|
|
1161
|
+
* Otherwise, returns the value of that Pair's key.
|
|
1162
|
+
*/
|
|
1163
|
+
get(e, n) {
|
|
1164
|
+
const s = T(this.items, e);
|
|
1165
|
+
return !n && j(s) ? L(s.key) ? s.key.value : s.key : s;
|
|
1166
|
+
}
|
|
1167
|
+
set(e, n) {
|
|
1168
|
+
if (typeof n != "boolean")
|
|
1169
|
+
throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);
|
|
1170
|
+
const s = T(this.items, e);
|
|
1171
|
+
s && !n ? this.items.splice(this.items.indexOf(s), 1) : !s && n && this.items.push(new M(e));
|
|
1172
|
+
}
|
|
1173
|
+
toJSON(e, n) {
|
|
1174
|
+
return super.toJSON(e, n, Set);
|
|
1175
|
+
}
|
|
1176
|
+
toString(e, n, s) {
|
|
1177
|
+
if (!e)
|
|
1178
|
+
return JSON.stringify(this);
|
|
1179
|
+
if (this.hasAllNullValues(!0))
|
|
1180
|
+
return super.toString(Object.assign({}, e, { allNullValues: !0 }), n, s);
|
|
1181
|
+
throw new Error("Set items must all have null values");
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
de.tag = "tag:yaml.org,2002:set";
|
|
1185
|
+
Ae.dirname(Ne(import.meta.url));
|
|
1186
|
+
const tt = (t) => t, nt = (t) => t, st = (t) => t, it = (t) => ({
|
|
1187
|
+
widget: "boolean",
|
|
1188
|
+
...t
|
|
1189
|
+
}), rt = (t) => ({
|
|
1190
|
+
widget: "code",
|
|
1191
|
+
...t
|
|
1192
|
+
}), ot = (t) => ({
|
|
1193
|
+
widget: "color",
|
|
1194
|
+
...t
|
|
1195
|
+
}), lt = (t) => ({ widget: "datetime", ...t }), ft = (t) => ({
|
|
1196
|
+
widget: "hidden",
|
|
1197
|
+
...t
|
|
1198
|
+
}), ct = (t) => ({
|
|
1199
|
+
widget: "file",
|
|
1200
|
+
...t
|
|
1201
|
+
}), at = (t) => ({
|
|
1202
|
+
widget: "image",
|
|
1203
|
+
...t
|
|
1204
|
+
}), ut = (t) => ({
|
|
1205
|
+
widget: "list",
|
|
1206
|
+
...t
|
|
1207
|
+
}), dt = (t) => ({
|
|
1208
|
+
widget: "map",
|
|
1209
|
+
...t
|
|
1210
|
+
}), gt = (t) => ({
|
|
1211
|
+
widget: "number",
|
|
1212
|
+
...t
|
|
1213
|
+
}), ht = (t) => ({
|
|
1214
|
+
widget: "object",
|
|
1215
|
+
...t
|
|
1216
|
+
}), pt = (t) => ({ widget: "relation", ...t }), mt = (t) => ({
|
|
1217
|
+
widget: "select",
|
|
1218
|
+
...t
|
|
1219
|
+
}), bt = (t) => ({
|
|
1220
|
+
widget: "string",
|
|
1221
|
+
...t
|
|
1222
|
+
}), yt = (t) => ({
|
|
1223
|
+
widget: "text",
|
|
1224
|
+
...t
|
|
1225
|
+
});
|
|
1226
|
+
export {
|
|
1227
|
+
it as defineBooleanWidget,
|
|
1228
|
+
rt as defineCodeWidget,
|
|
1229
|
+
ot as defineColorWidget,
|
|
1230
|
+
tt as defineConfig,
|
|
1231
|
+
lt as defineDateTimeWidget,
|
|
1232
|
+
st as defineFileCollection,
|
|
1233
|
+
ct as defineFileWidget,
|
|
1234
|
+
nt as defineFolderCollection,
|
|
1235
|
+
ft as defineHiddenWidget,
|
|
1236
|
+
at as defineImageWidget,
|
|
1237
|
+
ut as defineListWidget,
|
|
1238
|
+
dt as defineMapWidget,
|
|
1239
|
+
gt as defineNumberWidget,
|
|
1240
|
+
ht as defineObjectWidget,
|
|
1241
|
+
pt as defineRelationWidget,
|
|
1242
|
+
mt as defineSelectWidget,
|
|
1243
|
+
bt as defineStringWidget,
|
|
1244
|
+
yt as defineTextWidget
|
|
1245
|
+
};
|